[PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()

Philippe Mathieu-Daudé posted 3 patches 5 months, 3 weeks ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, "Frédéric Barrat" <fbarrat@linux.ibm.com>
[PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()
Posted by Philippe Mathieu-Daudé 5 months, 3 weeks ago
Since commit 9808ce6d5cb, building QEMU configured with
'--without-default-devices' fails:

  Undefined symbols for architecture arm64:
    "_pnv_chip_find_core", referenced from:
        _helper_load_sprd in target_ppc_misc_helper.c.o
        _helper_store_sprd in target_ppc_misc_helper.c.o
  ld: symbol(s) not found for architecture arm64
  clang: error: linker command failed with exit code 1

Fix by adding a stub when CONFIG_POWERNV is not available.

Reported-by: Thomas Huth <thuth@redhat.com>
Fixes: 9808ce6d5cb ("target/ppc: Big-core scratch register fix")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/ppc/pnv_stub.c  | 15 +++++++++++++++
 hw/ppc/meson.build |  3 ++-
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 hw/ppc/pnv_stub.c

diff --git a/hw/ppc/pnv_stub.c b/hw/ppc/pnv_stub.c
new file mode 100644
index 00000000000..8d11c8b65bb
--- /dev/null
+++ b/hw/ppc/pnv_stub.c
@@ -0,0 +1,15 @@
+/*
+ * QEMU PowerPC PowerNV stubs
+ *
+ *  Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/ppc/pnv.h"
+
+PnvCore *pnv_chip_find_core(PnvChip *chip, uint32_t core_id)
+{
+    g_assert_not_reached();
+}
diff --git a/hw/ppc/meson.build b/hw/ppc/meson.build
index 9893f8adebb..02f248f5f46 100644
--- a/hw/ppc/meson.build
+++ b/hw/ppc/meson.build
@@ -55,7 +55,8 @@ ppc_ss.add(when: 'CONFIG_POWERNV', if_true: files(
   'pnv_pnor.c',
   'pnv_nest_pervasive.c',
   'pnv_n1_chiplet.c',
-))
+), if_false: files('pnv_stub.c'))
+
 # PowerPC 4xx boards
 ppc_ss.add(when: 'CONFIG_PPC440', if_true: files(
   'ppc440_bamboo.c',
-- 
2.47.1


Re: [PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()
Posted by Cédric Le Goater 5 months, 3 weeks ago
On 5/26/25 13:23, Philippe Mathieu-Daudé wrote:
> Since commit 9808ce6d5cb, building QEMU configured with
> '--without-default-devices' fails:
> 
>    Undefined symbols for architecture arm64:
>      "_pnv_chip_find_core", referenced from:
>          _helper_load_sprd in target_ppc_misc_helper.c.o
>          _helper_store_sprd in target_ppc_misc_helper.c.o
>    ld: symbol(s) not found for architecture arm64
>    clang: error: linker command failed with exit code 1
> > Fix by adding a stub when CONFIG_POWERNV is not available.

The fix would be to add an abstract handler to implement SPRD accesses
on the PowerNV machine.

Thanks,

C.



> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Fixes: 9808ce6d5cb ("target/ppc: Big-core scratch register fix")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/ppc/pnv_stub.c  | 15 +++++++++++++++
>   hw/ppc/meson.build |  3 ++-
>   2 files changed, 17 insertions(+), 1 deletion(-)
>   create mode 100644 hw/ppc/pnv_stub.c
> 
> diff --git a/hw/ppc/pnv_stub.c b/hw/ppc/pnv_stub.c
> new file mode 100644
> index 00000000000..8d11c8b65bb
> --- /dev/null
> +++ b/hw/ppc/pnv_stub.c
> @@ -0,0 +1,15 @@
> +/*
> + * QEMU PowerPC PowerNV stubs
> + *
> + *  Copyright (c) Linaro
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#include "qemu/osdep.h"
> +#include "hw/ppc/pnv.h"
> +
> +PnvCore *pnv_chip_find_core(PnvChip *chip, uint32_t core_id)
> +{
> +    g_assert_not_reached();
> +}
> diff --git a/hw/ppc/meson.build b/hw/ppc/meson.build
> index 9893f8adebb..02f248f5f46 100644
> --- a/hw/ppc/meson.build
> +++ b/hw/ppc/meson.build
> @@ -55,7 +55,8 @@ ppc_ss.add(when: 'CONFIG_POWERNV', if_true: files(
>     'pnv_pnor.c',
>     'pnv_nest_pervasive.c',
>     'pnv_n1_chiplet.c',
> -))
> +), if_false: files('pnv_stub.c'))
> +
>   # PowerPC 4xx boards
>   ppc_ss.add(when: 'CONFIG_PPC440', if_true: files(
>     'ppc440_bamboo.c',


Re: [PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()
Posted by Philippe Mathieu-Daudé 5 months, 3 weeks ago
On 26/5/25 13:48, Cédric Le Goater wrote:
> On 5/26/25 13:23, Philippe Mathieu-Daudé wrote:
>> Since commit 9808ce6d5cb, building QEMU configured with
>> '--without-default-devices' fails:
>>
>>    Undefined symbols for architecture arm64:
>>      "_pnv_chip_find_core", referenced from:
>>          _helper_load_sprd in target_ppc_misc_helper.c.o
>>          _helper_store_sprd in target_ppc_misc_helper.c.o
>>    ld: symbol(s) not found for architecture arm64
>>    clang: error: linker command failed with exit code 1
>> > Fix by adding a stub when CONFIG_POWERNV is not available.
> 
> The fix would be to add an abstract handler to implement SPRD accesses
> on the PowerNV machine.

I don't know what "SPRD" is so I'll let someone more familiar with
this area do the proper cleanup.

Regards,

Phil.

> 
> Thanks,
> 
> C.


Re: [PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()
Posted by Aditya Gupta 3 months, 3 weeks ago
Hi Cédric and Philippe,


On 26/05/25 17:21, Philippe Mathieu-Daudé wrote:
> On 26/5/25 13:48, Cédric Le Goater wrote:
>> On 5/26/25 13:23, Philippe Mathieu-Daudé wrote:
>>> Since commit 9808ce6d5cb, building QEMU configured with
>>> '--without-default-devices' fails:
>>>
>>>    Undefined symbols for architecture arm64:
>>>      "_pnv_chip_find_core", referenced from:
>>>          _helper_load_sprd in target_ppc_misc_helper.c.o
>>>          _helper_store_sprd in target_ppc_misc_helper.c.o
>>>    ld: symbol(s) not found for architecture arm64
>>>    clang: error: linker command failed with exit code 1
>>> > Fix by adding a stub when CONFIG_POWERNV is not available.
>>
>> The fix would be to add an abstract handler to implement SPRD accesses
>> on the PowerNV machine.


Is this what you meant by an abstract handler ?
https://github.com/adi-g15-ibm/qemu/commit/0abac37032a5ef66d64a649ce04f24876bf9007d


The thing done, is just to introduce a function pointer in 
'PowerPCCPUClass',
namely 'handle_sprd_store' and 'handle_sprd_load'


These will be set in the PNV chip realize path, so now the SPRD code in
target/ppc, will only call this for PowerNV.

Separated the powernv specific code, so target/ppc code doesn't depend
on pnv calls now.


Not well tested, will try somethings.


Thanks,

Aditya Gupta


>
> I don't know what "SPRD" is so I'll let someone more familiar with
> this area do the proper cleanup.
>
> Regards,
>
> Phil.
>
>>
>> Thanks,
>>
>> C.
>
>

Re: [PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()
Posted by Philippe Mathieu-Daudé 3 months ago
On 22/7/25 20:04, Aditya Gupta wrote:
> Hi Cédric and Philippe,
> 
> 
> On 26/05/25 17:21, Philippe Mathieu-Daudé wrote:
>> On 26/5/25 13:48, Cédric Le Goater wrote:
>>> On 5/26/25 13:23, Philippe Mathieu-Daudé wrote:
>>>> Since commit 9808ce6d5cb, building QEMU configured with
>>>> '--without-default-devices' fails:
>>>>
>>>>    Undefined symbols for architecture arm64:
>>>>      "_pnv_chip_find_core", referenced from:
>>>>          _helper_load_sprd in target_ppc_misc_helper.c.o
>>>>          _helper_store_sprd in target_ppc_misc_helper.c.o
>>>>    ld: symbol(s) not found for architecture arm64
>>>>    clang: error: linker command failed with exit code 1
>>>> > Fix by adding a stub when CONFIG_POWERNV is not available.
>>>
>>> The fix would be to add an abstract handler to implement SPRD accesses
>>> on the PowerNV machine.
> 
> 
> Is this what you meant by an abstract handler ?
> https://github.com/adi-g15-ibm/qemu/ 
> commit/0abac37032a5ef66d64a649ce04f24876bf9007d

I think so.

Avoid using target_ulong if possible (I suppose SPRD only exists on
64-bit CPUs so can be uint64_t).

> 
> 
> The thing done, is just to introduce a function pointer in 
> 'PowerPCCPUClass',
> namely 'handle_sprd_store' and 'handle_sprd_load'
> 
> 
> These will be set in the PNV chip realize path, so now the SPRD code in
> target/ppc, will only call this for PowerNV.
> 
> Separated the powernv specific code, so target/ppc code doesn't depend
> on pnv calls now.
> 
> 
> Not well tested, will try somethings.
> 
> 
> Thanks,
> 
> Aditya Gupta
> 
> 
>>
>> I don't know what "SPRD" is so I'll let someone more familiar with
>> this area do the proper cleanup.
>>
>> Regards,
>>
>> Phil.
>>
>>>
>>> Thanks,
>>>
>>> C.
>>
>>



Re: [PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()
Posted by Aditya Gupta 2 months, 3 weeks ago
+Michael

On 11/08/25 14:10, Philippe Mathieu-Daudé wrote:
> On 22/7/25 20:04, Aditya Gupta wrote:
>> Hi Cédric and Philippe,
>>
>>
>> On 26/05/25 17:21, Philippe Mathieu-Daudé wrote:
>>> On 26/5/25 13:48, Cédric Le Goater wrote:
>>>> On 5/26/25 13:23, Philippe Mathieu-Daudé wrote:
>>>>> Since commit 9808ce6d5cb, building QEMU configured with
>>>>> '--without-default-devices' fails:
>>>>>
>>>>>    Undefined symbols for architecture arm64:
>>>>>      "_pnv_chip_find_core", referenced from:
>>>>>          _helper_load_sprd in target_ppc_misc_helper.c.o
>>>>>          _helper_store_sprd in target_ppc_misc_helper.c.o
>>>>>    ld: symbol(s) not found for architecture arm64
>>>>>    clang: error: linker command failed with exit code 1
>>>>> > Fix by adding a stub when CONFIG_POWERNV is not available.
>>>>
>>>> The fix would be to add an abstract handler to implement SPRD accesses
>>>> on the PowerNV machine.
>>
>>
>> Is this what you meant by an abstract handler ?
>> https://github.com/adi-g15-ibm/qemu/ 
>> commit/0abac37032a5ef66d64a649ce04f24876bf9007d
>
> I think so.
>
> Avoid using target_ulong if possible (I suppose SPRD only exists on
> 64-bit CPUs so can be uint64_t).


Thanks Phil. Posted along with your suggested change:

https://lore.kernel.org/qemu-devel/20250820122516.949766-2-adityag@linux.ibm.com/


Thanks,

- Aditya G



Re: [PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()
Posted by Michael Tokarev 4 months ago
Hi!

Has this change been forgotten?

Thanks,

/mjt

On 26.05.2025 14:51, Philippe Mathieu-Daudé wrote:
> On 26/5/25 13:48, Cédric Le Goater wrote:
>> On 5/26/25 13:23, Philippe Mathieu-Daudé wrote:
>>> Since commit 9808ce6d5cb, building QEMU configured with
>>> '--without-default-devices' fails:
>>>
>>>    Undefined symbols for architecture arm64:
>>>      "_pnv_chip_find_core", referenced from:
>>>          _helper_load_sprd in target_ppc_misc_helper.c.o
>>>          _helper_store_sprd in target_ppc_misc_helper.c.o
>>>    ld: symbol(s) not found for architecture arm64
>>>    clang: error: linker command failed with exit code 1
>>> > Fix by adding a stub when CONFIG_POWERNV is not available.
>>
>> The fix would be to add an abstract handler to implement SPRD accesses
>> on the PowerNV machine.
> 
> I don't know what "SPRD" is so I'll let someone more familiar with
> this area do the proper cleanup.


Re: [PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()
Posted by Michael Tokarev 3 months, 1 week ago
On 13.07.2025 14:18, Michael Tokarev wrote:
> Hi!
> 
> Has this change been forgotten?

Another ping?

Or can we assume this change isn't needed anymore? :)

Thanks,

/mjt

> On 26.05.2025 14:51, Philippe Mathieu-Daudé wrote:
>> On 26/5/25 13:48, Cédric Le Goater wrote:
>>> On 5/26/25 13:23, Philippe Mathieu-Daudé wrote:
>>>> Since commit 9808ce6d5cb, building QEMU configured with
>>>> '--without-default-devices' fails:
>>>>
>>>>    Undefined symbols for architecture arm64:
>>>>      "_pnv_chip_find_core", referenced from:
>>>>          _helper_load_sprd in target_ppc_misc_helper.c.o
>>>>          _helper_store_sprd in target_ppc_misc_helper.c.o
>>>>    ld: symbol(s) not found for architecture arm64
>>>>    clang: error: linker command failed with exit code 1
>>>> > Fix by adding a stub when CONFIG_POWERNV is not available.
>>>
>>> The fix would be to add an abstract handler to implement SPRD accesses
>>> on the PowerNV machine.
>>
>> I don't know what "SPRD" is so I'll let someone more familiar with
>> this area do the proper cleanup.
> 
> 


Re: [PATCH 3/3] hw/ppc: Add stub for pnv_chip_find_core()
Posted by Aditya Gupta 2 months, 3 weeks ago
On 10/08/25 13:30, Michael Tokarev wrote:
> On 13.07.2025 14:18, Michael Tokarev wrote:
>> Hi!
>>
>> Has this change been forgotten?
>
> Another ping?
>
> Or can we assume this change isn't needed anymore? :)


Thanks for the pings Michael.

About the change, we will post a patch-set soon with the suggested 
change by Cedric.

I was on vacation past week, so couldn't see the mails.


Thanks,

- Aditya G