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 C33FFC54EE9 for ; Fri, 2 Sep 2022 14:49:24 +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=fabjyFop70olu9avtPWCD4rgWkgpIAlO13wBKOF67hg=; b=BKxSz2nBU8wA90 MGgsfgDn25NwIf8bAZw4mBa1YGBiZXn6v99YrzW5ZjC6iGT6+ngmBgNKTE8Tj6QJAkdeLDJ97GDKA A60PfnXqAQBFUzqP754udh27kitY2y7ckjJyB0sjISb+HmSo9RQ7eJob6zYaWnH+Li4POo0K+vOnP RkfEHmRxIbEm/UQg+srkK4TFpwcehmpCNUi/8ebpEL1Vr6FfflB6o/M7hzT6bnvoiaLEY5hcV0thm wcu7bj/ex7oqZw9jpA2Fg2opbWQV9DCxVHxUqPzV0U7K80pzY5vtvqhArjMslgN+FM1UhSr9rUrML +gGyfqtMnyGyrkneTnDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU7y0-005kbF-Ju; Fri, 02 Sep 2022 14:48: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 1oU7xO-005k6W-Np for linux-arm-kernel@lists.infradead.org; Fri, 02 Sep 2022 14:47:44 +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 0FCD7D6E; Fri, 2 Sep 2022 07:47:48 -0700 (PDT) Received: from [10.57.45.3] (unknown [10.57.45.3]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9BE413F766; Fri, 2 Sep 2022 07:47:39 -0700 (PDT) Message-ID: Date: Fri, 2 Sep 2022 15:47:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3 5/7] KVM: arm64: unify the tests for VMAs in memslots when MTE is enabled Content-Language: en-GB To: Peter Collingbourne , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: Cornelia Huck , Catalin Marinas , Will Deacon , Marc Zyngier , Evgenii Stepanov , kvm@vger.kernel.org, Vincenzo Frascino References: <20220810193033.1090251-1-pcc@google.com> <20220810193033.1090251-6-pcc@google.com> From: Steven Price In-Reply-To: <20220810193033.1090251-6-pcc@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220902_074742_901868_4E870681 X-CRM114-Status: GOOD ( 24.24 ) 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 10/08/2022 20:30, Peter Collingbourne wrote: > Previously we allowed creating a memslot containing a private mapping that > was not VM_MTE_ALLOWED, but would later reject KVM_RUN with -EFAULT. Now > we reject the memory region at memslot creation time. > > Since this is a minor tweak to the ABI (a VMM that created one of > these memslots would fail later anyway), no VMM to my knowledge has > MTE support yet, and the hardware with the necessary features is not > generally available, we can probably make this ABI change at this point. > > Signed-off-by: Peter Collingbourne Reviewed-by: Steven Price > --- > arch/arm64/kvm/mmu.c | 25 ++++++++++++++++--------- > 1 file changed, 16 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 750a69a97994..d54be80e31dd 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -1073,6 +1073,19 @@ static void sanitise_mte_tags(struct kvm *kvm, kvm_pfn_t pfn, > } > } > > +static bool kvm_vma_mte_allowed(struct vm_area_struct *vma) > +{ > + /* > + * VM_SHARED mappings are not allowed with MTE to avoid races > + * when updating the PG_mte_tagged page flag, see > + * sanitise_mte_tags for more details. > + */ > + if (vma->vm_flags & VM_SHARED) > + return false; > + > + return vma->vm_flags & VM_MTE_ALLOWED; > +} > + > static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > struct kvm_memory_slot *memslot, unsigned long hva, > unsigned long fault_status) > @@ -1249,9 +1262,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > } > > if (fault_status != FSC_PERM && !device && kvm_has_mte(kvm)) { > - /* Check the VMM hasn't introduced a new VM_SHARED VMA */ > - if ((vma->vm_flags & VM_MTE_ALLOWED) && > - !(vma->vm_flags & VM_SHARED)) { > + /* Check the VMM hasn't introduced a new disallowed VMA */ > + if (kvm_vma_mte_allowed(vma)) { > sanitise_mte_tags(kvm, pfn, vma_pagesize); > } else { > ret = -EFAULT; > @@ -1695,12 +1707,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, > if (!vma) > break; > > - /* > - * VM_SHARED mappings are not allowed with MTE to avoid races > - * when updating the PG_mte_tagged page flag, see > - * sanitise_mte_tags for more details. > - */ > - if (kvm_has_mte(kvm) && vma->vm_flags & VM_SHARED) { > + if (kvm_has_mte(kvm) && !kvm_vma_mte_allowed(vma)) { > ret = -EINVAL; > break; > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel