From: Paul Durrant <paul.durrant@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Paul Durrant <paul.durrant@citrix.com>,
Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v3 3/5] viridian: define type for the 'virtual VP assist page'
Date: Wed, 7 Nov 2018 10:52:21 +0000 [thread overview]
Message-ID: <20181107105223.27013-4-paul.durrant@citrix.com> (raw)
In-Reply-To: <20181107105223.27013-1-paul.durrant@citrix.com>
The specification [1] defines a type so we should use it, rather than just
OR-ing and AND-ing magic bits.
No functional change.
NOTE: The type defined in the specification does include an anonymous
sub-struct in the page type but, as we currently use only the first
element, the struct declaration has been omitted.
[1] https://github.com/MicrosoftDocs/Virtualization-Documentation/raw/live/tlfs/Hypervisor%20Top%20Level%20Functional%20Specification%20v5.0C.pdf
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
v3:
- Move the typedef of HV_VP_ASSIST_PAGE into viridian.h so that it can
be used in the declaration of struct viridian_vcpu
---
xen/arch/x86/hvm/viridian/synic.c | 52 +++++++++++++++++++++++---------------
xen/include/asm-x86/hvm/viridian.h | 4 ++-
2 files changed, 35 insertions(+), 21 deletions(-)
diff --git a/xen/arch/x86/hvm/viridian/synic.c b/xen/arch/x86/hvm/viridian/synic.c
index 366608208f..d8d6f6e1c9 100644
--- a/xen/arch/x86/hvm/viridian/synic.c
+++ b/xen/arch/x86/hvm/viridian/synic.c
@@ -16,6 +16,18 @@
#include "private.h"
+typedef struct _HV_VIRTUAL_APIC_ASSIST
+{
+ uint32_t no_eoi:1;
+ uint32_t reserved_zero:31;
+} HV_VIRTUAL_APIC_ASSIST;
+
+union _HV_VP_ASSIST_PAGE
+{
+ HV_VIRTUAL_APIC_ASSIST ApicAssist;
+ uint8_t ReservedZBytePadding[PAGE_SIZE];
+};
+
static void dump_vp_assist(const struct vcpu *v)
{
const union viridian_page_msr *va = &v->arch.hvm.viridian.vp_assist.msr;
@@ -32,9 +44,9 @@ static void initialize_vp_assist(struct vcpu *v)
struct domain *d = v->domain;
unsigned long gmfn = v->arch.hvm.viridian.vp_assist.msr.fields.pfn;
struct page_info *page = get_page_from_gfn(d, gmfn, NULL, P2M_ALLOC);
- void *va;
+ HV_VP_ASSIST_PAGE *ptr;
- ASSERT(!v->arch.hvm.viridian.vp_assist.va);
+ ASSERT(!v->arch.hvm.viridian.vp_assist.ptr);
if ( !page )
goto fail;
@@ -45,16 +57,16 @@ static void initialize_vp_assist(struct vcpu *v)
goto fail;
}
- va = __map_domain_page_global(page);
- if ( !va )
+ ptr = __map_domain_page_global(page);
+ if ( !ptr )
{
put_page_and_type(page);
goto fail;
}
- clear_page(va);
+ clear_page(ptr);
- v->arch.hvm.viridian.vp_assist.va = va;
+ v->arch.hvm.viridian.vp_assist.ptr = ptr;
return;
fail:
@@ -64,25 +76,25 @@ static void initialize_vp_assist(struct vcpu *v)
static void teardown_vp_assist(struct vcpu *v)
{
- void *va = v->arch.hvm.viridian.vp_assist.va;
+ HV_VP_ASSIST_PAGE *ptr = v->arch.hvm.viridian.vp_assist.ptr;
struct page_info *page;
- if ( !va )
+ if ( !ptr )
return;
- v->arch.hvm.viridian.vp_assist.va = NULL;
+ v->arch.hvm.viridian.vp_assist.ptr = NULL;
- page = mfn_to_page(domain_page_map_to_mfn(va));
+ page = mfn_to_page(domain_page_map_to_mfn(ptr));
- unmap_domain_page_global(va);
+ unmap_domain_page_global(ptr);
put_page_and_type(page);
}
void viridian_apic_assist_set(struct vcpu *v)
{
- uint32_t *va = v->arch.hvm.viridian.vp_assist.va;
+ HV_VP_ASSIST_PAGE *ptr = v->arch.hvm.viridian.vp_assist.ptr;
- if ( !va )
+ if ( !ptr )
return;
/*
@@ -94,18 +106,18 @@ void viridian_apic_assist_set(struct vcpu *v)
domain_crash(v->domain);
v->arch.hvm.viridian.vp_assist.pending = true;
- *va |= 1u;
+ ptr->ApicAssist.no_eoi = 1;
}
bool viridian_apic_assist_completed(struct vcpu *v)
{
- uint32_t *va = v->arch.hvm.viridian.vp_assist.va;
+ HV_VP_ASSIST_PAGE *ptr = v->arch.hvm.viridian.vp_assist.ptr;
- if ( !va )
+ if ( !ptr )
return false;
if ( v->arch.hvm.viridian.vp_assist.pending &&
- !(*va & 1u) )
+ !ptr->ApicAssist.no_eoi )
{
/* An EOI has been avoided */
v->arch.hvm.viridian.vp_assist.pending = false;
@@ -117,12 +129,12 @@ bool viridian_apic_assist_completed(struct vcpu *v)
void viridian_apic_assist_clear(struct vcpu *v)
{
- uint32_t *va = v->arch.hvm.viridian.vp_assist.va;
+ HV_VP_ASSIST_PAGE *ptr = v->arch.hvm.viridian.vp_assist.ptr;
- if ( !va )
+ if ( !ptr )
return;
- *va &= ~1u;
+ ptr->ApicAssist.no_eoi = 0;
v->arch.hvm.viridian.vp_assist.pending = false;
}
diff --git a/xen/include/asm-x86/hvm/viridian.h b/xen/include/asm-x86/hvm/viridian.h
index 5ff83a46e5..22f14a526e 100644
--- a/xen/include/asm-x86/hvm/viridian.h
+++ b/xen/include/asm-x86/hvm/viridian.h
@@ -20,11 +20,13 @@ union viridian_page_msr
} fields;
};
+typedef union _HV_VP_ASSIST_PAGE HV_VP_ASSIST_PAGE;
+
struct viridian_vcpu
{
struct {
union viridian_page_msr msr;
- void *va;
+ HV_VP_ASSIST_PAGE *ptr;
bool pending;
} vp_assist;
uint64_t crash_param[5];
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-11-07 10:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-07 10:52 [PATCH v3 0/5] (remainder of) viridian cleanup Paul Durrant
2018-11-07 10:52 ` [PATCH v3 1/5] viridian: separate interrupt related enlightenment implementations Paul Durrant
2018-11-07 11:36 ` Roger Pau Monné
2018-11-07 10:52 ` [PATCH v3 2/5] viridian: separate time " Paul Durrant
2018-11-07 11:43 ` Roger Pau Monné
2018-11-07 10:52 ` Paul Durrant [this message]
2018-11-07 11:48 ` [PATCH v3 3/5] viridian: define type for the 'virtual VP assist page' Roger Pau Monné
2018-11-07 11:50 ` Paul Durrant
2018-11-09 10:24 ` Jan Beulich
2018-11-09 10:31 ` Paul Durrant
2018-11-07 10:52 ` [PATCH v3 4/5] tools/misc: fix hard tabs in xen-hvmctx.c Paul Durrant
2018-11-07 13:08 ` Wei Liu
2018-11-07 13:09 ` Paul Durrant
2018-11-07 10:52 ` [PATCH v3 5/5] viridian: introduce struct viridian_page Paul Durrant
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=20181107105223.27013-4-paul.durrant@citrix.com \
--to=paul.durrant@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=xen-devel@lists.xenproject.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).