All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Jim Mattson <jmattson@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: VMX: Add VMCS to CPU's loaded VMCSs before VMPTRLD
Date: Mon, 1 Aug 2016 15:29:23 +0200	[thread overview]
Message-ID: <20160801132922.GB3758@potion> (raw)
In-Reply-To: <1469843813-30810-1-git-send-email-jmattson@google.com>

2016-07-29 18:56-0700, Jim Mattson:
> Kexec needs to know the addresses of all VMCSs that are active on
> each CPU, so that it can flush them from the VMCS caches. It is
> safe to record superfluous addresses that are not associated with
> an active VMCS, but it is not safe to omit an address associated
> with an active VMCS.
> 
> After a call to vmcs_load, the VMCS that was loaded is active on
> the CPU. The VMCS should be added to the CPU's list of active
> VMCSs before it is loaded.
> 
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---

Applied to kvm/queue, thanks.

I have tentatively kept the patch without "Cc: stable@..." as VMX might
not write to the in-memory VMCS unless the cached VMCS has been dirtied.

>  arch/x86/kvm/vmx.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 7758680..f3d9995 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2121,22 +2121,14 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
>  {
>  	struct vcpu_vmx *vmx = to_vmx(vcpu);
>  	u64 phys_addr = __pa(per_cpu(vmxarea, cpu));
> +	bool already_loaded = vmx->loaded_vmcs->cpu == cpu;
>  
>  	if (!vmm_exclusive)
>  		kvm_cpu_vmxon(phys_addr);
> -	else if (vmx->loaded_vmcs->cpu != cpu)
> +	else if (!already_loaded)
>  		loaded_vmcs_clear(vmx->loaded_vmcs);
>  
> -	if (per_cpu(current_vmcs, cpu) != vmx->loaded_vmcs->vmcs) {
> -		per_cpu(current_vmcs, cpu) = vmx->loaded_vmcs->vmcs;
> -		vmcs_load(vmx->loaded_vmcs->vmcs);
> -	}
> -
> -	if (vmx->loaded_vmcs->cpu != cpu) {
> -		struct desc_ptr *gdt = this_cpu_ptr(&host_gdt);
> -		unsigned long sysenter_esp;
> -
> -		kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
> +	if (!already_loaded) {
>  		local_irq_disable();
>  		crash_disable_local_vmclear(cpu);
>  
> @@ -2151,6 +2143,18 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
>  			 &per_cpu(loaded_vmcss_on_cpu, cpu));
>  		crash_enable_local_vmclear(cpu);
>  		local_irq_enable();
> +	}
> +
> +	if (per_cpu(current_vmcs, cpu) != vmx->loaded_vmcs->vmcs) {
> +		per_cpu(current_vmcs, cpu) = vmx->loaded_vmcs->vmcs;
> +		vmcs_load(vmx->loaded_vmcs->vmcs);
> +	}
> +
> +	if (!already_loaded) {
> +		struct desc_ptr *gdt = this_cpu_ptr(&host_gdt);
> +		unsigned long sysenter_esp;
> +
> +		kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
>  
>  		/*
>  		 * Linux uses per-cpu TSS and GDT, so set these when switching
> -- 
> 2.8.0.rc3.226.g39d4020
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2016-08-01 13:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-30  1:56 [PATCH] KVM: VMX: Add VMCS to CPU's loaded VMCSs before VMPTRLD Jim Mattson
2016-08-01 13:29 ` Radim Krčmář [this message]

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=20160801132922.GB3758@potion \
    --to=rkrcmar@redhat.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.