From patchwork Sat Mar 23 19:09:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1062454 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="p/VvhJBt"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44RW231Jgvz9sSR for ; Sun, 24 Mar 2019 06:34:51 +1100 (AEDT) Received: from localhost ([127.0.0.1]:47066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7mPo-0006kg-VM for incoming@patchwork.ozlabs.org; Sat, 23 Mar 2019 15:34:49 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7mFs-0008Km-4r for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:24:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7m2S-0007Tx-DB for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:10:42 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:42139) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h7m2L-00075G-7r for qemu-devel@nongnu.org; Sat, 23 Mar 2019 15:10:37 -0400 Received: by mail-pf1-x442.google.com with SMTP id r15so3672008pfn.9 for ; Sat, 23 Mar 2019 12:10:04 -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=+sRDVIntdCdAO4YDH72tQOocV4ty8r9ZRYee6b01apk=; b=p/VvhJBtvSLZr0iNgWC0vWfwGPY4ZKBzPOrWErN2ARkpY8qA0aAXlHIakscT13PSFS iFSMdaXYRanTY1EqV11ZvqIu99sLIK+9PXM2B/jz95DlGFxWWa/Ax+a756XLNcInKN6F D+kVYB78g1JtOhOvyn1oh2BChH9qRfF1oLN6vNweY8AFvUYTFmW3PXmjnaeUXVvNwcho gKHj6JlpqV9TnKGxmWm8gAWCgweDBLaJK5mJEk5E9CP9mf/YQExt+5l5rNLBAqHfDmSq RMCz9+ywd5TqpQaabEv3jrVvp6g4B9DWMURzoIQ/9gf0kQb5nFStRtzv1pT2ee03NCns DF3g== 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=+sRDVIntdCdAO4YDH72tQOocV4ty8r9ZRYee6b01apk=; b=QFncjxxdcPDBez9nbhk7IFrcap78KYEYXcYzUZzNAQHTFx45fOQEfLJkefi8dzYL50 fOiwfz1kKjo2lnC4See2gJ1cKgYCIgXSSqcYmUAEh5YjgAPmAbiCvvmvfQPf16mx9hCo ZQn4Aa12ub69uI14aboIa1ahURETo+YyuvbKqtXtC8ZTx7aqfjphZxgicRYjLSD8e110 k4eKMLuEGtfOsVhqDA5AWEpADlPqdde4HjC2W+7xGLD9AChrXhqoo62WfExKWX6rrt2e WlA2JdN4b/a39xdE9qQnVWwfCqKmEaTewFCRg8+paxybfeyvdp8i+X9DEFZDnCPyYrUy zwZA== X-Gm-Message-State: APjAAAU2kxL09qbLjG8uxtvOZcrXrjcpHAG3eWJLIxnqykIpAVsXnOe0 dwRP8OSKHGOj0Ytd9tDhsmRAr85YVSM= X-Google-Smtp-Source: APXvYqxyrnQ8/kS5MhYl9Pju6PGe/RDw24mYAlgCcE3oG7oihndm6nhapTTq4vJrzGgDz35zbfYgzQ== X-Received: by 2002:a17:902:7289:: with SMTP id d9mr16260774pll.314.1553368203701; Sat, 23 Mar 2019 12:10:03 -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.10.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Mar 2019 12:10:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 23 Mar 2019 12:09:18 -0700 Message-Id: <20190323190925.21324-29-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::442 Subject: [Qemu-devel] [PATCH 28/35] target/xtensa: 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/xtensa/cpu.h | 17 ++++++----------- hw/xtensa/pic_cpu.c | 2 +- linux-user/xtensa/cpu_loop.c | 2 +- target/xtensa/dbg_helper.c | 4 ++-- target/xtensa/exc_helper.c | 9 ++++----- target/xtensa/helper.c | 2 +- target/xtensa/mmu_helper.c | 11 ++++------- target/xtensa/xtensa-semi.c | 2 +- 8 files changed, 20 insertions(+), 29 deletions(-) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index e6f57e0b64..d5465c2853 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -529,11 +529,6 @@ struct XtensaCPU { CPUXtensaState env; }; -static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env) -{ - return container_of(env, XtensaCPU, env); -} - #define ENV_OFFSET offsetof(XtensaCPU, env) @@ -712,10 +707,15 @@ static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch) #define XTENSA_CSBASE_LBEG_OFF_MASK 0x00ff0000 #define XTENSA_CSBASE_LBEG_OFF_SHIFT 16 +typedef CPUXtensaState CPUArchState; +typedef XtensaCPU ArchCPU; + +#include "exec/cpu-all.h" + static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *flags) { - CPUState *cs = CPU(xtensa_env_get_cpu(env)); + CPUState *cs = env_cpu(env); *pc = env->pc; *cs_base = 0; @@ -785,9 +785,4 @@ static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc, } } -typedef CPUXtensaState CPUArchState; -typedef XtensaCPU ArchCPU; - -#include "exec/cpu-all.h" - #endif diff --git a/hw/xtensa/pic_cpu.c b/hw/xtensa/pic_cpu.c index a8939f5e58..df3acbb541 100644 --- a/hw/xtensa/pic_cpu.c +++ b/hw/xtensa/pic_cpu.c @@ -33,7 +33,7 @@ void check_interrupts(CPUXtensaState *env) { - CPUState *cs = CPU(xtensa_env_get_cpu(env)); + CPUState *cs = env_cpu(env); int minlevel = xtensa_get_cintlevel(env); uint32_t int_set_enabled = env->sregs[INTSET] & env->sregs[INTENABLE]; int level; diff --git a/linux-user/xtensa/cpu_loop.c b/linux-user/xtensa/cpu_loop.c index bee78edb8a..64831c9199 100644 --- a/linux-user/xtensa/cpu_loop.c +++ b/linux-user/xtensa/cpu_loop.c @@ -123,7 +123,7 @@ static void xtensa_underflow12(CPUXtensaState *env) void cpu_loop(CPUXtensaState *env) { - CPUState *cs = CPU(xtensa_env_get_cpu(env)); + CPUState *cs = env_cpu(env); target_siginfo_t info; abi_ulong ret; int trapnr; diff --git a/target/xtensa/dbg_helper.c b/target/xtensa/dbg_helper.c index cd8fbd653a..be1f81107b 100644 --- a/target/xtensa/dbg_helper.c +++ b/target/xtensa/dbg_helper.c @@ -71,7 +71,7 @@ void HELPER(wsr_ibreaka)(CPUXtensaState *env, uint32_t i, uint32_t v) static void set_dbreak(CPUXtensaState *env, unsigned i, uint32_t dbreaka, uint32_t dbreakc) { - CPUState *cs = CPU(xtensa_env_get_cpu(env)); + CPUState *cs = env_cpu(env); int flags = BP_CPU | BP_STOP_BEFORE_ACCESS; uint32_t mask = dbreakc | ~DBREAKC_MASK; @@ -118,7 +118,7 @@ void HELPER(wsr_dbreakc)(CPUXtensaState *env, uint32_t i, uint32_t v) set_dbreak(env, i, env->sregs[DBREAKA + i], v); } else { if (env->cpu_watchpoint[i]) { - CPUState *cs = CPU(xtensa_env_get_cpu(env)); + CPUState *cs = env_cpu(env); cpu_watchpoint_remove_by_ref(cs, env->cpu_watchpoint[i]); env->cpu_watchpoint[i] = NULL; diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index 4a1f7aef5d..601341d13a 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -34,7 +34,7 @@ void HELPER(exception)(CPUXtensaState *env, uint32_t excp) { - CPUState *cs = CPU(xtensa_env_get_cpu(env)); + CPUState *cs = env_cpu(env); cs->exception_index = excp; if (excp == EXCP_YIELD) { @@ -100,7 +100,7 @@ void HELPER(debug_exception)(CPUXtensaState *env, uint32_t pc, uint32_t cause) void HELPER(waiti)(CPUXtensaState *env, uint32_t pc, uint32_t intlevel) { - CPUState *cpu; + CPUState *cpu = env_cpu(env); env->pc = pc; env->sregs[PS] = (env->sregs[PS] & ~PS_INTLEVEL) | @@ -111,11 +111,10 @@ void HELPER(waiti)(CPUXtensaState *env, uint32_t pc, uint32_t intlevel) qemu_mutex_unlock_iothread(); if (env->pending_irq_level) { - cpu_loop_exit(CPU(xtensa_env_get_cpu(env))); + cpu_loop_exit(cpu); return; } - cpu = CPU(xtensa_env_get_cpu(env)); cpu->halted = 1; HELPER(exception)(env, EXCP_HLT); } @@ -165,7 +164,7 @@ static void handle_interrupt(CPUXtensaState *env) (env->config->level_mask[level] & env->sregs[INTSET] & env->sregs[INTENABLE])) { - CPUState *cs = CPU(xtensa_env_get_cpu(env)); + CPUState *cs = env_cpu(env); if (level > 1) { env->sregs[EPC1 + level - 1] = env->pc; diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index f4867a9b56..51c8d992b9 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -315,7 +315,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, void xtensa_runstall(CPUXtensaState *env, bool runstall) { - CPUState *cpu = CPU(xtensa_env_get_cpu(env)); + CPUState *cpu = env_cpu(env); env->runstall = runstall; cpu->halted = runstall; diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c index 2096fbbd9f..97dfbe00ad 100644 --- a/target/xtensa/mmu_helper.c +++ b/target/xtensa/mmu_helper.c @@ -45,12 +45,10 @@ void HELPER(itlb_hit_test)(CPUXtensaState *env, uint32_t vaddr) void HELPER(wsr_rasid)(CPUXtensaState *env, uint32_t v) { - XtensaCPU *cpu = xtensa_env_get_cpu(env); - v = (v & 0xffffff00) | 0x1; if (v != env->sregs[RASID]) { env->sregs[RASID] = v; - tlb_flush(CPU(cpu)); + tlb_flush(env_cpu(env)); } } @@ -249,7 +247,7 @@ void HELPER(itlb)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) uint32_t wi; xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, &wi); if (entry->variable && entry->asid) { - tlb_flush_page(CPU(xtensa_env_get_cpu(env)), entry->vaddr); + tlb_flush_page(env_cpu(env), entry->vaddr); entry->asid = 0; } } @@ -295,8 +293,7 @@ void xtensa_tlb_set_entry_mmu(const CPUXtensaState *env, void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb, unsigned wi, unsigned ei, uint32_t vpn, uint32_t pte) { - XtensaCPU *cpu = xtensa_env_get_cpu(env); - CPUState *cs = CPU(cpu); + CPUState *cs = env_cpu(env); xtensa_tlb_entry *entry = xtensa_tlb_get_entry(env, dtlb, wi, ei); if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { @@ -651,7 +648,7 @@ static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb, static bool get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte) { - CPUState *cs = CPU(xtensa_env_get_cpu(env)); + CPUState *cs = env_cpu(env); uint32_t paddr; uint32_t page_size; unsigned access; diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c index 2f76216276..9cbf55db55 100644 --- a/target/xtensa/xtensa-semi.c +++ b/target/xtensa/xtensa-semi.c @@ -197,7 +197,7 @@ void xtensa_sim_open_console(Chardev *chr) void HELPER(simcall)(CPUXtensaState *env) { - CPUState *cs = CPU(xtensa_env_get_cpu(env)); + CPUState *cs = env_cpu(env); uint32_t *regs = env->regs; switch (regs[2]) {