From patchwork Wed Mar 13 21:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13591912 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 627D6C54E58 for ; Wed, 13 Mar 2024 21:47:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBEFA80062; Wed, 13 Mar 2024 17:47:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C6F7F8005E; Wed, 13 Mar 2024 17:47:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE8E280062; Wed, 13 Mar 2024 17:47:36 -0400 (EDT) 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 9B3438005E for ; Wed, 13 Mar 2024 17:47:36 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2DE1340C0D for ; Wed, 13 Mar 2024 21:47:36 +0000 (UTC) X-FDA: 81893352912.04.5B3A364 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 3995F40014 for ; Wed, 13 Mar 2024 21:47:33 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BF9wQ+HB; spf=pass (imf07.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=1710366453; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; b=8JuSDbVF/JsBbnodX6Ws9U+6c8q3HTdGJpL+Jhzfh7koGr14xUbI+jDNaV1/mbfq+kASau 6kkOKXq1Brw/f1MVuc97ho2NHFec3Ex+EjNomb3M+6U7wg6TPKzMJUARta5+trQbqioTsi c+/wz6xnMl7F0eQSu5cwcueW0ngonLg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710366453; a=rsa-sha256; cv=none; b=6BpWqhnGhGW40bK1p7DZ9u2EM1MeGmXXVd0ySPM1rpMazi4ZqYYpIZwvw5nx6Pv6F6GRV6 tQuUQoLlAR+ovICxyPMeaPe6EWLqplTUBJGK2RwrwXarPq3/EeVK0wMTXLZWwypYA2IjVK GD5Qda4nL2jpn0hQgDZnlueqUJghBYM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BF9wQ+HB; spf=pass (imf07.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366452; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; b=BF9wQ+HBhhFkfGEPLeRCBeGDjgC3X2KoSElJvalY00mWpQwclA1Cs1cXadTwsVY2iWZS1n Nt+Z/4f5OPzOSvtWfb8TRwaYMtSFSomb1MWCUwUoMDFakwH9sRMwhQDgFwWjHsy6FDBwZk xTEdYVwRGGWedlB0P6SXl5gwUNCnChw= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-322-LtxHDjWtN7yABwmSwMB5Rg-1; Wed, 13 Mar 2024 17:47:31 -0400 X-MC-Unique: LtxHDjWtN7yABwmSwMB5Rg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6818b8cb840so989276d6.1 for ; Wed, 13 Mar 2024 14:47:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366450; x=1710971250; 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=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; b=WQkzowFQHuMcJf9EZrSNaoQNjMtFnBzCzNwi5dvsxKbPXbcdHYY0JEdkdwS0Xx/4NH BNuh/5jC+54xk9zvPBYGarIWBQscnXO3N7v2nRr9mm4FVnKUi0sKTu04iNEXLc+IeIc5 gaZn6r7WeyT8L+jfFKuKFcfebuL14R5jx3A5hmabKMevn1vSSRimd9c2BugE5paLS8CS zh3Mo8+9YHGeqGb46balFouAodzrfP7wwvqio5UhJgK8ierf6jOiBcWXXng0eLfr7wOU 4ayse1dWaJue1jDvdVUH9n9t3w5+nR+nc21sM6yIIBZ/ywWNNplOSrymZbdxXIgHc/K7 Y9jg== X-Forwarded-Encrypted: i=1; AJvYcCU5MFxxeXMrVVFzzDF4aBeywv1+g93xiJpYKYX+XZdoayr1pD+/VtjKI8MZiQD7AtmVa3I29nxzJHfJqA85n0yDVdo= X-Gm-Message-State: AOJu0YyKyttMN21+C60l0x+YpQRtqfUWdu5MTkk3lt76BSn9rPRRe5of TuAJkUo0PoR2nvtMDQwerNJdnJBRvMBvOJIun0P7/ATbMR16Dq/j3TE6bt6HeuQQPtpE45VGbBK nvCXtwYU35SZEtjVKrN93JG2O5847AZ8xYSqoDt1hyXIMjdFyPXFIhpwf X-Received: by 2002:a05:6214:ca1:b0:690:ca31:f070 with SMTP id s1-20020a0562140ca100b00690ca31f070mr2870219qvs.2.1710366450573; Wed, 13 Mar 2024 14:47:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7R1Abf8N+n3Ay4Ttv5JPf4Xs41/taFQJ/1rB/5tSFgWpT6oJW7WbEayo47shzOXV0M53hEQ== X-Received: by 2002:a05:6214:ca1:b0:690:ca31:f070 with SMTP id s1-20020a0562140ca100b00690ca31f070mr2870205qvs.2.1710366450230; Wed, 13 Mar 2024 14:47:30 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:29 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe , Russell King , Shawn Guo , Krzysztof Kozlowski , Bjorn Andersson , Arnd Bergmann , Konrad Dybcio , Fabio Estevam Subject: [PATCH 06/13] mm/arm: Use macros to define pmd/pud helpers Date: Wed, 13 Mar 2024 17:47:12 -0400 Message-ID: <20240313214719.253873-7-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: 3995F40014 X-Rspam-User: X-Stat-Signature: k5d6y5g4tejdwpiay9cdxs8yfie4tffq X-Rspamd-Server: rspam03 X-HE-Tag: 1710366453-18931 X-HE-Meta: U2FsdGVkX1/qiAEff74OP1+ncdkX9NgBo37redtE12h1YKHFJC9yZsJNFRbEFor5rDkiCaFZoipyj7xddKIsokYArbJzICghUDKT7O+CJWUKmw+639lpjBtXhYok6mAJdNr5hoef8eGat3QiGxjETTOMZmFbOX9huHFnDG1t9qKq1tagG8iMwoh9unTl1ZNvnXo5M+zRLsl/kuoa2IEEnhb3d9+xc2pCh0uSZbCwYXBSTzpxoRNwX7teJt6RPD7xAaYsVosLK99oOlYlO13Yow/ycMnwBhAEKYImbU+V3GZAyb6GEpGx3vQgo9CPprwrjgSAA39wm82VFf54GtKwmDwESvMxxwovnI0QbMGhVe1MlrDYKGpRnJaGI/c8UTGB4AsDBL9oz33H6UyU2Aw7br37MRV1L/G9BXcSzjzjJyllIphV2CHrus59a34vbn81wm0EC7dIM9dN+GFbrrNqKE7F+0S0A07qXrPMaPfMeTEhPZKJikyjlGM3RlvRmpVE/xCFqUh4U+BVEcINcp9bdTSunsh7MFLe+UM4O67GpMTJ2wtESV1asclOkBNbm3hCTggnaYFw0aGaH9YobC1bKlS4s39zGZkP/eqOAYcRfDh1ZEYZobkTKfTb1UXBhQkgDdYLeGPyzJYn2p2v4Ap7f67B8GlmMbqSxmjfdVgo5MABDSGGxQ689Xw/Zi8vFAm135BtanamKm4kyqx1IE7H5Lyq4sLEO1FIqDO7vh0j4hL2z7ZWTGBVjkvprYySvZLEBJiDWP9kWVxD5DpPwTe8qhWXUYNkc4QWZuMCoNPvJSMN1KlmAWCjiiAcxI7dSqexEq2MuELZ9eqMoD/JP7/H6e5unLNbooqj/t6VA26RU82WcHTgI+kSpK+5IzbiqauOxIBr4fRc5dH0TbhLnKjKm5LTY9fPWKLcnIzv1yei150TBTYfD+IW3TMqHmSLKiPl614UdosLrW7xuovt2nP YIbmkTbl aVdWL1svmHCL75EiRhKMfd8MfsjLyQEuDRgn6yhKJMKF7bF42SOlovy8tlu2XjWNGHj7KcctP4DW4vorAunmMx+8fRfnsZsnKCsvCVIQNBMjYqo0/pGzPwpMY856nHm/T5YfF/t2Ll4A4LW+eRUNYf+YphA== 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 { \