[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH v8 4/4] xen/acpi: Parse PPTT to initialize CPU topology


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Date: Mon, 27 Jul 2026 23:17:59 +0000
  • Accept-language: ja-JP, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vfJzogbwymaJ9OrHrtkVra8sDWWYllqiXZClkRHUJ4k=; b=kBcY4hV9vVoYwK9UTu6gSWxy28WxLqeMKPIe1YMVOpRnjGhpqGkubUqvyKrBouWNe153DORvx2KHUFAxJFd4yXVSA606mo/ruszjmG/igD7WlAbU6gyT+2ExthYsN5aufSy0prD/lCEn+kuhCEs/ycrw+kOVZcavEh/4fe1xDm/Xop2Lj5f5iK03peLq8DvksZcw/6AyBoAAOFv/GcCe0Tx2TZXF4qRE84UKQaNUvBozL/ZJQf5zfY7tfUCRN8B0nFvKAtt2pjTh4yjLdpeFbi6FSEGPnVnEVXTaSn4DOp8Ww3sBdauJa/yqeogGuPRvQhBz3YpDEoWzFczA1bgn4A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ySFg5Wijlbjxsmepnd0525jY3hVsA2k6WrzREFFcBjOIs2Od0CHlx060OsevMMn912HEulxlgsAY7pCONPIUGwXKaKbcla5Phs0U5lOCJy84p4JzKIo9OJc3h4Dg2eQf/eoriV6yXXoY52GrNOqoYvg3tfOLZPq+1Yw1M7AeGp4YWLp4oueZGiy9Dy80g+Vnu0YcHWbv9BqZ1+Y+4u1vLrxqi4Bxo2aJtklOq3wJlXyt3S55Z9VLjhetS/C+Fun2WebUpII8aYWhRnweFHkBob0nencZyOQsCm7/tO4yUNz5ulEMbMwNow+lLmCH8qNcm3G2YeRanEXox0beQq1ONg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp;
  • Cc: "Mykyta_Poturai@xxxxxxxx" <Mykyta_Poturai@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 27 Jul 2026 23:18:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdHJl7CqbIatZ8bkec5VHVmdD2PraBVbMAgACjEnA=
  • Thread-topic: [PATCH v8 4/4] xen/acpi: Parse PPTT to initialize CPU topology

Hi Jan,

> > +    table_size = sizeof(*proc)
> > +        + (unsigned long)proc->number_of_priv_resources * sizeof(uint32_t);
> 
> ... holds for all binary operators, i.e. also the + here. Indentation of the
> continuing line would also better be

Okay,

>     table_size = sizeof(*proc) +
>                  (unsigned long)proc->number_of_priv_resources * 
> sizeof(uint32_t);
> 
> Where I'd then still question the need for the cast: The operation is, afaict,
> the same with it dropped, both in ILP32 and LP64 models. With one exception -
> there is an overflow potentially getting in the way, but the cast helps with
> that only in LP64. Question is whether too large a ->number_of_priv_resources
> wouldn't better be rejected uniformly as presumably bogus.

I will add code to check if the number of private resources fits within the 
limit 
derived from the maximum subtable size (255 bytes).

> > +
> > +    if ( proc->header.length < table_size )
> > +    {
> > +        printk(XENLOG_ERR "ACPI: PPTT processor node length invalid\n");
> > +        return false;
> > +    }
> > +
> > +    return true;
> > +}
> > +
> > +static const struct acpi_pptt_processor *__init find_pptt_node(
> > +    const struct acpi_table_pptt *pptt, uint32_t acpi_id)
> > +{
> > +    const struct acpi_subtable_header *entry;
> > +    unsigned long table_end = (unsigned long)pptt + pptt->header.length;
> > +    const void *ptr = pptt + 1;
> > +
> > +    while ( (unsigned long)ptr + sizeof(*entry) <= table_end )
> > +    {
> > +        entry = ptr;
> > +
> > +        if ( !verify_subtable(entry, pptt) )
> > +            break;
> > +
> > +        if ( entry->type == ACPI_PPTT_TYPE_PROCESSOR )
> > +        {
> > +            const struct acpi_pptt_processor *proc;
> > +
> > +            proc = container_of(entry, const struct acpi_pptt_processor,
> > +                                header);
> 
> Have this be the initializer of the variable:
> 
>             const struct acpi_pptt_processor *proc =
>                 container_of(entry, const struct acpi_pptt_processor, header);

Ok.

> > +    for_each_possible_cpu(cpu)
> > +    {
> > +        uint32_t acpi_id = map_cpu_acpiid[cpu];
> 
> You may end up reading INVALID_ACPIID here. Then ...
> 
> > +        struct cpu_topology *topo = &cpu_topology[cpu];
> > +        const struct acpi_pptt_processor *proc;
> > +        unsigned int level;
> > +        unsigned int core_group_key = 0;
> > +        unsigned int cluster_group_key = 0;
> > +        unsigned int socket_group_key = 0;
> > +        bool threading = false;
> > +
> > +        proc = find_pptt_node(pptt, acpi_id);
> 
> ... a bogus table entry with that ID would be found here, potentially for
> multiple values of "cpu".

Understood, I will add code to ensure 'acpi_id' is valid.

> > +            /*
> > +             * If this proc has no parent node, it is the root node. Treat 
> > it
> > +             * as equivalent to an ACPI_PPTT_PHYSICAL_PACKAGE node.
> > +             */
> > +            if ( proc->flags & ACPI_PPTT_PHYSICAL_PACKAGE || !proc->parent 
> > )
> 
> You say in the revlog that you added parentheses, but at least here you
> didn't.

Oops, I will fix it.

Thank you,
Hirokazu Takahashi.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.