From patchwork Mon Aug 26 20:43:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13778402 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 6B0D7C5472E for ; Mon, 26 Aug 2024 20:44:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BA606B009B; Mon, 26 Aug 2024 16:44:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 969166B009C; Mon, 26 Aug 2024 16:44:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76E926B009D; Mon, 26 Aug 2024 16:44:18 -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 569346B009B for ; Mon, 26 Aug 2024 16:44:18 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0DD8D1413A5 for ; Mon, 26 Aug 2024 20:44:18 +0000 (UTC) X-FDA: 82495574196.21.075C215 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id DF4F51C0017 for ; Mon, 26 Aug 2024 20:44:15 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MjeN0CQp; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724704960; 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=vK1PMhUcFVpQCvjQRaUqQOYBcILrsdr8yUlCuFWve7Q=; b=M4J4qTP5ujeop1pJi6sqeHJNzfmeliZxKjv5vebvgAF42eArvNDIv2J0wayIzaZ5bUFNBU FBBBgCgyBRT9J8eCeB5/UdMBcNbNbbFUv8+yjToXSnt6zlA0uK5BVyEc99ITs65zYmz8Fv V4Ih+hggoCh50HgtnBwp4voY6ANc268= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724704960; a=rsa-sha256; cv=none; b=s2JIuR3gvheU43vUnSqKr1zwOU+eRlEqI3Zb86hbAaz1CMtGite3eP/ONSeGbpGtWvq9A9 w+DuA6wsFpiyJqfgd3AqpjMI2DfWggUuVnoQjA4zmM4AhT//50k/D70fdKTAkX7Z7UPfhQ eFLAaG95SXiOvON81KCw3AOta7X52bo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MjeN0CQp; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724705055; 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=vK1PMhUcFVpQCvjQRaUqQOYBcILrsdr8yUlCuFWve7Q=; b=MjeN0CQpFhyybJqWUDBzLl0VSCnEEdrkbztDtUb53F7Gu+g85RycsMkC0aGEl2xcygzlaW clJ5IR9Cg2mBDWz0ykQdXWrRwY3po08ds4dHS7ZJ/uEfgI0X+L3hpGkV1hyRg2+gvPmHWL FiNjq1/2B/aKtnGCyBXS1EoraxB06rA= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-283-5GkLVTDnO9-BIbWb5ljY5g-1; Mon, 26 Aug 2024 16:44:14 -0400 X-MC-Unique: 5GkLVTDnO9-BIbWb5ljY5g-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-6b351a76beeso102720347b3.0 for ; Mon, 26 Aug 2024 13:44:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705052; x=1725309852; 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=vK1PMhUcFVpQCvjQRaUqQOYBcILrsdr8yUlCuFWve7Q=; b=aIQHuLEUjVns9NU2ecLZwEKD18DmGL9nDfeLJhqQTMhquj1KJePRJGWRSScQHjUha2 Oe4bv3wVIytXR+qCVbed1Clf3tW+CJuQk9sMthxjb9hGj++8fyi+2ZgNUTbsFPFY2sJS R5q3hHo/Al34gD0NaAucrSPTlPiwXzBFFDHvaBO+Y+V2e7G+wp2iONQux4GA7ug7xEeB WwFF+1kSvCrHordC+zNWOl5EJupZuLo/21ZSc7MMz4wcYdjRsYZ6J0ws8m6k+JtMJAUU PUuvSrc9NHUcWHFJGdIjeT3jcjObfDmibxuQwyDLEmLzxYGqD+sDBVnLRgOvMejKfkuX T8OQ== X-Forwarded-Encrypted: i=1; AJvYcCX1piqvdaOGUURokDjrdrpnH+6Pa7I8tzP7RQd+LlFNEVSPXesv091pKAtmHk7JVxrnz3pJBeE2IA==@kvack.org X-Gm-Message-State: AOJu0Yzk2wAZFDO1G5od4lFJWn7MbX97hNSqVSt1cYsomHdsv9rmEoNn 3SA3jCIktRGAgfMNeBD2S/rMU4CnuP5N2UxlqDnI2NoHclo+5vN3b7gSj/sLygjja4KM3VKq1iT ybbChy+l3Kg0clmhAcRr8nDBRh1k1EudAlxS8PNeof6L8uwZg X-Received: by 2002:a05:690c:60c2:b0:6bd:fdd3:e170 with SMTP id 00721157ae682-6c624dc7042mr142338947b3.10.1724705052648; Mon, 26 Aug 2024 13:44:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDLUzP2hp4LBST6IRuRTdz5MRV8z70t30cnU5hPcRwmZ021NQU+FxAT+ZUF1I58Qs4qkGJLg== X-Received: by 2002:a05:690c:60c2:b0:6bd:fdd3:e170 with SMTP id 00721157ae682-6c624dc7042mr142338617b3.10.1724705052349; Mon, 26 Aug 2024 13:44:12 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f3fd6c1sm491055185a.121.2024.08.26.13.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:44:11 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gavin Shan , Catalin Marinas , x86@kernel.org, Ingo Molnar , Andrew Morton , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Alistair Popple , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sean Christopherson , peterx@redhat.com, Oscar Salvador , Jason Gunthorpe , Borislav Petkov , Zi Yan , Axel Rasmussen , David Hildenbrand , Yan Zhao , Will Deacon , Kefeng Wang , Alex Williamson Subject: [PATCH v2 08/19] mm: Always define pxx_pgprot() Date: Mon, 26 Aug 2024 16:43:42 -0400 Message-ID: <20240826204353.2228736-9-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240826204353.2228736-1-peterx@redhat.com> References: <20240826204353.2228736-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DF4F51C0017 X-Stat-Signature: uatpfa5ec8p9etspjmeo6c8ho9e7hr8e X-Rspam-User: X-HE-Tag: 1724705055-323524 X-HE-Meta: U2FsdGVkX18Vnjq0yJzN1lj/2ebYHeuOfxd+jIj2NvD7lktp5Sl5BL98NGjITlXE6ty91lSRT5cvzMe//LWF5nvsDs0wAoYjG/FzuUYMiQvk1cEbpAMWT1CTJo1cFRCxt+uo/ongul8uyLYXBLF1OWkwdzl66E8+gco2Fu1b4eezD5AdLbcSdgdQbvMf1XacBHN58GG58JRjrxEDxvcBDsPiJjvRikpGwZ2wGx/1HJy2jy1b1GEVIJYZ4y8eUzwm/9o8lFnJyBriLzzS57XkjNlBAKBMo9S/AFDc3lNQztbtzU7uZq8K9jdxR0YByEiVdul+oJQbrp9fUKdU8m4LUZbktbgorXDdUKgiwOoRykSXKID1XRBo7ovovgG+99m5KgwPM8ASY+RNxrd8eQOwiuFo+Hr28VjUyspVIszFKIfIGGHW0ConxGLfS+mreZgP2+Yd5xbc6ANQzsqmefh7aNZ/5ca5PxZPuXhEvZFbWmFgGq7sbU5YB2qLgwlzkjSSnrpYKidYjYA1hEO48TBVVUYekpowhMGFMPX3T+jN1vzkzHQfCVW0mIbJbC/D9u9ZlSM0QuXHq6DuXHzAfkAg//kuBDQaE83r/CaxQkNEBCgOCUQ58r88bCVrMxG6m9qUh/WdAjgFZKDBi/iHqpjuGl5jG6F9AxY66b/T3WVJ5sJ3LfYctRx8drr3wzg+eylUgGxtNt2zaCCXLRiXfRoO8Q7OHfznFVRL6tC8H51hoJBR1/27srNb8dtY0mJiMiv943ApgNjvz0pmPhewb3B7hvR70r0CMrNElXoNxkGlRY5ltoqiHDCgtMRbI7MamJLMt+wfty0TVPyvPrCM5Bz2mZeAK4uB034HSn9tFjiQujzyAEFS26L3piFQWQ0ELaa5Z1eqNJKgqq/aYTGGL/i0NXrClkMN1NjKjK+LZJwrePTpymZy/WEvd366S3u5Uyp+y0HBN3RwNwW9EYbAVEn MVVNto3C mPoRoCxZ8poDQwbZE4FPhTXK9kB66xYUYO6s5i69jGEMyGmZD4K1IzX2PG1TbcUjQRlnZzEDfc82lNVvVG2LFMjOplDtgdT1t7r7Wfk/I737teOZRFOypE26FMfqp+Ap//gTFVZ5yUBtO08+h/SiB6OOHRmCAYaBhgoR3v3JTVsE/9wP225GTLs263EJ2TCmEU7B5G35E6ooq+lSuI5Tfp1Mldhnx/74seYRvYV3Shhe1Um1KgE0XTVIt+330GURg2xBptgf2jZRO7v3Bk+l8gZsnOv+g8srezFn42Ezh/ALyha5RjTi/WM+PZAHltFUrwKuKLnbUHSFwRhiAPKCBo8F1oWUmnFjGXfIDqHM6s3B/mNgDuPnvK/IEzALjjeLl7czaQrgLdvnJFxMbqduu+4xVsX+6AiG27hdF 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: There're: - 8 archs (arc, arm64, include, mips, powerpc, s390, sh, x86) that support pte_pgprot(). - 2 archs (x86, sparc) that support pmd_pgprot(). - 1 arch (x86) that support pud_pgprot(). Always define them to be used in generic code, and then we don't need to fiddle with "#ifdef"s when doing so. Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu --- arch/arm64/include/asm/pgtable.h | 1 + arch/powerpc/include/asm/pgtable.h | 1 + arch/s390/include/asm/pgtable.h | 1 + arch/sparc/include/asm/pgtable_64.h | 1 + include/linux/pgtable.h | 12 ++++++++++++ 5 files changed, 16 insertions(+) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 7a4f5604be3f..b78cc4a6758b 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -384,6 +384,7 @@ static inline void __sync_cache_and_tags(pte_t pte, unsigned int nr_pages) /* * Select all bits except the pfn */ +#define pte_pgprot pte_pgprot static inline pgprot_t pte_pgprot(pte_t pte) { unsigned long pfn = pte_pfn(pte); diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 264a6c09517a..2f72ad885332 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -65,6 +65,7 @@ static inline unsigned long pte_pfn(pte_t pte) /* * Select all bits except the pfn */ +#define pte_pgprot pte_pgprot static inline pgprot_t pte_pgprot(pte_t pte) { unsigned long pte_flags; diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 3fa280d0672a..0ffbaf741955 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -955,6 +955,7 @@ static inline int pte_unused(pte_t pte) * young/old accounting is not supported, i.e _PAGE_PROTECT and _PAGE_INVALID * must not be set. */ +#define pte_pgprot pte_pgprot static inline pgprot_t pte_pgprot(pte_t pte) { unsigned long pte_flags = pte_val(pte) & _PAGE_CHG_MASK; diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 3fe429d73a65..2b7f358762c1 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -783,6 +783,7 @@ static inline pmd_t pmd_mkwrite_novma(pmd_t pmd) return __pmd(pte_val(pte)); } +#define pmd_pgprot pmd_pgprot static inline pgprot_t pmd_pgprot(pmd_t entry) { unsigned long val = pmd_val(entry); diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 780f3b439d98..e8b2ac6bd2ae 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1956,6 +1956,18 @@ typedef unsigned int pgtbl_mod_mask; #define MAX_PTRS_PER_P4D PTRS_PER_P4D #endif +#ifndef pte_pgprot +#define pte_pgprot(x) ((pgprot_t) {0}) +#endif + +#ifndef pmd_pgprot +#define pmd_pgprot(x) ((pgprot_t) {0}) +#endif + +#ifndef pud_pgprot +#define pud_pgprot(x) ((pgprot_t) {0}) +#endif + /* description of effects of mapping type and prot in current implementation. * this is due to the limited x86 page protection hardware. The expected * behavior is in parens: