From: Carsten Otte <cotte@de.ibm.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tossati <mtosatti@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
KVM <kvm@vger.kernel.org>,
Joachim von Buttlar <joachim_von_buttlar@de.ibm.com>,
Jens Freimann <jfrei@de.ibm.com>,
Constantin Werner <constantin.werner@de.ibm.com>,
Alexander Graf <agraf@suse.de>,
Xiantao Zhang <xiantao.zhang@intel.com>
Subject: [patch 04/12] [PATCH] kvm-s390-ucontrol: export SIE control block to user
Date: Thu, 08 Dec 2011 10:12:34 +0100 [thread overview]
Message-ID: <20111208091729.233353938@de.ibm.com> (raw)
In-Reply-To: 20111208091230.874920251@de.ibm.com
[-- Attachment #1: sie-control-block-to-user.patch --]
[-- Type: text/plain, Size: 3738 bytes --]
This patch exports the s390 SIE hardware control block to userspace
via the mapping of the vcpu file descriptor. In order to do so,
a new arch callback named kvm_arch_vcpu_fault is introduced for all
architectures. It allows to map architecture specific pages.
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
---
---
Documentation/virtual/kvm/api.txt | 5 +++++
arch/ia64/kvm/kvm-ia64.c | 5 +++++
arch/powerpc/kvm/powerpc.c | 5 +++++
arch/s390/kvm/kvm-s390.c | 13 +++++++++++++
arch/x86/kvm/x86.c | 5 +++++
include/linux/kvm.h | 1 +
include/linux/kvm_host.h | 1 +
virt/kvm/kvm_main.c | 2 +-
8 files changed, 36 insertions(+), 1 deletion(-)
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -218,6 +218,11 @@ allocation of vcpu ids. For example, if
single-threaded guest vcpus, it should make all vcpu ids be a multiple
of the number of vcpus per vcore.
+For virtual cpus that have been created with S390 user controlled virtual
+machines, the resulting vcpu fd can be memory mapped at page offset
+KVM_S390_SIE_PAGE_OFFSET in order to obtain a memory map of the virtual
+cpu's hardware control block.
+
4.8 KVM_GET_DIRTY_LOG (vm ioctl)
Capability: basic
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1566,6 +1566,11 @@ out:
return r;
}
+int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
+{
+ return VM_FAULT_SIGBUS;
+}
+
int kvm_arch_prepare_memory_region(struct kvm *kvm,
struct kvm_memory_slot *memslot,
struct kvm_memory_slot old,
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -659,6 +659,11 @@ out:
return r;
}
+int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
+{
+ return VM_FAULT_SIGBUS;
+}
+
static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)
{
u32 inst_lis = 0x3c000000;
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -769,6 +769,19 @@ long kvm_arch_vcpu_ioctl(struct file *fi
return r;
}
+int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
+{
+#ifdef CONFIG_KVM_UCONTROL
+ if ((vmf->pgoff == KVM_S390_SIE_PAGE_OFFSET)
+ && (kvm_is_ucontrol(vcpu->kvm))) {
+ vmf->page = virt_to_page(vcpu->arch.sie_block);
+ get_page(vmf->page);
+ return 0;
+ }
+#endif
+ return VM_FAULT_SIGBUS;
+}
+
/* Section: memory related */
int kvm_arch_prepare_memory_region(struct kvm *kvm,
struct kvm_memory_slot *memslot,
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2790,6 +2790,11 @@ out:
return r;
}
+int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
+{
+ return VM_FAULT_SIGBUS;
+}
+
static int kvm_vm_ioctl_set_tss_addr(struct kvm *kvm, unsigned long addr)
{
int ret;
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -439,6 +439,7 @@ struct kvm_ppc_pvinfo {
#define KVM_VM_REGULAR 0
#define KVM_VM_S390_UCONTROL 1
+#define KVM_S390_SIE_PAGE_OFFSET 1
/*
* ioctls for /dev/kvm fds:
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -449,6 +449,7 @@ long kvm_arch_dev_ioctl(struct file *fil
unsigned int ioctl, unsigned long arg);
long kvm_arch_vcpu_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg);
+int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf);
int kvm_dev_ioctl_check_extension(long ext);
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1657,7 +1657,7 @@ static int kvm_vcpu_fault(struct vm_area
page = virt_to_page(vcpu->kvm->coalesced_mmio_ring);
#endif
else
- return VM_FAULT_SIGBUS;
+ return kvm_arch_vcpu_fault(vcpu, vmf);
get_page(page);
vmf->page = page;
return 0;
next prev parent reply other threads:[~2011-12-08 9:17 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-08 9:12 [patch 00/12] Ucontrol patchset V2 Carsten Otte
2011-12-08 9:12 ` [patch 01/12] [PATCH] kvm-s390: ioctl to switch to user controlled virtual machines Carsten Otte
2011-12-08 9:25 ` Sasha Levin
2011-12-08 9:27 ` Carsten Otte
2011-12-08 9:45 ` Avi Kivity
2011-12-08 9:53 ` Sasha Levin
2011-12-08 9:59 ` Avi Kivity
2011-12-08 10:18 ` Alexander Graf
2011-12-08 11:48 ` Carsten Otte
2011-12-08 13:16 ` Alexander Graf
2011-12-08 9:12 ` [patch 02/12] [PATCH] kvm-s390-ucontrol: per vcpu address spaces Carsten Otte
2011-12-08 9:12 ` [patch 03/12] [PATCH] kvm-s390-ucontrol: export page faults to user Carsten Otte
2011-12-08 9:12 ` Carsten Otte [this message]
2011-12-08 9:12 ` [patch 05/12] [PATCH] kvm-s390-ucontrol: disable in-kernel handling of SIE intercepts Carsten Otte
2011-12-08 9:12 ` [patch 06/12] [PATCH] kvm-s390-ucontrol: disable in-kernel irq stack Carsten Otte
2011-12-08 9:12 ` [patch 07/12] [PATCH] kvm-s390-ucontrol: interface to inject faults on a vcpu page table Carsten Otte
2011-12-08 9:12 ` [patch 08/12] [PATCH] kvm-s390-ucontrol: disable sca Carsten Otte
2011-12-08 9:12 ` [patch 09/12] [PATCH] kvm-s390: fix assumption for KVM_MAX_VCPUS Carsten Otte
2011-12-08 9:12 ` [patch 10/12] [PATCH] kvm-s390: storage key interface Carsten Otte
2011-12-08 9:12 ` [patch 11/12] [PATCH] kvm-s390-ucontrol: announce capability for user controlled vms Carsten Otte
2011-12-08 9:12 ` [patch 12/12] [PATCH] kvm-s390: Fix return code for unknown ioctl numbers Carsten Otte
-- strict thread matches above, loose matches on Subject: below --
2011-12-14 12:23 [patch 00/12] Ucontrol patchset V6 Carsten Otte
2011-12-14 12:23 ` [patch 04/12] [PATCH] kvm-s390-ucontrol: export SIE control block to user Carsten Otte
2011-12-10 12:35 [patch 00/12] Ucontrol patchset V5 Carsten Otte
2011-12-10 12:35 ` [patch 04/12] [PATCH] kvm-s390-ucontrol: export SIE control block to user Carsten Otte
2011-12-09 12:49 [patch 00/12] Ucontrol patchset V4 Carsten Otte
2011-12-09 12:49 ` [patch 04/12] [PATCH] kvm-s390-ucontrol: export SIE control block to user Carsten Otte
2011-12-09 16:06 ` Alexander Graf
2011-12-10 11:25 ` Carsten Otte
2011-12-12 9:17 ` Avi Kivity
2011-12-12 9:45 ` Carsten Otte
2011-12-09 11:23 [patch 00/12] Ucontrol patches V3 Carsten Otte
2011-12-09 11:23 ` [patch 04/12] [PATCH] kvm-s390-ucontrol: export SIE control block to user Carsten Otte
2011-12-09 11:37 ` Alexander Graf
2011-12-09 11:54 ` Carsten Otte
2011-12-01 12:57 [patch 00/12] User controlled virtual machines Carsten Otte
2011-12-01 12:57 ` [patch 04/12] [PATCH] kvm-s390-ucontrol: export SIE control block to user Carsten Otte
2011-12-01 13:25 ` Avi Kivity
2011-12-01 13:26 ` Avi Kivity
2011-12-01 13:59 ` Carsten Otte
2011-12-01 14:04 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111208091729.233353938@de.ibm.com \
--to=cotte@de.ibm.com \
--cc=agraf@suse.de \
--cc=avi@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=constantin.werner@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=jfrei@de.ibm.com \
--cc=joachim_von_buttlar@de.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=schwidefsky@de.ibm.com \
--cc=xiantao.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).