Accroding to the Intel® 64 and IA-32 Architectures Software Developer’s Manual.pdf section 35.2.7.6 IA32_RTIT_CR3_MATCH MSR Intel says Bits 63:5 hold the CR3 address value to match, bits 4:0 are reserved to 0.

But in your code at simple-pt.c line 774 function set_cr3_filter
static void set_cr3_filter(void *arg)
{
u64 val;
if (pt_rdmsrl_safe(MSR_IA32_RTIT_CTL, &val) < 0)
return;
if ((val & TRACE_EN) && pt_wrmsrl_safe(MSR_IA32_RTIT_CTL, val & ~TRACE_EN) < 0)
return;
if (pt_wrmsrl_safe(MSR_IA32_CR3_MATCH, *(u64 *)arg) < 0)
pr_err("cpu %d, cannot set cr3 filter\n", smp_processor_id());
if ((val & TRACE_EN) && pt_wrmsrl_safe(MSR_IA32_RTIT_CTL, val) < 0)
return;
}
You haven't set the low 5bit of arg(the value of cr3) to 0, this may cause general-protection fault (#GP)
We know when low 5 bit is 0 ,the mask is 0xffffffffffffffe0
hex(0b1111111111111111111111111111111111111111111111111111111111100000)=0xffffffffffffffe0L
so this is my code for set_cr3_filter,you can ignore the code for logging.
static void set_cr3_filter_fix(void *arg)
{
u64 val;
if (pt_rdmsrl_safe(MSR_IA32_RTIT_CTL, &val) < 0)
return;
if ((val & TRACE_EN) && pt_wrmsrl_safe(MSR_IA32_RTIT_CTL, val & ~TRACE_EN) < 0)
return;
pr_err("now arg: %p,before set_cr3_filter",*(u64 *)arg);
pr_err("simple-pt:Cpu %d Ready to set_cr3_filter: cr3:%p",smp_processor_id(),(*(u64 *)arg )&0xffffffffffffffe0 ) ;
if (pt_wrmsrl_safe(MSR_IA32_CR3_MATCH, (*(u64 *)arg )&0xffffffffffffffe0 ) < 0)
pr_err("cpu %d, cannot set cr3 filter\n", smp_processor_id());
if ((val & TRACE_EN) && pt_wrmsrl_safe(MSR_IA32_RTIT_CTL, val) < 0)
return;
}
And i have another question, after I perform this patch. I can only get trace log for my specific process in ring0 code,but can not get any log for my specific process in ring3 code. I wonder know it's my code error or i have not understand the mechanism of cr3 filter? Could you help figure out this question?
I want to use cr3 filter to trace an specific process both ring0 and cr3 code. thanks all.
Accroding to the

Intel® 64 and IA-32 Architectures Software Developer’s Manual.pdfsection 35.2.7.6IA32_RTIT_CR3_MATCH MSRIntel saysBits 63:5 hold the CR3 address value to match, bits 4:0 are reserved to 0.But in your code at simple-pt.c line 774 function set_cr3_filter
You haven't set the low 5bit of arg(the value of cr3) to 0, this may cause
general-protection fault (#GP)We know when low 5 bit is 0 ,the mask is 0xffffffffffffffe0
hex(0b1111111111111111111111111111111111111111111111111111111111100000)=0xffffffffffffffe0Lso this is my code for
set_cr3_filter,you can ignore the code for logging.And i have another question, after I perform this patch. I can only get trace log for my specific process in
ring0code,but can not get any log for my specific process inring3code. I wonder know it's my code error or i have not understand the mechanism of cr3 filter? Could you help figure out this question?I want to use cr3 filter to trace an specific process both ring0 and cr3 code. thanks all.