From patchwork Wed May 8 00:06:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163583 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp2001065ilm; Tue, 7 May 2019 17:26:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJkhrPbBTxNuU/d3e24z3c/D2Z/yHm9oZqvUVu2cx3wPaZCodASdNCEbUn2HiLUVnTK2Kq X-Received: by 2002:adf:fc51:: with SMTP id e17mr634901wrs.243.1557275212987; Tue, 07 May 2019 17:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557275212; cv=none; d=google.com; s=arc-20160816; b=qIgJ11RUWnZ14nJkIQRt4nDT7Uck9xSRuLvaXDJMGQF7XOKzaW5jugPKlnOoSjXWAj VhM/bxJl3DMK7iDHV8tNenZgZqclv7ZG9zENaRFCfQVHEGgMIXxDbBZLysJT44G/kkkO N3aQQfWpN5HjlRoRc92JU/s5bsPko3sFYEUXpXXnYF3gSe44GTqZvVb6SVOr9bkmBktA UcnWXuXLCQNE78rq37I+A75Mss/RTnanh1L4hwUiodZ5mVUt/FiHran968lyOlhI4keK MjUkyEgFb6nGqRjxHlcHGY91j59Lyjcu+meoyULIVKmpTfWwy/6nlq7nSTtS1l3qqIG8 VNbw== 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=e2MoXSBglROjVW1qX9oGId2d2/qC2uKVSMSH4SFJtck=; b=pT/jjEhzcNJ3Epez8dlMaDjLAb4HLvgP4bYvXqcX8+7ytekyZSqSxbH2cRlW9apsB4 j4gQ0mc+Xu668C7M4M3amUriAzd85QGGOvufvVYzOfzfmh3wcNLvj6yV1iMoOkx4pbiS qO7IJsXWuHYGhTIRardozscsl6gUEG1eYOHp7gyuaUd7RhHw82/ShsRTgginGgTrzqBc I0YwBOYMRKDgIZmqbaw5HvoaINwLUsBq5eZer2r1F1EpK5aYTHgbqZ1vZkc/k5ESpQBG wvQ4f18N5Fe2VUXbpwgPZ+gEakU7VUjgXbLSYTFbGRI8o6VE6alFB7ztiF/nDond1zF/ LtOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Yvu02UQi; 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 x10si361489wmh.172.2019.05.07.17.26.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 07 May 2019 17:26:52 -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=Yvu02UQi; 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]:56668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOAQ7-0007rG-Oa for patch@linaro.org; Tue, 07 May 2019 20:26:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOA7A-0007dX-Lk for qemu-devel@nongnu.org; Tue, 07 May 2019 20:07:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOA79-00075x-BJ for qemu-devel@nongnu.org; Tue, 07 May 2019 20:07:16 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:33450) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOA79-00073Y-1B for qemu-devel@nongnu.org; Tue, 07 May 2019 20:07:15 -0400 Received: by mail-pf1-x441.google.com with SMTP id z28so9503446pfk.0 for ; Tue, 07 May 2019 17:07:14 -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=e2MoXSBglROjVW1qX9oGId2d2/qC2uKVSMSH4SFJtck=; b=Yvu02UQi6EDj7n6xivaxhG7Cmpi0hRpz6pzCNG/kh72yjN7WLowuu+O14V0d2y2GHt BA6RIYRcAlIaz4T+Qm3KyLjwI7SYGK0m8KVovxrTgdG+1Rve7RzF7aK6kJ+WrHjryaU0 LnR6Drh6QGqAt/Pkf2xIlHh53MtJHMreYqhdd+H70fVOToINauxAcBbw3G0DFv15TSzo slTXqbv4U5RlSNemaNbIKMei/v/ewf1Aa1mrPzifXNdE5W36e9L+hnULtFdCX+8pI1VH EmVx4AgICQFbtGC0cr0LXeGJsSlu/ATOkFZYAN4y0CANsuJpLn93tH69Lx4zn1QSB4ov V3Tw== 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=e2MoXSBglROjVW1qX9oGId2d2/qC2uKVSMSH4SFJtck=; b=aTZxumr/qUKRYe09P3+rmAuJzCU93MvWg8rg+og4S7dOydxsfJ9Gm7hJIAz+AFqbSO ePjUA6DyULHaCjC0ngRj8IUP6BCr2+QLbmeu9unSn4OswUfslt/hnkJQAR+qZCwmU/NS xqNCJxnVXepSd3Ezt9ed919xdiKjyut9fZWjB4jt2yIdbve6SSf6d4DrYUXvqYOtPiYy S+EfN6nXxHNeJIRQL3KUG1u1bnoEdzQg3AHgvEdPkuUUmVqvDlyUA/RFzUKQuLwAVzmM NjxoLsKTvmGORZXgm2IPORDvYJ6BEQEsTJPMIqLq34Ha1KG1KmNbfg9CpR95wUf+2+Pq z7Jw== X-Gm-Message-State: APjAAAVvTzKXvM2sO0lSq+DDpKm3HqDq6WF7AlfVQ6keNDo2tWQZ4o+e xiwFaIrDX8O5aGXLjIFT+Uvr1sNYETg= X-Received: by 2002:aa7:8493:: with SMTP id u19mr26166187pfn.233.1557274033783; Tue, 07 May 2019 17:07:13 -0700 (PDT) Received: from localhost.localdomain (97-113-189-189.tukw.qwest.net. [97.113.189.189]) by smtp.gmail.com with ESMTPSA id j1sm15793183pgp.91.2019.05.07.17.07.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 May 2019 17:07:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 7 May 2019 17:06:25 -0700 Message-Id: <20190508000641.19090-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190508000641.19090-1-richard.henderson@linaro.org> References: <20190508000641.19090-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::441 Subject: [Qemu-devel] [PATCH v3 23/39] target/riscv: 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" Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- target/riscv/cpu.h | 5 ----- linux-user/riscv/cpu_loop.c | 2 +- target/riscv/cpu_helper.c | 4 ++-- target/riscv/csr.c | 12 ++++++------ target/riscv/op_helper.c | 8 ++++---- 5 files changed, 13 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index cd4f2de798..c32428a4ef 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -211,11 +211,6 @@ typedef struct RISCVCPU { CPURISCVState env; } RISCVCPU; -static inline RISCVCPU *riscv_env_get_cpu(CPURISCVState *env) -{ - return container_of(env, RISCVCPU, env); -} - static inline int riscv_has_ext(CPURISCVState *env, target_ulong ext) { return (env->misa & ext) != 0; diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index 31700f75d0..c1134597fd 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -25,7 +25,7 @@ void cpu_loop(CPURISCVState *env) { - CPUState *cs = CPU(riscv_env_get_cpu(env)); + CPUState *cs = env_cpu(env); int trapnr, signum, sigcode; target_ulong sigaddr; target_ulong ret; diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index b17f169681..72f82c1ccf 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -191,7 +191,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, } } - CPUState *cs = CPU(riscv_env_get_cpu(env)); + CPUState *cs = env_cpu(env); int va_bits = PGSHIFT + levels * ptidxbits; target_ulong mask = (1L << (TARGET_LONG_BITS - (va_bits - 1))) - 1; target_ulong masked_msbs = (addr >> (va_bits - 1)) & mask; @@ -320,7 +320,7 @@ restart: static void raise_mmu_exception(CPURISCVState *env, target_ulong address, MMUAccessType access_type) { - CPUState *cs = CPU(riscv_env_get_cpu(env)); + CPUState *cs = env_cpu(env); int page_fault_exceptions = (env->priv_ver >= PRIV_VERSION_1_10_0) && get_field(env->satp, SATP_MODE) != VM_1_10_MBARE; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e1d91b6c60..97a4e10e3e 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -296,7 +296,7 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) if (env->priv_ver <= PRIV_VERSION_1_09_1) { if ((val ^ mstatus) & (MSTATUS_MXR | MSTATUS_MPP | MSTATUS_MPRV | MSTATUS_SUM | MSTATUS_VM)) { - tlb_flush(CPU(riscv_env_get_cpu(env))); + tlb_flush(env_cpu(env)); } mask = MSTATUS_SIE | MSTATUS_SPIE | MSTATUS_MIE | MSTATUS_MPIE | MSTATUS_SPP | MSTATUS_FS | MSTATUS_MPRV | MSTATUS_SUM | @@ -307,7 +307,7 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) if (env->priv_ver >= PRIV_VERSION_1_10_0) { if ((val ^ mstatus) & (MSTATUS_MXR | MSTATUS_MPP | MSTATUS_MPRV | MSTATUS_SUM)) { - tlb_flush(CPU(riscv_env_get_cpu(env))); + tlb_flush(env_cpu(env)); } mask = MSTATUS_SIE | MSTATUS_SPIE | MSTATUS_MIE | MSTATUS_MPIE | MSTATUS_SPP | MSTATUS_FS | MSTATUS_MPRV | MSTATUS_SUM | @@ -382,7 +382,7 @@ static int write_misa(CPURISCVState *env, int csrno, target_ulong val) /* flush translation cache */ if (val != env->misa) { - tb_flush(CPU(riscv_env_get_cpu(env))); + tb_flush(env_cpu(env)); } env->misa = val; @@ -549,7 +549,7 @@ static int write_mbadaddr(CPURISCVState *env, int csrno, target_ulong val) static int rmw_mip(CPURISCVState *env, int csrno, target_ulong *ret_value, target_ulong new_value, target_ulong write_mask) { - RISCVCPU *cpu = riscv_env_get_cpu(env); + RISCVCPU *cpu = env_archcpu(env); /* Allow software control of delegable interrupts not claimed by hardware */ target_ulong mask = write_mask & delegable_ints & ~env->miclaim; uint32_t old_mip; @@ -712,7 +712,7 @@ static int write_satp(CPURISCVState *env, int csrno, target_ulong val) return 0; } if (env->priv_ver <= PRIV_VERSION_1_09_1 && (val ^ env->sptbr)) { - tlb_flush(CPU(riscv_env_get_cpu(env))); + tlb_flush(env_cpu(env)); env->sptbr = val & (((target_ulong) 1 << (TARGET_PHYS_ADDR_SPACE_BITS - PGSHIFT)) - 1); } @@ -723,7 +723,7 @@ static int write_satp(CPURISCVState *env, int csrno, target_ulong val) if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) { return -1; } else { - tlb_flush(CPU(riscv_env_get_cpu(env))); + tlb_flush(env_cpu(env)); env->satp = val; } } diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index b7dc18a41e..f078bafbe6 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -28,7 +28,7 @@ void QEMU_NORETURN riscv_raise_exception(CPURISCVState *env, uint32_t exception, uintptr_t pc) { - CPUState *cs = CPU(riscv_env_get_cpu(env)); + CPUState *cs = env_cpu(env); qemu_log_mask(CPU_LOG_INT, "%s: %d\n", __func__, exception); cs->exception_index = exception; cpu_loop_exit_restore(cs, pc); @@ -128,7 +128,7 @@ target_ulong helper_mret(CPURISCVState *env, target_ulong cpu_pc_deb) void helper_wfi(CPURISCVState *env) { - CPUState *cs = CPU(riscv_env_get_cpu(env)); + CPUState *cs = env_cpu(env); if (env->priv == PRV_S && env->priv_ver >= PRIV_VERSION_1_10_0 && @@ -143,8 +143,8 @@ void helper_wfi(CPURISCVState *env) void helper_tlb_flush(CPURISCVState *env) { - RISCVCPU *cpu = riscv_env_get_cpu(env); - CPUState *cs = CPU(cpu); + CPUState *cs = env_cpu(env); + if (env->priv == PRV_S && env->priv_ver >= PRIV_VERSION_1_10_0 && get_field(env->mstatus, MSTATUS_TVM)) {