From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3FC78F5F; Mon, 13 Feb 2023 15:59:11 +0000 (UTC) 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 840444B3; Mon, 13 Feb 2023 07:59:53 -0800 (PST) Received: from [10.57.13.51] (unknown [10.57.13.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9CC353F703; Mon, 13 Feb 2023 07:59:07 -0800 (PST) Message-ID: <748a6bcf-ec16-0870-8e33-bc29ab311211@arm.com> Date: Mon, 13 Feb 2023 15:59:05 +0000 Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [RFC PATCH 04/28] arm64: RME: Check for RME support at KVM init Content-Language: en-GB To: Zhi Wang Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, 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> <20230213174846.00003fad@gmail.com> From: Steven Price In-Reply-To: <20230213174846.00003fad@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 13/02/2023 15:48, Zhi Wang wrote: > On Fri, 27 Jan 2023 11:29:08 +0000 > 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/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h >> index 9bdba47f7e14..5a2b7229e83f 100644 >> --- a/arch/arm64/include/asm/kvm_emulate.h >> +++ b/arch/arm64/include/asm/kvm_emulate.h >> @@ -490,4 +490,21 @@ static inline bool vcpu_has_feature(struct kvm_vcpu *vcpu, int feature) >> return test_bit(feature, vcpu->arch.features); >> } >> >> +static inline bool kvm_is_realm(struct kvm *kvm) >> +{ >> + if (static_branch_unlikely(&kvm_rme_is_available)) >> + return kvm->arch.is_realm; >> + return false; >> +} >> + >> +static inline enum realm_state kvm_realm_state(struct kvm *kvm) >> +{ >> + return READ_ONCE(kvm->arch.realm.state); >> +} >> + >> +static inline bool vcpu_is_rec(struct kvm_vcpu *vcpu) >> +{ >> + return false; >> +} >> + >> #endif /* __ARM64_KVM_EMULATE_H__ */ >> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h >> index 35a159d131b5..04347c3a8c6b 100644 >> --- a/arch/arm64/include/asm/kvm_host.h >> +++ b/arch/arm64/include/asm/kvm_host.h >> @@ -26,6 +26,7 @@ >> #include >> #include >> #include >> +#include >> >> #define __KVM_HAVE_ARCH_INTC_INITIALIZED >> >> @@ -240,6 +241,9 @@ struct kvm_arch { >> * the associated pKVM instance in the hypervisor. >> */ >> struct kvm_protected_vm pkvm; >> + >> + bool is_realm; > ^ > It would be better to put more comments which really helps on the review. Thanks for the feedback - I had thought "is realm" was fairly self-documenting, but perhaps I've just spent too much time with this code. > I was looking for the user of this memeber to see when it is set. It seems > it is not in this patch. It would have been nice to have a quick answer from the > comments. The usage is in the kvm_is_realm() function which is used in several of the later patches as a way to detect this kvm guest is a realm guest. I think the main issue is that I've got the patches in the wrong other. Patch 7 "arm64: kvm: Allow passing machine type in KVM creation" should probably be before this one, then I could add the assignment of is_realm into this patch (potentially splitting out the is_realm parts into another patch). Thanks, Steve 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 4C806C6379F for ; Mon, 13 Feb 2023 16:00:26 +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-Transfer-Encoding:Content-Type: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=vK03gKfC7vw+KFUwvLpXdvhy8Z4Y3Ve++rC3QqLkBKE=; b=QqOyZ31DI5tiBO O7EnTFiLAvHIxAwQO/gh5m2vzpajNI6D4LpkF2YYQ86N12QavJTKkobtaLHnlVGdQICcF5jmpBUsM Shbe9arLT+UTUrxDHg7G4XYEuXgRZsA68ev1UYSwWIkuo7+IoD2/r/2afgqD/Qkr0PGm0i6O5Ozdz gqYQ+0vmqLOQqe6uNzeSELj6HtB7YvMd2VMG6ujU+3y9WBIbC1CFaGnzngCV85W40NB5Dc62fVlQj l3zMr115cmhXLiY7143LuR1oY+WAFgB2osBZVE41wt0z/RnHZBkG+zRMily5NbCnz8pT2KxBSIAbx u2cwD8mAWYCUChu2aCQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRbEf-00FMFM-CT; Mon, 13 Feb 2023 15:59:21 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRbEb-00FMDQ-Bm for linux-arm-kernel@lists.infradead.org; Mon, 13 Feb 2023 15:59:19 +0000 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 840444B3; Mon, 13 Feb 2023 07:59:53 -0800 (PST) Received: from [10.57.13.51] (unknown [10.57.13.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9CC353F703; Mon, 13 Feb 2023 07:59:07 -0800 (PST) Message-ID: <748a6bcf-ec16-0870-8e33-bc29ab311211@arm.com> Date: Mon, 13 Feb 2023 15:59:05 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [RFC PATCH 04/28] arm64: RME: Check for RME support at KVM init Content-Language: en-GB To: Zhi Wang Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, 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> <20230213174846.00003fad@gmail.com> From: Steven Price In-Reply-To: <20230213174846.00003fad@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230213_075917_558258_BB606A6E X-CRM114-Status: GOOD ( 26.15 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 13/02/2023 15:48, Zhi Wang wrote: > On Fri, 27 Jan 2023 11:29:08 +0000 > 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/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h >> index 9bdba47f7e14..5a2b7229e83f 100644 >> --- a/arch/arm64/include/asm/kvm_emulate.h >> +++ b/arch/arm64/include/asm/kvm_emulate.h >> @@ -490,4 +490,21 @@ static inline bool vcpu_has_feature(struct kvm_vcpu *vcpu, int feature) >> return test_bit(feature, vcpu->arch.features); >> } >> >> +static inline bool kvm_is_realm(struct kvm *kvm) >> +{ >> + if (static_branch_unlikely(&kvm_rme_is_available)) >> + return kvm->arch.is_realm; >> + return false; >> +} >> + >> +static inline enum realm_state kvm_realm_state(struct kvm *kvm) >> +{ >> + return READ_ONCE(kvm->arch.realm.state); >> +} >> + >> +static inline bool vcpu_is_rec(struct kvm_vcpu *vcpu) >> +{ >> + return false; >> +} >> + >> #endif /* __ARM64_KVM_EMULATE_H__ */ >> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h >> index 35a159d131b5..04347c3a8c6b 100644 >> --- a/arch/arm64/include/asm/kvm_host.h >> +++ b/arch/arm64/include/asm/kvm_host.h >> @@ -26,6 +26,7 @@ >> #include >> #include >> #include >> +#include >> >> #define __KVM_HAVE_ARCH_INTC_INITIALIZED >> >> @@ -240,6 +241,9 @@ struct kvm_arch { >> * the associated pKVM instance in the hypervisor. >> */ >> struct kvm_protected_vm pkvm; >> + >> + bool is_realm; > ^ > It would be better to put more comments which really helps on the review. Thanks for the feedback - I had thought "is realm" was fairly self-documenting, but perhaps I've just spent too much time with this code. > I was looking for the user of this memeber to see when it is set. It seems > it is not in this patch. It would have been nice to have a quick answer from the > comments. The usage is in the kvm_is_realm() function which is used in several of the later patches as a way to detect this kvm guest is a realm guest. I think the main issue is that I've got the patches in the wrong other. Patch 7 "arm64: kvm: Allow passing machine type in KVM creation" should probably be before this one, then I could add the assignment of is_realm into this patch (potentially splitting out the is_realm parts into another patch). Thanks, Steve _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel