Skip to content

Commit

Permalink
Merge tag 'pull-request-2023-07-10v2' of https://gitlab.com/thuth/qemu
Browse files Browse the repository at this point in the history
…into staging

* s390x instruction emulation fixes and corresponding TCG tests
* Extend the readconfig qtest
* Introduce "-run-with chroot=..." and deprecate the old "-chroot" option
* Speed up migration tests
* Fix coding style in the coding style document

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmSsCYQRHHRodXRoQHJl
# ZGhhdC5jb20ACgkQLtnXdP5wLbUhLw/+Mg74FGODwb/kdPSSY+ahEmutRaQG5z74
# zWnHFYTB0xLRxu5gwV09wcFt88RjkkdsKORtp1LBRahVaKYzYSq3PxMYsDii2pdr
# Ma58RLZC/42shrzZmXEyl3ilxCCHjq2UCezX+4ca/zuTl/83znVN6Mrq28GUmp7v
# 8yI78mPpZXEkLEN3cnnK3v7AsLwz439aHd3ADZ1IWUohGHQdDAj4nn5Yxp4SeIUj
# sOmCcEfLj3emNM/TTL2suohuZNwYjyLQ5iqQJ/B7v/S88PbWQUA9Cq/KpEGBLk/D
# fxDjbQ7+zpTTSQ+XihShtGdEnl4uPPixvJX43vriYDBQFsHKS7Y38cSAFVTDrQvh
# 4fELCAPg8wXeoyMu7WZWINDA6dVdInCdmljHYpK+mQg7AtHu/CliPWzVUZyeW3XD
# lwybNCoyJQcA4KPAyYrkau74JrLRGtLJJQ5XtQEDsK791xjeHt1hr42QY4YeHyjM
# Utf6inp4D7RZ3O9p5EeKNVpFin5AE+RTvNZKLJicFRb0hFziUkCK61nRwS5gmvXA
# I41av1L+mLI7jvu0M2ID1CfIhFf+/w4GKNkUlcutux7uz5mzxIj0oifsONEZGNo+
# NlVKKNxfQv2eRl+9sZPWNl8q11K3bvZbpvXZS5oSLIererWIIROaxcgzxpU+EGLT
# 8HhF7RZdO8w=
# =LLmM
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 10 Jul 2023 02:37:08 PM BST
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [undefined]
# gpg:                 aka "Thomas Huth <thuth@redhat.com>" [undefined]
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [undefined]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2023-07-10v2' of https://gitlab.com/thuth/qemu: (21 commits)
  docs/devel: Fix coding style in style.rst
  tests/qtest: massively speed up migration-test
  tests/tcg/s390x: Fix test-svc with clang
  meson.build: Skip C++ detection unless we're targeting Windows
  os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option
  tests/qtest/readconfig: Test the docs/config/q35-*.cfg files
  tests/qtest: Move mkimg() and have_qemu_img() from libqos to libqtest
  tests/qtest/readconfig-test: Allow testing for arbitrary memory sizes
  tests/tcg/s390x: Test MVCRL with a large value in R0
  tests/tcg/s390x: Test MDEB and MDEBR
  tests/tcg/s390x: Test LRA
  tests/tcg/s390x: Test LARL with a large offset
  tests/tcg/s390x: Test EPSW
  target/s390x: Fix relative long instructions with large offsets
  target/s390x: Fix LRA when DAT is off
  target/s390x: Fix LRA overwriting the top 32 bits on DAT error
  target/s390x: Fix MVCRL with a large value in R0
  target/s390x: Fix MDEB and MDEBR
  target/s390x: Fix EPSW CC reporting
  linux-user: elfload: Add more initial s390x PSW bits
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Jul 10, 2023
2 parents fcb237e + 7233bd1 commit 8d309a3
Show file tree
Hide file tree
Showing 45 changed files with 626 additions and 141 deletions.
2 changes: 0 additions & 2 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ S: Supported
F: target/s390x/kvm/
F: target/s390x/machine.c
F: target/s390x/sigp.c
F: hw/s390x/pv.c
F: include/hw/s390x/pv.h
F: gdb-xml/s390*.xml
T: git https://github.com/borntraeger/qemu.git s390-next
L: qemu-s390x@nongnu.org
Expand Down
5 changes: 5 additions & 0 deletions docs/about/deprecated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ Use "whpx" (on Windows) or "hvf" (on macOS) instead.

Use ``-run-with async-teardown=on`` instead.

``-chroot`` (since 8.1)
'''''''''''''''''''''''

Use ``-run-with chroot=dir`` instead.

``-singlestep`` (since 8.1)
'''''''''''''''''''''''''''

Expand Down
9 changes: 6 additions & 3 deletions docs/devel/style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ For example, instead of

.. code-block:: c
int somefunc(void) {
int somefunc(void)
{
int ret = -1;
char *foo = g_strdup_printf("foo%", "wibble");
GList *bar = .....
Expand All @@ -588,7 +589,8 @@ Using g_autofree/g_autoptr enables the code to be written as:

.. code-block:: c
int somefunc(void) {
int somefunc(void)
{
g_autofree char *foo = g_strdup_printf("foo%", "wibble");
g_autoptr (GList) bar = .....
Expand All @@ -613,7 +615,8 @@ are still some caveats to beware of

.. code-block:: c
char *somefunc(void) {
char *somefunc(void)
{
g_autofree char *foo = g_strdup_printf("foo%", "wibble");
g_autoptr (GList) bar = .....
Expand Down
2 changes: 1 addition & 1 deletion hw/s390x/ipl.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "hw/s390x/vfio-ccw.h"
#include "hw/s390x/css.h"
#include "hw/s390x/ebcdic.h"
#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"
#include "hw/scsi/scsi.h"
#include "hw/virtio/virtio-net.h"
#include "ipl.h"
Expand Down
1 change: 0 additions & 1 deletion hw/s390x/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files(
'tod-kvm.c',
's390-skeys-kvm.c',
's390-stattrib-kvm.c',
'pv.c',
's390-pci-kvm.c',
))
s390x_ss.add(when: 'CONFIG_TCG', if_true: files(
Expand Down
2 changes: 1 addition & 1 deletion hw/s390x/s390-pci-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <linux/kvm.h>

#include "kvm/kvm_s390x.h"
#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"
#include "hw/s390x/s390-pci-bus.h"
#include "hw/s390x/s390-pci-kvm.h"
#include "hw/s390x/s390-pci-inst.h"
Expand Down
2 changes: 1 addition & 1 deletion hw/s390x/s390-virtio-ccw.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "hw/s390x/tod.h"
#include "sysemu/sysemu.h"
#include "sysemu/cpus.h"
#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"
#include "migration/blocker.h"
#include "qapi/visitor.h"

Expand Down
2 changes: 1 addition & 1 deletion hw/s390x/tod-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "qemu/module.h"
#include "sysemu/runstate.h"
#include "hw/s390x/tod.h"
#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"
#include "kvm/kvm_s390x.h"

static void kvm_s390_get_tod_raw(S390TOD *tod, Error **errp)
Expand Down
4 changes: 3 additions & 1 deletion linux-user/elfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,9 @@ const char *elf_hwcap_str(uint32_t bit)
static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop)
{
regs->psw.addr = infop->entry;
regs->psw.mask = PSW_MASK_64 | PSW_MASK_32;
regs->psw.mask = PSW_MASK_DAT | PSW_MASK_IO | PSW_MASK_EXT | \
PSW_MASK_MCHECK | PSW_MASK_PSTATE | PSW_MASK_64 | \
PSW_MASK_32;
regs->gprs[15] = infop->start_stack;
}

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')

cc = meson.get_compiler('c')
all_languages = ['c']
if add_languages('cpp', required: false, native: false)
if targetos == 'windows' and add_languages('cpp', required: false, native: false)
all_languages += ['cpp']
cxx = meson.get_compiler('cpp')
endif
Expand Down
35 changes: 34 additions & 1 deletion os-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "qemu/cutils.h"
#include "qemu/config-file.h"
#include "qemu/option.h"
#include "qemu/module.h"

#ifdef CONFIG_LINUX
#include <sys/prctl.h>
Expand Down Expand Up @@ -148,6 +149,7 @@ int os_parse_cmd_args(int index, const char *optarg)
}
break;
case QEMU_OPTION_chroot:
warn_report("option is deprecated, use '-run-with chroot=...' instead");
chroot_dir = optarg;
break;
case QEMU_OPTION_daemonize:
Expand All @@ -158,18 +160,25 @@ int os_parse_cmd_args(int index, const char *optarg)
case QEMU_OPTION_asyncteardown:
init_async_teardown();
break;
#endif
case QEMU_OPTION_run_with: {
const char *str;
QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("run-with"),
optarg, false);
if (!opts) {
exit(1);
}
#if defined(CONFIG_LINUX)
if (qemu_opt_get_bool(opts, "async-teardown", false)) {
init_async_teardown();
}
#endif
str = qemu_opt_get(opts, "chroot");
if (str) {
chroot_dir = str;
}
break;
}
#endif
default:
return -1;
}
Expand Down Expand Up @@ -348,3 +357,27 @@ int os_mlock(void)
return -ENOSYS;
#endif
}

static QemuOptsList qemu_run_with_opts = {
.name = "run-with",
.head = QTAILQ_HEAD_INITIALIZER(qemu_run_with_opts.head),
.desc = {
#if defined(CONFIG_LINUX)
{
.name = "async-teardown",
.type = QEMU_OPT_BOOL,
},
#endif
{
.name = "chroot",
.type = QEMU_OPT_STRING,
},
{ /* end of list */ }
},
};

static void register_runwith(void)
{
qemu_add_opts(&qemu_run_with_opts);
}
opts_init(register_runwith);
18 changes: 13 additions & 5 deletions qemu-options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4677,11 +4677,12 @@ ERST

#ifndef _WIN32
DEF("chroot", HAS_ARG, QEMU_OPTION_chroot, \
"-chroot dir chroot to dir just before starting the VM\n",
"-chroot dir chroot to dir just before starting the VM (deprecated)\n",
QEMU_ARCH_ALL)
#endif
SRST
``-chroot dir``
Deprecated, use '-run-with chroot=...' instead.
Immediately before starting guest execution, chroot to the specified
directory. Especially useful in combination with -runas.
ERST
Expand Down Expand Up @@ -4868,13 +4869,16 @@ SRST
This option is deprecated and should no longer be used. The new option
``-run-with async-teardown=on`` is a replacement.
ERST
#endif
#ifdef CONFIG_POSIX
DEF("run-with", HAS_ARG, QEMU_OPTION_run_with,
"-run-with async-teardown[=on|off]\n"
" misc QEMU process lifecycle options\n"
" async-teardown=on enables asynchronous teardown\n",
"-run-with [async-teardown=on|off][,chroot=dir]\n"
" Set miscellaneous QEMU process lifecycle options:\n"
" async-teardown=on enables asynchronous teardown (Linux only)\n"
" chroot=dir chroot to dir just before starting the VM\n",
QEMU_ARCH_ALL)
SRST
``-run-with``
``-run-with [async-teardown=on|off][,chroot=dir]``
Set QEMU process lifecycle options.

``async-teardown=on`` enables asynchronous teardown. A new process called
Expand All @@ -4887,6 +4891,10 @@ SRST
performed correctly. This only works if the cleanup process is not
forcefully killed with SIGKILL before the main QEMU process has
terminated completely.

``chroot=dir`` can be used for doing a chroot to the specified directory
immediately before starting the guest execution. This is especially useful
in combination with -runas.
ERST
#endif

Expand Down
2 changes: 1 addition & 1 deletion target/s390x/arch_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "s390x-internal.h"
#include "elf.h"
#include "sysemu/dump.h"
#include "hw/s390x/pv.h"
#include "kvm/kvm_s390x.h"
#include "target/s390x/kvm/pv.h"

struct S390xUserRegsStruct {
uint64_t psw[2];
Expand Down
2 changes: 1 addition & 1 deletion target/s390x/cpu-sysemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "qapi/qapi-visit-run-state.h"
#include "sysemu/hw_accel.h"

#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"
#include "hw/boards.h"
#include "sysemu/sysemu.h"
#include "sysemu/tcg.h"
Expand Down
2 changes: 1 addition & 1 deletion target/s390x/cpu_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "qemu/module.h"
#include "cpu_features.h"
#ifndef CONFIG_USER_ONLY
#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"
#endif

#define DEF_FEAT(_FEAT, _NAME, _TYPE, _BIT, _DESC) \
Expand Down
2 changes: 1 addition & 1 deletion target/s390x/cpu_models.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "qemu/qemu-print.h"
#ifndef CONFIG_USER_ONLY
#include "sysemu/sysemu.h"
#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"
#endif

#define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \
Expand Down
2 changes: 1 addition & 1 deletion target/s390x/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include "sysemu/cpus.h"
#include "hw/s390x/ipl.h"
#include "hw/s390x/s390-virtio-ccw.h"
#include "hw/s390x/pv.h"
#include "sysemu/kvm.h"
#include "kvm/kvm_s390x.h"
#include "target/s390x/kvm/pv.h"
#include "qemu/error-report.h"


Expand Down
2 changes: 1 addition & 1 deletion target/s390x/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "gdbstub/helpers.h"
#include "qemu/timer.h"
#include "hw/s390x/ioinst.h"
#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"
#include "sysemu/hw_accel.h"
#include "sysemu/runstate.h"

Expand Down
2 changes: 1 addition & 1 deletion target/s390x/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ DEF_HELPER_FLAGS_4(idte, TCG_CALL_NO_RWG, void, env, i64, i64, i32)
DEF_HELPER_FLAGS_4(ipte, TCG_CALL_NO_RWG, void, env, i64, i64, i32)
DEF_HELPER_FLAGS_1(ptlb, TCG_CALL_NO_RWG, void, env)
DEF_HELPER_FLAGS_1(purge, TCG_CALL_NO_RWG, void, env)
DEF_HELPER_2(lra, i64, env, i64)
DEF_HELPER_3(lra, i64, env, i64, i64)
DEF_HELPER_1(per_check_exception, void, env)
DEF_HELPER_FLAGS_3(per_branch, TCG_CALL_NO_RWG, void, env, i64, i64)
DEF_HELPER_FLAGS_2(per_ifetch, TCG_CALL_NO_RWG, void, env, i64)
Expand Down
2 changes: 1 addition & 1 deletion target/s390x/ioinst.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "hw/s390x/ioinst.h"
#include "trace.h"
#include "hw/s390x/s390-pci-bus.h"
#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"

/* All I/O instructions but chsc use the s format */
static uint64_t get_address_from_regs(CPUS390XState *env, uint32_t ipb,
Expand Down
2 changes: 1 addition & 1 deletion target/s390x/kvm/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include "exec/memattrs.h"
#include "hw/s390x/s390-virtio-ccw.h"
#include "hw/s390x/s390-virtio-hcall.h"
#include "hw/s390x/pv.h"
#include "target/s390x/kvm/pv.h"

#ifndef DEBUG_KVM
#define DEBUG_KVM 0
Expand Down
1 change: 1 addition & 0 deletions target/s390x/kvm/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

s390x_ss.add(when: 'CONFIG_KVM', if_true: files(
'pv.c',
'kvm.c'
), if_false: files(
'stubs.c'
Expand Down
2 changes: 1 addition & 1 deletion hw/s390x/pv.c → target/s390x/kvm/pv.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include "qom/object_interfaces.h"
#include "exec/confidential-guest-support.h"
#include "hw/s390x/ipl.h"
#include "hw/s390x/pv.h"
#include "hw/s390x/sclp.h"
#include "target/s390x/kvm/kvm_s390x.h"
#include "target/s390x/kvm/pv.h"

static bool info_valid;
static struct kvm_s390_pv_info_vm info_vm;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion target/s390x/mmu_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,

vaddr &= TARGET_PAGE_MASK;

if (!(env->psw.mask & PSW_MASK_DAT)) {
if (rw != MMU_S390_LRA && !(env->psw.mask & PSW_MASK_DAT)) {
*raddr = vaddr;
goto nodat;
}
Expand Down
3 changes: 2 additions & 1 deletion target/s390x/tcg/fpu_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,9 @@ uint64_t HELPER(mdb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
/* 64/32-bit FP multiplication */
uint64_t HELPER(mdeb)(CPUS390XState *env, uint64_t f1, uint64_t f2)
{
float64 f1_64 = float32_to_float64(f1, &env->fpu_status);
float64 ret = float32_to_float64(f2, &env->fpu_status);
ret = float64_mul(f1, ret, &env->fpu_status);
ret = float64_mul(f1_64, ret, &env->fpu_status);
handle_exceptions(env, false, GETPC());
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions target/s390x/tcg/insn-data.h.inc
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,11 @@
F(0xb317, MEEBR, RRE, Z, e1, e2, new, e1, meeb, 0, IF_BFP)
F(0xb31c, MDBR, RRE, Z, f1, f2, new, f1, mdb, 0, IF_BFP)
F(0xb34c, MXBR, RRE, Z, x1, x2, new_x, x1, mxb, 0, IF_BFP)
F(0xb30c, MDEBR, RRE, Z, f1, e2, new, f1, mdeb, 0, IF_BFP)
F(0xb30c, MDEBR, RRE, Z, e1, e2, new, f1, mdeb, 0, IF_BFP)
F(0xb307, MXDBR, RRE, Z, f1, f2, new_x, x1, mxdb, 0, IF_BFP)
F(0xed17, MEEB, RXE, Z, e1, m2_32u, new, e1, meeb, 0, IF_BFP)
F(0xed1c, MDB, RXE, Z, f1, m2_64, new, f1, mdb, 0, IF_BFP)
F(0xed0c, MDEB, RXE, Z, f1, m2_32u, new, f1, mdeb, 0, IF_BFP)
F(0xed0c, MDEB, RXE, Z, e1, m2_32u, new, f1, mdeb, 0, IF_BFP)
F(0xed07, MXDB, RXE, Z, f1, m2_64, new_x, x1, mxdb, 0, IF_BFP)
/* MULTIPLY HALFWORD */
C(0x4c00, MH, RX_a, Z, r1_o, m2_16s, new, r1_32, mul, 0)
Expand Down
5 changes: 3 additions & 2 deletions target/s390x/tcg/mem_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ void HELPER(mvcrl)(CPUS390XState *env, uint64_t l, uint64_t dest, uint64_t src)
int32_t i;

/* MVCRL always copies one more byte than specified - maximum is 256 */
l &= 0xff;
l++;

access_prepare(&srca, env, src, l, MMU_DATA_LOAD, mmu_idx, ra);
Expand Down Expand Up @@ -2355,7 +2356,7 @@ void HELPER(purge)(CPUS390XState *env)
}

/* load real address */
uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr)
uint64_t HELPER(lra)(CPUS390XState *env, uint64_t r1, uint64_t addr)
{
uint64_t asc = env->psw.mask & PSW_MASK_ASC;
uint64_t ret, tec;
Expand All @@ -2369,7 +2370,7 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr)
exc = mmu_translate(env, addr, MMU_S390_LRA, asc, &ret, &flags, &tec);
if (exc) {
cc = 3;
ret = exc | 0x80000000;
ret = (r1 & 0xFFFFFFFF00000000ULL) | exc | 0x80000000;
} else {
cc = 0;
ret |= addr & ~TARGET_PAGE_MASK;
Expand Down

0 comments on commit 8d309a3

Please sign in to comment.