Branch: refs/heads/master
  Home:   https://github.com/tianocore/edk2
  Commit: 647cd40cf6658f52e0c6d4c356620a4dedd425ba
      
https://github.com/tianocore/edk2/commit/647cd40cf6658f52e0c6d4c356620a4dedd425ba
  Author: Oliver Smith-Denny <o...@linux.microsoft.com>
  Date:   2023-05-29 (Mon, 29 May 2023)

  Changed paths:
    M ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c

  Log Message:
  -----------
  ArmPkg/CpuDxe AARCH64: Report Memory Protection Attributes To GCD

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

When the AARCH64 CpuDxe attempts to SyncCacheConfig() with the GCD, it
collects the page attributes as:

  EntryAttribute = Entry & TT_ATTR_INDX_MASK

However, TT_ATTR_INDX_MASK only masks the cacheability attributes and
drops the memory protections attributes. Importantly, it also drops the
TT_AF (access flag) which is now wired up in EDK2 to represent
EFI_MEMORY_RP, so by default all SystemMem pages will report as
EFI_MEMORY_RP to the GCD. The GCD currently drops that silently, because
the Capabilities field in the GCD does not support EFI_MEMORY_RP by
default.

However, some ranges may support EFI_MEMORY_RP and incorrectly mark
those ranges as read protected. In conjunction with another change on
the mailing list (see: https://edk2.groups.io/g/devel/topic/98505340),
this causes an access flag fault incorrectly. See the linked BZ below
for full details.

This patch exposes all memory protections attributes to the GCD layer so
it can correctly set pages as EFI_MEMORY[RP|XP|RO] when it initially
syncs.

Cc: Leif Lindholm <quic_llind...@quicinc.com>
Cc: Sami Mujawar <sami.muja...@arm.com>
Cc: Taylor Beebe <t...@taylorbeebe.com>
Cc: Sean Brogan <sean.bro...@microsoft.com>
Signed-off-by: Oliver Smith-Denny <o...@linux.microsoft.com>
Reviewed-by: Ard Biesheuvel <a...@kernel.org>
Reviewed-by: Michael Kubacki <michael.kuba...@microsoft.com>


  Commit: 0b4263a2c2cd9d590945a8a01d310d88db3e39b0
      
https://github.com/tianocore/edk2/commit/0b4263a2c2cd9d590945a8a01d310d88db3e39b0
  Author: Sami Mujawar <sami.muja...@arm.com>
  Date:   2023-05-29 (Mon, 29 May 2023)

  Changed paths:
    M ArmVirtPkg/PrePi/PrePi.c

  Log Message:
  -----------
  ArmVirtPkg/PrePi: Allocate separate stack for Dxe phase

The patch "f07a9df9af60 ArmVirtPkg: Enable stack guard"
enabled stack overflow detection for ArmVirtPkg. Following
this patch, running UEFI shell command 'dmpstore' resulted
in a crash indicating a stack overflow. Invoking 'dmpstore'
results in recursive calls to CascadeProcessVariables ()
which apparently consumes the available stack space and
overflows.

Normally, SEC and PEI run off the initial stack, and the
DxeIpl PEIM is in charge of launching the DxeCore with a
full-sized stack and remapping it non-executable as well.

PrePi platforms take some shortcuts and the DXE and BDS
run off the initial stack which is relatively small. It
is therefore desirable to allocate 128 KiB worth of boot
services data memory as the stack for the Dxe phase.

The PrePiMain () in ArmVirtPkg/PrePi/PrePi.c invokes the
LoadDxeCoreFromFv () to load the Dxe core and transfers
control. The second parameter to LoadDxeCoreFromFv () is
the stack size, which is currently set to 0.
LoadDxeCoreFromFv () is implemented in PrePiLib and if the
stack size is 0, it continues to use the initial stack.
However, if a stack size is specified in the call to
LoadDxeCoreFromFv (), memory is allocated for a new stack
and the stack is switched to use the newly allocated stack
for the Dxe phase.

Therefore, specify 128 KiB as the stack size in the call to
LoadDxeCoreFromFv () so that a separate stack is allocated
and used for the Dxe phase.

Signed-off-by: Sami Mujawar <sami.muja...@arm.com>
Reviewed-by: Ard Biesheuvel <a...@kernel.org>


  Commit: 86cc2749418af2f52702972ab5db0ca52cb12caa
      
https://github.com/tianocore/edk2/commit/86cc2749418af2f52702972ab5db0ca52cb12caa
  Author: Sami Mujawar <sami.muja...@arm.com>
  Date:   2023-05-29 (Mon, 29 May 2023)

  Changed paths:
    M ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

  Log Message:
  -----------
  ArmPkg: Configure PcdEmuVariableNvModeEnable as a dynamic PCD

The PCD gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
indicates if a variable driver will emulate the variable NV mode.
This PCD is defined as [PcdsFixedAtBuild, PcdsPatchableInModule,
PcdsDynamic, PcdsDynamicEx].

Some firmware builds may define this PCD as a dynamic PCD and
initialise the value at runtime. Therefore, move the PCD declaration
from the [FixedPcd] section to the [Pcd] section in the platform
boot manager library file PlatformBootManagerLib.inf. Without this
change the build would not succeed.

Signed-off-by: Sami Mujawar <sami.muja...@arm.com>
Reviewed-by: Ard Biesheuvel <a...@kernel.org>


  Commit: 0e5aecfed12da337c766a152a47c35ac1ec35818
      
https://github.com/tianocore/edk2/commit/0e5aecfed12da337c766a152a47c35ac1ec35818
  Author: Sami Mujawar <sami.muja...@arm.com>
  Date:   2023-05-29 (Mon, 29 May 2023)

  Changed paths:
    M ArmVirtPkg/ArmVirtKvmTool.dsc

  Log Message:
  -----------
  ArmVirtPkg: Define variables for emulating runtime variables

Kvmtool allows guest VMs to be launched with or without a
CFI flash device.

When the kvmtool option '--flash <flash filename>' is used to
launch a guest VM a CFI flash device maps the flash file that
was specified at the command line. The NorFlash driver uses
this flash as the variable storage backend.

However, when the above option is not specified, a CFI flash
device is not present. In such cases, the firmware can fallback
to use emulated runtime variables (which uses the VMs DRAM as
the storage backend).

Therefore, define the PCD PcdEmuVariableNvModeEnable required
to enable the emulated runtime variable support, but do not
enable it by default.

The firmware is expected to dynamically discover if the CFI
flash is present and subsequently enable NorFlash or emulate
the runtime variables.

Signed-off-by: Sami Mujawar <sami.muja...@arm.com>
Reviewed-by: Ard Biesheuvel <a...@kernel.org>


  Commit: 84d0b21d18db479236b6f8143eaa2e874e4efa99
      
https://github.com/tianocore/edk2/commit/84d0b21d18db479236b6f8143eaa2e874e4efa99
  Author: Sami Mujawar <sami.muja...@arm.com>
  Date:   2023-05-29 (Mon, 29 May 2023)

  Changed paths:
    M ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c
    M ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf

  Log Message:
  -----------
  ArmVirtPkg: Fallback to variable emulation if no CFI is found

The kvmtool option '--flash <flash filename>' is used to launch
a guests VM with a CFI flash device that maps the flash file
specified at the command line.
However, kvmtool allows guest VMs to be launched without a CFI
flash device. In such scenarios the firmware can utilize the
emulated variable storage for UEFI variables. To support this
the PCD gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable
must be set to TRUE.

Therefore, update the NorFlashKvmtoolLib to fallback to variable
emulation if a CFI device is not detected. Also improve the error
logging.

Signed-off-by: Sami Mujawar <sami.muja...@arm.com>
Reviewed-by: Ard Biesheuvel <a...@kernel.org>


  Commit: 8e934ab9562a33191af21ce3babf1ad37a3cdc34
      
https://github.com/tianocore/edk2/commit/8e934ab9562a33191af21ce3babf1ad37a3cdc34
  Author: Sami Mujawar <sami.muja...@arm.com>
  Date:   2023-05-29 (Mon, 29 May 2023)

  Changed paths:
    M ArmVirtPkg/ArmVirtKvmTool.dsc
    M ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c
    M ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf

  Log Message:
  -----------
  ArmVirtPkg: Dispatch variable service if variable emulation is enabled

The VariableRuntimeDxe links with NvVarStoreFormattedLib which is
required to establish the dependency on OvmfPkg\VirtNorFlashDxe.
The VirtNorFlashDxe installs the gEdkiiNvVarStoreFormattedGuid to
indicate it has finished initialising the flash variable storage
and that the variable service can be dispatched.

However, the kvmtool guest firmware dynamically detects if CFI
flash is absent and sets PcdEmuVariableNvModeEnable to TRUE
indicating emulated runtime variable must be used. Therefore,
in this scenario install the gEdkiiNvVarStoreFormattedGuid so
that the variable service can be dispatched.

Also link the NorFlashKvmtoolLib as a NULL library so that
it can discover if the CFI flash is absent and setup the PCD
PcdEmuVariableNvModeEnable. This is required in case the
NorFlashDxe is not yet dispatched.

Signed-off-by: Sami Mujawar <sami.muja...@arm.com>
Reviewed-by: Ard Biesheuvel <a...@kernel.org>


Compare: https://github.com/tianocore/edk2/compare/04c5b3023e49...8e934ab9562a


_______________________________________________
edk2-commits mailing list
edk2-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to