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

ImmutAfterInit: misuse runtime detection #2

Merged
merged 4 commits into from
Jun 19, 2023

Commits on Jun 13, 2023

  1. mm/address_space: avoid double initialization of kernel mapping

    ImmutAfterInitCell states that the init() method should not be called
    on an already initialized instance, but KERNEL_MAPPING is initialized
    via ImmutAfterInitCell::new() first, and then via the aforementioned
    init() method. At the moment this requirement is not enforced in any
    way,(ImmutAfterInitCell::reinit() just calls init()), but this will
    not hold in the future.
    
    Create the global structure with ImmutAfterInitCell::uninit(), since
    there should be no users of the mapping before the call to
    init_kernel_mapping_info(), which happens very early in the boot
    process for both the stage 2 and the proper SVSM.
    
    Signed-off-by: Carlos López <carlos.lopez@suse.com>
    00xc committed Jun 13, 2023
    Configuration menu
    Copy the full SHA
    9a2c69b View commit details
    Browse the repository at this point in the history
  2. utils/immut_after_init: implement runtime checks

    Add debug-only runtime checks for ImmutAfterInitCell. This prevents
    using an uninitialized cell, as well as unintended double
    initialization bugs. As a consequence, ImmutAfterInitCell::init() and
    reinit() no longer need to be unsafe, since checks are done before
    accessing the inner type.
    
    To keep track of the initialization state we use an AtomicBool with
    relaxed ordering, for code simplicity reasons.
    
    Signed-off-by: Carlos López <carlos.lopez@suse.com>
    00xc committed Jun 13, 2023
    Configuration menu
    Copy the full SHA
    7ab5d6b View commit details
    Browse the repository at this point in the history
  3. utils/immut_after_init: mark results as infallible in release builds

    No safety runtime checks are performed in release builds, so mark the
    error variant of the return type for failable functions as
    core::convert::Infallible.
    
    Signed-off-by: Carlos López <carlos.lopez@suse.com>
    00xc committed Jun 13, 2023
    Configuration menu
    Copy the full SHA
    2f62196 View commit details
    Browse the repository at this point in the history

Commits on Jun 14, 2023

  1. utils/immut_after_init: relax Copy requirements

    Remove the Copy requirement for any T under the ImmutAfterInit* types,
    since it is not needed.
    
    Signed-off-by: Carlos López <carlos.lopez@suse.com>
    00xc committed Jun 14, 2023
    Configuration menu
    Copy the full SHA
    10b7610 View commit details
    Browse the repository at this point in the history