2008-03-26 01:47:23 +08:00
|
|
|
/*
|
2012-07-20 17:15:04 +08:00
|
|
|
* in-kernel handling for sie intercepts
|
2008-03-26 01:47:23 +08:00
|
|
|
*
|
2014-02-03 17:42:30 +08:00
|
|
|
* Copyright IBM Corp. 2008, 2014
|
2008-03-26 01:47:23 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License (version 2 only)
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* Author(s): Carsten Otte <cotte@de.ibm.com>
|
|
|
|
* Christian Borntraeger <borntraeger@de.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kvm_host.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
|
|
|
|
#include <asm/kvm_host.h>
|
2014-03-14 02:29:09 +08:00
|
|
|
#include <asm/asm-offsets.h>
|
2014-01-15 23:46:07 +08:00
|
|
|
#include <asm/irq.h>
|
2008-03-26 01:47:23 +08:00
|
|
|
|
|
|
|
#include "kvm-s390.h"
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
#include "gaccess.h"
|
2012-07-23 23:20:29 +08:00
|
|
|
#include "trace.h"
|
2012-07-23 23:20:30 +08:00
|
|
|
#include "trace-s390.h"
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
|
2012-12-20 22:32:10 +08:00
|
|
|
|
2012-12-20 22:32:06 +08:00
|
|
|
static const intercept_handler_t instruction_handlers[256] = {
|
2012-04-24 15:24:44 +08:00
|
|
|
[0x01] = kvm_s390_handle_01,
|
2012-12-20 22:32:09 +08:00
|
|
|
[0x82] = kvm_s390_handle_lpsw,
|
2008-03-26 01:47:34 +08:00
|
|
|
[0x83] = kvm_s390_handle_diag,
|
2008-03-26 01:47:31 +08:00
|
|
|
[0xae] = kvm_s390_handle_sigp,
|
2009-01-22 17:28:29 +08:00
|
|
|
[0xb2] = kvm_s390_handle_b2,
|
2014-01-23 17:47:13 +08:00
|
|
|
[0xb6] = kvm_s390_handle_stctl,
|
2013-06-20 23:22:04 +08:00
|
|
|
[0xb7] = kvm_s390_handle_lctl,
|
2012-12-20 22:32:09 +08:00
|
|
|
[0xb9] = kvm_s390_handle_b9,
|
2011-07-24 16:48:17 +08:00
|
|
|
[0xe5] = kvm_s390_handle_e5,
|
2013-06-20 23:22:04 +08:00
|
|
|
[0xeb] = kvm_s390_handle_eb,
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
};
|
2008-03-26 01:47:23 +08:00
|
|
|
|
|
|
|
static int handle_noop(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
switch (vcpu->arch.sie_block->icptcode) {
|
2008-05-07 15:22:53 +08:00
|
|
|
case 0x0:
|
|
|
|
vcpu->stat.exit_null++;
|
|
|
|
break;
|
2008-03-26 01:47:23 +08:00
|
|
|
case 0x10:
|
|
|
|
vcpu->stat.exit_external_request++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break; /* nothing */
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_stop(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2009-05-20 21:34:55 +08:00
|
|
|
int rc = 0;
|
2014-04-14 18:40:03 +08:00
|
|
|
unsigned int action_bits;
|
2008-03-26 01:47:31 +08:00
|
|
|
|
2008-03-26 01:47:23 +08:00
|
|
|
vcpu->stat.exit_stop_request++;
|
2012-07-23 23:20:30 +08:00
|
|
|
trace_kvm_s390_stop_request(vcpu->arch.local_int.action_bits);
|
|
|
|
|
2014-04-14 18:40:03 +08:00
|
|
|
action_bits = vcpu->arch.local_int.action_bits;
|
|
|
|
|
|
|
|
if (!(action_bits & ACTION_STOP_ON_STOP))
|
|
|
|
return 0;
|
2009-05-20 21:34:55 +08:00
|
|
|
|
2014-04-14 18:40:03 +08:00
|
|
|
if (action_bits & ACTION_STORE_ON_STOP) {
|
2012-02-06 17:59:03 +08:00
|
|
|
rc = kvm_s390_vcpu_store_status(vcpu,
|
|
|
|
KVM_S390_STORE_STATUS_NOADDR);
|
2014-04-14 18:40:03 +08:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-04-10 23:35:00 +08:00
|
|
|
if (!kvm_s390_user_cpu_state_ctrl(vcpu->kvm))
|
|
|
|
kvm_s390_vcpu_stop(vcpu);
|
2014-04-14 18:40:03 +08:00
|
|
|
return -EOPNOTSUPP;
|
2008-03-26 01:47:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_validity(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
int viwhy = vcpu->arch.sie_block->ipb >> 16;
|
2009-05-12 23:21:52 +08:00
|
|
|
|
2008-03-26 01:47:23 +08:00
|
|
|
vcpu->stat.exit_validity++;
|
2012-07-23 23:20:29 +08:00
|
|
|
trace_kvm_s390_intercept_validity(vcpu, viwhy);
|
2013-05-17 20:41:36 +08:00
|
|
|
WARN_ONCE(true, "kvm: unhandled validity intercept 0x%x\n", viwhy);
|
|
|
|
return -EOPNOTSUPP;
|
2008-03-26 01:47:23 +08:00
|
|
|
}
|
|
|
|
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
static int handle_instruction(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
intercept_handler_t handler;
|
|
|
|
|
|
|
|
vcpu->stat.exit_instruction++;
|
2012-07-23 23:20:29 +08:00
|
|
|
trace_kvm_s390_intercept_instruction(vcpu,
|
|
|
|
vcpu->arch.sie_block->ipa,
|
|
|
|
vcpu->arch.sie_block->ipb);
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
handler = instruction_handlers[vcpu->arch.sie_block->ipa >> 8];
|
|
|
|
if (handler)
|
|
|
|
return handler(vcpu);
|
2010-02-27 05:37:41 +08:00
|
|
|
return -EOPNOTSUPP;
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
}
|
|
|
|
|
2014-03-03 17:54:33 +08:00
|
|
|
static void __extract_prog_irq(struct kvm_vcpu *vcpu,
|
|
|
|
struct kvm_s390_pgm_info *pgm_info)
|
|
|
|
{
|
|
|
|
memset(pgm_info, 0, sizeof(struct kvm_s390_pgm_info));
|
|
|
|
pgm_info->code = vcpu->arch.sie_block->iprcc;
|
|
|
|
|
|
|
|
switch (vcpu->arch.sie_block->iprcc & ~PGM_PER) {
|
|
|
|
case PGM_AFX_TRANSLATION:
|
|
|
|
case PGM_ASX_TRANSLATION:
|
|
|
|
case PGM_EX_TRANSLATION:
|
|
|
|
case PGM_LFX_TRANSLATION:
|
|
|
|
case PGM_LSTE_SEQUENCE:
|
|
|
|
case PGM_LSX_TRANSLATION:
|
|
|
|
case PGM_LX_TRANSLATION:
|
|
|
|
case PGM_PRIMARY_AUTHORITY:
|
|
|
|
case PGM_SECONDARY_AUTHORITY:
|
|
|
|
case PGM_SPACE_SWITCH:
|
|
|
|
pgm_info->trans_exc_code = vcpu->arch.sie_block->tecmc;
|
|
|
|
break;
|
|
|
|
case PGM_ALEN_TRANSLATION:
|
|
|
|
case PGM_ALE_SEQUENCE:
|
|
|
|
case PGM_ASTE_INSTANCE:
|
|
|
|
case PGM_ASTE_SEQUENCE:
|
|
|
|
case PGM_ASTE_VALIDITY:
|
|
|
|
case PGM_EXTENDED_AUTHORITY:
|
|
|
|
pgm_info->exc_access_id = vcpu->arch.sie_block->eai;
|
|
|
|
break;
|
|
|
|
case PGM_ASCE_TYPE:
|
|
|
|
case PGM_PAGE_TRANSLATION:
|
|
|
|
case PGM_REGION_FIRST_TRANS:
|
|
|
|
case PGM_REGION_SECOND_TRANS:
|
|
|
|
case PGM_REGION_THIRD_TRANS:
|
|
|
|
case PGM_SEGMENT_TRANSLATION:
|
|
|
|
pgm_info->trans_exc_code = vcpu->arch.sie_block->tecmc;
|
|
|
|
pgm_info->exc_access_id = vcpu->arch.sie_block->eai;
|
|
|
|
pgm_info->op_access_id = vcpu->arch.sie_block->oai;
|
|
|
|
break;
|
|
|
|
case PGM_MONITOR:
|
|
|
|
pgm_info->mon_class_nr = vcpu->arch.sie_block->mcn;
|
|
|
|
pgm_info->mon_code = vcpu->arch.sie_block->tecmc;
|
|
|
|
break;
|
|
|
|
case PGM_DATA:
|
|
|
|
pgm_info->data_exc_code = vcpu->arch.sie_block->dxc;
|
|
|
|
break;
|
|
|
|
case PGM_PROTECTION:
|
|
|
|
pgm_info->trans_exc_code = vcpu->arch.sie_block->tecmc;
|
|
|
|
pgm_info->exc_access_id = vcpu->arch.sie_block->eai;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vcpu->arch.sie_block->iprcc & PGM_PER) {
|
|
|
|
pgm_info->per_code = vcpu->arch.sie_block->perc;
|
|
|
|
pgm_info->per_atmid = vcpu->arch.sie_block->peratmid;
|
|
|
|
pgm_info->per_address = vcpu->arch.sie_block->peraddr;
|
|
|
|
pgm_info->per_access_id = vcpu->arch.sie_block->peraid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-13 19:16:45 +08:00
|
|
|
/*
|
|
|
|
* restore ITDB to program-interruption TDB in guest lowcore
|
|
|
|
* and set TX abort indication if required
|
|
|
|
*/
|
|
|
|
static int handle_itdb(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_s390_itdb *itdb;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!IS_TE_ENABLED(vcpu) || !IS_ITDB_VALID(vcpu))
|
|
|
|
return 0;
|
|
|
|
if (current->thread.per_flags & PER_FLAG_NO_TE)
|
|
|
|
return 0;
|
|
|
|
itdb = (struct kvm_s390_itdb *)vcpu->arch.sie_block->itdba;
|
|
|
|
rc = write_guest_lc(vcpu, __LC_PGM_TDB, itdb, sizeof(*itdb));
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
memset(itdb, 0, sizeof(*itdb));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-23 19:26:52 +08:00
|
|
|
#define per_event(vcpu) (vcpu->arch.sie_block->iprcc & PGM_PER)
|
|
|
|
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
static int handle_prog(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2014-03-03 17:54:33 +08:00
|
|
|
struct kvm_s390_pgm_info pgm_info;
|
2014-04-17 15:57:10 +08:00
|
|
|
psw_t psw;
|
2014-01-01 23:37:47 +08:00
|
|
|
int rc;
|
|
|
|
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
vcpu->stat.exit_program_interruption++;
|
2013-06-28 19:30:24 +08:00
|
|
|
|
2014-01-23 19:26:52 +08:00
|
|
|
if (guestdbg_enabled(vcpu) && per_event(vcpu)) {
|
|
|
|
kvm_s390_handle_per_event(vcpu);
|
|
|
|
/* the interrupt might have been filtered out completely */
|
|
|
|
if (vcpu->arch.sie_block->iprcc == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-13 19:16:45 +08:00
|
|
|
trace_kvm_s390_intercept_prog(vcpu, vcpu->arch.sie_block->iprcc);
|
2014-04-17 15:57:10 +08:00
|
|
|
if (vcpu->arch.sie_block->iprcc == PGM_SPECIFICATION) {
|
|
|
|
rc = read_guest_lc(vcpu, __LC_PGM_NEW_PSW, &psw, sizeof(psw_t));
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
/* Avoid endless loops of specification exceptions */
|
|
|
|
if (!is_valid_psw(&psw))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2014-03-13 19:16:45 +08:00
|
|
|
rc = handle_itdb(vcpu);
|
2014-01-01 23:37:47 +08:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2014-03-03 17:54:33 +08:00
|
|
|
|
2014-03-13 19:16:45 +08:00
|
|
|
__extract_prog_irq(vcpu, &pgm_info);
|
2014-03-03 17:54:33 +08:00
|
|
|
return kvm_s390_inject_prog_irq(vcpu, &pgm_info);
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_instruction_and_prog(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
int rc, rc2;
|
|
|
|
|
|
|
|
vcpu->stat.exit_instr_and_program++;
|
|
|
|
rc = handle_instruction(vcpu);
|
|
|
|
rc2 = handle_prog(vcpu);
|
|
|
|
|
2010-02-27 05:37:41 +08:00
|
|
|
if (rc == -EOPNOTSUPP)
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
vcpu->arch.sie_block->icptcode = 0x04;
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
return rc2;
|
|
|
|
}
|
|
|
|
|
2014-01-15 23:46:07 +08:00
|
|
|
/**
|
|
|
|
* handle_external_interrupt - used for external interruption interceptions
|
|
|
|
*
|
|
|
|
* This interception only occurs if the CPUSTAT_EXT_INT bit was set, or if
|
|
|
|
* the new PSW does not have external interrupts disabled. In the first case,
|
|
|
|
* we've got to deliver the interrupt manually, and in the second case, we
|
|
|
|
* drop to userspace to handle the situation there.
|
|
|
|
*/
|
|
|
|
static int handle_external_interrupt(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
u16 eic = vcpu->arch.sie_block->eic;
|
|
|
|
struct kvm_s390_interrupt irq;
|
|
|
|
psw_t newpsw;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
vcpu->stat.exit_external_interrupt++;
|
|
|
|
|
|
|
|
rc = read_guest_lc(vcpu, __LC_EXT_NEW_PSW, &newpsw, sizeof(psw_t));
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
/* We can not handle clock comparator or timer interrupt with bad PSW */
|
|
|
|
if ((eic == EXT_IRQ_CLK_COMP || eic == EXT_IRQ_CPU_TIMER) &&
|
|
|
|
(newpsw.mask & PSW_MASK_EXT))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (eic) {
|
|
|
|
case EXT_IRQ_CLK_COMP:
|
|
|
|
irq.type = KVM_S390_INT_CLOCK_COMP;
|
|
|
|
break;
|
|
|
|
case EXT_IRQ_CPU_TIMER:
|
|
|
|
irq.type = KVM_S390_INT_CPU_TIMER;
|
|
|
|
break;
|
|
|
|
case EXT_IRQ_EXTERNAL_CALL:
|
2014-02-21 15:59:59 +08:00
|
|
|
if (kvm_s390_si_ext_call_pending(vcpu))
|
|
|
|
return 0;
|
2014-01-15 23:46:07 +08:00
|
|
|
irq.type = KVM_S390_INT_EXTERNAL_CALL;
|
|
|
|
irq.parm = vcpu->arch.sie_block->extcpuaddr;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return kvm_s390_inject_vcpu(vcpu, &irq);
|
|
|
|
}
|
|
|
|
|
2014-02-03 17:42:30 +08:00
|
|
|
/**
|
|
|
|
* Handle MOVE PAGE partial execution interception.
|
|
|
|
*
|
|
|
|
* This interception can only happen for guests with DAT disabled and
|
|
|
|
* addresses that are currently not mapped in the host. Thus we try to
|
|
|
|
* set up the mappings for the corresponding user pages here (or throw
|
|
|
|
* addressing exceptions in case of illegal guest addresses).
|
|
|
|
*/
|
|
|
|
static int handle_mvpg_pei(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
psw_t *psw = &vcpu->arch.sie_block->gpsw;
|
2014-05-07 17:44:17 +08:00
|
|
|
unsigned long srcaddr, dstaddr;
|
2014-02-03 17:42:30 +08:00
|
|
|
int reg1, reg2, rc;
|
|
|
|
|
|
|
|
kvm_s390_get_regs_rre(vcpu, ®1, ®2);
|
|
|
|
|
|
|
|
/* Make sure that the source is paged-in */
|
2014-05-07 17:44:17 +08:00
|
|
|
srcaddr = kvm_s390_real_to_abs(vcpu, vcpu->run->s.regs.gprs[reg2]);
|
|
|
|
if (kvm_is_error_gpa(vcpu->kvm, srcaddr))
|
2014-02-03 17:42:30 +08:00
|
|
|
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
|
2014-05-07 17:44:17 +08:00
|
|
|
rc = kvm_arch_fault_in_page(vcpu, srcaddr, 0);
|
|
|
|
if (rc != 0)
|
2014-02-03 17:42:30 +08:00
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Make sure that the destination is paged-in */
|
2014-05-07 17:44:17 +08:00
|
|
|
dstaddr = kvm_s390_real_to_abs(vcpu, vcpu->run->s.regs.gprs[reg1]);
|
|
|
|
if (kvm_is_error_gpa(vcpu->kvm, dstaddr))
|
2014-02-03 17:42:30 +08:00
|
|
|
return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
|
2014-05-07 17:44:17 +08:00
|
|
|
rc = kvm_arch_fault_in_page(vcpu, dstaddr, 1);
|
|
|
|
if (rc != 0)
|
2014-02-03 17:42:30 +08:00
|
|
|
return rc;
|
|
|
|
|
|
|
|
psw->addr = __rewind_psw(*psw, 4);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handle_partial_execution(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
if (vcpu->arch.sie_block->ipa == 0xb254) /* MVPG */
|
|
|
|
return handle_mvpg_pei(vcpu);
|
2014-02-21 15:59:59 +08:00
|
|
|
if (vcpu->arch.sie_block->ipa >> 8 == 0xae) /* SIGP */
|
|
|
|
return kvm_s390_handle_sigp_pei(vcpu);
|
2014-02-03 17:42:30 +08:00
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2010-01-21 19:19:07 +08:00
|
|
|
static const intercept_handler_t intercept_funcs[] = {
|
2008-03-26 01:47:23 +08:00
|
|
|
[0x00 >> 2] = handle_noop,
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
[0x04 >> 2] = handle_instruction,
|
|
|
|
[0x08 >> 2] = handle_prog,
|
|
|
|
[0x0C >> 2] = handle_instruction_and_prog,
|
2008-03-26 01:47:23 +08:00
|
|
|
[0x10 >> 2] = handle_noop,
|
2014-01-15 23:46:07 +08:00
|
|
|
[0x14 >> 2] = handle_external_interrupt,
|
2012-12-20 22:32:12 +08:00
|
|
|
[0x18 >> 2] = handle_noop,
|
KVM: s390: interrupt subsystem, cpu timer, waitpsw
This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).
In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.
This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.
The following interrupts are supported:
SIGP STOP - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
(stopped) remote cpu
INT EMERGENCY - interprocessor interrupt, usually used to signal need_reshed
and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
service processor
struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.
kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.
[christian: change virtio interrupt to 0x2603]
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
2008-03-26 01:47:26 +08:00
|
|
|
[0x1C >> 2] = kvm_s390_handle_wait,
|
2008-03-26 01:47:23 +08:00
|
|
|
[0x20 >> 2] = handle_validity,
|
|
|
|
[0x28 >> 2] = handle_stop,
|
2014-02-03 17:42:30 +08:00
|
|
|
[0x38 >> 2] = handle_partial_execution,
|
2008-03-26 01:47:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
intercept_handler_t func;
|
|
|
|
u8 code = vcpu->arch.sie_block->icptcode;
|
|
|
|
|
2010-01-21 19:19:07 +08:00
|
|
|
if (code & 3 || (code >> 2) >= ARRAY_SIZE(intercept_funcs))
|
2010-02-27 05:37:41 +08:00
|
|
|
return -EOPNOTSUPP;
|
2008-03-26 01:47:23 +08:00
|
|
|
func = intercept_funcs[code >> 2];
|
|
|
|
if (func)
|
|
|
|
return func(vcpu);
|
2010-02-27 05:37:41 +08:00
|
|
|
return -EOPNOTSUPP;
|
2008-03-26 01:47:23 +08:00
|
|
|
}
|