From patchwork Fri May 5 01:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 679289 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp93047wrs; Thu, 4 May 2023 18:17:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zFRm0fi2RouyGHdYFvT7g/0tT9ZP+dWQUO9VrUOW93dyUWbNoJvjfK2lXL8r8ouq2Lpfz X-Received: by 2002:a05:6214:c47:b0:616:58f1:2844 with SMTP id r7-20020a0562140c4700b0061658f12844mr18654927qvj.45.1683249466979; Thu, 04 May 2023 18:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683249466; cv=none; d=google.com; s=arc-20160816; b=lhAHH0jKy+ZQ/A9WrbiKKxGYMWOAlatD538q3gRkemm1XlLM8+a4xEkuzlhorcwUb+ NDUDuKLMO3vKbt7tqkLWkGVDKZv7EltNfdD2HTou+05pC+iyDR20NX6+SnK+kCqDPMA7 SMftvTAdTd8AxJDtv0tY/wg/kKpED8vtavb2kff06jPuZnC0f7ukJj2mOVCv05pht8o/ KbZmNpAlKaBFKpSRHEf8odzeAxXT3MZVtjp/yRIOWG0TBOnmknVQ1z3PUwGsxSqieyyL 1HBk5MECQB9KcG/zBFVow7UX43s6CXz43NDSrgrDh14MPH5uvbtk5PFeO7SxXYuy5d9D HWQg== 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=hnAT6rPeWHhnyQGQh4TsIFOiMxMNe6JrOBOWyeNI6yQ=; b=nEalAkukMuXvz6DKZc9CwDcclOQxBUh6jNlnENklY1PwPOR2Lx8NAyJ1XFNxO4XcdR zss9RtnFMPYdyT2m4OdE65qwKiZNrRbJjNS6TZtXWV8+MywuvR6KT9cvtzoMONORTr0+ iYcWH0p2bDv+GoMV3pj6HIw5xksBgcVooHQJKViK6e5C/2zRfuW18JeNe0O3JcAB1Ztv tYo2keCftUALCubroFNApatMZVObVbnSyV7sDTnX5c0zKQiOmkFlyoSUzI010L5xCojT cqK1ceQl3fuZR9DEUzex2BDUGJAd/gBPvcArIeed7bPgA1MCt7voSJKUyEfWxHPOMbYK tG6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=WBSIhKit; 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 b26-20020a05620a119a00b0074e034b6ee5si252392qkk.238.2023.05.04.18.17.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 May 2023 18:17:46 -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=WBSIhKit; 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 1pujus-0008Qc-6L; Thu, 04 May 2023 21:07:22 -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 1pujul-0008NJ-Pg for qemu-devel@nongnu.org; Thu, 04 May 2023 21:07:17 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pujuk-0007xo-6e for qemu-devel@nongnu.org; Thu, 04 May 2023 21:07:15 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-517bfdf55c3so565171a12.2 for ; Thu, 04 May 2023 18:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683248832; x=1685840832; 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=hnAT6rPeWHhnyQGQh4TsIFOiMxMNe6JrOBOWyeNI6yQ=; b=WBSIhKitK//PtL8Phzk+EE/bAf93oTHQPuBwkZRwmr8E4oLTuPN+iIEXHFP3qaIQLF kwXdAnccbuDRalyQyBSnCivqMc+me+rClhUEH4WSslN7EPcVcVDmGCV3FzbTgZquOA8+ GLpZVMHoTqJJFwVP9xSZrtGeeqHAk9WMVE0ixf22Cm9AES3ZYLEHYXMUxvLWl2ldv7gb SKq1gRiv0Fv5BE0rjuTTcofv+S+R6d01keHSbEP6kZPDqPieTJGYyO3n0NOfwgDVwDfj TWD+hzqFik+EQFt6vtb8h3th7xiq/UVkoW4ifr5GVXkEf6faJuOzTmPdDX5iI+WSPMHS ZPiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683248832; x=1685840832; 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=hnAT6rPeWHhnyQGQh4TsIFOiMxMNe6JrOBOWyeNI6yQ=; b=H0Ymyrr505E+oz16SmNJ4TlAaymmpO3FOJrB3yasiTJy9a4Jn2oHVtYejiyyCY+NLj GT0tdwmQ31RbSUWvH2ZgphNdAxCW2pEuvTlnFGxN3OqEyupYcg4ZElZ5CG5U4b3UgeyT PxcOswLW/NKtiMDWqNZ2VP374Xp8qKGYiSzafokFGzdh/22kLLh0SRpgaSOoq6plW98l gCpLvFIrTzK70B0XOFT10yEgu75xTQT7rMLyRfrGU/4CTppevRZUusQlCAAoQZWuPmst 4rcKzNLlFbxCGGeGkwVNL14gxHkXvxsHrcOjp19vzGHkDaiCloSFiVXSC/nW4aTbymGP MZNw== X-Gm-Message-State: AC+VfDybuuFk/YVimIFA7iPjsk3n9u2jHUuS18RrR8AF3lyeHpFp/K0P qEVac8bSzBZcOnvl5UOfwAYiK2cjgATUkA== X-Received: by 2002:a17:90b:4a8c:b0:23d:a2a:3ae4 with SMTP id lp12-20020a17090b4a8c00b0023d0a2a3ae4mr3901952pjb.44.1683248831972; Thu, 04 May 2023 18:07:11 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 18:07:11 -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 68/89] target/riscv: Introduce mmuidx_sum Date: Fri, 5 May 2023 11:02:20 +1000 Message-Id: <20230505010241.21812-69-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::52b; envelope-from=alistair23@gmail.com; helo=mail-pg1-x52b.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 In get_physical_address, we should use the setting passed via mmu_idx rather than checking env->mstatus directly. Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li Tested-by: Daniel Henrique Barboza Message-Id: <20230325105429.1142530-13-richard.henderson@linaro.org> Message-Id: <20230412114333.118895-13-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/internals.h | 5 +++++ target/riscv/cpu_helper.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/target/riscv/internals.h b/target/riscv/internals.h index 7b63c0f1b6..0b61f337dd 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -37,6 +37,11 @@ #define MMUIdx_M 3 #define MMU_2STAGE_BIT (1 << 2) +static inline bool mmuidx_sum(int mmu_idx) +{ + return (mmu_idx & 3) == MMUIdx_S_SUM; +} + /* 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 291a1acbf7..29ee9b1b42 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -842,7 +842,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, widened = 2; } /* status.SUM will be ignored if execute on background */ - sum = get_field(env->mstatus, MSTATUS_SUM) || use_background || is_debug; + sum = mmuidx_sum(mmu_idx) || use_background || is_debug; switch (vm) { case VM_1_10_SV32: levels = 2; ptidxbits = 10; ptesize = 4; break;