From: Arnd Bergmann <arnd@kernel.org>
To: Dave Hansen <dave.hansen@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Nikolay Borisov <nik.borisov@suse.com>,
linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 2/3] x86/devmem: remove phys_mem_access_prot_allowed()
Date: Tue, 20 May 2025 17:20:29 +0200 [thread overview]
Message-ID: <20250520152030.1499670-2-arnd@kernel.org> (raw)
In-Reply-To: <20250520152030.1499670-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
phys_mem_access_prot_allowed() was originally a workaround for
certain 32-bit CPUs, but after commit 1886297ce0c8 ("x86/mm/pat:
Fix BUG_ON() in mmap_mem() on QEMU/i386"), it no longer does anything
special as the only remaining bit now is the same logic that follows in
phys_mem_access_prot(), mapping everything as normal memory except when
either O_DSYNC is set or the address is highmem.
Just remove the thing entirely.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/x86/mm/pat/memtype.c | 15 ---------------
drivers/char/mem.c | 10 ----------
include/linux/pgtable.h | 2 --
3 files changed, 27 deletions(-)
diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index fe24b8d2dc4b..fec14f1f53a6 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -781,21 +781,6 @@ static inline void pgprot_set_cachemode(pgprot_t *prot, enum page_cache_mode pcm
cachemode2protval(pcm));
}
-int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
- unsigned long size, pgprot_t *vma_prot)
-{
- enum page_cache_mode pcm = _PAGE_CACHE_MODE_WB;
-
- if (!pat_enabled())
- return 1;
-
- if (file->f_flags & O_DSYNC)
- pcm = _PAGE_CACHE_MODE_UC_MINUS;
-
- pgprot_set_cachemode(vma_prot, pcm);
- return 1;
-}
-
/*
* Change the memory type for the physical address range in kernel identity
* mapping space if that range is a part of identity map.
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 85f963ce3b2d..30a5c0e0542a 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -256,12 +256,6 @@ static ssize_t write_mem(struct file *file, const char __user *buf,
return written;
}
-int __weak phys_mem_access_prot_allowed(struct file *file,
- unsigned long pfn, unsigned long size, pgprot_t *vma_prot)
-{
- return 1;
-}
-
#ifndef __HAVE_PHYS_MEM_ACCESS_PROT
/*
@@ -387,10 +381,6 @@ static int mmap_mem(struct file *file, struct vm_area_struct *vma)
if (!range_is_allowed(vma->vm_pgoff, size))
return -EPERM;
- if (!phys_mem_access_prot_allowed(file, vma->vm_pgoff, size,
- &vma->vm_page_prot))
- return -EINVAL;
-
vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
size,
vma->vm_page_prot);
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index adbebe2c6ce4..15b5a6b0943f 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -1764,8 +1764,6 @@ static inline int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
#endif
struct file;
-int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
- unsigned long size, pgprot_t *vma_prot);
#ifndef CONFIG_X86_ESPFIX64
static inline void init_espfix_bsp(void) { }
--
2.39.5
next prev parent reply other threads:[~2025-05-20 15:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 15:20 [PATCH 1/3] x86/devmem: move range_is_allowed() to drivers/char/mem.c Arnd Bergmann
2025-05-20 15:20 ` Arnd Bergmann [this message]
2025-05-21 22:08 ` [PATCH 2/3] x86/devmem: remove phys_mem_access_prot_allowed() Dan Williams
2025-05-20 15:20 ` [PATCH 3/3] [RFC] x86/devmem: remove low 1MB hack for x86-64 Arnd Bergmann
2025-05-21 22:14 ` Dan Williams
2025-05-22 12:24 ` Arnd Bergmann
2025-06-03 18:18 ` Dan Williams
2025-06-03 19:25 ` Arnd Bergmann
2025-06-03 19:36 ` Dan Williams
2025-06-11 14:18 ` Naveen N Rao
2025-05-21 22:05 ` [PATCH 1/3] x86/devmem: move range_is_allowed() to drivers/char/mem.c Dan Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250520152030.1499670-2-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=nik.borisov@suse.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.