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 9FA6FC433EF for ; Thu, 13 Jan 2022 12:13:19 +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:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/t42Koni9UW1lSb0ETkVtSGpT20IqMv7u0W/NlQibtQ=; b=GqZDZvfxBJ+X+5 chX0avYiVgoD5lxlUOdwAhT2Z6b72Nym4Igx7+tjwYiXvzL/KHqlejF3oMT6I2GMVVv/pP/X9dGfj b+Xral8SnL8y2M8eabswNTFiGM9HztT+OwAjRmuD2h+HIuRGJrbcu+/li7dxr3y50IugANOlWIoQk Ebwl8ZlNilBycl2Tv2V9rSXQv+am/Fn7XOW3F8rjCuxltX6GRoFtlzATvlGjAaFaBLVFcXfD2XrZK Vmgbr+1qfVEyrFJQ7yy+lGkACjnrl5QXbeAS7jkzB1at8GMf6q/+41pLLMTiAFJCyeoUfgcEgkFG8 MLyjaL/eSCi2fPHxGFCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7yxi-005lCN-TZ; Thu, 13 Jan 2022 12:12:15 +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 1n7yxf-005lAF-Sx for linux-arm-kernel@lists.infradead.org; Thu, 13 Jan 2022 12:12:13 +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 9C6CDED1; Thu, 13 Jan 2022 04:11:59 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9BB763F774; Thu, 13 Jan 2022 04:11:57 -0800 (PST) Date: Thu, 13 Jan 2022 12:12:04 +0000 From: Alexandru Elisei To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Andre Przywara , Christoffer Dall , Jintack Lim , Haibo Xu , Ganapatrao Kulkarni , James Morse , Suzuki K Poulose , kernel-team@android.com Subject: Re: [PATCH v5 05/69] KVM: arm64: Allow preservation of the S2 SW bits Message-ID: References: <20211129200150.351436-1-maz@kernel.org> <20211129200150.351436-6-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211129200150.351436-6-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220113_041212_022702_DE80FA1A X-CRM114-Status: GOOD ( 17.32 ) 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 Hi Marc, On Mon, Nov 29, 2021 at 08:00:46PM +0000, Marc Zyngier wrote: > The S2 page table code has a limited use the SW bits, but we are about > to need them to encode some guest Stage-2 information (its mapping size > in the form of the TTL encoding). > > Propagate the SW bits specified by the caller, and store them into > the corresponding entry. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/hyp/pgtable.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index 8cdbc43fa651..d69e400b2de6 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -1064,9 +1064,6 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr, > u32 level; > kvm_pte_t set = 0, clr = 0; > > - if (prot & KVM_PTE_LEAF_ATTR_HI_SW) > - return -EINVAL; > - > if (prot & KVM_PGTABLE_PROT_R) > set |= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R; > > @@ -1076,6 +1073,10 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr, > if (prot & KVM_PGTABLE_PROT_X) > clr |= KVM_PTE_LEAF_ATTR_HI_S2_XN; > > + /* Always propagate the SW bits */ > + clr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_SW, 0xf); Nitpick: isn't that the same as: clr |= KVM_PTE_LEAF_ATTR_HI_SW; which looks more readable to me. > + set |= prot & KVM_PTE_LEAF_ATTR_HI_SW; Checked stage2_attr_walker() callbak, first it clears the bits in clr, then sets the bits in set, so this looks correct to me: Reviewed-by: Alexandru Elisei Thanks, Alex > + > ret = stage2_update_leaf_attrs(pgt, addr, 1, set, clr, NULL, &level); > if (!ret) > kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, pgt->mmu, addr, level); > -- > 2.30.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel