Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Marcus_B_
Beginner
237 Views

Branch Monitoring

Hi, I'm Marcus, I'm doing an academic research on branch monitoring using Branch Trace Store capabilities. Currently, i'm trying to implement a BTS monitor on Windows 7/8. I'm facing some challenges on such development and so I ask for any help. I made a question on performance forum, but anyone was able to answer me, so I feel free to ask here, since Vtune uses BTS monitoring on Windows. I intend to count taken branches within under specific conditions, so I developed a device driver to be interrupted when my DS buffer is full (threshold defined). I set up DS area properly and BTINT flag on MSR. I checked: processor is already correctly filling my buffer. However, I don't know how to be interrupt properly. From what I understood, processor will generate the interrupt on APIC performance counter defined vector, which, in my case, is 254. I can't register a line interrupt on 254 IRQ once it is in use by Windows APIC. I can register other IRQ numbers, but, of course, i'm not interrupted (I tested it, just for confirmation). Any ideas of how to proceed would be very helpful Thanks in Advance
0 Kudos
6 Replies
Marcus_B_
Beginner
237 Views

I finally registered my ISR routine, but I am not being interrupted. I am looking to see if my configuration is correct. I set DS MSR with the BTS structure, and I checked: addresses are correctly written. I set DEBUGCTL MSR with BTS, BTINT and LBR flags. Is is enough to generate the interruption ? Should I set something more, like MSR_PERF_GLOBAL MSR or other ? Thanks, Marcus
Dmitry_P_Intel1
Employee
237 Views

Hello Marcus,

From VTune engineers we have the following output on the question you raised:

1.    DEBUGCTL should have TR, BTS, and BTINT (bits 6, 7, 8) set.
2.    Default Windows PMI vector (0xFE) can be hooked using this function:
HalSetSystemInformation(HalProfileSourceInterruptHandler, sizeof(void*), &handler);
3.    In case interrupts stop arriving after the first PMI, you should manually unmask APIC’s PMI LVT entry in your PMI handler by writing 0xFE to IA32_X2APIC_LVT_PMI MSR (0x834) or through APIC memory, depending on your CPU version.

Hope that helps, 

Thansk & Regards, Dmitry

 

Marcus_B_
Beginner
237 Views

Really Helpful, Thanks a lot.
Maor_H_
Beginner
237 Views

Very helpful indeed.

But i have a problem with handler in:

HalSetSystemInformation(HalProfileSourceInterruptHandler, sizeof(void*), &handler);

since according to MSDN, handler should be a struct of type MCA_DRIVER_INFO. but when i do it, only the exception callback is called, and not my handler.

if i pass the handler directly (not via MCA_DRIVER_INFO), than i get INTERRUPT_EXCEPTION_NOT_HANDLED.

Marcus_B_
Beginner
237 Views

In fact I did not tested this yet, but would be great to know how to make it work!
Maor_H_
Beginner
237 Views

oh i see...

would be great to see how to make it work. up until now i only get BSODs :)

i wonder what am i missing with this handler...

Reply