qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Babu Moger <babu.moger@amd.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org, imammedo@redhat.com,
	pbonzini@redhat.com, rth@twiddle.net
Subject: Re: [PATCH v7 07/13] hw/386: Add EPYC mode topology decoding functions
Date: Tue, 2 Jun 2020 13:18:38 -0400	[thread overview]
Message-ID: <20200602171838.GG577771@habkost.net> (raw)
In-Reply-To: <158396721426.58170.2930696192478912976.stgit@naples-babu.amd.com>

Hi,

It looks like this series breaks -device and CPU hotplug:

On Wed, Mar 11, 2020 at 05:53:34PM -0500, Babu Moger wrote:
> These functions add support for building EPYC mode topology given the smp
> details like numa nodes, cores, threads and sockets.
> 
> The new apic id decoding is mostly similar to current apic id decoding
> except that it adds a new field node_id when numa configured. Removes all
> the hardcoded values. Subsequent patches will use these functions to build
> the topology.
> 
> Following functions are added.
> apicid_llc_width_epyc
> apicid_llc_offset_epyc
> apicid_pkg_offset_epyc
> apicid_from_topo_ids_epyc
> x86_topo_ids_from_idx_epyc
> x86_topo_ids_from_apicid_epyc
> x86_apicid_from_cpu_idx_epyc
> 
> The topology details are available in Processor Programming Reference (PPR)
> for AMD Family 17h Model 01h, Revision B1 Processors. The revision guides are
> available from the bugzilla Link below.
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> Acked-by: Igor Mammedov <imammedo@redhat.com>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
[...]
>  typedef struct X86CPUTopoIDs {
>      unsigned pkg_id;
> +    unsigned node_id;

You have added a new field here.

>      unsigned die_id;
>      unsigned core_id;
>      unsigned smt_id;
[...]
> +static inline apic_id_t
> +x86_apicid_from_topo_ids_epyc(X86CPUTopoInfo *topo_info,
> +                              const X86CPUTopoIDs *topo_ids)
> +{
> +    return (topo_ids->pkg_id  << apicid_pkg_offset_epyc(topo_info)) |
> +           (topo_ids->node_id << apicid_node_offset_epyc(topo_info)) |

You are using the new field here.

> +           (topo_ids->die_id  << apicid_die_offset(topo_info)) |
> +           (topo_ids->core_id << apicid_core_offset(topo_info)) |
> +           topo_ids->smt_id;
> +}

But you are not initializing node_id in one caller of apicid_from_topo_ids():

static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
                            DeviceState *dev, Error **errp)
{
    [...]
    X86CPUTopoIDs topo_ids;
    [...]
    if (cpu->apic_id == UNASSIGNED_APIC_ID) {
        [...]
        topo_ids.pkg_id = cpu->socket_id;
        topo_ids.die_id = cpu->die_id;
        topo_ids.core_id = cpu->core_id;
        topo_ids.smt_id = cpu->thread_id;
        cpu->apic_id = x86ms->apicid_from_topo_ids(&topo_info, &topo_ids);
    }
    [...]
}

Result: -device is broken when using -cpu EPYC:

  $ qemu-system-x86_64 -machine q35,accel=kvm -smp 1,maxcpus=2,cores=1,threads=1,sockets=2 -cpu EPYC -device EPYC-x86_64-cpu,core-id=0,socket-id=1,thread-id=0
  qemu-system-x86_64: -device EPYC-x86_64-cpu,core-id=0,socket-id=1,thread-id=0: Invalid CPU [socket: 21855, die: 0, core: 0, thread: 0] with APIC ID 21855, valid index range 0:1

This happens because APIC ID is calculated using uninitialized
memory.

-- 
Eduardo



  parent reply	other threads:[~2020-06-02 17:19 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 22:52 [PATCH v7 00/13] APIC ID fixes for AMD EPYC CPU model Babu Moger
2020-03-11 22:52 ` [PATCH v7 01/13] hw/i386: Introduce X86CPUTopoInfo to contain topology info Babu Moger
2020-03-12 11:11   ` Igor Mammedov
2020-03-11 22:52 ` [PATCH v7 02/13] hw/i386: Consolidate topology functions Babu Moger
2020-03-11 22:53 ` [PATCH v7 03/13] machine: Add SMP Sockets in CpuTopology Babu Moger
2020-03-11 22:53 ` [PATCH v7 04/13] hw/i386: Remove unnecessary initialization in x86_cpu_new Babu Moger
2020-03-11 22:53 ` [PATCH v7 05/13] hw/i386: Update structures to save the number of nodes per package Babu Moger
2020-03-11 22:53 ` [PATCH v7 06/13] hw/i386: Rename apicid_from_topo_ids to x86_apicid_from_topo_ids Babu Moger
2020-03-11 22:53 ` [PATCH v7 07/13] hw/386: Add EPYC mode topology decoding functions Babu Moger
2020-03-12 12:39   ` Igor Mammedov
2020-03-12 13:44     ` Babu Moger
2020-06-02 17:18   ` Eduardo Habkost [this message]
2020-06-02 17:27     ` Babu Moger
2020-06-02 21:59     ` Babu Moger
2020-06-02 23:01       ` Eduardo Habkost
2020-06-03  0:07         ` Babu Moger
2020-06-03 15:22         ` Babu Moger
2020-06-03 15:31           ` Eduardo Habkost
2020-06-03 15:38             ` Babu Moger
2020-06-03 15:45               ` Eduardo Habkost
2020-06-03 15:49                 ` Babu Moger
2020-06-03 21:49                 ` Babu Moger
2020-06-15 11:44                   ` Dr. David Alan Gilbert
2020-03-11 22:53 ` [PATCH v7 08/13] target/i386: Cleanup and use the EPYC mode topology functions Babu Moger
2020-03-11 22:53 ` [PATCH v7 09/13] hw/i386: Introduce apicid functions inside X86MachineState Babu Moger
2020-03-11 22:53 ` [PATCH v7 10/13] i386: Introduce use_epyc_apic_id_encoding in X86CPUDefinition Babu Moger
2020-03-12 12:26   ` Igor Mammedov
2020-03-11 22:54 ` [PATCH v7 11/13] hw/i386: Move arch_id decode inside x86_cpus_init Babu Moger
2020-03-12 12:31   ` Igor Mammedov
2020-03-11 22:54 ` [PATCH v7 12/13] target/i386: Enable new apic id encoding for EPYC based cpus models Babu Moger
2020-03-11 22:54 ` [PATCH v7 13/13] i386: Fix pkg_id offset for EPYC cpu models Babu Moger
2020-03-12 16:28 ` [PATCH v7 00/13] APIC ID fixes for AMD EPYC CPU model Babu Moger
2020-03-17 23:22   ` Eduardo Habkost
2020-03-17 23:31     ` Moger, Babu
2020-03-17 23:46     ` Eduardo Habkost
2020-03-18  2:43       ` Moger, Babu
2020-03-18 10:47         ` Igor Mammedov
2020-03-23 15:35           ` Moger, Babu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200602171838.GG577771@habkost.net \
    --to=ehabkost@redhat.com \
    --cc=babu.moger@amd.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).