From patchwork Wed Oct 11 10:33:25 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: 731954 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp329852wrv; Wed, 11 Oct 2023 03:44:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFc4JyH4zWHbm8MqZYriWf8abdgJ9d3osYrrZ/3pH6/vUT8LzmUCLC1Qulvnl7bc13kKLbw X-Received: by 2002:ac8:5813:0:b0:405:47ef:8164 with SMTP id g19-20020ac85813000000b0040547ef8164mr25011550qtg.39.1697021098736; Wed, 11 Oct 2023 03:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697021098; cv=none; d=google.com; s=arc-20160816; b=ia43K1OwFNyrV0fnHPA1cgDrYBjMO5IRkjEgS1fXiZBCLB7PDwrQ5obYwvVouvjE+B VgrHc0GUIivjHGLgbBOTToMXC/J6XvSaEdteyGyGFMjZzGOYfcn1CNF97U06dp8PO9gv igOQxtQmkFle6R5nfY9oibW8zRPYjzm0OstMSIkuCQa7BDHINslBeAsPFDY3PhR59xaM +/chghyBVFwMbwND/o0cY4g0IdnTq/IjMhb4M5HskXvxeKDfixC6Oek4dqeRjTb096qq m9vJF6+DLqISRyeotLqN98QQIV26/af80G0NYFIg/R5nrobEvxFORV7HgQ+Ni/6jLmTz VV3w== 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=n810Flg3eUKPCpIa9Gc8YMsIUEaYzj3LB0YfR/j6wKY=; fh=leyZlo+5VI+K3VUQRunD4SpqEM5GaTQXmMfHWLwhGVs=; b=lZRBLiPrBn3HKfAeVivfG5cNS24GZKwhDorWdXKEfmaQ8rh+DI2kOhC5ZEH5VfoYwc gESe5dVuTnvCYvZlfO2BBkZu3Qso8I+3/qZmmROqt0vcFOevW9GuhlGVxgYET/fnM9+u N60re5pXW/42ogrs+ZqMiIqMFaQKZhj08uTcfpiYyxX/Wa+sUOZKqqH3HkJuMeD8z05g 9jfUuAVwBVYQJ0BCQSAa8QZSiGWNFRlklot5KUL/0zzKk1hESv623cK6uhY4/MYDlE/Q FRZ/p3fnnQVj4fOVhf0LvPD2MTp+UT+mJ8JjN6YWnypoirnQItBmJxTalR0P0bD/mJTS Jp/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LlwfYchK; 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 19-20020ac85913000000b00417d39dfc3esi8997420qty.755.2023.10.11.03.44.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Oct 2023 03:44:58 -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=LlwfYchK; 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 1qqWgl-0008CY-5R; Wed, 11 Oct 2023 06:43:39 -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 1qqWgj-0008Ax-RS for qemu-devel@nongnu.org; Wed, 11 Oct 2023 06:43:37 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqWgh-0007fV-Hw for qemu-devel@nongnu.org; Wed, 11 Oct 2023 06:43:37 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-32caaa1c493so1477364f8f.3 for ; Wed, 11 Oct 2023 03:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697021014; x=1697625814; 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=n810Flg3eUKPCpIa9Gc8YMsIUEaYzj3LB0YfR/j6wKY=; b=LlwfYchKOb0fmhShTiRQMjnhLINsXIc1+vaZ60a+vk8W9Rb0lUXyUftQe7SGHw6i98 uE3dBsR6tDYXccDm1mSw2cUDHt3ko3G4M5xS73dZ6s4Z2ZPFG467NEG9bh1qUafSBFrN RrbZcu5v8k6xPuTmPVEY1lu+MUE8TMXrNONkt0kUqaL7ZyhMjAKLXwTx4bMsCh7sTSB3 4OccV0Fto6pikg3Njj2zZaEH1hfRcQ97V63fRraM1wBAMnHZuK8blwJJgMTC2/co5moX 2f169s6jyijN/NuMHLjFCubAkp2oWDfuI1MA1jAiB7k/+LIMfgPcw+FDDQCIRsHAT8HE 9rCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697021014; x=1697625814; 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=n810Flg3eUKPCpIa9Gc8YMsIUEaYzj3LB0YfR/j6wKY=; b=soqx4EdpcRPCaFC1wc9smpByGgjXYWJriVFYkg/hhDEBt4JmYqqou99MmboR0UcvmP aJHktofL6tQRS77F6ZZH8GQqzNSss5YbDrvLuN7Gcq2xTTANRnAzbwUDvgqCx0YYwmog gZkY7vl+B/KttUwJ5fDzbRbW46b33fexHZOxDWOPfkTnLw6Lixc/dAysSIiJrA8SV77D +pnkfAJVDmQxnx/SWG2EmboA3RaMDQGcPNuNtKXQ0ctU1FKLfyf0p7X8FiIRkQChgwrO 88G1GL64oSMV2/kUJYtaq38LONHALvl7Ow76o4Zx7cKmHqk2vbBlsc+6tyacwxTlj55Z H3SA== X-Gm-Message-State: AOJu0YzBjXs6lBmsGUN9VSlSeXkFO/gpLuoC+b46QIKBHmNlSDEEPPZR B0sACbmLp/FubKvDMikrJVEQPw== X-Received: by 2002:a05:6000:1c02:b0:32d:4545:3832 with SMTP id ba2-20020a0560001c0200b0032d45453832mr3881270wrb.14.1697021014165; Wed, 11 Oct 2023 03:43:34 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id v3-20020adfa1c3000000b0032d8354fb43sm1869446wrv.76.2023.10.11.03.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:43:32 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 721FC1FFCD; Wed, 11 Oct 2023 11:33:32 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Yoshinori Sato Subject: [PULL 21/25] target/sh4: Disable decode_gusa when plugins enabled Date: Wed, 11 Oct 2023 11:33:25 +0100 Message-Id: <20231011103329.670525-22-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231011103329.670525-1-alex.bennee@linaro.org> References: <20231011103329.670525-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: 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 Message-Id: <20231009164104.369749-22-alex.bennee@linaro.org> 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