From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675063; cv=none; d=zohomail.com; s=zohoarc; b=RFQQ499j0XgAxWN4rdVAYs3I6Ic+LjqYQFB1w23N+WUzo51gotHoL/MNvEpFjlE0BzOMvmulhAt7P+JxXc1zkf9+Cd0iZ3Uk/vu+Iy9FFI9qXZD0SjDTqamMUjkfrpS477vpvDdz3IwZD5Y94I9xwshf/q19+jVNRIzC2lMxK8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675063; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Whl14FdWI0R6prvjrfI/55CDXqG3gB/mSgKCAYsXyE8=; b=HErpsF+z66KF1ifTN9qXgTeOy29QZfjaSgipfaVSVrVlTdPm7lzItNVArdAj1G9WFu/ROm1MIph5y2xEqVd/4OBpY75G3iTCKK3tGlAF02/WXbPsRjF4rGViUJG92xsIETUsNeJCHEc3sNYsvML1SR1oYFb11GWyeugjd3/Dwa0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675063506163.93901962800942; Fri, 28 Apr 2023 02:44:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKe0-0003Qa-O7; Fri, 28 Apr 2023 05:44:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKdz-0003QS-7X for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:43:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKdx-0007Yj-FF for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:43:58 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-eK04ByLuNri398SQT-6Shg-1; Fri, 28 Apr 2023 05:43:52 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D82B91C06EE6; Fri, 28 Apr 2023 09:43:51 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5A401410F23; Fri, 28 Apr 2023 09:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Whl14FdWI0R6prvjrfI/55CDXqG3gB/mSgKCAYsXyE8=; b=HFsKfYiFGTZlko3UctGsxAtMYhlXLrzlR/+5GY2htJ0YIBZ6I2KukJo8RnpINhQeYXrH3y ASdCTnQANpVNZGdg2KJ9kTWDsfAWeoO0HsR31AWN+2zrrzZxRur4sUjlXbbEYksvdaPUKj edlO9lnvwsFzgIrSpqOrNhlTrncVmws= X-MC-Unique: eK04ByLuNri398SQT-6Shg-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , Ilya Leoshkevich , David Hildenbrand Subject: [PULL 01/13] s390x/gdb: Split s390-virt.xml Date: Fri, 28 Apr 2023 11:43:34 +0200 Message-Id: <20230428094346.1292054-2-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675065026100003 Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich Both TCG and KVM emulate ckc, cputm, last_break and prefix, and it's quite useful to have them during debugging. Right now they are grouped together with KVM-only pp, pfault_token, pfault_select and pfault_compare in s390-virt.xml, and are not available when debugging TCG-emulated code. Move KVM-only registers into the new s390-virt-kvm.xml file. Advertise s390-virt.xml always, and the new s390-virt-kvm.xml only for KVM. Signed-off-by: Ilya Leoshkevich Message-Id: <20230314101813.174874-1-iii@linux.ibm.com> Acked-by: David Hildenbrand Signed-off-by: Thomas Huth --- configs/targets/s390x-linux-user.mak | 2 +- configs/targets/s390x-softmmu.mak | 2 +- target/s390x/gdbstub.c | 65 +++++++++++++++++++--------- gdb-xml/s390-virt-kvm.xml | 14 ++++++ gdb-xml/s390-virt.xml | 4 -- 5 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 gdb-xml/s390-virt-kvm.xml diff --git a/configs/targets/s390x-linux-user.mak b/configs/targets/s390x-l= inux-user.mak index e2978248ed..24c04c8589 100644 --- a/configs/targets/s390x-linux-user.mak +++ b/configs/targets/s390x-linux-user.mak @@ -2,4 +2,4 @@ TARGET_ARCH=3Ds390x TARGET_SYSTBL_ABI=3Dcommon,64 TARGET_SYSTBL=3Dsyscall.tbl TARGET_BIG_ENDIAN=3Dy -TARGET_XML_FILES=3D gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/= s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml = gdb-xml/s390-gs.xml +TARGET_XML_FILES=3D gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/= s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml = gdb-xml/s390-virt-kvm.xml gdb-xml/s390-gs.xml diff --git a/configs/targets/s390x-softmmu.mak b/configs/targets/s390x-soft= mmu.mak index 258b4cf358..70d2f9f0ba 100644 --- a/configs/targets/s390x-softmmu.mak +++ b/configs/targets/s390x-softmmu.mak @@ -1,4 +1,4 @@ TARGET_ARCH=3Ds390x TARGET_BIG_ENDIAN=3Dy TARGET_SUPPORTS_MTTCG=3Dy -TARGET_XML_FILES=3D gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/= s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml = gdb-xml/s390-gs.xml +TARGET_XML_FILES=3D gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/= s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml = gdb-xml/s390-virt-kvm.xml gdb-xml/s390-gs.xml diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index 0cb69395b4..6fbfd41bc8 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -206,12 +206,8 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t= *mem_buf, int n) #define S390_VIRT_CPUTM_REGNUM 1 #define S390_VIRT_BEA_REGNUM 2 #define S390_VIRT_PREFIX_REGNUM 3 -#define S390_VIRT_PP_REGNUM 4 -#define S390_VIRT_PFT_REGNUM 5 -#define S390_VIRT_PFS_REGNUM 6 -#define S390_VIRT_PFC_REGNUM 7 /* total number of registers in s390-virt.xml */ -#define S390_NUM_VIRT_REGS 8 +#define S390_NUM_VIRT_REGS 4 =20 static int cpu_read_virt_reg(CPUS390XState *env, GByteArray *mem_buf, int = n) { @@ -224,14 +220,6 @@ static int cpu_read_virt_reg(CPUS390XState *env, GByte= Array *mem_buf, int n) return gdb_get_regl(mem_buf, env->gbea); case S390_VIRT_PREFIX_REGNUM: return gdb_get_regl(mem_buf, env->psa); - case S390_VIRT_PP_REGNUM: - return gdb_get_regl(mem_buf, env->pp); - case S390_VIRT_PFT_REGNUM: - return gdb_get_regl(mem_buf, env->pfault_token); - case S390_VIRT_PFS_REGNUM: - return gdb_get_regl(mem_buf, env->pfault_select); - case S390_VIRT_PFC_REGNUM: - return gdb_get_regl(mem_buf, env->pfault_compare); default: return 0; } @@ -256,19 +244,51 @@ static int cpu_write_virt_reg(CPUS390XState *env, uin= t8_t *mem_buf, int n) env->psa =3D ldtul_p(mem_buf); cpu_synchronize_post_init(env_cpu(env)); return 8; - case S390_VIRT_PP_REGNUM: + default: + return 0; + } +} + +/* the values represent the positions in s390-virt-kvm.xml */ +#define S390_VIRT_KVM_PP_REGNUM 0 +#define S390_VIRT_KVM_PFT_REGNUM 1 +#define S390_VIRT_KVM_PFS_REGNUM 2 +#define S390_VIRT_KVM_PFC_REGNUM 3 +/* total number of registers in s390-virt-kvm.xml */ +#define S390_NUM_VIRT_KVM_REGS 4 + +static int cpu_read_virt_kvm_reg(CPUS390XState *env, GByteArray *mem_buf, = int n) +{ + switch (n) { + case S390_VIRT_KVM_PP_REGNUM: + return gdb_get_regl(mem_buf, env->pp); + case S390_VIRT_KVM_PFT_REGNUM: + return gdb_get_regl(mem_buf, env->pfault_token); + case S390_VIRT_KVM_PFS_REGNUM: + return gdb_get_regl(mem_buf, env->pfault_select); + case S390_VIRT_KVM_PFC_REGNUM: + return gdb_get_regl(mem_buf, env->pfault_compare); + default: + return 0; + } +} + +static int cpu_write_virt_kvm_reg(CPUS390XState *env, uint8_t *mem_buf, in= t n) +{ + switch (n) { + case S390_VIRT_KVM_PP_REGNUM: env->pp =3D ldtul_p(mem_buf); cpu_synchronize_post_init(env_cpu(env)); return 8; - case S390_VIRT_PFT_REGNUM: + case S390_VIRT_KVM_PFT_REGNUM: env->pfault_token =3D ldtul_p(mem_buf); cpu_synchronize_post_init(env_cpu(env)); return 8; - case S390_VIRT_PFS_REGNUM: + case S390_VIRT_KVM_PFS_REGNUM: env->pfault_select =3D ldtul_p(mem_buf); cpu_synchronize_post_init(env_cpu(env)); return 8; - case S390_VIRT_PFC_REGNUM: + case S390_VIRT_KVM_PFC_REGNUM: env->pfault_compare =3D ldtul_p(mem_buf); cpu_synchronize_post_init(env_cpu(env)); return 8; @@ -321,10 +341,15 @@ void s390_cpu_gdb_init(CPUState *cs) cpu_write_c_reg, S390_NUM_C_REGS, "s390-cr.xml", 0); =20 + gdb_register_coprocessor(cs, cpu_read_virt_reg, + cpu_write_virt_reg, + S390_NUM_VIRT_REGS, "s390-virt.xml", 0); + if (kvm_enabled()) { - gdb_register_coprocessor(cs, cpu_read_virt_reg, - cpu_write_virt_reg, - S390_NUM_VIRT_REGS, "s390-virt.xml", 0); + gdb_register_coprocessor(cs, cpu_read_virt_kvm_reg, + cpu_write_virt_kvm_reg, + S390_NUM_VIRT_KVM_REGS, "s390-virt-kvm.xm= l", + 0); } #endif } diff --git a/gdb-xml/s390-virt-kvm.xml b/gdb-xml/s390-virt-kvm.xml new file mode 100644 index 0000000000..a256eddaf5 --- /dev/null +++ b/gdb-xml/s390-virt-kvm.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/gdb-xml/s390-virt.xml b/gdb-xml/s390-virt.xml index e2e9a7ad3c..438eb68aab 100644 --- a/gdb-xml/s390-virt.xml +++ b/gdb-xml/s390-virt.xml @@ -11,8 +11,4 @@ - - - - --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675076; cv=none; d=zohomail.com; s=zohoarc; b=h05ePgb0SL6BxkIF1aPlBf/oDy8egHIgZYAVTYSO7HYAugxOiNnSLtoKX0lAoGR5HP24EWmzS1uSolPQESyCNHil0Ok0fQUM3A+pA+rnIRCrl4y1S0dpJYrO73GOUTXHxKAEZMbWtt7xalsFIWmqvl5VoKAWNk9snPAn/hm3rE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675076; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FMY6TNWmsyd0oLNeirVgt3oxIPuY5OVMgckNjaBfKmo=; b=P3WejQoGs2uPwlsgkn2VeM2JCrsleP2LywCXgwEpVql9HCXPJ1q4p4l16wjBHACv9pfp5nKLJxnAfKVsd8rE+v+XpquwG/EOUti8wbCfj1L4hVuDyNBhfLrMJejhuYcD+fFR3CyIy/DebGWwSNe0G9Fbe3u1Xo6esUfD73DkVkI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168267507612562.74127777066326; Fri, 28 Apr 2023 02:44:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKeE-0003dO-T6; Fri, 28 Apr 2023 05:44:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe8-0003Uz-0J for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe6-0007a2-AS for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:07 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-104-FUmGqKGLOwOwHsYXKivcRw-1; Fri, 28 Apr 2023 05:43:53 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69B4810504A6; Fri, 28 Apr 2023 09:43:53 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 413B41410F1E; Fri, 28 Apr 2023 09:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FMY6TNWmsyd0oLNeirVgt3oxIPuY5OVMgckNjaBfKmo=; b=VSIaO2Q09eKwqh5J01+f4B0onORE33ixJbnN7fmtap1qmfX/pjV0rq+l+Qt1HNW+z1We1U dDA+XhFKktMMDdCUowuAoYpRyZzDyaUscR+H9KKw2lR5+Qeef3lOD6myF3S0txjqeIiBRS bxn84tFQTyEy/z7wIMYDx9Yek2oJMFg= X-MC-Unique: FUmGqKGLOwOwHsYXKivcRw-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 02/13] hw/rdma: Remove unused macros PG_DIR_SZ and PG_TBL_SZ Date: Fri, 28 Apr 2023 11:43:35 +0200 Message-Id: <20230428094346.1292054-3-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675076727100002 They have apparently never been used. Message-Id: <20230419103018.627115-1-thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Thomas Huth --- hw/rdma/rdma_rm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c index cfd85de3e6..038d564433 100644 --- a/hw/rdma/rdma_rm.c +++ b/hw/rdma/rdma_rm.c @@ -23,10 +23,6 @@ #include "rdma_backend.h" #include "rdma_rm.h" =20 -/* Page directory and page tables */ -#define PG_DIR_SZ { TARGET_PAGE_SIZE / sizeof(__u64) } -#define PG_TBL_SZ { TARGET_PAGE_SIZE / sizeof(__u64) } - void rdma_format_device_counters(RdmaDeviceResources *dev_res, GString *bu= f) { g_string_append_printf(buf, "\ttx : %" PRId64 "\n", --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675130; cv=none; d=zohomail.com; s=zohoarc; b=MIxuM7BqyEjWMc4pY/7fE5T9mEn6jVJqon+7kkFNshcFbT75CbJRSgcNkBa2UpDb7o5RS+lfaA9TrTJRBY9I9ZkIoM1YCXoioM+cj2LZMFJIq2qXe4PSxx1AAmEpkj+GmnuLZkZBnVRDJFUZjgdEcZAk5DG0MwiLTwKJI1IXHNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675130; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uvO69u+7iCd+pwuHsuzCzuuClp9Td+ey/1aZNXKPKaw=; b=LSLQypUSax/cEOaEVLhMWQDD4DmyclgfYesuHLbokZxjV7a/IPeA9TcKUes5Iiz4pN4XRf93qoAwLueLBm3cfIFz2mS1TvuoQDQcq360u3mM3qelXBFPinUgUNpL82s7nbLila4LeeElDkAiXsELW8DHEHOBAMalQoN2IJo3Qg4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675130957220.66013091094317; Fri, 28 Apr 2023 02:45:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKe3-0003R4-8O; Fri, 28 Apr 2023 05:44:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe1-0003Qh-9e for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKdz-0007Yz-TM for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:01 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-512-Vw5Xr2TnMqeB8fuw3lA_Jg-1; Fri, 28 Apr 2023 05:43:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E575185A78B; Fri, 28 Apr 2023 09:43:55 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id C50F81410F1E; Fri, 28 Apr 2023 09:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uvO69u+7iCd+pwuHsuzCzuuClp9Td+ey/1aZNXKPKaw=; b=g6TcWPdycv0CL3+TRVUUyu8GyhNzfFyh6uBsYrlENoTgFSvlU6KIUJQLT/8ElEosLajB9u m2PL6Uh1ohvHypg5GJbZBWahHH1uGTLodlYGEV+xaKvMYj50az8IhQ2iO03DWqBFqRsYbT hegRAgzbGa7/WMWG7jAYByTi/jhTJcI= X-MC-Unique: Vw5Xr2TnMqeB8fuw3lA_Jg-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 03/13] hw/rdma: Compile target-independent parts of the rdma code only once Date: Fri, 28 Apr 2023 11:43:36 +0200 Message-Id: <20230428094346.1292054-4-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675132934100003 Some files of the rdma code do not depend on any target specific macros. Compile these only once to save some time during the build. Message-Id: <20230419114937.667221-1-thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Thomas Huth --- hw/rdma/meson.build | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/rdma/meson.build b/hw/rdma/meson.build index 7325f40c32..fc7917192f 100644 --- a/hw/rdma/meson.build +++ b/hw/rdma/meson.build @@ -1,10 +1,12 @@ -specific_ss.add(when: 'CONFIG_VMW_PVRDMA', if_true: files( +softmmu_ss.add(when: 'CONFIG_VMW_PVRDMA', if_true: files( 'rdma.c', 'rdma_backend.c', - 'rdma_rm.c', 'rdma_utils.c', + 'vmw/pvrdma_qp_ops.c', +)) +specific_ss.add(when: 'CONFIG_VMW_PVRDMA', if_true: files( + 'rdma_rm.c', 'vmw/pvrdma_cmd.c', 'vmw/pvrdma_dev_ring.c', 'vmw/pvrdma_main.c', - 'vmw/pvrdma_qp_ops.c', )) --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675076; cv=none; d=zohomail.com; s=zohoarc; b=U9ilAgQQINVfbjMgCth7EKWV02/uIPwS/cWRiF2v2cMnvbr9r4VW5orcrThcaEoSZSI/G5f2rp3Pfwo8B1lPTHLkmrSNFMtxAKnxc7+rxvvrx/9UP4lA21snf5KXsnjkzy/6iEZ1Du7skQ5ZPE++51npm6vL0NmZ1+F2J50QCOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675076; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XChoz1NxmCDnDkixQUKIQ0886I/dab/bZMOvKB3ZcdI=; b=IPLJRGp4Vk6ijq47AvllolyHwJIFF87STW1CRWAn1mmWEg/+jiaHPThlkPSptjukkouE3xfhUCDXPCGZPBWxMuNUqU67rqElcTVeAs6c7wkHSAbe8FStkwNXiGgVXkOtQ2vbnJJS6r/OqokCgp83zxAlf/gzGE0n5mOyfoLL/dU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675076109176.7642283136505; Fri, 28 Apr 2023 02:44:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKeA-0003ZC-9q; Fri, 28 Apr 2023 05:44:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe6-0003Rb-0t for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe4-0007Zc-2m for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:05 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-380-kES6YnmLO56rHovBlftC1A-1; Fri, 28 Apr 2023 05:43:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 35461885621; Fri, 28 Apr 2023 09:43:57 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id E724B1410F1E; Fri, 28 Apr 2023 09:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XChoz1NxmCDnDkixQUKIQ0886I/dab/bZMOvKB3ZcdI=; b=IzFSpjLDi5m7CMAAvFp5JYDYWeJRfjaTHGF6rehh0BnkRMhRx1Bv1gbiIt1wUvtoWaJRKw q34Ac6ScB9xW9oVoqU9Q6kYgw3bW+K4iP56z7alh6t1AZAuZaT8NWXr+5UpZrKdl+Draz2 oyjK1z7vbJ4MWnaFZrI2W1ZGO6yb8k4= X-MC-Unique: kES6YnmLO56rHovBlftC1A-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 04/13] hw/rdma: VMW_PVRDMA should depend on VMXNET3_PCI Date: Fri, 28 Apr 2023 11:43:37 +0200 Message-Id: <20230428094346.1292054-5-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675077023100007 The "pvrdma" device is only usable in conjunction with the "vmxnet3" NIC - see the check for TYPE_VMXNET3 in pvrdma_realize(). By adding this dependency, the amount of total files that have to be compiled for a configuration with all targets decreases by 64 files (!), since the rdma code is marked as target specific and thus got recompiled for all targets that enable PCI so far. Message-Id: <20230419111337.651673-1-thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Thomas Huth --- hw/rdma/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/rdma/Kconfig b/hw/rdma/Kconfig index 8e2211288f..840320bdc0 100644 --- a/hw/rdma/Kconfig +++ b/hw/rdma/Kconfig @@ -1,3 +1,3 @@ config VMW_PVRDMA default y if PCI_DEVICES - depends on PVRDMA && PCI && MSI_NONBROKEN + depends on PVRDMA && MSI_NONBROKEN && VMXNET3_PCI --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675079; cv=none; d=zohomail.com; s=zohoarc; b=Sl+4955Syu+IdPoZn22SwMWAmlH0TNj23ldP/zLMabKyJVLd+Nqe98elN1lJBNZq6bA0qTUOY64KD+X27nm/6FC/y1cGn9+XiCcQ2q/Z1iiXiNhZHrjUTdfkvaEixEuF3NpRFzlA4SC9sopFWprrXmPbV1g1NLKUVzNbLRDQJ9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675079; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CgZozoZ7jWMLBqlLHxf2A8jgsAID5gZcpTdT4lg09Dc=; b=iw0Ik/+ppCHiCQ+AMdp7qGGlXfPr85DyCHrM7T6ZT7qN5Oj8W+ILpnK6v28ICOax5EQUBFolm6dGuO7avTm8NMN6/RcgiM5i81TAVU7ruErc6S2h7befTbZZXFI55pSDxw63RuMnunThKgKwpojHIz7xOm7IDpnUk+rZSO89r0E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675079669294.6287642056195; Fri, 28 Apr 2023 02:44:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKe9-0003VW-0K; Fri, 28 Apr 2023 05:44:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe4-0003RL-B4 for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe2-0007ZO-Ue for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:04 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-Rr1e7AHsMxCzZsUZoynJwg-1; Fri, 28 Apr 2023 05:43:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 872F13C397C3; Fri, 28 Apr 2023 09:43:58 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BD121410F1E; Fri, 28 Apr 2023 09:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CgZozoZ7jWMLBqlLHxf2A8jgsAID5gZcpTdT4lg09Dc=; b=GQdpVpnnja67dK9yRL7YvLe/ORpIgTl/EBeVQ75xVZOIcdGqO3ZiI4RGmcHT2YP4EQ37FV RBr3Zmeel/IMnqBYdzSlAdMlgmohd0sHAyWnDU5OnRehhhsLj4+KrMcHj3PuVpzUcFymQM 3sXm+jRkUJI0RqvJzUcPB4p1YCeLaPU= X-MC-Unique: Rr1e7AHsMxCzZsUZoynJwg-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , Paolo Bonzini Subject: [PULL 05/13] tests: vhost-user-test: release mutex on protocol violation Date: Fri, 28 Apr 2023 11:43:38 +0200 Message-Id: <20230428094346.1292054-6-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675080730100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini chr_read() is printing an error message and returning with s->data_mutex ta= ken. This can potentially cause a hang. Reported by Coverity. Signed-off-by: Paolo Bonzini Message-Id: <20230427125423.103536-1-pbonzini@redhat.com> Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/qtest/vhost-user-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index bf9f7c4248..e4f95b2858 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -351,7 +351,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) if (size !=3D msg.size) { qos_printf("%s: Wrong message size received %d !=3D %d\n", __func__, size, msg.size); - return; + goto out; } } =20 @@ -509,6 +509,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) break; } =20 +out: g_mutex_unlock(&s->data_mutex); } =20 --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675150; cv=none; d=zohomail.com; s=zohoarc; b=hjaNj9TVLbuzn213l7H4Aba43O+RNOELatbeCZ5ZAS7IebumUVOuAEmFxRR4SkFDKPtAi3Vt3RcDWmTbSodE9Qz9YF7ii7pwmpdCBmVFbqgkzkpX8HKzwJnVtE1TLIgc024BUjtk7Pk/ZGsMqbrEFMfbtWVImJhFTdKGdmUmCUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675150; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cXaLpd203QwVJtQ9A6szekZJ+736OD/NuahYG+Yxquo=; b=hGVn+kFf1a0kTiWOA0qiIOimXs7yrfI8W0FQlWHA2t+wOdd2Nu+1BwmMhEb0nDUn9pFxjurdbsTe5GkYPebb4COhov6uI4jXH9eWF4qMGWRonymCeYJ0snGTzb04ic4fZuWdxmU6uQaANwRh4EcgPL1tRlrgHk2eQ16fTe0kVfc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168267515060486.96246032410511; Fri, 28 Apr 2023 02:45:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKe7-0003Rm-4o; Fri, 28 Apr 2023 05:44:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe4-0003RK-7a for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe2-0007ZG-Dx for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:03 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-462-vnS9hBzLPTa1WQAHCbmcnA-1; Fri, 28 Apr 2023 05:44:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EB5FA10504A2; Fri, 28 Apr 2023 09:43:59 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC41C1410F1E; Fri, 28 Apr 2023 09:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cXaLpd203QwVJtQ9A6szekZJ+736OD/NuahYG+Yxquo=; b=fmyPSV5y8j0jkMev4mX4fSPcnoXmmNBXJbzb1MODnwiJc603xfHMU7KLDBY9Fv85fki5vd Jv9wP0qW/6YJ2UzWpQsTj4hub1mTf144kjnAQ4hwl7QOT25WOxkg6ht7AbD23DjIrTpFSk /yTrdb42ad9kgvNB4dXsbBG21aTals0= X-MC-Unique: vnS9hBzLPTa1WQAHCbmcnA-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov Subject: [PULL 06/13] memory: prevent dma-reentracy issues Date: Fri, 28 Apr 2023 11:43:39 +0200 Message-Id: <20230428094346.1292054-7-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675152500100003 Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov Add a flag to the DeviceState, when a device is engaged in PIO/MMIO/DMA. This flag is set/checked prior to calling a device's MemoryRegion handlers, and set when device code initiates DMA. The purpose of this flag is to prevent two types of DMA-based reentrancy issues: 1.) mmio -> dma -> mmio case 2.) bh -> dma write -> mmio case These issues have led to problems such as stack-exhaustion and use-after-frees. Summary of the problem from Peter Maydell: https://lore.kernel.org/qemu-devel/CAFEAcA_23vc7hE3iaM-JVA6W38LK4hJoWae5Kck= nhPRD5fPBZA@mail.gmail.com Resolves: https://gitlab.com/qemu-project/qemu/-/issues/62 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/540 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/541 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/556 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/557 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/827 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1282 Resolves: CVE-2023-0330 Signed-off-by: Alexander Bulekov Reviewed-by: Thomas Huth Message-Id: <20230427211013.2994127-2-alxndr@bu.edu> [thuth: Replace warn_report() with warn_report_once()] Signed-off-by: Thomas Huth --- include/exec/memory.h | 5 +++++ include/hw/qdev-core.h | 7 +++++++ softmmu/memory.c | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 15ade918ba..e45ce6061f 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -767,6 +767,8 @@ struct MemoryRegion { bool is_iommu; RAMBlock *ram_block; Object *owner; + /* owner as TYPE_DEVICE. Used for re-entrancy checks in MR access hotp= ath */ + DeviceState *dev; =20 const MemoryRegionOps *ops; void *opaque; @@ -791,6 +793,9 @@ struct MemoryRegion { unsigned ioeventfd_nb; MemoryRegionIoeventfd *ioeventfds; RamDiscardManager *rdm; /* Only for RAM */ + + /* For devices designed to perform re-entrant IO into their own IO MRs= */ + bool disable_reentrancy_guard; }; =20 struct IOMMUMemoryRegion { diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index bd50ad5ee1..7623703943 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -162,6 +162,10 @@ struct NamedClockList { QLIST_ENTRY(NamedClockList) node; }; =20 +typedef struct { + bool engaged_in_io; +} MemReentrancyGuard; + /** * DeviceState: * @realized: Indicates whether the device has been fully constructed. @@ -194,6 +198,9 @@ struct DeviceState { int alias_required_for_version; ResettableState reset; GSList *unplug_blockers; + + /* Is the device currently in mmio/pio/dma? Used to prevent re-entranc= y */ + MemReentrancyGuard mem_reentrancy_guard; }; =20 struct DeviceListener { diff --git a/softmmu/memory.c b/softmmu/memory.c index b1a6cae6f5..b7b3386e9d 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -542,6 +542,18 @@ static MemTxResult access_with_adjusted_size(hwaddr ad= dr, access_size_max =3D 4; } =20 + /* Do not allow more than one simultaneous access to a device's IO Reg= ions */ + if (mr->dev && !mr->disable_reentrancy_guard && + !mr->ram_device && !mr->ram && !mr->rom_device && !mr->readonly) { + if (mr->dev->mem_reentrancy_guard.engaged_in_io) { + warn_report_once("Blocked re-entrant IO on MemoryRegion: " + "%s at addr: 0x%" HWADDR_PRIX, + memory_region_name(mr), addr); + return MEMTX_ACCESS_ERROR; + } + mr->dev->mem_reentrancy_guard.engaged_in_io =3D true; + } + /* FIXME: support unaligned access? */ access_size =3D MAX(MIN(size, access_size_max), access_size_min); access_mask =3D MAKE_64BIT_MASK(0, access_size * 8); @@ -556,6 +568,9 @@ static MemTxResult access_with_adjusted_size(hwaddr add= r, access_mask, attrs); } } + if (mr->dev) { + mr->dev->mem_reentrancy_guard.engaged_in_io =3D false; + } return r; } =20 @@ -1170,6 +1185,7 @@ static void memory_region_do_init(MemoryRegion *mr, } mr->name =3D g_strdup(name); mr->owner =3D owner; + mr->dev =3D (DeviceState *) object_dynamic_cast(mr->owner, TYPE_DEVICE= ); mr->ram_block =3D NULL; =20 if (name) { --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675114; cv=none; d=zohomail.com; s=zohoarc; b=B+QVDfztzImS0Zfxl7A8PqTTQa1KN/P+9CuTMbWc8kTlGeqo8bpPSoweYzD17iZD15+kY5448mmDsFyoNd8g0nP/wfWqt2LbAC3m6foCh/ItgsbMtr/LDIzl5y/1iF3cKHxlF43m7/rsZ8BdzECW99qwGCRL4rPmXtqEQJ9Vya0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675114; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kRLlU1drXdyiw7eseyPE3LzZKfsDIDxaz257GfJpRPI=; b=XCWhjPYT287bhHHVpgrOlTH8V1zIVawIdT+6lLw3+NpFAKGZJKz3wogER/tKP3fik3Gc9ndvkbUJjw7PDhzqU6kWacxtArK+mbz7CADvL5eog+X0aolXYUaqgoO0tbfEO5DOVHaaJ7GUieiLEFbmxwMxELe1/17JRknLckoIqCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675114842633.6545472613985; Fri, 28 Apr 2023 02:45:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKeE-0003ap-3g; Fri, 28 Apr 2023 05:44:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe8-0003VL-0S for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKe6-0007a0-2J for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:07 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-LzLtFYg8P5aqxrMMQPuw5g-1; Fri, 28 Apr 2023 05:44:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBFE31C04B6C; Fri, 28 Apr 2023 09:44:01 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74A691410F1E; Fri, 28 Apr 2023 09:44:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kRLlU1drXdyiw7eseyPE3LzZKfsDIDxaz257GfJpRPI=; b=Xy23EbysCOS3+ry+XfYfL5RaShpIovtJCRSAff+ICLzyOFFBwa/kC2N/uzrrjIIw5x7M35 LuXN7UDhfljGC5iWy3AXNmKoJvo5j/ZS3ASmJ57If6aMsH4dM8GCxn6SIuN//kHX8GauqE yx9X87+ojAUojdMYVi/1afQJh5nuMps= X-MC-Unique: LzLtFYg8P5aqxrMMQPuw5g-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , Darren Kenny Subject: [PULL 07/13] async: Add an optional reentrancy guard to the BH API Date: Fri, 28 Apr 2023 11:43:40 +0200 Message-Id: <20230428094346.1292054-8-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675115998100001 Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov Devices can pass their MemoryReentrancyGuard (from their DeviceState), when creating new BHes. Then, the async API will toggle the guard before/after calling the BH call-back. This prevents bh->mmio reentrancy issues. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Message-Id: <20230427211013.2994127-3-alxndr@bu.edu> [thuth: Fix "line over 90 characters" checkpatch.pl error] Signed-off-by: Thomas Huth --- docs/devel/multiple-iothreads.txt | 7 +++++++ include/block/aio.h | 18 ++++++++++++++++-- include/qemu/main-loop.h | 7 +++++-- tests/unit/ptimer-test-stubs.c | 3 ++- util/async.c | 18 +++++++++++++++++- util/main-loop.c | 6 ++++-- util/trace-events | 1 + 7 files changed, 52 insertions(+), 8 deletions(-) diff --git a/docs/devel/multiple-iothreads.txt b/docs/devel/multiple-iothre= ads.txt index 343120f2ef..a3e949f6b3 100644 --- a/docs/devel/multiple-iothreads.txt +++ b/docs/devel/multiple-iothreads.txt @@ -61,6 +61,7 @@ There are several old APIs that use the main loop AioCont= ext: * LEGACY qemu_aio_set_event_notifier() - monitor an event notifier * LEGACY timer_new_ms() - create a timer * LEGACY qemu_bh_new() - create a BH + * LEGACY qemu_bh_new_guarded() - create a BH with a device re-entrancy gu= ard * LEGACY qemu_aio_wait() - run an event loop iteration =20 Since they implicitly work on the main loop they cannot be used in code th= at @@ -72,8 +73,14 @@ Instead, use the AioContext functions directly (see incl= ude/block/aio.h): * aio_set_event_notifier() - monitor an event notifier * aio_timer_new() - create a timer * aio_bh_new() - create a BH + * aio_bh_new_guarded() - create a BH with a device re-entrancy guard * aio_poll() - run an event loop iteration =20 +The qemu_bh_new_guarded/aio_bh_new_guarded APIs accept a "MemReentrancyGua= rd" +argument, which is used to check for and prevent re-entrancy problems. For +BHs associated with devices, the reentrancy-guard is contained in the +corresponding DeviceState and named "mem_reentrancy_guard". + The AioContext can be obtained from the IOThread using iothread_get_aio_context() or for the main loop using qemu_get_aio_context= (). Code that takes an AioContext argument works both in IOThreads or the main diff --git a/include/block/aio.h b/include/block/aio.h index e267d918fd..89bbc536f9 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -23,6 +23,8 @@ #include "qemu/thread.h" #include "qemu/timer.h" #include "block/graph-lock.h" +#include "hw/qdev-core.h" + =20 typedef struct BlockAIOCB BlockAIOCB; typedef void BlockCompletionFunc(void *opaque, int ret); @@ -323,9 +325,11 @@ void aio_bh_schedule_oneshot_full(AioContext *ctx, QEM= UBHFunc *cb, void *opaque, * is opaque and must be allocated prior to its use. * * @name: A human-readable identifier for debugging purposes. + * @reentrancy_guard: A guard set when entering a cb to prevent + * device-reentrancy issues */ QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque, - const char *name); + const char *name, MemReentrancyGuard *reentrancy_g= uard); =20 /** * aio_bh_new: Allocate a new bottom half structure @@ -334,7 +338,17 @@ QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *c= b, void *opaque, * string. */ #define aio_bh_new(ctx, cb, opaque) \ - aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb))) + aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb)), NULL) + +/** + * aio_bh_new_guarded: Allocate a new bottom half structure with a + * reentrancy_guard + * + * A convenience wrapper for aio_bh_new_full() that uses the cb as the name + * string. + */ +#define aio_bh_new_guarded(ctx, cb, opaque, guard) \ + aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb)), guard) =20 /** * aio_notify: Force processing of pending events. diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index b3e54e00bc..68e70e61aa 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -387,9 +387,12 @@ void qemu_cond_timedwait_iothread(QemuCond *cond, int = ms); =20 /* internal interfaces */ =20 +#define qemu_bh_new_guarded(cb, opaque, guard) \ + qemu_bh_new_full((cb), (opaque), (stringify(cb)), guard) #define qemu_bh_new(cb, opaque) \ - qemu_bh_new_full((cb), (opaque), (stringify(cb))) -QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name); + qemu_bh_new_full((cb), (opaque), (stringify(cb)), NULL) +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name, + MemReentrancyGuard *reentrancy_guard); void qemu_bh_schedule_idle(QEMUBH *bh); =20 enum { diff --git a/tests/unit/ptimer-test-stubs.c b/tests/unit/ptimer-test-stubs.c index f2bfcede93..8c9407c560 100644 --- a/tests/unit/ptimer-test-stubs.c +++ b/tests/unit/ptimer-test-stubs.c @@ -107,7 +107,8 @@ int64_t qemu_clock_deadline_ns_all(QEMUClockType type, = int attr_mask) return deadline; } =20 -QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name) +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name, + MemReentrancyGuard *reentrancy_guard) { QEMUBH *bh =3D g_new(QEMUBH, 1); =20 diff --git a/util/async.c b/util/async.c index 21016a1ac7..a9b528c370 100644 --- a/util/async.c +++ b/util/async.c @@ -65,6 +65,7 @@ struct QEMUBH { void *opaque; QSLIST_ENTRY(QEMUBH) next; unsigned flags; + MemReentrancyGuard *reentrancy_guard; }; =20 /* Called concurrently from any thread */ @@ -137,7 +138,7 @@ void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMU= BHFunc *cb, } =20 QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque, - const char *name) + const char *name, MemReentrancyGuard *reentrancy_g= uard) { QEMUBH *bh; bh =3D g_new(QEMUBH, 1); @@ -146,13 +147,28 @@ QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *= cb, void *opaque, .cb =3D cb, .opaque =3D opaque, .name =3D name, + .reentrancy_guard =3D reentrancy_guard, }; return bh; } =20 void aio_bh_call(QEMUBH *bh) { + bool last_engaged_in_io =3D false; + + if (bh->reentrancy_guard) { + last_engaged_in_io =3D bh->reentrancy_guard->engaged_in_io; + if (bh->reentrancy_guard->engaged_in_io) { + trace_reentrant_aio(bh->ctx, bh->name); + } + bh->reentrancy_guard->engaged_in_io =3D true; + } + bh->cb(bh->opaque); + + if (bh->reentrancy_guard) { + bh->reentrancy_guard->engaged_in_io =3D last_engaged_in_io; + } } =20 /* Multiple occurrences of aio_bh_poll cannot be called concurrently. */ diff --git a/util/main-loop.c b/util/main-loop.c index e180c85145..7022f02ef8 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -605,9 +605,11 @@ void main_loop_wait(int nonblocking) =20 /* Functions to operate on the main QEMU AioContext. */ =20 -QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name) +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name, + MemReentrancyGuard *reentrancy_guard) { - return aio_bh_new_full(qemu_aio_context, cb, opaque, name); + return aio_bh_new_full(qemu_aio_context, cb, opaque, name, + reentrancy_guard); } =20 /* diff --git a/util/trace-events b/util/trace-events index 16f78d8fe5..3f7e766683 100644 --- a/util/trace-events +++ b/util/trace-events @@ -11,6 +11,7 @@ poll_remove(void *ctx, void *node, int fd) "ctx %p node %= p fd %d" # async.c aio_co_schedule(void *ctx, void *co) "ctx %p co %p" aio_co_schedule_bh_cb(void *ctx, void *co) "ctx %p co %p" +reentrant_aio(void *ctx, const char *name) "ctx %p name %s" =20 # thread-pool.c thread_pool_submit(void *pool, void *req, void *opaque) "pool %p req %p op= aque %p" --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675094; cv=none; d=zohomail.com; s=zohoarc; b=MeToZ4TBmpK+w0nFSlCweCxiAQq3E/uwRDVpuHyj0Xb3lZuKWy1BIzsYh+AzuhU9KDYuPcEOHUJY0K+r6fFWeirRiEC+Tl3V/UjG8ms+Eibspmldelb8vM0hM7M+Q+EwlNNMfI0N3/KovERYihcDZO4cIlvpLCViudef5RvDICQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675094; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0Mr1/fRU9ceH1LU+d0AVHquTPN8MqPlPxllseBWvOm0=; b=Egh05en/7ygCLLk1wRJz0QMPHrxoV48/hgjK3lZM1b7q1mzTyy50ioNcseoaUP4wpxuK0msDcpil2pgr4WaJo7jlOT9o+VuftJaSRSrZNILdIAOSYDEiElORvyIC7Fsbdb0djEnkQZpVbZH1Z5Lz+MQI0KkA1692UF64DqFQOoM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675094452937.0998884052293; Fri, 28 Apr 2023 02:44:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKeI-0003kN-QP; Fri, 28 Apr 2023 05:44:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeB-0003ar-MC for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeA-0007ac-6p for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:11 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-nzM2p_jNPxOWX1CNYrI0iA-1; Fri, 28 Apr 2023 05:44:03 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 89073800047; Fri, 28 Apr 2023 09:44:03 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 480211410F1F; Fri, 28 Apr 2023 09:44:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Mr1/fRU9ceH1LU+d0AVHquTPN8MqPlPxllseBWvOm0=; b=FyWrgHpzI+NKv15K240kqf6A6FoaREijVEkzv/IzUrrJGKnYTzH6oVQODR7NBXJbvi/ZiQ X5JboxlhhahkP9n0twQprClGyWUeCTHNZyxlqpysouLfi8JWOMoxlyXwdufUXl/TPlPd3g /1/99JDLowi+fr1I/7Hu5WOix3oNOgw= X-MC-Unique: nzM2p_jNPxOWX1CNYrI0iA-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , Darren Kenny Subject: [PULL 08/13] checkpatch: add qemu_bh_new/aio_bh_new checks Date: Fri, 28 Apr 2023 11:43:41 +0200 Message-Id: <20230428094346.1292054-9-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675095119100005 Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov Advise authors to use the _guarded versions of the APIs, instead. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Message-Id: <20230427211013.2994127-4-alxndr@bu.edu> Signed-off-by: Thomas Huth --- scripts/checkpatch.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d768171dcf..eeaec436eb 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2865,6 +2865,14 @@ sub process { if ($line =3D~ /\bsignal\s*\(/ && !($line =3D~ /SIG_(?:IGN|DFL)/)) { ERROR("use sigaction to establish signal handlers; signal is not portab= le\n" . $herecurr); } +# recommend qemu_bh_new_guarded instead of qemu_bh_new + if ($realfile =3D~ /.*\/hw\/.*/ && $line =3D~ /\bqemu_bh_new\s*\(/= ) { + ERROR("use qemu_bh_new_guarded() instead of qemu_bh_new() to avoid reen= trancy problems\n" . $herecurr); + } +# recommend aio_bh_new_guarded instead of aio_bh_new + if ($realfile =3D~ /.*\/hw\/.*/ && $line =3D~ /\baio_bh_new\s*\(/)= { + ERROR("use aio_bh_new_guarded() instead of aio_bh_new() to avoid reentr= ancy problems\n" . $herecurr); + } # check for module_init(), use category-specific init macros explicitly pl= ease if ($line =3D~ /^module_init\s*\(/) { ERROR("please use block_init(), type_init() etc. instead of module_init= ()\n" . $herecurr); --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675085; cv=none; d=zohomail.com; s=zohoarc; b=TCQxCRGCGnj9t2rbxIKtxxdytNO7vIBvW8KBPE+CESetISOJ/nCCPBfSZLQXSG93PD/i/1JPvZOsDjSGKYRNUn3LIWkNNuHjNZuUTWE/SZCrn5s5T9IYVZoBV+vOguZX9Q+ypzW2rfsVDJX/mRKPWJFj3evwEcr9ZBhtn5mcyRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675085; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DNLnAEjqCz0t4tKgYFHGc2ADRvjbzq3rbIoObWorkfU=; b=UYnuIGweRoD9vA2PsDkGIAkwOlQ2lZcSO/AtKhb6ySVEtLUuODMlVwD9yohorgJoHjXboFk7U4bgki8zkOcQ/+K+ck/apv3m8tpgVMbABxd7hUWBUCZomgTRL7b79mPVwkBIaFcKcKmHGQsgkdnC22y4u5N8UAo28MQTq/ykYl8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675084992139.79267858219623; Fri, 28 Apr 2023 02:44:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKeM-0003qK-5a; Fri, 28 Apr 2023 05:44:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeD-0003b9-6E for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeA-0007ag-Pe for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:12 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-183-dzIUzSUvND-HiKnU0Jj8Rg-1; Fri, 28 Apr 2023 05:44:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37477885626; Fri, 28 Apr 2023 09:44:06 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id E932A1410F1E; Fri, 28 Apr 2023 09:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DNLnAEjqCz0t4tKgYFHGc2ADRvjbzq3rbIoObWorkfU=; b=ApHQ8SLa5vmWEhSf97DK9V6JUW2KalVEx23T9FcR7/ylqtWrK/YY1ovx9BT0i37GQ00fl3 RPgLulgurioSM/0RJpRnjPmYQAeL1n7VwX+FyJHGZg0I2TZFZCvwBgOQr20voUuH0vrjiw z36QYfhfRpWcQ/JAx6jfSaAQ7bkSZO8= X-MC-Unique: dzIUzSUvND-HiKnU0Jj8Rg-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , Darren Kenny , Stefan Hajnoczi , "Michael S . Tsirkin" , Paul Durrant Subject: [PULL 09/13] hw: replace most qemu_bh_new calls with qemu_bh_new_guarded Date: Fri, 28 Apr 2023 11:43:42 +0200 Message-Id: <20230428094346.1292054-10-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675086817100001 Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov This protects devices from bh->mmio reentrancy issues. Thanks: Thomas Huth for diagnosing OS X test failure. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Paul Durrant Reviewed-by: Thomas Huth Message-Id: <20230427211013.2994127-5-alxndr@bu.edu> Signed-off-by: Thomas Huth --- hw/ide/ahci_internal.h | 1 + hw/9pfs/xen-9p-backend.c | 5 ++++- hw/block/dataplane/virtio-blk.c | 3 ++- hw/block/dataplane/xen-block.c | 5 +++-- hw/char/virtio-serial-bus.c | 3 ++- hw/display/qxl.c | 9 ++++++--- hw/display/virtio-gpu.c | 6 ++++-- hw/ide/ahci.c | 3 ++- hw/ide/core.c | 4 +++- hw/misc/imx_rngc.c | 6 ++++-- hw/misc/macio/mac_dbdma.c | 2 +- hw/net/virtio-net.c | 3 ++- hw/nvme/ctrl.c | 6 ++++-- hw/scsi/mptsas.c | 3 ++- hw/scsi/scsi-bus.c | 3 ++- hw/scsi/vmw_pvscsi.c | 3 ++- hw/usb/dev-uas.c | 3 ++- hw/usb/hcd-dwc2.c | 3 ++- hw/usb/hcd-ehci.c | 3 ++- hw/usb/hcd-uhci.c | 2 +- hw/usb/host-libusb.c | 6 ++++-- hw/usb/redirect.c | 6 ++++-- hw/usb/xen-usb.c | 3 ++- hw/virtio/virtio-balloon.c | 5 +++-- hw/virtio/virtio-crypto.c | 3 ++- 25 files changed, 66 insertions(+), 33 deletions(-) diff --git a/hw/ide/ahci_internal.h b/hw/ide/ahci_internal.h index 303fcd7235..2480455372 100644 --- a/hw/ide/ahci_internal.h +++ b/hw/ide/ahci_internal.h @@ -321,6 +321,7 @@ struct AHCIDevice { bool init_d2h_sent; AHCICmdHdr *cur_cmd; NCQTransferState ncq_tfs[AHCI_MAX_CMDS]; + MemReentrancyGuard mem_reentrancy_guard; }; =20 struct AHCIPCIState { diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index 74f3a05f88..0e266c552b 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -61,6 +61,7 @@ typedef struct Xen9pfsDev { =20 int num_rings; Xen9pfsRing *rings; + MemReentrancyGuard mem_reentrancy_guard; } Xen9pfsDev; =20 static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev); @@ -443,7 +444,9 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xen= dev) xen_9pdev->rings[i].ring.out =3D xen_9pdev->rings[i].data + XEN_FLEX_RING_SIZE(ring_order); =20 - xen_9pdev->rings[i].bh =3D qemu_bh_new(xen_9pfs_bh, &xen_9pdev->ri= ngs[i]); + xen_9pdev->rings[i].bh =3D qemu_bh_new_guarded(xen_9pfs_bh, + &xen_9pdev->rings[i], + &xen_9pdev->mem_reent= rancy_guard); xen_9pdev->rings[i].out_cons =3D 0; xen_9pdev->rings[i].out_size =3D 0; xen_9pdev->rings[i].inprogress =3D false; diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-bl= k.c index b28d81737e..a6202997ee 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -127,7 +127,8 @@ bool virtio_blk_data_plane_create(VirtIODevice *vdev, V= irtIOBlkConf *conf, } else { s->ctx =3D qemu_get_aio_context(); } - s->bh =3D aio_bh_new(s->ctx, notify_guest_bh, s); + s->bh =3D aio_bh_new_guarded(s->ctx, notify_guest_bh, s, + &DEVICE(vdev)->mem_reentrancy_guard); s->batch_notify_vqs =3D bitmap_new(conf->num_queues); =20 *dataplane =3D s; diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index 734da42ea7..d8bc39d359 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -633,8 +633,9 @@ XenBlockDataPlane *xen_block_dataplane_create(XenDevice= *xendev, } else { dataplane->ctx =3D qemu_get_aio_context(); } - dataplane->bh =3D aio_bh_new(dataplane->ctx, xen_block_dataplane_bh, - dataplane); + dataplane->bh =3D aio_bh_new_guarded(dataplane->ctx, xen_block_datapla= ne_bh, + dataplane, + &DEVICE(xendev)->mem_reentrancy_gua= rd); =20 return dataplane; } diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 7d4601cb5d..dd619f0731 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -985,7 +985,8 @@ static void virtser_port_device_realize(DeviceState *de= v, Error **errp) return; } =20 - port->bh =3D qemu_bh_new(flush_queued_data_bh, port); + port->bh =3D qemu_bh_new_guarded(flush_queued_data_bh, port, + &dev->mem_reentrancy_guard); port->elem =3D NULL; } =20 diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 80ce1e9a93..f1c0eb7dfc 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2201,11 +2201,14 @@ static void qxl_realize_common(PCIQXLDevice *qxl, E= rror **errp) =20 qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl); =20 - qxl->update_irq =3D qemu_bh_new(qxl_update_irq_bh, qxl); + qxl->update_irq =3D qemu_bh_new_guarded(qxl_update_irq_bh, qxl, + &DEVICE(qxl)->mem_reentrancy_gua= rd); qxl_reset_state(qxl); =20 - qxl->update_area_bh =3D qemu_bh_new(qxl_render_update_area_bh, qxl); - qxl->ssd.cursor_bh =3D qemu_bh_new(qemu_spice_cursor_refresh_bh, &qxl-= >ssd); + qxl->update_area_bh =3D qemu_bh_new_guarded(qxl_render_update_area_bh,= qxl, + &DEVICE(qxl)->mem_reentrancy= _guard); + qxl->ssd.cursor_bh =3D qemu_bh_new_guarded(qemu_spice_cursor_refresh_b= h, &qxl->ssd, + &DEVICE(qxl)->mem_reentrancy_= guard); } =20 static void qxl_realize_primary(PCIDevice *dev, Error **errp) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5e15c79b94..66ac9b6cc5 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1339,8 +1339,10 @@ void virtio_gpu_device_realize(DeviceState *qdev, Er= ror **errp) =20 g->ctrl_vq =3D virtio_get_queue(vdev, 0); g->cursor_vq =3D virtio_get_queue(vdev, 1); - g->ctrl_bh =3D qemu_bh_new(virtio_gpu_ctrl_bh, g); - g->cursor_bh =3D qemu_bh_new(virtio_gpu_cursor_bh, g); + g->ctrl_bh =3D qemu_bh_new_guarded(virtio_gpu_ctrl_bh, g, + &qdev->mem_reentrancy_guard); + g->cursor_bh =3D qemu_bh_new_guarded(virtio_gpu_cursor_bh, g, + &qdev->mem_reentrancy_guard); QTAILQ_INIT(&g->reslist); QTAILQ_INIT(&g->cmdq); QTAILQ_INIT(&g->fenceq); diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 55902e1df7..4e76d6b191 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1509,7 +1509,8 @@ static void ahci_cmd_done(const IDEDMA *dma) ahci_write_fis_d2h(ad); =20 if (ad->port_regs.cmd_issue && !ad->check_bh) { - ad->check_bh =3D qemu_bh_new(ahci_check_cmd_bh, ad); + ad->check_bh =3D qemu_bh_new_guarded(ahci_check_cmd_bh, ad, + &ad->mem_reentrancy_guard); qemu_bh_schedule(ad->check_bh); } } diff --git a/hw/ide/core.c b/hw/ide/core.c index 45d14a25e9..de48ff9f86 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -513,6 +513,7 @@ BlockAIOCB *ide_issue_trim( BlockCompletionFunc *cb, void *cb_opaque, void *opaque) { IDEState *s =3D opaque; + IDEDevice *dev =3D s->unit ? s->bus->slave : s->bus->master; TrimAIOCB *iocb; =20 /* Paired with a decrement in ide_trim_bh_cb() */ @@ -520,7 +521,8 @@ BlockAIOCB *ide_issue_trim( =20 iocb =3D blk_aio_get(&trim_aiocb_info, s->blk, cb, cb_opaque); iocb->s =3D s; - iocb->bh =3D qemu_bh_new(ide_trim_bh_cb, iocb); + iocb->bh =3D qemu_bh_new_guarded(ide_trim_bh_cb, iocb, + &DEVICE(dev)->mem_reentrancy_guard); iocb->ret =3D 0; iocb->qiov =3D qiov; iocb->i =3D -1; diff --git a/hw/misc/imx_rngc.c b/hw/misc/imx_rngc.c index 632c03779c..082c6980ad 100644 --- a/hw/misc/imx_rngc.c +++ b/hw/misc/imx_rngc.c @@ -228,8 +228,10 @@ static void imx_rngc_realize(DeviceState *dev, Error *= *errp) sysbus_init_mmio(sbd, &s->iomem); =20 sysbus_init_irq(sbd, &s->irq); - s->self_test_bh =3D qemu_bh_new(imx_rngc_self_test, s); - s->seed_bh =3D qemu_bh_new(imx_rngc_seed, s); + s->self_test_bh =3D qemu_bh_new_guarded(imx_rngc_self_test, s, + &dev->mem_reentrancy_guard); + s->seed_bh =3D qemu_bh_new_guarded(imx_rngc_seed, s, + &dev->mem_reentrancy_guard); } =20 static void imx_rngc_reset(DeviceState *dev) diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c index 43bb1f56ba..80a789f32b 100644 --- a/hw/misc/macio/mac_dbdma.c +++ b/hw/misc/macio/mac_dbdma.c @@ -914,7 +914,7 @@ static void mac_dbdma_realize(DeviceState *dev, Error *= *errp) { DBDMAState *s =3D MAC_DBDMA(dev); =20 - s->bh =3D qemu_bh_new(DBDMA_run_bh, s); + s->bh =3D qemu_bh_new_guarded(DBDMA_run_bh, s, &dev->mem_reentrancy_gu= ard); } =20 static void mac_dbdma_class_init(ObjectClass *oc, void *data) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 53e1c32643..447f669921 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2917,7 +2917,8 @@ static void virtio_net_add_queue(VirtIONet *n, int in= dex) n->vqs[index].tx_vq =3D virtio_add_queue(vdev, n->net_conf.tx_queue_size, virtio_net_handle_tx_bh); - n->vqs[index].tx_bh =3D qemu_bh_new(virtio_net_tx_bh, &n->vqs[inde= x]); + n->vqs[index].tx_bh =3D qemu_bh_new_guarded(virtio_net_tx_bh, &n->= vqs[index], + &DEVICE(vdev)->mem_reent= rancy_guard); } =20 n->vqs[index].tx_waiting =3D 0; diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f59dfe1cbe..fd917fcda1 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4607,7 +4607,8 @@ static void nvme_init_sq(NvmeSQueue *sq, NvmeCtrl *n,= uint64_t dma_addr, QTAILQ_INSERT_TAIL(&(sq->req_list), &sq->io_req[i], entry); } =20 - sq->bh =3D qemu_bh_new(nvme_process_sq, sq); + sq->bh =3D qemu_bh_new_guarded(nvme_process_sq, sq, + &DEVICE(sq->ctrl)->mem_reentrancy_guard); =20 if (n->dbbuf_enabled) { sq->db_addr =3D n->dbbuf_dbs + (sqid << 3); @@ -5253,7 +5254,8 @@ static void nvme_init_cq(NvmeCQueue *cq, NvmeCtrl *n,= uint64_t dma_addr, } } n->cq[cqid] =3D cq; - cq->bh =3D qemu_bh_new(nvme_post_cqes, cq); + cq->bh =3D qemu_bh_new_guarded(nvme_post_cqes, cq, + &DEVICE(cq->ctrl)->mem_reentrancy_guard); } =20 static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeRequest *req) diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c index c485da792c..3de288b454 100644 --- a/hw/scsi/mptsas.c +++ b/hw/scsi/mptsas.c @@ -1322,7 +1322,8 @@ static void mptsas_scsi_realize(PCIDevice *dev, Error= **errp) } s->max_devices =3D MPTSAS_NUM_PORTS; =20 - s->request_bh =3D qemu_bh_new(mptsas_fetch_requests, s); + s->request_bh =3D qemu_bh_new_guarded(mptsas_fetch_requests, s, + &DEVICE(dev)->mem_reentrancy_guard= ); =20 scsi_bus_init(&s->bus, sizeof(s->bus), &dev->qdev, &mptsas_scsi_info); } diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index c97176110c..3c20b47ad0 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -193,7 +193,8 @@ static void scsi_dma_restart_cb(void *opaque, bool runn= ing, RunState state) AioContext *ctx =3D blk_get_aio_context(s->conf.blk); /* The reference is dropped in scsi_dma_restart_bh.*/ object_ref(OBJECT(s)); - s->bh =3D aio_bh_new(ctx, scsi_dma_restart_bh, s); + s->bh =3D aio_bh_new_guarded(ctx, scsi_dma_restart_bh, s, + &DEVICE(s)->mem_reentrancy_guard); qemu_bh_schedule(s->bh); } } diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index fa76696855..4de34536e9 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -1184,7 +1184,8 @@ pvscsi_realizefn(PCIDevice *pci_dev, Error **errp) pcie_endpoint_cap_init(pci_dev, PVSCSI_EXP_EP_OFFSET); } =20 - s->completion_worker =3D qemu_bh_new(pvscsi_process_completion_queue, = s); + s->completion_worker =3D qemu_bh_new_guarded(pvscsi_process_completion= _queue, s, + &DEVICE(pci_dev)->mem_reent= rancy_guard); =20 scsi_bus_init(&s->bus, sizeof(s->bus), DEVICE(pci_dev), &pvscsi_scsi_i= nfo); /* override default SCSI bus hotplug-handler, with pvscsi's one */ diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index 88f99c05d5..f013ded91e 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -937,7 +937,8 @@ static void usb_uas_realize(USBDevice *dev, Error **err= p) =20 QTAILQ_INIT(&uas->results); QTAILQ_INIT(&uas->requests); - uas->status_bh =3D qemu_bh_new(usb_uas_send_status_bh, uas); + uas->status_bh =3D qemu_bh_new_guarded(usb_uas_send_status_bh, uas, + &d->mem_reentrancy_guard); =20 dev->flags |=3D (1 << USB_DEV_FLAG_IS_SCSI_STORAGE); scsi_bus_init(&uas->bus, sizeof(uas->bus), DEVICE(dev), &usb_uas_scsi_= info); diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c index 8755e9cbb0..a0c4e782b2 100644 --- a/hw/usb/hcd-dwc2.c +++ b/hw/usb/hcd-dwc2.c @@ -1364,7 +1364,8 @@ static void dwc2_realize(DeviceState *dev, Error **er= rp) s->fi =3D USB_FRMINTVL - 1; s->eof_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_frame_boundary,= s); s->frame_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_work_timer, s= ); - s->async_bh =3D qemu_bh_new(dwc2_work_bh, s); + s->async_bh =3D qemu_bh_new_guarded(dwc2_work_bh, s, + &dev->mem_reentrancy_guard); =20 sysbus_init_irq(sbd, &s->irq); } diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index d4da8dcb8d..c930c60921 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2533,7 +2533,8 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev,= Error **errp) } =20 s->frame_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, ehci_work_timer, s= ); - s->async_bh =3D qemu_bh_new(ehci_work_bh, s); + s->async_bh =3D qemu_bh_new_guarded(ehci_work_bh, s, + &dev->mem_reentrancy_guard); s->device =3D dev; =20 s->vmstate =3D qemu_add_vm_change_state_handler(usb_ehci_vm_state_chan= ge, s); diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 8ac1175ad2..77baaa7a6b 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -1190,7 +1190,7 @@ void usb_uhci_common_realize(PCIDevice *dev, Error **= errp) USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); } } - s->bh =3D qemu_bh_new(uhci_bh, s); + s->bh =3D qemu_bh_new_guarded(uhci_bh, s, &DEVICE(dev)->mem_reentrancy= _guard); s->frame_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, uhci_frame_timer, = s); s->num_ports_vmstate =3D NB_PORTS; QTAILQ_INIT(&s->queues); diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 176868d345..f500db85ab 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1141,7 +1141,8 @@ static void usb_host_nodev_bh(void *opaque) static void usb_host_nodev(USBHostDevice *s) { if (!s->bh_nodev) { - s->bh_nodev =3D qemu_bh_new(usb_host_nodev_bh, s); + s->bh_nodev =3D qemu_bh_new_guarded(usb_host_nodev_bh, s, + &DEVICE(s)->mem_reentrancy_guard= ); } qemu_bh_schedule(s->bh_nodev); } @@ -1739,7 +1740,8 @@ static int usb_host_post_load(void *opaque, int versi= on_id) USBHostDevice *dev =3D opaque; =20 if (!dev->bh_postld) { - dev->bh_postld =3D qemu_bh_new(usb_host_post_load_bh, dev); + dev->bh_postld =3D qemu_bh_new_guarded(usb_host_post_load_bh, dev, + &DEVICE(dev)->mem_reentrancy_= guard); } qemu_bh_schedule(dev->bh_postld); dev->bh_postld_pending =3D true; diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index fd7df599bc..39fbaaab16 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1441,8 +1441,10 @@ static void usbredir_realize(USBDevice *udev, Error = **errp) } } =20 - dev->chardev_close_bh =3D qemu_bh_new(usbredir_chardev_close_bh, dev); - dev->device_reject_bh =3D qemu_bh_new(usbredir_device_reject_bh, dev); + dev->chardev_close_bh =3D qemu_bh_new_guarded(usbredir_chardev_close_b= h, dev, + &DEVICE(dev)->mem_reentran= cy_guard); + dev->device_reject_bh =3D qemu_bh_new_guarded(usbredir_device_reject_b= h, dev, + &DEVICE(dev)->mem_reentran= cy_guard); dev->attach_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, usbredir_do_att= ach, dev); =20 packet_id_queue_init(&dev->cancelled, dev, "cancelled"); diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c index 66cb3f7c24..38ee660a30 100644 --- a/hw/usb/xen-usb.c +++ b/hw/usb/xen-usb.c @@ -1032,7 +1032,8 @@ static void usbback_alloc(struct XenLegacyDevice *xen= dev) =20 QTAILQ_INIT(&usbif->req_free_q); QSIMPLEQ_INIT(&usbif->hotplug_q); - usbif->bh =3D qemu_bh_new(usbback_bh, usbif); + usbif->bh =3D qemu_bh_new_guarded(usbback_bh, usbif, + &DEVICE(xendev)->mem_reentrancy_guard); } =20 static int usbback_free(struct XenLegacyDevice *xendev) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index fd06fcfb3f..d004cf29d2 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -886,8 +886,9 @@ static void virtio_balloon_device_realize(DeviceState *= dev, Error **errp) precopy_add_notifier(&s->free_page_hint_notify); =20 object_ref(OBJECT(s->iothread)); - s->free_page_bh =3D aio_bh_new(iothread_get_aio_context(s->iothrea= d), - virtio_ballloon_get_free_page_hints, = s); + s->free_page_bh =3D aio_bh_new_guarded(iothread_get_aio_context(s-= >iothread), + virtio_ballloon_get_free_page= _hints, s, + &dev->mem_reentrancy_guard); } =20 if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_REPORTING)) { diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 802e1b9659..2fe804510f 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1074,7 +1074,8 @@ static void virtio_crypto_device_realize(DeviceState = *dev, Error **errp) vcrypto->vqs[i].dataq =3D virtio_add_queue(vdev, 1024, virtio_crypto_handle_dataq_b= h); vcrypto->vqs[i].dataq_bh =3D - qemu_bh_new(virtio_crypto_dataq_bh, &vcrypto->vqs[i]); + qemu_bh_new_guarded(virtio_crypto_dataq_bh, &vcrypto->vqs= [i], + &dev->mem_reentrancy_guard); vcrypto->vqs[i].vcrypto =3D vcrypto; } =20 --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675192; cv=none; d=zohomail.com; s=zohoarc; b=Mepxp/IcH7eOvNQqTdAqDplMB5Jo5lonUN3XWvoI4kJcbN9zE9zaeUp8Iim0GTe5od9SiZYmMLOtcMV5GGwKOX5j5Lm/63m2FV055iHU3IKQdlirJIvgbLHMbZiujXpcYWDavPRXJnkRuXqypOIC63cfybL4C27h8TWgP5ceO20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675192; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yX47Kf3s97RcELPUzLROVGmeEF0jq/IGw6qkUYrWSGs=; b=cy6FyXsBaQ/qFOTPSK8HvTJFEvgfTAke3uqFeTe0fBviJVG/hjr7wtDQ8Bbc1aEGa6cKccz8e7Xmw0AN8kUmJFsv9zBFzHg2pzCPQCfxizh8BRkEqhGsh9LuUS2wo/unWlhWUytRs9fol5ZVy5sQKwUAbZFO6MBQfJgD2VM+Hvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675192842450.3445978774039; Fri, 28 Apr 2023 02:46:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKeN-0003yo-Ko; Fri, 28 Apr 2023 05:44:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeI-0003is-8A for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeF-0007b5-MQ for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:17 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-299-Osdc_kZyPjirIb5lxcZbWA-1; Fri, 28 Apr 2023 05:44:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8AD56885620; Fri, 28 Apr 2023 09:44:08 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id C52D61410F1E; Fri, 28 Apr 2023 09:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yX47Kf3s97RcELPUzLROVGmeEF0jq/IGw6qkUYrWSGs=; b=IMz+ciPjnoJB3+q9gfW7pRNw9HF99LeblmH7TZ3TQU/uGwoKAx1SV18ouPLDZ5tTe5gYii M66jRTBFkvYgsdyn48BKcLYxl5SdJh9JFr2W9uWtX/2SKg/YoKlSchgLFHZiHARWZXmfvj ++cSxDggc2r0CL6hzfjADWbfF4WWuuM= X-MC-Unique: Osdc_kZyPjirIb5lxcZbWA-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , Fiona Ebner , Darren Kenny Subject: [PULL 10/13] lsi53c895a: disable reentrancy detection for script RAM Date: Fri, 28 Apr 2023 11:43:43 +0200 Message-Id: <20230428094346.1292054-11-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675193730100001 Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov As the code is designed to use the memory APIs to access the script ram, disable reentrancy checks for the pseudo-RAM ram_io MemoryRegion. In the future, ram_io may be converted from an IO to a proper RAM MemoryReg= ion. Reported-by: Fiona Ebner Signed-off-by: Alexander Bulekov Reviewed-by: Thomas Huth Reviewed-by: Darren Kenny Message-Id: <20230427211013.2994127-6-alxndr@bu.edu> Signed-off-by: Thomas Huth --- hw/scsi/lsi53c895a.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index af93557a9a..db27872963 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -2302,6 +2302,12 @@ static void lsi_scsi_realize(PCIDevice *dev, Error *= *errp) memory_region_init_io(&s->io_io, OBJECT(s), &lsi_io_ops, s, "lsi-io", 256); =20 + /* + * Since we use the address-space API to interact with ram_io, disable= the + * re-entrancy guard. + */ + s->ram_io.disable_reentrancy_guard =3D true; + address_space_init(&s->pci_io_as, pci_address_space_io(dev), "lsi-pci-= io"); qdev_init_gpio_out(d, &s->ext_irq, 1); =20 --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675170; cv=none; d=zohomail.com; s=zohoarc; b=XVLP6tp7NWTcXw46JhaediGMjRbonCKLzvEZEjFQlDcs93FLSg6qCgPS0s50823oQ7Pa3IHjb13iibVshR1C/HMYMezt+AvgMlgcn2OywzbEweeQWD3nodYF2p0ZZbgnSs2RrPuAjihNNSkJf3F4MTB4X71p/xjKfwSIK/qO2JY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675170; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FbPjeDO6vsYu84ovSpLwdv+hX/+uCLtMSABu1oR4v8I=; b=bT7vbcioDuwnQl+BwywNnIzkyAExqKVtRDLGNFLxFaFM+d8DWlvL15LquKT09z3pZALg3N1SdPv1vcmPD9wKVYcCVfBQO1mVP9H584NlX1inEQUK8H3wBqFvtLtIYA7z+McNovAgZJ0IUKT8O42bSXzOOdv/nct8L6ahPpfSNZY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675170216303.2756995046651; Fri, 28 Apr 2023 02:46:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKeO-00043E-Dw; Fri, 28 Apr 2023 05:44:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeH-0003jH-Sh for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeG-0007bD-DJ for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:17 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-77-zf8oAUsvMqWmvVi44j93dA-1; Fri, 28 Apr 2023 05:44:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B7CE818E0921; Fri, 28 Apr 2023 09:44:09 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id F38281410F1E; Fri, 28 Apr 2023 09:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675055; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FbPjeDO6vsYu84ovSpLwdv+hX/+uCLtMSABu1oR4v8I=; b=B0fdjmTlE5vXnpPF6P5lC8fhcDnRzOTyF3wGtCPV/2fEgoSFLApHEtGXGXVgfApcFQOxzR Lde6JirffY7MMeqNmbIhIPKXamKsAuqZRQ/MlPf25eaA2EkK2FL4Ft5Zw0qv+RBZXarNcC VT7AYV6/fK/9zUJktwDRsJVfanBabSw= X-MC-Unique: zf8oAUsvMqWmvVi44j93dA-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov Subject: [PULL 11/13] bcm2835_property: disable reentrancy detection for iomem Date: Fri, 28 Apr 2023 11:43:44 +0200 Message-Id: <20230428094346.1292054-12-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675171592100003 Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov As the code is designed for re-entrant calls from bcm2835_property to bcm2835_mbox and back into bcm2835_property, mark iomem as reentrancy-safe. Signed-off-by: Alexander Bulekov Reviewed-by: Thomas Huth Message-Id: <20230427211013.2994127-7-alxndr@bu.edu> Signed-off-by: Thomas Huth --- hw/misc/bcm2835_property.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c index 890ae7bae5..de056ea2df 100644 --- a/hw/misc/bcm2835_property.c +++ b/hw/misc/bcm2835_property.c @@ -382,6 +382,13 @@ static void bcm2835_property_init(Object *obj) =20 memory_region_init_io(&s->iomem, OBJECT(s), &bcm2835_property_ops, s, TYPE_BCM2835_PROPERTY, 0x10); + + /* + * bcm2835_property_ops call into bcm2835_mbox, which in-turn reads fr= om + * iomem. As such, mark iomem as re-entracy safe. + */ + s->iomem.disable_reentrancy_guard =3D true; + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); sysbus_init_irq(SYS_BUS_DEVICE(s), &s->mbox_irq); } --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675184; cv=none; d=zohomail.com; s=zohoarc; b=HOb8ai4r/1zM4/PeNm64m6zjx65kVdKFFS1AuIRba1EwS993aXOujcLvbKeEfd/BrqreJHs0STSvN0fkMf99lLLBhkFf5moAE1/KLSL+ojurocAvvMYcKgfBmOXRuuFWyfQw9R7qWbbEkvekAquGksjR+hgOsshw4AS/wiIqHc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675184; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D1QbZqFwlfjUvJkqidyl0uI2ij2XfXvL/SUhnRwssbI=; b=b0mc/+dRspYwltKe2ZEAq/UN0bHfET6zsAZDBOh8j/FacDRVJ4MNCxvLXmZoPX6TLkkqYf03yRmNRiXJlEAbinH4qBYNXRyQx4U/89vnpkJUvsKeUZRX0qqmRCXndtjAyRWHi4ch90QBq51fGAwVM/NffP8w2T+tOBIBiyml0XE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675184643228.95419999684418; Fri, 28 Apr 2023 02:46:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKeN-0003vT-3n; Fri, 28 Apr 2023 05:44:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeG-0003h8-3X for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeE-0007b0-Nz for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:15 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-249-okYBEW-lOiGuZmTMAuD4Lg-1; Fri, 28 Apr 2023 05:44:11 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 601B485A5B1; Fri, 28 Apr 2023 09:44:11 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32B9D1410F1C; Fri, 28 Apr 2023 09:44:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D1QbZqFwlfjUvJkqidyl0uI2ij2XfXvL/SUhnRwssbI=; b=EtkNhCK3yehZF0qfxw7UtYCcRMaut0gTzL/z9v//K9qrOCsfLb1e3lvSIfisoeMaj80tl8 2ayB/ZYtOt4XSxeqOSMllPzzr68boPPMGHnmx3AXg2/tk/Vv7H5vfe4hVBvTA3qKJOiwXB fCsa1j5SsMenyooHH7L3gIRh4pNCW6Q= X-MC-Unique: okYBEW-lOiGuZmTMAuD4Lg-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov Subject: [PULL 12/13] raven: disable reentrancy detection for iomem Date: Fri, 28 Apr 2023 11:43:45 +0200 Message-Id: <20230428094346.1292054-13-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675185143100001 Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov As the code is designed for re-entrant calls from raven_io_ops to pci-conf, mark raven_io_ops as reentrancy-safe. Signed-off-by: Alexander Bulekov Message-Id: <20230427211013.2994127-8-alxndr@bu.edu> Signed-off-by: Thomas Huth --- hw/pci-host/raven.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c index 072ffe3c5e..9a11ac4b2b 100644 --- a/hw/pci-host/raven.c +++ b/hw/pci-host/raven.c @@ -294,6 +294,13 @@ static void raven_pcihost_initfn(Object *obj) memory_region_init(&s->pci_memory, obj, "pci-memory", 0x3f000000); address_space_init(&s->pci_io_as, &s->pci_io, "raven-io"); =20 + /* + * Raven's raven_io_ops use the address-space API to access pci-conf-i= dx + * (which is also owned by the raven device). As such, mark the + * pci_io_non_contiguous as re-entrancy safe. + */ + s->pci_io_non_contiguous.disable_reentrancy_guard =3D true; + /* CPU address space */ memory_region_add_subregion(address_space_mem, PCI_IO_BASE_ADDR, &s->pci_io); --=20 2.31.1 From nobody Wed May 15 00:02:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1682675154; cv=none; d=zohomail.com; s=zohoarc; b=e7CbxTd6SgYyxWHq4DUr9uhLzxrrmdVMsACDAIGVP9hCgnuZricA/WHlZsw5WygEOMyyHnKVJYze7NihjVS0UxQ3NjSJn9f7t+o1HMysRSjsQ4CXdlKu01dsjTs0QK0s8e/AG3Uo1loPdeRNLVA6DXeuhO9Bvfe/DmtXBNQMHk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682675154; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wGUIZEXyqc9DsRVKuagHrvkSytTZjdsLflbLid1tWsA=; b=d1jvttifp6cWg1SvnV9UMGHSaGBY8nK0C39FHyWUt9ALDQOKA4TDk/RXWn2SPC7YexhpYv1lMjc0xRwaSWIpRuh2VUpjS+6qFvCCiVzO9hDYP6E5idS75XadJIyz/dgzYi4xHKCFPrWzhpIIoGtT/xCyfk+xtPgayUe1iAACgmY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682675154508441.7072030944537; Fri, 28 Apr 2023 02:45:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psKeM-0003q5-4i; Fri, 28 Apr 2023 05:44:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeJ-0003nV-FW for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psKeI-0007bV-0C for qemu-devel@nongnu.org; Fri, 28 Apr 2023 05:44:19 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-kFOCYMz3ObuVmulVq5AokA-1; Fri, 28 Apr 2023 05:44:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5F73C10504A4; Fri, 28 Apr 2023 09:44:13 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBED01410F1C; Fri, 28 Apr 2023 09:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682675057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wGUIZEXyqc9DsRVKuagHrvkSytTZjdsLflbLid1tWsA=; b=AUZYpZ4uL0Cvgx1yqXMLLhpNuzng9FewRCL+7eE5GWTfe0JAnV0jNoymK0TFDetQQXaTxU M0UPEAfmFpe/Bw+4NP7Az0ZZ6aBDzC5Z6JgTd4RUOGN88ANqYOLqz3X050Nnh7+9ljG+lb SjnWcWwV/Wk828k28sfzvaUHYVmeMsY= X-MC-Unique: kFOCYMz3ObuVmulVq5AokA-1 From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Cc: Alexander Bulekov , Darren Kenny Subject: [PULL 13/13] apic: disable reentrancy detection for apic-msi Date: Fri, 28 Apr 2023 11:43:46 +0200 Message-Id: <20230428094346.1292054-14-thuth@redhat.com> In-Reply-To: <20230428094346.1292054-1-thuth@redhat.com> References: <20230428094346.1292054-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1682675155395100001 Content-Type: text/plain; charset="utf-8" From: Alexander Bulekov As the code is designed for re-entrant calls to apic-msi, mark apic-msi as reentrancy-safe. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Message-Id: <20230427211013.2994127-9-alxndr@bu.edu> Signed-off-by: Thomas Huth --- hw/intc/apic.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 20b5a94073..ac3d47d231 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -885,6 +885,13 @@ static void apic_realize(DeviceState *dev, Error **err= p) memory_region_init_io(&s->io_memory, OBJECT(s), &apic_io_ops, s, "apic= -msi", APIC_SPACE_SIZE); =20 + /* + * apic-msi's apic_mem_write can call into ioapic_eoi_broadcast, which= can + * write back to apic-msi. As such mark the apic-msi region re-entrancy + * safe. + */ + s->io_memory.disable_reentrancy_guard =3D true; + s->timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, apic_timer, s); local_apics[s->id] =3D s; =20 --=20 2.31.1