mbox series

[v2,0/3] KVM: arm64: Fixes for SMC64 SYSTEM_RESET2 calls

Message ID 20220322183538.2757758-1-oupton@google.com (mailing list archive)
Headers show
Series KVM: arm64: Fixes for SMC64 SYSTEM_RESET2 calls | expand

Message

Oliver Upton March 22, 2022, 6:35 p.m. UTC
This series addresses a couple of issues with how KVM exposes SMC64
calls to its guest. It is currently possible for an AArch32 guest to
discover the SMC64 SYSTEM_RESET2 function (via
PSCI_1_0_FN_PSCI_FEATURES) and even make a call to it. SMCCC does not
allow for 64 bit calls to be made from a 32 bit state.

Patch 1 cleans up the way we filter SMC64 calls in PSCI. Using a switch
with case statements for each possibly-filtered function is asking for
trouble. Instead, pivot off of the bit that indicates the desired
calling convention. This plugs the PSCI_FEATURES hole for SYSTEM_RESET2.

Patch 2 adds a check to the PSCI v1.x call handler in KVM, bailing out
early if the guest is not allowed to use a particular function. This
closes the door on calls to 64-bit SYSTEM_RESET2 from AArch32.

Lastly, patch 3 is a nit to remove a superfluous check in the hopes of
avoiding trouble the next time we raise KVM's PSCI version.

Applies on top of kvmarm/next at commit:

  21ea45784275 ("KVM: arm64: fix typos in comments")

v1: http://lore.kernel.org/r/20220318193831.482349-1-oupton@google.com

v1 -> v2:
 - Collect Acks and Reviews (Reiji, Will)
 - Hoist SMC64 filtering all the way up to kvm_psci_call() (Reiji)

Oliver Upton (3):
  KVM: arm64: Generally disallow SMC64 for AArch32 guests
  KVM: arm64: Actually prevent SMC64 SYSTEM_RESET2 from AArch32
  KVM: arm64: Drop unneeded minor version check from PSCI v1.x handler

 arch/arm64/kvm/psci.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

Comments

Marc Zyngier March 23, 2022, 9:26 a.m. UTC | #1
On Tue, 22 Mar 2022 18:35:35 +0000, Oliver Upton wrote:
> This series addresses a couple of issues with how KVM exposes SMC64
> calls to its guest. It is currently possible for an AArch32 guest to
> discover the SMC64 SYSTEM_RESET2 function (via
> PSCI_1_0_FN_PSCI_FEATURES) and even make a call to it. SMCCC does not
> allow for 64 bit calls to be made from a 32 bit state.
> 
> Patch 1 cleans up the way we filter SMC64 calls in PSCI. Using a switch
> with case statements for each possibly-filtered function is asking for
> trouble. Instead, pivot off of the bit that indicates the desired
> calling convention. This plugs the PSCI_FEATURES hole for SYSTEM_RESET2.
> 
> [...]

Applied to fixes, thanks!

[1/3] KVM: arm64: Generally disallow SMC64 for AArch32 guests
      commit: 905ec3226f8150f73838a36cb79ba79e1d789e8e
[2/3] KVM: arm64: Actually prevent SMC64 SYSTEM_RESET2 from AArch32
      commit: 3e1b3dbad320e1532fdf09e5b80e35d62a0fd82b
[3/3] KVM: arm64: Drop unneeded minor version check from PSCI v1.x handler
      commit: 8872d9b3e35a0ecb80d6413bba403d4aaf49af63

Cheers,

	M.