linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: "Raslan, KarimAllah" <karahmed@amazon.de>
Cc: "Sironi, Filippo" <sironi@amazon.de>,
	"Graf, Alexander" <graf@amazon.com>,
	"boris.ostrovsky@oracle.com" <boris.ostrovsky@oracle.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"konrad.wilk@oracle.com" <konrad.wilk@oracle.com>,
	"borntraeger@de.ibm.com" <borntraeger@de.ibm.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Christoffer Dall <Christoffer.Dall@arm.com>
Subject: Re: [PATCH v2 1/2] KVM: Start populating /sys/hypervisor with KVM entries
Date: Fri, 31 May 2019 10:38:40 +0100	[thread overview]
Message-ID: <86muj36k0v.wl-marc.zyngier@arm.com> (raw)
In-Reply-To: <1559293922.14762.2.camel@amazon.de>

On Fri, 31 May 2019 10:12:03 +0100,
"Raslan, KarimAllah" <karahmed@amazon.de> wrote:
> 
> On Fri, 2019-05-31 at 11:06 +0200, Alexander Graf wrote:
> > On 17.05.19 17:41, Sironi, Filippo wrote:
> > > 
> > > > 
> > > > On 16. May 2019, at 15:50, Graf, Alexander <graf@amazon.com> wrote:
> > > > 
> > > > On 14.05.19 08:16, Filippo Sironi wrote:
> > > > > 
> > > > > Start populating /sys/hypervisor with KVM entries when we're running on
> > > > > KVM. This is to replicate functionality that's available when we're
> > > > > running on Xen.
> > > > > 
> > > > > Start with /sys/hypervisor/uuid, which users prefer over
> > > > > /sys/devices/virtual/dmi/id/product_uuid as a way to recognize a virtual
> > > > > machine, since it's also available when running on Xen HVM and on Xen PV
> > > > > and, on top of that doesn't require root privileges by default.
> > > > > Let's create arch-specific hooks so that different architectures can
> > > > > provide different implementations.
> > > > > 
> > > > > Signed-off-by: Filippo Sironi <sironi@amazon.de>
> > > > I think this needs something akin to
> > > > 
> > > >   https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-hypervisor-xen
> > > > 
> > > > to document which files are available.
> > > > 
> > > > > 
> > > > > ---
> > > > > v2:
> > > > > * move the retrieval of the VM UUID out of uuid_show and into
> > > > >   kvm_para_get_uuid, which is a weak function that can be overwritten
> > > > > 
> > > > > drivers/Kconfig              |  2 ++
> > > > > drivers/Makefile             |  2 ++
> > > > > drivers/kvm/Kconfig          | 14 ++++++++++++++
> > > > > drivers/kvm/Makefile         |  1 +
> > > > > drivers/kvm/sys-hypervisor.c | 30 ++++++++++++++++++++++++++++++
> > > > > 5 files changed, 49 insertions(+)
> > > > > create mode 100644 drivers/kvm/Kconfig
> > > > > create mode 100644 drivers/kvm/Makefile
> > > > > create mode 100644 drivers/kvm/sys-hypervisor.c
> > > > > 
> > > > [...]
> > > > 
> > > > > 
> > > > > +
> > > > > +__weak const char *kvm_para_get_uuid(void)
> > > > > +{
> > > > > +	return NULL;
> > > > > +}
> > > > > +
> > > > > +static ssize_t uuid_show(struct kobject *obj,
> > > > > +			 struct kobj_attribute *attr,
> > > > > +			 char *buf)
> > > > > +{
> > > > > +	const char *uuid = kvm_para_get_uuid();
> > > > > +	return sprintf(buf, "%s\n", uuid);
> > > > The usual return value for the Xen /sys/hypervisor interface is
> > > > "<denied>". Wouldn't it make sense to follow that pattern for the KVM
> > > > one too? Currently, if we can not determine the UUID this will just
> > > > return (null).
> > > > 
> > > > Otherwise, looks good to me. Are you aware of any other files we should
> > > > provide? Also, is there any reason not to implement ARM as well while at it?
> > > > 
> > > > Alex
> > > This originated from a customer request that was using /sys/hypervisor/uuid.
> > > My guess is that we would want to expose "type" and "version" moving
> > > forward and that's when we hypervisor hooks will be useful on top
> > > of arch hooks.
> > > 
> > > On a different note, any idea how to check whether the OS is running
> > > virtualized on KVM on ARM and ARM64?  kvm_para_available() isn't an
> > 
> > 
> > Yeah, ARM doesn't have any KVM PV FWIW. I also can't find any explicit 
> > hint passed into guests that we are indeed running in KVM. The closest 
> > thing I can see is the SMBIOS product identifier in QEMU which gets 
> > patched to "KVM Virtual Machine". Maybe we'll have to do with that for 
> > the sake of backwards compatibility ...
> 
> How about "psci_ops.conduit" (PSCI_CONDUIT_HVC vs PSCI_CONDUIT_SMC)?

[changing Christoffer address for one that actually]

That's not enough. HVC only tells you about the fact that you are
running under a hypervisor without telling you which one, and doesn't
cater for nested virt. It doesn't tell you anything about a hypervisor
that doesn't use HVC at all (it could only advertise SMC, for example).

If you want to identify the hypervisor, don't guess. Use the SMCCC
discovery mechanism, and make KVM identify itself as the hypervisor. I
have some code for that stashed at [1] as part of an unrelated series,
which I may post at some point.

Thanks,

	M.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/pvcy

-- 
Jazz is not dead, it just smell funny.

  parent reply	other threads:[~2019-05-31  9:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09  9:54 [PATCH] KVM: Start populating /sys/hypervisor with KVM entries Filippo Sironi
2018-10-09 10:41 ` Christian Borntraeger
2018-10-09 16:21   ` Boris Ostrovsky
2018-10-09 17:50     ` Cornelia Huck
2018-10-09 15:00 ` Konrad Rzeszutek Wilk
2018-10-10  5:19 ` kbuild test robot
2019-05-14 15:16 ` Filippo Sironi
2019-05-14 15:16   ` [PATCH v2 1/2] " Filippo Sironi
2019-05-14 15:26     ` Christian Borntraeger
2019-05-14 16:09       ` Sironi, Filippo
2019-05-14 16:31         ` Christian Borntraeger
2019-05-14 22:08         ` Sironi, Filippo
2019-05-16 13:50     ` Alexander Graf
2019-05-16 14:02       ` [Xen-devel] " Andrew Cooper
2019-05-16 14:08         ` Alexander Graf
2019-05-16 15:02           ` Boris Ostrovsky
2019-05-16 15:14             ` Sironi, Filippo
2019-05-17 15:41       ` Sironi, Filippo
2019-05-31  9:06         ` Alexander Graf
2019-05-31  9:12           ` Raslan, KarimAllah
2019-05-31  9:26             ` Alexander Graf
2019-05-31  9:38             ` Marc Zyngier [this message]
2019-05-14 15:16   ` [PATCH v2 2/2] KVM: x86: Implement the arch-specific hook to report the VM UUID Filippo Sironi
2019-05-16 13:56     ` Alexander Graf
2019-05-16 15:25       ` Sironi, Filippo
2019-05-16 15:33         ` Alexander Graf
2019-05-16 16:40           ` Boris Ostrovsky
2019-05-16 17:41             ` Sironi, Filippo
2019-05-16 17:49               ` Alexander Graf

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=86muj36k0v.wl-marc.zyngier@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=Christoffer.Dall@arm.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=graf@amazon.com \
    --cc=karahmed@amazon.de \
    --cc=konrad.wilk@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sironi@amazon.de \
    --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 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).