public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: "Fan, Jeff" <jeff.fan@intel.com>, edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Justen, Jordan L" <jordan.l.justen@intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2 1/4] UefiCpuPkg/PiSmmCpuDxeSmm: dynamic PcdCpuSmmApSyncTimeout, PcdCpuSmmSyncMode
Date: Tue, 22 Nov 2016 09:09:59 +0100	[thread overview]
Message-ID: <4d5a747c-f404-1b8f-7a6c-cc8ff4a2b758@redhat.com> (raw)
In-Reply-To: <e0c824e3-59df-08b8-757d-3e0ed1cb795d@redhat.com>

On 11/22/16 09:06, Laszlo Ersek wrote:
> On 11/22/16 08:20, Fan, Jeff wrote:
>> Reviewed-by: Jeff Fan <jeff.fan@intel.com>
> 
> Thank Jeff!

This was supposed to be "Thank you, Jeff".

Not making much progress on the "getting enough sleep" front. :/

Laszlo

> I committed this patch in isolation (b43dd22981b7), because I think it
> has value without the OvmfPkg changes too. Plus, I think the OvmfPkg
> changes might take longer to get into the tree, and I wouldn't like
> PiSmmCpuDxeSmm to diverge in the meantime.
> 
> Thanks!
> Laszlo
> 
>> -----Original Message-----
>> From: Laszlo Ersek [mailto:lersek@redhat.com] 
>> Sent: Friday, November 18, 2016 9:53 PM
>> To: edk2-devel-01
>> Cc: Fan, Jeff; Justen, Jordan L; Kinney, Michael D; Paolo Bonzini
>> Subject: [PATCH v2 1/4] UefiCpuPkg/PiSmmCpuDxeSmm: dynamic PcdCpuSmmApSyncTimeout, PcdCpuSmmSyncMode
>>
>> Move the declaration of these PCDs from the
>>
>>   [PcdsFixedAtBuild, PcdsPatchableInModule]
>>
>> section of "UefiCpuPkg/UefiCpuPkg.dec" to the
>>
>>   [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
>>
>> section. Their types, default values, and token values remain unchanged.
>>
>> Only UefiCpuPkg/PiSmmCpuDxeSmm consumes these PCDs, specifically on the call stack of its entry point function, and it turns them into static or dynamically allocated data in SMRAM:
>>
>>   PiCpuSmmEntry()                            [PiSmmCpuDxeSmm.c]
>>     InitializeSmmTimer()                     [SyncTimer.c]
>>       PcdCpuSmmApSyncTimeout
>>       -> mTimeoutTicker
>>     InitializeMpServiceData()                [MpService.c]
>>       InitializeMpSyncData()                 [MpService.c]
>>         PcdCpuSmmSyncMode
>>         -> mSmmMpSyncData->EffectiveSyncMode
>>
>> However, there's another call path to fetching "PcdCpuSmmSyncMode", namely
>>
>>   SmmInitHandler()                           [PiSmmCpuDxeSmm.c]
>>     InitializeMpSyncData()                   [MpService.c]
>>       PcdCpuSmmSyncMode
>>       -> mSmmMpSyncData->EffectiveSyncMode
>>
>> and this path is exercised during S3 resume (as stated by the comment in
>> SmmInitHandler() too, "Initialize private data during S3 resume").
>>
>> While we can call the PCD protocol (via PcdLib) for fetching dynamic PCDs in the entry point function, we cannot do that at S3 resume. Therefore pre-fetch PcdCpuSmmSyncMode into a new global variable (which lives in
>> SMRAM) in InitializeMpServiceData(), just before calling InitializeMpSyncData(). This way InitializeMpSyncData() can retrieve the stashed PCD value from SMRAM, regardless of the boot mode.
>>
>> Cc: Jeff Fan <jeff.fan@intel.com>
>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>> Cc: Michael Kinney <michael.d.kinney@intel.com>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=230
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>> ---
>>
>> Notes:
>>     v2:
>>     - new in v2
>>
>>  UefiCpuPkg/UefiCpuPkg.dec             | 20 ++++++++++----------
>>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c |  4 +++-
>>  2 files changed, 13 insertions(+), 11 deletions(-)
>>
>> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 89779c447d50..ca560398bbef 100644
>> --- a/UefiCpuPkg/UefiCpuPkg.dec
>> +++ b/UefiCpuPkg/UefiCpuPkg.dec
>> @@ -156,10 +156,6 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
>>    # @Prompt Processor stack size in SMM.
>>    gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x2000|UINT32|0x32132105
>>  
>> -  ## Specifies timeout value in microseconds for the BSP in SMM to wait for all APs to come into SMM.
>> -  # @Prompt AP synchronization timeout value in SMM.
>> -  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000000|UINT64|0x32132104
>> -
>>    ## Indicates if SMM Code Access Check is enabled.
>>    #  If enabled, the SMM handler cannot execute the code outside SMM regions.
>>    #  This PCD is suggested to TRUE in production image.<BR><BR> @@ -168,12 +164,6 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
>>    # @Prompt SMM Code Access Check.
>>    gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmCodeAccessCheckEnable|TRUE|BOOLEAN|0x60000013
>>  
>> -  ## Indicates the CPU synchronization method used when processing an SMI.
>> -  #   0x00  - Traditional CPU synchronization method.<BR>
>> -  #   0x01  - Relaxed CPU synchronization method.<BR>
>> -  # @Prompt SMM CPU Synchronization Method.
>> -  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x00|UINT8|0x60000014
>> -
>>    ## Specifies the number of variable MTRRs reserved for OS use. The default number of
>>    #  MTRRs reserved for OS use is 2.
>>    # @Prompt Number of reserved variable MTRRs.
>> @@ -214,6 +204,16 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
>>    # @Prompt Use static page table for all memory in SMM.
>>    gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStaticPageTable|TRUE|BOOLEAN|0x3213210D
>>  
>> +  ## Specifies timeout value in microseconds for the BSP in SMM to wait for all APs to come into SMM.
>> +  # @Prompt AP synchronization timeout value in SMM.
>> +  
>> + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|1000000|UINT64|0x3213
>> + 2104
>> +
>> +  ## Indicates the CPU synchronization method used when processing an SMI.
>> +  #   0x00  - Traditional CPU synchronization method.<BR>
>> +  #   0x01  - Relaxed CPU synchronization method.<BR>
>> +  # @Prompt SMM CPU Synchronization Method.
>> +  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x00|UINT8|0x60000014
>> +
>>  [PcdsDynamic, PcdsDynamicEx]
>>    ## Contains the pointer to a CPU S3 data buffer of structure ACPI_CPU_DATA.
>>    # @Prompt The pointer to a CPU S3 data buffer.
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> index 9b8db90ff6ed..cfbf59e8f2ca 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> @@ -24,6 +24,7 @@ UINTN                                       mSmmMpSyncDataSize;
>>  SMM_CPU_SEMAPHORES                          mSmmCpuSemaphores;
>>  UINTN                                       mSemaphoreSize;
>>  SPIN_LOCK                                   *mPFLock = NULL;
>> +SMM_CPU_SYNC_MODE                           mCpuSmmSyncMode;
>>  
>>  /**
>>    Performs an atomic compare exchange operation to get semaphore.
>> @@ -1338,7 +1339,7 @@ InitializeMpSyncData (
>>        //
>>        mSmmMpSyncData->BspIndex = (UINT32)-1;
>>      }
>> -    mSmmMpSyncData->EffectiveSyncMode = (SMM_CPU_SYNC_MODE) PcdGet8 (PcdCpuSmmSyncMode);
>> +    mSmmMpSyncData->EffectiveSyncMode = mCpuSmmSyncMode;
>>  
>>      mSmmMpSyncData->Counter       = mSmmCpuSemaphores.SemaphoreGlobal.Counter;
>>      mSmmMpSyncData->InsideSmm     = mSmmCpuSemaphores.SemaphoreGlobal.InsideSmm;
>> @@ -1392,6 +1393,7 @@ InitializeMpServiceData (
>>                         (sizeof (SMM_CPU_DATA_BLOCK) + sizeof (BOOLEAN)) * gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;
>>    mSmmMpSyncData = (SMM_DISPATCHER_MP_SYNC_DATA*) AllocatePages (EFI_SIZE_TO_PAGES (mSmmMpSyncDataSize));
>>    ASSERT (mSmmMpSyncData != NULL);
>> +  mCpuSmmSyncMode = (SMM_CPU_SYNC_MODE)PcdGet8 (PcdCpuSmmSyncMode);
>>    InitializeMpSyncData ();
>>  
>>    //
>> --
>> 2.9.2
>>
>>
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
>>
> 



  reply	other threads:[~2016-11-22  8:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18 13:52 [PATCH v2 0/4] OvmfPkg: broadcast SMIs and dynamically revert to traditional AP sync mode Laszlo Ersek
2016-11-18 13:52 ` [PATCH v2 1/4] UefiCpuPkg/PiSmmCpuDxeSmm: dynamic PcdCpuSmmApSyncTimeout, PcdCpuSmmSyncMode Laszlo Ersek
2016-11-22  7:20   ` Fan, Jeff
2016-11-22  8:06     ` Laszlo Ersek
2016-11-22  8:09       ` Laszlo Ersek [this message]
2016-11-18 13:52 ` [PATCH v2 2/4] OvmfPkg: dynamic defaults for " Laszlo Ersek
2016-11-18 13:52 ` [PATCH v2 3/4] OvmfPkg/IndustryStandard: add macros for QEMU's SMI feature control bits Laszlo Ersek
2016-11-18 13:52 ` [PATCH v2 4/4] OvmfPkg/SmmControl2Dxe: select broadcast SMI if available Laszlo Ersek
2016-11-23  3:44   ` Jordan Justen
2016-11-23 15:44     ` Laszlo Ersek
2016-12-01 20:30       ` 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=4d5a747c-f404-1b8f-7a6c-cc8ff4a2b758@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