Download raw body.
[PATCH 1/7] hyperv: revoke ring GPADL before freeing it, don't sleep when cold
[PATCH 2/7] hyperv: attach drivers to channels regardless of monitor notification
[PATCH 3/7] hvs: use 10-byte commands with the Hyper-V virtual DVD drive
hv_channel_ring_destroy() returned the ring pages to the kernel and
only then asked the host to tear down the GPADL that maps them, so
the host could still access memory that had been reused. Tear the
GPADL down first.
hv_channel_close() could also sleep while cold. Use HCF_NOSLEEP
there like the other cold paths. Both are reached when a driver
gives up on its channel during autoconf, e.g. when hvn(4) fails to
attach.
---
sys/dev/pv/hyperv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git sys/dev/pv/hyperv.c sys/dev/pv/hyperv.c
index afb7eaaeb80..0c430a0345a 100644
--- sys/dev/pv/hyperv.c
+++ sys/dev/pv/hyperv.c
@@ -1158,9 +1158,10 @@ hv_channel_ring_create(struct hv_channel *ch, uint32_t buflen)
void
hv_channel_ring_destroy(struct hv_channel *ch)
{
+ /* Revoke host access to the ring before returning its pages. */
+ hv_handle_free(ch, ch->ch_ring_gpadl);
km_free(ch->ch_ring, ch->ch_ring_size, &kv_any, &kp_zero);
ch->ch_ring = NULL;
- hv_handle_free(ch, ch->ch_ring_gpadl);
memset(&ch->ch_wrd, 0, sizeof(ch->ch_wrd));
memset(&ch->ch_rrd, 0, sizeof(ch->ch_rrd));
@@ -1227,7 +1228,8 @@ hv_channel_close(struct hv_channel *ch)
cmd.chm_chanid = ch->ch_id;
ch->ch_state = HV_CHANSTATE_CLOSING;
- rv = hv_cmd(sc, &cmd, sizeof(cmd), NULL, 0, HCF_NOREPLY);
+ rv = hv_cmd(sc, &cmd, sizeof(cmd), NULL, 0,
+ HCF_NOREPLY | (cold ? HCF_NOSLEEP : 0));
if (rv) {
DPRINTF("%s: CHCLOSE failed with %d\n",
sc->sc_dev.dv_xname, rv);
[PATCH 1/7] hyperv: revoke ring GPADL before freeing it, don't sleep when cold
[PATCH 2/7] hyperv: attach drivers to channels regardless of monitor notification
[PATCH 3/7] hvs: use 10-byte commands with the Hyper-V virtual DVD drive