* Fixes for s390x branch instruction emulation

* Fixes for the tests/avocado/boot_linux.py:BootLinuxS390X test
 * Re-enable the "-cpu help" output
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmIxmUoRHHRodXRoQHJl
 ZGhhdC5jb20ACgkQLtnXdP5wLbV/XhAAskdaYxznvy8tRGxJWyTucV3c0LQfqTCq
 W7RPHmkBrnMFOchn9Vf2g+Y+3bbJEfOXa3VjfI/63bhxq4FjI8w3ZDG0yJ6sWDF6
 /8vRS2lkbEIO3DkXLjBBCxxboBMpo65Ltx6qd0ovdbFnxxxdONNrRi+hc6L5CmvA
 F+M6HeUuPLRIqmCoi3Ctxf4+RmyDpJn9bEL8ZRbksjMkyInrvBdu3Wdj4lwfk7Dn
 lo43LcsFqRjUhKsFsiIdo+xIvBJ6dTljAGKliwOmi116Tpv13gMTVGCWJEMru1PJ
 u3QUouum2jb5+JrFfzx1PZrq5SbaB90vNy9uyUHTYXiEKubMngrFRH2rOAuFMH6a
 kqBVh4I0jSe1huMFwk9Nhivott02oKn0Q8Zag41eRZk2/90tEy+yBmctWKExcxB7
 JoAYa7otFjtVzUWK496L8lC+ZpFbp+0Vk0NC2gfYIjAvJnEXJVvV7qMFUCw1GQ7d
 NTbqRXFZib6BHkgKA4wd19SwR/zPvHdp0Wmj3dULIDfyqdChqwMo0IRIicjoOcHo
 348b1wdPPk0G/1Y542DMdEJcFmh6y9E/nx0BA2WOX9ABCA25Q0m6Vn6oJbNbWElu
 5yb0dqRLqFfDzToz7OZvQcdaXbScZ4j1+gWVTiz+83TH4Oy27lyDBp+/NGEHuObb
 b69rSrFZxf0=
 =nWvs
 -----END PGP SIGNATURE-----

Merge tag 'pull-request-2022-03-15v2' of https://gitlab.com/thuth/qemu into staging

* Fixes for s390x branch instruction emulation
* Fixes for the tests/avocado/boot_linux.py:BootLinuxS390X test
* Re-enable the "-cpu help" output

# gpg: Signature made Wed 16 Mar 2022 08:01:14 GMT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg:                 aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg:                 aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg:                 aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3  EAB9 2ED9 D774 FE70 2DB5

* tag 'pull-request-2022-03-15v2' of https://gitlab.com/thuth/qemu:
  softmmu: List CPU types again
  accel/tcg: Fix cpu_ldq_be_mmu typo
  tests/avocado: start PhoneServer upfront
  tests/tcg/s390x: Test BRASL and BRCL with large negative offsets
  s390x/tcg: Fix BRCL with a large negative offset
  s390x/tcg: Fix BRASL with a large negative offset
  tests/tcg: drop -cpu max from s390x sha512-mvx invocation

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2022-03-16 10:43:58 +00:00
commit 1d60bb4b14
9 changed files with 90 additions and 21 deletions

View File

@ -2174,7 +2174,7 @@ uint32_t cpu_ldl_be_mmu(CPUArchState *env, abi_ptr addr,
uint64_t cpu_ldq_be_mmu(CPUArchState *env, abi_ptr addr,
MemOpIdx oi, uintptr_t ra)
{
return cpu_load_helper(env, addr, oi, MO_BEUQ, helper_be_ldq_mmu);
return cpu_load_helper(env, addr, oi, ra, helper_be_ldq_mmu);
}
uint16_t cpu_ldw_le_mmu(CPUArchState *env, abi_ptr addr,

9
cpu.c
View File

@ -35,6 +35,7 @@
#include "sysemu/tcg.h"
#include "sysemu/kvm.h"
#include "sysemu/replay.h"
#include "exec/cpu-common.h"
#include "exec/exec-all.h"
#include "exec/translate-all.h"
#include "exec/log.h"
@ -266,6 +267,14 @@ const char *parse_cpu_option(const char *cpu_option)
return cpu_type;
}
void list_cpus(const char *optarg)
{
/* XXX: implement xxx_cpu_list for targets that still miss it */
#if defined(cpu_list)
cpu_list();
#endif
}
#if defined(CONFIG_USER_ONLY)
void tb_invalidate_phys_addr(target_ulong addr)
{

View File

@ -158,4 +158,6 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
/* vl.c */
extern int singlestep;
void list_cpus(const char *optarg);
#endif /* CPU_COMMON_H */

View File

@ -55,6 +55,4 @@ extern int smp_cores;
extern int smp_threads;
#endif
void list_cpus(const char *optarg);
#endif

View File

@ -728,14 +728,6 @@ int vm_stop_force_state(RunState state)
}
}
void list_cpus(const char *optarg)
{
/* XXX: implement xxx_cpu_list for targets that still miss it */
#if defined(cpu_list)
cpu_list();
#endif
}
void qmp_memsave(int64_t addr, int64_t size, const char *filename,
bool has_cpu, int64_t cpu_index, Error **errp)
{

View File

@ -1201,7 +1201,7 @@ static DisasJumpType help_branch(DisasContext *s, DisasCompare *c,
bool is_imm, int imm, TCGv_i64 cdest)
{
DisasJumpType ret;
uint64_t dest = s->base.pc_next + 2 * imm;
uint64_t dest = s->base.pc_next + (int64_t)imm * 2;
TCGLabel *lab;
/* Take care of the special cases first. */
@ -1597,7 +1597,7 @@ static DisasJumpType op_bal(DisasContext *s, DisasOps *o)
static DisasJumpType op_basi(DisasContext *s, DisasOps *o)
{
pc_to_link_info(o->out, s, s->pc_tmp);
return help_goto_direct(s, s->base.pc_next + 2 * get_field(s, i2));
return help_goto_direct(s, s->base.pc_next + (int64_t)get_field(s, i2) * 2);
}
static DisasJumpType op_bc(DisasContext *s, DisasOps *o)

View File

@ -18,7 +18,7 @@ import time
import uuid
import avocado
from avocado.utils import cloudinit, datadrainer, network, process, ssh, vmimage
from avocado.utils import cloudinit, datadrainer, process, ssh, vmimage
from avocado.utils.path import find_command
#: The QEMU build root directory. It may also be the source directory
@ -602,9 +602,6 @@ class LinuxTest(LinuxSSHMixIn, QemuSystemTest):
self.log.info('Preparing cloudinit image')
try:
cloudinit_iso = os.path.join(self.workdir, 'cloudinit.iso')
self.phone_home_port = network.find_free_port()
if not self.phone_home_port:
self.cancel('Failed to get a free port')
pubkey_content = None
if ssh_pubkey:
with open(ssh_pubkey) as pubkey:
@ -614,7 +611,7 @@ class LinuxTest(LinuxSSHMixIn, QemuSystemTest):
password=self.password,
# QEMU's hard coded usermode router address
phone_home_host='10.0.2.2',
phone_home_port=self.phone_home_port,
phone_home_port=self.phone_server.server_port,
authorized_key=pubkey_content)
except Exception:
self.cancel('Failed to prepare the cloudinit image')
@ -625,6 +622,8 @@ class LinuxTest(LinuxSSHMixIn, QemuSystemTest):
self.vm.add_args('-drive', 'file=%s' % path)
def set_up_cloudinit(self, ssh_pubkey=None):
self.phone_server = cloudinit.PhoneHomeServer(('0.0.0.0', 0),
self.name)
cloudinit_iso = self.prepare_cloudinit(ssh_pubkey)
self.vm.add_args('-drive', 'file=%s,format=raw' % cloudinit_iso)
@ -635,7 +634,9 @@ class LinuxTest(LinuxSSHMixIn, QemuSystemTest):
logger=self.log.getChild('console'))
console_drainer.start()
self.log.info('VM launched, waiting for boot confirmation from guest')
cloudinit.wait_for_phone_home(('0.0.0.0', self.phone_home_port), self.name)
while not self.phone_server.instance_phoned_back:
self.phone_server.handle_request()
if set_up_ssh_connection:
self.log.info('Setting up the SSH connection')
self.ssh_connect(self.username, self.ssh_key)

View File

@ -15,6 +15,7 @@ TESTS+=mvc
TESTS+=shift
TESTS+=trap
TESTS+=signals-s390x
TESTS+=branch-relative-long
ifneq ($(HAVE_GDB_BIN),)
GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
@ -34,6 +35,4 @@ sha512-mvx: CFLAGS=-march=z13 -mvx -O3
sha512-mvx: sha512.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
run-sha512-mvx: QEMU_OPTS+=-cpu max
TESTS+=sha512-mvx

View File

@ -0,0 +1,68 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#define DEFINE_ASM(_name, _code) \
extern const char _name[]; \
extern const char _name ## _end[]; \
asm(" .globl " #_name "\n" \
#_name ":\n" \
" " _code "\n" \
" .globl " #_name "_end\n" \
#_name "_end:\n");
DEFINE_ASM(br_r14, "br %r14");
DEFINE_ASM(brasl_r0, "brasl %r0,.-0x100000000");
DEFINE_ASM(brcl_0xf, "brcl 0xf,.-0x100000000");
struct test {
const char *code;
const char *code_end;
};
static const struct test tests[] = {
{
.code = brasl_r0,
.code_end = brasl_r0_end,
},
{
.code = brcl_0xf,
.code_end = brcl_0xf_end,
},
};
int main(void)
{
unsigned char *buf;
size_t length = 0;
size_t i;
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
size_t test_length = 0x100000000 + (tests[i].code_end - tests[i].code);
if (test_length > length) {
length = test_length;
}
}
buf = mmap(NULL, length, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
if (buf == MAP_FAILED) {
perror("SKIP: mmap() failed");
return 0;
}
memcpy(buf, br_r14, br_r14_end - br_r14);
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
void (*code)(void) = (void *)(buf + 0x100000000);
memcpy(code, tests[i].code, tests[i].code_end - tests[i].code);
code();
memset(code, 0, tests[i].code_end - tests[i].code);
}
munmap(buf, length);
return 0;
}