Skip to content

Commit

Permalink
Merge branch 'akpm' (patches from Andrew)
Browse files Browse the repository at this point in the history
Merge more updates from Andrew Morton:

 - MM remainders

 - various misc things

 - kcov updates

* emailed patches from Andrew Morton <[email protected]>: (27 commits)
  lib/test_printf.c: call wait_for_random_bytes() before plain %p tests
  hexagon: drop the unused variable zero_page_mask
  hexagon: fix printk format warning in setup.c
  mm: fix oom_kill event handling
  treewide: use PHYS_ADDR_MAX to avoid type casting ULLONG_MAX
  mm: use octal not symbolic permissions
  ipc: use new return type vm_fault_t
  sysvipc/sem: mitigate semnum index against spectre v1
  fault-injection: reorder config entries
  arm: port KCOV to arm
  sched/core / kcov: avoid kcov_area during task switch
  kcov: prefault the kcov_area
  kcov: ensure irq code sees a valid area
  kernel/relay.c: change return type to vm_fault_t
  exofs: avoid VLA in structures
  coredump: fix spam with zero VMA process
  fat: use fat_fs_error() instead of BUG_ON() in __fat_get_block()
  proc: skip branch in /proc/*/* lookup
  mremap: remove LATENCY_LIMIT from mremap to reduce the number of TLB shootdowns
  mm/memblock: add missing include <linux/bootmem.h>
  ...
  • Loading branch information
torvalds committed Jun 14, 2018
2 parents 7a93251 + ee410f1 commit b5d903c
Show file tree
Hide file tree
Showing 56 changed files with 397 additions and 212 deletions.
3 changes: 2 additions & 1 deletion arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ config ARM
select ARCH_HAS_DEVMEM_IS_ALLOWED
select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_KCOV
select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_PHYS_TO_DMA
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
select ARCH_HAS_STRICT_MODULE_RWX if MMU
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
Expand Down
3 changes: 3 additions & 0 deletions arch/arm/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ endif

GCOV_PROFILE := n

# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
KCOV_INSTRUMENT := n

#
# Architecture dependencies
#
Expand Down
8 changes: 8 additions & 0 deletions arch/arm/kvm/hyp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o
obj-$(CONFIG_KVM_ARM_HOST) += switch.o
CFLAGS_switch.o += $(CFLAGS_ARMV7VE)
obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o

# KVM code is run at a different exception code with a different map, so
# compiler instrumentation that inserts callbacks or checks into the code may
# cause crashes. Just disable it.
GCOV_PROFILE := n
KASAN_SANITIZE := n
UBSAN_SANITIZE := n
KCOV_INSTRUMENT := n
3 changes: 3 additions & 0 deletions arch/arm/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ CFLAGS_vgettimeofday.o = -O2
# Disable gcov profiling for VDSO code
GCOV_PROFILE := n

# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
KCOV_INSTRUMENT := n

# Force dependency
$(obj)/vdso.o : $(obj)/vdso.so

Expand Down
6 changes: 3 additions & 3 deletions arch/arm64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static void __init arm64_memory_present(void)
}
#endif

static phys_addr_t memory_limit = (phys_addr_t)ULLONG_MAX;
static phys_addr_t memory_limit = PHYS_ADDR_MAX;

/*
* Limit the memory size that was specified via FDT.
Expand Down Expand Up @@ -401,7 +401,7 @@ void __init arm64_memblock_init(void)
* high up in memory, add back the kernel region that must be accessible
* via the linear mapping.
*/
if (memory_limit != (phys_addr_t)ULLONG_MAX) {
if (memory_limit != PHYS_ADDR_MAX) {
memblock_mem_limit_remove_map(memory_limit);
memblock_add(__pa_symbol(_text), (u64)(_end - _text));
}
Expand Down Expand Up @@ -666,7 +666,7 @@ __setup("keepinitrd", keepinitrd_setup);
*/
static int dump_mem_limit(struct notifier_block *self, unsigned long v, void *p)
{
if (memory_limit != (phys_addr_t)ULLONG_MAX) {
if (memory_limit != PHYS_ADDR_MAX) {
pr_emerg("Memory Limit: %llu MB\n", memory_limit >> 20);
} else {
pr_emerg("Memory Limit: none\n");
Expand Down
1 change: 0 additions & 1 deletion arch/hexagon/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

/* A handy thing to have if one has the RAM. Declared in head.S */
extern unsigned long empty_zero_page;
extern unsigned long zero_page_mask;

/*
* The PTE model described here is that of the Hexagon Virtual Machine,
Expand Down
2 changes: 1 addition & 1 deletion arch/hexagon/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void __init setup_arch(char **cmdline_p)
*/
__vmsetvec(_K_VM_event_vector);

printk(KERN_INFO "PHYS_OFFSET=0x%08x\n", PHYS_OFFSET);
printk(KERN_INFO "PHYS_OFFSET=0x%08lx\n", PHYS_OFFSET);

/*
* Simulator has a few differences from the hardware.
Expand Down
3 changes: 0 additions & 3 deletions arch/hexagon/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ unsigned long __phys_offset; /* physical kernel offset >> 12 */
/* Set as variable to limit PMD copies */
int max_kernel_seg = 0x303;

/* think this should be (page_size-1) the way it's used...*/
unsigned long zero_page_mask;

/* indicate pfn's of high memory */
unsigned long highstart_pfn, highend_pfn;

Expand Down
4 changes: 2 additions & 2 deletions arch/mips/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void __init add_memory_region(phys_addr_t start, phys_addr_t size, long type)
* If the region reaches the top of the physical address space, adjust
* the size slightly so that (start + size) doesn't overflow
*/
if (start + size - 1 == (phys_addr_t)ULLONG_MAX)
if (start + size - 1 == PHYS_ADDR_MAX)
--size;

/* Sanity check */
Expand Down Expand Up @@ -376,7 +376,7 @@ static void __init bootmem_init(void)
unsigned long reserved_end;
unsigned long mapstart = ~0UL;
unsigned long bootmap_size;
phys_addr_t ramstart = (phys_addr_t)ULLONG_MAX;
phys_addr_t ramstart = PHYS_ADDR_MAX;
bool bootmap_valid = false;
int i;

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/mm/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void __init mem_topology_setup(void)
/* Place all memblock_regions in the same node and merge contiguous
* memblock_regions
*/
memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
}

void __init initmem_init(void)
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/mm/init_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@ static void __init bootmem_init_nonnuma(void)
(top_of_ram - total_ram) >> 20);

init_node_masks_nonnuma();
memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
allocate_node_data(0);
node_set_online(0);
}
Expand Down
4 changes: 3 additions & 1 deletion arch/x86/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,9 @@ void __init init_mem_mapping(void)
*/
int devmem_is_allowed(unsigned long pagenr)
{
if (page_is_ram(pagenr)) {
if (region_intersects(PFN_PHYS(pagenr), PAGE_SIZE,
IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE)
!= REGION_DISJOINT) {
/*
* For disallowed memory regions in the low 1MB range,
* request that the page be shown as all zeros.
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/mm/init_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ void __init initmem_init(void)
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
#endif

memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
sparse_memory_present_with_active_regions(0);

#ifdef CONFIG_FLATMEM
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/mm/init_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ kernel_physical_mapping_init(unsigned long paddr_start,
#ifndef CONFIG_NUMA
void __init initmem_init(void)
{
memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/firmware/efi/arm-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static __init void reserve_regions(void)
* uses its own memory map instead.
*/
memblock_dump_all();
memblock_remove(0, (phys_addr_t)ULLONG_MAX);
memblock_remove(0, PHYS_ADDR_MAX);

for_each_efi_memory_desc(md) {
paddr = md->phys_addr;
Expand Down
2 changes: 1 addition & 1 deletion drivers/remoteproc/qcom_q6v5_pil.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
struct elf32_hdr *ehdr;
phys_addr_t mpss_reloc;
phys_addr_t boot_addr;
phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX;
phys_addr_t min_addr = PHYS_ADDR_MAX;
phys_addr_t max_addr = 0;
bool relocate = false;
char seg_name[10];
Expand Down
4 changes: 2 additions & 2 deletions drivers/soc/qcom/mdt_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)
const struct elf32_phdr *phdrs;
const struct elf32_phdr *phdr;
const struct elf32_hdr *ehdr;
phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX;
phys_addr_t min_addr = PHYS_ADDR_MAX;
phys_addr_t max_addr = 0;
int i;

Expand Down Expand Up @@ -97,7 +97,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
const struct elf32_hdr *ehdr;
const struct firmware *seg_fw;
phys_addr_t mem_reloc;
phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX;
phys_addr_t min_addr = PHYS_ADDR_MAX;
phys_addr_t max_addr = 0;
size_t fw_name_len;
ssize_t offset;
Expand Down
17 changes: 9 additions & 8 deletions fs/binfmt_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,8 +1621,8 @@ static int fill_files_note(struct memelfnote *note)
if (size >= MAX_FILE_NOTE_SIZE) /* paranoia check */
return -EINVAL;
size = round_up(size, PAGE_SIZE);
data = vmalloc(size);
if (!data)
data = kvmalloc(size, GFP_KERNEL);
if (ZERO_OR_NULL_PTR(data))
return -ENOMEM;

start_end_ofs = data + 2;
Expand All @@ -1639,7 +1639,7 @@ static int fill_files_note(struct memelfnote *note)
filename = file_path(file, name_curpos, remaining);
if (IS_ERR(filename)) {
if (PTR_ERR(filename) == -ENAMETOOLONG) {
vfree(data);
kvfree(data);
size = size * 5 / 4;
goto alloc;
}
Expand Down Expand Up @@ -1932,7 +1932,7 @@ static void free_note_info(struct elf_note_info *info)
kfree(t);
}
kfree(info->psinfo.data);
vfree(info->files.data);
kvfree(info->files.data);
}

#else
Expand Down Expand Up @@ -2148,7 +2148,7 @@ static void free_note_info(struct elf_note_info *info)

/* Free data possibly allocated by fill_files_note(): */
if (info->notes_files)
vfree(info->notes_files->data);
kvfree(info->notes_files->data);

kfree(info->prstatus);
kfree(info->psinfo);
Expand Down Expand Up @@ -2294,8 +2294,9 @@ static int elf_core_dump(struct coredump_params *cprm)

if (segs - 1 > ULONG_MAX / sizeof(*vma_filesz))
goto end_coredump;
vma_filesz = vmalloc(array_size(sizeof(*vma_filesz), (segs - 1)));
if (!vma_filesz)
vma_filesz = kvmalloc(array_size(sizeof(*vma_filesz), (segs - 1)),
GFP_KERNEL);
if (ZERO_OR_NULL_PTR(vma_filesz))
goto end_coredump;

for (i = 0, vma = first_vma(current, gate_vma); vma != NULL;
Expand Down Expand Up @@ -2402,7 +2403,7 @@ static int elf_core_dump(struct coredump_params *cprm)
cleanup:
free_note_info(&info);
kfree(shdr4extnum);
vfree(vma_filesz);
kvfree(vma_filesz);
kfree(phdr4note);
kfree(elf);
out:
Expand Down
84 changes: 49 additions & 35 deletions fs/exofs/ore.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,68 +146,82 @@ int _ore_get_io_state(struct ore_layout *layout,
struct ore_io_state **pios)
{
struct ore_io_state *ios;
struct page **pages;
struct osd_sg_entry *sgilist;
size_t size_ios, size_extra, size_total;
void *ios_extra;

/*
* The desired layout looks like this, with the extra_allocation
* items pointed at from fields within ios or per_dev:
struct __alloc_all_io_state {
struct ore_io_state ios;
struct ore_per_dev_state per_dev[numdevs];
union {
struct osd_sg_entry sglist[sgs_per_dev * numdevs];
struct page *pages[num_par_pages];
};
} *_aios;

if (likely(sizeof(*_aios) <= PAGE_SIZE)) {
_aios = kzalloc(sizeof(*_aios), GFP_KERNEL);
if (unlikely(!_aios)) {
ORE_DBGMSG("Failed kzalloc bytes=%zd\n",
sizeof(*_aios));
} extra_allocation;
} whole_allocation;
*/

/* This should never happen, so abort early if it ever does. */
if (sgs_per_dev && num_par_pages) {
ORE_DBGMSG("Tried to use both pages and sglist\n");
*pios = NULL;
return -EINVAL;
}

if (numdevs > (INT_MAX - sizeof(*ios)) /
sizeof(struct ore_per_dev_state))
return -ENOMEM;
size_ios = sizeof(*ios) + sizeof(struct ore_per_dev_state) * numdevs;

if (sgs_per_dev * numdevs > INT_MAX / sizeof(struct osd_sg_entry))
return -ENOMEM;
if (num_par_pages > INT_MAX / sizeof(struct page *))
return -ENOMEM;
size_extra = max(sizeof(struct osd_sg_entry) * (sgs_per_dev * numdevs),
sizeof(struct page *) * num_par_pages);

size_total = size_ios + size_extra;

if (likely(size_total <= PAGE_SIZE)) {
ios = kzalloc(size_total, GFP_KERNEL);
if (unlikely(!ios)) {
ORE_DBGMSG("Failed kzalloc bytes=%zd\n", size_total);
*pios = NULL;
return -ENOMEM;
}
pages = num_par_pages ? _aios->pages : NULL;
sgilist = sgs_per_dev ? _aios->sglist : NULL;
ios = &_aios->ios;
ios_extra = (char *)ios + size_ios;
} else {
struct __alloc_small_io_state {
struct ore_io_state ios;
struct ore_per_dev_state per_dev[numdevs];
} *_aio_small;
union __extra_part {
struct osd_sg_entry sglist[sgs_per_dev * numdevs];
struct page *pages[num_par_pages];
} *extra_part;

_aio_small = kzalloc(sizeof(*_aio_small), GFP_KERNEL);
if (unlikely(!_aio_small)) {
ios = kzalloc(size_ios, GFP_KERNEL);
if (unlikely(!ios)) {
ORE_DBGMSG("Failed alloc first part bytes=%zd\n",
sizeof(*_aio_small));
size_ios);
*pios = NULL;
return -ENOMEM;
}
extra_part = kzalloc(sizeof(*extra_part), GFP_KERNEL);
if (unlikely(!extra_part)) {
ios_extra = kzalloc(size_extra, GFP_KERNEL);
if (unlikely(!ios_extra)) {
ORE_DBGMSG("Failed alloc second part bytes=%zd\n",
sizeof(*extra_part));
kfree(_aio_small);
size_extra);
kfree(ios);
*pios = NULL;
return -ENOMEM;
}

pages = num_par_pages ? extra_part->pages : NULL;
sgilist = sgs_per_dev ? extra_part->sglist : NULL;
/* In this case the per_dev[0].sgilist holds the pointer to
* be freed
*/
ios = &_aio_small->ios;
ios->extra_part_alloc = true;
}

if (pages) {
ios->parity_pages = pages;
if (num_par_pages) {
ios->parity_pages = ios_extra;
ios->max_par_pages = num_par_pages;
}
if (sgilist) {
if (sgs_per_dev) {
struct osd_sg_entry *sgilist = ios_extra;
unsigned d;

for (d = 0; d < numdevs; ++d) {
Expand Down
Loading

0 comments on commit b5d903c

Please sign in to comment.