From patchwork Wed Mar 6 10:41:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583878 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94308C5475B for ; Wed, 6 Mar 2024 10:42:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 074D26B00A4; Wed, 6 Mar 2024 05:42:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F41A56B00A5; Wed, 6 Mar 2024 05:42:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D91E16B00A6; Wed, 6 Mar 2024 05:42:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C07EC6B00A4 for ; Wed, 6 Mar 2024 05:42:51 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8E0B080BA4 for ; Wed, 6 Mar 2024 10:42:51 +0000 (UTC) X-FDA: 81866276142.16.C91712C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id E61D4160010 for ; Wed, 6 Mar 2024 10:42:48 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OqK/Z0pc"; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721769; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; b=JpvVnIbOGuu/HN9zHH/x8plnsf2vkDkq9YpTNaMkH6p8UhK0jPWG70rcBYdciDe+9gpmfV iKbZuEVyI6q7stJQvUGrZY6ufPJhu5/O1ZRhEIYosS+Nv8hzpfpi8r+N6r9FOB8EaVO44z BplNcUXQc4m4jFKDXEP3/4FB1LBq1NQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OqK/Z0pc"; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721769; a=rsa-sha256; cv=none; b=pt8DYw4nuDL9IHHeJZrAVoYfwtW02jgDQSmqHiCeXRTBHMR1AJyTdxlpBk7LWIGXQo0vwZ piW+Z5IPQE2A9BipzmyeSyibpM4k+b4kdBYOUee60emLjfY9nNlv30u6BaqIVEmYdeb0nn YJSm3mRqhFM0aOjdgbkjshYO05YAufE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; b=OqK/Z0pc0AxhAWE3xo5vR9PG1pnkVhfAX9M3chFmT3wvd11iEjxeqcwDcGQB7bfWWoxdAQ GVEaDEOGki4DtnNt+FRAx40MwwuW04H5/KJgTB+a0F9UJwMSVscizt4gbZ9CGbDen8+jTE fCeQcrzfjpCjOqEk3UvPgNuVX4fRDmY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-Wb-frT--OHqzyYxRKxeqiw-1; Wed, 06 Mar 2024 05:42:44 -0500 X-MC-Unique: Wb-frT--OHqzyYxRKxeqiw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E994B10189AC; Wed, 6 Mar 2024 10:42:43 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA310111DD02; Wed, 6 Mar 2024 10:42:34 +0000 (UTC) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Andrew Morton , Muchun Song , Jason Gunthorpe , peterx@redhat.com, Matthew Wilcox , Mike Rapoport , Christophe Leroy , x86@kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Russell King , Shawn Guo , Krzysztof Kozlowski , Bjorn Andersson , Arnd Bergmann , Konrad Dybcio , Fabio Estevam Subject: [PATCH RFC 06/13] mm/arm: Use macros to define pmd/pud helpers Date: Wed, 6 Mar 2024 18:41:40 +0800 Message-ID: <20240306104147.193052-7-peterx@redhat.com> In-Reply-To: <20240306104147.193052-1-peterx@redhat.com> References: <20240306104147.193052-1-peterx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspamd-Queue-Id: E61D4160010 X-Rspam-User: X-Stat-Signature: n3gx5weuy4ox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/6NHexFWSAVer8hEkG593C8J4S49LVQ00JIRUgYqUiyUVl+JACsH4onHUS+mkvgP9ZdHk7myLkZmKmsJon1ebKBYLNg622QZU/mY4hyzbq3uMlTShBo8x7yysZz9zkUzwQe5IFw4wFjFVgr1oTqvKtd2uUid56b3o+NcEV5MEkKWZhZ1fi9ySOmpS3QZ56x2hg1ui1XdsTYJTjiStiqYPIp92bpQZzDmAtwe4AfOugMmay8ppt1JKoZk0OXmlHt0bg1crtWN+JzN1U/ggc9MRB9Vnm0/WcvXteci7A1lUrO4Stz6T345zFIra34v6z08vpJkVlXHeHWBu0s/eizI4mp1LAv7t6E8KQzLxJDGdiuZXleyLGSGGi+aAhWkU4WyGMA5esn+1H5 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Peter Xu It's already confusing that ARM 2-level v.s. 3-level defines SECT bit differently on pmd/puds. Always use a macro which is much clearer. Cc: Russell King Cc: Shawn Guo Cc: Krzysztof Kozlowski Cc: Bjorn Andersson Cc: Arnd Bergmann Cc: Konrad Dybcio Cc: Fabio Estevam Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Peter Xu --- arch/arm/include/asm/pgtable-2level.h | 4 ++-- arch/arm/include/asm/pgtable-3level-hwdef.h | 1 + arch/arm/include/asm/pgtable-3level.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index b0a262566eb9..4245c2e74720 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -213,8 +213,8 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) #define pmd_pfn(pmd) (__phys_to_pfn(pmd_val(pmd) & PHYS_MASK)) -#define pmd_leaf(pmd) (pmd_val(pmd) & 2) -#define pmd_bad(pmd) (pmd_val(pmd) & 2) +#define pmd_leaf(pmd) (pmd_val(pmd) & PMD_TYPE_SECT) +#define pmd_bad(pmd) pmd_leaf(pmd) #define pmd_present(pmd) (pmd_val(pmd)) #define copy_pmd(pmdpd,pmdps) \ diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h index 2f35b4eddaa8..e7b666cf0060 100644 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h @@ -14,6 +14,7 @@ * + Level 1/2 descriptor * - common */ +#define PUD_TABLE_BIT (_AT(pmdval_t, 1) << 1) #define PMD_TYPE_MASK (_AT(pmdval_t, 3) << 0) #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0) #define PMD_TYPE_TABLE (_AT(pmdval_t, 3) << 0) diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 4b1d9eb3908a..e7aecbef75c9 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -112,7 +112,7 @@ #ifndef __ASSEMBLY__ #define pud_none(pud) (!pud_val(pud)) -#define pud_bad(pud) (!(pud_val(pud) & 2)) +#define pud_bad(pud) (!(pud_val(pud) & PUD_TABLE_BIT)) #define pud_present(pud) (pud_val(pud)) #define pmd_table(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ PMD_TYPE_TABLE) @@ -137,7 +137,7 @@ static inline pmd_t *pud_pgtable(pud_t pud) return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK); } -#define pmd_bad(pmd) (!(pmd_val(pmd) & 2)) +#define pmd_bad(pmd) (!(pmd_val(pmd) & PMD_TABLE_BIT)) #define copy_pmd(pmdpd,pmdps) \ do { \