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: <a06997fe-8dd7-e91a-2017-912827f554e7@redhat.com>
Date:   Mon, 2 May 2022 18:07:11 +0200
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Zeng Guang <guang.zeng@...el.com>,
        Sean Christopherson <seanjc@...gle.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Tony Luck <tony.luck@...el.com>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        Kim Phillips <kim.phillips@....com>,
        Jarkko Sakkinen <jarkko@...nel.org>,
        Jethro Beekman <jethro@...tanix.com>,
        Kai Huang <kai.huang@...el.com>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org,
        Robert Hu <robert.hu@...el.com>, Gao Chao <chao.gao@...el.com>
Subject: Re: [PATCH v9 8/9] KVM: x86: Allow userspace set maximum VCPU id for
 VM

On 4/19/22 17:44, Zeng Guang wrote:
> +Userspace is able to calculate the limit to APIC ID values from designated CPU
> +topology. This capability allows userspace to specify maximum possible APIC ID
> +assigned for current VM session prior to the creation of vCPUs. By design, it
> +can set only once and doesn't accept change any more. KVM will manage memory
> +allocation of VM-scope structures which depends on the value of APIC ID.
> +
> +Calling KVM_CHECK_EXTENSION for this capability returns the value of maximum APIC
> +ID that KVM supports at runtime. It sets as KVM_MAX_VCPU_IDS by default.

Better:

This capability allows userspace to specify maximum possible APIC ID
assigned for current VM session prior to the creation of vCPUs, saving
memory for data structures indexed by the APIC ID.  Userspace is able
to calculate the limit to APIC ID values from designated
CPU topology.

The value can be changed only until KVM_ENABLE_CAP is set to a nonzero
value or until a vCPU is created.  Upon creation of the first vCPU,
if the value was set to zero or KVM_ENABLE_CAP was not invoked, KVM
uses the return value of KVM_CHECK_EXTENSION(KVM_CAP_MAX_VCPU_ID) as
the maximum APIC ID.

>   	case KVM_CAP_MAX_VCPU_ID:
> -		r = KVM_MAX_VCPU_IDS;
> +		if (!kvm->arch.max_vcpu_ids)
> +			r = KVM_MAX_VCPU_IDS;
> +		else
> +			r = kvm->arch.max_vcpu_ids;

I think returning the constant KVM_CAP_MAX_VCPU_IDS is better.

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ