Architecture independence layer - v0 - split generic/x86
PATCH 3/3 Architecture independence layer - v0 - split generic/x86
[Patch 3/3]
This patch moves the arch specific x86 code from kvm_main.c to kvm_x86.c and fills the kvm_arch.h header defining the current interface.
Related part from the 0/3 mail:
- A new header kvm_arch.h specifies the interface the architecture has to implement
- The ioctl interfaces are implemented by the generic kvm_main.c in three ways
a) a completely generic function is covered by kvm_main.c completely
b) a completely arch dependent function is not covered in kvm_main.c - at the end each ioctl goes to a architecture mapping doing the rest of the ioctl
not handled
in the generic part e.g. in kvm_vcpu_ioctl:
default:
r = kvm_arch_vcpu_ioctl(filp, ioctl, arg);
}c) functions that have a significant amount of shared code are implemented by kvm_main.c using kvm_arch_* to implement the arch specific part.
Either by just
mapping the old *_ioctl_whatever to *_arch_whatever or by moving some
more of the
code out of the arch function up to the generic portion e.g.:
case KVM_RUN:
r = -EINVAL;
if (arg)
goto out;
r = kvm_arch_vcpu_run(vcpu, vcpu->run);
break;Signature · 10 lines
Grüsse / regards, Christian Ehrhardt IBM Linux Technology Center, Open Virtualization +49 7031/16-3385 [email protected] [email protected] IBM Deutschland Entwicklung GmbH Vorsitzender des Aufsichtsrats: Johann Weihen Geschäftsführung: Herbert Kircher Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
drivers/kvm/kvm.h +20 -63
@@ -415,65 +415,6 @@ struct descriptor_table {unsigned long base; } __attribute__((packed)); -struct kvm_x86_ops { -int (*cpu_has_kvm_support)(void );/* __init */ -int (*disabled_by_bios)(void );/* __init */ -void (*hardware_enable)(void *dummy);/* __init */ -void (*hardware_disable)(void *dummy); -void (*check_processor_compatibility)(void *rtn); -int (*hardware_setup)(void );/* __init */ -void (*hardware_unsetup)(void );/* __exit */ - -/* Create, but do not attach this VCPU */ -struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm,unsigned id); -void (*vcpu_free)(struct kvm_vcpu *vcpu); - -void (*vcpu_load)(struct kvm_vcpu *vcpu,int cpu); -void (*vcpu_put)(struct kvm_vcpu *vcpu); -void (*vcpu_decache)(struct kvm_vcpu *vcpu); - -int (*set_guest_debug)(struct kvm_vcpu *vcpu, -struct kvm_debug_guest *dbg); -int (*get_msr)(struct kvm_vcpu *vcpu,u32 msr_index,u64 *pdata); -int (*set_msr)(struct kvm_vcpu *vcpu,u32 msr_index,u64 data); -u64 (*get_segment_base)(struct kvm_vcpu *vcpu,int seg); -void (*get_segment)(struct kvm_vcpu *vcpu, -struct kvm_segment *var,int seg); -void (*set_segment)(struct kvm_vcpu *vcpu, -struct kvm_segment *var,int seg); -void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu,int *db,int *l); -void (*decache_cr4_guest_bits)(struct kvm_vcpu *vcpu); -void (*set_cr0)(struct kvm_vcpu *vcpu,unsigned long cr0); -void (*set_cr3)(struct kvm_vcpu *vcpu,unsigned long cr3); -void (*set_cr4)(struct kvm_vcpu *vcpu,unsigned long cr4); -void (*set_efer)(struct kvm_vcpu *vcpu,u64 efer); -void (*get_idt)(struct kvm_vcpu *vcpu,struct descriptor_table *dt); -void (*set_idt)(struct kvm_vcpu *vcpu,struct descriptor_table *dt); -void (*get_gdt)(struct kvm_vcpu *vcpu,struct descriptor_table *dt); -void (*set_gdt)(struct kvm_vcpu *vcpu,struct descriptor_table *dt); -unsigned long (*get_dr)(struct kvm_vcpu *vcpu,int dr); -void (*set_dr)(struct kvm_vcpu *vcpu,int dr,unsigned long value, -int *exception); -void (*cache_regs)(struct kvm_vcpu *vcpu); -void (*decache_regs)(struct kvm_vcpu *vcpu); -unsigned long (*get_rflags)(struct kvm_vcpu *vcpu); -void (*set_rflags)(struct kvm_vcpu *vcpu,unsigned long rflags); - -void (*invlpg)(struct kvm_vcpu *vcpu,gva_t addr); -void (*tlb_flush)(struct kvm_vcpu *vcpu); -void (*inject_page_fault)(struct kvm_vcpu *vcpu, -unsigned long addr,u32 err_code); - -void (*inject_gp)(struct kvm_vcpu *vcpu,unsigned err_code); - -int (*run)(struct kvm_vcpu *vcpu,struct kvm_run *run); -void (*skip_emulated_instruction)(struct kvm_vcpu *vcpu); -void (*patch_hypercall)(struct kvm_vcpu *vcpu, -unsigned char *hypercall_addr); -}; - -extern struct kvm_x86_ops *kvm_x86_ops; -/* The guest did something we don't support. */ #define pr_unimpl (vcpu, fmt, ...) \ do { \
@@ -488,10 +429,6 @@ extern struct kvm_x86_ops *kvm_x86_ops;int kvm_vcpu_init (struct kvm_vcpu *vcpu,struct kvm *kvm,unsigned id);void kvm_vcpu_uninit (struct kvm_vcpu *vcpu); -int kvm_init_x86 (struct kvm_x86_ops *ops,unsigned int vcpu_size, -struct module *module); -void kvm_exit_x86 (void ); -int kvm_mmu_module_init (void );void kvm_mmu_module_exit (void );
@@ -744,4 +681,24 @@ static inline u32 get_rdx_init_val(void)#define TSS_REDIRECTION_SIZE (256 / 8)#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) +/* generic functions provided to arch module part by kvm_main code after split */ +extern __read_mostly struct preempt_ops kvm_preempt_ops; + +void kvm_destroy_vm (struct kvm *kvm); +void kvm_free_physmem_slot (struct kvm_memory_slot *free, +struct kvm_memory_slot *dont); + +struct kvm_io_device *vcpu_find_mmio_dev (struct kvm_vcpu *vcpu, +gpa_t addr); +int complete_pio (struct kvm_vcpu *vcpu); + +__init void kvm_init_debug (void ); +void kvm_exit_debug (void ); + +int kvm_init_generic (unsigned int vcpu_size,struct module *module); +void kvm_exit_generic (void ); + +void vcpu_load (struct kvm_vcpu *vcpu); +void vcpu_put (struct kvm_vcpu *vcpu); +#endif
drivers/kvm/kvm_arch.h +34 -0
@@ -11,4 +11,38 @@#include <linux/module.h> +long kvm_arch_dev_ioctl (struct file *filp,unsigned int ioctl, +unsigned long arg); +void kvm_arch_free_vcpus (struct kvm *kvm); + +long kvm_arch_vm_ioctl (struct file *filp,unsigned int ioctl, +unsigned long arg); +struct kvm_vcpu *kvm_arch_vcpu_create (struct kvm *kvm,unsigned id); +void kvm_arch_vcpu_free (struct kvm_vcpu *vcpu); +void kvm_arch_vcpu_decache (struct kvm_vcpu *vcpu); + +void kvm_arch_vcpu_load (struct kvm_vcpu *vcpu,int cpu); +void kvm_arch_vcpu_put (struct kvm_vcpu *vcpu); +void kvm_arch_cache_regs (struct kvm_vcpu *vcpu); +void kvm_arch_decache_regs (struct kvm_vcpu *vcpu); + +void kvm_arch_skip_emulated_instruction (struct kvm_vcpu *vcpu); +void kvm_arch_inject_gp (struct kvm_vcpu *vcpu); + +long kvm_arch_vcpu_ioctl (struct file *filp,unsigned int ioctl, +unsigned long arg); +int kvm_arch_vcpu_run (struct kvm_vcpu *vcpu,struct kvm_run *kvm_run); +int kvm_arch_vcpu_debug_guest (struct kvm_vcpu *vcpu, +struct kvm_debug_guest *dbg); +int kvm_arch_vcpu_get_regs (struct kvm_vcpu *vcpu,struct kvm_regs *regs); +int kvm_arch_vcpu_set_regs (struct kvm_vcpu *vcpu,struct kvm_regs *regs); +int kvm_arch_vcpu_get_fpu (struct kvm_vcpu *vcpu,struct kvm_fpu *fpu); +int kvm_arch_vcpu_set_fpu (struct kvm_vcpu *vcpu,struct kvm_fpu *fpu); + +void kvm_arch_hardware_enable (void *junk); +void kvm_arch_hardware_disable (void *junk); + +__exit void kvm_arch_exit(void); +__init int kvm_arch_init (void ); +#endif
drivers/kvm/kvm_main.c +55 -1807
2,191 lines not on this page · raw message
drivers/kvm/kvm_x86.c +1851 -0
672 lines not on this page · raw message
drivers/kvm/kvm_x86.h +63 -0
63 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel
Part of the diff is not shown here. View the raw message.
A message that is not in the archive (sent off-list or not yet received): 46CBFE0B.2070102-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
Quoted 26 lines · Christian Ehrhardt
[Patch 3/3]
This patch moves the arch specific x86 code fromkvm_main.ctokvm_x86.cand fills thekvm_arch.h
header defining the current interface.Related part from the 0/3 mail:
- A new headerkvm_arch.hspecifies the interface the architecture has to implement
- The ioctl interfaces are implemented by the generickvm_main.cin three ways
a) a completely generic function is covered bykvm_main.ccompletely
b) a completely arch dependent function is not covered inkvm_main.c- at the end
each ioctl goes to a architecture mapping doing the rest of the
ioctl not handled
in the generic part e.g. inkvm_vcpu_ioctl:default: r = kvm_arch_vcpu_ioctl(filp, ioctl, arg); }c) functions that have a significant amount of shared code are implemented by
kvm_main.cusing kvm_arch_* to implement the arch specific part.
Either by just
mapping the old*_ioctl_whateverto*_arch_whateveror by moving
some more of the
code out of the arch function up to the generic portion e.g.:
Quoted 6 lines
case KVM_RUN:
r = -EINVAL;
if (arg)
goto out;
r = kvm_arch_vcpu_run(vcpu, vcpu->run);
break;The patch is nearly unreadable due to its hugeness (can't be helped, I know). Can you experiment with the magic git switches that detect code movement? Maybe that will give a more readable patch. If not I'll just have to read it all.
The parts I did read seem fine.
Signature · 8 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/