All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr Tyshchenko <olekstysh@gmail.com>
To: Julien Grall <julien@xen.org>,
	Vikram Garhwal <vikram.garhwal@amd.com>,
	stefano.stabellini@amd.com
Cc: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	"Paul Durrant" <paul@xen.org>,
	"open list:ARM TCG CPUs" <qemu-arm@nongnu.org>,
	xen-devel@lists.xenproject.org,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH v1 10/12] hw/arm: introduce xenpv machine
Date: Fri, 28 Oct 2022 22:05:58 +0300	[thread overview]
Message-ID: <CAPD2p-nE30z9LosUkO6OdrPnuCaSwi_s2tsfbxgcOyu087tz-w@mail.gmail.com> (raw)
In-Reply-To: <7da20a2e-81e0-b3ad-c2d6-6012fa7edee2@xen.org>

[-- Attachment #1: Type: text/plain, Size: 4603 bytes --]

On Fri, Oct 28, 2022 at 8:58 PM Julien Grall <julien@xen.org> wrote:

> Hi,
>

Hello all.

[sorry for the possible format issues]



>
> On 27/10/2022 09:02, Alex Bennée wrote:
> >
> > Vikram Garhwal <vikram.garhwal@amd.com> writes:
> >
> > <snip>
> >> 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);
> >
> > I'm not sure what has gone wrong here but I'm getting:
> >
> >    ../../hw/arm/xen_arm.c: In function ‘xen_enable_tpm’:
> >    ../../hw/arm/xen_arm.c:120:32: error: ‘GUEST_TPM_BASE’ undeclared
> (first use in this function); did you mean ‘GUEST_RAM_BASE’?
> >      120 |     sysbus_mmio_map(busdev, 0, GUEST_TPM_BASE);
> >          |                                ^~~~~~~~~~~~~~
> >          |                                GUEST_RAM_BASE
> >    ../../hw/arm/xen_arm.c:120:32: note: each undeclared identifier is
> reported only once for each function it appears in
> >
> > In my cross build:
> >
> >    # Configured with: '../../configure' '--disable-docs'
> '--target-list=aarch64-softmmu' '--disable-kvm' '--enable-xen'
> '--disable-opengl' '--disable-libudev' '--enable-tpm'
> '--disable-xen-pci-passthrough' '--cross-prefix=aarch64-linux-gnu-'
> '--skip-meson'
> >
> > which makes me wonder if this is a configure failure or a confusion
> > about being able to have host swtpm implementations during emulation but
> > needing target tpm for Xen?
>
> I was also wondering where is that value come from. Note that the
> memory/IRQ layout exposed to the guest is not stable.
>
> Are we expecting the user to rebuild QEMU for every Xen versions (or
> possibly every guest if we ever allow dynamic layout in Xen)?
>


This doesn't sound ideal.

I am wondering what would be the correct way here assuming that we would
likely need to have more such information in place for supporting more
use-cases...
For instance, the PCI host bridge emulation in Qemu. Xen toolstack (another
software layer) generates device-tree for the guest, so creates PCI Host
bridge node by using reserved regions from Guest OS interface (arch-arm.h):
- GUEST_VPCI_MEM_ADDR (GUEST_VPCI_MEM_SIZE)
- GUEST_VPCI_ECAM_BASE (GUEST_VPCI_ECAM_SIZE)
- GUEST_VPCI_PREFETCH_MEM_ADDR (GUEST_VPCI_PREFETCH_MEM_SIZE)
https://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libs/light/libxl_arm.c;h=2a5e93c28403738779863aded31d2df3ba72f8c0;hb=HEAD#l833

Here in Qemu when creating a PCI Host bridge we would need to use exactly
the same reserved regions which toolstack writes in the corresponding
device-tree node. So how to tell Qemu about them?
1. Introduce new cmd line arguments?
2. Using Xenstore?
3. Anything else?

I am afraid this would be related to every device that we want to emulate
in Qemu and for which the toolstack needs to generate device-tree node by
using something defined with GUEST_*, unless I really missed something.



>
> Cheers,
>
> --
> Julien Grall
>
>

-- 
Regards,

Oleksandr Tyshchenko

[-- Attachment #2: Type: text/html, Size: 6869 bytes --]

  reply	other threads:[~2022-10-29  5:35 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-15  5:07 [PATCH v1 00/12] Introduce xenpv machine for arm architecture Vikram Garhwal
2022-10-15  5:07 ` [PATCH v1 01/12] hw/xen: Correct build config for xen_pt_stub Vikram Garhwal
2022-10-19 14:46   ` Paul Durrant
2022-10-26 19:01   ` Alex Bennée
2022-10-15  5:07 ` [PATCH v1 02/12] hw/i386/xen/: move xen-mapcache.c to hw/xen/ Vikram Garhwal
2022-10-19 14:53   ` Paul Durrant
2022-12-01 20:25     ` Garhwal, Vikram
2022-10-15  5:07 ` [PATCH v1 03/12] hw/i386/xen: rearrange xen_hvm_init_pc Vikram Garhwal
2022-10-19 14:59   ` Paul Durrant
2022-10-15  5:07 ` [PATCH v1 04/12] hw/i386/xen/xen-hvm: move x86-specific fields out of XenIOState Vikram Garhwal
2022-10-19 15:56   ` Paul Durrant
2022-10-19 16:00   ` Paul Durrant
2022-10-27  8:59   ` Alex Bennée
2022-10-15  5:07 ` [PATCH v1 05/12] hw/i386/xen/xen-hvm: create arch_handle_ioreq and arch_xen_set_memory Vikram Garhwal
2022-10-19 16:09   ` Paul Durrant
2022-10-27  9:02   ` Alex Bennée
2022-10-15  5:07 ` [PATCH v1 06/12] xen-hvm: move common functions to hw/xen/xen-hvm-common.c Vikram Garhwal
2022-10-16 18:07   ` Julien Grall
2022-10-19 16:16   ` Paul Durrant
2022-10-19 23:12     ` Garhwal, Vikram
2022-10-15  5:07 ` [PATCH v1 07/12] include/hw/xen/xen_common: return error from xen_create_ioreq_server Vikram Garhwal
2022-10-16 17:53   ` Julien Grall
2022-10-15  5:07 ` [PATCH v1 08/12] hw/xen/xen-hvm-common: skip ioreq creation on ioreq registration failure Vikram Garhwal
2022-10-27  8:46   ` Alex Bennée
2022-10-15  5:07 ` [PATCH v1 09/12] accel/xen/xen-all: export xenstore_record_dm_state Vikram Garhwal
2022-10-19 16:20   ` Paul Durrant
2022-10-27  9:14   ` Alex Bennée
2022-10-28 20:26     ` Oleksandr Tyshchenko
2022-10-29  5:36       ` Vikram Garhwal
2022-10-29  5:22     ` Garhwal, Vikram
2022-11-01 11:29       ` Alex Bennée
2022-10-15  5:07 ` [PATCH v1 10/12] hw/arm: introduce xenpv machine Vikram Garhwal
2022-10-16 17:47   ` Julien Grall
2022-10-18  1:26     ` Stefano Stabellini
2022-10-18  8:24       ` Julien Grall
2022-10-19  0:15         ` Stefano Stabellini
2022-10-19  9:49           ` Julien Grall
2022-10-27  8:37     ` Alex Bennée
2022-12-02  3:24     ` Garhwal, Vikram
2022-12-02  9:53       ` Julien Grall
2022-10-27  8:02   ` Alex Bennée
2022-10-28 17:57     ` Julien Grall
2022-10-28 19:05       ` Oleksandr Tyshchenko [this message]
2022-10-27  8:40   ` Alex Bennée
2022-10-15  5:07 ` [PATCH v1 11/12] meson.build: enable xenpv machine build for ARM Vikram Garhwal
2022-10-27  9:11   ` Alex Bennée
2022-10-15  5:07 ` [PATCH v1 12/12] meson.build: do not set have_xen_pci_passthrough for aarch64 targets Vikram Garhwal
2022-10-27  9:14   ` Alex Bennée
2022-10-27  8:26 ` [PATCH v1 00/12] Introduce xenpv machine for arm architecture Alex Bennée
2022-10-27  9:24 ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPD2p-nE30z9LosUkO6OdrPnuCaSwi_s2tsfbxgcOyu087tz-w@mail.gmail.com \
    --to=olekstysh@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=anthony.perard@citrix.com \
    --cc=julien@xen.org \
    --cc=paul@xen.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=stefano.stabellini@amd.com \
    --cc=vikram.garhwal@amd.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.