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:	Tue, 15 Jun 2010 14:22:06 +0300
From:	Avi Kivity <avi@...hat.com>
To:	Xiao Guangrong <xiaoguangrong@...fujitsu.com>
CC:	Marcelo Tosatti <mtosatti@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>,
	KVM list <kvm@...r.kernel.org>,
	Andi Kleen <andi@...stfloor.org>,
	Huang Ying <ying.huang@...el.com>
Subject: Re: [PATCH 3/6] KVM: MMU: introduce gfn_to_page_atomic() and gfn_to_pfn_atomic()

On 06/15/2010 05:46 AM, Xiao Guangrong wrote:
> Introduce gfn_to_page_atomic() and gfn_to_pfn_atomic(), those
> functions is fast path and can used in atomic context, the later
> patch will use those
>
>
> @@ -942,6 +942,41 @@ unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn)
>   }
>   EXPORT_SYMBOL_GPL(gfn_to_hva);
>
> +static pfn_t hva_to_pfn_atomic(struct kvm *kvm, unsigned long addr)
> +{
> +	struct page *page[1];
> +	int npages;
> +	pfn_t pfn;
> +
> +	npages = __get_user_pages_fast(addr, 1, 1, page);
> +
> +	if (unlikely(npages != 1)) {
> +		if (is_hwpoison_address(addr)) {
> +			get_page(hwpoison_page);
> +			return page_to_pfn(hwpoison_page);
> +		}
> +		get_page(bad_page);
> +		return page_to_pfn(bad_page);
> +	} else
> +		pfn = page_to_pfn(page[0]);
> +
> +	return pfn;
> +}
>    

Too much duplication.  How about putting the tail end of the function in 
a common helper (with an inatomic flag)?

btw, is_hwpoison_address() is racy.  While it looks up the address, some 
other task can unmap the page tables under us.

Andi/Huang?

One way of fixing it is get_user_pages_ptes_fast(), which also returns 
the pte, also atomically.  I want it for other reasons as well (respond 
to a read fault by gupping the page for read, but allowing write access 
if the pte indicates it is writeable).


-- 
error compiling committee.c: too many arguments to function

--
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