From patchwork Sat Mar 23 19:09:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 160978 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2191380jan; Sat, 23 Mar 2019 12:38:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKPtaK2EScrP4ZNtqKD8mzlA3iGe6aJaxA/iNtNaSh5ZIn/oK2xGW42Q6wZCUXu+NzIyDO X-Received: by 2002:a5b:7c1:: with SMTP id t1mr13777136ybq.289.1553369889755; Sat, 23 Mar 2019 12:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553369889; cv=none; d=google.com; s=arc-20160816; b=qVVmqUiHijTmP4yu7p7FJcaKcbVAnulhanBbcziBGEqSGKy03rwrWFVDkv80Pcfnqe g4J+/o3rapo4Jb2tABkV9J3XebHKbQ928ZX2YZ7TMePd+pkahDKEHzsfVp2TgxD+/TsD t90ahuX+N41GUXKZpsU5vwAgpSlIGfivWwB9r3/4luwo3oDtSL6EeF9SUUrQ0DJDbDQn tXo6Xhi+f22/rSFPahwBy3VJDFYF98++qeUfniZG9Ffdp+tMEVp/TOPRMYOLQSr/Bmv0 B3X37YmD88p3IDe1z3oDSXcOEas2UPHJ0K+rXMiYaebZiu4bmVhh4rrn/hzWhohQ7g55 07mA== 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=lDDnFZO5czCmaUbb1PZG7cNuDrH2EEa4yiXRXIIuvqw=; b=kctRfoznUWHOWqKm26teU7LyJ5k0G9qPg4t8ynLeatS+q4W9d9MvUKAPLCvUa7fbg7 26irYRaJ3r41dDcioCIXqrUc1LSK2/YVDdqLMnMNejNQjAEMd01lflzBGCo5fcMzLQ2e qzvyWpa5Yz6m9F7AepFKb6jpyxuHFOBWtXZrPcb3Lpb00jfnCJiUpyVhqnAMf0uVQIXu TLEAnfGG9sC6BiDTFzuPWrnp5IhNbSllHdh5XDD2gYllNLLG3FFJoRgIC56v8M0ScmlQ 9rGE0jdWAQYdbKUPNtBohU+OpZW+2wEwY+Sd/vX2Z/PQmRdzp6+k168SBysEUgaKkC8j y1dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nMFv9FHS; 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 x13si6426162ybm.475.2019.03.23.12.38.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 23 Mar 2019 12:38:09 -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=nMFv9FHS; 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]:47135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7mT3-0002Kn-73 for patch@linaro.org; Sat, 23 Mar 2019 15:38:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7mFx-0007mr-VZ for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:24:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7m27-0007EQ-TB for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:10:22 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:46023) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h7m22-0006z6-Av for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:10:16 -0400 Received: by mail-pg1-x544.google.com with SMTP id y3so3683624pgk.12 for ; Sat, 23 Mar 2019 12:09:58 -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=lDDnFZO5czCmaUbb1PZG7cNuDrH2EEa4yiXRXIIuvqw=; b=nMFv9FHSd0kOt9O+9FlUHGpSy8cCke3NELjprPzvU2MNKuSOmvA9oJj5GZieswvcTO 7YikGdEGK7Al/l6rzEpQVjPxuysDa/vMzBwyUprfT6iN9PlJJ0ve72jSRrpjxknj1CqZ +/79v7ptjp9gCeXuICGghs3DKl87nTgJIb1U5plifp3idz+93HEqFCRoBlGnPJHsWff2 LTWes9lDW1qh8wbNpQmsPaZwO2+xAAOXgrUlSN+SlWBydvPeFVbpEz/+zF0WQfXg1fK1 c2MwFlGik8MzvBMDZiZvNmRPbAiX9KNgK7dizSYDDrp91BJY1HHnTRLGpqbQdazoWvEo R2Mg== 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=lDDnFZO5czCmaUbb1PZG7cNuDrH2EEa4yiXRXIIuvqw=; b=N2fcr2kzMfAQcNuEIF+eM2g2IVo9faAhdI9+FCat0iuOyWZw4pjOgkMcll9gghW0Uo /taEbK3BYtpDKmQqybzYkuyIrm9Ash+XX8hNBJ7icXc/icjI5NP4uNoVje6f/eOG2eCN 8K+FVvsCjkBGK4WyDD20wyRWXz4bbbfuuDtGY1d12vcUKwN09kMwj3Jml4JigP38Flm/ pGzW1FRGhHoNEUWvwvoPpyC8A84kXtTHshOEOQrEPYJMMlAsZeH/p5wzzec2siF4ncki F3bNdKZSl6G2q9XYcs1NgMLc/edXJ3hF99m9kc+VmkZ9Ba+9L1U5gbBB8aak0GzN9R0E wDyA== X-Gm-Message-State: APjAAAU3jrXcRdyy6YCbOdoYKWG0gXeNx1Uj6H/xP9xDE+ovkUOD2Ija 2SSlLNH9sbYfAh7sZS/VLcD9mANT9hY= X-Received: by 2002:a62:6c43:: with SMTP id h64mr15892604pfc.123.1553368197162; Sat, 23 Mar 2019 12:09:57 -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.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Mar 2019 12:09:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 23 Mar 2019 12:09:13 -0700 Message-Id: <20190323190925.21324-24-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::544 Subject: [Qemu-devel] [PATCH 23/35] target/sh4: 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/sh4/cpu.h | 5 ----- linux-user/sh4/cpu_loop.c | 2 +- target/sh4/helper.c | 26 ++++++++++++-------------- target/sh4/op_helper.c | 9 +++------ 4 files changed, 16 insertions(+), 26 deletions(-) -- 2.17.1 diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 95094a517a..1f94e7bf7b 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -207,11 +207,6 @@ struct SuperHCPU { CPUSH4State env; }; -static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env) -{ - return container_of(env, SuperHCPU, env); -} - #define ENV_OFFSET offsetof(SuperHCPU, env) void superh_cpu_do_interrupt(CPUState *cpu); diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c index 47e54b9b61..677c5a461c 100644 --- a/linux-user/sh4/cpu_loop.c +++ b/linux-user/sh4/cpu_loop.c @@ -23,7 +23,7 @@ void cpu_loop(CPUSH4State *env) { - CPUState *cs = CPU(sh_env_get_cpu(env)); + CPUState *cs = env_cpu(env); int trapnr, ret; target_siginfo_t info; diff --git a/target/sh4/helper.c b/target/sh4/helper.c index 2ff0cf4060..5240da715e 100644 --- a/target/sh4/helper.c +++ b/target/sh4/helper.c @@ -238,8 +238,6 @@ static void update_itlb_use(CPUSH4State * env, int itlbnb) static int itlb_replacement(CPUSH4State * env) { - SuperHCPU *cpu = sh_env_get_cpu(env); - if ((env->mmucr & 0xe0000000) == 0xe0000000) { return 0; } @@ -252,7 +250,7 @@ static int itlb_replacement(CPUSH4State * env) if ((env->mmucr & 0x2c000000) == 0x00000000) { return 3; } - cpu_abort(CPU(cpu), "Unhandled itlb_replacement"); + cpu_abort(env_cpu(env), "Unhandled itlb_replacement"); } /* Find the corresponding entry in the right TLB @@ -308,7 +306,7 @@ static int copy_utlb_entry_itlb(CPUSH4State *env, int utlb) itlb = itlb_replacement(env); ientry = &env->itlb[itlb]; if (ientry->v) { - tlb_flush_page(CPU(sh_env_get_cpu(env)), ientry->vpn << 10); + tlb_flush_page(env_cpu(env), ientry->vpn << 10); } *ientry = env->utlb[utlb]; update_itlb_use(env, itlb); @@ -533,14 +531,14 @@ hwaddr superh_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) void cpu_load_tlb(CPUSH4State * env) { - SuperHCPU *cpu = sh_env_get_cpu(env); + CPUState *cs = env_cpu(env); int n = cpu_mmucr_urc(env->mmucr); tlb_t * entry = &env->utlb[n]; if (entry->v) { /* Overwriting valid entry in utlb. */ target_ulong address = entry->vpn << 10; - tlb_flush_page(CPU(cpu), address); + tlb_flush_page(cs, address); } /* Take values into cpu status from registers. */ @@ -563,7 +561,7 @@ void cpu_load_tlb(CPUSH4State * env) entry->size = 1024 * 1024; /* 1M */ break; default: - cpu_abort(CPU(cpu), "Unhandled load_tlb"); + cpu_abort(cs, "Unhandled load_tlb"); break; } entry->sh = (uint8_t)cpu_ptel_sh(env->ptel); @@ -590,7 +588,7 @@ void cpu_load_tlb(CPUSH4State * env) entry->v = 0; } - tlb_flush(CPU(sh_env_get_cpu(s))); + tlb_flush(env_cpu(s)); } uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s, @@ -616,7 +614,7 @@ void cpu_sh4_write_mmaped_itlb_addr(CPUSH4State *s, hwaddr addr, if (entry->v) { /* Overwriting valid entry in itlb. */ target_ulong address = entry->vpn << 10; - tlb_flush_page(CPU(sh_env_get_cpu(s)), address); + tlb_flush_page(env_cpu(s), address); } entry->asid = asid; entry->vpn = vpn; @@ -658,7 +656,7 @@ void cpu_sh4_write_mmaped_itlb_data(CPUSH4State *s, hwaddr addr, if (entry->v) { /* Overwriting valid entry in utlb. */ target_ulong address = entry->vpn << 10; - tlb_flush_page(CPU(sh_env_get_cpu(s)), address); + tlb_flush_page(env_cpu(s), address); } entry->ppn = (mem_value & 0x1ffffc00) >> 10; entry->v = (mem_value & 0x00000100) >> 8; @@ -711,7 +709,7 @@ void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, hwaddr addr, if (entry->vpn == vpn && (!use_asid || entry->asid == asid || entry->sh)) { if (utlb_match_entry) { - CPUState *cs = CPU(sh_env_get_cpu(s)); + CPUState *cs = env_cpu(s); /* Multiple TLB Exception */ cs->exception_index = 0x140; @@ -743,14 +741,14 @@ void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, hwaddr addr, } if (needs_tlb_flush) { - tlb_flush_page(CPU(sh_env_get_cpu(s)), vpn << 10); + tlb_flush_page(env_cpu(s), vpn << 10); } } else { int index = (addr & 0x00003f00) >> 8; tlb_t * entry = &s->utlb[index]; if (entry->v) { - CPUState *cs = CPU(sh_env_get_cpu(s)); + CPUState *cs = env_cpu(s); /* Overwriting valid entry in utlb. */ target_ulong address = entry->vpn << 10; @@ -805,7 +803,7 @@ void cpu_sh4_write_mmaped_utlb_data(CPUSH4State *s, hwaddr addr, if (entry->v) { /* Overwriting valid entry in utlb. */ target_ulong address = entry->vpn << 10; - tlb_flush_page(CPU(sh_env_get_cpu(s)), address); + tlb_flush_page(env_cpu(s), address); } entry->ppn = (mem_value & 0x1ffffc00) >> 10; entry->v = (mem_value & 0x00000100) >> 8; diff --git a/target/sh4/op_helper.c b/target/sh4/op_helper.c index 12fba6fc78..11cb68cc1c 100644 --- a/target/sh4/op_helper.c +++ b/target/sh4/op_helper.c @@ -58,10 +58,7 @@ void tlb_fill(CPUState *cs, target_ulong addr, int size, void helper_ldtlb(CPUSH4State *env) { #ifdef CONFIG_USER_ONLY - SuperHCPU *cpu = sh_env_get_cpu(env); - - /* XXXXX */ - cpu_abort(CPU(cpu), "Unhandled ldtlb"); + cpu_abort(env_cpu(env), "Unhandled ldtlb"); #else cpu_load_tlb(env); #endif @@ -70,7 +67,7 @@ void helper_ldtlb(CPUSH4State *env) static inline void QEMU_NORETURN raise_exception(CPUSH4State *env, int index, uintptr_t retaddr) { - CPUState *cs = CPU(sh_env_get_cpu(env)); + CPUState *cs = env_cpu(env); cs->exception_index = index; cpu_loop_exit_restore(cs, retaddr); @@ -103,7 +100,7 @@ void helper_debug(CPUSH4State *env) void helper_sleep(CPUSH4State *env) { - CPUState *cs = CPU(sh_env_get_cpu(env)); + CPUState *cs = env_cpu(env); cs->halted = 1; env->in_sleep = 1;