Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp360674ybi; Fri, 31 May 2019 02:40:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyPbhkGDM94hN7m2ZrIlPyIWKvJy2YVxO/Ao3V6et+vOnx+olXGotVW3k36gNGDN8eYXxe X-Received: by 2002:a62:160b:: with SMTP id 11mr8498320pfw.30.1559295627519; Fri, 31 May 2019 02:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559295627; cv=none; d=google.com; s=arc-20160816; b=X6Uvqd2DwFRTcyElFLIyy9JUjWklk1V8uGKfQxYSeTjNC4BO3Mi+xQrY+GYDe31BzM DsC+OuDwmp4w7L2H+VxQIOQswjMTyk3pQng3JLXuvzX+/RpmVuNIofP6BFQC44WnRhLv kfX9t1GorFtyrfyV6kBpPWK4i65KzHD02m3vjTVCJb4q5zrUuWYfLxo9iCWle9h2ihYM qzI2x0tLmnQvF4dlnO+4XKf6uAuDstFPrSThIXJMChww0FLeKE5kPCfaGzGWZFJJKnhe 9Lp0VZIaG3WfCsPu75JPacXMU7pGSfFQbX0ijO4xW7UCJjWtYjMbyTUPMPD7XonwAeR4 1dYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:user-agent :references:in-reply-to:subject:cc:to:from:message-id:date; bh=uOvD1f4RxSv7a7XQGbMw+2MOR9UlsnfjNuDvBoKwXnQ=; b=RPbCiUYFYnGS2JLuLT3HOuOQDxlF1kKoB3cRrvMI5hlIrrA24RWxy7m+hrdnaHPF1k DZXoFYNZ13uPycaPkcY2l6nlO65Cl5PtzOqzfY1PyESH2NQxkfZJtwUlkfTWrEchZ9UE csn10N4qWWq1AiQJAhKAzxDbaFx2jEcoAAq1Xj5wHzQqs1qF+pz0Ly3OFYClfDKg5lzH RphZ+iRgeSvL5eh/DYI7cczd7SeNPBsbNWW2BPzd1+Wd7hS/ZcZb5UCK6kRBsLJ5uPE1 vo8YnckJLCL9AfbPzrTFNQKaX6vYDGiF2qt+JBqa8B0WfUiTydXu4b3MSV2GA0aAm25S tu4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si3803277pje.9.2019.05.31.02.40.10; Fri, 31 May 2019 02:40:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726693AbfEaJiq (ORCPT + 99 others); Fri, 31 May 2019 05:38:46 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:48932 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbfEaJiq (ORCPT ); Fri, 31 May 2019 05:38:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9C554341; Fri, 31 May 2019 02:38:45 -0700 (PDT) Received: from big-swifty.misterjones.org (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E33F13F59C; Fri, 31 May 2019 02:38:42 -0700 (PDT) Date: Fri, 31 May 2019 10:38:40 +0100 Message-ID: <86muj36k0v.wl-marc.zyngier@arm.com> From: Marc Zyngier To: "Raslan, KarimAllah" Cc: "Sironi, Filippo" , "Graf, Alexander" , "boris.ostrovsky@oracle.com" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "cohuck@redhat.com" , "konrad.wilk@oracle.com" , "borntraeger@de.ibm.com" , "xen-devel@lists.xenproject.org" , Christoffer Dall Subject: Re: [PATCH v2 1/2] KVM: Start populating /sys/hypervisor with KVM entries In-Reply-To: <1559293922.14762.2.camel@amazon.de> References: <1539078879-4372-1-git-send-email-sironi@amazon.de> <1557847002-23519-1-git-send-email-sironi@amazon.de> <1557847002-23519-2-git-send-email-sironi@amazon.de> <3D2C4EE3-1C2E-4032-9964-31A066E542AA@amazon.de> <6b3dadf9-6240-6440-b784-50bec605bf2c@amazon.com> <1559293922.14762.2.camel@amazon.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/26 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 31 May 2019 10:12:03 +0100, "Raslan, KarimAllah" 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 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 > > > > 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 > > > > "". 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.