Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp147228lqt; Mon, 18 Mar 2024 04:23:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURtGs5jcOpFLUTT83fhHC4F33MpdcHad+QGmXDCuMtLCmgslYhrKt6inTHAbHyQSWETVtr04dSZtiExj9wAvlTfwEc6bjVqnbfmLXGng== X-Google-Smtp-Source: AGHT+IEooOqq9mLf7A02S+e5zBTCaZ0wOAFwzO5u5jum4L2Zrq8HJ/z1ZNuZZONDtg9vesI/y7cp X-Received: by 2002:a0c:e14d:0:b0:691:edd:1653 with SMTP id c13-20020a0ce14d000000b006910edd1653mr12198184qvl.41.1710760992086; Mon, 18 Mar 2024 04:23:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710760992; cv=pass; d=google.com; s=arc-20160816; b=YTYGxvj5D1QmzjI6VgUHCm/1imuAahO69pAoOdzLuaTd6Ws7hyECPpE0A2WTxQqpOB p/vQByzx1jn+HuKC0xauCWKaLmsGVrBbGckl6CI7nV+SKICzDH1PHolYATYQrzQKKblo aN6jWiD1k+NCMbBEidj6Y2iBNnwTwVY4KWvgK707DT1TF8agZa4D3y4aOCCSFN251I3K XdI7n3VbPPOBA8xsgogT6eLxqWb5RUcFI/0amflt/1JcXtWy3A8RgfLx8osRJ6bNCiq/ O3pMzqazQ2zzjy+Pz1106zTYqR4buw3rguHeEs/q1uqSaWyF1WHswic6veHAksgfdgB6 X8RQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=lm4Y4NeiXA09oKOUoYrfB51dt84WPLuQ3GgfhhGwzh4=; fh=oJQf9vf9Iao1c/CxH0qy0VgVNHy2SVb4lqxByEImyWQ=; b=rGK7pi4yCumuWp/5SyWLn6me5i8FWgp4q/gW+yXcUH8SkNZch5qHPcCMUxxWZoNCBx akjclyyE9UaKq45zGdZKo/HCnnGrEV5K8gs7r594z3g8Yv2iUvm0O4mdSkIu0gDvF555 sH1/4b6Eseedl87Bn4BR8ZY2YLzvfBljYpOIep44qWEgc1kkyVSUj40RbIAivsYM+5qU lJ2EhLcM3trhZhhkoO85r1LQ25O8r0+iUiy5lR84JgQbxu5xFRIteZ/ScX02a15HruSV CHSemsnoZJHkFll+N+0/7h4r9CABjoaosNmrT23h58FUYyqr/ak6tp8080I/FF3UBQul dITQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-106062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id kd23-20020a056214401700b00691743a051asi6894159qvb.467.2024.03.18.04.23.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 04:23:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-106062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C1DB11C21287 for ; Mon, 18 Mar 2024 11:23:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E825381A1; Mon, 18 Mar 2024 11:22:47 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1C52364A1; Mon, 18 Mar 2024 11:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760967; cv=none; b=nu7gAZdCEY8LzmL71OY3NMrKP/ICdeAlus7Cgjid10rNvd9mS/R8pB7BwNNq6FwaolQfGtJEdRYVFnQzAdNgW9dUtxGBGPypzTtsrqr9SgePf38nx8fVCP5HQOwnpKOmX341v4CV0pkzKWifT4yPUmq9UsbQYq/OeTw3lUKtZ1k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760967; c=relaxed/simple; bh=/XlGRfj+bypUxiL/nVJQfK2Y04gmJmgRzWZLHLYUIPM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WoYjoELoPxHGs6hY/p7i/nHamIexw45RlvV5FuV91/VIKOC3Tl/MZ6I364WDLRD80UyXkF/d/8LuKStjJX5lKLpTZiam7rAsOWQJsIv3mQEAyV/q4dQKi+5Jcuh4GZAs22iKijJUDLUbmE+W//5svYUdDOP9ELxupnOL+jGHxp0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3E50C106F; Mon, 18 Mar 2024 04:23:19 -0700 (PDT) Received: from [10.57.12.69] (unknown [10.57.12.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DD3383F7CE; Mon, 18 Mar 2024 04:22:40 -0700 (PDT) Message-ID: <9bd6668c-17c9-4fdf-ad06-3fd41814ba28@arm.com> Date: Mon, 18 Mar 2024 11:22:41 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 04/28] arm64: RME: Check for RME support at KVM init Content-Language: en-GB To: Ganapatrao Kulkarni , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127112932.38045-1-steven.price@arm.com> <20230127112932.38045-5-steven.price@arm.com> From: Steven Price In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 18/03/2024 07:17, Ganapatrao Kulkarni wrote: > > > On 27-01-2023 04:59 pm, Steven Price wrote: >> Query the RMI version number and check if it is a compatible version. A >> static key is also provided to signal that a supported RMM is available. >> >> Functions are provided to query if a VM or VCPU is a realm (or rec) >> which currently will always return false. >> >> Signed-off-by: Steven Price >> --- >>   arch/arm64/include/asm/kvm_emulate.h | 17 ++++++++++ >>   arch/arm64/include/asm/kvm_host.h    |  4 +++ >>   arch/arm64/include/asm/kvm_rme.h     | 22 +++++++++++++ >>   arch/arm64/include/asm/virt.h        |  1 + >>   arch/arm64/kvm/Makefile              |  3 +- >>   arch/arm64/kvm/arm.c                 |  8 +++++ >>   arch/arm64/kvm/rme.c                 | 49 ++++++++++++++++++++++++++++ >>   7 files changed, 103 insertions(+), 1 deletion(-) >>   create mode 100644 arch/arm64/include/asm/kvm_rme.h >>   create mode 100644 arch/arm64/kvm/rme.c >> [...] >> diff --git a/arch/arm64/kvm/rme.c b/arch/arm64/kvm/rme.c >> new file mode 100644 >> index 000000000000..f6b587bc116e >> --- /dev/null >> +++ b/arch/arm64/kvm/rme.c >> @@ -0,0 +1,49 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (C) 2023 ARM Ltd. >> + */ >> + >> +#include >> + >> +#include >> +#include >> + >> +static int rmi_check_version(void) >> +{ >> +    struct arm_smccc_res res; >> +    int version_major, version_minor; >> + >> +    arm_smccc_1_1_invoke(SMC_RMI_VERSION, &res); >> + >> +    if (res.a0 == SMCCC_RET_NOT_SUPPORTED) >> +        return -ENXIO; >> + >> +    version_major = RMI_ABI_VERSION_GET_MAJOR(res.a0); >> +    version_minor = RMI_ABI_VERSION_GET_MINOR(res.a0); >> + >> +    if (version_major != RMI_ABI_MAJOR_VERSION) { >> +        kvm_err("Unsupported RMI ABI (version %d.%d) we support %d\n", > > Can we please replace "we support" to host supports. > Also in the patch present in the repo, you are using variable > our_version, can this be changed to host_version? Sure, I do have a bad habit using "we" - thanks for point it out. Steve >> +            version_major, version_minor, >> +            RMI_ABI_MAJOR_VERSION); >> +        return -ENXIO; >> +    } >> + >> +    kvm_info("RMI ABI version %d.%d\n", version_major, version_minor); >> + >> +    return 0; >> +} >> + >> +int kvm_init_rme(void) >> +{ >> +    if (PAGE_SIZE != SZ_4K) >> +        /* Only 4k page size on the host is supported */ >> +        return 0; >> + >> +    if (rmi_check_version()) >> +        /* Continue without realm support */ >> +        return 0; >> + >> +    /* Future patch will enable static branch kvm_rme_is_available */ >> + >> +    return 0; >> +} > > Thanks, > Ganapat