Make S390x work in qemu-kvm
PATCH 1/1 Make S390x work in qemu-kvm
We now have S390x KVM support in qemu upstream.
Unfortunately it doesn't work in qemu-kvm, because that has its own main loop and slightly different calling conventions for the KVM helpers.
So let's hack in some small compat ifdefs that make qemu-kvm work on S390x!
--- configure | 4 ++ hw/msix.c | 4 ++ hw/msix.h | 33 +++++++++++++ hw/s390-virtio.c | 6 +++ kvm-tpr-opt.c | 3 + kvm/include/linux/kvm.h | 10 +++- kvm/include/s390/asm/kvm.h | 44 ++++++++++++++++++ qemu-kvm-helper.c | 2 + qemu-kvm.c | 32 ++++++++----- qemu-kvm.h | 8 --- target-s390x/kvm.c | 108 ++++++++++++++++++++++++++++++++++++++++++++ target-s390x/libkvm.h | 26 +++++++++++ 12 files changed, 256 insertions(+), 24 deletions(-) create mode 100644 kvm/include/s390/asm/kvm.h create mode 100644 target-s390x/libkvm.h
configure +4 -0
@@ -188,6 +188,7 @@ case "$cpu" in ;; s390x) cpu="s390x" + target_list="s390x-softmmu" ;; sparc|sun4[cdmuv]) cpu="sparc"
@@ -1430,6 +1431,9 @@ EOF ppc) kvm_arch="powerpc" ;; + s390x) + kvm_arch="s390" + ;; *) kvm_arch="$cpu" ;;
hw/msix.c +4 -0
@@ -11,6 +11,8 @@* the COPYING file in the top-level directory. */ +#ifndef __s390x__ +#include "hw.h" #include "msix.h" #include "pci.h"
@@ -559,3 +561,5 @@ void msix_unuse_all_vectors(PCIDevice *dev)return ; msix_free_irq_entries(dev); } + +#endif
hw/msix.h +33 -0
@@ -4,6 +4,37 @@#include "qemu-common.h" #include "pci.h" +#ifdef __s390x__ + +static int msix_init (PCIDevice *pdev,unsigned short nentries, +unsigned bar_nr,unsigned bar_size) {return 0 ; } + +static void msix_write_config (PCIDevice *pci_dev,uint32_t address, +uint32_t val,int len) { } + +static void msix_mmio_map (PCIDevice *pci_dev,int region_num, +pcibus_t addr,pcibus_t size,int type) { } + +static int msix_uninit (PCIDevice *d) {return 0 ; } + +static void msix_save (PCIDevice *dev,QEMUFile *f) { } +static void msix_load (PCIDevice *dev,QEMUFile *f) { } + +static int msix_enabled (PCIDevice *dev) {return 0 ; } +static int msix_present (PCIDevice *dev) {return 0 ; } + +static uint32_t msix_bar_size (PCIDevice *dev) {return 0 ; } + +static int msix_vector_use (PCIDevice *dev,unsigned vector) {return 0 ; } +static void msix_vector_unuse (PCIDevice *dev,unsigned vector) { } +static void msix_unuse_all_vectors (PCIDevice *dev) { } + +static void msix_notify (PCIDevice *dev,unsigned vector) { } + +static void msix_reset (PCIDevice *dev) { } + +#else +int msix_init (PCIDevice *pdev,unsigned short nentries,unsigned bar_nr,unsigned bar_size);
@@ -34,3 +65,5 @@ void msix_reset(PCIDevice *dev);extern int msix_supported;#endif + +#endif
hw/s390-virtio.c +6 -0
@@ -179,7 +179,9 @@ static void s390_init(ram_addr_t ram_size,exit (1 ); } +#ifdef KVM_UPSTREAM cpu_synchronize_state (env); +#endif env->psw.addr =KERN_IMAGE_START ; env->psw.mask =0x0000000180000000UL ; }
@@ -236,6 +238,10 @@ static void s390_init(ram_addr_t ram_size,qdev_prop_set_drive (dev,"drive" , dinfo);qdev_init_nofail (dev); } + +#ifndef KVM_UPSTREAM +kvm_arch_load_regs (env); +#endif }static QEMUMachine s390_machine = {
kvm-tpr-opt.c +3 -0
@@ -6,6 +6,8 @@* Licensed under the terms of the GNU GPL version 2 or higher. */ +#ifndef __s390x__ +#include "config.h" #include "config-host.h"
@@ -401,3 +403,4 @@ void kvm_tpr_opt_setup(void) register_ioport_write(0x7e, 2, 2, vtpr_ioport_write16, NULL); } +#endif
kvm/include/linux/kvm.h +7 -3
@@ -181,6 +181,11 @@ struct kvm_run {__u64 cr8;__u64 apic_base; +#ifdef __KVM_S390 +/* the processor status word for s390 */ +__u64 psw_mask;/* psw upper half */ +__u64 psw_addr;/* psw lower half */ +#endif union { /* KVM_EXIT_UNKNOWN */ struct {
@@ -232,8 +237,6 @@ struct kvm_run {/* KVM_EXIT_S390_SIEIC */ struct {__u8 icptcode; -__u64 mask;/* psw upper half */ -__u64 addr;/* psw lower half */ __u16 ipa;__u32 ipb; } s390_sieic;
@@ -309,7 +312,7 @@ struct kvm_dirty_log {__u32 slot;__u32 padding1;union { -void *dirty_bitmap;/* one bit per page */ +void __user *dirty_bitmap;/* one bit per page */ __u64 padding2; }; };
@@ -492,6 +495,7 @@ struct kvm_ioeventfd {#ifdef __KVM_HAVE_VCPU_EVENTS#define KVM_CAP_VCPU_EVENTS 41#endif +#define KVM_CAP_S390_PSW 42#ifdef KVM_CAP_IRQ_ROUTING
kvm/include/s390/asm/kvm.h new file +44 -0
44 lines not on this page · raw message
qemu-kvm-helper.c +2 -0
@@ -30,7 +30,9 @@ void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *newenv)static void call_helper_cpuid (void *junk) { +#ifndef __s390x__helper_cpuid (); +#endif }void qemu_kvm_cpuid_on_env (CPUState *env)
qemu-kvm.c +19 -13
@@ -66,7 +66,7 @@ pthread_cond_t qemu_pause_cond = PTHREAD_COND_INITIALIZER;pthread_cond_t qemu_work_cond =PTHREAD_COND_INITIALIZER ; __threadCPUState *current_env; -static int qemu_system_ready; +int qemu_system_ready;#define SIG_IPI (SIGRTMIN+4)
@@ -157,7 +157,7 @@ static void init_slots(void)static int get_free_slot (kvm_context_t kvm) { -int i; +int i =0 ;int tss_ext;#if defined(KVM_CAP_SET_TSS_ADDR ) && !defined(__s390__)
@@ -171,10 +171,12 @@ static int get_free_slot(kvm_context_t kvm)* slot 0 to hold the extended memory, as the vmx will use the last 3 * pages of this slot. */ +#ifndef __s390x__if (tss_ext >0 ) i =0 ;else i =1 ; +#endif for (; i <KVM_MAX_NUM_MEM_REGIONS ; ++i)if (!slots[i].len)
@@ -450,6 +452,14 @@ static void kvm_create_vcpu(CPUState *env, int id) env->kvm_fd = r; env->kvm_state = kvm_state; +#ifdef __s390x__ + r =kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,0 ); +if (r <0 ) { +fprintf (stderr,"kvm_s390_initial_reset: %m\n" ); +exit (1 ); + } +#endif + mmap_size =kvm_ioctl (kvm_state,KVM_GET_VCPU_MMAP_SIZE ,0 );if (mmap_size <0 ) {fprintf (stderr,"get vcpu mmap size: %m\n" );
@@ -939,12 +949,11 @@ int kvm_run(CPUState *env) }#endif -#if !defined(__s390__)if (r ==-1 ) { r =handle_io_window (kvm); goto more; } -#endif +if (1 ) {switch (run->exit_reason) {case KVM_EXIT_UNKNOWN :
@@ -981,14 +990,6 @@ int kvm_run(CPUState *env)case KVM_EXIT_SHUTDOWN : r =handle_shutdown (kvm, env);break ; -#if defined(__s390__) -case KVM_EXIT_S390_SIEIC : - r =kvm_s390_handle_intercept (kvm, env, run); -break ; -case KVM_EXIT_S390_RESET : - r =kvm_s390_handle_reset (kvm, env, run); -break ; -#endif case KVM_EXIT_INTERNAL_ERROR : r =kvm_handle_internal_error (kvm, env, run);break ;
@@ -1127,6 +1128,9 @@ int kvm_destroy_memory_region_works(kvm_context_t kvm)return ret; } +#ifdef __s390x__ +static +#endif int kvm_reinject_control (kvm_context_t kvm,int pit_reinject) {#ifdef KVM_CAP_REINJECT_CONTROL
@@ -1627,7 +1631,7 @@ static void kvm_do_save_mpstate(void *_env)CPUState *env = _env;kvm_arch_save_mpstate (env); -#ifdef KVM_CAP_MP_STATE +#if defined(KVM_CAP_MP_STATE ) && !defined(__s390x__)if (kvm_irqchip_in_kernel ()) env->halted = (env->mp_state ==KVM_MP_STATE_HALTED );#endif
@@ -2293,11 +2297,13 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr, ram_addr_t size,return ;#endif while (size >0 ) { +#ifdef TARGET_I386 p =find_mapping (start_addr);if (p) {kvm_unregister_memory_area (kvm_context, p->phys, p->len);drop_mapping (p->phys); } +#endif start_addr +=TARGET_PAGE_SIZE ;if (size >TARGET_PAGE_SIZE ) { size -=TARGET_PAGE_SIZE ;
qemu-kvm.h +0 -8
@@ -670,14 +670,6 @@ int kvm_enable_vapic(CPUState *env, uint64_t vapic);#endif -#if defined(__s390__) -int kvm_s390_initial_reset (kvm_context_t kvm,int slot); -int kvm_s390_interrupt (kvm_context_t kvm,int slot, -struct kvm_s390_interrupt *kvmint); -int kvm_s390_set_initial_psw (kvm_context_t kvm,int slot,psw_t psw); -int kvm_s390_store_status (kvm_context_t kvm,int slot,unsigned long addr); -#endif -#ifdef KVM_CAP_DEVICE_ASSIGNMENT /*! * \brief Notifies host kernel about a PCI device to be assigned to a guest
target-s390x/kvm.c +108 -0
161 lines not on this page · raw message
target-s390x/libkvm.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* This header is for functions & variables that will ONLY be +* used inside libkvm for x86. +* THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE +* WITHIN LIBKVM. +* +* derived from libkvm.c +* +* Copyright (C) 2006 Qumranet, Inc. +* +* Authors: +* Avi Kivity <[email protected]> +* Yaniv Kamay <[email protected]> +* +* This work is licensed under the GNU LGPL license, version 2. +*/ + +#ifndef KVM_X86_H +#define KVM_X86_H + +#define PAGE_SIZE 4096ul +#define PAGE_MASK (~(PAGE_SIZE - 1)) + +#define smp_wmb () asm volatile("" ::: "memory") + +#endif
Signature · 1 line
1.6.0.2
Quoted 15 lines · Alexander Graf
We now have S390x KVM support in qemu upstream.
Unfortunately it doesn't work in qemu-kvm, because that has its own main loop and slightly different calling conventions for the KVM helpers.
So let's hack in some small compat ifdefs that make qemu-kvm work on S390x!
hw/msix.c +0
-0
hw/msix.c line 16
Quoted 6 lines
hw/msix.c +2
-0@@ -11,6 +11,8 @@* the COPYING file in the top-level directory. */ +#ifndef __s390x__ +
This should be CONFIG_PCI or CONFIG_PCI_MSI. Also, better to hack it at the Makefile level.
hw/msix.h line 8
Quoted 10 lines
hw/msix.h +1
-0@@ -4,6 +4,37 @@#include "qemu-common.h" #include "pci.h" +#ifdef __s390x__
Ditto (minus Makefile).
Quoted 15 lines
hw/s390-virtio.c +2
-0@@ -179,7 +179,9 @@ static void s390_init(ram_addr_t ram_size,exit (1 ); } +#ifdef KVM_UPSTREAM cpu_synchronize_state (env); +#endif env->psw.addr =KERN_IMAGE_START ; env->psw.mask =0x0000000180000000UL ; }
hw/s390-virtio.c static void s390_init(ram_addr_t ram_size, · line 246
Quoted 9 lines
hw/s390-virtio.c +4
-0@@ -236,6 +238,10 @@ static void s390_init(ram_addr_t ram_size,qdev_prop_set_drive (dev,"drive" , dinfo);qdev_init_nofail (dev); } + +#ifndef KVM_UPSTREAM +kvm_arch_load_regs (env); +#endif }
Why isn't cpu_synchronize_state() suitable?
kvm-tpr-opt.c line 10
Quoted 12 lines
hw/s390-virtio.c +0
-0static QEMUMachine s390_machine = {kvm-tpr-opt.c +1
-0@@ -6,6 +6,8 @@* Licensed under the terms of the GNU GPL version 2 or higher. */ +#ifndef __s390x__
@Makefile.
kvm/include/linux/kvm.h
Quoted 5 lines
kvm/include/linux/kvm.h +0
-0
Please post kvm header changes as a separate patch.
qemu-kvm-helper.c void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *newenv) · line 37
Quoted 13 lines
qemu-kvm-helper.c +2
-0@@ -30,7 +30,9 @@ void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *newenv)static void call_helper_cpuid (void *junk) { +#ifndef __s390x__helper_cpuid (); +#endif }
That just has to die (but not in your patches). It dates from the pre-tcg days.
Quoted 10 lines
qemu-kvm-helper.c +1
-1@@ -157,7 +157,7 @@ static void init_slots(void)static int get_free_slot (kvm_context_t kvm) { -int i; +int i =0 ;int tss_ext;#if defined(KVM_CAP_SET_TSS_ADDR )&& !defined(__s390__)
qemu-kvm-helper.c static int get_free_slot(kvm_context_t kvm) · line 180
Quoted 10 lines
qemu-kvm-helper.c +2
-0@@ -171,10 +171,12 @@ static int get_free_slot(kvm_context_t kvm)* slot 0 to hold the extended memory, as the vmx will use the last 3 * pages of this slot. */ +#ifndef __s390x__if (tss_ext>0 ) i =0 ;else i =1 ; +#endif
That should conditioned on x86, not s390. While you're at it, drop the i = 0 assignment please.
Quoted 5 lines
qemu-kvm-helper.c +0
-0for (; i<KVM_MAX_NUM_MEM_REGIONS ; ++i)if (!slots[i].len)@@ -450,6 +452,14 @@ static void kvm_create_vcpu(CPUState *env, int id) env->kvm_fd = r;
qemu-kvm-helper.c static void kvm_create_vcpu(CPUState *env, int id) · line 462
Quoted 10 lines
qemu-kvm-helper.c +7
-0env->kvm_state = kvm_state; +#ifdef __s390x__ + r =kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,0 ); +if (r<0 ) { +fprintf (stderr,"kvm_s390_initial_reset: %m\n" ); +exit (1 ); + } +#endif
Isn't there an arch hook for this?
TARGET_S390 or similar.
Quoted 5 lines
qemu-kvm-helper.c +0
-0switch (run->exit_reason) {case KVM_EXIT_UNKNOWN :@@ -981,14 +990,6 @@ int kvm_run(CPUState *env)case KVM_EXIT_SHUTDOWN : r =handle_shutdown (kvm, env);
qemu-kvm-helper.c int kvm_run(CPUState *env) · line 993
Quoted 10 lines
qemu-kvm-helper.c +0
-8break ; -#if defined(__s390__) -case KVM_EXIT_S390_SIEIC : - r =kvm_s390_handle_intercept (kvm, env, run); -break ; -case KVM_EXIT_S390_RESET : - r =kvm_s390_handle_reset (kvm, env, run); -break ; -#endif
Ditto.
qemu-kvm-helper.c int kvm_run(CPUState *env)
Quoted 5 lines
qemu-kvm-helper.c +3
-0+#ifdef __s390x__ +static +#endif
Lovely. Why?
qemu-kvm-helper.c int kvm_arch_init_vcpu(CPUState *env) · line 96
Quoted 13 lines
int kvm_arch_init_vcpu(CPUState *env) {qemu-kvm-helper.c +4
-0@@ -86,12 +88,27 @@ int kvm_arch_init_vcpu(CPUState *env)return ret; } +#ifdef KVM_UPSTREAM void kvm_arch_reset_vcpu(CPUState *env) +#else +void kvm_arch_cpu_reset(CPUState *env) +#endif
:(
Quoted 21 lines
index 0000000..9a6bcd6
target-s390x/libkvm.h new file +16
-0@@ -0,0 +1,26 @@ +/* +* This header is for functions& variables that will ONLY be +* used inside libkvm for x86. +* THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE +* WITHIN LIBKVM. +* +* derived from libkvm.c +* +* Copyright (C) 2006 Qumranet, Inc. +* +* Authors: +* Avi Kivity<[email protected]> +* Yaniv Kamay<[email protected]> +* +* This work is licensed under the GNU LGPL license, version 2. +*/
target-s390x/libkvm.h line 26
Quoted 10 lines
target-s390x/libkvm.h new file +10
-0+ +#ifndef KVM_X86_H +#define KVM_X86_H + +#define PAGE_SIZE 4096ul +#define PAGE_MASK (~(PAGE_SIZE - 1)) + +#define smp_wmb () asm volatile("" ::: "memory") + +#endif
I thought we no longer include libkvm.h!
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 20 lines · Avi Kivity
Quoted 19 lines · Alexander Graf
We now have S390x KVM support in qemu upstream.
Unfortunately it doesn't work in qemu-kvm, because that has its own main loop and slightly different calling conventions for the KVM helpers.
So let's hack in some small compat ifdefs that make qemu-kvm work on S390x!
hw/msix.c +0
-0@@ -11,6 +11,8 @@* the COPYING file in the top-level directory. */
Quoted 6 lines
hw/msix.c line 16
Quoted 3 lines
hw/msix.c +2
-0+#ifndef __s390x__ +This should be
CONFIG_PCIorCONFIG_PCI_MSI. Also, better to hack it at theMakefilelevel.
That's what I did at first in a hacky way. To be honest, the new makefile structure scares me a bit, so I'm not sure I'll easily figure out how to do that properly :).
Quoted 32 lines
hw/msix.h line 8
Quoted 11 lines
hw/msix.h +1
-0@@ -4,6 +4,37 @@#include "qemu-common.h" #include "pci.h" +#ifdef __s390x__Ditto (minus
Makefile).Quoted 18 lines
hw/s390-virtio.c +2
-0@@ -179,7 +179,9 @@ static void s390_init(ram_addr_t ram_size,exit (1 ); } +#ifdef KVM_UPSTREAM cpu_synchronize_state (env); +#endif env->psw.addr =KERN_IMAGE_START ; env->psw.mask =0x0000000180000000UL ; }@@ -236,6 +238,10 @@ static void s390_init(ram_addr_t ram_size,qdev_prop_set_drive (dev,"drive" , dinfo);qdev_init_nofail (dev); }
Quoted 8 lines
hw/s390-virtio.c static void s390_init(ram_addr_t ram_size, · line 246
Quoted 6 lines
hw/s390-virtio.c +4
-0+ +#ifndef KVM_UPSTREAM +kvm_arch_load_regs (env); +#endif }Why isn't
cpu_synchronize_state()suitable?
Because the KVM fd's are not available yet.
Quoted 17 lines
kvm-tpr-opt.c line 10
Quoted 13 lines
hw/s390-virtio.c +0
-0static QEMUMachine s390_machine = {kvm-tpr-opt.c +1
-0@@ -6,6 +6,8 @@* Licensed under the terms of the GNU GPL version 2 or higher. */ +#ifndef __s390x__@Makefile.
Quoted 7 lines
kvm/include/linux/kvm.h
Quoted 5 lines
kvm/include/linux/kvm.h +0
-0Please post kvm header changes as a separate patch.
Ok.
Quoted 8 lines
Quoted 8 lines
qemu-kvm-helper.c +0
-0@@ -30,7 +30,9 @@ void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *newenv)
Quoted 10 lines
qemu-kvm-helper.c void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *newenv) · line 37
Quoted 7 lines
qemu-kvm-helper.c +2
-0static void call_helper_cpuid (void *junk) { +#ifndef __s390x__helper_cpuid (); +#endif }That just has to die (but not in your patches). It dates from the pre-tcg days.
Yep. IMHO all the code duplication should die :).
Quoted 9 lines
Quoted 9 lines
qemu-kvm-helper.c +1
-1@@ -157,7 +157,7 @@ static void init_slots(void)static int get_free_slot (kvm_context_t kvm) { -int i; +int i =0 ;int tss_ext;
Quoted 16 lines
qemu-kvm-helper.c
Quoted 13 lines
qemu-kvm-helper.c +0
-0#if defined(KVM_CAP_SET_TSS_ADDR )&& !defined(__s390__)@@ -171,10 +171,12 @@ static int get_free_slot(kvm_context_t kvm)* slot 0 to hold the extended memory, as the vmx will use the last 3
* pages of this slot.
*/qemu-kvm-helper.c +2
-0+#ifndef __s390x__if (tss_ext>0 ) i =0 ;else i =1 ; +#endif That should conditioned on x86, not s390. While you're at it, drop the i = 0 assignment please.
So it's useless for IA64 as well?
Quoted 19 lines
Quoted 6 lines
for (; i< KVM_MAX_NUM_MEM_REGIONS; ++i) if (!slots[i].len)qemu-kvm-helper.c +0
-0@@ -450,6 +452,14 @@ static void kvm_create_vcpu(CPUState *env, int id) env->kvm_fd = r;qemu-kvm-helper.c static void kvm_create_vcpu(CPUState *env, int id) · line 462
Quoted 10 lines
qemu-kvm-helper.c +7
-0env->kvm_state = kvm_state; +#ifdef __s390x__ + r =kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,0 ); +if (r<0 ) { +fprintf (stderr,"kvm_s390_initial_reset: %m\n" ); +exit (1 ); + } +#endif Isn't there an arch hook for this?
Quoted 1 line
TARGET_S390or similar.
Yes, there is. I figured this is just a temporary hack, so who cares :-).
Quoted 10 lines
Quoted 10 lines
qemu-kvm-helper.c +0
-3switch (run->exit_reason) {case KVM_EXIT_UNKNOWN :@@ -981,14 +990,6 @@ int kvm_run(CPUState *env)case KVM_EXIT_SHUTDOWN : r =handle_shutdown (kvm, env);break ; -#if defined(__s390__) -case KVM_EXIT_S390_SIEIC : - r =kvm_s390_handle_intercept (kvm, env, run);
Quoted 8 lines
qemu-kvm-helper.c int kvm_run(CPUState *env) · line 993
Quoted 6 lines
qemu-kvm-helper.c +0
-5-break ; -case KVM_EXIT_S390_RESET : - r =kvm_s390_handle_reset (kvm, env, run); -break ; -#endif Ditto.
Ditto what? This is code removal.
Quoted 8 lines
qemu-kvm-helper.c int kvm_run(CPUState *env)
Quoted 6 lines
qemu-kvm-helper.c +3
-0+#ifdef __s390x__ +static +#endif Lovely. Why?
Because it collided with the init function provided by target-s390x/kvm.c.
Quoted 8 lines
Quoted 8 lines
int kvm_arch_init_vcpu(CPUState *env) {qemu-kvm-helper.c +0
-0@@ -86,12 +88,27 @@ int kvm_arch_init_vcpu(CPUState *env)return ret; }
Quoted 8 lines
qemu-kvm-helper.c int kvm_arch_init_vcpu(CPUState *env) · line 96
Quoted 6 lines
qemu-kvm-helper.c +4
-0+#ifdef KVM_UPSTREAM void kvm_arch_reset_vcpu(CPUState *env) +#else +void kvm_arch_cpu_reset(CPUState *env) +#endif :(
Yeah, feel like getting the naming a bit closer? :)
Quoted 26 lines
Quoted 26 lines
index 0000000..9a6bcd6
target-s390x/libkvm.h new file +21
-0@@ -0,0 +1,26 @@ +/* +* This header is for functions& variables that will ONLY be +* used inside libkvm for x86. +* THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE +* WITHIN LIBKVM. +* +* derived from libkvm.c +* +* Copyright (C) 2006 Qumranet, Inc. +* +* Authors: +* Avi Kivity<[email protected]> +* Yaniv Kamay<[email protected]> +* +* This work is licensed under the GNU LGPL license, version 2. +*/ + +#ifndef KVM_X86_H +#define KVM_X86_H + +#define PAGE_SIZE 4096ul
Quoted 9 lines
target-s390x/libkvm.h line 26
Quoted 6 lines
target-s390x/libkvm.h new file +5
-0+#define PAGE_MASK (~(PAGE_SIZE - 1)) + +#define smp_wmb () asm volatile("" ::: "memory") + +#endif I thought we no longer include
libkvm.h!
Some file failed to build without it. IIRC because PAGE_* was not defined.
Alex
Quoted 8 lines · Alexander Graf
Quoted 4 lines
This should be
CONFIG_PCIorCONFIG_PCI_MSI. Also, better to hack it at theMakefilelevel.That's what I did at first in a hacky way. To be honest, the new makefile structure scares me a bit, so I'm not sure I'll easily figure out how to do that properly :).
I'm sure Juan will be glad to help.
Quoted 11 lines
Quoted 9 lines
hw/s390-virtio.c static void s390_init(ram_addr_t ram_size, · line 245
Quoted 7 lines
hw/s390-virtio.c +4
-0+ +#ifndef KVM_UPSTREAM +kvm_arch_load_regs (env); +#endif }Why isn't
cpu_synchronize_state()suitable?Because the KVM fd's are not available yet.
Then kvm_arch_load_regs() will fail as well, no?
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines
static int get_free_slot(kvm_context_t kvm) {qemu-kvm.c +1
-1-int i; +int i =0 ;int tss_ext;Quoted 17 lines
Quoted 8 lines
#if defined(KVM_CAP_SET_TSS_ADDR)&& !defined(__s390__)(quoted diff) +0
-0@@ -171,10 +171,12 @@ static int get_free_slot(kvm_context_t kvm) * slot 0 to hold the extended memory, as the vmx will use thelast 3
* pages of this slot.
*/qemu-kvm.c static int get_free_slot(kvm_context_t kvm) · line 179
Quoted 6 lines
qemu-kvm.c +2
-0+#ifndef __s390x__if (tss_ext>0 ) i =0 ;else i =1 ; +#endif That should conditioned on x86, not s390. While you're at it, drop the i = 0 assignment please.
Quoted 2 lines
So it's useless for IA64 as well?
Yes.
Quoted 17 lines
Quoted 17 lines
Quoted 5 lines
for (; i< KVM_MAX_NUM_MEM_REGIONS; ++i) if (!slots[i].len)qemu-kvm.c +0
-0@@ -450,6 +452,14 @@ static void kvm_create_vcpu(CPUState *env, int id) env->kvm_fd = r; env->kvm_state = kvm_state;qemu-kvm.c static void kvm_create_vcpu(CPUState *env, int id) · line 463
Quoted 10 lines
qemu-kvm.c +7
-0+#ifdef __s390x__ + r =kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,0 ); +if (r<0 ) { +fprintf (stderr,"kvm_s390_initial_reset: %m\n" ); +exit (1 ); + } +#endif Isn't there an arch hook for this?
Quoted 4 lines
Quoted 2 lines
TARGET_S390or similar.Yes, there is. I figured this is just a temporary hack, so who cares :-).
The whole of qemu-kvm.c is a temporary hack. No reason to make it uglier than it needs to be.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
qemu-kvm.c +0
-3break ; -#if defined(__s390__) -case KVM_EXIT_S390_SIEIC : - r =kvm_s390_handle_intercept (kvm, env, run);Quoted 9 lines
qemu-kvm.c int kvm_run(CPUState *env) · line 991
Quoted 7 lines
qemu-kvm.c +0
-5-break ; -case KVM_EXIT_S390_RESET : - r =kvm_s390_handle_reset (kvm, env, run); -break ; -#endif Ditto.
Quoted 2 lines
Ditto what? This is code removal.
Um, yes.
Quoted 9 lines
Quoted 7 lines
qemu-kvm.c int kvm_destroy_memory_region_works(kvm_context_t kvm) · line 1133
Quoted 5 lines
qemu-kvm.c +3
-0+#ifdef __s390x__ +static +#endif Lovely. Why?
Because it collided with the init function provided by
target-s390x/kvm.c.
I'd prefer a separate rename then.
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
int kvm_arch_init_vcpu(CPUState *env) {qemu-kvm.c +0
-0@@ -86,12 +88,27 @@ int kvm_arch_init_vcpu(CPUState *env)return ret; }Quoted 9 lines
target-s390x/kvm.c int kvm_arch_init_vcpu(CPUState *env)
Quoted 7 lines
target-s390x/kvm.c +4
-0+#ifdef KVM_UPSTREAM void kvm_arch_reset_vcpu(CPUState *env) +#else +void kvm_arch_cpu_reset(CPUState *env) +#endif :(
Quoted 2 lines
Yeah, feel like getting the naming a bit closer? :)
A renaming patch would be welcome.
Quoted 5 lines
Quoted 3 lines
I thought we no longer include
libkvm.h!Some file failed to build without it. IIRC because PAGE_* was not defined.
There's a TARGET_PAGE_SIZE or something, we can use that instead.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 21 lines · Avi Kivity
Quoted 8 lines · Alexander Graf
Quoted 4 lines
This should be
CONFIG_PCIorCONFIG_PCI_MSI. Also, better to hack it at theMakefilelevel.That's what I did at first in a hacky way. To be honest, the new makefile structure scares me a bit, so I'm not sure I'll easily figure out how to do that properly :).
I'm sure Juan will be glad to help.
Quoted 9 lines
Quoted 9 lines
hw/s390-virtio.c static void s390_init(ram_addr_t ram_size, · line 245
Quoted 7 lines
hw/s390-virtio.c +4
-0+ +#ifndef KVM_UPSTREAM +kvm_arch_load_regs (env); +#endif }Why isn't
cpu_synchronize_state()suitable?
Quoted 4 lines
Quoted 2 lines
Because the KVM fd's are not available yet.
Then
kvm_arch_load_regs()will fail as well, no?
Eeeh - there was a reason this didn't fail :-). I don't remember.
Quoted 81 lines
Quoted 24 lines
Quoted 7 lines
Quoted 7 lines
static int get_free_slot(kvm_context_t kvm) {qemu-kvm.c +1
-1-int i; +int i =0 ;int tss_ext;Quoted 17 lines
Quoted 8 lines
#if defined(KVM_CAP_SET_TSS_ADDR)&& !defined(__s390__)(quoted diff) +0
-0@@ -171,10 +171,12 @@ static int get_free_slot(kvm_context_t kvm) * slot 0 to hold the extended memory, as the vmx will use thelast 3
* pages of this slot.
*/qemu-kvm.c static int get_free_slot(kvm_context_t kvm) · line 179
Quoted 6 lines
qemu-kvm.c +2
-0+#ifndef __s390x__if (tss_ext>0 ) i =0 ;else i =1 ; +#endif That should conditioned on x86, not s390. While you're at it, drop the i = 0 assignment please.
Quoted 2 lines
So it's useless for IA64 as well?
Yes.
Quoted 18 lines
Quoted 18 lines
Quoted 6 lines
for (; i< KVM_MAX_NUM_MEM_REGIONS; ++i) if (!slots[i].len)qemu-kvm.c +0
-0@@ -450,6 +452,14 @@ static void kvm_create_vcpu(CPUState *env, int id) env->kvm_fd = r; env->kvm_state = kvm_state;qemu-kvm.c static void kvm_create_vcpu(CPUState *env, int · line 464
Quoted 10 lines
qemu-kvm.c +7
-0+#ifdef __s390x__ + r =kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,0 ); +if (r<0 ) { +fprintf (stderr,"kvm_s390_initial_reset: %m\n" ); +exit (1 ); + } +#endif Isn't there an arch hook for this?
Quoted 5 lines
Quoted 2 lines
TARGET_S390or similar.Yes, there is. I figured this is just a temporary hack, so who cares :-).
The whole of
qemu-kvm.cis a temporary hack. No reason to make it uglier than it needs to be.Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
qemu-kvm.c +0
-3break ; -#if defined(__s390__) -case KVM_EXIT_S390_SIEIC : - r =kvm_s390_handle_intercept (kvm, env, run);Quoted 9 lines
qemu-kvm.c int kvm_run(CPUState *env) · line 991
Quoted 7 lines
qemu-kvm.c +0
-5-break ; -case KVM_EXIT_S390_RESET : - r =kvm_s390_handle_reset (kvm, env, run); -break ; -#endif Ditto.
Quoted 2 lines
Ditto what? This is code removal.
Um, yes.
Quoted 7 lines
Quoted 7 lines
qemu-kvm.c int kvm_destroy_memory_region_works(kvm_context_t kvm) · line 1133
Quoted 5 lines
qemu-kvm.c +3
-0+#ifdef __s390x__ +static +#endif Lovely. Why?
Quoted 5 lines
Quoted 3 lines
Because it collided with the init function provided by
target-s390x/kvm.c.I'd prefer a separate rename then.
Rename in kvm.c?
Quoted 30 lines
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
int kvm_arch_init_vcpu(CPUState *env) {qemu-kvm.c +0
-0@@ -86,12 +88,27 @@ int kvm_arch_init_vcpu(CPUState *env)return ret; }Quoted 9 lines
target-s390x/kvm.c int kvm_arch_init_vcpu(CPUState *env)
Quoted 7 lines
target-s390x/kvm.c +4
-0+#ifdef KVM_UPSTREAM void kvm_arch_reset_vcpu(CPUState *env) +#else +void kvm_arch_cpu_reset(CPUState *env) +#endif :(
Quoted 2 lines
Yeah, feel like getting the naming a bit closer? :)
A renaming patch would be welcome.
Quoted 6 lines
Quoted 3 lines
I thought we no longer include
libkvm.h!Some file failed to build without it. IIRC because PAGE_* was not defined.
There's a
TARGET_PAGE_SIZEor something, we can use that instead.
Quoted 5 lines · Alexander Graf
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Why isn't
cpu_synchronize_state()suitable?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Because the KVM fd's are not available yet.
Then
kvm_arch_load_regs()will fail as well, no?Eeeh - there was a reason this didn't fail :-). I don't remember.
Please find out.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Because it collided with the init function provided by
target-s390x/kvm.c.I'd prefer a separate rename then.
Rename in
kvm.c?
kvm.c is harder to coordinate (need to rename in upstream), so rename the qemu-kvm specific function.
Signature · 1 line
error compiling committee.c: too many arguments to function