• Sean Christopherson's avatar
    KVM: selftests: Automatically do init_ucall() for non-barebones VMs · dc88244b
    Sean Christopherson authored
    Do init_ucall() automatically during VM creation to kill two (three?)
    birds with one stone.
    
    First, initializing ucall immediately after VM creations allows forcing
    aarch64's MMIO ucall address to immediately follow memslot0.  This is
    still somewhat fragile as tests could clobber the MMIO address with a
    new memslot, but it's safe-ish since tests have to be conversative when
    accounting for memslot0.  And this can be hardened in the future by
    creating a read-only memslot for the MMIO page (KVM ARM exits with MMIO
    if the guest writes to a read-only memslot).  Add a TODO to document that
    selftests can and should use a memslot for the ucall MMIO (doing so
    requires yet more rework because tests assumes thay can use all memslots
    except memslot0).
    
    Second, initializing ucall for all VMs prepares for making ucall
    initialization meaningful on all architectures.  aarch64 is currently the
    only arch that needs to do any setup, but that will change in the future
    by switching to a pool-based implementation (instead of the current
    stack-based approach).
    
    Lastly, defining the ucall MMIO address from common code will simplify
    switching all architectures (except s390) to a common MMIO-based ucall
    implementation (if there's ever sufficient motivation to do so).
    
    Cc: Oliver Upton <oliver.upton@linux.dev>
    Reviewed-by: default avatarAndrew Jones <andrew.jones@linux.dev>
    Tested-by: default avatarPeter Gonda <pgonda@google.com>
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Link: https://lore.kernel.org/r/20221006003409.649993-4-seanjc@google.com
    dc88244b
system_counter_offset_test.c 2.6 KB