From nobody Wed Dec 17 16:12:52 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82CBD355049; Wed, 17 Dec 2025 10:14:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765966469; cv=none; b=trtcpt6UqWKD0lGzW3hcc/YhGDCAqqX/K0wbLPpm/i2iNuKmS3OJ6ecXG2qCKjqiPHsIzDjzulSXVfyLnf6xoiBei+bM8LMGks4E4ckgmK0TR4fDLB/aDk4TzCrd6Oh5FFLyDIShvrN4Eb4MTpvXtHXT347i0d+PPmLrEGNNmno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765966469; c=relaxed/simple; bh=ewiyLDx1L7cn3+oZh4//VxrS1pilT9/HTRhgkorSti4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RA+d9WKRB3X9AI652CkGbrUmPzZ96DaVt++ihRtzIENMQPutyIapBE2Hw5xBzIDRS/uoXHnt43idXzgTarfCOkwog90BgqyWIl7WXboB2//D4eOx3uoq4RSTaHG+/DgxQYMlv+ed8QN+QGPlD+UuQE7vZzRsTxkUEc0Mpl+UXsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 01E4B1517; Wed, 17 Dec 2025 02:14:19 -0800 (PST) Received: from e122027.arm.com (unknown [10.57.45.201]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 38B123F73B; Wed, 17 Dec 2025 02:14:22 -0800 (PST) From: Steven Price To: 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 , "Aneesh Kumar K . V" , Emi Kisanuki , Vishal Annapurve Subject: [PATCH v12 33/46] arm64: RMI: Always use 4k pages for realms Date: Wed, 17 Dec 2025 10:11:10 +0000 Message-ID: <20251217101125.91098-34-steven.price@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217101125.91098-1-steven.price@arm.com> References: <20251217101125.91098-1-steven.price@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Guest_memfd doesn't yet natively support huge pages, and there are currently difficulties for a VMM to manage huge pages efficiently so for now always split up mappings to PTE (4k). The two issues that need progressing before supporting huge pages for realms are: 1. guest_memfd needs to be able to allocate from an appropriate allocator which can provide huge pages. 2. The VMM needs to be able to repurpose private memory for a shared mapping when the guest VM requests memory is transitioned. Because this can happen at a 4k granularity it isn't possible to free/reallocate while huge pages are in use. Allowing the VMM to mmap() the shared portion of a huge page would allow the huge page to be recreated when the memory is unshared and made protected again. These two issues are not specific to realms and don't affect the realm API, so for now just break everything down to 4k pages in the RMM controlled stage 2. Future work can add huge page support without changing the uAPI. Signed-off-by: Steven Price Reviewed-by: Gavin Shan Reviewed-by: Suzuki K Poulose --- Changes since v7: * Rewritten commit message --- arch/arm64/kvm/mmu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 860c42aabcf0..c30d7be27361 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1762,11 +1762,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, ph= ys_addr_t fault_ipa, write_fault =3D kvm_is_write_fault(vcpu); =20 /* - * Realms cannot map protected pages read-only + * Realms cannot map protected pages read-only, also force PTE mappings + * for Realms. * FIXME: It should be possible to map unprotected pages read-only */ - if (vcpu_is_rec(vcpu)) + if (vcpu_is_rec(vcpu)) { write_fault =3D true; + force_pte =3D true; + } =20 exec_fault =3D kvm_vcpu_trap_is_exec_fault(vcpu); VM_WARN_ON_ONCE(write_fault && exec_fault); --=20 2.43.0