From patchwork Fri Sep 6 19:13:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11135909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 300C81398 for ; Fri, 6 Sep 2019 19:28:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0730C20838 for ; Fri, 6 Sep 2019 19:28:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="x8heuH+A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0730C20838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Jtv-0002ZY-8b for patchwork-qemu-devel@patchwork.kernel.org; Fri, 06 Sep 2019 15:28:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42652) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Jfi-0003hx-Hx for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:13:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6Jfh-0004XU-DT for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:13:26 -0400 Received: from mail-eopbgr710070.outbound.protection.outlook.com ([40.107.71.70]:19249 helo=NAM05-BY2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6Jfh-0004XM-6u for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:13:25 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oYDqToygJHOTObI/8SgdWdHKyC6MSDbnX6bop9ORDmLrnH/b1pu6TOdvmF5B0z2jgVFp6D0h2GZFT4FaqGGcn5CacJwxE9LOiZ6brJzX5S03gRHdfDL2c+4EokhBMrXOZOuRL++0UwlNy6mdGKwUlLk8kEEz3xBVHZM1bMKHsv57r1HdsocONv9snWOxYSKs4b5pGWQPexxsUjyOJ0TfQYvvmuP+S3ZZ8Cjmq1uEX596svkb9HNlfDGYGw4VMnG0bIkapMqfHfkD13yYxQDM16FU693vB4uJof/kv6LnXuafvNEcQJoDySzBV3LDQiAq/+08NBieUZhWGHjPJk2FOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JlCmWhuijPG2rF3zJbY0bSW/5BrsiZWaBsW8NlWgxDk=; b=eZZbaShJxCIEcPSpKclGJxYxkHSPD1r/y3GxyhAV6b2z/wkPcwkqmIQQ+ZNjLOtqmLwbLFKlu9agvH5vQMHrOzbB6PNTbnzhgflM+N2fATh8GnS+axx8K69Gbli/jq/bRHFoCYgdEySn4qP0ofTPMwh0YIP6ro5u9OimgS5MmzOH6MuxuEJcIJ8rjAowjxpu+Zmh8q81PBQ5oBo2LGA/M9Lie2NJpuO71sQ9Hf0u1+lnwA2GZ3ajipSUv4lY+DAG9YqnKxeSksszMmywdUiTvN1J+KjHrFXv69W+42urH3fxvO+n/JkrMz0+6jC8un+r20QdACFrQiduVnI6Iu8L+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JlCmWhuijPG2rF3zJbY0bSW/5BrsiZWaBsW8NlWgxDk=; b=x8heuH+Ap/oT5HY1igz1SpYuInri83pw/ViXnmx5dZlU6JnaVagRd8kTKFuZcB9oVkDUwgpVG/XAt7ll1pytVeqZVHtymIQTd9Pf3T5hbb8amTzSqUKxN4lGQOQmsfj8lri39hF2stosqX/7aBN7Tn2IMDy7vo1pZktlH+sNvFI= Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB1930.namprd12.prod.outlook.com (10.175.88.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.18; Fri, 6 Sep 2019 19:13:23 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8%3]) with mapi id 15.20.2220.022; Fri, 6 Sep 2019 19:13:22 +0000 From: "Moger, Babu" To: ssg.sos.staff , "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "eblake@redhat.com" , "armbru@redhat.com" , "imammedo@redhat.com" Thread-Topic: [RFC 2 PATCH 15/16] i386: Fix pkg_id offset for epyc mode Thread-Index: AQHVZOcmbebOiftiVUCaGUSkVpMtgg== Date: Fri, 6 Sep 2019 19:13:22 +0000 Message-ID: <156779720146.21957.9036938076017885210.stgit@localhost.localdomain> References: <156779689013.21957.1631551572950676212.stgit@localhost.localdomain> In-Reply-To: <156779689013.21957.1631551572950676212.stgit@localhost.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN4PR0601CA0020.namprd06.prod.outlook.com (2603:10b6:803:2f::30) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 56c4b1fe-1041-4e74-2a9f-08d732fe493b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB1930; x-ms-traffictypediagnostic: DM5PR12MB1930: x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:439; x-forefront-prvs: 0152EBA40F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(189003)(199004)(3846002)(14444005)(99286004)(8936002)(256004)(7736002)(71200400001)(71190400001)(6116002)(66446008)(66476007)(14454004)(64756008)(66556008)(66946007)(53936002)(2501003)(8676002)(478600001)(6506007)(386003)(9686003)(5660300002)(486006)(446003)(6486002)(26005)(110136005)(2906002)(6512007)(103116003)(316002)(476003)(11346002)(6436002)(186003)(102836004)(81156014)(76176011)(66066001)(81166006)(25786009)(52116002)(4326008)(86362001)(305945005)(2201001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1930; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: XX3W+epJzeSzFIZqPNwN2Vm5N0+PuNFSlfK5QUIlPX2J3UMjRBD5xYDY/BEebGKPnXZxdrkf3EioaanjXsPGhaOHw49pYf54640Lp9hLseSdhVhYq39H5ZljZPZ/5hiWKKhXHautA+UD6J94j5K6YQRaoGcqFrmYkuLXCWrpJtUuVxAq19JOYNOCyrlwii+HZy/+Ao32PrqME/SkWhpTfM4gEflQNlx9sAtOuPGNBXMnJhYgSg2+e2iVSDU/zjaVW0QB1q5zGlBjze9csk6LcnAeb5vgLXjoxlQ9DUJtiTgk6t6rhz1mthmcc1BNO4FrbBubzFjeubbsJoQ8fDHcebDH9k2mJNk9c/htUHvm0pOfcFH+qVhhBaDC/90jJz0PALRgxs97EQlFIyjQJEsU7VghZmmtMMYqKdfCdB7rNBM= Content-ID: <751AC802B34CAE449F8922185A98C7FF@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56c4b1fe-1041-4e74-2a9f-08d732fe493b X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2019 19:13:22.8690 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jUlccFwgLfO13YmOfIGzuRT9/2UvRPrRVpYBP0hhPg5BuZP7ZMWGWqwWowmmqt6k X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1930 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.71.70 Subject: [Qemu-devel] [RFC 2 PATCH 15/16] i386: Fix pkg_id offset for epyc mode 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: "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Babu Moger --- target/i386/cpu.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f25491a029..f8b1fc5c07 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4094,9 +4094,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { + MachineState *ms = MACHINE(qdev_get_machine()); X86CPU *cpu = env_archcpu(env); CPUState *cs = env_cpu(env); - uint32_t die_offset; + uint32_t die_offset, pkg_offset; uint32_t limit; uint32_t signature[3]; @@ -4119,6 +4120,21 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, index = env->cpuid_level; } + if (ms->epyc) { + X86CPUTopoInfo topo_info = { + .numa_nodes = nb_numa_nodes, + .nr_sockets = ms->smp.sockets, + .nr_cores = ms->smp.cores, + .nr_threads = ms->smp.threads, + }; + unsigned nodes = nodes_in_pkg(&topo_info); + pkg_offset = apicid_pkg_offset_epyc(nodes, MAX_CCX, MAX_CORES_IN_CCX, + cs->nr_threads); + } else { + pkg_offset = apicid_pkg_offset(env->nr_dies, cs->nr_cores, + cs->nr_threads); + } + switch(index) { case 0: *eax = env->cpuid_level; @@ -4275,8 +4291,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx |= CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax = apicid_pkg_offset(env->nr_dies, - cs->nr_cores, cs->nr_threads); + *eax = pkg_offset; *ebx = cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break; @@ -4310,8 +4325,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break; case 2: - *eax = apicid_pkg_offset(env->nr_dies, cs->nr_cores, - cs->nr_threads); + *eax = pkg_offset; *ebx = env->nr_dies * cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_DIE; break;