Skip to content

Commit 0d0a193

Browse files
committed
Merge tag 'kvm-s390-next-5.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
KVM: s390: Fix and feature for 5.15 - enable interpretion of specification exceptions - fix a vcpu_idx vs vcpu_id mixup
2 parents a40b2fd + a3e03bc commit 0d0a193

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

arch/s390/include/asm/kvm_host.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ struct kvm_s390_sie_block {
244244
__u8 fpf; /* 0x0060 */
245245
#define ECB_GS 0x40
246246
#define ECB_TE 0x10
247+
#define ECB_SPECI 0x08
247248
#define ECB_SRSI 0x04
248249
#define ECB_HOSTPROTINT 0x02
249250
__u8 ecb; /* 0x0061 */
@@ -957,6 +958,7 @@ struct kvm_arch{
957958
atomic64_t cmma_dirty_pages;
958959
/* subset of available cpu features enabled by user space */
959960
DECLARE_BITMAP(cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
961+
/* indexed by vcpu_idx */
960962
DECLARE_BITMAP(idle_mask, KVM_MAX_VCPUS);
961963
struct kvm_s390_gisa_interrupt gisa_int;
962964
struct kvm_s390_pv pv;

arch/s390/kvm/interrupt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,13 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu)
419419
static void __set_cpu_idle(struct kvm_vcpu *vcpu)
420420
{
421421
kvm_s390_set_cpuflags(vcpu, CPUSTAT_WAIT);
422-
set_bit(vcpu->vcpu_id, vcpu->kvm->arch.idle_mask);
422+
set_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask);
423423
}
424424

425425
static void __unset_cpu_idle(struct kvm_vcpu *vcpu)
426426
{
427427
kvm_s390_clear_cpuflags(vcpu, CPUSTAT_WAIT);
428-
clear_bit(vcpu->vcpu_id, vcpu->kvm->arch.idle_mask);
428+
clear_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask);
429429
}
430430

431431
static void __reset_intercept_indicators(struct kvm_vcpu *vcpu)
@@ -3050,18 +3050,18 @@ int kvm_s390_get_irq_state(struct kvm_vcpu *vcpu, __u8 __user *buf, int len)
30503050

30513051
static void __airqs_kick_single_vcpu(struct kvm *kvm, u8 deliverable_mask)
30523052
{
3053-
int vcpu_id, online_vcpus = atomic_read(&kvm->online_vcpus);
3053+
int vcpu_idx, online_vcpus = atomic_read(&kvm->online_vcpus);
30543054
struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int;
30553055
struct kvm_vcpu *vcpu;
30563056

3057-
for_each_set_bit(vcpu_id, kvm->arch.idle_mask, online_vcpus) {
3058-
vcpu = kvm_get_vcpu(kvm, vcpu_id);
3057+
for_each_set_bit(vcpu_idx, kvm->arch.idle_mask, online_vcpus) {
3058+
vcpu = kvm_get_vcpu(kvm, vcpu_idx);
30593059
if (psw_ioint_disabled(vcpu))
30603060
continue;
30613061
deliverable_mask &= (u8)(vcpu->arch.sie_block->gcr[6] >> 24);
30623062
if (deliverable_mask) {
30633063
/* lately kicked but not yet running */
3064-
if (test_and_set_bit(vcpu_id, gi->kicked_mask))
3064+
if (test_and_set_bit(vcpu_idx, gi->kicked_mask))
30653065
return;
30663066
kvm_s390_vcpu_wakeup(vcpu);
30673067
return;

arch/s390/kvm/kvm-s390.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3196,6 +3196,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
31963196
vcpu->arch.sie_block->ecb |= ECB_SRSI;
31973197
if (test_kvm_facility(vcpu->kvm, 73))
31983198
vcpu->arch.sie_block->ecb |= ECB_TE;
3199+
if (!kvm_is_ucontrol(vcpu->kvm))
3200+
vcpu->arch.sie_block->ecb |= ECB_SPECI;
31993201

32003202
if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
32013203
vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
@@ -4040,7 +4042,7 @@ static int vcpu_pre_run(struct kvm_vcpu *vcpu)
40404042
kvm_s390_patch_guest_per_regs(vcpu);
40414043
}
40424044

4043-
clear_bit(vcpu->vcpu_id, vcpu->kvm->arch.gisa_int.kicked_mask);
4045+
clear_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.gisa_int.kicked_mask);
40444046

40454047
vcpu->arch.sie_block->icptcode = 0;
40464048
cpuflags = atomic_read(&vcpu->arch.sie_block->cpuflags);

arch/s390/kvm/kvm-s390.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static inline int is_vcpu_stopped(struct kvm_vcpu *vcpu)
7979

8080
static inline int is_vcpu_idle(struct kvm_vcpu *vcpu)
8181
{
82-
return test_bit(vcpu->vcpu_id, vcpu->kvm->arch.idle_mask);
82+
return test_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask);
8383
}
8484

8585
static inline int kvm_is_ucontrol(struct kvm *kvm)

arch/s390/kvm/vsie.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
510510
prefix_unmapped(vsie_page);
511511
scb_s->ecb |= ECB_TE;
512512
}
513+
/* specification exception interpretation */
514+
scb_s->ecb |= scb_o->ecb & ECB_SPECI;
513515
/* branch prediction */
514516
if (test_kvm_facility(vcpu->kvm, 82))
515517
scb_s->fpf |= scb_o->fpf & FPF_BPBC;

0 commit comments

Comments
 (0)