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.web08.42474.1609137474828179805 for ; Sun, 27 Dec 2020 22:37:54 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=rPZ/ci7n; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: jiewen.yao@intel.com) IronPort-SDR: Ce2AJrLy/3mO5jOJR+LhH2L1UXRRgymWWp5cgRWjUsGWdVIGh91NOShtlIRQrK5eCAZJX4GRIg B88lz04FDLrw== X-IronPort-AV: E=McAfee;i="6000,8403,9847"; a="173773723" X-IronPort-AV: E=Sophos;i="5.78,454,1599548400"; d="scan'208,217";a="173773723" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2020 22:37:53 -0800 IronPort-SDR: 0F6rAtAmwuLR/6XIM2IAgArqO67dYPrpGdgyz8Eof/M+oSQG40IltPaxRFZ5J6wWxsjo2J/FZq JwYt2MFEEY4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,454,1599548400"; d="scan'208,217";a="399859197" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by FMSMGA003.fm.intel.com with ESMTP; 27 Dec 2020 22:37:53 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 27 Dec 2020 22:37:53 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 27 Dec 2020 22:37:52 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 27 Dec 2020 22:37:52 -0800 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.170) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Sun, 27 Dec 2020 22:37:52 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nkiwe8QMz1gROLo6EF3AUjjPngHlVTkI1D9ZtBwO9xWo17VXnYksrNYIwGQE9hbJIgxnv/EfiCe2Jmjg0YHOkpB+ylvRaPnfapvlSIqgKViGOLJ1JlVoTJwMqY2o0Z+ItTQXQUbQmfyrOJCBVYYlFryfmHgnlOz+JUdJRy+FZwt+5LMvRnsVv1RYiSh84SpO0B8dgbYQMTOnfE/J0rcj9s0gALJpHaPp+4i4M8Iu7UUFexHMJmAWoR1iTTWrXuwdMDkHFoZ0f/sxS6AA9LWh0ezX+ZmJNmNupeQAXVU5e5a4u3cqGYWAHGHqANcWQ6GzXKy/AipTB5XEV4oiXIj8SA== 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=bU798meVwESBBslS9oisYpw2O5uXPuVP669GeHj8/pY=; b=KRjnQD0KrGWcZPyL40HByBWWw37wRYBCg1DEN+/PmfO4DwqoT8Ue5jn/DViH5/phV57k59NPDzsZfnWo3ho2gHKwH5UNFCdFPu7Qe2eXsfi6k04X6Oon5Mbi/3iKRIqI3YHBFI0QxB+fgonCCDrbtRuIba5th6gzZtKWnVYdVYDJdWLfSjoHvUb0Vy3y2P79u27Kz8gVRUyXgAZupIOD85lYKo2EDopUSnowEwvAFzqLtbhiR1p+Wi7O+M2Lxrbho5PwRGC79LbLkbCAcqT5ZjiWrMQZzsQ+XUv0U+TTK7ESZ9svwC02vCYYA8pjfNVusaezIt3A07Y9NnIszG5dkg== 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=bU798meVwESBBslS9oisYpw2O5uXPuVP669GeHj8/pY=; b=rPZ/ci7nkY2UswmzobYFT43hWBY3B8846EdHiAGVAhF7xKEjIHgArA5pe3dpAp0xCTZXKOUfQGBM6iqs+tUKy+BUfjYCtJWaLjvkYNvEJWt6/GMxKpf9FRVvqxm40+X+TbQcv2bcrkUN6qKCPA3ihAIZcvuDKyWq+ViW41EE36c= Received: from CY4PR11MB1288.namprd11.prod.outlook.com (2603:10b6:903:23::8) by CY4PR11MB1992.namprd11.prod.outlook.com (2603:10b6:903:2f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27; Mon, 28 Dec 2020 06:37:50 +0000 Received: from CY4PR11MB1288.namprd11.prod.outlook.com ([fe80::e058:fd5a:28d8:2b17]) by CY4PR11MB1288.namprd11.prod.outlook.com ([fe80::e058:fd5a:28d8:2b17%12]) with mapi id 15.20.3700.031; Mon, 28 Dec 2020 06:37:50 +0000 From: "Yao, Jiewen" To: "devel@edk2.groups.io" , "kun.q@outlook.com" CC: Ard Biesheuvel , Sami Mujawar , Supreeth Venkatesh Subject: Re: [edk2-devel] [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture Thread-Topic: [edk2-devel] [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture Thread-Index: AQHW1W60Vk5xAW1fXUeG9eUbieXuqaoLsrVwgABCeoCAACNn0IAABBIAgAAAW8A= Date: Mon, 28 Dec 2020 06:37:50 +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: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.37] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d5f8f488-e1c8-410c-2a9f-08d8aafb1912 x-ms-traffictypediagnostic: CY4PR11MB1992: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mU/7MkKJJTqXJXDRnbAmcFU8HD4tDZS2AhH02R8U/jPL7YCf8IxYYvhDb31aHkQ6I34pN26OE+1ILMYX9zWr1hU+y5XFxLPSuxf6KuS0ad2s0e59IfK4PtzmmrloxUWsX9yjlztAr5iEJeFOgKvxZPbJM1H1nVEUBor3Lmdr6JNRqQrSErieHUCDoH5zao0xaqgII89fGjBZmT/hJ3ZRTfpYqFs+udrIUWB/gHUer3MAzwdx0XYmNVv7apPFn8o613uiO2RT3lKxHmdpcqlUmgKntgxRdRkfR508Nm44HOGhGq/3B8t+bQygp2AOl09O4D+KmtRWCfnHXtlCRqGIJR3PefcJwPtZBBVmHcbcEcogdOF1m9KnwYCo/grV/Mv3jI6W7rBG+yp345xbZEE8iesBVwyxMPFtAqfboeQ5UMjDitJoixXtZWZwI7Hj2k4DigdfeTVj9iM/72YQONi2pA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1288.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(4636009)(376002)(39860400002)(136003)(346002)(396003)(366004)(54906003)(66446008)(86362001)(7696005)(64756008)(66476007)(66556008)(9686003)(55016002)(166002)(26005)(76236003)(8936002)(66946007)(4326008)(83380400001)(33656002)(45080400002)(186003)(53546011)(6506007)(76116006)(316002)(71200400001)(8676002)(2906002)(52536014)(110136005)(5660300002)(478600001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?vLzObOBktxzO8Sqctsgu1efg987//RVtyvouCCmCV1lyz7lb8OmQiAMsPHTP?= =?us-ascii?Q?seN/fxdZYXgB81BwCxJShFWJCTWPTiQiMToEcr6sogqN0MkcirbqXiQGekaW?= =?us-ascii?Q?hvCWLWgWVh6GMvGeekEhH0HHjcaLS8YNqgnokioWSnnCQsswoAXTAa4scvUq?= =?us-ascii?Q?pv5wnPLTAxl5p7p9BS7igUpMYLsVeembJLAaZvZ4TImZDW8dt7/Yu2tGDq5C?= =?us-ascii?Q?SkKYZWYa8xkPNRJsYYzgYJwqgud4ITn4q0RbmvPiiFMl52QzZ/mPf/pxnkmY?= =?us-ascii?Q?RVaRWW/Rac+2WV+y9Or4DQ9HibN0J/DUBvjBx7+gRaJtQccjtHE2L1JyHxzg?= =?us-ascii?Q?Ij01107PyBBPxkASi4YTV6JXDQ/58q2E6q6olCXqlSudaiwhsQjFuwFpK7cm?= =?us-ascii?Q?HPlYzrX7W6MG2VQWojg0D+sJXQ9v0wSnpAXs6Gxw7AmJWoSyfIMNeU497e6d?= =?us-ascii?Q?B9LVGq6mtFYHPOnd4q/+rxRAcqg8i/vHJXiawqEmSAzFXRvhRkt0eUGGkCTd?= =?us-ascii?Q?/529ZhkQ7Q4sX9sFxwqHacqu+XdgruCKve8XkZFgaCZfWOudLOqXtWLUE3+/?= =?us-ascii?Q?Fq0r9PT2g5eZTdArTNNdGBXPD7f9p8SjA+Aa2//mLMvUNZZLgi7Q8GC1mu02?= =?us-ascii?Q?FURnQRwLv89AgXonVRNfZq5f3i94oOP0yY8qdZJWbJ8dBC+CUEPQYoFpgM64?= =?us-ascii?Q?avaSILGZkMFugtCkGFFOfwRnwJLDCyHeZv6v2qzgksjIPXvVSf4ipEBbQ9Zc?= =?us-ascii?Q?zKPdDrQKfK9IU9nqF4WLkM17p1I4RDmK2bedcS8P6yhUOefpg5QDchfydRZc?= =?us-ascii?Q?TLLHnsOcFwT7pkbYLjLiQNtD+GzpjeVYpKuEln9I8atydBE27UY1iMlDJ+PL?= =?us-ascii?Q?//BJrAfO2LQmlgzlgoQzPeRQG+0obdpp558P5kHQKfHlc4xHI/jKJJnKAhUr?= =?us-ascii?Q?wH7yizoomUEK2goxiid3RO/l00RE88VWi/EEAqe7AH0=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1288.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5f8f488-e1c8-410c-2a9f-08d8aafb1912 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2020 06:37:50.6019 (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: /Ci3iQx0BbgSWx6jRSKJ4lyzp1IyivDsHfXXeNEbM6e6O0T7zfRJ1uYro/V+wml0Xy1lLlgxtbjSL2dRRVtN1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1992 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR11MB1288C948BFB565A287414AAD8CD90CY4PR11MB1288namp_" --_000_CY4PR11MB1288C948BFB565A287414AAD8CD90CY4PR11MB1288namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Sounds good. Thank you! From: devel@edk2.groups.io On Behalf Of Kun Qin Sent: Monday, December 28, 2020 2:36 PM To: Yao, Jiewen ; devel@edk2.groups.io Cc: Ard Biesheuvel ; Sami Mujawar ; Supreeth Venkatesh Subject: Re: [edk2-devel] [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMe= mLib: Extends support for X64 architecture Understood, not including this library for x86 will fail CI build on some = new drivers in this patch series, so we will need to give it a full fix. I = will add the fix at least for x86 in patch v2. Thanks, Kun From: Yao, Jiewen Sent: Sunday, December 27, 2020 22:24 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 I am not familiar with AArch64. So I will let ARM people comment it. For X86, I think it is security hole, if we do not fill mMmMemLibInternalM= mramRanges. A partial fix with known security vulnerability is not the best idea. I prefer to we give a full fix, or no fix it in V2. Thank you Yao Jiewen From: Kun Qin > Sent: Monday, December 28, 2020 12:15 PM To: Yao, Jiewen >; devel= @edk2.groups.io Cc: Ard Biesheuvel >= ; Sami Mujawar >; Supreet= h Venkatesh > Subject: RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends= support for X64 architecture Hi Jiewen, I did not fill these 2 variables for this patch because I thought to follo= w up fix for this issue separately because the AARCH64 instance does not fi= ll it either and I meant for this patch to solely extends the coverage to x= 64 (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 a= m 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 physica= l > 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 t= he > 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_CY4PR11MB1288C948BFB565A287414AAD8CD90CY4PR11MB1288namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Sounds good. Thank you!

 

From: devel@edk2.groups.io <devel@edk2.gr= oups.io> On Behalf Of Kun Qin
Sent: Monday, December 28, 2020 2:36 PM
To: Yao, Jiewen <jiewen.yao@intel.com>; devel@edk2.groups.io<= br> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Sami Mujawar <= ;sami.mujawar@arm.com>; Supreeth Venkatesh <supreeth.venkatesh@arm.co= m>
Subject: Re: [edk2-devel] [PATCH v1 04/15] StandaloneMmPkg: Standal= oneMmMemLib: Extends support for X64 architecture

 

Understood, not including this library for x86 will= fail CI build on some new drivers in this patch series, so we will need to= give it a full fix. I will add the fix at least for x86 in patch v2.<= /o:p>

 

Thanks,

Kun

 

From: Yao, Jiewen
Sent: Sunday, December 27, 2020 22:24
To: Kun Qin; devel@edk2.groups.io
Cc: Ard Biesheuvel; <= a href=3D"mailto:sami.mujawar@arm.com"> Sami Mujawar; Supreeth V= enkatesh
Subject: RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: = Extends support for X64 architecture

 

I am not familiar with AArch64. So I will let ARM p= eople comment it.

 

For X86, I think it is security hole, if we do not = fill mMmMemLibInternalMmramRanges.

 

A partial fix with known security vulnerability is = not the best idea.

 

I prefer to we give a full fix, or no fix it in V2.=

 

Thank you

Yao Jiewen

 

 

From: Kun Qin <kun.q@outlook.com>
Sent: Monday, December 28, 2020 12:15 PM
To: Yao, Jiewen <jiewen.= yao@intel.com>; devel@edk2.groups.io
Cc: Ard Biesheuvel <ar= d.biesheuvel@arm.com>; Sami Mujawar <sami.mujawar@arm.com>; Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Subject: RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: = Extends support for X64 architecture

 

Hi Jiewen,

 

I did not fill these 2 variables for this patch bec= ause I thought to follow up fix for this issue separately because the AARCH= 64 instance does not fill it either and I meant for this patch to solely ex= tends the coverage to x64 (and IA32). But please let me know if you think otherwise, I can add the x64 fix in t= his patch as well. But I do not have fix for AARCH64 since I am not familia= r 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; <= a href=3D"mailto:sami.mujawar@arm.com"> Sami Mujawar; Supreeth V= enkatesh
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           &nb= sp;    mMmMemLibInternalMmramCount;



> -----Original Message-----
> From: Kun Qin <kun.q@outlook.= com>
> Sent: Saturday, December 19, 2020 2:50 AM
> To: devel@edk2.groups.io<= br> > Cc: Ard Biesheuvel <ard.= biesheuvel@arm.com>; Sami Mujawar
> <sami.mujawar@arm.com&= gt;; Yao, Jiewen <jiewen.yao@int= el.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.muj= awar@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           |&nb= sp; 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 instan= ce, the
> platform should produce
> +  all MMRAM range via MM_ACCESS_PROTOCOL, including the range f= or
> firmware (like MM Core
> +  and MM driver) and/or specific dedicated hardware.
> +
> +  Copyright (c) 2015, Intel Corporation. All rights reserved.&l= t;BR>
> +  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.&= lt;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        PhysicalAddre= ssBits;
> +
> +  //
> +  // 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, NU= LL);
> +    if (RegEax >=3D 0x80000008) {
> +      AsmCpuid (0x80000008, &RegEax, NU= LL, NULL, NULL);
> +      PhysicalAddressBits =3D (UINT8) RegEa= x;
> +    } 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, "mMmMemLibInternalMaximumSupportAddr= ess
> =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 requi= red 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_CY4PR11MB1288C948BFB565A287414AAD8CD90CY4PR11MB1288namp_--