From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.7508.1592976776457364618 for ; Tue, 23 Jun 2020 22:32:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=lERwmeIS; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: dandan.bi@intel.com) IronPort-SDR: bmQ7PW4Ne8engzuQGBfwUDJyyw3shqa4Uk0Bg9pL+NggKjFFSb0gPzFoWVBv/PY2HS0WdkXBFp Qbrd1C4R3qBA== X-IronPort-AV: E=McAfee;i="6000,8403,9661"; a="141829434" X-IronPort-AV: E=Sophos;i="5.75,274,1589266800"; d="scan'208";a="141829434" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2020 22:32:55 -0700 IronPort-SDR: bEV0mrQVhR6nbmYMbbTUuRnkZppzI+hxwqv2iSByIvWcuxgdDSGQDYGilABLIoHXVUe/LzmSdO JIqAynNEI8hA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,274,1589266800"; d="scan'208";a="354026976" Received: from orsmsx102.amr.corp.intel.com ([10.22.225.129]) by orsmga001.jf.intel.com with ESMTP; 23 Jun 2020 22:32:55 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX102.amr.corp.intel.com (10.22.225.129) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 23 Jun 2020 22:32:55 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 23 Jun 2020 22:32:55 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 23 Jun 2020 22:32:55 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.170) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 23 Jun 2020 22:32:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gxy2rFM0AQeD5cdF3i0HbQbVMadQ79914LC08uc8dlKjxnySX0JJwOBlyEilG1sQ2Df99/fwhuKKfBaVAzSlwc2Q7+wl2bg4OXyNgFnZyYRhZIza7mU7FkO0kttCN+qUMA70KHslmraqvtfWyKmUulPOvHn83DYNFY4PQCXzZT4m6qJL4eGjGj+mp0SiLRIwtUaPGdUHLE4M1K+qv0raZ2SN0rI4WvrUxlOMPOpeIN78riuokZnlG8b3PQOvPsOGHqAMzx0eseomQW6uO59YdokuHVqRp2yt1AXkBDqwSspCB3BNW0MJxfabJlFd1NefK5BdCrIj6v4eKBwl3hhCRg== 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=5baEg6F9aeWsfzbsaHUXk5FQcPzzaV6azDCdqhEjc88=; b=BtBRVM4UhSa/jEmnUbbruEowmbBCkdhecpSrtdKsbhE34Enn1u6B3Xzhb3D6rjkxjyiRvlm510HunY7wZHfpU/wWz5z2FHcsjw1YWJ2zmWLUUDhwJuZo0SoSXRQOnIG3vlgVDDb0I0BBxdFIap5XYbIyHy4RlN4cNvXcXE7zwptdwFGTYrnU+DGEa9vrVj123JoqfjzFxQ1WCmz8BTyj3E/6fP10jDAb8KCWZtdn8/BCVtsdhdeUqJm9/F+W7DenGp9xaPVk6hTcu0lEpQnZ/f3x2M09EcSd1LXn0+7PNt1ceV6ENOZWKFUyzdhZe8IubKi/DYeO0HVNS0werU8SmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5baEg6F9aeWsfzbsaHUXk5FQcPzzaV6azDCdqhEjc88=; b=lERwmeISZ/7Vr9PoYr+KA81IVLSFBe6QOI3QqEYVgKAXCyOyWwHjouytmJiKri+vJ2KjETeWpPdeGbhkI1lIE5kYPq9UVn1gKZlbLPW/oiOd+dYSL1yzcx9v7tFpZ+JAjKk+L45+yCp2Ohh1ZancEWgD7xUBs6HsKXNkW3h8f1Q= Received: from BN6PR11MB1393.namprd11.prod.outlook.com (2603:10b6:404:3c::12) by BN6PR11MB1393.namprd11.prod.outlook.com (2603:10b6:404:3c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.24; Wed, 24 Jun 2020 05:32:50 +0000 Received: from BN6PR11MB1393.namprd11.prod.outlook.com ([fe80::a1f4:15d6:9a79:de03]) by BN6PR11MB1393.namprd11.prod.outlook.com ([fe80::a1f4:15d6:9a79:de03%11]) with mapi id 15.20.3109.027; Wed, 24 Jun 2020 05:32:50 +0000 From: "Dandan Bi" To: Oleksiy Yakovlev , "devel@edk2.groups.io" CC: "Gao, Liming" , "Kinney, Michael D" , "Ni, Ray" , "lersek@redhat.com" , "Kumar, Rahul1" , "Felixp@ami.com" Subject: Re: [PATCH V2 2/3] MdeModulePkg: Add New Memory Attributes Thread-Topic: [PATCH V2 2/3] MdeModulePkg: Add New Memory Attributes Thread-Index: AQHWSak/WmqITA9XOUaRobNDuHJjx6jnPlTA Date: Wed, 24 Jun 2020 05:32:50 +0000 Message-ID: References: <20200623215556.80804-1-oleksiyy@ami.com> <20200623215556.80804-3-oleksiyy@ami.com> In-Reply-To: <20200623215556.80804-3-oleksiyy@ami.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: ami.com; dkim=none (message not signed) header.d=none;ami.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.36] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: dc3d48c8-d72f-43d3-1861-08d818000923 x-ms-traffictypediagnostic: BN6PR11MB1393: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 0444EB1997 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /c8T6gqimLjJvVTIxbVnM1/dCX+sBvqpYze+5KhhuxHF6IfyXl8ydVVFhvnGJ95Pc5RUV/soT0aKcVXLdTa1ePAVgDVuGK+UgksqXepyoQYisg94z1pMT8eRUpxWdhp27Y/nId++Vq/joZ5dfXyelj/Jac0PRUZmc3hBayYkSAdyEjtNPw2p72vmlIgscthnufnAoNG6gtbFRPTMc4IA9VrtgHtxX02K71QMEowoZva8vygFI8HA2plTqMUsYQQLxqZOVjqjc67PA+lSjhQfaFeWEzpIULhDg8/mmN4YAIavPutFqv9zy902ys966vgt x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR11MB1393.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(396003)(376002)(39860400002)(366004)(136003)(4326008)(66476007)(110136005)(316002)(53546011)(186003)(6506007)(26005)(55016002)(478600001)(8676002)(9686003)(71200400001)(52536014)(2906002)(66446008)(66556008)(64756008)(7696005)(83380400001)(66946007)(33656002)(76116006)(54906003)(5660300002)(86362001)(8936002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: N+TuE553K6tPWav/7NA9KBjWxbM/u8dPGfxgWm+2IwEoTnkDoXqDX2xo7Sj3k305IeoJyPfLauD2kdM7pFtBWrS696KqHUiVkKwDt+ZKFxlLdHM1QwkfcRakB2ysL8IPHh44WAqqdWgbjDohhEekq6h8078blQySBSqtpFlMUG3zxlqEv1G8CnCkZWHyY74tPw1VlX8w8ZxUSD5JD/1qJeRBFKNpWkItN+hXMa41oAhYXv9w2IgTjmrc4VWa0UhMxVHQ/WrHocrm0ey0akkVJ37HPj4pruy5i/kYKHXGXFwezKJKWjbPMRva+GL3L8VZSahT6Nr1LxIDjEm7Z6W7MSvIdcl5ugtyp1iYR3Sadl/aW7zlXo3QY9QjLD0vf+eGUQaTywPAfM2hPcJh7FseKs0qCnNata37Uhdefc9TfE5SIpEu6nQESUUXyVaaeCYQIAsCFuxcfoA3iz4g7TvVuFzPu//9MJcEm5bFwQYVZlxMoc7i8QNgqMtXpR7omeRT MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: dc3d48c8-d72f-43d3-1861-08d818000923 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jun 2020 05:32:50.3727 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 3JUhmX8XhL3m3lS+PS64gbJrFTshm3gXmd8VY7YkoGHn8u4mpkziRuG1Yhm9U9WFK+Y7BfKPMTHm5DTXBRQxSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1393 Return-Path: dandan.bi@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Dandan Bi Thanks, Dandan > -----Original Message----- > From: Oleksiy Yakovlev > Sent: Wednesday, June 24, 2020 5:56 AM > To: devel@edk2.groups.io > Cc: Gao, Liming ; Kinney, Michael D > ; Bi, Dandan ; Ni, Ray > ; lersek@redhat.com; Kumar, Rahul1 > ; Felixp@ami.com; oleksiyy@ami.com > Subject: [PATCH V2 2/3] MdeModulePkg: Add New Memory Attributes >=20 > Add usage of EFI_MEMORY_SP and EFI_MEMORY_CPU_CRYPTO attributes > introduced in UEFI 2.8. > (UEFI 2.8, mantis 1919 and 1872). > Use attributes bitmasks, defined in MdePkg. >=20 > Signed-off-by: Oleksiy Yakovlev > --- > MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 11 ++--------- > MdeModulePkg/Core/Dxe/Mem/Page.c | 9 +++------ > MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 7 ++----- > MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 10 ++-------- > 4 files changed, 9 insertions(+), 28 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c index 74f3b1b..2d8c076 100644 > --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c > @@ -35,13 +35,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > #define PRESENT_MEMORY_ATTRIBUTES > (EFI_RESOURCE_ATTRIBUTE_PRESENT) >=20 > -#define EXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_UC | > EFI_MEMORY_WC | \ > - EFI_MEMORY_WT | EFI_MEMORY_WB | \ > - EFI_MEMORY_WP | EFI_MEMORY_UCE) > - > -#define NONEXCLUSIVE_MEMORY_ATTRIBUTES (EFI_MEMORY_XP | > EFI_MEMORY_RP | \ > - EFI_MEMORY_RO) > - > // > // Module Variables > // > @@ -665,7 +658,7 @@ ConverToCpuArchAttributes ( { > UINT64 CpuArchAttributes; >=20 > - CpuArchAttributes =3D Attributes & NONEXCLUSIVE_MEMORY_ATTRIBUTES; > + CpuArchAttributes =3D Attributes & EFI_MEMORY_ATTRIBUTE_MASK; >=20 > if ( (Attributes & EFI_MEMORY_UC) =3D=3D EFI_MEMORY_UC) { > CpuArchAttributes |=3D EFI_MEMORY_UC; @@ -951,7 +944,7 @@ > CoreConvertSpace ( > // Keep original CPU arch attributes when caller just calls > // SetMemorySpaceAttributes() with none CPU arch attributes (for > example, RUNTIME). > // > - Attributes |=3D (Entry->Attributes & (EXCLUSIVE_MEMORY_ATTRIBUTE= S | > NONEXCLUSIVE_MEMORY_ATTRIBUTES)); > + Attributes |=3D (Entry->Attributes & (EFI_CACHE_ATTRIBUTE_MASK | > + EFI_MEMORY_ATTRIBUTE_MASK)); > } > Entry->Attributes =3D Attributes; > break; > diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c > b/MdeModulePkg/Core/Dxe/Mem/Page.c > index 1f0e3d9..2c2c9cd 100644 > --- a/MdeModulePkg/Core/Dxe/Mem/Page.c > +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c > @@ -1857,8 +1857,7 @@ CoreGetMemoryMap ( > MemoryMap->VirtualStart =3D 0; > MemoryMap->NumberOfPages =3D RShiftU64 > ((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress + 1), > EFI_PAGE_SHIFT); > MemoryMap->Attribute =3D (MergeGcdMapEntry.Attributes & > ~EFI_MEMORY_PORT_IO) | > - (MergeGcdMapEntry.Capabilities & (EFI_ME= MORY_RP | > EFI_MEMORY_WP | EFI_MEMORY_XP | EFI_MEMORY_RO | > - EFI_MEMORY_UC | EFI_MEMORY_UCE | EFI_MEM= ORY_WC > | EFI_MEMORY_WT | EFI_MEMORY_WB)); > + (MergeGcdMapEntry.Capabilities & > + (EFI_CACHE_ATTRIBUTE_MASK | EFI_MEMORY_ATTRIBUTE_MASK)); >=20 > if (MergeGcdMapEntry.GcdMemoryType =3D=3D > EfiGcdMemoryTypeReserved) { > MemoryMap->Type =3D EfiReservedMemoryType; @@ -1892,8 +1891,7 > @@ CoreGetMemoryMap ( > MemoryMap->VirtualStart =3D 0; > MemoryMap->NumberOfPages =3D RShiftU64 > ((MergeGcdMapEntry.EndAddress - MergeGcdMapEntry.BaseAddress + 1), > EFI_PAGE_SHIFT); > MemoryMap->Attribute =3D MergeGcdMapEntry.Attributes | > EFI_MEMORY_NV | > - (MergeGcdMapEntry.Capabilities & (EFI_ME= MORY_RP | > EFI_MEMORY_WP | EFI_MEMORY_XP | EFI_MEMORY_RO | > - EFI_MEMORY_UC | EFI_MEMORY_UCE | EFI_MEM= ORY_WC > | EFI_MEMORY_WT | EFI_MEMORY_WB)); > + (MergeGcdMapEntry.Capabilities & > + (EFI_CACHE_ATTRIBUTE_MASK | EFI_MEMORY_ATTRIBUTE_MASK)); > MemoryMap->Type =3D EfiPersistentMemory; >=20 > // > @@ -1935,8 +1933,7 @@ CoreGetMemoryMap ( > MemoryMapEnd =3D MemoryMap; > MemoryMap =3D MemoryMapStart; > while (MemoryMap < MemoryMapEnd) { > - MemoryMap->Attribute &=3D ~(UINT64)(EFI_MEMORY_RP | > EFI_MEMORY_RO | > - EFI_MEMORY_XP); > + MemoryMap->Attribute &=3D ~(UINT64)EFI_MEMORY_ATTRIBUTE_MASK; > MemoryMap =3D NEXT_MEMORY_DESCRIPTOR (MemoryMap, Size); > } > MergeMemoryMap (MemoryMapStart, &BufferSize, Size); diff --git > a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c > b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c > index 92a442f..7d1daf0 100644 > --- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c > +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c > @@ -42,9 +42,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include > "DxeMain.h" > #include "Mem/HeapGuard.h" >=20 > -#define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC > | EFI_MEMORY_WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | > EFI_MEMORY_WP) > -#define MEMORY_ATTRIBUTE_MASK (EFI_MEMORY_RP | > EFI_MEMORY_XP | EFI_MEMORY_RO) > - > // > // Image type definitions > // > @@ -221,7 +218,7 @@ SetUefiImageMemoryAttributes ( > Status =3D CoreGetMemorySpaceDescriptor(BaseAddress, &Descriptor); > ASSERT_EFI_ERROR(Status); >=20 > - FinalAttributes =3D (Descriptor.Attributes & CACHE_ATTRIBUTE_MASK) | > (Attributes & MEMORY_ATTRIBUTE_MASK); > + FinalAttributes =3D (Descriptor.Attributes & EFI_CACHE_ATTRIBUTE_MASK) > + | (Attributes & EFI_MEMORY_ATTRIBUTE_MASK); >=20 > DEBUG ((DEBUG_INFO, "SetUefiImageMemoryAttributes - 0x%016lx - > 0x%016lx (0x%016lx)\n", BaseAddress, Length, FinalAttributes)); >=20 > @@ -924,7 +921,7 @@ InitializeDxeNxMemoryProtectionPolicy ( > (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)) { >=20 > Attributes =3D GetPermissionAttributeForMemoryType > (EfiConventionalMemory) | > - (Entry->Attributes & CACHE_ATTRIBUTE_MASK); > + (Entry->Attributes & EFI_CACHE_ATTRIBUTE_MASK); >=20 > DEBUG ((DEBUG_INFO, > "Untested GCD memory space region: - 0x%016lx - 0x%016lx > (0x%016lx)\n", diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c > b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c > index 0385f1d..599a0cd 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c > @@ -39,12 +39,6 @@ >=20 > #define SMRAM_CAPABILITIES (EFI_MEMORY_WB | EFI_MEMORY_UC) >=20 > -#define MEMORY_CACHE_ATTRIBUTES (EFI_MEMORY_UC | > EFI_MEMORY_WC | \ > - EFI_MEMORY_WT | EFI_MEMORY_WB | \ > - EFI_MEMORY_WP | EFI_MEMORY_UCE) > - > -#define MEMORY_PAGE_ATTRIBUTES (EFI_MEMORY_XP | > EFI_MEMORY_RP | EFI_MEMORY_RO) > - > // > // Function prototypes from produced protocols // @@ -1710,7 +1704,7 @@ > SmmIplEntry ( > CpuArch =3D NULL; > Status =3D gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOI= D > **)&CpuArch); > if (!EFI_ERROR (Status)) { > - MemDesc.Attributes &=3D ~(MEMORY_CACHE_ATTRIBUTES | > MEMORY_PAGE_ATTRIBUTES); > + MemDesc.Attributes &=3D ~(EFI_CACHE_ATTRIBUTE_MASK | > + EFI_MEMORY_ATTRIBUTE_MASK); > MemDesc.Attributes |=3D EFI_MEMORY_WB; > Status =3D gDS->SetMemorySpaceAttributes ( > mSmramCacheBase, > @@ -1727,7 +1721,7 @@ SmmIplEntry ( > &MemDesc > ); > DEBUG ((DEBUG_INFO, "SMRAM attributes: %016lx\n", > MemDesc.Attributes)); > - ASSERT ((MemDesc.Attributes & MEMORY_PAGE_ATTRIBUTES) =3D=3D 0); > + ASSERT ((MemDesc.Attributes & EFI_MEMORY_ATTRIBUTE_MASK) =3D=3D > 0); > ); > } > // > -- > 2.9.0.windows.1 >=20 >=20 > Please consider the environment before printing this email. >=20 > The information contained in this message may be confidential and > proprietary to American Megatrends (AMI). This communication is intended > to be read only by the individual or entity to whom it is addressed or by= their > designee. If the reader of this message is not the intended recipient, yo= u are > on notice that any distribution of this message, in any form, is strictly > prohibited. Please promptly notify the sender by reply e-mail or by > telephone at 770-246-8600, and then delete or destroy all copies of the > transmission.