From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: Fix CPU stack guard support by aligning GDT buffer To: Vitaly Cheptsov ,devel@edk2.groups.io From: "Vitaly Cheptsov" X-Originating-Location: Moscow, RU (77.232.9.83) X-Originating-Platform: Mac Safari 14.1 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Mon, 20 Sep 2021 09:15:12 -0700 References: <20210920141347.25161-1-cheptsov@ispras.ru> In-Reply-To: <20210920141347.25161-1-cheptsov@ispras.ru> Message-ID: <4886.1632154512621436417@groups.io> Content-Type: multipart/alternative; boundary="deyPZj6BDOrGWgzcl02F" --deyPZj6BDOrGWgzcl02F Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Just to make it clear, this is an immediate solution that is good enough to= fix the bug. However, a more proper solution would be to introduce the _Al= ignas ( https://en.cppreference.com/w/c/language/_Alignas ) concept to EDK = II. I would suggest the following macro in Base.h: /** Enforce custom alignment for a variable definition. Similar to C11 alignas macro from stdalign.h, except it must be functional = to support MSVC. @param =C2=A0Alignment =C2=A0Numeric alignment to require. **/ #ifdef _MSC_EXTENSIONS #define ALIGNAS(Alignment) __declspec(align(Alignment)) #else #define ALIGNAS(Alignment) _Alignas(Alignment) #endif If there is no disagreement on this, I can imagine submitting an update aft= er this patch is merged. --deyPZj6BDOrGWgzcl02F Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Just to make it clear, this is an immediate solution that is good enough to= fix the bug. However, a more proper solution would be to introduce the _Alignas concept to EDK II. I would suggest the foll= owing macro in Base.h:

/**
  Enforce custom alignment = for a variable definition.
  Similar to C11 alignas macro fr= om stdalign.h, except it must be functional to support MSVC.

&nb= sp; @param  Alignment  Numeric alignment to require.
**/
#ifdef _MSC_EXTENSIONS
  #define ALIGNAS(Alignment) __declspec(align(Alignment))
#else
  #define ALIGNAS(Alignment) _Alignas(Alignment)
#endif

If there is no disagreement on this, I can imagine submitting an= update after this patch is merged.


--deyPZj6BDOrGWgzcl02F--