public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: Leif Lindholm <leif@nuviainc.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"cheptsov@ispras.ru" <cheptsov@ispras.ru>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "Yao, Jiewen" <jiewen.yao@intel.com>,
	"Dong, Eric" <eric.dong@intel.com>,
	"Wang, Jian J" <jian.j.wang@intel.com>,
	"Jeff Fan" <vanjeff_919@hotmail.com>,
	"Mikhail Krichanov" <krichanov@ispras.ru>,
	"Marvin Häuser" <mhaeuser@posteo.de>
Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: Fix CPU stack guard support by aligning GDT buffer
Date: Fri, 5 Nov 2021 19:42:29 +0000	[thread overview]
Message-ID: <CO1PR11MB4929085DDF0B9B68EEE8F2F6D28E9@CO1PR11MB4929.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20211105192821.s2itdxh5t6azp4z6@leviathan>

Hi Vitaly,

Can you please provide some details on the compiler/build command that did not align the array 
correctly.

I agree that the GDT must have the correct alignment.

I do not like the idea of unused bytes at the beginning of the array. I would prefer to see
an array that is aligned correctly by declaration.
 

Mike

> -----Original Message-----
> From: Leif Lindholm <leif@nuviainc.com>
> Sent: Friday, November 5, 2021 12:28 PM
> To: devel@edk2.groups.io; cheptsov@ispras.ru
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Dong, Eric <eric.dong@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>; Jeff Fan <vanjeff_919@hotmail.com>; Mikhail Krichanov <krichanov@ispras.ru>; Marvin
> Häuser <mhaeuser@posteo.de>
> Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: Fix CPU stack guard support by aligning GDT buffer
> 
> UefiCpuPkg maintainers - please respond.
> 
> Meanwhile, Vitaly, could you please provide a commit message?
> The BZ link is needed, but it's not a substitute.
> 
> /
>     Leif
> 
> On Mon, Sep 20, 2021 at 17:13:47 +0300, Vitaly Cheptsov wrote:
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3639
> >
> >
> >
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> >
> > Cc: Eric Dong <eric.dong@intel.com>
> >
> > Cc: Michael Kinney <michael.d.kinney@intel.com>
> >
> > Cc: Jian J Wang <jian.j.wang@intel.com>
> >
> > Cc: Jeff Fan <vanjeff_919@hotmail.com>
> >
> > Cc: Mikhail Krichanov <krichanov@ispras.ru>
> >
> > Cc: Marvin Häuser <mhaeuser@posteo.de>
> >
> > Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
> >
> > ---
> >
> >  .../Library/CpuExceptionHandlerLib/DxeException.c    | 12 +++++++-----
> >
> >  1 file changed, 7 insertions(+), 5 deletions(-)
> >
> >
> >
> > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
> >
> > index fd59f09ecd..12874811e1 100644
> >
> > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
> >
> > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
> >
> > @@ -22,7 +22,7 @@ EXCEPTION_HANDLER_DATA      mExceptionHandlerData;
> >
> >
> >
> >  UINT8                       mNewStack[CPU_STACK_SWITCH_EXCEPTION_NUMBER *
> >
> >                                        CPU_KNOWN_GOOD_STACK_SIZE];
> >
> > -UINT8                       mNewGdt[CPU_TSS_GDT_SIZE];
> >
> > +UINT8                       mNewGdt[CPU_TSS_GDT_SIZE + IA32_GDT_ALIGNMENT];
> >
> >
> >
> >  /**
> >
> >    Common exception handler.
> >
> > @@ -238,6 +238,7 @@ InitializeCpuExceptionHandlersEx (
> >
> >    CPU_EXCEPTION_INIT_DATA           EssData;
> >
> >    IA32_DESCRIPTOR                   Idtr;
> >
> >    IA32_DESCRIPTOR                   Gdtr;
> >
> > +  UINT8                             *Gdt;
> >
> >
> >
> >    //
> >
> >    // To avoid repeat initialization of default handlers, the caller should pass
> >
> > @@ -259,6 +260,7 @@ InitializeCpuExceptionHandlersEx (
> >
> >      if (PcdGetBool (PcdCpuStackGuard)) {
> >
> >        if (InitData == NULL) {
> >
> >          SetMem (mNewGdt, sizeof (mNewGdt), 0);
> >
> > +        Gdt = ALIGN_POINTER (mNewGdt, IA32_GDT_ALIGNMENT);
> >
> >
> >
> >          AsmReadIdtr (&Idtr);
> >
> >          AsmReadGdtr (&Gdtr);
> >
> > @@ -270,11 +272,11 @@ InitializeCpuExceptionHandlersEx (
> >
> >          EssData.X64.StackSwitchExceptionNumber = CPU_STACK_SWITCH_EXCEPTION_NUMBER;
> >
> >          EssData.X64.IdtTable = (VOID *)Idtr.Base;
> >
> >          EssData.X64.IdtTableSize = Idtr.Limit + 1;
> >
> > -        EssData.X64.GdtTable = mNewGdt;
> >
> > -        EssData.X64.GdtTableSize = sizeof (mNewGdt);
> >
> > -        EssData.X64.ExceptionTssDesc = mNewGdt + Gdtr.Limit + 1;
> >
> > +        EssData.X64.GdtTable = Gdt;
> >
> > +        EssData.X64.GdtTableSize = CPU_TSS_GDT_SIZE;
> >
> > +        EssData.X64.ExceptionTssDesc = Gdt + Gdtr.Limit + 1;
> >
> >          EssData.X64.ExceptionTssDescSize = CPU_TSS_DESC_SIZE;
> >
> > -        EssData.X64.ExceptionTss = mNewGdt + Gdtr.Limit + 1 + CPU_TSS_DESC_SIZE;
> >
> > +        EssData.X64.ExceptionTss = Gdt + Gdtr.Limit + 1 + CPU_TSS_DESC_SIZE;
> >
> >          EssData.X64.ExceptionTssSize = CPU_TSS_SIZE;
> >
> >
> >
> >          InitData = &EssData;
> >
> > --
> >
> > 2.30.1 (Apple Git-130)
> >
> >
> >
> >
> >
> > 
> >
> >

  parent reply	other threads:[~2021-11-05 19:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 14:13 [PATCH] UefiCpuPkg: Fix CPU stack guard support by aligning GDT buffer Vitaly Cheptsov
2021-09-20 16:15 ` [edk2-devel] " Vitaly Cheptsov
2021-10-24 10:59   ` Vitaly Cheptsov
2021-11-05 19:28 ` Leif Lindholm
2021-11-05 19:37   ` Vitaly Cheptsov
2021-11-08 14:04     ` Leif Lindholm
2021-11-05 19:42   ` Michael D Kinney [this message]
2021-11-05 20:36     ` Vitaly Cheptsov
2021-11-05 21:39       ` Michael D Kinney
2021-11-06  4:42         ` Vitaly Cheptsov

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=CO1PR11MB4929085DDF0B9B68EEE8F2F6D28E9@CO1PR11MB4929.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