From: "Wen, Qian" <qian.wen@intel.com>
To: Zhao Liu <zhao1.liu@intel.com>
Cc: Igor Mammedov <imammedo@redhat.com>,
qemu-devel@nongnu.org, xiaoyao.li@intel.com, pbonzini@redhat.com,
richard.henderson@linaro.org, babu.moger@amd.com
Subject: Re: [PATCH v2] target/i386: Avoid cpu number overflow in legacy topology
Date: Mon, 14 Aug 2023 14:32:55 +0800 [thread overview]
Message-ID: <72aa3939-46b8-6664-6bb7-31ce666e5daf@intel.com> (raw)
In-Reply-To: <ZNluSyIAyOxYFomL@liuzhao-OptiPlex-7080>
[-- Attachment #1: Type: text/plain, Size: 1695 bytes --]
On 8/14/2023 7:59 AM, Zhao Liu wrote:
> Hi Qian,
>
> On Sun, Aug 13, 2023 at 06:49:40PM +0800, Wen, Qian wrote:
>
> [snip]
>
>>> also perhaps double check if we could do induce similar overflow
>>> tweaking other -smp properties (todo for another patch[es] if there are such places).
>> I have a check, the CPUID.0x4:EAX[31:26] indicates the Maximum number of addressable IDs for processor cores in the physical package.
>> If we launch over 64 cores VM, the 6-bits field will also overflow. I will add the following fix to patch2 in v3.
> Good catch!
>
> Just discussion, I find if we use APIC ID offset to encode 0x4, then it
> seems no need for an explicit check [1], right?
>
> [1]: https://lists.gnu.org/archive/html/qemu-devel/2023-08/msg00027.html
Yes. The offset is always power of 2, so the value written to the 6-bit field likes 0b1111, 0b11111, 0b111111, 0b1111111...
So, EAX[31:26] will be expected, i.e., 0x3f, when the value is overflow and truncated.
>
> Thanks,
> Zhao
>
>> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
>> index 52a2a1a1c7..9c1ae3d83d 100644
>> --- a/target/i386/cpu.c
>> +++ b/target/i386/cpu.c
>> @@ -243,6 +243,7 @@ static void encode_cache_cpuid4(CPUCacheInfo *cache,
>> cache->partitions * cache->sets);
>>
>> assert(num_apic_ids > 0);
>> + num_cores = num_cores > 64 ? 64 : num_cores;
>> *eax = CACHE_TYPE(cache->type) |
>> CACHE_LEVEL(cache->level) |
>> (cache->self_init ? CACHE_SELF_INIT_LEVEL : 0) |
>>
>>
>> Thanks,
>> Qian
>>>>>> *edx |= CPUID_HT;
>>>>>> }
>>>>>> if (!cpu->enable_pmu) {
[-- Attachment #2: Type: text/html, Size: 3041 bytes --]
prev parent reply other threads:[~2023-08-14 6:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 10:27 [PATCH v2] target/i386: Avoid cpu number overflow in legacy topology Qian Wen
2023-08-09 11:14 ` Igor Mammedov
2023-08-09 13:20 ` Wen, Qian
2023-08-09 13:47 ` Igor Mammedov
2023-08-13 10:49 ` Wen, Qian
2023-08-13 23:59 ` Zhao Liu
2023-08-14 6:32 ` Wen, Qian [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=72aa3939-46b8-6664-6bb7-31ce666e5daf@intel.com \
--to=qian.wen@intel.com \
--cc=babu.moger@amd.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=xiaoyao.li@intel.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).