From nobody Thu Mar 28 13:43:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1592497442; cv=none; d=zohomail.com; s=zohoarc; b=GEiTJ6mDqxArL/oN37iJ9RXuADxPmQFEywDVMT0/gr3o9WM+hxYu7H5q0lrXOv8bXKpbWI43N9VIRYhBNAvmPqCeoe6hp4kV7RZv+jb+Q9I+ip9L8AEfq5mEBQV4ppqdXtUR6+RKgybFt1ZQnHStuDYIaaGou969SdAH3jHzj04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592497442; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Kc5/1tvzLazygoqf3aqsxPSpJpqePUieulStMOjk4J8=; b=iu0g+hz2dRB9nDcg3OtGOQep1AqMpBoo2YR9p0wzQ1oCezSpNhPKghBDI+URD9SdqqJJpYy4+B2OY5wU7YXvYHum0R2KtOcIPdQSsixNNpJz3o2pick+v7tBM/C8d0HFPm1Nn94ewX9I26ECTcK92Iyp2Nf3FajuJvkC0oEzH7A= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1592497442750820.3242187922955; Thu, 18 Jun 2020 09:24:02 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jlxK8-0005t3-CL; Thu, 18 Jun 2020 16:23:32 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jlxK7-0005sy-7f for xen-devel@lists.xenproject.org; Thu, 18 Jun 2020 16:23:31 +0000 Received: from bagnar.nask.net.pl (unknown [195.187.242.196]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0b74dd34-b180-11ea-babb-12813bfff9fa; Thu, 18 Jun 2020 16:23:30 +0000 (UTC) Received: from bagnar.nask.net.pl (unknown [172.16.9.10]) by bagnar.nask.net.pl (Postfix) with ESMTP id 08509A31E1; Thu, 18 Jun 2020 18:23:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bagnar.nask.net.pl (Postfix) with ESMTP id F2373A1E22; Thu, 18 Jun 2020 18:23:27 +0200 (CEST) Received: from bagnar.nask.net.pl ([127.0.0.1]) by localhost (bagnar.nask.net.pl [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id t_SUwrxZQpDC; Thu, 18 Jun 2020 18:23:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bagnar.nask.net.pl (Postfix) with ESMTP id 8D2BCA31E1; Thu, 18 Jun 2020 18:23:27 +0200 (CEST) Received: from bagnar.nask.net.pl ([127.0.0.1]) by localhost (bagnar.nask.net.pl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ykPHM6-kYoqo; Thu, 18 Jun 2020 18:23:27 +0200 (CEST) Received: from belindir.nask.net.pl (belindir-ext.nask.net.pl [195.187.242.210]) by bagnar.nask.net.pl (Postfix) with ESMTP id 6BE59A1E22; Thu, 18 Jun 2020 18:23:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by belindir.nask.net.pl (Postfix) with ESMTP id 5BF4D20981; Thu, 18 Jun 2020 18:22:57 +0200 (CEST) Received: from belindir.nask.net.pl ([127.0.0.1]) by localhost (belindir.nask.net.pl [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id bHSnnSqrvzd7; Thu, 18 Jun 2020 18:22:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by belindir.nask.net.pl (Postfix) with ESMTP id EDE8821698; Thu, 18 Jun 2020 18:22:51 +0200 (CEST) Received: from belindir.nask.net.pl ([127.0.0.1]) by localhost (belindir.nask.net.pl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4TBmn3T2BaKb; Thu, 18 Jun 2020 18:22:51 +0200 (CEST) Received: from arnold.localdomain (unknown [195.187.238.48]) by belindir.nask.net.pl (Postfix) with ESMTPSA id 7D5EF20981; Thu, 18 Jun 2020 18:22:51 +0200 (CEST) X-Inumbo-ID: 0b74dd34-b180-11ea-babb-12813bfff9fa X-Virus-Scanned: amavisd-new at bagnar.nask.net.pl X-Virus-Scanned: amavisd-new at belindir.nask.net.pl From: Hubert Jasudowicz To: xen-devel@lists.xenproject.org Subject: [PATCH] x86/cpuid: Expose number of vCPUs in CPUID.1.EBX Date: Thu, 18 Jun 2020 18:22:33 +0200 Message-Id: X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" When running under KVM (or presumably other hypervisors) we enable the CPUID.1.EDX.HTT flag, thus indicating validity of CPUID.1.EBX[23:16] - maximum number of logical processors which the guest reads as 0. Although this method of topology detection is considered legacy, Windows falls back to it when CPUID.0BH.EBX is 0. CPUID.1.EBX[23:16] being equal to 0, triggers memory corruption in ntoskrnl.exe as Windows assumes that number of logical processors would be at least 1. Memory corruption manifests itself while mapping framebuffer for early graphical subsystem, causing BSOD. This patch fixes running nested Windows (tested on 7 and 10) with KVM as L0 hypervisor, by setting the value to maximum number of vCPUs in domain. Signed-off-by: Hubert Jasudowicz --- xen/arch/x86/cpuid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index ee11087626..bf38398ef3 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -811,10 +811,12 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, =20 case 0x1: /* TODO: Rework topology logic. */ - res->b &=3D 0x00ffffffu; + res->b &=3D 0x0000ffffu; if ( is_hvm_domain(d) ) res->b |=3D (v->vcpu_id * 2) << 24; =20 + res->b |=3D (d->max_vcpus & 0xff) << 16; + /* TODO: Rework vPMU control in terms of toolstack choices. */ if ( vpmu_available(v) && vpmu_is_set(vcpu_vpmu(v), VPMU_CPU_HAS_DS) ) --=20 2.27.0