2013-01-24 03:28:03 +01:00
|
|
|
/*
|
|
|
|
* I/O instructions for S/390
|
|
|
|
*
|
2015-02-12 18:09:33 +01:00
|
|
|
* Copyright 2012, 2015 IBM Corp.
|
2013-01-24 03:28:03 +01:00
|
|
|
* Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or (at
|
|
|
|
* your option) any later version. See the COPYING file in the top-level
|
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:00 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-01-24 03:28:03 +01:00
|
|
|
|
|
|
|
#include "cpu.h"
|
2021-07-07 12:53:16 +02:00
|
|
|
#include "s390x-internal.h"
|
2015-12-04 12:06:26 +01:00
|
|
|
#include "hw/s390x/ioinst.h"
|
2013-01-24 03:28:05 +01:00
|
|
|
#include "trace.h"
|
2015-01-09 09:04:38 +01:00
|
|
|
#include "hw/s390x/s390-pci-bus.h"
|
2023-06-24 22:06:44 +02:00
|
|
|
#include "target/s390x/kvm/pv.h"
|
2020-03-19 14:19:17 +01:00
|
|
|
|
|
|
|
/* All I/O instructions but chsc use the s format */
|
|
|
|
static uint64_t get_address_from_regs(CPUS390XState *env, uint32_t ipb,
|
|
|
|
uint8_t *ar)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Addresses for protected guests are all offsets into the
|
|
|
|
* satellite block which holds the IO control structures. Those
|
|
|
|
* control structures are always starting at offset 0 and are
|
|
|
|
* always aligned and accessible. So we can return 0 here which
|
|
|
|
* will pass the following address checks.
|
|
|
|
*/
|
|
|
|
if (s390_is_pv()) {
|
|
|
|
*ar = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return decode_basedisp_s(env, ipb, ar);
|
|
|
|
}
|
2013-01-24 03:28:03 +01:00
|
|
|
|
|
|
|
int ioinst_disassemble_sch_ident(uint32_t value, int *m, int *cssid, int *ssid,
|
|
|
|
int *schid)
|
|
|
|
{
|
|
|
|
if (!IOINST_SCHID_ONE(value)) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
if (!IOINST_SCHID_M(value)) {
|
|
|
|
if (IOINST_SCHID_CSSID(value)) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
*cssid = 0;
|
|
|
|
*m = 0;
|
|
|
|
} else {
|
|
|
|
*cssid = IOINST_SCHID_CSSID(value);
|
|
|
|
*m = 1;
|
|
|
|
}
|
|
|
|
*ssid = IOINST_SCHID_SSID(value);
|
|
|
|
*schid = IOINST_SCHID_NR(value);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-01-24 03:28:05 +01:00
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
int cssid, ssid, schid, m;
|
|
|
|
SubchDev *sch;
|
|
|
|
|
|
|
|
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(&cpu->env, PGM_OPERAND, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
trace_ioinst_sch_id("xsch", cssid, ssid, schid);
|
|
|
|
sch = css_find_subch(m, cssid, ssid, schid);
|
2017-10-17 16:04:50 +02:00
|
|
|
if (!sch || !css_subch_visible(sch)) {
|
|
|
|
setcc(cpu, 3);
|
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2017-10-17 16:04:50 +02:00
|
|
|
setcc(cpu, css_do_xsch(sch));
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
int cssid, ssid, schid, m;
|
|
|
|
SubchDev *sch;
|
|
|
|
|
|
|
|
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(&cpu->env, PGM_OPERAND, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
trace_ioinst_sch_id("csch", cssid, ssid, schid);
|
|
|
|
sch = css_find_subch(m, cssid, ssid, schid);
|
2017-10-17 16:04:51 +02:00
|
|
|
if (!sch || !css_subch_visible(sch)) {
|
|
|
|
setcc(cpu, 3);
|
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2017-10-17 16:04:51 +02:00
|
|
|
setcc(cpu, css_do_csch(sch));
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
int cssid, ssid, schid, m;
|
|
|
|
SubchDev *sch;
|
|
|
|
|
|
|
|
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(&cpu->env, PGM_OPERAND, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
trace_ioinst_sch_id("hsch", cssid, ssid, schid);
|
|
|
|
sch = css_find_subch(m, cssid, ssid, schid);
|
2017-10-17 16:04:52 +02:00
|
|
|
if (!sch || !css_subch_visible(sch)) {
|
|
|
|
setcc(cpu, 3);
|
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2017-10-17 16:04:52 +02:00
|
|
|
setcc(cpu, css_do_hsch(sch));
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ioinst_schib_valid(SCHIB *schib)
|
|
|
|
{
|
2015-06-15 17:57:01 +02:00
|
|
|
if ((be16_to_cpu(schib->pmcw.flags) & PMCW_FLAGS_MASK_INVALID) ||
|
|
|
|
(be32_to_cpu(schib->pmcw.chars) & PMCW_CHARS_MASK_INVALID)) {
|
2013-01-24 03:28:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* Disallow extended measurements for now. */
|
2015-06-15 17:57:01 +02:00
|
|
|
if (be32_to_cpu(schib->pmcw.chars) & PMCW_CHARS_MASK_XMWME) {
|
2013-01-24 03:28:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2021-02-19 14:39:33 +01:00
|
|
|
/* for MB format 1 bits 26-31 of word 11 must be 0 */
|
|
|
|
/* MBA uses words 10 and 11, it means align on 2**6 */
|
2021-08-05 16:37:53 +02:00
|
|
|
if ((be32_to_cpu(schib->pmcw.chars) & PMCW_CHARS_MASK_MBFC) &&
|
2021-02-19 14:39:33 +01:00
|
|
|
(be64_to_cpu(schib->mba) & 0x03fUL)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-01-24 03:28:05 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
int cssid, ssid, schid, m;
|
|
|
|
SubchDev *sch;
|
2015-02-12 18:09:33 +01:00
|
|
|
SCHIB schib;
|
2013-01-24 03:28:05 +01:00
|
|
|
uint64_t addr;
|
2013-07-01 15:44:18 +02:00
|
|
|
CPUS390XState *env = &cpu->env;
|
2015-03-05 10:36:48 +01:00
|
|
|
uint8_t ar;
|
2013-01-24 03:28:05 +01:00
|
|
|
|
2020-03-19 14:19:17 +01:00
|
|
|
addr = get_address_from_regs(env, ipb, &ar);
|
2013-06-21 10:13:42 +02:00
|
|
|
if (addr & 3) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_SPECIFICATION, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-06-21 10:13:42 +02:00
|
|
|
}
|
2020-03-19 14:19:18 +01:00
|
|
|
if (s390_is_pv()) {
|
|
|
|
s390_cpu_pv_mem_read(cpu, addr, &schib, sizeof(schib));
|
|
|
|
} else if (s390_cpu_virt_mem_read(cpu, addr, ar, &schib, sizeof(schib))) {
|
2017-11-30 17:27:35 +01:00
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
2015-02-12 18:09:33 +01:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2013-06-25 14:59:12 +02:00
|
|
|
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid) ||
|
2015-02-12 18:09:33 +01:00
|
|
|
!ioinst_schib_valid(&schib)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_OPERAND, ra);
|
2015-02-12 18:09:33 +01:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2013-06-25 14:59:12 +02:00
|
|
|
trace_ioinst_sch_id("msch", cssid, ssid, schid);
|
2013-01-24 03:28:05 +01:00
|
|
|
sch = css_find_subch(m, cssid, ssid, schid);
|
2017-10-17 16:04:53 +02:00
|
|
|
if (!sch || !css_subch_visible(sch)) {
|
|
|
|
setcc(cpu, 3);
|
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2017-10-17 16:04:53 +02:00
|
|
|
setcc(cpu, css_do_msch(sch, &schib));
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_orb_from_guest(ORB *dest, const ORB *src)
|
|
|
|
{
|
|
|
|
dest->intparm = be32_to_cpu(src->intparm);
|
|
|
|
dest->ctrl0 = be16_to_cpu(src->ctrl0);
|
|
|
|
dest->lpm = src->lpm;
|
|
|
|
dest->ctrl1 = src->ctrl1;
|
|
|
|
dest->cpa = be32_to_cpu(src->cpa);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ioinst_orb_valid(ORB *orb)
|
|
|
|
{
|
|
|
|
if ((orb->ctrl0 & ORB_CTRL0_MASK_INVALID) ||
|
|
|
|
(orb->ctrl1 & ORB_CTRL1_MASK_INVALID)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2017-05-24 14:06:12 +02:00
|
|
|
/* We don't support MIDA. */
|
|
|
|
if (orb->ctrl1 & ORB_CTRL1_MASK_MIDAW) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-01-24 03:28:05 +01:00
|
|
|
if ((orb->cpa & HIGH_ORDER_BIT) != 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
int cssid, ssid, schid, m;
|
|
|
|
SubchDev *sch;
|
2015-02-12 18:09:34 +01:00
|
|
|
ORB orig_orb, orb;
|
2013-01-24 03:28:05 +01:00
|
|
|
uint64_t addr;
|
2013-07-01 15:44:18 +02:00
|
|
|
CPUS390XState *env = &cpu->env;
|
2015-03-05 10:36:48 +01:00
|
|
|
uint8_t ar;
|
2013-01-24 03:28:05 +01:00
|
|
|
|
2020-03-19 14:19:17 +01:00
|
|
|
addr = get_address_from_regs(env, ipb, &ar);
|
2013-06-21 10:13:42 +02:00
|
|
|
if (addr & 3) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_SPECIFICATION, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-06-21 10:13:42 +02:00
|
|
|
}
|
2020-03-19 14:19:18 +01:00
|
|
|
if (s390_is_pv()) {
|
|
|
|
s390_cpu_pv_mem_read(cpu, addr, &orig_orb, sizeof(orb));
|
|
|
|
} else if (s390_cpu_virt_mem_read(cpu, addr, ar, &orig_orb, sizeof(orb))) {
|
2017-11-30 17:27:35 +01:00
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
2015-02-12 18:09:34 +01:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2015-02-12 18:09:34 +01:00
|
|
|
copy_orb_from_guest(&orb, &orig_orb);
|
2013-06-25 14:59:12 +02:00
|
|
|
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid) ||
|
|
|
|
!ioinst_orb_valid(&orb)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_OPERAND, ra);
|
2015-02-12 18:09:34 +01:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2013-06-25 14:59:12 +02:00
|
|
|
trace_ioinst_sch_id("ssch", cssid, ssid, schid);
|
2013-01-24 03:28:05 +01:00
|
|
|
sch = css_find_subch(m, cssid, ssid, schid);
|
2017-10-17 16:04:49 +02:00
|
|
|
if (!sch || !css_subch_visible(sch)) {
|
|
|
|
setcc(cpu, 3);
|
2017-05-17 02:48:11 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2017-10-17 16:04:49 +02:00
|
|
|
setcc(cpu, css_do_ssch(sch, &orb));
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
2015-02-12 18:09:38 +01:00
|
|
|
CRW crw;
|
2013-01-24 03:28:05 +01:00
|
|
|
uint64_t addr;
|
|
|
|
int cc;
|
2013-07-01 15:44:18 +02:00
|
|
|
CPUS390XState *env = &cpu->env;
|
2015-03-05 10:36:48 +01:00
|
|
|
uint8_t ar;
|
2013-01-24 03:28:05 +01:00
|
|
|
|
2020-03-19 14:19:17 +01:00
|
|
|
addr = get_address_from_regs(env, ipb, &ar);
|
2013-06-21 10:13:42 +02:00
|
|
|
if (addr & 3) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_SPECIFICATION, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-06-21 10:13:42 +02:00
|
|
|
}
|
2015-02-12 18:09:38 +01:00
|
|
|
|
|
|
|
cc = css_do_stcrw(&crw);
|
2013-01-24 03:28:05 +01:00
|
|
|
/* 0 - crw stored, 1 - zeroes stored */
|
2013-07-01 15:44:18 +02:00
|
|
|
|
2020-03-19 14:19:18 +01:00
|
|
|
if (s390_is_pv()) {
|
|
|
|
s390_cpu_pv_mem_write(cpu, addr, &crw, sizeof(crw));
|
2015-02-12 18:09:38 +01:00
|
|
|
setcc(cpu, cc);
|
2017-11-30 17:27:35 +01:00
|
|
|
} else {
|
2020-03-19 14:19:18 +01:00
|
|
|
if (s390_cpu_virt_mem_write(cpu, addr, ar, &crw, sizeof(crw)) == 0) {
|
|
|
|
setcc(cpu, cc);
|
|
|
|
} else {
|
|
|
|
if (cc == 0) {
|
|
|
|
/* Write failed: requeue CRW since STCRW is suppressing */
|
|
|
|
css_undo_stcrw(&crw);
|
|
|
|
}
|
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
2017-11-30 17:27:35 +01:00
|
|
|
}
|
2015-02-12 18:09:38 +01:00
|
|
|
}
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb,
|
|
|
|
uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
int cssid, ssid, schid, m;
|
|
|
|
SubchDev *sch;
|
|
|
|
uint64_t addr;
|
|
|
|
int cc;
|
2015-02-12 18:09:35 +01:00
|
|
|
SCHIB schib;
|
2013-07-01 15:44:18 +02:00
|
|
|
CPUS390XState *env = &cpu->env;
|
2015-03-05 10:36:48 +01:00
|
|
|
uint8_t ar;
|
2013-01-24 03:28:05 +01:00
|
|
|
|
2020-03-19 14:19:17 +01:00
|
|
|
addr = get_address_from_regs(env, ipb, &ar);
|
2013-06-21 10:13:42 +02:00
|
|
|
if (addr & 3) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_SPECIFICATION, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-06-21 10:13:42 +02:00
|
|
|
}
|
2013-06-25 14:59:12 +02:00
|
|
|
|
|
|
|
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
|
2020-03-19 14:19:18 +01:00
|
|
|
/*
|
|
|
|
* The Ultravisor checks schid bit 16 to be one and bits 0-12
|
|
|
|
* to be 0 and injects a operand exception itself.
|
|
|
|
*
|
|
|
|
* Hence we should never end up here.
|
|
|
|
*/
|
|
|
|
g_assert(!s390_is_pv());
|
2015-02-12 18:09:35 +01:00
|
|
|
/*
|
|
|
|
* As operand exceptions have a lower priority than access exceptions,
|
2022-06-08 20:38:47 +02:00
|
|
|
* we check whether the memory area is writable (injecting the
|
2022-11-11 19:17:33 +01:00
|
|
|
* access exception if it is not) first.
|
2015-02-12 18:09:35 +01:00
|
|
|
*/
|
2015-03-05 10:36:48 +01:00
|
|
|
if (!s390_cpu_virt_mem_check_write(cpu, addr, ar, sizeof(schib))) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_OPERAND, ra);
|
2017-11-30 17:27:35 +01:00
|
|
|
} else {
|
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
2015-02-12 18:09:35 +01:00
|
|
|
}
|
|
|
|
return;
|
2013-06-25 14:59:12 +02:00
|
|
|
}
|
|
|
|
trace_ioinst_sch_id("stsch", cssid, ssid, schid);
|
2013-01-24 03:28:05 +01:00
|
|
|
sch = css_find_subch(m, cssid, ssid, schid);
|
|
|
|
if (sch) {
|
|
|
|
if (css_subch_visible(sch)) {
|
2020-05-05 14:57:54 +02:00
|
|
|
cc = css_do_stsch(sch, &schib);
|
2013-01-24 03:28:05 +01:00
|
|
|
} else {
|
|
|
|
/* Indicate no more subchannels in this css/ss */
|
|
|
|
cc = 3;
|
|
|
|
}
|
|
|
|
} else {
|
2013-02-22 10:01:32 +01:00
|
|
|
if (css_schid_final(m, cssid, ssid, schid)) {
|
2013-01-24 03:28:05 +01:00
|
|
|
cc = 3; /* No more subchannels in this css/ss */
|
|
|
|
} else {
|
|
|
|
/* Store an empty schib. */
|
2015-02-12 18:09:35 +01:00
|
|
|
memset(&schib, 0, sizeof(schib));
|
2013-01-24 03:28:05 +01:00
|
|
|
cc = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-02-12 18:09:35 +01:00
|
|
|
if (cc != 3) {
|
2020-03-19 14:19:18 +01:00
|
|
|
if (s390_is_pv()) {
|
|
|
|
s390_cpu_pv_mem_write(cpu, addr, &schib, sizeof(schib));
|
|
|
|
} else if (s390_cpu_virt_mem_write(cpu, addr, ar, &schib,
|
|
|
|
sizeof(schib)) != 0) {
|
2017-11-30 17:27:35 +01:00
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
2015-02-12 18:09:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Access exceptions have a higher priority than cc3 */
|
2020-03-19 14:19:18 +01:00
|
|
|
if (!s390_is_pv() &&
|
|
|
|
s390_cpu_virt_mem_check_write(cpu, addr, ar, sizeof(schib)) != 0) {
|
2017-11-30 17:27:35 +01:00
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
2015-02-12 18:09:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-07-01 15:44:18 +02:00
|
|
|
setcc(cpu, cc);
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
int ioinst_handle_tsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
2015-02-12 18:09:36 +01:00
|
|
|
CPUS390XState *env = &cpu->env;
|
2013-01-24 03:28:05 +01:00
|
|
|
int cssid, ssid, schid, m;
|
|
|
|
SubchDev *sch;
|
2015-02-12 18:09:37 +01:00
|
|
|
IRB irb;
|
2013-01-24 03:28:05 +01:00
|
|
|
uint64_t addr;
|
2015-02-12 18:09:37 +01:00
|
|
|
int cc, irb_len;
|
2015-03-05 10:36:48 +01:00
|
|
|
uint8_t ar;
|
2013-01-24 03:28:05 +01:00
|
|
|
|
|
|
|
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_OPERAND, ra);
|
2013-01-24 03:28:05 +01:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
trace_ioinst_sch_id("tsch", cssid, ssid, schid);
|
2020-03-19 14:19:17 +01:00
|
|
|
addr = get_address_from_regs(env, ipb, &ar);
|
2013-06-21 10:13:42 +02:00
|
|
|
if (addr & 3) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_SPECIFICATION, ra);
|
2013-06-21 10:13:42 +02:00
|
|
|
return -EIO;
|
|
|
|
}
|
2015-02-12 18:09:37 +01:00
|
|
|
|
2013-01-24 03:28:05 +01:00
|
|
|
sch = css_find_subch(m, cssid, ssid, schid);
|
|
|
|
if (sch && css_subch_visible(sch)) {
|
2015-02-12 18:09:37 +01:00
|
|
|
cc = css_do_tsch_get_irb(sch, &irb, &irb_len);
|
2013-01-24 03:28:05 +01:00
|
|
|
} else {
|
|
|
|
cc = 3;
|
|
|
|
}
|
2015-02-12 18:09:37 +01:00
|
|
|
/* 0 - status pending, 1 - not status pending, 3 - not operational */
|
|
|
|
if (cc != 3) {
|
2020-03-19 14:19:18 +01:00
|
|
|
if (s390_is_pv()) {
|
|
|
|
s390_cpu_pv_mem_write(cpu, addr, &irb, irb_len);
|
|
|
|
} else if (s390_cpu_virt_mem_write(cpu, addr, ar, &irb, irb_len) != 0) {
|
2017-11-30 17:27:35 +01:00
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
2015-02-12 18:09:37 +01:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
css_do_tsch_update_subch(sch);
|
|
|
|
} else {
|
|
|
|
irb_len = sizeof(irb) - sizeof(irb.emw);
|
|
|
|
/* Access exceptions have a higher priority than cc3 */
|
2020-03-19 14:19:18 +01:00
|
|
|
if (!s390_is_pv() &&
|
|
|
|
s390_cpu_virt_mem_check_write(cpu, addr, ar, irb_len) != 0) {
|
2017-11-30 17:27:35 +01:00
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
2015-02-12 18:09:37 +01:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-12 18:09:36 +01:00
|
|
|
setcc(cpu, cc);
|
2015-02-12 18:09:37 +01:00
|
|
|
return 0;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct ChscReq {
|
|
|
|
uint16_t len;
|
|
|
|
uint16_t command;
|
|
|
|
uint32_t param0;
|
|
|
|
uint32_t param1;
|
|
|
|
uint32_t param2;
|
|
|
|
} QEMU_PACKED ChscReq;
|
|
|
|
|
|
|
|
typedef struct ChscResp {
|
|
|
|
uint16_t len;
|
|
|
|
uint16_t code;
|
|
|
|
uint32_t param;
|
2020-03-04 16:38:16 +01:00
|
|
|
char data[];
|
2013-01-24 03:28:05 +01:00
|
|
|
} QEMU_PACKED ChscResp;
|
|
|
|
|
|
|
|
#define CHSC_MIN_RESP_LEN 0x0008
|
|
|
|
|
|
|
|
#define CHSC_SCPD 0x0002
|
|
|
|
#define CHSC_SCSC 0x0010
|
|
|
|
#define CHSC_SDA 0x0031
|
2015-01-09 09:04:38 +01:00
|
|
|
#define CHSC_SEI 0x000e
|
2013-01-24 03:28:05 +01:00
|
|
|
|
|
|
|
#define CHSC_SCPD_0_M 0x20000000
|
|
|
|
#define CHSC_SCPD_0_C 0x10000000
|
|
|
|
#define CHSC_SCPD_0_FMT 0x0f000000
|
|
|
|
#define CHSC_SCPD_0_CSSID 0x00ff0000
|
|
|
|
#define CHSC_SCPD_0_RFMT 0x00000f00
|
|
|
|
#define CHSC_SCPD_0_RES 0xc000f000
|
|
|
|
#define CHSC_SCPD_1_RES 0xffffff00
|
|
|
|
#define CHSC_SCPD_01_CHPID 0x000000ff
|
|
|
|
static void ioinst_handle_chsc_scpd(ChscReq *req, ChscResp *res)
|
|
|
|
{
|
|
|
|
uint16_t len = be16_to_cpu(req->len);
|
|
|
|
uint32_t param0 = be32_to_cpu(req->param0);
|
|
|
|
uint32_t param1 = be32_to_cpu(req->param1);
|
|
|
|
uint16_t resp_code;
|
|
|
|
int rfmt;
|
|
|
|
uint16_t cssid;
|
|
|
|
uint8_t f_chpid, l_chpid;
|
|
|
|
int desc_size;
|
|
|
|
int m;
|
|
|
|
|
|
|
|
rfmt = (param0 & CHSC_SCPD_0_RFMT) >> 8;
|
|
|
|
if ((rfmt == 0) || (rfmt == 1)) {
|
|
|
|
rfmt = !!(param0 & CHSC_SCPD_0_C);
|
|
|
|
}
|
|
|
|
if ((len != 0x0010) || (param0 & CHSC_SCPD_0_RES) ||
|
|
|
|
(param1 & CHSC_SCPD_1_RES) || req->param2) {
|
|
|
|
resp_code = 0x0003;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
if (param0 & CHSC_SCPD_0_FMT) {
|
|
|
|
resp_code = 0x0007;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
cssid = (param0 & CHSC_SCPD_0_CSSID) >> 16;
|
|
|
|
m = param0 & CHSC_SCPD_0_M;
|
|
|
|
if (cssid != 0) {
|
|
|
|
if (!m || !css_present(cssid)) {
|
|
|
|
resp_code = 0x0008;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f_chpid = param0 & CHSC_SCPD_01_CHPID;
|
|
|
|
l_chpid = param1 & CHSC_SCPD_01_CHPID;
|
|
|
|
if (l_chpid < f_chpid) {
|
|
|
|
resp_code = 0x0003;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
/* css_collect_chp_desc() is endian-aware */
|
|
|
|
desc_size = css_collect_chp_desc(m, cssid, f_chpid, l_chpid, rfmt,
|
|
|
|
&res->data);
|
|
|
|
res->code = cpu_to_be16(0x0001);
|
|
|
|
res->len = cpu_to_be16(8 + desc_size);
|
|
|
|
res->param = cpu_to_be32(rfmt);
|
|
|
|
return;
|
|
|
|
|
|
|
|
out_err:
|
|
|
|
res->code = cpu_to_be16(resp_code);
|
|
|
|
res->len = cpu_to_be16(CHSC_MIN_RESP_LEN);
|
|
|
|
res->param = cpu_to_be32(rfmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHSC_SCSC_0_M 0x20000000
|
|
|
|
#define CHSC_SCSC_0_FMT 0x000f0000
|
|
|
|
#define CHSC_SCSC_0_CSSID 0x0000ff00
|
|
|
|
#define CHSC_SCSC_0_RES 0xdff000ff
|
|
|
|
static void ioinst_handle_chsc_scsc(ChscReq *req, ChscResp *res)
|
|
|
|
{
|
|
|
|
uint16_t len = be16_to_cpu(req->len);
|
|
|
|
uint32_t param0 = be32_to_cpu(req->param0);
|
|
|
|
uint8_t cssid;
|
|
|
|
uint16_t resp_code;
|
|
|
|
uint32_t general_chars[510];
|
|
|
|
uint32_t chsc_chars[508];
|
|
|
|
|
|
|
|
if (len != 0x0010) {
|
|
|
|
resp_code = 0x0003;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param0 & CHSC_SCSC_0_FMT) {
|
|
|
|
resp_code = 0x0007;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
cssid = (param0 & CHSC_SCSC_0_CSSID) >> 8;
|
|
|
|
if (cssid != 0) {
|
|
|
|
if (!(param0 & CHSC_SCSC_0_M) || !css_present(cssid)) {
|
|
|
|
resp_code = 0x0008;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((param0 & CHSC_SCSC_0_RES) || req->param1 || req->param2) {
|
|
|
|
resp_code = 0x0003;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
res->code = cpu_to_be16(0x0001);
|
|
|
|
res->len = cpu_to_be16(4080);
|
|
|
|
res->param = 0;
|
|
|
|
|
|
|
|
memset(general_chars, 0, sizeof(general_chars));
|
|
|
|
memset(chsc_chars, 0, sizeof(chsc_chars));
|
|
|
|
|
|
|
|
general_chars[0] = cpu_to_be32(0x03000000);
|
2016-07-13 17:43:18 +02:00
|
|
|
general_chars[1] = cpu_to_be32(0x00079000);
|
2015-10-01 19:21:33 +02:00
|
|
|
general_chars[3] = cpu_to_be32(0x00080000);
|
2013-01-24 03:28:05 +01:00
|
|
|
|
|
|
|
chsc_chars[0] = cpu_to_be32(0x40000000);
|
|
|
|
chsc_chars[3] = cpu_to_be32(0x00040000);
|
|
|
|
|
|
|
|
memcpy(res->data, general_chars, sizeof(general_chars));
|
|
|
|
memcpy(res->data + sizeof(general_chars), chsc_chars, sizeof(chsc_chars));
|
|
|
|
return;
|
|
|
|
|
|
|
|
out_err:
|
|
|
|
res->code = cpu_to_be16(resp_code);
|
|
|
|
res->len = cpu_to_be16(CHSC_MIN_RESP_LEN);
|
|
|
|
res->param = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHSC_SDA_0_FMT 0x0f000000
|
|
|
|
#define CHSC_SDA_0_OC 0x0000ffff
|
|
|
|
#define CHSC_SDA_0_RES 0xf0ff0000
|
|
|
|
#define CHSC_SDA_OC_MCSSE 0x0
|
|
|
|
#define CHSC_SDA_OC_MSS 0x2
|
|
|
|
static void ioinst_handle_chsc_sda(ChscReq *req, ChscResp *res)
|
|
|
|
{
|
|
|
|
uint16_t resp_code = 0x0001;
|
|
|
|
uint16_t len = be16_to_cpu(req->len);
|
|
|
|
uint32_t param0 = be32_to_cpu(req->param0);
|
|
|
|
uint16_t oc;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if ((len != 0x0400) || (param0 & CHSC_SDA_0_RES)) {
|
|
|
|
resp_code = 0x0003;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param0 & CHSC_SDA_0_FMT) {
|
|
|
|
resp_code = 0x0007;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
oc = param0 & CHSC_SDA_0_OC;
|
|
|
|
switch (oc) {
|
|
|
|
case CHSC_SDA_OC_MCSSE:
|
|
|
|
ret = css_enable_mcsse();
|
|
|
|
if (ret == -EINVAL) {
|
|
|
|
resp_code = 0x0101;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CHSC_SDA_OC_MSS:
|
|
|
|
ret = css_enable_mss();
|
|
|
|
if (ret == -EINVAL) {
|
|
|
|
resp_code = 0x0101;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
resp_code = 0x0003;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
res->code = cpu_to_be16(resp_code);
|
|
|
|
res->len = cpu_to_be16(CHSC_MIN_RESP_LEN);
|
|
|
|
res->param = 0;
|
|
|
|
}
|
|
|
|
|
2015-01-09 09:04:38 +01:00
|
|
|
static int chsc_sei_nt0_get_event(void *res)
|
|
|
|
{
|
|
|
|
/* no events yet */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int chsc_sei_nt0_have_event(void)
|
|
|
|
{
|
|
|
|
/* no events yet */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-07-06 16:40:21 +02:00
|
|
|
static int chsc_sei_nt2_get_event(void *res)
|
|
|
|
{
|
|
|
|
if (s390_has_feat(S390_FEAT_ZPCI)) {
|
|
|
|
return pci_chsc_sei_nt2_get_event(res);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int chsc_sei_nt2_have_event(void)
|
|
|
|
{
|
|
|
|
if (s390_has_feat(S390_FEAT_ZPCI)) {
|
|
|
|
return pci_chsc_sei_nt2_have_event();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-01-09 09:04:38 +01:00
|
|
|
#define CHSC_SEI_NT0 (1ULL << 63)
|
|
|
|
#define CHSC_SEI_NT2 (1ULL << 61)
|
|
|
|
static void ioinst_handle_chsc_sei(ChscReq *req, ChscResp *res)
|
|
|
|
{
|
|
|
|
uint64_t selection_mask = ldq_p(&req->param1);
|
|
|
|
uint8_t *res_flags = (uint8_t *)res->data;
|
|
|
|
int have_event = 0;
|
|
|
|
int have_more = 0;
|
|
|
|
|
|
|
|
/* regarding architecture nt0 can not be masked */
|
|
|
|
have_event = !chsc_sei_nt0_get_event(res);
|
|
|
|
have_more = chsc_sei_nt0_have_event();
|
|
|
|
|
|
|
|
if (selection_mask & CHSC_SEI_NT2) {
|
|
|
|
if (!have_event) {
|
|
|
|
have_event = !chsc_sei_nt2_get_event(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!have_more) {
|
|
|
|
have_more = chsc_sei_nt2_have_event();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (have_event) {
|
|
|
|
res->code = cpu_to_be16(0x0001);
|
|
|
|
if (have_more) {
|
|
|
|
(*res_flags) |= 0x80;
|
|
|
|
} else {
|
|
|
|
(*res_flags) &= ~0x80;
|
2016-01-19 02:55:00 +01:00
|
|
|
css_clear_sei_pending();
|
2015-01-09 09:04:38 +01:00
|
|
|
}
|
|
|
|
} else {
|
2016-01-14 13:29:53 +01:00
|
|
|
res->code = cpu_to_be16(0x0005);
|
|
|
|
res->len = cpu_to_be16(CHSC_MIN_RESP_LEN);
|
2015-01-09 09:04:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 03:28:05 +01:00
|
|
|
static void ioinst_handle_chsc_unimplemented(ChscResp *res)
|
|
|
|
{
|
|
|
|
res->len = cpu_to_be16(CHSC_MIN_RESP_LEN);
|
|
|
|
res->code = cpu_to_be16(0x0004);
|
|
|
|
res->param = 0;
|
|
|
|
}
|
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
ChscReq *req;
|
|
|
|
ChscResp *res;
|
2020-03-19 14:19:17 +01:00
|
|
|
uint64_t addr = 0;
|
2013-01-24 03:28:05 +01:00
|
|
|
int reg;
|
|
|
|
uint16_t len;
|
|
|
|
uint16_t command;
|
2013-07-01 15:44:18 +02:00
|
|
|
CPUS390XState *env = &cpu->env;
|
2015-02-12 18:09:39 +01:00
|
|
|
uint8_t buf[TARGET_PAGE_SIZE];
|
2013-01-24 03:28:05 +01:00
|
|
|
|
|
|
|
trace_ioinst("chsc");
|
|
|
|
reg = (ipb >> 20) & 0x00f;
|
2020-03-19 14:19:17 +01:00
|
|
|
if (!s390_is_pv()) {
|
|
|
|
addr = env->regs[reg];
|
|
|
|
}
|
2013-01-24 03:28:05 +01:00
|
|
|
/* Page boundary? */
|
|
|
|
if (addr & 0xfff) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_SPECIFICATION, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2015-02-12 18:09:39 +01:00
|
|
|
/*
|
|
|
|
* Reading sizeof(ChscReq) bytes is currently enough for all of our
|
|
|
|
* present CHSC sub-handlers ... if we ever need more, we should take
|
|
|
|
* care of req->len here first.
|
|
|
|
*/
|
2020-03-19 14:19:18 +01:00
|
|
|
if (s390_is_pv()) {
|
|
|
|
s390_cpu_pv_mem_read(cpu, addr, buf, sizeof(ChscReq));
|
|
|
|
} else if (s390_cpu_virt_mem_read(cpu, addr, reg, buf, sizeof(ChscReq))) {
|
2017-11-30 17:27:35 +01:00
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
2015-02-12 18:09:39 +01:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2015-02-12 18:09:39 +01:00
|
|
|
req = (ChscReq *)buf;
|
2013-01-24 03:28:05 +01:00
|
|
|
len = be16_to_cpu(req->len);
|
|
|
|
/* Length field valid? */
|
|
|
|
if ((len < 16) || (len > 4088) || (len & 7)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_OPERAND, ra);
|
2015-02-12 18:09:39 +01:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
memset((char *)req + len, 0, TARGET_PAGE_SIZE - len);
|
|
|
|
res = (void *)((char *)req + len);
|
|
|
|
command = be16_to_cpu(req->command);
|
|
|
|
trace_ioinst_chsc_cmd(command, len);
|
|
|
|
switch (command) {
|
|
|
|
case CHSC_SCSC:
|
|
|
|
ioinst_handle_chsc_scsc(req, res);
|
|
|
|
break;
|
|
|
|
case CHSC_SCPD:
|
|
|
|
ioinst_handle_chsc_scpd(req, res);
|
|
|
|
break;
|
|
|
|
case CHSC_SDA:
|
|
|
|
ioinst_handle_chsc_sda(req, res);
|
|
|
|
break;
|
2015-01-09 09:04:38 +01:00
|
|
|
case CHSC_SEI:
|
|
|
|
ioinst_handle_chsc_sei(req, res);
|
|
|
|
break;
|
2013-01-24 03:28:05 +01:00
|
|
|
default:
|
|
|
|
ioinst_handle_chsc_unimplemented(res);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-03-19 14:19:18 +01:00
|
|
|
if (s390_is_pv()) {
|
|
|
|
s390_cpu_pv_mem_write(cpu, addr + len, res, be16_to_cpu(res->len));
|
2015-02-12 18:09:39 +01:00
|
|
|
setcc(cpu, 0); /* Command execution complete */
|
2017-11-30 17:27:35 +01:00
|
|
|
} else {
|
2020-03-19 14:19:18 +01:00
|
|
|
if (!s390_cpu_virt_mem_write(cpu, addr + len, reg, res,
|
|
|
|
be16_to_cpu(res->len))) {
|
|
|
|
setcc(cpu, 0); /* Command execution complete */
|
|
|
|
} else {
|
|
|
|
s390_cpu_virt_mem_handle_exc(cpu, ra);
|
|
|
|
}
|
2015-02-12 18:09:39 +01:00
|
|
|
}
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SCHM_REG1_RES(_reg) (_reg & 0x000000000ffffffc)
|
|
|
|
#define SCHM_REG1_MBK(_reg) ((_reg & 0x00000000f0000000) >> 28)
|
|
|
|
#define SCHM_REG1_UPD(_reg) ((_reg & 0x0000000000000002) >> 1)
|
|
|
|
#define SCHM_REG1_DCT(_reg) (_reg & 0x0000000000000001)
|
|
|
|
|
2013-07-01 15:44:18 +02:00
|
|
|
void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, uint64_t reg2,
|
2017-11-30 17:27:32 +01:00
|
|
|
uint32_t ipb, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
uint8_t mbk;
|
|
|
|
int update;
|
|
|
|
int dct;
|
2013-07-01 15:44:18 +02:00
|
|
|
CPUS390XState *env = &cpu->env;
|
2013-01-24 03:28:05 +01:00
|
|
|
|
|
|
|
trace_ioinst("schm");
|
|
|
|
|
|
|
|
if (SCHM_REG1_RES(reg1)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_OPERAND, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mbk = SCHM_REG1_MBK(reg1);
|
|
|
|
update = SCHM_REG1_UPD(reg1);
|
|
|
|
dct = SCHM_REG1_DCT(reg1);
|
|
|
|
|
2013-06-21 15:57:31 +02:00
|
|
|
if (update && (reg2 & 0x000000000000001f)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_OPERAND, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
css_do_schm(mbk, update, dct, update ? reg2 : 0);
|
|
|
|
}
|
|
|
|
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
int cssid, ssid, schid, m;
|
|
|
|
SubchDev *sch;
|
|
|
|
|
|
|
|
if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(&cpu->env, PGM_OPERAND, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
trace_ioinst_sch_id("rsch", cssid, ssid, schid);
|
|
|
|
sch = css_find_subch(m, cssid, ssid, schid);
|
2017-10-17 16:04:49 +02:00
|
|
|
if (!sch || !css_subch_visible(sch)) {
|
|
|
|
setcc(cpu, 3);
|
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2017-10-17 16:04:49 +02:00
|
|
|
setcc(cpu, css_do_rsch(sch));
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define RCHP_REG1_RES(_reg) (_reg & 0x00000000ff00ff00)
|
|
|
|
#define RCHP_REG1_CSSID(_reg) ((_reg & 0x0000000000ff0000) >> 16)
|
|
|
|
#define RCHP_REG1_CHPID(_reg) (_reg & 0x00000000000000ff)
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_rchp(S390CPU *cpu, uint64_t reg1, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
int cc;
|
|
|
|
uint8_t cssid;
|
|
|
|
uint8_t chpid;
|
|
|
|
int ret;
|
2013-07-01 15:44:18 +02:00
|
|
|
CPUS390XState *env = &cpu->env;
|
2013-01-24 03:28:05 +01:00
|
|
|
|
|
|
|
if (RCHP_REG1_RES(reg1)) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_OPERAND, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cssid = RCHP_REG1_CSSID(reg1);
|
|
|
|
chpid = RCHP_REG1_CHPID(reg1);
|
|
|
|
|
|
|
|
trace_ioinst_chp_id("rchp", cssid, chpid);
|
|
|
|
|
|
|
|
ret = css_do_rchp(cssid, chpid);
|
|
|
|
|
|
|
|
switch (ret) {
|
|
|
|
case -ENODEV:
|
|
|
|
cc = 3;
|
|
|
|
break;
|
|
|
|
case -EBUSY:
|
|
|
|
cc = 2;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
cc = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Invalid channel subsystem. */
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(env, PGM_OPERAND, ra);
|
2013-07-01 15:44:18 +02:00
|
|
|
return;
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
2013-07-01 15:44:18 +02:00
|
|
|
setcc(cpu, cc);
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SAL_REG1_INVALID(_reg) (_reg & 0x0000000080000000)
|
2017-11-30 17:27:32 +01:00
|
|
|
void ioinst_handle_sal(S390CPU *cpu, uint64_t reg1, uintptr_t ra)
|
2013-01-24 03:28:05 +01:00
|
|
|
{
|
|
|
|
/* We do not provide address limit checking, so let's suppress it. */
|
|
|
|
if (SAL_REG1_INVALID(reg1) || reg1 & 0x000000000000ffff) {
|
2019-10-01 19:15:59 +02:00
|
|
|
s390_program_interrupt(&cpu->env, PGM_OPERAND, ra);
|
2013-01-24 03:28:05 +01:00
|
|
|
}
|
|
|
|
}
|