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]
Date:   Mon, 3 Feb 2020 07:15:14 -0300
From:   Thadeu Lima de Souza Cascardo <cascardo@...onical.com>
To:     Vitaly Kuznetsov <vkuznets@...hat.com>
Cc:     pbonzini@...hat.com, sean.j.christopherson@...el.com,
        wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
        x86@...nel.org, linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Subject: Re: [PATCH] x86/kvm: do not setup pv tlb flush when not
 paravirtualized

On Mon, Feb 03, 2020 at 10:59:10AM +0100, Vitaly Kuznetsov wrote:
> Thadeu Lima de Souza Cascardo <cascardo@...onical.com> writes:
> 
> > kvm_setup_pv_tlb_flush will waste memory and print a misguiding message
> > when KVM paravirtualization is not available.
> >
> > Intel SDM says that the when cpuid is used with EAX higher than the
> > maximum supported value for basic of extended function, the data for the
> > highest supported basic function will be returned.
> >
> > So, in some systems, kvm_arch_para_features will return bogus data,
> > causing kvm_setup_pv_tlb_flush to detect support for pv tlb flush.
> >
> > Testing for kvm_para_available will work as it checks for the hypervisor
> > signature.
> >
> > Besides, when the "nopv" command line parameter is used, it should not
> > continue as well, as kvm_guest_init will no be called in that case.
> >
> > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@...onical.com>
> > ---
> >  arch/x86/kernel/kvm.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> > index 81045aabb6f4..d817f255aed8 100644
> > --- a/arch/x86/kernel/kvm.c
> > +++ b/arch/x86/kernel/kvm.c
> > @@ -736,6 +736,9 @@ static __init int kvm_setup_pv_tlb_flush(void)
> >  {
> >  	int cpu;
> >  
> > +	if (!kvm_para_available() || nopv)
> > +		return 0;
> > +
> >  	if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
> >  	    !kvm_para_has_hint(KVM_HINTS_REALTIME) &&
> >  	    kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) {
> 
> The patch will fix the immediate issue, but why kvm_setup_pv_tlb_flush()
> is just an arch_initcall() which will be executed regardless of the fact
> if we are running on KVM or not?
> 
> In Hyper-V we setup PV TLB flush from ms_hyperv_init_platform() -- which
> only happens if Hyper-V platform was detected. Why don't we do it from
> kvm_init_platform() in KVM?
> 
> -- 
> Vitaly
> 

Because we can't call the allocator that early.

Also, see the thread where this was "decided", the v6 of the original patch:

https://lore.kernel.org/kvm/20171129162118.GA10661@flask/

Regards.
Cascardo.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ