]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: Introduce CONFIG_HAVE_KVM_DIRTY_RING
authorDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 16 Nov 2021 10:15:55 +0000 (10:15 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Sat, 20 Nov 2021 10:16:28 +0000 (10:16 +0000)
I'd like to make the build include dirty_ring.c based on whether the
arch wants it or not. That's a whole lot simpler if there's a config
symbol instead of doing it implicitly on KVM_DIRTY_LOG_PAGE_OFFSET
being set to something non-zero.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
arch/x86/kvm/Kconfig
include/linux/kvm_dirty_ring.h
virt/kvm/Kconfig
virt/kvm/kvm_main.c

index 6191861381768c60e5aa409e05934fba3a21d4a6..d7fa0a42ac2517d5d7cb8ca6c04a29269b3d2103 100644 (file)
@@ -27,6 +27,7 @@ config KVM
        select MMU_NOTIFIER
        select HAVE_KVM_IRQCHIP
        select HAVE_KVM_IRQFD
+       select HAVE_KVM_DIRTY_RING
        select IRQ_BYPASS_MANAGER
        select HAVE_KVM_IRQ_BYPASS
        select HAVE_KVM_IRQ_ROUTING
index fb0fa18878e2e10cb1abff34ff90778d487f562b..906f899813dc98de600f63d3ce7ea5de7f91233d 100644 (file)
@@ -27,9 +27,9 @@ struct kvm_dirty_ring {
        int index;
 };
 
-#if (KVM_DIRTY_LOG_PAGE_OFFSET == 0)
+#ifndef CONFIG_HAVE_KVM_DIRTY_RING
 /*
- * If KVM_DIRTY_LOG_PAGE_OFFSET not defined, kvm_dirty_ring.o should
+ * If CONFIG_HAVE_HVM_DIRTY_RING not defined, kvm_dirty_ring.o should
  * not be included as well, so define these nop functions for the arch.
  */
 static inline u32 kvm_dirty_ring_get_rsvd_entries(void)
@@ -69,7 +69,7 @@ static inline bool kvm_dirty_ring_soft_full(struct kvm_dirty_ring *ring)
        return true;
 }
 
-#else /* KVM_DIRTY_LOG_PAGE_OFFSET == 0 */
+#else /* CONFIG_HAVE_KVM_DIRTY_RING */
 
 u32 kvm_dirty_ring_get_rsvd_entries(void);
 int kvm_dirty_ring_alloc(struct kvm_dirty_ring *ring, int index, u32 size);
@@ -92,6 +92,6 @@ struct page *kvm_dirty_ring_get_page(struct kvm_dirty_ring *ring, u32 offset);
 void kvm_dirty_ring_free(struct kvm_dirty_ring *ring);
 bool kvm_dirty_ring_soft_full(struct kvm_dirty_ring *ring);
 
-#endif /* KVM_DIRTY_LOG_PAGE_OFFSET == 0 */
+#endif /* CONFIG_HAVE_KVM_DIRTY_RING */
 
 #endif /* KVM_DIRTY_RING_H */
index 62b39149b8c82b901a7cb2b975a89dc9ed31d6b8..97cf5413ac25ce5da6fe7727793389f81779edc9 100644 (file)
@@ -13,6 +13,9 @@ config HAVE_KVM_IRQFD
 config HAVE_KVM_IRQ_ROUTING
        bool
 
+config HAVE_KVM_DIRTY_RING
+       bool
+
 config HAVE_KVM_EVENTFD
        bool
        select EVENTFD
index 72c6453bcef480e0e4f32e482a462c58eba529b5..8eb8c962838dc8316257820e0b7c852909defd7e 100644 (file)
@@ -3432,7 +3432,7 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_on_spin);
 
 static bool kvm_page_in_dirty_ring(struct kvm *kvm, unsigned long pgoff)
 {
-#if KVM_DIRTY_LOG_PAGE_OFFSET > 0
+#ifdef CONFIG_HAVE_KVM_DIRTY_RING
        return (pgoff >= KVM_DIRTY_LOG_PAGE_OFFSET) &&
            (pgoff < KVM_DIRTY_LOG_PAGE_OFFSET +
             kvm->dirty_ring_size / PAGE_SIZE);
@@ -4135,7 +4135,7 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
        case KVM_CAP_NR_MEMSLOTS:
                return KVM_USER_MEM_SLOTS;
        case KVM_CAP_DIRTY_LOG_RING:
-#if KVM_DIRTY_LOG_PAGE_OFFSET > 0
+#ifdef CONFIG_HAVE_KVM_DIRTY_RING
                return KVM_DIRTY_RING_MAX_ENTRIES * sizeof(struct kvm_dirty_gfn);
 #else
                return 0;