Add flag that toggles tracing
This commit is contained in:
parent
7883ec274c
commit
c417e20ce0
@ -92,6 +92,8 @@ typedef struct nyx_interface_state {
|
|||||||
bool dump_pt_trace;
|
bool dump_pt_trace;
|
||||||
bool edge_cb_trace;
|
bool edge_cb_trace;
|
||||||
|
|
||||||
|
bool global_pt_enable;
|
||||||
|
|
||||||
bool redqueen;
|
bool redqueen;
|
||||||
|
|
||||||
uint32_t aux_buffer_size;
|
uint32_t aux_buffer_size;
|
||||||
@ -394,6 +396,8 @@ static void nyx_realize(DeviceState *dev, Error **errp)
|
|||||||
{
|
{
|
||||||
nyx_interface_state *s = NYX_MEM(dev);
|
nyx_interface_state *s = NYX_MEM(dev);
|
||||||
|
|
||||||
|
set_global_pt_enabled(s->global_pt_enable);
|
||||||
|
|
||||||
if (s->bitmap_size <= 0) {
|
if (s->bitmap_size <= 0) {
|
||||||
s->bitmap_size = DEFAULT_NYX_BITMAP_SIZE;
|
s->bitmap_size = DEFAULT_NYX_BITMAP_SIZE;
|
||||||
}
|
}
|
||||||
@ -465,6 +469,7 @@ static Property nyx_interface_properties[] = {
|
|||||||
input_buffer_size,
|
input_buffer_size,
|
||||||
DEFAULT_NYX_BITMAP_SIZE),
|
DEFAULT_NYX_BITMAP_SIZE),
|
||||||
DEFINE_PROP_BOOL("dump_pt_trace", nyx_interface_state, dump_pt_trace, false),
|
DEFINE_PROP_BOOL("dump_pt_trace", nyx_interface_state, dump_pt_trace, false),
|
||||||
|
DEFINE_PROP_BOOL("global_pt_enable", nyx_interface_state, global_pt_enable, true),
|
||||||
DEFINE_PROP_BOOL("edge_cb_trace", nyx_interface_state, edge_cb_trace, false),
|
DEFINE_PROP_BOOL("edge_cb_trace", nyx_interface_state, edge_cb_trace, false),
|
||||||
DEFINE_PROP_UINT32("aux_buffer_size",
|
DEFINE_PROP_UINT32("aux_buffer_size",
|
||||||
nyx_interface_state,
|
nyx_interface_state,
|
||||||
|
10
nyx/pt.c
10
nyx/pt.c
@ -52,6 +52,12 @@ along with QEMU-PT. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#define PT_BUFFER_MMAP_ADDR 0x3ffff0000000
|
#define PT_BUFFER_MMAP_ADDR 0x3ffff0000000
|
||||||
|
|
||||||
|
static bool PT_ENABLED = false;
|
||||||
|
|
||||||
|
void set_global_pt_enabled(bool pt_enabled) {
|
||||||
|
PT_ENABLED = pt_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
static void pt_set(CPUState *cpu, run_on_cpu_data arg)
|
static void pt_set(CPUState *cpu, run_on_cpu_data arg)
|
||||||
{
|
{
|
||||||
asm volatile("" ::: "memory");
|
asm volatile("" ::: "memory");
|
||||||
@ -257,7 +263,7 @@ void pt_pre_kvm_run(CPUState *cpu)
|
|||||||
GET_GLOBAL_STATE()->redqueen_disable_pending = false;
|
GET_GLOBAL_STATE()->redqueen_disable_pending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GET_GLOBAL_STATE()->pt_trace_mode || GET_GLOBAL_STATE()->pt_trace_mode_force)
|
if (PT_ENABLED && (GET_GLOBAL_STATE()->pt_trace_mode || GET_GLOBAL_STATE()->pt_trace_mode_force))
|
||||||
{
|
{
|
||||||
if (!cpu->pt_fd) {
|
if (!cpu->pt_fd) {
|
||||||
cpu->pt_fd = kvm_vcpu_ioctl(cpu, KVM_VMX_PT_SETUP_FD, (unsigned long)0);
|
cpu->pt_fd = kvm_vcpu_ioctl(cpu, KVM_VMX_PT_SETUP_FD, (unsigned long)0);
|
||||||
@ -357,7 +363,7 @@ void pt_handle_overflow(CPUState *cpu)
|
|||||||
|
|
||||||
void pt_post_kvm_run(CPUState *cpu)
|
void pt_post_kvm_run(CPUState *cpu)
|
||||||
{
|
{
|
||||||
if (GET_GLOBAL_STATE()->pt_trace_mode || GET_GLOBAL_STATE()->pt_trace_mode_force)
|
if (PT_ENABLED && (GET_GLOBAL_STATE()->pt_trace_mode || GET_GLOBAL_STATE()->pt_trace_mode_force))
|
||||||
{
|
{
|
||||||
pt_handle_overflow(cpu);
|
pt_handle_overflow(cpu);
|
||||||
}
|
}
|
||||||
|
2
nyx/pt.h
2
nyx/pt.h
@ -22,6 +22,8 @@ along with QEMU-PT. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#ifndef PT_H
|
#ifndef PT_H
|
||||||
#define PT_H
|
#define PT_H
|
||||||
|
|
||||||
|
void set_global_pt_enabled(bool pt_enabled);
|
||||||
|
|
||||||
int pt_enable(CPUState *cpu, bool hmp_mode);
|
int pt_enable(CPUState *cpu, bool hmp_mode);
|
||||||
int pt_disable(CPUState *cpu, bool hmp_mode);
|
int pt_disable(CPUState *cpu, bool hmp_mode);
|
||||||
int pt_enable_ip_filtering(CPUState *cpu, uint8_t addrn, bool redqueen, bool hmp_mode);
|
int pt_enable_ip_filtering(CPUState *cpu, uint8_t addrn, bool redqueen, bool hmp_mode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user