From: Zhao Liu <zhao1.liu@intel.com>
To: "Wen, Qian" <qian.wen@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,
zhao1.liu@intel.com
Subject: Re: [PATCH v2] target/i386: Avoid cpu number overflow in legacy topology
Date: Mon, 14 Aug 2023 07:59:07 +0800 [thread overview]
Message-ID: <ZNluSyIAyOxYFomL@liuzhao-OptiPlex-7080> (raw)
In-Reply-To: <6aa7915c-c39d-ad5f-0171-8516868c9632@intel.com>
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 v2.
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
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) {
next prev parent reply other threads:[~2023-08-13 23:49 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 [this message]
2023-08-14 6:32 ` Wen, Qian
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=ZNluSyIAyOxYFomL@liuzhao-OptiPlex-7080 \
--to=zhao1.liu@intel.com \
--cc=babu.moger@amd.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qian.wen@intel.com \
--cc=richard.henderson@linaro.org \
--cc=xiaoyao.li@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.