[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [QEMU][PATCH v2 10/11] hw/arm: introduce xenpv machine
- To: Alex Bennée <alex.bennee@xxxxxxxxxx>
- From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
- Date: Fri, 2 Dec 2022 14:13:20 -0800
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+hdoaK1Y4WhR0W6eKq0T/vXT5F/VaD3TZTJPfCw5HRY=; b=CMHr404NjH8c11JNxTs/cqWrFwtNYev1uoBGK7vh4SxPv15D7CFs2rq3IJ/Nyjpv6dqNJLYeVjYkDxySOFGLHwyEeLSkKFejKM2fSCyzHWjmdfbJpDk7oPABt2S28ikv0lH0S3MwCcIOb3YU0vaDBAdyC8OqUL8cD59sJNMvGwiCNy3Ut7FlEgvx/1rB9ZwsDRlG46FXHZ2fJPogDf5UqUqLSbLPR+DSD+uP9fF3aAtibg5+mQWxflHsaKfE+Th9CoVa0Vgk7t4mcpm9FIzOqJ4894LICxHZ65+4FI0m5UjbBW0xrHzs/gF5NYcDb2zgFK/AzcZ67T/+WkdcfyWQNQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HWce6T/ck+e1xx/HnE+P2C52Kcl1NVe1Be5aD4edGk6/GbU+CZkF1rg7coGpabe6ESnEIYEQHKeeVEJs1iaQbrTJSo76b7BxgBwh2MvQ+3JyD8Qo0yEIW3CS7pTu3vOfnxz44tpSTxWfndZWv3w90W05Bcd0oCZnzxiEJEOl2a5JjlSFdgQI05CTzUKkdMLqxvoQVnBI9CfoVIB/nvVQ78mUQ28UCbTbrRZKr0l9N19oCNzuOlMHaIpbJezP58eM6s84eBi5R3fXHdRM7wr0Jjw8MX9WeQtiwfNmo1fdMt4QoKLfCA8n9vcRCqFnDpwx3QWlzFAcs7V/hkXTQ+RAoA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
- Cc: qemu-dev@xxxxxxxxxx, stefano.stabellini@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, Peter Maydell <peter.maydell@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "open list:ARM TCG CPUs" <qemu-arm@xxxxxxxxxx>, "open list:All patches CC here" <qemu-devel@xxxxxxxxxx>
- Delivery-date: Fri, 02 Dec 2022 22:13:40 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Hi Alex,
On 12/2/22 6:52 AM, Alex Bennée wrote:
Vikram Garhwal <vikram.garhwal@xxxxxxx> writes:
Add a new machine xenpv which creates a IOREQ server to register/connect with
Xen Hypervisor.
Optional: When CONFIG_TPM is enabled, it also creates a tpm-tis-device, adds a
TPM emulator and connects to swtpm running on host machine via chardev socket
and support TPM functionalities for a guest domain.
Extra command line for aarch64 xenpv QEMU to connect to swtpm:
-chardev socket,id=chrtpm,path=/tmp/myvtpm2/swtpm-sock \
-tpmdev emulator,id=tpm0,chardev=chrtpm \
swtpm implements a TPM software emulator(TPM 1.2 & TPM 2) built on libtpms and
provides access to TPM functionality over socket, chardev and CUSE interface.
Github repo: https://github.com/stefanberger/swtpm
Example for starting swtpm on host machine:
mkdir /tmp/vtpm2
swtpm socket --tpmstate dir=/tmp/vtpm2 \
--ctrl type=unixio,path=/tmp/vtpm2/swtpm-sock &
<snip>
+
+static void xen_enable_tpm(void)
+{
+/* qemu_find_tpm_be is only available when CONFIG_TPM is enabled. */
+#ifdef CONFIG_TPM
+ Error *errp = NULL;
+ DeviceState *dev;
+ SysBusDevice *busdev;
+
+ TPMBackend *be = qemu_find_tpm_be("tpm0");
+ if (be == NULL) {
+ DPRINTF("Couldn't fine the backend for tpm0\n");
+ return;
+ }
+ dev = qdev_new(TYPE_TPM_TIS_SYSBUS);
+ object_property_set_link(OBJECT(dev), "tpmdev", OBJECT(be), &errp);
+ object_property_set_str(OBJECT(dev), "tpmdev", be->id, &errp);
+ busdev = SYS_BUS_DEVICE(dev);
+ sysbus_realize_and_unref(busdev, &error_fatal);
+ sysbus_mmio_map(busdev, 0, GUEST_TPM_BASE);
Still fails on my aarch64 Debian machine:
FAILED: libqemu-aarch64-softmmu.fa.p/hw_arm_xen_arm.c.o
cc -Ilibqemu-aarch64-softmmu.fa.p -I. -I../.. -Itarget/arm -I../../target/arm -Iqapi -Itrace
-Iui -Iui/shader -I/usr/include/pixman-1 -I/usr/local/include -I/usr/include/capstone
-I/usr/include/spice-server -I/usr/include/spice-1 -I/usr/include/glib-2.0
-I/usr/lib/aarch64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror
-std=gnu11 -O2 -g -isystem /home/alex/lsrc/qemu.git/linux-headers -isystem linux-headers -iquote .
-iquote /home/alex/lsrc/qemu.git -iquote /home/alex/lsrc/qemu.git/include -iquote
/home/alex/lsrc/qemu.git/tcg/aarch64 -pthread -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef
-Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv
-Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k
-Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels
-Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wno-missing-include-dirs -Wno-shift-negative-value
-Wno-psabi -fstack-protector-strong -fPIE -isystem../../linux-headers -isystemlinux-headers
-DNEED_CPU_H '-DCONFIG_TARGET="aarch64-softmmu-config-target.h"'
'-DCONFIG_DEVICES="aarch64-softmmu-config-devices.h"' -MD -MQ
libqemu-aarch64-softmmu.fa.p/hw_arm_xen_arm.c.o -MF
libqemu-aarch64-softmmu.fa.p/hw_arm_xen_arm.c.o.d -o
libqemu-aarch64-softmmu.fa.p/hw_arm_xen_arm.c.o -c ../../hw/arm/xen_arm.c
../../hw/arm/xen_arm.c: In function ‘xen_enable_tpm’:
../../hw/arm/xen_arm.c:126:32: error: ‘GUEST_TPM_BASE’ undeclared (first use in this
function); did you mean ‘GUEST_RAM_BASE’?
126 | sysbus_mmio_map(busdev, 0, GUEST_TPM_BASE);
| ^~~~~~~~~~~~~~
| GUEST_RAM_BASE
../../hw/arm/xen_arm.c:126:32: note: each undeclared identifier is reported
only once for each function it appears in
[2082/3246] Compiling C object
libqemu-aarch64-softmmu.fa.p/hw_xen_xen-mapcache.c.o
[2083/3246] Compiling C object
libqemu-aarch64-softmmu.fa.p/hw_xen_xen-hvm-common.c.o
ninja: build stopped: subcommand failed.
make: *** [Makefile:165: run-ninja] Error 1
Do you know what Xen version your build env has?
Another way to fix this(as Julien suggested) is by setting this
GUEST_TPM_BASE value via a property or something and user can set it via
command line.
@sstabellini@xxxxxxxxxx, do you think of any other fix?
+
+ DPRINTF("Connected tpmdev at address 0x%lx\n", GUEST_TPM_BASE);
+#endif
+}
If there is a minimum required version for TPM then it needs to be
picked up by configure.
|