From: Pekka Enberg Date: Sun, 28 Mar 2010 16:41:48 +0000 (+0300) Subject: kvm: Move interrupt table to struct kvm X-Git-Tag: next-20110824~3^2~528^2~210 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1c510a76a60179b80699ad38f821f22b15ebdd8c;p=karo-tx-linux.git kvm: Move interrupt table to struct kvm This patch moves the global interrupt table to struct kvm. Signed-off-by: Pekka Enberg --- diff --git a/tools/kvm/include/kvm/interrupt.h b/tools/kvm/include/kvm/interrupt.h index 95d294fb0681..b24e3fd3f766 100644 --- a/tools/kvm/include/kvm/interrupt.h +++ b/tools/kvm/include/kvm/interrupt.h @@ -11,10 +11,11 @@ struct ivt_entry { uint16_t segment; } __attribute__((packed)); -void ivt_reset(void); -void ivt_copy_table(void *dst, unsigned int size); -struct ivt_entry * const ivt_get_entry(unsigned int n); -void ivt_set_entry(struct ivt_entry e, unsigned int n); -void ivt_set_all(struct ivt_entry e); +struct interrupt_table { + struct ivt_entry entries[IVT_VECTORS]; +}; + +void interrupt_table__copy(struct interrupt_table *self, void *dst, unsigned int size); +void interrupt_table__setup(struct interrupt_table *self, struct ivt_entry e); #endif /* KVM__INTERRUPT_H */ diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index f46b32cd2422..1022177ab45b 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -1,6 +1,8 @@ #ifndef KVM__KVM_H #define KVM__KVM_H +#include "kvm/interrupt.h" + #include /* for struct kvm_regs */ #include @@ -21,6 +23,8 @@ struct kvm { struct kvm_regs regs; struct kvm_sregs sregs; + + struct interrupt_table interrupt_table; }; struct kvm *kvm__init(void); diff --git a/tools/kvm/interrupt.c b/tools/kvm/interrupt.c index 0d4ba997ae50..de8d8a1fb620 100644 --- a/tools/kvm/interrupt.c +++ b/tools/kvm/interrupt.c @@ -4,38 +4,18 @@ #include -static struct ivt_entry ivt_table[IVT_VECTORS]; - -void ivt_reset(void) +void interrupt_table__copy(struct interrupt_table *self, void *dst, unsigned int size) { - memset(ivt_table, 0x0, sizeof(ivt_table)); -} - -void ivt_copy_table(void *dst, unsigned int size) -{ - if (size < sizeof(ivt_table)) + if (size < sizeof(self->entries)) die("An attempt to overwrite host memory"); - memcpy(dst, ivt_table, sizeof(ivt_table)); -} -struct ivt_entry * const ivt_get_entry(unsigned int n) -{ - struct ivt_entry *v = NULL; - if (n < IVT_VECTORS) - v = &ivt_table[n]; - return (struct ivt_entry * const)v; -} - -void ivt_set_entry(struct ivt_entry e, unsigned int n) -{ - if (n < IVT_VECTORS) - ivt_table[n] = e; + memcpy(dst, self->entries, sizeof(self->entries)); } -void ivt_set_all(struct ivt_entry e) +void interrupt_table__setup(struct interrupt_table *self, struct ivt_entry e) { unsigned int i; for (i = 0; i < IVT_VECTORS; i++) - ivt_table[i] = e; + self->entries[i] = e; } diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index a6d5f4ed44d1..638441d3107d 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -261,9 +261,9 @@ static bool load_bzimage(struct kvm *self, int fd, const char *kernel_cmdline) .segment = nr >> 4, .offset = (nr - (nr & ~0xf)), }; - ivt_set_all(real_mode_irq); + interrupt_table__setup(&self->interrupt_table, real_mode_irq); p = guest_flat_to_host(self, 0); - ivt_copy_table(p, IVT_VECTORS * sizeof(real_mode_irq)); + interrupt_table__copy(&self->interrupt_table, p, IVT_VECTORS * sizeof(real_mode_irq)); return true; }