From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.71]) by mx.groups.io with SMTP id smtpd.web12.20912.1594737193906501283 for ; Tue, 14 Jul 2020 07:33:14 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=NiVXelQp; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.93.71, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XN37fRhBEk6Hi1ry/q+uFmqK6gmV3uQtHDyGl9HiQsTavfaWjZcEhM/mBT/tIXGk5GjR43ovM/JD/hkw8Ly/io9x+AwlP+/OEK5swQ0mQk8IpTv2l/N+3TcPu8Sojk1fCDc2HIc+hILLe6FQvR3bL7XzARPaNPYgIyIlriT4emVROMED2HTX4bbAtFs16mGjLYEi7oF0MMzxfscamfniXdFkvanK/4eR0PqAv3btQio86vltLgIP4nojO43Gw8fvywf50E3h+ENOtbzrXl2PtB/EQMz/Nj76RLMIPZgzi7cws/h8ss/3em8sF/kd9+6eciqYGjZXdl1aaQSUlsOuTQ== 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=8NTCnoZUa8l7fJRJjHTmN6rj4HEhSC81uhz1zBZyzhs=; b=NMPb2DyPxj0yOa9+e9VCW5ST3X7DuNsFnWk1h/ymyLGRNfpO9+KGfLZ5hKyQ4UoQI+1IbQl0C5i2eRlXEE4jXTik4aENzxRTxxNXH+RMc+pcWyPkP9wL1+v1Q6D2kZf8U/lNZ9RfyRkfYmQQpkF/aPtLh8QkbIRpiyAkowN7nJWjTdpe2Q+vj2cDdIJn+tWAS0RmUSltZvYXF9aG6lOkGh1+cuZWsTUXYECk9kWQ80Fmlnr7JoXeYMIXwwnmWQ3zvSqFZJUA4omx19POONvLT4tWoNMr5ihTo4Xg5gUs6LJsulHchtPDtnMrzx5H0uxahr7pEPbACaoZFnSIDE01uw== 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=8NTCnoZUa8l7fJRJjHTmN6rj4HEhSC81uhz1zBZyzhs=; b=NiVXelQpqbWaOxIXbSTkr5UnLUPaEYVV7hoRKmBsTFbvMasBODzb4r1S7vUwJR8wR7y85b7sMzcVfLKQFG8V8Q2M2iipPUfR/xsW2v/Wo5voAwR2+2vwkbwEDVoQ3wZoNzoD81ncUh/v32EFjp6Mkv4/G84udn+kmuXYYN+uYO8= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM6PR12MB3177.namprd12.prod.outlook.com (2603:10b6:5:187::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Tue, 14 Jul 2020 14:33:12 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0%8]) with mapi id 15.20.3174.026; Tue, 14 Jul 2020 14:33:12 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Ard Biesheuvel , Eric Dong , Jordan Justen , Laszlo Ersek , Liming Gao , Michael D Kinney , Ray Ni Subject: [PATCH v10 22/46] OvmfPkg/VmgExitLib: Add support for VMMCALL NAE events Date: Tue, 14 Jul 2020 09:27:53 -0500 Message-ID: <6101d91ac6c43213197c43e6864fb96d9aa412ac.1594736896.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR13CA0060.namprd13.prod.outlook.com (2603:10b6:3:117::22) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by DM5PR13CA0060.namprd13.prod.outlook.com (2603:10b6:3:117::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.10 via Frontend Transport; Tue, 14 Jul 2020 14:33:11 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 59e8d15a-000c-4f38-521f-08d82802d5f3 X-MS-TrafficTypeDiagnostic: DM6PR12MB3177: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UAf++jTP2DcPSbA/8DI3ZLBzuZpTx7JyhpTNvZs7mbYFVNEgWjw9fDSOkxNgmQqcwyH+pirY39x7/XI5NCwUEFsiicMghjqcRUTwmiWcU4d8hWgUn2two+LqonbKTCP6oYgpbMizKC6/+oU5D679QkNahZZjUwhieTd6Qk0tmF4lMq84Oc9Cu73O5klAdBCZnWvAbL+r+jMzH/RoVa566ZqfEsGSZ9UdymD0toZFuTO/6I0L9U0IG5blTuvYSV/4NosBe4jaGLj6rl4d9R/fdluF+xLNbWzdJG0l49/2iUM9ixaXOIDU2oDXeqan7ljbBZE8FBSjNoRq78xGQ7vF9yHIvxsbY3ME0P2e6EVBiOJR/5SUhZmCYN+i/0WwqIsn1C9iqSHSDHeCYn0miFHruZ6fG2NU3O+7EUZnGHrVNgSJMHyoMXor4FszY6HfmPsJ0gRYvGEajp1XPm7k7nzrdw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(136003)(346002)(366004)(376002)(86362001)(478600001)(8676002)(54906003)(6916009)(2906002)(8936002)(956004)(6486002)(2616005)(52116002)(966005)(7696005)(66946007)(4326008)(6666004)(66476007)(186003)(66556008)(16526019)(26005)(83380400001)(5660300002)(316002)(36756003)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YlxS9HIogIbQaD4ASOk503Kyqhsmuz1TZPUPpBCcP2jg6Vdj/bcY/JVcdYg20FSZV/x/lzhOlbUoIWp3pfrALhxQQIUtqGer6NMoqZ6+HfTyqpA9XXegE+2D+RJ41s979fPJahIpyRJYwxZnEFLhcM58rWuHnhC5lIwpvToQMPA//Sq4cKE7wMVC0Olkk3HFVFEI+QGwPmUWe9Rt+w0vRQNxv4g/+vKKAADvkDpyA3lejQDRgktyMfko86oe8o6igOqd7P6icD+1Puq8oSGnGga3HydzefVIms3nbJoiU3ETzh1chvObAdzZTES1HrOHEh2ajg6PkxLaWDVMuDD3FBNF7alUnvFUgY3j59Xyu2hhQEFOqQWI0+vSrFkeajzdnDnP/UeaSypu5+p0r1kNH/y/mEbQXQyHvpSGiVLAwRfIIqUfn/pgFtnD2C7ES1s6SxEwBQEHiE5fLkD005Fz3VKzsB45eBMEDNg5Q98w5RU= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59e8d15a-000c-4f38-521f-08d82802d5f3 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2020 14:33:12.0132 (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: izC2661ndM3s0J9loDH180+J+nv8gDRdj3fnRZI0aKQuF8Sywo1G3Iga+8o6gRvT2xhMoi6oj36GS4qzGKarGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3177 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 Under SEV-ES, a VMMCALL intercept generates a #VC exception. VMGEXIT must be used to allow the hypervisor to handle this intercept. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Acked-by: Laszlo Ersek Signed-off-by: Tom Lendacky --- OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Librar= y/VmgExitLib/VmgExitVcHandler.c index af5264095b98..54134f37e614 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -881,6 +881,50 @@ WbinvdExit ( return VmgExit (Ghcb, SVM_EXIT_WBINVD, 0, 0); } =20 +/** + Handle a VMMCALL event. + + Use the VMGEXIT instruction to handle a VMMCALL event. + + @param[in, out] Ghcb Pointer to the Guest-Hypervisor Communi= cation + Block + @param[in, out] Regs x64 processor context + @param[in] InstructionData Instruction parsing context + + @retval 0 Event handled successfully + @return New exception value to propagate + +**/ +STATIC +UINT64 +VmmCallExit ( + IN OUT GHCB *Ghcb, + IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, + IN SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINT64 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, SVM_EXIT_VMMCALL, 0, 0); + if (Status !=3D 0) { + return Status; + } + + if (!GhcbIsRegValid (Ghcb, GhcbRax)) { + return UnsupportedExit (Ghcb, Regs, InstructionData); + } + Regs->Rax =3D Ghcb->SaveArea.Rax; + + return 0; +} + /** Handle an MSR event. =20 @@ -1395,6 +1439,10 @@ VmgExitHandleVc ( NaeExit =3D MsrExit; break; =20 + case SVM_EXIT_VMMCALL: + NaeExit =3D VmmCallExit; + break; + case SVM_EXIT_WBINVD: NaeExit =3D WbinvdExit; break; --=20 2.27.0