aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2021-12-17 13:15:38 -0800
committerRichard Henderson <richard.henderson@linaro.org>2021-12-17 13:15:38 -0800
commit90978e15bc9a23c208b25bf7ea697a5d0925562b (patch)
tree6bdc96b7eefd208ef671395e898f6e2aa36f745e
parent93dc314c9225e103487ae22b62da1ac59ac86325 (diff)
parentce2ff9cccf0c5f123f9d1e3d5e4fc07d1c2c159d (diff)
downloadqemu-90978e15bc9a23c208b25bf7ea697a5d0925562b.zip
qemu-90978e15bc9a23c208b25bf7ea697a5d0925562b.tar.gz
qemu-90978e15bc9a23c208b25bf7ea697a5d0925562b.tar.bz2
Merge tag 'trivial-branch-for-7.0-pull-request' of https://gitlab.com/laurent_vivier/qemu into staging
Trivial patches pull request 20211217 # gpg: Signature made Fri 17 Dec 2021 12:09:51 PM PST # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "laurent@vivier.eu" # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [unknown] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [unknown] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * tag 'trivial-branch-for-7.0-pull-request' of https://gitlab.com/laurent_vivier/qemu: checkpatch: Do not allow deprecated g_memdup() tests/qtest: Replace g_memdup() by g_memdup2() glib-compat: Introduce g_memdup2() wrapper docs/block-replication.txt: Fix replication top-id command demo hw/virtio/vhost: Fix typo in comment. hw/avr: Realize AVRCPU qdev object using qdev_realize() qemu-keymap: Add license in generated files target/i386/kvm: Replace use of __u32 type configure: Symlink binaries using .exe suffix with MinGW Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rwxr-xr-xconfigure2
-rw-r--r--docs/block-replication.txt2
-rw-r--r--hw/avr/atmega.c2
-rw-r--r--hw/virtio/vhost.c2
-rw-r--r--include/glib-compat.h37
-rw-r--r--qemu-keymap.c1
-rwxr-xr-xscripts/checkpatch.pl5
-rw-r--r--target/i386/kvm/kvm.c2
-rw-r--r--tests/qtest/libqos/ahci.c6
-rw-r--r--tests/qtest/libqos/qgraph.c2
10 files changed, 52 insertions, 9 deletions
diff --git a/configure b/configure
index 5fae198..28e1cf6 100755
--- a/configure
+++ b/configure
@@ -3754,7 +3754,7 @@ fi
for target in $target_list; do
target_dir="$target"
- target_name=$(echo $target | cut -d '-' -f 1)
+ target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
mkdir -p $target_dir
case $target in
*-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
diff --git a/docs/block-replication.txt b/docs/block-replication.txt
index b0f2376..e1b28a6 100644
--- a/docs/block-replication.txt
+++ b/docs/block-replication.txt
@@ -179,7 +179,7 @@ Primary:
Secondary:
-drive if=none,driver=raw,file.filename=1.raw,id=colo1 \
- -drive if=none,id=childs1,driver=replication,mode=secondary,top-id=childs1
+ -drive if=none,id=childs1,driver=replication,mode=secondary,top-id=top-disk1
file.file.filename=active_disk.qcow2,\
file.driver=qcow2,\
file.backing.file.filename=hidden_disk.qcow2,\
diff --git a/hw/avr/atmega.c b/hw/avr/atmega.c
index 0608e2d..a34803e 100644
--- a/hw/avr/atmega.c
+++ b/hw/avr/atmega.c
@@ -233,7 +233,7 @@ static void atmega_realize(DeviceState *dev, Error **errp)
/* CPU */
object_initialize_child(OBJECT(dev), "cpu", &s->cpu, mc->cpu_type);
- object_property_set_bool(OBJECT(&s->cpu), "realized", true, &error_abort);
+ qdev_realize(DEVICE(&s->cpu), NULL, &error_abort);
cpudev = DEVICE(&s->cpu);
/* SRAM */
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 437347a..20913cf 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -313,7 +313,7 @@ static int vhost_dev_has_iommu(struct vhost_dev *dev)
* For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
* incremental memory mapping API via IOTLB API. For platform that
* does not have IOMMU, there's no need to enable this feature
- * which may cause unnecessary IOTLB miss/update trnasactions.
+ * which may cause unnecessary IOTLB miss/update transactions.
*/
return virtio_bus_device_iommu_enabled(vdev) &&
virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
diff --git a/include/glib-compat.h b/include/glib-compat.h
index 9e95c88..8d01a8c 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -68,6 +68,43 @@
* without generating warnings.
*/
+/*
+ * g_memdup2_qemu:
+ * @mem: (nullable): the memory to copy.
+ * @byte_size: the number of bytes to copy.
+ *
+ * Allocates @byte_size bytes of memory, and copies @byte_size bytes into it
+ * from @mem. If @mem is %NULL it returns %NULL.
+ *
+ * This replaces g_memdup(), which was prone to integer overflows when
+ * converting the argument from a #gsize to a #guint.
+ *
+ * This static inline version is a backport of the new public API from
+ * GLib 2.68, kept internal to GLib for backport to older stable releases.
+ * See https://gitlab.gnome.org/GNOME/glib/-/issues/2319.
+ *
+ * Returns: (nullable): a pointer to the newly-allocated copy of the memory,
+ * or %NULL if @mem is %NULL.
+ */
+static inline gpointer g_memdup2_qemu(gconstpointer mem, gsize byte_size)
+{
+#if GLIB_CHECK_VERSION(2, 68, 0)
+ return g_memdup2(mem, byte_size);
+#else
+ gpointer new_mem;
+
+ if (mem && byte_size != 0) {
+ new_mem = g_malloc(byte_size);
+ memcpy(new_mem, mem, byte_size);
+ } else {
+ new_mem = NULL;
+ }
+
+ return new_mem;
+#endif
+}
+#define g_memdup2(m, s) g_memdup2_qemu(m, s)
+
#if defined(G_OS_UNIX)
/*
* Note: The fallback implementation is not MT-safe, and it returns a copy of
diff --git a/qemu-keymap.c b/qemu-keymap.c
index 536e8f2..4095b65 100644
--- a/qemu-keymap.c
+++ b/qemu-keymap.c
@@ -187,6 +187,7 @@ int main(int argc, char *argv[])
}
fprintf(outfile,
+ "# SPDX-License-Identifier: GPL-2.0-or-later\n"
"#\n"
"# generated by qemu-keymap\n"
"# model : %s\n"
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index cb8eff2..5caa739 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2850,6 +2850,11 @@ sub process {
WARN("consider using g_path_get_$1() in preference to g_strdup($1())\n" . $herecurr);
}
+# enforce g_memdup2() over g_memdup()
+ if ($line =~ /\bg_memdup\s*\(/) {
+ ERROR("use g_memdup2() instead of unsafe g_memdup()\n" . $herecurr);
+ }
+
# recommend qemu_strto* over strto* for numeric conversions
if ($line =~ /\b(strto[^kd].*?)\s*\(/) {
ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr);
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 5a698bd..13f8e30 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1406,7 +1406,7 @@ static int hyperv_fill_cpuids(CPUState *cs,
c->edx = cpu->hyperv_limits[2];
if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) {
- __u32 function;
+ uint32_t function;
/* Create zeroed 0x40000006..0x40000009 leaves */
for (function = HV_CPUID_IMPLEMENT_LIMITS + 1;
diff --git a/tests/qtest/libqos/ahci.c b/tests/qtest/libqos/ahci.c
index fba3e7a..eaa2096 100644
--- a/tests/qtest/libqos/ahci.c
+++ b/tests/qtest/libqos/ahci.c
@@ -639,8 +639,8 @@ void ahci_exec(AHCIQState *ahci, uint8_t port,
AHCIOpts *opts;
uint64_t buffer_in;
- opts = g_memdup((opts_in == NULL ? &default_opts : opts_in),
- sizeof(AHCIOpts));
+ opts = g_memdup2((opts_in == NULL ? &default_opts : opts_in),
+ sizeof(AHCIOpts));
buffer_in = opts->buffer;
@@ -860,7 +860,7 @@ AHCICommand *ahci_command_create(uint8_t command_name)
g_assert(!props->ncq || props->lba48);
/* Defaults and book-keeping */
- cmd->props = g_memdup(props, sizeof(AHCICommandProp));
+ cmd->props = g_memdup2(props, sizeof(AHCICommandProp));
cmd->name = command_name;
cmd->xbytes = props->size;
cmd->prd_size = 4096;
diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c
index d1dc491..109ff04 100644
--- a/tests/qtest/libqos/qgraph.c
+++ b/tests/qtest/libqos/qgraph.c
@@ -93,7 +93,7 @@ static void add_edge(const char *source, const char *dest,
edge->type = type;
edge->dest = g_strdup(dest);
edge->edge_name = g_strdup(opts->edge_name ?: dest);
- edge->arg = g_memdup(opts->arg, opts->size_arg);
+ edge->arg = g_memdup2(opts->arg, opts->size_arg);
edge->before_cmd_line =
opts->before_cmd_line ? g_strconcat(" ", opts->before_cmd_line, NULL) : NULL;