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=L4rSmfYW; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.72.85, mailfrom: thomas.lendacky@amd.com) Received: from NAM05-CO1-obe.outbound.protection.outlook.com (NAM05-CO1-obe.outbound.protection.outlook.com [40.107.72.85]) by groups.io with SMTP; Mon, 19 Aug 2019 14:36:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hc3yfjkfubPVfR/L4W9S0ptVyXXU0o+IrDdXKTwnYW/wRxmDwDOMm3bwu3hii1W8A90YNGfopVvFkjiHZkkw5vHKqn568cUkkJDgsnZ48QReXXL6VTeQKhAwq4p/k16p/tM+kYxE6hlKpHDu0r8sJHbfiLEpRss72KW9aibfRROpo7TyNgymuBESjP3I6iQpMIDbchK+CCWS86ei9cT77GY78UZ0J8RwkDOk4hkWHtZLsH1D5//xua7Crt4s5C2i8IuxHyuXhN0QZcqYmQ6q7+oMog+xlf2pJVu2Gzb6+gns1lBwWxJng/s+JAzqeJKsKCsYhuplJgAScvCCZ4HRnA== 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=ZCcvkJr9VeHgaLDBd49JxKAf+Uzut+HHMEFpLIJKRyU=; b=DxUSHRQbWx6t5vHz1jTtrPCPUkfGitJOZa3aBb28ssnWmQONu0Tx+g2+0/JFyhmxhGQ6andpom3d5wl9GuIblxQVuAfo2NK34O9wd7pXDAI4hAVCV2etElATxcXCD1irzb/dVEpxp2c+8GO54z6USP9NNL7UxVUyIF94gpGvYojX0sL95WGdtbLLAv/V8g9hT4hkSckeGT5pCgxdyOPJLvCNeLwMEEXtYez1g5A4KQl6/dXIrXzmEeOhSC6sXHYEmUviMNKYzHTAMS0OBPpd9J0XHMNV+m/OdT4h56V5CMv1EasXgjllz1PliTdmhojjsJ80FhjHRzJhteaZCbzc5Q== 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=ZCcvkJr9VeHgaLDBd49JxKAf+Uzut+HHMEFpLIJKRyU=; b=L4rSmfYWk/y/cek2YNyYtcnza8fBAgnUH0YDcuVqlgJ+W1oehyZXbWMdYY2ZKg6e+EUb1FrCxfE8Z5q+LmuzVkFjxqZFP9RJGPrO+IINrNx0R2QmUoFAlBhWAujK7snc4yEvA4y4aOfhRi7mrvSTYEQhqxQESfstUJzvhmZK0/g= Received: from BYAPR12MB3158.namprd12.prod.outlook.com (20.179.92.19) by BYAPR12MB3112.namprd12.prod.outlook.com (20.178.54.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.20; Mon, 19 Aug 2019 21:36:14 +0000 Received: from BYAPR12MB3158.namprd12.prod.outlook.com ([fe80::39b9:76bd:a491:1f27]) by BYAPR12MB3158.namprd12.prod.outlook.com ([fe80::39b9:76bd:a491:1f27%6]) with mapi id 15.20.2157.022; Mon, 19 Aug 2019 21:36:14 +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 20/28] UefiCpuPkg/CpuExceptionHandler: Add support for VMMCALL NAE events Thread-Topic: [RFC PATCH 20/28] UefiCpuPkg/CpuExceptionHandler: Add support for VMMCALL NAE events Thread-Index: AQHVVtYggefRtboLAkGI3F9D6z7Wsg== Date: Mon, 19 Aug 2019 21:36:13 +0000 Message-ID: <213aff9448251c52a3a4fe4085729461bbda2fea.1566250534.git.thomas.lendacky@amd.com> 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: SN2PR01CA0031.prod.exchangelabs.com (2603:10b6:804:2::41) To BYAPR12MB3158.namprd12.prod.outlook.com (2603:10b6:a03:132::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fcbe5fa8-e7a0-4b15-da84-08d724ed4264 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020);SRVR:BYAPR12MB3112; x-ms-traffictypediagnostic: BYAPR12MB3112: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2000; x-forefront-prvs: 0134AD334F x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(346002)(376002)(366004)(396003)(136003)(189003)(199004)(66556008)(66476007)(5660300002)(52116002)(76176011)(186003)(86362001)(305945005)(7736002)(6116002)(66446008)(6916009)(5640700003)(36756003)(6436002)(6486002)(102836004)(6506007)(386003)(26005)(2351001)(476003)(2501003)(2616005)(486006)(11346002)(66066001)(118296001)(25786009)(446003)(54906003)(2906002)(19627235002)(4326008)(6512007)(99286004)(71200400001)(8936002)(50226002)(71190400001)(316002)(8676002)(478600001)(256004)(53936002)(3846002)(81166006)(1730700003)(81156014)(66946007)(64756008)(14454004);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR12MB3112;H:BYAPR12MB3158.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: gigKjbFMaQ0S+vm/+LnPkIZX154jxCgtsTnJBRbcooB09wdO7c6MR75+FtfR2+hVvYlfNGqRnMfe2Dx57Ltx+h/vvmwA2iDIJbfGQc81pPgrx0OB2WyunZsAA+AisAmngGa8gkSHoIxIez+HeDyVGwygZqxUZUiCk/cSIw2eEjElGKKYATr7FDiGOsxb6lWxhRJ+LbXFNsGvtzbgJpmyuqnarrZmQO31EXARa6eSrgFDcz0W3iQE9kodptp9ANWAMfgqelPRuSWm4Eo/dI2YmlBTEn1Ca46e6jCjRJepq7PZwnZoZ8QnCi/dG7JFMfwUoobz/KzLX3LrQ9OvxxywuBrcEh+VspIao0H279545+SCx+U3aieNIhdLZh3NynyQOskdtNYjFIY2Avh6FT+YuRjbZVUaiBavrLt7guuJk8U= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcbe5fa8-e7a0-4b15-da84-08d724ed4264 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 21:36:13.8537 (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: RrCg5BKn3rv7jv1nA49ScCmW8gHo7DmDjCOZImrXLF7B9XOq8gZYL+qt1+OBfl+SxVeeFtpu/AEP1LBbineqXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3112 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable From: Tom Lendacky Under SEV-ES, a VMMCALL intercept generates a #VC exception. VMGEXIT must be used to allow the hypervisor to handle this intercept. Signed-off-by: Tom Lendacky --- .../X64/AMDSevVcCommon.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index 3f10af401aa0..1a0a8f5cd718 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -546,6 +546,37 @@ WbinvdExit ( return 0; } =20 +STATIC +UINTN +VmmCallExit ( + 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.Cpl =3D (UINT8) (Regs->Cs & 0x3); + GhcbSetRegValid (Ghcb, GhcbCpl); + + Status =3D VmgExit (Ghcb, SvmExitVmmCall, 0, 0); + if (Status) { + return Status; + } + + if (!GhcbIsRegValid (Ghcb, GhcbRax)) { + VmgExit (Ghcb, SvmExitUnsupported, SvmExitVmmCall, 0); + ASSERT (0); + } + Regs->Rax =3D Ghcb->SaveArea.Rax; + + return 0; +} + STATIC UINTN MsrExit ( @@ -970,6 +1001,10 @@ DoVcCommon ( NaeExit =3D MsrExit; break; =20 + case SvmExitVmmCall: + NaeExit =3D VmmCallExit; + break; + case SvmExitWbinvd: NaeExit =3D WbinvdExit; break; --=20 2.17.1