From patchwork Wed Apr 20 11:57:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12820146 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07FCDC433F5 for ; Wed, 20 Apr 2022 12:05:39 +0000 (UTC) Received: from localhost ([::1]:51028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nh95V-0005HE-W1 for qemu-devel@archiver.kernel.org; Wed, 20 Apr 2022 08:05:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nh8v2-00070f-T4; Wed, 20 Apr 2022 07:54:49 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nh8v1-0003QS-8J; Wed, 20 Apr 2022 07:54:48 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23KAVB6D032641; Wed, 20 Apr 2022 11:54:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=0hGhj58FdiHDAzDtxReTNchnzT2XeL6O87NtDJso2T0=; b=oWBSbDCoQL2pB3bY/e2aq116Ypvkw2q2AjZiFk0kPnoGjYqWx1wMgBsjtjqLzwoJTw+q Zf021j3eSNEjhLBc3WifloyZW/xdG35ffc4UFYfD/t8/DXjGproIilrrBIxAlp/amTYf ShhcCJjwwF5XJSu4GMrBWJ7BKgZHNJOMv+dpKl2QozeMFGHH7sjlqb/kwhSC0NS91QoT nkNm6JCt9/DXu9/Rl1kub2bQRz+ACvfDkR1ywkTxcMP/WxP4L8fYTpPvbAn/HMItj1JW zhdZEe1UZAod3vwR62K8HIaRuIyWIGgKrjXpmrAaRyWLDgL8uEBnZ98hT6sk54XRKnY7 9A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7kb8fhu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Apr 2022 11:54:45 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 23KBYfdS031086; Wed, 20 Apr 2022 11:54:45 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 3fg7kb8fh8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Apr 2022 11:54:45 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23KBrqcX021646; Wed, 20 Apr 2022 11:54:43 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma02fra.de.ibm.com with ESMTP id 3fgu6u3ckj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Apr 2022 11:54:43 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23KBseIv43909556 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Apr 2022 11:54:40 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 08189AE058; Wed, 20 Apr 2022 11:54:40 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A2DCAE045; Wed, 20 Apr 2022 11:54:39 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com.com (unknown [9.171.58.217]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 20 Apr 2022 11:54:39 +0000 (GMT) From: Pierre Morel To: qemu-s390x@nongnu.org Subject: [PATCH v7 11/13] s390x: topology: resetting the Topology-Change-Report Date: Wed, 20 Apr 2022 13:57:43 +0200 Message-Id: <20220420115745.13696-12-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220420115745.13696-1-pmorel@linux.ibm.com> References: <20220420115745.13696-1-pmorel@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: MS7qkaV8ysg84OUQkudWj38rTDvlr4GO X-Proofpoint-GUID: eC9DW9-WkCDnx7FJsq06N3cxTKr3eo-m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-20_02,2022-04-20_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 priorityscore=1501 adultscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204200071 Received-SPF: pass client-ip=148.163.158.5; envelope-from=pmorel@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com, ehabkost@redhat.com, kvm@vger.kernel.org, david@redhat.com, eblake@redhat.com, cohuck@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org, armbru@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, philmd@redhat.com, frankja@linux.ibm.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" During a subsystem reset the Topology-Change-Report is cleared. Let's ask KVM to clear the MTCR in the case of a subsystem reset. Signed-off-by: Pierre Morel --- hw/s390x/cpu-topology.c | 6 ++++++ hw/s390x/s390-virtio-ccw.c | 1 + target/s390x/cpu-sysemu.c | 7 +++++++ target/s390x/cpu.h | 1 + target/s390x/kvm/kvm.c | 31 +++++++++++++++++++++++++++++++ target/s390x/kvm/kvm_s390x.h | 2 ++ 6 files changed, 48 insertions(+) diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c index 3ae86f80f1..a4e9840cc0 100644 --- a/hw/s390x/cpu-topology.c +++ b/hw/s390x/cpu-topology.c @@ -561,6 +561,11 @@ static void s390_node_device_realize(DeviceState *dev, Error **errp) qbus_set_hotplug_handler(bus, OBJECT(dev)); } +static void s390_topology_reset(DeviceState *dev) +{ + s390_cpu_topology_mtr_reset(); +} + static void node_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); @@ -570,6 +575,7 @@ static void node_class_init(ObjectClass *oc, void *data) set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); dc->realize = s390_node_device_realize; dc->desc = "topology node"; + dc->reset = s390_topology_reset; } static const TypeInfo node_info = { diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 1ffaddebcc..d46bff1a8a 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -121,6 +121,7 @@ static const char *const reset_dev_types[] = { "s390-flic", "diag288", TYPE_S390_PCI_HOST_BRIDGE, + TYPE_S390_TOPOLOGY_NODE, }; static void subsystem_reset(void) diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c index 948e4bd3e0..11d0d87301 100644 --- a/target/s390x/cpu-sysemu.c +++ b/target/s390x/cpu-sysemu.c @@ -306,3 +306,10 @@ 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_mtr_reset(void) +{ + if (kvm_enabled()) { + kvm_s390_cpu_topology_reset(); + } +} diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index a617c943ff..61a71a7807 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -825,6 +825,7 @@ void s390_enable_css_support(S390CPU *cpu); void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg); int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id, int vq, bool assign); +void s390_cpu_topology_mtr_reset(void); #ifndef CONFIG_USER_ONLY unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu); #else diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index e3792e52c2..f3924633c6 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -2585,3 +2585,34 @@ bool kvm_arch_cpu_check_are_resettable(void) { return true; } + +static void kvm_s390_set_mtr(uint64_t attr) +{ + struct kvm_device_attr attribute = { + .group = KVM_S390_VM_CPU_TOPOLOGY, + .attr = attr, + }; + + int ret = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attribute); + + if (ret) { + error_report("Failed to set cpu topology attribute %lu: %s", + attr, strerror(-ret)); + } +} + +static void kvm_s390_reset_mtr(void) +{ + uint64_t attr = KVM_S390_VM_CPU_TOPO_MTR_CLEAR; + + if (kvm_vm_check_attr(kvm_state, KVM_S390_VM_CPU_TOPOLOGY, attr)) { + kvm_s390_set_mtr(attr); + } +} + +void kvm_s390_cpu_topology_reset(void) +{ + if (s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) { + kvm_s390_reset_mtr(); + } +} diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h index 05a5e1e6f4..d717c05827 100644 --- a/target/s390x/kvm/kvm_s390x.h +++ b/target/s390x/kvm/kvm_s390x.h @@ -46,4 +46,6 @@ 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); +void kvm_s390_cpu_topology_reset(void); + #endif /* KVM_S390X_H */