-
Notifications
You must be signed in to change notification settings - Fork 162
Description
Describe the bug
Physical memory allocations requested via the .place_phys memory attribute cannot span across platform-defined memory region boundaries.
When an allocation request overlaps the boundary between two mem_region entries, the allocation fails without error, warning, or diagnostic output, leaving the caller unaware of the failure.
For example, on the Raspberry Pi 4 the platform description may define two memory regions:
.cpu_num = 4,
.region_num = (RPI4_MEM_GB > 1) ? 2 : 1,
.regions = (struct mem_region[]) {
{
.base = 0x80000,
.size = 0x40000000 - 0x80000 - 0x4c00000,
},
{
.base = 0x40000000,
.size = ((RPI4_MEM_GB - 1) * 0x40000000ULL) - 0x4000000,
},
},If a .place_phys allocation request covers the 0x40000000 boundary (e.g., a region that begins below 0x40000000 and extends past it), the allocation:
- does not occur for the portion over the first memory region
- does not report any error to the user
Expected behavior
-
Allocations that span multiple
mem_regionentries should either:- be correctly split/handled internally, or
- be explicitly rejected with a clear error message
-
Silent failures should be replaced with proper diagnostics or error returns
Impact
- Debugging becomes extremely difficult due to lack of feedback
- Platform descriptions using disjoint memory regions (e.g., >1GB RPI4 configurations) silently break valid physical placement requests
Steps to reproduce
- Use a platform description that defines multiple memory regions (such as RPI4 with >1GB)
- Request a
.place_physallocation whose range crosses amem_regionboundary - Observe that memory over the first memory region range is not allocated and no error is reported
Proposed fix / suggestions
At minimum, the system should:
-
Detect allocations that cross region boundaries
-
Emit an error such as:
ERROR: place_phys allocation spans multiple platform memory regions, which is not supported. Requested range: 0xXXXXXXXX – 0xXXXXXXXX Platform regions: [0] 0xXXXXXXXX – 0xXXXXXXXX [1] 0xXXXXXXXX – 0xXXXXXXXX -
Or implement support for splitting physical allocations accordingly