Skip to content

Commit 198190a

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/linux-aarch64
Pull arm64 fixes from Catalin Marinas: "Main changes: - AArch64 Linux compilation fixes following 3.7-rc1 changes (MODULES_USE_ELF_RELA, update_vsyscall() prototype) - Unnecessary register setting in start_thread() (thanks to Al Viro) - ptrace fixes" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/linux-aarch64: arm64: fix alignment padding in assembly code arm64: ptrace: use HW_BREAKPOINT_EMPTY type for disabled breakpoints arm64: ptrace: make structure padding explicit for debug registers arm64: No need to set the x0-x2 registers in start_thread() arm64: Ignore memory blocks below PHYS_OFFSET arm64: Fix the update_vsyscall() prototype arm64: Select MODULES_USE_ELF_RELA arm64: Remove duplicate inclusion of mmu_context.h in smp.c
2 parents 31fd84b + aeed41a commit 198190a

File tree

9 files changed

+83
-45
lines changed

9 files changed

+83
-45
lines changed

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ config ARM64
2222
select HAVE_PERF_EVENTS
2323
select HAVE_SPARSE_IRQ
2424
select IRQ_DOMAIN
25+
select MODULES_USE_ELF_RELA
2526
select NO_BOOTMEM
2627
select OF
2728
select OF_EARLY_FLATTREE

arch/arm64/include/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ generic-y += ipcbuf.h
1818
generic-y += irq_regs.h
1919
generic-y += kdebug.h
2020
generic-y += kmap_types.h
21-
generic-y += linkage.h
2221
generic-y += local.h
2322
generic-y += local64.h
2423
generic-y += mman.h

arch/arm64/include/asm/linkage.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef __ASM_LINKAGE_H
2+
#define __ASM_LINKAGE_H
3+
4+
#define __ALIGN .align 4
5+
#define __ALIGN_STR ".align 4"
6+
7+
#endif

arch/arm64/include/asm/processor.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,20 @@ static inline void start_thread_common(struct pt_regs *regs, unsigned long pc)
9292
static inline void start_thread(struct pt_regs *regs, unsigned long pc,
9393
unsigned long sp)
9494
{
95-
unsigned long *stack = (unsigned long *)sp;
96-
9795
start_thread_common(regs, pc);
9896
regs->pstate = PSR_MODE_EL0t;
9997
regs->sp = sp;
100-
regs->regs[2] = stack[2]; /* x2 (envp) */
101-
regs->regs[1] = stack[1]; /* x1 (argv) */
102-
regs->regs[0] = stack[0]; /* x0 (argc) */
10398
}
10499

105100
#ifdef CONFIG_COMPAT
106101
static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
107102
unsigned long sp)
108103
{
109-
unsigned int *stack = (unsigned int *)sp;
110-
111104
start_thread_common(regs, pc);
112105
regs->pstate = COMPAT_PSR_MODE_USR;
113106
if (pc & 1)
114107
regs->pstate |= COMPAT_PSR_T_BIT;
115108
regs->compat_sp = sp;
116-
regs->regs[2] = stack[2]; /* x2 (envp) */
117-
regs->regs[1] = stack[1]; /* x1 (argv) */
118-
regs->regs[0] = stack[0]; /* x0 (argc) */
119109
}
120110
#endif
121111

arch/arm64/include/uapi/asm/ptrace.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ struct user_fpsimd_state {
7979

8080
struct user_hwdebug_state {
8181
__u32 dbg_info;
82+
__u32 pad;
8283
struct {
8384
__u64 addr;
8485
__u32 ctrl;
86+
__u32 pad;
8587
} dbg_regs[16];
8688
};
8789

88-
8990
#endif /* __ASSEMBLY__ */
9091

9192
#endif /* _UAPI__ASM_PTRACE_H */

arch/arm64/kernel/ptrace.c

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,28 +234,33 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type,
234234
struct arch_hw_breakpoint_ctrl ctrl,
235235
struct perf_event_attr *attr)
236236
{
237-
int err, len, type;
237+
int err, len, type, disabled = !ctrl.enabled;
238238

239-
err = arch_bp_generic_fields(ctrl, &len, &type);
240-
if (err)
241-
return err;
242-
243-
switch (note_type) {
244-
case NT_ARM_HW_BREAK:
245-
if ((type & HW_BREAKPOINT_X) != type)
246-
return -EINVAL;
247-
break;
248-
case NT_ARM_HW_WATCH:
249-
if ((type & HW_BREAKPOINT_RW) != type)
239+
if (disabled) {
240+
len = 0;
241+
type = HW_BREAKPOINT_EMPTY;
242+
} else {
243+
err = arch_bp_generic_fields(ctrl, &len, &type);
244+
if (err)
245+
return err;
246+
247+
switch (note_type) {
248+
case NT_ARM_HW_BREAK:
249+
if ((type & HW_BREAKPOINT_X) != type)
250+
return -EINVAL;
251+
break;
252+
case NT_ARM_HW_WATCH:
253+
if ((type & HW_BREAKPOINT_RW) != type)
254+
return -EINVAL;
255+
break;
256+
default:
250257
return -EINVAL;
251-
break;
252-
default:
253-
return -EINVAL;
258+
}
254259
}
255260

256261
attr->bp_len = len;
257262
attr->bp_type = type;
258-
attr->disabled = !ctrl.enabled;
263+
attr->disabled = disabled;
259264

260265
return 0;
261266
}
@@ -372,15 +377,15 @@ static int ptrace_hbp_set_addr(unsigned int note_type,
372377

373378
#define PTRACE_HBP_ADDR_SZ sizeof(u64)
374379
#define PTRACE_HBP_CTRL_SZ sizeof(u32)
375-
#define PTRACE_HBP_REG_OFF sizeof(u32)
380+
#define PTRACE_HBP_PAD_SZ sizeof(u32)
376381

377382
static int hw_break_get(struct task_struct *target,
378383
const struct user_regset *regset,
379384
unsigned int pos, unsigned int count,
380385
void *kbuf, void __user *ubuf)
381386
{
382387
unsigned int note_type = regset->core_note_type;
383-
int ret, idx = 0, offset = PTRACE_HBP_REG_OFF, limit;
388+
int ret, idx = 0, offset, limit;
384389
u32 info, ctrl;
385390
u64 addr;
386391

@@ -389,11 +394,20 @@ static int hw_break_get(struct task_struct *target,
389394
if (ret)
390395
return ret;
391396

392-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &info, 0, 4);
397+
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &info, 0,
398+
sizeof(info));
399+
if (ret)
400+
return ret;
401+
402+
/* Pad */
403+
offset = offsetof(struct user_hwdebug_state, pad);
404+
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, offset,
405+
offset + PTRACE_HBP_PAD_SZ);
393406
if (ret)
394407
return ret;
395408

396409
/* (address, ctrl) registers */
410+
offset = offsetof(struct user_hwdebug_state, dbg_regs);
397411
limit = regset->n * regset->size;
398412
while (count && offset < limit) {
399413
ret = ptrace_hbp_get_addr(note_type, target, idx, &addr);
@@ -413,6 +427,13 @@ static int hw_break_get(struct task_struct *target,
413427
if (ret)
414428
return ret;
415429
offset += PTRACE_HBP_CTRL_SZ;
430+
431+
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
432+
offset,
433+
offset + PTRACE_HBP_PAD_SZ);
434+
if (ret)
435+
return ret;
436+
offset += PTRACE_HBP_PAD_SZ;
416437
idx++;
417438
}
418439

@@ -425,12 +446,13 @@ static int hw_break_set(struct task_struct *target,
425446
const void *kbuf, const void __user *ubuf)
426447
{
427448
unsigned int note_type = regset->core_note_type;
428-
int ret, idx = 0, offset = PTRACE_HBP_REG_OFF, limit;
449+
int ret, idx = 0, offset, limit;
429450
u32 ctrl;
430451
u64 addr;
431452

432-
/* Resource info */
433-
ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, 4);
453+
/* Resource info and pad */
454+
offset = offsetof(struct user_hwdebug_state, dbg_regs);
455+
ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, offset);
434456
if (ret)
435457
return ret;
436458

@@ -454,6 +476,13 @@ static int hw_break_set(struct task_struct *target,
454476
if (ret)
455477
return ret;
456478
offset += PTRACE_HBP_CTRL_SZ;
479+
480+
ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
481+
offset,
482+
offset + PTRACE_HBP_PAD_SZ);
483+
if (ret)
484+
return ret;
485+
offset += PTRACE_HBP_PAD_SZ;
457486
idx++;
458487
}
459488

arch/arm64/kernel/setup.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,19 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
170170

171171
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
172172
{
173+
base &= PAGE_MASK;
173174
size &= PAGE_MASK;
175+
if (base + size < PHYS_OFFSET) {
176+
pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
177+
base, base + size);
178+
return;
179+
}
180+
if (base < PHYS_OFFSET) {
181+
pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
182+
base, PHYS_OFFSET);
183+
size -= PHYS_OFFSET - base;
184+
base = PHYS_OFFSET;
185+
}
174186
memblock_add(base, size);
175187
}
176188

arch/arm64/kernel/smp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#include <asm/sections.h>
4747
#include <asm/tlbflush.h>
4848
#include <asm/ptrace.h>
49-
#include <asm/mmu_context.h>
5049

5150
/*
5251
* as from 2.5, kernels no longer have an init_tasks structure

arch/arm64/kernel/vdso.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/sched.h>
2929
#include <linux/signal.h>
3030
#include <linux/slab.h>
31+
#include <linux/timekeeper_internal.h>
3132
#include <linux/vmalloc.h>
3233

3334
#include <asm/cacheflush.h>
@@ -222,11 +223,10 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
222223
/*
223224
* Update the vDSO data page to keep in sync with kernel timekeeping.
224225
*/
225-
void update_vsyscall(struct timespec *ts, struct timespec *wtm,
226-
struct clocksource *clock, u32 mult)
226+
void update_vsyscall(struct timekeeper *tk)
227227
{
228228
struct timespec xtime_coarse;
229-
u32 use_syscall = strcmp(clock->name, "arch_sys_counter");
229+
u32 use_syscall = strcmp(tk->clock->name, "arch_sys_counter");
230230

231231
++vdso_data->tb_seq_count;
232232
smp_wmb();
@@ -237,13 +237,13 @@ void update_vsyscall(struct timespec *ts, struct timespec *wtm,
237237
vdso_data->xtime_coarse_nsec = xtime_coarse.tv_nsec;
238238

239239
if (!use_syscall) {
240-
vdso_data->cs_cycle_last = clock->cycle_last;
241-
vdso_data->xtime_clock_sec = ts->tv_sec;
242-
vdso_data->xtime_clock_nsec = ts->tv_nsec;
243-
vdso_data->cs_mult = mult;
244-
vdso_data->cs_shift = clock->shift;
245-
vdso_data->wtm_clock_sec = wtm->tv_sec;
246-
vdso_data->wtm_clock_nsec = wtm->tv_nsec;
240+
vdso_data->cs_cycle_last = tk->clock->cycle_last;
241+
vdso_data->xtime_clock_sec = tk->xtime_sec;
242+
vdso_data->xtime_clock_nsec = tk->xtime_nsec >> tk->shift;
243+
vdso_data->cs_mult = tk->mult;
244+
vdso_data->cs_shift = tk->shift;
245+
vdso_data->wtm_clock_sec = tk->wall_to_monotonic.tv_sec;
246+
vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec;
247247
}
248248

249249
smp_wmb();

0 commit comments

Comments
 (0)