On Thu, May 14, 2020 at 08:05:37PM +0200, Vitaly Kuznetsov wrote: > PCIe config space can (depending on the configuration) be quite big but > usually is sparsely populated. Guest may scan it by accessing individual > device's page which, when device is missing, is supposed to have 'pci > holes' semantics: reads return '0xff' and writes get discarded. Currently, > userspace has to allocate real memory for these holes and fill them with > '0xff'. Moreover, different VMs usually require different memory. > > The idea behind the feature introduced by this patch is: let's have a > single read-only page filled with '0xff' in KVM and map it to all such > PCI holes in all VMs. This will free userspace of obligation to allocate > real memory. Later, this will also allow us to speed up access to these > holes as we can aggressively map the whole slot upon first fault. > > Suggested-by: Michael S. Tsirkin <m...@redhat.com> > Signed-off-by: Vitaly Kuznetsov <vkuzn...@redhat.com> > --- > Documentation/virt/kvm/api.rst | 22 ++++++--- > arch/x86/include/uapi/asm/kvm.h | 1 + > arch/x86/kvm/x86.c | 9 ++-- > include/linux/kvm_host.h | 15 ++++++- > include/uapi/linux/kvm.h | 2 + > virt/kvm/kvm_main.c | 79 +++++++++++++++++++++++++++++++-- > 6 files changed, 113 insertions(+), 15 deletions(-) > > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index d871dacb984e..2b87d588a7e0 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -1236,7 +1236,8 @@ yet and must be cleared on entry. > > /* for kvm_memory_region::flags */ > #define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) > - #define KVM_MEM_READONLY (1UL << 1) > + #define KVM_MEM_READONLY (1UL << 1) > + #define KVM_MEM_ALLONES (1UL << 2)
Why not call this KVM_MEM_PCI_HOLE or something else that better conveys that this is memslot is intended to emulate PCI master abort semantics?