From patchwork Mon Aug 31 16:05:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 248808 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp3459061ilg; Mon, 31 Aug 2020 09:30:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfxVgSzAXyWs4kckA9dAXgY3ncrO0FfTaef2eUpKTfjKd2TS42MXWkcwt0UBpoIC2xnvyW X-Received: by 2002:a05:6102:2403:: with SMTP id j3mr1993032vsi.193.1598891438401; Mon, 31 Aug 2020 09:30:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598891438; cv=none; d=google.com; s=arc-20160816; b=AVvo6+Z2sbYwoRFm7rAvc0s6Wm2qPsmV+3M0JsiTC36U2aWaXPItAcHx76YWaAhh6+ sJNS601kZcg2m19zU5WPx4gNRuxcLnNg4YqKixg3jRbNZIKb56+QMMgFivIL7h5mQ5vl 4H++e2b3nC8NBM9XouwB0KZmTFAWuR4+5oVzZB3WQYmTL8kLvIycfGOJ12Y9D/DUdgas SCY8m0v6JUUQMJsRNynfjtUnB5Jl2QbPtRfEe/wP45cz02emjUmsnNMr7opdDrz3CAyB DUN8ryiJB5n884cyv++nXhZgdpzIMxjLrBvlu5dXVKnlYkVsk/ECT+X2NECWR9HQvPK8 U/Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=NQ0LfAVoBPployk6kB6YiHjM59FX58JiRnl2u3IyKWs=; b=mu1uOVv28Mi+UoJ1JlYQT6EBJkiq8tPqAF7+w5GR1m+IrkiO27FeVMEA6ss8CMpmiE qXf8QfVlzigOtVE7U1CeeqF88r9SdRW7waaXzH57JeD63sQNpvbuPqH059TlaBwpIXoI pe+IprIFYYfWmEbFuVHcn6TJpftMGVUqid0lBFUbL2AlS/0zk9hNhiPVuiMw41joBvnA XEplBU3OregEOTvXhAI8bUYUdu1ANEwRTYr7VkpgTtLbJ7ilr3Zxlas4wue7ee0p+bbG TXjhzIgnO8BYsxtQ0LepRrGisGX6G8xTcOfc5fXuf4bJkLABKv9p26AIY+W1xvivX040 yoBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oDqGgh9v; 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=fail (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 j22si1297798vsf.333.2020.08.31.09.30.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Aug 2020 09:30:38 -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=fail header.i=@linaro.org header.s=google header.b=oDqGgh9v; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCmhZ-0004qH-NQ for patch@linaro.org; Mon, 31 Aug 2020 12:30:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCmLG-0006KX-0i for qemu-devel@nongnu.org; Mon, 31 Aug 2020 12:07:34 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:39650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kCmLE-000697-21 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 12:07:33 -0400 Received: by mail-pf1-x435.google.com with SMTP id u128so810712pfb.6 for ; Mon, 31 Aug 2020 09:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NQ0LfAVoBPployk6kB6YiHjM59FX58JiRnl2u3IyKWs=; b=oDqGgh9vT80uBueamEINE2OAUqA5ubG1l+SCohRLS2ghPp0v/b+XjjWbU1WA2di7pA 5N/v+hboVg4O+5+XL2HJPva5d19kBcBI7yVPTAZsi1xlY/I7Jo9xe6jiBU/HazgAnT6y /D84goIVMu9fQfXds9U2mZQQgeGfCvPOsKNL7dK1NXW90rFGD7B90BZOxZyvL3remfyN hXbgktJ71DjROJaLFiQvk02IcGuVWBn4Y7+OCqxd0Asi8OWNoZz9KEhIhqrquBXQl4nc xc/NpzEQqV1Fx+Uh/zJFyr3Bf1Mo/ZIYXj9wd6KIBXwb5mTD3eBnlT1ismJwscc0vd0b r90A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NQ0LfAVoBPployk6kB6YiHjM59FX58JiRnl2u3IyKWs=; b=H+Kw8EfOEFcGru16MPsLBDfHXYUHR3KYSjrqYS9bQm8vuKXb/KvChzW1/TwDZXfEja eRsxIHy+k0V0rplJVDotRiW6l1uJtc14HVYWYLx8A3ED0K5bHpDXlph7cQ7TkG2uUCzi CsVTSziwSxsJM969hFOYeKh8pzJtmJDYMcRkkIlpDzd6pKYc2zxwrsPfovUBLujh86It 73ldMflS2BFvjy4+p92koGJqjq6qLEFY3ro/qIrTSE9FOa20JCxEnwNgvaRCBdezovwl 2XrYb7W6HyC1Q58Hk7Ly87ozGk2wU1zOrnqFFlZdpaGz8UdYXdz6ATzcpULJrA64h8p9 lGQA== X-Gm-Message-State: AOAM530522UfwFkXAuhD5DtJUsqOlQLg15P81HPMOU5NPuJ3QH47BIX8 w0KcWgeglapAp4HIQ80R3AQoi1vXU+zvmQ== X-Received: by 2002:a62:1514:: with SMTP id 20mr1854293pfv.62.1598890050337; Mon, 31 Aug 2020 09:07:30 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id gt13sm17218pjb.43.2020.08.31.09.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 09:07:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 64/76] target/microblaze: Convert mbar to decodetree Date: Mon, 31 Aug 2020 09:05:49 -0700 Message-Id: <20200831160601.833692-65-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200831160601.833692-1-richard.henderson@linaro.org> References: <20200831160601.833692-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E . Iglesias" , peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Split this out of the normal branch instructions, as it requires special handling. Tested-by: Edgar E. Iglesias Reviewed-by: Edgar E. Iglesias Signed-off-by: Richard Henderson --- target/microblaze/insns.decode | 2 + target/microblaze/translate.c | 85 +++++++++++++++++++--------------- 2 files changed, 49 insertions(+), 38 deletions(-) -- 2.25.1 diff --git a/target/microblaze/insns.decode b/target/microblaze/insns.decode index 9273a51d20..8eba47d90c 100644 --- a/target/microblaze/insns.decode +++ b/target/microblaze/insns.decode @@ -127,6 +127,8 @@ lwea 110010 ..... ..... ..... 0001 000 0000 @typea lwx 110010 ..... ..... ..... 1000 000 0000 @typea lwi 111010 ..... ..... ................ @typeb +mbar 101110 imm:5 00010 0000 0000 0000 0100 + mul 010000 ..... ..... ..... 000 0000 0000 @typea mulh 010000 ..... ..... ..... 000 0000 0001 @typea mulhu 010000 ..... ..... ..... 000 0000 0011 @typea diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 1c772b95d9..832cf85c64 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1127,6 +1127,52 @@ static bool trans_brki(DisasContext *dc, arg_typeb_br *arg) return true; } +static bool trans_mbar(DisasContext *dc, arg_mbar *arg) +{ + int mbar_imm = arg->imm; + + /* Data access memory barrier. */ + if ((mbar_imm & 2) == 0) { + tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); + } + + /* Sleep. */ + if (mbar_imm & 16) { + TCGv_i32 tmp_1; + + if (trap_userspace(dc, true)) { + /* Sleep is a privileged instruction. */ + return true; + } + + t_sync_flags(dc); + + tmp_1 = tcg_const_i32(1); + tcg_gen_st_i32(tmp_1, cpu_env, + -offsetof(MicroBlazeCPU, env) + +offsetof(CPUState, halted)); + tcg_temp_free_i32(tmp_1); + + tcg_gen_movi_i32(cpu_pc, dc->base.pc_next + 4); + + gen_raise_exception(dc, EXCP_HLT); + } + + /* + * If !(mbar_imm & 1), this is an instruction access memory barrier + * and we need to end the TB so that we recognize self-modified + * code immediately. + * + * However, there are some data mbars that need the TB break + * (and return to main loop) to recognize interrupts right away. + * E.g. recognizing a change to an interrupt controller register. + * + * Therefore, choose to end the TB always. + */ + dc->cpustate_changed = 1; + return true; +} + static bool trans_zero(DisasContext *dc, arg_zero *arg) { /* If opcode_0_illegal, trap. */ @@ -1417,50 +1463,13 @@ static void dec_bcc(DisasContext *dc) static void dec_br(DisasContext *dc) { - unsigned int dslot, link, abs, mbar; + unsigned int dslot, link, abs; uint32_t add_pc; dslot = dc->ir & (1 << 20); abs = dc->ir & (1 << 19); link = dc->ir & (1 << 18); - /* Memory barrier. */ - mbar = (dc->ir >> 16) & 31; - if (mbar == 2 && dc->imm == 4) { - uint16_t mbar_imm = dc->rd; - - /* Data access memory barrier. */ - if ((mbar_imm & 2) == 0) { - tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); - } - - /* mbar IMM & 16 decodes to sleep. */ - if (mbar_imm & 16) { - TCGv_i32 tmp_1; - - if (trap_userspace(dc, true)) { - /* Sleep is a privileged instruction. */ - return; - } - - t_sync_flags(dc); - - tmp_1 = tcg_const_i32(1); - tcg_gen_st_i32(tmp_1, cpu_env, - -offsetof(MicroBlazeCPU, env) - +offsetof(CPUState, halted)); - tcg_temp_free_i32(tmp_1); - - tcg_gen_movi_i32(cpu_pc, dc->base.pc_next + 4); - - gen_raise_exception(dc, EXCP_HLT); - return; - } - /* Break the TB. */ - dc->cpustate_changed = 1; - return; - } - if (dslot) { dec_setup_dslot(dc); }