diff options
author | Avi Kivity <avi@redhat.com> | 2010-05-27 07:35:58 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-06-09 11:48:37 -0400 |
commit | 69325a122580d3a7b26589e8efdd6663001c3297 (patch) | |
tree | 714358f2e6229e699740bc249b2327b10ba67854 /arch | |
parent | 3be2264be3c00865116f997dc53ebcc90fe7fc4b (diff) |
KVM: MMU: Remove user access when allowing kernel access to gpte.w=0 page
If cr0.wp=0, we have to allow the guest kernel access to a page with pte.w=0.
We do that by setting spte.w=1, since the host cr0.wp must remain set so the
host can write protect pages. Once we allow write access, we must remove
user access otherwise we mistakenly allow the user to write the page.
Reviewed-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/mmu.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 6fbcb48d5a9b..a6f695d76928 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -1815,6 +1815,9 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, | |||
1815 | 1815 | ||
1816 | spte |= PT_WRITABLE_MASK; | 1816 | spte |= PT_WRITABLE_MASK; |
1817 | 1817 | ||
1818 | if (!tdp_enabled && !(pte_access & ACC_WRITE_MASK)) | ||
1819 | spte &= ~PT_USER_MASK; | ||
1820 | |||
1818 | /* | 1821 | /* |
1819 | * Optimization: for pte sync, if spte was writable the hash | 1822 | * Optimization: for pte sync, if spte was writable the hash |
1820 | * lookup is unnecessary (and expensive). Write protection | 1823 | * lookup is unnecessary (and expensive). Write protection |