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 36B7ED3000A for ; Fri, 18 Oct 2024 13:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type: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=NUuZb41WDAqjJpGP1IiLPdgbRl5e1k275TAV8C935jM=; b=QWiCmFwcfQjiWEIdJvQ8UBKT5P aSIysBMb+3qfb0LH/nPBRLz9LwHSsTuMheLVjw4WekHp8Ir2/mIO/1+51L6arP0XeOKaKec/81wVw EDsvS9LlUkVHLazhRpmvPq6tuiEvN8S6HCTr+l7Ei4V2H1A7qtA5GzFKYqjWQHnuYvuyFwEB3HLig UTeHxg23aXTQBjBI/S7P88wFAJoyiysVDy5puWvvkp1Iq/0eC2ZI1mhIk74fplGFLkiPyYvalXRiq iWpXaild3tdWi3f3GMffeP9GoBZfQ+gWM77t+oLI3nZwHtB2tQAd+aV9U1y6m9cgolhRkjAkHcooO czB50goQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1nGD-00000000vh3-3QNw; Fri, 18 Oct 2024 13:43:22 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1n3b-00000000sgW-1YBd for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2024 13:30:21 +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 332DFFEC; Fri, 18 Oct 2024 06:30:47 -0700 (PDT) Received: from [10.57.64.219] (unknown [10.57.64.219]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AAD373F528; Fri, 18 Oct 2024 06:30:14 -0700 (PDT) Message-ID: <7ca207aa-4433-4e9b-8cd2-e025bb265796@arm.com> Date: Fri, 18 Oct 2024 14:30:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 31/43] arm64: rme: Prevent Device mappings for Realms Content-Language: en-GB To: Steven Price , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , 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, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" References: <20241004152804.72508-1-steven.price@arm.com> <20241004152804.72508-32-steven.price@arm.com> From: Suzuki K Poulose In-Reply-To: <20241004152804.72508-32-steven.price@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241018_063019_486863_E20EDE9E X-CRM114-Status: GOOD ( 16.81 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 04/10/2024 16:27, Steven Price wrote: > Physical device assignment is not yet supported by the RMM, so it > doesn't make much sense to allow device mappings within the realm. > Prevent them when the guest is a realm. > > Signed-off-by: Steven Price > --- > arch/arm64/kvm/mmu.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 4f0403059c91..602c49eae90d 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -1142,6 +1142,10 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa, > if (is_protected_kvm_enabled()) > return -EPERM; > > + /* We don't support mapping special pages into a Realm */ > + if (kvm_is_realm(kvm)) > + return -EINVAL; > + I believe this is not sufficient. This is only called for GICv2 today. But we also need to check in user_mem_abort() and only allow the mapping if it targeting an unprotected IPA. Something like: diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 26d550ad8393..e433bf8376f2 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1710,6 +1710,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, if (exec_fault && device) return -ENOEXEC; + if (device && kvm_gpa_from_fault(fault_ipa) != fault_ipa) + return -EINVAL; + /* * Potentially reduce shadow S2 permissions to match the guest's own * S2. For exec faults, we'd only reach this point if the guest Suzuki > size += offset_in_page(guest_ipa); > guest_ipa &= PAGE_MASK; >