kvm-s390.c (593d0a3e9f813db910dc50574532914db21d09ff) kvm-s390.c (2df72e9bc4c505d8357012f2924589f3d16f9d44)
1/*
2 * hosting zSeries kernel virtual machines
3 *
4 * Copyright IBM Corp. 2008, 2009
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.

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

27#include <asm/lowcore.h>
28#include <asm/pgtable.h>
29#include <asm/nmi.h>
30#include <asm/switch_to.h>
31#include <asm/sclp.h>
32#include "kvm-s390.h"
33#include "gaccess.h"
34
1/*
2 * hosting zSeries kernel virtual machines
3 *
4 * Copyright IBM Corp. 2008, 2009
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.

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

27#include <asm/lowcore.h>
28#include <asm/pgtable.h>
29#include <asm/nmi.h>
30#include <asm/switch_to.h>
31#include <asm/sclp.h>
32#include "kvm-s390.h"
33#include "gaccess.h"
34
35#define CREATE_TRACE_POINTS
36#include "trace.h"
37#include "trace-s390.h"
38
35#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
36
37struct kvm_stats_debugfs_item debugfs_entries[] = {
38 { "userspace_handled", VCPU_STAT(exit_userspace) },
39 { "exit_null", VCPU_STAT(exit_null) },
40 { "exit_validity", VCPU_STAT(exit_validity) },
41 { "exit_stop_request", VCPU_STAT(exit_stop_request) },
42 { "exit_external_request", VCPU_STAT(exit_external_request) },

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

237 free_page((unsigned long)(kvm->arch.sca));
238out_err:
239 return rc;
240}
241
242void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
243{
244 VCPU_EVENT(vcpu, 3, "%s", "free cpu");
39#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
40
41struct kvm_stats_debugfs_item debugfs_entries[] = {
42 { "userspace_handled", VCPU_STAT(exit_userspace) },
43 { "exit_null", VCPU_STAT(exit_null) },
44 { "exit_validity", VCPU_STAT(exit_validity) },
45 { "exit_stop_request", VCPU_STAT(exit_stop_request) },
46 { "exit_external_request", VCPU_STAT(exit_external_request) },

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

241 free_page((unsigned long)(kvm->arch.sca));
242out_err:
243 return rc;
244}
245
246void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
247{
248 VCPU_EVENT(vcpu, 3, "%s", "free cpu");
249 trace_kvm_s390_destroy_vcpu(vcpu->vcpu_id);
245 if (!kvm_is_ucontrol(vcpu->kvm)) {
246 clear_bit(63 - vcpu->vcpu_id,
247 (unsigned long *) &vcpu->kvm->arch.sca->mcn);
248 if (vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda ==
249 (__u64) vcpu->arch.sie_block)
250 vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda = 0;
251 }
252 smp_mb();

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

412 vcpu->arch.local_int.cpuflags = &vcpu->arch.sie_block->cpuflags;
413 spin_unlock(&kvm->arch.float_int.lock);
414
415 rc = kvm_vcpu_init(vcpu, kvm, id);
416 if (rc)
417 goto out_free_sie_block;
418 VM_EVENT(kvm, 3, "create cpu %d at %p, sie block at %p", id, vcpu,
419 vcpu->arch.sie_block);
250 if (!kvm_is_ucontrol(vcpu->kvm)) {
251 clear_bit(63 - vcpu->vcpu_id,
252 (unsigned long *) &vcpu->kvm->arch.sca->mcn);
253 if (vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda ==
254 (__u64) vcpu->arch.sie_block)
255 vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda = 0;
256 }
257 smp_mb();

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

417 vcpu->arch.local_int.cpuflags = &vcpu->arch.sie_block->cpuflags;
418 spin_unlock(&kvm->arch.float_int.lock);
419
420 rc = kvm_vcpu_init(vcpu, kvm, id);
421 if (rc)
422 goto out_free_sie_block;
423 VM_EVENT(kvm, 3, "create cpu %d at %p, sie block at %p", id, vcpu,
424 vcpu->arch.sie_block);
425 trace_kvm_s390_create_vcpu(id, vcpu, vcpu->arch.sie_block);
420
421 return vcpu;
422out_free_sie_block:
423 free_page((unsigned long)(vcpu->arch.sie_block));
424out_free_cpu:
425 kfree(vcpu);
426out:
427 return ERR_PTR(rc);

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

602 kvm_s390_deliver_pending_interrupts(vcpu);
603
604 vcpu->arch.sie_block->icptcode = 0;
605 local_irq_disable();
606 kvm_guest_enter();
607 local_irq_enable();
608 VCPU_EVENT(vcpu, 6, "entering sie flags %x",
609 atomic_read(&vcpu->arch.sie_block->cpuflags));
426
427 return vcpu;
428out_free_sie_block:
429 free_page((unsigned long)(vcpu->arch.sie_block));
430out_free_cpu:
431 kfree(vcpu);
432out:
433 return ERR_PTR(rc);

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

608 kvm_s390_deliver_pending_interrupts(vcpu);
609
610 vcpu->arch.sie_block->icptcode = 0;
611 local_irq_disable();
612 kvm_guest_enter();
613 local_irq_enable();
614 VCPU_EVENT(vcpu, 6, "entering sie flags %x",
615 atomic_read(&vcpu->arch.sie_block->cpuflags));
616 trace_kvm_s390_sie_enter(vcpu,
617 atomic_read(&vcpu->arch.sie_block->cpuflags));
610 rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
611 if (rc) {
612 if (kvm_is_ucontrol(vcpu->kvm)) {
613 rc = SIE_INTERCEPT_UCONTROL;
614 } else {
615 VCPU_EVENT(vcpu, 3, "%s", "fault in sie instruction");
618 rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
619 if (rc) {
620 if (kvm_is_ucontrol(vcpu->kvm)) {
621 rc = SIE_INTERCEPT_UCONTROL;
622 } else {
623 VCPU_EVENT(vcpu, 3, "%s", "fault in sie instruction");
624 trace_kvm_s390_sie_fault(vcpu);
616 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
617 rc = 0;
618 }
619 }
620 VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
621 vcpu->arch.sie_block->icptcode);
625 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
626 rc = 0;
627 }
628 }
629 VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
630 vcpu->arch.sie_block->icptcode);
631 trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
622 local_irq_disable();
623 kvm_guest_exit();
624 local_irq_enable();
625
626 memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
627 return rc;
628}
629

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

954
955 rc = gmap_map_segment(kvm->arch.gmap, mem->userspace_addr,
956 mem->guest_phys_addr, mem->memory_size);
957 if (rc)
958 printk(KERN_WARNING "kvm-s390: failed to commit memory region\n");
959 return;
960}
961
632 local_irq_disable();
633 kvm_guest_exit();
634 local_irq_enable();
635
636 memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
637 return rc;
638}
639

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

964
965 rc = gmap_map_segment(kvm->arch.gmap, mem->userspace_addr,
966 mem->guest_phys_addr, mem->memory_size);
967 if (rc)
968 printk(KERN_WARNING "kvm-s390: failed to commit memory region\n");
969 return;
970}
971
962void kvm_arch_flush_shadow(struct kvm *kvm)
972void kvm_arch_flush_shadow_all(struct kvm *kvm)
963{
964}
965
973{
974}
975
976void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
977 struct kvm_memory_slot *slot)
978{
979}
980
966static int __init kvm_s390_init(void)
967{
968 int ret;
969 ret = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
970 if (ret)
971 return ret;
972
973 /*

--- 23 unchanged lines hidden ---
981static int __init kvm_s390_init(void)
982{
983 int ret;
984 ret = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
985 if (ret)
986 return ret;
987
988 /*

--- 23 unchanged lines hidden ---