Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ppc64: Avoid restricted memory areas when allocating memory #152

Open
wants to merge 10 commits into
base: rhel-9.3.0
Choose a base branch
from

Commits on Dec 7, 2023

  1. kern/ieee1275/init/ppc64: Introduce a request for regions_claim()

    The regions_claim() function limits the allocation of memory regions
    by excluding certain memory areas from being used by GRUB. This for
    example includes a gap between 640MB and 768MB as well as an upper
    limit beyond which no memory may be used when an fadump is present.
    However, the ieee1275 loader for kernel and initrd currently does not
    use regions_claim() for memory allocation on PowerVM and KVM on Power
    and therefore may allocate memory in those areas that it should not use.
    
    To make the regions_claim() function more flexible and ultimately usable
    for the ieee1275 loader, introduce a request structure to pass various
    parameters to the regions_claim() function that describe the properties
    of requested memory chunks. In a first step, move the total and flags
    variables into this structure.
    
    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    Cc: Hari Bathini <[email protected]>
    Cc: Pavithra Prakash <[email protected]>
    Cc: Michael Ellerman <[email protected]>
    Cc: Carolyn Scherrer <[email protected]>
    Cc: Mahesh Salgaonkar <[email protected]>
    Cc: Sourabh Jain <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    d7169bc View commit details
    Browse the repository at this point in the history
  2. kern/ieee1275/init/ppc64: Decide by request whether to initialize region

    Let the regions_claim() request structure's init_region determine whether
    to call grub_mm_init_region() on it. This allows for adding memory to
    GRUB's memory heap if init_region is set to true, or direct usage of the
    memory otherwise. Set all current callers' init_region to true since they
    want to add memory regions to GRUB's heap.
    
    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    Cc: Hari Bathini <[email protected]>
    Cc: Pavithra Prakash <[email protected]>
    Cc: Michael Ellerman <[email protected]>
    Cc: Carolyn Scherrer <[email protected]>
    Cc: Mahesh Salgaonkar <[email protected]>
    Cc: Sourabh Jain <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    0d9ab5f View commit details
    Browse the repository at this point in the history
  3. kern/ieee1275/init/ppc64: Return allocated address using context

    Return the allocated address of the memory block in the request structure
    if a memory allocation was actually done. Leave the address untouched
    otherwise. This enables a caller who wants to use the allocated memory
    directly, rather than adding the memory to the heap, to see where memory
    was allocated. None of the current callers need this but the converted
    ieee1275 loader will make use of it.
    
    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    Cc: Hari Bathini <[email protected]>
    Cc: Pavithra Prakash <[email protected]>
    Cc: Michael Ellerman <[email protected]>
    Cc: Carolyn Scherrer <[email protected]>
    Cc: Mahesh Salgaonkar <[email protected]>
    Cc: Sourabh Jain <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    e13993a View commit details
    Browse the repository at this point in the history
  4. kern/ieee1275/init/ppc64: Add support for alignment requirements

    Add support for memory alignment requirements and adjust a candidate
    address to it before checking whether the block is large enough. This
    must be done in this order since the alignment adjustment can make
    a block smaller than what was requested.
    
    None of the current callers has memory alignment requirements but the
    ieee1275 loader for kernel and initrd will use it to convey them.
    
    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    Cc: Hari Bathini <[email protected]>
    Cc: Pavithra Prakash <[email protected]>
    Cc: Michael Ellerman <[email protected]>
    Cc: Carolyn Scherrer <[email protected]>
    Cc: Mahesh Salgaonkar <[email protected]>
    Cc: Sourabh Jain <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    5629bbf View commit details
    Browse the repository at this point in the history
  5. kern/ieee1275/init/ppc64: Rename regions_claim() to grub_regions_claim()

    Rename regions_claim() to grub_regions_claim() to make it available for
    memory allocation. The ieee1275 loader will use this function on PowerVM
    and KVM on Power and thus avoid usage of memory that it is not allowed
    to use.
    
    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    Cc: Hari Bathini <[email protected]>
    Cc: Pavithra Prakash <[email protected]>
    Cc: Michael Ellerman <[email protected]>
    Cc: Carolyn Scherrer <[email protected]>
    Cc: Mahesh Salgaonkar <[email protected]>
    Cc: Sourabh Jain <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    a9682bd View commit details
    Browse the repository at this point in the history
  6. kern/ieee1275/cmain/ppc64: Introduce flags to identify KVM and PowerVM

    Introduce flags to identify PowerVM and KVM on Power and set them where
    each type of host has been detected.
    
    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    Cc: Hari Bathini <[email protected]>
    Cc: Pavithra Prakash <[email protected]>
    Cc: Michael Ellerman <[email protected]>
    Cc: Carolyn Scherrer <[email protected]>
    Cc: Mahesh Salgaonkar <[email protected]>
    Cc: Sourabh Jain <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    dfa79a7 View commit details
    Browse the repository at this point in the history
  7. loader/powerpc/ieee1275: Use new allocation function for kernel and i…

    …nitrd
    
    On PowerVM and KVM on Power use the new memory allocation function that
    honors restrictions on which memory GRUB can actually use. In the request
    structure indicate the request for a single memory block along with
    address alignment restrictions. Request direct usage of the memory block
    by setting init_region to false (prevent it from being added to GRUB's
    heap). Initialize the found addr to -1, so that -1 will be returned
    to the loader in case no memory could be allocated.
    
    Report an out-of-memory error in case the initrd could not be loaded.
    
    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    Cc: Hari Bathini <[email protected]>
    Cc: Pavithra Prakash <[email protected]>
    Cc: Michael Ellerman <[email protected]>
    Cc: Carolyn Scherrer <[email protected]>
    Cc: Mahesh Salgaonkar <[email protected]>
    Cc: Sourabh Jain <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    f716e38 View commit details
    Browse the repository at this point in the history
  8. kern/ieee1275/ieee1275: Display successful memory claims when debugging

    Display successful memory claims with exact address and rounded-down
    MiB location and rounded-up size in MiB.
    
    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    Cc: Eric Snowberg <[email protected]>
    Cc: Hari Bathini <[email protected]>
    Cc: Pavithra Prakash <[email protected]>
    Cc: Michael Ellerman <[email protected]>
    Cc: Carolyn Scherrer <[email protected]>
    Cc: Mahesh Salgaonkar <[email protected]>
    Cc: Sourabh Jain <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    fadedec View commit details
    Browse the repository at this point in the history
  9. kern/ieee1275/init/ppc64: Fix a comment

    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    7dad85d View commit details
    Browse the repository at this point in the history
  10. kern/ieee1275/init/ppc64: Display upper_mem_limit when debugging

    Display upper_mem_limit and its rounded-down value in MiB.
    
    Signed-off-by: Stefan Berger <[email protected]>
    Reviewed-by: Daniel Kiper <[email protected]>
    stefanberger committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    9fd8ec0 View commit details
    Browse the repository at this point in the history