aboutsummaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
Diffstat (limited to 'target')
-rw-r--r--target/s390x/kvm/kvm.c33
-rw-r--r--target/s390x/kvm/trace-events7
-rw-r--r--target/s390x/tcg/translate_vx.c.inc6
-rw-r--r--target/s390x/tcg/vec_helper.c2
-rw-r--r--target/s390x/tcg/vec_string_helper.c54
5 files changed, 39 insertions, 63 deletions
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index a9e5880..c47a4a2 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -52,16 +52,6 @@
#include "hw/s390x/s390-virtio-hcall.h"
#include "target/s390x/kvm/pv.h"
-#ifndef DEBUG_KVM
-#define DEBUG_KVM 0
-#endif
-
-#define DPRINTF(fmt, ...) do { \
- if (DEBUG_KVM) { \
- fprintf(stderr, fmt, ## __VA_ARGS__); \
- } \
-} while (0)
-
#define kvm_vm_check_mem_attr(s, attr) \
kvm_vm_check_attr(s, KVM_S390_VM_MEM_CTRL, attr)
@@ -912,11 +902,11 @@ static void determine_sw_breakpoint_instr(void)
if (kvm_vm_enable_cap(kvm_state, KVM_CAP_S390_USER_INSTR0, 0)) {
sw_bp_inst = diag_501;
sw_bp_ilen = sizeof(diag_501);
- DPRINTF("KVM: will use 4-byte sw breakpoints.\n");
+ trace_kvm_sw_breakpoint(4);
} else {
sw_bp_inst = instr_0x0000;
sw_bp_ilen = sizeof(instr_0x0000);
- DPRINTF("KVM: will use 2-byte sw breakpoints.\n");
+ trace_kvm_sw_breakpoint(2);
}
}
@@ -1307,7 +1297,7 @@ static int handle_b2(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
break;
default:
rc = -1;
- DPRINTF("KVM: unhandled PRIV: 0xb2%x\n", ipa1);
+ trace_kvm_insn_unhandled_priv(ipa1);
break;
}
@@ -1487,7 +1477,7 @@ static int handle_b9(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
break;
default:
r = -1;
- DPRINTF("KVM: unhandled PRIV: 0xb9%x\n", ipa1);
+ trace_kvm_insn_unhandled_priv(ipa1);
break;
}
@@ -1511,7 +1501,7 @@ static int handle_eb(S390CPU *cpu, struct kvm_run *run, uint8_t ipbl)
break;
default:
r = -1;
- DPRINTF("KVM: unhandled PRIV: 0xeb%x\n", ipbl);
+ trace_kvm_insn_unhandled_priv(ipbl);
break;
}
@@ -1531,7 +1521,7 @@ static int handle_e3(S390CPU *cpu, struct kvm_run *run, uint8_t ipbl)
break;
default:
r = -1;
- DPRINTF("KVM: unhandled PRIV: 0xe3%x\n", ipbl);
+ trace_kvm_insn_unhandled_priv(ipbl);
break;
}
@@ -1654,7 +1644,7 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb)
r = handle_sw_breakpoint(cpu, run);
break;
default:
- DPRINTF("KVM: unknown DIAG: 0x%x\n", func_code);
+ trace_kvm_insn_diag(func_code);
kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION);
break;
}
@@ -1684,8 +1674,7 @@ static int handle_instruction(S390CPU *cpu, struct kvm_run *run)
uint8_t ipa1 = run->s390_sieic.ipa & 0x00ff;
int r = -1;
- DPRINTF("handle_instruction 0x%x 0x%x\n",
- run->s390_sieic.ipa, run->s390_sieic.ipb);
+ trace_kvm_insn(run->s390_sieic.ipa, run->s390_sieic.ipb);
switch (ipa0) {
case IPA0_B2:
r = handle_b2(cpu, run, ipa1);
@@ -1765,7 +1754,7 @@ static int handle_intercept(S390CPU *cpu)
int icpt_code = run->s390_sieic.icptcode;
int r = 0;
- DPRINTF("intercept: 0x%x (at 0x%lx)\n", icpt_code, (long)run->psw_addr);
+ trace_kvm_intercept(icpt_code, (long)run->psw_addr);
switch (icpt_code) {
case ICPT_INSTRUCTION:
case ICPT_PV_INSTR:
@@ -2150,13 +2139,13 @@ int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
uint32_t vec = data & ZPCI_MSI_VEC_MASK;
if (!dev) {
- DPRINTF("add_msi_route no pci device\n");
+ trace_kvm_msi_route_fixup("no pci device");
return -ENODEV;
}
pbdev = s390_pci_find_dev_by_target(s390_get_phb(), DEVICE(dev)->id);
if (!pbdev) {
- DPRINTF("add_msi_route no zpci device\n");
+ trace_kvm_msi_route_fixup("no zpci device");
return -ENODEV;
}
diff --git a/target/s390x/kvm/trace-events b/target/s390x/kvm/trace-events
index 5289f5f..818f1a3 100644
--- a/target/s390x/kvm/trace-events
+++ b/target/s390x/kvm/trace-events
@@ -5,3 +5,10 @@ kvm_enable_cmma(int rc) "CMMA: enabling with result code %d"
kvm_clear_cmma(int rc) "CMMA: clearing with result code %d"
kvm_failed_cpu_state_set(int cpu_index, uint8_t state, const char *msg) "Warning: Unable to set cpu %d state %" PRIu8 " to KVM: %s"
kvm_assign_subch_ioeventfd(int fd, uint32_t addr, bool assign, int datamatch) "fd: %d sch: @0x%x assign: %d vq: %d"
+
+kvm_sw_breakpoint(uint32_t n) "KVM: will use %d-byte sw breakpoints"
+kvm_insn_unhandled_priv(uint32_t x) "KVM: unhandled PRIV: 0x%x"
+kvm_insn_diag(uint32_t x) "KVM: unknown DIAG: 0x%x"
+kvm_insn(uint32_t ipa, uint32_t ipb) "handle_instruction 0x%x 0x%x"
+kvm_intercept(uint32_t icpt_code, uint64_t psw_addr) "intercept: 0x%x (at 0x%"PRIx64"lx)"
+kvm_msi_route_fixup(const char* msg) "%s"
diff --git a/target/s390x/tcg/translate_vx.c.inc b/target/s390x/tcg/translate_vx.c.inc
index f8df121..ec94d39 100644
--- a/target/s390x/tcg/translate_vx.c.inc
+++ b/target/s390x/tcg/translate_vx.c.inc
@@ -57,7 +57,7 @@
#define FPF_LONG 3
#define FPF_EXT 4
-static inline bool valid_vec_element(uint8_t enr, MemOp es)
+static inline bool valid_vec_element(uint16_t enr, MemOp es)
{
return !(enr & ~(NUM_VEC_ELEMENTS(es) - 1));
}
@@ -964,7 +964,7 @@ static DisasJumpType op_vpdi(DisasContext *s, DisasOps *o)
static DisasJumpType op_vrep(DisasContext *s, DisasOps *o)
{
- const uint8_t enr = get_field(s, i2);
+ const uint16_t enr = get_field(s, i2);
const uint8_t es = get_field(s, m4);
if (es > ES_64 || !valid_vec_element(enr, es)) {
@@ -3047,7 +3047,7 @@ static DisasJumpType op_vfmax(DisasContext *s, DisasOps *o)
const uint8_t m5 = get_field(s, m5);
gen_helper_gvec_3_ptr *fn;
- if (m6 == 5 || m6 == 6 || m6 == 7 || m6 >= 13) {
+ if (m6 == 5 || m6 == 6 || m6 == 7 || m6 >= 13 || (m5 & 7)) {
gen_program_exception(s, PGM_SPECIFICATION);
return DISAS_NORETURN;
}
diff --git a/target/s390x/tcg/vec_helper.c b/target/s390x/tcg/vec_helper.c
index 48d8672..dafc4c3 100644
--- a/target/s390x/tcg/vec_helper.c
+++ b/target/s390x/tcg/vec_helper.c
@@ -193,7 +193,7 @@ void HELPER(vstl)(CPUS390XState *env, const void *v1, uint64_t addr,
uint64_t bytes)
{
/* Probe write access before actually modifying memory */
- probe_write_access(env, addr, bytes, GETPC());
+ probe_write_access(env, addr, MIN(bytes, 16), GETPC());
if (likely(bytes >= 16)) {
cpu_stq_data_ra(env, addr, s390_vec_read_element64(v1, 0), GETPC());
diff --git a/target/s390x/tcg/vec_string_helper.c b/target/s390x/tcg/vec_string_helper.c
index 9b85bec..a19f429 100644
--- a/target/s390x/tcg/vec_string_helper.c
+++ b/target/s390x/tcg/vec_string_helper.c
@@ -474,9 +474,9 @@ DEF_VSTRC_CC_RT_HELPER(32)
static int vstrs(S390Vector *v1, const S390Vector *v2, const S390Vector *v3,
const S390Vector *v4, uint8_t es, bool zs)
{
- int substr_elen, substr_0, str_elen, i, j, k, cc;
+ int substr_elen, i, j, k, cc;
int nelem = 16 >> es;
- bool eos = false;
+ int str_leftmost_0;
substr_elen = s390_vec_read_element8(v4, 7) >> es;
@@ -498,47 +498,20 @@ static int vstrs(S390Vector *v1, const S390Vector *v2, const S390Vector *v3,
}
/* If ZS, look for eos in the searched string. */
+ str_leftmost_0 = nelem;
if (zs) {
for (k = 0; k < nelem; k++) {
if (s390_vec_read_element(v2, k, es) == 0) {
- eos = true;
+ str_leftmost_0 = k;
break;
}
}
- str_elen = k;
- } else {
- str_elen = nelem;
}
- substr_0 = s390_vec_read_element(v3, 0, es);
-
- for (k = 0; ; k++) {
- for (; k < str_elen; k++) {
- if (s390_vec_read_element(v2, k, es) == substr_0) {
- break;
- }
- }
-
- /* If we reached the end of the string, no match. */
- if (k == str_elen) {
- cc = eos; /* no match (with or without zero char) */
- goto done;
- }
-
- /* If the substring is only one char, match. */
- if (substr_elen == 1) {
- cc = 2; /* full match */
- goto done;
- }
-
- /* If the match begins at the last char, we have a partial match. */
- if (k == str_elen - 1) {
- cc = 3; /* partial match */
- goto done;
- }
-
+ cc = str_leftmost_0 == nelem ? 0 : 1; /* No match. */
+ for (k = 0; k < nelem; k++) {
i = MIN(nelem, k + substr_elen);
- for (j = k + 1; j < i; j++) {
+ for (j = k; j < i; j++) {
uint32_t e2 = s390_vec_read_element(v2, j, es);
uint32_t e3 = s390_vec_read_element(v3, j - k, es);
if (e2 != e3) {
@@ -546,9 +519,16 @@ static int vstrs(S390Vector *v1, const S390Vector *v2, const S390Vector *v3,
}
}
if (j == i) {
- /* Matched up until "end". */
- cc = i - k == substr_elen ? 2 : 3; /* full or partial match */
- goto done;
+ /* All elements matched. */
+ if (k > str_leftmost_0) {
+ cc = 1; /* Ignored match. */
+ k = nelem;
+ } else if (i - k == substr_elen) {
+ cc = 2; /* Full match. */
+ } else {
+ cc = 3; /* Partial match. */
+ }
+ break;
}
}