From patchwork Wed May 15 20:23:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 796998 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp3164112wra; Wed, 15 May 2024 13:24:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVnQP9XL1exNkB7UlrVKeKrlxkcYDmBqp4PntICr9jvxcLcoTA3gMWVtEEdang1qLYT9F3QbspXE3ZhHEGwCxIE X-Google-Smtp-Source: AGHT+IE/OUQcbDL68tjLnSFfpFEBxfPEDlifPXqoGagc787sB7IMVyyKn65/P12rv1Rnaaajfezy X-Received: by 2002:a05:622a:24d:b0:43a:8353:775c with SMTP id d75a77b69052e-43dfdb0706fmr187877021cf.2.1715804687892; Wed, 15 May 2024 13:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715804687; cv=none; d=google.com; s=arc-20160816; b=FFVew70XZNPl7i9P6rUCxmAorTqrMN8CTh5beuZlBaoPh9iqIUYhBk/toHuCeZxnIX PF/khSYsuMMBnCyPPX08o01fMcRkQfigESLJmJdwwquHMQg4XS2nEpQTV6t4NP40hNVY ic4i2ok14B52+q/844bsrvsEXEpNalzb5MhdLNiu6Id23sMr8Ls0o4x8fAipYZDfSBhl clM/PKKLUjjMs+9JrYFazqiaVQNzu68fdPCoW7AVbtNsr3iQIvST7vmG/rtm+ist62wC ZRfyvhelNqRxaHVGLoj6SQ3lEQGSu2BcftNQjQT91YbcgKpnSQM3dOKLyr9kKJ/orV3D lgiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V17NPaQQwwHMnN3X6cxvn5az3/KcYU/7IcYrIEVuRSU=; fh=yDxfNhc8BtztgaqLxt926N+a7HyqjTE3aLn3d46icR0=; b=hxBauaW8MKBo/lY6jXNinHgvEkQosaW862fQcfkZiV85PyDB3Wt22Iq5/aI7bpSMd3 Fe268JlmTkSRwLpIWQxEJS1slcH4l3Zc8FHULA/W9B74gRAI5jGMy5mu2xfClRY3f0yc e/XGRrUmz+OvDgFCowYWT5Mb71JzrrGjxXlisMud3BsCRfiIuRq8hPHUHi9T6eDGIuv9 BvFZHFhwrP/L6TOriA46k/2Q0LRqOJ2Lde4aYTkuOGIZpXPyNmv/Cie5fxQ8tlBV7zU0 P4ZkEmTANcyOZI75yvfSxlg7appVbK+ceYKBbepjRa1wXF4/HtkhROo/wq06zBh4roXh hClQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J27kGr3N; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-43df566f522si150302421cf.338.2024.05.15.13.24.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 May 2024 13:24:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J27kGr3N; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7LAF-00019q-EF; Wed, 15 May 2024 16:23:51 -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 1s7LA7-00012q-QN for qemu-devel@nongnu.org; Wed, 15 May 2024 16:23:44 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s7LA3-0004Et-Ux for qemu-devel@nongnu.org; Wed, 15 May 2024 16:23:43 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a5a1054cf61so263046566b.1 for ; Wed, 15 May 2024 13:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715804618; x=1716409418; 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=V17NPaQQwwHMnN3X6cxvn5az3/KcYU/7IcYrIEVuRSU=; b=J27kGr3NrhoJUnyhibWV7k5rqj0+0g0OOnIaFrO6EkyxlHKtRw6PLxUf9XRAHe6R2w Rr+lkc+EVfka6Jxmf+D86K2kaJ6QDLk04sd6bq9iCT4rvhw7ErcvSFCjMGJsU8BRPOY/ mRHvP56rlixyC1z9Ubs1T3aBqm5LpYGK5+tW7B15cxY+ivg5J38211zcvg2+0YvW1LJj Y7OcUHBCHms5Jyi6PgmwRw7ZQBf7D8ZTgoKRhiIxpA2z7NbwCNYqXvv8IDffTipNgoJg h7Kt7UruJ1pYuBjbfn71j/XnhLN2zNFOuTOGXbBqqfODvYMUg4OwDQteOllWI6QDG8Lr aNpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715804618; x=1716409418; 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=V17NPaQQwwHMnN3X6cxvn5az3/KcYU/7IcYrIEVuRSU=; b=VdNoj+HJRlorLDX0nlWQ9a6usUoTC5Pcg1ex04ysYX6G1qok1/YKlFFVUPI/MNtgun qPgUa9LfUD8jQnxs83nI0ziNsGL9VsnDeZZdRCiM1D5okiACKeaUN8fk8AB/8pT93p9b hp65Yxgwh3zkYJkkVVWVEK1eDNMiEG3jLo3+jrngAEcKs9UXPAjx2TQyJfnh/TzNFVHv YpZ8clwS05OXMlmeIi2E3ktmWZuORzFWSX2wUplDyzmOCcXahYjyKz31bvCcZ8VUILtW WMjsjjgnO0naGVJQRYswPMvvgB0t80N4wUJmsCShHYXrGTK1tv5ibuoQA2LyXwYjNoCo A/dA== X-Gm-Message-State: AOJu0YyeJGyv6OnDy5uzT8xP74PAmZ8i9LShtdr0W8IQJalS9v02fY/w z1mzMirDQ7rwUkW0wB9FEeKw4RVa0z64GiH40Kgm02SC7mr3NMSWOS9s44CaYqM= X-Received: by 2002:a17:906:1714:b0:a59:b02a:90da with SMTP id a640c23a62f3a-a5a2d67647fmr1463274366b.68.1715804617702; Wed, 15 May 2024 13:23:37 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5cd627e681sm118484366b.150.2024.05.15.13.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 13:23:37 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 039865FA1B; Wed, 15 May 2024 21:23:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , "Michael S . Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini Subject: [PULL 04/11] plugins: extract generate ptr for qemu_plugin_u64 Date: Wed, 15 May 2024 21:23:27 +0100 Message-Id: <20240515202334.710324-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240515202334.710324-1-alex.bennee@linaro.org> References: <20240515202334.710324-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x636.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=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Pierrick Bouvier Plugin operations can access a scoreboard. This function factorizes code generation for accessing entry associated to a given vcpu. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240502211522.346467-3-pierrick.bouvier@linaro.org> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Alex Bennée Message-Id: <20240514174253.694591-5-alex.bennee@linaro.org> diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 4069d51daf..97868781fe 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -113,24 +113,33 @@ static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) tcg_temp_free_i32(cpu_index); } -static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) +static TCGv_ptr gen_plugin_u64_ptr(qemu_plugin_u64 entry) { - GArray *arr = cb->inline_insn.entry.score->data; - size_t offset = cb->inline_insn.entry.offset; - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - TCGv_i64 val = tcg_temp_ebb_new_i64(); TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); + GArray *arr = entry.score->data; + char *base_ptr = arr->data + entry.offset; + size_t entry_size = g_array_get_element_size(arr); + + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); tcg_gen_ld_i32(cpu_index, tcg_env, -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); - tcg_gen_muli_i32(cpu_index, cpu_index, g_array_get_element_size(arr)); + tcg_gen_muli_i32(cpu_index, cpu_index, entry_size); tcg_gen_ext_i32_ptr(ptr, cpu_index); tcg_temp_free_i32(cpu_index); + tcg_gen_addi_ptr(ptr, ptr, (intptr_t) base_ptr); + + return ptr; +} + +static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) +{ + TCGv_ptr ptr = gen_plugin_u64_ptr(cb->inline_insn.entry); + TCGv_i64 val = tcg_temp_ebb_new_i64(); - tcg_gen_addi_ptr(ptr, ptr, (intptr_t)arr->data); - tcg_gen_ld_i64(val, ptr, offset); + tcg_gen_ld_i64(val, ptr, 0); tcg_gen_addi_i64(val, val, cb->inline_insn.imm); - tcg_gen_st_i64(val, ptr, offset); + tcg_gen_st_i64(val, ptr, 0); tcg_temp_free_i64(val); tcg_temp_free_ptr(ptr);