From patchwork Fri May 5 01:02:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 679287 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp92845wrs; Thu, 4 May 2023 18:17:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55LNKEJVPvgodi5gGU5ilKAs/dB+gfdKCOFteHPS4FmnH8rpV8APVhVVQxOd+8GBEavFcm X-Received: by 2002:ac8:4e86:0:b0:3e8:b9a0:babf with SMTP id 6-20020ac84e86000000b003e8b9a0babfmr300930qtp.12.1683249423723; Thu, 04 May 2023 18:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683249423; cv=none; d=google.com; s=arc-20160816; b=XAFj1pywd7zB8yxqXt3/YV2KUW4EYI50yM/kGDpIk1Atjb/YCni5HaW0xNOCWbIfEx VDrZKVl1/GjzaKg9emCuvGdwi+++tVw7JJVHgSFGdJRmXzbpdq8VzQusiKwT2Kyv9kM2 MCv+qOHg3X99DYbIdJs1rPfgQdEdfb4YN0xW2gx1L1s/kZaOLRvZN6XsVGV+THTAnrbc 7qR+AarcpBNZZN4YxN5ad4D+2zLwiasWL48Xf8hIRkEifnlvnlCkqHMXfI1cGek1Eas4 VaOjXdCLME/A5ro3FVhOryIhMm43rBblB9kGvp2SQ1kIeQ9dJLqm8BG49vzOo8WSy7un 7U1A== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wi+1v00zCXgIbo5ZQUE7RzeAN6+AZmd0gp2h5NJhB9o=; b=N0GqX/CnCOuhZFD8YF8z2xOgtan9ghqyq7+JlC+b8DQ2ybgNDgw67Mv5Tthnu6Smp2 mMKhFrxDY2YdVIdmMIj6fwmUqHQo/Sga3FoysS1HusVlNE3OIQ2ZucWKlUwZEcTXZbK8 u9Omw/UJZGg/xJHS+FlveRBGMzbkoprH6GqUkrsyqL9p77yv2dUhfd3Z2NqU9LM5oaLy 683zYZDY5BZLF1SENDng9uiEk+j+GXPEyPoBDH3Zcyk/Ya+tTCS6i3qT4W5XEhc70p/k CfUeAVxSr5noMR+N4UxfQ+7LB7oKhkrKQu6ByxUwSzRPJOKk4NBwTr/Gf+ywJwkNpALY JwgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Oeo5StD3; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h2-20020a37de02000000b0075168fbfd39si228031qkj.722.2023.05.04.18.17.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 May 2023 18:17:03 -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=@gmail.com header.s=20221208 header.b=Oeo5StD3; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pujvH-0000kl-Bk; Thu, 04 May 2023 21:07:47 -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 1pujus-000086-QE for qemu-devel@nongnu.org; Thu, 04 May 2023 21:07:22 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pujuq-0007yv-S6 for qemu-devel@nongnu.org; Thu, 04 May 2023 21:07:22 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1aaff9c93a5so8151745ad.2 for ; Thu, 04 May 2023 18:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683248839; x=1685840839; 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=Wi+1v00zCXgIbo5ZQUE7RzeAN6+AZmd0gp2h5NJhB9o=; b=Oeo5StD34xN8QRsGMRQCMS+5usi756D1yRQU/u11Tf+NjGCCQRbK7dcO3+kVKoLXSM ylTjGQjAS4VsgG5ntObAEjYMB2Kz8v9u4v/gt2S5KH+sTyTa+6qkmjHrCh+gI8EQHvdN p5Tfok9aWp+PSi7W5uMWvFRhcB/tTv08ZglacewbV9fxdst4BAJQFdsQ2AI8pa2iKjHE vm7zhl4VC5kbIxGeFy6BUB45M5dSR2ssww9YK27dRIrDq72HCuLNQRLqghw5duoQvIMZ 3LpqerrqK4nPM9W0tGEbmgFVa3+mkFIt5dFyLcJ61mDrTPt8E6tGHjBx0avAlZPTz1pU THNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683248839; x=1685840839; 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=Wi+1v00zCXgIbo5ZQUE7RzeAN6+AZmd0gp2h5NJhB9o=; b=L4oCb0fLbwU4d+FQEi8KFZT6axRy3Srh2AKwWep5Wx5rc7m4Hgb1t2YnNksLZ+Vnb+ cAwLlxfMjnycsZNP1SzGUdHRMThBnxHajXMS1TBvylihnf/tMBMNhuBEqbs3k0aLKDDA 6JwqkCPwpSZ1bPXH2UA3+XnNnJLUbOrTyD4SPRHDdTF6qK/e9N1I6v7GYfCrBSQXg8KM Ihj5ruAywJLfxiyY1i2Eop8pEQRwmbGUhPH5ylY9qrCP/hnD2XAmR4f2ld1lVQYo24e3 SEqHXVAkV7g3BK71tp58beCyppX/SzrIGYINTbGSuWFGlGTYRJHMoJufLvdffRda6Sbd hC1w== X-Gm-Message-State: AC+VfDx9L0LwfTRNJvq74KKRg2G5zO0iZxY1PHExMnnW7PKZZndW9pP2 nWrV+3s3mm+AoZ5Ko9Y1Z8AB39oZhahlBg== X-Received: by 2002:a17:902:eccf:b0:1a6:f93a:a135 with SMTP id a15-20020a170902eccf00b001a6f93aa135mr6791826plh.61.1683248839389; Thu, 04 May 2023 18:07:19 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id l19-20020a170902d35300b0019309be03e7sm218762plk.66.2023.05.04.18.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 18:07:18 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , Weiwei Li , Daniel Henrique Barboza Subject: [PULL 70/89] target/riscv: Introduce mmuidx_2stage Date: Fri, 5 May 2023 11:02:22 +1000 Message-Id: <20230505010241.21812-71-alistair.francis@wdc.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230505010241.21812-1-alistair.francis@wdc.com> References: <20230505010241.21812-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=alistair23@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Move and rename riscv_cpu_two_stage_lookup, to match the other mmuidx_* functions. Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li Tested-by: Daniel Henrique Barboza Message-Id: <20230325105429.1142530-15-richard.henderson@linaro.org> Message-Id: <20230412114333.118895-15-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 1 - target/riscv/internals.h | 5 +++++ target/riscv/cpu_helper.c | 20 ++++++-------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 35cf2e2691..d1f888a790 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -581,7 +581,6 @@ target_ulong riscv_cpu_get_geilen(CPURISCVState *env); void riscv_cpu_set_geilen(CPURISCVState *env, target_ulong geilen); bool riscv_cpu_vector_enabled(CPURISCVState *env); void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable); -bool riscv_cpu_two_stage_lookup(int mmu_idx); int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch); G_NORETURN void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, diff --git a/target/riscv/internals.h b/target/riscv/internals.h index 4aa1cb409f..b5f823c7ec 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -51,6 +51,11 @@ static inline bool mmuidx_sum(int mmu_idx) return (mmu_idx & 3) == MMUIdx_S_SUM; } +static inline bool mmuidx_2stage(int mmu_idx) +{ + return mmu_idx & MMU_2STAGE_BIT; +} + /* share data between vector helpers and decode code */ FIELD(VDATA, VM, 0, 1) FIELD(VDATA, LMUL, 1, 3) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 57bb19c76e..9dfd1d739b 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -591,11 +591,6 @@ void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable) } } -bool riscv_cpu_two_stage_lookup(int mmu_idx) -{ - return mmu_idx & MMU_2STAGE_BIT; -} - int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint64_t interrupts) { CPURISCVState *env = &cpu->env; @@ -779,7 +774,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, * MPRV does not affect the virtual-machine load/store * instructions, HLV, HLVX, and HSV. */ - if (riscv_cpu_two_stage_lookup(mmu_idx)) { + if (mmuidx_2stage(mmu_idx)) { mode = get_field(env->hstatus, HSTATUS_SPVP); } @@ -1175,8 +1170,7 @@ void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, } env->badaddr = addr; - env->two_stage_lookup = env->virt_enabled || - riscv_cpu_two_stage_lookup(mmu_idx); + env->two_stage_lookup = env->virt_enabled || mmuidx_2stage(mmu_idx); env->two_stage_indirect_lookup = false; cpu_loop_exit_restore(cs, retaddr); } @@ -1201,8 +1195,7 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, g_assert_not_reached(); } env->badaddr = addr; - env->two_stage_lookup = env->virt_enabled || - riscv_cpu_two_stage_lookup(mmu_idx); + env->two_stage_lookup = env->virt_enabled || mmuidx_2stage(mmu_idx); env->two_stage_indirect_lookup = false; cpu_loop_exit_restore(cs, retaddr); } @@ -1256,7 +1249,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, * MPRV does not affect the virtual-machine load/store * instructions, HLV, HLVX, and HSV. */ - if (riscv_cpu_two_stage_lookup(mmu_idx)) { + if (mmuidx_2stage(mmu_idx)) { mode = get_field(env->hstatus, HSTATUS_SPVP); } else if (mode == PRV_M && access_type != MMU_INST_FETCH && get_field(env->mstatus, MSTATUS_MPRV)) { @@ -1268,7 +1261,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, pmu_tlb_fill_incr_ctr(cpu, access_type); if (env->virt_enabled || - ((riscv_cpu_two_stage_lookup(mmu_idx) || two_stage_lookup) && + ((mmuidx_2stage(mmu_idx) || two_stage_lookup) && access_type != MMU_INST_FETCH)) { /* Two stage lookup */ ret = get_physical_address(env, &pa, &prot, address, @@ -1366,8 +1359,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } else { raise_mmu_exception(env, address, access_type, pmp_violation, first_stage_error, - env->virt_enabled || - riscv_cpu_two_stage_lookup(mmu_idx), + env->virt_enabled || mmuidx_2stage(mmu_idx), two_stage_indirect_error); cpu_loop_exit_restore(cs, retaddr); }