• Paul Durrant's avatar
    KVM: x86/xen: allow shared_info to be mapped by fixed HVA · b9220d32
    Paul Durrant authored
    The shared_info page is not guest memory as such. It is a dedicated page
    allocated by the VMM and overlaid onto guest memory in a GFN chosen by the
    guest and specified in the XENMEM_add_to_physmap hypercall. The guest may
    even request that shared_info be moved from one GFN to another by
    re-issuing that hypercall, but the HVA is never going to change.
    
    Because the shared_info page is an overlay the memory slots need to be
    updated in response to the hypercall. However, memory slot adjustment is
    not atomic and, whilst all vCPUs are paused, there is still the possibility
    that events may be delivered (which requires the shared_info page to be
    updated) whilst the shared_info GPA is absent. The HVA is never absent
    though, so it makes much more sense to use that as the basis for the
    kernel's mapping.
    
    Hence add a new KVM_XEN_ATTR_TYPE_SHARED_INFO_HVA attribute type for this
    purpose and a KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA flag to advertize its
    availability. Don't actually advertize it yet though. That will be done in
    a subsequent patch, which will also add tests for the new attribute type.
    
    Also update the KVM API documentation with the new attribute and also fix
    it up to consistently refer to 'shared_info' (with the underscore).
    Signed-off-by: default avatarPaul Durrant <pdurrant@amazon.com>
    Reviewed-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
    Link: https://lore.kernel.org/r/20240215152916.1158-13-paul@xen.org
    [sean: store "hva" as a user pointer, use kvm_gpc_is_{gpa,hva}_active()]
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    b9220d32
xen.c 60.4 KB