Skip to content

Commit 8fe3cca

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge fixes from Andrew Morton: "26 fixes" * emailed patches from Andrew Morton <[email protected]>: (26 commits) userfaultfd: remove wrong comment from userfaultfd_ctx_get() fat: fix using uninitialized fields of fat_inode/fsinfo_inode sh: cayman: IDE support fix kasan: fix races in quarantine_remove_cache() kasan: resched in quarantine_remove_cache() mm: do not call mem_cgroup_free() from within mem_cgroup_alloc() thp: fix another corner case of munlock() vs. THPs rmap: fix NULL-pointer dereference on THP munlocking mm/memblock.c: fix memblock_next_valid_pfn() userfaultfd: selftest: vm: allow to build in vm/ directory userfaultfd: non-cooperative: userfaultfd_remove revalidate vma in MADV_DONTNEED userfaultfd: non-cooperative: fix fork fctx->new memleak mm/cgroup: avoid panic when init with low memory drivers/md/bcache/util.h: remove duplicate inclusion of blkdev.h mm/vmstats: add thp_split_pud event for clarity include/linux/fs.h: fix unsigned enum warning with gcc-4.2 userfaultfd: non-cooperative: release all ctx in dup_userfaultfd_complete userfaultfd: non-cooperative: robustness check userfaultfd: non-cooperative: rollback userfaultfd_exit x86, mm: unify exit paths in gup_pte_range() ...
2 parents 9db61d6 + 2378cd6 commit 8fe3cca

File tree

54 files changed

+277
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+277
-185
lines changed

Documentation/dev-tools/kcov.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Note that kcov does not aim to collect as much coverage as possible. It aims
1010
to collect more or less stable coverage that is function of syscall inputs.
1111
To achieve this goal it does not collect coverage in soft/hard interrupts
1212
and instrumentation of some inherently non-deterministic parts of kernel is
13-
disbled (e.g. scheduler, locking).
13+
disabled (e.g. scheduler, locking).
1414

1515
Usage
1616
-----

Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Required Properties:
4545
Optional Properties:
4646
- reg-names: In addition to the required properties, the following are optional
4747
- "efuse-address" - Contains efuse base address used to pick up ABB info.
48-
- "ldo-address" - Contains address of ABB LDO overide register address.
48+
- "ldo-address" - Contains address of ABB LDO override register.
4949
"efuse-address" is required for this.
5050
- ti,ldovbb-vset-mask - Required if ldo-address is set, mask for LDO override
5151
register to provide override vset value.

Documentation/vm/userfaultfd.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ the same read(2) protocol as for the page fault notifications. The
172172
manager has to explicitly enable these events by setting appropriate
173173
bits in uffdio_api.features passed to UFFDIO_API ioctl:
174174

175-
UFFD_FEATURE_EVENT_EXIT - enable notification about exit() of the
176-
non-cooperative process. When the monitored process exits, the uffd
177-
manager will get UFFD_EVENT_EXIT.
178-
179175
UFFD_FEATURE_EVENT_FORK - enable userfaultfd hooks for fork(). When
180176
this feature is enabled, the userfaultfd context of the parent process
181177
is duplicated into the newly created process. The manager receives

arch/cris/arch-v32/drivers/cryptocop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ static void cryptocop_job_queue_close(void)
20862086
dma_in_cfg.en = regk_dma_no;
20872087
REG_WR(dma, IN_DMA_INST, rw_cfg, dma_in_cfg);
20882088

2089-
/* Disble the cryptocop. */
2089+
/* Disable the cryptocop. */
20902090
rw_cfg = REG_RD(strcop, regi_strcop, rw_cfg);
20912091
rw_cfg.en = 0;
20922092
REG_WR(strcop, regi_strcop, rw_cfg, rw_cfg);

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -347,23 +347,58 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm,
347347
__r; \
348348
})
349349

350+
static inline int __pte_write(pte_t pte)
351+
{
352+
return !!(pte_raw(pte) & cpu_to_be64(_PAGE_WRITE));
353+
}
354+
355+
#ifdef CONFIG_NUMA_BALANCING
356+
#define pte_savedwrite pte_savedwrite
357+
static inline bool pte_savedwrite(pte_t pte)
358+
{
359+
/*
360+
* Saved write ptes are prot none ptes that doesn't have
361+
* privileged bit sit. We mark prot none as one which has
362+
* present and pviliged bit set and RWX cleared. To mark
363+
* protnone which used to have _PAGE_WRITE set we clear
364+
* the privileged bit.
365+
*/
366+
return !(pte_raw(pte) & cpu_to_be64(_PAGE_RWX | _PAGE_PRIVILEGED));
367+
}
368+
#else
369+
#define pte_savedwrite pte_savedwrite
370+
static inline bool pte_savedwrite(pte_t pte)
371+
{
372+
return false;
373+
}
374+
#endif
375+
376+
static inline int pte_write(pte_t pte)
377+
{
378+
return __pte_write(pte) || pte_savedwrite(pte);
379+
}
380+
350381
#define __HAVE_ARCH_PTEP_SET_WRPROTECT
351382
static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
352383
pte_t *ptep)
353384
{
354-
if ((pte_raw(*ptep) & cpu_to_be64(_PAGE_WRITE)) == 0)
355-
return;
356-
357-
pte_update(mm, addr, ptep, _PAGE_WRITE, 0, 0);
385+
if (__pte_write(*ptep))
386+
pte_update(mm, addr, ptep, _PAGE_WRITE, 0, 0);
387+
else if (unlikely(pte_savedwrite(*ptep)))
388+
pte_update(mm, addr, ptep, 0, _PAGE_PRIVILEGED, 0);
358389
}
359390

360391
static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
361392
unsigned long addr, pte_t *ptep)
362393
{
363-
if ((pte_raw(*ptep) & cpu_to_be64(_PAGE_WRITE)) == 0)
364-
return;
365-
366-
pte_update(mm, addr, ptep, _PAGE_WRITE, 0, 1);
394+
/*
395+
* We should not find protnone for hugetlb, but this complete the
396+
* interface.
397+
*/
398+
if (__pte_write(*ptep))
399+
pte_update(mm, addr, ptep, _PAGE_WRITE, 0, 1);
400+
else if (unlikely(pte_savedwrite(*ptep)))
401+
pte_update(mm, addr, ptep, 0, _PAGE_PRIVILEGED, 1);
367402
}
368403

369404
#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
@@ -397,11 +432,6 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
397432
pte_update(mm, addr, ptep, ~0UL, 0, 0);
398433
}
399434

400-
static inline int pte_write(pte_t pte)
401-
{
402-
return !!(pte_raw(pte) & cpu_to_be64(_PAGE_WRITE));
403-
}
404-
405435
static inline int pte_dirty(pte_t pte)
406436
{
407437
return !!(pte_raw(pte) & cpu_to_be64(_PAGE_DIRTY));
@@ -465,19 +495,12 @@ static inline pte_t pte_clear_savedwrite(pte_t pte)
465495
VM_BUG_ON(!pte_protnone(pte));
466496
return __pte(pte_val(pte) | _PAGE_PRIVILEGED);
467497
}
468-
469-
#define pte_savedwrite pte_savedwrite
470-
static inline bool pte_savedwrite(pte_t pte)
498+
#else
499+
#define pte_clear_savedwrite pte_clear_savedwrite
500+
static inline pte_t pte_clear_savedwrite(pte_t pte)
471501
{
472-
/*
473-
* Saved write ptes are prot none ptes that doesn't have
474-
* privileged bit sit. We mark prot none as one which has
475-
* present and pviliged bit set and RWX cleared. To mark
476-
* protnone which used to have _PAGE_WRITE set we clear
477-
* the privileged bit.
478-
*/
479-
VM_BUG_ON(!pte_protnone(pte));
480-
return !(pte_raw(pte) & cpu_to_be64(_PAGE_RWX | _PAGE_PRIVILEGED));
502+
VM_WARN_ON(1);
503+
return __pte(pte_val(pte) & ~_PAGE_WRITE);
481504
}
482505
#endif /* CONFIG_NUMA_BALANCING */
483506

@@ -506,6 +529,8 @@ static inline unsigned long pte_pfn(pte_t pte)
506529
/* Generic modifiers for PTE bits */
507530
static inline pte_t pte_wrprotect(pte_t pte)
508531
{
532+
if (unlikely(pte_savedwrite(pte)))
533+
return pte_clear_savedwrite(pte);
509534
return __pte(pte_val(pte) & ~_PAGE_WRITE);
510535
}
511536

@@ -926,6 +951,7 @@ static inline int pmd_protnone(pmd_t pmd)
926951

927952
#define __HAVE_ARCH_PMD_WRITE
928953
#define pmd_write(pmd) pte_write(pmd_pte(pmd))
954+
#define __pmd_write(pmd) __pte_write(pmd_pte(pmd))
929955
#define pmd_savedwrite(pmd) pte_savedwrite(pmd_pte(pmd))
930956

931957
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -982,11 +1008,10 @@ static inline int __pmdp_test_and_clear_young(struct mm_struct *mm,
9821008
static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,
9831009
pmd_t *pmdp)
9841010
{
985-
986-
if ((pmd_raw(*pmdp) & cpu_to_be64(_PAGE_WRITE)) == 0)
987-
return;
988-
989-
pmd_hugepage_update(mm, addr, pmdp, _PAGE_WRITE, 0);
1011+
if (__pmd_write((*pmdp)))
1012+
pmd_hugepage_update(mm, addr, pmdp, _PAGE_WRITE, 0);
1013+
else if (unlikely(pmd_savedwrite(*pmdp)))
1014+
pmd_hugepage_update(mm, addr, pmdp, 0, _PAGE_PRIVILEGED);
9901015
}
9911016

9921017
static inline int pmd_trans_huge(pmd_t pmd)

arch/powerpc/kvm/book3s_64_mmu_hv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
601601
hva, NULL, NULL);
602602
if (ptep) {
603603
pte = kvmppc_read_update_linux_pte(ptep, 1);
604-
if (pte_write(pte))
604+
if (__pte_write(pte))
605605
write_ok = 1;
606606
}
607607
local_irq_restore(flags);

arch/powerpc/kvm/book3s_hv_rm_mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags,
256256
}
257257
pte = kvmppc_read_update_linux_pte(ptep, writing);
258258
if (pte_present(pte) && !pte_protnone(pte)) {
259-
if (writing && !pte_write(pte))
259+
if (writing && !__pte_write(pte))
260260
/* make the actual HPTE be read-only */
261261
ptel = hpte_make_readonly(ptel);
262262
is_ci = pte_ci(pte);

arch/sh/boards/mach-cayman/setup.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ static int __init smsc_superio_setup(void)
128128
SMSC_SUPERIO_WRITE_INDEXED(1, SMSC_PRIMARY_INT_INDEX);
129129
SMSC_SUPERIO_WRITE_INDEXED(12, SMSC_SECONDARY_INT_INDEX);
130130

131-
#ifdef CONFIG_IDE
132131
/*
133132
* Only IDE1 exists on the Cayman
134133
*/
@@ -158,7 +157,6 @@ static int __init smsc_superio_setup(void)
158157
SMSC_SUPERIO_WRITE_INDEXED(0x01, 0xc5); /* GP45 = IDE1_IRQ */
159158
SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc6); /* GP46 = nIOROP */
160159
SMSC_SUPERIO_WRITE_INDEXED(0x00, 0xc7); /* GP47 = nIOWOP */
161-
#endif
162160

163161
/* Exit the configuration state */
164162
outb(SMSC_EXIT_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);

arch/x86/kernel/ftrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ static void run_sync(void)
535535
{
536536
int enable_irqs = irqs_disabled();
537537

538-
/* We may be called with interrupts disbled (on bootup). */
538+
/* We may be called with interrupts disabled (on bootup). */
539539
if (enable_irqs)
540540
local_irq_enable();
541541
on_each_cpu(do_sync_core, NULL, 1);

arch/x86/mm/gup.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,32 +106,35 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
106106
unsigned long end, int write, struct page **pages, int *nr)
107107
{
108108
struct dev_pagemap *pgmap = NULL;
109-
int nr_start = *nr;
110-
pte_t *ptep;
109+
int nr_start = *nr, ret = 0;
110+
pte_t *ptep, *ptem;
111111

112-
ptep = pte_offset_map(&pmd, addr);
112+
/*
113+
* Keep the original mapped PTE value (ptem) around since we
114+
* might increment ptep off the end of the page when finishing
115+
* our loop iteration.
116+
*/
117+
ptem = ptep = pte_offset_map(&pmd, addr);
113118
do {
114119
pte_t pte = gup_get_pte(ptep);
115120
struct page *page;
116121

117122
/* Similar to the PMD case, NUMA hinting must take slow path */
118-
if (pte_protnone(pte)) {
119-
pte_unmap(ptep);
120-
return 0;
121-
}
123+
if (pte_protnone(pte))
124+
break;
125+
126+
if (!pte_allows_gup(pte_val(pte), write))
127+
break;
122128

123129
if (pte_devmap(pte)) {
124130
pgmap = get_dev_pagemap(pte_pfn(pte), pgmap);
125131
if (unlikely(!pgmap)) {
126132
undo_dev_pagemap(nr, nr_start, pages);
127-
pte_unmap(ptep);
128-
return 0;
133+
break;
129134
}
130-
} else if (!pte_allows_gup(pte_val(pte), write) ||
131-
pte_special(pte)) {
132-
pte_unmap(ptep);
133-
return 0;
134-
}
135+
} else if (pte_special(pte))
136+
break;
137+
135138
VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
136139
page = pte_page(pte);
137140
get_page(page);
@@ -141,9 +144,11 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
141144
(*nr)++;
142145

143146
} while (ptep++, addr += PAGE_SIZE, addr != end);
144-
pte_unmap(ptep - 1);
147+
if (addr == end)
148+
ret = 1;
149+
pte_unmap(ptem);
145150

146-
return 1;
151+
return ret;
147152
}
148153

149154
static inline void get_head_page_multiple(struct page *page, int nr)

0 commit comments

Comments
 (0)