All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: speck@linutronix.de
Subject: [MODERATED] Re: [patch V5 05/10] KVM magic # 5
Date: Mon, 2 Jul 2018 12:35:59 -0400	[thread overview]
Message-ID: <20180702163559.GD17137@char.US.ORACLE.com> (raw)
In-Reply-To: <20180702160528.906801335@linutronix.de>

..snip..
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -9576,9 +9576,20 @@ static int vmx_handle_exit(struct kvm_vc
>  #define L1D_CACHE_ORDER 4
>  static void *vmx_l1d_flush_pages;
>  
> -static void __maybe_unused vmx_l1d_flush(void)
> +static void vmx_l1d_flush(struct kvm_vcpu *vcpu)
>  {
>  	int size = PAGE_SIZE << L1D_CACHE_ORDER;
> +	bool always;
> +
> +	/*
> +	 * If the mitigation mode is 'flush always', keep the flush bit
> +	 * set, otherwise clear it. It gets set again either from
> +	 * vcpu_run() or from one of the unsafe VMEXIT handlers.
> +	 */
> +	always = vmentry_l1d_flush == VMENTER_L1D_FLUSH_ALWAYS;
> +	vcpu->arch.l1tf_flush_l1d = always;

<blinks> You did the reset of arch.l1tf_flush_l1d _after_ we have done
this vmx_l1d_flush call, nice!! So obvious in retrospect.

See below one tiny comment.
..snip..
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -195,6 +195,7 @@ struct kvm_stats_debugfs_item debugfs_en
>  	{ "irq_injections", VCPU_STAT(irq_injections) },
>  	{ "nmi_injections", VCPU_STAT(nmi_injections) },
>  	{ "req_event", VCPU_STAT(req_event) },
> +	{ "l1d_flush", VCPU_STAT(l1d_flush) },
>  	{ "mmu_shadow_zapped", VM_STAT(mmu_shadow_zapped) },
>  	{ "mmu_pte_write", VM_STAT(mmu_pte_write) },
>  	{ "mmu_pte_updated", VM_STAT(mmu_pte_updated) },
> @@ -4799,6 +4800,8 @@ int kvm_read_guest_virt(struct kvm_vcpu
>  {
>  	u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
>  
> +	/* The gva_to_pa walker can pull in tons of pages. */
> +	vcpu->arch.l1tf_flush_l1d = true;


I think also kvm_write_guest_virt_system ? That covers vmptrs and vmread.


>  	return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, access,
>  					  exception);
>  }
> @@ -6050,6 +6053,8 @@ int x86_emulate_instruction(struct kvm_v
>  	bool writeback = true;
>  	bool write_fault_to_spt = vcpu->arch.write_fault_to_shadow_pgtable;
>  
> +	vcpu->arch.l1tf_flush_l1d = true;
> +
>  	/*
>  	 * Clear write_fault_to_shadow_pgtable here to ensure it is
>  	 * never reused.
> @@ -7579,6 +7584,7 @@ static int vcpu_run(struct kvm_vcpu *vcp
>  	struct kvm *kvm = vcpu->kvm;
>  
>  	vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
> +	vcpu->arch.l1tf_flush_l1d = true;
>  
>  	for (;;) {
>  		if (kvm_vcpu_running(vcpu)) {
> @@ -8698,6 +8704,7 @@ void kvm_arch_vcpu_uninit(struct kvm_vcp
>  
>  void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu)
>  {
> +	vcpu->arch.l1tf_flush_l1d = true;
>  	kvm_x86_ops->sched_in(vcpu, cpu);
>  }
>  
> 

  reply	other threads:[~2018-07-02 16:36 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-02 15:44 [patch V5 00/10] KVM magic # 0 Thomas Gleixner
2018-07-02 15:44 ` [patch V5 01/10] KVM magic # 1 Thomas Gleixner
2018-07-02 16:22   ` [MODERATED] " Konrad Rzeszutek Wilk
2018-07-02 17:10     ` Thomas Gleixner
2018-07-02 16:25   ` [MODERATED] " Borislav Petkov
2018-07-02 15:44 ` [patch V5 02/10] KVM magic # 2 Thomas Gleixner
2018-07-02 15:44 ` [patch V5 03/10] KVM magic # 3 Thomas Gleixner
2018-07-02 23:42   ` [MODERATED] " Jon Masters
2018-07-02 15:44 ` [patch V5 04/10] KVM magic # 4 Thomas Gleixner
2018-07-02 15:44 ` [patch V5 05/10] KVM magic # 5 Thomas Gleixner
2018-07-02 16:35   ` Konrad Rzeszutek Wilk [this message]
2018-07-02 17:01     ` Thomas Gleixner
2018-07-02 17:24   ` [MODERATED] " Paolo Bonzini
2018-07-03 15:21     ` Thomas Gleixner
2018-07-02 21:19   ` [MODERATED] Re: ***UNCHECKED*** " Alexander Graf
2018-07-02 23:45     ` Andrew Cooper
2018-07-03  1:33       ` Linus Torvalds
2018-07-03  8:23     ` Paolo Bonzini
2018-07-03 14:29       ` [MODERATED] Re: ***UNCHECKED*** " Alexander Graf
2018-07-05 19:08         ` Jon Masters
2018-07-05 21:43         ` Paolo Bonzini
2018-07-05 21:50           ` Linus Torvalds
2018-07-02 15:44 ` [patch V5 06/10] KVM magic # 6 Thomas Gleixner
2018-07-02 15:44 ` [patch V5 07/10] KVM magic # 7 Thomas Gleixner
2018-07-02 15:44 ` [patch V5 08/10] KVM magic # 8 Thomas Gleixner
2018-07-02 15:44 ` [patch V5 09/10] KVM magic # 9 Thomas Gleixner
2018-07-02 15:44 ` [patch V5 10/10] KVM magic # 10 Thomas Gleixner
2018-07-02 17:29   ` [MODERATED] " Paolo Bonzini
2018-07-02 17:41     ` Thomas Gleixner
2018-07-02 22:11       ` Thomas Gleixner
2018-07-03  9:05         ` [MODERATED] " Paolo Bonzini
2018-07-02 16:25 ` [patch V5 00/10] KVM magic # 0 Thomas Gleixner
2018-07-02 22:14 ` [MODERATED] [patch v5 11/10] Linux+KVM magic # 1 Jiri Kosina
2018-07-05 23:56   ` [MODERATED] " Josh Poimboeuf
2018-07-06 11:54     ` Jiri Kosina
2018-07-06 13:05       ` Konrad Rzeszutek Wilk
2018-07-06 15:11       ` Jon Masters

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=20180702163559.GD17137@char.US.ORACLE.com \
    --to=konrad.wilk@oracle.com \
    --cc=speck@linutronix.de \
    /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.