]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
arm64/hyperv: Add some missing functions to arm64
authorNuno Das Neves <nunodasneves@linux.microsoft.com>
Fri, 14 Mar 2025 19:28:49 +0000 (12:28 -0700)
committerWei Liu <wei.liu@kernel.org>
Thu, 20 Mar 2025 21:23:03 +0000 (21:23 +0000)
These non-nested msr and fast hypercall functions are present in x86,
but they must be available in both architectures for the root partition
driver code.

While at it, remove the redundant 'extern' keywords from the
hv_do_hypercall() variants in asm-generic/mshyperv.h.

Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Reviewed-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Reviewed-by: Roman Kisel <romank@linux.microsoft.com>
Link: https://lore.kernel.org/r/1741980536-3865-4-git-send-email-nunodasneves@linux.microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <1741980536-3865-4-git-send-email-nunodasneves@linux.microsoft.com>

arch/arm64/hyperv/hv_core.c
arch/arm64/include/asm/mshyperv.h
include/asm-generic/mshyperv.h

index 69004f619c579fea5a3ae4acf58e35f2f47990ca..e33a9e3c366a1dd368225e27e425de17198fe27f 100644 (file)
@@ -53,6 +53,23 @@ u64 hv_do_fast_hypercall8(u16 code, u64 input)
 }
 EXPORT_SYMBOL_GPL(hv_do_fast_hypercall8);
 
+/*
+ * hv_do_fast_hypercall16 -- Invoke the specified hypercall
+ * with arguments in registers instead of physical memory.
+ * Avoids the overhead of virt_to_phys for simple hypercalls.
+ */
+u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2)
+{
+       struct arm_smccc_res    res;
+       u64                     control;
+
+       control = (u64)code | HV_HYPERCALL_FAST_BIT;
+
+       arm_smccc_1_1_hvc(HV_FUNC_ID, control, input1, input2, &res);
+       return res.a0;
+}
+EXPORT_SYMBOL_GPL(hv_do_fast_hypercall16);
+
 /*
  * Set a single VP register to a 64-bit value.
  */
index 2e2f83bafcfbbbf7b586e2d7ca0c2833babd2851..b721d3134ab66616bbff4008592711d6be2ce083 100644 (file)
@@ -40,6 +40,19 @@ static inline u64 hv_get_msr(unsigned int reg)
        return hv_get_vpreg(reg);
 }
 
+/*
+ * Nested is not supported on arm64
+ */
+static inline void hv_set_non_nested_msr(unsigned int reg, u64 value)
+{
+       hv_set_msr(reg, value);
+}
+
+static inline u64 hv_get_non_nested_msr(unsigned int reg)
+{
+       return hv_get_msr(reg);
+}
+
 /* SMCCC hypercall parameters */
 #define HV_SMCCC_FUNC_NUMBER   1
 #define HV_FUNC_ID     ARM_SMCCC_CALL_VAL(                     \
index c8043efabf5ab3c6332dbaef1a2405b8d995c1c5..c3697bc0598dcad7cbea60b0f25bbb6038dd20b8 100644 (file)
@@ -70,8 +70,10 @@ extern enum hv_partition_type hv_curr_partition_type;
 extern void * __percpu *hyperv_pcpu_input_arg;
 extern void * __percpu *hyperv_pcpu_output_arg;
 
-extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
-extern u64 hv_do_fast_hypercall8(u16 control, u64 input8);
+u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
+u64 hv_do_fast_hypercall8(u16 control, u64 input8);
+u64 hv_do_fast_hypercall16(u16 control, u64 input1, u64 input2);
+
 bool hv_isolation_type_snp(void);
 bool hv_isolation_type_tdx(void);