From patchwork Mon Aug 31 16:05:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 248814 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp3461699ilg; Mon, 31 Aug 2020 09:34:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIzIcq6ZZhTPLraRyybz6o6RpXODTIxYoqxqavVxuMbJ7SPYy2f9wEnWJ7pvFULdJKsFIu X-Received: by 2002:a5b:410:: with SMTP id m16mr3299694ybp.309.1598891654586; Mon, 31 Aug 2020 09:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598891654; cv=none; d=google.com; s=arc-20160816; b=VXPb6Bd2a+6DfHw5sMzNKJYOC7yMVWpynApxjGArhHpGqXIPCQWrhw8kctGHYMII+0 /tgQEcXRcEBiLV+XKq3OCnshY6IIqYkUma/1aT3ihk91VTAifcyMFYiXaZ0CdkeatHYB nhH4TBotRjYUrDQp1ydhbxn5Ayna81HiLAU31v5VSVtKZ31mbbED7FgcFhkg1jyGnlEK gl/FjkqkxMqfJmIPDdxjw98ZJZ+X/HJ6E8rPq2Y27j+6w8AzWddh5VtSlDEJFku0eBm8 lJMS4j4WPsA5+HIBZ8DBWLwUDfMtldPsHxZXCiJzdrgSq2PobtzfTyuUHGht7MUxCQ8G RLtQ== 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=qD9TO6jGFspxgEuw853gVRm0hcTBzuluIXG7+nD8HAE=; b=hENt8MCjG0bNi0w+BD1ik3SP8tKuZIP/bDt8fbcP1QDbYBnBF8at6UOwGP4KEQc4hF 74aHS+AWFeavSoyrnCZUhFwxsbb9xQ/alxXXeWCZd9bP+QBIlrel6DBHxh/vYSFeESom iYiki5j46iUgsfdwIluKnhLZ2EgOXPTPRs+LAzkSBTY6qrEE85br9L7mGHX20GcM6gaO HLYnuKotAG37jptEiwZURK2rrl7yDILkZvFnw5hSVoufpg4MVojiS0mFSxDSQZJA6koV hdEMzLInon/zTHF2zxFXUK9IKxRCRPds318aYyC6eNrE9WE+79k70G2Bpvewgyzffqxo L/Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=it6gFr26; 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 j127si1996445ybg.458.2020.08.31.09.34.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Aug 2020 09:34: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=fail header.i=@linaro.org header.s=google header.b=it6gFr26; 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]:52476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCml4-0002Mi-0d for patch@linaro.org; Mon, 31 Aug 2020 12:34:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCmLO-0006gw-Bb for qemu-devel@nongnu.org; Mon, 31 Aug 2020 12:07:42 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:55319) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kCmLM-0006Ai-1q for qemu-devel@nongnu.org; Mon, 31 Aug 2020 12:07:41 -0400 Received: by mail-pj1-x1042.google.com with SMTP id 2so21717pjx.5 for ; Mon, 31 Aug 2020 09:07:39 -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=qD9TO6jGFspxgEuw853gVRm0hcTBzuluIXG7+nD8HAE=; b=it6gFr26EkQ4zo09ApJAmMqAT8cdh8Z8KCxVnMKlTHx0FF9qPpTxFlqaTEM4gC4jB/ Wmy9yt47pENq5WxxWMhT4kJZFJ+iX6cMsELMCBVV3MD3lNYHdhbtdHAbJXkRSHRlzfff QeFaKcUPpKKCv4IUJnZ+0cwmVwLvcnQ+fimHzzn0MKA6gRyqi+WMh1ed14ZTat2145YV NkjHv4FfGA9LsnA03e+66IKfMR5ZbPk+R8IHjOBuhnAUpKaGe5GYEkJO3QdNEYicFS+A dIU7KFrJ2gyondW02IOLFNloMQMCiuziILKBZaG5SnsIW5Tx+iyIkSPrvvEqt9OV/J4t HEMg== 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=qD9TO6jGFspxgEuw853gVRm0hcTBzuluIXG7+nD8HAE=; b=P3nOBBntVHDTYXdPObk0dhQmiSS113jE+WaoiwUA8UbaroNJQddQYvD7zFAzYzDdvh oDkdTmJ1Fzn6+TTNwBo3hn14b/8xKSitNgFxYuwT3UW++tZixyYPKyB1Ks1XTcD+PX5A U6W+EmRRjmAQeUlSlMHS8bD7iKBP/dFKCj7aC6EoyEEPUim0LYHLH6zs3UhyqBbUzxg5 5n82CXrGWKFk9dWcTKP8Zeq/5mzjnlpGMjBxzPUimMv1E9YfkvcA+nfkI/8H6+8MzjJd WxcOkDzb6MYyEXkK0BWEIDzb+vK4H/Khqp+Ao1eM62QCUa3rTUfBTYw4sToNPOEHPcAl Lcww== X-Gm-Message-State: AOAM531LbSKPa6bswsnNOsSkwfo1dIvKTCTuhtig1uFQvuRluFyIo4Yh /JJlViykVc91QofI+chZAcHg617MO9GZ6g== X-Received: by 2002:a17:90a:bc8c:: with SMTP id x12mr97622pjr.106.1598890058276; Mon, 31 Aug 2020 09:07:38 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id gt13sm17218pjb.43.2020.08.31.09.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 09:07:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 70/76] target/microblaze: Convert msrclr, msrset to decodetree Date: Mon, 31 Aug 2020 09:05:55 -0700 Message-Id: <20200831160601.833692-71-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::1042; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1042.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 dec_msr. Tested-by: Edgar E. Iglesias Reviewed-by: Edgar E. Iglesias Signed-off-by: Richard Henderson --- target/microblaze/insns.decode | 6 +++ target/microblaze/translate.c | 85 +++++++++++++++++++--------------- 2 files changed, 54 insertions(+), 37 deletions(-) -- 2.25.1 diff --git a/target/microblaze/insns.decode b/target/microblaze/insns.decode index 8906058a29..ed3312982f 100644 --- a/target/microblaze/insns.decode +++ b/target/microblaze/insns.decode @@ -24,6 +24,7 @@ &typeb rd ra imm &typeb_br rd imm &typeb_bc ra imm +&type_msr rd imm # Include any IMM prefix in the value reported. %extimm 0:s16 !function=typeb_imm @@ -55,6 +56,8 @@ %ieimm 6:5 0:5 @typeb_ie ...... rd:5 ra:5 ..... ..... . ..... &typeb imm=%ieimm +@type_msr ...... rd:5 ...... imm:15 &type_msr + ### { @@ -179,6 +182,9 @@ lwi 111010 ..... ..... ................ @typeb mbar 101110 imm:5 00010 0000 0000 0000 0100 +msrclr 100101 ..... 100010 ............... @type_msr +msrset 100101 ..... 100000 ............... @type_msr + 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 0872795038..9479dbc103 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1311,16 +1311,61 @@ static void msr_write(DisasContext *dc, TCGv_i32 v) tcg_gen_andi_i32(cpu_msr, v, ~(MSR_C | MSR_CC | MSR_PVR)); } +static bool do_msrclrset(DisasContext *dc, arg_type_msr *arg, bool set) +{ + uint32_t imm = arg->imm; + + if (trap_userspace(dc, imm != MSR_C)) { + return true; + } + + if (arg->rd) { + msr_read(dc, cpu_R[arg->rd]); + } + + /* + * Handle the carry bit separately. + * This is the only bit that userspace can modify. + */ + if (imm & MSR_C) { + tcg_gen_movi_i32(cpu_msr_c, set); + } + + /* + * MSR_C and MSR_CC set above. + * MSR_PVR is not writable, and is always clear. + */ + imm &= ~(MSR_C | MSR_CC | MSR_PVR); + + if (imm != 0) { + if (set) { + tcg_gen_ori_i32(cpu_msr, cpu_msr, imm); + } else { + tcg_gen_andi_i32(cpu_msr, cpu_msr, ~imm); + } + dc->cpustate_changed = 1; + } + return true; +} + +static bool trans_msrclr(DisasContext *dc, arg_type_msr *arg) +{ + return do_msrclrset(dc, arg, false); +} + +static bool trans_msrset(DisasContext *dc, arg_type_msr *arg) +{ + return do_msrclrset(dc, arg, true); +} + static void dec_msr(DisasContext *dc) { CPUState *cs = CPU(dc->cpu); - TCGv_i32 t0, t1; unsigned int sr, rn; - bool to, clrset, extended = false; + bool to, extended = false; sr = extract32(dc->imm, 0, 14); to = extract32(dc->imm, 14, 1); - clrset = extract32(dc->imm, 15, 1) == 0; dc->type_b = 1; if (to) { dc->cpustate_changed = 1; @@ -1334,40 +1379,6 @@ static void dec_msr(DisasContext *dc) extended = extract32(dc->imm, e_bit[to], 1); } - /* msrclr and msrset. */ - if (clrset) { - bool clr = extract32(dc->ir, 16, 1); - - if (!dc->cpu->cfg.use_msr_instr) { - /* nop??? */ - return; - } - - if (trap_userspace(dc, dc->imm != 4 && dc->imm != 0)) { - return; - } - - if (dc->rd) - msr_read(dc, cpu_R[dc->rd]); - - t0 = tcg_temp_new_i32(); - t1 = tcg_temp_new_i32(); - msr_read(dc, t0); - tcg_gen_mov_i32(t1, *(dec_alu_op_b(dc))); - - if (clr) { - tcg_gen_not_i32(t1, t1); - tcg_gen_and_i32(t0, t0, t1); - } else - tcg_gen_or_i32(t0, t0, t1); - msr_write(dc, t0); - tcg_temp_free_i32(t0); - tcg_temp_free_i32(t1); - tcg_gen_movi_i32(cpu_pc, dc->base.pc_next + 4); - dc->base.is_jmp = DISAS_UPDATE; - return; - } - if (trap_userspace(dc, to)) { return; }