From patchwork Fri Apr 22 16:51:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564874 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp684058map; Fri, 22 Apr 2022 10:29:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmT9MX6Dgg5M44n8r9Y4Mh+xZIyQQ5kE61sADKBJu7Ts5R23EPm1un8PGRMmJNK+zy1y7X X-Received: by 2002:a0d:f587:0:b0:2f1:b1ca:287e with SMTP id e129-20020a0df587000000b002f1b1ca287emr6222036ywf.60.1650648551164; Fri, 22 Apr 2022 10:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650648551; cv=none; d=google.com; s=arc-20160816; b=xmlzcJELpBjkzoZiPVp2V4WNCrSG6uqsNtJ75pICESSPpsQGxmPqDeS8oX1hH03Wd7 wiTLt+hrpIJNy98u4ZzdAkkgtUF0sYuSPe12zkIE2jmnxry7iZj9YC8IZbFOjrLTehEd 9pqkRaqfzpWk0BOzXddWYoSDWnlAZ7A2pBrdgD/Ca5GLMYE3FT0knmW6uBHXsb+pUV+V WqFhgMIyzIaHbNjy8vP43Mdkl0q0lAtmPzjoKmkEtPIJCa8W6zQYM/sg1wDvd08nhdhp w/ZdLJW/1MPta+0hqzQw/kkFx8OlcDAqO09cO29YroJHlnTfiztOENj6xRS8kJroxuED UZ4Q== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=C/u00nAmgF45yxO3zIMu5WmncM8sGR/FNykbnvTKhkM=; b=KhddQRxZubbJkeFGeYsCSGNnPPT9jQI8JfhfpEw7bfs7EjZNE0jfgqis57pVnXduLx B1WMfy3ckotqf6pyz6PwigLpji9W5uP9o5GK6Es4lUt2suGLDmN8GwAE6hL7ydHE/aeX IkXMN2CiUmfDYPmZUHDkDpj76nvIOfkQJiboOdo/OX6lS8Sy8OgCmTfqZuvhJimHZANe 5yaCrj6sD/LBY4Fjt0MX0edswLN8PRLe0RSSL+CHA3pWsn3xn3SXpmrgOKPPCNWo+W1g cwYx5Bitj5Uwv9TyHqrmqGqQhRggBtIkNfbeWoHLmKNu8ggWuAuL+3TqEnrhxYDQ2lOD i4+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s+NLTO0z; 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=pass (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 c84-20020a25c057000000b0064163aab08bsi5560130ybf.560.2022.04.22.10.29.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Apr 2022 10:29:11 -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=pass header.i=@linaro.org header.s=google header.b=s+NLTO0z; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhx5i-0005dy-HG for patch@linaro.org; Fri, 22 Apr 2022 13:29:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhwXC-0001Mh-MB for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:53:30 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:37395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhwXA-0007Jp-RR for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:53:30 -0400 Received: by mail-pl1-x633.google.com with SMTP id u15so8713483ple.4 for ; Fri, 22 Apr 2022 09:53:28 -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 :mime-version:content-transfer-encoding; bh=C/u00nAmgF45yxO3zIMu5WmncM8sGR/FNykbnvTKhkM=; b=s+NLTO0zYZXe5D2boxvu/IU/QOOpFtwQqg+8KONyh0g8aF0pYarujYD8POpLZJafVS 8FqsM5UOzVJvw4HQyei5KW/HbnnNOrjiLxxMaUaYhFbrC1DStPXIAjMkgogvklnSQk6v gEyMnAi+mQYh8IDyrNJche4sTXcY5Jslc14HuhnTm+fgoqRckIADmAVUTB7ojhvzq1C+ PziOxk1nMQP/4pE6ol4Oz7AXT3g8YdTOAyE2CGe/S5i9kUYAUxhL+SSP6p2a8nGKXQZ0 LcgNY/5IFgrtCScSPZJW+2rc1DM1i0VYyACBOu3vnokWXfVP1KtePw58YQKXSFulw8S9 LnpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C/u00nAmgF45yxO3zIMu5WmncM8sGR/FNykbnvTKhkM=; b=mP0d0cNV2mJ6chtbgI5H6J1POJELq2JUgsD3aKWvQiZC5PlP8mzhN+oikVbxe/q41E nklqHThV+rCtTw9KlptHWs4+YfTLNtoFBDapCYFc8RjLqul6u9IKW0Au5kCursK/el7F uJjtMNYoIK1q3iTtltLZ8qQQPYZenFZOf8ogfSeQwu0ouT8RDNBmtAePt/QOab54kUiQ ZZ00y0IY4c5IIXnWT9lkYjI8QWqmkrgCs+UeqH1c3dTVTO8csuHF5iQM1w1alQpTc/rm McYyboHHM3OMaf1lLEBMfnzKJUPC80oeQDqo0ZmZdP47J6+mGuEpPztnfTxv2nKCg/DZ NUhg== X-Gm-Message-State: AOAM533vI5J3ufP3kkoZIU2PZQheq281RMootNfoX6KjVsj/2kQosouH ubAdvh+9Ya45JYrj/czilvs5hhNGNxRBHVdk X-Received: by 2002:a17:902:c2c7:b0:159:9f9:85f3 with SMTP id c7-20020a170902c2c700b0015909f985f3mr5229826pla.18.1650646407518; Fri, 22 Apr 2022 09:53:27 -0700 (PDT) Received: from stoup.. ([2607:fb90:27d0:b0f2:934d:3e2:9f8c:dd1]) by smtp.gmail.com with ESMTPSA id 6-20020a17090a030600b001cd4989ff5fsm6835904pje.38.2022.04.22.09.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:53:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v8 26/68] target/nios2: Use hw/registerfields.h for CR_TLBADDR fields Date: Fri, 22 Apr 2022 09:51:56 -0700 Message-Id: <20220422165238.1971496-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220422165238.1971496-1-richard.henderson@linaro.org> References: <20220422165238.1971496-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use FIELD_EX32 and FIELD_DP32 instead of manual manipulation of the fields. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20220421151735.31996-27-richard.henderson@linaro.org> --- target/nios2/cpu.h | 8 ++++---- target/nios2/helper.c | 4 ++-- target/nios2/mmu.c | 17 +++++++++-------- target/nios2/translate.c | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index f8cd5dc218..a6811ff7ea 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -110,10 +110,10 @@ FIELD(CR_EXCEPTION, CAUSE, 2, 5) FIELD(CR_EXCEPTION, ECCFTL, 31, 1) #define CR_PTEADDR 8 -#define CR_PTEADDR_PTBASE_SHIFT 22 -#define CR_PTEADDR_PTBASE_MASK (0x3FF << CR_PTEADDR_PTBASE_SHIFT) -#define CR_PTEADDR_VPN_SHIFT 2 -#define CR_PTEADDR_VPN_MASK (0xFFFFF << CR_PTEADDR_VPN_SHIFT) + +FIELD(CR_PTEADDR, VPN, 2, 20) +FIELD(CR_PTEADDR, PTBASE, 22, 10) + #define CR_TLBACC 9 #define CR_TLBACC_IGN_SHIFT 25 #define CR_TLBACC_IGN_MASK (0x7F << CR_TLBACC_IGN_SHIFT) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index b30740824c..c2d0afe1b6 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -286,8 +286,8 @@ bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } else { env->ctrl[CR_TLBMISC] |= CR_TLBMISC_D; } - env->ctrl[CR_PTEADDR] &= CR_PTEADDR_PTBASE_MASK; - env->ctrl[CR_PTEADDR] |= (address >> 10) & CR_PTEADDR_VPN_MASK; + env->ctrl[CR_PTEADDR] = FIELD_DP32(env->ctrl[CR_PTEADDR], CR_PTEADDR, VPN, + address >> TARGET_PAGE_BITS); env->mmu.pteaddr_wr = env->ctrl[CR_PTEADDR]; cs->exception_index = excp; diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index 95900724e8..75afc56daf 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -97,7 +97,7 @@ void helper_mmu_write_tlbacc(CPUNios2State *env, uint32_t v) /* if tlbmisc.WE == 1 then trigger a TLB write on writes to TLBACC */ if (env->ctrl[CR_TLBMISC] & CR_TLBMISC_WR) { int way = (env->ctrl[CR_TLBMISC] >> CR_TLBMISC_WAY_SHIFT); - int vpn = (env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK) >> 2; + int vpn = FIELD_EX32(env->mmu.pteaddr_wr, CR_PTEADDR, VPN); int pid = (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4; int g = (v & CR_TLBACC_G) ? 1 : 0; int valid = ((vpn & CR_TLBACC_PFN_MASK) < 0xC0000) ? 1 : 0; @@ -148,7 +148,7 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) /* if tlbmisc.RD == 1 then trigger a TLB read on writes to TLBMISC */ if (v & CR_TLBMISC_RD) { int way = (v >> CR_TLBMISC_WAY_SHIFT); - int vpn = (env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK) >> 2; + int vpn = FIELD_EX32(env->mmu.pteaddr_wr, CR_PTEADDR, VPN); Nios2TLBEntry *entry = &env->mmu.tlb[(way * cpu->tlb_num_ways) + (vpn & env->mmu.tlb_entry_mask)]; @@ -160,8 +160,9 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) (v & ~CR_TLBMISC_PID_MASK) | ((entry->tag & ((1 << cpu->pid_num_bits) - 1)) << CR_TLBMISC_PID_SHIFT); - env->ctrl[CR_PTEADDR] &= ~CR_PTEADDR_VPN_MASK; - env->ctrl[CR_PTEADDR] |= (entry->tag >> 12) << CR_PTEADDR_VPN_SHIFT; + env->ctrl[CR_PTEADDR] = FIELD_DP32(env->ctrl[CR_PTEADDR], + CR_PTEADDR, VPN, + entry->tag >> TARGET_PAGE_BITS); } else { env->ctrl[CR_TLBMISC] = v; } @@ -171,12 +172,12 @@ void helper_mmu_write_tlbmisc(CPUNios2State *env, uint32_t v) void helper_mmu_write_pteaddr(CPUNios2State *env, uint32_t v) { - trace_nios2_mmu_write_pteaddr(v >> CR_PTEADDR_PTBASE_SHIFT, - (v & CR_PTEADDR_VPN_MASK) >> CR_PTEADDR_VPN_SHIFT); + trace_nios2_mmu_write_pteaddr(FIELD_EX32(v, CR_PTEADDR, PTBASE), + FIELD_EX32(v, CR_PTEADDR, VPN)); /* Writes to PTEADDR don't change the read-back VPN value */ - env->ctrl[CR_PTEADDR] = ((v & ~CR_PTEADDR_VPN_MASK) | - (env->ctrl[CR_PTEADDR] & CR_PTEADDR_VPN_MASK)); + env->ctrl[CR_PTEADDR] = ((v & ~R_CR_PTEADDR_VPN_MASK) | + (env->ctrl[CR_PTEADDR] & R_CR_PTEADDR_VPN_MASK)); env->mmu.pteaddr_wr = v; } diff --git a/target/nios2/translate.c b/target/nios2/translate.c index fc49a7101f..baa22c5101 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -924,7 +924,7 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) } } qemu_fprintf(f, " mmu write: VPN=%05X PID %02X TLBACC %08X\n", - env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK, + env->mmu.pteaddr_wr & R_CR_PTEADDR_VPN_MASK, (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4, env->mmu.tlbacc_wr); #endif