* [PATCH 1/4] arm64: Select MODULES_USE_ELF_RELA
2012-10-16 16:46 [PATCH 0/4] arm64: Random fixes for 3.7 Catalin Marinas
@ 2012-10-16 16:46 ` Catalin Marinas
2012-10-16 16:53 ` Will Deacon
2012-10-16 16:46 ` [PATCH 2/4] arm64: Fix the update_vsyscall() prototype Catalin Marinas
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Catalin Marinas @ 2012-10-16 16:46 UTC (permalink / raw)
To: linux-arm-kernel
With commit 786d35d4 (make most arch asm/module.h files use
asm-generic/module.h) arm64 needs to enable MODULES_USE_ELF_RELA for
loadable modules.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
arch/arm64/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7ff68c9..ef54a59 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -22,6 +22,7 @@ config ARM64
select HAVE_PERF_EVENTS
select HAVE_SPARSE_IRQ
select IRQ_DOMAIN
+ select MODULES_USE_ELF_RELA
select NO_BOOTMEM
select OF
select OF_EARLY_FLATTREE
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 1/4] arm64: Select MODULES_USE_ELF_RELA
2012-10-16 16:46 ` [PATCH 1/4] arm64: Select MODULES_USE_ELF_RELA Catalin Marinas
@ 2012-10-16 16:53 ` Will Deacon
0 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2012-10-16 16:53 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Oct 16, 2012 at 05:46:37PM +0100, Catalin Marinas wrote:
> With commit 786d35d4 (make most arch asm/module.h files use
> asm-generic/module.h) arm64 needs to enable MODULES_USE_ELF_RELA for
> loadable modules.
>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> ---
> arch/arm64/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 7ff68c9..ef54a59 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -22,6 +22,7 @@ config ARM64
> select HAVE_PERF_EVENTS
> select HAVE_SPARSE_IRQ
> select IRQ_DOMAIN
> + select MODULES_USE_ELF_RELA
> select NO_BOOTMEM
> select OF
> select OF_EARLY_FLATTREE
Acked-by: Will Deacon <will.deacon@arm.com>
Will
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/4] arm64: Fix the update_vsyscall() prototype
2012-10-16 16:46 [PATCH 0/4] arm64: Random fixes for 3.7 Catalin Marinas
2012-10-16 16:46 ` [PATCH 1/4] arm64: Select MODULES_USE_ELF_RELA Catalin Marinas
@ 2012-10-16 16:46 ` Catalin Marinas
2012-11-09 22:47 ` John Stultz
2012-10-16 16:46 ` [PATCH 3/4] arm64: Ignore memory blocks below PHYS_OFFSET Catalin Marinas
2012-10-16 16:46 ` [PATCH 4/4] arm64: No need to set the x0-x2 registers in start_thread() Catalin Marinas
3 siblings, 1 reply; 7+ messages in thread
From: Catalin Marinas @ 2012-10-16 16:46 UTC (permalink / raw)
To: linux-arm-kernel
With commit 576094b7 (time: Introduce new GENERIC_TIME_VSYSCALL) the old
update_vsyscall() prototype is no longer available. This patch updates
the arm64 port.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: John Stultz <john.stultz@linaro.org>
---
arch/arm64/kernel/vdso.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 17948fc..ba45794 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -28,6 +28,7 @@
#include <linux/sched.h>
#include <linux/signal.h>
#include <linux/slab.h>
+#include <linux/timekeeper_internal.h>
#include <linux/vmalloc.h>
#include <asm/cacheflush.h>
@@ -222,11 +223,10 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
/*
* Update the vDSO data page to keep in sync with kernel timekeeping.
*/
-void update_vsyscall(struct timespec *ts, struct timespec *wtm,
- struct clocksource *clock, u32 mult)
+void update_vsyscall(struct timekeeper *tk)
{
struct timespec xtime_coarse;
- u32 use_syscall = strcmp(clock->name, "arch_sys_counter");
+ u32 use_syscall = strcmp(tk->clock->name, "arch_sys_counter");
++vdso_data->tb_seq_count;
smp_wmb();
@@ -237,13 +237,13 @@ void update_vsyscall(struct timespec *ts, struct timespec *wtm,
vdso_data->xtime_coarse_nsec = xtime_coarse.tv_nsec;
if (!use_syscall) {
- vdso_data->cs_cycle_last = clock->cycle_last;
- vdso_data->xtime_clock_sec = ts->tv_sec;
- vdso_data->xtime_clock_nsec = ts->tv_nsec;
- vdso_data->cs_mult = mult;
- vdso_data->cs_shift = clock->shift;
- vdso_data->wtm_clock_sec = wtm->tv_sec;
- vdso_data->wtm_clock_nsec = wtm->tv_nsec;
+ vdso_data->cs_cycle_last = tk->clock->cycle_last;
+ vdso_data->xtime_clock_sec = tk->xtime_sec;
+ vdso_data->xtime_clock_nsec = tk->xtime_nsec >> tk->shift;
+ vdso_data->cs_mult = tk->mult;
+ vdso_data->cs_shift = tk->shift;
+ vdso_data->wtm_clock_sec = tk->wall_to_monotonic.tv_sec;
+ vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec;
}
smp_wmb();
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] arm64: Fix the update_vsyscall() prototype
2012-10-16 16:46 ` [PATCH 2/4] arm64: Fix the update_vsyscall() prototype Catalin Marinas
@ 2012-11-09 22:47 ` John Stultz
0 siblings, 0 replies; 7+ messages in thread
From: John Stultz @ 2012-11-09 22:47 UTC (permalink / raw)
To: linux-arm-kernel
On 10/16/2012 09:46 AM, Catalin Marinas wrote:
> With commit 576094b7 (time: Introduce new GENERIC_TIME_VSYSCALL) the old
> update_vsyscall() prototype is no longer available. This patch updates
> the arm64 port.
>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> Acked-by: Will Deacon <will.deacon@arm.com>
> Cc: John Stultz <john.stultz@linaro.org>
> ---
> arch/arm64/kernel/vdso.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
> index 17948fc..ba45794 100644
> --- a/arch/arm64/kernel/vdso.c
> +++ b/arch/arm64/kernel/vdso.c
> @@ -28,6 +28,7 @@
> #include <linux/sched.h>
> #include <linux/signal.h>
> #include <linux/slab.h>
> +#include <linux/timekeeper_internal.h>
> #include <linux/vmalloc.h>
>
> #include <asm/cacheflush.h>
> @@ -222,11 +223,10 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
> /*
> * Update the vDSO data page to keep in sync with kernel timekeeping.
> */
> -void update_vsyscall(struct timespec *ts, struct timespec *wtm,
> - struct clocksource *clock, u32 mult)
> +void update_vsyscall(struct timekeeper *tk)
> {
> struct timespec xtime_coarse;
> - u32 use_syscall = strcmp(clock->name, "arch_sys_counter");
> + u32 use_syscall = strcmp(tk->clock->name, "arch_sys_counter");
>
> ++vdso_data->tb_seq_count;
> smp_wmb();
> @@ -237,13 +237,13 @@ void update_vsyscall(struct timespec *ts, struct timespec *wtm,
> vdso_data->xtime_coarse_nsec = xtime_coarse.tv_nsec;
>
> if (!use_syscall) {
> - vdso_data->cs_cycle_last = clock->cycle_last;
> - vdso_data->xtime_clock_sec = ts->tv_sec;
> - vdso_data->xtime_clock_nsec = ts->tv_nsec;
> - vdso_data->cs_mult = mult;
> - vdso_data->cs_shift = clock->shift;
> - vdso_data->wtm_clock_sec = wtm->tv_sec;
> - vdso_data->wtm_clock_nsec = wtm->tv_nsec;
> + vdso_data->cs_cycle_last = tk->clock->cycle_last;
> + vdso_data->xtime_clock_sec = tk->xtime_sec;
> + vdso_data->xtime_clock_nsec = tk->xtime_nsec >> tk->shift;
Sorry for the collision here!
One word of warning: Truncating the sub-ns base like this can cause
small single ns inconsistencies from the vsyscalls.
So either use GENERIC_TIME_VSYSCALL_OLD to enable the 1ns generic
rounding-up code, or rework the vsyscall code to use the sub-ns
granularity as done in 650ea02475106e8d6bdf561896d2ffe0d1c0ebb4 for
x86_64. I hope to drop the _OLD config eventually, so this will need to
be done at some point.
thanks
-john
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/4] arm64: Ignore memory blocks below PHYS_OFFSET
2012-10-16 16:46 [PATCH 0/4] arm64: Random fixes for 3.7 Catalin Marinas
2012-10-16 16:46 ` [PATCH 1/4] arm64: Select MODULES_USE_ELF_RELA Catalin Marinas
2012-10-16 16:46 ` [PATCH 2/4] arm64: Fix the update_vsyscall() prototype Catalin Marinas
@ 2012-10-16 16:46 ` Catalin Marinas
2012-10-16 16:46 ` [PATCH 4/4] arm64: No need to set the x0-x2 registers in start_thread() Catalin Marinas
3 siblings, 0 replies; 7+ messages in thread
From: Catalin Marinas @ 2012-10-16 16:46 UTC (permalink / raw)
To: linux-arm-kernel
According to Documentation/arm64/booting.txt, the kernel image must be
loaded at a pre-defined offset from the start of RAM so that the kernel
can calculate PHYS_OFFSET based on this address. If the DT contains
memory blocks below this PHYS_OFFSET, report them and ignore the
corresponding memory range.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
arch/arm64/kernel/setup.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 48ffb9f..7665a9b 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -170,7 +170,19 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
+ base &= PAGE_MASK;
size &= PAGE_MASK;
+ if (base + size < PHYS_OFFSET) {
+ pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
+ base, base + size);
+ return;
+ }
+ if (base < PHYS_OFFSET) {
+ pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
+ base, PHYS_OFFSET);
+ size -= PHYS_OFFSET - base;
+ base = PHYS_OFFSET;
+ }
memblock_add(base, size);
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] arm64: No need to set the x0-x2 registers in start_thread()
2012-10-16 16:46 [PATCH 0/4] arm64: Random fixes for 3.7 Catalin Marinas
` (2 preceding siblings ...)
2012-10-16 16:46 ` [PATCH 3/4] arm64: Ignore memory blocks below PHYS_OFFSET Catalin Marinas
@ 2012-10-16 16:46 ` Catalin Marinas
3 siblings, 0 replies; 7+ messages in thread
From: Catalin Marinas @ 2012-10-16 16:46 UTC (permalink / raw)
To: linux-arm-kernel
For historical reasons, ARM used to set r0-r2 in start_thread() to the
first values on the user stack when starting a new user application. The
same logic has been inherited in AArch64. The x0 register is overridden
by the sys_execve() return value so it's always zero on success. The x1
and x2 registers are ignored by AArch64 and EABI AArch32 applications,
so we can safely remove the register setting for both native and compat
user space.
This also fixes a potential fault with the kernel accessing user space
stack directly.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
---
arch/arm64/include/asm/processor.h | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 39a208a..5d81004 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -92,30 +92,20 @@ static inline void start_thread_common(struct pt_regs *regs, unsigned long pc)
static inline void start_thread(struct pt_regs *regs, unsigned long pc,
unsigned long sp)
{
- unsigned long *stack = (unsigned long *)sp;
-
start_thread_common(regs, pc);
regs->pstate = PSR_MODE_EL0t;
regs->sp = sp;
- regs->regs[2] = stack[2]; /* x2 (envp) */
- regs->regs[1] = stack[1]; /* x1 (argv) */
- regs->regs[0] = stack[0]; /* x0 (argc) */
}
#ifdef CONFIG_COMPAT
static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
unsigned long sp)
{
- unsigned int *stack = (unsigned int *)sp;
-
start_thread_common(regs, pc);
regs->pstate = COMPAT_PSR_MODE_USR;
if (pc & 1)
regs->pstate |= COMPAT_PSR_T_BIT;
regs->compat_sp = sp;
- regs->regs[2] = stack[2]; /* x2 (envp) */
- regs->regs[1] = stack[1]; /* x1 (argv) */
- regs->regs[0] = stack[0]; /* x0 (argc) */
}
#endif
^ permalink raw reply related [flat|nested] 7+ messages in thread