[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4C50E43A.4020106@cn.fujitsu.com>
Date: Thu, 29 Jul 2010 10:15:22 +0800
From: Lai Jiangshan <laijs@...fujitsu.com>
To: Gleb Natapov <gleb@...hat.com>
CC: LKML <linux-kernel@...r.kernel.org>, kvm@...r.kernel.org,
Avi Kivity <avi@...hat.com>,
Marcelo Tosatti <mtosatti@...hat.com>,
Nick Piggin <npiggin@...e.de>
Subject: Re: [PATCH 5/6] kvm, x86: use ro page and don't copy shared page
On 07/16/2010 03:19 PM, Gleb Natapov wrote:
>> +/* get a current mapped page fast, and test whether the page is writable. */
>> +static struct page *get_user_page_and_protection(unsigned long addr,
>> + int *writable)
>> +{
>> + struct page *page[1];
>> +
>> + if (__get_user_pages_fast(addr, 1, 1, page) == 1) {
>> + *writable = 1;
>> + return page[0];
>> + }
>> + if (__get_user_pages_fast(addr, 1, 0, page) == 1) {
>> + *writable = 0;
>> + return page[0];
>> + }
>> + return NULL;
>> +}
>> +
>> +static pfn_t kvm_get_pfn_for_page_fault(struct kvm *kvm, gfn_t gfn,
>> + int write_fault, int *host_writable)
>> +{
>> + unsigned long addr;
>> + struct page *page;
>> +
>> + if (!write_fault) {
>> + addr = gfn_to_hva(kvm, gfn);
>> + if (kvm_is_error_hva(addr)) {
>> + get_page(bad_page);
>> + return page_to_pfn(bad_page);
>> + }
>> +
>> + page = get_user_page_and_protection(addr, host_writable);
>> + if (page)
>> + return page_to_pfn(page);
>> + }
>> +
>> + *host_writable = 1;
>> + return kvm_get_pfn_for_gfn(kvm, gfn);
>> +}
>> +
> kvm_get_pfn_for_gfn() returns fault_page if page is mapped RO, so caller
> of kvm_get_pfn_for_page_fault() and kvm_get_pfn_for_gfn() will get
> different results when called on the same page. Not good.
> kvm_get_pfn_for_page_fault() logic should be folded into
> kvm_get_pfn_for_gfn().
>
The different results are the things we just need.
We don't want to copy and write a page which is mapped RO when
only read fault.
--
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