diff options
author | 2020-06-13 07:09:59 +0000 | |
---|---|---|
committer | 2020-06-13 07:09:59 +0000 | |
commit | 26cc0c6b48baa8aa278040ab9c1d48bfb521d5c3 (patch) | |
tree | ddee1a54b698ad8902cb57a305df56b8f92c29df /sys | |
parent | remove the reference to tun(4), as suggested by kaya saman, (diff) | |
download | wireguard-openbsd-26cc0c6b48baa8aa278040ab9c1d48bfb521d5c3.tar.xz wireguard-openbsd-26cc0c6b48baa8aa278040ab9c1d48bfb521d5c3.zip |
Some new firmware for ConnectX-5 tries to give pages back when
going from boot to regular operation, which it indicates by returning a
negative number of pages from the QUERY_PAGES operation. We previously
interpreted this as an unsigned number, causing an allocation failure.
We're not actually retrieving the pages and returning them to UVM yet,
but if the firmware's memory requirements become more complicated, we'll
probably have to do that.
problem reported and fix tested by Hrvoje Popovski
ok dlg@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/if_mcx.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/dev/pci/if_mcx.c b/sys/dev/pci/if_mcx.c index 55937f094fe..4471acef409 100644 --- a/sys/dev/pci/if_mcx.c +++ b/sys/dev/pci/if_mcx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mcx.c,v 1.52 2020/06/12 11:41:48 deraadt Exp $ */ +/* $OpenBSD: if_mcx.c,v 1.53 2020/06/13 07:09:59 jmatthew Exp $ */ /* * Copyright (c) 2017 David Gwynne <dlg@openbsd.org> @@ -523,7 +523,7 @@ struct mcx_cmd_query_pages_out { uint32_t cmd_syndrome; uint8_t cmd_reserved1[2]; uint16_t cmd_func_id; - uint32_t cmd_num_pages; + int32_t cmd_num_pages; } __packed __aligned(4); struct mcx_cmd_manage_pages_in { @@ -3049,7 +3049,7 @@ free: static int mcx_query_pages(struct mcx_softc *sc, uint16_t type, - uint32_t *npages, uint16_t *func_id) + int32_t *npages, uint16_t *func_id) { struct mcx_cmdq_entry *cqe; struct mcx_cmd_query_pages_in *in; @@ -3205,7 +3205,7 @@ free: static int mcx_pages(struct mcx_softc *sc, struct mcx_hwmem *mhm, uint16_t type) { - uint32_t npages; + int32_t npages; uint16_t func_id; if (mcx_query_pages(sc, type, &npages, &func_id) != 0) { @@ -3213,7 +3213,7 @@ mcx_pages(struct mcx_softc *sc, struct mcx_hwmem *mhm, uint16_t type) return (-1); } - if (npages == 0) + if (npages < 1) return (0); if (mcx_hwmem_alloc(sc, mhm, npages) != 0) { |