public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kinney, Michael D" <michael.d.kinney@intel.com>
To: "Dong, Eric" <eric.dong@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "Ni, Ruiyu" <ruiyu.ni@intel.com>, "Shao, Ming" <ming.shao@intel.com>
Subject: Re: [Patch] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage.
Date: Wed, 16 Aug 2017 02:40:39 +0000	[thread overview]
Message-ID: <E92EE9817A31E24EB0585FDF735412F5A7D80652@ORSMSX113.amr.corp.intel.com> (raw)
In-Reply-To: <1502845412-10856-1-git-send-email-eric.dong@intel.com>

Hi Eric,

I think we should keep the Getxxx() functions to make
the code easier to read and we have matched Get/Set
functions to access these PCDs.

Mike

> -----Original Message-----
> From: Dong, Eric
> Sent: Tuesday, August 15, 2017 6:04 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Shao, Ming
> <ming.shao@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: [Patch] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer
> pointer error usage.
> 
> Current code allocate buffer for the pointer which later get
> value
> from PCD database. but current code error use "=" for this case.
> Use AllocateCopyPool instead to fix it.
> 
> V2 enhanced to directly use AllocateCopyPool to get the PCD
> value.
> V3 enhanced to avoid using local temp variable.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Shao Ming <ming.shao@intel.com>
> Cc: Kinney Michael D <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  .../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 55 +++++--
> ---------------
>  1 file changed, 11 insertions(+), 44 deletions(-)
> 
> diff --git
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ
> e.c
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ
> e.c
> index 474aea3..a7e1852 100644
> ---
> a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ
> e.c
> +++
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ
> e.c
> @@ -51,48 +51,6 @@ SetSettingPcd (
>  }
> 
>  /**
> -  Worker function to get PcdCpuFeaturesSupport.
> -
> -  @return  The pointer to CPU feature bits mask buffer.
> -**/
> -UINT8 *
> -GetSupportPcds (
> -  VOID
> -  )
> -{
> -  UINTN                  BitMaskSize;
> -  UINT8                  *SupportBitMask;
> -
> -  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
> -  SupportBitMask = AllocateZeroPool (BitMaskSize);
> -  ASSERT (SupportBitMask != NULL);
> -  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport);
> -
> -  return SupportBitMask;
> -}
> -
> -/**
> -  Worker function to get PcdCpuFeaturesUserConfiguration.
> -
> -  @return  The pointer to CPU feature bits mask buffer.
> -**/
> -UINT8 *
> -GetConfigurationPcds (
> -  VOID
> -  )
> -{
> -  UINTN                  BitMaskSize;
> -  UINT8                  *SupportBitMask;
> -
> -  BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration);
> -  SupportBitMask = AllocateZeroPool (BitMaskSize);
> -  ASSERT (SupportBitMask != NULL);
> -  SupportBitMask = (UINT8 *) PcdGetPtr
> (PcdCpuFeaturesUserConfiguration);
> -
> -  return SupportBitMask;
> -}
> -
> -/**
>    Collects CPU type and feature information.
> 
>    @param[in, out]  CpuInfo  The pointer to CPU feature
> information
> @@ -180,8 +138,17 @@ CpuInitDataInitialize (
>    //
>    // Get support and configuration PCDs
>    //
> -  CpuFeaturesData->SupportPcds       = GetSupportPcds ();
> -  CpuFeaturesData->ConfigurationPcds = GetConfigurationPcds ();
> +  CpuFeaturesData->SupportPcds = AllocateCopyPool (
> +          PcdGetSize (PcdCpuFeaturesSupport),
> +          PcdGetPtr (PcdCpuFeaturesSupport)
> +          );
> +  ASSERT (CpuFeaturesData->SupportPcds != NULL);
> +
> +  CpuFeaturesData->ConfigurationPcds = AllocateCopyPool (
> +          PcdGetSize (PcdCpuFeaturesUserConfiguration),
> +          PcdGetPtr (PcdCpuFeaturesUserConfiguration)
> +          );
> +  ASSERT (CpuFeaturesData->ConfigurationPcds != NULL);
>  }
> 
>  /**
> --
> 2.7.0.windows.1



  reply	other threads:[~2017-08-16  2:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16  1:03 [Patch] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage Eric Dong
2017-08-16  2:40 ` Kinney, Michael D [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-08-15  5:31 [Patch] UefiCpuPkg RegisterCpuFeaturesLib: Enhance debug messages Eric Dong
2017-08-15  5:31 ` [Patch] UefiCpuPkg RegisterCpuFeaturesLib: Fix buffer pointer error usage Eric Dong
2017-08-15  5:44   ` Ni, Ruiyu

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=E92EE9817A31E24EB0585FDF735412F5A7D80652@ORSMSX113.amr.corp.intel.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