Skip to content

place_phys cannot allocate across platform memory region boundaries and fails silently #287

@DavidMCerdeira

Description

@DavidMCerdeira

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_region entries 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

  1. Use a platform description that defines multiple memory regions (such as RPI4 with >1GB)
  2. Request a .place_phys allocation whose range crosses a mem_region boundary
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions