• R/O
  • HTTP
  • SSH
  • HTTPS

qemu: Commit


Commit MetaInfo

Revisione2c6cd567422bfa563be026b9741a1854aecdc06 (tree)
Time2020-11-19 00:57:48
AuthorCollin Walling <walling@linu...>
CommiterCornelia Huck

Log Message

s390/kvm: fix diag318 propagation and reset functionality

The Control Program Name Code (CPNC) portion of the diag318
info must be set within the SIE block of each VCPU in the
configuration. The handler will iterate through each VCPU
and dirty the diag318_info reg to be synced with KVM on a
subsequent sync_regs call.

Additionally, the diag318 info resets must be handled via
userspace. As such, QEMU will reset this value for each
VCPU during a modified clear, load normal, and load clear
reset event.

Fixes: fabdada9357b ("s390: guest support for diagnose 0x318")
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <20201113221022.257054-1-walling@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Janosch Frank <frankja@de.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>

Change Summary

Incremental Difference

--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -486,6 +486,10 @@ static void s390_machine_reset(MachineState *machine)
486486 default:
487487 g_assert_not_reached();
488488 }
489+
490+ CPU_FOREACH(t) {
491+ run_on_cpu(t, s390_do_cpu_set_diag318, RUN_ON_CPU_HOST_ULONG(0));
492+ }
489493 s390_ipl_clear_reset_request();
490494 }
491495
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -447,6 +447,13 @@ void s390_enable_css_support(S390CPU *cpu)
447447 kvm_s390_enable_css_support(cpu);
448448 }
449449 }
450+
451+void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg)
452+{
453+ if (kvm_enabled()) {
454+ kvm_s390_set_diag318(cs, arg.host_ulong);
455+ }
456+}
450457 #endif
451458
452459 static gchar *s390_gdb_arch_name(CPUState *cs)
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -769,6 +769,7 @@ int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit);
769769 void s390_set_max_pagesize(uint64_t pagesize, Error **errp);
770770 void s390_cmma_reset(void);
771771 void s390_enable_css_support(S390CPU *cpu);
772+void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg);
772773 int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id,
773774 int vq, bool assign);
774775 #ifndef CONFIG_USER_ONLY
--- a/target/s390x/kvm-stub.c
+++ b/target/s390x/kvm-stub.c
@@ -120,3 +120,7 @@ void kvm_s390_stop_interrupt(S390CPU *cpu)
120120 void kvm_s390_restart_interrupt(S390CPU *cpu)
121121 {
122122 }
123+
124+void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info)
125+{
126+}
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -1611,10 +1611,23 @@ static int handle_sw_breakpoint(S390CPU *cpu, struct kvm_run *run)
16111611 return -ENOENT;
16121612 }
16131613
1614+void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info)
1615+{
1616+ CPUS390XState *env = &S390_CPU(cs)->env;
1617+
1618+ /* Feat bit is set only if KVM supports sync for diag318 */
1619+ if (s390_has_feat(S390_FEAT_DIAG_318)) {
1620+ env->diag318_info = diag318_info;
1621+ cs->kvm_run->s.regs.diag318 = diag318_info;
1622+ cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_DIAG318;
1623+ }
1624+}
1625+
16141626 static void handle_diag_318(S390CPU *cpu, struct kvm_run *run)
16151627 {
16161628 uint64_t reg = (run->s390_sieic.ipa & 0x00f0) >> 4;
16171629 uint64_t diag318_info = run->s.regs.gprs[reg];
1630+ CPUState *t;
16181631
16191632 /*
16201633 * DIAG 318 can only be enabled with KVM support. As such, let's
@@ -1622,13 +1635,12 @@ static void handle_diag_318(S390CPU *cpu, struct kvm_run *run)
16221635 */
16231636 if (!s390_has_feat(S390_FEAT_DIAG_318)) {
16241637 kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION);
1638+ return;
16251639 }
16261640
1627- cpu->env.diag318_info = diag318_info;
1628-
1629- if (can_sync_regs(CPU(cpu), KVM_SYNC_DIAG318)) {
1630- run->s.regs.diag318 = diag318_info;
1631- run->kvm_dirty_regs |= KVM_SYNC_DIAG318;
1641+ CPU_FOREACH(t) {
1642+ run_on_cpu(t, s390_do_cpu_set_diag318,
1643+ RUN_ON_CPU_HOST_ULONG(diag318_info));
16321644 }
16331645 }
16341646
--- a/target/s390x/kvm_s390x.h
+++ b/target/s390x/kvm_s390x.h
@@ -45,5 +45,6 @@ void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp);
4545 void kvm_s390_crypto_reset(void);
4646 void kvm_s390_restart_interrupt(S390CPU *cpu);
4747 void kvm_s390_stop_interrupt(S390CPU *cpu);
48+void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info);
4849
4950 #endif /* KVM_S390X_H */
Show on old repository browser