Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 329867
b: refs/heads/master
c: 12ce13f
h: refs/heads/master
i:
  329865: 0ae6810
  329863: 3c98275
v: v3
  • Loading branch information
Xiao Guangrong authored and Avi Kivity committed Aug 22, 2012
1 parent ecfd825 commit 34461ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2fc843117d64b31c20d36c6b625c0626c9a41a41
refs/heads/master: 12ce13fea925ab629f2281be2b9b01cf647a86cd
24 changes: 23 additions & 1 deletion trunk/virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,14 @@ static bool hva_to_pfn_fast(unsigned long addr, bool atomic, bool *async,
if (!(async || atomic))
return false;

/*
* Fast pin a writable pfn only if it is a write fault request
* or the caller allows to map a writable pfn for a read fault
* request.
*/
if (!(write_fault || writable))
return false;

npages = __get_user_pages_fast(addr, 1, 1, page);
if (npages == 1) {
*pfn = page_to_pfn(page[0]);
Expand Down Expand Up @@ -1093,7 +1101,7 @@ static int hva_to_pfn_slow(unsigned long addr, bool *async, bool write_fault,
return npages;

/* map read fault as writable if possible */
if (unlikely(!write_fault)) {
if (unlikely(!write_fault) && writable) {
struct page *wpage[1];

npages = __get_user_pages_fast(addr, 1, 1, wpage);
Expand All @@ -1109,6 +1117,20 @@ static int hva_to_pfn_slow(unsigned long addr, bool *async, bool write_fault,
return npages;
}

/*
* Pin guest page in memory and return its pfn.
* @addr: host virtual address which maps memory to the guest
* @atomic: whether this function can sleep
* @async: whether this function need to wait IO complete if the
* host page is not in the memory
* @write_fault: whether we should get a writable host page
* @writable: whether it allows to map a writable host page for !@write_fault
*
* The function will map a writable host page for these two cases:
* 1): @write_fault = true
* 2): @write_fault = false && @writable, @writable will tell the caller
* whether the mapping is writable.
*/
static pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
bool write_fault, bool *writable)
{
Expand Down

0 comments on commit 34461ba

Please sign in to comment.