From patchwork Fri Aug 9 16:08:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13758933 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 3D0DDC52D7C for ; Fri, 9 Aug 2024 16:09:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FCDB6B00A7; Fri, 9 Aug 2024 12:09:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 436516B00A8; Fri, 9 Aug 2024 12:09:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23B5E6B00AA; Fri, 9 Aug 2024 12:09:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E613E6B00A7 for ; Fri, 9 Aug 2024 12:09:37 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9CE27160F9A for ; Fri, 9 Aug 2024 16:09:37 +0000 (UTC) X-FDA: 82433192394.26.468F66A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 8E4D34000C for ; Fri, 9 Aug 2024 16:09:35 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Gth6H0Ji; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723219721; a=rsa-sha256; cv=none; b=Se5Ww7B0ZVAIjVm6ZHGNknkSPmr7WVsrShVlsgMAnJnZkW2NSmOpACxH/qHhKgOB9/gxmq RECg18UZRLWZnuLOXfW+POTp9bgEGFUgaaI9RvzlBJTQuMKjGC614oR/ce4++WLp1HnZOX p+YzslIOVZIkesm8tefH03LzE6+64Zc= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Gth6H0Ji; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.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=1723219721; 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=3aM3oVPeXmFPFf4Q68bjufzjsUq2ESmscQPnLEkaBB8=; b=MaQJEdVNEHM6ZdWjEm1HA+tL3XO/diJZpqcaYvD1tpK2q/NKqbCoyNNbK+HjK65eA+ZM5t gJ90FER6fXNsEPqaU4bFwBmUTvQbROPZiK+AQe26bdAT4yJhTyxphtRsfQYEbmF+dW9GzS PWt58PP72gxLATnm02n+riyntfrVB88= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723219774; 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=3aM3oVPeXmFPFf4Q68bjufzjsUq2ESmscQPnLEkaBB8=; b=Gth6H0JiQmUa8JZCcN9EQQ4jGMoDek3jzRrpm7yccOdxJ2dcj/2xCrQIsPWVsOb8zIQcUc 3UNr9ELVDTKlsc6cTCYFqgalUjdEjHya6cuvgLql25OW6DiiXOwpn2N1Wb8lxre4wtt+ts omVi9S15ZmZbdyWjRSRSnLA04AOLiIo= 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-218-4OQMLml-M5yGbcJ7ato0iA-1; Fri, 09 Aug 2024 12:09:33 -0400 X-MC-Unique: 4OQMLml-M5yGbcJ7ato0iA-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-45009e27b83so4905411cf.1 for ; Fri, 09 Aug 2024 09:09:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723219773; x=1723824573; 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=3aM3oVPeXmFPFf4Q68bjufzjsUq2ESmscQPnLEkaBB8=; b=hlQ3THaxKTDNA+P+saUnvQrab6De0EqkJu6zY8L+MNk2c/l7jIJv464BXzq7e/d/1f N6R+o1syVjWCqxtRfrvEvBf8qwbH3O3IWE7JKquvRoBgiyef8qhow9QXLF7vvY3A4hNk PlpvTH4NH0/udGqjMCa2axQpiYMHDeZgmWdB4GuyvVa80W6FvlzG7O09kuASSrcWmTBg fd8EnWVMLm76IGHe6ua9k8jlmGXGRUKlAf5Ptj2Towpt1uHLOo5EqAa5P7Zj72yL0stE 9Z+vg+O3gyYQqo37ecpOBh9dyy6456hNouDPFE9Hu24Y05nqTpw2Ot4xbdZQ6IkMKK5C 4zlQ== X-Gm-Message-State: AOJu0YxSMlIzk+Y9Unf8UjkO5Y2WQHT8i85mLYThb0h3ZasJ/puiUxKc W6+ycX+oG6BedYvVdttl9ruMyRYZ+deKOHPFn1Poq8pBPHoGZM5TY/eWo1niub1fNWhAWXAOLee 2WSVxi+PEfyva1Ykh4knvk2zaWtxnCQU9+2hGEI25yWSNGeIho4PjEJqbVjYmHgbeBYPYknC6aU OGWGLmeGbXjLqRCPWAca8MSpO2N3z+dtYg X-Received: by 2002:ac8:5f10:0:b0:450:349:1170 with SMTP id d75a77b69052e-4531255c62dmr14739881cf.6.1723219773131; Fri, 09 Aug 2024 09:09:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6GyuXgyukqToIMYwmYCyyJms6T0RBSwsqvRpSKO6DWSQsB926zH9/mqcqwcpfSE6Nqd5Tsw== X-Received: by 2002:ac8:5f10:0:b0:450:349:1170 with SMTP id d75a77b69052e-4531255c62dmr14739431cf.6.1723219772696; Fri, 09 Aug 2024 09:09:32 -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 d75a77b69052e-451c870016csm22526741cf.19.2024.08.09.09.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 09:09:32 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Sean Christopherson , Oscar Salvador , Jason Gunthorpe , Axel Rasmussen , linux-arm-kernel@lists.infradead.org, x86@kernel.org, peterx@redhat.com, Will Deacon , Gavin Shan , Paolo Bonzini , Zi Yan , Andrew Morton , Catalin Marinas , Ingo Molnar , Alistair Popple , Borislav Petkov , David Hildenbrand , Thomas Gleixner , kvm@vger.kernel.org, Dave Hansen , Alex Williamson , Yan Zhao Subject: [PATCH 08/19] mm: Always define pxx_pgprot() Date: Fri, 9 Aug 2024 12:08:58 -0400 Message-ID: <20240809160909.1023470-9-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240809160909.1023470-1-peterx@redhat.com> References: <20240809160909.1023470-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8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bKYfXj4SGjGK4vJjvm6KeRT2fjL5JOjv/b4RXoToRv1zBl/eNU0ZljncWJs2L9TBLYOBfgXFixGJo6qOvi2+pah4CqpqNknm+TdL2V92LmBKP5/hvXQZFxi0G5meGcHaHpLrxXC1nxQGIv1m+l7imeU5a0KHt068GJ6FcdG/YGeZ1DWoq2TW6vrS7m5CLUJLRNXliqehVLYbjCfg7iQJGohL9fEXLDaNvBw6uwrtCB3Q0+Qs+KCdAvUikPThS4jiQezhtb7Mz5aomtCi1TgDtn3NfPCaIbXa9HTEP2TxuMzoHJMF9So8t9RiqcCArnrp9BvG9TzuDOtql9N6v/AqD/EjfvHPOTAqSs+bQ02r2QkOFsTb8deKfWkBT3DH9ftqHl4za29OU5qVJTkSEhjjzB7Lk7lXy/jvMW/RuXih9OhW3Y0j89WJvqWnttuCzq9vwElxZsUnR9lC29Aqgg7OLFSZ5DDhWrjC4fxhljjB7iL5S9quW/Z3N4n 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. Signed-off-by: Peter Xu Reviewed-by: Jason Gunthorpe --- 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: