From nobody Mon Nov 25 05:09:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1717403932; cv=none; d=zohomail.com; s=zohoarc; b=Xuuua2BGZqibRh4WI7YvoVZk691Kks4TWeKz4QMfJYiev2eOMuevnwr5iZh/OuTDpEqGUubUnJi4w+9YIZQXcxylVwHi0e48bbVKeXD6eJcSWxO612c7k0yrU0w9z203ufm98xT+fLvigLx/4GBkDnd2Xjrb1Jm34vdN5dZE784= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717403932; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Gm+0tUE9TGOC7pOyFlrqsIXvfB/fALxsNiDZ0Zoab5A=; b=eMQMowuSkVvMCXUU2nq9mVsth+Oqtchc2VZ6fJ6opd67HrNP5HvjNjckPco4VLUyIFmiuhimxBeCfJNTCI400T8EYECP2MjnPCr6HcDL8SvdUsVwCdsgI9urhMTW+wLFuQP6SBVQsaEnnrEZWoK/83+VHlx05esQyxQQM0c2uDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717403932018716.720696221951; Mon, 3 Jun 2024 01:38:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sE3Ci-0007SH-NG; Mon, 03 Jun 2024 04:38:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sE3Cg-0007QX-Mo for qemu-devel@nongnu.org; Mon, 03 Jun 2024 04:38:06 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sE3Ce-0001HX-2Q for qemu-devel@nongnu.org; Mon, 03 Jun 2024 04:38:06 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1f630e35a01so23014835ad.1 for ; Mon, 03 Jun 2024 01:37:59 -0700 (PDT) Received: from MacBook-Pro-2.local.bytedance.net ([203.208.167.151]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f63232dd39sm59406275ad.21.2024.06.03.01.37.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2024 01:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1717403878; x=1718008678; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Gm+0tUE9TGOC7pOyFlrqsIXvfB/fALxsNiDZ0Zoab5A=; b=YUqihhctxic98vKd86GKWJSWNzsDdohDDs29Ph3D9rjLavrtOa1we8N3W3frLHMGkm aW0Y1+xj213jsOvonNBVh60cy8wXANUFyFqGCSb+1XrzIw3emNTN63ZVZgW35TFO0SP0 054TxKwExm5sRfc8XxAy9Zdb1AYx4eXveq9P6dsEQqtNTXBFswaNtc8+4KRZIXm6lUa6 fcUT1T6Wu3NPzEGeJVhpyWo73d5bUjL/F3rBsm4y9QdxnlkF9Y+Xk8RJTfk3WilFbgZy TPBKZKwv/qnDQX8m4ZpsQxLy5BPVendmrp8fS0dS12Sx37swmCgdZo2qXGwBMGrjwi5M r/oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717403878; x=1718008678; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Gm+0tUE9TGOC7pOyFlrqsIXvfB/fALxsNiDZ0Zoab5A=; b=SARyupcOhOoFajR8F0tsMjnhPaKu8N9M7lIBAJZG0OBurLm3XWjoJULXnOzlxRAKcF Jkk+uPpLhl9JlRGtsyOSKVMfds1kl8HcEd3DEts1zbUiM/J5RTf9ANnkdSoO+OhUhrM4 Oq1YoS+cHTVLj2tgPhq/8Beul/fOJL85bpNMEnX9PgH6bo52kaFl1galIuQSgRaCc97f SuzhNshtYzuhcA9yTeTzNo8uG2QBeiMkd/oNMVF4jQ+6bG8vRJCkCkqwXsA7oJ8a4p17 WdB/2gMMqeC6xH5a0SX4BXWsviyOW09IZV86xOZC+nqtXAX8E8ttt1JJOlR76gJoNxWB +pjw== X-Gm-Message-State: AOJu0YyjhamFCAelnCFT99AqgZECN8Trz3MIf9yv/8VU2t9wunr4cKuX hqSOTIz3hIlbVAFpAlAVt2FwcG3TlFcJaBpNSgeTKBnTC1i2CGNkXxdQuOAn3+YXiYM5y5uT3CD r X-Google-Smtp-Source: AGHT+IE5pAvHxAyURR5PhJDvLzJm44GdX1kQI+I13GKtju0RORU/rx3jsEOmGa/CK7Kl5YaqKSoCwg== X-Received: by 2002:a17:902:d512:b0:1f6:782e:da40 with SMTP id d9443c01a7336-1f6782ee2f3mr28772495ad.62.1717403878306; Mon, 03 Jun 2024 01:37:58 -0700 (PDT) From: Chuang Xu To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, xieyongji@bytedance.com, imammedo@redhat.com, zhao1.liu@intel.com, qemu-stable@nongnu.org, Chuang Xu , Guixiong Wei , Yipeng Yin Subject: [PATCH v2] i386/cpu: fixup number of addressable IDs for processor cores in the physical package Date: Mon, 3 Jun 2024 16:36:41 +0800 Message-Id: <20240603083641.97241-1-xuchuangxclwt@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=xuchuangxclwt@bytedance.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_LOCAL_NOVOWEL=0.5, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bytedance.com) X-ZM-MESSAGEID: 1717403933362100008 Content-Type: text/plain; charset="utf-8" When QEMU is started with: -cpu host,host-cache-info=3Don,l3-cache=3Doff \ -smp 2,sockets=3D1,dies=3D1,cores=3D1,threads=3D2 Guest can't acquire maximum number of addressable IDs for processor cores in the physical package from CPUID[04H]. When testing Intel TDX, guest attempts to acquire extended topology from CP= UID[0bH], but because the TDX module doesn't provide the emulation of CPUID[0bH], guest will instead acquire extended topology from CPUID[04H]. However, due to QEMU's inaccurate emulation of CPUID[04H], one of the vcpus in 2c TDX guest would be offline. Fix it by removing the unnecessary condition. Fixes: d7caf13b5fcf742e5680c1d3448ba070fc811644 ("x86: cpu: fixup number of= addressable IDs for logical processors sharing cache") Signed-off-by: Guixiong Wei Signed-off-by: Yipeng Yin Signed-off-by: Chuang Xu --- target/i386/cpu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index bc2dceb647..b68f7460db 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6426,10 +6426,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, if (*eax & 31) { int host_vcpus_per_cache =3D 1 + ((*eax & 0x3FFC000) >> 14= ); =20 - if (cores_per_pkg > 1) { - *eax &=3D ~0xFC000000; - *eax |=3D max_core_ids_in_package(&topo_info) << 26; - } + *eax &=3D ~0xFC000000; + *eax |=3D max_core_ids_in_package(&topo_info) << 26; if (host_vcpus_per_cache > threads_per_pkg) { *eax &=3D ~0x3FFC000; =20 --=20 2.20.1