On Thursday, September 20, 2018 8:08 PM, Gonglei (Arei) wrote:
> > +static bool guest_access_lbr_msr(struct kvm_vcpu *vcpu,
> > +                            struct msr_data *msr_info,
> > +                            bool set)
> > +{
> > +   bool ret = false;
> > +
> > +   if (!vcpu->kvm->arch.guest_lbr_enabled)
> > +           return false;
> > +
> > +   if (set)
> > +           ret = guest_set_lbr_msr(vcpu, msr_info);
> > +   else
> > +           ret = guest_get_lbr_msr(vcpu, msr_info);
> > +
> > +   if (ret) {
> > +           vcpu->arch.lbr_used = true;
> > +           vmx_set_intercept_for_lbr_msrs(vcpu, false);
> 
> You can use if (!vcpu->arch.lbr_used) as the condition of assign values.
> They are need only once.

Thanks, I think it would be better to use

If (ret && !vcpu->arch.lbr_used)
(we need to make sure that the guest is accessing one of the LBR related MSRs 
via ret=true)

Best,
Wei

Reply via email to