Skip to content

Commit feba84c

Browse files
NunoDasNevesliuw
authored andcommitted
arm64/hyperv: Add some missing functions to arm64
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>
1 parent 8cac517 commit feba84c

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

arch/arm64/hyperv/hv_core.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ u64 hv_do_fast_hypercall8(u16 code, u64 input)
5353
}
5454
EXPORT_SYMBOL_GPL(hv_do_fast_hypercall8);
5555

56+
/*
57+
* hv_do_fast_hypercall16 -- Invoke the specified hypercall
58+
* with arguments in registers instead of physical memory.
59+
* Avoids the overhead of virt_to_phys for simple hypercalls.
60+
*/
61+
u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2)
62+
{
63+
struct arm_smccc_res res;
64+
u64 control;
65+
66+
control = (u64)code | HV_HYPERCALL_FAST_BIT;
67+
68+
arm_smccc_1_1_hvc(HV_FUNC_ID, control, input1, input2, &res);
69+
return res.a0;
70+
}
71+
EXPORT_SYMBOL_GPL(hv_do_fast_hypercall16);
72+
5673
/*
5774
* Set a single VP register to a 64-bit value.
5875
*/

arch/arm64/include/asm/mshyperv.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ static inline u64 hv_get_msr(unsigned int reg)
4040
return hv_get_vpreg(reg);
4141
}
4242

43+
/*
44+
* Nested is not supported on arm64
45+
*/
46+
static inline void hv_set_non_nested_msr(unsigned int reg, u64 value)
47+
{
48+
hv_set_msr(reg, value);
49+
}
50+
51+
static inline u64 hv_get_non_nested_msr(unsigned int reg)
52+
{
53+
return hv_get_msr(reg);
54+
}
55+
4356
/* SMCCC hypercall parameters */
4457
#define HV_SMCCC_FUNC_NUMBER 1
4558
#define HV_FUNC_ID ARM_SMCCC_CALL_VAL( \

include/asm-generic/mshyperv.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ extern enum hv_partition_type hv_curr_partition_type;
7070
extern void * __percpu *hyperv_pcpu_input_arg;
7171
extern void * __percpu *hyperv_pcpu_output_arg;
7272

73-
extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
74-
extern u64 hv_do_fast_hypercall8(u16 control, u64 input8);
73+
u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
74+
u64 hv_do_fast_hypercall8(u16 control, u64 input8);
75+
u64 hv_do_fast_hypercall16(u16 control, u64 input1, u64 input2);
76+
7577
bool hv_isolation_type_snp(void);
7678
bool hv_isolation_type_tdx(void);
7779

0 commit comments

Comments
 (0)