diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2011-12-12 18:24:35 +0000 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2012-01-03 15:49:12 +0100 |
commit | 9fc380d3ed1cfac7d87dbe2a140e465cac58ed7b (patch) | |
tree | db4788b15b48796ad62334c3e95e3c9f0c0e2772 /hw | |
parent | 68f3a94c64bbaaf8c7f2daa70de1b5d87a432f86 (diff) | |
download | qemu-9fc380d3ed1cfac7d87dbe2a140e465cac58ed7b.zip qemu-9fc380d3ed1cfac7d87dbe2a140e465cac58ed7b.tar.gz qemu-9fc380d3ed1cfac7d87dbe2a140e465cac58ed7b.tar.bz2 |
pseries: Check for duplicate addresses on the spapr-vio bus
Check that devices on the spapr vio bus aren't given duplicate
addresses. Currently we will not run with duplicate devices, the
fdt code will spot it, but the error reporting is not great. With
this patch we can report the error nicely in terms of the device
names given by the user.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/spapr_vio.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c index cd03416..7a86dc8 100644 --- a/hw/spapr_vio.c +++ b/hw/spapr_vio.c @@ -621,11 +621,43 @@ static void rtas_quiesce(sPAPREnvironment *spapr, uint32_t token, rtas_st(rets, 0, 0); } +static int spapr_vio_check_reg(VIOsPAPRDevice *sdev, VIOsPAPRDeviceInfo *info) +{ + VIOsPAPRDevice *other_sdev; + DeviceState *qdev; + VIOsPAPRBus *sbus; + + sbus = DO_UPCAST(VIOsPAPRBus, bus, sdev->qdev.parent_bus); + + /* + * Check two device aren't given clashing addresses by the user (or some + * other mechanism). We have to open code this because we have to check + * for matches with devices other than us. + */ + QTAILQ_FOREACH(qdev, &sbus->bus.children, sibling) { + other_sdev = DO_UPCAST(VIOsPAPRDevice, qdev, qdev); + + if (other_sdev != sdev && other_sdev->reg == sdev->reg) { + fprintf(stderr, "vio: %s and %s devices conflict at address %#x\n", + info->qdev.name, other_sdev->qdev.info->name, sdev->reg); + return -EEXIST; + } + } + + return 0; +} + static int spapr_vio_busdev_init(DeviceState *qdev, DeviceInfo *qinfo) { VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qinfo; VIOsPAPRDevice *dev = (VIOsPAPRDevice *)qdev; char *id; + int ret; + + ret = spapr_vio_check_reg(dev, info); + if (ret) { + return ret; + } /* Don't overwrite ids assigned on the command line */ if (!dev->qdev.id) { |