aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2018-04-30 11:55:24 -0400
committerChristian Borntraeger <borntraeger@de.ibm.com>2018-05-17 03:02:27 -0400
commitb9224cd7381aea7380e230d7488d8672143600e4 (patch)
tree5c5820e01df7374674e883736ef434facf04a254
parent20c922f04b17aa51a75e514eca8fcbfa337a002d (diff)
KVM: s390: introduce defines for control registers
In KVM code we use masks to test/set control registers. Let's define the ones we use in arch/s390/include/asm/ctl_reg.h and replace all occurrences in KVM code. As we will be needing the define for Clock-comparator sign control soon, let's also add it. Suggested-by: Collin L. Walling <walling@linux.ibm.com> Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Reviewed-by: Collin Walling <walling@linux.ibm.com> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> Acked-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
-rw-r--r--arch/s390/include/asm/ctl_reg.h12
-rw-r--r--arch/s390/kvm/guestdbg.c2
-rw-r--r--arch/s390/kvm/interrupt.c20
-rw-r--r--arch/s390/kvm/kvm-s390.c10
4 files changed, 30 insertions, 14 deletions
diff --git a/arch/s390/include/asm/ctl_reg.h b/arch/s390/include/asm/ctl_reg.h
index 99c93d0346f9..4600453536c2 100644
--- a/arch/s390/include/asm/ctl_reg.h
+++ b/arch/s390/include/asm/ctl_reg.h
@@ -10,8 +10,20 @@
10 10
11#include <linux/const.h> 11#include <linux/const.h>
12 12
13#define CR0_CLOCK_COMPARATOR_SIGN _BITUL(63 - 10)
14#define CR0_EMERGENCY_SIGNAL_SUBMASK _BITUL(63 - 49)
15#define CR0_EXTERNAL_CALL_SUBMASK _BITUL(63 - 50)
16#define CR0_CLOCK_COMPARATOR_SUBMASK _BITUL(63 - 52)
17#define CR0_CPU_TIMER_SUBMASK _BITUL(63 - 53)
18#define CR0_SERVICE_SIGNAL_SUBMASK _BITUL(63 - 54)
19#define CR0_UNUSED_56 _BITUL(63 - 56)
20#define CR0_INTERRUPT_KEY_SUBMASK _BITUL(63 - 57)
21#define CR0_MEASUREMENT_ALERT_SUBMASK _BITUL(63 - 58)
22
13#define CR2_GUARDED_STORAGE _BITUL(63 - 59) 23#define CR2_GUARDED_STORAGE _BITUL(63 - 59)
14 24
25#define CR14_UNUSED_32 _BITUL(63 - 32)
26#define CR14_UNUSED_33 _BITUL(63 - 33)
15#define CR14_CHANNEL_REPORT_SUBMASK _BITUL(63 - 35) 27#define CR14_CHANNEL_REPORT_SUBMASK _BITUL(63 - 35)
16#define CR14_RECOVERY_SUBMASK _BITUL(63 - 36) 28#define CR14_RECOVERY_SUBMASK _BITUL(63 - 36)
17#define CR14_DEGRADATION_SUBMASK _BITUL(63 - 37) 29#define CR14_DEGRADATION_SUBMASK _BITUL(63 - 37)
diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
index b5f3e82006d0..394a5f53805b 100644
--- a/arch/s390/kvm/guestdbg.c
+++ b/arch/s390/kvm/guestdbg.c
@@ -153,7 +153,7 @@ void kvm_s390_patch_guest_per_regs(struct kvm_vcpu *vcpu)
153 153
154 if (guestdbg_sstep_enabled(vcpu)) { 154 if (guestdbg_sstep_enabled(vcpu)) {
155 /* disable timer (clock-comparator) interrupts */ 155 /* disable timer (clock-comparator) interrupts */
156 vcpu->arch.sie_block->gcr[0] &= ~0x800ul; 156 vcpu->arch.sie_block->gcr[0] &= ~CR0_CLOCK_COMPARATOR_SUBMASK;
157 vcpu->arch.sie_block->gcr[9] |= PER_EVENT_IFETCH; 157 vcpu->arch.sie_block->gcr[9] |= PER_EVENT_IFETCH;
158 vcpu->arch.sie_block->gcr[10] = 0; 158 vcpu->arch.sie_block->gcr[10] = 0;
159 vcpu->arch.sie_block->gcr[11] = -1UL; 159 vcpu->arch.sie_block->gcr[11] = -1UL;
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 37d06e022238..daa09f89ca2d 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -159,7 +159,7 @@ static int psw_interrupts_disabled(struct kvm_vcpu *vcpu)
159static int ckc_interrupts_enabled(struct kvm_vcpu *vcpu) 159static int ckc_interrupts_enabled(struct kvm_vcpu *vcpu)
160{ 160{
161 if (psw_extint_disabled(vcpu) || 161 if (psw_extint_disabled(vcpu) ||
162 !(vcpu->arch.sie_block->gcr[0] & 0x800ul)) 162 !(vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SUBMASK))
163 return 0; 163 return 0;
164 if (guestdbg_enabled(vcpu) && guestdbg_sstep_enabled(vcpu)) 164 if (guestdbg_enabled(vcpu) && guestdbg_sstep_enabled(vcpu))
165 /* No timer interrupts when single stepping */ 165 /* No timer interrupts when single stepping */
@@ -172,7 +172,7 @@ static int ckc_irq_pending(struct kvm_vcpu *vcpu)
172 const u64 now = kvm_s390_get_tod_clock_fast(vcpu->kvm); 172 const u64 now = kvm_s390_get_tod_clock_fast(vcpu->kvm);
173 const u64 ckc = vcpu->arch.sie_block->ckc; 173 const u64 ckc = vcpu->arch.sie_block->ckc;
174 174
175 if (vcpu->arch.sie_block->gcr[0] & 0x0020000000000000ul) { 175 if (vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SIGN) {
176 if ((s64)ckc >= (s64)now) 176 if ((s64)ckc >= (s64)now)
177 return 0; 177 return 0;
178 } else if (ckc >= now) { 178 } else if (ckc >= now) {
@@ -184,7 +184,7 @@ static int ckc_irq_pending(struct kvm_vcpu *vcpu)
184static int cpu_timer_interrupts_enabled(struct kvm_vcpu *vcpu) 184static int cpu_timer_interrupts_enabled(struct kvm_vcpu *vcpu)
185{ 185{
186 return !psw_extint_disabled(vcpu) && 186 return !psw_extint_disabled(vcpu) &&
187 (vcpu->arch.sie_block->gcr[0] & 0x400ul); 187 (vcpu->arch.sie_block->gcr[0] & CR0_CPU_TIMER_SUBMASK);
188} 188}
189 189
190static int cpu_timer_irq_pending(struct kvm_vcpu *vcpu) 190static int cpu_timer_irq_pending(struct kvm_vcpu *vcpu)
@@ -285,15 +285,15 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu)
285 active_mask &= ~IRQ_PEND_IO_MASK; 285 active_mask &= ~IRQ_PEND_IO_MASK;
286 else 286 else
287 active_mask = disable_iscs(vcpu, active_mask); 287 active_mask = disable_iscs(vcpu, active_mask);
288 if (!(vcpu->arch.sie_block->gcr[0] & 0x2000ul)) 288 if (!(vcpu->arch.sie_block->gcr[0] & CR0_EXTERNAL_CALL_SUBMASK))
289 __clear_bit(IRQ_PEND_EXT_EXTERNAL, &active_mask); 289 __clear_bit(IRQ_PEND_EXT_EXTERNAL, &active_mask);
290 if (!(vcpu->arch.sie_block->gcr[0] & 0x4000ul)) 290 if (!(vcpu->arch.sie_block->gcr[0] & CR0_EMERGENCY_SIGNAL_SUBMASK))
291 __clear_bit(IRQ_PEND_EXT_EMERGENCY, &active_mask); 291 __clear_bit(IRQ_PEND_EXT_EMERGENCY, &active_mask);
292 if (!(vcpu->arch.sie_block->gcr[0] & 0x800ul)) 292 if (!(vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SUBMASK))
293 __clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &active_mask); 293 __clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &active_mask);
294 if (!(vcpu->arch.sie_block->gcr[0] & 0x400ul)) 294 if (!(vcpu->arch.sie_block->gcr[0] & CR0_CPU_TIMER_SUBMASK))
295 __clear_bit(IRQ_PEND_EXT_CPU_TIMER, &active_mask); 295 __clear_bit(IRQ_PEND_EXT_CPU_TIMER, &active_mask);
296 if (!(vcpu->arch.sie_block->gcr[0] & 0x200ul)) 296 if (!(vcpu->arch.sie_block->gcr[0] & CR0_SERVICE_SIGNAL_SUBMASK))
297 __clear_bit(IRQ_PEND_EXT_SERVICE, &active_mask); 297 __clear_bit(IRQ_PEND_EXT_SERVICE, &active_mask);
298 if (psw_mchk_disabled(vcpu)) 298 if (psw_mchk_disabled(vcpu))
299 active_mask &= ~IRQ_PEND_MCHK_MASK; 299 active_mask &= ~IRQ_PEND_MCHK_MASK;
@@ -1042,7 +1042,7 @@ int kvm_s390_vcpu_has_irq(struct kvm_vcpu *vcpu, int exclude_stop)
1042 /* external call pending and deliverable */ 1042 /* external call pending and deliverable */
1043 if (kvm_s390_ext_call_pending(vcpu) && 1043 if (kvm_s390_ext_call_pending(vcpu) &&
1044 !psw_extint_disabled(vcpu) && 1044 !psw_extint_disabled(vcpu) &&
1045 (vcpu->arch.sie_block->gcr[0] & 0x2000ul)) 1045 (vcpu->arch.sie_block->gcr[0] & CR0_EXTERNAL_CALL_SUBMASK))
1046 return 1; 1046 return 1;
1047 1047
1048 if (!exclude_stop && kvm_s390_is_stop_irq_pending(vcpu)) 1048 if (!exclude_stop && kvm_s390_is_stop_irq_pending(vcpu))
@@ -1062,7 +1062,7 @@ static u64 __calculate_sltime(struct kvm_vcpu *vcpu)
1062 u64 cputm, sltime = 0; 1062 u64 cputm, sltime = 0;
1063 1063
1064 if (ckc_interrupts_enabled(vcpu)) { 1064 if (ckc_interrupts_enabled(vcpu)) {
1065 if (vcpu->arch.sie_block->gcr[0] & 0x0020000000000000ul) { 1065 if (vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SIGN) {
1066 if ((s64)now < (s64)ckc) 1066 if ((s64)now < (s64)ckc)
1067 sltime = tod_to_ns((s64)ckc - (s64)now); 1067 sltime = tod_to_ns((s64)ckc - (s64)now);
1068 } else if (now < ckc) { 1068 } else if (now < ckc) {
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index d9799946722e..60bb3b7243d9 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -2441,8 +2441,12 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
2441 vcpu->arch.sie_block->ckc = 0UL; 2441 vcpu->arch.sie_block->ckc = 0UL;
2442 vcpu->arch.sie_block->todpr = 0; 2442 vcpu->arch.sie_block->todpr = 0;
2443 memset(vcpu->arch.sie_block->gcr, 0, 16 * sizeof(__u64)); 2443 memset(vcpu->arch.sie_block->gcr, 0, 16 * sizeof(__u64));
2444 vcpu->arch.sie_block->gcr[0] = 0xE0UL; 2444 vcpu->arch.sie_block->gcr[0] = CR0_UNUSED_56 |
2445 vcpu->arch.sie_block->gcr[14] = 0xC2000000UL; 2445 CR0_INTERRUPT_KEY_SUBMASK |
2446 CR0_MEASUREMENT_ALERT_SUBMASK;
2447 vcpu->arch.sie_block->gcr[14] = CR14_UNUSED_32 |
2448 CR14_UNUSED_33 |
2449 CR14_EXTERNAL_DAMAGE_SUBMASK;
2446 /* make sure the new fpc will be lazily loaded */ 2450 /* make sure the new fpc will be lazily loaded */
2447 save_fpu_regs(); 2451 save_fpu_regs();
2448 current->thread.fpu.fpc = 0; 2452 current->thread.fpu.fpc = 0;
@@ -3200,7 +3204,7 @@ static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu)
3200 return 0; 3204 return 0;
3201 if (kvm_s390_vcpu_has_irq(vcpu, 0)) 3205 if (kvm_s390_vcpu_has_irq(vcpu, 0))
3202 return 0; 3206 return 0;
3203 if (!(vcpu->arch.sie_block->gcr[0] & 0x200ul)) 3207 if (!(vcpu->arch.sie_block->gcr[0] & CR0_SERVICE_SIGNAL_SUBMASK))
3204 return 0; 3208 return 0;
3205 if (!vcpu->arch.gmap->pfault_enabled) 3209 if (!vcpu->arch.gmap->pfault_enabled)
3206 return 0; 3210 return 0;