* [PULL 00/28] Misc HW+ patches for 2024-07-23
@ 2024-07-23 20:38 Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 01/28] accel: Restrict probe_access*() functions to TCG Philippe Mathieu-Daudé
` (28 more replies)
0 siblings, 29 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe =?unknown-8bit?q?Mathieu-Daud=C3=A9?=
The following changes since commit 3cce8bd4d737f2ca688bbdcb92cd5cc683245bbd:
Merge tag 'ui-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging (2024-07-23 15:23:05 +1000)
are available in the Git repository at:
https://github.com/philmd/qemu.git tags/hw-misc-20240723
for you to fetch changes up to e4a44f94db11fcf873399c60ebb1d93a9ad1cd6e:
MAINTAINERS: Add myself as a reviewer of machine core (2024-07-23 22:34:54 +0200)
Ignored unrelated error:
TEST signals on ppc64
signals: allocatestack.c:223: allocate_stack: Assertion `powerof2 (pagesize_m1 + 1)' failed.
qemu: uncaught target signal 6 (Aborted) - core dumped
timeout: the monitored command dumped core
Aborted
make[1]: *** [Makefile:175: run-signals] Error 134
make: *** [/builds/philmd/qemu/tests/Makefile.include:56: run-tcg-tests-ppc64-linux-user] Error 2
----------------------------------------------------------------
Misc HW patch queue
- Restrict probe_access*() functions to TCG (Phil)
- Extract do_invalidate_device_tlb from vtd_process_device_iotlb_desc (Clément)
- Fixes in Loongson IPI model (Bibo & Phil)
- Make docs/interop/firmware.json compatible with qapi-gen.py script (Thomas)
- Correct MPC I2C MMIO region size (Zoltan)
- Remove useless cast in Loongson3 Virt machine (Yao)
- Various uses of range overlap API (Yao)
- Use ERRP_GUARD macro in nubus_virtio_mmio_realize (Zhao)
- Use DMA memory API in Goldfish UART model (Phil)
- Expose fifo8_pop_buf and introduce fifo8_drop (Phil)
- MAINTAINERS updates (Zhao, Phil)
----------------------------------------------------------------
BALATON Zoltan (1):
hw/i2c/mpc_i2c: Fix mmio region size
Bibo Mao (1):
hw/intc/loongson_ipi: Access memory in little endian
Clément Mathieu--Drif (1):
hw/i386/intel_iommu: Extract device IOTLB invalidation logic
Philippe Mathieu-Daudé (13):
accel: Restrict probe_access*() functions to TCG
hw/intc/loongson_ipi: Fix resource leak
hw/intc/loongson_ipi: Declare QOM types using DEFINE_TYPES() macro
docs: Correct Loongarch -> LoongArch
hw/char/goldfish: Use DMA memory API
chardev/char-fe: Document returned value on error
util/fifo8: Fix style
util/fifo8: Use fifo8_reset() in fifo8_create()
util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_bufptr()
util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr()
util/fifo8: Expose fifo8_pop_buf()
util/fifo8: Introduce fifo8_drop()
MAINTAINERS: Cover guest-agent in QAPI schema
Thomas Weißschuh (3):
docs/interop/firmware.json: add new enum FirmwareFormat
docs/interop/firmware.json: add new enum FirmwareArchitecture
docs/interop/firmware.json: convert "Example" section
Yao Xingtao (7):
hw/mips/loongson3_virt: remove useless type cast
util/range: Make ranges_overlap() return bool
cxl/mailbox: make range overlap check more readable
sparc/ldst_helper: make range overlap check more readable
system/memory_mapping: make range overlap check more readable
crypto/block-luks: make range overlap check more readable
dump: make range overlap check more readable
Zhao Liu (2):
hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler
MAINTAINERS: Add myself as a reviewer of machine core
MAINTAINERS | 2 ++
docs/about/emulation.rst | 2 +-
docs/interop/firmware.json | 47 +++++++++++++++++++++++++----
include/chardev/char-fe.h | 3 ++
include/exec/exec-all.h | 7 ++++-
include/qemu/fifo8.h | 57 +++++++++++++++++++++++-------------
include/qemu/range.h | 4 +--
accel/stubs/tcg-stub.c | 14 ---------
chardev/msmouse.c | 2 +-
crypto/block-luks.c | 3 +-
dump/dump.c | 12 +++++---
hw/char/goldfish_tty.c | 12 ++++----
hw/cxl/cxl-mailbox-utils.c | 8 ++---
hw/i2c/mpc_i2c.c | 8 ++---
hw/i386/intel_iommu.c | 57 +++++++++++++++++++++---------------
hw/intc/loongson_ipi.c | 40 ++++++++++++-------------
hw/mips/loongson3_virt.c | 4 +--
hw/net/allwinner_emac.c | 2 +-
hw/nubus/nubus-virtio-mmio.c | 2 ++
hw/rtc/ls7a_rtc.c | 2 +-
hw/scsi/esp.c | 38 +++---------------------
system/memory_mapping.c | 4 +--
target/sparc/ldst_helper.c | 5 ++--
ui/console-vc.c | 2 +-
ui/gtk.c | 2 +-
util/fifo8.c | 48 +++++++++++++++++++++++++-----
26 files changed, 226 insertions(+), 161 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PULL 01/28] accel: Restrict probe_access*() functions to TCG
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 02/28] hw/i386/intel_iommu: Extract device IOTLB invalidation logic Philippe Mathieu-Daudé
` (27 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson
This API is specific to TCG (already handled by hardware
accelerators), so restrict it with #ifdef'ry. Remove
unnecessary stubs.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240529155918.6221-1-philmd@linaro.org>
---
include/exec/exec-all.h | 7 ++++++-
accel/stubs/tcg-stub.c | 14 --------------
2 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index b6b46ad13c7..72240ef4263 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -301,6 +301,9 @@ static inline void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu,
{
}
#endif
+
+#if defined(CONFIG_TCG)
+
/**
* probe_access:
* @env: CPUArchState
@@ -357,6 +360,7 @@ int probe_access_flags(CPUArchState *env, vaddr addr, int size,
bool nonfault, void **phost, uintptr_t retaddr);
#ifndef CONFIG_USER_ONLY
+
/**
* probe_access_full:
* Like probe_access_flags, except also return into @pfull.
@@ -392,7 +396,8 @@ int probe_access_full_mmu(CPUArchState *env, vaddr addr, int size,
MMUAccessType access_type, int mmu_idx,
void **phost, CPUTLBEntryFull **pfull);
-#endif
+#endif /* !CONFIG_USER_ONLY */
+#endif /* CONFIG_TCG */
static inline tb_page_addr_t tb_page_addr0(const TranslationBlock *tb)
{
diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c
index dd890d6cf69..7f4208fddf2 100644
--- a/accel/stubs/tcg-stub.c
+++ b/accel/stubs/tcg-stub.c
@@ -18,20 +18,6 @@ void tb_flush(CPUState *cpu)
{
}
-int probe_access_flags(CPUArchState *env, vaddr addr, int size,
- MMUAccessType access_type, int mmu_idx,
- bool nonfault, void **phost, uintptr_t retaddr)
-{
- g_assert_not_reached();
-}
-
-void *probe_access(CPUArchState *env, vaddr addr, int size,
- MMUAccessType access_type, int mmu_idx, uintptr_t retaddr)
-{
- /* Handled by hardware accelerator. */
- g_assert_not_reached();
-}
-
G_NORETURN void cpu_loop_exit(CPUState *cpu)
{
g_assert_not_reached();
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 02/28] hw/i386/intel_iommu: Extract device IOTLB invalidation logic
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 01/28] accel: Restrict probe_access*() functions to TCG Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 03/28] hw/intc/loongson_ipi: Access memory in little endian Philippe Mathieu-Daudé
` (26 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Clément Mathieu--Drif, Philippe Mathieu-Daudé,
Zhenzhong Duan
From: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
This piece of code can be shared by both IOTLB invalidation and
PASID-based IOTLB invalidation
No functional changes intended.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Message-ID: <20240718081636.879544-12-zhenzhong.duan@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/i386/intel_iommu.c | 57 +++++++++++++++++++++++++------------------
1 file changed, 33 insertions(+), 24 deletions(-)
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 37c21a0aec6..536994c3107 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2666,13 +2666,43 @@ static bool vtd_process_inv_iec_desc(IntelIOMMUState *s,
return true;
}
+static void do_invalidate_device_tlb(VTDAddressSpace *vtd_dev_as,
+ bool size, hwaddr addr)
+{
+ /*
+ * According to ATS spec table 2.4:
+ * S = 0, bits 15:12 = xxxx range size: 4K
+ * S = 1, bits 15:12 = xxx0 range size: 8K
+ * S = 1, bits 15:12 = xx01 range size: 16K
+ * S = 1, bits 15:12 = x011 range size: 32K
+ * S = 1, bits 15:12 = 0111 range size: 64K
+ * ...
+ */
+
+ IOMMUTLBEvent event;
+ uint64_t sz;
+
+ if (size) {
+ sz = (VTD_PAGE_SIZE * 2) << cto64(addr >> VTD_PAGE_SHIFT);
+ addr &= ~(sz - 1);
+ } else {
+ sz = VTD_PAGE_SIZE;
+ }
+
+ event.type = IOMMU_NOTIFIER_DEVIOTLB_UNMAP;
+ event.entry.target_as = &vtd_dev_as->as;
+ event.entry.addr_mask = sz - 1;
+ event.entry.iova = addr;
+ event.entry.perm = IOMMU_NONE;
+ event.entry.translated_addr = 0;
+ memory_region_notify_iommu(&vtd_dev_as->iommu, 0, event);
+}
+
static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s,
VTDInvDesc *inv_desc)
{
VTDAddressSpace *vtd_dev_as;
- IOMMUTLBEvent event;
hwaddr addr;
- uint64_t sz;
uint16_t sid;
bool size;
@@ -2697,28 +2727,7 @@ static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s,
goto done;
}
- /* According to ATS spec table 2.4:
- * S = 0, bits 15:12 = xxxx range size: 4K
- * S = 1, bits 15:12 = xxx0 range size: 8K
- * S = 1, bits 15:12 = xx01 range size: 16K
- * S = 1, bits 15:12 = x011 range size: 32K
- * S = 1, bits 15:12 = 0111 range size: 64K
- * ...
- */
- if (size) {
- sz = (VTD_PAGE_SIZE * 2) << cto64(addr >> VTD_PAGE_SHIFT);
- addr &= ~(sz - 1);
- } else {
- sz = VTD_PAGE_SIZE;
- }
-
- event.type = IOMMU_NOTIFIER_DEVIOTLB_UNMAP;
- event.entry.target_as = &vtd_dev_as->as;
- event.entry.addr_mask = sz - 1;
- event.entry.iova = addr;
- event.entry.perm = IOMMU_NONE;
- event.entry.translated_addr = 0;
- memory_region_notify_iommu(&vtd_dev_as->iommu, 0, event);
+ do_invalidate_device_tlb(vtd_dev_as, size, addr);
done:
return true;
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 03/28] hw/intc/loongson_ipi: Access memory in little endian
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 01/28] accel: Restrict probe_access*() functions to TCG Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 02/28] hw/i386/intel_iommu: Extract device IOTLB invalidation logic Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 04/28] hw/intc/loongson_ipi: Fix resource leak Philippe Mathieu-Daudé
` (25 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Bibo Mao, qemu-stable, Philippe Mathieu-Daudé, Song Gao,
Richard Henderson, Jiaxun Yang
From: Bibo Mao <maobibo@loongson.cn>
Loongson IPI is only available in little-endian,
so use that to access the guest memory (in case
we run on a big-endian host).
Cc: qemu-stable@nongnu.org
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Fixes: f6783e3438 ("hw/loongarch: Add LoongArch ipi interrupt support")
[PMD: Extracted from bigger commit, added commit description]
Co-Developed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Tested-by: Bibo Mao <maobibo@loongson.cn>
Acked-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Message-Id: <20240718133312.10324-3-philmd@linaro.org>
---
hw/intc/loongson_ipi.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c
index e6a7142480c..e7979dbdd8b 100644
--- a/hw/intc/loongson_ipi.c
+++ b/hw/intc/loongson_ipi.c
@@ -14,6 +14,7 @@
#include "qapi/error.h"
#include "qemu/log.h"
#include "exec/address-spaces.h"
+#include "exec/memory.h"
#include "migration/vmstate.h"
#ifdef TARGET_LOONGARCH64
#include "target/loongarch/cpu.h"
@@ -102,7 +103,7 @@ static MemTxResult send_ipi_data(CPUState *cpu, uint64_t val, hwaddr addr,
* if the mask is 0, we need not to do anything.
*/
if ((val >> 27) & 0xf) {
- data = address_space_ldl(iocsr_as, addr, attrs, NULL);
+ data = address_space_ldl_le(iocsr_as, addr, attrs, NULL);
for (i = 0; i < 4; i++) {
/* get mask for byte writing */
if (val & (0x1 << (27 + i))) {
@@ -113,7 +114,7 @@ static MemTxResult send_ipi_data(CPUState *cpu, uint64_t val, hwaddr addr,
data &= mask;
data |= (val >> 32) & ~mask;
- address_space_stl(iocsr_as, addr, data, attrs, NULL);
+ address_space_stl_le(iocsr_as, addr, data, attrs, NULL);
return MEMTX_OK;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 04/28] hw/intc/loongson_ipi: Fix resource leak
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2024-07-23 20:38 ` [PULL 03/28] hw/intc/loongson_ipi: Access memory in little endian Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 05/28] hw/intc/loongson_ipi: Declare QOM types using DEFINE_TYPES() macro Philippe Mathieu-Daudé
` (24 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, qemu-stable, Song Gao
Once initialised, QOM objects can be realized and
unrealized multiple times before being finalized.
Resources allocated in REALIZE must be deallocated
in an equivalent UNREALIZE handler.
Free the CPU array in loongson_ipi_unrealize()
instead of loongson_ipi_finalize().
Cc: qemu-stable@nongnu.org
Fixes: 5e90b8db382 ("hw/loongarch: Set iocsr address space per-board rather than percpu")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20240723111405.14208-3-philmd@linaro.org>
---
hw/intc/loongson_ipi.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c
index e7979dbdd8b..4013f81745e 100644
--- a/hw/intc/loongson_ipi.c
+++ b/hw/intc/loongson_ipi.c
@@ -318,6 +318,13 @@ static void loongson_ipi_realize(DeviceState *dev, Error **errp)
}
}
+static void loongson_ipi_unrealize(DeviceState *dev)
+{
+ LoongsonIPI *s = LOONGSON_IPI(dev);
+
+ g_free(s->cpu);
+}
+
static const VMStateDescription vmstate_ipi_core = {
.name = "ipi-single",
.version_id = 2,
@@ -353,23 +360,16 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = loongson_ipi_realize;
+ dc->unrealize = loongson_ipi_unrealize;
device_class_set_props(dc, ipi_properties);
dc->vmsd = &vmstate_loongson_ipi;
}
-static void loongson_ipi_finalize(Object *obj)
-{
- LoongsonIPI *s = LOONGSON_IPI(obj);
-
- g_free(s->cpu);
-}
-
static const TypeInfo loongson_ipi_info = {
.name = TYPE_LOONGSON_IPI,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(LoongsonIPI),
.class_init = loongson_ipi_class_init,
- .instance_finalize = loongson_ipi_finalize,
};
static void loongson_ipi_register_types(void)
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 05/28] hw/intc/loongson_ipi: Declare QOM types using DEFINE_TYPES() macro
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2024-07-23 20:38 ` [PULL 04/28] hw/intc/loongson_ipi: Fix resource leak Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 06/28] docs: Correct Loongarch -> LoongArch Philippe Mathieu-Daudé
` (23 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Song Gao, Richard Henderson,
Jiaxun Yang
When multiple QOM types are registered in the same file,
it is simpler to use the the DEFINE_TYPES() macro. Replace
the type_init() / type_register_static() combination.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Message-Id: <20240718133312.10324-2-philmd@linaro.org>
---
hw/intc/loongson_ipi.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c
index 4013f81745e..682cec96f3f 100644
--- a/hw/intc/loongson_ipi.c
+++ b/hw/intc/loongson_ipi.c
@@ -365,16 +365,13 @@ static void loongson_ipi_class_init(ObjectClass *klass, void *data)
dc->vmsd = &vmstate_loongson_ipi;
}
-static const TypeInfo loongson_ipi_info = {
- .name = TYPE_LOONGSON_IPI,
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(LoongsonIPI),
- .class_init = loongson_ipi_class_init,
+static const TypeInfo loongson_ipi_types[] = {
+ {
+ .name = TYPE_LOONGSON_IPI,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(LoongsonIPI),
+ .class_init = loongson_ipi_class_init,
+ }
};
-static void loongson_ipi_register_types(void)
-{
- type_register_static(&loongson_ipi_info);
-}
-
-type_init(loongson_ipi_register_types)
+DEFINE_TYPES(loongson_ipi_types)
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 06/28] docs: Correct Loongarch -> LoongArch
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2024-07-23 20:38 ` [PULL 05/28] hw/intc/loongson_ipi: Declare QOM types using DEFINE_TYPES() macro Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 07/28] docs/interop/firmware.json: add new enum FirmwareFormat Philippe Mathieu-Daudé
` (22 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Richard Henderson, Jiaxun Yang
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Message-Id: <20240718133312.10324-20-philmd@linaro.org>
---
docs/about/emulation.rst | 2 +-
hw/rtc/ls7a_rtc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst
index b5ff9c5f696..3bfe8cc14a2 100644
--- a/docs/about/emulation.rst
+++ b/docs/about/emulation.rst
@@ -42,7 +42,7 @@ depending on the guest architecture.
- :ref:`Yes<QEMU-PC-System-emulator>`
- Yes
- The ubiquitous desktop PC CPU architecture, 32 and 64 bit.
- * - Loongarch
+ * - LoongArch
- Yes
- Yes
- A MIPS-like 64bit RISC architecture developed in China
diff --git a/hw/rtc/ls7a_rtc.c b/hw/rtc/ls7a_rtc.c
index 052201c2cd5..3226b6105e8 100644
--- a/hw/rtc/ls7a_rtc.c
+++ b/hw/rtc/ls7a_rtc.c
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
- * Loongarch LS7A Real Time Clock emulation
+ * LoongArch LS7A Real Time Clock emulation
*
* Copyright (C) 2021 Loongson Technology Corporation Limited
*/
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 07/28] docs/interop/firmware.json: add new enum FirmwareFormat
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2024-07-23 20:38 ` [PULL 06/28] docs: Correct Loongarch -> LoongArch Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 08/28] docs/interop/firmware.json: add new enum FirmwareArchitecture Philippe Mathieu-Daudé
` (21 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Weißschuh, Daniel P . Berrangé,
Markus Armbruster, Philippe Mathieu-Daudé
From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Only a small subset of all blockdev drivers make sense for firmware
images. Introduce and use a new enum to represent this.
This also reduces the dependency on firmware.json from the global qapi
definitions.
Claim "Since: 3.0" for the new enum, because that's correct for its
members, and the members are what matters in the interface.
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240719-qapi-firmware-json-v6-1-c2e3de390b58@linutronix.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
docs/interop/firmware.json | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json
index 54a1fc6c104..d5d4c17f230 100644
--- a/docs/interop/firmware.json
+++ b/docs/interop/firmware.json
@@ -15,7 +15,6 @@
##
{ 'include' : 'machine.json' }
-{ 'include' : 'block-core.json' }
##
# @FirmwareOSInterface:
@@ -200,6 +199,20 @@
'enrolled-keys', 'requires-smm', 'secure-boot',
'verbose-dynamic', 'verbose-static' ] }
+##
+# @FirmwareFormat:
+#
+# Formats that are supported for firmware images.
+#
+# @raw: Raw disk image format.
+#
+# @qcow2: The QCOW2 image format.
+#
+# Since: 3.0
+##
+{ 'enum': 'FirmwareFormat',
+ 'data': [ 'raw', 'qcow2' ] }
+
##
# @FirmwareFlashFile:
#
@@ -219,7 +232,7 @@
##
{ 'struct' : 'FirmwareFlashFile',
'data' : { 'filename' : 'str',
- 'format' : 'BlockdevDriver' } }
+ 'format' : 'FirmwareFormat' } }
##
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 08/28] docs/interop/firmware.json: add new enum FirmwareArchitecture
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2024-07-23 20:38 ` [PULL 07/28] docs/interop/firmware.json: add new enum FirmwareFormat Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 09/28] docs/interop/firmware.json: convert "Example" section Philippe Mathieu-Daudé
` (20 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Weißschuh, Daniel P . Berrangé,
Markus Armbruster, Philippe Mathieu-Daudé
From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Only a small subset of all architectures supported by qemu make use of
firmware files. Introduce and use a new enum to represent this.
This also removes the dependency to machine.json from the global qapi
definitions.
Claim "Since: 3.0" for the new enum, because that's correct for most of
its members, and the members are what matters in the interface.
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240719-qapi-firmware-json-v6-2-c2e3de390b58@linutronix.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
docs/interop/firmware.json | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json
index d5d4c17f230..ae417999447 100644
--- a/docs/interop/firmware.json
+++ b/docs/interop/firmware.json
@@ -14,7 +14,10 @@
# = Firmware
##
-{ 'include' : 'machine.json' }
+{ 'pragma': {
+ 'member-name-exceptions': [
+ 'FirmwareArchitecture' # x86_64
+ ] } }
##
# @FirmwareOSInterface:
@@ -59,6 +62,27 @@
{ 'enum' : 'FirmwareDevice',
'data' : [ 'flash', 'kernel', 'memory' ] }
+##
+# @FirmwareArchitecture:
+#
+# Enumeration of architectures for which Qemu uses additional
+# firmware files.
+#
+# @aarch64: 64-bit Arm.
+#
+# @arm: 32-bit Arm.
+#
+# @i386: 32-bit x86.
+#
+# @loongarch64: 64-bit LoongArch. (since: 7.1)
+#
+# @x86_64: 64-bit x86.
+#
+# Since: 3.0
+##
+{ 'enum' : 'FirmwareArchitecture',
+ 'data' : [ 'aarch64', 'arm', 'i386', 'loongarch64', 'x86_64' ] }
+
##
# @FirmwareTarget:
#
@@ -80,7 +104,7 @@
# Since: 3.0
##
{ 'struct' : 'FirmwareTarget',
- 'data' : { 'architecture' : 'SysEmuTarget',
+ 'data' : { 'architecture' : 'FirmwareArchitecture',
'machines' : [ 'str' ] } }
##
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 09/28] docs/interop/firmware.json: convert "Example" section
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2024-07-23 20:38 ` [PULL 08/28] docs/interop/firmware.json: add new enum FirmwareArchitecture Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 10/28] hw/i2c/mpc_i2c: Fix mmio region size Philippe Mathieu-Daudé
` (19 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Thomas Weißschuh, Markus Armbruster,
Philippe Mathieu-Daudé
From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Since commit 3c5f6114d9ff ("qapi: remove "Example" doc section")
the "Example" section is not valid anymore.
It has been replaced by the "qmp-example" directive.
This was not detected earlier as firmware.json was not validated.
As this validation is about to be added, adapt firmware.json.
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Message-ID: <20240719-qapi-firmware-json-v6-3-c2e3de390b58@linutronix.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
docs/interop/firmware.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json
index ae417999447..57f55f6c545 100644
--- a/docs/interop/firmware.json
+++ b/docs/interop/firmware.json
@@ -470,7 +470,7 @@
#
# Since: 3.0
#
-# Examples:
+# .. qmp-example::
#
# {
# "description": "SeaBIOS",
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 10/28] hw/i2c/mpc_i2c: Fix mmio region size
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2024-07-23 20:38 ` [PULL 09/28] docs/interop/firmware.json: convert "Example" section Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 11/28] hw/mips/loongson3_virt: remove useless type cast Philippe Mathieu-Daudé
` (18 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: BALATON Zoltan, Philippe Mathieu-Daudé
From: BALATON Zoltan <balaton@eik.bme.hu>
The last register of this device is at offset 0x14 occupying 8 bits so
to cover it the mmio region needs to be 0x15 bytes long. Also correct
the name of the field storing this register value to match the
register name.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Fixes: 7abb479c7a ("PPC: E500: Add FSL I2C controller")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240721225506.B32704E6039@zero.eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/i2c/mpc_i2c.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/i2c/mpc_i2c.c b/hw/i2c/mpc_i2c.c
index cb051a520f7..06d4ce7d68d 100644
--- a/hw/i2c/mpc_i2c.c
+++ b/hw/i2c/mpc_i2c.c
@@ -82,7 +82,7 @@ struct MPCI2CState {
uint8_t cr;
uint8_t sr;
uint8_t dr;
- uint8_t dfssr;
+ uint8_t dfsrr;
};
static bool mpc_i2c_is_enabled(MPCI2CState *s)
@@ -293,7 +293,7 @@ static void mpc_i2c_write(void *opaque, hwaddr addr,
}
break;
case MPC_I2C_DFSRR:
- s->dfssr = value;
+ s->dfsrr = value;
break;
default:
DPRINTF("ERROR: Bad write addr 0x%x\n", (unsigned int)addr);
@@ -319,7 +319,7 @@ static const VMStateDescription mpc_i2c_vmstate = {
VMSTATE_UINT8(cr, MPCI2CState),
VMSTATE_UINT8(sr, MPCI2CState),
VMSTATE_UINT8(dr, MPCI2CState),
- VMSTATE_UINT8(dfssr, MPCI2CState),
+ VMSTATE_UINT8(dfsrr, MPCI2CState),
VMSTATE_END_OF_LIST()
}
};
@@ -329,7 +329,7 @@ static void mpc_i2c_realize(DeviceState *dev, Error **errp)
MPCI2CState *i2c = MPC_I2C(dev);
sysbus_init_irq(SYS_BUS_DEVICE(dev), &i2c->irq);
memory_region_init_io(&i2c->iomem, OBJECT(i2c), &i2c_ops, i2c,
- "mpc-i2c", 0x14);
+ "mpc-i2c", 0x15);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &i2c->iomem);
i2c->bus = i2c_init_bus(dev, "i2c");
}
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 11/28] hw/mips/loongson3_virt: remove useless type cast
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2024-07-23 20:38 ` [PULL 10/28] hw/i2c/mpc_i2c: Fix mmio region size Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 12/28] util/range: Make ranges_overlap() return bool Philippe Mathieu-Daudé
` (17 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Yao Xingtao, Peter Maydell, Philippe Mathieu-Daudé
From: Yao Xingtao <yaoxt.fnst@fujitsu.com>
The type of kernel_entry, kernel_low and kernel_high is uint64_t, cast
the pointer of this type to uint64_t* is useless.
Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240722091728.4334-2-yaoxt.fnst@fujitsu.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/mips/loongson3_virt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index 4ad36f0c5b6..408e3d7054c 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -355,8 +355,8 @@ static uint64_t load_kernel(CPUMIPSState *env)
kernel_size = load_elf(loaderparams.kernel_filename, NULL,
cpu_mips_kseg0_to_phys, NULL,
- (uint64_t *)&kernel_entry,
- (uint64_t *)&kernel_low, (uint64_t *)&kernel_high,
+ &kernel_entry,
+ &kernel_low, &kernel_high,
NULL, 0, EM_MIPS, 1, 0);
if (kernel_size < 0) {
error_report("could not load kernel '%s': %s",
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 12/28] util/range: Make ranges_overlap() return bool
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2024-07-23 20:38 ` [PULL 11/28] hw/mips/loongson3_virt: remove useless type cast Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 13/28] cxl/mailbox: make range overlap check more readable Philippe Mathieu-Daudé
` (16 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Yao Xingtao, Philippe Mathieu-Daudé
From: Yao Xingtao <yaoxt.fnst@fujitsu.com>
Just like range_overlaps_range(), use the returned bool value
to check whether 2 given ranges overlap.
Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240722040742.11513-2-yaoxt.fnst@fujitsu.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qemu/range.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/qemu/range.h b/include/qemu/range.h
index 4ce694a3983..d446ad885d2 100644
--- a/include/qemu/range.h
+++ b/include/qemu/range.h
@@ -210,8 +210,8 @@ static inline int range_covers_byte(uint64_t offset, uint64_t len,
/* Check whether 2 given ranges overlap.
* Undefined if ranges that wrap around 0. */
-static inline int ranges_overlap(uint64_t first1, uint64_t len1,
- uint64_t first2, uint64_t len2)
+static inline bool ranges_overlap(uint64_t first1, uint64_t len1,
+ uint64_t first2, uint64_t len2)
{
uint64_t last1 = range_get_last(first1, len1);
uint64_t last2 = range_get_last(first2, len2);
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 13/28] cxl/mailbox: make range overlap check more readable
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2024-07-23 20:38 ` [PULL 12/28] util/range: Make ranges_overlap() return bool Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 14/28] sparc/ldst_helper: " Philippe Mathieu-Daudé
` (15 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Yao Xingtao, Philippe Mathieu-Daudé
From: Yao Xingtao <yaoxt.fnst@fujitsu.com>
use ranges_overlap() instead of open-coding the overlap check to improve
the readability of the code.
Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240722040742.11513-5-yaoxt.fnst@fujitsu.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/cxl/cxl-mailbox-utils.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index 74eeb6fde73..507690c0dd1 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -1086,8 +1086,8 @@ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd,
QLIST_FOREACH(ent, poison_list, node) {
/* Check for no overlap */
- if (ent->start >= query_start + query_length ||
- ent->start + ent->length <= query_start) {
+ if (!ranges_overlap(ent->start, ent->length,
+ query_start, query_length)) {
continue;
}
record_count++;
@@ -1100,8 +1100,8 @@ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd,
uint64_t start, stop;
/* Check for no overlap */
- if (ent->start >= query_start + query_length ||
- ent->start + ent->length <= query_start) {
+ if (!ranges_overlap(ent->start, ent->length,
+ query_start, query_length)) {
continue;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 14/28] sparc/ldst_helper: make range overlap check more readable
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2024-07-23 20:38 ` [PULL 13/28] cxl/mailbox: make range overlap check more readable Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 15/28] system/memory_mapping: " Philippe Mathieu-Daudé
` (14 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Yao Xingtao, Philippe Mathieu-Daudé
From: Yao Xingtao <yaoxt.fnst@fujitsu.com>
use ranges_overlap() instead of open-coding the overlap check to improve
the readability of the code.
Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240722040742.11513-9-yaoxt.fnst@fujitsu.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/sparc/ldst_helper.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index 2d48e98bf46..d92c9f15934 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
+#include "qemu/range.h"
#include "cpu.h"
#include "tcg/tcg.h"
#include "exec/helper-proto.h"
@@ -240,9 +241,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,
if (new_ctx == ctx) {
uint64_t vaddr = tlb[i].tag & ~0x1fffULL;
uint64_t size = 8192ULL << 3 * TTE_PGSIZE(tlb[i].tte);
- if (new_vaddr == vaddr
- || (new_vaddr < vaddr + size
- && vaddr < new_vaddr + new_size)) {
+ if (ranges_overlap(new_vaddr, new_size, vaddr, size)) {
DPRINTF_MMU("auto demap entry [%d] %lx->%lx\n", i, vaddr,
new_vaddr);
replace_tlb_entry(&tlb[i], tlb_tag, tlb_tte, env1);
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 15/28] system/memory_mapping: make range overlap check more readable
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2024-07-23 20:38 ` [PULL 14/28] sparc/ldst_helper: " Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 16/28] crypto/block-luks: " Philippe Mathieu-Daudé
` (13 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Yao Xingtao, Philippe Mathieu-Daudé, David Hildenbrand
From: Yao Xingtao <yaoxt.fnst@fujitsu.com>
use ranges_overlap() instead of open-coding the overlap check to improve
the readability of the code.
Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-ID: <20240722040742.11513-10-yaoxt.fnst@fujitsu.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
system/memory_mapping.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/system/memory_mapping.c b/system/memory_mapping.c
index 6f884c5b90c..ca2390eb804 100644
--- a/system/memory_mapping.c
+++ b/system/memory_mapping.c
@@ -12,6 +12,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/range.h"
#include "qapi/error.h"
#include "sysemu/memory_mapping.h"
@@ -353,8 +354,7 @@ void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
MemoryMapping *cur, *next;
QTAILQ_FOREACH_SAFE(cur, &list->head, next, next) {
- if (cur->phys_addr >= begin + length ||
- cur->phys_addr + cur->length <= begin) {
+ if (!ranges_overlap(cur->phys_addr, cur->length, begin, length)) {
QTAILQ_REMOVE(&list->head, cur, next);
g_free(cur);
list->num--;
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 16/28] crypto/block-luks: make range overlap check more readable
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2024-07-23 20:38 ` [PULL 15/28] system/memory_mapping: " Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 17/28] dump: " Philippe Mathieu-Daudé
` (12 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Yao Xingtao, Philippe Mathieu-Daudé,
Daniel P . Berrangé
From: Yao Xingtao <yaoxt.fnst@fujitsu.com>
use ranges_overlap() instead of open-coding the overlap check to improve
the readability of the code.
Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20240722040742.11513-12-yaoxt.fnst@fujitsu.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
crypto/block-luks.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/crypto/block-luks.c b/crypto/block-luks.c
index 5b777c15d3c..45347adeeb7 100644
--- a/crypto/block-luks.c
+++ b/crypto/block-luks.c
@@ -33,6 +33,7 @@
#include "qemu/uuid.h"
#include "qemu/bitmap.h"
+#include "qemu/range.h"
/*
* Reference for the LUKS format implemented here is
@@ -572,7 +573,7 @@ qcrypto_block_luks_check_header(const QCryptoBlockLUKS *luks,
header_sectors,
slot2->stripes);
- if (start1 + len1 > start2 && start2 + len2 > start1) {
+ if (ranges_overlap(start1, len1, start2, len2)) {
error_setg(errp,
"Keyslots %zu and %zu are overlapping in the header",
i, j);
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 17/28] dump: make range overlap check more readable
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2024-07-23 20:38 ` [PULL 16/28] crypto/block-luks: " Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 18/28] hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler Philippe Mathieu-Daudé
` (11 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Yao Xingtao, Marc-André Lureau, Philippe Mathieu-Daudé
From: Yao Xingtao <yaoxt.fnst@fujitsu.com>
use ranges_overlap() instead of open-coding the overlap check to improve
the readability of the code.
Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20240722040742.11513-13-yaoxt.fnst@fujitsu.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
dump/dump.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index 84064d890d2..45e84428aea 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -30,6 +30,7 @@
#include "migration/blocker.h"
#include "hw/core/cpu.h"
#include "win_dump.h"
+#include "qemu/range.h"
#include <zlib.h>
#ifdef CONFIG_LZO
@@ -574,8 +575,10 @@ static void get_offset_range(hwaddr phys_addr,
QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
if (dump_has_filter(s)) {
- if (block->target_start >= s->filter_area_begin + s->filter_area_length ||
- block->target_end <= s->filter_area_begin) {
+ if (!ranges_overlap(block->target_start,
+ block->target_end - block->target_start,
+ s->filter_area_begin,
+ s->filter_area_length)) {
/* This block is out of the range */
continue;
}
@@ -734,8 +737,9 @@ int64_t dump_filtered_memblock_start(GuestPhysBlock *block,
{
if (filter_area_length) {
/* return -1 if the block is not within filter area */
- if (block->target_start >= filter_area_start + filter_area_length ||
- block->target_end <= filter_area_start) {
+ if (!ranges_overlap(block->target_start,
+ block->target_end - block->target_start,
+ filter_area_start, filter_area_length)) {
return -1;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 18/28] hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2024-07-23 20:38 ` [PULL 17/28] dump: " Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 19/28] hw/char/goldfish: Use DMA memory API Philippe Mathieu-Daudé
` (10 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Zhao Liu, Markus Armbruster, Philippe Mathieu-Daudé
From: Zhao Liu <zhao1.liu@intel.com>
According to the comment in qapi/error.h, dereferencing @errp requires
ERRP_GUARD():
* = Why, when and how to use ERRP_GUARD() =
*
* Without ERRP_GUARD(), use of the @errp parameter is restricted:
* - It must not be dereferenced, because it may be null.
...
* ERRP_GUARD() lifts these restrictions.
*
* To use ERRP_GUARD(), add it right at the beginning of the function.
* @errp can then be used without worrying about the argument being
* NULL or &error_fatal.
*
* Using it when it's not needed is safe, but please avoid cluttering
* the source with useless code.
In nubus_virtio_mmio_realize(), @errp is dereferenced without
ERRP_GUARD().
Although nubus_virtio_mmio_realize() - as a DeviceClass.realize()
method - is never passed a null @errp argument, it should follow the
rules on @errp usage. Add the ERRP_GUARD() there.
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Message-ID: <20240723161802.1377985-1-zhao1.liu@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/nubus/nubus-virtio-mmio.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/nubus/nubus-virtio-mmio.c b/hw/nubus/nubus-virtio-mmio.c
index 58a63c84d0b..7a98731c451 100644
--- a/hw/nubus/nubus-virtio-mmio.c
+++ b/hw/nubus/nubus-virtio-mmio.c
@@ -7,6 +7,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "hw/nubus/nubus-virtio-mmio.h"
@@ -23,6 +24,7 @@ static void nubus_virtio_mmio_set_input_irq(void *opaque, int n, int level)
static void nubus_virtio_mmio_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
NubusVirtioMMIODeviceClass *nvmdc = NUBUS_VIRTIO_MMIO_GET_CLASS(dev);
NubusVirtioMMIO *s = NUBUS_VIRTIO_MMIO(dev);
NubusDevice *nd = NUBUS_DEVICE(dev);
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 19/28] hw/char/goldfish: Use DMA memory API
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2024-07-23 20:38 ` [PULL 18/28] hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 20/28] chardev/char-fe: Document returned value on error Philippe Mathieu-Daudé
` (9 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Peter Xu, Pierrick Bouvier
Rather than using address_space_rw(..., 0 or 1),
use the simpler DMA memory API which expand to
the same code. This allows removing a cast on
the 'buf' variable which is really const. Since
'buf' is only used in the CMD_READ_BUFFER case,
we can reduce its scope.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240723181850.46000-1-philmd@linaro.org>
---
hw/char/goldfish_tty.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/char/goldfish_tty.c b/hw/char/goldfish_tty.c
index f8ff043c396..cdff46bc13b 100644
--- a/hw/char/goldfish_tty.c
+++ b/hw/char/goldfish_tty.c
@@ -16,6 +16,7 @@
#include "qemu/log.h"
#include "trace.h"
#include "exec/address-spaces.h"
+#include "sysemu/dma.h"
#include "hw/char/goldfish_tty.h"
#define GOLDFISH_TTY_VERSION 1
@@ -69,7 +70,6 @@ static uint64_t goldfish_tty_read(void *opaque, hwaddr addr,
static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd)
{
uint32_t to_copy;
- uint8_t *buf;
uint8_t data_out[GOLFISH_TTY_BUFFER_SIZE];
int len;
uint64_t ptr;
@@ -97,8 +97,8 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd)
while (len) {
to_copy = MIN(GOLFISH_TTY_BUFFER_SIZE, len);
- address_space_rw(&address_space_memory, ptr,
- MEMTXATTRS_UNSPECIFIED, data_out, to_copy, 0);
+ dma_memory_read_relaxed(&address_space_memory, ptr,
+ data_out, to_copy);
qemu_chr_fe_write_all(&s->chr, data_out, to_copy);
len -= to_copy;
@@ -109,9 +109,9 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd)
len = s->data_len;
ptr = s->data_ptr;
while (len && !fifo8_is_empty(&s->rx_fifo)) {
- buf = (uint8_t *)fifo8_pop_buf(&s->rx_fifo, len, &to_copy);
- address_space_rw(&address_space_memory, ptr,
- MEMTXATTRS_UNSPECIFIED, buf, to_copy, 1);
+ const uint8_t *buf = fifo8_pop_buf(&s->rx_fifo, len, &to_copy);
+
+ dma_memory_write_relaxed(&address_space_memory, ptr, buf, to_copy);
len -= to_copy;
ptr += to_copy;
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 20/28] chardev/char-fe: Document returned value on error
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2024-07-23 20:38 ` [PULL 19/28] hw/char/goldfish: Use DMA memory API Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 21/28] util/fifo8: Fix style Philippe Mathieu-Daudé
` (8 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Mark Cave-Ayland, Pierrick Bouvier
qemu_chr_fe_add_watch() and qemu_chr_fe_write[_all]()
return -1 on error. Mention it in the documentation.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240722160745.67904-2-philmd@linaro.org>
---
include/chardev/char-fe.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h
index ecef1828355..3310449eaf0 100644
--- a/include/chardev/char-fe.h
+++ b/include/chardev/char-fe.h
@@ -228,6 +228,7 @@ guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond,
* is thread-safe.
*
* Returns: the number of bytes consumed (0 if no associated Chardev)
+ * or -1 on error.
*/
int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len);
@@ -242,6 +243,7 @@ int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len);
* attempted to be written. This function is thread-safe.
*
* Returns: the number of bytes consumed (0 if no associated Chardev)
+ * or -1 on error.
*/
int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len);
@@ -253,6 +255,7 @@ int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len);
* Read data to a buffer from the back end.
*
* Returns: the number of bytes read (0 if no associated Chardev)
+ * or -1 on error.
*/
int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len);
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 21/28] util/fifo8: Fix style
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2024-07-23 20:38 ` [PULL 20/28] chardev/char-fe: Document returned value on error Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 22/28] util/fifo8: Use fifo8_reset() in fifo8_create() Philippe Mathieu-Daudé
` (7 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Pierrick Bouvier, Mark Cave-Ayland
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20240722160745.67904-3-philmd@linaro.org>
---
include/qemu/fifo8.h | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
index c6295c6ff0c..2692d6bfdaa 100644
--- a/include/qemu/fifo8.h
+++ b/include/qemu/fifo8.h
@@ -15,10 +15,9 @@ typedef struct {
* @fifo: struct Fifo8 to initialise with new FIFO
* @capacity: capacity of the newly created FIFO
*
- * Create a FIFO of the specified size. Clients should call fifo8_destroy()
+ * Create a FIFO of the specified capacity. Clients should call fifo8_destroy()
* when finished using the fifo. The FIFO is initially empty.
*/
-
void fifo8_create(Fifo8 *fifo, uint32_t capacity);
/**
@@ -26,9 +25,8 @@ void fifo8_create(Fifo8 *fifo, uint32_t capacity);
* @fifo: FIFO to cleanup
*
* Cleanup a FIFO created with fifo8_create(). Frees memory created for FIFO
- *storage. The FIFO is no longer usable after this has been called.
+ * storage. The FIFO is no longer usable after this has been called.
*/
-
void fifo8_destroy(Fifo8 *fifo);
/**
@@ -39,7 +37,6 @@ void fifo8_destroy(Fifo8 *fifo);
* Push a data byte to the FIFO. Behaviour is undefined if the FIFO is full.
* Clients are responsible for checking for fullness using fifo8_is_full().
*/
-
void fifo8_push(Fifo8 *fifo, uint8_t data);
/**
@@ -52,7 +49,6 @@ void fifo8_push(Fifo8 *fifo, uint8_t data);
* Clients are responsible for checking the space left in the FIFO using
* fifo8_num_free().
*/
-
void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num);
/**
@@ -64,7 +60,6 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num);
*
* Returns: The popped data byte.
*/
-
uint8_t fifo8_pop(Fifo8 *fifo);
/**
@@ -73,7 +68,7 @@ uint8_t fifo8_pop(Fifo8 *fifo);
* @max: maximum number of bytes to pop
* @numptr: pointer filled with number of bytes returned (can be NULL)
*
- * Pop a number of elements from the FIFO up to a maximum of max. The buffer
+ * Pop a number of elements from the FIFO up to a maximum of @max. The buffer
* containing the popped data is returned. This buffer points directly into
* the FIFO backing store and data is invalidated once any of the fifo8_* APIs
* are called on the FIFO.
@@ -82,7 +77,7 @@ uint8_t fifo8_pop(Fifo8 *fifo);
* around in the ring buffer; in this case only a contiguous part of the data
* is returned.
*
- * The number of valid bytes returned is populated in *numptr; will always
+ * The number of valid bytes returned is populated in *@numptr; will always
* return at least 1 byte. max must not be 0 or greater than the number of
* bytes in the FIFO.
*
@@ -99,7 +94,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
* @max: maximum number of bytes to peek
* @numptr: pointer filled with number of bytes returned (can be NULL)
*
- * Peek into a number of elements from the FIFO up to a maximum of max.
+ * Peek into a number of elements from the FIFO up to a maximum of @max.
* The buffer containing the data peeked into is returned. This buffer points
* directly into the FIFO backing store. Since data is invalidated once any
* of the fifo8_* APIs are called on the FIFO, it is the caller responsibility
@@ -109,7 +104,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
* around in the ring buffer; in this case only a contiguous part of the data
* is returned.
*
- * The number of valid bytes returned is populated in *numptr; will always
+ * The number of valid bytes returned is populated in *@numptr; will always
* return at least 1 byte. max must not be 0 or greater than the number of
* bytes in the FIFO.
*
@@ -126,7 +121,6 @@ const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
*
* Reset a FIFO. All data is discarded and the FIFO is emptied.
*/
-
void fifo8_reset(Fifo8 *fifo);
/**
@@ -137,7 +131,6 @@ void fifo8_reset(Fifo8 *fifo);
*
* Returns: True if the fifo is empty, false otherwise.
*/
-
bool fifo8_is_empty(Fifo8 *fifo);
/**
@@ -148,7 +141,6 @@ bool fifo8_is_empty(Fifo8 *fifo);
*
* Returns: True if the fifo is full, false otherwise.
*/
-
bool fifo8_is_full(Fifo8 *fifo);
/**
@@ -159,7 +151,6 @@ bool fifo8_is_full(Fifo8 *fifo);
*
* Returns: Number of free bytes.
*/
-
uint32_t fifo8_num_free(Fifo8 *fifo);
/**
@@ -170,7 +161,6 @@ uint32_t fifo8_num_free(Fifo8 *fifo);
*
* Returns: Number of used bytes.
*/
-
uint32_t fifo8_num_used(Fifo8 *fifo);
extern const VMStateDescription vmstate_fifo8;
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 22/28] util/fifo8: Use fifo8_reset() in fifo8_create()
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2024-07-23 20:38 ` [PULL 21/28] util/fifo8: Fix style Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 23/28] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_bufptr() Philippe Mathieu-Daudé
` (6 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Mark Cave-Ayland, Pierrick Bouvier
Avoid open-coding fifo8_reset() in fifo8_create().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240722160745.67904-4-philmd@linaro.org>
---
util/fifo8.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/util/fifo8.c b/util/fifo8.c
index 4e01b532d9d..2925fe56119 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -16,12 +16,17 @@
#include "migration/vmstate.h"
#include "qemu/fifo8.h"
+void fifo8_reset(Fifo8 *fifo)
+{
+ fifo->num = 0;
+ fifo->head = 0;
+}
+
void fifo8_create(Fifo8 *fifo, uint32_t capacity)
{
fifo->data = g_new(uint8_t, capacity);
fifo->capacity = capacity;
- fifo->head = 0;
- fifo->num = 0;
+ fifo8_reset(fifo);
}
void fifo8_destroy(Fifo8 *fifo)
@@ -97,12 +102,6 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
return fifo8_peekpop_buf(fifo, max, numptr, true);
}
-void fifo8_reset(Fifo8 *fifo)
-{
- fifo->num = 0;
- fifo->head = 0;
-}
-
bool fifo8_is_empty(Fifo8 *fifo)
{
return (fifo->num == 0);
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 23/28] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_bufptr()
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2024-07-23 20:38 ` [PULL 22/28] util/fifo8: Use fifo8_reset() in fifo8_create() Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 24/28] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr() Philippe Mathieu-Daudé
` (5 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Pierrick Bouvier, Mark Cave-Ayland
Since fifo8_peek_buf() return a const buffer (which points
directly into the FIFO backing store). Rename it using the
'bufptr' suffix to better reflect that it is a pointer to
the internal buffer that is being returned. This will help
differentiate with methods *copying* the FIFO data.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20240722160745.67904-5-philmd@linaro.org>
---
include/qemu/fifo8.h | 11 ++++++-----
hw/scsi/esp.c | 2 +-
util/fifo8.c | 2 +-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
index 2692d6bfdaa..e287e871190 100644
--- a/include/qemu/fifo8.h
+++ b/include/qemu/fifo8.h
@@ -89,16 +89,17 @@ uint8_t fifo8_pop(Fifo8 *fifo);
const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
/**
- * fifo8_peek_buf: read upto max bytes from the fifo
+ * fifo8_peek_bufptr: read upto max bytes from the fifo
* @fifo: FIFO to read from
* @max: maximum number of bytes to peek
* @numptr: pointer filled with number of bytes returned (can be NULL)
*
* Peek into a number of elements from the FIFO up to a maximum of @max.
* The buffer containing the data peeked into is returned. This buffer points
- * directly into the FIFO backing store. Since data is invalidated once any
- * of the fifo8_* APIs are called on the FIFO, it is the caller responsibility
- * to access it before doing further API calls.
+ * directly into the internal FIFO backing store (without checking for
+ * overflow!). Since data is invalidated once any of the fifo8_* APIs are
+ * called on the FIFO, it is the caller responsibility to access it before
+ * doing further API calls.
*
* The function may return fewer bytes than requested when the data wraps
* around in the ring buffer; in this case only a contiguous part of the data
@@ -113,7 +114,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
*
* Returns: A pointer to peekable data.
*/
-const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
+const uint8_t *fifo8_peek_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
/**
* fifo8_reset:
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 8504dd30a0d..412c8cf2260 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -486,7 +486,7 @@ static bool esp_cdb_ready(ESPState *s)
return false;
}
- pbuf = fifo8_peek_buf(&s->cmdfifo, len, &n);
+ pbuf = fifo8_peek_bufptr(&s->cmdfifo, len, &n);
if (n < len) {
/*
* In normal use the cmdfifo should never wrap, but include this check
diff --git a/util/fifo8.c b/util/fifo8.c
index 2925fe56119..566b0893441 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -92,7 +92,7 @@ static const uint8_t *fifo8_peekpop_buf(Fifo8 *fifo, uint32_t max,
return ret;
}
-const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
+const uint8_t *fifo8_peek_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
{
return fifo8_peekpop_buf(fifo, max, numptr, false);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 24/28] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr()
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2024-07-23 20:38 ` [PULL 23/28] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_bufptr() Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 25/28] util/fifo8: Expose fifo8_pop_buf() Philippe Mathieu-Daudé
` (4 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Pierrick Bouvier, Mark Cave-Ayland
Since fifo8_pop_buf() return a const buffer (which points
directly into the FIFO backing store). Rename it using the
'bufptr' suffix to better reflect that it is a pointer to
the internal buffer that is being returned. This will help
differentiate with methods *copying* the FIFO data.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20240722160745.67904-6-philmd@linaro.org>
---
include/qemu/fifo8.h | 15 +++++++--------
chardev/msmouse.c | 2 +-
hw/char/goldfish_tty.c | 2 +-
hw/net/allwinner_emac.c | 2 +-
hw/scsi/esp.c | 4 ++--
ui/console-vc.c | 2 +-
ui/gtk.c | 2 +-
util/fifo8.c | 2 +-
8 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
index e287e871190..a30220c8e96 100644
--- a/include/qemu/fifo8.h
+++ b/include/qemu/fifo8.h
@@ -63,15 +63,15 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num);
uint8_t fifo8_pop(Fifo8 *fifo);
/**
- * fifo8_pop_buf:
+ * fifo8_pop_bufptr:
* @fifo: FIFO to pop from
* @max: maximum number of bytes to pop
* @numptr: pointer filled with number of bytes returned (can be NULL)
*
* Pop a number of elements from the FIFO up to a maximum of @max. The buffer
* containing the popped data is returned. This buffer points directly into
- * the FIFO backing store and data is invalidated once any of the fifo8_* APIs
- * are called on the FIFO.
+ * the internal FIFO backing store and data (without checking for overflow!)
+ * and is invalidated once any of the fifo8_* APIs are called on the FIFO.
*
* The function may return fewer bytes than requested when the data wraps
* around in the ring buffer; in this case only a contiguous part of the data
@@ -86,7 +86,7 @@ uint8_t fifo8_pop(Fifo8 *fifo);
*
* Returns: A pointer to popped data.
*/
-const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
+const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
/**
* fifo8_peek_bufptr: read upto max bytes from the fifo
@@ -96,10 +96,9 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
*
* Peek into a number of elements from the FIFO up to a maximum of @max.
* The buffer containing the data peeked into is returned. This buffer points
- * directly into the internal FIFO backing store (without checking for
- * overflow!). Since data is invalidated once any of the fifo8_* APIs are
- * called on the FIFO, it is the caller responsibility to access it before
- * doing further API calls.
+ * directly into the FIFO backing store. Since data is invalidated once any
+ * of the fifo8_* APIs are called on the FIFO, it is the caller responsibility
+ * to access it before doing further API calls.
*
* The function may return fewer bytes than requested when the data wraps
* around in the ring buffer; in this case only a contiguous part of the data
diff --git a/chardev/msmouse.c b/chardev/msmouse.c
index a774c397b45..2279694cfab 100644
--- a/chardev/msmouse.c
+++ b/chardev/msmouse.c
@@ -81,7 +81,7 @@ static void msmouse_chr_accept_input(Chardev *chr)
const uint8_t *buf;
uint32_t size;
- buf = fifo8_pop_buf(&mouse->outbuf, MIN(len, avail), &size);
+ buf = fifo8_pop_bufptr(&mouse->outbuf, MIN(len, avail), &size);
qemu_chr_be_write(chr, buf, size);
len = qemu_chr_be_can_write(chr);
avail -= size;
diff --git a/hw/char/goldfish_tty.c b/hw/char/goldfish_tty.c
index cdff46bc13b..c2e1f6537f7 100644
--- a/hw/char/goldfish_tty.c
+++ b/hw/char/goldfish_tty.c
@@ -109,7 +109,7 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd)
len = s->data_len;
ptr = s->data_ptr;
while (len && !fifo8_is_empty(&s->rx_fifo)) {
- const uint8_t *buf = fifo8_pop_buf(&s->rx_fifo, len, &to_copy);
+ const uint8_t *buf = fifo8_pop_bufptr(&s->rx_fifo, len, &to_copy);
dma_memory_write_relaxed(&address_space_memory, ptr, buf, to_copy);
diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c
index 989839784a9..d40ff37e994 100644
--- a/hw/net/allwinner_emac.c
+++ b/hw/net/allwinner_emac.c
@@ -349,7 +349,7 @@ static void aw_emac_write(void *opaque, hwaddr offset, uint64_t value,
"allwinner_emac: TX length > fifo data length\n");
}
if (len > 0) {
- data = fifo8_pop_buf(fifo, len, &ret);
+ data = fifo8_pop_bufptr(fifo, len, &ret);
qemu_send_packet(nc, data, ret);
aw_emac_tx_reset(s, chan);
/* Raise TX interrupt */
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 412c8cf2260..7e9657e9c30 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -208,7 +208,7 @@ static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen)
}
len = maxlen;
- buf = fifo8_pop_buf(fifo, len, &n);
+ buf = fifo8_pop_bufptr(fifo, len, &n);
if (dest) {
memcpy(dest, buf, n);
}
@@ -217,7 +217,7 @@ static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen)
len -= n;
len = MIN(len, fifo8_num_used(fifo));
if (len) {
- buf = fifo8_pop_buf(fifo, len, &n2);
+ buf = fifo8_pop_bufptr(fifo, len, &n2);
if (dest) {
memcpy(&dest[n], buf, n2);
}
diff --git a/ui/console-vc.c b/ui/console-vc.c
index 899fa11c948..8393d532e7f 100644
--- a/ui/console-vc.c
+++ b/ui/console-vc.c
@@ -287,7 +287,7 @@ static void kbd_send_chars(QemuTextConsole *s)
const uint8_t *buf;
uint32_t size;
- buf = fifo8_pop_buf(&s->out_fifo, MIN(len, avail), &size);
+ buf = fifo8_pop_bufptr(&s->out_fifo, MIN(len, avail), &size);
qemu_chr_be_write(s->chr, buf, size);
len = qemu_chr_be_can_write(s->chr);
avail -= size;
diff --git a/ui/gtk.c b/ui/gtk.c
index bc29f7a1b4f..8e14c2ac81d 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1820,7 +1820,7 @@ static void gd_vc_send_chars(VirtualConsole *vc)
const uint8_t *buf;
uint32_t size;
- buf = fifo8_pop_buf(&vc->vte.out_fifo, MIN(len, avail), &size);
+ buf = fifo8_pop_bufptr(&vc->vte.out_fifo, MIN(len, avail), &size);
qemu_chr_be_write(vc->vte.chr, buf, size);
len = qemu_chr_be_can_write(vc->vte.chr);
avail -= size;
diff --git a/util/fifo8.c b/util/fifo8.c
index 566b0893441..5bbb6150b60 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -97,7 +97,7 @@ const uint8_t *fifo8_peek_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
return fifo8_peekpop_buf(fifo, max, numptr, false);
}
-const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
+const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
{
return fifo8_peekpop_buf(fifo, max, numptr, true);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 25/28] util/fifo8: Expose fifo8_pop_buf()
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (23 preceding siblings ...)
2024-07-23 20:38 ` [PULL 24/28] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr() Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 26/28] util/fifo8: Introduce fifo8_drop() Philippe Mathieu-Daudé
` (3 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Mark Cave-Ayland, Pierrick Bouvier
Extract fifo8_pop_buf() from hw/scsi/esp.c and expose
it as part of the <qemu/fifo8.h> API. This function takes
care of non-contiguous (wrapped) FIFO buffer (which is an
implementation detail).
Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20240722160745.67904-7-philmd@linaro.org>
---
include/qemu/fifo8.h | 16 ++++++++++++++++
hw/scsi/esp.c | 36 +++---------------------------------
util/fifo8.c | 29 +++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 33 deletions(-)
diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
index a30220c8e96..bca6da306f7 100644
--- a/include/qemu/fifo8.h
+++ b/include/qemu/fifo8.h
@@ -62,12 +62,28 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num);
*/
uint8_t fifo8_pop(Fifo8 *fifo);
+/**
+ * fifo8_pop_buf:
+ * @fifo: FIFO to pop from
+ * @dest: the buffer to write the data into (can be NULL)
+ * @destlen: size of @dest and maximum number of bytes to pop
+ *
+ * Pop a number of elements from the FIFO up to a maximum of @destlen.
+ * The popped data is copied into the @dest buffer.
+ * Care is taken when the data wraps around in the ring buffer.
+ *
+ * Returns: number of bytes popped.
+ */
+uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen);
+
/**
* fifo8_pop_bufptr:
* @fifo: FIFO to pop from
* @max: maximum number of bytes to pop
* @numptr: pointer filled with number of bytes returned (can be NULL)
*
+ * New code should prefer to use fifo8_pop_buf() instead of fifo8_pop_bufptr().
+ *
* Pop a number of elements from the FIFO up to a maximum of @max. The buffer
* containing the popped data is returned. This buffer points directly into
* the internal FIFO backing store and data (without checking for overflow!)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 7e9657e9c30..04c9a557b69 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -197,39 +197,9 @@ static uint8_t esp_fifo_pop(ESPState *s)
return val;
}
-static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen)
-{
- const uint8_t *buf;
- uint32_t n, n2;
- int len;
-
- if (maxlen == 0) {
- return 0;
- }
-
- len = maxlen;
- buf = fifo8_pop_bufptr(fifo, len, &n);
- if (dest) {
- memcpy(dest, buf, n);
- }
-
- /* Add FIFO wraparound if needed */
- len -= n;
- len = MIN(len, fifo8_num_used(fifo));
- if (len) {
- buf = fifo8_pop_bufptr(fifo, len, &n2);
- if (dest) {
- memcpy(&dest[n], buf, n2);
- }
- n += n2;
- }
-
- return n;
-}
-
static uint32_t esp_fifo_pop_buf(ESPState *s, uint8_t *dest, int maxlen)
{
- uint32_t len = esp_fifo8_pop_buf(&s->fifo, dest, maxlen);
+ uint32_t len = fifo8_pop_buf(&s->fifo, dest, maxlen);
esp_update_drq(s);
return len;
@@ -335,7 +305,7 @@ static void do_command_phase(ESPState *s)
if (!cmdlen || !s->current_dev) {
return;
}
- esp_fifo8_pop_buf(&s->cmdfifo, buf, cmdlen);
+ fifo8_pop_buf(&s->cmdfifo, buf, cmdlen);
current_lun = scsi_device_find(&s->bus, 0, s->current_dev->id, s->lun);
if (!current_lun) {
@@ -381,7 +351,7 @@ static void do_message_phase(ESPState *s)
/* Ignore extended messages for now */
if (s->cmdfifo_cdb_offset) {
int len = MIN(s->cmdfifo_cdb_offset, fifo8_num_used(&s->cmdfifo));
- esp_fifo8_pop_buf(&s->cmdfifo, NULL, len);
+ fifo8_pop_buf(&s->cmdfifo, NULL, len);
s->cmdfifo_cdb_offset = 0;
}
}
diff --git a/util/fifo8.c b/util/fifo8.c
index 5bbb6150b60..a250ea9f804 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -102,6 +102,35 @@ const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
return fifo8_peekpop_buf(fifo, max, numptr, true);
}
+uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen)
+{
+ const uint8_t *buf;
+ uint32_t n1, n2 = 0;
+ uint32_t len;
+
+ if (destlen == 0) {
+ return 0;
+ }
+
+ len = destlen;
+ buf = fifo8_pop_bufptr(fifo, len, &n1);
+ if (dest) {
+ memcpy(dest, buf, n1);
+ }
+
+ /* Add FIFO wraparound if needed */
+ len -= n1;
+ len = MIN(len, fifo8_num_used(fifo));
+ if (len) {
+ buf = fifo8_pop_bufptr(fifo, len, &n2);
+ if (dest) {
+ memcpy(&dest[n1], buf, n2);
+ }
+ }
+
+ return n1 + n2;
+}
+
bool fifo8_is_empty(Fifo8 *fifo)
{
return (fifo->num == 0);
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 26/28] util/fifo8: Introduce fifo8_drop()
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (24 preceding siblings ...)
2024-07-23 20:38 ` [PULL 25/28] util/fifo8: Expose fifo8_pop_buf() Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 27/28] MAINTAINERS: Cover guest-agent in QAPI schema Philippe Mathieu-Daudé
` (2 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Pierrick Bouvier, Mark Cave-Ayland
Add the fifo8_drop() helper for clarity.
It is a simple wrapper over fifo8_pop_buf().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <20240722160745.67904-8-philmd@linaro.org>
---
include/qemu/fifo8.h | 9 +++++++++
hw/scsi/esp.c | 2 +-
util/fifo8.c | 6 ++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
index bca6da306f7..d1d06754d84 100644
--- a/include/qemu/fifo8.h
+++ b/include/qemu/fifo8.h
@@ -131,6 +131,15 @@ const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
*/
const uint8_t *fifo8_peek_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
+/**
+ * fifo8_drop:
+ * @fifo: FIFO to drop bytes
+ * @len: number of bytes to drop
+ *
+ * Drop (consume) bytes from a FIFO.
+ */
+void fifo8_drop(Fifo8 *fifo, uint32_t len);
+
/**
* fifo8_reset:
* @fifo: FIFO to reset
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 04c9a557b69..b7af8256232 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -351,7 +351,7 @@ static void do_message_phase(ESPState *s)
/* Ignore extended messages for now */
if (s->cmdfifo_cdb_offset) {
int len = MIN(s->cmdfifo_cdb_offset, fifo8_num_used(&s->cmdfifo));
- fifo8_pop_buf(&s->cmdfifo, NULL, len);
+ fifo8_drop(&s->cmdfifo, len);
s->cmdfifo_cdb_offset = 0;
}
}
diff --git a/util/fifo8.c b/util/fifo8.c
index a250ea9f804..1ffa19d900e 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -131,6 +131,12 @@ uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen)
return n1 + n2;
}
+void fifo8_drop(Fifo8 *fifo, uint32_t len)
+{
+ len -= fifo8_pop_buf(fifo, NULL, len);
+ assert(len == 0);
+}
+
bool fifo8_is_empty(Fifo8 *fifo)
{
return (fifo->num == 0);
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 27/28] MAINTAINERS: Cover guest-agent in QAPI schema
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (25 preceding siblings ...)
2024-07-23 20:38 ` [PULL 26/28] util/fifo8: Introduce fifo8_drop() Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 28/28] MAINTAINERS: Add myself as a reviewer of machine core Philippe Mathieu-Daudé
2024-07-24 8:14 ` [PULL 00/28] Misc HW+ patches for 2024-07-23 Richard Henderson
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel
Cc: Philippe Mathieu-Daudé, Markus Armbruster,
Konstantin Kostiuk
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240717140025.66397-1-philmd@linaro.org>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index d5ff6c2498e..8c048782a6d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3218,6 +3218,7 @@ M: Eric Blake <eblake@redhat.com>
M: Markus Armbruster <armbru@redhat.com>
S: Supported
F: qapi/*.json
+F: qga/qapi-schema.json
T: git https://repo.or.cz/qemu/armbru.git qapi-next
QObject
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PULL 28/28] MAINTAINERS: Add myself as a reviewer of machine core
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (26 preceding siblings ...)
2024-07-23 20:38 ` [PULL 27/28] MAINTAINERS: Cover guest-agent in QAPI schema Philippe Mathieu-Daudé
@ 2024-07-23 20:38 ` Philippe Mathieu-Daudé
2024-07-24 8:14 ` [PULL 00/28] Misc HW+ patches for 2024-07-23 Richard Henderson
28 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-23 20:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Zhao Liu, Philippe Mathieu-Daudé
From: Zhao Liu <zhao1.liu@intel.com>
While working on a series of CPU/cache topology work, I became
interested in the machine core component and would like to help to
review more related patches.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240722164412.1163414-1-zhao1.liu@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 8c048782a6d..a8e9d1b0010 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1878,6 +1878,7 @@ M: Eduardo Habkost <eduardo@habkost.net>
M: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
R: Philippe Mathieu-Daudé <philmd@linaro.org>
R: Yanan Wang <wangyanan55@huawei.com>
+R: Zhao Liu <zhao1.liu@intel.com>
S: Supported
F: hw/core/cpu-common.c
F: hw/core/cpu-sysemu.c
--
2.41.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PULL 00/28] Misc HW+ patches for 2024-07-23
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
` (27 preceding siblings ...)
2024-07-23 20:38 ` [PULL 28/28] MAINTAINERS: Add myself as a reviewer of machine core Philippe Mathieu-Daudé
@ 2024-07-24 8:14 ` Richard Henderson
28 siblings, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2024-07-24 8:14 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
On 7/24/24 06:38, Philippe Mathieu-Daudé wrote:
> The following changes since commit 3cce8bd4d737f2ca688bbdcb92cd5cc683245bbd:
>
> Merge tag 'ui-pull-request' ofhttps://gitlab.com/marcandre.lureau/qemu into staging (2024-07-23 15:23:05 +1000)
>
> are available in the Git repository at:
>
> https://github.com/philmd/qemu.git tags/hw-misc-20240723
>
> for you to fetch changes up to e4a44f94db11fcf873399c60ebb1d93a9ad1cd6e:
>
> MAINTAINERS: Add myself as a reviewer of machine core (2024-07-23 22:34:54 +0200)
>
> Ignored unrelated error:
>
> TEST signals on ppc64
> signals:allocatestack.c:223: allocate_stack: Assertion `powerof2 (pagesize_m1 + 1)' failed.
> qemu: uncaught target signal 6 (Aborted) - core dumped
> timeout: the monitored command dumped core
> Aborted
> make[1]: *** [Makefile:175: run-signals] Error 134
> make: *** [/builds/philmd/qemu/tests/Makefile.include:56: run-tcg-tests-ppc64-linux-user] Error 2
>
> ----------------------------------------------------------------
> Misc HW patch queue
>
> - Restrict probe_access*() functions to TCG (Phil)
> - Extract do_invalidate_device_tlb from vtd_process_device_iotlb_desc (Clément)
> - Fixes in Loongson IPI model (Bibo & Phil)
> - Make docs/interop/firmware.json compatible with qapi-gen.py script (Thomas)
> - Correct MPC I2C MMIO region size (Zoltan)
> - Remove useless cast in Loongson3 Virt machine (Yao)
> - Various uses of range overlap API (Yao)
> - Use ERRP_GUARD macro in nubus_virtio_mmio_realize (Zhao)
> - Use DMA memory API in Goldfish UART model (Phil)
> - Expose fifo8_pop_buf and introduce fifo8_drop (Phil)
> - MAINTAINERS updates (Zhao, Phil)
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.
r~
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2024-07-24 8:15 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-23 20:38 [PULL 00/28] Misc HW+ patches for 2024-07-23 Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 01/28] accel: Restrict probe_access*() functions to TCG Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 02/28] hw/i386/intel_iommu: Extract device IOTLB invalidation logic Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 03/28] hw/intc/loongson_ipi: Access memory in little endian Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 04/28] hw/intc/loongson_ipi: Fix resource leak Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 05/28] hw/intc/loongson_ipi: Declare QOM types using DEFINE_TYPES() macro Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 06/28] docs: Correct Loongarch -> LoongArch Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 07/28] docs/interop/firmware.json: add new enum FirmwareFormat Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 08/28] docs/interop/firmware.json: add new enum FirmwareArchitecture Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 09/28] docs/interop/firmware.json: convert "Example" section Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 10/28] hw/i2c/mpc_i2c: Fix mmio region size Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 11/28] hw/mips/loongson3_virt: remove useless type cast Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 12/28] util/range: Make ranges_overlap() return bool Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 13/28] cxl/mailbox: make range overlap check more readable Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 14/28] sparc/ldst_helper: " Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 15/28] system/memory_mapping: " Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 16/28] crypto/block-luks: " Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 17/28] dump: " Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 18/28] hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 19/28] hw/char/goldfish: Use DMA memory API Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 20/28] chardev/char-fe: Document returned value on error Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 21/28] util/fifo8: Fix style Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 22/28] util/fifo8: Use fifo8_reset() in fifo8_create() Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 23/28] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_bufptr() Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 24/28] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr() Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 25/28] util/fifo8: Expose fifo8_pop_buf() Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 26/28] util/fifo8: Introduce fifo8_drop() Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 27/28] MAINTAINERS: Cover guest-agent in QAPI schema Philippe Mathieu-Daudé
2024-07-23 20:38 ` [PULL 28/28] MAINTAINERS: Add myself as a reviewer of machine core Philippe Mathieu-Daudé
2024-07-24 8:14 ` [PULL 00/28] Misc HW+ patches for 2024-07-23 Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).