Commit e07c67584c for qemu.org
commit e07c67584c69da44a4d52df747a6fff1f411500d
Author: Peter Maydell <peter.maydell@linaro.org>
Date: Wed Jul 8 13:10:11 2026 +0100
hw/pci-host/q35.c: Avoid early return in mch_write_config()
In mch_write_config() we return early if has_smm_ranges is false.
This is slightly bug-prone because it leaves the door open to somebody
later adding non-SMM-specific code at the bottom of the function.
This case isn't as bad as the one in realize, because the function is
a lot shorter. But putting the handling of the three SMM specific
ranges into an if() rather than having an early return seems better.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260708121011.1653365-4-peter.maydell@linaro.org>
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index e42b84b978..f4556ad03a 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -485,22 +485,20 @@ static void mch_write_config(PCIDevice *d,
mch_update_pciexbar(mch);
}
- if (!mch->has_smm_ranges) {
- return;
- }
-
- if (ranges_overlap(address, len, MCH_HOST_BRIDGE_SMRAM,
- MCH_HOST_BRIDGE_SMRAM_SIZE)) {
- mch_update_smram(mch);
- }
+ if (mch->has_smm_ranges) {
+ if (ranges_overlap(address, len, MCH_HOST_BRIDGE_SMRAM,
+ MCH_HOST_BRIDGE_SMRAM_SIZE)) {
+ mch_update_smram(mch);
+ }
- if (ranges_overlap(address, len, MCH_HOST_BRIDGE_EXT_TSEG_MBYTES,
- MCH_HOST_BRIDGE_EXT_TSEG_MBYTES_SIZE)) {
- mch_update_ext_tseg_mbytes(mch);
- }
+ if (ranges_overlap(address, len, MCH_HOST_BRIDGE_EXT_TSEG_MBYTES,
+ MCH_HOST_BRIDGE_EXT_TSEG_MBYTES_SIZE)) {
+ mch_update_ext_tseg_mbytes(mch);
+ }
- if (ranges_overlap(address, len, MCH_HOST_BRIDGE_F_SMBASE, 1)) {
- mch_update_smbase_smram(mch);
+ if (ranges_overlap(address, len, MCH_HOST_BRIDGE_F_SMBASE, 1)) {
+ mch_update_smbase_smram(mch);
+ }
}
}