From patchwork Mon Oct 9 16:41:00 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: 731015 Delivered-To: patch@linaro.org Received: by 2002:a5d:574c:0:b0:31d:da82:a3b4 with SMTP id q12csp1312778wrw; Mon, 9 Oct 2023 09:47:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsFgcc0WII2zBH2qmhUO2eP9ZB1rg0kWmKu4hWl2doa035S9VJF8dX8Nij+UDeJQelGN1c X-Received: by 2002:a05:622a:11d2:b0:417:b913:7f92 with SMTP id n18-20020a05622a11d200b00417b9137f92mr18341305qtk.28.1696870033339; Mon, 09 Oct 2023 09:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696870033; cv=none; d=google.com; s=arc-20160816; b=b0phCqi/5x4rPTS/kDxt7h8OqT1Uv01Q2LT7lrH8fYJdOf6H1XAd9T9v9fhvD0i23r pHdYf0JSmRyMpZRdokV81A31fUwF8qMYTow+VTr/gGEavPIoG/alcSpsUid2qIGkqlub tEnmKtmBsF3hhl1gnRlokfmcJKsoYA2hLpQ3NvBU3gHHfD+E5qdBr6gR1JJMwsS/bDeE wvpN/gPYqsCuAf3eezTbObLscVpqFccdfCvaOsprLcmZebBG0xLV9oWXG5G9bbVxcBnu K5vRQigYY9gXJfJbdc9i81ZBVwBVywOvVuoCJzl5wDVUNlhCykzEXVmd4LFXdz34OpQg fZQg== 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=e5StG+rhxOIhMaXsnxTS3HFTjNGO8160fFaP+7NtskE=; fh=hH+hY2AOPCtQWK44NzX0H5SWS0EYJFmL3o+I0zvKKVU=; b=gPGfSYIoe2jdQiZmLuMRKc4mehKwM+KtuQ61KspF814BcArGNDSoOcrFV4V9HuVxIt HD+yqc+rx5xVyt94ePOS8kuqJmfvQwIQnsIMUrMWOBZgF2+wdQ6xOp9uoFaXRgs4AU25 H8voKx/YwbIruxu1U4fx2qze/GF87i67XTPQwJ1AqSiif17NemBhdveKWKLp7sMrG8ZZ XDZz3Do0K1OMq2JD2FCY+yFWe/idF0Rj2PLKBqYrUeCkJKa7QldtVzaAi4o6zComQuST FQQ5TsJI6s54cpfm5glKGWqqYDzwR2rKuPddCFpWZYIKwULuErX3lyKdQeyfNKiETI2I nkCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDCSE4lM; 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 e9-20020ac85dc9000000b00417ce8008cdsi6401621qtx.803.2023.10.09.09.47.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2023 09:47:13 -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=HDCSE4lM; 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 1qptPM-0003qX-Dv; Mon, 09 Oct 2023 12:47: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 1qptOu-0003BS-Dp for qemu-devel@nongnu.org; Mon, 09 Oct 2023 12:46:52 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qptOk-0003VQ-3M for qemu-devel@nongnu.org; Mon, 09 Oct 2023 12:46:34 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4064867903cso47900265e9.2 for ; Mon, 09 Oct 2023 09:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696869972; x=1697474772; 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=e5StG+rhxOIhMaXsnxTS3HFTjNGO8160fFaP+7NtskE=; b=HDCSE4lMeW6mi1SD6Bat9CQhsT8IWC1hw/KZeTQ4YVDEfSgfGZt1vM4QS8iEtK0HYq YB2WZjHwfqwY6wEOesYLkdkx+YAkiI2od3w/7Fn3lCf4yOIvmPqk2tbLMNDWdtT4eUtR kTZLNoi9l9bBMLvQS1Jqblbply9+5ifHN7dN/mLkanrKdj8rdgdqtGDoJ14vjD8W9wfj nz+9xQO3Ulr1mqOqLrJXocTl8AT+uKslKaZhpgmvdOSGxAkjrpC8ScrQp4ZH1LkPTxiy +E9YOOMF9FDfsLs4CDyPTk2yeCZL7dQ35+q2GM0Gl5LmlAocaGPUBU8jaNJ/jY/COCG7 Iu2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696869972; x=1697474772; 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=e5StG+rhxOIhMaXsnxTS3HFTjNGO8160fFaP+7NtskE=; b=X1YOrEeSD09v6IOWnnHOgrwEnoRICI/ldQexwCW9pUHBj4Gtysy/EAigwPl5RRoGcQ SW8obH88PgCINUmtjMqgJ3ojogstf6sgczZe0JNlMYknarkdz/haAhiu+75RXCEEtSD8 /q7/bKA0tDpQTTKpbkiT/TM0x91kpYMaay5XjsietbBWZ1+Dk+wQK+OxLitvun0wsT91 C6pC+UyW2aVstvI+dDqKtMZSCZ47sBN9vr+pyOIknrjGtplrACuAE124R5pIxAAEGZF8 DThliMH8hl47ochsvUCrbNfN9RjVEWUG0sjsc826pVaIwroXDl1lWjOFcNgSmkH+7ssU rmDg== X-Gm-Message-State: AOJu0Yz7JB/JDyHSrlpAAIRRzniLAsRlkZVS8FH8QKPfnxOphAHIECwx U5+nG5ZVK++AnEVjlxO5trTGZ0+0fuokHOTbIm8= X-Received: by 2002:a1c:ed17:0:b0:406:7d74:a29e with SMTP id l23-20020a1ced17000000b004067d74a29emr14087044wmh.19.1696869971896; Mon, 09 Oct 2023 09:46:11 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id m16-20020a7bca50000000b004064ac107cfsm11787284wml.39.2023.10.09.09.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 09:46:11 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9D8CB1FFCD; Mon, 9 Oct 2023 17:41:07 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Xiaojuan Yang , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Bastian Koppelmann , Brad Smith , Radoslaw Biernacki , David Hildenbrand , Cleber Rosa , Ilya Leoshkevich , qemu-riscv@nongnu.org, Daniel Henrique Barboza , Alexandre Iooss , Nicholas Piggin , Bin Meng , Leif Lindholm , Paolo Bonzini , Eduardo Habkost , Alistair Francis , qemu-ppc@nongnu.org, John Snow , Liu Zhiwei , qemu-arm@nongnu.org, Wainer dos Santos Moschetta , Palmer Dabbelt , Peter Maydell , Yanan Wang , Weiwei Li , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Marcel Apfelbaum , Beraldo Leal , Yoshinori Sato , Mahmoud Mandour , Richard Henderson , Song Gao , Marcin Juszkiewicz , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 21/25] target/sh4: Disable decode_gusa when plugins enabled Date: Mon, 9 Oct 2023 17:41:00 +0100 Message-Id: <20231009164104.369749-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009164104.369749-1-alex.bennee@linaro.org> References: <20231009164104.369749-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Signed-off-by: Richard Henderson Message-Id: <20230824181233.1568795-3-richard.henderson@linaro.org> [AJB: fixed s/cpu_env/tcg_env/ during re-base] Signed-off-by: Alex Bennée --- target/sh4/translate.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index cbd8dfc02f..220a06bdce 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -1816,6 +1816,18 @@ static void decode_opc(DisasContext * ctx) } #ifdef CONFIG_USER_ONLY +/* + * Restart with the EXCLUSIVE bit set, within a TB run via + * cpu_exec_step_atomic holding the exclusive lock. + */ +static void gen_restart_exclusive(DisasContext *ctx) +{ + ctx->envflags |= TB_FLAG_GUSA_EXCLUSIVE; + gen_save_cpu_state(ctx, false); + gen_helper_exclusive(tcg_env); + ctx->base.is_jmp = DISAS_NORETURN; +} + /* For uniprocessors, SH4 uses optimistic restartable atomic sequences. Upon an interrupt, a real kernel would simply notice magic values in the registers and reset the PC to the start of the sequence. @@ -2149,12 +2161,7 @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env) qemu_log_mask(LOG_UNIMP, "Unrecognized gUSA sequence %08x-%08x\n", pc, pc_end); - /* Restart with the EXCLUSIVE bit set, within a TB run via - cpu_exec_step_atomic holding the exclusive lock. */ - ctx->envflags |= TB_FLAG_GUSA_EXCLUSIVE; - gen_save_cpu_state(ctx, false); - gen_helper_exclusive(tcg_env); - ctx->base.is_jmp = DISAS_NORETURN; + gen_restart_exclusive(ctx); /* We're not executing an instruction, but we must report one for the purposes of accounting within the TB. We might as well report the @@ -2242,12 +2249,22 @@ static void sh4_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) #ifdef CONFIG_USER_ONLY if (unlikely(ctx->envflags & TB_FLAG_GUSA_MASK) && !(ctx->envflags & TB_FLAG_GUSA_EXCLUSIVE)) { - /* We're in an gUSA region, and we have not already fallen - back on using an exclusive region. Attempt to parse the - region into a single supported atomic operation. Failure - is handled within the parser by raising an exception to - retry using an exclusive region. */ - decode_gusa(ctx, env); + /* + * We're in an gUSA region, and we have not already fallen + * back on using an exclusive region. Attempt to parse the + * region into a single supported atomic operation. Failure + * is handled within the parser by raising an exception to + * retry using an exclusive region. + * + * Parsing the region in one block conflicts with plugins, + * so always use exclusive mode if plugins enabled. + */ + if (ctx->base.plugin_enabled) { + gen_restart_exclusive(ctx); + ctx->base.pc_next += 2; + } else { + decode_gusa(ctx, env); + } return; } #endif