Date   

[edk2-platforms][PATCH v1 0/5] MinPlatformPkg: TestPointCheckLib bug fixes and improvements

Michael Kubacki
 

From: Michael Kubacki <michael.kubacki@...>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3531
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3518
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3520
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3521

This patch series groups together several bug fixes and improvements
to TestPointCheckLib. The first patch is required for the others
since it fixes a MinPlatformPkg build issue that occurs with the
current edk2/master branch.

Cc: Chasel Chiu <chasel.chiu@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Liming Gao <gaoliming@...>
Cc: Eric Dong <eric.dong@...>
Signed-off-by: Michael Kubacki <michael.kubacki@...>

Michael Kubacki (5):
MinPlatformPkg/TestPointCheckLib: Fix MessageLength cast issue
MinPlatformPkg/TestPointCheckLib: Set required size field in protocol
MinPlatformPkg/TestPointCheckLib: Fix incorrect array index
MinPlatformPkg/TestPointCheckLib: Improve adjacent region checking
MinPlatformPkg/TestPointCheckLib: Make OutTable parameter optional

Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcp=
i.c | 32 +++++------
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmi=
HandlerInstrument.c | 4 +-
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmm=
Info.c | 56 ++++++++++----------
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcg=
TrustedBoot.c | 1 +
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPoin=
tCheckLib.c | 15 +++++-
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPoin=
tCheckLib.c | 4 +-
Platform/Intel/MinPlatformPkg/Test/TestPointStubDxe/TestPointStubDxe.c =
| 10 ++--
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPoin=
tCheckLib.inf | 1 +
8 files changed, 70 insertions(+), 53 deletions(-)

--=20
2.28.0.windows.1


Re: [PATCH 0/3] reuse the SevEsWork area

Brijesh Singh
 

Hi Jiewen,

On 8/4/21 9:18 PM, Yao, Jiewen wrote:
HI Brijesh
Thanks for the startup. Feedback below:
1) I don't think we need a PCD to indicate the header.
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaHeaderSize|4|UINT32|0x51
Instead, if we define a HEADER structure, we can use sizeof() naturally. Otherwise, when we update this header, we need update 2 different places, which is not preferred.
Can you use the sizeof() inside the OvmfPkg.fdf ? I was not able to find a reference usage for it in this file. Also, can a .fdf refer the C header file ?

We need to know the size of the header so that we can set the fixed PcdOvmfSevEsWorkArea. In the current approach the .fdf sets the PCD as shown below:

SET PcdOvmfSevEsWorkArea = PcdOvmfWorkAreaBase + <HeaderSize>

I am hard coding the header size to be 4 so that pcd points to the correct location within the WorkArea.

thanks


typedef struct {
UINT8 GuestType;
UINT8 Reserved1[3];
} CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER;
2) I don't think we can define a common structure OVMF_WORK_AREA to contain SEV specific field.
typedef struct _OVMF_WORK_AREA {
UINT8 GuestType;
UINT8 Reserved1[3];
SEC_SEV_ES_WORK_AREA SevEsWorkArea;
} OVMF_WORK_AREA;
A common patter is to define each individual structure, then use UNION.
For example,
typedef struct {
UINT8 GuestType;
UINT8 Reserved1[3];
SEC_SEV_ES_WORK_AREA SevEsWorkArea;
} SEV_WORK_AREA;
typedef union {
CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER Header;
SEV_WORK_AREA Sev;
} OVMF_WORK_AREA;

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Brijesh
Singh via groups.io
Sent: Thursday, August 5, 2021 4:20 AM
To: devel@edk2.groups.io
Cc: James Bottomley <jejb@...>; Xu, Min M <min.m.xu@...>;
Yao, Jiewen <jiewen.yao@...>; Tom Lendacky
<thomas.lendacky@...>; Justen, Jordan L <jordan.l.justen@...>;
Ard Biesheuvel <ardb+tianocore@...>; Erdem Aktas
<erdemaktas@...>; Michael Roth <Michael.Roth@...>; Brijesh
Singh <brijesh.singh@...>
Subject: [edk2-devel] [PATCH 0/3] reuse the SevEsWork area

Based on the discussion on the mailing list, we agreed that instead
of wasting extra page in the MEMFD, we can reuse the SevEsWorkArea
buffer for the TDX. To avoid any confusion, lets introduce a OvmfWorkArea
that will contains 32 bytes of header followed by the actual workarea.

While at it, move the code to clear the GHCB page from PageTable build
to AmdSev.asm.

I have used the existing TDX BZ for it because the request came
during the TDX patch review. if anyone have concern please let me know
and I will happily create a new BZ.

Full tree is at: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAMDESE%2Fovmf%2Ftree%2Fsev-new-work-area&;data=04%7C01%7Cbrijesh.singh%40amd.com%7C4c55a642f1804a803c4e08d957b75e61%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637637267367225365%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=NSsUVfQodJMDUcpLCsHSpTaRDHM8et%2BWZJOS8lCS3Kw%3D&amp;reserved=0

Brijesh Singh (3):
OvmfPkg: introduce a common work area
OvmfPkg/ResetVector: update SEV support to use new work area format
OvmfPkg/ResetVector: move the GHCB page setup in AmdSev.asm

Cc: James Bottomley <jejb@...>
Cc: Min Xu <min.m.xu@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Tom Lendacky <thomas.lendacky@...>
Cc: Jordan Justen <jordan.l.justen@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Erdem Aktas <erdemaktas@...>

OvmfPkg/OvmfPkg.dec | 6 ++
OvmfPkg/OvmfPkgX64.fdf | 9 +-
OvmfPkg/PlatformPei/PlatformPei.inf | 4 +-
OvmfPkg/ResetVector/ResetVector.inf | 1 +
OvmfPkg/Sec/SecMain.inf | 1 +
OvmfPkg/Include/Library/MemEncryptSevLib.h | 21 +---
OvmfPkg/Include/WorkArea.h | 53 ++++++++++
OvmfPkg/PlatformPei/MemDetect.c | 32 +++---
OvmfPkg/Sec/SecMain.c | 25 ++++-
OvmfPkg/ResetVector/Ia32/AmdSev.asm | 111 +++++++++++++++++----
OvmfPkg/ResetVector/Ia32/PageTables64.asm | 57 ++---------
OvmfPkg/ResetVector/ResetVector.nasmb | 1 +
12 files changed, 213 insertions(+), 108 deletions(-)
create mode 100644 OvmfPkg/Include/WorkArea.h

--
2.17.1




Cancelled Event: TianoCore Design Meeting - APAC/NAMO - Friday, August 6, 2021 #cal-cancelled

devel@edk2.groups.io Calendar <noreply@...>
 

Cancelled: TianoCore Design Meeting - APAC/NAMO

This event has been cancelled.

When:
Friday, August 6, 2021
9:30am to 10:30am
(UTC+08:00) Asia/Shanghai

Where:
Microsoft Teams

Organizer: Ray Ni ray.ni@...

Description:

TOPIC

  1. NA

For more info, see here: https://www.tianocore.org/design-meeting/


Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 119 715 416 0

Alternate VTC dialing instructions

Learn More | Meeting options


Is there any use case of FirmwarePerformanceStandaloneMm.inf now?

Dandan Bi
 

Hi Kun,

 

I plan to make some change for FirmwarePerformanceSmm.inf, may also update the behavior of FirmwarePerformanceStandaloneMm.inf as they are sharing codes now.

And I saw you are the submitter of this driver. Could you help clarify following questions ? Thanks in advance.

 

  1. Do you have the use case to leverage FirmwarePerformanceStandaloneMm.inf to collect Standalone MM performance data now?
  2. Do you have any Library/module used by StandaloneMmCore to collect Standalone MM performance data and report the data to FirmwarePerformanceStandaloneMm like the SmmCorePerformanceLib used for SMM core?
  3. I plan to move some logic from FirmwarePerformanceDataTableSmm to SmmCorePerformanceLib as below. Do you think is it ok just to remove them from FirmwarePerformanceStandaloneMm.inf now?

If there is not any module to report Standalone MM performance data to FirmwarePerformanceStandaloneMm.inf, I think it should be OK to remove them from FirmwarePerformanceStandaloneMm now.

 

 

Change:

SMM performance data collection now:

  1. SmmCorePerformanceLib collect all the performance data in SMM and report the data to FirmwarePerformanceDataTableSmm through status code.
  2. DxeCorePerformanceLib will communicate with FirmwarePerformanceDataTableSmm to get the SMM performance data and allocate performance table to store all the performance data.

Now I want to simplify the process to make DxeCorePerformanceLib communicate with SmmCorePerformanceLib directly to collect SMM performance data, so FirmwarePerformanceDataTableSmm don’t need to get the SMM performance data from SmmCorePerformanceLib and register SMI handler for the communication with DxeCorePerformanceLib.

For FirmwarePerformanceStandaloneMm.inf, just remove this logic if there is no module to prepare MM performance data to it now.

 

 

Thanks,

Dandan


Re: [PATCH 0/3] reuse the SevEsWork area

Brijesh Singh
 

Hi Jiewen,

Thanks for the quick feedback. I will make the recommended change and
send the updated patch. I was under assumption that union will be done
when Min adds the SGX support because that's when we start reusing the
WorkArea for SEV and TDX. But I guess its good idea for me to do it now
so that Min does not have to touch the SEV code in his series.

thanks

On 8/4/21 9:18 PM, Yao, Jiewen wrote:
HI Brijesh
Thanks for the startup. Feedback below:

1) I don't think we need a PCD to indicate the header.
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaHeaderSize|4|UINT32|0x51

Instead, if we define a HEADER structure, we can use sizeof() naturally. Otherwise, when we update this header, we need update 2 different places, which is not preferred.

typedef struct {
UINT8 GuestType;
UINT8 Reserved1[3];
} CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER;

2) I don't think we can define a common structure OVMF_WORK_AREA to contain SEV specific field.

typedef struct _OVMF_WORK_AREA {
UINT8 GuestType;
UINT8 Reserved1[3];

SEC_SEV_ES_WORK_AREA SevEsWorkArea;
} OVMF_WORK_AREA;

A common patter is to define each individual structure, then use UNION.

For example,

typedef struct {
UINT8 GuestType;
UINT8 Reserved1[3];

SEC_SEV_ES_WORK_AREA SevEsWorkArea;
} SEV_WORK_AREA;

typedef union {
CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER Header;
SEV_WORK_AREA Sev;
} OVMF_WORK_AREA;



-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Brijesh
Singh via groups.io
Sent: Thursday, August 5, 2021 4:20 AM
To: devel@edk2.groups.io
Cc: James Bottomley <jejb@...>; Xu, Min M <min.m.xu@...>;
Yao, Jiewen <jiewen.yao@...>; Tom Lendacky
<thomas.lendacky@...>; Justen, Jordan L <jordan.l.justen@...>;
Ard Biesheuvel <ardb+tianocore@...>; Erdem Aktas
<erdemaktas@...>; Michael Roth <Michael.Roth@...>; Brijesh
Singh <brijesh.singh@...>
Subject: [edk2-devel] [PATCH 0/3] reuse the SevEsWork area

Based on the discussion on the mailing list, we agreed that instead
of wasting extra page in the MEMFD, we can reuse the SevEsWorkArea
buffer for the TDX. To avoid any confusion, lets introduce a OvmfWorkArea
that will contains 32 bytes of header followed by the actual workarea.

While at it, move the code to clear the GHCB page from PageTable build
to AmdSev.asm.

I have used the existing TDX BZ for it because the request came
during the TDX patch review. if anyone have concern please let me know
and I will happily create a new BZ.

Full tree is at: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAMDESE%2Fovmf%2Ftree%2Fsev-new-work-area&;data=04%7C01%7Cbrijesh.singh%40amd.com%7C4c55a642f1804a803c4e08d957b75e61%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637637267367225365%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=NSsUVfQodJMDUcpLCsHSpTaRDHM8et%2BWZJOS8lCS3Kw%3D&amp;reserved=0

Brijesh Singh (3):
OvmfPkg: introduce a common work area
OvmfPkg/ResetVector: update SEV support to use new work area format
OvmfPkg/ResetVector: move the GHCB page setup in AmdSev.asm

Cc: James Bottomley <jejb@...>
Cc: Min Xu <min.m.xu@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Tom Lendacky <thomas.lendacky@...>
Cc: Jordan Justen <jordan.l.justen@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Erdem Aktas <erdemaktas@...>

OvmfPkg/OvmfPkg.dec | 6 ++
OvmfPkg/OvmfPkgX64.fdf | 9 +-
OvmfPkg/PlatformPei/PlatformPei.inf | 4 +-
OvmfPkg/ResetVector/ResetVector.inf | 1 +
OvmfPkg/Sec/SecMain.inf | 1 +
OvmfPkg/Include/Library/MemEncryptSevLib.h | 21 +---
OvmfPkg/Include/WorkArea.h | 53 ++++++++++
OvmfPkg/PlatformPei/MemDetect.c | 32 +++---
OvmfPkg/Sec/SecMain.c | 25 ++++-
OvmfPkg/ResetVector/Ia32/AmdSev.asm | 111 +++++++++++++++++----
OvmfPkg/ResetVector/Ia32/PageTables64.asm | 57 ++---------
OvmfPkg/ResetVector/ResetVector.nasmb | 1 +
12 files changed, 213 insertions(+), 108 deletions(-)
create mode 100644 OvmfPkg/Include/WorkArea.h

--
2.17.1





Re: [PATCH v6 0/6] SEV Live Migration support for OVMF.

Ashish Kalra
 

On Thu, Aug 05, 2021 at 05:17:15AM +0000, Yao, Jiewen wrote:
Hi
I have some questions:

1) May I know what is the usage of this UEFI variable - SevLiveMigrationEnabled?
I only see it is created, but I do not see how it is consumed.
Yes, it is created by UEFI but consumed by the (guest) linux kernel.

This is actually part of a 3-way negotiation of the live migration
feature between hypervisor, guest OVMF and guest kernel. Host indicates
support for live migration, which is detected by OVMF and
correspondingly OVMF sets this SetLiveMigrationEnabled UEFI variable,
which is read by the guest kernel and it indicates to the guest kernel
that both host and OVMF support and have enabled the live migration
feature.

The guest flow for detecting live migration feature is captured below
(from the corresponding kernel patch):

The guest support for detecting and enabling SEV Live migration
feature uses the following logic :

- kvm_init_plaform() checks if its booted under the EFI

- If not EFI,

i) if kvm_para_has_feature(KVM_FEATURE_MIGRATION_CONTROL), issue a wrmsrl()
to enable the SEV live migration support

- If EFI,

i) If kvm_para_has_feature(KVM_FEATURE_MIGRATION_CONTROL), read
the UEFI variable which indicates OVMF support for live migration
(SetLiveMigrationEnabled)

ii) the variable indicates live migration is supported, issue a wrmsrl() to
enable the SEV live migration support


2) Is this a full live migration patch, or is this just a startup and there will be more on the way?
Yes. Actually this is hypervisor based live migration, so it relies on
host KVM and qemu support and it mainly requires OVMF support to make
hypercalls for any decrypted memory regions it sets up, for example,
MMIO and non-existant memory regions, so that hypervisor can keep track
of guest firmware's page encryption status.

So this is the full patch-set for UEFI for PSP based live migration.

Thanks,
Ashish

Thank you
Yao Jiewen


-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ashish Kalra
via groups.io
Sent: Monday, August 2, 2021 8:31 PM
To: devel@edk2.groups.io
Cc: dovmurik@...; brijesh.singh@...; tobin@...;
Thomas.Lendacky@...; jejb@...; Justen, Jordan L
<jordan.l.justen@...>; ard.biesheuvel@...;
erdemaktas@...; Yao, Jiewen <jiewen.yao@...>; Xu, Min M
<min.m.xu@...>
Subject: [edk2-devel] [PATCH v6 0/6] SEV Live Migration support for OVMF.

From: Ashish Kalra <ashish.kalra@...>

BZ: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3467&;data=04%7C01%7Cashish.kalra%40amd.com%7Cd4bf7bc0c17840d8a25208d957d04dcd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637637374441109760%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=238zqkur1zpuKDorzZLrzcbTNhlO6gM8aFoi7Zr%2BUao%3D&amp;reserved=0

By default all the SEV guest memory regions are considered encrypted,
if a guest changes the encryption attribute of the page (e.g mark a
page as decrypted) then notify hypervisor. Hypervisor will need to
track the unencrypted pages. The information will be used during
guest live migration, guest page migration and guest debugging.

The patch-set detects if it is running under KVM hypervisor and then
checks for SEV live migration feature support via KVM_FEATURE_CPUID,
if detected setup a new UEFI enviroment variable to indicate OVMF
support for SEV live migration.

A branch containing these patches is available here:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fashkalra%2Fedk2-1%2Ftree%2Fsev_live_migration_v5_10&;data=04%7C01%7Cashish.kalra%40amd.com%7Cd4bf7bc0c17840d8a25208d957d04dcd%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637637374441109760%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=PyChejF9mzIVLCvQiCW5olQ8LOFWM3%2FGGO938qL80f8%3D&amp;reserved=0

Changes since v5:
- Split first patch into three components, one patch for the
MemEncryptSevLiveMigrationIsEnabled() API, one patch for the
SetMemoryEncDecHypercall3() API, one patch to make use of the
SetMemoryEncDecHypercall3() API.
- Fix patch subject, in code and patch comments and
additionally add relevant comments.
- Replace SetMemoryEncDecHypercall3() API's Status argument
with a boolean IsEncrypted argument and corresponding fixes
to users of this API call.
- Fix AsciiStrCmp() usage in KVM hypervisor detection code.

Changes since v4:
- Remove MemEncryptHypercallLib Library and add support to issue
hypercall in the BaseMemEncryptSevLib library itself.
- For SEV-ES, make the VC handler hypercall aware by comparing
the hypercall number and add the additional register values
in the GHCB.
- Fix comments in the hypercall API interface.
- The encryption bit is set/clear on the smallest page size, hence
use the 4k page size in MAP_GPA_RANGE hypercall.
- Make the hypercall expect the guest physical address to be
page-aligned.
- Add KVM live migration feature flag check in BaseMemEncryptSevLib
library similar to how BaseMemEncryptSevLib does for the
MemEncryptSevIsEnabled() and check it before invoking HC. Also
export the MemEncryptSevLiveMigrationIsEnabled() function as
part of the library.
- Add error handling on hypercall return, on failure, return error
code to caller which potentially will cause an assert() and
terminate the boot.

Changes since v3:
- Fix all DSC files under OvmfPkg except X64 to add support for
BaseMemEncryptLib and add NULL instance of BaseMemEncryptLib
for 32 bit platforms.
- Add the MemEncryptHypercallLib-related files to Maintainers.txt,
in section "OvmfPkg: Confidential Computing".
- Add support for the new KVM_HC_MAP_GPA_RANGE hypercall interface.
- Add patch for SEV live migration support.

Changes since v2:
- GHCB_BASE setup during reset-vector as decrypted is marked explicitly
in the hypervisor page encryption bitmap after setting the
PcdSevEsIsEnabled PCD.

Changes since v1:
- Mark GHCB_BASE setup during reset-vector as decrypted explicitly in
the hypervisor page encryption bitmap.
- Resending the series with correct shallow threading.

Ashish Kalra (6):
OvmfPkg/BaseMemEncryptLib: Detect SEV live migration feature.
OvmfPkg/BaseMemEncryptLib: Hypercall API for page encryption state
change
OvmfPkg/BaseMemEncryptLib: Invoke page encryption state change
hypercall
OvmfPkg/VmgExitLib: Encryption state change hypercall support in VC
handler
OvmfPkg/PlatformPei: Mark SEC GHCB page as unencrypted via hypercall
OvmfPkg/AmdSevDxe: Add support for SEV live migration.

OvmfPkg/AmdSevDxe/AmdSevDxe.c | 64 +++++++++++++++++
OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 4 ++
OvmfPkg/Include/Guid/AmdSevMemEncryptLib.h | 20 ++++++
OvmfPkg/Include/Library/MemEncryptSevLib.h | 70 +++++++++++++++++++
.../DxeMemEncryptSevLib.inf | 1 +
.../DxeMemEncryptSevLibInternal.c | 39 +++++++++++
.../Ia32/MemEncryptSevLib.c | 27 +++++++
.../PeiDxeMemEncryptSevLibInternal.c | 52 ++++++++++++++
.../PeiMemEncryptSevLib.inf | 1 +
.../PeiMemEncryptSevLibInternal.c | 39 +++++++++++
.../SecMemEncryptSevLibInternal.c | 38 ++++++++++
.../X64/AsmHelperStub.nasm | 33 +++++++++
.../X64/MemEncryptSevLib.c | 62 ++++++++++++++++
.../X64/PeiDxeVirtualMemory.c | 20 ++++++
OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 13 ++++
OvmfPkg/OvmfPkg.dec | 1 +
OvmfPkg/PlatformPei/AmdSev.c | 11 +++
17 files changed, 495 insertions(+)
create mode 100644 OvmfPkg/Include/Guid/AmdSevMemEncryptLib.h
create mode 100644
OvmfPkg/Library/BaseMemEncryptSevLib/X64/AsmHelperStub.nasm

--
2.17.1





[edk2-platforms: PATCH V5] Platform/Intel: Correct CPU APIC IDs

JackX Lin
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3365

BIOS cannot find correct AcpiProcId in mApicIdMap because of
there is no suitable map, that causes ACPI_BIOS_ERROR.
Remove mApicIdMap for determing AcpiProcId, uses normal
countings instead.

Signed-off-by: JackX Lin <JackX.Lin@...>
Cc: Chasel Chiu <chasel.chiu@...>
Cc: Jenny Huang <jenny.huang@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Donald Kuo <Donald.Kuo@...>
Cc: Chandana C Kumar <chandana.c.kumar@...>
Cc: JackX Lin <JackX.Lin@...>
Change-Id: Ib64e519686b2f324a0a57c3b5bba220a7b75fda1
---
Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 536 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 file changed, 204 insertions(+), 332 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index 2b51c34ef2..d027e2852b 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -1,22 +1,19 @@
/** @file
ACPI Platform Driver

-Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include "AcpiPlatform.h"

-#define MAX_CPU_NUM (FixedPcdGet32(PcdMaxCpuThreadCount) * FixedPcdGet32(PcdMaxCpuCoreCount) * FixedPcdGet32(PcdMaxCpuSocketCount))
-
#pragma pack(1)

typedef struct {
UINT32 AcpiProcessorId;
UINT32 ApicId;
UINT32 Flags;
- UINT32 SwProcApicId;
UINT32 SocketNum;
} EFI_CPU_ID_ORDER_MAP;

@@ -50,7 +47,7 @@ VOID *mLocalTable[] = {
&Wsmt,
};

-EFI_ACPI_TABLE_PROTOCOL *mAcpiTable;
+EFI_ACPI_TABLE_PROTOCOL *mAcpiTable;

UINT32 mNumOfBitShift = 6;
BOOLEAN mForceX2ApicId;
@@ -58,138 +55,19 @@ BOOLEAN mX2ApicEnabled;

EFI_MP_SERVICES_PROTOCOL *mMpService;
BOOLEAN mCpuOrderSorted;
-EFI_CPU_ID_ORDER_MAP mCpuApicIdOrderTable[MAX_CPU_NUM];
-UINTN mNumberOfCPUs = 0;
+EFI_CPU_ID_ORDER_MAP *mCpuApicIdOrderTable = NULL;
+UINTN mNumberOfCpus = 0;
UINTN mNumberOfEnabledCPUs = 0;

-// following are possible APICID Map for SKX
-static const UINT32 ApicIdMapA[] = { //for SKUs have number of core > 16
- //it is 14 + 14 + 14 + 14 format
- 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x00000010, 0x00000011,
- 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019,
- 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x00000020, 0x00000021, 0x00000022, 0x00000023,
- 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B,
- 0x0000002C, 0x0000002D, 0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035,
- 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D
-};
-
-static const UINT32 ApicIdMapB[] = { //for SKUs have number of cores <= 16 use 32 ID space
- //it is 16+16 format
- 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
- 0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017,
- 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
-};
-
-
-static const UINT32 ApicIdMapC[] = { //for SKUs have number of cores <= 16 use 64 ID space
- //it is 16+0+16+0 format
- 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
- 0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027,
- 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
-};
-
-static const UINT32 ApicIdMapD[] = { //for SKUs have number of cores <= 8 use 16 ID space
- //it is 16 format
- 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
-};
-
-const UINT32 *mApicIdMap = NULL;
-
/**
- This function detect the APICID map and update ApicID Map pointer
+ Find BSP in mCpuApicIdOrderTable.

- @param None
+ This function searches mCpuApicIdOrderTable to find the BSP ApicId, and returns a number where the BSP is.

- @retval VOID
-
-**/
-VOID DetectApicIdMap(VOID)
-{
- UINTN CoreCount;
-
- CoreCount = 0;
-
- if(mApicIdMap != NULL) {
- return; //aleady initialized
- }
-
- mApicIdMap = ApicIdMapA; // default to > 16C SKUs
-
- CoreCount = mNumberOfEnabledCPUs / 2;
- DEBUG ((DEBUG_INFO, "CoreCount - %d\n", CoreCount));
-
- //DEBUG((EFI_D_ERROR, ":: Default to use Map A @ %08X FusedCoreCount: %02d, sktlevel: %d\n",mApicIdMap, FusedCoreCount, mNumOfBitShift));
- // Dont assert for single core, single thread system.
- //ASSERT (CoreCount != 0);
-
- if(CoreCount <= 16) {
-
- if(mNumOfBitShift == 4) {
- mApicIdMap = ApicIdMapD;
- //DEBUG((EFI_D_ERROR, ":: Use Map B @ %08X\n",mApicIdMap));
- }
-
- if(mNumOfBitShift == 5) {
- mApicIdMap = ApicIdMapB;
- //DEBUG((EFI_D_ERROR, ":: Use Map B @ %08X\n",mApicIdMap));
- }
-
- if(mNumOfBitShift == 6) {
- mApicIdMap = ApicIdMapC;
- //DEBUG((EFI_D_ERROR, ":: Use Map C @ %08X\n",mApicIdMap));
- }
-
- }
-
- return;
-}
-
-/**
- This function return the CoreThreadId of ApicId from ACPI ApicId Map array
-
- @param ApicId
-
- @retval Index of ACPI ApicId Map array
+ @param[in] ApicId Apic ID.

+ @return Where the BSP is.
**/
-UINT32
-GetIndexFromApicId (
- UINT32 ApicId
- )
-{
- UINT32 CoreThreadId;
- UINT32 i;
-
- ASSERT (mApicIdMap != NULL);
-
- CoreThreadId = ApicId & ((1 << mNumOfBitShift) - 1);
-
- for(i = 0; i < (FixedPcdGet32(PcdMaxCpuCoreCount) * FixedPcdGet32(PcdMaxCpuThreadCount)); i++) {
- if(mApicIdMap[i] == CoreThreadId) {
- break;
- }
- }
-
- ASSERT (i <= (FixedPcdGet32(PcdMaxCpuCoreCount) * FixedPcdGet32(PcdMaxCpuThreadCount)));
-
- return i;
-}
-
UINT32
ApicId2SwProcApicId (
UINT32 ApicId
@@ -197,7 +75,7 @@ ApicId2SwProcApicId (
{
UINT32 Index;

- for (Index = 0; Index < MAX_CPU_NUM; Index++) {
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
if ((mCpuApicIdOrderTable[Index].Flags == 1) && (mCpuApicIdOrderTable[Index].ApicId == ApicId)) {
return Index;
}
@@ -207,21 +85,25 @@ ApicId2SwProcApicId (

}

+/**
+ Print Cpu Apic ID Table
+
+ @param[in] CpuApicIdOrderTable Data will be dumped.
+**/
VOID
-DebugDisplayReOrderTable(
- VOID
+DebugDisplayReOrderTable (
+ IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable
)
{
UINT32 Index;

- DEBUG ((EFI_D_ERROR, "Index AcpiProcId ApicId Flags SwApicId Skt\n"));
- for (Index=0; Index<MAX_CPU_NUM; Index++) {
- DEBUG ((EFI_D_ERROR, " %02d 0x%02X 0x%02X %d 0x%02X %d\n",
- Index, mCpuApicIdOrderTable[Index].AcpiProcessorId,
- mCpuApicIdOrderTable[Index].ApicId,
- mCpuApicIdOrderTable[Index].Flags,
- mCpuApicIdOrderTable[Index].SwProcApicId,
- mCpuApicIdOrderTable[Index].SocketNum));
+ DEBUG ((DEBUG_INFO, "Index AcpiProcId ApicId Flags Skt\n"));
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
+ DEBUG ((DEBUG_INFO, " %02d 0x%02X 0x%02X %d %d\n",
+ Index, CpuApicIdOrderTable[Index].AcpiProcessorId,
+ CpuApicIdOrderTable[Index].ApicId,
+ CpuApicIdOrderTable[Index].Flags,
+ CpuApicIdOrderTable[Index].SocketNum));
}
}

@@ -284,125 +166,111 @@ SortCpuLocalApicInTable (
UINT32 TempVal = 0;
EFI_CPU_ID_ORDER_MAP *CpuIdMapPtr;
UINT32 CoreThreadMask;
+ EFI_CPU_ID_ORDER_MAP *TempCpuApicIdOrderTable;

Index = 0;
Status = EFI_SUCCESS;

+ TempCpuApicIdOrderTable = AllocateZeroPool (mNumberOfCpus * sizeof (EFI_CPU_ID_ORDER_MAP));
CoreThreadMask = (UINT32) ((1 << mNumOfBitShift) - 1);

if(!mCpuOrderSorted) {
-
- Index = 0;
-
- for (CurrProcessor = 0; CurrProcessor < mNumberOfCPUs; CurrProcessor++) {
+ for (CurrProcessor = 0, Index = 0; CurrProcessor < mNumberOfCpus; CurrProcessor++, Index++) {
Status = mMpService->GetProcessorInfo (
- mMpService,
- CurrProcessor,
- &ProcessorInfoBuffer
- );
+ mMpService,
+ CurrProcessor,
+ &ProcessorInfoBuffer
+ );

if ((ProcessorInfoBuffer.StatusFlag & PROCESSOR_ENABLED_BIT) != 0) {
- if(ProcessorInfoBuffer.ProcessorId & 1) { //is 2nd thread
- CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *)&mCpuApicIdOrderTable[(Index - 1) + MAX_CPU_NUM / 2];
- } else { //is primary thread
- CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *)&mCpuApicIdOrderTable[Index];
- Index++;
- }
+ CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *) &TempCpuApicIdOrderTable[Index];
CpuIdMapPtr->ApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;
CpuIdMapPtr->Flags = ((ProcessorInfoBuffer.StatusFlag & PROCESSOR_ENABLED_BIT) != 0);
CpuIdMapPtr->SocketNum = (UINT32)ProcessorInfoBuffer.Location.Package;
- CpuIdMapPtr->AcpiProcessorId = (CpuIdMapPtr->SocketNum * FixedPcdGet32(PcdMaxCpuCoreCount) * FixedPcdGet32(PcdMaxCpuThreadCount)) + GetIndexFromApicId(CpuIdMapPtr->ApicId); //CpuIdMapPtr->ApicId;
- CpuIdMapPtr->SwProcApicId = ((UINT32)(ProcessorInfoBuffer.Location.Package << mNumOfBitShift) + (((UINT32)ProcessorInfoBuffer.ProcessorId) & CoreThreadMask));
- if(mX2ApicEnabled) { //if X2Apic, re-order the socket # so it starts from base 0 and contiguous
- //may not necessory!!!!!
- }
+ CpuIdMapPtr->AcpiProcessorId = ((UINT32)ProcessorInfoBuffer.Location.Package * (UINT32)mNumberOfCpus * 2) + Index;

//update processorbitMask
if (CpuIdMapPtr->Flags == 1) {
-
if(mForceX2ApicId) {
CpuIdMapPtr->SocketNum &= 0x7;
CpuIdMapPtr->AcpiProcessorId &= 0xFF; //keep lower 8bit due to use Proc obj in dsdt
- CpuIdMapPtr->SwProcApicId &= 0xFF;
}
}
} else { //not enabled
- CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *)&mCpuApicIdOrderTable[Index];
+ CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *)&TempCpuApicIdOrderTable[Index];
CpuIdMapPtr->ApicId = (UINT32)-1;
CpuIdMapPtr->Flags = 0;
CpuIdMapPtr->AcpiProcessorId = (UINT32)-1;
- CpuIdMapPtr->SwProcApicId = (UINT32)-1;
CpuIdMapPtr->SocketNum = (UINT32)-1;
} //end if PROC ENABLE
} //end for CurrentProcessor

//keep for debug purpose
- DEBUG(( EFI_D_ERROR, "::ACPI:: APIC ID Order Table Init. CoreThreadMask = %x, mNumOfBitShift = %x\n", CoreThreadMask, mNumOfBitShift));
- DebugDisplayReOrderTable();
+ DEBUG ((DEBUG_INFO, "::ACPI:: APIC ID Order Table Init. CoreThreadMask = %x, mNumOfBitShift = %x\n", CoreThreadMask, mNumOfBitShift));
+ DebugDisplayReOrderTable (TempCpuApicIdOrderTable);

//make sure 1st entry is BSP
if(mX2ApicEnabled) {
- BspApicId = (UINT32)AsmReadMsr64(0x802);
+ BspApicId = (UINT32)AsmReadMsr64 (0x802);
} else {
BspApicId = (*(volatile UINT32 *)(UINTN)0xFEE00020) >> 24;
}
- DEBUG ((EFI_D_INFO, "BspApicId - 0x%x\n", BspApicId));
+ DEBUG ((DEBUG_INFO, "BspApicId - 0x%x\n", BspApicId));

- if(mCpuApicIdOrderTable[0].ApicId != BspApicId) {
+ if (TempCpuApicIdOrderTable[0].ApicId != BspApicId) {
//check to see if 1st entry is BSP, if not swap it
Index = ApicId2SwProcApicId(BspApicId);

- if(MAX_CPU_NUM <= Index) {
- DEBUG ((EFI_D_ERROR, "Asserting the SortCpuLocalApicInTable Index Bufferflow\n"));
+ if(mNumberOfCpus <= Index) {
+ DEBUG ((DEBUG_ERROR, "Asserting the SortCpuLocalApicInTable Index Bufferflow\n"));
return EFI_INVALID_PARAMETER;
}

- TempVal = mCpuApicIdOrderTable[Index].ApicId;
- mCpuApicIdOrderTable[Index].ApicId = mCpuApicIdOrderTable[0].ApicId;
- mCpuApicIdOrderTable[0].ApicId = TempVal;
- mCpuApicIdOrderTable[Index].Flags = mCpuApicIdOrderTable[0].Flags;
- mCpuApicIdOrderTable[0].Flags = 1;
- TempVal = mCpuApicIdOrderTable[Index].SwProcApicId;
- mCpuApicIdOrderTable[Index].SwProcApicId = mCpuApicIdOrderTable[0].SwProcApicId;
- mCpuApicIdOrderTable[0].SwProcApicId = TempVal;
+ TempVal = TempCpuApicIdOrderTable[Index].ApicId;
+ TempCpuApicIdOrderTable[Index].ApicId = TempCpuApicIdOrderTable[0].ApicId;
+ TempCpuApicIdOrderTable[0].ApicId = TempVal;
+ TempCpuApicIdOrderTable[Index].Flags = TempCpuApicIdOrderTable[0].Flags;
+ TempCpuApicIdOrderTable[0].Flags = 1;
//swap AcpiProcId
- TempVal = mCpuApicIdOrderTable[Index].AcpiProcessorId;
- mCpuApicIdOrderTable[Index].AcpiProcessorId = mCpuApicIdOrderTable[0].AcpiProcessorId;
- mCpuApicIdOrderTable[0].AcpiProcessorId = TempVal;
-
+ TempVal = TempCpuApicIdOrderTable[Index].AcpiProcessorId;
+ TempCpuApicIdOrderTable[Index].AcpiProcessorId = TempCpuApicIdOrderTable[0].AcpiProcessorId;
+ TempCpuApicIdOrderTable[0].AcpiProcessorId = TempVal;
}

//Make sure no holes between enabled threads
- for(CurrProcessor = 0; CurrProcessor < MAX_CPU_NUM; CurrProcessor++) {
-
- if(mCpuApicIdOrderTable[CurrProcessor].Flags == 0) {
- //make sure disabled entry has ProcId set to FFs
- mCpuApicIdOrderTable[CurrProcessor].ApicId = (UINT32)-1;
- mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = (UINT32)-1;
- mCpuApicIdOrderTable[CurrProcessor].SwProcApicId = (UINT32)-1;
-
- for(Index = CurrProcessor+1; Index < MAX_CPU_NUM; Index++) {
- if(mCpuApicIdOrderTable[Index].Flags == 1) {
- //move enabled entry up
- mCpuApicIdOrderTable[CurrProcessor].Flags = 1;
- mCpuApicIdOrderTable[CurrProcessor].ApicId = mCpuApicIdOrderTable[Index].ApicId;
- mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = mCpuApicIdOrderTable[Index].AcpiProcessorId;
- mCpuApicIdOrderTable[CurrProcessor].SwProcApicId = mCpuApicIdOrderTable[Index].SwProcApicId;
- mCpuApicIdOrderTable[CurrProcessor].SocketNum = mCpuApicIdOrderTable[Index].SocketNum;
- //disable moved entry
- mCpuApicIdOrderTable[Index].Flags = 0;
- mCpuApicIdOrderTable[Index].ApicId = (UINT32)-1;
- mCpuApicIdOrderTable[Index].AcpiProcessorId = (UINT32)-1;
- mCpuApicIdOrderTable[Index].SwProcApicId = (UINT32)-1;
- break;
- }
- }
+ for (CurrProcessor = 0, Index = 0; Index < mNumberOfCpus; Index++) {
+ if ((TempCpuApicIdOrderTable[Index].ApicId & 1) == 0) { // primary thread
+ mCpuApicIdOrderTable[CurrProcessor].ApicId = TempCpuApicIdOrderTable[Index].ApicId;
+ mCpuApicIdOrderTable[CurrProcessor].Flags = TempCpuApicIdOrderTable[Index].Flags;
+ mCpuApicIdOrderTable[CurrProcessor].SocketNum = TempCpuApicIdOrderTable[Index].SocketNum;
+ mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = TempCpuApicIdOrderTable[Index].AcpiProcessorId;
+ CurrProcessor++;
+ }
+ }
+
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
+ if ((TempCpuApicIdOrderTable[Index].ApicId & 1) == 1) { //second thread
+ mCpuApicIdOrderTable[CurrProcessor].ApicId = TempCpuApicIdOrderTable[Index].ApicId;
+ mCpuApicIdOrderTable[CurrProcessor].Flags = TempCpuApicIdOrderTable[Index].Flags;
+ mCpuApicIdOrderTable[CurrProcessor].SocketNum = TempCpuApicIdOrderTable[Index].SocketNum;
+ mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = TempCpuApicIdOrderTable[Index].AcpiProcessorId;
+ CurrProcessor++;
+ }
+ }
+
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
+ if (TempCpuApicIdOrderTable[Index].Flags == 0) { // not enabled
+ mCpuApicIdOrderTable[CurrProcessor].ApicId = TempCpuApicIdOrderTable[Index].ApicId;
+ mCpuApicIdOrderTable[CurrProcessor].Flags = TempCpuApicIdOrderTable[Index].Flags;
+ mCpuApicIdOrderTable[CurrProcessor].SocketNum = TempCpuApicIdOrderTable[Index].SocketNum;
+ mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = TempCpuApicIdOrderTable[Index].AcpiProcessorId;
+ CurrProcessor++;
}
}

//keep for debug purpose
- DEBUG ((EFI_D_ERROR, "APIC ID Order Table ReOrdered\n"));
- DebugDisplayReOrderTable();
+ DEBUG ((DEBUG_INFO, "APIC ID Order Table ReOrdered\n"));
+ DebugDisplayReOrderTable (mCpuApicIdOrderTable);

mCpuOrderSorted = TRUE;
}
@@ -602,11 +470,11 @@ InitializeMadtHeader (
}

Status = InitializeHeader (
- &MadtHeader->Header,
- EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
- EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
- 0
- );
+ &MadtHeader->Header,
+ EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
+ 0
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -784,11 +652,11 @@ BuildAcpiTable (
// Allocate the memory needed for the table.
//
Status = AllocateTable (
- TableSpecificHdrLength,
- Structures,
- StructureCount,
- &InternalTable
- );
+ TableSpecificHdrLength,
+ Structures,
+ StructureCount,
+ &InternalTable
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -871,18 +739,22 @@ InstallMadtFromScratch (
NewMadtTable = NULL;
MaxMadtStructCount = 0;

- DetectApicIdMap();
+ mCpuApicIdOrderTable = AllocateZeroPool (mNumberOfCpus * sizeof (EFI_CPU_ID_ORDER_MAP));
+ if (mCpuApicIdOrderTable == NULL) {
+ DEBUG ((DEBUG_ERROR, "Could not allocate mCpuApicIdOrderTable structure pointer array\n"));
+ return EFI_OUT_OF_RESOURCES;
+ }

// Call for Local APIC ID Reorder
Status = SortCpuLocalApicInTable ();
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "SortCpuLocalApicInTable failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "SortCpuLocalApicInTable failed: %r\n", Status));
goto Done;
}

MaxMadtStructCount = (UINT32) (
- MAX_CPU_NUM + // processor local APIC structures
- MAX_CPU_NUM + // processor local x2APIC structures
+ mNumberOfCpus + // processor local APIC structures
+ mNumberOfCpus + // processor local x2APIC structures
1 + PcdGet8(PcdPcIoApicCount) + // I/O APIC structures
2 + // interrupt source override structures
1 + // local APIC NMI structures
@@ -906,11 +778,11 @@ InstallMadtFromScratch (
//
Status = InitializeMadtHeader (&MadtTableHeader);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "InitializeMadtHeader failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeMadtHeader failed: %r\n", Status));
goto Done;
}

- DEBUG ((EFI_D_INFO, "Number of CPUs detected = %d \n", mNumberOfCPUs));
+ DEBUG ((DEBUG_INFO, "Number of CPUs detected = %d \n", mNumberOfCpus));

//
// Build Processor Local APIC Structures and Processor Local X2APIC Structures
@@ -923,7 +795,7 @@ InstallMadtFromScratch (
ProcLocalX2ApicStruct.Reserved[0] = 0;
ProcLocalX2ApicStruct.Reserved[1] = 0;

- for (Index = 0; Index < MAX_CPU_NUM; Index++) {
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
//
// If x2APIC mode is not enabled, and if it is possible to express the
// APIC ID as a UINT8, use a processor local APIC structure. Otherwise,
@@ -936,10 +808,10 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &ProcLocalApicStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &ProcLocalApicStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
} else if (mCpuApicIdOrderTable[Index].ApicId != 0xFFFFFFFF) {
ProcLocalX2ApicStruct.Flags = (UINT8) mCpuApicIdOrderTable[Index].Flags;
ProcLocalX2ApicStruct.X2ApicId = mCpuApicIdOrderTable[Index].ApicId;
@@ -947,13 +819,13 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &ProcLocalX2ApicStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &ProcLocalX2ApicStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
}
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (local APIC/x2APIC) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (local APIC/x2APIC) failed: %r\n", Status));
goto Done;
}
}
@@ -965,44 +837,44 @@ InstallMadtFromScratch (
IoApicStruct.Length = sizeof (EFI_ACPI_4_0_IO_APIC_STRUCTURE);
IoApicStruct.Reserved = 0;

- PcIoApicEnable = PcdGet32(PcdPcIoApicEnable);
+ PcIoApicEnable = PcdGet32 (PcdPcIoApicEnable);

- if (FixedPcdGet32(PcdMaxCpuSocketCount) <= 4) {
+ if (FixedPcdGet32 (PcdMaxCpuSocketCount) <= 4) {
IoApicStruct.IoApicId = PcdGet8(PcdIoApicId);
IoApicStruct.IoApicAddress = PcdGet32(PcdIoApicAddress);
IoApicStruct.GlobalSystemInterruptBase = 0;
ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &IoApicStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &IoApicStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n", Status));
goto Done;
}
}

for (PcIoApicIndex = 0; PcIoApicIndex < PcdGet8(PcdPcIoApicCount); PcIoApicIndex++) {
- PcIoApicMask = (1 << PcIoApicIndex);
- if ((PcIoApicEnable & PcIoApicMask) == 0) {
- continue;
- }
+ PcIoApicMask = (1 << PcIoApicIndex);
+ if ((PcIoApicEnable & PcIoApicMask) == 0) {
+ continue;
+ }

- IoApicStruct.IoApicId = (UINT8)(PcdGet8(PcdPcIoApicIdBase) + PcIoApicIndex);
- IoApicStruct.IoApicAddress = CurrentIoApicAddress;
- CurrentIoApicAddress = (CurrentIoApicAddress & 0xFFFF8000) + 0x8000;
- IoApicStruct.GlobalSystemInterruptBase = (UINT32)(24 + (PcIoApicIndex * 8));
- ASSERT (MadtStructsIndex < MaxMadtStructCount);
- Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &IoApicStruct,
- &MadtStructs[MadtStructsIndex++]
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n", Status));
- goto Done;
- }
+ IoApicStruct.IoApicId = (UINT8)(PcdGet8(PcdPcIoApicIdBase) + PcIoApicIndex);
+ IoApicStruct.IoApicAddress = CurrentIoApicAddress;
+ CurrentIoApicAddress = (CurrentIoApicAddress & 0xFFFF8000) + 0x8000;
+ IoApicStruct.GlobalSystemInterruptBase = (UINT32)(24 + (PcIoApicIndex * 8));
+ ASSERT (MadtStructsIndex < MaxMadtStructCount);
+ Status = CopyStructure (
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &IoApicStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n", Status));
+ goto Done;
+ }
}

//
@@ -1021,12 +893,12 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &IntSrcOverrideStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &IntSrcOverrideStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (IRQ2 source override) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (IRQ2 source override) failed: %r\n", Status));
goto Done;
}

@@ -1040,12 +912,12 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &IntSrcOverrideStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &IntSrcOverrideStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (IRQ9 source override) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (IRQ9 source override) failed: %r\n", Status));
goto Done;
}

@@ -1060,12 +932,12 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &LocalApciNmiStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &LocalApciNmiStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n", Status));
goto Done;
}

@@ -1084,10 +956,10 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &LocalX2ApicNmiStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &LocalX2ApicNmiStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "CopyMadtStructure (x2APIC NMI) failed: %r\n", Status));
goto Done;
@@ -1098,14 +970,14 @@ InstallMadtFromScratch (
// Build Madt Structure from the Madt Header and collection of pointers in MadtStructs[]
//
Status = BuildAcpiTable (
- (EFI_ACPI_DESCRIPTION_HEADER *) &MadtTableHeader,
- sizeof (EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER),
- MadtStructs,
- MadtStructsIndex,
- (UINT8 **)&NewMadtTable
- );
+ (EFI_ACPI_DESCRIPTION_HEADER *) &MadtTableHeader,
+ sizeof (EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER),
+ MadtStructs,
+ MadtStructsIndex,
+ (UINT8 **) &NewMadtTable
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "BuildAcpiTable failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "BuildAcpiTable failed: %r\n", Status));
goto Done;
}

@@ -1113,11 +985,11 @@ InstallMadtFromScratch (
// Publish Madt Structure to ACPI
//
Status = mAcpiTable->InstallAcpiTable (
- mAcpiTable,
- NewMadtTable,
- NewMadtTable->Header.Length,
- &TableHandle
- );
+ mAcpiTable,
+ NewMadtTable,
+ NewMadtTable->Header.Length,
+ &TableHandle
+ );

Done:
//
@@ -1136,6 +1008,10 @@ Done:
FreePool (NewMadtTable);
}

+ if (mCpuApicIdOrderTable != NULL) {
+ FreePool (mCpuApicIdOrderTable);
+ }
+
return Status;
}

@@ -1155,8 +1031,8 @@ InstallMcfgFromScratch (
PciSegmentInfo = GetPciSegmentInfo (&SegmentCount);

McfgTable = AllocateZeroPool (
- sizeof(EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER) +
- sizeof(EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE) * SegmentCount
+ sizeof (EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER) +
+ sizeof (EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE) * SegmentCount
);
if (McfgTable == NULL) {
DEBUG ((DEBUG_ERROR, "Could not allocate MCFG structure\n"));
@@ -1164,11 +1040,11 @@ InstallMcfgFromScratch (
}

Status = InitializeHeader (
- &McfgTable->Header,
- EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
- EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION,
- 0
- );
+ &McfgTable->Header,
+ EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION,
+ 0
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1192,11 +1068,11 @@ InstallMcfgFromScratch (
// Publish Madt Structure to ACPI
//
Status = mAcpiTable->InstallAcpiTable (
- mAcpiTable,
- McfgTable,
- McfgTable->Header.Length,
- &TableHandle
- );
+ mAcpiTable,
+ McfgTable,
+ McfgTable->Header.Length,
+ &TableHandle
+ );

return Status;
}
@@ -1280,7 +1156,7 @@ PlatformUpdateTables (
switch (Table->Signature) {

case EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE:
- ASSERT(FALSE);
+ ASSERT (FALSE);
break;

case EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE:
@@ -1324,9 +1200,9 @@ PlatformUpdateTables (
FadtHeader->XGpe1Blk.AccessSize = 0;
}

- DEBUG(( EFI_D_ERROR, "ACPI FADT table @ address 0x%x\n", Table ));
- DEBUG(( EFI_D_ERROR, " IaPcBootArch 0x%x\n", FadtHeader->IaPcBootArch ));
- DEBUG(( EFI_D_ERROR, " Flags 0x%x\n", FadtHeader->Flags ));
+ DEBUG ((DEBUG_INFO, "ACPI FADT table @ address 0x%x\n", Table));
+ DEBUG ((DEBUG_INFO, " IaPcBootArch 0x%x\n", FadtHeader->IaPcBootArch));
+ DEBUG ((DEBUG_INFO, " Flags 0x%x\n", FadtHeader->Flags));
break;

case EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE:
@@ -1346,12 +1222,12 @@ PlatformUpdateTables (
HpetBlockId.Bits.VendorId = HpetCapabilities.Bits.VendorId;
HpetTable->EventTimerBlockId = HpetBlockId.Uint32;
HpetTable->MainCounterMinimumClockTickInPeriodicMode = (UINT16)HpetCapabilities.Bits.CounterClockPeriod;
- DEBUG(( EFI_D_ERROR, "ACPI HPET table @ address 0x%x\n", Table ));
- DEBUG(( EFI_D_ERROR, " HPET base 0x%x\n", PcdGet32 (PcdHpetBaseAddress) ));
+ DEBUG ((DEBUG_INFO, "ACPI HPET table @ address 0x%x\n", Table));
+ DEBUG ((DEBUG_INFO, " HPET base 0x%x\n", PcdGet32 (PcdHpetBaseAddress)));
break;

case EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE:
- ASSERT(FALSE);
+ ASSERT (FALSE);
break;

default:
@@ -1403,8 +1279,8 @@ IsHardwareChange (
// pFADT->XDsdt
//
HWChangeSize = HandleCount + 1;
- HWChange = AllocateZeroPool( sizeof(UINT32) * HWChangeSize );
- ASSERT( HWChange != NULL );
+ HWChange = AllocateZeroPool (sizeof(UINT32) * HWChangeSize);
+ ASSERT(HWChange != NULL);

if (HWChange == NULL) return;

@@ -1445,14 +1321,14 @@ IsHardwareChange (
// Calculate CRC value with HWChange data.
//
Status = gBS->CalculateCrc32(HWChange, HWChangeSize, &CRC);
- DEBUG((DEBUG_INFO, "CRC = %x and Status = %r\n", CRC, Status));
+ DEBUG ((DEBUG_INFO, "CRC = %x and Status = %r\n", CRC, Status));

//
// Set HardwareSignature value based on CRC value.
//
FacsPtr = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)pFADT->FirmwareCtrl;
FacsPtr->HardwareSignature = CRC;
- FreePool( HWChange );
+ FreePool (HWChange);
}

VOID
@@ -1475,17 +1351,16 @@ UpdateLocalTable (

if (Version != EFI_ACPI_TABLE_VERSION_NONE) {
Status = mAcpiTable->InstallAcpiTable (
- mAcpiTable,
- CurrentTable,
- CurrentTable->Length,
- &TableHandle
- );
+ mAcpiTable,
+ CurrentTable,
+ CurrentTable->Length,
+ &TableHandle
+ );
ASSERT_EFI_ERROR (Status);
}
}
}

-
VOID
EFIAPI
AcpiEndOfDxeEvent (
@@ -1493,16 +1368,14 @@ AcpiEndOfDxeEvent (
VOID *ParentImageHandle
)
{
-
if (Event != NULL) {
- gBS->CloseEvent(Event);
+ gBS->CloseEvent (Event);
}

-
//
// Calculate Hardware Signature value based on current platform configurations
//
- IsHardwareChange();
+ IsHardwareChange ();
}

/**
@@ -1526,7 +1399,6 @@ InstallAcpiPlatform (
EFI_STATUS Status;
EFI_EVENT EndOfDxeEvent;

-
Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&mMpService);
ASSERT_EFI_ERROR (Status);

@@ -1550,19 +1422,19 @@ InstallAcpiPlatform (
// Determine the number of processors
//
mMpService->GetNumberOfProcessors (
- mMpService,
- &mNumberOfCPUs,
- &mNumberOfEnabledCPUs
- );
- ASSERT (mNumberOfCPUs <= MAX_CPU_NUM && mNumberOfEnabledCPUs >= 1);
- DEBUG ((DEBUG_INFO, "mNumberOfCPUs - %d\n", mNumberOfCPUs));
+ mMpService,
+ &mNumberOfCpus,
+ &mNumberOfEnabledCPUs
+ );
+
+ DEBUG ((DEBUG_INFO, "mNumberOfCpus - %d\n", mNumberOfCpus));
DEBUG ((DEBUG_INFO, "mNumberOfEnabledCPUs - %d\n", mNumberOfEnabledCPUs));

DEBUG ((DEBUG_INFO, "mX2ApicEnabled - 0x%x\n", mX2ApicEnabled));
DEBUG ((DEBUG_INFO, "mForceX2ApicId - 0x%x\n", mForceX2ApicId));

// support up to 64 threads/socket
- AsmCpuidEx(CPUID_EXTENDED_TOPOLOGY, 1, &mNumOfBitShift, NULL, NULL, NULL);
+ AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 1, &mNumOfBitShift, NULL, NULL, NULL);
mNumOfBitShift &= 0x1F;
DEBUG ((DEBUG_INFO, "mNumOfBitShift - 0x%x\n", mNumOfBitShift));

--
2.32.0.windows.2


[edk2-platforms: PATCH V4] Platform/Intel: Correct CPU APIC IDs

JackX Lin
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3365

BIOS cannot find correct AcpiProcId in mApicIdMap because of
there is no suitable map, that causes ACPI_BIOS_ERROR.
Remove mApicIdMap for determing AcpiProcId, uses normal
countings instead.

Signed-off-by: JackX Lin <JackX.Lin@...>
Cc: Chasel Chiu <chasel.chiu@...>
Cc: Jenny Huang <jenny.huang@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Donald Kuo <Donald.Kuo@...>
Cc: Chandana C Kumar <chandana.c.kumar@...>
Cc: Tinax Chen <tinax.y.chen@...>
Cc: JackX Lin <JackX.Lin@...>
Change-Id: Ib64e519686b2f324a0a57c3b5bba220a7b75fda1
---
Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 538 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 file changed, 206 insertions(+), 332 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index 2b51c34ef2..4d9c709e4f 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -1,22 +1,19 @@
/** @file
ACPI Platform Driver

-Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include "AcpiPlatform.h"

-#define MAX_CPU_NUM (FixedPcdGet32(PcdMaxCpuThreadCount) * FixedPcdGet32(PcdMaxCpuCoreCount) * FixedPcdGet32(PcdMaxCpuSocketCount))
-
#pragma pack(1)

typedef struct {
UINT32 AcpiProcessorId;
UINT32 ApicId;
UINT32 Flags;
- UINT32 SwProcApicId;
UINT32 SocketNum;
} EFI_CPU_ID_ORDER_MAP;

@@ -50,7 +47,7 @@ VOID *mLocalTable[] = {
&Wsmt,
};

-EFI_ACPI_TABLE_PROTOCOL *mAcpiTable;
+EFI_ACPI_TABLE_PROTOCOL *mAcpiTable;

UINT32 mNumOfBitShift = 6;
BOOLEAN mForceX2ApicId;
@@ -58,138 +55,19 @@ BOOLEAN mX2ApicEnabled;

EFI_MP_SERVICES_PROTOCOL *mMpService;
BOOLEAN mCpuOrderSorted;
-EFI_CPU_ID_ORDER_MAP mCpuApicIdOrderTable[MAX_CPU_NUM];
-UINTN mNumberOfCPUs = 0;
+EFI_CPU_ID_ORDER_MAP *mCpuApicIdOrderTable = NULL;
+UINTN mNumberOfCpus = 0;
UINTN mNumberOfEnabledCPUs = 0;

-// following are possible APICID Map for SKX
-static const UINT32 ApicIdMapA[] = { //for SKUs have number of core > 16
- //it is 14 + 14 + 14 + 14 format
- 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x00000010, 0x00000011,
- 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019,
- 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x00000020, 0x00000021, 0x00000022, 0x00000023,
- 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B,
- 0x0000002C, 0x0000002D, 0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035,
- 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D
-};
-
-static const UINT32 ApicIdMapB[] = { //for SKUs have number of cores <= 16 use 32 ID space
- //it is 16+16 format
- 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
- 0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017,
- 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
-};
-
-
-static const UINT32 ApicIdMapC[] = { //for SKUs have number of cores <= 16 use 64 ID space
- //it is 16+0+16+0 format
- 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
- 0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027,
- 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
-};
-
-static const UINT32 ApicIdMapD[] = { //for SKUs have number of cores <= 8 use 16 ID space
- //it is 16 format
- 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
- 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
- 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
-};
-
-const UINT32 *mApicIdMap = NULL;
-
/**
- This function detect the APICID map and update ApicID Map pointer
+ Find BSP in mCpuApicIdOrderTable.

- @param None
+ This function searches mCpuApicIdOrderTable to find the BSP ApicId, and returns a number where the BSP is.

- @retval VOID
-
-**/
-VOID DetectApicIdMap(VOID)
-{
- UINTN CoreCount;
-
- CoreCount = 0;
-
- if(mApicIdMap != NULL) {
- return; //aleady initialized
- }
-
- mApicIdMap = ApicIdMapA; // default to > 16C SKUs
-
- CoreCount = mNumberOfEnabledCPUs / 2;
- DEBUG ((DEBUG_INFO, "CoreCount - %d\n", CoreCount));
-
- //DEBUG((EFI_D_ERROR, ":: Default to use Map A @ %08X FusedCoreCount: %02d, sktlevel: %d\n",mApicIdMap, FusedCoreCount, mNumOfBitShift));
- // Dont assert for single core, single thread system.
- //ASSERT (CoreCount != 0);
-
- if(CoreCount <= 16) {
-
- if(mNumOfBitShift == 4) {
- mApicIdMap = ApicIdMapD;
- //DEBUG((EFI_D_ERROR, ":: Use Map B @ %08X\n",mApicIdMap));
- }
-
- if(mNumOfBitShift == 5) {
- mApicIdMap = ApicIdMapB;
- //DEBUG((EFI_D_ERROR, ":: Use Map B @ %08X\n",mApicIdMap));
- }
-
- if(mNumOfBitShift == 6) {
- mApicIdMap = ApicIdMapC;
- //DEBUG((EFI_D_ERROR, ":: Use Map C @ %08X\n",mApicIdMap));
- }
-
- }
-
- return;
-}
-
-/**
- This function return the CoreThreadId of ApicId from ACPI ApicId Map array
-
- @param ApicId
-
- @retval Index of ACPI ApicId Map array
+ @param[in] ApicId Apic ID.

+ @return Where the BSP is.
**/
-UINT32
-GetIndexFromApicId (
- UINT32 ApicId
- )
-{
- UINT32 CoreThreadId;
- UINT32 i;
-
- ASSERT (mApicIdMap != NULL);
-
- CoreThreadId = ApicId & ((1 << mNumOfBitShift) - 1);
-
- for(i = 0; i < (FixedPcdGet32(PcdMaxCpuCoreCount) * FixedPcdGet32(PcdMaxCpuThreadCount)); i++) {
- if(mApicIdMap[i] == CoreThreadId) {
- break;
- }
- }
-
- ASSERT (i <= (FixedPcdGet32(PcdMaxCpuCoreCount) * FixedPcdGet32(PcdMaxCpuThreadCount)));
-
- return i;
-}
-
UINT32
ApicId2SwProcApicId (
UINT32 ApicId
@@ -197,7 +75,7 @@ ApicId2SwProcApicId (
{
UINT32 Index;

- for (Index = 0; Index < MAX_CPU_NUM; Index++) {
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
if ((mCpuApicIdOrderTable[Index].Flags == 1) && (mCpuApicIdOrderTable[Index].ApicId == ApicId)) {
return Index;
}
@@ -207,21 +85,25 @@ ApicId2SwProcApicId (

}

+/**
+ Print Cpu Apic ID Table
+
+ @param[in] CpuApicIdOrderTable Data will be dumped.
+**/
VOID
-DebugDisplayReOrderTable(
- VOID
+DebugDisplayReOrderTable (
+ IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable
)
{
UINT32 Index;

- DEBUG ((EFI_D_ERROR, "Index AcpiProcId ApicId Flags SwApicId Skt\n"));
- for (Index=0; Index<MAX_CPU_NUM; Index++) {
- DEBUG ((EFI_D_ERROR, " %02d 0x%02X 0x%02X %d 0x%02X %d\n",
- Index, mCpuApicIdOrderTable[Index].AcpiProcessorId,
- mCpuApicIdOrderTable[Index].ApicId,
- mCpuApicIdOrderTable[Index].Flags,
- mCpuApicIdOrderTable[Index].SwProcApicId,
- mCpuApicIdOrderTable[Index].SocketNum));
+ DEBUG ((DEBUG_INFO, "Index AcpiProcId ApicId Flags Skt\n"));
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
+ DEBUG ((DEBUG_INFO, " %02d 0x%02X 0x%02X %d %d\n",
+ Index, CpuApicIdOrderTable[Index].AcpiProcessorId,
+ CpuApicIdOrderTable[Index].ApicId,
+ CpuApicIdOrderTable[Index].Flags,
+ CpuApicIdOrderTable[Index].SocketNum));
}
}

@@ -284,125 +166,113 @@ SortCpuLocalApicInTable (
UINT32 TempVal = 0;
EFI_CPU_ID_ORDER_MAP *CpuIdMapPtr;
UINT32 CoreThreadMask;
+ EFI_CPU_ID_ORDER_MAP *TempCpuApicIdOrderTable;

Index = 0;
Status = EFI_SUCCESS;

+ TempCpuApicIdOrderTable = AllocateZeroPool (mNumberOfCpus * sizeof (EFI_CPU_ID_ORDER_MAP));
CoreThreadMask = (UINT32) ((1 << mNumOfBitShift) - 1);

if(!mCpuOrderSorted) {
-
- Index = 0;
-
- for (CurrProcessor = 0; CurrProcessor < mNumberOfCPUs; CurrProcessor++) {
+ for (CurrProcessor = 0, Index = 0; CurrProcessor < mNumberOfCpus; CurrProcessor++, Index++) {
Status = mMpService->GetProcessorInfo (
- mMpService,
- CurrProcessor,
- &ProcessorInfoBuffer
- );
+ mMpService,
+ CurrProcessor,
+ &ProcessorInfoBuffer
+ );

if ((ProcessorInfoBuffer.StatusFlag & PROCESSOR_ENABLED_BIT) != 0) {
- if(ProcessorInfoBuffer.ProcessorId & 1) { //is 2nd thread
- CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *)&mCpuApicIdOrderTable[(Index - 1) + MAX_CPU_NUM / 2];
- } else { //is primary thread
- CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *)&mCpuApicIdOrderTable[Index];
- Index++;
- }
+ CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *) &TempCpuApicIdOrderTable[Index];
CpuIdMapPtr->ApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;
CpuIdMapPtr->Flags = ((ProcessorInfoBuffer.StatusFlag & PROCESSOR_ENABLED_BIT) != 0);
CpuIdMapPtr->SocketNum = (UINT32)ProcessorInfoBuffer.Location.Package;
- CpuIdMapPtr->AcpiProcessorId = (CpuIdMapPtr->SocketNum * FixedPcdGet32(PcdMaxCpuCoreCount) * FixedPcdGet32(PcdMaxCpuThreadCount)) + GetIndexFromApicId(CpuIdMapPtr->ApicId); //CpuIdMapPtr->ApicId;
- CpuIdMapPtr->SwProcApicId = ((UINT32)(ProcessorInfoBuffer.Location.Package << mNumOfBitShift) + (((UINT32)ProcessorInfoBuffer.ProcessorId) & CoreThreadMask));
- if(mX2ApicEnabled) { //if X2Apic, re-order the socket # so it starts from base 0 and contiguous
- //may not necessory!!!!!
- }
+ CpuIdMapPtr->AcpiProcessorId = ((UINT32)ProcessorInfoBuffer.Location.Package * (UINT32)mNumberOfCpus * 2) + Index;

//update processorbitMask
if (CpuIdMapPtr->Flags == 1) {
-
if(mForceX2ApicId) {
CpuIdMapPtr->SocketNum &= 0x7;
CpuIdMapPtr->AcpiProcessorId &= 0xFF; //keep lower 8bit due to use Proc obj in dsdt
- CpuIdMapPtr->SwProcApicId &= 0xFF;
}
}
} else { //not enabled
- CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *)&mCpuApicIdOrderTable[Index];
+ CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *)&TempCpuApicIdOrderTable[Index];
CpuIdMapPtr->ApicId = (UINT32)-1;
CpuIdMapPtr->Flags = 0;
CpuIdMapPtr->AcpiProcessorId = (UINT32)-1;
- CpuIdMapPtr->SwProcApicId = (UINT32)-1;
CpuIdMapPtr->SocketNum = (UINT32)-1;
} //end if PROC ENABLE
} //end for CurrentProcessor

//keep for debug purpose
- DEBUG(( EFI_D_ERROR, "::ACPI:: APIC ID Order Table Init. CoreThreadMask = %x, mNumOfBitShift = %x\n", CoreThreadMask, mNumOfBitShift));
- DebugDisplayReOrderTable();
+ DEBUG ((DEBUG_INFO, "::ACPI:: APIC ID Order Table Init. CoreThreadMask = %x, mNumOfBitShift = %x\n", CoreThreadMask, mNumOfBitShift));
+ DebugDisplayReOrderTable (TempCpuApicIdOrderTable);

//make sure 1st entry is BSP
if(mX2ApicEnabled) {
- BspApicId = (UINT32)AsmReadMsr64(0x802);
+ BspApicId = (UINT32)AsmReadMsr64 (0x802);
} else {
BspApicId = (*(volatile UINT32 *)(UINTN)0xFEE00020) >> 24;
}
- DEBUG ((EFI_D_INFO, "BspApicId - 0x%x\n", BspApicId));
+ DEBUG ((DEBUG_INFO, "BspApicId - 0x%x\n", BspApicId));

- if(mCpuApicIdOrderTable[0].ApicId != BspApicId) {
+ if (TempCpuApicIdOrderTable[0].ApicId != BspApicId) {
//check to see if 1st entry is BSP, if not swap it
Index = ApicId2SwProcApicId(BspApicId);

- if(MAX_CPU_NUM <= Index) {
- DEBUG ((EFI_D_ERROR, "Asserting the SortCpuLocalApicInTable Index Bufferflow\n"));
+ if(mNumberOfCpus <= Index) {
+ DEBUG ((DEBUG_ERROR, "Asserting the SortCpuLocalApicInTable Index Bufferflow\n"));
return EFI_INVALID_PARAMETER;
}

- TempVal = mCpuApicIdOrderTable[Index].ApicId;
- mCpuApicIdOrderTable[Index].ApicId = mCpuApicIdOrderTable[0].ApicId;
- mCpuApicIdOrderTable[0].ApicId = TempVal;
- mCpuApicIdOrderTable[Index].Flags = mCpuApicIdOrderTable[0].Flags;
- mCpuApicIdOrderTable[0].Flags = 1;
- TempVal = mCpuApicIdOrderTable[Index].SwProcApicId;
- mCpuApicIdOrderTable[Index].SwProcApicId = mCpuApicIdOrderTable[0].SwProcApicId;
- mCpuApicIdOrderTable[0].SwProcApicId = TempVal;
+ TempVal = TempCpuApicIdOrderTable[Index].ApicId;
+ TempCpuApicIdOrderTable[Index].ApicId = TempCpuApicIdOrderTable[0].ApicId;
+ TempCpuApicIdOrderTable[0].ApicId = TempVal;
+ TempCpuApicIdOrderTable[Index].Flags = TempCpuApicIdOrderTable[0].Flags;
+ TempCpuApicIdOrderTable[0].Flags = 1;
//swap AcpiProcId
- TempVal = mCpuApicIdOrderTable[Index].AcpiProcessorId;
- mCpuApicIdOrderTable[Index].AcpiProcessorId = mCpuApicIdOrderTable[0].AcpiProcessorId;
- mCpuApicIdOrderTable[0].AcpiProcessorId = TempVal;
-
+ TempVal = TempCpuApicIdOrderTable[Index].AcpiProcessorId;
+ TempCpuApicIdOrderTable[Index].AcpiProcessorId = TempCpuApicIdOrderTable[0].AcpiProcessorId;
+ TempCpuApicIdOrderTable[0].AcpiProcessorId = TempVal;
}

//Make sure no holes between enabled threads
- for(CurrProcessor = 0; CurrProcessor < MAX_CPU_NUM; CurrProcessor++) {
-
- if(mCpuApicIdOrderTable[CurrProcessor].Flags == 0) {
- //make sure disabled entry has ProcId set to FFs
- mCpuApicIdOrderTable[CurrProcessor].ApicId = (UINT32)-1;
- mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = (UINT32)-1;
- mCpuApicIdOrderTable[CurrProcessor].SwProcApicId = (UINT32)-1;
-
- for(Index = CurrProcessor+1; Index < MAX_CPU_NUM; Index++) {
- if(mCpuApicIdOrderTable[Index].Flags == 1) {
- //move enabled entry up
- mCpuApicIdOrderTable[CurrProcessor].Flags = 1;
- mCpuApicIdOrderTable[CurrProcessor].ApicId = mCpuApicIdOrderTable[Index].ApicId;
- mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = mCpuApicIdOrderTable[Index].AcpiProcessorId;
- mCpuApicIdOrderTable[CurrProcessor].SwProcApicId = mCpuApicIdOrderTable[Index].SwProcApicId;
- mCpuApicIdOrderTable[CurrProcessor].SocketNum = mCpuApicIdOrderTable[Index].SocketNum;
- //disable moved entry
- mCpuApicIdOrderTable[Index].Flags = 0;
- mCpuApicIdOrderTable[Index].ApicId = (UINT32)-1;
- mCpuApicIdOrderTable[Index].AcpiProcessorId = (UINT32)-1;
- mCpuApicIdOrderTable[Index].SwProcApicId = (UINT32)-1;
- break;
- }
- }
+ mCpuApicIdOrderTable = AllocateZeroPool (mNumberOfCpus * sizeof (EFI_CPU_ID_ORDER_MAP));
+
+ for (CurrProcessor = 0, Index = 0; Index < mNumberOfCpus; Index++) {
+ if ((TempCpuApicIdOrderTable[Index].ApicId & 1) == 0) { // primary thread
+ mCpuApicIdOrderTable[CurrProcessor].ApicId = TempCpuApicIdOrderTable[Index].ApicId;
+ mCpuApicIdOrderTable[CurrProcessor].Flags = TempCpuApicIdOrderTable[Index].Flags;
+ mCpuApicIdOrderTable[CurrProcessor].SocketNum = TempCpuApicIdOrderTable[Index].SocketNum;
+ mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = TempCpuApicIdOrderTable[Index].AcpiProcessorId;
+ CurrProcessor++;
+ }
+ }
+
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
+ if ((TempCpuApicIdOrderTable[Index].ApicId & 1) == 1) { //second thread
+ mCpuApicIdOrderTable[CurrProcessor].ApicId = TempCpuApicIdOrderTable[Index].ApicId;
+ mCpuApicIdOrderTable[CurrProcessor].Flags = TempCpuApicIdOrderTable[Index].Flags;
+ mCpuApicIdOrderTable[CurrProcessor].SocketNum = TempCpuApicIdOrderTable[Index].SocketNum;
+ mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = TempCpuApicIdOrderTable[Index].AcpiProcessorId;
+ CurrProcessor++;
+ }
+ }
+
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
+ if (TempCpuApicIdOrderTable[Index].Flags == 0) { // not enabled
+ mCpuApicIdOrderTable[CurrProcessor].ApicId = TempCpuApicIdOrderTable[Index].ApicId;
+ mCpuApicIdOrderTable[CurrProcessor].Flags = TempCpuApicIdOrderTable[Index].Flags;
+ mCpuApicIdOrderTable[CurrProcessor].SocketNum = TempCpuApicIdOrderTable[Index].SocketNum;
+ mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId = TempCpuApicIdOrderTable[Index].AcpiProcessorId;
+ CurrProcessor++;
}
}

//keep for debug purpose
- DEBUG ((EFI_D_ERROR, "APIC ID Order Table ReOrdered\n"));
- DebugDisplayReOrderTable();
+ DEBUG ((DEBUG_INFO, "APIC ID Order Table ReOrdered\n"));
+ DebugDisplayReOrderTable (mCpuApicIdOrderTable);

mCpuOrderSorted = TRUE;
}
@@ -602,11 +472,11 @@ InitializeMadtHeader (
}

Status = InitializeHeader (
- &MadtHeader->Header,
- EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
- EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
- 0
- );
+ &MadtHeader->Header,
+ EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
+ 0
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -784,11 +654,11 @@ BuildAcpiTable (
// Allocate the memory needed for the table.
//
Status = AllocateTable (
- TableSpecificHdrLength,
- Structures,
- StructureCount,
- &InternalTable
- );
+ TableSpecificHdrLength,
+ Structures,
+ StructureCount,
+ &InternalTable
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -871,18 +741,22 @@ InstallMadtFromScratch (
NewMadtTable = NULL;
MaxMadtStructCount = 0;

- DetectApicIdMap();
+ mCpuApicIdOrderTable = AllocateZeroPool (mNumberOfCpus * sizeof (EFI_CPU_ID_ORDER_MAP));
+ if (mCpuApicIdOrderTable == NULL) {
+ DEBUG ((DEBUG_ERROR, "Could not allocate mCpuApicIdOrderTable structure pointer array\n"));
+ return EFI_OUT_OF_RESOURCES;
+ }

// Call for Local APIC ID Reorder
Status = SortCpuLocalApicInTable ();
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "SortCpuLocalApicInTable failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "SortCpuLocalApicInTable failed: %r\n", Status));
goto Done;
}

MaxMadtStructCount = (UINT32) (
- MAX_CPU_NUM + // processor local APIC structures
- MAX_CPU_NUM + // processor local x2APIC structures
+ mNumberOfCpus + // processor local APIC structures
+ mNumberOfCpus + // processor local x2APIC structures
1 + PcdGet8(PcdPcIoApicCount) + // I/O APIC structures
2 + // interrupt source override structures
1 + // local APIC NMI structures
@@ -906,11 +780,11 @@ InstallMadtFromScratch (
//
Status = InitializeMadtHeader (&MadtTableHeader);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "InitializeMadtHeader failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeMadtHeader failed: %r\n", Status));
goto Done;
}

- DEBUG ((EFI_D_INFO, "Number of CPUs detected = %d \n", mNumberOfCPUs));
+ DEBUG ((DEBUG_INFO, "Number of CPUs detected = %d \n", mNumberOfCpus));

//
// Build Processor Local APIC Structures and Processor Local X2APIC Structures
@@ -923,7 +797,7 @@ InstallMadtFromScratch (
ProcLocalX2ApicStruct.Reserved[0] = 0;
ProcLocalX2ApicStruct.Reserved[1] = 0;

- for (Index = 0; Index < MAX_CPU_NUM; Index++) {
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
//
// If x2APIC mode is not enabled, and if it is possible to express the
// APIC ID as a UINT8, use a processor local APIC structure. Otherwise,
@@ -936,10 +810,10 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &ProcLocalApicStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &ProcLocalApicStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
} else if (mCpuApicIdOrderTable[Index].ApicId != 0xFFFFFFFF) {
ProcLocalX2ApicStruct.Flags = (UINT8) mCpuApicIdOrderTable[Index].Flags;
ProcLocalX2ApicStruct.X2ApicId = mCpuApicIdOrderTable[Index].ApicId;
@@ -947,13 +821,13 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &ProcLocalX2ApicStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &ProcLocalX2ApicStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
}
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (local APIC/x2APIC) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (local APIC/x2APIC) failed: %r\n", Status));
goto Done;
}
}
@@ -965,44 +839,44 @@ InstallMadtFromScratch (
IoApicStruct.Length = sizeof (EFI_ACPI_4_0_IO_APIC_STRUCTURE);
IoApicStruct.Reserved = 0;

- PcIoApicEnable = PcdGet32(PcdPcIoApicEnable);
+ PcIoApicEnable = PcdGet32 (PcdPcIoApicEnable);

- if (FixedPcdGet32(PcdMaxCpuSocketCount) <= 4) {
+ if (FixedPcdGet32 (PcdMaxCpuSocketCount) <= 4) {
IoApicStruct.IoApicId = PcdGet8(PcdIoApicId);
IoApicStruct.IoApicAddress = PcdGet32(PcdIoApicAddress);
IoApicStruct.GlobalSystemInterruptBase = 0;
ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &IoApicStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &IoApicStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n", Status));
goto Done;
}
}

for (PcIoApicIndex = 0; PcIoApicIndex < PcdGet8(PcdPcIoApicCount); PcIoApicIndex++) {
- PcIoApicMask = (1 << PcIoApicIndex);
- if ((PcIoApicEnable & PcIoApicMask) == 0) {
- continue;
- }
+ PcIoApicMask = (1 << PcIoApicIndex);
+ if ((PcIoApicEnable & PcIoApicMask) == 0) {
+ continue;
+ }

- IoApicStruct.IoApicId = (UINT8)(PcdGet8(PcdPcIoApicIdBase) + PcIoApicIndex);
- IoApicStruct.IoApicAddress = CurrentIoApicAddress;
- CurrentIoApicAddress = (CurrentIoApicAddress & 0xFFFF8000) + 0x8000;
- IoApicStruct.GlobalSystemInterruptBase = (UINT32)(24 + (PcIoApicIndex * 8));
- ASSERT (MadtStructsIndex < MaxMadtStructCount);
- Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &IoApicStruct,
- &MadtStructs[MadtStructsIndex++]
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n", Status));
- goto Done;
- }
+ IoApicStruct.IoApicId = (UINT8)(PcdGet8(PcdPcIoApicIdBase) + PcIoApicIndex);
+ IoApicStruct.IoApicAddress = CurrentIoApicAddress;
+ CurrentIoApicAddress = (CurrentIoApicAddress & 0xFFFF8000) + 0x8000;
+ IoApicStruct.GlobalSystemInterruptBase = (UINT32)(24 + (PcIoApicIndex * 8));
+ ASSERT (MadtStructsIndex < MaxMadtStructCount);
+ Status = CopyStructure (
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &IoApicStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n", Status));
+ goto Done;
+ }
}

//
@@ -1021,12 +895,12 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &IntSrcOverrideStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &IntSrcOverrideStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (IRQ2 source override) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (IRQ2 source override) failed: %r\n", Status));
goto Done;
}

@@ -1040,12 +914,12 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &IntSrcOverrideStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &IntSrcOverrideStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (IRQ9 source override) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (IRQ9 source override) failed: %r\n", Status));
goto Done;
}

@@ -1060,12 +934,12 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &LocalApciNmiStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &LocalApciNmiStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n", Status));
goto Done;
}

@@ -1084,10 +958,10 @@ InstallMadtFromScratch (

ASSERT (MadtStructsIndex < MaxMadtStructCount);
Status = CopyStructure (
- &MadtTableHeader.Header,
- (STRUCTURE_HEADER *) &LocalX2ApicNmiStruct,
- &MadtStructs[MadtStructsIndex++]
- );
+ &MadtTableHeader.Header,
+ (STRUCTURE_HEADER *) &LocalX2ApicNmiStruct,
+ &MadtStructs[MadtStructsIndex++]
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "CopyMadtStructure (x2APIC NMI) failed: %r\n", Status));
goto Done;
@@ -1098,14 +972,14 @@ InstallMadtFromScratch (
// Build Madt Structure from the Madt Header and collection of pointers in MadtStructs[]
//
Status = BuildAcpiTable (
- (EFI_ACPI_DESCRIPTION_HEADER *) &MadtTableHeader,
- sizeof (EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER),
- MadtStructs,
- MadtStructsIndex,
- (UINT8 **)&NewMadtTable
- );
+ (EFI_ACPI_DESCRIPTION_HEADER *) &MadtTableHeader,
+ sizeof (EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER),
+ MadtStructs,
+ MadtStructsIndex,
+ (UINT8 **) &NewMadtTable
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "BuildAcpiTable failed: %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "BuildAcpiTable failed: %r\n", Status));
goto Done;
}

@@ -1113,11 +987,11 @@ InstallMadtFromScratch (
// Publish Madt Structure to ACPI
//
Status = mAcpiTable->InstallAcpiTable (
- mAcpiTable,
- NewMadtTable,
- NewMadtTable->Header.Length,
- &TableHandle
- );
+ mAcpiTable,
+ NewMadtTable,
+ NewMadtTable->Header.Length,
+ &TableHandle
+ );

Done:
//
@@ -1136,6 +1010,10 @@ Done:
FreePool (NewMadtTable);
}

+ if (mCpuApicIdOrderTable != NULL) {
+ FreePool (mCpuApicIdOrderTable);
+ }
+
return Status;
}

@@ -1155,8 +1033,8 @@ InstallMcfgFromScratch (
PciSegmentInfo = GetPciSegmentInfo (&SegmentCount);

McfgTable = AllocateZeroPool (
- sizeof(EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER) +
- sizeof(EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE) * SegmentCount
+ sizeof (EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER) +
+ sizeof (EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE) * SegmentCount
);
if (McfgTable == NULL) {
DEBUG ((DEBUG_ERROR, "Could not allocate MCFG structure\n"));
@@ -1164,11 +1042,11 @@ InstallMcfgFromScratch (
}

Status = InitializeHeader (
- &McfgTable->Header,
- EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
- EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION,
- 0
- );
+ &McfgTable->Header,
+ EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
+ EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION,
+ 0
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1192,11 +1070,11 @@ InstallMcfgFromScratch (
// Publish Madt Structure to ACPI
//
Status = mAcpiTable->InstallAcpiTable (
- mAcpiTable,
- McfgTable,
- McfgTable->Header.Length,
- &TableHandle
- );
+ mAcpiTable,
+ McfgTable,
+ McfgTable->Header.Length,
+ &TableHandle
+ );

return Status;
}
@@ -1280,7 +1158,7 @@ PlatformUpdateTables (
switch (Table->Signature) {

case EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE:
- ASSERT(FALSE);
+ ASSERT (FALSE);
break;

case EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE:
@@ -1324,9 +1202,9 @@ PlatformUpdateTables (
FadtHeader->XGpe1Blk.AccessSize = 0;
}

- DEBUG(( EFI_D_ERROR, "ACPI FADT table @ address 0x%x\n", Table ));
- DEBUG(( EFI_D_ERROR, " IaPcBootArch 0x%x\n", FadtHeader->IaPcBootArch ));
- DEBUG(( EFI_D_ERROR, " Flags 0x%x\n", FadtHeader->Flags ));
+ DEBUG ((DEBUG_INFO, "ACPI FADT table @ address 0x%x\n", Table));
+ DEBUG ((DEBUG_INFO, " IaPcBootArch 0x%x\n", FadtHeader->IaPcBootArch));
+ DEBUG ((DEBUG_INFO, " Flags 0x%x\n", FadtHeader->Flags));
break;

case EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE:
@@ -1346,12 +1224,12 @@ PlatformUpdateTables (
HpetBlockId.Bits.VendorId = HpetCapabilities.Bits.VendorId;
HpetTable->EventTimerBlockId = HpetBlockId.Uint32;
HpetTable->MainCounterMinimumClockTickInPeriodicMode = (UINT16)HpetCapabilities.Bits.CounterClockPeriod;
- DEBUG(( EFI_D_ERROR, "ACPI HPET table @ address 0x%x\n", Table ));
- DEBUG(( EFI_D_ERROR, " HPET base 0x%x\n", PcdGet32 (PcdHpetBaseAddress) ));
+ DEBUG ((DEBUG_INFO, "ACPI HPET table @ address 0x%x\n", Table));
+ DEBUG ((DEBUG_INFO, " HPET base 0x%x\n", PcdGet32 (PcdHpetBaseAddress)));
break;

case EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE:
- ASSERT(FALSE);
+ ASSERT (FALSE);
break;

default:
@@ -1403,8 +1281,8 @@ IsHardwareChange (
// pFADT->XDsdt
//
HWChangeSize = HandleCount + 1;
- HWChange = AllocateZeroPool( sizeof(UINT32) * HWChangeSize );
- ASSERT( HWChange != NULL );
+ HWChange = AllocateZeroPool (sizeof(UINT32) * HWChangeSize);
+ ASSERT(HWChange != NULL);

if (HWChange == NULL) return;

@@ -1445,14 +1323,14 @@ IsHardwareChange (
// Calculate CRC value with HWChange data.
//
Status = gBS->CalculateCrc32(HWChange, HWChangeSize, &CRC);
- DEBUG((DEBUG_INFO, "CRC = %x and Status = %r\n", CRC, Status));
+ DEBUG ((DEBUG_INFO, "CRC = %x and Status = %r\n", CRC, Status));

//
// Set HardwareSignature value based on CRC value.
//
FacsPtr = (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)pFADT->FirmwareCtrl;
FacsPtr->HardwareSignature = CRC;
- FreePool( HWChange );
+ FreePool (HWChange);
}

VOID
@@ -1475,17 +1353,16 @@ UpdateLocalTable (

if (Version != EFI_ACPI_TABLE_VERSION_NONE) {
Status = mAcpiTable->InstallAcpiTable (
- mAcpiTable,
- CurrentTable,
- CurrentTable->Length,
- &TableHandle
- );
+ mAcpiTable,
+ CurrentTable,
+ CurrentTable->Length,
+ &TableHandle
+ );
ASSERT_EFI_ERROR (Status);
}
}
}

-
VOID
EFIAPI
AcpiEndOfDxeEvent (
@@ -1493,16 +1370,14 @@ AcpiEndOfDxeEvent (
VOID *ParentImageHandle
)
{
-
if (Event != NULL) {
- gBS->CloseEvent(Event);
+ gBS->CloseEvent (Event);
}

-
//
// Calculate Hardware Signature value based on current platform configurations
//
- IsHardwareChange();
+ IsHardwareChange ();
}

/**
@@ -1526,7 +1401,6 @@ InstallAcpiPlatform (
EFI_STATUS Status;
EFI_EVENT EndOfDxeEvent;

-
Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&mMpService);
ASSERT_EFI_ERROR (Status);

@@ -1550,19 +1424,19 @@ InstallAcpiPlatform (
// Determine the number of processors
//
mMpService->GetNumberOfProcessors (
- mMpService,
- &mNumberOfCPUs,
- &mNumberOfEnabledCPUs
- );
- ASSERT (mNumberOfCPUs <= MAX_CPU_NUM && mNumberOfEnabledCPUs >= 1);
- DEBUG ((DEBUG_INFO, "mNumberOfCPUs - %d\n", mNumberOfCPUs));
+ mMpService,
+ &mNumberOfCpus,
+ &mNumberOfEnabledCPUs
+ );
+
+ DEBUG ((DEBUG_INFO, "mNumberOfCpus - %d\n", mNumberOfCpus));
DEBUG ((DEBUG_INFO, "mNumberOfEnabledCPUs - %d\n", mNumberOfEnabledCPUs));

DEBUG ((DEBUG_INFO, "mX2ApicEnabled - 0x%x\n", mX2ApicEnabled));
DEBUG ((DEBUG_INFO, "mForceX2ApicId - 0x%x\n", mForceX2ApicId));

// support up to 64 threads/socket
- AsmCpuidEx(CPUID_EXTENDED_TOPOLOGY, 1, &mNumOfBitShift, NULL, NULL, NULL);
+ AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 1, &mNumOfBitShift, NULL, NULL, NULL);
mNumOfBitShift &= 0x1F;
DEBUG ((DEBUG_INFO, "mNumOfBitShift - 0x%x\n", mNumOfBitShift));

--
2.32.0.windows.2


[PATCH edk2-platform v2 0/1] Hisilicon:Fix header file issues

wenyi,xie
 

Main Changes since v1:
1.change the name of header file.

Wenyi Xie (1):
Hisilicon:Fix header file issues

Silicon/Hisilicon/HisiPkg.dec | 2 +-
Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.h | 2 +-
Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClass.h | 2 +-
Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.h | 15 +--------------
Silicon/Hisilicon/Hi1616/Pptt/Pptt.h | 2 +-
Silicon/Hisilicon/Hi1620/Pptt/Pptt.h | 2 +-
Silicon/Hisilicon/Include/Library/{OemMiscLib.h => OemHisiMiscLib.h} | 0
Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c | 2 +-
Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.c | 2 +-
Platform/Hisilicon/D03/Library/OemMiscLib2P/BoardFeature2PHi1610.c | 2 +-
Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c | 2 +-
Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c | 2 +-
Platform/Hisilicon/D05/Library/OemMiscLibD05/BoardFeatureD05.c | 2 +-
Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c | 2 +-
Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c | 2 +-
Platform/Hisilicon/D06/Library/OemMiscLibD06/BoardFeatureD06.c | 2 +-
Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c | 2 +-
Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c | 2 +-
Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c | 2 +-
Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/Type09/MiscSystemSlotDesignationFunction.c | 2 +-
Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c | 2 +-
Silicon/Hisilicon/Hi1610/Library/Hi161xPciPlatformLib/Hi161xPciPlatformLib.c | 2 +-
22 files changed, 21 insertions(+), 34 deletions(-)
rename Silicon/Hisilicon/Include/Library/{OemMiscLib.h => OemHisiMiscLib.h} (100%)

--
2.20.1.windows.1


[PATCH edk2-platform v2 1/1] Hisilicon:Fix header file issues

wenyi,xie
 

EDK2 has removed header file ArmLibPrivate.h, so need to
use ArmLib.h instead. A new file OemMiscLib.h is added
to EDK2, its name is same with the header file in
Hisilicon\Include and it will being included first. So
changing the name of header file from OemMiscLib.h to
OemHisiMiscLib.h.

Cc: Leif Lindholm <leif@...>
Cc: Ard Biesheuvel <ard.biesheuvel@...>
Signed-off-by: Wenyi Xie <xiewenyi2@...>
---
Silicon/Hisilicon/HisiPkg.dec | 2 +-
Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.h | 2 +-
Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClass.h | 2 +-
Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.h | 15 +--------------
Silicon/Hisilicon/Hi1616/Pptt/Pptt.h | 2 +-
Silicon/Hisilicon/Hi1620/Pptt/Pptt.h | 2 +-
Silicon/Hisilicon/Include/Library/{OemMiscLib.h => OemHisiMiscLib.h} | 0
Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c | 2 +-
Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.c | 2 +-
Platform/Hisilicon/D03/Library/OemMiscLib2P/BoardFeature2PHi1610.c | 2 +-
Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c | 2 +-
Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c | 2 +-
Platform/Hisilicon/D05/Library/OemMiscLibD05/BoardFeatureD05.c | 2 +-
Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c | 2 +-
Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c | 2 +-
Platform/Hisilicon/D06/Library/OemMiscLibD06/BoardFeatureD06.c | 2 +-
Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c | 2 +-
Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c | 2 +-
Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c | 2 +-
Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/Type09/MiscSystemSlotDesignationFunction.c | 2 +-
Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c | 2 +-
Silicon/Hisilicon/Hi1610/Library/Hi161xPciPlatformLib/Hi161xPciPlatformLib.c | 2 +-
22 files changed, 21 insertions(+), 34 deletions(-)

diff --git a/Silicon/Hisilicon/HisiPkg.dec b/Silicon/Hisilicon/HisiPkg.dec
index 051b5b8c3d88..e7ae01ffc750 100644
--- a/Silicon/Hisilicon/HisiPkg.dec
+++ b/Silicon/Hisilicon/HisiPkg.dec
@@ -49,7 +49,7 @@ [LibraryClasses]
PlatformSysCtrlLib|Include/Library/PlatformSysCtrlLib.h
CpldIoLib|Include/Library/CpldIoLib.h
OemAddressMapLib|Include/Library/OemAddressMapLib.h
- OemMiscLib|Include/Library/OemMiscLib.h
+ OemMiscLib|Include/Library/OemHisiMiscLib.h
I2CLib|Include/Library/I2CLib.h
PlatformPciLib|Include/Library/PlatformPciLib.h
FdtUpdateLib|Include/Library/FdtUpdateLib.h
diff --git a/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.h b/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.h
index 7194ae589042..7f50c8ff317d 100644
--- a/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.h
+++ b/Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.h
@@ -25,6 +25,6 @@
#include <Library/PrintLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>

#endif
diff --git a/Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClass.h b/Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClass.h
index 22c7f6797168..d28f7095ef37 100644
--- a/Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClass.h
+++ b/Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClass.h
@@ -30,7 +30,7 @@
#include <Guid/DebugMask.h>
#include <Guid/MemoryMapData.h>
#include <Library/PlatformSysCtrlLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>

//
// This is the generated header file which includes whatever needs to be exported (strings + IFR)
diff --git a/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.h b/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.h
index 3ce180d21df3..14a1b44d8db4 100644
--- a/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.h
+++ b/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.h
@@ -25,7 +25,7 @@
#include <Library/PcdLib.h>
#include <PlatformArch.h>
#include <Library/PlatformSysCtrlLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/ArmLib.h>

//
@@ -68,19 +68,6 @@ typedef union {
UINT16 Data;
}CACHE_CONFIGURATION;

-//
-// Processor Status
-//
-typedef union {
- struct {
- UINT8 CpuStatus :3; // Indicates the status of the processor.
- UINT8 Reserved1 :3; // Reserved for future use. Should be set to zero.
- UINT8 SocketPopulated :1; // Indicates if the processor socket is populated or not.
- UINT8 Reserved2 :1; // Reserved for future use. Should be set to zero.
- } Bits;
- UINT8 Data;
-}PROCESSOR_STATUS_DATA;
-
//
// Processor Characteristics
//
diff --git a/Silicon/Hisilicon/Hi1616/Pptt/Pptt.h b/Silicon/Hisilicon/Hi1616/Pptt/Pptt.h
index a0ad31a990db..0cb9a6e31e65 100644
--- a/Silicon/Hisilicon/Hi1616/Pptt/Pptt.h
+++ b/Silicon/Hisilicon/Hi1616/Pptt/Pptt.h
@@ -13,7 +13,7 @@
#define _PPTT_H_

#include <IndustryStandard/Acpi.h>
-#include <Library/ArmLib/ArmLibPrivate.h>
+#include <Library/ArmLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
diff --git a/Silicon/Hisilicon/Hi1620/Pptt/Pptt.h b/Silicon/Hisilicon/Hi1620/Pptt/Pptt.h
index 30ba5fff65ce..7d8228503dba 100644
--- a/Silicon/Hisilicon/Hi1620/Pptt/Pptt.h
+++ b/Silicon/Hisilicon/Hi1620/Pptt/Pptt.h
@@ -14,7 +14,7 @@

#include <PlatformArch.h>
#include <IndustryStandard/Acpi.h>
-#include <Library/ArmLib/ArmLibPrivate.h>
+#include <Library/ArmLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
diff --git a/Silicon/Hisilicon/Include/Library/OemMiscLib.h b/Silicon/Hisilicon/Include/Library/OemHisiMiscLib.h
similarity index 100%
rename from Silicon/Hisilicon/Include/Library/OemMiscLib.h
rename to Silicon/Hisilicon/Include/Library/OemHisiMiscLib.h
diff --git a/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c b/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c
index 75b6dec34b30..88b5e3e57e66 100644
--- a/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c
+++ b/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c
@@ -18,7 +18,7 @@
#include <PlatformArch.h>
#include <Library/PlatformSysCtrlLib.h>

-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/OemAddressMapLib.h>
#include <Library/ArmLib.h>

diff --git a/Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.c b/Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.c
index a242e4bd9af5..d52782e84dbe 100755
--- a/Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.c
+++ b/Platform/Hisilicon/D03/Library/FdtUpdateLib/FdtUpdateLib.c
@@ -21,7 +21,7 @@
#include <Library/MemoryAllocationLib.h>
#include <Protocol/HisiBoardNicProtocol.h>
#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>

typedef union AA_DAW
{
diff --git a/Platform/Hisilicon/D03/Library/OemMiscLib2P/BoardFeature2PHi1610.c b/Platform/Hisilicon/D03/Library/OemMiscLib2P/BoardFeature2PHi1610.c
index 1670cac1d491..a88afe4fe884 100644
--- a/Platform/Hisilicon/D03/Library/OemMiscLib2P/BoardFeature2PHi1610.c
+++ b/Platform/Hisilicon/D03/Library/OemMiscLib2P/BoardFeature2PHi1610.c
@@ -14,7 +14,7 @@
#include <IndustryStandard/SmBios.h>

#include <PlatformArch.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/I2CLib.h>
#include <Library/HiiLib.h>

diff --git a/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c b/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c
index 1d9c3dfd491b..22d04c5c72d4 100644
--- a/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c
+++ b/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c
@@ -14,7 +14,7 @@
#include <Library/IoLib.h>
#include <Library/TimerLib.h>
#include <Library/SerialPortLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <PlatformArch.h>
#include <Library/PlatformSysCtrlLib.h>
#include <Library/OemAddressMapLib.h>
diff --git a/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c b/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c
index 05aefc90f789..1af3df9ea4d9 100644
--- a/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c
+++ b/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c
@@ -16,7 +16,7 @@
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/OemAddressMapLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/PcdLib.h>
#include <Library/PlatformSysCtrlLib.h>

diff --git a/Platform/Hisilicon/D05/Library/OemMiscLibD05/BoardFeatureD05.c b/Platform/Hisilicon/D05/Library/OemMiscLibD05/BoardFeatureD05.c
index ac013ca30890..323a420e2d7f 100644
--- a/Platform/Hisilicon/D05/Library/OemMiscLibD05/BoardFeatureD05.c
+++ b/Platform/Hisilicon/D05/Library/OemMiscLibD05/BoardFeatureD05.c
@@ -15,7 +15,7 @@
#include <Library/HiiLib.h>
#include <Library/I2CLib.h>
#include <Library/IoLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Protocol/Smbios.h>


diff --git a/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c b/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c
index 2ee15dbc7b43..151f3f779aef 100644
--- a/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c
+++ b/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c
@@ -15,7 +15,7 @@
#include <Library/IoLib.h>
#include <Library/LpcLib.h>
#include <Library/OemAddressMapLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/PcdLib.h>
#include <Library/PlatformPciLib.h>
#include <Library/PlatformSysCtrlLib.h>
diff --git a/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c b/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c
index 72f30ff07550..6e10765b5952 100644
--- a/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c
+++ b/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c
@@ -14,7 +14,7 @@
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/OemAddressMapLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/PcdLib.h>
#include <Library/PlatformSysCtrlLib.h>
#include <PiPei.h>
diff --git a/Platform/Hisilicon/D06/Library/OemMiscLibD06/BoardFeatureD06.c b/Platform/Hisilicon/D06/Library/OemMiscLibD06/BoardFeatureD06.c
index 980eabfe3355..284a58669f43 100644
--- a/Platform/Hisilicon/D06/Library/OemMiscLibD06/BoardFeatureD06.c
+++ b/Platform/Hisilicon/D06/Library/OemMiscLibD06/BoardFeatureD06.c
@@ -14,7 +14,7 @@
#include <Library/HiiLib.h>
#include <Library/I2CLib.h>
#include <Library/IoLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Protocol/Smbios.h>

#include <PlatformArch.h>
diff --git a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
index 1b0a2180c179..bc781ccedc48 100644
--- a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
+++ b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
@@ -15,7 +15,7 @@
#include <Library/IoLib.h>
#include <Library/LpcLib.h>
#include <Library/OemAddressMapLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/PcdLib.h>
#include <Library/PlatformSysCtrlLib.h>
#include <Library/SerialPortLib.h>
diff --git a/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 1be7de5ccf44..463281e0f9fa 100644
--- a/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -13,7 +13,7 @@
#include <Library/DevicePathLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/PcdLib.h>
#include <Library/PciHostBridgeLib.h>
#include <Library/PlatformPciLib.h>
diff --git a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c
index 39f7f6b1a333..98bce6e7a234 100644
--- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c
+++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c
@@ -11,7 +11,7 @@
#include <Library/HobLib.h>
#include <Library/HwMemInitLib.h>
#include <Library/OemConfigData.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiLib.h>
diff --git a/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/Type09/MiscSystemSlotDesignationFunction.c b/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/Type09/MiscSystemSlotDesignationFunction.c
index 929288519780..976382183939 100644
--- a/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/Type09/MiscSystemSlotDesignationFunction.c
+++ b/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/Type09/MiscSystemSlotDesignationFunction.c
@@ -11,7 +11,7 @@

#include "SmbiosMisc.h"

-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>

extern SMBIOS_TABLE_TYPE9 MiscSystemSlotDesignationPcie0Data;
extern SMBIOS_TABLE_TYPE9 MiscSystemSlotDesignationPcie1Data;
diff --git a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c
index 954655d47087..d02f6e982cc6 100644
--- a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c
+++ b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c
@@ -10,7 +10,7 @@
#include "PcieInit.h"
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/PlatformPciLib.h>


diff --git a/Silicon/Hisilicon/Hi1610/Library/Hi161xPciPlatformLib/Hi161xPciPlatformLib.c b/Silicon/Hisilicon/Hi1610/Library/Hi161xPciPlatformLib/Hi161xPciPlatformLib.c
index 4fb092009a25..cacf5db22cea 100644
--- a/Silicon/Hisilicon/Hi1610/Library/Hi161xPciPlatformLib/Hi161xPciPlatformLib.c
+++ b/Silicon/Hisilicon/Hi1610/Library/Hi161xPciPlatformLib/Hi161xPciPlatformLib.c
@@ -11,7 +11,7 @@
#include <IndustryStandard/Acpi.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
-#include <Library/OemMiscLib.h>
+#include <Library/OemHisiMiscLib.h>
#include <Library/PcdLib.h>
#include <Library/PciExpressLib.h>
#include <Library/PlatformPciLib.h>
--
2.20.1.windows.1


Re: [PATCH v6 0/6] SEV Live Migration support for OVMF.

Yao, Jiewen
 

Hi
I have some questions:

1) May I know what is the usage of this UEFI variable - SevLiveMigrationEnabled?
I only see it is created, but I do not see how it is consumed.

2) Is this a full live migration patch, or is this just a startup and there will be more on the way?

Thank you
Yao Jiewen

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ashish Kalra
via groups.io
Sent: Monday, August 2, 2021 8:31 PM
To: devel@edk2.groups.io
Cc: dovmurik@...; brijesh.singh@...; tobin@...;
Thomas.Lendacky@...; jejb@...; Justen, Jordan L
<jordan.l.justen@...>; ard.biesheuvel@...;
erdemaktas@...; Yao, Jiewen <jiewen.yao@...>; Xu, Min M
<min.m.xu@...>
Subject: [edk2-devel] [PATCH v6 0/6] SEV Live Migration support for OVMF.

From: Ashish Kalra <ashish.kalra@...>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3467

By default all the SEV guest memory regions are considered encrypted,
if a guest changes the encryption attribute of the page (e.g mark a
page as decrypted) then notify hypervisor. Hypervisor will need to
track the unencrypted pages. The information will be used during
guest live migration, guest page migration and guest debugging.

The patch-set detects if it is running under KVM hypervisor and then
checks for SEV live migration feature support via KVM_FEATURE_CPUID,
if detected setup a new UEFI enviroment variable to indicate OVMF
support for SEV live migration.

A branch containing these patches is available here:
https://github.com/ashkalra/edk2-1/tree/sev_live_migration_v5_10

Changes since v5:
- Split first patch into three components, one patch for the
MemEncryptSevLiveMigrationIsEnabled() API, one patch for the
SetMemoryEncDecHypercall3() API, one patch to make use of the
SetMemoryEncDecHypercall3() API.
- Fix patch subject, in code and patch comments and
additionally add relevant comments.
- Replace SetMemoryEncDecHypercall3() API's Status argument
with a boolean IsEncrypted argument and corresponding fixes
to users of this API call.
- Fix AsciiStrCmp() usage in KVM hypervisor detection code.

Changes since v4:
- Remove MemEncryptHypercallLib Library and add support to issue
hypercall in the BaseMemEncryptSevLib library itself.
- For SEV-ES, make the VC handler hypercall aware by comparing
the hypercall number and add the additional register values
in the GHCB.
- Fix comments in the hypercall API interface.
- The encryption bit is set/clear on the smallest page size, hence
use the 4k page size in MAP_GPA_RANGE hypercall.
- Make the hypercall expect the guest physical address to be
page-aligned.
- Add KVM live migration feature flag check in BaseMemEncryptSevLib
library similar to how BaseMemEncryptSevLib does for the
MemEncryptSevIsEnabled() and check it before invoking HC. Also
export the MemEncryptSevLiveMigrationIsEnabled() function as
part of the library.
- Add error handling on hypercall return, on failure, return error
code to caller which potentially will cause an assert() and
terminate the boot.

Changes since v3:
- Fix all DSC files under OvmfPkg except X64 to add support for
BaseMemEncryptLib and add NULL instance of BaseMemEncryptLib
for 32 bit platforms.
- Add the MemEncryptHypercallLib-related files to Maintainers.txt,
in section "OvmfPkg: Confidential Computing".
- Add support for the new KVM_HC_MAP_GPA_RANGE hypercall interface.
- Add patch for SEV live migration support.

Changes since v2:
- GHCB_BASE setup during reset-vector as decrypted is marked explicitly
in the hypervisor page encryption bitmap after setting the
PcdSevEsIsEnabled PCD.

Changes since v1:
- Mark GHCB_BASE setup during reset-vector as decrypted explicitly in
the hypervisor page encryption bitmap.
- Resending the series with correct shallow threading.

Ashish Kalra (6):
OvmfPkg/BaseMemEncryptLib: Detect SEV live migration feature.
OvmfPkg/BaseMemEncryptLib: Hypercall API for page encryption state
change
OvmfPkg/BaseMemEncryptLib: Invoke page encryption state change
hypercall
OvmfPkg/VmgExitLib: Encryption state change hypercall support in VC
handler
OvmfPkg/PlatformPei: Mark SEC GHCB page as unencrypted via hypercall
OvmfPkg/AmdSevDxe: Add support for SEV live migration.

OvmfPkg/AmdSevDxe/AmdSevDxe.c | 64 +++++++++++++++++
OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 4 ++
OvmfPkg/Include/Guid/AmdSevMemEncryptLib.h | 20 ++++++
OvmfPkg/Include/Library/MemEncryptSevLib.h | 70 +++++++++++++++++++
.../DxeMemEncryptSevLib.inf | 1 +
.../DxeMemEncryptSevLibInternal.c | 39 +++++++++++
.../Ia32/MemEncryptSevLib.c | 27 +++++++
.../PeiDxeMemEncryptSevLibInternal.c | 52 ++++++++++++++
.../PeiMemEncryptSevLib.inf | 1 +
.../PeiMemEncryptSevLibInternal.c | 39 +++++++++++
.../SecMemEncryptSevLibInternal.c | 38 ++++++++++
.../X64/AsmHelperStub.nasm | 33 +++++++++
.../X64/MemEncryptSevLib.c | 62 ++++++++++++++++
.../X64/PeiDxeVirtualMemory.c | 20 ++++++
OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 13 ++++
OvmfPkg/OvmfPkg.dec | 1 +
OvmfPkg/PlatformPei/AmdSev.c | 11 +++
17 files changed, 495 insertions(+)
create mode 100644 OvmfPkg/Include/Guid/AmdSevMemEncryptLib.h
create mode 100644
OvmfPkg/Library/BaseMemEncryptSevLib/X64/AsmHelperStub.nasm

--
2.17.1





回复: [edk2-devel] [PATCH v7 1/3] BaseTools: Remove COMMON section from the GCC discard list

gaoliming
 

Ard:
Chris explains this change in https://edk2.groups.io/g/devel/message/77662. And, he also verifies the patch in OVMF with GCC5 tool chain.

Thanks
Liming

-----邮件原件-----
发件人: Ard Biesheuvel <ardb@...>
发送时间: 2021年8月4日 20:27
收件人: Yao, Jiewen <jiewen.yao@...>
抄送: devel@edk2.groups.io; christopher.zurcher@...; Feng, Bob C
<bob.c.feng@...>; Liming Gao <gaoliming@...>
主题: Re: [edk2-devel] [PATCH v7 1/3] BaseTools: Remove COMMON section
from the GCC discard list

On Wed, 21 Jul 2021 at 13:44, Yao, Jiewen <jiewen.yao@...> wrote:

Acked-by: Jiewen Yao <Jiewen.yao@...>
I don't think this is a good idea tbh. We have already identified that
EDK2 code often fails to use the STATIC keyword when possible for
global variables, and that unrelated variables that happen to have the
same name will be collapsed into the same storage unit in the program
image. (see commit 214a3b79417f64bf2faae74af42c1b9d23f50dc8 for
details)

Was this considered? Is this no longer an issue?



-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
Christopher
Zurcher
Sent: Wednesday, July 21, 2021 6:07 AM
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb@...>; Feng, Bob C
<bob.c.feng@...>;
Liming Gao <gaoliming@...>
Subject: [edk2-devel] [PATCH v7 1/3] BaseTools: Remove COMMON
section
from the GCC discard list

From: Christopher Zurcher <christopher.zurcher@...>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2507

The COMMON section is used by OpenSSL assembly-optimized crypto
functions. OpenSSL assembly code is auto-generated from the submodule
and cannot be modified to remove dependence on the COMMON section.
The default -fno-common compiler flag should still prevent variable from
being emitted into the COMMON section.

Cc: Ard Biesheuvel <ardb@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Signed-off-by: Christopher Zurcher <christopher.zurcher@...>
---
BaseTools/Scripts/GccBase.lds | 1 -
1 file changed, 1 deletion(-)

diff --git a/BaseTools/Scripts/GccBase.lds
b/BaseTools/Scripts/GccBase.lds
index a9dd2138d4..83cebd29d5 100644
--- a/BaseTools/Scripts/GccBase.lds
+++ b/BaseTools/Scripts/GccBase.lds
@@ -74,6 +74,5 @@ SECTIONS {
*(.dynamic)
*(.hash .gnu.hash)
*(.comment)
- *(COMMON)
}
}
--
2.32.0.windows.1





Re: "StdLibPkg" branch on edk2-staging

Kilian Kegel
 

Hi all,

 

I plan to come back with the https://github.com/tianocore/edk2-staging/tree/CdePkg end of this year

and to unroll the source code of fundamental parts of my C Library and discuss that along

the 30. anniversary of “The C Book” https://publications.gbdirect.co.uk/c_book/chapter9

 

Additionally I will discuss the details you need to know:

  1. about the differences C90/C95/C99 in language and library
  2. how to get HOSTED ENVIRONMENT for UEFI POST drivers
  3. how to get Intel/AMD TimeStampCounter based precise time calibration - platform,

processor  and chipset independent for x86 UEFI platforms

  1. how to arrange space optimization for UEFI FW as an embedded platform
  2. how to test and verify the compatibility of a Standard C Library implementation,

since “CI“ won’t help at all in this regards

  1. how to implement a printf-core that performs narrow and wide mode at once for space optimization
  2. how to implement a scanf-core that performs narrow and wide mode at once for space optimization
  3. how to implement realloc() sub-allocator on UEFI memory management functions for PEI and DXE

 

Note: If UEFI is going to provide Standard-C-Functions for all drivers, you will have soon e.g. “sprintf()”

in all drivers. The amount of code for a proper sprintf() + scanf() + wscanf() + strtok() + wcstok() + malloc() … implementation

that is not tailored for embedded FW, will overrun the BIOS FLASH space instantly.

I consider commercial BIOS implementations that runs really many drivers (> 100) to start a platform.

 

Currently I implement more feature to CdePkg/Torito C Library:

  1. Improve UEFI driver cross development for VisualStudio and EDK2
  2. substitution of “DEBUG” traces by CdePkg-traces

that allows usage of predefined DEBUG-messages to run in a CdePkg-based driver.

 

Sole purpose is to have DEBUG/RELEASE mode _NOT_ globally, but locally to get

trace messages selectively for specific drivers only.

(to speed up POST with traces, that consumes a significant amount of time during

working hours of a BIOS developer)

 

  1. add SMM support.

Shell, DXE, PEI (pre and post memory) is already available for 2 years:

https://edk2.groups.io/g/devel/message/51562?p=,,,20,0,0,0::Created,,CdePkg,20,2,0,65191785

 

  1. get ACPICA tools https://acpica.org/ to UEFI Shell

 

I need to implement some non-standard / Microsoft specific C functions

to get that running for Andrew Fish.

 

That time links from https://github.com/KilianKegel are under construction and are

not necessarily  up-to-date.

Same for https://github.com/tianocore/edk2-staging/tree/CdePkg that is not used for long …

 

But https://github.com/KilianKegel/CdePkg.git driver set and sample set runs instantly

on the latest BIOS of a commercial vendor on a Intel IOTG TGL-H (Tiger Lake H) board using the Microsoft

build environment.

 

@Tim: I’d really appreciate if CdePkg could hold additionally Insyde BIOS support. Regrettably

I do not have access to Insyde source code.

 

@Maciej

I can not see any “wide” functions here. https://github.com/DevSolar/pdclib

from WCHAR.H or WCTYPE.H. That is a serious limitation in the UEFI environment.

 

To create UEFI-Shell programs for Personal Computers this link can be used.

https://github.com/KilianKegel/Visual-ANSI-C-for-UEFI-Shell#visual-ansi-c-for-uefi-shell

 

Best regards,

Kilian

 

From: Andrew Fish via groups.io
Sent: Thursday, August 5, 2021 05:35 AM
To: edk2-devel-groups-io; Leif Lindholm
Cc: Rebecca Cran; tim.lewis@...; maciej.rabeda@...; Mike Kinney
Subject: Re: [edk2-devel] "StdLibPkg" branch on edk2-staging

 

I’d guess I’d also ask the why not NewLib? Especially since Red Hat helps out with edk2….

Thanks,

Andrew Fish

> On Aug 4, 2021, at 4:03 AM, Leif Lindholm <leif@...> wrote:
>
> Hi Rebecca,
>
> I think the truth is we're a bit resigned about edk2-libc in general.
> My view is it should be either maintained or deprecated (or replaced).
>
> And maintainership *should* mean at least keeping it up to date with
> security fixes.
>
> I personally have no enthusiasm for the topic, but if there existed:
> - An up-to-date codebase.
> - A plan for keeping the coodbase up-to-date (as opposed to a plan to
>  keep the codebase up-to-date).
> - At least a couple of maintainers.
> I would have no objection to that existing under the TianoCore
> umbrella.
>
> Best Regards,
>
> Leif
>
> On Wed, Jul 28, 2021 at 16:44:02 -0600, Rebecca Cran wrote:
>> CC'ing the Tianocore stewards.
>>
>>
>> I've had problems getting a recent patch committed just to make edk2-libc
>> work against current edk2 master.
>>
>> Tianocore stewards: do we need new or additional maintainers for edk2-libc,
>> or is there a plan to deprecate it?
>>
>>
>> The current maintainers are listed as:
>>
>> StdLib, StdLibPrivateInternalFiles
>> W: https://github.com/tianocore/tianocore.github.io/wiki/StdLib
>> M: Daryl McDaniel <edk2-lists@...>
>> M: Jaben Carsey <jaben.carsey@...>
>>
>>
>> --
>> Rebecca Cran
>>
>>
>> On 7/28/21 4:25 PM, tim.lewis@... wrote:
>>> I would point out that there was significant work on libc in the
>> past (see https://github.com/andreiw/UefiToolsPkg) but never any
>> help to upstream these fixes, including making sure that many Linux
>> tools can easily be ported. I myself have used it to port several
>> BSD utilities over, but each time there will little nits with the
>> existing port and even small patches were returned with "no current
>> maintainer"
>>>
>>> In terms of making other projects use libc, I think the other
>>> objection was that it was never optimized for non-shell
>>> usage. Other projects (lie
>>> https://github.com/tianocore/edk2-staging/tree/CdePkg ) have tried
>>> to remedy this, but never with source checked in. But it allows
>>> support under PEI, DXE, etc.
>>>
>>> Tim
>>>
>>> -----Original Message-----
>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
>>> Sent: Wednesday, July 28, 2021 8:34 AM
>>> To: devel@edk2.groups.io; maciej.rabeda@...
>>> Subject: Re: [edk2-devel] "StdLibPkg" branch on edk2-staging
>>>
>>> Are you aware of the edk2-libc project at https://github.com/tianocore/edk2-libc ?
>>>
>>>
>
>
>
>
>





 


Re: [edk2-platforms] [PATCH V1] PurleyOpenBoardPkg : Add ReadMe document for LinuxBoot

Nate DeSimone
 

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of manickavasakam karpagavinayagam
Sent: Wednesday, August 4, 2021 5:00 PM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Desimone, Nathaniel L <nathaniel.l.desimone@...>; Felixp@...; DOPPALAPUDI, HARIKRISHNA <harikrishnad@...>; Jha, Manish <manishj@...>; Bobroff, Zachary <zacharyb@...>; KARPAGAVINAYAGAM, MANICKAVASAKAM <manickavasakamk@...>
Subject: [edk2-devel] [edk2-platforms] [PATCH V1] PurleyOpenBoardPkg : Add ReadMe document for LinuxBoot

linux.efi/initrd.cpio.xz are dummy files.
These dummy files needs to be replaced by building the Linux Kernel.

1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
2. Copy the following built files
(1) initrd.cpio.xz to LinuxBoot/LinuxBinaries/initrd.cpio.xz
(2) bzimage to LinuxBoot/LinuxBinaries/linux.efi

Signed-off-by: Manickavasakam Karpagavinayagam <manickavasakamk@...>
---
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/Readme.md | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/Readme.md b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/Readme.md
new file mode 100644
index 0000000000..47e53fcb70
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/Readme.md
@@ -0,0 +1,9 @@
+
+linux.efi/initrd.cpio.xz are dummy files.
+These dummy files needs to be replaced by building the Linux Kernel.
+
+1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
+2. Copy the following built files
+(1) initrd.cpio.xz to LinuxBoot/LinuxBinaries/initrd.cpio.xz
+(2) bzimage to LinuxBoot/LinuxBinaries/linux.efi
+
--
2.25.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


Re: [edk2-platforms] [PATCH V1] PurleyOpenBoardPkg : Add ReadMe document for LinuxBoot

Nate DeSimone
 

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of manickavasakam karpagavinayagam
Sent: Wednesday, August 4, 2021 5:00 PM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Desimone, Nathaniel L <nathaniel.l.desimone@...>; Felixp@...; DOPPALAPUDI, HARIKRISHNA <harikrishnad@...>; Jha, Manish <manishj@...>; Bobroff, Zachary <zacharyb@...>; KARPAGAVINAYAGAM, MANICKAVASAKAM <manickavasakamk@...>
Subject: [edk2-devel] [edk2-platforms] [PATCH V1] PurleyOpenBoardPkg : Add ReadMe document for LinuxBoot

linux.efi/initrd.cpio.xz are dummy files.
These dummy files needs to be replaced by building the Linux Kernel.

1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
2. Copy the following built files
(1) initrd.cpio.xz to LinuxBoot/LinuxBinaries/initrd.cpio.xz
(2) bzimage to LinuxBoot/LinuxBinaries/linux.efi

Signed-off-by: Manickavasakam Karpagavinayagam <manickavasakamk@...>
---
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/Readme.md | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/Readme.md b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/Readme.md
new file mode 100644
index 0000000000..47e53fcb70
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/Readme.md
@@ -0,0 +1,9 @@
+
+linux.efi/initrd.cpio.xz are dummy files.
+These dummy files needs to be replaced by building the Linux Kernel.
+
+1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
+2. Copy the following built files
+(1) initrd.cpio.xz to LinuxBoot/LinuxBinaries/initrd.cpio.xz
+(2) bzimage to LinuxBoot/LinuxBinaries/linux.efi
+
--
2.25.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


Re: [edk2-platforms][PATCH] IpmiFeaturePkg: IPMI Transport PPI and Protocol for BIOS/BMC communication

Nate DeSimone
 

-----Original Message-----
From: manickavasakam karpagavinayagam <manickavasakamk@...>
Sent: Thursday, June 10, 2021 4:44 PM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Desimone, Nathaniel L <nathaniel.l.desimone@...>; Felixp@...; DOPPALAPUDI, HARIKRISHNA <harikrishnad@...>; Jha, Manish <manishj@...>; Bobroff, Zachary <zacharyb@...>; KARPAGAVINAYAGAM, MANICKAVASAKAM <manickavasakamk@...>
Subject: [edk2-platforms][PATCH] IpmiFeaturePkg: IPMI Transport PPI and Protocol for BIOS/BMC communication

Enable IPMI Transport PPI and Protocol for BIOS/BMC communication Add PlatformIpmiIoRangeSet() to enable OEM specific southbridge SIO KCS I/O address range
---
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c | 7 ++++++-
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf | 2 ++
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf | 5 +++--
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemory.fdf | 3 ++-
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf | 3 +++
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf | 3 +++
6 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
index 31f613925d..14040c089c 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/
+++ PeiGenericIpmi.c
@@ -9,7 +9,7 @@
#include <IndustryStandard/Ipmi.h> #include "PeiGenericIpmi.h" #include <Library/ReportStatusCodeLib.h>-+#include <Library/IpmiPlatformHookLib.h> /////////////////////////////////////////////////////////////////////////////// // Function Implementations@@ -48,6 +48,11 @@ PeiInitializeIpmiKcsPhysicalLayer (
// Enable OEM specific southbridge SIO KCS I/O address range 0xCA0 to 0xCAF at here // if the the I/O address range has not been enabled. //+ Status = PlatformIpmiIoRangeSet (PcdGet16 (PcdIpmiIoBaseAddress));+ DEBUG ((DEBUG_INFO, "IPMI Peim:PlatformIpmiIoRangeSet - %r!\n", Status));+ if (EFI_ERROR(Status)) {+ return Status;+ } mIpmiInstance = AllocateZeroPool (sizeof (PEI_IPMI_BMC_INSTANCE_DATA)); if (mIpmiInstance == NULL) {diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
index 0ef2c18116..883a9168e5 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/
+++ PeiGenericIpmi.inf
@@ -41,7 +41,9 @@
MemoryAllocationLib DebugLib IoLib+ ReportStatusCodeLib TimerLib+ IpmiPlatformHookLib [Guids] diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf
index b5b37ddd9f..cbd9453cf0 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemo
+++ ry.fdf
@@ -7,10 +7,11 @@
# ## - INF OutOfBandManagement/IpmiFeaturePkg/BmcAcpi/BmcAcpi.inf+ INF OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf+ INF OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf+ INF RuleOverride = DRIVER_ACPITABLE OutOfBandManagement/IpmiFeaturePkg/BmcAcpi/BmcAcpi.inf INF OutOfBandManagement/IpmiFeaturePkg/BmcElog/BmcElog.inf INF OutOfBandManagement/IpmiFeaturePkg/Frb/FrbDxe.inf INF OutOfBandManagement/IpmiFeaturePkg/IpmiFru/IpmiFru.inf- INF OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf INF OutOfBandManagement/IpmiFeaturePkg/OsWdt/OsWdt.inf INF OutOfBandManagement/IpmiFeaturePkg/SolStatus/SolStatus.infdiff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemory.fdf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemory.fdf
index 4aa2d8e9da..826490952b 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemory.fdf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemor
+++ y.fdf
@@ -7,5 +7,6 @@
# ## -INF OutOfBandManagement/IpmiFeaturePkg/Frb/FrbPei.inf+INF OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf INF OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf+INF OutOfBandManagement/IpmiFeaturePkg/Frb/FrbPei.infdiff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
index b429d3b7b9..86df943560 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBase
+++ Lib/IpmiBaseLib.inf
@@ -26,3 +26,6 @@
[Protocols] gIpmiTransportProtocolGuid++[Depex]+ gIpmiTransportProtocolGuiddiff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
index f89614adfb..9a2c87873f 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiB
+++ aseLib/PeiIpmiBaseLib.inf
@@ -28,3 +28,6 @@
[Ppis] gPeiIpmiTransportPpiGuid++[Depex]+ gPeiIpmiTransportPpiGuid--
2.25.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


Re: [edk2-platforms][PATCH] IpmiFeaturePkg: IPMI Transport PPI and Protocol for BIOS/BMC communication

Nate DeSimone
 

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>

-----Original Message-----
From: manickavasakam karpagavinayagam <manickavasakamk@...>
Sent: Thursday, June 10, 2021 4:44 PM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Desimone, Nathaniel L <nathaniel.l.desimone@...>; Felixp@...; DOPPALAPUDI, HARIKRISHNA <harikrishnad@...>; Jha, Manish <manishj@...>; Bobroff, Zachary <zacharyb@...>; KARPAGAVINAYAGAM, MANICKAVASAKAM <manickavasakamk@...>
Subject: [edk2-platforms][PATCH] IpmiFeaturePkg: IPMI Transport PPI and Protocol for BIOS/BMC communication

Enable IPMI Transport PPI and Protocol for BIOS/BMC communication Add PlatformIpmiIoRangeSet() to enable OEM specific southbridge SIO KCS I/O address range
---
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c | 7 ++++++-
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf | 2 ++
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf | 5 +++--
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemory.fdf | 3 ++-
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf | 3 +++
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf | 3 +++
6 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
index 31f613925d..14040c089c 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.c
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/
+++ PeiGenericIpmi.c
@@ -9,7 +9,7 @@
#include <IndustryStandard/Ipmi.h> #include "PeiGenericIpmi.h" #include <Library/ReportStatusCodeLib.h>-+#include <Library/IpmiPlatformHookLib.h> /////////////////////////////////////////////////////////////////////////////// // Function Implementations@@ -48,6 +48,11 @@ PeiInitializeIpmiKcsPhysicalLayer (
// Enable OEM specific southbridge SIO KCS I/O address range 0xCA0 to 0xCAF at here // if the the I/O address range has not been enabled. //+ Status = PlatformIpmiIoRangeSet (PcdGet16 (PcdIpmiIoBaseAddress));+ DEBUG ((DEBUG_INFO, "IPMI Peim:PlatformIpmiIoRangeSet - %r!\n", Status));+ if (EFI_ERROR(Status)) {+ return Status;+ } mIpmiInstance = AllocateZeroPool (sizeof (PEI_IPMI_BMC_INSTANCE_DATA)); if (mIpmiInstance == NULL) {diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
index 0ef2c18116..883a9168e5 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/
+++ PeiGenericIpmi.inf
@@ -41,7 +41,9 @@
MemoryAllocationLib DebugLib IoLib+ ReportStatusCodeLib TimerLib+ IpmiPlatformHookLib [Guids] diff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf
index b5b37ddd9f..cbd9453cf0 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemory.fdf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PostMemo
+++ ry.fdf
@@ -7,10 +7,11 @@
# ## - INF OutOfBandManagement/IpmiFeaturePkg/BmcAcpi/BmcAcpi.inf+ INF OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Dxe/GenericIpmi.inf+ INF OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf+ INF RuleOverride = DRIVER_ACPITABLE OutOfBandManagement/IpmiFeaturePkg/BmcAcpi/BmcAcpi.inf INF OutOfBandManagement/IpmiFeaturePkg/BmcElog/BmcElog.inf INF OutOfBandManagement/IpmiFeaturePkg/Frb/FrbDxe.inf INF OutOfBandManagement/IpmiFeaturePkg/IpmiFru/IpmiFru.inf- INF OutOfBandManagement/IpmiFeaturePkg/IpmiInit/DxeIpmiInit.inf INF OutOfBandManagement/IpmiFeaturePkg/OsWdt/OsWdt.inf INF OutOfBandManagement/IpmiFeaturePkg/SolStatus/SolStatus.infdiff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemory.fdf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemory.fdf
index 4aa2d8e9da..826490952b 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemory.fdf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Include/PreMemor
+++ y.fdf
@@ -7,5 +7,6 @@
# ## -INF OutOfBandManagement/IpmiFeaturePkg/Frb/FrbPei.inf+INF OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/Pei/PeiGenericIpmi.inf INF OutOfBandManagement/IpmiFeaturePkg/IpmiInit/PeiIpmiInit.inf+INF OutOfBandManagement/IpmiFeaturePkg/Frb/FrbPei.infdiff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
index b429d3b7b9..86df943560 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBaseLib/IpmiBaseLib.inf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/IpmiBase
+++ Lib/IpmiBaseLib.inf
@@ -26,3 +26,6 @@
[Protocols] gIpmiTransportProtocolGuid++[Depex]+ gIpmiTransportProtocolGuiddiff --git a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
index f89614adfb..9a2c87873f 100644
--- a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiBaseLib/PeiIpmiBaseLib.inf
+++ b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/Library/PeiIpmiB
+++ aseLib/PeiIpmiBaseLib.inf
@@ -28,3 +28,6 @@
[Ppis] gPeiIpmiTransportPpiGuid++[Depex]+ gPeiIpmiTransportPpiGuid--
2.25.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


Re: "StdLibPkg" branch on edk2-staging

Andrew Fish
 

I’d guess I’d also ask the why not NewLib? Especially since Red Hat helps out with edk2….

Thanks,

Andrew Fish

On Aug 4, 2021, at 4:03 AM, Leif Lindholm <leif@...> wrote:

Hi Rebecca,

I think the truth is we're a bit resigned about edk2-libc in general.
My view is it should be either maintained or deprecated (or replaced).

And maintainership *should* mean at least keeping it up to date with
security fixes.

I personally have no enthusiasm for the topic, but if there existed:
- An up-to-date codebase.
- A plan for keeping the coodbase up-to-date (as opposed to a plan to
keep the codebase up-to-date).
- At least a couple of maintainers.
I would have no objection to that existing under the TianoCore
umbrella.

Best Regards,

Leif

On Wed, Jul 28, 2021 at 16:44:02 -0600, Rebecca Cran wrote:
CC'ing the Tianocore stewards.


I've had problems getting a recent patch committed just to make edk2-libc
work against current edk2 master.

Tianocore stewards: do we need new or additional maintainers for edk2-libc,
or is there a plan to deprecate it?


The current maintainers are listed as:

StdLib, StdLibPrivateInternalFiles
W: https://github.com/tianocore/tianocore.github.io/wiki/StdLib
M: Daryl McDaniel <edk2-lists@...>
M: Jaben Carsey <jaben.carsey@...>


--
Rebecca Cran


On 7/28/21 4:25 PM, tim.lewis@... wrote:
I would point out that there was significant work on libc in the
past (see https://github.com/andreiw/UefiToolsPkg) but never any
help to upstream these fixes, including making sure that many Linux
tools can easily be ported. I myself have used it to port several
BSD utilities over, but each time there will little nits with the
existing port and even small patches were returned with "no current
maintainer"

In terms of making other projects use libc, I think the other
objection was that it was never optimized for non-shell
usage. Other projects (lie
https://github.com/tianocore/edk2-staging/tree/CdePkg ) have tried
to remedy this, but never with source checked in. But it allows
support under PEI, DXE, etc.

Tim

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
Sent: Wednesday, July 28, 2021 8:34 AM
To: devel@edk2.groups.io; maciej.rabeda@...
Subject: Re: [edk2-devel] "StdLibPkg" branch on edk2-staging

Are you aware of the edk2-libc project at https://github.com/tianocore/edk2-libc ?





Re: [EXTERNAL] RE: [edk2-platforms][PATCH V2] PurleyOpenBoardPkg : Support for LINUX Boot

Nate DeSimone
 

-----Original Message-----
From: Manickavasakam Karpagavinayagam <manickavasakamk@...>
Sent: Thursday, July 29, 2021 5:35 AM
To: Desimone, Nathaniel L <nathaniel.l.desimone@...>; devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Felix Polyudov <Felixp@...>; DOPPALAPUDI, HARIKRISHNA <harikrishnad@...>; Jha, Manish <manishj@...>; Bobroff, Zachary <zacharyb@...>
Subject: RE: [EXTERNAL] RE: [edk2-platforms][PATCH V2] PurleyOpenBoardPkg : Support for LINUX Boot

Nate :

If you see in this patch, linux.efi/initrd.cpio.xz are dummy files. These dummy files needs to be replaced by building the Linux Kernel.

How to build Linux Kernel is mentioned in the ReadMe document which is part of this patch.

1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
2. Copy the following built files
(1) initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
(2) bzimage to LinuxBootPkg/LinuxBinaries/linux.efi

Thank you

-Manic

-----Original Message-----
From: Desimone, Nathaniel L <nathaniel.l.desimone@...>
Sent: Thursday, July 29, 2021 3:17 AM
To: Manickavasakam Karpagavinayagam <manickavasakamk@...>; devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Felix Polyudov <Felixp@...>; Harikrishna Doppalapudi <Harikrishnad@...>; Manish Jha <manishj@...>; Zachary Bobroff <zacharyb@...>; Manickavasakam Karpagavinayagam <manickavasakamk@...>
Subject: [EXTERNAL] RE: [edk2-platforms][PATCH V2] PurleyOpenBoardPkg : Support for LINUX Boot


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Manic,

Unfortunately this patch cannot be merged as is. It appears to contain a pre-built binary of the Linux kernel that has been pre-configured for Linuxboot use. While this is very convenient, the Linux kernel is licensed under the GPL and hence we cannot add it to edk2-platforms, which must be kept as BSD only. It might be possible to add this to edk2-non-osi, but even then we would require that you provide a readme file that explains how to get and compile the source code that you used to build this exact Linux image, as required by the GPL.

The easiest and safest option would be to remove the Linux binary all together and provide instructions to the user for how to build their own image and add it to the tree.

Thanks,
Nate

-----Original Message-----
From: manickavasakam karpagavinayagam <manickavasakamk@...>
Sent: Wednesday, June 30, 2021 2:57 PM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Desimone, Nathaniel L
<nathaniel.l.desimone@...>; Felixp@...; DOPPALAPUDI,
HARIKRISHNA <harikrishnad@...>; Jha, Manish <manishj@...>;
Bobroff, Zachary <zacharyb@...>; KARPAGAVINAYAGAM, MANICKAVASAKAM
<manickavasakamk@...>
Subject: [edk2-platforms][PATCH V2] PurleyOpenBoardPkg : Support for
LINUX Boot

Support for LINUX Boot
To enable/disable feature, PcdLinuxBootEnable can be used
1. Follow directions on https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fosresearch.net%2FBuilding%2F&;data=04%7C01%7Cmanickavasakamk%40ami.com%7C3a64470864e64ee9f28d08d95260d55c%7C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C637631398142258756%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=ylzkAVWRzAtPBLq%2FFLqn1i4Y%2Fa0o%2FjR%2B7GpsfWI6OCk%3D&amp;reserved=0 to compile the
heads kernel and initrd for qemu-system_x86_64
2. Copy the following built files
(1) initrd.cpio.xz to
PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/initrd.cpio.xz
(2) bzimage to
PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/linux.efi

Notes:
V2 :
- Rename LinuxBootPkg to LinuxBoot
- Move LinuxBootPkg to PurleyOpenBoardPkg/Features/LinuxBoot
- Follow Coding Standard in LinuxBoot.C and LinuxBoot.h

Signed-off-by: manickavasakam karpagavinayagam
<manickavasakamk@...>
---
.../BoardTiogaPass/CoreDxeInclude.dsc | 5 +-
.../BoardTiogaPass/CoreUefiBootInclude.fdf | 5 +-
.../BoardTiogaPass/OpenBoardPkg.dsc | 7 +
.../BoardTiogaPass/OpenBoardPkg.fdf | 57 ++-
.../BoardTiogaPass/PlatformPkgConfig.dsc | 7 +
.../LinuxBoot/LinuxBinaries/LinuxKernel.inf | 17 +
.../LinuxBoot/LinuxBinaries/initrd.cpio.xz | Bin 0 -> 16 bytes
.../LinuxBoot/LinuxBinaries/linux.efi | Bin 0 -> 16 bytes
.../Features/LinuxBoot/LinuxBoot.c | 412 ++++++++++++++++++
.../Features/LinuxBoot/LinuxBoot.h | 185 ++++++++
.../Features/LinuxBoot/LinuxBoot.inf | 40 ++
.../Features/LinuxBoot/LinuxBootNull.c | 36 ++
.../Features/LinuxBoot/LinuxBootNull.inf | 25 ++
.../Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec | 2 +
.../DxePlatformBootManagerLib/BdsPlatform.c | 9 +
.../DxePlatformBootManagerLib.inf | 2 +
Platform/Intel/Readme.md | 42 ++
17 files changed, 843 insertions(+), 8 deletions(-) create mode
100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/Lin
u
xKernel.inf
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/ini
tr
d.cpio.xz
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/lin
u
x.efi
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.c
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.h
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.inf
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.c
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.inf

diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
index b0660d72dd..a17015704b 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.ds
+++ c
@@ -83,6 +83,7 @@

$(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBus
Dxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -97,10 +98,11 @@
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf

MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
-
+!endif

#MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputD
xe.inf

MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
xe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -124,6 +126,7 @@
<LibraryClasses>
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
}
+!endif

!if gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly == FALSE
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclud
e.fdf
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclud
e.fdf
index 141ce5dda3..6cd8ba6626 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclud
e.fdf
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclu
+++ de.fdf
@@ -47,6 +47,7 @@ INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
INF
$(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBus
Dxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -62,10 +63,12 @@ INF
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
INF
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
INF FatPkg/EnhancedFatDxe/Fat.inf
+!endif

#INF
MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDx
e.inf
INF
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
xe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -79,4 +82,4 @@ INF
MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf

INF MdeModulePkg/Application/UiApp/UiApp.inf
INF
MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuAp
p.inf
-
+!endif
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
index e4c8e7fbf1..67472a1182 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
@@ -104,6 +104,13 @@

##########################################################
######################

[LibraryClasses.common]
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/Features/LinuxBoot/LinuxB
oot.inf
+ LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
+!else
+
+LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/Features/LinuxBoot/LinuxB
ootNull
+.inf
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == FALSE

PlatformBootManagerLib|$(PLATFORM_PACKAGE)/Bds/Library/DxePlatfor
mBootManagerLib/DxePlatformBootManagerLib.inf
!else
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
index 43cd8d94e1..1623c44cd8 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
@@ -19,6 +19,38 @@
# Also all values will have a PCD assigned so that they can be used in the
system, and
# the FlashMap edit tool can be used to change the values here, without
effecting the code.
# This requires all code to only use the PCD tokens to recover the values.
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset =
0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize =
0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset =
0x00300000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset =
0x00400000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset =
0x00500000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset =
0x00600000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize =
0x00600000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset =
0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
= 0x0007C000 #
+
+!else
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset =
0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize =
0x00500000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset =
0x00500000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset =
0x00600000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset =
0x00700000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize =
0x00200000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset =
0x00900000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize =
0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset =
0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
= 0x0007C000 #
+
+!endif
+

[FD.Platform]
BaseAddress = 0xFF000000 |
gEfiPchTokenSpaceGuid.PcdFlashAreaBaseAddress
@@ -27,27 +59,27 @@ ErasePolarity = 1
BlockSize = 0x10000
NumBlocks = 0x100

-0x00000000|0x00500000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset|gMinPlatfor
mPkgT
+okenSpaceGuid.PcdFlashFvAdvancedSize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase|gMinPlatformP
kgTokenSpaceGuid.PcdFlashFvAdvancedSize
FV = FvAdvanced

-0x00500000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset|gMinPlatform
PkgT
+okenSpaceGuid.PcdFlashFvSecuritySize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase|gMinPlatformPk
gTokenSpaceGuid.PcdFlashFvSecuritySize
FV = FvSecurity

-0x00600000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset|gMinPlatform
PkgTok
+enSpaceGuid.PcdFlashFvOsBootSize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase|gMinPlatformPkg
TokenSpaceGuid.PcdFlashFvOsBootSize
FV = FvOsBoot

-0x00700000|0x00200000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset|gMinPlatformPk
gToken
+SpaceGuid.PcdFlashFvFspUSize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUBase|gMinPlatformPkgTo
kenSpaceGuid.PcdFlashFvFspUSize
FV = FvLateSiliconCompressed

-0x00900000|0x00300000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset|gMinPlatfor
mPkgT
+okenSpaceGuid.PcdFlashFvUefiBootSize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase|gMinPlatformPk
gTokenSpaceGuid.PcdFlashFvUefiBootSize
FV = FvUefiBoot

-0x00C00000|0x0007C000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset|gEfiM
deMo
+dulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|gEfiM
deModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
#NV_VARIABLE_STORE
DATA = {
@@ -303,6 +335,19 @@ FILE DRIVER = db90bb7e-e4ba-4f07-96d6-
b7076713bd2c {

INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+FILE DRIVER = 81339b04-fa8c-4be0-9ca7-916fc5319eb5 {
+ SECTION DXE_DEPEX_EXP = {FALSE}
+ SECTION PE32 =
+$(PLATFORM_BOARD_PACKAGE)/Features/LinuxBoot/LinuxBinaries/linux.
efi
+}
+
+FILE FREEFORM = 16b60e5d-f1c5-42f0-9b34-08C81C430473 {
+ SECTION RAW =
+$(PLATFORM_BOARD_PACKAGE)/Features/LinuxBoot/LinuxBinaries/initrd.
cpio.
+xz
+}
+
+!endif
+

[FV.FvUefiBoot]
FvAlignment = 16
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.d
sc
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.
dsc
index 36a29c8d68..ff27252233 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.d
sc
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig
+++ .dsc
@@ -51,7 +51,14 @@

gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable|TRUE

+ gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE
+
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+ gPlatformTokenSpaceGuid.PcdFastBoot|TRUE
+!else
gPlatformTokenSpaceGuid.PcdFastBoot|FALSE
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == TRUE
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable|FALSE
gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|FALSE
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/L
i
nuxKernel.inf
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/L
i
nuxKernel.inf
new file mode 100644
index 0000000000..0e197ecb68
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries
+++ /LinuxKernel.inf
@@ -0,0 +1,17 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC.<BR> # #
+SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[Defines]
+ INF_VERSION = 1.27
+ BASE_NAME = LinuxKernel
+ FILE_GUID = 81339b04-fa8c-4be0-9ca7-916fc5319eb5
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+
+[Binaries.common.AARCH64]
+ PE32|linux.efi|*
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/i
ni
trd.cpio.xz
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/i
n
itrd.cpio.xz
new file mode 100644
index
0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911
d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/l
in
ux.efi
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/l
i
nux.efi
new file mode 100644
index
0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911
d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.c
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.c
new file mode 100644
index 0000000000..682047cef0
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.c
@@ -0,0 +1,412 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h> #include
+<Library/UefiBootServicesTableLib.h>
+#include <Guid/DxeServices.h>
+#include <Library/DxeServicesTableLib.h> #include <Library/UefiLib.h>
+#include <Protocol/FirmwareVolume2.h> #include
<Protocol/LoadedImage.h>
+#include <Guid/MemoryTypeInformation.h> #include <Pi/PiDxeCis.h>
+#include <Pi/PiHob.h> #include <Library/PcdLib.h> #include
+<Library/DxeServicesLib.h> #include "LinuxBoot.h"
+
+//16b60e5d-f1c5-42f0-9b34-08C81C430473
+#define LINUX_BOOT_INITRD_GUID \
+ { \
+ 0x16b60e5d, 0xf1c5, 0x42f0, {0x9b, 0x34, 0x08, 0xc8, 0x1c, 0x43,
+0x04, 0x73} \
+ }
+
+#define LINUX_BOOT_KERNEL_GUID \
+ { \
+ 0x81339b04, 0xfa8c, 0x4be0, {0x9c, 0xa7, 0x91, 0x6f, 0xc5, 0x31,
+0x9e, 0xb5} \
+ }
+
+
+EFI_STATUS
+EFIAPI
+LoadLinuxCheckKernelSetup (
+ IN VOID *KernelSetup,
+ IN UINTN KernelSetupSize
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelSetupPages (
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxInitializeKernelSetup (
+ IN VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxSetCommandLine (
+ IN OUT VOID *KernelSetup,
+ IN CHAR8 *CommandLine
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinux (
+ IN VOID *Kernel,
+ IN OUT VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateInitrdPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_GUID gLinuxBootInitrdFileGuid = LINUX_BOOT_INITRD_GUID;
+
+EFI_GUID gLinuxBootKernelFileGuid = LINUX_BOOT_KERNEL_GUID;
+
+//-------------------------------------------------------------------
+--
+------
+
+/**
+ Dump some hexadecimal data to the screen.
+
+ @note Function taken from
+ ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c in EDKII
+
+ @param[in] Indent How many spaces to indent the output.
+ @param[in] Offset The offset of the printing.
+ @param[in] DataSize The size in bytes of UserData.
+ @param[in] UserData The data to print out.
+**/
+static
+VOID
+DumpHex (
+ IN UINTN Indent,
+ IN UINTN Offset,
+ IN UINTN DataSize,
+ IN VOID *UserData
+ )
+{
+ UINT8 *Data;
+ CHAR8 Val[50];
+ CHAR8 Str[20];
+ UINT8 TempByte;
+ UINTN Size;
+ UINTN Index;
+ CHAR8 Hex[] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
+ };
+
+ DEBUG((DEBUG_INFO, "%*a 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D
0E 0F\n", Indent, ""));
+ DEBUG((DEBUG_INFO, "%*a ------------------------------------------------
\n", Indent, ""));
+
+ Data = UserData;
+ while (DataSize != 0) {
+ Size = 16;
+ if (Size > DataSize) {
+ Size = DataSize;
+ }
+
+ for (Index = 0; Index < Size; Index += 1) {
+ TempByte = Data[Index];
+ Val[Index * 3 + 0] = Hex[TempByte >> 4];
+ Val[Index * 3 + 1] = Hex[TempByte & 0xF];
+ Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
+ Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' :
TempByte);
+ }
+
+ Val[Index * 3] = 0;
+ Str[Index] = 0;
+ DEBUG((DEBUG_INFO, "%*a%08X: %-48a %a\n", Indent, "", Offset,
+ Val, Str));
+
+ Data += Size;
+ Offset += Size;
+ DataSize -= Size;
+ }
+}
+
+
+/**
+ * This function completes a minimal amount of the necessary BDS
+functions to prepare
+ * for booting the kernel.
+ *
+ * @param None
+ *
+ * @retval EFI_SUCCESS Successfully completed remaining tasks
+ * @return EFI_ERROR Could not complete BDS tasks
+ */
+EFI_STATUS
+CompleteBdsTasks (
+ VOID
+)
+{
+
+ return EFI_SUCCESS;
+}
+
+/**
+ * This function will load and launch the Linux kernel from a BIOS FV.
+ *
+ * @note This function is not intended to return. Any exiting from this
function indicates
+ * a problem loading or launching the kernel.
+ *
+ * @param None
+ *
+ * @return EFI_ERROR Any error code
+ */
+EFI_STATUS
+LoadAndLaunchKernel (
+ VOID
+)
+{
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage = NULL;
+ EFI_STATUS Status;
+ EFI_HANDLE KernelHandle = NULL;
+ VOID *KernelBuffer = NULL;
+ VOID *KernelFfsBuffer = NULL;
+ UINTN KernelFfsSize = 0;
+ VOID *InitrdData = NULL;
+ VOID *InitrdBuffer = NULL;
+ UINTN InitrdSize = 0;
+ struct BootParams *BootParams = NULL;
+ struct BootParams *HandoverParams = NULL;
+ UINT32 StartOffset = 0;
+ UINT32 KernelLength = 0;
+ UINT8 *Temp;
+ UINT8 CmdLine[] = " ";
+
+ DEBUG((DEBUG_INFO, "LoadAndLaunchKernel Entry\n"));
+
+ ///
+ /// Kernel load and preparation
+ ///
+ DEBUG((DEBUG_INFO, "Preparing the kernel...\n"));
+
+ // Retrieve the kernel from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootKernelFileGuid,
+ EFI_SECTION_PE32,
+ 0,
+ &KernelFfsBuffer,
+ &KernelFfsSize
+ );
+
+ DEBUG((DEBUG_INFO, "Status %r\n",Status));
+ DEBUG((DEBUG_INFO, "KernelFfsBuffer %x\n",KernelFfsBuffer));
+ DEBUG((DEBUG_INFO, "KernelFfsSize %x\n",KernelFfsSize));
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve kernel; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded kernel to buffer at 0x%p with size
0x%X.\n", KernelFfsBuffer, KernelFfsSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n",
+ MIN(KernelFfsSize, 0x100)));
+
+ DumpHex(2, 0, MIN(0x100, KernelFfsSize), KernelFfsBuffer);
+
+ // Create a LoadImage protocol for the kernel
+ Status = gBS->LoadImage(TRUE, gImageHandle, NULL,
+ KernelFfsBuffer,
KernelFfsSize, &KernelHandle);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not create LoadImage for kernel
+ %r\n",
Status));
+ goto FatalError;
+ }
+
+ // Get the new LoadedImage protocol to retrieve information about
+ the
kernel
+ Status = gBS->HandleProtocol(KernelHandle,
&gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not get kernel LoadedImage
+ protocol;
%r\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Kernel LoadedImage information:\n"));
+ DEBUG((DEBUG_INFO, " ImageBase = 0x%p\n", LoadedImage-
ImageBase));
+ DEBUG((DEBUG_INFO, " ImageSize = 0x%p\n",
+ LoadedImage->ImageSize));
+
+ // Verify the kernel boot parameters from the LoadedImage and
+ allocate
an initalization buffer once verified
+ BootParams = (struct BootParams*) LoadedImage->ImageBase;
+
+ Status = LoadLinuxCheckKernelSetup((VOID *) BootParams,
+ sizeof(struct
BootParams));
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "LoadLinuxCheckKernelSetup failed;
+ %r.\n",
Status));
+ goto FatalError;
+ }
+
+ HandoverParams =
LoadLinuxAllocateKernelSetupPages(EFI_SIZE_TO_PAGES(KERNEL_SETUP_SI
ZE));
+ if (HandoverParams == NULL) {
+ DEBUG((DEBUG_ERROR, "Could not allocate memory for kernel
handover parameters.\n"));
+ goto FatalError;
+ }
+ DEBUG((DEBUG_INFO, "Handover parameters allocated at 0x%p\n",
+ HandoverParams));
+
+ gBS->CopyMem(&HandoverParams->Hdr, &BootParams->Hdr,
sizeof(struct
+ SetupHeader));
+
+ Status = LoadLinuxInitializeKernelSetup(HandoverParams);
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "Unable to initialize the handover
+ parameters;
%r.\n", Status));
+ goto FatalError;
+ }
+
+ // Allocate space for the kernel and copy it into the new buffer
+ KernelBuffer = LoadLinuxAllocateKernelPages(HandoverParams,
EFI_SIZE_TO_PAGES(HandoverParams->Hdr.InitSize));
+ if (KernelBuffer == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for kernel.\n"));
+ goto FatalError;
+ }
+
+ StartOffset = (HandoverParams->Hdr.SetupSecs + 1) * 512;
+ KernelLength = (UINT32) (KernelFfsSize - StartOffset);
+ Temp = (UINT8 *) LoadedImage->ImageBase;
+
+ DEBUG((DEBUG_INFO, "Kernel starts at offset 0x%X with length
+ 0x%X\n", StartOffset, KernelLength));
+
+ gBS->CopyMem(KernelBuffer, (Temp + StartOffset), KernelLength);
+ DEBUG((DEBUG_INFO, "First 0x%X bytes of new kernel buffer
+ contents:\n", MIN(0x100, KernelLength)));
+
+ DumpHex(2, 0, MIN(0x100, KernelLength), KernelBuffer);
+
+ // Prepare the command line
+ Status = LoadLinuxSetCommandLine(HandoverParams, (UINT8 *)
&CmdLine);
+ if (EFI_ERROR (Status)) {
+ DEBUG((EFI_D_INFO, "Unable to set linux command line; %r.\n",
Status));
+ goto FatalError;
+ }
+
+ HandoverParams->Hdr.Code32Start = (UINT32)(UINTN) KernelBuffer;
+ HandoverParams->Hdr.LoaderId = 0x21;
+
+ DEBUG((DEBUG_INFO, "Kernel loaded.\n"));
+
+ //
+ // Initrd load and preparation
+ //
+ DEBUG((DEBUG_INFO, "Preparing the initrd...\n"));
+
+ // Retrieve the initrd from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootInitrdFileGuid,
+ EFI_SECTION_RAW,
+ 0,
+ &InitrdBuffer,
+ &InitrdSize
+ );
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve initrd; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded initrd to buffer at 0x%p with size
0x%X.\n", InitrdBuffer, InitrdSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n", MIN(0x100,
InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdBuffer);
+
+ // Allocate the initrd for the kernel and copy it in
+ InitrdData = LoadLinuxAllocateInitrdPages(HandoverParams,
EFI_SIZE_TO_PAGES(InitrdSize));
+ if (InitrdData == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for initrd.\n"));
+ goto FatalError;
+ }
+
+ gBS->CopyMem(InitrdData, InitrdBuffer, InitrdSize);
+
+ HandoverParams->Hdr.RamDiskStart = (UINT32)(UINTN) InitrdData;
+ HandoverParams->Hdr.RamDiskLen = (UINT32) InitrdSize;
+
+ DEBUG((DEBUG_INFO, "Initrd loaded.\n"));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes of initrd
+ buffer:\n",
MIN(0x100, InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdData);
+
+ // General cleanup before launching the kernel
+ gBS->FreePool(InitrdBuffer);
+ InitrdBuffer = NULL;
+
+ gBS->UnloadImage(KernelHandle);
+ gBS->FreePool(KernelFfsBuffer);
+ KernelFfsBuffer = NULL;
+
+ DEBUG((DEBUG_ERROR, "Launching the kernel\n"));
+
+
+ //
+ // Signal the EFI_EVENT_GROUP_READY_TO_BOOT event.
+ //
+ EfiSignalEventReadyToBoot();
+
+
+ // Launch the kernel
+ Status = LoadLinux(KernelBuffer, HandoverParams);
+
+ ///
+ /// LoadLinux should never return if the kernel boots. Anything
+ past here
is an error scenario
+ ///
+ DEBUG((DEBUG_ERROR, "ERROR: LoadLinux has returned with status;
+ %r.\n", Status));
+
+FatalError:
+ // Free everything
+ if (InitrdData != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS)
InitrdData, EFI_SIZE_TO_PAGES(InitrdSize));
+ if (KernelBuffer != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS)
KernelBuffer, EFI_SIZE_TO_PAGES(HandoverParams->Hdr.InitSize));
+ if (HandoverParams != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS)
HandoverParams, EFI_SIZE_TO_PAGES(KERNEL_SETUP_SIZE));
+ if (InitrdBuffer != NULL) gBS->FreePool(InitrdBuffer);
+ if (KernelHandle != NULL) gBS->UnloadImage(KernelHandle);
+ if (KernelFfsBuffer != NULL) gBS->FreePool(KernelFfsBuffer);
+
+ return EFI_NOT_FOUND;
+}
+
+/**
+ * This is the main function for this feature. This will handle
+finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The
LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for
some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ // Finish BDS and then try to launch the kernel
+ //Status = CompleteBdsTasks();
+
+ if (!EFI_ERROR(Status)) {
+ LoadAndLaunchKernel();
+ }
+
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ DEBUG((DEBUG_ERROR, " ERROR: Kernel failed to launch.\n"));
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ return Status;
+}
+
+//-------------------------------------------------------------------
+--
+------
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.h
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.h
new file mode 100644
index 0000000000..ebbcd6bfd8
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.h
@@ -0,0 +1,185 @@
+/** @file
+Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#ifndef __LINUX_BOOT_PRIVATE__H__
+#define __LINUX_BOOT_PRIVATE__H__
+#ifdef __cplusplus
+extern "C" {
+#endif // #ifdef __cplusplus
+
+//-------------------------------------------------------------------
+--
+------
+
+//#include <Token.h>
+
+#define BOOTSIG 0x1FE
+#define SETUP_HDR 0x53726448 /* 0x53726448 == "HdrS" */
+
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3
+#define E820_NVS 4
+#define E820_UNUSABLE 5
+
+#pragma pack(1)
+
+struct SetupHeader {
+ UINT8 SetupSecs; // Sectors for setup code
+ UINT16 Rootflags;
+ UINT32 SysSize;
+ UINT16 RamSize;
+ UINT16 VideoMode;
+ UINT16 RootDev;
+ UINT16 Signature; // Boot signature
+ UINT16 Jump;
+ UINT32 Header;
+ UINT16 Version;
+ UINT16 SuSwitch;
+ UINT16 SetupSeg;
+ UINT16 StartSys;
+ UINT16 KernelVer;
+ UINT8 LoaderId;
+ UINT8 LoadFlags;
+ UINT16 MoveSize;
+ UINT32 Code32Start; // Start of code loaded high
+ UINT32 RamDiskStart; // Start of initial ramdisk
+ UINT32 RamDiskLen; // Length of initial ramdisk
+ UINT32 BootSectkludge;
+ UINT16 HeapEnd;
+ UINT8 ExtLoaderVer; // Extended boot loader version
+ UINT8 ExtLoaderType; // Extended boot loader ID
+ UINT32 CmdLinePtr; // 32-bit pointer to the kernel command line
+ UINT32 RamDiskMax; // Highest legal initrd address
+ UINT32 KernelAlignment; // Physical addr alignment required for
+kernel
+ UINT8 RelocatableKernel; // Whether kernel is relocatable or not
+ UINT8 MinAlignment;
+ UINT16 XloadFlags;
+ UINT32 CmdlineSize;
+ UINT32 HardwareSubarch;
+ UINT64 HardwareSubarchData;
+ UINT32 PayloadOffset;
+ UINT32 PayloadLength;
+ UINT64 SetupData;
+ UINT64 PrefAddress;
+ UINT32 InitSize;
+ UINT32 HandoverOffset;
+};
+
+struct EfiInfo {
+ UINT32 EfiLoaderSignature;
+ UINT32 EfiSystab;
+ UINT32 EfiMemdescSize;
+ UINT32 EfiMemdescVersion;
+ UINT32 EfiMemMap;
+ UINT32 EfiMemMapSize;
+ UINT32 EfiSystabHi;
+ UINT32 EfiMemMapHi;
+};
+
+struct E820Entry {
+ UINT64 Addr; // start of memory segment
+ UINT64 Size; // size of memory segment
+ UINT32 Type; // type of memory segment
+};
+
+struct ScreenInfo {
+ UINT8 OrigX; // 0x00
+ UINT8 OrigY; // 0x01
+ UINT16 ExtMemK; // 0x02
+ UINT16 OrigVideoPage; // 0x04
+ UINT8 OrigVideoMode; // 0x06
+ UINT8 OrigVideoCols; // 0x07
+ UINT8 Flags; // 0x08
+ UINT8 Unused2; // 0x09
+ UINT16 OrigVideoEgaBx;// 0x0a
+ UINT16 Unused3; // 0x0c
+ UINT8 OrigVideoLines; // 0x0e
+ UINT8 OrigVideoIsVGA; // 0x0f
+ UINT16 OrigVideoPoints;// 0x10
+
+ // VESA graphic mode -- linear frame buffer
+ UINT16 LfbWidth; // 0x12
+ UINT16 LfbHeight; // 0x14
+ UINT16 LfbDepth; // 0x16
+ UINT32 LfbBase; // 0x18
+ UINT32 LfbSize; // 0x1c
+ UINT16 ClMagic, ClOffset; // 0x20
+ UINT16 LfbLineLength; // 0x24
+ UINT8 RedSize; // 0x26
+ UINT8 RedPos; // 0x27
+ UINT8 GreenSize; // 0x28
+ UINT8 GreenPos; // 0x29
+ UINT8 BlueSize; // 0x2a
+ UINT8 BluePos; // 0x2b
+ UINT8 RsvdSize; // 0x2c
+ UINT8 RsvdPos; // 0x2d
+ UINT16 VesaPmSeg; // 0x2e
+ UINT16 VesaPmOff; // 0x30
+ UINT16 Pages; // 0x32
+ UINT16 VesaAttributes; // 0x34
+ UINT32 Capabilities; // 0x36
+ UINT8 Reserved[6]; // 0x3a
+};
+
+struct BootParams {
+ struct ScreenInfo ScreenInfo;
+ UINT8 ApmBiosInfo[0x14];
+ UINT8 Pad2[4];
+ UINT64 TbootAddr;
+ UINT8 IstInfo[0x10];
+ UINT8 Pad3[16];
+ UINT8 Hd0Info[16];
+ UINT8 Hd1Info[16];
+ UINT8 SysDescTable[0x10];
+ UINT8 OlpcOfwHeader[0x10];
+ UINT8 Pad4[128];
+ UINT8 EdidInfo[0x80];
+ struct EfiInfo EfiInfo;
+ UINT32 AltMemK;
+ UINT32 Scratch;
+ UINT8 E820Entries;
+ UINT8 EddBufEntries;
+ UINT8 EddMbrSigBufEntries;
+ UINT8 Pad6[6];
+ struct SetupHeader Hdr;
+ UINT8 Pad7[0x290-0x1f1-sizeof(struct SetupHeader)];
+ UINT32 EddMbrSigBuffer[16];
+ struct E820Entry E820Map[128];
+ UINT8 Pad8[48];
+ UINT8 EddBuf[0x1ec];
+ UINT8 Pad9[276];
+};
+#pragma pack ()
+
+//-------------------------------------------------------------------
+--
+------
+
+#ifndef MIN
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#endif // #ifndef MIN
+
+#define KERNEL_SETUP_SIZE 16384
+
+//-------------------------------------------------------------------
+--
+------
+
+///
+/// Function prototypes from Bds module /// VOID ConnectEverything();
+VOID RecoverTheMemoryAbove4Gb(); VOID
SignalAllDriversConnectedEvent();
+VOID SignalProtocolEvent(IN EFI_GUID *ProtocolGuid);
+
+#if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+VOID SignalExitPmAuthProtocolEvent(VOID);
+#endif // #if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+
+typedef VOID (BDS_CONTROL_FLOW_FUNCTION)();
+
+//-------------------------------------------------------------------
+--
+------
+
+/****** DO NOT WRITE BELOW THIS LINE *******/ #ifdef __cplusplus }
+#endif // #ifdef __cplusplus #endif // #ifndef
+__LINUX_BOOT_PRIVATE__H__
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.inf
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.inf
new file mode 100644
index 0000000000..5c09e5d317
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.inf
@@ -0,0 +1,40 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC.<BR> # #
+SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 74a41ddc-fac5-4787-afad-d81ee30a8b63 #
{0x74a41ddc, 0xfac5, 0x4787, {0xaf, 0xad, 0xd8, 0x1e, 0xe3, 0x0a,
0x8b, 0x63}}
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBoot.c
+ LinuxBoot.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
+ BaseMemoryLib
+ DebugLib
+ UefiRuntimeServicesTableLib
+ UefiBootServicesTableLib
+ UefiLib
+ LoadLinuxLib
+
+[Guids]
+
+[Protocols]
+ gEfiLoadedImageProtocolGuid
+
+[Pcd]
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.c
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.c
new file mode 100644
index 0000000000..2e5e44db6c
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull
+++ .c
@@ -0,0 +1,36 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+
+/**
+ * This is the main function for this feature. This will handle
+finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The
LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for
some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+
+ return EFI_SUCCESS;
+}
+
+
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.i
n
f
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.i
nf
new file mode 100644
index 0000000000..e292be9671
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull
+++ .inf
@@ -0,0 +1,25 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC.<BR> # #
+SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 0551B6D3-0594-4B02-AF42-5A9C7515CEC8
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBootNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
\ No newline at end of file
diff --git a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
index 4dcec5430b..0c1ab318b8 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
@@ -49,6 +49,8 @@

gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|TRUE|BOOLEAN|0x300
00035 +
gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE|BOOLEAN|0x300000
36+ [PcdsDynamicEx]
gPlatformTokenSpaceGuid.PcdDfxAdvDebugJumper|FALSE|BOOLEAN|0x60
00001D diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
index b3b8ceba6f..bd0509ab10 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
+++
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatf
+++ ormPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
@@ -2,6 +2,7 @@
This file include all platform action which can be customized by IBV/OEM.
Copyright (c) 2017, Intel Corporation. All rights
reserved.<BR>+Copyright (c) 2021, American Megatrends International LLC.<BR> SPDX-License-Identifier:
BSD-2-Clause-Patent **/@@ -31,6 +32,12 @@ BOOLEAN
gPPRequireUIConfirm;
extern UINTN mBootMenuOptionNumber;
+EFI_STATUS+LinuxBootStart (+ VOID+ );++
GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH
gUsbClassKeyboardDevicePath = { { {@@ -1268,6 +1275,8 @@
PlatformBootManagerAfterConsole (
LocalBootMode = gBootMode; DEBUG ((DEBUG_INFO, "Current local
bootmode - %x\n", LocalBootMode)); + LinuxBootStart();+ // // Go the
different platform policy with different boot mode // Notes: this part code
can be change with the table policydiff --git
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLi
b.inf
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLi
b.inf
index 5790743565..21ac65257c 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLi
b.inf
+++
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatf
+++
ormPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManage
rL
+++ ib.inf
@@ -2,6 +2,7 @@
# Component name for module DxePlatformBootManagerLib # # Copyright
(c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>+#
Copyright (c) 2021, American Megatrends International LLC.<BR> # #
SPDX-License-
Identifier: BSD-2-Clause-Patent #@@ -40,6 +41,7 @@
PerformanceLib TimerLib Tcg2PhysicalPresenceLib+ LinuxBootLib
[Packages] MdePkg/MdePkg.decdiff --git a/Platform/Intel/Readme.md
b/Platform/Intel/Readme.md
index 06c5f32b1e..a34784ccb8 100644
--- a/Platform/Intel/Readme.md
+++ b/Platform/Intel/Readme.md
@@ -87,6 +87,11 @@ A UEFI firmware implementation using MinPlatformPkg
is constructed using the fol

----------------------------------------|-----------------------------
---------------|------
------------------------|--------------------| | Mt. Olympus | Purley
| PurleyOpenBoardPkg | BoardMtOlympus | +| Machine Name
| Supported Chipsets | BoardPkg | Board Name |+-
---------------------------------------|--------------------------------------------|--------
----------------------|--------------------|+| TiogaPass | Purley
| PurleyOpenBoardPkg | BoardTiogaPass |++ #### Simics | Machine
Name | Supported Chipsets | BoardPkg |
Board Name |@@ -250,6 +255,12 @@ return back to the minimum
platform caller.
| | | | build settings, environment variables.
| | | |---build_board.py: Optional board-specific pre-build,
| | | build, post-build and clean functions.+ | |
|------PurleyOpenBoardPkg+ | | | |------BoardTiogaPass+ |
| | |---build_config.cfg: BoardTiogaPass specific+ | | |
| build settings, environment variables.+ | | | |---
build_board.py: Optional board-specific pre-build,+ | | |
build, post-build and clean functions. | | | | | |---
---SimicsOpenBoardPkg | | | |------BoardX58Ich10@@ -292,6
+303,18 @@ For PurleyOpenBoardPkg
"bld cache-consume" Consume a cache of binary files from the specified
directory, BINARY_CACHE_PATH is empty, used "BinCache" as default path.
+For PurleyOpenBoardPkg (TiogaPass)+1. Open command window, go to the
workspace directory, e.g. c:\Edk2Workspace.+2. Type "cd edk2-
platforms\Platform\Intel\PurleyOpenBoardPkg\BoardTiogaPass".+3. Type
"GitEdk2MinBoardTiogaPass.bat" to setup GIT environment.+4. Type "bld"
to build Purley BoardTiogaPass board UEFI firmware image, "bld release" for
release build, "bld clean" to+ remove intermediate files."bld cache-
produce" Generate a cache of binary files in the specified directory,+ "bld
cache-consume" Consume a cache of binary files from the specified
directory, BINARY_CACHE_PATH is empty,+ used "BinCache" as default
path. +5. Final BIOS image will be
Build\PurleyOpenBoardPkg\BoardTiagoPass\DEBUG_VS2015x86\FV\PLATFO
RM.fd or +
Build\PurleyOpenBoardPkg\BoardTiagoPass\RELEASE_VS2015x86\FV\PLATF
ORM.fd, depending on bld batch script input.+6. This BIOS image needs to be
merged with SPS FW + ### **Known limitations**
**KabylakeOpenBoardPkg**@@ -307,6 +330,25 @@ For PurleyOpenBoardPkg
2. This firmware project does not build with the GCC compiler. 3. The
validated version of iASL compiler that can build MinPurley is
20180629. Older versions may generate ACPI build errors.
+**PurleyOpenBoardPkg Tioga Pass **+1. This firmware project has only
been tested on the Tioga Pass hardware.+2. This firmware project build
has only been tested using the Microsoft Visual Studio 2015 build
tools.+3. This firmware project does not build with the GCC
compiler.+4. The validated version of iASL compiler that can build
MinPurley is 20180629. Older versions may generate ACPI build errors.+5. Installed and booted to UEFI Windows 2016 on M.2 NVME slot+6.
Installed and booted to UEFI Windows 2019 on M.2 NVME slot and with
SATA HDD.+7. Installed and booted to UEFI RHEL 7.3 on SATA HDD+8.
Installed and booted to Ubuntu 18.04 on M.2 NVME slot.+9. Verified
Mellanox card detection during POST and OS+10. LINUX Boot Support (PcdLinuxBootEnable
needs to be enabled)++1. Follow directions on
https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fosresearch.net%2FBuilding%2F&;data=04%7C01%7Cmanickavasakamk%40ami.com%7C3a64470864e64ee9f28d08d95260d55c%7C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C637631398142258756%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=ylzkAVWRzAtPBLq%2FFLqn1i4Y%2Fa0o%2FjR%2B7GpsfWI6OCk%3D&amp;reserved=0 to compile the heads kernel and initrd for
qemu-system_x86_64 +2. Copy the following built files +(1)
initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz +(2)
bzimage to LinuxBootPkg/LinuxBinaries/linux.efi+++
**SimicsOpenBoardPkg** 1. This firmware project has only been tested
booting to Microsoft Windows 10 x64 and Ubuntu 17.10 with AHCI mode.
--
2.25.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and
proprietary to American Megatrends (AMI). This communication is
intended to be read only by the individual or entity to whom it is
addressed or by their designee. If the reader of this message is not
the intended recipient, you are on notice that any distribution of
this message, in any form, is strictly prohibited. Please promptly
notify the sender by reply e-mail or by telephone at 770-246-8600, and
then delete or destroy all copies of the transmission.
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


Re: [EXTERNAL] RE: [edk2-platforms][PATCH V2] PurleyOpenBoardPkg : Support for LINUX Boot

Nate DeSimone
 

Hi Manic,

That is fair. I see your new patch which add a readme.md explaining that. With that...

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>

-----Original Message-----
From: Manickavasakam Karpagavinayagam <manickavasakamk@...>
Sent: Thursday, July 29, 2021 5:35 AM
To: Desimone, Nathaniel L <nathaniel.l.desimone@...>; devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Felix Polyudov <Felixp@...>; DOPPALAPUDI, HARIKRISHNA <harikrishnad@...>; Jha, Manish <manishj@...>; Bobroff, Zachary <zacharyb@...>
Subject: RE: [EXTERNAL] RE: [edk2-platforms][PATCH V2] PurleyOpenBoardPkg : Support for LINUX Boot

Nate :

If you see in this patch, linux.efi/initrd.cpio.xz are dummy files. These dummy files needs to be replaced by building the Linux Kernel.

How to build Linux Kernel is mentioned in the ReadMe document which is part of this patch.

1. Follow directions on http://osresearch.net/Building/ to compile the heads kernel and initrd for qemu-system_x86_64
2. Copy the following built files
(1) initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz
(2) bzimage to LinuxBootPkg/LinuxBinaries/linux.efi

Thank you

-Manic

-----Original Message-----
From: Desimone, Nathaniel L <nathaniel.l.desimone@...>
Sent: Thursday, July 29, 2021 3:17 AM
To: Manickavasakam Karpagavinayagam <manickavasakamk@...>; devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Felix Polyudov <Felixp@...>; Harikrishna Doppalapudi <Harikrishnad@...>; Manish Jha <manishj@...>; Zachary Bobroff <zacharyb@...>; Manickavasakam Karpagavinayagam <manickavasakamk@...>
Subject: [EXTERNAL] RE: [edk2-platforms][PATCH V2] PurleyOpenBoardPkg : Support for LINUX Boot


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Manic,

Unfortunately this patch cannot be merged as is. It appears to contain a pre-built binary of the Linux kernel that has been pre-configured for Linuxboot use. While this is very convenient, the Linux kernel is licensed under the GPL and hence we cannot add it to edk2-platforms, which must be kept as BSD only. It might be possible to add this to edk2-non-osi, but even then we would require that you provide a readme file that explains how to get and compile the source code that you used to build this exact Linux image, as required by the GPL.

The easiest and safest option would be to remove the Linux binary all together and provide instructions to the user for how to build their own image and add it to the tree.

Thanks,
Nate

-----Original Message-----
From: manickavasakam karpagavinayagam <manickavasakamk@...>
Sent: Wednesday, June 30, 2021 2:57 PM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@...>; Desimone, Nathaniel L
<nathaniel.l.desimone@...>; Felixp@...; DOPPALAPUDI,
HARIKRISHNA <harikrishnad@...>; Jha, Manish <manishj@...>;
Bobroff, Zachary <zacharyb@...>; KARPAGAVINAYAGAM, MANICKAVASAKAM
<manickavasakamk@...>
Subject: [edk2-platforms][PATCH V2] PurleyOpenBoardPkg : Support for
LINUX Boot

Support for LINUX Boot
To enable/disable feature, PcdLinuxBootEnable can be used
1. Follow directions on https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fosresearch.net%2FBuilding%2F&;data=04%7C01%7Cmanickavasakamk%40ami.com%7C3a64470864e64ee9f28d08d95260d55c%7C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C637631398142258756%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=ylzkAVWRzAtPBLq%2FFLqn1i4Y%2Fa0o%2FjR%2B7GpsfWI6OCk%3D&amp;reserved=0 to compile the
heads kernel and initrd for qemu-system_x86_64
2. Copy the following built files
(1) initrd.cpio.xz to
PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/initrd.cpio.xz
(2) bzimage to
PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/linux.efi

Notes:
V2 :
- Rename LinuxBootPkg to LinuxBoot
- Move LinuxBootPkg to PurleyOpenBoardPkg/Features/LinuxBoot
- Follow Coding Standard in LinuxBoot.C and LinuxBoot.h

Signed-off-by: manickavasakam karpagavinayagam
<manickavasakamk@...>
---
.../BoardTiogaPass/CoreDxeInclude.dsc | 5 +-
.../BoardTiogaPass/CoreUefiBootInclude.fdf | 5 +-
.../BoardTiogaPass/OpenBoardPkg.dsc | 7 +
.../BoardTiogaPass/OpenBoardPkg.fdf | 57 ++-
.../BoardTiogaPass/PlatformPkgConfig.dsc | 7 +
.../LinuxBoot/LinuxBinaries/LinuxKernel.inf | 17 +
.../LinuxBoot/LinuxBinaries/initrd.cpio.xz | Bin 0 -> 16 bytes
.../LinuxBoot/LinuxBinaries/linux.efi | Bin 0 -> 16 bytes
.../Features/LinuxBoot/LinuxBoot.c | 412 ++++++++++++++++++
.../Features/LinuxBoot/LinuxBoot.h | 185 ++++++++
.../Features/LinuxBoot/LinuxBoot.inf | 40 ++
.../Features/LinuxBoot/LinuxBootNull.c | 36 ++
.../Features/LinuxBoot/LinuxBootNull.inf | 25 ++
.../Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec | 2 +
.../DxePlatformBootManagerLib/BdsPlatform.c | 9 +
.../DxePlatformBootManagerLib.inf | 2 +
Platform/Intel/Readme.md | 42 ++
17 files changed, 843 insertions(+), 8 deletions(-) create mode
100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/Lin
u
xKernel.inf
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/ini
tr
d.cpio.xz
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/lin
u
x.efi
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.c
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.h
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.inf
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.c
create mode 100644
Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.inf

diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
index b0660d72dd..a17015704b 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.dsc
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreDxeInclude.ds
+++ c
@@ -83,6 +83,7 @@

$(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBus
Dxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -97,10 +98,11 @@
MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf

MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
FatPkg/EnhancedFatDxe/Fat.inf
-
+!endif

#MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputD
xe.inf

MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
xe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -124,6 +126,7 @@
<LibraryClasses>
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
}
+!endif

!if gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly == FALSE
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclud
e.fdf
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclud
e.fdf
index 141ce5dda3..6cd8ba6626 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclud
e.fdf
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/CoreUefiBootInclu
+++ de.fdf
@@ -47,6 +47,7 @@ INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
INF
$(PLATFORM_BOARD_PACKAGE)/Override/MdeModulePkg/Bus/Pci/PciBus
Dxe/PciBusDxe.inf
#TiogaPass Override END

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
@@ -62,10 +63,12 @@ INF
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
INF
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
INF FatPkg/EnhancedFatDxe/Fat.inf
+!endif

#INF
MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDx
e.inf
INF
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
xe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == FALSE
INF
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

@@ -79,4 +82,4 @@ INF
MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf

INF MdeModulePkg/Application/UiApp/UiApp.inf
INF
MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuAp
p.inf
-
+!endif
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
index e4c8e7fbf1..67472a1182 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.dsc
@@ -104,6 +104,13 @@

##########################################################
######################

[LibraryClasses.common]
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/Features/LinuxBoot/LinuxB
oot.inf
+ LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
+!else
+
+LinuxBootLib|$(PLATFORM_BOARD_PACKAGE)/Features/LinuxBoot/LinuxB
ootNull
+.inf
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == FALSE

PlatformBootManagerLib|$(PLATFORM_PACKAGE)/Bds/Library/DxePlatfor
mBootManagerLib/DxePlatformBootManagerLib.inf
!else
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
index 43cd8d94e1..1623c44cd8 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/OpenBoardPkg.fdf
@@ -19,6 +19,38 @@
# Also all values will have a PCD assigned so that they can be used in the
system, and
# the FlashMap edit tool can be used to change the values here, without
effecting the code.
# This requires all code to only use the PCD tokens to recover the values.
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset =
0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize =
0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset =
0x00300000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset =
0x00400000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset =
0x00500000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset =
0x00600000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize =
0x00600000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset =
0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
= 0x0007C000 #
+
+!else
+
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset =
0x00000000 # Flash addr (0xFF840000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedSize =
0x00500000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset =
0x00500000 # Flash addr (0xFF8A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecuritySize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset =
0x00600000 # Flash addr (0xFF910000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize =
0x00100000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset =
0x00700000 # Flash addr (0xFFE00000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize =
0x00200000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset =
0x00900000 # Flash addr (0xFF9A0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize =
0x00300000 #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset =
0x00C00000 # Flash addr (0xFF800000)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
= 0x0007C000 #
+
+!endif
+

[FD.Platform]
BaseAddress = 0xFF000000 |
gEfiPchTokenSpaceGuid.PcdFlashAreaBaseAddress
@@ -27,27 +59,27 @@ ErasePolarity = 1
BlockSize = 0x10000
NumBlocks = 0x100

-0x00000000|0x00500000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedOffset|gMinPlatfor
mPkgT
+okenSpaceGuid.PcdFlashFvAdvancedSize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedBase|gMinPlatformP
kgTokenSpaceGuid.PcdFlashFvAdvancedSize
FV = FvAdvanced

-0x00500000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityOffset|gMinPlatform
PkgT
+okenSpaceGuid.PcdFlashFvSecuritySize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvSecurityBase|gMinPlatformPk
gTokenSpaceGuid.PcdFlashFvSecuritySize
FV = FvSecurity

-0x00600000|0x00100000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootOffset|gMinPlatform
PkgTok
+enSpaceGuid.PcdFlashFvOsBootSize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootBase|gMinPlatformPkg
TokenSpaceGuid.PcdFlashFvOsBootSize
FV = FvOsBoot

-0x00700000|0x00200000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset|gMinPlatformPk
gToken
+SpaceGuid.PcdFlashFvFspUSize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUBase|gMinPlatformPkgTo
kenSpaceGuid.PcdFlashFvFspUSize
FV = FvLateSiliconCompressed

-0x00900000|0x00300000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset|gMinPlatfor
mPkgT
+okenSpaceGuid.PcdFlashFvUefiBootSize

gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootBase|gMinPlatformPk
gTokenSpaceGuid.PcdFlashFvUefiBootSize
FV = FvUefiBoot

-0x00C00000|0x0007C000
+gMinPlatformPkgTokenSpaceGuid.PcdFlashNvStorageVariableOffset|gEfiM
deMo
+dulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|gEfiM
deModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
#NV_VARIABLE_STORE
DATA = {
@@ -303,6 +335,19 @@ FILE DRIVER = db90bb7e-e4ba-4f07-96d6-
b7076713bd2c {

INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf

+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+
+FILE DRIVER = 81339b04-fa8c-4be0-9ca7-916fc5319eb5 {
+ SECTION DXE_DEPEX_EXP = {FALSE}
+ SECTION PE32 =
+$(PLATFORM_BOARD_PACKAGE)/Features/LinuxBoot/LinuxBinaries/linux.
efi
+}
+
+FILE FREEFORM = 16b60e5d-f1c5-42f0-9b34-08C81C430473 {
+ SECTION RAW =
+$(PLATFORM_BOARD_PACKAGE)/Features/LinuxBoot/LinuxBinaries/initrd.
cpio.
+xz
+}
+
+!endif
+

[FV.FvUefiBoot]
FvAlignment = 16
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.d
sc
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.
dsc
index 36a29c8d68..ff27252233 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig.d
sc
+++
b/Platform/Intel/PurleyOpenBoardPkg/BoardTiogaPass/PlatformPkgConfig
+++ .dsc
@@ -51,7 +51,14 @@

gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable|TRUE

+ gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE
+
+!if gPlatformTokenSpaceGuid.PcdLinuxBootEnable == TRUE
+ gPlatformTokenSpaceGuid.PcdFastBoot|TRUE
+!else
gPlatformTokenSpaceGuid.PcdFastBoot|FALSE
+!endif
+
!if gPlatformTokenSpaceGuid.PcdFastBoot == TRUE
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable|FALSE
gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|FALSE
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/L
i
nuxKernel.inf
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/L
i
nuxKernel.inf
new file mode 100644
index 0000000000..0e197ecb68
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries
+++ /LinuxKernel.inf
@@ -0,0 +1,17 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC.<BR> # #
+SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[Defines]
+ INF_VERSION = 1.27
+ BASE_NAME = LinuxKernel
+ FILE_GUID = 81339b04-fa8c-4be0-9ca7-916fc5319eb5
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+
+[Binaries.common.AARCH64]
+ PE32|linux.efi|*
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/i
ni
trd.cpio.xz
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/i
n
itrd.cpio.xz
new file mode 100644
index
0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911
d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/l
in
ux.efi
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBinaries/l
i
nux.efi
new file mode 100644
index
0000000000000000000000000000000000000000..01d633b27e8ea9b17084fc911
d0c8cc43a4170a9
GIT binary patch
literal 16
KcmZQzKm`B*5C8!H

literal 0
HcmV?d00001

diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.c
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.c
new file mode 100644
index 0000000000..682047cef0
--- /dev/null
+++ b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.c
@@ -0,0 +1,412 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h> #include
+<Library/UefiBootServicesTableLib.h>
+#include <Guid/DxeServices.h>
+#include <Library/DxeServicesTableLib.h> #include <Library/UefiLib.h>
+#include <Protocol/FirmwareVolume2.h> #include
<Protocol/LoadedImage.h>
+#include <Guid/MemoryTypeInformation.h> #include <Pi/PiDxeCis.h>
+#include <Pi/PiHob.h> #include <Library/PcdLib.h> #include
+<Library/DxeServicesLib.h> #include "LinuxBoot.h"
+
+//16b60e5d-f1c5-42f0-9b34-08C81C430473
+#define LINUX_BOOT_INITRD_GUID \
+ { \
+ 0x16b60e5d, 0xf1c5, 0x42f0, {0x9b, 0x34, 0x08, 0xc8, 0x1c, 0x43,
+0x04, 0x73} \
+ }
+
+#define LINUX_BOOT_KERNEL_GUID \
+ { \
+ 0x81339b04, 0xfa8c, 0x4be0, {0x9c, 0xa7, 0x91, 0x6f, 0xc5, 0x31,
+0x9e, 0xb5} \
+ }
+
+
+EFI_STATUS
+EFIAPI
+LoadLinuxCheckKernelSetup (
+ IN VOID *KernelSetup,
+ IN UINTN KernelSetupSize
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelSetupPages (
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxInitializeKernelSetup (
+ IN VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateKernelPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinuxSetCommandLine (
+ IN OUT VOID *KernelSetup,
+ IN CHAR8 *CommandLine
+ );
+
+EFI_STATUS
+EFIAPI
+LoadLinux (
+ IN VOID *Kernel,
+ IN OUT VOID *KernelSetup
+ );
+
+VOID*
+EFIAPI
+LoadLinuxAllocateInitrdPages (
+ IN VOID *KernelSetup,
+ IN UINTN Pages
+ );
+
+EFI_GUID gLinuxBootInitrdFileGuid = LINUX_BOOT_INITRD_GUID;
+
+EFI_GUID gLinuxBootKernelFileGuid = LINUX_BOOT_KERNEL_GUID;
+
+//-------------------------------------------------------------------
+--
+------
+
+/**
+ Dump some hexadecimal data to the screen.
+
+ @note Function taken from
+ ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c in EDKII
+
+ @param[in] Indent How many spaces to indent the output.
+ @param[in] Offset The offset of the printing.
+ @param[in] DataSize The size in bytes of UserData.
+ @param[in] UserData The data to print out.
+**/
+static
+VOID
+DumpHex (
+ IN UINTN Indent,
+ IN UINTN Offset,
+ IN UINTN DataSize,
+ IN VOID *UserData
+ )
+{
+ UINT8 *Data;
+ CHAR8 Val[50];
+ CHAR8 Str[20];
+ UINT8 TempByte;
+ UINTN Size;
+ UINTN Index;
+ CHAR8 Hex[] = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
+ };
+
+ DEBUG((DEBUG_INFO, "%*a 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D
0E 0F\n", Indent, ""));
+ DEBUG((DEBUG_INFO, "%*a ------------------------------------------------
\n", Indent, ""));
+
+ Data = UserData;
+ while (DataSize != 0) {
+ Size = 16;
+ if (Size > DataSize) {
+ Size = DataSize;
+ }
+
+ for (Index = 0; Index < Size; Index += 1) {
+ TempByte = Data[Index];
+ Val[Index * 3 + 0] = Hex[TempByte >> 4];
+ Val[Index * 3 + 1] = Hex[TempByte & 0xF];
+ Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
+ Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' :
TempByte);
+ }
+
+ Val[Index * 3] = 0;
+ Str[Index] = 0;
+ DEBUG((DEBUG_INFO, "%*a%08X: %-48a %a\n", Indent, "", Offset,
+ Val, Str));
+
+ Data += Size;
+ Offset += Size;
+ DataSize -= Size;
+ }
+}
+
+
+/**
+ * This function completes a minimal amount of the necessary BDS
+functions to prepare
+ * for booting the kernel.
+ *
+ * @param None
+ *
+ * @retval EFI_SUCCESS Successfully completed remaining tasks
+ * @return EFI_ERROR Could not complete BDS tasks
+ */
+EFI_STATUS
+CompleteBdsTasks (
+ VOID
+)
+{
+
+ return EFI_SUCCESS;
+}
+
+/**
+ * This function will load and launch the Linux kernel from a BIOS FV.
+ *
+ * @note This function is not intended to return. Any exiting from this
function indicates
+ * a problem loading or launching the kernel.
+ *
+ * @param None
+ *
+ * @return EFI_ERROR Any error code
+ */
+EFI_STATUS
+LoadAndLaunchKernel (
+ VOID
+)
+{
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage = NULL;
+ EFI_STATUS Status;
+ EFI_HANDLE KernelHandle = NULL;
+ VOID *KernelBuffer = NULL;
+ VOID *KernelFfsBuffer = NULL;
+ UINTN KernelFfsSize = 0;
+ VOID *InitrdData = NULL;
+ VOID *InitrdBuffer = NULL;
+ UINTN InitrdSize = 0;
+ struct BootParams *BootParams = NULL;
+ struct BootParams *HandoverParams = NULL;
+ UINT32 StartOffset = 0;
+ UINT32 KernelLength = 0;
+ UINT8 *Temp;
+ UINT8 CmdLine[] = " ";
+
+ DEBUG((DEBUG_INFO, "LoadAndLaunchKernel Entry\n"));
+
+ ///
+ /// Kernel load and preparation
+ ///
+ DEBUG((DEBUG_INFO, "Preparing the kernel...\n"));
+
+ // Retrieve the kernel from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootKernelFileGuid,
+ EFI_SECTION_PE32,
+ 0,
+ &KernelFfsBuffer,
+ &KernelFfsSize
+ );
+
+ DEBUG((DEBUG_INFO, "Status %r\n",Status));
+ DEBUG((DEBUG_INFO, "KernelFfsBuffer %x\n",KernelFfsBuffer));
+ DEBUG((DEBUG_INFO, "KernelFfsSize %x\n",KernelFfsSize));
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve kernel; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded kernel to buffer at 0x%p with size
0x%X.\n", KernelFfsBuffer, KernelFfsSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n",
+ MIN(KernelFfsSize, 0x100)));
+
+ DumpHex(2, 0, MIN(0x100, KernelFfsSize), KernelFfsBuffer);
+
+ // Create a LoadImage protocol for the kernel
+ Status = gBS->LoadImage(TRUE, gImageHandle, NULL,
+ KernelFfsBuffer,
KernelFfsSize, &KernelHandle);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not create LoadImage for kernel
+ %r\n",
Status));
+ goto FatalError;
+ }
+
+ // Get the new LoadedImage protocol to retrieve information about
+ the
kernel
+ Status = gBS->HandleProtocol(KernelHandle,
&gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not get kernel LoadedImage
+ protocol;
%r\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Kernel LoadedImage information:\n"));
+ DEBUG((DEBUG_INFO, " ImageBase = 0x%p\n", LoadedImage-
ImageBase));
+ DEBUG((DEBUG_INFO, " ImageSize = 0x%p\n",
+ LoadedImage->ImageSize));
+
+ // Verify the kernel boot parameters from the LoadedImage and
+ allocate
an initalization buffer once verified
+ BootParams = (struct BootParams*) LoadedImage->ImageBase;
+
+ Status = LoadLinuxCheckKernelSetup((VOID *) BootParams,
+ sizeof(struct
BootParams));
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "LoadLinuxCheckKernelSetup failed;
+ %r.\n",
Status));
+ goto FatalError;
+ }
+
+ HandoverParams =
LoadLinuxAllocateKernelSetupPages(EFI_SIZE_TO_PAGES(KERNEL_SETUP_SI
ZE));
+ if (HandoverParams == NULL) {
+ DEBUG((DEBUG_ERROR, "Could not allocate memory for kernel
handover parameters.\n"));
+ goto FatalError;
+ }
+ DEBUG((DEBUG_INFO, "Handover parameters allocated at 0x%p\n",
+ HandoverParams));
+
+ gBS->CopyMem(&HandoverParams->Hdr, &BootParams->Hdr,
sizeof(struct
+ SetupHeader));
+
+ Status = LoadLinuxInitializeKernelSetup(HandoverParams);
+ if (EFI_ERROR (Status)) {
+ DEBUG((DEBUG_ERROR, "Unable to initialize the handover
+ parameters;
%r.\n", Status));
+ goto FatalError;
+ }
+
+ // Allocate space for the kernel and copy it into the new buffer
+ KernelBuffer = LoadLinuxAllocateKernelPages(HandoverParams,
EFI_SIZE_TO_PAGES(HandoverParams->Hdr.InitSize));
+ if (KernelBuffer == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for kernel.\n"));
+ goto FatalError;
+ }
+
+ StartOffset = (HandoverParams->Hdr.SetupSecs + 1) * 512;
+ KernelLength = (UINT32) (KernelFfsSize - StartOffset);
+ Temp = (UINT8 *) LoadedImage->ImageBase;
+
+ DEBUG((DEBUG_INFO, "Kernel starts at offset 0x%X with length
+ 0x%X\n", StartOffset, KernelLength));
+
+ gBS->CopyMem(KernelBuffer, (Temp + StartOffset), KernelLength);
+ DEBUG((DEBUG_INFO, "First 0x%X bytes of new kernel buffer
+ contents:\n", MIN(0x100, KernelLength)));
+
+ DumpHex(2, 0, MIN(0x100, KernelLength), KernelBuffer);
+
+ // Prepare the command line
+ Status = LoadLinuxSetCommandLine(HandoverParams, (UINT8 *)
&CmdLine);
+ if (EFI_ERROR (Status)) {
+ DEBUG((EFI_D_INFO, "Unable to set linux command line; %r.\n",
Status));
+ goto FatalError;
+ }
+
+ HandoverParams->Hdr.Code32Start = (UINT32)(UINTN) KernelBuffer;
+ HandoverParams->Hdr.LoaderId = 0x21;
+
+ DEBUG((DEBUG_INFO, "Kernel loaded.\n"));
+
+ //
+ // Initrd load and preparation
+ //
+ DEBUG((DEBUG_INFO, "Preparing the initrd...\n"));
+
+ // Retrieve the initrd from the firmware volume
+ Status = GetSectionFromAnyFv(
+ &gLinuxBootInitrdFileGuid,
+ EFI_SECTION_RAW,
+ 0,
+ &InitrdBuffer,
+ &InitrdSize
+ );
+
+ if (EFI_ERROR(Status)) {
+ DEBUG((DEBUG_ERROR, "Could not retrieve initrd; %r.\n", Status));
+ goto FatalError;
+ }
+
+ DEBUG((DEBUG_INFO, "Loaded initrd to buffer at 0x%p with size
0x%X.\n", InitrdBuffer, InitrdSize));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes:\n", MIN(0x100,
InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdBuffer);
+
+ // Allocate the initrd for the kernel and copy it in
+ InitrdData = LoadLinuxAllocateInitrdPages(HandoverParams,
EFI_SIZE_TO_PAGES(InitrdSize));
+ if (InitrdData == NULL) {
+ DEBUG((DEBUG_ERROR, "Unable to allocate memory for initrd.\n"));
+ goto FatalError;
+ }
+
+ gBS->CopyMem(InitrdData, InitrdBuffer, InitrdSize);
+
+ HandoverParams->Hdr.RamDiskStart = (UINT32)(UINTN) InitrdData;
+ HandoverParams->Hdr.RamDiskLen = (UINT32) InitrdSize;
+
+ DEBUG((DEBUG_INFO, "Initrd loaded.\n"));
+ DEBUG((DEBUG_INFO, "Printing first 0x%X bytes of initrd
+ buffer:\n",
MIN(0x100, InitrdSize)));
+ DumpHex(2, 0, MIN(0x100, InitrdSize), InitrdData);
+
+ // General cleanup before launching the kernel
+ gBS->FreePool(InitrdBuffer);
+ InitrdBuffer = NULL;
+
+ gBS->UnloadImage(KernelHandle);
+ gBS->FreePool(KernelFfsBuffer);
+ KernelFfsBuffer = NULL;
+
+ DEBUG((DEBUG_ERROR, "Launching the kernel\n"));
+
+
+ //
+ // Signal the EFI_EVENT_GROUP_READY_TO_BOOT event.
+ //
+ EfiSignalEventReadyToBoot();
+
+
+ // Launch the kernel
+ Status = LoadLinux(KernelBuffer, HandoverParams);
+
+ ///
+ /// LoadLinux should never return if the kernel boots. Anything
+ past here
is an error scenario
+ ///
+ DEBUG((DEBUG_ERROR, "ERROR: LoadLinux has returned with status;
+ %r.\n", Status));
+
+FatalError:
+ // Free everything
+ if (InitrdData != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS)
InitrdData, EFI_SIZE_TO_PAGES(InitrdSize));
+ if (KernelBuffer != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS)
KernelBuffer, EFI_SIZE_TO_PAGES(HandoverParams->Hdr.InitSize));
+ if (HandoverParams != NULL) gBS->FreePages((EFI_PHYSICAL_ADDRESS)
HandoverParams, EFI_SIZE_TO_PAGES(KERNEL_SETUP_SIZE));
+ if (InitrdBuffer != NULL) gBS->FreePool(InitrdBuffer);
+ if (KernelHandle != NULL) gBS->UnloadImage(KernelHandle);
+ if (KernelFfsBuffer != NULL) gBS->FreePool(KernelFfsBuffer);
+
+ return EFI_NOT_FOUND;
+}
+
+/**
+ * This is the main function for this feature. This will handle
+finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The
LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for
some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ // Finish BDS and then try to launch the kernel
+ //Status = CompleteBdsTasks();
+
+ if (!EFI_ERROR(Status)) {
+ LoadAndLaunchKernel();
+ }
+
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ DEBUG((DEBUG_ERROR, " ERROR: Kernel failed to launch.\n"));
+ DEBUG((DEBUG_ERROR, "-----------------------------------\n"));
+ return Status;
+}
+
+//-------------------------------------------------------------------
+--
+------
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.h
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.h
new file mode 100644
index 0000000000..ebbcd6bfd8
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.h
@@ -0,0 +1,185 @@
+/** @file
+Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#ifndef __LINUX_BOOT_PRIVATE__H__
+#define __LINUX_BOOT_PRIVATE__H__
+#ifdef __cplusplus
+extern "C" {
+#endif // #ifdef __cplusplus
+
+//-------------------------------------------------------------------
+--
+------
+
+//#include <Token.h>
+
+#define BOOTSIG 0x1FE
+#define SETUP_HDR 0x53726448 /* 0x53726448 == "HdrS" */
+
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3
+#define E820_NVS 4
+#define E820_UNUSABLE 5
+
+#pragma pack(1)
+
+struct SetupHeader {
+ UINT8 SetupSecs; // Sectors for setup code
+ UINT16 Rootflags;
+ UINT32 SysSize;
+ UINT16 RamSize;
+ UINT16 VideoMode;
+ UINT16 RootDev;
+ UINT16 Signature; // Boot signature
+ UINT16 Jump;
+ UINT32 Header;
+ UINT16 Version;
+ UINT16 SuSwitch;
+ UINT16 SetupSeg;
+ UINT16 StartSys;
+ UINT16 KernelVer;
+ UINT8 LoaderId;
+ UINT8 LoadFlags;
+ UINT16 MoveSize;
+ UINT32 Code32Start; // Start of code loaded high
+ UINT32 RamDiskStart; // Start of initial ramdisk
+ UINT32 RamDiskLen; // Length of initial ramdisk
+ UINT32 BootSectkludge;
+ UINT16 HeapEnd;
+ UINT8 ExtLoaderVer; // Extended boot loader version
+ UINT8 ExtLoaderType; // Extended boot loader ID
+ UINT32 CmdLinePtr; // 32-bit pointer to the kernel command line
+ UINT32 RamDiskMax; // Highest legal initrd address
+ UINT32 KernelAlignment; // Physical addr alignment required for
+kernel
+ UINT8 RelocatableKernel; // Whether kernel is relocatable or not
+ UINT8 MinAlignment;
+ UINT16 XloadFlags;
+ UINT32 CmdlineSize;
+ UINT32 HardwareSubarch;
+ UINT64 HardwareSubarchData;
+ UINT32 PayloadOffset;
+ UINT32 PayloadLength;
+ UINT64 SetupData;
+ UINT64 PrefAddress;
+ UINT32 InitSize;
+ UINT32 HandoverOffset;
+};
+
+struct EfiInfo {
+ UINT32 EfiLoaderSignature;
+ UINT32 EfiSystab;
+ UINT32 EfiMemdescSize;
+ UINT32 EfiMemdescVersion;
+ UINT32 EfiMemMap;
+ UINT32 EfiMemMapSize;
+ UINT32 EfiSystabHi;
+ UINT32 EfiMemMapHi;
+};
+
+struct E820Entry {
+ UINT64 Addr; // start of memory segment
+ UINT64 Size; // size of memory segment
+ UINT32 Type; // type of memory segment
+};
+
+struct ScreenInfo {
+ UINT8 OrigX; // 0x00
+ UINT8 OrigY; // 0x01
+ UINT16 ExtMemK; // 0x02
+ UINT16 OrigVideoPage; // 0x04
+ UINT8 OrigVideoMode; // 0x06
+ UINT8 OrigVideoCols; // 0x07
+ UINT8 Flags; // 0x08
+ UINT8 Unused2; // 0x09
+ UINT16 OrigVideoEgaBx;// 0x0a
+ UINT16 Unused3; // 0x0c
+ UINT8 OrigVideoLines; // 0x0e
+ UINT8 OrigVideoIsVGA; // 0x0f
+ UINT16 OrigVideoPoints;// 0x10
+
+ // VESA graphic mode -- linear frame buffer
+ UINT16 LfbWidth; // 0x12
+ UINT16 LfbHeight; // 0x14
+ UINT16 LfbDepth; // 0x16
+ UINT32 LfbBase; // 0x18
+ UINT32 LfbSize; // 0x1c
+ UINT16 ClMagic, ClOffset; // 0x20
+ UINT16 LfbLineLength; // 0x24
+ UINT8 RedSize; // 0x26
+ UINT8 RedPos; // 0x27
+ UINT8 GreenSize; // 0x28
+ UINT8 GreenPos; // 0x29
+ UINT8 BlueSize; // 0x2a
+ UINT8 BluePos; // 0x2b
+ UINT8 RsvdSize; // 0x2c
+ UINT8 RsvdPos; // 0x2d
+ UINT16 VesaPmSeg; // 0x2e
+ UINT16 VesaPmOff; // 0x30
+ UINT16 Pages; // 0x32
+ UINT16 VesaAttributes; // 0x34
+ UINT32 Capabilities; // 0x36
+ UINT8 Reserved[6]; // 0x3a
+};
+
+struct BootParams {
+ struct ScreenInfo ScreenInfo;
+ UINT8 ApmBiosInfo[0x14];
+ UINT8 Pad2[4];
+ UINT64 TbootAddr;
+ UINT8 IstInfo[0x10];
+ UINT8 Pad3[16];
+ UINT8 Hd0Info[16];
+ UINT8 Hd1Info[16];
+ UINT8 SysDescTable[0x10];
+ UINT8 OlpcOfwHeader[0x10];
+ UINT8 Pad4[128];
+ UINT8 EdidInfo[0x80];
+ struct EfiInfo EfiInfo;
+ UINT32 AltMemK;
+ UINT32 Scratch;
+ UINT8 E820Entries;
+ UINT8 EddBufEntries;
+ UINT8 EddMbrSigBufEntries;
+ UINT8 Pad6[6];
+ struct SetupHeader Hdr;
+ UINT8 Pad7[0x290-0x1f1-sizeof(struct SetupHeader)];
+ UINT32 EddMbrSigBuffer[16];
+ struct E820Entry E820Map[128];
+ UINT8 Pad8[48];
+ UINT8 EddBuf[0x1ec];
+ UINT8 Pad9[276];
+};
+#pragma pack ()
+
+//-------------------------------------------------------------------
+--
+------
+
+#ifndef MIN
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#endif // #ifndef MIN
+
+#define KERNEL_SETUP_SIZE 16384
+
+//-------------------------------------------------------------------
+--
+------
+
+///
+/// Function prototypes from Bds module /// VOID ConnectEverything();
+VOID RecoverTheMemoryAbove4Gb(); VOID
SignalAllDriversConnectedEvent();
+VOID SignalProtocolEvent(IN EFI_GUID *ProtocolGuid);
+
+#if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+VOID SignalExitPmAuthProtocolEvent(VOID);
+#endif // #if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
+
+typedef VOID (BDS_CONTROL_FLOW_FUNCTION)();
+
+//-------------------------------------------------------------------
+--
+------
+
+/****** DO NOT WRITE BELOW THIS LINE *******/ #ifdef __cplusplus }
+#endif // #ifdef __cplusplus #endif // #ifndef
+__LINUX_BOOT_PRIVATE__H__
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.inf
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.inf
new file mode 100644
index 0000000000..5c09e5d317
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBoot.inf
@@ -0,0 +1,40 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC.<BR> # #
+SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 74a41ddc-fac5-4787-afad-d81ee30a8b63 #
{0x74a41ddc, 0xfac5, 0x4787, {0xaf, 0xad, 0xd8, 0x1e, 0xe3, 0x0a,
0x8b, 0x63}}
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBoot.c
+ LinuxBoot.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
+ BaseMemoryLib
+ DebugLib
+ UefiRuntimeServicesTableLib
+ UefiBootServicesTableLib
+ UefiLib
+ LoadLinuxLib
+
+[Guids]
+
+[Protocols]
+ gEfiLoadedImageProtocolGuid
+
+[Pcd]
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.c
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.c
new file mode 100644
index 0000000000..2e5e44db6c
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull
+++ .c
@@ -0,0 +1,36 @@
+/** @file
+
+Copyright (c) 2021, American Megatrends International LLC. All rights
+reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#include <PiDxe.h>
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+
+/**
+ * This is the main function for this feature. This will handle
+finding and launching
+ * the Linux kernel.
+ *
+ * @note In general, this function will never return to BDS. The
LINUXBOOT_ALLOW_RETURN_TO_BDS
+ * token will allow you to return to BDS if the kernel fails to launch for
some reason.
+ *
+ * @param None
+ *
+ * @retval None
+ */
+
+EFI_STATUS
+LinuxBootStart (
+ VOID
+ )
+{
+
+ return EFI_SUCCESS;
+}
+
+
diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.i
n
f
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull.i
nf
new file mode 100644
index 0000000000..e292be9671
--- /dev/null
+++
b/Platform/Intel/PurleyOpenBoardPkg/Features/LinuxBoot/LinuxBootNull
+++ .inf
@@ -0,0 +1,25 @@
+## @file
+#
+# Copyright (c) 2021, American Megatrends International LLC.<BR> # #
+SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ VERSION_STRING = 1.0
+ BASE_NAME = LinuxBoot
+ FILE_GUID = 0551B6D3-0594-4B02-AF42-5A9C7515CEC8
+ MODULE_TYPE = DXE_DRIVER
+ LIBRARY_CLASS = LinuxBootLib|DXE_DRIVER
+[Sources]
+ LinuxBootNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DxeServicesLib
\ No newline at end of file
diff --git a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
index 4dcec5430b..0c1ab318b8 100644
--- a/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec
@@ -49,6 +49,8 @@

gPlatformTokenSpaceGuid.PcdUpdateConsoleInBds|TRUE|BOOLEAN|0x300
00035 +
gPlatformTokenSpaceGuid.PcdLinuxBootEnable|FALSE|BOOLEAN|0x300000
36+ [PcdsDynamicEx]
gPlatformTokenSpaceGuid.PcdDfxAdvDebugJumper|FALSE|BOOLEAN|0x60
00001D diff --git
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
index b3b8ceba6f..bd0509ab10 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
+++
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatf
+++ ormPkg/Bds/Library/DxePlatformBootManagerLib/BdsPlatform.c
@@ -2,6 +2,7 @@
This file include all platform action which can be customized by IBV/OEM.
Copyright (c) 2017, Intel Corporation. All rights
reserved.<BR>+Copyright (c) 2021, American Megatrends International LLC.<BR> SPDX-License-Identifier:
BSD-2-Clause-Patent **/@@ -31,6 +32,12 @@ BOOLEAN
gPPRequireUIConfirm;
extern UINTN mBootMenuOptionNumber;
+EFI_STATUS+LinuxBootStart (+ VOID+ );++
GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH
gUsbClassKeyboardDevicePath = { { {@@ -1268,6 +1275,8 @@
PlatformBootManagerAfterConsole (
LocalBootMode = gBootMode; DEBUG ((DEBUG_INFO, "Current local
bootmode - %x\n", LocalBootMode)); + LinuxBootStart();+ // // Go the
different platform policy with different boot mode // Notes: this part code
can be change with the table policydiff --git
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLi
b.inf
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLi
b.inf
index 5790743565..21ac65257c 100644
---
a/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatfor
mPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLi
b.inf
+++
b/Platform/Intel/PurleyOpenBoardPkg/Override/Platform/Intel/MinPlatf
+++
ormPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManage
rL
+++ ib.inf
@@ -2,6 +2,7 @@
# Component name for module DxePlatformBootManagerLib # # Copyright
(c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>+#
Copyright (c) 2021, American Megatrends International LLC.<BR> # #
SPDX-License-
Identifier: BSD-2-Clause-Patent #@@ -40,6 +41,7 @@
PerformanceLib TimerLib Tcg2PhysicalPresenceLib+ LinuxBootLib
[Packages] MdePkg/MdePkg.decdiff --git a/Platform/Intel/Readme.md
b/Platform/Intel/Readme.md
index 06c5f32b1e..a34784ccb8 100644
--- a/Platform/Intel/Readme.md
+++ b/Platform/Intel/Readme.md
@@ -87,6 +87,11 @@ A UEFI firmware implementation using MinPlatformPkg
is constructed using the fol

----------------------------------------|-----------------------------
---------------|------
------------------------|--------------------| | Mt. Olympus | Purley
| PurleyOpenBoardPkg | BoardMtOlympus | +| Machine Name
| Supported Chipsets | BoardPkg | Board Name |+-
---------------------------------------|--------------------------------------------|--------
----------------------|--------------------|+| TiogaPass | Purley
| PurleyOpenBoardPkg | BoardTiogaPass |++ #### Simics | Machine
Name | Supported Chipsets | BoardPkg |
Board Name |@@ -250,6 +255,12 @@ return back to the minimum
platform caller.
| | | | build settings, environment variables.
| | | |---build_board.py: Optional board-specific pre-build,
| | | build, post-build and clean functions.+ | |
|------PurleyOpenBoardPkg+ | | | |------BoardTiogaPass+ |
| | |---build_config.cfg: BoardTiogaPass specific+ | | |
| build settings, environment variables.+ | | | |---
build_board.py: Optional board-specific pre-build,+ | | |
build, post-build and clean functions. | | | | | |---
---SimicsOpenBoardPkg | | | |------BoardX58Ich10@@ -292,6
+303,18 @@ For PurleyOpenBoardPkg
"bld cache-consume" Consume a cache of binary files from the specified
directory, BINARY_CACHE_PATH is empty, used "BinCache" as default path.
+For PurleyOpenBoardPkg (TiogaPass)+1. Open command window, go to the
workspace directory, e.g. c:\Edk2Workspace.+2. Type "cd edk2-
platforms\Platform\Intel\PurleyOpenBoardPkg\BoardTiogaPass".+3. Type
"GitEdk2MinBoardTiogaPass.bat" to setup GIT environment.+4. Type "bld"
to build Purley BoardTiogaPass board UEFI firmware image, "bld release" for
release build, "bld clean" to+ remove intermediate files."bld cache-
produce" Generate a cache of binary files in the specified directory,+ "bld
cache-consume" Consume a cache of binary files from the specified
directory, BINARY_CACHE_PATH is empty,+ used "BinCache" as default
path. +5. Final BIOS image will be
Build\PurleyOpenBoardPkg\BoardTiagoPass\DEBUG_VS2015x86\FV\PLATFO
RM.fd or +
Build\PurleyOpenBoardPkg\BoardTiagoPass\RELEASE_VS2015x86\FV\PLATF
ORM.fd, depending on bld batch script input.+6. This BIOS image needs to be
merged with SPS FW + ### **Known limitations**
**KabylakeOpenBoardPkg**@@ -307,6 +330,25 @@ For PurleyOpenBoardPkg
2. This firmware project does not build with the GCC compiler. 3. The
validated version of iASL compiler that can build MinPurley is
20180629. Older versions may generate ACPI build errors.
+**PurleyOpenBoardPkg Tioga Pass **+1. This firmware project has only
been tested on the Tioga Pass hardware.+2. This firmware project build
has only been tested using the Microsoft Visual Studio 2015 build
tools.+3. This firmware project does not build with the GCC
compiler.+4. The validated version of iASL compiler that can build
MinPurley is 20180629. Older versions may generate ACPI build errors.+5. Installed and booted to UEFI Windows 2016 on M.2 NVME slot+6.
Installed and booted to UEFI Windows 2019 on M.2 NVME slot and with
SATA HDD.+7. Installed and booted to UEFI RHEL 7.3 on SATA HDD+8.
Installed and booted to Ubuntu 18.04 on M.2 NVME slot.+9. Verified
Mellanox card detection during POST and OS+10. LINUX Boot Support (PcdLinuxBootEnable
needs to be enabled)++1. Follow directions on
https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fosresearch.net%2FBuilding%2F&;data=04%7C01%7Cmanickavasakamk%40ami.com%7C3a64470864e64ee9f28d08d95260d55c%7C27e97857e15f486cb58e86c2b3040f93%7C1%7C0%7C637631398142258756%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=ylzkAVWRzAtPBLq%2FFLqn1i4Y%2Fa0o%2FjR%2B7GpsfWI6OCk%3D&amp;reserved=0 to compile the heads kernel and initrd for
qemu-system_x86_64 +2. Copy the following built files +(1)
initrd.cpio.xz to LinuxBootPkg/LinuxBinaries/initrd.cpio.xz +(2)
bzimage to LinuxBootPkg/LinuxBinaries/linux.efi+++
**SimicsOpenBoardPkg** 1. This firmware project has only been tested
booting to Microsoft Windows 10 x64 and Ubuntu 17.10 with AHCI mode.
--
2.25.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and
proprietary to American Megatrends (AMI). This communication is
intended to be read only by the individual or entity to whom it is
addressed or by their designee. If the reader of this message is not
the intended recipient, you are on notice that any distribution of
this message, in any form, is strictly prohibited. Please promptly
notify the sender by reply e-mail or by telephone at 770-246-8600, and
then delete or destroy all copies of the transmission.
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

12341 - 12360 of 90975