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 860F610ED660 for ; Fri, 27 Mar 2026 11:37:03 +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: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5QxcG/6iJ/Z0/ph9o4yEC1etPqOvWgLvtAtuvAoxavU=; b=dmpED+09BoFUHDV7Wto5885tXh JTawQCSkEw+ij8NV1H1KTAi+a95/xekwvnHE97iteqTQOicHSTPH7Sh58hgIp4hKk+ccI/o0zwgZr e7WGdDaJDk1lhvKI9ntK7bbZ/dmPvn6+lYeVLhQrpMXXvS+7LMbktDD4QzPW7EO1VG4QIN6f7+Zv5 FfsQulEgnuzv7e0Uc6icoeSStBHFcDnI3BmK4ttU3LbPpzM1ZtGYkXVByQUYIKHFgnHovBMDkKOkW 0+0lUgUoChlHa1QeNoZuh8C9K6DS4+NgDJOY4csPfBKWVRZaKpFNwjcRfaqpDuu63VQaH5OzWIqlG gP1HjuXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w65Uj-00000007FT9-1icx; Fri, 27 Mar 2026 11:36:53 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1w65UK-00000007F4z-2o03 for linux-arm-kernel@lists.infradead.org; Fri, 27 Mar 2026 11:36:30 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 454B942A2B; Fri, 27 Mar 2026 11:36:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AFA0C2BCC6; Fri, 27 Mar 2026 11:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774611388; bh=L01PTHb9ygvL6qt++CMbu5M5Gf0Wru9Ycf5ATiCx7g4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OiBZMCTN3cu2i/J5PDNnkuDXVX7flgpRC7DIz7D8jO+7N1uRTs9LhC4ExGvXJI/e4 paphMuPWTZzdDjuvudLlCQo2JWjEs622fbLGFC6ftoSe00ECcEIlJoVRUoKkp7cq40 8q/QuAuNoLI7U+5NnAA6yf7/2fTeGRhthvQcwLmazUDlJGNXcN+3o30o0azNGMIp4q 6lX2C5uC4OoQ9BzMgc89hLEDlZ+/JwDz7MgiSHzGAHZNoPMAIihiRt83WoI8050Mo0 13ky5zbzSzUTvW8kFSlsp939dyIS5DXiCCM0+Z1UqUYFW2fHMGv6qhQZL/mvpCOf4M HyL6GIiYYk+0w== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w65UI-00000006K4a-0vlN; Fri, 27 Mar 2026 11:36:26 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Fuad Tabba , Will Deacon , Quentin Perret Subject: [PATCH v2 17/30] KVM: arm64: Replace fault_is_perm with a helper Date: Fri, 27 Mar 2026 11:36:05 +0000 Message-ID: <20260327113618.4051534-18-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260327113618.4051534-1-maz@kernel.org> References: <20260327113618.4051534-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, yuzenghui@huawei.com, tabba@google.com, will@kernel.org, qperret@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260327_043628_818391_3BB22822 X-CRM114-Status: GOOD ( 15.72 ) 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 Carrying a boolean to indicate that a given fault is a permission fault is slightly odd, as this is a property of the fault itself, and we'd better avoid duplicating state. For this purpose, introduce a kvm_s2_fault_is_perm() predicate that can take a fault descriptor as a parameter. fault_is_perm is therefore dropped from kvm_s2_fault. Tested-by: Fuad Tabba Reviewed-by: Fuad Tabba Reviewed-by: Suzuki K Poulose Reviewed-by: Joey Gouly Signed-off-by: Marc Zyngier --- arch/arm64/kvm/mmu.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 09e32f08028e4..1e0d93d6d265a 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1711,8 +1711,6 @@ static short kvm_s2_resolve_vma_size(const struct kvm_s2_fault_desc *s2fd, } struct kvm_s2_fault { - bool fault_is_perm; - bool write_fault; bool exec_fault; bool writable; @@ -1732,6 +1730,11 @@ struct kvm_s2_fault { vm_flags_t vm_flags; }; +static bool kvm_s2_fault_is_perm(const struct kvm_s2_fault_desc *s2fd) +{ + return kvm_vcpu_trap_is_permission_fault(s2fd->vcpu); +} + static int kvm_s2_fault_get_vma_info(const struct kvm_s2_fault_desc *s2fd, struct kvm_s2_fault *fault) { @@ -1888,7 +1891,7 @@ static int kvm_s2_fault_compute_prot(const struct kvm_s2_fault_desc *s2fd, if (s2fd->nested) adjust_nested_exec_perms(kvm, s2fd->nested, &fault->prot); - if (!fault->fault_is_perm && !fault->s2_force_noncacheable && kvm_has_mte(kvm)) { + if (!kvm_s2_fault_is_perm(s2fd) && !fault->s2_force_noncacheable && kvm_has_mte(kvm)) { /* Check the VMM hasn't introduced a new disallowed VMA */ if (!fault->mte_allowed) return -EFAULT; @@ -1905,6 +1908,7 @@ static phys_addr_t get_ipa(const struct kvm_s2_fault *fault) static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd, struct kvm_s2_fault *fault, void *memcache) { + bool fault_is_perm = kvm_s2_fault_is_perm(s2fd); struct kvm *kvm = s2fd->vcpu->kvm; struct kvm_pgtable *pgt; int ret; @@ -1922,7 +1926,7 @@ static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd, */ if (fault->vma_pagesize == PAGE_SIZE && !(fault->force_pte || fault->s2_force_noncacheable)) { - if (fault->fault_is_perm && fault->fault_granule > PAGE_SIZE) { + if (fault_is_perm && fault->fault_granule > PAGE_SIZE) { fault->vma_pagesize = fault->fault_granule; } else { fault->vma_pagesize = transparent_hugepage_adjust(kvm, s2fd->memslot, @@ -1936,7 +1940,7 @@ static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd, } } - if (!fault->fault_is_perm && !fault->s2_force_noncacheable && kvm_has_mte(kvm)) + if (!fault_is_perm && !fault->s2_force_noncacheable && kvm_has_mte(kvm)) sanitise_mte_tags(kvm, fault->pfn, fault->vma_pagesize); /* @@ -1944,7 +1948,7 @@ static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd, * permissions only if fault->vma_pagesize equals fault->fault_granule. Otherwise, * kvm_pgtable_stage2_map() should be called to change block size. */ - if (fault->fault_is_perm && fault->vma_pagesize == fault->fault_granule) { + if (fault_is_perm && fault->vma_pagesize == fault->fault_granule) { /* * Drop the SW bits in favour of those stored in the * PTE, which will be preserved. @@ -1977,7 +1981,6 @@ static int user_mem_abort(const struct kvm_s2_fault_desc *s2fd) bool write_fault = kvm_is_write_fault(s2fd->vcpu); bool logging_active = memslot_is_logging(s2fd->memslot); struct kvm_s2_fault fault = { - .fault_is_perm = perm_fault, .logging_active = logging_active, .force_pte = logging_active, .prot = KVM_PGTABLE_PROT_R, -- 2.47.3