Skip to content

Commit af709ad

Browse files
committed
Merge tag 'mm-hotfixes-stable-2024-04-05-11-30' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "8 hotfixes, 3 are cc:stable There are a couple of fixups for this cycle's vmalloc changes and one for the stackdepot changes. And a fix for a very old x86 PAT issue which can cause a warning splat" * tag 'mm-hotfixes-stable-2024-04-05-11-30' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: stackdepot: rename pool_index to pool_index_plus_1 x86/mm/pat: fix VM_PAT handling in COW mappings MAINTAINERS: change vmware.com addresses to broadcom.com selftests/mm: include strings.h for ffsl mm: vmalloc: fix lockdep warning mm: vmalloc: bail out early in find_vmap_area() if vmap is not init init: open output files from cpio unpacking with O_LARGEFILE mm/secretmem: fix GUP-fast succeeding on secretmem folios
2 parents c783023 + a6c1d9c commit af709ad

File tree

10 files changed

+122
-76
lines changed

10 files changed

+122
-76
lines changed

.mailmap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Adam Oldham <[email protected]>
2020
Adam Radford <[email protected]>
2121
2222
Adrian Bunk <[email protected]>
23+
2324
2425
2526
@@ -36,6 +37,7 @@ Alexei Avshalom Lazar <[email protected]> <[email protected]>
3637
Alexei Starovoitov <[email protected]> <[email protected]>
3738
Alexei Starovoitov <[email protected]> <[email protected]>
3839
Alexei Starovoitov <[email protected]> <[email protected]>
40+
3941
4042
4143
@@ -110,6 +112,7 @@ Brendan Higgins <[email protected]> <[email protected]>
110112
Brian Avery <[email protected]>
111113
Brian King <[email protected]>
112114
115+
113116
114117
115118
@@ -529,6 +532,7 @@ Rocky Liao <[email protected]> <[email protected]>
529532
530533
531534
535+
532536
533537
534538
@@ -651,6 +655,7 @@ Viresh Kumar <[email protected]> <[email protected]>
651655
652656
653657
658+
654659
655660
656661

MAINTAINERS

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16733,9 +16733,9 @@ F: include/uapi/linux/ppdev.h
1673316733

1673416734
PARAVIRT_OPS INTERFACE
1673516735
M: Juergen Gross <[email protected]>
16736-
R: Ajay Kaher <akaher@vmware.com>
16737-
R: Alexey Makhalov <amakhalov@vmware.com>
16738-
R: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
16736+
R: Ajay Kaher <ajay.kaher@broadcom.com>
16737+
R: Alexey Makhalov <alexey.amakhalov@broadcom.com>
16738+
R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
1673916739
1674016740
1674116741
S: Supported
@@ -23654,9 +23654,9 @@ S: Supported
2365423654
F: drivers/misc/vmw_balloon.c
2365523655

2365623656
VMWARE HYPERVISOR INTERFACE
23657-
M: Ajay Kaher <akaher@vmware.com>
23658-
M: Alexey Makhalov <amakhalov@vmware.com>
23659-
R: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
23657+
M: Ajay Kaher <ajay.kaher@broadcom.com>
23658+
M: Alexey Makhalov <alexey.amakhalov@broadcom.com>
23659+
R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
2366023660
2366123661
2366223662
S: Supported
@@ -23665,33 +23665,34 @@ F: arch/x86/include/asm/vmware.h
2366523665
F: arch/x86/kernel/cpu/vmware.c
2366623666

2366723667
VMWARE PVRDMA DRIVER
23668-
M: Bryan Tan <bryantan@vmware.com>
23669-
M: Vishnu Dasa <vdasa@vmware.com>
23670-
R: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
23668+
M: Bryan Tan <bryan-bt.tan@broadcom.com>
23669+
M: Vishnu Dasa <vishnu.dasa@broadcom.com>
23670+
R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
2367123671
2367223672
S: Supported
2367323673
F: drivers/infiniband/hw/vmw_pvrdma/
2367423674

2367523675
VMWARE PVSCSI DRIVER
23676-
M: Vishal Bhakta <vbhakta@vmware.com>
23677-
R: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
23676+
M: Vishal Bhakta <vishal.bhakta@broadcom.com>
23677+
R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
2367823678
2367923679
S: Supported
2368023680
F: drivers/scsi/vmw_pvscsi.c
2368123681
F: drivers/scsi/vmw_pvscsi.h
2368223682

2368323683
VMWARE VIRTUAL PTP CLOCK DRIVER
23684-
R: Ajay Kaher <[email protected]>
23685-
R: Alexey Makhalov <[email protected]>
23686-
R: VMware PV-Drivers Reviewers <[email protected]>
23684+
M: Nick Shi <[email protected]>
23685+
R: Ajay Kaher <[email protected]>
23686+
R: Alexey Makhalov <[email protected]>
23687+
R: Broadcom internal kernel review list <[email protected]>
2368723688
2368823689
S: Supported
2368923690
F: drivers/ptp/ptp_vmw.c
2369023691

2369123692
VMWARE VMCI DRIVER
23692-
M: Bryan Tan <bryantan@vmware.com>
23693-
M: Vishnu Dasa <vdasa@vmware.com>
23694-
R: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
23693+
M: Bryan Tan <bryan-bt.tan@broadcom.com>
23694+
M: Vishnu Dasa <vishnu.dasa@broadcom.com>
23695+
R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
2369523696
2369623697
S: Supported
2369723698
F: drivers/misc/vmw_vmci/
@@ -23706,16 +23707,16 @@ F: drivers/input/mouse/vmmouse.c
2370623707
F: drivers/input/mouse/vmmouse.h
2370723708

2370823709
VMWARE VMXNET3 ETHERNET DRIVER
23709-
M: Ronak Doshi <doshir@vmware.com>
23710-
R: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
23710+
M: Ronak Doshi <ronak.doshi@broadcom.com>
23711+
R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
2371123712
2371223713
S: Supported
2371323714
F: drivers/net/vmxnet3/
2371423715

2371523716
VMWARE VSOCK VMCI TRANSPORT DRIVER
23716-
M: Bryan Tan <bryantan@vmware.com>
23717-
M: Vishnu Dasa <vdasa@vmware.com>
23718-
R: VMware PV-Drivers Reviewers <pv-drivers@vmware.com>
23717+
M: Bryan Tan <bryan-bt.tan@broadcom.com>
23718+
M: Vishnu Dasa <vishnu.dasa@broadcom.com>
23719+
R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
2371923720
2372023721
S: Supported
2372123722
F: net/vmw_vsock/vmci_transport*

arch/x86/mm/pat/memtype.c

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,38 @@ static void free_pfn_range(u64 paddr, unsigned long size)
947947
memtype_free(paddr, paddr + size);
948948
}
949949

950+
static int get_pat_info(struct vm_area_struct *vma, resource_size_t *paddr,
951+
pgprot_t *pgprot)
952+
{
953+
unsigned long prot;
954+
955+
VM_WARN_ON_ONCE(!(vma->vm_flags & VM_PAT));
956+
957+
/*
958+
* We need the starting PFN and cachemode used for track_pfn_remap()
959+
* that covered the whole VMA. For most mappings, we can obtain that
960+
* information from the page tables. For COW mappings, we might now
961+
* suddenly have anon folios mapped and follow_phys() will fail.
962+
*
963+
* Fallback to using vma->vm_pgoff, see remap_pfn_range_notrack(), to
964+
* detect the PFN. If we need the cachemode as well, we're out of luck
965+
* for now and have to fail fork().
966+
*/
967+
if (!follow_phys(vma, vma->vm_start, 0, &prot, paddr)) {
968+
if (pgprot)
969+
*pgprot = __pgprot(prot);
970+
return 0;
971+
}
972+
if (is_cow_mapping(vma->vm_flags)) {
973+
if (pgprot)
974+
return -EINVAL;
975+
*paddr = (resource_size_t)vma->vm_pgoff << PAGE_SHIFT;
976+
return 0;
977+
}
978+
WARN_ON_ONCE(1);
979+
return -EINVAL;
980+
}
981+
950982
/*
951983
* track_pfn_copy is called when vma that is covering the pfnmap gets
952984
* copied through copy_page_range().
@@ -957,20 +989,13 @@ static void free_pfn_range(u64 paddr, unsigned long size)
957989
int track_pfn_copy(struct vm_area_struct *vma)
958990
{
959991
resource_size_t paddr;
960-
unsigned long prot;
961992
unsigned long vma_size = vma->vm_end - vma->vm_start;
962993
pgprot_t pgprot;
963994

964995
if (vma->vm_flags & VM_PAT) {
965-
/*
966-
* reserve the whole chunk covered by vma. We need the
967-
* starting address and protection from pte.
968-
*/
969-
if (follow_phys(vma, vma->vm_start, 0, &prot, &paddr)) {
970-
WARN_ON_ONCE(1);
996+
if (get_pat_info(vma, &paddr, &pgprot))
971997
return -EINVAL;
972-
}
973-
pgprot = __pgprot(prot);
998+
/* reserve the whole chunk covered by vma. */
974999
return reserve_pfn_range(paddr, vma_size, &pgprot, 1);
9751000
}
9761001

@@ -1045,19 +1070,15 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn,
10451070
unsigned long size, bool mm_wr_locked)
10461071
{
10471072
resource_size_t paddr;
1048-
unsigned long prot;
10491073

10501074
if (vma && !(vma->vm_flags & VM_PAT))
10511075
return;
10521076

10531077
/* free the chunk starting from pfn or the whole chunk */
10541078
paddr = (resource_size_t)pfn << PAGE_SHIFT;
10551079
if (!paddr && !size) {
1056-
if (follow_phys(vma, vma->vm_start, 0, &prot, &paddr)) {
1057-
WARN_ON_ONCE(1);
1080+
if (get_pat_info(vma, &paddr, NULL))
10581081
return;
1059-
}
1060-
10611082
size = vma->vm_end - vma->vm_start;
10621083
}
10631084
free_pfn_range(paddr, size);

include/linux/secretmem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ static inline bool folio_is_secretmem(struct folio *folio)
1313
/*
1414
* Using folio_mapping() is quite slow because of the actual call
1515
* instruction.
16-
* We know that secretmem pages are not compound and LRU so we can
16+
* We know that secretmem pages are not compound, so we can
1717
* save a couple of cycles here.
1818
*/
19-
if (folio_test_large(folio) || !folio_test_lru(folio))
19+
if (folio_test_large(folio))
2020
return false;
2121

2222
mapping = (struct address_space *)

include/linux/stackdepot.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ typedef u32 depot_stack_handle_t;
4444
union handle_parts {
4545
depot_stack_handle_t handle;
4646
struct {
47-
/* pool_index is offset by 1 */
48-
u32 pool_index : DEPOT_POOL_INDEX_BITS;
49-
u32 offset : DEPOT_OFFSET_BITS;
50-
u32 extra : STACK_DEPOT_EXTRA_BITS;
47+
u32 pool_index_plus_1 : DEPOT_POOL_INDEX_BITS;
48+
u32 offset : DEPOT_OFFSET_BITS;
49+
u32 extra : STACK_DEPOT_EXTRA_BITS;
5150
};
5251
};
5352

init/initramfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static int __init do_name(void)
367367
if (S_ISREG(mode)) {
368368
int ml = maybe_link();
369369
if (ml >= 0) {
370-
int openflags = O_WRONLY|O_CREAT;
370+
int openflags = O_WRONLY|O_CREAT|O_LARGEFILE;
371371
if (ml != 1)
372372
openflags |= O_TRUNC;
373373
wfile = filp_open(collected, openflags, mode);

lib/stackdepot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static struct stack_record *depot_pop_free_pool(void **prealloc, size_t size)
330330
stack = current_pool + pool_offset;
331331

332332
/* Pre-initialize handle once. */
333-
stack->handle.pool_index = pool_index + 1;
333+
stack->handle.pool_index_plus_1 = pool_index + 1;
334334
stack->handle.offset = pool_offset >> DEPOT_STACK_ALIGN;
335335
stack->handle.extra = 0;
336336
INIT_LIST_HEAD(&stack->hash_list);
@@ -441,7 +441,7 @@ static struct stack_record *depot_fetch_stack(depot_stack_handle_t handle)
441441
const int pools_num_cached = READ_ONCE(pools_num);
442442
union handle_parts parts = { .handle = handle };
443443
void *pool;
444-
u32 pool_index = parts.pool_index - 1;
444+
u32 pool_index = parts.pool_index_plus_1 - 1;
445445
size_t offset = parts.offset << DEPOT_STACK_ALIGN;
446446
struct stack_record *stack;
447447

mm/memory.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5973,6 +5973,10 @@ int follow_phys(struct vm_area_struct *vma,
59735973
goto out;
59745974
pte = ptep_get(ptep);
59755975

5976+
/* Never return PFNs of anon folios in COW mappings. */
5977+
if (vm_normal_folio(vma, address, pte))
5978+
goto unlock;
5979+
59765980
if ((flags & FOLL_WRITE) && !pte_write(pte))
59775981
goto unlock;
59785982

mm/vmalloc.c

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,27 @@ unsigned long vmalloc_nr_pages(void)
989989
return atomic_long_read(&nr_vmalloc_pages);
990990
}
991991

992+
static struct vmap_area *__find_vmap_area(unsigned long addr, struct rb_root *root)
993+
{
994+
struct rb_node *n = root->rb_node;
995+
996+
addr = (unsigned long)kasan_reset_tag((void *)addr);
997+
998+
while (n) {
999+
struct vmap_area *va;
1000+
1001+
va = rb_entry(n, struct vmap_area, rb_node);
1002+
if (addr < va->va_start)
1003+
n = n->rb_left;
1004+
else if (addr >= va->va_end)
1005+
n = n->rb_right;
1006+
else
1007+
return va;
1008+
}
1009+
1010+
return NULL;
1011+
}
1012+
9921013
/* Look up the first VA which satisfies addr < va_end, NULL if none. */
9931014
static struct vmap_area *
9941015
__find_vmap_area_exceed_addr(unsigned long addr, struct rb_root *root)
@@ -1025,47 +1046,39 @@ __find_vmap_area_exceed_addr(unsigned long addr, struct rb_root *root)
10251046
static struct vmap_node *
10261047
find_vmap_area_exceed_addr_lock(unsigned long addr, struct vmap_area **va)
10271048
{
1028-
struct vmap_node *vn, *va_node = NULL;
1029-
struct vmap_area *va_lowest;
1049+
unsigned long va_start_lowest;
1050+
struct vmap_node *vn;
10301051
int i;
10311052

1032-
for (i = 0; i < nr_vmap_nodes; i++) {
1053+
repeat:
1054+
for (i = 0, va_start_lowest = 0; i < nr_vmap_nodes; i++) {
10331055
vn = &vmap_nodes[i];
10341056

10351057
spin_lock(&vn->busy.lock);
1036-
va_lowest = __find_vmap_area_exceed_addr(addr, &vn->busy.root);
1037-
if (va_lowest) {
1038-
if (!va_node || va_lowest->va_start < (*va)->va_start) {
1039-
if (va_node)
1040-
spin_unlock(&va_node->busy.lock);
1041-
1042-
*va = va_lowest;
1043-
va_node = vn;
1044-
continue;
1045-
}
1046-
}
1058+
*va = __find_vmap_area_exceed_addr(addr, &vn->busy.root);
1059+
1060+
if (*va)
1061+
if (!va_start_lowest || (*va)->va_start < va_start_lowest)
1062+
va_start_lowest = (*va)->va_start;
10471063
spin_unlock(&vn->busy.lock);
10481064
}
10491065

1050-
return va_node;
1051-
}
1052-
1053-
static struct vmap_area *__find_vmap_area(unsigned long addr, struct rb_root *root)
1054-
{
1055-
struct rb_node *n = root->rb_node;
1066+
/*
1067+
* Check if found VA exists, it might have gone away. In this case we
1068+
* repeat the search because a VA has been removed concurrently and we
1069+
* need to proceed to the next one, which is a rare case.
1070+
*/
1071+
if (va_start_lowest) {
1072+
vn = addr_to_node(va_start_lowest);
10561073

1057-
addr = (unsigned long)kasan_reset_tag((void *)addr);
1074+
spin_lock(&vn->busy.lock);
1075+
*va = __find_vmap_area(va_start_lowest, &vn->busy.root);
10581076

1059-
while (n) {
1060-
struct vmap_area *va;
1077+
if (*va)
1078+
return vn;
10611079

1062-
va = rb_entry(n, struct vmap_area, rb_node);
1063-
if (addr < va->va_start)
1064-
n = n->rb_left;
1065-
else if (addr >= va->va_end)
1066-
n = n->rb_right;
1067-
else
1068-
return va;
1080+
spin_unlock(&vn->busy.lock);
1081+
goto repeat;
10691082
}
10701083

10711084
return NULL;
@@ -2343,6 +2356,9 @@ struct vmap_area *find_vmap_area(unsigned long addr)
23432356
struct vmap_area *va;
23442357
int i, j;
23452358

2359+
if (unlikely(!vmap_initialized))
2360+
return NULL;
2361+
23462362
/*
23472363
* An addr_to_node_id(addr) converts an address to a node index
23482364
* where a VA is located. If VA spans several zones and passed

tools/testing/selftests/mm/vm_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <stdbool.h>
44
#include <sys/mman.h>
55
#include <err.h>
6-
#include <string.h> /* ffsl() */
6+
#include <strings.h> /* ffsl() */
77
#include <unistd.h> /* _SC_PAGESIZE */
88

99
#define BIT_ULL(nr) (1ULL << (nr))

0 commit comments

Comments
 (0)