From a570251d000f1a092acca9d1348e80f40de9b2a2 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Wed, 13 Jul 2016 09:11:03 +0000 Subject: [PATCH] hyperv: All Hypercall parameters have same alignment requirement. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7086 --- sys/dev/hyperv/vmbus/hv_channel_mgmt.c | 2 +- sys/dev/hyperv/vmbus/hyperv_reg.h | 13 ++++++++++--- sys/dev/hyperv/vmbus/vmbus.c | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c index ed1f0690cbd..574ef383474 100644 --- a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c +++ b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c @@ -298,7 +298,7 @@ vmbus_channel_on_offer_internal(struct vmbus_softc *sc, new_channel->ch_sigevt = hyperv_dmamem_alloc( bus_get_dma_tag(sc->vmbus_dev), - HYPERCALL_SIGEVTIN_ALIGN, 0, sizeof(struct hypercall_sigevt_in), + HYPERCALL_PARAM_ALIGN, 0, sizeof(struct hypercall_sigevt_in), &new_channel->ch_sigevt_dma, BUS_DMA_WAITOK | BUS_DMA_ZERO); if (new_channel->ch_sigevt == NULL) { device_printf(sc->vmbus_dev, "sigevt alloc failed\n"); diff --git a/sys/dev/hyperv/vmbus/hyperv_reg.h b/sys/dev/hyperv/vmbus/hyperv_reg.h index 20f48106062..6cb5e9dbfad 100644 --- a/sys/dev/hyperv/vmbus/hyperv_reg.h +++ b/sys/dev/hyperv/vmbus/hyperv_reg.h @@ -153,13 +153,22 @@ /* * Hypercall input parameters */ +#define HYPERCALL_PARAM_ALIGN 8 +#if 0 +/* + * XXX + * <> requires + * input parameters size to be multiple of 8, however, many post + * message input parameters do _not_ meet this requirement. + */ +#define HYPERCALL_PARAM_SIZE_ALIGN 8 +#endif /* * HYPERCALL_POST_MESSAGE */ #define HYPERCALL_POSTMSGIN_DSIZE_MAX 240 #define HYPERCALL_POSTMSGIN_SIZE 256 -#define HYPERCALL_POSTMSGIN_ALIGN 8 struct hypercall_postmsg_in { uint32_t hc_connid; @@ -173,8 +182,6 @@ CTASSERT(sizeof(struct hypercall_postmsg_in) == HYPERCALL_POSTMSGIN_SIZE); /* * HYPERCALL_SIGNAL_EVENT */ -#define HYPERCALL_SIGEVTIN_ALIGN 8 - struct hypercall_sigevt_in { uint32_t hc_connid; uint16_t hc_evtflag_ofs; diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c index 14f3fef028b..36bb036d4dc 100644 --- a/sys/dev/hyperv/vmbus/vmbus.c +++ b/sys/dev/hyperv/vmbus/vmbus.c @@ -130,7 +130,7 @@ vmbus_msghc_alloc(bus_dma_tag_t parent_dtag) mh = malloc(sizeof(*mh), M_DEVBUF, M_WAITOK | M_ZERO); mh->mh_inprm = hyperv_dmamem_alloc(parent_dtag, - HYPERCALL_POSTMSGIN_ALIGN, 0, HYPERCALL_POSTMSGIN_SIZE, + HYPERCALL_PARAM_ALIGN, 0, HYPERCALL_POSTMSGIN_SIZE, &mh->mh_inprm_dma, BUS_DMA_WAITOK); if (mh->mh_inprm == NULL) { free(mh, M_DEVBUF);