aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/include/asm/kvm_host.h5
-rw-r--r--arch/s390/kernel/asm-offsets.c1
-rw-r--r--arch/s390/kernel/entry64.S4
-rw-r--r--arch/s390/kvm/kvm-s390.c28
-rw-r--r--arch/s390/kvm/kvm-s390.h4
5 files changed, 40 insertions, 2 deletions
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 962b92e6cf00..9a809f935580 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -71,7 +71,10 @@ struct kvm_s390_sie_block {
71 __u8 reserved08[4]; /* 0x0008 */ 71 __u8 reserved08[4]; /* 0x0008 */
72#define PROG_IN_SIE (1<<0) 72#define PROG_IN_SIE (1<<0)
73 __u32 prog0c; /* 0x000c */ 73 __u32 prog0c; /* 0x000c */
74 __u8 reserved10[24]; /* 0x0010 */ 74 __u8 reserved10[16]; /* 0x0010 */
75#define PROG_BLOCK_SIE 0x00000001
76 atomic_t prog20; /* 0x0020 */
77 __u8 reserved24[4]; /* 0x0024 */
75 __u64 cputm; /* 0x0028 */ 78 __u64 cputm; /* 0x0028 */
76 __u64 ckc; /* 0x0030 */ 79 __u64 ckc; /* 0x0030 */
77 __u64 epoch; /* 0x0038 */ 80 __u64 epoch; /* 0x0038 */
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index 6456bbe1fbb1..78db6338695d 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -163,6 +163,7 @@ int main(void)
163 DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, thread.trap_tdb)); 163 DEFINE(__THREAD_trap_tdb, offsetof(struct task_struct, thread.trap_tdb));
164 DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce)); 164 DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
165 DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c)); 165 DEFINE(__SIE_PROG0C, offsetof(struct kvm_s390_sie_block, prog0c));
166 DEFINE(__SIE_PROG20, offsetof(struct kvm_s390_sie_block, prog20));
166#endif /* CONFIG_32BIT */ 167#endif /* CONFIG_32BIT */
167 return 0; 168 return 0;
168} 169}
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index c2e81b4ea42c..c7daeefb9864 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -958,7 +958,9 @@ sie_loop:
958 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce 958 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
959sie_gmap: 959sie_gmap:
960 lg %r14,__SF_EMPTY(%r15) # get control block pointer 960 lg %r14,__SF_EMPTY(%r15) # get control block pointer
961 oi __SIE_PROG0C+3(%r14),1 # we are in SIE now 961 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
962 tm __SIE_PROG20+3(%r14),1 # last exit...
963 jnz sie_done
962 LPP __SF_EMPTY(%r15) # set guest id 964 LPP __SF_EMPTY(%r15) # set guest id
963 sie 0(%r14) 965 sie 0(%r14)
964sie_done: 966sie_done:
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index c1c7c683fa26..ef4ef21f2c73 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -454,6 +454,34 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
454 return 0; 454 return 0;
455} 455}
456 456
457void s390_vcpu_block(struct kvm_vcpu *vcpu)
458{
459 atomic_set_mask(PROG_BLOCK_SIE, &vcpu->arch.sie_block->prog20);
460}
461
462void s390_vcpu_unblock(struct kvm_vcpu *vcpu)
463{
464 atomic_clear_mask(PROG_BLOCK_SIE, &vcpu->arch.sie_block->prog20);
465}
466
467/*
468 * Kick a guest cpu out of SIE and wait until SIE is not running.
469 * If the CPU is not running (e.g. waiting as idle) the function will
470 * return immediately. */
471void exit_sie(struct kvm_vcpu *vcpu)
472{
473 atomic_set_mask(CPUSTAT_STOP_INT, &vcpu->arch.sie_block->cpuflags);
474 while (vcpu->arch.sie_block->prog0c & PROG_IN_SIE)
475 cpu_relax();
476}
477
478/* Kick a guest cpu out of SIE and prevent SIE-reentry */
479void exit_sie_sync(struct kvm_vcpu *vcpu)
480{
481 s390_vcpu_block(vcpu);
482 exit_sie(vcpu);
483}
484
457int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu) 485int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
458{ 486{
459 /* kvm common code refers to this, but never calls it */ 487 /* kvm common code refers to this, but never calls it */
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index efc14f687265..7a8abfd26a0f 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -133,6 +133,10 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu);
133/* implemented in kvm-s390.c */ 133/* implemented in kvm-s390.c */
134int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, 134int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu,
135 unsigned long addr); 135 unsigned long addr);
136void s390_vcpu_block(struct kvm_vcpu *vcpu);
137void s390_vcpu_unblock(struct kvm_vcpu *vcpu);
138void exit_sie(struct kvm_vcpu *vcpu);
139void exit_sie_sync(struct kvm_vcpu *vcpu);
136/* implemented in diag.c */ 140/* implemented in diag.c */
137int kvm_s390_handle_diag(struct kvm_vcpu *vcpu); 141int kvm_s390_handle_diag(struct kvm_vcpu *vcpu);
138 142