From patchwork Mon Mar 18 20:03:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13595765 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 4555EC54E69 for ; Mon, 18 Mar 2024 20:04:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96F026B008C; Mon, 18 Mar 2024 16:04:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 91E1B6B0092; Mon, 18 Mar 2024 16:04:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 770F46B0093; Mon, 18 Mar 2024 16:04:21 -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 64CF36B008C for ; Mon, 18 Mar 2024 16:04:21 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1A6461201B3 for ; Mon, 18 Mar 2024 20:04:21 +0000 (UTC) X-FDA: 81911236722.24.216A215 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id E83001A0005 for ; Mon, 18 Mar 2024 20:04:17 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UvAC3mlJ; spf=pass (imf19.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=1710792258; a=rsa-sha256; cv=none; b=dM6l9wRICpHTT3WCcvu0puvC0EMzIM4ccY0Mlf8BYK0UR7L4cJiqlso/OtT4DDu1HLP7u0 d0IBNftuSSfty7VKSBEAF8jRGhARnJ4x2pob83uvXYhu3277+nVokn5OLZWGPLbpy7kf6v DGkRAX7eren5OIRMhWsXvKlHSbWnNeQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UvAC3mlJ; spf=pass (imf19.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=1710792258; 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=u9rxdbkLRngfyNzf9O/2DsytT6/6qO6lxvKEQ92hcTSjMbtSPKX1ZuEmotu2wm62C8FwEj b75Ixf32jWbAs9HbGG64TZEWTizxJzvt8lUEsoHbjWCtqLRfcT/tTb53SPolQEd28D03P9 1jMevd389oXYEi2CBxwoTcjwX8ZYRqs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710792257; 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=UvAC3mlJJCSOHNU5MD1NjSKMPmJAP7m+zAHZMj4VIQ7DR16FAGGCcRNf8Ky8MK1wlAZepj EkolWP9ryJTHkDDwvA3O+94HW0nLPdiqpZpV8YRInFUxA5rii2guOKPiSJkPq7s+mmRN+G 1Y/CoYQNOCL/cc98X8ADKQ08KNQtAok= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-394-wmR2qvzBNkyBdtT_qCYA1A-1; Mon, 18 Mar 2024 16:04:16 -0400 X-MC-Unique: wmR2qvzBNkyBdtT_qCYA1A-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-430c76df729so6672811cf.0 for ; Mon, 18 Mar 2024 13:04:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710792255; x=1711397055; 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=bUfhwdvhZz5W5EO++JjoaR881HumI3mXXKcY0X/EzSgStH0yULL72GiVur7KNx6T2c 3Mbx/oHrkmwDAQQFgEujQlT4Ope96rnvGKLOF9w2WHSS8+xT3GQC19B42vvSV7Omg/pG dytyoe6shtobtRgh1E6/He8lb0A3zy1b1pWpgG5An/aTmWXXxTnkXwsLj0swWAB/UPJK uA1aC0qExT+StBo6E6p0Cl8Euo3L3xZdFATXxiob9fapwDGPVKQm96aBeeLPb1cpMJ87 ppXIly/neRzjttwcB0YqMJiyac3UNd5ykvBTDsMmLHh1vZj0uBZrOqn6lwmbgycaMu61 LX5g== X-Forwarded-Encrypted: i=1; AJvYcCXSNP5zh7EUXwtxHwZojteTdk03tkfsHNrCrJ+Jp/LGyiN2tCsIeYXoMxHMNdup15ZecGFCemMp4Ber+2BMb8Sh0y4= X-Gm-Message-State: AOJu0YyO0Ql7lGY28YHw5/oA/y1KD2gjgd3+AnFge7euD7Jqz9xBb2eJ EXBSJFj0PUpQswa+i/HkaVY2HqPi2xn+rIVsAWvlXVg9INP1DKNb3XmTN9QYPJKI+iC9Kp5Xs44 0xD6Kyp3vzKskfbn/ieg2iQvdaX34dI3BUfiGxsGqIjpQZrk8 X-Received: by 2002:a05:6214:ab2:b0:695:c55d:fdf8 with SMTP id ew18-20020a0562140ab200b00695c55dfdf8mr6345896qvb.1.1710792255543; Mon, 18 Mar 2024 13:04:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHM5if+BJ4z/wKMKgmRKGlctu1Y5Zn0gs2J/D1UPDtxcNZL4bpQ3QnCrk82omp9xwt5ITq/IA== X-Received: by 2002:a05:6214:ab2:b0:695:c55d:fdf8 with SMTP id ew18-20020a0562140ab200b00695c55dfdf8mr6345849qvb.1.1710792254868; Mon, 18 Mar 2024 13:04:14 -0700 (PDT) Received: from x1n.. ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id hj10-20020a05622a620a00b0042ebbc1196fsm3484491qtb.87.2024.03.18.13.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 13:04:14 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , x86@kernel.org, Muchun Song , Mike Rapoport , Matthew Wilcox , sparclinux@vger.kernel.org, Jason Gunthorpe , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , linux-arm-kernel@lists.infradead.org, peterx@redhat.com, Russell King , Shawn Guo , Krzysztof Kozlowski , Bjorn Andersson , Arnd Bergmann , Konrad Dybcio , Fabio Estevam Subject: [PATCH v2 06/14] mm/arm: Use macros to define pmd/pud helpers Date: Mon, 18 Mar 2024 16:03:56 -0400 Message-ID: <20240318200404.448346-7-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240318200404.448346-1-peterx@redhat.com> References: <20240318200404.448346-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: red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1tP8zrmntRHxT0ZOTiSoenFzHb sw510xNj ko6U5I9P9mvZNzOgIyxuLMsRbm22MrYrW08q0hi610Hw+drFphdWbMlX55rNP1lqWY+KRmGaDQnOPgdcIhFAWpV9CQjT1pqZQJjwyyvjuupzKTTq1CJ7pemQtkUxq7eXqkbVDPuGt9lpP1LDmfbe4cLmxyv7tzgx4TNohE9Qy7R7fGnriOcFF1K0Ds/5vkI1lvVh/DDo4rCQnAcaqrKOAuFy36q1ozzppW9vwknAsQpdgiR9HjRvAnykDcnYV1Zh/3wAq4AyjAWZmTfWrC2B8lpQcp/0lqLQYao4xtvKlrE3XPzapglkjkA9utO31K1mougH/qC4oN9yOGcS3L0uwIiqJoGT92kotnzUyv/YxltSZUxTQbUMGJzOwvP6zSCl7wztByA9Nn6GKC2vi6sNN+6rZgogiZDIf8oYgyvdEYFgr5HLM17tm2mjcMKZS7uZnY6+iKniHZ953P4MMx5H5XPLFU5OamJpMXvtaXNHyjZabr4fHsqJXyxam5/SC7oyCdS7mqMPtGoDEFJc5YYf0Jc4dL8qfvshNH6Hp/JQeHcACEzSQ+UIx83aMwOeIPji9QBh0qSToDxYOWPFUaB/Aak5VkUGCJ/1mMsEzDAiH7ALGrQ8XrQn06qeWQA== 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 { \