diff options
author | Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> | 2010-12-23 03:09:29 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-01-12 04:31:19 -0500 |
commit | f8e453b00cf1d90a047eb0ef8eefe6200e0f4512 (patch) | |
tree | 7347af552a9a0ca0ba2bf8e19e3c33721a7637e5 | |
parent | b034cf0105235e65ee1b0161dbe8fef0338d06e7 (diff) |
KVM: MMU: handle 'map_writable' in set_spte() function
Move the operation of 'writable' to set_spte() to clean up code
[avi: remove unneeded booleanification]
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/x86/kvm/mmu.c | 4 | ||||
-rw-r--r-- | arch/x86/kvm/paging_tmpl.h | 11 |
2 files changed, 4 insertions, 11 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 892ffc603ff9..9cafbb499813 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -1983,6 +1983,8 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, | |||
1983 | 1983 | ||
1984 | if (host_writable) | 1984 | if (host_writable) |
1985 | spte |= SPTE_HOST_WRITEABLE; | 1985 | spte |= SPTE_HOST_WRITEABLE; |
1986 | else | ||
1987 | pte_access &= ~ACC_WRITE_MASK; | ||
1986 | 1988 | ||
1987 | spte |= (u64)pfn << PAGE_SHIFT; | 1989 | spte |= (u64)pfn << PAGE_SHIFT; |
1988 | 1990 | ||
@@ -2222,8 +2224,6 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write, | |||
2222 | if (iterator.level == level) { | 2224 | if (iterator.level == level) { |
2223 | unsigned pte_access = ACC_ALL; | 2225 | unsigned pte_access = ACC_ALL; |
2224 | 2226 | ||
2225 | if (!map_writable) | ||
2226 | pte_access &= ~ACC_WRITE_MASK; | ||
2227 | mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, pte_access, | 2227 | mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, pte_access, |
2228 | 0, write, 1, &pt_write, | 2228 | 0, write, 1, &pt_write, |
2229 | level, gfn, pfn, prefault, map_writable); | 2229 | level, gfn, pfn, prefault, map_writable); |
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 5ca9426389b5..53210f1e94c2 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h | |||
@@ -511,9 +511,6 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, | |||
511 | link_shadow_page(it.sptep, sp); | 511 | link_shadow_page(it.sptep, sp); |
512 | } | 512 | } |
513 | 513 | ||
514 | if (!map_writable) | ||
515 | access &= ~ACC_WRITE_MASK; | ||
516 | |||
517 | mmu_set_spte(vcpu, it.sptep, access, gw->pte_access & access, | 514 | mmu_set_spte(vcpu, it.sptep, access, gw->pte_access & access, |
518 | user_fault, write_fault, dirty, ptwrite, it.level, | 515 | user_fault, write_fault, dirty, ptwrite, it.level, |
519 | gw->gfn, pfn, prefault, map_writable); | 516 | gw->gfn, pfn, prefault, map_writable); |
@@ -809,12 +806,8 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) | |||
809 | 806 | ||
810 | nr_present++; | 807 | nr_present++; |
811 | pte_access = sp->role.access & FNAME(gpte_access)(vcpu, gpte); | 808 | pte_access = sp->role.access & FNAME(gpte_access)(vcpu, gpte); |
812 | if (!(sp->spt[i] & SPTE_HOST_WRITEABLE)) { | 809 | host_writable = sp->spt[i] & SPTE_HOST_WRITEABLE; |
813 | pte_access &= ~ACC_WRITE_MASK; | 810 | |
814 | host_writable = 0; | ||
815 | } else { | ||
816 | host_writable = 1; | ||
817 | } | ||
818 | set_spte(vcpu, &sp->spt[i], pte_access, 0, 0, | 811 | set_spte(vcpu, &sp->spt[i], pte_access, 0, 0, |
819 | is_dirty_gpte(gpte), PT_PAGE_TABLE_LEVEL, gfn, | 812 | is_dirty_gpte(gpte), PT_PAGE_TABLE_LEVEL, gfn, |
820 | spte_to_pfn(sp->spt[i]), true, false, | 813 | spte_to_pfn(sp->spt[i]), true, false, |