From nobody Sun Nov 2 03:11:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1527487998983290.4280040621014; Sun, 27 May 2018 23:13:18 -0700 (PDT) Received: from localhost ([::1]:54344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNBP1-0008MM-I5 for importer@patchew.org; Mon, 28 May 2018 02:13:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNBO1-00082b-UA for qemu-devel@nongnu.org; Mon, 28 May 2018 02:12:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNBNw-0007TF-V2 for qemu-devel@nongnu.org; Mon, 28 May 2018 02:12:05 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:39213) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fNBNw-0007T0-Qb for qemu-devel@nongnu.org; Mon, 28 May 2018 02:12:00 -0400 Received: by mail-qt0-x242.google.com with SMTP id f1-v6so13711949qtj.6 for ; Sun, 27 May 2018 23:12:00 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id c24-v6sm20751655qtp.22.2018.05.27.23.11.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 May 2018 23:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=E98N+DUNjy/ib5vYQ8ZpK41H+Xh/LGpANYcyfp6ThNI=; b=fpa8R8XRh0pF7Pq/lcdvRYNe9KamDp+ZI25VwooToRl+owLLgA8I+Fv7ZIg46Uz8uN yTattp8JB+KKriqdpZj1zMTSkpt/9eo8khIE+bAcLFAI42vYj4gw6FiQLPcPlihL/8vG KVsg0Ho1Sc2yqZlIcIwZ2BZwFUUOwVnHRnAyjoh1Y2vRtf0rjc5s9jSlmnRmd1y81u/1 2j4lGbdjbeK40sk2AY6SYywhYZm8nBrE6J1I+1ZN5Y6eu/juRexUDFlAiJHP+AL3+BgC SFKSKT/4+Iu8G9e4f6zlGdTIUo2b35rbjn4kz9tE9To4UpYkylvJEjk/4M8iD9AIwysh /uEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=E98N+DUNjy/ib5vYQ8ZpK41H+Xh/LGpANYcyfp6ThNI=; b=YNZvDia1Rcy9+qW/McV90NzjVjohBMrNZ03RuCfixEZVUssu65q6MiQn7FnRXisUQB yOjWtPQatuqIyrAQvimufqEhfdNRjlGIHYUYhTazPUUaUIIchpyQdaEAGAApIohl1GgI K67FuRh5I7lrDdVHio1f46FFwWxOerEQ/hZe2VWVCFE8/+D4smhPhscTj2UbKwBxSY5m gH5ObN9VGNrFSu0FIWIHGDy6/QvAg7EHOUhvP99atJH2aaWy9AT/cA3ckrISYckUW7IT NiHUdsal8ktndKG4R2oZB/gbuIoyEQYQcl0mWDPDX0hZ+iLrbtexLOYET4MeRzgQHfur lGpQ== X-Gm-Message-State: ALKqPwcms6e3MHOP/EFJGIOXiK8nG9WuQbxKJrxAA93gjUg/gz/HoT5r jKmR9LJg54rXgjxjIRcMciU= X-Google-Smtp-Source: ADUXVKKHnuXI8suvyfXdRE0kpIKyTycWLa5N8zigCrKTVsyScM28b7DSAm1ydH6J/KYPZlQtHWDtOQ== X-Received: by 2002:ac8:5192:: with SMTP id c18-v6mr10850823qtn.80.1527487920382; Sun, 27 May 2018 23:12:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Peter Maydell , Richard Henderson Date: Mon, 28 May 2018 03:11:54 -0300 Message-Id: <20180528061154.25367-1-f4bug@amsat.org> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [RFC PATCH] hw/misc/unimp: Add create_unimplemented_subregion_device() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Korolev , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 The create_unimplemented_device() function is very useful to register unimplemented devices to the SysBus 'absolute' address. Some devices are modelled as container of memory subregions, the subregions being mmio-mapped relatively to the container base address. With these container devices, the current create_unimplemented_device() does not work. Add a function to remove the current limitation, and allow containerized devices to use the helpful UnimplementedDevice. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- I don't like the function name much, I first tried with create_unimplemented_device_mr() :( Would it be cleaner renaming current create_unimplemented_device() -> create_unimplemented_sysbus_device()? Also, is this useful to have this code inlined? --- include/hw/misc/unimp.h | 42 +++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h index 2a291ca42d..7ae1ace885 100644 --- a/include/hw/misc/unimp.h +++ b/include/hw/misc/unimp.h @@ -23,9 +23,12 @@ typedef struct { } UnimplementedDeviceState; =20 /** - * create_unimplemented_device: create and map a dummy device + * create_unimplemented_subregion_device: create and map a dummy device + * + * @mr: the #MemoryRegion to contain the new device. * @name: name of the device for debug logging - * @base: base address of the device's MMIO region + * @addr: base address of the device's MMIO region, or + * offset relative to @mr where the device is added. * @size: size of the device's MMIO region * * This utility function creates and maps an instance of unimplemented-dev= ice, @@ -35,9 +38,10 @@ typedef struct { * use it to cover a large region and then map other devices on top of it * if necessary. */ -static inline void create_unimplemented_device(const char *name, - hwaddr base, - hwaddr size) +static inline void create_unimplemented_subregion_device(MemoryRegion *mr, + const char *name, + hwaddr addr, + hwaddr size) { DeviceState *dev =3D qdev_create(NULL, TYPE_UNIMPLEMENTED_DEVICE); =20 @@ -45,7 +49,33 @@ static inline void create_unimplemented_device(const cha= r *name, qdev_prop_set_uint64(dev, "size", size); qdev_init_nofail(dev); =20 - sysbus_mmio_map_overlap(SYS_BUS_DEVICE(dev), 0, base, -1000); + if (mr) { + MemoryRegion *submr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(dev)= , 0); + memory_region_add_subregion_overlap(mr, addr, submr, -1000); + } else { + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(dev), 0, addr, -1000); + } +} + +/** + * create_unimplemented_device: create and map a dummy SysBus device + * + * @name: name of the device for debug logging + * @base: base address of the device's MMIO region + * @size: size of the device's MMIO region + * + * This utility function creates and maps an instance of unimplemented-dev= ice, + * which is a dummy device which simply logs all guest accesses to + * it via the qemu_log LOG_UNIMP debug log. + * The device is mapped at priority -1000, which means that you can + * use it to cover a large region and then map other devices on top of it + * if necessary. + */ +static inline void create_unimplemented_device(const char *name, + hwaddr base, + hwaddr size) +{ + create_unimplemented_subregion_device(NULL, name, base, size); } =20 #endif --=20 2.17.0