From patchwork Thu Mar 21 15:48:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1914518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=H1qzqjlx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0ql15RX7z23r9 for ; Fri, 22 Mar 2024 02:54:05 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKhd-0001vs-6G; Thu, 21 Mar 2024 11:51:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnKgy-000164-PG for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:58 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rnKgt-00028y-4A for qemu-ppc@nongnu.org; Thu, 21 Mar 2024 11:50:54 -0400 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-56bcede226eso849420a12.1 for ; Thu, 21 Mar 2024 08:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711036249; x=1711641049; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HBTm7fX0XnajgMEHRoXg20PUgOsEK5tp5uuFAd0ZnLA=; b=H1qzqjlxkFgeWoyQSFcTFl3TEpIWfvk9T4J1EQEwiTf0GuSzHlYQtWdNpZW40t9ZEo I6Oi62JeJe+extwbnPA2gvgFiPUsaOiE/2HoiqIU5AL1msL6rFuT9q1xHm9qd22hlmwH E0X80XzKOGgxRx2tJ5hwxLe4OxkgYdwvXcNngYX4jET7zCBKeQO0Pw/JgJr9MpVGikxk Rsw6blJCj5VxuOsN3EB6hjCEoyDcgnR+0Xmc8KUcgiKtduXfZ8eFzVlgf0/kUyrg4CjC rYEgs/tjkJvJ3xUR56XSestV8IVGeKCeWzvOMmZb4q04h9edFUD3fgr3ShkNdWbcKdDC yKrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036249; x=1711641049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HBTm7fX0XnajgMEHRoXg20PUgOsEK5tp5uuFAd0ZnLA=; b=ZjSbmz4E6jtGlmQF0SSmJSmQSCWKtgmsqLcVnlvTzt4dot7ENNO+heY7JbnzFcNIMO iZOxUpgGJgqJoHZyT1kzFsq4zj4XcLp4qWkeo1f9MCWXCj+8obDbnJXxtIaRKh5fNwzn G7DyWHtwqc4DxF3d/4y1I+j/55ntA3NSCZy4nGITm7p/cFi3ys06dqmZpdtdTDlAkvnJ 6fF2QH7EU5ebHe998Fahd0DYiQzaLCBSo7H7zMVERdfEZcQOPOU/M/iAQoPB1JxhTQJW ZZppgB6RFCSpcUOD3jZ4Pk+hifPSfejk1k0ZuK62TMlPcgk8tK1hDfssg0zbtXqRD5gE u9vQ== X-Forwarded-Encrypted: i=1; AJvYcCXtu9j2bnwmtuuR1xfw0eWlrptFGgMt/ViMZiQlCwrCHvdLD8otasaS4rZ4g8lVLSZxr0vYycW5u/25uW/+9iO7P2b5 X-Gm-Message-State: AOJu0YytMO0qYYNBkSWIFrceqIgEeiqESlSLGrNwE/WF+aEdfxuIS4zZ 3DXxdB0pCZcqwRM4qpSVFxKr+nDXghhJZ/wwmO/Hcfzq8NioJTUPz4YB8R9f54o= X-Google-Smtp-Source: AGHT+IG0y8L0mGnPrFKMTIUU0M1hBiRNav6XsB7ffIMx0E+AmGpLpKoEjlnLiJMwx0BhB6oYf9DiRg== X-Received: by 2002:a05:6402:159a:b0:568:9fc9:ec72 with SMTP id ij26-20020a056402159a00b005689fc9ec72mr3999872edb.35.1711036249579; Thu, 21 Mar 2024 08:50:49 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.222]) by smtp.gmail.com with ESMTPSA id l9-20020a056402028900b00568d4cf3288sm17978edv.7.2024.03.21.08.50.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Mar 2024 08:50:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Artyom Tarasenko , Chris Wulff , "Edgar E. Iglesias" , Marek Vasut , Max Filippov , "Dr . David Alan Gilbert" , Jiaxun Yang , Nicholas Piggin , Paolo Bonzini , Daniel Henrique Barboza , Yoshinori Sato , Markus Armbruster , Richard Henderson , qemu-ppc@nongnu.org, Laurent Vivier , Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH-for-9.1 17/21] target/xtensa: Prefix MMU API with 'xtensa_' Date: Thu, 21 Mar 2024 16:48:33 +0100 Message-ID: <20240321154838.95771-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240321154838.95771-1-philmd@linaro.org> References: <20240321154838.95771-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=philmd@linaro.org; helo=mail-ed1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-ppc@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org In order to extract the MMU API to a new "mmu.h" header, prefix it with the target name. Signed-off-by: Philippe Mathieu-Daudé --- target/xtensa/cpu.h | 4 ++-- target/xtensa/cpu.c | 2 +- target/xtensa/mmu_helper.c | 41 +++++++++++++++++++++----------------- target/xtensa/monitor.c | 2 +- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 6b8d0636d2..b2cfc78e9d 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -692,8 +692,8 @@ static inline int xtensa_get_cring(const CPUXtensaState *env) int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, uint32_t vaddr, int is_write, int mmu_idx, uint32_t *paddr, uint32_t *page_size, unsigned *access); -void reset_mmu(CPUXtensaState *env); -void dump_mmu(CPUXtensaState *env); +void xtensa_reset_mmu(CPUXtensaState *env); +void xtensa_dump_mmu(CPUXtensaState *env); static inline MemoryRegion *xtensa_get_er_region(CPUXtensaState *env) { diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 875cf843c9..ae0c4aab24 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -130,7 +130,7 @@ static void xtensa_cpu_reset_hold(Object *obj) env->exclusive_addr = -1; #ifndef CONFIG_USER_ONLY - reset_mmu(env); + xtensa_reset_mmu(env); cs->halted = env->runstall; #endif set_no_signaling_nans(!dfpu, &env->fp_status); diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c index 47063b0a57..31ee3fa957 100644 --- a/target/xtensa/mmu_helper.c +++ b/target/xtensa/mmu_helper.c @@ -139,7 +139,8 @@ static uint32_t xtensa_tlb_get_addr_mask(const CPUXtensaState *env, * Get bit mask for the 'VPN without index' field. * See ISA, 4.6.5.6, data format for RxTLB0 */ -static uint32_t get_vpn_mask(const CPUXtensaState *env, bool dtlb, uint32_t way) +static uint32_t xtensa_get_vpn_mask(const CPUXtensaState *env, bool dtlb, + uint32_t way) { if (way < 4) { bool is32 = (dtlb ? @@ -168,9 +169,10 @@ static uint32_t get_vpn_mask(const CPUXtensaState *env, bool dtlb, uint32_t way) * Split virtual address into VPN (with index) and entry index * for the given TLB way */ -static void split_tlb_entry_spec_way(const CPUXtensaState *env, uint32_t v, - bool dtlb, uint32_t *vpn, - uint32_t wi, uint32_t *ei) +static void xtensa_split_tlb_entry_spec_way(const CPUXtensaState *env, + uint32_t v, + bool dtlb, uint32_t *vpn, + uint32_t wi, uint32_t *ei) { bool varway56 = dtlb ? env->config->dtlb.varway56 : @@ -224,13 +226,15 @@ static void split_tlb_entry_spec_way(const CPUXtensaState *env, uint32_t v, * Split TLB address into TLB way, entry index and VPN (with index). * See ISA, 4.6.5.5 - 4.6.5.8 for the TLB addressing format */ -static bool split_tlb_entry_spec(CPUXtensaState *env, uint32_t v, bool dtlb, - uint32_t *vpn, uint32_t *wi, uint32_t *ei) +static bool xtensa_split_tlb_entry_spec(CPUXtensaState *env, + uint32_t v, bool dtlb, + uint32_t *vpn, uint32_t *wi, + uint32_t *ei) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { *wi = v & (dtlb ? 0xf : 0x7); if (*wi < (dtlb ? env->config->dtlb.nways : env->config->itlb.nways)) { - split_tlb_entry_spec_way(env, v, dtlb, vpn, *wi, ei); + xtensa_split_tlb_entry_spec_way(env, v, dtlb, vpn, *wi, ei); return true; } else { return false; @@ -254,14 +258,14 @@ static xtensa_tlb_entry *xtensa_tlb_get_entry(CPUXtensaState *env, bool dtlb, env->itlb[wi] + ei; } -static xtensa_tlb_entry *get_tlb_entry(CPUXtensaState *env, +static xtensa_tlb_entry *xtensa_get_tlb_entry(CPUXtensaState *env, uint32_t v, bool dtlb, uint32_t *pwi) { uint32_t vpn; uint32_t wi; uint32_t ei; - if (split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { + if (xtensa_split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { if (pwi) { *pwi = wi; } @@ -405,7 +409,7 @@ static void reset_tlb_region_way0(CPUXtensaState *env, } } -void reset_mmu(CPUXtensaState *env) +void xtensa_reset_mmu(CPUXtensaState *env) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { env->sregs[RASID] = 0x04030201; @@ -470,7 +474,7 @@ static int xtensa_tlb_lookup(const CPUXtensaState *env, for (wi = 0; wi < tlb->nways; ++wi) { uint32_t vpn; uint32_t ei; - split_tlb_entry_spec_way(env, addr, dtlb, &vpn, wi, &ei); + xtensa_split_tlb_entry_spec_way(env, addr, dtlb, &vpn, wi, &ei); if (entry[wi][ei].vaddr == vpn && entry[wi][ei].asid) { unsigned ring = get_ring(env, entry[wi][ei].asid); if (ring < 4) { @@ -493,10 +497,11 @@ uint32_t HELPER(rtlb0)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { uint32_t wi; - const xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, &wi); + const xtensa_tlb_entry *entry = xtensa_get_tlb_entry(env, v, dtlb, &wi); if (entry) { - return (entry->vaddr & get_vpn_mask(env, dtlb, wi)) | entry->asid; + return (entry->vaddr & xtensa_get_vpn_mask(env, dtlb, wi)) + | entry->asid; } else { return 0; } @@ -507,7 +512,7 @@ uint32_t HELPER(rtlb0)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) uint32_t HELPER(rtlb1)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) { - const xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, NULL); + const xtensa_tlb_entry *entry = xtensa_get_tlb_entry(env, v, dtlb, NULL); if (entry) { return entry->paddr | entry->attr; @@ -520,7 +525,7 @@ void HELPER(itlb)(CPUXtensaState *env, uint32_t v, uint32_t dtlb) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { uint32_t wi; - xtensa_tlb_entry *entry = get_tlb_entry(env, v, dtlb, &wi); + xtensa_tlb_entry *entry = xtensa_get_tlb_entry(env, v, dtlb, &wi); if (entry && entry->variable && entry->asid) { tlb_flush_page(env_cpu(env), entry->vaddr); entry->asid = 0; @@ -559,7 +564,7 @@ void HELPER(wtlb)(CPUXtensaState *env, uint32_t p, uint32_t v, uint32_t dtlb) uint32_t vpn; uint32_t wi; uint32_t ei; - if (split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { + if (xtensa_split_tlb_entry_spec(env, v, dtlb, &vpn, &wi, &ei)) { xtensa_tlb_set_entry(env, dtlb, wi, ei, vpn, p); } } @@ -818,7 +823,7 @@ static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb, may_lookup_pt && get_pte(env, vaddr, &pte)) { ring = (pte >> 4) & 0x3; wi = 0; - split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei); + xtensa_split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei); if (update_tlb) { wi = ++env->autorefill_idx & 0x3; @@ -1192,7 +1197,7 @@ static void dump_mpu(CPUXtensaState *env, } } -void dump_mmu(CPUXtensaState *env) +void xtensa_dump_mmu(CPUXtensaState *env) { if (xtensa_option_bits_enabled(env->config, XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c index fbf60d5553..ce1b791a5c 100644 --- a/target/xtensa/monitor.c +++ b/target/xtensa/monitor.c @@ -35,5 +35,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu(env1); + xtensa_dump_mmu(env1); }