Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1158145rwl; Fri, 31 Mar 2023 07:27:11 -0700 (PDT) X-Google-Smtp-Source: AKy350aKCnA6h6RlNLilz5Uca+i1Vx0iTYl8G4CmJedprnTYFh1dTm+0yGiyqIMxqxxBK/Lm1JKn X-Received: by 2002:a05:6a20:4416:b0:d7:3c1a:6c9a with SMTP id ce22-20020a056a20441600b000d73c1a6c9amr7191015pzb.4.1680272830894; Fri, 31 Mar 2023 07:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680272830; cv=none; d=google.com; s=arc-20160816; b=0rUjQOX07gA4xTMm8ML+JZiq/q0I68v+EbTg7Iuxn75/DAwo7XGGXy65kugWZA6K7R tm+2pytF7qLQy/4w2TZLSqmNQA8kXDd20V0GUSW3zqZxd0FpxoqmKsNOj7cmWFpN6n6I z/kh1tpr4o6EXBbuILjqrwpX1nWxRlt01nGs4pBpzRQWP2vswQ2ZFzyMEYU26Fv5YgoC 71Ya3XHkwdh49GzXryjEsskXgrLuu/rn5I/W+WfmR3wLRiFqZF1iK1AiaGmHZlK6Hoh+ ykVEV+IjBcmaPqNwkTWweCDdLvKfDIZbA+uUVYMmMWKopUYaGTF2IM6eoKJyvAYty7mT 76Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=id+GR3iqUDi1DUpj2KMsPAnwHrgu9sMNPElpRz2tsnU=; b=rRCY1T7GbUbeVJe0HvmdFC+2omCUZ48RPn5R82F5UW9NCmctu5/p2GrQob5P5njg69 asC1j5kT5CNEhV4NcjnW+wONtHU7Uq25KoMsA5tXrAhc8UZF5xUKsD1v/rHYAoqb7FLp YhcUK7H5N5F3GJjsJIQzMkFGthQYkKKGyKvw4uG7wrXnsGeo+uVuu+u/K4LINZBJXsTC mZK7LFCblLr/X8Q9Tls6qJLToyZ3dY8WYjePbV6vwnYvbCk5ledEz7Y3zo4hJKQdE9zn /+EoibBjOGFv4hrtBF930x4F1+UuylRaWI8ouM+/4weV/ir5R011t8GTAgwbp0OTeVqw RvIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JSpwWb5z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a656944000000b004dacaa17ecbsi2226242pgq.559.2023.03.31.07.26.59; Fri, 31 Mar 2023 07:27:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JSpwWb5z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232496AbjCaOZH (ORCPT + 99 others); Fri, 31 Mar 2023 10:25:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232523AbjCaOZC (ORCPT ); Fri, 31 Mar 2023 10:25:02 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 813A81EFDF for ; Fri, 31 Mar 2023 07:24:57 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id j2so4556062ila.8 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=7XJlKNGx8HMyhHXNbF5aw+Kb0oO0Yka0o3UF+MmmYxBhZGJinrBox+EjMUzyGNle7I +RUfbAVlOVfGRlNnsuSkQFNdc7aiM+MJ9e36Z8eK3G7qaylugoi2UngFItIGB2lPuV5+ VjEar13ApG2bCWXTC2OlUhdaQkaUud13RvMmIix0xcuoAQ/tnPk0V01ZxWEX+stIFhM+ XEjMHJp7jg2Kfzk+C6pV8HeYXyn+3hHWTyRTiZp5frFZdwe7BzjyeZZIE8NZLQzSYkD8 LGLmddILPX8hYCMswY/Fdi0II6PuSwauxk7oW2nPy37ILU20hHU9EN7tusoGR22dOutm opJQ== X-Gm-Message-State: AAQBX9cRHoglY0XkQzJxFED5HEkVKXb3veO/5seEfE4qs6uKzuonHP0G 0qCbZdCWAvgI/ffnJTCqkzxHmw== 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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");