From nobody Sat May 18 19:12:49 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=yadro.com ARC-Seal: i=1; a=rsa-sha256; t=1676647463; cv=none; d=zohomail.com; s=zohoarc; b=RutVn1EawEIJRmWtNR6W0xlrJNXIuoSNB5VDWuBkNkfqOwS/bBfIt9iDtfDPYcfikYpBGkWUtdvQHA1Kq4qSp4wgHJFC8U3ljXBxPx3v8CagyL8LgLPmauWW+3kQK2owUD2K+zZErum4NJLKSKWWAG7MOSsDj+NF1a9f/UBA8Kg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676647463; 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=CscEokhDmmflwLi8d1GLOZ99qZk24c2AWA/MJ3s8o9Q=; b=J+u7qJph68bLDbQ0jqXFGvZCZ4XzpPTpVLgFi3yYMyFOLdgK0PXpHaKmgF+/oa3PQam7pKJVLT0jlH3PZWwmmi6MVPXM3xNXN8u6b0Y90k6hdFrsAq+rgi2ftk+QXxUEG/BHF0FkhYkZV3r+c2nulJxwNsJx5qosF0gCkbkbPQo= 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 1676647463567421.9173525041531; Fri, 17 Feb 2023 07:24:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pT2aE-0000HD-Oj; Fri, 17 Feb 2023 10:23:34 -0500 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 1pT2aD-0000Gx-Ck for qemu-devel@nongnu.org; Fri, 17 Feb 2023 10:23:33 -0500 Received: from mta-02.yadro.com ([89.207.88.252] helo=mta-01.yadro.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pT2aB-0005VM-3P for qemu-devel@nongnu.org; Fri, 17 Feb 2023 10:23:33 -0500 Received: from mta-01.yadro.com (localhost.localdomain [127.0.0.1]) by mta-01.yadro.com (Proxmox) with ESMTP id 54956341E6A; Fri, 17 Feb 2023 18:23:26 +0300 (MSK) Received: from T-EXCH-07.corp.yadro.com (unknown [172.17.10.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Proxmox) with ESMTPS id 4A3E9341DA5; Fri, 17 Feb 2023 18:23:26 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-07.corp.yadro.com (172.17.11.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 17 Feb 2023 18:23:26 +0300 Received: from T-EXCH-08.corp.yadro.com (172.17.11.58) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.9; Fri, 17 Feb 2023 18:23:25 +0300 Received: from T-EXCH-08.corp.yadro.com ([172.17.11.58]) by T-EXCH-08.corp.yadro.com ([172.17.11.58]) with mapi id 15.02.1118.009; Fri, 17 Feb 2023 18:23:25 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yadro.com; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mta-01; bh=CscEokhDmmflwLi8d1 GLOZ99qZk24c2AWA/MJ3s8o9Q=; b=n+cEEfC/mVb9JJK7um2KVSSVn2gS3PP+yt beuOifBJPkcFRwIx3d+K6NG09Dqv8yl1mOj7v4EWDG/TibL1DIyfeT0PRo7GK+Ji mz0TPwiaxETTfCjyhQLj09tzpYtLKJWEMPw+azwEqLdrIwfNu2IPKpe8rsTru9XV OZC9W+uxg= From: Mikhail Tyutin To: "qemu-devel@nongnu.org" CC: "alex.bennee@linaro.org" , Richard Henderson Subject: RE: TCG asserts on some of translation blocks with plugin memory callback Thread-Topic: TCG asserts on some of translation blocks with plugin memory callback Thread-Index: AQHZQpCQZUyYKKfKzUKg+ugTeuoVKK7TQNjw Date: Fri, 17 Feb 2023 15:23:25 +0000 Message-ID: <697e7edb1f554fb789082fe8943ead7b@yadro.com> References: <13fc40e4-2637-02bc-5f83-4fb9f04cd730@yadro.com> In-Reply-To: <13fc40e4-2637-02bc-5f83-4fb9f04cd730@yadro.com> Accept-Language: en-US Content-Language: ru-RU X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.178.120.230] Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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=89.207.88.252; envelope-from=m.tyutin@yadro.com; helo=mta-01.yadro.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @yadro.com) X-ZM-MESSAGEID: 1676647465417100001 > I have been testing TCG plugin patch on latest Qemu build but noticed tha= t it > fails with assert on some of the applications. >=20 > ERROR:../accel/tcg/cpu-exec.c:983:cpu_exec_loop: > assertion failed: (cpu->plugin_mem_cbs =3D=3D ((void *)0)) >=20 It seems that the problem is around tcg_ctx->plugin_tb->mem_helper flag. It= is set to true by inject_mem_enable_helper() if plugin requests memory callbacks injection= and checked by inject_mem_disable_helper() to insert appropriate cleanup code at the en= d. It works if translation block has single exit point. However if translation block has b= ranches or exits, inject_mem_disable_helper() is called during code generation prepending all= tb exits. Unfortunately it happens before inject_mem_enable_helper() initializes mem_= helper flag for that block. I=E2=80=99ve tried quick fix by commenting out this check in inject_mem_dis= able_helper() so that clean up code is inserted unconditionally on every exit. The assert is gone. What would be a better way to fix it? diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 17a686bd9e..6651874c0f 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -637,9 +637,9 @@ void plugin_gen_disable_mem_helpers(void) * Note: we do not reset plugin_tb->mem_helper here; a TB might have s= everal * exit points, and we want to emit the clearing from all of them. */ - if (!tcg_ctx->plugin_tb->mem_helper) { - return; - } + // if (!tcg_ctx->plugin_tb->mem_helper) { + // return; + // } ptr =3D tcg_const_ptr(NULL); tcg_gen_st_ptr(ptr, cpu_env, offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, env));