diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-04-07 14:33:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-04-07 14:33:04 -0400 |
commit | 7bc30c23c8ace3821a6732bfbe7e8f1b0995a63e (patch) | |
tree | 3440c323f331fb2c0b5e84c206b3c73d70826ee6 /virt/kvm | |
parent | ccfeef0ff76ebd632ae51bc56700f0072c4f1864 (diff) | |
parent | bd22f5cfcfe8f68bf43b72daf4530cd7eedc9b7a (diff) |
Merge branch 'kvm-updates/2.6.39' of git://git.kernel.org/pub/scm/virt/kvm/kvm
* 'kvm-updates/2.6.39' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: move and fix substitue search for missing CPUID entries
KVM: fix XSAVE bit scanning
KVM: Enable async page fault processing
KVM: fix crash on irqfd deassign
Diffstat (limited to 'virt/kvm')
-rw-r--r-- | virt/kvm/eventfd.c | 2 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 23 |
2 files changed, 22 insertions, 3 deletions
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 36d8092dbb3f..73358d256fa2 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c | |||
@@ -90,7 +90,7 @@ irqfd_shutdown(struct work_struct *work) | |||
90 | * We know no new events will be scheduled at this point, so block | 90 | * We know no new events will be scheduled at this point, so block |
91 | * until all previously outstanding events have completed | 91 | * until all previously outstanding events have completed |
92 | */ | 92 | */ |
93 | flush_work(&irqfd->inject); | 93 | flush_work_sync(&irqfd->inject); |
94 | 94 | ||
95 | /* | 95 | /* |
96 | * It is now safe to release the object's resources | 96 | * It is now safe to release the object's resources |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 556e3efe5325..6330653480e4 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -1037,6 +1037,17 @@ static pfn_t get_fault_pfn(void) | |||
1037 | return fault_pfn; | 1037 | return fault_pfn; |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | int get_user_page_nowait(struct task_struct *tsk, struct mm_struct *mm, | ||
1041 | unsigned long start, int write, struct page **page) | ||
1042 | { | ||
1043 | int flags = FOLL_TOUCH | FOLL_NOWAIT | FOLL_HWPOISON | FOLL_GET; | ||
1044 | |||
1045 | if (write) | ||
1046 | flags |= FOLL_WRITE; | ||
1047 | |||
1048 | return __get_user_pages(tsk, mm, start, 1, flags, page, NULL, NULL); | ||
1049 | } | ||
1050 | |||
1040 | static inline int check_user_page_hwpoison(unsigned long addr) | 1051 | static inline int check_user_page_hwpoison(unsigned long addr) |
1041 | { | 1052 | { |
1042 | int rc, flags = FOLL_TOUCH | FOLL_HWPOISON | FOLL_WRITE; | 1053 | int rc, flags = FOLL_TOUCH | FOLL_HWPOISON | FOLL_WRITE; |
@@ -1070,7 +1081,14 @@ static pfn_t hva_to_pfn(struct kvm *kvm, unsigned long addr, bool atomic, | |||
1070 | if (writable) | 1081 | if (writable) |
1071 | *writable = write_fault; | 1082 | *writable = write_fault; |
1072 | 1083 | ||
1073 | npages = get_user_pages_fast(addr, 1, write_fault, page); | 1084 | if (async) { |
1085 | down_read(¤t->mm->mmap_sem); | ||
1086 | npages = get_user_page_nowait(current, current->mm, | ||
1087 | addr, write_fault, page); | ||
1088 | up_read(¤t->mm->mmap_sem); | ||
1089 | } else | ||
1090 | npages = get_user_pages_fast(addr, 1, write_fault, | ||
1091 | page); | ||
1074 | 1092 | ||
1075 | /* map read fault as writable if possible */ | 1093 | /* map read fault as writable if possible */ |
1076 | if (unlikely(!write_fault) && npages == 1) { | 1094 | if (unlikely(!write_fault) && npages == 1) { |
@@ -1093,7 +1111,8 @@ static pfn_t hva_to_pfn(struct kvm *kvm, unsigned long addr, bool atomic, | |||
1093 | return get_fault_pfn(); | 1111 | return get_fault_pfn(); |
1094 | 1112 | ||
1095 | down_read(¤t->mm->mmap_sem); | 1113 | down_read(¤t->mm->mmap_sem); |
1096 | if (check_user_page_hwpoison(addr)) { | 1114 | if (npages == -EHWPOISON || |
1115 | (!async && check_user_page_hwpoison(addr))) { | ||
1097 | up_read(¤t->mm->mmap_sem); | 1116 | up_read(¤t->mm->mmap_sem); |
1098 | get_page(hwpoison_page); | 1117 | get_page(hwpoison_page); |
1099 | return page_to_pfn(hwpoison_page); | 1118 | return page_to_pfn(hwpoison_page); |