lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221117201004.GA2751024@ls.amr.corp.intel.com>
Date:   Thu, 17 Nov 2022 12:10:04 -0800
From:   Isaku Yamahata <isaku.yamahata@...il.com>
To:     Binbin Wu <binbin.wu@...ux.intel.com>
Cc:     isaku.yamahata@...el.com, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, isaku.yamahata@...il.com,
        Paolo Bonzini <pbonzini@...hat.com>, erdemaktas@...gle.com,
        Sean Christopherson <seanjc@...gle.com>,
        Sagi Shahar <sagis@...gle.com>,
        David Matlack <dmatlack@...gle.com>,
        Chao Gao <chao.gao@...el.com>
Subject: Re: [PATCH v10 071/108] KVM: x86: Allow to update cached values in
 kvm_user_return_msrs w/o wrmsr

On Mon, Nov 14, 2022 at 03:36:27PM +0800,
Binbin Wu <binbin.wu@...ux.intel.com> wrote:

> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 65541bfebb37..4d4b71c4cdb1 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -440,6 +440,15 @@ void kvm_user_return_msr_init_cpu(void)
> >   }
> >   EXPORT_SYMBOL_GPL(kvm_user_return_msr_init_cpu);
> > +static void kvm_user_return_register_notifier(struct kvm_user_return_msrs *msrs)
> > +{
> > +	if (!msrs->registered) {
> > +		msrs->urn.on_user_return = kvm_on_user_return;
> > +		user_return_notifier_register(&msrs->urn);
> > +		msrs->registered = true;
> > +	}
> > +}
> > +
> >   int kvm_set_user_return_msr(unsigned slot, u64 value, u64 mask)
> >   {
> >   	struct kvm_user_return_msrs *msrs = this_cpu_ptr(user_return_msrs);
> > @@ -455,15 +464,22 @@ int kvm_set_user_return_msr(unsigned slot, u64 value, u64 mask)
> >   		return 1;
> >   	msrs->values[slot].curr = value;
> > -	if (!msrs->registered) {
> > -		msrs->urn.on_user_return = kvm_on_user_return;
> > -		user_return_notifier_register(&msrs->urn);
> > -		msrs->registered = true;
> > -	}
> > +	kvm_user_return_register_notifier(msrs);
> >   	return 0;
> >   }
> >   EXPORT_SYMBOL_GPL(kvm_set_user_return_msr);
> > +/* Update the cache, "curr", and register the notifier */
> > +void kvm_user_return_update_cache(unsigned int slot, u64 value)
> > +{
> > +	struct kvm_user_return_msrs *msrs = this_cpu_ptr(user_return_msrs);
> > +
> > +	WARN_ON_ONCE(!msrs->initialized);
> > +	msrs->values[slot].curr = value;
> 
> If the value is the same as the cached one, can it just skip notifier
> registration?

We know tha the the user of the function (in the next patch) passes the
different value, the initial reset value in the return of TDH.VP.ENTER.  So
such check isn't added.
-- 
Isaku Yamahata <isaku.yamahata@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ