On 20 August 2018 at 16:07, Probir Roy <r...@probir.info> wrote: >> What exactly are you trying to do >> with your new signal ? > > I am implementing PEBS (Intel's Precise-Event Based Sampling) > virtualization, so that I can sample guest OS from host machine using > Linux Perf. The PEBS device is configured from host's user space as > perf event. I am registering a perf-event using "perf_event_open" in > kvm_cpu_exec: > > +++ accel/kvm/kvm-all.c 2018-08-07 11:01:05.326280431 -0500 > @@ -1903,6 +1904,12 @@ > qemu_mutex_unlock_iothread(); > cpu_exec_start(cpu); > > + /* Probir: vcpu thread starting. Should call the tool thread handler*/ > + kvm__VCPU_start(); // calling perf_event_open > > > "kvm__VCPU_start" calling perf_event_open and a signal handler > "generic_dev_signal_handler" is set via sigaction: > > // Set a signal handler for SIGUSR1 > struct sigaction sa; > sa.sa_sigaction = generic_dev_signal_handler; > sa.sa_mask = block_mask_dev; > sa.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER | SA_ONSTACK;
You cannot use SIGUSR1 for this. QEMU uses it internally as its SIG_IPI (inter-vcpu-communication). You'll need to get the perf code to use a different signal. (And you'll need to manually unblock that signal on the CPU thread when you install your handler.) > I am expecting to perform some task in "generic_dev_signal_handler" at > PEBS event when the VCPU is halted. This task can be reading/writing > hardware registers at that event point. Guest or host hardware registers? Either way, this is tricky stuff to be trying to do in a signal handler. thanks -- PMM