From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.63]) by mx.groups.io with SMTP id smtpd.web11.12351.1625753314215322528 for ; Thu, 08 Jul 2021 07:08:34 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=sgLuQrFw; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.236.63, mailfrom: ashish.kalra@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aZroPnLWwGUwBRxf8wvR5D2eyoBq4ELRC1CGBET0Wkivi7PHjauxCrBzbuseYrGEn8mwUjU+mZ0Xyrgu6q9TGTOr47fHpmjVGf0rqXqtaCXU27uSENVwAvZ+nBxLXUP/OA+k6bdKS1MMrZ9lKSDCtNz44rd8XyqkQDr7YDKxgRmPJQokzfIqSdr7t7P4hdfAJAw5uqxEDIDeo4b8GRe3TjhFipdRTdlhjmRip9Cd0lIeGX7QdHqkmHM2SelL7SVpsOjbt3fIlG6tSa4Qu2JyOloWrnxt4PXyiesP/2rJ5XVcRoD1cnStz5tmaAUqNcpoTVoYO4TG/YYbnzYaDb0B8w== 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=vlwiqQkRMEAA6llGg4bEhWcx4SiZwhDeyRHUvZsYVUg=; b=METbOqbkTAArvFijQcVxsIrVXepuFSty62uuGA7RHj2mTHshK1tUd7cKoj4ALdoJlDuB7SMk81MvAtZyC//68T5LwUc/IneqaO1EltRR3gVH9A9ONPORWtaObJ3ehDOWp0k1J8qxH/LaZ11BLKdlPz4XL3Nuw9UB73zIVQeZeySJm7JOYd6PiNE1WKEktNpIWwz+9/pinqM7xkZTuTve1HcLclBmRjBjW3pHMhwnQPemh6XSvXgOm7+QBUiSL8CW4/1ymyhxvn4yQ/Px+RU6kfcPfWoAMZk5AsaU+Us1Ex8gOTFxFTaC6G/H1uUCWdX4YQGUNR+5IWY3f8foMjzYwg== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vlwiqQkRMEAA6llGg4bEhWcx4SiZwhDeyRHUvZsYVUg=; b=sgLuQrFwA3hIVScBlT/yPWB9jU8Hvu9pnAwrr6ogdQVqGeryaqiGfoYn5vVd/jb9VYuOBbu3tN5j5lbUXzi4pF/3/Ny8GC3JcIvKF/OA3NhVSGlBTqfgPOXMchtzwW+xd0w9x+kUdkCBJ7v7BWm0ye9SNMGNV5+BluG/9uLIKCM= 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 SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) by SA0PR12MB4592.namprd12.prod.outlook.com (2603:10b6:806:9b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Thu, 8 Jul 2021 14:08:31 +0000 Received: from SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::e8b2:38db:240f:b3ec]) by SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::e8b2:38db:240f:b3ec%7]) with mapi id 15.20.4287.035; Thu, 8 Jul 2021 14:08:31 +0000 From: "Ashish Kalra" To: devel@edk2.groups.io Cc: dovmurik@linux.vnet.ibm.com, brijesh.singh@amd.com, tobin@ibm.com, Thomas.Lendacky@amd.com, jejb@linux.ibm.com, lersek@redhat.com, jordan.l.justen@intel.com, ard.biesheuvel@arm.com, erdemaktas@google.com, jiewen.yao@intel.com, min.m.xu@intel.com Subject: [PATCH v5 2/4] OvmfPkg/VmgExitLib: Add support for hypercalls with SEV-ES. Date: Thu, 8 Jul 2021 14:08:17 +0000 Message-Id: <5cf6633e2510dd399aba0d8dbb7b979577e77c13.1625687246.git.ashish.kalra@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SA9PR13CA0123.namprd13.prod.outlook.com (2603:10b6:806:27::8) To SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) Return-Path: Ashish.Kalra@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ashkalra_ubuntu_server.amd.com (165.204.77.1) by SA9PR13CA0123.namprd13.prod.outlook.com (2603:10b6:806:27::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.12 via Frontend Transport; Thu, 8 Jul 2021 14:08:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 044c3ae0-649d-4e15-f4c3-08d94219ddaf X-MS-TrafficTypeDiagnostic: SA0PR12MB4592: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: reKAOc1oiRgLXf7cXy2PI6SkwanN6WAzUX6IzDydLAL50hfa46jpzj9jH/N1UWgLWR8fDpEBK+kAibHsbM3R0YOGK6bELULas/Qo+e784a3qNvUlbf94kY2vumRF/cRB5hCRsJl2PjKOiS55/C9ePCA8m5HhP/C+eAEnUv2IyNhm8K7fl5Bg4wRViqYDNgaUk36vGLlcpIqkCzDaaIw0SB0Hit/ERYw7UsbLu6BcUwCI78wwJXZPS2vaMrIjh5HL566i292/PMCQGctBaWVdhj5fDYC4y4PY2syiBAvjTW0BvEVfOzQFJrWjSioQk1bTw1jblQi3DiwV4gyPXQVp3tNzf4LGt6vi6zC9lOpyp+uyogKoW7hkRJKBq8Ti6oT8bpFt8cVG7X0iTAPxwQTVReyEi06QvWNEmXP/XVibaZ+pORR5iuQJeaT8SvKUcpV5g6MsYP3LlpnQSGEU7hwO/seDVhFLh3OV2NcY6rslFyOXyioFQikDwtd5yaXg5gaqu9Wa4JQgp+u1v2vKWTrGlgUwVO4lzL6yECCBuO1CKhr3Az4BPOlVGsv/dNm2Y/sWdXaF3wxWEtlk5cGK1yt+jUbDSWEmZAw3DqIEIBiBM1RbwmJCBqurDSRQhCEM1aAaltnIuapub/1HyjgTNO0Y6HgnzddZB/6vsGxu8oM2MaHBZ42+9IR0pHgPmA2lhIY1FO3P/akjoyZd4CDGP/VmQw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2767.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(376002)(136003)(346002)(39860400002)(6486002)(86362001)(7416002)(36756003)(6916009)(52116002)(316002)(7696005)(8676002)(2616005)(956004)(66946007)(8936002)(26005)(478600001)(5660300002)(186003)(4326008)(66476007)(66556008)(6666004)(38100700002)(38350700002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sofD34F0zjsCldyiDFCJb+g+YwUvWjRgyMrGOa1t2obTqRrFSAcXF1agy1kE?= =?us-ascii?Q?J8HPk2wngScxAldDX6M2HXwy/ZUbcNsMXYvN+LA7StjW3aQiwEeI073TRepI?= =?us-ascii?Q?Fn6xcy2vLFnUPHgue6/iYj53cPIXOhWruZP5bq8NRO9+s+ANp4bE3Ei1AXcw?= =?us-ascii?Q?S5B2xByZ4BYVKcRRGxDL0Lb4lGgB336hSSZJF3PD7bBw40e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XQel1Jz3QAjsfTi8xtCrFCmpUWSp0g/CLXmNR?= =?us-ascii?Q?XbFrMAP/XdWvCDJgNP4xWWsuV802ggkQ9SKFF15ifST46x3jwL4ENNccUBSi?= =?us-ascii?Q?7qr0fq6HlwBn/RLkl+d16hSxJaiJYH4719UrGp04k2na++K4f9Di5kKtRhDj?= =?us-ascii?Q?2JzmUGl9jC2g6L+6hMDPloDxQtV1UtQlTn/DJ1pJvb2iztv0bGidO+DpxPAg?= =?us-ascii?Q?Tnb+eIajQrt+UsGFB+NB+3AA?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 044c3ae0-649d-4e15-f4c3-08d94219ddaf X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2767.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2021 14:08:31.1946 (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: UG0V5P1ZxLGtJBl5c7+RCCH3U5/VrFf2n5jYi50UqHW2o3I8rimCzD0ebzC1NNN3Mazcr0lZcaPII9+C9uJabw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4592 Content-Type: text/plain From: Ashish Kalra Make the VC handler hypercall aware by adding support to compare the hypercall number and add the additional register values used by hypercall in the GHCB. Also mark the SEC GHCB page (that is mapped as unencrypted in ResetVector code) in the hypervisor guest page status tracking. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Signed-off-by: Ashish Kalra --- OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c index 41b0c8cc53..7f69bfab5f 100644 --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c @@ -1171,6 +1171,15 @@ VmmCallExit ( Ghcb->SaveArea.Cpl = (UINT8) (Regs->Cs & 0x3); VmgSetOffsetValid (Ghcb, GhcbCpl); + if (Regs->Rax == KVM_HC_MAP_GPA_RANGE) { + Ghcb->SaveArea.Rbx = Regs->Rbx; + VmgSetOffsetValid (Ghcb, GhcbRbx); + Ghcb->SaveArea.Rcx = Regs->Rcx; + VmgSetOffsetValid (Ghcb, GhcbRcx); + Ghcb->SaveArea.Rdx = Regs->Rdx; + VmgSetOffsetValid (Ghcb, GhcbRdx); + } + Status = VmgExit (Ghcb, SVM_EXIT_VMMCALL, 0, 0); if (Status != 0) { return Status; -- 2.17.1