lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 8 Jul 2010 21:05:25 +0300
From:	Gleb Natapov <gleb@...hat.com>
To:	Marcelo Tosatti <mtosatti@...hat.com>
Cc:	kvm@...r.kernel.org, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, avi@...hat.com, mingo@...e.hu,
	a.p.zijlstra@...llo.nl, tglx@...utronix.de, hpa@...or.com,
	riel@...hat.com, cl@...ux-foundation.org
Subject: Re: [PATCH v4 08/12] Inject asynchronous page fault into a guest
 if page is swapped out.

On Thu, Jul 08, 2010 at 12:59:20PM -0300, Marcelo Tosatti wrote:
> > +static int apf_put_user(struct kvm_vcpu *vcpu, u32 val)
> > +{
> > +	if (unlikely(vcpu->arch.apf_memslot_ver !=
> > +		     vcpu->kvm->memslot_version)) {
> > +		u64 gpa = vcpu->arch.apf_msr_val & ~0x3f;
> > +		unsigned long addr;
> > +		int offset = offset_in_page(gpa);
> > +
> > +		addr = gfn_to_hva(vcpu->kvm, gpa >> PAGE_SHIFT);
> > +		vcpu->arch.apf_data = (u32 __user*)(addr + offset);
> > +		if (kvm_is_error_hva(addr)) {
> > +			vcpu->arch.apf_data = NULL;
> > +			return -EFAULT;
> > +		}
> > +	}
> > +
> > +	return put_user(val, vcpu->arch.apf_data);
> > +}
> 
> Why not use kvm_write_guest?
Because I want to cache gfn_to_hva() translation, so this code tracks
memslot changes and does translation only when needed (almost never).

> 
> > +int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn,
> > +		       struct kvm_arch_async_pf *arch)
> > +{
> > +	struct kvm_async_pf *work;
> > +
> > +	if (vcpu->async_pf_queued >= ASYNC_PF_PER_VCPU)
> > +		return 0;
> > +
> > +	/* setup slow work */
> > +
> > +	/* do alloc atomic since if we are going to sleep anyway we
> > +	   may as well sleep faulting in page */
> > +	work = kmem_cache_zalloc(async_pf_cache, GFP_ATOMIC);
> > +	if (!work)
> > +		return 0;
> 
> GFP_KERNEL is fine for this context.
But it can sleep, no? The comment explains why I don't want to sleep
here.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ