Skip to content

Commit

Permalink
s390x/cpu topology: resetting the Topology-Change-Report
Browse files Browse the repository at this point in the history
During a subsystem reset the Topology-Change-Report is cleared
by the machine.
Let's ask KVM to clear the Modified Topology Change Report (MTCR)
bit of the SCA in the case of a subsystem reset.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Co-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Message-ID: <20231016183925.2384704-7-nsg@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
  • Loading branch information
Pierre Morel authored and huth committed Oct 18, 2023
1 parent 71e3e48 commit 7358aeb
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hw/s390x/cpu-topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ static void s390_topology_init(MachineState *ms)
smp->books * smp->drawers);
}

/**
* s390_topology_reset:
*
* Generic reset for CPU topology, calls s390_topology_reset()
* to reset the kernel Modified Topology Change Record.
*/
void s390_topology_reset(void)
{
s390_cpu_topology_set_changed(false);
}

/**
* s390_topology_cpu_default:
* @cpu: pointer to a S390CPU
Expand Down
3 changes: 3 additions & 0 deletions hw/s390x/s390-virtio-ccw.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ static void subsystem_reset(void)
device_cold_reset(dev);
}
}
if (s390_has_topology()) {
s390_topology_reset();
}
}

static int virtio_ccw_hcall_notify(const uint64_t *args)
Expand Down
1 change: 1 addition & 0 deletions include/hw/s390x/cpu-topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static inline void s390_topology_setup_cpu(MachineState *ms,
#endif

extern S390Topology s390_topology;
void s390_topology_reset(void);

static inline int s390_std_socket(int n, CpuTopology *smp)
{
Expand Down
13 changes: 13 additions & 0 deletions target/s390x/cpu-sysemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,16 @@ void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg)
kvm_s390_set_diag318(cs, arg.host_ulong);
}
}

void s390_cpu_topology_set_changed(bool changed)
{
int ret;

if (kvm_enabled()) {
ret = kvm_s390_topology_set_mtcr(changed);
if (ret) {
error_report("Failed to set Modified Topology Change Report: %s",
strerror(-ret));
}
}
}
1 change: 1 addition & 0 deletions target/s390x/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ typedef struct SysIBCPUListEntry {
QEMU_BUILD_BUG_ON(sizeof(SysIBCPUListEntry) != 16);

void insert_stsi_15_1_x(S390CPU *cpu, int sel2, uint64_t addr, uint8_t ar, uintptr_t ra);
void s390_cpu_topology_set_changed(bool changed);

/* MMU defines */
#define ASCE_ORIGIN (~0xfffULL) /* segment table origin */
Expand Down
17 changes: 17 additions & 0 deletions target/s390x/kvm/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,23 @@ int kvm_s390_get_zpci_op(void)
return cap_zpci_op;
}

int kvm_s390_topology_set_mtcr(uint64_t attr)
{
struct kvm_device_attr attribute = {
.group = KVM_S390_VM_CPU_TOPOLOGY,
.attr = attr,
};

if (!s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) {
return 0;
}
if (!kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, attr)) {
return -ENOTSUP;
}

return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attribute);
}

void kvm_arch_accel_class_init(ObjectClass *oc)
{
}
1 change: 1 addition & 0 deletions target/s390x/kvm/kvm_s390x.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ void kvm_s390_crypto_reset(void);
void kvm_s390_restart_interrupt(S390CPU *cpu);
void kvm_s390_stop_interrupt(S390CPU *cpu);
void kvm_s390_set_diag318(CPUState *cs, uint64_t diag318_info);
int kvm_s390_topology_set_mtcr(uint64_t attr);

#endif /* KVM_S390X_H */

0 comments on commit 7358aeb

Please sign in to comment.