linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
To: linux-hyperv@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	iommu@lists.linux.dev, netdev@vger.kernel.org,
	linux-pci@vger.kernel.org, linux-arch@vger.kernel.org,
	virtualization@lists.linux.dev
Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
	decui@microsoft.com, catalin.marinas@arm.com, will@kernel.org,
	luto@kernel.org, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com,
	peterz@infradead.org, daniel.lezcano@linaro.org, joro@8bytes.org,
	robin.murphy@arm.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, lpieralisi@kernel.org,
	kw@linux.com, robh@kernel.org, bhelgaas@google.com,
	arnd@arndb.de, sgarzare@redhat.com,
	jinankjain@linux.microsoft.com, muminulrussell@gmail.com,
	skinsburskii@linux.microsoft.com, mukeshrathor@microsoft.com
Subject: [PATCH 4/5] hyperv: Add hv_defs.h to conditionally include hyperv-tlfs.h or hvhdk.h
Date: Thu,  3 Oct 2024 12:51:03 -0700	[thread overview]
Message-ID: <1727985064-18362-5-git-send-email-nunodasneves@linux.microsoft.com> (raw)
In-Reply-To: <1727985064-18362-1-git-send-email-nunodasneves@linux.microsoft.com>

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@linux.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


  parent reply	other threads:[~2024-10-03 19:51 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03 19:50 [PATCH 0/5] Add new headers for Hyper-V Dom0 Nuno Das Neves
2024-10-03 19:51 ` [PATCH 1/5] hyperv: Move hv_connection_id to hyperv-tlfs.h Nuno Das Neves
2024-10-07 16:24   ` Wei Liu
2024-10-03 19:51 ` [PATCH 2/5] hyperv: Remove unnecessary #includes Nuno Das Neves
2024-10-07 16:24   ` Wei Liu
2024-10-10 18:21   ` Michael Kelley
2024-10-31 18:47     ` Nuno Das Neves
2024-10-03 19:51 ` [PATCH 3/5] hyperv: Add new Hyper-V headers Nuno Das Neves
2024-10-10 18:21   ` Michael Kelley
2024-10-11  1:34     ` [EXTERNAL] " MUKESH RATHOR
2024-10-03 19:51 ` Nuno Das Neves [this message]
2024-10-03 19:51 ` [PATCH 5/5] hyperv: Use hvhdk.h instead of hyperv-tlfs.h in Hyper-V code Nuno Das Neves
2024-10-04 15:58   ` Stanislav Kinsburskii
2024-10-05  0:07     ` Nuno Das Neves
2024-10-04 19:11   ` Simon Horman
2024-10-04 23:36     ` Nuno Das Neves
2024-10-04 21:55   ` kernel test robot
2024-10-05  1:54   ` kernel test robot
2024-10-07 16:26 ` [PATCH 0/5] Add new headers for Hyper-V Dom0 Wei Liu
2024-10-10 18:21 ` Michael Kelley
2024-10-11  1:34   ` [EXTERNAL] " MUKESH RATHOR
2024-10-23  0:04     ` Nuno Das Neves
2024-10-23 18:39       ` Michael Kelley
2024-10-23  0:51   ` Nuno Das Neves
2024-10-23 18:32     ` Michael Kelley
2024-10-31 19:05 ` Easwar Hariharan
2024-10-31 22:59   ` Nuno Das Neves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1727985064-18362-5-git-send-email-nunodasneves@linux.microsoft.com \
    --to=nunodasneves@linux.microsoft.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=edumazet@google.com \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=iommu@lists.linux.dev \
    --cc=jinankjain@linux.microsoft.com \
    --cc=joro@8bytes.org \
    --cc=kuba@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kw@linux.com \
    --cc=kys@microsoft.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mukeshrathor@microsoft.com \
    --cc=muminulrussell@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=seanjc@google.com \
    --cc=sgarzare@redhat.com \
    --cc=skinsburskii@linux.microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux.dev \
    --cc=wei.liu@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).