]> err.no Git - linux-2.6/commitdiff
KVM: Trivial: Use standard BITMAP macros, open-code userspace-exposed header
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 18 Jul 2007 03:05:58 +0000 (13:05 +1000)
committerAvi Kivity <avi@qumranet.com>
Sat, 13 Oct 2007 08:18:18 +0000 (10:18 +0200)
Creating one's own BITMAP macro seems suboptimal: if we use manual
arithmetic in the one place exposed to userspace, we can use standard
macros elsewhere.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm.h
drivers/kvm/kvm_main.c
include/linux/kvm.h

index 25439a5968f9f791b7daa9d415e590ba2aa8f9a7..cec5f057f3bf00f0f803f87e742b8bbd84d68078 100644 (file)
@@ -324,8 +324,7 @@ struct kvm_vcpu {
        int guest_mode;
        unsigned long requests;
        unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */
-#define NR_IRQ_WORDS KVM_IRQ_BITMAP_SIZE(unsigned long)
-       unsigned long irq_pending[NR_IRQ_WORDS];
+       DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS);
        unsigned long regs[NR_VCPU_REGS]; /* for rsp: vcpu_load_rsp_rip() */
        unsigned long rip;      /* needs vcpu_load_rsp_rip() */
 
index af02320012c9e12f95e4339cc7e4cb146f47a2d6..fc63de25d9b03ce7e15bfffb7adc00ca78385614 100644 (file)
@@ -2130,7 +2130,7 @@ static int kvm_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
        memcpy(vcpu->irq_pending, sregs->interrupt_bitmap,
               sizeof vcpu->irq_pending);
        vcpu->irq_summary = 0;
-       for (i = 0; i < NR_IRQ_WORDS; ++i)
+       for (i = 0; i < ARRAY_SIZE(vcpu->irq_pending); ++i)
                if (vcpu->irq_pending[i])
                        __set_bit(i, &vcpu->irq_summary);
 
index 68ecced40119026fc0741cc7cd214b51e0cae99e..8db01a91e1a77c5fe8531102a687433758d82970 100644 (file)
 
 #define KVM_API_VERSION 12
 
-/*
- * Architectural interrupt line count, and the size of the bitmap needed
- * to hold them.
- */
+/* Architectural interrupt line count. */
 #define KVM_NR_INTERRUPTS 256
-#define KVM_IRQ_BITMAP_SIZE_BYTES    ((KVM_NR_INTERRUPTS + 7) / 8)
-#define KVM_IRQ_BITMAP_SIZE(type)    (KVM_IRQ_BITMAP_SIZE_BYTES / sizeof(type))
-
 
 /* for KVM_CREATE_MEMORY_REGION */
 struct kvm_memory_region {
@@ -165,7 +159,7 @@ struct kvm_sregs {
        __u64 cr0, cr2, cr3, cr4, cr8;
        __u64 efer;
        __u64 apic_base;
-       __u64 interrupt_bitmap[KVM_IRQ_BITMAP_SIZE(__u64)];
+       __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
 };
 
 struct kvm_msr_entry {