Commit Graph

577 Commits

Author SHA1 Message Date
Alexander Gryanko 9e0c46efb0 ArmVirtPkg: PXE boot option build flag
The first step is to add an option to disable PXE loading. The patch is
divided into 3 parts. This part adds the NETWORK_PXE_BOOT_ENABLE flag
to the ArmVirtPkg module. At the current stage the flag is not functional.

Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
2024-12-06 18:26:01 +00:00
Ard Biesheuvel 47e28a6d44 ArmVirtPkg/ArmPlatformLibQemu: Enable early ID map on EL2+VHE
When booting at EL2, enable VHE if available so that the early ID map
can be enabled as well. This gets rid of any memory accesses (reads or
writes) before the MMU and caches are enabled.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-12-05 10:50:48 +00:00
Yang Gang 4928851899 ArmVirtPkg: Report an error if NETWORK_TLS_ENABLE is TRUE on ARM
Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
2024-11-27 20:57:03 +00:00
Ard Biesheuvel ae8ab7190c ArmVirtPkg/ArmVirtKvmTool: Use PSCI/SMCCC conduit from FDT
ArmVirtKvmTool might execute at EL2 when running under nested
virtualization, and in this case, it should not use HVC but SMC to
invoke PSCI and SMCCC services.

Like QEMU, kvmtool provides the PSCI conduit via a node in the FDT, and
as per the SMCCC, the PSCI conduit and the SMCCC conduit are guaranteed
to be the same. So switch to the ArmMonitorLib implementation that
selects the conduit based on this FDT node.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-11-26 23:53:16 +00:00
Ard Biesheuvel f9f4164af9 ArmVirtPkg: Rename ArmVirtQemuMonitorLib to ArmVirtMonitorLib
The implementation of ArmMonitorLib that selects the conduit (SMC or
HVC) based on the PSCI FDT node is suitable for other VMMs as well, so
rename it more appropriately.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-11-26 23:53:16 +00:00
Ard Biesheuvel 91171b6b94 ArmVirtPkg/PrePi: Don't clear HCR_EL2 fields when setting TGE
HCR_EL2 may contain fields that should be preserved (such as E2H, which
may be RES1 for all intents and purposes other than reading back the
register). So preserve the existing value when setting the TGE bit.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-11-26 23:53:16 +00:00
Ard Biesheuvel e54794bcc6 Remove all ArmSoftFloatLib library class resolutions
ArmSoftFloatLib is going away, so remove all residual references to it.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-11-26 22:00:36 +00:00
Oliver Smith-Denny ef4f3aa3f7 MdePkg: MdeLibs.dsc.inc: Apply StackCheckLibNull to All Module Types
Now that the ResetVectors are USER_DEFINED modules, they will not
be linked against StackCheckLibNull, which were the only modules
causing issues. So, we can now remove the kludge we had before
and the requirement for every DSC to include StackCheckLibNull
for SEC modules and just apply StackCheckLibNull globally.

This also changes every DSC to drop the SEC definition of
StackCheckLibNull.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-11-13 21:01:46 +00:00
Michael Kubacki d1372720a8 ArmVirtPkg/MemoryInitPei: Remove Non-RT Types from Mem Type Info HOB
Removes the following types from the memory type information HOBs
produced in the MemoryInitPei PEIM:

- `EfiBootServicesCode`
- `EfiBootServicesData`
- `EfiLoaderCode`
- `EfiLoaderData`

Our platform has a memory type information validation routine that
currently expects those types to be excluded as they would not impact
the UEFI memory map since they are not runtime memory types.

This follows the guidance in the whitepaper "A Tour Beyond BIOS
Memory Map and Practices in UEFI BIOS".

https://github.com/tianocore-docs/Docs/raw/master/White_Papers/A_Tour_Beyond_BIOS_Memory_Map_And_Practices_in_UEFI_BIOS_V2.pdf

"NOTE: We recommend a platform only define the ReservedMemory,
ACPINvs, ACPIReclaim,  RuntimeCode, RuntimeData in Memory Type
Information table, because OSes only request  these regions to be
consistent. There is no need to add BootServicesCode,
BootServicesData, LoaderCode, LoaderData in memory type information
table, because these regions will not be reserved during S4 resume."

Since these memory types are not tracked in memory type information
any longer it also reduces the number of resets that may need to
occur to update memory type buckets that are not needed.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-11-11 16:45:29 +00:00
Aleksandr Goncharov d8984e86c7 ArmVirtPkg: mark fixed network PCDs
Rename `NetworkPcds` to `NetworkFixedPcds` to avoid confusion with
dynamic PCDs.

Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Aleksandr Goncharov <chat@joursoir.net>
2024-11-11 13:38:51 +00:00
Aleksandr Goncharov 9cab9905af ArmVirtPkg: use NetworkDynamicPcds include file
Start using the include file in the ArmVirtPkg package to manage
dynamic network-related PCDs. This change removes the manual addition
of `PcdIPv4PXESupport` and `PcdIPv6PXESupport` from the DSC file,
relying instead on the centralized include file introduced in
NetworkPkg.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Aleksandr Goncharov <chat@joursoir.net>
2024-11-11 13:38:51 +00:00
Sudeep Holla 7327089f63 ArmVirtPkg: KvmTool: Fix clang linker error
Clang build for ArmVirtPkg/ArmVirtKvmTool.dsc fails with the below
warning:

  |  ld.lld: error: duplicate symbol: PciExpressRegisterForRuntimeAccess
  |  ld.lld: error: duplicate symbol: GetPciExpressBaseAddress
  |  ld.lld: error: duplicate symbol: PciExpressRead8
  |  ld.lld: error: duplicate symbol: PciExpressWrite8
  |  ld.lld: error: duplicate symbol: PciExpressOr8
  |  ld.lld: error: duplicate symbol: PciExpressAnd8
  |  ld.lld: error: duplicate symbol: PciExpressAndThenOr8
  |  ld.lld: error: duplicate symbol: PciExpressBitFieldRead8
  |  ld.lld: error: duplicate symbol: PciExpressBitFieldWrite8
  |  ld.lld: error: duplicate symbol: PciExpressBitFieldOr8
  |  ld.lld: error: duplicate symbol: PciExpressBitFieldAnd8
  |  ld.lld: error: duplicate symbol: PciExpressBitFieldAndThenOr8
  |  ld.lld: error: duplicate symbol: PciExpressRead16
  |  ld.lld: error: duplicate symbol: PciExpressWrite16
  |  ld.lld: error: duplicate symbol: PciExpressOr16
  |  ld.lld: error: duplicate symbol: PciExpressAnd16
  |  ld.lld: error: duplicate symbol: PciExpressAndThenOr16
  |  ld.lld: error: duplicate symbol: PciExpressBitFieldRead16
  |  ld.lld: error: duplicate symbol: PciExpressBitFieldWrite16
  |  ld.lld: error: duplicate symbol: PciExpressBitFieldOr16
  |  >>> defined in MdePkg/Library/BasePciExpressLib/BasePciExpressLib/OUTPUT/BasePciExpressLib.lib(PciExpressLib.obj)
  |  >>> defined in OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib/OUTPUT/BaseCachingPciExpressLib.lib(PciExpressLib.obj)
  |
  |  ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
  |  clang: error: linker command failed with exit code 1 (use -v to see invocation)

OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf is
getting linked as NULL library in these pacakges:
1. UefiCpuPkg/CpuMmio2Dxe/CpuMmio2Dxe.inf
2. MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
3. MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
which results in duplicate symbols shown in the warning above as
MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf is not properly replaced
by OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf
as PciExpressLib library.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2024-10-30 17:37:55 +00:00
Leif Lindholm cac73c45c4 ArmVirtPkg/ArmVirtQemu: avoid unnecessary use of $(ARCH) conditional
ARCH as set by "build" command is not really useful for
conditionals, so move AArch64-specific Pcd to
[PcdsFixedAtBuild.AARCH64].

Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
2024-10-02 07:45:03 +00:00
Leif Lindholm dab548a51b ArmVirtPkg: add QemuVirtMemInfoLib missing dependency/includes
QemuVirtMemInfoLib makes use of BaseLib but never declared the
dependency or included the header. The code still built by
luck and by including the EmbeddedPkg FdtLib. Which is going
away, so add the missing stanzas in preparation.

Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
2024-09-27 12:42:07 +00:00
Heinrich Schuchardt 2936b7d162 ArmVirtPkg: Correct PcdDxeNxMemoryProtectionPolicy comment
Since commit 2997ae3873 ("ArmVirtPkg: make EFI_LOADER_DATA
non-executable") the comment for PcdDxeNxMemoryProtectionPolicy is
incorrect.

* Remove the incorrect part of the description.
* Describe overriding NX protection by passing a pcd parameter on the
  build command line.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-09-26 13:46:45 +00:00
Oliver Smith-Denny 02e6c73a99 ArmVirtPkg: Add Null Stack Check Lib
Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-13 03:58:46 +00:00
Mike Beaton bb403511d4 ArmVirtPkg: Fix unable to build with -D NETWORK_ENABLE=0
https://bugzilla.tianocore.org/show_bug.cgi?id=4829

7f17a15 (2024/02/22)
"OvmfPkg: Shell*.inc: allow building without network support"
breaks building OVMF with `-D NETWORK_ENABLE=0`.

Before this commit we could build OVMF e.g. with the following
command in the OvmfPkg directory:

./build.sh -D NETWORK_ENABLE=0

After the commit the same command fails early with:

/home/user/OpenSource/edk2/OvmfPkg/OvmfPkgX64.dsc(15):
error F001: Pcd (gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections)
defined in DSC is not declared in DEC files referenced in INF files in
FDF. Arch: ['X64']

This problem also applies in the ArmVirtPkg
platforms which are modified here, but is currently
masked by another issue, namely that these platforms
incorrectly still include some network packages when
most are disabled. (A fix for this was previously applied,
for OvmfPkg Intel platforms only, by
d933ec1 followed by
7f17a15 .)

This commit was created at the same time as the
commits resolving this issue in NetworkPkg and
OvmfPkg. It makes conditional the Pcd references
in ArmVirtPkg platforms which will become references to
undefined Pcds as and when the other issue mentioned
above is fixed.

Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
2024-09-12 21:34:33 +00:00
Oliver Smith-Denny 8f74b95a21 MdePkg: Move CompilerIntrinsicsLib from ArmPkg
As per the emailed RFC in
https://edk2.groups.io/g/devel/topic/rfc_move/107675828,
this patch moves CompilerIntrinsicsLib from ArmPkg to
MdePkg as this library provides compiler intrinsics, which
are industry standard.

This aligns with the goal of integrating ArmPkg into existing
packages: https://bugzilla.tianocore.org/show_bug.cgi?id=4121.

The newly placed CompilerIntrinsicsLib is added to MdeLibs.dsc.inc
as every DSC that builds ARM/AARCH64 needs this library added. The
old location is removed from every DSC in edk2 in this commit also
to not break bisectability with minimal hoop jumping.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-12 19:36:59 +00:00
Oliver Smith-Denny 734e71f428 MdePkg: Move AsmMacroIoLib*.h from ArmPkg
AsmMacroIoLib.h and AsmMacroIoLibV8.h are used by the
CompilerIntrinsicsLib, which is moving to MdePkg. These
functions provide standard definitions for ARM/AARCH64
assembly code, respectively, and so are moved to the arch
directories in MdePkg to avoid MdePkg having a
dependency on ArmPkg.

Now that the files are in Arm/ and AArch64/ directories,
the filenames are changed to AsmMacroLib.h as we can
distinguish the architecture from the path.

AsmMacroIoLib.inc is unused and so is removed.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-12 19:36:59 +00:00
Ard Biesheuvel 99d60cbd39 ArmVirtPkg ARM: Move to MbedTls for crypto
Move all BaseCryptLib resolutions for 32-bit ARM to MbedTls, which does
not require a softfloat library, which can therefore be dropped from
EDK2 entirely going forward.

Note that this implies no TLS networking for 32-bit ARM, as this code
has a direct dependency on OpenSSL, so move the TlsLib resolution to a
AARCH64-only section to force the build to fail early when attempting to
build 32-bit ARM targets with NETWORK_TLS_ENABLE set.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-09-04 10:22:35 +00:00
Ard Biesheuvel afba5358c8 ArmVirtPkg: Resolve RngLib via RngDxe for TRNG support
Gerd reports that ArmVirtQemu running under KVM lost network boot
support on systems that do not implement the RNDR/RNDRRS system
registers, which provide an architectural, CPU-based source of random
numbers. Under KVM, the TRNG SMCCC is available as a fallback, which is
exposed via RngDxe but not via the base RngLib library. This means that
direct users of RngLib, such as OpensslLib, have no access to the TRNG
based entropy source.

Let's fix this by resolving RngLib dependencies for UEFI_DRIVER type
drivers via DxeRngLib, which uses the protocol exposed by RngDxe
internally.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-09-03 22:47:09 +00:00
Ard Biesheuvel a63a7dbf85 ArmVirtPkg: Drop incorrect reference to LzmaDecompressLib
LzmaDecompressLib does not exist as a library class, and the library
implementation that is usually referenced in this context is intended to
be incorporated using NULL library class resolution.

Let's fix this so that we can drop the reference to LzmaDecompressLib.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Sami Mujawar <sami.mujawar@arm.com>
2024-08-30 09:57:24 +00:00
Ard Biesheuvel 5c566abb12 ArmVirtPkg/ArmPlatformLib: Drop unused MPCore routines
Some of the boilerplate in ArmPlatformLib is only relevant when entering
UEFI on multiple cores, and this is no longer supported. So retire the
associated helper routines.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-08-30 08:01:28 +00:00
Rebecca Cran 394cbc4ab2 ArmVirtPkg: Fix some spelling mistakes found by cspell
When cspell is installed (via `npm install cspell`), CI checks for
spelling mistakes. There are currently a very large number of them: some
are genuine mistakes while others are words or acryonyms that cspell
doesn't know.

Fix a few of the misspellings in ArmVirtPkg.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
2024-08-01 19:53:47 +00:00
Ard Biesheuvel 2d5390053f ArmVirtPkg: Switch all PrePeiCore users to new Sec.inf
Switch to the new SEC driver based on PrePeiCore, but with a sane name.
The old one will be retired once all users have migrated, including many
in edk2-platforms.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-08-01 14:55:03 +00:00
Ard Biesheuvel 8c10017aa7 ArmVirtPkg/PrePi: Drop call to TimerConstructor()
Drop the call to the TimerConstructor, which should not be called
explicitly, and does nothing useful to begin with.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-08-01 14:55:03 +00:00
Ard Biesheuvel caac25e22e ArmVirtPkg: Drop bogus reference to MPCore related PCD
Bringing up secondaries is out of scope for ArmVirtPkg, and the declared
PCD reference is never actually made from the code. So drop it.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-08-01 14:55:03 +00:00
Sami Mujawar ae1ba78718 ArmVirtPkg: Kvmtool: Update Pci Config Space Info in Cfg Manager
The Pci Config Space Info object was moved from the Arm
Namespace to the Arch Common namespace.

Therefore, update the Kvmtool guest firmware configuration
manager to reflect this change.

Cc: Pierre Gondois <Pierre.Gondois@arm.com>
Cc: Yeo Reum Yun <YeoReum.Yun@arm.com>
Cc: AbdulLateef Attar <AbdulLateef.Attar@amd.com>
Cc: Jeshua Smith <jeshuas@nvidia.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>
Cc: Girish Mahadevan <gmahadevan@nvidia.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
2024-07-29 13:44:55 +00:00
Sami Mujawar 1775c9d51c ArmVirtPkg: Kvmtool: Update Power Mgmt Profile info in Cfg Manager
The PowerManagementProfileInfo Object has been moved from the
Arm Namespace to the Arch Common namespace.

Therefore, update the Kvmtool Guest firmware configuration
manager to reflect this change.

Cc: Pierre Gondois <Pierre.Gondois@arm.com>
Cc: Yeo Reum Yun <YeoReum.Yun@arm.com>
Cc: AbdulLateef Attar <AbdulLateef.Attar@amd.com>
Cc: Jeshua Smith <jeshuas@nvidia.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>
Cc: Girish Mahadevan <gmahadevan@nvidia.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
2024-07-29 13:44:55 +00:00
Sami Mujawar 6dad45b7dd ArmVirtPkg: Kvmtool: Update ConfigMgr to support ArchCommon
Update the Configuration Manager for Kvmtool guest firmware
to handle ArchComm namespace objects.

Cc: Pierre Gondois <Pierre.Gondois@arm.com>
Cc: Yeo Reum Yun <YeoReum.Yun@arm.com>
Cc: AbdulLateef Attar <AbdulLateef.Attar@amd.com>
Cc: Jeshua Smith <jeshuas@nvidia.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>
Cc: Girish Mahadevan <gmahadevan@nvidia.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
2024-07-29 13:44:55 +00:00
Ard Biesheuvel 52eb643d07 ArmVirtPkg/ArmVirtQemu: Switch to generic ResetSystemLib
Retire the special ResetSystemLib implementation for the PEI phase on
virtual platforms, which has been superseded by the generic version
combined with a PEI-compatible implementation of ArmMonitorLib.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-07-27 15:51:27 +00:00
Ard Biesheuvel 08c60b40da ArmVirtPkg: Implement DT-based ArmMonitorLib for the PEI phase
The TPM2 related PEIMs depend on ResetSystemLib too, and so in order to
be able to switch to the generic ArmPkg implementation which relies on
ArmMonitorLib, the latter library class requires a PEIM-compatible
implementation too.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-07-27 15:51:27 +00:00
Ard Biesheuvel 358b19e6bf ArmVirtPkg: Move to generic ArmPsciResetSystemLib
Switch to the new, generic ArmPsciResetSystemLib implementation that
obtains the conduit using ArmMonitorLib, of which a version already
exists that determines the conduit by looking up the PSCI DT node.
This permits the removal of the ArmVirtPkg specific implementation of
ResetSystemLib, which essentially does the exact same thing, but in a
single library.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-07-27 15:51:27 +00:00
Ard Biesheuvel 43130ae403 ArmPkg: Convert PcdMonitorConduitHvc to FixedAtBuild
Feature PCDs and fixed-at-build PCDs are identical in concept, but the
latter are accessible from assembler, whereas the former are not. So
convert the SMCCC conduit selection PCD to fixed-at-build so we can make
use of this in a subsequent patch.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-07-25 14:41:09 +00:00
Oliver Smith-Denny 1b8ca81133 ArmVirtPkg: KvmtoolRtcFdtClientLib: Set MMIO Memory NX
When setting memory attributes on its MMIO region,
KvmtoolRtcFdtClientLib will clear EFI_MEMORY_XP from
the region if a platform has it set. This MMIO region is
not intended to be executed from, so fix this by explicitly
setting EFI_MEMORY_XP on this region in the lib.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-07-23 06:07:45 +00:00
Michael Kubacki c5582e435c ArmVirtPkg: QemuVirtMemInfoPeiLib: Allow Dynamic PcdSystemMemorySize
Platforms today may use this PCD as a dynamic PCD as that is an
allowed type in its PCD declaration. From `ArmPkg.dec`:

[PcdsFixedAtBuild.common, PcdsDynamic.common, PcdsPatchableInModule.common]
  gArmTokenSpaceGuid.PcdSystemMemorySize|0|UINT64|0x0000002A

This library causes a build error if it used as a dynamic PCD since
it places the PCD in a `[FixedPcd]` section in the INF.

Other libraries do set the PCD and depend on the dynamic PCD behavior.

Since this library accesses the PCD with `PcdGet64 ()` which is
compatible with FixedAtBuild PCDs, this change moves the PCD out an
explicit `[FixedPcd]` section to resolve the following build error:

```
  INFO -  : error 3000: Building modules from source INFs, following
                        PCD use Dynamic and FixedAtBuild access method.
                        It must be corrected to use only one access
                        method.
  INFO - 	gArmTokenSpaceGuid.PcdSystemMemorySize
```

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-07-22 23:16:15 +00:00
Leif Lindholm 7ee89453b5 ArmVirtPkg: drop use of PcdArmArchTimerFreqInHz
PcdArmArchTimerFreqInHz lets platforms override the architectural timer
frequency, but this really isn't supported in hardware by anything lower
than EL3. Setting it to 0 skips the override - but that is also the
default. So drop the explicit setting in ArmVirtPkg platforms in
preparation for deleting the Pcd completely.

Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
2024-06-26 01:51:15 +00:00
Pierre Gondois c68fb69dfe ArmPkg,MdePkg: Move ArmPkg/Chipset/ArmV7[|Mmu].h to MdePkg
Following the discussion at [1] and as the ArmLib relies on them,
move ArmPkg/Chipset/ArmV7[|Mmu].h files to the MdePkg.

Update the path to correctly include the moved files.

[1] https://edk2.groups.io/g/devel/message/111566

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
2024-06-15 03:57:14 +00:00
Ard Biesheuvel 3dcc7b73df ArmPkg: Revert "Allow SMC/HVC monitor conduit to be specified at runtime"
This reverts commit 32460bb5b1, which is
no longer needed as ArmVirtQemu now has its own special implementation
for ArmMonitorLib.

Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-06-10 08:44:48 +00:00
Ard Biesheuvel 2c19297e6c ArmVirtPkg/ArmVirtQemu: Revert "Permit the use of dynamic PCDs in PEI"
This reverts commit 865229bcc8, and
restores the old state where dynamic PCDs are only used when TPM support
is configured.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-06-10 08:44:48 +00:00
Ard Biesheuvel 7bcd49edd0 ArmVirtPkg: Revert "Use dynamic PCD to set the SMCCC conduit"
This reverts commit c98f7f7550, which is
no longer needed: the SMCCC conduit will be converted back to being
hardcoded, as PrePi based ArmVirtPkg build cannot support dynamic PCDs,
and falling back to patchable PCDs does not work either.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-06-10 08:44:48 +00:00
Ard Biesheuvel 059676e4fa ArmVirtPkg/ArmVirtQemu: Implement ArmMonitorLib for QEMU specifically
Whether SMCCC calls use HVC or SMC generally depends on the exception
level that the firmware executes at, but also on whether or not EL2 is
implemented.

This is almost always known at build time, which is why the default
ArmMonitorLib used to model this as a feature PCD. However, on QEMU,
things are not that simple.

However, SMCCC specifies that the conduit is the same as the one used
for PSCI calls (which has been retrofitted into SMCCC when it was
defined). Given that QEMU provides this information via the device tree,
let's use it to select the conduit, using a special ArmMonitorLib
implementation.

This also removes the need to set the associated PCD at runtime, given
that its updated value will no longer be used.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-06-10 08:44:48 +00:00
Ard Biesheuvel 5bea691233 ArmVirtPkg/PrePi: Enable VFP before calling into C code
When building ArmVirtQemuKernel with CLANGDWARF (which does not require
a GCC workaround where -mgeneral-regs-only is needed to ensure
-mstrict-align works as expected), the C code invoked from the PrePi
startup code may contain instructions that access the FP/SIMD register
file. This means that the FP/SIMD must be enabled before making such
calls, and this is currently not the case. So fix that, by moving the
call to ArmEnableVFP() early into the asm startup code.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2024-06-10 08:44:48 +00:00
Chao Li 10ab1c67c4 ArmVirtPkg: Remove the NorFlashQemuLib
The FdtNorFlashQemuLib has been enabled, remove ArmVirtPkg version.

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

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
2024-06-05 21:50:38 +00:00
Chao Li 7772e339bd ArmVirtPkg: Enable the non-hardcode version FdtNorFlashQemuLib
Enable the non-hardcode version of FdtNorFlashQemuLib in ArmVirtQemu.dsc
and ArmVirtQemuKernel.dsc, and it can work rightly after enabling it.

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

Build-tested (with "ArmVirtQemu.dsc" and "ArmVirtQemuKernel.dsc").

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Co-authored-by: Xianglai Li <lixianglai@loongson.cn>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
2024-06-04 22:51:09 +00:00
Ard Biesheuvel 3e722403cd ArmVirtPkg/ArmVirtQemu: Add RngDxe driver
Add the RngDxe driver to the build, backed by either RNDR or TRNG, one
of which is expected to be available in most cases:
- RNDR is implemented by the 'max' CPU that QEMU implements in TCG mode
- TRNG is implemented by the KVM hypervisor, which backs QEMU's 'host'
  CPU

Other TCG modes (e.g., the 'cortex-a*' CPUs) implement neither, which
should prevent the RngDxe driver from dispatching entirely, resulting
in the same situation as before.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>

Committed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2024-05-24 15:48:52 +00:00
Ard Biesheuvel 66c69871e7 ArmVirtPkg: Reverse inclusion order of MdeLibs.inc and ArmVirt.dsc.inc
MdeLibs.inc sets default library class resolutions which are much more
general than the ones that might be specified in ArmVirt.dsc.inc. So the
latter should be included *after* MdeLibs.inc to ensure that its
definitions take precedence.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>

Committed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2024-05-24 15:48:52 +00:00
Ard Biesheuvel c98f7f7550 ArmVirtPkg: Use dynamic PCD to set the SMCCC conduit
On ARM systems, whether SMC or HVC instructions need to be used to issue
monitor calls is typically dependent on the exception level, but there
are also cases where EL1 might use SMC instructions, so there is no hard
and fast rule.

For ArmVirtQemu, this does depend strictly on the exception level, so
set the default to HVC (for EL1 execution) and override it to SMC when
booted at EL2.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>

Committed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2024-05-24 15:48:52 +00:00
Ard Biesheuvel 865229bcc8 ArmVirtPkg/ArmVirtQemu: Permit the use of dynamic PCDs in PEI
Currently, only TPM2 builds enable the PCD PEIM, which is a prerequisite
for being able to use dynamic PCDs already at the PEI stage. This
facility will be used for other reasons too so move those pieces out of
code block that are conditional on TPM2_ENABLE

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>

Committed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2024-05-24 15:48:52 +00:00
Flickdm 9440986d4e ArmVirtPkg: Move PcdMonitorConduitHvc
This moves the PcdMonitorConduitHvc from PcdsFeatureFlag.Common to
PcdsFixedAtBuild.Common

This is a follow on to the previous commit:
ArmPkg: Allow SMC/HVC monitor conduit to be specified at runtime

ArmVirtQemu may execute at EL2, in which case monitor calls are
generally made using SMC instructions instead of HVC instructions.

Whether or not this is the case can only be decided at runtime, and so
the associated PCD needs to be settable at runtime, if the platform
definition chooses so. This implies a boolean PCD, given that a feature
PCD is build-time configurable only.

Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>

Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2024-05-24 15:48:52 +00:00