public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: Nate DeSimone <nathaniel.l.desimone@intel.com>,devel@edk2.groups.io
Subject: Re: [edk2-devel] [RFC] Remove PI spec TemporaryRamSupport PPI from PEI Core
Date: Thu, 12 Jan 2023 02:16:56 -0800	[thread overview]
Message-ID: <16581.1673518616985803102@groups.io> (raw)
In-Reply-To: <02A34F284D1DA44BB705E61F7180EF0AAEA6B259@ORSMSX114.amr.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1446 bytes --]

Nate,
GCC generates assembly code that uses `RBP` to store `Private` local variable for below C code in PeiCore/Dispatcher.c

```c
      if (StackOffsetPositive) {
        SecCoreData = (CONST EFI_SEC_PEI_HAND_OFF *)((UINTN)(VOID *)SecCoreData + StackOffset);
        Private     = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private + StackOffset);
      } else {
        SecCoreData = (CONST EFI_SEC_PEI_HAND_OFF *)((UINTN)(VOID *)SecCoreData - StackOffset);
        Private     = (PEI_CORE_INSTANCE *)((UINTN)(VOID *)Private - StackOffset);
      }

      TemporaryRamSupportPpi->TemporaryRamMigration (
                                PeiServices,
                                TemporaryRamBase,
                                (EFI_PHYSICAL_ADDRESS)(UINTN)(TopOfNewStack - TemporaryStackSize),
                                TemporaryRamSize
                                );

      PeiCore (SecCoreData, NULL, Private);
```

If `TemporaryRamMigration()` updates the `RBP` to point to physical memory by adding/subtracting
the `StackOffset`, that results the Private is added/subtracted by `StackOffset` twice: One in the C code before calling
TemporayRamSupport PPI, the other in `TemporaryRamMigration ()`.

Since `FspSecMain.SecSwitchStack()` does update the `RBP`, have you met the similar issue?

The issue doesn't always happen. It depends on whether `RBP` is used to store either `SecCoreData` or `Private`.

[-- Attachment #2: Type: text/html, Size: 1659 bytes --]

      reply	other threads:[~2023-01-12 10:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24  7:51 [RFC] Remove PI spec TemporaryRamSupport PPI from PEI Core Jordan Justen
2019-04-24 16:36 ` Laszlo Ersek
2019-04-25  0:09 ` [edk2-devel] " Nate DeSimone
2023-01-12 10:16   ` Ni, Ray [this message]

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=16581.1673518616985803102@groups.io \
    --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