mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krish Sadhukhan <krish.sadhukhan@oracle.com>
To: Uros Bizjak <ubizjak@gmail.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Sean Christopherson <seanjc@google.com>
Subject: Re: [PATCH v3] KVM/x86: Move definition of __ex to x86.h
Date: Mon, 21 Dec 2020 14:00:52 -0800	[thread overview]
Message-ID: <a773afca-7f28-2392-74ad-0895da3f75ca@oracle.com> (raw)
In-Reply-To: <20201221194800.46962-1-ubizjak@gmail.com>


On 12/21/20 11:48 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.
>
> v2: Rebase to the latest kvm/queue.
>
> v3: Incorporate changes from review comments.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> ---
>   arch/x86/include/asm/kvm_host.h | 25 -------------------------
>   arch/x86/kvm/svm/sev.c          |  2 --
>   arch/x86/kvm/svm/svm.c          |  2 --
>   arch/x86/kvm/vmx/vmx.c          |  4 +---
>   arch/x86/kvm/vmx/vmx_ops.h      |  4 +---
>   arch/x86/kvm/x86.h              | 24 ++++++++++++++++++++++++
>   6 files changed, 26 insertions(+), 35 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 39707e72b062..a78e4b1a5d77 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1634,31 +1634,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/sev.c b/arch/x86/kvm/svm/sev.c
> index e57847ff8bd2..ba492b6d37a0 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -25,8 +25,6 @@
>   #include "cpuid.h"
>   #include "trace.h"
>   
> -#define __ex(x) __kvm_handle_fault_on_reboot(x)
> -
>   static u8 sev_enc_bit;
>   static int sev_flush_asids(void);
>   static DECLARE_RWSEM(sev_deactivate_lock);
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 941e5251e13f..733d9f98a121 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.c b/arch/x86/kvm/vmx/vmx.c
> index 75c9c6a0a3a4..b82f2689f2d7 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -2320,9 +2320,7 @@ static void vmclear_local_loaded_vmcss(void)
>   }
>   
>   
> -/* Just like cpu_vmxoff(), but with the __kvm_handle_fault_on_reboot()
> - * tricks.
> - */
> +/* Just like cpu_vmxoff(), but with the fault handling. */
>   static void kvm_cpu_vmxoff(void)
>   {
>   	asm volatile (__ex("vmxoff"));
> 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 c5ee0f5ce0f1..5b16d2b5c3bc 100644
> --- a/arch/x86/kvm/x86.h
> +++ b/arch/x86/kvm/x86.h
> @@ -8,6 +8,30 @@
>   #include "kvm_cache_regs.h"
>   #include "kvm_emulate.h"
>   
> +asmlinkage void kvm_spurious_fault(void);
> +
> +/*
> + * Handle a fault on a hardware virtualization (VMX or SVM) instruction.
> + *
> + * 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)							\


While the previous name was too elaborate, this new name is very 
cryptic.  Unless we are saving for space, it's better to give a somewhat 
descriptive name.

> +	"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

  reply	other threads:[~2020-12-21 22:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21 19:48 Uros Bizjak
2020-12-21 22:00 ` Krish Sadhukhan [this message]
2020-12-21 22:10   ` Uros Bizjak
2020-12-21 23:05   ` Sean Christopherson
2020-12-28 23:54 ` Sean Christopherson
2020-12-29 22:14   ` Sean Christopherson

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=a773afca-7f28-2392-74ad-0895da3f75ca@oracle.com \
    --to=krish.sadhukhan@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=ubizjak@gmail.com \
    /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

all inboxes | Powered by JetHome®