From patchwork Fri Nov 3 19:59:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 740734 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp12607wrr; Fri, 3 Nov 2023 13:11:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWovzEUta8RAXmfszSjYfrmCjMtDXUsaocqUZO99oyacDNOL+Z4mgKgnqr2P3FvH/XPEZo X-Received: by 2002:adf:d1c3:0:b0:32f:a8bb:31b5 with SMTP id b3-20020adfd1c3000000b0032fa8bb31b5mr4919511wrd.23.1699042280959; Fri, 03 Nov 2023 13:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699042280; cv=none; d=google.com; s=arc-20160816; b=B0USWKREnrJoKWjU7Qm6JsMEVacPVeliSPPopxEKhZ331HCSMh5ojV2ijyc5iNsEs1 OTHstCXj24NCiO9peG6qPljcqJrS+wvJ4FQQJVLfCp7I3gFZ2QmsUQAMpS0keAHSE+XG qHJVv8Ix7eG6oxmc+ntZOO+3JBuvwpbDFTH1agXH6Ky51KIslnhDoyu73qMrcudmbPzH u/0Zabrna6jt8I8b6uu0JqInE0sRN53ZT/EHxFv8JNwN5z3adJ67ju4CE7Y6BdJXyL9v vHmDBrZgD6O1/S7EFDrwK9G7kZhuTzzBLufE70zrf3RYTS/fu3M2EOjjDPwrJuuXIIKT OxdA== 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=w9RdZiPgsiDcf04qOgvE4HVryOUV6Pt59oipsR46vcQ=; fh=+DJyABPrPOszaX8covAxj8Yhupz9POTwrYeebio0HgM=; b=wdU11JatOnlkWDYslbuq+w59cKTc9MbSWVr+zLol9PcFClg8GwE9th+kvwQHZCemID 8SdhgbOBDmO4u88iPbewK3EYeVS8h9EQFqNHQCVYZsLhTgd66X5+XtAC8XCf3cDyeMUL V3JKhNp2u3tph4+5km6ErUFzoXzlVtaaJ89r93IhJj7x+dZfzj7DSFhKT9dmNQ6MaQ1m 0j75BG5DszbmLSj2H0q5Twrciw4WmKSXsG8hcO2SJWaKAF7hxUlRlOeDz151w+pViHAZ SWJit39j2060M3ffpsM3XQwhMsWZ77o6aTMJvb3dyI7aztalR6+NT//b10n2c41RA+c1 mY2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mMrjqKlN; 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 n8-20020a5d5888000000b003176f1027cesi1887182wrf.33.2023.11.03.13.11.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2023 13:11:20 -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=mMrjqKlN; 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 1qz0Qo-0003Vz-Vs; Fri, 03 Nov 2023 16:06: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 1qz0Qn-0003R6-Jo for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:13 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qz0Qh-0006vq-Ii for qemu-devel@nongnu.org; Fri, 03 Nov 2023 16:06:13 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-32fb190bf9bso1161363f8f.1 for ; Fri, 03 Nov 2023 13:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699041966; x=1699646766; 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=w9RdZiPgsiDcf04qOgvE4HVryOUV6Pt59oipsR46vcQ=; b=mMrjqKlN4HmfrYOg/hMugXWmdQSAvCcOveQxqaGd0mombWu90c84fVqdwKTyVfO1Le zobQGB2HYceuJh0jG1S7YJmyPHGDjUEPuUGw5lnn/GvBJcJ9xc3svC434uBWMaZ6JEST 5c/WrwIeEGOzXe9lnSchOW5BuZkHY2KLhlDF0bRfyyruwAXvKmpXcvm9cIdgVHCTg5Wt nlxr9tsX08Nji2ToNSaFBhBaPDnhvhbpYLZduvosnq/NZmuazgCy3JCOLwkMLxJ5Hs9H n1/bVcDwNrrJ39CpQGP54yAphzuhUcCGMEWeA6yxxqbKHlSKciTEtB0Y5coUYLiPhSXt VRNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699041966; x=1699646766; 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=w9RdZiPgsiDcf04qOgvE4HVryOUV6Pt59oipsR46vcQ=; b=bbdmCO28Xz/UgHQtJ+SVsOnpM7Uk19vLBA6e3qGSFM47SxiItvUntVPZrvyKaDG1hD BPnoKoVOitVN19NSduVthlkni0qghR54iU2EMw4U8yBCFy+7VRaJ55zcIbOfHdPBQoHk waKtyS6ycMUsw9K4Sgl92syUccX1SE0cr4o0w4vv02J116qI4PJ/bPf6VTcfX8cTwRNy 639NBTAwTB8luPH8Ot/94hIDcj9qttEecMxxRhbCWW70cJTwMijb2DWPrRH7sNFW/9ga IQXOydDMaTQ3T8tjI+bNhqbkEOboUIl4kTshQuq1SEkBdp8WvxNgOgb8eGzYWgTPKVO9 Mf/Q== X-Gm-Message-State: AOJu0YyU8omrqaqE3KI6/xQCoeJ3sU5u7yCwC/zJIgDmQdAwKCZqhA2Y KQ+lftD30EnxrqiN581BpRpaYA== X-Received: by 2002:a5d:47a1:0:b0:32f:a6b0:d21a with SMTP id 1-20020a5d47a1000000b0032fa6b0d21amr4562007wrb.34.1699041965871; Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id g10-20020a056000118a00b00326dd5486dcsm2610517wrx.107.2023.11.03.13.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 13:06:05 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3F0E365753; Fri, 3 Nov 2023 19:59:59 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , "Edgar E. Iglesias" , Song Gao , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Wainer dos Santos Moschetta , Weiwei Li , Marcel Apfelbaum , Ilya Leoshkevich , Daniel Henrique Barboza , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Paolo Bonzini , David Hildenbrand , Brian Cain , qemu-ppc@nongnu.org, Palmer Dabbelt , qemu-riscv@nongnu.org, Eduardo Habkost , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , Liu Zhiwei , Cleber Rosa , qemu-s390x@nongnu.org, Laurent Vivier , Yoshinori Sato , Nicholas Piggin , Thomas Huth , John Snow , Alexandre Iooss , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Mahmoud Mandour , Daniel Henrique Barboza , Bin Meng , Beraldo Leal , Richard Henderson , Michael Rolnik , Akihiko Odaki Subject: [PATCH 23/29] plugins: Use different helpers when reading registers Date: Fri, 3 Nov 2023 19:59:50 +0000 Message-Id: <20231103195956.1998255-24-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103195956.1998255-1-alex.bennee@linaro.org> References: <20231103195956.1998255-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki This avoids optimizations incompatible when reading registers. Signed-off-by: Akihiko Odaki Message-Id: <20231025093128.33116-17-akihiko.odaki@daynix.com> Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- accel/tcg/plugin-helpers.h | 3 ++- include/qemu/plugin.h | 1 + accel/tcg/plugin-gen.c | 43 ++++++++++++++++++++++++++++++++++---- plugins/api.c | 12 +++++++++-- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/accel/tcg/plugin-helpers.h b/accel/tcg/plugin-helpers.h index 8e685e0654..11796436f3 100644 --- a/accel/tcg/plugin-helpers.h +++ b/accel/tcg/plugin-helpers.h @@ -1,4 +1,5 @@ #ifdef CONFIG_PLUGIN -DEF_HELPER_FLAGS_2(plugin_vcpu_udata_cb, TCG_CALL_NO_RWG | TCG_CALL_PLUGIN, void, i32, ptr) +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/qemu/plugin.h b/include/qemu/plugin.h index 7fdc3a4849..b0c5ac6829 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -73,6 +73,7 @@ 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 78b331b251..b37ce7683e 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -79,6 +79,7 @@ enum plugin_gen_from { 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, @@ -90,7 +91,10 @@ enum plugin_gen_cb { * 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)(uint32_t cpu_index, void *udata) +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, @@ -98,7 +102,7 @@ void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index, void *userdata) { } -static void gen_empty_udata_cb(void) +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(); @@ -106,12 +110,22 @@ static void gen_empty_udata_cb(void) 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_udata_cb(cpu_index, udata); + 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. @@ -192,7 +206,8 @@ static void plugin_gen_empty_callback(enum plugin_gen_from from) gen_empty_mem_helper); /* fall through */ case PLUGIN_GEN_FROM_TB: - gen_wrapped(from, PLUGIN_GEN_CB_UDATA, gen_empty_udata_cb); + 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); break; default: @@ -588,6 +603,12 @@ static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb, 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) { @@ -602,6 +623,14 @@ static void plugin_gen_insn_udata(const struct qemu_plugin_tb *ptb, 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) { @@ -721,6 +750,9 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) 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; @@ -737,6 +769,9 @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) 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; diff --git a/plugins/api.c b/plugins/api.c index 5521b0ad36..ac39cdea0b 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -89,7 +89,11 @@ 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], + 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], cb, flags, udata); } } @@ -109,7 +113,11 @@ 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], + 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); } }