From nobody Sun May 5 15:42:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511181545256682.1052159920388; Mon, 20 Nov 2017 04:39:05 -0800 (PST) Received: from localhost ([::1]:56851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGlLp-0003oW-I4 for importer@patchew.org; Mon, 20 Nov 2017 07:39:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGlIe-0001bJ-Sq for qemu-devel@nongnu.org; Mon, 20 Nov 2017 07:35:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGlIb-0000WW-Ph for qemu-devel@nongnu.org; Mon, 20 Nov 2017 07:35:44 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGlIb-0000WG-H6 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 07:35:41 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAKCT0NW043311 for ; Mon, 20 Nov 2017 07:35:33 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ebv141wcx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 20 Nov 2017 07:35:33 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Nov 2017 12:35:31 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Nov 2017 12:35:27 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAKCZRHH40960004; Mon, 20 Nov 2017 12:35:27 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89F1842047; Mon, 20 Nov 2017 12:30:13 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 783FA42042; Mon, 20 Nov 2017 12:30:13 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 20 Nov 2017 12:30:13 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 95CDB20F648; Mon, 20 Nov 2017 13:35:26 +0100 (CET) From: Christian Borntraeger To: Cornelia Huck Date: Mon, 20 Nov 2017 13:35:24 +0100 X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171120123525.147663-1-borntraeger@de.ibm.com> References: <20171120123525.147663-1-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17112012-0012-0000-0000-0000058F702A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17112012-0013-0000-0000-0000190A3BE5 Message-Id: <20171120123525.147663-2-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-20_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711200170 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 1/2] s390x/migration: use zero flag parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Graf , Thomas Huth , Halil Pasic , qemu-devel , Christian Borntraeger , qemu-s390x , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" valgrind pointed out that we call KVM_S390_GET_IRQ_STATE with an undefined value for flags. Right now this is unused, but we better play safe. Signed-off-by: Christian Borntraeger Reviewed-by: Thomas Huth --- target/s390x/kvm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 343fcec..b0439a1 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2069,7 +2069,10 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu= _state) =20 void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu) { - struct kvm_s390_irq_state irq_state; + struct kvm_s390_irq_state irq_state =3D { + .buf =3D (uint64_t) cpu->irqstate, + .len =3D VCPU_IRQ_BUF_SIZE, + }; CPUState *cs =3D CPU(cpu); int32_t bytes; =20 @@ -2077,9 +2080,6 @@ void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu) return; } =20 - irq_state.buf =3D (uint64_t) cpu->irqstate; - irq_state.len =3D VCPU_IRQ_BUF_SIZE; - bytes =3D kvm_vcpu_ioctl(cs, KVM_S390_GET_IRQ_STATE, &irq_state); if (bytes < 0) { cpu->irqstate_saved_size =3D 0; --=20 2.9.4 From nobody Sun May 5 15:42:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511181482121969.0475483143998; Mon, 20 Nov 2017 04:38:02 -0800 (PST) Received: from localhost ([::1]:56847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGlKh-00034r-B5 for importer@patchew.org; Mon, 20 Nov 2017 07:37:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGlIe-0001b7-2O for qemu-devel@nongnu.org; Mon, 20 Nov 2017 07:35:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGlIY-0000V4-27 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 07:35:44 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52326 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGlIX-0000Uq-T9 for qemu-devel@nongnu.org; Mon, 20 Nov 2017 07:35:37 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAKCT04m027530 for ; Mon, 20 Nov 2017 07:35:33 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ebuyquarm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 20 Nov 2017 07:35:32 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Nov 2017 12:35:31 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Nov 2017 12:35:27 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAKCZRwS41680914; Mon, 20 Nov 2017 12:35:27 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FA67AE057; Mon, 20 Nov 2017 12:28:45 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46BA8AE051; Mon, 20 Nov 2017 12:28:45 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 20 Nov 2017 12:28:45 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id D2E6620F647; Mon, 20 Nov 2017 13:35:26 +0100 (CET) From: Christian Borntraeger To: Cornelia Huck Date: Mon, 20 Nov 2017 13:35:25 +0100 X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171120123525.147663-1-borntraeger@de.ibm.com> References: <20171120123525.147663-1-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17112012-0040-0000-0000-000004106FC7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17112012-0041-0000-0000-000020B334A8 Message-Id: <20171120123525.147663-3-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-20_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711200170 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 2/2] s390x/kvm: use valgrind annotations for kvm device attributes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Graf , Thomas Huth , Halil Pasic , qemu-devel , Christian Borntraeger , qemu-s390x , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" the KVM_GET/SET_DEVICE_ATTR calls have non-self-describing side effects. Use valgrind annotations to properly mark all storage changes instead of using memset or designated initializers. Signed-off-by: Christian Borntraeger --- hw/s390x/s390-skeys-kvm.c | 12 ++++++++++- hw/s390x/s390-stattrib-kvm.c | 7 ++++++ target/s390x/kvm.c | 51 ++++++++++++++++++++++++++++++++++++++++= ---- 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/hw/s390x/s390-skeys-kvm.c b/hw/s390x/s390-skeys-kvm.c index dc54ed8..0986795 100644 --- a/hw/s390x/s390-skeys-kvm.c +++ b/hw/s390x/s390-skeys-kvm.c @@ -13,6 +13,9 @@ #include "hw/s390x/storage-keys.h" #include "sysemu/kvm.h" #include "qemu/error-report.h" +#ifdef CONFIG_VALGRIND_H +#include +#endif =20 static int kvm_s390_skeys_enabled(S390SKeysState *ss) { @@ -35,8 +38,15 @@ static int kvm_s390_skeys_get(S390SKeysState *ss, uint64= _t start_gfn, .count =3D count, .skeydata_addr =3D (__u64)keys }; + int ret; =20 - return kvm_vm_ioctl(kvm_state, KVM_S390_GET_SKEYS, &args); + ret =3D kvm_vm_ioctl(kvm_state, KVM_S390_GET_SKEYS, &args); + if (!ret) { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(keys, count); +#endif + } + return ret; } =20 static int kvm_s390_skeys_set(S390SKeysState *ss, uint64_t start_gfn, diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c index 41770a7..eb2b220 100644 --- a/hw/s390x/s390-stattrib-kvm.c +++ b/hw/s390x/s390-stattrib-kvm.c @@ -18,6 +18,9 @@ #include "exec/ram_addr.h" #include "cpu.h" #include "kvm_s390x.h" +#ifdef CONFIG_VALGRIND_H +#include +#endif =20 Object *kvm_s390_stattrib_create(void) { @@ -54,6 +57,10 @@ static int kvm_s390_stattrib_read_helper(S390StAttribSta= te *sa, if (r < 0) { error_report("KVM_S390_GET_CMMA_BITS failed: %s", strerror(-r)); return r; + } else { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(values, clog.count); +#endif } =20 *start_gfn =3D clog.start_gfn; diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index b0439a1..d3f3ddb 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -50,6 +50,9 @@ #include "exec/memattrs.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/s390-virtio-hcall.h" +#ifdef CONFIG_VALGRIND_H +#include +#endif =20 #ifndef DEBUG_KVM #define DEBUG_KVM 0 @@ -176,8 +179,13 @@ int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_= t *hw_limit) rc =3D kvm_s390_query_mem_limit(hw_limit); if (rc) { return rc; - } else if (*hw_limit < new_limit) { - return -E2BIG; + } else { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(hw_limit, sizeof(*hw_limit)); +#endif + if (*hw_limit < new_limit) { + return -E2BIG; + } } =20 return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); @@ -312,6 +320,10 @@ static int compat_disable_facilities(KVMState *s, __u6= 4 fac_mask[], int len) if (rc) { error_report("KVM_GET_DEVICE_ATTR failed with rc %d", rc); return rc; + } else { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(&mach_attrs, sizeof(mach_attrs)); +#endif } =20 cpu_attrs.cpuid =3D mach_attrs.cpuid | 0xff00000000000000UL; @@ -704,11 +716,21 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *t= od_low) r =3D kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); if (r) { return r; + } else { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(tod_low, sizeof(tod_low)); +#endif } =20 attr.attr =3D KVM_S390_VM_TOD_HIGH; attr.addr =3D (uint64_t)tod_high; - return kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); + r =3D kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); + if (!r) { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(tod_high, sizeof(tod_high)); +#endif + } + return r; } =20 int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_low) @@ -722,6 +744,11 @@ int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t= *tod_low) }; =20 r =3D kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); + if (!r) { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(>od, sizeof(gtod)); +#endif + } *tod_high =3D gtod.epoch_idx; *tod_low =3D gtod.tod; =20 @@ -2085,6 +2112,10 @@ void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu) cpu->irqstate_saved_size =3D 0; error_report("Migration of interrupt state failed"); return; + } else { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(cpu->irqstate, bytes); +#endif } =20 cpu->irqstate_saved_size =3D bytes; @@ -2170,6 +2201,10 @@ static int query_cpu_subfunc(S390FeatBitmap features) rc =3D kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); if (rc) { return rc; + } else { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(&prop, sizeof(prop)); +#endif } =20 /* @@ -2280,6 +2315,10 @@ static int query_cpu_feat(S390FeatBitmap features) rc =3D kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); if (rc) { return rc; + } else { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(&prop, sizeof(prop)); +#endif } =20 for (i =3D 0; i < ARRAY_SIZE(kvm_to_feat); i++) { @@ -2328,7 +2367,7 @@ bool kvm_s390_cpu_models_supported(void) =20 void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp) { - struct kvm_s390_vm_cpu_machine prop =3D {}; + struct kvm_s390_vm_cpu_machine prop; struct kvm_device_attr attr =3D { .group =3D KVM_S390_VM_CPU_MODEL, .attr =3D KVM_S390_VM_CPU_MACHINE, @@ -2349,6 +2388,10 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model= , Error **errp) if (rc) { error_setg(errp, "KVM: Error querying host CPU model: %d", rc); return; + } else { +#ifdef CONFIG_VALGRIND_H + VALGRIND_MAKE_MEM_DEFINED(&prop, sizeof(prop)); +#endif } =20 cpu_type =3D cpuid_type(prop.cpuid); --=20 2.9.4