public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: Laszlo Ersek <lersek@redhat.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpu: Remove hardcode 48 address size limitation
Date: Tue, 18 May 2021 07:51:11 +0000	[thread overview]
Message-ID: <CO1PR11MB4930BC0AB58383C3CA4523378C2C9@CO1PR11MB4930.namprd11.prod.outlook.com> (raw)
In-Reply-To: <877e17dd-8235-1a56-13c1-c61a505d543e@redhat.com>



> -----Original Message-----
> From: Laszlo Ersek <lersek@redhat.com>
> Sent: Sunday, May 16, 2021 9:39 AM
> To: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>
> Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpu: Remove hardcode 48 address size limitation
> 
> On 05/15/21 02:04, Ni, Ray wrote:
> > Laszlo,
> > Do you think that another API is also needed: GetPhysicalAddressWidth() that returns number 36/52?
> 
> No. The GetPhysicalAddressBits() function that I proposed already returns this information. It has three outputs: the number of
> bits (that is, the width), as return value, and the two optional output parameters.
> 
> So if you only need the the bit count, call
> 
>   GetPhysicalAddressBits (NULL, NULL);
> 
> These calculations are so cheap and small that keeping them in a single function makes a lot of sense in my opinion.

I wasn't aware of the return value of the API. with your API, there is no need for another API to retrieve the address size.

> For a critical bugfix, I would prefer not mixing the actual fix with the introduction of the symbolic names. Your patch currently
> fixes three things at the same time: (1) coding style (it replaces magic constants with macros / type names), (2) a bug in
> calculation, (3) a missing CPUID "maximum function" check.
> 
> Maybe writing a separate patch for each of these is unjustified, but I was really unhappy to see that the commit message said
> nothing about (1) and (3), and I had to hunt down (2) between the other changes.
> 
> The minimal fix -- that is, the fix for (2) -- would be just one line:
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index fd6583f9d172..4592b76fe595 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1920,7 +1920,7 @@ InitializeMpServiceData (
>    //
>    AsmCpuid (0x80000008, (UINT32*)&Index, NULL, NULL, NULL);
>    gPhyMask = LShiftU64 (1, (UINT8)Index) - 1;
> -  gPhyMask &= (1ull << 48) - EFI_PAGE_SIZE;
> +  gPhyMask &= 0xfffffffffffff000ULL;
> 
>    //
>    // Create page tables
> 
> 
> I don't like that the patch currently does three things but only documents one.

Thanks for explaining why you don't think it's a good patch. I thought anytime changing a code,
I should try to make it better, functional better, looks better.

I will follow your suggestion next time for bug fixes.

> 
> That said, if you are out of time, feel free to go ahead with Eric's R-b.
Indeed. thanks for the understanding.

> 
> Thanks
> Laszlo
> 
> 
> 
> >
> >
> > 
> >
> >
> >


  reply	other threads:[~2021-05-18  7:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12  4:53 [PATCH] UefiCpuPkg/PiSmmCpu: Remove hardcode 48 address size limitation Ni, Ray
2021-05-13  3:32 ` Dong, Eric
2021-05-14 10:55 ` [edk2-devel] " Laszlo Ersek
2021-05-15  0:04   ` Ni, Ray
2021-05-16  1:39     ` Laszlo Ersek
2021-05-18  7:51       ` Ni, Ray [this message]
2021-05-18 18:42         ` Laszlo Ersek
2021-05-20  4:28           ` Ni, Ray
2021-05-20  7:50             ` Laszlo Ersek
2021-05-20 11:11           ` Michael Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO1PR11MB4930BC0AB58383C3CA4523378C2C9@CO1PR11MB4930.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox