@@ -76,6 +76,7 @@ static inline void hv_set_hypercall_pg(void *ptr)
7676EXPORT_SYMBOL_GPL (hv_hypercall_pg );
7777#endif
7878
79+ void * hv_vp_early_input_arg ;
7980union hv_ghcb * __percpu * hv_ghcb_pg ;
8081
8182/* Storage to save the hypercall page temporarily for hibernation */
@@ -120,6 +121,10 @@ static int hv_cpu_init(unsigned int cpu)
120121 if (ret )
121122 return ret ;
122123
124+ /* Allow Hyper-V stimer vector to be injected from Hypervisor. */
125+ if (ms_hyperv .misc_features & HV_STIMER_DIRECT_MODE_AVAILABLE )
126+ apic_update_vector (cpu , HYPERV_STIMER0_VECTOR , true);
127+
123128 return hyperv_init_ghcb ();
124129}
125130
@@ -227,6 +232,9 @@ static int hv_cpu_die(unsigned int cpu)
227232 * ghcb_va = NULL ;
228233 }
229234
235+ if (ms_hyperv .misc_features & HV_STIMER_DIRECT_MODE_AVAILABLE )
236+ apic_update_vector (cpu , HYPERV_STIMER0_VECTOR , false);
237+
230238 hv_common_cpu_die (cpu );
231239
232240 if (hv_reenlightenment_cb == NULL )
@@ -375,13 +383,32 @@ void __init hyperv_init(void)
375383 u64 guest_id ;
376384 union hv_x64_msr_hypercall_contents hypercall_msr ;
377385 int cpuhp ;
386+ int ret ;
378387
379388 if (x86_hyper_type != X86_HYPER_MS_HYPERV )
380389 return ;
381390
382391 if (hv_common_init ())
383392 return ;
384393
394+ if (cc_platform_has (CC_ATTR_SNP_SECURE_AVIC )) {
395+ hv_vp_early_input_arg = (void * )__get_free_pages (
396+ GFP_KERNEL | __GFP_ZERO ,
397+ get_order (num_possible_cpus () * PAGE_SIZE ));
398+ if (hv_vp_early_input_arg ) {
399+ ret = set_memory_decrypted ((u64 )hv_vp_early_input_arg ,
400+ num_possible_cpus ());
401+ if (ret ) {
402+ free_pages ((unsigned long )hv_vp_early_input_arg ,
403+ get_order (num_possible_cpus () * PAGE_SIZE ));
404+ hv_vp_early_input_arg = NULL ;
405+ goto common_free ;
406+ }
407+ } else {
408+ goto common_free ;
409+ }
410+ }
411+
385412 if (ms_hyperv .paravisor_present && hv_isolation_type_snp ()) {
386413 /* Negotiate GHCB Version. */
387414 if (!hv_ghcb_negotiate_protocol ())
@@ -519,6 +546,16 @@ void __init hyperv_init(void)
519546free_vp_assist_page :
520547 kfree (hv_vp_assist_page );
521548 hv_vp_assist_page = NULL ;
549+ free_vp_early_input_arg :
550+ if (hv_vp_early_input_arg ) {
551+ set_memory_encrypted ((u64 )hv_vp_early_input_arg ,
552+ num_possible_cpus ());
553+ free_pages ((unsigned long )hv_vp_early_input_arg ,
554+ get_order (num_possible_cpus () * PAGE_SIZE ));
555+ hv_vp_early_input_arg = NULL ;
556+ }
557+ common_free :
558+ hv_common_free ();
522559}
523560
524561/*
0 commit comments