@@ -72,10 +72,16 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
7272 return hv_status ;
7373}
7474
75+ /* Hypercall to the L0 hypervisor */
76+ static inline u64 hv_do_nested_hypercall (u64 control , void * input , void * output )
77+ {
78+ return hv_do_hypercall (control | HV_HYPERCALL_NESTED , input , output );
79+ }
80+
7581/* Fast hypercall with 8 bytes of input and no output */
76- static inline u64 hv_do_fast_hypercall8 ( u16 code , u64 input1 )
82+ static inline u64 _hv_do_fast_hypercall8 ( u64 control , u64 input1 )
7783{
78- u64 hv_status , control = ( u64 ) code | HV_HYPERCALL_FAST_BIT ;
84+ u64 hv_status ;
7985
8086#ifdef CONFIG_X86_64
8187 {
@@ -103,10 +109,24 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
103109 return hv_status ;
104110}
105111
112+ static inline u64 hv_do_fast_hypercall8 (u16 code , u64 input1 )
113+ {
114+ u64 control = (u64 )code | HV_HYPERCALL_FAST_BIT ;
115+
116+ return _hv_do_fast_hypercall8 (control , input1 );
117+ }
118+
119+ static inline u64 hv_do_fast_nested_hypercall8 (u16 code , u64 input1 )
120+ {
121+ u64 control = (u64 )code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED ;
122+
123+ return _hv_do_fast_hypercall8 (control , input1 );
124+ }
125+
106126/* Fast hypercall with 16 bytes of input */
107- static inline u64 hv_do_fast_hypercall16 ( u16 code , u64 input1 , u64 input2 )
127+ static inline u64 _hv_do_fast_hypercall16 ( u64 control , u64 input1 , u64 input2 )
108128{
109- u64 hv_status , control = ( u64 ) code | HV_HYPERCALL_FAST_BIT ;
129+ u64 hv_status ;
110130
111131#ifdef CONFIG_X86_64
112132 {
@@ -137,6 +157,20 @@ static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2)
137157 return hv_status ;
138158}
139159
160+ static inline u64 hv_do_fast_hypercall16 (u16 code , u64 input1 , u64 input2 )
161+ {
162+ u64 control = (u64 )code | HV_HYPERCALL_FAST_BIT ;
163+
164+ return _hv_do_fast_hypercall16 (control , input1 , input2 );
165+ }
166+
167+ static inline u64 hv_do_fast_nested_hypercall16 (u16 code , u64 input1 , u64 input2 )
168+ {
169+ u64 control = (u64 )code | HV_HYPERCALL_FAST_BIT | HV_HYPERCALL_NESTED ;
170+
171+ return _hv_do_fast_hypercall16 (control , input1 , input2 );
172+ }
173+
140174extern struct hv_vp_assist_page * * hv_vp_assist_page ;
141175
142176static inline struct hv_vp_assist_page * hv_get_vp_assist_page (unsigned int cpu )
@@ -190,36 +224,20 @@ extern bool hv_isolation_type_snp(void);
190224
191225static inline bool hv_is_synic_reg (unsigned int reg )
192226{
193- if ((reg >= HV_REGISTER_SCONTROL ) &&
194- (reg <= HV_REGISTER_SINT15 ))
195- return true;
196- return false;
227+ return (reg >= HV_REGISTER_SCONTROL ) &&
228+ (reg <= HV_REGISTER_SINT15 );
197229}
198230
199- static inline u64 hv_get_register (unsigned int reg )
231+ static inline bool hv_is_sint_reg (unsigned int reg )
200232{
201- u64 value ;
202-
203- if (hv_is_synic_reg (reg ) && hv_isolation_type_snp ())
204- hv_ghcb_msr_read (reg , & value );
205- else
206- rdmsrl (reg , value );
207- return value ;
233+ return (reg >= HV_REGISTER_SINT0 ) &&
234+ (reg <= HV_REGISTER_SINT15 );
208235}
209236
210- static inline void hv_set_register (unsigned int reg , u64 value )
211- {
212- if (hv_is_synic_reg (reg ) && hv_isolation_type_snp ()) {
213- hv_ghcb_msr_write (reg , value );
214-
215- /* Write proxy bit via wrmsl instruction */
216- if (reg >= HV_REGISTER_SINT0 &&
217- reg <= HV_REGISTER_SINT15 )
218- wrmsrl (reg , value | 1 << 20 );
219- } else {
220- wrmsrl (reg , value );
221- }
222- }
237+ u64 hv_get_register (unsigned int reg );
238+ void hv_set_register (unsigned int reg , u64 value );
239+ u64 hv_get_non_nested_register (unsigned int reg );
240+ void hv_set_non_nested_register (unsigned int reg , u64 value );
223241
224242#else /* CONFIG_HYPERV */
225243static inline void hyperv_init (void ) {}
@@ -239,6 +257,8 @@ static inline int hyperv_flush_guest_mapping_range(u64 as,
239257}
240258static inline void hv_set_register (unsigned int reg , u64 value ) { }
241259static inline u64 hv_get_register (unsigned int reg ) { return 0 ; }
260+ static inline void hv_set_non_nested_register (unsigned int reg , u64 value ) { }
261+ static inline u64 hv_get_non_nested_register (unsigned int reg ) { return 0 ; }
242262static inline int hv_set_mem_host_visibility (unsigned long addr , int numpages ,
243263 bool visible )
244264{
0 commit comments