xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	David Vrabel <david.vrabel@citrix.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCHv1 4/5] x86/viridian: set x87 FIP width to 4 for Windows guests
Date: Thu, 18 Feb 2016 18:52:09 +0000	[thread overview]
Message-ID: <1455821530-4263-5-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <1455821530-4263-1-git-send-email-david.vrabel@citrix.com>

Microsoft Windows always uses a 32-bit FPU state save/restore and expects
the FCS/FDS to be saved/restored.  Ensure that for these guests, the
hypervisor does 32-bit save/restore to preserve FCS/FDS.

These guests are identified by the write to the Guest OS ID MSR.

This fixes an 0x3D BugCheck when running the Driver Verifier in 64-bit
Windows.  This BugCheck occurs because a context switch would clear
FCS/FDS and Driver Verifier would assert because the FPU state changed.

We only set FIP width if it is still in auto-mode, to allow the toolstack
to override if necessary.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 xen/arch/x86/hvm/viridian.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c
index 6bd844b..fb9f044 100644
--- a/xen/arch/x86/hvm/viridian.c
+++ b/xen/arch/x86/hvm/viridian.c
@@ -148,6 +148,30 @@ static void dump_guest_os_id(const struct domain *d)
            goi->fields.service_pack, goi->fields.build_number);
 }
 
+static void set_guest_os_id(struct domain *d, uint64_t val)
+{
+    const union viridian_guest_os_id *goi;
+
+    d->arch.hvm_domain.viridian.guest_os_id.raw = val;
+    goi = &d->arch.hvm_domain.viridian.guest_os_id;
+
+    /*
+     * Microsoft Windows only saves the lower 32-bits of FIP/FDP and
+     * can get upset if the selectors are not saved/restored by the
+     * hypervisor.
+     *
+     * Only do this if the FIP width is not in auto-mode, so this
+     * heuristic can be overriden by the toolstack.
+     */
+    if ( !d->arch.x87_fip_width )
+    {
+        if ( goi->fields.vendor == 1 && goi->fields.os == 4 )
+            d->arch.x87_fip_width = 4;
+    }
+
+    dump_guest_os_id(d);
+}
+
 static void dump_hypercall(const struct domain *d)
 {
     const union viridian_hypercall_gpa *hg;
@@ -334,8 +358,7 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val)
     {
     case VIRIDIAN_MSR_GUEST_OS_ID:
         perfc_incr(mshv_wrmsr_osid);
-        d->arch.hvm_domain.viridian.guest_os_id.raw = val;
-        dump_guest_os_id(d);
+        set_guest_os_id(d, val);
         break;
 
     case VIRIDIAN_MSR_HYPERCALL:
-- 
2.1.4

  parent reply	other threads:[~2016-02-18 18:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-18 18:52 [RFC PATCH 0/5] x86: workaround inability to fully restore FPU state David Vrabel
2016-02-18 18:52 ` [PATCHv1 1/5] domctl: Add op to get/set generic numeric parameters David Vrabel
2016-02-18 19:02   ` Andrew Cooper
2016-02-19 13:59   ` Jan Beulich
2016-02-18 18:52 ` [PATCHv1 2/5] tools/libxc: add xc_domain_get_param() and xc_domain_set_param() David Vrabel
2016-02-18 19:03   ` Andrew Cooper
2016-02-18 18:52 ` [PATCHv1 3/5] x86/fpu: Add a per-domain field to set the width of FIP/FDP David Vrabel
2016-02-18 19:13   ` Andrew Cooper
2016-02-19 10:03     ` David Vrabel
2016-02-19 14:08   ` Jan Beulich
2016-02-19 14:16     ` David Vrabel
2016-02-19 14:36       ` Jan Beulich
2016-02-19 14:49         ` David Vrabel
2016-02-19 15:14           ` Jan Beulich
2016-02-19 15:43             ` David Vrabel
2016-02-19 16:38               ` David Vrabel
2016-02-19 17:20                 ` Jan Beulich
2016-02-18 18:52 ` David Vrabel [this message]
2016-02-18 19:19   ` [PATCHv1 4/5] x86/viridian: set x87 FIP width to 4 for Windows guests Andrew Cooper
2016-02-19 14:11   ` Jan Beulich
2016-02-18 18:52 ` [PATCHv1 5/5] x86/domctl: Add XEN_DOMCTL_PARAM_ARCH_X86_FIP_WIDTH parameter David Vrabel
2016-02-19 10:05   ` David Vrabel
2016-02-19 14:13     ` Jan Beulich

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=1455821530-4263-5-git-send-email-david.vrabel@citrix.com \
    --to=david.vrabel@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).