The host always sets cr0.wp (in shadow mode) so we can write protectAvi,
page tables. So when the guest clears cr0.wp, we emulate a gpte with
gpte.w=0 and gpte.u=1 in two ways:
- spte.w=1, spte.u=0: this will allow the guest kernel to write but trap
on guest user access
- spte.w=0, spte.u=1: allows guest user access but traps on guest kernel
writes
If the guest attempts an access that is currently disallowed, we switch
to the other spte encoding.
Thanks for your explanation, but i not see where to implement what you say,
could you please point it out for me? :-(
- } else
- /*
- * Kernel mode access. Fail if it's a read-only page and
- * supervisor write protection is enabled.
- */
- if (!writable_shadow) {
- if (is_write_protection(vcpu))
- return 0;
- *shadow_ent &= ~PT_USER_MASK;
- }
And, i think use 'spte.w=1, spte.u=0' to emulate 'guest cr0.wp=0 and gpte.w=0'
is not a good way since it can completely stop user process access, but in this
case, user process is usually read and kernel lazily to write, just like vdso,
it will generate a lots of #PF