From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web09.10434.1619783538721945423 for ; Fri, 30 Apr 2021 04:52:22 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=drkoQWWW; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: , mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZmmpjELLc0Y4FG+Z95c/+F0KTkc06LQNBNFYY+4f+xkjuTS+ZvUVKEyUbNTmBPXZj0jvNi4vdLM8irkyHE4/zZgjHWw5If50vM2c50Eqbt++K2XC1gVNQtVhugBCq8g+xnvC3jM8nM7WAC4GgqaIkOflJ1f81Cmzt0/lara2NHYwHfgRVo+ot55i74igV2K7+Nxg+TU7nbeYmyurhDnCV1qg99NN73uEgicbYXiYlhowGUNBHFxDCW08ql+Gterex0I6QQDap79oJqix88yJPQCIFKaIR7bvm0wOQKhlurSy5c1MlxeQ8NdQhFVkdhaXtYr0u5UilDB5mf1+U5rcuA== 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=Byhfge6Nvsxtftjtpo0JvnbTd2aoR7vZz2tST6qCeG4=; b=b5vSUg6QH/OEBQqYm8M9E6Pw1/7eDxR6P9S2zOEMDaXXbGmqBW16eMsWfL9PzWoYO0kWQwpE8alQiGSFYf83ZyuGeWhjWoeY+iSxgXpZH4jNA9o0nZe628slDAws9wwGWJqr2Rr3tb+eVluU2P/hEu5HgNfdHQ5RsgBpQaTOEWyDOgrbikcz1qbqr9fXW2Q7zAYLzDvA3LAWWWXvhevfMxFMnIew8pA3FipTp2rSvaWFsrjPkQYgEAk2b6VrWmEW6aDp0C6TvqgRWs6ZFdlyKKkR/u9g8TX1zJBWVe1r8+6aWb7uv7JBB2ENRiz4niG9Vm/PZhXif/Ap7yU9XeK12Q== 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=Byhfge6Nvsxtftjtpo0JvnbTd2aoR7vZz2tST6qCeG4=; b=drkoQWWWGi+siEitq0Z+Te3X3A1Y6KXua2D6fhLSCcq4XrlGCLqmMPnoXdQUKX02ju7PKgE8jcSvdm3tyTCHKRdl/A2Vuv/8jj8R8GhhIe7tdHPpvVWw6PG/suB2gpfaM2jJfd4+tWmgTEFdgyrlWyptwyfQWHUtDsa/qjv2lCk= 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 SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SA0PR12MB4349.namprd12.prod.outlook.com (2603:10b6:806:98::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.23; Fri, 30 Apr 2021 11:52:20 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::9898:5b48:a062:db94%6]) with mapi id 15.20.4065.027; Fri, 30 Apr 2021 11:52:20 +0000 From: "Brijesh Singh" To: devel@edk2.groups.io Cc: Brijesh Singh , James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Laszlo Ersek , Erdem Aktas Subject: [PATCH RFC v2 07/28] OvmfPkg: Use MemEncryptSevClearMmioPageEncMask() to clear EncMask from Mmio Date: Fri, 30 Apr 2021 06:51:27 -0500 Message-Id: <20210430115148.22267-8-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210430115148.22267-1-brijesh.singh@amd.com> References: <20210430115148.22267-1-brijesh.singh@amd.com> X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SA0PR12CA0006.namprd12.prod.outlook.com (2603:10b6:806:6f::11) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) Return-Path: brijesh.singh@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sbrijesh-desktop.amd.com (165.204.77.1) by SA0PR12CA0006.namprd12.prod.outlook.com (2603:10b6:806:6f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Fri, 30 Apr 2021 11:52:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9580fd44-269f-4e39-34cc-08d90bce68df X-MS-TrafficTypeDiagnostic: SA0PR12MB4349: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K+KKX31megSKJy1piVJETgsS+3qvLJPtbR+tiAsksnmxcLXy0/Oizy3z1JhzMrEXKo63HrdcFqve79d9ZdTQEhRnt3d3XaPoUM3IuaOWOvx36+OX9DiTBsZabiv7n+5CgTuFh/BJSbkIjD2Q7iP28/FUydbVLbDYHfNffprnzd90n7unM1K+LoiI8TZvgv4ao45r4TyydTJWWCNmRXpGXXSoJrGmd+RjRQbMkxj8zLk+XficxaAcPB7+w4wEV/UScTEkUn2vKfJO5JPfI6Bl97iaO6wpHvdZjm21gheqBZZ8AzcxK5FNTZ8SFvJQ+iJnoGOEcAw7W/qyZlAbDPrUnvlaY6Ww5fMgJig7t6t0LypL2ghVQNOa8QjZmzygCxaNnZNsGSuGFh9Zu4ekwmO3iYY1A/ws5qqft1p31RmqC8nQAq+nKbfx8GgtOrxJrQp8lVJBiwiNpICwEHL7qTwldE+np4Xe8cNjO03DqD32arU1B6Kx0V3Hr0s7j73hj6SCay/2DUpzi2yrLgs3I8Laf6NKrrksqtiA09X0ggZP3PB2LAeYEFhatRwkm9ZUskguBJZ9giwwtoEnXrWHdnfuzCsHgzk1sYlyJWjQYGD5d7dzu132E3suE7Urb6cvoJwiOX9gHDUlq8Xmgoq6+lTrENBVUtJ7xyJaA4u6gbx72XPCQZYIQUxA00WiDlxrpU8Vy03zuWn4fk6Sv5vrS8THSC7s89lCn5mgbwyVOz6eQw4bFFiCwoawTY8C3ZuzmKc1N9YvV0FUmLyIsKmlACz70Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(366004)(396003)(346002)(136003)(376002)(966005)(38100700002)(2616005)(26005)(1076003)(86362001)(316002)(6916009)(8936002)(6666004)(2906002)(4326008)(52116002)(66946007)(5660300002)(186003)(54906003)(44832011)(36756003)(66556008)(8676002)(66476007)(16526019)(83380400001)(478600001)(956004)(7696005)(38350700002)(6486002)(213903007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?CWyiIWOKANzInLM0z7h8uuFdpuGIPTy5pDcrJuAOe9OATOd3yzrhp0JxK19F?= =?us-ascii?Q?yxGEctOjJx4vf2CBgydwVZB/hNrQmokFM3vFFNIN5yyPbOvBF0DY+QBzv+8j?= =?us-ascii?Q?9ZRpoModJx6+GyRPu4Wz5Ckx69QyR70LgtxhIHDzysCkTvOgIgpfA5utFHpO?= =?us-ascii?Q?Aieoo8v/YYPVn1gX0AqLgBUiYJmht/08t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?Q?SYr8E3XnbUFP68McBlN+wIwRkm2i5oq4Jv443zHqoTgTJU6Sty+PWkEFcz5c?= =?us-ascii?Q?DRYmVOI7e4CYKmC0UMGQhr1ecURnFoDlg5fPRIju7ijPWramEyxdE1DZlfwA?= =?us-ascii?Q?grONKsU1LM6djrrXkx3NPdNMyphTRyrBbuO1g2lEGHeO7SIG2k/loFC47PYe?= =?us-ascii?Q?Cyar0Hul6P5aKrEi1l5jsp6l8W+Tp+C/GgUVcOOrqZCAw3QgCNb267+gsNX1?= =?us-ascii?Q?/QiLsbBxV7VsgH4khze8Rytz?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9580fd44-269f-4e39-34cc-08d90bce68df X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 11:52:20.2111 (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: EsFWt1bFP9RXl1Xft1amRXvzJcRVWl1R7e6G1rwkW44ktgP3jC9ptGM3usGPIlf4sJuM5tM3YsmGIGpBHrkKeg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4349 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3275 Use the MemEncryptSevClearMmioPageEncMask() to clear memory encryption mask for the Mmio address range from the current page table context. Cc: James Bottomley Cc: Min Xu Cc: Jiewen Yao Cc: Tom Lendacky Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Laszlo Ersek Cc: Erdem Aktas Signed-off-by: Brijesh Singh --- OvmfPkg/AmdSevDxe/AmdSevDxe.c | 10 ++++------ OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c | 5 ++--- OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashSmm.c | 5 ++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index 689bfb376d..80831b81fa 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -53,11 +53,10 @@ AmdSevDxeEntryPoint ( Desc = &AllDescMap[Index]; if (Desc->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo || Desc->GcdMemoryType == EfiGcdMemoryTypeNonExistent) { - Status = MemEncryptSevClearPageEncMask ( + Status = MemEncryptSevClearMmioPageEncMask ( 0, Desc->BaseAddress, - EFI_SIZE_TO_PAGES (Desc->Length), - FALSE + EFI_SIZE_TO_PAGES (Desc->Length) ); ASSERT_EFI_ERROR (Status); } @@ -73,11 +72,10 @@ AmdSevDxeEntryPoint ( // the range. // if (PcdGet16 (PcdOvmfHostBridgePciDevId) == INTEL_Q35_MCH_DEVICE_ID) { - Status = MemEncryptSevClearPageEncMask ( + Status = MemEncryptSevClearMmioPageEncMask ( 0, FixedPcdGet64 (PcdPciExpressBaseAddress), - EFI_SIZE_TO_PAGES (SIZE_256MB), - FALSE + EFI_SIZE_TO_PAGES (SIZE_256MB) ); ASSERT_EFI_ERROR (Status); diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c index 1f285e0083..ab40087a84 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c @@ -205,11 +205,10 @@ MarkIoMemoryRangeForRuntimeAccess ( // memory range. // if (MemEncryptSevIsEnabled ()) { - Status = MemEncryptSevClearPageEncMask ( + Status = MemEncryptSevClearMmioPageEncMask ( 0, BaseAddress, - EFI_SIZE_TO_PAGES (Length), - FALSE + EFI_SIZE_TO_PAGES (Length) ); ASSERT_EFI_ERROR (Status); } diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashSmm.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashSmm.c index 7eb80bfeff..ea75b489c7 100644 --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashSmm.c +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlashSmm.c @@ -38,11 +38,10 @@ QemuFlashBeforeProbe ( // C-bit on flash ranges from SMM page table. // - Status = MemEncryptSevClearPageEncMask ( + Status = MemEncryptSevClearMmioPageEncMask ( 0, BaseAddress, - EFI_SIZE_TO_PAGES (FdBlockSize * FdBlockCount), - FALSE + EFI_SIZE_TO_PAGES (FdBlockSize * FdBlockCount) ); ASSERT_EFI_ERROR (Status); } -- 2.17.1