From: "Dong, Eric" <eric.dong@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"Lofgren, John E" <john.e.lofgren@intel.com>
Cc: "Ni, Ray" <ray.ni@intel.com>,
"Laszlo Ersek (lersek@redhat.com)" <lersek@redhat.com>,
"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [edk2-devel] [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Fix #AC split lock
Date: Thu, 12 Sep 2019 13:21:34 +0000 [thread overview]
Message-ID: <ED077930C258884BBCB450DB737E662259EE4A6B@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20190909184039.1648-1-john.e.lofgren@intel.com>
Cc other reviewers.
Reviewed-by: Eric Dong <eric.dong@intel.com>
Thanks,
Eric
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of John E
> Lofgren
> Sent: Tuesday, September 10, 2019 2:41 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Fix
> #AC split lock
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2150
>
> V2 changes:
> Add xchg 16 bit instructions to handle sgdt and sidt base
> 63:48 bits and 47:32 bits.
> Add comment to explain why xchg 64bit isnt being used
>
> Fix #AC split lock's caused by seperating base and limit from sgdt and sidt by
> changing xchg operands to 32-bit to stop from crossing cacheline.
>
> Signed-off-by: John E Lofgren <john.e.lofgren@intel.com>
> ---
>
> UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nas
> m | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.n
> asm
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.n
> asm
> index 4db1a09f28..7b7642b290 100644
> ---
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.n
> asm
> +++
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.
> +++ nasm
> @@ -180,21 +180,29 @@ HasErrorCode:
> push qword [rbp + 24]
>
> ;; UINT64 Gdtr[2], Idtr[2];
> + ; sidt and sgdt saves 10 bytes to memory, 8 bytes = base and 2 bytes =
> limit.
> + ; To avoid #AC split lock when separating base and limit into their
> + ; own separate 64 bit memory, we can’t use 64 bit xchg since base
> [63:48] bits
> + ; may cross the cache line.
> xor rax, rax
> push rax
> push rax
> sidt [rsp]
> - xchg rax, [rsp + 2]
> - xchg rax, [rsp]
> - xchg rax, [rsp + 8]
> + xchg eax, [rsp + 2]
> + xchg eax, [rsp]
> + xchg eax, [rsp + 8]
> + xchg ax, [rsp + 6]
> + xchg ax, [rsp + 4]
>
> xor rax, rax
> push rax
> push rax
> sgdt [rsp]
> - xchg rax, [rsp + 2]
> - xchg rax, [rsp]
> - xchg rax, [rsp + 8]
> + xchg eax, [rsp + 2]
> + xchg eax, [rsp]
> + xchg eax, [rsp + 8]
> + xchg ax, [rsp + 6]
> + xchg ax, [rsp + 4]
>
> ;; UINT64 Ldtr, Tr;
> xor rax, rax
> --
> 2.16.2.windows.1
>
>
>
next prev parent reply other threads:[~2019-09-12 13:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-09 18:40 [Patch V2] UefiCpuPkg/CpuExceptionHandlerLib: Fix #AC split lock John E Lofgren
2019-09-12 13:21 ` Dong, Eric [this message]
2019-09-13 16:31 ` [edk2-devel] " Laszlo Ersek
2019-09-13 22:24 ` John E Lofgren
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=ED077930C258884BBCB450DB737E662259EE4A6B@shsmsx102.ccr.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