diff options
-rw-r--r-- | arch_init.c | 4 | ||||
-rw-r--r-- | blockdev.c | 10 | ||||
-rw-r--r-- | bsd-user/main.c | 4 | ||||
-rwxr-xr-x | configure | 62 | ||||
-rw-r--r-- | coroutine-ucontext.c | 4 | ||||
-rw-r--r-- | hw/apic.h | 5 | ||||
-rw-r--r-- | hw/apic_common.c | 16 | ||||
-rw-r--r-- | hw/mips_jazz.c | 2 | ||||
-rw-r--r-- | hw/pc.c | 18 | ||||
-rw-r--r-- | hw/qdev-monitor.c | 4 | ||||
-rw-r--r-- | hw/watchdog.c | 2 | ||||
-rw-r--r-- | hw/xen_pt.c | 4 | ||||
-rw-r--r-- | linux-user/main.c | 4 | ||||
-rw-r--r-- | linux-user/signal.c | 8 | ||||
-rw-r--r-- | net.c | 3 | ||||
-rw-r--r-- | qemu-common.h | 18 | ||||
-rw-r--r-- | qemu-doc.texi | 2 | ||||
-rw-r--r-- | qemu-ga.c | 2 | ||||
-rw-r--r-- | qemu-img.c | 4 | ||||
-rw-r--r-- | qemu-option.c | 12 | ||||
-rw-r--r-- | qemu-option.h | 12 | ||||
-rw-r--r-- | qemu-options.hx | 4 | ||||
-rw-r--r-- | qemu-timer.c | 2 | ||||
-rw-r--r-- | target-i386/cpu.c | 30 | ||||
-rw-r--r-- | target-i386/helper.c | 1 | ||||
-rw-r--r-- | target-i386/kvm.c | 4 | ||||
-rw-r--r-- | user-exec.c | 2 | ||||
-rw-r--r-- | vl.c | 4 |
28 files changed, 180 insertions, 67 deletions
diff --git a/arch_init.c b/arch_init.c index 26f30ef987..60823baabd 100644 --- a/arch_init.c +++ b/arch_init.c @@ -680,7 +680,7 @@ void select_soundhw(const char *optarg) { struct soundhw *c; - if (*optarg == '?') { + if (is_help_option(optarg)) { show_valid_cards: printf("Valid sound card names (comma separated):\n"); @@ -688,7 +688,7 @@ void select_soundhw(const char *optarg) printf ("%-11s %s\n", c->name, c->descr); } printf("\n-soundhw all will enable all of the above\n"); - exit(*optarg != '?'); + exit(!is_help_option(optarg)); } else { size_t l; diff --git a/blockdev.c b/blockdev.c index 3d7501565d..8669142704 100644 --- a/blockdev.c +++ b/blockdev.c @@ -398,11 +398,11 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { - if (strcmp(buf, "?") == 0) { - error_printf("Supported formats:"); - bdrv_iterate_format(bdrv_format_print, NULL); - error_printf("\n"); - return NULL; + if (is_help_option(buf)) { + error_printf("Supported formats:"); + bdrv_iterate_format(bdrv_format_print, NULL); + error_printf("\n"); + return NULL; } drv = bdrv_find_whitelisted_format(buf); if (!drv) { diff --git a/bsd-user/main.c b/bsd-user/main.c index cd33d655f5..095ae8eaaa 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -681,7 +681,7 @@ static void usage(void) "-g port wait gdb connection to port\n" "-L path set the elf interpreter prefix (default=%s)\n" "-s size set the stack size in bytes (default=%ld)\n" - "-cpu model select CPU (-cpu ? for list)\n" + "-cpu model select CPU (-cpu help for list)\n" "-drop-ld-preload drop LD_PRELOAD for target process\n" "-E var=value sets/modifies targets environment variable(s)\n" "-U var unsets targets environment variable(s)\n" @@ -825,7 +825,7 @@ int main(int argc, char **argv) qemu_uname_release = argv[optind++]; } else if (!strcmp(r, "cpu")) { cpu_model = argv[optind++]; - if (strcmp(cpu_model, "?") == 0) { + if (is_help_option(cpu_model)) { /* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) cpu_list(stdout, &fprintf); @@ -1158,9 +1158,10 @@ gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits" gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags" gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags" gcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags" -if test "$werror" = "yes" ; then - gcc_flags="-Werror $gcc_flags" -fi +# Note that we do not add -Werror to gcc_flags here, because that would +# enable it for all configure tests. If a configure test failed due +# to -Werror this would just silently disable some features, +# so it's too error prone. cat > $TMPC << EOF int main(void) { return 0; } EOF @@ -1728,7 +1729,7 @@ cat > $TMPC <<EOF int main(void) { png_structp png_ptr; png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - return 0; + return png_ptr != 0; } EOF if $pkg_config libpng --modversion >/dev/null 2>&1; then @@ -1821,7 +1822,8 @@ if test "$vde" != "no" ; then int main(void) { struct vde_open_args a = {0, 0, 0}; - vde_open("", "", &a); + char s[] = ""; + vde_open(s, s, &a); return 0; } EOF @@ -1890,7 +1892,7 @@ for drv in $audio_drv_list; do case $drv in alsa) audio_drv_probe $drv alsa/asoundlib.h -lasound \ - "snd_pcm_t **handle; return snd_pcm_close(*handle);" + "return snd_pcm_close((snd_pcm_t *)0);" libs_softmmu="-lasound $libs_softmmu" ;; @@ -2341,6 +2343,7 @@ cat > $TMPC << EOF #define _ATFILE_SOURCE #include <stddef.h> #include <fcntl.h> +#include <sys/stat.h> int main(void) { @@ -2655,13 +2658,22 @@ if test "$smartcard" != "no" ; then #include <pk11pub.h> int main(void) { PK11_FreeSlot(0); return 0; } EOF - smartcard_cflags="-I\$(SRC_PATH)/libcacard" + smartcard_includes="-I\$(SRC_PATH)/libcacard" libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs" libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags" + test_cflags="$libcacard_cflags" + # The header files in nss < 3.13.3 have a bug which causes them to + # emit a warning. If we're going to compile QEMU with -Werror, then + # test that the headers don't have this bug. Otherwise we would pass + # the configure test but fail to compile QEMU later. + if test "$werror" = "yes"; then + test_cflags="-Werror $test_cflags" + fi if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \ - compile_prog "$smartcard_cflags $libcacard_cflags" "$libcacard_libs"; then + compile_prog "$test_cflags" "$libcacard_libs"; then smartcard_nss="yes" - QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags" + QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags" + QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes" libs_softmmu="$libcacard_libs $libs_softmmu" else if test "$smartcard_nss" = "yes"; then @@ -2790,7 +2802,7 @@ fi # specification is necessary if test "$vhost_net" = "yes" && test "$cpu" = "i386"; then cat > $TMPC << EOF -int sfaa(unsigned *ptr) +static int sfaa(int *ptr) { return __sync_fetch_and_and(ptr, 0); } @@ -2803,7 +2815,7 @@ int main(int argc, char **argv) } EOF if ! compile_prog "" "" ; then - CFLAGS+="-march=i486" + QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" fi fi @@ -2873,14 +2885,29 @@ if compile_prog "" "" ; then fi ######################################## +# check whether we can disable the -Wunused-but-set-variable +# option with a pragma (this is needed to silence a warning in +# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.) +# This test has to be compiled with -Werror as otherwise an +# unknown pragma is only a warning. +pragma_disable_unused_but_set=no +cat > $TMPC << EOF +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" +int main(void) { + return 0; +} +EOF +if compile_prog "-Werror" "" ; then + pragma_disable_unused_but_set=yes +fi + +######################################## # check if we have valgrind/valgrind.h valgrind_h=no cat > $TMPC << EOF #include <valgrind/valgrind.h> -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" int main(void) { - VALGRIND_STACK_DEREGISTER(0); return 0; } EOF @@ -2921,6 +2948,11 @@ if test -z "$zero_malloc" ; then fi fi +# Now we've finished running tests it's OK to add -Werror to the compiler flags +if test "$werror" = "yes"; then + QEMU_CFLAGS="-Werror $QEMU_CFLAGS" +fi + if test "$solaris" = "no" ; then if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then LDFLAGS="-Wl,--warn-common $LDFLAGS" @@ -3397,6 +3429,10 @@ if test "$linux_magic_h" = "yes" ; then echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak fi +if test "$pragma_disable_unused_but_set" = "yes" ; then + echo "CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET=y" >> $config_host_mak +fi + if test "$valgrind_h" = "yes" ; then echo "CONFIG_VALGRIND_H=y" >> $config_host_mak fi diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c index e3c450b322..784081ab18 100644 --- a/coroutine-ucontext.c +++ b/coroutine-ucontext.c @@ -200,14 +200,18 @@ Coroutine *qemu_coroutine_new(void) } #ifdef CONFIG_VALGRIND_H +#ifdef CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET /* Work around an unused variable in the valgrind.h macro... */ #pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#endif static inline void valgrind_stack_deregister(CoroutineUContext *co) { VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id); } +#ifdef CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET #pragma GCC diagnostic error "-Wunused-but-set-variable" #endif +#endif void qemu_coroutine_delete(Coroutine *co_) { @@ -21,9 +21,12 @@ void apic_sipi(DeviceState *s); void apic_handle_tpr_access_report(DeviceState *d, target_ulong ip, TPRAccess access); void apic_poll_irq(DeviceState *d); +void apic_designate_bsp(DeviceState *d); /* pc.c */ -int cpu_is_bsp(CPUX86State *env); DeviceState *cpu_get_current_apic(void); +/* cpu.c */ +bool cpu_is_bsp(X86CPU *cpu); + #endif diff --git a/hw/apic_common.c b/hw/apic_common.c index 60b82596e7..58e63b00da 100644 --- a/hw/apic_common.c +++ b/hw/apic_common.c @@ -43,8 +43,8 @@ uint64_t cpu_get_apic_base(DeviceState *d) trace_cpu_get_apic_base((uint64_t)s->apicbase); return s->apicbase; } else { - trace_cpu_get_apic_base(0); - return 0; + trace_cpu_get_apic_base(MSR_IA32_APICBASE_BSP); + return MSR_IA32_APICBASE_BSP; } } @@ -201,13 +201,23 @@ void apic_init_reset(DeviceState *d) s->timer_expiry = -1; } +void apic_designate_bsp(DeviceState *d) +{ + if (d == NULL) { + return; + } + + APICCommonState *s = APIC_COMMON(d); + s->apicbase |= MSR_IA32_APICBASE_BSP; +} + static void apic_reset_common(DeviceState *d) { APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d); APICCommonClass *info = APIC_COMMON_GET_CLASS(s); bool bsp; - bsp = cpu_is_bsp(s->cpu_env); + bsp = cpu_is_bsp(x86_env_get_cpu(s->cpu_env)); s->apicbase = 0xfee00000 | (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE; diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index bf1b799c4d..db927f14d0 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -239,7 +239,7 @@ static void mips_jazz_init(MemoryRegion *address_space, dp83932_init(nd, 0x80001000, 2, get_system_memory(), rc4030[4], rc4030_opaque, rc4030_dma_memory_rw); break; - } else if (strcmp(nd->model, "?") == 0) { + } else if (is_help_option(nd->model)) { fprintf(stderr, "qemu: Supported NICs: dp83932\n"); exit(1); } else { @@ -857,12 +857,6 @@ void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd) nb_ne2k++; } -int cpu_is_bsp(CPUX86State *env) -{ - /* We hard-wire the BSP to the first CPU. */ - return env->cpu_index == 0; -} - DeviceState *cpu_get_current_apic(void) { if (cpu_single_env) { @@ -910,15 +904,6 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level) } } -static void pc_cpu_reset(void *opaque) -{ - X86CPU *cpu = opaque; - CPUX86State *env = &cpu->env; - - cpu_reset(CPU(cpu)); - env->halted = !cpu_is_bsp(env); -} - static X86CPU *pc_new_cpu(const char *cpu_model) { X86CPU *cpu; @@ -933,8 +918,7 @@ static X86CPU *pc_new_cpu(const char *cpu_model) if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) { env->apic_state = apic_init(env, env->cpuid_apic_id); } - qemu_register_reset(pc_cpu_reset, cpu); - pc_cpu_reset(cpu); + cpu_reset(CPU(cpu)); return cpu; } diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 7915b4500d..b22a37a00c 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -138,13 +138,13 @@ int qdev_device_help(QemuOpts *opts) ObjectClass *klass; driver = qemu_opt_get(opts, "driver"); - if (driver && !strcmp(driver, "?")) { + if (driver && is_help_option(driver)) { bool show_no_user = false; object_class_foreach(qdev_print_devinfo, TYPE_DEVICE, false, &show_no_user); return 1; } - if (!driver || !qemu_opt_get(opts, "?")) { + if (!driver || !qemu_opt_has_help_opt(opts)) { return 0; } diff --git a/hw/watchdog.c b/hw/watchdog.c index a42124d520..b52acedd98 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -55,7 +55,7 @@ int select_watchdog(const char *p) QemuOpts *opts; /* -watchdog ? lists available devices and exits cleanly. */ - if (strcmp(p, "?") == 0) { + if (is_help_option(p)) { QLIST_FOREACH(model, &watchdog_list, entry) { fprintf(stderr, "\t%s\t%s\n", model->wdt_name, model->wdt_description); diff --git a/hw/xen_pt.c b/hw/xen_pt.c index fdf68aa564..307119a12f 100644 --- a/hw/xen_pt.c +++ b/hw/xen_pt.c @@ -764,7 +764,7 @@ out: return 0; } -static int xen_pt_unregister_device(PCIDevice *d) +static void xen_pt_unregister_device(PCIDevice *d) { XenPCIPassthroughState *s = DO_UPCAST(XenPCIPassthroughState, dev, d); uint8_t machine_irq = s->machine_irq; @@ -814,8 +814,6 @@ static int xen_pt_unregister_device(PCIDevice *d) memory_listener_unregister(&s->memory_listener); xen_host_pci_device_put(&s->real_device); - - return 0; } static Property xen_pci_passthrough_properties[] = { diff --git a/linux-user/main.c b/linux-user/main.c index a0ab8e839c..25eaa11a1f 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3140,7 +3140,7 @@ static void handle_arg_uname(const char *arg) static void handle_arg_cpu(const char *arg) { cpu_model = strdup(arg); - if (cpu_model == NULL || strcmp(cpu_model, "?") == 0) { + if (cpu_model == NULL || is_help_option(cpu_model)) { /* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list_id) cpu_list_id(stdout, &fprintf, ""); @@ -3231,7 +3231,7 @@ struct qemu_argument arg_table[] = { {"s", "QEMU_STACK_SIZE", true, handle_arg_stack_size, "size", "set the stack size to 'size' bytes"}, {"cpu", "QEMU_CPU", true, handle_arg_cpu, - "model", "select CPU (-cpu ? for list)"}, + "model", "select CPU (-cpu help for list)"}, {"E", "QEMU_SET_ENV", true, handle_arg_set_env, "var=value", "sets targets environment variable (see below)"}, {"U", "QEMU_UNSET_ENV", true, handle_arg_unset_env, diff --git a/linux-user/signal.c b/linux-user/signal.c index 97f30d9547..9be5ac0788 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -2849,7 +2849,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, * Arguments to signal handler: * * a0 = signal number - * a1 = pointer to struct siginfo + * a1 = pointer to siginfo_t * a2 = pointer to struct ucontext * * $25 and PC point to the signal handler, $29 points to the @@ -3255,7 +3255,7 @@ struct target_signal_frame { }; struct rt_signal_frame { - struct siginfo info; + siginfo_t info; struct ucontext uc; uint32_t tramp[2]; }; @@ -3474,9 +3474,9 @@ struct target_signal_frame { }; struct rt_signal_frame { - struct siginfo *pinfo; + siginfo_t *pinfo; void *puc; - struct siginfo info; + siginfo_t info; struct ucontext uc; uint8_t retcode[8]; /* Trampoline code. */ }; @@ -691,8 +691,9 @@ int qemu_show_nic_models(const char *arg, const char *const *models) { int i; - if (!arg || strcmp(arg, "?")) + if (!arg || !is_help_option(arg)) { return 0; + } fprintf(stderr, "qemu: Supported NIC models: "); for (i = 0 ; models[i]; i++) diff --git a/qemu-common.h b/qemu-common.h index d26ff39e87..dd91912024 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -136,6 +136,24 @@ int qemu_main(int argc, char **argv, char **envp); void qemu_get_timedate(struct tm *tm, int offset); int qemu_timedate_diff(struct tm *tm); +/** + * is_help_option: + * @s: string to test + * + * Check whether @s is one of the standard strings which indicate + * that the user is asking for a list of the valid values for a + * command option like -cpu or -M. The current accepted strings + * are 'help' and '?'. '?' is deprecated (it is a shell wildcard + * which makes it annoying to use in a reliable way) but provided + * for backwards compatibility. + * + * Returns: true if @s is a request for a list. + */ +static inline bool is_help_option(const char *s) +{ + return !strcmp(s, "?") || !strcmp(s, "help"); +} + /* cutils.c */ void pstrcpy(char *buf, int buf_size, const char *str); void strpadcpy(char *buf, int buf_size, const char *str, char pad); diff --git a/qemu-doc.texi b/qemu-doc.texi index 84dad19579..a41448a7a7 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2390,7 +2390,7 @@ Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386) @item -s size Set the x86 stack size in bytes (default=524288) @item -cpu model -Select CPU model (-cpu ? for list and additional feature selection) +Select CPU model (-cpu help for list and additional feature selection) @item -ignore-environment Start with an empty environment. Without this option, the initial environment is a copy of the caller's environment. @@ -736,7 +736,7 @@ int main(int argc, char **argv) break; case 'b': { char **list_head, **list; - if (*optarg == '?') { + if (is_help_option(optarg)) { list_head = list = qmp_get_command_list(); while (*list != NULL) { printf("%s\n", *list); diff --git a/qemu-img.c b/qemu-img.c index 80cfb9b167..b866f8081e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -350,7 +350,7 @@ static int img_create(int argc, char **argv) img_size = (uint64_t)sval; } - if (options && !strcmp(options, "?")) { + if (options && is_help_option(options)) { ret = print_block_option_help(filename, fmt); goto out; } @@ -744,7 +744,7 @@ static int img_convert(int argc, char **argv) /* Initialize before goto out */ qemu_progress_init(progress, 2.0); - if (options && !strcmp(options, "?")) { + if (options && is_help_option(options)) { ret = print_block_option_help(out_filename, out_fmt); goto out; } diff --git a/qemu-option.c b/qemu-option.c index 8334190c53..27891e74e7 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -529,6 +529,18 @@ const char *qemu_opt_get(QemuOpts *opts, const char *name) return opt ? opt->str : NULL; } +bool qemu_opt_has_help_opt(QemuOpts *opts) +{ + QemuOpt *opt; + + QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) { + if (is_help_option(opt->name)) { + return true; + } + } + return false; +} + bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval) { QemuOpt *opt = qemu_opt_find(opts, name); diff --git a/qemu-option.h b/qemu-option.h index 951dec3cc4..ca729862d5 100644 --- a/qemu-option.h +++ b/qemu-option.h @@ -107,6 +107,18 @@ struct QemuOptsList { }; const char *qemu_opt_get(QemuOpts *opts, const char *name); +/** + * qemu_opt_has_help_opt: + * @opts: options to search for a help request + * + * Check whether the options specified by @opts include one of the + * standard strings which indicate that the user is asking for a + * list of the valid values for a command line option (as defined + * by is_help_option()). + * + * Returns: true if @opts includes 'help' or equivalent. + */ +bool qemu_opt_has_help_opt(QemuOpts *opts); bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval); uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval); uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval); diff --git a/qemu-options.hx b/qemu-options.hx index dc68e15033..9277414782 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -6,6 +6,10 @@ HXCOMM construct option structures, enums and help message for specified HXCOMM architectures. HXCOMM HXCOMM can be used for comments, discarded from both texi and C +HXCOMM TODO : when we are able to change -help output without breaking +HXCOMM libvirt we should update the help options which refer to -cpu ?, +HXCOMM -driver ?, etc to use the preferred -cpu help etc instead. + DEFHEADING(Standard options:) STEXI @table @option diff --git a/qemu-timer.c b/qemu-timer.c index de9897788d..062fdf2cb9 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -183,7 +183,7 @@ void configure_alarms(char const *opt) char *name; struct qemu_alarm_timer tmp; - if (!strcmp(opt, "?")) { + if (is_help_option(opt)) { show_available_alarms(); exit(0); } diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 6b9659f9e7..857b94ea87 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -31,6 +31,8 @@ #include "hyperv.h" +#include "hw/hw.h" + /* feature flags taken from "Intel Processor Identification and the CPUID * Instruction" and AMD's "CPUID Specification". In cases of disagreement * between feature naming conventions, aliases may be added. @@ -1686,8 +1688,31 @@ static void x86_cpu_reset(CPUState *s) env->dr[7] = DR7_FIXED_1; cpu_breakpoint_remove_all(env, BP_CPU); cpu_watchpoint_remove_all(env, BP_CPU); + +#if !defined(CONFIG_USER_ONLY) + /* We hard-wire the BSP to the first CPU. */ + if (env->cpu_index == 0) { + apic_designate_bsp(env->apic_state); + } + + env->halted = !cpu_is_bsp(cpu); +#endif } +#ifndef CONFIG_USER_ONLY +bool cpu_is_bsp(X86CPU *cpu) +{ + return cpu_get_apic_base(cpu->env.apic_state) & MSR_IA32_APICBASE_BSP; +} + +/* TODO: remove me, when reset over QOM tree is implemented */ +static void x86_cpu_machine_reset_cb(void *opaque) +{ + X86CPU *cpu = opaque; + cpu_reset(CPU(cpu)); +} +#endif + static void mce_init(X86CPU *cpu) { CPUX86State *cenv = &cpu->env; @@ -1708,8 +1733,13 @@ void x86_cpu_realize(Object *obj, Error **errp) { X86CPU *cpu = X86_CPU(obj); +#ifndef CONFIG_USER_ONLY + qemu_register_reset(x86_cpu_machine_reset_cb, cpu); +#endif + mce_init(cpu); qemu_init_vcpu(&cpu->env); + cpu_reset(CPU(cpu)); } static void x86_cpu_initfn(Object *obj) diff --git a/target-i386/helper.c b/target-i386/helper.c index d3af6eaf71..b748d90063 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1191,7 +1191,6 @@ void do_cpu_init(X86CPU *cpu) env->interrupt_request = sipi; env->pat = pat; apic_init_reset(env->apic_state); - env->halted = !cpu_is_bsp(env); } void do_cpu_sipi(X86CPU *cpu) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index e53c2f6bdf..4cfb3faf01 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -584,11 +584,13 @@ int kvm_arch_init_vcpu(CPUX86State *env) void kvm_arch_reset_vcpu(CPUX86State *env) { + X86CPU *cpu = x86_env_get_cpu(env); + env->exception_injected = -1; env->interrupt_injected = -1; env->xcr0 = 1; if (kvm_irqchip_in_kernel()) { - env->mp_state = cpu_is_bsp(env) ? KVM_MP_STATE_RUNNABLE : + env->mp_state = cpu_is_bsp(cpu) ? KVM_MP_STATE_RUNNABLE : KVM_MP_STATE_UNINITIALIZED; } else { env->mp_state = KVM_MP_STATE_RUNNABLE; diff --git a/user-exec.c b/user-exec.c index b2a4261eca..1a9c276eb3 100644 --- a/user-exec.c +++ b/user-exec.c @@ -588,7 +588,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, int cpu_signal_handler(int host_signum, void *pinfo, void *puc) { - struct siginfo *info = pinfo; + siginfo_t *info = pinfo; struct ucontext *uc = puc; unsigned long pc = uc->uc_mcontext.sc_iaoq[0]; uint32_t insn = *(uint32_t *)pc; @@ -2086,7 +2086,7 @@ static QEMUMachine *machine_parse(const char *name) printf("%-20s %s%s\n", m->name, m->desc, m->is_default ? " (default)" : ""); } - exit(!name || *name != '?'); + exit(!name || !is_help_option(name)); } static int tcg_init(void) @@ -3216,7 +3216,7 @@ int main(int argc, char **argv, char **envp) */ cpudef_init(); - if (cpu_model && *cpu_model == '?') { + if (cpu_model && is_help_option(cpu_model)) { list_cpus(stdout, &fprintf, cpu_model); exit(0); } |