From patchwork Tue Jun 5 22:15:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)\" via" X-Patchwork-Id: 10449397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3D1AE60234 for ; Tue, 5 Jun 2018 22:17:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 262EA29D9F for ; Tue, 5 Jun 2018 22:17:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A99529DA2; Tue, 5 Jun 2018 22:17:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A03AE29D9F for ; Tue, 5 Jun 2018 22:17:32 +0000 (UTC) Received: from localhost ([::1]:49349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQKGh-0004Pk-TU for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Jun 2018 18:17:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQKEo-0003pE-9l for qemu-devel@nongnu.org; Tue, 05 Jun 2018 18:15:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQKEl-0003vk-0p for qemu-devel@nongnu.org; Tue, 05 Jun 2018 18:15:34 -0400 Received: from mail-sn1nam02on0125.outbound.protection.outlook.com ([104.47.36.125]:20751 helo=NAM02-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQKEk-0003sZ-3E for qemu-devel@nongnu.org; Tue, 05 Jun 2018 18:15:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YwYdGfz33t/v1MZRcOeCNGkg9wDhwSK3zCTOU/XeFaE=; b=JTVwNXiH+HtrfyjmwdGvFfhcI/tx/gpN+zsIMlcoozwBH4rma2ElGWaxm7o6OP9fFEfuL7n8mKZH5S+ipYx8EgSa2e6syJygnF2BlyvVCJCHmjETdK+voHYkWLp2GtB8DmiKOxLKUmHMrQWJDejqYJxj1s1avpZ5uY9xb3NYsLk= Received: from MW2PR2101MB0921.namprd21.prod.outlook.com (52.132.152.29) by MW2PR2101MB1033.namprd21.prod.outlook.com (52.132.146.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.841.7; Tue, 5 Jun 2018 22:15:27 +0000 Received: from MW2PR2101MB0921.namprd21.prod.outlook.com ([fe80::f12f:6c3:3ccf:4848]) by MW2PR2101MB0921.namprd21.prod.outlook.com ([fe80::f12f:6c3:3ccf:4848%5]) with mapi id 15.20.0841.011; Tue, 5 Jun 2018 22:15:27 +0000 To: "qemu-devel@nongnu.org" Thread-Topic: [PATCH 1/2] WHPX workaround bug in OSVW handling Thread-Index: AQHT/Rq0wOBrX1lJBkKJ/p0x88/3jw== Date: Tue, 5 Jun 2018 22:15:27 +0000 Message-ID: <20180605221500.21674-1-juterry@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2001:4898:80e8:9:8ad2:c38:73d4:ee95] x-mailer: git-send-email 2.11.0 x-clientproxiedby: CY4PR04CA0078.namprd04.prod.outlook.com (2603:10b6:910:4f::43) To MW2PR2101MB0921.namprd21.prod.outlook.com (2603:10b6:302:10::29) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MW2PR2101MB1033; 7:+7F6sw0u3hH8R0GEgZ3cCP/R2H99D5ufWI7luQLQYhmSeikYzq8mXT43pb8LqsLDvsMBX+6SkVvZPewJZqmMKTmRq/5/fFbkt74s0mFObqoW8Cquw+1ENwBMIg8uZqGwi7IoYerZMMYuT6aMRkoTWH8fOcHJt/O7WCEi9HB8E8GA9Ra7xn8kvdLF1GUDa31LRzzCZNze63zjw0w70amBno/apcDR+/Z/x4yjOWUM7xacLNaaz41TUREO776ImMYb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:MW2PR2101MB1033; x-ms-traffictypediagnostic: MW2PR2101MB1033: authentication-results: spf=none (sender IP is ) smtp.mailfrom=juterry@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231254)(2018427008)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:MW2PR2101MB1033; BCL:0; PCL:0; RULEID:; SRVR:MW2PR2101MB1033; x-forefront-prvs: 0694C54398 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(39380400002)(346002)(376002)(366004)(396003)(189003)(199004)(6512007)(53936002)(305945005)(10290500003)(46003)(476003)(2616005)(106356001)(10090500001)(105586002)(99286004)(25786009)(86612001)(6486002)(22452003)(50226002)(5660300001)(5640700003)(6916009)(54906003)(486006)(86362001)(7736002)(36756003)(6436002)(316002)(478600001)(68736007)(8676002)(81156014)(81166006)(14454004)(97736004)(2501003)(1076002)(2351001)(2906002)(8936002)(4326008)(3660700001)(3280700002)(5250100002)(6116002)(52116002)(2900100001)(6506007)(59450400001)(386003)(107886003)(102836004)(186003)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR2101MB1033; H:MW2PR2101MB0921.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: P48samjfYj4qO/OJId7KxEUWEswZahC9erEANUbc3NxmfAXVHjaDK8Smn/H4ZcBaGyV/0VMfwnSS7yoH7UFF7twZnLfRE8gvzYKuYIIuQGZzSmWyClKoOsc1JWzXWEQBKGX8RRcM4FavrRS/BikKV8t3OOAlG9zpun7ghaazeUQLQnSWcuyZAb5R9/4HOYz0 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: f91d3fab-2c39-4d7f-f9f6-08d5cb31d71b X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f91d3fab-2c39-4d7f-f9f6-08d5cb31d71b X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jun 2018 22:15:27.5380 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1033 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.36.125 Subject: [Qemu-devel] [PATCH 1/2] WHPX workaround bug in OSVW handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Justin Terry \(VM\) via Qemu-devel" From: "Zhijian Li (Fujitsu)\" via" Reply-To: "Justin Terry \(VM\)" Cc: "pbonzini@redhat.com" , "Justin Terry \(VM\)" , "ehabkost@redhat.com" , "rth@twiddle.net" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Adds a workaround to an incorrect value setting CPUID Fn8000_0001_ECX[bit 9 OSVW] = 1. This can cause a guest linux kernel to panic when an issue to rdmsr C001_0140h returns 0. Disabling this feature correctly allows the guest to boot without accessing the osv workarounds. Signed-off-by: Justin Terry (VM) --- target/i386/whpx-all.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c index 6b42096698..99501bac57 100644 --- a/target/i386/whpx-all.c +++ b/target/i386/whpx-all.c @@ -964,6 +964,16 @@ static int whpx_vcpu_run(CPUState *cpu) rdx = vcpu->exit_ctx.CpuidAccess.DefaultResultRdx; rbx = vcpu->exit_ctx.CpuidAccess.DefaultResultRbx; break; + case 0x80000001: + rax = vcpu->exit_ctx.CpuidAccess.DefaultResultRax; + /* Remove any support of OSVW */ + rcx = + vcpu->exit_ctx.CpuidAccess.DefaultResultRcx & + ~CPUID_EXT3_OSVW; + + rdx = vcpu->exit_ctx.CpuidAccess.DefaultResultRdx; + rbx = vcpu->exit_ctx.CpuidAccess.DefaultResultRbx; + break; default: rax = vcpu->exit_ctx.CpuidAccess.DefaultResultRax; rcx = vcpu->exit_ctx.CpuidAccess.DefaultResultRcx; @@ -1382,12 +1392,13 @@ static int whpx_accel_init(MachineState *ms) goto error; } - UINT32 cpuidExitList[] = {1}; + UINT32 cpuidExitList[] = {1, 0x80000001}; hr = whp_dispatch.WHvSetPartitionProperty( whpx->partition, WHvPartitionPropertyCodeCpuidExitList, cpuidExitList, RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32)); + if (FAILED(hr)) { error_report("WHPX: Failed to set partition CpuidExitList hr=%08lx", hr);