public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V2] XhcCreateUsbHc: Check return value of XHC_PAGESIZE_OFFSET
@ 2022-06-20  7:08 Heng Luo
  2022-06-20  7:39 ` Wu, Hao A
  0 siblings, 1 reply; 3+ messages in thread
From: Heng Luo @ 2022-06-20  7:08 UTC (permalink / raw)
  To: devel; +Cc: Ray Ni, Hao Wu

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

Report error if reserved bits are not 0 for PageSize

Cc: Ray Ni <ray.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Signed-off-by: Heng Luo <heng.luo@intel.com>
---
 MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
index b79499e225..381d7a9536 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
@@ -1,7 +1,7 @@
 /** @file
   The XHCI controller driver.
 
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2022, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -1813,7 +1813,13 @@ XhcCreateUsbHc (
   // This xHC supports a page size of 2^(n+12) if bit n is Set. For example,
   // if bit 0 is Set, the xHC supports 4k byte page sizes.
   //
-  PageSize      = XhcReadOpReg (Xhc, XHC_PAGESIZE_OFFSET) & XHC_PAGESIZE_MASK;
+  PageSize = XhcReadOpReg (Xhc, XHC_PAGESIZE_OFFSET);
+  if ((PageSize & (~XHC_PAGESIZE_MASK)) != 0) {
+    DEBUG ((DEBUG_ERROR, "XhcCreateUsb3Hc: Reserved bits are not 0 for PageSize\n"));
+    goto ON_ERROR;
+  }
+
+  PageSize     &= XHC_PAGESIZE_MASK;
   Xhc->PageSize = 1 << (HighBitSet32 (PageSize) + 12);
 
   ExtCapReg              = (UINT16)(Xhc->HcCParams.Data.ExtCapReg);
-- 
2.31.1.windows.1


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

* Re: [Patch V2] XhcCreateUsbHc: Check return value of XHC_PAGESIZE_OFFSET
  2022-06-20  7:08 [Patch V2] XhcCreateUsbHc: Check return value of XHC_PAGESIZE_OFFSET Heng Luo
@ 2022-06-20  7:39 ` Wu, Hao A
  2022-06-22  1:18   ` [edk2-devel] " Wu, Hao A
  0 siblings, 1 reply; 3+ messages in thread
From: Wu, Hao A @ 2022-06-20  7:39 UTC (permalink / raw)
  To: Luo, Heng, devel@edk2.groups.io; +Cc: Ni, Ray, Chan, Amy

Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Will wait some time to see if comments from other reviewers.

Also, Will change the title a little bit to:
MdeModulePkg/XhciDxe: Check return value of XHC_PAGESIZE_OFFSET

Best Regards,
Hao Wu

> -----Original Message-----
> From: Luo, Heng <heng.luo@intel.com>
> Sent: Monday, June 20, 2022 3:08 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> Subject: [Patch V2] XhcCreateUsbHc: Check return value of
> XHC_PAGESIZE_OFFSET
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3954
> 
> Report error if reserved bits are not 0 for PageSize
> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Signed-off-by: Heng Luo <heng.luo@intel.com>
> ---
>  MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> index b79499e225..381d7a9536 100644
> --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> @@ -1,7 +1,7 @@
>  /** @file
> 
>    The XHCI controller driver.
> 
> 
> 
> -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
> 
> +Copyright (c) 2011 - 2022, Intel Corporation. All rights reserved.<BR>
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
> 
>  **/
> 
> @@ -1813,7 +1813,13 @@ XhcCreateUsbHc (
>    // This xHC supports a page size of 2^(n+12) if bit n is Set. For example,
> 
>    // if bit 0 is Set, the xHC supports 4k byte page sizes.
> 
>    //
> 
> -  PageSize      = XhcReadOpReg (Xhc, XHC_PAGESIZE_OFFSET) &
> XHC_PAGESIZE_MASK;
> 
> +  PageSize = XhcReadOpReg (Xhc, XHC_PAGESIZE_OFFSET);
> 
> +  if ((PageSize & (~XHC_PAGESIZE_MASK)) != 0) {
> 
> +    DEBUG ((DEBUG_ERROR, "XhcCreateUsb3Hc: Reserved bits are not 0 for
> PageSize\n"));
> 
> +    goto ON_ERROR;
> 
> +  }
> 
> +
> 
> +  PageSize     &= XHC_PAGESIZE_MASK;
> 
>    Xhc->PageSize = 1 << (HighBitSet32 (PageSize) + 12);
> 
> 
> 
>    ExtCapReg              = (UINT16)(Xhc->HcCParams.Data.ExtCapReg);
> 
> --
> 2.31.1.windows.1


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

* Re: [edk2-devel] [Patch V2] XhcCreateUsbHc: Check return value of XHC_PAGESIZE_OFFSET
  2022-06-20  7:39 ` Wu, Hao A
@ 2022-06-22  1:18   ` Wu, Hao A
  0 siblings, 0 replies; 3+ messages in thread
From: Wu, Hao A @ 2022-06-22  1:18 UTC (permalink / raw)
  To: devel@edk2.groups.io, Wu, Hao A, Luo, Heng; +Cc: Ni, Ray, Chan, Amy

Patch merged via:
PR - https://github.com/tianocore/edk2/pull/2997
Commit - https://github.com/tianocore/edk2/commit/b97243dea3c95ad923fa4ca190940158209e8384

Best Regards,
Hao Wu

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao
> A
> Sent: Monday, June 20, 2022 3:40 PM
> To: Luo, Heng <heng.luo@intel.com>; devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Chan, Amy <amy.chan@intel.com>
> Subject: Re: [edk2-devel] [Patch V2] XhcCreateUsbHc: Check return value of
> XHC_PAGESIZE_OFFSET
> 
> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
> 
> Will wait some time to see if comments from other reviewers.
> 
> Also, Will change the title a little bit to:
> MdeModulePkg/XhciDxe: Check return value of XHC_PAGESIZE_OFFSET
> 
> Best Regards,
> Hao Wu
> 
> > -----Original Message-----
> > From: Luo, Heng <heng.luo@intel.com>
> > Sent: Monday, June 20, 2022 3:08 PM
> > To: devel@edk2.groups.io
> > Cc: Ni, Ray <ray.ni@intel.com>; Wu, Hao A <hao.a.wu@intel.com>
> > Subject: [Patch V2] XhcCreateUsbHc: Check return value of
> > XHC_PAGESIZE_OFFSET
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3954
> >
> > Report error if reserved bits are not 0 for PageSize
> >
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Hao Wu <hao.a.wu@intel.com>
> > Signed-off-by: Heng Luo <heng.luo@intel.com>
> > ---
> >  MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> > b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> > index b79499e225..381d7a9536 100644
> > --- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
> > @@ -1,7 +1,7 @@
> >  /** @file
> >
> >    The XHCI controller driver.
> >
> >
> >
> > -Copyright (c) 2011 - 2018, Intel Corporation. All rights
> > reserved.<BR>
> >
> > +Copyright (c) 2011 - 2022, Intel Corporation. All rights
> > +reserved.<BR>
> >
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >
> >
> >  **/
> >
> > @@ -1813,7 +1813,13 @@ XhcCreateUsbHc (
> >    // This xHC supports a page size of 2^(n+12) if bit n is Set. For
> > example,
> >
> >    // if bit 0 is Set, the xHC supports 4k byte page sizes.
> >
> >    //
> >
> > -  PageSize      = XhcReadOpReg (Xhc, XHC_PAGESIZE_OFFSET) &
> > XHC_PAGESIZE_MASK;
> >
> > +  PageSize = XhcReadOpReg (Xhc, XHC_PAGESIZE_OFFSET);
> >
> > +  if ((PageSize & (~XHC_PAGESIZE_MASK)) != 0) {
> >
> > +    DEBUG ((DEBUG_ERROR, "XhcCreateUsb3Hc: Reserved bits are not 0
> > + for
> > PageSize\n"));
> >
> > +    goto ON_ERROR;
> >
> > +  }
> >
> > +
> >
> > +  PageSize     &= XHC_PAGESIZE_MASK;
> >
> >    Xhc->PageSize = 1 << (HighBitSet32 (PageSize) + 12);
> >
> >
> >
> >    ExtCapReg              = (UINT16)(Xhc->HcCParams.Data.ExtCapReg);
> >
> > --
> > 2.31.1.windows.1
> 
> 
> 
> 
> 


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

end of thread, other threads:[~2022-06-22  1:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-20  7:08 [Patch V2] XhcCreateUsbHc: Check return value of XHC_PAGESIZE_OFFSET Heng Luo
2022-06-20  7:39 ` Wu, Hao A
2022-06-22  1:18   ` [edk2-devel] " Wu, Hao A

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