From patchwork Thu Mar 28 23:03:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 161343 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1329301jan; Thu, 28 Mar 2019 16:27:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzS5gL1fFTlouJaUDO5CMmHLbJ10e5oiznYB/qFNWLwZ72klCFfzi6RS2WVhxnKSJDHlpke X-Received: by 2002:a24:e4c6:: with SMTP id o189mr1861655ith.4.1553815657212; Thu, 28 Mar 2019 16:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553815657; cv=none; d=google.com; s=arc-20160816; b=VcvK9UUeV8RHI9Dx4e+vrHg8eHZ5IBq7FmMCSV9gT6SRTtwy0LqhtUIN9IizzjtwaA lr8IG84Vsu7QLmlJNltOZhiurVs40vigFEDIDtxeTqMRYG9Tnmkq6YVDo2ss4M63aqBm plyeeusXfZ4/6+NP+S8cLe4isvljBQs+t6GDaUOOwakdxoLO2UQpM52jAauaPcHc1hz3 kwIJ5nGADZKOUAGJZwLHREjcvrGBBQi0pxvmDTMC8KGtZEDm5Aalon+0aBOaXnuLsngl ScfSfl26LFRJks3Dh4aNdumVKFuJ1ECoBrC5xAuJd3lmh4KA/EPZIQARRoPfh9660BZs QfPA== 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=aKfVREGx8Npi8KLiXwQBPMG2nETepzh03f94XWL17vSncM/95Cocx0uh4c1vNmlw8O NqKk3BO9UnOvOANBRSwc8KwK1J4XKP8hPdlIFAWhTJ6II3QyXwKq9OdCYntRHDBzXjIQ yo54d34xwsKiePNd7qHnsOeM7K68320MteX9xBs8hgXuDL5jCDP5g8dtj0psKcs57XgQ f4gtBoLGyE5Gk842BKu8RRBwoPzYuKE8oYDeOqucPQAot/Z/VQXtkPdX2TmeqSQkGmHB cy190UMT+wxZBjTkWElKplkxY2iBcVl3xEfVEBLFmJzDFT/ZKdv9M1yZS8Nl75rUIB1g dnEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TgyJ1Gz4; 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 k139si203408ite.56.2019.03.28.16.27.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Mar 2019 16:27:37 -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=TgyJ1Gz4; 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]:43258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9eQq-0007xZ-HB for patch@linaro.org; Thu, 28 Mar 2019 19:27:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9eKo-0001dn-8i for qemu-devel@nongnu.org; Thu, 28 Mar 2019 19:21:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9e4o-0003AC-KU for qemu-devel@nongnu.org; Thu, 28 Mar 2019 19:04:52 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:36438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h9e4l-00038W-Nu for qemu-devel@nongnu.org; Thu, 28 Mar 2019 19:04:49 -0400 Received: by mail-pg1-x542.google.com with SMTP id 85so236150pgc.3 for ; Thu, 28 Mar 2019 16:04:46 -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=TgyJ1Gz42FRnyrZFuBqyT7zPriCNucYR557o0epWMbjlLapB7OxjynMkFzIKVH2G50 JB5c9xUD0pQn8NtTCv1X+SKzrkDMecvGOPboLZ6EZssoitVmQTCY9JT3YWMwCI+/L+z4 tWJRwyHQUSAb3l151bEkitt+mgViFdfifCUz4gbXZ5Su3EPjkXzUnQLXigHw8tCUHzOZ 7XdurUjwklbkRmMHx5xdoXiemptonkhCbfWZq23XKN9YkIHis48I/lbH/skTREXVbzUg MwP08/ZsYLMubatzQI3Z2kG7oX8BKLlxoqa7CywU4YhB7w5STebcW1uRa6DLu01lr48J dqvA== 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=T6lReYgWyWIJQqxHXeQxTnps3lSImMfTbign+FV3rdjfOGioTXzWs3HE/x/dR4z9uI DpD9ag+0EiHIREnyvuIIiGM/U9u9JncvJXeVHxbNKSQ2Szyh9EjX4ZdlRNctBHFpxQ1d HhSp4s3sVkVMnCk82xR/VmFfQQy12kjZutCe6IgpnW08UrZ7wdT3njBwaYpNQMO2dvkl VpmGAHZpvJMW9qgb8uI41K+LjzyeAKUo+T2iVQtTulC14BiS8nFvAn8zBYFR9VZUSYLT qesGcjplt54wZzxpQkA+PadIof6AvMf5krn+l+nkzqk01Csp3wWrPIIcR6u8IcFV5VX/ ifgQ== X-Gm-Message-State: APjAAAXm5efPqqmJoWOHh5oalr4cVmSM+ayeylLFVtOtdGbbHoUmqXbX GdLPbb7hIn91Lp17UwuDXPiQv29sWWY= X-Received: by 2002:a62:449b:: with SMTP id m27mr44209807pfi.79.1553814285706; Thu, 28 Mar 2019 16:04:45 -0700 (PDT) Received: from cloudburst.ASUS (cpe-66-75-72-255.hawaii.res.rr.com. [66.75.72.255]) by smtp.gmail.com with ESMTPSA id f1sm280911pgl.35.2019.03.28.16.04.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2019 16:04:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 28 Mar 2019 13:03:51 -1000 Message-Id: <20190328230404.12909-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190328230404.12909-1-richard.henderson@linaro.org> References: <20190328230404.12909-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::542 Subject: [Qemu-devel] [PATCH for-4.1 v2 23/36] 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 Reviewed-by: Philippe Mathieu-Daudé 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;