Commit fe289ebb authored by Paolo Bonzini's avatar Paolo Bonzini

Merge tag 'kvm-s390-next-5.5-1' of...

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
parents 7ee30bc1 c7b7de63
...@@ -392,6 +392,7 @@ struct kvm_vcpu_stat { ...@@ -392,6 +392,7 @@ struct kvm_vcpu_stat {
u64 diagnose_10; u64 diagnose_10;
u64 diagnose_44; u64 diagnose_44;
u64 diagnose_9c; u64 diagnose_9c;
u64 diagnose_9c_ignored;
u64 diagnose_258; u64 diagnose_258;
u64 diagnose_308; u64 diagnose_308;
u64 diagnose_500; u64 diagnose_500;
......
...@@ -158,14 +158,28 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu) ...@@ -158,14 +158,28 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu)
tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4]; tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4];
vcpu->stat.diagnose_9c++; vcpu->stat.diagnose_9c++;
VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d", tid);
/* yield to self */
if (tid == vcpu->vcpu_id) if (tid == vcpu->vcpu_id)
return 0; goto no_yield;
/* yield to invalid */
tcpu = kvm_get_vcpu_by_id(vcpu->kvm, tid); tcpu = kvm_get_vcpu_by_id(vcpu->kvm, tid);
if (tcpu) if (!tcpu)
kvm_vcpu_yield_to(tcpu); goto no_yield;
/* target already running */
if (READ_ONCE(tcpu->cpu) >= 0)
goto no_yield;
if (kvm_vcpu_yield_to(tcpu) <= 0)
goto no_yield;
VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: done", tid);
return 0;
no_yield:
VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: ignored", tid);
vcpu->stat.diagnose_9c_ignored++;
return 0; return 0;
} }
......
...@@ -1477,8 +1477,7 @@ static int __inject_sigp_stop(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq) ...@@ -1477,8 +1477,7 @@ static int __inject_sigp_stop(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
return 0; return 0;
} }
static int __inject_sigp_restart(struct kvm_vcpu *vcpu, static int __inject_sigp_restart(struct kvm_vcpu *vcpu)
struct kvm_s390_irq *irq)
{ {
struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
...@@ -2007,7 +2006,7 @@ static int do_inject_vcpu(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq) ...@@ -2007,7 +2006,7 @@ static int do_inject_vcpu(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
rc = __inject_sigp_stop(vcpu, irq); rc = __inject_sigp_stop(vcpu, irq);
break; break;
case KVM_S390_RESTART: case KVM_S390_RESTART:
rc = __inject_sigp_restart(vcpu, irq); rc = __inject_sigp_restart(vcpu);
break; break;
case KVM_S390_INT_CLOCK_COMP: case KVM_S390_INT_CLOCK_COMP:
rc = __inject_ckc(vcpu); rc = __inject_ckc(vcpu);
......
...@@ -155,6 +155,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { ...@@ -155,6 +155,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
{ "instruction_diag_10", VCPU_STAT(diagnose_10) }, { "instruction_diag_10", VCPU_STAT(diagnose_10) },
{ "instruction_diag_44", VCPU_STAT(diagnose_44) }, { "instruction_diag_44", VCPU_STAT(diagnose_44) },
{ "instruction_diag_9c", VCPU_STAT(diagnose_9c) }, { "instruction_diag_9c", VCPU_STAT(diagnose_9c) },
{ "diag_9c_ignored", VCPU_STAT(diagnose_9c_ignored) },
{ "instruction_diag_258", VCPU_STAT(diagnose_258) }, { "instruction_diag_258", VCPU_STAT(diagnose_258) },
{ "instruction_diag_308", VCPU_STAT(diagnose_308) }, { "instruction_diag_308", VCPU_STAT(diagnose_308) },
{ "instruction_diag_500", VCPU_STAT(diagnose_500) }, { "instruction_diag_500", VCPU_STAT(diagnose_500) },
...@@ -453,16 +454,14 @@ static void kvm_s390_cpu_feat_init(void) ...@@ -453,16 +454,14 @@ static void kvm_s390_cpu_feat_init(void)
int kvm_arch_init(void *opaque) int kvm_arch_init(void *opaque)
{ {
int rc; int rc = -ENOMEM;
kvm_s390_dbf = debug_register("kvm-trace", 32, 1, 7 * sizeof(long)); kvm_s390_dbf = debug_register("kvm-trace", 32, 1, 7 * sizeof(long));
if (!kvm_s390_dbf) if (!kvm_s390_dbf)
return -ENOMEM; return -ENOMEM;
if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view)) { if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view))
rc = -ENOMEM; goto out;
goto out_debug_unreg;
}
kvm_s390_cpu_feat_init(); kvm_s390_cpu_feat_init();
...@@ -470,19 +469,17 @@ int kvm_arch_init(void *opaque) ...@@ -470,19 +469,17 @@ int kvm_arch_init(void *opaque)
rc = kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC); rc = kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC);
if (rc) { if (rc) {
pr_err("A FLIC registration call failed with rc=%d\n", rc); pr_err("A FLIC registration call failed with rc=%d\n", rc);
goto out_debug_unreg; goto out;
} }
rc = kvm_s390_gib_init(GAL_ISC); rc = kvm_s390_gib_init(GAL_ISC);
if (rc) if (rc)
goto out_gib_destroy; goto out;
return 0; return 0;
out_gib_destroy: out:
kvm_s390_gib_destroy(); kvm_arch_exit();
out_debug_unreg:
debug_unregister(kvm_s390_dbf);
return rc; return rc;
} }
......
...@@ -25,12 +25,15 @@ ...@@ -25,12 +25,15 @@
static void guest_code(void) static void guest_code(void)
{ {
register u64 stage asm("11") = 0; /*
* We embed diag 501 here instead of doing a ucall to avoid that
for (;;) { * the compiler has messed with r11 at the time of the ucall.
GUEST_SYNC(0); */
asm volatile ("ahi %0,1" : : "r"(stage)); asm volatile (
} "0: diag 0,0,0x501\n"
" ahi 11,1\n"
" j 0b\n"
);
} }
#define REG_COMPARE(reg) \ #define REG_COMPARE(reg) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment