summaryrefslogtreecommitdiff
path: root/drivers/hv
diff options
context:
space:
mode:
authorNuno Das Neves <nunodasneves@linux.microsoft.com>2025-02-07 11:03:21 -0800
committerWei Liu <wei.liu@kernel.org>2025-02-13 23:38:47 +0000
commite96204e5e96ea3cacb5686e06ed29977c023254f (patch)
treed55e3a3c6fd43e119cc33bb76302219bf61d2212 /drivers/hv
parenta64dcfb451e254085a7daee5fe51bf22959d52d3 (diff)
downloadlinux-next-e96204e5e96ea3cacb5686e06ed29977c023254f.tar.gz
linux-next-e96204e5e96ea3cacb5686e06ed29977c023254f.zip
hyperv: Move hv_current_partition_id to arch-generic code
Move hv_current_partition_id and hv_get_partition_id() to hv_common.c, and call hv_get_partition_id() on arm64 in hyperv_init(). These aren't specific to x86_64 and will be needed by common code. Set hv_current_partition_id to HV_PARTITION_ID_SELF by default. Rename struct hv_get_partition_id to hv_output_get_partition_id, to make it distinct from the function hv_get_partition_id(), and match the original Hyper-V struct name. Remove the BUG()s. Failing to get the id need not crash the machine. Signed-off-by: Nuno Das Neves <nunodasneves@linux.microsoft.com> Reviewed-by: Michael Kelley <mhklinux@outlook.com> Link: https://lore.kernel.org/r/1738955002-20821-2-git-send-email-nunodasneves@linux.microsoft.com Signed-off-by: Wei Liu <wei.liu@kernel.org> Message-ID: <1738955002-20821-2-git-send-email-nunodasneves@linux.microsoft.com>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/hv_common.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
index f2e6f55d6ca6..ee3083937b4f 100644
--- a/drivers/hv/hv_common.c
+++ b/drivers/hv/hv_common.c
@@ -31,6 +31,9 @@
#include <hyperv/hvhdk.h>
#include <asm/mshyperv.h>
+u64 hv_current_partition_id = HV_PARTITION_ID_SELF;
+EXPORT_SYMBOL_GPL(hv_current_partition_id);
+
/*
* hv_root_partition, ms_hyperv and hv_nested are defined here with other
* Hyper-V specific globals so they are shared across all architectures and are
@@ -283,6 +286,25 @@ 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;
+ unsigned long flags;
+ u64 status, pt_id;
+
+ local_irq_save(flags);
+ output = *this_cpu_ptr(hyperv_pcpu_input_arg);
+ status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, &output);
+ pt_id = output->partition_id;
+ local_irq_restore(flags);
+
+ if (hv_result_success(status))
+ hv_current_partition_id = pt_id;
+ else
+ pr_err("Hyper-V: failed to get partition ID: %#x\n",
+ hv_result(status));
+}
+
int __init hv_common_init(void)
{
int i;