KVM: s390: some patches for kvm-next
Subsystems (4)
Gleb, Paolo,
here's a pull request for some fixes/cleanups that have accumulated on our side. As this is my first pull request via kernel.org, feel free to tell me whether I messed up :)
The following changes since commit 0a00a775d2a49d16efba721c786859844184599c:
KVM: Change maintainer email address (2013-11-27 17:56:36 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-20131128
for you to fetch changes up to 36daca9bb36f0395755817d1b0c45ab6fbf0441b:
KVM: s390: Removed kvm_s390_inject_sigp_stop() (2013-11-28 11:08:17 +0100)
----------------------------------------------------------------
Several fixes for kvm-next.
The diagnose decoding and the missing store status are more major (can cause the host to execute different things than the guest wanted resp. produce unusable dumps when something breaks). The other patches contain more minor fixes and cleanups.
----------------------------------------------------------------
Heiko Carstens (1):
KVM: s390: fix diagnose code extraction
Thomas Huth (8):
KVM: s390: Removed SIE_INTERCEPT_UCONTROL
KVM: s390: Removed VIRTIODESCSPACE
KVM: s390: Fix access to CR6 in TPI handler
KVM: s390: Do not set CC3 for EQBS and SQBS
KVM: s390: Always store status during SIGP STOP_AND_STORE_STATUS
KVM: s390: Fix clock comparator field for STORE STATUS
KVM: s390: Add SIGP store-status-at-address order
KVM: s390: Removed kvm_s390_inject_sigp_stop()
arch/s390/kvm/diag.c | 2 +- arch/s390/kvm/kvm-s390.c | 53 ++++++++++++++++++++----------------------- arch/s390/kvm/kvm-s390.h | 10 ++------- arch/s390/kvm/priv.c | 4 +--- arch/s390/kvm/sigp.c | 56 ++++++++++++++++++++++++++++++++++++++++------ arch/s390/kvm/trace.h | 1 + 6 files changed, 78 insertions(+), 48 deletions(-)
Signature · 1 line
1.7.9.5
[PULL 1/9] KVM: s390: Removed SIE_INTERCEPT_UCONTROL
From: Thomas Huth <[email protected]>
The SIE_INTERCEPT_UCONTROL can be removed by moving the related code from kvm_arch_vcpu_ioctl_run() to vcpu_post_run().
--- arch/s390/kvm/kvm-s390.c | 24 ++++++------------------ arch/s390/kvm/kvm-s390.h | 2 -- 2 files changed, 6 insertions(+), 20 deletions(-)
arch/s390/kvm/kvm-s390.c +6 -18
@@ -732,14 +732,12 @@ static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason)if (exit_reason >=0 ) { rc =0 ; - }else { -if (kvm_is_ucontrol (vcpu->kvm)) { - rc =SIE_INTERCEPT_UCONTROL ; - }else { -VCPU_EVENT (vcpu,3 ,"%s" ,"fault in sie instruction" ); -trace_kvm_s390_sie_fault (vcpu); - rc =kvm_s390_inject_program_int (vcpu,PGM_ADDRESSING ); - } + }else if (kvm_is_ucontrol (vcpu->kvm)) { + vcpu->run->exit_reason =KVM_EXIT_S390_UCONTROL ; + vcpu->run->s390_ucontrol.trans_exc_code = + current->thread.gmap_addr; + vcpu->run->s390_ucontrol.pgm_code =0x10 ; + rc = -EREMOTE ; }memcpy (&vcpu->run->s.regs.gprs[14 ], &vcpu->arch.sie_block->gg14,16 );
@@ -833,16 +831,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) rc = -EINTR ; } -#ifdef CONFIG_KVM_S390_UCONTROL -if (rc ==SIE_INTERCEPT_UCONTROL ) { - kvm_run->exit_reason =KVM_EXIT_S390_UCONTROL ; - kvm_run->s390_ucontrol.trans_exc_code = - current->thread.gmap_addr; - kvm_run->s390_ucontrol.pgm_code =0x10 ; - rc =0 ; - } -#endif -if (rc == -EOPNOTSUPP ) {/* intercept cannot be handled in-kernel, prepare kvm-run */ kvm_run->exit_reason =KVM_EXIT_S390_SIEIC ;
arch/s390/kvm/kvm-s390.h +0 -2
@@ -27,8 +27,6 @@ typedef int (*intercept_handler_t)(struct kvm_vcpu *vcpu);/* declare vfacilities extern */ extern unsigned long *vfacilities; -/* negativ values are error codes, positive values for internal conditions */ -#define SIE_INTERCEPT_UCONTROL (1<<0)int kvm_handle_sie_intercept (struct kvm_vcpu *vcpu); #define VM_EVENT(d_kvm, d_loglevel, d_string, d_args...)\
Signature · 1 line
1.7.9.5
[PULL 2/9] KVM: s390: Removed VIRTIODESCSPACE
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
VIRTIODESCSPACE is completely unused nowadays and thus can be removed without any problems.
--- arch/s390/kvm/kvm-s390.h | 3 --- 1 file changed, 3 deletions(-)
arch/s390/kvm/kvm-s390.h +0 -3
@@ -19,9 +19,6 @@#include <linux/kvm.h> #include <linux/kvm_host.h> -/* The current code can have up to 256 pages for virtio */ -#define VIRTIODESCSPACE (256ul * 4096ul) -typedef int (*intercept_handler_t )(struct kvm_vcpu *vcpu);/* declare vfacilities extern */
Signature · 1 line
1.7.9.5
[PULL 3/9] KVM: s390: Fix access to CR6 in TPI handler
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
The TPI handler currently uses vcpu->run->s.regs.crs[6] to get the current value of CR6. I think this is wrong, because vcpu->run->s.regs.crs is only updated when kvm_arch_vcpu_ioctl_run() drops back to userspace. So let's change the TPI handler to use vcpu->arch.sie_block->gcr[6] instead.
--- arch/s390/kvm/priv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/priv.c +1 -1
@@ -197,7 +197,7 @@ static int handle_tpi(struct kvm_vcpu *vcpu)if (addr &3 )return kvm_s390_inject_program_int (vcpu,PGM_SPECIFICATION ); cc =0 ; - inti =kvm_s390_get_io_int (vcpu->kvm, vcpu->run->s.regs.crs[6 ],0 ); + inti =kvm_s390_get_io_int (vcpu->kvm, vcpu->arch.sie_block->gcr[6 ],0 );if (!inti) goto no_interrupt; cc =1 ;
Signature · 1 line
1.7.9.5
[PULL 4/9] KVM: s390: Do not set CC3 for EQBS and SQBS
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
The EQBS and SQBS instructions do not set CC3 for invalid channels, but should throw an operation exception instead when not available. Thus they should not be handled by the handle_io_inst() wrapper but drop to userspace instead (which will then inject the operation exception).
--- arch/s390/kvm/priv.c | 2 -- 1 file changed, 2 deletions(-)
arch/s390/kvm/priv.c +0 -2
@@ -638,7 +638,6 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)static const intercept_handler_t b9_handlers[256 ] = { [0x8d ] = handle_epsw, - [0x9c ] = handle_io_inst, [0xaf ] = handle_pfmf, };
@@ -731,7 +730,6 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)static const intercept_handler_t eb_handlers[256 ] = { [0x2f ] = handle_lctlg, - [0x8a ] = handle_io_inst, };int kvm_s390_handle_eb (struct kvm_vcpu *vcpu)
Signature · 1 line
1.7.9.5
[PULL 5/9] KVM: s390: Always store status during SIGP STOP_AND_STORE_STATUS
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
The SIGP order STOP_AND_STORE_STATUS is defined to stop a CPU and store its status. However, we only stored the status if the CPU was still running, so make sure that the status is now also stored if the CPU was already stopped. This fixes the problem that the CPU information was not stored correctly in kdump files, rendering them unreadable.
--- arch/s390/kvm/kvm-s390.c | 25 +++++++++++++++---------- arch/s390/kvm/kvm-s390.h | 4 ++-- arch/s390/kvm/sigp.c | 15 ++++++++++++++- 3 files changed, 31 insertions(+), 13 deletions(-)
arch/s390/kvm/kvm-s390.c +15 -10
@@ -873,7 +873,7 @@ static int __guestcopy(struct kvm_vcpu *vcpu, u64 guestdest, void *from,* KVM_S390_STORE_STATUS_NOADDR: -> 0x1200 on 64 bit * KVM_S390_STORE_STATUS_PREFIXED: -> prefix */ -int kvm_s390_vcpu_store_status (struct kvm_vcpu *vcpu,unsigned long addr) +int kvm_s390_store_status_unloaded (struct kvm_vcpu *vcpu,unsigned long addr) {unsigned char archmode =1 ;int prefix;
@@ -891,15 +891,6 @@ int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr) }else prefix =0 ; -/* -* The guest FPRS and ACRS are in the host FPRS/ACRS due to the lazy -* copying in vcpu load/put. Lets update our copies before we save -* it into the save area -*/ -save_fp_ctl (&vcpu->arch.guest_fpregs.fpc); -save_fp_regs (vcpu->arch.guest_fpregs.fprs); -save_access_regs (vcpu->run->s.regs.acrs); -if (__guestcopy (vcpu, addr + offsetof(struct save_area , fp_regs), vcpu->arch.guest_fpregs.fprs,128 , prefix))return -EFAULT ;
@@ -944,6 +935,20 @@ int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)return 0 ; } +int kvm_s390_vcpu_store_status (struct kvm_vcpu *vcpu,unsigned long addr) +{ +/* +* The guest FPRS and ACRS are in the host FPRS/ACRS due to the lazy +* copying in vcpu load/put. Lets update our copies before we save +* it into the save area +*/ +save_fp_ctl (&vcpu->arch.guest_fpregs.fpc); +save_fp_regs (vcpu->arch.guest_fpregs.fprs); +save_access_regs (vcpu->run->s.regs.acrs); + +return kvm_s390_store_status_unloaded (vcpu, addr); +} +static int kvm_vcpu_ioctl_enable_cap (struct kvm_vcpu *vcpu,struct kvm_enable_cap *cap) {
arch/s390/kvm/kvm-s390.h +2 -2
@@ -145,8 +145,8 @@ int kvm_s390_handle_eb(struct kvm_vcpu *vcpu);int kvm_s390_handle_sigp (struct kvm_vcpu *vcpu);/* implemented in kvm-s390.c */ -int kvm_s390_vcpu_store_status (struct kvm_vcpu *vcpu, -unsigned long addr); +int kvm_s390_store_status_unloaded (struct kvm_vcpu *vcpu,unsigned long addr); +int kvm_s390_vcpu_store_status (struct kvm_vcpu *vcpu,unsigned long addr);void s390_vcpu_block (struct kvm_vcpu *vcpu);void s390_vcpu_unblock (struct kvm_vcpu *vcpu);void exit_sie (struct kvm_vcpu *vcpu);
arch/s390/kvm/sigp.c +14 -1
@@ -130,6 +130,7 @@ unlock:static int __inject_sigp_stop (struct kvm_s390_local_interrupt *li,int action) {struct kvm_s390_interrupt_info *inti; +int rc =SIGP_CC_ORDER_CODE_ACCEPTED ; inti =kzalloc (sizeof (*inti),GFP_ATOMIC );if (!inti)
@@ -139,6 +140,8 @@ static int __inject_sigp_stop(struct kvm_s390_local_interrupt *li, int action)spin_lock_bh (&li->lock);if ((atomic_read (li->cpuflags) &CPUSTAT_STOPPED )) {kfree (inti); +if ((action &ACTION_STORE_ON_STOP ) !=0 ) + rc = -ESHUTDOWN ; goto out; }list_add_tail (&inti->list, &li->list);
@@ -150,7 +153,7 @@ static int __inject_sigp_stop(struct kvm_s390_local_interrupt *li, int action) out:spin_unlock_bh (&li->lock); -return SIGP_CC_ORDER_CODE_ACCEPTED ; +return rc; }static int __sigp_stop (struct kvm_vcpu *vcpu,u16 cpu_addr,int action)
@@ -174,6 +177,16 @@ static int __sigp_stop(struct kvm_vcpu *vcpu, u16 cpu_addr, int action) unlock:spin_unlock (&fi->lock);VCPU_EVENT (vcpu,4 ,"sent sigp stop to cpu %x" , cpu_addr); + +if ((action &ACTION_STORE_ON_STOP ) !=0 && rc == -ESHUTDOWN ) { +/* If the CPU has already been stopped, we still have +* to save the status when doing stop-and-store. This +* has to be done after unlocking all spinlocks. */ +struct kvm_vcpu *dst_vcpu =kvm_get_vcpu (vcpu->kvm, cpu_addr); + rc =kvm_s390_store_status_unloaded (dst_vcpu, +KVM_S390_STORE_STATUS_NOADDR ); + } +return rc; }
Signature · 1 line
1.7.9.5
[PULL 6/9] KVM: s390: Fix clock comparator field for STORE STATUS
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
Only the most 7 significant bytes of the clock comparator must be saved to the status area, and the byte at offset 304 has to be zero.
--- arch/s390/kvm/kvm-s390.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kvm/kvm-s390.c +3 -1
@@ -877,6 +877,7 @@ int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr) {unsigned char archmode =1 ;int prefix; +u64 clkcomp;if (addr ==KVM_S390_STORE_STATUS_NOADDR ) {if (copy_to_guest_absolute (vcpu,163ul , &archmode,1 ))
@@ -920,8 +921,9 @@ int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr) &vcpu->arch.sie_block->cputm, 8, prefix))return -EFAULT ; + clkcomp = vcpu->arch.sie_block->ckc >>8 ;if (__guestcopy (vcpu, addr + offsetof(struct save_area , clk_cmp), - &vcpu->arch.sie_block->ckc,8 , prefix)) + &clkcomp,8 , prefix))return -EFAULT ; if (__guestcopy(vcpu, addr + offsetof(struct save_area, acc_regs),
Signature · 1 line
1.7.9.5
[PULL 7/9] KVM: s390: fix diagnose code extraction
In reply to Cornelia HuckFrom: Heiko Carstens <[email protected]>
The diagnose code to be used is the contents of the base register (if not zero), plus the displacement. The current code ignores the base register contents. So let's fix that...
--- arch/s390/kvm/diag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/diag.c +1 -1
@@ -137,7 +137,7 @@ static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu)int kvm_s390_handle_diag (struct kvm_vcpu *vcpu) { -int code = (vcpu->arch.sie_block->ipb &0xfff0000 ) >>16 ; +int code =kvm_s390_get_base_disp_rs (vcpu) &0xffff ;if (vcpu->arch.sie_block->gpsw.mask &PSW_MASK_PSTATE )return kvm_s390_inject_program_int (vcpu,PGM_PRIVILEGED_OP );
Signature · 1 line
1.7.9.5
[PULL 8/9] KVM: s390: Add SIGP store-status-at-address order
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
The STORE STATUS AT ADDRESS order of SIGP was still missing. Now it is supported, using the common kvm_s390_store_status() function.
--- arch/s390/kvm/sigp.c | 35 +++++++++++++++++++++++++++++++++++ arch/s390/kvm/trace.h | 1 + 2 files changed, 36 insertions(+)
arch/s390/kvm/sigp.c +35 -0
@@ -275,6 +275,37 @@ out_fi:return rc; } +static int __sigp_store_status_at_addr (struct kvm_vcpu *vcpu,u16 cpu_id, +u32 addr,u64 *reg) +{ +struct kvm_vcpu *dst_vcpu =NULL ; +int flags; +int rc; + +if (cpu_id <KVM_MAX_VCPUS ) + dst_vcpu =kvm_get_vcpu (vcpu->kvm, cpu_id); +if (!dst_vcpu) +return SIGP_CC_NOT_OPERATIONAL ; + +spin_lock_bh (&dst_vcpu->arch.local_int.lock); + flags =atomic_read (dst_vcpu->arch.local_int.cpuflags); +spin_unlock_bh (&dst_vcpu->arch.local_int.lock); +if (!(flags &CPUSTAT_STOPPED )) { + *reg &=0xffffffff00000000UL ; + *reg |=SIGP_STATUS_INCORRECT_STATE ; +return SIGP_CC_STATUS_STORED ; + } + + addr &=0x7ffffe00 ; + rc =kvm_s390_store_status_unloaded (dst_vcpu, addr); +if (rc == -EFAULT ) { + *reg &=0xffffffff00000000UL ; + *reg |=SIGP_STATUS_INVALID_PARAMETER ; + rc =SIGP_CC_STATUS_STORED ; + } +return rc; +} +static int __sigp_sense_running (struct kvm_vcpu *vcpu,u16 cpu_addr,u64 *reg) {
@@ -379,6 +410,10 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu) rc =__sigp_stop (vcpu, cpu_addr,ACTION_STORE_ON_STOP |ACTION_STOP_ON_STOP );break ; +case SIGP_STORE_STATUS_AT_ADDRESS : + rc =__sigp_store_status_at_addr (vcpu, cpu_addr, parameter, + &vcpu->run->s.regs.gprs[r1]); +break ;case SIGP_SET_ARCHITECTURE : vcpu->stat.instruction_sigp_arch++; rc =__sigp_set_arch (vcpu, parameter);
arch/s390/kvm/trace.h +1 -0
@@ -175,6 +175,7 @@ TRACE_EVENT(kvm_s390_intercept_validity, {SIGP_STOP_AND_STORE_STATUS, "stop and store status"}, \ {SIGP_SET_ARCHITECTURE, "set architecture"}, \ {SIGP_SET_PREFIX, "set prefix"}, \ + {SIGP_STORE_STATUS_AT_ADDRESS, "store status at addr"}, \ {SIGP_SENSE_RUNNING, "sense running"}, \ {SIGP_RESTART, "restart"}
Signature · 1 line
1.7.9.5
[PULL 9/9] KVM: s390: Removed kvm_s390_inject_sigp_stop()
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
The function kvm_s390_inject_sigp_stop() as been unused since the removal of the old mmu reload code and thus can be removed safely.
--- arch/s390/kvm/kvm-s390.h | 1 - arch/s390/kvm/sigp.c | 6 ------ 2 files changed, 7 deletions(-)
arch/s390/kvm/kvm-s390.h +0 -1
@@ -128,7 +128,6 @@ int __must_check kvm_s390_inject_vm(struct kvm *kvm,int __must_check kvm_s390_inject_vcpu (struct kvm_vcpu *vcpu,struct kvm_s390_interrupt *s390int);int __must_check kvm_s390_inject_program_int (struct kvm_vcpu *vcpu,u16 code); -int __must_check kvm_s390_inject_sigp_stop (struct kvm_vcpu *vcpu,int action);struct kvm_s390_interrupt_info *kvm_s390_get_io_int (struct kvm *kvm,u64 cr6,u64 schid);
arch/s390/kvm/sigp.c +0 -6
@@ -190,12 +190,6 @@ unlock:return rc; } -int kvm_s390_inject_sigp_stop (struct kvm_vcpu *vcpu,int action) -{ -struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; -return __inject_sigp_stop (li, action); -} -static int __sigp_set_arch (struct kvm_vcpu *vcpu,u32 parameter) {int rc;
Signature · 1 line
1.7.9.5
Paolo Bonzini
maintainerIl 28/11/2013 15:06, Cornelia Huck ha scritto:
Quoted 41 lines
Gleb, Paolo,
here's a pull request for some fixes/cleanups that have accumulated on our side. As this is my first pull request via kernel.org, feel free to tell me whether I messed up :)
The following changes since commit
0a00a775d2a49d16efba721c786859844184599c:KVM: Change maintainer email address (2013-11-27 17:56:36 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.gittags/kvm-s390-20131128for you to fetch changes up to
36daca9bb36f0395755817d1b0c45ab6fbf0441b:KVM: s390: Removed
kvm_s390_inject_sigp_stop()(2013-11-28 11:08:17 +0100)----------------------------------------------------------------
Several fixes for kvm-next.The diagnose decoding and the missing store status are more major (can cause the host to execute different things than the guest wanted resp. produce unusable dumps when something breaks). The other patches contain more minor fixes and cleanups.
----------------------------------------------------------------
Heiko Carstens (1):
KVM: s390: fix diagnose code extractionThomas Huth (8):
KVM: s390: RemovedSIE_INTERCEPT_UCONTROL
KVM: s390: Removed VIRTIODESCSPACE
KVM: s390: Fix access to CR6 in TPI handler
KVM: s390: Do not set CC3 for EQBS and SQBS
KVM: s390: Always store status during SIGPSTOP_AND_STORE_STATUS
KVM: s390: Fix clock comparator field for STORE STATUS
KVM: s390: Add SIGP store-status-at-address order
KVM: s390: Removedkvm_s390_inject_sigp_stop()
Quoted 8 lines
arch/s390/kvm/diag.c | 2 +- arch/s390/kvm/kvm-s390.c | 53 ++++++++++++++++++++----------------------- arch/s390/kvm/kvm-s390.h | 10 ++------- arch/s390/kvm/priv.c | 4 +--- arch/s390/kvm/sigp.c | 56 ++++++++++++++++++++++++++++++++++++++++------ arch/s390/kvm/trace.h | 1 + 6 files changed, 78 insertions(+), 48 deletions(-)
Pulled, thanks.
Paolo