Portability: allow for non-x86 headers
PATCH 1/1 Portability: allow for non-x86 headers
These patches allow us to stop unconditionally including x86 headers, which allows us to provide alternative definitions. The first two just split things out to avoid circular header dependencies.
In fact, with just a couple additional hacks, I was finally able to get a stub PowerPC implementation building.
7 files changed, 127 insertions(+), 70 deletions(-) drivers/kvm/i8259.c | 1 drivers/kvm/iodev.h | 63 ++++++++++++++++++++++++++++++++++++++++++ drivers/kvm/irq.h | 8 ++++- drivers/kvm/kvm.h | 72 ++++-------------------------------------------- drivers/kvm/kvm_main.c | 4 -- drivers/kvm/types.h | 41 +++++++++++++++++++++++++++ drivers/kvm/x86.h | 8 +++++
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
PATCH 1/1 Move address types to their own header file
---
2 files changed, 43 insertions(+), 19 deletions(-) drivers/kvm/kvm.h | 21 ++------------------- drivers/kvm/types.h | 41 +++++++++++++++++++++++++++++++++++++++++
drivers/kvm/kvm.h +2 -19
@@ -19,6 +19,8 @@#include <linux/kvm.h> #include <linux/kvm_para.h> + +#include "types.h" #define KVM_MAX_VCPUS 4#define KVM_ALIAS_SLOTS 4
@@ -38,25 +40,6 @@* vcpu->requests bit members */ #define KVM_REQ_TLB_FLUSH 0 - -/* -* Address types: -* -* gva - guest virtual address -* gpa - guest physical address -* gfn - guest frame number -* hva - host virtual address -* hpa - host physical address -* hfn - host frame number -*/ - -typedef unsigned long gva_t ; -typedef u64 gpa_t ; -typedef unsigned long gfn_t ; - -typedef unsigned long hva_t ; -typedef u64 hpa_t ; -typedef unsigned long hfn_t ;#define NR_PTE_CHAIN_ENTRIES 5
drivers/kvm/types.h new file +41 -0
41 lines not on this page · raw message
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Re: [PATCH 1 of 3] Move address types to their own header file
Quoted 1 line · Hollis Blanchard
Signed-off-by Hollis Blanchard <hollisb-r/[email protected]>
These types work for us too.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
PATCH 1/1 Move IO device definitions to its own header file
In reply to Hollis Blanchard---
4 files changed, 65 insertions(+), 42 deletions(-) drivers/kvm/iodev.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/kvm/irq.h | 1 drivers/kvm/kvm.h | 42 -------------------------------- drivers/kvm/kvm_main.c | 1
drivers/kvm/iodev.h new file +63 -0
@@ -0,0 +1,63 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef __KVM_IODEV_H__ +#define __KVM_IODEV_H__ + +#include "types.h" + +struct kvm_io_device { +void (*read)(struct kvm_io_device *this, +gpa_t addr, +int len, +void *val); +void (*write)(struct kvm_io_device *this, +gpa_t addr, +int len, +const void *val); +int (*in_range)(struct kvm_io_device *this,gpa_t addr); +void (*destructor)(struct kvm_io_device *this); + +void *private; +}; + +static inline void kvm_iodevice_read (struct kvm_io_device *dev, +gpa_t addr, +int len, +void *val) +{ + dev->read (dev, addr, len, val); +} + +static inline void kvm_iodevice_write (struct kvm_io_device *dev, +gpa_t addr, +int len, +const void *val) +{ + dev->write (dev, addr, len, val); +} + +static inline int kvm_iodevice_inrange (struct kvm_io_device *dev,gpa_t addr) +{ +return dev->in_range (dev, addr); +} + +static inline void kvm_iodevice_destructor (struct kvm_io_device *dev) +{ +if (dev->destructor) + dev->destructor (dev); +} + +#endif /* __KVM_IODEV_H__ */
drivers/kvm/irq.h +1 -0
@@ -23,6 +23,7 @@#define __IRQ_H#include "kvm.h" +#include "iodev.h" typedef void irq_request_func (void *opaque,int level);
drivers/kvm/kvm.h +0 -42
48 lines not on this page · raw message
drivers/kvm/kvm_main.c +1 -0
@@ -18,6 +18,7 @@#include "kvm.h" #include "x86.h" #include "irq.h" +#include "iodev.h" #include <linux/kvm.h> #include <linux/module.h>
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Re: [PATCH 2 of 3] Move IO device definitions to its own header file
drivers/kvm/kvm_main.c line 24
Quoted 11 lines · Hollis Blanchard
drivers/kvm/kvm_main.c +1
-0@@ -18,6 +18,7 @@#include "kvm.h" #include "x86.h" #include "irq.h" +#include "iodev.h" #include <linux/kvm.h> #include <linux/module.h>
Why do we have that include in kvm_main? I will need to get rid of it for s390 later on.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [kvm-ppc-devel] [PATCH 2 of 3] Move IO device definitions to its own header file
Quoted 10 lines · Carsten Otte
Quoted 9 lines · Hollis Blanchard
drivers/kvm/kvm_main.c +1
-0@@ -18,6 +18,7 @@#include "kvm.h" #include "x86.h" #include "irq.h" +#include "iodev.h"
Quoted 4 lines
drivers/kvm/kvm_main.c line 24
Quoted 2 lines
drivers/kvm/kvm_main.c +0
-0#include <linux/kvm.h> #include <linux/module.h> Why do we have that include in
kvm_main? I will need to get rid of it for s390 later on.
Just because of the call to kvm_iodevice_destructor(). I would be happy to see kvm_io_bus_* moved out to its own files as well, which would solve this issue.
Signature · 9 lines
Hollis Blanchard IBM Linux Technology Center ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
PATCH 1/1 Stop including x86-specific headers in kvm_main.c
In reply to Hollis Blanchard---
5 files changed, 19 insertions(+), 9 deletions(-) drivers/kvm/i8259.c | 1 + drivers/kvm/irq.h | 7 ++++++- drivers/kvm/kvm.h | 9 ++++----- drivers/kvm/kvm_main.c | 3 --- drivers/kvm/x86.h | 8 ++++++++
drivers/kvm/i8259.c +1 -0
@@ -27,6 +27,7 @@*/ #include <linux/mm.h> #include "irq.h" +#include "kvm.h" /* * set irq level. If an edge is detected, then the IRR is set to 1
drivers/kvm/irq.h +6 -1
@@ -22,8 +22,13 @@#ifndef __IRQ_H#define __IRQ_H -#include "kvm.h" +#include <linux/mm_types.h> +#include <linux/hrtimer.h> +#include <asm/kvm.h> #include "iodev.h" + +struct kvm ; +struct kvm_vcpu ;typedef void irq_request_func (void *opaque,int level);
drivers/kvm/kvm.h +4 -5
@@ -287,11 +287,6 @@ static inline int irqchip_in_kernel(stru {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, ...) \
@@ -457,4 +452,8 @@ struct kvm_stats_debugfs_item { };extern struct kvm_stats_debugfs_item debugfs_entries[]; +#if defined(CONFIG_X86 ) +#include "x86.h" #endif + +#endif
drivers/kvm/kvm_main.c +0 -3
@@ -16,8 +16,6 @@*/ #include "kvm.h" -#include "x86.h" -#include "irq.h" #include "iodev.h" #include <linux/kvm.h>
@@ -46,7 +44,6 @@#include <asm/processor.h> #include <asm/io.h> #include <asm/uaccess.h> -#include <asm/desc.h> #include <asm/pgtable.h> MODULE_AUTHOR ("Qumranet" );
drivers/kvm/x86.h +8 -0
@@ -12,12 +12,15 @@#define KVM_X86_H #include "kvm.h" +#include "irq.h" #include <linux/types.h> #include <linux/mm.h> #include <linux/kvm.h> #include <linux/kvm_para.h> + +#include <asm/desc.h> #define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1)#define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD))
@@ -155,6 +158,11 @@ struct kvm_vcpu {struct x86_emulate_ctxt emulate_ctxt; }; + +struct descriptor_table { +u16 limit; +unsigned long base; +} __attribute__((packed));struct kvm_x86_ops {int (*cpu_has_kvm_support)(void );/* __init */
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Re: [PATCH 3 of 3] Stop including x86-specific headers in kvm_main.c
Quoted 1 line · Hollis Blanchard
Signed-off-by Hollis Blanchard <hollisb-r/[email protected]>
Looks good.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
Avi Kivity
AppliedQuoted 5 lines · Hollis Blanchard
These patches allow us to stop unconditionally including x86 headers, which allows us to provide alternative definitions. The first two just split things out to avoid circular header dependencies.
Applied all three, thanks.
Signature · 8 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4