>From 52a33b98a3c53b4e888f71b3c149cf7cec88b026 Mon Sep 17 00:00:00 2001 From: Zhang Xiantao <[EMAIL PROTECTED]> Date: Tue, 20 Nov 2007 23:23:50 +0800 Subject: [PATCH] KVM Portability: Splitting kvm structure. Moving fields vpic and vioapic to kvm_x86. Signed-off-by: Zhang Xiantao <[EMAIL PROTECTED]> --- drivers/kvm/i8259.c | 1 + drivers/kvm/ioapic.c | 7 +++++-- drivers/kvm/kvm.h | 17 ----------------- drivers/kvm/x86.c | 18 ++++++++++-------- drivers/kvm/x86.h | 21 +++++++++++++++++++++ 5 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/drivers/kvm/i8259.c b/drivers/kvm/i8259.c
index f0dc2ee..8871eb8 100644
--- a/drivers/kvm/i8259.c
+++ b/drivers/kvm/i8259.c
@@ -27,6 +27,7 @@
*/
#include <linux/mm.h>
#include "irq.h"
+#include "x86.h"
/*
* set irq level. If an edge is detected, then the IRR is set to 1
diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
index cf1d50b..541164d 100644
--- a/drivers/kvm/ioapic.c
+++ b/drivers/kvm/ioapic.c
@@ -276,7 +276,9 @@ static int get_eoi_gsi(struct kvm_ioapic *ioapic,
int vector)
void kvm_ioapic_update_eoi(struct kvm *kvm, int vector)
{
- struct kvm_ioapic *ioapic = kvm->vioapic;
+ struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
+
+ struct kvm_ioapic *ioapic = kvm_x86->vioapic;
union ioapic_redir_entry *ent;
int gsi;
@@ -386,11 +388,12 @@ void kvm_ioapic_reset(struct kvm_ioapic *ioapic)
int kvm_ioapic_init(struct kvm *kvm)
{
struct kvm_ioapic *ioapic;
+ struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
ioapic = kzalloc(sizeof(struct kvm_ioapic), GFP_KERNEL);
if (!ioapic)
return -ENOMEM;
- kvm->vioapic = ioapic;
+ kvm_x86->vioapic = ioapic;
kvm_ioapic_reset(ioapic);
ioapic->dev.read = ioapic_mmio_read;
ioapic->dev.write = ioapic_mmio_write;
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index dac517f..bcfa555 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -223,29 +223,12 @@ struct kvm {
struct file *filp;
struct kvm_io_bus mmio_bus;
struct kvm_io_bus pio_bus;
- struct kvm_pic *vpic;
- struct kvm_ioapic *vioapic;
int round_robin_prev_vcpu;
unsigned int tss_addr;
struct page *apic_access_page;
struct kvm_vm_stat stat;
};
-static inline struct kvm_pic *pic_irqchip(struct kvm *kvm)
-{
- return kvm->vpic;
-}
-
-static inline struct kvm_ioapic *ioapic_irqchip(struct kvm *kvm)
-{
- return kvm->vioapic;
-}
-
-static inline int irqchip_in_kernel(struct kvm *kvm)
-{
- return pic_irqchip(kvm) != NULL;
-}
-
struct descriptor_table {
u16 limit;
unsigned long base;
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index d41d962..ace1dbc 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -995,6 +995,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
struct kvm *kvm = filp->private_data;
void __user *argp = (void __user *)arg;
int r = -EINVAL;
+ struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
switch (ioctl) {
case KVM_SET_TSS_ADDR:
@@ -1039,12 +1040,12 @@ long kvm_arch_vm_ioctl(struct file *filp,
}
case KVM_CREATE_IRQCHIP:
r = -ENOMEM;
- kvm->vpic = kvm_create_pic(kvm);
- if (kvm->vpic) {
+ kvm_x86->vpic = kvm_create_pic(kvm);
+ if (kvm_x86->vpic) {
r = kvm_ioapic_init(kvm);
if (r) {
- kfree(kvm->vpic);
- kvm->vpic = NULL;
+ kfree(kvm_x86->vpic);
+ kvm_x86->vpic = NULL;
goto out;
}
} else
@@ -1062,7 +1063,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
kvm_pic_set_irq(pic_irqchip(kvm),
irq_event.irq,
irq_event.level);
- kvm_ioapic_set_irq(kvm->vioapic,
+ kvm_ioapic_set_irq(kvm_x86->vioapic,
irq_event.irq,
irq_event.level);
mutex_unlock(&kvm->lock);
@@ -2649,8 +2650,10 @@ static void kvm_free_vcpus(struct kvm *kvm)
void kvm_arch_destroy_vm(struct kvm *kvm)
{
- kfree(kvm->vpic);
- kfree(kvm->vioapic);
+ struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
+
+ kfree(kvm_x86->vpic);
+ kfree(kvm_x86->vioapic);
kvm_free_vcpus(kvm);
kvm_free_physmem(kvm);
kfree(kvm);
@@ -2665,7 +2668,6 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
struct kvm_memory_slot *memslot = &kvm->memslots[mem->slot];
struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
-
/*To keep backward compatibility with older userspace,
*x86 needs to hanlde !user_alloc case.
*/
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
index ea8e635..d16d9a3 100644
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -257,6 +257,8 @@ struct kvm_x86 {
unsigned int n_requested_mmu_pages;
unsigned int n_alloc_mmu_pages;
struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
+ struct kvm_pic *vpic;
+ struct kvm_ioapic *vioapic;
};
static inline struct kvm_x86 *to_kvm_x86(struct kvm *kvm)
@@ -264,6 +266,25 @@ static inline struct kvm_x86 *to_kvm_x86(struct kvm
*kvm)
return container_of(kvm, struct kvm_x86, kvm);
}
+static inline struct kvm_pic *pic_irqchip(struct kvm *kvm)
+{
+ struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
+
+ return kvm_x86->vpic;
+}
+
+static inline struct kvm_ioapic *ioapic_irqchip(struct kvm *kvm)
+{
+ struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
+
+ return kvm_x86->vioapic;
+}
+
+static inline int irqchip_in_kernel(struct kvm *kvm)
+{
+ return pic_irqchip(kvm) != NULL;
+}
+
struct kvm_x86_ops {
int (*cpu_has_kvm_support)(void); /* __init */
int (*disabled_by_bios)(void); /* __init */
--
1.5.1.2
0006-KVM-Portability-Splitting-kvm-structure.patch
Description: 0006-KVM-Portability-Splitting-kvm-structure.patch
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ kvm-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kvm-devel
