qemu/target/i386
Kevin Wolf e7cff9c68d hmp: Pass monitor to mon_get_cpu_env()
mon_get_cpu_env() is indirectly called monitor_parse_arguments() where
the current monitor isn't set yet. Instead of using monitor_cur_env(),
explicitly pass the Monitor pointer to the function.

Without this fix, an HMP command like "x $pc" crashes like this:

  #0  0x0000555555caa01f in mon_get_cpu_sync (mon=0x0, synchronize=true) at ../monitor/misc.c:270
  #1  0x0000555555caa141 in mon_get_cpu (mon=0x0) at ../monitor/misc.c:294
  #2  0x0000555555caa158 in mon_get_cpu_env () at ../monitor/misc.c:299
  #3  0x0000555555b19739 in monitor_get_pc (mon=0x555556ad2de0, md=0x5555565d2d40 <monitor_defs+1152>, val=0) at ../target/i386/monitor.c:607
  #4  0x0000555555cadbec in get_monitor_def (mon=0x555556ad2de0, pval=0x7fffffffc208, name=0x7fffffffc220 "pc") at ../monitor/misc.c:1681
  #5  0x000055555582ec4f in expr_unary (mon=0x555556ad2de0) at ../monitor/hmp.c:387
  #6  0x000055555582edbb in expr_prod (mon=0x555556ad2de0) at ../monitor/hmp.c:421
  #7  0x000055555582ee79 in expr_logic (mon=0x555556ad2de0) at ../monitor/hmp.c:455
  #8  0x000055555582eefe in expr_sum (mon=0x555556ad2de0) at ../monitor/hmp.c:484
  #9  0x000055555582efe8 in get_expr (mon=0x555556ad2de0, pval=0x7fffffffc418, pp=0x7fffffffc408) at ../monitor/hmp.c:511
  #10 0x000055555582fcd4 in monitor_parse_arguments (mon=0x555556ad2de0, endp=0x7fffffffc890, cmd=0x555556675b50 <hmp_cmds+7920>) at ../monitor/hmp.c:876
  #11 0x00005555558306a8 in handle_hmp_command (mon=0x555556ad2de0, cmdline=0x555556ada452 "$pc") at ../monitor/hmp.c:1087
  #12 0x000055555582df14 in monitor_command_cb (opaque=0x555556ad2de0, cmdline=0x555556ada450 "x $pc", readline_opaque=0x0) at ../monitor/hmp.c:47

After this fix, nothing is left in monitor_parse_arguments() that can
indirectly call monitor_cur(), so the fix is complete.

Fixes: ff04108a0e
Reported-by: lichun <lichun@ruijie.com.cn>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20201113114326.97663-4-kwolf@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
2020-11-13 12:45:51 +00:00
..
hvf hvf: remove hvf specific functions from global includes 2020-10-05 16:41:22 +02:00
arch_dump.c
arch_memory_mapping.c
bpt_helper.c target/i386: Use env_cpu, env_archcpu 2019-06-10 07:03:42 -07:00
cc_helper_template.h
cc_helper.c
cpu-param.h tcg: Split out target/arch/cpu-param.h 2019-06-10 07:03:34 -07:00
cpu-qom.h qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros 2020-09-18 14:12:32 -04:00
cpu.c x86 queue, 2020-10-15 2020-10-16 22:46:28 +01:00
cpu.h target/i386: support KVM_FEATURE_ASYNC_PF_INT 2020-09-30 19:09:19 +02:00
excp_helper.c tcg/svm: use host cr4 during NPT page table walk 2020-07-10 18:02:14 -04:00
fpu_helper.c target/i386: floatx80: avoid compound literals in static initializers 2020-07-27 09:40:16 +01:00
gdbstub.c target/i386: fix IEEE SSE floating-point exception raising 2020-07-10 18:02:17 -04:00
hax-all.c hax: remove hax specific functions from global includes 2020-10-05 16:41:22 +02:00
hax-cpus.c hax: unbreak accelerator cpu code after cpus.c split 2020-10-17 10:45:53 -04:00
hax-cpus.h hax: remove hax specific functions from global includes 2020-10-05 16:41:22 +02:00
hax-i386.h cpus: extract out hax-specific code to target/i386/ 2020-10-05 16:41:22 +02:00
hax-interface.h Clean up ill-advised or unusual header guards 2019-05-13 08:58:55 +02:00
hax-mem.c hax: remove hax specific functions from global includes 2020-10-05 16:41:22 +02:00
hax-posix.c hax: remove hax specific functions from global includes 2020-10-05 16:41:22 +02:00
hax-posix.h Clean up header guards that don't match their file name 2019-05-13 08:58:55 +02:00
hax-windows.c hax: remove hax specific functions from global includes 2020-10-05 16:41:22 +02:00
hax-windows.h hax: remove hax specific functions from global includes 2020-10-05 16:41:22 +02:00
helper.c target-i386: post memory failure event to QMP 2020-10-04 18:36:23 +02:00
helper.h target/i386: fix IEEE SSE floating-point exception raising 2020-07-10 18:02:17 -04:00
hyperv-proto.h i386/kvm: add NoNonArchitecturalCoreSharing Hyper-V enlightenment 2019-10-22 09:38:42 +02:00
hyperv-stub.c target/i386: fix feature check in hyperv-stub.c 2019-07-05 22:16:46 +02:00
hyperv.c i386/kvm: convert hyperv enlightenments properties from bools to bits 2019-06-21 02:29:38 +02:00
hyperv.h
int_helper.c target/i386: Implement CPUID_EXT_RDRAND 2019-05-22 12:38:54 -04:00
kvm_i386.h i386/kvm: Delete kvm_allows_irq0_override() 2020-10-14 15:28:54 -04:00
kvm-stub.c i386/kvm: Delete kvm_allows_irq0_override() 2020-10-14 15:28:54 -04:00
kvm.c i386/kvm: Delete kvm_allows_irq0_override() 2020-10-14 15:28:54 -04:00
machine.c target/i386: support KVM_FEATURE_ASYNC_PF_INT 2020-09-30 19:09:19 +02:00
mem_helper.c qemu/atomic.h: rename atomic_ to qatomic_ 2020-09-23 16:07:44 +01:00
meson.build cpus: extract out whpx-specific code to target/i386/ 2020-10-05 16:41:22 +02:00
misc_helper.c target/i386: Fix OUTL debug output 2020-06-10 12:09:35 -04:00
monitor.c hmp: Pass monitor to mon_get_cpu_env() 2020-11-13 12:45:51 +00:00
mpx_helper.c
ops_sse_header.h
ops_sse.h target/i386: fix IEEE SSE floating-point exception raising 2020-07-10 18:02:17 -04:00
seg_helper.c helper_syscall x86_64: clear exception_is_int 2020-09-30 19:11:36 +02:00
sev_i386.h target/i386: sev: provide proper error reporting for query-sev-capabilities 2020-07-10 18:02:22 -04:00
sev-stub.c target/i386: sev: provide proper error reporting for query-sev-capabilities 2020-07-10 18:02:22 -04:00
sev.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
shift_helper_template.h
smm_helper.c target/i386: Use env_cpu, env_archcpu 2019-06-10 07:03:42 -07:00
svm_helper.c tcg/svm: use host cr4 during NPT page table walk 2020-07-10 18:02:14 -04:00
svm.h tcg/svm: use host cr4 during NPT page table walk 2020-07-10 18:02:14 -04:00
tcg-stub.c target/i386: fix IEEE SSE floating-point exception raising 2020-07-10 18:02:17 -04:00
trace-events trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
translate.c target/i386: Save cc_op before loop insns 2020-07-24 14:29:35 -07:00
whp-dispatch.h WHPX: vmware cpuid leaf for tsc and apic frequency 2020-09-30 19:09:19 +02:00
whpx-all.c cpus: add handle_interrupt to the CpusAccel interface 2020-10-05 16:41:22 +02:00
whpx-cpus.c cpus: extract out whpx-specific code to target/i386/ 2020-10-05 16:41:22 +02:00
whpx-cpus.h whpx: remove whpx specific functions from global includes 2020-10-05 16:41:22 +02:00
xsave_helper.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00