|
|
@ -16,6 +16,7 @@
|
|
|
|
#include <linux/mmu_context.h>
|
|
|
|
#include <linux/mmu_context.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
|
|
|
#include <linux/bitmap.h>
|
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include "kvm-s390.h"
|
|
|
|
#include "kvm-s390.h"
|
|
|
@ -136,6 +137,31 @@ static int __must_check __interrupt_is_deliverable(struct kvm_vcpu *vcpu,
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static inline unsigned long pending_local_irqs(struct kvm_vcpu *vcpu)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return vcpu->arch.local_int.pending_irqs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned long deliverable_local_irqs(struct kvm_vcpu *vcpu)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
unsigned long active_mask = pending_local_irqs(vcpu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (psw_extint_disabled(vcpu))
|
|
|
|
|
|
|
|
active_mask &= ~IRQ_PEND_EXT_MASK;
|
|
|
|
|
|
|
|
if (!(vcpu->arch.sie_block->gcr[0] & 0x2000ul))
|
|
|
|
|
|
|
|
__clear_bit(IRQ_PEND_EXT_EXTERNAL, &active_mask);
|
|
|
|
|
|
|
|
if (!(vcpu->arch.sie_block->gcr[0] & 0x4000ul))
|
|
|
|
|
|
|
|
__clear_bit(IRQ_PEND_EXT_EMERGENCY, &active_mask);
|
|
|
|
|
|
|
|
if (!(vcpu->arch.sie_block->gcr[0] & 0x800ul))
|
|
|
|
|
|
|
|
__clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &active_mask);
|
|
|
|
|
|
|
|
if (!(vcpu->arch.sie_block->gcr[0] & 0x400ul))
|
|
|
|
|
|
|
|
__clear_bit(IRQ_PEND_EXT_CPU_TIMER, &active_mask);
|
|
|
|
|
|
|
|
if (psw_mchk_disabled(vcpu))
|
|
|
|
|
|
|
|
active_mask &= ~IRQ_PEND_MCHK_MASK;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return active_mask;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void __set_cpu_idle(struct kvm_vcpu *vcpu)
|
|
|
|
static void __set_cpu_idle(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
atomic_set_mask(CPUSTAT_WAIT, &vcpu->arch.sie_block->cpuflags);
|
|
|
|
atomic_set_mask(CPUSTAT_WAIT, &vcpu->arch.sie_block->cpuflags);
|
|
|
@ -170,26 +196,45 @@ static void __set_cpuflag(struct kvm_vcpu *vcpu, u32 flag)
|
|
|
|
atomic_set_mask(flag, &vcpu->arch.sie_block->cpuflags);
|
|
|
|
atomic_set_mask(flag, &vcpu->arch.sie_block->cpuflags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void set_intercept_indicators_ext(struct kvm_vcpu *vcpu)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!(pending_local_irqs(vcpu) & IRQ_PEND_EXT_MASK))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (psw_extint_disabled(vcpu))
|
|
|
|
|
|
|
|
__set_cpuflag(vcpu, CPUSTAT_EXT_INT);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
vcpu->arch.sie_block->lctl |= LCTL_CR0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void set_intercept_indicators_mchk(struct kvm_vcpu *vcpu)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!(pending_local_irqs(vcpu) & IRQ_PEND_MCHK_MASK))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (psw_mchk_disabled(vcpu))
|
|
|
|
|
|
|
|
vcpu->arch.sie_block->ictl |= ICTL_LPSW;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
vcpu->arch.sie_block->lctl |= LCTL_CR14;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set interception request for non-deliverable local interrupts */
|
|
|
|
|
|
|
|
static void set_intercept_indicators_local(struct kvm_vcpu *vcpu)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
set_intercept_indicators_ext(vcpu);
|
|
|
|
|
|
|
|
set_intercept_indicators_mchk(vcpu);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void __set_intercept_indicator(struct kvm_vcpu *vcpu,
|
|
|
|
static void __set_intercept_indicator(struct kvm_vcpu *vcpu,
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (inti->type) {
|
|
|
|
switch (inti->type) {
|
|
|
|
case KVM_S390_INT_EXTERNAL_CALL:
|
|
|
|
|
|
|
|
case KVM_S390_INT_EMERGENCY:
|
|
|
|
|
|
|
|
case KVM_S390_INT_SERVICE:
|
|
|
|
case KVM_S390_INT_SERVICE:
|
|
|
|
case KVM_S390_INT_PFAULT_INIT:
|
|
|
|
|
|
|
|
case KVM_S390_INT_PFAULT_DONE:
|
|
|
|
case KVM_S390_INT_PFAULT_DONE:
|
|
|
|
case KVM_S390_INT_VIRTIO:
|
|
|
|
case KVM_S390_INT_VIRTIO:
|
|
|
|
case KVM_S390_INT_CLOCK_COMP:
|
|
|
|
|
|
|
|
case KVM_S390_INT_CPU_TIMER:
|
|
|
|
|
|
|
|
if (psw_extint_disabled(vcpu))
|
|
|
|
if (psw_extint_disabled(vcpu))
|
|
|
|
__set_cpuflag(vcpu, CPUSTAT_EXT_INT);
|
|
|
|
__set_cpuflag(vcpu, CPUSTAT_EXT_INT);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
vcpu->arch.sie_block->lctl |= LCTL_CR0;
|
|
|
|
vcpu->arch.sie_block->lctl |= LCTL_CR0;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_SIGP_STOP:
|
|
|
|
|
|
|
|
__set_cpuflag(vcpu, CPUSTAT_STOP_INT);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_MCHK:
|
|
|
|
case KVM_S390_MCHK:
|
|
|
|
if (psw_mchk_disabled(vcpu))
|
|
|
|
if (psw_mchk_disabled(vcpu))
|
|
|
|
vcpu->arch.sie_block->ictl |= ICTL_LPSW;
|
|
|
|
vcpu->arch.sie_block->ictl |= ICTL_LPSW;
|
|
|
@ -228,6 +273,7 @@ static u16 get_ilc(struct kvm_vcpu *vcpu)
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_cpu_timer(struct kvm_vcpu *vcpu)
|
|
|
|
static int __must_check __deliver_cpu_timer(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CPU_TIMER,
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CPU_TIMER,
|
|
|
@ -239,11 +285,13 @@ static int __must_check __deliver_cpu_timer(struct kvm_vcpu *vcpu)
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW,
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW,
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs);
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_ckc(struct kvm_vcpu *vcpu)
|
|
|
|
static int __must_check __deliver_ckc(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CLOCK_COMP,
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CLOCK_COMP,
|
|
|
@ -255,20 +303,27 @@ static int __must_check __deliver_ckc(struct kvm_vcpu *vcpu)
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW,
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW,
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs);
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_pfault_init(struct kvm_vcpu *vcpu,
|
|
|
|
static int __must_check __deliver_pfault_init(struct kvm_vcpu *vcpu)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_ext_info *ext = &inti->ext;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_ext_info ext;
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
ext = li->irq.ext;
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_PFAULT_INIT, &li->pending_irqs);
|
|
|
|
|
|
|
|
li->irq.ext.ext_params2 = 0;
|
|
|
|
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 4, "interrupt: pfault init parm:%x,parm64:%llx",
|
|
|
|
VCPU_EVENT(vcpu, 4, "interrupt: pfault init parm:%x,parm64:%llx",
|
|
|
|
0, ext->ext_params2);
|
|
|
|
0, ext.ext_params2);
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
|
|
|
|
KVM_S390_INT_PFAULT_INIT,
|
|
|
|
KVM_S390_INT_PFAULT_INIT,
|
|
|
|
0, ext->ext_params2);
|
|
|
|
0, ext.ext_params2);
|
|
|
|
|
|
|
|
|
|
|
|
rc = put_guest_lc(vcpu, EXT_IRQ_CP_SERVICE, (u16 *) __LC_EXT_INT_CODE);
|
|
|
|
rc = put_guest_lc(vcpu, EXT_IRQ_CP_SERVICE, (u16 *) __LC_EXT_INT_CODE);
|
|
|
|
rc |= put_guest_lc(vcpu, PFAULT_INIT, (u16 *) __LC_EXT_CPU_ADDR);
|
|
|
|
rc |= put_guest_lc(vcpu, PFAULT_INIT, (u16 *) __LC_EXT_CPU_ADDR);
|
|
|
@ -276,28 +331,40 @@ static int __must_check __deliver_pfault_init(struct kvm_vcpu *vcpu,
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW,
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW,
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
rc |= put_guest_lc(vcpu, ext->ext_params2, (u64 *) __LC_EXT_PARAMS2);
|
|
|
|
rc |= put_guest_lc(vcpu, ext.ext_params2, (u64 *) __LC_EXT_PARAMS2);
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_machine_check(struct kvm_vcpu *vcpu,
|
|
|
|
static int __must_check __deliver_machine_check(struct kvm_vcpu *vcpu)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_mchk_info *mchk = &inti->mchk;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_mchk_info mchk;
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
mchk = li->irq.mchk;
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* If there was an exigent machine check pending, then any repressible
|
|
|
|
|
|
|
|
* machine checks that might have been pending are indicated along
|
|
|
|
|
|
|
|
* with it, so always clear both bits
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_MCHK_EX, &li->pending_irqs);
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_MCHK_REP, &li->pending_irqs);
|
|
|
|
|
|
|
|
memset(&li->irq.mchk, 0, sizeof(mchk));
|
|
|
|
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 4, "interrupt: machine check mcic=%llx",
|
|
|
|
VCPU_EVENT(vcpu, 4, "interrupt: machine check mcic=%llx",
|
|
|
|
mchk->mcic);
|
|
|
|
mchk.mcic);
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_MCHK,
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_MCHK,
|
|
|
|
mchk->cr14, mchk->mcic);
|
|
|
|
mchk.cr14, mchk.mcic);
|
|
|
|
|
|
|
|
|
|
|
|
rc = kvm_s390_vcpu_store_status(vcpu, KVM_S390_STORE_STATUS_PREFIXED);
|
|
|
|
rc = kvm_s390_vcpu_store_status(vcpu, KVM_S390_STORE_STATUS_PREFIXED);
|
|
|
|
rc |= put_guest_lc(vcpu, mchk->mcic,
|
|
|
|
rc |= put_guest_lc(vcpu, mchk.mcic,
|
|
|
|
(u64 __user *) __LC_MCCK_CODE);
|
|
|
|
(u64 __user *) __LC_MCCK_CODE);
|
|
|
|
rc |= put_guest_lc(vcpu, mchk->failing_storage_address,
|
|
|
|
rc |= put_guest_lc(vcpu, mchk.failing_storage_address,
|
|
|
|
(u64 __user *) __LC_MCCK_FAIL_STOR_ADDR);
|
|
|
|
(u64 __user *) __LC_MCCK_FAIL_STOR_ADDR);
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_PSW_SAVE_AREA,
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_PSW_SAVE_AREA,
|
|
|
|
&mchk->fixed_logout, sizeof(mchk->fixed_logout));
|
|
|
|
&mchk.fixed_logout, sizeof(mchk.fixed_logout));
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_MCK_OLD_PSW,
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_MCK_OLD_PSW,
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_MCK_NEW_PSW,
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_MCK_NEW_PSW,
|
|
|
@ -307,6 +374,7 @@ static int __must_check __deliver_machine_check(struct kvm_vcpu *vcpu,
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_restart(struct kvm_vcpu *vcpu)
|
|
|
|
static int __must_check __deliver_restart(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 4, "%s", "interrupt: cpu restart");
|
|
|
|
VCPU_EVENT(vcpu, 4, "%s", "interrupt: cpu restart");
|
|
|
@ -318,6 +386,7 @@ static int __must_check __deliver_restart(struct kvm_vcpu *vcpu)
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
rc |= read_guest_lc(vcpu, offsetof(struct _lowcore, restart_psw),
|
|
|
|
rc |= read_guest_lc(vcpu, offsetof(struct _lowcore, restart_psw),
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_RESTART, &li->pending_irqs);
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -329,38 +398,52 @@ static int __must_check __deliver_stop(struct kvm_vcpu *vcpu)
|
|
|
|
0, 0);
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
__set_cpuflag(vcpu, CPUSTAT_STOP_INT);
|
|
|
|
__set_cpuflag(vcpu, CPUSTAT_STOP_INT);
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_SIGP_STOP, &vcpu->arch.local_int.pending_irqs);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_set_prefix(struct kvm_vcpu *vcpu,
|
|
|
|
static int __must_check __deliver_set_prefix(struct kvm_vcpu *vcpu)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_prefix_info *prefix = &inti->prefix;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_prefix_info prefix;
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 4, "interrupt: set prefix to %x", prefix->address);
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
prefix = li->irq.prefix;
|
|
|
|
|
|
|
|
li->irq.prefix.address = 0;
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_SET_PREFIX, &li->pending_irqs);
|
|
|
|
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 4, "interrupt: set prefix to %x", prefix.address);
|
|
|
|
vcpu->stat.deliver_prefix_signal++;
|
|
|
|
vcpu->stat.deliver_prefix_signal++;
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
|
|
|
|
KVM_S390_SIGP_SET_PREFIX,
|
|
|
|
KVM_S390_SIGP_SET_PREFIX,
|
|
|
|
prefix->address, 0);
|
|
|
|
prefix.address, 0);
|
|
|
|
|
|
|
|
|
|
|
|
kvm_s390_set_prefix(vcpu, prefix->address);
|
|
|
|
kvm_s390_set_prefix(vcpu, prefix.address);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_emergency_signal(struct kvm_vcpu *vcpu,
|
|
|
|
static int __must_check __deliver_emergency_signal(struct kvm_vcpu *vcpu)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_emerg_info *emerg = &inti->emerg;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
int cpu_addr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
cpu_addr = find_first_bit(li->sigp_emerg_pending, KVM_MAX_VCPUS);
|
|
|
|
|
|
|
|
clear_bit(cpu_addr, li->sigp_emerg_pending);
|
|
|
|
|
|
|
|
if (bitmap_empty(li->sigp_emerg_pending, KVM_MAX_VCPUS))
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_EXT_EMERGENCY, &li->pending_irqs);
|
|
|
|
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 4, "%s", "interrupt: sigp emerg");
|
|
|
|
VCPU_EVENT(vcpu, 4, "%s", "interrupt: sigp emerg");
|
|
|
|
vcpu->stat.deliver_emergency_signal++;
|
|
|
|
vcpu->stat.deliver_emergency_signal++;
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type,
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_EMERGENCY,
|
|
|
|
inti->emerg.code, 0);
|
|
|
|
cpu_addr, 0);
|
|
|
|
|
|
|
|
|
|
|
|
rc = put_guest_lc(vcpu, EXT_IRQ_EMERGENCY_SIG,
|
|
|
|
rc = put_guest_lc(vcpu, EXT_IRQ_EMERGENCY_SIG,
|
|
|
|
(u16 *)__LC_EXT_INT_CODE);
|
|
|
|
(u16 *)__LC_EXT_INT_CODE);
|
|
|
|
rc |= put_guest_lc(vcpu, emerg->code, (u16 *)__LC_EXT_CPU_ADDR);
|
|
|
|
rc |= put_guest_lc(vcpu, cpu_addr, (u16 *)__LC_EXT_CPU_ADDR);
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW,
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW,
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW,
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW,
|
|
|
@ -368,21 +451,27 @@ static int __must_check __deliver_emergency_signal(struct kvm_vcpu *vcpu,
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_external_call(struct kvm_vcpu *vcpu,
|
|
|
|
static int __must_check __deliver_external_call(struct kvm_vcpu *vcpu)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_extcall_info *extcall = &inti->extcall;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_extcall_info extcall;
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
extcall = li->irq.extcall;
|
|
|
|
|
|
|
|
li->irq.extcall.code = 0;
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_EXT_EXTERNAL, &li->pending_irqs);
|
|
|
|
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 4, "%s", "interrupt: sigp ext call");
|
|
|
|
VCPU_EVENT(vcpu, 4, "%s", "interrupt: sigp ext call");
|
|
|
|
vcpu->stat.deliver_external_call++;
|
|
|
|
vcpu->stat.deliver_external_call++;
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id,
|
|
|
|
KVM_S390_INT_EXTERNAL_CALL,
|
|
|
|
KVM_S390_INT_EXTERNAL_CALL,
|
|
|
|
extcall->code, 0);
|
|
|
|
extcall.code, 0);
|
|
|
|
|
|
|
|
|
|
|
|
rc = put_guest_lc(vcpu, EXT_IRQ_EXTERNAL_CALL,
|
|
|
|
rc = put_guest_lc(vcpu, EXT_IRQ_EXTERNAL_CALL,
|
|
|
|
(u16 *)__LC_EXT_INT_CODE);
|
|
|
|
(u16 *)__LC_EXT_INT_CODE);
|
|
|
|
rc |= put_guest_lc(vcpu, extcall->code, (u16 *)__LC_EXT_CPU_ADDR);
|
|
|
|
rc |= put_guest_lc(vcpu, extcall.code, (u16 *)__LC_EXT_CPU_ADDR);
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW,
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW,
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, &vcpu->arch.sie_block->gpsw,
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, &vcpu->arch.sie_block->gpsw,
|
|
|
@ -390,20 +479,26 @@ static int __must_check __deliver_external_call(struct kvm_vcpu *vcpu,
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_prog(struct kvm_vcpu *vcpu,
|
|
|
|
static int __must_check __deliver_prog(struct kvm_vcpu *vcpu)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_pgm_info *pgm_info = &inti->pgm;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_pgm_info pgm_info;
|
|
|
|
int rc = 0;
|
|
|
|
int rc = 0;
|
|
|
|
u16 ilc = get_ilc(vcpu);
|
|
|
|
u16 ilc = get_ilc(vcpu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
pgm_info = li->irq.pgm;
|
|
|
|
|
|
|
|
clear_bit(IRQ_PEND_PROG, &li->pending_irqs);
|
|
|
|
|
|
|
|
memset(&li->irq.pgm, 0, sizeof(pgm_info));
|
|
|
|
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 4, "interrupt: pgm check code:%x, ilc:%x",
|
|
|
|
VCPU_EVENT(vcpu, 4, "interrupt: pgm check code:%x, ilc:%x",
|
|
|
|
pgm_info->code, ilc);
|
|
|
|
pgm_info.code, ilc);
|
|
|
|
vcpu->stat.deliver_program_int++;
|
|
|
|
vcpu->stat.deliver_program_int++;
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_PROGRAM_INT,
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_PROGRAM_INT,
|
|
|
|
pgm_info->code, 0);
|
|
|
|
pgm_info.code, 0);
|
|
|
|
|
|
|
|
|
|
|
|
switch (pgm_info->code & ~PGM_PER) {
|
|
|
|
switch (pgm_info.code & ~PGM_PER) {
|
|
|
|
case PGM_AFX_TRANSLATION:
|
|
|
|
case PGM_AFX_TRANSLATION:
|
|
|
|
case PGM_ASX_TRANSLATION:
|
|
|
|
case PGM_ASX_TRANSLATION:
|
|
|
|
case PGM_EX_TRANSLATION:
|
|
|
|
case PGM_EX_TRANSLATION:
|
|
|
@ -414,7 +509,7 @@ static int __must_check __deliver_prog(struct kvm_vcpu *vcpu,
|
|
|
|
case PGM_PRIMARY_AUTHORITY:
|
|
|
|
case PGM_PRIMARY_AUTHORITY:
|
|
|
|
case PGM_SECONDARY_AUTHORITY:
|
|
|
|
case PGM_SECONDARY_AUTHORITY:
|
|
|
|
case PGM_SPACE_SWITCH:
|
|
|
|
case PGM_SPACE_SWITCH:
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info->trans_exc_code,
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info.trans_exc_code,
|
|
|
|
(u64 *)__LC_TRANS_EXC_CODE);
|
|
|
|
(u64 *)__LC_TRANS_EXC_CODE);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PGM_ALEN_TRANSLATION:
|
|
|
|
case PGM_ALEN_TRANSLATION:
|
|
|
@ -423,7 +518,7 @@ static int __must_check __deliver_prog(struct kvm_vcpu *vcpu,
|
|
|
|
case PGM_ASTE_SEQUENCE:
|
|
|
|
case PGM_ASTE_SEQUENCE:
|
|
|
|
case PGM_ASTE_VALIDITY:
|
|
|
|
case PGM_ASTE_VALIDITY:
|
|
|
|
case PGM_EXTENDED_AUTHORITY:
|
|
|
|
case PGM_EXTENDED_AUTHORITY:
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info->exc_access_id,
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info.exc_access_id,
|
|
|
|
(u8 *)__LC_EXC_ACCESS_ID);
|
|
|
|
(u8 *)__LC_EXC_ACCESS_ID);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PGM_ASCE_TYPE:
|
|
|
|
case PGM_ASCE_TYPE:
|
|
|
@ -432,44 +527,44 @@ static int __must_check __deliver_prog(struct kvm_vcpu *vcpu,
|
|
|
|
case PGM_REGION_SECOND_TRANS:
|
|
|
|
case PGM_REGION_SECOND_TRANS:
|
|
|
|
case PGM_REGION_THIRD_TRANS:
|
|
|
|
case PGM_REGION_THIRD_TRANS:
|
|
|
|
case PGM_SEGMENT_TRANSLATION:
|
|
|
|
case PGM_SEGMENT_TRANSLATION:
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info->trans_exc_code,
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info.trans_exc_code,
|
|
|
|
(u64 *)__LC_TRANS_EXC_CODE);
|
|
|
|
(u64 *)__LC_TRANS_EXC_CODE);
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info->exc_access_id,
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info.exc_access_id,
|
|
|
|
(u8 *)__LC_EXC_ACCESS_ID);
|
|
|
|
(u8 *)__LC_EXC_ACCESS_ID);
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info->op_access_id,
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info.op_access_id,
|
|
|
|
(u8 *)__LC_OP_ACCESS_ID);
|
|
|
|
(u8 *)__LC_OP_ACCESS_ID);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PGM_MONITOR:
|
|
|
|
case PGM_MONITOR:
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info->mon_class_nr,
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info.mon_class_nr,
|
|
|
|
(u16 *)__LC_MON_CLASS_NR);
|
|
|
|
(u16 *)__LC_MON_CLASS_NR);
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info->mon_code,
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info.mon_code,
|
|
|
|
(u64 *)__LC_MON_CODE);
|
|
|
|
(u64 *)__LC_MON_CODE);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PGM_DATA:
|
|
|
|
case PGM_DATA:
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info->data_exc_code,
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info.data_exc_code,
|
|
|
|
(u32 *)__LC_DATA_EXC_CODE);
|
|
|
|
(u32 *)__LC_DATA_EXC_CODE);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PGM_PROTECTION:
|
|
|
|
case PGM_PROTECTION:
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info->trans_exc_code,
|
|
|
|
rc = put_guest_lc(vcpu, pgm_info.trans_exc_code,
|
|
|
|
(u64 *)__LC_TRANS_EXC_CODE);
|
|
|
|
(u64 *)__LC_TRANS_EXC_CODE);
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info->exc_access_id,
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info.exc_access_id,
|
|
|
|
(u8 *)__LC_EXC_ACCESS_ID);
|
|
|
|
(u8 *)__LC_EXC_ACCESS_ID);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pgm_info->code & PGM_PER) {
|
|
|
|
if (pgm_info.code & PGM_PER) {
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info->per_code,
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info.per_code,
|
|
|
|
(u8 *) __LC_PER_CODE);
|
|
|
|
(u8 *) __LC_PER_CODE);
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info->per_atmid,
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info.per_atmid,
|
|
|
|
(u8 *)__LC_PER_ATMID);
|
|
|
|
(u8 *)__LC_PER_ATMID);
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info->per_address,
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info.per_address,
|
|
|
|
(u64 *) __LC_PER_ADDRESS);
|
|
|
|
(u64 *) __LC_PER_ADDRESS);
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info->per_access_id,
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info.per_access_id,
|
|
|
|
(u8 *) __LC_PER_ACCESS_ID);
|
|
|
|
(u8 *) __LC_PER_ACCESS_ID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rc |= put_guest_lc(vcpu, ilc, (u16 *) __LC_PGM_ILC);
|
|
|
|
rc |= put_guest_lc(vcpu, ilc, (u16 *) __LC_PGM_ILC);
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info->code,
|
|
|
|
rc |= put_guest_lc(vcpu, pgm_info.code,
|
|
|
|
(u16 *)__LC_PGM_INT_CODE);
|
|
|
|
(u16 *)__LC_PGM_INT_CODE);
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_PGM_OLD_PSW,
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_PGM_OLD_PSW,
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
@ -572,50 +667,63 @@ static int __must_check __deliver_io(struct kvm_vcpu *vcpu,
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __do_deliver_interrupt(struct kvm_vcpu *vcpu,
|
|
|
|
static int __must_check __deliver_mchk_floating(struct kvm_vcpu *vcpu,
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct kvm_s390_mchk_info *mchk = &inti->mchk;
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 4, "interrupt: machine check mcic=%llx",
|
|
|
|
|
|
|
|
mchk->mcic);
|
|
|
|
|
|
|
|
trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_MCHK,
|
|
|
|
|
|
|
|
mchk->cr14, mchk->mcic);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rc = kvm_s390_vcpu_store_status(vcpu, KVM_S390_STORE_STATUS_PREFIXED);
|
|
|
|
|
|
|
|
rc |= put_guest_lc(vcpu, mchk->mcic,
|
|
|
|
|
|
|
|
(u64 __user *) __LC_MCCK_CODE);
|
|
|
|
|
|
|
|
rc |= put_guest_lc(vcpu, mchk->failing_storage_address,
|
|
|
|
|
|
|
|
(u64 __user *) __LC_MCCK_FAIL_STOR_ADDR);
|
|
|
|
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_PSW_SAVE_AREA,
|
|
|
|
|
|
|
|
&mchk->fixed_logout, sizeof(mchk->fixed_logout));
|
|
|
|
|
|
|
|
rc |= write_guest_lc(vcpu, __LC_MCK_OLD_PSW,
|
|
|
|
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
|
|
|
|
rc |= read_guest_lc(vcpu, __LC_MCK_NEW_PSW,
|
|
|
|
|
|
|
|
&vcpu->arch.sie_block->gpsw, sizeof(psw_t));
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef int (*deliver_irq_t)(struct kvm_vcpu *vcpu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const deliver_irq_t deliver_irq_funcs[] = {
|
|
|
|
|
|
|
|
[IRQ_PEND_MCHK_EX] = __deliver_machine_check,
|
|
|
|
|
|
|
|
[IRQ_PEND_PROG] = __deliver_prog,
|
|
|
|
|
|
|
|
[IRQ_PEND_EXT_EMERGENCY] = __deliver_emergency_signal,
|
|
|
|
|
|
|
|
[IRQ_PEND_EXT_EXTERNAL] = __deliver_external_call,
|
|
|
|
|
|
|
|
[IRQ_PEND_EXT_CLOCK_COMP] = __deliver_ckc,
|
|
|
|
|
|
|
|
[IRQ_PEND_EXT_CPU_TIMER] = __deliver_cpu_timer,
|
|
|
|
|
|
|
|
[IRQ_PEND_RESTART] = __deliver_restart,
|
|
|
|
|
|
|
|
[IRQ_PEND_SIGP_STOP] = __deliver_stop,
|
|
|
|
|
|
|
|
[IRQ_PEND_SET_PREFIX] = __deliver_set_prefix,
|
|
|
|
|
|
|
|
[IRQ_PEND_PFAULT_INIT] = __deliver_pfault_init,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int __must_check __deliver_floating_interrupt(struct kvm_vcpu *vcpu,
|
|
|
|
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
switch (inti->type) {
|
|
|
|
switch (inti->type) {
|
|
|
|
case KVM_S390_INT_EMERGENCY:
|
|
|
|
|
|
|
|
rc = __deliver_emergency_signal(vcpu, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_EXTERNAL_CALL:
|
|
|
|
|
|
|
|
rc = __deliver_external_call(vcpu, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_CLOCK_COMP:
|
|
|
|
|
|
|
|
rc = __deliver_ckc(vcpu);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_CPU_TIMER:
|
|
|
|
|
|
|
|
rc = __deliver_cpu_timer(vcpu);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_SERVICE:
|
|
|
|
case KVM_S390_INT_SERVICE:
|
|
|
|
rc = __deliver_service(vcpu, inti);
|
|
|
|
rc = __deliver_service(vcpu, inti);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_INT_PFAULT_INIT:
|
|
|
|
|
|
|
|
rc = __deliver_pfault_init(vcpu, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_PFAULT_DONE:
|
|
|
|
case KVM_S390_INT_PFAULT_DONE:
|
|
|
|
rc = __deliver_pfault_done(vcpu, inti);
|
|
|
|
rc = __deliver_pfault_done(vcpu, inti);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_INT_VIRTIO:
|
|
|
|
case KVM_S390_INT_VIRTIO:
|
|
|
|
rc = __deliver_virtio(vcpu, inti);
|
|
|
|
rc = __deliver_virtio(vcpu, inti);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_SIGP_STOP:
|
|
|
|
|
|
|
|
rc = __deliver_stop(vcpu);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_SIGP_SET_PREFIX:
|
|
|
|
|
|
|
|
rc = __deliver_set_prefix(vcpu, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_RESTART:
|
|
|
|
|
|
|
|
rc = __deliver_restart(vcpu);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_PROGRAM_INT:
|
|
|
|
|
|
|
|
rc = __deliver_prog(vcpu, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_MCHK:
|
|
|
|
case KVM_S390_MCHK:
|
|
|
|
rc = __deliver_machine_check(vcpu, inti);
|
|
|
|
rc = __deliver_mchk_floating(vcpu, inti);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_INT_IO_MIN...KVM_S390_INT_IO_MAX:
|
|
|
|
case KVM_S390_INT_IO_MIN...KVM_S390_INT_IO_MAX:
|
|
|
|
rc = __deliver_io(vcpu, inti);
|
|
|
|
rc = __deliver_io(vcpu, inti);
|
|
|
@ -643,20 +751,11 @@ int kvm_s390_si_ext_call_pending(struct kvm_vcpu *vcpu)
|
|
|
|
|
|
|
|
|
|
|
|
int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
|
|
|
|
int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_float_interrupt *fi = vcpu->arch.local_int.float_int;
|
|
|
|
struct kvm_s390_float_interrupt *fi = vcpu->arch.local_int.float_int;
|
|
|
|
struct kvm_s390_interrupt_info *inti;
|
|
|
|
struct kvm_s390_interrupt_info *inti;
|
|
|
|
int rc = 0;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
if (atomic_read(&li->active)) {
|
|
|
|
rc = !!deliverable_local_irqs(vcpu);
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
list_for_each_entry(inti, &li->list, list)
|
|
|
|
|
|
|
|
if (__interrupt_is_deliverable(vcpu, inti)) {
|
|
|
|
|
|
|
|
rc = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((!rc) && atomic_read(&fi->active)) {
|
|
|
|
if ((!rc) && atomic_read(&fi->active)) {
|
|
|
|
spin_lock(&fi->lock);
|
|
|
|
spin_lock(&fi->lock);
|
|
|
@ -748,18 +847,15 @@ enum hrtimer_restart kvm_s390_idle_wakeup(struct hrtimer *timer)
|
|
|
|
void kvm_s390_clear_local_irqs(struct kvm_vcpu *vcpu)
|
|
|
|
void kvm_s390_clear_local_irqs(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_interrupt_info *n, *inti = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
list_for_each_entry_safe(inti, n, &li->list, list) {
|
|
|
|
li->pending_irqs = 0;
|
|
|
|
list_del(&inti->list);
|
|
|
|
bitmap_zero(li->sigp_emerg_pending, KVM_MAX_VCPUS);
|
|
|
|
kfree(inti);
|
|
|
|
memset(&li->irq, 0, sizeof(li->irq));
|
|
|
|
}
|
|
|
|
|
|
|
|
atomic_set(&li->active, 0);
|
|
|
|
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
|
|
|
|
|
|
|
|
/* clear pending external calls set by sigp interpretation facility */
|
|
|
|
/* clear pending external calls set by sigp interpretation facility */
|
|
|
|
atomic_clear_mask(CPUSTAT_ECALL_PEND, &vcpu->arch.sie_block->cpuflags);
|
|
|
|
atomic_clear_mask(CPUSTAT_ECALL_PEND, li->cpuflags);
|
|
|
|
atomic_clear_mask(SIGP_CTRL_C,
|
|
|
|
atomic_clear_mask(SIGP_CTRL_C,
|
|
|
|
&vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].ctrl);
|
|
|
|
&vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].ctrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -769,34 +865,35 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_float_interrupt *fi = vcpu->arch.local_int.float_int;
|
|
|
|
struct kvm_s390_float_interrupt *fi = vcpu->arch.local_int.float_int;
|
|
|
|
struct kvm_s390_interrupt_info *n, *inti = NULL;
|
|
|
|
struct kvm_s390_interrupt_info *n, *inti = NULL;
|
|
|
|
|
|
|
|
deliver_irq_t func;
|
|
|
|
int deliver;
|
|
|
|
int deliver;
|
|
|
|
int rc = 0;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
unsigned long irq_type;
|
|
|
|
|
|
|
|
unsigned long deliverable_irqs;
|
|
|
|
|
|
|
|
|
|
|
|
__reset_intercept_indicators(vcpu);
|
|
|
|
__reset_intercept_indicators(vcpu);
|
|
|
|
if (atomic_read(&li->active)) {
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
deliver = 0;
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(inti, n, &li->list, list) {
|
|
|
|
|
|
|
|
if (__interrupt_is_deliverable(vcpu, inti)) {
|
|
|
|
|
|
|
|
list_del(&inti->list);
|
|
|
|
|
|
|
|
deliver = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
__set_intercept_indicator(vcpu, inti);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (list_empty(&li->list))
|
|
|
|
|
|
|
|
atomic_set(&li->active, 0);
|
|
|
|
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
|
|
|
|
if (deliver) {
|
|
|
|
|
|
|
|
rc = __do_deliver_interrupt(vcpu, inti);
|
|
|
|
|
|
|
|
kfree(inti);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (!rc && deliver);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!rc && kvm_cpu_has_pending_timer(vcpu))
|
|
|
|
/* pending ckc conditions might have been invalidated */
|
|
|
|
rc = __deliver_ckc(vcpu);
|
|
|
|
clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs);
|
|
|
|
|
|
|
|
if (kvm_cpu_has_pending_timer(vcpu))
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
deliverable_irqs = deliverable_local_irqs(vcpu);
|
|
|
|
|
|
|
|
/* bits are in the order of interrupt priority */
|
|
|
|
|
|
|
|
irq_type = find_first_bit(&deliverable_irqs, IRQ_PEND_COUNT);
|
|
|
|
|
|
|
|
if (irq_type == IRQ_PEND_COUNT)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
func = deliver_irq_funcs[irq_type];
|
|
|
|
|
|
|
|
if (!func) {
|
|
|
|
|
|
|
|
WARN_ON_ONCE(func == NULL);
|
|
|
|
|
|
|
|
clear_bit(irq_type, &li->pending_irqs);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = func(vcpu);
|
|
|
|
|
|
|
|
} while (!rc && irq_type != IRQ_PEND_COUNT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_intercept_indicators_local(vcpu);
|
|
|
|
|
|
|
|
|
|
|
|
if (!rc && atomic_read(&fi->active)) {
|
|
|
|
if (!rc && atomic_read(&fi->active)) {
|
|
|
|
do {
|
|
|
|
do {
|
|
|
@ -815,7 +912,7 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
|
|
|
|
atomic_set(&fi->active, 0);
|
|
|
|
atomic_set(&fi->active, 0);
|
|
|
|
spin_unlock(&fi->lock);
|
|
|
|
spin_unlock(&fi->lock);
|
|
|
|
if (deliver) {
|
|
|
|
if (deliver) {
|
|
|
|
rc = __do_deliver_interrupt(vcpu, inti);
|
|
|
|
rc = __deliver_floating_interrupt(vcpu, inti);
|
|
|
|
kfree(inti);
|
|
|
|
kfree(inti);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!rc && deliver);
|
|
|
|
} while (!rc && deliver);
|
|
|
@ -824,33 +921,26 @@ int __must_check kvm_s390_deliver_pending_interrupts(struct kvm_vcpu *vcpu)
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_prog_irq(struct kvm_vcpu *vcpu,
|
|
|
|
static int __inject_prog(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
|
|
|
|
list_add(&inti->list, &li->list);
|
|
|
|
li->irq.pgm = irq->u.pgm;
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
__set_bit(IRQ_PEND_PROG, &li->pending_irqs);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code)
|
|
|
|
int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_interrupt_info *inti;
|
|
|
|
struct kvm_s390_irq irq;
|
|
|
|
|
|
|
|
|
|
|
|
inti = kzalloc(sizeof(*inti), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!inti)
|
|
|
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inti->type = KVM_S390_PROGRAM_INT;
|
|
|
|
|
|
|
|
inti->pgm.code = code;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: program check %d (from kernel)", code);
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: program check %d (from kernel)", code);
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, inti->type, code, 0, 1);
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_PROGRAM_INT, code,
|
|
|
|
|
|
|
|
0, 1);
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
list_add(&inti->list, &li->list);
|
|
|
|
irq.u.pgm.code = code;
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
__inject_prog(vcpu, &irq);
|
|
|
|
BUG_ON(waitqueue_active(li->wq));
|
|
|
|
BUG_ON(waitqueue_active(li->wq));
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -860,151 +950,158 @@ int kvm_s390_inject_prog_irq(struct kvm_vcpu *vcpu,
|
|
|
|
struct kvm_s390_pgm_info *pgm_info)
|
|
|
|
struct kvm_s390_pgm_info *pgm_info)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_interrupt_info *inti;
|
|
|
|
struct kvm_s390_irq irq;
|
|
|
|
int rc;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
inti = kzalloc(sizeof(*inti), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!inti)
|
|
|
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: prog irq %d (from kernel)",
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: prog irq %d (from kernel)",
|
|
|
|
pgm_info->code);
|
|
|
|
pgm_info->code);
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_PROGRAM_INT,
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_PROGRAM_INT,
|
|
|
|
pgm_info->code, 0, 1);
|
|
|
|
pgm_info->code, 0, 1);
|
|
|
|
|
|
|
|
|
|
|
|
inti->type = KVM_S390_PROGRAM_INT;
|
|
|
|
|
|
|
|
memcpy(&inti->pgm, pgm_info, sizeof(inti->pgm));
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
rc = __inject_prog_irq(vcpu, inti);
|
|
|
|
irq.u.pgm = *pgm_info;
|
|
|
|
|
|
|
|
rc = __inject_prog(vcpu, &irq);
|
|
|
|
BUG_ON(waitqueue_active(li->wq));
|
|
|
|
BUG_ON(waitqueue_active(li->wq));
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_pfault_init(struct kvm_vcpu *vcpu,
|
|
|
|
static int __inject_pfault_init(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
|
|
|
|
struct kvm_s390_interrupt *s390int,
|
|
|
|
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
|
|
|
|
inti->ext.ext_params2 = s390int->parm64;
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: external irq params:%x, params2:%llx",
|
|
|
|
list_add_tail(&inti->list, &li->list);
|
|
|
|
irq->u.ext.ext_params, irq->u.ext.ext_params2);
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_PFAULT_INIT,
|
|
|
|
|
|
|
|
irq->u.ext.ext_params,
|
|
|
|
|
|
|
|
irq->u.ext.ext_params2, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
li->irq.ext = irq->u.ext;
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_PFAULT_INIT, &li->pending_irqs);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_extcall(struct kvm_vcpu *vcpu,
|
|
|
|
int __inject_extcall(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
|
|
|
|
struct kvm_s390_interrupt *s390int,
|
|
|
|
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_extcall_info *extcall = &li->irq.extcall;
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: external call source-cpu:%u",
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: external call source-cpu:%u",
|
|
|
|
s390int->parm);
|
|
|
|
irq->u.extcall.code);
|
|
|
|
if (s390int->parm & 0xffff0000)
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_EXTERNAL_CALL,
|
|
|
|
return -EINVAL;
|
|
|
|
irq->u.extcall.code, 0, 2);
|
|
|
|
inti->extcall.code = s390int->parm;
|
|
|
|
|
|
|
|
list_add_tail(&inti->list, &li->list);
|
|
|
|
*extcall = irq->u.extcall;
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
__set_bit(IRQ_PEND_EXT_EXTERNAL, &li->pending_irqs);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_set_prefix(struct kvm_vcpu *vcpu,
|
|
|
|
static int __inject_set_prefix(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
|
|
|
|
struct kvm_s390_interrupt *s390int,
|
|
|
|
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_prefix_info *prefix = &li->irq.prefix;
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: set prefix to %x (from user)",
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: set prefix to %x (from user)",
|
|
|
|
s390int->parm);
|
|
|
|
prefix->address);
|
|
|
|
inti->prefix.address = s390int->parm;
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_SIGP_SET_PREFIX,
|
|
|
|
list_add_tail(&inti->list, &li->list);
|
|
|
|
prefix->address, 0, 2);
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
|
|
|
|
|
|
|
|
*prefix = irq->u.prefix;
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_SET_PREFIX, &li->pending_irqs);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_sigp_stop(struct kvm_vcpu *vcpu,
|
|
|
|
static int __inject_sigp_stop(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
|
|
|
|
struct kvm_s390_interrupt *s390int,
|
|
|
|
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
|
|
|
|
list_add_tail(&inti->list, &li->list);
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_SIGP_STOP, 0, 0, 2);
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
|
|
|
|
li->action_bits |= ACTION_STOP_ON_STOP;
|
|
|
|
li->action_bits |= ACTION_STOP_ON_STOP;
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_SIGP_STOP, &li->pending_irqs);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_sigp_restart(struct kvm_vcpu *vcpu,
|
|
|
|
static int __inject_sigp_restart(struct kvm_vcpu *vcpu,
|
|
|
|
struct kvm_s390_interrupt *s390int,
|
|
|
|
struct kvm_s390_irq *irq)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: type %x", s390int->type);
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: restart type %llx", irq->type);
|
|
|
|
list_add_tail(&inti->list, &li->list);
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_RESTART, 0, 0, 2);
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_RESTART, &li->pending_irqs);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_sigp_emergency(struct kvm_vcpu *vcpu,
|
|
|
|
static int __inject_sigp_emergency(struct kvm_vcpu *vcpu,
|
|
|
|
struct kvm_s390_interrupt *s390int,
|
|
|
|
struct kvm_s390_irq *irq)
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_emerg_info *emerg = &li->irq.emerg;
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: emergency %u\n", s390int->parm);
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: emergency %u\n",
|
|
|
|
if (s390int->parm & 0xffff0000)
|
|
|
|
irq->u.emerg.code);
|
|
|
|
return -EINVAL;
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_EMERGENCY,
|
|
|
|
inti->emerg.code = s390int->parm;
|
|
|
|
emerg->code, 0, 2);
|
|
|
|
list_add_tail(&inti->list, &li->list);
|
|
|
|
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
set_bit(emerg->code, li->sigp_emerg_pending);
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_EXT_EMERGENCY, &li->pending_irqs);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_mchk(struct kvm_vcpu *vcpu,
|
|
|
|
static int __inject_mchk(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
|
|
|
|
struct kvm_s390_interrupt *s390int,
|
|
|
|
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
struct kvm_s390_mchk_info *mchk = &li->irq.mchk;
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 5, "inject: machine check parm64:%llx",
|
|
|
|
VCPU_EVENT(vcpu, 5, "inject: machine check parm64:%llx",
|
|
|
|
s390int->parm64);
|
|
|
|
mchk->mcic);
|
|
|
|
inti->mchk.mcic = s390int->parm64;
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_MCHK, 0,
|
|
|
|
list_add_tail(&inti->list, &li->list);
|
|
|
|
mchk->mcic, 2);
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Combine mcic with previously injected machine checks and
|
|
|
|
|
|
|
|
* indicate them all together as described in the Principles
|
|
|
|
|
|
|
|
* of Operation, Chapter 11, Interruption action
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
mchk->mcic |= irq->u.mchk.mcic;
|
|
|
|
|
|
|
|
if (mchk->mcic & MCHK_EX_MASK)
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_MCHK_EX, &li->pending_irqs);
|
|
|
|
|
|
|
|
else if (mchk->mcic & MCHK_REP_MASK)
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_MCHK_REP, &li->pending_irqs);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_ckc(struct kvm_vcpu *vcpu,
|
|
|
|
static int __inject_ckc(struct kvm_vcpu *vcpu)
|
|
|
|
struct kvm_s390_interrupt *s390int,
|
|
|
|
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: type %x", s390int->type);
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: type %x", KVM_S390_INT_CLOCK_COMP);
|
|
|
|
list_add_tail(&inti->list, &li->list);
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_CLOCK_COMP,
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
0, 0, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int __inject_cpu_timer(struct kvm_vcpu *vcpu,
|
|
|
|
static int __inject_cpu_timer(struct kvm_vcpu *vcpu)
|
|
|
|
struct kvm_s390_interrupt *s390int,
|
|
|
|
|
|
|
|
struct kvm_s390_interrupt_info *inti)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: type %x", s390int->type);
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: type %x", KVM_S390_INT_CPU_TIMER);
|
|
|
|
list_add_tail(&inti->list, &li->list);
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_INT_CPU_TIMER,
|
|
|
|
atomic_set(&li->active, 1);
|
|
|
|
0, 0, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
atomic_set_mask(CPUSTAT_EXT_INT, li->cpuflags);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm,
|
|
|
|
struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm,
|
|
|
|
u64 cr6, u64 schid)
|
|
|
|
u64 cr6, u64 schid)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1169,58 +1266,74 @@ void kvm_s390_reinject_io_int(struct kvm *kvm,
|
|
|
|
__inject_vm(kvm, inti);
|
|
|
|
__inject_vm(kvm, inti);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
|
|
|
|
int s390int_to_s390irq(struct kvm_s390_interrupt *s390int,
|
|
|
|
struct kvm_s390_interrupt *s390int)
|
|
|
|
struct kvm_s390_irq *irq)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
irq->type = s390int->type;
|
|
|
|
struct kvm_s390_interrupt_info *inti;
|
|
|
|
switch (irq->type) {
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inti = kzalloc(sizeof(*inti), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!inti)
|
|
|
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inti->type = s390int->type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, s390int->type,
|
|
|
|
|
|
|
|
s390int->parm, 0, 2);
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
switch (inti->type) {
|
|
|
|
|
|
|
|
case KVM_S390_PROGRAM_INT:
|
|
|
|
case KVM_S390_PROGRAM_INT:
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: program check %d (from user)",
|
|
|
|
|
|
|
|
s390int->parm);
|
|
|
|
|
|
|
|
inti->pgm.code = s390int->parm;
|
|
|
|
|
|
|
|
if (s390int->parm & 0xffff0000)
|
|
|
|
if (s390int->parm & 0xffff0000)
|
|
|
|
rc = -EINVAL;
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
|
|
|
irq->u.pgm.code = s390int->parm;
|
|
|
|
rc = __inject_prog_irq(vcpu, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_SIGP_SET_PREFIX:
|
|
|
|
case KVM_S390_SIGP_SET_PREFIX:
|
|
|
|
rc = __inject_set_prefix(vcpu, s390int, inti);
|
|
|
|
irq->u.prefix.address = s390int->parm;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_SIGP_STOP:
|
|
|
|
|
|
|
|
rc = __inject_sigp_stop(vcpu, s390int, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_RESTART:
|
|
|
|
|
|
|
|
rc = __inject_sigp_restart(vcpu, s390int, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_CLOCK_COMP:
|
|
|
|
|
|
|
|
rc = __inject_ckc(vcpu, s390int, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_CPU_TIMER:
|
|
|
|
|
|
|
|
rc = __inject_cpu_timer(vcpu, s390int, inti);
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_INT_EXTERNAL_CALL:
|
|
|
|
case KVM_S390_INT_EXTERNAL_CALL:
|
|
|
|
rc = __inject_extcall(vcpu, s390int, inti);
|
|
|
|
if (irq->u.extcall.code & 0xffff0000)
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
irq->u.extcall.code = s390int->parm;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_INT_EMERGENCY:
|
|
|
|
case KVM_S390_INT_EMERGENCY:
|
|
|
|
rc = __inject_sigp_emergency(vcpu, s390int, inti);
|
|
|
|
if (irq->u.emerg.code & 0xffff0000)
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
irq->u.emerg.code = s390int->parm;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_MCHK:
|
|
|
|
case KVM_S390_MCHK:
|
|
|
|
rc = __inject_mchk(vcpu, s390int, inti);
|
|
|
|
irq->u.mchk.mcic = s390int->parm64;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spin_lock(&li->lock);
|
|
|
|
|
|
|
|
switch (irq->type) {
|
|
|
|
|
|
|
|
case KVM_S390_PROGRAM_INT:
|
|
|
|
|
|
|
|
VCPU_EVENT(vcpu, 3, "inject: program check %d (from user)",
|
|
|
|
|
|
|
|
irq->u.pgm.code);
|
|
|
|
|
|
|
|
rc = __inject_prog(vcpu, irq);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_SIGP_SET_PREFIX:
|
|
|
|
|
|
|
|
rc = __inject_set_prefix(vcpu, irq);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_SIGP_STOP:
|
|
|
|
|
|
|
|
rc = __inject_sigp_stop(vcpu, irq);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_RESTART:
|
|
|
|
|
|
|
|
rc = __inject_sigp_restart(vcpu, irq);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_CLOCK_COMP:
|
|
|
|
|
|
|
|
rc = __inject_ckc(vcpu);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_CPU_TIMER:
|
|
|
|
|
|
|
|
rc = __inject_cpu_timer(vcpu);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_EXTERNAL_CALL:
|
|
|
|
|
|
|
|
rc = __inject_extcall(vcpu, irq);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_INT_EMERGENCY:
|
|
|
|
|
|
|
|
rc = __inject_sigp_emergency(vcpu, irq);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KVM_S390_MCHK:
|
|
|
|
|
|
|
|
rc = __inject_mchk(vcpu, irq);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_INT_PFAULT_INIT:
|
|
|
|
case KVM_S390_INT_PFAULT_INIT:
|
|
|
|
rc = __inject_pfault_init(vcpu, s390int, inti);
|
|
|
|
rc = __inject_pfault_init(vcpu, irq);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KVM_S390_INT_VIRTIO:
|
|
|
|
case KVM_S390_INT_VIRTIO:
|
|
|
|
case KVM_S390_INT_SERVICE:
|
|
|
|
case KVM_S390_INT_SERVICE:
|
|
|
@ -1231,8 +1344,6 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
spin_unlock(&li->lock);
|
|
|
|
if (!rc)
|
|
|
|
if (!rc)
|
|
|
|
kvm_s390_vcpu_wakeup(vcpu);
|
|
|
|
kvm_s390_vcpu_wakeup(vcpu);
|
|
|
|
else
|
|
|
|
|
|
|
|
kfree(inti);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|