From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (NAM02-SN1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web11.16081.1620419958521088408 for ; Fri, 07 May 2021 13:39:18 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=W5HMQnQX; 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=jmr5uqQAFNtRPnx+HbIZQsdI8gcfWX5C2GEwWP5LMQQ/w1PxEvnTez+oIK8w99F1Q+0WC7DIEazzN6amtUTHIQCb1aIEQwEsxUIuaBuXEuZNynimu4svlNeoNbhlNYij5n8tFasDQOtnCf8CQy0SAtbzKWc2Rcs3N6oSF0HFLlzprOmB8y7mabI/4gDDqQxfJ3hvY7LXf70aZERNJV2+K7eoU3XC4ox1PuosuE1jpASy9qX9tIsx3yKbva1lHPMRe7o6M+L3GdAnGu/6ec091yIgMaZY/vFNKyouXprxxxQ08c2rQQMsM6hGFad1PMyp/k8oUjQNzhvz4GlCWY0lUw== 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=DC1Vs24sVCC8+Hq/SuyPrfoqaejsPpDZmTlxYftqwmU=; b=WgzQ6URkzp0UW93NNZjMMeytCHmqpBJ/ytTHe23B8sK4IqGkidAPA3iHSmVayFXX1xhgRSH3buoKaI8hlktnExIF8YcsGx/cL0b5//KRHS7h+2j3O8DbcU8UfB6jBZW7Pdlad5p1SFP0ZAk1Z1ZKq74J/whPTNRhVIXq2ekzOJ/JdbxJwanS+1itimOQKTuBRC/QhrzLohJtJY22csD9R/pFpl9f4feHoXg5IsU1nL6srTOz7DpH9DlHs8AsbudpnCSJbM39EiOYhQ6zLwPxlqsqF3PHKchVeAJUzdVtlrQYEYOIldS0jEdRErMpYrjZ3a0pECLJ+RukQ/GGPJtcBQ== 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=DC1Vs24sVCC8+Hq/SuyPrfoqaejsPpDZmTlxYftqwmU=; b=W5HMQnQXQvJBVZKqkF3IspH3gU9DE7rzoBkgvtYSZZzsMjOdnqs+C9Uv0sGCLjjK1I4U6nu2sMWtu7jVQ9qJkFduCCp5lQ0cxXj4DPnv5AL3eWvZoB+OIR6eKmaU3F10J5or2U4AM5tbdjv8luc5FE5d7RUGR4vqp8BumHnazuA= 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 SN1PR12MB2367.namprd12.prod.outlook.com (2603:10b6:802:26::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.27; Fri, 7 May 2021 20:39:17 +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.4108.029; Fri, 7 May 2021 20:39:17 +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 13/13] OvmfPkg/BaseMemEncryptSevLib: remove Flush parameter Date: Fri, 7 May 2021 15:38:38 -0500 Message-ID: <20210507203838.23706-14-brijesh.singh@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210507203838.23706-1-brijesh.singh@amd.com> References: <20210507203838.23706-1-brijesh.singh@amd.com> X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN7PR04CA0020.namprd04.prod.outlook.com (2603:10b6:806:f2::25) 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 SN7PR04CA0020.namprd04.prod.outlook.com (2603:10b6:806:f2::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Fri, 7 May 2021 20:39:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2907b982-d5c0-4a18-15d5-08d911982eda X-MS-TrafficTypeDiagnostic: SN1PR12MB2367: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BEmyuivuvYI0M8ZIbH5VewEFh7xpNRuKG8BaFAmpm0WKyiLB+FGdLEGaY2FLNPRVA5/bk+OXP4etCVxZDRgKxm7ZkCVDJ14Y/bSTzq0zDapREuTFuqp6pEfNvjT9JxjeFQ8vKVWYh5i+8AJZQ9E3E4uhmeGW2ZGZYTo9xun8v2tgfzZTCAflnyQUjPCq2KYUWYnXEfQK1BumvYVZRHuLuH/OjWKO3IKSkspirzxKCOh0M+6Da2lxkYL4jWvnQsdAYuVJlQCYIP3CCoHLhpqmFeF0HcGGu6c5pXroC9G4TIiaH2+Mzgh7ERwk2s2if8/FULxQhtXIuFEJ8g4AsPrdQHjJmdgRIse3LDRsLijFYdUHyBeszNU+CwTeHqquV1ISBxbdBqF6zgG2yg/e4aC7Lbjf1MCs3N+S2Oi43Y/qNvSiiTlHo3R4zxJEi51oA74JDWlHgAIGWC7qnaLZChwF1rEXJfFNJafdSbwzvsozSqxIXTcc4HMeZhmOhRKdA7exvWlfoGwc41Xl8MYOqZ7peIIlJ7EN1uUAopfUgXF3Qm1e5q45mUGRmJwiLEQUig/7pSt+ZWdJuGcJ4ZlAvlGbvOpt/D7ZGdVNAVdoUSw+rstGBxqydFfMwzZdCtgn693j72aYgMMf6/0k+ORrFNgnEUdE5nkGMO563d0Jh288QT9HDDfGV4XvjIkKgqrW9tNxBVcF++HAGq0eqBwNU5UWqOZpPL/4n0+PIpUvOeqD9MfMelZ7ql93NBNOAOzTiYxK 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)(376002)(366004)(346002)(136003)(396003)(39860400002)(2906002)(316002)(1076003)(6486002)(19627235002)(8936002)(30864003)(4326008)(54906003)(186003)(7696005)(5660300002)(83380400001)(86362001)(6666004)(966005)(6916009)(956004)(66946007)(52116002)(38350700002)(16526019)(44832011)(2616005)(478600001)(38100700002)(66476007)(8676002)(66556008)(26005)(36756003)(213903007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?h5pGTz7IQ3uSq1vAcA7mHJCSJ8oftlbNIPoMzCpXsFPMRTR5KKRD/yyYzarz?= =?us-ascii?Q?GF0L/R6e7yLPHpoleUjvivujK9xZbxV0Nk4aEd1D0E6tObWgp2kWUD+F21rP?= =?us-ascii?Q?HnhsbisB1Xd+nNz4oZgneJIs2CMbYjHReUt33QFRXuGwqskuEVtYNuPkCpDt?= =?us-ascii?Q?OW4o7IC9mwBuCf30fOPSfpSNoPqzdbm9NhINe0D1RccI5/LfXcrJWIXB+iCA?= =?us-ascii?Q?eTSN14Bxzav2XKxwEgTMYRl3vN+2o2D+2z4wP1CAhOoEFV2J1sn8DvzNNjio?= =?us-ascii?Q?CZSJYIrqXEHHDMvCe766b3um17sZZ96K2juJ/yKPYDgDbxs5boTo8bnm4rSk?= =?us-ascii?Q?7YURa78DBqx4SIk3xi0zAn2W964vWyKNRUYtC6EVtcPPV1K4yQrxgUb8juAA?= =?us-ascii?Q?Jij9m0bpFagf+AbA7uytExwnSRKjzvMfzxLQuEHOPF6v5uPEsTdozRjN2cP+?= =?us-ascii?Q?+vssouR5NR1KO+2NMJbUl+8uL1cnFxlBef55AIcE1CBPRGhyTWUwLdFtDwsS?= =?us-ascii?Q?NoYJtghtAjaacXouSQ7NUEuSSmcFp42a0Sadq4KM6/UEJSMyKQ4SQcoNpNf8?= =?us-ascii?Q?2siWPjvurK8ChEu49jMIozINnDrW96C72YwOGGwQsthLNhMB+ywuAbne2TcU?= =?us-ascii?Q?dFwx4PjavZnY4uqU0z38WxAGyQOOSjgy9AFRRCkugnLG67VsZ3LlY9fs5jUr?= =?us-ascii?Q?bsZHe7HwnMGaSZ5ggFtDTGz0c4yizgsIfpe6GD9mnmvV/oBOecRZf+1MKCxK?= =?us-ascii?Q?qrvEtMmIqhEgCsD7TE+mbOj/GKVX061YRtci+8n9ijMFbqYyqHooGFaOGTJB?= =?us-ascii?Q?OHDT0I4BdM2+sV2Q9I/LyZMgCY7X3iUx5QlIa+wZwVrBwVuGPFl9XPzZL48L?= =?us-ascii?Q?KEc63S018T8T+zRl06hRCVkdaB0TrOVG72pe81fGrKYMhy6wEKU0LUUn0tZ/?= =?us-ascii?Q?KF47OQE0LsUR+X5UlCMrJmZT9CLM9aCfA/2kex+zzgsdVkzpa1sQsAgz8b/O?= =?us-ascii?Q?aMNejl7CyDzI0xywenINm+GYVEqk4BSyYJP2ixoR18Ug6R2WmlC1gFa39GvW?= =?us-ascii?Q?Wr4cHpaX6MHSKTNDbF2Kcl+quDVe8GyfIeiRQ1wSSnEaodhUSGPP3Vb2c05r?= =?us-ascii?Q?Sjc/ijqERZoqElTxUeJkI57Yp7f0SPwj+tyn3ri7fdfvsM+8CQhdZnyf8Gus?= =?us-ascii?Q?uLTlucYh2Nv8CUCgS+6nxWQ+7F0LrhKWvxkoPf6CgVql0fdPaBW8LC1c6jxj?= =?us-ascii?Q?2C8KIqbFmJjgSEWFVd4ORfE1FUw0bQVR5UyczclZLTxdxIhChZQ5Nci4daNV?= =?us-ascii?Q?ZrCwyse4h6i5lm61cNS1F4dU?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2907b982-d5c0-4a18-15d5-08d911982eda X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2021 20:39:17.0150 (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: 8HobcGXU/lFagoy2RODEScccDiFNDBCalzwyQ/85R0c1M48JXCFSKK4ac1jf9/Q7N+VJ/kWzwu9YkLGtYc3Bww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2367 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3275 The Flush parameter is used to provide a hint whether the specified range is Mmio address. Now that we have a dedicated helper to clear the memory encryption mask for the Mmio address range, its safe to remove the Flush parameter from MemEncryptSev{Set,Clear}PageEncMask(). 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/Include/Library/MemEncryptSevLib.h | 10 ++---- .../BaseMemEncryptSevLib/X64/VirtualMemory.h | 10 ++---- OvmfPkg/AmdSevDxe/AmdSevDxe.c | 3 +- OvmfPkg/IoMmuDxe/AmdSevIoMmu.c | 6 ++-- .../Ia32/MemEncryptSevLib.c | 10 ++---- .../X64/MemEncryptSevLib.c | 16 +++------- .../X64/PeiDxeVirtualMemory.c | 32 +++++++++++-------- .../X64/SecVirtualMemory.c | 8 ++--- .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 3 +- OvmfPkg/PlatformPei/AmdSev.c | 3 +- 10 files changed, 35 insertions(+), 66 deletions(-) diff --git a/OvmfPkg/Include/Library/MemEncryptSevLib.h b/OvmfPkg/Include/L= ibrary/MemEncryptSevLib.h index b91490d5d44d..76d06c206c8b 100644 --- a/OvmfPkg/Include/Library/MemEncryptSevLib.h +++ b/OvmfPkg/Include/Library/MemEncryptSevLib.h @@ -100,8 +100,6 @@ MemEncryptSevIsEnabled ( address of a memory region. @param[in] NumPages The number of pages from start memor= y region. - @param[in] Flush Flush the caches before clearing the= bit - (mostly TRUE except MMIO addresses) =20 @retval RETURN_SUCCESS The attributes were cleared for the memory region. @@ -114,8 +112,7 @@ EFIAPI MemEncryptSevClearPageEncMask ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, - IN UINTN NumPages, - IN BOOLEAN Flush + IN UINTN NumPages ); =20 /** @@ -128,8 +125,6 @@ MemEncryptSevClearPageEncMask ( address of a memory region. @param[in] NumPages The number of pages from start memor= y region. - @param[in] Flush Flush the caches before setting the = bit - (mostly TRUE except MMIO addresses) =20 @retval RETURN_SUCCESS The attributes were set for the memo= ry region. @@ -142,8 +137,7 @@ EFIAPI MemEncryptSevSetPageEncMask ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, - IN UINTN NumPages, - IN BOOLEAN Flush + IN UINTN NumPages ); =20 =20 diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h b/Ovm= fPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h index 8dc39e647b90..21bbbd1c4f9c 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.h @@ -58,8 +58,6 @@ InternalGetMemEncryptionAddressMask ( @param[in] PhysicalAddress The physical address that is the sta= rt address of a memory region. @param[in] Length The length of memory region - @param[in] Flush Flush the caches before applying the - encryption mask =20 @retval RETURN_SUCCESS The attributes were cleared for the memory region. @@ -72,8 +70,7 @@ EFIAPI InternalMemEncryptSevSetMemoryDecrypted ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS PhysicalAddress, - IN UINTN Length, - IN BOOLEAN Flush + IN UINTN Length ); =20 /** @@ -85,8 +82,6 @@ InternalMemEncryptSevSetMemoryDecrypted ( @param[in] PhysicalAddress The physical address that is the sta= rt address of a memory region. @param[in] Length The length of memory region - @param[in] Flush Flush the caches before applying the - encryption mask =20 @retval RETURN_SUCCESS The attributes were set for the memo= ry region. @@ -99,8 +94,7 @@ EFIAPI InternalMemEncryptSevSetMemoryEncrypted ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS PhysicalAddress, - IN UINTN Length, - IN BOOLEAN Flush + IN UINTN Length ); =20 /** diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c index 80831b81facf..41e4b291d070 100644 --- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c +++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c @@ -120,8 +120,7 @@ AmdSevDxeEntryPoint ( Status =3D MemEncryptSevClearPageEncMask ( 0, // Cr3BaseAddress -- use current CR3 MapPagesBase, // BaseAddress - MapPagesCount, // NumPages - TRUE // Flush + MapPagesCount // NumPages ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: MemEncryptSevClearPageEncMask(): %r\n", diff --git a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.= c index 49ffa2448811..b30628078f73 100644 --- a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c +++ b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.c @@ -252,8 +252,7 @@ IoMmuMap ( Status =3D MemEncryptSevClearPageEncMask ( 0, MapInfo->PlainTextAddress, - MapInfo->NumberOfPages, - TRUE + MapInfo->NumberOfPages ); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { @@ -407,8 +406,7 @@ IoMmuUnmapWorker ( Status =3D MemEncryptSevSetPageEncMask ( 0, MapInfo->PlainTextAddress, - MapInfo->NumberOfPages, - TRUE + MapInfo->NumberOfPages ); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c b= /OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c index 169d3118e44f..be260e0d1014 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c @@ -25,8 +25,6 @@ address of a memory region. @param[in] NumPages The number of pages from start memor= y region. - @param[in] Flush Flush the caches before clearing the= bit - (mostly TRUE except MMIO addresses) =20 @retval RETURN_SUCCESS The attributes were cleared for the memory region. @@ -39,8 +37,7 @@ EFIAPI MemEncryptSevClearPageEncMask ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, - IN UINTN NumPages, - IN BOOLEAN Flush + IN UINTN NumPages ) { // @@ -59,8 +56,6 @@ MemEncryptSevClearPageEncMask ( address of a memory region. @param[in] NumPages The number of pages from start memor= y region. - @param[in] Flush Flush the caches before setting the = bit - (mostly TRUE except MMIO addresses) =20 @retval RETURN_SUCCESS The attributes were set for the memo= ry region. @@ -73,8 +68,7 @@ EFIAPI MemEncryptSevSetPageEncMask ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, - IN UINTN NumPages, - IN BOOLEAN Flush + IN UINTN NumPages ) { // diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c b/= OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c index a2bf698bcde7..a57e8fd37fa7 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c @@ -27,8 +27,6 @@ address of a memory region. @param[in] NumPages The number of pages from start memor= y region. - @param[in] Flush Flush the caches before clearing the= bit - (mostly TRUE except MMIO addresses) =20 @retval RETURN_SUCCESS The attributes were cleared for the memory region. @@ -41,15 +39,13 @@ EFIAPI MemEncryptSevClearPageEncMask ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, - IN UINTN NumPages, - IN BOOLEAN Flush + IN UINTN NumPages ) { return InternalMemEncryptSevSetMemoryDecrypted ( Cr3BaseAddress, BaseAddress, - EFI_PAGES_TO_SIZE (NumPages), - Flush + EFI_PAGES_TO_SIZE (NumPages) ); } =20 @@ -63,8 +59,6 @@ MemEncryptSevClearPageEncMask ( address of a memory region. @param[in] NumPages The number of pages from start memor= y region. - @param[in] Flush Flush the caches before setting the = bit - (mostly TRUE except MMIO addresses) =20 @retval RETURN_SUCCESS The attributes were set for the memo= ry region. @@ -77,15 +71,13 @@ EFIAPI MemEncryptSevSetPageEncMask ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS BaseAddress, - IN UINTN NumPages, - IN BOOLEAN Flush + IN UINTN NumPages ) { return InternalMemEncryptSevSetMemoryEncrypted ( Cr3BaseAddress, BaseAddress, - EFI_PAGES_TO_SIZE (NumPages), - Flush + EFI_PAGES_TO_SIZE (NumPages) ); } =20 diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c= b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c index a18d336a8789..ad1021bd3e43 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c @@ -555,8 +555,7 @@ EnableReadOnlyPageWriteProtect ( address of a memory region. @param[in] Length The length of memory region @param[in] Mode Set or Clear mode - @param[in] CacheFlush Flush the caches before applying the - encryption mask + @param[in] Mmio The physical address range is Mmio. =20 @retval RETURN_SUCCESS The attributes were cleared for the memory region. @@ -572,7 +571,7 @@ SetMemoryEncDec ( IN PHYSICAL_ADDRESS PhysicalAddress, IN UINTN Length, IN MAP_RANGE_MODE Mode, - IN BOOLEAN CacheFlush + IN BOOLEAN Mmio ) { PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry; @@ -585,12 +584,23 @@ SetMemoryEncDec ( UINT64 AddressEncMask; BOOLEAN IsWpEnabled; RETURN_STATUS Status; + BOOLEAN CacheFlush; =20 // // Set PageMapLevel4Entry to suppress incorrect compiler/analyzer warnin= gs. // PageMapLevel4Entry =3D NULL; =20 + // + // The cache need to flushed for the non-Mmio address range. + // + if (Mmio =3D=3D TRUE) { + CacheFlush =3D FALSE; + } else { + CacheFlush =3D TRUE; + } + + // DEBUG (( DEBUG_VERBOSE, "%a:%a: Cr3Base=3D0x%Lx Physical=3D0x%Lx Length=3D0x%Lx Mode=3D%a Cach= eFlush=3D%u\n", @@ -828,8 +838,6 @@ SetMemoryEncDec ( @param[in] PhysicalAddress The physical address that is the sta= rt address of a memory region. @param[in] Length The length of memory region - @param[in] Flush Flush the caches before applying the - encryption mask =20 @retval RETURN_SUCCESS The attributes were cleared for the memory region. @@ -842,8 +850,7 @@ EFIAPI InternalMemEncryptSevSetMemoryDecrypted ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS PhysicalAddress, - IN UINTN Length, - IN BOOLEAN Flush + IN UINTN Length ) { =20 @@ -852,7 +859,7 @@ InternalMemEncryptSevSetMemoryDecrypted ( PhysicalAddress, Length, ClearCBit, - Flush + FALSE ); } =20 @@ -865,8 +872,6 @@ InternalMemEncryptSevSetMemoryDecrypted ( @param[in] PhysicalAddress The physical address that is the sta= rt address of a memory region. @param[in] Length The length of memory region - @param[in] Flush Flush the caches before applying the - encryption mask =20 @retval RETURN_SUCCESS The attributes were set for the memo= ry region. @@ -879,8 +884,7 @@ EFIAPI InternalMemEncryptSevSetMemoryEncrypted ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS PhysicalAddress, - IN UINTN Length, - IN BOOLEAN Flush + IN UINTN Length ) { return SetMemoryEncDec ( @@ -888,7 +892,7 @@ InternalMemEncryptSevSetMemoryEncrypted ( PhysicalAddress, Length, SetCBit, - Flush + FALSE ); } =20 @@ -921,6 +925,6 @@ InternalMemEncryptSevClearMmioPageEncMask ( PhysicalAddress, Length, ClearCBit, - FALSE + TRUE ); } diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c b/= OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c index bca5e3febb1b..24d19d3ca161 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c @@ -42,8 +42,6 @@ InternalGetMemEncryptionAddressMask ( @param[in] PhysicalAddress The physical address that is the sta= rt address of a memory region. @param[in] Length The length of memory region - @param[in] Flush Flush the caches before applying the - encryption mask =20 @retval RETURN_SUCCESS The attributes were cleared for the memory region. @@ -56,8 +54,7 @@ EFIAPI InternalMemEncryptSevSetMemoryDecrypted ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS PhysicalAddress, - IN UINTN Length, - IN BOOLEAN Flush + IN UINTN Length ) { // @@ -89,8 +86,7 @@ EFIAPI InternalMemEncryptSevSetMemoryEncrypted ( IN PHYSICAL_ADDRESS Cr3BaseAddress, IN PHYSICAL_ADDRESS PhysicalAddress, - IN UINTN Length, - IN BOOLEAN Flush + IN UINTN Length ) { // diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index fdf2380974fa..c7cc5b0389c8 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -283,8 +283,7 @@ SmmCpuFeaturesSmmRelocationComplete ( Status =3D MemEncryptSevSetPageEncMask ( 0, // Cr3BaseAddress -- use current CR3 MapPagesBase, // BaseAddress - MapPagesCount, // NumPages - TRUE // Flush + MapPagesCount // NumPages ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: MemEncryptSevSetPageEncMask(): %r\n", diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c index dddffdebda4b..a8bf610022ba 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -72,8 +72,7 @@ AmdSevEsInitialize ( DecryptStatus =3D MemEncryptSevClearPageEncMask ( 0, GhcbBasePa + EFI_PAGES_TO_SIZE (PageCount), - 1, - TRUE + 1 ); ASSERT_RETURN_ERROR (DecryptStatus); } --=20 2.17.1