kvm-s390.c (b0c632db637d68ad39d9f97f452ce176253f5f4e) kvm-s390.c (8f2abe6a1e525e878bdf58f68ccd146d543fde84)
1/*
2 * s390host.c -- hosting zSeries kernel virtual machines
3 *
4 * Copyright IBM Corp. 2008
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only)
8 * as published by the Free Software Foundation.

--- 9 unchanged lines hidden (view full) ---

18#include <linux/init.h>
19#include <linux/kvm.h>
20#include <linux/kvm_host.h>
21#include <linux/module.h>
22#include <linux/slab.h>
23#include <asm/lowcore.h>
24#include <asm/pgtable.h>
25
1/*
2 * s390host.c -- hosting zSeries kernel virtual machines
3 *
4 * Copyright IBM Corp. 2008
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only)
8 * as published by the Free Software Foundation.

--- 9 unchanged lines hidden (view full) ---

18#include <linux/init.h>
19#include <linux/kvm.h>
20#include <linux/kvm_host.h>
21#include <linux/module.h>
22#include <linux/slab.h>
23#include <asm/lowcore.h>
24#include <asm/pgtable.h>
25
26#include "kvm-s390.h"
26#include "gaccess.h"
27
28#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
29
30struct kvm_stats_debugfs_item debugfs_entries[] = {
31 { "userspace_handled", VCPU_STAT(exit_userspace) },
27#include "gaccess.h"
28
29#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
30
31struct kvm_stats_debugfs_item debugfs_entries[] = {
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 }
33};
34
35
36/* Section: not file related */
37void kvm_arch_hardware_enable(void *garbage)
38{
39 /* every s390 is virtualization enabled ;-) */

--- 335 unchanged lines hidden (view full) ---

375 kvm_guest_exit();
376 local_irq_enable();
377
378 memcpy(&vcpu->arch.guest_gprs[14], &vcpu->arch.sie_block->gg14, 16);
379}
380
381int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
382{
37 { NULL }
38};
39
40
41/* Section: not file related */
42void kvm_arch_hardware_enable(void *garbage)
43{
44 /* every s390 is virtualization enabled ;-) */

--- 335 unchanged lines hidden (view full) ---

380 kvm_guest_exit();
381 local_irq_enable();
382
383 memcpy(&vcpu->arch.guest_gprs[14], &vcpu->arch.sie_block->gg14, 16);
384}
385
386int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
387{
388 int rc;
383 sigset_t sigsaved;
384
385 vcpu_load(vcpu);
386
387 if (vcpu->sigset_active)
388 sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
389
390 atomic_set_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags);
391
389 sigset_t sigsaved;
390
391 vcpu_load(vcpu);
392
393 if (vcpu->sigset_active)
394 sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
395
396 atomic_set_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags);
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 }
393
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 }
437
394 if (vcpu->sigset_active)
395 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
396
397 vcpu_put(vcpu);
398
399 vcpu->stat.exit_userspace++;
400 return 0;
401}

--- 165 unchanged lines hidden ---
438 if (vcpu->sigset_active)
439 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
440
441 vcpu_put(vcpu);
442
443 vcpu->stat.exit_userspace++;
444 return 0;
445}

--- 165 unchanged lines hidden ---