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

RE: [PATCH v7 5/5] xen/acpi: Parse PPTT to initialize CPU topology


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Date: Sat, 25 Jul 2026 07:45:22 +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=h8a7G4QUlLhL64z34KSEucbUQ5kcfbKAYyVNW+iqL6o=; b=em0AyaExRWF81z55R77VS2zCb0+67hZjD5TO63zcdq6oKdK4opqVgaZ8hi5C3oLz1xlGhLGPnLePmNq+/8WwkNiFONEsFXxsxg8TXztMhFfsbFDkkJP8HQLD+DbNyojSYKdTdPcOWCzJ9OUABBLaPZitcnT7LJwYYTupblc7f8/MSYld7MEmQsn2xbaFCuUTuTifFifBn2oem5ovjz+PT4e+3YAhSaSl/3UnEOpez7TmOoTsCm2iGB8+ehz6FX5LcYNvc0v3//rr/qNxy0shX+nvX8QHvoipKNHUuUz2BrxQoJIohUKjUHbLduYW8BsEG2EhcKAhczMiW3AD1Eq9sw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z+Yytyr0xhOgg9+3ViFKZ3c4c6fUyLtOjIaaH844Rr9TkxEa8y/UnGNTJ39RLFnLD14ISl66K5hlS1dapIbGprkWx9aJapiAtGJklTx/iX6dDbay02BCfGEnpVnSP7Opu4egvlZIiD9d//dQSYxP5sye5HxhLuUjoDIbJ96kIlWq+TXKbj0+WaEYGu20SR2RHQa3u91rhrVwFprGqtWLOns5/QRLcMLEVMQlHhyfNUybzQPCJypLMSQdf7bL17eIqdFN53DG3dk7yUQO9HU42C/vnFd6pxRhC+kTLG6ucPwbTjCOt6j9WRsQIP919NPZULaRPNSJE434sI0Nv7Wjfg==
  • 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>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Sat, 25 Jul 2026 07:45:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdGGUJxRKGqVdhdUeL5+uGF+qgy7Z7MHsAgAKpzwA=
  • Thread-topic: [PATCH v7 5/5] xen/acpi: Parse PPTT to initialize CPU topology

Hi Jan,

> > --- a/xen/arch/arm/include/asm/acpi.h
> > +++ b/xen/arch/arm/include/asm/acpi.h
> > @@ -61,6 +61,8 @@ paddr_t acpi_get_table_offset(struct membank tbl_add[], 
> > EFI_MEM_RES index);
> >      (!(entry) || (unsigned long)(entry) + sizeof(*(entry)) > (end) ||      
> > \
> >       (entry)->header.length != ACPI_MADT_GICC_LENGTH)
> >
> > +#define INVALID_ACPIID             (-1U)
> 
> This way the constant is becoming available only on Arm, but ...
> 
> > --- a/xen/drivers/acpi/topology.c
> > +++ b/xen/drivers/acpi/topology.c
> > @@ -4,33 +4,319 @@
> >  #include <xen/cpu-topology.h>
> >  #include <xen/cpumask.h>
> >  #include <xen/init.h>
> > +#include <xen/xvmalloc.h>
> > +
> > +#define ACPI_PPTT_MAX_LEVELS 16
> > +
> > +static uint32_t __initdata map_cpu_acpiid[NR_CPUS] = {
> > +    [0 ... NR_CPUS - 1] = INVALID_ACPIID
> 
> ... you use it in code which (in principle) isn't Arm-specific (it only
> happens to be right now).

Okay, I will move the definition in xen/acpi.h.

> >  /*
> > - * TODO: Populate the topology information by scanning the ACPI
> > - *       PPTT (Processor Properties Topology Table).
> > + * The first argument 'cpu' is the logical CPU ID assigned by Xen,
> > + * and the second argument 'acpi_id' is passed the 'uid' field from
> > + * the ACPI MADT Generic Interrupt subtable.
> 
> This comment also looks to be (in part) Arm-specific, which it shouldn't be
> here.

Okay.

> > +static bool __init verify_subtable(const struct acpi_subtable_header 
> > *entry,
> > +                                   const struct acpi_table_pptt *pptt)
> > +{
> > +    unsigned long table_end = (unsigned long)pptt + pptt->header.length;
> > +
> > +    if ( entry->length < sizeof(*entry) || entry->length & 3 )
> 
> Parentheses please around & or alike within || or alike.

Okay.

> > +    {
> > +        printk(XENLOG_ERR "ACPI: PPTT subtable length is invalid\n");
> 
> Like you have it here, ...
> 
> > +        return false;
> > +    }
> > +
> > +    if ( (unsigned long)entry + entry->length > table_end )
> > +    {
> > +        printk(XENLOG_ERR "ACPI: PPTT subtable extends beyond table 
> > end.\n");
> 
> ... no full stop please in log messages (applies elsewhere as well).

Okay.

> > +static bool __init verify_proc(const struct acpi_pptt_processor *proc)
> > +{
> > +    unsigned long table_size;
> > +
> > +    if ( proc->header.length < sizeof(*proc) )
> > +    {
> > +        printk(XENLOG_ERR "ACPI: PPTT processor node length is too 
> > small.\n");
> > +        return false;
> > +    }
> >
> >      /*
> > -     * Generate temporary cpu topology information for now.
> > -     * It assumes that the cpu doesn't have SMT and all CPUs
> > -     * belong to the same socket.
> > +     * Each private resource is represented by a 32-bit resource ID.
> > +     * Ensure the structure length accurately accounts for the trailing 
> > array.
> >       */
> > +    table_size = sizeof(*proc)
> > +        + (unsigned long)proc->number_of_priv_resources * sizeof(uint32_t);
> > +
> > +    if ( proc->header.length != table_size )
> 
> Isn't != overly strict?

I will replace it with "if ( proc->header.length < table_size )."

> > +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;
> > +    const void *ptr;
> > +
> > +    table_end = (unsigned long)pptt + pptt->header.length;
> > +
> > +    ptr = pptt + 1;
> 
> Make these the initializers of their variables?

Okay.

> > +            if ( (proc->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID)
> > +                 && proc->acpi_processor_id == acpi_id
> > +                 && (pptt->header.revision < 2
> > +                     || (proc->flags & ACPI_PPTT_ACPI_LEAF_NODE)) )
> 
> Misplaced binary operators (also elsewhere). On continued lines they go at
> the end of the earlier line.

Okay.

> > +        proc = find_pptt_node(pptt, acpi_id);
> > +        if ( !proc )
> > +        {
> > +            printk(XENLOG_WARNING
> > +                   "ACPI: No PPTT leaf node for CPU %u (ACPI ID 0x%u)\n",
> 
> Please prefer the slightly shorter %#x (and definitely please don't mix a 0x
> prefix with %u). Again applies elsewhere as well.

Okay.

Thank you,
Hirokazu Takahashi.

 


Rackspace

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