[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161220155602.6298-16-rkagan@virtuozzo.com>
Date: Tue, 20 Dec 2016 18:56:02 +0300
From: Roman Kagan <rkagan@...tuozzo.com>
To: Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>
CC: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, <x86@...nel.org>,
Haiyang Zhang <haiyangz@...rosoft.com>, <kvm@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <devel@...uxdriverproject.org>,
"Denis V . Lunev" <den@...nvz.org>,
Roman Kagan <rkagan@...tuozzo.com>
Subject: [PATCH 15/15] hyperv: redefine hv_message without bitfields
This brings more symmetry in the API.
The downside is that this changes the userspace-visible structure.
Hopefully no userspace code had a chance to use it yet.
Signed-off-by: Roman Kagan <rkagan@...tuozzo.com>
---
arch/x86/include/uapi/asm/hyperv.h | 32 +++++---------------------------
drivers/hv/hyperv_vmbus.h | 2 +-
arch/x86/kvm/hyperv.c | 10 +++++-----
drivers/hv/channel_mgmt.c | 6 +++---
drivers/hv/vmbus_drv.c | 2 +-
5 files changed, 15 insertions(+), 37 deletions(-)
diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
index 5d6e525..89ef9c2 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -276,7 +276,8 @@ struct hv_ref_tsc_page {
/* Define synthetic interrupt controller message constants. */
#define HV_MESSAGE_SIZE (256)
#define HV_MESSAGE_PAYLOAD_BYTE_COUNT (240)
-#define HV_MESSAGE_PAYLOAD_QWORD_COUNT (30)
+
+#define HV_MESSAGE_FLAG_PENDING (1)
/* Define hypervisor message types. */
enum hv_message_type {
@@ -308,42 +309,19 @@ enum hv_message_type {
HVMSG_X64_LEGACY_FP_ERROR = 0x80010005
};
-/* Define synthetic interrupt controller message flags. */
-union hv_message_flags {
- __u8 asu8;
- struct {
- __u8 msg_pending:1;
- __u8 reserved:7;
- };
-};
-
-/* Define port identifier type. */
-union hv_port_id {
- __u32 asu32;
- struct {
- __u32 id:24;
- __u32 reserved:8;
- } u;
-};
-
/* Define synthetic interrupt controller message header. */
struct hv_message_header {
__u32 message_type;
__u8 payload_size;
- union hv_message_flags message_flags;
+ __u8 message_flags;
__u8 reserved[2];
- union {
- __u64 sender;
- union hv_port_id port;
- };
+ __u64 origination_id;
};
/* Define synthetic interrupt controller message format. */
struct hv_message {
struct hv_message_header header;
- union {
- __u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
- } u;
+ __u64 payload[HV_MESSAGE_PAYLOAD_BYTE_COUNT / 8];
};
/* Define the synthetic interrupt message page layout. */
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 8ce6d64..87713cc 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -260,7 +260,7 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
*/
mb();
- if (msg->header.message_flags.msg_pending) {
+ if (msg->header.message_flags & HV_MESSAGE_FLAG_PENDING) {
/*
* This will cause message queue rescan to
* possibly deliver another msg from the
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index c7db112..546dddc 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -137,7 +137,7 @@ static void synic_clear_sint_msg_pending(struct kvm_vcpu_hv_synic *synic,
msg_page = kmap_atomic(page);
msg = &msg_page->sint_message[sint];
- msg->header.message_flags.msg_pending = 0;
+ msg->header.message_flags &= ~HV_MESSAGE_FLAG_PENDING;
kunmap_atomic(msg_page);
kvm_release_page_dirty(page);
@@ -564,10 +564,10 @@ static int synic_deliver_msg(struct kvm_vcpu_hv_synic *synic, u32 sint,
dst_msg = &msg_page->sint_message[sint];
if (sync_cmpxchg(&dst_msg->header.message_type, HVMSG_NONE,
src_msg->header.message_type) != HVMSG_NONE) {
- dst_msg->header.message_flags.msg_pending = 1;
+ dst_msg->header.message_flags |= HV_MESSAGE_FLAG_PENDING;
r = -EAGAIN;
} else {
- memcpy(&dst_msg->u.payload, &src_msg->u.payload,
+ memcpy(&dst_msg->payload, &src_msg->payload,
src_msg->header.payload_size);
dst_msg->header.message_type = src_msg->header.message_type;
dst_msg->header.payload_size = src_msg->header.payload_size;
@@ -588,7 +588,7 @@ static int stimer_send_msg(struct kvm_vcpu_hv_stimer *stimer)
struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer);
struct hv_message *msg = &stimer->msg;
struct hv_timer_message_payload *payload =
- (struct hv_timer_message_payload *)&msg->u.payload;
+ (struct hv_timer_message_payload *)&msg->payload;
payload->expiration_time = stimer->exp_time;
payload->delivery_time = get_time_ref_counter(vcpu->kvm);
@@ -653,7 +653,7 @@ static void stimer_prepare_msg(struct kvm_vcpu_hv_stimer *stimer)
{
struct hv_message *msg = &stimer->msg;
struct hv_timer_message_payload *payload =
- (struct hv_timer_message_payload *)&msg->u.payload;
+ (struct hv_timer_message_payload *)&msg->payload;
memset(&msg->header, 0, sizeof(msg->header));
msg->header.message_type = HVMSG_TIMER_EXPIRED;
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 4a5cc11..3576a0b 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -680,7 +680,7 @@ static void vmbus_wait_for_unload(void)
continue;
hdr = (struct vmbus_channel_message_header *)
- msg->u.payload;
+ msg->payload;
if (hdr->msgtype == CHANNELMSG_UNLOAD_RESPONSE)
complete(&vmbus_connection.unload_event);
@@ -1071,14 +1071,14 @@ void vmbus_onmessage(void *context)
struct vmbus_channel_message_header *hdr;
int size;
- hdr = (struct vmbus_channel_message_header *)msg->u.payload;
+ hdr = (struct vmbus_channel_message_header *)msg->payload;
size = msg->header.payload_size;
if (hdr->msgtype >= CHANNELMSG_COUNT) {
pr_err("Received invalid channel message type %d size %d\n",
hdr->msgtype, size);
print_hex_dump_bytes("", DUMP_PREFIX_NONE,
- (unsigned char *)msg->u.payload, size);
+ (unsigned char *)msg->payload, size);
return;
}
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index f6b626b..60571a8 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -883,7 +883,7 @@ void vmbus_on_msg_dpc(unsigned long data)
/* no msg */
return;
- hdr = (struct vmbus_channel_message_header *)msg->u.payload;
+ hdr = (struct vmbus_channel_message_header *)msg->payload;
if (hdr->msgtype >= CHANNELMSG_COUNT) {
WARN_ONCE(1, "unknown msgtype=%d\n", hdr->msgtype);
--
2.9.3
Powered by blists - more mailing lists