Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kvm: rename KVM_MAX_VCPU_ID to KVM_MAX_VCPU_IDS

KVM_MAX_VCPU_ID is not specifying the highest allowed vcpu-id, but the
number of allowed vcpu-ids. This has already led to confusion, so
rename KVM_MAX_VCPU_ID to KVM_MAX_VCPU_IDS to make its semantics more
clear

Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210913135745.13944-3-jgross@suse.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Juergen Gross and committed by
Paolo Bonzini
a1c42dde 1e254d0d

+17 -17
+1 -1
Documentation/virt/kvm/devices/xics.rst
··· 22 22 Errors: 23 23 24 24 ======= ========================================== 25 - -EINVAL Value greater than KVM_MAX_VCPU_ID. 25 + -EINVAL Value greater than KVM_MAX_VCPU_IDS. 26 26 -EFAULT Invalid user pointer for attr->addr. 27 27 -EBUSY A vcpu is already connected to the device. 28 28 ======= ==========================================
+1 -1
Documentation/virt/kvm/devices/xive.rst
··· 91 91 Errors: 92 92 93 93 ======= ========================================== 94 - -EINVAL Value greater than KVM_MAX_VCPU_ID. 94 + -EINVAL Value greater than KVM_MAX_VCPU_IDS. 95 95 -EFAULT Invalid user pointer for attr->addr. 96 96 -EBUSY A vCPU is already connected to the device. 97 97 ======= ==========================================
+1 -1
arch/mips/kvm/mips.c
··· 1073 1073 r = KVM_MAX_VCPUS; 1074 1074 break; 1075 1075 case KVM_CAP_MAX_VCPU_ID: 1076 - r = KVM_MAX_VCPU_ID; 1076 + r = KVM_MAX_VCPU_IDS; 1077 1077 break; 1078 1078 case KVM_CAP_MIPS_FPU: 1079 1079 /* We don't handle systems with inconsistent cpu_has_fpu */
+1 -1
arch/powerpc/include/asm/kvm_book3s.h
··· 434 434 #define SPLIT_HACK_OFFS 0xfb000000 435 435 436 436 /* 437 - * This packs a VCPU ID from the [0..KVM_MAX_VCPU_ID) space down to the 437 + * This packs a VCPU ID from the [0..KVM_MAX_VCPU_IDS) space down to the 438 438 * [0..KVM_MAX_VCPUS) space, using knowledge of the guest's core stride 439 439 * (but not its actual threading mode, which is not available) to avoid 440 440 * collisions.
+2 -2
arch/powerpc/include/asm/kvm_host.h
··· 33 33 34 34 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 35 35 #include <asm/kvm_book3s_asm.h> /* for MAX_SMT_THREADS */ 36 - #define KVM_MAX_VCPU_ID (MAX_SMT_THREADS * KVM_MAX_VCORES) 36 + #define KVM_MAX_VCPU_IDS (MAX_SMT_THREADS * KVM_MAX_VCORES) 37 37 #define KVM_MAX_NESTED_GUESTS KVMPPC_NR_LPIDS 38 38 39 39 #else 40 - #define KVM_MAX_VCPU_ID KVM_MAX_VCPUS 40 + #define KVM_MAX_VCPU_IDS KVM_MAX_VCPUS 41 41 #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ 42 42 43 43 #define __KVM_HAVE_ARCH_INTC_INITIALIZED
+1 -1
arch/powerpc/kvm/book3s_xive.c
··· 1928 1928 1929 1929 pr_devel("%s nr_servers=%u\n", __func__, nr_servers); 1930 1930 1931 - if (!nr_servers || nr_servers > KVM_MAX_VCPU_ID) 1931 + if (!nr_servers || nr_servers > KVM_MAX_VCPU_IDS) 1932 1932 return -EINVAL; 1933 1933 1934 1934 mutex_lock(&xive->lock);
+1 -1
arch/powerpc/kvm/powerpc.c
··· 649 649 r = KVM_MAX_VCPUS; 650 650 break; 651 651 case KVM_CAP_MAX_VCPU_ID: 652 - r = KVM_MAX_VCPU_ID; 652 + r = KVM_MAX_VCPU_IDS; 653 653 break; 654 654 #ifdef CONFIG_PPC_BOOK3S_64 655 655 case KVM_CAP_PPC_GET_SMMU_INFO:
+1 -1
arch/x86/include/asm/kvm_host.h
··· 50 50 * so ratio of 4 should be enough. 51 51 */ 52 52 #define KVM_VCPU_ID_RATIO 4 53 - #define KVM_MAX_VCPU_ID (KVM_MAX_VCPUS * KVM_VCPU_ID_RATIO) 53 + #define KVM_MAX_VCPU_IDS (KVM_MAX_VCPUS * KVM_VCPU_ID_RATIO) 54 54 55 55 /* memory slots that are not exposed to userspace */ 56 56 #define KVM_PRIVATE_MEM_SLOTS 3
+1 -1
arch/x86/kvm/ioapic.c
··· 96 96 static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic) 97 97 { 98 98 ioapic->rtc_status.pending_eoi = 0; 99 - bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_ID); 99 + bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_IDS); 100 100 } 101 101 102 102 static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic);
+2 -2
arch/x86/kvm/ioapic.h
··· 39 39 40 40 struct dest_map { 41 41 /* vcpu bitmap where IRQ has been sent */ 42 - DECLARE_BITMAP(map, KVM_MAX_VCPU_ID); 42 + DECLARE_BITMAP(map, KVM_MAX_VCPU_IDS); 43 43 44 44 /* 45 45 * Vector sent to a given vcpu, only valid when 46 46 * the vcpu's bit in map is set 47 47 */ 48 - u8 vectors[KVM_MAX_VCPU_ID]; 48 + u8 vectors[KVM_MAX_VCPU_IDS]; 49 49 }; 50 50 51 51
+1 -1
arch/x86/kvm/x86.c
··· 4077 4077 r = KVM_MAX_VCPUS; 4078 4078 break; 4079 4079 case KVM_CAP_MAX_VCPU_ID: 4080 - r = KVM_MAX_VCPU_ID; 4080 + r = KVM_MAX_VCPU_IDS; 4081 4081 break; 4082 4082 case KVM_CAP_PV_MMU: /* obsolete */ 4083 4083 r = 0;
+2 -2
include/linux/kvm_host.h
··· 39 39 #include <asm/kvm_host.h> 40 40 #include <linux/kvm_dirty_ring.h> 41 41 42 - #ifndef KVM_MAX_VCPU_ID 43 - #define KVM_MAX_VCPU_ID KVM_MAX_VCPUS 42 + #ifndef KVM_MAX_VCPU_IDS 43 + #define KVM_MAX_VCPU_IDS KVM_MAX_VCPUS 44 44 #endif 45 45 46 46 /*
+1 -1
tools/testing/selftests/kvm/kvm_create_max_vcpus.c
··· 53 53 kvm_max_vcpu_id = kvm_max_vcpus; 54 54 55 55 TEST_ASSERT(kvm_max_vcpu_id >= kvm_max_vcpus, 56 - "KVM_MAX_VCPU_ID (%d) must be at least as large as KVM_MAX_VCPUS (%d).", 56 + "KVM_MAX_VCPU_IDS (%d) must be at least as large as KVM_MAX_VCPUS (%d).", 57 57 kvm_max_vcpu_id, kvm_max_vcpus); 58 58 59 59 test_vcpu_creation(0, kvm_max_vcpus);
+1 -1
virt/kvm/kvm_main.c
··· 3595 3595 struct kvm_vcpu *vcpu; 3596 3596 struct page *page; 3597 3597 3598 - if (id >= KVM_MAX_VCPU_ID) 3598 + if (id >= KVM_MAX_VCPU_IDS) 3599 3599 return -EINVAL; 3600 3600 3601 3601 mutex_lock(&kvm->lock);