All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: KVM: Guests can skip __install_bp_hardening_cb()s HYP work
@ 2018-09-21 20:49 ` James Morse
  0 siblings, 0 replies; 6+ messages in thread
From: James Morse @ 2018-09-21 20:49 UTC (permalink / raw
  To: linux-arm-kernel

enable_smccc_arch_workaround_1() passes NULL as the hyp_vecs start and
end if the HVC conduit is in use, and ARM_SMCCC_ARCH_WORKAROUND_1 is
detected.

If the guest kernel happened to be built with KVM_INDIRECT_VECTORS,
we go on to allocate a slot, memcpy() the empty workaround in and
do the appropriate cache maintenance.

This works as we always tell memcpy() the range is 0, so it never
accesses the NULL src pointer, but we still do the cache maintenance.

If hyp_vecs_start is NULL we know we're a guest, just update the fn
like the !KVM_INDIRECT_VECTORS version.

Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Julien Thierry <julien.thierry@arm.com>
---
 arch/arm64/kernel/cpu_errata.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index dec10898d688..25305f8a8670 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -116,6 +116,15 @@ static void __install_bp_hardening_cb(bp_hardening_cb_t fn,
 	static DEFINE_SPINLOCK(bp_lock);
 	int cpu, slot = -1;
 
+	/*
+	 * enable_smccc_arch_workaround_1() passes NULL for the hyp_vecs
+	 * start/end if we're a guest. Skip the hyp-vectors work.
+	 */
+	if (!hyp_vecs_start) {
+		__this_cpu_write(bp_hardening_data.fn, fn);
+		return;
+	}
+
 	spin_lock(&bp_lock);
 	for_each_possible_cpu(cpu) {
 		if (per_cpu(bp_hardening_data.fn, cpu) == fn) {
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] arm64: KVM: Guests can skip __install_bp_hardening_cb()s HYP work
@ 2018-09-21 20:49 ` James Morse
  0 siblings, 0 replies; 6+ messages in thread
From: James Morse @ 2018-09-21 20:49 UTC (permalink / raw
  To: linux-arm-kernel; +Cc: Marc Zyngier, Catalin Marinas, Will Deacon, kvmarm

enable_smccc_arch_workaround_1() passes NULL as the hyp_vecs start and
end if the HVC conduit is in use, and ARM_SMCCC_ARCH_WORKAROUND_1 is
detected.

If the guest kernel happened to be built with KVM_INDIRECT_VECTORS,
we go on to allocate a slot, memcpy() the empty workaround in and
do the appropriate cache maintenance.

This works as we always tell memcpy() the range is 0, so it never
accesses the NULL src pointer, but we still do the cache maintenance.

If hyp_vecs_start is NULL we know we're a guest, just update the fn
like the !KVM_INDIRECT_VECTORS version.

Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Julien Thierry <julien.thierry@arm.com>
---
 arch/arm64/kernel/cpu_errata.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index dec10898d688..25305f8a8670 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -116,6 +116,15 @@ static void __install_bp_hardening_cb(bp_hardening_cb_t fn,
 	static DEFINE_SPINLOCK(bp_lock);
 	int cpu, slot = -1;
 
+	/*
+	 * enable_smccc_arch_workaround_1() passes NULL for the hyp_vecs
+	 * start/end if we're a guest. Skip the hyp-vectors work.
+	 */
+	if (!hyp_vecs_start) {
+		__this_cpu_write(bp_hardening_data.fn, fn);
+		return;
+	}
+
 	spin_lock(&bp_lock);
 	for_each_possible_cpu(cpu) {
 		if (per_cpu(bp_hardening_data.fn, cpu) == fn) {
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] arm64: KVM: Guests can skip __install_bp_hardening_cb()s HYP work
  2018-09-21 20:49 ` James Morse
@ 2018-10-19 10:17   ` Marc Zyngier
  -1 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2018-10-19 10:17 UTC (permalink / raw
  To: linux-arm-kernel

On 21/09/18 21:49, James Morse wrote:
> enable_smccc_arch_workaround_1() passes NULL as the hyp_vecs start and
> end if the HVC conduit is in use, and ARM_SMCCC_ARCH_WORKAROUND_1 is
> detected.
> 
> If the guest kernel happened to be built with KVM_INDIRECT_VECTORS,
> we go on to allocate a slot, memcpy() the empty workaround in and
> do the appropriate cache maintenance.
> 
> This works as we always tell memcpy() the range is 0, so it never
> accesses the NULL src pointer, but we still do the cache maintenance.
> 
> If hyp_vecs_start is NULL we know we're a guest, just update the fn
> like the !KVM_INDIRECT_VECTORS version.
> 
> Signed-off-by: James Morse <james.morse@arm.com>
> Reviewed-by: Julien Thierry <julien.thierry@arm.com>

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

Catalin: could you sneak this one in for 4.20? It is strictly a KVM
patch, but its location makes it more suitable for the arm64 tree...

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: KVM: Guests can skip __install_bp_hardening_cb()s HYP work
@ 2018-10-19 10:17   ` Marc Zyngier
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2018-10-19 10:17 UTC (permalink / raw
  To: James Morse, linux-arm-kernel; +Cc: Catalin Marinas, Will Deacon, kvmarm

On 21/09/18 21:49, James Morse wrote:
> enable_smccc_arch_workaround_1() passes NULL as the hyp_vecs start and
> end if the HVC conduit is in use, and ARM_SMCCC_ARCH_WORKAROUND_1 is
> detected.
> 
> If the guest kernel happened to be built with KVM_INDIRECT_VECTORS,
> we go on to allocate a slot, memcpy() the empty workaround in and
> do the appropriate cache maintenance.
> 
> This works as we always tell memcpy() the range is 0, so it never
> accesses the NULL src pointer, but we still do the cache maintenance.
> 
> If hyp_vecs_start is NULL we know we're a guest, just update the fn
> like the !KVM_INDIRECT_VECTORS version.
> 
> Signed-off-by: James Morse <james.morse@arm.com>
> Reviewed-by: Julien Thierry <julien.thierry@arm.com>

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

Catalin: could you sneak this one in for 4.20? It is strictly a KVM
patch, but its location makes it more suitable for the arm64 tree...

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] arm64: KVM: Guests can skip __install_bp_hardening_cb()s HYP work
  2018-10-19 10:17   ` Marc Zyngier
@ 2018-10-19 14:38     ` Catalin Marinas
  -1 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2018-10-19 14:38 UTC (permalink / raw
  To: linux-arm-kernel

On Fri, Oct 19, 2018 at 11:17:32AM +0100, Marc Zyngier wrote:
> On 21/09/18 21:49, James Morse wrote:
> > enable_smccc_arch_workaround_1() passes NULL as the hyp_vecs start and
> > end if the HVC conduit is in use, and ARM_SMCCC_ARCH_WORKAROUND_1 is
> > detected.
> > 
> > If the guest kernel happened to be built with KVM_INDIRECT_VECTORS,
> > we go on to allocate a slot, memcpy() the empty workaround in and
> > do the appropriate cache maintenance.
> > 
> > This works as we always tell memcpy() the range is 0, so it never
> > accesses the NULL src pointer, but we still do the cache maintenance.
> > 
> > If hyp_vecs_start is NULL we know we're a guest, just update the fn
> > like the !KVM_INDIRECT_VECTORS version.
> > 
> > Signed-off-by: James Morse <james.morse@arm.com>
> > Reviewed-by: Julien Thierry <julien.thierry@arm.com>
> 
> Acked-by: Marc Zyngier <marc.zyngier@arm.com>
> 
> Catalin: could you sneak this one in for 4.20? It is strictly a KVM
> patch, but its location makes it more suitable for the arm64 tree...

Done.

-- 
Catalin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: KVM: Guests can skip __install_bp_hardening_cb()s HYP work
@ 2018-10-19 14:38     ` Catalin Marinas
  0 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2018-10-19 14:38 UTC (permalink / raw
  To: Marc Zyngier; +Cc: Will Deacon, kvmarm, linux-arm-kernel

On Fri, Oct 19, 2018 at 11:17:32AM +0100, Marc Zyngier wrote:
> On 21/09/18 21:49, James Morse wrote:
> > enable_smccc_arch_workaround_1() passes NULL as the hyp_vecs start and
> > end if the HVC conduit is in use, and ARM_SMCCC_ARCH_WORKAROUND_1 is
> > detected.
> > 
> > If the guest kernel happened to be built with KVM_INDIRECT_VECTORS,
> > we go on to allocate a slot, memcpy() the empty workaround in and
> > do the appropriate cache maintenance.
> > 
> > This works as we always tell memcpy() the range is 0, so it never
> > accesses the NULL src pointer, but we still do the cache maintenance.
> > 
> > If hyp_vecs_start is NULL we know we're a guest, just update the fn
> > like the !KVM_INDIRECT_VECTORS version.
> > 
> > Signed-off-by: James Morse <james.morse@arm.com>
> > Reviewed-by: Julien Thierry <julien.thierry@arm.com>
> 
> Acked-by: Marc Zyngier <marc.zyngier@arm.com>
> 
> Catalin: could you sneak this one in for 4.20? It is strictly a KVM
> patch, but its location makes it more suitable for the arm64 tree...

Done.

-- 
Catalin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-10-19 14:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-21 20:49 [PATCH] arm64: KVM: Guests can skip __install_bp_hardening_cb()s HYP work James Morse
2018-09-21 20:49 ` James Morse
2018-10-19 10:17 ` Marc Zyngier
2018-10-19 10:17   ` Marc Zyngier
2018-10-19 14:38   ` Catalin Marinas
2018-10-19 14:38     ` Catalin Marinas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.