Skip to contentSkip to conversation

KVM: x86: KVM_MEM_ALLONES memory

RFC PATCH In review Vitaly Kuznetsov 4 participants 18 messages May 14, 2020 – May 15, 2020

Subsystems (5)
Documentation x86 KVM Kselftest +1 more subsystems
lore
Share & tools
lore
#0 lore raw

cover KVM: x86: KVM_MEM_ALLONES memory

The idea of the patchset was suggested by Michael S. Tsirkin.

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 and also allow us to speed up access to these holes as we can aggressively map the whole slot upon first fault.

RFC. I've only tested the feature with the selftest (PATCH5) on Intel/AMD with and wiuthout EPT/NPT. I haven't tested memslot modifications yet.

Patches are against kvm/next.

Vitaly Kuznetsov (5):
KVM: rename labels in kvm_init()
KVM: x86: introduce KVM_MEM_ALLONES memory
KVM: x86: move kvm_vcpu_gfn_to_memslot() out of try_async_pf()
KVM: x86: aggressively map PTEs in KVM_MEM_ALLONES slots
KVM: selftests: add KVM_MEM_ALLONES test

 Documentation/virt/kvm/api.rst                |  22 ++--
 arch/x86/include/uapi/asm/kvm.h               |   1 +
 arch/x86/kvm/mmu/mmu.c                        |  34 ++++--
 arch/x86/kvm/mmu/paging_tmpl.h                |  30 ++++-
 arch/x86/kvm/x86.c                            |   9 +-
 include/linux/kvm_host.h                      |  15 ++-
 include/uapi/linux/kvm.h                      |   2 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../testing/selftests/kvm/include/kvm_util.h  |   1 +
 tools/testing/selftests/kvm/lib/kvm_util.c    |  81 +++++++------
 .../kvm/x86_64/memory_region_allones.c        | 112 ++++++++++++++++++
 virt/kvm/kvm_main.c                           | 110 +++++++++++++----
 12 files changed, 342 insertions(+), 76 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/memory_region_allones.c
Signature · 1 line
2.25.4
#1 lore raw

RFC PATCH 1/5 KVM: rename labels in kvm_init()

Label names in kvm_init() are horrible, rename them to make it obvious what we are going to do on the failure path.

---
 virt/kvm/kvm_main.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
virt/kvm/kvm_main.c +16 -17
index 33e1eee96f75..892ea0b9087e 100644
@@ -4674,7 +4674,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
 
 	r = kvm_arch_init(opaque);
 	if (r)
-		goto out_fail;
+		return r;
 
 	/*
 	 * kvm_arch_init makes sure there's at most one caller
@@ -4685,29 +4685,29 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
 	 */
 	r = kvm_irqfd_init();
 	if (r)
-		goto out_irqfd;
+		goto out_arch_exit;
 
 	if (!zalloc_cpumask_var(&cpus_hardware_enabled, GFP_KERNEL)) {
 		r = -ENOMEM;
-		goto out_free_0;
+		goto out_irqfd_exit;
 	}
 
 	r = kvm_arch_hardware_setup(opaque);
 	if (r < 0)
-		goto out_free_1;
+		goto out_free_hardware_enabled;
 
 	c.ret = &r;
 	c.opaque = opaque;
 	for_each_online_cpu(cpu) {
 		smp_call_function_single(cpu, check_processor_compat, &c, 1);
 		if (r < 0)
-			goto out_free_2;
+			goto out_free_hardware_unsetup;
 	}
 
 	r = cpuhp_setup_state_nocalls(CPUHP_AP_KVM_STARTING, "kvm/cpu:starting",
 				      kvm_starting_cpu, kvm_dying_cpu);
 	if (r)
-		goto out_free_2;
+		goto out_free_hardware_unsetup;
 	register_reboot_notifier(&kvm_reboot_notifier);
 
 	/* A kmem cache lets us meet the alignment requirements of fx_save. */
@@ -4721,12 +4721,12 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
 					   NULL);
 	if (!kvm_vcpu_cache) {
 		r = -ENOMEM;
-		goto out_free_3;
+		goto out_free_cpuhp_unregister;
 	}
 
 	r = kvm_async_pf_init();
 	if (r)
-		goto out_free;
+		goto out_free_vcpu_cache;
 
 	kvm_chardev_ops.owner = module;
 	kvm_vm_fops.owner = module;
@@ -4735,7 +4735,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
 	r = misc_register(&kvm_dev);
 	if (r) {
 		pr_err("kvm: misc device register failed\n");
-		goto out_unreg;
+		goto out_async_pf_deinit;
 	}
 
 	register_syscore_ops(&kvm_syscore_ops);
@@ -4750,22 +4750,21 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
 
 	return 0;
 
-out_unreg:
+out_async_pf_deinit:
 	kvm_async_pf_deinit();
-out_free:
+out_free_vcpu_cache:
 	kmem_cache_destroy(kvm_vcpu_cache);
-out_free_3:
+out_free_cpuhp_unregister:
 	unregister_reboot_notifier(&kvm_reboot_notifier);
 	cpuhp_remove_state_nocalls(CPUHP_AP_KVM_STARTING);
-out_free_2:
+out_free_hardware_unsetup:
 	kvm_arch_hardware_unsetup();
-out_free_1:
+out_free_hardware_enabled:
 	free_cpumask_var(cpus_hardware_enabled);
-out_free_0:
+out_irqfd_exit:
 	kvm_irqfd_exit();
-out_irqfd:
+out_arch_exit:
 	kvm_arch_exit();
-out_fail:
 	return r;
 }
 EXPORT_SYMBOL_GPL(kvm_init);
Signature · 1 line
2.25.4
#2 lore raw

RFC PATCH 2/5 KVM: x86: introduce KVM_MEM_ALLONES memory

In reply to Vitaly Kuznetsov

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.

---
 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(-)
Documentation/virt/kvm/api.rst +15 -7
index d871dacb984e..2b87d588a7e0 100644
@@ -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)
 
 This ioctl allows the user to create, modify or delete a guest physical
 memory slot.  Bits 0-15 of "slot" specify the slot id and this value
@@ -1264,12 +1265,19 @@ It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr
 be identical.  This allows large pages in the guest to be backed by large
 pages in the host.
 
-The flags field supports two flags: KVM_MEM_LOG_DIRTY_PAGES and
-KVM_MEM_READONLY.  The former can be set to instruct KVM to keep track of
-writes to memory within the slot.  See KVM_GET_DIRTY_LOG ioctl to know how to
-use it.  The latter can be set, if KVM_CAP_READONLY_MEM capability allows it,
-to make a new slot read-only.  In this case, writes to this memory will be
-posted to userspace as KVM_EXIT_MMIO exits.
+The flags field supports the following flags: KVM_MEM_LOG_DIRTY_PAGES,
+KVM_MEM_READONLY, KVM_MEM_READONLY:
+- KVM_MEM_LOG_DIRTY_PAGES can be set to instruct KVM to keep track of writes to
+  memory within the slot.  See KVM_GET_DIRTY_LOG ioctl to know how to use it.
+- KVM_MEM_READONLY can be set, if KVM_CAP_READONLY_MEM capability allows it,
+  to make a new slot read-only.  In this case, writes to this memory will be
+  posted to userspace as KVM_EXIT_MMIO exits.
+- KVM_MEM_ALLONES can be set, if KVM_CAP_ALLONES_MEM capability allows it,
+  to create a new virtual read-only slot which will always return '0xff' when
+  guest reads from it. 'userspace_addr' has to be set to NULL, KVM maps all
+  pages in such slots to a single readonly page. This flag is mutually exclusive
+  with KVM_MEM_LOG_DIRTY_PAGES/KVM_MEM_READONLY. All writes to this memory will be
+  posted to userspace as KVM_EXIT_MMIO exits.
 
 When the KVM_CAP_SYNC_MMU capability is available, changes in the backing of
 the memory region are automatically reflected into the guest.  For example, an
arch/x86/include/uapi/asm/kvm.h +1 -0
index 3f3f780c8c65..97ad1d90636e 100644
@@ -48,6 +48,7 @@
 #define __KVM_HAVE_XSAVE
 #define __KVM_HAVE_XCRS
 #define __KVM_HAVE_READONLY_MEM
+#define __KVM_HAVE_ALLONES_MEM
 
 /* Architectural interrupt line count. */
 #define KVM_NR_INTERRUPTS 256
arch/x86/kvm/x86.c +6 -3
index 8c0b77ac8dc6..2c0fcab8ea1e 100644
@@ -3389,6 +3389,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
 	case KVM_CAP_GET_MSR_FEATURES:
 	case KVM_CAP_MSR_PLATFORM_INFO:
 	case KVM_CAP_EXCEPTION_PAYLOAD:
+	case KVM_CAP_ALLONES_MEM:
 		r = 1;
 		break;
 	case KVM_CAP_SYNC_REGS:
@@ -9962,9 +9963,11 @@ static int kvm_alloc_memslot_metadata(struct kvm_memory_slot *slot,
 		ugfn = slot->userspace_addr >> PAGE_SHIFT;
 		/*
 		 * If the gfn and userspace address are not aligned wrt each
-		 * other, disable large page support for this slot.
+		 * other, disable large page support for this slot. Also,
+		 * disable large page support for KVM_MEM_ALLONES slots.
 		 */
-		if ((slot->base_gfn ^ ugfn) & (KVM_PAGES_PER_HPAGE(level) - 1)) {
+		if (slot->flags & KVM_MEM_ALLONES || ((slot->base_gfn ^ ugfn) &
+				      (KVM_PAGES_PER_HPAGE(level) - 1))) {
 			unsigned long j;
 
 			for (j = 0; j < lpages; ++j)
@@ -10021,7 +10024,7 @@ static void kvm_mmu_slot_apply_flags(struct kvm *kvm,
 				     struct kvm_memory_slot *new)
 {
 	/* Still write protect RO slot */
-	if (new->flags & KVM_MEM_READONLY) {
+	if (new->flags & KVM_MEM_READONLY || new->flags & KVM_MEM_ALLONES) {
 		kvm_mmu_slot_remove_write_access(kvm, new, PT_PAGE_TABLE_LEVEL);
 		return;
 	}
include/linux/kvm_host.h +14 -1
index 3cc6ccbb1183..47a01ebe019d 100644
@@ -1064,10 +1064,23 @@ __gfn_to_memslot(struct kvm_memslots *slots, gfn_t gfn)
 	return search_memslots(slots, gfn);
 }
 
+#ifdef __KVM_HAVE_ALLONES_MEM
+extern void *kvm_allones_pg;
+#endif
+
 static inline unsigned long
 __gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn)
 {
-	return slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE;
+	if (likely(!(slot->flags & KVM_MEM_ALLONES))) {
+		return slot->userspace_addr +
+			(gfn - slot->base_gfn) * PAGE_SIZE;
+	} else {
+#ifdef __KVM_HAVE_ALLONES_MEM
+		return (unsigned long)kvm_allones_pg;
+#else
+		BUG();
+#endif
+	}
 }
 
 static inline int memslot_id(struct kvm *kvm, gfn_t gfn)
include/uapi/linux/kvm.h +2 -0
index ac9eba0289d1..2d28890d6c7d 100644
@@ -109,6 +109,7 @@ struct kvm_userspace_memory_region {
  */
 #define KVM_MEM_LOG_DIRTY_PAGES	(1UL << 0)
 #define KVM_MEM_READONLY	(1UL << 1)
+#define KVM_MEM_ALLONES		(1UL << 2)
 
 /* for KVM_IRQ_LINE */
 struct kvm_irq_level {
@@ -1018,6 +1019,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_S390_PROTECTED 180
 #define KVM_CAP_PPC_SECURE_GUEST 181
 #define KVM_CAP_HALT_POLL 182
+#define KVM_CAP_ALLONES_MEM 183
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
virt/kvm/kvm_main.c +75 -4

135 lines not on this page · raw message

Signature · 1 line
2.25.4
#3 lore raw

Re: [PATCH RFC 2/5] KVM: x86: introduce KVM_MEM_ALLONES memory

Quoted 29 lines · Vitaly Kuznetsov

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.

---
 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(-)
Documentation/virt/kvm/api.rst +0 -0
index d871dacb984e..2b87d588a7e0 100644

Documentation/virt/kvm/api.rst yet and must be cleared on entry. · line 1240

Quoted 6 lines
Documentation/virt/kvm/api.rst +2 -1
@@ -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?

#4 lore raw

Re: [PATCH RFC 2/5] KVM: x86: introduce KVM_MEM_ALLONES memory

Quoted 31 lines · Sean Christopherson
Quoted 30 lines · Vitaly Kuznetsov

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.

---
 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(-)
Documentation/virt/kvm/api.rst +0 -0
index d871dacb984e..2b87d588a7e0 100644
@@ -1236,7 +1236,8 @@ yet and must be cleared on entry.
 
Quoted 9 lines

Documentation/virt/kvm/api.rst yet and must be cleared on entry. · line 1240

Quoted 5 lines
Documentation/virt/kvm/api.rst +2 -1
   /* 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?

Becuase there's always hope this can be usefult for something else but PCI? :-) Actually, I was thinking about generalizing this a little bit to something like KVM_MEM_CONSTANT with a way to set the pattern but I'm failing to see any need for anything but all-ones or all-zeroes. Maybe other-than-x86 architectures have some needs?

I'm definitely fine with renaming this to KVM_MEM_PCI_HOLE.

Signature · 1 line
Vitaly
#5 lore raw

RFC PATCH 3/5 KVM: x86: move kvm_vcpu_gfn_to_memslot() out of try_async_pf()

In reply to Vitaly Kuznetsov

No functional change intended. We will need to analyze slot information to map PTEs for KVM_MEM_ALLONES slots aggressively.

---
 arch/x86/kvm/mmu/mmu.c         | 14 ++++++++------
 arch/x86/kvm/mmu/paging_tmpl.h |  7 +++++--
 2 files changed, 13 insertions(+), 8 deletions(-)
arch/x86/kvm/mmu/mmu.c +8 -6
index e618472c572b..3db499df2dfc 100644
@@ -4078,11 +4078,10 @@ static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
 				  kvm_vcpu_gfn_to_hva(vcpu, gfn), &arch);
 }
 
-static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn,
-			 gpa_t cr2_or_gpa, kvm_pfn_t *pfn, bool write,
-			 bool *writable)
+static bool try_async_pf(struct kvm_vcpu *vcpu, struct kvm_memory_slot *slot,
+			 bool prefault, gfn_t gfn, gpa_t cr2_or_gpa,
+			 kvm_pfn_t *pfn, bool write, bool *writable)
 {
-	struct kvm_memory_slot *slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
 	bool async;
 
 	/* Don't expose private memslots to L2. */
@@ -4118,7 +4117,7 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
 	bool exec = error_code & PFERR_FETCH_MASK;
 	bool lpage_disallowed = exec && is_nx_huge_page_enabled();
 	bool map_writable;
-
+	struct kvm_memory_slot *slot;
 	gfn_t gfn = gpa >> PAGE_SHIFT;
 	unsigned long mmu_seq;
 	kvm_pfn_t pfn;
@@ -4140,7 +4139,10 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
 	mmu_seq = vcpu->kvm->mmu_notifier_seq;
 	smp_rmb();
 
-	if (try_async_pf(vcpu, prefault, gfn, gpa, &pfn, write, &map_writable))
+	slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
+
+	if (try_async_pf(vcpu, slot, prefault, gfn, gpa, &pfn, write,
+			 &map_writable))
 		return RET_PF_RETRY;
 
 	if (handle_abnormal_pfn(vcpu, is_tdp ? 0 : gpa, gfn, pfn, ACC_ALL, &r))
arch/x86/kvm/mmu/paging_tmpl.h +5 -2
index efec7d27b8c5..98e368788e8b 100644
@@ -781,6 +781,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code,
 	int write_fault = error_code & PFERR_WRITE_MASK;
 	int user_fault = error_code & PFERR_USER_MASK;
 	struct guest_walker walker;
+	struct kvm_memory_slot *slot;
 	int r;
 	kvm_pfn_t pfn;
 	unsigned long mmu_seq;
@@ -835,8 +836,10 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code,
 	mmu_seq = vcpu->kvm->mmu_notifier_seq;
 	smp_rmb();
 
-	if (try_async_pf(vcpu, prefault, walker.gfn, addr, &pfn, write_fault,
-			 &map_writable))
+	slot = kvm_vcpu_gfn_to_memslot(vcpu, walker.gfn);
+
+	if (try_async_pf(vcpu, slot, prefault, walker.gfn, addr, &pfn,
+			 write_fault, &map_writable))
 		return RET_PF_RETRY;
 
 	if (handle_abnormal_pfn(vcpu, addr, walker.gfn, pfn, walker.pte_access, &r))
Signature · 1 line
2.25.4
#6 lore raw

RFC PATCH 4/5 KVM: x86: aggressively map PTEs in KVM_MEM_ALLONES slots

In reply to Vitaly Kuznetsov

All PTEs in KVM_MEM_ALLONES slots point to the same read-only page in KVM so instead of mapping each page upon first access we can map everything aggressively.

---
 arch/x86/kvm/mmu/mmu.c         | 20 ++++++++++++++++++--
 arch/x86/kvm/mmu/paging_tmpl.h | 23 +++++++++++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)
arch/x86/kvm/mmu/mmu.c +18 -2
index 3db499df2dfc..e92ca9ed3ff5 100644
@@ -4154,8 +4154,24 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
 		goto out_unlock;
 	if (make_mmu_pages_available(vcpu) < 0)
 		goto out_unlock;
-	r = __direct_map(vcpu, gpa, write, map_writable, max_level, pfn,
-			 prefault, is_tdp && lpage_disallowed);
+
+	if (likely(!(slot->flags & KVM_MEM_ALLONES) || write)) {
+		r = __direct_map(vcpu, gpa, write, map_writable, max_level, pfn,
+				 prefault, is_tdp && lpage_disallowed);
+	} else {
+		/*
+		 * KVM_MEM_ALLONES are 4k only slots fully mapped to the same
+		 * readonly 'allones' page, map all PTEs aggressively here.
+		 */
+		for (gfn = slot->base_gfn; gfn < slot->base_gfn + slot->npages;
+		     gfn++) {
+			r = __direct_map(vcpu, gfn << PAGE_SHIFT, write,
+					 map_writable, max_level, pfn, prefault,
+					 is_tdp && lpage_disallowed);
+			if (r)
+				break;
+		}
+	}
 
 out_unlock:
 	spin_unlock(&vcpu->kvm->mmu_lock);
arch/x86/kvm/mmu/paging_tmpl.h +21 -2
index 98e368788e8b..7bf0c48b858f 100644
@@ -789,6 +789,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code,
 	bool lpage_disallowed = (error_code & PFERR_FETCH_MASK) &&
 				is_nx_huge_page_enabled();
 	int max_level;
+	gfn_t gfn;
 
 	pgprintk("%s: addr %lx err %x\n", __func__, addr, error_code);
 
@@ -873,8 +874,26 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code,
 	kvm_mmu_audit(vcpu, AUDIT_PRE_PAGE_FAULT);
 	if (make_mmu_pages_available(vcpu) < 0)
 		goto out_unlock;
-	r = FNAME(fetch)(vcpu, addr, &walker, write_fault, max_level, pfn,
-			 map_writable, prefault, lpage_disallowed);
+	if (likely(!(slot->flags & KVM_MEM_ALLONES) || write_fault)) {
+		r = FNAME(fetch)(vcpu, addr, &walker, write_fault, max_level,
+				 pfn, map_writable, prefault, lpage_disallowed);
+	} else {
+		/*
+		 * KVM_MEM_ALLONES are 4k only slots fully mapped to the same
+		 * readonly 'allones' page, map all PTEs aggressively here.
+		 */
+		for (gfn = slot->base_gfn; gfn < slot->base_gfn + slot->npages;
+		     gfn++) {
+			walker.gfn = gfn;
+			r = FNAME(fetch)(vcpu, gfn << PAGE_SHIFT, &walker,
+					 write_fault, max_level, pfn,
+					 map_writable, prefault,
+					 lpage_disallowed);
+			if (r)
+				break;
+		}
+	}
+
 	kvm_mmu_audit(vcpu, AUDIT_POST_PAGE_FAULT);
 
 out_unlock:
Signature · 1 line
2.25.4
#7 lore raw

Re: [PATCH RFC 4/5] KVM: x86: aggressively map PTEs in KVM_MEM_ALLONES slots

Quoted 16 lines · Vitaly Kuznetsov

All PTEs in KVM_MEM_ALLONES slots point to the same read-only page in KVM so instead of mapping each page upon first access we can map everything aggressively.

---
 arch/x86/kvm/mmu/mmu.c         | 20 ++++++++++++++++++--
 arch/x86/kvm/mmu/paging_tmpl.h | 23 +++++++++++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)
arch/x86/kvm/mmu/mmu.c +0 -0
index 3db499df2dfc..e92ca9ed3ff5 100644

arch/x86/kvm/mmu/mmu.c static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, · line 4158

Quoted 7 lines
arch/x86/kvm/mmu/mmu.c +2 -2
@@ -4154,8 +4154,24 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
 		goto out_unlock;
 	if (make_mmu_pages_available(vcpu) < 0)
 		goto out_unlock;
-	r = __direct_map(vcpu, gpa, write, map_writable, max_level, pfn,
-			 prefault, is_tdp && lpage_disallowed);
+
+	if (likely(!(slot->flags & KVM_MEM_ALLONES) || write)) {

The 'write' check is wrong. More specifically, patch 2/5 is missing code to add KVM_MEM_ALLONES to memslot_is_readonly(). If we end up going with an actual kvm_allones_pg backing, writes to an ALLONES memslots should be handled same as writes to RO memslots; MMIO occurs but no MMIO spte is created.

arch/x86/kvm/mmu/mmu.c static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, · line 4170

Quoted 12 lines
arch/x86/kvm/mmu/mmu.c +12 -0
+		r = __direct_map(vcpu, gpa, write, map_writable, max_level, pfn,
+				 prefault, is_tdp && lpage_disallowed);
+	} else {
+		/*
+		 * KVM_MEM_ALLONES are 4k only slots fully mapped to the same
+		 * readonly 'allones' page, map all PTEs aggressively here.
+		 */
+		for (gfn = slot->base_gfn; gfn < slot->base_gfn + slot->npages;
+		     gfn++) {
+			r = __direct_map(vcpu, gfn << PAGE_SHIFT, write,
+					 map_writable, max_level, pfn, prefault,
+					 is_tdp && lpage_disallowed);

IMO this is a waste of memory and TLB entries. Why not treat the access as the MMIO it is and emulate the access with a 0xff return value? I think it'd be a simple change to have __kvm_read_guest_page() stuff 0xff, i.e. a kvm_allones_pg wouldn't be needed. I would even vote to never create an MMIO SPTE. The guest has bigger issues if reading from a PCI hole is performance sensitive.

Regarding memory, looping wantonly on __direct_map() will eventually trigger the BUG_ON() in mmu_memory_cache_alloc(). mmu_topup_memory_caches() only ensures there are enough objects available to map a single translation, i.e. one entry per level, sans the root[*].

[*] The gorilla math in mmu_topup_memory_caches() is horrendously misleading,
e.g. the '8' pages is really 2*(ROOT_LEVEL - 1), but the 2x part has been obsolete for the better part of a decade, and the '- 1' wasn't actually originally intended or needed, but is now required because of 5-level paging. I have the beginning of a series to clean up that mess; it was low on my todo list because I didn't expect anyone to be mucking with related code :-)

Quoted 4 lines
arch/x86/kvm/mmu/mmu.c +4 -0
+			if (r)
+				break;
+		}
+	}
#8 lore raw

Re: [PATCH RFC 4/5] KVM: x86: aggressively map PTEs in KVM_MEM_ALLONES slots

Quoted 22 lines · Sean Christopherson
Quoted 21 lines · Vitaly Kuznetsov

All PTEs in KVM_MEM_ALLONES slots point to the same read-only page in KVM so instead of mapping each page upon first access we can map everything aggressively.

---
 arch/x86/kvm/mmu/mmu.c         | 20 ++++++++++++++++++--
 arch/x86/kvm/mmu/paging_tmpl.h | 23 +++++++++++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)
arch/x86/kvm/mmu/mmu.c +0 -2
index 3db499df2dfc..e92ca9ed3ff5 100644
@@ -4154,8 +4154,24 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
 		goto out_unlock;
 	if (make_mmu_pages_available(vcpu) < 0)
 		goto out_unlock;
-	r = __direct_map(vcpu, gpa, write, map_writable, max_level, pfn,
-			 prefault, is_tdp && lpage_disallowed);
Quoted 9 lines

arch/x86/kvm/mmu/mmu.c static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, · line 4158

Quoted 2 lines
arch/x86/kvm/mmu/mmu.c +2 -0
+
+	if (likely(!(slot->flags & KVM_MEM_ALLONES) || write)) {

The 'write' check is wrong. More specifically, patch 2/5 is missing code to add KVM_MEM_ALLONES to memslot_is_readonly(). If we end up going with an actual kvm_allones_pg backing, writes to an ALLONES memslots should be handled same as writes to RO memslots; MMIO occurs but no MMIO spte is created.

Missed that, thanks!

Quoted 11 lines
Quoted 11 lines
arch/x86/kvm/mmu/mmu.c +11 -0
+		r = __direct_map(vcpu, gpa, write, map_writable, max_level, pfn,
+				 prefault, is_tdp && lpage_disallowed);
+	} else {
+		/*
+		 * KVM_MEM_ALLONES are 4k only slots fully mapped to the same
+		 * readonly 'allones' page, map all PTEs aggressively here.
+		 */
+		for (gfn = slot->base_gfn; gfn < slot->base_gfn + slot->npages;
+		     gfn++) {
+			r = __direct_map(vcpu, gfn << PAGE_SHIFT, write,
+					 map_writable, max_level, pfn, prefault,
Quoted 8 lines

arch/x86/kvm/mmu/mmu.c static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, · line 4170

Quoted 1 line
arch/x86/kvm/mmu/mmu.c +1 -0
+					 is_tdp && lpage_disallowed);

IMO this is a waste of memory and TLB entries. Why not treat the access as the MMIO it is and emulate the access with a 0xff return value? I think it'd be a simple change to have __kvm_read_guest_page() stuff 0xff, i.e. a kvm_allones_pg wouldn't be needed. I would even vote to never create an MMIO SPTE. The guest has bigger issues if reading from a PCI hole is performance sensitive.

You're trying to defeat the sole purpose of the feature :-) I also saw the option you suggest but Michael convinced me we should go further.

The idea (besides memory waste) was that the time we spend on PCI scan during boot is significant. Unfortunatelly, I don't have any numbers but we can certainly try to get them. With this feature (AFAIU) we're not aiming at 'classic' long-living VMs but rather at something like Kata containers/FaaS/... where boot time is crucial.

Quoted 6 lines

Regarding memory, looping wantonly on __direct_map() will eventually trigger the BUG_ON() in mmu_memory_cache_alloc(). mmu_topup_memory_caches() only ensures there are enough objects available to map a single translation, i.e. one entry per level, sans the root[*].

Quoted 7 lines

[*] The gorilla math in mmu_topup_memory_caches() is horrendously misleading,
e.g. the '8' pages is really 2*(ROOT_LEVEL - 1), but the 2x part has been obsolete for the better part of a decade, and the '- 1' wasn't actually originally intended or needed, but is now required because of 5-level paging. I have the beginning of a series to clean up that mess; it was low on my todo list because I didn't expect anyone to be mucking with related code :-)

I missed that too but oh well, this is famous KVM MMU, I should't feel that bad about it :-) Thanks for your review!

Quoted 6 lines
Quoted 5 lines
arch/x86/kvm/mmu/mmu.c +4 -0
+			if (r)
+				break;
+		}
+	}
Signature · 1 line
Vitaly
#9 lore raw

Re: [PATCH RFC 4/5] KVM: x86: aggressively map PTEs in KVM_MEM_ALLONES slots

Quoted 8 lines · Vitaly Kuznetsov
Quoted 6 lines · Sean Christopherson

IMO this is a waste of memory and TLB entries. Why not treat the access as the MMIO it is and emulate the access with a 0xff return value? I think it'd be a simple change to have __kvm_read_guest_page() stuff 0xff, i.e. a kvm_allones_pg wouldn't be needed. I would even vote to never create an MMIO SPTE. The guest has bigger issues if reading from a PCI hole is performance sensitive.

Quoted 5 lines

You're trying to defeat the sole purpose of the feature :-) I also saw the option you suggest but Michael convinced me we should go further.

The idea (besides memory waste) was that the time we spend on PCI scan during boot is significant.

Put that in the cover letter. The impression I got from the current cover letter is that the focus was entirely on memory consumption.

Quoted 2 lines

Unfortunatelly, I don't have any numbers but we can certainly try to get them.

Numbers are definitely required, otherwise we'll have no idea whether doing something like the agressive prefetch actually has a meaningful impact.

Quoted 2 lines

With this feature (AFAIU) we're not aiming at 'classic' long-living VMs but rather at something like Kata containers/FaaS/... where boot time is crucial.

Isn't the guest kernel fully controlled by the VMM in those use cases? Why not enlighten the guest kernel in some way so that it doesn't have to spend time scanning PCI space in the first place?

#10 lore raw

RFC PATCH 5/5 KVM: selftests: add KVM_MEM_ALLONES test

In reply to Vitaly Kuznetsov

Test the newly introduced KVM_MEM_ALLONES memslots:
- Reads from all pages return '0xff'
- Writes to all pages cause KVM_EXIT_MMIO

---
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../testing/selftests/kvm/include/kvm_util.h  |   1 +
 tools/testing/selftests/kvm/lib/kvm_util.c    |  81 +++++++------
 .../kvm/x86_64/memory_region_allones.c        | 112 ++++++++++++++++++
 4 files changed, 162 insertions(+), 33 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/memory_region_allones.c
tools/testing/selftests/kvm/Makefile +1 -0
index 7af62030c12f..0c9aff445755 100644
@@ -15,6 +15,7 @@ LIBKVM_s390x = lib/s390x/processor.c lib/s390x/ucall.c
 TEST_GEN_PROGS_x86_64 = x86_64/cr4_cpuid_sync_test
 TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test
 TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid
+TEST_GEN_PROGS_x86_64 += x86_64/memory_region_allones
 TEST_GEN_PROGS_x86_64 += x86_64/mmio_warning_test
 TEST_GEN_PROGS_x86_64 += x86_64/platform_info_test
 TEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test
tools/testing/selftests/kvm/include/kvm_util.h +1 -0
index 53b11d725d81..8f5ebc8520b8 100644
@@ -59,6 +59,7 @@ enum vm_mem_backing_src_type {
 	VM_MEM_SRC_ANONYMOUS,
 	VM_MEM_SRC_ANONYMOUS_THP,
 	VM_MEM_SRC_ANONYMOUS_HUGETLB,
+	VM_MEM_SRC_NONE,
 };
 
 int kvm_check_cap(long cap);
tools/testing/selftests/kvm/lib/kvm_util.c +48 -33

99 lines not on this page · raw message

tools/testing/selftests/kvm/x86_64/memory_region_allones.c new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
2.25.4
#11 lore raw
In reply to Vitaly Kuznetsov
Quoted 15 lines · Vitaly Kuznetsov

The idea of the patchset was suggested by Michael S. Tsirkin.

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 and also allow us to speed up access to these holes as we can aggressively map the whole slot upon first fault.

Quoted 4 lines

RFC. I've only tested the feature with the selftest (PATCH5) on Intel/AMD with and wiuthout EPT/NPT. I haven't tested memslot modifications yet.

Patches are against kvm/next.

Hi, Vitaly,

Could this be done in userspace with existing techniques?

E.g., shm_open() with a handle and fill one 0xff page, then remap it to anywhere needed in QEMU?

Thanks,

Signature · 1 line
Peter Xu
#12 lore raw
Quoted 19 lines · Peter Xu
Quoted 18 lines · Vitaly Kuznetsov

The idea of the patchset was suggested by Michael S. Tsirkin.

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 and also allow us to speed up access to these holes as we can aggressively map the whole slot upon first fault.

RFC. I've only tested the feature with the selftest (PATCH5) on Intel/AMD with and wiuthout EPT/NPT. I haven't tested memslot modifications yet.

Quoted 8 lines
Quoted 1 line

Patches are against kvm/next.

Hi, Vitaly,

Could this be done in userspace with existing techniques?

E.g., shm_open() with a handle and fill one 0xff page, then remap it to anywhere needed in QEMU?

Mapping that 4k page over and over is going to get expensive, e.g. each duplicate will need a VMA and a memslot, plus any PTE overhead. If the total sum of the holes is >2mb it'll even overflow the mumber of allowed memslots.

#13 lore raw
Quoted 26 lines · Sean Christopherson
Quoted 25 lines · Peter Xu
Quoted 15 lines · Vitaly Kuznetsov

The idea of the patchset was suggested by Michael S. Tsirkin.

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 and also allow us to speed up access to these holes as we can aggressively map the whole slot upon first fault.

Quoted 4 lines

RFC. I've only tested the feature with the selftest (PATCH5) on Intel/AMD with and wiuthout EPT/NPT. I haven't tested memslot modifications yet.

Patches are against kvm/next.

Hi, Vitaly,

Could this be done in userspace with existing techniques?

Quoted 7 lines
Quoted 2 lines

E.g., shm_open() with a handle and fill one 0xff page, then remap it to anywhere needed in QEMU?

Mapping that 4k page over and over is going to get expensive, e.g. each duplicate will need a VMA and a memslot, plus any PTE overhead. If the total sum of the holes is >2mb it'll even overflow the mumber of allowed memslots.

What's the PTE overhead you mentioned? We need to fill PTEs one by one on fault even if the page is allocated in the kernel, am I right?

4K is only an example - we can also use more pages as the template. However I guess the kvm memslot count could be a limit.. Could I ask what's the normal size of this 0xff region, and its distribution?

Thanks,

Signature · 1 line
Peter Xu
#14 lore raw
Quoted 5 lines · Peter Xu
Quoted 4 lines · Sean Christopherson
Quoted 2 lines · Peter Xu

E.g., shm_open() with a handle and fill one 0xff page, then remap it to anywhere needed in QEMU?

Quoted 7 lines
Quoted 4 lines

Mapping that 4k page over and over is going to get expensive, e.g. each duplicate will need a VMA and a memslot, plus any PTE overhead. If the total sum of the holes is >2mb it'll even overflow the mumber of allowed memslots.

What's the PTE overhead you mentioned? We need to fill PTEs one by one on fault even if the page is allocated in the kernel, am I right?

It won't require host PTEs for every page if it's a kernel page. I doubt PTEs are a significant overhead, especially compared to memslots, but it's still worth considering.

My thought was to skimp on both host PTEs _and_ KVM SPTEs by always sending the PCI hole accesses down the slow MMIO path[*].

[*] https://lkml.kernel.org/r/[email protected]

Quoted 9 lines

4K is only an example - we can also use more pages as the template. However I guess the kvm memslot count could be a limit.. Could I ask what's the normal size of this 0xff region, and its distribution?

Thanks,

Signature · 1 line
Peter Xu
#15 lore raw
Quoted 14 lines · Sean Christopherson
Quoted 5 lines · Peter Xu
Quoted 4 lines · Sean Christopherson
Quoted 2 lines · Peter Xu

E.g., shm_open() with a handle and fill one 0xff page, then remap it to anywhere needed in QEMU?

Quoted 7 lines
Quoted 4 lines

Mapping that 4k page over and over is going to get expensive, e.g. each duplicate will need a VMA and a memslot, plus any PTE overhead. If the total sum of the holes is >2mb it'll even overflow the mumber of allowed memslots.

What's the PTE overhead you mentioned? We need to fill PTEs one by one on fault even if the page is allocated in the kernel, am I right?

Quoted 9 lines

It won't require host PTEs for every page if it's a kernel page. I doubt PTEs are a significant overhead, especially compared to memslots, but it's still worth considering.

My thought was to skimp on both host PTEs _and_ KVM SPTEs by always sending the PCI hole accesses down the slow MMIO path[*].

[*] https://lkml.kernel.org/r/[email protected]

If we drop 'aggressive' patch from this patchset we can probably get away with KVM_MEM_READONLY and userspace VMAs but this will only help us to save some memory, it won't speed things up.

Quoted 3 lines
Quoted 3 lines

4K is only an example - we can also use more pages as the template. However I guess the kvm memslot count could be a limit.. Could I ask what's the normal size of this 0xff region, and its distribution?

Julia/Michael, could you please provide some 'normal' configuration for a Q35 machine and its PCIe config space?

Signature · 1 line
Vitaly
#16 lore raw
In reply to Sean Christopherson
Quoted 27 lines · Sean Christopherson
Quoted 25 lines · Peter Xu
Quoted 15 lines · Vitaly Kuznetsov

The idea of the patchset was suggested by Michael S. Tsirkin.

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 and also allow us to speed up access to these holes as we can aggressively map the whole slot upon first fault.

Quoted 4 lines

RFC. I've only tested the feature with the selftest (PATCH5) on Intel/AMD with and wiuthout EPT/NPT. I haven't tested memslot modifications yet.

Patches are against kvm/next.

Hi, Vitaly,

Could this be done in userspace with existing techniques?

Quoted 7 lines
Quoted 2 lines

E.g., shm_open() with a handle and fill one 0xff page, then remap it to anywhere needed in QEMU?

Mapping that 4k page over and over is going to get expensive, e.g. each duplicate will need a VMA and a memslot, plus any PTE overhead. If the total sum of the holes is >2mb it'll even overflow the mumber of allowed memslots.

How about a tiny character device driver /dev/ones?

#17 lore raw
Quoted 32 lines · Andy Lutomirski
Quoted 30 lines · Sean Christopherson
Quoted 27 lines · Peter Xu
Quoted 15 lines · Vitaly Kuznetsov

The idea of the patchset was suggested by Michael S. Tsirkin.

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 and also allow us to speed up access to these holes as we can aggressively map the whole slot upon first fault.

Quoted 4 lines

RFC. I've only tested the feature with the selftest (PATCH5) on Intel/AMD with and wiuthout EPT/NPT. I haven't tested memslot modifications yet.

Patches are against kvm/next.

Hi, Vitaly,

Could this be done in userspace with existing techniques?

E.g., shm_open() with a handle and fill one 0xff page, then remap it to anywhere needed in QEMU?

Quoted 6 lines
Quoted 4 lines

Mapping that 4k page over and over is going to get expensive, e.g. each duplicate will need a VMA and a memslot, plus any PTE overhead. If the total sum of the holes is >2mb it'll even overflow the mumber of allowed memslots.

How about a tiny character device driver /dev/ones?

Yeah, this looks very clean.

Or I also like Sean's idea about using the slow path - I think the answer could depend on a better knowledge on the problem to solve (PCI scan for small VM boots) to firstly justify that the fast path is required. E.g., could we even workaround that inefficient reading of 0xff's for our use case? After all what the BIOS really needs is not those 0xff's, but some other facts.

Thanks!

Signature · 1 line
Peter Xu