[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1727985064-18362-5-git-send-email-nunodasneves@linux.microsoft.com>
Date: Thu, 3 Oct 2024 12:51:03 -0700
From: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
To: linux-hyperv@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
kvm@...r.kernel.org,
iommu@...ts.linux.dev,
netdev@...r.kernel.org,
linux-pci@...r.kernel.org,
linux-arch@...r.kernel.org,
virtualization@...ts.linux.dev
Cc: kys@...rosoft.com,
haiyangz@...rosoft.com,
wei.liu@...nel.org,
decui@...rosoft.com,
catalin.marinas@....com,
will@...nel.org,
luto@...nel.org,
tglx@...utronix.de,
mingo@...hat.com,
bp@...en8.de,
dave.hansen@...ux.intel.com,
x86@...nel.org,
hpa@...or.com,
seanjc@...gle.com,
pbonzini@...hat.com,
peterz@...radead.org,
daniel.lezcano@...aro.org,
joro@...tes.org,
robin.murphy@....com,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
lpieralisi@...nel.org,
kw@...ux.com,
robh@...nel.org,
bhelgaas@...gle.com,
arnd@...db.de,
sgarzare@...hat.com,
jinankjain@...ux.microsoft.com,
muminulrussell@...il.com,
skinsburskii@...ux.microsoft.com,
mukeshrathor@...rosoft.com
Subject: [PATCH 4/5] hyperv: Add hv_defs.h to conditionally include hyperv-tlfs.h or hvhdk.h
Include one or the other depending on whether HYPERV_NONTLFS_HEADERS is
defined.
This will allow Hyper-V code to use the new headers while other code can
continue using hyperv-tlfs.h which is only for Hyper-V guests.
Replace hyperv-tlfs.h in shared headers with hv_defs.h These headers are
shared between Hyper-V code and non-Hyper-V code (KVM for example). This
will allow switching to the new headers in Hyper-V code only.
Signed-off-by: Nuno Das Neves <nunodasneves@...ux.microsoft.com>
---
arch/arm64/include/asm/mshyperv.h | 2 +-
arch/x86/include/asm/mshyperv.h | 2 +-
arch/x86/include/asm/svm.h | 2 +-
include/asm-generic/mshyperv.h | 2 +-
include/clocksource/hyperv_timer.h | 2 +-
include/hyperv/hv_defs.h | 29 +++++++++++++++++++++++++++++
6 files changed, 34 insertions(+), 5 deletions(-)
create mode 100644 include/hyperv/hv_defs.h
diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h
index a975e1a689dd..13b2b2218d85 100644
--- a/arch/arm64/include/asm/mshyperv.h
+++ b/arch/arm64/include/asm/mshyperv.h
@@ -20,7 +20,7 @@
#include <linux/types.h>
#include <linux/arm-smccc.h>
-#include <asm/hyperv-tlfs.h>
+#include <hyperv/hv_defs.h>
/*
* Declare calls to get and set Hyper-V VP register values on ARM64, which
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 47ca48062547..dc8587f02850 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -6,9 +6,9 @@
#include <linux/nmi.h>
#include <linux/msi.h>
#include <linux/io.h>
-#include <asm/hyperv-tlfs.h>
#include <asm/nospec-branch.h>
#include <asm/paravirt.h>
+#include <hyperv/hv_defs.h>
/*
* Hyper-V always provides a single IO-APIC at this MMIO address.
diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h
index f0dea3750ca9..c682fc080310 100644
--- a/arch/x86/include/asm/svm.h
+++ b/arch/x86/include/asm/svm.h
@@ -5,7 +5,7 @@
#include <uapi/asm/svm.h>
#include <uapi/asm/kvm.h>
-#include <asm/hyperv-tlfs.h>
+#include <hyperv/hv_defs.h>
/*
* 32-bit intercept words in the VMCB Control Area, starting
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index 8fe7aaab2599..8bd308ae1056 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -25,7 +25,7 @@
#include <linux/cpumask.h>
#include <linux/nmi.h>
#include <asm/ptrace.h>
-#include <asm/hyperv-tlfs.h>
+#include <hyperv/hv_defs.h>
#define VTPM_BASE_ADDRESS 0xfed40000
diff --git a/include/clocksource/hyperv_timer.h b/include/clocksource/hyperv_timer.h
index 6cdc873ac907..068ca1934c23 100644
--- a/include/clocksource/hyperv_timer.h
+++ b/include/clocksource/hyperv_timer.h
@@ -15,7 +15,7 @@
#include <linux/clocksource.h>
#include <linux/math64.h>
-#include <asm/hyperv-tlfs.h>
+#include <hyperv/hv_defs.h>
#define HV_MAX_MAX_DELTA_TICKS 0xffffffff
#define HV_MIN_DELTA_TICKS 1
diff --git a/include/hyperv/hv_defs.h b/include/hyperv/hv_defs.h
new file mode 100644
index 000000000000..eed500288499
--- /dev/null
+++ b/include/hyperv/hv_defs.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * This file includes Microsoft Hypervisor definitions from hyperv-tlfs.h, or
+ * hvhdk.h when HYPERV_NONTLFS_HEADERS is defined.
+ */
+/*
+ * NOTE:
+ * The typical #ifdef guard to prevent redefinition errors is intentionally
+ * omitted. This makes compiler error (either via #error or redefinition) in
+ * the case where hyperv-tlfs.h is accidentally included, followed by
+ * definition of HYPERV_NON_TLFS_HEADERS and inclusion of this file.
+ * If this file could only be included once, the compiler would ignore the
+ * attempt to use HYPERV_NONTLFS_HEADERS to include hvhdk.h.
+ */
+
+#ifdef HYPERV_NONTLFS_HEADERS
+
+#ifdef HYPERV_TLFS_HEADERS_INCLUDED
+#error "hyperv-tlfs.h was already included before HYPERV_NONTLFS_HEADERS was defined"
+#else
+#include <hyperv/hvhdk.h>
+#endif
+
+#else /* HYPERV_NONTLFS_HEADERS */
+
+#include <asm/hyperv-tlfs.h>
+#define HYPERV_TLFS_HEADERS_INCLUDED
+
+#endif /* !HYPERV_NONTLFS_HEADERS */
--
2.34.1
Powered by blists - more mailing lists