diff mbox series

[1/2] hmat acpi: Do not add Memory Proximity Domain Attributes Structure targetting non existent memory.

Message ID 20240229162545.7887-2-Jonathan.Cameron@huawei.com (mailing list archive)
State New, archived
Headers show
Series hw/acpi/hmat: Misc fixes | expand

Commit Message

Jonathan Cameron Feb. 29, 2024, 4:25 p.m. UTC
If qemu is started with a proximity node containing CPUs alone,
it will provide one of these structures to say memory in this
node is directly connected to itself.

This description is arguably pointless even if there is memory
in the node.  If there is no memory present, and hence no SRAT
entry it breaks Linux HMAT passing and the table is rejected.

https://elixir.bootlin.com/linux/latest/source/drivers/acpi/numa/hmat.c#L444

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 hw/acpi/hmat.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Gregory Price Feb. 29, 2024, 5:28 p.m. UTC | #1
On Thu, Feb 29, 2024 at 04:25:44PM +0000, Jonathan Cameron wrote:
> If qemu is started with a proximity node containing CPUs alone,
> it will provide one of these structures to say memory in this
> node is directly connected to itself.
> 
> This description is arguably pointless even if there is memory
> in the node.  If there is no memory present, and hence no SRAT
> entry it breaks Linux HMAT passing and the table is rejected.
> 
> https://elixir.bootlin.com/linux/latest/source/drivers/acpi/numa/hmat.c#L444
> 

Nit: This link becomes out of date pretty much immediately, consider
using a versioned link.

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>  hw/acpi/hmat.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c
> index 3042d223c8..723ae28d32 100644
> --- a/hw/acpi/hmat.c
> +++ b/hw/acpi/hmat.c
> @@ -204,6 +204,13 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
>      build_append_int_noprefix(table_data, 0, 4); /* Reserved */
>  
>      for (i = 0; i < numa_state->num_nodes; i++) {
> +        /*
> +         * Linux rejects whole HMAT table if a node with no memory
> +         * has one of these structures listing it as a target.
> +         */
> +        if (!numa_state->nodes[i].node_mem) {
> +            continue;
> +        }
>          flags = 0;
>  
>          if (numa_state->nodes[i].initiator < MAX_NODES) {
> -- 
> 2.39.2
> 
>
Jonathan Cameron Feb. 29, 2024, 5:52 p.m. UTC | #2
On Thu, 29 Feb 2024 12:28:51 -0500
Gregory Price <gregory.price@memverge.com> wrote:

> On Thu, Feb 29, 2024 at 04:25:44PM +0000, Jonathan Cameron wrote:
> > If qemu is started with a proximity node containing CPUs alone,
> > it will provide one of these structures to say memory in this
> > node is directly connected to itself.
> > 
> > This description is arguably pointless even if there is memory
> > in the node.  If there is no memory present, and hence no SRAT
> > entry it breaks Linux HMAT passing and the table is rejected.
> > 
> > https://elixir.bootlin.com/linux/latest/source/drivers/acpi/numa/hmat.c#L444
> >   
> 
> Nit: This link becomes out of date pretty much immediately, consider
> using a versioned link.
Good point.

https://elixir.bootlin.com/linux/v6.7/source/drivers/acpi/numa/hmat.c#L444

> 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > ---
> >  hw/acpi/hmat.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c
> > index 3042d223c8..723ae28d32 100644
> > --- a/hw/acpi/hmat.c
> > +++ b/hw/acpi/hmat.c
> > @@ -204,6 +204,13 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
> >      build_append_int_noprefix(table_data, 0, 4); /* Reserved */
> >  
> >      for (i = 0; i < numa_state->num_nodes; i++) {
> > +        /*
> > +         * Linux rejects whole HMAT table if a node with no memory
> > +         * has one of these structures listing it as a target.
> > +         */
> > +        if (!numa_state->nodes[i].node_mem) {
> > +            continue;
> > +        }
> >          flags = 0;
> >  
> >          if (numa_state->nodes[i].initiator < MAX_NODES) {
> > -- 
> > 2.39.2
> > 
> >
diff mbox series

Patch

diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c
index 3042d223c8..723ae28d32 100644
--- a/hw/acpi/hmat.c
+++ b/hw/acpi/hmat.c
@@ -204,6 +204,13 @@  static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
     build_append_int_noprefix(table_data, 0, 4); /* Reserved */
 
     for (i = 0; i < numa_state->num_nodes; i++) {
+        /*
+         * Linux rejects whole HMAT table if a node with no memory
+         * has one of these structures listing it as a target.
+         */
+        if (!numa_state->nodes[i].node_mem) {
+            continue;
+        }
         flags = 0;
 
         if (numa_state->nodes[i].initiator < MAX_NODES) {