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 88F1FD2E015 for ; Wed, 23 Oct 2024 05:52:57 +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-Type:MIME-Version: Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KsDx9/nzhsNpeWhD3HISLTI3Kj/Gq0Bl0BprSJaYReQ=; b=EC/OLGdCL7Fu5dDHizfRoHMC+z MZa5c43Jkqr9xJQMey9QmRJ+qlI5LPs4qt57mC3ezWGypUjuYAamTPwqw7GxvX8n5Cyy0Wo6a2KwC m2hrLRZQZN3pripw6o/Ek/DyG4Zp+QtQ5aKx5AYL15jaw+70XvvRvs9Y19Mv1zeQWbXtsGBjuP2Ga X8y4ATbxJ4I2vrKv7EOfmnpZY/U9EZ9hoktMlSHmvi25hm0QR1uAbfTAAa0yaWW8XQpIoEauOiSW3 wE0ZfU6/uYhYcu+Dy8rkcNmhHlrxNMhOaYHCd0jI5McOduTeWEPLJymwQ8o0et5TzNlWJ26S+JSNV w7DpKryg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t3UIW-0000000D7Aj-0ba4; Wed, 23 Oct 2024 05:52:44 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t3UGw-0000000D6ms-3Lj3 for linux-arm-kernel@lists.infradead.org; Wed, 23 Oct 2024 05:51:09 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 625DBA449DD; Wed, 23 Oct 2024 05:50:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82E46C4CEC6; Wed, 23 Oct 2024 05:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729662665; bh=M7aW7sxLx+ChIx2S9zBXQ1rM3KjHSPN+I4dTs+cdgrY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=mv0UjbKggh21apRWlL3ozSbZ+z2YuV6nmp+1X23/ZCd2g35Ng9hANH6i8w3KCfxB1 6WHm+WeOvk8YiWrW7IREbdPz9OMqoEN6Q8LVE8z2IDkN5uM/O7QulH03FH4BK6Ppxl p5Thg249BFlniB+1+sFssrzCBcK3l5MF4Mw0yiaOSi3Yl8jdnBn6LYlHbd7TvDXbeF bSg7C5yql1a7KQi6rUQpsY58MXlO9TOOJlDdbcFoFGiwosWRON6kCl4dBbL/VxgiXP C5/c37/WD+9knK/gcJW0CFJcvznoh6F6wnP3pLbH2dOXMW0x7QKycmGEus8Lz/C/hD 6pxJs8GC0lgHg== X-Mailer: emacs 31.0.50 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Steven Price , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Steven Price , 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, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun Subject: Re: [PATCH v5 21/43] arm64: RME: Runtime faulting of memory In-Reply-To: <20241004152804.72508-22-steven.price@arm.com> References: <20241004152804.72508-1-steven.price@arm.com> <20241004152804.72508-22-steven.price@arm.com> Date: Wed, 23 Oct 2024 11:20:54 +0530 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241022_225106_996392_E4EAD1FE X-CRM114-Status: GOOD ( 17.26 ) 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 Steven Price writes: ..... > +int realm_map_protected(struct realm *realm, > + unsigned long base_ipa, > + struct page *dst_page, > + unsigned long map_size, > + struct kvm_mmu_memory_cache *memcache) > +{ > + phys_addr_t dst_phys = page_to_phys(dst_page); > + phys_addr_t rd = virt_to_phys(realm->rd); > + unsigned long phys = dst_phys; > + unsigned long ipa = base_ipa; > + unsigned long size; > + int map_level; > + int ret = 0; > + > + if (WARN_ON(!IS_ALIGNED(ipa, map_size))) > + return -EINVAL; > + > + switch (map_size) { > + case PAGE_SIZE: > + map_level = 3; > + break; > + case RME_L2_BLOCK_SIZE: > + map_level = 2; > + break; > + default: > + return -EINVAL; > + } > + > + if (map_level < RME_RTT_MAX_LEVEL) { > + /* > + * A temporary RTT is needed during the map, precreate it, > + * however if there is an error (e.g. missing parent tables) > + * this will be handled below. > + */ > + realm_create_rtt_levels(realm, ipa, map_level, > + RME_RTT_MAX_LEVEL, memcache); > + } > + > + for (size = 0; size < map_size; size += PAGE_SIZE) { > + if (rmi_granule_delegate(phys)) { > + struct rtt_entry rtt; > + > + /* > + * It's possible we raced with another VCPU on the same > + * fault. If the entry exists and matches then exit > + * early and assume the other VCPU will handle the > + * mapping. > + */ > + if (rmi_rtt_read_entry(rd, ipa, RME_RTT_MAX_LEVEL, &rtt)) > + goto err; > + > + /* > + * FIXME: For a block mapping this could race at level > + * 2 or 3... currently we don't support block mappings > + */ > + if (WARN_ON((rtt.walk_level != RME_RTT_MAX_LEVEL || > + rtt.state != RMI_ASSIGNED || > + rtt_get_phys(realm, &rtt) != phys))) { > + goto err; > + } > + > + return 0; > + } > Technically we are are not mapping more than PAGE_SIZE here, but then the code does the loop above and with that loop should that return 0 be a 'continue'? if we find the granule delegated, then does that ensure rest of the map_size is also delegated? -aneesh