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] [day] [month] [year] [list]
Message-ID: <87ilnymwit.fsf@redhat.com>
Date:   Fri, 15 Jul 2022 13:43:22 +0200
From:   Vitaly Kuznetsov <vkuznets@...hat.com>
To:     Sean Christopherson <seanjc@...gle.com>,
        "Durrant, Paul" <pdurrant@...zon.co.uk>
Cc:     "x86@...nel.org" <x86@...nel.org>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        David Woodhouse <dwmw2@...radead.org>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH v5] KVM: x86/xen: Update Xen CPUID Leaf 4 (tsc info)
 sub-leaves, if present

Sean Christopherson <seanjc@...gle.com> writes:

> On Tue, Jul 12, 2022, Durrant, Paul wrote:
>> > > @@ -1855,3 +1858,51 @@ void kvm_xen_destroy_vm(struct kvm *kvm)
>> > >       if (kvm->arch.xen_hvm_config.msr)
>> > >               static_branch_slow_dec_deferred(&kvm_xen_enabled);
>> > >  }
>> > > +
>> > > +void kvm_xen_after_set_cpuid(struct kvm_vcpu *vcpu)
>> > > +{
>> > > +     u32 base = 0;
>> > > +     u32 limit;
>> > > +     u32 function;
>> > > +
>> > > +     vcpu->arch.xen.cpuid_tsc_info = 0;
>> > > +
>> > > +     for_each_possible_hypervisor_cpuid_base(function) {
>> > > +             struct kvm_cpuid_entry2 *entry = kvm_find_cpuid_entry(vcpu, function, 0);
>> > > +
>> > > +             if (entry &&
>> > > +                 entry->ebx == XEN_CPUID_SIGNATURE_EBX &&
>> > > +                 entry->ecx == XEN_CPUID_SIGNATURE_ECX &&
>> > > +                 entry->edx == XEN_CPUID_SIGNATURE_EDX) {
>> > > +                     base = function;
>> > > +                     limit = entry->eax;
>> > > +                     break;
>> > > +             }
>> > > +     }
>> > > +     if (!base)
>> > > +             return;
>> > 
>> > Rather than open code a variant of kvm_update_kvm_cpuid_base(), that helper can
>> > be tweaked to take a signature.  Along with a patch to provide a #define for Xen's
>> > signature as a string, this entire function becomes a one-liner.
>> > 
>> 
>> Sure, but as said above, we could make capturing the limit part of the
>> general function too. It could even be extended to capture the Hyper-V
>> base/limit too.  As for defining the sig as a string... I guess it would be
>> neater to use the values from the Xen header, but it'll probably make the
>> code more ugly so a secondary definition is reasonable.
>
> The base needs to be captured separately for KVM and Xen because KVM (and presumably
> Xen itself since Xen also allows a variable base) supports advertising multiple
> hypervisors to the guest.  I don't know if there are any guests that will concurrently
> utilize multiple hypervisor's paravirt features, so maybe we could squeak by, but
> saving 4 bytes isn't worth the risk.
>
> AFAIK, Hyper-V doesn't allow for a variable base, and so doesn't utilize the
> for_each_possible... macro.

FWIW, this matches my understanding too: Windows guests don't seem to
check anything besides 0x40000001 and give up if Hyper-V's id is not
there.

-- 
Vitaly

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ