From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: [PATCHv1 4/5] x86/viridian: set x87 FIP width to 4 for Windows guests Date: Thu, 18 Feb 2016 18:52:09 +0000 Message-ID: <1455821530-4263-5-git-send-email-david.vrabel@citrix.com> References: <1455821530-4263-1-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aWTge-0002UO-AB for xen-devel@lists.xenproject.org; Thu, 18 Feb 2016 18:52:24 +0000 In-Reply-To: <1455821530-4263-1-git-send-email-david.vrabel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , David Vrabel , Jan Beulich List-Id: xen-devel@lists.xenproject.org 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 --- 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