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 [40.92.21.10]) by mx.groups.io with SMTP id smtpd.web08.41612.1609128908802207687 for ; Sun, 27 Dec 2020 20:15:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=bUQfnw1U; spf=pass (domain: outlook.com, ip: 40.92.21.10, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MHTuiQS0Hyv5aYj/i0bqUyXmWiwTHBXZme3mOFlufqf3/CL8BqCK83cRdg9kwgdDY80rdGEL5NA/JnGndSZkDbD02uew9YTKloiM+C2s7XgifVmYYfRyycT3eZz1uGr4vtK1rkLtBfuaxDT/U2HG++oEMsSA55VX/75bxfADaQqe/OMo9POMJ6fQRcp+r/N/kSfmCjNgJsZ2pAybqbEN4oO/gpKLQY287Xfqh5ehuyjpN5GURZXvDX+USSJSX0Y5l9ASV2vwDPFQd2KEAyMR5iqMW+lYZhP1yhPIi3UKnlQ3qYiEeabsw+bWM/fBQ7IAy6WGc3rp/vrG4TWMqm9xgA== 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=lRap+84qDT+6O1gQqmmtglz5bbsVUIiipw6/ymUwG8I=; b=KhAGari8Y90Iz9IO46aY81DGnCRLNXF7M8//2i14W37pNNWvXtWZL5atFU/NqarPQvekM0vna845hfn6v8ZIf2+TfIpgOq6/fgJwAZqYswZxLaXshxIIXjnKtnUnoum600l4gqu9VXSJJzGWaN4Cxf0oLN5UDiNUFHv+3/82jmQ+koEB/jCgN80sFlyc4zPIlxd7vvqFBHTkgpKMPHSuOe7GFL5pqG9GlBKfXgYdisdzqlb/LYWlVxlyH2hPv4PzXgI/FyLVAClcniPPMhDewBFhPLYmxF9SqI5egNlg+MMZiVnBOzjs2AdAfV3vSU2ew+Ri+XDsrFg4FqenW/pSRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lRap+84qDT+6O1gQqmmtglz5bbsVUIiipw6/ymUwG8I=; b=bUQfnw1UFy6pPim3ckbF3I0o/GOfFd3iEXqot4GQrT3MJUylLXXjzdU9J4KFeleTwvxCjzfLiH/xLbJfENKOUw9pWAAqAPSkmuHhtvS1xna2QBwCpbiEcBgEfBwWq9zIwqsshqKRIm0n2TXiLvwTYpA9j0uKL0TejXlbi+/AI9KEeqIt0rHv51HP+OHh4mWbajLwNiDh4CaknwqeqaGC/lZSiiDoivitgTUbtmyYG9r8EUN3lH4ny+Bg+wHShk8QFyLsx3wUNStjIB0ZkfR2IUJcEHCB3f0Vpe/dgZyw0RS2KmtuDnLoGfBTLV6iezb0VvFuxWAxub2aNOM2OjwRFg== Received: from MW2NAM12FT029.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::4f) by MW2NAM12HT012.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::442) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.10; Mon, 28 Dec 2020 04:15:07 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:fc65::46) by MW2NAM12FT029.mail.protection.outlook.com (2a01:111:e400:fc65::318) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.20 via Frontend Transport; Mon, 28 Dec 2020 04:15:07 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::acb3:ab69:563d:b0d6]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::acb3:ab69:563d:b0d6%5]) with mapi id 15.20.3676.035; Mon, 28 Dec 2020 04:15:07 +0000 From: "Kun Qin" To: "Yao, Jiewen" , "devel@edk2.groups.io" CC: Ard Biesheuvel , Sami Mujawar , Supreeth Venkatesh Subject: Re: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture Thread-Topic: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture Thread-Index: AQHW1W6n7OPNuBsfz02gKe4Obw+H9KoLsxMAgABABnM= Date: Mon, 28 Dec 2020 04:15:07 +0000 Message-ID: References: <20201218185011.1366-1-kun.q@outlook.com> , In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:F7A37E82FBE71BE5AD947B39CD84AE4B63E7236D51A4A742E77048C1FF4A0C62;UpperCasedChecksum:E80901BAE9167FF79F49BE906AD39145FBC9865991C2980B56C3FA7AFE54767D;SizeAsReceived:7219;Count:44 x-tmn: [/6D3qpGjY/fIRpUVrJQrjPB5CrnaiU3b] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: a1f43868-ad3d-44f3-8063-08d8aae728e6 x-ms-traffictypediagnostic: MW2NAM12HT012: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: FQYeDPhj0rpdAwK1iZO5IfXijLVEnP2ha70UNHig3XdEBydVQcxmqNNoZG5CTWO0mCNd0i/2AjgGlj9FgWtg6Ncf8F/mocSprHm/iAAcrb3BC8EK+vCaMnaUVWMWZFq5Fm+MlmrpZvc1eZgtxYel6SWncTiDRAZYffxTUhUR3oUrut7GvMA0tIrTxQTpOwJ1GYHi66QNCXgryA+URbb7Wo7857ZPiCTYOQeRnQrSZELzC1nCT1WEOpS2tuZuNFww x-ms-exchange-antispam-messagedata: PmXA/P+nmoGnZ38vhssTlee/fImy5jSXqcd7Jr+CsJAAG45g96UnqPwwMAt4b88zx+bnUbI5RJHeA+4gWxbQvWtHX3h1telCvx7ZIBH1bV7EOjOoorkAseb7vCMNBmmy2yGC0E4a7vAfAHRG3Ii0Zw== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: MW2NAM12FT029.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: a1f43868-ad3d-44f3-8063-08d8aae728e6 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2020 04:15:07.2787 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT012 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MWHPR06MB31029087C07954C196EE0E08F3D90MWHPR06MB3102namp_" --_000_MWHPR06MB31029087C07954C196EE0E08F3D90MWHPR06MB3102namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Jiewen, I did not fill these 2 variables for this patch because I thought to follow= up fix for this issue separately because the AARCH64 instance does not fil= l it either and I meant for this patch to solely extends the coverage to x6= 4 (and IA32). But please let me know if you think otherwise, I can add the = x64 fix in this patch as well. But I do not have fix for AARCH64 since I am= not familiar with how it should work. Thanks, Kun From: Yao, Jiewen Sent: Sunday, December 27, 2020 16:18 To: Kun Qin; devel@edk2.groups.io Cc: Ard Biesheuvel; Sami Mujawar; Supreeth Venkatesh Subject: RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends = support for X64 architecture May I know where is the code to fill below? EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges; UINTN mMmMemLibInternalMmramCount; > -----Original Message----- > From: Kun Qin > Sent: Saturday, December 19, 2020 2:50 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel ; Sami Mujawar > ; Yao, Jiewen ; Supreeth > Venkatesh > Subject: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: > Extends support for X64 architecture > > This change extends StandaloneMmMemLib library to support X64 > architecture. The implementation is ported from > MdePkg/Library/SmmMemLib. > > Cc: Ard Biesheuvel > Cc: Sami Mujawar > Cc: Jiewen Yao > Cc: Supreeth Venkatesh > > Signed-off-by: Kun Qin > --- > > StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMmMe > mLibInternal.c | 67 ++++++++++++++++++++ > > StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib > .inf | 6 +- > 2 files changed, 72 insertions(+), 1 deletion(-) > > diff --git > a/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm > MemLibInternal.c > b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm > MemLibInternal.c > new file mode 100644 > index 000000000000..c5e21c583f44 > --- /dev/null > +++ > b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm > MemLibInternal.c > @@ -0,0 +1,67 @@ > +/** @file > + Internal ARCH Specific file of MM memory check library. > + > + MM memory check library implementation. This library consumes > MM_ACCESS_PROTOCOL > + to get MMRAM information. In order to use this library instance, the > platform should produce > + all MMRAM range via MM_ACCESS_PROTOCOL, including the range for > firmware (like MM Core > + and MM driver) and/or specific dedicated hardware. > + > + Copyright (c) 2015, Intel Corporation. All rights reserved.
> + Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#include > +#include > +#include > +#include > +// > +// Maximum support address used to check input buffer > +// > +extern EFI_PHYSICAL_ADDRESS > mMmMemLibInternalMaximumSupportAddress; > + > +/** > + Calculate and save the maximum support address. > + > +**/ > +VOID > +MmMemLibInternalCalculateMaximumSupportAddress ( > + VOID > + ) > +{ > + VOID *Hob; > + UINT32 RegEax; > + UINT8 PhysicalAddressBits; > + > + // > + // Get physical address bits supported. > + // > + Hob =3D GetFirstHob (EFI_HOB_TYPE_CPU); > + if (Hob !=3D NULL) { > + PhysicalAddressBits =3D ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace; > + } else { > + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); > + if (RegEax >=3D 0x80000008) { > + AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); > + PhysicalAddressBits =3D (UINT8) RegEax; > + } else { > + PhysicalAddressBits =3D 36; > + } > + } > + // > + // IA-32e paging translates 48-bit linear addresses to 52-bit physical > addresses. > + // > + ASSERT (PhysicalAddressBits <=3D 52); > + if (PhysicalAddressBits > 48) { > + PhysicalAddressBits =3D 48; > + } > + > + // > + // Save the maximum support address in one global variable > + // > + mMmMemLibInternalMaximumSupportAddress =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, PhysicalAddressBits) - 1); > + DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddress > =3D 0x%lx\n", mMmMemLibInternalMaximumSupportAddress)); > +} > + > + > diff --git > a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem > Lib.inf > b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem > Lib.inf > index 49da02e54e6d..65ad0a48905c 100644 > --- > a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem > Lib.inf > +++ > b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem > Lib.inf > @@ -26,12 +26,15 @@ [Defines] > # > # The following information is for reference only and not required by th= e > build tools. > # > -# VALID_ARCHITECTURES =3D AARCH64 > +# VALID_ARCHITECTURES =3D X64 AARCH64 > # > > [Sources.Common] > StandaloneMmMemLib.c > > +[Sources.X64] > + X64/StandaloneMmMemLibInternal.c > + > [Sources.AARCH64] > AArch64/StandaloneMmMemLibInternal.c > > @@ -42,3 +45,4 @@ [Packages] > [LibraryClasses] > BaseMemoryLib > DebugLib > + HobLib > -- > 2.28.0.windows.1 --_000_MWHPR06MB31029087C07954C196EE0E08F3D90MWHPR06MB3102namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Jiewen,

 

I did not fill these 2 variables for this patch beca= use I thought to follow up fix for this issue separately because the AARCH6= 4 instance does not fill it either and I meant for this patch to solely ext= ends the coverage to x64 (and IA32). But please let me know if you think otherwise, I can add the x64 fix in th= is patch as well. But I do not have fix for AARCH64 since I am not familiar= with how it should work.

 

Thanks,

Kun

 

From: Yao, Jiewen
Sent: Sunday, December 27, 2020 16:18
To: Kun Qin; devel@edk2.groups.io
Cc: Ard Biesheuvel; Sami Mujawar; Supreeth Ve= nkatesh
Subject: RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: E= xtends support for X64 architecture

 

May I know where is t= he code to fill below?
EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges;
UINTN           &nbs= p;    mMmMemLibInternalMmramCount;



> -----Original Message-----
> From: Kun Qin <kun.q@outlook.com>
> Sent: Saturday, December 19, 2020 2:50 AM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Sami Mujawar
> <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>= ; Supreeth
> Venkatesh <supreeth.venkatesh@arm.com>
> Subject: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib:
> Extends support for X64 architecture
>
> This change extends StandaloneMmMemLib library to support X64
> architecture. The implementation is ported from
> MdePkg/Library/SmmMemLib.
>
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
>
> Signed-off-by: Kun Qin <kun.q@outlook.com>
> ---
>
> StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMmMe
> mLibInternal.c | 67 ++++++++++++++++++++
>
> StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib
> .inf           |&nbs= p; 6 +-
>  2 files changed, 72 insertions(+), 1 deletion(-)
>
> diff --git
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm
> MemLibInternal.c
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm
> MemLibInternal.c
> new file mode 100644
> index 000000000000..c5e21c583f44
> --- /dev/null
> +++
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm
> MemLibInternal.c
> @@ -0,0 +1,67 @@
> +/** @file
> +  Internal ARCH Specific file of MM memory check library.
> +
> +  MM memory check library implementation. This library consumes<= br> > MM_ACCESS_PROTOCOL
> +  to get MMRAM information. In order to use this library instanc= e, the
> platform should produce
> +  all MMRAM range via MM_ACCESS_PROTOCOL, including the range fo= r
> firmware (like MM Core
> +  and MM driver) and/or specific dedicated hardware.
> +
> +  Copyright (c) 2015, Intel Corporation. All rights reserved.<= ;BR>
> +  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.&l= t;BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/HobLib.h>
> +//
> +// Maximum support address used to check input buffer
> +//
> +extern EFI_PHYSICAL_ADDRESS
> mMmMemLibInternalMaximumSupportAddress;
> +
> +/**
> +  Calculate and save the maximum support address.
> +
> +**/
> +VOID
> +MmMemLibInternalCalculateMaximumSupportAddress (
> +  VOID
> +  )
> +{
> +  VOID         *Hob;
> +  UINT32       RegEax;
> +  UINT8        PhysicalAddres= sBits;
> +
> +  //
> +  // Get physical address bits supported.
> +  //
> +  Hob =3D GetFirstHob (EFI_HOB_TYPE_CPU);
> +  if (Hob !=3D NULL) {
> +    PhysicalAddressBits =3D ((EFI_HOB_CPU *) Hob)->= SizeOfMemorySpace;
> +  } else {
> +    AsmCpuid (0x80000000, &RegEax, NULL, NULL, NUL= L);
> +    if (RegEax >=3D 0x80000008) {
> +      AsmCpuid (0x80000008, &RegEax, NUL= L, NULL, NULL);
> +      PhysicalAddressBits =3D (UINT8) RegEax= ;
> +    } else {
> +      PhysicalAddressBits =3D 36;
> +    }
> +  }
> +  //
> +  // IA-32e paging translates 48-bit linear addresses to 52-bit = physical
> addresses.
> +  //
> +  ASSERT (PhysicalAddressBits <=3D 52);
> +  if (PhysicalAddressBits > 48) {
> +    PhysicalAddressBits =3D 48;
> +  }
> +
> +  //
> +  // Save the maximum support address in one global variable
> +  //
> +  mMmMemLibInternalMaximumSupportAddress =3D
> (EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, PhysicalAddressBits) - 1);=
> +  DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddre= ss
> =3D 0x%lx\n", mMmMemLibInternalMaximumSupportAddress));
> +}
> +
> +
> diff --git
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem
> Lib.inf
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem
> Lib.inf
> index 49da02e54e6d..65ad0a48905c 100644
> ---
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem
> Lib.inf
> +++
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem
> Lib.inf
> @@ -26,12 +26,15 @@ [Defines]
>  #
>  # The following information is for reference only and not requir= ed by the
> build tools.
>  #
> -#  VALID_ARCHITECTURES       =     =3D AARCH64
> +#  VALID_ARCHITECTURES       =     =3D X64 AARCH64
>  #
>
>  [Sources.Common]
>    StandaloneMmMemLib.c
>
> +[Sources.X64]
> +  X64/StandaloneMmMemLibInternal.c
> +
>  [Sources.AARCH64]
>    AArch64/StandaloneMmMemLibInternal.c
>
> @@ -42,3 +45,4 @@ [Packages]
>  [LibraryClasses]
>    BaseMemoryLib
>    DebugLib
> +  HobLib
> --
> 2.28.0.windows.1

 

--_000_MWHPR06MB31029087C07954C196EE0E08F3D90MWHPR06MB3102namp_--