mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
Remove get_kernel_pages()
Vmalloc page support is removed from shm_get_kernel_pages() and the
get_kernel_pages() call is replaced by calls to get_page(). With no
remaining callers of get_kernel_pages() the function is removed.
-----BEGIN PGP SIGNATURE-----
iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmPygGcaHGplbnMud2lr
bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJdBWhAA0jwMI/NL5lfR+T8X2uEK
yzuPcX5UFBWLsVgSgiNREyskuA1ZCa5qVp+0o022DiBuuUHQB+kkCuhlLKwzsYsj
droqi5nv3+RjjnHiHX+LvI8G9GCfyY9aWwh4RmpDck5Ugpp/tFBSfJToGRtVWpin
s3plUGBsSrt5Xo7Ao9cDb0u7iwnFi18i22jyTpPC3PuZoZRnUcIG4tXnvEurMNxC
+Go57WejPls3NdXGYWM/vKCt2qRHphCr3w22Q7ljxasBSxbiscRI4K+YaAISefvC
/29XR7Apd52+DsDMyJWyEJpoU1HL0NP8RLYqZJEJOYQMv6YzNtXKOQLCD7Pebnbb
3A98JRdpUzn9KY8c43+SlPSMusd+L8HO+9Aw058sCW+3UDEaJ4wi0gLVZr15g8WK
u4qM3vYQywoc6ES9dxeDv9xkepiwK/qKfhk0XvK7gr5SuXo2ewscknpf/oGiz9wm
9b19x3tJH9X4iII4Mi4zVmly+LE2xIue1hDMI9Uh6wKfo8oDb1sNQWPTDLNNYQdw
iorFWC9FNCklrxCVeeXxcAhL5gI6MebXcqpCCbzFYM3wdWf7844PfP6KC67230Pr
Q4D+deTc6tqFy1Uf79iTC4DbGnNRN2+tq7mMwooID5Jxk80L4YpfzKFWaiRwfO8q
XbtI7NfI9VP3UJ70iD7LUHg=
=eenJ
-----END PGP SIGNATURE-----
Merge tag 'remove-get_kernel_pages-for-6.3' of https://git.linaro.org/people/jens.wiklander/linux-tee
Pull TEE update from Jens Wiklander:
"Remove get_kernel_pages()
Vmalloc page support is removed from shm_get_kernel_pages() and the
get_kernel_pages() call is replaced by calls to get_page(). With no
remaining callers of get_kernel_pages() the function is removed"
[ This looks like it's just some random 'tee' cleanup, but the bigger
picture impetus for this is really to to to remove historical
confusion with mixed use of kernel virtual addresses and 'struct page'
pointers.
Kernel virtual pointers in the vmalloc space is then particularly
confusing - both for looking up a page pointer (when trying to then
unify a "virtual address or page" interface) and _particularly_ when
mixed with HIGHMEM support and the kmap*() family of remapping.
This is particularly true with HIGHMEM getting much less test coverage
with 32-bit architectures being increasingly legacy targets.
So we actively wanted to remove get_kernel_pages() to make sure nobody
else used it too, and thus the 'tee' part is "finally remove last
user".
See also commit 6647e76ab6
("v4l2: don't fall back to follow_pfn()
if pin_user_pages_fast() fails") for a totally different version of a
conceptually similar "let's stop this confusion of different ways of
referring to memory". - Linus ]
* tag 'remove-get_kernel_pages-for-6.3' of https://git.linaro.org/people/jens.wiklander/linux-tee:
mm: Remove get_kernel_pages()
tee: Remove call to get_kernel_pages()
tee: Remove vmalloc page support
highmem: Enhance is_kmap_addr() to check kmap_local_page() mappings
This commit is contained in:
commit
d644c670ef
@ -11,6 +11,7 @@
|
||||
#include <linux/tee_drv.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/uio.h>
|
||||
#include <linux/highmem.h>
|
||||
#include "tee_private.h"
|
||||
|
||||
static void shm_put_kernel_pages(struct page **pages, size_t page_count)
|
||||
@ -24,38 +25,20 @@ static void shm_put_kernel_pages(struct page **pages, size_t page_count)
|
||||
static int shm_get_kernel_pages(unsigned long start, size_t page_count,
|
||||
struct page **pages)
|
||||
{
|
||||
struct page *page;
|
||||
size_t n;
|
||||
int rc;
|
||||
|
||||
if (is_vmalloc_addr((void *)start)) {
|
||||
struct page *page;
|
||||
if (WARN_ON_ONCE(is_vmalloc_addr((void *)start) ||
|
||||
is_kmap_addr((void *)start)))
|
||||
return -EINVAL;
|
||||
|
||||
for (n = 0; n < page_count; n++) {
|
||||
page = vmalloc_to_page((void *)(start + PAGE_SIZE * n));
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
|
||||
get_page(page);
|
||||
pages[n] = page;
|
||||
}
|
||||
rc = page_count;
|
||||
} else {
|
||||
struct kvec *kiov;
|
||||
|
||||
kiov = kcalloc(page_count, sizeof(*kiov), GFP_KERNEL);
|
||||
if (!kiov)
|
||||
return -ENOMEM;
|
||||
|
||||
for (n = 0; n < page_count; n++) {
|
||||
kiov[n].iov_base = (void *)(start + n * PAGE_SIZE);
|
||||
kiov[n].iov_len = PAGE_SIZE;
|
||||
}
|
||||
|
||||
rc = get_kernel_pages(kiov, page_count, 0, pages);
|
||||
kfree(kiov);
|
||||
page = virt_to_page(start);
|
||||
for (n = 0; n < page_count; n++) {
|
||||
pages[n] = page + n;
|
||||
get_page(pages[n]);
|
||||
}
|
||||
|
||||
return rc;
|
||||
return page_count;
|
||||
}
|
||||
|
||||
static void release_registered_pages(struct tee_shm *shm)
|
||||
|
@ -152,7 +152,10 @@ static inline void totalhigh_pages_add(long count)
|
||||
static inline bool is_kmap_addr(const void *x)
|
||||
{
|
||||
unsigned long addr = (unsigned long)x;
|
||||
return addr >= PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP);
|
||||
|
||||
return (addr >= PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP)) ||
|
||||
(addr >= __fix_to_virt(FIX_KMAP_END) &&
|
||||
addr < __fix_to_virt(FIX_KMAP_BEGIN));
|
||||
}
|
||||
#else /* CONFIG_HIGHMEM */
|
||||
|
||||
|
@ -2101,8 +2101,6 @@ int __account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc,
|
||||
struct task_struct *task, bool bypass_rlim);
|
||||
|
||||
struct kvec;
|
||||
int get_kernel_pages(const struct kvec *iov, int nr_pages, int write,
|
||||
struct page **pages);
|
||||
struct page *get_dump_page(unsigned long addr);
|
||||
|
||||
bool folio_mark_dirty(struct folio *folio);
|
||||
|
30
mm/swap.c
30
mm/swap.c
@ -158,36 +158,6 @@ void put_pages_list(struct list_head *pages)
|
||||
}
|
||||
EXPORT_SYMBOL(put_pages_list);
|
||||
|
||||
/*
|
||||
* get_kernel_pages() - pin kernel pages in memory
|
||||
* @kiov: An array of struct kvec structures
|
||||
* @nr_segs: number of segments to pin
|
||||
* @write: pinning for read/write, currently ignored
|
||||
* @pages: array that receives pointers to the pages pinned.
|
||||
* Should be at least nr_segs long.
|
||||
*
|
||||
* Returns number of pages pinned. This may be fewer than the number requested.
|
||||
* If nr_segs is 0 or negative, returns 0. If no pages were pinned, returns 0.
|
||||
* Each page returned must be released with a put_page() call when it is
|
||||
* finished with.
|
||||
*/
|
||||
int get_kernel_pages(const struct kvec *kiov, int nr_segs, int write,
|
||||
struct page **pages)
|
||||
{
|
||||
int seg;
|
||||
|
||||
for (seg = 0; seg < nr_segs; seg++) {
|
||||
if (WARN_ON(kiov[seg].iov_len != PAGE_SIZE))
|
||||
return seg;
|
||||
|
||||
pages[seg] = kmap_to_page(kiov[seg].iov_base);
|
||||
get_page(pages[seg]);
|
||||
}
|
||||
|
||||
return seg;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(get_kernel_pages);
|
||||
|
||||
typedef void (*move_fn_t)(struct lruvec *lruvec, struct folio *folio);
|
||||
|
||||
static void lru_add_fn(struct lruvec *lruvec, struct folio *folio)
|
||||
|
Loading…
Reference in New Issue
Block a user