public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: "Wu, Hao A" <hao.a.wu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Yao, Jiewen" <jiewen.yao@intel.com>, "Dong, Eric" <eric.dong@intel.com>
Subject: Re: [PATCH 0/2] UefiCpuPkg: Add RSB stuffing before rsm instruction
Date: Thu, 16 Aug 2018 14:33:57 +0200	[thread overview]
Message-ID: <e3cb175c-030a-e1a1-ac48-ef1cd23939ef@redhat.com> (raw)
In-Reply-To: <B80AF82E9BFB8E4FBD8C89DA810C6A0931E3909A@SHSMSX104.ccr.corp.intel.com>

On 08/16/18 05:07, Wu, Hao A wrote:
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Laszlo
>> Ersek
>> Sent: Friday, August 10, 2018 11:06 PM

>> (2) If I understand correctly, the same pattern is used everywhere -- a
>> loop body is executed 32 times, and in the loop body, we jump (via
>> subroutine calls) twice, and each call is followed by a "trap" for
>> speculative execution. At the end of the loop, we forcefully unwind the
>> stack, and then we proceed to RSM.
>>
>> I think this should be implemented with a lot less code duplication.
>> NASM supports macros with labels that are local to macro *invocation*
>> (not macro *definition*); please see the %%skip example here:
>>
>>   https://www.nasm.us/doc/nasmdoc4.html
>>   4.3.2 Macro-Local Labels
>>
>> In addition, it should be possible to pass parameters to macros, such as:
>> - the register to use as counter (eax vs. rax),
>> - the stack pointer to restore (esp vs. rsp),
>> - the size of a stack frame (4 vs. 8)
>>
>> Using all those tools, it should be possible to define the macro only
>> once, in a UefiCpuPkg-level ".inc" file (for example,
>> "UefiCpuPkg/Include/StuffRsb.inc"), and then only invoke the macro near
>> all 10 RSM instructions:
> 
> Yes. Extracting the common logic to a INC file is a good idea.
> 
> However, I found that when compiling .NASM files, the current build rule
> does not support including files other than the .NASM file directory.
> So including a package-level INC file is not supported at this moment.
> 
> I have filed a Bugzilla for adding $(INC)-like support when compiling
> .NASM files:
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=1085
> 
> After some discussion with the BaseTools owners, some investigation is
> needed for the above support. Hence, I plan to perform a 2-stage change
> when extracting the common RSB stuffing logics to INC file:
> 
> 1. Duplicate the INC file and place them together with the NASM files that
> uses the RSB stuffing logics.
> 
> 2. After NASM compiling support the $(INC)-like feature, propose another
> patch to remove those duplicated INC files and create one under
> UefiCpuPkg/Include/.
> 
> Please help to share your thought on this. Thanks in advance.

Sounds good to me. This approach still eliminates as much code
duplication as it is possible at the current level of BaseTools support.
Also we'll have a reminder (a BZ) for completing the unification.

Thanks!
Laszlo


  reply	other threads:[~2018-08-16 12:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-10  1:43 [PATCH 0/2] UefiCpuPkg: Add RSB stuffing before rsm instruction Hao Wu
2018-08-10  1:43 ` [PATCH 1/2] UefiCpuPkg/SmmCpuFeaturesLib: " Hao Wu
2018-08-10  1:43 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: " Hao Wu
2018-08-10 15:06 ` [PATCH 0/2] UefiCpuPkg: " Laszlo Ersek
2018-08-16  0:25   ` Yao, Jiewen
2018-08-16  3:07   ` Wu, Hao A
2018-08-16 12:33     ` Laszlo Ersek [this message]
2018-08-16 12:46     ` Laszlo Ersek

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=e3cb175c-030a-e1a1-ac48-ef1cd23939ef@redhat.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