From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494366; cv=none; d=zohomail.com; s=zohoarc; b=eyaVMiwyvDJXXaoQ7gKPEij5DUzQyzYVjvvF7Rbo8cLFvLoi8vm0hUy16zPrXjdybIOpsNSINrzWQx9B6U9CUAQnniBt0+gqIvrdW9iOYyZfpRY+yiVaYuxBHPtIcyxuKMWsW8Z6reuUj9Gj+cHV53pQHk3gyrM5H+AoHUkJQ9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494366; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CK5kzJ8d8O/59rh7LEbO3PEtQpsX5CEGwc3ZD2EiWog=; b=GeiOk9vKDknGljXI050PWegvx2s0vmr2QKmT++9T6klnW//bRtQoPmaaoMSmrlEVmDjLJfkmYBnOuBNiR/W3ILdSBaIuXVlgzrv3FvaF7xHw1shQO78apsWMAm4B0ybHB9vCmcG50Kr8IqIV4y4XsXGa9ESQse8i5EpeCqELL10= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494366218794.3438670159827; Tue, 17 Mar 2020 18:19:26 -0700 (PDT) Received: from localhost ([::1]:43976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENMj-0005KQ-0U for importer@patchew.org; Tue, 17 Mar 2020 21:19:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34035) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLJ-0003sG-GU for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:17:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLI-0000NZ-G0 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:17:57 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:54617) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLI-0000N0-CS for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:17:56 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-i-Xv86HyNEKb93M2Fw5RgA-1; Tue, 17 Mar 2020 21:17:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C721E477; Wed, 18 Mar 2020 01:17:52 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BBFD1001938; Wed, 18 Mar 2020 01:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494276; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CK5kzJ8d8O/59rh7LEbO3PEtQpsX5CEGwc3ZD2EiWog=; b=GRYPZxRLTIyfCafhbFCPZtPMLAiyF40oSnrl7DvIFn5hGwsSEIeSy9V8ZFIKk5e74F6mX0 LUYvduTdmB35SZ3NHwgo67c0mhaKNXDevPAl+vdemON17LpytVTGctT5HQQa+yBZr8Wvne KJPAnfTBNuMkoMbbYG4vMkxiBMJ1Cyw= X-MC-Unique: i-Xv86HyNEKb93M2Fw5RgA-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 01/13] target/i386: Add Denverton-v2 (no MPX) CPU model Date: Tue, 17 Mar 2020 21:17:36 -0400 Message-Id: <20200318011748.2104336-2-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Tao Xu , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tao Xu Because MPX is being removed from the linux kernel, remove MPX feature from Denverton. Signed-off-by: Tao Xu Message-Id: <20200212081328.7385-2-tao3.xu@intel.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 92fafa2659..c3b5cf1369 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3592,6 +3592,18 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .features[FEAT_VMX_VMFUNC] =3D MSR_VMX_VMFUNC_EPT_SWITCHING, .xlevel =3D 0x80000008, .model_id =3D "Intel Atom Processor (Denverton)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + .props =3D (PropValue[]) { + { "monitor", "off" }, + { "mpx", "off" }, + { /* end of list */ }, + }, + }, + { /* end of list */ }, + }, }, { .name =3D "Snowridge", --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494495; cv=none; d=zohomail.com; s=zohoarc; b=giI4dozPnY4eq1856dRRFccHD/96gfHA3DnVpY4nvUzvmWHcPcNwwRFr+9P4K7wj2K/AtdIx/acDsNI1hMQkP03WCXrrGMPF4rtP7R+esEdeo/faSuQnMefPdbhs5KSlDFkoP05BMircmpUN8+LuJ5UUPeXhOF4vYiHcwF4chjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494495; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6sdTixl3XvFiBYSntPyXi7dFn3qA9pvkmLi2kk9CoQg=; b=nzYqO4QKBqa/mp1dgifTNu0ldU64ELLUmc73f8aWihvnifvMT/aLLRPTJWmwDvntXAYtZHSL/tKdeU1a7YOTv8k/foa6TT29ZfEHpSK6FScMqXs4HJRIUpC1JbhzR8ExjGLZ0zKqkJFkNPwN7orfPBekds8+7kDbo6ptr+0iSAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494495845279.30124502366505; Tue, 17 Mar 2020 18:21:35 -0700 (PDT) Received: from localhost ([::1]:44014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENOo-00006a-P8 for importer@patchew.org; Tue, 17 Mar 2020 21:21:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34098) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLM-0003sx-0K for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLK-0000da-Rv for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:17:59 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:56774) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLK-0000cG-O0 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:17:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-qkcd4dzvMgqcR21qo2gXCQ-1; Tue, 17 Mar 2020 21:17:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F7C2107ACC7; Wed, 18 Mar 2020 01:17:55 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id D335B8FBE9; Wed, 18 Mar 2020 01:17:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6sdTixl3XvFiBYSntPyXi7dFn3qA9pvkmLi2kk9CoQg=; b=cITuwTKQIz44GO7g0LnFgroVnItXo7LBlaTZdOmPvEeHzjfVRfpC2TkOe/ojUAkEZK2ax5 rCF8Wo6nC+BcfTJUHr5IATFKX45fcOVJsh2REUkgckiiyddNdc6e9z5v+YwNBHWTyPlyQi MSGB4iBW/mhg6Em0steD7QdNIorikRc= X-MC-Unique: qkcd4dzvMgqcR21qo2gXCQ-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 02/13] target/i386: Add new property note to versioned CPU models Date: Tue, 17 Mar 2020 21:17:37 -0400 Message-Id: <20200318011748.2104336-3-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Tao Xu , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tao Xu Add additional information for -cpu help to indicate the changes in this version of CPU model. Suggested-by: Eduardo Habkost Signed-off-by: Tao Xu Message-Id: <20200212081328.7385-4-tao3.xu@intel.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c3b5cf1369..dc78494167 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1690,6 +1690,7 @@ typedef struct PropValue { typedef struct X86CPUVersionDefinition { X86CPUVersion version; const char *alias; + const char *note; PropValue *props; } X86CPUVersionDefinition; =20 @@ -1720,6 +1721,7 @@ struct X86CPUModel { X86CPUDefinition *cpudef; /* CPU model version */ X86CPUVersion version; + const char *note; /* * If true, this is an alias CPU model. * This matters only for "-cpu help" and query-cpu-definitions @@ -4861,6 +4863,7 @@ static void x86_cpu_list_entry(gpointer data, gpointe= r user_data) g_autofree char *name =3D x86_cpu_class_get_model_name(cc); g_autofree char *desc =3D g_strdup(cc->model_description); g_autofree char *alias_of =3D x86_cpu_class_get_alias_of(cc); + g_autofree char *model_id =3D x86_cpu_class_get_model_id(cc); =20 if (!desc && alias_of) { if (cc->model && cc->model->version =3D=3D CPU_VERSION_AUTO) { @@ -4869,11 +4872,14 @@ static void x86_cpu_list_entry(gpointer data, gpoin= ter user_data) desc =3D g_strdup_printf("(alias of %s)", alias_of); } } + if (!desc && cc->model && cc->model->note) { + desc =3D g_strdup_printf("%s [%s]", model_id, cc->model->note); + } if (!desc) { - desc =3D x86_cpu_class_get_model_id(cc); + desc =3D g_strdup_printf("%s", model_id); } =20 - qemu_printf("x86 %-20s %-48s\n", name, desc); + qemu_printf("x86 %-20s %-58s\n", name, desc); } =20 /* list available CPU models and flags */ @@ -5350,6 +5356,7 @@ static void x86_register_cpudef_types(X86CPUDefinitio= n *def) x86_cpu_versioned_model_name(def, vdef->version); m->cpudef =3D def; m->version =3D vdef->version; + m->note =3D vdef->note; x86_register_cpu_model_type(name, m); =20 if (vdef->alias) { --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494380; cv=none; d=zohomail.com; s=zohoarc; b=T34TnqTBn7rTcxaNkSpyX/uRu59d3+PEmEbMJAkDmWjOmTjr5b+hsJpLIjVg8/iYui5YsXUHIZ7HhFbjpN1HrVp3XqbZ8ANSiyrGXZNLX4OupgtkdD3whAQx3vZfanTrCOht3r7BoVbW/yfpvflRVKUe2ZMDrxL/Pu5lq3HGb9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494380; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nNkB6gdZNo2jzcrcDf6k9nZn60z3vJ1C/KO3xYtIHdQ=; b=c+AIhFWrzJNsCExlYWGfmvgTxMddSxiAO3H8EcBVKMMI8d6/mWBkWuhjE7tEkt1XArUvZIB+UMHtw9Yn8KsoSr/4/9hebdYXE+6RgtU4JrB+ZxIBawZwz+qH60YdGHHsusIrYMWJbwNcmR51Vl9UIR7LiFuzAqTnczPqxpXpNPY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494380399124.2535906152184; Tue, 17 Mar 2020 18:19:40 -0700 (PDT) Received: from localhost ([::1]:43982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENMx-0005jI-BP for importer@patchew.org; Tue, 17 Mar 2020 21:19:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34174) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLQ-00040I-Qx for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLP-0000zz-KP for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:04 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:29223) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLP-0000yJ-Fb for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-gK5R7Wh1M5KG5IVzAUPgeg-1; Tue, 17 Mar 2020 21:17:58 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B5E15800D50; Wed, 18 Mar 2020 01:17:57 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A48B5D9E5; Wed, 18 Mar 2020 01:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nNkB6gdZNo2jzcrcDf6k9nZn60z3vJ1C/KO3xYtIHdQ=; b=FTG6E1lU71Y5DH+E8nllHPgbNld8l1jCjeC2ujXfOPqEzH2uWZZyWMzxuKIKTifPLparUA CyqXWuBGEsoNaJchLjVsoU/76WMVq7oLG5545Q+hUOdI0Ydis4EG6n4I8Q6SSHK9sOIX11 r26m2Vfs7IPJy0mwUhf1FpPUAcDwZrE= X-MC-Unique: gK5R7Wh1M5KG5IVzAUPgeg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 03/13] i386: Add missing cpu feature bits in EPYC model Date: Tue, 17 Mar 2020 21:17:38 -0400 Message-Id: <20200318011748.2104336-4-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , "Moger, Babu" , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Moger, Babu" Adds the following missing CPUID bits: perfctr-core : core performance counter extensions support. Enables the VM to use extended performance counter support. It enables six programmable counters instead of 4 counters. clzero : instruction zeroes out the 64 byte cache line specified in R= AX. xsaveerptr : XSAVE, XSAVE, FXSAVEOPT, XSAVEC, XSAVES always save error pointers and FXRSTOR, XRSTOR, XRSTORS always restore error pointers. ibpb : Indirect Branch Prediction Barrie. xsaves : XSAVES, XRSTORS and IA32_XSS supported. Depends on following kernel commits: 40bc47b08b6e ("kvm: x86: Enumerate support for CLZERO instruction") 504ce1954fba ("KVM: x86: Expose XSAVEERPTR to the guest") 52297436199d ("kvm: svm: Update svm_xsaves_supported") These new features will be added in EPYC-v3. The -cpu help output after the= change. x86 EPYC-v1 AMD EPYC Processor x86 EPYC-v2 AMD EPYC Processor (with IBPB) x86 EPYC-v3 AMD EPYC Processor Signed-off-by: Babu Moger Message-Id: <157314965662.23828.3063243729449408327.stgit@naples-babu.amd.c= om> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index dc78494167..54f42dcd25 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3942,10 +3942,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED= | CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSH= OPT | CPUID_7_0_EBX_SHA_NI, - /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component. - */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1, @@ -3968,6 +3964,19 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, + { + .version =3D 3, + .props =3D (PropValue[]) { + { "ibpb", "on" }, + { "perfctr-core", "on" }, + { "clzero", "on" }, + { "xsaveerptr", "on" }, + { "xsaves", "on" }, + { "model-id", + "AMD EPYC Processor" }, + { /* end of list */ } + } + }, { /* end of list */ } } }, --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494726; cv=none; d=zohomail.com; s=zohoarc; b=JmX47uu9N2n4Vj1QAXPj2nirPECF5ijcpjSoAmTsraYXk1xVE8xtH7PV0u7u2b08eUVpJ4gjoKbbGkF9PiIDfVQtXjx3jzqTLsOWgR0Z09Jc9+lGNlb8NIiI8QRpTl9cBrT5cvT9qGLuNsaP8TFVmQOQ2eKvICJUPc3J716UszQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494726; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hhOfX8bgYV0VL7iu+967tvvfoSww6+QsiDTuUBu5Ebk=; b=YMtURaPf15UR88IoocF7HysMsvhHxCtmftnfBeDzQNxBYs9/zwiqm3hpjEiaqyKfnEVy7WrowQBXGCBKMJTyp87WfvB3tnuEWUcVaEtfgHUrKovL3Zyl/KmpELue9PYevx0UX3exTrTxm6L3ZNFeWlI809qdUnCeRB3OnZrrBf8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494726588125.23328369584328; Tue, 17 Mar 2020 18:25:26 -0700 (PDT) Received: from localhost ([::1]:44052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENSX-00058U-3u for importer@patchew.org; Tue, 17 Mar 2020 21:25:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34585) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLj-0004Tv-Ld for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLg-0002Lg-Rs for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:23 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:31780) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLg-0002JN-MO for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-396-GHtJ3AZkNFyYz_UBzwy0SQ-1; Tue, 17 Mar 2020 21:18:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6C4B1005509; Wed, 18 Mar 2020 01:17:59 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B98093509; Wed, 18 Mar 2020 01:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hhOfX8bgYV0VL7iu+967tvvfoSww6+QsiDTuUBu5Ebk=; b=EJKoVGPa30A78uwTiE74Re6RUOSnf9ZgXHaQyFkCKdkeRPHXeI711AbD+RO2FbcmPXbE5J 5dpduGAc4npg9qx5xNJJkhjXsrtBGN7+a4i95cqcpHUMAYONUJcijGC765tWUYtEGpKsns VqxUZ8dPZg0aSE1kNpYqzG0TZqQwP3I= X-MC-Unique: GHtJ3AZkNFyYz_UBzwy0SQ-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 04/13] i386: Add 2nd Generation AMD EPYC processors Date: Tue, 17 Mar 2020 21:17:39 -0400 Message-Id: <20200318011748.2104336-5-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , "Moger, Babu" , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Moger, Babu" Adds the support for 2nd Gen AMD EPYC Processors. The model display name will be EPYC-Rome. Adds the following new feature bits on top of the feature bits from the first generation EPYC models. perfctr-core : core performance counter extensions support. Enables the VM = to use extended performance counter support. It enables six programmable counters instead of four counters. clzero : instruction zeroes out the 64 byte cache line specified in R= AX. xsaveerptr : XSAVE, XSAVE, FXSAVEOPT, XSAVEC, XSAVES always save error pointers and FXRSTOR, XRSTOR, XRSTORS always restore error pointers. wbnoinvd : Write back and do not invalidate cache ibpb : Indirect Branch Prediction Barrier amd-stibp : Single Thread Indirect Branch Predictor clwb : Cache Line Write Back and Retain xsaves : XSAVES, XRSTORS and IA32_XSS support rdpid : Read Processor ID instruction support umip : User-Mode Instruction Prevention support The Reference documents are available at https://developer.amd.com/wp-content/resources/55803_0.54-PUB.pdf https://www.amd.com/system/files/TechDocs/24594.pdf Depends on following kernel commits: 40bc47b08b6e ("kvm: x86: Enumerate support for CLZERO instruction") 504ce1954fba ("KVM: x86: Expose XSAVEERPTR to the guest") 6d61e3c32248 ("kvm: x86: Expose RDPID in KVM_GET_SUPPORTED_CPUID") 52297436199d ("kvm: svm: Update svm_xsaves_supported") Signed-off-by: Babu Moger Message-Id: <157314966312.23828.17684821666338093910.stgit@naples-babu.amd.= com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 102 +++++++++++++++++++++++++++++++++++++++++++++- target/i386/cpu.h | 2 + 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 54f42dcd25..350b51b346 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1133,7 +1133,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORD= S] =3D { "clzero", NULL, "xsaveerptr", NULL, NULL, NULL, NULL, NULL, NULL, "wbnoinvd", NULL, NULL, - "ibpb", NULL, NULL, NULL, + "ibpb", NULL, NULL, "amd-stibp", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "amd-ssbd", "virt-ssbd", "amd-no-ssb", NULL, @@ -1798,6 +1798,56 @@ static CPUCaches epyc_cache_info =3D { }, }; =20 +static CPUCaches epyc_rome_cache_info =3D { + .l1d_cache =3D &(CPUCacheInfo) { + .type =3D DATA_CACHE, + .level =3D 1, + .size =3D 32 * KiB, + .line_size =3D 64, + .associativity =3D 8, + .partitions =3D 1, + .sets =3D 64, + .lines_per_tag =3D 1, + .self_init =3D 1, + .no_invd_sharing =3D true, + }, + .l1i_cache =3D &(CPUCacheInfo) { + .type =3D INSTRUCTION_CACHE, + .level =3D 1, + .size =3D 32 * KiB, + .line_size =3D 64, + .associativity =3D 8, + .partitions =3D 1, + .sets =3D 64, + .lines_per_tag =3D 1, + .self_init =3D 1, + .no_invd_sharing =3D true, + }, + .l2_cache =3D &(CPUCacheInfo) { + .type =3D UNIFIED_CACHE, + .level =3D 2, + .size =3D 512 * KiB, + .line_size =3D 64, + .associativity =3D 8, + .partitions =3D 1, + .sets =3D 1024, + .lines_per_tag =3D 1, + }, + .l3_cache =3D &(CPUCacheInfo) { + .type =3D UNIFIED_CACHE, + .level =3D 3, + .size =3D 16 * MiB, + .line_size =3D 64, + .associativity =3D 16, + .partitions =3D 1, + .sets =3D 16384, + .lines_per_tag =3D 1, + .self_init =3D true, + .inclusive =3D true, + .complex_indexing =3D true, + }, +}; + /* The following VMX features are not supported by KVM and are left out in= the * CPU definitions: * @@ -4030,6 +4080,56 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .model_id =3D "Hygon Dhyana Processor", .cache_info =3D &epyc_cache_info, }, + { + .name =3D "EPYC-Rome", + .level =3D 0xd, + .vendor =3D CPUID_VENDOR_AMD, + .family =3D 23, + .model =3D 49, + .stepping =3D 0, + .features[FEAT_1_EDX] =3D + CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | CPUID_CLFLUS= H | + CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA | CPUID_PGE | + CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | CPUID_MCE | + CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | CPUID_DE | + CPUID_VME | CPUID_FP87, + .features[FEAT_1_ECX] =3D + CPUID_EXT_RDRAND | CPUID_EXT_F16C | CPUID_EXT_AVX | + CPUID_EXT_XSAVE | CPUID_EXT_AES | CPUID_EXT_POPCNT | + CPUID_EXT_MOVBE | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 | + CPUID_EXT_CX16 | CPUID_EXT_FMA | CPUID_EXT_SSSE3 | + CPUID_EXT_MONITOR | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3, + .features[FEAT_8000_0001_EDX] =3D + CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_PDPE1GB | + CPUID_EXT2_FFXSR | CPUID_EXT2_MMXEXT | CPUID_EXT2_NX | + CPUID_EXT2_SYSCALL, + .features[FEAT_8000_0001_ECX] =3D + CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH | + CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | + CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM | + CPUID_EXT3_TOPOEXT | CPUID_EXT3_PERFCORE, + .features[FEAT_8000_0008_EBX] =3D + CPUID_8000_0008_EBX_CLZERO | CPUID_8000_0008_EBX_XSAVEERPTR | + CPUID_8000_0008_EBX_WBNOINVD | CPUID_8000_0008_EBX_IBPB | + CPUID_8000_0008_EBX_STIBP, + .features[FEAT_7_0_EBX] =3D + CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AV= X2 | + CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED= | + CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSH= OPT | + CPUID_7_0_EBX_SHA_NI | CPUID_7_0_EBX_CLWB, + .features[FEAT_7_0_ECX] =3D + CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_RDPID, + .features[FEAT_XSAVE] =3D + CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | + CPUID_XSAVE_XGETBV1 | CPUID_XSAVE_XSAVES, + .features[FEAT_6_EAX] =3D + CPUID_6_EAX_ARAT, + .features[FEAT_SVM] =3D + CPUID_SVM_NPT | CPUID_SVM_NRIPSAVE, + .xlevel =3D 0x8000001E, + .model_id =3D "AMD EPYC-Rome Processor", + .cache_info =3D &epyc_rome_cache_info, + }, }; =20 /* KVM-specific features that are automatically added/removed diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 576f309bbf..68b186d258 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -792,6 +792,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; #define CPUID_8000_0008_EBX_WBNOINVD (1U << 9) /* Indirect Branch Prediction Barrier */ #define CPUID_8000_0008_EBX_IBPB (1U << 12) +/* Single Thread Indirect Branch Predictors */ +#define CPUID_8000_0008_EBX_STIBP (1U << 15) =20 #define CPUID_XSAVE_XSAVEOPT (1U << 0) #define CPUID_XSAVE_XSAVEC (1U << 1) --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494423; cv=none; d=zohomail.com; s=zohoarc; b=Uy/ZELisJu3ytG7jM8S7BGHwv/k+ylIAKQFcHRs71f+PnaY8jhmv1DJR3kjh1C7G96Ql4s9IHlosV9JHp6SLNxg6EJj0GAmNNWTq4ln5ksBKlP4FI2UqbXiDzAMZ3LoaSw/Dcb950HB/Z8f84O/sfHq07jrh7HNGkPaTppDZivI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494423; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RXaaXi1obSI+LFUzsUj4WibcybnyLRIumIU+jKS0tpA=; b=nRk4pWCyVfP24fa6EqE65TEqP7mWOPPwMBWxgUGNBYlYP4CUNbzTK62cUdQJ1JohliS8s9DSmsHnFDt6EpmFyVtVYkTJJ0Hlf5Q6XMDI7kZGpxRE6HDiuZn4Gtea7bEdwqoAJmwT9yp2ZiLUeea0PgHkUGcY9eNX/kZvZxYoH94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494423807381.4867866546833; Tue, 17 Mar 2020 18:20:23 -0700 (PDT) Received: from localhost ([::1]:43990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENNe-00072W-K6 for importer@patchew.org; Tue, 17 Mar 2020 21:20:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34297) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLV-00047p-PP for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLT-0001KF-QO for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:09 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:47100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLT-0001Hu-I4 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-LXHQleIHOXmrrZSxWo21Hg-1; Tue, 17 Mar 2020 21:18:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3313818A5500; Wed, 18 Mar 2020 01:18:02 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 931AE60BF3; Wed, 18 Mar 2020 01:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RXaaXi1obSI+LFUzsUj4WibcybnyLRIumIU+jKS0tpA=; b=B7pZnd9zT1Oyz0cKzS1kUB3NJWT+DOpI5nJWzNCknXjvv/JPtvKXGzrznqzeii64HwJKff GM/FzEM7Mg/QBs37hQKZdUowDYTbmwfFYJc2SY5cSngd3HSJWTUU3EC9vrS9+jeswFZqop RXgb7eyYQ+jpH0akjdRE/KYoBppnWUQ= X-MC-Unique: LXHQleIHOXmrrZSxWo21Hg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 05/13] hw/i386: Rename X86CPUTopoInfo structure to X86CPUTopoIDs Date: Tue, 17 Mar 2020 21:17:40 -0400 Message-Id: <20200318011748.2104336-6-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Babu Moger , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Babu Moger 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 Message-Id: <158326541877.40452.17535023236841538507.stgit@naples-babu.amd.= com> Signed-off-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 362eb2a180..f52e84b2ba 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1505,7 +1505,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, int idx; CPUState *cs; CPUArchId *cpu_slot; - X86CPUTopoInfo topo; + X86CPUTopoIDs topo_ids; X86CPU *cpu =3D X86_CPU(dev); CPUX86State *env =3D &cpu->env; MachineState *ms =3D MACHINE(hotplug_dev); @@ -1571,12 +1571,12 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, return; } =20 - topo.pkg_id =3D cpu->socket_id; - topo.die_id =3D cpu->die_id; - topo.core_id =3D cpu->core_id; - topo.smt_id =3D cpu->thread_id; + topo_ids.pkg_id =3D cpu->socket_id; + topo_ids.die_id =3D cpu->die_id; + topo_ids.core_id =3D cpu->core_id; + topo_ids.smt_id =3D cpu->thread_id; cpu->apic_id =3D apicid_from_topo_ids(x86ms->smp_dies, smp_cores, - smp_threads, &topo); + smp_threads, &topo_ids); } =20 cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); @@ -1584,11 +1584,11 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, MachineState *ms =3D MACHINE(pcms); =20 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.s= mt_id, cpu->apic_id, ms->possible_cpus->len - 1); return; } @@ -1606,34 +1606,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 globa= ls */ x86_topo_ids_from_apicid(cpu->apic_id, x86ms->smp_dies, - smp_cores, smp_threads, &topo); - if (cpu->socket_id !=3D -1 && cpu->socket_id !=3D topo.pkg_id) { + smp_cores, smp_threads, &topo_ids); + if (cpu->socket_id !=3D -1 && cpu->socket_id !=3D 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.pk= g_id); + " 0x%x (socket-id: %u)", cpu->socket_id, cpu->apic_id, + topo_ids.pkg_id); return; } - cpu->socket_id =3D topo.pkg_id; + cpu->socket_id =3D topo_ids.pkg_id; =20 - if (cpu->die_id !=3D -1 && cpu->die_id !=3D topo.die_id) { + if (cpu->die_id !=3D -1 && cpu->die_id !=3D 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 =3D topo.die_id; + cpu->die_id =3D topo_ids.die_id; =20 - if (cpu->core_id !=3D -1 && cpu->core_id !=3D topo.core_id) { + if (cpu->core_id !=3D -1 && cpu->core_id !=3D 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_i= d); + " 0x%x (core-id: %u)", cpu->core_id, cpu->apic_id, + topo_ids.core_id); return; } - cpu->core_id =3D topo.core_id; + cpu->core_id =3D topo_ids.core_id; =20 - if (cpu->thread_id !=3D -1 && cpu->thread_id !=3D topo.smt_id) { + if (cpu->thread_id !=3D -1 && cpu->thread_id !=3D 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.sm= t_id); + " 0x%x (thread-id: %u)", cpu->thread_id, cpu->apic_id, + topo_ids.smt_id); return; } - cpu->thread_id =3D topo.smt_id; + cpu->thread_id =3D topo_ids.smt_id; =20 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 08246523f2..c6ee5aac8c 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) =20 int64_t x86_get_default_cpu_node_id(const MachineState *ms, int idx) { - X86CPUTopoInfo topo; + X86CPUTopoIDs topo_ids; X86MachineState *x86ms =3D X86_MACHINE(ms); =20 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; } =20 const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) @@ -172,7 +172,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineS= tate *ms) sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len =3D max_cpus; for (i =3D 0; i < ms->possible_cpus->len; i++) { - X86CPUTopoInfo topo; + X86CPUTopoIDs topo_ids; =20 ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; @@ -180,17 +180,17 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(Machin= eState *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 =3D true; - ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; + ms->possible_cpus->cpus[i].props.socket_id =3D topo_ids.pkg_id; if (x86ms->smp_dies > 1) { ms->possible_cpus->cpus[i].props.has_die_id =3D true; - ms->possible_cpus->cpus[i].props.die_id =3D topo.die_id; + ms->possible_cpus->cpus[i].props.die_id =3D topo_ids.die_id; } ms->possible_cpus->cpus[i].props.has_core_id =3D true; - ms->possible_cpus->cpus[i].props.core_id =3D topo.core_id; + ms->possible_cpus->cpus[i].props.core_id =3D topo_ids.core_id; ms->possible_cpus->cpus[i].props.has_thread_id =3D true; - ms->possible_cpus->cpus[i].props.thread_id =3D topo.smt_id; + ms->possible_cpus->cpus[i].props.thread_id =3D 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; =20 -typedef struct X86CPUTopoInfo { +typedef struct X86CPUTopoIDs { unsigned pkg_id; unsigned die_id; unsigned core_id; unsigned smt_id; -} X86CPUTopoInfo; +} X86CPUTopoIDs; =20 /* 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_threa= ds)) | - (topo->die_id << apicid_die_offset(nr_dies, nr_cores, nr_threa= ds)) | - (topo->core_id << apicid_core_offset(nr_dies, nr_cores, nr_threa= ds)) | - 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; } =20 /* 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 =3D cpu_index / (nr_dies * nr_cores * nr_threads); - topo->die_id =3D cpu_index / (nr_cores * nr_threads) % nr_dies; - topo->core_id =3D cpu_index / nr_threads % nr_cores; - topo->smt_id =3D cpu_index % nr_threads; + topo_ids->pkg_id =3D cpu_index / (nr_dies * nr_cores * nr_threads); + topo_ids->die_id =3D cpu_index / (nr_cores * nr_threads) % nr_dies; + topo_ids->core_id =3D cpu_index / nr_threads % nr_cores; + topo_ids->smt_id =3D cpu_index % nr_threads; } =20 /* 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 =3D apicid & + topo_ids->smt_id =3D apicid & ~(0xFFFFFFFFUL << apicid_smt_width(nr_dies, nr_cores, nr_threa= ds)); - topo->core_id =3D + topo_ids->core_id =3D (apicid >> apicid_core_offset(nr_dies, nr_cores, nr_threads)) & ~(0xFFFFFFFFUL << apicid_core_width(nr_dies, nr_cores, nr_thre= ads)); - topo->die_id =3D + topo_ids->die_id =3D (apicid >> apicid_die_offset(nr_dies, nr_cores, nr_threads)) & ~(0xFFFFFFFFUL << apicid_die_width(nr_dies, nr_cores, nr_threa= ds)); - topo->pkg_id =3D apicid >> apicid_pkg_offset(nr_dies, nr_cores, nr_thr= eads); + topo_ids->pkg_id =3D + apicid >> apicid_pkg_offset(nr_dies, nr_cores, nr_threads); } =20 /* Make APIC ID for the CPU 'cpu_index' @@ -174,9 +178,9 @@ static inline apic_id_t x86_apicid_from_cpu_idx(unsigne= d 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); } =20 #endif /* HW_I386_TOPOLOGY_H */ --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494491; cv=none; d=zohomail.com; s=zohoarc; b=oKm9OdXOrMqvzkvlCyZHV+LnRHnKy/wVuvsB9eNb4m8a032wydi1C+nRswIcCiXwdB71AwMWYFJ/+rZYFyahIEKIeBjfJCGpigX1JVGL+V2jI8C098jJRgSkvciuDH+cL4wounJcuyikDb31bsiynkASTi6A06JxFA3TXggNSGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494491; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3eZa9tGnyx4UMUgM4w4jYdF3/wPJuRSgyMAtCXfsWWo=; b=VVG75SxkUDlJrw0zVP6i8ePpvfD+PSFDPf3gcJZyLkWTvaeweqNxsCY7mDT500Vsj5cCMaI9jeCf2DmJbsSlt+l/OVpd5/owtTGaTMPCcZSlRyKtUEBHVq/wpwK6ZHYQ2Vaa6MDmANIFHj7qM6+oI4SP/Jg2NfK/7NyeEXAdPWw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494491316882.1231172241743; Tue, 17 Mar 2020 18:21:31 -0700 (PDT) Received: from localhost ([::1]:44010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENOj-0008R3-8T for importer@patchew.org; Tue, 17 Mar 2020 21:21:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34287) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLV-00046i-9w for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLU-0001M7-0v for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:09 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:22777) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLT-0001JV-SL for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-9-ALIwUM0VPG6SGfxMgsGqZw-1; Tue, 17 Mar 2020 21:18:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74B29477; Wed, 18 Mar 2020 01:18:04 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1366873865; Wed, 18 Mar 2020 01:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3eZa9tGnyx4UMUgM4w4jYdF3/wPJuRSgyMAtCXfsWWo=; b=CNLqiC7hQKMxnkdkhM9RbNw5eNW5hdfT3dEUjW3dqCoyIAeG5GRhj0nn+MK51V3wn9C8Np db9dc5rzRKmQqkUHTq4wD6ZQ8SjnZ9UE8VD2M2BKMGWCbnmtejP5sGEQNFPzY4uTzOgYet ZMQCZls2dsO1Gex0SfwcRhakG/9tcyU= X-MC-Unique: ALIwUM0VPG6SGfxMgsGqZw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 06/13] machine/memory encryption: Disable mem merge Date: Tue, 17 Mar 2020 21:17:41 -0400 Message-Id: <20200318011748.2104336-7-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , "Dr. David Alan Gilbert" , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" When a host is running with memory encryption, the memory isn't visible to the host kernel; attempts to merge that memory are futile because what it's really comparing is encrypted memory, usually encrypted with different keys. Automatically turn mem-merge off when memory encryption is specified. https://bugzilla.redhat.com/show_bug.cgi?id=3D1796356 Signed-off-by: Dr. David Alan Gilbert Message-Id: <20200130175046.85850-1-dgilbert@redhat.com> Signed-off-by: Eduardo Habkost --- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index 9e8c06036f..4778bc6b08 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -425,6 +425,14 @@ static void machine_set_memory_encryption(Object *obj,= const char *value, =20 g_free(ms->memory_encryption); ms->memory_encryption =3D g_strdup(value); + + /* + * With memory encryption, the host can't see the real contents of RAM, + * so there's no point in it trying to merge areas. + */ + if (value) { + machine_set_mem_merge(obj, false, errp); + } } =20 static bool machine_get_nvdimm(Object *obj, Error **errp) --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494732; cv=none; d=zohomail.com; s=zohoarc; b=ONXw9px5J5psdkQ6YvwW/VAuQf5ZO1ePF61FlVY/zflJro7BbvKfHcHhscWNbPQB4e6g+I/t3A1Gzrr6jnn0Glyy8qWSHJIIA23V82wvVT4JciS2TU+9bGTlBDp3Wy2ZcVCjRZ8ARP9r4faReqNHChkbpo0oBKcQITokWkRDso4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494732; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eKhrJItNIkvWmrCR50dEdxZPw/hKTi45smTcUpgrUT8=; b=KVrZKXZn56a0SGPVjqs/soard5x7yXPr4I/u9M5yqCq8LFnF+tuiIJZx1+phJT7pxOEV0ublav6CVupCGrTbEtx3UEPiTN/y7b2ETfsOXoriKcnilQI6ucLOToz4JMNb0I4YtRkzz8xAXPwN1gS6B2/9Y1QIy7051odH5NCeyww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158449473286148.02892343529652; Tue, 17 Mar 2020 18:25:32 -0700 (PDT) Received: from localhost ([::1]:44058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENSd-0005Im-KC for importer@patchew.org; Tue, 17 Mar 2020 21:25:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34674) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLn-0004aJ-JR for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLi-0002Sm-MM for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:27 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:52316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLi-0002PZ-Dz for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-zO4qZYQmPxyejTGJjD_SDw-1; Tue, 17 Mar 2020 21:18:08 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDEDA18A5500; Wed, 18 Mar 2020 01:18:06 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id E57475D9E5; Wed, 18 Mar 2020 01:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eKhrJItNIkvWmrCR50dEdxZPw/hKTi45smTcUpgrUT8=; b=CUpGEEXgpWV5NRsbbPLE62jksTBTuPD7H7M0fI3stLkKvQZD3LI5b6Zdte1gCOj0oPtAq2 HlIDKmP2/TqMpP322PXN0AmvnFvFfyUstAqZAFnF7IrJnUOGSgbF6tuvzNws0lhLNn9LF5 qUUGKYfiI1LHWx0RcLhkz1yZMSM1rBU= X-MC-Unique: zO4qZYQmPxyejTGJjD_SDw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 07/13] cpu: Use DeviceClass reset instead of a special CPUClass reset Date: Tue, 17 Mar 2020 21:17:42 -0400 Message-Id: <20200318011748.2104336-8-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 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: Eduardo Habkost , Richard Henderson , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Maydell The CPUClass has a 'reset' method. This is a legacy from when TYPE_CPU used not to inherit from TYPE_DEVICE. We don't need it any more, as we can simply use the TYPE_DEVICE reset. The 'cpu_reset()' function is kept as the API which most places use to reset a CPU; it is now a wrapper which calls device_cold_reset() and then the tracepoint function. This change should not cause CPU objects to be reset more often than they are at the moment, because: * nobody is directly calling device_cold_reset() or qdev_reset_all() on CPU objects * no CPU object is on a qbus, so they will not be reset either by somebody calling qbus_reset_all()/bus_cold_reset(), or by the main "reset sysbus and everything in the qbus tree" reset that most devices are reset by Note that this does not change the need for each machine or whatever to use qemu_register_reset() to arrange to call cpu_reset() -- that is necessary because CPU objects are not on any qbus, so they don't get reset when the qbus tree rooted at the sysbus bus is reset, and this isn't being changed here. All the changes to the files under target/ were made using the included Coccinelle script, except: (1) the deletion of the now-inaccurate and not terribly useful "CPUClass::reset" comments was done with a perl one-liner afterwards: perl -n -i -e '/ CPUClass::reset/ or print' target/*/*.c (2) this bit of the s390 change was done by hand, because the Coccinelle script is not sophisticated enough to handle the parent_reset call being inside another function: | @@ -96,8 +96,9 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type = type) | S390CPU *cpu =3D S390_CPU(s); | S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); | CPUS390XState *env =3D &cpu->env; |+ DeviceState *dev =3D DEVICE(s); | |- scc->parent_reset(s); |+ scc->parent_reset(dev); | cpu->env.sigp_order =3D 0; | s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); Signed-off-by: Peter Maydell Message-Id: <20200303100511.5498-1-peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Eduardo Habkost --- hw/core/cpu.c | 19 +++--------- include/hw/core/cpu.h | 6 ---- scripts/coccinelle/cpu-reset.cocci | 47 ++++++++++++++++++++++++++++++ target/alpha/cpu-qom.h | 2 +- target/arm/cpu-qom.h | 2 +- target/arm/cpu.c | 8 ++--- target/cris/cpu-qom.h | 2 +- target/cris/cpu.c | 8 ++--- target/hppa/cpu-qom.h | 2 +- target/i386/cpu-qom.h | 2 +- target/i386/cpu.c | 8 ++--- target/lm32/cpu-qom.h | 2 +- target/lm32/cpu.c | 8 ++--- target/m68k/cpu-qom.h | 2 +- target/m68k/cpu.c | 8 ++--- target/microblaze/cpu-qom.h | 2 +- target/microblaze/cpu.c | 8 ++--- target/mips/cpu-qom.h | 2 +- target/mips/cpu.c | 8 ++--- target/moxie/cpu.c | 7 +++-- target/moxie/cpu.h | 2 +- target/nios2/cpu.c | 8 ++--- target/nios2/cpu.h | 2 +- target/openrisc/cpu.c | 8 ++--- target/openrisc/cpu.h | 2 +- target/ppc/cpu-qom.h | 2 +- target/ppc/translate_init.inc.c | 8 ++--- target/riscv/cpu.c | 7 +++-- target/riscv/cpu.h | 2 +- target/s390x/cpu-qom.h | 2 +- target/s390x/cpu.c | 8 +++-- target/sh4/cpu-qom.h | 2 +- target/sh4/cpu.c | 8 ++--- target/sparc/cpu-qom.h | 2 +- target/sparc/cpu.c | 8 ++--- target/tilegx/cpu.c | 7 +++-- target/tilegx/cpu.h | 2 +- target/tricore/cpu-qom.h | 2 +- target/tricore/cpu.c | 7 +++-- target/xtensa/cpu-qom.h | 2 +- target/xtensa/cpu.c | 8 ++--- 41 files changed, 144 insertions(+), 108 deletions(-) create mode 100644 scripts/coccinelle/cpu-reset.cocci diff --git a/hw/core/cpu.c b/hw/core/cpu.c index fe65ca62ac..b889878f3c 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -239,27 +239,16 @@ void cpu_dump_statistics(CPUState *cpu, int flags) } } =20 -void cpu_class_set_parent_reset(CPUClass *cc, - void (*child_reset)(CPUState *cpu), - void (**parent_reset)(CPUState *cpu)) -{ - *parent_reset =3D cc->reset; - cc->reset =3D child_reset; -} - void cpu_reset(CPUState *cpu) { - CPUClass *klass =3D CPU_GET_CLASS(cpu); - - if (klass->reset !=3D NULL) { - (*klass->reset)(cpu); - } + device_cold_reset(DEVICE(cpu)); =20 trace_guest_cpu_reset(cpu); } =20 -static void cpu_common_reset(CPUState *cpu) +static void cpu_common_reset(DeviceState *dev) { + CPUState *cpu =3D CPU(dev); CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 if (qemu_loglevel_mask(CPU_LOG_RESET)) { @@ -419,7 +408,6 @@ static void cpu_class_init(ObjectClass *klass, void *da= ta) CPUClass *k =3D CPU_CLASS(klass); =20 k->parse_features =3D cpu_common_parse_features; - k->reset =3D cpu_common_reset; k->get_arch_id =3D cpu_common_get_arch_id; k->has_work =3D cpu_common_has_work; k->get_paging_enabled =3D cpu_common_get_paging_enabled; @@ -440,6 +428,7 @@ static void cpu_class_init(ObjectClass *klass, void *da= ta) set_bit(DEVICE_CATEGORY_CPU, dc->categories); dc->realize =3D cpu_common_realizefn; dc->unrealize =3D cpu_common_unrealizefn; + dc->reset =3D cpu_common_reset; device_class_set_props(dc, cpu_common_props); /* * Reason: CPUs still need special care by board code: wiring up diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 73e9a869a4..88ee543722 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -79,7 +79,6 @@ struct TranslationBlock; * @class_by_name: Callback to map -cpu command line model name to an * instantiatable CPU type. * @parse_features: Callback to parse command line arguments. - * @reset: Callback to reset the #CPUState to its initial state. * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @has_work: Callback for checking if there is work to do. * @do_interrupt: Callback for interrupt handling. @@ -165,7 +164,6 @@ typedef struct CPUClass { ObjectClass *(*class_by_name)(const char *cpu_model); void (*parse_features)(const char *typename, char *str, Error **errp); =20 - void (*reset)(CPUState *cpu); int reset_dump_flags; bool (*has_work)(CPUState *cpu); void (*do_interrupt)(CPUState *cpu); @@ -1135,10 +1133,6 @@ void cpu_exec_unrealizefn(CPUState *cpu); */ bool target_words_bigendian(void); =20 -void cpu_class_set_parent_reset(CPUClass *cc, - void (*child_reset)(CPUState *cpu), - void (**parent_reset)(CPUState *cpu)); - #ifdef NEED_CPU_H =20 #ifdef CONFIG_SOFTMMU diff --git a/scripts/coccinelle/cpu-reset.cocci b/scripts/coccinelle/cpu-re= set.cocci new file mode 100644 index 0000000000..396a724e51 --- /dev/null +++ b/scripts/coccinelle/cpu-reset.cocci @@ -0,0 +1,47 @@ +// Convert targets using the old CPUState reset to DeviceState reset +// +// Copyright Linaro Ltd 2020 +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch --macro-file scripts/cocci-macro-file.h \ +// --sp-file scripts/coccinelle/cpu-reset.cocci \ +// --keep-comments --smpl-spacing --in-place --include-headers --di= r target +// +// For simplicity we assume some things about the code we're modifying +// that happen to be true for all our targets: +// * all cpu_class_set_parent_reset() callsites have a 'DeviceClass *dc' = local +// * the parent reset field in the target CPU class is 'parent_reset' +// * no reset function already has a 'dev' local + +@@ +identifier cpu, x; +typedef CPUState; +@@ +struct x { +... +- void (*parent_reset)(CPUState *cpu); ++ DeviceReset parent_reset; +... +}; +@ rule1 @ +identifier resetfn; +expression resetfield; +identifier cc; +@@ +- cpu_class_set_parent_reset(cc, resetfn, resetfield) ++ device_class_set_parent_reset(dc, resetfn, resetfield) +@@ +identifier rule1.resetfn; +identifier cpu, cc; +typedef CPUState, DeviceState; +@@ +-resetfn(CPUState *cpu) +-{ ++resetfn(DeviceState *dev) ++{ ++ CPUState *cpu =3D CPU(dev); +<... +- cc->parent_reset(cpu); ++ cc->parent_reset(dev); +...> +} diff --git a/target/alpha/cpu-qom.h b/target/alpha/cpu-qom.h index 6f0a0adb9e..08832fa767 100644 --- a/target/alpha/cpu-qom.h +++ b/target/alpha/cpu-qom.h @@ -44,7 +44,7 @@ typedef struct AlphaCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } AlphaCPUClass; =20 typedef struct AlphaCPU AlphaCPU; diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 3a9d31ea9d..d95568bf05 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -51,7 +51,7 @@ typedef struct ARMCPUClass { =20 const ARMCPUInfo *info; DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } ARMCPUClass; =20 typedef struct ARMCPU ARMCPU; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7fe367078c..8e5ba619a0 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -155,14 +155,14 @@ static void cp_reg_check_reset(gpointer key, gpointer= value, gpointer opaque) assert(oldvalue =3D=3D newvalue); } =20 -/* CPUClass::reset() */ -static void arm_cpu_reset(CPUState *s) +static void arm_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); ARMCPU *cpu =3D ARM_CPU(s); ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(cpu); CPUARMState *env =3D &cpu->env; =20 - acc->parent_reset(s); + acc->parent_reset(dev); =20 memset(env, 0, offsetof(CPUARMState, end_reset_fields)); =20 @@ -2785,7 +2785,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) &acc->parent_realize); =20 device_class_set_props(dc, arm_cpu_properties); - cpu_class_set_parent_reset(cc, arm_cpu_reset, &acc->parent_reset); + device_class_set_parent_reset(dc, arm_cpu_reset, &acc->parent_reset); =20 cc->class_by_name =3D arm_cpu_class_by_name; cc->has_work =3D arm_cpu_has_work; diff --git a/target/cris/cpu-qom.h b/target/cris/cpu-qom.h index 308c1f95bd..f1de6041dc 100644 --- a/target/cris/cpu-qom.h +++ b/target/cris/cpu-qom.h @@ -45,7 +45,7 @@ typedef struct CRISCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; =20 uint32_t vr; } CRISCPUClass; diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 17c6712e29..cff6b9eabf 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -40,15 +40,15 @@ static bool cris_cpu_has_work(CPUState *cs) return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI= ); } =20 -/* CPUClass::reset() */ -static void cris_cpu_reset(CPUState *s) +static void cris_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); CRISCPU *cpu =3D CRIS_CPU(s); CRISCPUClass *ccc =3D CRIS_CPU_GET_CLASS(cpu); CPUCRISState *env =3D &cpu->env; uint32_t vr; =20 - ccc->parent_reset(s); + ccc->parent_reset(dev); =20 vr =3D env->pregs[PR_VR]; memset(env, 0, offsetof(CPUCRISState, end_reset_fields)); @@ -264,7 +264,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *= data) device_class_set_parent_realize(dc, cris_cpu_realizefn, &ccc->parent_realize); =20 - cpu_class_set_parent_reset(cc, cris_cpu_reset, &ccc->parent_reset); + device_class_set_parent_reset(dc, cris_cpu_reset, &ccc->parent_reset); =20 cc->class_by_name =3D cris_cpu_class_by_name; cc->has_work =3D cris_cpu_has_work; diff --git a/target/hppa/cpu-qom.h b/target/hppa/cpu-qom.h index 6367dc4793..b1f6045495 100644 --- a/target/hppa/cpu-qom.h +++ b/target/hppa/cpu-qom.h @@ -44,7 +44,7 @@ typedef struct HPPACPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } HPPACPUClass; =20 typedef struct HPPACPU HPPACPU; diff --git a/target/i386/cpu-qom.h b/target/i386/cpu-qom.h index 0efab2fc67..3e96f8d668 100644 --- a/target/i386/cpu-qom.h +++ b/target/i386/cpu-qom.h @@ -71,7 +71,7 @@ typedef struct X86CPUClass { =20 DeviceRealize parent_realize; DeviceUnrealize parent_unrealize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } X86CPUClass; =20 typedef struct X86CPU X86CPU; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 350b51b346..fb3f3c54bb 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5983,9 +5983,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, } } =20 -/* CPUClass::reset() */ -static void x86_cpu_reset(CPUState *s) +static void x86_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); X86CPU *cpu =3D X86_CPU(s); X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); CPUX86State *env =3D &cpu->env; @@ -5993,7 +5993,7 @@ static void x86_cpu_reset(CPUState *s) uint64_t xcr0; int i; =20 - xcc->parent_reset(s); + xcc->parent_reset(dev); =20 memset(env, 0, offsetof(CPUX86State, end_reset_fields)); =20 @@ -7297,7 +7297,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc= , void *data) &xcc->parent_unrealize); device_class_set_props(dc, x86_cpu_properties); =20 - cpu_class_set_parent_reset(cc, x86_cpu_reset, &xcc->parent_reset); + device_class_set_parent_reset(dc, x86_cpu_reset, &xcc->parent_reset); cc->reset_dump_flags =3D CPU_DUMP_FPU | CPU_DUMP_CCOP; =20 cc->class_by_name =3D x86_cpu_class_by_name; diff --git a/target/lm32/cpu-qom.h b/target/lm32/cpu-qom.h index dc9ac9ac9f..bdedb3759a 100644 --- a/target/lm32/cpu-qom.h +++ b/target/lm32/cpu-qom.h @@ -44,7 +44,7 @@ typedef struct LM32CPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } LM32CPUClass; =20 typedef struct LM32CPU LM32CPU; diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index 687bf35e65..c50ad5fa15 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -99,14 +99,14 @@ static bool lm32_cpu_has_work(CPUState *cs) return cs->interrupt_request & CPU_INTERRUPT_HARD; } =20 -/* CPUClass::reset() */ -static void lm32_cpu_reset(CPUState *s) +static void lm32_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); LM32CPU *cpu =3D LM32_CPU(s); LM32CPUClass *lcc =3D LM32_CPU_GET_CLASS(cpu); CPULM32State *env =3D &cpu->env; =20 - lcc->parent_reset(s); + lcc->parent_reset(dev); =20 /* reset cpu state */ memset(env, 0, offsetof(CPULM32State, end_reset_fields)); @@ -218,7 +218,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *= data) =20 device_class_set_parent_realize(dc, lm32_cpu_realizefn, &lcc->parent_realize); - cpu_class_set_parent_reset(cc, lm32_cpu_reset, &lcc->parent_reset); + device_class_set_parent_reset(dc, lm32_cpu_reset, &lcc->parent_reset); =20 cc->class_by_name =3D lm32_cpu_class_by_name; cc->has_work =3D lm32_cpu_has_work; diff --git a/target/m68k/cpu-qom.h b/target/m68k/cpu-qom.h index b56da8a213..88b11b60f1 100644 --- a/target/m68k/cpu-qom.h +++ b/target/m68k/cpu-qom.h @@ -44,7 +44,7 @@ typedef struct M68kCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } M68kCPUClass; =20 typedef struct M68kCPU M68kCPU; diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index f0653cda2f..9445fcd6df 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -41,16 +41,16 @@ static void m68k_set_feature(CPUM68KState *env, int fea= ture) env->features |=3D (1u << feature); } =20 -/* CPUClass::reset() */ -static void m68k_cpu_reset(CPUState *s) +static void m68k_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); M68kCPU *cpu =3D M68K_CPU(s); M68kCPUClass *mcc =3D M68K_CPU_GET_CLASS(cpu); CPUM68KState *env =3D &cpu->env; floatx80 nan =3D floatx80_default_nan(NULL); int i; =20 - mcc->parent_reset(s); + mcc->parent_reset(dev); =20 memset(env, 0, offsetof(CPUM68KState, end_reset_fields)); #ifdef CONFIG_SOFTMMU @@ -273,7 +273,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) =20 device_class_set_parent_realize(dc, m68k_cpu_realizefn, &mcc->parent_realize); - cpu_class_set_parent_reset(cc, m68k_cpu_reset, &mcc->parent_reset); + device_class_set_parent_reset(dc, m68k_cpu_reset, &mcc->parent_reset); =20 cc->class_by_name =3D m68k_cpu_class_by_name; cc->has_work =3D m68k_cpu_has_work; diff --git a/target/microblaze/cpu-qom.h b/target/microblaze/cpu-qom.h index 49b07cc697..053ba44ee8 100644 --- a/target/microblaze/cpu-qom.h +++ b/target/microblaze/cpu-qom.h @@ -44,7 +44,7 @@ typedef struct MicroBlazeCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } MicroBlazeCPUClass; =20 typedef struct MicroBlazeCPU MicroBlazeCPU; diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 8c90110e52..a2c2f271df 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -102,14 +102,14 @@ static void microblaze_cpu_set_irq(void *opaque, int = irq, int level) } #endif =20 -/* CPUClass::reset() */ -static void mb_cpu_reset(CPUState *s) +static void mb_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(s); MicroBlazeCPUClass *mcc =3D MICROBLAZE_CPU_GET_CLASS(cpu); CPUMBState *env =3D &cpu->env; =20 - mcc->parent_reset(s); + mcc->parent_reset(dev); =20 memset(env, 0, offsetof(CPUMBState, end_reset_fields)); env->res_addr =3D RES_ADDR_NONE; @@ -292,7 +292,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) =20 device_class_set_parent_realize(dc, mb_cpu_realizefn, &mcc->parent_realize); - cpu_class_set_parent_reset(cc, mb_cpu_reset, &mcc->parent_reset); + device_class_set_parent_reset(dc, mb_cpu_reset, &mcc->parent_reset); =20 cc->class_by_name =3D mb_cpu_class_by_name; cc->has_work =3D mb_cpu_has_work; diff --git a/target/mips/cpu-qom.h b/target/mips/cpu-qom.h index a430c0fe4b..9d0df6c034 100644 --- a/target/mips/cpu-qom.h +++ b/target/mips/cpu-qom.h @@ -48,7 +48,7 @@ typedef struct MIPSCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; const struct mips_def_t *cpu_def; } MIPSCPUClass; =20 diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 6cd6b9650b..e86cd06548 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -96,14 +96,14 @@ static bool mips_cpu_has_work(CPUState *cs) return has_work; } =20 -/* CPUClass::reset() */ -static void mips_cpu_reset(CPUState *s) +static void mips_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); MIPSCPU *cpu =3D MIPS_CPU(s); MIPSCPUClass *mcc =3D MIPS_CPU_GET_CLASS(cpu); CPUMIPSState *env =3D &cpu->env; =20 - mcc->parent_reset(s); + mcc->parent_reset(dev); =20 memset(env, 0, offsetof(CPUMIPSState, end_reset_fields)); =20 @@ -189,7 +189,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) =20 device_class_set_parent_realize(dc, mips_cpu_realizefn, &mcc->parent_realize); - cpu_class_set_parent_reset(cc, mips_cpu_reset, &mcc->parent_reset); + device_class_set_parent_reset(dc, mips_cpu_reset, &mcc->parent_reset); =20 cc->class_by_name =3D mips_cpu_class_by_name; cc->has_work =3D mips_cpu_has_work; diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index cf47bc709b..6e0443ccb7 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -35,13 +35,14 @@ static bool moxie_cpu_has_work(CPUState *cs) return cs->interrupt_request & CPU_INTERRUPT_HARD; } =20 -static void moxie_cpu_reset(CPUState *s) +static void moxie_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); MoxieCPU *cpu =3D MOXIE_CPU(s); MoxieCPUClass *mcc =3D MOXIE_CPU_GET_CLASS(cpu); CPUMoxieState *env =3D &cpu->env; =20 - mcc->parent_reset(s); + mcc->parent_reset(dev); =20 memset(env, 0, offsetof(CPUMoxieState, end_reset_fields)); env->pc =3D 0x1000; @@ -101,7 +102,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void = *data) =20 device_class_set_parent_realize(dc, moxie_cpu_realizefn, &mcc->parent_realize); - cpu_class_set_parent_reset(cc, moxie_cpu_reset, &mcc->parent_reset); + device_class_set_parent_reset(dc, moxie_cpu_reset, &mcc->parent_reset); =20 cc->class_by_name =3D moxie_cpu_class_by_name; =20 diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h index 01dca548e5..455553b794 100644 --- a/target/moxie/cpu.h +++ b/target/moxie/cpu.h @@ -69,7 +69,7 @@ typedef struct MoxieCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } MoxieCPUClass; =20 /** diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 1c0c855a6f..0a4075949e 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -39,9 +39,9 @@ static bool nios2_cpu_has_work(CPUState *cs) return cs->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI= ); } =20 -/* CPUClass::reset() */ -static void nios2_cpu_reset(CPUState *cs) +static void nios2_cpu_reset(DeviceState *dev) { + CPUState *cs =3D CPU(dev); Nios2CPU *cpu =3D NIOS2_CPU(cs); Nios2CPUClass *ncc =3D NIOS2_CPU_GET_CLASS(cpu); CPUNios2State *env =3D &cpu->env; @@ -51,7 +51,7 @@ static void nios2_cpu_reset(CPUState *cs) log_cpu_state(cs, 0); } =20 - ncc->parent_reset(cs); + ncc->parent_reset(dev); =20 memset(env->regs, 0, sizeof(uint32_t) * NUM_CORE_REGS); env->regs[R_PC] =3D cpu->reset_addr; @@ -188,7 +188,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void = *data) device_class_set_parent_realize(dc, nios2_cpu_realizefn, &ncc->parent_realize); device_class_set_props(dc, nios2_properties); - cpu_class_set_parent_reset(cc, nios2_cpu_reset, &ncc->parent_reset); + device_class_set_parent_reset(dc, nios2_cpu_reset, &ncc->parent_reset); =20 cc->class_by_name =3D nios2_cpu_class_by_name; cc->has_work =3D nios2_cpu_has_work; diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 78f633f970..4dddf9c3a1 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -50,7 +50,7 @@ typedef struct Nios2CPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } Nios2CPUClass; =20 #define TARGET_HAS_ICE 1 diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 5cd04dafab..5528c0918f 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -41,13 +41,13 @@ static void openrisc_disas_set_info(CPUState *cpu, disa= ssemble_info *info) info->print_insn =3D print_insn_or1k; } =20 -/* CPUClass::reset() */ -static void openrisc_cpu_reset(CPUState *s) +static void openrisc_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); OpenRISCCPU *cpu =3D OPENRISC_CPU(s); OpenRISCCPUClass *occ =3D OPENRISC_CPU_GET_CLASS(cpu); =20 - occ->parent_reset(s); + occ->parent_reset(dev); =20 memset(&cpu->env, 0, offsetof(CPUOpenRISCState, end_reset_fields)); =20 @@ -150,7 +150,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, vo= id *data) =20 device_class_set_parent_realize(dc, openrisc_cpu_realizefn, &occ->parent_realize); - cpu_class_set_parent_reset(cc, openrisc_cpu_reset, &occ->parent_reset); + device_class_set_parent_reset(dc, openrisc_cpu_reset, &occ->parent_res= et); =20 cc->class_by_name =3D openrisc_cpu_class_by_name; cc->has_work =3D openrisc_cpu_has_work; diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 0ad02eab79..e7fb06445e 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -48,7 +48,7 @@ typedef struct OpenRISCCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } OpenRISCCPUClass; =20 #define TARGET_INSN_START_EXTRA_WORDS 1 diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index e499575dc8..b528131761 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -166,7 +166,7 @@ typedef struct PowerPCCPUClass { =20 DeviceRealize parent_realize; DeviceUnrealize parent_unrealize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; void (*parent_parse_features)(const char *type, char *str, Error **err= p); =20 uint32_t pvr; diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 53995f62ea..7e9780e875 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10669,16 +10669,16 @@ static bool ppc_cpu_has_work(CPUState *cs) return msr_ee && (cs->interrupt_request & CPU_INTERRUPT_HARD); } =20 -/* CPUClass::reset() */ -static void ppc_cpu_reset(CPUState *s) +static void ppc_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); PowerPCCPU *cpu =3D POWERPC_CPU(s); PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); CPUPPCState *env =3D &cpu->env; target_ulong msr; int i; =20 - pcc->parent_reset(s); + pcc->parent_reset(dev); =20 msr =3D (target_ulong)0; msr |=3D (target_ulong)MSR_HVB; @@ -10885,7 +10885,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) pcc->interrupts_big_endian =3D ppc_cpu_interrupts_big_endian_always; device_class_set_props(dc, ppc_cpu_properties); =20 - cpu_class_set_parent_reset(cc, ppc_cpu_reset, &pcc->parent_reset); + device_class_set_parent_reset(dc, ppc_cpu_reset, &pcc->parent_reset); =20 cc->class_by_name =3D ppc_cpu_class_by_name; pcc->parent_parse_features =3D cc->parse_features; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index c0b7023100..4e578239d3 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -330,13 +330,14 @@ void restore_state_to_opc(CPURISCVState *env, Transla= tionBlock *tb, env->pc =3D data[0]; } =20 -static void riscv_cpu_reset(CPUState *cs) +static void riscv_cpu_reset(DeviceState *dev) { + CPUState *cs =3D CPU(dev); RISCVCPU *cpu =3D RISCV_CPU(cs); RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(cpu); CPURISCVState *env =3D &cpu->env; =20 - mcc->parent_reset(cs); + mcc->parent_reset(dev); #ifndef CONFIG_USER_ONLY env->priv =3D PRV_M; env->mstatus &=3D ~(MSTATUS_MIE | MSTATUS_MPRV); @@ -511,7 +512,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) device_class_set_parent_realize(dc, riscv_cpu_realize, &mcc->parent_realize); =20 - cpu_class_set_parent_reset(cc, riscv_cpu_reset, &mcc->parent_reset); + device_class_set_parent_reset(dc, riscv_cpu_reset, &mcc->parent_reset); =20 cc->class_by_name =3D riscv_cpu_class_by_name; cc->has_work =3D riscv_cpu_has_work; diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 3dcdf92227..078fc83959 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -234,7 +234,7 @@ typedef struct RISCVCPUClass { CPUClass parent_class; /*< public >*/ DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } RISCVCPUClass; =20 /** diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h index dbe5346ec9..1630818c28 100644 --- a/target/s390x/cpu-qom.h +++ b/target/s390x/cpu-qom.h @@ -61,7 +61,7 @@ typedef struct S390CPUClass { const char *desc; =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; void (*load_normal)(CPUState *cpu); void (*reset)(CPUState *cpu, cpu_reset_type type); } S390CPUClass; diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 3dd396e870..427a46e3e1 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -96,8 +96,9 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type ty= pe) S390CPU *cpu =3D S390_CPU(s); S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); CPUS390XState *env =3D &cpu->env; + DeviceState *dev =3D DEVICE(s); =20 - scc->parent_reset(s); + scc->parent_reset(dev); cpu->env.sigp_order =3D 0; s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); =20 @@ -450,8 +451,9 @@ static Property s390x_cpu_properties[] =3D { DEFINE_PROP_END_OF_LIST() }; =20 -static void s390_cpu_reset_full(CPUState *s) +static void s390_cpu_reset_full(DeviceState *dev) { + CPUState *s =3D CPU(dev); return s390_cpu_reset(s, S390_CPU_RESET_CLEAR); } =20 @@ -466,7 +468,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) device_class_set_props(dc, s390x_cpu_properties); dc->user_creatable =3D true; =20 - cpu_class_set_parent_reset(cc, s390_cpu_reset_full, &scc->parent_reset= ); + device_class_set_parent_reset(dc, s390_cpu_reset_full, &scc->parent_re= set); #if !defined(CONFIG_USER_ONLY) scc->load_normal =3D s390_cpu_load_normal; #endif diff --git a/target/sh4/cpu-qom.h b/target/sh4/cpu-qom.h index 0c56d055ba..72a63f3fd3 100644 --- a/target/sh4/cpu-qom.h +++ b/target/sh4/cpu-qom.h @@ -51,7 +51,7 @@ typedef struct SuperHCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; =20 uint32_t pvr; uint32_t prr; diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 70c8d8170f..3c68021c56 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -47,14 +47,14 @@ static bool superh_cpu_has_work(CPUState *cs) return cs->interrupt_request & CPU_INTERRUPT_HARD; } =20 -/* CPUClass::reset() */ -static void superh_cpu_reset(CPUState *s) +static void superh_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); SuperHCPU *cpu =3D SUPERH_CPU(s); SuperHCPUClass *scc =3D SUPERH_CPU_GET_CLASS(cpu); CPUSH4State *env =3D &cpu->env; =20 - scc->parent_reset(s); + scc->parent_reset(dev); =20 memset(env, 0, offsetof(CPUSH4State, end_reset_fields)); =20 @@ -214,7 +214,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) device_class_set_parent_realize(dc, superh_cpu_realizefn, &scc->parent_realize); =20 - cpu_class_set_parent_reset(cc, superh_cpu_reset, &scc->parent_reset); + device_class_set_parent_reset(dc, superh_cpu_reset, &scc->parent_reset= ); =20 cc->class_by_name =3D superh_cpu_class_by_name; cc->has_work =3D superh_cpu_has_work; diff --git a/target/sparc/cpu-qom.h b/target/sparc/cpu-qom.h index 7442e2768e..8b4d33c21e 100644 --- a/target/sparc/cpu-qom.h +++ b/target/sparc/cpu-qom.h @@ -49,7 +49,7 @@ typedef struct SPARCCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; sparc_def_t *cpu_def; } SPARCCPUClass; =20 diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index eeaecbd8d6..3f05aba9d6 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -28,14 +28,14 @@ =20 //#define DEBUG_FEATURES =20 -/* CPUClass::reset() */ -static void sparc_cpu_reset(CPUState *s) +static void sparc_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); SPARCCPU *cpu =3D SPARC_CPU(s); SPARCCPUClass *scc =3D SPARC_CPU_GET_CLASS(cpu); CPUSPARCState *env =3D &cpu->env; =20 - scc->parent_reset(s); + scc->parent_reset(dev); =20 memset(env, 0, offsetof(CPUSPARCState, end_reset_fields)); env->cwp =3D 0; @@ -859,7 +859,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) &scc->parent_realize); device_class_set_props(dc, sparc_cpu_properties); =20 - cpu_class_set_parent_reset(cc, sparc_cpu_reset, &scc->parent_reset); + device_class_set_parent_reset(dc, sparc_cpu_reset, &scc->parent_reset); =20 cc->class_by_name =3D sparc_cpu_class_by_name; cc->parse_features =3D sparc_cpu_parse_features; diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index cd422a0467..1fee87c094 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -68,13 +68,14 @@ static bool tilegx_cpu_has_work(CPUState *cs) return true; } =20 -static void tilegx_cpu_reset(CPUState *s) +static void tilegx_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); TileGXCPU *cpu =3D TILEGX_CPU(s); TileGXCPUClass *tcc =3D TILEGX_CPU_GET_CLASS(cpu); CPUTLGState *env =3D &cpu->env; =20 - tcc->parent_reset(s); + tcc->parent_reset(dev); =20 memset(env, 0, offsetof(CPUTLGState, end_reset_fields)); } @@ -142,7 +143,7 @@ static void tilegx_cpu_class_init(ObjectClass *oc, void= *data) device_class_set_parent_realize(dc, tilegx_cpu_realizefn, &tcc->parent_realize); =20 - cpu_class_set_parent_reset(cc, tilegx_cpu_reset, &tcc->parent_reset); + device_class_set_parent_reset(dc, tilegx_cpu_reset, &tcc->parent_reset= ); =20 cc->class_by_name =3D tilegx_cpu_class_by_name; cc->has_work =3D tilegx_cpu_has_work; diff --git a/target/tilegx/cpu.h b/target/tilegx/cpu.h index 9cbec247d2..193b6bbccb 100644 --- a/target/tilegx/cpu.h +++ b/target/tilegx/cpu.h @@ -118,7 +118,7 @@ typedef struct TileGXCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } TileGXCPUClass; =20 /** diff --git a/target/tricore/cpu-qom.h b/target/tricore/cpu-qom.h index 7c1e130b4e..cd819e6f24 100644 --- a/target/tricore/cpu-qom.h +++ b/target/tricore/cpu-qom.h @@ -36,7 +36,7 @@ typedef struct TriCoreCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; } TriCoreCPUClass; =20 typedef struct TriCoreCPU TriCoreCPU; diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index 85bc9f03a1..743b404a95 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -53,13 +53,14 @@ static void tricore_cpu_synchronize_from_tb(CPUState *c= s, env->PC =3D tb->pc; } =20 -static void tricore_cpu_reset(CPUState *s) +static void tricore_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); TriCoreCPU *cpu =3D TRICORE_CPU(s); TriCoreCPUClass *tcc =3D TRICORE_CPU_GET_CLASS(cpu); CPUTriCoreState *env =3D &cpu->env; =20 - tcc->parent_reset(s); + tcc->parent_reset(dev); =20 cpu_state_reset(env); } @@ -153,7 +154,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void= *data) device_class_set_parent_realize(dc, tricore_cpu_realizefn, &mcc->parent_realize); =20 - cpu_class_set_parent_reset(cc, tricore_cpu_reset, &mcc->parent_reset); + device_class_set_parent_reset(dc, tricore_cpu_reset, &mcc->parent_rese= t); cc->class_by_name =3D tricore_cpu_class_by_name; cc->has_work =3D tricore_cpu_has_work; =20 diff --git a/target/xtensa/cpu-qom.h b/target/xtensa/cpu-qom.h index 9ac54241bd..3ea93ce1f9 100644 --- a/target/xtensa/cpu-qom.h +++ b/target/xtensa/cpu-qom.h @@ -56,7 +56,7 @@ typedef struct XtensaCPUClass { /*< public >*/ =20 DeviceRealize parent_realize; - void (*parent_reset)(CPUState *cpu); + DeviceReset parent_reset; =20 const XtensaConfig *config; } XtensaCPUClass; diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 4856aee8ec..82c2ee0679 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -67,14 +67,14 @@ bool xtensa_abi_call0(void) } #endif =20 -/* CPUClass::reset() */ -static void xtensa_cpu_reset(CPUState *s) +static void xtensa_cpu_reset(DeviceState *dev) { + CPUState *s =3D CPU(dev); XtensaCPU *cpu =3D XTENSA_CPU(s); XtensaCPUClass *xcc =3D XTENSA_CPU_GET_CLASS(cpu); CPUXtensaState *env =3D &cpu->env; =20 - xcc->parent_reset(s); + xcc->parent_reset(dev); =20 env->exception_taken =3D 0; env->pc =3D env->config->exception_vector[EXC_RESET0 + env->static_vec= tors]; @@ -184,7 +184,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) device_class_set_parent_realize(dc, xtensa_cpu_realizefn, &xcc->parent_realize); =20 - cpu_class_set_parent_reset(cc, xtensa_cpu_reset, &xcc->parent_reset); + device_class_set_parent_reset(dc, xtensa_cpu_reset, &xcc->parent_reset= ); =20 cc->class_by_name =3D xtensa_cpu_class_by_name; cc->has_work =3D xtensa_cpu_has_work; --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494598; cv=none; d=zohomail.com; s=zohoarc; b=HUrIkCyAWi8Qi6OyvqpCiB8WD+E4iY1hLObzuCEIVmUJ1D7k825rq0hxrcWb95JhE/20WBZEQ8reIgtC6Va8vwQF/12xcA9krRCfoBMYbO5ASgEB4EgNWDLPAmFLPu4E0FjbaT0C87lN9x3/KLtK/REfW6gBD0/U8pcg1X0ln2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494598; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ee1lMh7e2gW2tg/Gbem+6EUMfUGQDqgf65E4cU6r3Zg=; b=HN3vRz67Bs7x67Y0dWkvAAYs+rD2vpWGAyzSROMtJDSBjIsyM5oovyUrTVYmDYeEvT6kywdLhGLK+RDXQwJlcw9w7AFAzedfLZ0B8ZIO3s7w0PquzwANRG1FdWOG4iZpyOEX/AQ1rXggToZn8HbT7Ke0n4eqljsoKBEebnqHt/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494598086322.57432704912014; Tue, 17 Mar 2020 18:23:18 -0700 (PDT) Received: from localhost ([::1]:44032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENQS-0002bJ-Vr for importer@patchew.org; Tue, 17 Mar 2020 21:23:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34452) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLc-0004KR-IX for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLa-0001rB-EE for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:16 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:41812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLa-0001mV-12 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-oGGpmKNBOVm7n3DiBs4Njg-1; Tue, 17 Mar 2020 21:18:10 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D028E18A5502; Wed, 18 Mar 2020 01:18:08 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F8E419C58; Wed, 18 Mar 2020 01:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494293; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ee1lMh7e2gW2tg/Gbem+6EUMfUGQDqgf65E4cU6r3Zg=; b=dDYJ3VYdS44n1z7AEL3tRw5ZQTA3EjPuKG48PhLACgknE2EJa1m/rDvsw3Lqajb+uMTdUR DkSGkqzf3AFh/z4dxvdN/I6zcGUhwJqclr6TnBJxwJzcrNpEY79SyBVWiZcFYy6rqiwBc7 FRT6HioCtMNwY8M1/DJfaFOPog15bMw= X-MC-Unique: oGGpmKNBOVm7n3DiBs4Njg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 08/13] hw/i386: Introduce X86CPUTopoInfo to contain topology info Date: Tue, 17 Mar 2020 21:17:43 -0400 Message-Id: <20200318011748.2104336-9-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Babu Moger , Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Babu Moger 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. 3. Update x86 unit tests for new calling convention with parameter X86CPUTo= poInfo There is no functional changes. Signed-off-by: Babu Moger Message-Id: <158396717251.58170.4499717831243474938.stgit@naples-babu.amd.c= om> --- hw/i386/pc.c | 12 +++++------ hw/i386/x86.c | 32 +++++++++++++++++++++------- include/hw/i386/topology.h | 38 ++++++++++++++++++++------------- include/hw/i386/x86.h | 3 +++ tests/test-x86-cpuid.c | 43 +++++++++++++++++++++----------------- 5 files changed, 81 insertions(+), 47 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f52e84b2ba..662abb549d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1513,6 +1513,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, X86MachineState *x86ms =3D X86_MACHINE(pcms); unsigned int smp_cores =3D ms->smp.cores; unsigned int smp_threads =3D ms->smp.threads; + X86CPUTopoInfo topo_info; =20 if(!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) { error_setg(errp, "Invalid CPU type, expected cpu type: '%s'", @@ -1520,6 +1521,8 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, return; } =20 + init_topo_info(&topo_info, x86ms); + env->nr_dies =3D x86ms->smp_dies; =20 /* @@ -1575,16 +1578,14 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, topo_ids.die_id =3D cpu->die_id; topo_ids.core_id =3D cpu->core_id; topo_ids.smt_id =3D cpu->thread_id; - cpu->apic_id =3D apicid_from_topo_ids(x86ms->smp_dies, smp_cores, - smp_threads, &topo_ids); + cpu->apic_id =3D apicid_from_topo_ids(&topo_info, &topo_ids); } =20 cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); if (!cpu_slot) { MachineState *ms =3D MACHINE(pcms); =20 - 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", @@ -1605,8 +1606,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizef= n() * once -smp refactoring is complete and there will be CPU private * CPUState::nr_cores and CPUState::nr_threads fields instead of globa= ls */ - 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 !=3D -1 && cpu->socket_id !=3D 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 c6ee5aac8c..b7d94e8dfe 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; =20 +inline void init_topo_info(X86CPUTopoInfo *topo_info, + const X86MachineState *x86ms) +{ + MachineState *ms =3D MACHINE(x86ms); + + topo_info->dies_per_pkg =3D x86ms->smp_dies; + topo_info->cores_per_die =3D ms->smp.cores; + topo_info->threads_per_core =3D 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 =3D MACHINE(x86ms); X86MachineClass *x86mc =3D X86_MACHINE_GET_CLASS(x86ms); + X86CPUTopoInfo topo_info; uint32_t correct_id; static bool warned; =20 - correct_id =3D x86_apicid_from_cpu_idx(x86ms->smp_dies, ms->smp.cores, - ms->smp.threads, cpu_index); + init_topo_info(&topo_info, x86ms); + + correct_id =3D x86_apicid_from_cpu_idx(&topo_info, cpu_index); if (x86mc->compat_apic_id_mode) { if (cpu_index !=3D 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 MachineStat= e *ms, int idx) { X86CPUTopoIDs topo_ids; X86MachineState *x86ms =3D X86_MACHINE(ms); + X86CPUTopoInfo topo_info; + + init_topo_info(&topo_info, x86ms); =20 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; } =20 const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms) { X86MachineState *x86ms =3D X86_MACHINE(ms); - int i; unsigned int max_cpus =3D ms->smp.max_cpus; + X86CPUTopoInfo topo_info; + int i; =20 if (ms->possible_cpus) { /* @@ -171,6 +185,9 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineS= tate *ms) ms->possible_cpus =3D g_malloc0(sizeof(CPUArchIdList) + sizeof(CPUArchId) * max_cpus); ms->possible_cpus->len =3D max_cpus; + + init_topo_info(&topo_info, x86ms); + for (i =3D 0; i < ms->possible_cpus->len; i++) { X86CPUTopoIDs topo_ids; =20 @@ -179,8 +196,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineS= tate *ms) ms->possible_cpus->cpus[i].arch_id =3D 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 =3D true; ms->possible_cpus->cpus[i].props.socket_id =3D 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; =20 +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 =3D topo_info->dies_per_pkg; + unsigned nr_cores =3D topo_info->cores_per_die; + unsigned nr_threads =3D 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 =3D topo_info->dies_per_pkg; + unsigned nr_cores =3D topo_info->cores_per_die; + unsigned nr_threads =3D topo_info->threads_per_core; + topo_ids->pkg_id =3D cpu_index / (nr_dies * nr_cores * nr_threads); topo_ids->die_id =3D cpu_index / (nr_cores * nr_threads) % nr_dies; topo_ids->core_id =3D 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 =3D topo_info->dies_per_pkg; + unsigned nr_cores =3D topo_info->cores_per_die; + unsigned nr_threads =3D topo_info->threads_per_core; + topo_ids->smt_id =3D apicid & ~(0xFFFFFFFFUL << apicid_smt_width(nr_dies, nr_cores, nr_threa= ds)); topo_ids->core_id =3D @@ -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); } =20 #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" =20 +#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) =20 +void init_topo_info(X86CPUTopoInfo *topo_info, const X86MachineState *x86m= s); + uint32_t x86_cpu_apic_id_from_index(X86MachineState *pcms, unsigned int cpu_index); =20 diff --git a/tests/test-x86-cpuid.c b/tests/test-x86-cpuid.c index 1942287f33..66b953113b 100644 --- a/tests/test-x86-cpuid.c +++ b/tests/test-x86-cpuid.c @@ -28,15 +28,18 @@ =20 static void test_topo_bits(void) { + X86CPUTopoInfo topo_info =3D {0}; + /* simple tests for 1 thread per core, 1 core per die, 1 die per packa= ge */ g_assert_cmpuint(apicid_smt_width(1, 1, 1), =3D=3D, 0); g_assert_cmpuint(apicid_core_width(1, 1, 1), =3D=3D, 0); g_assert_cmpuint(apicid_die_width(1, 1, 1), =3D=3D, 0); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 0), =3D=3D, 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 1), =3D=3D, 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 2), =3D=3D, 2); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 3), =3D=3D, 3); + topo_info =3D (X86CPUTopoInfo) {1, 1, 1}; + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), =3D=3D, 0); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), =3D=3D, 1); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), =3D=3D, 2); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 3), =3D=3D, 3); =20 =20 /* Test field width calculation for multiple values @@ -71,36 +74,38 @@ static void test_topo_bits(void) g_assert_cmpuint(apicid_die_offset(1, 6, 3), =3D=3D, 5); g_assert_cmpuint(apicid_pkg_offset(1, 6, 3), =3D=3D, 5); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 0), =3D=3D, 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1), =3D=3D, 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2), =3D=3D, 2); + topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), =3D=3D, 0); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), =3D=3D, 1); + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), =3D=3D, 2); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1 * 3 + 0), =3D=3D, + topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 0), =3D= =3D, (1 << 2) | 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1 * 3 + 1), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 1), =3D= =3D, (1 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1 * 3 + 2), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 2), =3D= =3D, (1 << 2) | 2); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2 * 3 + 0), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2 * 3 + 0), =3D= =3D, (2 << 2) | 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2 * 3 + 1), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2 * 3 + 1), =3D= =3D, (2 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2 * 3 + 2), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2 * 3 + 2), =3D= =3D, (2 << 2) | 2); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 5 * 3 + 0), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 5 * 3 + 0), =3D= =3D, (5 << 2) | 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 5 * 3 + 1), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 5 * 3 + 1), =3D= =3D, (5 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 5 * 3 + 2), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 5 * 3 + 2), =3D= =3D, (5 << 2) | 2); =20 - 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), =3D=3D, (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), =3D=3D, (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), =3D=3D, (3 << 5) | (5 << 2) |= 2); } =20 --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494545; cv=none; d=zohomail.com; s=zohoarc; b=KrsmVh0iY6H/uc0YEBNvq6pB0vP85MqrQ5a4n9qjqGjcNmY1tbLpfSToQhPKAKpfjDVXWSfEtej5YfdDf+1T7Y/OyILKxACDsIGy9puEKrS72TZ0lQH+fvZCS1nOJYFdWX0171DhJmxyzV4+XG0QzwRXMXkMMvTjMiVCpqK0UwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494545; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UgCYaxcuR7r23GCYXzW2vstRGQBikD2Yxmp3zeSsAUI=; b=GhCEVf/n+AR0srYCtjx4TUhwvj27RgMS0FF9rrY7OPOrZBZEJf1m0y5mH3QfC/pkP6XGqHWAPCtS4T6q8en1dBs2au6U2xs7OkBrS7o1S9UQ+TWQA3laRbFXXsEMBWw8aEhqXKs2NOVpDc/MdzQPf9OgG/gn7yB/KB0sy8LwpEI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494545454267.9551242836534; Tue, 17 Mar 2020 18:22:25 -0700 (PDT) Received: from localhost ([::1]:44028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENPc-0001PI-8E for importer@patchew.org; Tue, 17 Mar 2020 21:22:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34524) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLg-0004QD-Ne for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLe-00024P-B9 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:20 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:29269) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLe-00021W-5x for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-yoJMSAO9Mzi2yBPx04yAbw-1; Tue, 17 Mar 2020 21:18:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54A13477; Wed, 18 Mar 2020 01:18:13 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36BA560BF3; Wed, 18 Mar 2020 01:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UgCYaxcuR7r23GCYXzW2vstRGQBikD2Yxmp3zeSsAUI=; b=hCEN4MvcelRNN2tBxS79Lg4sX205wBwYkNe8hv4HWCs9VPEctvg5RL1jtGYLTTpaHzpBXt kSkRd+0xDcm0Pa4bGBA4UgnKVZ15SgI6pAJWcVEfhtIxJOA3y80kaGl2oaFQ4um1fxEBEb xKAKfI1QQNf/p5XGBm8UIsFDONh5n24= X-MC-Unique: yoJMSAO9Mzi2yBPx04yAbw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 09/13] hw/i386: Consolidate topology functions Date: Tue, 17 Mar 2020 21:17:44 -0400 Message-Id: <20200318011748.2104336-10-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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: Eduardo Habkost , "Michael S . Tsirkin" , Babu Moger , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Babu Moger 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 Acked-by: Michael S. Tsirkin Message-Id: <158396717953.58170.5628042059144117669.stgit@naples-babu.amd.c= om> --- include/hw/i386/topology.h | 68 ++++++++++++------------------------- target/i386/cpu.c | 23 ++++++------- tests/test-x86-cpuid.c | 69 ++++++++++++++++++++++++-------------- 3 files changed, 75 insertions(+), 85 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 coun= t) =20 /* 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); } =20 /* 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); } =20 /* 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); } =20 /* 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); } =20 /* 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); } =20 /* 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); } =20 /* 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_d= ies, static inline apic_id_t apicid_from_topo_ids(X86CPUTopoInfo *topo_info, const X86CPUTopoIDs *topo_ids) { - unsigned nr_dies =3D topo_info->dies_per_pkg; - unsigned nr_cores =3D topo_info->cores_per_die; - unsigned nr_threads =3D 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; } =20 @@ -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 =3D topo_info->dies_per_pkg; - unsigned nr_cores =3D topo_info->cores_per_die; - unsigned nr_threads =3D topo_info->threads_per_core; - topo_ids->smt_id =3D apicid & - ~(0xFFFFFFFFUL << apicid_smt_width(nr_dies, nr_cores, nr_threa= ds)); + ~(0xFFFFFFFFUL << apicid_smt_width(topo_info)); topo_ids->core_id =3D - (apicid >> apicid_core_offset(nr_dies, nr_cores, nr_threads)) & - ~(0xFFFFFFFFUL << apicid_core_width(nr_dies, nr_cores, nr_thre= ads)); + (apicid >> apicid_core_offset(topo_info)) & + ~(0xFFFFFFFFUL << apicid_core_width(topo_info)); topo_ids->die_id =3D - (apicid >> apicid_die_offset(nr_dies, nr_cores, nr_threads)) & - ~(0xFFFFFFFFUL << apicid_die_width(nr_dies, nr_cores, nr_threa= ds)); - topo_ids->pkg_id =3D - 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 =3D apicid >> apicid_pkg_offset(topo_info); } =20 /* Make APIC ID for the CPU 'cpu_index' diff --git a/target/i386/cpu.c b/target/i386/cpu.c index fb3f3c54bb..f1ac572efd 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5497,6 +5497,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 =3D env->nr_dies; + topo_info.cores_per_die =3D cs->nr_cores; + topo_info.threads_per_core =3D cs->nr_threads; =20 /* Calculate & apply limits for different index ranges */ if (index >=3D 0xC0000000) { @@ -5583,8 +5588,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 =3D apicid_die_offset(env->nr_dies, - cs->nr_cores, cs->nr_threads); + die_offset =3D 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, @@ -5675,14 +5679,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, =20 switch (count) { case 0: - *eax =3D apicid_core_offset(env->nr_dies, - cs->nr_cores, cs->nr_threads); + *eax =3D apicid_core_offset(&topo_info); *ebx =3D cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax =3D apicid_pkg_offset(env->nr_dies, - cs->nr_cores, cs->nr_threads); + *eax =3D apicid_pkg_offset(&topo_info); *ebx =3D cs->nr_cores * cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; break; @@ -5706,20 +5708,17 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, *edx =3D cpu->apic_id; switch (count) { case 0: - *eax =3D apicid_core_offset(env->nr_dies, cs->nr_cores, - cs->nr_threads); + *eax =3D apicid_core_offset(&topo_info); *ebx =3D cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax =3D apicid_die_offset(env->nr_dies, cs->nr_cores, - cs->nr_threads); + *eax =3D apicid_die_offset(&topo_info); *ebx =3D cs->nr_cores * cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; break; case 2: - *eax =3D apicid_pkg_offset(env->nr_dies, cs->nr_cores, - cs->nr_threads); + *eax =3D apicid_pkg_offset(&topo_info); *ebx =3D env->nr_dies * cs->nr_cores * cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_DIE; break; diff --git a/tests/test-x86-cpuid.c b/tests/test-x86-cpuid.c index 66b953113b..bfabc0403a 100644 --- a/tests/test-x86-cpuid.c +++ b/tests/test-x86-cpuid.c @@ -31,9 +31,10 @@ static void test_topo_bits(void) X86CPUTopoInfo topo_info =3D {0}; =20 /* simple tests for 1 thread per core, 1 core per die, 1 die per packa= ge */ - g_assert_cmpuint(apicid_smt_width(1, 1, 1), =3D=3D, 0); - g_assert_cmpuint(apicid_core_width(1, 1, 1), =3D=3D, 0); - g_assert_cmpuint(apicid_die_width(1, 1, 1), =3D=3D, 0); + topo_info =3D (X86CPUTopoInfo) {1, 1, 1}; + g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 0); + g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 0); + g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 0); =20 topo_info =3D (X86CPUTopoInfo) {1, 1, 1}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), =3D=3D, 0); @@ -44,35 +45,51 @@ static void test_topo_bits(void) =20 /* Test field width calculation for multiple values */ - g_assert_cmpuint(apicid_smt_width(1, 1, 2), =3D=3D, 1); - g_assert_cmpuint(apicid_smt_width(1, 1, 3), =3D=3D, 2); - g_assert_cmpuint(apicid_smt_width(1, 1, 4), =3D=3D, 2); - - g_assert_cmpuint(apicid_smt_width(1, 1, 14), =3D=3D, 4); - g_assert_cmpuint(apicid_smt_width(1, 1, 15), =3D=3D, 4); - g_assert_cmpuint(apicid_smt_width(1, 1, 16), =3D=3D, 4); - g_assert_cmpuint(apicid_smt_width(1, 1, 17), =3D=3D, 5); - - - g_assert_cmpuint(apicid_core_width(1, 30, 2), =3D=3D, 5); - g_assert_cmpuint(apicid_core_width(1, 31, 2), =3D=3D, 5); - g_assert_cmpuint(apicid_core_width(1, 32, 2), =3D=3D, 5); - g_assert_cmpuint(apicid_core_width(1, 33, 2), =3D=3D, 6); - - g_assert_cmpuint(apicid_die_width(1, 30, 2), =3D=3D, 0); - g_assert_cmpuint(apicid_die_width(2, 30, 2), =3D=3D, 1); - g_assert_cmpuint(apicid_die_width(3, 30, 2), =3D=3D, 2); - g_assert_cmpuint(apicid_die_width(4, 30, 2), =3D=3D, 2); + topo_info =3D (X86CPUTopoInfo) {1, 1, 2}; + g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 1); + topo_info =3D (X86CPUTopoInfo) {1, 1, 3}; + g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); + topo_info =3D (X86CPUTopoInfo) {1, 1, 4}; + g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); + + topo_info =3D (X86CPUTopoInfo) {1, 1, 14}; + g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 4); + topo_info =3D (X86CPUTopoInfo) {1, 1, 15}; + g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 4); + topo_info =3D (X86CPUTopoInfo) {1, 1, 16}; + g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 4); + topo_info =3D (X86CPUTopoInfo) {1, 1, 17}; + g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 5); + + + topo_info =3D (X86CPUTopoInfo) {1, 30, 2}; + g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 5); + topo_info =3D (X86CPUTopoInfo) {1, 31, 2}; + g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 5); + topo_info =3D (X86CPUTopoInfo) {1, 32, 2}; + g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 5); + topo_info =3D (X86CPUTopoInfo) {1, 33, 2}; + g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 6); + + topo_info =3D (X86CPUTopoInfo) {1, 30, 2}; + g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 0); + topo_info =3D (X86CPUTopoInfo) {2, 30, 2}; + g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 1); + topo_info =3D (X86CPUTopoInfo) {3, 30, 2}; + g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 2); + topo_info =3D (X86CPUTopoInfo) {4, 30, 2}; + g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 2); =20 /* build a weird topology and see if IDs are calculated correctly */ =20 /* This will use 2 bits for thread ID and 3 bits for core ID */ - g_assert_cmpuint(apicid_smt_width(1, 6, 3), =3D=3D, 2); - g_assert_cmpuint(apicid_core_offset(1, 6, 3), =3D=3D, 2); - g_assert_cmpuint(apicid_die_offset(1, 6, 3), =3D=3D, 5); - g_assert_cmpuint(apicid_pkg_offset(1, 6, 3), =3D=3D, 5); + topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; + g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); + g_assert_cmpuint(apicid_core_offset(&topo_info), =3D=3D, 2); + g_assert_cmpuint(apicid_die_offset(&topo_info), =3D=3D, 5); + g_assert_cmpuint(apicid_pkg_offset(&topo_info), =3D=3D, 5); =20 topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), =3D=3D, 0); --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494604; cv=none; d=zohomail.com; s=zohoarc; b=cmLGShn2wwnhs0DLqGJT5DIMSqjCb6CsyqJYp/4fc4QVQyRXH39WV+M82E5VC36svi3ozr7MOQLlP/bdtIJddWXXGh1vkrv0cbYIRO3FAPfEZo1zOiFoc97ciat5afogZPx8gU4LglKqzniMy+ePXgy+LuaAOcCEy1Eu5wZgGX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494604; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KXPYI74UUQLKfuswF4jeS8KuX070oe1Vo0knYTlRAvE=; b=AAUl8lR4IH+qZIiPj2R8bpje7HPHDLMg94bCMyRdro6jHocUhRf6Lv5N9NeRCw7iLCtV5TkkBPdsf58uViBXXAAEnbf8FgGY7QZj1aM4s2zq1Nvjgp2cHqWaOCme4th8IwV8Nn1KwXLdoeF37wpx06qwdvEMq+K95wL6+UnTilA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494604429466.36262806108607; Tue, 17 Mar 2020 18:23:24 -0700 (PDT) Received: from localhost ([::1]:44036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENQZ-0002h8-Aj for importer@patchew.org; Tue, 17 Mar 2020 21:23:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34638) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLl-0004Y6-Nk for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLk-0002eS-DO for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:25 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:35816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLk-0002Zi-90 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-bu98x6YYO9-7J4_KFYQlSw-1; Tue, 17 Mar 2020 21:18:18 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 95431DB60; Wed, 18 Mar 2020 01:18:17 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79BCC19C58; Wed, 18 Mar 2020 01:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494303; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KXPYI74UUQLKfuswF4jeS8KuX070oe1Vo0knYTlRAvE=; b=LyxqXN0Nj67FLzIBZk2QAxIFJrQXL0zhKTdwv8ygCvZVLw530R/meXBw1ZX9v3H8kQToMJ +diGLIKClB4epmJ/iEgaeL8pHxYl9Oe5oCx/yStLDfoAYOmHhC0T4X0OWMIPPhvxPk5U0w UD/qdLuaRYHCkzNBRga91aXfku2wkCw= X-MC-Unique: bu98x6YYO9-7J4_KFYQlSw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 10/13] machine: Add SMP Sockets in CpuTopology Date: Tue, 17 Mar 2020 21:17:45 -0400 Message-Id: <20200318011748.2104336-11-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 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: Eduardo Habkost , "Michael S . Tsirkin" , Babu Moger , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Babu Moger 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 Acked-by: Michael S. Tsirkin Message-Id: <158396718647.58170.2278448323151215741.stgit@naples-babu.amd.c= om> --- hw/core/machine.c | 1 + hw/i386/pc.c | 1 + include/hw/boards.h | 2 ++ softmmu/vl.c | 1 + 4 files changed, 5 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index 4778bc6b08..b958cd1b99 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -757,6 +757,7 @@ static void smp_parse(MachineState *ms, QemuOpts *opts) ms->smp.cpus =3D cpus; ms->smp.cores =3D cores; ms->smp.threads =3D threads; + ms->smp.sockets =3D sockets; } =20 if (ms->smp.cpus > 1) { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 662abb549d..05e7f1090f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -781,6 +781,7 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) ms->smp.cpus =3D cpus; ms->smp.cores =3D cores; ms->smp.threads =3D threads; + ms->smp.sockets =3D sockets; x86ms->smp_dies =3D dies; } =20 diff --git a/include/hw/boards.h b/include/hw/boards.h index c96120d15f..236d239c19 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -236,12 +236,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; =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index 6a285925b3..1d33a28340 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3946,6 +3946,7 @@ void qemu_init(int argc, char **argv, char **envp) current_machine->smp.max_cpus =3D machine_class->default_cpus; current_machine->smp.cores =3D 1; current_machine->smp.threads =3D 1; + current_machine->smp.sockets =3D 1; =20 machine_class->smp_parse(current_machine, qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494794; cv=none; d=zohomail.com; s=zohoarc; b=hb8XKBfTbrPJsTKrxsYLg9gfQZVzTCrNHuVIIGEK2rA+MYCqpB7G8BrsrA4EF1TGOatqLJJqPCmyWDLX9nBttF1BhZbIrgDjEKYQRzIGp0ihgduAq/IwswD1S/RuX2jN45MybxOsUy8aiiepSIzjfKi5xPKxBInpAWU12yEZmRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494794; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xj0koGR1OOWTs/7O6WlMBbzTU6PRJEmOAi0wJCQpdTY=; b=kyBJEyjlo7530M7EQi+H7/LDeBg/ciLA60zSUT8XeZzXGH+8SPcwhwgdXXEcJjljBwMQM4fjqCMaJsVN2R0QVgjGDYfC4sH++sM4ZU/pt9TLlgP1Qdux4Uf62XXQEpw4MyUFL1VK7Z9ETiBsZ6DLNIDUJBnICtGQf3D6BaS9UFs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494794469964.1707186570554; Tue, 17 Mar 2020 18:26:34 -0700 (PDT) Received: from localhost ([::1]:44084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENTd-0006ey-Fa for importer@patchew.org; Tue, 17 Mar 2020 21:26:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34673) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLn-0004aI-Ij for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLl-0002no-Nc for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:27 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:33212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLl-0002ld-IW for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-GUY6RpzSPbiFRrIvkTDnSw-1; Tue, 17 Mar 2020 21:18:23 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03BBF800D50; Wed, 18 Mar 2020 01:18:22 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9A1E10016EB; Wed, 18 Mar 2020 01:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xj0koGR1OOWTs/7O6WlMBbzTU6PRJEmOAi0wJCQpdTY=; b=a7MH6+ToTluuJ+tlCpCh1WTEiMylQXFHLvltSOooXEMyxHGyjjFEkDCho+pJnzMKVPlehS N6rYwBZ0lVTjZCHoEnUJ7BqEO3d6cS/G0QUmLNJwz/vxiBsQwh9Y9Yu3/YR3zrlba4ze9l yuBBfTsTf7IwKzz4Xdo1zeyU9L3XjSM= X-MC-Unique: GUY6RpzSPbiFRrIvkTDnSw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 11/13] hw/i386: Remove unnecessary initialization in x86_cpu_new Date: Tue, 17 Mar 2020 21:17:46 -0400 Message-Id: <20200318011748.2104336-12-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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: Eduardo Habkost , "Michael S . Tsirkin" , Babu Moger , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Babu Moger The 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 Acked-by: Michael S. Tsirkin Message-Id: <158396719336.58170.11951852360759449871.stgit@naples-babu.amd.= com> --- hw/i386/x86.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index b7d94e8dfe..41b884605f 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 =3D NULL; Error *local_err =3D NULL; - CPUX86State *env =3D NULL; =20 cpu =3D object_new(MACHINE(x86ms)->cpu_type); =20 - env =3D &X86_CPU(cpu)->env; - env->nr_dies =3D x86ms->smp_dies; - object_property_set_uint(cpu, apic_id, "apic-id", &local_err); object_property_set_bool(cpu, true, "realized", &local_err); =20 --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494865; cv=none; d=zohomail.com; s=zohoarc; b=Db5XGwZDZoCEjWvsr2UOER1C/ozWM+7t6qpVK5F19hwsrcjjFsdA839QKEkpHkak48Vb5eibf6cWqH8Jrv83e9gFbN8v2+lt4tq4l6nl7O79P9uRKLCzsvUWoBqt1davdGEMvdhfwPmrM8vUwdcGHgVukBVTvd3MDmD+y8ne+AA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494865; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0Di2bKwmkhcLLcha49rb/0iGLRVyTDpUbFOqJuBsw3Q=; b=m96/3+czEPvpK9LiDbzWn1Io4CuiR/OJM/ccdVfA88ay2fhlvfpIwwoin7t3DvWaVDePm+I/FUfjbtFndoD8aPMEYT8SpzNFZlnA9m6gQJNACh/hteqY5aopGyd12yDPTvFwVmzfXN72GABsC7R3jnuciSjxEutU94uKP5027Is= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494865560996.1241229648157; Tue, 17 Mar 2020 18:27:45 -0700 (PDT) Received: from localhost ([::1]:44090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENUm-0007Yu-Aj for importer@patchew.org; Tue, 17 Mar 2020 21:27:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34743) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLs-0004c7-Bw for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLq-000342-Ox for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:32 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:49456) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLq-000315-2r for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-c5vFYE3UMxGiuItKiUPyRg-1; Tue, 17 Mar 2020 21:18:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F8FE8017CC; Wed, 18 Mar 2020 01:18:26 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD6F05D9E5; Wed, 18 Mar 2020 01:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494309; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Di2bKwmkhcLLcha49rb/0iGLRVyTDpUbFOqJuBsw3Q=; b=i26Ea9EfERCEPzBUJU7HqmBijvu5B5NOejEAMXNU/IG6dw3Yq9zJI+15zxMxDzNWa5fbW1 pblf9F4fkRGoeij5s7Gi3/Ks59fKsVVHwnp64wy705LL/26rAnl1j3r3kNZaPClGRS9Lrp x6xCB28Gzgr0ILop7nXT9g2sGpxVzYY= X-MC-Unique: c5vFYE3UMxGiuItKiUPyRg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 12/13] hw/i386: Update structures to save the number of nodes per package Date: Tue, 17 Mar 2020 21:17:47 -0400 Message-Id: <20200318011748.2104336-13-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 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: Eduardo Habkost , "Michael S . Tsirkin" , Babu Moger , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Babu Moger 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 Acked-by: Michael S. Tsirkin Message-Id: <158396720035.58170.1973738805301006456.stgit@naples-babu.amd.c= om> --- 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 + tests/test-x86-cpuid.c | 40 +++++++++++++++++++------------------- 6 files changed, 25 insertions(+), 20 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 05e7f1090f..ee89fcd1c3 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1525,6 +1525,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, init_topo_info(&topo_info, x86ms); =20 env->nr_dies =3D x86ms->smp_dies; + env->nr_nodes =3D topo_info.nodes_per_pkg; =20 /* * If APIC ID is not set, diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 41b884605f..87b73fe33c 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 =3D MACHINE(x86ms); =20 + topo_info->nodes_per_pkg =3D ms->numa_state->num_nodes / ms->smp.socke= ts; topo_info->dies_per_pkg =3D x86ms->smp_dies; topo_info->cores_per_die =3D ms->smp.cores; topo_info->threads_per_core =3D 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; =20 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 f1ac572efd..34b511f078 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6957,6 +6957,7 @@ static void x86_cpu_initfn(Object *obj) FeatureWord w; =20 env->nr_dies =3D 1; + env->nr_nodes =3D 1; cpu_set_cpustate_pointers(cpu); =20 object_property_add(obj, "family", "int", diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 68b186d258..7e9e963d78 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1609,6 +1609,7 @@ typedef struct CPUX86State { TPRAccess tpr_access_type; =20 unsigned nr_dies; + unsigned nr_nodes; } CPUX86State; =20 struct kvm_msrs; diff --git a/tests/test-x86-cpuid.c b/tests/test-x86-cpuid.c index bfabc0403a..049030a50e 100644 --- a/tests/test-x86-cpuid.c +++ b/tests/test-x86-cpuid.c @@ -31,12 +31,12 @@ static void test_topo_bits(void) X86CPUTopoInfo topo_info =3D {0}; =20 /* simple tests for 1 thread per core, 1 core per die, 1 die per packa= ge */ - topo_info =3D (X86CPUTopoInfo) {1, 1, 1}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 1, 1}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 0); g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 0); g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 0); =20 - topo_info =3D (X86CPUTopoInfo) {1, 1, 1}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 1, 1}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), =3D=3D, 0); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), =3D=3D, 1); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), =3D=3D, 2); @@ -45,39 +45,39 @@ static void test_topo_bits(void) =20 /* Test field width calculation for multiple values */ - topo_info =3D (X86CPUTopoInfo) {1, 1, 2}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 1, 2}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 1); - topo_info =3D (X86CPUTopoInfo) {1, 1, 3}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 1, 3}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); - topo_info =3D (X86CPUTopoInfo) {1, 1, 4}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 1, 4}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); =20 - topo_info =3D (X86CPUTopoInfo) {1, 1, 14}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 1, 14}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 4); - topo_info =3D (X86CPUTopoInfo) {1, 1, 15}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 1, 15}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 4); - topo_info =3D (X86CPUTopoInfo) {1, 1, 16}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 1, 16}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 4); - topo_info =3D (X86CPUTopoInfo) {1, 1, 17}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 1, 17}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 5); =20 =20 - topo_info =3D (X86CPUTopoInfo) {1, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 30, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 5); - topo_info =3D (X86CPUTopoInfo) {1, 31, 2}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 31, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 5); - topo_info =3D (X86CPUTopoInfo) {1, 32, 2}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 32, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 5); - topo_info =3D (X86CPUTopoInfo) {1, 33, 2}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 33, 2}; g_assert_cmpuint(apicid_core_width(&topo_info), =3D=3D, 6); =20 - topo_info =3D (X86CPUTopoInfo) {1, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 0); - topo_info =3D (X86CPUTopoInfo) {2, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {0, 2, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 1); - topo_info =3D (X86CPUTopoInfo) {3, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {0, 3, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 2); - topo_info =3D (X86CPUTopoInfo) {4, 30, 2}; + topo_info =3D (X86CPUTopoInfo) {0, 4, 30, 2}; g_assert_cmpuint(apicid_die_width(&topo_info), =3D=3D, 2); =20 /* build a weird topology and see if IDs are calculated correctly @@ -85,18 +85,18 @@ static void test_topo_bits(void) =20 /* This will use 2 bits for thread ID and 3 bits for core ID */ - topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 6, 3}; g_assert_cmpuint(apicid_smt_width(&topo_info), =3D=3D, 2); g_assert_cmpuint(apicid_core_offset(&topo_info), =3D=3D, 2); g_assert_cmpuint(apicid_die_offset(&topo_info), =3D=3D, 5); g_assert_cmpuint(apicid_pkg_offset(&topo_info), =3D=3D, 5); =20 - topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 6, 3}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 0), =3D=3D, 0); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1), =3D=3D, 1); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 2), =3D=3D, 2); =20 - topo_info =3D (X86CPUTopoInfo) {1, 6, 3}; + topo_info =3D (X86CPUTopoInfo) {0, 1, 6, 3}; g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 0), =3D= =3D, (1 << 2) | 0); g_assert_cmpuint(x86_apicid_from_cpu_idx(&topo_info, 1 * 3 + 1), =3D= =3D, --=20 2.24.1 From nobody Fri Nov 14 02:16:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584494671; cv=none; d=zohomail.com; s=zohoarc; b=LzWQep87XxA+HTs7UbSBDlP8yx6hDtpEwtcszgMSIJESeI41twQCi1MkjuoDaDxdg49sAaZkXE+d/l1gYUvumNHbatLH5pQSTPxhC1IRkalhB81ouZcfeCWgp9omECp1PpVIbFqCpAZhfvDDFCS/h1IjnTpkzJ3viJwcp2Kspa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584494671; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=voVjw1fARwKeDsQu+V/Sro8uXISbVenrGia2M0p4Cr0=; b=XAVjGr/ujGCdl9aVpuULL3bpt0c/w5ftsbTsicr/vNnp3g9/z4f/egCNlUJTndCUhitrXqpWcOUmjFnwfM/ngDUUAZQR5AszUXO4qf8WTfN+l4cR5FOLlzerWiViV82m2spyDUEfrRP6dAjzajlkh7N8k4ECYS8Knc9xg7OMQu4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584494671290430.04508793815796; Tue, 17 Mar 2020 18:24:31 -0700 (PDT) Received: from localhost ([::1]:44048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENRe-00040C-5q for importer@patchew.org; Tue, 17 Mar 2020 21:24:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34801) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jENLv-0004dp-Dg for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jENLu-0003Ua-35 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:35 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:46117) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jENLt-0003S6-VL for qemu-devel@nongnu.org; Tue, 17 Mar 2020 21:18:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-253-oarIuCOcMAu4_uJfJ3p8gQ-1; Tue, 17 Mar 2020 21:18:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5429518A5505; Wed, 18 Mar 2020 01:18:28 +0000 (UTC) Received: from localhost (ovpn-118-148.rdu2.redhat.com [10.10.118.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD66760BF3; Wed, 18 Mar 2020 01:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584494313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=voVjw1fARwKeDsQu+V/Sro8uXISbVenrGia2M0p4Cr0=; b=hUEsCIvTUwJSUc5t99IneFrQncUJx46HJOByu3fwg4WFEoqE6asvYtGTfEGhfbDhE8uJaz n0qkfdjGBpwY8AZcSZ//RoFNS7Ti1yq4wXopp/+5gz/U7lyijPJOmHzozDT+optlU7cHTK N4bRDKjqhC2rpmWP1MQD33b+RV6PvAE= X-MC-Unique: oarIuCOcMAu4_uJfJ3p8gQ-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 13/13] hw/i386: Rename apicid_from_topo_ids to x86_apicid_from_topo_ids Date: Tue, 17 Mar 2020 21:17:48 -0400 Message-Id: <20200318011748.2104336-14-ehabkost@redhat.com> In-Reply-To: <20200318011748.2104336-1-ehabkost@redhat.com> References: <20200318011748.2104336-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 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: Eduardo Habkost , "Michael S . Tsirkin" , Babu Moger , Igor Mammedov , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Babu Moger For consistency rename apicid_from_topo_ids to x86_apicid_from_topo_ids. No functional change. Signed-off-by: Babu Moger Reviewed-by: Igor Mammedov Acked-by: Michael S. Tsirkin Message-Id: <158396720748.58170.5335409429390890145.stgit@naples-babu.amd.c= om> --- 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 ee89fcd1c3..98ee763f68 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1580,7 +1580,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, topo_ids.die_id =3D cpu->die_id; topo_ids.core_id =3D cpu->core_id; topo_ids.smt_id =3D cpu->thread_id; - cpu->apic_id =3D apicid_from_topo_ids(&topo_info, &topo_ids); + cpu->apic_id =3D x86_apicid_from_topo_ids(&topo_info, &topo_ids); } =20 cpu_slot =3D 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(X86CPUT= opoInfo *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); } =20 #endif /* HW_I386_TOPOLOGY_H */ --=20 2.24.1