* [PATCH v2 1/4] arm64: Introduce a way to disable the 32bit vdso
[not found] <20200706163802.1836732-1-maz@kernel.org>
@ 2020-07-06 16:37 ` Marc Zyngier
2020-07-10 14:02 ` Sasha Levin
2020-07-06 16:38 ` [PATCH v2 2/4] arm64: arch_timer: Allow an workaround descriptor to disable compat vdso Marc Zyngier
2020-07-06 16:38 ` [PATCH v2 3/4] arm64: arch_timer: Disable the compat vdso for cores affected by ARM64_WORKAROUND_1418040 Marc Zyngier
2 siblings, 1 reply; 6+ messages in thread
From: Marc Zyngier @ 2020-07-06 16:37 UTC (permalink / raw)
To: Will Deacon, Catalin Marinas
Cc: Daniel Lezcano, Vincenzo Frascino, Thomas Gleixner,
linux-arm-kernel, linux-kernel, kernel-team, stable, Mark Rutland
We have a class of errata (grouped under the ARM64_WORKAROUND_1418040
banner) that force the trapping of counter access from 32bit EL0.
We would normally disable the whole vdso for such defect, except that
it would disable it for 64bit userspace as well, which is a shame.
Instead, add a new vdso_clock_mode, which signals that the vdso
isn't usable for compat tasks. This gets checked in the new
vdso_clocksource_ok() helper, now provided for the 32bit vdso.
Cc: stable@vger.kernel.org
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
arch/arm64/include/asm/vdso/clocksource.h | 7 +++++--
arch/arm64/include/asm/vdso/compat_gettimeofday.h | 8 +++++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/include/asm/vdso/clocksource.h b/arch/arm64/include/asm/vdso/clocksource.h
index df6ea65c1dec..b054d9febfb5 100644
--- a/arch/arm64/include/asm/vdso/clocksource.h
+++ b/arch/arm64/include/asm/vdso/clocksource.h
@@ -2,7 +2,10 @@
#ifndef __ASM_VDSOCLOCKSOURCE_H
#define __ASM_VDSOCLOCKSOURCE_H
-#define VDSO_ARCH_CLOCKMODES \
- VDSO_CLOCKMODE_ARCHTIMER
+#define VDSO_ARCH_CLOCKMODES \
+ /* vdso clocksource for both 32 and 64bit tasks */ \
+ VDSO_CLOCKMODE_ARCHTIMER, \
+ /* vdso clocksource for 64bit tasks only */ \
+ VDSO_CLOCKMODE_ARCHTIMER_NOCOMPAT
#endif
diff --git a/arch/arm64/include/asm/vdso/compat_gettimeofday.h b/arch/arm64/include/asm/vdso/compat_gettimeofday.h
index b6907ae78e53..9a625e8947ff 100644
--- a/arch/arm64/include/asm/vdso/compat_gettimeofday.h
+++ b/arch/arm64/include/asm/vdso/compat_gettimeofday.h
@@ -111,7 +111,7 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
* update. Return something. Core will do another round and then
* see the mode change and fallback to the syscall.
*/
- if (clock_mode == VDSO_CLOCKMODE_NONE)
+ if (clock_mode != VDSO_CLOCKMODE_ARCHTIMER)
return 0;
/*
@@ -152,6 +152,12 @@ static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
return ret;
}
+static inline bool vdso_clocksource_ok(const struct vdso_data *vd)
+{
+ return vd->clock_mode == VDSO_CLOCKMODE_ARCHTIMER;
+}
+#define vdso_clocksource_ok vdso_clocksource_ok
+
#endif /* !__ASSEMBLY__ */
#endif /* __ASM_VDSO_GETTIMEOFDAY_H */
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2 1/4] arm64: Introduce a way to disable the 32bit vdso
2020-07-06 16:37 ` [PATCH v2 1/4] arm64: Introduce a way to disable the 32bit vdso Marc Zyngier
@ 2020-07-10 14:02 ` Sasha Levin
0 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2020-07-10 14:02 UTC (permalink / raw)
To: Sasha Levin, Marc Zyngier, Will Deacon; +Cc: Daniel Lezcano, stable, stable
Hi
[This is an automated email]
This commit has been processed because it contains a -stable tag.
The stable tag indicates that it's relevant for the following trees: all
The bot has tested the following trees: v5.7.7, v5.4.50, v4.19.131, v4.14.187, v4.9.229, v4.4.229.
v5.7.7: Build OK!
v5.4.50: Failed to apply! Possible dependencies:
04bb96427d4ee ("ARM: 8947/1: Fix __arch_get_hw_counter() access to CNTVCT")
20e2fc42312f9 ("ARM: 8930/1: Add support for generic vDSO")
31fdcac07f679 ("arm64: Introduce asm/vdso/clocksource.h")
5e3c6a312a094 ("ARM/arm64: vdso: Use common vdso clock mode storage")
v4.19.131: Failed to apply! Possible dependencies:
31fdcac07f679 ("arm64: Introduce asm/vdso/clocksource.h")
5e3c6a312a094 ("ARM/arm64: vdso: Use common vdso clock mode storage")
6bf752daca07c ("powerpc: implement CONFIG_DEBUG_VIRTUAL")
942fa985e9f16 ("32-bit userspace ABI: introduce ARCH_32BIT_OFF_T config option")
aef0f78e7460c ("binfmt_flat: add a ARCH_HAS_BINFMT_FLAT option")
bdd15a288492f ("binfmt_flat: replace flat_argvp_envp_on_stack with a Kconfig variable")
c32e64e852f3f ("csky: Build infrastructure")
e0a9317d90042 ("hexagon: use generic dma_noncoherent_ops")
ea6a37373f9ac ("MIPS: Avoid FP ELF checks when CONFIG_MIPS_FP_SUPPORT=n")
f406f222d4b21 ("hexagon: implement the sync_sg_for_device DMA operation")
v4.14.187: Failed to apply! Possible dependencies:
104daea149c45 ("kconfig: reference environment variables directly and remove 'option env='")
18492685e479f ("kconfig: use yylineno option instead of manual lineno increments")
21c54b7747447 ("kconfig: show compiler version text in the top comment")
31fdcac07f679 ("arm64: Introduce asm/vdso/clocksource.h")
32a94b8b0c3e5 ("kconfig: remove duplicated file name and lineno of recursive inclusion")
379a8eb8eb1a5 ("kconfig: detect recursive inclusion earlier")
5ae6fcc4bb82b ("kconfig: fix line number in recursive inclusion error message")
5e3c6a312a094 ("ARM/arm64: vdso: Use common vdso clock mode storage")
79b05c1f31e2e ("um: stop abusing KBUILD_KCONFIG")
7f5c1ea3b707f ("c6x: use generic dma_noncoherent_ops")
87a4c375995ed ("kconfig: include kernel/Kconfig.preempt from init/Kconfig")
942fa985e9f16 ("32-bit userspace ABI: introduce ARCH_32BIT_OFF_T config option")
9e3e10c725360 ("kconfig: send error messages to stderr")
c32e64e852f3f ("csky: Build infrastructure")
cd81fc82b93fa ("kconfig: add xstrdup() helper")
d717f24d8c680 ("kconfig: add xrealloc() helper")
e0a9317d90042 ("hexagon: use generic dma_noncoherent_ops")
e2c75e7667c73 ("kconfig: tests: test if recursive inclusion is detected")
e71ea3badae55 ("nds32: Build infrastructure")
f163977d21a2b ("um: cleanup Kconfig files")
fbe934d69eb7e ("RISC-V: Build Infrastructure")
v4.9.229: Failed to apply! Possible dependencies:
2fbadc3002c5f ("arm/arm64: xen: Move shared architecture headers to include/xen/arm")
31fdcac07f679 ("arm64: Introduce asm/vdso/clocksource.h")
5299709d0a873 ("treewide: Constify most dma_map_ops structures")
5e3c6a312a094 ("ARM/arm64: vdso: Use common vdso clock mode storage")
7f5c1ea3b707f ("c6x: use generic dma_noncoherent_ops")
942fa985e9f16 ("32-bit userspace ABI: introduce ARCH_32BIT_OFF_T config option")
eb17726b00b32 ("m32r: add simple dma")
v4.4.229: Failed to apply! Possible dependencies:
0cb0786bac159 ("ARM64: PCI: Support ACPI-based PCI host controller")
1a4f93f7112fd ("PCI: Factor DT-specific pci_bus_find_domain_nr() code out")
1bd37a6835bef ("iommu/arm-smmu: Workaround for ThunderX erratum #27704")
1d8f51d41fc71 ("arm/arm64: arch_timer: Use archdata to indicate vdso suitability")
21266be9ed542 ("arch: consolidate CONFIG_STRICT_DEVM in lib/Kconfig.debug")
2ab51ddeca2fc ("ARM64: PCI: Add acpi_pci_bus_find_domain_nr()")
31fdcac07f679 ("arm64: Introduce asm/vdso/clocksource.h")
46fd5c6b30594 ("clocksource/drivers/arm_arch_timer: Control the evtstrm via the cmdline")
4e3e9b6997b24 ("iommu/arm-smmu: Add support for 16 bit VMID")
5e3c6a312a094 ("ARM/arm64: vdso: Use common vdso clock mode storage")
75df1386557c2 ("iommu/arm-smmu: Invalidate TLBs properly")
942fa985e9f16 ("32-bit userspace ABI: introduce ARCH_32BIT_OFF_T config option")
9c7cb891ecfea ("PCI: Refactor pci_bus_assign_domain_nr() for CONFIG_PCI_DOMAINS_GENERIC")
cd5f22d7967f6 ("arm64: arch_timer: simplify accessors")
f6dc1576cd517 ("arm64: arch_timer: Work around QorIQ Erratum A-008585")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
--
Thanks
Sasha
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/4] arm64: arch_timer: Allow an workaround descriptor to disable compat vdso
[not found] <20200706163802.1836732-1-maz@kernel.org>
2020-07-06 16:37 ` [PATCH v2 1/4] arm64: Introduce a way to disable the 32bit vdso Marc Zyngier
@ 2020-07-06 16:38 ` Marc Zyngier
2020-07-06 16:55 ` Mark Rutland
2020-07-06 16:38 ` [PATCH v2 3/4] arm64: arch_timer: Disable the compat vdso for cores affected by ARM64_WORKAROUND_1418040 Marc Zyngier
2 siblings, 1 reply; 6+ messages in thread
From: Marc Zyngier @ 2020-07-06 16:38 UTC (permalink / raw)
To: Will Deacon, Catalin Marinas
Cc: Daniel Lezcano, Vincenzo Frascino, Thomas Gleixner,
linux-arm-kernel, linux-kernel, kernel-team, stable
As we are about to disable the vdso for compat tasks in some circumstances,
let's allow a workaround descriptor to express exactly that.
Cc: stable@vger.kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
arch/arm64/include/asm/arch_timer.h | 1 +
drivers/clocksource/arm_arch_timer.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
index 7ae54d7d333a..9f0ec21d6327 100644
--- a/arch/arm64/include/asm/arch_timer.h
+++ b/arch/arm64/include/asm/arch_timer.h
@@ -58,6 +58,7 @@ struct arch_timer_erratum_workaround {
u64 (*read_cntvct_el0)(void);
int (*set_next_event_phys)(unsigned long, struct clock_event_device *);
int (*set_next_event_virt)(unsigned long, struct clock_event_device *);
+ bool disable_compat_vdso;
};
DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *,
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index ecf7b7db2d05..a8e4fb429f52 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -566,6 +566,9 @@ void arch_timer_enable_workaround(const struct arch_timer_erratum_workaround *wa
if (wa->read_cntvct_el0) {
clocksource_counter.vdso_clock_mode = VDSO_CLOCKMODE_NONE;
vdso_default = VDSO_CLOCKMODE_NONE;
+ } else if (wa->disable_compat_vdso && vdso_default != VDSO_CLOCKMODE_NONE) {
+ vdso_default = VDSO_CLOCKMODE_ARCHTIMER_NOCOMPAT;
+ clocksource_counter.vdso_clock_mode = vdso_default;
}
}
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2 2/4] arm64: arch_timer: Allow an workaround descriptor to disable compat vdso
2020-07-06 16:38 ` [PATCH v2 2/4] arm64: arch_timer: Allow an workaround descriptor to disable compat vdso Marc Zyngier
@ 2020-07-06 16:55 ` Mark Rutland
0 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2020-07-06 16:55 UTC (permalink / raw)
To: Marc Zyngier
Cc: Will Deacon, Catalin Marinas, Daniel Lezcano, Vincenzo Frascino,
Thomas Gleixner, linux-arm-kernel, linux-kernel, kernel-team,
stable
On Mon, Jul 06, 2020 at 05:38:00PM +0100, Marc Zyngier wrote:
> As we are about to disable the vdso for compat tasks in some circumstances,
> let's allow a workaround descriptor to express exactly that.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Mark.
> ---
> arch/arm64/include/asm/arch_timer.h | 1 +
> drivers/clocksource/arm_arch_timer.c | 3 +++
> 2 files changed, 4 insertions(+)
>
> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
> index 7ae54d7d333a..9f0ec21d6327 100644
> --- a/arch/arm64/include/asm/arch_timer.h
> +++ b/arch/arm64/include/asm/arch_timer.h
> @@ -58,6 +58,7 @@ struct arch_timer_erratum_workaround {
> u64 (*read_cntvct_el0)(void);
> int (*set_next_event_phys)(unsigned long, struct clock_event_device *);
> int (*set_next_event_virt)(unsigned long, struct clock_event_device *);
> + bool disable_compat_vdso;
> };
>
> DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *,
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index ecf7b7db2d05..a8e4fb429f52 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -566,6 +566,9 @@ void arch_timer_enable_workaround(const struct arch_timer_erratum_workaround *wa
> if (wa->read_cntvct_el0) {
> clocksource_counter.vdso_clock_mode = VDSO_CLOCKMODE_NONE;
> vdso_default = VDSO_CLOCKMODE_NONE;
> + } else if (wa->disable_compat_vdso && vdso_default != VDSO_CLOCKMODE_NONE) {
> + vdso_default = VDSO_CLOCKMODE_ARCHTIMER_NOCOMPAT;
> + clocksource_counter.vdso_clock_mode = vdso_default;
> }
> }
>
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 3/4] arm64: arch_timer: Disable the compat vdso for cores affected by ARM64_WORKAROUND_1418040
[not found] <20200706163802.1836732-1-maz@kernel.org>
2020-07-06 16:37 ` [PATCH v2 1/4] arm64: Introduce a way to disable the 32bit vdso Marc Zyngier
2020-07-06 16:38 ` [PATCH v2 2/4] arm64: arch_timer: Allow an workaround descriptor to disable compat vdso Marc Zyngier
@ 2020-07-06 16:38 ` Marc Zyngier
2020-07-06 16:57 ` Mark Rutland
2 siblings, 1 reply; 6+ messages in thread
From: Marc Zyngier @ 2020-07-06 16:38 UTC (permalink / raw)
To: Will Deacon, Catalin Marinas
Cc: Daniel Lezcano, Vincenzo Frascino, Thomas Gleixner,
linux-arm-kernel, linux-kernel, kernel-team, stable
ARM64_WORKAROUND_1418040 requires that AArch32 EL0 accesses to
the virtual counter register are trapped and emulated by the kernel.
This makes the vdso pretty pointless, and in some cases livelock
prone.
Provide a workaround entry that limits the vdso to 64bit tasks.
Cc: stable@vger.kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
drivers/clocksource/arm_arch_timer.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index a8e4fb429f52..6c3e84180146 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -480,6 +480,14 @@ static const struct arch_timer_erratum_workaround ool_workarounds[] = {
.set_next_event_virt = erratum_set_next_event_tval_virt,
},
#endif
+#ifdef CONFIG_ARM64_ERRATUM_1418040
+ {
+ .match_type = ate_match_local_cap_id,
+ .id = (void *)ARM64_WORKAROUND_1418040,
+ .desc = "ARM erratum 1418040",
+ .disable_compat_vdso = true,
+ },
+#endif
};
typedef bool (*ate_match_fn_t)(const struct arch_timer_erratum_workaround *,
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2 3/4] arm64: arch_timer: Disable the compat vdso for cores affected by ARM64_WORKAROUND_1418040
2020-07-06 16:38 ` [PATCH v2 3/4] arm64: arch_timer: Disable the compat vdso for cores affected by ARM64_WORKAROUND_1418040 Marc Zyngier
@ 2020-07-06 16:57 ` Mark Rutland
0 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2020-07-06 16:57 UTC (permalink / raw)
To: Marc Zyngier
Cc: Will Deacon, Catalin Marinas, Daniel Lezcano, Vincenzo Frascino,
Thomas Gleixner, linux-arm-kernel, linux-kernel, kernel-team,
stable
On Mon, Jul 06, 2020 at 05:38:01PM +0100, Marc Zyngier wrote:
> ARM64_WORKAROUND_1418040 requires that AArch32 EL0 accesses to
> the virtual counter register are trapped and emulated by the kernel.
> This makes the vdso pretty pointless, and in some cases livelock
> prone.
>
> Provide a workaround entry that limits the vdso to 64bit tasks.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Mark.
> ---
> drivers/clocksource/arm_arch_timer.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index a8e4fb429f52..6c3e84180146 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -480,6 +480,14 @@ static const struct arch_timer_erratum_workaround ool_workarounds[] = {
> .set_next_event_virt = erratum_set_next_event_tval_virt,
> },
> #endif
> +#ifdef CONFIG_ARM64_ERRATUM_1418040
> + {
> + .match_type = ate_match_local_cap_id,
> + .id = (void *)ARM64_WORKAROUND_1418040,
> + .desc = "ARM erratum 1418040",
> + .disable_compat_vdso = true,
> + },
> +#endif
> };
>
> typedef bool (*ate_match_fn_t)(const struct arch_timer_erratum_workaround *,
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread