并感谢您之前在How to make "%bp.hap.run-until name = X86_HLT_Instr" 中提供的帮助?
我的下一个障碍是当我开始跑步时 %rip 神奇地变为零。
我的测试程序:
#include <simics/magic-instruction.h>
__attribute__((noinline))
void MagicBreakpoint() {
MAGIC_BREAKPOINT;
asm volatile ("hlt");
}
extern "C" void _start() {
asm volatile ("mov $42, %rax");
MagicBreakpoint();
}
0000000000401000 <_Z15MagicBreakpointv>:
401000: 53 push %rbx
401001: b8 11 47 00 00 mov $0x4711,%eax
401006: 0f a2 cpuid
401008: f4 hlt
401009: 5b pop %rbx
40100a: c3 retq
40100b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
0000000000401010 <_start>:
401010: 48 c7 c0 2a 00 00 00 mov $0x2a,%rax
401017: e9 e4 ff ff ff jmpq 401000 <_Z15MagicBreakpointv>
我想看到的是从_start开始执行,将%rax设置为42,然后点击魔术指令,然后退出。相反,执行从 %rip=0 开始。
我的脚本:
run-command-file "%simics%/targets/qsp-x86/firststeps-no-network.simics"
$start = ($system.mb.cpu0.core[0][0].load-binary ./small)
$system.mb.cpu0.core[0][0].set-pc $start ## Special command for the PC
$system.mb.cpu0.core[0][0].write-reg "rsp" 0x7fffffffdf50
enable-magic-breakpoint
print -x %rip
print -x %rsp
step-instruction
print -x %rip
quit
./simics -no-gui t2.simics
Intel Simics 6 (build 6096 linux64) Copyright 2010-2021 Intel Corporation
Use of this software is subject to appropriate license.
Type 'copyright' for details on copyright and 'help' for on-line documentation.
[board.mb.cpu0.core[0][0] info] VMP disabled. Failed to open device.
WARNING: Simics failed to enable VMP. Enabling VMP substantially improves
simulation performance. The problem is most likely caused by the
vmxmon kernel module not being properly installed or updated.
See the "Simics User's Guide", the "Performance" section,
for instructions how to setup VMP.
Welcome to Simics!
An x86 target machine, referred to as a Quick Start Platform (QSP)
in the documentation, has been just created.
To start the simulation, enter the command "run" (or simply "r") at
the Simics prompt. This will boot Linux and automatically log you in.
You will see the login appear in the serial console window.
Note that during the boot Linux will emit a couple
of harmless warning messages related to ACPI errors.
To pause the simulation, use the command "stop". To resume simulation,
enter the command "run" again.
0x401010
0x7fffffffdf50
[board.mb.cpu0.core[0][0]] Exception: General_Protection_Exception
0x0
如您所见,在执行之前step-instruction
,%rip
是0x401010
,而在执行之后step-instruction
,%rip
是零。