From patchwork Fri Sep 6 19:12:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 1159188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="JXYhMNYw"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 46Q6sF3HyTz9sDB for ; Sat, 7 Sep 2019 05:22:55 +1000 (AEST) Received: from localhost ([::1]:59616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Joq-0004Kq-CB for incoming@patchwork.ozlabs.org; Fri, 06 Sep 2019 15:22:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42528) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6JfL-0003AJ-Cj for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:13:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6JfI-0004PV-UC for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:13:03 -0400 Received: from mail-eopbgr700077.outbound.protection.outlook.com ([40.107.70.77]:48986 helo=NAM04-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i6JfH-0004O1-WF for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:13:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bgTCPWyjGmNbJeMZmjspsoGSEb3bCZVGTryiV7BC4LF6io0bMEnIrtVpHQcHVwfW2TohFDI11Kz6R0FSpMJ4NG/aY+NjOU4pHrHYPIEZsG33A4dm7d/Y6GiHg/UNOnVe28NL10nxbWr5NfOyW9/JYouT5Wgv+kpqLnwxZ5y9iOBMnr56EEvH/VFp6/rXXKksRl2xZVfYI62LQ4o1JhyrrRxqeHUcMywdt0jiR8p0vpML4q1iFVp5MSywUGDvVqY6D4PWcO/ezN5EmizLp+Lrm/OA2HiwDsp52Q4lG4iVXLjTVmlKsT0QZqUvCuV/4tb+pfkJ8mzuoLYRXhbjxRGgDQ== 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=H6sm/L5YDA9nKqo5gYoqdbi/XTlgbgfahEqjmf00VKk=; b=R3kOmj6RBItdBbstoW9+VWjoWjmyuBeUe0MEpWCjRtA6wg9iTfYKt15jB3dKoHNIuY3HI2N1os8zueVhZ6XphuLaFFNmJgIdpIbaqGmw4Zh7VvILByr0aOrodEtczJea2+1j2nwtafa12kUyJcxG5Tk0gXqPsLF94tQoeMrHhIurrBBHHBaOxiZZMRJ8zZ/BrN7Ab0P7EJHhIKnjwwv7oaul7xQgDWg5k15Dnu6KBvutVteSh8OtksPTQEvQe1bLZfrzdFKGYhSCdDcV+898noMT4mKtjCVMVK5wm7qc/gh8fn7l6qTgGqxeE48eINPpS8ajeR2M8XRAPLyP/J5QHA== 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=H6sm/L5YDA9nKqo5gYoqdbi/XTlgbgfahEqjmf00VKk=; b=JXYhMNYw3+8TYvKvA4V6EXGX1K46sDsy5fH+Xh2fHBEMSNJ+dYb42RA8LdaLAJ7LYdkkQoVegJ2cWOOx0Rsz3MVgCqpNqRx+GYqqbFcQM1T7jPuBr2Ma5ptTQWHWCqKKWeJQ6oIGlV48cSKdiu0NKITEQZ66ZJ38QFBrrR77VOg= Received: from DM5PR12MB2471.namprd12.prod.outlook.com (52.132.141.138) by DM5PR12MB1145.namprd12.prod.outlook.com (10.168.238.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2241.14; Fri, 6 Sep 2019 19:12:56 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8%3]) with mapi id 15.20.2220.022; Fri, 6 Sep 2019 19:12:56 +0000 From: "Moger, Babu" To: ssg.sos.staff , "ehabkost@redhat.com" , "marcel.apfelbaum@gmail.com" , "mst@redhat.com" , "pbonzini@redhat.com" , "rth@twiddle.net" , "eblake@redhat.com" , "armbru@redhat.com" , "imammedo@redhat.com" Thread-Topic: [RFC 2 PATCH 11/16] Introduce-topo_ids_from_apicid-handler Thread-Index: AQHVZOcWMrF/C1DABUG5/VPpbi5v/g== Date: Fri, 6 Sep 2019 19:12:55 +0000 Message-ID: <156779717413.21957.2843856950982088519.stgit@localhost.localdomain> References: <156779689013.21957.1631551572950676212.stgit@localhost.localdomain> In-Reply-To: <156779689013.21957.1631551572950676212.stgit@localhost.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN6PR06CA0004.namprd06.prod.outlook.com (2603:10b6:805:8e::17) To DM5PR12MB2471.namprd12.prod.outlook.com (2603:10b6:4:b5::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 52c459a6-c936-484c-2a5e-08d732fe38ec x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DM5PR12MB1145; x-ms-traffictypediagnostic: DM5PR12MB1145: x-ld-processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3968; x-forefront-prvs: 0152EBA40F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(396003)(366004)(39860400002)(136003)(346002)(199004)(189003)(2201001)(71190400001)(305945005)(7736002)(9686003)(52116002)(86362001)(71200400001)(6116002)(8936002)(6512007)(3846002)(6436002)(11346002)(103116003)(99286004)(6506007)(6486002)(26005)(4326008)(14454004)(5660300002)(386003)(476003)(102836004)(2906002)(25786009)(76176011)(2501003)(53936002)(8676002)(66446008)(446003)(186003)(66556008)(486006)(66946007)(66476007)(64756008)(110136005)(81166006)(81156014)(478600001)(66066001)(256004)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1145; H:DM5PR12MB2471.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: kty3Ft8Kz0yM/SXq7XwHjNf4QgKNDsz3+wfT5BintZe4NWV0ArlVLiRywmrpQK3Sq8wqvJXOq5m74ad7VL6EiU34WZs3015S252AZoCre+d/vpMDBSDmSu9UG9tP5z9pDcuCROW6G5nIUjwDsTwooSJ0UwXfcMY5rwiB4+LJqigWRE+TB0ca8bzmHptVyAE56JHtDR1gPDYVlBWhXDn1ZDVi1tdGbGKxM2CpyCca/HUcoYUKWX2MX/OhyUgsY0tmWtWBcQeFqqMG+elyvgQ+pbwcG7ZHjagYI+AbLY3RfOZxsnywFH8xqC/nixe6DbFbMyRODRHEDJooE+dE9sEVvchk/Mn9M98UGXVbRf/Y4wQKDmsqOquhsQOHpaiqImqXTZPpd0MsRZ8jvLRK6WRTi25UfNwSyvkogh2kv9C14So= Content-ID: <24A7FDFEAC85D043A764D1EDE8FDB395@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52c459a6-c936-484c-2a5e-08d732fe38ec X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2019 19:12:55.9854 (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: Yc5awS5aUURPfVnE7PHFWKQXPn3yZIrneLBObX67lknTY+lKcIZDeeQzCpbK4gdH X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1145 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.70.77 Subject: [Qemu-devel] [RFC 2 PATCH 11/16] Introduce-topo_ids_from_apicid-handler 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" hw/i386: Introduce topo_ids_from_apicid handler PCMachineState Add function pointer topo_ids_from_apicid in PCMachineState. Initialize with correct handler based on mode selected. x86_apicid_from_cpu_idx will be the default handler. Signed-off-by: Babu Moger --- hw/i386/pc.c | 13 +++++++------ include/hw/i386/pc.h | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 69a6b82186..c88de09350 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2461,7 +2461,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, if (!cpu_slot) { MachineState *ms = MACHINE(pcms); - x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); + pcms->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", @@ -2482,7 +2482,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); + pcms->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, topo_ids.pkg_id); @@ -2830,6 +2830,7 @@ static void pc_machine_initfn(Object *obj) /* Initialize the apic id related handlers */ pcms->apicid_from_cpu_idx = x86_apicid_from_cpu_idx; + pcms->topo_ids_from_apicid = x86_topo_ids_from_apicid; pc_system_flash_create(pcms); } @@ -2872,8 +2873,8 @@ static int64_t pc_get_default_cpu_node_id(const MachineState *ms, int idx) initialize_topo_info(&topo_info, pcms, ms); assert(idx < ms->possible_cpus->len); - x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, - &topo_info, &topo_ids); + pcms->topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, + &topo_info, &topo_ids); return topo_ids.pkg_id % nb_numa_nodes; } @@ -2906,8 +2907,8 @@ static const CPUArchIdList *pc_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(pcms, i); - x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, - &topo_info, &topo_ids); + pcms->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; ms->possible_cpus->cpus[i].props.has_die_id = true; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 6cefefdd57..9a40f123d0 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -69,6 +69,8 @@ struct PCMachineState { /* 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); /* Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space. */