From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=gW8J1/sP; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.80.73, mailfrom: thomas.lendacky@amd.com) Received: from NAM03-DM3-obe.outbound.protection.outlook.com (NAM03-DM3-obe.outbound.protection.outlook.com [40.107.80.73]) by groups.io with SMTP; Thu, 19 Sep 2019 12:53:31 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NCUvrktq1NBgjYPXHXmWje0n5Il7xeR7V6U2eVabg4N8u1EhFiFHJyK2NbF6hsl9tYBOY5C/WiWyyNQqpWxdcPN7CRAmx0sh/PjqJrVMbuOzj0DeyQPsBXugStf3UHH2d9wjXgHBR2WOxV5YOJPAlgqdNr9CZu8ihe6y2FBKMFkCtekJ/o91W4GLk4LIRIOG7PL6Mr9nweKhx2DyZ8Vyf4F4Qpflxnl5p+tpJnpLVrBHhqO1DkNcBD7lw59ozPN1yy2s7fv8fC33q9KNrMtf897PugbkaWwhiHQVRwBTfRatAQwgdD8+hBtXkdmP1SbTQZcFFhVswk87NQ8m5A+qLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VJsdZLNLwAFjgUrrrfuA94lZw6nZchcwaL6rZUUQvNk=; b=l8cVpClA3BijSHymTffjYDLwNd0YJPaykeuSBSMvc0hy8i+YzOoWF+CSn0B7GD3aP4Clp36OWzLY2XsEa3PyStSXkk2tYCqkIo6nosGQdNVtVo6kWtYj9zVPbZkKFq1xx2NHqLM78QlRpSY178JsPzuE4bQdNI+8bMI2eRvr7Mm/448diiwKTQGnmvK18xVTY6srFhOLMO12N6Vp1Yj+oSbAT/YtJ8/VVg2fRajQZZMNy0//7zAv38SkjxKC2tDxg5iDh2eifzc3kOllQXkc6/FVSvvkUtX/M5GJZx4PvSfN3bHQLD/xLmd5/euLwwk7kdKUDMveVMAoK+zL98Ut5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VJsdZLNLwAFjgUrrrfuA94lZw6nZchcwaL6rZUUQvNk=; b=gW8J1/sP9lSNEU9njRYtZ00YbwdYdtLI1Ex1MFdVY7a63ZRVIXx1FdfFzr9op2ObzRRySNuGn1TSrxao52f320v8CH3jNfFyQvMm8W1NZmQqgI3vNXW37dwakbPLSISi1DvvVl3y88xF22r0KYFBf0ADLCw/uqJooIOV9uX7XSQ= Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.104.150) by DM6PR12MB2890.namprd12.prod.outlook.com (20.179.71.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2263.23; Thu, 19 Sep 2019 19:53:30 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::400e:f0c3:7ca:2fcc%6]) with mapi id 15.20.2284.009; Thu, 19 Sep 2019 19:53:30 +0000 From: "Lendacky, Thomas" To: "devel@edk2.groups.io" CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Michael D Kinney , Liming Gao , Eric Dong , Ray Ni , "Singh, Brijesh" Subject: [RFC PATCH v2 32/44] UefiCpuPkg/CpuExceptionHandler: Add support for MWAIT/MWAITX NAE events Thread-Topic: [RFC PATCH v2 32/44] UefiCpuPkg/CpuExceptionHandler: Add support for MWAIT/MWAITX NAE events Thread-Index: AQHVbyPXodt9usDq2kKJx9I9AlCr0w== Date: Thu, 19 Sep 2019 19:53:00 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: SN4PR0501CA0146.namprd05.prod.outlook.com (2603:10b6:803:2c::24) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:182::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 41a96a00-e1f3-4cae-43f4-08d73d3af9e3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:DM6PR12MB2890; x-ms-traffictypediagnostic: DM6PR12MB2890: x-ms-exchange-purlcount: 1 x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; x-forefront-prvs: 016572D96D x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(346002)(376002)(366004)(396003)(136003)(39860400002)(189003)(199004)(2501003)(99286004)(6486002)(86362001)(476003)(52116002)(11346002)(446003)(54906003)(2616005)(8936002)(19627235002)(3846002)(6436002)(64756008)(5660300002)(66556008)(66476007)(8676002)(66446008)(76176011)(66946007)(256004)(2351001)(486006)(6512007)(5640700003)(6116002)(50226002)(6916009)(6306002)(118296001)(71200400001)(71190400001)(2906002)(386003)(6506007)(966005)(14454004)(478600001)(4326008)(305945005)(6666004)(66066001)(36756003)(26005)(102836004)(316002)(7736002)(81166006)(186003)(1730700003)(25786009)(81156014);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB2890;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ZxoH9FCissiPoF5GmALBQax1f6MOcnxxpPWYaiqzdm281WeMZjRGkE0QzVzAnZKfgLe6L+cmbUDViBB1+DfnV6YfaaZQJzg70Wbsn4dkaDJXv9Qoy8365gz7cMioGRCjTdPa7/LB+Ba6Fz9+GwdyRIQ9xbOoi+JYfOYsyKaAofAURbiJxD2vnfRnla4sxe5ZTcTRfjy1aMPLFnH5+c9ocrjGPcZrncAifw0RvPq81wUdWu9FmpQR8mGBa+ymDF3pckoW9gALRX6XNbIVcjACXvS9KTh0zVULqs+0l6UeUOe5S6vIQ3+zmlmaCGRNm71iRy66ctkDwXiwWG2El1QRVR+i8JIotDlglc1ODH/njeMTKlTHpZ0SnbOv36ZKO5eZ2x0n9RJwqmbrRlaXl1/CsN3Bg+Yu4H024sxvORd5Dy4= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41a96a00-e1f3-4cae-43f4-08d73d3af9e3 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2019 19:53:00.8041 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: TWrSh7YmGPrQE2CfzMWk+y7Ez4KypLbjUtgOiFci2cKI8ZE0ReoIR8Udigd//kQRIhUv4DlrbtkW39/4SzYJuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2890 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: <9B68A38E8E562B4989194D601B15A767@namprd12.prod.outlook.com> Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 Under SEV-ES, a MWAIT/MWAITX intercept generates a #VC exception. VMGEXIT must be used to allow the hypervisor to handle this intercept. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Tom Lendacky --- .../X64/AMDSevVcCommon.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index 824175a80b9b..8cb595e5a625 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -555,6 +555,31 @@ UnsupportedExit ( return Status; } =20 +STATIC +UINTN +MwaitExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINTN Status; + + DecodeModRm (Regs, InstructionData); + + Ghcb->SaveArea.Rax =3D Regs->Rax; + GhcbSetRegValid (Ghcb, GhcbRax); + Ghcb->SaveArea.Rcx =3D Regs->Rcx; + GhcbSetRegValid (Ghcb, GhcbRcx); + + Status =3D VmgExit (Ghcb, SvmExitMwait, 0, 0); + if (Status) { + return Status; + } + + return 0; +} + STATIC UINTN MonitorExit ( @@ -1082,6 +1107,10 @@ DoVcCommon ( NaeExit =3D MonitorExit; break; =20 + case SvmExitMwait: + NaeExit =3D MwaitExit; + break; + case SvmExitNpf: NaeExit =3D MmioExit; break; --=20 2.17.1