mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Chenyi Qiang <chenyi.qiang@intel.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	Xiaoyao Li <xiaoyao.li@intel.com>
Subject: Re: [RFC v2 2/2] KVM: VMX: Enable bus lock VM exit
Date: Wed, 2 Sep 2020 15:44:06 -0700	[thread overview]
Message-ID: <20200902224405.GK11695@sjchrist-ice> (raw)
In-Reply-To: <87sgc1x4yn.fsf@vitty.brq.redhat.com>

On Tue, Sep 01, 2020 at 10:43:12AM +0200, Vitaly Kuznetsov wrote:
> > @@ -6809,6 +6824,19 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)
> >  	if (unlikely(vmx->exit_reason.failed_vmentry))
> >  		return EXIT_FASTPATH_NONE;
> >  
> > +	/*
> > +	 * check the exit_reason to see if there is a bus lock
> > +	 * happened in guest.
> > +	 */
> > +	if (kvm_bus_lock_exit_enabled(vmx->vcpu.kvm)) {
> > +		if (vmx->exit_reason.bus_lock_detected) {
> > +			vcpu->stat.bus_locks++;

Why bother with stats?  Every bus lock exits to userspace, having quick
stats doesn't seem all that interesting.

> > +			vcpu->arch.bus_lock_detected = true;
> > +		} else {
> > +			vcpu->arch.bus_lock_detected = false;
> 
> This is a fast path so I'm wondering if we can move bus_lock_detected
> clearing somewhere else.

Why even snapshot vmx->exit_reason.bus_lock_detected?  I don't see any
reason why vcpu_enter_guest() needs to handle the exit to userspace, e.g.
it's just as easily handled in VMX code.

> 
> > +		}
> > +	}
> > +
> >  	vmx->loaded_vmcs->launched = 1;
> >  	vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
> >  
> > @@ -8060,6 +8088,9 @@ static __init int hardware_setup(void)
> >  		kvm_tsc_scaling_ratio_frac_bits = 48;
> >  	}
> >  
> > +	if (cpu_has_vmx_bus_lock_detection())
> > +		kvm_has_bus_lock_exit = true;
> > +
> >  	set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */
> >  
> >  	if (enable_ept)

...

> > @@ -4990,6 +4996,12 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
> >  		kvm->arch.exception_payload_enabled = cap->args[0];
> >  		r = 0;
> >  		break;
> > +	case KVM_CAP_X86_BUS_LOCK_EXIT:
> > +		if (!kvm_has_bus_lock_exit)
> > +			return -EINVAL;
> 
> ... because userspace can check for -EINVAL when enabling the cap. Or we
> can return e.g. -EOPNOTSUPP here. I don't have a strong opinion on the matter..
> 
> > +		kvm->arch.bus_lock_exit = cap->args[0];

Assuming we even want to make this per-VM, I think it'd make sense to make
args[0] a bit mask, e.g. to provide "off" and "exit" (this behavior) while
allowing for future modes, e.g. log-only.

> > +		r = 0;
> > +		break;
> >  	default:
> >  		r = -EINVAL;
> >  		break;
> > @@ -7732,12 +7744,23 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu)

  parent reply	other threads:[~2020-09-02 22:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17  1:44 [RFC v2 0/2] add bus lock VM exit support Chenyi Qiang
2020-08-17  1:44 ` [RFC v2 1/2] KVM: VMX: Convert vcpu_vmx.exit_reason to a union Chenyi Qiang
2020-08-17  1:44 ` [RFC v2 2/2] KVM: VMX: Enable bus lock VM exit Chenyi Qiang
2020-09-01  8:43   ` Vitaly Kuznetsov
2020-09-02  5:19     ` Chenyi Qiang
2020-09-02 22:44     ` Sean Christopherson [this message]
2020-09-03  0:52       ` Xiaoyao Li
2020-09-03  1:25         ` 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=20200902224405.GK11695@sjchrist-ice \
    --to=sean.j.christopherson@intel.com \
    --cc=chenyi.qiang@intel.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=xiaoyao.li@intel.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®