From: Paolo Bonzini <pbonzini@redhat.com>
To: Jeff Fan <jeff.fan@intel.com>, edk2-devel@lists.01.org
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
Laszlo Ersek <lersek@redhat.com>,
Jiewen Yao <jiewen.yao@intel.com>
Subject: Re: [PATCH v2 3/3] UefiCpuPkg/PiSmmCpuDxeSmm: Decrease mNumberToFinish in AP safe code
Date: Fri, 11 Nov 2016 11:16:21 +0100 [thread overview]
Message-ID: <c9256391-3773-4223-c18b-6711f9a5ee1d@redhat.com> (raw)
In-Reply-To: <20161111054545.19616-4-jeff.fan@intel.com>
On 11/11/2016 06:45, Jeff Fan wrote:
> We will put APs into hlt-loop in safe code. But we decrease mNumberToFinish
> before APs enter into the safe code. Paolo pointed out this gap.
>
> This patch is to move mNumberToFinish decreasing to the safe code. It could
> make sure BSP could wait for all APs are running in safe code.
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=216
>
> Reported-by: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Fan <jeff.fan@intel.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 17 +++++++----------
> UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c | 6 ++++--
> UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 4 +++-
> UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c | 6 ++++--
> 4 files changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> index e53e096..34547e0 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
> @@ -79,9 +79,11 @@ BOOLEAN mAcpiS3Enable = TRUE;
>
> UINT8 *mApHltLoopCode = NULL;
> UINT8 mApHltLoopCodeTemplate[] = {
> - 0xFA, // cli
> - 0xF4, // hlt
> - 0xEB, 0xFC // jmp $-2
> + 0x8B, 0x44, 0x24, 0x04, // mov eax, dword ptr [esp+4]
> + 0xF0, 0xFF, 0x08, // lock dec dword ptr [eax]
> + 0xFA, // cli
> + 0xF4, // hlt
> + 0xEB, 0xFC // jmp $-2
> };
>
> /**
> @@ -399,17 +401,12 @@ MPRendezvousProcedure (
> }
>
> //
> - // Count down the number with lock mechanism.
> - //
> - InterlockedDecrement (&mNumberToFinish);
> -
> - //
> - // Place AP into the safe code
> + // Place AP into the safe code, count down the number with lock mechanism in the safe code.
> //
> TopOfStack = (UINT32) (UINTN) Stack + sizeof (Stack);
> TopOfStack &= ~(UINT32) (CPU_STACK_ALIGNMENT - 1);
> CopyMem ((VOID *) (UINTN) mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate));
> - TransferApToSafeState ((UINT32) (UINTN) mApHltLoopCode, TopOfStack);
> + TransferApToSafeState ((UINT32) (UINTN) mApHltLoopCode, TopOfStack, &mNumberToFinish);
> }
>
> /**
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> index 8b880d6..9760373 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmFuncsArch.c
> @@ -100,17 +100,19 @@ InitGdt (
>
> @param[in] ApHltLoopCode The 32-bit address of the safe hlt-loop function.
> @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode.
> + @param[in] NumberToFinish Semaphore of APs finish count.
>
> **/
> VOID
> TransferApToSafeState (
> IN UINT32 ApHltLoopCode,
> - IN UINT32 TopOfStack
> + IN UINT32 TopOfStack,
> + IN UINT32 *NumberToFinish
> )
> {
> SwitchStack (
> (SWITCH_STACK_ENTRY_POINT) (UINTN) ApHltLoopCode,
> - NULL,
> + NumberToFinish,
> NULL,
> (VOID *) (UINTN) TopOfStack
> );
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> index 6c98659..88d9c85 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> @@ -830,12 +830,14 @@ GetAcpiS3EnableFlag (
>
> @param[in] ApHltLoopCode The 32-bit address of the safe hlt-loop function.
> @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode.
> + @param[in] NumberToFinish Semaphore of APs finish count.
>
> **/
> VOID
> TransferApToSafeState (
> IN UINT32 ApHltLoopCode,
> - IN UINT32 TopOfStack
> + IN UINT32 TopOfStack,
> + IN UINT32 *NumberToFinish
> );
>
> #endif
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
> index 62338b7..6844c3f 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
> @@ -105,18 +105,20 @@ GetProtectedModeCS (
>
> @param[in] ApHltLoopCode The 32-bit address of the safe hlt-loop function.
> @param[in] TopOfStack A pointer to the new stack to use for the ApHltLoopCode.
> + @param[in] NumberToFinish Semaphore of APs finish count.
>
> **/
> VOID
> TransferApToSafeState (
> IN UINT32 ApHltLoopCode,
> - IN UINT32 TopOfStack
> + IN UINT32 TopOfStack,
> + IN UINT32 *NumberToFinish
> )
> {
> AsmDisablePaging64 (
> GetProtectedModeCS (),
> (UINT32) (UINTN) ApHltLoopCode,
> - 0,
> + (UINT32) (UINTN) NumberToFinish,
> 0,
> TopOfStack
> );
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2016-11-11 10:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-11 5:45 [PATCH v2 0/3] Put AP into safe hlt-loop code on S3 path Jeff Fan
2016-11-11 5:45 ` [PATCH v2 1/3] UefiCpuPkg/PiSmmCpuDxeSmm: " Jeff Fan
2016-11-11 5:45 ` [PATCH v2 2/3] UefiCpuPkg/PiSmmCpuDxeSmm: Place AP to 32bit protected mode " Jeff Fan
2016-11-11 5:45 ` [PATCH v2 3/3] UefiCpuPkg/PiSmmCpuDxeSmm: Decrease mNumberToFinish in AP safe code Jeff Fan
2016-11-11 10:16 ` Paolo Bonzini [this message]
2016-11-11 19:49 ` [PATCH v2 0/3] Put AP into safe hlt-loop code on S3 path Laszlo Ersek
2016-11-13 12:51 ` Fan, Jeff
2016-11-14 1:41 ` Yao, Jiewen
2016-11-14 8:17 ` Laszlo Ersek
2016-11-14 8:50 ` Paolo Bonzini
2016-11-14 10:39 ` Laszlo Ersek
2016-11-14 11:09 ` Paolo Bonzini
2016-11-14 11:27 ` Laszlo Ersek
2016-11-14 12:00 ` Paolo Bonzini
2016-11-14 18:07 ` Laszlo Ersek
2016-11-14 18:13 ` Paolo Bonzini
2016-11-14 23:56 ` Laszlo Ersek
2016-11-15 0:47 ` Fan, Jeff
2016-11-15 1:03 ` Laszlo Ersek
2016-11-15 1:04 ` Fan, Jeff
2016-11-15 1:19 ` Fan, Jeff
2016-11-15 1:30 ` Laszlo Ersek
2016-11-15 1:27 ` Laszlo Ersek
2016-11-15 1:38 ` Fan, Jeff
[not found] ` <542CF652F8836A4AB8DBFAAD40ED192A4A2DCDE3@shsmsx102.ccr.corp.intel.com>
2016-11-15 1:21 ` Yao, Jiewen
2016-11-15 1:24 ` Fan, Jeff
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=c9256391-3773-4223-c18b-6711f9a5ee1d@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