Skip to content

Commit 710fb08

Browse files
committed
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-07-06' into staging
* Fuzzer fixes from Alexander * Clean-up patches for qtests, configure and mcf5206 * Sparc64 sun4u acceptance test # gpg: Signature made Mon 06 Jul 2020 08:34:14 BST # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "[email protected]" # gpg: Good signature from "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [full] # gpg: aka "Thomas Huth <[email protected]>" [unknown] # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * remotes/huth-gitlab/tags/pull-request-2020-07-06: tests/acceptance: Add a test for the sun4u sparc64 machine hw/m68k/mcf5206: Replace remaining hw_error()s by qemu_log_mask() configure / util: Auto-detect the availability of openpty() tests/qtest: Unify the test for the xenfv and xenpv machines fuzz: do not use POSIX shm for coverage bitmap fuzz: fix broken qtest check at rcu_disable_atfork Signed-off-by: Peter Maydell <[email protected]>
2 parents 7623b5b + 8c43292 commit 710fb08

File tree

12 files changed

+98
-66
lines changed

12 files changed

+98
-66
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,7 @@ F: include/hw/pci-host/sabre.h
13191319
F: hw/pci-bridge/simba.c
13201320
F: include/hw/pci-bridge/simba.h
13211321
F: pc-bios/openbios-sparc64
1322+
F: tests/acceptance/machine_sparc64_sun4u.py
13221323

13231324
Sun4v
13241325
M: Artyom Tarasenko <[email protected]>

configure

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5141,10 +5141,14 @@ extern int openpty(int *am, int *as, char *name, void *termp, void *winp);
51415141
int main(void) { return openpty(0, 0, 0, 0, 0); }
51425142
EOF
51435143

5144-
if ! compile_prog "" "" ; then
5144+
have_openpty="no"
5145+
if compile_prog "" "" ; then
5146+
have_openpty="yes"
5147+
else
51455148
if compile_prog "" "-lutil" ; then
51465149
libs_softmmu="-lutil $libs_softmmu"
51475150
libs_tools="-lutil $libs_tools"
5151+
have_openpty="yes"
51485152
fi
51495153
fi
51505154

@@ -7390,6 +7394,9 @@ fi
73907394
if test "$have_broken_size_max" = "yes" ; then
73917395
echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
73927396
fi
7397+
if test "$have_openpty" = "yes" ; then
7398+
echo "HAVE_OPENPTY=y" >> $config_host_mak
7399+
fi
73937400

73947401
# Work around a system header bug with some kernel/XFS header
73957402
# versions where they both try to define 'struct fsxattr':

hw/m68k/mcf5206.c

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "qemu/error-report.h"
1111
#include "qemu/log.h"
1212
#include "cpu.h"
13-
#include "hw/hw.h"
1413
#include "hw/irq.h"
1514
#include "hw/m68k/mcf.h"
1615
#include "qemu/timer.h"
@@ -69,10 +68,16 @@ static void m5206_timer_recalibrate(m5206_timer_state *s)
6968
if (mode == 2)
7069
prescale *= 16;
7170

72-
if (mode == 3 || mode == 0)
73-
hw_error("m5206_timer: mode %d not implemented\n", mode);
74-
if ((s->tmr & TMR_FRR) == 0)
75-
hw_error("m5206_timer: free running mode not implemented\n");
71+
if (mode == 3 || mode == 0) {
72+
qemu_log_mask(LOG_UNIMP, "m5206_timer: mode %d not implemented\n",
73+
mode);
74+
goto exit;
75+
}
76+
if ((s->tmr & TMR_FRR) == 0) {
77+
qemu_log_mask(LOG_UNIMP,
78+
"m5206_timer: free running mode not implemented\n");
79+
goto exit;
80+
}
7681

7782
/* Assume 66MHz system clock. */
7883
ptimer_set_freq(s->timer, 66000000 / prescale);
@@ -391,7 +396,9 @@ static uint32_t m5206_mbar_readb(void *opaque, hwaddr offset)
391396
m5206_mbar_state *s = (m5206_mbar_state *)opaque;
392397
offset &= 0x3ff;
393398
if (offset >= 0x200) {
394-
hw_error("Bad MBAR read offset 0x%x", (int)offset);
399+
qemu_log_mask(LOG_GUEST_ERROR, "Bad MBAR read offset 0x%" HWADDR_PRIX,
400+
offset);
401+
return 0;
395402
}
396403
if (m5206_mbar_width[offset >> 2] > 1) {
397404
uint16_t val;
@@ -410,7 +417,9 @@ static uint32_t m5206_mbar_readw(void *opaque, hwaddr offset)
410417
int width;
411418
offset &= 0x3ff;
412419
if (offset >= 0x200) {
413-
hw_error("Bad MBAR read offset 0x%x", (int)offset);
420+
qemu_log_mask(LOG_GUEST_ERROR, "Bad MBAR read offset 0x%" HWADDR_PRIX,
421+
offset);
422+
return 0;
414423
}
415424
width = m5206_mbar_width[offset >> 2];
416425
if (width > 2) {
@@ -434,7 +443,9 @@ static uint32_t m5206_mbar_readl(void *opaque, hwaddr offset)
434443
int width;
435444
offset &= 0x3ff;
436445
if (offset >= 0x200) {
437-
hw_error("Bad MBAR read offset 0x%x", (int)offset);
446+
qemu_log_mask(LOG_GUEST_ERROR, "Bad MBAR read offset 0x%" HWADDR_PRIX,
447+
offset);
448+
return 0;
438449
}
439450
width = m5206_mbar_width[offset >> 2];
440451
if (width < 4) {
@@ -458,7 +469,9 @@ static void m5206_mbar_writeb(void *opaque, hwaddr offset,
458469
int width;
459470
offset &= 0x3ff;
460471
if (offset >= 0x200) {
461-
hw_error("Bad MBAR write offset 0x%x", (int)offset);
472+
qemu_log_mask(LOG_GUEST_ERROR, "Bad MBAR write offset 0x%" HWADDR_PRIX,
473+
offset);
474+
return;
462475
}
463476
width = m5206_mbar_width[offset >> 2];
464477
if (width > 1) {
@@ -482,7 +495,9 @@ static void m5206_mbar_writew(void *opaque, hwaddr offset,
482495
int width;
483496
offset &= 0x3ff;
484497
if (offset >= 0x200) {
485-
hw_error("Bad MBAR write offset 0x%x", (int)offset);
498+
qemu_log_mask(LOG_GUEST_ERROR, "Bad MBAR write offset 0x%" HWADDR_PRIX,
499+
offset);
500+
return;
486501
}
487502
width = m5206_mbar_width[offset >> 2];
488503
if (width > 2) {
@@ -510,7 +525,9 @@ static void m5206_mbar_writel(void *opaque, hwaddr offset,
510525
int width;
511526
offset &= 0x3ff;
512527
if (offset >= 0x200) {
513-
hw_error("Bad MBAR write offset 0x%x", (int)offset);
528+
qemu_log_mask(LOG_GUEST_ERROR, "Bad MBAR write offset 0x%" HWADDR_PRIX,
529+
offset);
530+
return;
514531
}
515532
width = m5206_mbar_width[offset >> 2];
516533
if (width < 4) {

softmmu/vl.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3832,17 +3832,7 @@ void qemu_init(int argc, char **argv, char **envp)
38323832
machine_class);
38333833

38343834
os_daemonize();
3835-
3836-
/*
3837-
* If QTest is enabled, keep the rcu_atfork enabled, since system processes
3838-
* may be forked testing purposes (e.g. fork-server based fuzzing) The fork
3839-
* should happen before a signle cpu instruction is executed, to prevent
3840-
* deadlocks. See commit 73c6e40, rcu: "completely disable pthread_atfork
3841-
* callbacks as soon as possible"
3842-
*/
3843-
if (!qtest_enabled()) {
3844-
rcu_disable_atfork();
3845-
}
3835+
rcu_disable_atfork();
38463836

38473837
if (pid_file && !qemu_write_pidfile(pid_file, &err)) {
38483838
error_reportf_err(err, "cannot create PID file: ");
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Functional test that boots a Linux kernel and checks the console
2+
#
3+
# Copyright (c) 2020 Red Hat, Inc.
4+
#
5+
# Author:
6+
# Thomas Huth <[email protected]>
7+
#
8+
# This work is licensed under the terms of the GNU GPL, version 2 or
9+
# later. See the COPYING file in the top-level directory.
10+
11+
import os
12+
13+
from avocado_qemu import wait_for_console_pattern
14+
from avocado.utils import archive
15+
from boot_linux_console import LinuxKernelTest
16+
17+
class Sun4uMachine(LinuxKernelTest):
18+
"""Boots the Linux kernel and checks that the console is operational"""
19+
20+
timeout = 90
21+
22+
def test_sparc64_sun4u(self):
23+
"""
24+
:avocado: tags=arch:sparc64
25+
:avocado: tags=machine:sun4u
26+
"""
27+
tar_url = ('https://www.qemu-advent-calendar.org'
28+
'/2018/download/day23.tar.xz')
29+
tar_hash = '142db83cd974ffadc4f75c8a5cad5bcc5722c240'
30+
file_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
31+
archive.extract(file_path, self.workdir)
32+
self.vm.set_console()
33+
self.vm.add_args('-kernel', self.workdir + '/day23/vmlinux',
34+
'-append', self.KERNEL_COMMON_COMMAND_LINE)
35+
self.vm.launch()
36+
wait_for_console_pattern(self, 'Starting logging: OK')

tests/qtest/device-introspect-test.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,6 @@ static void add_machine_test_case(const char *mname)
287287
{
288288
char *path, *args;
289289

290-
/* Ignore blacklisted machines */
291-
if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
292-
return;
293-
}
294-
295290
path = g_strdup_printf("device/introspect/concrete/defaults/%s", mname);
296291
args = g_strdup_printf("-M %s", mname);
297292
qtest_add_data_func(path, args, test_device_intro_concrete);

tests/qtest/fuzz/fork_fuzz.c

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,25 @@
1717

1818
void counter_shm_init(void)
1919
{
20-
char *shm_path = g_strdup_printf("/qemu-fuzz-cntrs.%d", getpid());
21-
int fd = shm_open(shm_path, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
22-
g_free(shm_path);
23-
24-
if (fd == -1) {
25-
perror("Error: ");
26-
exit(1);
27-
}
28-
if (ftruncate(fd, &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START) == -1) {
29-
perror("Error: ");
30-
exit(1);
31-
}
32-
/* Copy what's in the counter region to the shm.. */
33-
void *rptr = mmap(NULL ,
34-
&__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START,
35-
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
36-
memcpy(rptr,
20+
/* Copy what's in the counter region to a temporary buffer.. */
21+
void *copy = malloc(&__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START);
22+
memcpy(copy,
3723
&__FUZZ_COUNTERS_START,
3824
&__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START);
3925

40-
munmap(rptr, &__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START);
41-
42-
/* And map the shm over the counter region */
43-
rptr = mmap(&__FUZZ_COUNTERS_START,
44-
&__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START,
45-
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
46-
47-
close(fd);
48-
49-
if (!rptr) {
26+
/* Map a shared region over the counter region */
27+
if (mmap(&__FUZZ_COUNTERS_START,
28+
&__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START,
29+
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED | MAP_ANONYMOUS,
30+
0, 0) == MAP_FAILED) {
5031
perror("Error: ");
5132
exit(1);
5233
}
34+
35+
/* Copy the original data back to the counter-region */
36+
memcpy(&__FUZZ_COUNTERS_START, copy,
37+
&__FUZZ_COUNTERS_END - &__FUZZ_COUNTERS_START);
38+
free(copy);
5339
}
5440

5541

tests/qtest/fuzz/fuzz.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,8 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
211211

212212
qemu_init(result.we_wordc, result.we_wordv, NULL);
213213

214+
/* re-enable the rcu atfork, which was previously disabled in qemu_init */
215+
rcu_enable_atfork();
216+
214217
return 0;
215218
}

tests/qtest/libqtest.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,10 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine),
12321232
qstr = qobject_to(QString, qobj);
12331233
g_assert(qstr);
12341234
mname = qstring_get_str(qstr);
1235+
/* Ignore machines that cannot be used for qtests */
1236+
if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
1237+
continue;
1238+
}
12351239
if (!skip_old_versioned || !qtest_is_old_versioned_machine(mname)) {
12361240
cb(mname);
12371241
}

tests/qtest/qom-test.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ static void add_machine_test_case(const char *mname)
8181
{
8282
char *path;
8383

84-
/* Ignore blacklisted machines that have known problems */
85-
if (!memcmp("xenfv", mname, 5) || g_str_equal("xenpv", mname)) {
86-
return;
87-
}
88-
8984
path = g_strdup_printf("qom/%s", mname);
9085
qtest_add_data_func(path, g_strdup(mname), test_machine);
9186
g_free(path);

0 commit comments

Comments
 (0)