summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Hajnoczi2022-10-04 20:04:18 +0200
committerStefan Hajnoczi2022-10-04 20:04:18 +0200
commitfafd35a6dab8e70a7c395aaa8e1273267cf9f3c8 (patch)
tree145bb14b5c1a3bcad71c4aafd836d8b8513a814f
parentMerge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (diff)
parentdocs: Update TPM documentation for usage of a TPM 2 (diff)
downloadqemu-fafd35a6dab8e70a7c395aaa8e1273267cf9f3c8.tar.gz
qemu-fafd35a6dab8e70a7c395aaa8e1273267cf9f3c8.tar.xz
qemu-fafd35a6dab8e70a7c395aaa8e1273267cf9f3c8.zip
Merge tag 'trivial-branch-for-7.2-pull-request' of https://gitlab.com/laurent_vivier/qemu into staging
Pull request trivial patches branch 20220930-v2 # -----BEGIN PGP SIGNATURE----- # # iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmM7XoISHGxhdXJlbnRA # dml2aWVyLmV1AAoJEPMMOL0/L748D/0QAKbYtTWjhFPeapjZVoTv13YrTvczWrcF # omL6IZivVq0t7hun4iem0DwmvXJELMGexEOTvEJOzM19IIlvvwvOsI8xnxpcMnEY # 6GKVbs53Ba0bg2yh7Dll2W9jkou9eX27DwUHMVF8KX7qqsbU+WyD/vdGZitgGt+T # 8yna7kzVvNVsdB3+DbIatI5RzzHeu4OqeuH/WCtAyzCaLB64UYTcHprskxIp4+wp # dR+EUSoDEr9Qx4PC+uVEsTFK1zZjyAYNoNIkh6fhlkRvDJ1uA75m3EJ57P8xPPqe # VbVkPMKi0d4c52m6XvLsQhyYryLx/qLLUAkJWVpY66aHcapYbZAEAfZmNGTQLrOJ # qIOJzIkOdU6l3pRgXVdVCgkHRc2HETwET2LyVbNkUz/vBlW2wOZQbZFbezComael # bQ/gNBYqP+eOGnZzeWbKBGHr/9QDBClNufidIMC+sOiUw0iSifzjkFwvH7IElx6K # EQCOSV6pOhKVlinTpmBbk1XD3xDkQ7ZidiLT9g+P1c8dExrXBhWOnfUHueISb8+s # KKMozuxQ/6/3c/DP5hwI9cKPEWEbqJfq1kMuxIvEivKGwUIqX2yq4VJ+hSlYJ+CW # nGjXZldtf4KwH+cTsxyPmdZRR5Q7+ODr5Xo7GNvEKBuDsHs7uUl1c3vvOykQgje9 # +dyJR6TfbQWn # =aK29 # -----END PGP SIGNATURE----- # gpg: Signature made Mon 03 Oct 2022 18:13:22 EDT # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "laurent@vivier.eu" # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [full] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full] # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * tag 'trivial-branch-for-7.2-pull-request' of https://gitlab.com/laurent_vivier/qemu: docs: Update TPM documentation for usage of a TPM 2 Use g_new() & friends where that makes obvious sense Drop superfluous conditionals around g_free() block/qcow2-bitmap: Add missing cast to silent GCC error checkpatch: ignore target/hexagon/imported/* files mem/cxl_type3: fix GPF DVSEC .gitignore: add .cache/ to .gitignore hw/virtio/vhost-shadow-virtqueue: Silence GCC error "maybe-uninitialized" Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r--.gitignore1
-rw-r--r--docs/specs/tpm.rst44
-rw-r--r--hw/mem/cxl_type3.c2
-rw-r--r--hw/remote/iommu.c2
-rw-r--r--hw/virtio/vhost-shadow-virtqueue.c2
-rw-r--r--hw/virtio/virtio-crypto.c2
-rw-r--r--migration/dirtyrate.c4
-rw-r--r--replay/replay.c6
-rwxr-xr-xscripts/checkpatch.pl1
-rw-r--r--softmmu/dirtylimit.c4
-rw-r--r--target/i386/kvm/kvm.c12
-rw-r--r--target/i386/whpx/whpx-all.c14
12 files changed, 46 insertions, 48 deletions
diff --git a/.gitignore b/.gitignore
index 9726a778b3..8aab671265 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
/GNUmakefile
/build/
+/.cache/
*.pyc
.sdk
.stgit-*
diff --git a/docs/specs/tpm.rst b/docs/specs/tpm.rst
index 3be190343a..535912a92b 100644
--- a/docs/specs/tpm.rst
+++ b/docs/specs/tpm.rst
@@ -250,24 +250,25 @@ hardware TPM ``/dev/tpm0``:
The following commands should result in similar output inside the VM
with a Linux kernel that either has the TPM TIS driver built-in or
-available as a module:
+available as a module (assuming a TPM 2 is passed through):
.. code-block:: console
# dmesg | grep -i tpm
- [ 0.711310] tpm_tis 00:06: 1.2 TPM (device=id 0x1, rev-id 1)
-
- # dmesg | grep TCPA
- [ 0.000000] ACPI: TCPA 0x0000000003FFD191C 000032 (v02 BOCHS \
- BXPCTCPA 0000001 BXPC 00000001)
+ [ 0.012560] ACPI: TPM2 0x000000000BFFD1900 00004C (v04 BOCHS \
+ BXPC 0000001 BXPC 00000001)
# ls -l /dev/tpm*
- crw-------. 1 root root 10, 224 Jul 11 10:11 /dev/tpm0
+ crw-rw----. 1 tss root 10, 224 Sep 6 12:36 /dev/tpm0
+ crw-rw----. 1 tss rss 253, 65536 Sep 6 12:36 /dev/tpmrm0
- # find /sys/devices/ | grep pcrs$ | xargs cat
- PCR-00: 35 4E 3B CE 23 9F 38 59 ...
+ Starting with Linux 5.12 there are PCR entries for TPM 2 in sysfs:
+ # find /sys/devices/ -type f | grep pcr-sha
+ ...
+ /sys/devices/LNXSYSTEM:00/LNXSYBUS:00/MSFT0101:00/tpm/tpm0/pcr-sha256/1
+ ...
+ /sys/devices/LNXSYSTEM:00/LNXSYBUS:00/MSFT0101:00/tpm/tpm0/pcr-sha256/9
...
- PCR-23: 00 00 00 00 00 00 00 00 ...
The QEMU TPM emulator device
----------------------------
@@ -304,6 +305,7 @@ a socket interface. They do not need to be run as root.
mkdir /tmp/mytpm1
swtpm socket --tpmstate dir=/tmp/mytpm1 \
--ctrl type=unixio,path=/tmp/mytpm1/swtpm-sock \
+ --tpm2 \
--log level=20
Command line to start QEMU with the TPM emulator device communicating
@@ -365,19 +367,20 @@ available as a module:
.. code-block:: console
# dmesg | grep -i tpm
- [ 0.711310] tpm_tis 00:06: 1.2 TPM (device=id 0x1, rev-id 1)
-
- # dmesg | grep TCPA
- [ 0.000000] ACPI: TCPA 0x0000000003FFD191C 000032 (v02 BOCHS \
- BXPCTCPA 0000001 BXPC 00000001)
+ [ 0.012560] ACPI: TPM2 0x000000000BFFD1900 00004C (v04 BOCHS \
+ BXPC 0000001 BXPC 00000001)
# ls -l /dev/tpm*
- crw-------. 1 root root 10, 224 Jul 11 10:11 /dev/tpm0
+ crw-rw----. 1 tss root 10, 224 Sep 6 12:36 /dev/tpm0
+ crw-rw----. 1 tss rss 253, 65536 Sep 6 12:36 /dev/tpmrm0
- # find /sys/devices/ | grep pcrs$ | xargs cat
- PCR-00: 35 4E 3B CE 23 9F 38 59 ...
+ Starting with Linux 5.12 there are PCR entries for TPM 2 in sysfs:
+ # find /sys/devices/ -type f | grep pcr-sha
+ ...
+ /sys/devices/LNXSYSTEM:00/LNXSYBUS:00/MSFT0101:00/tpm/tpm0/pcr-sha256/1
+ ...
+ /sys/devices/LNXSYSTEM:00/LNXSYBUS:00/MSFT0101:00/tpm/tpm0/pcr-sha256/9
...
- PCR-23: 00 00 00 00 00 00 00 00 ...
Migration with the TPM emulator
===============================
@@ -398,7 +401,8 @@ In a 1st terminal start an instance of a swtpm using the following command:
mkdir /tmp/mytpm1
swtpm socket --tpmstate dir=/tmp/mytpm1 \
--ctrl type=unixio,path=/tmp/mytpm1/swtpm-sock \
- --log level=20 --tpm2
+ --tpm2 \
+ --log level=20
In a 2nd terminal start the VM:
diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
index 3bf2869573..ada2108fac 100644
--- a/hw/mem/cxl_type3.c
+++ b/hw/mem/cxl_type3.c
@@ -49,7 +49,7 @@ static void build_dvsecs(CXLType3Dev *ct3d)
.phase2_power = 0x33, /* 0x33 miliwatts */
};
cxl_component_create_dvsec(cxl_cstate, CXL2_TYPE3_DEVICE,
- GPF_DEVICE_DVSEC_LENGTH, GPF_PORT_DVSEC,
+ GPF_DEVICE_DVSEC_LENGTH, GPF_DEVICE_DVSEC,
GPF_DEVICE_DVSEC_REVID, dvsec);
}
diff --git a/hw/remote/iommu.c b/hw/remote/iommu.c
index fd723d91f3..1391dd712c 100644
--- a/hw/remote/iommu.c
+++ b/hw/remote/iommu.c
@@ -47,7 +47,7 @@ static AddressSpace *remote_iommu_find_add_as(PCIBus *pci_bus,
elem = g_hash_table_lookup(iommu->elem_by_devfn, INT2VOIDP(devfn));
if (!elem) {
- elem = g_malloc0(sizeof(RemoteIommuElem));
+ elem = g_new0(RemoteIommuElem, 1);
g_hash_table_insert(iommu->elem_by_devfn, INT2VOIDP(devfn), elem);
}
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
index e8e5bbc368..596d4434d2 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -289,7 +289,7 @@ static void vhost_handle_guest_kick(VhostShadowVirtqueue *svq)
virtio_queue_set_notification(svq->vq, false);
while (true) {
- g_autofree VirtQueueElement *elem;
+ g_autofree VirtQueueElement *elem = NULL;
int r;
if (svq->next_guest_avail_elem) {
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index c1243c3f93..df4bde210b 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -710,7 +710,7 @@ virtio_crypto_handle_asym_req(VirtIOCrypto *vcrypto,
uint8_t *src = NULL;
uint8_t *dst = NULL;
- asym_op_info = g_malloc0(sizeof(CryptoDevBackendAsymOpInfo));
+ asym_op_info = g_new0(CryptoDevBackendAsymOpInfo, 1);
src_len = ldl_le_p(&req->para.src_data_len);
dst_len = ldl_le_p(&req->para.dst_data_len);
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index 795fab5c37..d6f1e01a70 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -119,9 +119,9 @@ static DirtyPageRecord *vcpu_dirty_stat_alloc(VcpuStat *stat)
}
stat->nvcpu = nvcpu;
- stat->rates = g_malloc0(sizeof(DirtyRateVcpu) * nvcpu);
+ stat->rates = g_new0(DirtyRateVcpu, nvcpu);
- records = g_malloc0(sizeof(DirtyPageRecord) * nvcpu);
+ records = g_new0(DirtyPageRecord, nvcpu);
return records;
}
diff --git a/replay/replay.c b/replay/replay.c
index 4c396bb376..9a0dc1cf44 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -366,10 +366,8 @@ void replay_finish(void)
fclose(replay_file);
replay_file = NULL;
}
- if (replay_filename) {
- g_free(replay_filename);
- replay_filename = NULL;
- }
+ g_free(replay_filename);
+ replay_filename = NULL;
g_free(replay_snapshot);
replay_snapshot = NULL;
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d900d18048..e3e3b43076 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1667,6 +1667,7 @@ sub process {
# some scripts we imported from other projects.
next if ($realfile =~ /\.(s|S)$/);
next if ($realfile =~ /(checkpatch|get_maintainer)\.pl$/);
+ next if ($realfile =~ /^target\/hexagon\/imported\/*/);
if ($rawline =~ /^\+.*\t/) {
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c
index 8d98cb7f2c..12668555f2 100644
--- a/softmmu/dirtylimit.c
+++ b/softmmu/dirtylimit.c
@@ -154,7 +154,7 @@ void vcpu_dirty_rate_stat_initialize(void)
vcpu_dirty_rate_stat->stat.nvcpu = max_cpus;
vcpu_dirty_rate_stat->stat.rates =
- g_malloc0(sizeof(DirtyRateVcpu) * max_cpus);
+ g_new0(DirtyRateVcpu, max_cpus);
vcpu_dirty_rate_stat->running = false;
}
@@ -198,7 +198,7 @@ void dirtylimit_state_initialize(void)
dirtylimit_state = g_malloc0(sizeof(*dirtylimit_state));
dirtylimit_state->states =
- g_malloc0(sizeof(VcpuDirtyLimitState) * max_cpus);
+ g_new0(VcpuDirtyLimitState, max_cpus);
for (i = 0; i < max_cpus; i++) {
dirtylimit_state->states[i].cpu_index = i;
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 9eeee91c2f..f2a96492ce 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2176,15 +2176,11 @@ int kvm_arch_destroy_vcpu(CPUState *cs)
g_free(env->xsave_buf);
- if (cpu->kvm_msr_buf) {
- g_free(cpu->kvm_msr_buf);
- cpu->kvm_msr_buf = NULL;
- }
+ g_free(cpu->kvm_msr_buf);
+ cpu->kvm_msr_buf = NULL;
- if (env->nested_state) {
- g_free(env->nested_state);
- env->nested_state = NULL;
- }
+ g_free(env->nested_state);
+ env->nested_state = NULL;
qemu_del_vm_change_state_handler(cpu->vmsentry);
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index b22a3314b4..8e4969edeb 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -1225,14 +1225,12 @@ static void whpx_translate_cpu_breakpoints(
}
}
- if (breakpoints->breakpoints) {
- /*
- * Free the previous breakpoint list. This can be optimized by keeping
- * it as shadow buffer for the next computation instead of freeing
- * it immediately.
- */
- g_free(breakpoints->breakpoints);
- }
+ /*
+ * Free the previous breakpoint list. This can be optimized by keeping
+ * it as shadow buffer for the next computation instead of freeing
+ * it immediately.
+ */
+ g_free(breakpoints->breakpoints);
breakpoints->breakpoints = new_breakpoints;
}