From patchwork Tue May 18 20:11:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 441225 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp577427jac; Tue, 18 May 2021 13:14:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgbWQ+2TUsKXQ3PPP9JGwa+fK2Huhl63C9sALbqL1zhC6M5z4tQxpKEvcHm//72bW/d7xL X-Received: by 2002:a92:700a:: with SMTP id l10mr6138813ilc.44.1621368850510; Tue, 18 May 2021 13:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621368850; cv=none; d=google.com; s=arc-20160816; b=ZVcWZRPvA0cYsySPrr47g9ePUQR6OodiuKWuHvD/oQE/CA3c0Wpy0+nJqv0UttmkLa yy4N36KMJk3F0SyOQW7+C3piSb0sthhZSPjC8W8Xq1FcrVuuqPsqMArBT2Tpc3p0Scxs ndSKETxiFqifUKc5HH/659WBIhfiU0vI8CdBMBctQ6nJwhRUjwckqO//zaqFKQ462sDE IyqelE2y3rAvJsZwZQqgDQF8aA87D7ADIZjeqPmsBsfub2Ac5lZZ75XqV0SIuVavTcjh mFSvbJk1NegNDnxQUPjJ8Z0kFFPPcc7C1P/EEq5HyYVsh9uBtm2DCgl8UGHrFprZfKzS Wzxw== 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=a7/fohj61j76TyyFJ4tR2jXYVerXRa1Mweo4AkQY9Lk=; b=dgrIZlJA6aBFegxQxHbQEYH4OiZDv4uJ9qA46h2ulOD8rP+o1lDQvxayCbxOUAw6iZ r328E8f1AvLd8pvwo5fKq3abEPgVwH+2C188yDGa5frit2nAjYQRwUiIneiVGtYMCZcE srrVrjaK556Gn+8AOptjL94Mfd3NtQG5vOCJqujnG3N79VF6jehTmEbFjIHyBZ0xQuez Gd4XeKDK2ADPGiJ4DXdmD/um2Exxjh4eD9u4/RPx2md5RDwrL+Bshnh2Tq1TgX3mRwIf GPsoE41s92Kec4s4JImzt7JYPNf/WptzcWpIV6y2ozgHZ6dQZVeiBUpJUAQLXzTQ8dgk 4hkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FA67xz5i; 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=fail (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 u3si1910877iof.8.2021.05.18.13.14.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 May 2021 13:14:10 -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=fail header.i=@linaro.org header.s=google header.b=FA67xz5i; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj66T-0003Bs-Vd for patch@linaro.org; Tue, 18 May 2021 16:14:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj64M-0000JD-Rl for qemu-devel@nongnu.org; Tue, 18 May 2021 16:11:58 -0400 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]:43928) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lj64K-00068f-Qa for qemu-devel@nongnu.org; Tue, 18 May 2021 16:11:58 -0400 Received: by mail-ot1-x32e.google.com with SMTP id u19-20020a0568302493b02902d61b0d29adso9751115ots.10 for ; Tue, 18 May 2021 13:11:56 -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=a7/fohj61j76TyyFJ4tR2jXYVerXRa1Mweo4AkQY9Lk=; b=FA67xz5i1zckkWigmxHDp3HcDrA5bxUPPsLgfLvqFeXCwme7SiaGKvqrMob4Oc9k2j B2QYyx4oKL/szxZKWP6pf1n3Fu1rxNVV2+UKadfJTkUmRDkXAI2XkxktH4IhKCDXe/D2 nlfmTOv1qFYglzOSA9tT5Nd/CB28HcH8OWO5by1ySNP2jBKCHc2rPHCySqgTBRIL5lED gzvRopNiO3M0qYqoz4Zgk/avZamP2NG8FloJrWEwkuqV3Za36l1lE4vfqcqHmTJgWz2r q+/uXkFoljf8W/vPipyUmialtSMOnbt90GUjnSe/1omJgKsLo4/p7O6uirYmgd8AZcgw 1XcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a7/fohj61j76TyyFJ4tR2jXYVerXRa1Mweo4AkQY9Lk=; b=UJCJ4yG9lMEoHJrz+Zqr2/fLAr11e7JcJV4d4COuYf/fbMAp4HTurzWSGZk1BryMhp z/jrxlSQxvALrxdL4aiiOdFDyB6XnS/DaVgmgyt86QgZjTOIHPLRkYUKQ8Xwh+u/8ZyI L99bSphxgwpYB28luLtC/4CQZnqR1wqhY8HMWVlZ4bzXskmjNj+MzNnOWufrACoWz/N0 EBL0QmNPIQsaKpT0j6Ca4GY6/6qGKsf8USEPrZyq64v8A1ChRtyhJoRIPPOfLqbcRxu9 kdai+CNYqiovs0QBp6VKHDJFFMqwc9jTHlgRESIiYLnsSGdDhvDwPDZ/018DBuOtFPA5 AueA== X-Gm-Message-State: AOAM532kIRHy5rEocruttvAclSLkLfOHHHS5gnh88P6zi9T9Bk49CpNP 3ujq0MNYJfZWkOUX+ItBZj4N3ekznckoZ/aT X-Received: by 2002:a9d:37e2:: with SMTP id x89mr5993137otb.352.1621368715588; Tue, 18 May 2021 13:11:55 -0700 (PDT) Received: from localhost.localdomain ([45.235.253.15]) by smtp.gmail.com with ESMTPSA id u27sm3953204oof.38.2021.05.18.13.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 13:11:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 07/24] target/ppc: Remove type argument from check_prot Date: Tue, 18 May 2021 15:11:29 -0500 Message-Id: <20210518201146.794854-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518201146.794854-1-richard.henderson@linaro.org> References: <20210518201146.794854-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32e.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bruno.larsen@eldorado.org.br, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We can now use MMU_INST_FETCH from access_type for this. Use prot_for_access_type to simplify everything. Signed-off-by: Richard Henderson --- target/ppc/mmu_helper.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) -- 2.25.1 diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index 2aa1b777de..e3912e4094 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -32,6 +32,7 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/qemu-print.h" +#include "internal.h" #include "mmu-book3s-v3.h" #include "mmu-radix64.h" @@ -126,33 +127,11 @@ static int pp_check(int key, int pp, int nx) return access; } -static int check_prot(int prot, MMUAccessType access_type, int type) +static int check_prot(int prot, MMUAccessType access_type) { - int ret; - - if (type == ACCESS_CODE) { - if (prot & PAGE_EXEC) { - ret = 0; - } else { - ret = -2; - } - } else if (access_type == MMU_DATA_STORE) { - if (prot & PAGE_WRITE) { - ret = 0; - } else { - ret = -2; - } - } else { - if (prot & PAGE_READ) { - ret = 0; - } else { - ret = -2; - } - } - - return ret; + return prot & prot_for_access_type(access_type) ? 0 : -2; } - + static int ppc6xx_tlb_pte_check(mmu_ctx_t *ctx, target_ulong pte0, target_ulong pte1, int h, MMUAccessType access_type, int type) @@ -182,7 +161,7 @@ static int ppc6xx_tlb_pte_check(mmu_ctx_t *ctx, target_ulong pte0, /* Keep the matching PTE information */ ctx->raddr = pte1; ctx->prot = access; - ret = check_prot(ctx->prot, access_type, type); + ret = check_prot(ctx->prot, access_type); if (ret == 0) { /* Access granted */ qemu_log_mask(CPU_LOG_MMU, "PTE access granted !\n"); @@ -441,7 +420,7 @@ static int get_bat_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx, (virtual & 0x0001F000); /* Compute access rights */ ctx->prot = prot; - ret = check_prot(ctx->prot, access_type, type); + ret = check_prot(ctx->prot, access_type); if (ret == 0) { LOG_BATS("BAT %d match: r " TARGET_FMT_plx " prot=%c%c\n", i, ctx->raddr, ctx->prot & PAGE_READ ? 'R' : '-', @@ -733,7 +712,7 @@ static int mmu40x_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, check_perms: /* Check from TLB entry */ ctx->prot = tlb->prot; - ret = check_prot(ctx->prot, access_type, type); + ret = check_prot(ctx->prot, access_type); if (ret == -2) { env->spr[SPR_40x_ESR] = 0; }