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 []) by mx.groups.io with SMTP id smtpd.web10.1665.1580857343101360274 for ; Tue, 04 Feb 2020 15:02:23 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=sDlbTuf9; spf=none, err=SPF record not found (domain: amd.com, ip: , mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b1jQbibm4TVM2VVGQSbpuwloZApwj+URZHnl3cKn35Oi5CoVKTOEUKMjwKsF4WbiC9L4f83vh0ItQxufhpm7xN76s+HrEAS1Wpk0CMBUwKLPP+tjdmXKY/6hUXvjopnmz3n1uhnNwUh3y3K32PyMpAKOOXrXfrlgoeJCxnwPgL8DMNTdzzO+AXMUx02hrMBmj7yRvayuE8gXh5utOorT3kS+mAm675ZiywxK/mICXqB0CcU2b7i/gDcPEr5KtJG12Hig1EynbEr/Tr/CdOVWk5edwXueH4ThlrG0FA/m4ib/fNOZo59XTcbw74YyPYD+2aIBj2XTCsrefaoPvAIhow== 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=vQxyWAFCSwnkPP4JhfckQXAveFz1I5Mcl5mO2uQeQu4=; b=Irk+f+jlWNGXiWMLtBcsp1OMDM7pJJS4Ec7rz01077qN2gtshLFWUXXwgOcE7onqN/py+s7lmHV8EeEByQRffRqMJAblKuixKYAk429aIsfS2p5zP1Ppp53VurUNUQPpMvMQ3ufHG8LOntZZ4ILg398YHxxi6027G6+F2QG7p75StsasIBcBKhiRlPjr7cG2moTTRIfoyG6XN1Rm7ftn0T4oc93dGAA/cJpgYh750IDlIut1UQ5ykuUG2kQYAXIRsnHNowBJsw9xxj3+pLSJzT2rMC9CqDoIrFI6UOvTLMq1Ns3USew0jDrMFkCaA7ZR9DQscLMC0MyxiP5igPc/VQ== 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=vQxyWAFCSwnkPP4JhfckQXAveFz1I5Mcl5mO2uQeQu4=; b=sDlbTuf9/s+NOx4aySBlwTQTAYwBPeCKlI76F6Fgfclf1WGJJeWM1PgqG6r4ViRRcrihGkSUCf6qmy4ooYwAoa/OCIALqZi9pEgWm4fc6XzPHhOZVgvmUqWD2OYL40YIDbrJoe0oyst0nAjtAqTBQV2RKV1AVQ7yWqtnpFe7sKw= 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:22 +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:22 +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 20/40] UefiCpuPkg/CpuExceptionHandler: Add support for MONITOR/MONITORX NAE events Date: Tue, 4 Feb 2020 17:01:24 -0600 Message-Id: <0e5a8093c885baa235c6482b09b1e01198e73dc7.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:21 +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: e6566a71-1aa1-4d4e-6db2-08d7a9c64b0a 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)(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: rI6xcZDv3ek4FF2o+goDD6Qf+VbomGn1C4SMC2Ct1ya9ZO7KFKuiatRG6Rep3XG+umHVln90++Vtqm9XE19OSDtF1PjtcvwQlAeQxVh2D6t4ZZ0eHpstpQ8/jt1k4B4zosnMzVPEiMESeiVEJPe0neceE8qO+K2ZdIgjW5aPzq39mTVAT0RLlKV4qXpj6iFEXrZRFFJVirXztk6dFor5aH3MsBz6Ik4+Zo4K3ULpLE9riMQKd8JT8/aj5EjFsOTU56s2DK0AUNGLLc7u1Jfq7IveH7W2wvbjWhU5Wo9D3rrlGUR/rcl4xO5o2RZRNg6/4cWrbXhG98e7j46eBLhAiFbyXGCSX+G+0o4L7/UD0nu05ROAMWVQgNJdBACL9VLhWlunnfEqcpJYdM0dhzNJtYcB53bb3OtKg530dCT/xpWVq4IIXC33eW0GU/Qn9SxYayf6+zycAXLLNIsOawEOIhAVasidxtiEUj5VKn83ttTF3QtTa9m/C/H9AeURpNckfvfIgfgWhAgTprxrINN4gQ== X-MS-Exchange-AntiSpam-MessageData: SOOAOxtMZ2gLoKkyNHvMv9albEvGhYVw4n7ggPCcKWNcG9fNs5uyCNBl3rm570bVTn3YgxjMe8Kr7N+xuYb5xEl0ae0IDCxsKcvcD0ZA67RG9C1qmkrv42BeJyh7vgvRITUAjyQy9FqTm4v2ejcyug== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6566a71-1aa1-4d4e-6db2-08d7a9c64b0a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2020 23:02:22.5966 (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: PPKqqpatPa+xw+I0Qf47AustoC22USDwj6DgL2LtigB4OToSgrmwMn60uziXufLdgukESdd71hBhJ4uvAkxsAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3930 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/AMDSevVcCommon.c | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c index f18fbe97e147..93341a647e48 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/AMDSevVcCommon.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