mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-04 04:31:27 +00:00
kvm: Move interrupt table to struct kvm
This patch moves the global interrupt table to struct kvm. Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
This commit is contained in:
committed by
Will Deacon
parent
06f8237197
commit
da8883c13e
@@ -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 */
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef KVM__KVM_H
|
||||
#define KVM__KVM_H
|
||||
|
||||
#include "kvm/interrupt.h"
|
||||
|
||||
#include <linux/kvm.h> /* for struct kvm_regs */
|
||||
|
||||
#include <stdbool.h>
|
||||
@@ -21,6 +23,8 @@ struct kvm {
|
||||
|
||||
struct kvm_regs regs;
|
||||
struct kvm_sregs sregs;
|
||||
|
||||
struct interrupt_table interrupt_table;
|
||||
};
|
||||
|
||||
struct kvm *kvm__init(void);
|
||||
|
||||
+6
-26
@@ -4,38 +4,18 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
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));
|
||||
|
||||
memcpy(dst, self->entries, sizeof(self->entries));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user