public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "Wu, Jiaxin" <jiaxin.wu@intel.com>, Gerd Hoffmann <kraxel@redhat.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Zeng, Star" <star.zeng@intel.com>,
	"Kumar, Rahul R" <rahul.r.kumar@intel.com>,
	"Dong, Guo" <guo.dong@intel.com>,
	"Rhodes, Sean" <sean@starlabs.systems>,
	"Lu, James" <james.lu@intel.com>, "Guo, Gua" <gua.guo@intel.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	"Yao, Jiewen" <jiewen.yao@intel.com>,
	"Abdul Lateef Attar" <AbdulLateef.Attar@amd.com>,
	Abner Chang <abner.chang@amd.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Subject: Re: [edk2-devel] [PATCH v3 00/13] Add SmmRelocationLib
Date: Thu, 25 Apr 2024 05:50:49 +0000	[thread overview]
Message-ID: <MN6PR11MB8244BC511F9259F8E287FD448C172@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MN0PR11MB61587EDA1EDFC7C57542E226FE172@MN0PR11MB6158.namprd11.prod.outlook.com>

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

I checked the AMD64 Architecture Programmer's Manual and it says below:
--- AMD64 manual ---
SMM-revision Level—Bits 15:0. Specifies the version of SMM supported by the processor. The SMM-revision level is of the form 0_xx64h, where xx starts with 00 and is incremented for later revisions to the SMM mechanism.
---

That means the SMMRevId is 0_xx64h for AMD64 processor. But I am not sure what the value is for AMD32 processor. Maybe 0 according to the OVMF logic.
--- OVMF's logic ---
  AMD_SMRAM_SAVE_STATE_MAP  *CpuSaveState;

  CpuSaveState = (AMD_SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);

  if ((CpuSaveState->x86.SMMRevId & 0xFFFF) == 0) {
    CpuSaveState->x86.SMBASE = (UINT32)SmBase;
  } else {
    CpuSaveState->x64.SMBASE = (UINT32)SmBase;
  }
------


But, I am very suspicious about the logic in AMD's version as below:
--- AMD's version
  SmmSaveStateRegisterLma = (UINT8)EFI_MM_SAVE_STATE_REGISTER_LMA_32BIT;

  LMAValue = (UINT32)AsmReadMsr64 (EFER_ADDRESS) & LMA;
  if (LMAValue) {
    SmmSaveStateRegisterLma = (UINT8)EFI_MM_SAVE_STATE_REGISTER_LMA_64BIT;
  }
---
The above logic detects the current CPU mode and 64bit save state area layout is used if it's running in 64bit.

But if a AMD64 CPU runs in 32bit mode, the above logic causes the 32bit save state area layout is used. It's not right!
The save state area layout does not depend on the CPU running mode, but whether it's a legacy CPU or a 64-capable CPU.

Jiaxin, I agree that the confusion should be cleaned up by AMD experts. Let's not change any existing behavior.

Thanks,
Ray
________________________________
From: Wu, Jiaxin <jiaxin.wu@intel.com>
Sent: Thursday, April 25, 2024 8:54
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: devel@edk2.groups.io <devel@edk2.groups.io>; Ni, Ray <ray.ni@intel.com>; Zeng, Star <star.zeng@intel.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>; Dong, Guo <guo.dong@intel.com>; Rhodes, Sean <sean@starlabs.systems>; Lu, James <james.lu@intel.com>; Guo, Gua <gua.guo@intel.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>; Yao, Jiewen <jiewen.yao@intel.com>; Abdul Lateef Attar <AbdulLateef.Attar@amd.com>; Abner Chang <abner.chang@amd.com>; Tom Lendacky <thomas.lendacky@amd.com>
Subject: RE: [edk2-devel] [PATCH v3 00/13] Add SmmRelocationLib

> >
> > AMD version is not work for IA32X64 ovmf.
> >
> > I checked the detailed: CpuSaveState->x64 is always used for OVMF no
> matter IA32 or X64, while AMD is not, which is decided by the MSR
> EFER_ADDRESS LMA bit check.
>
> Hmm, probably because only PEI runs in 32-bit mode whereas DXE and SMM
> run in 64-bit mode, so 32-bit PEI has to prepare things for the 64-bit
> SMM.
>
> > There is a potential issue/open in OVMF why need use the X64
> > CpuSaveState for IA32. Before this open resolved, I still prefer to
> > keep use the ovmf specific lib instance.
>
> Yes, lets stick to the ovmf version for now, and maybe remove it later
> when fixing the ia32 ovmf builds.
>

Ok, no problem.




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118266): https://edk2.groups.io/g/devel/message/118266
Mute This Topic: https://groups.io/mt/105593568/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



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

  reply	other threads:[~2024-04-25  5:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <17C74D78B0B952AD.15491@groups.io>
2024-04-18  8:02 ` [edk2-devel] [PATCH v3 00/13] Add SmmRelocationLib Wu, Jiaxin
2024-04-22  7:57   ` Gerd Hoffmann
2024-04-23  7:31     ` Wu, Jiaxin
2024-04-23  8:43       ` Gerd Hoffmann
2024-04-23 12:16         ` Wu, Jiaxin
2024-04-24  3:56         ` Wu, Jiaxin
2024-04-24 11:29           ` Gerd Hoffmann
2024-04-25  0:54             ` Wu, Jiaxin
2024-04-25  5:50               ` Ni, Ray [this message]
2024-04-25  6:58                 ` Gerd Hoffmann
2024-04-26  6:07                   ` Ni, Ray
2024-04-26 13:18                   ` Lendacky, Thomas via groups.io
2024-04-18  8:03 ` Wu, Jiaxin
2024-04-19  3:35   ` Ni, Ray
2024-04-19  3:47     ` Chang, Abner via groups.io
2024-04-19  3:55       ` Wu, Jiaxin
2024-04-18  6:55 Wu, Jiaxin

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=MN6PR11MB8244BC511F9259F8E287FD448C172@MN6PR11MB8244.namprd11.prod.outlook.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