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 672C1C76196 for ; Fri, 31 Mar 2023 14:26:25 +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=4vN1EvMnlZxYkYohMfYlRyq/kz/UkFVTN9LUue/VCaw=; b=dEnc+Vc4Eo+At9 jg/uSNHNiifqiRCGrFa/UHh86hMl27IryNJXcLgd9nKhDOOn3lhJZy/+a9td0uGV9SBdUYs02SnYw f8UmGahJ8E5cMPudeVyOUReTaiMr2BfTUwVfSTUfFFdCd3C4aYT67BB/+dxrWiUAERJS9l9XPsHV1 0ZIDc1BuSGwgwT2x1cNdNSNdpt5GiO6qzBQYKKyXMtE60oWgq5yA1Kz//wkYETk3yq2p6CXTjCAQs gqYJsXD3WyJrt+8yrOal/jPKieYtYWB4fIQVAphITy5X2MKJs4hkbjrxR1ULzoaqQPoUUFS9QcPk/ e4sK/XDeV8fkQ3aGHMag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1piFh0-007gDv-1N; Fri, 31 Mar 2023 14:25:26 +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 1piFgZ-007g5t-10 for linux-arm-kernel@lists.infradead.org; Fri, 31 Mar 2023 14:25:00 +0000 Received: by mail-il1-x132.google.com with SMTP id o12so6560929ilh.13 for ; Fri, 31 Mar 2023 07:24:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680272697; x=1682864697; 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=id+GR3iqUDi1DUpj2KMsPAnwHrgu9sMNPElpRz2tsnU=; b=JSpwWb5zSlSeqGJChV/8WIdrxghOC35J/Oit6vL+r6PDzJ6ojMwuXyXN77xxg9gZbl AnTu90S1K57iz1KzYumWIHoOZzqQ7cOaanupwb1sQCiI51cfu+JBITFWuwYvfHRHGi8A 76n1jPez7cWLijucRM9ZFqNK/jr4dVmOFjqDicsHxuZgyo1N5+Xl4yonUvskdJBTSl9r cPQwXHgGcwsmTFnMXtrpnmzd6Bohex0xO8xVJ9tDZL4poo2unK40iZkYg4bTH/kHEUpl aOd1mlQbn1Td6o0dGndJRb1EXmy8QHnXasxzeMPidiCBDtHuaLycsEdOwLnvt4Q3hY9v c8XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680272697; x=1682864697; 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=id+GR3iqUDi1DUpj2KMsPAnwHrgu9sMNPElpRz2tsnU=; b=1YTImDXh7Z+Vq8ejekJO9Q0fludBmACKcDFHXtVsu1DTbKRkHn/VxlNTUF6wOmOqzy NjwKomwCxDRxO+zzbrbO3qAVMaSbrj1JVw8T+lTQpTQlxSWlv+5EfQKV90B81Ef1YPS4 0B3ujDRDP5HvLIsyUzEyU8eO12kkb8Xe5g9uh1MZLwN3HqF6Xio5R/uqixiuT0ANCfgM yUvYOeDSRLWCLRN4iBMkYJvfvKu4rHMHWKdUKsj+YbeTz3lj07orr+SyyaFojz6/1Bfl iYk1QkbPgaXOFrSh40BnoB0fIIjT6G9MG2UfvKDnMkibjvm86NkUb1lJ1O8c7cpq4rPd KyBw== X-Gm-Message-State: AAQBX9coidbY8IOZbh6IxiNsZwmm5zsog4nrTVfc10/FB++GhtS8hYZa dCKwM1zV/ZwB546TjsuuvmQMhA== X-Google-Smtp-Source: AKy350YYEMfCtuKVVpDekR7oYOlph9QmRnKy6tO/kVqS8ZinY2h8xcsLxXr/BBrwn/Wblo8oy1V7UA== X-Received: by 2002:a92:7f0c:0:b0:326:4313:db91 with SMTP id a12-20020a927f0c000000b003264313db91mr3051071ild.23.1680272697151; Fri, 31 Mar 2023 07:24:57 -0700 (PDT) Received: from [172.22.22.4] ([98.61.227.136]) by smtp.googlemail.com with ESMTPSA id k18-20020a056638371200b004051ff71eacsm656394jav.144.2023.03.31.07.24.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 Mar 2023 07:24:56 -0700 (PDT) Message-ID: <7a294778-ef61-695f-316a-92017100a88b@linaro.org> Date: Fri, 31 Mar 2023 09:24:55 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 From: Alex Elder Subject: Re: [PATCH v11 05/26] virt: gunyah: Identify hypervisor version To: Elliot Berman , Srinivas Kandagatla , 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 , Will Deacon , Andy Gross , Catalin Marinas , 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: <20230304010632.2127470-1-quic_eberman@quicinc.com> <20230304010632.2127470-6-quic_eberman@quicinc.com> Content-Language: en-US In-Reply-To: <20230304010632.2127470-6-quic_eberman@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230331_072459_362929_84B1390D X-CRM114-Status: GOOD ( 22.95 ) 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 3/3/23 7:06 PM, Elliot Berman wrote: > Export the version of Gunyah which is reported via the hyp_identify > hypercall. Increments of the major API version indicate possibly > backwards incompatible changes. > > Export the hypervisor identity so that Gunyah drivers can act according > to the major API version. > > Signed-off-by: Elliot Berman Looks good. Reviewed-by: Alex Elder > --- > drivers/virt/Makefile | 1 + > drivers/virt/gunyah/Makefile | 3 ++ > drivers/virt/gunyah/gunyah.c | 57 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 61 insertions(+) > create mode 100644 drivers/virt/gunyah/Makefile > create mode 100644 drivers/virt/gunyah/gunyah.c > > diff --git a/drivers/virt/Makefile b/drivers/virt/Makefile > index e9aa6fc96fab..a5817e2d7d71 100644 > --- a/drivers/virt/Makefile > +++ b/drivers/virt/Makefile > @@ -12,3 +12,4 @@ obj-$(CONFIG_ACRN_HSM) += acrn/ > obj-$(CONFIG_EFI_SECRET) += coco/efi_secret/ > obj-$(CONFIG_SEV_GUEST) += coco/sev-guest/ > obj-$(CONFIG_INTEL_TDX_GUEST) += coco/tdx-guest/ > +obj-y += gunyah/ > diff --git a/drivers/virt/gunyah/Makefile b/drivers/virt/gunyah/Makefile > new file mode 100644 > index 000000000000..34f32110faf9 > --- /dev/null > +++ b/drivers/virt/gunyah/Makefile > @@ -0,0 +1,3 @@ > +# SPDX-License-Identifier: GPL-2.0 > + > +obj-$(CONFIG_GUNYAH) += gunyah.o > diff --git a/drivers/virt/gunyah/gunyah.c b/drivers/virt/gunyah/gunyah.c > new file mode 100644 > index 000000000000..4b7e6f3edaff > --- /dev/null > +++ b/drivers/virt/gunyah/gunyah.c > @@ -0,0 +1,57 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. > + */ > + > +#define pr_fmt(fmt) "gunyah: " fmt > + > +#include > +#include > +#include > +#include > + > +static struct gh_hypercall_hyp_identify_resp gh_api; > + > +u16 gh_api_version(void) > +{ > + return FIELD_GET(GH_API_INFO_API_VERSION_MASK, gh_api.api_info); > +} > +EXPORT_SYMBOL_GPL(gh_api_version); > + > +bool gh_api_has_feature(enum gh_api_feature feature) > +{ > + switch (feature) { > + case GH_FEATURE_DOORBELL: > + case GH_FEATURE_MSGQUEUE: > + case GH_FEATURE_VCPU: > + case GH_FEATURE_MEMEXTENT: > + return !!(gh_api.flags[0] & BIT_ULL(feature)); > + default: > + return false; > + } > +} > +EXPORT_SYMBOL_GPL(gh_api_has_feature); > + > +static int __init gh_init(void) > +{ > + if (!arch_is_gh_guest()) > + return -ENODEV; > + > + gh_hypercall_hyp_identify(&gh_api); > + > + pr_info("Running under Gunyah hypervisor %llx/v%u\n", > + FIELD_GET(GH_API_INFO_VARIANT_MASK, gh_api.api_info), > + gh_api_version()); > + > + /* We might move this out to individual drivers if there's ever an API version bump */ > + if (gh_api_version() != GH_API_V1) { > + pr_info("Unsupported Gunyah version: %u\n", gh_api_version()); > + return -ENODEV; > + } > + > + return 0; > +} > +arch_initcall(gh_init); > + > +MODULE_LICENSE("GPL"); > +MODULE_DESCRIPTION("Gunyah Hypervisor Driver"); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel