S390x KVM support v4
cover S390x KVM support v4
While S390x was one of the first targets that were supported by KVM it always lacked qemu system emulation support.
In order to change that sad fact, I figured I'd just take on the task myself, taking kuli (http://www.ibm.com/developerworks/linux/linux390/kuli.html),Documentation/s390/kvm.txt and lguest as starting points to write a clean, qemu'ish S390x Virtio machine emulation.
So now you can run Linux VMs on Linux on z/VM on LPAR on zSeries!
This is the resulting code. Please comment on things you like and also on the ones you don't :-).
The patchset is based on Uli's S390x userspace emulation patches. There's not really that much shared functionality, but I didn't want to reimplement the configure wheels. So make sure to have his patches applied first.
Please only run S390x system virtualization using io threads. S390x has very few intercepts and even less that actually reach userspace. So you'll end up with a non-responsive VM without a dedicated IO thread.
Use: $ ./configure --target-list=s390x-softmmu --enable-io-thread
Currently only -kernel, -initrd and friends work. Booting from a real dasd device is not supported.
Also to actually run this code you need a patch for an ugly bug in the kernel module that Carsten sent a patch to on the ML.
I verified that the userspace actually works on a 2.6.27 (SLES11) kernel, so if it doesn't work on current git, please tell me! I'm too afraid that I might end up in a 3270 terminal to update the kernel on my z/VM instance :-).
##### WARNING #####
Apparently the qemu review process has scared off yet another developer for now.
So I'm sending this patchset without relying on Uli's set but rather implemented small stubs for TCG host and TCG guest support, so we can run on KVM. He promised me to send it again "soon" - whenever that is.
These stubs don't serve any purpose but to get KVM running, so you get no x86 on S390X or S390X on x86 for now!
##################
v1 -> v2:
- use new kvm_run variables
- use DO_UPCAST
- add bridge device for "info qtree"
v2 -> v3:
- move memory allocation logic to qemu_ram_alloc
v3 -> v4:
- minor bugfixes
- adjust to more recent qdev nic code
- zipl loader
- include fake emulation series
v4 -> v5:
- remove zipl loader
- remove early printk
Alexander Graf (11):
S/390 CPU fake emulation
S/390 host/target build system support
S/390 fake TCG implementation
Add KVM support for S390x
Allocate physical memory in low virtual address space Add support for S390x system emulation
Add S390x virtio machine bus
Add S390x virtio machine description
S390 GDB stub
Set default console to virtio on S390x
Add S390 maintainer information
MAINTAINERS | 3 + Makefile.target | 2 + configure | 24 ++- cpu-exec.c | 2 + dyngen-exec.h | 2 +- exec.c | 6 + gdbstub.c | 52 ++++ hw/s390-virtio-bus.c | 385 ++++++++++++++++++++++++++++++ hw/s390-virtio-bus.h | 65 +++++ hw/s390-virtio.c | 240 +++++++++++++++++++ target-s390x/cpu.h | 268 +++++++++++++++++++++ target-s390x/exec.h | 56 +++++ target-s390x/helper.c | 84 +++++++ target-s390x/kvm.c | 463 +++++++++++++++++++++++++++++++++++++ target-s390x/machine.c | 30 +++ target-s390x/op_helper.c | 74 ++++++ target-s390x/translate.c | 57 +++++ tcg/s390/tcg-target.c | 103 ++++++++ tcg/s390/tcg-target.h | 48 ++++ vl.c | 26 ++ 20 files changed, 1982 insertions(+), 8 deletions(-) create mode 100644 default-configs/s390x-softmmu.mak create mode 100644 hw/s390-virtio-bus.c create mode 100644 hw/s390-virtio-bus.h create mode 100644 hw/s390-virtio.c create mode 100644 target-s390x/cpu.h create mode 100644 target-s390x/exec.h create mode 100644 target-s390x/helper.c create mode 100644 target-s390x/kvm.c create mode 100644 target-s390x/machine.c create mode 100644 target-s390x/op_helper.c create mode 100644 target-s390x/translate.c create mode 100644 tcg/s390/tcg-target.c create mode 100644 tcg/s390/tcg-target.h
PATCH 1/11 S/390 CPU fake emulation
Because Qemu currently requires a TCG target to exist and there are quite some useful helpers here to lay the groundwork for out KVM target, let's create a stub TCG emulation target for S390X CPUs.
This is required to make tcg happy. The emulation target itself won't work though.
--- cpu-exec.c | 2 + target-s390x/cpu.h | 119 ++++++++++++++++++++++++++++++++++++++++++++++ target-s390x/exec.h | 51 ++++++++++++++++++++ target-s390x/helper.c | 57 ++++++++++++++++++++++ target-s390x/op_helper.c | 74 ++++++++++++++++++++++++++++ target-s390x/translate.c | 57 ++++++++++++++++++++++ 6 files changed, 360 insertions(+), 0 deletions(-) create mode 100644 target-s390x/cpu.h create mode 100644 target-s390x/exec.h create mode 100644 target-s390x/helper.c create mode 100644 target-s390x/op_helper.c create mode 100644 target-s390x/translate.c
cpu-exec.c +2 -0
@@ -249,6 +249,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_MIPS )#elif defined(TARGET_SH4 )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPU
@@ -673,6 +674,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_SH4 )#elif defined(TARGET_ALPHA )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPU
target-s390x/cpu.h new file +119 -0
119 lines not on this page · raw message
target-s390x/exec.h new file +51 -0
51 lines not on this page · raw message
target-s390x/helper.c new file +57 -0
57 lines not on this page · raw message
target-s390x/op_helper.c new file +74 -0
74 lines not on this page · raw message
target-s390x/translate.c new file +57 -0
57 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH 01/11] S/390 CPU fake emulation
Quoted 6 lines · Alexander Graf
Because Qemu currently requires a TCG target to exist and there are quite some useful helpers here to lay the groundwork for out KVM target, let's create a stub TCG emulation target for S390X CPUs.
This is required to make tcg happy. The emulation target itself won't work though.
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>--- cpu-exec.c | 2 + target-s390x/cpu.h | 119 ++++++++++++++++++++++++++++++++++++++++++++++ target-s390x/exec.h | 51 ++++++++++++++++++++ target-s390x/helper.c | 57 ++++++++++++++++++++++ target-s390x/op_helper.c | 74 ++++++++++++++++++++++++++++ target-s390x/translate.c | 57 ++++++++++++++++++++++ 6 files changed, 360 insertions(+), 0 deletions(-) create mode 100644 target-s390x/cpu.h create mode 100644 target-s390x/exec.h create mode 100644 target-s390x/helper.c create mode 100644 target-s390x/op_helper.c create mode 100644 target-s390x/translate.ccpu-exec.c +2
-0@@ -249,6 +249,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_MIPS )#elif defined(TARGET_SH4 )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPU@@ -673,6 +674,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_SH4 )#elif defined(TARGET_ALPHA )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPUtarget-s390x/cpu.h new file +65
-0@@ -0,0 +1,119 @@ +/* +* S/390 virtual CPU header +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ +#ifndef CPU_S390X_H +#define CPU_S390X_H + +#define TARGET_LONG_BITS 64 + +#define ELF_MACHINE EM_S390 + +#define CPUState struct CPUS390XState + +#include "cpu-defs.h" + +#include "softfloat.h" + +#define NB_MMU_MODES 2 // guess +#define MMU_USER_IDX 0 // guess + +typedef union FPReg { + struct { +#ifdef WORDS_BIGENDIAN + float32 e; + int32_t __pad; +#else + int32_t __pad; + float32 e; +#endif + }; + float64 d; + uint64_t i; +} FPReg; + +typedef struct CPUS390XState { + uint64_t regs[16]; /* GP registers */ + + uint32_t aregs[16]; /* access registers */ + + uint32_t fpc; /* floating-point control register */ + FPReg fregs[16]; /* FP registers */ + float_status fpu_status; /* passed to softfloat lib */ + + struct { + uint64_t mask; + uint64_t addr; + } psw; + + int cc; /* condition code (0-3) */ +
target-s390x/cpu.h line 75
Quoted 10 lines
target-s390x/cpu.h new file +10
-0+uint64_t __excp_addr; + +CPU_COMMON +} CPUS390XState; + +#if defined(CONFIG_USER_ONLY ) +static inline void cpu_clone_regs (CPUState *env,target_ulong newsp) +{ +if (newsp) + env->regs[15 ] = newsp;
Coding style.
Quoted 32 lines
target-s390x/cpu.h new file +32
-0+ env->regs[0] = 0; +} +#endif + +CPUS390XState *cpu_s390x_init (const char *cpu_model); +int cpu_s390x_exec (CPUS390XState *s); +void cpu_s390x_close (CPUS390XState *s); + +/* you can call this signal handler from your SIGBUS and SIGSEGV +signal handlers to inform the virtual CPU of exceptions. non zero +is returned if the signal was handled by the virtual CPU. */ +int cpu_s390x_signal_handler (int host_signum,void *pinfo, +void *puc); +int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong address,int rw, +int mmu_idx,int is_softmuu); +#define cpu_handle_mmu_fault cpu_s390x_handle_mmu_fault + +#define TARGET_PAGE_BITS 12 + +#define cpu_init cpu_s390x_init +#define cpu_exec cpu_s390x_exec +#define cpu_gen_code cpu_s390x_gen_code + +#include "cpu-all.h" +#include "exec-all.h" + +#define EXCP_OPEX 1/* operation exception (sigill) */ +#define EXCP_SVC 2/* supervisor call (syscall) */ +#define EXCP_ADDR 5/* addressing exception */ +#define EXCP_EXECUTE_SVC 0xff00000/* supervisor call via execute insn */ + +static inline void cpu_pc_from_tb (CPUState *env,TranslationBlock * tb)
target-s390x/cpu.h line 117
Quoted 10 lines
target-s390x/cpu.h new file +10
-0+{ + env->psw.addr = tb->pc; +} + +static inline void cpu_get_tb_cpu_state (CPUState * env,target_ulong *pc, +target_ulong *cs_base,int *flags) +{ + *pc = env->psw.addr; + *cs_base =0 ; + *flags = env->psw.mask;// guess
I don't know what psw.mask represent, but it may be wrong. It should be a way to identify which TB can be reused, that is they have been generated in the same CPU mode.
Quoted 110 lines
target-s390x/cpu.h new file +2
-0+} +#endif target-s390x/exec.h new file +51
-0@@ -0,0 +1,51 @@ +/* +* S/390 execution defines +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ + +#include "dyngen-exec.h" + +register struct CPUS390XState *env asm(AREG0); + +#include "cpu.h" +#include "exec-all.h" + +static inline int cpu_has_work (CPUState *env) +{ +return env->interrupt_request &CPU_INTERRUPT_HARD ;// guess +} + +static inline void regs_to_env (void ) +{ +} + +static inline void env_to_regs (void ) +{ +} + +static inline int cpu_halted (CPUState *env) +{ +if (!env->halted) { +return 0 ; + } +if (cpu_has_work (env)) { + env->halted =0 ; +return 0 ; + } +return EXCP_HALTED ; +}target-s390x/helper.c new file +45
-0@@ -0,0 +1,57 @@ +/* +* S/390 helpers +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "cpu.h" +#include "exec-all.h" +#include "gdbstub.h" +#include "qemu-common.h" + +CPUS390XState *cpu_s390x_init (const char *cpu_model) +{ +CPUS390XState *env; +static int inited =0 ; + + env =qemu_mallocz (sizeof (CPUS390XState)); +cpu_exec_init (env); +if (!inited) { + inited =1 ; + } + + env->cpu_model_str = cpu_model; +cpu_reset (env); +qemu_init_vcpu (env); +return env; +}
target-s390x/helper.c line 55
Quoted 10 lines
target-s390x/helper.c new file +10
-0+ +void cpu_reset (CPUS390XState *env) +{ +if (qemu_loglevel_mask (CPU_LOG_RESET )) { +qemu_log ("CPU Reset (CPU %d)\n" , env->cpu_index); +log_cpu_state (env,0 ); + } + +memset (env,0 , offsetof(CPUS390XState , breakpoints)); +/* FIXME: reset vector? */
Isn't it also needed by kvm to make reset working?
Quoted 151 lines
target-s390x/helper.c new file +2
-0+tlb_flush (env,1 ); +}target-s390x/op_helper.c new file +74
-0@@ -0,0 +1,74 @@ +/* +* S/390 helper routines +* +* Copyright (c) 2009 Alexander Graf +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ + +#include "exec.h" + +/*****************************************************************************/ +/* Softmmu support */ +#if !defined (CONFIG_USER_ONLY ) + +#define MMUSUFFIX _mmu + +#define SHIFT 0 +#include "softmmu_template.h" + +#define SHIFT 1 +#include "softmmu_template.h" + +#define SHIFT 2 +#include "softmmu_template.h" + +#define SHIFT 3 +#include "softmmu_template.h" + +/* try to fill the TLB and return an exception if error. If retaddr is +NULL, it means that the function was called in C code (i.e. not +from generated code or from helper.c) */ +/* XXX: fix it to restore all registers */ +void tlb_fill (target_ulong addr,int is_write,int mmu_idx,void *retaddr) +{ +TranslationBlock *tb; +CPUState *saved_env; +unsigned long pc; +int ret; + +/* XXX: hack to restore env in all cases, even if not called from +generated code */ + saved_env = env; + env = cpu_single_env; + ret =cpu_s390x_handle_mmu_fault (env, addr, is_write, mmu_idx,1 ); +if (unlikely (ret !=0 )) { +if (likely (retaddr)) { +/* now we have a real cpu fault */ + pc = (unsigned long )retaddr; + tb =tb_find_pc (pc); +if (likely (tb)) { +/* the PC is inside the translated code. It means that we have +a virtual CPU fault */ +cpu_restore_state (tb, env, pc,NULL ); + } + } +/* XXX */ +/* helper_raise_exception_err(env->exception_index, env->error_code); */ + } + env = saved_env; +} + +#endif target-s390x/translate.c new file +57
-0@@ -0,0 +1,57 @@ +/* +* S/390 translation +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ + +#include "cpu.h" +#include "exec-all.h" +#include "disas.h" +#include "tcg-op.h" +#include "qemu-log.h" + +void cpu_dump_state (CPUState *env,FILE *f, +int (*cpu_fprintf)(FILE *f,const char *fmt, ...), +int flags) +{ +int i; +for (i =0 ; i <16 ; i++) { +cpu_fprintf (f,"R%02d=%016lx" , i, env->regs[i]); +if ((i %4 ) ==3 )cpu_fprintf (f,"\n" ); +else cpu_fprintf (f," " ); + } +for (i =0 ; i <16 ; i++) { +cpu_fprintf (f,"F%02d=%016lx" , i, env->fregs[i]); +if ((i %4 ) ==3 )cpu_fprintf (f,"\n" ); +else cpu_fprintf (f," " ); + } +cpu_fprintf (f,"PSW=mask %016lx addr %016lx cc %02x\n" , env->psw.mask, env->psw.addr, env->cc); +} + +void gen_intermediate_code (CPUState *env,struct TranslationBlock *tb) +{ +} + +void gen_intermediate_code_pc (CPUState *env,struct TranslationBlock *tb) +{ +} + +void gen_pc_load (CPUState *env,TranslationBlock *tb, +unsigned long searched_pc,int pc_pos,void *puc) +{ + env->psw.addr = gen_opc_pc[pc_pos]; +}Signature · 1 line
1.6.0.2
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 01/11] S/390 CPU fake emulation
Quoted 167 lines · Aurelien Jarno
Quoted 6 lines · Alexander Graf
Because Qemu currently requires a TCG target to exist and there are quite some useful helpers here to lay the groundwork for out KVM target, let's create a stub TCG emulation target for S390X CPUs.
This is required to make tcg happy. The emulation target itself won't work though.
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>---
cpu-exec.c | 2 + target-s390x/cpu.h | 119 ++++++++++++++++++++++++++++++++++++++++++++++ target-s390x/exec.h | 51 ++++++++++++++++++++ target-s390x/helper.c | 57 ++++++++++++++++++++++ target-s390x/op_helper.c | 74 ++++++++++++++++++++++++++++ target-s390x/translate.c | 57 ++++++++++++++++++++++ 6 files changed, 360 insertions(+), 0 deletions(-)create mode 100644
target-s390x/cpu.h
create mode 100644target-s390x/exec.h
create mode 100644target-s390x/helper.c
create mode 100644target-s390x/op_helper.c
create mode 100644target-s390x/translate.ccpu-exec.c +2
-0@@ -249,6 +249,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_MIPS )#elif defined(TARGET_SH4 )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPU@@ -673,6 +674,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_SH4 )#elif defined(TARGET_ALPHA )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPUtarget-s390x/cpu.h new file +65
-0@@ -0,0 +1,119 @@ +/* +* S/390 virtual CPU header +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ +#ifndef CPU_S390X_H +#define CPU_S390X_H + +#define TARGET_LONG_BITS 64 + +#define ELF_MACHINE EM_S390 + +#define CPUState struct CPUS390XState + +#include "cpu-defs.h" + +#include "softfloat.h" + +#define NB_MMU_MODES 2 // guess +#define MMU_USER_IDX 0 // guess + +typedef union FPReg { + struct { +#ifdef WORDS_BIGENDIAN + float32 e; + int32_t __pad; +#else + int32_t __pad; + float32 e; +#endif + }; + float64 d; + uint64_t i; +} FPReg; + +typedef struct CPUS390XState { + uint64_t regs[16]; /* GP registers */ + + uint32_t aregs[16]; /* access registers */ + + uint32_t fpc; /* floating-point control register */ + FPReg fregs[16]; /* FP registers */ + float_status fpu_status; /* passed to softfloat lib */ + + struct { + uint64_t mask; + uint64_t addr; + } psw; + + int cc; /* condition code (0-3) */ +target-s390x/cpu.h line 75
Quoted 10 lines
target-s390x/cpu.h new file +10
-0+uint64_t __excp_addr; + +CPU_COMMON +} CPUS390XState; + +#if defined(CONFIG_USER_ONLY ) +static inline void cpu_clone_regs (CPUState *env,target_ulong newsp) +{ +if (newsp) + env->regs[15 ] = newsp;Coding style.
Quoted 38 lines
target-s390x/cpu.h new file +38
-0+ env->regs[0 ] =0 ; +} +#endif + +CPUS390XState *cpu_s390x_init (const char *cpu_model); +int cpu_s390x_exec (CPUS390XState *s); +void cpu_s390x_close (CPUS390XState *s); + +/* you can call this signal handler from your SIGBUS and SIGSEGV +signal handlers to inform the virtual CPU of exceptions. non zero +is returned if the signal was handled by the virtual CPU. */ +int cpu_s390x_signal_handler (int host_signum,void *pinfo, +void *puc); +int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong address,int rw, +int mmu_idx,int is_softmuu); +#define cpu_handle_mmu_fault cpu_s390x_handle_mmu_fault + +#define TARGET_PAGE_BITS 12 + +#define cpu_init cpu_s390x_init +#define cpu_exec cpu_s390x_exec +#define cpu_gen_code cpu_s390x_gen_code + +#include "cpu-all.h" +#include "exec-all.h" + +#define EXCP_OPEX 1/* operation exception (sigill) */ +#define EXCP_SVC 2/* supervisor call (syscall) */ +#define EXCP_ADDR 5/* addressing exception */ +#define EXCP_EXECUTE_SVC 0xff00000/* supervisor call via execute insn */ + +static inline void cpu_pc_from_tb (CPUState *env,TranslationBlock * tb) +{ + env->psw.addr = tb->pc; +} + +static inline void cpu_get_tb_cpu_state (CPUState * env,target_ulong *pc, +target_ulong *cs_base,int *flags)
Quoted 8 lines
target-s390x/cpu.h line 117
Quoted 4 lines
target-s390x/cpu.h new file +4
-0+{ + *pc = env->psw.addr; + *cs_base =0 ; + *flags = env->psw.mask;// guess I don't know what psw.mask represent, but it may be wrong. It should be a way to identify which TB can be reused, that is they have been generated in the same CPU mode.
psw.mask is rougly the same as RFLAGS, cr0 and cr4 on x86_64 combined. So IMHO it looked like a pretty good identifier for TB uniqueness.
Alex
Re: [Qemu-devel] [PATCH 01/11] S/390 CPU fake emulation
Quoted 5 lines · Alexander Graf
Quoted 3 lines
I don't know what psw.mask represent, but it may be wrong. It should be a way to identify which TB can be reused, that is they have been generated in the same CPU mode.
psw.mask is rougly the same as RFLAGS, cr0 and cr4 on
x86_64combined. So IMHO it looked like a pretty good identifier for TB uniqueness.
I am not familar with qemu at all here, therefore the following explanation may not fit here. I assume the translation block refers to guest virtual to guest physical memory translations. In that case this is not the right indicator on it's own. The right indicator which translation the cpu would do would be pretty complex:
Our cpu keeps multiple seperate address spaces open at the same time (similar to x86 with a bunch of cr0s), defined by address space control elements in various control registers. Linux uses primary, secondary and home space to address user space and kernel space. The third one is user space once again for exec-type access (to implement stack execute protection). PSW.mask selects which one is to be used for address translation by _default_. Even worse, the cpu may load instructions and data from different adddress spaces (secondary space mdoe). Yet more worse some instructions use "access register mode" where a general purpose register points to yet another address space. A detailed documentation can be found here: http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr002/3.0?DT=20030424140649
That said, I think it's best to keep out softmmu for now. It's not needed for kvm operation and very complex to do right.
Re: [Qemu-devel] [PATCH 01/11] S/390 CPU fake emulation
Quoted 9 lines · Carsten Otte
Quoted 4 lines · Alexander Graf
Quoted 3 lines
I don't know what psw.mask represent, but it may be wrong. It should be a way to identify which TB can be reused, that is they have been generated in the same CPU mode.
psw.mask is rougly the same as RFLAGS, cr0 and cr4 on
x86_64combined. So IMHO it looked like a pretty good identifier for TB uniqueness.I am not familar with qemu at all here, therefore the following explanation may not fit here. I assume the translation block refers to guest virtual to guest physical memory translations. In that case this is not the right indicator on it's own. The right indicator which translation the cpu would do would be pretty complex:
Our cpu keeps multiple seperate address spaces open at the same time (similar to x86 with a bunch of cr0s), defined by address space control elements in various control registers. Linux uses primary, secondary and home space to address user space and kernel space. The third one is user space once again for exec-type access (to implement stack execute protection). PSW.mask selects which one is to be used for address translation by _default_. Even worse, the cpu may load instructions and data from different adddress spaces (secondary space mdoe). Yet more worse some instructions use "access register mode" where a general purpose register points to yet another address space. A detailed documentation can be found here: http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr002/3.0?DT=20030424140649That said, I think it's best to keep out softmmu for now. It's not needed for kvm operation and very complex to do right.
Ah ok, so we're missing the asce register information for softmmu uniqueness. Well - I guess I should put a comment there that tells anyone who feels like implementing a softmmu target that this is a pitfall.
Alex
Re: [Qemu-devel] [PATCH 01/11] S/390 CPU fake emulation
In reply to Carsten Otte2009/12/1 Carsten Otte <[email protected]>:
Quoted 6 lines
Quoted 5 lines · Alexander Graf
Quoted 4 lines
I don't know what psw.mask represent, but it may be wrong. It should be a way to identify which TB can be reused, that is they have been generated in the same CPU mode.
Quoted 8 lines
Quoted 2 lines
psw.mask is rougly the same as RFLAGS, cr0 and cr4 on
x86_64combined. So IMHO it looked like a pretty good identifier for TB uniqueness.I am not familar with qemu at all here, therefore the following explanation may not fit here. I assume the translation block refers to guest virtual to guest physical memory translations. In that case this is not the right indicator on it's own. The right indicator which translation the cpu would do would be pretty complex:
The translation block (TB) refers to a block of host instructions, translated from some block of target instructions under some assumptions. The assumptions used when translating (for example, user vs supervisor mode in the CPU state) are recorded to TB flags. If the CPU state changes, the old TBs with different flags will not be used and new TBs will be generated.
Quoted 4 lines
Our cpu keeps multiple seperate address spaces open at the same time (similar to x86 with a bunch of cr0s), defined by address space control elements in various control registers. Linux uses primary, secondary and home space to address user space and kernel space. The third one is user
Quoted 8 lines
space once again for exec-type access (to implement stack execute protection). PSW.mask selects which one is to be used for address translation by _default_. Even worse, the cpu may load instructions and data from different adddress spaces (secondary space mdoe). Yet more worse some instructions use "access register mode" where a general purpose register points to yet another address space. A detailed documentation can be found here:
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr002/3.0?DT=20030424140649
Actually Sparc64 address spaces and ASIs are very similar. There are nucleus, primary and secondary address spaces (not fully implemented yet in QEMU). Instructions can encode the ASI or %asi register can be used. Some ASIs are restricted for supervisor or hypervisor modes. Sparc32 ASIs are simpler (physical address space extension to 36 bits, basically) and for supervisor only.
For S/390, I think the TB flags do not need to contain the address space control registers if the generated instructions fetch the state from CPU state and do not rely on translation time information. If the address spaces do not change very often, it may alternatively be possible to rely on the CPU state during translation, but then it must be ensured that all generated TBs are always flushed when the registers change.
Re: [Qemu-devel] [PATCH 01/11] S/390 CPU fake emulation
Quoted 6 lines · Blue Swirl
The translation block (TB) refers to a block of host instructions, translated from some block of target instructions under some assumptions. The assumptions used when translating (for example, user vs supervisor mode in the CPU state) are recorded to TB flags. If the CPU state changes, the old TBs with different flags will not be used and new TBs will be generated.
Thanks for the explanation, Alex did explain it too on irc.
Quoted 6 lines
Actually Sparc64 address spaces and ASIs are very similar. There are nucleus, primary and secondary address spaces (not fully implemented yet in QEMU). Instructions can encode the ASI or %asi register can be used. Some ASIs are restricted for supervisor or hypervisor modes. Sparc32 ASIs are simpler (physical address space extension to 36 bits, basically) and for supervisor only.
Oh, I though we were the only odd bird on this one.
Quoted 7 lines
For S/390, I think the TB flags do not need to contain the address space control registers if the generated instructions fetch the state from CPU state and do not rely on translation time information. If the address spaces do not change very often, it may alternatively be possible to rely on the CPU state during translation, but then it must be ensured that all generated TBs are always flushed when the registers change.
Yes, that would work as far as I can tell. The registers change whenever $guest decides to schedule a different task, but not on every syscall.
cheers,
Carsten
Re: [Qemu-devel] [PATCH 01/11] S/390 CPU fake emulation
In reply to Blue SwirlQuoted 21 lines
Quoted 5 lines
Our cpu keeps multiple seperate address spaces open at the same time (similar to x86 with a bunch of cr0s), defined by address space control elements in various control registers. Linux uses primary, secondary and home space to address user space and kernel space. The third one is user space once again for exec-type access (to implement stack execute
Quoted 8 lines
protection). PSW.mask selects which one is to be used for address translation by _default_. Even worse, the cpu may load instructions and data from different adddress spaces (secondary space mdoe). Yet more worse some instructions use "access register mode" where a general purpose register points to yet another address space. A detailed documentation can be found here:
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dz9zr002/3.0?DT=200
30424140649Actually Sparc64 address spaces and ASIs are very similar. There are nucleus, primary and secondary address spaces (not fully implemented yet in QEMU). Instructions can encode the ASI or %asi register can be used. Some ASIs are restricted for supervisor or hypervisor modes. Sparc32 ASIs are simpler (physical address space extension to 36 bits, basically) and for supervisor only.
Quoted 7 lines
For S/390, I think the TB flags do not need to contain the address space control registers if the generated instructions fetch the state from CPU state and do not rely on translation time information. If the address spaces do not change very often, it may alternatively be possible to rely on the CPU state during translation, but then it must be ensured that all generated TBs are always flushed when the registers change.
It sounds like there's some confusion between virtual address translation and state that effects instruction semantics. The TB flags should include the latter. The former isn't particularly well supported in qemu. If you have more than a couple of different address spaces (i.e. kernel and userspace) then you basically have to flush the TLB every time the current address space changes. If the address space an be selected per-instruction then you're pretty much screwed.
Paul
Re: [Qemu-devel] [PATCH 01/11] S/390 CPU fake emulation
In reply to Alexander GrafQuoted 179 lines · Alexander Graf
Quoted 167 lines · Aurelien Jarno
Quoted 6 lines · Alexander Graf
Because Qemu currently requires a TCG target to exist and there are quite some useful helpers here to lay the groundwork for out KVM target, let's create a stub TCG emulation target for S390X CPUs.
This is required to make tcg happy. The emulation target itself won't work though.
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>---
cpu-exec.c | 2 + target-s390x/cpu.h | 119 ++++++++++++++++++++++++++++++++++++++++++++++ target-s390x/exec.h | 51 ++++++++++++++++++++ target-s390x/helper.c | 57 ++++++++++++++++++++++ target-s390x/op_helper.c | 74 ++++++++++++++++++++++++++++ target-s390x/translate.c | 57 ++++++++++++++++++++++ 6 files changed, 360 insertions(+), 0 deletions(-)create mode 100644
target-s390x/cpu.h
create mode 100644target-s390x/exec.h
create mode 100644target-s390x/helper.c
create mode 100644target-s390x/op_helper.c
create mode 100644target-s390x/translate.ccpu-exec.c +2
-0@@ -249,6 +249,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_MIPS )#elif defined(TARGET_SH4 )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPU@@ -673,6 +674,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_SH4 )#elif defined(TARGET_ALPHA )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPUtarget-s390x/cpu.h new file +65
-0@@ -0,0 +1,119 @@ +/* +* S/390 virtual CPU header +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ +#ifndef CPU_S390X_H +#define CPU_S390X_H + +#define TARGET_LONG_BITS 64 + +#define ELF_MACHINE EM_S390 + +#define CPUState struct CPUS390XState + +#include "cpu-defs.h" + +#include "softfloat.h" + +#define NB_MMU_MODES 2 // guess +#define MMU_USER_IDX 0 // guess + +typedef union FPReg { + struct { +#ifdef WORDS_BIGENDIAN + float32 e; + int32_t __pad; +#else + int32_t __pad; + float32 e; +#endif + }; + float64 d; + uint64_t i; +} FPReg; + +typedef struct CPUS390XState { + uint64_t regs[16]; /* GP registers */ + + uint32_t aregs[16]; /* access registers */ + + uint32_t fpc; /* floating-point control register */ + FPReg fregs[16]; /* FP registers */ + float_status fpu_status; /* passed to softfloat lib */ + + struct { + uint64_t mask; + uint64_t addr; + } psw; + + int cc; /* condition code (0-3) */ +target-s390x/cpu.h line 75
Quoted 10 lines
target-s390x/cpu.h new file +10
-0+uint64_t __excp_addr; + +CPU_COMMON +} CPUS390XState; + +#if defined(CONFIG_USER_ONLY ) +static inline void cpu_clone_regs (CPUState *env,target_ulong newsp) +{ +if (newsp) + env->regs[15 ] = newsp;Coding style.
Quoted 38 lines
target-s390x/cpu.h new file +38
-0+ env->regs[0 ] =0 ; +} +#endif + +CPUS390XState *cpu_s390x_init (const char *cpu_model); +int cpu_s390x_exec (CPUS390XState *s); +void cpu_s390x_close (CPUS390XState *s); + +/* you can call this signal handler from your SIGBUS and SIGSEGV +signal handlers to inform the virtual CPU of exceptions. non zero +is returned if the signal was handled by the virtual CPU. */ +int cpu_s390x_signal_handler (int host_signum,void *pinfo, +void *puc); +int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong address,int rw, +int mmu_idx,int is_softmuu); +#define cpu_handle_mmu_fault cpu_s390x_handle_mmu_fault + +#define TARGET_PAGE_BITS 12 + +#define cpu_init cpu_s390x_init +#define cpu_exec cpu_s390x_exec +#define cpu_gen_code cpu_s390x_gen_code + +#include "cpu-all.h" +#include "exec-all.h" + +#define EXCP_OPEX 1/* operation exception (sigill) */ +#define EXCP_SVC 2/* supervisor call (syscall) */ +#define EXCP_ADDR 5/* addressing exception */ +#define EXCP_EXECUTE_SVC 0xff00000/* supervisor call via execute insn */ + +static inline void cpu_pc_from_tb (CPUState *env,TranslationBlock * tb) +{ + env->psw.addr = tb->pc; +} + +static inline void cpu_get_tb_cpu_state (CPUState * env,target_ulong *pc, +target_ulong *cs_base,int *flags)Quoted 8 lines
target-s390x/cpu.h line 117
Quoted 4 lines
target-s390x/cpu.h new file +4
-0+{ + *pc = env->psw.addr; + *cs_base =0 ; + *flags = env->psw.mask;// guess I don't know what psw.mask represent, but it may be wrong. It should be a way to identify which TB can be reused, that is they have been generated in the same CPU mode.
Quoted 2 lines
psw.mask is rougly the same as RFLAGS, cr0 and cr4 on
x86_64combined. So IMHO it looked like a pretty good identifier for TB uniqueness.
Then it's most probably correct, except some bits may have to be ignored. Can you update the comment explaining that?
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 01/11] S/390 CPU fake emulation
Quoted 180 lines · Aurelien Jarno
Quoted 179 lines · Alexander Graf
Quoted 175 lines · Aurelien Jarno
Quoted 6 lines · Alexander Graf
Because Qemu currently requires a TCG target to exist and there are quite some useful helpers here to lay the groundwork for out KVM target, let's create a stub TCG emulation target for S390X CPUs.
This is required to make tcg happy. The emulation target itself won't work though.
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>---
cpu-exec.c | 2 + target-s390x/cpu.h | 119 ++++++++++++++++++++++++++++++++++++++++++++++ target-s390x/exec.h | 51 ++++++++++++++++++++ target-s390x/helper.c | 57 ++++++++++++++++++++++ target-s390x/op_helper.c | 74 ++++++++++++++++++++++++++++ target-s390x/translate.c | 57 ++++++++++++++++++++++ 6 files changed, 360 insertions(+), 0 deletions(-)create mode 100644
target-s390x/cpu.h
create mode 100644target-s390x/exec.h
create mode 100644target-s390x/helper.c
create mode 100644target-s390x/op_helper.c
create mode 100644target-s390x/translate.ccpu-exec.c +2
-0@@ -249,6 +249,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_MIPS )#elif defined(TARGET_SH4 )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPU@@ -673,6 +674,7 @@ int cpu_exec(CPUState *env1)#elif defined(TARGET_SH4 )#elif defined(TARGET_ALPHA )#elif defined(TARGET_CRIS ) +#elif defined(TARGET_S390X )/* XXXXX */ #else #error unsupported target CPUtarget-s390x/cpu.h new file +65
-0@@ -0,0 +1,119 @@ +/* +* S/390 virtual CPU header +* +* Copyright (c) 2009 Ulrich Hecht +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA +*/ +#ifndef CPU_S390X_H +#define CPU_S390X_H + +#define TARGET_LONG_BITS 64 + +#define ELF_MACHINE EM_S390 + +#define CPUState struct CPUS390XState + +#include "cpu-defs.h" + +#include "softfloat.h" + +#define NB_MMU_MODES 2 // guess +#define MMU_USER_IDX 0 // guess + +typedef union FPReg { + struct { +#ifdef WORDS_BIGENDIAN + float32 e; + int32_t __pad; +#else + int32_t __pad; + float32 e; +#endif + }; + float64 d; + uint64_t i; +} FPReg; + +typedef struct CPUS390XState { + uint64_t regs[16]; /* GP registers */ + + uint32_t aregs[16]; /* access registers */ + + uint32_t fpc; /* floating-point control register */ + FPReg fregs[16]; /* FP registers */ + float_status fpu_status; /* passed to softfloat lib */ + + struct { + uint64_t mask; + uint64_t addr; + } psw; + + int cc; /* condition code (0-3) */ +target-s390x/cpu.h line 75
Quoted 10 lines
target-s390x/cpu.h new file +10
-0+uint64_t __excp_addr; + +CPU_COMMON +} CPUS390XState; + +#if defined(CONFIG_USER_ONLY ) +static inline void cpu_clone_regs (CPUState *env,target_ulong newsp) +{ +if (newsp) + env->regs[15 ] = newsp;Coding style.
Quoted 32 lines
target-s390x/cpu.h new file +32
-0+ env->regs[0] = 0; +} +#endif + +CPUS390XState *cpu_s390x_init (const char *cpu_model); +int cpu_s390x_exec (CPUS390XState *s); +void cpu_s390x_close (CPUS390XState *s); + +/* you can call this signal handler from your SIGBUS and SIGSEGV +signal handlers to inform the virtual CPU of exceptions. non zero +is returned if the signal was handled by the virtual CPU. */ +int cpu_s390x_signal_handler (int host_signum,void *pinfo, +void *puc); +int cpu_s390x_handle_mmu_fault (CPUS390XState *env,target_ulong address,int rw, +int mmu_idx,int is_softmuu); +#define cpu_handle_mmu_fault cpu_s390x_handle_mmu_fault + +#define TARGET_PAGE_BITS 12 + +#define cpu_init cpu_s390x_init +#define cpu_exec cpu_s390x_exec +#define cpu_gen_code cpu_s390x_gen_code + +#include "cpu-all.h" +#include "exec-all.h" + +#define EXCP_OPEX 1/* operation exception (sigill) */ +#define EXCP_SVC 2/* supervisor call (syscall) */ +#define EXCP_ADDR 5/* addressing exception */ +#define EXCP_EXECUTE_SVC 0xff00000/* supervisor call via execute insn */ + +static inline void cpu_pc_from_tb (CPUState *env,TranslationBlock * tb)target-s390x/cpu.h line 117
Quoted 10 lines
target-s390x/cpu.h new file +10
-0+{ + env->psw.addr = tb->pc; +} + +static inline void cpu_get_tb_cpu_state (CPUState * env,target_ulong *pc, +target_ulong *cs_base,int *flags) +{ + *pc = env->psw.addr; + *cs_base =0 ; + *flags = env->psw.mask;// guess I don't know what psw.mask represent, but it may be wrong. It should be a way to identify which TB can be reused, that is they have been generated in the same CPU mode.
Quoted 5 lines
Quoted 2 lines
psw.mask is rougly the same as RFLAGS, cr0 and cr4 on
x86_64combined. So IMHO it looked like a pretty good identifier for TB uniqueness.Then it's most probably correct, except some bits may have to be ignored. Can you update the comment explaining that?
Yep.
Alex
PATCH 2/11 S/390 host/target build system support
In reply to Alexander GrafThis patch makes configure aware of S390 hosts and guests. When not explicitly defined using --target-list= no S390 targets will be built though.
--- configure | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-)
configure +14 -6
@@ -158,9 +158,12 @@ case "$cpu" in parisc|parisc64) cpu="hppa" ;; - s390*) + s390) cpu="s390" ;; + s390x) + cpu="s390x" + ;; sparc|sun4[cdmuv]) cpu="sparc" ;;
@@ -862,7 +865,7 @@ fi # host long bits test hostlongbits="32" case "$cpu" in - x86_64|alpha|ia64|sparc64|ppc64) + x86_64|alpha|ia64|sparc64|ppc64|s390x) hostlongbits=64 ;; esac
@@ -1874,7 +1877,7 @@ echo >> $config_host_mak echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak case "$cpu" in - i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64) + i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64) ARCH=$cpu ;; armv4b|armv4l)
@@ -2158,7 +2161,7 @@ target_arch2=`echo $target | cut -d '-' -f 1` target_bigendian="no" case "$target_arch2" in - armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus) + armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus) target_bigendian=yes ;; esac
@@ -2326,6 +2329,9 @@ case "$target_arch2" in echo "TARGET_ABI32=y" >> $config_target_mak target_phys_bits=64 ;; + s390x) + target_phys_bits=64 + ;; *) echo "Unsupported target CPU" exit 1
@@ -2394,7 +2400,7 @@ if test ! -z "$gdb_xml_files" ; then fi case "$target_arch2" in - arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus) + arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus) echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak ;; *)
@@ -2427,6 +2433,8 @@ ldflags="" if test "$ARCH" = "sparc64" ; then cflags="-I\$(SRC_PATH)/tcg/sparc $cflags" +elif test "$ARCH" = "s390x" ; then + cflags="-I\$(SRC_PATH)/tcg/s390 $cflags" else cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags" fi
@@ -2462,7 +2470,7 @@ for i in $ARCH $TARGET_BASE_ARCH ; do ppc*) echo "CONFIG_PPC_DIS=y" >> $config_target_mak ;; - s390) + s390*) echo "CONFIG_S390_DIS=y" >> $config_target_mak ;; sh4)
Signature · 1 line
1.6.0.2
PATCH 3/11 S/390 fake TCG implementation
In reply to Alexander GrafQemu won't let us run a KVM target without having host TCG support. Well, for now we don't have any so let's implement a fake target that only stubs out everything.
I tried to keep the patch as close to Uli's source as possible, so whenever he feels like it he can easily diff his version against this one.
--- dyngen-exec.h | 2 +- target-s390x/helper.c | 5 ++ tcg/s390/tcg-target.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ tcg/s390/tcg-target.h | 48 +++++++++++++++++++++++ 4 files changed, 157 insertions(+), 1 deletions(-) create mode 100644 tcg/s390/tcg-target.c create mode 100644 tcg/s390/tcg-target.h
dyngen-exec.h +1 -1
@@ -117,7 +117,7 @@ extern int printf(const char *, ...);/* The return address may point to the start of the next instruction. Subtracting one gets us the call instruction itself. */ -#if defined(__s390__) +#if defined(__s390__) && !defined(__s390x__)# define GETPC () ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))#elif defined(__arm__)/* Thumb return addresses have the low bit set, so we need to subtract two.
target-s390x/helper.c +5 -0
@@ -44,6 +44,11 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model)return env; } +target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr; +} +void cpu_reset (CPUS390XState *env) {if (qemu_loglevel_mask (CPU_LOG_RESET )) {
tcg/s390/tcg-target.c new file +103 -0
103 lines not on this page · raw message
tcg/s390/tcg-target.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH 03/11] S/390 fake TCG implementation
Quoted 6 lines · Alexander Graf
Qemu won't let us run a KVM target without having host TCG support. Well, for now we don't have any so let's implement a fake target that only stubs out everything.
I tried to keep the patch as close to Uli's source as possible, so whenever he feels like it he can easily diff his version against this one.
Please find the comments below.
Quoted 28 lines
Signed-off-by Alexander Graf <[email protected]>--- dyngen-exec.h | 2 +- target-s390x/helper.c | 5 ++ tcg/s390/tcg-target.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ tcg/s390/tcg-target.h | 48 +++++++++++++++++++++++ 4 files changed, 157 insertions(+), 1 deletions(-) create mode 100644 tcg/s390/tcg-target.c create mode 100644 tcg/s390/tcg-target.hdyngen-exec.h +1
-1@@ -117,7 +117,7 @@ extern int printf(const char *, ...);/* The return address may point to the start of the next instruction. Subtracting one gets us the call instruction itself. */ -#if defined(__s390__) +#if defined(__s390__) && !defined(__s390x__)# define GETPC () ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))#elif defined(__arm__)/* Thumb return addresses have the low bit set, so we need to subtract two. target-s390x/helper.c +0
-0
target-s390x/helper.c CPUS390XState *cpu_s390x_init(const char *cpu_model) · line 51
Quoted 8 lines
target-s390x/helper.c +5
-0@@ -44,6 +44,11 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model)return env; } +target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr; +} +
Why does it appear in this patch? It has nothing to do with TCG support.
Quoted 88 lines
target-s390x/helper.c +0
-0void cpu_reset (CPUS390XState *env) {if (qemu_loglevel_mask (CPU_LOG_RESET )) {tcg/s390/tcg-target.c new file +79
-0@@ -0,0 +1,103 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +static const int tcg_target_reg_alloc_order[] = { +}; + +static const int tcg_target_call_iarg_regs[] = { +}; + +static const int tcg_target_call_oarg_regs[] = { +}; + +static void patch_reloc (uint8_t *code_ptr,int type, +tcg_target_long value,tcg_target_long addend) +{ +tcg_abort (); +} + +static inline int tcg_target_get_call_iarg_regs_count (int flags) +{ +tcg_abort (); +return 0 ; +} + +/* parse target specific constraints */ +static int target_parse_constraint (TCGArgConstraint *ct,const char **pct_str) +{ +tcg_abort (); +return 0 ; +} + +/* Test if a constant matches the constraint. */ +static inline int tcg_target_const_match (tcg_target_long val, +const TCGArgConstraint *arg_ct) +{ +tcg_abort (); +return 0 ; +} + +/* load a register with an immediate value */ +static inline void tcg_out_movi (TCGContext *s,TCGType type, +int ret,tcg_target_long arg) +{ +tcg_abort (); +} + +/* load data without address translation or endianness conversion */ +static inline void tcg_out_ld (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +} + +static inline void tcg_out_st (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +}
tcg/s390/tcg-target.c line 89
Quoted 10 lines
tcg/s390/tcg-target.c new file +10
-0+ +static inline void tcg_out_op (TCGContext *s,int opc, +const TCGArg *args,const int *const_args) +{ +tcg_abort (); +} + +void tcg_target_init (TCGContext *s) +{ +}
This is probably here that tcg_abort() is actually the most important.
tcg/s390/tcg-target.c line 94
Quoted 5 lines
tcg/s390/tcg-target.c new file +5
-0+ +void tcg_target_qemu_prologue (TCGContext *s) +{ +} +
Also adding it here doesn't cost a lot.
Quoted 38 lines
tcg/s390/tcg-target.c new file +9
-0+static inline void tcg_out_mov (TCGContext *s,int ret,int arg) +{ +tcg_abort (); +} + +static inline void tcg_out_addi (TCGContext *s,int reg,tcg_target_long val) +{ +tcg_abort (); +}tcg/s390/tcg-target.h new file +23
-0@@ -0,0 +1,48 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/
tcg/s390/tcg-target.h line 33
Quoted 10 lines
tcg/s390/tcg-target.h new file +10
-0+#define TCG_TARGET_S390 1 + +#define TCG_TARGET_REG_BITS 64 +#define TCG_TARGET_WORDS_BIGENDIAN + +#define TCG_TARGET_NB_REGS 0 + +enum { +TCG_AREG0 =0 , +};
As this is defined in Uli's patch, I think it might be a good idea to define that correctly. Same for the list of registers.
tcg/s390/tcg-target.h line 44
Quoted 10 lines
tcg/s390/tcg-target.h new file +10
-0+/* used for function call generation */ +#define TCG_REG_CALL_STACK 0 +#define TCG_TARGET_STACK_ALIGN 8 +#define TCG_TARGET_CALL_STACK_OFFSET 0 + +static inline void flush_icache_range (unsigned long start,unsigned long stop) +{ +#if QEMU_GNUC_PREREQ (4 ,1 ) +void __clear_cache (char *beg,char *end); +__clear_cache ((char *) start, (char *) stop);
You should use __builtin___clear_cache instead to avoid having to declare the function.
Quoted 10 lines
tcg/s390/tcg-target.h new file +4
-0+#else +#error not implemented +#endif +}Signature · 1 line
1.6.0.2
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 03/11] S/390 fake TCG implementation
Quoted 41 lines · Aurelien Jarno
Quoted 6 lines · Alexander Graf
Qemu won't let us run a KVM target without having host TCG support. Well, for now we don't have any so let's implement a fake target that only stubs out everything.
I tried to keep the patch as close to Uli's source as possible, so whenever he feels like it he can easily diff his version against this one.
Please find the comments below.
Quoted 31 lines
Signed-off-by Alexander Graf <[email protected]>---
dyngen-exec.h | 2 +- target-s390x/helper.c | 5 ++ tcg/s390/tcg-target.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ tcg/s390/tcg-target.h | 48 +++++++++++++++++++++++ 4 files changed, 157 insertions(+), 1 deletions(-)create mode 100644
tcg/s390/tcg-target.c
create mode 100644tcg/s390/tcg-target.hdyngen-exec.h +1
-1@@ -117,7 +117,7 @@ extern int printf(const char *, ...);/* The return address may point to the start of the next instruction. Subtracting one gets us the call instruction itself. */ -#if defined(__s390__) +#if defined(__s390__) && !defined(__s390x__)# define GETPC () ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))#elif defined(__arm__)/* Thumb return addresses have the low bit set, so we need to subtract two. target-s390x/helper.c +0
-0@@ -44,6 +44,11 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model)return env; }
Quoted 7 lines
target-s390x/helper.c CPUS390XState *cpu_s390x_init(const char *cpu_model) · line 51
Quoted 5 lines
target-s390x/helper.c +5
-0+target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr; +} +Why does it appear in this patch? It has nothing to do with TCG support.
I don't remember. What is this used for anyways?
Quoted 101 lines
Quoted 88 lines
target-s390x/helper.c +0
-0void cpu_reset (CPUS390XState *env) {if (qemu_loglevel_mask (CPU_LOG_RESET )) {tcg/s390/tcg-target.c new file +79
-0@@ -0,0 +1,103 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +static const int tcg_target_reg_alloc_order[] = { +}; + +static const int tcg_target_call_iarg_regs[] = { +}; + +static const int tcg_target_call_oarg_regs[] = { +}; + +static void patch_reloc (uint8_t *code_ptr,int type, +tcg_target_long value,tcg_target_long addend) +{ +tcg_abort (); +} + +static inline int tcg_target_get_call_iarg_regs_count (int flags) +{ +tcg_abort (); +return 0 ; +} + +/* parse target specific constraints */ +static int target_parse_constraint (TCGArgConstraint *ct,const char **pct_str) +{ +tcg_abort (); +return 0 ; +} + +/* Test if a constant matches the constraint. */ +static inline int tcg_target_const_match (tcg_target_long val, +const TCGArgConstraint *arg_ct) +{ +tcg_abort (); +return 0 ; +} + +/* load a register with an immediate value */ +static inline void tcg_out_movi (TCGContext *s,TCGType type, +int ret,tcg_target_long arg) +{ +tcg_abort (); +} + +/* load data without address translation or endianness conversion */ +static inline void tcg_out_ld (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +} + +static inline void tcg_out_st (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +}tcg/s390/tcg-target.c line 89
Quoted 10 lines
tcg/s390/tcg-target.c new file +10
-0+ +static inline void tcg_out_op (TCGContext *s,int opc, +const TCGArg *args,const int *const_args) +{ +tcg_abort (); +} + +void tcg_target_init (TCGContext *s) +{ +}This is probably here that
tcg_abort()is actually the most important.
Quoted 7 lines
tcg/s390/tcg-target.c line 94
Quoted 5 lines
tcg/s390/tcg-target.c new file +5
-0+ +void tcg_target_qemu_prologue (TCGContext *s) +{ +} +Also adding it here doesn't cost a lot.
Both places get called with KVM as well. If I call tcg_abort() here KVM doesn't start.
Quoted 44 lines
Quoted 44 lines
tcg/s390/tcg-target.c new file +9
-0+static inline void tcg_out_mov (TCGContext *s,int ret,int arg) +{ +tcg_abort (); +} + +static inline void tcg_out_addi (TCGContext *s,int reg,tcg_target_long val) +{ +tcg_abort (); +}tcg/s390/tcg-target.h new file +28
-0@@ -0,0 +1,48 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#define TCG_TARGET_S390 1 + +#define TCG_TARGET_REG_BITS 64 +#define TCG_TARGET_WORDS_BIGENDIAN +
Quoted 8 lines
tcg/s390/tcg-target.h line 33
Quoted 5 lines
tcg/s390/tcg-target.h new file +5
-0+#define TCG_TARGET_NB_REGS 0 + +enum { +TCG_AREG0 =0 , +};As this is defined in Uli's patch, I think it might be a good idea to define that correctly. Same for the list of registers.
I wasn't sure how much of the real architecture I should actually keep. So you think registers belong in?
Quoted 5 lines
Quoted 5 lines
tcg/s390/tcg-target.h new file +5
-0+/* used for function call generation */ +#define TCG_REG_CALL_STACK 0 +#define TCG_TARGET_STACK_ALIGN 8 +#define TCG_TARGET_CALL_STACK_OFFSET 0 +
Quoted 8 lines
tcg/s390/tcg-target.h line 44
Quoted 5 lines
tcg/s390/tcg-target.h new file +5
-0+static inline void flush_icache_range (unsigned long start,unsigned long stop) +{ +#if QEMU_GNUC_PREREQ (4 ,1 ) +void __clear_cache (char *beg,char *end); +__clear_cache ((char *) start, (char *) stop);You should use
__builtin___clear_cacheinstead to avoid having to declare the function.
Oh, ok :)
Alex
Re: [Qemu-devel] [PATCH 03/11] S/390 fake TCG implementation
Quoted 52 lines · Alexander Graf
Quoted 41 lines · Aurelien Jarno
Quoted 6 lines · Alexander Graf
Qemu won't let us run a KVM target without having host TCG support. Well, for now we don't have any so let's implement a fake target that only stubs out everything.
I tried to keep the patch as close to Uli's source as possible, so whenever he feels like it he can easily diff his version against this one.
Please find the comments below.
Quoted 31 lines
Signed-off-by Alexander Graf <[email protected]>---
dyngen-exec.h | 2 +- target-s390x/helper.c | 5 ++ tcg/s390/tcg-target.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ tcg/s390/tcg-target.h | 48 +++++++++++++++++++++++ 4 files changed, 157 insertions(+), 1 deletions(-)create mode 100644
tcg/s390/tcg-target.c
create mode 100644tcg/s390/tcg-target.hdyngen-exec.h +1
-1@@ -117,7 +117,7 @@ extern int printf(const char *, ...);/* The return address may point to the start of the next instruction. Subtracting one gets us the call instruction itself. */ -#if defined(__s390__) +#if defined(__s390__) && !defined(__s390x__)# define GETPC () ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))#elif defined(__arm__)/* Thumb return addresses have the low bit set, so we need to subtract two. target-s390x/helper.c +0
-0@@ -44,6 +44,11 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model)return env; }Quoted 7 lines
target-s390x/helper.c CPUS390XState *cpu_s390x_init(const char *cpu_model) · line 51
Quoted 5 lines
target-s390x/helper.c +5
-0+target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr; +} +Why does it appear in this patch? It has nothing to do with TCG support.
Quoted 1 line
I don't remember. What is this used for anyways?
If it is not used, maybe it's better to remove it.
Quoted 109 lines
Quoted 101 lines
Quoted 88 lines
target-s390x/helper.c +0
-0void cpu_reset (CPUS390XState *env) {if (qemu_loglevel_mask (CPU_LOG_RESET )) {tcg/s390/tcg-target.c new file +79
-0@@ -0,0 +1,103 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +static const int tcg_target_reg_alloc_order[] = { +}; + +static const int tcg_target_call_iarg_regs[] = { +}; + +static const int tcg_target_call_oarg_regs[] = { +}; + +static void patch_reloc (uint8_t *code_ptr,int type, +tcg_target_long value,tcg_target_long addend) +{ +tcg_abort (); +} + +static inline int tcg_target_get_call_iarg_regs_count (int flags) +{ +tcg_abort (); +return 0 ; +} + +/* parse target specific constraints */ +static int target_parse_constraint (TCGArgConstraint *ct,const char **pct_str) +{ +tcg_abort (); +return 0 ; +} + +/* Test if a constant matches the constraint. */ +static inline int tcg_target_const_match (tcg_target_long val, +const TCGArgConstraint *arg_ct) +{ +tcg_abort (); +return 0 ; +} + +/* load a register with an immediate value */ +static inline void tcg_out_movi (TCGContext *s,TCGType type, +int ret,tcg_target_long arg) +{ +tcg_abort (); +} + +/* load data without address translation or endianness conversion */ +static inline void tcg_out_ld (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +} + +static inline void tcg_out_st (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +}tcg/s390/tcg-target.c line 89
Quoted 10 lines
tcg/s390/tcg-target.c new file +10
-0+ +static inline void tcg_out_op (TCGContext *s,int opc, +const TCGArg *args,const int *const_args) +{ +tcg_abort (); +} + +void tcg_target_init (TCGContext *s) +{ +}This is probably here that
tcg_abort()is actually the most important.Quoted 7 lines
tcg/s390/tcg-target.c line 94
Quoted 5 lines
tcg/s390/tcg-target.c new file +5
-0+ +void tcg_target_qemu_prologue (TCGContext *s) +{ +} +Also adding it here doesn't cost a lot.
Quoted 1 line
Both places get called with KVM as well. If I call
tcg_abort()here KVM doesn't start.
Then can you add a comment explaining that code is missing.
I am very reluctant in introducing missing/wrong code in qemu. Experience has shown that it stays for a very long time, until someone spend hours or days trying to debug an issue.
Quoted 53 lines
Quoted 44 lines
Quoted 44 lines
tcg/s390/tcg-target.c new file +9
-0+static inline void tcg_out_mov (TCGContext *s,int ret,int arg) +{ +tcg_abort (); +} + +static inline void tcg_out_addi (TCGContext *s,int reg,tcg_target_long val) +{ +tcg_abort (); +}tcg/s390/tcg-target.h new file +28
-0@@ -0,0 +1,48 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#define TCG_TARGET_S390 1 + +#define TCG_TARGET_REG_BITS 64 +#define TCG_TARGET_WORDS_BIGENDIAN +Quoted 8 lines
tcg/s390/tcg-target.h line 33
Quoted 5 lines
tcg/s390/tcg-target.h new file +5
-0+#define TCG_TARGET_NB_REGS 0 + +enum { +TCG_AREG0 =0 , +};As this is defined in Uli's patch, I think it might be a good idea to define that correctly. Same for the list of registers.
Quoted 1 line
I wasn't sure how much of the real architecture I should actually keep. So you think registers belong in?
Again what chokes me is that it introduces wrong code. Especially TCG_AREG0 = 0. Introducing the registers will fix that.
Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
tcg/s390/tcg-target.h new file +5
-0+/* used for function call generation */ +#define TCG_REG_CALL_STACK 0 +#define TCG_TARGET_STACK_ALIGN 8 +#define TCG_TARGET_CALL_STACK_OFFSET 0 +Quoted 8 lines
tcg/s390/tcg-target.h line 44
Quoted 5 lines
tcg/s390/tcg-target.h new file +5
-0+static inline void flush_icache_range (unsigned long start,unsigned long stop) +{ +#if QEMU_GNUC_PREREQ (4 ,1 ) +void __clear_cache (char *beg,char *end); +__clear_cache ((char *) start, (char *) stop);You should use
__builtin___clear_cacheinstead to avoid having to declare the function.Oh, ok :)
Alex
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 03/11] S/390 fake TCG implementation
Quoted 53 lines · Aurelien Jarno
Quoted 52 lines · Alexander Graf
Quoted 48 lines · Aurelien Jarno
Quoted 6 lines · Alexander Graf
Qemu won't let us run a KVM target without having host TCG support. Well, for now we don't have any so let's implement a fake target that only stubs out everything.
I tried to keep the patch as close to Uli's source as possible, so whenever he feels like it he can easily diff his version against this one.
Please find the comments below.
Quoted 28 lines
Signed-off-by Alexander Graf <[email protected]>---
dyngen-exec.h | 2 +- target-s390x/helper.c | 5 ++ tcg/s390/tcg-target.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ tcg/s390/tcg-target.h | 48 +++++++++++++++++++++++ 4 files changed, 157 insertions(+), 1 deletions(-)create mode 100644
tcg/s390/tcg-target.c
create mode 100644tcg/s390/tcg-target.hdyngen-exec.h +1
-1@@ -117,7 +117,7 @@ extern int printf(const char *, ...);/* The return address may point to the start of the next instruction. Subtracting one gets us the call instruction itself. */ -#if defined(__s390__) +#if defined(__s390__) && !defined(__s390x__)# define GETPC () ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))#elif defined(__arm__)/* Thumb return addresses have the low bit set, so we need to subtract two. target-s390x/helper.c +0
-0target-s390x/helper.c CPUS390XState *cpu_s390x_init(const char *cpu_model) · line 51
Quoted 8 lines
target-s390x/helper.c +5
-0@@ -44,6 +44,11 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model)return env; } +target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr; +} +Why does it appear in this patch? It has nothing to do with TCG support.
Quoted 3 lines
Quoted 1 line
I don't remember. What is this used for anyways?
If it is not used, maybe it's better to remove it.
It's called from exec.c.
Quoted 110 lines
Quoted 110 lines
Quoted 109 lines
Quoted 89 lines
target-s390x/helper.c +0
-0void cpu_reset (CPUS390XState *env) {if (qemu_loglevel_mask (CPU_LOG_RESET )) {tcg/s390/tcg-target.c new file +79
-0@@ -0,0 +1,103 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +static const int tcg_target_reg_alloc_order[] = { +}; + +static const int tcg_target_call_iarg_regs[] = { +}; + +static const int tcg_target_call_oarg_regs[] = { +}; + +static void patch_reloc (uint8_t *code_ptr,int type, +tcg_target_long value,tcg_target_long addend) +{ +tcg_abort (); +} + +static inline int tcg_target_get_call_iarg_regs_count (int flags) +{ +tcg_abort (); +return 0 ; +} + +/* parse target specific constraints */ +static int target_parse_constraint (TCGArgConstraint *ct,const char **pct_str) +{ +tcg_abort (); +return 0 ; +} + +/* Test if a constant matches the constraint. */ +static inline int tcg_target_const_match (tcg_target_long val, +const TCGArgConstraint *arg_ct) +{ +tcg_abort (); +return 0 ; +} + +/* load a register with an immediate value */ +static inline void tcg_out_movi (TCGContext *s,TCGType type, +int ret,tcg_target_long arg) +{ +tcg_abort (); +} + +/* load data without address translation or endianness conversion */ +static inline void tcg_out_ld (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +} + +static inline void tcg_out_st (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +}tcg/s390/tcg-target.c line 89
Quoted 10 lines
tcg/s390/tcg-target.c new file +10
-0+ +static inline void tcg_out_op (TCGContext *s,int opc, +const TCGArg *args,const int *const_args) +{ +tcg_abort (); +} + +void tcg_target_init (TCGContext *s) +{ +}This is probably here that
tcg_abort()is actually the most important.tcg/s390/tcg-target.c line 94
Quoted 5 lines
tcg/s390/tcg-target.c new file +5
-0+ +void tcg_target_qemu_prologue (TCGContext *s) +{ +} +Also adding it here doesn't cost a lot.
Quoted 7 lines
Quoted 1 line
Both places get called with KVM as well. If I call
tcg_abort()here KVM doesn't start.Then can you add a comment explaining that code is missing.
I am very reluctant in introducing missing/wrong code in qemu. Experience has shown that it stays for a very long time, until someone spend hours or days trying to debug an issue.
Alright.
Quoted 54 lines
Quoted 54 lines
Quoted 53 lines
Quoted 40 lines
tcg/s390/tcg-target.c new file +9
-0+static inline void tcg_out_mov (TCGContext *s,int ret,int arg) +{ +tcg_abort (); +} + +static inline void tcg_out_addi (TCGContext *s,int reg,tcg_target_long val) +{ +tcg_abort (); +}tcg/s390/tcg-target.h new file +23
-0@@ -0,0 +1,48 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ tcg/s390/tcg-target.h line 33
Quoted 10 lines
tcg/s390/tcg-target.h new file +10
-0+#define TCG_TARGET_S390 1 + +#define TCG_TARGET_REG_BITS 64 +#define TCG_TARGET_WORDS_BIGENDIAN + +#define TCG_TARGET_NB_REGS 0 + +enum { +TCG_AREG0 =0 , +};As this is defined in Uli's patch, I think it might be a good idea to define that correctly. Same for the list of registers.
Quoted 4 lines
Quoted 1 line
I wasn't sure how much of the real architecture I should actually keep. So you think registers belong in?
Again what chokes me is that it introduces wrong code. Especially
TCG_AREG0= 0. Introducing the registers will fix that.
Ok.
Re: [Qemu-devel] [PATCH 03/11] S/390 fake TCG implementation
Quoted 56 lines · Alexander Graf
Quoted 53 lines · Aurelien Jarno
Quoted 52 lines · Alexander Graf
Quoted 48 lines · Aurelien Jarno
Quoted 6 lines · Alexander Graf
Qemu won't let us run a KVM target without having host TCG support. Well, for now we don't have any so let's implement a fake target that only stubs out everything.
I tried to keep the patch as close to Uli's source as possible, so whenever he feels like it he can easily diff his version against this one.
Please find the comments below.
Quoted 28 lines
Signed-off-by Alexander Graf <[email protected]>---
dyngen-exec.h | 2 +- target-s390x/helper.c | 5 ++ tcg/s390/tcg-target.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ tcg/s390/tcg-target.h | 48 +++++++++++++++++++++++ 4 files changed, 157 insertions(+), 1 deletions(-)create mode 100644
tcg/s390/tcg-target.c
create mode 100644tcg/s390/tcg-target.hdyngen-exec.h +1
-1@@ -117,7 +117,7 @@ extern int printf(const char *, ...);/* The return address may point to the start of the next instruction. Subtracting one gets us the call instruction itself. */ -#if defined(__s390__) +#if defined(__s390__) && !defined(__s390x__)# define GETPC () ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))#elif defined(__arm__)/* Thumb return addresses have the low bit set, so we need to subtract two. target-s390x/helper.c +0
-0target-s390x/helper.c CPUS390XState *cpu_s390x_init(const char *cpu_model) · line 51
Quoted 8 lines
target-s390x/helper.c +5
-0@@ -44,6 +44,11 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model)return env; } +target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr; +} +Why does it appear in this patch? It has nothing to do with TCG support.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I don't remember. What is this used for anyways?
If it is not used, maybe it's better to remove it.
It's called from
exec.c.
Then it's clearly not part of this patch, it should probably be part of patch 1 or 6 instead.
Quoted 180 lines
Quoted 110 lines
Quoted 110 lines
Quoted 109 lines
Quoted 89 lines
target-s390x/helper.c +0
-0void cpu_reset (CPUS390XState *env) {if (qemu_loglevel_mask (CPU_LOG_RESET )) {tcg/s390/tcg-target.c new file +79
-0@@ -0,0 +1,103 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +static const int tcg_target_reg_alloc_order[] = { +}; + +static const int tcg_target_call_iarg_regs[] = { +}; + +static const int tcg_target_call_oarg_regs[] = { +}; + +static void patch_reloc (uint8_t *code_ptr,int type, +tcg_target_long value,tcg_target_long addend) +{ +tcg_abort (); +} + +static inline int tcg_target_get_call_iarg_regs_count (int flags) +{ +tcg_abort (); +return 0 ; +} + +/* parse target specific constraints */ +static int target_parse_constraint (TCGArgConstraint *ct,const char **pct_str) +{ +tcg_abort (); +return 0 ; +} + +/* Test if a constant matches the constraint. */ +static inline int tcg_target_const_match (tcg_target_long val, +const TCGArgConstraint *arg_ct) +{ +tcg_abort (); +return 0 ; +} + +/* load a register with an immediate value */ +static inline void tcg_out_movi (TCGContext *s,TCGType type, +int ret,tcg_target_long arg) +{ +tcg_abort (); +} + +/* load data without address translation or endianness conversion */ +static inline void tcg_out_ld (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +} + +static inline void tcg_out_st (TCGContext *s,TCGType type,int arg, +int arg1,tcg_target_long arg2) +{ +tcg_abort (); +}tcg/s390/tcg-target.c line 89
Quoted 10 lines
tcg/s390/tcg-target.c new file +10
-0+ +static inline void tcg_out_op (TCGContext *s,int opc, +const TCGArg *args,const int *const_args) +{ +tcg_abort (); +} + +void tcg_target_init (TCGContext *s) +{ +}This is probably here that
tcg_abort()is actually the most important.tcg/s390/tcg-target.c line 94
Quoted 5 lines
tcg/s390/tcg-target.c new file +5
-0+ +void tcg_target_qemu_prologue (TCGContext *s) +{ +} +Also adding it here doesn't cost a lot.
Quoted 7 lines
Quoted 1 line
Both places get called with KVM as well. If I call
tcg_abort()here KVM doesn't start.Then can you add a comment explaining that code is missing.
I am very reluctant in introducing missing/wrong code in qemu. Experience has shown that it stays for a very long time, until someone spend hours or days trying to debug an issue.
Alright.
Quoted 54 lines
Quoted 54 lines
Quoted 53 lines
Quoted 40 lines
tcg/s390/tcg-target.c new file +9
-0+static inline void tcg_out_mov (TCGContext *s,int ret,int arg) +{ +tcg_abort (); +} + +static inline void tcg_out_addi (TCGContext *s,int reg,tcg_target_long val) +{ +tcg_abort (); +}tcg/s390/tcg-target.h new file +23
-0@@ -0,0 +1,48 @@ +/* +* Tiny Code Generator for QEMU +* +* Copyright (c) 2009 Ulrich Hecht <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ tcg/s390/tcg-target.h line 33
Quoted 10 lines
tcg/s390/tcg-target.h new file +10
-0+#define TCG_TARGET_S390 1 + +#define TCG_TARGET_REG_BITS 64 +#define TCG_TARGET_WORDS_BIGENDIAN + +#define TCG_TARGET_NB_REGS 0 + +enum { +TCG_AREG0 =0 , +};As this is defined in Uli's patch, I think it might be a good idea to define that correctly. Same for the list of registers.
Quoted 4 lines
Quoted 1 line
I wasn't sure how much of the real architecture I should actually keep. So you think registers belong in?
Again what chokes me is that it introduces wrong code. Especially
TCG_AREG0= 0. Introducing the registers will fix that.Ok.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 03/11] S/390 fake TCG implementation
Quoted 57 lines · Aurelien Jarno
Quoted 56 lines · Alexander Graf
Quoted 53 lines · Aurelien Jarno
Quoted 52 lines · Alexander Graf
Quoted 48 lines · Aurelien Jarno
Quoted 6 lines · Alexander Graf
Qemu won't let us run a KVM target without having host TCG support. Well, for now we don't have any so let's implement a fake target that only stubs out everything.
I tried to keep the patch as close to Uli's source as possible, so whenever he feels like it he can easily diff his version against this one.
Please find the comments below.
Quoted 28 lines
Signed-off-by Alexander Graf <[email protected]>---
dyngen-exec.h | 2 +- target-s390x/helper.c | 5 ++ tcg/s390/tcg-target.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++ tcg/s390/tcg-target.h | 48 +++++++++++++++++++++++ 4 files changed, 157 insertions(+), 1 deletions(-)create mode 100644
tcg/s390/tcg-target.c
create mode 100644tcg/s390/tcg-target.hdyngen-exec.h +1
-1@@ -117,7 +117,7 @@ extern int printf(const char *, ...);/* The return address may point to the start of the next instruction. Subtracting one gets us the call instruction itself. */ -#if defined(__s390__) +#if defined(__s390__) && !defined(__s390x__)# define GETPC () ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))#elif defined(__arm__)/* Thumb return addresses have the low bit set, so we need to subtract two. target-s390x/helper.c +0
-0target-s390x/helper.c CPUS390XState *cpu_s390x_init(const char *cpu_model) · line 51
Quoted 8 lines
target-s390x/helper.c +5
-0@@ -44,6 +44,11 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model)return env; } +target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +{ +return addr; +} +Why does it appear in this patch? It has nothing to do with TCG support.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I don't remember. What is this used for anyways?
If it is not used, maybe it's better to remove it.
It's called from
exec.c.Then it's clearly not part of this patch, it should probably be part of patch 1 or 6 instead.
Yes, moved it already.
Alex
PATCH 4/11 Add KVM support for S390x
In reply to Alexander GrafS390x was one of the first platforms that received support for KVM back in the day. Unfortunately until now there hasn't been a qemu implementation that would enable users to actually run guests.
So let's include support for KVM S390x in qemu!
--- configure | 4 +- target-s390x/kvm.c | 463 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 466 insertions(+), 1 deletions(-) create mode 100644 target-s390x/kvm.c
configure +3 -1
@@ -1348,6 +1348,8 @@ EOF kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include" elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include" + elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then + kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include" elif test -d "$kerneldir/arch/$cpu/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include" fi
@@ -2360,7 +2362,7 @@ case "$target_arch2" in fi esac case "$target_arch2" in - i386|x86_64|ppcemb|ppc|ppc64) + i386|x86_64|ppcemb|ppc|ppc64|s390x) # Make sure the target and host cpus are compatible if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ \( "$target_arch2" = "$cpu" -o \
target-s390x/kvm.c new file +463 -0
463 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH 04/11] Add KVM support for S390x
Quoted 5 lines · Alexander Graf
S390x was one of the first platforms that received support for KVM back in the day. Unfortunately until now there hasn't been a qemu implementation that would enable users to actually run guests.
So let's include support for KVM S390x in qemu!
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>--- configure | 4 +- target-s390x/kvm.c | 463 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 466 insertions(+), 1 deletions(-) create mode 100644 target-s390x/kvm.cconfigure +3
-1@@ -1348,6 +1348,8 @@ EOF kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include" elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include" + elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then + kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include" elif test -d "$kerneldir/arch/$cpu/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include" fi@@ -2360,7 +2362,7 @@ case "$target_arch2" in fi esac case "$target_arch2" in - i386|x86_64|ppcemb|ppc|ppc64) + i386|x86_64|ppcemb|ppc|ppc64|s390x) # Make sure the target and host cpus are compatible if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ \( "$target_arch2" = "$cpu" -o \target-s390x/kvm.c new file +71
-0@@ -0,0 +1,463 @@ +/* +* QEMU S390x KVM implementation +* +* Copyright (c) 2009 Alexander Graf <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/mman.h> + +#include <linux/kvm.h> +#include <asm/ptrace.h> + +#include "qemu-common.h" +#include "qemu-timer.h" +#include "sysemu.h" +#include "kvm.h" +#include "cpu.h" +#include "device_tree.h" + +/* #define DEBUG_KVM */ + +#ifdef DEBUG_KVM +#define dprintf (fmt, ...) \ + do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +#else +#define dprintf (fmt, ...) \ + do { } while (0) +#endif + +#define IPA0_DIAG 0x8300 +#define IPA0_SIGP 0xae00 +#define IPA0_PRIV 0xb200 + +#define PRIV_SCLP_CALL 0x20 +#define DIAG_KVM_HYPERCALL 0x500 +#define DIAG_KVM_BREAKPOINT 0x501 + +#define SCP_LENGTH 0x00 +#define SCP_FUNCTION_CODE 0x02 +#define SCP_CONTROL_MASK 0x03 +#define SCP_RESPONSE_CODE 0x06 +#define SCP_MEM_CODE 0x08 +#define SCP_INCREMENT 0x0a + +#define ICPT_INSTRUCTION 0x04 +#define ICPT_WAITPSW 0x1c +#define ICPT_SOFT_INTERCEPT 0x24 +#define ICPT_CPU_STOP 0x28 +#define ICPT_IO 0x40 + +#define SIGP_RESTART 0x06 +#define SIGP_INITIAL_CPU_RESET 0x0b +#define SIGP_STORE_STATUS_ADDR 0x0e +#define SIGP_SET_ARCH 0x12 + + +int kvm_arch_init (KVMState *s,int smp_cpus)
target-s390x/kvm.c line 81
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+{ +return 0 ; +} + +int kvm_arch_init_vcpu (CPUState *env) +{ +int ret =0 ; + +if (kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,NULL ) <0 ) +perror ("cannot init reset vcpu" );
coding style.
target-s390x/kvm.c line 88
Quoted 7 lines
target-s390x/kvm.c new file +7
-0+ +return ret; +} + +void kvm_arch_reset_vcpu (CPUState *env) +{ +}
Is there really nothing to do? If some code has to be added later, it may be worth adding a comment.
target-s390x/kvm.c line 98
Quoted 9 lines
target-s390x/kvm.c new file +9
-0+int kvm_arch_put_registers (CPUState *env) +{ +struct kvm_regs regs; +int ret; +int i; + + ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); +if (ret <0 ) +return ret;
coding style.
target-s390x/kvm.c line 101
Quoted 2 lines
target-s390x/kvm.c new file +2
-0+for (i =0 ; i <16 ; i++) + regs.gprs[i] = env->regs[i];
coding style.
target-s390x/kvm.c line 105
Quoted 4 lines
target-s390x/kvm.c new file +4
-0+ + ret =kvm_vcpu_ioctl (env,KVM_SET_REGS , ®s); +if (ret <0 ) +return ret;
coding style.
Quoted 6 lines
target-s390x/kvm.c new file +6
-0+ + env->kvm_run->psw_addr = env->psw.addr; + env->kvm_run->psw_mask = env->psw.mask; + +return ret; +}
target-s390x/kvm.c line 121
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+ +int kvm_arch_get_registers (CPUState *env) +{ +uint32_t ret; +struct kvm_regs regs; +int i; + + ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); +if (ret <0 ) +return ret;
coding style.
target-s390x/kvm.c line 124
Quoted 3 lines
target-s390x/kvm.c new file +3
-0+ +for (i =0 ; i <16 ; i++) + env->regs[i] = regs.gprs[i];
coding style.
Quoted 4 lines
target-s390x/kvm.c new file +4
-0+ + env->psw.addr = env->kvm_run->psw_addr; + env->psw.mask = env->kvm_run->psw_mask; +
target-s390x/kvm.c line 138
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+return 0 ; +} + +int kvm_arch_insert_sw_breakpoint (CPUState *env,struct kvm_sw_breakpoint *bp) +{ +static const uint8_t diag_501[] = {0x83 ,0x24 ,0x05 ,0x01 }; + +if (cpu_memory_rw_debug (env, bp->pc, (uint8_t *)&bp->saved_insn,4 ,0 ) || +cpu_memory_rw_debug (env, bp->pc, (uint8_t *)diag_501,4 ,1 )) +return -EINVAL ;
coding style.
Quoted 4 lines
target-s390x/kvm.c new file +4
-0+return 0 ; +} + +int kvm_arch_remove_sw_breakpoint (CPUState *env,struct kvm_sw_breakpoint *bp)
target-s390x/kvm.c line 152
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+{ +uint8_t t[4 ]; +static const uint8_t diag_501[] = {0x83 ,0x24 ,0x05 ,0x01 }; + +if (cpu_memory_rw_debug (env, bp->pc, t,4 ,0 )) +return -EINVAL ; +if (memcmp (t, diag_501,4 )) +return -EINVAL ; +if (cpu_memory_rw_debug (env, bp->pc, (uint8_t *)&bp->saved_insn,1 ,1 )) +return -EINVAL ;
coding style.
Quoted 6 lines
target-s390x/kvm.c new file +6
-0+ +return 0 ; +} + +int kvm_arch_pre_run (CPUState *env,struct kvm_run *run) +{
target-s390x/kvm.c line 168
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+return 0 ; +} + +int kvm_arch_post_run (CPUState *env,struct kvm_run *run) +{ +return 0 ; +} + +static void _kvm_s390_interrupt (CPUState *env,int type,uint32_t parm,uint64_t parm64,int vm) +{
Why such a name starting with an underscore?
target-s390x/kvm.c line 173
Quoted 5 lines
target-s390x/kvm.c new file +5
-0+struct kvm_s390_interrupt kvmint; +int r; + +if (!env->kvm_state) +return ;
coding style.
target-s390x/kvm.c line 185
Quoted 12 lines
target-s390x/kvm.c new file +12
-0+ + env->halted =0 ; + env->exception_index =0 ; + + kvmint.type = type; + kvmint.parm = parm; + kvmint.parm64 = parm64; + +if (vm) + r =kvm_vm_ioctl (env->kvm_state,KVM_S390_INTERRUPT , &kvmint); +else + r =kvm_vcpu_ioctl (env,KVM_S390_INTERRUPT , &kvmint);
coding style.
Quoted 42 lines
target-s390x/kvm.c new file +42
-0+ +if (r <0 ) { +fprintf (stderr,"KVM failed to inject interrupt\n" ); +exit (1 ); + } +} + +void kvm_s390_virtio_irq (CPUState *env,int config_change,uint64_t token) +{ +_kvm_s390_interrupt (env,KVM_S390_INT_VIRTIO , config_change, token,1 ); +} + +static void kvm_s390_interrupt (CPUState *env,int type,uint32_t code) +{ +_kvm_s390_interrupt (env, type, code,0 ,0 ); +} + +static void enter_pgmcheck (CPUState *env,uint16_t code) +{ +kvm_s390_interrupt (env,KVM_S390_PROGRAM_INT , code); +} + +static void setcc (CPUState *env,uint64_t cc) +{ + env->kvm_run->psw_mask &= ~(3ul <<44 ); + env->kvm_run->psw_mask |= (cc &3 ) <<44 ; + + env->psw.mask &= ~(3ul <<44 ); + env->psw.mask |= (cc &3 ) <<44 ; +} + +static int sclp_service_call (CPUState *env,struct kvm_run *run,uint16_t ipbh0) +{ +uint32_t sccb; +uint64_t code; +int r =0 ; + +cpu_synchronize_state (env); + sccb = env->regs[ipbh0 &0xf ]; + code = env->regs[(ipbh0 &0xf0 ) >>4 ]; + +dprintf ("sclp(0x%x, 0x%lx)\n" , sccb, code);
target-s390x/kvm.c line 237
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+ +if (sccb & ~0x7ffffff8ul ) { +fprintf (stderr,"KVM: invalid sccb address 0x%x\n" , sccb); + r =-1 ; + goto out; + } + +switch (code) { +case 0x00020001 : +case 0x00120001 :
What are those constants?
Quoted 6 lines
target-s390x/kvm.c new file +6
-0+stw_phys (sccb +SCP_MEM_CODE , ram_size >>20 ); +stb_phys (sccb +SCP_INCREMENT ,1 ); +stw_phys (sccb +SCP_RESPONSE_CODE ,0x10 ); +setcc (env,0 ); + +_kvm_s390_interrupt (env,KVM_S390_INT_SERVICE , sccb & ~3 ,0 ,1 );
target-s390x/kvm.c line 253
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+break ; +default : +dprintf ("KVM: invalid sclp call 0x%x / 0x%lx\n" , sccb, code); + r =-1 ; +break ; + } + +out: +if (r <0 ) +setcc (env,3 );
coding style.
Quoted 82 lines
target-s390x/kvm.c new file +82
-0+return 0 ; +} + +static int handle_priv (CPUState *env,struct kvm_run *run,uint8_t ipa1) +{ +int r =0 ; +uint16_t ipbh0 = (run->s390_sieic.ipb &0xffff0000 ) >>16 ; + +dprintf ("KVM: PRIV: %d\n" , ipa1); +switch (ipa1) { +case PRIV_SCLP_CALL : + r =sclp_service_call (env, run, ipbh0); +break ; +default : +dprintf ("KVM: unknown PRIV: 0x%x\n" , ipa1); + r =-1 ; +break ; + } + +return r; +} + +static int handle_hypercall (CPUState *env,struct kvm_run *run) +{ +int r; + +cpu_synchronize_state (env); + r =s390_virtio_hypercall (env); +kvm_arch_put_registers (env); + +return r; +} + +static int handle_diag (CPUState *env,struct kvm_run *run,int ipb_code) +{ +int r =0 ; + +switch (ipb_code) { +case DIAG_KVM_HYPERCALL : + r =handle_hypercall (env, run); +break ; +case DIAG_KVM_BREAKPOINT : +sleep (10 ); +break ; +default : +dprintf ("KVM: unknown DIAG: 0x%x\n" , ipb_code); + r =-1 ; +break ; + } + +return r; +} + +static int s390_cpu_restart (CPUState *env) +{ +kvm_s390_interrupt (env,KVM_S390_RESTART ,0 ); + env->halted =0 ; + env->exception_index =0 ; +qemu_cpu_kick (env); +fprintf (stderr,"DONE: SIGP cpu restart: %p\n" , env); +return 0 ; +} + +static int s390_store_status (CPUState *env,uint32_t parameter) +{ +/* XXX */ +fprintf (stderr,"XXX SIGP store status\n" ); +return -1 ; +} + +static int s390_cpu_initial_reset (CPUState *env) +{ +/* XXX */ +fprintf (stderr,"XXX SIGP init\n" ); +return -1 ; +} + +static int handle_sigp (CPUState *env,struct kvm_run *run,uint8_t ipa1) +{ +uint8_t order_code; +uint32_t parameter; +uint16_t cpu_addr;
target-s390x/kvm.c line 345
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+uint8_t t; +int r =-1 ; +CPUState *target_env; + +cpu_synchronize_state (env); + +/* get order code */ + order_code = run->s390_sieic.ipb >>28 ; +if (order_code >0 ) + order_code = env->regs[order_code];
coding style.
target-s390x/kvm.c line 351
Quoted 6 lines
target-s390x/kvm.c new file +6
-0+ order_code += (run->s390_sieic.ipb &0x0fff0000 ) >>16 ; + +/* get parameters */ + t = (ipa1 &0xf0 ) >>4 ; +if (!(t %2 )) + t++;
coding style.
target-s390x/kvm.c line 358
Quoted 7 lines
target-s390x/kvm.c new file +7
-0+ + parameter = env->regs[t] &0x7ffffe00 ; + cpu_addr = env->regs[ipa1 &0x0f ]; + + target_env =s390_cpu_addr2state (cpu_addr); +if (!target_env) + goto out;
coding style.
Quoted 111 lines
target-s390x/kvm.c new file +105
-0+ +switch (order_code) { +case SIGP_RESTART : + r =s390_cpu_restart (target_env); +break ; +case SIGP_STORE_STATUS_ADDR : + r =s390_store_status (target_env, parameter); +break ; +case SIGP_SET_ARCH : +/* make the caller panic */ +return -1 ; +case SIGP_INITIAL_CPU_RESET : + r =s390_cpu_initial_reset (target_env); +break ; +default : +fprintf (stderr,"KVM: unknown SIGP: 0x%x\n" , ipa1); +break ; + } + +out: +setcc (env, r ?3 :0 ); +return 0 ; +} + +static int handle_instruction (CPUState *env,struct kvm_run *run) +{ +unsigned int ipa0 = (run->s390_sieic.ipa &0xff00 ); +uint8_t ipa1 = run->s390_sieic.ipa &0x00ff ; +int ipb_code = (run->s390_sieic.ipb &0x0fff0000 ) >>16 ; +int r =0 ; + +dprintf ("handle_instruction 0x%x 0x%x\n" , run->s390_sieic.ipa, run->s390_sieic.ipb); +switch (ipa0) { +case IPA0_PRIV : + r =handle_priv (env, run, ipa1); +break ; +case IPA0_DIAG : + r =handle_diag (env, run, ipb_code); +break ; +case IPA0_SIGP : + r =handle_sigp (env, run, ipa1); +break ; + } + +if (r <0 ) { +enter_pgmcheck (env,0x0001 ); + } +return r; +} + +static int handle_intercept (CPUState *env) +{ +struct kvm_run *run = env->kvm_run; +int icpt_code = run->s390_sieic.icptcode; +int r =0 ; + +dprintf ("intercept: 0x%x (at 0x%lx)\n" , icpt_code, env->kvm_run->psw_addr); +switch (icpt_code) { +case ICPT_INSTRUCTION : + r =handle_instruction (env, run); +break ; +case ICPT_WAITPSW : +/* XXX What to do on system shutdown? */ + env->halted =1 ; + env->exception_index =EXCP_HLT ; +break ; +case ICPT_SOFT_INTERCEPT : +fprintf (stderr,"KVM unimplemented icpt SOFT\n" ); +exit (1 ); +break ; +case ICPT_CPU_STOP : +qemu_system_shutdown_request (); +break ; +case ICPT_IO : +fprintf (stderr,"KVM unimplemented icpt IO\n" ); +exit (1 ); +break ; +default : +fprintf (stderr,"Unknown intercept code: %d\n" , icpt_code); +exit (1 ); +break ; + } + +return r; +} + +int kvm_arch_handle_exit (CPUState *env,struct kvm_run *run) +{ +int ret =0 ; + +switch (run->exit_reason) { +case KVM_EXIT_S390_SIEIC : + ret =handle_intercept (env); +break ; +case KVM_EXIT_S390_RESET : +fprintf (stderr,"RESET not implemented\n" ); +exit (1 ); +break ; +default : +fprintf (stderr,"Unknown KVM exit: %d\n" , run->exit_reason); +break ; + } + +return ret; +}Signature · 1 line
1.6.0.2
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 04/11] Add KVM support for S390x
Quoted 128 lines · Aurelien Jarno
Quoted 5 lines · Alexander Graf
S390x was one of the first platforms that received support for KVM back in the day. Unfortunately until now there hasn't been a qemu implementation that would enable users to actually run guests.
So let's include support for KVM S390x in qemu!
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>---
configure | 4 +-target-s390x/kvm.c| 463 ++++++++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 466 insertions(+), 1 deletions(-)create mode 100644
target-s390x/kvm.cconfigure +2
-0@@ -1348,6 +1348,8 @@ EOF kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include" elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include" + elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then + kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include" elif test -d "$kerneldir/arch/$cpu/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include" fi@@ -2360,7 +2362,7 @@ case "$target_arch2" in fiesac
case "$target_arch2" inconfigure +1
-1- i386|x86_64|ppcemb|ppc|ppc64) + i386|x86_64|ppcemb|ppc|ppc64|s390x) # Make sure the target and host cpus are compatible if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ \( "$target_arch2" = "$cpu" -o \target-s390x/kvm.c new file +71
-0@@ -0,0 +1,463 @@ +/* +* QEMU S390x KVM implementation +* +* Copyright (c) 2009 Alexander Graf <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/mman.h> + +#include <linux/kvm.h> +#include <asm/ptrace.h> + +#include "qemu-common.h" +#include "qemu-timer.h" +#include "sysemu.h" +#include "kvm.h" +#include "cpu.h" +#include "device_tree.h" + +/* #define DEBUG_KVM */ + +#ifdef DEBUG_KVM +#define dprintf (fmt, ...) \ + do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +#else +#define dprintf (fmt, ...) \ + do { } while (0) +#endif + +#define IPA0_DIAG 0x8300 +#define IPA0_SIGP 0xae00 +#define IPA0_PRIV 0xb200 + +#define PRIV_SCLP_CALL 0x20 +#define DIAG_KVM_HYPERCALL 0x500 +#define DIAG_KVM_BREAKPOINT 0x501 + +#define SCP_LENGTH 0x00 +#define SCP_FUNCTION_CODE 0x02 +#define SCP_CONTROL_MASK 0x03 +#define SCP_RESPONSE_CODE 0x06 +#define SCP_MEM_CODE 0x08 +#define SCP_INCREMENT 0x0a + +#define ICPT_INSTRUCTION 0x04 +#define ICPT_WAITPSW 0x1c +#define ICPT_SOFT_INTERCEPT 0x24 +#define ICPT_CPU_STOP 0x28 +#define ICPT_IO 0x40 + +#define SIGP_RESTART 0x06 +#define SIGP_INITIAL_CPU_RESET 0x0b +#define SIGP_STORE_STATUS_ADDR 0x0e +#define SIGP_SET_ARCH 0x12 + + +int kvm_arch_init (KVMState *s,int smp_cpus)target-s390x/kvm.c line 81
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+{ +return 0 ; +} + +int kvm_arch_init_vcpu (CPUState *env) +{ +int ret =0 ; + +if (kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,NULL ) <0 ) +perror ("cannot init reset vcpu" );coding style.
Quoted 10 lines
target-s390x/kvm.c line 88
Quoted 7 lines
target-s390x/kvm.c new file +7
-0+ +return ret; +} + +void kvm_arch_reset_vcpu (CPUState *env) +{ +}Is there really nothing to do? If some code has to be added later, it may be worth adding a comment.
As you have probably realized by now, all reset code is missing. In fact, we don't even ever call the qemu reset functions to actually do a reset.
Quoted 5 lines
target-s390x/kvm.c line 168
Quoted 3 lines
target-s390x/kvm.c new file +3
-0+ +static void _kvm_s390_interrupt (CPUState *env,int type,uint32_t parm,uint64_t parm64,int vm) +{Why such a name starting with an underscore?
Because that's the internal function that gets used by the exported, properly named ones. Are there any conventions on how to declare private functions?
Quoted 15 lines
Quoted 15 lines
target-s390x/kvm.c new file +15
-0+static int sclp_service_call (CPUState *env,struct kvm_run *run,uint16_t ipbh0) +{ +uint32_t sccb; +uint64_t code; +int r =0 ; + +cpu_synchronize_state (env); + sccb = env->regs[ipbh0 &0xf ]; + code = env->regs[(ipbh0 &0xf0 ) >>4 ]; + +dprintf ("sclp(0x%x, 0x%lx)\n" , sccb, code); + +if (sccb & ~0x7ffffff8ul ) { +fprintf (stderr,"KVM: invalid sccb address 0x%x\n" , sccb); + r =-1 ;
Quoted 8 lines
target-s390x/kvm.c line 237
Quoted 6 lines
target-s390x/kvm.c new file +6
-0+ goto out; + } + +switch (code) { +case 0x00020001 : +case 0x00120001 :What are those constants?
If I knew I'd have defined some more verbose constants. I just took them 1:1 from kuli.
Re: [Qemu-devel] [PATCH 04/11] Add KVM support for S390x
Quoted 142 lines · Alexander Graf
Quoted 128 lines · Aurelien Jarno
Quoted 5 lines · Alexander Graf
S390x was one of the first platforms that received support for KVM back in the day. Unfortunately until now there hasn't been a qemu implementation that would enable users to actually run guests.
So let's include support for KVM S390x in qemu!
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>---
configure | 4 +-target-s390x/kvm.c| 463 ++++++++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 466 insertions(+), 1 deletions(-)create mode 100644
target-s390x/kvm.cconfigure +2
-0@@ -1348,6 +1348,8 @@ EOF kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include" elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include" + elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then + kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include" elif test -d "$kerneldir/arch/$cpu/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include" fi@@ -2360,7 +2362,7 @@ case "$target_arch2" in fiesac
case "$target_arch2" inconfigure +1
-1- i386|x86_64|ppcemb|ppc|ppc64) + i386|x86_64|ppcemb|ppc|ppc64|s390x) # Make sure the target and host cpus are compatible if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ \( "$target_arch2" = "$cpu" -o \target-s390x/kvm.c new file +71
-0@@ -0,0 +1,463 @@ +/* +* QEMU S390x KVM implementation +* +* Copyright (c) 2009 Alexander Graf <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/mman.h> + +#include <linux/kvm.h> +#include <asm/ptrace.h> + +#include "qemu-common.h" +#include "qemu-timer.h" +#include "sysemu.h" +#include "kvm.h" +#include "cpu.h" +#include "device_tree.h" + +/* #define DEBUG_KVM */ + +#ifdef DEBUG_KVM +#define dprintf (fmt, ...) \ + do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +#else +#define dprintf (fmt, ...) \ + do { } while (0) +#endif + +#define IPA0_DIAG 0x8300 +#define IPA0_SIGP 0xae00 +#define IPA0_PRIV 0xb200 + +#define PRIV_SCLP_CALL 0x20 +#define DIAG_KVM_HYPERCALL 0x500 +#define DIAG_KVM_BREAKPOINT 0x501 + +#define SCP_LENGTH 0x00 +#define SCP_FUNCTION_CODE 0x02 +#define SCP_CONTROL_MASK 0x03 +#define SCP_RESPONSE_CODE 0x06 +#define SCP_MEM_CODE 0x08 +#define SCP_INCREMENT 0x0a + +#define ICPT_INSTRUCTION 0x04 +#define ICPT_WAITPSW 0x1c +#define ICPT_SOFT_INTERCEPT 0x24 +#define ICPT_CPU_STOP 0x28 +#define ICPT_IO 0x40 + +#define SIGP_RESTART 0x06 +#define SIGP_INITIAL_CPU_RESET 0x0b +#define SIGP_STORE_STATUS_ADDR 0x0e +#define SIGP_SET_ARCH 0x12 + + +int kvm_arch_init (KVMState *s,int smp_cpus)target-s390x/kvm.c line 81
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+{ +return 0 ; +} + +int kvm_arch_init_vcpu (CPUState *env) +{ +int ret =0 ; + +if (kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,NULL ) <0 ) +perror ("cannot init reset vcpu" );coding style.
Quoted 10 lines
target-s390x/kvm.c line 88
Quoted 7 lines
target-s390x/kvm.c new file +7
-0+ +return ret; +} + +void kvm_arch_reset_vcpu (CPUState *env) +{ +}Is there really nothing to do? If some code has to be added later, it may be worth adding a comment.
Quoted 1 line
As you have probably realized by now, all reset code is missing. In fact, we don't even ever call the qemu reset functions to actually do a reset.
Can you make it clean with an abort?
Quoted 7 lines
Quoted 5 lines
target-s390x/kvm.c line 168
Quoted 3 lines
target-s390x/kvm.c new file +3
-0+ +static void _kvm_s390_interrupt (CPUState *env,int type,uint32_t parm,uint64_t parm64,int vm) +{Why such a name starting with an underscore?
Because that's the internal function that gets used by the exported, properly named ones. Are there any conventions on how to declare private functions?
I don't think there is any convention, but I know malc always complains about not introducing names starting with an underscore.
Quoted 25 lines
Quoted 15 lines
Quoted 15 lines
target-s390x/kvm.c new file +15
-0+static int sclp_service_call (CPUState *env,struct kvm_run *run,uint16_t ipbh0) +{ +uint32_t sccb; +uint64_t code; +int r =0 ; + +cpu_synchronize_state (env); + sccb = env->regs[ipbh0 &0xf ]; + code = env->regs[(ipbh0 &0xf0 ) >>4 ]; + +dprintf ("sclp(0x%x, 0x%lx)\n" , sccb, code); + +if (sccb & ~0x7ffffff8ul ) { +fprintf (stderr,"KVM: invalid sccb address 0x%x\n" , sccb); + r =-1 ;Quoted 8 lines
target-s390x/kvm.c line 237
Quoted 6 lines
target-s390x/kvm.c new file +6
-0+ goto out; + } + +switch (code) { +case 0x00020001 : +case 0x00120001 :What are those constants?
If I knew I'd have defined some more verbose constants. I just took them 1:1 from kuli.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 04/11] Add KVM support for S390x
Quoted 153 lines · Aurelien Jarno
Quoted 142 lines · Alexander Graf
Quoted 128 lines · Aurelien Jarno
Quoted 5 lines · Alexander Graf
S390x was one of the first platforms that received support for KVM back in the day. Unfortunately until now there hasn't been a qemu implementation that would enable users to actually run guests.
So let's include support for KVM S390x in qemu!
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>---
configure | 4 +-target-s390x/kvm.c| 463 ++++++++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 466 insertions(+), 1 deletions(-)create mode 100644
target-s390x/kvm.cconfigure +2
-0@@ -1348,6 +1348,8 @@ EOF kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include" elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include" + elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then + kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include" elif test -d "$kerneldir/arch/$cpu/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include" fi@@ -2360,7 +2362,7 @@ case "$target_arch2" in fiesac
case "$target_arch2" inconfigure +1
-1- i386|x86_64|ppcemb|ppc|ppc64) + i386|x86_64|ppcemb|ppc|ppc64|s390x) # Make sure the target and host cpus are compatible if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ \( "$target_arch2" = "$cpu" -o \target-s390x/kvm.c new file +71
-0@@ -0,0 +1,463 @@ +/* +* QEMU S390x KVM implementation +* +* Copyright (c) 2009 Alexander Graf <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/mman.h> + +#include <linux/kvm.h> +#include <asm/ptrace.h> + +#include "qemu-common.h" +#include "qemu-timer.h" +#include "sysemu.h" +#include "kvm.h" +#include "cpu.h" +#include "device_tree.h" + +/* #define DEBUG_KVM */ + +#ifdef DEBUG_KVM +#define dprintf (fmt, ...) \ + do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +#else +#define dprintf (fmt, ...) \ + do { } while (0) +#endif + +#define IPA0_DIAG 0x8300 +#define IPA0_SIGP 0xae00 +#define IPA0_PRIV 0xb200 + +#define PRIV_SCLP_CALL 0x20 +#define DIAG_KVM_HYPERCALL 0x500 +#define DIAG_KVM_BREAKPOINT 0x501 + +#define SCP_LENGTH 0x00 +#define SCP_FUNCTION_CODE 0x02 +#define SCP_CONTROL_MASK 0x03 +#define SCP_RESPONSE_CODE 0x06 +#define SCP_MEM_CODE 0x08 +#define SCP_INCREMENT 0x0a + +#define ICPT_INSTRUCTION 0x04 +#define ICPT_WAITPSW 0x1c +#define ICPT_SOFT_INTERCEPT 0x24 +#define ICPT_CPU_STOP 0x28 +#define ICPT_IO 0x40 + +#define SIGP_RESTART 0x06 +#define SIGP_INITIAL_CPU_RESET 0x0b +#define SIGP_STORE_STATUS_ADDR 0x0e +#define SIGP_SET_ARCH 0x12 + + +int kvm_arch_init (KVMState *s,int smp_cpus)target-s390x/kvm.c line 81
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+{ +return 0 ; +} + +int kvm_arch_init_vcpu (CPUState *env) +{ +int ret =0 ; + +if (kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,NULL ) <0 ) +perror ("cannot init reset vcpu" );coding style.
Quoted 10 lines
target-s390x/kvm.c line 88
Quoted 7 lines
target-s390x/kvm.c new file +7
-0+ +return ret; +} + +void kvm_arch_reset_vcpu (CPUState *env) +{ +}Is there really nothing to do? If some code has to be added later, it may be worth adding a comment.
Quoted 1 line
As you have probably realized by now, all reset code is missing. In fact, we don't even ever call the qemu reset functions to actually do a reset.
Can you make it clean with an abort?
Quoted 6 lines
Quoted 5 lines
target-s390x/kvm.c line 168
Quoted 3 lines
target-s390x/kvm.c new file +3
-0+ +static void _kvm_s390_interrupt (CPUState *env,int type,uint32_t parm,uint64_t parm64,int vm) +{Why such a name starting with an underscore?
Quoted 4 lines
Quoted 1 line
Because that's the internal function that gets used by the exported, properly named ones. Are there any conventions on how to declare private functions?
I don't think there is any convention, but I know malc always complains about not introducing names starting with an underscore.
Hm - I just wanted to clearly show that this is an internal API, nobody should really have to call directly. But I'm open for other naming suggestions.
Alex
Re: [Qemu-devel] [PATCH 04/11] Add KVM support for S390x
Quoted 156 lines · Alexander Graf
Quoted 153 lines · Aurelien Jarno
Quoted 142 lines · Alexander Graf
Quoted 128 lines · Aurelien Jarno
Quoted 5 lines · Alexander Graf
S390x was one of the first platforms that received support for KVM back in the day. Unfortunately until now there hasn't been a qemu implementation that would enable users to actually run guests.
So let's include support for KVM S390x in qemu!
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>---
configure | 4 +-target-s390x/kvm.c| 463 ++++++++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 466 insertions(+), 1 deletions(-)create mode 100644
target-s390x/kvm.cconfigure +2
-0@@ -1348,6 +1348,8 @@ EOF kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include" elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include" + elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then + kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include" elif test -d "$kerneldir/arch/$cpu/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include" fi@@ -2360,7 +2362,7 @@ case "$target_arch2" in fiesac
case "$target_arch2" inconfigure +1
-1- i386|x86_64|ppcemb|ppc|ppc64) + i386|x86_64|ppcemb|ppc|ppc64|s390x) # Make sure the target and host cpus are compatible if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ \( "$target_arch2" = "$cpu" -o \target-s390x/kvm.c new file +71
-0@@ -0,0 +1,463 @@ +/* +* QEMU S390x KVM implementation +* +* Copyright (c) 2009 Alexander Graf <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/mman.h> + +#include <linux/kvm.h> +#include <asm/ptrace.h> + +#include "qemu-common.h" +#include "qemu-timer.h" +#include "sysemu.h" +#include "kvm.h" +#include "cpu.h" +#include "device_tree.h" + +/* #define DEBUG_KVM */ + +#ifdef DEBUG_KVM +#define dprintf (fmt, ...) \ + do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +#else +#define dprintf (fmt, ...) \ + do { } while (0) +#endif + +#define IPA0_DIAG 0x8300 +#define IPA0_SIGP 0xae00 +#define IPA0_PRIV 0xb200 + +#define PRIV_SCLP_CALL 0x20 +#define DIAG_KVM_HYPERCALL 0x500 +#define DIAG_KVM_BREAKPOINT 0x501 + +#define SCP_LENGTH 0x00 +#define SCP_FUNCTION_CODE 0x02 +#define SCP_CONTROL_MASK 0x03 +#define SCP_RESPONSE_CODE 0x06 +#define SCP_MEM_CODE 0x08 +#define SCP_INCREMENT 0x0a + +#define ICPT_INSTRUCTION 0x04 +#define ICPT_WAITPSW 0x1c +#define ICPT_SOFT_INTERCEPT 0x24 +#define ICPT_CPU_STOP 0x28 +#define ICPT_IO 0x40 + +#define SIGP_RESTART 0x06 +#define SIGP_INITIAL_CPU_RESET 0x0b +#define SIGP_STORE_STATUS_ADDR 0x0e +#define SIGP_SET_ARCH 0x12 + + +int kvm_arch_init (KVMState *s,int smp_cpus)target-s390x/kvm.c line 81
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+{ +return 0 ; +} + +int kvm_arch_init_vcpu (CPUState *env) +{ +int ret =0 ; + +if (kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,NULL ) <0 ) +perror ("cannot init reset vcpu" );coding style.
Quoted 10 lines
target-s390x/kvm.c line 88
Quoted 7 lines
target-s390x/kvm.c new file +7
-0+ +return ret; +} + +void kvm_arch_reset_vcpu (CPUState *env) +{ +}Is there really nothing to do? If some code has to be added later, it may be worth adding a comment.
Quoted 1 line
As you have probably realized by now, all reset code is missing. In fact, we don't even ever call the qemu reset functions to actually do a reset.
Can you make it clean with an abort?
Quoted 6 lines
Quoted 5 lines
target-s390x/kvm.c line 168
Quoted 3 lines
target-s390x/kvm.c new file +3
-0+ +static void _kvm_s390_interrupt (CPUState *env,int type,uint32_t parm,uint64_t parm64,int vm) +{Why such a name starting with an underscore?
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Because that's the internal function that gets used by the exported, properly named ones. Are there any conventions on how to declare private functions?
I don't think there is any convention, but I know malc always complains about not introducing names starting with an underscore.
Yeah he does.
Quoted 4 lines
Hm - I just wanted to clearly show that this is an internal API, nobody should really have to call directly. But I'm open for other naming suggestions.
Thing is, in 7.1.3#1 standard says (after explicitly reserving __ _[A-Z] for any use):
-- All identifiers that begin with an underscore are
always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
And i could never really understand (or recall/comprehend when asked and being given an answer) what this entails. (Anyone?)
So i would go with something imaginative like internal_do_not_use_kvm*, but that's just me. You can go wild here, leading underscore doesn't look attractive though.
Signature · 1 line
mailto:[email protected]
Re: [Qemu-devel] [PATCH 04/11] Add KVM support for S390x
Quoted 170 lines · malc
Quoted 156 lines · Alexander Graf
Quoted 153 lines · Aurelien Jarno
Quoted 142 lines · Alexander Graf
Quoted 128 lines · Aurelien Jarno
Quoted 5 lines · Alexander Graf
S390x was one of the first platforms that received support for KVM back in the day. Unfortunately until now there hasn't been a qemu implementation that would enable users to actually run guests.
So let's include support for KVM S390x in qemu!
Please find the comments below.
Quoted 106 lines
Signed-off-by Alexander Graf <[email protected]>---
configure | 4 +-target-s390x/kvm.c| 463 ++++++++++++++++++++++++++++++++++++++++++++++++++++2 files changed, 466 insertions(+), 1 deletions(-)create mode 100644
target-s390x/kvm.cconfigure +2
-0@@ -1348,6 +1348,8 @@ EOF kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include" elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include" + elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then + kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include" elif test -d "$kerneldir/arch/$cpu/include" ; then kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include" fi@@ -2360,7 +2362,7 @@ case "$target_arch2" in fiesac
case "$target_arch2" inconfigure +1
-1- i386|x86_64|ppcemb|ppc|ppc64) + i386|x86_64|ppcemb|ppc|ppc64|s390x) # Make sure the target and host cpus are compatible if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \ \( "$target_arch2" = "$cpu" -o \target-s390x/kvm.c new file +71
-0@@ -0,0 +1,463 @@ +/* +* QEMU S390x KVM implementation +* +* Copyright (c) 2009 Alexander Graf <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/mman.h> + +#include <linux/kvm.h> +#include <asm/ptrace.h> + +#include "qemu-common.h" +#include "qemu-timer.h" +#include "sysemu.h" +#include "kvm.h" +#include "cpu.h" +#include "device_tree.h" + +/* #define DEBUG_KVM */ + +#ifdef DEBUG_KVM +#define dprintf (fmt, ...) \ + do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +#else +#define dprintf (fmt, ...) \ + do { } while (0) +#endif + +#define IPA0_DIAG 0x8300 +#define IPA0_SIGP 0xae00 +#define IPA0_PRIV 0xb200 + +#define PRIV_SCLP_CALL 0x20 +#define DIAG_KVM_HYPERCALL 0x500 +#define DIAG_KVM_BREAKPOINT 0x501 + +#define SCP_LENGTH 0x00 +#define SCP_FUNCTION_CODE 0x02 +#define SCP_CONTROL_MASK 0x03 +#define SCP_RESPONSE_CODE 0x06 +#define SCP_MEM_CODE 0x08 +#define SCP_INCREMENT 0x0a + +#define ICPT_INSTRUCTION 0x04 +#define ICPT_WAITPSW 0x1c +#define ICPT_SOFT_INTERCEPT 0x24 +#define ICPT_CPU_STOP 0x28 +#define ICPT_IO 0x40 + +#define SIGP_RESTART 0x06 +#define SIGP_INITIAL_CPU_RESET 0x0b +#define SIGP_STORE_STATUS_ADDR 0x0e +#define SIGP_SET_ARCH 0x12 + + +int kvm_arch_init (KVMState *s,int smp_cpus)target-s390x/kvm.c line 81
Quoted 10 lines
target-s390x/kvm.c new file +10
-0+{ +return 0 ; +} + +int kvm_arch_init_vcpu (CPUState *env) +{ +int ret =0 ; + +if (kvm_vcpu_ioctl (env,KVM_S390_INITIAL_RESET ,NULL ) <0 ) +perror ("cannot init reset vcpu" );coding style.
Quoted 10 lines
target-s390x/kvm.c line 88
Quoted 7 lines
target-s390x/kvm.c new file +7
-0+ +return ret; +} + +void kvm_arch_reset_vcpu (CPUState *env) +{ +}Is there really nothing to do? If some code has to be added later, it may be worth adding a comment.
Quoted 1 line
As you have probably realized by now, all reset code is missing. In fact, we don't even ever call the qemu reset functions to actually do a reset.
Can you make it clean with an abort?
Quoted 6 lines
Quoted 5 lines
target-s390x/kvm.c line 168
Quoted 3 lines
target-s390x/kvm.c new file +3
-0+ +static void _kvm_s390_interrupt (CPUState *env,int type,uint32_t parm,uint64_t parm64,int vm) +{Why such a name starting with an underscore?
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Because that's the internal function that gets used by the exported, properly named ones. Are there any conventions on how to declare private functions?
I don't think there is any convention, but I know malc always complains about not introducing names starting with an underscore.
Yeah he does.
Quoted 4 lines
Hm - I just wanted to clearly show that this is an internal API, nobody should really have to call directly. But I'm open for other naming suggestions.
Quoted 8 lines
Thing is, in 7.1.3#1 standard says (after explicitly reserving __ _[A-Z] for any use):
-- All identifiers that begin with an underscore are
always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.And i could never really understand (or recall/comprehend when asked and being given an answer) what this entails. (Anyone?)
I don't get the second part, but the first one clearly says "If you use a function beginning underscore, only use it within the file you're declaring it at".
Quoted 3 lines
So i would go with something imaginative like internal_do_not_use_kvm*, but that's just me. You can go wild here, leading underscore doesn't look attractive though.
Well I could have gone with kvm_s390_interrupt_generic or kvm_s390_interrupt_internal. But I wanted to have a function name that doesn't exceed the 80 character limit all by itself ;-).
Alex
Re: [Qemu-devel] [PATCH 04/11] Add KVM support for S390x
Quoted 4 lines · Alexander Graf
Quoted 1 line · malc
On Wed, 2 Dec 2009, Alexander Graf wrote:
[..snip..]
Quoted 21 lines
Quoted 21 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Why such a name starting with an underscore?
Because that's the internal function that gets used by the exported, properly named ones. Are there any conventions on how to declare private functions?
I don't think there is any convention, but I know malc always complains about not introducing names starting with an underscore.
Yeah he does.
Quoted 4 lines
Hm - I just wanted to clearly show that this is an internal API, nobody should really have to call directly. But I'm open for other naming suggestions.
Thing is, in 7.1.3#1 standard says (after explicitly reserving __ _[A-Z] for any use):
-- All identifiers that begin with an underscore are
always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
Quoted 6 lines
Quoted 2 lines
And i could never really understand (or recall/comprehend when asked and being given an answer) what this entails. (Anyone?)
I don't get the second part, but the first one clearly says "If you use a function beginning underscore, only use it within the file you're declaring it at".
6.2.3 describes name spaces.
FWIW here's my interpretation: those names are reserved by implementation for use in oridnary and tag name spaces, so keep out, feel free to use them in other name spaces.
Perhaps Mans Rullgard, if he still reads this that is, can enlighten us. Unfortuantelly i do not have write access to Usenet anymore so can not ask this on comp.std.c on my own.
Quoted 8 lines
Quoted 4 lines
So i would go with something imaginative like internal_do_not_use_kvm*, but that's just me. You can go wild here, leading underscore doesn't look attractive though.
Well I could have gone with
kvm_s390_interrupt_genericorkvm_s390_interrupt_internal. But I wanted to have a function name that doesn't exceed the 80 character limit all by itself ;-).
Oh c'mon those are less than 30 chars :)
Signature · 1 line
mailto:[email protected]
Re: [Qemu-devel] [PATCH 04/11] Add KVM support for S390x
In reply to malcQuoted 10 lines · malc
Quoted 8 lines · Alexander Graf
Quoted 5 lines · Aurelien Jarno
Quoted 4 lines · Alexander Graf
Quoted 1 line · Aurelien Jarno
On Thu, Nov 26, 2009 at 02:23:13PM +0100, Alexander Graf wrote:
[...]
Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
target-s390x/kvm.c line 168
Quoted 3 lines
target-s390x/kvm.c new file +3
-0+ +static void _kvm_s390_interrupt (CPUState *env,int type,uint32_t parm,uint64_t parm64,int vm) +{Why such a name starting with an underscore?
Because that's the internal function that gets used by the exported, properly named ones. Are there any conventions on how to declare private functions?
I don't think there is any convention, but I know malc always complains about not introducing names starting with an underscore.
Yeah he does.
Quoted 4 lines
Hm - I just wanted to clearly show that this is an internal API, nobody should really have to call directly. But I'm open for other naming suggestions.
Quoted 8 lines
Thing is, in 7.1.3#1 standard says (after explicitly reserving __ _[A-Z] for any use):
-- All identifiers that begin with an underscore are
always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.And i could never really understand (or recall/comprehend when asked and being given an answer) what this entails. (Anyone?)
Later in 7.1.3:
If the program declares or defines an identifier in a context in which it is reserved (other than as allowed by 7.1.4), or defines a reserved identifier as a macro name, the behavior is undefined.
This gives implementations of the standard (compiler + libc) license to use reserved identifiers for their own purposes. If they clash with the user's identifiers, and things break, the user gets to keep the pieces.
Now, it's quite unlikely that _kvm_s390_interrupt() clashes with anything in practice. It does, however, set a bad example.
Quoted 3 lines
So i would go with something imaginative like internal_do_not_use_kvm*, but that's just me. You can go wild here, leading underscore doesn't look attractive though.
Why not kvm_s390_interrupt_internal(), or even kvm_s390_interrupt_()?
Re: [Qemu-devel] [PATCH 04/11] Add KVM support for S390x
Quoted 42 lines · Markus Armbruster
Quoted 10 lines · malc
Quoted 8 lines · Alexander Graf
Quoted 5 lines · Aurelien Jarno
Quoted 4 lines · Alexander Graf
Quoted 1 line · Aurelien Jarno
On Thu, Nov 26, 2009 at 02:23:13PM +0100, Alexander Graf wrote:
[...]
Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ +static void _kvm_s390_interrupt(CPUState *env, int type, uint32_t parm, uint64_t parm64, int vm) +{Why such a name starting with an underscore?
Because that's the internal function that gets used by the exported, properly named ones. Are there any conventions on how to declare private functions?
I don't think there is any convention, but I know malc always complains about not introducing names starting with an underscore.
Yeah he does.
Quoted 4 lines
Hm - I just wanted to clearly show that this is an internal API, nobody should really have to call directly. But I'm open for other naming suggestions.
Quoted 8 lines
Thing is, in 7.1.3#1 standard says (after explicitly reserving __ _[A-Z] for any use):
-- All identifiers that begin with an underscore are
always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.And i could never really understand (or recall/comprehend when asked and being given an answer) what this entails. (Anyone?)
Later in 7.1.3:
Quoted 7 lines
If the program declares or defines an identifier in a context in which it is reserved (other than as allowed by 7.1.4), or defines a reserved identifier as a macro name, the behavior is undefined.
This gives implementations of the standard (compiler + libc) license to use reserved identifiers for their own purposes. If they clash with the user's identifiers, and things break, the user gets to keep the pieces.
Yes, that's how i would interpret it too (as stated in another message)
Quoted 3 lines
Now, it's quite unlikely that
_kvm_s390_interrupt()clashes with anything in practice. It does, however, set a bad example.
Indeed.
Quoted 7 lines
Quoted 4 lines
So i would go with something imaginative like internal_do_not_use_kvm*, but that's just me. You can go wild here, leading underscore doesn't look attractive though.
Why not
kvm_s390_interrupt_internal(), or evenkvm_s390_interrupt_()?
Signature · 1 line
mailto:[email protected]
PATCH 5/11 Allocate physical memory in low virtual address space
In reply to Alexander GrafKVM on S390x requires the virtual address space of the guest's RAM to be within the first 256GB.
The general direction I'd like to see KVM on S390 move is that this requirement is losened, but for now that's what we're stuck with.
So let's just hack up qemu_ram_alloc until KVM behaves nicely :-).
--- exec.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
exec.c +6 -0
@@ -2411,7 +2411,13 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size) size =TARGET_PAGE_ALIGN (size); new_block =qemu_malloc (sizeof (*new_block)); +#if defined(TARGET_S390 ) && defined(CONFIG_KVM ) +/* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */ + new_block->host =mmap (0x1000000 , size,PROT_EXEC |PROT_READ |PROT_WRITE , +MAP_SHARED |MAP_ANONYMOUS ,-1 ,0 ); +#else new_block->host =qemu_vmalloc (size); +#endif #ifdef MADV_MERGEABLE madvise (new_block->host, size,MADV_MERGEABLE );#endif
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH 05/11] Allocate physical memory in low virtual address space
Quoted 3 lines · Alexander Graf
KVM on S390x requires the virtual address space of the guest's RAM to be within the first 256GB.
While I have no problem with this patch, I am curious to know the reason of this. No need to change anything in the patch.
Quoted 34 lines
The general direction I'd like to see KVM on S390 move is that this requirement is losened, but for now that's what we're stuck with.
So let's just hack up
qemu_ram_allocuntil KVM behaves nicely :-).Signed-off-by Alexander Graf <[email protected]>--- exec.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)exec.c +6
-0@@ -2411,7 +2411,13 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size) size =TARGET_PAGE_ALIGN (size); new_block =qemu_malloc (sizeof (*new_block)); +#if defined(TARGET_S390 ) && defined(CONFIG_KVM ) +/* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */ + new_block->host =mmap (0x1000000 , size,PROT_EXEC |PROT_READ |PROT_WRITE , +MAP_SHARED |MAP_ANONYMOUS ,-1 ,0 ); +#else new_block->host =qemu_vmalloc (size); +#endif #ifdef MADV_MERGEABLE madvise (new_block->host, size,MADV_MERGEABLE );#endif Signature · 1 line
1.6.0.2
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 05/11] Allocate physical memory in low virtual address space
Quoted 7 lines · Aurelien Jarno
Quoted 3 lines · Alexander Graf
KVM on S390x requires the virtual address space of the guest's RAM to be within the first 256GB.
While I have no problem with this patch, I am curious to know the reason of this. No need to change anything in the patch.
For the technical reason I hope Carsten can provide some insight.
As for the implementation reason - S390 KVM (the kernel part) doesn't do memslots properly :-).
Alex
Re: [Qemu-devel] [PATCH 05/11] Allocate physical memory in low virtual address space
Quoted 2 lines · Alexander Graf
For the technical reason I hope Carsten can provide some insight.
As for the implementation reason - S390 KVM (the kernel part) doesn't do memslots properly :-).
I'm sorry, I cannot comment on that :-(.
PATCH 6/11 Add support for S390x system emulation
In reply to Alexander GrafLet's enable the basics for system emulation so we can run virtual machines with KVM!
--- target-s390x/cpu.h | 153 ++++++++++++++++++++++++++++++++++++- target-s390x/exec.h | 5 + target-s390x/helper.c | 22 +++++ target-s390x/machine.c | 30 +++++++ 4 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 default-configs/s390x-softmmu.mak create mode 100644 target-s390x/machine.c
default-configs/s390x-softmmu.mak new file +0 -0
target-s390x/cpu.h +151 -2
175 lines not on this page · raw message
target-s390x/exec.h +5 -0
@@ -22,9 +22,14 @@ register struct CPUS390XState *env asm(AREG0); +#include "config.h" #include "cpu.h" #include "exec-all.h" +#if !defined(CONFIG_USER_ONLY ) +#include "softmmu_exec.h" +#endif /* !defined(CONFIG_USER_ONLY) */ +static inline int cpu_has_work (CPUState *env) {return env->interrupt_request &CPU_INTERRUPT_HARD ;// guess
target-s390x/helper.c +22 -0
@@ -27,6 +27,9 @@#include "gdbstub.h" #include "qemu-common.h" +#include <linux/kvm.h> +#include "kvm.h" +CPUS390XState *cpu_s390x_init (const char *cpu_model) {CPUS390XState *env;
@@ -60,3 +63,22 @@ void cpu_reset(CPUS390XState *env)/* FIXME: reset vector? */ tlb_flush (env,1 ); } + +#ifndef CONFIG_USER_ONLY + +int cpu_s390x_handle_mmu_fault (CPUState *env,target_ulong address,int rw, +int mmu_idx,int is_softmmu) +{ +target_ulong phys; +int prot; + +/* XXX: implement mmu */ + + phys = address; + prot =PAGE_READ |PAGE_WRITE ; + +return tlb_set_page (env, address &TARGET_PAGE_MASK , + phys &TARGET_PAGE_MASK , prot, + mmu_idx, is_softmmu); +} +#endif /* CONFIG_USER_ONLY */
target-s390x/machine.c new file +30 -0
@@ -0,0 +1,30 @@ +/* +* QEMU S390x machine definitions +* +* Copyright (c) 2009 Alexander Graf <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "hw/hw.h" +#include "hw/boards.h" + +void cpu_save (QEMUFile *f,void *opaque) +{ +} + +int cpu_load (QEMUFile *f,void *opaque,int version_id) +{ +return 0 ; +}
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH 06/11] Add support for S390x system emulation
Quoted 2 lines · Alexander Graf
Let's enable the basics for system emulation so we can run virtual machines with KVM!
I don't really understand while this whole patch is not merged in patch number 1. Otherwise, please find the comments below.
Quoted 28 lines
Signed-off-by Alexander Graf <[email protected]>--- target-s390x/cpu.h | 153 ++++++++++++++++++++++++++++++++++++- target-s390x/exec.h | 5 + target-s390x/helper.c | 22 +++++ target-s390x/machine.c | 30 +++++++ 4 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 default-configs/s390x-softmmu.mak create mode 100644 target-s390x/machine.cdefault-configs/s390x-softmmu.mak new file +0
-0target-s390x/cpu.h +1
-2@@ -30,8 +30,7 @@#include "softfloat.h" -#define NB_MMU_MODES 2 // guess -#define MMU_USER_IDX 0 // guess +#define NB_MMU_MODES 2 typedef union FPReg { struct {
target-s390x/cpu.h static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) · line 85
Quoted 10 lines
target-s390x/cpu.h +7
-0@@ -77,6 +76,15 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) }#endif +#define MMU_MODE0_SUFFIX _kernel +#define MMU_MODE1_SUFFIX _user +#define MMU_USER_IDX 1 +static inline int cpu_mmu_index (CPUState *env) +{ +/* XXX: Currently we don't implement virtual memory */ +return 0 ;
Is it correct? It means that memory access will aways be kernel memory accesses. IIRC, even with KVM enabled, softmmu accesses are possible in some cases (devices ?).
Quoted 202 lines
target-s390x/cpu.h +143
-0+} +CPUS390XState *cpu_s390x_init (const char *cpu_model);int cpu_s390x_exec (CPUS390XState *s);void cpu_s390x_close (CPUS390XState *s);@@ -92,6 +100,13 @@ int cpu_s390x_handle_mmu_fault (CPUS390XState *env, target_ulong address, int rw#define TARGET_PAGE_BITS 12 +#ifndef CONFIG_USER_ONLY +extern int s390_virtio_hypercall (CPUState *env); +extern void kvm_s390_virtio_irq (CPUState *env,int config_change,uint64_t token); +extern CPUState *s390_cpu_addr2state (uint16_t cpu_addr); +#endif + +#define cpu_init cpu_s390x_init#define cpu_exec cpu_s390x_exec#define cpu_gen_code cpu_s390x_gen_code@@ -116,4 +131,138 @@ static inline void cpu_get_tb_cpu_state(CPUState* env, target_ulong *pc, *cs_base =0 ; *flags = env->psw.mask; // guess } + +/* Program Status Word. */ +#define S390_PSWM_REGNUM 0 +#define S390_PSWA_REGNUM 1 +/* General Purpose Registers. */ +#define S390_R0_REGNUM 2 +#define S390_R1_REGNUM 3 +#define S390_R2_REGNUM 4 +#define S390_R3_REGNUM 5 +#define S390_R4_REGNUM 6 +#define S390_R5_REGNUM 7 +#define S390_R6_REGNUM 8 +#define S390_R7_REGNUM 9 +#define S390_R8_REGNUM 10 +#define S390_R9_REGNUM 11 +#define S390_R10_REGNUM 12 +#define S390_R11_REGNUM 13 +#define S390_R12_REGNUM 14 +#define S390_R13_REGNUM 15 +#define S390_R14_REGNUM 16 +#define S390_R15_REGNUM 17 +/* Access Registers. */ +#define S390_A0_REGNUM 18 +#define S390_A1_REGNUM 19 +#define S390_A2_REGNUM 20 +#define S390_A3_REGNUM 21 +#define S390_A4_REGNUM 22 +#define S390_A5_REGNUM 23 +#define S390_A6_REGNUM 24 +#define S390_A7_REGNUM 25 +#define S390_A8_REGNUM 26 +#define S390_A9_REGNUM 27 +#define S390_A10_REGNUM 28 +#define S390_A11_REGNUM 29 +#define S390_A12_REGNUM 30 +#define S390_A13_REGNUM 31 +#define S390_A14_REGNUM 32 +#define S390_A15_REGNUM 33 +/* Floating Point Control Word. */ +#define S390_FPC_REGNUM 34 +/* Floating Point Registers. */ +#define S390_F0_REGNUM 35 +#define S390_F1_REGNUM 36 +#define S390_F2_REGNUM 37 +#define S390_F3_REGNUM 38 +#define S390_F4_REGNUM 39 +#define S390_F5_REGNUM 40 +#define S390_F6_REGNUM 41 +#define S390_F7_REGNUM 42 +#define S390_F8_REGNUM 43 +#define S390_F9_REGNUM 44 +#define S390_F10_REGNUM 45 +#define S390_F11_REGNUM 46 +#define S390_F12_REGNUM 47 +#define S390_F13_REGNUM 48 +#define S390_F14_REGNUM 49 +#define S390_F15_REGNUM 50 +/* Total. */ +#define S390_NUM_REGS 51 + +/* Pseudo registers -- PC and condition code. */ +#define S390_PC_REGNUM S390_NUM_REGS +#define S390_CC_REGNUM (S390_NUM_REGS+1) +#define S390_NUM_PSEUDO_REGS 2 +#define S390_NUM_TOTAL_REGS (S390_NUM_REGS+2) + + + +/* Program Status Word. */ +#define S390_PSWM_REGNUM 0 +#define S390_PSWA_REGNUM 1 +/* General Purpose Registers. */ +#define S390_R0_REGNUM 2 +#define S390_R1_REGNUM 3 +#define S390_R2_REGNUM 4 +#define S390_R3_REGNUM 5 +#define S390_R4_REGNUM 6 +#define S390_R5_REGNUM 7 +#define S390_R6_REGNUM 8 +#define S390_R7_REGNUM 9 +#define S390_R8_REGNUM 10 +#define S390_R9_REGNUM 11 +#define S390_R10_REGNUM 12 +#define S390_R11_REGNUM 13 +#define S390_R12_REGNUM 14 +#define S390_R13_REGNUM 15 +#define S390_R14_REGNUM 16 +#define S390_R15_REGNUM 17 +/* Access Registers. */ +#define S390_A0_REGNUM 18 +#define S390_A1_REGNUM 19 +#define S390_A2_REGNUM 20 +#define S390_A3_REGNUM 21 +#define S390_A4_REGNUM 22 +#define S390_A5_REGNUM 23 +#define S390_A6_REGNUM 24 +#define S390_A7_REGNUM 25 +#define S390_A8_REGNUM 26 +#define S390_A9_REGNUM 27 +#define S390_A10_REGNUM 28 +#define S390_A11_REGNUM 29 +#define S390_A12_REGNUM 30 +#define S390_A13_REGNUM 31 +#define S390_A14_REGNUM 32 +#define S390_A15_REGNUM 33 +/* Floating Point Control Word. */ +#define S390_FPC_REGNUM 34 +/* Floating Point Registers. */ +#define S390_F0_REGNUM 35 +#define S390_F1_REGNUM 36 +#define S390_F2_REGNUM 37 +#define S390_F3_REGNUM 38 +#define S390_F4_REGNUM 39 +#define S390_F5_REGNUM 40 +#define S390_F6_REGNUM 41 +#define S390_F7_REGNUM 42 +#define S390_F8_REGNUM 43 +#define S390_F9_REGNUM 44 +#define S390_F10_REGNUM 45 +#define S390_F11_REGNUM 46 +#define S390_F12_REGNUM 47 +#define S390_F13_REGNUM 48 +#define S390_F14_REGNUM 49 +#define S390_F15_REGNUM 50 +/* Total. */ +#define S390_NUM_REGS 51 + +/* Pseudo registers -- PC and condition code. */ +#define S390_PC_REGNUM S390_NUM_REGS +#define S390_CC_REGNUM (S390_NUM_REGS+1) +#define S390_NUM_PSEUDO_REGS 2 +#define S390_NUM_TOTAL_REGS (S390_NUM_REGS+2) + +#endif target-s390x/exec.h +5
-0@@ -22,9 +22,14 @@ register struct CPUS390XState *env asm(AREG0); +#include "config.h" #include "cpu.h" #include "exec-all.h" +#if !defined(CONFIG_USER_ONLY ) +#include "softmmu_exec.h" +#endif /* !defined(CONFIG_USER_ONLY) */ +static inline int cpu_has_work (CPUState *env) {return env->interrupt_request &CPU_INTERRUPT_HARD ;// guess target-s390x/helper.c +10
-0@@ -27,6 +27,9 @@#include "gdbstub.h" #include "qemu-common.h" +#include <linux/kvm.h> +#include "kvm.h" +CPUS390XState *cpu_s390x_init (const char *cpu_model) {CPUS390XState *env;@@ -60,3 +63,22 @@ void cpu_reset(CPUS390XState *env)/* FIXME: reset vector? */ tlb_flush (env,1 ); } + +#ifndef CONFIG_USER_ONLY + +int cpu_s390x_handle_mmu_fault (CPUState *env,target_ulong address,int rw, +int mmu_idx,int is_softmmu) +{ +target_ulong phys;
target-s390x/helper.c void cpu_reset(CPUS390XState *env) · line 82
Quoted 10 lines
target-s390x/helper.c +10
-0+int prot; + +/* XXX: implement mmu */ + + phys = address; + prot =PAGE_READ |PAGE_WRITE ; + +return tlb_set_page (env, address &TARGET_PAGE_MASK , + phys &TARGET_PAGE_MASK , prot, + mmu_idx, is_softmmu);
Same as previous comment, if softmmu accesses are possible, this function should be written correctly.
Quoted 12 lines
target-s390x/helper.c +2
-0+} +#endif /* CONFIG_USER_ONLY */ target-s390x/machine.c new file +4
-0@@ -0,0 +1,30 @@ +/* +* QEMU S390x machine definitions +* +* Copyright (c) 2009 Alexander Graf <[email protected]>
target-s390x/machine.c line 14
Quoted 10 lines
target-s390x/machine.c new file +10
-0+* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details.
/> + *
Quoted 21 lines
target-s390x/machine.c new file +15
-0+* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "hw/hw.h" +#include "hw/boards.h" + +void cpu_save (QEMUFile *f,void *opaque) +{ +} + +int cpu_load (QEMUFile *f,void *opaque,int version_id) +{ +return 0 ; +}Signature · 1 line
1.6.0.2
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 06/11] Add support for S390x system emulation
Quoted 6 lines · Aurelien Jarno
Quoted 2 lines · Alexander Graf
Let's enable the basics for system emulation so we can run virtual machines with KVM!
I don't really understand while this whole patch is not merged in patch number 1. Otherwise, please find the comments below.
Historical reasons. To keep Uli's stripped down version separate from my code.
Quoted 32 lines
Quoted 32 lines
Signed-off-by Alexander Graf <[email protected]>---
target-s390x/cpu.h | 153 ++++++++++++++++++++++++++++++++++++- target-s390x/exec.h | 5 + target-s390x/helper.c | 22 +++++ target-s390x/machine.c | 30 +++++++ 4 files changed, 208 insertions(+), 2 deletions(-)create mode 100644 default-configs/s390x-softmmu.mak create mode 100644
target-s390x/machine.cdefault-configs/s390x-softmmu.mak new file +0
-0target-s390x/cpu.h +1
-2@@ -30,8 +30,7 @@#include "softfloat.h" -#define NB_MMU_MODES 2 // guess -#define MMU_USER_IDX 0 // guess +#define NB_MMU_MODES 2 typedef union FPReg { struct {@@ -77,6 +76,15 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) }#endif
Quoted 11 lines
target-s390x/cpu.h static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) · line 85
Quoted 7 lines
target-s390x/cpu.h +7
-0+#define MMU_MODE0_SUFFIX _kernel +#define MMU_MODE1_SUFFIX _user +#define MMU_USER_IDX 1 +static inline int cpu_mmu_index (CPUState *env) +{ +/* XXX: Currently we don't implement virtual memory */ +return 0 ;Is it correct? It means that memory access will aways be kernel memory accesses. IIRC, even with KVM enabled, softmmu accesses are possible in some cases (devices ?).
I can't imagine any hardware using the CPU's MMU to write to RAM. That's what IOMMUs are for.
The only 2 consumers are:
1) tcg
2) gdb / monitor
With 2) being broken, because we can't resolve virtual addresses to physical addresses. But that won't change until someone implements the softmmu emulation target for real.
Re: [Qemu-devel] [PATCH 06/11] Add support for S390x system emulation
Quoted 56 lines · Alexander Graf
Quoted 6 lines · Aurelien Jarno
Quoted 2 lines · Alexander Graf
Let's enable the basics for system emulation so we can run virtual machines with KVM!
I don't really understand while this whole patch is not merged in patch number 1. Otherwise, please find the comments below.
Historical reasons. To keep Uli's stripped down version separate from my code.
Quoted 32 lines
Quoted 32 lines
Signed-off-by Alexander Graf <[email protected]>---
target-s390x/cpu.h | 153 ++++++++++++++++++++++++++++++++++++- target-s390x/exec.h | 5 + target-s390x/helper.c | 22 +++++ target-s390x/machine.c | 30 +++++++ 4 files changed, 208 insertions(+), 2 deletions(-)create mode 100644 default-configs/s390x-softmmu.mak create mode 100644
target-s390x/machine.cdefault-configs/s390x-softmmu.mak new file +0
-0target-s390x/cpu.h +1
-2@@ -30,8 +30,7 @@#include "softfloat.h" -#define NB_MMU_MODES 2 // guess -#define MMU_USER_IDX 0 // guess +#define NB_MMU_MODES 2 typedef union FPReg { struct {@@ -77,6 +76,15 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) }#endif Quoted 11 lines
target-s390x/cpu.h static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) · line 85
Quoted 7 lines
target-s390x/cpu.h +7
-0+#define MMU_MODE0_SUFFIX _kernel +#define MMU_MODE1_SUFFIX _user +#define MMU_USER_IDX 1 +static inline int cpu_mmu_index (CPUState *env) +{ +/* XXX: Currently we don't implement virtual memory */ +return 0 ;Is it correct? It means that memory access will aways be kernel memory accesses. IIRC, even with KVM enabled, softmmu accesses are possible in some cases (devices ?).
Quoted 8 lines
I can't imagine any hardware using the CPU's MMU to write to RAM. That's what IOMMUs are for.
The only 2 consumers are:
1) tcg
2) gdb / monitorWith 2) being broken, because we can't resolve virtual addresses to physical addresses. But that won't change until someone implements the softmmu emulation target for real.
If it is sure it is never used, I would prefer to see an abort(). Otherwise it's fine.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 06/11] Add support for S390x system emulation
Quoted 61 lines · Aurelien Jarno
Quoted 60 lines · Alexander Graf
Quoted 6 lines · Aurelien Jarno
Quoted 2 lines · Alexander Graf
Let's enable the basics for system emulation so we can run virtual machines with KVM!
I don't really understand while this whole patch is not merged in patch number 1. Otherwise, please find the comments below.
Historical reasons. To keep Uli's stripped down version separate from my code.
Quoted 32 lines
Quoted 32 lines
Signed-off-by Alexander Graf <[email protected]>---
target-s390x/cpu.h | 153 ++++++++++++++++++++++++++++++++++++- target-s390x/exec.h | 5 + target-s390x/helper.c | 22 +++++ target-s390x/machine.c | 30 +++++++ 4 files changed, 208 insertions(+), 2 deletions(-)create mode 100644 default-configs/s390x-softmmu.mak create mode 100644
target-s390x/machine.cdefault-configs/s390x-softmmu.mak new file +0
-0target-s390x/cpu.h +1
-2@@ -30,8 +30,7 @@#include "softfloat.h" -#define NB_MMU_MODES 2 // guess -#define MMU_USER_IDX 0 // guess +#define NB_MMU_MODES 2 typedef union FPReg { struct {@@ -77,6 +76,15 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) }#endif Quoted 11 lines
target-s390x/cpu.h static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) · line 85
Quoted 7 lines
target-s390x/cpu.h +7
-0+#define MMU_MODE0_SUFFIX _kernel +#define MMU_MODE1_SUFFIX _user +#define MMU_USER_IDX 1 +static inline int cpu_mmu_index (CPUState *env) +{ +/* XXX: Currently we don't implement virtual memory */ +return 0 ;Is it correct? It means that memory access will aways be kernel memory accesses. IIRC, even with KVM enabled, softmmu accesses are possible in some cases (devices ?).
I can't imagine any hardware using the CPU's MMU to write to RAM. That's what IOMMUs are for.
The only 2 consumers are:
Quoted 7 lines
Quoted 4 lines
1) tcg
2) gdb / monitorWith 2) being broken, because we can't resolve virtual addresses to physical addresses. But that won't change until someone implements the softmmu emulation target for real.
If it is sure it is never used, I would prefer to see an
abort(). Otherwise it's fine.
I don't think I understand where you want to put the abort().
Alex
Re: [Qemu-devel] [PATCH 06/11] Add support for S390x system emulation
Quoted 67 lines · Alexander Graf
Quoted 64 lines · Aurelien Jarno
Quoted 63 lines · Alexander Graf
Quoted 6 lines · Aurelien Jarno
Quoted 2 lines · Alexander Graf
Let's enable the basics for system emulation so we can run virtual machines with KVM!
I don't really understand while this whole patch is not merged in patch number 1. Otherwise, please find the comments below.
Historical reasons. To keep Uli's stripped down version separate from my code.
Quoted 32 lines
Quoted 32 lines
Signed-off-by Alexander Graf <[email protected]>---
target-s390x/cpu.h | 153 ++++++++++++++++++++++++++++++++++++- target-s390x/exec.h | 5 + target-s390x/helper.c | 22 +++++ target-s390x/machine.c | 30 +++++++ 4 files changed, 208 insertions(+), 2 deletions(-)create mode 100644 default-configs/s390x-softmmu.mak create mode 100644
target-s390x/machine.cdefault-configs/s390x-softmmu.mak new file +0
-0target-s390x/cpu.h +1
-2@@ -30,8 +30,7 @@#include "softfloat.h" -#define NB_MMU_MODES 2 // guess -#define MMU_USER_IDX 0 // guess +#define NB_MMU_MODES 2 typedef union FPReg { struct {@@ -77,6 +76,15 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) }#endif Quoted 11 lines
target-s390x/cpu.h static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) · line 85
Quoted 7 lines
target-s390x/cpu.h +7
-0+#define MMU_MODE0_SUFFIX _kernel +#define MMU_MODE1_SUFFIX _user +#define MMU_USER_IDX 1 +static inline int cpu_mmu_index (CPUState *env) +{ +/* XXX: Currently we don't implement virtual memory */ +return 0 ;Is it correct? It means that memory access will aways be kernel memory accesses. IIRC, even with KVM enabled, softmmu accesses are possible in some cases (devices ?).
I can't imagine any hardware using the CPU's MMU to write to RAM. That's what IOMMUs are for.
The only 2 consumers are:
1) tcg
2) gdb / monitor
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
With 2) being broken, because we can't resolve virtual addresses to physical addresses. But that won't change until someone implements the softmmu emulation target for real.
If it is sure it is never used, I would prefer to see an
abort(). Otherwise it's fine.I don't think I understand where you want to put the
abort().
In inline cpu_mmu_index(), just before the return, to make sure this function is never called, as it is clearly wrong.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] [PATCH 06/11] Add support for S390x system emulation
Quoted 70 lines · Aurelien Jarno
Quoted 69 lines · Alexander Graf
Quoted 66 lines · Aurelien Jarno
Quoted 64 lines · Alexander Graf
Quoted 6 lines · Aurelien Jarno
Quoted 2 lines · Alexander Graf
Let's enable the basics for system emulation so we can run virtual machines with KVM!
I don't really understand while this whole patch is not merged in patch number 1. Otherwise, please find the comments below.
Historical reasons. To keep Uli's stripped down version separate from my code.
Quoted 32 lines
Quoted 32 lines
Signed-off-by Alexander Graf <[email protected]>---
target-s390x/cpu.h | 153 ++++++++++++++++++++++++++++++++++++- target-s390x/exec.h | 5 + target-s390x/helper.c | 22 +++++ target-s390x/machine.c | 30 +++++++ 4 files changed, 208 insertions(+), 2 deletions(-)create mode 100644 default-configs/s390x-softmmu.mak create mode 100644
target-s390x/machine.cdefault-configs/s390x-softmmu.mak new file +0
-0target-s390x/cpu.h +1
-2@@ -30,8 +30,7 @@#include "softfloat.h" -#define NB_MMU_MODES 2 // guess -#define MMU_USER_IDX 0 // guess +#define NB_MMU_MODES 2 typedef union FPReg { struct {@@ -77,6 +76,15 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) }#endif Quoted 11 lines
target-s390x/cpu.h static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) · line 85
Quoted 7 lines
target-s390x/cpu.h +7
-0+#define MMU_MODE0_SUFFIX _kernel +#define MMU_MODE1_SUFFIX _user +#define MMU_USER_IDX 1 +static inline int cpu_mmu_index (CPUState *env) +{ +/* XXX: Currently we don't implement virtual memory */ +return 0 ;Is it correct? It means that memory access will aways be kernel memory accesses. IIRC, even with KVM enabled, softmmu accesses are possible in some cases (devices ?).
I can't imagine any hardware using the CPU's MMU to write to RAM. That's what IOMMUs are for.
The only 2 consumers are:
1) tcg
2) gdb / monitorWith 2) being broken, because we can't resolve virtual addresses to physical addresses. But that won't change until someone implements the softmmu emulation target for real.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
If it is sure it is never used, I would prefer to see an
abort(). Otherwise it's fine.I don't think I understand where you want to put the
abort().In inline
cpu_mmu_index(), just before the return, to make sure this function is never called, as it is clearly wrong.
It's just always saying we're in kernel mode. I don't see where that's wrong. There's no logic to implement modes, so that's the only reasonable thing to do.
Also, it does get called. That's what I mean with the target 2). When you're in the monitor and do x /i $pc, you end up calling that function. While it's not great to only have linear mapped memory here, it's a lot better than having no reply or, even worse, killing the VM.
Alex
Re: [Qemu-devel] [PATCH 06/11] Add support for S390x system emulation
In reply to Aurelien JarnoQuoted 8 lines · Aurelien Jarno
target-s390x/cpu.h static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) · line 85
Quoted 4 lines
target-s390x/cpu.h +4
-0+static inline int cpu_mmu_index (CPUState *env) +{ +/* XXX: Currently we don't implement virtual memory */ +return 0 ;Is it correct? It means that memory access will aways be kernel memory accesses. IIRC, even with KVM enabled, softmmu accesses are possible in some cases (devices ?).
On s390, we don't have memory mapped I/O. KVM is virtio only, and even if we would add channel devices we would not require softmmu emulation here. S390 does'nt have pci, usb or alike.
PATCH 7/11 Add S390x virtio machine bus
In reply to Alexander GrafOn S390x we don't want to go through the hassle of emulating real existing hardware, because we don't need to for running Linux.
So let's instead implement a machine that is 100% based on VirtIO which we fortunately implement already.
This patch implements the bus that is the groundwork for such an S390x virtio machine.
--- Makefile.target | 2 + hw/s390-virtio-bus.c | 385 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/s390-virtio-bus.h | 65 +++++++++ 3 files changed, 452 insertions(+), 0 deletions(-) create mode 100644 hw/s390-virtio-bus.c create mode 100644 hw/s390-virtio-bus.h
Makefile.target +2 -0
@@ -296,6 +296,8 @@ obj-sh4-y += ide/core.o ide/mmio.o obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o obj-m68k-y += m68k-semi.o dummy_m68k.o +obj-s390x-y = s390-virtio-bus.o + main.o vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
hw/s390-virtio-bus.c new file +385 -0
385 lines not on this page · raw message
hw/s390-virtio-bus.h new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
1.6.0.2
PATCH 8/11 Add S390x virtio machine description
In reply to Alexander GrafIn order to use the new S390x virtio bus we just introduced, we also need a machine description that sets up the machine according to our PV specification.
Let's add that machine description and be happy!
---
v4 -> v5
- disable early console
--- Makefile.target | 2 +- hw/s390-virtio.c | 240 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 241 insertions(+), 1 deletions(-) create mode 100644 hw/s390-virtio.c
Makefile.target +1 -1
@@ -296,7 +296,7 @@ obj-sh4-y += ide/core.o ide/mmio.o obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o obj-m68k-y += m68k-semi.o dummy_m68k.o -obj-s390x-y = s390-virtio-bus.o +obj-s390x-y = s390-virtio-bus.o s390-virtio.o main.o vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
hw/s390-virtio.c new file +240 -0
240 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Re: [Qemu-devel] [PATCH 08/11] Add S390x virtio machine description
Quoted 5 lines · Alexander Graf
In order to use the new S390x virtio bus we just introduced, we also need a machine description that sets up the machine according to our PV specification.
Let's add that machine description and be happy!
Please find the comments below.
Quoted 97 lines
Signed-off-by Alexander Graf <[email protected]>---
v4 -> v5
- disable early console
--- Makefile.target | 2 +- hw/s390-virtio.c | 240 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 241 insertions(+), 1 deletions(-) create mode 100644 hw/s390-virtio.cMakefile.target +1
-1@@ -296,7 +296,7 @@ obj-sh4-y += ide/core.o ide/mmio.o obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o obj-m68k-y += m68k-semi.o dummy_m68k.o -obj-s390x-y = s390-virtio-bus.o +obj-s390x-y = s390-virtio-bus.o s390-virtio.o main.o vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)hw/s390-virtio.c new file +65
-0@@ -0,0 +1,240 @@ +/* +* QEMU S390 virtio target +* +* Copyright (c) 2009 Alexander Graf <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "hw.h" +#include "block.h" +#include "sysemu.h" +#include "net.h" +#include "boards.h" +#include "monitor.h" +#include "loader.h" +#include "elf.h" +#include "hw/virtio.h" +#include "hw/virtio-console.h" +#include "hw/sysbus.h" +#include "kvm.h" + +#include "hw/s390-virtio-bus.h" + +//#define DEBUG_S390 + +#ifdef DEBUG_S390 +#define dprintf (fmt, ...) \ + do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +#else +#define dprintf (fmt, ...) \ + do { } while (0) +#endif + +#define KVM_S390_VIRTIO_NOTIFY 0 +#define KVM_S390_VIRTIO_RESET 1 +#define KVM_S390_VIRTIO_SET_STATUS 2 + +#define KERN_IMAGE_START 0x010000UL +#define KERN_PARM_AREA 0x010480UL +#define INITRD_START 0x800000UL +#define INITRD_PARM_START 0x010408UL +#define INITRD_PARM_SIZE 0x010410UL +#define PARMFILE_START 0x001000UL + +#define MAX_BLK_DEVS 10 + +static VirtIOS390Bus *s390_bus; +static CPUState **ipi_states; + +void irq_info (Monitor *mon); +void pic_info (Monitor *mon); + +void irq_info (Monitor *mon) +{
hw/s390-virtio.c line 75
Quoted 10 lines
hw/s390-virtio.c new file +10
-0+} + +void pic_info (Monitor *mon) +{ +} + +CPUState *s390_cpu_addr2state (uint16_t cpu_addr) +{ +if (cpu_addr >= smp_cpus) +return NULL ;
coding style.
Quoted 18 lines
hw/s390-virtio.c new file +18
-0+ +return ipi_states[cpu_addr]; +} + +int s390_virtio_hypercall (CPUState *env) +{ +int r =0 , i; +target_ulong mem = env->regs[2 ]; + +dprintf ("KVM hypercall: %ld\n" , env->regs[1 ]); +switch (env->regs[1 ]) { +case KVM_S390_VIRTIO_NOTIFY : +if (mem > ram_size) { +VirtIOS390Device *dev =s390_virtio_bus_find_vring (s390_bus, + mem, &i); +if (dev) { +virtio_queue_notify (dev->vdev, i); + }else {
hw/s390-virtio.c line 103
Quoted 10 lines
hw/s390-virtio.c new file +10
-0+ r = -EINVAL ; + } + }else { +/* Early printk */ + } +break ; +case KVM_S390_VIRTIO_RESET : + { +/* Virtio_reset resets the internal addresses, so we'd have to sync +them up again. We don't want to reallicate a vring though, so let's
^^^^^ typo
hw/s390-virtio.c line 116
Quoted 13 lines
hw/s390-virtio.c new file +13
-0+just not reset. */ +/* virtio_reset(dev->vdev); */ +break ; + } +case KVM_S390_VIRTIO_SET_STATUS : + { +VirtIOS390Device *dev; + + dev =s390_virtio_bus_find_mem (s390_bus, mem); +if (dev) +s390_virtio_device_update_status (dev); +else + r = -EINVAL ;
coding style.
Quoted 43 lines
hw/s390-virtio.c new file +43
-0+break ; + } +default : + r = -EINVAL ; +break ; + } + + env->regs[2 ] = r; +return 0 ; +} + +/* PC hardware initialisation */ +static void s390_init (ram_addr_t _ram_size, +const char *boot_device, +const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename, +const char *cpu_model) +{ +CPUState *env =NULL ; +ram_addr_t ram_addr, ram_size = _ram_size; +ram_addr_t kernel_size =0 ; +ram_addr_t initrd_offset; +ram_addr_t initrd_size =0 ; +int i; + +/* get a BUS */ + s390_bus =s390_virtio_bus_init (&ram_size); + +/* allocate RAM */ + ram_addr =qemu_ram_alloc (ram_size); +cpu_register_physical_memory (0 , ram_size, ram_addr); + +/* init CPUs */ +if (cpu_model ==NULL ) { + cpu_model ="host" ; + } + + ipi_states =qemu_malloc (sizeof (CPUState *) * smp_cpus); + +for (i =0 ; i < smp_cpus; i++) { + env =cpu_init (cpu_model); + ipi_states[smp_cpus - (i +1 )] = env;
hw/s390-virtio.c line 169
Quoted 10 lines
hw/s390-virtio.c new file +10
-0+ env->halted =1 ; + env->exception_index =EXCP_HLT ; + } + + env->halted =0 ; + env->exception_index =0 ; + +if (kernel_filename) { + kernel_size =load_image (kernel_filename,qemu_get_ram_ptr (0 )); +
You should probably use load_image_targphys() instead to reload the kernel on reset.
hw/s390-virtio.c line 177
Quoted 8 lines
hw/s390-virtio.c new file +8
-0+if (lduw_phys (KERN_IMAGE_START ) !=0x0dd0 ) { +fprintf (stderr,"Specified image is not an s390 boot image\n" ); +exit (1 ); + } + +cpu_synchronize_state (env); + env->psw.addr =KERN_IMAGE_START ; + env->psw.mask =0x0000000180000000UL ;
Shouldn't it be done by registering a reset handler, so that this value are restored on reset?
hw/s390-virtio.c line 183
Quoted 6 lines
hw/s390-virtio.c new file +6
-0+ } + +if (initrd_filename) { + initrd_offset =INITRD_START ; +while (kernel_size +0x100000 > initrd_offset) + initrd_offset +=0x100000 ;
coding style.
hw/s390-virtio.c line 185
Quoted 2 lines
hw/s390-virtio.c new file +2
-0+ initrd_size =load_image (initrd_filename,qemu_get_ram_ptr (initrd_offset)); +
Same as for the kernel.
hw/s390-virtio.c line 187
Quoted 2 lines
hw/s390-virtio.c new file +2
-0+stq_phys (INITRD_PARM_START , initrd_offset); +stq_phys (INITRD_PARM_SIZE , initrd_size);
The same way, it should probably be added with rom_add_blob_fixed().
hw/s390-virtio.c line 192
Quoted 5 lines
hw/s390-virtio.c new file +5
-0+ } + +if (kernel_cmdline) { +cpu_physical_memory_rw (KERN_PARM_AREA , (uint8_t *)kernel_cmdline, +strlen (kernel_cmdline),1 );
and here with pstrcpy_targphys().
hw/s390-virtio.c line 204
Quoted 12 lines
hw/s390-virtio.c new file +12
-0+ } + +/* Create VirtIO console */ +qdev_init_nofail (qdev_create ((BusState *)s390_bus,"virtio-console-s390" )); + +/* Create VirtIO network adapters */ +for (i =0 ; i < nb_nics; i++) { +NICInfo *nd = &nd_table[i]; +DeviceState *dev; + +if (!nd->model) + nd->model = (char *)"virtio" ;
What happens if someone request a nice that is not virtio? It should probably fail.
Quoted 41 lines
hw/s390-virtio.c new file +35
-0+ dev =qdev_create ((BusState *)s390_bus,"virtio-net-s390" ); +qdev_set_nic_properties (dev, nd); +qdev_init_nofail (dev); + } + +/* Create VirtIO disk drives */ +for (i =0 ; i <MAX_BLK_DEVS ; i++) { +DriveInfo *dinfo; +DeviceState *dev; + + dinfo =drive_get (IF_IDE ,0 , i); +if (!dinfo) +continue ; + + dev =qdev_create ((BusState *)s390_bus,"virtio-blk-s390" ); +qdev_prop_set_drive (dev,"drive" , dinfo); +qdev_init_nofail (dev); + } +} + +static QEMUMachine s390_machine = { + .name ="s390-virtio" , + .alias ="s390" , + .desc ="VirtIO based S390 machine" , + .init = s390_init, + .max_cpus =255 , + .is_default =1 , +}; + +static void s390_machine_init (void ) +{ +qemu_register_machine (&s390_machine); +} + +machine_init (s390_machine_init);Signature · 1 line
1.6.0.2
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
PATCH 9/11 S390 GDB stub
In reply to Alexander GrafIn order to debug funny kernel breakages it's always good to have a working gdb stub around.
While Uli's patches don't include one one, I needed one that's at least good enough for 'bt' and some variable examinations during early bootup.
So here it is - the absolute basics to get the qemu gdb stub running with s390x targets.
--- gdbstub.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-)
gdbstub.c +52 -0
@@ -1348,6 +1348,55 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)return 8 ; } +#elif defined (TARGET_S390X ) + +#define NUM_CORE_REGS S390_NUM_TOTAL_REGS + +static int cpu_gdb_read_register (CPUState *env,uint8_t *mem_buf,int n) +{ +switch (n) { +case S390_PSWM_REGNUM :GET_REGL (env->psw.mask);break ; +case S390_PSWA_REGNUM :GET_REGL (env->psw.addr);break ; + case S390_R0_REGNUM ... S390_R15_REGNUM: +GET_REGL (env->regs[n-S390_R0_REGNUM ]);break ; + case S390_A0_REGNUM ... S390_A15_REGNUM: +GET_REG32 (env->aregs[n-S390_A0_REGNUM ]);break ; +case S390_FPC_REGNUM :GET_REG32 (env->fpc);break ; + case S390_F0_REGNUM ... S390_F15_REGNUM: +/* XXX */ +break ; +case S390_PC_REGNUM :GET_REGL (env->psw.addr);break ; +case S390_CC_REGNUM :GET_REG32 (env->cc);break ; + } + +return 0 ; +} + +static int cpu_gdb_write_register (CPUState *env,uint8_t *mem_buf,int n) +{ +target_ulong tmpl; +uint32_t tmp32; +int r =8 ; + tmpl =ldtul_p (mem_buf); + tmp32 =ldl_p (mem_buf); + +switch (n) { +case S390_PSWM_REGNUM : env->psw.mask = tmpl;break ; +case S390_PSWA_REGNUM : env->psw.addr = tmpl;break ; + case S390_R0_REGNUM ... S390_R15_REGNUM: + env->regs[n-S390_R0_REGNUM ] = tmpl;break ; + case S390_A0_REGNUM ... S390_A15_REGNUM: + env->aregs[n-S390_A0_REGNUM ] = tmp32; r=4 ;break ; +case S390_FPC_REGNUM : env->fpc = tmp32; r=4 ;break ; + case S390_F0_REGNUM ... S390_F15_REGNUM: +/* XXX */ +break ; +case S390_PC_REGNUM : env->psw.addr = tmpl;break ; +case S390_CC_REGNUM : env->cc = tmp32; r=4 ;break ; + } + +return r; +}#else #define NUM_CORE_REGS 0
@@ -1616,6 +1665,9 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) s->c_cpu->pc = pc;#elif defined (TARGET_ALPHA ) s->c_cpu->pc = pc; +#elif defined (TARGET_S390X ) +cpu_synchronize_state (s->c_cpu); + s->c_cpu->psw.addr = pc;#endif }
Signature · 1 line
1.6.0.2
PATCH 10/11 Set default console to virtio on S390x
In reply to Alexander GrafAll "normal" system emulation targets in qemu I'm aware of display output on either VGA or serial output.
Our S390x virtio machine doesn't have such kind of legacy hardware. So instead we need to default to a virtio console.
I'm not particularly proud of this patch. It would be a lot better to have something in the machine description that tells us about the default terminal.
--- vl.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-)
vl.c +26 -0
@@ -4663,6 +4663,20 @@ int main(int argc, char **argv, char **envp) cyls = heads = secs =0 ; translation =BIOS_ATA_TRANSLATION_AUTO ; +#ifdef TARGET_S390X +for (i =0 ; i <MAX_SERIAL_PORTS ; i++) + serial_devices[i] =NULL ; + serial_device_index =0 ; + +for (i =0 ; i <MAX_PARALLEL_PORTS ; i++) + parallel_devices[i] =NULL ; + parallel_device_index =0 ; + + virtio_consoles[0 ] ="mon:stdio" ; +for (i =1 ; i <MAX_VIRTIO_CONSOLES ; i++) + virtio_consoles[i] =NULL ; + virtio_console_index =0 ; +#else serial_devices[0 ] ="vc:80Cx24C" ;for (i =1 ; i <MAX_SERIAL_PORTS ; i++) serial_devices[i] =NULL ;
@@ -4676,6 +4690,7 @@ int main(int argc, char **argv, char **envp)for (i =0 ; i <MAX_VIRTIO_CONSOLES ; i++) virtio_consoles[i] =NULL ; virtio_console_index =0 ; +#endif monitor_devices[0 ] ="vc:80Cx24C" ;for (i =1 ; i <MAX_MONITOR_DEVICES ; i++) {
@@ -5585,6 +5600,17 @@ int main(int argc, char **argv, char **envp)break ; } } +for (i =0 ; i <MAX_VIRTIO_CONSOLES ; i++) { +const char *devname = virtio_consoles[i]; +if (devname && !strcmp (devname,"mon:stdio" )) { + monitor_devices[0 ] =NULL ; +break ; + }else if (devname && !strcmp (devname,"stdio" )) { + monitor_devices[0 ] =NULL ; + virtio_consoles[i] ="mon:stdio" ; +break ; + } + } }if (nb_numa_nodes >0 ) {
Signature · 1 line
1.6.0.2
PATCH 11/11 Add S390 maintainer information
In reply to Alexander GrafThis patch adds information about who handles what when it comes to S390. I'll gladly support anything that's related to the device emulation model and S390 KVM parts.
Since this patchset doesn't implement S390 CPU emulation, I left that part with a question mark. As soon as Uli's patchset gets committed I'd recommend setting him there.
--- MAINTAINERS | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
MAINTAINERS +3 -0
@@ -20,6 +20,7 @@ SH4 ? CRIS Edgar E. Iglesias Alpha ? MicroBlaze Edgar E. Iglesias +S390 ? Machines (sorted by CPU): -------------------------
@@ -63,6 +64,8 @@ CRIS Alpha MicroBlaze petalogix_s3adsp1800.c Edgar E. Iglesias +S390 + s390-*.c Alexander Graf Generic Subsystems: -------------------
Signature · 1 line
1.6.0.2
Hi,
Quoted 35 lines · Alexander Graf
While S390x was one of the first targets that were supported by KVM it always lacked qemu system emulation support.
In order to change that sad fact, I figured I'd just take on the task myself, taking kuli (http://www.ibm.com/developerworks/linux/linux390/kuli.html),
Documentation/s390/kvm.txtand lguest as starting points to write a clean, qemu'ish S390x Virtio machine emulation.So now you can run Linux VMs on Linux on z/VM on LPAR on zSeries!
This is the resulting code. Please comment on things you like and also on the ones you don't :-).
The patchset is based on Uli's S390x userspace emulation patches. There's not really that much shared functionality, but I didn't want to reimplement the configure wheels. So make sure to have his patches applied first.
Please only run S390x system virtualization using io threads. S390x has very few intercepts and even less that actually reach userspace. So you'll end up with a non-responsive VM without a dedicated IO thread.
Use: $ ./configure --target-list=s390x-softmmu --enable-io-thread
Currently only -kernel, -initrd and friends work. Booting from a real dasd device is not supported.
Also to actually run this code you need a patch for an ugly bug in the kernel module that Carsten sent a patch to on the ML.
I verified that the userspace actually works on a 2.6.27 (SLES11) kernel, so if it doesn't work on current git, please tell me! I'm too afraid that I might end up in a 3270 terminal to update the kernel on my z/VM instance :-).
##### WARNING #####
Quoted 9 lines
Apparently the qemu review process has scared off yet another developer for now.
So I'm sending this patchset without relying on Uli's set but rather implemented small stubs for TCG host and TCG guest support, so we can run on KVM. He promised me to send it again "soon" - whenever that is.
These stubs don't serve any purpose but to get KVM running, so you get no x86 on S390X or S390X on x86 for now!
This patchset basically looks ok. I have some minor comments, a lot of them being related to coding style, but they should be easy to solve, and should not prevent inclusion in 0.12.0 release.
Please find comments in the individual patches.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net