aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kvm
diff options
context:
space:
mode:
authorMartin Schwidefsky <schwidefsky@de.ibm.com>2016-03-08 05:54:42 -0500
committerChristian Borntraeger <borntraeger@de.ibm.com>2016-06-20 03:46:49 -0400
commitb2d73b2a0ad1c758cb0c1acb01a911744b845942 (patch)
tree1b88c5ba8120fc53fc4c9ecb7993e73a7e68c664 /arch/s390/kvm
parent8ecb1a59d6c6674bc98e4eee0c2482490748e21a (diff)
s390/mm: extended gmap pte notifier
The current gmap pte notifier forces a pte into to a read-write state. If the pte is invalidated the gmap notifier is called to inform KVM that the mapping will go away. Extend this approach to allow read-write, read-only and no-access as possible target states and call the pte notifier for any change to the pte. This mechanism is used to temporarily set specific access rights for a pte without doing the heavy work of a true mprotect call. Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Diffstat (limited to 'arch/s390/kvm')
-rw-r--r--arch/s390/kvm/kvm-s390.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 67f1b6b4c060..b6e7f66f0f01 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/kvm.h> 22#include <linux/kvm.h>
23#include <linux/kvm_host.h> 23#include <linux/kvm_host.h>
24#include <linux/mman.h>
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/random.h> 26#include <linux/random.h>
26#include <linux/slab.h> 27#include <linux/slab.h>
@@ -185,7 +186,7 @@ static struct notifier_block kvm_clock_notifier = {
185int kvm_arch_hardware_setup(void) 186int kvm_arch_hardware_setup(void)
186{ 187{
187 gmap_notifier.notifier_call = kvm_gmap_notifier; 188 gmap_notifier.notifier_call = kvm_gmap_notifier;
188 gmap_register_ipte_notifier(&gmap_notifier); 189 gmap_register_pte_notifier(&gmap_notifier);
189 atomic_notifier_chain_register(&s390_epoch_delta_notifier, 190 atomic_notifier_chain_register(&s390_epoch_delta_notifier,
190 &kvm_clock_notifier); 191 &kvm_clock_notifier);
191 return 0; 192 return 0;
@@ -193,7 +194,7 @@ int kvm_arch_hardware_setup(void)
193 194
194void kvm_arch_hardware_unsetup(void) 195void kvm_arch_hardware_unsetup(void)
195{ 196{
196 gmap_unregister_ipte_notifier(&gmap_notifier); 197 gmap_unregister_pte_notifier(&gmap_notifier);
197 atomic_notifier_chain_unregister(&s390_epoch_delta_notifier, 198 atomic_notifier_chain_unregister(&s390_epoch_delta_notifier,
198 &kvm_clock_notifier); 199 &kvm_clock_notifier);
199} 200}
@@ -2272,16 +2273,16 @@ retry:
2272 return 0; 2273 return 0;
2273 /* 2274 /*
2274 * We use MMU_RELOAD just to re-arm the ipte notifier for the 2275 * We use MMU_RELOAD just to re-arm the ipte notifier for the
2275 * guest prefix page. gmap_ipte_notify will wait on the ptl lock. 2276 * guest prefix page. gmap_mprotect_notify will wait on the ptl lock.
2276 * This ensures that the ipte instruction for this request has 2277 * This ensures that the ipte instruction for this request has
2277 * already finished. We might race against a second unmapper that 2278 * already finished. We might race against a second unmapper that
2278 * wants to set the blocking bit. Lets just retry the request loop. 2279 * wants to set the blocking bit. Lets just retry the request loop.
2279 */ 2280 */
2280 if (kvm_check_request(KVM_REQ_MMU_RELOAD, vcpu)) { 2281 if (kvm_check_request(KVM_REQ_MMU_RELOAD, vcpu)) {
2281 int rc; 2282 int rc;
2282 rc = gmap_ipte_notify(vcpu->arch.gmap, 2283 rc = gmap_mprotect_notify(vcpu->arch.gmap,
2283 kvm_s390_get_prefix(vcpu), 2284 kvm_s390_get_prefix(vcpu),
2284 PAGE_SIZE * 2); 2285 PAGE_SIZE * 2, PROT_WRITE);
2285 if (rc) 2286 if (rc)
2286 return rc; 2287 return rc;
2287 goto retry; 2288 goto retry;