* x86: re-enable rng seeding via SetupData

* x86: reinitialize RNG seed on system reboot and after kernel load
 * qboot: rebuild based on latest commit
 * watchdog: remove -watchdog option
 * update Meson to 0.61.5, move more configure tests
 -----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmM4kiAUHHBib256aW5p
 QHJlZGhhdC5jb20ACgkQv/vSX3jHroNfbgf+IHhIHVxtBVWqayVRkwpQC+oAFV/V
 4bvJI90rHmTNPA36n1ocUmQmXyNVTQFW/t7mlln5BhOwNzxnQycVe2idfMa6ntkb
 hHpe2NbICF9Crzb9BkK4wnaBLwEWA/X3WlnCqPYtxlxEhjmxu+HPtF7vm12OTkOV
 JevH3EN1gMiAfMo+gcRBlrwb5kntLm3nGZTCd218Ope22PoU6MVvxb9ivieJG8kD
 xDUGPQNU0mB9pypwLYZAqmu34xJ8Stly9UuJ1M2iQoawIs7W2Qy7svpOrsKZ3W/7
 D7J18QLAjI7Hq6rUWPgK5ugnUvVMdaTXM7MZSuIDIxRJuj5YryIsHRPybQ==
 =HEmX
 -----END PGP SIGNATURE-----

Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging

* x86: re-enable rng seeding via SetupData
* x86: reinitialize RNG seed on system reboot and after kernel load
* qboot: rebuild based on latest commit
* watchdog: remove -watchdog option
* update Meson to 0.61.5, move more configure tests

# -----BEGIN PGP SIGNATURE-----
#
# iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmM4kiAUHHBib256aW5p
# QHJlZGhhdC5jb20ACgkQv/vSX3jHroNfbgf+IHhIHVxtBVWqayVRkwpQC+oAFV/V
# 4bvJI90rHmTNPA36n1ocUmQmXyNVTQFW/t7mlln5BhOwNzxnQycVe2idfMa6ntkb
# hHpe2NbICF9Crzb9BkK4wnaBLwEWA/X3WlnCqPYtxlxEhjmxu+HPtF7vm12OTkOV
# JevH3EN1gMiAfMo+gcRBlrwb5kntLm3nGZTCd218Ope22PoU6MVvxb9ivieJG8kD
# xDUGPQNU0mB9pypwLYZAqmu34xJ8Stly9UuJ1M2iQoawIs7W2Qy7svpOrsKZ3W/7
# D7J18QLAjI7Hq6rUWPgK5ugnUvVMdaTXM7MZSuIDIxRJuj5YryIsHRPybQ==
# =HEmX
# -----END PGP SIGNATURE-----
# gpg: Signature made Sat 01 Oct 2022 15:16:48 EDT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* tag 'for-upstream' of https://gitlab.com/bonzini/qemu:
  x86: re-initialize RNG seed when selecting kernel
  target/i386/kvm: fix kvmclock_current_nsec: Assertion `time.tsc_timestamp <= migration_tsc' failed
  configure, meson: move linker flag detection to meson
  configure, meson: move C++ compiler detection to meson.build
  meson: multiple names can be passed to dependency()
  meson: require 0.61.3
  meson: -display dbus and CFI are incompatible
  ui: fix path to dbus-display1.h
  watchdog: remove -watchdog option
  configure: do not invoke as/ld directly for pc-bios/optionrom
  qboot: rebuild based on latest commit
  x86: re-enable rng seeding via SetupData
  x86: reinitialize RNG seed on system reboot
  x86: use typedef for SetupData struct
  x86: return modified setup_data only if read as memory, not as file

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2022-10-04 14:03:21 -04:00
commit f8ec554cb8
28 changed files with 159 additions and 297 deletions

97
configure vendored
View File

@ -75,7 +75,6 @@ fi
TMPB="qemu-conf"
TMPC="${TMPDIR1}/${TMPB}.c"
TMPO="${TMPDIR1}/${TMPB}.o"
TMPCXX="${TMPDIR1}/${TMPB}.cxx"
TMPM="${TMPDIR1}/${TMPB}.m"
TMPE="${TMPDIR1}/${TMPB}.exe"
@ -158,10 +157,6 @@ do_cc() {
do_compiler_werror "$cc" $CPU_CFLAGS "$@"
}
do_cxx() {
do_compiler_werror "$cxx" $CPU_CFLAGS "$@"
}
do_objc() {
do_compiler_werror "$objcc" $CPU_CFLAGS "$@"
}
@ -171,24 +166,6 @@ add_to() {
eval $1=\${$1:+\"\$$1 \"}\$2
}
update_cxxflags() {
# Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
# options which some versions of GCC's C++ compiler complain about
# because they only make sense for C programs.
QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
for arg in $QEMU_CFLAGS; do
case $arg in
-Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
-Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
;;
*)
QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
;;
esac
done
}
compile_object() {
local_cflags="$1"
do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
@ -1101,7 +1078,7 @@ fi
python="$python -B"
if test -z "$meson"; then
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.61.5; then
meson=meson
elif test "$git_submodules_action" != 'ignore' ; then
meson=git
@ -1353,12 +1330,10 @@ EOF
if test "$static" = "yes"; then
if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
pie="yes"
elif test "$pie" = "yes"; then
error_exit "-static-pie not available due to missing toolchain support"
else
QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
pie="no"
fi
elif test "$pie" = "no"; then
@ -1380,12 +1355,6 @@ else
pie="no"
fi
# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
# The combination is known as "full relro", because .got.plt is read-only too.
if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
fi
##########################################
# __sync_fetch_and_and requires at least -march=i486. Many toolchains
# use i686 as default anyway, but for those that don't, an explicit
@ -2243,14 +2212,6 @@ if test "$have_ubsan" = "yes"; then
fi
##########################################
# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
if test "$solaris" = "no" && test "$tsan" = "no"; then
if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
fi
fi
# Guest agent Windows MSI package
if test "$QEMU_GA_MANUFACTURER" = ""; then
@ -2298,23 +2259,11 @@ probe_target_compiler i386-softmmu
if test -n "$target_cc" &&
test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
test "$targetos" != "haiku" && test "$softmmu" = yes ; then
# Different host OS linkers have different ideas about the name of the ELF
# emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
# variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
if "$target_ld" -verbose 2>&1 | grep -q "^[[:space:]]*${emu}[[:space:]]*$"; then
ld_i386_emulation="$emu"
break
fi
done
if test -n "$ld_i386_emulation"; then
roms="pc-bios/optionrom"
config_mak=pc-bios/optionrom/config.mak
echo "# Automatically generated by configure - do not modify" > $config_mak
echo "TOPSRC_DIR=$source_path" >> $config_mak
echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_mak
write_target_makefile >> $config_mak
fi
roms="pc-bios/optionrom"
config_mak=pc-bios/optionrom/config.mak
echo "# Automatically generated by configure - do not modify" > $config_mak
echo "TOPSRC_DIR=$source_path" >> $config_mak
write_target_makefile >> $config_mak
fi
probe_target_compiler ppc-softmmu
@ -2352,38 +2301,6 @@ fi
#######################################
# generate config-host.mak
# Check that the C++ compiler exists and works with the C compiler.
# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
if has $cxx; then
cat > $TMPC <<EOF
int c_function(void);
int main(void) { return c_function(); }
EOF
compile_object
cat > $TMPCXX <<EOF
extern "C" {
int c_function(void);
}
int c_function(void) { return 42; }
EOF
update_cxxflags
if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
# C++ compiler $cxx works ok with C compiler $cc
:
else
echo "C++ compiler $cxx does not work with C compiler $cc"
echo "Disabling C++ specific optional code"
cxx=
fi
else
echo "No C++ compiler available; disabling C++ specific optional code"
cxx=
fi
if ! (GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
exit 1
fi
@ -2464,7 +2381,6 @@ echo "MESON=$meson" >> $config_host_mak
echo "NINJA=$ninja" >> $config_host_mak
echo "CC=$cc" >> $config_host_mak
echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
@ -2655,7 +2571,6 @@ if test "$skip_meson" = no; then
echo "${a}-softmmu = '$c'" >> $cross
done
test -z "$cxx" && echo "link_language = 'c'" >> $cross
echo "[built-in options]" >> $cross
echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross

View File

@ -81,11 +81,6 @@ the process listing. This is replaced by the new ``password-secret``
option which lets the password be securely provided on the command
line using a ``secret`` object instance.
``-watchdog`` (since 6.2)
'''''''''''''''''''''''''
Use ``-device`` instead.
``-smp`` ("parameter=0" SMP configurations) (since 6.2)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''

View File

@ -403,6 +403,11 @@ Sound card devices should be created using ``-device`` or ``-audio``.
The exception is ``pcspk`` which can be activated using ``-machine
pcspk-audiodev=<name>``.
``-watchdog`` (since 7.2)
'''''''''''''''''''''''''
Use ``-device`` instead.
QEMU Machine Protocol (QMP) commands
------------------------------------

View File

@ -332,7 +332,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)
rom_set_fw(fw_cfg);
if (machine->kernel_filename != NULL) {
x86_load_linux(x86ms, fw_cfg, 0, true, true);
x86_load_linux(x86ms, fw_cfg, 0, true, false);
}
if (mms->option_roms) {

View File

@ -439,7 +439,6 @@ static void pc_i440fx_7_2_machine_options(MachineClass *m)
m->alias = "pc";
m->is_default = true;
pcmc->default_cpu_version = 1;
pcmc->legacy_no_rng_seed = true;
}
DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,
@ -447,9 +446,11 @@ DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,
static void pc_i440fx_7_1_machine_options(MachineClass *m)
{
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_i440fx_7_2_machine_options(m);
m->alias = NULL;
m->is_default = false;
pcmc->legacy_no_rng_seed = true;
compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
}

View File

@ -376,7 +376,6 @@ static void pc_q35_7_2_machine_options(MachineClass *m)
pc_q35_machine_options(m);
m->alias = "q35";
pcmc->default_cpu_version = 1;
pcmc->legacy_no_rng_seed = true;
}
DEFINE_Q35_MACHINE(v7_2, "pc-q35-7.2", NULL,
@ -384,8 +383,10 @@ DEFINE_Q35_MACHINE(v7_2, "pc-q35-7.2", NULL,
static void pc_q35_7_1_machine_options(MachineClass *m)
{
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_q35_7_2_machine_options(m);
m->alias = NULL;
pcmc->legacy_no_rng_seed = true;
compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
}

View File

@ -37,6 +37,7 @@
#include "sysemu/whpx.h"
#include "sysemu/numa.h"
#include "sysemu/replay.h"
#include "sysemu/reset.h"
#include "sysemu/sysemu.h"
#include "sysemu/cpu-timers.h"
#include "sysemu/xen.h"
@ -652,12 +653,12 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state)
return dev;
}
struct setup_data {
typedef struct SetupData {
uint64_t next;
uint32_t type;
uint32_t len;
uint8_t data[];
} __attribute__((packed));
} __attribute__((packed)) SetupData;
/*
@ -764,6 +765,30 @@ static bool load_elfboot(const char *kernel_filename,
return true;
}
typedef struct SetupDataFixup {
void *pos;
hwaddr orig_val, new_val;
uint32_t addr;
} SetupDataFixup;
static void fixup_setup_data(void *opaque)
{
SetupDataFixup *fixup = opaque;
stq_p(fixup->pos, fixup->new_val);
}
static void reset_setup_data(void *opaque)
{
SetupDataFixup *fixup = opaque;
stq_p(fixup->pos, fixup->orig_val);
}
static void reset_rng_seed(void *opaque)
{
SetupData *setup_data = opaque;
qemu_guest_getrandom_nofail(setup_data->data, le32_to_cpu(setup_data->len));
}
void x86_load_linux(X86MachineState *x86ms,
FWCfgState *fw_cfg,
int acpi_data_size,
@ -780,7 +805,7 @@ void x86_load_linux(X86MachineState *x86ms,
FILE *f;
char *vmode;
MachineState *machine = MACHINE(x86ms);
struct setup_data *setup_data;
SetupData *setup_data;
const char *kernel_filename = machine->kernel_filename;
const char *initrd_filename = machine->initrd_filename;
const char *dtb_filename = machine->dtb;
@ -1063,11 +1088,11 @@ void x86_load_linux(X86MachineState *x86ms,
}
setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
kernel_size = setup_data_offset + sizeof(struct setup_data) + dtb_size;
kernel_size = setup_data_offset + sizeof(SetupData) + dtb_size;
kernel = g_realloc(kernel, kernel_size);
setup_data = (struct setup_data *)(kernel + setup_data_offset);
setup_data = (SetupData *)(kernel + setup_data_offset);
setup_data->next = cpu_to_le64(first_setup_data);
first_setup_data = prot_addr + setup_data_offset;
setup_data->type = cpu_to_le32(SETUP_DTB);
@ -1078,18 +1103,25 @@ void x86_load_linux(X86MachineState *x86ms,
if (!legacy_no_rng_seed) {
setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
kernel_size = setup_data_offset + sizeof(struct setup_data) + RNG_SEED_LENGTH;
kernel_size = setup_data_offset + sizeof(SetupData) + RNG_SEED_LENGTH;
kernel = g_realloc(kernel, kernel_size);
setup_data = (struct setup_data *)(kernel + setup_data_offset);
setup_data = (SetupData *)(kernel + setup_data_offset);
setup_data->next = cpu_to_le64(first_setup_data);
first_setup_data = prot_addr + setup_data_offset;
setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
qemu_register_reset(reset_rng_seed, setup_data);
fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_KERNEL_DATA, reset_rng_seed, NULL,
setup_data, kernel, kernel_size, true);
} else {
fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
}
/* Offset 0x250 is a pointer to the first setup_data link. */
stq_p(header + 0x250, first_setup_data);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
sev_load_ctx.kernel_data = (char *)kernel;
sev_load_ctx.kernel_size = kernel_size;
/*
* If we're starting an encrypted VM, it will be OVMF based, which uses the
@ -1099,16 +1131,20 @@ void x86_load_linux(X86MachineState *x86ms,
* file the user passed in.
*/
if (!sev_enabled()) {
SetupDataFixup *fixup = g_malloc(sizeof(*fixup));
memcpy(setup, header, MIN(sizeof(header), setup_size));
/* Offset 0x250 is a pointer to the first setup_data link. */
fixup->pos = setup + 0x250;
fixup->orig_val = ldq_p(fixup->pos);
fixup->new_val = first_setup_data;
fixup->addr = cpu_to_le32(real_addr);
fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_SETUP_ADDR, fixup_setup_data, NULL,
fixup, &fixup->addr, sizeof(fixup->addr), true);
qemu_register_reset(reset_setup_data, fixup);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
}
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
sev_load_ctx.kernel_data = (char *)kernel;
sev_load_ctx.kernel_size = kernel_size;
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
sev_load_ctx.setup_data = (char *)setup;

View File

@ -692,12 +692,12 @@ static const VMStateDescription vmstate_fw_cfg = {
}
};
static void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
FWCfgCallback select_cb,
FWCfgWriteCallback write_cb,
void *callback_opaque,
void *data, size_t len,
bool read_only)
void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
FWCfgCallback select_cb,
FWCfgWriteCallback write_cb,
void *callback_opaque,
void *data, size_t len,
bool read_only)
{
int arch = !!(key & FW_CFG_ARCH_LOCAL);

View File

@ -24,11 +24,6 @@
#include "qemu/log.h"
#include "qemu/module.h"
static WatchdogTimerModel model = {
.wdt_name = TYPE_WDT_SBSA,
.wdt_description = "SBSA-compliant generic watchdog device",
};
static const VMStateDescription vmstate_sbsa_gwdt = {
.name = "sbsa-gwdt",
.version_id = 1,
@ -287,7 +282,6 @@ static const TypeInfo wdt_sbsa_gwdt_info = {
static void wdt_sbsa_gwdt_register_types(void)
{
watchdog_add_model(&model);
type_register_static(&wdt_sbsa_gwdt_info);
}

View File

@ -32,49 +32,6 @@
#include "qemu/help_option.h"
static WatchdogAction watchdog_action = WATCHDOG_ACTION_RESET;
static QLIST_HEAD(, WatchdogTimerModel) watchdog_list;
void watchdog_add_model(WatchdogTimerModel *model)
{
QLIST_INSERT_HEAD(&watchdog_list, model, entry);
}
/* Returns:
* 0 = continue
* 1 = exit program with error
* 2 = exit program without error
*/
int select_watchdog(const char *p)
{
WatchdogTimerModel *model;
QemuOpts *opts;
/* -watchdog ? lists available devices and exits cleanly. */
if (is_help_option(p)) {
QLIST_FOREACH(model, &watchdog_list, entry) {
fprintf(stderr, "\t%s\t%s\n",
model->wdt_name, model->wdt_description);
}
return 2;
}
QLIST_FOREACH(model, &watchdog_list, entry) {
if (strcasecmp(model->wdt_name, p) == 0) {
/* add the device */
opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
&error_abort);
qemu_opt_set(opts, "driver", p, &error_abort);
return 0;
}
}
fprintf(stderr, "Unknown -watchdog device. Supported devices are:\n");
QLIST_FOREACH(model, &watchdog_list, entry) {
fprintf(stderr, "\t%s\t%s\n",
model->wdt_name, model->wdt_description);
}
return 1;
}
WatchdogAction get_watchdog_action(void)
{

View File

@ -202,11 +202,6 @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data,
return;
}
static WatchdogTimerModel model = {
.wdt_name = TYPE_ASPEED_WDT,
.wdt_description = "Aspeed watchdog device",
};
static const VMStateDescription vmstate_aspeed_wdt = {
.name = "vmstate_aspeed_wdt",
.version_id = 0,
@ -416,7 +411,6 @@ static const TypeInfo aspeed_1030_wdt_info = {
static void wdt_aspeed_register_types(void)
{
watchdog_add_model(&model);
type_register_static(&aspeed_wdt_info);
type_register_static(&aspeed_2400_wdt_info);
type_register_static(&aspeed_2500_wdt_info);

View File

@ -19,11 +19,6 @@
#include "migration/vmstate.h"
#include "qemu/log.h"
static WatchdogTimerModel model = {
.wdt_name = TYPE_WDT_DIAG288,
.wdt_description = "diag288 device for s390x platform",
};
static const VMStateDescription vmstate_diag288 = {
.name = "vmstate_diag288",
.version_id = 0,
@ -138,7 +133,6 @@ static const TypeInfo wdt_diag288_info = {
static void wdt_diag288_register_types(void)
{
watchdog_add_model(&model);
type_register_static(&wdt_diag288_info);
}

View File

@ -457,11 +457,6 @@ static void i6300esb_exit(PCIDevice *dev)
timer_free(d->timer);
}
static WatchdogTimerModel model = {
.wdt_name = "i6300esb",
.wdt_description = "Intel 6300ESB",
};
static void i6300esb_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@ -493,7 +488,6 @@ static const TypeInfo i6300esb_info = {
static void i6300esb_register_types(void)
{
watchdog_add_model(&model);
type_register_static(&i6300esb_info);
}

View File

@ -128,11 +128,6 @@ static void wdt_ib700_reset(DeviceState *dev)
timer_del(s->timer);
}
static WatchdogTimerModel model = {
.wdt_name = "ib700",
.wdt_description = "iBASE 700",
};
static void wdt_ib700_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@ -153,7 +148,6 @@ static const TypeInfo wdt_ib700_info = {
static void wdt_ib700_register_types(void)
{
watchdog_add_model(&model);
type_register_static(&wdt_ib700_info);
}

View File

@ -291,14 +291,8 @@ static const TypeInfo imx2_wdt_info = {
.class_init = imx2_wdt_class_init,
};
static WatchdogTimerModel model = {
.wdt_name = "imx2-watchdog",
.wdt_description = "i.MX2 Watchdog",
};
static void imx2_wdt_register_type(void)
{
watchdog_add_model(&model);
type_register_static(&imx2_wdt_info);
}
type_init(imx2_wdt_register_type)

View File

@ -117,6 +117,28 @@ struct FWCfgMemState {
*/
void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len);
/**
* fw_cfg_add_bytes_callback:
* @s: fw_cfg device being modified
* @key: selector key value for new fw_cfg item
* @select_cb: callback function when selecting
* @write_cb: callback function after a write
* @callback_opaque: argument to be passed into callback function
* @data: pointer to start of item data
* @len: size of item data
* @read_only: is file read only
*
* Add a new fw_cfg item, available by selecting the given key, as a raw
* "blob" of the given size. The data referenced by the starting pointer
* is only linked, NOT copied, into the data structure of the fw_cfg device.
*/
void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
FWCfgCallback select_cb,
FWCfgWriteCallback write_cb,
void *callback_opaque,
void *data, size_t len,
bool read_only);
/**
* fw_cfg_add_string:
* @s: fw_cfg device being modified

View File

@ -25,20 +25,8 @@
#include "qemu/queue.h"
#include "qapi/qapi-types-run-state.h"
struct WatchdogTimerModel {
QLIST_ENTRY(WatchdogTimerModel) entry;
/* Short name of the device - used to select it on the command line. */
const char *wdt_name;
/* Longer description (eg. manufacturer and full model number). */
const char *wdt_description;
};
typedef struct WatchdogTimerModel WatchdogTimerModel;
/* in hw/watchdog.c */
int select_watchdog(const char *p);
WatchdogAction get_watchdog_action(void);
void watchdog_add_model(WatchdogTimerModel *model);
void watchdog_perform_action(void);
#endif /* QEMU_WATCHDOG_H */

2
meson

@ -1 +1 @@
Subproject commit 12f9f04ba0decfda425dbbf9a501084c153a2d18
Subproject commit 3a9b285a55b91b53b2acda987192274352ecb5be

View File

@ -1,4 +1,4 @@
project('qemu', ['c'], meson_version: '>=0.59.3',
project('qemu', ['c'], meson_version: '>=0.61.3',
default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
'b_staticpic=false', 'stdsplit=false', 'optimization=2', 'b_pie=true'],
version: files('VERSION'))
@ -180,10 +180,17 @@ endif
##################
qemu_cflags = config_host['QEMU_CFLAGS'].split()
qemu_cxxflags = config_host['QEMU_CXXFLAGS'].split()
qemu_objcflags = config_host['QEMU_OBJCFLAGS'].split()
qemu_ldflags = config_host['QEMU_LDFLAGS'].split()
if enable_static
qemu_ldflags += get_option('b_pie') ? '-static-pie' : '-static'
endif
# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
# The combination is known as "full relro", because .got.plt is read-only too.
qemu_ldflags += cc.get_supported_link_arguments('-Wl,-z,relro', '-Wl,-z,now')
if targetos == 'windows'
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--no-seh', '-Wl,--nxcompat')
# Disable ASLR for debug builds to allow debugging with gdb
@ -194,7 +201,6 @@ endif
if get_option('gprof')
qemu_cflags += ['-p']
qemu_cxxflags += ['-p']
qemu_objcflags += ['-p']
qemu_ldflags += ['-p']
endif
@ -240,8 +246,38 @@ if get_option('fuzzing')
endif
add_global_arguments(qemu_cflags, native: false, language: ['c'])
add_global_arguments(qemu_cxxflags, native: false, language: ['cpp'])
add_global_arguments(qemu_objcflags, native: false, language: ['objc'])
# Check that the C++ compiler exists and works with the C compiler.
link_language = 'c'
linker = cc
qemu_cxxflags = []
if add_languages('cpp', required: false, native: false)
cxx = meson.get_compiler('cpp')
add_global_arguments(['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'],
native: false, language: 'cpp')
foreach k: qemu_cflags
if k not in ['-Wstrict-prototypes', '-Wmissing-prototypes', '-Wnested-externs',
'-Wold-style-declaration', '-Wold-style-definition', '-Wredundant-decls']
qemu_cxxflags += [k]
endif
endforeach
add_global_arguments(qemu_cxxflags, native: false, language: 'cpp')
if cxx.links(files('scripts/main.c'), args: qemu_cflags)
link_language = 'cpp'
linker = cxx
else
message('C++ compiler does not work with C compiler')
message('Disabling C++-specific optional code')
endif
endif
# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
if targetos != 'sunos' and not config_host.has_key('CONFIG_TSAN')
qemu_ldflags += linker.get_supported_link_arguments('-Wl,--warn-common')
endif
add_global_link_arguments(qemu_ldflags, native: false, language: ['c', 'cpp', 'objc'])
if targetos == 'linux'
@ -255,14 +291,6 @@ add_project_arguments('-iquote', '.',
'-iquote', meson.current_source_dir() / 'include',
language: ['c', 'cpp', 'objc'])
link_language = meson.get_external_property('link_language', 'cpp')
if link_language == 'cpp'
add_languages('cpp', required: true, native: false)
cxx = meson.get_compiler('cpp')
linker = cxx
else
linker = cc
endif
if host_machine.system() == 'darwin'
add_languages('objc', required: false, native: false)
endif
@ -487,6 +515,7 @@ meson.override_dependency('glib-2.0', glib)
gio = not_found
gdbus_codegen = not_found
gdbus_codegen_error = '@0@ requires gdbus-codegen, please install libgio'
if not get_option('gio').auto() or have_system
gio = dependency('gio-2.0', required: get_option('gio'),
method: 'pkg-config', kwargs: static_kwargs)
@ -511,6 +540,10 @@ if not get_option('gio').auto() or have_system
version: gio.version())
endif
endif
if gdbus_codegen.found() and get_option('cfi')
gdbus_codegen = not_found
gdbus_codegen_error = '@0@ uses gdbus-codegen, which does not support control flow integrity'
endif
lttng = not_found
if 'ust' in get_option('trace_backends')
@ -844,14 +877,10 @@ if have_system and get_option('curses').allowed()
}'''
curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
foreach curses_dep : curses_dep_list
if not curses.found()
curses = dependency(curses_dep,
required: false,
method: 'pkg-config',
kwargs: static_kwargs)
endif
endforeach
curses = dependency(curses_dep_list,
required: false,
method: 'pkg-config',
kwargs: static_kwargs)
msg = get_option('curses').enabled() ? 'curses library not found' : ''
curses_compile_args = ['-DNCURSES_WIDECHAR=1']
if curses.found()
@ -1689,14 +1718,11 @@ endif
have_host_block_device = (targetos != 'darwin' or
cc.has_header('IOKit/storage/IOMedia.h'))
# FIXME enable_modules shouldn't be necessary, but: https://github.com/mesonbuild/meson/issues/8333
dbus_display = get_option('dbus_display') \
.require(gio.version().version_compare('>=2.64'),
error_message: '-display dbus requires glib>=2.64') \
.require(enable_modules,
error_message: '-display dbus requires --enable-modules') \
.require(gdbus_codegen.found(),
error_message: '-display dbus requires gdbus-codegen') \
error_message: gdbus_codegen_error.format('-display dbus')) \
.require(opengl.found() and gbm.found(),
error_message: '-display dbus requires epoxy/egl and gbm') \
.allowed()

View File

@ -20,28 +20,24 @@ override CFLAGS += $(call cc-option, -fcf-protection=none)
# Flags for dependency generation
override CPPFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d
override CFLAGS += $(filter -W%, $(QEMU_CFLAGS))
override CFLAGS += $(call cc-option, -fno-pie)
override CFLAGS += $(call cc-option, -no-pie)
override CFLAGS += -ffreestanding -I$(TOPSRC_DIR)/include
override CFLAGS += $(call cc-option, -fno-stack-protector)
override CFLAGS += $(call cc-option, -Wno-array-bounds)
Wa = -Wa,
override ASFLAGS += -32
override CFLAGS += $(call cc-option, $(Wa)-32)
override LDFLAGS = -m $(LD_I386_EMULATION) -T $(SRC_DIR)/flat.lds
override LDFLAGS = -nostdlib -Wl,-T,$(SRC_DIR)/flat.lds
pvh.img: pvh.o pvh_main.o
%.o: %.S
$(call quiet-command,$(CC) $(CPPFLAGS) -E -o - $< | $(AS) $(ASFLAGS) -o $@,"AS","$@")
$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<,"AS","$@")
%.o: %.c
$(call quiet-command,$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@,"CC","$@")
%.img: %.o
$(call quiet-command,$(LD) $(LDFLAGS) -s -o $@ $^,"BUILD","$@")
$(call quiet-command,$(CC) $(CFLAGS) $(LDFLAGS) -s -o $@ $^,"BUILD","$@")
%.raw: %.img
$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"BUILD","$@")

BIN
pc-bios/qboot.rom Normal file → Executable file

Binary file not shown.

View File

@ -4352,7 +4352,7 @@ SRST
``-action panic=none``
``-action reboot=shutdown,shutdown=pause``
``-watchdog i6300esb -action watchdog=pause``
``-device i6300esb -action watchdog=pause``
ERST
@ -4470,35 +4470,6 @@ SRST
specifies the snapshot name used to load the initial VM state.
ERST
DEF("watchdog", HAS_ARG, QEMU_OPTION_watchdog, \
"-watchdog model\n" \
" enable virtual hardware watchdog [default=none]\n",
QEMU_ARCH_ALL)
SRST
``-watchdog model``
Create a virtual hardware watchdog device. Once enabled (by a guest
action), the watchdog must be periodically polled by an agent inside
the guest or else the guest will be restarted. Choose a model for
which your guest has drivers.
The model is the model of hardware watchdog to emulate. Use
``-watchdog help`` to list available hardware models. Only one
watchdog can be enabled for a guest.
The following models may be available:
``ib700``
iBASE 700 is a very simple ISA watchdog with a single timer.
``i6300esb``
Intel 6300ESB I/O controller hub is a much more featureful
PCI-based dual-timer watchdog.
``diag288``
A virtual watchdog for s390x backed by the diagnose 288
hypercall (currently KVM only).
ERST
DEF("watchdog-action", HAS_ARG, QEMU_OPTION_watchdog_action, \
"-watchdog-action reset|shutdown|poweroff|inject-nmi|pause|debug|none\n" \
" action when watchdog fires [default=reset]\n",
@ -4520,7 +4491,7 @@ SRST
Examples:
``-watchdog i6300esb -watchdog-action pause``; \ ``-watchdog ib700``
``-device i6300esb -watchdog-action pause``
ERST

View File

@ -138,7 +138,7 @@ else
if get_option('guest_agent_msi').enabled()
error('MSI guest agent package is available only for MinGW Windows cross-compilation')
endif
install_subdir('run', install_dir: get_option('localstatedir'))
install_emptydir(get_option('localstatedir') / 'run')
endif
alias_target('qemu-ga', all_qga)

1
scripts/main.c Normal file
View File

@ -0,0 +1 @@
int main(void) {}

View File

@ -53,7 +53,6 @@
#include "hw/isa/isa.h"
#include "hw/scsi/scsi.h"
#include "hw/display/vga.h"
#include "sysemu/watchdog.h"
#include "hw/firmware/smbios.h"
#include "hw/acpi/acpi.h"
#include "hw/xen/xen.h"
@ -181,7 +180,6 @@ static Chardev **serial_hds;
static const char *log_mask;
static const char *log_file;
static bool list_data_dirs;
static const char *watchdog;
static const char *qtest_chrdev;
static const char *qtest_log;
@ -2329,12 +2327,6 @@ static void qemu_process_sugar_options(void)
}
object_register_sugar_prop("memory-backend", "prealloc", "on", false);
}
if (watchdog) {
int i = select_watchdog(watchdog);
if (i > 0)
exit (i == 1 ? 1 : 0);
}
}
/* -action processing */
@ -3107,14 +3099,6 @@ void qemu_init(int argc, char **argv)
default_monitor = 0;
}
break;
case QEMU_OPTION_watchdog:
if (watchdog) {
error_report("only one watchdog option may be given");
exit(1);
}
warn_report("-watchdog is deprecated; use -device instead.");
watchdog = optarg;
break;
case QEMU_OPTION_action:
olist = qemu_find_opts("action");
if (!qemu_opts_parse_noisily(olist, optarg, false)) {

View File

@ -157,7 +157,7 @@ bool kvm_has_adjust_clock_stable(void)
{
int ret = kvm_check_extension(kvm_state, KVM_CAP_ADJUST_CLOCK);
return (ret == KVM_CLOCK_TSC_STABLE);
return (ret & KVM_CLOCK_TSC_STABLE);
}
bool kvm_has_adjust_clock(void)

View File

@ -3,7 +3,7 @@
#include <gio/gio.h>
#include <gio/gunixfdlist.h>
#include "libqtest.h"
#include "dbus-display1.h"
#include "ui/dbus-display1.h"
static GDBusConnection*
test_dbus_p2p_from_fd(int fd)

View File

@ -31,7 +31,7 @@
#include "ui/console.h"
#include "ui/clipboard.h"
#include "dbus-display1.h"
#include "ui/dbus-display1.h"
typedef struct DBusClipboardRequest {
GDBusMethodInvocation *invocation;