diff options
author | Christian Borntraeger <borntraeger@de.ibm.com> | 2008-03-25 13:47:23 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-04-27 05:00:43 -0400 |
commit | 8f2abe6a1e525e878bdf58f68ccd146d543fde84 (patch) | |
tree | 5f52959474a16847c740fb8668ebd9d6cbc75d07 /arch/s390/kvm/kvm-s390.c | |
parent | b0c632db637d68ad39d9f97f452ce176253f5f4e (diff) |
KVM: s390: sie intercept handling
This path introduces handling of sie intercepts in three flavors: Intercepts
are either handled completely in-kernel by kvm_handle_sie_intercept(),
or passed to userspace with corresponding data in struct kvm_run in case
kvm_handle_sie_intercept() returns -ENOTSUPP.
In case of partial execution in kernel with the need of userspace support,
kvm_handle_sie_intercept() may choose to set up struct kvm_run and return
-EREMOTE.
The trivial intercept reasons are handled in this patch:
handle_noop() just does nothing for intercepts that don't require our support
at all
handle_stop() is called when a cpu enters stopped state, and it drops out to
userland after updating our vcpu state
handle_validity() faults in the cpu lowcore if needed, or passes the request
to userland
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/s390/kvm/kvm-s390.c')
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 6e1e1d39ae15..a906499214bb 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -23,12 +23,17 @@ | |||
23 | #include <asm/lowcore.h> | 23 | #include <asm/lowcore.h> |
24 | #include <asm/pgtable.h> | 24 | #include <asm/pgtable.h> |
25 | 25 | ||
26 | #include "kvm-s390.h" | ||
26 | #include "gaccess.h" | 27 | #include "gaccess.h" |
27 | 28 | ||
28 | #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU | 29 | #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU |
29 | 30 | ||
30 | struct kvm_stats_debugfs_item debugfs_entries[] = { | 31 | struct kvm_stats_debugfs_item debugfs_entries[] = { |
31 | { "userspace_handled", VCPU_STAT(exit_userspace) }, | 32 | { "userspace_handled", VCPU_STAT(exit_userspace) }, |
33 | { "exit_validity", VCPU_STAT(exit_validity) }, | ||
34 | { "exit_stop_request", VCPU_STAT(exit_stop_request) }, | ||
35 | { "exit_external_request", VCPU_STAT(exit_external_request) }, | ||
36 | { "exit_external_interrupt", VCPU_STAT(exit_external_interrupt) }, | ||
32 | { NULL } | 37 | { NULL } |
33 | }; | 38 | }; |
34 | 39 | ||
@@ -380,6 +385,7 @@ static void __vcpu_run(struct kvm_vcpu *vcpu) | |||
380 | 385 | ||
381 | int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | 386 | int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) |
382 | { | 387 | { |
388 | int rc; | ||
383 | sigset_t sigsaved; | 389 | sigset_t sigsaved; |
384 | 390 | ||
385 | vcpu_load(vcpu); | 391 | vcpu_load(vcpu); |
@@ -389,7 +395,45 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
389 | 395 | ||
390 | atomic_set_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); | 396 | atomic_set_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); |
391 | 397 | ||
392 | __vcpu_run(vcpu); | 398 | switch (kvm_run->exit_reason) { |
399 | case KVM_EXIT_S390_SIEIC: | ||
400 | vcpu->arch.sie_block->gpsw.mask = kvm_run->s390_sieic.mask; | ||
401 | vcpu->arch.sie_block->gpsw.addr = kvm_run->s390_sieic.addr; | ||
402 | break; | ||
403 | case KVM_EXIT_UNKNOWN: | ||
404 | case KVM_EXIT_S390_RESET: | ||
405 | break; | ||
406 | default: | ||
407 | BUG(); | ||
408 | } | ||
409 | |||
410 | might_sleep(); | ||
411 | |||
412 | do { | ||
413 | __vcpu_run(vcpu); | ||
414 | |||
415 | rc = kvm_handle_sie_intercept(vcpu); | ||
416 | } while (!signal_pending(current) && !rc); | ||
417 | |||
418 | if (signal_pending(current) && !rc) | ||
419 | rc = -EINTR; | ||
420 | |||
421 | if (rc == -ENOTSUPP) { | ||
422 | /* intercept cannot be handled in-kernel, prepare kvm-run */ | ||
423 | kvm_run->exit_reason = KVM_EXIT_S390_SIEIC; | ||
424 | kvm_run->s390_sieic.icptcode = vcpu->arch.sie_block->icptcode; | ||
425 | kvm_run->s390_sieic.mask = vcpu->arch.sie_block->gpsw.mask; | ||
426 | kvm_run->s390_sieic.addr = vcpu->arch.sie_block->gpsw.addr; | ||
427 | kvm_run->s390_sieic.ipa = vcpu->arch.sie_block->ipa; | ||
428 | kvm_run->s390_sieic.ipb = vcpu->arch.sie_block->ipb; | ||
429 | rc = 0; | ||
430 | } | ||
431 | |||
432 | if (rc == -EREMOTE) { | ||
433 | /* intercept was handled, but userspace support is needed | ||
434 | * kvm_run has been prepared by the handler */ | ||
435 | rc = 0; | ||
436 | } | ||
393 | 437 | ||
394 | if (vcpu->sigset_active) | 438 | if (vcpu->sigset_active) |
395 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); | 439 | sigprocmask(SIG_SETMASK, &sigsaved, NULL); |