From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.57]) by mx.groups.io with SMTP id smtpd.web12.1646.1580857341841322832 for ; Tue, 04 Feb 2020 15:02:22 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=vfZfHBl2; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.92.57, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AmpvwSM7s7Bdd84GJXd6mmTuelpME05WxSSaJzVmRCkecxtIayrrNo9VWnopVb5ztKfi6g4kwFcIvWW2LOeLOrTyf/41r38GqDq/0kczm0QgRij1wepcCR1pv1msCUB0tgYypfIZgCT+zxhf753UkkC5Sta6odatWxoE1s1B39ribmrvbjVpjr+/y5RXnGQuNKQQbBRBTBIMnAjPs0CRwm1hiv6m/8Hh+LN2f4x5ruI+UjtCaN16j/a3+ZWDJR7f/TZ9ASx06FFfSG9tf2vBv8hti5ZPmcSQEV/7NGpjS9/XIUyl9NcvPvpEf8ja4LH/cwS+do7CRAy6Ark1jUQqpA== 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=HWMqrbLRwZW1s2syh9em5+wd7Uni2ZSZl2q8AZzsLJw=; b=oDR7wH121g5UsMzXukmtVkM4GCtzj6IaUqrLog3y1hlL9m5NT0vgs/s5qX9HuCI3gIpOVY5z1+DCk6MkrGO5WfbhiIgWhNx/XQ/V58j7oczjOuhiUxm60DiUAEPRxcKIL8/1owEyjPJPbosm/MK++zY/vI90Dc768MTEjO3/X4/PywX+HeTkrTgL+RcEo7uTxF15rRO+0hB3cNjq0VyVvJcYnQOWJuo0rqxUeUwYeFIyhiasjAX58lKYvsKN+7ZmnlZFaKgfPiA4NbOJ3jVGUqq1RN2GuYdZSU90p9Se95uy8UaYCGYrwDkK8Xk/x3Mb2uLLxC/2v3DdhU1tBLJhXw== 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=HWMqrbLRwZW1s2syh9em5+wd7Uni2ZSZl2q8AZzsLJw=; b=vfZfHBl2K/vgczSTnbRfZMIcc8rKTSSkLibcDfrsikiMTnbuBtKYjHWzvjEb+Q/KKTtCYWQqAYQXS7mVYiF5qzVKpi0moB+fLADvhXs+2URR8OLPyeHx8sdIcY9Q6y9qdLFyHvZaKIQ7g8+pcx5TD2cdLSIKsR/gAgm+0x5xDEA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.71.154) by DM6PR12MB3930.namprd12.prod.outlook.com (10.255.174.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.29; Tue, 4 Feb 2020 23:02:20 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270%7]) with mapi id 15.20.2707.020; Tue, 4 Feb 2020 23:02:20 +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 , Brijesh Singh Subject: [PATCH v4 18/40] UefiCpuPkg/CpuExceptionHandler: Add support for VMMCALL NAE events Date: Tue, 4 Feb 2020 17:01:22 -0600 Message-Id: <64143f04ce4c47595ee53012817e2130f10c1d6e.1580857303.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 Received: from tlendack-t1.amd.com (165.204.77.1) by SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.32 via Frontend Transport; Tue, 4 Feb 2020 23:02:19 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ed47d3d8-e132-4ff8-c329-08d7a9c649aa X-MS-TrafficTypeDiagnostic: DM6PR12MB3930:|DM6PR12MB3930: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-Forefront-PRVS: 03030B9493 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(366004)(376002)(136003)(396003)(346002)(199004)(189003)(4326008)(478600001)(6916009)(81156014)(2616005)(956004)(81166006)(8676002)(6666004)(966005)(316002)(54906003)(19627235002)(2906002)(6486002)(66476007)(66556008)(52116002)(7696005)(186003)(26005)(16526019)(5660300002)(86362001)(36756003)(66946007)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3930;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 01o/6ZAoGZNcyvI141X8Fm6VjBKJRznkFi9/CujYYeCFzAjL91mGqQwjLtitTOn/nG1EIzx14nSJDzhkjc+PbB+sD4toRx1KgxVUFqR6mLGscrEaCQ4ty7lntc3OR7xqZpJkNRuwGGqr/x3SctGj6t0RZvbcVILxJaLqpJDAv0aCQJ9SGMtJxOJychDHqz24nvpxzlllC6spxE1F8nxA13X16k6KKDxg6fIoNP+6oKfWNOT6T+6sfULPiOhT4jE+wYKOU0Dyb7cdrwezG7l2n2FZlisEhsu2rKsXaNKWzJ7fhgTmdY2YapbGpRp6bM+I55gf7Bqe2euJvrkeJBpTFRz1U3Qlo0AksNXsi+vY+5VffRnKhc0B43ghf+Fv2HqL+j3r8VVpHsASRbgZtBVEarx2rQOGoSS8wW8jK0BOwlvXCxUGy4LGQcYhnHbcGggik5rbbOr5SBaEUl7ixtomSYB4u5733C6/+Eeu0Kf0SFBpzsfBnKsmDOF6j/ilzmIf2Y/ur4kQ2gjy0z9AS+NG8w== X-MS-Exchange-AntiSpam-MessageData: mmZwHf/a5Potgol9UxHIc03yieBLLGnGdY2q+cGevmuerNBMepz5t7RPKEHFnch//ZrxeOiJucto4nAa7FLW9rub44+cHMvfdxs+OYQmVkTRg8klaMvgHII0FGviKEZdBhY5L68Fida4pavNZNdmAw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed47d3d8-e132-4ff8-c329-08d7a9c649aa X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2020 23:02:20.4648 (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: P8ggbya47qzDSirvPUebGWS7iU+L6ckRskVN1NhuLqhws7VxneuN4UaUid6M3Fh+d1zPZMwv1U4RrgFfRaxk2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3930 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 Under SEV-ES, a VMMCALL 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 | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index a47bba5ac1c1..734c2bbeb989 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c @@ -609,6 +609,36 @@ WbinvdExit ( return 0; } +STATIC +UINT64 +VmmCallExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINT64 Status; + + DecodeModRm (Regs, InstructionData); + + Ghcb->SaveArea.Rax = Regs->Rax; + GhcbSetRegValid (Ghcb, GhcbRax); + Ghcb->SaveArea.Cpl = (UINT8) (Regs->Cs & 0x3); + GhcbSetRegValid (Ghcb, GhcbCpl); + + Status = VmgExit (Ghcb, SvmExitVmmCall, 0, 0); + if (Status) { + return Status; + } + + if (!GhcbIsRegValid (Ghcb, GhcbRax)) { + return UnsupportedExit (Ghcb, Regs, InstructionData); + } + Regs->Rax = Ghcb->SaveArea.Rax; + + return 0; +} + STATIC UINT64 MsrExit ( @@ -1005,6 +1035,10 @@ DoVcCommon ( NaeExit = MsrExit; break; + case SvmExitVmmCall: + NaeExit = VmmCallExit; + break; + case SvmExitWbinvd: NaeExit = WbinvdExit; break; -- 2.17.1