From nobody Fri Nov 14 07:52:14 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585866178; cv=none; d=zohomail.com; s=zohoarc; b=K9CDwGMloMht+d1mdCLt+z+90of2v7Qw7p1ygB69dX7ZjKZS7RmThFlWS3x+xH//Ljzaxl+YUEgq+HaxSxSYHnTsnPjTATA4RAPJRkPRIjYNXPdC1VShMvh2Tob+xrXS6vDP52u5+WKtRK6HpMrYbrFdqLYCjVQyTJkfrrVWJYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585866178; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8eikJeiSTpVtVuqjHyYzgg7DESld7tVIUuqk7/szlPk=; b=KEaMqIT6PgzxBSCtc51JIchpC231XwjAYi3m/yfK2+FM4CeklvCl7fczh0QNJPN4/bQMhUuRXcPAs2Wd+XPUV8Sg5YEFUv1Dra2Jw7m2O8CZpLeqCd+Nl0z0KGn86A8w/SRfVTQrefHP6Jto6on1U9xAFyB1aGGNQRZvwPYpyLQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585866178921836.7737504946888; Thu, 2 Apr 2020 15:22:58 -0700 (PDT) Received: from localhost ([::1]:47870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jK8Ej-0004Af-Jw for importer@patchew.org; Thu, 02 Apr 2020 18:22:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34582) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jK8Da-0002TJ-Op for qemu-devel@nongnu.org; Thu, 02 Apr 2020 18:21:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jK8DZ-0007hU-9j for qemu-devel@nongnu.org; Thu, 02 Apr 2020 18:21:46 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:36881 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jK8DZ-0007gR-5P for qemu-devel@nongnu.org; Thu, 02 Apr 2020 18:21:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-pwCV72d8NoCUw5_XGb4rHg-1; Thu, 02 Apr 2020 18:21:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 15EB8801E67; Thu, 2 Apr 2020 22:21:27 +0000 (UTC) Received: from localhost (ovpn-116-71.gru2.redhat.com [10.97.116.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id B18B9A63B7; Thu, 2 Apr 2020 22:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585866104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8eikJeiSTpVtVuqjHyYzgg7DESld7tVIUuqk7/szlPk=; b=Mg7eOtBjrdWj4qWmSLpCVMDyYGu676YnFD7x4blE6QVvutuR7gfmt+wodG9jUkPR2CiFYT gGCYEKhrJvKwcIhHpRKpj58CcMYzN7cqy+IllCsFpnAvOTwJH2DU8om103zwymEwvPhfim o+MiXwALcueE3bc5wwkFvtEjGmOKeO8= X-MC-Unique: pwCV72d8NoCUw5_XGb4rHg-1 From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL 6/9] target/i386: Enable new apic id encoding for EPYC based cpus models Date: Thu, 2 Apr 2020 19:20:48 -0300 Message-Id: <20200402222051.523093-7-ehabkost@redhat.com> In-Reply-To: <20200402222051.523093-1-ehabkost@redhat.com> References: <20200402222051.523093-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , "Michael S . Tsirkin" , Babu Moger , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Babu Moger The APIC ID is decoded based on the sequence sockets->dies->cores->threads. This works fine for most standard AMD and other vendors' configurations, but this decoding sequence does not follow that of AMD's APIC ID enumeration strictly. In some cases this can cause CPU topology inconsistency. When booting a guest VM, the kernel tries to validate the topology, and fin= ds it inconsistent with the enumeration of EPYC cpu models. The more details a= re in the bug https://bugzilla.redhat.com/show_bug.cgi?id=3D1728166. To fix the problem we need to build the topology as per the Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors. The documentation is available from the bugzilla Link below. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 It is also available at https://www.amd.com/system/files/TechDocs/55570-B1_PUB.zip Here is the text from the PPR. Operating systems are expected to use Core::X86::Cpuid::SizeId[ApicIdSize],= the number of least significant bits in the Initial APIC ID that indicate core = ID within a processor, in constructing per-core CPUID masks. Core::X86::Cpuid::SizeId[ApicIdSize] determines the maximum number of cores (MNC) that the processor could theoretically support, not the actual number= of cores that are actually implemented or enabled on the processor, as indicat= ed by Core::X86::Cpuid::SizeId[NC]. Each Core::X86::Apic::ApicId[ApicId] register is preset as follows: =E2=80=A2 ApicId[6] =3D Socket ID. =E2=80=A2 ApicId[5:4] =3D Node ID. =E2=80=A2 ApicId[3] =3D Logical CCX L3 complex ID =E2=80=A2 ApicId[2:0]=3D (SMT) ? {LogicalCoreID[1:0],ThreadId} : {1'b0,Logi= calCoreID[1:0]} The new apic id encoding is enabled for EPYC and EPYC-Rome models. Signed-off-by: Babu Moger Acked-by: Michael S. Tsirkin Acked-by: Igor Mammedov Message-Id: <158396724913.58170.3539083528095710811.stgit@naples-babu.amd.c= om> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 50cd257a7e..468e03a153 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3925,6 +3925,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .xlevel =3D 0x8000001E, .model_id =3D "AMD EPYC Processor", .cache_info =3D &epyc_cache_info, + .use_epyc_apic_id_encoding =3D 1, .versions =3D (X86CPUVersionDefinition[]) { { .version =3D 1 }, { @@ -4052,6 +4053,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .xlevel =3D 0x8000001E, .model_id =3D "AMD EPYC-Rome Processor", .cache_info =3D &epyc_rome_cache_info, + .use_epyc_apic_id_encoding =3D 1, }, }; =20 --=20 2.24.1