Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp981533lqs; Wed, 6 Mar 2024 02:44:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWj4sBhbzAwyW2g2z2yu9svdTcnww9w8Da027msbenODrkCMoYtAW2orIQbE+woDGuuIgaVQkIjG6ee34beln6rbrvW04rFRIJa1sdtwA== X-Google-Smtp-Source: AGHT+IGFutlWcPl/odbMJGTrCAjkhworRm76RgY2wlGL6Y3QQAu28uhUIvZpVaOMG71Hd3yvJLxW X-Received: by 2002:a05:6a21:3408:b0:1a1:3b90:3d5 with SMTP id yn8-20020a056a21340800b001a13b9003d5mr5096993pzb.36.1709721893849; Wed, 06 Mar 2024 02:44:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709721893; cv=pass; d=google.com; s=arc-20160816; b=uFpvAWYZw6W+EW6gpkGaV6fAxCy1z2eBUIILQuYMTNPstI+9qhfq9hGpXbyLNTJjJK DU9sDcpQ6HhZNF2LgfWUkcGylDd7Z8w49u+EhTNOMEqjdc19q14Xk7Mmv8IQxOpZZpff gv1+5of8kraQc1YpRWOWf+m89Sfx7AEY6WPcGxQbUep3z+WuzHBMnE7WGG5yeUktQ5Rz /AV1ox4ORTffaKCInnQfHylgDsHLWJ4uuokAOXNFES3U68PuEJ+pgbHzPkxUDeNBarX5 V3kOTADjVEmMyi9qghlgIa9LsWzYwBgAn7N3srYfggajFFDKRoDcLtM76i94XKnyzj2P ZY8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; fh=dqm2JVbsZvsx1sSci7k7OdRmqLBdIzu4KZ9nXaS8qPY=; b=CCyz0BWhqo9BWLhypQ0PaZnFeV/OgsWf6qL/kxs28GHT1vT7niGPVYTz2ps018loB6 mdr9PRhJQJa6xoWpFiM6wfnADTI7STtUTSh0tEJZdLSPQoJQ6uQliy2EpRchcRxO33lq 0GaKkmNwPJEPSFIr9bKhpzY/4co30EqCXkDUS1gtVkze5lM06bCR9++f1NPj5oHsodjU Qc5UrOUnd+mNcNVZnYnwFJx/b2TNb09Rssg1+53Lmm1r56UJp4IEX2B9jguWFne2Geai 2+j6x/vqNMrmgJ4ZQLmrI+yw/opnKQ40uYuyzsV1LItI9e/y3XQUhA65xYsFOYqBVqP7 Pytw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y4S0HTy6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-93791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u1-20020a170902e80100b001d9c37d7188si11678576plg.201.2024.03.06.02.44.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 02:44:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y4S0HTy6; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-93791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0A1DB28C216 for ; Wed, 6 Mar 2024 10:43:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E438605CE; Wed, 6 Mar 2024 10:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y4S0HTy6" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A933605AD for ; Wed, 6 Mar 2024 10:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721774; cv=none; b=i0/oz7Dn9rlk+aawD5R99fOGJjCuqm3k3IuwoEKttzIArT2QVkfIA8UDbbWtiwTR3Oyw/Ej+joMracK8vXxCwONLB8pnNGdAqcvwpOcsSgDuHbYPhZaBxk+tHKM0fD8frIh2xGzXPpgDHPrV83DbWVJYfTqYlx/dm8IwlkVoeUo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721774; c=relaxed/simple; bh=udgt5BojDZ8EVWkeL4uhl2LfvjHvU9M2T020easV1nc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rt89gy/ggasoS+wSeBQpZOyIGBLNRBoAEPNoZ0Xm9TLix8zDcHLtbUVxIASQmJH3daEJBjtCivfJztRrC8eH44QYd2v7VSEnmdwNjZ4Zl2IpxOlvHHWfzGvWNpvGE6IuGk4O4hzF+ZTsf+qYFdC4qCYA3RVY4HqKP5UbpxD/P/4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Y4S0HTy6; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721771; 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=Y4S0HTy6jCldD0E6sgHMs6yaPdO1ngMF+WVwFMeY+vwr5saDJB3JH6HScUWOgERSX3LYxx xcRUDRqbKVPmhxwENnsqcG1wmGhG7hw/4eINXX0jcxY7eDqggrf7kMu5ekhUSpAkSrJxvl ZTU2JfWRxsaMKn94rp1pd6VDKtuFhRM= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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 { \ -- 2.44.0