From patchwork Mon Jun 10 02:02:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 166263 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp475798ilk; Sun, 9 Jun 2019 19:26:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZahB18n6Fnrv0zTx4TEX0f9T+pWiEIGd2y3ekm2pKlf+8XeaiaeLGDP5PlN5LEGoPgLmb X-Received: by 2002:a37:8306:: with SMTP id f6mr8629532qkd.19.1560133603071; Sun, 09 Jun 2019 19:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560133603; cv=none; d=google.com; s=arc-20160816; b=AaFgyhavY2o4i7xp0WohO51SRo71/kdlzYN+zYE5yqZY+zDFZwKpHfc1Cw9ox4qQ1S x6x3qz6JcUGvUf3DLWF4Xmz3muTXkCBqagNKhU+VuRyZncsyB477llQC7J+IyD2oM+V0 JIEciOtSSjkUl2aIVVAaehSlqMD18tk2ZIQf/Ll+O93dLK7HgqPoiWt2GqGzo8ArhIq7 ZTWHLgti4VhA2gDG6xVEhOV9vIuOCecGUBNX1vLVlJzQUz/Pv3YtGWzdq3v6DYXZINs5 +SoHB90UNMkU5icWCrKzM5SqYxb46DAY6UR/sMQzqd9PVqB9BEEtIcQBMCPH7ee9aI9A LSSg== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=BPOSGSRwnnlDmzKutwLcU2dnjTQ5x21/pJ7MvOt5Ozw=; b=zSPFpo5GXjIsKRqF6l/W7uI7zvY2Ud+I0Mfb21XQHD1gZ9pfn86fa1/8ma0X1y97Yv Zi3xCr8XTKHuLKlqqREsckSM/eJGrMSl9was9IzOPmSkxIrxaSpVMsAZz65/ULtXmfHl galqzZxzxFPRnBrwDluBK9SbVkU54caj+d0qRNFdJFIXXYo25x7DDwjaL+F50d8JSMur 9RQK6g6FaBIylWl5iZdUDC6TRVotmv6CodvDl6ilOfCiyrilW4NwuWI7MUGXwqriKwsM XYuNTvv1huz/g6SxRjb69tlYbJuoNFiEv3PUdhMa34OIu0HD6MiwibXOmf4+F7keFjG/ gz/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="x1A/kUQI"; 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 46si6551990qtn.363.2019.06.09.19.26.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jun 2019 19:26:43 -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="x1A/kUQI"; 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]:39762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haA1C-0004Mw-MT for patch@linaro.org; Sun, 09 Jun 2019 22:26:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53189) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ha9e7-0006b0-PT for qemu-devel@nongnu.org; Sun, 09 Jun 2019 22:02:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ha9e6-0001nk-Cl for qemu-devel@nongnu.org; Sun, 09 Jun 2019 22:02:51 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:36248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ha9e6-0001nJ-6r for qemu-devel@nongnu.org; Sun, 09 Jun 2019 22:02:50 -0400 Received: by mail-pg1-x531.google.com with SMTP id a3so4155831pgb.3 for ; Sun, 09 Jun 2019 19:02:50 -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; bh=BPOSGSRwnnlDmzKutwLcU2dnjTQ5x21/pJ7MvOt5Ozw=; b=x1A/kUQIngeKgk36aOdH4fmlltdYL1O9WmCzSkuZhwe/iMfR1K+wj4glBCz6iAo9Lb 6T0VG7NiU0xZ9LLS+UsfzlYsd1E3/cwyitxbWVuQW1Rw94dw2BAy9aUVgE4UJsknS0kR SpVCCd/Xf+hA3ilANcIcKV3HgNIUavXVrAqFX06VRp8Q+2NlE0xeoT4Z3hOQdawxnXdj XUiZlL4TMWcQ1Gs5twCjtcFxbpZPSblE/2c/jKmpOUJ0lGEiQRX1CH6gUW1zptSZ9eJg LkXhfWsUNA3+eM8CjtnGLUj2ubW2CHzVtHKPoxTLwrrm7aYrbgT0U7GWZxz0gI3AV9iI cxVA== 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; bh=BPOSGSRwnnlDmzKutwLcU2dnjTQ5x21/pJ7MvOt5Ozw=; b=lLrvHL35sHSTQfPOrNT8ctggOmllGjGx8JrOWT4w80BlRS38NAJAMOdewvJevS7en7 EpLASMKFyMoCKxd/CmAKEz+XqLiFmLNnN6WDRhkwXUtcEzQC/PGaJnIUNNFL7iaQq86k eYLtNn8tN9V8DY0QeOaXRCLMw/wYZm0SsNaCUme1OOA/1tqmoR/FLiLxYQmyCOvajLwS VtR2tlUvPuTYqA5tP8ru2JD7LSkn41qDh37K6M3e034vclHkbyW0/WI+ST+rLgijco0p 0xNpOl5Ima9pYvb28BOe6ylVvNveJwuZ8q6Jw+aOnvos/10/1mBsn05DVwV/0RLeJ0FE MJxg== X-Gm-Message-State: APjAAAWimA9UDuE1WtW2Ht7Kwm4GatpJw1GvpdIHGI+RMvILm0ciZM8Q AO8iVDsULas9THc97PPov/1ENvaVbzw= X-Received: by 2002:a63:dc4d:: with SMTP id f13mr13361295pgj.417.1560132168830; Sun, 09 Jun 2019 19:02:48 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id l63sm9749013pfl.181.2019.06.09.19.02.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Jun 2019 19:02:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 9 Jun 2019 19:02:02 -0700 Message-Id: <20190610020218.9228-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190610020218.9228-1-richard.henderson@linaro.org> References: <20190610020218.9228-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::531 Subject: [Qemu-devel] [PULL 23/39] target/riscv: Use env_cpu, env_archcpu 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cleanup in the boilerplate that each target must define. Replace riscv_env_get_cpu with env_archcpu. The combination CPU(riscv_env_get_cpu) should have used ENV_GET_CPU to begin; use env_cpu now. 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 | 10 ++++------ target/riscv/csr.c | 12 ++++++------ target/riscv/op_helper.c | 7 +++---- 5 files changed, 14 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 9ab038bac3..29a1e08f03 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -221,11 +221,6 @@ typedef struct RISCVCPU { } cfg; } 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 c577a262b8..8b6754b917 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -89,14 +89,12 @@ struct CpuAsyncInfo { static void riscv_cpu_update_mip_irqs_async(CPUState *target_cpu_state, run_on_cpu_data data) { - CPURISCVState *env = &RISCV_CPU(target_cpu_state)->env; - RISCVCPU *cpu = riscv_env_get_cpu(env); struct CpuAsyncInfo *info = (struct CpuAsyncInfo *) data.host_ptr; if (info->new_mip) { - cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); + cpu_interrupt(target_cpu_state, CPU_INTERRUPT_HARD); } else { - cpu_reset_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); + cpu_reset_interrupt(target_cpu_state, CPU_INTERRUPT_HARD); } g_free(info); @@ -212,7 +210,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; @@ -341,7 +339,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 f9e2910643..c67d29e206 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_MPV | 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); } @@ -724,7 +724,7 @@ static int write_satp(CPURISCVState *env, int csrno, target_ulong val) return -1; } else { if((val ^ env->satp) & SATP_ASID) { - 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 644d0fb35f..331cc36232 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,7 @@ 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 == PRV_S && env->priv_ver >= PRIV_VERSION_1_10_0 &&