aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2007-07-17 23:05:58 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:18 -0400
commit9eb829ced8c6f2e43a3a644ddf1279ffeee38a33 (patch)
treeea8360405de41110dd0063a9838447c5a7ab2632
parent66aee91aaab8f998d28a61ed7733be17ad8e6d8f (diff)
KVM: Trivial: Use standard BITMAP macros, open-code userspace-exposed header
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>
-rw-r--r--drivers/kvm/kvm.h3
-rw-r--r--drivers/kvm/kvm_main.c2
-rw-r--r--include/linux/kvm.h10
3 files changed, 4 insertions, 11 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 25439a5968f9..cec5f057f3bf 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -324,8 +324,7 @@ struct kvm_vcpu {
324 int guest_mode; 324 int guest_mode;
325 unsigned long requests; 325 unsigned long requests;
326 unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */ 326 unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */
327#define NR_IRQ_WORDS KVM_IRQ_BITMAP_SIZE(unsigned long) 327 DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS);
328 unsigned long irq_pending[NR_IRQ_WORDS];
329 unsigned long regs[NR_VCPU_REGS]; /* for rsp: vcpu_load_rsp_rip() */ 328 unsigned long regs[NR_VCPU_REGS]; /* for rsp: vcpu_load_rsp_rip() */
330 unsigned long rip; /* needs vcpu_load_rsp_rip() */ 329 unsigned long rip; /* needs vcpu_load_rsp_rip() */
331 330
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index af02320012c9..fc63de25d9b0 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -2130,7 +2130,7 @@ static int kvm_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
2130 memcpy(vcpu->irq_pending, sregs->interrupt_bitmap, 2130 memcpy(vcpu->irq_pending, sregs->interrupt_bitmap,
2131 sizeof vcpu->irq_pending); 2131 sizeof vcpu->irq_pending);
2132 vcpu->irq_summary = 0; 2132 vcpu->irq_summary = 0;
2133 for (i = 0; i < NR_IRQ_WORDS; ++i) 2133 for (i = 0; i < ARRAY_SIZE(vcpu->irq_pending); ++i)
2134 if (vcpu->irq_pending[i]) 2134 if (vcpu->irq_pending[i])
2135 __set_bit(i, &vcpu->irq_summary); 2135 __set_bit(i, &vcpu->irq_summary);
2136 2136
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 68ecced40119..8db01a91e1a7 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -12,14 +12,8 @@
12 12
13#define KVM_API_VERSION 12 13#define KVM_API_VERSION 12
14 14
15/* 15/* Architectural interrupt line count. */
16 * Architectural interrupt line count, and the size of the bitmap needed
17 * to hold them.
18 */
19#define KVM_NR_INTERRUPTS 256 16#define KVM_NR_INTERRUPTS 256
20#define KVM_IRQ_BITMAP_SIZE_BYTES ((KVM_NR_INTERRUPTS + 7) / 8)
21#define KVM_IRQ_BITMAP_SIZE(type) (KVM_IRQ_BITMAP_SIZE_BYTES / sizeof(type))
22
23 17
24/* for KVM_CREATE_MEMORY_REGION */ 18/* for KVM_CREATE_MEMORY_REGION */
25struct kvm_memory_region { 19struct kvm_memory_region {
@@ -165,7 +159,7 @@ struct kvm_sregs {
165 __u64 cr0, cr2, cr3, cr4, cr8; 159 __u64 cr0, cr2, cr3, cr4, cr8;
166 __u64 efer; 160 __u64 efer;
167 __u64 apic_base; 161 __u64 apic_base;
168 __u64 interrupt_bitmap[KVM_IRQ_BITMAP_SIZE(__u64)]; 162 __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
169}; 163};
170 164
171struct kvm_msr_entry { 165struct kvm_msr_entry {