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 765EEC74A5B for ; Tue, 21 Mar 2023 15:50:48 +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:From:References:Cc:To:Subject: 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=PmWvkEjd80wfqztg6AoAWqeINitWoAYL6Sr+GPkIxJo=; b=F6hSIaB74IxmGk Yh02QC0Oftm2j6Yk9AlOgFcSzz0Q89/eJZHmGlRuyO427erZzTVPEpmuyMbukbTFL3ad3sNktUkca BawhXfDkedjG2eOynj3wD0oWdH34VjILeaj9C4up5kg/2GVzoH7txhSW9LZPaPOjC9FeFIn3HtOV6 Ju1gykTi9fBr+EbjCJveyRqVxz+0gQnrUSIDiHHLbGnz76YbuPcwHgCxCR8Fi+o/mI23eIbiEY8ZY hyPhM6FBvekecg+cOiniQ/kPTW5rFlW5aSrsF9C4QhzJJHaBB1RbyEekDqVhiq8EjUet7OcDSCGJn dmBLw7QwWfScSMSImF+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peeET-00CzBe-2k; Tue, 21 Mar 2023 15:49:05 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peeER-00CzAE-1k for linux-arm-kernel@lists.infradead.org; Tue, 21 Mar 2023 15:49:05 +0000 Received: by mail-ed1-x52c.google.com with SMTP id w9so61530873edc.3 for ; Tue, 21 Mar 2023 08:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679413739; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=SzDFIymbRjbLhmlcc42BiXxJve1ZLr1cxA94sUeeuDQ=; b=xOT3dQErkNbyGneftJFjSnjdfjvRXh/wgUVE5YAfSTsdLMTa+oockgRQBPsMclLUqB U4IIkytzklFq3jHOSyH/KRiUUMWFL904rv+e2yYFdLIGSSxwYfEn66IwA+O/FKnkH9iK OJK3kwJMjNqVkvLoIjBC6FS9mNN4Ll7JAfWxkUWqChVcMIXFTR5NbWlFd0yD13vIyBxI uAKdjSajzGq8sZ6BxflLceYT/1OTdUELaqxWhf+6s70Re59N2OD/PhlyfVbBfXF4GO6g nH4567gpkoZS/JXECrwQYFmnNnPF7Aat07MoTwnRh/gCm8hQ+LrxqJqlp9XGSbdaAFlx NpRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679413739; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SzDFIymbRjbLhmlcc42BiXxJve1ZLr1cxA94sUeeuDQ=; b=tYAogcwbimCyHsoVZyxvpi7aE40rQZ1NRM/a/SJwTstqtAtOUNUIpvUV7TXD1S0p9c 0EyP9LdCfr2ivAywSBEbtZnFep5jrJBGwIbVs7VA4oq28Jx1wGtCqJSxPVlW5/GvbVFM 9pcT+3BFe5FZ4kr9W2MM8PaegHk/WWmVqdq5w8bqNZgtCCE8XmJHwTWjw0iP7+x/QsLj +k6pUQN63lny73o2nA4DGX376Vpr7csTbCsnVp9doj3e7FsPFA310Gold4qQpqvkNLFs WtGMLg1MUZF1UpByRe4rMojklPfnSzYlzajEtn2JSEwklTes1dPwDEC//EmLnYU1h5ky PuwQ== X-Gm-Message-State: AO0yUKVL0LNcRERMJ5JkyyaBdXRcqc4NQ0k5tBJQ064cXq5yYNmh22L5 jGy0BU0m2aYJ+MgjC5brrmfRZA== X-Google-Smtp-Source: AK7set9vvgE0/AZT5nETWstzcgB/WJjjvy5BXgYV3f+XN39lD7CIun132siBk0Fq/T5DQE94TJZWlQ== X-Received: by 2002:a17:906:6d13:b0:925:f542:1a3d with SMTP id m19-20020a1709066d1300b00925f5421a3dmr3383284ejr.25.1679413739616; Tue, 21 Mar 2023 08:48:59 -0700 (PDT) Received: from [192.168.1.195] ([5.133.47.210]) by smtp.googlemail.com with ESMTPSA id s9-20020a170906454900b008f89953b761sm5958260ejq.3.2023.03.21.08.48.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Mar 2023 08:48:58 -0700 (PDT) Message-ID: Date: Tue, 21 Mar 2023 15:48:54 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v11 05/26] virt: gunyah: Identify hypervisor version Content-Language: en-US To: Elliot Berman , Alex Elder , 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> From: Srinivas Kandagatla 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-20230321_084903_602747_F3D503A2 X-CRM114-Status: GOOD ( 23.52 ) 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 04/03/2023 01:06, 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 Reviewed-by: Srinivas Kandagatla --srini > --- > 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