From: Markus Armbruster <armbru@redhat.com>
To: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com,
philmd@mailo.com, aurelien@aurel32.net, peter.maydell@linaro.org,
richard.henderson@linaro.org, marcandre.lureau@redhat.com,
qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: Re: [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
Date: Tue, 25 Aug 2026 09:17:52 +0200 [thread overview]
Message-ID: <87fr02pt27.fsf@pond.sub.org> (raw)
In-Reply-To: <1fd9946e-1d2a-462a-93e3-238f2c67a1b6@nutanix.com> (Mark Cave-Ayland's message of "Mon, 24 Aug 2026 14:47:13 +0100")
Mark Cave-Ayland <mark.caveayland@nutanix.com> writes:
> On 24/08/2026 14:04, Daniel P. Berrangé wrote:
>
>> On Fri, Aug 21, 2026 at 12:14:26PM +0100, Mark Cave-Ayland wrote:
>>> Move the ACPI_PCIHP_PROP_BSEL property to the PCIBus object and update all
>>> callers accordingly.
>>>
>>> Since the existing logic checks for the existence of the ACPI_PCIHP_PROP_BSEL
>>> property to enable the relevant ACPI changes, set the type of the underlying
>>> variable to uint32_t with a default value of UINT32_MAX indicating that the
>>> property has not been set.
>>>
>>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>> ---
>>> include/hw/pci/pci_bus.h | 2 ++
>>> hw/acpi/pci-bridge.c | 9 ++++++++-
>>> hw/acpi/pcihp.c | 30 ++++++++++++++----------------
>>> hw/arm/virt-acpi-build.c | 7 ++++++-
>>> hw/i386/acpi-build.c | 7 ++++++-
>>> hw/pci/pci.c | 7 +++++++
>>> 6 files changed, 43 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
>>> index c738446788..7ecb23d13c 100644
>>> --- a/include/hw/pci/pci_bus.h
>>> +++ b/include/hw/pci/pci_bus.h
>>> @@ -56,6 +56,8 @@ struct PCIBus {
>>> int *irq_count;
>>> Notifier machine_done;
>>> +
>>> + uint32_t acpi_pcihp_bsel_val;
>>> };
>>> static inline bool pci_bus_is_cxl(PCIBus *bus)
>>> diff --git a/hw/acpi/pci-bridge.c b/hw/acpi/pci-bridge.c
>>> index 394a919479..1bfc5431f2 100644
>>> --- a/hw/acpi/pci-bridge.c
>>> +++ b/hw/acpi/pci-bridge.c
>>> @@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>> @@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>>
>>> if (!DEVICE(br)->hotplugged) {
>>> PCIBus *sec_bus = pci_bridge_get_sec_bus(br);
>>> + Error *local_err = NULL;
>>> + uint32_t bsel;
>>>
>>> build_append_pci_bus_devices(scope, sec_bus);
>>>
>>> @@ -30,9 +32,14 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>> * generate hotplug slots descriptors if
>>> * bridge has ACPI PCI hotplug attached,
>>> */
>>> - if (object_property_find(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL)) {
>>> + bsel = object_property_get_uint(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
>>> + &local_err);
>>> +
>>> + if (local_err == NULL && bsel != UINT32_MAX) {
>>> build_append_pcihp_slots(scope, sec_bus);
>>> }
>>> +
>>> + error_free(local_err);
>> IIUC, in this new approach the property should always exist and so I'd
>> expect object_property_get_uint to always succeed.
>> IOW, is something stopping us using &error_abort and merely checking
>> if (bsel != UINT32_MAX)
>> ?
>
> I think that would work, although in the back of my mind I have a memory that we should try avoiding error_abort where at all possible.
>
> Markus, any thoughts/comments on error_abort usage?
&error_abort is an assertion, just like assert().
Assertions are strictly for programming errors. When the program
detects such an error, it is defective and needs fixing.
Commonly, the program is in an invalid state then, and continuing
execution is unsafe. Aborting it is the only sane option.
Assertions conveniently combine the error check and the abort, and also
scream "this is a a programming error" both to readers of the code and
unfortunate users tripping them. Good!
I particularly dislike the pattern
if (programming error detected) {
error recovery that should never be reached
}
where the code doesn't actually *tell* me it's a programming error.
This matters! The error recovery needs to be treated with extreme
suspicion then, because it's not testable and almost certainly unsafe.
The pattern can also make me go "huh, I wonder how this error can
happen, let me figure that out", wasting my time.
Another gripe of mine: we often pass NULL where we should pass
&error_abort.
Questions?
[...]
next prev parent reply other threads:[~2026-08-25 7:18 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
2026-08-21 11:14 ` [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro Mark Cave-Ayland
2026-08-24 12:43 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro Mark Cave-Ayland
2026-08-24 12:44 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro Mark Cave-Ayland
2026-08-24 12:44 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 04/16] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
2026-08-24 12:45 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
2026-08-24 12:46 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
2026-08-24 12:47 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
2026-08-24 12:48 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 08/16] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
2026-08-24 12:48 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property Mark Cave-Ayland
2026-08-24 12:50 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr() Mark Cave-Ayland
2026-08-24 12:53 ` Daniel P. Berrangé
2026-08-24 13:39 ` Mark Cave-Ayland
2026-08-24 13:57 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
2026-08-24 12:59 ` Daniel P. Berrangé
2026-08-24 13:41 ` Mark Cave-Ayland
2026-08-21 11:14 ` [PATCH v4 12/16] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
2026-08-24 13:00 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props Mark Cave-Ayland
2026-08-24 13:01 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
2026-08-24 13:04 ` Daniel P. Berrangé
2026-08-24 13:47 ` Mark Cave-Ayland
2026-08-25 7:17 ` Markus Armbruster [this message]
2026-08-25 12:53 ` Mark Cave-Ayland
2026-08-25 13:29 ` Markus Armbruster
2026-08-21 11:14 ` [PATCH v4 15/16] hw/acpi/piix4.c: convert static variables to static class properties Mark Cave-Ayland
2026-08-24 13:05 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop Mark Cave-Ayland
2026-08-24 13:06 ` Daniel P. Berrangé
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=87fr02pt27.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=anisinha@redhat.com \
--cc=aurelien@aurel32.net \
--cc=berrange@redhat.com \
--cc=imammedo@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.caveayland@nutanix.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@mailo.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.