Skip to contentSkip to conversation

Handling a MEM_EVENT_REASON_CR3

DISCUSSION Razvan Cojocaru 2 participants 2 messages Dec 12, 2012 – Dec 13, 2012

lore
Share & tools
lore
#0 lore raw

Hello,

a few questions about receiving a MEM_EVENT_REASON_CR3 even in dom0 userspace:

1. If I call

xc_set_hvm_param(xci, domain_id,

                 HVM_PARAM_MEMORY_EVENT_CR3,
                 HVMPME_onchangeonly);

that only triggers a CR3 event if the new value that the guest writes to CR3 is different from the existing value, is that assumption correct?

2. mem_event.h says that if "CR3 was hit: gfn is CR3 value". I'm assuming that gfn is the _new_ value, and that the old value is unavailable, is that also correct?

3. Is it possible to, upon intercepting the CR3 write, write a _different_ value to CR3, instead of gfn?

Thanks,
Razvan Cojocaru

#1 lore raw
Quoted 5 lines · Razvan Cojocaru

Hello,

a few questions about receiving a MEM_EVENT_REASON_CR3 even in dom0 userspace:

Quoted 8 lines

1. If I call

xc_set_hvm_param(xci, domain_id,

                 HVM_PARAM_MEMORY_EVENT_CR3,
                 HVMPME_onchangeonly);

that only triggers a CR3 event if the new value that the guest writes to CR3 is different from the existing value, is that assumption correct?

Yes, I think so. That's what HVMPME_onchangeonly ought to do. Did you try it?

Quoted 3 lines

2. mem_event.h says that if "CR3 was hit: gfn is CR3 value". I'm assuming that gfn is the _new_ value, and that the old value is unavailable, is that also correct?

Yes.

Quoted 2 lines

3. Is it possible to, upon intercepting the CR3 write, write a _different_ value to CR3, instead of gfn?

Yes. you can use either xc_vcpu_getcontext()/xc_vcpu_setcontext() or xc_domain_hvm_getcontext_partial()/xc_domain_hvm_setcontext() to read and write the vCPU registers.

Cheers,

Tim.