From patchwork Tue Nov 2 11:07:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516686 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp4447541iml; Tue, 2 Nov 2021 05:05:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7UtJ9187zl/xPxMwN3nt2eeL8mgBdYZWKqAHZLS5yAoVDRnrD4qVTXMd6J4oHLXMk0I0o X-Received: by 2002:a54:4594:: with SMTP id z20mr4498659oib.17.1635854738273; Tue, 02 Nov 2021 05:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635854738; cv=none; d=google.com; s=arc-20160816; b=S6/pwvqQBk8eGEp3btdGXpruBmMWM/BnIpcSNQowr53gh/HwDNCxegUI5P8r9rge2l FkuAUazYecb5lSxFQ1Iez8mK2NEgj5B3Vpf7KNaETkMh4azOhDIhwmwcbgGySI/2eD/P lGTJEO76Qmy/DxfiUWuldWCyIrH0oUEBVuYdowSXCvAl3vi8oVSU0/xn0GxPPDzPT5vg skcuaoA3UbL9uh2O08HAAVqoPWhOPsxKcfhFcr1908TQ4H1m+dK+lqUYBT88avFeNmS9 UGffr+xVyYq1h+ydiCJnuI19qpnRlHLDnGT3zdcqFwlQQfmx6/y6hJ/7+dDM+IgiDrS5 bmAg== 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=fVhlPoABQmS8wc89+ovGDAnkicIV2MZx6WAeJyRD9lM=; b=mcGLE2O+lFPwg+BLuiAnVEnk51lKrJ/Oj6WSdQ36eKNPQaH0abJdyGB2xoP8k7592p nozsthjIH1pvkho/CifwBnrmOnDKA94RILJ0qOJ6notjUHBTu9SZG7Kam08YLWta+K/L U445pT0fl8KV31DRX5dGpykMk/6OnAbhC9uiixBIyXUzD6XYyDk+0Nw5yci2nqaLR9+d N6TFEuKaciNoTKe7KeqKmMjELB/M2mQEIyneVCmm161ChHwqwzMI0pyy8vEFpHiTAJPG vhMT87elpWzePKlZhLd4k4DzsAPYSdynIYevRoEPTOmbdq10NKKocXpvnWj8HSN/Ltd5 9LFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CTrjXneP; 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 w25si804659otq.23.2021.11.02.05.05.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Nov 2021 05:05:38 -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=CTrjXneP; 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]:34490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsXp-0002we-Ii for patch@linaro.org; Tue, 02 Nov 2021 08:05:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhF-0001df-E4 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:19 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:33524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhD-00020y-5y for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:17 -0400 Received: by mail-qt1-x832.google.com with SMTP id h16so14043859qtk.0 for ; Tue, 02 Nov 2021 04:11:14 -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=fVhlPoABQmS8wc89+ovGDAnkicIV2MZx6WAeJyRD9lM=; b=CTrjXnePJF+Rse4Oe5iu/WPsWydGurIrp4qUSUJsm4/Dm5fIuA+DBCgWMVl6g5/RcE ySoEGTJuVyEIBpHNIosgATegdoNOd1CRRuPHu9yBdC3h1DSmBtCi9KBiDk3HjzcYFnLb o/ZdCkhVbjZ2Lol2aTs8YpLZWCyJnePK6zGjHyzyufEmfY63NUmk5mH/1J7F/srbuhai X5XLpjfvrSewphK40H58Qi5n5SBU+es7Q/IB1xoJO1kOA58QkpMYpH5K7QUXXgqezyHA 0rqRbgRbZe+xwWEmOJIwsDqgxvuvYA0TwVgxfI2GP0ixxc1l9qlSiGZFr4bQ+OBDoVN+ BZSQ== 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=fVhlPoABQmS8wc89+ovGDAnkicIV2MZx6WAeJyRD9lM=; b=AKU6G9P5etvYZE85b9fszYfbCxRxAItzuHKAEe8fqvYBZvaPTTlP2SqWMzem6xmLLg eJfS/+eAhb5QRSDHCCwwSBoqb6LWu2uHWPpNjlZLXcOk9IetdwqQunzDuvb5ZPgrVitk 9KQiz0oAQeGbCY4zzZaWbD2g9FU4ikvM+ZYcpGeNlXRpqT50l69Xh6os9enuYz0J/o+A 0Wg8XDvc/r5AlIqh3B6/fjCGV91rQwL4z8x2A4SskC5qnq88x9uQfqeNSABHK4p7ice/ JmXLkRtbROy2O1YO+Gl6ICqJP25XBbE+KEsFHOpQtVl6GLsBUFLD4rwMqdt41kY4t9Nr Jh/g== X-Gm-Message-State: AOAM531WSHXz5DSkhf2ciMdPygUBUTfp3SyL7RbBfrqTyfUqwFBF+s/9 O3VQNUVhPkzcrInVzZQLtV/TxvuBx4EV5w== X-Received: by 2002:a05:622a:394:: with SMTP id j20mr37681502qtx.386.1635851474332; Tue, 02 Nov 2021 04:11:14 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 55/60] target/sparc: Split out build_sfsr Date: Tue, 2 Nov 2021 07:07:35 -0400 Message-Id: <20211102110740.215699-56-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x832.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-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target/sparc/mmu_helper.c | 72 +++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 26 deletions(-) -- 2.25.1 diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index 2ad47391d0..014601e701 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -502,16 +502,60 @@ static inline int ultrasparc_tag_match(SparcTLBEntry *tlb, return 0; } +static uint64_t build_sfsr(CPUSPARCState *env, int mmu_idx, int rw) +{ + uint64_t sfsr = SFSR_VALID_BIT; + + switch (mmu_idx) { + case MMU_PHYS_IDX: + sfsr |= SFSR_CT_NOTRANS; + break; + case MMU_USER_IDX: + case MMU_KERNEL_IDX: + sfsr |= SFSR_CT_PRIMARY; + break; + case MMU_USER_SECONDARY_IDX: + case MMU_KERNEL_SECONDARY_IDX: + sfsr |= SFSR_CT_SECONDARY; + break; + case MMU_NUCLEUS_IDX: + sfsr |= SFSR_CT_NUCLEUS; + break; + default: + g_assert_not_reached(); + } + + if (rw == 1) { + sfsr |= SFSR_WRITE_BIT; + } else if (rw == 4) { + sfsr |= SFSR_NF_BIT; + } + + if (env->pstate & PS_PRIV) { + sfsr |= SFSR_PR_BIT; + } + + if (env->dmmu.sfsr & SFSR_VALID_BIT) { /* Fault status register */ + sfsr |= SFSR_OW_BIT; /* overflow (not read before another fault) */ + } + + /* FIXME: ASI field in SFSR must be set */ + + return sfsr; +} + static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical, int *prot, MemTxAttrs *attrs, target_ulong address, int rw, int mmu_idx) { CPUState *cs = env_cpu(env); unsigned int i; + uint64_t sfsr; uint64_t context; - uint64_t sfsr = 0; bool is_user = false; + sfsr = build_sfsr(env, mmu_idx, rw); + switch (mmu_idx) { case MMU_PHYS_IDX: g_assert_not_reached(); @@ -520,29 +564,18 @@ static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical, /* fallthru */ case MMU_KERNEL_IDX: context = env->dmmu.mmu_primary_context & 0x1fff; - sfsr |= SFSR_CT_PRIMARY; break; case MMU_USER_SECONDARY_IDX: is_user = true; /* fallthru */ case MMU_KERNEL_SECONDARY_IDX: context = env->dmmu.mmu_secondary_context & 0x1fff; - sfsr |= SFSR_CT_SECONDARY; break; - case MMU_NUCLEUS_IDX: - sfsr |= SFSR_CT_NUCLEUS; - /* FALLTHRU */ default: context = 0; break; } - if (rw == 1) { - sfsr |= SFSR_WRITE_BIT; - } else if (rw == 4) { - sfsr |= SFSR_NF_BIT; - } - for (i = 0; i < 64; i++) { /* ctx match, vaddr match, valid? */ if (ultrasparc_tag_match(&env->dtlb[i], address, context, physical)) { @@ -592,22 +625,9 @@ static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical, return 0; } - if (env->dmmu.sfsr & SFSR_VALID_BIT) { /* Fault status register */ - sfsr |= SFSR_OW_BIT; /* overflow (not read before - another fault) */ - } - - if (env->pstate & PS_PRIV) { - sfsr |= SFSR_PR_BIT; - } - - /* FIXME: ASI field in SFSR must be set */ - env->dmmu.sfsr = sfsr | SFSR_VALID_BIT; - + env->dmmu.sfsr = sfsr; env->dmmu.sfar = address; /* Fault address register */ - env->dmmu.tag_access = (address & ~0x1fffULL) | context; - return 1; } }