From patchwork Fri Oct 28 07:21:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Icenowy Zheng X-Patchwork-Id: 1695851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=icenowy.me header.i=uwu@icenowy.me header.a=rsa-sha256 header.s=zmail header.b=KHrhHT7F; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MzDbK3XfMz20S2 for ; Fri, 28 Oct 2022 18:25:17 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooJii-0006b0-W5; Fri, 28 Oct 2022 03:24:01 -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 1ooJih-0006ah-66 for qemu-devel@nongnu.org; Fri, 28 Oct 2022 03:23:59 -0400 Received: from sender4-op-o18.zoho.com ([136.143.188.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooJif-0002kk-JB for qemu-devel@nongnu.org; Fri, 28 Oct 2022 03:23:58 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1666941829; cv=none; d=zohomail.com; s=zohoarc; b=H2MQEfGfqwqqVJRAy/eQjb6AOPoIIa4dAsExvib+DPfbHXMTyqn3ex9dtSSf1npA48t1zo8aVCNK0WlXcZ5Y150olWwGo0S1fCYM1aBoK3f5dgWu6AD5hTsZNxBiCF3/JI/xAhpoNSxXI0WEASwWApZAMVra8iEnNmUzv5toZg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666941829; h=Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=NQuh7zi2wtasmtboF4R4qO1RB0L1rHeApw73kba+H2k=; b=adiV6Rw3MXFoEcDafdRf2lYcdQ5EIFm93v2OdPsjv8H9je1N68LDD2yXFmGULZ07Z6M0U2NWmMMRa6xu+M0LLLoelgW5EQNDSv72padGswbsm6GL/TMdhuzM9XvJU4GTzz+Sa3wZK7r/o5qts2izyUGDwhoei/Kr2niO/8dAjb0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=icenowy.me; spf=pass smtp.mailfrom=uwu@icenowy.me; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1666941829; s=zmail; d=icenowy.me; i=uwu@icenowy.me; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=NQuh7zi2wtasmtboF4R4qO1RB0L1rHeApw73kba+H2k=; b=KHrhHT7FpwrCiqxQNrGhqmIYZgUxv3d7D4VPfAc6QzH6lczLMVzF6sz9IeJ8F4vQ zVXBpFXT+X/G0VwNxyZcvHNAbwu7cQla3fT1R6Bc4/RzJWfkCP86gn7h1Q2rzj8gNvc 6jT/SvdWWYG+A3PUaKJKDpWKhDsUSjYu6wHmviOs= Received: from edelgard.fodlan.icenowy.me (112.94.102.53 [112.94.102.53]) by mx.zohomail.com with SMTPS id 1666941828587360.22039856339995; Fri, 28 Oct 2022 00:23:48 -0700 (PDT) From: Icenowy Zheng To: Richard Henderson Cc: qemu-devel@nongnu.org, Icenowy Zheng Subject: [PATCH] tcg/tci: fix logic error when registering helpers via FFI Date: Fri, 28 Oct 2022 15:21:45 +0800 Message-Id: <20221028072145.1593205-1-uwu@icenowy.me> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.18; envelope-from=uwu@icenowy.me; helo=sender4-op-o18.zoho.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, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When registering helpers via FFI for TCI, the inner loop that iterates parameters of the helper reuses (and thus pollutes) the same variable used by the outer loop that iterates all helpers, thus made some helpers unregistered. Fix this logic error by using a dedicated temporary variable for the inner loop. Signed-off-by: Icenowy Zheng Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- tcg/tcg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 612a12f58f..adfaf61a32 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -619,6 +619,7 @@ static void tcg_context_init(unsigned max_cpus) gpointer hash = (gpointer)(uintptr_t)typemask; ffi_status status; int nargs; + int j; if (g_hash_table_lookup(ffi_table, hash)) { continue; @@ -634,9 +635,9 @@ static void tcg_context_init(unsigned max_cpus) if (nargs != 0) { ca->cif.arg_types = ca->args; - for (i = 0; i < nargs; ++i) { - int typecode = extract32(typemask, (i + 1) * 3, 3); - ca->args[i] = typecode_to_ffi[typecode]; + for (j = 0; j < nargs; ++j) { + int typecode = extract32(typemask, (j + 1) * 3, 3); + ca->args[j] = typecode_to_ffi[typecode]; } }