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:   Thu, 18 Nov 2021 16:24:28 +0100
From:   Juergen Gross <jgross@...e.com>
To:     Sean Christopherson <seanjc@...gle.com>
Cc:     kvm@...r.kernel.org, x86@...nel.org, linux-kernel@...r.kernel.org,
        Paolo Bonzini <pbonzini@...hat.com>,
        Vitaly Kuznetsov <vkuznets@...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 v3 3/4] x86/kvm: add max number of vcpus for hyperv
 emulation

On 18.11.21 15:49, Sean Christopherson wrote:
> On Thu, Nov 18, 2021, Juergen Gross wrote:
>> On 17.11.21 21:50, Sean Christopherson wrote:
>>>> @@ -166,7 +166,7 @@ static struct kvm_vcpu *get_vcpu_by_vpidx(struct kvm *kvm, u32 vpidx)
>>>>    	struct kvm_vcpu *vcpu = NULL;
>>>>    	int i;
>>>> -	if (vpidx >= KVM_MAX_VCPUS)
>>>> +	if (vpidx >= min(KVM_MAX_VCPUS, KVM_MAX_HYPERV_VCPUS))
>>>
>>> IMO, this is conceptually wrong.  KVM should refuse to allow Hyper-V to be enabled
>>> if the max number of vCPUs exceeds what can be supported, or should refuse to create
>>
>> TBH, I wasn't sure where to put this test. Is there a guaranteed
>> sequence of ioctl()s regarding vcpu creation (or setting the max
>> number of vcpus) and the Hyper-V enabling?
> 
> For better or worse (mostly worse), like all other things CPUID, Hyper-V is a per-vCPU
> knob.  If KVM can't detect the impossible condition at compile time, kvm_check_cpuid()
> is probably the right place to prevent enabling Hyper-V on an unreachable vCPU.

With HYPERV_CPUID_IMPLEMENT_LIMITS already returning the
supported number of vcpus for the Hyper-V case I'm not sure
there is really more needed.

The problem I'm seeing is that the only thing I can do is to
let kvm_get_hv_cpuid() not adding the Hyper-V cpuid leaves for
vcpus > 64. I can't return a failure, because that would
probably let vcpu creation fail. And this is something we don't
want, as kvm_get_hv_cpuid() is called even in the case the guest
doesn't plan to use Hyper-V extensions.

> 
>>> the vCPUs.  I agree it makes sense to add a Hyper-V specific limit, since there are
>>> Hyper-V structures that have a hard limit, but detection of violations should be a
>>> BUILD_BUG_ON, not a silent failure at runtime.
>>>
>>
>> A BUILD_BUG_ON won't be possible with KVM_MAX_VCPUS being selecteble via
>> boot parameter.
> 
> I was thinking that there would still be a KVM-defined max that would cap whatever
> comes in from userspace.
> 

See my answers to you your other responses.


Juergen

Download attachment "OpenPGP_0xB0DE9DD628BF132F.asc" of type "application/pgp-keys" (3092 bytes)

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (496 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ