kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM/x86: Move definition of __ex to x86.h
@ 2020-12-18 12:11 Uros Bizjak
  2020-12-19  1:19 ` Krish Sadhukhan
  0 siblings, 1 reply; 2+ messages in thread
From: Uros Bizjak @ 2020-12-18 12:11 UTC (permalink / raw)
  To: kvm, linux-kernel; +Cc: Uros Bizjak, Paolo Bonzini, Sean Christopherson

Merge __kvm_handle_fault_on_reboot with its sole user
and move the definition of __ex to a common include to be
shared between VMX and SVM.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
---
 arch/x86/include/asm/kvm_host.h | 25 -------------------------
 arch/x86/kvm/svm/svm.c          |  2 --
 arch/x86/kvm/vmx/vmx_ops.h      |  4 +---
 arch/x86/kvm/x86.h              | 23 +++++++++++++++++++++++
 4 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 7e5f33a0d0e2..ff152ee1d63f 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1623,31 +1623,6 @@ enum {
 #define kvm_arch_vcpu_memslots_id(vcpu) ((vcpu)->arch.hflags & HF_SMM_MASK ? 1 : 0)
 #define kvm_memslots_for_spte_role(kvm, role) __kvm_memslots(kvm, (role).smm)
 
-asmlinkage void kvm_spurious_fault(void);
-
-/*
- * Hardware virtualization extension instructions may fault if a
- * reboot turns off virtualization while processes are running.
- * Usually after catching the fault we just panic; during reboot
- * instead the instruction is ignored.
- */
-#define __kvm_handle_fault_on_reboot(insn)				\
-	"666: \n\t"							\
-	insn "\n\t"							\
-	"jmp	668f \n\t"						\
-	"667: \n\t"							\
-	"1: \n\t"							\
-	".pushsection .discard.instr_begin \n\t"			\
-	".long 1b - . \n\t"						\
-	".popsection \n\t"						\
-	"call	kvm_spurious_fault \n\t"				\
-	"1: \n\t"							\
-	".pushsection .discard.instr_end \n\t"				\
-	".long 1b - . \n\t"						\
-	".popsection \n\t"						\
-	"668: \n\t"							\
-	_ASM_EXTABLE(666b, 667b)
-
 #define KVM_ARCH_WANT_MMU_NOTIFIER
 int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
 			unsigned flags);
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index da7eb4aaf44f..0a72ab9fd568 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -42,8 +42,6 @@
 
 #include "svm.h"
 
-#define __ex(x) __kvm_handle_fault_on_reboot(x)
-
 MODULE_AUTHOR("Qumranet");
 MODULE_LICENSE("GPL");
 
diff --git a/arch/x86/kvm/vmx/vmx_ops.h b/arch/x86/kvm/vmx/vmx_ops.h
index 692b0c31c9c8..7e3cb53c413f 100644
--- a/arch/x86/kvm/vmx/vmx_ops.h
+++ b/arch/x86/kvm/vmx/vmx_ops.h
@@ -4,13 +4,11 @@
 
 #include <linux/nospec.h>
 
-#include <asm/kvm_host.h>
 #include <asm/vmx.h>
 
 #include "evmcs.h"
 #include "vmcs.h"
-
-#define __ex(x) __kvm_handle_fault_on_reboot(x)
+#include "x86.h"
 
 asmlinkage void vmread_error(unsigned long field, bool fault);
 __attribute__((regparm(0))) void vmread_error_trampoline(unsigned long field,
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index e7ca622a468f..608548d05e84 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -7,6 +7,29 @@
 #include "kvm_cache_regs.h"
 #include "kvm_emulate.h"
 
+asmlinkage void kvm_spurious_fault(void);
+
+/*
+ * Hardware virtualization extension instructions may fault if a
+ * reboot turns off virtualization while processes are running.
+ * Usually after catching the fault we just panic; during reboot
+ * instead the instruction is ignored.
+ */
+#define __ex(insn)							\
+	"666:	" insn "\n"						\
+	"	jmp 669f\n"						\
+	"667:\n"							\
+	".pushsection .discard.instr_begin\n"				\
+	".long 667b - .\n"						\
+	".popsection\n"							\
+	"	call kvm_spurious_fault\n"				\
+	"668:\n"							\
+	".pushsection .discard.instr_end\n"				\
+	".long 668b - .\n"						\
+	".popsection\n"							\
+	"669:\n"							\
+	_ASM_EXTABLE(666b, 667b)
+
 #define KVM_DEFAULT_PLE_GAP		128
 #define KVM_VMX_DEFAULT_PLE_WINDOW	4096
 #define KVM_DEFAULT_PLE_WINDOW_GROW	2
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM/x86: Move definition of __ex to x86.h
  2020-12-18 12:11 [PATCH] KVM/x86: Move definition of __ex to x86.h Uros Bizjak
@ 2020-12-19  1:19 ` Krish Sadhukhan
  0 siblings, 0 replies; 2+ messages in thread
From: Krish Sadhukhan @ 2020-12-19  1:19 UTC (permalink / raw)
  To: Uros Bizjak, kvm, linux-kernel; +Cc: Paolo Bonzini, Sean Christopherson


On 12/18/20 4:11 AM, Uros Bizjak wrote:
> Merge __kvm_handle_fault_on_reboot with its sole user
> and move the definition of __ex to a common include to be
> shared between VMX and SVM.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> ---
>   arch/x86/include/asm/kvm_host.h | 25 -------------------------
>   arch/x86/kvm/svm/svm.c          |  2 --
>   arch/x86/kvm/vmx/vmx_ops.h      |  4 +---
>   arch/x86/kvm/x86.h              | 23 +++++++++++++++++++++++
>   4 files changed, 24 insertions(+), 30 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 7e5f33a0d0e2..ff152ee1d63f 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1623,31 +1623,6 @@ enum {
>   #define kvm_arch_vcpu_memslots_id(vcpu) ((vcpu)->arch.hflags & HF_SMM_MASK ? 1 : 0)
>   #define kvm_memslots_for_spte_role(kvm, role) __kvm_memslots(kvm, (role).smm)
>   
> -asmlinkage void kvm_spurious_fault(void);
> -
> -/*
> - * Hardware virtualization extension instructions may fault if a
> - * reboot turns off virtualization while processes are running.
> - * Usually after catching the fault we just panic; during reboot
> - * instead the instruction is ignored.
> - */
> -#define __kvm_handle_fault_on_reboot(insn)				\
> -	"666: \n\t"							\
> -	insn "\n\t"							\
> -	"jmp	668f \n\t"						\
> -	"667: \n\t"							\
> -	"1: \n\t"							\
> -	".pushsection .discard.instr_begin \n\t"			\
> -	".long 1b - . \n\t"						\
> -	".popsection \n\t"						\
> -	"call	kvm_spurious_fault \n\t"				\
> -	"1: \n\t"							\
> -	".pushsection .discard.instr_end \n\t"				\
> -	".long 1b - . \n\t"						\
> -	".popsection \n\t"						\
> -	"668: \n\t"							\
> -	_ASM_EXTABLE(666b, 667b)
> -
>   #define KVM_ARCH_WANT_MMU_NOTIFIER
>   int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
>   			unsigned flags);
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index da7eb4aaf44f..0a72ab9fd568 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -42,8 +42,6 @@
>   
>   #include "svm.h"
>   
> -#define __ex(x) __kvm_handle_fault_on_reboot(x)
> -
>   MODULE_AUTHOR("Qumranet");
>   MODULE_LICENSE("GPL");
>   
> diff --git a/arch/x86/kvm/vmx/vmx_ops.h b/arch/x86/kvm/vmx/vmx_ops.h
> index 692b0c31c9c8..7e3cb53c413f 100644
> --- a/arch/x86/kvm/vmx/vmx_ops.h
> +++ b/arch/x86/kvm/vmx/vmx_ops.h
> @@ -4,13 +4,11 @@
>   
>   #include <linux/nospec.h>
>   
> -#include <asm/kvm_host.h>
>   #include <asm/vmx.h>
>   
>   #include "evmcs.h"
>   #include "vmcs.h"
> -
> -#define __ex(x) __kvm_handle_fault_on_reboot(x)
> +#include "x86.h"
>   
>   asmlinkage void vmread_error(unsigned long field, bool fault);
>   __attribute__((regparm(0))) void vmread_error_trampoline(unsigned long field,
> diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> index e7ca622a468f..608548d05e84 100644
> --- a/arch/x86/kvm/x86.h
> +++ b/arch/x86/kvm/x86.h
> @@ -7,6 +7,29 @@
>   #include "kvm_cache_regs.h"
>   #include "kvm_emulate.h"
>   
> +asmlinkage void kvm_spurious_fault(void);
> +
> +/*
> + * Hardware virtualization extension instructions may fault if a
> + * reboot turns off virtualization while processes are running.
> + * Usually after catching the fault we just panic; during reboot
> + * instead the instruction is ignored.
> + */
> +#define __ex(insn)							\
> +	"666:	" insn "\n"						\
> +	"	jmp 669f\n"						\
> +	"667:\n"							\
> +	".pushsection .discard.instr_begin\n"				\
> +	".long 667b - .\n"						\
> +	".popsection\n"							\
> +	"	call kvm_spurious_fault\n"				\
> +	"668:\n"							\
> +	".pushsection .discard.instr_end\n"				\
> +	".long 668b - .\n"						\
> +	".popsection\n"							\
> +	"669:\n"							\
> +	_ASM_EXTABLE(666b, 667b)
> +
>   #define KVM_DEFAULT_PLE_GAP		128
>   #define KVM_VMX_DEFAULT_PLE_WINDOW	4096
>   #define KVM_DEFAULT_PLE_WINDOW_GROW	2
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-19  1:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-18 12:11 [PATCH] KVM/x86: Move definition of __ex to x86.h Uros Bizjak
2020-12-19  1:19 ` Krish Sadhukhan

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).