Skip to content

Commit

Permalink
OvmfPkg/RiscVVirt: Check "no-map" and mark EfiReservedMemoryType
Browse files Browse the repository at this point in the history
OpenSBI now marks PMP regions with "no-map" attribute.
So, remove the workaround and add the ReservedMemory only
when no-map is set so that it follows DT spec.

Cc: Ard Biesheuvel <[email protected]>
Cc: Jiewen Yao <[email protected]>
Cc: Jordan Justen <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Andrei Warkentin <[email protected]>

Signed-off-by: Sunil V L <[email protected]>
Reviewed-by: Ranbir Singh <[email protected]>
  • Loading branch information
vlsunil authored and mergify[bot] committed Jul 21, 2023
1 parent c6b5129 commit 7427dd3
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions OvmfPkg/RiscVVirt/Sec/Memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,10 @@ GetNumCells (

/** Mark reserved memory ranges in the EFI memory map
The M-mode firmware ranges should not be used by the
EDK2/OS. These ranges are passed via device tree using reserved
memory nodes. Parse the DT and mark those ranges as of
type EfiReservedMemoryType.
NOTE: Device Tree spec section 3.5.4 says reserved memory regions
without no-map property should be installed as EfiBootServicesData.
As per UEFI spec, memory of type EfiBootServicesData can be used
by the OS after ExitBootServices().
This is not an issue for DT since OS can parse the DT also along
with EFI memory map and avoid using these ranges. But with ACPI,
there is no such mechanisms possible.
Since EDK2 needs to support both DT and ACPI, we are deviating
from the DT spec and marking all reserved memory ranges as
EfiReservedMemoryType itself irrespective of no-map.
* As per DT spec v0.4 Section 3.5.4,
* "Reserved regions with the no-map property must be listed in the
* memory map with type EfiReservedMemoryType. All other reserved
* regions must be listed with type EfiBootServicesData."
@param FdtPointer Pointer to FDT
Expand Down Expand Up @@ -228,11 +217,19 @@ AddReservedMemoryMap (
Size
));

BuildMemoryAllocationHob (
Addr,
Size,
EfiReservedMemoryType
);
if (fdt_getprop (FdtPointer, SubNode, "no-map", &Len)) {
BuildMemoryAllocationHob (
Addr,
Size,
EfiReservedMemoryType
);
} else {
BuildMemoryAllocationHob (
Addr,
Size,
EfiBootServicesData
);
}
}
}
}
Expand Down

0 comments on commit 7427dd3

Please sign in to comment.