From: Roman Kagan <rkagan@virtuozzo.com>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
<x86@kernel.org>, Haiyang Zhang <haiyangz@microsoft.com>,
<kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<devel@linuxdriverproject.org>,
"Denis V . Lunev" <den@openvz.org>,
Roman Kagan <rkagan@virtuozzo.com>
Subject: [PATCH 15/15] hyperv: redefine hv_message without bitfields
Date: Tue, 20 Dec 2016 18:56:02 +0300 [thread overview]
Message-ID: <20161220155602.6298-16-rkagan@virtuozzo.com> (raw)
In-Reply-To: <20161220155602.6298-1-rkagan@virtuozzo.com>
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@virtuozzo.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
next prev parent reply other threads:[~2016-12-20 16:42 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-20 15:55 [PATCH 00/15] hyperv: more stuff to uapi + cleanup Roman Kagan
2016-12-20 15:55 ` [PATCH 01/15] hyperv: consolidate TSC ref page definitions Roman Kagan
2016-12-20 20:57 ` KY Srinivasan
2016-12-21 6:25 ` Roman Kagan
2016-12-20 15:55 ` [PATCH 02/15] hyperv: uapi-fy synic event flags definitions Roman Kagan
2016-12-20 17:24 ` Stephen Hemminger
2016-12-21 6:33 ` Roman Kagan
2016-12-21 10:58 ` kbuild test robot
2016-12-21 18:58 ` KY Srinivasan
2016-12-20 15:55 ` [PATCH 03/15] hyperv: use standard bitops Roman Kagan
2016-12-21 12:00 ` Olaf Hering
2016-12-21 13:23 ` Roman Kagan
2016-12-22 12:33 ` Paolo Bonzini
2016-12-21 19:08 ` KY Srinivasan
2016-12-20 15:55 ` [PATCH 04/15] hyperv: define VMBus message type Roman Kagan
2016-12-20 15:55 ` [PATCH 05/15] hyperv: GFP_ATOMIC -> GFP_KERNEL Roman Kagan
2016-12-20 15:55 ` [PATCH 06/15] hyperv: avoid unnecessary vmalloc Roman Kagan
2016-12-21 19:19 ` KY Srinivasan
2016-12-20 15:55 ` [PATCH 07/15] hyperv: dedup cpuid definitions Roman Kagan
2016-12-20 15:55 ` [PATCH 08/15] hyperv: dedup crash msr related definitions Roman Kagan
2016-12-20 15:55 ` [PATCH 09/15] hyperv: unify Hyper-V msr definitions Roman Kagan
2016-12-20 15:55 ` [PATCH 10/15] hyperv: uapi-fy PostMessage and SignalEvent hypercall structures Roman Kagan
2016-12-21 19:27 ` KY Srinivasan
2016-12-20 15:55 ` [PATCH 11/15] hyperv: uapi-fy monitored notification structures Roman Kagan
2016-12-20 15:55 ` [PATCH 12/15] hyperv: move VMBus connection ids to uapi Roman Kagan
2016-12-20 17:25 ` Stephen Hemminger
2016-12-21 6:29 ` Roman Kagan
2016-12-21 12:18 ` Christoph Hellwig
2016-12-21 12:59 ` Roman Kagan
2016-12-21 14:26 ` Christoph Hellwig
2016-12-21 14:39 ` Roman Kagan
2016-12-21 15:39 ` Paolo Bonzini
2016-12-21 15:43 ` Christoph Hellwig
2016-12-21 17:25 ` Paolo Bonzini
2016-12-21 17:50 ` Stephen Hemminger
2016-12-21 17:53 ` Paolo Bonzini
2016-12-21 17:58 ` Christoph Hellwig
2016-12-21 18:02 ` Stephen Hemminger
2016-12-21 19:54 ` KY Srinivasan
2016-12-28 17:09 ` Roman Kagan
2016-12-29 18:29 ` Stephen Hemminger
2017-01-02 8:19 ` Paolo Bonzini
2017-01-09 8:32 ` Roman Kagan
2017-01-09 8:40 ` hpa
2017-01-09 8:58 ` Roman Kagan
2017-01-09 9:02 ` Paolo Bonzini
2017-01-02 19:39 ` Stephen Hemminger
2017-01-03 9:32 ` Paolo Bonzini
2016-12-20 15:56 ` [PATCH 13/15] hyperv: move function close to its only callsite Roman Kagan
2016-12-20 15:56 ` [PATCH 14/15] hyperv_vmbus: drop unused definitions Roman Kagan
2016-12-20 15:56 ` Roman Kagan [this message]
2016-12-21 18:00 ` [PATCH 00/15] hyperv: more stuff to uapi + cleanup KY Srinivasan
2016-12-28 16:57 ` Roman Kagan
2016-12-30 19:45 ` KY Srinivasan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161220155602.6298-16-rkagan@virtuozzo.com \
--to=rkagan@virtuozzo.com \
--cc=den@openvz.org \
--cc=devel@linuxdriverproject.org \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).