Skip to content

Commit fe289eb

Browse files
committed
Merge tag 'kvm-s390-next-5.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
KVM: s390: small fixes and enhancements - selftest improvements - yield improvements - cleanups
2 parents 7ee30bc + c7b7de6 commit fe289eb

File tree

5 files changed

+38
-24
lines changed

5 files changed

+38
-24
lines changed

arch/s390/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ struct kvm_vcpu_stat {
392392
u64 diagnose_10;
393393
u64 diagnose_44;
394394
u64 diagnose_9c;
395+
u64 diagnose_9c_ignored;
395396
u64 diagnose_258;
396397
u64 diagnose_308;
397398
u64 diagnose_500;

arch/s390/kvm/diag.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,28 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu)
158158

159159
tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4];
160160
vcpu->stat.diagnose_9c++;
161-
VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d", tid);
162161

162+
/* yield to self */
163163
if (tid == vcpu->vcpu_id)
164-
return 0;
164+
goto no_yield;
165165

166+
/* yield to invalid */
166167
tcpu = kvm_get_vcpu_by_id(vcpu->kvm, tid);
167-
if (tcpu)
168-
kvm_vcpu_yield_to(tcpu);
168+
if (!tcpu)
169+
goto no_yield;
170+
171+
/* target already running */
172+
if (READ_ONCE(tcpu->cpu) >= 0)
173+
goto no_yield;
174+
175+
if (kvm_vcpu_yield_to(tcpu) <= 0)
176+
goto no_yield;
177+
178+
VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: done", tid);
179+
return 0;
180+
no_yield:
181+
VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: ignored", tid);
182+
vcpu->stat.diagnose_9c_ignored++;
169183
return 0;
170184
}
171185

arch/s390/kvm/interrupt.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,8 +1477,7 @@ static int __inject_sigp_stop(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
14771477
return 0;
14781478
}
14791479

1480-
static int __inject_sigp_restart(struct kvm_vcpu *vcpu,
1481-
struct kvm_s390_irq *irq)
1480+
static int __inject_sigp_restart(struct kvm_vcpu *vcpu)
14821481
{
14831482
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
14841483

@@ -2007,7 +2006,7 @@ static int do_inject_vcpu(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
20072006
rc = __inject_sigp_stop(vcpu, irq);
20082007
break;
20092008
case KVM_S390_RESTART:
2010-
rc = __inject_sigp_restart(vcpu, irq);
2009+
rc = __inject_sigp_restart(vcpu);
20112010
break;
20122011
case KVM_S390_INT_CLOCK_COMP:
20132012
rc = __inject_ckc(vcpu);

arch/s390/kvm/kvm-s390.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
155155
{ "instruction_diag_10", VCPU_STAT(diagnose_10) },
156156
{ "instruction_diag_44", VCPU_STAT(diagnose_44) },
157157
{ "instruction_diag_9c", VCPU_STAT(diagnose_9c) },
158+
{ "diag_9c_ignored", VCPU_STAT(diagnose_9c_ignored) },
158159
{ "instruction_diag_258", VCPU_STAT(diagnose_258) },
159160
{ "instruction_diag_308", VCPU_STAT(diagnose_308) },
160161
{ "instruction_diag_500", VCPU_STAT(diagnose_500) },
@@ -453,36 +454,32 @@ static void kvm_s390_cpu_feat_init(void)
453454

454455
int kvm_arch_init(void *opaque)
455456
{
456-
int rc;
457+
int rc = -ENOMEM;
457458

458459
kvm_s390_dbf = debug_register("kvm-trace", 32, 1, 7 * sizeof(long));
459460
if (!kvm_s390_dbf)
460461
return -ENOMEM;
461462

462-
if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view)) {
463-
rc = -ENOMEM;
464-
goto out_debug_unreg;
465-
}
463+
if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view))
464+
goto out;
466465

467466
kvm_s390_cpu_feat_init();
468467

469468
/* Register floating interrupt controller interface. */
470469
rc = kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC);
471470
if (rc) {
472471
pr_err("A FLIC registration call failed with rc=%d\n", rc);
473-
goto out_debug_unreg;
472+
goto out;
474473
}
475474

476475
rc = kvm_s390_gib_init(GAL_ISC);
477476
if (rc)
478-
goto out_gib_destroy;
477+
goto out;
479478

480479
return 0;
481480

482-
out_gib_destroy:
483-
kvm_s390_gib_destroy();
484-
out_debug_unreg:
485-
debug_unregister(kvm_s390_dbf);
481+
out:
482+
kvm_arch_exit();
486483
return rc;
487484
}
488485

tools/testing/selftests/kvm/s390x/sync_regs_test.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525

2626
static void guest_code(void)
2727
{
28-
register u64 stage asm("11") = 0;
29-
30-
for (;;) {
31-
GUEST_SYNC(0);
32-
asm volatile ("ahi %0,1" : : "r"(stage));
33-
}
28+
/*
29+
* We embed diag 501 here instead of doing a ucall to avoid that
30+
* the compiler has messed with r11 at the time of the ucall.
31+
*/
32+
asm volatile (
33+
"0: diag 0,0,0x501\n"
34+
" ahi 11,1\n"
35+
" j 0b\n"
36+
);
3437
}
3538

3639
#define REG_COMPARE(reg) \

0 commit comments

Comments
 (0)