From: Avi Kivity Date: Wed, 23 Jul 2008 08:43:43 +0000 (+0300) Subject: KVM: MMU: Fix potential race setting upper shadow ptes on nonpae hosts X-Git-Tag: v2.6.26.1~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c5a4a12d8d5bf025a09a576a0b5c62e0167423c;p=platform%2Fkernel%2Flinux-stable.git KVM: MMU: Fix potential race setting upper shadow ptes on nonpae hosts Original-Commit-Hash: c23a6fe17abf8562e675465f8d55ba1a551d314d The direct mapped shadow code (used for real mode and two dimensional paging) sets upper-level ptes using direct assignment rather than calling set_shadow_pte(). A nonpae host will split this into two writes, which opens up a race if another vcpu accesses the same memory area. Fix by calling set_shadow_pte() instead of assigning directly. Noticed by Izik Eidus. Signed-off-by: Avi Kivity Signed-off-by: Greg Kroah-Hartman --- diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index c640b2f96c86..c26d811d9191 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1171,9 +1171,10 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write, return -ENOMEM; } - table[index] = __pa(new_table->spt) - | PT_PRESENT_MASK | PT_WRITABLE_MASK - | shadow_user_mask | shadow_x_mask; + set_shadow_pte(&table[index], + __pa(new_table->spt) + | PT_PRESENT_MASK | PT_WRITABLE_MASK + | shadow_user_mask | shadow_x_mask); } table_addr = table[index] & PT64_BASE_ADDR_MASK; }