From patchwork Sat Mar 23 19:09:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160989 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2199161jan; Sat, 23 Mar 2019 12:49:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTUI0oS4rWq9fv3uwQUxuwGMGLrj4rVben8aZftSg6XM5UblQtxMhzj9TzfXO7qA87nkrn X-Received: by 2002:a81:4c13:: with SMTP id z19mr14438100ywa.57.1553370561750; Sat, 23 Mar 2019 12:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553370561; cv=none; d=google.com; s=arc-20160816; b=bmRq9zUO9GNVgFYXQtsYkFYK7MmpvW9vgQT3A6w8CEYaDO3TFYaCMlfY7TgNa9waPN azMCeU1ilMmhc4eykTk4rf5/AUBWQk0d+PVghpR3vMfh2CYy0mHbiPM2qO7ivM2IYiF0 C+Lqt6+Fsi1DbLHayCfBH4RAI/QpB9vqx5tG9vsv1pjZfjPrsRmgtd+mJOZ34zjGG0CD XxwhrZ7R4kcF71I6hDjDCPJpoePhqQeCUJd2/DcbqoM5IqGO+y4QqSOMoZutuAmpYbBS hpnsx9LaKXCKG22NBbTr4R3D+fu0krIX0Ovvq6SEpweBgRJMT0UVtNIO4w3RoO5oCKnN X3yA== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=3OxT6mpM/m6PbtrRF3gNTdG5tddrrD1q+DqAaSZ/g70=; b=L+qmrSYTiL/fn4++gZ9cjTo63a71sfwMmocQFZ6W0GNfi0WLk35xNEEQCSCczPjInT T5Vy1KKhi4ZwvolyUKzc5hOpRjgsEl2vJRJqke5D5kFWnRykVpsW0GlhQ0aLp4nR913G MBbxVppZT2Zvdy0PCP9X4J0NUwtgteK87iGjE3g2ZzsX2GnzYVVw4t0gltiyL+DVvcfz fCuXVkouNTCxNB5TehhR6sq1qKWVG/FcaD2k1RzwQjfNFL+a5npeltbNV9uhzbGtxxG5 teXfVwouBbB7Whe0Fr99YQyVSOFPspTVZHEwTJiq7UBn2Hps3FsvCJodj48XHueq4Ziq 22Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RfA1iPWP; 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 j83si7184591ywc.100.2019.03.23.12.49.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 23 Mar 2019 12:49:21 -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=RfA1iPWP; 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 ([127.0.0.1]:47280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7mdt-0003ph-7M for patch@linaro.org; Sat, 23 Mar 2019 15:49:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7mG4-0007kB-Cq for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:24:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7m1q-00073q-44 for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:10:03 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:38927) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h7m1j-0006u2-34 for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:09:59 -0400 Received: by mail-pg1-x541.google.com with SMTP id k3so1818pga.6 for ; Sat, 23 Mar 2019 12:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=3OxT6mpM/m6PbtrRF3gNTdG5tddrrD1q+DqAaSZ/g70=; b=RfA1iPWPfaw5WeXnLiq0TttMWgPNzpTp0372ECzn+ZpE5Kq1rQQRZv7FPlwIUpkN9i duQzpDKUuuZW0UES8ZwOphwqflRVAcTLtbdOuC+I75vsCBf6llYi81Io7/0hvSKID5gX SK8Nu6FFmIcYE+uPj5vM3bWpj/nRDP735x7qQgkBmg+W/n1xmtKmZaRmp38sihtbgL++ XYKl2hgiOWIiRbFqym/idPvcrYVf3oPjJRuZvBJmE09gGJWJ/liWQqrpem5woASkrd9j p7/3wMAuuoLmLVLR8JKIPvnxhsU0So2y/LrrYPQhWaPugTqzkWcemFd0OH1TdaQLQ/53 dbug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=3OxT6mpM/m6PbtrRF3gNTdG5tddrrD1q+DqAaSZ/g70=; b=c5z9+lkyGPxXNlxgB8b+4zqRkzQVvdQwGjnfgFFuQ7fGPw9JKp3kp4L1sjXjgjrKR8 AawAUWLm3pYrMzBG4b4EzZJBT4YBwBHvFm1qd7ddPp60q9CqR2neDHkvkUB1lAYy5gKs s7D8o5MPrZ/QDBs8GG8JHSE/gTvUQYca2i09gIwEhCBvvZJTBHIPQ5oKeYTHL/YXSxnG 4WtJS2yy8+EZMzopaz+a8inSlE7jr2/1iRL7BU1khTx3YtOv+nDK4EYCX5OPs8ykPzOY eOGvDNrT8M1d7QzKfMenmoJkC0evEmDW6sB/OtGKKlnJekzvLnYmYzLZvNo0pAS9++AU XXVQ== X-Gm-Message-State: APjAAAUqkoGZrfeR1fqvWYrXCrQIzDcHmOl00YVVKhzbCCGINf81jyTC eUDl4sAzWRxUD+zFkCOqOEiaVHjAm7M= X-Received: by 2002:a63:4847:: with SMTP id x7mr14727974pgk.233.1553368187467; Sat, 23 Mar 2019 12:09:47 -0700 (PDT) Received: from localhost.localdomain (174-21-5-201.tukw.qwest.net. [174.21.5.201]) by smtp.gmail.com with ESMTPSA id h184sm25990703pfc.78.2019.03.23.12.09.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Mar 2019 12:09:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 23 Mar 2019 12:09:05 -0700 Message-Id: <20190323190925.21324-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190323190925.21324-1-richard.henderson@linaro.org> References: <20190323190925.21324-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH 15/35] target/microblaze: Use env_cpu, env_archcpu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Signed-off-by: Richard Henderson --- target/microblaze/cpu.h | 35 ++++++++++++++------------------ linux-user/microblaze/cpu_loop.c | 2 +- target/microblaze/mmu.c | 5 ++--- target/microblaze/op_helper.c | 2 +- target/microblaze/translate.c | 2 +- 5 files changed, 20 insertions(+), 26 deletions(-) -- 2.17.1 diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index 3ca5d21451..a9748d57ad 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -310,11 +310,6 @@ struct MicroBlazeCPU { CPUMBState env; }; -static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env) -{ - return container_of(env, MicroBlazeCPU, env); -} - #define ENV_OFFSET offsetof(MicroBlazeCPU, env) void mb_cpu_do_interrupt(CPUState *cs); @@ -345,21 +340,6 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo, #define MMU_USER_IDX 2 /* See NB_MMU_MODES further up the file. */ -static inline int cpu_mmu_index (CPUMBState *env, bool ifetch) -{ - MicroBlazeCPU *cpu = mb_env_get_cpu(env); - - /* Are we in nommu mode?. */ - if (!(env->sregs[SR_MSR] & MSR_VM) || !cpu->cfg.use_mmu) { - return MMU_NOMMU_IDX; - } - - if (env->sregs[SR_MSR] & MSR_UM) { - return MMU_USER_IDX; - } - return MMU_KERNEL_IDX; -} - int mb_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, int mmu_idx); @@ -384,4 +364,19 @@ void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, MemTxResult response, uintptr_t retaddr); #endif +static inline int cpu_mmu_index(CPUMBState *env, bool ifetch) +{ + MicroBlazeCPU *cpu = env_archcpu(env); + + /* Are we in nommu mode?. */ + if (!(env->sregs[SR_MSR] & MSR_VM) || !cpu->cfg.use_mmu) { + return MMU_NOMMU_IDX; + } + + if (env->sregs[SR_MSR] & MSR_UM) { + return MMU_USER_IDX; + } + return MMU_KERNEL_IDX; +} + #endif diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_loop.c index c2190e15fd..f70329e021 100644 --- a/linux-user/microblaze/cpu_loop.c +++ b/linux-user/microblaze/cpu_loop.c @@ -23,7 +23,7 @@ void cpu_loop(CPUMBState *env) { - CPUState *cs = CPU(mb_env_get_cpu(env)); + CPUState *cs = env_cpu(env); int trapnr, ret; target_siginfo_t info; diff --git a/target/microblaze/mmu.c b/target/microblaze/mmu.c index fcf86b12d5..6763421ba2 100644 --- a/target/microblaze/mmu.c +++ b/target/microblaze/mmu.c @@ -34,7 +34,7 @@ static unsigned int tlb_decode_size(unsigned int f) static void mmu_flush_idx(CPUMBState *env, unsigned int idx) { - CPUState *cs = CPU(mb_env_get_cpu(env)); + CPUState *cs = env_cpu(env); struct microblaze_mmu *mmu = &env->mmu; unsigned int tlb_size; uint32_t tlb_tag, end, t; @@ -228,7 +228,6 @@ uint32_t mmu_read(CPUMBState *env, bool ext, uint32_t rn) void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v) { - MicroBlazeCPU *cpu = mb_env_get_cpu(env); uint64_t tmp64; unsigned int i; qemu_log_mask(CPU_LOG_MMU, @@ -269,7 +268,7 @@ void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v) /* Changes to the zone protection reg flush the QEMU TLB. Fortunately, these are very uncommon. */ if (v != env->mmu.regs[rn]) { - tlb_flush(CPU(cpu)); + tlb_flush(env_cpu(env)); } env->mmu.regs[rn] = v; break; diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c index e23dcfdc20..aa91d3a257 100644 --- a/target/microblaze/op_helper.c +++ b/target/microblaze/op_helper.c @@ -84,7 +84,7 @@ uint32_t helper_get(uint32_t id, uint32_t ctrl) void helper_raise_exception(CPUMBState *env, uint32_t index) { - CPUState *cs = CPU(mb_env_get_cpu(env)); + CPUState *cs = env_cpu(env); cs->exception_index = index; cpu_loop_exit(cs); diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 78ca265b04..816ba53721 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1603,7 +1603,7 @@ static inline void decode(DisasContext *dc, uint32_t ir) void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) { CPUMBState *env = cs->env_ptr; - MicroBlazeCPU *cpu = mb_env_get_cpu(env); + MicroBlazeCPU *cpu = env_archcpu(env); uint32_t pc_start; struct DisasContext ctx; struct DisasContext *dc = &ctx;