public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Jeff Fan <jeff.fan@intel.com>, edk2-devel@ml01.01.org
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Feng Tian <feng.tian@intel.com>
Subject: Re: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Clear some semaphores on S3 boot path
Date: Tue, 29 Nov 2016 21:48:56 +0100	[thread overview]
Message-ID: <b9d6e3d0-4c7c-66fd-2ce9-0ecff0bda130@redhat.com> (raw)
In-Reply-To: <20161129075130.15192-1-jeff.fan@intel.com>

On 11/29/16 08:51, Jeff Fan wrote:
> Some semaphores are not cleared on S3 boot path. For example,
> mSmmMpSyncData->CpuData[CpuIndex].Present. It may still keeps the value set at
> SMM runtime during S3 resume. It may causes BSP have the wrong judgement on SMM
> AP's present state.
> 
> We have one related fix at e78a2a49ee6b0c0d7c6997c87ace31d7761cf636. But that is
> not completed.
> 
> This fix is to clear Busy/Run/Present semaphores in InitializeMpSyncData().
> 
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Feng Tian <feng.tian@intel.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/MpService.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index cfbf59e..a873b68 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1357,6 +1357,9 @@ InitializeMpSyncData (
>          (UINT32 *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Run + mSemaphoreSize * CpuIndex);
>        mSmmMpSyncData->CpuData[CpuIndex].Present =
>          (BOOLEAN *)((UINTN)mSmmCpuSemaphores.SemaphoreCpu.Present + mSemaphoreSize * CpuIndex);
> +      *(mSmmMpSyncData->CpuData[CpuIndex].Busy)    = 0;
> +      *(mSmmMpSyncData->CpuData[CpuIndex].Run)     = 0;
> +      *(mSmmMpSyncData->CpuData[CpuIndex].Present) = FALSE;
>      }
>    }
>  }
> 

Even after this patch, the values pointed-to by the following fields of
SemaphoreGlobal are not cleared: PFLock, CodeAccessCheckLock,
MemoryMappedLock. Is that okay?

The values pointed-to by the following fields of SemaphoreMsr are not
cleared either: Msr, AvailableCounter. Is that okay?

Can we imitate e78a2a49ee6b0c0d7c6997c87ace31d7761cf636 here; namely,
can we save "SemaphoreBlock" and "TotalSize" from
InitializeSmmCpuSemaphores() in global variables (in SMRAM), and then
just do another ZeroMem() here? That would cover the currently listed
objects (*Counter, *InsideSmm, *AllCpusInSync), and everything else too,
in a future-proof way.

In fact, I wonder if the ZeroMem() could be moved into
InitializeMpSyncData() from InitializeSmmCpuSemaphores().

Of course, if some pointed-to objects must not be cleared, then the
ZeroMem() is not appropriate.

Thanks!
Laszlo


  reply	other threads:[~2016-11-29 20:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29  7:51 [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Clear some semaphores on S3 boot path Jeff Fan
2016-11-29 20:48 ` Laszlo Ersek [this message]
2016-11-30  0:43   ` Fan, Jeff
2016-11-30  8:47     ` Laszlo Ersek
2016-12-01  2:53       ` Tian, Feng

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=b9d6e3d0-4c7c-66fd-2ce9-0ecff0bda130@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