@@ -482,16 +482,16 @@ void __init hyperv_init(void)
* A TDX VM with no paravisor only uses TDX GHCI rather than hv_hypercall_pg:
* when the hypercall input is a page, such a VM must pass a decrypted
* page to Hyper-V, e.g. hv_post_message() uses the per-CPU page
- * hyperv_pcpu_input_arg, which is decrypted if no paravisor is present.
+ * hyperv_pcpu_arg, which is decrypted if no paravisor is present.
*
* A TDX VM with the paravisor uses hv_hypercall_pg for most hypercalls,
* which are handled by the paravisor and the VM must use an encrypted
- * input page: in such a VM, the hyperv_pcpu_input_arg is encrypted and
+ * input page: in such a VM, the hyperv_pcpu_arg is encrypted and
* used in the hypercalls, e.g. see hv_mark_gpa_visibility() and
* hv_arch_irq_unmask(). Such a VM uses TDX GHCI for two hypercalls:
* 1. HVCALL_SIGNAL_EVENT: see vmbus_set_event() and _hv_do_fast_hypercall8().
* 2. HVCALL_POST_MESSAGE: the input page must be a decrypted page, i.e.
- * hv_post_message() in such a VM can't use the encrypted hyperv_pcpu_input_arg;
+ * hv_post_message() in such a VM can't use the encrypted hyperv_pcpu_arg;
* instead, hv_post_message() uses the post_msg_page, which is decrypted
* in such a VM and is only used in such a VM.
*/
@@ -60,7 +60,7 @@ int hv_post_message(union hv_connection_id connection_id,
/*
* A TDX VM with the paravisor must use the decrypted post_msg_page: see
* the comment in struct hv_per_cpu_context. A SNP VM with the paravisor
- * can use the encrypted hyperv_pcpu_input_arg because it copies the
+ * can use the encrypted hyperv_pcpu_arg because it copies the
* input into the GHCB page, which has been decrypted by the paravisor.
*/
if (hv_isolation_type_tdx() && ms_hyperv.paravisor_present)
@@ -58,11 +58,8 @@ EXPORT_SYMBOL_GPL(hv_vp_index);
u32 hv_max_vp_index;
EXPORT_SYMBOL_GPL(hv_max_vp_index);
-void * __percpu *hyperv_pcpu_input_arg;
-EXPORT_SYMBOL_GPL(hyperv_pcpu_input_arg);
-
-void * __percpu *hyperv_pcpu_output_arg;
-EXPORT_SYMBOL_GPL(hyperv_pcpu_output_arg);
+void * __percpu *hyperv_pcpu_arg;
+EXPORT_SYMBOL_GPL(hyperv_pcpu_arg);
static void hv_kmsg_dump_unregister(void);
@@ -85,11 +82,8 @@ void __init hv_common_free(void)
kfree(hv_vp_index);
hv_vp_index = NULL;
- free_percpu(hyperv_pcpu_output_arg);
- hyperv_pcpu_output_arg = NULL;
-
- free_percpu(hyperv_pcpu_input_arg);
- hyperv_pcpu_input_arg = NULL;
+ free_percpu(hyperv_pcpu_arg);
+ hyperv_pcpu_arg = NULL;
}
/*
@@ -281,11 +275,6 @@ static void hv_kmsg_dump_register(void)
}
}
-static inline bool hv_output_page_exists(void)
-{
- return hv_root_partition() || IS_ENABLED(CONFIG_HYPERV_VTL_MODE);
-}
-
void __init hv_get_partition_id(void)
{
struct hv_output_get_partition_id *output;
@@ -363,14 +352,8 @@ int __init hv_common_init(void)
* (per-CPU) hypercall input page and thus this failure is
* fatal on Hyper-V.
*/
- hyperv_pcpu_input_arg = alloc_percpu(void *);
- BUG_ON(!hyperv_pcpu_input_arg);
-
- /* Allocate the per-CPU state for output arg for root */
- if (hv_output_page_exists()) {
- hyperv_pcpu_output_arg = alloc_percpu(void *);
- BUG_ON(!hyperv_pcpu_output_arg);
- }
+ hyperv_pcpu_arg = alloc_percpu(void *);
+ BUG_ON(!hyperv_pcpu_arg);
hv_vp_index = kmalloc_array(nr_cpu_ids, sizeof(*hv_vp_index),
GFP_KERNEL);
@@ -459,32 +442,27 @@ void __init ms_hyperv_late_init(void)
int hv_common_cpu_init(unsigned int cpu)
{
- void **inputarg, **outputarg;
+ void **inputarg;
u64 msr_vp_index;
gfp_t flags;
- const int pgcount = hv_output_page_exists() ? 2 : 1;
+ const int pgcount = HV_HVCALL_ARG_PAGES;
void *mem;
int ret;
/* hv_cpu_init() can be called with IRQs disabled from hv_resume() */
flags = irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL;
- inputarg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg);
+ inputarg = (void **)this_cpu_ptr(hyperv_pcpu_arg);
/*
- * hyperv_pcpu_input_arg and hyperv_pcpu_output_arg memory is already
- * allocated if this CPU was previously online and then taken offline
+ * hyperv_pcpu_arg memory is already allocated if this CPU was
+ * previously online and then taken offline
*/
if (!*inputarg) {
mem = kmalloc(pgcount * HV_HYP_PAGE_SIZE, flags);
if (!mem)
return -ENOMEM;
- if (hv_output_page_exists()) {
- outputarg = (void **)this_cpu_ptr(hyperv_pcpu_output_arg);
- *outputarg = (char *)mem + HV_HYP_PAGE_SIZE;
- }
-
if (!ms_hyperv.paravisor_present &&
(hv_isolation_type_snp() || hv_isolation_type_tdx())) {
ret = set_memory_decrypted((unsigned long)mem, pgcount);
@@ -498,13 +476,13 @@ int hv_common_cpu_init(unsigned int cpu)
/*
* In a fully enlightened TDX/SNP VM with more than 64 VPs, if
- * hyperv_pcpu_input_arg is not NULL, set_memory_decrypted() ->
+ * hyperv_pcpu_arg is not NULL, set_memory_decrypted() ->
* ... -> cpa_flush()-> ... -> __send_ipi_mask_ex() tries to
- * use hyperv_pcpu_input_arg as the hypercall input page, which
+ * use hyperv_pcpu_arg as the hypercall input page, which
* must be a decrypted page in such a VM, but the page is still
* encrypted before set_memory_decrypted() returns. Fix this by
* setting *inputarg after the above set_memory_decrypted(): if
- * hyperv_pcpu_input_arg is NULL, __send_ipi_mask_ex() returns
+ * hyperv_pcpu_arg is NULL, __send_ipi_mask_ex() returns
* HV_STATUS_INVALID_PARAMETER immediately, and the function
* hv_send_ipi_mask() falls back to orig_apic.send_IPI_mask(),
* which may be slightly slower than the hypercall, but still
@@ -526,9 +504,8 @@ int hv_common_cpu_init(unsigned int cpu)
int hv_common_cpu_die(unsigned int cpu)
{
/*
- * The hyperv_pcpu_input_arg and hyperv_pcpu_output_arg memory
- * is not freed when the CPU goes offline as the hyperv_pcpu_input_arg
- * may be used by the Hyper-V vPCI driver in reassigning interrupts
+ * The hyperv_pcpu_arg memory is not freed when the CPU goes offline as
+ * it may be used by the Hyper-V vPCI driver in reassigning interrupts
* as part of the offlining process. The interrupt reassignment
* happens *after* the CPUHP_AP_HYPERV_ONLINE state has run and
* called this function.
@@ -66,8 +66,7 @@ extern bool hv_nested;
extern u64 hv_current_partition_id;
extern enum hv_partition_type hv_curr_partition_type;
-extern void * __percpu *hyperv_pcpu_input_arg;
-extern void * __percpu *hyperv_pcpu_output_arg;
+extern void * __percpu *hyperv_pcpu_arg;
extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
extern u64 hv_do_fast_hypercall8(u16 control, u64 input8);
@@ -139,9 +138,6 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size,
* Hypercall input and output argument setup
*/
-/* Temporary mapping to be removed at the end of the patch series */
-#define hyperv_pcpu_arg hyperv_pcpu_input_arg
-
/*
* Allocate one page that is shared between input and output args, which is
* sufficient for all current hypercalls. If a future hypercall requires