| Age | Commit message (Collapse) | Author | Files | Lines |
|
Update the Brotli submodule to v1.2.1
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
|
|
Commit cec2c6bbccf7 ("MdeModulePkg: Always Initialize Separate Exception
Stacks") made DxeMain() call InitializeSeparateExceptionStacks()
regardless of PcdCpuStackGuard. This only ever runs on the BSP, and it
loads TR.
This cannot be undone: LTR does not accept a NULL selector, and so the
BSP will hand over control to the OS loader with a non-NULL TR. This
breaks the Windows Server 2016 hypervisor, which is launched by winload
when Credential Guard or virtualization based security is enabled: the
system gets stuck in a reset loop as soon as winload transfers control
to the hypervisor.
So restore the PcdCpuStackGuard check, so that platforms that do not
enable stack guard hand over control to the OS loader with TR in its
reset state, as they did before. This complements the corresponding
change to CpuMpPei and CpuDxe, which load TR on the BSP as well.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
|
Some compilers treat EFI_MEMORY_TYPE as signed. OS-reserved memory
types with bit 31 set can therefore pass a signed comparison against
EfiMaxMemoryType and index outside the memory type statistics array.
Cast the memory type to UINT32 before checking the array bound in
CoreTerminateMemoryMap and InternalBuildMemoryAllocationHob, matching
the existing guards in the page, pool, and memory bin code.
Fixes: https://github.com/tianocore/edk2/issues/13451
Signed-off-by: Mattia Giambirtone <nocturn9x@nocturn9x.space>
|
|
This reverts commit 0e7dad44bae663193b580adeb9d942c2559166f6.
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
|
|
This reverts commit 0d61209231b2ec50ca6f6b96825baaa07c280854.
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
|
|
Three DEBUG messages in CapsulePei print capsule addresses: the coalesce
memory range, the free memory range, and the capsule copy source and
destination. All three used the "0x%8X" format specifier with UINTN
arguments. On X64, this truncates the printed value to 32 bits, so when
the capsule coalesce buffer is allocated above 4GB, the logs show a
misleading address.
Change these messages to use the "0x%lX" specifier and cast the
arguments to UINT64 so that the full 64-bit address and size are printed
on X64 while remaining correct on IA32.
Signed-off-by: Phil Noh <Phil.Noh@amd.com>
|
|
Remove the duplicate OptionOrder free on reallocation failure in
EfiBootManagerGetLoadOptions().
Signed-off-by: Anbazhagan Baraneedharan <anbazhagan@hp.com>
|
|
Free the previous GOP device path pool only once when the recursive
search returns a path to append. If it returns NULL, preserve paths
collected from earlier children instead of freeing the pool.
Signed-off-by: Anbazhagan Baraneedharan <anbazhagan@hp.com>
|
|
The existing ArmCcaLib instance uses GUID HOBs to read the cached
IsRealm status and Realm IPA width. This does not work during early SEC
execution, where GetHobList() can fail because the HOB list has not yet
been set up.
Split the direct RSI query helpers into common code and add an early
ArmCcaLib instance for SEC and PEI users. The early instance implements
ArmCcaIsRealm() and ArmCcaGetIpaWidth() by querying RSI directly,
without relying on cached HOB data.
Keep the existing ArmCcaLib instance for DXE and later phases, where the
cached HOB values can be used. Also make ArmCcaMemRangeIsProtectedMmio()
return RETURN_UNSUPPORTED when called outside a Realm.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
|
|
Current `gSmmCorePrivate` data used in PiSmmCore is a shared data
structure initialized and used by PiSmmIpl. Thus the content is exposed
to normal DXE environment.
Specifically, `SmmDispatcher` actively uses `gSmmCorePrivate` to
determine dispatch behavior. As a result, the potential attack surface is
exposed from SMM initialization through the SMM Ready-to-Lock event.
This change decouple Core private data from and IPL mailbox at the
entrypoint of each MMI handle routine. It is a preventative fix to
eliminate hot access to gSmmCorePrivate within the SMM core.
Signed-off-by: Kun Qin <kun.qin@microsoft.com>
|
|
Replace HandleProtocol with OpenProtocol using
EFI_OPEN_PROTOCOL_GET_PROTOCOL in SmmCorePerformanceLib.
Signed-off-by: Anbazhagan Baraneedharan <anbazhagan@hp.com>
|
|
SMM images without embedded PDB paths trigger a UI-name fallback
that incorrectly treats PiSmmCore's private-context pointer as a
DXE image handle, causing an assertion or invalid memory access.
Read the UI section from the target image's firmware-volume
DeviceHandle instead.
Signed-off-by: Anbazhagan Baraneedharan <anbazhagan@hp.com>
|
|
Add a PEI Core host-test target and register it in
MdeModulePkgHostTest.dsc. Cover Temporary Memory reuse after
PeiFreePages(), search suppression without free events, active-range
priority during a pending stack switch, and Permanent Memory top-down
ordering.
Test early best-fit selection, padding-HOB reuse, and aligned 4 KiB,
16 KiB, and 64 KiB allocation. Cover invalid memory types and unrestricted
fallback for out-of-PHIT and adjacent coalesced HOBs. Verify final-fallback
best-fit and HOB-list tie order. Skip padding-HOB integration when runtime
granularity is no larger than default.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
|
|
Track TemporaryMemoryPagesFreed in PEI_CORE_INSTANCE. Set it after a
successful PeiFreePages() call while PEI uses Temporary Memory or creation
of an alignment-padding HOB, and leave it set after ranges are reused.
When PEI uses Temporary Memory and PeiMemoryInstalled and
SwitchStackSignal are FALSE, search conventional-memory allocation HOBs
before consuming the active top-down range. Select the smallest suitable
HOB, preserve HOB-list order for ties, and merge adjacent free HOBs on
demand when no candidate fits. Share the best-fit helper with the final
unrestricted fallback.
While the stack switch to Permanent Memory is pending, suppress the early
search and use the active physical-memory range first. Preserve Permanent
Memory top-down/bin-first priority and the existing unrestricted fallback.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
|
|
The Enhanced Allocation capability of a PCI-PCI bridge carries an
additional DWORD describing the fixed secondary and subordinate bus
numbers used by the bridge, if it does not rely on its bus number
registers. Such a bridge only forwards configuration transactions for
its fixed bus numbers, and so they must be assigned to it during bus
enumeration.
Record the fixed bus numbers when parsing the EA capability, and assign
them in PciScanBus () instead of allocating the next available bus
number. The buses below the bridge are numbered from its fixed secondary
bus number onwards, and the entire fixed range is consumed, regardless
of how many buses are actually in use below the bridge. Hot plug bus
padding does not apply to such bridges.
As bus numbers are assigned in ascending order, the fixed bus numbers
cannot be honoured if they have already been assigned to another
bridge, if they are not covered by a single bus number range of the root
bridge, or if they are not nested inside the fixed bus numbers of an
upstream bridge. In this case, do not scan behind the bridge, and set
its primary bus number to an invalid value, so that the device info
collector pass does not scan behind it either: its bus number registers
are likely hardwired, and so the hierarchy behind it may remain visible
on buses that are assigned to other bridges.
Report an error if buses below a bridge with fixed bus numbers end up
outside of its fixed range, as those will be unreachable.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
|
A PCI-PCI bridge that implements the Enhanced Allocation (EA) capability
may use entries with BEI 6 to describe fixed I/O, memory and prefetchable
memory ranges that it forwards to its secondary side, regardless of the
contents of its Base/Limit registers.
So record such windows when parsing the EA capability of a bridge, and
treat the corresponding decodes as supported so that resources are not
degraded to a different type on account of the Base/Limit registers not
being implemented.
When calculating the aperture of such a bridge window, pin it to the fixed
range. Fixed resources below the bridge must reside inside that range, and
are dropped otherwise. Relocatable resources are placed inside the range at
the offsets calculated for them, provided that the window does not hold any
fixed resources, and is large enough, suitably aligned and, if it resides
above 4 GB, only covers resources that may be placed above 4 GB. Otherwise,
they are dropped.
Pinned EA windows are not programmed into the Base/Limit registers, and
propagate upwards as fixed resources, like any other pinned bridge window.
The on-chip bridges of some SoCs (e.g., Cavium/Marvell ThunderX family)
implement the EA capability only to describe their fixed bus numbers, and
carry no BEI 6 entries at all. The fixed BARs below such bridges are 64-bit
non-prefetchable ranges above 4 GB, and those below different bridges are
interleaved, as each device has BARs in multiple distinct regions. Covering
them with pinned windows does not work: the 32-bit non-prefetchable window
cannot describe them, and the pinned windows of sibling bridges overlap.
Evidently, such bridges forward the fixed ranges below them regardless of
their Base/Limit registers.
So assume that a bridge that implements the EA capability but has no BEI 6
entry for a certain type of window passes through the fixed resources of
that type below it: move them to the resource nodes of the upstream bus,
restoring the original BAR type of fixed device resources, and leave the
bridge window to the relocatable resources below it, if any. Bridges that
do not implement the EA capability are unaffected.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
|
After submitting the resource requirements for a root bridge, pass the
fixed ranges below it to the host bridge driver via the EDKII PCI Host
Bridge Fixed Resource protocol, if it is implemented. These are the fixed
BARs of devices on the root bus, and the pinned windows of PCI-PCI bridges
that cover fixed BARs further down the hierarchy.
If the protocol is not implemented, log the fixed ranges, as they need to
be reserved by the platform in that case.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
|
Implement the EDKII PCI Host Bridge Fixed Resource protocol, and install
it alongside the resource allocation protocol.
Fixed ranges submitted for a root bridge are validated against its
apertures, and claimed in GCD at their host address before any of the
root bridge windows are allocated, so that the allocator will steer clear
of them. Failure to claim a range is not treated as an error, given that
the platform may have reserved it already. The claimed ranges are released
again when the resources are freed or the enumeration is restarted.
The fixed ranges are appended to the resource descriptors returned by the
root bridge's Configuration () method, which permits the PCI bus driver to
resolve the translation offset for BARs that decode a fixed range.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
|
Introduce a protocol that permits the PCI bus driver to inform the PCI
host bridge driver about ranges below a root bridge that are decoded at a
fixed address, e.g., BARs described by an Enhanced Allocation capability,
or PCI-PCI bridge windows that cover them.
The host bridge driver is expected to keep these ranges clear when
allocating the root bridge windows, and to report them via the
Configuration () method of the root bridge I/O protocol, so that
translation offsets can be resolved for them.
The protocol is optional: in its absence, the platform is expected to
reserve such fixed ranges itself.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
|
BARs described by an Enhanced Allocation capability decode a fixed address
range, and so they must be excluded from the ordinary resource allocation,
which assigns relocatable ranges by packing BARs at offsets from the base
of the enclosing window.
So represent such BARs as fixed resource nodes, which are not taken into
account when calculating the size of the enclosing window, and which are
not programmed into the BAR registers.
A PCI-PCI bridge window that covers fixed resource nodes must itself be
pinned to a range that covers all of them. Relocatable resources of the
same type below such a bridge cannot be accommodated, and are dropped with
an error. The pinned windows are programmed before the rest of the
hierarchy, and are propagated upwards as fixed nodes.
Finally, permit PciIo to fall back to a translation offset of 0 for fixed
BARs that are not covered by any of the root bridge's resource windows,
given that the platform may have reserved these ranges by other means.
Fixed resources don't occupy any of the relocatable aperture of the
enclosing window, and so a window or root bridge resource pool that only
holds fixed resources does not request any resources. So don't submit a
resource request for it, and don't treat the absence of an allocated base
as an error when programming the resources below it. This is the case,
e.g., for root bridges whose devices only have fixed BARs.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
|
Devices that implement the PCI Enhanced Allocation (EA) capability may
have BARs that are hardwired to a fixed address range, and that cannot be
sized or relocated via the ordinary BAR registers.
So when gathering device and PCI-PCI bridge information, parse the EA
capability if it exists, and use each enabled entry for BEI 0-5 (0-1 for
bridges) to override the information obtained from the corresponding BAR:
record the fixed base address and size, and mark the BAR as having a fixed
address, so that the resource allocator can take this into account.
Do the same after resizable BARs have been adjusted, as this re-parses the
BAR registers, and ensure that UpdatePciInfo () leaves such BARs alone.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
|
Currently, PciOperateRegister() unconditionally writes to the target PCI
configuration register (Command or Bridge Control) on
EFI_ENABLE_REGISTER and EFI_DISABLE_REGISTER operations even when the
requested bits are already in the target state or when Command is 0.
Similarly, PciIoAttributes() unconditionally invokes
PCI_ENABLE_COMMAND_REGISTER() and PCI_DISABLE_COMMAND_REGISTER() even
when Command is 0 (unlike BridgeControl, which is guarded by
BridgeControl != 0), and unconditionally recurses into
UpStreamBridge->PciIo.Attributes() even when UpStreamAttributes is 0
(such as when enabling IO, MEMORY, or BUS_MASTER on an endpoint).
Under virtualization (especially confidential computing environments
such as AMD SEV-SNP and Intel TDX), every PCI configuration space read
or write traps to the hypervisor. Update PciOperateRegister() to skip
no-op register reads/writes when Command is 0 or when the register value
is unchanged, and update PciIoAttributes() to guard Command register
updates and upstream bridge recursion on non-zero masks.
Suggested-by: Ard Biesheuvel <ardb+tianocore@kernel.org>
Signed-off-by: Kevin Loughlin <kevinloughlin@google.com>
|
|
Follow JESD216H 6.4.19, DWORD 16
Introduce Enter4Byte/Exit4Byte In SpiNorFlashJedecSfdp And SpiNorFlash
Fixes: #13171
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Vincent Ke <vincentke@ami.com>
|
|
Add support for loading logos from FREEFORM FFS files identified by
PcdLogoFileGuid. When the PCD is zero or invalid, preserve the
existing HII-based logo loading path.
When the PCD is valid non-zero, select the logo from the corresponding RAW
FFS file in the firmware volume, including compressed and uncompressed
section layouts.
Key Difference
- LogoDxe: HII fallback always works (embedded logo available)
- LogoFfsDxe: HII fallback returns EFI_NOT_FOUND (no embedded logo)
Update LogoDxe file descriptions, copyright notices, include ordering,
and INF annotations. Consolidate module includes into single shared
header.
Signed-off-by: Thamballi Sreelalitha <sreelali@qti.qualcomm.com>
|
|
Several places in MdeModulePkg were implementing their
own versions of hex dumping logic; use the DebugLib.h
macro instead.
Prints change slightly, they are now standardized with
uppercase hex, prefixes on every row instead of in the
header only, and VarCheckHiiLib no longer indents rows
with *ASCII*.
Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
|
|
Add debug verification for Resource Descriptor HOBs. Parse both v1
and v2 Resource Descriptor HOBs, and warn about overlapping ranges.
Check I/O resources separately from memory and MMIO resources.
Print the complete GCD memory space map starting at address zero and
represent any gaps as non-existent memory with
These changes are for debug purposes only. Examining the debug output
will enable a platform owner to view overlapping resource hobs, and
show gaps in the memory map based upon input from the PEI phase.
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
|
|
Add IS_RESOURCE_DESCRIPTOR_HOB() and GET_RESOURCE_HOB_ATTRIBUTE()
macros to handle both EFI_HOB_TYPE_RESOURCE_DESCRIPTOR and
EFI_HOB_TYPE_RESOURCE_DESCRIPTOR2 HOB types. Resource Descriptor v2
HOBs use ResourceCapabilities instead of ResourceAttribute, so they
cannot be accessed through the same union member.
Update consumers of ResourceDescriptorHobs to understand both
EFI_HOB_TYPE_RESOURCE_DESCRIPTOR and EFI_HOB_TYPE_RESOURCE_DESCRIPTOR2.
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
|
|
Enable printing EFI_HOB_TYPE_RESOURCE_DESCRIPTOR2 type hobs
from HobPrintLib.
PrintResourceDiscriptorHob was misspelled.
While adding Descriptor2 support, fix up spelling of Descriptor
in existing function.
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
|
|
Add BuildResourceDescriptor2Hob to HobLib implementations
as described in PI 1.10 specification.
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
|
|
UsbGetDevBosDesc() allocates a buffer for the initial BOS descriptor
request. If that request fails, the success-only cleanup is skipped and
the function returns without freeing the buffer. Repeated enumeration
attempts can leak one allocation per failure.
Free the initial buffer before returning the transfer error.
The leaking retrieval helper was introduced by PR #12714:
https://github.com/tianocore/edk2/pull/12714
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
|
|
UsbIsSSDevice() trusts device-reported NumDeviceCaps and capability
Length fields without bounding reads to the BOS buffer. Malformed values
can cause out-of-bounds reads and an exception during device enumeration.
Validate the BOS header and total length. Before reading each capability,
check that its header and declared length fit in the remaining bytes.
Reject malformed or truncated descriptors and recognize SuperSpeed only
after validating the complete capability list.
The unbounded parser was introduced by PR #12714:
https://github.com/tianocore/edk2/pull/12714
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
|
|
UsbEnumerateNewDev() frees DevDesc before resetting the port for an
enumeration retry. UsbRootHubResetPort() scans that device during the
reset and previously dereferenced DevDesc without checking it.
For a SuperSpeed-capable device running below SuperSpeed, IsSSDev and
Speed still satisfy the scan's preceding conditions after DevDesc is
cleared. The DeviceClass access can therefore cause a null-pointer
exception. Add descriptor checks before those dereferences and clear
IsSSDev when freeing the descriptor.
The unsafe reset dereference was introduced by PR #12714:
https://github.com/tianocore/edk2/pull/12714
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
|
|
Test valid SuperSpeed recognition and reject capabilities extending beyond
the BOS total length or supplied buffer. Verify failed initial BOS reads
free their buffers and root-hub reset succeeds after descriptor cleanup.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
|
|
TimestampDxe only declares IA32, X64 and EBC as valid architectures.
This restriction is a leftover from when the driver was introduced and
no longer reflects reality: the driver is plain C on top of TimerLib
and the protocol it produces is not architecture specific, so it builds
and works on every architecture edk2 supports.
Use ANY instead of enumerating architectures, so the comment cannot go
out of date again when further architectures are added.
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
|
|
A blank (unwritten) optical disc reports a zero capacity through READ
CAPACITY (LastBlock == 0). The driver currently exposes such a device
with BlockSize 2048 and LastBlock 0, so upper layers such as PartitionDxe
and the BDS removable-media boot probe keep reading LBA 0. The drive
rejects the read with "Illegal Request / LBA out of range" (sense 5/21/0)
and UsbMassReadBlocks enters its reset recovery loop. So each failed probe
can block for tens of seconds and boot appears to hang.
Treat an optical device with zero capacity as media absent so that the
media is skipped instead of being probed.
Signed-off-by: Haword <zhenghaowei@loongson.cn>
|
|
Correct "#lauguage" to "#language" in the fr-FR entry of STR_NULL.
Signed-off-by: Wolf Hess <hailrake99@yandex.ru>
|
|
Memory leak anytime the FormatNvm function is called.
Signed-off-by: Sean Brogan <sebrogan@microsoft.com>
|
|
LastBlock field is inclusive.
To lower confusion it should be initialized to the intended
value which was to create metadata for an 8mb disk.
Signed-off-by: Sean Brogan <sebrogan@microsoft.com>
|
|
NamespaceData was allocated, zeroed, and never modifed.
Then it was copied over another buffer that was already zero.
Then it was leaked.
Remove local variable NamespaceData and the associated code.
Signed-off-by: Sean Brogan <sebrogan@microsoft.com>
|
|
Add tests for MediaClear functions in the Nvme Media Sanitize Unit tests
Signed-off-by: Sean Brogan <sebrogan@microsoft.com>
|
|
Replace hardcoded PCI configuration-space offsets with the type-safe
macros from MdePkg/Include/IndustryStandard/Pci22.h. This removes magic
numbers from the PciBus driver and makes the code easier to read and
maintain. No functional change.
1. MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
- GatherDeviceInfo() / InitializePciDevice(): use
PCI_BASE_ADDRESSREG_OFFSET and PCI_BASE_ADDRESSREG5_OFFSET as the
BAR scan loop bounds instead of 0x10/0x24.
- GatherPpbInfo(): use PCI_BASE_ADDRESSREG_OFFSET /
PCI_BASE_ADDRESSREG1_OFFSET for the two PPB BARs, and the
PCI_BRIDGE_* offset macros instead of 0x1C/0x24/0x28.
- GatherP2CInfo(): use PCI_BASE_ADDRESSREG_OFFSET instead of 0x10
for the CardBus bridge BAR.
- InitializePpb(): use the PCI_BRIDGE_* offset macros instead of
hardcoded offsets (0x1C/0x1D/0x20/0x22/0x24/0x26/0x28/0x2C/0x30/0x32)
when initializing the I/O, 32-bit memory, and 64-bit memory windows
to their disabled state (base set to all-ones, limit to all-zeros).
- IsPciDeviceRejected(): use PCI_CARD_MEMORY_BASE_0,
PCI_CARD_IO_BASE_0_LOWER, and PCI_CARD_IO_LIMIT_1_LOWER in place of
0x1C/0x2C/0x38 for the CardBus BAR scan, and
PCI_BASE_ADDRESSREG1_OFFSET / PCI_BASE_ADDRESSREG5_OFFSET instead of
0x14/0x24 for the standard PCI BAR scan.
- ResetAllPpbBusNumber(): use PCI_BRIDGE_PRIMARY_BUS_REGISTER_OFFSET
instead of 0x18.
2. MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
- Use PCI_BASE_ADDRESSREG_OFFSET / PCI_BASE_ADDRESSREG5_OFFSET as the
BAR scan loop bounds instead of 0x10/0x24.
3. MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
- ProgramPpbAperture(): replace hardcoded PCI bridge aperture offsets
with the PCI_BRIDGE_* macros in the PPB_IO_RANGE, PPB_MEM32_RANGE,
PPB_PMEM32_RANGE, and PPB_PMEM64_RANGE cases.
4. MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
- Use PCI_BRIDGE_PRIMARY_BUS_REGISTER_OFFSET,
PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET, and
PCI_BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET instead of 0x18/0x19/0x1A
when programming and reading the bridge bus-number registers.
5. MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
- Use PCI_INT_LINE_OFFSET instead of 0x3C when writing the device
Interrupt Line register to 0xFF (no connection / unknown).
References:
- PCI Local Bus Specification, Revision 2.2
- PCI-to-PCI Bridge Architecture Specification, Revision 1.2
- PCI Express Base Specification, Revision 7.0
Cc: Sachin Ganesh <sachinganesh@ami.com>
Cc: Dhanaraj V <vdhanaraj@ami.com>
Cc: Sergiy Yakovlev <sergiyy@ami.com>
Cc: Dhiinesh M <dhiineshm@ami.com>
Signed-off-by: Varun G <varung@ami.com>
|
|
Add host-based Google Test coverage for PciParseBar() and
PciIovParseVfBar().
Cover absent BARs, 16-bit and 32-bit I/O BARs, 32-bit memory BARs, and
64-bit memory BARs. Also verify that a resource following a 64-bit BAR
retains its physical BAR number because the upper DWORD consumes the
intermediate BAR register.
Add equivalent SR-IOV VF BAR coverage, including InitialVFs length
scaling, system page alignment, 64-bit VF BAR parsing, and physical VF
BAR numbering after a 64-bit VF BAR.
Provide test-only PCI configuration access and boot service mocks.
Stub unrelated PciBusDxe dependencies pulled in by
PciEnumeratorSupport.c, and register the test application in
MdeModulePkgHostTest.dsc.
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
|
|
PCI BARs are by six consecutive 32-bit configurationv registers. 64-bit
BARs consume two of those registers: the first contains the low address
bits and the second contains the high address bits. These are
represented in the private PCI_IO_DEVICE as PciBar[PCI_MAX_BAR] and
VfPciBar[PCI_MAX_BAR].
PciBusDxe previously maintained a separate BarIndex while walking the
configuration registers. PciParseBar() and PciIovParseVfBar() advance
the configuration offset by two registers when parsing a 64-bit BAR,
but their callers incremented BarIndex only once. As a result, every
BAR following a 64-bit BAR was stored in the preceding array entry. For
example, a BAR at offset 0x18 following a 64-bit BAR at offset 0x10 was
recorded as PciBar[1] instead of PciBar[2].
This breaks the invariant that PciBar[Index] and VfPciBar[Index]
describe the corresponding physical BAR register. It can cause later
resource handling and diagnostics to associate a BAR with the wrong
hardware slot. VF BAR programming retained the configuration offset in
each entry, which could mask the problem, but its array and resource
node indices were still incorrect.
Derive the BAR index directly from the configuration offset in both
parsers. Remove the redundant BarIndex parameters and let each caller
advance using the offset returned by the parser. This preserves holes
for the upper DWORDs of 64-bit BARs and keeps conventional and SR-IOV
VF BAR numbering aligned with the hardware configuration space.
Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
|
|
Add only grouped notify events to gEventSignalQueue so event group signaling does not scan unrelated events.
Ungrouped EVT_NOTIFY_SIGNAL events are dispatched directly by CoreSignalEvent() and do not need to be visited by CoreNotifySignalList().
Signed-off-by: Sureshkumar Ponnusamy <sponnusamy@microsoft.com>
|
|
InsertResourceNode() keeps the resource list of a bridge sorted by
descending alignment. The new node is inserted at the head of the list
and then moved towards the tail, but it stops in front of the first
node that it does not need to follow. Resources that rank equal, such
as BARs of the same size, therefore end up in the reverse order of
their discovery (LIFO), and the last discovered one is assigned the
lowest address.
Linux also sorts the resources by descending alignment in
pdev_sort_resources() (drivers/pci/setup-bus.c), but it inserts a new
resource after all the resources with the same alignment, so these
keep their discovery order (FIFO).
When the OS reassigns the PCI resources instead of keeping the firmware
assignment (for example Linux on ARM64 ACPI systems, unless the
firmware requests to preserve the PCI boot configuration through _DSM
function 5), this difference makes it swap the addresses of equally
sized BARs. While doing so, a BAR is temporarily programmed with a
range that is still decoded by another device, which is not handled by
some platforms, such as VMMs that do not allow overlapping BARs.
Insert the new node at the tail of the list and move it towards the
head instead, swapping the roles of the two compared nodes, so that
resources that rank equal keep their discovery order, consistent with
Linux.
Resources with the same alignment are also sorted by the remainder of
their length modulo the alignment. In practice, the remainder is only
non-zero for the window of a child bridge, whose length is a multiple
of the window granularity but whose alignment is the largest alignment
of the resources behind it. Such a window leaves a gap in front of the
next resource with the same alignment, so resources without a remainder
should come first. However, the check only ranks a zero remainder first
for the node that is being inserted, not for the existing node that it
is compared with, so the relative order of windows with and without a
remainder also depends on the insertion order. Reversing it can waste
address space. For example, on QEMU q35 with three PCIe root ports,
where the first one has a 3 MB MMIO window aligned to 2 MB and the
other two have a 2 MB window, the 3 MB window would be placed first,
leaving a 1 MB gap and growing the MMIO32 aperture of the root bridge
from 8 MB to 9 MB.
Therefore, rank a zero remainder first for both compared nodes.
Resources without a remainder now always come first, regardless of the
discovery order, which never increases the size of the aperture, and
only resources that rank equal are ordered by their discovery. Update
the description of InsertResourceNode() to document the full ordering.
Signed-off-by: Shubham Aggarwal <shubagga@google.com>
|
|
The function CoreInstallProtocolInterfaceNotify() checks if the protocol
already installed on handle by using HandleProtocol(). And later
HandleProtocol() calls OpenProtocol(). If it is determined that protocol
is present on handle, the protocol is being left open which could leak
internal resources.
This change replaces HandleProtocol() with OpenProtocol() with test
attribute, thus no CloseProtocol() is required.
Signed-off-by: Khalid Ali <khaliidcaliy@gmail.com>
|
|
PR #12829 added an early return when LocateHandleBuffer() failed
during short-form hard drive device path expansion. On a fast boot,
a miss in the HDDP cache can occur before Block I/O handles are
available, so the return bypassed EfiBootManagerConnectAll() and
prevented the fallback search from finding the device.
Continue with an empty handle list after the lookup failure. This lets
the existing path connect all controllers and retry the Block I/O search.
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
|
|
REF:https://github.com/tianocore/edk2/issues/10727
Signed-off-by: Kanagavel <kanagavels@ami.com>
On branch Kanagavel/MdeModulePkg
|
|
Commit ee58614bbb ("MdeModulePkg/ScsiDiskDxe: Check Write Caching and
FUA support") added a best-effort FUA-support query to
ScsiDiskDetectMedia(). It issues a MODE SENSE(10) for the Caching mode
page via ScsiDiskFuaMode() and assigns the result to the function's
shared Status variable.
When the device rejects that command, Status is left as
EFI_DEVICE_ERROR and falls through to the function's return, even
though the media was already detected successfully (capacity read,
media present). Callers treat this as fatal:
ScsiDiskDriverBindingStart() skips installing Block I/O, and
ScsiDiskReadBlocks()/WriteBlocks() return EFI_DEVICE_ERROR. For
non-fixed devices DetectMedia() re-runs on every access, so the disk
is never usable.
This is observed on UFS (google/yaviks): the LUN answers the MODE
SENSE with a Target Failure ("UfsExecScsiCmds() fails with Target
Failure"), so a drive that was detected with edk2-stable202602 is no
longer detected with edk2-stable202605.
The FUA query is only used to refine ScsiDiskDevice->FuaMode, which
already defaults to TRUE (the prior always-set-FUA behavior). Its
failure must not affect media detection, so stop assigning its result
to Status and hoist the device-type check out of the retry loop.
Fixes: ee58614bbb ("MdeModulePkg/ScsiDiskDxe: Check Write Caching and
FUA support")
TEST=build/boot google/yaviks Chromebook with UFS, drive is detected
and bootable.
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
|
|
ArmCcaLib provides helper functions for detecting Realm execution state
and caching Realm IPA width. These helpers build on the architectural Arm
CCA RSI library and are not specific to ArmVirtPkg.
Therefore, move ArmCcaLib, ArmCcaLibNull, their public header, and related
GUID declarations to MdeModulePkg. Update ArmVirtPkg library mappings and
consumers to use the new MdeModulePkg library instances.
Also perform minor non-functional cleanup to the moved INF files by
fixing a comment typo and ordering the package dependencies.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
|