From patchwork Sat Mar 16 01:56:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780747 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489485wrs; Fri, 15 Mar 2024 18:59:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVHZVVSIU/WHksh1DGTuPB6vvdVYQBT8mhZ+/MGn035DHOWD2D+nnMwywP2tBIyz5BBEJoB5mmlZXTZku2xM6YM X-Google-Smtp-Source: AGHT+IFc9kU4G3E+BX0tkBCoZSYUts+gsZTFtio0i61tFUtKl0+xERHXqyLFc2iukX1VybpDQB73 X-Received: by 2002:a05:620a:4513:b0:787:91fc:f940 with SMTP id t19-20020a05620a451300b0078791fcf940mr7562584qkp.48.1710554361107; Fri, 15 Mar 2024 18:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554361; cv=none; d=google.com; s=arc-20160816; b=fgjhTByPchOZkNyneYsWcm/Dv/Vaa1Bj5fci662K4XrH2qH/pNv1uvU6+GSUuMQDTK SrCIIBzqHweqJAK9seCETwMQHolGQr/aU6PMz76mKje39ZhXen7CqOZKtST8Zk9K8/Xw 6qtv0ZBOvceZGsHh250PFKo4jKxxpq7+wJMTeWHX6MGBqzfoaq2miM5n4o1bw1o4kLMT C+5Jw40eXE6sgpLs9r6d58XnYAmKRzkYnBwh/HhUAHRf6PYaTr3k2wXuG/RbbZHvXQSi ZuztSEAV1YEQrGybdsNOX2VSKOzNSO3Zguw/+7bcwV5p3i6hOTnHGSRZnaxZxWExsTYb mMRg== 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=La+2iVCXFm9nixFDLUn8X+dnCJSJftKhHVIhvf5XOuw=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=039iuXOWLiJQOFVPIFQTN+XeekkstzNGbRPiililowZ3b+x4mqSa/mhN54F4nTk4g/ xQrYITX80SfMnW9mRjmlPCFC7OLvYE4qlEtRjh07tsc8X6gxxVC6IBv7mNP2GWzQORPa 1E7PDecOkyLG4jAbMt/w30dMq8JWYYBHxDVjQmMAUDR0epd9Pipyq+HjWIVqyavo8JeN Pd4wNqEzqGXlRWlEaHecwcp67eiEC5CDh1fvOhrHKdXIugp9xGR2dZxt7N4myVDSE+fU ucWier9KXC7qDpkDuCmxfeovF81tFxL0biWFycO6migMSs0yhVi8/XKsP4Pl/B3ZT6qd mbuQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UbByIbor; 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 fq11-20020a056214258b00b006900690c1bbsi4129722qvb.237.2024.03.15.18.59.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:21 -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=UbByIbor; 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 1rlJIq-0002l4-Ho; Fri, 15 Mar 2024 21:57:40 -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 1rlJIk-0002kP-Au for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:34 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIe-0000hc-M2 for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:31 -0400 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-29bc1c64a98so1946826a91.1 for ; Fri, 15 Mar 2024 18:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554247; x=1711159047; 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=La+2iVCXFm9nixFDLUn8X+dnCJSJftKhHVIhvf5XOuw=; b=UbByIborFU+07bEtkql2HaZgGO+2WrNsRwLjU/D/K7pHmbpPFREQahp+EZGsWNK/ST r0+cZliaDrPnjfiPqCFFbI16h92UqNx/wo/p6rffM9Bq0nFVJYrX/OzX281aDim4NCW2 +vnRvPcs2stOmp3hyxl3ggWioKcYFfWJU5piBm5w/59NCL8Fp8u785aVtJ2SraCDEjVJ kEhgjMyonW95wjKeW3xFX+ibsRCS2zh37k58oPCUaeByxFB6ydHgEgYKqudzR7VuwenW XTJA11DwWcARhcaIZkwZmNgy0RFx0XfhzcXmaj2qh6WAAOZUGTboUbd2ck1UPFd/X8wr I2gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554247; x=1711159047; 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=La+2iVCXFm9nixFDLUn8X+dnCJSJftKhHVIhvf5XOuw=; b=rqX9M/BEYBoAPKMfm3k3tv+OwpOUd8MkdYweDSmKdUx7OSOMG2bURtjTKOqTjCcutO aF7k4Bnni3RsYaEXoMuilzDSNRq3fDbA8ryNfVLcoekwuFAuI6Dj8AkjinNGnv+xUUFK de2tHR3b3cBxzef+1LYiZMVbqrpjBqws6dpM5sgLNyIjefxzX0snIRmbrUy6wKRzhrVM lCBiqsvYOh+L/OcvEPlrUs5rCnfSi6htBSH+QD5nWAxwM8I64TfWA/B5ZhHgfhqMvCyj 4l50r0MyIAyuJPfzggdRmvHH+wyXyFNsb5e6+97/0N3zwQmFItOA+FyqPZpOI3HSmqZ6 EaTQ== X-Gm-Message-State: AOJu0YzBThk6B1X0T8JjoHJGJZijLaPyJgOx/FYzMso5ulpEWhs5ngGy PB4Aw5CQBf3x8edFXNlrKJsFKSE47uiR9gBVoy1mX151FIgrCCe/aX9Anuyw6h0JSzTF/0kp/e+ 0 X-Received: by 2002:a17:902:e5c3:b0:1dd:66d4:4d46 with SMTP id u3-20020a170902e5c300b001dd66d44d46mr4935155plf.66.1710554247145; Fri, 15 Mar 2024 18:57:27 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 01/22] tcg: Add TCGContext.emit_before_op Date: Fri, 15 Mar 2024 15:56:59 -1000 Message-Id: <20240316015720.3661236-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Allow operations to be emitted via normal expanders into the middle of the opcode stream. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/tcg/tcg.h | 1 + tcg/tcg.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 451f3fec41..e9d05f40b0 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -552,6 +552,7 @@ struct TCGContext { QTAILQ_HEAD(, TCGOp) ops, free_ops; QSIMPLEQ_HEAD(, TCGLabel) labels; + TCGOp *emit_before_op; /* Tells which temporary holds a given register. It does not take into account fixed registers */ diff --git a/tcg/tcg.c b/tcg/tcg.c index d6670237fb..0c0bb9d169 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1521,6 +1521,7 @@ void tcg_func_start(TCGContext *s) QTAILQ_INIT(&s->ops); QTAILQ_INIT(&s->free_ops); + s->emit_before_op = NULL; QSIMPLEQ_INIT(&s->labels); tcg_debug_assert(s->addr_type == TCG_TYPE_I32 || @@ -2332,7 +2333,11 @@ static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) op->args[pi++] = (uintptr_t)info; tcg_debug_assert(pi == total_args); - QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + if (tcg_ctx->emit_before_op) { + QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link); + } else { + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + } tcg_debug_assert(n_extend < ARRAY_SIZE(extend_free)); for (i = 0; i < n_extend; ++i) { @@ -3215,7 +3220,12 @@ static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs) TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs) { TCGOp *op = tcg_op_alloc(opc, nargs); - QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + + if (tcg_ctx->emit_before_op) { + QTAILQ_INSERT_BEFORE(tcg_ctx->emit_before_op, op, link); + } else { + QTAILQ_INSERT_TAIL(&tcg_ctx->ops, op, link); + } return op; } From patchwork Sat Mar 16 01:57:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780752 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489565wrs; Fri, 15 Mar 2024 18:59:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXaVY8d85jXVuq8CthCHELC+WBLB8t7Zwn3cUsuKWAbz7+q910JWcO7Gcto33z0B0sQq3JWs+MXGnzTdV3YACRj X-Google-Smtp-Source: AGHT+IGbi80RmLrX4B5mEADGWc9cZTnYdlrrZLujnPt5/bjtd4Kk57476OTW/kjaDeiPJRxt7bEq X-Received: by 2002:a05:622a:134e:b0:430:a090:9ede with SMTP id w14-20020a05622a134e00b00430a0909edemr6423995qtk.22.1710554386812; Fri, 15 Mar 2024 18:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554386; cv=none; d=google.com; s=arc-20160816; b=U1mxLmc9F9L2WUDsbZB7wIDXtMAiGwyxHZWZ/EX4GZRpHx2NteCoV4rOL9WeDpxl3f 3UrM5QTjN/HcqrYrm3nm0FozV0lf8hf2bVf87WCAXGMZLXqQt/Dmynn0L2qT4wldmb72 DYV3lUkEijvHVPcyrQNAG7vAhecGz+uWewV0SU0X/yMeulZktwHNYwsKFkBG+fd9m62k gTE7TBCGpFQVfM9O7r35iq6mcdKLFm4StQaHKWlSrKavOojiyz1YK+HB4Q73MAjTvjek cnAdgdUjxlA3//iGKzQIXkPnWralDMtgovKB4FOO6LXx6rJNn49LjYs4cXhzCN2HQz/X nMjA== 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=W87lWQOU4ax1d83X8hX13Y9WQtWIQCcPTltB0qvJM70=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=e2c2z6020CayVL7F0szATHM6eFSXKqm2JZYDdtB2Dv+leGEGZBHXM1GRKwQqBb0YM/ FQlwjuRCzGwLJSkP2sshfJZZWp/6T6nqc1y+U8XERZiNcBYr55f9cV2IOW7/faOffjxI HltKRFAtvGko0mXuTmWmomTKvQUEIHT1rICYiuWFD6JoyelW0lgU7VXyMnoYLhVvpE6A NhaOq6R9DBFvmbg/3h8NPWMRNrdB00tXjBsPCMkIadHDgTqF/BjCEu/B6aQdv6qdaJoW tbRokqcPQp0bvry9JMMn6e1IpZG76/w+tgwZWRchfPDekpp5ridiBA4Cg8Bsd6EEsHK9 DfIw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AIQo43I3; 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 p12-20020a05622a13cc00b0042eed673e05si5035131qtk.564.2024.03.15.18.59.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:46 -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=AIQo43I3; 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 1rlJIs-0002lu-MJ; Fri, 15 Mar 2024 21:57:42 -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 1rlJIo-0002km-2s for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:38 -0400 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIh-0000hl-KD for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:34 -0400 Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3669ab1bd67so4254515ab.1 for ; Fri, 15 Mar 2024 18:57:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554249; x=1711159049; 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=W87lWQOU4ax1d83X8hX13Y9WQtWIQCcPTltB0qvJM70=; b=AIQo43I3t2V1LJ17A2hRa72kF+jhXnvvp7xatxpgh7PyuB9Vc2yq2iep0DDU0zmZB4 koazckSCakmRYS6HtrfSK+YsUJu4qQwm5ZiwdXzFXi0mpCHHmzLIbt0mBTFXSAuWX8Q4 3c/Lop9n2AGdeaVczyAnkO2EJsjDI6Jebs6WTN9fhFwMmYlgbRU+puDExp3fWwdTVFoI YbznQ4Mbw2bfyAgsHRogYq1wJhD2cw6npphVcET1ino7K7e6Um3O20VEZdWoBF0VBryy pQXOKEcnEfhupZfPVxUa1XnzdGDr0w6Ss63b7dofXOiYx6+8u2uN5VXnoWMlLDE2d9F/ o+6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554249; x=1711159049; 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=W87lWQOU4ax1d83X8hX13Y9WQtWIQCcPTltB0qvJM70=; b=tR4KUy3TFbdiQWA4O2+ZMAU4q4bW8p8EHGrjuEGBWOsP2VV+v2zAKSXvHTxpOXwwqT 4YlMp0xi8CAaqvAJ0HWdWvLdV2n2f157zFt501sHuH2QfKuoqJMic4DIRiN1UlXARq9u rp/6Jpw1j7MkNcQMs88Dv1bMyk8jHZtIdozXXc1i6PmTSEBqFQhoLI39S6NzH7yZvpa1 iGew9dfqp+NFkesTibMY12BRgdtI3TV8vbSLlkmFAiP8ovtg5khBD1lfmisrhity83U2 YvjHrQLCZ9tzGLLfxZhz3c2QnkNePxtgCovHkwS6v+mquoOSEVD3a/gIQebByWLbF2Iw QrUw== X-Gm-Message-State: AOJu0Yzn+GYHSX9g5JG0aqCz6yAqWHp9y3o64oBE5h8JNyq3R3/FV3z6 5VNEEt0XGSZPXGF4dq8fa7Vcsx8kBK054JMVw7m2o4hJaKwC76ghZku9X4V4XjyRe+dufcdQP7O j X-Received: by 2002:a92:d952:0:b0:365:d2be:3de6 with SMTP id l18-20020a92d952000000b00365d2be3de6mr5038549ilq.2.1710554249490; Fri, 15 Mar 2024 18:57:29 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 02/22] tcg: Make tcg/helper-info.h self-contained Date: Fri, 15 Mar 2024 15:57:00 -1000 Message-Id: <20240316015720.3661236-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::12d; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x12d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move MAX_CALL_IARGS from tcg.h and include for the define of TCG_TARGET_REG_BITS. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/tcg/helper-info.h | 3 +++ include/tcg/tcg.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/tcg/helper-info.h b/include/tcg/helper-info.h index 7c27d6164a..909fe73afa 100644 --- a/include/tcg/helper-info.h +++ b/include/tcg/helper-info.h @@ -12,6 +12,9 @@ #ifdef CONFIG_TCG_INTERPRETER #include #endif +#include "tcg-target-reg-bits.h" + +#define MAX_CALL_IARGS 7 /* * Describe the calling convention of a given argument type. diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index e9d05f40b0..a6e7df146a 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -39,8 +39,6 @@ /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 266 -#define MAX_CALL_IARGS 7 - #define CPU_TEMP_BUF_NLONGS 128 #define TCG_STATIC_FRAME_SIZE (CPU_TEMP_BUF_NLONGS * sizeof(long)) From patchwork Sat Mar 16 01:57:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780759 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489972wrs; Fri, 15 Mar 2024 19:00:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXT2t3fup3pC/BWVCYKWsXBJGPA8sEzU7X44oLVRHa9wZekYTtVXua17npihvlwDzDu9xZQr04zlNsuJxBAQK63 X-Google-Smtp-Source: AGHT+IG2s1BfZY5cIaJAqaBaL9bOk/ByoqAiehkY5zi84BE4So27mQ0eIZYaYGxHdpGivpjWeQoZ X-Received: by 2002:a05:6808:211b:b0:3c2:51df:4462 with SMTP id r27-20020a056808211b00b003c251df4462mr8123805oiw.2.1710554450258; Fri, 15 Mar 2024 19:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554450; cv=none; d=google.com; s=arc-20160816; b=TQrl6Oyj0oXgFUtFTCoP+QCCBTpp0Y9n/CmHCYuEIPapwzrT/B7IThIBAoPsHzXLCq rknkQXTQnUYI3BnBzhu3+gg7WiTMbKrf/3PEKTwLwZabA6zHDCmT0T1Le4zNup5GrLJS sbTg3GZ2YlnOzsT0u6a5t19sCSr3c7gprfdIhrkwO/uS/05PEfJ6j5PBqpDNMipFZgRz c6LlbiNgs5dfB6NYHOvAXmHPi5Gv2LFOCdW4J9hw7NOSuQujJghQuP0R1UkeyizEStBN KtXmr6vm2r/YzN6M0Hs0xROZqqikxuCynk9sN1EzeQw8odegFE0s0LCnBGqmOr6h8FrS 7ITw== 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=dO/ulOB4H8uJBhCl1h5X1j8smU5S71009KZPyttGPV8=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=QCu7fXYYnpURv/J9JP2UZMdf0K4Usuh9pETGjcmD0O8RUVZsm4NUpuhLB8l+xvSOxO qFgxOmbSlei3PLiXjwKGZKRY+iuM1kmkMMKGqSULqU1w0munTGEgtvNS67yLubT4f5GQ eJyWZsGzoKAcMErhOWiSWXeySkkwuc1HABl+BBl/1/FjkipMHfy5CHOf2qaiHsGIp9Jn FPIBwSjraCEpjHU5m+gWathkmOmR5h0xzOQPyc1WvMrddRti4rmLohgmmbob0KWXK4M0 hEr6cecCu/UtQ3396KjqBCFFAODOHKay+IxRNyHBotdZxCaWDg4yE7zEen59B4RMLDwA S/8A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sYlrfHAw; 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 s7-20020a05622a178700b0042f2128b42fsi4999710qtk.459.2024.03.15.19.00.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 19:00:50 -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=sYlrfHAw; 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 1rlJIs-0002lv-Qt; Fri, 15 Mar 2024 21:57:42 -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 1rlJIq-0002l6-La for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:40 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIj-0000ht-Ef for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:35 -0400 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-29e0229d6b5so711239a91.3 for ; Fri, 15 Mar 2024 18:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554251; x=1711159051; 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=dO/ulOB4H8uJBhCl1h5X1j8smU5S71009KZPyttGPV8=; b=sYlrfHAwPX+dQigzS46ZO84vvi54+j2px48b3iUHUt76jzC4dAlgu0OyQiMHApxe3g XM4UayPBHdAMkrHkFb9efPIJft6jWAghgT2n91cfqj3v0AhmgUN/4/tHhk3fx5UvYDvU Uy1roKF7TtnYZDVYBl4N4KxIASDG++FJxEmlMmMPWlHiQWmqJ7g1AasuJJucRVTYb378 6PUFb79FyPg+Epu+P2CDei1PaggwCTxnpc7kYB62UyKDKvJKnqi+ChM6JH4Q+tEAeTZH S0h2yaUGIfYLNy4iuW8ryaIb4+yU3oExlIazo4QaWiB9nC5r5FDR6z3PjIkqLs6/WSaN v8HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554251; x=1711159051; 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=dO/ulOB4H8uJBhCl1h5X1j8smU5S71009KZPyttGPV8=; b=WpShWlCTG3LKwUz6uXOkd9LS9cO0TSRBT6KL6xaIZcBnVwRZkTotBDBkwnj1JTUYXt c8CWVXvzJ0Rh8nwrkGIAzVF5hjuGviQZ4c1Ov2zPS8PLUQKlQq2h9S7O4fE1qG1dbrqv Fy7Y0CdiUO/nkj1/k61L852yMiU4/5LdQMgSg6mwxdVxvOUqexsMt2YynS+LLrsOJHVV rupbAHjxSAJ0kerlaM3bojOF6Em/XmO+nnoLLd3q59bCOHBsSmt2ZBna2q9IkRax+tc8 B7BSCygeP3TwfW0WRye08l2GDWgURCqbsK5gWfT/o6yr0jlWZybZuBjQk1lBQ3KR43z+ 1NMQ== X-Gm-Message-State: AOJu0YxyDH/XX6yh1MSRuFZp8VXqh2ZYeji2NpggGPU6eIV69vrgVBZE o4w50T9IsAvb0YT3c02EYLj56y9/8P9LInc2aAV0Vtz8JNc8A8yTpkqG/16Ce9aFmE8qDsSfp3B 9 X-Received: by 2002:a17:902:f7d3:b0:1dd:b505:d556 with SMTP id h19-20020a170902f7d300b001ddb505d556mr5377907plw.21.1710554251553; Fri, 15 Mar 2024 18:57:31 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 03/22] tcg: Pass function pointer to tcg_gen_call* Date: Fri, 15 Mar 2024 15:57:01 -1000 Message-Id: <20240316015720.3661236-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For normal helpers, read the function pointer from the structure earlier. For plugins, this will allow the function pointer to come from elsewhere. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/tcg/tcg.h | 21 +++++++++------- include/exec/helper-gen.h.inc | 24 ++++++++++++------- tcg/tcg.c | 45 +++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index a6e7df146a..95a7f4d010 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -847,19 +847,22 @@ typedef struct TCGTargetOpDef { bool tcg_op_supported(TCGOpcode op); -void tcg_gen_call0(TCGHelperInfo *, TCGTemp *ret); -void tcg_gen_call1(TCGHelperInfo *, TCGTemp *ret, TCGTemp *); -void tcg_gen_call2(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *); -void tcg_gen_call3(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, +void tcg_gen_call0(void *func, TCGHelperInfo *, TCGTemp *ret); +void tcg_gen_call1(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *); +void tcg_gen_call2(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *); -void tcg_gen_call4(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, - TCGTemp *, TCGTemp *); -void tcg_gen_call5(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, +void tcg_gen_call3(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, TCGTemp *); -void tcg_gen_call6(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, +void tcg_gen_call4(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *); -void tcg_gen_call7(TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, +void tcg_gen_call5(void *func, TCGHelperInfo *, TCGTemp *ret, TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *); +void tcg_gen_call6(void *func, TCGHelperInfo *, TCGTemp *ret, + TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *, + TCGTemp *, TCGTemp *); +void tcg_gen_call7(void *func, TCGHelperInfo *, TCGTemp *ret, + TCGTemp *, TCGTemp *, TCGTemp *, TCGTemp *, + TCGTemp *, TCGTemp *, TCGTemp *); TCGOp *tcg_emit_op(TCGOpcode opc, unsigned nargs); void tcg_op_remove(TCGContext *s, TCGOp *op); diff --git a/include/exec/helper-gen.h.inc b/include/exec/helper-gen.h.inc index c009641517..f7eb59b6c1 100644 --- a/include/exec/helper-gen.h.inc +++ b/include/exec/helper-gen.h.inc @@ -14,7 +14,8 @@ extern TCGHelperInfo glue(helper_info_, name); \ static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret)) \ { \ - tcg_gen_call0(&glue(helper_info_, name), dh_retvar(ret)); \ + tcg_gen_call0(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret)); \ } #define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ @@ -22,7 +23,8 @@ extern TCGHelperInfo glue(helper_info_, name); \ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1)) \ { \ - tcg_gen_call1(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call1(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1)); \ } @@ -31,7 +33,8 @@ extern TCGHelperInfo glue(helper_info_, name); \ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2)) \ { \ - tcg_gen_call2(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call2(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2)); \ } @@ -40,7 +43,8 @@ extern TCGHelperInfo glue(helper_info_, name); \ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \ { \ - tcg_gen_call3(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call3(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3)); \ } @@ -50,7 +54,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), \ dh_arg_decl(t3, 3), dh_arg_decl(t4, 4)) \ { \ - tcg_gen_call4(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call4(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), \ dh_arg(t3, 3), dh_arg(t4, 4)); \ } @@ -61,7 +66,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), \ dh_arg_decl(t4, 4), dh_arg_decl(t5, 5)) \ { \ - tcg_gen_call5(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call5(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3), \ dh_arg(t4, 4), dh_arg(t5, 5)); \ } @@ -72,7 +78,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), \ dh_arg_decl(t4, 4), dh_arg_decl(t5, 5), dh_arg_decl(t6, 6)) \ { \ - tcg_gen_call6(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call6(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3), \ dh_arg(t4, 4), dh_arg(t5, 5), dh_arg(t6, 6)); \ } @@ -84,7 +91,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ dh_arg_decl(t4, 4), dh_arg_decl(t5, 5), dh_arg_decl(t6, 6), \ dh_arg_decl(t7, 7)) \ { \ - tcg_gen_call7(&glue(helper_info_, name), dh_retvar(ret), \ + tcg_gen_call7(glue(helper_info_,name).func, \ + &glue(helper_info_,name), dh_retvar(ret), \ dh_arg(t1, 1), dh_arg(t2, 2), dh_arg(t3, 3), \ dh_arg(t4, 4), dh_arg(t5, 5), dh_arg(t6, 6), \ dh_arg(t7, 7)); \ diff --git a/tcg/tcg.c b/tcg/tcg.c index 0c0bb9d169..0bf218314b 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2251,7 +2251,8 @@ bool tcg_op_supported(TCGOpcode op) static TCGOp *tcg_op_alloc(TCGOpcode opc, unsigned nargs); -static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) +static void tcg_gen_callN(void *func, TCGHelperInfo *info, + TCGTemp *ret, TCGTemp **args) { TCGv_i64 extend_free[MAX_CALL_IARGS]; int n_extend = 0; @@ -2329,7 +2330,7 @@ static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) g_assert_not_reached(); } } - op->args[pi++] = (uintptr_t)info->func; + op->args[pi++] = (uintptr_t)func; op->args[pi++] = (uintptr_t)info; tcg_debug_assert(pi == total_args); @@ -2345,56 +2346,58 @@ static void tcg_gen_callN(TCGHelperInfo *info, TCGTemp *ret, TCGTemp **args) } } -void tcg_gen_call0(TCGHelperInfo *info, TCGTemp *ret) +void tcg_gen_call0(void *func, TCGHelperInfo *info, TCGTemp *ret) { - tcg_gen_callN(info, ret, NULL); + tcg_gen_callN(func, info, ret, NULL); } -void tcg_gen_call1(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1) +void tcg_gen_call1(void *func, TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1) { - tcg_gen_callN(info, ret, &t1); + tcg_gen_callN(func, info, ret, &t1); } -void tcg_gen_call2(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, TCGTemp *t2) +void tcg_gen_call2(void *func, TCGHelperInfo *info, TCGTemp *ret, + TCGTemp *t1, TCGTemp *t2) { TCGTemp *args[2] = { t1, t2 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call3(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, - TCGTemp *t2, TCGTemp *t3) +void tcg_gen_call3(void *func, TCGHelperInfo *info, TCGTemp *ret, + TCGTemp *t1, TCGTemp *t2, TCGTemp *t3) { TCGTemp *args[3] = { t1, t2, t3 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call4(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, - TCGTemp *t2, TCGTemp *t3, TCGTemp *t4) +void tcg_gen_call4(void *func, TCGHelperInfo *info, TCGTemp *ret, + TCGTemp *t1, TCGTemp *t2, TCGTemp *t3, TCGTemp *t4) { TCGTemp *args[4] = { t1, t2, t3, t4 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call5(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, +void tcg_gen_call5(void *func, TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, TCGTemp *t2, TCGTemp *t3, TCGTemp *t4, TCGTemp *t5) { TCGTemp *args[5] = { t1, t2, t3, t4, t5 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call6(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, TCGTemp *t2, - TCGTemp *t3, TCGTemp *t4, TCGTemp *t5, TCGTemp *t6) +void tcg_gen_call6(void *func, TCGHelperInfo *info, TCGTemp *ret, + TCGTemp *t1, TCGTemp *t2, TCGTemp *t3, + TCGTemp *t4, TCGTemp *t5, TCGTemp *t6) { TCGTemp *args[6] = { t1, t2, t3, t4, t5, t6 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } -void tcg_gen_call7(TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, +void tcg_gen_call7(void *func, TCGHelperInfo *info, TCGTemp *ret, TCGTemp *t1, TCGTemp *t2, TCGTemp *t3, TCGTemp *t4, TCGTemp *t5, TCGTemp *t6, TCGTemp *t7) { TCGTemp *args[7] = { t1, t2, t3, t4, t5, t6, t7 }; - tcg_gen_callN(info, ret, args); + tcg_gen_callN(func, info, ret, args); } static void tcg_reg_alloc_start(TCGContext *s) From patchwork Sat Mar 16 01:57:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780758 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489920wrs; Fri, 15 Mar 2024 19:00:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVjyODmowof0wiupqqRa/dS7hAddh6MxsAix8986I/OxJNWED1Ypcj8t9ULMCClXoQtFjxOgaGvngVhfexG4yKl X-Google-Smtp-Source: AGHT+IFmU27AFaw9SafQ3I3Q1VRTV0E8K/i74DeGQ9EHttm/5XB3EUme9JeAhYsEVmgUUn0PU9YF X-Received: by 2002:a05:6214:180d:b0:690:b27f:1b24 with SMTP id o13-20020a056214180d00b00690b27f1b24mr7170992qvw.12.1710554443268; Fri, 15 Mar 2024 19:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554443; cv=none; d=google.com; s=arc-20160816; b=TpAURXXHXrjuHHHei5a+C0taYiFI/tn/INs3XVFQt7lSyZ9mr3vAQGah1bK2woSCOZ F1PYAvIjCL0zWHkWvwhfgBclJOZAPMlcI4oI1W2kz3f+ZbeabOgGPDLJKca7AeR3bfRt Ea4Zh0ZPbJQNOJ4p12LPTcdjdjKB9MfBgvGk5Vx9NC82WMcPNnhkUm1GKQydLfpapS5J jrFL1tM82VqHX74jzTP2xb1MjAmLqfhyWRlzXOiqezg1td49z7IHIQZaDMYYB60SxVW/ kzC7I3YgAg/PHU09P9qqEaHUxabst0V4e6ebYHTLH+0aQsKKxchfvj2bm7U5DfhNGo/j VyQQ== 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=4I6ltn5r5eQP6OaKsPETbZYIZfsGGG0xeYi8oAp9EDY=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=TYiQp7dDWzTiQpluTzhx4e6MEvmteSN/ez+hlYmk7w7I0qcL/ADHoGyhq6JQH7ph8L kl+vX/XKMCfhPuvQunb6j/FgdYFzvI7U65yGr/4UWtKKjO0NsefFEu1mXlS157zpNKsH xnFJv71F1WnIW0erhqDVnmEPdgJORtg/VGXTXNPNOeJxg2KJ/RYScf/eRTliXRU99btg b81Cs6L7YBKNNYkO+2ekTnYv7YSNxoOZ5buK+TOYYmhOg/uc6dvMZmMmHhoZ3E9lpWQ3 nHk5PpKPeKHaZG5DN+0eNmCLzkiQLzO/Qn+tqVvEzKQdjvWUgBMKmlvGmJGM59fjawNa n1zQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cJxFzdIa; 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 iv7-20020ad45ce7000000b0068fab53dcc3si4449106qvb.64.2024.03.15.19.00.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 19:00:43 -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=cJxFzdIa; 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 1rlJIs-0002le-5E; Fri, 15 Mar 2024 21:57:42 -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 1rlJIq-0002l7-Lx for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:40 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIn-0000i4-Ar for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:39 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1dddbeac9f9so19775515ad.3 for ; Fri, 15 Mar 2024 18:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554253; x=1711159053; 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=4I6ltn5r5eQP6OaKsPETbZYIZfsGGG0xeYi8oAp9EDY=; b=cJxFzdIa2pPVmh8TQNEOzOfqED3H+ib7rEIu+9ZI6MqwNWlHMEMSTHUisES5UgEf31 N0dXcuiU+REIyuGYd1gGnHHGi8Eh5U44HyxnpGeOss+AChhX5dBkTJu8dQelcNy1oQIr WPVC8/Vlls/An2gGldkhpk+stxrAdS5q1iU+T8ZVAnybcqG2lVcLA19FiF4PB15A0tE+ +3OHb8YfBq68Kw/Ix0zxU+n6Ln0ZGTd0FPG/Y1f/FSjt4CwNB0PuYtBwioCg91x4DIRc 3cPRhovlBpV6i9cBQAgUBXXHqgMaFs+wcxEMY8Q7WwwI9yXrQyVMq+dsGkXs6kBgoUqV yRHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554253; x=1711159053; 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=4I6ltn5r5eQP6OaKsPETbZYIZfsGGG0xeYi8oAp9EDY=; b=tjyYgCDIpgYOuhjrwHfVEaByTHilPBqanaR1D1uwr9l6YR8k3c4coo8MBSQA1Cg8mG vLSvZsUMStV8FhkgOCYKPsbnA+PRz4DX5JQeXAcVZnMsQDce7fr3IsvIA3C0UZ1X9Itm nw5AJsuwPZ3LKUy0id6cOdHO72vkWvdCh1OfnM9ccxea/zglgTrZnVvpHQtguhnWKfYu SJyghY4F0AzOCVDIbQvvBQi/zj16tiR1t/H8fh3aS1tKhtdDlsSMruYClDu0KSxigWdU UyTo8KcUE4e+gDPyIdBrMn6t/TsWHjO7hwWD+bapw4cZdtFptjKsa3qkzem5HywzTIdl FKuA== X-Gm-Message-State: AOJu0YxGjT3fW/vazXxXo9WJmmrZrHPALi4VDah/IeEqCy4Idl4aYulF GQ6Btktf00J6zt3VMi9dRdOXA2VbWMZIy6S2Tqv7uFUlJhcrue+do6Cs+gxTfcg0lBC5mopxAwv M X-Received: by 2002:a17:903:11c3:b0:1dd:7d6a:d6c8 with SMTP id q3-20020a17090311c300b001dd7d6ad6c8mr7726619plh.14.1710554253537; Fri, 15 Mar 2024 18:57:33 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 04/22] plugins: Zero new qemu_plugin_dyn_cb entries Date: Fri, 15 Mar 2024 15:57:02 -1000 Message-Id: <20240316015720.3661236-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- plugins/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/core.c b/plugins/core.c index 11ca20e626..4487cb7c48 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -307,7 +307,7 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GArray **arr) GArray *cbs = *arr; if (!cbs) { - cbs = g_array_sized_new(false, false, + cbs = g_array_sized_new(false, true, sizeof(struct qemu_plugin_dyn_cb), 1); *arr = cbs; } From patchwork Sat Mar 16 01:57:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780757 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489847wrs; Fri, 15 Mar 2024 19:00:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXhd5Q4eu9IliAFYYX+VDiKdhKF2B50auK/LyAdnYc5lq2ikYzNg7fdWts9i5eUZGbnZN4zvLJKPelLf1ZwiMjR X-Google-Smtp-Source: AGHT+IE6Va4xLl96k4b7TFUOgEI/W00XyT8i2QrTnm1HUphlS9U9f7UfiOxytms4fn5aMZfbu32r X-Received: by 2002:a05:6830:1e14:b0:6e4:dd8a:5f70 with SMTP id s20-20020a0568301e1400b006e4dd8a5f70mr6747437otr.1.1710554431891; Fri, 15 Mar 2024 19:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554431; cv=none; d=google.com; s=arc-20160816; b=wTs301oYhCGbkZJoITs6gPmjialNncbNUu3ePzHbyZzbcy6WUB/MFIslJO0qib5eYP s7jPAwKzYcKjMTDn84KUeM3z84k7E9AyTmZbKOxvfWuC0aNSvjfZln7/464seD9MayBN L4m0BK6Mu1z2EQMDPtE2Y9Nzn01CGlQZxJ07NQHdBb/N5qlb3ZJGdR/ASgrfPLYN+ebT nsMlBBzepDviMuMraynuDZ32Xxlj2TWSDv5+7FZV0bOhhZ97Ms0I2XXdOqDJxQqN+M/1 BJQqt/+pDiNcxbDqUcgbPm9Im7pHoY0SF6yEhDMD22QGoOyl2iqTU/PPV28BluWB6KI7 ELmA== 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=LBMQW30MaUGTTlpQEoDn37zgtsJ/Rvfav+1wxxZ/gso=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=O72JbpwpNGRnWvFw0KENMyVKMDJyANYK0W25Bd4heQrLgh48qVO6yjBWkBACpDB/c3 LtFayuqSsvLu3u0X3knsEUt9NZpO20tDlnds1rwatoMky1imQWbCOkMXOr06ywp6DphK OetFeBDAWymNcqvhry7pD8Y4DwfO9Uf0Y3j7RicqS8rAOX7WIMe7MJzv/vGoF8EhKPno StCoLo9jarDmWnNkMNU0H+ySDij0EJb/mztugokBwNjPyXCWCQyiGzdvls6Wx3DAPVGg BOBqxH6Qco5KYxUkUjKSm62qJuDqy5hNAH+2iHe/rflW4ngSAsyv2p31AvMspvoYyQ+i vRrQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q70sISkV; 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 wk14-20020a05620a578e00b007883963c627si4753174qkn.533.2024.03.15.19.00.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 19:00:31 -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=Q70sISkV; 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 1rlJIt-0002mP-9d; Fri, 15 Mar 2024 21:57:43 -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 1rlJIr-0002lc-Tf for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:42 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIo-0000iM-BF for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:41 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1dddb160a37so19824145ad.2 for ; Fri, 15 Mar 2024 18:57:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554256; x=1711159056; 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=LBMQW30MaUGTTlpQEoDn37zgtsJ/Rvfav+1wxxZ/gso=; b=Q70sISkVt5KfkVxbDCtCbSN2g25bWCAvb4ZjAXLuDplFImEoHcRr55Xsaoyaro3w6X dc31ABX8n/eNPg+oZ4+hJ3/DYG61wIDSwdVOHWcRYhL8KVNXuvQIEVeOakoWq1aaeX+i wUIpiWP6bxjTselLqnFhiTu0/PkDPIxwk3Qq9AKPhOLen/bswqqL6jwfKRsVmZ+jS1JE kjOss8hM5/b0Q3vJNj5G2sPA5jjVJ9AwHzB+0T4Ma60CAB8ekndSdsJOby8t8KVCHKOu OaDj1cAS6pO2QPtyMgBWr/TzFENXg+n3+j2GyxqV/sWWgmtnHHPLmEjx8a+0UH/juioZ J4GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554256; x=1711159056; 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=LBMQW30MaUGTTlpQEoDn37zgtsJ/Rvfav+1wxxZ/gso=; b=XWvlwpsHlhzV4/lf/T+5pTl5z3w1Ov625s1/AaTXEIECHIARFVk6n16Db6P4wU3ozp kQelFXB4gB1zOSrYqjgpuAbuYlKqoT0+u8AQtS1XaZpm0s8hUGlJBQSfGse5IYKaDh5I VH4hUHnfwdVvJrhIJfKfxfNUYhSDvz2ycGWNmtUR37plPmSL/O9vL9mMk3JF5nadL1Sz 2RZJNOcmE6UiCHDCsCv/gizRXWYxBYc3bLW5jD5EzmjI5FmrFaJR6dhXv/ybYI7j0C9h Xzi+SwsXTmaajjBeVotfh9+ZrLsyX6gMibJ5PoSPRMh3f2DB5Cwo8R94Sz7QLdi+GAyP M2qw== X-Gm-Message-State: AOJu0Yx5l4RpZq9WhBiL71Uz+Q+KYkjF/SdR9lnQPlqnMoOhJrBUcAoj V2OAcZZO3kA4LnpxcdQ7n3hFQnNTpHdVkhejNfCoHTUX0echaGvbz4OMBl3QTYL/RW7L96AxUs6 5 X-Received: by 2002:a17:903:2289:b0:1dd:eba:e744 with SMTP id b9-20020a170903228900b001dd0ebae744mr9258058plh.53.1710554256213; Fri, 15 Mar 2024 18:57:36 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 05/22] plugins: Move function pointer in qemu_plugin_dyn_cb Date: Fri, 15 Mar 2024 15:57:03 -1000 Message-Id: <20240316015720.3661236-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The out-of-line function pointer is mutually exclusive with inline expansion, so move it into the union. Wrap the pointer in a structure named 'regular' to match PLUGIN_CB_REGULAR. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/qemu/plugin.h | 4 +++- accel/tcg/plugin-gen.c | 4 ++-- plugins/core.c | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 12a96cea2a..143262dca8 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -84,13 +84,15 @@ enum plugin_dyn_cb_subtype { * instance of a callback to be called upon the execution of a particular TB. */ struct qemu_plugin_dyn_cb { - union qemu_plugin_cb_sig f; void *userp; enum plugin_dyn_cb_subtype type; /* @rw applies to mem callbacks only (both regular and inline) */ enum qemu_plugin_mem_rw rw; /* fields specific to each dyn_cb type go here */ union { + struct { + union qemu_plugin_cb_sig f; + } regular; struct { qemu_plugin_u64 entry; enum qemu_plugin_op op; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 8028786c7b..c56f104aee 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -431,7 +431,7 @@ static TCGOp *append_udata_cb(const struct qemu_plugin_dyn_cb *cb, } /* call */ - op = copy_call(&begin_op, op, cb->f.vcpu_udata, cb_idx); + op = copy_call(&begin_op, op, cb->regular.f.vcpu_udata, cb_idx); return op; } @@ -479,7 +479,7 @@ static TCGOp *append_mem_cb(const struct qemu_plugin_dyn_cb *cb, if (type == PLUGIN_GEN_CB_MEM) { /* call */ - op = copy_call(&begin_op, op, cb->f.vcpu_udata, cb_idx); + op = copy_call(&begin_op, op, cb->regular.f.vcpu_udata, cb_idx); } return op; diff --git a/plugins/core.c b/plugins/core.c index 4487cb7c48..837c373690 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -342,7 +342,7 @@ void plugin_register_dyn_cb__udata(GArray **arr, dyn_cb->userp = udata; /* Note flags are discarded as unused. */ - dyn_cb->f.vcpu_udata = cb; + dyn_cb->regular.f.vcpu_udata = cb; dyn_cb->type = PLUGIN_CB_REGULAR; } @@ -359,7 +359,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr, /* Note flags are discarded as unused. */ dyn_cb->type = PLUGIN_CB_REGULAR; dyn_cb->rw = rw; - dyn_cb->f.generic = cb; + dyn_cb->regular.f.vcpu_mem = cb; } /* @@ -511,8 +511,8 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, } switch (cb->type) { case PLUGIN_CB_REGULAR: - cb->f.vcpu_mem(cpu->cpu_index, make_plugin_meminfo(oi, rw), - vaddr, cb->userp); + cb->regular.f.vcpu_mem(cpu->cpu_index, make_plugin_meminfo(oi, rw), + vaddr, cb->userp); break; case PLUGIN_CB_INLINE: exec_inline_op(cb, cpu->cpu_index); From patchwork Sat Mar 16 01:57:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780760 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp490038wrs; Fri, 15 Mar 2024 19:01:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXRWFKu2MybY0uSvwCGALlvN0l06EPIS82salAxtaTuRUTGtbj+dsdoyhJkAfGum3hnIK9jTO050RdxBVe5hOtl X-Google-Smtp-Source: AGHT+IHc4/t5HPQ5VSlBw/s8u6/XyxsVuR3biW3Rm0LDpR8qOeFQqaFOc9i2KJYKpGUZmpQin+Lq X-Received: by 2002:a05:6214:1854:b0:690:a7ff:521d with SMTP id d20-20020a056214185400b00690a7ff521dmr5769500qvy.6.1710554460810; Fri, 15 Mar 2024 19:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554460; cv=none; d=google.com; s=arc-20160816; b=KSYTmQHPP0dayznXSmIKfxOxoa0Ywdb+1741tprG61+LDXvBNEoojdRVSxMN+V930Z OiHqGxuEXe+gltYS+d/IxK2FyossbTmh6JDbgyotDOAQInFvTuNV5AOzjF5cRf847zOU SEXOC1//rJabP2D0u/mL/CbQXae/JusqunVzNocZXF6Qk/4Iu/PsOYYXxBiZIJy6Vyob Gu7L69N3vL/SFdHEnrac277UHxlqq1q72BDlWY03OsquXcKv2xRliTCwtXdKINyL3Ap/ Kl1afSUU15WKf6Age11H0F3+P65fJtBkRG/fF1viAXosGDlt+mdkfCpzRSAR4KRAUNyw s5NQ== 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=tejnOfEGCIS6beGjus6J1qxofDOH1tfJTZA704n4hj8=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=ctqtKJSJgs6Xtr/+UUfdA3KsjPIJLqJTe4xfTE4rmZ6o1I+5D1IM+rLK/dwO69s8P6 HoGUwEKdEHD70XfoskL9XtvWG/mfsL9EazAYGluCGgrmNd9+7oCj2DT8GDQTc6sWFvZt xejQR6+5qx3YoULyDImasOry7GkMBaN1hlkJ25SrWVqsBIpkEPPoM+2NuT5RO2LSd8Uz tm5sSWcIBpRXvArSh404BZUyHZE58UfvnGki2uYXGDW86pq1s9Pvxiia56TusXaVWORY RjKpvwUzDni5mmoMfP5JmTGoGacGGqHYrdxWxrCXihgw8c8B6y4JoDHlxJXMBDT753Py dXCA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ktHZiDj/"; 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 r2-20020ad45762000000b00690b35046c9si4161550qvx.544.2024.03.15.19.01.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 19:01:00 -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="ktHZiDj/"; 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 1rlJIt-0002nD-R3; Fri, 15 Mar 2024 21:57:43 -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 1rlJIs-0002lf-3t for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:42 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIq-0000ia-Eg for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:41 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5ce6b5e3c4eso1787639a12.2 for ; Fri, 15 Mar 2024 18:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554258; x=1711159058; 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=tejnOfEGCIS6beGjus6J1qxofDOH1tfJTZA704n4hj8=; b=ktHZiDj/SgCjaWxtBrbGmpge3WJ4L/3f9rxbjrEROvynoCl2vpQS76Y7IujQihJbwo YHQgDjJ4tH+lv+z6BSCS6XWD9KeHtLwBbCayfwdl5uQvYkk/7Yh9t7k1kHxSwQyvZeXI Qx1L7Zi9WpZwbm1RRW++FxcslC4RjM/8Mm0/Mfq5D5obUQ+B756aMlzOLeGdfN+psCqo ZnTF7l2EzyHL0a1pLLI+YCb4/Ur2CgnYXgNdk8ThAKmo0arWIgx2kzhDpvtLt9LrR8qm qlLTOo63i/D/cd7mOocOvdelAMEXicaZDy2AEiyLbA1eUR3g6/qG49NVFixm2vNjwJ/6 w68g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554258; x=1711159058; 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=tejnOfEGCIS6beGjus6J1qxofDOH1tfJTZA704n4hj8=; b=iOcgidQyVGKldAZq6QUlNA+iLfAUMf/tFtmeTyaVD4kL+DZRGCRJoaIrkyp+aXAbUe J/Fg9T1ep49gOzE/ZwR+2a4uQH1n6q283iHzEkMKn9FHhqPk+2ZcWCH7pjJIE0BgkQFo te/YU+GCvbKtmG8vQXnUDCWEmeK6T/cw/fC1f26ZFfT90DL6jyVjsumc40+Jh0jGc12z +gFfbdQOpGAoYdqavySzFg5Zi6cjdSMDXhzzO7/wGgYMzDt4zZ6W9yRtl7vZmGpb9DdI E4Jl8tsu1GNYHgtzxuuWP28iZbF9EjQhx5rBytUkWUxGfVfv3QNdmAnZ3P1A+3tVAl/Q YxjQ== X-Gm-Message-State: AOJu0YwFW/0kbrcMUvallSW81OIl27AGzn1nbygUuJPHA1NTm4IK2DsY qk2v1Lmhg+ED2kx/sYdY0g78B7k2JH8frmcUB1FMq7q/lojCiUSj4G7zAFYNuNXeSAK7GyVFiee 4 X-Received: by 2002:a17:902:ce86:b0:1dd:c7ea:81f3 with SMTP id f6-20020a170902ce8600b001ddc7ea81f3mr5679327plg.1.1710554258139; Fri, 15 Mar 2024 18:57:38 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 06/22] plugins: Create TCGHelperInfo for all out-of-line callbacks Date: Fri, 15 Mar 2024 15:57:04 -1000 Message-Id: <20240316015720.3661236-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org TCGHelperInfo includes the ABI for every function call. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/qemu/plugin.h | 1 + plugins/core.c | 51 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 143262dca8..793c44f1f2 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -92,6 +92,7 @@ struct qemu_plugin_dyn_cb { union { struct { union qemu_plugin_cb_sig f; + TCGHelperInfo *info; } regular; struct { qemu_plugin_u64 entry; diff --git a/plugins/core.c b/plugins/core.c index 837c373690..b0a2e80874 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -338,12 +338,26 @@ void plugin_register_dyn_cb__udata(GArray **arr, enum qemu_plugin_cb_flags flags, void *udata) { - struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); + static TCGHelperInfo info[3] = { + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + /* + * Match qemu_plugin_vcpu_udata_cb_t: + * void (*)(uint32_t, void *) + */ + [0 ... 2].typemask = (dh_typemask(void, 0) | + dh_typemask(i32, 1) | + dh_typemask(ptr, 2)) + }; + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - /* Note flags are discarded as unused. */ - dyn_cb->regular.f.vcpu_udata = cb; dyn_cb->type = PLUGIN_CB_REGULAR; + dyn_cb->regular.f.vcpu_udata = cb; + + assert((unsigned)flags < ARRAY_SIZE(info)); + dyn_cb->regular.info = &info[flags]; } void plugin_register_vcpu_mem_cb(GArray **arr, @@ -352,14 +366,39 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata) { - struct qemu_plugin_dyn_cb *dyn_cb; + /* + * Expect that the underlying type for enum qemu_plugin_meminfo_t + * is either int32_t or uint32_t, aka int or unsigned int. + */ + QEMU_BUILD_BUG_ON( + !__builtin_types_compatible_p(qemu_plugin_meminfo_t, uint32_t) && + !__builtin_types_compatible_p(qemu_plugin_meminfo_t, int32_t)); - dyn_cb = plugin_get_dyn_cb(arr); + static TCGHelperInfo info[3] = { + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + /* + * Match qemu_plugin_vcpu_mem_cb_t: + * void (*)(uint32_t, qemu_plugin_meminfo_t, uint64_t, void *) + */ + [0 ... 2].typemask = + (dh_typemask(void, 0) | + dh_typemask(i32, 1) | + (__builtin_types_compatible_p(qemu_plugin_meminfo_t, uint32_t) + ? dh_typemask(i32, 2) : dh_typemask(s32, 2)) | + dh_typemask(i64, 3) | + dh_typemask(ptr, 4)) + }; + + struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - /* Note flags are discarded as unused. */ dyn_cb->type = PLUGIN_CB_REGULAR; dyn_cb->rw = rw; dyn_cb->regular.f.vcpu_mem = cb; + + assert((unsigned)flags < ARRAY_SIZE(info)); + dyn_cb->regular.info = &info[flags]; } /* From patchwork Sat Mar 16 01:57:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780745 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489470wrs; Fri, 15 Mar 2024 18:59:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXCXGBNztStgmO7g72/TGyz6oTL8XvYDF0GnF6PGAT/x8NyEj/HRwCaRgWroAg44b8O84PXSXFfoJP6MObr+5y2 X-Google-Smtp-Source: AGHT+IFJL7nBQQt7vZvYnfgy/5BBrKIszBlq6twEOxaihaLTVYHzw9Larj1yFKU/bAkYGyeKtNXc X-Received: by 2002:a05:620a:55af:b0:789:ecac:7163 with SMTP id vr15-20020a05620a55af00b00789ecac7163mr920903qkn.57.1710554357001; Fri, 15 Mar 2024 18:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554356; cv=none; d=google.com; s=arc-20160816; b=oQZu4HSZtxQLKgMqRkoBajcJpUMa34eI6FKqrLlxw8+Akmo/A68fyOxcD2vd+8E6p/ M625irMEcZAaRSW1jV9peYFa6OUD+of9Wyw0cenoVxonTnZukBc4FzhZi7Ij1SUjLJyc HYyFvyYxYlxygxGAVEaFLrLeUp/NjfD7QQoOON+/oskjsO7Xxr1k6tBGlUtCSqqz7RRd 8rDkR0wpJpzygjT4tHnUSYw7urmNOxKMmV+cHQTh4LrMa7KjP8Ud5rRK70a0V8xQdZwE BGW0UWKByW79okuAev7BWXarrQg4wBsqNmZb4AHtU4VuIzvaRaa/E9Grq+vZj7VpqdBO tIyw== 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=5GryAJXFnUj11zs8uoNqYE1HevxmAcx5O0dvpjg9Kdo=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=RFuI3nhpvDpBu4OBoGGi70eAkiiUXBuL1TbKWSgqe4VkD5Ns2JYBj2Gi6e1Yy89aEL xmCszgOXaTAK5YiDKLReRZthZfkYWj0vtOfFj8f4goDyRXyP/eNhODjZInYu368kKpMv EKqwldUQkcFMuP+pHdXlC1uIZmrPcdOXfw1YbGauTP0wabBLREwB3s0fbGdJv/AFIbTo m+XJ6jPV2Mc0J6vbYzWgE8rlPbER8Vmv+NHKWnDHDQPf5FSjfaw7cI15rIKj+XOSLinu U07ivrUMB4wXaAdOa8/f2OpHEXApMl5v21a4mYbw7EutOZvI2ljjkLDdrN88hTymnx+x wYtw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fr5Rd8qi; 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 y12-20020a05620a09cc00b00789d602d4b9si2140605qky.568.2024.03.15.18.59.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:16 -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=fr5Rd8qi; 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 1rlJIv-0002o0-Fc; Fri, 15 Mar 2024 21:57:45 -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 1rlJIt-0002mU-Ck for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:43 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIr-0000ij-6o for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:43 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-5cdbc4334edso1627687a12.3 for ; Fri, 15 Mar 2024 18:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554260; x=1711159060; 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=5GryAJXFnUj11zs8uoNqYE1HevxmAcx5O0dvpjg9Kdo=; b=fr5Rd8qizMkRpHiKVKSDyTvDZ5N5xCH0fnImn6PdBwpoCHQVTLQ419I5reLDU6gsdv 3Bjw2bcNjv+EI2M4Ksfiw3LOqW3xj4qVYAsSg5xVf7Yr4PBZN1TkQpBW4O6nDuxx5Zhi zuIuFTokXJGapIqYiCuWs1pChPYrT7KM/2Ub+bOMLgPRnRZ8AGW418Lufh5K9yst4MOK U6e+vumKfog98FepOaI3txXLvK6WJ6PIzpwPTgqtisd2j2PYhiPJoUisWXDU/WxubnCw 3nuPwIn3tifD6v5GlZbB6LNIG77M5DytM9vrthjtZyXUHLAtI4KEvdad94fLCZGCdS4B KE7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554260; x=1711159060; 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=5GryAJXFnUj11zs8uoNqYE1HevxmAcx5O0dvpjg9Kdo=; b=YFWEcmR9N0MKMgomnkX4ncvTsO7WgcL8F1qy+WHfs57PPXGnHFcFCHH/1rLr0xHNgk kDUAt+6ZEnhXrmDJhKNNhTj7VDrSbZiKSogyF6eytxKD5IYs23RY+67S/jdk1Y+Xo8p3 WKLiwnk4wndhHFQZhspQN+1uaY5E+qfjrR5FVCrbh9gyc190S4cCCVg510Y0iGDhGAr+ X/r6XdPwFGjB5/hVHyXciASr62ybU1R58I8ON92ejxqRtJDCUxBIOrrFKRAqaWeLdtO5 tWo37FQ01nSdW1ZPucsojdpAb8PjEJGQ2MRDdMMzMQclcxcVCi+Q3onNX+0i4cIYl7MN LzxA== X-Gm-Message-State: AOJu0Yy0V/gHqUVoA9T0hJvxjqnGAqe+p1BI5lCZQXqBVGZm0xjBK2XK TjnSB43P/8q7OJOTrw9uRahBc2aOISXXUlm3RNz6Tlro7nXKatVXhXW2fC/i37grlrFp9DQTOS9 Y X-Received: by 2002:a17:902:7d98:b0:1dd:de0f:c01e with SMTP id a24-20020a1709027d9800b001ddde0fc01emr4439010plm.37.1710554259849; Fri, 15 Mar 2024 18:57:39 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 07/22] plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN Date: Fri, 15 Mar 2024 15:57:05 -1000 Message-Id: <20240316015720.3661236-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Introduce a new plugin_cb op and migrate one operation. By using emit_before_op, we do not need to emit opcodes early and modify them later -- we can simply emit the final set of opcodes once. Signed-off-by: Richard Henderson --- include/tcg/tcg-op-common.h | 1 + include/tcg/tcg-opc.h | 1 + accel/tcg/plugin-gen.c | 74 +++++++++++++++++++++---------------- tcg/tcg-op.c | 5 +++ 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index 2d932a515e..9de5a7f280 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -74,6 +74,7 @@ void tcg_gen_goto_tb(unsigned idx); */ void tcg_gen_lookup_and_goto_ptr(void); +void tcg_gen_plugin_cb(unsigned from); void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr); void tcg_gen_plugin_cb_end(void); diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index b80227fa1c..3b7cb2bce1 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -197,6 +197,7 @@ DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) +DEF(plugin_cb, 0, 0, 1, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index c56f104aee..8fa342b425 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -207,8 +207,7 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { case PLUGIN_GEN_AFTER_INSN: - gen_wrapped(from, PLUGIN_GEN_DISABLE_MEM_HELPER, - gen_empty_mem_helper); + tcg_gen_plugin_cb(from); break; case PLUGIN_GEN_FROM_INSN: /* @@ -614,16 +613,6 @@ static void inject_mem_enable_helper(struct qemu_plugin_tb *ptb, inject_mem_helper(begin_op, arr); } -static void inject_mem_disable_helper(struct qemu_plugin_insn *plugin_insn, - TCGOp *begin_op) -{ - if (likely(!plugin_insn->mem_helper)) { - rm_ops(begin_op); - return; - } - inject_mem_helper(begin_op, NULL); -} - /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { @@ -709,11 +698,14 @@ static void plugin_gen_enable_mem_helper(struct qemu_plugin_tb *ptb, inject_mem_enable_helper(ptb, insn, begin_op); } -static void plugin_gen_disable_mem_helper(struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) +static void gen_disable_mem_helper(struct qemu_plugin_tb *ptb, + struct qemu_plugin_insn *insn) { - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - inject_mem_disable_helper(insn, begin_op); + if (insn->mem_helper) { + tcg_gen_st_ptr(tcg_constant_ptr(0), tcg_env, + offsetof(CPUState, plugin_mem_cbs) - + offsetof(ArchCPU, env)); + } } /* #define DEBUG_PLUGIN_GEN_OPS */ @@ -772,16 +764,49 @@ static void pr_ops(void) static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { - TCGOp *op; + TCGOp *op, *next; int insn_idx = -1; pr_ops(); - QTAILQ_FOREACH(op, &tcg_ctx->ops, link) { + /* + * While injecting code, we cannot afford to reuse any ebb temps + * that might be live within the existing opcode stream. + * The simplest solution is to release them all and create new. + */ + memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps)); + + QTAILQ_FOREACH_SAFE(op, &tcg_ctx->ops, link, next) { switch (op->opc) { case INDEX_op_insn_start: insn_idx++; break; + + case INDEX_op_plugin_cb: + { + enum plugin_gen_from from = op->args[0]; + struct qemu_plugin_insn *insn = NULL; + + if (insn_idx >= 0) { + insn = g_ptr_array_index(plugin_tb->insns, insn_idx); + } + + tcg_ctx->emit_before_op = op; + + switch (from) { + case PLUGIN_GEN_AFTER_INSN: + assert(insn != NULL); + gen_disable_mem_helper(plugin_tb, insn); + break; + default: + g_assert_not_reached(); + } + + tcg_ctx->emit_before_op = NULL; + tcg_op_remove(tcg_ctx, op); + break; + } + case INDEX_op_plugin_cb_start: { enum plugin_gen_from from = op->args[0]; @@ -846,19 +871,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) break; } - case PLUGIN_GEN_AFTER_INSN: - { - g_assert(insn_idx >= 0); - - switch (type) { - case PLUGIN_GEN_DISABLE_MEM_HELPER: - plugin_gen_disable_mem_helper(plugin_tb, op, insn_idx); - break; - default: - g_assert_not_reached(); - } - break; - } default: g_assert_not_reached(); } diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index aa6bc6f57d..0f2026c91c 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -312,6 +312,11 @@ void tcg_gen_mb(TCGBar mb_type) } } +void tcg_gen_plugin_cb(unsigned from) +{ + tcg_gen_op1(INDEX_op_plugin_cb, from); +} + void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr) { tcg_gen_op3(INDEX_op_plugin_cb_start, from, type, wr); From patchwork Sat Mar 16 01:57:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780739 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489363wrs; Fri, 15 Mar 2024 18:58:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU0BnMs7MLd0hG9Za8w6FlbUzFyv7wO5dquFdzEPQmJFfZC7kmwvNEw3ce/RRm4FWeknRnxZMBMt3OoTzljOEhA X-Google-Smtp-Source: AGHT+IH1T34x0e5fI1xLxSXbhX5QxxZi+n8IXgEBloXTa2f8LNvrI/L6UV6b5hY4vPAqTfqbb4Bm X-Received: by 2002:a05:6808:2e96:b0:3c2:2f29:7d72 with SMTP id gt22-20020a0568082e9600b003c22f297d72mr7750992oib.2.1710554332236; Fri, 15 Mar 2024 18:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554332; cv=none; d=google.com; s=arc-20160816; b=tPCE2OXLz0col//GRl+ma6WruGmZkSCARQfAp/GMS3OY5Zded2JbSt8F6K1G/IL1qJ DnfmDq2VvqI8IhxgRKblEiCvzu0V9JPJ6Ej89Lh4AxtHDzjPiwgvkMNNZ+b5FEhqO027 twEHR21mgOeEi9Gt7i+HpQnGqsb6PNo7+koNQIve25H0FuXNbGoXw8NbHq+spEecys1N YMLa4WCgrh2MJXRgKNz88gaTXdSLTF8SzEIfvXEFwJCg7kqhGodNXX0Be2X7UUK47tbf sGu9d6LDeRlfjNS7WuQDTkGU062IW1Z16sYmr8DPzXi5yHfevaie9pfcnWULbpNLWxfd SVTA== 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=lNF27JH3rJLz68kZoTFt9GK2MSk5zOPAV8Ck18ejJIY=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=zIGZCCyPdJ+yEOeAbZaF2/s3gCmYrG65HACdYrg5/W3ASKJzVniH83g0X+s/O4wGEx +TxsoxwZ0mZJv1B/AVXbR3Xknnt3fvQNF6tvl81T1cNLA0SFFcHaF2LCpxdnPfU+x9/o hzHc/+WkAFmhdqbyXcpcfpC/k3AGPsCMUauFLhwgjkejVEUzn+3U+p9YSdkHdV5t1SEX 4LitBneXPzVEpZEf7jF69nNKa8wL/24SDeBKVyBIVJdtx6Xmv87c+KlP2bz0LXRzw2uP mPMHdeKZXtohm3aLefJejXo9MvICH0ah2ZBNJFqUfhNk9h/q7XeEQcvRaEcUKEy9RCQe Q81w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bLYM9M/5"; 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 pt17-20020a056214049100b006910abcaddcsi4035919qvb.111.2024.03.15.18.58.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:58:52 -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="bLYM9M/5"; 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 1rlJIw-0002o3-Bb; Fri, 15 Mar 2024 21:57:46 -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 1rlJIu-0002ne-R2 for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:44 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIt-0000jB-1n for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:44 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dca3951ad9so19696915ad.3 for ; Fri, 15 Mar 2024 18:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554261; x=1711159061; 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=lNF27JH3rJLz68kZoTFt9GK2MSk5zOPAV8Ck18ejJIY=; b=bLYM9M/5r179hXEgx8PeR4rnDvWx30nS8WOz5VJyOaw0y2eVi7ptmRyLZQvEeysSIC 1ozP12sdAhJtUA4noJFuTv1M48pkTnJqlyOaG4quvqH70qn+ldv+yRZvNr4VKIZOgB+R 7IOYhstcRg7UuU7NV40lYrmob4wyea8lIQtCc4FKTfPCxR9xMYULcCC7lHLHbR0tl6qG Lk3jiPf2bDlPNXdmdl8xwBEQ+AiikvaoFspiRG0byt+NIsDeIuTCbd03RibhfxELG5Rp AvWdRsuATPcIk+k20laSDKmNgMa/hByO99g8SNTScpdS7+4Eb2KO7YN2QWczv2/HcQg0 I3vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554261; x=1711159061; 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=lNF27JH3rJLz68kZoTFt9GK2MSk5zOPAV8Ck18ejJIY=; b=m9wzY+CGszLwCDmpzSLn4ScjXx+Ndnlyz6Uw1fb7U9kcwpYXxHW3nGEjlNLUS7e4K9 QW++9nT2HSrcAHi3kENuoR1o50YcHEm8k9g2KW+DMJtqPAQQLVpTVGHAZwEsaN80aUcT 8AmNcQjiwhotKVU1IPysvW+DY9DDhNFhAMKnMMYHSxe57a5I448uasiCtBz2DT4bOqfq 4IaBx5de2Q6kUE4USBjqTmXgLa6hCwI2d9MJnqx5RnrLWdVyhZJFwjI6MqfC9khJ98gP /AnzR1AwFe4LFhtvyU0oBlG7icQLiHxGxKMMBLHdfUD1X0pgMo3nO0UDpySjjbNUXQrc zfBg== X-Gm-Message-State: AOJu0Yz8Xx+pATU+CAVnCOXZeXNMDsZzL9ZAlhh47urwgjqEmTpeCwEk 0Kfin6d33i75zajIsgJ/QQZCY31VsPU+WQGuWg0Bex0OCiwfpf/h7ZCGNLa15bq3ouY94acY+TB 1 X-Received: by 2002:a17:902:e74f:b0:1dd:8c28:8a8d with SMTP id p15-20020a170902e74f00b001dd8c288a8dmr8482107plf.68.1710554261732; Fri, 15 Mar 2024 18:57:41 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 08/22] plugins: Use emit_before_op for PLUGIN_GEN_FROM_TB Date: Fri, 15 Mar 2024 15:57:06 -1000 Message-Id: <20240316015720.3661236-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org By having the qemu_plugin_cb_flags be recorded in the TCGHelperInfo, we no longer need to distinguish PLUGIN_CB_REGULAR from PLUGIN_CB_REGULAR_R, so place all TB callbacks in the same queue. Signed-off-by: Richard Henderson --- accel/tcg/plugin-gen.c | 96 +++++++++++++++++++++++++----------------- plugins/api.c | 6 +-- 2 files changed, 58 insertions(+), 44 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 8fa342b425..f92aa80510 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -207,6 +207,7 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { case PLUGIN_GEN_AFTER_INSN: + case PLUGIN_GEN_FROM_TB: tcg_gen_plugin_cb(from); break; case PLUGIN_GEN_FROM_INSN: @@ -216,8 +217,6 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) */ gen_wrapped(from, PLUGIN_GEN_ENABLE_MEM_HELPER, gen_empty_mem_helper); - /* fall through */ - case PLUGIN_GEN_FROM_TB: gen_wrapped(from, PLUGIN_GEN_CB_UDATA, gen_empty_udata_cb_no_rwg); gen_wrapped(from, PLUGIN_GEN_CB_UDATA_R, gen_empty_udata_cb_no_wg); gen_wrapped(from, PLUGIN_GEN_CB_INLINE, gen_empty_inline_cb); @@ -632,24 +631,6 @@ void plugin_gen_disable_mem_helpers(void) offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, env)); } -static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op) -{ - inject_udata_cb(ptb->cbs[PLUGIN_CB_REGULAR], begin_op); -} - -static void plugin_gen_tb_udata_r(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op) -{ - inject_udata_cb(ptb->cbs[PLUGIN_CB_REGULAR_R], begin_op); -} - -static void plugin_gen_tb_inline(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op) -{ - inject_inline_cb(ptb->cbs[PLUGIN_CB_INLINE], begin_op, op_ok); -} - static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, TCGOp *begin_op, int insn_idx) { @@ -708,6 +689,41 @@ static void gen_disable_mem_helper(struct qemu_plugin_tb *ptb, } } +static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) +{ + 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_call2(cb->regular.f.vcpu_udata, cb->regular.info, NULL, + tcgv_i32_temp(cpu_index), + tcgv_ptr_temp(tcg_constant_ptr(cb->userp))); + tcg_temp_free_i32(cpu_index); +} + +static void gen_inline_cb(struct qemu_plugin_dyn_cb *cb) +{ + 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(); + + 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_ext_i32_ptr(ptr, cpu_index); + tcg_temp_free_i32(cpu_index); + + tcg_gen_addi_ptr(ptr, ptr, (intptr_t)arr->data); + tcg_gen_ld_i64(val, ptr, offset); + tcg_gen_addi_i64(val, val, cb->inline_insn.imm); + tcg_gen_st_i64(val, ptr, offset); + + tcg_temp_free_i64(val); + tcg_temp_free_ptr(ptr); +} + /* #define DEBUG_PLUGIN_GEN_OPS */ static void pr_ops(void) { @@ -786,6 +802,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { enum plugin_gen_from from = op->args[0]; struct qemu_plugin_insn *insn = NULL; + const GArray *cbs; + int i, n; if (insn_idx >= 0) { insn = g_ptr_array_index(plugin_tb->insns, insn_idx); @@ -798,6 +816,25 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) assert(insn != NULL); gen_disable_mem_helper(plugin_tb, insn); break; + + case PLUGIN_GEN_FROM_TB: + assert(insn == NULL); + + cbs = plugin_tb->cbs[PLUGIN_CB_REGULAR]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_udata_cb(cb); + } + + cbs = plugin_tb->cbs[PLUGIN_CB_INLINE]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_inline_cb(cb); + } + break; + default: g_assert_not_reached(); } @@ -813,25 +850,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) enum plugin_gen_cb type = op->args[1]; switch (from) { - case PLUGIN_GEN_FROM_TB: - { - g_assert(insn_idx == -1); - - switch (type) { - case PLUGIN_GEN_CB_UDATA: - plugin_gen_tb_udata(plugin_tb, op); - break; - case PLUGIN_GEN_CB_UDATA_R: - plugin_gen_tb_udata_r(plugin_tb, op); - break; - case PLUGIN_GEN_CB_INLINE: - plugin_gen_tb_inline(plugin_tb, op); - break; - default: - g_assert_not_reached(); - } - break; - } case PLUGIN_GEN_FROM_INSN: { g_assert(insn_idx >= 0); diff --git a/plugins/api.c b/plugins/api.c index 8fa5a600ac..5d119e8049 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -92,11 +92,7 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, void *udata) { if (!tb->mem_only) { - int index = flags == QEMU_PLUGIN_CB_R_REGS || - flags == QEMU_PLUGIN_CB_RW_REGS ? - PLUGIN_CB_REGULAR_R : PLUGIN_CB_REGULAR; - - plugin_register_dyn_cb__udata(&tb->cbs[index], + plugin_register_dyn_cb__udata(&tb->cbs[PLUGIN_CB_REGULAR], cb, flags, udata); } } From patchwork Sat Mar 16 01:57:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780749 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489528wrs; Fri, 15 Mar 2024 18:59:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3lnqd2lJhUqigqEiwBsA7vr9yMlpOGG7G3JohU5N+r1ZtpC7/Ea2C5tTYYK3q8ZHRvAQFCrz9m05QLCWCjkAM X-Google-Smtp-Source: AGHT+IEp6INUaghg6JJH3FJ4xJAYCHE6+6LpEVpYgAnivLL1FnmgHI7o3NtrmekXtkFtF7dSA51+ X-Received: by 2002:a05:622a:344:b0:42e:fa7c:291c with SMTP id r4-20020a05622a034400b0042efa7c291cmr6282940qtw.13.1710554375909; Fri, 15 Mar 2024 18:59:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554375; cv=none; d=google.com; s=arc-20160816; b=z4ZlD833YX/KtpfqP1UkKqwNkO2bN0g/YI0OyPmScdWcDLkCpMVGHQTpXnd7UZny9h N7nastrGh7Km3kDnRNKTVOa8RX2lqAFjX7knVQillkLrJ8L2EM46nTwCdeeC+rv3yQXs pRluBUEnD3qCOR3Z7IH08QBxR3CDxzxuL4MM7brxe+++LoE7tE69bNP0nANJW8syK/Oc 4BVNAZKM2IJ2WUFsUXYbndGbUYQwUngOSMJ1JzJk/xtvs88nRhrWEGEJ+344rpK3O2VV eDM6rrjVdzL2j14qObChsYMCzf/9j2eYpcb1Ssk36rhYm1wijvqFoZfixwJl3gSvL2tG c8LQ== 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=7nfW9NMKBYgHEbFge3X4GcZHuOXPsIrrYwIsT1Iscy8=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=cPKuZBE4qFLnvZxUPuQ7XFLo0O8GRT/VU8ezi8ZsNiR04T3OXahmykxPPJu0JtfTqu fBc3g7WjfwSQZ8oUnbTCt6hNKSOAgSo97me7XsswEqnKH+wEbP+1ODbvpyVMimmbHn74 My2MGNjmxH6vEy+vyaeux84adtaoh0y/+PZyNpvJpuGdMyr8j2x3ewsmXHROmFIw6mjm b9QjXJJJk6PUf2MM35bW9oa98VWQr8fLDZRIxZEZoAn2mD7Ga+ODOB1DgCFSW72TueVc BUhZyGLZYcHCby7a2I9UDKPCAW+3UDdIzPJX9C63UfzPE/sPwpaXDE6hy/CicXBDT8mV fm2Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wH9mQHDC; 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 w19-20020ac87e93000000b0042ed731ad3esi2703705qtj.598.2024.03.15.18.59.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:35 -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=wH9mQHDC; 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 1rlJIx-0002q4-U7; Fri, 15 Mar 2024 21:57:47 -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 1rlJIw-0002o5-F9 for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:46 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIu-0000jN-Re for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:46 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1dc49b00bdbso20597895ad.3 for ; Fri, 15 Mar 2024 18:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554263; x=1711159063; 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=7nfW9NMKBYgHEbFge3X4GcZHuOXPsIrrYwIsT1Iscy8=; b=wH9mQHDC+n/2lF/qyOb2bDJsJAT9iKUQqg8xbVnOYYozynBEGMBT/V4CbQqirt9wqv mEommrnEYan0yHt9tX3GNy4c4mGmGJxW5Rr/SRr+bI8gK11O2rp6sR5izHHgGL8PRPDQ lj6EnkJbO8ymSpZf/X2PdIol/7Mvw+CASRAdW0604EWUmN9IQxH4DRRrYNzwh8nXT8X3 GyivU8oP/v/Yli2IFTt0iVfyg62Aiwg7dKro4VgbMiio3axl4cxL6n6XTHuneZqq7CxT w9SOy72IN2lDoEoFEqU9nmW2voDeAQ83lPoEHANGNjCVgx8gf5fyq2aSBHNUes1LqwEx 46+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554263; x=1711159063; 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=7nfW9NMKBYgHEbFge3X4GcZHuOXPsIrrYwIsT1Iscy8=; b=I8erLO32o1f2LDxAimvttIR7Zh2c/IMVtEgkfEu/SOYCMfCZE0tiEYRNLjFu9FRq3s 7rP5BTaoILYfFlacUPISLHk2ATPj2t6if3oxaKzoB8xnOmyOb735AIaBrWZLvuuC1b84 ARBnTV4bEYtYGedo3zEpCpb1IfOp/7RSVAx7QPOcD3cFJ5MYVH5Pubkv3Su/eGrggrKM nekDmngNx3j9j7Hevhdo3LAUrgJ9RNlTEJ3Y8Gdv7kXiI3ilBRueeoUNLIfZWsnH/Ja8 BZ7tQ0Qw23saKPerpGgWCzVGhfs2oZfV2ECnFYUgB/+jQ2xlrKGYsqsyk960NkvUS6zR bEMg== X-Gm-Message-State: AOJu0YwGNv/YiwgH1xjvaoh5K7FsaZHq6aCsNm8yjhv008TE6m+5ZePj UcVcxD1lfGEpM+nYagb4svDNJG5JtQP3JPZ+J5u8NLH/7VfWn2Ga+85FLOzhtdePqG0hM7QHztL H X-Received: by 2002:a17:902:f68c:b0:1df:fd30:8b2d with SMTP id l12-20020a170902f68c00b001dffd308b2dmr72873plg.50.1710554263625; Fri, 15 Mar 2024 18:57:43 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 09/22] plugins: Add PLUGIN_GEN_AFTER_TB Date: Fri, 15 Mar 2024 15:57:07 -1000 Message-Id: <20240316015720.3661236-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Delay test of plugin_tb->mem_helper until the inject pass. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index f92aa80510..aa74e580bd 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -75,6 +75,7 @@ enum plugin_gen_from { PLUGIN_GEN_FROM_INSN, PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_AFTER_INSN, + PLUGIN_GEN_AFTER_TB, PLUGIN_GEN_N_FROMS, }; @@ -615,20 +616,9 @@ static void inject_mem_enable_helper(struct qemu_plugin_tb *ptb, /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { - /* - * We could emit the clearing unconditionally and be done. However, this can - * be wasteful if for instance plugins don't track memory accesses, or if - * most TBs don't use helpers. Instead, emit the clearing iff the TB calls - * helpers that might access guest memory. - * - * Note: we do not reset plugin_tb->mem_helper here; a TB might have several - * exit points, and we want to emit the clearing from all of them. - */ - if (!tcg_ctx->plugin_tb->mem_helper) { - return; + if (tcg_ctx->plugin_insn) { + tcg_gen_plugin_cb(PLUGIN_GEN_AFTER_TB); } - tcg_gen_st_ptr(tcg_constant_ptr(NULL), tcg_env, - offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, env)); } static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, @@ -679,14 +669,11 @@ static void plugin_gen_enable_mem_helper(struct qemu_plugin_tb *ptb, inject_mem_enable_helper(ptb, insn, begin_op); } -static void gen_disable_mem_helper(struct qemu_plugin_tb *ptb, - struct qemu_plugin_insn *insn) +static void gen_disable_mem_helper(void) { - if (insn->mem_helper) { - tcg_gen_st_ptr(tcg_constant_ptr(0), tcg_env, - offsetof(CPUState, plugin_mem_cbs) - - offsetof(ArchCPU, env)); - } + tcg_gen_st_ptr(tcg_constant_ptr(0), tcg_env, + offsetof(CPUState, plugin_mem_cbs) - + offsetof(ArchCPU, env)); } static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) @@ -812,9 +799,17 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) tcg_ctx->emit_before_op = op; switch (from) { + case PLUGIN_GEN_AFTER_TB: + if (plugin_tb->mem_helper) { + gen_disable_mem_helper(); + } + break; + case PLUGIN_GEN_AFTER_INSN: assert(insn != NULL); - gen_disable_mem_helper(plugin_tb, insn); + if (insn->mem_helper) { + gen_disable_mem_helper(); + } break; case PLUGIN_GEN_FROM_TB: From patchwork Sat Mar 16 01:57:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780746 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489469wrs; Fri, 15 Mar 2024 18:59:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXkgJ5W2sGcrxpU5dcyDVsWumeqUPlFkjEq+b6fv2ZGAzvFwgM5qvdcCxEoVkT/hEwNDh7rWoZ96kw2hNrlD60s X-Google-Smtp-Source: AGHT+IGdmKj1QSlsVytzHEf1b2OkkVmPN7+Zu6GDGgLsSy8qSsHJjF7Ogp2Q23VCAgYGKm4AIWTl X-Received: by 2002:a05:622a:47c3:b0:42e:d692:e5b6 with SMTP id dp3-20020a05622a47c300b0042ed692e5b6mr6480584qtb.41.1710554356929; Fri, 15 Mar 2024 18:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554356; cv=none; d=google.com; s=arc-20160816; b=aF4dEHOH68dXbZm+ND8Gp4k1hKO3KzEWG64sCKsf5uhK68lb0xojlZZv3T1nzQSAvN TeclB99+qBR6aeGw8o5L5K0EZn/qzT5ux9AyzpnQ6+kOZjHelKsq5plQvISUD88KqVYL BFMehQFesgq2lPcFinhov//hW7iRXN+/XBXF71wE/pU5LMcsSYkuYWeivD7xJ58+ojDq jRRY0/LBwyBM7YK++awsxxQ2jCP9DW2SIzwZEZB5ddFstoWEyULji1OqolB52DwulU+4 Ohd6ugPEtzAVbIllPcnkvzFtrhJcvzNaMiqX7jr6NnBeHvRLjqx5pcoXJ7jMQGPYiwp9 +7Ng== 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=TcZkqfAEAWlYD7fR2bGgj6hyMWWgAyjlFTJyGyl+PF8=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=iuRYgzajnINIZsd4tzs5bV7Jsc27xYmFEq9I78iVrWw1qvxER7kew4vTPjRzJ2QyCj FK2l902xvFlP9ZenhUFkp8lSim6d87Z1tuh35fG5l3zYNoKbOh9L1P31nVdGIwU5kP1+ 9K2KnUmgh4sTUyIR+mgmPFwOi8DmAIwowMDzkSOkr15o5zOLJXqlMXbqhBKMRe5nbOCX LwYGu+0DUor9R9og3yoszUj62bjhuT4SWOpzMuMr5rLnbUUDgelLmIFTBuwF0iJM7MA8 Fb0p1Pc0QahLsHPHP87XZ1+jtRCeCkIo4S0aSUlxXncyMdXLov6rsfwNtvJXJHQ/0TwA BAkg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yGBCYJuP; 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 14-20020ac8574e000000b00430a215c75esi4187366qtx.428.2024.03.15.18.59.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:16 -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=yGBCYJuP; 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 1rlJJ0-0002qb-5T; Fri, 15 Mar 2024 21:57:50 -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 1rlJIz-0002qS-7i for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:49 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIx-0000jY-2U for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:48 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5c6bd3100fcso1809194a12.3 for ; Fri, 15 Mar 2024 18:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554265; x=1711159065; 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=TcZkqfAEAWlYD7fR2bGgj6hyMWWgAyjlFTJyGyl+PF8=; b=yGBCYJuPr/FsnUP+Ua74zb50jm53vaaTcHa2vq3us9xOlmFXQw5byPVTf0kZ/q3Rhv B+1zXk0AYRt055tDa3Z36HCEeyeT+JJSXfKDJk8VP10OeUveLmsq2NOs9Iy3gBlDZjYc 8/NzQuXl15rCBgIbMcPWTsi9RIRovZaInduAo9jd9grh70EEK/mWN7EEklUS+Nr4SN8Y cv0Ej44bGrDshDEpQhONWgo3y9pEctwbEi7y0nLGFpKwLWGShvmxDq+xviBu9xq5X0wU pa7J1+K5c1BMSqmXnetI85jiP+Nqj8gKcr3VeBZOKHtBWuMRmBBdL9vUudCTaLyvWiJM 4p4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554265; x=1711159065; 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=TcZkqfAEAWlYD7fR2bGgj6hyMWWgAyjlFTJyGyl+PF8=; b=Hjf3+mtA66wERVj6U/iSW3VCoh4lLqM2cZrcZbkVzAtgdg86jQ5Enjr01+iUxMh+OS sA5zgQjrIYasOmlMvbb3z4QUVcByRX9wCx7I5IhUPID3aGBfcRUBP7FSeo7/QJDkq3Yu 29Ay/f4I4HGrrsZa9tg9yjh9YR3zMcyKYiOHTBK8RmbHY+SqB6ncoa2K4TU0yujK4q9w rGGg0bx090SUlqCaehrLDn1bzCZjZ7QCHT2YQTF7EAQMXSWTqcMtyeuNS8BlG+xyulec afbyolQHNimAGQvKyvg6+Ol7u1TjUTjJ3/sGJydC1+vfhPQaGVfb0DaeQYrAUj55r/Cv kvnQ== X-Gm-Message-State: AOJu0YwjbRBMiy+Q7eAnlZkTCH+UarolP1Y+KuGM86bm/qJPmlyTZr+E p1W0dcVRVSp38tfBHXIulcViKiJDd8j/ghDgjgVXpp1K9r0ZHGP8cEF8C9uTnoqdZ3hRu/fHHp7 6 X-Received: by 2002:a17:902:ea0c:b0:1de:e6a5:e51d with SMTP id s12-20020a170902ea0c00b001dee6a5e51dmr5867167plg.16.1710554265657; Fri, 15 Mar 2024 18:57:45 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 10/22] plugins: Use emit_before_op for PLUGIN_GEN_FROM_INSN Date: Fri, 15 Mar 2024 15:57:08 -1000 Message-Id: <20240316015720.3661236-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/qemu/plugin.h | 1 - accel/tcg/plugin-gen.c | 286 ++++++++++------------------------------- plugins/api.c | 8 +- 3 files changed, 67 insertions(+), 228 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 793c44f1f2..ee1c1b174a 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -73,7 +73,6 @@ enum plugin_dyn_cb_type { enum plugin_dyn_cb_subtype { PLUGIN_CB_REGULAR, - PLUGIN_CB_REGULAR_R, PLUGIN_CB_INLINE, PLUGIN_N_CB_SUBTYPES, }; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index aa74e580bd..4785838eca 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -104,30 +104,6 @@ void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, void *userdata) { } -static void gen_empty_udata_cb(void (*gen_helper)(TCGv_i32, TCGv_ptr)) -{ - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - TCGv_ptr udata = tcg_temp_ebb_new_ptr(); - - tcg_gen_movi_ptr(udata, 0); - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); - gen_helper(cpu_index, udata); - - tcg_temp_free_ptr(udata); - tcg_temp_free_i32(cpu_index); -} - -static void gen_empty_udata_cb_no_wg(void) -{ - gen_empty_udata_cb(gen_helper_plugin_vcpu_udata_cb_no_wg); -} - -static void gen_empty_udata_cb_no_rwg(void) -{ - gen_empty_udata_cb(gen_helper_plugin_vcpu_udata_cb_no_rwg); -} - /* * For now we only support addi_i64. * When we support more ops, we can generate one empty inline cb for each. @@ -176,51 +152,19 @@ static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) tcg_temp_free_i32(cpu_index); } -/* - * Share the same function for enable/disable. When enabling, the NULL - * pointer will be overwritten later. - */ -static void gen_empty_mem_helper(void) -{ - TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); - - tcg_gen_movi_ptr(ptr, 0); - tcg_gen_st_ptr(ptr, tcg_env, offsetof(CPUState, plugin_mem_cbs) - - offsetof(ArchCPU, env)); - tcg_temp_free_ptr(ptr); -} - static void gen_plugin_cb_start(enum plugin_gen_from from, enum plugin_gen_cb type, unsigned wr) { tcg_gen_plugin_cb_start(from, type, wr); } -static void gen_wrapped(enum plugin_gen_from from, - enum plugin_gen_cb type, void (*func)(void)) -{ - gen_plugin_cb_start(from, type, 0); - func(); - tcg_gen_plugin_cb_end(); -} - static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { case PLUGIN_GEN_AFTER_INSN: case PLUGIN_GEN_FROM_TB: - tcg_gen_plugin_cb(from); - break; case PLUGIN_GEN_FROM_INSN: - /* - * Note: plugin_gen_inject() relies on ENABLE_MEM_HELPER being - * the first callback of an instruction - */ - gen_wrapped(from, PLUGIN_GEN_ENABLE_MEM_HELPER, - gen_empty_mem_helper); - gen_wrapped(from, PLUGIN_GEN_CB_UDATA, gen_empty_udata_cb_no_rwg); - gen_wrapped(from, PLUGIN_GEN_CB_UDATA_R, gen_empty_udata_cb_no_wg); - gen_wrapped(from, PLUGIN_GEN_CB_INLINE, gen_empty_inline_cb); + tcg_gen_plugin_cb(from); break; default: g_assert_not_reached(); @@ -374,18 +318,6 @@ static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) return op; } -static TCGOp *copy_st_ptr(TCGOp **begin_op, TCGOp *op) -{ - if (UINTPTR_MAX == UINT32_MAX) { - /* st_i32 */ - op = copy_op(begin_op, op, INDEX_op_st_i32); - } else { - /* st_i64 */ - op = copy_st_i64(begin_op, op); - } - return op; -} - static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *func, int *cb_idx) { TCGOp *old_op; @@ -409,32 +341,6 @@ static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *func, int *cb_idx) return op; } -/* - * When we append/replace ops here we are sensitive to changing patterns of - * TCGOps generated by the tcg_gen_FOO calls when we generated the - * empty callbacks. This will assert very quickly in a debug build as - * we assert the ops we are replacing are the correct ones. - */ -static TCGOp *append_udata_cb(const struct qemu_plugin_dyn_cb *cb, - TCGOp *begin_op, TCGOp *op, int *cb_idx) -{ - /* const_ptr */ - op = copy_const_ptr(&begin_op, op, cb->userp); - - /* copy the ld_i32, but note that we only have to copy it once */ - if (*cb_idx == -1) { - op = copy_op(&begin_op, op, INDEX_op_ld_i32); - } else { - begin_op = QTAILQ_NEXT(begin_op, link); - tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); - } - - /* call */ - op = copy_call(&begin_op, op, cb->regular.f.vcpu_udata, cb_idx); - - return op; -} - static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *unused) @@ -488,11 +394,6 @@ typedef TCGOp *(*inject_fn)(const struct qemu_plugin_dyn_cb *cb, TCGOp *begin_op, TCGOp *op, int *intp); typedef bool (*op_ok_fn)(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb); -static bool op_ok(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb) -{ - return true; -} - static bool op_rw(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb) { int w; @@ -530,12 +431,6 @@ static void inject_cb_type(const GArray *cbs, TCGOp *begin_op, rm_ops_range(begin_op, end_op); } -static void -inject_udata_cb(const GArray *cbs, TCGOp *begin_op) -{ - inject_cb_type(cbs, begin_op, append_udata_cb, op_ok); -} - static void inject_inline_cb(const GArray *cbs, TCGOp *begin_op, op_ok_fn ok) { @@ -548,71 +443,6 @@ inject_mem_cb(const GArray *cbs, TCGOp *begin_op) inject_cb_type(cbs, begin_op, append_mem_cb, op_rw); } -/* we could change the ops in place, but we can reuse more code by copying */ -static void inject_mem_helper(TCGOp *begin_op, GArray *arr) -{ - TCGOp *orig_op = begin_op; - TCGOp *end_op; - TCGOp *op; - - end_op = find_op(begin_op, INDEX_op_plugin_cb_end); - tcg_debug_assert(end_op); - - /* const ptr */ - op = copy_const_ptr(&begin_op, end_op, arr); - - /* st_ptr */ - op = copy_st_ptr(&begin_op, op); - - rm_ops_range(orig_op, end_op); -} - -/* - * Tracking memory accesses performed from helpers requires extra work. - * If an instruction is emulated with helpers, we do two things: - * (1) copy the CB descriptors, and keep track of it so that they can be - * freed later on, and (2) point CPUState.plugin_mem_cbs to the descriptors, so - * that we can read them at run-time (i.e. when the helper executes). - * This run-time access is performed from qemu_plugin_vcpu_mem_cb. - * - * Note that plugin_gen_disable_mem_helpers undoes (2). Since it - * is possible that the code we generate after the instruction is - * dead, we also add checks before generating tb_exit etc. - */ -static void inject_mem_enable_helper(struct qemu_plugin_tb *ptb, - struct qemu_plugin_insn *plugin_insn, - TCGOp *begin_op) -{ - GArray *cbs[2]; - GArray *arr; - size_t n_cbs, i; - - cbs[0] = plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; - cbs[1] = plugin_insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; - - n_cbs = 0; - for (i = 0; i < ARRAY_SIZE(cbs); i++) { - n_cbs += cbs[i]->len; - } - - plugin_insn->mem_helper = plugin_insn->calls_helpers && n_cbs; - if (likely(!plugin_insn->mem_helper)) { - rm_ops(begin_op); - return; - } - ptb->mem_helper = true; - - arr = g_array_sized_new(false, false, - sizeof(struct qemu_plugin_dyn_cb), n_cbs); - - for (i = 0; i < ARRAY_SIZE(cbs); i++) { - g_array_append_vals(arr, cbs[i]->data, cbs[i]->len); - } - - qemu_plugin_add_dyn_cb_arr(arr); - inject_mem_helper(begin_op, arr); -} - /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { @@ -621,30 +451,6 @@ void plugin_gen_disable_mem_helpers(void) } } -static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - - inject_udata_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], begin_op); -} - -static void plugin_gen_insn_udata_r(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - - inject_udata_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR_R], begin_op); -} - -static void plugin_gen_insn_inline(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - inject_inline_cb(insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], - begin_op, op_ok); -} - static void plugin_gen_mem_regular(const struct qemu_plugin_tb *ptb, TCGOp *begin_op, int insn_idx) { @@ -662,11 +468,51 @@ static void plugin_gen_mem_inline(const struct qemu_plugin_tb *ptb, inject_inline_cb(cbs, begin_op, op_rw); } -static void plugin_gen_enable_mem_helper(struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) +static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, + struct qemu_plugin_insn *insn) { - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - inject_mem_enable_helper(ptb, insn, begin_op); + GArray *cbs[2]; + GArray *arr; + size_t n_cbs; + + /* + * Tracking memory accesses performed from helpers requires extra work. + * If an instruction is emulated with helpers, we do two things: + * (1) copy the CB descriptors, and keep track of it so that they can be + * freed later on, and (2) point CPUState.plugin_mem_cbs to the + * descriptors, so that we can read them at run-time + * (i.e. when the helper executes). + * This run-time access is performed from qemu_plugin_vcpu_mem_cb. + * + * Note that plugin_gen_disable_mem_helpers undoes (2). Since it + * is possible that the code we generate after the instruction is + * dead, we also add checks before generating tb_exit etc. + */ + if (!insn->calls_helpers) { + return; + } + + cbs[0] = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + cbs[1] = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; + n_cbs = cbs[0]->len + cbs[1]->len; + + if (n_cbs == 0) { + insn->mem_helper = false; + return; + } + insn->mem_helper = true; + ptb->mem_helper = true; + + arr = g_array_sized_new(false, false, + sizeof(struct qemu_plugin_dyn_cb), n_cbs); + g_array_append_vals(arr, cbs[0]->data, cbs[0]->len); + g_array_append_vals(arr, cbs[1]->data, cbs[1]->len); + + qemu_plugin_add_dyn_cb_arr(arr); + + tcg_gen_st_ptr(tcg_constant_ptr((intptr_t)arr), tcg_env, + offsetof(CPUState, plugin_mem_cbs) - + offsetof(ArchCPU, env)); } static void gen_disable_mem_helper(void) @@ -830,6 +676,26 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) } break; + case PLUGIN_GEN_FROM_INSN: + assert(insn != NULL); + + gen_enable_mem_helper(plugin_tb, insn); + + cbs = insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_udata_cb(cb); + } + + cbs = insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + gen_inline_cb(cb); + } + break; + default: g_assert_not_reached(); } @@ -845,28 +711,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) enum plugin_gen_cb type = op->args[1]; switch (from) { - case PLUGIN_GEN_FROM_INSN: - { - g_assert(insn_idx >= 0); - - switch (type) { - case PLUGIN_GEN_CB_UDATA: - plugin_gen_insn_udata(plugin_tb, op, insn_idx); - break; - case PLUGIN_GEN_CB_UDATA_R: - plugin_gen_insn_udata_r(plugin_tb, op, insn_idx); - break; - case PLUGIN_GEN_CB_INLINE: - plugin_gen_insn_inline(plugin_tb, op, insn_idx); - break; - case PLUGIN_GEN_ENABLE_MEM_HELPER: - plugin_gen_enable_mem_helper(plugin_tb, op, insn_idx); - break; - default: - g_assert_not_reached(); - } - break; - } case PLUGIN_GEN_FROM_MEM: { g_assert(insn_idx >= 0); diff --git a/plugins/api.c b/plugins/api.c index 5d119e8049..29cce2d97c 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -115,12 +115,8 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, void *udata) { if (!insn->mem_only) { - int index = flags == QEMU_PLUGIN_CB_R_REGS || - flags == QEMU_PLUGIN_CB_RW_REGS ? - PLUGIN_CB_REGULAR_R : PLUGIN_CB_REGULAR; - - plugin_register_dyn_cb__udata(&insn->cbs[PLUGIN_CB_INSN][index], - cb, flags, udata); + plugin_register_dyn_cb__udata( + &insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], cb, flags, udata); } } From patchwork Sat Mar 16 01:57:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780741 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489364wrs; Fri, 15 Mar 2024 18:58:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXolhWkdVxpTsMwyQSA7uaAFwjrEBXerZLUhvWQrQko0X/m5yzx7OSaDdGvwzdCmkdbtPnCZb41b+vGtuWe7P8P X-Google-Smtp-Source: AGHT+IEPQp28BAI1S7n3//Uh8a262KafZOYq2OuJUokgEBZ6HkUKaAEjxEzktUFSQ7Uu8eaPutl4 X-Received: by 2002:a05:622a:149:b0:42e:a46d:722f with SMTP id v9-20020a05622a014900b0042ea46d722fmr6454398qtw.23.1710554332184; Fri, 15 Mar 2024 18:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554332; cv=none; d=google.com; s=arc-20160816; b=JgXHHlsYng5qTnnkg7jGdqjZpLOrrXt0Cv2xSoEFGCz/M8GLVQ1qewruH1TLf9zosw uCdg6GoekPYC/XWHaK2+BzhxLLtPpgCNeIs+rNsD6ep7H/khIBDkZ+yxcZVe234hrIdJ ooshfYcrQCmMOkdgVPbN/i8TAEH4uVJE/S3CWSEZOr7ZiNNCXXbIrOBOqo6Y6wlfScX0 nxat/khFzs6PRXcBtqaOymFb0I7dLpHItw2b/5MYzbN5UnjJHgfFH4PYNWm8HJ7JVdie CyjLq3NHEtO6NcClLpZUU2WQHOBjunlmDvxqlwlig82wbwmmkGih78wDF/lcD5lkjJxj Thlw== 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=de7L7Bv5q1ei3kBB2iSJsavrnToybDFv6t5y0UURxTU=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=y2XmeJLafR3AE5ug5gSnIIM/sQInbPfoyCCYo7UMUqMhTuHwXvs7i5EaBbREiwQh2J JHjETryb26cAIMAiQzqZAPwQ/yZ2tHFFVJLm6f9awVK9Lw8YDAZOyu3epkhQhiBHAlnz WFUKRpsKv20GuoFqnTCqt0WKimlSk+YjQad7sNAKLU+zmktHI+/DpIZ3GjYLgIMCpAw6 az//hkvY07vrMUlySfn8VvQq73X3IEucQ3Ih/8j4dm5rGFccbmCCr1VekNr/1aeaiNXT ZW0yMYv/8VoN6Ra/RWkehxF9Y5ayj4A48Sm9DpfRNA462mPJJ5VBKKlU+coOOd5+4QXJ TOiA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KIwLbHUi; 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 x10-20020ac85f0a000000b0042efaefcff1si4886553qta.589.2024.03.15.18.58.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:58:52 -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=KIwLbHUi; 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 1rlJJ4-0002rI-Lp; Fri, 15 Mar 2024 21:57:55 -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 1rlJJ1-0002qr-73 for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:51 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJIy-0000l5-RW for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:50 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1dddaa02d22so15799565ad.2 for ; Fri, 15 Mar 2024 18:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554267; x=1711159067; 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=de7L7Bv5q1ei3kBB2iSJsavrnToybDFv6t5y0UURxTU=; b=KIwLbHUimXZQptdwV53LNjd5dDT9nwbqDo+QUOryLbg+S+2GyYOCSYBBbnX5PaGWT7 7HRygRlgeJm2B1etGpeS/3nBTbRcNpeLQBdqp0m1b+LU+o6kQT9K5jdTeDqc6NaKQSn7 d9lf5ndaawYOqYu9930CFDo8PYx9sLSxrdNf32TRwl6ZtYTD9RRYsO2Py/MeeXI9yr8u O7cxljItoJh1vuOfc7wS9Fa+uy9ZGL7fjA+WsrO9J7YBQACgE20pY/hClNKDWdl4l18Z hSVjWWpNfgQdno3JzeTNkLcP+Gx2xs2GSDaBnMC8lgPAvYiPjQ1YXGNfpExkS3FoQTMT 9jDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554267; x=1711159067; 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=de7L7Bv5q1ei3kBB2iSJsavrnToybDFv6t5y0UURxTU=; b=KfyiGkqAG4ENqXxGu00f+8j7EiiG7Xx/hbSiCCvtH7pMDoc3BWQdZWlVsqekWr/myH 5rLVor7/tbh+bZnASbbCNAqhc5KY2/g2ObC/XXga+omPTqpmPC8/tIG8vz6f5NChcYV0 klnEi9U405asbTjeKLmM+Gs8nZt2xqkkBa9Z/Dd2H/MLaD2PSwvc0Uj+akS685dkNwaR MlpGzRe0p2f34XE+VFZCLwv8OcOAfhdTTH+ApD91hZJhJmDPAwOOoV63KTW5JcRCiVUk MdfV6i1oha6BZTe/92NSCCE5y3zTcPOmU0qRV6E/b6m9ylC/vXFE0ZGhShkrk3JGTV4L LpMQ== X-Gm-Message-State: AOJu0Ywxg7jBm1x/PH1VXArvoQePpusP8CbmCOjvKHj9Sowi7psTJDrT kaMy0xNlXkoKqpueXntVg42HkpayRHLUGhMysRM+TQbQ4rr7QuQxIL2c5bi7F/hlMR4J3E267pf J X-Received: by 2002:a17:902:f64d:b0:1dd:a16e:dea4 with SMTP id m13-20020a170902f64d00b001dda16edea4mr6207758plg.67.1710554267505; Fri, 15 Mar 2024 18:57:47 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 11/22] plugins: Use emit_before_op for PLUGIN_GEN_FROM_MEM Date: Fri, 15 Mar 2024 15:57:09 -1000 Message-Id: <20240316015720.3661236-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Introduce a new plugin_mem_cb op to hold the address temp and meminfo computed by tcg-op-ldst.c. Because this now has its own opcode, we no longer need PLUGIN_GEN_FROM_MEM. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/exec/plugin-gen.h | 4 - include/tcg/tcg-op-common.h | 1 + include/tcg/tcg-opc.h | 1 + accel/tcg/plugin-gen.c | 408 ++++-------------------------------- tcg/tcg-op-ldst.c | 6 +- tcg/tcg-op.c | 5 + 6 files changed, 54 insertions(+), 371 deletions(-) diff --git a/include/exec/plugin-gen.h b/include/exec/plugin-gen.h index c4552b5061..f333f33198 100644 --- a/include/exec/plugin-gen.h +++ b/include/exec/plugin-gen.h @@ -25,7 +25,6 @@ void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db); void plugin_gen_insn_end(void); void plugin_gen_disable_mem_helpers(void); -void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info); #else /* !CONFIG_PLUGIN */ @@ -48,9 +47,6 @@ static inline void plugin_gen_tb_end(CPUState *cpu, size_t num_insns) static inline void plugin_gen_disable_mem_helpers(void) { } -static inline void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info) -{ } - #endif /* CONFIG_PLUGIN */ #endif /* QEMU_PLUGIN_GEN_H */ diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index 9de5a7f280..72b80b20d0 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -75,6 +75,7 @@ void tcg_gen_goto_tb(unsigned idx); void tcg_gen_lookup_and_goto_ptr(void); void tcg_gen_plugin_cb(unsigned from); +void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo); void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr); void tcg_gen_plugin_cb_end(void); diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index 3b7cb2bce1..be9e36e386 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -198,6 +198,7 @@ DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(plugin_cb, 0, 0, 1, TCG_OPF_NOT_PRESENT) +DEF(plugin_mem_cb, 0, 1, 1, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT) DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 4785838eca..be7fd548cc 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -73,7 +73,6 @@ enum plugin_gen_from { PLUGIN_GEN_FROM_TB, PLUGIN_GEN_FROM_INSN, - PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_AFTER_INSN, PLUGIN_GEN_AFTER_TB, PLUGIN_GEN_N_FROMS, @@ -104,60 +103,6 @@ void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, void *userdata) { } -/* - * For now we only support addi_i64. - * When we support more ops, we can generate one empty inline cb for each. - */ -static void gen_empty_inline_cb(void) -{ - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - TCGv_ptr cpu_index_as_ptr = tcg_temp_ebb_new_ptr(); - TCGv_i64 val = tcg_temp_ebb_new_i64(); - TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); - - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); - /* second operand will be replaced by immediate value */ - tcg_gen_mul_i32(cpu_index, cpu_index, cpu_index); - tcg_gen_ext_i32_ptr(cpu_index_as_ptr, cpu_index); - - tcg_gen_movi_ptr(ptr, 0); - tcg_gen_add_ptr(ptr, ptr, cpu_index_as_ptr); - tcg_gen_ld_i64(val, ptr, 0); - /* second operand will be replaced by immediate value */ - tcg_gen_add_i64(val, val, val); - - tcg_gen_st_i64(val, ptr, 0); - tcg_temp_free_ptr(ptr); - tcg_temp_free_i64(val); - tcg_temp_free_ptr(cpu_index_as_ptr); - tcg_temp_free_i32(cpu_index); -} - -static void gen_empty_mem_cb(TCGv_i64 addr, uint32_t info) -{ - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - TCGv_i32 meminfo = tcg_temp_ebb_new_i32(); - TCGv_ptr udata = tcg_temp_ebb_new_ptr(); - - tcg_gen_movi_i32(meminfo, info); - tcg_gen_movi_ptr(udata, 0); - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); - - gen_helper_plugin_vcpu_mem_cb(cpu_index, meminfo, addr, udata); - - tcg_temp_free_ptr(udata); - tcg_temp_free_i32(meminfo); - tcg_temp_free_i32(cpu_index); -} - -static void gen_plugin_cb_start(enum plugin_gen_from from, - enum plugin_gen_cb type, unsigned wr) -{ - tcg_gen_plugin_cb_start(from, type, wr); -} - static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { @@ -171,278 +116,6 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) } } -void plugin_gen_empty_mem_callback(TCGv_i64 addr, uint32_t info) -{ - enum qemu_plugin_mem_rw rw = get_plugin_meminfo_rw(info); - - gen_plugin_cb_start(PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_CB_MEM, rw); - gen_empty_mem_cb(addr, info); - tcg_gen_plugin_cb_end(); - - gen_plugin_cb_start(PLUGIN_GEN_FROM_MEM, PLUGIN_GEN_CB_INLINE, rw); - gen_empty_inline_cb(); - tcg_gen_plugin_cb_end(); -} - -static TCGOp *find_op(TCGOp *op, TCGOpcode opc) -{ - while (op) { - if (op->opc == opc) { - return op; - } - op = QTAILQ_NEXT(op, link); - } - return NULL; -} - -static TCGOp *rm_ops_range(TCGOp *begin, TCGOp *end) -{ - TCGOp *ret = QTAILQ_NEXT(end, link); - - QTAILQ_REMOVE_SEVERAL(&tcg_ctx->ops, begin, end, link); - return ret; -} - -/* remove all ops until (and including) plugin_cb_end */ -static TCGOp *rm_ops(TCGOp *op) -{ - TCGOp *end_op = find_op(op, INDEX_op_plugin_cb_end); - - tcg_debug_assert(end_op); - return rm_ops_range(op, end_op); -} - -static TCGOp *copy_op_nocheck(TCGOp **begin_op, TCGOp *op) -{ - TCGOp *old_op = QTAILQ_NEXT(*begin_op, link); - unsigned nargs = old_op->nargs; - - *begin_op = old_op; - op = tcg_op_insert_after(tcg_ctx, op, old_op->opc, nargs); - memcpy(op->args, old_op->args, sizeof(op->args[0]) * nargs); - - return op; -} - -static TCGOp *copy_op(TCGOp **begin_op, TCGOp *op, TCGOpcode opc) -{ - op = copy_op_nocheck(begin_op, op); - tcg_debug_assert((*begin_op)->opc == opc); - return op; -} - -static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr) -{ - if (UINTPTR_MAX == UINT32_MAX) { - /* mov_i32 */ - op = copy_op(begin_op, op, INDEX_op_mov_i32); - op->args[1] = tcgv_i32_arg(tcg_constant_i32((uintptr_t)ptr)); - } else { - /* mov_i64 */ - op = copy_op(begin_op, op, INDEX_op_mov_i64); - op->args[1] = tcgv_i64_arg(tcg_constant_i64((uintptr_t)ptr)); - } - return op; -} - -static TCGOp *copy_ld_i32(TCGOp **begin_op, TCGOp *op) -{ - return copy_op(begin_op, op, INDEX_op_ld_i32); -} - -static TCGOp *copy_ext_i32_ptr(TCGOp **begin_op, TCGOp *op) -{ - if (UINTPTR_MAX == UINT32_MAX) { - op = copy_op(begin_op, op, INDEX_op_mov_i32); - } else { - op = copy_op(begin_op, op, INDEX_op_ext_i32_i64); - } - return op; -} - -static TCGOp *copy_add_ptr(TCGOp **begin_op, TCGOp *op) -{ - if (UINTPTR_MAX == UINT32_MAX) { - op = copy_op(begin_op, op, INDEX_op_add_i32); - } else { - op = copy_op(begin_op, op, INDEX_op_add_i64); - } - return op; -} - -static TCGOp *copy_ld_i64(TCGOp **begin_op, TCGOp *op) -{ - if (TCG_TARGET_REG_BITS == 32) { - /* 2x ld_i32 */ - op = copy_ld_i32(begin_op, op); - op = copy_ld_i32(begin_op, op); - } else { - /* ld_i64 */ - op = copy_op(begin_op, op, INDEX_op_ld_i64); - } - return op; -} - -static TCGOp *copy_st_i64(TCGOp **begin_op, TCGOp *op) -{ - if (TCG_TARGET_REG_BITS == 32) { - /* 2x st_i32 */ - op = copy_op(begin_op, op, INDEX_op_st_i32); - op = copy_op(begin_op, op, INDEX_op_st_i32); - } else { - /* st_i64 */ - op = copy_op(begin_op, op, INDEX_op_st_i64); - } - return op; -} - -static TCGOp *copy_add_i64(TCGOp **begin_op, TCGOp *op, uint64_t v) -{ - if (TCG_TARGET_REG_BITS == 32) { - /* all 32-bit backends must implement add2_i32 */ - g_assert(TCG_TARGET_HAS_add2_i32); - op = copy_op(begin_op, op, INDEX_op_add2_i32); - op->args[4] = tcgv_i32_arg(tcg_constant_i32(v)); - op->args[5] = tcgv_i32_arg(tcg_constant_i32(v >> 32)); - } else { - op = copy_op(begin_op, op, INDEX_op_add_i64); - op->args[2] = tcgv_i64_arg(tcg_constant_i64(v)); - } - return op; -} - -static TCGOp *copy_mul_i32(TCGOp **begin_op, TCGOp *op, uint32_t v) -{ - op = copy_op(begin_op, op, INDEX_op_mul_i32); - op->args[2] = tcgv_i32_arg(tcg_constant_i32(v)); - return op; -} - -static TCGOp *copy_call(TCGOp **begin_op, TCGOp *op, void *func, int *cb_idx) -{ - TCGOp *old_op; - int func_idx; - - /* copy all ops until the call */ - do { - op = copy_op_nocheck(begin_op, op); - } while (op->opc != INDEX_op_call); - - /* fill in the op call */ - old_op = *begin_op; - TCGOP_CALLI(op) = TCGOP_CALLI(old_op); - TCGOP_CALLO(op) = TCGOP_CALLO(old_op); - tcg_debug_assert(op->life == 0); - - func_idx = TCGOP_CALLO(op) + TCGOP_CALLI(op); - *cb_idx = func_idx; - op->args[func_idx] = (uintptr_t)func; - - return op; -} - -static TCGOp *append_inline_cb(const struct qemu_plugin_dyn_cb *cb, - TCGOp *begin_op, TCGOp *op, - int *unused) -{ - char *ptr = cb->inline_insn.entry.score->data->data; - size_t elem_size = g_array_get_element_size( - cb->inline_insn.entry.score->data); - size_t offset = cb->inline_insn.entry.offset; - - op = copy_ld_i32(&begin_op, op); - op = copy_mul_i32(&begin_op, op, elem_size); - op = copy_ext_i32_ptr(&begin_op, op); - op = copy_const_ptr(&begin_op, op, ptr + offset); - op = copy_add_ptr(&begin_op, op); - op = copy_ld_i64(&begin_op, op); - op = copy_add_i64(&begin_op, op, cb->inline_insn.imm); - op = copy_st_i64(&begin_op, op); - return op; -} - -static TCGOp *append_mem_cb(const struct qemu_plugin_dyn_cb *cb, - TCGOp *begin_op, TCGOp *op, int *cb_idx) -{ - enum plugin_gen_cb type = begin_op->args[1]; - - tcg_debug_assert(type == PLUGIN_GEN_CB_MEM); - - /* const_i32 == mov_i32 ("info", so it remains as is) */ - op = copy_op(&begin_op, op, INDEX_op_mov_i32); - - /* const_ptr */ - op = copy_const_ptr(&begin_op, op, cb->userp); - - /* copy the ld_i32, but note that we only have to copy it once */ - if (*cb_idx == -1) { - op = copy_op(&begin_op, op, INDEX_op_ld_i32); - } else { - begin_op = QTAILQ_NEXT(begin_op, link); - tcg_debug_assert(begin_op && begin_op->opc == INDEX_op_ld_i32); - } - - if (type == PLUGIN_GEN_CB_MEM) { - /* call */ - op = copy_call(&begin_op, op, cb->regular.f.vcpu_udata, cb_idx); - } - - return op; -} - -typedef TCGOp *(*inject_fn)(const struct qemu_plugin_dyn_cb *cb, - TCGOp *begin_op, TCGOp *op, int *intp); -typedef bool (*op_ok_fn)(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb); - -static bool op_rw(const TCGOp *op, const struct qemu_plugin_dyn_cb *cb) -{ - int w; - - w = op->args[2]; - return !!(cb->rw & (w + 1)); -} - -static void inject_cb_type(const GArray *cbs, TCGOp *begin_op, - inject_fn inject, op_ok_fn ok) -{ - TCGOp *end_op; - TCGOp *op; - int cb_idx = -1; - int i; - - if (!cbs || cbs->len == 0) { - rm_ops(begin_op); - return; - } - - end_op = find_op(begin_op, INDEX_op_plugin_cb_end); - tcg_debug_assert(end_op); - - op = end_op; - for (i = 0; i < cbs->len; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - if (!ok(begin_op, cb)) { - continue; - } - op = inject(cb, begin_op, op, &cb_idx); - } - rm_ops_range(begin_op, end_op); -} - -static void -inject_inline_cb(const GArray *cbs, TCGOp *begin_op, op_ok_fn ok) -{ - inject_cb_type(cbs, begin_op, append_inline_cb, ok); -} - -static void -inject_mem_cb(const GArray *cbs, TCGOp *begin_op) -{ - inject_cb_type(cbs, begin_op, append_mem_cb, op_rw); -} - /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { @@ -451,23 +124,6 @@ void plugin_gen_disable_mem_helpers(void) } } -static void plugin_gen_mem_regular(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - inject_mem_cb(insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], begin_op); -} - -static void plugin_gen_mem_inline(const struct qemu_plugin_tb *ptb, - TCGOp *begin_op, int insn_idx) -{ - const GArray *cbs; - struct qemu_plugin_insn *insn = g_ptr_array_index(ptb->insns, insn_idx); - - cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; - inject_inline_cb(cbs, begin_op, op_rw); -} - static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, struct qemu_plugin_insn *insn) { @@ -557,6 +213,21 @@ static void gen_inline_cb(struct qemu_plugin_dyn_cb *cb) tcg_temp_free_ptr(ptr); } +static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb, + qemu_plugin_meminfo_t meminfo, TCGv_i64 addr) +{ + 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_call4(cb->regular.f.vcpu_mem, cb->regular.info, NULL, + tcgv_i32_temp(cpu_index), + tcgv_i32_temp(tcg_constant_i32(meminfo)), + tcgv_i64_temp(addr), + tcgv_ptr_temp(tcg_constant_ptr(cb->userp))); + tcg_temp_free_i32(cpu_index); +} + /* #define DEBUG_PLUGIN_GEN_OPS */ static void pr_ops(void) { @@ -705,34 +376,43 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) break; } - case INDEX_op_plugin_cb_start: + case INDEX_op_plugin_mem_cb: { - enum plugin_gen_from from = op->args[0]; - enum plugin_gen_cb type = op->args[1]; + TCGv_i64 addr = temp_tcgv_i64(arg_temp(op->args[0])); + qemu_plugin_meminfo_t meminfo = op->args[1]; + struct qemu_plugin_insn *insn; + const GArray *cbs; + int i, n, rw; - switch (from) { - case PLUGIN_GEN_FROM_MEM: - { - g_assert(insn_idx >= 0); + assert(insn_idx >= 0); + insn = g_ptr_array_index(plugin_tb->insns, insn_idx); + rw = qemu_plugin_mem_is_store(meminfo) ? 2 : 1; - switch (type) { - case PLUGIN_GEN_CB_MEM: - plugin_gen_mem_regular(plugin_tb, op, insn_idx); - break; - case PLUGIN_GEN_CB_INLINE: - plugin_gen_mem_inline(plugin_tb, op, insn_idx); - break; - default: - g_assert_not_reached(); + tcg_ctx->emit_before_op = op; + + cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + if (cb->rw & rw) { + gen_mem_cb(cb, meminfo, addr); } + } - break; - } - default: - g_assert_not_reached(); + cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; + for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { + struct qemu_plugin_dyn_cb *cb = + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); + if (cb->rw & rw) { + gen_inline_cb(cb); + } } + + tcg_ctx->emit_before_op = NULL; + tcg_op_remove(tcg_ctx, op); break; } + default: /* plugins don't care about any other ops */ break; diff --git a/tcg/tcg-op-ldst.c b/tcg/tcg-op-ldst.c index f11043b449..8510160258 100644 --- a/tcg/tcg-op-ldst.c +++ b/tcg/tcg-op-ldst.c @@ -161,14 +161,14 @@ plugin_gen_mem_callbacks(TCGv_i64 copy_addr, TCGTemp *orig_addr, MemOpIdx oi, copy_addr = tcg_temp_ebb_new_i64(); tcg_gen_extu_i32_i64(copy_addr, temp_tcgv_i32(orig_addr)); } - plugin_gen_empty_mem_callback(copy_addr, info); + tcg_gen_plugin_mem_cb(copy_addr, info); tcg_temp_free_i64(copy_addr); } else { if (copy_addr) { - plugin_gen_empty_mem_callback(copy_addr, info); + tcg_gen_plugin_mem_cb(copy_addr, info); tcg_temp_free_i64(copy_addr); } else { - plugin_gen_empty_mem_callback(temp_tcgv_i64(orig_addr), info); + tcg_gen_plugin_mem_cb(temp_tcgv_i64(orig_addr), info); } } } diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 0f2026c91c..0ae12fa49d 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -317,6 +317,11 @@ void tcg_gen_plugin_cb(unsigned from) tcg_gen_op1(INDEX_op_plugin_cb, from); } +void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo) +{ + tcg_gen_op2(INDEX_op_plugin_mem_cb, tcgv_i64_arg(addr), meminfo); +} + void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr) { tcg_gen_op3(INDEX_op_plugin_cb_start, from, type, wr); From patchwork Sat Mar 16 01:57:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780750 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489537wrs; Fri, 15 Mar 2024 18:59:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVEOVv12rxGoEC3sZLEdfqhVIc0+Z4nM+GF7YDP10FROFhmIosXaMAzFJdfQ5kX96RX/B6o/7Gz7JY2Sv1Mf+i3 X-Google-Smtp-Source: AGHT+IG9tbh9atZVjsYwQbRO8ueJF1oVyTLmIFtHxiXA/UQzeHPMXHuW1PlRh45XB5oMJz2Wsc6z X-Received: by 2002:a05:620a:100a:b0:789:cd44:6b1 with SMTP id z10-20020a05620a100a00b00789cd4406b1mr6626322qkj.2.1710554377996; Fri, 15 Mar 2024 18:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554377; cv=none; d=google.com; s=arc-20160816; b=BZ0u6YRFx/LucIVvmSdMmO/j2/nHbdCZe5bD5g9KyLU0HBpT+wa/1UWqqEBNz/NIVe 8hefwmkz6VC/dtvL2rfZ0GBq0385wQYpM4atJN4gA52O2HAi50csHMio5ItroIa/717w Ay5ZAgf2zmIrlw4lvqxknPL9NvngXLfyfHR6UuLTiIfxbzVV8Wule3YPgpJPcicqECOm ngyHHn+jxNQetn6QihIdFrA0Bzi6TfXs9B+YB1beCMxfZClfIqRQfZdRdBDcheIYbNa5 xRa+yJblor9Bkn/KcOyqDvYhXB4L5oRcsI+cu41kl0Pyq1QHugKrexkipjLUyNBYMgeZ fjyg== 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=r3h8QUtdpv2Bkm8l3PLViSF5XzQ3nzd/ZWsA5m75Pu0=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=0qqpsP8q5sqbHdx2aSTY5JEmV1RsMciEQlL7t18ofRN0BdrYxRW4V7T2r0RqvPtLZR TyArYLTIsW3kLLiByV+x2ESL9svTbrgtO+kSp4QVrzbOtnbqQTEFfaTvqA6VV+cfrrD4 Ahr7HFAs0eF6snzHPiMxSQxZ8O3ov4TxxROSe7zW9wTetGlMZ+Jjaw79Sd9Guzj5SrIn R1QsWsXQuZ4x/y7Pa+gfRnj5bfmdX/8e4RT0BYuYH6AN6eI0ZZxruTLsEdJYk5TbnXXr yvim0VOLlE6XmFgG81Cd/XGV5K0chsScorpbSVVHd4L2tNrsVOWPnhDIW3C1hNeLqALp KGrw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gmN2AxlK; 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 wk16-20020a05620a579000b00789e7189e0csi2074533qkn.687.2024.03.15.18.59.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:37 -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=gmN2AxlK; 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 1rlJJ4-0002rY-38; Fri, 15 Mar 2024 21:57:54 -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 1rlJJ2-0002r0-1A for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:52 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJ0-0000lG-FA for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:51 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1dd9b6098aeso20337085ad.0 for ; Fri, 15 Mar 2024 18:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554269; x=1711159069; 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=r3h8QUtdpv2Bkm8l3PLViSF5XzQ3nzd/ZWsA5m75Pu0=; b=gmN2AxlKeiDcACMGGZv+zBUn184OKaH0coHm2iMLsCyVdUGFV8LArSGq294M3/o55U JHG4PGTLG2blXtvb74J+2JeagaCP7o0C0qtVCSU21qnQ30khwQpI9tDv6xsDioY979vF WUuup9OH5ewXoriu44/q7y4f25U0czW8YnLbQMPdTrTQD7jZ7Fd2zpX/rzT11pPXSKDh BAaizdSUpdYBzbbPvQJQqeyKHc/iYAf0/iHitkl4TxVmMrHFAH5lUe0IQojL/2c0dlKw 34eVwcJeLvxJXpo3ITr5m4Hn0x4gCfnb5hpTEnKegRp9ZBwxqY9/NkckWJRWPRDJV7q5 dbQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554269; x=1711159069; 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=r3h8QUtdpv2Bkm8l3PLViSF5XzQ3nzd/ZWsA5m75Pu0=; b=vVF/j5GtNOfDSx8UhSQs/yhOyC8hC2j59/oOqt168nC9vHmnupZFwxH4NqB8zF0iKl Xh4KZA2mbzRPq9V7u8TXMXaaFq8Y6Y/tJlcga3bFTK++dOhoMiL+22rZh/9eBBTnBWTO glCakQp/D5RCiCFJLFizX3jIR9krvq5+iCJgDZo9Cqf+CQGGoVhtgx9HH+KnOqaxTE0V qPgaQ/KVcR7CV5OdDjNkhDTSU4+nrwpgAf5Mlg8JdvIvwfCDEVn1jf3abxxLkP9TPoL+ xMPOgu2XB0dWhITtHOKZdDmK3GEnKo9YmYaPTHfgFf/OV/cKpguSF5ONFE2zsUbZ6RPj 03Bw== X-Gm-Message-State: AOJu0Yx7QSUYXpoupxPfpegOldSj+gDOy0ixyAyBAZjZHkKuRksB97I1 66dm3d4j3lEbnxbpbDoC9YEE+UBbn2intxc9ZOW/rq8+IlMSpi3Xxnjl/m4Xp2UH4JHStcoVYEb T X-Received: by 2002:a17:903:187:b0:1de:de58:2a55 with SMTP id z7-20020a170903018700b001dede582a55mr6684883plg.26.1710554269156; Fri, 15 Mar 2024 18:57:49 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 12/22] plugins: Remove plugin helpers Date: Fri, 15 Mar 2024 15:57:10 -1000 Message-Id: <20240316015720.3661236-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These placeholder helpers are no longer required. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- accel/tcg/plugin-helpers.h | 5 ----- include/exec/helper-gen-common.h | 4 ---- include/exec/helper-proto-common.h | 4 ---- accel/tcg/plugin-gen.c | 20 -------------------- 4 files changed, 33 deletions(-) delete mode 100644 accel/tcg/plugin-helpers.h diff --git a/accel/tcg/plugin-helpers.h b/accel/tcg/plugin-helpers.h deleted file mode 100644 index 11796436f3..0000000000 --- a/accel/tcg/plugin-helpers.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef CONFIG_PLUGIN -DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb_no_wg, TCG_CALL_NO_WG | TCG_CALL_PLUGIN, void, i32, ptr) -DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb_no_rwg, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, ptr) -DEF_HELPER_FLAGS_4(plugin_vcpu_mem_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, i32, i64, ptr) -#endif diff --git a/include/exec/helper-gen-common.h b/include/exec/helper-gen-common.h index 5d6d78a625..834590dc4e 100644 --- a/include/exec/helper-gen-common.h +++ b/include/exec/helper-gen-common.h @@ -11,8 +11,4 @@ #include "exec/helper-gen.h.inc" #undef HELPER_H -#define HELPER_H "accel/tcg/plugin-helpers.h" -#include "exec/helper-gen.h.inc" -#undef HELPER_H - #endif /* HELPER_GEN_COMMON_H */ diff --git a/include/exec/helper-proto-common.h b/include/exec/helper-proto-common.h index 8b67170a22..16782ef46c 100644 --- a/include/exec/helper-proto-common.h +++ b/include/exec/helper-proto-common.h @@ -13,8 +13,4 @@ #include "exec/helper-proto.h.inc" #undef HELPER_H -#define HELPER_H "accel/tcg/plugin-helpers.h" -#include "exec/helper-proto.h.inc" -#undef HELPER_H - #endif /* HELPER_PROTO_COMMON_H */ diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index be7fd548cc..b5261edc38 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -51,11 +51,6 @@ #include "exec/exec-all.h" #include "exec/plugin-gen.h" #include "exec/translator.h" -#include "exec/helper-proto-common.h" - -#define HELPER_H "accel/tcg/plugin-helpers.h" -#include "exec/helper-info.c.inc" -#undef HELPER_H #ifdef CONFIG_SOFTMMU # define CONFIG_SOFTMMU_GATE 1 @@ -88,21 +83,6 @@ enum plugin_gen_cb { PLUGIN_GEN_N_CBS, }; -/* - * These helpers are stubs that get dynamically switched out for calls - * direct to the plugin if they are subscribed to. - */ -void HELPER(plugin_vcpu_udata_cb_no_wg)(uint32_t cpu_index, void *udata) -{ } - -void HELPER(plugin_vcpu_udata_cb_no_rwg)(uint32_t cpu_index, void *udata) -{ } - -void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, - qemu_plugin_meminfo_t info, uint64_t vaddr, - void *userdata) -{ } - static void plugin_gen_empty_callback(enum plugin_gen_from from) { switch (from) { From patchwork Sat Mar 16 01:57:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780743 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489441wrs; Fri, 15 Mar 2024 18:59:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWiXMeIzkXmo5rXOtCOhZG2BdgedzQUp/Zvsn77JD7MLlpKCr5YChf+ty14KdZbMhitrERIAIYwBI93tILhawvp X-Google-Smtp-Source: AGHT+IGeKNhAr1Oa6YI7pWUs5iZx59qhU9gft2k6y3w5Y7UCbDEI5/HYIGY6IM4sTlkVJh6zZJ9J X-Received: by 2002:a05:6808:d4e:b0:3c3:7ea0:cbf3 with SMTP id w14-20020a0568080d4e00b003c37ea0cbf3mr606940oik.15.1710554349944; Fri, 15 Mar 2024 18:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554349; cv=none; d=google.com; s=arc-20160816; b=DoNO5YLH8xzCa0eF6vs+1N8ipBuHcDxg0XKFEIz1wi9W2+4j2HkeVlAO+C2GrMc7cY SKAKVWXdMkwatLJ2Re2AYHpcz/Wi+cFb9k+ZZQ2Y+7v8QFjnVh3St8ddinVTDokxJpwj E0kvK5n/TMeirwnSxwb4I3jn/Z+BDRSdWlz6maZGfYa4JSNtcnWXm0vXK42OTBEho0f0 IQ5kqTV6EptXnEsDAGr3r+zOmFDumt4IE78IUwzyKFiW9NxLtfPk0V0OTKy2hehGlDxn Ykb3jUH+QJy54E89qaIqv2PSbM7pCRfuczDYprzVD9W6VDa7+C4CxMrNLoxydy6d+eKy bVSw== 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=a4/P6RWm6w7Ud7tHYlYhwMNF/R2rr67Q03MPgnoMVeQ=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=TzEGxl1HRhYC4FeSc6cRzbV/T3xry79EciPoelwqlPcElgbWG+8K9Yd7xvLNraXZ5Y Jn8ps830gNIjWgdG0/2UlxnLMbhD/7H2IEKG0IVV84D6hX2sIBGQwuezMfOj/cWDlcuB GHry2DbZjaeIxodW8Qmv2XZ+32kD9ahq7VRXGhO0sC09HWO8aVyhPMCaAj/ZxXZGRqec iGCYIuvR0epko248e5HAArfTQj3ukhvMdPmssfkRbPcA/IM3m+ZU1r3IJWftqYN4So8x WRwAQD5JxDP256VDSXi/ymkJVprF5OcemNxl1LzLjwynJ/j2UZraUYcmH5un9UBemNtl Iuuw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XT2cDvRc; 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 o6-20020a0562140e4600b00690db5d7f7bsi3871289qvc.373.2024.03.15.18.59.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:09 -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=XT2cDvRc; 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 1rlJJH-0002xr-F6; Fri, 15 Mar 2024 21:58:08 -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 1rlJJ4-0002ra-3g for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:54 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJ2-0000lW-G7 for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:53 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-29de4c33441so1467807a91.1 for ; Fri, 15 Mar 2024 18:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554271; x=1711159071; 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=a4/P6RWm6w7Ud7tHYlYhwMNF/R2rr67Q03MPgnoMVeQ=; b=XT2cDvRcs9v1z7XDuYkT2v6GLve2SGglhG7IgEKj/bMFS0PHH/mx0qqlrpU1CD9Bs7 R+1b+c9NHcGKR2+p5NMmh8T/ZRZnB5tlTBYtO7aWTt4J/5HDumo8ROVhekSIZVZ7Duv2 LQH71ChXGhcl2TVCjBY1GCFzfvSqcpm4Cft6KvDrcbRyVm+WppHEaidxyFu+ahlktpVF w/JFzKun4DZCEJRteFUvUQJ7vAHoiF65Vi9qbzmWzMd4pHFdFA6u1C57jgxkd7QiVX7L j3ofxdOr7mmCG63TNRz2tuyVsZcVCdZYcnC0uNyRLgHIXiyLSIoE8V89hNEHLnr94xl9 C3Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554271; x=1711159071; 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=a4/P6RWm6w7Ud7tHYlYhwMNF/R2rr67Q03MPgnoMVeQ=; b=jpJAZHexfk6WNN5adjRJArw5qLXdxTBw+jsKWrk4V2xKmw0YbIJhN++ZkiHD9GbVkY u1Kx8+gmZAHEXhWF5NTHlfQyt20whyQh/iHy7rKx07X4MRhlAfCPU2G8JeyFNXjCk++U dUffGUQKibYgMXeCmUDwsbHPG/DDIiI8Xkictz8i8qRxgVBZtJrrACyH/dloG19+TKNs sdhgRlCo4eNkPjz/OMX2E9XA8AsRHdmVfdKvnvq8qJ4EFiYY/Sv+Kum/mfd/KikReLoK 2qh+72tyrJy/fnadZdmcdmZA5W76nwsjY+IQYDTmNsv1jS8nXibeexJP0lCUZf5rl5ry NxBg== X-Gm-Message-State: AOJu0YwnMWe+gU/VPDd/ZYF/Sr5Ebyo53h3tCgkV04mwG8sJtIbe58D1 Ttd4VcMBr3qRxXHocZtzgQGsNSX19hb4wtYcnLxbIFnEgW7Irus6RWlaLA0xCJRa1KxPhUZ/Qgh D X-Received: by 2002:a17:903:943:b0:1de:de26:f6b3 with SMTP id ma3-20020a170903094300b001dede26f6b3mr6499331plb.26.1710554271164; Fri, 15 Mar 2024 18:57:51 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 13/22] tcg: Remove TCG_CALL_PLUGIN Date: Fri, 15 Mar 2024 15:57:11 -1000 Message-Id: <20240316015720.3661236-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since we no longer emit plugin helpers during the initial code translation phase, we don't need to specially mark plugin helpers. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/tcg/tcg.h | 2 -- plugins/core.c | 10 ++++------ tcg/tcg.c | 4 +--- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 95a7f4d010..df66e8f012 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -353,8 +353,6 @@ typedef TCGv_ptr TCGv_env; #define TCG_CALL_NO_SIDE_EFFECTS 0x0004 /* Helper is G_NORETURN. */ #define TCG_CALL_NO_RETURN 0x0008 -/* Helper is part of Plugins. */ -#define TCG_CALL_PLUGIN 0x0010 /* convenience version of most used call flags */ #define TCG_CALL_NO_RWG TCG_CALL_NO_READ_GLOBALS diff --git a/plugins/core.c b/plugins/core.c index b0a2e80874..b0615f1e7f 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -339,9 +339,8 @@ void plugin_register_dyn_cb__udata(GArray **arr, void *udata) { static TCGHelperInfo info[3] = { - [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, - [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, - [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG, /* * Match qemu_plugin_vcpu_udata_cb_t: * void (*)(uint32_t, void *) @@ -375,9 +374,8 @@ void plugin_register_vcpu_mem_cb(GArray **arr, !__builtin_types_compatible_p(qemu_plugin_meminfo_t, int32_t)); static TCGHelperInfo info[3] = { - [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, - [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG | TCG_CALL_PLUGIN, - [QEMU_PLUGIN_CB_RW_REGS].flags = TCG_CALL_PLUGIN, + [QEMU_PLUGIN_CB_NO_REGS].flags = TCG_CALL_NO_RWG, + [QEMU_PLUGIN_CB_R_REGS].flags = TCG_CALL_NO_WG, /* * Match qemu_plugin_vcpu_mem_cb_t: * void (*)(uint32_t, qemu_plugin_meminfo_t, uint64_t, void *) diff --git a/tcg/tcg.c b/tcg/tcg.c index 0bf218314b..363a065e28 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2269,9 +2269,7 @@ static void tcg_gen_callN(void *func, TCGHelperInfo *info, #ifdef CONFIG_PLUGIN /* Flag helpers that may affect guest state */ - if (tcg_ctx->plugin_insn && - !(info->flags & TCG_CALL_PLUGIN) && - !(info->flags & TCG_CALL_NO_SIDE_EFFECTS)) { + if (tcg_ctx->plugin_insn && !(info->flags & TCG_CALL_NO_SIDE_EFFECTS)) { tcg_ctx->plugin_insn->calls_helpers = true; } #endif From patchwork Sat Mar 16 01:57:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780740 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489362wrs; Fri, 15 Mar 2024 18:58:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV7qv2Fpxkp6GMZdJpLKWSeRrO/1wvo2wkFSZZrCF1UWE4ESEVzsLVCWMuHpN/m9k9z1i4PCpbQhpPwObQzWtwi X-Google-Smtp-Source: AGHT+IHpVB2Atml2QJgA89XvFC/31ncSaq1EI80OplM0+F6fYBzEQLMo0hzdxLANQzYzXFWjl87e X-Received: by 2002:a0c:e705:0:b0:690:beb7:c6da with SMTP id d5-20020a0ce705000000b00690beb7c6damr5805016qvn.38.1710554332146; Fri, 15 Mar 2024 18:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554332; cv=none; d=google.com; s=arc-20160816; b=bRuk1qbTu9H84JRE8VZjwQzII7803FJrLY00JM64FXh+JgNkN7FiHE3mklyUHr5xbb 1qafptrMMWFjjckk2OTs2sdOqQYHq11d589L8L3Z1yQMknEwbshZh0OWwB0tStJByXRQ ayVrZ9UMykLi7ntxqskk0p3nGPcmTF//qqeGfLtW/NvBYnmkO14Ec9kppAVPvDFaJaGC mHhtkxk7w71IMuraJxAQ7zxGRjnvtJajID+8CIzP90R2i2dArcWJ4tnDLni4g2r85uCq ddZe68tjsDwCEjUYhZfmSwRjZ8Mmk6XTvyXNfwvGcERD1aZ2OB0eukTQRTkJZ+v9i4uD Qx2g== 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=pfrhB6wtiY1dRspgCcVihnqjgoTQCBAZYhtK1KymQU8=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=v2xxA20j61AIZK0Mzn78OwG16TZdTmAznLY+h3Zu1LuJ9i8oa1RGt3xNpS7dwxIyej XBus9hYFrNG+RiH5uV4KjxPAYrJg7hcrTbDPJlGwXP/2yF5ZZ9duHfxIN3ifIUF3L3H8 99eufy4NYh1a0PkJjtDW7qeIdWyIQgD+TkRP7oeKMnKebo/rlygg1ZlYtM2jX2566b2S 0nc/bjEPaBXUQ9fs8v1P5ZriEaDh++veKa75jBtBvmgPnIPFAPdelyeojjmMjCUGfSOa 0ERcyKm3LGoEfSN9O5RFY4m/oDprSPo159rbp/yo+0CKVb1d5Sv2Zbaj5bFGZAATF+k+ R96A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZDXl6Je7; 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 r11-20020a0562140c8b00b006910d0d2ae4si3895523qvr.211.2024.03.15.18.58.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:58:52 -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=ZDXl6Je7; 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 1rlJJC-0002v5-Ej; Fri, 15 Mar 2024 21:58:04 -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 1rlJJ6-0002s5-Uh for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:59 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJ5-0000m2-5g for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:57:56 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dee5daa236so15052625ad.0 for ; Fri, 15 Mar 2024 18:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554273; x=1711159073; 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=pfrhB6wtiY1dRspgCcVihnqjgoTQCBAZYhtK1KymQU8=; b=ZDXl6Je7jGLn16nCYdR4z7RTllvyIjvsYUgmSvNxFvajUIegfVv7WS1K3IyT1GRLR0 4vbxdgm5gGq+K1JuqUpTAr8bDOEwh8CX0P2/48gcMoYyd1yCDUzsJ8kBv6J8q0+dvcJd j17DJIvvTZaG69KkbxBzULHRHSEYomgfAiqy/zYSV8nE+Q17iraTBa2sUJ5uH2PNXpVi IqOijzjNkTfsiDec/5jRZbCna1eQIdl4UaUtqm9zoakPfnR8rh5dIB7I8sLA+fyF0+qG E4vxMWGwpr2tKjnBpMA8obUg+mRMR4a/+3iKRz0wYp96Z0n6+MkgeGLSkRmDMgfHCdyY bzhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554273; x=1711159073; 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=pfrhB6wtiY1dRspgCcVihnqjgoTQCBAZYhtK1KymQU8=; b=eEMu38Yu0suMy4qqDrvIuTOYIy3pSO6NqKLmd0IXFfYNLoC6i79ZZ1oPkECs1fNdyO /bBBGsoTUfMlAOplqccVc0BlvwkXDTzjlo/3B3Xoz6jhIBryKP3M8VnhcoNkseqqkt/x ZwTvlamAVhFYvkMeU1f8bJ7lbwAvNSGta9+yK7w6MYgsv+P462mtsIIrZ6meIeMjmLNX bLKLJdIrFG1dH3vz2rfOOOvBYcKirgbeWImz24rtAy7YchANvQPszUtUdr8P2JP2Ae+r MV2DtS8g7VNjrWoXBhsi6gn5N3TfzyohdY76kq0/iLEzgoSR022YC0KtTWJ5Sqz01vxz aVbA== X-Gm-Message-State: AOJu0Yx126+IM7Xikvo7covqNxSrref0+40kV4fqjL1j1CWBVq17ReF5 Up2SCLVUb7/Xs8EUWD83hg/uNT7zJomlfInwyaQi29UdvLqLwqCYp+UHT6hmm8kNnS89qiFn2g7 w X-Received: by 2002:a17:902:d2d0:b0:1dc:6d64:dcff with SMTP id n16-20020a170902d2d000b001dc6d64dcffmr6432966plc.37.1710554272928; Fri, 15 Mar 2024 18:57:52 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 14/22] tcg: Remove INDEX_op_plugin_cb_{start,end} Date: Fri, 15 Mar 2024 15:57:12 -1000 Message-Id: <20240316015720.3661236-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These opcodes are no longer used. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/tcg/tcg-op-common.h | 2 -- include/tcg/tcg-opc.h | 2 -- accel/tcg/plugin-gen.c | 18 ------------------ tcg/tcg-op.c | 10 ---------- 4 files changed, 32 deletions(-) diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index 72b80b20d0..009e2778c5 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -76,8 +76,6 @@ void tcg_gen_lookup_and_goto_ptr(void); void tcg_gen_plugin_cb(unsigned from); void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo); -void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr); -void tcg_gen_plugin_cb_end(void); /* 32 bit ops */ diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index be9e36e386..546eb49c11 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -199,8 +199,6 @@ DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) DEF(plugin_cb, 0, 0, 1, TCG_OPF_NOT_PRESENT) DEF(plugin_mem_cb, 0, 1, 1, TCG_OPF_NOT_PRESENT) -DEF(plugin_cb_start, 0, 0, 3, TCG_OPF_NOT_PRESENT) -DEF(plugin_cb_end, 0, 0, 0, TCG_OPF_NOT_PRESENT) /* Replicate ld/st ops for 32 and 64-bit guest addresses. */ DEF(qemu_ld_a32_i32, 1, 1, 1, diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index b5261edc38..c8f0e0ecaa 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -58,29 +58,11 @@ # define CONFIG_SOFTMMU_GATE 0 #endif -/* - * plugin_cb_start TCG op args[]: - * 0: enum plugin_gen_from - * 1: enum plugin_gen_cb - * 2: set to 1 for mem callback that is a write, 0 otherwise. - */ - enum plugin_gen_from { PLUGIN_GEN_FROM_TB, PLUGIN_GEN_FROM_INSN, PLUGIN_GEN_AFTER_INSN, PLUGIN_GEN_AFTER_TB, - PLUGIN_GEN_N_FROMS, -}; - -enum plugin_gen_cb { - PLUGIN_GEN_CB_UDATA, - PLUGIN_GEN_CB_UDATA_R, - PLUGIN_GEN_CB_INLINE, - PLUGIN_GEN_CB_MEM, - PLUGIN_GEN_ENABLE_MEM_HELPER, - PLUGIN_GEN_DISABLE_MEM_HELPER, - PLUGIN_GEN_N_CBS, }; static void plugin_gen_empty_callback(enum plugin_gen_from from) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 0ae12fa49d..eff3728622 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -322,16 +322,6 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo) tcg_gen_op2(INDEX_op_plugin_mem_cb, tcgv_i64_arg(addr), meminfo); } -void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr) -{ - tcg_gen_op3(INDEX_op_plugin_cb_start, from, type, wr); -} - -void tcg_gen_plugin_cb_end(void) -{ - tcg_emit_op(INDEX_op_plugin_cb_end, 0); -} - /* 32 bit ops */ void tcg_gen_discard_i32(TCGv_i32 arg) From patchwork Sat Mar 16 01:57:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780756 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489703wrs; Fri, 15 Mar 2024 19:00:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV8E8wC5/F/PoeHdqc8xFqIivAFllcFowI/hhfRCXVPevOwVNZMoOdqbUAYHl96kG3vR19O3SkiXQaxxNtaBIMy X-Google-Smtp-Source: AGHT+IGflVSTik7HiPD8GIsF2YQxByi2cciGTHzoR1UWgrWG7OJiFpmsxcMr/lIpA0AN+d48mmmE X-Received: by 2002:ad4:4041:0:b0:690:d4b8:a09 with SMTP id r1-20020ad44041000000b00690d4b80a09mr7546364qvp.39.1710554408738; Fri, 15 Mar 2024 19:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554408; cv=none; d=google.com; s=arc-20160816; b=CZa6bw+eJXdlL+Nzo/g2jyMN86hm6mQPbKUgYjS+OpGhZEkhzRuVGACDIOc/QZQ/2K 7U5Ux6soYS6kxxf9fdd1NdMcPsmDw8JIFYut/PqdEF6eNyol3mtSdw4OAVhmNAK2vvPP 05Td10RwfRA8dUNpr72BFyl9rUkhWuIl7W8andhNzpTu8P0MGyNKPXOhzL/6MsmCoKzT lxf3xrm2fSdP5pj9A1PGvAAQLwH4ILfHZ5gUc2DptPg+G0h2/Xc8IiaV4iIZpAWqE4Ng /3y479zZyIJJ1jCCDhw8i47crfqpY0ep7UUjUUwpZTdHsscAK3hffIkrhjHjfukF4yyD 4VkA== 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=1r860Fs0umWNdHdT/Kjt1p732OG4U2qCU3kOvvc/EXA=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=zGhXVCRrHdUp1bzsCkgV9N1RQy1MjsMAv8xdAmjMA0ZJUDrQxNxDu6sv+fnSDPviZr ptnZ//ZJJ1Ffx1f0XTTL2UxHf+k9kNTdnv2ONAVOEfxjtJXJZtjrZYpZ5fOCSvPxy6V/ Xu7Pm8/Sgq/kcCJxXESKWnOscjJMXIhsgXXCXIAqCx4nXIUJ43vd1PSztPojG0rR1JmT VAGRHUf5lqCa+zLL3GiQD4kBVZ5eWEypiTwZczJBvhe+mS5mYqq84qpbC3JPxxIlOmHV gw2AwmWCkf3/htxuOueMmxg4qB0/6W0Oucqjts29Fx/+QO5b+WjvuGaw7bLOzT6ga5d/ +04Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C6hqQhuc; 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 q14-20020ad45cae000000b0068cb633507asi3902231qvh.575.2024.03.15.19.00.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 19:00:08 -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=C6hqQhuc; 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 1rlJJP-00031w-7b; Fri, 15 Mar 2024 21:58:15 -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 1rlJJI-0002zB-LJ for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:10 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJ6-0000mC-2i for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:08 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1def142ae7bso11280255ad.3 for ; Fri, 15 Mar 2024 18:57:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554274; x=1711159074; 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=1r860Fs0umWNdHdT/Kjt1p732OG4U2qCU3kOvvc/EXA=; b=C6hqQhucmvJoFsRhlkclp1wl8V7zDuNe5RZBlIi09iLbivPehlQZjvEwdKNAUTWLPy bRJQ7fKtO8qArytBULWJCiTWjX8LPG62VRPYYjcPzrkmwAbZQw3PFJbaSAMnfOWnGAe5 8GYfH0RnQSR5FAqhKBFqcTtz408MHkkLv6Om4f3zvH08OWsfv/K0a5SdylD21rcvyDTh 97jqcYYmC4wWWxwSgWaEU+1XGUbraWa25o6u7uQ7zyBMLXkzzQIxF5yeQjSiIpTtWH0P 2j6BQQT+SiUWSORWc9Wcew/Pml+V+mHi8bYCn/am9osJxaJ+SFzU6mER7W58hMG+ZxZZ PH4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554275; x=1711159075; 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=1r860Fs0umWNdHdT/Kjt1p732OG4U2qCU3kOvvc/EXA=; b=ESUD6caqfXdaWdrciUjKPY4DiLvdTXaKf3BK3PZyN8aQqO60Jfhftzf8ep9sG9C3qt c+mUJeioCppkcsco5XMM4jU8Swq81l6XvYVIYTusmB6yIJ7p07DHwM7o0fvC4csbzbYh 0NMfCvn6fRMngMCeBudhyc6n9hJIOF/qOdgQmFSGKFEpboj9k5ScBFn4ay7A5ctNyq89 ywWmi1GCh2eb3B82OcvLYPvIDkGeX8Ot+S8Mv7W4Djql6w0WSAt6NRW+avvIjkoiZUjM pgVXcJoVlV61bNIHK6lbUuEluio7uR1+RalIJOq62jKNuicEz4Y6AyqgQOlQR91u8M5x wGYA== X-Gm-Message-State: AOJu0YxEQY132qVmIgGk7cC2kaBwQPGuC3UjZhuEgHBvAqjMH5Cyoa75 dPME703zPeC9SZ8e322zZIiiT+kN9nE7YicPIuxvHe2t5X9gNPDIKJMqzd/RQJW6EnKr6f/3SW+ G X-Received: by 2002:a17:902:e551:b0:1dd:c24d:4d1f with SMTP id n17-20020a170902e55100b001ddc24d4d1fmr7475289plf.67.1710554274583; Fri, 15 Mar 2024 18:57:54 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 15/22] plugins: Simplify callback queues Date: Fri, 15 Mar 2024 15:57:13 -1000 Message-Id: <20240316015720.3661236-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We have qemu_plugin_dyn_cb.type to differentiate the various callback types, so we do not need to keep them in separate queues. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/qemu/plugin.h | 35 ++++++---------- accel/tcg/plugin-gen.c | 90 ++++++++++++++++++++++-------------------- plugins/api.c | 18 +++------ 3 files changed, 65 insertions(+), 78 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index ee1c1b174a..cf9758be55 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -66,15 +66,8 @@ union qemu_plugin_cb_sig { }; enum plugin_dyn_cb_type { - PLUGIN_CB_INSN, - PLUGIN_CB_MEM, - PLUGIN_N_CB_TYPES, -}; - -enum plugin_dyn_cb_subtype { PLUGIN_CB_REGULAR, PLUGIN_CB_INLINE, - PLUGIN_N_CB_SUBTYPES, }; /* @@ -84,7 +77,7 @@ enum plugin_dyn_cb_subtype { */ struct qemu_plugin_dyn_cb { void *userp; - enum plugin_dyn_cb_subtype type; + enum plugin_dyn_cb_type type; /* @rw applies to mem callbacks only (both regular and inline) */ enum qemu_plugin_mem_rw rw; /* fields specific to each dyn_cb type go here */ @@ -106,7 +99,8 @@ struct qemu_plugin_insn { GByteArray *data; uint64_t vaddr; void *haddr; - GArray *cbs[PLUGIN_N_CB_TYPES][PLUGIN_N_CB_SUBTYPES]; + GArray *insn_cbs; + GArray *mem_cbs; bool calls_helpers; /* if set, the instruction calls helpers that might access guest memory */ @@ -135,16 +129,9 @@ static inline void qemu_plugin_insn_cleanup_fn(gpointer data) static inline struct qemu_plugin_insn *qemu_plugin_insn_alloc(void) { - int i, j; struct qemu_plugin_insn *insn = g_new0(struct qemu_plugin_insn, 1); - insn->data = g_byte_array_sized_new(4); - for (i = 0; i < PLUGIN_N_CB_TYPES; i++) { - for (j = 0; j < PLUGIN_N_CB_SUBTYPES; j++) { - insn->cbs[i][j] = g_array_new(false, false, - sizeof(struct qemu_plugin_dyn_cb)); - } - } + insn->data = g_byte_array_sized_new(4); return insn; } @@ -161,7 +148,7 @@ struct qemu_plugin_tb { /* if set, the TB calls helpers that might access guest memory */ bool mem_helper; - GArray *cbs[PLUGIN_N_CB_SUBTYPES]; + GArray *cbs; }; /** @@ -174,22 +161,22 @@ struct qemu_plugin_insn *qemu_plugin_tb_insn_get(struct qemu_plugin_tb *tb, uint64_t pc) { struct qemu_plugin_insn *insn; - int i, j; if (unlikely(tb->n == tb->insns->len)) { struct qemu_plugin_insn *new_insn = qemu_plugin_insn_alloc(); g_ptr_array_add(tb->insns, new_insn); } + insn = g_ptr_array_index(tb->insns, tb->n++); g_byte_array_set_size(insn->data, 0); insn->calls_helpers = false; insn->mem_helper = false; insn->vaddr = pc; - - for (i = 0; i < PLUGIN_N_CB_TYPES; i++) { - for (j = 0; j < PLUGIN_N_CB_SUBTYPES; j++) { - g_array_set_size(insn->cbs[i][j], 0); - } + if (insn->insn_cbs) { + g_array_set_size(insn->insn_cbs, 0); + } + if (insn->mem_cbs) { + g_array_set_size(insn->mem_cbs, 0); } return insn; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index c8f0e0ecaa..669e343cfb 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -89,9 +89,8 @@ void plugin_gen_disable_mem_helpers(void) static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, struct qemu_plugin_insn *insn) { - GArray *cbs[2]; GArray *arr; - size_t n_cbs; + size_t len; /* * Tracking memory accesses performed from helpers requires extra work. @@ -110,22 +109,25 @@ static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, return; } - cbs[0] = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; - cbs[1] = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; - n_cbs = cbs[0]->len + cbs[1]->len; - - if (n_cbs == 0) { + if (!insn->mem_cbs || !insn->mem_cbs->len) { insn->mem_helper = false; return; } insn->mem_helper = true; ptb->mem_helper = true; + /* + * TODO: It seems like we should be able to use ref/unref + * to avoid needing to actually copy this array. + * Alternately, perhaps we could allocate new memory adjacent + * to the TranslationBlock itself, so that we do not have to + * actively manage the lifetime after this. + */ + len = insn->mem_cbs->len; arr = g_array_sized_new(false, false, - sizeof(struct qemu_plugin_dyn_cb), n_cbs); - g_array_append_vals(arr, cbs[0]->data, cbs[0]->len); - g_array_append_vals(arr, cbs[1]->data, cbs[1]->len); - + sizeof(struct qemu_plugin_dyn_cb), len); + memcpy(arr->data, insn->mem_cbs->data, + len * sizeof(struct qemu_plugin_dyn_cb)); qemu_plugin_add_dyn_cb_arr(arr); tcg_gen_st_ptr(tcg_constant_ptr((intptr_t)arr), tcg_env, @@ -294,18 +296,21 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) case PLUGIN_GEN_FROM_TB: assert(insn == NULL); - cbs = plugin_tb->cbs[PLUGIN_CB_REGULAR]; + cbs = plugin_tb->cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { struct qemu_plugin_dyn_cb *cb = &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - gen_udata_cb(cb); - } - cbs = plugin_tb->cbs[PLUGIN_CB_INLINE]; - for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - gen_inline_cb(cb); + switch (cb->type) { + case PLUGIN_CB_REGULAR: + gen_udata_cb(cb); + break; + case PLUGIN_CB_INLINE: + gen_inline_cb(cb); + break; + default: + g_assert_not_reached(); + } } break; @@ -314,18 +319,21 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) gen_enable_mem_helper(plugin_tb, insn); - cbs = insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR]; + cbs = insn->insn_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { struct qemu_plugin_dyn_cb *cb = &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - gen_udata_cb(cb); - } - cbs = insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE]; - for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - gen_inline_cb(cb); + switch (cb->type) { + case PLUGIN_CB_REGULAR: + gen_udata_cb(cb); + break; + case PLUGIN_CB_INLINE: + gen_inline_cb(cb); + break; + default: + g_assert_not_reached(); + } } break; @@ -352,21 +360,22 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) tcg_ctx->emit_before_op = op; - cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR]; + cbs = insn->mem_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { struct qemu_plugin_dyn_cb *cb = &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - if (cb->rw & rw) { - gen_mem_cb(cb, meminfo, addr); - } - } - cbs = insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE]; - for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); if (cb->rw & rw) { - gen_inline_cb(cb); + switch (cb->type) { + case PLUGIN_CB_REGULAR: + gen_mem_cb(cb, meminfo, addr); + break; + case PLUGIN_CB_INLINE: + gen_inline_cb(cb); + break; + default: + g_assert_not_reached(); + } } } @@ -390,13 +399,10 @@ bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, cpu->plugin_state->event_mask)) { struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb; - int i; /* reset callbacks */ - for (i = 0; i < PLUGIN_N_CB_SUBTYPES; i++) { - if (ptb->cbs[i]) { - g_array_set_size(ptb->cbs[i], 0); - } + if (ptb->cbs) { + g_array_set_size(ptb->cbs, 0); } ptb->n = 0; diff --git a/plugins/api.c b/plugins/api.c index 29cce2d97c..3912c9cc8f 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -92,8 +92,7 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_plugin_tb *tb, void *udata) { if (!tb->mem_only) { - plugin_register_dyn_cb__udata(&tb->cbs[PLUGIN_CB_REGULAR], - cb, flags, udata); + plugin_register_dyn_cb__udata(&tb->cbs, cb, flags, udata); } } @@ -104,8 +103,7 @@ void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( uint64_t imm) { if (!tb->mem_only) { - plugin_register_inline_op_on_entry( - &tb->cbs[PLUGIN_CB_INLINE], 0, op, entry, imm); + plugin_register_inline_op_on_entry(&tb->cbs, 0, op, entry, imm); } } @@ -115,8 +113,7 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qemu_plugin_insn *insn, void *udata) { if (!insn->mem_only) { - plugin_register_dyn_cb__udata( - &insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_REGULAR], cb, flags, udata); + plugin_register_dyn_cb__udata(&insn->insn_cbs, cb, flags, udata); } } @@ -127,8 +124,7 @@ void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( uint64_t imm) { if (!insn->mem_only) { - plugin_register_inline_op_on_entry( - &insn->cbs[PLUGIN_CB_INSN][PLUGIN_CB_INLINE], 0, op, entry, imm); + plugin_register_inline_op_on_entry(&insn->insn_cbs, 0, op, entry, imm); } } @@ -143,8 +139,7 @@ void qemu_plugin_register_vcpu_mem_cb(struct qemu_plugin_insn *insn, enum qemu_plugin_mem_rw rw, void *udata) { - plugin_register_vcpu_mem_cb(&insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_REGULAR], - cb, flags, rw, udata); + plugin_register_vcpu_mem_cb(&insn->mem_cbs, cb, flags, rw, udata); } void qemu_plugin_register_vcpu_mem_inline_per_vcpu( @@ -154,8 +149,7 @@ void qemu_plugin_register_vcpu_mem_inline_per_vcpu( qemu_plugin_u64 entry, uint64_t imm) { - plugin_register_inline_op_on_entry( - &insn->cbs[PLUGIN_CB_MEM][PLUGIN_CB_INLINE], rw, op, entry, imm); + plugin_register_inline_op_on_entry(&insn->mem_cbs, rw, op, entry, imm); } void qemu_plugin_register_vcpu_tb_trans_cb(qemu_plugin_id_t id, From patchwork Sat Mar 16 01:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780751 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489551wrs; Fri, 15 Mar 2024 18:59:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXwjs38aclBKewFFeC1Ow8tpClydRh2j1JgSr+b++yeT7hsXCdMw192p/sBUZthntetnwU2FbDYCVBRERot6CNL X-Google-Smtp-Source: AGHT+IF6sYfPfNWJxslovSeRMs5kve14MXk8oSu08HDR5ZVhI+h7pC4+R1Zko4DYkeiT+dcFBYRk X-Received: by 2002:a05:620a:2110:b0:789:e73d:9ec7 with SMTP id l16-20020a05620a211000b00789e73d9ec7mr2881121qkl.69.1710554381906; Fri, 15 Mar 2024 18:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554381; cv=none; d=google.com; s=arc-20160816; b=JfKvGcvjJuiBZf761SmrxK0YzKfso4sZXi7gTrz9Oa84a4rwEOwkBwuxCTgzANp1nG tM3UJR0XzmqV47d0tizABY/AjlCHMnRmQfqEkMdkGHlJMc4EtUardAoTwV5ek1YvpDoW q8v0X+uteb88mWkKOzaqbsrWzRq3Dk6NyMriMvspnJOzBJdydMEQ8jGVHS+i/5HUr1xm xkAv4odjy4xkeToU3JQ70mYksWuJ8TbkeZNg0UG2Hya1l2Mna4GP48R4yvRr5CjXwSzf BSVjbVCt0MqmrBNh6oXQ2xknNH5oir5VCOHyiYAenvj9ODAtNYAxhl7b7GbR1n+bF0EO sQmw== 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=wurtzFqTOAUqad7j3dN96Y1gK8V7tm4jLC9zvYbsnSw=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=wFPx1D8ZhfeK+VkvvVwEpUa57sxVw7/gizn0gONxsZGjvLyNYuW3kff5I059Y8iPHz Bc3BPbnW4hGifAnzpWNyAz46WHMwYkfTI8nnhH4E6UnWtv70w8LozLw7XjSv+r6VDo12 4GjiiYwNNojAkU0sauPceAjjvYJMUuuKSrtJN7iRlbqDdy6XB64ZqChp378cgDOmcK40 Mc0nMafUG/FWvr2hXi20I8U3zl+1GJbRED5Sjoadto1lT6nMiNyZMR9Txt0zaJ7iwkRo KTV4ldkaujzxs816cDvbiwm9SZ1ZfDwKD1XZJ3li8juO1FUjckgiPFbOc2FCzHiX1zDY 6q3w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VHRSitp0; 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 dt21-20020a05620a479500b00789ed7b0a06si502011qkb.229.2024.03.15.18.59.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:41 -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=VHRSitp0; 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 1rlJJN-00030o-Ll; Fri, 15 Mar 2024 21:58:13 -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 1rlJJD-0002x9-Rz for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:05 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJ7-0000mP-Ts for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:03 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dffd764036so23015ad.1 for ; Fri, 15 Mar 2024 18:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554276; x=1711159076; 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=wurtzFqTOAUqad7j3dN96Y1gK8V7tm4jLC9zvYbsnSw=; b=VHRSitp0PaRKdlhLXq8aAOGV3LAcwS86Wz67sYdIWE8tqaocsGwM3CpStaswWrcZ9y XjeQcFknkZV1JNzxBpPMPSyOfVXmN5wSjp5JNmqrzmswFs7WVChqAWxDxozH2xtU0aFf rz1csP/ro8BsBBeEAoZaNOUqa3HQ5KTadYdm4Avuoym0FzIOAqDEOxvN01pTfDphLFuC 7sle6AJ+6RMtVX5uxed1fqgLwhk8fOaLBy0g23b3Nb6O0+PWBlL7DrXCP5g3WOAjc1zF Uu0QpqBvRbtqlZMrZgTClc+04og5cQli9zo2ISwGa0w7YyvrB8h/jcUkLNdxAEhiZh9w CMrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554276; x=1711159076; 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=wurtzFqTOAUqad7j3dN96Y1gK8V7tm4jLC9zvYbsnSw=; b=KX4C8674pcYdNY/+787m8U61Jv4Pg2NaM+3LKg09ob0irKyZVTTZrykDa+tinsrVAq 47WH3PtHW1Wu+eKOhQsgvIi+Rs17jtBl92TfSE62eR0uENvI1jYy9rupiS2sbfDooKuu 5ZgV/U5H//IfcE/DDXec4stHy93EU0tjl98rIrHcL7tPb2mAygMFhFBwGR43BEsiiFgl QvHbspAwXgvWDQc7kk53FaV/abHa/ibjTkiK9dczasucbIWFNK+/9wxY9EMD4QeboSEO Mzj8iZECW/QdPoels0xcsEjidxwM9h9ep7z+in5ZUL+3R/ncQl3y4M0QVri3pkdVkP/T f0CQ== X-Gm-Message-State: AOJu0Yz9WJ6ISmZs6MXBl699ShBq1IFvztZZEehnUQ5/EWhkm5m+MgDf jSC5shZ3c30ELzPKyWiwJuFw5BMZbmSaPFmTdixPMDQDRaJrREH5wwXxqzGWDu5oyuXFZpdR8Hb 5 X-Received: by 2002:a17:902:f68b:b0:1dc:af70:9f78 with SMTP id l11-20020a170902f68b00b001dcaf709f78mr7915128plg.46.1710554276419; Fri, 15 Mar 2024 18:57:56 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 16/22] plugins: Introduce PLUGIN_CB_MEM_REGULAR Date: Fri, 15 Mar 2024 15:57:14 -1000 Message-Id: <20240316015720.3661236-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use different enumerators for vcpu_udata and vcpu_mem callbacks. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/qemu/plugin.h | 1 + accel/tcg/plugin-gen.c | 2 +- plugins/core.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index cf9758be55..34498da717 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -67,6 +67,7 @@ union qemu_plugin_cb_sig { enum plugin_dyn_cb_type { PLUGIN_CB_REGULAR, + PLUGIN_CB_MEM_REGULAR, PLUGIN_CB_INLINE, }; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 669e343cfb..6f0731b479 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -367,7 +367,7 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) if (cb->rw & rw) { switch (cb->type) { - case PLUGIN_CB_REGULAR: + case PLUGIN_CB_MEM_REGULAR: gen_mem_cb(cb, meminfo, addr); break; case PLUGIN_CB_INLINE: diff --git a/plugins/core.c b/plugins/core.c index b0615f1e7f..0213513ec6 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -391,7 +391,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr, struct qemu_plugin_dyn_cb *dyn_cb = plugin_get_dyn_cb(arr); dyn_cb->userp = udata; - dyn_cb->type = PLUGIN_CB_REGULAR; + dyn_cb->type = PLUGIN_CB_MEM_REGULAR; dyn_cb->rw = rw; dyn_cb->regular.f.vcpu_mem = cb; @@ -547,7 +547,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, break; } switch (cb->type) { - case PLUGIN_CB_REGULAR: + case PLUGIN_CB_MEM_REGULAR: cb->regular.f.vcpu_mem(cpu->cpu_index, make_plugin_meminfo(oi, rw), vaddr, cb->userp); break; From patchwork Sat Mar 16 01:57:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780755 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489623wrs; Fri, 15 Mar 2024 18:59:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVGXEda0fFirDiGaxbXt3lf+CtFS8uYHdWTEIW+defaXKZ6wionBOGezbb1ZcHxXzzvmWrvb3U1dK0JfGX7HoTt X-Google-Smtp-Source: AGHT+IFwPBwg2nE/msTMwY700vQSx7SWG5/onwH0UicV3jPZIcYycAMqoBd/abQ02p5tUln+YuAr X-Received: by 2002:a05:622a:90:b0:42e:58c6:bc9e with SMTP id o16-20020a05622a009000b0042e58c6bc9emr6196118qtw.60.1710554396752; Fri, 15 Mar 2024 18:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554396; cv=none; d=google.com; s=arc-20160816; b=Y0wIbDqJA5us0TLImA+x/IbANR+9PiCCQ4M0veqwNiwt7UE87Jd6wkBd0qavkTGoSw 9dVtePGoksxQNYvfOrlLN8QlMvlbPDaVB+xCXnJAZ3oIWGFJOWv+HlrYlzpLl9PN/wAO FSATYrU5X658Hf+FivHo0ImjD9FLfLcu31heXm7Kg73pQ/jkIRVP5zURwBjl5UOmvXBe A52RAXk733TVZ8fQUrQkbVX0nT9FnNdhuXArxMhpKltYD7JoPo/sp7cuyO20z4XMMs7r WyodmGlfgjq7ZEl8mwmOmiozOu8PdADbv+ltqq2/CN4fp0Wj/fMAEjLy1y8nBRk1KB+7 PoOQ== 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=aXNCxUw+xNH5pFREtrweHMcItwOMy2358ghWL5eYh0A=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=XFjELszCV3IqwkcVzmb8mV9AAY1QepQ4Fb+MbaScW5U9Fy/8Xk7+6bRvE1EjBFDZs4 3oU0pzFwNXQnz8AMSJ6mIQoXtxyVkGQUuBwpw5HOs0jQKGPLX0lgNIQw/zSGLQ3tfOml rn0S/152wMLFelWmk1eeM83jQ9UXi0QxRFgRgKL6ZF+DcmyWA7DW5LVc/ewYD/zTed2k /FyuFlRNwdbmJstqFAFvV+nSjyR+qAkNQupqhrCDnVP7Qt3BP7L2YLBm1Rgqk2saFP/U XK5ruG0ozJ8mB4t7q0ejBJvsYsLXEPA6l96qn5OS3RFRYel4m+05eYP1ss2wf/A+jqb6 YCOw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VWyWNssJ; 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 j7-20020a05622a038700b0042dff81e402si4912937qtx.471.2024.03.15.18.59.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:56 -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=VWyWNssJ; 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 1rlJJQ-00032Q-TD; Fri, 15 Mar 2024 21:58:16 -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 1rlJJE-0002xO-7W for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:05 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJ9-0000md-Rb for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:03 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1def59b537cso8376075ad.2 for ; Fri, 15 Mar 2024 18:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554278; x=1711159078; 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=aXNCxUw+xNH5pFREtrweHMcItwOMy2358ghWL5eYh0A=; b=VWyWNssJ4rLZ6EAcfD2JJO6Rrc+YuJA6pYt9il/iy3rtihEEeR+96ecZ5VMc/ih49W 3yHGrIox1ox1NpdsrhrmdXpzzlHsQX8nhFzkg9dIQ2Kguj8C2Feyoc+aAVRvUTUMdtmA oDRwf9RPQmJQchdTH6lFccbKBlL4c020a5rI2o53VBrg500guxg9wJCWJ8V03diV1yDA 2AkOPI8FTl7IYfkT/ZRsQuGDnd2Sq5ircz0Rmxjufwx3m/90nFpqf2CGlIC5irjrZHJ6 uz4yO1JX14/dD5I80U/nr13PwwBYf0KhFIhrJx8xtt+Xe32sYSK0VNVuXgXvYHIRfiMG a3jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554278; x=1711159078; 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=aXNCxUw+xNH5pFREtrweHMcItwOMy2358ghWL5eYh0A=; b=p0bfvRvfhoRyFWACeoE6svKNeChk+Ucwn/SjsZG3BF1PQLLmlIqqaNGZznrY8UcJCl 2r0//0vAVMd6AbJart7SkD2zNkLVg/3rnVT4WYZTdjGNb3sOVX1YiM7XmAzyvJSgWhin CFx3IBXTCQ+K5MnlDQTdMQolEwcLtnTfS6YMcAq2X1CvyP4PSoSIRr2TkmS+MKoM98o3 fqCAAght16zuYh+AIRw5AruNlq1HJm5T8Ur113Wer/+ZKQSL498S9OvGvkwCSEXK2iOl aSJ3OknuzA+9oby475Ay4jncujtqZApASUr4kP3D/1a2B0MF3FX+bneT6j8LilckpZQs 32kw== X-Gm-Message-State: AOJu0YyDHeyo7lO5HiiRnqNVz9i6KYOgy+9Hf96DA+eJ9USF/vtVXD/P 7YXaAaRo5wrhz6PzL7UoKyadq6jXVnyMq4idevilgOmgoOiKhbVCqQhlz+KkyL+bCSJtqGNUqca W X-Received: by 2002:a17:902:e54c:b0:1dd:a33f:5916 with SMTP id n12-20020a170902e54c00b001dda33f5916mr5630078plf.4.1710554278476; Fri, 15 Mar 2024 18:57:58 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 17/22] plugins: Replace pr_ops with a proper debug dump flag Date: Fri, 15 Mar 2024 15:57:15 -1000 Message-Id: <20240316015720.3661236-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The DEBUG_PLUGIN_GEN_OPS ifdef is replaced with "-d op_plugin". The second pr_ops call can be obtained with "-d op". Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/qemu/log.h | 1 + include/tcg/tcg.h | 1 + accel/tcg/plugin-gen.c | 68 ++++++++---------------------------------- tcg/tcg.c | 29 +++++++++++++++++- util/log.c | 4 +++ 5 files changed, 46 insertions(+), 57 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index df59bfabcd..e10e24cd4f 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -36,6 +36,7 @@ bool qemu_log_separate(void); #define LOG_STRACE (1 << 19) #define LOG_PER_THREAD (1 << 20) #define CPU_LOG_TB_VPU (1 << 21) +#define LOG_TB_OP_PLUGIN (1 << 22) /* Lock/unlock output. */ diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index df66e8f012..753d7ca3e0 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -1065,5 +1065,6 @@ static inline const TCGOpcode *tcg_swap_vecop_list(const TCGOpcode *n) } bool tcg_can_emit_vecop_list(const TCGOpcode *, TCGType, unsigned); +void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs); #endif /* TCG_H */ diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 6f0731b479..10d917abd3 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -44,6 +44,7 @@ */ #include "qemu/osdep.h" #include "qemu/plugin.h" +#include "qemu/log.h" #include "cpu.h" #include "tcg/tcg.h" #include "tcg/tcg-temp-internal.h" @@ -58,6 +59,7 @@ # define CONFIG_SOFTMMU_GATE 0 #endif +/* Update plugin_from_name in tcg.c. */ enum plugin_gen_from { PLUGIN_GEN_FROM_TB, PLUGIN_GEN_FROM_INSN, @@ -192,66 +194,21 @@ static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb, tcg_temp_free_i32(cpu_index); } -/* #define DEBUG_PLUGIN_GEN_OPS */ -static void pr_ops(void) -{ -#ifdef DEBUG_PLUGIN_GEN_OPS - TCGOp *op; - int i = 0; - - QTAILQ_FOREACH(op, &tcg_ctx->ops, link) { - const char *name = ""; - const char *type = ""; - - if (op->opc == INDEX_op_plugin_cb_start) { - switch (op->args[0]) { - case PLUGIN_GEN_FROM_TB: - name = "tb"; - break; - case PLUGIN_GEN_FROM_INSN: - name = "insn"; - break; - case PLUGIN_GEN_FROM_MEM: - name = "mem"; - break; - case PLUGIN_GEN_AFTER_INSN: - name = "after insn"; - break; - default: - break; - } - switch (op->args[1]) { - case PLUGIN_GEN_CB_UDATA: - type = "udata"; - break; - case PLUGIN_GEN_CB_INLINE: - type = "inline"; - break; - case PLUGIN_GEN_CB_MEM: - type = "mem"; - break; - case PLUGIN_GEN_ENABLE_MEM_HELPER: - type = "enable mem helper"; - break; - case PLUGIN_GEN_DISABLE_MEM_HELPER: - type = "disable mem helper"; - break; - default: - break; - } - } - printf("op[%2i]: %s %s %s\n", i, tcg_op_defs[op->opc].name, name, type); - i++; - } -#endif -} - static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { TCGOp *op, *next; int insn_idx = -1; - pr_ops(); + if (unlikely(qemu_loglevel_mask(LOG_TB_OP_PLUGIN) + && qemu_log_in_addr_range(plugin_tb->vaddr))) { + FILE *logfile = qemu_log_trylock(); + if (logfile) { + fprintf(logfile, "OP before plugin injection:\n"); + tcg_dump_ops(tcg_ctx, logfile, false); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } + } /* * While injecting code, we cannot afford to reuse any ebb temps @@ -389,7 +346,6 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) break; } } - pr_ops(); } bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, diff --git a/tcg/tcg.c b/tcg/tcg.c index 363a065e28..d248c52e96 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2540,6 +2540,15 @@ static const char bswap_flag_name[][6] = { [TCG_BSWAP_IZ | TCG_BSWAP_OS] = "iz,os", }; +#ifdef CONFIG_PLUGIN +static const char * const plugin_from_name[] = { + "from-tb", + "from-insn", + "after-insn", + "after-tb", +}; +#endif + static inline bool tcg_regset_single(TCGRegSet d) { return (d & (d - 1)) == 0; @@ -2558,7 +2567,7 @@ static inline TCGReg tcg_regset_first(TCGRegSet d) #define ne_fprintf(...) \ ({ int ret_ = fprintf(__VA_ARGS__); ret_ >= 0 ? ret_ : 0; }) -static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) +void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) { char buf[128]; TCGOp *op; @@ -2714,6 +2723,24 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) i = k = 1; } break; +#ifdef CONFIG_PLUGIN + case INDEX_op_plugin_cb: + { + TCGArg from = op->args[k++]; + const char *name = NULL; + + if (from < ARRAY_SIZE(plugin_from_name)) { + name = plugin_from_name[from]; + } + if (name) { + col += ne_fprintf(f, "%s", name); + } else { + col += ne_fprintf(f, "$0x%" TCG_PRIlx, from); + } + i = 1; + } + break; +#endif default: i = 0; break; diff --git a/util/log.c b/util/log.c index d36c98da0b..6219819855 100644 --- a/util/log.c +++ b/util/log.c @@ -466,6 +466,10 @@ const QEMULogItem qemu_log_items[] = { "show micro ops after optimization" }, { CPU_LOG_TB_OP_IND, "op_ind", "show micro ops before indirect lowering" }, +#ifdef CONFIG_PLUGIN + { LOG_TB_OP_PLUGIN, "op_plugin", + "show micro ops before plugin injection" }, +#endif { CPU_LOG_INT, "int", "show interrupts/exceptions in short format" }, { CPU_LOG_EXEC, "exec", From patchwork Sat Mar 16 01:57:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780753 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489572wrs; Fri, 15 Mar 2024 18:59:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWGNkjrHKSfc6LK7HESZBVq9jV5kj04Bp9KgimIhP5IYrzsmQxjy4e4aBfGcdFgAxhYf7FRt0CTkZsT76NytHG0 X-Google-Smtp-Source: AGHT+IEATGOkmODQPYNStdt1KFBCwRJmu3J+7AzCISGeBGA+qDP/DrefwwujVYGIlcZ8AIAKgSqr X-Received: by 2002:a05:620a:145b:b0:789:e917:ac9e with SMTP id i27-20020a05620a145b00b00789e917ac9emr2316104qkl.47.1710554388793; Fri, 15 Mar 2024 18:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554388; cv=none; d=google.com; s=arc-20160816; b=NOU3dzBVfUyTmT5pOF9u13pzssD6Pg0q3I+vWyS01qkX3MYOeMhu5M8Zhp0z9DvcMh NqxbW9iVHnH6VCakVi9jp/NSydS1GWM0B+cb0mJJoLAZ7UUDY4EDbrABgldV+8KLeXIX ZGWNCTfASHoXyZO9tr8/orqG1MuNX06WWBBHzZm2cLH7q7hMEyhyxji83Ml9lq0glp3X PKMP3n5YbqGaQf2f6SEb68LQ38Ht4zS/mQ+wrredEuC74Mi1moRLKkDp7dTAQGMWVo1F mU0vJ0eAic0crNlO/LwC8FjawuIV8eZRq1EIO5HKiEWn8WBFxs9bVjShGqGs5kXENW80 TOpg== 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=6vZ2v0E2G9TI2cbvq58iFtaf/WAOAxyxcbXki0MuPsM=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=QmhPn8KBpRUVSac9CmBC3fZLHlrXC4AyLNHzn7WknHHEY/lnYCfzKotyepJJTiplzm ORZ+eznRoDpqcQGwYnyGVbKXc2Pu6h9fpmCcr4V4ltf/jC+pqaDjimBQdQgshJr//2NV VxjESolvClGwuw7mWSD+untWPNrCHkMPWjQpNdPycJDh/LwncE+rW/j54sQWTUPpU0BQ SuK7k9FTRFo1Z3YhWAziNbKQlrtoQeBYoWUl4Ole58JpE9AJ6y1H4iPkBIn8b7/Hgcwj iKmMeKze8vE+lSa/kcjX+X8/IshTkpn628EatwHx70zHjG3OxcZwhY4F0LFB/NLikk1Z CyXg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ELUq04eM; 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 c21-20020a05620a165500b00789dd63d4cesi3814781qko.93.2024.03.15.18.59.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:48 -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=ELUq04eM; 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 1rlJJN-00030r-OF; Fri, 15 Mar 2024 21:58:13 -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 1rlJJE-0002xM-7W for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:05 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJB-0000n0-S7 for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:03 -0400 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-29b7caa88c6so2138075a91.0 for ; Fri, 15 Mar 2024 18:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554280; x=1711159080; 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=6vZ2v0E2G9TI2cbvq58iFtaf/WAOAxyxcbXki0MuPsM=; b=ELUq04eM19IBBI8w78PudLEx6js0bvZL56QiN73/cOSGSSG5n0LZztIbjhkU4qZfja A/h7mwnrYwLPnMI0b0uOgr9P6im2obwsjrZm8YXEb3MUhZVEqT5rs47d/+X9qz6eE6t/ XnTFGzrGyVVI7Ce7Q9vHV25WFHAyLoCTG701mNd41FX1bzcx5ArVi0ms42NLg/BLgEZ/ K5Hmv9Puc3i9L7QVmztjcN++6ap9v4OKG55PebdYP+6XwMnMmH1K8XNnEawHGsp06dx/ VbbnRpuhD62Uy3Us4LOb2lE2w2U07lI36Wil+A4JFStEyoaujXNk5gHc80FdV4uyvZfI wnLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554280; x=1711159080; 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=6vZ2v0E2G9TI2cbvq58iFtaf/WAOAxyxcbXki0MuPsM=; b=iHPRnNMS+SLa500DO42YC4VHpF/k98iBmRUx/VR1fCGl0AAdkzfmKmFQPRlH/0YQ1P J3ClOU1GLIIIVRt3c3v8O23OXuvWa73M+WBgi1dQB7+uYJPwm0lbDfROhD0Hi5CvcE3M AfY8OyYyFwGJbQeMlt4zHXHaqJWodL10A814FlGCHBEr6nne3HQ26LWLBSwjy1VB7r8C 8qXx5w1QVoqRu2LIxMB4lpMnms0yBeBYRVZunDof250FFeMDkq+GtTS6v+mc8Rjgv1yf 076z2Jji21DELWVpZIFvcLv5Ay2Mm7lR8WJCUvOZiGisuzFjoAr5E6Vp3EdKEzlakZnE n/+Q== X-Gm-Message-State: AOJu0YxBzSHyr7p/+BqyjSqBxlA0GEiztqXIav0lRYOIXL3mWS9N+1HV EpZvoEbUhkeK13A4t+aZU8GIMWl2u/qMSOkMSvdYcppD8VnWLedlHkT3p1PbNfJH/uJ9A5l3dk6 G X-Received: by 2002:a17:903:2443:b0:1dd:7d64:8f35 with SMTP id l3-20020a170903244300b001dd7d648f35mr7444411pls.31.1710554280457; Fri, 15 Mar 2024 18:58:00 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:57:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 18/22] plugins: Split out common cb expanders Date: Fri, 15 Mar 2024 15:57:16 -1000 Message-Id: <20240316015720.3661236-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 84 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 10d917abd3..28414c4ff1 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -194,6 +194,37 @@ static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb, tcg_temp_free_i32(cpu_index); } +static void inject_cb(struct qemu_plugin_dyn_cb *cb) + +{ + switch (cb->type) { + case PLUGIN_CB_REGULAR: + gen_udata_cb(cb); + break; + case PLUGIN_CB_INLINE: + gen_inline_cb(cb); + break; + default: + g_assert_not_reached(); + } +} + +static void inject_mem_cb(struct qemu_plugin_dyn_cb *cb, + enum qemu_plugin_mem_rw rw, + qemu_plugin_meminfo_t meminfo, TCGv_i64 addr) +{ + if (cb->rw & rw) { + switch (cb->type) { + case PLUGIN_CB_MEM_REGULAR: + gen_mem_cb(cb, meminfo, addr); + break; + default: + inject_cb(cb); + break; + } + } +} + static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { TCGOp *op, *next; @@ -255,19 +286,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) cbs = plugin_tb->cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - switch (cb->type) { - case PLUGIN_CB_REGULAR: - gen_udata_cb(cb); - break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); - break; - default: - g_assert_not_reached(); - } + inject_cb( + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i)); } break; @@ -278,19 +298,8 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) cbs = insn->insn_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - switch (cb->type) { - case PLUGIN_CB_REGULAR: - gen_udata_cb(cb); - break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); - break; - default: - g_assert_not_reached(); - } + inject_cb( + &g_array_index(cbs, struct qemu_plugin_dyn_cb, i)); } break; @@ -307,33 +316,22 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { TCGv_i64 addr = temp_tcgv_i64(arg_temp(op->args[0])); qemu_plugin_meminfo_t meminfo = op->args[1]; + enum qemu_plugin_mem_rw rw = + (qemu_plugin_mem_is_store(meminfo) + ? QEMU_PLUGIN_MEM_W : QEMU_PLUGIN_MEM_R); struct qemu_plugin_insn *insn; const GArray *cbs; - int i, n, rw; + int i, n; assert(insn_idx >= 0); insn = g_ptr_array_index(plugin_tb->insns, insn_idx); - rw = qemu_plugin_mem_is_store(meminfo) ? 2 : 1; tcg_ctx->emit_before_op = op; cbs = insn->mem_cbs; for (i = 0, n = (cbs ? cbs->len : 0); i < n; i++) { - struct qemu_plugin_dyn_cb *cb = - &g_array_index(cbs, struct qemu_plugin_dyn_cb, i); - - if (cb->rw & rw) { - switch (cb->type) { - case PLUGIN_CB_MEM_REGULAR: - gen_mem_cb(cb, meminfo, addr); - break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); - break; - default: - g_assert_not_reached(); - } - } + inject_mem_cb(&g_array_index(cbs, struct qemu_plugin_dyn_cb, i), + rw, meminfo, addr); } tcg_ctx->emit_before_op = NULL; From patchwork Sat Mar 16 01:57:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780742 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489371wrs; Fri, 15 Mar 2024 18:58:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXtQI0v/pKPifTipInQguPT4xqzySEKEG9ABjQ5ROUK6qActEr2G0x357YAs9nvMh7xcR/bddjMswvIGY4uOBny X-Google-Smtp-Source: AGHT+IEUAwSm1LtugqgoyMYO2HhFkYhtWodpKGyGQRfOC5g6g+Cz78hTwoZtw3lcMWI55PN4aKd6 X-Received: by 2002:ac8:5c8e:0:b0:430:ad62:32fc with SMTP id r14-20020ac85c8e000000b00430ad6232fcmr5026772qta.45.1710554334710; Fri, 15 Mar 2024 18:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554334; cv=none; d=google.com; s=arc-20160816; b=FRCtyFcP3GVCpV2uMmuvhgKpdr2Pk9fYk1UKacdA5w1mt0aNW/lf1asxInbXeW5o+p rpCb93MxhE5lb8UYK/Rq2uQFBOOEW54xLI5uogtN1Ez/gEDE23kKfNuELB+0zDa3Y4LK iBEwrmw+dFV6EC077KAQ+i8zUAT2ybdErAnXTsPgsUHtTr6xruH2D0u2/vB1VdxAtFO+ Mh6YXU11ng2jBzaNEww5bQPHOMaK/CyBiz4qwd+T3N+/lamR85NkgqeHSxBhoCeFHj36 SmXafdoulB81vtubgjZCl3XYVeLD6Btljif1xS3W65PYEWTIOH/36WGksnZfsxO56lO+ g32g== 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=XgRR5z5N9ZwHDXdf41GgZ4jwjQp2wWo1KDtmOb5J2wQ=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=Rmw1cmfElIkhMTVsU/gOM/vRJCnbl/av8AbZ5IkLVIuwOM0NPATXckaeIelY6mFOVV d3QoqvLKkUJaujRnBngOd3lNUExX6AkBw9jo7DJ2yNgFHxkTBbjQvCUma/WsPUgETAGk YaiKhfGNyRhsKJlQw/o43PnrKDfzqamFTOCaZy1PXxN2WR1a+2+EGpGe/+hB7eywmODd l6SiQRDAJpr/N3ha0HLMcIQ2Yk531b1opfLFcMmSlbi39dRb/CLDimGUWl4GtXYsKo8P L5Y0qnA745sfHrwb2BBYFOIkY9gFqKU50G5RRooOqF3eL6scfhIcchcDVfW5DbqRPnlt ZsOg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ONjPB90m; 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 x19-20020a05620a14b300b007882531c274si4860558qkj.535.2024.03.15.18.58.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:58:54 -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=ONjPB90m; 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 1rlJJN-00030l-LV; Fri, 15 Mar 2024 21:58:13 -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 1rlJJF-0002xu-K9 for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:07 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJD-0000nL-RZ for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:05 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1dff837d674so1595975ad.3 for ; Fri, 15 Mar 2024 18:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554282; x=1711159082; 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=XgRR5z5N9ZwHDXdf41GgZ4jwjQp2wWo1KDtmOb5J2wQ=; b=ONjPB90mU3KHmE03s1nE0Pvus8BiQyKxoO7QSGwgI+Or5S7p+4l4o8izlFO+/WCLjK aLEw5sefbCaOr0kMjCpTBIVgbzoQqOnt8IkEg8zrJPI94sY34K06cFUpR/TUH2WyFHrr jwDiP88cs41W38btRPMg77L1CT0GK/j/1QB7uj2soxhkeaVlFofKa5KgOq4KvwWBX6Cp t8eNk2xbSBfpyObnd3QrNMEGS8BL2OwrxGVXHHyD9rC5h++tEGBMeWpdnBzdPMbdrXnp 2fnoJbWubMrg9yS6MLv3QRWuQeqL1EjTqo6CgrDpzvNQrhyxdFKjIQRJN/i68U1tNfbk bbHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554282; x=1711159082; 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=XgRR5z5N9ZwHDXdf41GgZ4jwjQp2wWo1KDtmOb5J2wQ=; b=jL2WkuQyf/Nr3W4+L+HUZrp/bu25HDf/gKZ4AALrDm0+tHBtEn4et/Biwv3oYEjlNA duyDPEsnbZD5qIu3h3xrZvqixswNNwRzlfvcMTz8xw2Z8wouqUhAZg7xTFXpAUx2f8WP +K/H8objSNXt3w9HhB6qCBsHUxQkuyvYg0lzfOGrKlQoyHgOBuTTC/L07Mylf1nlOgJK Tf+xUM4nBumLLYG0i7zTTImaHA+x2IFbNlkGqMwO4TIZ3B2AIFbNiNXf8Sui7T071aoo 2yH/EwF5vAOPj8uBOi/lpDa3AljYRB0TV8qO871m4B0qLTg2OKvpsV1YVKIUFIWDh6gT ITEQ== X-Gm-Message-State: AOJu0Yxcr5skTphZkXIs8ees8DgV6WzEcoczThrGtV81vzJrV1RuHzbK I2psWmPLAKZrfpTLQb1qC5ZeChBvD/qB8YssTxlbnTMjQSg8wdV4jbCidgv+1fYD5ihOYKHavYV E X-Received: by 2002:a17:902:da8b:b0:1dd:b3e0:519d with SMTP id j11-20020a170902da8b00b001ddb3e0519dmr8072434plx.6.1710554282422; Fri, 15 Mar 2024 18:58:02 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:58:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 19/22] plugins: Merge qemu_plugin_tb_insn_get to plugin-gen.c Date: Fri, 15 Mar 2024 15:57:17 -1000 Message-Id: <20240316015720.3661236-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Merge qemu_plugin_insn_alloc and qemu_plugin_tb_insn_get into plugin_gen_insn_start, since it is used nowhere else. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- include/qemu/plugin.h | 39 --------------------------------------- accel/tcg/plugin-gen.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 34498da717..07b1755990 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -128,14 +128,6 @@ static inline void qemu_plugin_insn_cleanup_fn(gpointer data) g_byte_array_free(insn->data, true); } -static inline struct qemu_plugin_insn *qemu_plugin_insn_alloc(void) -{ - struct qemu_plugin_insn *insn = g_new0(struct qemu_plugin_insn, 1); - - insn->data = g_byte_array_sized_new(4); - return insn; -} - /* Internal context for this TranslationBlock */ struct qemu_plugin_tb { GPtrArray *insns; @@ -152,37 +144,6 @@ struct qemu_plugin_tb { GArray *cbs; }; -/** - * qemu_plugin_tb_insn_get(): get next plugin record for translation. - * @tb: the internal tb context - * @pc: address of instruction - */ -static inline -struct qemu_plugin_insn *qemu_plugin_tb_insn_get(struct qemu_plugin_tb *tb, - uint64_t pc) -{ - struct qemu_plugin_insn *insn; - - if (unlikely(tb->n == tb->insns->len)) { - struct qemu_plugin_insn *new_insn = qemu_plugin_insn_alloc(); - g_ptr_array_add(tb->insns, new_insn); - } - - insn = g_ptr_array_index(tb->insns, tb->n++); - g_byte_array_set_size(insn->data, 0); - insn->calls_helpers = false; - insn->mem_helper = false; - insn->vaddr = pc; - if (insn->insn_cbs) { - g_array_set_size(insn->insn_cbs, 0); - } - if (insn->mem_cbs) { - g_array_set_size(insn->mem_cbs, 0); - } - - return insn; -} - /** * struct CPUPluginState - per-CPU state for plugins * @event_mask: plugin event bitmap. Modified only via async work. diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 28414c4ff1..70914c3bf8 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -380,11 +380,34 @@ bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) { struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb; - struct qemu_plugin_insn *pinsn; + struct qemu_plugin_insn *insn; + size_t n = db->num_insns; + vaddr pc; - pinsn = qemu_plugin_tb_insn_get(ptb, db->pc_next); - tcg_ctx->plugin_insn = pinsn; - plugin_gen_empty_callback(PLUGIN_GEN_FROM_INSN); + assert(n >= 1); + ptb->n = n; + if (n <= ptb->insns->len) { + insn = g_ptr_array_index(ptb->insns, n - 1); + g_byte_array_set_size(insn->data, 0); + } else { + assert(n - 1 == ptb->insns->len); + insn = g_new0(struct qemu_plugin_insn, 1); + insn->data = g_byte_array_sized_new(4); + g_ptr_array_add(ptb->insns, insn); + } + + tcg_ctx->plugin_insn = insn; + insn->calls_helpers = false; + insn->mem_helper = false; + if (insn->insn_cbs) { + g_array_set_size(insn->insn_cbs, 0); + } + if (insn->mem_cbs) { + g_array_set_size(insn->mem_cbs, 0); + } + + pc = db->pc_next; + insn->vaddr = pc; /* * Detect page crossing to get the new host address. @@ -392,16 +415,18 @@ void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) * fetching instructions from a region not backed by RAM. */ if (ptb->haddr1 == NULL) { - pinsn->haddr = NULL; + insn->haddr = NULL; } else if (is_same_page(db, db->pc_next)) { - pinsn->haddr = ptb->haddr1 + pinsn->vaddr - ptb->vaddr; + insn->haddr = ptb->haddr1 + pc - ptb->vaddr; } else { if (ptb->vaddr2 == -1) { ptb->vaddr2 = TARGET_PAGE_ALIGN(db->pc_first); get_page_addr_code_hostp(cpu_env(cpu), ptb->vaddr2, &ptb->haddr2); } - pinsn->haddr = ptb->haddr2 + pinsn->vaddr - ptb->vaddr2; + insn->haddr = ptb->haddr2 + pc - ptb->vaddr2; } + + plugin_gen_empty_callback(PLUGIN_GEN_FROM_INSN); } void plugin_gen_insn_end(void) From patchwork Sat Mar 16 01:57:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780761 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp490126wrs; Fri, 15 Mar 2024 19:01:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVKqV+rkTwo32JYVVyuc9EiY3/CjsUSCDtEnOtaPPqpmlRke5NR5gmAZWwmHPOg3HoSdrxY+BDOBagwHBt3eyF+ X-Google-Smtp-Source: AGHT+IEXowiFT0BdoBmv68TODMp7Lm4K4H55iwd4qF0nS69l38pecyDX1EQw57pIYjuIFTd9u6ZC X-Received: by 2002:a05:620a:269e:b0:789:e745:b31 with SMTP id c30-20020a05620a269e00b00789e7450b31mr3702960qkp.58.1710554475383; Fri, 15 Mar 2024 19:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554475; cv=none; d=google.com; s=arc-20160816; b=JCYAK9nU0edK8MM06rUg/+1KhazPZiQufl3ayBVJkv/5eh8KI/7Ux4tnu7KJS0nppn RDYoWwDlCmD+C2y9wKDLGxTMgQLubcKpNuwWS1sy4xcCXxNSyeVg6PZueBN4Ze1Y5Vc3 fEK9SflDb9F8QbM+hZhj29IvUOEH6vw9AqN2buNQ0N8xW46P+ge5xUNqdIvx5c4nmiqq N1Y0y+iazbSOw5ZsNJ1Ee8LAvIHxSho9djxNJEdgm5Jkqpu6r9NeluR72nVIG7Ui0s8t VDjTSPj+R4A+Coh/O/pijAdr+UTaBZ6nQ6ySXMGMyWiyoILOB+nH9CRxUlk5GKfkC0Cr lIXA== 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=aoP+WuNen9axGI0bTk0+2XzD9h5L/3eLseZfJNUB13M=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=HLAPiDtBxpEIVqVtplEeqjDXPH+y4B2+BNnjzSHcoawXR58nm2GpMo1vDWktJmn/rD KDRpmio7PsNguLVppxkDUuFP7KIK5yjG97ss62xIKyAlTF87gtW1IUlQKqOO0DkUTf8P cWc+KLJOSBXKRRDN4gZI8rd6fa17KfGx0GgQZ4MEPMXHUUk3LuthyfYlk1QygNxNeL50 TtlwNKsobFZDli/T43VLLLX6kmJ5yhAiKMYQr52UzpP+UWb621Mwj9sLcoL2CejzU436 S7zrOY75csIkMMVwhOmOebyoVpR9Xr/ir3vn+zBnWIdt0fBTxk70FU7yfek3yoC/EAmD jZtw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EODOK4hM; 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 xx11-20020a05620a5d8b00b00789e737a01bsi1977324qkn.361.2024.03.15.19.01.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 19:01:15 -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=EODOK4hM; 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 1rlJJO-00031O-7Q; Fri, 15 Mar 2024 21:58:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlJJI-0002z3-FN for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:10 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJH-0000o3-0u for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:08 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1dff837d674so1596025ad.3 for ; Fri, 15 Mar 2024 18:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554284; x=1711159084; 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=aoP+WuNen9axGI0bTk0+2XzD9h5L/3eLseZfJNUB13M=; b=EODOK4hMrfPN5q/pJAqlu3gQO1Hzc5cFSnd5KSkihaFh+AJUxZSMTi/JGBlna4mdOA Vis8cPk109Ad1uosVluDyGwTb/92z6cuQU2+uSkmR6K8e8TBbqTDYtvuqAMI5/+/fUxa nETIw5ZtApx1onlzPwGgB9JdqJEUALNedMB69ow0ZUdk3t+fUrcrq1cyYKcZpBhTp5Wa T3WpPoWe3jnEXsPpcqvZDoAg49H4QGQjrEsm2Zq2r1JMOyylcjUiktayfwX76m29W14E awzbc6EYptDNpzcv65yqy2cR0u/fZhnfjo7vsV3FickoUjrLQXuEEZK24F8w86VbEWJK hLPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554284; x=1711159084; 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=aoP+WuNen9axGI0bTk0+2XzD9h5L/3eLseZfJNUB13M=; b=mSC5Vmh4wHTnJwon8dofe24W6/LDB3szaWAf3za/zbCXhD2KoVdMN3UBNh799/0Dk5 SdfH/X7Y0iy6QllFqJI0ZA+u2w8bKyJMTW/cKZsBGdcqZvojdA4lLEgny/tO20KzTGaK gJJ+J5xY16TuhM8dcdlvCIeFHDqFF3MN/G9N9X20DpROx+QXPCyUNYKmiMSGMP5IvEpG 3g2JCMWUIZzu74/Xn44KvN6EUN2qFlPcoRl6B2FkGGS2skEP465pYjBRnpgbXkx5W56U +NymMc8yHN3bi7dccjOWUfrTLEu4M+NK86qQ24OdFxpxqfaCplG8eD+AOkCvrdOLuTeH 2FZg== X-Gm-Message-State: AOJu0YyuF+BZ7QPu+ElspUfChCoyZT0JipC4/S4HdHUXUcIb1zRPJRWH djyfPwAIzsY+FEe4M0zpoxZUoLHEmqw1SVazQWmYvOWJhAIAGXd2ZVwlCHoB3FtFMzsP3FsysBL 2 X-Received: by 2002:a17:902:e5c1:b0:1dd:96cc:b5d1 with SMTP id u1-20020a170902e5c100b001dd96ccb5d1mr7773742plf.60.1710554284431; Fri, 15 Mar 2024 18:58:04 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:58:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 20/22] plugins: Move qemu_plugin_insn_cleanup_fn to tcg.c Date: Fri, 15 Mar 2024 15:57:18 -1000 Message-Id: <20240316015720.3661236-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This is only used in one place, and usage requires an out-of-line function. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/qemu/plugin.h | 12 ------------ tcg/tcg.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 07b1755990..201889cbee 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -116,18 +116,6 @@ struct qemu_plugin_scoreboard { QLIST_ENTRY(qemu_plugin_scoreboard) entry; }; -/* - * qemu_plugin_insn allocate and cleanup functions. We don't expect to - * cleanup many of these structures. They are reused for each fresh - * translation. - */ - -static inline void qemu_plugin_insn_cleanup_fn(gpointer data) -{ - struct qemu_plugin_insn *insn = (struct qemu_plugin_insn *) data; - g_byte_array_free(insn->data, true); -} - /* Internal context for this TranslationBlock */ struct qemu_plugin_tb { GPtrArray *insns; diff --git a/tcg/tcg.c b/tcg/tcg.c index d248c52e96..d7abc514c4 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -761,6 +761,18 @@ QEMU_BUILD_BUG_ON((int)(offsetof(CPUNegativeOffsetState, tlb.f[0]) - < MIN_TLB_MASK_TABLE_OFS); #endif +#ifdef CONFIG_PLUGIN +/* + * We don't expect to cleanup many of these structures. + * They are reused for each fresh translation. + */ +static void qemu_plugin_insn_cleanup_fn(gpointer data) +{ + struct qemu_plugin_insn *insn = (struct qemu_plugin_insn *) data; + g_byte_array_free(insn->data, true); +} +#endif + static void alloc_tcg_plugin_context(TCGContext *s) { #ifdef CONFIG_PLUGIN From patchwork Sat Mar 16 01:57:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780744 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489461wrs; Fri, 15 Mar 2024 18:59:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXQb8xgxSIfPpb/mHNjosqatWBLuQWAagjkuosWrN6tHezYrE+eaf277o2c/QimIjGy9cZ4hRDTwWt2VPcrYAwV X-Google-Smtp-Source: AGHT+IGpk39u8zIXY01UUxp2AgIGjZ1LHVU+i1eO9z7etXLp1a+9t/mDon0TjB0C9FCxz6EDCtM6 X-Received: by 2002:a05:622a:1d4:b0:42f:3096:c4d3 with SMTP id t20-20020a05622a01d400b0042f3096c4d3mr7724040qtw.20.1710554354212; Fri, 15 Mar 2024 18:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554354; cv=none; d=google.com; s=arc-20160816; b=nlu93diGtuwGWpfa73S+6IfcVElKcC7KPExgfJf4uNKSMfINQd2OjAdRWdb5VODNRB 7q4M8O1XteGyCtDUV8kvjj+IPUApUjXl4iwHwC74DaLtWgv39JCV0H9MFddrgk0uYwXT BJ2FwfHrg4ja7r82AJIUQhrUD6czNWXq9E1n/7bSpF1I1RbQ6meTbcf+QnSseUA//uk9 ak7u5+DFTuFy5mngTWtcCAgbvmgVRpmw5uWO7om+npZVwNFvVDz1q4YkzaqDI2Xpj5Xy fFS2j+U7NdPzkHJFIVhVCsOi5bKBnl4uRP+NiMrCRNAxvfA8lgfeuF8/TZQCsyo5QaiI MaYw== 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=T4SjKUXNEFn8jDbcremHLBaU7vP8s71moqLjJgD1MWo=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=WFPAPj8TQsAh0f1xk6WQtOfcVuphaHVIcqw52qoDOfqNKgMqe77q7PW2g1MJryFtw7 MH9AqL7jI3rATV3cH9/uaPqhV/Zw7kNpdKHQspSSV5Msy7+jI/elJR4BJshIJm58EXnm nNFUNdpJKOMtDjLAdfv/hGy3LTss+hl2jf87CRz7eG73NP6+xUG+Td7EwkjjA+xRRuQd rCsyilisxPxO+NdVIETWtd4BfLnlNEXjKfOQQZpbai7DHKrj0gFeoYl6oeRBZPQoVJOC j2LdXU7LQYYQF4iPUIxjtLGdtPdb9FXGdY0L7cvnMd5wj78hAlltdIADuyQsyeaBoV+1 1T8w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xzA0WqcA; 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 d1-20020ac85ac1000000b0042f213973a5si4922495qtd.318.2024.03.15.18.59.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:14 -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=xzA0WqcA; 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 1rlJJO-00031o-UO; Fri, 15 Mar 2024 21:58:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlJJK-0002zg-72 for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:11 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJI-0000oz-1Q for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:09 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1def3340682so9382885ad.1 for ; Fri, 15 Mar 2024 18:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554287; x=1711159087; 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=T4SjKUXNEFn8jDbcremHLBaU7vP8s71moqLjJgD1MWo=; b=xzA0WqcAHeHxjLeWnIhZg/prJCBfMEv2ET1JtrkHP5YZPeah3Tq/71Husc1FUnFWym N2F+Mxeufi8y54joz/9vFarUPoK4xn/+f1sFdOg30YflAfQg5B5xzDxsSanIqZH7hxTF QTcBPPvyzvvW7YZV9r0F1mMM7jy72ifWa5zWe3j4uOl1hNK9R/G7V4zc2h9Efjo5YnDn 9mxCb/z1nWW1pDl7/9t9WH74CcxLjc1ReT8od1bQ3bAlUYBqfHWZXfCh4CAbVfVwOhDI xTk63QBkz6Gbcl8ZCTKVecks0tC5t2i0uvGgE7QcTU8RKZUrHz/rnID+LB7EMvAfVK5g lW7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554287; x=1711159087; 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=T4SjKUXNEFn8jDbcremHLBaU7vP8s71moqLjJgD1MWo=; b=JOPERhGsLQgxGm8Owas9HzhOr1z47Fx2b962LtwM7bi/U/LS7n9Op+yN6GzRmMg6jr C2YLya2G+8dyFDomPm2H04dZwzQUAwoqHuH2tm+NBl9pcyS6/ZNrw2VYDrW4UzAoWnXz 3CO+l6g58qWQ/GovbosQz0yiuMgEN6VQ69dbMyJuqIEhoLBNzJ5TUwAdOYFJ6U0qPiWQ c3HmHBAmW2NgQ74X+fK+7FpjoFfW8fGm+3BXm2/BQrwvOWLW07IDkl8eFxBUmxwI0kl7 PURXXL7l/M/iogfbak40tX7cfkhcOuvvOynI3gWNTt8zoZPTxO+ZaTQEXrijcba81CFk UE2A== X-Gm-Message-State: AOJu0YzHrXdvKRpZO4H/lu8dI/FAGbop4q5mODEnMNzxh3Cyye5xFU5J OpzCQuPB9CW1cq3HRpgKmJDC+gasxjQPVwh9ZVzK+ntlVHX+CCYZ4uKAXLjWz3eL54kovJPQ978 R X-Received: by 2002:a17:903:1108:b0:1da:1daa:e2bd with SMTP id n8-20020a170903110800b001da1daae2bdmr8335452plh.19.1710554286810; Fri, 15 Mar 2024 18:58:06 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:58:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 21/22] plugins: Inline plugin_gen_empty_callback Date: Fri, 15 Mar 2024 15:57:19 -1000 Message-Id: <20240316015720.3661236-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Each caller can use tcg_gen_plugin_cb directly. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- accel/tcg/plugin-gen.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 70914c3bf8..fd52ea3987 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -67,19 +67,6 @@ enum plugin_gen_from { PLUGIN_GEN_AFTER_TB, }; -static void plugin_gen_empty_callback(enum plugin_gen_from from) -{ - switch (from) { - case PLUGIN_GEN_AFTER_INSN: - case PLUGIN_GEN_FROM_TB: - case PLUGIN_GEN_FROM_INSN: - tcg_gen_plugin_cb(from); - break; - default: - g_assert_not_reached(); - } -} - /* called before finishing a TB with exit_tb, goto_tb or goto_ptr */ void plugin_gen_disable_mem_helpers(void) { @@ -369,7 +356,7 @@ bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, ptb->mem_only = mem_only; ptb->mem_helper = false; - plugin_gen_empty_callback(PLUGIN_GEN_FROM_TB); + tcg_gen_plugin_cb(PLUGIN_GEN_FROM_TB); } tcg_ctx->plugin_insn = NULL; @@ -426,12 +413,12 @@ void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) insn->haddr = ptb->haddr2 + pc - ptb->vaddr2; } - plugin_gen_empty_callback(PLUGIN_GEN_FROM_INSN); + tcg_gen_plugin_cb(PLUGIN_GEN_FROM_INSN); } void plugin_gen_insn_end(void) { - plugin_gen_empty_callback(PLUGIN_GEN_AFTER_INSN); + tcg_gen_plugin_cb(PLUGIN_GEN_AFTER_INSN); } /* From patchwork Sat Mar 16 01:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 780754 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp489587wrs; Fri, 15 Mar 2024 18:59:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXY79V2BA0bGcaTzPl0BddtKSu9pOHo6h34nlCDAkrzdbN8iZsKsd6XZ43Ks8mn+f7j5pwr9VOVWM6scpjyliyo X-Google-Smtp-Source: AGHT+IFepKOQCMcr2zs2xcHxlB9epcnD+JmyKJmdec/K+Yx81vipVMJGsa/LsrxaIXakkLfRordR X-Received: by 2002:a0c:cd83:0:b0:692:494f:f0aa with SMTP id v3-20020a0ccd83000000b00692494ff0aamr16201qvm.9.1710554391320; Fri, 15 Mar 2024 18:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710554391; cv=none; d=google.com; s=arc-20160816; b=a71Z8Js7LNq2erKLxM24TL8wqZAUAb4rxL63Cfy76oxv0fP84jsHYXx0Qdn9pA/5Ub K7o7/jnSHYjoSA3yV2vMFMX2YMH2h2mLtOGrWrXj/t+FW/AMzt98dNVz6zd/mNfh2uj2 SG/WR1Q521SHJlI/cxIH9Mr//CaX8EG1yYGzw+knFFDyaVfZQrL29w+ahKFUEkXZ10bE /QomBRPvaaZ8nq3PkBzN39yf+4UJ0SQeDWlwCGKi4ZW1fMIFDwjeNAf6dxmB2M02NDsk qkph4//NAsEjOblI5aPJ2OGf0BFpajYnSn4M3TIo+tqnGk9jAAXvTuuhrLeNoPLeAFv4 kofg== 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=P54sXZhacQ5iITFNcA4P+H/BERfNZULzKjLOWe/9z8w=; fh=DfUxOGz7MnM49MBgqH5VPROGi+97fYtPWhcEZCG1Y5Q=; b=rs24ekyj5dTZZxxM/Ng5z5h3Q6oQHgqHc0Xxs2avErz7l4sRt1igPgS637sZ6Ysufs PVMvY7GQaU+oBpfBGtZMAH7pTNQRW9Dm4CfbbQtNmFXmvbMDt9nxI7sCvaOFMbNI13P+ Lx/QBg2oUOZgJhkecCUWHnWaobw8edYGKT6cdEkmlUXrXYL6WrnW3CfxUa1ajs1g07B2 +YdbmR52btk6QOLOZLUYli/0ZDr5IIPoGZx+oCQp+szpLSZW/Xq6uxiThXmqWp1bxbiA prWL/3wHaGTniqZesz+Cnv2kEXzFGi+Ae5p7WjqHLk/qzx+v32J9enZAxJcy0CY5W7SC GkqA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RCce+Mbg; 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 t13-20020ad45bcd000000b00691664f4112si3497477qvt.428.2024.03.15.18.59.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Mar 2024 18:59:51 -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=RCce+Mbg; 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 1rlJJR-00032q-PI; Fri, 15 Mar 2024 21:58:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlJJL-00030B-UZ for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:12 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlJJJ-0000pN-WD for qemu-devel@nongnu.org; Fri, 15 Mar 2024 21:58:11 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1def89f0cfdso6711005ad.0 for ; Fri, 15 Mar 2024 18:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710554289; x=1711159089; 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=P54sXZhacQ5iITFNcA4P+H/BERfNZULzKjLOWe/9z8w=; b=RCce+MbghlQfnsVYXuGL3nKKrJKYMvSa728dbFR4Maq/W4NYQ2qpuXt4HqN2+9bzSt 64id1jF3wBOvVFjvvCqq5KE28vsNE7YiRV5rMLQDLE+sFnakirO4RHg7GDrrhIcDz4uf o4+2wc5dI/Ob89EajtoivkGB6dBKpz3rMKglThbbhe8rbnxJ58nT/aNJRgdvyCy/73fS PrwAO7llhrBs/CwNugW/5OY9b+9EsrW0xerXYUJNmgghSD4x3sXPsXCPEC+D+xcLIuZw /LCdtjdJuxNoTsYdEDm3R74Z5X0kLJK0XJs0seAn8bPB9aMRJpqh4BWkGP3cMG94T16A RmEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710554289; x=1711159089; 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=P54sXZhacQ5iITFNcA4P+H/BERfNZULzKjLOWe/9z8w=; b=VBp76OrTpVOlN9WBxT/DyBE+iEfKpa8+LaMMLxV3zgEe69XhypE0ZYYvD+DL1Afffe +yGobCpwDmDF8fTyJtzQ9gXyKmzzo2uiP7A3okTPIQBeU/xLua7aDNDCbgpglGHucYWJ Y/7fSRI/9HYNTvgajYwSEoOxaAIFL5DYTO7pp7dO5MTI+1KzwnrksYktdriwBQTkOjbe VXaiLWw79o+DHRMr5i0v1DfYJXvIrDt+jjhIiUix/DyzulZT0F8d9SrkhJiONij8d53b gEFi+Qz5kIZbXYHx6Z4Hw2RoYpgwIPqjGPO2RyuQWeKRrN1N3Q6igcaH8yJ/seQNS16s Aeww== X-Gm-Message-State: AOJu0YzaaBsXse/82EVklP/zG8ppeEm5E4DPt1mXep/eEZhwuswcOABu FM7FFRUAuc/pzVwZurknqZSeHrBykMpV+66XWuuV0jEA7enDPzALdEi49ETUrTd10Kg2yjWIo8M y X-Received: by 2002:a17:902:f68b:b0:1db:cf64:7331 with SMTP id l11-20020a170902f68b00b001dbcf647331mr14824464plg.13.1710554288764; Fri, 15 Mar 2024 18:58:08 -0700 (PDT) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id b3-20020a170903228300b001dd42bbb08asm4592985plh.253.2024.03.15.18.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 18:58:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pierrick.bouvier@linaro.org, alex.bennee@linaro.org Subject: [PATCH 22/22] plugins: Update the documentation block for plugin-gen.c Date: Fri, 15 Mar 2024 15:57:20 -1000 Message-Id: <20240316015720.3661236-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240316015720.3661236-1-richard.henderson@linaro.org> References: <20240316015720.3661236-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index fd52ea3987..c354825779 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -14,33 +14,10 @@ * Injecting the desired instrumentation could be done with a second * translation pass that combined the instrumentation requests, but that * would be ugly and inefficient since we would decode the guest code twice. - * Instead, during TB translation we add "empty" instrumentation calls for all - * possible instrumentation events, and then once we collect the instrumentation - * requests from plugins, we either "fill in" those empty events or remove them - * if they have no requests. - * - * When "filling in" an event we first copy the empty callback's TCG ops. This - * might seem unnecessary, but it is done to support an arbitrary number - * of callbacks per event. Take for example a regular instruction callback. - * We first generate a callback to an empty helper function. Then, if two - * plugins register one callback each for this instruction, we make two copies - * of the TCG ops generated for the empty callback, substituting the function - * pointer that points to the empty helper function with the plugins' desired - * callback functions. After that we remove the empty callback's ops. - * - * Note that the location in TCGOp.args[] of the pointer to a helper function - * varies across different guest and host architectures. Instead of duplicating - * the logic that figures this out, we rely on the fact that the empty - * callbacks point to empty functions that are unique pointers in the program. - * Thus, to find the right location we just have to look for a match in - * TCGOp.args[]. This is the main reason why we first copy an empty callback's - * TCG ops and then fill them in; regardless of whether we have one or many - * callbacks for that event, the logic to add all of them is the same. - * - * When generating more than one callback per event, we make a small - * optimization to avoid generating redundant operations. For instance, for the - * second and all subsequent callbacks of an event, we do not need to reload the - * CPU's index into a TCG temp, since the first callback did it already. + * Instead, during TB translation we add "plugin_cb" marker opcodes + * for all possible instrumentation events, and then once we collect the + * instrumentation requests from plugins, we generate code for those markers + * or remove them if they have no requests. */ #include "qemu/osdep.h" #include "qemu/plugin.h"