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 2/7] x86/viridian: fix xen-hvmcrash when vp_assist page is present
Date: Fri, 17 Mar 2017 09:57:08 +0000 [thread overview]
Message-ID: <1489744633-28760-3-git-send-email-paul.durrant@citrix.com> (raw)
In-Reply-To: <1489744633-28760-1-git-send-email-paul.durrant@citrix.com>
Currently use of xen-hvmcrash will cause an immediate domain_crash() in
initialize_vp_assist() because it is called from viridian_load_vcpu_ctxt()
without having first cleared any previous mapping.
This patch makes initialize_vp_assist() responsible for clearing previous
mappings, if necessary.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
xen/arch/x86/hvm/viridian.c | 50 +++++++++++++++++++-------------------
xen/include/asm-x86/hvm/viridian.h | 1 +
2 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c
index d741e81..59d76d5 100644
--- a/xen/arch/x86/hvm/viridian.c
+++ b/xen/arch/x86/hvm/viridian.c
@@ -276,6 +276,22 @@ static void enable_hypercall_page(struct domain *d)
put_page_and_type(page);
}
+static void teardown_vp_assist(struct vcpu *v)
+{
+ void *va = v->arch.hvm_vcpu.viridian.vp_assist.va;
+ struct page_info *page;
+
+ if ( !va )
+ return;
+
+ v->arch.hvm_vcpu.viridian.vp_assist.va = NULL;
+
+ page = mfn_to_page(domain_page_map_to_mfn(va));
+
+ unmap_domain_page_global(va);
+ put_page_and_type(page);
+}
+
static void initialize_vp_assist(struct vcpu *v)
{
struct domain *d = v->domain;
@@ -288,6 +304,14 @@ static void initialize_vp_assist(struct vcpu *v)
* enlightenment.
*/
+ if ( v->arch.hvm_vcpu.viridian.vp_assist.va )
+ {
+ if ( v->arch.hvm_vcpu.viridian.vp_assist.gmfn == gmfn )
+ return;
+
+ teardown_vp_assist(v);
+ }
+
if ( !page )
goto fail;
@@ -306,15 +330,8 @@ static void initialize_vp_assist(struct vcpu *v)
clear_page(va);
- /*
- * If we overwrite an existing address here then something has
- * gone wrong and a domain page will leak. Instead crash the
- * domain to make the problem obvious.
- */
- if ( v->arch.hvm_vcpu.viridian.vp_assist.va )
- domain_crash(d);
-
v->arch.hvm_vcpu.viridian.vp_assist.va = va;
+ v->arch.hvm_vcpu.viridian.vp_assist.gmfn = gmfn;
return;
fail:
@@ -322,22 +339,6 @@ static void initialize_vp_assist(struct vcpu *v)
page ? page_to_mfn(page) : mfn_x(INVALID_MFN));
}
-static void teardown_vp_assist(struct vcpu *v)
-{
- void *va = v->arch.hvm_vcpu.viridian.vp_assist.va;
- struct page_info *page;
-
- if ( !va )
- return;
-
- v->arch.hvm_vcpu.viridian.vp_assist.va = NULL;
-
- page = mfn_to_page(domain_page_map_to_mfn(va));
-
- unmap_domain_page_global(va);
- put_page_and_type(page);
-}
-
void viridian_start_apic_assist(struct vcpu *v, int vector)
{
uint32_t *va = v->arch.hvm_vcpu.viridian.vp_assist.va;
@@ -513,7 +514,6 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val)
case HV_X64_MSR_VP_ASSIST_PAGE:
perfc_incr(mshv_wrmsr_apic_msr);
- teardown_vp_assist(v); /* release any previous mapping */
v->arch.hvm_vcpu.viridian.vp_assist.msr.raw = val;
dump_vp_assist(v);
if ( v->arch.hvm_vcpu.viridian.vp_assist.msr.fields.enabled )
diff --git a/xen/include/asm-x86/hvm/viridian.h b/xen/include/asm-x86/hvm/viridian.h
index 271c36d..18f1f1a 100644
--- a/xen/include/asm-x86/hvm/viridian.h
+++ b/xen/include/asm-x86/hvm/viridian.h
@@ -23,6 +23,7 @@ struct viridian_vcpu
{
struct {
union viridian_vp_assist msr;
+ unsigned long gmfn;
void *va;
int vector;
} vp_assist;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-17 9:57 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 9:57 [PATCH 0/7] x86/viridian updates Paul Durrant
2017-03-17 9:57 ` [PATCH 1/7] x86/viridian: update to version 5.0a of the specification Paul Durrant
2017-03-20 11:27 ` Jan Beulich
2017-03-20 11:43 ` Paul Durrant
2017-03-20 11:54 ` Jan Beulich
2017-03-17 9:57 ` Paul Durrant [this message]
2017-03-20 11:36 ` [PATCH 2/7] x86/viridian: fix xen-hvmcrash when vp_assist page is present Jan Beulich
2017-03-20 11:50 ` Paul Durrant
2017-03-20 13:42 ` Paul Durrant
2017-03-20 13:58 ` Jan Beulich
2017-03-17 9:57 ` [PATCH 3/7] x86/viridian: don't put Xen version information in CPUID leaf 2 Paul Durrant
2017-03-20 11:41 ` Jan Beulich
2017-03-20 11:57 ` Paul Durrant
2017-03-20 12:03 ` Jan Beulich
2017-03-20 13:08 ` Paul Durrant
2017-03-20 13:20 ` Jan Beulich
2017-03-17 9:57 ` [PATCH 4/7] x86/viridian: get rid of the magic numbers in CPUID leaves 1 and 2 Paul Durrant
2017-03-20 12:15 ` Jan Beulich
2017-03-20 12:56 ` Paul Durrant
2017-03-17 9:57 ` [PATCH 5/7] x86/viridian: add warnings for unimplemented hypercalls and MSRs Paul Durrant
2017-03-20 12:21 ` Jan Beulich
2017-03-20 12:54 ` Paul Durrant
2017-03-17 9:57 ` [PATCH 6/7] x86/viridian: make the threshold for HvNotifyLongSpinWait tunable Paul Durrant
2017-03-20 12:26 ` Jan Beulich
2017-03-20 12:51 ` Paul Durrant
2017-03-20 13:22 ` Jan Beulich
2017-03-20 17:03 ` Andrew Cooper
2017-03-20 17:07 ` Paul Durrant
2017-03-17 9:57 ` [PATCH 7/7] x86/viridian: implement the crash MSRs Paul Durrant
2017-03-20 12:38 ` Jan Beulich
2017-03-20 12:48 ` Paul Durrant
2017-03-20 13:29 ` Jan Beulich
2017-03-20 13:33 ` 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=1489744633-28760-3-git-send-email-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).