Skip to content

Commit d29e472

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Will Deacon: "The main thing here is reviving hugetlb support using contiguous ptes, which we ended up reverting at the last minute in 4.5 pending a fix which went into the core mm/ code during the recent merge window. - Revert a previous revert and get hugetlb going with contiguous hints - Wire up missing compat syscalls - Enable CONFIG_SET_MODULE_RONX by default - Add missing line to our compat /proc/cpuinfo output - Clarify levels in our page table dumps - Fix booting with RANDOMIZE_TEXT_OFFSET enabled - Misc fixes to the ARM CPU PMU driver (refcounting, probe failure) - Remove some dead code and update a comment" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: fix alignment when RANDOMIZE_TEXT_OFFSET is enabled arm64: move {PAGE,CONT}_SHIFT into Kconfig arm64: mm: dump: log span level arm64: update stale PAGE_OFFSET comment drivers/perf: arm_pmu: Avoid leaking pmu->irq_affinity on error drivers/perf: arm_pmu: Defer the setting of __oprofile_cpu_pmu drivers/perf: arm_pmu: Fix reference count of a device_node in of_pmu_irq_cfg arm64: report CPU number in bad_mode arm64: unistd32.h: wire up missing syscalls for compat tasks arm64: Provide "model name" in /proc/cpuinfo for PER_LINUX32 tasks arm64: enable CONFIG_SET_MODULE_RONX by default arm64: Remove orphaned __addr_ok() definition Revert "arm64: hugetlb: partial revert of 66b3923"
2 parents 5306d76 + aed7eb8 commit d29e472

File tree

14 files changed

+79
-51
lines changed

14 files changed

+79
-51
lines changed

arch/arm64/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ config ARCH_PHYS_ADDR_T_64BIT
113113
config MMU
114114
def_bool y
115115

116+
config ARM64_PAGE_SHIFT
117+
int
118+
default 16 if ARM64_64K_PAGES
119+
default 14 if ARM64_16K_PAGES
120+
default 12
121+
122+
config ARM64_CONT_SHIFT
123+
int
124+
default 5 if ARM64_64K_PAGES
125+
default 7 if ARM64_16K_PAGES
126+
default 4
127+
116128
config ARCH_MMAP_RND_BITS_MIN
117129
default 14 if ARM64_64K_PAGES
118130
default 16 if ARM64_16K_PAGES

arch/arm64/Kconfig.debug

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ config ARM64_PTDUMP
1212
who are working in architecture specific areas of the kernel.
1313
It is probably not a good idea to enable this feature in a production
1414
kernel.
15-
If in doubt, say "N"
15+
16+
If in doubt, say N.
1617

1718
config PID_IN_CONTEXTIDR
1819
bool "Write the current PID to the CONTEXTIDR register"
@@ -38,15 +39,15 @@ config ARM64_RANDOMIZE_TEXT_OFFSET
3839
value.
3940

4041
config DEBUG_SET_MODULE_RONX
41-
bool "Set loadable kernel module data as NX and text as RO"
42-
depends on MODULES
43-
help
44-
This option helps catch unintended modifications to loadable
45-
kernel module's text and read-only data. It also prevents execution
46-
of module data. Such protection may interfere with run-time code
47-
patching and dynamic kernel tracing - and they might also protect
48-
against certain classes of kernel exploits.
49-
If in doubt, say "N".
42+
bool "Set loadable kernel module data as NX and text as RO"
43+
depends on MODULES
44+
default y
45+
help
46+
Is this is set, kernel module text and rodata will be made read-only.
47+
This is to help catch accidental or malicious attempts to change the
48+
kernel's executable code.
49+
50+
If in doubt, say Y.
5051

5152
config DEBUG_RODATA
5253
bool "Make kernel text and rodata read-only"
@@ -56,7 +57,7 @@ config DEBUG_RODATA
5657
is to help catch accidental or malicious attempts to change the
5758
kernel's executable code.
5859

59-
If in doubt, say Y
60+
If in doubt, say Y.
6061

6162
config DEBUG_ALIGN_RODATA
6263
depends on DEBUG_RODATA
@@ -69,7 +70,7 @@ config DEBUG_ALIGN_RODATA
6970
alignment and potentially wasted space. Turn on this option if
7071
performance is more important than memory pressure.
7172

72-
If in doubt, say N
73+
If in doubt, say N.
7374

7475
source "drivers/hwtracing/coresight/Kconfig"
7576

arch/arm64/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ head-y := arch/arm64/kernel/head.o
6060

6161
# The byte offset of the kernel image in RAM from the start of RAM.
6262
ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y)
63-
TEXT_OFFSET := $(shell awk 'BEGIN {srand(); printf "0x%03x000\n", int(512 * rand())}')
63+
TEXT_OFFSET := $(shell awk "BEGIN {srand(); printf \"0x%06x\n\", \
64+
int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \
65+
rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}")
6466
else
6567
TEXT_OFFSET := 0x00080000
6668
endif

arch/arm64/include/asm/elf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
160160
#define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12))
161161
#endif
162162

163-
#ifdef CONFIG_COMPAT
164-
165163
#ifdef __AARCH64EB__
166164
#define COMPAT_ELF_PLATFORM ("v8b")
167165
#else
168166
#define COMPAT_ELF_PLATFORM ("v8l")
169167
#endif
170168

169+
#ifdef CONFIG_COMPAT
170+
171171
#define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3)
172172

173173
/* AArch32 registers. */

arch/arm64/include/asm/memory.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
#define VMEMMAP_SIZE (UL(1) << (VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT))
5656

5757
/*
58-
* PAGE_OFFSET - the virtual address of the start of the kernel image (top
58+
* PAGE_OFFSET - the virtual address of the start of the linear map (top
5959
* (VA_BITS - 1))
60+
* KIMAGE_VADDR - the virtual address of the start of the kernel image
6061
* VA_BITS - the maximum number of bits for virtual addresses.
6162
* VA_START - the first kernel virtual address.
6263
* TASK_SIZE - the maximum size of a user space task.

arch/arm64/include/asm/page.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,8 @@
2323

2424
/* PAGE_SHIFT determines the page size */
2525
/* CONT_SHIFT determines the number of pages which can be tracked together */
26-
#ifdef CONFIG_ARM64_64K_PAGES
27-
#define PAGE_SHIFT 16
28-
#define CONT_SHIFT 5
29-
#elif defined(CONFIG_ARM64_16K_PAGES)
30-
#define PAGE_SHIFT 14
31-
#define CONT_SHIFT 7
32-
#else
33-
#define PAGE_SHIFT 12
34-
#define CONT_SHIFT 4
35-
#endif
26+
#define PAGE_SHIFT CONFIG_ARM64_PAGE_SHIFT
27+
#define CONT_SHIFT CONFIG_ARM64_CONT_SHIFT
3628
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
3729
#define PAGE_MASK (~(PAGE_SIZE-1))
3830

arch/arm64/include/asm/uaccess.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,6 @@ static inline void set_fs(mm_segment_t fs)
8080

8181
#define segment_eq(a, b) ((a) == (b))
8282

83-
/*
84-
* Return 1 if addr < current->addr_limit, 0 otherwise.
85-
*/
86-
#define __addr_ok(addr) \
87-
({ \
88-
unsigned long flag; \
89-
asm("cmp %1, %0; cset %0, lo" \
90-
: "=&r" (flag) \
91-
: "r" (addr), "0" (current_thread_info()->addr_limit) \
92-
: "cc"); \
93-
flag; \
94-
})
95-
9683
/*
9784
* Test whether a block of memory is a valid user space address.
9885
* Returns 1 if the range is valid, 0 otherwise.

arch/arm64/include/asm/unistd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2)
4545
#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5)
4646

47-
#define __NR_compat_syscalls 390
47+
#define __NR_compat_syscalls 394
4848
#endif
4949

5050
#define __ARCH_WANT_SYS_CLONE

arch/arm64/include/asm/unistd32.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,14 @@ __SYSCALL(__NR_execveat, compat_sys_execveat)
801801
__SYSCALL(__NR_userfaultfd, sys_userfaultfd)
802802
#define __NR_membarrier 389
803803
__SYSCALL(__NR_membarrier, sys_membarrier)
804+
#define __NR_mlock2 390
805+
__SYSCALL(__NR_mlock2, sys_mlock2)
806+
#define __NR_copy_file_range 391
807+
__SYSCALL(__NR_copy_file_range, sys_copy_file_range)
808+
#define __NR_preadv2 392
809+
__SYSCALL(__NR_preadv2, compat_sys_preadv2)
810+
#define __NR_pwritev2 393
811+
__SYSCALL(__NR_pwritev2, compat_sys_pwritev2)
804812

805813
/*
806814
* Please add new compat syscalls above this comment and update

arch/arm64/kernel/cpuinfo.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#include <linux/bitops.h>
2424
#include <linux/bug.h>
25+
#include <linux/compat.h>
26+
#include <linux/elf.h>
2527
#include <linux/init.h>
2628
#include <linux/kernel.h>
2729
#include <linux/personality.h>
@@ -104,6 +106,7 @@ static const char *const compat_hwcap2_str[] = {
104106
static int c_show(struct seq_file *m, void *v)
105107
{
106108
int i, j;
109+
bool compat = personality(current->personality) == PER_LINUX32;
107110

108111
for_each_online_cpu(i) {
109112
struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);
@@ -115,6 +118,9 @@ static int c_show(struct seq_file *m, void *v)
115118
* "processor". Give glibc what it expects.
116119
*/
117120
seq_printf(m, "processor\t: %d\n", i);
121+
if (compat)
122+
seq_printf(m, "model name\t: ARMv8 Processor rev %d (%s)\n",
123+
MIDR_REVISION(midr), COMPAT_ELF_PLATFORM);
118124

119125
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
120126
loops_per_jiffy / (500000UL/HZ),
@@ -127,7 +133,7 @@ static int c_show(struct seq_file *m, void *v)
127133
* software which does already (at least for 32-bit).
128134
*/
129135
seq_puts(m, "Features\t:");
130-
if (personality(current->personality) == PER_LINUX32) {
136+
if (compat) {
131137
#ifdef CONFIG_COMPAT
132138
for (j = 0; compat_hwcap_str[j]; j++)
133139
if (compat_elf_hwcap & (1 << j))

arch/arm64/kernel/traps.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,9 @@ asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
477477
void __user *pc = (void __user *)instruction_pointer(regs);
478478
console_verbose();
479479

480-
pr_crit("Bad mode in %s handler detected, code 0x%08x -- %s\n",
481-
handler[reason], esr, esr_get_class_string(esr));
480+
pr_crit("Bad mode in %s handler detected on CPU%d, code 0x%08x -- %s\n",
481+
handler[reason], smp_processor_id(), esr,
482+
esr_get_class_string(esr));
482483
__show_regs(regs);
483484

484485
info.si_signo = SIGILL;

arch/arm64/mm/dump.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,27 @@ static const struct prot_bits pte_bits[] = {
150150

151151
struct pg_level {
152152
const struct prot_bits *bits;
153+
const char *name;
153154
size_t num;
154155
u64 mask;
155156
};
156157

157158
static struct pg_level pg_level[] = {
158159
{
159160
}, { /* pgd */
161+
.name = "PGD",
160162
.bits = pte_bits,
161163
.num = ARRAY_SIZE(pte_bits),
162164
}, { /* pud */
165+
.name = (CONFIG_PGTABLE_LEVELS > 3) ? "PUD" : "PGD",
163166
.bits = pte_bits,
164167
.num = ARRAY_SIZE(pte_bits),
165168
}, { /* pmd */
169+
.name = (CONFIG_PGTABLE_LEVELS > 2) ? "PMD" : "PGD",
166170
.bits = pte_bits,
167171
.num = ARRAY_SIZE(pte_bits),
168172
}, { /* pte */
173+
.name = "PTE",
169174
.bits = pte_bits,
170175
.num = ARRAY_SIZE(pte_bits),
171176
},
@@ -214,7 +219,8 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level,
214219
delta >>= 10;
215220
unit++;
216221
}
217-
seq_printf(st->seq, "%9lu%c", delta, *unit);
222+
seq_printf(st->seq, "%9lu%c %s", delta, *unit,
223+
pg_level[st->level].name);
218224
if (pg_level[st->level].bits)
219225
dump_prot(st, pg_level[st->level].bits,
220226
pg_level[st->level].num);

arch/arm64/mm/hugetlbpage.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ static __init int setup_hugepagesz(char *opt)
306306
hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT);
307307
} else if (ps == PUD_SIZE) {
308308
hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
309+
} else if (ps == (PAGE_SIZE * CONT_PTES)) {
310+
hugetlb_add_hstate(CONT_PTE_SHIFT);
311+
} else if (ps == (PMD_SIZE * CONT_PMDS)) {
312+
hugetlb_add_hstate((PMD_SHIFT + CONT_PMD_SHIFT) - PAGE_SHIFT);
309313
} else {
310314
hugetlb_bad_size();
311315
pr_err("hugepagesz: Unsupported page size %lu K\n", ps >> 10);
@@ -314,3 +318,13 @@ static __init int setup_hugepagesz(char *opt)
314318
return 1;
315319
}
316320
__setup("hugepagesz=", setup_hugepagesz);
321+
322+
#ifdef CONFIG_ARM64_64K_PAGES
323+
static __init int add_default_hugepagesz(void)
324+
{
325+
if (size_to_hstate(CONT_PTES * PAGE_SIZE) == NULL)
326+
hugetlb_add_hstate(CONT_PMD_SHIFT);
327+
return 0;
328+
}
329+
arch_initcall(add_default_hugepagesz);
330+
#endif

drivers/perf/arm_pmu.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -950,17 +950,14 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu)
950950

951951
/* For SPIs, we need to track the affinity per IRQ */
952952
if (using_spi) {
953-
if (i >= pdev->num_resources) {
954-
of_node_put(dn);
953+
if (i >= pdev->num_resources)
955954
break;
956-
}
957955

958956
irqs[i] = cpu;
959957
}
960958

961959
/* Keep track of the CPUs containing this PMU type */
962960
cpumask_set_cpu(cpu, &pmu->supported_cpus);
963-
of_node_put(dn);
964961
i++;
965962
} while (1);
966963

@@ -995,9 +992,6 @@ int arm_pmu_device_probe(struct platform_device *pdev,
995992

996993
armpmu_init(pmu);
997994

998-
if (!__oprofile_cpu_pmu)
999-
__oprofile_cpu_pmu = pmu;
1000-
1001995
pmu->plat_device = pdev;
1002996

1003997
if (node && (of_id = of_match_node(of_table, pdev->dev.of_node))) {
@@ -1033,6 +1027,9 @@ int arm_pmu_device_probe(struct platform_device *pdev,
10331027
if (ret)
10341028
goto out_destroy;
10351029

1030+
if (!__oprofile_cpu_pmu)
1031+
__oprofile_cpu_pmu = pmu;
1032+
10361033
pr_info("enabled with %s PMU driver, %d counters available\n",
10371034
pmu->name, pmu->num_events);
10381035

@@ -1043,6 +1040,7 @@ int arm_pmu_device_probe(struct platform_device *pdev,
10431040
out_free:
10441041
pr_info("%s: failed to register PMU devices!\n",
10451042
of_node_full_name(node));
1043+
kfree(pmu->irq_affinity);
10461044
kfree(pmu);
10471045
return ret;
10481046
}

0 commit comments

Comments
 (0)