public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable
@ 2020-08-18 13:10 Lendacky, Thomas
  2020-08-19  7:08 ` Liming Gao
  2020-08-19  9:24 ` Laszlo Ersek
  0 siblings, 2 replies; 5+ messages in thread
From: Lendacky, Thomas @ 2020-08-18 13:10 UTC (permalink / raw)
  To: devel; +Cc: Liming Gao, Eric Dong, Ray Ni, Laszlo Ersek, Rahul Kumar

From: Tom Lendacky <thomas.lendacky@amd.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2901

The DoDecrement variable in ApWakeupFunction () wasn't always being
initialized. Update the code to always fully initialize it.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 90416c81b616..e24bdc64f930 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -885,9 +885,7 @@ ApWakeupFunction (
           UINT64                    Status;
           BOOLEAN                   DoDecrement;
 
-          if (CpuMpData->InitFlag == ApInitConfig) {
-            DoDecrement = TRUE;
-          }
+          DoDecrement = (CpuMpData->InitFlag == ApInitConfig) ? TRUE : FALSE;
 
           while (TRUE) {
             Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable
  2020-08-18 13:10 [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable Lendacky, Thomas
@ 2020-08-19  7:08 ` Liming Gao
  2020-08-20 14:52   ` Lendacky, Thomas
  2020-08-19  9:24 ` Laszlo Ersek
  1 sibling, 1 reply; 5+ messages in thread
From: Liming Gao @ 2020-08-19  7:08 UTC (permalink / raw)
  To: Tom Lendacky, devel@edk2.groups.io
  Cc: Dong, Eric, Ni, Ray, Laszlo Ersek, Kumar, Rahul1

Tested-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

-----Original Message-----
From: Tom Lendacky <thomas.lendacky@amd.com> 
Sent: 2020年8月18日 21:10
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@intel.com>; Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>
Subject: [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable

From: Tom Lendacky <thomas.lendacky@amd.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2901

The DoDecrement variable in ApWakeupFunction () wasn't always being initialized. Update the code to always fully initialize it.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 90416c81b616..e24bdc64f930 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -885,9 +885,7 @@ ApWakeupFunction (
           UINT64                    Status;
           BOOLEAN                   DoDecrement;
 
-          if (CpuMpData->InitFlag == ApInitConfig) {
-            DoDecrement = TRUE;
-          }
+          DoDecrement = (CpuMpData->InitFlag == ApInitConfig) ? TRUE : 
+ FALSE;
 
           while (TRUE) {
             Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);
--
2.28.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable
  2020-08-18 13:10 [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable Lendacky, Thomas
  2020-08-19  7:08 ` Liming Gao
@ 2020-08-19  9:24 ` Laszlo Ersek
  2020-08-19 14:45   ` [edk2-devel] " Liming Gao
  1 sibling, 1 reply; 5+ messages in thread
From: Laszlo Ersek @ 2020-08-19  9:24 UTC (permalink / raw)
  To: Tom Lendacky, devel; +Cc: Liming Gao, Eric Dong, Ray Ni, Rahul Kumar

On 08/18/20 15:10, Tom Lendacky wrote:
> From: Tom Lendacky <thomas.lendacky@amd.com>
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2901
> 
> The DoDecrement variable in ApWakeupFunction () wasn't always being
> initialized. Update the code to always fully initialize it.
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 90416c81b616..e24bdc64f930 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -885,9 +885,7 @@ ApWakeupFunction (
>            UINT64                    Status;
>            BOOLEAN                   DoDecrement;
>  
> -          if (CpuMpData->InitFlag == ApInitConfig) {
> -            DoDecrement = TRUE;
> -          }
> +          DoDecrement = (CpuMpData->InitFlag == ApInitConfig) ? TRUE : FALSE;
>  
>            while (TRUE) {
>              Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);
> 

Not that I want to obsess about style, but

  (condition) ? TRUE : FALSE

is an anti-patter that's similar to

  (condition) == TRUE

Instead, I suggest:

  DoDecrement = (BOOLEAN)(CpuMpData->InitFlag == ApInitConfig);

(The (BOOLEAN) cast is necessary, or at least used to be necessary,
becasue the == operator returns "int" (INT32), but BOOLEAN (i.e., the
type of "DoDecrement") is UINT8 -- and some VS toolchains perceive (or
used to perceive) this implicit conversion as a "potential loss of
precision". That warning is of course bogus, as the == operator only
produces 0 or 1, each of which values fits comfortably into a UINT8. But
still the explicit (BOOLEAN) cast is how we suppress the warning.)

Different question: who's supposed to merge (v2 of) this? Per
"Maintainers.txt", it should be Eric or Ray; OTOH, maybe the fix is
urgent (build failure with CLANGPDB) and anyone with push access could
qualify.

Thanks,
Laszlo


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable
  2020-08-19  9:24 ` Laszlo Ersek
@ 2020-08-19 14:45   ` Liming Gao
  0 siblings, 0 replies; 5+ messages in thread
From: Liming Gao @ 2020-08-19 14:45 UTC (permalink / raw)
  To: devel@edk2.groups.io, lersek@redhat.com, Tom Lendacky
  Cc: Dong, Eric, Ni, Ray, Kumar, Rahul1

Laszlo:

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Laszlo Ersek
> Sent: Wednesday, August 19, 2020 5:24 PM
> To: Tom Lendacky <thomas.lendacky@amd.com>; devel@edk2.groups.io
> Cc: Gao, Liming <liming.gao@intel.com>; Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar, Rahul1
> <rahul1.kumar@intel.com>
> Subject: Re: [edk2-devel] [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable
> 
> On 08/18/20 15:10, Tom Lendacky wrote:
> > From: Tom Lendacky <thomas.lendacky@amd.com>
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2901
> >
> > The DoDecrement variable in ApWakeupFunction () wasn't always being
> > initialized. Update the code to always fully initialize it.
> >
> > Cc: Eric Dong <eric.dong@intel.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Laszlo Ersek <lersek@redhat.com>
> > Cc: Rahul Kumar <rahul1.kumar@intel.com>
> > Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> > ---
> >  UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > index 90416c81b616..e24bdc64f930 100644
> > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> > @@ -885,9 +885,7 @@ ApWakeupFunction (
> >            UINT64                    Status;
> >            BOOLEAN                   DoDecrement;
> >
> > -          if (CpuMpData->InitFlag == ApInitConfig) {
> > -            DoDecrement = TRUE;
> > -          }
> > +          DoDecrement = (CpuMpData->InitFlag == ApInitConfig) ? TRUE : FALSE;
> >
> >            while (TRUE) {
> >              Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);
> >
> 
> Not that I want to obsess about style, but
> 
>   (condition) ? TRUE : FALSE
> 
> is an anti-patter that's similar to
> 
>   (condition) == TRUE
> 
> Instead, I suggest:
> 
>   DoDecrement = (BOOLEAN)(CpuMpData->InitFlag == ApInitConfig);
> 
> (The (BOOLEAN) cast is necessary, or at least used to be necessary,
> becasue the == operator returns "int" (INT32), but BOOLEAN (i.e., the
> type of "DoDecrement") is UINT8 -- and some VS toolchains perceive (or
> used to perceive) this implicit conversion as a "potential loss of
> precision". That warning is of course bogus, as the == operator only
> produces 0 or 1, each of which values fits comfortably into a UINT8. But
> still the explicit (BOOLEAN) cast is how we suppress the warning.)

I agree this style is simpler than before. 
> 
> Different question: who's supposed to merge (v2 of) this? Per
> "Maintainers.txt", it should be Eric or Ray; OTOH, maybe the fix is
> urgent (build failure with CLANGPDB) and anyone with push access could
> qualify.
This fix needs to catch this stable tag. Once the package maintainer reviews it, I will merge it. 

Thanks
Liming
> 
> Thanks,
> Laszlo
> 
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable
  2020-08-19  7:08 ` Liming Gao
@ 2020-08-20 14:52   ` Lendacky, Thomas
  0 siblings, 0 replies; 5+ messages in thread
From: Lendacky, Thomas @ 2020-08-20 14:52 UTC (permalink / raw)
  To: Gao, Liming, devel@edk2.groups.io
  Cc: Dong, Eric, Ni, Ray, Laszlo Ersek, Kumar, Rahul1

Hi Liming,

It didn't feel quite right to keep your Tested-by: and Reviewed-by: for  
the change in v2 that I'm about to send. So please re-test / re-review.

Thanks,
Tom

On 8/19/20 2:08 AM, Gao, Liming wrote:
> Tested-by: Liming Gao <liming.gao@intel.com>
> Reviewed-by: Liming Gao <liming.gao@intel.com>
> 
> -----Original Message-----
> From: Tom Lendacky <thomas.lendacky@amd.com>
> Sent: 2020年8月18日 21:10
> To: devel@edk2.groups.io
> Cc: Gao, Liming <liming.gao@intel.com>; Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>
> Subject: [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable
> 
> From: Tom Lendacky <thomas.lendacky@amd.com>
> 
> REF: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2901&amp;data=02%7C01%7Cthomas.lendacky%40amd.com%7Cb01af87f70694b578aef08d8440ea50c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637334176971927286&amp;sdata=YSk7vULEekTRnjrd8XamlT1whKE3YkMk4lmh%2BfLf284%3D&amp;reserved=0
> 
> The DoDecrement variable in ApWakeupFunction () wasn't always being initialized. Update the code to always fully initialize it.
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>   UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 90416c81b616..e24bdc64f930 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -885,9 +885,7 @@ ApWakeupFunction (
>             UINT64                    Status;
>             BOOLEAN                   DoDecrement;
>   
> -          if (CpuMpData->InitFlag == ApInitConfig) {
> -            DoDecrement = TRUE;
> -          }
> +          DoDecrement = (CpuMpData->InitFlag == ApInitConfig) ? TRUE :
> + FALSE;
>   
>             while (TRUE) {
>               Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);
> --
> 2.28.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-20 14:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-18 13:10 [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable Lendacky, Thomas
2020-08-19  7:08 ` Liming Gao
2020-08-20 14:52   ` Lendacky, Thomas
2020-08-19  9:24 ` Laszlo Ersek
2020-08-19 14:45   ` [edk2-devel] " Liming Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox