From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.68]) by mx.groups.io with SMTP id smtpd.web11.1233.1585071692498004034 for ; Tue, 24 Mar 2020 10:41:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=y0MebQcT; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.68, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gsw5+rhv6cteLCCUIfULpqnf9HBHT6Muy4VsKX/zLsoj+JSAGSdM1gKJhQVTfw1vdya/phVLrgbNlVTLQP2EEvgr3KiXvhc+rXDfVDeqsaPyogS4G5rhvuPMbQmcrxQlwpS4DM15a5ZCYraLHe3vg4nekYmZoY6agpLb/OXUZgdTeGJsJeHVLKOp+ZMgsRSHiu8X8Q/1Z5GpAH817NtCNHekRNLxQdDLmfnOw6s6w32Wsr8vXR27H/9RF9m3ozKFP6cqvFrDzjhTnZPh2Ikxowio3Q+wijphKXZwZh6ibCah8iXKZ/x8n5qmWBScw2u8hVphUP2iiiB1c9cNnHzOag== 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=zuIZkE08Y8Q4msR4gQEWcYPsrx8VouGmOZgIChsD/Q4=; b=iFJpTrSLlYtHJGovsdRcIIckqA6FY1jLMxo6AOvYoy1Df6dAEHna13b3QBN6B0MUREyCSUy3QTLt3lry/NvCNVRiNtI72OBuRF+tK8+92Fjvcm6oyW6jG/pZXxAYcblGTcGqFfv9UiJDe6Sllk+DenYFahldn7LR/61LMWCxNypse+t3MgFwNaXr34O9p+IddZLHAVouxXJZg6OPZkKMQZbnUoyGxBQPmalib0DB96uj9Gn2KUw+5TYpc0zmK+G8GaMVFFW3MNpQHW+KZ0OvndvmKArEddnPITx0C5y5AjGJYRyiE8zy/D13QCyHky7n5E//XFOxDseU19wPXGcbdA== 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=zuIZkE08Y8Q4msR4gQEWcYPsrx8VouGmOZgIChsD/Q4=; b=y0MebQcTo6fMyLFj/FHWnb+++B+cv/SKrslLhJI0cXYxjS99hJXMEMXbqv6cZWXB2nxnn0H3NZCjptp3MJUXuFVSq2bWqH1XEkNUuzEDFtxom3mosPtZK3Fnof9DShIolKBUBlTlyQ4ApZQio+pSPgqqa0FicKXcXjEW48d9RlM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) by DM6PR12MB3915.namprd12.prod.outlook.com (2603:10b6:5:1c4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.22; Tue, 24 Mar 2020 17:41:31 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::f0f9:a88f:f840:2733%7]) with mapi id 15.20.2835.023; Tue, 24 Mar 2020 17:41:31 +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 v6 22/42] UefiCpuPkg/CpuExceptionHandler: Add support for MONITOR/MONITORX NAE events Date: Tue, 24 Mar 2020 12:40:36 -0500 Message-Id: <89df6a7543cbdcce45383ecaebbe6bed49c612ef.1585071656.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM5PR06CA0025.namprd06.prod.outlook.com (2603:10b6:3:5d::11) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) 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 DM5PR06CA0025.namprd06.prod.outlook.com (2603:10b6:3:5d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19 via Frontend Transport; Tue, 24 Mar 2020 17:41:30 +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: 50462a7a-1f44-4403-b4e9-08d7d01a9674 X-MS-TrafficTypeDiagnostic: DM6PR12MB3915:|DM6PR12MB3915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-Forefront-PRVS: 03524FBD26 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(376002)(366004)(346002)(136003)(396003)(39860400002)(8676002)(8936002)(186003)(316002)(54906003)(16526019)(956004)(66476007)(36756003)(6486002)(19627235002)(66946007)(6916009)(66556008)(2616005)(26005)(4326008)(966005)(81156014)(478600001)(81166006)(5660300002)(2906002)(7696005)(52116002)(86362001)(136400200001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3915;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords; 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: DuNq2uuANpDnBjQmRsGQGCUQheDofOejz5pzrzsKinTPZEAnaQERdgTXdeXNN3Jh2ixQ1gNhC90fQOklMhYEI31CBOrGkOnw6RzYZ83HfXZN72v8JilxQF8DyAtJExxc9+KPDJN4IBJOo5GjuD8M0TETJ9b9s4q/w1FgZXrKH5EAj5hHhNnZmUAkJWjjqncezBRaBt4ol0t8BzrM0WYux7Qp75IBSalV50Zdrps63I2WFc+FIrx8vqufv8ahv1gMnTpRDbVOzvn0fvfZDMaNas/bT/xIt9+RkvVs0Mo4zb1iNe0BGVelBChOu3Mtf5oX85HZFD5RaC9ZvSCWD3liVi6e5uwaXZ0DHMtGlr2Zmb0ENB1U0xs/jMZP8ebms4lTLvH6j2hy1FvtnM3XD31PD3Xx18/EFjCcc8ntd4hVAoihISucgmac/703/J+qIlQgqzFJKBS9kLkRHhscJTcbwVNp+tfgPthlpTKNv+TLkzgklkktowYlVjwYVmooVJ7EADylgP69v0QwqCpRr0bHZzFFE+KDTKpRaYjjcJVXCbny8//rmFcKw8eCWxSseY56m71ARXDEor8BEjnm+Djy5g== X-MS-Exchange-AntiSpam-MessageData: 5vBSfBJs5vlGjo5caIlrvxnmn/90r7UNA4r/ipxwAoB6PkFJeLXToMxoIEi9NPCVNO68AE3slPVQed7oUay8IYh/OZXxbr/fKJdAFRjEffvWTs72H9S/YS8njpy1nSSYs/LiiOEpON1FNszvVEfFRQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50462a7a-1f44-4403-b4e9-08d7d01a9674 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2020 17:41:31.1240 (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: 5XJRItyFyUvpV3hyIMQB0gahWfAl4r5C5Zjp8dPY2YGFvSmAjKoAvg4vMh5hHBd8Tzhna8y70oE7e9FfHGls1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3915 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 Under SEV-ES, a MONITOR/MONITORX 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/ArchAMDSevVcHandler.c | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c index fcd4738b2915..90255cd55e5e 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchAMDSevVcHandler.c @@ -591,6 +591,33 @@ MmioExit ( return Status; } +STATIC +UINT64 +MonitorExit ( + GHCB *Ghcb, + EFI_SYSTEM_CONTEXT_X64 *Regs, + SEV_ES_INSTRUCTION_DATA *InstructionData + ) +{ + UINT64 Status; + + DecodeModRm (Regs, InstructionData); + + Ghcb->SaveArea.Rax = Regs->Rax; // Identity mapped, so VA = PA + GhcbSetRegValid (Ghcb, GhcbRax); + Ghcb->SaveArea.Rcx = Regs->Rcx; + GhcbSetRegValid (Ghcb, GhcbRcx); + Ghcb->SaveArea.Rdx = Regs->Rdx; + GhcbSetRegValid (Ghcb, GhcbRdx); + + Status = VmgExit (Ghcb, SvmExitMonitor, 0, 0); + if (Status) { + return Status; + } + + return 0; +} + STATIC UINT64 WbinvdExit ( @@ -1076,6 +1103,10 @@ DoVcCommon ( NaeExit = WbinvdExit; break; + case SvmExitMonitor: + NaeExit = MonitorExit; + break; + case SvmExitNpf: NaeExit = MmioExit; break; -- 2.17.1