From patchwork Wed Jan 22 09:30:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947040 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19CB5C02182 for ; Wed, 22 Jan 2025 09:33:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4W-0001G4-UL; Wed, 22 Jan 2025 04:30:53 -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 1taX4I-00019J-TC for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:39 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4H-0003Bq-7J for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:38 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-438a39e659cso26408545e9.2 for ; Wed, 22 Jan 2025 01:30:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538235; x=1738143035; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X8ArVsKGybNKtSkR5dolq6Oiydwa+G4DFnUDdzS7HsU=; b=JDaTQ5gB7zu127QoD7xTJ6JHG036EPsyOX36sdO29l6qgiIm1oKGAggNVAL9XihkAM ttQVoBbxKwbFPom/mqLeeWoz8MwnPTEGeuU3qHyXCg8HWSA6oezs4eGmYiwedFOSh3+y 9dKJCzoSrxQc3KUyaY64cblPg77FlBRIM96Zy/tBdNuourCWX/jyY1vBDcr3EYwZ6QMg DS0eJuLrGhwXPZ7vqw3nQXRfxHiy4HlztMGJGC02vlOX5hPSrvB2UkLOeD5PsX4j2UmY 4ap3yBZEtnHAvEupfjIHShVbwU3ELrEK/qb3AYW+yGRaI7HJh9STee+Ykpf+Y2Aha4Au 8AUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538235; x=1738143035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X8ArVsKGybNKtSkR5dolq6Oiydwa+G4DFnUDdzS7HsU=; b=WypClf5rmqZbfcpZ+f09N9YVBvWZLIzzJ3+mwV0v/S6tPHgtPvArYy8ZtYGd4GNRRC T9Zi4RwiXiio3OwKrlSVOuFfmxdFjIaZ6Zt8YDUTRT3lwDQ6TIgllS94Q5GI9JjfHUCe GI9tk74H70k8rdKTkoHMzd2TsE7Al83wod2Yq8jF/plI8arUTdkwN0DFqRASs0J0/2bJ NLF2zffZQBTjrNx+OxgQFJkplMRo95ao1995mjogotsZSDCcg8SOrn+UhnDXGh4ip3Zl LM/P2kPFcS21FG2+RGxgiMbWY1j57HvWgav8TBIqUMoV2LV1PCKAotH4OpOF7MilHCxn voxA== X-Gm-Message-State: AOJu0YzYnkweU+pXzHAZ/kny8VxEM3P13jW+rncCBmwkfPF9SxyVibcO /xHJG8gq9e8r8pzAkj8yBsIt+kcK1ouVG2xSXUUjDd8ORonIFIaQ6FeHoTxUzi0jlpZyipfNVee IITk= X-Gm-Gg: ASbGncs+vT07hrWptJhpC7wo4ZBng5PWumAHOkflG7wtWfXbOVB+1BujlVA8z4r3C4w RkMw7nmLdHDKVP6yx5c06FoE3bOVb8hVAN6ZKX6i3W6eqmmgaAgnlPZ35m67fQ0X76VWOoSwsFQ h1vtFib83YRGc2cy1WBbalBx+5676iT3LKSoQBfNjpJa5WsXcGO/JQpdd2WIiRA06TtfXsLqxpK KXBCwBHNpmGiQFxop6VXKGinop5KIedKJ2bdv4qnwiLeyN/4tGurhD0Ri+4MUTgHo+RjZXM4Iuv EEz76uiiHRsr7uINyvUVG5okiaIegcv9FK94RvVZ5IKm X-Google-Smtp-Source: AGHT+IHks2jHi8AyiUO0a8BgVEjQWxhPXHsTRUiMOuiSFnHUZ3kH69HzTsmHxw9Sivrz+GFXR/bERQ== X-Received: by 2002:a05:600c:b8a:b0:434:a386:6ae with SMTP id 5b1f17b1804b1-438913cae53mr199214635e9.7.1737538235272; Wed, 22 Jan 2025 01:30:35 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b31b718fsm17282655e9.28.2025.01.22.01.30.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:30:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 01/10] hw/core/generic-loader: Do not open-code cpu_set_pc() Date: Wed, 22 Jan 2025 10:30:19 +0100 Message-ID: <20250122093028.52416-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Directly call cpu_set_pc() instead of open-coding it. Signed-off-by: Philippe Mathieu-Daudé --- hw/core/generic-loader.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c index fb354693aff..1b9ab600c9c 100644 --- a/hw/core/generic-loader.c +++ b/hw/core/generic-loader.c @@ -48,11 +48,8 @@ static void generic_loader_reset(void *opaque) GenericLoaderState *s = GENERIC_LOADER(opaque); if (s->set_pc) { - CPUClass *cc = CPU_GET_CLASS(s->cpu); cpu_reset(s->cpu); - if (cc) { - cc->set_pc(s->cpu, s->addr); - } + cpu_set_pc(s->cpu, s->addr); } if (s->data_len) { From patchwork Wed Jan 22 09:30:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84F05C02182 for ; Wed, 22 Jan 2025 09:32:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4Z-0001JO-HO; Wed, 22 Jan 2025 04:30:55 -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 1taX4S-0001DO-9d for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:49 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4L-0003Cn-R7 for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:43 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361b0ec57aso68496625e9.0 for ; Wed, 22 Jan 2025 01:30:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538240; x=1738143040; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Exwv2SUshKwTjHy8msyqoapLFQlZN2ZYaumIRAoksx4=; b=B1uWhsUUirJqiJilOepJQOlg7boSiweOkSghn3oQgmW9JtU97oDI1cItnVqnQETQDk I3A76BEv19VAc/qvdzpu3ktDh2psEaXAdfsDB5LgTblxJgQSHmfe2vNs2tOu60v7mV0R gUbs2VppR2m+l7S7XvapLgWCbFlEQRFy5ZV9v5Qd3JxsQzUP8AWcZ4669YUs1YK3VRnO 9yQ98+471ewyNTmFqHf447h+7AkuP63rirubYaHuHMZVbKfeszDCQrNivCbBWx+EukX4 VsFqxi4olRm/zdNQYoIIJeo78NEFVlcg6vhhvMF3aKKCKNAKA+iW1mDcSjqFf08/D7PL z50w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538240; x=1738143040; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Exwv2SUshKwTjHy8msyqoapLFQlZN2ZYaumIRAoksx4=; b=Cn27QaeE2TyF4kPPEWDZ0oT+N/zLI15cOnzH1OD+PNnyRvFS2DDEYDFUTzK4zF3Udd j/lhKPTMVsQNnflPypfMu0yMWS4ysLinLLUojNJdM8eQgp55+IyaP5sAlCz91f2RY8UM vtym9qP4pZNdYvEWh+SO2O8qYi4yblaV6vV18lnrguXUBfYhur6qheiClGwmynXt49mv 3gEebzz6AEnCgOsffdEmIeEUZUO9uVXKOptPEbA699bxcK7yWbe3OixHvCykNpIoctp+ uSE/ta7j8461YjBwfpd3PaKyngTwTSLp7/zAcTtTZ4qrIEJaJtcugvjme6vWH7DMx0OL ilRg== X-Gm-Message-State: AOJu0Yx5+Bs5wPVKRLrrqbUpdhXdA38FUBoAko0mZoT+hkkcaxVpVgJC 3WBZhbdKPdFaH8cTvItt6IAIHV8XZ7lP5JrJOw2MUzYwMp+RkmjHHAw4W1GSu2WavaNNAs7saYf ocZI= X-Gm-Gg: ASbGnct2+b34Ok4VYqbiRkHWYACL1YzoNYh/n5k7bLDVgupW2fCCj6TqFozgcsX2di+ x7/Y9nwtwO4SdtdBvbw+2OUXPftYFywE2Ta87lFcl6xlKYE8LHVPwI0X/87n7HVrM5wmplUBz1c 8jLZ3grN2AYyjJiXJ75mOD8x8QMJJUGQKjRmqBtXcS6B+LcO+9qCCl4EtYiRIX5B0l2+xuEAzwN 2IZklNHfPHBDWEjlB1HG4/srWgqZLRGQdqfYEsbD2psI5kFDy1YN5FOQYqAI4wUxfQ7GedQkhYs nxO1q9xiCrSd7lyc07jz7k3jO4mVzsUqpQebzx58kCYj X-Google-Smtp-Source: AGHT+IEZYV0UXoFjfU+tl1VOkpos+WFwna6iC8gUcKm8PVyAYHRasOGF7v+cm7JbdRsSBECp5+5ksg== X-Received: by 2002:a05:600c:ccc:b0:436:1bbe:f686 with SMTP id 5b1f17b1804b1-4389141c073mr153240065e9.21.1737538239766; Wed, 22 Jan 2025 01:30:39 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b31afb70sm17224715e9.19.2025.01.22.01.30.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:30:39 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 02/10] gdbstub: Clarify no more than @gdb_num_core_regs can be accessed Date: Wed, 22 Jan 2025 10:30:20 +0100 Message-ID: <20250122093028.52416-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Both CPUClass::gdb_read_register() and CPUClass::gdb_write_register() handlers are called from common gdbstub code, and won't be called with register index over CPUClass::gdb_num_core_regs: int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { CPUClass *cc = CPU_GET_CLASS(cpu); if (reg < cc->gdb_num_core_regs) { return cc->gdb_read_register(cpu, buf, reg); } ... } static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) { CPUClass *cc = CPU_GET_CLASS(cpu); if (reg < cc->gdb_num_core_regs) { return cc->gdb_write_register(cpu, mem_buf, reg); } ... } Clarify that in CPUClass docstring, and remove unreachable code on the microblaze and tricore implementations. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- include/hw/core/cpu.h | 2 ++ target/microblaze/gdbstub.c | 5 ----- target/openrisc/gdbstub.c | 5 ----- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index fb397cdfc53..7b6b22c431b 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -124,7 +124,9 @@ struct SysemuCPUOps; * @get_pc: Callback for getting the Program Counter register. * As above, with the semantics of the target architecture. * @gdb_read_register: Callback for letting GDB read a register. + * No more than @gdb_num_core_regs registers can be read. * @gdb_write_register: Callback for letting GDB write a register. + * No more than @gdb_num_core_regs registers can be written. * @gdb_adjust_breakpoint: Callback for adjusting the address of a * breakpoint. Used by AVR to handle a gdb mis-feature with * its Harvard architecture split code and data. diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index 09d74e164d0..d493681d38d 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -110,14 +110,9 @@ int mb_cpu_gdb_read_stack_protect(CPUState *cs, GByteArray *mem_buf, int n) int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - CPUClass *cc = CPU_GET_CLASS(cs); CPUMBState *env = cpu_env(cs); uint32_t tmp; - if (n > cc->gdb_num_core_regs) { - return 0; - } - tmp = ldl_p(mem_buf); switch (n) { diff --git a/target/openrisc/gdbstub.c b/target/openrisc/gdbstub.c index c2a77d5d4d5..45bba80d878 100644 --- a/target/openrisc/gdbstub.c +++ b/target/openrisc/gdbstub.c @@ -47,14 +47,9 @@ int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) int openrisc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { - CPUClass *cc = CPU_GET_CLASS(cs); CPUOpenRISCState *env = cpu_env(cs); uint32_t tmp; - if (n > cc->gdb_num_core_regs) { - return 0; - } - tmp = ldl_p(mem_buf); if (n < 32) { From patchwork Wed Jan 22 09:30:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9715BC0218D for ; Wed, 22 Jan 2025 09:32:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4c-0001PC-4Y; Wed, 22 Jan 2025 04:30:58 -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 1taX4U-0001FV-Vz for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:52 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4S-0003Da-3J for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:50 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-437a92d7b96so65653335e9.2 for ; Wed, 22 Jan 2025 01:30:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538244; x=1738143044; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JSvw35u1c/GeD9pKIKqf6WHVcOBbPhJhoq/j5sOwl2I=; b=d5Kprf1hmbAcIK7tj2CBTj44Kwb1h2fIzgDGVgiZvPWesGLHtSQizNTS52iZyB/yqS sXdtZsvf4DH/mDJoyRJJGUqn+cmeFkrFS19xDN4SsDw+jTmV1AdRuwSaBI/3ix41kxtl 1e42p+PHljs50DU8Alw/UyHpoclK9/iohldsy6XIgGHoFO+CcE/zSdk/90bpwkXotsIf F+UAluw5Yud6VTdTjgBq1rb6PcEERWZyVFF+N/xFzR/TzeNa0T+7ArvXiV28j8TldE49 Y8sBhB5y/0n7ScZZ7IEur2RSHC8PWyHaVn2WyB6sd7+4Bkwmv0lc+dkf+jDZTT/4awzq YSnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538244; x=1738143044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JSvw35u1c/GeD9pKIKqf6WHVcOBbPhJhoq/j5sOwl2I=; b=oIxQqeQ5kh3ZVCKwcjykfeI9IWoamBUh/5zXdLNXfvwE6rV32YEzE5/ZF4VaArE84M 1JVG4hCRPUgSiP/2124865QpWOXO512Lp+zN2Eir7aNpGd/MWeVq35sd3ElNMq+mINWS PyhTECY663KPlwdVEAqW+YzjhGjyhZgQ7zKch/mJO48rEGNb+EI1M0uFCIbFCeJs8wBd o8dnPSSQrFBPdO4TRB4t8fAs164jvyRdocROEr4/b/y79gsKIjKSjA5vlR7qMj2NfMM+ aiE3ZKZZszT62qCg8jq/+6TS/lgOatSEuixEd94KeTw5c5Oe+aFwRzmwyxNaXm9FLbwq G9KQ== X-Gm-Message-State: AOJu0YxYc7zFCob6UIQdYW76jdfQuqLnj7ugOVPkjeD0RdaFBVYZJD1L oqv8Y9eB+Yt5KamJ1+YvdE+5dV3pG4MxHzRW1sT4Da/yXSeLsKDNZiLODo6W6pn6nLdn6lWPeGK FEjI= X-Gm-Gg: ASbGncuR5mlo3gjPCi/5zntcvX8411g9AR0DbyQS4O5hhthQGtutM59PlIGaxJj6ZfN fw5yf4lPRZop9LPnocfrktO4TNSkJ21dksnmW3BmV2KRpQxqoZLNa36fMbhW5faQfavtAkiORVh yK1NcKDmON2DAwAvVIxr7/Aw0Ey5IEbNkIfHvbq3uBMs8bDnvKTT1cFETmidSXO0MFbRnbRuMoi 1akDfcEoa2G6hGvxk3XiKKuX57BbOgSej2t5ZMuZUvu4be5CcTQJ/zq9r5sWMpvsOb+F2H5BCcP Wb1svjJeDvWsv6klGsoW8Y8+5VvMfqfuCkkoFXNsJR+b X-Google-Smtp-Source: AGHT+IHiUZIdO9A6w16zxh/DaE5cD8lYprARYeJQ+U96OYFnahGVEXjmjwj0vMVEtFkeOyFPL/1N+w== X-Received: by 2002:a05:600c:3593:b0:431:5632:448b with SMTP id 5b1f17b1804b1-4389144eed4mr166894525e9.25.1737538244298; Wed, 22 Jan 2025 01:30:44 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b31a1e7fsm17313825e9.10.2025.01.22.01.30.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:30:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 03/10] cpus: Cache CPUClass early in instance_init() handler Date: Wed, 22 Jan 2025 10:30:21 +0100 Message-ID: <20250122093028.52416-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Cache CPUClass as early as possible, when the instance is initialized. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- cpu-target.c | 3 --- hw/core/cpu-common.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cpu-target.c b/cpu-target.c index 667688332c9..89874496a41 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -134,9 +134,6 @@ const VMStateDescription vmstate_cpu_common = { bool cpu_exec_realizefn(CPUState *cpu, Error **errp) { - /* cache the cpu class for the hotpath */ - cpu->cc = CPU_GET_CLASS(cpu); - if (!accel_cpu_common_realize(cpu, errp)) { return false; } diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index cb79566cc51..ff605059c15 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -238,6 +238,9 @@ static void cpu_common_initfn(Object *obj) { CPUState *cpu = CPU(obj); + /* cache the cpu class for the hotpath */ + cpu->cc = CPU_GET_CLASS(cpu); + gdb_init_cpu(cpu); cpu->cpu_index = UNASSIGNED_CPU_INDEX; cpu->cluster_index = UNASSIGNED_CLUSTER_INDEX; From patchwork Wed Jan 22 09:30:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947038 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89313C0218C for ; Wed, 22 Jan 2025 09:32:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4b-0001ML-Ev; Wed, 22 Jan 2025 04:30:57 -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 1taX4W-0001GD-Tt for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:53 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4U-0003ER-Ui for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:52 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-43625c4a50dso45967265e9.0 for ; Wed, 22 Jan 2025 01:30:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538249; x=1738143049; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1UV0l1u1VpXGSm89LpbkaA5vSB88+gDPSxyKKjefn6E=; b=bE20KuZHuGBN5xPpgheLOWv6Ouo1Jey2BrOXbNK5CdLUDolsFVxipUkdAgbpJRZtRT GX8SIWFQXC3JTCVzSl0NHY1J2e6aVCnpEcyh83vTTmpMWUlOsB08678rc/3DidMDpTdj 1Xmqnx+f3vDB/dh1VWtgDdO9Lt5c+k/WOiN9uZL7u2/MS0x0UNwkOL4b+FSVgktREvqy ybwFCE4I/uNheSdt+YUWiaNvbP0SYwFBhcB4f0LS+avk93qLcTzZkny55HsSTSvvaqwO ffsWzjVLh68O/me6Sh/pSJLMZFnn5jjF+EvwAU2pUMJ/etTDao2v/Gl+tH++ov8So25d hMIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538249; x=1738143049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1UV0l1u1VpXGSm89LpbkaA5vSB88+gDPSxyKKjefn6E=; b=Lu1Sqyx1OHo299lebJJN/OavELUPzbTUBSZvQsyuOOKMdYg9nUOq2Ti3NPHZudnHi7 /7LX8pS53Mez3SauYPqroJZ7xVGvSw9PCjK7ghaPElSCcMukVVmxLMy0snfMvs0aZHzf omcwXg1KacWj3Mq1sWeqyu/6PW3KiLJxMhYzU3/dKG07aR8w7aJopbMPVfSnatg5tTxM 0C0v6UADc1wIw5pzMDay92HWrfhkIvMA9Nif/bMQ//xm3uvCkAlryyKBUrNk3pUTsbcX JFCjL6nOo3QxwRALNOkHWPMkMy00FLdFrQEu6JL9XHMfGuvo6eOKWibbljOZp6CvFo2w XVCA== X-Gm-Message-State: AOJu0Yw8P21xVtQo17Smu5VxqIQrphtIu15dBQwjyZvjN+HWhHk6/pO1 pmWaZcUrYNkba9WqRjC2JA9BbwW0Sfn2dKRHudi8GCBaCTZOovy20S4HdYfNvekiuTAYiXfgktx dAwQ= X-Gm-Gg: ASbGncsR+DAjNceXWkMTLYeSuTT3z9toKJ58x3GW1CuJc6G8d8uw8g5A7SFf0aq/Jxq yA/Quuz6bZb85XUlhQnVN1OhOBtPnq0Ix4Frrj3ZAT7GdLoYIRSdq442ZIU3LvFQbtHZabGCiay 2gmBs8yQ9qyYx0CKShpyAkwqLTchEzS59xqNIeRlEfAVGS8DgO2kHyeERwV9Hk2LH0Li5j2vcbz 2BxZVzp1c3+kbcf5/LNUg7mHa7y31qdLLZp8z3qRNTvZCMhYrupyDS/fj1XTQ/D7WV+HP2YXcC9 oLB4fpG+QRNLxS06BbEhM8wi7Wnf8JOuHhbp8h3T1eno X-Google-Smtp-Source: AGHT+IG9O4Vaslac/rd22GI8JJjeSuQaSY9J/vZ19MsSESCQirxJFfUqVnRG0W1Jv966HJvoPWtHKw== X-Received: by 2002:a05:600c:4511:b0:431:60ec:7a96 with SMTP id 5b1f17b1804b1-438914387ddmr160190935e9.25.1737538248888; Wed, 22 Jan 2025 01:30:48 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b318c1a2sm17580255e9.7.2025.01.22.01.30.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:30:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 04/10] cpus: Prefer cached CpuClass over CPU_GET_CLASS() macro Date: Wed, 22 Jan 2025 10:30:22 +0100 Message-ID: <20250122093028.52416-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org CpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 10 +++----- cpu-common.c | 10 ++++---- cpu-target.c | 6 ++--- hw/core/cpu-common.c | 13 ++++------ hw/core/cpu-system.c | 55 +++++++++++++++---------------------------- 5 files changed, 32 insertions(+), 62 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 7b6b22c431b..d9e19d192e4 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -826,10 +826,8 @@ const char *parse_cpu_option(const char *cpu_option); */ static inline bool cpu_has_work(CPUState *cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - g_assert(cc->has_work); - return cc->has_work(cpu); + g_assert(cpu->cc->has_work); + return cpu->cc->has_work(cpu); } /** @@ -968,9 +966,7 @@ void cpu_interrupt(CPUState *cpu, int mask); */ static inline void cpu_set_pc(CPUState *cpu, vaddr addr) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - cc->set_pc(cpu, addr); + cpu->cc->set_pc(cpu, addr); } /** diff --git a/cpu-common.c b/cpu-common.c index 4248b2d727e..3a409aacb2e 100644 --- a/cpu-common.c +++ b/cpu-common.c @@ -389,11 +389,10 @@ void process_queued_cpu_work(CPUState *cpu) int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags, CPUBreakpoint **breakpoint) { - CPUClass *cc = CPU_GET_CLASS(cpu); CPUBreakpoint *bp; - if (cc->gdb_adjust_breakpoint) { - pc = cc->gdb_adjust_breakpoint(cpu, pc); + if (cpu->cc->gdb_adjust_breakpoint) { + pc = cpu->cc->gdb_adjust_breakpoint(cpu, pc); } bp = g_malloc(sizeof(*bp)); @@ -419,11 +418,10 @@ int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags, /* Remove a specific breakpoint. */ int cpu_breakpoint_remove(CPUState *cpu, vaddr pc, int flags) { - CPUClass *cc = CPU_GET_CLASS(cpu); CPUBreakpoint *bp; - if (cc->gdb_adjust_breakpoint) { - pc = cc->gdb_adjust_breakpoint(cpu, pc); + if (cpu->cc->gdb_adjust_breakpoint) { + pc = cpu->cc->gdb_adjust_breakpoint(cpu, pc); } QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) { diff --git a/cpu-target.c b/cpu-target.c index 89874496a41..98e9e7cc4a1 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -159,10 +159,8 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp) void cpu_exec_unrealizefn(CPUState *cpu) { #ifndef CONFIG_USER_ONLY - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (cc->sysemu_ops->legacy_vmsd != NULL) { - vmstate_unregister(NULL, cc->sysemu_ops->legacy_vmsd, cpu); + if (cpu->cc->sysemu_ops->legacy_vmsd != NULL) { + vmstate_unregister(NULL, cpu->cc->sysemu_ops->legacy_vmsd, cpu); } if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { vmstate_unregister(NULL, &vmstate_cpu_common, cpu); diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index ff605059c15..886aa793c04 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -40,9 +40,7 @@ CPUState *cpu_by_arch_id(int64_t id) CPUState *cpu; CPU_FOREACH(cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (cc->get_arch_id(cpu) == id) { + if (cpu->cc->get_arch_id(cpu) == id) { return cpu; } } @@ -101,11 +99,9 @@ static int cpu_common_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg) void cpu_dump_state(CPUState *cpu, FILE *f, int flags) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (cc->dump_state) { + if (cpu->cc->dump_state) { cpu_synchronize_state(cpu); - cc->dump_state(cpu, f, flags); + cpu->cc->dump_state(cpu, f, flags); } } @@ -119,11 +115,10 @@ void cpu_reset(CPUState *cpu) static void cpu_common_reset_hold(Object *obj, ResetType type) { CPUState *cpu = CPU(obj); - CPUClass *cc = CPU_GET_CLASS(cpu); if (qemu_loglevel_mask(CPU_LOG_RESET)) { qemu_log("CPU Reset (CPU %d)\n", cpu->cpu_index); - log_cpu_state(cpu, cc->reset_dump_flags); + log_cpu_state(cpu, cpu->cc->reset_dump_flags); } cpu->interrupt_request = 0; diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c index 6aae28a349a..37d54d04bf8 100644 --- a/hw/core/cpu-system.c +++ b/hw/core/cpu-system.c @@ -25,10 +25,8 @@ bool cpu_paging_enabled(const CPUState *cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (cc->sysemu_ops->get_paging_enabled) { - return cc->sysemu_ops->get_paging_enabled(cpu); + if (cpu->cc->sysemu_ops->get_paging_enabled) { + return cpu->cc->sysemu_ops->get_paging_enabled(cpu); } return false; @@ -37,10 +35,8 @@ bool cpu_paging_enabled(const CPUState *cpu) bool cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list, Error **errp) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (cc->sysemu_ops->get_memory_mapping) { - return cc->sysemu_ops->get_memory_mapping(cpu, list, errp); + if (cpu->cc->sysemu_ops->get_memory_mapping) { + return cpu->cc->sysemu_ops->get_memory_mapping(cpu, list, errp); } error_setg(errp, "Obtaining memory mappings is unsupported on this CPU."); @@ -50,14 +46,12 @@ bool cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list, hwaddr cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, MemTxAttrs *attrs) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (cc->sysemu_ops->get_phys_page_attrs_debug) { - return cc->sysemu_ops->get_phys_page_attrs_debug(cpu, addr, attrs); + if (cpu->cc->sysemu_ops->get_phys_page_attrs_debug) { + return cpu->cc->sysemu_ops->get_phys_page_attrs_debug(cpu, addr, attrs); } /* Fallback for CPUs which don't implement the _attrs_ hook */ *attrs = MEMTXATTRS_UNSPECIFIED; - return cc->sysemu_ops->get_phys_page_debug(cpu, addr); + return cpu->cc->sysemu_ops->get_phys_page_debug(cpu, addr); } hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr) @@ -81,64 +75,53 @@ int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs) int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu, void *opaque) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (!cc->sysemu_ops->write_elf32_qemunote) { + if (!cpu->cc->sysemu_ops->write_elf32_qemunote) { return 0; } - return (*cc->sysemu_ops->write_elf32_qemunote)(f, cpu, opaque); + return (*cpu->cc->sysemu_ops->write_elf32_qemunote)(f, cpu, opaque); } int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu, int cpuid, void *opaque) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (!cc->sysemu_ops->write_elf32_note) { + if (!cpu->cc->sysemu_ops->write_elf32_note) { return -1; } - return (*cc->sysemu_ops->write_elf32_note)(f, cpu, cpuid, opaque); + return (*cpu->cc->sysemu_ops->write_elf32_note)(f, cpu, cpuid, opaque); } int cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu, void *opaque) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (!cc->sysemu_ops->write_elf64_qemunote) { + if (!cpu->cc->sysemu_ops->write_elf64_qemunote) { return 0; } - return (*cc->sysemu_ops->write_elf64_qemunote)(f, cpu, opaque); + return (*cpu->cc->sysemu_ops->write_elf64_qemunote)(f, cpu, opaque); } int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu, int cpuid, void *opaque) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (!cc->sysemu_ops->write_elf64_note) { + if (!cpu->cc->sysemu_ops->write_elf64_note) { return -1; } - return (*cc->sysemu_ops->write_elf64_note)(f, cpu, cpuid, opaque); + return (*cpu->cc->sysemu_ops->write_elf64_note)(f, cpu, cpuid, opaque); } bool cpu_virtio_is_big_endian(CPUState *cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (cc->sysemu_ops->virtio_is_big_endian) { - return cc->sysemu_ops->virtio_is_big_endian(cpu); + if (cpu->cc->sysemu_ops->virtio_is_big_endian) { + return cpu->cc->sysemu_ops->virtio_is_big_endian(cpu); } return target_words_bigendian(); } GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); GuestPanicInformation *res = NULL; - if (cc->sysemu_ops->get_crash_info) { - res = cc->sysemu_ops->get_crash_info(cpu); + if (cpu->cc->sysemu_ops->get_crash_info) { + res = cpu->cc->sysemu_ops->get_crash_info(cpu); } return res; } From patchwork Wed Jan 22 09:30:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EEF89C0218C for ; Wed, 22 Jan 2025 09:33:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4d-0001PS-Ej; Wed, 22 Jan 2025 04:30:59 -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 1taX4b-0001NW-Ld for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:57 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4Z-0003Fy-W2 for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:30:57 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-385de59c1a0so3791347f8f.2 for ; Wed, 22 Jan 2025 01:30:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538253; x=1738143053; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3ds9Wj0QZU42GLHBsVwmUFq56bCDGO06IGIH+Sdiodc=; b=PmjUjP9CKILYn+fBhV8S2ICj/3uSCLw237P+IYX0BTiPjRX8ugYkpGIFh0J5P9hza8 miDLGx0xAXEOtJHSzN1xWi3vDq3W2lBj7tq6x7At+f5wmrVJgv4ken15WR7zZRxla1zu c57wSXDRP/srDP6P3bbhwLwa1sx8ScPRU6iQ/5UbMvRI4BJwve+LKcQLkIrS2Usa843c 24VX6FTT7ciO8DS4Uu+mi4haxv982CCjBRX+4NY4jyktVwC8pqYYTn0uFb/6/2stJMAE skchOP/DHjMkrogdJ35rcyIuD2BmWCQTfVcCAuQ6Jc3kDuSF6evaX/YSvkuVDW5AHKga XEpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538253; x=1738143053; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3ds9Wj0QZU42GLHBsVwmUFq56bCDGO06IGIH+Sdiodc=; b=d6XepkMFcK5ZbZbe4PfLD8cP3cwZAKJGHKQwM0S0u5tCkv3POV5J70vQ0HSUEn+Sr5 FJ2W+7Oa6FTPzM0HF1CBQ3T813gSIymfyajKpOz8iZtFRju/9nE7gSy8svJNtovFBG1V 1ll8SKKFX0R9/7JkUcGuJphJM/s/Ns4qSjrnd7wilFz6omckjHuMEvEoBAmuCcYY79LH vsBfMUj9SWGdbzQCJOdEsdWNfPY8quAIdX/HaMFL6csZyQw/YAnuCB4TEzHtARbJ9h3m 8ee8N9LdZ92N1WFusrZifcKcDSMpP6Mo+LWD/CSYouWyQdPN9uRFa76TK3QXT4m/LHzP ZT6w== X-Gm-Message-State: AOJu0YyQbnxecDEO1+Fdc8qGR9RTUoVYLkMs2k4M6O67vmL8hGEyNfKg dK+itmpcPQxRwT009c2nEWL71FHsEOAexhBP86nCgeFBUFtSrYlko03N2vM+uBv2y8XlFUQXjfN hAcY= X-Gm-Gg: ASbGncsmvw421JehaOyq5jyjTyopjJ08ND6zegCH4bHPgdbGUDHvXX8VBeGDEPrwFS7 BEg8YFO1OWA69ifTs4INeSSEIgRP2j6tA0WWKL3LacId/y7Ny6MBYKc7paP76a0ZJ7I+6v8ws6y SXbvTvIJGYYnKCzBMY1lGe0UVg68TGR4VLbRS2f+ZYYfXPmlkEmm+5md7utrjC/e13O14mMT51E hKBoDIFiO7AJjZPGW7NNqAmhvj5QaFGon5ov4buoyjutKTmAhAMUl8qz09x8sEgw9LNp2NZUzzP lzMnTTy9qxpwFzshl3SLugLLdP5ylN7YI9ENdLnRgD7q X-Google-Smtp-Source: AGHT+IGpVW92Redmqgr+HmUbpNm8hsX+p2uNrDpzZR1xgMtAGnI2STvmEVxhrXqPqFc+p4wVYOA0OQ== X-Received: by 2002:a05:6000:1f81:b0:386:3213:5b9b with SMTP id ffacd0b85a97d-38bf57a9477mr21266255f8f.43.1737538253473; Wed, 22 Jan 2025 01:30:53 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38bf322acdcsm16022223f8f.55.2025.01.22.01.30.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:30:53 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 05/10] accel: Prefer cached CpuClass over CPU_GET_CLASS() macro Date: Wed, 22 Jan 2025 10:30:23 +0100 Message-ID: <20250122093028.52416-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org CpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- accel/accel-target.c | 12 +++++------- accel/tcg/tcg-accel-ops.c | 3 +-- accel/tcg/translate-all.c | 2 +- accel/tcg/watchpoint.c | 9 ++++----- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/accel/accel-target.c b/accel/accel-target.c index 08626c00c2d..8a16c0c3ae0 100644 --- a/accel/accel-target.c +++ b/accel/accel-target.c @@ -112,22 +112,20 @@ void accel_init_interfaces(AccelClass *ac) void accel_cpu_instance_init(CPUState *cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (cc->accel_cpu && cc->accel_cpu->cpu_instance_init) { - cc->accel_cpu->cpu_instance_init(cpu); + if (cpu->cc->accel_cpu && cpu->cc->accel_cpu->cpu_instance_init) { + cpu->cc->accel_cpu->cpu_instance_init(cpu); } } bool accel_cpu_common_realize(CPUState *cpu, Error **errp) { - CPUClass *cc = CPU_GET_CLASS(cpu); AccelState *accel = current_accel(); AccelClass *acc = ACCEL_GET_CLASS(accel); /* target specific realization */ - if (cc->accel_cpu && cc->accel_cpu->cpu_target_realize - && !cc->accel_cpu->cpu_target_realize(cpu, errp)) { + if (cpu->cc->accel_cpu + && cpu->cc->accel_cpu->cpu_target_realize + && !cpu->cc->accel_cpu->cpu_target_realize(cpu, errp)) { return false; } diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 6e3f1fa92b2..299d6176cfb 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -120,10 +120,9 @@ static inline int xlat_gdb_type(CPUState *cpu, int gdbtype) [GDB_WATCHPOINT_ACCESS] = BP_GDB | BP_MEM_ACCESS, }; - CPUClass *cc = CPU_GET_CLASS(cpu); int cputype = xlat[gdbtype]; - if (cc->gdb_stop_before_watchpoint) { + if (cpu->cc->gdb_stop_before_watchpoint) { cputype |= BP_STOP_BEFORE_ACCESS; } return cputype; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index d56ca13cddf..5a378cb0281 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -622,7 +622,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) * to account for the re-execution of the branch. */ n = 1; - cc = CPU_GET_CLASS(cpu); + cc = cpu->cc; if (cc->tcg_ops->io_recompile_replay_branch && cc->tcg_ops->io_recompile_replay_branch(cpu, tb)) { cpu->neg.icount_decr.u16.low++; diff --git a/accel/tcg/watchpoint.c b/accel/tcg/watchpoint.c index af57d182d5b..52e550dec6b 100644 --- a/accel/tcg/watchpoint.c +++ b/accel/tcg/watchpoint.c @@ -69,7 +69,6 @@ int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len) void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, MemTxAttrs attrs, int flags, uintptr_t ra) { - CPUClass *cc = CPU_GET_CLASS(cpu); CPUWatchpoint *wp; assert(tcg_enabled()); @@ -85,9 +84,9 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, return; } - if (cc->tcg_ops->adjust_watchpoint_address) { + if (cpu->cc->tcg_ops->adjust_watchpoint_address) { /* this is currently used only by ARM BE32 */ - addr = cc->tcg_ops->adjust_watchpoint_address(cpu, addr, len); + addr = cpu->cc->tcg_ops->adjust_watchpoint_address(cpu, addr, len); } assert((flags & ~BP_MEM_ACCESS) == 0); @@ -119,8 +118,8 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, wp->hitattrs = attrs; if (wp->flags & BP_CPU - && cc->tcg_ops->debug_check_watchpoint - && !cc->tcg_ops->debug_check_watchpoint(cpu, wp)) { + && cpu->cc->tcg_ops->debug_check_watchpoint + && !cpu->cc->tcg_ops->debug_check_watchpoint(cpu, wp)) { wp->flags &= ~BP_WATCHPOINT_HIT; continue; } From patchwork Wed Jan 22 09:30:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38FD4C02182 for ; Wed, 22 Jan 2025 09:33:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4i-0001dP-IM; Wed, 22 Jan 2025 04:31:04 -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 1taX4g-0001UN-6h for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:02 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4e-0003HO-4Y for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:01 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-43618283dedso68310165e9.3 for ; Wed, 22 Jan 2025 01:30:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538258; x=1738143058; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GFH8+KHnxWyy8fn4eViNDfLZ8hXpurTe6Lr7eVv7UPs=; b=OuzfUUaelBM2OjtE+MhF6GVWQrabhjS7YpkaGAkJt0lXmqiylMY0FOWGQOOMbYcUxv sEV3sRiwsbcIKQJQRK1f0uEhYzc8MKAPM8RbXs5QCRb77+hJtKDPs6xytOws2Su4Djko Q9Fu6rLJkoLiXNY65w128pp5wl91aExyKn1grLQtyoOdqFWbOsF+uDkgVKqgNKs+EUxQ GUPHp1PoPqC1cLtf7XkfQURExCDSomgnjklEUN7luASNbWFQBcYQr3MiuVxByZa6VrH2 2X1fpFmaj0RiKTtDrAQtdZlXG9MPsr9jY2Kdf7PQu+rhKEpUGx6WBFJO2lc89EasZVe+ OLpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538258; x=1738143058; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GFH8+KHnxWyy8fn4eViNDfLZ8hXpurTe6Lr7eVv7UPs=; b=j9NiUD4M16so/jSWNVvWJ4qrQEoYfnj3ibousRSg99p0dYpQklASN0pSNT6E4s88Gw xwf3nX6EqfMXiuztelcyoNcBglp9ifRX9H8ea6Y76Q/NNGHLaV2O0N0SjL7VPXq+7M6N ze2yzi13MCoFTQ2+fnnKitP3a8zNZxu33shTC24B+/6KPKI2g+kZ2jVAAECB5arPqHHb 2DZi3hkwW+5HMi85TxVqO9/YF0KttAw2vnfWRPY4qo7KMVA5aQsfq+QFbElThlnoTTNf c3nSGqBZAVTLFc5gCtF5z/7x4bQYh8+LTpgE9+YCkTRWmwGG3kj215fE8DgI8Lf5C9SX tpUw== X-Gm-Message-State: AOJu0Yz+91FqjACcq0o9ZrTB21JC2b9rlpv5fkzwZsbxaJ3JEntoKcOB Lf2MtgLvzjSqwq1wnkLTwGO/mlHGyxNgSwZF7H1sFTmOQkau58Nn/P3aVWPAtx7EqZgbDWqDRkj BiTE= X-Gm-Gg: ASbGncuuKiEeU0+9UrHKkdqAqPvo3BJOBelhQqKszD1UQtepC0VZkyPQzszS4wZSbbA EmMpIDENeAWhk3bdcmsq9mteEyMExv45UE1Q7GvFZ/Yfl0fzumnT+rICoxrhfnc/Lom7bxR73dX SRi6wnsuqTmW5Mb0AASgtO5cxsBlZi5POVaPbiKdHJRkqQCC343ggbYlIqSR5SMhEanAruh4qvL heb8wrOUwcRSrQkZfcNAZ7eMxUJG1HfBZwO3NQMfOvgbnVSUJRU8ZHEIGglCDAKzlgbefTNoGUW h2Aqok24MbZ16fS9dLAOn8S+3KG4Wok+Gll4ezjCdCPY X-Google-Smtp-Source: AGHT+IEhxajtTv3CRYfRljbKHFWTclhTo/t8qNAC8SrmWIAElc8vVmVt/qK+Dowl1CkKINeDdp8Lgg== X-Received: by 2002:a05:600c:4743:b0:434:ff25:199f with SMTP id 5b1f17b1804b1-438914309a8mr154805895e9.26.1737538258152; Wed, 22 Jan 2025 01:30:58 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b318c004sm17475455e9.4.2025.01.22.01.30.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:30:57 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 06/10] user: Prefer cached CpuClass over CPU_GET_CLASS() macro Date: Wed, 22 Jan 2025 10:30:24 +0100 Message-ID: <20250122093028.52416-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org CpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- linux-user/alpha/target_proc.h | 2 +- bsd-user/signal.c | 4 ++-- linux-user/signal.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/linux-user/alpha/target_proc.h b/linux-user/alpha/target_proc.h index dac37dffc9d..da437ee0e56 100644 --- a/linux-user/alpha/target_proc.h +++ b/linux-user/alpha/target_proc.h @@ -15,7 +15,7 @@ static int open_cpuinfo(CPUArchState *cpu_env, int fd) const char *p, *q; int t; - p = object_class_get_name(OBJECT_CLASS(CPU_GET_CLASS(env_cpu(cpu_env)))); + p = object_class_get_name(OBJECT_CLASS(env_cpu(cpu_env)->cc)); q = strchr(p, '-'); t = q - p; assert(t < sizeof(model)); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index b4e1458237a..4e32cd64f18 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -1021,7 +1021,7 @@ void process_pending_signals(CPUArchState *env) void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, MMUAccessType access_type, bool maperr, uintptr_t ra) { - const TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; if (tcg_ops->record_sigsegv) { tcg_ops->record_sigsegv(cpu, addr, access_type, maperr, ra); @@ -1037,7 +1037,7 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, MMUAccessType access_type, uintptr_t ra) { - const TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; if (tcg_ops->record_sigbus) { tcg_ops->record_sigbus(cpu, addr, access_type, ra); diff --git a/linux-user/signal.c b/linux-user/signal.c index 087c4d270e4..53b40e82261 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -743,7 +743,7 @@ void force_sigsegv(int oldsig) void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, MMUAccessType access_type, bool maperr, uintptr_t ra) { - const TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; if (tcg_ops->record_sigsegv) { tcg_ops->record_sigsegv(cpu, addr, access_type, maperr, ra); @@ -759,7 +759,7 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, MMUAccessType access_type, uintptr_t ra) { - const TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops; + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; if (tcg_ops->record_sigbus) { tcg_ops->record_sigbus(cpu, addr, access_type, ra); From patchwork Wed Jan 22 09:30:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0FC7EC02181 for ; Wed, 22 Jan 2025 09:33:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4m-0001nG-G0; Wed, 22 Jan 2025 04:31:08 -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 1taX4j-0001i3-Ss for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:05 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4i-0003In-Ex for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:05 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-437a92d7b96so65656175e9.2 for ; Wed, 22 Jan 2025 01:31:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538263; x=1738143063; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6euSBLv31aJZp9lvcImTSgTbDVlnwvaPYw0ieO+1v6o=; b=hWSPv+d2k8JBdaQDMD92SKchTB/Zl+COaNKqvQH8EjdOTFL4ZG3ynU1CB93uf4z0Di yN+ajwby+91/ByvxiMjcUtJaP1z9fFtW4IxblQORd1HE0Qr2y9BfAgvPowfbUtJ6qdWK C/InLmQ7Nj5ALx75pWKueZnF2MhWbaHuYXkj5s7I92XwgyK3kaUsklQ/1rfMHhJJuMpu iOQ/ozsx6cucF+TDxYom93c2qf8IxoYdMnWjPF6CceDmpn85lRWYmBek580pYvIPA2tV JKO+I1onBLdG7lmYqla55CyeVOFHWDzRovO4l9pfN0T3zp601DkdWxwifaOpNZMjn2Q6 8o/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538263; x=1738143063; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6euSBLv31aJZp9lvcImTSgTbDVlnwvaPYw0ieO+1v6o=; b=KQacXUbLk9k914IH04sX3nCX4Qb9yq+I1wVON1RbdPBgEId2RegxmsYQOIxQeG7P4A cElASIu68v+DNdi/EiZcMDdpnBHOF0aQRCGB5cdH+AE+/lueoNc87aZKW8BiuzmXAEsD GGXoKCQq4OFKfmuYN+9jS6jDqfGZwWMRgxfUfIDM7mLDki1wSxmPahSPfZFUKjE9JcDH KL2i+NxBC/MrVkOqDkGa8YbZsDhWglPC1rU0WJv3V3HZXNsXTPU/AYEOEtVnbwGOQMn9 ov8IQK6IeMi7JFr28kaHVRWDSV+Avfaz3kEZlDGyQUYSU52WB3xaNEgyEmkQn5gz1nsC h4Dg== X-Gm-Message-State: AOJu0Yxx88+0Hc0mSZe7E1iGLYcsmoqnIVl501YUWCgKfa9VLdUUMeq/ FLOJ37/QpWofVtqBcOt3X3916nxVedj+S6kAZCiIV+TNE0uNmqYSWlyHav93FRfN8HJjW00VAld N94U= X-Gm-Gg: ASbGncujOqa7VR0ZUI/1lPpgJv2nDwRsPooLILiwkwELGqJyKHCE7fWnDwwZ67/3wIm g+a31aFtsYiVJBjJ5rLd9UXIcySOu67J2Yik3wAC3sl8Zudeatz2QnSJBpGyUnHE4x6uUeU3KAi 0VS9uiCYi0km8HkJU6bf7HBMIDQTFHUD1DagKsf9CWpPK5xH4kGt/bp+KNmwcGMIm1NkrBfKCe2 DUiYxtuf2tOt5ykalFeBLIfu7PXUae/fgjTilmeDJduyK4jMMHxUQUh6sQGgzUk67n/oCBn5Znf sb/rZ3IafoFduQjfV6zhzL/4Jyeoyjr8s55HuTgC58DW X-Google-Smtp-Source: AGHT+IF2JvGRnHc2kBttL0oH/jSFC9d4hSmVy0jmUw3+QS0SDdp5u+fq9MN06CLSXLDViVVLuT7YAw== X-Received: by 2002:a05:600c:3593:b0:431:5632:448b with SMTP id 5b1f17b1804b1-4389144eed4mr166904965e9.25.1737538262741; Wed, 22 Jan 2025 01:31:02 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b31adbccsm17547875e9.19.2025.01.22.01.31.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:31:02 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 07/10] disas: Prefer cached CpuClass over CPU_GET_CLASS() macro Date: Wed, 22 Jan 2025 10:30:25 +0100 Message-ID: <20250122093028.52416-8-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org CpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- disas/disas-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/disas/disas-common.c b/disas/disas-common.c index de61f6d8a12..57505823cb7 100644 --- a/disas/disas-common.c +++ b/disas/disas-common.c @@ -67,9 +67,8 @@ void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu) s->info.endian = BFD_ENDIAN_LITTLE; } - CPUClass *cc = CPU_GET_CLASS(cpu); - if (cc->disas_set_info) { - cc->disas_set_info(cpu, &s->info); + if (cpu->cc->disas_set_info) { + cpu->cc->disas_set_info(cpu, &s->info); } } From patchwork Wed Jan 22 09:30:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0262C02181 for ; Wed, 22 Jan 2025 09:33:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4q-0001uZ-LR; Wed, 22 Jan 2025 04:31:12 -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 1taX4p-0001no-0s for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:11 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4n-0003JN-37 for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:10 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43618283dedso68312065e9.3 for ; Wed, 22 Jan 2025 01:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538267; x=1738143067; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oNGgwti16N0RaYgdrpqIsRq0rprgvC+KnfZZxJFop+c=; b=kuPihQ+jR1gPK2UJ5o4uSVFxKd8szyWW6+hgzm/NbfV8EjIXgQZzsy7NUt0TSIsoNq AnCdhNgfQODnQTax462AxdH6Fzv5lOXFB0ry5RP7IhbB7UI3qVeGAdaJnHoBwTlML/zx kdEVoCywx3SurXSinoFbPPu7qf/y1cEpdLdX0QGgYCQotp52OTyZ1RiHsTnxmu1nzcYQ wxknbMQezYYG13BbyBxkJ00fatrXHch7ppOErsAWPsrH9vwaA+npVWdXxm2dmukMeqoz +sKfHdD+sgWUETi3Kvc9Do1pui9O88UTQn2g68+rQwhfq/62ptleNVjJwSnCQ2rVz1Cu fFFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538267; x=1738143067; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oNGgwti16N0RaYgdrpqIsRq0rprgvC+KnfZZxJFop+c=; b=SQTB/ZINvU2nYhUGSwZGysBKUQab9N/NfbXKIzpc8IuzpY9HhHzDCMKumRZYdDsjTk x8onswo36BwZSd1yVTDmAva18drysD4mZ5N0wnINA1ZGISyk3iGbSEqYJcrBkn57LbdK 7p5KrgsnQTTDe+IQlThtYsJxw4D1dZqD/DGAruxi78CdCbRugOWh4Vps0CVKf4Xc+OUj 49f6E3tUjXnFn8zP85X3Wiq1ePIIon/82jAzI8dkNjjIbpVylOAeO6jX7PY5VNtpsCCI IfJZh1re7GZrwpPYUnP8z4+L//mHkA1H8jvvIkC/KM3SY90Dgi9V+NTMEJ3eWU2i9/fJ 1BcA== X-Gm-Message-State: AOJu0YyJnWzWIJlLjuHfS6bDOL44lPJByzFNwc6eH5t09IFwYMKeKNfb clDuUdATELh3Lg3l6upOjg0GlLud4UGURMQjVpekSi990+hB4F+iJgV4YOY6vTPFzyokY7famI4 UIeY= X-Gm-Gg: ASbGnctZDpHeSdVvBeMxUFEF00siQEIjoLPqMrb6y2wbDi7TklTtZ9pBf6Zl6NVVto5 zo80r2nDbMVh1T/+Ff6SqyVmCUtNwI2pEOnZUwbG6ay/2jns9FnPdiiwI1R7xYkjCOIJv4xi/kN aT6bagreDAoicKw1qfOloZZeMV/7mz9UjIevWDtFwyIxsElAr12A3WR3gVtFMMMufa59CjHmVic K3U8R3uRuAv6ZaR1BjpIt1uD33CuTo9M/y/JGsZo58oCTjkcxflupfvD58gYby5i1hc53tLjoVF GpNQ4bTmnSAjfo+VXPyP6KxZYf+UqAkrBW2719pq3sd5 X-Google-Smtp-Source: AGHT+IGuXAL20mHd9R2/lClWS7l1W26KPDxoiKT0W+da+K9wiLYkg9YH5EALMh5dy9yk4m8BTc+Cyw== X-Received: by 2002:a05:600c:468d:b0:434:a75b:5f59 with SMTP id 5b1f17b1804b1-438913bdb19mr175725585e9.3.1737538267345; Wed, 22 Jan 2025 01:31:07 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b31afaf8sm17294715e9.21.2025.01.22.01.31.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:31:06 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 08/10] gdbstub: Prefer cached CpuClass over CPU_GET_CLASS() macro Date: Wed, 22 Jan 2025 10:30:26 +0100 Message-ID: <20250122093028.52416-9-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org CpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Acked-by: Alex Bennée --- gdbstub/gdbstub.c | 26 +++++++++----------------- gdbstub/system.c | 7 ++----- gdbstub/user-target.c | 6 ++---- gdbstub/user.c | 7 ++----- 4 files changed, 15 insertions(+), 31 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index e366df12d4a..282e13e163f 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -354,7 +354,6 @@ static const char *get_feature_xml(const char *p, const char **newp, GDBProcess *process) { CPUState *cpu = gdb_get_first_cpu_in_process(process); - CPUClass *cc = CPU_GET_CLASS(cpu); GDBRegisterState *r; size_t len; @@ -377,11 +376,11 @@ static const char *get_feature_xml(const char *p, const char **newp, "" "")); - if (cc->gdb_arch_name) { + if (cpu->cc->gdb_arch_name) { g_ptr_array_add( xml, g_markup_printf_escaped("%s", - cc->gdb_arch_name(cpu))); + cpu->cc->gdb_arch_name(cpu))); } for (guint i = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); @@ -520,11 +519,10 @@ GArray *gdb_get_register_list(CPUState *cpu) int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { - CPUClass *cc = CPU_GET_CLASS(cpu); GDBRegisterState *r; - if (reg < cc->gdb_num_core_regs) { - return cc->gdb_read_register(cpu, buf, reg); + if (reg < cpu->cc->gdb_num_core_regs) { + return cpu->cc->gdb_read_register(cpu, buf, reg); } for (guint i = 0; i < cpu->gdb_regs->len; i++) { @@ -538,11 +536,10 @@ int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) { - CPUClass *cc = CPU_GET_CLASS(cpu); GDBRegisterState *r; - if (reg < cc->gdb_num_core_regs) { - return cc->gdb_write_register(cpu, mem_buf, reg); + if (reg < cpu->cc->gdb_num_core_regs) { + return cpu->cc->gdb_write_register(cpu, mem_buf, reg); } for (guint i = 0; i < cpu->gdb_regs->len; i++) { @@ -570,7 +567,7 @@ static void gdb_register_feature(CPUState *cpu, int base_reg, void gdb_init_cpu(CPUState *cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); + CPUClass *cc = cpu->cc; const GDBFeature *feature; cpu->gdb_regs = g_array_new(false, false, sizeof(GDBRegisterState)); @@ -1646,11 +1643,8 @@ void gdb_extend_qsupported_features(char *qflags) static void handle_query_supported(GArray *params, void *user_ctx) { - CPUClass *cc; - g_string_printf(gdbserver_state.str_buf, "PacketSize=%x", MAX_PACKET_LENGTH); - cc = CPU_GET_CLASS(first_cpu); - if (cc->gdb_core_xml_file) { + if (first_cpu->cc->gdb_core_xml_file) { g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+"); } @@ -1697,7 +1691,6 @@ static void handle_query_supported(GArray *params, void *user_ctx) static void handle_query_xfer_features(GArray *params, void *user_ctx) { GDBProcess *process; - CPUClass *cc; unsigned long len, total_len, addr; const char *xml; const char *p; @@ -1708,8 +1701,7 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) } process = gdb_get_cpu_process(gdbserver_state.g_cpu); - cc = CPU_GET_CLASS(gdbserver_state.g_cpu); - if (!cc->gdb_core_xml_file) { + if (!gdbserver_state.g_cpu->cc->gdb_core_xml_file) { gdb_put_packet(""); return; } diff --git a/gdbstub/system.c b/gdbstub/system.c index 8ce79fa88cf..215a2c5dcad 100644 --- a/gdbstub/system.c +++ b/gdbstub/system.c @@ -452,8 +452,6 @@ static int phy_memory_mode; int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, uint8_t *buf, int len, bool is_write) { - CPUClass *cc; - if (phy_memory_mode) { if (is_write) { cpu_physical_memory_write(addr, buf, len); @@ -463,9 +461,8 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, return 0; } - cc = CPU_GET_CLASS(cpu); - if (cc->memory_rw_debug) { - return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + if (cpu->cc->memory_rw_debug) { + return cpu->cc->memory_rw_debug(cpu, addr, buf, len, is_write); } return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c index 22bf4008c0f..355b1901b4f 100644 --- a/gdbstub/user-target.c +++ b/gdbstub/user-target.c @@ -233,10 +233,8 @@ void gdb_handle_query_offsets(GArray *params, void *user_ctx) static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, uint8_t *buf, int len, bool is_write) { - CPUClass *cc; - cc = CPU_GET_CLASS(cpu); - if (cc->memory_rw_debug) { - return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + if (cpu->cc->memory_rw_debug) { + return cpu->cc->memory_rw_debug(cpu, addr, buf, len, is_write); } return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } diff --git a/gdbstub/user.c b/gdbstub/user.c index c2bdfc3d491..375f7f80653 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -665,11 +665,8 @@ int gdb_continue_partial(char *newstates) int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, uint8_t *buf, int len, bool is_write) { - CPUClass *cc; - - cc = CPU_GET_CLASS(cpu); - if (cc->memory_rw_debug) { - return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + if (cpu->cc->memory_rw_debug) { + return cpu->cc->memory_rw_debug(cpu, addr, buf, len, is_write); } return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } From patchwork Wed Jan 22 09:30:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947044 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85483C02181 for ; Wed, 22 Jan 2025 09:33:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX4v-0001wl-9D; Wed, 22 Jan 2025 04:31:17 -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 1taX4t-0001vy-Ix for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:15 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4r-0003K3-SQ for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:15 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-38a8b35e168so409887f8f.1 for ; Wed, 22 Jan 2025 01:31:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538272; x=1738143072; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XAK8+ZcQI8PZXdkgjSlPlEy1wFV5KzZpV4Si9c0ft5M=; b=VXAjRfjE8OylNIyuOsBkgXwpcq94dayKhJgrI1QhZitsYBaSz7jvIi1OjIHZ8hg6aH 0HapH6CoLoXR1YVkvOu/+FfZX+abTU1UuIcx/Ziiqpd4eEXpzgWORCqGeO9rnn2Qi388 PSmQisliiPSz37rcNI8q5JaUiuLvuJjQzA5HWCItW+GW7BvNkSh9YYcgkP51o1f0gg4H K8VfRudtaxQqTXBD+dZUVNAA7cWlY7WGWHF2c9LC2R0xDMI45axgpKXz6rLX5u+IuhoN zPw9E6/ulbeQFsxE1pwOItw5lvOJqDn3LzyakVszCqkHNeheDehXxGU5Ca6heDeXzPUj 6pHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538272; x=1738143072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XAK8+ZcQI8PZXdkgjSlPlEy1wFV5KzZpV4Si9c0ft5M=; b=dj8O3ZHCG0GPQMWZZOxVo68q2mF+WEah1AfCB1+1zZfIdfYBuQvk30yh26XI/gTll1 nVSQ1mkxhwG/nZcsnFlMhf7PumhjOdKK4gDZGnXrdheEcqEAs5bNu8S71I0ikQzvJaVG fkrqhmx0zN4Ou5gdExpef3Zd74y+VBO7nAd4m8VXKtAAcXkSmzhavwYvrA7/ZFBUxWxV 0g50d8NEUYShbmO8JUWpfniQtgT7ZYxjpI/VfiCQid1D5eWDSLNFRpF3RHleBsSehoDI qG6h2Uv81OB6KEySfNv9AEwc49vai4jMBi0a/Z6ihg21HLzE3M9m4Fe8H63VEyZFO93n 8v7Q== X-Gm-Message-State: AOJu0Yyr2GmF1Z6bi5tJENq64pVXxSQeF5yZ7EpdOKxNvUmGrWqKq7KU DhEwzCHZ7Tm12TiIttrypuLblY/SWQcHeGKzU3umAUJ946eI889UTrqICqagiV/kOr9TugSpwci DGcs= X-Gm-Gg: ASbGncuNhmTHMxy7qNSruaQJrGpbhs/bKu8BP3jykiCOKu5y0x5Q99NHPlo+V9WPfVD g1Kiev7Qedo0hzKnRSKMahFWBEM++dToqMHbVlJl1PdNCXtZ6yoSXtMG2zJULjdtcQyirZZIUdS hOpzZSfcf7ql5G3MYT87OhHk6pSUC8NbXaSKfU3cjg/bwsLucXIecGoKI7GyPNlI/Aw4i89daVX Er0kSCS+3QYzuwqzteWlyC+KdfPfxzNXN3vYYv1yb/m4pOAGW4OI+/rA4AZsZGB/Uzbrmjw8En+ rSj3BR/wUePP3GnUSXdLCF3XRl2xEE5IOGyFtbihlum+ X-Google-Smtp-Source: AGHT+IFai9mD8GltFAw7gxPrREpzrvJjo+UMSvD2ijZjgbzRv5dMrin2AUgKp4k7hnSrJKSzVAnRdw== X-Received: by 2002:a5d:64e6:0:b0:381:ed32:d604 with SMTP id ffacd0b85a97d-38bf5ad3a71mr16765849f8f.10.1737538271919; Wed, 22 Jan 2025 01:31:11 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38bf322a414sm15660432f8f.47.2025.01.22.01.31.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:31:11 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 09/10] hw/acpi: Prefer cached CpuClass over CPU_GET_CLASS() macro Date: Wed, 22 Jan 2025 10:30:27 +0100 Message-ID: <20250122093028.52416-10-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org CpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/acpi/cpu.c | 4 ++-- hw/acpi/cpu_hotplug.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index f70a2c045e1..6f1ae79edbf 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -235,8 +235,8 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, static AcpiCpuStatus *get_cpu_status(CPUHotplugState *cpu_st, DeviceState *dev) { - CPUClass *k = CPU_GET_CLASS(dev); - uint64_t cpu_arch_id = k->get_arch_id(CPU(dev)); + CPUState *cpu = CPU(dev); + uint64_t cpu_arch_id = cpu->cc->get_arch_id(cpu); int i; for (i = 0; i < cpu_st->dev_count; i++) { diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c index 83b8bc5deb8..aa0e1e3efa5 100644 --- a/hw/acpi/cpu_hotplug.c +++ b/hw/acpi/cpu_hotplug.c @@ -62,10 +62,9 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = { static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu, bool *swtchd_to_modern) { - CPUClass *k = CPU_GET_CLASS(cpu); int64_t cpu_id; - cpu_id = k->get_arch_id(cpu); + cpu_id = cpu->cc->get_arch_id(cpu); if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) { object_property_set_bool(g->device, "cpu-hotplug-legacy", false, &error_abort); From patchwork Wed Jan 22 09:30:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13947047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64D58C0218C for ; Wed, 22 Jan 2025 09:33:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1taX50-00026s-Vz; Wed, 22 Jan 2025 04:31:23 -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 1taX4y-00025D-2r for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:20 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taX4w-0003Kd-Hh for qemu-devel@nongnu.org; Wed, 22 Jan 2025 04:31:19 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-43622267b2eso65858095e9.0 for ; Wed, 22 Jan 2025 01:31:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737538276; x=1738143076; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zX6wKmzI06nCmXct1pzxbuNtoEp265I9BJm+57rS6fc=; b=E0XnPb6KePl8gWoAp6nEc4OJu6MMWT+oFyLVvHN5GMFpBmDMP6fovKeMmqEHzQa4F4 pWVtyg+agUupVTtV1W+IF57IJ8Tf5Oee4gJvbRCGs3hJThvR0PrYD+ZqkC5iXML26j2B qnGvxKFmE5cL9zwHdiLQlGwjSis9CnSAOPS/6RL5bR2rF5AB44y4O5uwtgxOhhhvL+Yz GLsOOUuqzRUC4iBBBY6KIFReLvPtjaovuUnfx7VRQe5kf8BPAV3R6y7uktz8RBtrCO/5 /n5WViq8sHxtJzEXpSQIze5PwVfRp8cKinxTryuxlik1Lh3Y3/yAn51y74C7RS1nHQSE sIow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737538276; x=1738143076; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zX6wKmzI06nCmXct1pzxbuNtoEp265I9BJm+57rS6fc=; b=dZLC7YuaQkHCp1bHTMtExVWK3qy/5m7Y7103HWk4/U6d9IWeEAIuIZL4nlwmyKB6Z1 c4TQ8RRuekvSPDyb2mSBr+us9orO6xjwvQnH+/2P1BrW/JjsP/vOKIM7Ym0/GDgzUMKw eVGfD8rS2glp1qcSOfCcl69orgc4lamBT/LzlCU18Ft1+B14bG1mmNMSpR1ZcHVdl0Ds ObxK8n6vqWR+AJ6FTDtufPtyzQHC7fIHedUYMDSX9BvMjvzPUvG8BYycZjEnCTNtOnhs 9yfdpCqrxiTlWcUBXA3MAKtibuV12h4natnJ/Vqe0ETnrft+TO7yI/CwwFmDjFzCvBC2 q8Kw== X-Gm-Message-State: AOJu0YwOjgFjGiE0WslXOHEr6Y2Rj3zIukdkESpQ4s4lMNPGTkiSfn+G d4YmhzOr37Ojw6HeIjBO6qURsjaEZqICZzW6Eq2bpJyaH+cvYQ67aDWBlRVKc9m6o/HxvGBpzWX nGFQ= X-Gm-Gg: ASbGncvpc2V5HbFioNFTD8pZ3cB1PSCtNdkwZeorDx4Q1ScV6IlzRURpZb/PF3SJ2OT 6DZj+3BoFT8Mrxxrhiepg2/Atm5ArN6XpJR3K2eedrpdep/9EqlLXLmOPkZog8jDnt4PjDQjOmw pBUVl7AMy4N0WjPvhbbu03i5fYFwpjifL+oAlEOIYveaNbAwLRxcDqLkySAmWbn5R8yBFSXdSPD iPT6Ri8/nFaIU+q45XaR6W+uL8PhsaSlW6jxn9FXgInegIrc3NlX8wgCCs77su2YNSPdrqsRpmd yjCMzGvfUw9D0KPWiesaazs22AljF4mYKFG0RQhy4VpB X-Google-Smtp-Source: AGHT+IG6O9YAZndqYHtLAOIJrxfLy8HdpLW0g3XjNE4dMucyHCtbEMrzySz5+yEgU7OfImhUVkvOdw== X-Received: by 2002:a05:600c:83ce:b0:436:ed33:1535 with SMTP id 5b1f17b1804b1-438913e0384mr202379415e9.12.1737538276486; Wed, 22 Jan 2025 01:31:16 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b318aae1sm17628795e9.1.2025.01.22.01.31.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jan 2025 01:31:16 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v2 10/10] target/arm: Prefer cached CpuClass over CPU_GET_CLASS() macro Date: Wed, 22 Jan 2025 10:30:28 +0100 Message-ID: <20250122093028.52416-11-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250122093028.52416-1-philmd@linaro.org> References: <20250122093028.52416-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org CpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/arm/cpu.c | 3 +-- target/arm/tcg/cpu-v7m.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index dc0231233a6..048b825a006 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -846,7 +846,6 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - CPUClass *cc = CPU_GET_CLASS(cs); CPUARMState *env = cpu_env(cs); uint32_t cur_el = arm_current_el(env); bool secure = arm_is_secure(env); @@ -946,7 +945,7 @@ static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) found: cs->exception_index = excp_idx; env->exception.target_el = target_el; - cc->tcg_ops->do_interrupt(cs); + cs->cc->tcg_ops->do_interrupt(cs); return true; } diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c index 03acdf83e00..d2d0b94b630 100644 --- a/target/arm/tcg/cpu-v7m.c +++ b/target/arm/tcg/cpu-v7m.c @@ -19,7 +19,6 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { - CPUClass *cc = CPU_GET_CLASS(cs); ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; bool ret = false; @@ -35,7 +34,7 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) if (interrupt_request & CPU_INTERRUPT_HARD && (armv7m_nvic_can_take_pending_exception(env->nvic))) { cs->exception_index = EXCP_IRQ; - cc->tcg_ops->do_interrupt(cs); + cs->cc->tcg_ops->do_interrupt(cs); ret = true; } return ret;