summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Otte <cotte@de.ibm.com>2012-01-04 04:25:26 -0500
committerAvi Kivity <avi@redhat.com>2012-03-05 07:52:20 -0500
commitccc7910fe564d99415def7c041fa261e62a43011 (patch)
tree8895fd2463f7b4e48c4510284c37e84a1753ee0d
parentd6b6d166864fa97ca3b1ed1a5c62fd3b53d4606f (diff)
KVM: s390: ucontrol: interface to inject faults on a vcpu page table
This patch allows the user to fault in pages on a virtual cpus address space for user controlled virtual machines. Typically this is superfluous because userspace can just create a mapping and let the kernel's page fault logic take are of it. There is one exception: SIE won't start if the lowcore is not present. Normally the kernel takes care of this [handle_validity() in arch/s390/kvm/intercept.c] but since the kernel does not handle intercepts for user controlled virtual machines, userspace needs to be able to handle this condition. Signed-off-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--Documentation/virtual/kvm/api.txt16
-rw-r--r--arch/s390/kvm/kvm-s390.c6
-rw-r--r--include/linux/kvm.h1
3 files changed, 23 insertions, 0 deletions
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 5ebf47d99e56..a67fb35993fa 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1539,6 +1539,22 @@ This ioctl unmaps the memory in the vcpu's address space starting at
1539"vcpu_addr" with the length "length". The field "user_addr" is ignored. 1539"vcpu_addr" with the length "length". The field "user_addr" is ignored.
1540All parameters need to be alligned by 1 megabyte. 1540All parameters need to be alligned by 1 megabyte.
1541 1541
15424.66 KVM_S390_VCPU_FAULT
1543
1544Capability: KVM_CAP_S390_UCONTROL
1545Architectures: s390
1546Type: vcpu ioctl
1547Parameters: vcpu absolute address (in)
1548Returns: 0 in case of success
1549
1550This call creates a page table entry on the virtual cpu's address space
1551(for user controlled virtual machines) or the virtual machine's address
1552space (for regular virtual machines). This only works for minor faults,
1553thus it's recommended to access subject memory page via the user page
1554table upfront. This is useful to handle validity intercepts for user
1555controlled virtual machines to fault in the virtual cpu's lowcore pages
1556prior to calling the KVM_RUN ioctl.
1557
15425. The kvm_run structure 15585. The kvm_run structure
1543 1559
1544Application code obtains a pointer to the kvm_run structure by 1560Application code obtains a pointer to the kvm_run structure by
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 5b5c28e471df..8489edf80c89 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -761,6 +761,12 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
761 break; 761 break;
762 } 762 }
763#endif 763#endif
764 case KVM_S390_VCPU_FAULT: {
765 r = gmap_fault(arg, vcpu->arch.gmap);
766 if (!IS_ERR_VALUE(r))
767 r = 0;
768 break;
769 }
764 default: 770 default:
765 r = -EINVAL; 771 r = -EINVAL;
766 } 772 }
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 8f888df206a2..778e748927b4 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -675,6 +675,7 @@ struct kvm_s390_ucas_mapping {
675}; 675};
676#define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping) 676#define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping)
677#define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping) 677#define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping)
678#define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long)
678 679
679/* Device model IOC */ 680/* Device model IOC */
680#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 681#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60)