diff mbox series

[v3,22/33] KVM: x86: Explicitly #define the VCPU_REGS_* indices

Message ID 20190125154120.19385-23-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show
Series KVM: VMX: Move vCPU-run to proper asm sub-routine | expand

Commit Message

Sean Christopherson Jan. 25, 2019, 3:41 p.m. UTC
Declaring the VCPU_REGS_* as enums allows for more robust C code, but it
prevents using the values in assembly files.  Expliciting #define the
indices in an asm-friendly file to prepare for VMX moving its transition
code to a proper assembly file, but keep the enums for general usage.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/include/asm/kvm_host.h      | 33 ++++++++++++++--------------
 arch/x86/include/asm/kvm_vcpu_regs.h | 25 +++++++++++++++++++++
 2 files changed, 42 insertions(+), 16 deletions(-)
 create mode 100644 arch/x86/include/asm/kvm_vcpu_regs.h

Comments

Tianyu Lan Feb. 18, 2019, 6:52 a.m. UTC | #1
Hi Paolo & Sean:
             This commit in the queue brand missed new file
kvm_vcpu_regs.h and this causes build error. Please have a look.
Thanks.
https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?h=queue&id=1561fcbc8e1663268bc69dc59b1c86aca4cf203d


On Fri, Jan 25, 2019 at 11:42 PM Sean Christopherson
<sean.j.christopherson@intel.com> wrote:
>
> Declaring the VCPU_REGS_* as enums allows for more robust C code, but it
> prevents using the values in assembly files.  Expliciting #define the
> indices in an asm-friendly file to prepare for VMX moving its transition
> code to a proper assembly file, but keep the enums for general usage.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/include/asm/kvm_host.h      | 33 ++++++++++++++--------------
>  arch/x86/include/asm/kvm_vcpu_regs.h | 25 +++++++++++++++++++++
>  2 files changed, 42 insertions(+), 16 deletions(-)
>  create mode 100644 arch/x86/include/asm/kvm_vcpu_regs.h
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 49f449f56434..b157d87b105b 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -35,6 +35,7 @@
>  #include <asm/msr-index.h>
>  #include <asm/asm.h>
>  #include <asm/kvm_page_track.h>
> +#include <asm/kvm_vcpu_regs.h>
>  #include <asm/hyperv-tlfs.h>
>
>  #define KVM_MAX_VCPUS 288
> @@ -138,23 +139,23 @@ static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
>  #define ASYNC_PF_PER_VCPU (1 << ASYNC_PF_PER_VCPU_ORDER)
>
>  enum kvm_reg {
> -       VCPU_REGS_RAX = 0,
> -       VCPU_REGS_RCX = 1,
> -       VCPU_REGS_RDX = 2,
> -       VCPU_REGS_RBX = 3,
> -       VCPU_REGS_RSP = 4,
> -       VCPU_REGS_RBP = 5,
> -       VCPU_REGS_RSI = 6,
> -       VCPU_REGS_RDI = 7,
> +       VCPU_REGS_RAX = __VCPU_REGS_RAX,
> +       VCPU_REGS_RCX = __VCPU_REGS_RCX,
> +       VCPU_REGS_RDX = __VCPU_REGS_RDX,
> +       VCPU_REGS_RBX = __VCPU_REGS_RBX,
> +       VCPU_REGS_RSP = __VCPU_REGS_RSP,
> +       VCPU_REGS_RBP = __VCPU_REGS_RBP,
> +       VCPU_REGS_RSI = __VCPU_REGS_RSI,
> +       VCPU_REGS_RDI = __VCPU_REGS_RDI,
>  #ifdef CONFIG_X86_64
> -       VCPU_REGS_R8 = 8,
> -       VCPU_REGS_R9 = 9,
> -       VCPU_REGS_R10 = 10,
> -       VCPU_REGS_R11 = 11,
> -       VCPU_REGS_R12 = 12,
> -       VCPU_REGS_R13 = 13,
> -       VCPU_REGS_R14 = 14,
> -       VCPU_REGS_R15 = 15,
> +       VCPU_REGS_R8  = __VCPU_REGS_R8,
> +       VCPU_REGS_R9  = __VCPU_REGS_R9,
> +       VCPU_REGS_R10 = __VCPU_REGS_R10,
> +       VCPU_REGS_R11 = __VCPU_REGS_R11,
> +       VCPU_REGS_R12 = __VCPU_REGS_R12,
> +       VCPU_REGS_R13 = __VCPU_REGS_R13,
> +       VCPU_REGS_R14 = __VCPU_REGS_R14,
> +       VCPU_REGS_R15 = __VCPU_REGS_R15,
>  #endif
>         VCPU_REGS_RIP,
>         NR_VCPU_REGS
> diff --git a/arch/x86/include/asm/kvm_vcpu_regs.h b/arch/x86/include/asm/kvm_vcpu_regs.h
> new file mode 100644
> index 000000000000..1af2cb59233b
> --- /dev/null
> +++ b/arch/x86/include/asm/kvm_vcpu_regs.h
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_X86_KVM_VCPU_REGS_H
> +#define _ASM_X86_KVM_VCPU_REGS_H
> +
> +#define __VCPU_REGS_RAX  0
> +#define __VCPU_REGS_RCX  1
> +#define __VCPU_REGS_RDX  2
> +#define __VCPU_REGS_RBX  3
> +#define __VCPU_REGS_RSP  4
> +#define __VCPU_REGS_RBP  5
> +#define __VCPU_REGS_RSI  6
> +#define __VCPU_REGS_RDI  7
> +
> +#ifdef CONFIG_X86_64
> +#define __VCPU_REGS_R8   8
> +#define __VCPU_REGS_R9   9
> +#define __VCPU_REGS_R10 10
> +#define __VCPU_REGS_R11 11
> +#define __VCPU_REGS_R12 12
> +#define __VCPU_REGS_R13 13
> +#define __VCPU_REGS_R14 14
> +#define __VCPU_REGS_R15 15
> +#endif
> +
> +#endif /* _ASM_X86_KVM_VCPU_REGS_H */
> --
> 2.20.1
>
diff mbox series

Patch

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 49f449f56434..b157d87b105b 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -35,6 +35,7 @@ 
 #include <asm/msr-index.h>
 #include <asm/asm.h>
 #include <asm/kvm_page_track.h>
+#include <asm/kvm_vcpu_regs.h>
 #include <asm/hyperv-tlfs.h>
 
 #define KVM_MAX_VCPUS 288
@@ -138,23 +139,23 @@  static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
 #define ASYNC_PF_PER_VCPU (1 << ASYNC_PF_PER_VCPU_ORDER)
 
 enum kvm_reg {
-	VCPU_REGS_RAX = 0,
-	VCPU_REGS_RCX = 1,
-	VCPU_REGS_RDX = 2,
-	VCPU_REGS_RBX = 3,
-	VCPU_REGS_RSP = 4,
-	VCPU_REGS_RBP = 5,
-	VCPU_REGS_RSI = 6,
-	VCPU_REGS_RDI = 7,
+	VCPU_REGS_RAX = __VCPU_REGS_RAX,
+	VCPU_REGS_RCX = __VCPU_REGS_RCX,
+	VCPU_REGS_RDX = __VCPU_REGS_RDX,
+	VCPU_REGS_RBX = __VCPU_REGS_RBX,
+	VCPU_REGS_RSP = __VCPU_REGS_RSP,
+	VCPU_REGS_RBP = __VCPU_REGS_RBP,
+	VCPU_REGS_RSI = __VCPU_REGS_RSI,
+	VCPU_REGS_RDI = __VCPU_REGS_RDI,
 #ifdef CONFIG_X86_64
-	VCPU_REGS_R8 = 8,
-	VCPU_REGS_R9 = 9,
-	VCPU_REGS_R10 = 10,
-	VCPU_REGS_R11 = 11,
-	VCPU_REGS_R12 = 12,
-	VCPU_REGS_R13 = 13,
-	VCPU_REGS_R14 = 14,
-	VCPU_REGS_R15 = 15,
+	VCPU_REGS_R8  = __VCPU_REGS_R8,
+	VCPU_REGS_R9  = __VCPU_REGS_R9,
+	VCPU_REGS_R10 = __VCPU_REGS_R10,
+	VCPU_REGS_R11 = __VCPU_REGS_R11,
+	VCPU_REGS_R12 = __VCPU_REGS_R12,
+	VCPU_REGS_R13 = __VCPU_REGS_R13,
+	VCPU_REGS_R14 = __VCPU_REGS_R14,
+	VCPU_REGS_R15 = __VCPU_REGS_R15,
 #endif
 	VCPU_REGS_RIP,
 	NR_VCPU_REGS
diff --git a/arch/x86/include/asm/kvm_vcpu_regs.h b/arch/x86/include/asm/kvm_vcpu_regs.h
new file mode 100644
index 000000000000..1af2cb59233b
--- /dev/null
+++ b/arch/x86/include/asm/kvm_vcpu_regs.h
@@ -0,0 +1,25 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_KVM_VCPU_REGS_H
+#define _ASM_X86_KVM_VCPU_REGS_H
+
+#define __VCPU_REGS_RAX  0
+#define __VCPU_REGS_RCX  1
+#define __VCPU_REGS_RDX  2
+#define __VCPU_REGS_RBX  3
+#define __VCPU_REGS_RSP  4
+#define __VCPU_REGS_RBP  5
+#define __VCPU_REGS_RSI  6
+#define __VCPU_REGS_RDI  7
+
+#ifdef CONFIG_X86_64
+#define __VCPU_REGS_R8   8
+#define __VCPU_REGS_R9   9
+#define __VCPU_REGS_R10 10
+#define __VCPU_REGS_R11 11
+#define __VCPU_REGS_R12 12
+#define __VCPU_REGS_R13 13
+#define __VCPU_REGS_R14 14
+#define __VCPU_REGS_R15 15
+#endif
+
+#endif /* _ASM_X86_KVM_VCPU_REGS_H */