All of lore.kernel.org
 help / color / mirror / Atom feed
* [stable:PATCH] KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU
@ 2022-03-08 16:29 ` James Morse
  0 siblings, 0 replies; 7+ messages in thread
From: James Morse @ 2022-03-08 16:29 UTC (permalink / raw)
  To: stable, kvmarm; +Cc: Marc Zyngier, Alexandru Elisei, james.morse

The logic in commit 2a5f1b67ec57 "KVM: arm64: Don't access PMCR_EL0 when no
PMU is available" relies on an empty reset handler being benign.  This was
not the case in earlier kernel versions, so the stable backport of this
patch is causing problems.

KVMs behaviour in this area changed over time. In particular, prior to commit
03fdfb269009 ("KVM: arm64: Don't write junk to sysregs on reset"), an empty
reset handler will trigger a warning, as the guest registers have been
poisoned.
Prior to commit 20589c8cc47d ("arm/arm64: KVM: Don't panic on failure to
properly reset system registers"), this warning was a panic().

Instead of reverting the backport, make it write 0 to the sys_reg[] array.
This keeps the reset logic happy, and the dodgy value can't be seen by
the guest as it can't request the emulation.

The original bug was accessing the PMCR_EL0 register on CPUs that don't
implement that feature. There is no known silicon that does this, but
v4.9's ACPI support is unable to find the PMU, so triggers this code:

| Kernel panic - not syncing: Didn't reset vcpu_sys_reg(24)
| CPU: 1 PID: 3055 Comm: lkvm Not tainted 4.9.302-00032-g64e078a56789 #13476
| Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Jul 30 2018
| Call trace:
| [<ffff00000808b4b0>] dump_backtrace+0x0/0x1a0
| [<ffff00000808b664>] show_stack+0x14/0x20
| [<ffff0000088f0e18>] dump_stack+0x98/0xb8
| [<ffff0000088eef08>] panic+0x118/0x274
| [<ffff0000080b50e0>] access_actlr+0x0/0x20
| [<ffff0000080b2620>] kvm_reset_vcpu+0x5c/0xac
| [<ffff0000080ac688>] kvm_arch_vcpu_ioctl+0x3e4/0x490
| [<ffff0000080a382c>] kvm_vcpu_ioctl+0x5b8/0x720
| [<ffff000008201e44>] do_vfs_ioctl+0x2f4/0x884
| [<ffff00000820244c>] SyS_ioctl+0x78/0x9c
| [<ffff000008083a9c>] __sys_trace_return+0x0/0x4

Cc: <stable@vger.kernel.org> # < v5.3 with 2a5f1b67ec57 backported
Signed-off-by: James Morse <james.morse@arm.com>
---
 arch/arm64/kvm/sys_regs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 10d80456f38f..8d548fdbb6b2 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -451,8 +451,10 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 	u64 pmcr, val;
 
 	/* No PMU available, PMCR_EL0 may UNDEF... */
-	if (!kvm_arm_support_pmu_v3())
+	if (!kvm_arm_support_pmu_v3()) {
+		vcpu_sys_reg(vcpu, PMCR_EL0) = 0;
 		return;
+	}
 
 	pmcr = read_sysreg(pmcr_el0);
 	/*
-- 
2.30.2


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

* [stable:PATCH] KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU
@ 2022-03-08 16:29 ` James Morse
  0 siblings, 0 replies; 7+ messages in thread
From: James Morse @ 2022-03-08 16:29 UTC (permalink / raw)
  To: stable, kvmarm; +Cc: Marc Zyngier

The logic in commit 2a5f1b67ec57 "KVM: arm64: Don't access PMCR_EL0 when no
PMU is available" relies on an empty reset handler being benign.  This was
not the case in earlier kernel versions, so the stable backport of this
patch is causing problems.

KVMs behaviour in this area changed over time. In particular, prior to commit
03fdfb269009 ("KVM: arm64: Don't write junk to sysregs on reset"), an empty
reset handler will trigger a warning, as the guest registers have been
poisoned.
Prior to commit 20589c8cc47d ("arm/arm64: KVM: Don't panic on failure to
properly reset system registers"), this warning was a panic().

Instead of reverting the backport, make it write 0 to the sys_reg[] array.
This keeps the reset logic happy, and the dodgy value can't be seen by
the guest as it can't request the emulation.

The original bug was accessing the PMCR_EL0 register on CPUs that don't
implement that feature. There is no known silicon that does this, but
v4.9's ACPI support is unable to find the PMU, so triggers this code:

| Kernel panic - not syncing: Didn't reset vcpu_sys_reg(24)
| CPU: 1 PID: 3055 Comm: lkvm Not tainted 4.9.302-00032-g64e078a56789 #13476
| Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Jul 30 2018
| Call trace:
| [<ffff00000808b4b0>] dump_backtrace+0x0/0x1a0
| [<ffff00000808b664>] show_stack+0x14/0x20
| [<ffff0000088f0e18>] dump_stack+0x98/0xb8
| [<ffff0000088eef08>] panic+0x118/0x274
| [<ffff0000080b50e0>] access_actlr+0x0/0x20
| [<ffff0000080b2620>] kvm_reset_vcpu+0x5c/0xac
| [<ffff0000080ac688>] kvm_arch_vcpu_ioctl+0x3e4/0x490
| [<ffff0000080a382c>] kvm_vcpu_ioctl+0x5b8/0x720
| [<ffff000008201e44>] do_vfs_ioctl+0x2f4/0x884
| [<ffff00000820244c>] SyS_ioctl+0x78/0x9c
| [<ffff000008083a9c>] __sys_trace_return+0x0/0x4

Cc: <stable@vger.kernel.org> # < v5.3 with 2a5f1b67ec57 backported
Signed-off-by: James Morse <james.morse@arm.com>
---
 arch/arm64/kvm/sys_regs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 10d80456f38f..8d548fdbb6b2 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -451,8 +451,10 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 	u64 pmcr, val;
 
 	/* No PMU available, PMCR_EL0 may UNDEF... */
-	if (!kvm_arm_support_pmu_v3())
+	if (!kvm_arm_support_pmu_v3()) {
+		vcpu_sys_reg(vcpu, PMCR_EL0) = 0;
 		return;
+	}
 
 	pmcr = read_sysreg(pmcr_el0);
 	/*
-- 
2.30.2

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Re: [stable:PATCH] KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU
  2022-03-08 16:29 ` James Morse
@ 2022-03-12 11:09   ` Greg KH
  -1 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2022-03-12 11:09 UTC (permalink / raw)
  To: James Morse; +Cc: stable, kvmarm, Marc Zyngier, Alexandru Elisei

On Tue, Mar 08, 2022 at 04:29:39PM +0000, James Morse wrote:
> The logic in commit 2a5f1b67ec57 "KVM: arm64: Don't access PMCR_EL0 when no
> PMU is available" relies on an empty reset handler being benign.  This was
> not the case in earlier kernel versions, so the stable backport of this
> patch is causing problems.
> 
> KVMs behaviour in this area changed over time. In particular, prior to commit
> 03fdfb269009 ("KVM: arm64: Don't write junk to sysregs on reset"), an empty
> reset handler will trigger a warning, as the guest registers have been
> poisoned.
> Prior to commit 20589c8cc47d ("arm/arm64: KVM: Don't panic on failure to
> properly reset system registers"), this warning was a panic().
> 
> Instead of reverting the backport, make it write 0 to the sys_reg[] array.
> This keeps the reset logic happy, and the dodgy value can't be seen by
> the guest as it can't request the emulation.
> 
> The original bug was accessing the PMCR_EL0 register on CPUs that don't
> implement that feature. There is no known silicon that does this, but
> v4.9's ACPI support is unable to find the PMU, so triggers this code:
> 
> | Kernel panic - not syncing: Didn't reset vcpu_sys_reg(24)
> | CPU: 1 PID: 3055 Comm: lkvm Not tainted 4.9.302-00032-g64e078a56789 #13476
> | Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Jul 30 2018
> | Call trace:
> | [<ffff00000808b4b0>] dump_backtrace+0x0/0x1a0
> | [<ffff00000808b664>] show_stack+0x14/0x20
> | [<ffff0000088f0e18>] dump_stack+0x98/0xb8
> | [<ffff0000088eef08>] panic+0x118/0x274
> | [<ffff0000080b50e0>] access_actlr+0x0/0x20
> | [<ffff0000080b2620>] kvm_reset_vcpu+0x5c/0xac
> | [<ffff0000080ac688>] kvm_arch_vcpu_ioctl+0x3e4/0x490
> | [<ffff0000080a382c>] kvm_vcpu_ioctl+0x5b8/0x720
> | [<ffff000008201e44>] do_vfs_ioctl+0x2f4/0x884
> | [<ffff00000820244c>] SyS_ioctl+0x78/0x9c
> | [<ffff000008083a9c>] __sys_trace_return+0x0/0x4
> 
> Cc: <stable@vger.kernel.org> # < v5.3 with 2a5f1b67ec57 backported
> Signed-off-by: James Morse <james.morse@arm.com>
> ---
>  arch/arm64/kvm/sys_regs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Now queued up for 4.9, 4.14, and 4.19 kernels, thanks!

greg k-h

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

* Re: [stable:PATCH] KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU
@ 2022-03-12 11:09   ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2022-03-12 11:09 UTC (permalink / raw)
  To: James Morse; +Cc: Marc Zyngier, kvmarm, stable

On Tue, Mar 08, 2022 at 04:29:39PM +0000, James Morse wrote:
> The logic in commit 2a5f1b67ec57 "KVM: arm64: Don't access PMCR_EL0 when no
> PMU is available" relies on an empty reset handler being benign.  This was
> not the case in earlier kernel versions, so the stable backport of this
> patch is causing problems.
> 
> KVMs behaviour in this area changed over time. In particular, prior to commit
> 03fdfb269009 ("KVM: arm64: Don't write junk to sysregs on reset"), an empty
> reset handler will trigger a warning, as the guest registers have been
> poisoned.
> Prior to commit 20589c8cc47d ("arm/arm64: KVM: Don't panic on failure to
> properly reset system registers"), this warning was a panic().
> 
> Instead of reverting the backport, make it write 0 to the sys_reg[] array.
> This keeps the reset logic happy, and the dodgy value can't be seen by
> the guest as it can't request the emulation.
> 
> The original bug was accessing the PMCR_EL0 register on CPUs that don't
> implement that feature. There is no known silicon that does this, but
> v4.9's ACPI support is unable to find the PMU, so triggers this code:
> 
> | Kernel panic - not syncing: Didn't reset vcpu_sys_reg(24)
> | CPU: 1 PID: 3055 Comm: lkvm Not tainted 4.9.302-00032-g64e078a56789 #13476
> | Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Jul 30 2018
> | Call trace:
> | [<ffff00000808b4b0>] dump_backtrace+0x0/0x1a0
> | [<ffff00000808b664>] show_stack+0x14/0x20
> | [<ffff0000088f0e18>] dump_stack+0x98/0xb8
> | [<ffff0000088eef08>] panic+0x118/0x274
> | [<ffff0000080b50e0>] access_actlr+0x0/0x20
> | [<ffff0000080b2620>] kvm_reset_vcpu+0x5c/0xac
> | [<ffff0000080ac688>] kvm_arch_vcpu_ioctl+0x3e4/0x490
> | [<ffff0000080a382c>] kvm_vcpu_ioctl+0x5b8/0x720
> | [<ffff000008201e44>] do_vfs_ioctl+0x2f4/0x884
> | [<ffff00000820244c>] SyS_ioctl+0x78/0x9c
> | [<ffff000008083a9c>] __sys_trace_return+0x0/0x4
> 
> Cc: <stable@vger.kernel.org> # < v5.3 with 2a5f1b67ec57 backported
> Signed-off-by: James Morse <james.morse@arm.com>
> ---
>  arch/arm64/kvm/sys_regs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Now queued up for 4.9, 4.14, and 4.19 kernels, thanks!

greg k-h
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Patch "KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU" has been added to the 4.9-stable tree
  2022-03-08 16:29 ` James Morse
  (?)
  (?)
@ 2022-03-12 11:16 ` gregkh
  -1 siblings, 0 replies; 7+ messages in thread
From: gregkh @ 2022-03-12 11:16 UTC (permalink / raw)
  To: alexandru.elisei, gregkh, james.morse, kvmarm, maz; +Cc: stable-commits


This is a note to let you know that I've just added the patch titled

    KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU

to the 4.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-arm64-reset-pmc_el0-to-avoid-a-panic-on-systems-with-no-pmu.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


From james.morse@arm.com  Sat Mar 12 12:08:36 2022
From: James Morse <james.morse@arm.com>
Date: Tue,  8 Mar 2022 16:29:39 +0000
Subject: KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU
To: stable@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: Marc Zyngier <maz@kernel.org>, Alexandru Elisei <alexandru.elisei@arm.com>, james.morse@arm.com
Message-ID: <20220308162939.603335-1-james.morse@arm.com>

From: James Morse <james.morse@arm.com>

The logic in commit 2a5f1b67ec57 "KVM: arm64: Don't access PMCR_EL0 when no
PMU is available" relies on an empty reset handler being benign.  This was
not the case in earlier kernel versions, so the stable backport of this
patch is causing problems.

KVMs behaviour in this area changed over time. In particular, prior to commit
03fdfb269009 ("KVM: arm64: Don't write junk to sysregs on reset"), an empty
reset handler will trigger a warning, as the guest registers have been
poisoned.
Prior to commit 20589c8cc47d ("arm/arm64: KVM: Don't panic on failure to
properly reset system registers"), this warning was a panic().

Instead of reverting the backport, make it write 0 to the sys_reg[] array.
This keeps the reset logic happy, and the dodgy value can't be seen by
the guest as it can't request the emulation.

The original bug was accessing the PMCR_EL0 register on CPUs that don't
implement that feature. There is no known silicon that does this, but
v4.9's ACPI support is unable to find the PMU, so triggers this code:

| Kernel panic - not syncing: Didn't reset vcpu_sys_reg(24)
| CPU: 1 PID: 3055 Comm: lkvm Not tainted 4.9.302-00032-g64e078a56789 #13476
| Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Jul 30 2018
| Call trace:
| [<ffff00000808b4b0>] dump_backtrace+0x0/0x1a0
| [<ffff00000808b664>] show_stack+0x14/0x20
| [<ffff0000088f0e18>] dump_stack+0x98/0xb8
| [<ffff0000088eef08>] panic+0x118/0x274
| [<ffff0000080b50e0>] access_actlr+0x0/0x20
| [<ffff0000080b2620>] kvm_reset_vcpu+0x5c/0xac
| [<ffff0000080ac688>] kvm_arch_vcpu_ioctl+0x3e4/0x490
| [<ffff0000080a382c>] kvm_vcpu_ioctl+0x5b8/0x720
| [<ffff000008201e44>] do_vfs_ioctl+0x2f4/0x884
| [<ffff00000820244c>] SyS_ioctl+0x78/0x9c
| [<ffff000008083a9c>] __sys_trace_return+0x0/0x4

Cc: <stable@vger.kernel.org> # < v5.3 with 2a5f1b67ec57 backported
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arm64/kvm/sys_regs.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -451,8 +451,10 @@ static void reset_pmcr(struct kvm_vcpu *
 	u64 pmcr, val;
 
 	/* No PMU available, PMCR_EL0 may UNDEF... */
-	if (!kvm_arm_support_pmu_v3())
+	if (!kvm_arm_support_pmu_v3()) {
+		vcpu_sys_reg(vcpu, PMCR_EL0) = 0;
 		return;
+	}
 
 	pmcr = read_sysreg(pmcr_el0);
 	/*


Patches currently in stable-queue which might be from james.morse@arm.com are

queue-4.9/kvm-arm64-reset-pmc_el0-to-avoid-a-panic-on-systems-with-no-pmu.patch
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Patch "KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU" has been added to the 4.14-stable tree
  2022-03-08 16:29 ` James Morse
                   ` (2 preceding siblings ...)
  (?)
@ 2022-03-12 11:16 ` gregkh
  -1 siblings, 0 replies; 7+ messages in thread
From: gregkh @ 2022-03-12 11:16 UTC (permalink / raw)
  To: alexandru.elisei, gregkh, james.morse, kvmarm, maz; +Cc: stable-commits


This is a note to let you know that I've just added the patch titled

    KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-arm64-reset-pmc_el0-to-avoid-a-panic-on-systems-with-no-pmu.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


From james.morse@arm.com  Sat Mar 12 12:08:36 2022
From: James Morse <james.morse@arm.com>
Date: Tue,  8 Mar 2022 16:29:39 +0000
Subject: KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU
To: stable@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: Marc Zyngier <maz@kernel.org>, Alexandru Elisei <alexandru.elisei@arm.com>, james.morse@arm.com
Message-ID: <20220308162939.603335-1-james.morse@arm.com>

From: James Morse <james.morse@arm.com>

The logic in commit 2a5f1b67ec57 "KVM: arm64: Don't access PMCR_EL0 when no
PMU is available" relies on an empty reset handler being benign.  This was
not the case in earlier kernel versions, so the stable backport of this
patch is causing problems.

KVMs behaviour in this area changed over time. In particular, prior to commit
03fdfb269009 ("KVM: arm64: Don't write junk to sysregs on reset"), an empty
reset handler will trigger a warning, as the guest registers have been
poisoned.
Prior to commit 20589c8cc47d ("arm/arm64: KVM: Don't panic on failure to
properly reset system registers"), this warning was a panic().

Instead of reverting the backport, make it write 0 to the sys_reg[] array.
This keeps the reset logic happy, and the dodgy value can't be seen by
the guest as it can't request the emulation.

The original bug was accessing the PMCR_EL0 register on CPUs that don't
implement that feature. There is no known silicon that does this, but
v4.9's ACPI support is unable to find the PMU, so triggers this code:

| Kernel panic - not syncing: Didn't reset vcpu_sys_reg(24)
| CPU: 1 PID: 3055 Comm: lkvm Not tainted 4.9.302-00032-g64e078a56789 #13476
| Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Jul 30 2018
| Call trace:
| [<ffff00000808b4b0>] dump_backtrace+0x0/0x1a0
| [<ffff00000808b664>] show_stack+0x14/0x20
| [<ffff0000088f0e18>] dump_stack+0x98/0xb8
| [<ffff0000088eef08>] panic+0x118/0x274
| [<ffff0000080b50e0>] access_actlr+0x0/0x20
| [<ffff0000080b2620>] kvm_reset_vcpu+0x5c/0xac
| [<ffff0000080ac688>] kvm_arch_vcpu_ioctl+0x3e4/0x490
| [<ffff0000080a382c>] kvm_vcpu_ioctl+0x5b8/0x720
| [<ffff000008201e44>] do_vfs_ioctl+0x2f4/0x884
| [<ffff00000820244c>] SyS_ioctl+0x78/0x9c
| [<ffff000008083a9c>] __sys_trace_return+0x0/0x4

Cc: <stable@vger.kernel.org> # < v5.3 with 2a5f1b67ec57 backported
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arm64/kvm/sys_regs.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -471,8 +471,10 @@ static void reset_pmcr(struct kvm_vcpu *
 	u64 pmcr, val;
 
 	/* No PMU available, PMCR_EL0 may UNDEF... */
-	if (!kvm_arm_support_pmu_v3())
+	if (!kvm_arm_support_pmu_v3()) {
+		vcpu_sys_reg(vcpu, PMCR_EL0) = 0;
 		return;
+	}
 
 	pmcr = read_sysreg(pmcr_el0);
 	/*


Patches currently in stable-queue which might be from james.morse@arm.com are

queue-4.14/kvm-arm64-reset-pmc_el0-to-avoid-a-panic-on-systems-with-no-pmu.patch
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Patch "KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU" has been added to the 4.19-stable tree
  2022-03-08 16:29 ` James Morse
                   ` (3 preceding siblings ...)
  (?)
@ 2022-03-12 11:16 ` gregkh
  -1 siblings, 0 replies; 7+ messages in thread
From: gregkh @ 2022-03-12 11:16 UTC (permalink / raw)
  To: alexandru.elisei, gregkh, james.morse, kvmarm, maz; +Cc: stable-commits


This is a note to let you know that I've just added the patch titled

    KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-arm64-reset-pmc_el0-to-avoid-a-panic-on-systems-with-no-pmu.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


From james.morse@arm.com  Sat Mar 12 12:08:36 2022
From: James Morse <james.morse@arm.com>
Date: Tue,  8 Mar 2022 16:29:39 +0000
Subject: KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU
To: stable@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: Marc Zyngier <maz@kernel.org>, Alexandru Elisei <alexandru.elisei@arm.com>, james.morse@arm.com
Message-ID: <20220308162939.603335-1-james.morse@arm.com>

From: James Morse <james.morse@arm.com>

The logic in commit 2a5f1b67ec57 "KVM: arm64: Don't access PMCR_EL0 when no
PMU is available" relies on an empty reset handler being benign.  This was
not the case in earlier kernel versions, so the stable backport of this
patch is causing problems.

KVMs behaviour in this area changed over time. In particular, prior to commit
03fdfb269009 ("KVM: arm64: Don't write junk to sysregs on reset"), an empty
reset handler will trigger a warning, as the guest registers have been
poisoned.
Prior to commit 20589c8cc47d ("arm/arm64: KVM: Don't panic on failure to
properly reset system registers"), this warning was a panic().

Instead of reverting the backport, make it write 0 to the sys_reg[] array.
This keeps the reset logic happy, and the dodgy value can't be seen by
the guest as it can't request the emulation.

The original bug was accessing the PMCR_EL0 register on CPUs that don't
implement that feature. There is no known silicon that does this, but
v4.9's ACPI support is unable to find the PMU, so triggers this code:

| Kernel panic - not syncing: Didn't reset vcpu_sys_reg(24)
| CPU: 1 PID: 3055 Comm: lkvm Not tainted 4.9.302-00032-g64e078a56789 #13476
| Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Jul 30 2018
| Call trace:
| [<ffff00000808b4b0>] dump_backtrace+0x0/0x1a0
| [<ffff00000808b664>] show_stack+0x14/0x20
| [<ffff0000088f0e18>] dump_stack+0x98/0xb8
| [<ffff0000088eef08>] panic+0x118/0x274
| [<ffff0000080b50e0>] access_actlr+0x0/0x20
| [<ffff0000080b2620>] kvm_reset_vcpu+0x5c/0xac
| [<ffff0000080ac688>] kvm_arch_vcpu_ioctl+0x3e4/0x490
| [<ffff0000080a382c>] kvm_vcpu_ioctl+0x5b8/0x720
| [<ffff000008201e44>] do_vfs_ioctl+0x2f4/0x884
| [<ffff00000820244c>] SyS_ioctl+0x78/0x9c
| [<ffff000008083a9c>] __sys_trace_return+0x0/0x4

Cc: <stable@vger.kernel.org> # < v5.3 with 2a5f1b67ec57 backported
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arm64/kvm/sys_regs.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -620,8 +620,10 @@ static void reset_pmcr(struct kvm_vcpu *
 	u64 pmcr, val;
 
 	/* No PMU available, PMCR_EL0 may UNDEF... */
-	if (!kvm_arm_support_pmu_v3())
+	if (!kvm_arm_support_pmu_v3()) {
+		vcpu_sys_reg(vcpu, PMCR_EL0) = 0;
 		return;
+	}
 
 	pmcr = read_sysreg(pmcr_el0);
 	/*


Patches currently in stable-queue which might be from james.morse@arm.com are

queue-4.19/kvm-arm64-reset-pmc_el0-to-avoid-a-panic-on-systems-with-no-pmu.patch
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

end of thread, other threads:[~2022-03-12 11:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 16:29 [stable:PATCH] KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU James Morse
2022-03-08 16:29 ` James Morse
2022-03-12 11:09 ` Greg KH
2022-03-12 11:09   ` Greg KH
2022-03-12 11:16 ` Patch "KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU" has been added to the 4.9-stable tree gregkh
2022-03-12 11:16 ` Patch "KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU" has been added to the 4.14-stable tree gregkh
2022-03-12 11:16 ` Patch "KVM: arm64: Reset PMC_EL0 to avoid a panic() on systems with no PMU" has been added to the 4.19-stable tree gregkh

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.