summaryrefslogtreecommitdiff
path: root/arch/arm64/include
diff options
context:
space:
mode:
authorDavid Brazdil <dbrazdil@google.com>2020-12-08 17:24:47 +0300
committerMarc Zyngier <maz@kernel.org>2020-12-22 13:47:59 +0300
commitff367fe473a9857160c17827931375a899076394 (patch)
tree4281bbe4ddc2f0a4bcff4d9e7de973ce4ce56c85 /arch/arm64/include
parent2a5f1b67ec577fb1544b563086e0377f095f88e2 (diff)
downloadlinux-ff367fe473a9857160c17827931375a899076394.tar.xz
KVM: arm64: Prevent use of invalid PSCI v0.1 function IDs
PSCI driver exposes a struct containing the PSCI v0.1 function IDs configured in the DT. However, the struct does not convey the information whether these were set from DT or contain the default value zero. This could be a problem for PSCI proxy in KVM protected mode. Extend config passed to KVM with a bit mask with individual bits set depending on whether the corresponding function pointer in psci_ops is set, eg. set bit for PSCI_CPU_SUSPEND if psci_ops.cpu_suspend != NULL. Previously config was split into multiple global variables. Put everything into a single struct for convenience. Reported-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: David Brazdil <dbrazdil@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20201208142452.87237-2-dbrazdil@google.com
Diffstat (limited to 'arch/arm64/include')
-rw-r--r--arch/arm64/include/asm/kvm_host.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 11beda85ee7e..828d50d40dc2 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -17,6 +17,7 @@
#include <linux/jump_label.h>
#include <linux/kvm_types.h>
#include <linux/percpu.h>
+#include <linux/psci.h>
#include <asm/arch_gicv3.h>
#include <asm/barrier.h>
#include <asm/cpufeature.h>
@@ -240,6 +241,25 @@ struct kvm_host_data {
struct kvm_pmu_events pmu_events;
};
+#define KVM_HOST_PSCI_0_1_CPU_SUSPEND BIT(0)
+#define KVM_HOST_PSCI_0_1_CPU_ON BIT(1)
+#define KVM_HOST_PSCI_0_1_CPU_OFF BIT(2)
+#define KVM_HOST_PSCI_0_1_MIGRATE BIT(3)
+
+struct kvm_host_psci_config {
+ /* PSCI version used by host. */
+ u32 version;
+
+ /* Function IDs used by host if version is v0.1. */
+ struct psci_0_1_function_ids function_ids_0_1;
+
+ /* Bitmask of functions enabled for v0.1, bits KVM_HOST_PSCI_0_1_*. */
+ unsigned int enabled_functions_0_1;
+};
+
+extern struct kvm_host_psci_config kvm_nvhe_sym(kvm_host_psci_config);
+#define kvm_host_psci_config CHOOSE_NVHE_SYM(kvm_host_psci_config)
+
struct vcpu_reset_state {
unsigned long pc;
unsigned long r0;