Re: [PATCH 4/6] kvm: add host_writable parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 16, 2010 at 10:13:04AM +0800, Lai Jiangshan wrote:
> add host_writable parameter for some functions,
> no functionality changed, prepare for using RO pages.
> 
> 
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
> ---
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 0867ced..8ba9b0d 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -1861,7 +1861,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
>  		    unsigned pte_access, int user_fault,
>  		    int write_fault, int dirty, int level,
>  		    gfn_t gfn, pfn_t pfn, bool speculative,
> -		    bool can_unsync, bool reset_host_protection)
> +		    bool can_unsync, bool host_writable)
>  {
>  	u64 spte;
>  	int ret = 0;
> @@ -1888,8 +1888,10 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
>  		spte |= kvm_x86_ops->get_mt_mask(vcpu, gfn,
>  			kvm_is_mmio_pfn(pfn));
>  
> -	if (reset_host_protection)
> +	if (host_writable)
>  		spte |= SPTE_HOST_WRITEABLE;
> +	else
> +		pte_access &= ~ACC_WRITE_MASK;

Two vcpus faulting the same address with different access type can 
now race:

vcpu0                               vcpu1

read fault                          write fault
gfn_to_pfn readonly
                                    gfn_to_pfn write, break COW
                                    set writable spte to COWed page
                                    vcpu writes to page
set spte to original page
vcpu reads stale content

Should not instantiate a new spte if (pfn != spte_to_pfn(*sptep)), to
cause a refault.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux