diff mbox series

[v2,3/6] x86/viridian: drop private copy of definitions from synic.c

Message ID 20191218144233.15372-4-liuwe@microsoft.com (mailing list archive)
State New, archived
Headers show
Series Implement Hyper-V reference TSC based clock source | expand

Commit Message

Wei Liu Dec. 18, 2019, 2:42 p.m. UTC
Use hyperv-tlfs.h instead. No functional change intended.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
 xen/arch/x86/hvm/viridian/synic.c | 68 ++++++++-----------------------
 1 file changed, 16 insertions(+), 52 deletions(-)

Comments

Paul Durrant Dec. 18, 2019, 2:57 p.m. UTC | #1
> -----Original Message-----
> From: Wei Liu <wei.liu.xen@gmail.com> On Behalf Of Wei Liu
> Sent: 18 December 2019 14:43
> To: Xen Development List <xen-devel@lists.xenproject.org>
> Cc: Michael Kelley <mikelley@microsoft.com>; Durrant, Paul
> <pdurrant@amazon.com>; Wei Liu <liuwe@microsoft.com>; Paul Durrant
> <paul@xen.org>; Jan Beulich <jbeulich@suse.com>; Andrew Cooper
> <andrew.cooper3@citrix.com>; Wei Liu <wl@xen.org>; Roger Pau Monné
> <roger.pau@citrix.com>
> Subject: [PATCH v2 3/6] x86/viridian: drop private copy of definitions
> from synic.c
> 
> Use hyperv-tlfs.h instead. No functional change intended.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

Reviewed-by: Paul Durrant <pdurrant@amazon.com>
diff mbox series

Patch

diff --git a/xen/arch/x86/hvm/viridian/synic.c b/xen/arch/x86/hvm/viridian/synic.c
index 2791021bcc..54c62f843f 100644
--- a/xen/arch/x86/hvm/viridian/synic.c
+++ b/xen/arch/x86/hvm/viridian/synic.c
@@ -12,58 +12,22 @@ 
 #include <xen/version.h>
 
 #include <asm/apic.h>
+#include <asm/guest/hyperv-tlfs.h>
 #include <asm/hvm/support.h>
 #include <asm/hvm/vlapic.h>
 
 #include "private.h"
 
-typedef struct _HV_VIRTUAL_APIC_ASSIST
-{
-    uint32_t no_eoi:1;
-    uint32_t reserved_zero:31;
-} HV_VIRTUAL_APIC_ASSIST;
-
-typedef union _HV_VP_ASSIST_PAGE
-{
-    HV_VIRTUAL_APIC_ASSIST ApicAssist;
-    uint8_t ReservedZBytePadding[PAGE_SIZE];
-} HV_VP_ASSIST_PAGE;
-
-typedef enum HV_MESSAGE_TYPE {
-    HvMessageTypeNone,
-    HvMessageTimerExpired = 0x80000010,
-} HV_MESSAGE_TYPE;
-
-typedef struct HV_MESSAGE_FLAGS {
-    uint8_t MessagePending:1;
-    uint8_t Reserved:7;
-} HV_MESSAGE_FLAGS;
-
-typedef struct HV_MESSAGE_HEADER {
-    HV_MESSAGE_TYPE MessageType;
-    uint16_t Reserved1;
-    HV_MESSAGE_FLAGS MessageFlags;
-    uint8_t PayloadSize;
-    uint64_t Reserved2;
-} HV_MESSAGE_HEADER;
-
-#define HV_MESSAGE_SIZE 256
-#define HV_MESSAGE_MAX_PAYLOAD_QWORD_COUNT 30
-
-typedef struct HV_MESSAGE {
-    HV_MESSAGE_HEADER Header;
-    uint64_t Payload[HV_MESSAGE_MAX_PAYLOAD_QWORD_COUNT];
-} HV_MESSAGE;
 
 void __init __maybe_unused build_assertions(void)
 {
-    BUILD_BUG_ON(sizeof(HV_MESSAGE) != HV_MESSAGE_SIZE);
+    BUILD_BUG_ON(sizeof(struct hv_message) != HV_MESSAGE_SIZE);
 }
 
 void viridian_apic_assist_set(const struct vcpu *v)
 {
     struct viridian_vcpu *vv = v->arch.hvm.viridian;
-    HV_VP_ASSIST_PAGE *ptr = vv->vp_assist.ptr;
+    struct hv_vp_assist_page *ptr = vv->vp_assist.ptr;
 
     if ( !ptr )
         return;
@@ -77,18 +41,18 @@  void viridian_apic_assist_set(const struct vcpu *v)
         domain_crash(v->domain);
 
     vv->apic_assist_pending = true;
-    ptr->ApicAssist.no_eoi = 1;
+    ptr->apic_assist = 1;
 }
 
 bool viridian_apic_assist_completed(const struct vcpu *v)
 {
     struct viridian_vcpu *vv = v->arch.hvm.viridian;
-    HV_VP_ASSIST_PAGE *ptr = vv->vp_assist.ptr;
+    struct hv_vp_assist_page *ptr = vv->vp_assist.ptr;
 
     if ( !ptr )
         return false;
 
-    if ( vv->apic_assist_pending && !ptr->ApicAssist.no_eoi )
+    if ( vv->apic_assist_pending && !ptr->apic_assist )
     {
         /* An EOI has been avoided */
         vv->apic_assist_pending = false;
@@ -101,12 +65,12 @@  bool viridian_apic_assist_completed(const struct vcpu *v)
 void viridian_apic_assist_clear(const struct vcpu *v)
 {
     struct viridian_vcpu *vv = v->arch.hvm.viridian;
-    HV_VP_ASSIST_PAGE *ptr = vv->vp_assist.ptr;
+    struct hv_vp_assist_page *ptr = vv->vp_assist.ptr;
 
     if ( !ptr )
         return;
 
-    ptr->ApicAssist.no_eoi = 0;
+    ptr->apic_assist = 0;
     vv->apic_assist_pending = false;
 }
 
@@ -358,7 +322,7 @@  bool viridian_synic_deliver_timer_msg(struct vcpu *v, unsigned int sintx,
 {
     struct viridian_vcpu *vv = v->arch.hvm.viridian;
     const union viridian_sint_msr *vs = &vv->sint[sintx];
-    HV_MESSAGE *msg = vv->simp.ptr;
+    struct hv_message *msg = vv->simp.ptr;
     struct {
         uint32_t TimerIndex;
         uint32_t Reserved;
@@ -382,19 +346,19 @@  bool viridian_synic_deliver_timer_msg(struct vcpu *v, unsigned int sintx,
 
     msg += sintx;
 
-    if ( msg->Header.MessageType != HvMessageTypeNone )
+    if ( msg->header.message_type != HVMSG_NONE )
     {
-        msg->Header.MessageFlags.MessagePending = 1;
+        msg->header.message_flags.msg_pending = 1;
         __set_bit(sintx, &vv->msg_pending);
         return false;
     }
 
-    msg->Header.MessageType = HvMessageTimerExpired;
-    msg->Header.MessageFlags.MessagePending = 0;
-    msg->Header.PayloadSize = sizeof(payload);
+    msg->header.message_type = HVMSG_TIMER_EXPIRED;
+    msg->header.message_flags.msg_pending = 0;
+    msg->header.payload_size = sizeof(payload);
 
-    BUILD_BUG_ON(sizeof(payload) > sizeof(msg->Payload));
-    memcpy(msg->Payload, &payload, sizeof(payload));
+    BUILD_BUG_ON(sizeof(payload) > sizeof(msg->u.payload));
+    memcpy(msg->u.payload, &payload, sizeof(payload));
 
     if ( !vs->mask )
         vlapic_set_irq(vcpu_vlapic(v), vs->vector, 0);