From patchwork Tue Mar 3 19:56:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418719 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 66C4C1395 for ; Tue, 3 Mar 2020 19:58:11 +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 2D96C2073B for ; Tue, 3 Mar 2020 19:58:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="dDud1/bV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D96C2073B 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]:53020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DgA-0001lt-43 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 14:58:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38128) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Df9-000830-75 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9Df6-0002u0-B9 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:07 -0500 Received: from mail-mw2nam12on2045.outbound.protection.outlook.com ([40.107.244.45]:25633 helo=NAM12-MW2-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 1j9Df6-0002tj-13 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VAR32lR+bsfMF7Ew4cpX9fvw6vLyhahtcKSVEobb8nhhHQTlnODzmPkiRGXcRK/mtiOGrUQJKehdGwKD2QhhRvx7DbQtHNN4Jcw4dvEXm92eD05D8bEHciybddKmpZsowYXSlbgPqQKAdbEKiICO+RyOiyuRu0cPnSAdgqr8/Q2XNyOVA2d6g2IdtcctRyoW/N8NQDP9ygjzVnwNCPbHBzy8Nzx42F58XVfaIspQ4AVUkPgr8dcQ9liGBWPsy+H/UHpslnzeQ06vo5YjocKzgmaTpACXFmCbQxs2ykbCqRh5ghCna7SXHoWHYcyA8dTu4ax1lChZ2ncDskh70Ocm0Q== 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=VxKAxNxgzF3wHaoeHlASpyHZB/3aHfo5uditPKr51uk=; b=D849TgqMZVDP/DChGmWLoInzUG3v8T1W1o5O+zfb0JuOAeZbttKP2sKNI+zb7U1oufO8Z0Mku+Ajos+R4BVPm30Ol5+FCEr0vz9SLtMk4bewDjVOtGpAD0dZi10eSG3JZ3RlJ568EMtqROomsfudRIwj+iQ/7XdqsQQBq4gg6lzL86TrEvDvfD0x8AE1w9vgtdoNHjbpfD6L4XgPygO/5YLHr5Qi8TmqVsa8b3+K7IKlDvTWzOSDKC2mdRSdlSVmHkeQkSMQYBV6aBm2WW5vC0jrbhWvzu/4693ix5gWVaw/PLd33wfeWDhS+FX7F+w3mQKxX/TR5u27pUdZ6rcSlg== 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=VxKAxNxgzF3wHaoeHlASpyHZB/3aHfo5uditPKr51uk=; b=dDud1/bVI0x6V5I/XfBuk2hcwfvtAtO/Nn24D/uW2MkNfrzLYt+yCjzNXtx161x/HL9R+RNxDSvyBp30efMTc5fV5QVe7zKsWXg8m3Z5jJssqM1x6MaZ8YLUWaqT70EqCv4yOi5G06jzxmQhNgf2bQZhpybNTvsN1wIcA7jUsr4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2382.namprd12.prod.outlook.com (2603:10b6:802:2e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:00 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:00 +0000 Subject: [PATCH v5 01/16] hw/i386: Rename X86CPUTopoInfo structure to X86CPUTopoIDs From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:56:58 -0600 Message-ID: <158326541877.40452.17535023236841538507.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM6PR08CA0045.namprd08.prod.outlook.com (2603:10b6:5:1e0::19) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by DM6PR08CA0045.namprd08.prod.outlook.com (2603:10b6:5:1e0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18 via Frontend Transport; Tue, 3 Mar 2020 19:56:59 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5620e198-76f2-41d0-8a31-08d7bfad0952 X-MS-TrafficTypeDiagnostic: SN1PR12MB2382:|SN1PR12MB2382: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(396003)(346002)(376002)(39860400002)(189003)(199004)(186003)(8676002)(8936002)(81166006)(81156014)(26005)(16526019)(5660300002)(478600001)(86362001)(52116002)(7696005)(956004)(316002)(2906002)(66946007)(66476007)(44832011)(66556008)(55016002)(4326008)(103116003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2382; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: 3GBAXM5J/R912Bkp0yYX7+unMOV5czcXAc4HxAevekS3NCGpiFhENK6oHQ09HJZL5jG6d+vcOIieZQsD1Y20McMSvWQaDTMpkkmCtkielPsBxTO7xtZs3Fxk+RezWJWqMYLAlljRMM1o6OrqtUiKxAGmgca9ZhDXHkz6meLPCf/Iqep87AEXSgMlr5gvMvnCDO9elx9MFCG7vkPki5Vpdss4l4VJV4lfOQSGa8fyq3eX9YX/4ypTfTjEzqagOMlzbTAAUVLtKJpnSZP858F8RSgqmZDiAoiMpIMpYC+Z94ly43Gl7H1r0a2mH84+UEaKTOmdOyO3KCsOaAYQIElbTUxx+QskwXfDlQHy0aElyFdd21+xY2431V3F8vZ8psNG8uO90Ul/VrSy2TSv1rxHBS9n3ICl+48rcIKaS8mFKvsnIrrg6eZ7q/95bO2DxDIG X-MS-Exchange-AntiSpam-MessageData: 1vVrURFGqXepC3kDuc2bvD096jvZ5ixzq9c/cf/Ws+vmyRO3C/G4JcfWlNYBZbnIFeOIUSi3sKYZdFn+y0JQPMYmbS7Ti47NeQ4K9p3DaxKD4dqmayqLfxLNvLhOyt4eFkdsSuNXwRrK6dcNqaUQdA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5620e198-76f2-41d0-8a31-08d7bfad0952 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:00.4605 (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: KVr79lu/XN3vmM1AKJ61V8cia8otdZozxC4I6s7mqwl0xVZJaZCTvkbSGLpvnKa5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2382 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.244.45 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" Rename few data structures related to X86 topology. X86CPUTopoIDs will have individual arch ids. Next patch introduces X86CPUTopoInfo which will have all topology information(like cores, threads etc..). Signed-off-by: Babu Moger Reviewed-by: Eduardo Habkost --- hw/i386/pc.c | 45 +++++++++++++++++++++++--------------------- hw/i386/x86.c | 18 +++++++++--------- include/hw/i386/topology.h | 44 +++++++++++++++++++++++-------------------- 3 files changed, 57 insertions(+), 50 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2ddce4230a..715f79f58c 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1506,7 +1506,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, int idx; CPUState *cs; CPUArchId *cpu_slot; - X86CPUTopoInfo topo; + X86CPUTopoIDs topo_ids; X86CPU *cpu = X86_CPU(dev); CPUX86State *env = &cpu->env; MachineState *ms = MACHINE(hotplug_dev); @@ -1572,12 +1572,12 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, return; } - topo.pkg_id = cpu->socket_id; - topo.die_id = cpu->die_id; - topo.core_id = cpu->core_id; - topo.smt_id = cpu->thread_id; + topo_ids.pkg_id = cpu->socket_id; + topo_ids.die_id = cpu->die_id; + topo_ids.core_id = cpu->core_id; + topo_ids.smt_id = cpu->thread_id; cpu->apic_id = apicid_from_topo_ids(x86ms->smp_dies, smp_cores, - smp_threads, &topo); + smp_threads, &topo_ids); } cpu_slot = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); @@ -1585,11 +1585,11 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, MachineState *ms = MACHINE(pcms); x86_topo_ids_from_apicid(cpu->apic_id, x86ms->smp_dies, - smp_cores, smp_threads, &topo); + smp_cores, smp_threads, &topo_ids); error_setg(errp, "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" " APIC ID %" PRIu32 ", valid index range 0:%d", - topo.pkg_id, topo.die_id, topo.core_id, topo.smt_id, + topo_ids.pkg_id, topo_ids.die_id, topo_ids.core_id, topo_ids.smt_id, cpu->apic_id, ms->possible_cpus->len - 1); return; } @@ -1607,34 +1607,37 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, * once -smp refactoring is complete and there will be CPU private * CPUState::nr_cores and CPUState::nr_threads fields instead of globals */ x86_topo_ids_from_apicid(cpu->apic_id, x86ms->smp_dies, - smp_cores, smp_threads, &topo); - if (cpu->socket_id != -1 && cpu->socket_id != topo.pkg_id) { + smp_cores, smp_threads, &topo_ids); + if (cpu->socket_id != -1 && cpu->socket_id != topo_ids.pkg_id) { error_setg(errp, "property socket-id: %u doesn't match set apic-id:" - " 0x%x (socket-id: %u)", cpu->socket_id, cpu->apic_id, topo.pkg_id); + " 0x%x (socket-id: %u)", cpu->socket_id, cpu->apic_id, + topo_ids.pkg_id); return; } - cpu->socket_id = topo.pkg_id; + cpu->socket_id = topo_ids.pkg_id; - if (cpu->die_id != -1 && cpu->die_id != topo.die_id) { + if (cpu->die_id != -1 && cpu->die_id != topo_ids.die_id) { error_setg(errp, "property die-id: %u doesn't match set apic-id:" - " 0x%x (die-id: %u)", cpu->die_id, cpu->apic_id, topo.die_id); + " 0x%x (die-id: %u)", cpu->die_id, cpu->apic_id, topo_ids.die_id); return; } - cpu->die_id = topo.die_id; + cpu->die_id = topo_ids.die_id; - if (cpu->core_id != -1 && cpu->core_id != topo.core_id) { + if (cpu->core_id != -1 && cpu->core_id != topo_ids.core_id) { error_setg(errp, "property core-id: %u doesn't match set apic-id:" - " 0x%x (core-id: %u)", cpu->core_id, cpu->apic_id, topo.core_id); + " 0x%x (core-id: %u)", cpu->core_id, cpu->apic_id, + topo_ids.core_id); return; } - cpu->core_id = topo.core_id; + cpu->core_id = topo_ids.core_id; - if (cpu->thread_id != -1 && cpu->thread_id != topo.smt_id) { + if (cpu->thread_id != -1 && cpu->thread_id != topo_ids.smt_id) { error_setg(errp, "property thread-id: %u doesn't match set apic-id:" - " 0x%x (thread-id: %u)", cpu->thread_id, cpu->apic_id, topo.smt_id); + " 0x%x (thread-id: %u)", cpu->thread_id, cpu->apic_id, + topo_ids.smt_id); return; } - cpu->thread_id = topo.smt_id; + cpu->thread_id = topo_ids.smt_id; if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VPINDEX) && !kvm_hv_vpindex_settable()) { diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 7f38e6ba8b..322fb6abbc 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -143,14 +143,14 @@ x86_cpu_index_to_props(MachineState *ms, unsigned cpu_index) int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) { - X86CPUTopoInfo topo; + X86CPUTopoIDs topo_ids; X86MachineState *x86ms = X86_MACHINE(ms); assert(idx < ms->possible_cpus->len); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, x86ms->smp_dies, ms->smp.cores, - ms->smp.threads, &topo); - return topo.pkg_id % ms->numa_state->num_nodes; + ms->smp.threads, &topo_ids); + return topo_ids.pkg_id % ms->numa_state->num_nodes; } const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) @@ -172,7 +172,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len = max_cpus; for (i = 0; i < ms->possible_cpus->len; i++) { - X86CPUTopoInfo topo; + X86CPUTopoIDs topo_ids; ms->possible_cpus->cpus[i].type = ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count = 1; @@ -180,17 +180,17 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) x86_cpu_apic_id_from_index(x86ms, i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, x86ms->smp_dies, ms->smp.cores, - ms->smp.threads, &topo); + ms->smp.threads, &topo_ids); ms->possible_cpus->cpus[i].props.has_socket_id = true; - ms->possible_cpus->cpus[i].props.socket_id = topo.pkg_id; + ms->possible_cpus->cpus[i].props.socket_id = topo_ids.pkg_id; if (x86ms->smp_dies > 1) { ms->possible_cpus->cpus[i].props.has_die_id = true; - ms->possible_cpus->cpus[i].props.die_id = topo.die_id; + ms->possible_cpus->cpus[i].props.die_id = topo_ids.die_id; } ms->possible_cpus->cpus[i].props.has_core_id = true; - ms->possible_cpus->cpus[i].props.core_id = topo.core_id; + ms->possible_cpus->cpus[i].props.core_id = topo_ids.core_id; ms->possible_cpus->cpus[i].props.has_thread_id = true; - ms->possible_cpus->cpus[i].props.thread_id = topo.smt_id; + ms->possible_cpus->cpus[i].props.thread_id = topo_ids.smt_id; } return ms->possible_cpus; } diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 4ff5b2da6c..52def68610 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -45,12 +45,12 @@ */ typedef uint32_t apic_id_t; -typedef struct X86CPUTopoInfo { +typedef struct X86CPUTopoIDs { unsigned pkg_id; unsigned die_id; unsigned core_id; unsigned smt_id; -} X86CPUTopoInfo; +} X86CPUTopoIDs; /* Return the bit width needed for 'count' IDs */ @@ -122,12 +122,15 @@ static inline unsigned apicid_pkg_offset(unsigned nr_dies, static inline apic_id_t apicid_from_topo_ids(unsigned nr_dies, unsigned nr_cores, unsigned nr_threads, - const X86CPUTopoInfo *topo) + const X86CPUTopoIDs *topo_ids) { - return (topo->pkg_id << apicid_pkg_offset(nr_dies, nr_cores, nr_threads)) | - (topo->die_id << apicid_die_offset(nr_dies, nr_cores, nr_threads)) | - (topo->core_id << apicid_core_offset(nr_dies, nr_cores, nr_threads)) | - topo->smt_id; + return (topo_ids->pkg_id << + apicid_pkg_offset(nr_dies, nr_cores, nr_threads)) | + (topo_ids->die_id << + apicid_die_offset(nr_dies, nr_cores, nr_threads)) | + (topo_ids->core_id << + apicid_core_offset(nr_dies, nr_cores, nr_threads)) | + topo_ids->smt_id; } /* Calculate thread/core/package IDs for a specific topology, @@ -137,12 +140,12 @@ static inline void x86_topo_ids_from_idx(unsigned nr_dies, unsigned nr_cores, unsigned nr_threads, unsigned cpu_index, - X86CPUTopoInfo *topo) + X86CPUTopoIDs *topo_ids) { - topo->pkg_id = cpu_index / (nr_dies * nr_cores * nr_threads); - topo->die_id = cpu_index / (nr_cores * nr_threads) % nr_dies; - topo->core_id = cpu_index / nr_threads % nr_cores; - topo->smt_id = cpu_index % nr_threads; + topo_ids->pkg_id = cpu_index / (nr_dies * nr_cores * nr_threads); + topo_ids->die_id = cpu_index / (nr_cores * nr_threads) % nr_dies; + topo_ids->core_id = cpu_index / nr_threads % nr_cores; + topo_ids->smt_id = cpu_index % nr_threads; } /* Calculate thread/core/package IDs for a specific topology, @@ -152,17 +155,18 @@ static inline void x86_topo_ids_from_apicid(apic_id_t apicid, unsigned nr_dies, unsigned nr_cores, unsigned nr_threads, - X86CPUTopoInfo *topo) + X86CPUTopoIDs *topo_ids) { - topo->smt_id = apicid & + topo_ids->smt_id = apicid & ~(0xFFFFFFFFUL << apicid_smt_width(nr_dies, nr_cores, nr_threads)); - topo->core_id = + topo_ids->core_id = (apicid >> apicid_core_offset(nr_dies, nr_cores, nr_threads)) & ~(0xFFFFFFFFUL << apicid_core_width(nr_dies, nr_cores, nr_threads)); - topo->die_id = + topo_ids->die_id = (apicid >> apicid_die_offset(nr_dies, nr_cores, nr_threads)) & ~(0xFFFFFFFFUL << apicid_die_width(nr_dies, nr_cores, nr_threads)); - topo->pkg_id = apicid >> apicid_pkg_offset(nr_dies, nr_cores, nr_threads); + topo_ids->pkg_id = + apicid >> apicid_pkg_offset(nr_dies, nr_cores, nr_threads); } /* Make APIC ID for the CPU 'cpu_index' @@ -174,9 +178,9 @@ static inline apic_id_t x86_apicid_from_cpu_idx(unsigned nr_dies, unsigned nr_threads, unsigned cpu_index) { - X86CPUTopoInfo topo; - x86_topo_ids_from_idx(nr_dies, nr_cores, nr_threads, cpu_index, &topo); - return apicid_from_topo_ids(nr_dies, nr_cores, nr_threads, &topo); + X86CPUTopoIDs topo_ids; + x86_topo_ids_from_idx(nr_dies, nr_cores, nr_threads, cpu_index, &topo_ids); + return apicid_from_topo_ids(nr_dies, nr_cores, nr_threads, &topo_ids); } #endif /* HW_I386_TOPOLOGY_H */ From patchwork Tue Mar 3 19:57:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418727 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 C82AE1395 for ; Tue, 3 Mar 2020 20:00:00 +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 8E7F62073B for ; Tue, 3 Mar 2020 20:00:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="h7V8mocw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E7F62073B 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]:53054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dhv-0005Fn-P2 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 14:59:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38168) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DfE-00088v-0z for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9DfC-0002vB-8N for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:11 -0500 Received: from mail-mw2nam12on2084.outbound.protection.outlook.com ([40.107.244.84]:6034 helo=NAM12-MW2-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 1j9DfB-0002uc-KL for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hqvn2Mj7tWVnd2jZ2ahJh3k/kVCY87nsgS8Z4+yccg3U3cqlTw0lsh19RAnf9owaflSCrjY7rpxNgXFzOCbUc2tAdyxTJd3467i5tfw9tjZ28jLmhHxqlxF8JAXUQhRao5iXsk1iIfO3mFiWciFD2BIBdTP3vh0xB229JD3DIiyWvV1KPYF6K/Zu29HtYkkEZsEvwpVEq6wEQY6gC+Rx5j/YYYp+bnorzEJT29ZX5uthJ913NqeREEkzB4HTQncECx3HaBGHZeL19EgJNIU0uiZBrovmGeGRx2yHTd5GKPKslSvpsRLiQqQs/w/cR6ihIMZr4was6ppjoWwNpPM2iw== 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=5afSzfhXe+Q0IL8ZUhihzM/CWBnrbHmzSyboKS1nVJY=; b=Jc1A+tSmZDQMqByCTH7CHDCE1vQ5Y7xl3SP5mlZT68MKyTj44BERNKo9YT9+4dExWHOfJsqLvW+2FAVl64WBoIDt6A2wBo0kgTjsk3ewL6bD1pv6MGjBfc6bs0JKXWgtU826iLx8zuf2Sjn98N7nb0+oE5X0K3o4naK1ekdJP2dx2apJtxff2YM4MR38H/vyXHlKMkbyI+3m0I79rdbsKzigTu1tdWdmOY4qAr/QCksm68JC8Rj20Jm/L1HRn2OCtI2sMH7ucbnIb3xrVQJ3x8Y9Psbh7YR8YAkihElgRcSEECzEkYEi+8uAdruCrtowcfZvaj/Zx1ETlQ8nJ+VHVg== 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=5afSzfhXe+Q0IL8ZUhihzM/CWBnrbHmzSyboKS1nVJY=; b=h7V8mocw/0cgvEuL6NRE0Aqnq4rryzzhJeDNVQ5+R0RJtX4gUccTUfh5FoCFwZaNJO2DyUMhLAV14zaKo1VKThPX/BlRrd2ox6PH8a/UyZ2pga4jepleYMmUO6CGnTA/2sm+YrpCrGGSya0cc04/A641OjbJvCxtIEbJfQmx2YM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2382.namprd12.prod.outlook.com (2603:10b6:802:2e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:06 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:06 +0000 Subject: [PATCH v5 02/16] hw/i386: Introduce X86CPUTopoInfo to contain topology info From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:57:05 -0600 Message-ID: <158326542572.40452.15331466265190906874.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN1PR12CA0084.namprd12.prod.outlook.com (2603:10b6:802:21::19) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN1PR12CA0084.namprd12.prod.outlook.com (2603:10b6:802:21::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.19 via Frontend Transport; Tue, 3 Mar 2020 19:57:06 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9d8c6974-6e0b-4af5-f26c-08d7bfad0d14 X-MS-TrafficTypeDiagnostic: SN1PR12MB2382:|SN1PR12MB2382: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(396003)(346002)(376002)(39860400002)(189003)(199004)(186003)(8676002)(8936002)(81166006)(81156014)(26005)(16526019)(5660300002)(478600001)(86362001)(52116002)(7696005)(956004)(316002)(2906002)(66946007)(66476007)(44832011)(66556008)(55016002)(4326008)(103116003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2382; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: 6eINom45hl9TIV8lAB60nCs6o19UzZg+BHXBvv7iX1eTLXntE60YdwGyavUTeZCM0bdyy3Wv83Gy9pE47hae2h7wVPGucC4CSaREdXX4Hda8tSGUSSAWyQ/2YeU7XHuJ4CY1aNhO8qOuln2OrFBF2laf7SLMAunldurOGeP4F5hU3VCvl0+Jw8JGcn0RaMVuFdHIrE7/Uasu2dtx11wIB7NViy//r74V6LpwpBLu+dqHwjcqq33So/pp/vjgEwwHniIG7O8N0e+n15w39I0mY1+6mzkh4YI2R4tt38vjSbnh3/9mWXd5VzfzEs/baCVCMrayql4/z1xN6Lny3YSzdriwMzOhgS5h8Z3HuQs2zuENKioMJVqVzIeAfLjZRlkI/AqSLqX0ANMG4xCkL/wkZRgHE/cUtt4jm7ugIj6YnlsTYNh9tU4MDWyErbUmceL2 X-MS-Exchange-AntiSpam-MessageData: ZFG2czGoWObRG879hDqaubwwCvOK1yYt7rh2w+CrS+iwXsNjEaI/ZJTPLbYUSqsoGEExEZKhScbP0CQQzcLU89ePesEcwq3nADA/EZXGvn3yQwxJ314SkNj29uK169dNbVNj1ZE3XTJjTs/tRaeoNA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d8c6974-6e0b-4af5-f26c-08d7bfad0d14 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:06.7427 (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: mDuDK+dToFTUoek5oHBDCoO1X4FsISwpAtmScefuwerxcAD24KqOB8F1LRAvTJft X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2382 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.244.84 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" This is an effort to re-arrange few data structure for better readability. 1. Add X86CPUTopoInfo which will have all the topology informations required to build the cpu topology. There is no functional changes. 2. Introduce init_topo_info to initialize X86CPUTopoInfo members from X86MachineState. There is no functional changes. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 12 ++++++------ hw/i386/x86.c | 32 ++++++++++++++++++++++++-------- include/hw/i386/topology.h | 38 ++++++++++++++++++++++++-------------- include/hw/i386/x86.h | 3 +++ 4 files changed, 57 insertions(+), 28 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 715f79f58c..ef23ae2af5 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1514,6 +1514,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, X86MachineState *x86ms = X86_MACHINE(pcms); unsigned int smp_cores = ms->smp.cores; unsigned int smp_threads = ms->smp.threads; + X86CPUTopoInfo topo_info; if(!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) { error_setg(errp, "Invalid CPU type, expected cpu type: '%s'", @@ -1521,6 +1522,8 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, return; } + init_topo_info(&topo_info, x86ms); + env->nr_dies = x86ms->smp_dies; /* @@ -1576,16 +1579,14 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, topo_ids.die_id = cpu->die_id; topo_ids.core_id = cpu->core_id; topo_ids.smt_id = cpu->thread_id; - cpu->apic_id = apicid_from_topo_ids(x86ms->smp_dies, smp_cores, - smp_threads, &topo_ids); + cpu->apic_id = apicid_from_topo_ids(&topo_info, &topo_ids); } cpu_slot = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); if (!cpu_slot) { MachineState *ms = MACHINE(pcms); - x86_topo_ids_from_apicid(cpu->apic_id, x86ms->smp_dies, - smp_cores, smp_threads, &topo_ids); + x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); error_setg(errp, "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" " APIC ID %" PRIu32 ", valid index range 0:%d", @@ -1606,8 +1607,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizefn() * once -smp refactoring is complete and there will be CPU private * CPUState::nr_cores and CPUState::nr_threads fields instead of globals */ - x86_topo_ids_from_apicid(cpu->apic_id, x86ms->smp_dies, - smp_cores, smp_threads, &topo_ids); + x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); if (cpu->socket_id != -1 && cpu->socket_id != topo_ids.pkg_id) { error_setg(errp, "property socket-id: %u doesn't match set apic-id:" " 0x%x (socket-id: %u)", cpu->socket_id, cpu->apic_id, diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 322fb6abbc..03b8962c98 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -57,6 +57,16 @@ /* Physical Address of PVH entry point read from kernel ELF NOTE */ static size_t pvh_start_addr; +inline void init_topo_info(X86CPUTopoInfo *topo_info, + const X86MachineState *x86ms) +{ + MachineState *ms = MACHINE(x86ms); + + topo_info->dies_per_pkg = x86ms->smp_dies; + topo_info->cores_per_die = ms->smp.cores; + topo_info->threads_per_core = ms->smp.threads; +} + /* * Calculates initial APIC ID for a specific CPU index * @@ -68,13 +78,14 @@ static size_t pvh_start_addr; uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms, unsigned int cpu_index) { - MachineState *ms = MACHINE(x86ms); X86MachineClass *x86mc = X86_MACHINE_GET_CLASS(x86ms); + X86CPUTopoInfo topo_info; uint32_t correct_id; static bool warned; - correct_id = x86_apicid_from_cpu_idx(x86ms->smp_dies, ms->smp.cores, - ms->smp.threads, cpu_index); + init_topo_info(&topo_info, x86ms); + + correct_id = x86_apicid_from_cpu_idx(&topo_info, cpu_index); if (x86mc->compat_apic_id_mode) { if (cpu_index != correct_id && !warned && !qtest_enabled()) { error_report("APIC IDs set in compatibility mode, " @@ -145,19 +156,22 @@ int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) { X86CPUTopoIDs topo_ids; X86MachineState *x86ms = X86_MACHINE(ms); + X86CPUTopoInfo topo_info; + + init_topo_info(&topo_info, x86ms); assert(idx < ms->possible_cpus->len); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, - x86ms->smp_dies, ms->smp.cores, - ms->smp.threads, &topo_ids); + &topo_info, &topo_ids); return topo_ids.pkg_id % ms->numa_state->num_nodes; } const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) { X86MachineState *x86ms = X86_MACHINE(ms); - int i; unsigned int max_cpus = ms->smp.max_cpus; + X86CPUTopoInfo topo_info; + int i; if (ms->possible_cpus) { /* @@ -171,6 +185,9 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) + sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len = max_cpus; + + init_topo_info(&topo_info, x86ms); + for (i = 0; i < ms->possible_cpus->len; i++) { X86CPUTopoIDs topo_ids; @@ -179,8 +196,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) ms->possible_cpus->cpus[i].arch_id = x86_cpu_apic_id_from_index(x86ms, i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, - x86ms->smp_dies, ms->smp.cores, - ms->smp.threads, &topo_ids); + &topo_info, &topo_ids); ms->possible_cpus->cpus[i].props.has_socket_id = true; ms->possible_cpus->cpus[i].props.socket_id = topo_ids.pkg_id; if (x86ms->smp_dies > 1) { diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 52def68610..7ea507f376 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -52,6 +52,12 @@ typedef struct X86CPUTopoIDs { unsigned smt_id; } X86CPUTopoIDs; +typedef struct X86CPUTopoInfo { + unsigned dies_per_pkg; + unsigned cores_per_die; + unsigned threads_per_core; +} X86CPUTopoInfo; + /* Return the bit width needed for 'count' IDs */ static unsigned apicid_bitwidth_for_count(unsigned count) @@ -119,11 +125,13 @@ static inline unsigned apicid_pkg_offset(unsigned nr_dies, * * The caller must make sure core_id < nr_cores and smt_id < nr_threads. */ -static inline apic_id_t apicid_from_topo_ids(unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads, +static inline apic_id_t apicid_from_topo_ids(X86CPUTopoInfo *topo_info, const X86CPUTopoIDs *topo_ids) { + unsigned nr_dies = topo_info->dies_per_pkg; + unsigned nr_cores = topo_info->cores_per_die; + unsigned nr_threads = topo_info->threads_per_core; + return (topo_ids->pkg_id << apicid_pkg_offset(nr_dies, nr_cores, nr_threads)) | (topo_ids->die_id << @@ -136,12 +144,14 @@ static inline apic_id_t apicid_from_topo_ids(unsigned nr_dies, /* Calculate thread/core/package IDs for a specific topology, * based on (contiguous) CPU index */ -static inline void x86_topo_ids_from_idx(unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads, +static inline void x86_topo_ids_from_idx(X86CPUTopoInfo *topo_info, unsigned cpu_index, X86CPUTopoIDs *topo_ids) { + unsigned nr_dies = topo_info->dies_per_pkg; + unsigned nr_cores = topo_info->cores_per_die; + unsigned nr_threads = topo_info->threads_per_core; + topo_ids->pkg_id = cpu_index / (nr_dies * nr_cores * nr_threads); topo_ids->die_id = cpu_index / (nr_cores * nr_threads) % nr_dies; topo_ids->core_id = cpu_index / nr_threads % nr_cores; @@ -152,11 +162,13 @@ static inline void x86_topo_ids_from_idx(unsigned nr_dies, * based on APIC ID */ static inline void x86_topo_ids_from_apicid(apic_id_t apicid, - unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads, + X86CPUTopoInfo *topo_info, X86CPUTopoIDs *topo_ids) { + unsigned nr_dies = topo_info->dies_per_pkg; + unsigned nr_cores = topo_info->cores_per_die; + unsigned nr_threads = topo_info->threads_per_core; + topo_ids->smt_id = apicid & ~(0xFFFFFFFFUL << apicid_smt_width(nr_dies, nr_cores, nr_threads)); topo_ids->core_id = @@ -173,14 +185,12 @@ static inline void x86_topo_ids_from_apicid(apic_id_t apicid, * * 'cpu_index' is a sequential, contiguous ID for the CPU. */ -static inline apic_id_t x86_apicid_from_cpu_idx(unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads, +static inline apic_id_t x86_apicid_from_cpu_idx(X86CPUTopoInfo *topo_info, unsigned cpu_index) { X86CPUTopoIDs topo_ids; - x86_topo_ids_from_idx(nr_dies, nr_cores, nr_threads, cpu_index, &topo_ids); - return apicid_from_topo_ids(nr_dies, nr_cores, nr_threads, &topo_ids); + x86_topo_ids_from_idx(topo_info, cpu_index, &topo_ids); + return apicid_from_topo_ids(topo_info, &topo_ids); } #endif /* HW_I386_TOPOLOGY_H */ diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 41fe37b8a3..22babcb3bb 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -21,6 +21,7 @@ #include "exec/hwaddr.h" #include "qemu/notify.h" +#include "hw/i386/topology.h" #include "hw/boards.h" #include "hw/nmi.h" #include "hw/isa/isa.h" @@ -82,6 +83,8 @@ typedef struct { #define X86_MACHINE_CLASS(class) \ OBJECT_CLASS_CHECK(X86MachineClass, class, TYPE_X86_MACHINE) +void init_topo_info(X86CPUTopoInfo *topo_info, const X86MachineState *x86ms); + uint32_t x86_cpu_apic_id_from_index(X86MachineState *pcms, unsigned int cpu_index); From patchwork Tue Mar 3 19:57:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418721 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 CD56C14B4 for ; Tue, 3 Mar 2020 19:58:24 +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 92E282073B for ; Tue, 3 Mar 2020 19:58:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="yRuWQA8I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92E282073B 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]:53024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DgN-0002Ba-OH for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 14:58:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38210) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DfI-0008E3-KV for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9DfH-0002wj-1m for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:16 -0500 Received: from mail-eopbgr680046.outbound.protection.outlook.com ([40.107.68.46]:6446 helo=NAM04-BN3-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 1j9DfG-0002wQ-SG for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A0dQKXHq8e80lDmt0xVNnpMavfWS3ySb/TQ2g8T0dUUs65X0y9W0otwdvdcaF7kDyWYA/qqhc0SeMoZtSBA2F7vsT6RK6ZSSDQ3PTx1I3032T9G8SL6TLBsOZvr3ej/2e+8/18vlBIgV66fsUwLrV0JHCygven9IWsUok9/Aht0e8S9tjqAQcYWPdCRU0oialErGFHShEMm58+20wgRnDMuehHqV2DxUbZ26LwLXxCPrXQZM0Monh8owTk9NsdZdeVmDW8nmiwQdz7ELbbpoCxndhoppOyIG6KAtmfakGj1olJJdGNHjtfAjO/2FPuHlJjK+m6RQT2YLAKpy2F8D/Q== 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=cd27KtSeSVoX2w30gqahJo34DlLFxc/0r5KcA6+kKVU=; b=lpq8HHqsonkFJRS/n++GrQSyZtHI6ESoTmW7Khnq/vDywho+53m39L0RJSiK82EokKii87Q1QSpNRIDxtKFkTwymOnXEL1HnxdFzl2iIE0Rmj7dEWEQFW7bJAMKpOAajHpXuoSOQdJLSMDF8FDt+JyYSMcnPZuOyF/sz3lI+wjKffGgo2VvpWgdQ/TxdES95VabAkfv2QEM6PH/0CRPAxJBM2M1TNVkR19reABjUVLVo/vFEPIFvbCWSorSrY/ISFlkbhfA4WsVEspcVXn6uY1zu/Lcu74080SAjO1PkEg7KwXqrz6rY7BJb1lTXFoCXFAlei6BKOo64RpFt/dyaqQ== 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=cd27KtSeSVoX2w30gqahJo34DlLFxc/0r5KcA6+kKVU=; b=yRuWQA8IYFm+/7DXFLV5GVg03j1uunVuflREa/A53Ay/+D958nOguJdebwd8CDxLK1vT2nqIRuImWQa6kJcJV50ZYT+F+zrTP9PYqkylxx/cb1LiLCrsiIXAFk7BJ4nBjzVsKcpI+mG9e6QBOaJy5zqWzAsR02/ZTLJ1VQTxbvQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:13 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:13 +0000 Subject: [PATCH v5 03/16] hw/i386: Consolidate topology functions From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:57:11 -0600 Message-ID: <158326543195.40452.7437947098625099601.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN6PR08CA0016.namprd08.prod.outlook.com (2603:10b6:805:66::29) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN6PR08CA0016.namprd08.prod.outlook.com (2603:10b6:805:66::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.19 via Frontend Transport; Tue, 3 Mar 2020 19:57:12 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1490c453-3098-43e2-e81e-08d7bfad10cd X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: aAWSJ8XQFjBvdJJVAhTU0zU34gab2o6JD7ZE3n+KOMWAiPGj8u7fTbEhx7Pjct/Ype7hSSkW1dkCyXt/y9L7jy8woSnFZ3BO1OiqXSWvpwk9jOZw0oAWzh2sUSreVW3DIVan+jzdeuSu/I9mdlXSM6LkiFj81fyygYv/4tRIbA+1InWXQsc9/lU7a6HAevORFoDxGZUbgl1Mbvuj8j9PcBz+IF0rjJV8d81h4oXwd9NM+SFMXUxt4QyYnUCVP/YxR/LIGUw+ADcLj5aUEljTuvH83aWgo4lbucoDcxEQLMFDYJfEMZoOCRCpPu1znIIlhdoJaYdG5zfD0kl++kFg1x6ZLvXylmdthQq91OA8RUP1TtxEW9X+d5IgoDOv+IWCd21QFsUm4852+emK1J0D91eW/AfhtFyaB4u3luhXJOA82BOsuZPhu0afAD6N16nY X-MS-Exchange-AntiSpam-MessageData: rbF6VwWzGfLyuhg9RXslOmoJCFVqjzyV2EmS0zZPfBlDBBlZUFktd9kjSV4BilRajD639cwAJA3tJwxir2OUtkP6ZiyAsu4YGKOvGORzrmZUTWgV5VBQN1T1flr9SlCnEnCkbGK2MOoXZANTRBSxQg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1490c453-3098-43e2-e81e-08d7bfad10cd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:13.0040 (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: OixT6bM48tCVQgoz/z3UqM2WTpWx0jkpKnE8EfVDSp8d885EWEa3dpvpuWHwadHY X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.68.46 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" Now that we have all the parameters in X86CPUTopoInfo, we can just pass the structure to calculate the offsets and width. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- include/hw/i386/topology.h | 68 ++++++++++++++------------------------------ target/i386/cpu.c | 23 +++++++-------- 2 files changed, 32 insertions(+), 59 deletions(-) diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 7ea507f376..ba52d49079 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -69,56 +69,42 @@ static unsigned apicid_bitwidth_for_count(unsigned count) /* Bit width of the SMT_ID (thread ID) field on the APIC ID */ -static inline unsigned apicid_smt_width(unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads) +static inline unsigned apicid_smt_width(X86CPUTopoInfo *topo_info) { - return apicid_bitwidth_for_count(nr_threads); + return apicid_bitwidth_for_count(topo_info->threads_per_core); } /* Bit width of the Core_ID field */ -static inline unsigned apicid_core_width(unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads) +static inline unsigned apicid_core_width(X86CPUTopoInfo *topo_info) { - return apicid_bitwidth_for_count(nr_cores); + return apicid_bitwidth_for_count(topo_info->cores_per_die); } /* Bit width of the Die_ID field */ -static inline unsigned apicid_die_width(unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads) +static inline unsigned apicid_die_width(X86CPUTopoInfo *topo_info) { - return apicid_bitwidth_for_count(nr_dies); + return apicid_bitwidth_for_count(topo_info->dies_per_pkg); } /* Bit offset of the Core_ID field */ -static inline unsigned apicid_core_offset(unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads) +static inline unsigned apicid_core_offset(X86CPUTopoInfo *topo_info) { - return apicid_smt_width(nr_dies, nr_cores, nr_threads); + return apicid_smt_width(topo_info); } /* Bit offset of the Die_ID field */ -static inline unsigned apicid_die_offset(unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads) +static inline unsigned apicid_die_offset(X86CPUTopoInfo *topo_info) { - return apicid_core_offset(nr_dies, nr_cores, nr_threads) + - apicid_core_width(nr_dies, nr_cores, nr_threads); + return apicid_core_offset(topo_info) + apicid_core_width(topo_info); } /* Bit offset of the Pkg_ID (socket ID) field */ -static inline unsigned apicid_pkg_offset(unsigned nr_dies, - unsigned nr_cores, - unsigned nr_threads) +static inline unsigned apicid_pkg_offset(X86CPUTopoInfo *topo_info) { - return apicid_die_offset(nr_dies, nr_cores, nr_threads) + - apicid_die_width(nr_dies, nr_cores, nr_threads); + return apicid_die_offset(topo_info) + apicid_die_width(topo_info); } /* Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID @@ -128,16 +114,9 @@ static inline unsigned apicid_pkg_offset(unsigned nr_dies, static inline apic_id_t apicid_from_topo_ids(X86CPUTopoInfo *topo_info, const X86CPUTopoIDs *topo_ids) { - unsigned nr_dies = topo_info->dies_per_pkg; - unsigned nr_cores = topo_info->cores_per_die; - unsigned nr_threads = topo_info->threads_per_core; - - return (topo_ids->pkg_id << - apicid_pkg_offset(nr_dies, nr_cores, nr_threads)) | - (topo_ids->die_id << - apicid_die_offset(nr_dies, nr_cores, nr_threads)) | - (topo_ids->core_id << - apicid_core_offset(nr_dies, nr_cores, nr_threads)) | + return (topo_ids->pkg_id << apicid_pkg_offset(topo_info)) | + (topo_ids->die_id << apicid_die_offset(topo_info)) | + (topo_ids->core_id << apicid_core_offset(topo_info)) | topo_ids->smt_id; } @@ -165,20 +144,15 @@ static inline void x86_topo_ids_from_apicid(apic_id_t apicid, X86CPUTopoInfo *topo_info, X86CPUTopoIDs *topo_ids) { - unsigned nr_dies = topo_info->dies_per_pkg; - unsigned nr_cores = topo_info->cores_per_die; - unsigned nr_threads = topo_info->threads_per_core; - topo_ids->smt_id = apicid & - ~(0xFFFFFFFFUL << apicid_smt_width(nr_dies, nr_cores, nr_threads)); + ~(0xFFFFFFFFUL << apicid_smt_width(topo_info)); topo_ids->core_id = - (apicid >> apicid_core_offset(nr_dies, nr_cores, nr_threads)) & - ~(0xFFFFFFFFUL << apicid_core_width(nr_dies, nr_cores, nr_threads)); + (apicid >> apicid_core_offset(topo_info)) & + ~(0xFFFFFFFFUL << apicid_core_width(topo_info)); topo_ids->die_id = - (apicid >> apicid_die_offset(nr_dies, nr_cores, nr_threads)) & - ~(0xFFFFFFFFUL << apicid_die_width(nr_dies, nr_cores, nr_threads)); - topo_ids->pkg_id = - apicid >> apicid_pkg_offset(nr_dies, nr_cores, nr_threads); + (apicid >> apicid_die_offset(topo_info)) & + ~(0xFFFFFFFFUL << apicid_die_width(topo_info)); + topo_ids->pkg_id = apicid >> apicid_pkg_offset(topo_info); } /* Make APIC ID for the CPU 'cpu_index' diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 92fafa2659..1263271edd 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5369,6 +5369,11 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, uint32_t die_offset; uint32_t limit; uint32_t signature[3]; + X86CPUTopoInfo topo_info; + + topo_info.dies_per_pkg = env->nr_dies; + topo_info.cores_per_die = cs->nr_cores; + topo_info.threads_per_core = cs->nr_threads; /* Calculate & apply limits for different index ranges */ if (index >= 0xC0000000) { @@ -5455,8 +5460,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, eax, ebx, ecx, edx); break; case 3: /* L3 cache info */ - die_offset = apicid_die_offset(env->nr_dies, - cs->nr_cores, cs->nr_threads); + die_offset = apicid_die_offset(&topo_info); if (cpu->enable_l3_cache) { encode_cache_cpuid4(env->cache_info_cpuid4.l3_cache, (1 << die_offset), cs->nr_cores, @@ -5547,14 +5551,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, switch (count) { case 0: - *eax = apicid_core_offset(env->nr_dies, - cs->nr_cores, cs->nr_threads); + *eax = apicid_core_offset(&topo_info); *ebx = cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax = apicid_pkg_offset(env->nr_dies, - cs->nr_cores, cs->nr_threads); + *eax = apicid_pkg_offset(&topo_info); *ebx = cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break; @@ -5578,20 +5580,17 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx = cpu->apic_id; switch (count) { case 0: - *eax = apicid_core_offset(env->nr_dies, cs->nr_cores, - cs->nr_threads); + *eax = apicid_core_offset(&topo_info); *ebx = cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax = apicid_die_offset(env->nr_dies, cs->nr_cores, - cs->nr_threads); + *eax = apicid_die_offset(&topo_info); *ebx = cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break; case 2: - *eax = apicid_pkg_offset(env->nr_dies, cs->nr_cores, - cs->nr_threads); + *eax = apicid_pkg_offset(&topo_info); *ebx = env->nr_dies * cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_DIE; break; From patchwork Tue Mar 3 19:57:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418725 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 60F0F1395 for ; Tue, 3 Mar 2020 19:59:55 +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 360882073B for ; Tue, 3 Mar 2020 19:59:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="QKFL4JbI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 360882073B 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]:53052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dhq-00050e-Cb for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 14:59:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38265) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DfQ-0008VV-1w for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9DfO-0002yq-NN for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:23 -0500 Received: from mail-eopbgr680062.outbound.protection.outlook.com ([40.107.68.62]:33922 helo=NAM04-BN3-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 1j9DfO-0002xw-HW for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mdhp/6ian/Zbmf2jzLLP47wiSxPeLfv0GWZGLcCfLeSnqbzs8dnFCb3QEe2+vR+KX3tTWTPQ1bBxQ+Uupw1sdwKLvkAtm/uMtgTnXhcvqVOF+pgGnIThVaLRsUVG/euT6vyQZKb+9Q5iFaXp7F157ed48s0nbcmFAhKyaoWYIx7pjgzaysOdbOWlqCKOmINTQykwS+Guufz/09ZssbZCfyElkHsYfAhCfWq846mDhzoqHb5X8xobGe8kwWO3bCZ7Nu2fqD00SzM3Hl47SFK5b4HMawCV4iQwRtkxj6J7HbSPH+QFmq4hifuErb9bd3//mQm2WNG6SFy7gqIhogvQyQ== 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=rad23UMfdNy9LIHmhE+UOd2++OzXyNFDWNC91oWlLPU=; b=DdsAj7rcuvNUVTc7ipCCdl5Lf20MZ0VSqpjeW5cyOQOY21uQmLMgkdg+83Kc0DUJdE+UiGA4LIR5TjD3/Cv8EBNSCAOUoLrPFTECjnPdgQN6Yvyc2TNX2Y/7QfpenTBXV2tdXzxbLRNEiCeq021d0oNlEMpkXhCV+R6c+lY+oqksrJPoCL+Q1D2NXinmVo/4U8p838Smc4G3ddsJuOexE8YQx/VZZ3zq0wPRMQ6tFarM9LqBeI2XmoEhZIeT2aCk61TJWSViDOpKMH2ABcSzQ5syPYI2VWRKD8kHu+G1v3d0/ug2sXFk0AQAfylgZtHVns1XFRCxGbHj1Pe+kpntPg== 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=rad23UMfdNy9LIHmhE+UOd2++OzXyNFDWNC91oWlLPU=; b=QKFL4JbIhbIGMwy9MTYtoPkNVOncjPwZnrGKB2EChAQ1kFdfIFy0j2Y1wj6pOeW4H6n6KPkPQlkzf6xN2VgtPIFGL1w7GlbLqlWKMuAtL8Nl9O0t2gP2zuQiT5FPGIVqy+RNoA/AVSzCOTnJsQKpNpayjH4gCtc+ttKtLgVca5o= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:19 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:19 +0000 Subject: [PATCH v5 04/16] machine: Add SMP Sockets in CpuTopology From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:57:18 -0600 Message-ID: <158326543822.40452.17598145031344735065.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0501CA0043.namprd05.prod.outlook.com (2603:10b6:803:41::20) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN4PR0501CA0043.namprd05.prod.outlook.com (2603:10b6:803:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.5 via Frontend Transport; Tue, 3 Mar 2020 19:57:18 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c7108ebc-9b9c-4aa2-6e77-08d7bfad1484 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: lKqol37nBUYP1lLkWDg8hMQlyQ8/KiPQe6mjNs5Aue9gQk76gVgyPvc8/Xm2zy5UGCwrvNfdcLYKnlM03sf61tUz7E+yBCtU2Jv+y4ur3zg1fj9pqjCepIeSixBpefpS76sbiDAcVULF7w3CoSxfbIP7NPekyG79AduFA2kzhjKSW7SWwN9Ix3UXclsAq30B09d0Kg4F8dy54ZCI52GqgAi/Wu1qotJK58iIEJRII/LC1LKlYVhHVdE8bsnU+T5bb8DrOXL+6NWJFWRRzQcqFp/IZBS5zlZTCpka+mR0wsxR59uu1gepj6ub23yS13rG8SaDsIDf+3ay1HmucRA0iUKwpYSSrgyN3kSgrrqIJ5AXnvl7ojZLZRC9JY2qiFLV4Oy8oTUO2YOL+1YNsqwCu27fTk26ewEfHXCpl0jOlGCco+IG74a05oHmU2CNF6mI X-MS-Exchange-AntiSpam-MessageData: B1WfdS0VTPVDn6n23S/OqdA+FLXuONqBywRggz8dOfGM/A54dKqBYYc6Ud7m5FVY8RCN0uuYviJ+dCsC+VeMU6F3Ox95BKyjSbGwUFG4gQwLizEeW4ZsBPM98y2wqyfrc2WSYRZ92b8xuchym/a0NA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7108ebc-9b9c-4aa2-6e77-08d7bfad1484 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:19.2164 (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: 5CkdLHuuT9qw+o+/Xs0FVxRJMTTlkn69ku58WfD8zYph69DtLyvZEXnRrd+vEvUr X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.68.62 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" Store the smp sockets in CpuTopology. The socket information required to build the apic id in EPYC mode. Right now socket information is not passed to down when decoding the apic id. Add the socket information here. Signed-off-by: Babu Moger Reviewed-by: Eduardo Habkost Reviewed-by: Igor Mammedov --- hw/core/machine.c | 1 + hw/i386/pc.c | 1 + include/hw/boards.h | 2 ++ vl.c | 1 + 4 files changed, 5 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index d8e30e4895..2582ce94f6 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -728,6 +728,7 @@ static void smp_parse(MachineState *ms, QemuOpts *opts) ms->smp.cpus = cpus; ms->smp.cores = cores; ms->smp.threads = threads; + ms->smp.sockets = sockets; } if (ms->smp.cpus > 1) { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index ef23ae2af5..68bf08f285 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -780,6 +780,7 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) ms->smp.cpus = cpus; ms->smp.cores = cores; ms->smp.threads = threads; + ms->smp.sockets = sockets; x86ms->smp_dies = dies; } diff --git a/include/hw/boards.h b/include/hw/boards.h index fb1b43d5b9..320dd14e02 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -252,12 +252,14 @@ typedef struct DeviceMemoryState { * @cpus: the number of present logical processors on the machine * @cores: the number of cores in one package * @threads: the number of threads in one core + * @sockets: the number of sockets on the machine * @max_cpus: the maximum number of logical processors on the machine */ typedef struct CpuTopology { unsigned int cpus; unsigned int cores; unsigned int threads; + unsigned int sockets; unsigned int max_cpus; } CpuTopology; diff --git a/vl.c b/vl.c index 7dcb0879c4..f77b1285c6 100644 --- a/vl.c +++ b/vl.c @@ -3949,6 +3949,7 @@ int main(int argc, char **argv, char **envp) current_machine->smp.max_cpus = machine_class->default_cpus; current_machine->smp.cores = 1; current_machine->smp.threads = 1; + current_machine->smp.sockets = 1; machine_class->smp_parse(current_machine, qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); From patchwork Tue Mar 3 19:57:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418729 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 940531395 for ; Tue, 3 Mar 2020 20:00:19 +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 6A48E2073B for ; Tue, 3 Mar 2020 20:00:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="z+mKsaOC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A48E2073B 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]:53066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DiE-0005dT-Jq for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:00:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38309) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DfV-0000Gk-AY for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9DfU-00031I-9i for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:29 -0500 Received: from mail-bn3nam04on0623.outbound.protection.outlook.com ([2a01:111:f400:fe4e::623]:28322 helo=NAM04-BN3-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 1j9DfU-00030y-3e for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fD/ppDCIP/M3rWJxbB/aQbCH2hq8rH0IJUceMawgRpSAcagj5K7ZvxG8LZChnRYDH9dZF5PMaA8LHoGvqk2DiJU6QVL2izZMKSduNNrDD5IHh+kneYga3fNHUMmc86R5sGgvLzxID/QAGEUQo0ALrdUuFjmh4yam+4k452tt8vQUq6mmKi6zTOuFJg8MeEO/gp4Y2FuPmIYAyzzmBZpDELh2qI4Czc7HZCr8JcV6qhfDc0Wd0+jQv4NG7nC+IBdsglyGQzlNd2Amo/Flofpw6FIvn17kfr2n/bUYc6pCG81KHqa0qkXvDsEiSLMI23ffx8TIApK3/ucLhezat/QKLg== 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=/vBOvC4A3FWBf/rhF7wTUjoUPneTqtm5XEO4DeULwi0=; b=auPZ3x0c3SXwM42U2zlOGDvsYuC23CQyimBTUXUS/v1yeoRapd34oMQpBwqEJwN0ulNd8y84UL7c++JMkoyLt4xGvHoynADrkPEigHQtR6jurUg4vsLrcmL1akVD9AbR9yx4Vo5L0zpe1e/HRqDTeb8bC75twKeNn7oiwMJt1nxtv9b2s4GpLyP3LWvZruWOoJp3BDGhnHB6/qcSGEdfmgiWaXbZ8g1TULBjv+ChM1yvGG0VtDT6kcTl0VoqR+z6ZiLJb8szmT3OuXDN8EdGw3B5p5DdOMAnrUw2tVX7o4wN46JU7+l4UPEVztGnXc0B3UWqribkp3fbxdqRycPAFQ== 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=/vBOvC4A3FWBf/rhF7wTUjoUPneTqtm5XEO4DeULwi0=; b=z+mKsaOCYYze4PKDZmTf2eLpg1e8l6WM4sbfhFoyRvziqgWD4ZYLf71r/Wl8A8OprshP4tmjw1+3LGylISNt2ZvPXjl+IQN8E7zbFLezL+W2S0Ld+fzf1PlnYCbkvjJwJ9ZppW8zoJaF08RRR27w9sDrCxmOe7UfqMdB62nvTt8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:25 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:25 +0000 Subject: [PATCH v5 05/16] hw/i386: Remove unnecessary initialization in x86_cpu_new From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:57:24 -0600 Message-ID: <158326544443.40452.17613849801643778536.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN1PR12CA0097.namprd12.prod.outlook.com (2603:10b6:802:21::32) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN1PR12CA0097.namprd12.prod.outlook.com (2603:10b6:802:21::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18 via Frontend Transport; Tue, 3 Mar 2020 19:57:24 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: dd830821-e987-44a4-b505-08d7bfad1834 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:935; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(4744005)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: I00bwM6Wxh3oRfJIJ3D/cisQbLusDfGjQnovxxnfyF2Yf0ygKKHRKu1Qxe6h2pn2i0uBSaHDiSOhHPgesS9neBcJ3wqY8TebhPzKoujlqeFUdl5ZrQqThWR5rMGDbsrmJULeC4QzjzyO6XBXqphPRNI0svLVYLdkRwq2pMMU2xbSJKe0lzloJxbEPxONvXvaruYJ4vb+50KwCTU1jUdEtpcasXBGU6k8tWR8OyzXsyY5NNOJDkOo8IBLUD5RGJtZ9K9umJvrWSKWsfdaItW3xfVm9J7zK8dJ/eFemhJTynazcsrb/dOtl90fOOpADaEpsFQw5VPhWKNzwZU5bPjl/bQ/J4nvD+bGuOqZ/DAADFWmBovEsMxM3NvmRUdgXP3NNaIjTJmVCrKMUWY6apmrfNE6b+yG8n+fpP9y8raObLhuv9CeqxpgIGpNtiPFGdP+ X-MS-Exchange-AntiSpam-MessageData: ozafyQWvEhb4Tyss575nW65AUvFKXwpHCZP1OUq4VlnhnlplA8grrpoOBH9EKKxTj7UWdlgVvj2Yr3JvLtdpp63QkTwOT+mJ5UhV96APluz+kYvT4yPHDcRxwhX2gZb5i+X1QXKoXtJQqJXwm+5fjQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd830821-e987-44a4-b505-08d7bfad1834 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:25.4188 (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: yxX9b2Aqdt0BJ/NZF3Z1Xi+IIYrkPoGCQLl8PREEftYVDI7WNjM1RPwk9o/RFtgg X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a01:111:f400:fe4e::623 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" The function pc_cpu_pre_plug takes care of initialization of CPUX86State. So, remove the initialization here. Suggested-by: Igor Mammedov Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/x86.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 03b8962c98..79badcc4ec 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -103,13 +103,9 @@ void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp) { Object *cpu = NULL; Error *local_err = NULL; - CPUX86State *env = NULL; cpu = object_new(MACHINE(x86ms)->cpu_type); - env = &X86_CPU(cpu)->env; - env->nr_dies = x86ms->smp_dies; - object_property_set_uint(cpu, apic_id, "apic-id", &local_err); object_property_set_bool(cpu, true, "realized", &local_err); From patchwork Tue Mar 3 19:57:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418733 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 BC05C14B7 for ; Tue, 3 Mar 2020 20:02:34 +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 8FE302073B for ; Tue, 3 Mar 2020 20:02:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="HxvEcwKv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FE302073B 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]:53102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DkO-0000U7-Rd for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:02:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38380) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dfb-0000Yg-7v for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9DfZ-000374-T3 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:35 -0500 Received: from mail-eopbgr680046.outbound.protection.outlook.com ([40.107.68.46]:13799 helo=NAM04-BN3-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 1j9DfZ-00036o-K7 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:33 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bVYnXhYPwz4m4kV+39eIUObJ+eJ1fhei7+YP0U7fB73DX6HSE6ycY7TLyVMpi6k2DiVL2h+hkMCLiekZXbYGWrQ7uElLHMLR7fpw5VlsLfX3uMfWDT97tCUDJdsNQpcGEK0vvXCsv70NEUNiUWrG29qx4YELqv/HMnJvPvEo8eD1KTF3mdZ8AX3gmZrchT3R3EmUo2aDad5V2Fa7h7iEerygPTV4KDqB0o6WBC5gAVlF+XIBv8dOYxIwPPF2kB5bxFt1q2nRZXguKUElHssaSChW/bgrpOB7Mhridmc2PJ9ssC/HgXOCDXNzv7xnOJzgN4Bi0uMUyQCJPiWN8wvdag== 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=H5gmNRIWq1pWWeg50Tsw5x5yoK2dwsGFK7mJ4WcjmxU=; b=WP0s8VapnFSVkC2mvggGt6gjmTDu2O/0mAtgbOf+xMVxCZR5XrCKJbSNXKj8U9DbuSrgiAfqR7yMJVPnkQ5dySHDtWrcqh9o1nBYQVHcTOPU1PReO5+Jp6EyS1mrUoKd6bKrhI1mHSKIlOfHrVivUhOIxFEyA0IuU6lRph13UMN+oVJC84Kzy2QriUr2CCOc95WzimPuSGkeLbNdMNB1zo/sbnvADrDYslylK2AHK4FMUcNrbgZzVxLBwGbLBvAvfBNta2frFsWc+m9jDLIp6BlyMTUn3aix1XKT0ymffAiC50aP/04+SikLSgCS24I5J+q05orXKSyrjQzJgux7rg== 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=H5gmNRIWq1pWWeg50Tsw5x5yoK2dwsGFK7mJ4WcjmxU=; b=HxvEcwKv9XFKy+dLQDzmSFa/gm9WDb2bFhNBbfm5lQoHW9Sy64Q1nFMdOA3PGZ5LFrhFyonGNeoKjv+XoevEXlDAMlejNR80S3RXyAMYBAyWN7qm87m/axWeTkMM6JMUWMutvMWE58QyWXN3p9yOF5ZdyZiFYcpjGm5CLoXbWHI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:31 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:31 +0000 Subject: [PATCH v5 06/16] hw/i386: Update structures to save the number of nodes per package From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:57:30 -0600 Message-ID: <158326545066.40452.2744012199788458115.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN4PR0501CA0049.namprd05.prod.outlook.com (2603:10b6:803:41::26) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN4PR0501CA0049.namprd05.prod.outlook.com (2603:10b6:803:41::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.5 via Frontend Transport; Tue, 3 Mar 2020 19:57:31 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2584e4cd-ba18-4e0a-bbc1-08d7bfad1be4 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(15650500001)(4326008)(66476007)(478600001)(60793003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: bud30QjqKsqaBi76/u3v4b/QM0rGGhzxxYR11N2WqmOlj5bsv/PKGPfDHIT5PUwJd9suMD5wnC0K1hG91EXHkuTq35L7Ky5Gi7sDxn7sXSS82poGTkEFg85xsvthhQDa0klXP8uJgP4QHp+nEGfy7QJQAmbBaslBSjZ5T8cWYE3FcXCzj1WUyzp/ehox9uvwwfmJ/sMcVXrVqTXW2w7KTSoGnVBMsSy7J6hFARhU60B43M+lbi8/PgDS19FYrgR5rNw9chWu8ULWgWklhwsS8UAvPn0Rl+3CVUz2jxs6QvrKYHmuOOBsa3wNyuJ9PVv9bAt/7vo5FwGR6x4FK4R75dZR6JLB7Lw2ueyC2oT1uMmAtzApIP8aj/MuMXduOma9CqFTLBkAq+ZL2y+nseR05WA1SOr1ZaWLhP5O9ew2I3hCdbj8ZHvfOdOBUpZb8D0IHZvvZCQ5HYDB1X2jkzddU5CVkGuStixSMPjedvsOcLJlrIIodRIgQ+vu1JuAWYh+ X-MS-Exchange-AntiSpam-MessageData: 3XCqu3dqEg+YnHV9Be6+P0cw15l3fx9ZFMclunohrm/C4ihsy/KjPH4VbfAE5HQ+SbNjQ6DlsqinGWubU4/dSFKgsfG5yTvb/SGziBBwA9W+VRqJ5fwHkMMjPvck3zsOLB7ZDn54CljDbznlJ7+nKg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2584e4cd-ba18-4e0a-bbc1-08d7bfad1be4 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:31.6056 (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: 8Gqd8h8nhY9Ekc1IGyVTOy18GrB0U1ymkNGAnVrjZMWEGc8oUHYr82pJOedNtitv X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.68.46 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" Update structures X86CPUTopoIDs and CPUX86State to hold the number of nodes per package. This is required to build EPYC mode topology. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 1 + hw/i386/x86.c | 1 + include/hw/i386/topology.h | 1 + target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + 5 files changed, 5 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 68bf08f285..3d13cd46d6 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1526,6 +1526,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, init_topo_info(&topo_info, x86ms); env->nr_dies = x86ms->smp_dies; + env->nr_nodes = topo_info.nodes_per_pkg; /* * If APIC ID is not set, diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 79badcc4ec..929b80c9c7 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -62,6 +62,7 @@ inline void init_topo_info(X86CPUTopoInfo *topo_info, { MachineState *ms = MACHINE(x86ms); + topo_info->nodes_per_pkg = ms->numa_state->num_nodes / ms->smp.sockets; topo_info->dies_per_pkg = x86ms->smp_dies; topo_info->cores_per_die = ms->smp.cores; topo_info->threads_per_core = ms->smp.threads; diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index ba52d49079..04f01e2a09 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -53,6 +53,7 @@ typedef struct X86CPUTopoIDs { } X86CPUTopoIDs; typedef struct X86CPUTopoInfo { + unsigned nodes_per_pkg; unsigned dies_per_pkg; unsigned cores_per_die; unsigned threads_per_core; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 1263271edd..40670f8aca 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6829,6 +6829,7 @@ static void x86_cpu_initfn(Object *obj) FeatureWord w; env->nr_dies = 1; + env->nr_nodes = 1; cpu_set_cpustate_pointers(cpu); object_property_add(obj, "family", "int", diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 576f309bbf..20abbda647 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1607,6 +1607,7 @@ typedef struct CPUX86State { TPRAccess tpr_access_type; unsigned nr_dies; + unsigned nr_nodes; } CPUX86State; struct kvm_msrs; From patchwork Tue Mar 3 19:57:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418723 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 E0F8814B4 for ; Tue, 3 Mar 2020 19:59:31 +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 B75DD2073B for ; Tue, 3 Mar 2020 19:59:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="JbR8Fg6x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B75DD2073B 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]:53050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DhQ-0004JU-TX for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 14:59:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38446) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dfi-0000lg-1A for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9Dfg-00039B-UV for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:41 -0500 Received: from mail-bn3nam04on0605.outbound.protection.outlook.com ([2a01:111:f400:fe4e::605]:30851 helo=NAM04-BN3-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 1j9Dfg-00038Z-Os for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vp+cvrN/Py+zU2QJRmHKhLxyL2efBaZoc0i6N+vyfDwg2G6ndKP/0Sas2NyxyaWRXzpiv2g6qgUJbTxrX3bTHOHsLyGjhpP/blcrpR7nz3/k/rb4qLk4QpVXKmsNdNc1Qnm1QMyh40y+48Dv5U7sbISXgh7G9oi/d+qTP0MZQrRynJCo+nc6GDmoZqSkktEBnSYazbBTfhfesi2ogyKlu7oJKQI3rXbe1P4qsWDhaiCI4aN1imL+luC+xfjLkNEUV7Q4+xGP/FTr1aFYcxPMsEpqyfceKSQfNbdwto5KtQbsjUMRSUxxJd3VuG0WOJ+ljjokM6LV7QVAAgrn4exreA== 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=m+u2ICj/Q5djVtdlPcK6+p/2u0NKk3HTJ0sJ3qCpY08=; b=YYE8vljjUKBcEri337GkZDXuUtguv/y3a7XX6mhyXilGAekCPUC5SktIuSQNNDp1i44OPWLKo4/DLo0H1iv8ofyS/NYTj2kXDUhUV1VmunDiknHUrhJX+YeMdrnYniQybPLD9Btd0oMVYzbyXeudHQtwi+hCWdn6G89pouLvKbjJdkcgizf9ZmjHRewngFC07jiwOu7doZs7jW8CH+RpEZBDRNAfRu4o982LapXoFx+3TBAog48Jmzsm6t5stnrj4INTdXpJ+dd/ye6bMauYPdWs4BK1s1ie9COxq4WcHxIPnqv+4edacPM68tairROvDJg0ybhi4m1pf5A9yk5eJg== 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=m+u2ICj/Q5djVtdlPcK6+p/2u0NKk3HTJ0sJ3qCpY08=; b=JbR8Fg6xwdcGM7v24LyazisLwaWjaW1drTuNdXO7MWB9ZXaQx9aa0Qs0rEVckptvmalTKYJc2vrb/Rs7zwiDSawi436PUP1MPAxKlTCXVmH8R+L19wohTdt/EyiWRSniG7CaBloIUOGSKmB+d9KsLWtoosYj9UbJAQepTFAYKHc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:37 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:37 +0000 Subject: [PATCH v5 07/16] hw/i386: Rename apicid_from_topo_ids to x86_apicid_from_topo_ids From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:57:36 -0600 Message-ID: <158326545682.40452.3744786681609930727.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN6PR08CA0016.namprd08.prod.outlook.com (2603:10b6:805:66::29) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN6PR08CA0016.namprd08.prod.outlook.com (2603:10b6:805:66::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.19 via Frontend Transport; Tue, 3 Mar 2020 19:57:37 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 65aec257-0827-445b-88f3-08d7bfad1f7e X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:534; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: qwxS/7x+QVrzyThrF8MjIasYdG6xYF38Xjaggr22kAodEoB+irnA31OIzPE2heHbtnfN/i8aIXqzsSjvt85qYEiMjO2q6kWegxvHvftx54ZCP8w4PilyUzxg7rsfuU3tRvDIhAnjtDA29vRd32pd5/vi3neL4gmVYtNFxtutUg7hm8FkMTnmvpzEm+3HqVveM+zo86R8KKx5OqRaMMDvKQzLWHDGZihZVxK6xDGTx6hOzqz3tJL/MJ66ZQxX6RP1thpLYkNgD0IM6sOqfoYTOzljWQo26bMHugZE+m2rcJFr/Z8oM4Mk+0cmCJEEHCcydP9RrHYXnJSAZXI3w/aNvXQlAbZGt9njXA/f50m5PN5rFrjDF1UzUGBqhJOpCeyWzD2pES7743eKWaW2lqQSyVNtYKoJUsVZrZJbWE+v1LCNB+FlIwhIig7FYLwbC9Si X-MS-Exchange-AntiSpam-MessageData: wXaxu543TcQFyDeZ+gYuYHuMtld83neUW1X5V262z4S6/cgQ92+BLmf5Lqk3C2edy+lr2HlNV3ghh5g5ENsaWHXy/NGYb6wQ/CABhjbrBubODFt2ldXo2PuyoT2yEnCVzGkNgpRP0G0SmImtC57+tg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65aec257-0827-445b-88f3-08d7bfad1f7e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:37.6457 (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: Skz/M6O0Y+Q4j4xOfo5L5OBqScz8zfNiZ8ciEXbo3rlzMz94s/1+4unYXTLt0StU X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a01:111:f400:fe4e::605 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" For consistancy rename apicid_from_topo_ids to x86_apicid_from_topo_ids. No functional change. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 2 +- include/hw/i386/topology.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 3d13cd46d6..17cce3f074 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1581,7 +1581,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, topo_ids.die_id = cpu->die_id; topo_ids.core_id = cpu->core_id; topo_ids.smt_id = cpu->thread_id; - cpu->apic_id = apicid_from_topo_ids(&topo_info, &topo_ids); + cpu->apic_id = x86_apicid_from_topo_ids(&topo_info, &topo_ids); } cpu_slot = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 04f01e2a09..b9593b9905 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -112,8 +112,8 @@ static inline unsigned apicid_pkg_offset(X86CPUTopoInfo *topo_info) * * The caller must make sure core_id < nr_cores and smt_id < nr_threads. */ -static inline apic_id_t apicid_from_topo_ids(X86CPUTopoInfo *topo_info, - const X86CPUTopoIDs *topo_ids) +static inline apic_id_t x86_apicid_from_topo_ids(X86CPUTopoInfo *topo_info, + const X86CPUTopoIDs *topo_ids) { return (topo_ids->pkg_id << apicid_pkg_offset(topo_info)) | (topo_ids->die_id << apicid_die_offset(topo_info)) | @@ -165,7 +165,7 @@ static inline apic_id_t x86_apicid_from_cpu_idx(X86CPUTopoInfo *topo_info, { X86CPUTopoIDs topo_ids; x86_topo_ids_from_idx(topo_info, cpu_index, &topo_ids); - return apicid_from_topo_ids(topo_info, &topo_ids); + return x86_apicid_from_topo_ids(topo_info, &topo_ids); } #endif /* HW_I386_TOPOLOGY_H */ From patchwork Tue Mar 3 19:57:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418735 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 753DD1395 for ; Tue, 3 Mar 2020 20:02:59 +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 4ABA62073B for ; Tue, 3 Mar 2020 20:02:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="qmuPCWKT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4ABA62073B 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]:53106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dko-00017Y-Bw for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:02:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38496) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dfn-00012X-Ug for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9Dfm-0003CF-Af for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:47 -0500 Received: from mail-eopbgr750070.outbound.protection.outlook.com ([40.107.75.70]:29313 helo=NAM02-BL2-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 1j9Dfm-0003C6-4B for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G/jdFCDBxUOar5X37xr/PhMClQ4tEGP1QVibzmf2X63KZEf/S5Wd/edoaK0pKzsnbMet/SNIGwDViXBBHh4GLGMZcbFmwXIuguFiuqJIMGH6hTQjr6cDiqoBu1h7hvXt4sfNtj6ImDu+q5OBh5Z8mXW054QKxqzYRs5j3wGSLmlelFFTr2Op3dd2/4jFKXSA9YPbuPRyOTno5QCT65X3sYyufctMFnijzk+PXll3QqfJrHBPO2fgd/qe5oILAjhmmKcPIZXV27fpIAilAI8OUF2bk2VAlNLi/rp658rqFCobhEdEplQXNLyPqU6ZtnpK9ZWK6V9NzfxkzeanL/EDSA== 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=6aSnt20DaxWCSVFSSP+4YY6umab93oj6bPdSDzbD240=; b=lhznvSAdHBmuNR4J+X2solOEb8kCbdLEAioIZAf3ARTYy9+yrOcVd1SIEQjynuM1uEjfl7/ahT5/hYbz63e6kaZsevJZCCF8L7+JJA3W7A++gUxU5MYFNa40LihAuxu5DTysEA2W5k2npe5j8RMyedEe0lYbw5/mJapH/hCAwvVDZhdtryRJIN19HT1ZPbhPKA5SHdsIV825iIRDlLjMwZN2o/5i4kia6pELlTmOQtWGiC0tYlxzgUXzqA48PptAMwtB7khbbKxDpa1I88/SPha1spLf4iVhO+scL9+u5ePvnZe33KlhZHVF8grUd2XePuHuJBkb04dwXdubR7sy0g== 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=6aSnt20DaxWCSVFSSP+4YY6umab93oj6bPdSDzbD240=; b=qmuPCWKTJbmszlc+FhIP2azoXQ1glwENa3LAb+4An3w4++qsWLjHPLiJtcDh80QDZRmLN2hMZvh1onovpn5OrRYA5DNGXDTCRLGVaTy9XzA68h/0+rY3+hAh0WHDDenmgsKX5ZqOuct4n3Uy9agcgP3I8oEARgfPCpu/+AabctE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:44 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:44 +0000 Subject: [PATCH v5 08/16] hw/386: Add EPYC mode topology decoding functions From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:57:42 -0600 Message-ID: <158326546286.40452.13430980772455711494.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM6PR07CA0042.namprd07.prod.outlook.com (2603:10b6:5:74::19) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by DM6PR07CA0042.namprd07.prod.outlook.com (2603:10b6:5:74::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.16 via Frontend Transport; Tue, 3 Mar 2020 19:57:43 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fdc7fe52-37e1-4fde-249c-08d7bfad2396 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001)(966005); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: Kz7PPvKxM9gMe2KT6p5CAzRmzpfA2pv4m5jm94JbgOaggWUrF//1tVTztdkvPg4O0u3zeVOuGBoTl3bCyueW1Y3BZ/towhHPZix8mxDv1VRUzoJkokQVSUCl3tWEjDDjRW+h64xSM7qpR9M878xT17fL3CeJdHe7jc90w1bheVHCVj8gFG6Bi+6moO3flTyQceC9qVzIrDE8pboYakGq69vGUhoJ2OKjy+KCQKKQi+qYLQHShE8GbwisTXphhGmoiEfNZfQUizBmb285Nd5dOOV6CB8I60Jq3sP8DPsQdNsEIlcuFvsuZ1If0gvPJ3ScBtUmJ21Kal0Ez/EbIS8ya4wcVVbFwLj5nGbS4Lt64BAycKypodqiDzZ+8c81wQVBbidTWVFqn8CyFy7TZb1EAYWUKA+se1OgV3bcpk2lJwVoM5/os3DQAh49i9ZOJwe1e5EPVVdK+Dsw23uCxp7Cyxy8Q5qu7WSDgWoir9IS0UbtBhCSiMntTbXdioY+P+DpSxUCYTlzDtXDGOSELgOw5A== X-MS-Exchange-AntiSpam-MessageData: k4FoLEoOJ++0iIp0YiLO8PQc3XNIA3exhxeXMc+tsm/1JS30lkJo98nHVbl/Umxva00QfJelJxT/s0I5HtRZkewyTDHPF9FKJPrVcxtri7prW4GRl6NvS3maOUj4LracoYyOgunzrrKUjtsgWydveg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: fdc7fe52-37e1-4fde-249c-08d7bfad2396 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:44.5633 (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: ilpSAMwqNaOTGML5IYixj/G7cHijPOpyN7ZTChxmPZo4tYY6xNWp+ibaiUk+BhcY X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.75.70 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" These functions add support for building EPYC mode topology given the smp details like numa nodes, cores, threads and sockets. The new apic id decoding is mostly similar to current apic id decoding except that it adds a new field node_id when numa configured. Removes all the hardcoded values. Subsequent patches will use these functions to build the topology. Following functions are added. apicid_llc_width_epyc apicid_llc_offset_epyc apicid_pkg_offset_epyc apicid_from_topo_ids_epyc x86_topo_ids_from_idx_epyc x86_topo_ids_from_apicid_epyc x86_apicid_from_cpu_idx_epyc The topology details are available in Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors. The revision guides are available from the bugzilla Link below. Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537 Signed-off-by: Babu Moger Acked-by: Igor Mammedov --- include/hw/i386/topology.h | 100 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index b9593b9905..07239f95f4 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -47,6 +47,7 @@ typedef uint32_t apic_id_t; typedef struct X86CPUTopoIDs { unsigned pkg_id; + unsigned node_id; unsigned die_id; unsigned core_id; unsigned smt_id; @@ -88,6 +89,11 @@ static inline unsigned apicid_die_width(X86CPUTopoInfo *topo_info) return apicid_bitwidth_for_count(topo_info->dies_per_pkg); } +/* Bit width of the node_id field per socket */ +static inline unsigned apicid_node_width_epyc(X86CPUTopoInfo *topo_info) +{ + return apicid_bitwidth_for_count(MAX(topo_info->nodes_per_pkg, 1)); +} /* Bit offset of the Core_ID field */ static inline unsigned apicid_core_offset(X86CPUTopoInfo *topo_info) @@ -108,6 +114,100 @@ static inline unsigned apicid_pkg_offset(X86CPUTopoInfo *topo_info) return apicid_die_offset(topo_info) + apicid_die_width(topo_info); } +#define NODE_ID_OFFSET 3 /* Minimum node_id offset if numa configured */ + +/* + * Bit offset of the node_id field + * + * Make sure nodes_per_pkg > 0 if numa configured else zero. + */ +static inline unsigned apicid_node_offset_epyc(X86CPUTopoInfo *topo_info) +{ + unsigned offset = apicid_die_offset(topo_info) + + apicid_die_width(topo_info); + + if (topo_info->nodes_per_pkg) { + return MAX(NODE_ID_OFFSET, offset); + } else { + return offset; + } +} + +/* Bit offset of the Pkg_ID (socket ID) field */ +static inline unsigned apicid_pkg_offset_epyc(X86CPUTopoInfo *topo_info) +{ + return apicid_node_offset_epyc(topo_info) + + apicid_node_width_epyc(topo_info); +} + +/* + * Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID + * + * The caller must make sure core_id < nr_cores and smt_id < nr_threads. + */ +static inline apic_id_t +x86_apicid_from_topo_ids_epyc(X86CPUTopoInfo *topo_info, + const X86CPUTopoIDs *topo_ids) +{ + return (topo_ids->pkg_id << apicid_pkg_offset_epyc(topo_info)) | + (topo_ids->node_id << apicid_node_offset_epyc(topo_info)) | + (topo_ids->die_id << apicid_die_offset(topo_info)) | + (topo_ids->core_id << apicid_core_offset(topo_info)) | + topo_ids->smt_id; +} + +static inline void x86_topo_ids_from_idx_epyc(X86CPUTopoInfo *topo_info, + unsigned cpu_index, + X86CPUTopoIDs *topo_ids) +{ + unsigned nr_nodes = MAX(topo_info->nodes_per_pkg, 1); + unsigned nr_dies = topo_info->dies_per_pkg; + unsigned nr_cores = topo_info->cores_per_die; + unsigned nr_threads = topo_info->threads_per_core; + unsigned cores_per_node = DIV_ROUND_UP((nr_dies * nr_cores * nr_threads), + nr_nodes); + + topo_ids->pkg_id = cpu_index / (nr_dies * nr_cores * nr_threads); + topo_ids->node_id = (cpu_index / cores_per_node) % nr_nodes; + topo_ids->die_id = cpu_index / (nr_cores * nr_threads) % nr_dies; + topo_ids->core_id = cpu_index / nr_threads % nr_cores; + topo_ids->smt_id = cpu_index % nr_threads; +} + +/* + * Calculate thread/core/package IDs for a specific topology, + * based on APIC ID + */ +static inline void x86_topo_ids_from_apicid_epyc(apic_id_t apicid, + X86CPUTopoInfo *topo_info, + X86CPUTopoIDs *topo_ids) +{ + topo_ids->smt_id = apicid & + ~(0xFFFFFFFFUL << apicid_smt_width(topo_info)); + topo_ids->core_id = + (apicid >> apicid_core_offset(topo_info)) & + ~(0xFFFFFFFFUL << apicid_core_width(topo_info)); + topo_ids->die_id = + (apicid >> apicid_die_offset(topo_info)) & + ~(0xFFFFFFFFUL << apicid_die_width(topo_info)); + topo_ids->node_id = + (apicid >> apicid_node_offset_epyc(topo_info)) & + ~(0xFFFFFFFFUL << apicid_node_width_epyc(topo_info)); + topo_ids->pkg_id = apicid >> apicid_pkg_offset_epyc(topo_info); +} + +/* + * Make APIC ID for the CPU 'cpu_index' + * + * 'cpu_index' is a sequential, contiguous ID for the CPU. + */ +static inline apic_id_t x86_apicid_from_cpu_idx_epyc(X86CPUTopoInfo *topo_info, + unsigned cpu_index) +{ + X86CPUTopoIDs topo_ids; + x86_topo_ids_from_idx_epyc(topo_info, cpu_index, &topo_ids); + return x86_apicid_from_topo_ids_epyc(topo_info, &topo_ids); +} /* Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID * * The caller must make sure core_id < nr_cores and smt_id < nr_threads. From patchwork Tue Mar 3 19:57:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418731 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 A7F1614B7 for ; Tue, 3 Mar 2020 20:01:47 +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 6D3CB2073B for ; Tue, 3 Mar 2020 20:01:47 +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="ysFeUwh3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D3CB2073B 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]:53096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dje-00086I-Hd for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:01:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38574) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dfz-0001QX-IG for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9Dft-0003Dl-PH for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:59 -0500 Received: from mail-eopbgr680058.outbound.protection.outlook.com ([40.107.68.58]:13380 helo=NAM04-BN3-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 1j9Dft-0003DV-Ic for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:57:53 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JmO9ZeXWjEDr1jOlLZrvEDAJlF1jf+cRFGX72ivVpgwQU7FTUilU0rssF8JAojWDsrDcRSQfnkM/3MzkJkeo3Zxt/0jY4RBWJ6dxO6FwBEJW4/w2V/gt4RZ3ItN+N2FXYI5HfKvnjWcDGp7Z1IN+ekoqaio2l+55PyRxetVfc3ZBdrr8fmVNdWwgKP4pZQ2Lo+ycwwLiZP5bmzgvAqS8Yt5cQFEr09f8KFENXc8NOghnxBbXg8XcaXqrw4JhpNclGepwWna5FJmapiHjEFrUNJGnrGQk5wMc8iq973HRaqErvEuYMmKtbb7aCTQIFsjyeG1Oba7Z217pKeR46wySuQ== 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=zfC1sh24BhBwezs8E2nL/ruyPoX/4dpi7o+Z+JRXd6w=; b=RD4sHeNzEJ7qwHbQfkbf92DsSgDRdM9gJ7KZ/9WhRd6JhCC7ADSEMPQWu0r4E1kyzpDdd5nhfCQNUuPIalotU//Jaqk0zVhPSJwum8oEGPHC+Ap2iO2+mK79acNflBXf8raA5NpHIFGza5doL2TR8qsDk5WEdPmczjjg47s1UV+cGcL8JSkSStauib/DErXJdyA6TQWqAe1sodz9de9oOa5JlkNHSKh6K5XrvOKuSkbkMHqDZ1f+Rjjc6rvTtj5WLY6GwQDszZJrKcZg+BxrjkYl8+Q9vvTphtA4PwG8UaRhAlE3CaitzSKK63avpbLEDdaFYAc1IOcrz9s0d9lwuw== 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=zfC1sh24BhBwezs8E2nL/ruyPoX/4dpi7o+Z+JRXd6w=; b=ysFeUwh3XScqm0x+WESMObNhJO/OYkAn997nIlyHeI8sBs8jI7y7i5qAcR/0fkyM3MkCjmWqbrklhJ79Tg2RetLKutb8QAYlU4l0OO93pTvntT10u6LgNHqp38pXVCXI09MYrcwchL4Sa1iWoQqRca2NxEmL1dEKx2ZcuD60u6s= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:51 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:51 +0000 Subject: [PATCH v5 09/16] target/i386: Cleanup and use the EPYC mode topology functions From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:57:49 -0600 Message-ID: <158326546983.40452.10693492138041061735.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM6PR07CA0053.namprd07.prod.outlook.com (2603:10b6:5:74::30) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by DM6PR07CA0053.namprd07.prod.outlook.com (2603:10b6:5:74::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.16 via Frontend Transport; Tue, 3 Mar 2020 19:57:50 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e1c602cb-f0e8-4e18-9026-08d7bfad27b8 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: 6x8oZPDUw8pGLp77LBw50l+RsuFf3zFXJH7BtwO785zo3YOEM7JPYqf7hL2UNPPUoW2cRXY0p+FLeRPLsX9a9ndroJzq1QJqy1FzLikujvrigaR04ye/23139YqXJaw/lAqCkrQEKLspcWd+ueZnCXuke2h57O2nAMI3GNN87GIH111oPxg7OMAlxjcUvM6k+679P7qbCBXV6FZ4xWSYLcjPK9RxUtzDO5u/9lCD746iyDUeTbJl1MWRbhvt0j3GDPjUiyj79AtggL2TUceQAVxCsebgMkA/jWDcppI4ajLLBWIYjMayUAvLahI0hcgo1mM0DOq/Dyo0hcp1l2Uw/cBdb+1SuZYvkNbaEqmCNgD+yDl4+E/jPI0by8Ux6emvr2E6JT6ubJoCOX4EoXuQRwCyZlIHKeqhJoaXnswDRpMoPigJMB1SDv3AIDYAi2SD X-MS-Exchange-AntiSpam-MessageData: yDs3lVryNF8/rKOYUzw4Ae4Vlh0IuIh5sPkCjk5mwNtHao9tNdMi+dfBzPthiYsdmHa7Z1ZD6Lq4xsedUeI3QSDmIr+uXsfjkvL24/aGSAJOSdy65+o7eOwzfxzFknjANqNbPMVEu6/9bIigodtB1Q== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1c602cb-f0e8-4e18-9026-08d7bfad27b8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:51.4897 (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: Hqsyc2kmQAwyVBE23p2w2J9aCL6QbMwNfy8hPw7AfCbrAy73eMeC9WJoveQwNRBr X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.68.58 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" Use the new functions from topology.h and delete the unused code. Given the sockets, nodes, cores and threads, the new functions generate apic id for EPYC mode. Removes all the hardcoded values. Signed-off-by: Babu Moger --- target/i386/cpu.c | 162 +++++++++++------------------------------------------ 1 file changed, 35 insertions(+), 127 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 40670f8aca..c75cf744ab 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -338,68 +338,15 @@ static void encode_cache_cpuid80000006(CPUCacheInfo *l2, } } -/* - * Definitions used for building CPUID Leaf 0x8000001D and 0x8000001E - * Please refer to the AMD64 Architecture Programmer’s Manual Volume 3. - * Define the constants to build the cpu topology. Right now, TOPOEXT - * feature is enabled only on EPYC. So, these constants are based on - * EPYC supported configurations. We may need to handle the cases if - * these values change in future. - */ -/* Maximum core complexes in a node */ -#define MAX_CCX 2 -/* Maximum cores in a core complex */ -#define MAX_CORES_IN_CCX 4 -/* Maximum cores in a node */ -#define MAX_CORES_IN_NODE 8 -/* Maximum nodes in a socket */ -#define MAX_NODES_PER_SOCKET 4 - -/* - * Figure out the number of nodes required to build this config. - * Max cores in a node is 8 - */ -static int nodes_in_socket(int nr_cores) -{ - int nodes; - - nodes = DIV_ROUND_UP(nr_cores, MAX_CORES_IN_NODE); - - /* Hardware does not support config with 3 nodes, return 4 in that case */ - return (nodes == 3) ? 4 : nodes; -} - -/* - * Decide the number of cores in a core complex with the given nr_cores using - * following set constants MAX_CCX, MAX_CORES_IN_CCX, MAX_CORES_IN_NODE and - * MAX_NODES_PER_SOCKET. Maintain symmetry as much as possible - * L3 cache is shared across all cores in a core complex. So, this will also - * tell us how many cores are sharing the L3 cache. - */ -static int cores_in_core_complex(int nr_cores) -{ - int nodes; - - /* Check if we can fit all the cores in one core complex */ - if (nr_cores <= MAX_CORES_IN_CCX) { - return nr_cores; - } - /* Get the number of nodes required to build this config */ - nodes = nodes_in_socket(nr_cores); - - /* - * Divide the cores accros all the core complexes - * Return rounded up value - */ - return DIV_ROUND_UP(nr_cores, nodes * MAX_CCX); -} - /* Encode cache info for CPUID[8000001D] */ -static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, CPUState *cs, - uint32_t *eax, uint32_t *ebx, - uint32_t *ecx, uint32_t *edx) +static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, + X86CPUTopoInfo *topo_info, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) { uint32_t l3_cores; + unsigned nodes = MAX(topo_info->nodes_per_pkg, 1); + assert(cache->size == cache->line_size * cache->associativity * cache->partitions * cache->sets); @@ -408,10 +355,13 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, CPUState *cs, /* L3 is shared among multiple cores */ if (cache->level == 3) { - l3_cores = cores_in_core_complex(cs->nr_cores); - *eax |= ((l3_cores * cs->nr_threads) - 1) << 14; + l3_cores = DIV_ROUND_UP((topo_info->dies_per_pkg * + topo_info->cores_per_die * + topo_info->threads_per_core), + nodes); + *eax |= (l3_cores - 1) << 14; } else { - *eax |= ((cs->nr_threads - 1) << 14); + *eax |= ((topo_info->threads_per_core - 1) << 14); } assert(cache->line_size > 0); @@ -431,55 +381,17 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *cache, CPUState *cs, (cache->complex_indexing ? CACHE_COMPLEX_IDX : 0); } -/* Data structure to hold the configuration info for a given core index */ -struct core_topology { - /* core complex id of the current core index */ - int ccx_id; - /* - * Adjusted core index for this core in the topology - * This can be 0,1,2,3 with max 4 cores in a core complex - */ - int core_id; - /* Node id for this core index */ - int node_id; - /* Number of nodes in this config */ - int num_nodes; -}; - -/* - * Build the configuration closely match the EPYC hardware. Using the EPYC - * hardware configuration values (MAX_CCX, MAX_CORES_IN_CCX, MAX_CORES_IN_NODE) - * right now. This could change in future. - * nr_cores : Total number of cores in the config - * core_id : Core index of the current CPU - * topo : Data structure to hold all the config info for this core index - */ -static void build_core_topology(int nr_cores, int core_id, - struct core_topology *topo) -{ - int nodes, cores_in_ccx; - - /* First get the number of nodes required */ - nodes = nodes_in_socket(nr_cores); - - cores_in_ccx = cores_in_core_complex(nr_cores); - - topo->node_id = core_id / (cores_in_ccx * MAX_CCX); - topo->ccx_id = (core_id % (cores_in_ccx * MAX_CCX)) / cores_in_ccx; - topo->core_id = core_id % cores_in_ccx; - topo->num_nodes = nodes; -} - /* Encode cache info for CPUID[8000001E] */ -static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, +static void encode_topo_cpuid8000001e(X86CPUTopoInfo *topo_info, X86CPU *cpu, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { - struct core_topology topo = {0}; - unsigned long nodes; + X86CPUTopoIDs topo_ids = {0}; + unsigned long nodes = MAX(topo_info->nodes_per_pkg, 1); int shift; - build_core_topology(cs->nr_cores, cpu->core_id, &topo); + x86_topo_ids_from_apicid_epyc(cpu->apic_id, topo_info, &topo_ids); + *eax = cpu->apic_id; /* * CPUID_Fn8000001E_EBX @@ -496,12 +408,8 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, * 3 Core complex id * 1:0 Core id */ - if (cs->nr_threads - 1) { - *ebx = ((cs->nr_threads - 1) << 8) | (topo.node_id << 3) | - (topo.ccx_id << 2) | topo.core_id; - } else { - *ebx = (topo.node_id << 4) | (topo.ccx_id << 3) | topo.core_id; - } + *ebx = ((topo_info->threads_per_core - 1) << 8) | (topo_ids.node_id << 3) | + (topo_ids.core_id); /* * CPUID_Fn8000001E_ECX * 31:11 Reserved @@ -510,9 +418,9 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, * 2 Socket id * 1:0 Node id */ - if (topo.num_nodes <= 4) { - *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << 2) | - topo.node_id; + + if (nodes <= 4) { + *ecx = ((nodes - 1) << 8) | (topo_ids.pkg_id << 2) | topo_ids.node_id; } else { /* * Node id fix up. Actual hardware supports up to 4 nodes. But with @@ -527,10 +435,10 @@ static void encode_topo_cpuid8000001e(CPUState *cs, X86CPU *cpu, * number of nodes. find_last_bit returns last set bit(0 based). Left * shift(+1) the socket id to represent all the nodes. */ - nodes = topo.num_nodes - 1; + nodes -= 1; shift = find_last_bit(&nodes, 8); - *ecx = ((topo.num_nodes - 1) << 8) | (cpu->socket_id << (shift + 1)) | - topo.node_id; + *ecx = (nodes << 8) | (topo_ids.pkg_id << (shift + 1)) | + topo_ids.node_id; } *edx = 0; } @@ -5371,6 +5279,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, uint32_t signature[3]; X86CPUTopoInfo topo_info; + topo_info.nodes_per_pkg = env->nr_nodes; topo_info.dies_per_pkg = env->nr_dies; topo_info.cores_per_die = cs->nr_cores; topo_info.threads_per_core = cs->nr_threads; @@ -5790,20 +5699,20 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, } switch (count) { case 0: /* L1 dcache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l1d_cache, cs, - eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l1d_cache, + &topo_info, eax, ebx, ecx, edx); break; case 1: /* L1 icache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l1i_cache, cs, - eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l1i_cache, + &topo_info, eax, ebx, ecx, edx); break; case 2: /* L2 cache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l2_cache, cs, - eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l2_cache, + &topo_info, eax, ebx, ecx, edx); break; case 3: /* L3 cache info */ - encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache, cs, - eax, ebx, ecx, edx); + encode_cache_cpuid8000001d(env->cache_info_amd.l3_cache, + &topo_info, eax, ebx, ecx, edx); break; default: /* end of info */ *eax = *ebx = *ecx = *edx = 0; @@ -5812,8 +5721,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; case 0x8000001E: assert(cpu->core_id <= 255); - encode_topo_cpuid8000001e(cs, cpu, - eax, ebx, ecx, edx); + encode_topo_cpuid8000001e(&topo_info, cpu, eax, ebx, ecx, edx); break; case 0xC0000000: *eax = env->cpuid_xlevel2; From patchwork Tue Mar 3 19:57:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418737 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 4B89014B7 for ; Tue, 3 Mar 2020 20:04:17 +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 216132073B for ; Tue, 3 Mar 2020 20:04:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="q7Dmvz98" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 216132073B 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]:53138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dm4-0003MC-8U for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:04:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38588) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dg1-0001Vy-CG for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9Dg0-0003Ga-BH for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:01 -0500 Received: from mail-eopbgr750053.outbound.protection.outlook.com ([40.107.75.53]:53821 helo=NAM02-BL2-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 1j9Dg0-0003GE-6I for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YJW2FzYld2CI/NXIB4NCplAiP6ZS6eCLtzljdM/xwfxAY8qZUYJ0MRIusFLmLGacbTA1bTgQuWYhsXbygIXfdkuXYxx2wrS4D8NeOTI6B6LWr7oulOckaO/VHsvEON+6calB+W7MhGA+iZu+1Ybklh+V+UbjtUgeSTi6Z7ZGhKbzanniO3xLiW7WMPxfhI5TiIEU5HuuvO83sLdGIhzMZ64AbQ2Mhs1Zkl4vSyh/ugY1Pvn5dp680J589nE+YaOVHzahUavlJQ0243ieEN53/LS+3VwEKOJRIub6ner6O0Z90AUJf9GH9BmqkHsBM/YukOot/lp1HDI+PECli7cuog== 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=cevM5B3yVpPXgT1/wxHDezjkDgPzHj1xYIdaUUb4uHY=; b=akYq4xxCQgFeyPgJOR74yG0I3AiEqu4WrGNyPk4rK7CWLBU8MM4hP+uXDfkzhyvUyJcDyr6ak4kvFXTMT4eZn3N+2Q5ESVPLju0JaTu2jhfkymW3dsjxwYIKI9C9nzODKqtea+HiaGKlIR+PuFeJlfdXwujF4N85A3Pz8ylWLtBZUgW6T4V0cKXiHQK4dCPbz2a8gbyDmq4EIugsNTQ1LOE3CAXpiRnU2mGJ4OALAholVb+a3AcMgnFXyLw097Xq24q7BcN/0K+UR0lo1rEtKHndT7WXsglneGTj7TOjhRTLLRRRoAbDrfesq4zYQyaJXMAKv4RYhoSw5w4SgewZ4Q== 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=cevM5B3yVpPXgT1/wxHDezjkDgPzHj1xYIdaUUb4uHY=; b=q7Dmvz98vgfdz5sozzh1Z5stto+Q9WpiAHVJ9B0n8F5Db9Di+cbZCR4mr+vCoHnaEJBQ63NcWESife0IL49Ogj2sNPfeJyCvrGHWgxHIIhICROiiwJclVy43IwKJNcKJWId39zB7tA1z8MEt4bZrtYyYM1JPnzMIDOyjX/S/ONs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:57:57 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:57:57 +0000 Subject: [PATCH v5 10/16] hw/i386: Introduce apicid functions inside X86MachineState From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:57:56 -0600 Message-ID: <158326547677.40452.8049125270383618696.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: SN6PR08CA0022.namprd08.prod.outlook.com (2603:10b6:805:66::35) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by SN6PR08CA0022.namprd08.prod.outlook.com (2603:10b6:805:66::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18 via Frontend Transport; Tue, 3 Mar 2020 19:57:57 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ffa12321-b3c6-4871-549c-08d7bfad2b7d X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1107; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: np4trQtBKGUTV5qbE3Hgtn2UaaJszcI1oiWhslK5/uatezV0cMCO5jdSKq8N6fZ2FVF3kt3Jm11sOJOfsELxdy+9di6Qhx7pxMOZU5AFjeYOvtPPUrH8QQ5lWb56/MzZtB5rayoDHDofK6MzcZlfm7Iu6G/rzgi3Rk+AVN3g5naWJpwyuHSke4wSd9LigiZNOkXGAt3BpySAtjTkCxqXR4AXUKBQ1RJPWzCpwcGO6h34/6cTmRhDwl/vQw9Sb0l0nL/Lp31VRGm0X9UiYpgBMTYMgLPw4qUtpHgbqk8tKhGVSSKp3vfgQ5KKntAtWLVSAPJQ+XFDOqC0j558uiLkrJZx0QCsrH9geDttqyvTsu88g5UkkbwNlycmchpx3Lay6VkS+/0kV+QahpTl4HdiFjLYXnnJ/NBb3dM68WWFqOuJ+Cl+5eMjMdkY+N611CCB X-MS-Exchange-AntiSpam-MessageData: tGm9j3zkiNsEYzCMmisQgnn4tHFxgtUn1PIExCS8AyehvKMEj7TnbgYHHIVBVkme36ul/QP18q1eg4GI6IsAMubIAkMOtzWroMkg/x0SPnGoDEZx2iMqLya3o8AJaNGh5lizpuMFhX3j9JQNf9DacQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ffa12321-b3c6-4871-549c-08d7bfad2b7d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:57:57.7675 (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: CnuA7nrZrcrZirujfcV5ZWRDbijX7VP4WB38bOa+hmZtwweLFeCsJQHOcoWtTUTT X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.75.53 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" Introduce model specific apicid functions inside X86MachineState. These functions will be loaded from X86CPUDefinition. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/x86.c | 5 +++++ include/hw/i386/x86.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 929b80c9c7..15b7815bb0 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -911,6 +911,11 @@ static void x86_machine_initfn(Object *obj) x86ms->smm = ON_OFF_AUTO_AUTO; x86ms->max_ram_below_4g = 0; /* use default */ x86ms->smp_dies = 1; + + x86ms->apicid_from_cpu_idx = x86_apicid_from_cpu_idx; + x86ms->topo_ids_from_apicid = x86_topo_ids_from_apicid; + x86ms->apicid_from_topo_ids = x86_apicid_from_topo_ids; + x86ms->apicid_pkg_offset = apicid_pkg_offset; } static void x86_machine_class_init(ObjectClass *oc, void *data) diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 22babcb3bb..2643b57629 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -65,6 +65,15 @@ typedef struct { OnOffAuto smm; + /* Apic id specific handlers */ + uint32_t (*apicid_from_cpu_idx)(X86CPUTopoInfo *topo_info, + unsigned cpu_index); + void (*topo_ids_from_apicid)(apic_id_t apicid, X86CPUTopoInfo *topo_info, + X86CPUTopoIDs *topo_ids); + apic_id_t (*apicid_from_topo_ids)(X86CPUTopoInfo *topo_info, + const X86CPUTopoIDs *topo_ids); + uint32_t (*apicid_pkg_offset)(X86CPUTopoInfo *topo_info); + /* * Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space. From patchwork Tue Mar 3 19:58:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418741 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 28B6B14B7 for ; Tue, 3 Mar 2020 20:05:55 +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 F20542073B for ; Tue, 3 Mar 2020 20:05:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="i/C7D8e2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F20542073B 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]:53170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dne-0006a3-5e for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:05:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38628) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dg7-0001in-RS for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9Dg6-0003Kd-JO for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:07 -0500 Received: from mail-eopbgr680064.outbound.protection.outlook.com ([40.107.68.64]:28798 helo=NAM04-BN3-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 1j9Dg6-0003KY-Dj for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h2xnSEx9m5SDQYn/jDDyq2eoNzVxjhKhZeTGdWMMynGN44h9qXoMTwhL1KZqtIiLwTaFWlN8k+AjY5X7aX04pT6T9ofvy8J4zSx3IPWGiv3ul6XrfXlOttl9r91ANZJUwd5XhbH2vOBzAcGKjWzy5GNiLB0ri+/+U6ezf0cdYZLEzvl5AtELYCFdjimqPi1VBzkNR8vRt5pHAZck1Tfwj4HXvYj9Mrf4+DvvMLxHeF6lmQrVnlyHXEWRFX/zDRk9g+gLrRUGDM4k6X5OrWdGwWbPFOrCeStAd08zsixtpc8KwWBnSJdMUpMPjU9DXMlqyoYXV3FMbxy59ZPht4KT2w== 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=gXycWrgZU9tV/qv3XlKKeojqrHBuZ+t7B3SlRDM9nDY=; b=j7XAxGNWLQzbSlNvVJ0BgNqPxzWOWJP33q3Ce69WdHQB/s+WjFjFA26lA7wszuR6XKUNAT+m5LmJBNoroPuHtq/OvntZfFqyOMF3+u5nsDoCnfzFItsU1YnMHQtjE90f75/LDoN3QGpBa4iY1ZbNFoNJDqNJe0bFSyPk/hS54kfDlIA1JILdkrwLPyGnSWebm2Xd2cyXGb5u0rUH7fcz8NBdQ5aIi3dDMQVNWEKdjf3VoUWBXPG7hiyDcsjNjOrQzxUaVcP87gCi2NK3QtYK3raat6ny/Ke1IyR/kEt5zz0yELBiXBa8gQDTAc1Hv9DoUiDkELhqmV5IE7Ea4y+A7A== 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=gXycWrgZU9tV/qv3XlKKeojqrHBuZ+t7B3SlRDM9nDY=; b=i/C7D8e2DVCVTr+x1TLNjZqbY/cW0J2389UF9CwNkfJfwn3cqVItd1ArOYfdWyMGaT1nqKeeiBsmi4eRtcFhkocI//jk4H1C2F639gq5rcSSBsWqrg2jv6umHijme7jlQXkEUgaiLImr9CaE/KUg4jsn7ZVtYIpqmJfBeih9o0o= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:58:04 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:58:04 +0000 Subject: [PATCH v5 11/16] target/i386: Load apicid model specific handlers from X86CPUDefinition From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:58:03 -0600 Message-ID: <158326548299.40452.4030040738160407065.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM6PR13CA0031.namprd13.prod.outlook.com (2603:10b6:5:bc::44) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by DM6PR13CA0031.namprd13.prod.outlook.com (2603:10b6:5:bc::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.5 via Frontend Transport; Tue, 3 Mar 2020 19:58:03 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c4353582-fe5f-423f-2f72-08d7bfad2fa0 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: JTnx5G9CUSKtDGr88JDRFIFSEQng3GpxJQKxAoi5iK9vqrp7Wjq5r1uLA0vIFaFoYYKW7KcHNarBcV7/jV4XXg9t7PwfsDg6lMd/zbjf2klr46A0O0Xuyy7vWreoj5qsSRyrBhm0hIbFYXvRInSZ/3hahHTEi1DgJvivkCD7FuiKZjVLkrOGifjV+s/Q+ss6Wp9kXg74wifHIgfgFkW8fEfb/Hid6WrNG46WUs0biVn5gi8IgFNxnYHl6vF6YC7sJkHXuQdLejn0UwKfdCAWmYOPk/BgJohc8Nd126+VsS7VBEs1ewdq7/xKVJmgfOkOc72wxhHGGhdCTyQAlXh36Cll6rdfkAtE+9ECHFXPSI5UewU6eKZaOagRFIxpdXI4bKNYGxmIybXNK91jhfrVUReJqYtLEWoDxzqsOmWFat6ESZg/t3oFEP4lOyzSD+fo X-MS-Exchange-AntiSpam-MessageData: pnlU7TP9BAtvvB0vyCSmdrZqVAyL9xR32PVD3RkpjK3oyr0Tn+bn/V9GSKzVIJtY6FDvjA9KKfiOYOc3BvqxngmBeGJNnaD3mBZljfif9UWnxyP6Q2tF1an5XciD+Og+REX3SpC67xikDsvTwLUI0w== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4353582-fe5f-423f-2f72-08d7bfad2fa0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:58:04.7348 (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: vwAHxphApZ6hUJjTx3GLsWQvfMv3Rcf0PLPkg5e8oPMu4u8Oj+1PND/ejJBxN9/H X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.68.64 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" Load the model specific handlers if available or else default handlers will be loaded. Add the model specific handlers if apicid decoding differs from the standard sequential numbering. Signed-off-by: Babu Moger --- target/i386/cpu.c | 34 ++++++++++++++++++++++++++++++++++ target/i386/cpu.h | 1 + 2 files changed, 35 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c75cf744ab..f33d8b77f5 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -51,6 +51,7 @@ #include "sysemu/sysemu.h" #include "sysemu/tcg.h" #include "hw/qdev-properties.h" +#include "hw/i386/x86.h" #include "hw/i386/topology.h" #ifndef CONFIG_USER_ONLY #include "exec/address-spaces.h" @@ -1614,6 +1615,16 @@ typedef struct X86CPUDefinition { FeatureWordArray features; const char *model_id; CPUCaches *cache_info; + + /* Apic id specific handlers */ + uint32_t (*apicid_from_cpu_idx)(X86CPUTopoInfo *topo_info, + unsigned cpu_index); + void (*topo_ids_from_apicid)(apic_id_t apicid, X86CPUTopoInfo *topo_info, + X86CPUTopoIDs *topo_ids); + apic_id_t (*apicid_from_topo_ids)(X86CPUTopoInfo *topo_info, + const X86CPUTopoIDs *topo_ids); + uint32_t (*apicid_pkg_offset)(X86CPUTopoInfo *topo_info); + /* * Definitions for alternative versions of CPU model. * List is terminated by item with version == 0. @@ -1654,6 +1665,29 @@ static const X86CPUVersionDefinition *x86_cpu_def_get_versions(X86CPUDefinition return def->versions ?: default_version_list; } +void cpu_x86_init_apicid_fns(MachineState *machine) +{ + X86CPUClass *xcc = X86_CPU_CLASS(object_class_by_name(machine->cpu_type)); + X86CPUModel *model = xcc->model; + X86CPUDefinition *def = model->cpudef; + X86MachineState *x86ms = X86_MACHINE(machine); + + if (def) { + if (def->apicid_from_cpu_idx) { + x86ms->apicid_from_cpu_idx = def->apicid_from_cpu_idx; + } + if (def->topo_ids_from_apicid) { + x86ms->topo_ids_from_apicid = def->topo_ids_from_apicid; + } + if (def->apicid_from_topo_ids) { + x86ms->apicid_from_topo_ids = def->apicid_from_topo_ids; + } + if (def->apicid_pkg_offset) { + x86ms->apicid_pkg_offset = def->apicid_pkg_offset; + } + } +} + static CPUCaches epyc_cache_info = { .l1d_cache = &(CPUCacheInfo) { .type = DATA_CACHE, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 20abbda647..34f0d994ef 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1895,6 +1895,7 @@ void cpu_clear_apic_feature(CPUX86State *env); void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); void host_vendor_fms(char *vendor, int *family, int *model, int *stepping); +void cpu_x86_init_apicid_fns(MachineState *machine); /* helper.c */ bool x86_cpu_tlb_fill(CPUState *cs, vaddr address, int size, From patchwork Tue Mar 3 19:58:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418745 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 1AFB414B7 for ; Tue, 3 Mar 2020 20:07:00 +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 E5C7220714 for ; Tue, 3 Mar 2020 20:06:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="iQ4Mllfi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5C7220714 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]:53186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Doh-0008NT-6Q for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:06:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38687) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DgE-0001yL-Ab for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9DgD-0003MX-52 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:14 -0500 Received: from mail-eopbgr750080.outbound.protection.outlook.com ([40.107.75.80]:17038 helo=NAM02-BL2-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 1j9DgC-0003ME-VC for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:13 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T36tzclmBouQUsUozpmsfHAQxFt4mbWksy2qlX7wQ+SNOO7YPkubHXnmL/Pyxg8Cgj5xeOGN9+7kU061M1k534SvqRhlnxNA5k5RaqW0uxCOhRvE/3HMcfphNr6y/0IDiaK2D/9j1DbfAI5At6jI1imP1PhiD630J+DeIHl70AeSx5PUk3ONSbZUftynG6dmNdHrAukx30kZJuIphfiguYR/ILkfoGH7lpo2XtlT5OHBGZjq6YWM+923M3DJqkloOEZ9D/XL3GlI7MnS5KGCItJhBRYlqDM1s6lvnGqw1TwcQkFQDx+8DFOSPZkJ6Uq/tE3vdEyE6mhdjcANgCEKdQ== 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=o4MRTCgeO9CNedx9KR/tPEvUxAx2M+BlFOsF2JihnMc=; b=LLfriGqA0PbqR06L4ngXvSQLnk/0SAncoPHS6H0G7LxazkItQclv8xQmbqulbhPArKazWFPJ+vDVjKadKzyKSaJm49kmx1LQTZmdFdybYMDRjAvR9w6rvZD7fxRRBVEn2sHHeBy2PL4IrdcKB3ifp1m2vWDmKVuDvTeXuY2035tsKSTgQMIDdukmVUeLPIIC+SjF70D24ORw49+oz+aL+2PIC2ZX2OQN/AXAam/ZBfb9EKTNleaklG/2/LYQeQB/132yb9IBpv+iQto1LN3oGtMU29i33QFK3IxIddR+5Er00usZa7h0cbnsI1FP9vjptdtVMyxDuNxeyhKXMpWm3w== 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=o4MRTCgeO9CNedx9KR/tPEvUxAx2M+BlFOsF2JihnMc=; b=iQ4MllfiHCQf4ss+3HrHt4EvEv2dcLaTnXMWJjwin75yzcacTdkrqoJ1snVZ06wAWv/xgTu/i9VPdZfv/z7djZBeR2XzkfIBXvORBdePVHs+KxQtIuzVnX8TebxSFwo9IzSGzpI3o8medPxe6HZOmrD9QT2Q5MOIUhgnL0ZBRls= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:58:11 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:58:11 +0000 Subject: [PATCH v5 12/16] hw/i386: Use the apicid handlers from X86MachineState From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:58:10 -0600 Message-ID: <158326548999.40452.9247570542382737462.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM5PR1101CA0011.namprd11.prod.outlook.com (2603:10b6:4:4c::21) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by DM5PR1101CA0011.namprd11.prod.outlook.com (2603:10b6:4:4c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15 via Frontend Transport; Tue, 3 Mar 2020 19:58:10 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5333ce80-77a6-4899-f36d-08d7bfad33b1 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: Kxm0cIary9txP6hQnsnLLLMR/s3vWN3Tmoc1YolZSzQu1WQYtoZNDCj655dZv7GJRJ+H5oujvlcUjTd7wCA1pwWoeVTY7vuWhYu4L2ODQBdkml+Nw2lDNwxyqcu/tpB0409/5ik35fscGOXnEtA/FQpMXBp2JqQCQvRAt9QYNxhh0GIrVyv5uYoUOStEusfvMpZeXXwZ/DvQo7a6Wly0WiB0miIttAbS29pwCm3PeQBU8eGmjVUAkZXcTrB2L2OfaHWN3SBQyEwDdkIeNSL0BoiRRDyDIWWJAFlvUfmTic6PqqY+bz2nhFQlZ2kMEAb52lkIF8eQc5GEiOmgZ5qW/IC71PEvSHpcok3eJ1/ZmoFeQVDyxq8AlpYa0s8Kc8PF2nW+v07tFq+vp8SeHsD7od1OdOxDQgB+9nTkvgwAtRcnLrSYLNLEJdWgiTJ1ZOBR X-MS-Exchange-AntiSpam-MessageData: QwtXJ9vF+z+zl63oStRggVawQXPguzFLS4xq6rldjy/EplZpOhwPHrIgoomIqWefujqGqhRV2qp9xWXmiOhZZELlEog/5pqyviUDELLxKiN2zKgxvv1uGS6+TBcs+Yr1LFcDJDqkH3QG8SvVOeSS+w== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5333ce80-77a6-4899-f36d-08d7bfad33b1 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:58:11.5521 (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: jMQrwQ01IXOVOcs+EKretl0Rv0Cir1lHJAOjnUpDzskVVYpknW2nITcARMDj6mSb X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.75.80 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" Check and Load the apicid handlers from X86CPUDefinition if available. Update the calling convention for the apicid handlers. Signed-off-by: Babu Moger --- hw/i386/pc.c | 6 +++--- hw/i386/x86.c | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 17cce3f074..c600ba0432 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1581,14 +1581,14 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, topo_ids.die_id = cpu->die_id; topo_ids.core_id = cpu->core_id; topo_ids.smt_id = cpu->thread_id; - cpu->apic_id = x86_apicid_from_topo_ids(&topo_info, &topo_ids); + cpu->apic_id = x86ms->apicid_from_topo_ids(&topo_info, &topo_ids); } cpu_slot = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); if (!cpu_slot) { MachineState *ms = MACHINE(pcms); - x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); + x86ms->topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); error_setg(errp, "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" " APIC ID %" PRIu32 ", valid index range 0:%d", @@ -1609,7 +1609,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizefn() * once -smp refactoring is complete and there will be CPU private * CPUState::nr_cores and CPUState::nr_threads fields instead of globals */ - x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); + x86ms->topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); if (cpu->socket_id != -1 && cpu->socket_id != topo_ids.pkg_id) { error_setg(errp, "property socket-id: %u doesn't match set apic-id:" " 0x%x (socket-id: %u)", cpu->socket_id, cpu->apic_id, diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 15b7815bb0..d46dd4ad9e 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -86,7 +86,7 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms, init_topo_info(&topo_info, x86ms); - correct_id = x86_apicid_from_cpu_idx(&topo_info, cpu_index); + correct_id = x86ms->apicid_from_cpu_idx(&topo_info, cpu_index); if (x86mc->compat_apic_id_mode) { if (cpu_index != correct_id && !warned && !qtest_enabled()) { error_report("APIC IDs set in compatibility mode, " @@ -158,8 +158,8 @@ int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) init_topo_info(&topo_info, x86ms); assert(idx < ms->possible_cpus->len); - x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, - &topo_info, &topo_ids); + x86ms->topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, + &topo_info, &topo_ids); return topo_ids.pkg_id % ms->numa_state->num_nodes; } @@ -179,6 +179,9 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) return ms->possible_cpus; } + /* Initialize apicid handlers */ + cpu_x86_init_apicid_fns(ms); + ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) + sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len = max_cpus; @@ -192,7 +195,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) ms->possible_cpus->cpus[i].vcpus_count = 1; ms->possible_cpus->cpus[i].arch_id = x86_cpu_apic_id_from_index(x86ms, i); - x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, + x86ms->topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, &topo_info, &topo_ids); ms->possible_cpus->cpus[i].props.has_socket_id = true; ms->possible_cpus->cpus[i].props.socket_id = topo_ids.pkg_id; From patchwork Tue Mar 3 19:58:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418739 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 C645C17E0 for ; Tue, 3 Mar 2020 20:04:31 +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 9D0A32073B for ; Tue, 3 Mar 2020 20:04:31 +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="ImSiVmoh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D0A32073B 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]:53140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DmI-0003x0-Pm for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:04:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38727) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DgN-0002Dq-Nm for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9DgM-0003Nc-C9 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:23 -0500 Received: from mail-eopbgr680080.outbound.protection.outlook.com ([40.107.68.80]:27877 helo=NAM04-BN3-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 1j9DgM-0003NP-6f for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nrx52wsnwG+i3VapGKFuD7ERY+aibzdPn6tHdj9ePYpLawZaTvYtaNSXV5jk75meZssTaEF7XeCe9ak8oEr1xPoSEz3iwXPyQ2YkOFxFK4Pz6n9F6DpWrP+mI7y9+PD1v6dbZArwmdgRwjE5GMV4G4unR1SPHSSsE0SFk6dXisC4JnmADW9JXaxX4iK2dFtvqWvy0Onm+LUjqUtm22J6Nhat07340KfCvlGaArT4MWEhMfASAd2IcqFUGZk18Uk4sdc8nPUGeC1M6dwFyrm/MTv4c9OVZuUnuUXlUIqGKCsVFOrxS83qg7BQtCRWVeQrvNV/MZvgmfnqdB9OjXqUcQ== 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=6oRuo/lh28/2XJWy4dP6mZpTXzVZAlN3SENyqm0S/p8=; b=MXijhLxL9BZiWZE5oeU/YpwBvl1g6G9UO+ObkYPYInJM115sIxxYFRjkO0dLyhYPfWRUgQs6ynYV06Dm+8MsHa/EiIvUdZ2lN/CWuCOtg1R1vnuEz4ese0JrnDXcF7Mxp+x0IFBb3XCAzhDME7MP4TtKB0px/2sP9YAsFVgMkoGKOgvUhCROztM5zNNhtHIanYV1RzM04xs4+Xd4c6rUD3KJoj94n4XAWhQIUqhFiew4WQbXPBlVv6AJ0+nnBZiTxlCYah2tJGyzOgv4HBepLsVLbq7asNZAuAZ40AiWXpB4MDYY/snzim2WbSzowQdDHbCDxGBmM711DynDqzJf5w== 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=6oRuo/lh28/2XJWy4dP6mZpTXzVZAlN3SENyqm0S/p8=; b=ImSiVmohE+iaTTYNbdQuZOFY91XH4jdNAYriXSPygiqDJNWrbLgP0HT0eVVdHS3tme5dKSzKweuwJxleDfUL22+KF4ot/SHDqdCUqhnfm2JTlf6YSZgsNMUXKz57OsVasO4akUOa+njcxbx8CTCD4kT6rL0wHNb7CPTNGAOi47Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:58:18 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:58:18 +0000 Subject: [PATCH v5 13/16] target/i386: Add EPYC model specific handlers From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:58:16 -0600 Message-ID: <158326549681.40452.14219781294371149597.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM6PR08CA0007.namprd08.prod.outlook.com (2603:10b6:5:80::20) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by DM6PR08CA0007.namprd08.prod.outlook.com (2603:10b6:5:80::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14 via Frontend Transport; Tue, 3 Mar 2020 19:58:17 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 13e008c4-1ec6-4ef2-3d19-08d7bfad37f9 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001)(966005); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: vNkGIYX7+giDPNiCs5a/Vptw9LrFz610efNrHXwVZtsIAKALIRG+xoqqYRTc9xxXgHu8X75mdE1rlRx5i5JkFtDhB0X1AegluolDykn/sVrthR3AFV76uTN3G2YXZOBOhO3fVSiD0Yaqh9dZizF5OqNSYwSiIB+cBES97NqwVQfpofMpKtfXV1YedVY8mwME5QBWOI8lkKDhZTWdLFEUdhTe9TXLJDezBQKQa761Py/wARNr7hJBxS78TUUxYs+cMi/IriOKiWi2Au0dMW/7wAq88I7xmQ236DZwrW/3sJGb4rWJDTLp0m6AtrIDKtGDZINye38VDxM+oeLdD4lvEDWbCf6uNMf6w4IZ2u80a3LeCtsi1wHVSeqx2tB7Qrc9rtd4X6sOSRkZErtrKTiQFam58VKadmAc4prprI6MCQnB9Hz4K67yEpfw0w7WiXY75sWifhXhvprw68cY9kV5qjKjcPnPALVJa9VCewZiqXOlcSq7Cmk6r3fhkJ0jOLijKU99ltKYLRAikc6FDNu0fA== X-MS-Exchange-AntiSpam-MessageData: j3+S2E/b1thR2q+ZizlINipCZCMbm4R91r+8NF9m9EHotmLRd7r/6xZhxAEXHELdZlcKkxm/YicGaTqTahwUPNOYNm/BhmmvY6uy8Nel2Fr28SwG7RFfwfasNdV2oQtFf+iVI8DDCpsbdL8x1GupVw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13e008c4-1ec6-4ef2-3d19-08d7bfad37f9 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:58:18.7331 (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: BNlR4gByN25vr44F8BYxe5+Kzwn8sDb6cs9zWYFq50+z2j1wWQKTDaQrUF458T8G X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.68.80 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" Add the new EPYC model specific handlers to fix the apicid decoding. 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 finds it inconsistent with the enumeration of EPYC cpu models. The more details are in the bug https://bugzilla.redhat.com/show_bug.cgi?id=1728166. 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. It is 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 indicated by Core::X86::Cpuid::SizeId[NC]. Each Core::X86::Apic::ApicId[ApicId] register is preset as follows: • ApicId[6] = Socket ID. • ApicId[5:4] = Node ID. • ApicId[3] = Logical CCX L3 complex ID • ApicId[2:0]= (SMT) ? {LogicalCoreID[1:0],ThreadId} : {1'b0,LogicalCoreID[1:0]} Signed-off-by: Babu Moger Acked-by: Igor Mammedov --- target/i386/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f33d8b77f5..f870f7c55b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3884,6 +3884,10 @@ static X86CPUDefinition builtin_x86_defs[] = { .xlevel = 0x8000001E, .model_id = "AMD EPYC Processor", .cache_info = &epyc_cache_info, + .apicid_from_cpu_idx = x86_apicid_from_cpu_idx_epyc, + .topo_ids_from_apicid = x86_topo_ids_from_apicid_epyc, + .apicid_from_topo_ids = x86_apicid_from_topo_ids_epyc, + .apicid_pkg_offset = apicid_pkg_offset_epyc, .versions = (X86CPUVersionDefinition[]) { { .version = 1 }, { From patchwork Tue Mar 3 19:58:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418743 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 5DDE51395 for ; Tue, 3 Mar 2020 20:06:07 +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 34BC62073B for ; Tue, 3 Mar 2020 20:06:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="3UXqq/Gd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34BC62073B 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]:53172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dnq-0006wZ-Cy for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:06:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38758) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9DgS-0002QQ-Ig for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9DgR-0003Oh-Fr for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:28 -0500 Received: from mail-eopbgr680044.outbound.protection.outlook.com ([40.107.68.44]:12441 helo=NAM04-BN3-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 1j9DgR-0003Oa-Ac for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:27 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gA2lFw3TBojDAZ81xKTsYpR/dnBeI/0f8KI094gZNDLlk8jAU6yEdKYoNIbPcdbXmWXQosFBTRYCGg4CXaRNhhyXx0RV9x2rBwysQvTwEl5FmGlA7A4U8i0t2RPp00o/2tWNEgFn6HqKjAu/L4svGzrrlbrpH8fZxHQCOZQw75rqzPs4xYHBxsmqkEkhVLu43rc9oWKvr/6AFe+9ZwItnOTh2lq8ubsZUpl7wT4WbhMrYJh3ifvAv8eOnMN5fVIn/qB3r/JhpCAerSDz/FqfX/unj3uTMFygVR5mwGwYpoCdH31CeRd42b2osN4W9Z5UhyjNG/ulVQDB/hlW3pA33A== 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=LQ+iUm6fjVmmjcFl73APMr59faKnGQ6BP2PBLUKQJF8=; b=Xp7iCzYi4aQ9H5iaG/2fv7ahRHaDWZKUSsctLgSsDRA9oqpSCXxRVoMhlo0/5BXTzeIvc8AL0YC2/XE04iqaD5gtWM+JGWoG+uQvQi9zva7PIu4zyfIsZTw+DoR0ayW8RhimN5f7pxxosxXFQyyCmMMOtTBmonaPPnRetoRfMlcm7PJH0kGRtIekZZpd05qkIievTJVrr8IoazrHSaPuLzsha5sQCxA6Ss7lUuSx480aN4tuBft3MEzSmxfkSueb0OPaSw+oAGiaeuQ5C0tz5tQI7AX95p9QrrwKGPdEzIcbOy1lrC/P95d+B1RTSEom+GiFFssaFG+7GDk2dMAfKw== 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=LQ+iUm6fjVmmjcFl73APMr59faKnGQ6BP2PBLUKQJF8=; b=3UXqq/Gd9c+pp9/LzA4R/xOphYWsz2viBbknBKdbb8VW4sm0ts7HTWd4hKd4UC3ZIgii2YHEXcpWGMD6XOq6+MRwrwqL/vR+ANu9Z70+T9QRqiiuyCgJlMLWaCbaAXMAoUGRXIWYYmyzBdrW+67Tn42SaNESGdoRdPWGup4MG/Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:58:25 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:58:25 +0000 Subject: [PATCH v5 14/16] hw/i386: Move arch_id decode inside x86_cpus_init From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:58:24 -0600 Message-ID: <158326550403.40452.15934956681175349815.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM6PR13CA0015.namprd13.prod.outlook.com (2603:10b6:5:bc::28) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by DM6PR13CA0015.namprd13.prod.outlook.com (2603:10b6:5:bc::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.5 via Frontend Transport; Tue, 3 Mar 2020 19:58:24 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ddcf8b7d-0a05-48df-c8f2-08d7bfad3c19 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: SSJbfKYw/DKlt9owjqV2VAhz1ZZ5aXd7pFAUEPjBfHL6GiWWO3XTdpEA9JMDJQGfNrab1FQDmYXIkTdIAZzQuLt1G+XjkZ3l/3SUroLOEC3yJRQG9xIDgbp8ER1EIUYdCW+nTQah9VAbYPU5AOwwKtt5Kk814oFI2IBianZqaPR0CI/Fno9TJ3JOQEj8iBzmhnDjnGZeI4zCxmO4BODo6h+ktxb08CA9XxRD3YsSjNyL5SYUwesEMSwh92LZsqVHtrhMoHjJf6j37V/28bGZ+oMU9pL/U3HxoRJT2gvanrf1wfkuZ01/mTtHlKUxJLF4d7qEjE2nFxyN36uoP5Co1rJp5SmzdeUKOonqly4WcyW9ZwmFUlCHgg1dQ0DJgiE6vnsJMpIEFSF7hhYOBqJ0tuvJNCaooo5Jyz8jG/VXxAr2FVaczNxRlFoxFUeH0WRM X-MS-Exchange-AntiSpam-MessageData: tir7xTpsX9g1iPsNSQLOKdHBVzDqKeVG3Y1DbzpWUIg6ZnC2Yc9vAFP95rsFSuHljSiYYPxPn6nGjhIAhQtAdaO+bJNyWp/IUmI9m97m1sFo/nkZtdvc6PsASMPC1suwIz3Y3zoJ+6afiNMgiK9iVQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddcf8b7d-0a05-48df-c8f2-08d7bfad3c19 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:58:25.6423 (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: nsgR53BbDb3Z2O+xmbc2d2vJIUobvrOwF81yRf3uMVOVS3lJg1c/wvgoOCpDuFs6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.68.44 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" Apicid calculation depends on knowing the total number of numa nodes for EPYC cpu models. Right now, we are calculating the arch_id while parsing the numa(parse_numa). At this time, it is not known how many total numa nodes are configured in the system. Move the arch_id inside x86_cpus_init. At this time smp parameter is already completed and numa node information is available. Signed-off-by: Babu Moger --- hw/i386/x86.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index d46dd4ad9e..66998b065c 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -121,6 +121,9 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) MachineState *ms = MACHINE(x86ms); MachineClass *mc = MACHINE_GET_CLASS(x86ms); + /* Initialize apicid handlers first */ + cpu_x86_init_apicid_fns(ms); + x86_cpu_set_default_version(default_cpu_version); /* @@ -134,6 +137,12 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) x86ms->apic_id_limit = x86_cpu_apic_id_from_index(x86ms, ms->smp.max_cpus - 1) + 1; possible_cpus = mc->possible_cpu_arch_ids(ms); + + for (i = 0; i < ms->smp.cpus; i++) { + ms->possible_cpus->cpus[i].arch_id = + x86_cpu_apic_id_from_index(x86ms, i); + } + for (i = 0; i < ms->smp.cpus; i++) { x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id, &error_fatal); } @@ -158,8 +167,7 @@ int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) init_topo_info(&topo_info, x86ms); assert(idx < ms->possible_cpus->len); - x86ms->topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, - &topo_info, &topo_ids); + x86_topo_ids_from_idx(&topo_info, idx, &topo_ids); return topo_ids.pkg_id % ms->numa_state->num_nodes; } @@ -193,10 +201,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) ms->possible_cpus->cpus[i].type = ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count = 1; - ms->possible_cpus->cpus[i].arch_id = - x86_cpu_apic_id_from_index(x86ms, i); - x86ms->topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, - &topo_info, &topo_ids); + x86_topo_ids_from_idx(&topo_info, i, &topo_ids); ms->possible_cpus->cpus[i].props.has_socket_id = true; ms->possible_cpus->cpus[i].props.socket_id = topo_ids.pkg_id; if (x86ms->smp_dies > 1) { From patchwork Tue Mar 3 19:58:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418747 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 A7DE71395 for ; Tue, 3 Mar 2020 20:07:09 +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 7E5EC20714 for ; Tue, 3 Mar 2020 20:07:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="xbAiA/Z0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E5EC20714 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]:53188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Doq-0000DP-Nd for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:07:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38786) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dge-0002jz-1L for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9Dgc-0003QG-Tu for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:39 -0500 Received: from mail-eopbgr750058.outbound.protection.outlook.com ([40.107.75.58]:7696 helo=NAM02-BL2-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 1j9Dgc-0003PT-Ox for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RalJ8o07Bn7sSvZYq6lHvCOkLPOvFtPDgeQCUeMfcuao1HRjH6ihSUh7RnCUE6O0vZOee1jHQpANVzKFDr6c1IOzk3nf5zpG17PUahMogbbDEFt3bWSxKjrOq5IBXSz2iJa1zpk7JdsTR+88q08mLxpCjONMiOMlvCFVsowt7jNpWFDjEM46JetOPZJIQ0PdXdCFlDxp+MQ698yw+Aqp83D4+6ceM0bnvKcAibS9GEk6/UytYlxA/UNqxy4XpCMUl+d1P3N/MRxQHeeZDe0EqG0REBUG3xc+/sFcXWpuNOozpvJLyTHCRShbURNEY73TJPsdwP3zJT5mvCimKcxjOg== 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=pVIC4sKeLph2g2hFlW3C21w+T30yPZ7S6kn+xYiiAnE=; b=UU48yQAhGk/gRwXXwAhWUm3NYJDYf4W/06BwY5Pu/m53lDa7CyMh78r/eGYoHo2BuLdEYkIoV4lZZnYSGl9HWOx/zTl6Oy2d1bwDOR/HDyLq8LBfodc4gfSEcnoOGljkEa3hJTfT5wmE7sNWmEGeR9y0x+40hrGUAObUc6gZUNKqCZr0grMKzu1gPjNHLUCvi6NF6Miwbe2FiBLWbdsBQE52Ymvb5r7tpLo+GdMZMJF2aAyG4orBMMKP9iyKGYr9lptITNWVppWcIKu+xzMgF7ofh3tN0j3LUUPRqBqOub6Ps7dLZVcpCYHlWJuKQob31tl0j02f8qkTIkaPVelZeQ== 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=pVIC4sKeLph2g2hFlW3C21w+T30yPZ7S6kn+xYiiAnE=; b=xbAiA/Z0YcgZpa6ZdIBaIzotZ9RycNtzTmsZk6lhdGlZ6/iPNM0If6JZdNZ0I0FUXpnSJZ2tCtTUAW+HPg/J0gT4f4os0+HFDzwna5zj/IjhoT00r4G433uV47Caog2rPgk7N2JtUsX+nyggWTUjaknznIC6VmSF7GjiVO1zMX4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2573.namprd12.prod.outlook.com (2603:10b6:802:2b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:58:32 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:58:32 +0000 Subject: [PATCH v5 15/16] i386: Fix pkg_id offset for EPYC cpu models From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:58:30 -0600 Message-ID: <158326551090.40452.9028312447486758348.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM6PR08CA0023.namprd08.prod.outlook.com (2603:10b6:5:80::36) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by DM6PR08CA0023.namprd08.prod.outlook.com (2603:10b6:5:80::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.16 via Frontend Transport; Tue, 3 Mar 2020 19:58:31 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 46607dfa-31f1-4869-78f5-08d7bfad4055 X-MS-TrafficTypeDiagnostic: SN1PR12MB2573:|SN1PR12MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(189003)(199004)(2906002)(316002)(81166006)(8676002)(81156014)(8936002)(103116003)(52116002)(5660300002)(55016002)(7696005)(66556008)(66946007)(44832011)(16526019)(186003)(86362001)(956004)(26005)(4326008)(66476007)(478600001)(170073001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2573; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: lZo3Vo/ktCfw1czcjXmPyvH/xzVB/u47bGIOw0wL7tPUdN5jR1EdNgMqLuRVbY4IIXuub/TTEqZBgx7s0cqMlsnovQqM4Cm2es538OIGo5wUw6eievaZ6L511RTKCRG9SempfVuqV5aVoU0nuJcTfkdXeJ4rBTr6P2yFlg7tTR++89CzTdktxkxA+f2jaBgWhLAMcn3ld4ZD7Rvlv0cVPxw8m98BRXV1R+W42MBH0vXvK1tqxrnBmQJUjG77kU6eXprvhUcxAXInhq1MfvGDL/J/u1YsAU2Ou82ATrxOHiyhUybULdpGlYfzomN8l8vqx052sGM8aFK6EM8uOyBwZi2msFI9tfrENYzctvFruk5/psQ9kKIeYjNE9HzvuClaumg8oKg4enljYKvPjXw15IjJn/slEoQ5ZFesrhAZWSmkCOjwH4SReXjcOq5tf28bfe+XbuLvkbpuws/VuUv4rGbbExMBi2LxqmVFNb+LI6IsC01Ro38xDmL0q74oXFPH X-MS-Exchange-AntiSpam-MessageData: ScA3+5/uG5YxfM0xsax/i3fEX5YRZd/HzBjnLMYH3LkgbGfu1yb49NRgPAW4ozYH/HJoLo3BQJ+aRq3TYke3NpZqU2UJEZnBYfLuH7eyMDB4FALVg69vbDw/4p9IsXzJYEDN2DZkzdmQVrPfGMnLFg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46607dfa-31f1-4869-78f5-08d7bfad4055 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:58:32.7624 (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: tivWkLo+E0LXC05s6m0ct5Rie6QtQ0RXn/uyZzak5KpG58pNiTLZ8MkRvEPfYHzA X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2573 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.75.58 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" If the system is numa configured the pkg_offset needs to be adjusted for EPYC cpu models. Fix it calling the model specific handler. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov --- hw/i386/pc.c | 1 + target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c600ba0432..b6237a3a14 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1527,6 +1527,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, env->nr_dies = x86ms->smp_dies; env->nr_nodes = topo_info.nodes_per_pkg; + env->pkg_offset = x86ms->apicid_pkg_offset(&topo_info); /* * If APIC ID is not set, diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f870f7c55b..9b160cbdd1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5503,7 +5503,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(&topo_info); + *eax = env->pkg_offset; *ebx = cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_CORE; break; @@ -5537,7 +5537,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(&topo_info); + *eax = env->pkg_offset; *ebx = env->nr_dies * cs->nr_cores * cs->nr_threads; *ecx |= CPUID_TOPOLOGY_LEVEL_DIE; break; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 34f0d994ef..aac86af5cf 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1608,6 +1608,7 @@ typedef struct CPUX86State { unsigned nr_dies; unsigned nr_nodes; + unsigned pkg_offset; } CPUX86State; struct kvm_msrs; From patchwork Tue Mar 3 19:58:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11418749 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 5B07C921 for ; Tue, 3 Mar 2020 20:08:17 +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 E589420714 for ; Tue, 3 Mar 2020 20:08:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="aZaxk0y1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E589420714 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]:53206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dpw-0001j1-4s for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 Mar 2020 15:08:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38804) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9Dgh-0002sA-3F for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9Dgf-0003Qn-K4 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:43 -0500 Received: from mail-bn8nam11on2067.outbound.protection.outlook.com ([40.107.236.67]:13536 helo=NAM11-BN8-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 1j9Dgf-0003Qb-Dh for qemu-devel@nongnu.org; Tue, 03 Mar 2020 14:58:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WPgRM/pFVigLnQH3cFb0EK9WWlu4VCYw1WtZmPGIBxAp/0FLwYkkXm0fnF6JC/pfjKk7tHdjKHdrAXByz1GQ+zhV5FjRRfGy+qMTlbc3jHzDNVS8OYsH/H3H2oE/3cQUX3VItdQiBfPmR6VbdU0GXom10FeUYtxhFC67zgsakDg6735fkd+STeYUUkllCB3vtdmv1wau2gvU9TJ1TtWvy5aDmKX9r/DjTB/33gzusiAsvxMzPQloqS+b/3Y3laQNveDFXj81SgBxLMCm8gDnDwq8DYyynf5J5z5F00JYyhrLaENcQZjdeOYmqyzLxAoGtje8p61i8eeKn+hUh1x6cQ== 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=hAQb04Z8pY4pWGNtekpdV2h7RNoU2rwJnd2aRbQmSO0=; b=GFG+Shzu5U5qKcJH/SVBUNlrYEw1zp7x+fUQLha5xjQ2/28c0PJtxhVVAk7aRNHu8EvwTSDYO92YGVJhvFFgEcBnrF165GTW9K8+//DQWtLpCEB56EBKVDluC0Fa4ts6B47VvEoY0xqkmMfg539aCYUelflnXtevuHUBtMY0jiutgZjZkyNTl6XuMd4QGdSimAHrz3kW6sCm/HXyzLVgKni405m0f2hMoFRGqPVJyp/gdlO+wscPPZ1wMdg3/098Yfr1gEXYoewK7voeBu8iyyrvs3WG6Xp4+TeoFZFz9iIbV1wGIugfOO1JYFR7V85SFLnpNpeEgPnLbdaRBopOYA== 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=hAQb04Z8pY4pWGNtekpdV2h7RNoU2rwJnd2aRbQmSO0=; b=aZaxk0y1P8eBL7ws63bt/eiZXpejCSOVFTYQeTOgFJCzfvICT1e3zpY7ZZ8nRfydUV8jNWXT+3+Q1OBtCp7EBammbN5nGnV8nkF/kiDqJ0YqR41Gadw3E7Vnt9ibnAXh3qj29NwGanu3Fg9QvFs2TJj1l4xfsh8K8OFQm6s0o30= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) by SN1PR12MB2382.namprd12.prod.outlook.com (2603:10b6:802:2e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Tue, 3 Mar 2020 19:58:39 +0000 Received: from SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93]) by SN1PR12MB2560.namprd12.prod.outlook.com ([fe80::382f:640c:215f:be93%5]) with mapi id 15.20.2772.019; Tue, 3 Mar 2020 19:58:39 +0000 Subject: [PATCH v5 16/16] tests: Update the Unit tests From: Babu Moger To: ehabkost@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, mst@redhat.com, imammedo@redhat.com Date: Tue, 03 Mar 2020 13:58:38 -0600 Message-ID: <158326551802.40452.18371333088303667854.stgit@naples-babu.amd.com> In-Reply-To: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> References: <158326531474.40452.11433722850425537745.stgit@naples-babu.amd.com> User-Agent: StGit/unknown-version X-ClientProxiedBy: DM6PR02CA0043.namprd02.prod.outlook.com (2603:10b6:5:177::20) To SN1PR12MB2560.namprd12.prod.outlook.com (2603:10b6:802:26::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from naples-babu.amd.com (165.204.78.2) by DM6PR02CA0043.namprd02.prod.outlook.com (2603:10b6:5:177::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14 via Frontend Transport; Tue, 3 Mar 2020 19:58:38 +0000 X-Originating-IP: [165.204.78.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 45a0530c-587e-49c2-e497-08d7bfad4471 X-MS-TrafficTypeDiagnostic: SN1PR12MB2382:|SN1PR12MB2382: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(396003)(346002)(376002)(39860400002)(189003)(199004)(186003)(8676002)(8936002)(81166006)(81156014)(26005)(16526019)(15650500001)(5660300002)(478600001)(86362001)(52116002)(7696005)(956004)(316002)(2906002)(66946007)(66476007)(44832011)(66556008)(55016002)(4326008)(103116003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2382; H:SN1PR12MB2560.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: BCL:0; X-Microsoft-Antispam-Message-Info: s52UCjmCXRE/s1MJ5PSX3VPoBTM0lYDP3rVdwEuRAkeMmNfa7yvcLDh8lV5rqhOa+TL6A5ERh8rCGdZQNjxbKz00vt0g3ekCgNKR1EwHVaRBrjsaGnBcYdAebrpmlUAJBPup4hX1lZHuYCdCX5tN6vj9G6QKwihHQNSUBdRicIlMc4TEkLT9CPc/aZy9GsF0a0wVFqLTm9N2/SodtLJTXuM9UmK6KTGq8qInzmxAH00gVfSey8TvLLTtH7nTlBEb+b+Fl9/lR0z25ZnbC9M7+aBDoyl6/DB5aX/839tgH7wZquOf/IXAmNh7oFH8D/lkpkwTIXl50GPephVKAsnPMCRAU2HZdd/udsHE7xWwXCuee4hN9g3E74xca2m/D1ueqc+MGeWxqiz+hfA0BMC8+pYJVEVwMgd0E3GWkfFeIAXFdZWVkWaBR3tS/9rS5UIO X-MS-Exchange-AntiSpam-MessageData: N4RDO7Uogw2DKgm7DQNvZZV5SJhfvBR0gXFSrPt4675b0zWD/2s1D0MBF9hS61dPhz4O93t5JDXB7hPYc4EnnA6GEKnzrXSqjh5dtRjdju79/bB0KpCJDngVoum0ckR4qW1TKHwpN9wfJVPOtcnqZQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45a0530c-587e-49c2-e497-08d7bfad4471 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2020 19:58:39.6615 (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: vVZuMJFgF6csATj7CsHu/gYRgBycvUf4ukEfGLowanrM8BwyFYv+gGaXzSxlE7nd X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2382 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.236.67 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" Since the topology routines have changed, update the unit tests to use the new APIs. Signed-off-by: Babu Moger --- tests/test-x86-cpuid.c | 115 ++++++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 47 deletions(-) diff --git a/tests/test-x86-cpuid.c b/tests/test-x86-cpuid.c index 1942287f33..00553c1d77 100644 --- a/tests/test-x86-cpuid.c +++ b/tests/test-x86-cpuid.c @@ -28,79 +28,100 @@ static void test_topo_bits(void) { + X86CPUTopoInfo topo_info = {0}; + /* simple tests for 1 thread per core, 1 core per die, 1 die per package */ - g_assert_cmpuint(apicid_smt_width(1, 1, 1), ==, 0); - g_assert_cmpuint(apicid_core_width(1, 1, 1), ==, 0); - g_assert_cmpuint(apicid_die_width(1, 1, 1), ==, 0); + topo_info = (X86CPUTopoInfo) {0, 1, 1, 1}; + g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 0); + g_assert_cmpuint(apicid_core_width(&topo_info), ==, 0); + g_assert_cmpuint(apicid_die_width(&topo_info), ==, 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 0), ==, 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 1), ==, 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 2), ==, 2); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 3), ==, 3); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), ==, 0); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), ==, 1); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), ==, 2); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 3), ==, 3); /* Test field width calculation for multiple values */ - g_assert_cmpuint(apicid_smt_width(1, 1, 2), ==, 1); - g_assert_cmpuint(apicid_smt_width(1, 1, 3), ==, 2); - g_assert_cmpuint(apicid_smt_width(1, 1, 4), ==, 2); - - g_assert_cmpuint(apicid_smt_width(1, 1, 14), ==, 4); - g_assert_cmpuint(apicid_smt_width(1, 1, 15), ==, 4); - g_assert_cmpuint(apicid_smt_width(1, 1, 16), ==, 4); - g_assert_cmpuint(apicid_smt_width(1, 1, 17), ==, 5); - - - g_assert_cmpuint(apicid_core_width(1, 30, 2), ==, 5); - g_assert_cmpuint(apicid_core_width(1, 31, 2), ==, 5); - g_assert_cmpuint(apicid_core_width(1, 32, 2), ==, 5); - g_assert_cmpuint(apicid_core_width(1, 33, 2), ==, 6); - - g_assert_cmpuint(apicid_die_width(1, 30, 2), ==, 0); - g_assert_cmpuint(apicid_die_width(2, 30, 2), ==, 1); - g_assert_cmpuint(apicid_die_width(3, 30, 2), ==, 2); - g_assert_cmpuint(apicid_die_width(4, 30, 2), ==, 2); + topo_info = (X86CPUTopoInfo) {0, 1, 1, 2}; + g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 1); + topo_info = (X86CPUTopoInfo) {0, 1, 1, 3}; + g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 2); + topo_info = (X86CPUTopoInfo) {0, 1, 1, 4}; + g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 2); + + topo_info = (X86CPUTopoInfo) {0, 1, 1, 14}; + g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 4); + topo_info = (X86CPUTopoInfo) {0, 1, 1, 15}; + g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 4); + topo_info = (X86CPUTopoInfo) {0, 1, 1, 16}; + g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 4); + topo_info = (X86CPUTopoInfo) {0, 1, 1, 17}; + g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 5); + + + topo_info = (X86CPUTopoInfo) {0, 1, 30, 2}; + g_assert_cmpuint(apicid_core_width(&topo_info), ==, 5); + topo_info = (X86CPUTopoInfo) {0, 1, 31, 2}; + g_assert_cmpuint(apicid_core_width(&topo_info), ==, 5); + topo_info = (X86CPUTopoInfo) {0, 1, 32, 2}; + g_assert_cmpuint(apicid_core_width(&topo_info), ==, 5); + topo_info = (X86CPUTopoInfo) {0, 1, 33, 2}; + g_assert_cmpuint(apicid_core_width(&topo_info), ==, 6); + + topo_info = (X86CPUTopoInfo) {0, 1, 30, 2}; + g_assert_cmpuint(apicid_die_width(&topo_info), ==, 0); + topo_info = (X86CPUTopoInfo) {0, 2, 30, 2}; + g_assert_cmpuint(apicid_die_width(&topo_info), ==, 1); + topo_info = (X86CPUTopoInfo) {0, 3, 30, 2}; + g_assert_cmpuint(apicid_die_width(&topo_info), ==, 2); + topo_info = (X86CPUTopoInfo) {0, 4, 30, 2}; + g_assert_cmpuint(apicid_die_width(&topo_info), ==, 2); /* build a weird topology and see if IDs are calculated correctly */ /* This will use 2 bits for thread ID and 3 bits for core ID */ - g_assert_cmpuint(apicid_smt_width(1, 6, 3), ==, 2); - g_assert_cmpuint(apicid_core_offset(1, 6, 3), ==, 2); - g_assert_cmpuint(apicid_die_offset(1, 6, 3), ==, 5); - g_assert_cmpuint(apicid_pkg_offset(1, 6, 3), ==, 5); - - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 0), ==, 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1), ==, 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2), ==, 2); - - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1 * 3 + 0), ==, + topo_info = (X86CPUTopoInfo) {0, 1, 6, 3}; + g_assert_cmpuint(apicid_smt_width(&topo_info), ==, 2); + g_assert_cmpuint(apicid_core_offset(&topo_info), ==, 2); + g_assert_cmpuint(apicid_die_offset(&topo_info), ==, 5); + g_assert_cmpuint(apicid_pkg_offset(&topo_info), ==, 5); + + topo_info = (X86CPUTopoInfo) {0, 1, 6, 3}; + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), ==, 0); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), ==, 1); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), ==, 2); + + topo_info = (X86CPUTopoInfo) {0, 1, 6, 3}; + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 0), ==, (1 << 2) | 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1 * 3 + 1), ==, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 1), ==, (1 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1 * 3 + 2), ==, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 2), ==, (1 << 2) | 2); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2 * 3 + 0), ==, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2 * 3 + 0), ==, (2 << 2) | 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2 * 3 + 1), ==, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2 * 3 + 1), ==, (2 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2 * 3 + 2), ==, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2 * 3 + 2), ==, (2 << 2) | 2); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 5 * 3 + 0), ==, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 5 * 3 + 0), ==, (5 << 2) | 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 5 * 3 + 1), ==, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 5 * 3 + 1), ==, (5 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 5 * 3 + 2), ==, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 5 * 3 + 2), ==, (5 << 2) | 2); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 6 * 3 + 0 * 3 + 0), ==, (1 << 5)); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 6 * 3 + 1 * 3 + 1), ==, (1 << 5) | (1 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 3 * 6 * 3 + 5 * 3 + 2), ==, (3 << 5) | (5 << 2) | 2); }