Re: [kvm-devel] [PATCH] KVM Portability split: Splitting kvm structure (V2)

2007-11-20 Thread Hollis Blanchard
NAK. I sent you a patch queue yesterday that replaces this patch.
(Unfortunately I didn't copy kvm-devel due to technical error; resending
in a moment.)

-- 
Hollis Blanchard
IBM Linux Technology Center

On Tue, 2007-11-20 at 10:29 +0800, Zhang, Xiantao wrote:
 From: Zhang xiantao [EMAIL PROTECTED]
 Date: Tue, 20 Nov 2007 10:08:19 +0800
 Subject: [PATCH] KVM Portability split: Splitting kvm structure.
 Use kvm_x86 to hold x86 specific kvm fields, in this way
 kvm strcut only contains common fields.
 Signed-off-by: Zhang xiantao [EMAIL PROTECTED]
 ---
  drivers/kvm/ioapic.c   |7 +++-
  drivers/kvm/irq.h  |1 +
  drivers/kvm/kvm.h  |   33 -
  drivers/kvm/kvm_main.c |9 --
  drivers/kvm/mmu.c  |   74
 +--
  drivers/kvm/vmx.c  |   18 
  drivers/kvm/x86.c  |   33 +
  drivers/kvm/x86.h  |   50 +++-
  8 files changed, 139 insertions(+), 86 deletions(-)
 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/irq.h b/drivers/kvm/irq.h
 index 5ad3cfd..7180481 100644
 --- a/drivers/kvm/irq.h
 +++ b/drivers/kvm/irq.h
 @@ -23,6 +23,7 @@
  #define __IRQ_H
  
  #include kvm.h
 +#include x86.h
  
  typedef void irq_request_func(void *opaque, int level);
  
 diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
 index 1901456..445012e 100644
 --- a/drivers/kvm/kvm.h
 +++ b/drivers/kvm/kvm.h
 @@ -309,48 +309,16 @@ struct kvm {
   int nmemslots;
   struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS +
   KVM_PRIVATE_MEM_SLOTS];
 - /*
 -  * Hash table of struct kvm_mmu_page.
 -  */
 - struct list_head active_mmu_pages;
 - unsigned int n_free_mmu_pages;
 - unsigned int n_requested_mmu_pages;
 - unsigned int n_alloc_mmu_pages;
 - struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
   struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
   unsigned long rmap_overflow;
   struct list_head vm_list;
   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;
 -} __attribute__((packed));
 -
  /* The guest did something we don't support. */
  #define pr_unimpl(vcpu, fmt, ...)
 \
   do {
 \
 @@ -493,7 +461,6 @@ static inline int memslot_id(struct kvm *kvm, struct
 kvm_memory_slot *slot)
   return slot - kvm-memslots;
  }
  
 -
  enum kvm_stat_kind {
   KVM_STAT_VM,
   KVM_STAT_VCPU,
 diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
 index bda733a..5d4bb68 100644
 --- a/drivers/kvm/kvm_main.c
 +++ b/drivers/kvm/kvm_main.c
 @@ -233,6 +233,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
   struct kvm_memory_slot *memslot;
   struct kvm_memory_slot old, new;
  
 + struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
 +
   r = -EINVAL;
   /* General sanity checks */
   if (mem-memory_size  (PAGE_SIZE - 1))
 @@ -332,18 +334,19 @@ int __kvm_set_memory_region(struct kvm *kvm,
   if (mem-slot = kvm-nmemslots)
   kvm-nmemslots = mem-slot + 1;
  
 - if (!kvm-n_requested_mmu_pages) {
 + if (!kvm_x86-n_requested_mmu_pages) {
   unsigned int n_pages;
  
   if (npages) {
   n_pages = npages * KVM_PERMILLE_MMU_PAGES /
 1000;
 - kvm_mmu_change_mmu_pages(kvm,
 kvm-n_alloc_mmu_pages +
 + kvm_mmu_change_mmu_pages(kvm,
 

Re: [kvm-devel] [PATCH] KVM Portability split: Splitting kvm structure (V2)

2007-11-20 Thread Zhang, Xiantao
Hollis Blanchard wrote:
 NAK. I sent you a patch queue yesterday that replaces this patch.
 (Unfortunately I didn't copy kvm-devel due to technical error;
 resending in a moment.)

Hi Hollis,
Unfortunately, I didn't receive this mail  you mentioned :(.
Does it have new changes except moving the filed stat to kvm_x86?  I
have included them in V3.
BTW, I used git-send-emailt to deliver these mails, seems it still can't
work with you.  I will check my mail format again. Thank you:)
Xiantao

 On Tue, 2007-11-20 at 10:29 +0800, Zhang, Xiantao wrote:
 From: Zhang xiantao [EMAIL PROTECTED]
 Date: Tue, 20 Nov 2007 10:08:19 +0800
 Subject: [PATCH] KVM Portability split: Splitting kvm structure.
 Use kvm_x86 to hold x86 specific kvm fields, in this way
 kvm strcut only contains common fields.
 Signed-off-by: Zhang xiantao [EMAIL PROTECTED] ---
  drivers/kvm/ioapic.c   |7 +++-
  drivers/kvm/irq.h  |1 +
  drivers/kvm/kvm.h  |   33 -
  drivers/kvm/kvm_main.c |9 --
  drivers/kvm/mmu.c  |   74
 +--
  drivers/kvm/vmx.c  |   18 
  drivers/kvm/x86.c  |   33 +
  drivers/kvm/x86.h  |   50 +++-
  8 files changed, 139 insertions(+), 86 deletions(-)
 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/irq.h b/drivers/kvm/irq.h
 index 5ad3cfd..7180481 100644
 --- a/drivers/kvm/irq.h
 +++ b/drivers/kvm/irq.h
 @@ -23,6 +23,7 @@
  #define __IRQ_H
 
  #include kvm.h
 +#include x86.h
 
  typedef void irq_request_func(void *opaque, int level);
 
 diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
 index 1901456..445012e 100644
 --- a/drivers/kvm/kvm.h
 +++ b/drivers/kvm/kvm.h
 @@ -309,48 +309,16 @@ struct kvm {
  int nmemslots;
  struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS + 
 KVM_PRIVATE_MEM_SLOTS]; 
 -/*
 - * Hash table of struct kvm_mmu_page.
 - */
 -struct list_head active_mmu_pages;
 -unsigned int n_free_mmu_pages;
 -unsigned int n_requested_mmu_pages;
 -unsigned int n_alloc_mmu_pages;
 -struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
  struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
  unsigned long rmap_overflow;
  struct list_head vm_list;
  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;
 -} __attribute__((packed));
 -
  /* The guest did something we don't support. */
  #define pr_unimpl(vcpu, fmt, ...)
 \
   do {
 \
 @@ -493,7 +461,6 @@ static inline int memslot_id(struct kvm *kvm,
  struct kvm_memory_slot *slot) return slot - kvm-memslots;
  }
 
 -
  enum kvm_stat_kind {
  KVM_STAT_VM,
  KVM_STAT_VCPU,
 diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
 index bda733a..5d4bb68 100644
 --- a/drivers/kvm/kvm_main.c
 +++ b/drivers/kvm/kvm_main.c
 @@ -233,6 +233,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
  struct kvm_memory_slot *memslot;
  struct kvm_memory_slot old, new;
 
 +struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
 +
  r = -EINVAL;
  /* General sanity checks */
  if (mem-memory_size  (PAGE_SIZE - 1))
 @@ -332,18 +334,19 @@ int __kvm_set_memory_region(struct kvm *kvm,
  if (mem-slot = kvm-nmemslots)
  kvm-nmemslots = mem-slot + 1;
 
 -if (!kvm-n_requested_mmu_pages) {
 +if (!kvm_x86-n_requested_mmu_pages) {
  unsigned int n_pages;
 
  if (npages) {