From nobody Wed Dec 17 01:48:31 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2456C88CB2 for ; Fri, 25 Aug 2023 11:26:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241587AbjHYL0X (ORCPT ); Fri, 25 Aug 2023 07:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242000AbjHYLZ4 (ORCPT ); Fri, 25 Aug 2023 07:25:56 -0400 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A38C1FEC for ; Fri, 25 Aug 2023 04:25:53 -0700 (PDT) Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4RXHgz5Ym8z9vbk; Fri, 25 Aug 2023 13:25:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CnZ899-xiQmK; Fri, 25 Aug 2023 13:25:51 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4RXHgz4jH5z9vbh; Fri, 25 Aug 2023 13:25:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9DC6E8B7BE; Fri, 25 Aug 2023 13:25:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ZVNk_mHNg-9E; Fri, 25 Aug 2023 13:25:51 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.234.95]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 65AD28B765; Fri, 25 Aug 2023 13:25:51 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 37PBPjL11400397 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Aug 2023 13:25:45 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 37PBPiN21400384; Fri, 25 Aug 2023 13:25:44 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH] powerpc/8xx: Fix pte_access_permitted() for PAGE_NONE Date: Fri, 25 Aug 2023 13:25:36 +0200 Message-ID: <30de3838862d1a7d55582963ca5fe567b3a91b28.1692962717.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1692962735; l=1818; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=jJZQF1YAq1al9uZuIZE8KXIy71bQEkSgP4654a7NyxE=; b=O4xNO0bIpYOM9y1YXEh2bceNCrnTBsQKWXyv25+M7lDTNBnA4WaNnexjFanfNwtmPg51JPtsg 99NF9WtYnZXD5QlvjVr/Cgv8dQJdIYSkzX2AX2HKKsLOr+3nepdXiLu X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On 8xx, PAGE_NONE is handled by setting _PAGE_NA instead of clearing _PAGE_USER. But then pte_user() returns 1 also for PAGE_NONE. As _PAGE_NA prevent reads, add a specific version of pte_read() that returns 0 when _PAGE_NA is set instead of always returning 1. Fixes: 351750331fc1 ("powerpc/mm: Introduce _PAGE_NA") Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/nohash/32/pte-8xx.h | 7 +++++++ arch/powerpc/include/asm/nohash/pgtable.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/arch/powerpc/include/asm/nohash/32/pte-8xx.h b/arch/powerpc/in= clude/asm/nohash/32/pte-8xx.h index 1a89ebdc3acc..0238e6bd0d6c 100644 --- a/arch/powerpc/include/asm/nohash/32/pte-8xx.h +++ b/arch/powerpc/include/asm/nohash/32/pte-8xx.h @@ -94,6 +94,13 @@ static inline pte_t pte_wrprotect(pte_t pte) =20 #define pte_wrprotect pte_wrprotect =20 +static inline int pte_read(pte_t pte) +{ + return (pte_val(pte) & _PAGE_RO) !=3D _PAGE_NA; +} + +#define pte_read pte_read + static inline int pte_write(pte_t pte) { return !(pte_val(pte) & _PAGE_RO); diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/inclu= de/asm/nohash/pgtable.h index a6caaaab6f92..3af11981fcd5 100644 --- a/arch/powerpc/include/asm/nohash/pgtable.h +++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -25,7 +25,9 @@ static inline int pte_write(pte_t pte) return pte_val(pte) & _PAGE_RW; } #endif +#ifndef pte_read static inline int pte_read(pte_t pte) { return 1; } +#endif static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRT= Y; } static inline int pte_special(pte_t pte) { return pte_val(pte) & _PAGE_SPE= CIAL; } static inline int pte_none(pte_t pte) { return (pte_val(pte) & ~_PTE_NONE= _MASK) =3D=3D 0; } --=20 2.41.0