s390x fixes and cleanups; also related fixes in xtensa,

arm, and x86 code
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEEw9DWbcNiT/aowBjO3s9rk8bwL68FAmCmVLMSHGNvaHVja0By
 ZWRoYXQuY29tAAoJEN7Pa5PG8C+vihcP/2yiwThQBll+ZDKYimRu91hMkmty+24c
 F3YNv+6HnKTmnFPoo35O1iH4phd5LVZJTVicOl+XAw75DzFMpwMh8ukfq4hIYvPY
 9QSYdDBj/JX0CHTo0u2Wl92dr87vsVGwMwgqojnNZXUOMYyQGpDT/RgHqTfoCzNH
 Dl6/MqgmTNBSCZGS6GOfkmUC6bT9ZTaiSHpXPJCfvgpANDG6l2Mblz8ihcOjygoP
 e8KVXKERoUGViT+MXTAJLUlMu6valDFY6pZUh6u3EOzqqLSRXrAJACLz+zv77X7P
 Ryn03md1KWj0PRh8eEC/VfadeRbIXHrhw5T8oK8HwHW4VErL5fcAwt1EybRNWe6U
 UEj446qT37hwA9TthqZtZiR+aZHO70JRmf0svnxXaM6WepRVxzwHexDnKNi6gJvd
 cdH+yIcIzu5fEnoHNC0famYdJT4f+hmPj2r+FtbMWZXLRxMT26p4mlE0joY7EjOg
 saGBlGSdHTcSGk2X7RV/iX38s/BYpOuYM6dsi6EKn3Z1/vQbvrJ9ZZWaDDhmykJE
 1n4nOgwj7kOolNw3VlJOEBhJvozh1mf9Sr0SsXEAQQYWLwPFgX4nNnOwkk5jBTY5
 fH5Oy/aUk5tf8mmST8Sw/oSM377YC+ez3o8mtKkXtu3H0W4HTm1mnSIHbWG7xhw2
 WjmfHyRrEWT1
 =secp
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cohuck-gitlab/tags/s390x-20210520-v2' into staging

s390x fixes and cleanups; also related fixes in xtensa,
arm, and x86 code

# gpg: Signature made Thu 20 May 2021 13:23:15 BST
# gpg:                using RSA key C3D0D66DC3624FF6A8C018CEDECF6B93C6F02FAF
# gpg:                issuer "cohuck@redhat.com"
# gpg: Good signature from "Cornelia Huck <conny@cornelia-huck.de>" [unknown]
# gpg:                 aka "Cornelia Huck <huckc@linux.vnet.ibm.com>" [full]
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>" [full]
# gpg:                 aka "Cornelia Huck <cohuck@kernel.org>" [unknown]
# gpg:                 aka "Cornelia Huck <cohuck@redhat.com>" [unknown]
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck-gitlab/tags/s390x-20210520-v2:
  tests/tcg/x86_64: add vsyscall smoke test
  target/i386: Make sure that vsyscall's tb->size != 0
  vfio-ccw: Attempt to clean up all IRQs on error
  hw/s390x/ccw: Register qbus type in abstract TYPE_CCW_DEVICE parent
  vfio-ccw: Permit missing IRQs
  accel/tcg: Assert that tb->size != 0 after translation
  target/xtensa: Make sure that tb->size != 0
  target/arm: Make sure that commpage's tb->size != 0
  target/s390x: Fix translation exception on illegal instruction

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2021-05-20 18:42:00 +01:00
commit 972e848b53
13 changed files with 48 additions and 17 deletions

View File

@ -1912,6 +1912,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
tcg_ctx->cpu = env_cpu(env);
gen_intermediate_code(cpu, tb, max_insns);
assert(tb->size != 0);
tcg_ctx->cpu = NULL;
max_insns = tb->icount;

View File

@ -158,7 +158,6 @@ static void emulated_ccw_3270_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
device_class_set_props(dc, emulated_ccw_3270_properties);
dc->bus_type = TYPE_VIRTUAL_CSS_BUS;
dc->realize = emulated_ccw_3270_realize;
dc->hotpluggable = false;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);

View File

@ -59,6 +59,7 @@ static void ccw_device_class_init(ObjectClass *klass, void *data)
k->refill_ids = ccw_device_refill_ids;
device_class_set_props(dc, ccw_device_properties);
dc->reset = ccw_device_reset;
dc->bus_type = TYPE_VIRTUAL_CSS_BUS;
}
const VMStateDescription vmstate_ccw_dev = {

View File

@ -14,6 +14,7 @@
#include "qom/object.h"
#include "hw/qdev-core.h"
#include "hw/s390x/css.h"
#include "hw/s390x/css-bridge.h"
struct CcwDevice {
DeviceState parent_obj;

View File

@ -176,10 +176,8 @@ static void s390_ccw_instance_init(Object *obj)
static void s390_ccw_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
S390CCWDeviceClass *cdc = S390_CCW_DEVICE_CLASS(klass);
dc->bus_type = TYPE_VIRTUAL_CSS_BUS;
cdc->realize = s390_ccw_realize;
cdc->unrealize = s390_ccw_unrealize;
}

View File

@ -1234,7 +1234,6 @@ static void virtio_ccw_device_class_init(ObjectClass *klass, void *data)
k->unplug = virtio_ccw_busdev_unplug;
dc->realize = virtio_ccw_busdev_realize;
dc->unrealize = virtio_ccw_busdev_unrealize;
dc->bus_type = TYPE_VIRTUAL_CSS_BUS;
device_class_set_parent_reset(dc, virtio_ccw_reset, &vdc->parent_reset);
}

View File

@ -411,8 +411,8 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
}
if (vdev->num_irqs < irq + 1) {
error_setg(errp, "vfio: unexpected number of irqs %u",
vdev->num_irqs);
error_setg(errp, "vfio: IRQ %u not available (number of irqs %u)",
irq, vdev->num_irqs);
return;
}
@ -469,7 +469,7 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
if (vfio_set_irq_signaling(&vcdev->vdev, irq, 0,
VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) {
error_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name);
warn_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name);
}
qemu_set_fd_handler(event_notifier_get_fd(notifier),
@ -689,20 +689,24 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
if (vcdev->crw_region) {
vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX, &err);
if (err) {
goto out_crw_notifier_err;
goto out_irq_notifier_err;
}
}
vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX, &err);
if (err) {
goto out_req_notifier_err;
/*
* Report this error, but do not make it a failing condition.
* Lack of this IRQ in the host does not prevent normal operation.
*/
error_report_err(err);
}
return;
out_req_notifier_err:
out_irq_notifier_err:
vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX);
vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX);
out_crw_notifier_err:
vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX);
out_io_notifier_err:
vfio_ccw_put_region(vcdev);

View File

@ -8981,6 +8981,7 @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
unsigned int insn;
if (arm_pre_translate_insn(dc)) {
dc->base.pc_next += 4;
return;
}
@ -9050,6 +9051,7 @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
bool is_16bit;
if (arm_pre_translate_insn(dc)) {
dc->base.pc_next += 2;
return;
}

View File

@ -8628,6 +8628,7 @@ static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
*/
if ((dc->base.pc_next & TARGET_PAGE_MASK) == TARGET_VSYSCALL_PAGE) {
gen_exception(dc, EXCP_VSYSCALL, dc->base.pc_next);
dc->base.pc_next = dc->pc + 1;
return;
}
#endif

View File

@ -6412,7 +6412,8 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)
qemu_log_mask(LOG_UNIMP, "unimplemented opcode 0x%02x%02x\n",
s->fields.op, s->fields.op2);
gen_illegal_opcode(s);
return DISAS_NORETURN;
ret = DISAS_NORETURN;
goto out;
}
#ifndef CONFIG_USER_ONLY
@ -6428,7 +6429,8 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)
/* privileged instruction */
if ((s->base.tb->flags & FLAG_MASK_PSTATE) && (insn->flags & IF_PRIV)) {
gen_program_exception(s, PGM_PRIVILEGED);
return DISAS_NORETURN;
ret = DISAS_NORETURN;
goto out;
}
/* if AFP is not enabled, instructions and registers are forbidden */
@ -6455,7 +6457,8 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)
}
if (dxc) {
gen_data_exception(dxc);
return DISAS_NORETURN;
ret = DISAS_NORETURN;
goto out;
}
}
@ -6463,7 +6466,8 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)
if (insn->flags & IF_VEC) {
if (!((s->base.tb->flags & FLAG_MASK_VECTOR))) {
gen_data_exception(0xfe);
return DISAS_NORETURN;
ret = DISAS_NORETURN;
goto out;
}
}
@ -6484,7 +6488,8 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)
(insn->spec & SPEC_r1_f128 && !is_fp_pair(get_field(s, r1))) ||
(insn->spec & SPEC_r2_f128 && !is_fp_pair(get_field(s, r2)))) {
gen_program_exception(s, PGM_SPECIFICATION);
return DISAS_NORETURN;
ret = DISAS_NORETURN;
goto out;
}
}
@ -6544,6 +6549,7 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s)
}
#endif
out:
/* Advance to the next instruction. */
s->base.pc_next = s->pc_tmp;
return ret;

View File

@ -917,6 +917,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
"unknown instruction length (pc = %08x)\n",
dc->pc);
gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
dc->base.pc_next = dc->pc + 1;
return;
}
@ -1274,11 +1275,13 @@ static void xtensa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
if ((tb_cflags(dc->base.tb) & CF_USE_ICOUNT)
&& (dc->base.tb->flags & XTENSA_TBFLAG_YIELD)) {
gen_exception(dc, EXCP_YIELD);
dc->base.pc_next = dc->pc + 1;
dc->base.is_jmp = DISAS_NORETURN;
return;
}
if (dc->base.tb->flags & XTENSA_TBFLAG_EXCEPTION) {
gen_exception(dc, EXCP_DEBUG);
dc->base.pc_next = dc->pc + 1;
dc->base.is_jmp = DISAS_NORETURN;
return;
}

View File

@ -3,14 +3,18 @@
# x86_64 tests - included from tests/tcg/Makefile.target
#
# Currently we only build test-x86_64 and test-i386-ssse3 from
# $(SRC)/tests/tcg/i386/
# $(SRC_PATH)/tests/tcg/i386/
#
include $(SRC_PATH)/tests/tcg/i386/Makefile.target
X86_64_TESTS += vsyscall
TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
QEMU_OPTS += -cpu max
test-x86_64: LDFLAGS+=-lm -lc
test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
vsyscall: $(SRC_PATH)/tests/tcg/x86_64/vsyscall.c
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include <time.h>
#define VSYSCALL_PAGE 0xffffffffff600000
#define TIME_OFFSET 0x400
typedef time_t (*time_func)(time_t *);
int main(void)
{
printf("%ld\n", ((time_func)(VSYSCALL_PAGE + TIME_OFFSET))(NULL));
return 0;
}