From patchwork Fri Sep 6 19:13:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 11135865 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 E074816B1 for ; Fri, 6 Sep 2019 19:18:37 +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 AD10B206BB for ; Fri, 6 Sep 2019 19:18:37 +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="yek2ma7+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD10B206BB 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]:59588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6Jki-0000hs-1P for patchwork-qemu-devel@patchwork.kernel.org; Fri, 06 Sep 2019 15:18:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42565) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i6JfQ-0003DI-MN for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:13:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i6JfP-0004RO-ED for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:13:08 -0400 Received: from mail-co1nam04on062a.outbound.protection.outlook.com ([2a01:111:f400:fe4d::62a]:33435 helo=NAM04-CO1-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 1i6JfN-0004Qd-OS for qemu-devel@nongnu.org; Fri, 06 Sep 2019 15:13:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nyswW4EfQR23jAHUZ41veKGYteEfBxO7i44r8U5TihGIL6EniE4HmjLDCU58XCnO5xjOKZPo33L1AgIghS72lzOARjVRFffuIDi14k0U531mPjedaacto9T91I26sDC/7NWofwlcltlR9s7A0h6VbC0FS+soHLrOEmnlB3N9pVAtNHpm8xD0VHo4s1fLmzJVunE+lq+5rR66v/C88wMmOyLIxt6I/WhQL2PIq3DrHyGwsKLYnNhsWdgWPTDNtxia3gYerF6Xoxh5xqz3gB5nKFYHKnRzKI9tL5b03+lJEoHtE15dGsKo2Yxb3Cw5ajDikHBe7qdcyZ+DydmstPHYbA== 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=9lk9i52IXa7cTPHDgznIIL4vW6w2thRKXFNd/NEINbY=; b=dnfNjBhCgCKZOow5BLSuOWB925IfVmUvftFUbgn2HzfFjc4QM5lR7IBi9yKwXUH5Qr4Knfm80FysjP7pZYXDycQlmKuvX+Q4zc7K80eHA5tyiWkhV8zl3MFuL8BbYtwSC7+XzLoXUlJj+b9SFofpHbwqE3nTIn0NDAw118qmdd8jxQ5uyySskYqc7NjPy40N7pN908fCqgjMOAW+XcR/12MGoF4pFvLZdARLSsr8obj75c5JZbeW7k0aqmOTRZaNztNwMoL4KttUI6EC+7X/47i0lR3cRIAcpf07ibcGa92ZDg5sw7IFRn4APnmQXJWr0ve6PD0mGx2vxXV8MSZGBw== 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=9lk9i52IXa7cTPHDgznIIL4vW6w2thRKXFNd/NEINbY=; b=yek2ma7+zA6v8r1aJ+zvvIrKZsX6MsREyn12OKrE5gL8wUqDHLaz2PS6srUK/BHjlevLXCvfWi/XFWF5Ib5tsfRnW9fx5PLHGcRwu4Mmx72WzkRwD+LyBgILqgPyDCAirhYaO4IEGEzQi0b1Y7Bbp9ZItAPB7EAuk3vccTE0GYU= 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:13:02 +0000 Received: from DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8]) by DM5PR12MB2471.namprd12.prod.outlook.com ([fe80::6c7c:4b6d:f136:1bf8%3]) with mapi id 15.20.2220.022; Fri, 6 Sep 2019 19:13:02 +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 12/16] hw/i386: Introduce apic_id_from_topo_ids handler in PCMachineState Thread-Index: AQHVZOcaItEosya+MEKaCAT2nutfDg== Date: Fri, 6 Sep 2019 19:13:02 +0000 Message-ID: <156779718115.21957.699621482515468870.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: SN4PR0601CA0009.namprd06.prod.outlook.com (2603:10b6:803:2f::19) 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: 87a6f11a-352c-4c8d-6856-08d732fe3d2c 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:7219; 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: kgSQG/Qk4jKYR/QNAy0AqByZ8ycEyWXe9GvO2qbUMc3C0mVwEgFw8Qd8EP4397uB2zwK6zPj5d6USgcjbG/eTJJuWwzuZEgx9SdTCYq7lKnnDpp2G65vxUUpv32b40YHhHR6oqucc7fw4h/5084KtJJJJrqdexNI+jIkMQd/dF/xATWsZKBhD/9Y77K6fCQXhOq/rINFd5UXXVwYjurHJXQiYckVJHIUl2/msGKoxOG1jPMnskx7qLKUGoAfu/9LlS9WxSdnKob30WMmcBqeU7oyrpPuYAH0yPzIsI5WiPVNlGTMNXEjNXfkIziLmYOpu+RLuGCuLN6jKUHlqd48CkmHENSL0z3/HUeX3OAf63dPksRRp0xoy7u2UItCR5h7WhcpC4fkuC1UYd3OIz8Q8QZyxPJGXOa9xtIoJ5TTh+k= Content-ID: <72118726988BF64CBE69A5D1E53A9C88@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87a6f11a-352c-4c8d-6856-08d732fe3d2c X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2019 19:13:02.6886 (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: uNBLapWs3Pw8W2qdNj5ejbwmU7RWAbSZ1HSQxxqzwGpVzzIDxEULwB7UopaFSx/Y X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1145 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe4d::62a Subject: [Qemu-devel] [RFC 2 PATCH 12/16] hw/i386: Introduce apic_id_from_topo_ids handler in PCMachineState 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 function pointer apic_id_from_topo_ids in PCMachineState. Initialize with correct handler based on the mode selected. Also rename the handler apicid_from_topo_ids to x86_apicid_from_topo_ids for consistency. x86_apicid_from_topo_ids will be the default handler. Signed-off-by: Babu Moger --- hw/i386/pc.c | 3 ++- include/hw/i386/pc.h | 2 ++ include/hw/i386/topology.h | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c88de09350..959bd3821b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2454,7 +2454,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev, topo_ids.ccx_id = cpu->ccx_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 = pcms->apicid_from_topo_ids(&topo_info, &topo_ids); } cpu_slot = pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); @@ -2831,6 +2831,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; + pcms->apicid_from_topo_ids = x86_apicid_from_topo_ids; pc_system_flash_create(pcms); } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 9a40f123d0..d6f1189997 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -71,6 +71,8 @@ struct PCMachineState { 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); /* Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space. */ diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 6fd4184f07..740e66970d 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -294,7 +294,7 @@ static inline apic_id_t x86_apicid_from_cpu_idx_epyc(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, +static inline apic_id_t x86_apicid_from_topo_ids(X86CPUTopoInfo *topo_info, const X86CPUTopoIDs *topo_ids) { unsigned nr_dies = topo_info->nr_dies; @@ -356,7 +356,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 */