• Chao Peng's avatar
    KVM: x86: Disallow hugepages when memory attributes are mixed · 90b4fe17
    Chao Peng authored
    Disallow creating hugepages with mixed memory attributes, e.g. shared
    versus private, as mapping a hugepage in this case would allow the guest
    to access memory with the wrong attributes, e.g. overlaying private memory
    with a shared hugepage.
    
    Tracking whether or not attributes are mixed via the existing
    disallow_lpage field, but use the most significant bit in 'disallow_lpage'
    to indicate a hugepage has mixed attributes instead using the normal
    refcounting.  Whether or not attributes are mixed is binary; either they
    are or they aren't.  Attempting to squeeze that info into the refcount is
    unnecessarily complex as it would require knowing the previous state of
    the mixed count when updating attributes.  Using a flag means KVM just
    needs to ensure the current status is reflected in the memslots.
    Signed-off-by: default avatarChao Peng <chao.p.peng@linux.intel.com>
    Co-developed-by: default avatarSean Christopherson <seanjc@google.com>
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20231027182217.3615211-20-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    90b4fe17
mmu.c 202 KB