qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, richard.henderson@linaro.org,
	f4bug@amsat.org, yang.zhong@intel.com
Subject: [PATCH 1/2] x86: cpu: make sure number of addressable IDs for processor cores meets the spec
Date: Tue, 24 May 2022 11:10:19 -0400	[thread overview]
Message-ID: <20220524151020.2541698-2-imammedo@redhat.com> (raw)
In-Reply-To: <20220524151020.2541698-1-imammedo@redhat.com>

Accourding Intel's CPUID[EAX=04H] resulting bits 31 - 26 in EAX
should be:
"
 **** The nearest power-of-2 integer that is not smaller than (1 + EAX[31:26]) is the number of unique
    Core_IDs reserved for addressing different processor cores in a physical package. Core ID is a subset of
    bits of the initial APIC ID.
"

ensure that values stored in EAX[31-26] always meets this condition.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target/i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 35c3475e6c..bbe37dce2e 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -5279,7 +5279,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
             /* QEMU gives out its own APIC IDs, never pass down bits 31..26.  */
             *eax &= ~0xFC000000;
             if ((*eax & 31) && cs->nr_cores > 1) {
-                *eax |= (cs->nr_cores - 1) << 26;
+                *eax |= (pow2ceil(cs->nr_cores) - 1) << 26;
             }
         } else if (cpu->vendor_cpuid_only && IS_AMD_CPU(env)) {
             *eax = *ebx = *ecx = *edx = 0;
-- 
2.31.1



  reply	other threads:[~2022-05-24 15:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-24 15:10 [PATCH 0/2] i386: fixup number of logical CPUs when host-cache-info=on Igor Mammedov
2022-05-24 15:10 ` Igor Mammedov [this message]
2022-05-24 15:10 ` [PATCH 2/2] x86: cpu: fixup number of addressable IDs for logical processors sharing cache Igor Mammedov
2022-05-24 15:19 ` [PATCH 0/2] i386: fixup number of logical CPUs when host-cache-info=on Igor Mammedov
2022-05-24 19:48   ` Moger, Babu
2022-05-24 23:23     ` Alejandro Jimenez
2022-05-25 19:56       ` Moger, Babu
2022-05-25 21:20         ` Alejandro Jimenez
2022-05-25  7:05     ` Igor Mammedov
2022-05-25 20:04       ` Moger, Babu
2022-05-31 12:44 ` Igor Mammedov
2022-06-01 10:02   ` Paolo Bonzini

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=20220524151020.2541698-2-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=yang.zhong@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).