From patchwork Fri May 5 01:02:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 679283 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp92374wrs; Thu, 4 May 2023 18:15:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4dcZfxkaqq00xBxFgjeNYmyuizoY3qW1HfdVDpjO7STaQN8S/YMLZRkLHwsgUyTN/sZe4W X-Received: by 2002:a05:622a:1826:b0:3ef:3057:62db with SMTP id t38-20020a05622a182600b003ef305762dbmr260526qtc.4.1683249320864; Thu, 04 May 2023 18:15:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683249320; cv=none; d=google.com; s=arc-20160816; b=IPI9OzAN1BPNwt5DoCIfSzg6kCvwKyI03bBcxzuy+6Tx9SQXMQv6963geiGuqfpS6b Jc5k5lpkBAln/4ODhWC7w/H7hsT8n8b749CxgulKIaM217h8CvXk3BTQo+p0Uj624jM/ geSWupJ9iTuDVxhdsfhY/PVgnCWK4fCkeHYfiIqc07rar5lGJn41H9u8LCT1Ynwtrnd4 1lV88ZV40fy2A6rzt8KZIdnsEOH1qwyf9WGU07lt2lnDJlrpcl+QrE7pIP6qthGpAmHd ZgB3pPGxC76LSeJvQEwQGbAEN87HJ2dBtSrs5VJA7sGRCkdR/28efKv0NJLGKMcBSPTd QDAg== 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=kQOvu3VF8tFauxUlZuL69IHK6L45Rg+xcZox/q0Oz7g=; b=o338Fc/Tx/YNBKG73PfASiytMZzL87qpGaVT3NzcKBR3zAePuJW7CPLtp2DRQgikUp qFVYYTPnC2NP1iFXUg1hIG4fp4KULMK5oL5vhl3Q79Xk1UtRrg5jSq63yxhiMdspfFtn KU/X6rcJPEXfbPXSNo6vGcNHWwBdddIX1/WdRwv9M5WgUMDBaQBNWOTRpGxdHVZoD/Y8 36+etfd77S0zES/IzzKKH1T3izsgu1TFo3SJlNkpzFrfVJb9S1f1WZ/I6jmYS9ANAELo vdZLy2zQGWvxs7NgyuldPUgPhSLUKoZmAyiFGd3xBKgqI8ebEW6sVxNpY+NS/GR25S6M 1BUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=AMUerAx9; 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 a11-20020a05622a02cb00b003f2266d4a98si156381qtx.277.2023.05.04.18.15.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 May 2023 18:15:20 -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=AMUerAx9; 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 1pujvK-0000s8-Ty; Thu, 04 May 2023 21:07:50 -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 1pujvF-0000gv-Nw for qemu-devel@nongnu.org; Thu, 04 May 2023 21:07:45 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pujv9-00083m-L6 for qemu-devel@nongnu.org; Thu, 04 May 2023 21:07:40 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1aaea43def7so7996285ad.2 for ; Thu, 04 May 2023 18:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683248857; x=1685840857; 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=kQOvu3VF8tFauxUlZuL69IHK6L45Rg+xcZox/q0Oz7g=; b=AMUerAx9ObDkmsrQRElHEFamW4cbLnfdZNeC2FeFsTZ9cQ0XL2QI3Gm53MmeVZrlM1 GsPQ5fUAzjN7wSbKTPvvuGzEyhWRGwd4eDvaf71EgmVhKm9R5+AjjfNcAfIrDLjpcjCV bZ1h8BKOwPUaitF/QDZv5p+5Y2ywTXEFZ3AsxKVSY9/0zUKKn5i9dgTrbM1J5P9a+iZr RLwRV+xfwuvVSB5tamSAy6UPt48uZTe/zRK2VBrJBfE1yAQd4NsVTB2mJ169AxrAiDDn QmjIuB8uWihOwbxV1sIRx4mYSSlYVSpuG3pMIf4FRrC+0l4edG4KutDx7leQOur1wypb DSfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683248857; x=1685840857; 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=kQOvu3VF8tFauxUlZuL69IHK6L45Rg+xcZox/q0Oz7g=; b=hgFVa7emtJYEOJGOvYCzzhh0SfmeeYL+KxlNuK0eQOoEjUwuPJG8JZaNZPOAd9FosN D3glhl5mMUQiifEhrcnAe0nlSeaqYPkxQDtjYWW++kM+jdmVta0Gee7gbiidlOsPti0d nMeAtEu5ORp9PQG5BMnPI7WaHBCeYOt+UGFz1TG+JM6ZYQbfz7+uvSHwl8g7+5O6fHik dMIURBLfjTs3MXZsJF9RD0kWrVa26elriEC/B0lD9+Hl3hmzX+NlFMj8MtLJfIWF6jg/ 4J2d3MTVP1V5hQ3aM8m0jl/tmReGEsWkHe2us9JSpvVoNFbDJq/wCJHr/T0er7zJ1NUD llSw== X-Gm-Message-State: AC+VfDyVJ9SKKJ0iox22od+9EzQtIevOFO80azDAbvXTMat5pZqJ7gPR 1+HKEeScyYd4XDgsJUtP9bPmbKo/qNtZoQ== X-Received: by 2002:a17:902:bd86:b0:1ab:ef3:73e5 with SMTP id q6-20020a170902bd8600b001ab0ef373e5mr5279724pls.61.1683248857262; Thu, 04 May 2023 18:07:37 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 18:07:36 -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 75/89] target/riscv: Hoist pbmte and hade out of the level loop Date: Fri, 5 May 2023 11:02:27 +1000 Message-Id: <20230505010241.21812-76-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::62e; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62e.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 These values are constant for every level of pte lookup. Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li Tested-by: Daniel Henrique Barboza Message-Id: <20230325105429.1142530-20-richard.henderson@linaro.org> Message-Id: <20230412114333.118895-20-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/cpu_helper.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 5753e4e612..7c9f89d4d3 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -856,6 +856,14 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, return TRANSLATE_FAIL; } + bool pbmte = env->menvcfg & MENVCFG_PBMTE; + bool hade = env->menvcfg & MENVCFG_HADE; + + if (first_stage && two_stage && env->virt_enabled) { + pbmte = pbmte && (env->henvcfg & HENVCFG_PBMTE); + hade = hade && (env->henvcfg & HENVCFG_HADE); + } + int ptshift = (levels - 1) * ptidxbits; int i; @@ -916,14 +924,6 @@ restart: return TRANSLATE_FAIL; } - bool pbmte = env->menvcfg & MENVCFG_PBMTE; - bool hade = env->menvcfg & MENVCFG_HADE; - - if (first_stage && two_stage && env->virt_enabled) { - pbmte = pbmte && (env->henvcfg & HENVCFG_PBMTE); - hade = hade && (env->henvcfg & HENVCFG_HADE); - } - if (riscv_cpu_sxl(env) == MXL_RV32) { ppn = pte >> PTE_PPN_SHIFT; } else if (pbmte || riscv_cpu_cfg(env)->ext_svnapot) {