Skip to content

Commit 89d0abe

Browse files
committed
Merge tag 'arm64-stable' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/linux-aarch64
Pull arm64 fixes from Catalin Marinas: - Post -rc1 update to the common reboot infrastructure. - Fixes (user cache maintenance fault handling, !COMPAT compilation, CPU online and interrupt hanlding). * tag 'arm64-stable' of git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/linux-aarch64: arm64: use common reboot infrastructure arm64: mm: don't treat user cache maintenance faults as writes arm64: add '#ifdef CONFIG_COMPAT' for aarch32_break_handler() arm64: Only enable local interrupts after the CPU is marked online
2 parents 89a8c59 + ff70130 commit 89d0abe

File tree

5 files changed

+31
-42
lines changed

5 files changed

+31
-42
lines changed

arch/arm64/include/asm/debug-monitors.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,7 @@ static inline int reinstall_suspended_bps(struct pt_regs *regs)
8383
}
8484
#endif
8585

86-
#ifdef CONFIG_COMPAT
8786
int aarch32_break_handler(struct pt_regs *regs);
88-
#else
89-
static int aarch32_break_handler(struct pt_regs *regs)
90-
{
91-
return -EFAULT;
92-
}
93-
#endif
9487

9588
#endif /* __ASSEMBLY */
9689
#endif /* __KERNEL__ */

arch/arm64/include/asm/system_misc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/compiler.h>
2424
#include <linux/linkage.h>
2525
#include <linux/irqflags.h>
26+
#include <linux/reboot.h>
2627

2728
struct pt_regs;
2829

@@ -41,7 +42,7 @@ extern void show_pte(struct mm_struct *mm, unsigned long addr);
4142
extern void __show_regs(struct pt_regs *);
4243

4344
void soft_restart(unsigned long);
44-
extern void (*arm_pm_restart)(char str, const char *cmd);
45+
extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
4546

4647
#define UDBG_UNDEFINED (1 << 0)
4748
#define UDBG_SYSCALL (1 << 1)

arch/arm64/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void machine_restart(char *cmd)
132132

133133
/* Now call the architecture specific reboot code. */
134134
if (arm_pm_restart)
135-
arm_pm_restart('h', cmd);
135+
arm_pm_restart(reboot_mode, cmd);
136136

137137
/*
138138
* Whoops - the architecture was unable to reboot.

arch/arm64/kernel/smp.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,6 @@ asmlinkage void secondary_start_kernel(void)
199199
raw_spin_lock(&boot_lock);
200200
raw_spin_unlock(&boot_lock);
201201

202-
/*
203-
* Enable local interrupts.
204-
*/
205-
notify_cpu_starting(cpu);
206-
local_irq_enable();
207-
local_fiq_enable();
208-
209202
/*
210203
* OK, now it's safe to let the boot CPU continue. Wait for
211204
* the CPU migration code to notice that the CPU is online
@@ -214,6 +207,14 @@ asmlinkage void secondary_start_kernel(void)
214207
set_cpu_online(cpu, true);
215208
complete(&cpu_running);
216209

210+
/*
211+
* Enable GIC and timers.
212+
*/
213+
notify_cpu_starting(cpu);
214+
215+
local_irq_enable();
216+
local_fiq_enable();
217+
217218
/*
218219
* OK, it's off to the idle thread for us
219220
*/

arch/arm64/mm/fault.c

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,8 @@ void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *regs)
152152
#define ESR_CM (1 << 8)
153153
#define ESR_LNX_EXEC (1 << 24)
154154

155-
/*
156-
* Check that the permissions on the VMA allow for the fault which occurred.
157-
* If we encountered a write fault, we must have write permission, otherwise
158-
* we allow any permission.
159-
*/
160-
static inline bool access_error(unsigned int esr, struct vm_area_struct *vma)
161-
{
162-
unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
163-
164-
if (esr & ESR_WRITE)
165-
mask = VM_WRITE;
166-
if (esr & ESR_LNX_EXEC)
167-
mask = VM_EXEC;
168-
169-
return vma->vm_flags & mask ? false : true;
170-
}
171-
172155
static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
173-
unsigned int esr, unsigned int flags,
156+
unsigned int mm_flags, unsigned long vm_flags,
174157
struct task_struct *tsk)
175158
{
176159
struct vm_area_struct *vma;
@@ -188,12 +171,17 @@ static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
188171
* it.
189172
*/
190173
good_area:
191-
if (access_error(esr, vma)) {
174+
/*
175+
* Check that the permissions on the VMA allow for the fault which
176+
* occurred. If we encountered a write or exec fault, we must have
177+
* appropriate permissions, otherwise we allow any permission.
178+
*/
179+
if (!(vma->vm_flags & vm_flags)) {
192180
fault = VM_FAULT_BADACCESS;
193181
goto out;
194182
}
195183

196-
return handle_mm_fault(mm, vma, addr & PAGE_MASK, flags);
184+
return handle_mm_fault(mm, vma, addr & PAGE_MASK, mm_flags);
197185

198186
check_stack:
199187
if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
@@ -208,9 +196,15 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
208196
struct task_struct *tsk;
209197
struct mm_struct *mm;
210198
int fault, sig, code;
211-
bool write = (esr & ESR_WRITE) && !(esr & ESR_CM);
212-
unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
213-
(write ? FAULT_FLAG_WRITE : 0);
199+
unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC;
200+
unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
201+
202+
if (esr & ESR_LNX_EXEC) {
203+
vm_flags = VM_EXEC;
204+
} else if ((esr & ESR_WRITE) && !(esr & ESR_CM)) {
205+
vm_flags = VM_WRITE;
206+
mm_flags |= FAULT_FLAG_WRITE;
207+
}
214208

215209
tsk = current;
216210
mm = tsk->mm;
@@ -248,7 +242,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
248242
#endif
249243
}
250244

251-
fault = __do_page_fault(mm, addr, esr, flags, tsk);
245+
fault = __do_page_fault(mm, addr, mm_flags, vm_flags, tsk);
252246

253247
/*
254248
* If we need to retry but a fatal signal is pending, handle the
@@ -265,7 +259,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
265259
*/
266260

267261
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
268-
if (flags & FAULT_FLAG_ALLOW_RETRY) {
262+
if (mm_flags & FAULT_FLAG_ALLOW_RETRY) {
269263
if (fault & VM_FAULT_MAJOR) {
270264
tsk->maj_flt++;
271265
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs,
@@ -280,7 +274,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
280274
* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk of
281275
* starvation.
282276
*/
283-
flags &= ~FAULT_FLAG_ALLOW_RETRY;
277+
mm_flags &= ~FAULT_FLAG_ALLOW_RETRY;
284278
goto retry;
285279
}
286280
}

0 commit comments

Comments
 (0)