From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94571C77B73 for ; Mon, 5 Jun 2023 19:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:References:Cc:To:Subject:From: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QQzeQpbH607Sgfgc5PCI/JmmNN2n5imJp5eE5GFzBYI=; b=MMk6qPU54sgwCE jkykeUf/OYM0iVPl/gNxsPfcMIXySVj5tcO7BZ79VDwT9Y+YBstUNYlUcZrOn7zYOc50WA6d+/MCt nzXscI6mMDdKo4GoqbyaDF/oVbxd6sJIoknLvUGeFoUA90rvmPfqkcUjmkkd1nJSrWqpAtjJaIjXX JwGLjM3y70Ead5tXdWap8zGPMJ1baUr5/5rksGLmIRhc8vk6Tab0IdSHXnVZZGPXetowaXqpCNw1q fIbVGI8XQGOBIWQYqoaitquY537kxpvoNOD2N21ND7uiJ6MQopDLN7gr/BuvEv5HwRnRnPBm7iyTW 75dolBEetQOEWfKLJsrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6GB0-00Galg-39; Mon, 05 Jun 2023 19:47:38 +0000 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6GAx-00GakM-0W for linux-arm-kernel@lists.infradead.org; Mon, 05 Jun 2023 19:47:36 +0000 Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-33bdab7b4caso16302885ab.3 for ; Mon, 05 Jun 2023 12:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685994453; x=1688586453; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=bVGBckaA7wE6e493eXPHGBBhjES3HSRY4YnjclwMy0M=; b=oPb/liL2dnCPXJ+aq609ulXPSS7MhnMeZYIvpomIXCi48dvg0nv7n7rQYXjJb6T+Xk 8ndEoEDQmBHSm0HnUQvCXNUOm2m2wcZVn4wkTXl9SXWvgjZvOzXeeCrWX189Tw2uTT1L YWcjrSsdcxZGvi4g7OcJt+BxzAUYIADfTLi5zGgAq3Q/o63EEiOxJDgasXeT/ngZIy1V IBNMSsOtQlj/8pebFacrfCXYV1SBuOdGUiFPHr89bkumhNEdFGcdB74rscUo5hhnA4n3 zjjd4BvgCY1Xvfxyq01upslMZZu6E9LTRdFkLgUsTTMM1PrPlk45Jq+vgkZnBAEvMgtq sGmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685994453; x=1688586453; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bVGBckaA7wE6e493eXPHGBBhjES3HSRY4YnjclwMy0M=; b=UxjFT8BzqoLzeSyA1s9MbMqYRTTPdI/+t7zJw/z1p15vD0o7Wq/75m+OtnK2LzYZY/ h8WbNeCEYoa0BfTUP8pdBlWmR7ACEQlwYAoHSGuc3QBKs6W9tBLQ6kpX2Qt50Z8yhyW+ 23f9KDiFZDyYCuLHlTjP4QEmjH8jk9bDrOaxi5kedCc5Lq1dv2hLFL1bmox+5pKGR6Xi 5lrR4cJ65K1Q1f5xaobwGybwLgFei3AdbyOd25e+sBV7dWyUnID2Bu8hdV7kalwpq1A3 yHl92cIBD9jqmHvRsAKK817zqBjGRWnob3REdGapq9JLTCZBqPY/PNYTmjCWGEqYYLW0 OjFw== X-Gm-Message-State: AC+VfDxugWaDDxwCqxYcS0Qj2RlD2OCpXsrH4ke/vZwe3ck4rSuFNT8i wToC64OveW8TOthodfIdkD3TXQ== X-Google-Smtp-Source: ACHHUZ5S5FAwRue5DB46jNBpsQ3adpRdYQqVkzJ4peXKhPdRgVGnScJxm0uoXwr3sF+m3ANKF1Xmdg== X-Received: by 2002:a92:d847:0:b0:338:6ace:dd62 with SMTP id h7-20020a92d847000000b003386acedd62mr63176ilq.14.1685994453041; Mon, 05 Jun 2023 12:47:33 -0700 (PDT) Received: from [172.22.22.28] ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id g6-20020a0566380c4600b0041669a9fb62sm2278801jal.131.2023.06.05.12.47.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jun 2023 12:47:32 -0700 (PDT) Message-ID: <483e396b-9094-ed3a-e545-6c500e5d4ea2@linaro.org> Date: Mon, 5 Jun 2023 14:47:31 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 From: Alex Elder Subject: Re: [PATCH v13 03/24] virt: gunyah: Add hypercalls to identify Gunyah To: Elliot Berman , Srinivas Kandagatla , Catalin Marinas , Will Deacon , Prakruthi Deepak Heragu Cc: Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Dmitry Baryshkov , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Bagas Sanjaya , Andy Gross , Jassi Brar , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20230509204801.2824351-1-quic_eberman@quicinc.com> <20230509204801.2824351-4-quic_eberman@quicinc.com> Content-Language: en-US In-Reply-To: <20230509204801.2824351-4-quic_eberman@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230605_124735_196861_F91562D1 X-CRM114-Status: GOOD ( 25.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 5/9/23 3:47 PM, Elliot Berman wrote: > Add hypercalls to identify when Linux is running a virtual machine under > Gunyah. > > There are two calls to help identify Gunyah: > > 1. gh_hypercall_get_uid() returns a UID when running under a Gunyah > hypervisor. > 2. gh_hypercall_hyp_identify() returns build information and a set of > feature flags that are supported by Gunyah. > > Reviewed-by: Srinivas Kandagatla > Signed-off-by: Elliot Berman I have a suggestion below. But whether or not you choose to incorporate it: Reviewed-by: Alex Elder > --- > arch/arm64/Kbuild | 1 + > arch/arm64/gunyah/Makefile | 3 ++ > arch/arm64/gunyah/gunyah_hypercall.c | 56 ++++++++++++++++++++++++++++ > drivers/virt/Kconfig | 2 + > drivers/virt/gunyah/Kconfig | 13 +++++++ > include/linux/gunyah.h | 31 +++++++++++++++ > 6 files changed, 106 insertions(+) > create mode 100644 arch/arm64/gunyah/Makefile > create mode 100644 arch/arm64/gunyah/gunyah_hypercall.c > create mode 100644 drivers/virt/gunyah/Kconfig > > diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild > index 5bfbf7d79c99..e4847ba0e3c9 100644 > --- a/arch/arm64/Kbuild > +++ b/arch/arm64/Kbuild > @@ -3,6 +3,7 @@ obj-y += kernel/ mm/ net/ > obj-$(CONFIG_KVM) += kvm/ > obj-$(CONFIG_XEN) += xen/ > obj-$(subst m,y,$(CONFIG_HYPERV)) += hyperv/ > +obj-$(CONFIG_GUNYAH) += gunyah/ > obj-$(CONFIG_CRYPTO) += crypto/ > > # for cleaning > diff --git a/arch/arm64/gunyah/Makefile b/arch/arm64/gunyah/Makefile > new file mode 100644 > index 000000000000..84f1e38cafb1 > --- /dev/null > +++ b/arch/arm64/gunyah/Makefile > @@ -0,0 +1,3 @@ > +# SPDX-License-Identifier: GPL-2.0 > + > +obj-$(CONFIG_GUNYAH) += gunyah_hypercall.o > diff --git a/arch/arm64/gunyah/gunyah_hypercall.c b/arch/arm64/gunyah/gunyah_hypercall.c > new file mode 100644 > index 000000000000..2166d5dab869 > --- /dev/null > +++ b/arch/arm64/gunyah/gunyah_hypercall.c > @@ -0,0 +1,56 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. > + */ > + > +#include > +#include > +#include > +#include > + > +/* {c1d58fcd-a453-5fdb-9265-ce36673d5f14} */ > +static const uuid_t GUNYAH_UUID = > + UUID_INIT(0xc1d58fcd, 0xa453, 0x5fdb, 0x92, 0x65, 0xce, 0x36, 0x67, 0x3d, 0x5f, 0x14); > + > +bool arch_is_gh_guest(void) > +{ > + struct arm_smccc_res res; > + uuid_t uuid; > + > + arm_smccc_1_1_hvc(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID, &res); > + > + ((u32 *)&uuid.b[0])[0] = lower_32_bits(res.a0); > + ((u32 *)&uuid.b[0])[1] = lower_32_bits(res.a1); > + ((u32 *)&uuid.b[0])[2] = lower_32_bits(res.a2); > + ((u32 *)&uuid.b[0])[3] = lower_32_bits(res.a3); I think I'd rather see this more like: u32 *up = (u32 *)&uuid.b; /* The lower bytes of the four result fields encode the UUID */ *up++ = lower_32_bits(res.a0); *up++ = lower_32_bits(res.a1); *up++ = lower_32_bits(res.a2); *up = lower_32_bits(res.a3); Basically I think casting the assigned-to value makes things harder to read. So doing that cast just once seems simpler. But it's not a big deal. > + > + return uuid_equal(&uuid, &GUNYAH_UUID); > +} > +EXPORT_SYMBOL_GPL(arch_is_gh_guest); . . . _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel