s390x: assorted updates
The following changes since commit 008a51bbb343972dd8cf09126da8c3b87f4e1c96:
Merge remote-tracking branch 'remotes/famz/tags/staging-pull-request' into staging (2018-02-08 14:31:51 +0000)
are available in the git repository at:
git://github.com/cohuck/qemu tags/s390x-20180209
for you to fetch changes up to ced01bb7e5d353a9055743d68d54f3581b29328c:
MAINTAINERS: add David as additional tcg/s390 maintainer (2018-02-09 09:37:13 +0100)
----------------------------------------------------------------
s390x updates:
- rework interrupt handling for tcg, smp is now considered non-experimental
- some general improvements in the flic
- improvements in the pci code, and wiring it up in tcg
- add PTFF subfunctions for multiple-epoch to the cpu model
- maintainership updates
- various other fixes and improvements
----------------------------------------------------------------
Alice Frosi (1):
Fix configure for s390 qemu on alpine and other busybox environments
Christian Borntraeger (1):
s390x/sclp: fix event mask handling
Cornelia Huck (5):
s390x/tcg: wire up pci instructions s390x/cpumodel: allow zpci features in qemu model
MAINTAINERS: add myself as overall s390x maintainer
MAINTAINERS: reorganize s390-ccw bios maintainership
MAINTAINERS: add David as additional tcg/s390 maintainer
David Hildenbrand (19):
s390x/tcg: deliver multiple interrupts in a row s390x/flic: simplify flic initialization
s390x/tcg: simplify lookup of flic
s390x/tcg: simplify machine check handling
s390x/flic: factor out injection of floating interrupts s390x/flic: no need to call s390_io_interrupt() from flic s390x/tcg: tolerate wrong wakeups due to floating interrupts s390x/flic: make floating interrupts on TCG actually floating s390x/tcg: implement TEST PENDING INTERRUPTION s390x/flic: implement qemu_s390_clear_io_flic() s390x/flic: optimize CPU wakeup for TCG
s390x: fix size + content of STSI blocks
s390x/tcg: STSI overhaul
s390x/tcg: remove SMP warning
configure: s390x supports mttcg now
s390x/tcg: cache the qemu flic in a central function s390x/kvm: cache the kvm flic in a central function s390x/flic: cache the common flic class in a central function s390x/cpumodel: model PTFF subfunctions for Multiple-epoch facility
Yi Min Zhao (3):
s390x/pci: fixup the code walking IOMMU tables s390x/pci: fixup global refresh
s390x/pci: use the right pal and pba in reg_ioat()
MAINTAINERS | 35 +++- configure | 5 +- hw/intc/s390_flic.c | 257 +++++++++++++++++++++++++++-- hw/intc/s390_flic_kvm.c | 84 ++++++++-- hw/s390x/css.c | 10 +- hw/s390x/event-facility.c | 4 +- hw/s390x/s390-pci-bus.c | 233 +++++++++++++++++++++----- hw/s390x/s390-pci-bus.h | 17 ++ hw/s390x/s390-pci-inst.c | 103 ++++++++---- hw/s390x/s390-virtio-ccw.c | 4 - hw/s390x/virtio-ccw.c | 4 +- include/hw/s390x/s390_flic.h | 57 ++++++- target/s390x/cpu.c | 10 -- target/s390x/cpu.h | 99 ++++++----- target/s390x/cpu_features.c | 5 + target/s390x/cpu_features_def.h | 4 + target/s390x/cpu_models.c | 6 + target/s390x/excp_helper.c | 147 +++++++---------- target/s390x/gen-features.c | 17 +- target/s390x/helper.h | 10 ++ target/s390x/insn-data.def | 14 ++ target/s390x/internal.h | 5 - target/s390x/interrupt.c | 100 +++-------- target/s390x/kvm-stub.c | 13 -- target/s390x/kvm.c | 78 ++------- target/s390x/kvm_s390x.h | 10 +- target/s390x/misc_helper.c | 355 +++++++++++++++++++++++++++++----------- target/s390x/translate.c | 110 +++++++++++++ 28 files changed, 1244 insertions(+), 552 deletions(-)
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 01/29] Fix configure for s390 qemu on alpine and other busybox environments
From: Alice Frosi <[email protected]>
In alpine docker image the qemu-system-s390x build is broken and it throws this error:
qemu-system-s390x: Initialization of device s390-ipl failed: could not load bootloader 's390-ccw.img'
The grep command of busybox uses regex. This fails on binary data (e.g. stops on every \0), so it does not identify the string BiGeNdIaN in the test case big/little. Therefore, it assumes that the architecture is little endian.
This fix solves the grep problem by printing the content of TMPO with strings
Message-Id: <[email protected]>
--- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
configure +2 -2
@@ -1933,9 +1933,9 @@ int main(int argc, char *argv[]) { EOF if compile_object ; then - if grep -q BiGeNdIaN $TMPO ; then + if strings -a $TMPO | grep -q BiGeNdIaN ; then bigendian="yes" - elif grep -q LiTtLeEnDiAn $TMPO ; then + elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then bigendian="no" else echo big/little test failed
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 02/29] s390x/tcg: deliver multiple interrupts in a row
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
We have to consider all deliverable interrupts.
We now have to take care of the special scenario, where we first inject an interrupt with a WAIT PSW, followed by a !WAIT PSW. (very unlikely but possible)
Message-Id: <[email protected]>
--- target/s390x/excp_helper.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
target/s390x/excp_helper.c +16 -4
@@ -433,10 +433,12 @@ void s390_cpu_do_interrupt(CPUState *cs) {S390CPU *cpu =S390_CPU (cs);CPUS390XState *env = &cpu->env; +bool stopped = false;qemu_log_mask (CPU_LOG_INT ,"%s: %d at pc=%" PRIx64"\n" , __func__, cs->exception_index, env->psw.addr); +try_deliver:/* handle machine checks */ if (cs->exception_index ==-1 &&s390_cpu_has_mcck_int (cpu)) { cs->exception_index =EXCP_MCHK ;
@@ -479,13 +481,14 @@ void s390_cpu_do_interrupt(CPUState *cs)break ;case EXCP_STOP :do_stop_interrupt (env); + stopped = true;break ; } -/* WAIT PSW during interrupt injection or STOP interrupt */ -if (cs->exception_index ==EXCP_HLT ) { -/* don't trigger a cpu_loop_exit(), use an interrupt instead */ -cpu_interrupt (CPU (cpu),CPU_INTERRUPT_HALT ); +if (cs->exception_index !=-1 && !stopped) { +/* check if there are more pending interrupts to deliver */ + cs->exception_index =-1 ; + goto try_deliver; } cs->exception_index =-1 ;
@@ -493,6 +496,15 @@ void s390_cpu_do_interrupt(CPUState *cs)if (!env->pending_int) { cs->interrupt_request &= ~CPU_INTERRUPT_HARD ; } + +/* WAIT PSW during interrupt injection or STOP interrupt */ +if ((env->psw.mask &PSW_MASK_WAIT ) || stopped) { +/* don't trigger a cpu_loop_exit(), use an interrupt instead */ +cpu_interrupt (CPU (cpu),CPU_INTERRUPT_HALT ); + }else if (cs->halted) { +/* unhalt if we had a WAIT PSW somehwere in our injection chain */ +s390_cpu_unhalt (cpu); + } }bool s390_cpu_exec_interrupt (CPUState *cs,int interrupt_request)
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 03/29] s390x/flic: simplify flic initialization
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
This makes it clearer, which device is used for which accelerator.
Message-Id: <[email protected]>
--- hw/intc/s390_flic.c | 7 +++++-- hw/intc/s390_flic_kvm.c | 12 ------------ include/hw/s390x/s390_flic.h | 9 --------- 3 files changed, 5 insertions(+), 23 deletions(-)
hw/intc/s390_flic.c +5 -2
@@ -40,8 +40,11 @@ void s390_flic_init(void) {DeviceState *dev; - dev =s390_flic_kvm_create (); -if (!dev) { +if (kvm_enabled ()) { + dev =qdev_create (NULL ,TYPE_KVM_S390_FLIC ); +object_property_add_child (qdev_get_machine (),TYPE_KVM_S390_FLIC , +OBJECT (dev),NULL ); + }else { dev =qdev_create (NULL ,TYPE_QEMU_S390_FLIC );object_property_add_child (qdev_get_machine (),TYPE_QEMU_S390_FLIC ,OBJECT (dev),NULL );
hw/intc/s390_flic_kvm.c +0 -12
@@ -35,18 +35,6 @@ typedef struct KVMS390FLICState {bool clear_io_supported; } KVMS390FLICState; -DeviceState *s390_flic_kvm_create (void ) -{ -DeviceState *dev =NULL ; - -if (kvm_enabled ()) { - dev =qdev_create (NULL ,TYPE_KVM_S390_FLIC ); -object_property_add_child (qdev_get_machine (),TYPE_KVM_S390_FLIC , -OBJECT (dev),NULL ); - } -return dev; -} -/** * flic_get_all_irqs - store all pending irqs in buffer * @buf: pointer to buffer which is passed to kernel
include/hw/s390x/s390_flic.h +0 -9
@@ -91,13 +91,4 @@ void s390_flic_init(void);S390FLICState *s390_get_flic (void );bool ais_needed (void *opaque); -#ifdef CONFIG_KVM -DeviceState *s390_flic_kvm_create (void ); -#else -static inline DeviceState *s390_flic_kvm_create (void ) -{ -return NULL ; -} -#endif -#endif /* HW_S390_FLIC_H */
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 04/29] s390x/tcg: simplify lookup of flic
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
We can simply search for an object of our common type.
Message-Id: <[email protected]>
--- hw/intc/s390_flic.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
hw/intc/s390_flic.c +3 -5
@@ -27,11 +27,9 @@ S390FLICState *s390_get_flic(void)static S390FLICState *fs;if (!fs) { - fs =S390_FLIC_COMMON (object_resolve_path (TYPE_KVM_S390_FLIC ,NULL )); -if (!fs) { - fs =S390_FLIC_COMMON (object_resolve_path (TYPE_QEMU_S390_FLIC , -NULL )); - } + fs =S390_FLIC_COMMON (object_resolve_path_type ("" , +TYPE_S390_FLIC_COMMON , +NULL )); }return fs; }
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 05/29] s390x/tcg: simplify machine check handling
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
We currently only support CRW machine checks. This is a preparation for real floating interrupt support.
Get rid of the queue and handle it via the bit INTERRUPT_MCHK. We don't rename it for now, as it will be soon gone (when moving crw machine checks into the flic).
Please note that this is the same way also KVM handles it: only one instance of a machine check can be pending at a time. So no need for a queue.
While at it, make sure we try to deliver only if env->cregs[14] actually indicates that CRWs are accepted.
Drop two unused defines on the way (we already have PSW_MASK_...).
Message-Id: <[email protected]>
--- target/s390x/cpu.c | 2 -- target/s390x/cpu.h | 10 ---------- target/s390x/excp_helper.c | 29 +++++------------------------ target/s390x/interrupt.c | 18 +++++++----------- 4 files changed, 12 insertions(+), 47 deletions(-)
target/s390x/cpu.c +0 -2
@@ -119,7 +119,6 @@ static void s390_cpu_initial_reset(CPUState *s)for (i =0 ; i <ARRAY_SIZE (env->io_index); i++) { env->io_index[i] =-1 ; } - env->mchk_index =-1 ;/* tininess for underflow is detected before rounding */ set_float_detect_tininess(float_tininess_before_rounding,
@@ -156,7 +155,6 @@ static void s390_cpu_full_reset(CPUState *s)for (i =0 ; i <ARRAY_SIZE (env->io_index); i++) { env->io_index[i] =-1 ; } - env->mchk_index =-1 ;/* tininess for underflow is detected before rounding */ set_float_detect_tininess(float_tininess_before_rounding,
target/s390x/cpu.h +0 -10
@@ -54,10 +54,6 @@#define MMU_USER_IDX 0#define MAX_IO_QUEUE 16 -#define MAX_MCHK_QUEUE 16 - -#define PSW_MCHK_MASK 0x0004000000000000 -#define PSW_IO_MASK 0x0200000000000000#define S390_MAX_CPUS 248
@@ -73,10 +69,6 @@ typedef struct IOIntQueue {uint32_t word; } IOIntQueue; -typedef struct MchkQueue { -uint16_t type; -}MchkQueue ; -struct CPUS390XState {uint64_t regs[16 ];/* GP registers */ /*
@@ -123,14 +115,12 @@ struct CPUS390XState {uint64_t cregs[16 ];/* control registers */ IOIntQueue io_queue[MAX_IO_QUEUE ][8 ]; -MchkQueue mchk_queue[MAX_MCHK_QUEUE ];int pending_int;uint32_t service_param;uint16_t external_call_addr;DECLARE_BITMAP (emergency_signals,S390_MAX_CPUS );int io_index[8 ]; -int mchk_index;uint64_t ckc;uint64_t cputm;
target/s390x/excp_helper.c +5 -24
@@ -368,30 +368,16 @@ static void do_io_interrupt(CPUS390XState *env)static void do_mchk_interrupt (CPUS390XState *env) { -S390CPU *cpu =s390_env_get_cpu (env);uint64_t mask, addr;LowCore *lowcore; -MchkQueue *q;int i; -if (!(env->psw.mask &PSW_MASK_MCHECK )) { -cpu_abort (CPU (cpu),"Machine check w/o mchk mask\n" ); - } +/* for now we only support channel report machine checks (floating) */ +g_assert (env->psw.mask &PSW_MASK_MCHECK ); +g_assert (env->cregs[14 ] &CR14_CHANNEL_REPORT_SC ); -if (env->mchk_index <0 || env->mchk_index >=MAX_MCHK_QUEUE ) { -cpu_abort (CPU (cpu),"Mchk queue overrun: %d\n" , env->mchk_index); - } - - q = &env->mchk_queue[env->mchk_index]; - -if (q->type !=1 ) { -/* Don't know how to handle this... */ -cpu_abort (CPU (cpu),"Unknown machine check type %d\n" , q->type); - } -if (!(env->cregs[14 ] & (1 <<28 ))) { -/* CRW machine checks disabled */ -return ; - } +g_assert (env->pending_int &INTERRUPT_MCHK ); + env->pending_int &= ~INTERRUPT_MCHK ; lowcore =cpu_map_lowcore (env);
@@ -418,11 +404,6 @@ static void do_mchk_interrupt(CPUS390XState *env)cpu_unmap_lowcore (lowcore); - env->mchk_index--; -if (env->mchk_index ==-1 ) { - env->pending_int &= ~INTERRUPT_MCHK ; - } -DPRINTF ("%s: %" PRIx64" %" PRIx64"\n" , __func__, env->psw.mask, env->psw.addr);
target/s390x/interrupt.c +7 -11
@@ -162,16 +162,6 @@ static void cpu_inject_crw_mchk(S390CPU *cpu) {CPUS390XState *env = &cpu->env; -if (env->mchk_index ==MAX_MCHK_QUEUE -1 ) { -/* ugh - can't queue anymore. Let's drop. */ -return ; - } - - env->mchk_index++; -assert (env->mchk_index <MAX_MCHK_QUEUE ); - - env->mchk_queue[env->mchk_index].type =1 ; - env->pending_int |=INTERRUPT_MCHK ;cpu_interrupt (CPU (cpu),CPU_INTERRUPT_HARD ); }
@@ -225,7 +215,13 @@ bool s390_cpu_has_mcck_int(S390CPU *cpu)return false; } -return env->pending_int &INTERRUPT_MCHK ; +/* for now we only support channel report machine checks (floating) */ +if ((env->pending_int &INTERRUPT_MCHK ) && + (env->cregs[14 ] &CR14_CHANNEL_REPORT_SC )) { +return true; + } + +return false; }bool s390_cpu_has_ext_int (S390CPU *cpu)
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 06/29] s390x/flic: factor out injection of floating interrupts
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Let the flic device handle it internally. This will allow us to later on store floating interrupts in the flic for the TCG case.
This now also simplifies kvm.c. All that's left is the fallback interface for floating interrupts, which is now triggered directly via the flic in case anything goes wrong.
Message-Id: <[email protected]>
--- hw/intc/s390_flic.c | 31 ++++++++++++++++++++ hw/intc/s390_flic_kvm.c | 63 ++++++++++++++++++++++++++++++++++++---- include/hw/s390x/s390_flic.h | 5 ++++ target/s390x/cpu.h | 7 ++++- target/s390x/interrupt.c | 42 +++++++++++---------------- target/s390x/kvm-stub.c | 13 --------- target/s390x/kvm.c | 68 ++++---------------------------------------- target/s390x/kvm_s390x.h | 10 +------ 8 files changed, 123 insertions(+), 116 deletions(-)
hw/intc/s390_flic.c +31 -0
@@ -127,6 +127,34 @@ static int qemu_s390_inject_airq(S390FLICState *fs, uint8_t type,return 0 ; } +static void qemu_s390_inject_service (S390FLICState *fs,uint32_t parm) +{ + +S390CPU *dummy_cpu =s390_cpu_addr2state (0 ); + +/* FIXME: don't inject into dummy CPU */ +cpu_inject_service (dummy_cpu, parm); +} + +static void qemu_s390_inject_io (S390FLICState *fs,uint16_t subchannel_id, +uint16_t subchannel_nr,uint32_t io_int_parm, +uint32_t io_int_word) +{ +S390CPU *dummy_cpu =s390_cpu_addr2state (0 ); + +/* FIXME: don't inject into dummy CPU */ +cpu_inject_io (dummy_cpu, subchannel_id, subchannel_nr, io_int_parm, + io_int_word); +} + +static void qemu_s390_inject_crw_mchk (S390FLICState *fs) +{ +S390CPU *dummy_cpu =s390_cpu_addr2state (0 ); + +/* FIXME: don't inject into dummy CPU */ +cpu_inject_crw_mchk (dummy_cpu); +} +static void qemu_s390_flic_reset (DeviceState *dev) {QEMUS390FLICState *flic =QEMU_S390_FLIC (dev);
@@ -168,6 +196,9 @@ static void qemu_s390_flic_class_init(ObjectClass *oc, void *data) fsc->clear_io_irq = qemu_s390_clear_io_flic; fsc->modify_ais_mode = qemu_s390_modify_ais_mode; fsc->inject_airq = qemu_s390_inject_airq; + fsc->inject_service = qemu_s390_inject_service; + fsc->inject_io = qemu_s390_inject_io; + fsc->inject_crw_mchk = qemu_s390_inject_crw_mchk; }static Property s390_flic_common_properties[] = {
hw/intc/s390_flic_kvm.c +58 -5
78 lines not on this page · raw message
include/hw/s390x/s390_flic.h +5 -0
@@ -66,6 +66,11 @@ typedef struct S390FLICStateClass {int (*modify_ais_mode)(S390FLICState *fs,uint8_t isc,uint16_t mode);int (*inject_airq)(S390FLICState *fs,uint8_t type,uint8_t isc,uint8_t flags); +void (*inject_service)(S390FLICState *fs,uint32_t parm); +void (*inject_io)(S390FLICState *fs,uint16_t subchannel_id, +uint16_t subchannel_nr,uint32_t io_int_parm, +uint32_t io_int_word); +void (*inject_crw_mchk)(S390FLICState *fs); } S390FLICStateClass;#define TYPE_KVM_S390_FLIC "s390-flic-kvm"
target/s390x/cpu.h +6 -1
@@ -741,7 +741,12 @@ void s390_program_interrupt(CPUS390XState *env, uint32_t code, int ilen, uintptr_t ra);/* service interrupts are floating therefore we must not pass an cpustate */ void s390_sclp_extint (uint32_t parm); - +/* FIXME: remove once we have proper floating interrupts in TCG */ +void cpu_inject_service (S390CPU *cpu,uint32_t param); +void cpu_inject_crw_mchk (S390CPU *cpu); +void cpu_inject_io (S390CPU *cpu,uint16_t subchannel_id, +uint16_t subchannel_number,uint32_t io_int_parm, +uint32_t io_int_word);/* mmu_helper.c */ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf,
target/s390x/interrupt.c +17 -25
84 lines not on this page · raw message
target/s390x/kvm-stub.c +0 -13
@@ -12,10 +12,6 @@#include "cpu.h" #include "kvm_s390x.h" -void kvm_s390_service_interrupt (uint32_t parm) -{ -} -void kvm_s390_access_exception (S390CPU *cpu,uint16_t code,uint64_t te_code) { }
@@ -30,15 +26,6 @@ void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code) { } -void kvm_s390_io_interrupt (uint16_t subchannel_id,uint16_t subchannel_nr, -uint32_t io_int_parm,uint32_t io_int_word) -{ -} - -void kvm_s390_crw_mchk (void ) -{ -} -int kvm_s390_set_cpu_state (S390CPU *cpu,uint8_t cpu_state) {return -ENOSYS ;
target/s390x/kvm.c +5 -63
92 lines not on this page · raw message
target/s390x/kvm_s390x.h +1 -9
@@ -12,17 +12,12 @@struct kvm_s390_irq ; -void kvm_s390_floating_interrupt (struct kvm_s390_irq *irq); -void kvm_s390_service_interrupt (uint32_t parm); +void kvm_s390_floating_interrupt_legacy (struct kvm_s390_irq *irq);void kvm_s390_vcpu_interrupt (S390CPU *cpu,struct kvm_s390_irq *irq);void kvm_s390_access_exception (S390CPU *cpu,uint16_t code,uint64_t te_code);int kvm_s390_mem_op (S390CPU *cpu,vaddr addr,uint8_t ar,void *hostbuf,int len,bool is_write);void kvm_s390_program_interrupt (S390CPU *cpu,uint16_t code); -void kvm_s390_io_interrupt (uint16_t subchannel_id, -uint16_t subchannel_nr,uint32_t io_int_parm, -uint32_t io_int_word); -void kvm_s390_crw_mchk (void );int kvm_s390_set_cpu_state (S390CPU *cpu,uint8_t cpu_state);void kvm_s390_vcpu_interrupt_pre_save (S390CPU *cpu);int kvm_s390_vcpu_interrupt_post_load (S390CPU *cpu);
@@ -44,7 +39,4 @@ void kvm_s390_crypto_reset(void);void kvm_s390_restart_interrupt (S390CPU *cpu);void kvm_s390_stop_interrupt (S390CPU *cpu); -/* implemented outside of target/s390x/ */ -int kvm_s390_inject_flic (struct kvm_s390_irq *irq); -#endif /* KVM_S390X_H */
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 07/29] s390x/flic: no need to call s390_io_interrupt() from flic
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
We can directly call the right function.
Message-Id: <[email protected]>
--- hw/intc/s390_flic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/intc/s390_flic.c +2 -1
@@ -108,6 +108,7 @@ static int qemu_s390_inject_airq(S390FLICState *fs, uint8_t type, uint8_t isc, uint8_t flags) {QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); +S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs);bool flag = flags &S390_ADAPTER_SUPPRESSIBLE ;uint32_t io_int_word = (isc <<27 ) |IO_INT_WORD_AI ;
@@ -116,7 +117,7 @@ static int qemu_s390_inject_airq(S390FLICState *fs, uint8_t type,return 0 ; } -s390_io_interrupt (0 ,0 ,0 , io_int_word); + fsc->inject_io (fs,0 ,0 ,0 , io_int_word);if (flag && (flic->simm &AIS_MODE_MASK (isc))) { flic->nimm |=AIS_MODE_MASK (isc);
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 08/29] s390x/tcg: tolerate wrong wakeups due to floating interrupts
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
This is a preparation for floating interrupt support and only applies to MTTCG, single threaded TCG works just fine. If a floating interrupt wakes up a VCPU and the CPU thinks it can run (clearing cs->halted), at the point where the interrupt would be delivered, already another VCPU might have picked up the interrupt, resulting in a wakeup without an interrupt (executing wrong code).
It is wrong to let the VCPU continue to execute (the WAIT PSW). Instead, we have to put the VCPU back to sleep.
Message-Id: <[email protected]>
--- target/s390x/excp_helper.c | 5 +++++ 1 file changed, 5 insertions(+)
target/s390x/excp_helper.c +5 -0
@@ -503,6 +503,11 @@ bool s390_cpu_exec_interrupt(CPUState *cs, int interrupt_request)s390_cpu_do_interrupt (cs);return true; } +if (env->psw.mask &PSW_MASK_WAIT ) { +/* Woken up because of a floating interrupt but it has already +* been delivered. Go back to sleep. */ +cpu_interrupt (CPU (cpu),CPU_INTERRUPT_HALT ); + } }return false; }
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 10/29] s390x/tcg: implement TEST PENDING INTERRUPTION
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Use s390_cpu_virt_mem_write() so we can actually revert what we did (re-inject the dequeued IO interrupt).
Message-Id: <[email protected]>
--- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 1 + target/s390x/misc_helper.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ target/s390x/translate.c | 8 +++++++ 4 files changed, 64 insertions(+)
target/s390x/helper.h +1 -0
@@ -170,6 +170,7 @@ DEF_HELPER_4(schm, void, env, i64, i64, i64) DEF_HELPER_3(ssch, void, env, i64, i64) DEF_HELPER_2(stcrw, void, env, i64) DEF_HELPER_3(stsch, void, env, i64, i64) +DEF_HELPER_2(tpi, i32, env, i64) DEF_HELPER_3(tsch, void, env, i64, i64) DEF_HELPER_2(chsc, void, env, i64)#endif
target/s390x/insn-data.def +1 -0
@@ -1063,6 +1063,7 @@ C(0xb233, SSCH, S, Z, 0, insn, 0, 0, ssch, 0) C(0xb239, STCRW, S, Z, 0, insn, 0, 0, stcrw, 0) C(0xb234, STSCH, S, Z, 0, insn, 0, 0, stsch, 0) + C(0xb236, TPI , S, Z, la2, 0, 0, 0, tpi, 0) C(0xb235, TSCH, S, Z, 0, insn, 0, 0, tsch, 0) /* ??? Not listed in PoO ninth edition, but there's a linux driver that uses it: "A CHSC subchannel is usually present on LPAR only." */
target/s390x/misc_helper.c +54 -0
66 lines not on this page · raw message
target/s390x/translate.c +8 -0
@@ -4199,6 +4199,14 @@ static ExitStatus op_stcrw(DisasContext *s, DisasOps *o)return NO_EXIT ; } +static ExitStatus op_tpi (DisasContext *s,DisasOps *o) +{ +check_privileged (s); +gen_helper_tpi (cc_op, cpu_env, o->addr1); +set_cc_static (s); +return NO_EXIT ; +} +static ExitStatus op_tsch (DisasContext *s,DisasOps *o) {check_privileged (s);
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 11/29] s390x/flic: implement qemu_s390_clear_io_flic()
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Now that we have access to the io interrupts, we can implement clear_io_irq() for TCG.
Message-Id: <[email protected]>
--- hw/intc/s390_flic.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
hw/intc/s390_flic.c +29 -2
@@ -79,8 +79,35 @@ static void qemu_s390_release_adapter_routes(S390FLICState *fs,static int qemu_s390_clear_io_flic (S390FLICState *fs,uint16_t subchannel_id,uint16_t subchannel_nr) { -/* Fixme TCG */ -return -ENOSYS ; +QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); +QEMUS390FlicIO *cur, *next; +uint8_t isc; + +g_assert (qemu_mutex_iothread_locked ()); +if (!(flic->pending &FLIC_PENDING_IO )) { +return 0 ; + } + +/* check all iscs */ +for (isc =0 ; isc <8 ; isc++) { +if (QLIST_EMPTY (&flic->io[isc])) { +continue ; + } + +/* search and delete any matching one */ + QLIST_FOREACH_SAFE(cur, &flic->io[isc], next, next) { +if (cur->id == subchannel_id && cur->nr == subchannel_nr) { +QLIST_REMOVE (cur, next); +g_free (cur); + } + } + +/* update our indicator bit */ +if (QLIST_EMPTY (&flic->io[isc])) { + flic->pending &= ~ISC_TO_PENDING_IO (isc); + } + } +return 0 ; } static int qemu_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc,
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 12/29] s390x/flic: optimize CPU wakeup for TCG
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Kicking all CPUs on every floating interrupt is far from efficient. Let's optimize it at least a little bit.
Message-Id: <[email protected]>
--- hw/intc/s390_flic.c | 31 +++++++++++++++++++++++++++++-- target/s390x/cpu.h | 4 ++++ target/s390x/internal.h | 5 ----- 3 files changed, 33 insertions(+), 7 deletions(-)
hw/intc/s390_flic.c +29 -2
@@ -161,10 +161,37 @@ static void qemu_s390_flic_notify(uint32_t type)/* * We have to make all CPUs see CPU_INTERRUPT_HARD, so they might -* consider it. TODO: don't kick/wakeup all VCPUs but try to be -* smarter (using the interrupt type). +* consider it. We will kick all running CPUs and only relevant +* sleeping ones. */ CPU_FOREACH (cs) { +S390CPU *cpu =S390_CPU (cs); + + cs->interrupt_request |=CPU_INTERRUPT_HARD ; + +/* ignore CPUs that are not sleeping */ +if (s390_cpu_get_state (cpu) !=CPU_STATE_OPERATING && +s390_cpu_get_state (cpu) !=CPU_STATE_LOAD ) { +continue ; + } + +/* we always kick running CPUs for now, this is tricky */ +if (cs->halted) { +/* don't check for subclasses, CPUs double check when waking up */ +if (type &FLIC_PENDING_SERVICE ) { +if (!(cpu->env.psw.mask &PSW_MASK_EXT )) { +continue ; + } + }else if (type &FLIC_PENDING_IO ) { +if (!(cpu->env.psw.mask &PSW_MASK_IO )) { +continue ; + } + }else if (type &FLIC_PENDING_MCHK_CR ) { +if (!(cpu->env.psw.mask &PSW_MASK_MCHECK )) { +continue ; + } + } + }cpu_interrupt (cs,CPU_INTERRUPT_HARD ); } }
target/s390x/cpu.h +4 -0
@@ -692,6 +692,10 @@ static inline unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu) return 0; }#endif /* CONFIG_USER_ONLY */ +static inline uint8_t s390_cpu_get_state (S390CPU *cpu) +{ +return cpu->env.cpu_state; +}/* cpu_models.c */
target/s390x/internal.h +0 -5
@@ -278,11 +278,6 @@ static inline void s390_do_cpu_full_reset(CPUState *cs, run_on_cpu_data arg)cpu_reset (cs); } -static inline uint8_t s390_cpu_get_state (S390CPU *cpu) -{ -return cpu->env.cpu_state; -} -/* arch_dump.c */ int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 09/29] s390x/flic: make floating interrupts on TCG actually floating
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Move floating interrupt handling into the flic. Floating interrupts will now be considered by all CPUs, not just CPU #0. While at it, convert I/O interrupts to use a list and make sure we properly consider I/O sub-classes in s390_cpu_has_io_int().
Message-Id: <[email protected]>
--- hw/intc/s390_flic.c | 144 ++++++++++++++++++++++++++++++++++++++++--- include/hw/s390x/s390_flic.h | 41 ++++++++++++ target/s390x/cpu.c | 8 --- target/s390x/cpu.h | 22 ------- target/s390x/excp_helper.c | 97 ++++++++++------------------- target/s390x/interrupt.c | 52 ++-------------- 6 files changed, 212 insertions(+), 152 deletions(-)
hw/intc/s390_flic.c +134 -10
@@ -128,40 +128,153 @@ static int qemu_s390_inject_airq(S390FLICState *fs, uint8_t type,return 0 ; } +static void qemu_s390_flic_notify (uint32_t type) +{ +CPUState *cs; + +/* +* We have to make all CPUs see CPU_INTERRUPT_HARD, so they might +* consider it. TODO: don't kick/wakeup all VCPUs but try to be +* smarter (using the interrupt type). +*/ +CPU_FOREACH (cs) { +cpu_interrupt (cs,CPU_INTERRUPT_HARD ); + } +} + +uint32_t qemu_s390_flic_dequeue_service (QEMUS390FLICState *flic) +{ +uint32_t tmp; + +g_assert (qemu_mutex_iothread_locked ()); +g_assert (flic->pending &FLIC_PENDING_SERVICE ); + tmp = flic->service_param; + flic->service_param =0 ; + flic->pending &= ~FLIC_PENDING_SERVICE ; + +return tmp; +} + +/* caller has to free the returned object */ +QEMUS390FlicIO *qemu_s390_flic_dequeue_io (QEMUS390FLICState *flic,uint64_t cr6) +{ +QEMUS390FlicIO *io; +uint8_t isc; + +g_assert (qemu_mutex_iothread_locked ()); +if (!(flic->pending &CR6_TO_PENDING_IO (cr6))) { +return NULL ; + } + +for (isc =0 ; isc <8 ; isc++) { +if (QLIST_EMPTY (&flic->io[isc]) || !(cr6 &ISC_TO_ISC_BITS (isc))) { +continue ; + } + io =QLIST_FIRST (&flic->io[isc]); +QLIST_REMOVE (io, next); + +/* update our indicator bit */ +if (QLIST_EMPTY (&flic->io[isc])) { + flic->pending &= ~ISC_TO_PENDING_IO (isc); + } +return io; + } + +return NULL ; +} + +void qemu_s390_flic_dequeue_crw_mchk (QEMUS390FLICState *flic) +{ +g_assert (qemu_mutex_iothread_locked ()); +g_assert (flic->pending &FLIC_PENDING_MCHK_CR ); + flic->pending &= ~FLIC_PENDING_MCHK_CR ; +} +static void qemu_s390_inject_service (S390FLICState *fs,uint32_t parm) { +QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); -S390CPU *dummy_cpu =s390_cpu_addr2state (0 ); +g_assert (qemu_mutex_iothread_locked ()); +/* multiplexing is good enough for sclp - kvm does it internally as well */ + flic->service_param |= parm; + flic->pending |=FLIC_PENDING_SERVICE ; -/* FIXME: don't inject into dummy CPU */ -cpu_inject_service (dummy_cpu, parm); +qemu_s390_flic_notify (FLIC_PENDING_SERVICE ); }static void qemu_s390_inject_io (S390FLICState *fs,uint16_t subchannel_id,uint16_t subchannel_nr,uint32_t io_int_parm,uint32_t io_int_word) { -S390CPU *dummy_cpu =s390_cpu_addr2state (0 ); +const uint8_t isc =IO_INT_WORD_ISC (io_int_word); +QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); +QEMUS390FlicIO *io; -/* FIXME: don't inject into dummy CPU */ -cpu_inject_io (dummy_cpu, subchannel_id, subchannel_nr, io_int_parm, - io_int_word); +g_assert (qemu_mutex_iothread_locked ()); + io =g_new0 (QEMUS390FlicIO,1 ); + io->id = subchannel_id; + io->nr = subchannel_nr; + io->parm = io_int_parm; + io->word = io_int_word; + +QLIST_INSERT_HEAD (&flic->io[isc], io, next); + flic->pending |=ISC_TO_PENDING_IO (isc); + +qemu_s390_flic_notify (ISC_TO_PENDING_IO (isc)); }static void qemu_s390_inject_crw_mchk (S390FLICState *fs) { -S390CPU *dummy_cpu =s390_cpu_addr2state (0 ); +QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); + +g_assert (qemu_mutex_iothread_locked ()); + flic->pending |=FLIC_PENDING_MCHK_CR ; + +qemu_s390_flic_notify (FLIC_PENDING_MCHK_CR ); +} + +bool qemu_s390_flic_has_service (QEMUS390FLICState *flic) +{ +/* called without lock via cc->has_work, will be validated under lock */ +return !!(flic->pending &FLIC_PENDING_SERVICE ); +} + +bool qemu_s390_flic_has_io (QEMUS390FLICState *flic,uint64_t cr6) +{ +/* called without lock via cc->has_work, will be validated under lock */ +return !!(flic->pending &CR6_TO_PENDING_IO (cr6)); +} + +bool qemu_s390_flic_has_crw_mchk (QEMUS390FLICState *flic) +{ +/* called without lock via cc->has_work, will be validated under lock */ +return !!(flic->pending &FLIC_PENDING_MCHK_CR ); +} -/* FIXME: don't inject into dummy CPU */ -cpu_inject_crw_mchk (dummy_cpu); +bool qemu_s390_flic_has_any (QEMUS390FLICState *flic) +{ +g_assert (qemu_mutex_iothread_locked ()); +return !!flic->pending; }static void qemu_s390_flic_reset (DeviceState *dev) {QEMUS390FLICState *flic =QEMU_S390_FLIC (dev); +QEMUS390FlicIO *cur, *next; +int isc; +g_assert (qemu_mutex_iothread_locked ()); flic->simm =0 ; flic->nimm =0 ; + flic->pending =0 ; + +/* remove all pending io interrupts */ +for (isc =0 ; isc <8 ; isc++) { + QLIST_FOREACH_SAFE(cur, &flic->io[isc], next, next) { +QLIST_REMOVE (cur, next); +g_free (cur); + } + } }bool ais_needed (void *opaque)
@@ -183,6 +296,16 @@ static const VMStateDescription qemu_s390_flic_vmstate = { } }; +static void qemu_s390_flic_instance_init (Object *obj) +{ +QEMUS390FLICState *flic =QEMU_S390_FLIC (obj); +int isc; + +for (isc =0 ; isc <8 ; isc++) { +QLIST_INIT (&flic->io[isc]); + } +} +static void qemu_s390_flic_class_init (ObjectClass *oc,void *data) {DeviceClass *dc =DEVICE_CLASS (oc);
@@ -234,6 +357,7 @@ static const TypeInfo qemu_s390_flic_info = { .name = TYPE_QEMU_S390_FLIC, .parent = TYPE_S390_FLIC_COMMON, .instance_size = sizeof(QEMUS390FLICState), + .instance_init = qemu_s390_flic_instance_init, .class_init = qemu_s390_flic_class_init, };
include/hw/s390x/s390_flic.h +41 -0
59 lines not on this page · raw message
target/s390x/cpu.c +0 -8
@@ -100,7 +100,6 @@ static void s390_cpu_initial_reset(CPUState *s) {S390CPU *cpu =S390_CPU (s);CPUS390XState *env = &cpu->env; -int i;s390_cpu_reset (s);/* initial reset does not clear everything! */
@@ -116,9 +115,6 @@ static void s390_cpu_initial_reset(CPUState *s) env->gbea =1 ; env->pfault_token =-1UL ; -for (i =0 ; i <ARRAY_SIZE (env->io_index); i++) { - env->io_index[i] =-1 ; - }/* tininess for underflow is detected before rounding */ set_float_detect_tininess(float_tininess_before_rounding,
@@ -136,7 +132,6 @@ static void s390_cpu_full_reset(CPUState *s)S390CPU *cpu =S390_CPU (s);S390CPUClass *scc =S390_CPU_GET_CLASS (cpu);CPUS390XState *env = &cpu->env; -int i; scc->parent_reset (s); cpu->env.sigp_order =0 ;
@@ -152,9 +147,6 @@ static void s390_cpu_full_reset(CPUState *s) env->gbea =1 ; env->pfault_token =-1UL ; -for (i =0 ; i <ARRAY_SIZE (env->io_index); i++) { - env->io_index[i] =-1 ; - }/* tininess for underflow is detected before rounding */ set_float_detect_tininess(float_tininess_before_rounding,
target/s390x/cpu.h +0 -22
@@ -53,8 +53,6 @@#define MMU_USER_IDX 0 -#define MAX_IO_QUEUE 16 -#define S390_MAX_CPUS 248 typedef struct PSW {
@@ -62,13 +60,6 @@ typedef struct PSW {uint64_t addr; }PSW ; -typedef struct IOIntQueue { -uint16_t id; -uint16_t nr; -uint32_t parm; -uint32_t word; -}IOIntQueue ; -struct CPUS390XState {uint64_t regs[16 ];/* GP registers */ /*
@@ -114,13 +105,9 @@ struct CPUS390XState {uint64_t cregs[16 ];/* control registers */ -IOIntQueue io_queue[MAX_IO_QUEUE ][8 ]; -int pending_int; -uint32_t service_param;uint16_t external_call_addr;DECLARE_BITMAP (emergency_signals,S390_MAX_CPUS ); -int io_index[8 ];uint64_t ckc;uint64_t cputm;
@@ -399,9 +386,6 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState* env, target_ulong *pc,#define EXCP_IO 7/* I/O interrupt */ #define EXCP_MCHK 8/* machine check */ -#define INTERRUPT_IO (1 << 0) -#define INTERRUPT_MCHK (1 << 1) -#define INTERRUPT_EXT_SERVICE (1 << 2)#define INTERRUPT_EXT_CPU_TIMER (1 << 3)#define INTERRUPT_EXT_CLOCK_COMPARATOR (1 << 4)#define INTERRUPT_EXTERNAL_CALL (1 << 5)
@@ -741,12 +725,6 @@ void s390_program_interrupt(CPUS390XState *env, uint32_t code, int ilen, uintptr_t ra);/* service interrupts are floating therefore we must not pass an cpustate */ void s390_sclp_extint (uint32_t parm); -/* FIXME: remove once we have proper floating interrupts in TCG */ -void cpu_inject_service (S390CPU *cpu,uint32_t param); -void cpu_inject_crw_mchk (S390CPU *cpu); -void cpu_inject_io (S390CPU *cpu,uint16_t subchannel_id, -uint16_t subchannel_number,uint32_t io_int_parm, -uint32_t io_int_word);/* mmu_helper.c */ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf,
target/s390x/excp_helper.c +31 -66
152 lines not on this page · raw message
target/s390x/interrupt.c +6 -46
100 lines not on this page · raw message
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 13/29] s390x: fix size + content of STSI blocks
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
All blocks are 4k in size, which is only true for two of them right now. Also some reserved fields were wrong, fix it and convert all reserved fields to u8.
This also fixes the LPAR part output in /proc/sysinfo under TCG. (for now, everything was indicated as 0)
While at it, introduce typedefs for these structs and use them in TCG/KVM code.
Message-Id: <[email protected]>
--- target/s390x/cpu.h | 46 ++++++++++++++++++++++++++-------------------- target/s390x/kvm.c | 2 +- target/s390x/misc_helper.c | 12 ++++++------ 3 files changed, 33 insertions(+), 27 deletions(-)
target/s390x/cpu.h +26 -20
@@ -437,29 +437,31 @@ static inline void setcc(S390CPU *cpu, uint64_t cc)#define STSI_R1_SEL2_MASK 0x000000000000ffffULL/* Basic Machine Configuration */ -struct sysib_111 { -uint32_t res1[8 ]; +typedef struct SysIB_111 { +uint8_t res1[32 ];uint8_t manuf[16 ];uint8_t type[4 ];uint8_t res2[12 ];uint8_t model[16 ];uint8_t sequence[16 ];uint8_t plant[4 ]; -uint8_t res3[156 ]; -}; +uint8_t res3[3996 ]; +}SysIB_111 ; +QEMU_BUILD_BUG_ON (sizeof (SysIB_111) !=4096 );/* Basic Machine CPU */ -struct sysib_121 { -uint32_t res1[80 ]; +typedef struct SysIB_121 { +uint8_t res1[80 ];uint8_t sequence[16 ];uint8_t plant[4 ];uint8_t res2[2 ];uint16_t cpu_addr; -uint8_t res3[152 ]; -}; +uint8_t res3[3992 ]; +}SysIB_121 ; +QEMU_BUILD_BUG_ON (sizeof (SysIB_121) !=4096 );/* Basic Machine CPUs */ -struct sysib_122 { +typedef struct SysIB_122 { uint8_t res1[32]; uint32_t capability; uint16_t total_cpus;
@@ -467,21 +469,23 @@ struct sysib_122 {uint16_t standby_cpus;uint16_t reserved_cpus;uint16_t adjustments[2026 ]; -}; +} SysIB_122; +QEMU_BUILD_BUG_ON (sizeof (SysIB_122) !=4096 );/* LPAR CPU */ -struct sysib_221 { -uint32_t res1[80 ]; +typedef struct SysIB_221 { +uint8_t res1[80 ];uint8_t sequence[16 ];uint8_t plant[4 ];uint16_t cpu_id;uint16_t cpu_addr; -uint8_t res3[152 ]; -}; +uint8_t res3[3992 ]; +}SysIB_221 ; +QEMU_BUILD_BUG_ON (sizeof (SysIB_221) !=4096 );/* LPAR CPUs */ -struct sysib_222 { -uint32_t res1[32 ]; +typedef struct SysIB_222 { + uint8_t res1[32]; uint16_t lpar_num; uint8_t res2; uint8_t lcpuc;
@@ -494,11 +498,12 @@ struct sysib_222 {uint8_t res3[16 ];uint16_t dedicated_cpus;uint16_t shared_cpus; -uint8_t res4[180 ]; -}; +uint8_t res4[4020 ]; +} SysIB_222; +QEMU_BUILD_BUG_ON (sizeof (SysIB_222) !=4096 );/* VM CPUs */ -struct sysib_322 { +typedef struct SysIB_322 { uint8_t res1[31]; uint8_t count; struct {
@@ -517,7 +522,8 @@ struct sysib_322 { } vm[8 ];uint8_t res4[1504 ];uint8_t ext_names[8 ][256 ]; -}; +} SysIB_322; +QEMU_BUILD_BUG_ON (sizeof (SysIB_322) !=4096 );/* MMU defines */ #define _ASCE_ORIGIN ~0xfffULL/* segment table origin */
target/s390x/kvm.c +1 -1
@@ -1675,7 +1675,7 @@ static int handle_tsch(S390CPU *cpu)static void insert_stsi_3_2_2 (S390CPU *cpu,__u64 addr,uint8_t ar) { -struct sysib_322 sysib; +SysIB_322 sysib;int del;if (s390_cpu_virt_mem_read (cpu, addr, ar, &sysib,sizeof (sysib))) {
target/s390x/misc_helper.c +6 -6
@@ -217,7 +217,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0,case STSI_LEVEL_1 :if ((sel1 ==1 ) && (sel2 ==1 )) {/* Basic Machine Configuration */ -struct sysib_111 sysib; +SysIB_111 sysib;char type[5 ] = {};memset (&sysib,0 ,sizeof (sysib));
@@ -232,7 +232,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0,cpu_physical_memory_write (a0, &sysib,sizeof (sysib)); }else if ((sel1 ==2 ) && (sel2 ==1 )) {/* Basic Machine CPU */ -struct sysib_121 sysib; +SysIB_121 sysib;memset (&sysib,0 ,sizeof (sysib));/* XXX make different for different CPUs? */
@@ -242,7 +242,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0,cpu_physical_memory_write (a0, &sysib,sizeof (sysib)); }else if ((sel1 ==2 ) && (sel2 ==2 )) {/* Basic Machine CPUs */ -struct sysib_122 sysib; +SysIB_122 sysib;memset (&sysib,0 ,sizeof (sysib));stl_p (&sysib.capability,0x443afc29 );
@@ -260,7 +260,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, {if ((sel1 ==2 ) && (sel2 ==1 )) {/* LPAR CPU */ -struct sysib_221 sysib; +SysIB_221 sysib;memset (&sysib,0 ,sizeof (sysib));/* XXX make different for different CPUs? */
@@ -271,7 +271,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0,cpu_physical_memory_write (a0, &sysib,sizeof (sysib)); }else if ((sel1 ==2 ) && (sel2 ==2 )) {/* LPAR CPUs */ -struct sysib_222 sysib; +SysIB_222 sysib;memset (&sysib,0 ,sizeof (sysib));stw_p (&sysib.lpar_num,0 );
@@ -295,7 +295,7 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, {if ((sel1 ==2 ) && (sel2 ==2 )) {/* VM CPUs */ -struct sysib_322 sysib; +SysIB_322 sysib;memset (&sysib,0 ,sizeof (sysib)); sysib.count =1 ;
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 14/29] s390x/tcg: STSI overhaul
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
Current STSI implementation is a mess, so let's rewrite it.
Problems fixed by this patch:
1) The order of exceptions/when recognized is wrong.
2) We have to store to virtual address space, not absolute.
3) Alignment check of the block is missing.
3) The SMP information is not indicated.
While at it:
a) Make the code look nicer
- get rid of nesting levels
- use struct initialization instead of initializing to zero
- rename a misspelled field and rename function code defines
- use a union and have only one write statement
- use cpu_to_beX()
b) Indicate the VM name/extended name + UUID just like KVM does
c) Indicate that all LPAR CPUs we fake are dedicated
d) Add a comment why we fake being a KVM guest
e) Give our guest as default the name "TCGguest"
f) Fake the same CPU information we have in our Guest for all layers
While at it, get rid of "potential_page_fault()" by forwarding the retaddr properly.
The result is best verified by looking at "/proc/sysinfo" in the guest when specifying on the qemu command line
-uuid "74738ff5-5367-5958-9aee-98fffdcd1876" \
-name "extra long guest name"
Message-Id: <[email protected]>
--- target/s390x/cpu.h | 22 +++-- target/s390x/misc_helper.c | 212 ++++++++++++++++++++++++--------------------- 2 files changed, 131 insertions(+), 103 deletions(-)
target/s390x/cpu.h +16 -6
@@ -426,11 +426,11 @@ static inline void setcc(S390CPU *cpu, uint64_t cc) }/* STSI */ -#define STSI_LEVEL_MASK 0x00000000f0000000ULL -#define STSI_LEVEL_CURRENT 0x0000000000000000ULL -#define STSI_LEVEL_1 0x0000000010000000ULL -#define STSI_LEVEL_2 0x0000000020000000ULL -#define STSI_LEVEL_3 0x0000000030000000ULL +#define STSI_R0_FC_MASK 0x00000000f0000000ULL +#define STSI_R0_FC_CURRENT 0x0000000000000000ULL +#define STSI_R0_FC_LEVEL_1 0x0000000010000000ULL +#define STSI_R0_FC_LEVEL_2 0x0000000020000000ULL +#define STSI_R0_FC_LEVEL_3 0x0000000030000000ULL#define STSI_R0_RESERVED_MASK 0x000000000fffff00ULL#define STSI_R0_SEL1_MASK 0x00000000000000ffULL#define STSI_R1_RESERVED_MASK 0x00000000ffff0000ULL
@@ -465,7 +465,7 @@ typedef struct SysIB_122 {uint8_t res1[32 ];uint32_t capability;uint16_t total_cpus; -uint16_t active_cpus; +uint16_t conf_cpus;uint16_t standby_cpus;uint16_t reserved_cpus;uint16_t adjustments[2026 ];
@@ -525,6 +525,16 @@ typedef struct SysIB_322 { } SysIB_322;QEMU_BUILD_BUG_ON (sizeof (SysIB_322) !=4096 ); +typedef union SysIB { +SysIB_111 sysib_111; +SysIB_121 sysib_121; +SysIB_122 sysib_122; +SysIB_221 sysib_221; +SysIB_222 sysib_222; +SysIB_322 sysib_322; +}SysIB ; +QEMU_BUILD_BUG_ON (sizeof (SysIB) !=4096 ); +/* MMU defines */ #define _ASCE_ORIGIN ~0xfffULL/* segment table origin */ #define _ASCE_SUBSPACE 0x200/* subspace group control */
target/s390x/misc_helper.c +115 -97
253 lines not on this page · raw message
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 17/29] s390x/tcg: cache the qemu flic in a central function
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
This avoids tons of conversions when handling interrupts.
Message-Id: <[email protected]>
--- hw/intc/s390_flic.c | 23 +++++++++++++++++------ include/hw/s390x/s390_flic.h | 1 + target/s390x/interrupt.c | 6 +++--- target/s390x/misc_helper.c | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-)
hw/intc/s390_flic.c +17 -6
@@ -22,6 +22,17 @@#include "qapi/error.h" #include "hw/s390x/s390-virtio-ccw.h" +QEMUS390FLICState *s390_get_qemu_flic (S390FLICState *fs) +{ +static QEMUS390FLICState *flic; + +if (!flic) { +/* we only have one flic device, so this is fine to cache */ + flic =QEMU_S390_FLIC (fs); + } +return flic; +} +S390FLICState *s390_get_flic (void ) {static S390FLICState *fs;
@@ -79,7 +90,7 @@ static void qemu_s390_release_adapter_routes(S390FLICState *fs,static int qemu_s390_clear_io_flic (S390FLICState *fs,uint16_t subchannel_id,uint16_t subchannel_nr) { -QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); +QEMUS390FLICState *flic =s390_get_qemu_flic (fs);QEMUS390FlicIO *cur, *next;uint8_t isc;
@@ -113,7 +124,7 @@ static int qemu_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,static int qemu_s390_modify_ais_mode (S390FLICState *fs,uint8_t isc,uint16_t mode) { -QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); +QEMUS390FLICState *flic =s390_get_qemu_flic (fs);switch (mode) {case SIC_IRQ_MODE_ALL :
@@ -134,7 +145,7 @@ static int qemu_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc,static int qemu_s390_inject_airq (S390FLICState *fs,uint8_t type,uint8_t isc,uint8_t flags) { -QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); +QEMUS390FLICState *flic =s390_get_qemu_flic (fs);S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs);bool flag = flags &S390_ADAPTER_SUPPRESSIBLE ;uint32_t io_int_word = (isc <<27 ) |IO_INT_WORD_AI ;
@@ -246,7 +257,7 @@ void qemu_s390_flic_dequeue_crw_mchk(QEMUS390FLICState *flic)static void qemu_s390_inject_service (S390FLICState *fs,uint32_t parm) { -QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); +QEMUS390FLICState *flic =s390_get_qemu_flic (fs);g_assert (qemu_mutex_iothread_locked ());/* multiplexing is good enough for sclp - kvm does it internally as well */
@@ -261,7 +272,7 @@ static void qemu_s390_inject_io(S390FLICState *fs, uint16_t subchannel_id, uint32_t io_int_word) {const uint8_t isc =IO_INT_WORD_ISC (io_int_word); -QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); +QEMUS390FLICState *flic =s390_get_qemu_flic (fs);QEMUS390FlicIO *io;g_assert (qemu_mutex_iothread_locked ());
@@ -279,7 +290,7 @@ static void qemu_s390_inject_io(S390FLICState *fs, uint16_t subchannel_id,static void qemu_s390_inject_crw_mchk (S390FLICState *fs) { -QEMUS390FLICState *flic =QEMU_S390_FLIC (fs); +QEMUS390FLICState *flic =s390_get_qemu_flic (fs);g_assert (qemu_mutex_iothread_locked ()); flic->pending |=FLIC_PENDING_MCHK_CR ;
include/hw/s390x/s390_flic.h +1 -0
@@ -135,6 +135,7 @@ bool qemu_s390_flic_has_any(QEMUS390FLICState *flic);void s390_flic_init (void );S390FLICState *s390_get_flic (void ); +QEMUS390FLICState *s390_get_qemu_flic (S390FLICState *fs);bool ais_needed (void *opaque);#endif /* HW_S390_FLIC_H */
target/s390x/interrupt.c +3 -3
@@ -158,7 +158,7 @@ void s390_crw_mchk(void)bool s390_cpu_has_mcck_int (S390CPU *cpu) { -QEMUS390FLICState *flic =QEMU_S390_FLIC (s390_get_flic ()); +QEMUS390FLICState *flic =s390_get_qemu_flic (s390_get_flic ());CPUS390XState *env = &cpu->env;if (!(env->psw.mask &PSW_MASK_MCHECK )) {
@@ -176,7 +176,7 @@ bool s390_cpu_has_mcck_int(S390CPU *cpu)bool s390_cpu_has_ext_int (S390CPU *cpu) { -QEMUS390FLICState *flic =QEMU_S390_FLIC (s390_get_flic ()); +QEMUS390FLICState *flic =s390_get_qemu_flic (s390_get_flic ());CPUS390XState *env = &cpu->env;if (!(env->psw.mask &PSW_MASK_EXT )) {
@@ -218,7 +218,7 @@ bool s390_cpu_has_ext_int(S390CPU *cpu)bool s390_cpu_has_io_int (S390CPU *cpu) { -QEMUS390FLICState *flic =QEMU_S390_FLIC (s390_get_flic ()); +QEMUS390FLICState *flic =s390_get_qemu_flic (s390_get_flic ());CPUS390XState *env = &cpu->env;if (!(env->psw.mask &PSW_MASK_IO )) {
target/s390x/misc_helper.c +1 -1
@@ -452,7 +452,7 @@ uint32_t HELPER(tpi)(CPUS390XState *env, uint64_t addr) {const uintptr_t ra =GETPC ();S390CPU *cpu =s390_env_get_cpu (env); -QEMUS390FLICState *flic =QEMU_S390_FLIC (s390_get_flic ()); +QEMUS390FLICState *flic =s390_get_qemu_flic (s390_get_flic ());QEMUS390FlicIO *io =NULL ;LowCore *lowcore;
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 18/29] s390x/kvm: cache the kvm flic in a central function
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
This avoids tons of conversions when handling interrupts.
Message-Id: <[email protected]>
--- hw/intc/s390_flic_kvm.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
hw/intc/s390_flic_kvm.c +16 -5
@@ -35,6 +35,17 @@ typedef struct KVMS390FLICState {bool clear_io_supported; } KVMS390FLICState; +static KVMS390FLICState *s390_get_kvm_flic (S390FLICState *fs) +{ +static KVMS390FLICState *flic; + +if (!flic) { +/* we only have one flic device, so this is fine to cache */ + flic =KVM_S390_FLIC (fs); + } +return flic; +} +/** * flic_get_all_irqs - store all pending irqs in buffer * @buf: pointer to buffer which is passed to kernel
@@ -117,7 +128,7 @@ static void kvm_s390_inject_flic(S390FLICState *fs, struct kvm_s390_irq *irq)int r;if (use_flic) { - r =flic_enqueue_irqs (irq,sizeof (*irq),KVM_S390_FLIC (fs)); + r =flic_enqueue_irqs (irq,sizeof (*irq),s390_get_kvm_flic (fs));if (r == -ENOSYS ) { use_flic = false; }
@@ -174,7 +185,7 @@ static void kvm_s390_inject_crw_mchk(S390FLICState *fs)static int kvm_s390_clear_io_flic (S390FLICState *fs,uint16_t subchannel_id,uint16_t subchannel_nr) { -KVMS390FLICState *flic =KVM_S390_FLIC (fs); +KVMS390FLICState *flic =s390_get_kvm_flic (fs);int rc;uint32_t sid = subchannel_id <<16 | subchannel_nr;struct kvm_device_attr attr = {
@@ -192,7 +203,7 @@ static int kvm_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,static int kvm_s390_modify_ais_mode (S390FLICState *fs,uint8_t isc,uint16_t mode) { -KVMS390FLICState *flic =KVM_S390_FLIC (fs); +KVMS390FLICState *flic =s390_get_kvm_flic (fs);struct kvm_s390_ais_req req = { .isc = isc, .mode = mode,
@@ -212,7 +223,7 @@ static int kvm_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc,static int kvm_s390_inject_airq (S390FLICState *fs,uint8_t type,uint8_t isc,uint8_t flags) { -KVMS390FLICState *flic =KVM_S390_FLIC (fs); +KVMS390FLICState *flic =s390_get_kvm_flic (fs);uint32_t id =css_get_adapter_id (type, isc);struct kvm_device_attr attr = { .group =KVM_DEV_FLIC_AIRQ_INJECT ,
@@ -301,7 +312,7 @@ static int kvm_s390_io_adapter_map(S390FLICState *fs, uint32_t id, .group = KVM_DEV_FLIC_ADAPTER_MODIFY, .addr = (uint64_t)&req, }; -KVMS390FLICState *flic =KVM_S390_FLIC (fs); +KVMS390FLICState *flic =s390_get_kvm_flic (fs);int r;if (!kvm_gsi_routing_enabled ()) {
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 15/29] s390x/tcg: remove SMP warning
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
We should be pretty good in shape now. Floating interrupts are working and atomic instructions should be atomic.
Message-Id: <[email protected]>
--- hw/s390x/s390-virtio-ccw.c | 4 ---- 1 file changed, 4 deletions(-)
hw/s390x/s390-virtio-ccw.c +0 -4
@@ -78,10 +78,6 @@ static void s390_init_cpus(MachineState *machine)MachineClass *mc =MACHINE_GET_CLASS (machine);int i; -if (tcg_enabled () && max_cpus >1 ) { -error_report ("WARNING: SMP support on s390x is experimental!" ); - } -/* initialize possible_cpus */ mc->possible_cpu_arch_ids (machine);
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 16/29] configure: s390x supports mttcg now
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
s390x is ready. Most likely we are missing some pieces, but it should already be in pretty good shape now.
Message-Id: <[email protected]>
--- configure | 1 + 1 file changed, 1 insertion(+)
configure +1 -0
@@ -6731,6 +6731,7 @@ case "$target_name" in echo "TARGET_ABI32=y" >> $config_target_mak ;; s390x) + mttcg=yes gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml" ;; tilegx)
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 20/29] s390x/sclp: fix event mask handling
In reply to Cornelia HuckFrom: Christian Borntraeger <[email protected]>
commit 67915de9f038 ("s390x/event-facility: variable-length event masks") switched the sclp receive/send mask. This broke the sclp lm console.
Message-Id: <[email protected]>
--- hw/s390x/event-facility.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/s390x/event-facility.c +2 -2
@@ -293,10 +293,10 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb) ef->receive_mask =be32_to_cpu (tmp_mask);/* return the SCLP's capability masks to the guest */ - tmp_mask =cpu_to_be32 (get_host_send_mask (ef)); + tmp_mask =cpu_to_be32 (get_host_receive_mask (ef));copy_mask (WEM_RECEIVE_MASK (we_mask, mask_length), (uint8_t *)&tmp_mask, mask_length,sizeof (tmp_mask)); - tmp_mask =cpu_to_be32 (get_host_receive_mask (ef)); + tmp_mask =cpu_to_be32 (get_host_send_mask (ef));copy_mask (WEM_SEND_MASK (we_mask, mask_length), (uint8_t *)&tmp_mask, mask_length,sizeof (tmp_mask));
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 21/29] s390x/tcg: wire up pci instructions
In reply to Cornelia HuckOn s390x, pci support is implemented via a set of instructions (no mmio). Unfortunately, none of them are documented in the PoP; the code is based upon the existing implementation for KVM and the Linux zpci driver.
--- target/s390x/helper.h | 9 ++++ target/s390x/insn-data.def | 13 ++++++ target/s390x/misc_helper.c | 89 +++++++++++++++++++++++++++++++++++++++ target/s390x/translate.c | 102 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 213 insertions(+)
target/s390x/helper.h +9 -0
@@ -173,4 +173,13 @@ DEF_HELPER_3(stsch, void, env, i64, i64) DEF_HELPER_2(tpi, i32, env, i64) DEF_HELPER_3(tsch, void, env, i64, i64) DEF_HELPER_2(chsc, void, env, i64) + +DEF_HELPER_2(clp, void, env, i32) +DEF_HELPER_3(pcilg, void, env, i32, i32) +DEF_HELPER_3(pcistg, void, env, i32, i32) +DEF_HELPER_4(stpcifc, void, env, i32, i64, i32) +DEF_HELPER_3(sic, void, env, i64, i64) +DEF_HELPER_3(rpcit, void, env, i32, i32) +DEF_HELPER_5(pcistb, void, env, i32, i32, i64, i32) +DEF_HELPER_4(mpcifc, void, env, i32, i64, i32)#endif
target/s390x/insn-data.def +13 -0
@@ -1068,4 +1068,17 @@ /* ??? Not listed in PoO ninth edition, but there's a linux driver that uses it: "A CHSC subchannel is usually present on LPAR only." */ C(0xb25f, CHSC, RRE, Z, 0, insn, 0, 0, chsc, 0) + +/* zPCI Instructions */ + /* None of these instructions are documented in the PoP, so this is all + based upon target/s390x/kvm.c and Linux code and likely incomplete */ + C(0xebd0, PCISTB, RSY_a, PCI, la2, 0, 0, 0, pcistb, 0) + C(0xebd1, SIC, RSY_a, AIS, r1, r3, 0, 0, sic, 0) + C(0xb9a0, CLP, RRF_c, PCI, 0, 0, 0, 0, clp, 0) + C(0xb9d0, PCISTG, RRE, PCI, 0, 0, 0, 0, pcistg, 0) + C(0xb9d2, PCILG, RRE, PCI, 0, 0, 0, 0, pcilg, 0) + C(0xb9d3, RPCIT, RRE, PCI, 0, 0, 0, 0, rpcit, 0) + C(0xe3d0, MPCIFC, RXY_a, PCI, la2, 0, 0, 0, mpcifc, 0) + C(0xe3d4, STPCIFC, RXY_a, PCI, la2, 0, 0, 0, stpcifc, 0) + #endif /* CONFIG_USER_ONLY */
target/s390x/misc_helper.c +89 -0
98 lines not on this page · raw message
target/s390x/translate.c +102 -0
114 lines not on this page · raw message
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 22/29] s390x/cpumodel: allow zpci features in qemu model
In reply to Cornelia HuckAEN and AIS can be provided unconditionally, ZPCI should be turned on manually.
With -cpu qemu,zpci=on, the guest kernel can now successfully detect virtio-pci devices under tcg.
Also fixup the order of the MSA_EXT_{3,4} flags while at it.
--- target/s390x/cpu_models.c | 6 ++++++ target/s390x/gen-features.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-)
target/s390x/cpu_models.c +6 -0
@@ -23,6 +23,7 @@#include "qapi/qmp/qbool.h" #ifndef CONFIG_USER_ONLY #include "sysemu/arch_init.h" +#include "hw/pci/pci.h" #endif #define CPUDEF_INIT (_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \
@@ -1271,6 +1272,11 @@ static void register_types(void)/* init all bitmaps from gnerated data initially */ s390_init_feat_bitmap (qemu_max_cpu_feat_init, qemu_max_cpu_feat); +#ifndef CONFIG_USER_ONLY +if (!pci_available) { +clear_bit (S390_FEAT_ZPCI , qemu_max_cpu_feat); + } +#endif for (i =0 ; i <ARRAY_SIZE (s390_cpu_defs); i++) {s390_init_feat_bitmap (s390_cpu_defs[i].base_init, s390_cpu_defs[i].base_feat);
target/s390x/gen-features.c +5 -1
@@ -572,8 +572,10 @@ static uint16_t qemu_LATEST[] = {S390_FEAT_STFLE_49 ,S390_FEAT_LOCAL_TLB_CLEARING ,S390_FEAT_INTERLOCKED_ACCESS_2 , -S390_FEAT_MSA_EXT_4 , +S390_FEAT_ADAPTER_EVENT_NOTIFICATION , +S390_FEAT_ADAPTER_INT_SUPPRESSION ,S390_FEAT_MSA_EXT_3 , + S390_FEAT_MSA_EXT_4, };/* add all new definitions before this point */
@@ -582,6 +584,8 @@ static uint16_t qemu_MAX[] = {S390_FEAT_STFLE_53 ,/* generates a dependency warning, leave it out for now */ S390_FEAT_MSA_EXT_5 , +/* only with CONFIG_PCI */ + S390_FEAT_ZPCI, };/****** END FEATURE DEFS ******/
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 23/29] s390x/cpumodel: model PTFF subfunctions for Multiple-epoch facility
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
For now, the kernel does not properly indicate configured CPU subfunctions to the guest, but simply uses the host values (as support in KVM is still missing). That's why we missed to model the PTFF subfunctions that come with Multiple-epoch facility.
Let's properly add these, along with a new feature group.
Message-Id: <[email protected]>
--- target/s390x/cpu_features.c | 5 +++++ target/s390x/cpu_features_def.h | 4 ++++ target/s390x/gen-features.c | 11 +++++++++++ target/s390x/kvm.c | 8 ++++++++ 4 files changed, 28 insertions(+)
target/s390x/cpu_features.c +5 -0
@@ -156,8 +156,12 @@ static const S390FeatDef s390_features[] = {FEAT_INIT ("ptff-qpc" ,S390_FEAT_TYPE_PTFF ,3 ,"PTFF Query Physical Clock" ),FEAT_INIT ("ptff-qui" ,S390_FEAT_TYPE_PTFF ,4 ,"PTFF Query UTC Information" ),FEAT_INIT ("ptff-qtou" ,S390_FEAT_TYPE_PTFF ,5 ,"PTFF Query TOD Offset User" ), +FEAT_INIT ("ptff-qsie" ,S390_FEAT_TYPE_PTFF ,10 ,"PTFF Query Steering Information Extended" ), +FEAT_INIT ("ptff-qtoue" ,S390_FEAT_TYPE_PTFF ,13 ,"PTFF Query TOD Offset User Extended" ),FEAT_INIT ("ptff-sto" ,S390_FEAT_TYPE_PTFF ,65 ,"PTFF Set TOD Offset" ),FEAT_INIT ("ptff-stou" ,S390_FEAT_TYPE_PTFF ,69 ,"PTFF Set TOD Offset User" ), +FEAT_INIT ("ptff-stoe" ,S390_FEAT_TYPE_PTFF ,73 ,"PTFF Set TOD Offset Extended" ), +FEAT_INIT ("ptff-stoue" ,S390_FEAT_TYPE_PTFF ,77 ,"PTFF Set TOD Offset User Extended" ),FEAT_INIT ("kmac-dea" ,S390_FEAT_TYPE_KMAC ,1 ,"KMAC DEA" ), FEAT_INIT("kmac-tdea-128", S390_FEAT_TYPE_KMAC, 2, "KMAC TDEA-128"),
@@ -445,6 +449,7 @@ static S390FeatGroupDef s390_feature_groups[] = {FEAT_GROUP_INIT ("plo" ,PLO ,"Perform-locked-operation facility" ),FEAT_GROUP_INIT ("tods" ,TOD_CLOCK_STEERING ,"Tod-clock-steering facility" ),FEAT_GROUP_INIT ("gen13ptff" ,GEN13_PTFF ,"PTFF enhancements introduced with z13" ), +FEAT_GROUP_INIT ("mepochptff" ,MULTIPLE_EPOCH_PTFF ,"PTFF enhancements introduced with Multiple-epoch facility" ),FEAT_GROUP_INIT ("msa" ,MSA ,"Message-security-assist facility" ),FEAT_GROUP_INIT ("msa1" ,MSA_EXT_1 ,"Message-security-assist-extension 1 facility" ), FEAT_GROUP_INIT("msa2", MSA_EXT_2, "Message-security-assist-extension 2 facility"),
target/s390x/cpu_features_def.h +4 -0
@@ -151,8 +151,12 @@ typedef enum {S390_FEAT_PTFF_QPT ,S390_FEAT_PTFF_QUI ,S390_FEAT_PTFF_QTOU , +S390_FEAT_PTFF_QSIE , +S390_FEAT_PTFF_QTOUE ,S390_FEAT_PTFF_STO ,S390_FEAT_PTFF_STOU , +S390_FEAT_PTFF_STOE , +S390_FEAT_PTFF_STOUE ,/* KMAC */ S390_FEAT_KMAC_DEA,
target/s390x/gen-features.c +11 -0
@@ -59,6 +59,12 @@S390_FEAT_PTFF_QTOU , \ S390_FEAT_PTFF_STOU +#define S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF \ + S390_FEAT_PTFF_QSIE, \ + S390_FEAT_PTFF_QTOUE, \ + S390_FEAT_PTFF_STOE, \ + S390_FEAT_PTFF_STOUE +#define S390_FEAT_GROUP_MSA \ S390_FEAT_MSA, \ S390_FEAT_KMAC_DEA, \
@@ -219,6 +225,9 @@ static uint16_t group_TOD_CLOCK_STEERING[] = {static uint16_t group_GEN13_PTFF[] = {S390_FEAT_GROUP_GEN13_PTFF , }; +static uint16_t group_MULTIPLE_EPOCH_PTFF[] = { +S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF , +};static uint16_t group_MSA[] = {S390_FEAT_GROUP_MSA , };
@@ -466,6 +475,7 @@ static uint16_t full_GEN14_GA1[] = {S390_FEAT_CMM_NT ,S390_FEAT_HPMA2 ,S390_FEAT_SIE_KSS , + S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF, };/* Default features (in order of release)
@@ -668,6 +678,7 @@ static FeatGroupDefSpec FeatGroupDef[] = {FEAT_GROUP_INITIALIZER (PLO ),FEAT_GROUP_INITIALIZER (TOD_CLOCK_STEERING ),FEAT_GROUP_INITIALIZER (GEN13_PTFF ), +FEAT_GROUP_INITIALIZER (MULTIPLE_EPOCH_PTFF ),FEAT_GROUP_INITIALIZER (MSA ),FEAT_GROUP_INITIALIZER (MSA_EXT_1 ), FEAT_GROUP_INITIALIZER(MSA_EXT_2),
target/s390x/kvm.c +8 -0
@@ -2221,6 +2221,14 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)return ; } +/* PTFF subfunctions might be indicated although kernel support missing */ +if (!test_bit (S390_FEAT_MULTIPLE_EPOCH , model->features)) { +clear_bit (S390_FEAT_PTFF_QSIE , model->features); +clear_bit (S390_FEAT_PTFF_QTOUE , model->features); +clear_bit (S390_FEAT_PTFF_STOE , model->features); +clear_bit (S390_FEAT_PTFF_STOUE , model->features); + } +/* with cpu model support, CMM is only indicated if really available */ if (kvm_s390_cmma_available ()) {set_bit (S390_FEAT_CMM , model->features);
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 19/29] s390x/flic: cache the common flic class in a central function
In reply to Cornelia HuckFrom: David Hildenbrand <[email protected]>
This avoids tons of conversions when handling interrupts.
Message-Id: <[email protected]>
--- hw/intc/s390_flic.c | 13 ++++++++++++- hw/s390x/css.c | 10 +++++----- hw/s390x/virtio-ccw.c | 4 ++-- include/hw/s390x/s390_flic.h | 1 + target/s390x/interrupt.c | 6 +++--- 5 files changed, 23 insertions(+), 11 deletions(-)
hw/intc/s390_flic.c +12 -1
@@ -22,6 +22,17 @@#include "qapi/error.h" #include "hw/s390x/s390-virtio-ccw.h" +S390FLICStateClass *s390_get_flic_class (S390FLICState *fs) +{ +static S390FLICStateClass *class; + +if (!class) { +/* we only have one flic device, so this is fine to cache */ + class =S390_FLIC_COMMON_GET_CLASS (fs); + } +return class; +} +QEMUS390FLICState *s390_get_qemu_flic (S390FLICState *fs) {static QEMUS390FLICState *flic;
@@ -146,7 +157,7 @@ static int qemu_s390_inject_airq(S390FLICState *fs, uint8_t type, uint8_t isc, uint8_t flags) {QEMUS390FLICState *flic =s390_get_qemu_flic (fs); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs);bool flag = flags &S390_ADAPTER_SUPPRESSIBLE ;uint32_t io_int_word = (isc <<27 ) |IO_INT_WORD_AI ;
hw/s390x/css.c +5 -5
@@ -439,7 +439,7 @@ static int s390_io_adapter_map(AdapterInfo *adapter, uint64_t map_addr, bool do_map) {S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs);return fsc->io_adapter_map (fs, adapter->adapter_id, map_addr, do_map); }
@@ -520,7 +520,7 @@ void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maskable,int ret, isc;IoAdapter *adapter;S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs);/* * Disallow multiple registrations for the same device type.
@@ -566,7 +566,7 @@ static void css_clear_io_interrupt(uint16_t subchannel_id,Error *err =NULL ;static bool no_clear_irq;S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs);int r;if (unlikely (no_clear_irq)) {
@@ -640,7 +640,7 @@ void css_conditional_io_interrupt(SubchDev *sch)int css_do_sic (CPUS390XState *env,uint8_t isc,uint16_t mode) {S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs);int r;if (env->psw.mask &PSW_MASK_PSTATE ) {
@@ -666,7 +666,7 @@ out:void css_adapter_interrupt (CssIoAdapterType type,uint8_t isc) {S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs);uint32_t io_int_word = (isc <<27 ) |IO_INT_WORD_AI ;IoAdapter *adapter = channel_subsys.io_adapters[type][isc];
hw/s390x/virtio-ccw.c +2 -2
@@ -1111,7 +1111,7 @@ static int virtio_ccw_setup_irqroutes(VirtioCcwDevice *dev, int nvqs)VirtIODevice *vdev =virtio_bus_get_device (&dev->bus);int ret;S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs); ret =virtio_ccw_get_mappings (dev);if (ret) {
@@ -1129,7 +1129,7 @@ static int virtio_ccw_setup_irqroutes(VirtioCcwDevice *dev, int nvqs)static void virtio_ccw_release_irqroutes (VirtioCcwDevice *dev,int nvqs) {S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs); fsc->release_adapter_routes (fs, &dev->routes); }
include/hw/s390x/s390_flic.h +1 -0
@@ -136,6 +136,7 @@ void s390_flic_init(void);S390FLICState *s390_get_flic (void );QEMUS390FLICState *s390_get_qemu_flic (S390FLICState *fs); +S390FLICStateClass *s390_get_flic_class (S390FLICState *fs);bool ais_needed (void *opaque);#endif /* HW_S390_FLIC_H */
target/s390x/interrupt.c +3 -3
@@ -134,7 +134,7 @@ void cpu_inject_stop(S390CPU *cpu)void s390_sclp_extint (uint32_t parm) {S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs); fsc->inject_service (fs, parm); }
@@ -143,7 +143,7 @@ void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr, uint32_t io_int_parm, uint32_t io_int_word) {S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs); fsc->inject_io (fs, subchannel_id, subchannel_nr, io_int_parm, io_int_word); }
@@ -151,7 +151,7 @@ void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,void s390_crw_mchk (void ) {S390FLICState *fs =s390_get_flic (); -S390FLICStateClass *fsc =S390_FLIC_COMMON_GET_CLASS (fs); +S390FLICStateClass *fsc =s390_get_flic_class (fs); fsc->inject_crw_mchk (fs); }
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 24/29] s390x/pci: fixup the code walking IOMMU tables
In reply to Cornelia HuckFrom: Yi Min Zhao <[email protected]>
Current s390x PCI IOMMU code is lack of flags' checking, including:
1) protection bit
2) table length
3) table offset
4) intermediate tables' invalid bit
5) format control bit
This patch introduces a new struct named S390IOTLBEntry, and makes up these missed checkings. At the same time, inform the guest with the corresponding error number when the check fails. Finally, in order to get the error number, we export s390_guest_io_table_walk().
Message-Id: <[email protected]>
--- hw/s390x/s390-pci-bus.c | 223 ++++++++++++++++++++++++++++++++++++++--------- hw/s390x/s390-pci-bus.h | 16 ++++ hw/s390x/s390-pci-inst.c | 64 ++++++-------- 3 files changed, 225 insertions(+), 78 deletions(-)
hw/s390x/s390-pci-bus.c +180 -43
@@ -309,49 +309,186 @@ static uint64_t get_st_pto(uint64_t entry) : 0; } -static uint64_t s390_guest_io_table_walk (uint64_t guest_iota, -uint64_t guest_dma_address) +static bool rt_entry_isvalid (uint64_t entry) { -uint64_t sto_a, pto_a, px_a; -uint64_t sto, pto, pte; -uint32_t rtx, sx, px; - - rtx =calc_rtx (guest_dma_address); - sx =calc_sx (guest_dma_address); - px =calc_px (guest_dma_address); - - sto_a = guest_iota + rtx *sizeof (uint64_t ); - sto =address_space_ldq (&address_space_memory, sto_a, -MEMTXATTRS_UNSPECIFIED ,NULL ); - sto =get_rt_sto (sto); -if (!sto) { - pte =0 ; +return (entry &ZPCI_TABLE_VALID_MASK ) ==ZPCI_TABLE_VALID ; +} + +static bool pt_entry_isvalid (uint64_t entry) +{ +return (entry &ZPCI_PTE_VALID_MASK ) ==ZPCI_PTE_VALID ; +} + +static bool entry_isprotected (uint64_t entry) +{ +return (entry &ZPCI_TABLE_PROT_MASK ) ==ZPCI_TABLE_PROTECTED ; +} + +/* ett is expected table type, -1 page table, 0 segment table, 1 region table */ +static uint64_t get_table_index (uint64_t iova,int8_t ett) +{ +switch (ett) { +case ZPCI_ETT_PT : +return calc_px (iova); +case ZPCI_ETT_ST : +return calc_sx (iova); +case ZPCI_ETT_RT : +return calc_rtx (iova); + } + +return -1 ; +} + +static bool entry_isvalid (uint64_t entry,int8_t ett) +{ +switch (ett) { +case ZPCI_ETT_PT : +return pt_entry_isvalid (entry); +case ZPCI_ETT_ST : +case ZPCI_ETT_RT : +return rt_entry_isvalid (entry); + } + +return false; +} + +/* Return true if address translation is done */ +static bool translate_iscomplete (uint64_t entry,int8_t ett) +{ +switch (ett) { +case 0 : +return (entry &ZPCI_TABLE_FC ) ? true : false; +case 1 : +return false; + } + +return true; +} + +static uint64_t get_frame_size (int8_t ett) +{ +switch (ett) { +case ZPCI_ETT_PT : +return 1ULL <<12 ; +case ZPCI_ETT_ST : +return 1ULL <<20 ; +case ZPCI_ETT_RT : +return 1ULL <<31 ; + } + +return 0 ; +} + +static uint64_t get_next_table_origin (uint64_t entry,int8_t ett) +{ +switch (ett) { +case ZPCI_ETT_PT : +return entry &ZPCI_PTE_ADDR_MASK ; +case ZPCI_ETT_ST : +return get_st_pto (entry); +case ZPCI_ETT_RT : +return get_rt_sto (entry); + } + +return 0 ; +} + +/** +* table_translate: do translation within one table and return the following +* table origin +* +* @entry: the entry being translated, the result is stored in this. +* @to: the address of table origin. +* @ett: expected table type, 1 region table, 0 segment table and -1 page table. +* @error: error code +*/ +static uint64_t table_translate (S390IOTLBEntry *entry,uint64_t to,int8_t ett, +uint16_t *error) +{ +uint64_t tx, te, nto =0 ; +uint16_t err =0 ; + + tx =get_table_index (entry->iova, ett); + te =address_space_ldq (&address_space_memory, to + tx *sizeof (uint64_t ), +MEMTXATTRS_UNSPECIFIED ,NULL ); + +if (!te) { + err =ERR_EVENT_INVALTE ; goto out; } - pto_a = sto + sx *sizeof (uint64_t ); - pto =address_space_ldq (&address_space_memory, pto_a, -MEMTXATTRS_UNSPECIFIED ,NULL ); - pto =get_st_pto (pto); -if (!pto) { - pte =0 ; +if (!entry_isvalid (te, ett)) { + entry->perm &=IOMMU_NONE ; goto out; } - px_a = pto + px *sizeof (uint64_t ); - pte =address_space_ldq (&address_space_memory, px_a, -MEMTXATTRS_UNSPECIFIED ,NULL ); +if (ett ==ZPCI_ETT_RT && ((te &ZPCI_TABLE_LEN_RTX ) !=ZPCI_TABLE_LEN_RTX + || te &ZPCI_TABLE_OFFSET_MASK )) { + err =ERR_EVENT_INVALTL ; + goto out; + } + nto =get_next_table_origin (te, ett); +if (!nto) { + err =ERR_EVENT_TT ; + goto out; + } + +if (entry_isprotected (te)) { + entry->perm &=IOMMU_RO ; + }else { + entry->perm &=IOMMU_RW ; + } + +if (translate_iscomplete (te, ett)) { +switch (ett) { +case ZPCI_ETT_PT : + entry->translated_addr = te &ZPCI_PTE_ADDR_MASK ; +break ; +case ZPCI_ETT_ST : + entry->translated_addr = (te &ZPCI_SFAA_MASK ) | + (entry->iova & ~ZPCI_SFAA_MASK ); +break ; + } + nto =0 ; + } out: -return pte; +if (err) { + entry->perm =IOMMU_NONE ; + *error = err; + } + entry->len =get_frame_size (ett); +return nto; +} + +uint16_t s390_guest_io_table_walk (uint64_t g_iota,hwaddr addr, +S390IOTLBEntry *entry) +{ +uint64_t to =s390_pci_get_table_origin (g_iota); +int8_t ett =1 ; +uint16_t error =0 ; + + entry->iova = addr &PAGE_MASK ; + entry->translated_addr =0 ; + entry->perm =IOMMU_RW ; + +if (entry_isprotected (g_iota)) { + entry->perm &=IOMMU_RO ; + } + +while (to) { + to =table_translate (entry, to, ett--, &error); + } + +return error; }static IOMMUTLBEntry s390_translate_iommu (IOMMUMemoryRegion *mr,hwaddr addr,IOMMUAccessFlags flag) { -uint64_t pte; -uint32_t flags;S390PCIIOMMU *iommu =container_of (mr,S390PCIIOMMU , iommu_mr); +S390IOTLBEntry entry; +uint16_t error =0 ;IOMMUTLBEntry ret = { .target_as = &address_space_memory, .iova =0 ,
@@ -374,26 +511,26 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr,DPRINTF ("iommu trans addr 0x%" PRIx64"\n" , addr);if (addr < iommu->pba || addr > iommu->pal) { -return ret; + error =ERR_EVENT_OORANGE ; + goto err; } - pte =s390_guest_io_table_walk (s390_pci_get_table_origin (iommu->g_iota), - addr); -if (!pte) { -return ret; - } + error =s390_guest_io_table_walk (iommu->g_iota, addr, &entry); - flags = pte &ZPCI_PTE_FLAG_MASK ; - ret.iova = addr; - ret.translated_addr = pte &ZPCI_PTE_ADDR_MASK ; - ret.addr_mask =0xfff ; + ret.iova = entry.iova; + ret.translated_addr = entry.translated_addr; + ret.addr_mask = entry.len -1 ; + ret.perm = entry.perm; -if (flags &ZPCI_PTE_INVALID ) { - ret.perm =IOMMU_NONE ; - }else { - ret.perm =IOMMU_RW ; +if (flag !=IOMMU_NONE && !(flag & ret.perm)) { + error =ERR_EVENT_TPROTE ; + } +err: +if (error) { + iommu->pbdev->state =ZPCI_FS_ERROR ; +s390_pci_generate_error_event (error, iommu->pbdev->fh, + iommu->pbdev->fid, addr,0 ); } -return ret; }
hw/s390x/s390-pci-bus.h +16 -0
@@ -148,6 +148,8 @@ enum ZpciIoatDtype {#define ZPCI_STE_FLAG_MASK 0x7ffULL#define ZPCI_STE_ADDR_MASK (~ZPCI_STE_FLAG_MASK) +#define ZPCI_SFAA_MASK (~((1ULL << 20) - 1)) +/* I/O Page tables */ #define ZPCI_PTE_VALID_MASK 0x400#define ZPCI_PTE_INVALID 0x400
@@ -165,10 +167,15 @@ enum ZpciIoatDtype {#define ZPCI_TABLE_INVALID 0x20#define ZPCI_TABLE_PROTECTED 0x200#define ZPCI_TABLE_UNPROTECTED 0x000 +#define ZPCI_TABLE_FC 0x400#define ZPCI_TABLE_VALID_MASK 0x20#define ZPCI_TABLE_PROT_MASK 0x200 +#define ZPCI_ETT_RT 1 +#define ZPCI_ETT_ST 0 +#define ZPCI_ETT_PT -1 +/* PCI Function States * * reserved: default; device has just been plugged or is in progress of being
@@ -253,6 +260,13 @@ typedef struct S390MsixInfo {uint32_t pba_offset; } S390MsixInfo; +typedef struct S390IOTLBEntry { +uint64_t iova; +uint64_t translated_addr; +uint64_t len; +uint64_t perm; +}S390IOTLBEntry ; +typedef struct S390PCIBusDevice S390PCIBusDevice ; typedef struct S390PCIIOMMU { Object parent_obj;
@@ -320,6 +334,8 @@ void s390_pci_iommu_enable(S390PCIIOMMU *iommu);void s390_pci_iommu_disable (S390PCIIOMMU *iommu);void s390_pci_generate_error_event (uint16_t pec,uint32_t fh,uint32_t fid,uint64_t faddr,uint32_t e); +uint16_t s390_guest_io_table_walk (uint64_t g_iota,hwaddr addr, +S390IOTLBEntry *entry);S390PCIBusDevice *s390_pci_find_dev_by_idx (S390pciState *s,uint32_t idx);S390PCIBusDevice *s390_pci_find_dev_by_fh (S390pciState *s,uint32_t fh);S390PCIBusDevice *s390_pci_find_dev_by_fid (S390pciState *s,uint32_t fid);
hw/s390x/s390-pci-inst.c +29 -35
103 lines not on this page · raw message
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 25/29] s390x/pci: fixup global refresh
In reply to Cornelia HuckFrom: Yi Min Zhao <[email protected]>
The VFIO common code doesn't provide the possibility to modify a previous mapping entry in another way than unmapping and mapping again with new properties.
To avoid -EEXIST DMA mapping error, we introduce a GHashTable to store S390IOTLBEntry instances in order to cache the mapped entries. When intercepting rpcit instruction, ignore the identical mapped entries to avoid doing map operations multiple times and do unmap and re-map operations for the case of updating the valid entries.
Message-Id: <[email protected]>
--- hw/s390x/s390-pci-bus.c | 24 +++++++++++++++------- hw/s390x/s390-pci-bus.h | 1 + hw/s390x/s390-pci-inst.c | 53 ++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 63 insertions(+), 15 deletions(-)
hw/s390x/s390-pci-bus.c +17 -7
@@ -487,7 +487,8 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr, IOMMUAccessFlags flag) {S390PCIIOMMU *iommu =container_of (mr,S390PCIIOMMU , iommu_mr); -S390IOTLBEntry entry; +S390IOTLBEntry *entry; +uint64_t iova = addr &PAGE_MASK ;uint16_t error =0 ;IOMMUTLBEntry ret = { .target_as = &address_space_memory,
@@ -515,12 +516,17 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr, goto err; } - error =s390_guest_io_table_walk (iommu->g_iota, addr, &entry); - - ret.iova = entry.iova; - ret.translated_addr = entry.translated_addr; - ret.addr_mask = entry.len -1 ; - ret.perm = entry.perm; + entry =g_hash_table_lookup (iommu->iotlb, &iova); +if (entry) { + ret.iova = entry->iova; + ret.translated_addr = entry->translated_addr; + ret.addr_mask = entry->len -1 ; + ret.perm = entry->perm; + }else { + ret.iova = iova; + ret.addr_mask = ~PAGE_MASK ; + ret.perm =IOMMU_NONE ; + }if (flag !=IOMMU_NONE && !(flag & ret.perm)) { error =ERR_EVENT_TPROTE ;
@@ -572,6 +578,8 @@ static S390PCIIOMMU *s390_pci_get_iommu(S390pciState *s, PCIBus *bus, PCI_FUNC(devfn));memory_region_init (&iommu->mr,OBJECT (iommu), mr_name,UINT64_MAX );address_space_init (&iommu->as, &iommu->mr, as_name); + iommu->iotlb =g_hash_table_new_full (g_int64_hash, g_int64_equal, +NULL , g_free); table->iommu[PCI_SLOT (devfn)] = iommu;g_free (mr_name);
@@ -661,6 +669,7 @@ void s390_pci_iommu_enable(S390PCIIOMMU *iommu)void s390_pci_iommu_disable (S390PCIIOMMU *iommu) { iommu->enabled = false; +g_hash_table_remove_all (iommu->iotlb);memory_region_del_subregion (&iommu->mr,MEMORY_REGION (&iommu->iommu_mr));object_unparent (OBJECT (&iommu->iommu_mr)); }
@@ -676,6 +685,7 @@ static void s390_pci_iommu_free(S390pciState *s, PCIBus *bus, int32_t devfn) } table->iommu[PCI_SLOT (devfn)] =NULL ; +g_hash_table_destroy (iommu->iotlb);address_space_destroy (&iommu->as);object_unparent (OBJECT (&iommu->mr));object_unparent (OBJECT (iommu));
hw/s390x/s390-pci-bus.h +1 -0
@@ -278,6 +278,7 @@ typedef struct S390PCIIOMMU {uint64_t g_iota;uint64_t pba;uint64_t pal; +GHashTable *iotlb; }S390PCIIOMMU ; typedef struct S390PCIIOMMUTable {
hw/s390x/s390-pci-inst.c +45 -8
73 lines not on this page · raw message
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 26/29] s390x/pci: use the right pal and pba in reg_ioat()
In reply to Cornelia HuckFrom: Yi Min Zhao <[email protected]>
When registering ioat, pba should be comprised of leftmost 52 bits and rightmost 12 binary zeros, and pal should be comprised of leftmost 52 bits and right most 12 binary ones. The lower 12 bits of words 5 and 7 of the FIB are ignored by the facility. Let's fixup this.
Message-Id: <[email protected]>
--- hw/s390x/s390-pci-inst.c | 2 ++ 1 file changed, 2 insertions(+)
hw/s390x/s390-pci-inst.c +2 -0
@@ -865,6 +865,8 @@ static int reg_ioat(CPUS390XState *env, S390PCIIOMMU *iommu, ZpciFib fib,uint8_t dt = (g_iota >>2 ) &0x7 ;uint8_t t = (g_iota >>11 ) &0x1 ; + pba &= ~0xfff ; + pal |=0xfff ;if (pba > pal || pba <ZPCI_SDMA_ADDR || pal >ZPCI_EDMA_ADDR ) {s390_program_interrupt (env,PGM_OPERAND ,6 , ra);return -EINVAL ;
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 27/29] MAINTAINERS: add myself as overall s390x maintainer
In reply to Cornelia HuckAll your mainframes are belong to me.
--- MAINTAINERS | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
MAINTAINERS +23 -0
@@ -76,6 +76,29 @@ K: ^Subject:.*(?i)trivial T: git git://git.corpit.ru/qemu.git trivial-patches T: git git://github.com/vivier/qemu.git trivial-patches +Architecture support +-------------------- +S390 +M: Cornelia Huck <[email protected]> +S: Supported +F: default-configs/s390x-softmmu.mak +F: gdb-xml/s390*.xml +F: hw/char/sclp*.[hc] +F: hw/char/terminal3270.c +F: hw/intc/s390_flic.c +F: hw/intc/s390_flic_kvm.c +F: hw/s390x/ +F: hw/vfio/ccw.c +F: hw/watchdog/wdt_diag288.c +F: include/hw/s390x/ +F: include/hw/watchdog/wdt_diag288.h +F: pc-bios/s390-ccw/ +F: pc-bios/s390-ccw.img +F: target/s390x/ +K: ^Subject:.*(?i)s390x? +T: git git://github.com/cohuck/qemu.git s390-next +L: [email protected] + Guest CPU cores (TCG): ---------------------- Overall
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 28/29] MAINTAINERS: reorganize s390-ccw bios maintainership
In reply to Cornelia HuckSplit it out from the s390-ccw-virtio machine, add Thomas as a maintainer in addition to Christian.
--- MAINTAINERS | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
MAINTAINERS +9 -2
@@ -855,15 +855,22 @@ F: hw/char/sclp*.[hc] F: hw/char/terminal3270.c F: hw/s390x/ F: include/hw/s390x/ -F: pc-bios/s390-ccw/ F: hw/watchdog/wdt_diag288.c F: include/hw/watchdog/wdt_diag288.h -F: pc-bios/s390-ccw.img F: default-configs/s390x-softmmu.mak T: git git://github.com/cohuck/qemu.git s390-next T: git git://github.com/borntraeger/qemu.git s390-next L: [email protected] +S390-ccw Bios +M: Christian Borntraeger <[email protected]> +M: Thomas Huth <[email protected]> +S: Supported +F: pc-bios/s390-ccw/ +F: pc-bios/s390-ccw.img +T: git git://github.com/borntraeger/qemu.git s390-next +L: [email protected] + UniCore32 Machines ------------- PKUnity-3 SoC initramfs-with-busybox
Signature · 1 line
2.13.6
[Qemu-devel] [PULL 29/29] MAINTAINERS: add David as additional tcg/s390 maintainer
In reply to Cornelia Huck--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -236,6 +236,7 @@ F: disas/ppc.c S390 M: Richard Henderson <[email protected]> M: Alexander Graf <[email protected]> +M: David Hildenbrand <[email protected]> S: Maintained F: target/s390x/ F: hw/s390x/
Signature · 1 line
2.13.6
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PULL 00/29] s390x: assorted updates
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
008a51bbb3..04bb7fe2bf master -> master
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'b1c1c1ec7c MAINTAINERS: add David as additional tcg/s390 maintainer cc5290f37c MAINTAINERS: reorganize s390-ccw bios maintainership 1c617d5185 MAINTAINERS: add myself as overall s390x maintainer a7560ae1a7 s390x/pci: use the right pal and pba in reg_ioat() bade030c15 s390x/pci: fixup global refreshc82c36e54d s390x/pci: fixup the code walking IOMMU tables bf22d638fb s390x/cpumodel: model PTFF subfunctions for Multiple-epoch facility f28d2a91cd s390x/cpumodel: allow zpci features in qemu model 34b0bd98bc s390x/tcg: wire up pci instructions13b2bbce1d s390x/sclp: fix event mask handling511c79770d s390x/flic: cache the common flic class in a central function 3cf760d263 s390x/kvm: cache the kvm flic in a central function b2a1f04b81 s390x/tcg: cache the qemu flic in a central function e531257b07 configure: s390x supports mttcg now95d36d11c2 s390x/tcg: remove SMP warning6c00754b2d s390x/tcg: STSI overhaul3f35dc9a46 s390x: fix size + content of STSI blockse71c443e52 s390x/flic: optimize CPU wakeup for TCG7d63a4ea2e s390x/flic: implement qemu_s390_clear_io_flic() f6319e6bcb s390x/tcg: implement TEST PENDING INTERRUPTION aa43e08adb s390x/flic: make floating interrupts on TCG actually floating feaf5fd238 s390x/tcg: tolerate wrong wakeups due to floating interrupts f445d494a8 s390x/flic: no need to call s390_io_interrupt() from flic d501653bf4 s390x/flic: factor out injection of floating interrupts e467b68d2f s390x/tcg: simplify machine check handling5bf66b4828 s390x/tcg: simplify lookup of flic0edc990c45 s390x/flic: simplify flic initialization1b3a2452b9 s390x/tcg: deliver multiple interrupts in a row 6c1d71e1d7 Fix configure for s390 qemu on alpine and other busybox environments
=== OUTPUT BEGIN ===
Checking PATCH 1/29: Fix configure for s390 qemu on alpine and other busybox environments... Checking PATCH 2/29: s390x/tcg: deliver multiple interrupts in a row... Checking PATCH 3/29: s390x/flic: simplify flic initialization...
Checking PATCH 4/29: s390x/tcg: simplify lookup of flic...
Checking PATCH 5/29: s390x/tcg: simplify machine check handling...
Checking PATCH 6/29: s390x/flic: factor out injection of floating interrupts... Checking PATCH 7/29: s390x/flic: no need to call s390_io_interrupt() from flic... Checking PATCH 8/29: s390x/tcg: tolerate wrong wakeups due to floating interrupts... Checking PATCH 9/29: s390x/flic: make floating interrupts on TCG actually floating... Checking PATCH 10/29: s390x/tcg: implement TEST PENDING INTERRUPTION... Checking PATCH 11/29: s390x/flic: implement qemu_s390_clear_io_flic()... Checking PATCH 12/29: s390x/flic: optimize CPU wakeup for TCG...
Checking PATCH 13/29: s390x: fix size + content of STSI blocks...
Checking PATCH 14/29: s390x/tcg: STSI overhaul...
Checking PATCH 15/29: s390x/tcg: remove SMP warning...
Checking PATCH 16/29: configure: s390x supports mttcg now...
Checking PATCH 17/29: s390x/tcg: cache the qemu flic in a central function... Checking PATCH 18/29: s390x/kvm: cache the kvm flic in a central function... Checking PATCH 19/29: s390x/flic: cache the common flic class in a central function... Checking PATCH 20/29: s390x/sclp: fix event mask handling...
Checking PATCH 21/29: s390x/tcg: wire up pci instructions...
Checking PATCH 22/29: s390x/cpumodel: allow zpci features in qemu model... Checking PATCH 23/29: s390x/cpumodel: model PTFF subfunctions for Multiple-epoch facility...
ERROR: line over 90 characters
#29: FILE: target/s390x/cpu_features.c:159:
+ FEAT_INIT("ptff-qsie", S390_FEAT_TYPE_PTFF, 10, "PTFF Query Steering Information Extended"),
ERROR: line over 90 characters
#30: FILE: target/s390x/cpu_features.c:160:
+ FEAT_INIT("ptff-qtoue", S390_FEAT_TYPE_PTFF, 13, "PTFF Query TOD Offset User Extended"),
WARNING: line over 80 characters
#33: FILE: target/s390x/cpu_features.c:163:
+ FEAT_INIT("ptff-stoe", S390_FEAT_TYPE_PTFF, 73, "PTFF Set TOD Offset Extended"),
WARNING: line over 80 characters
#34: FILE: target/s390x/cpu_features.c:164:
+ FEAT_INIT("ptff-stoue", S390_FEAT_TYPE_PTFF, 77, "PTFF Set TOD Offset User Extended"),
ERROR: line over 90 characters
#42: FILE: target/s390x/cpu_features.c:452:
+ FEAT_GROUP_INIT("mepochptff", MULTIPLE_EPOCH_PTFF, "PTFF enhancements introduced with Multiple-epoch facility"),
ERROR: Macros with complex values should be enclosed in parenthesis #71: FILE: target/s390x/gen-features.c:62:
+#define S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF \
+ S390_FEAT_PTFF_QSIE, \ + S390_FEAT_PTFF_QTOUE, \ + S390_FEAT_PTFF_STOE, \ + S390_FEAT_PTFF_STOUE
total: 4 errors, 2 warnings, 80 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 24/29: s390x/pci: fixup the code walking IOMMU tables... Checking PATCH 25/29: s390x/pci: fixup global refresh...
Checking PATCH 26/29: s390x/pci: use the right pal and pba in reg_ioat()... Checking PATCH 27/29: MAINTAINERS: add myself as overall s390x maintainer... Checking PATCH 28/29: MAINTAINERS: reorganize s390-ccw bios maintainership... Checking PATCH 29/29: MAINTAINERS: add David as additional tcg/s390 maintainer... === OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Peter Maydell
AppliedQuoted 21 lines · Cornelia Huck
The following changes since commit
008a51bbb343972dd8cf09126da8c3b87f4e1c96:Merge remote-tracking branch 'remotes/famz/tags/staging-pull-request' into staging (2018-02-08 14:31:51 +0000)
are available in the git repository at:
git://github.com/cohuck/qemutags/s390x-20180209for you to fetch changes up to
ced01bb7e5d353a9055743d68d54f3581b29328c:
MAINTAINERS: add David as additional tcg/s390 maintainer (2018-02-09 09:37:13 +0100)----------------------------------------------------------------
s390x updates:
- rework interrupt handling for tcg, smp is now considered non-experimental
- some general improvements in the flic
- improvements in the pci code, and wiring it up in tcg
- add PTFF subfunctions for multiple-epoch to the cpu model
- maintainership updates
- various other fixes and improvements
Quoted 1 line
----------------------------------------------------------------
Applied, thanks.
-- PMM