From: Jack Thomson <jackabt.amazon@gmail.com>
To: maz@kernel.org, oliver.upton@linux.dev, pbonzini@redhat.com
Cc: joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com,
catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
isaku.yamahata@intel.com, roypat@amazon.co.uk,
kalyazin@amazon.co.uk, jackabt@amazon.com
Subject: [PATCH 1/6] KVM: arm64: Add __gmem_abort and __user_mem_abort
Date: Thu, 11 Sep 2025 14:46:43 +0100 [thread overview]
Message-ID: <20250911134648.58945-2-jackabt.amazon@gmail.com> (raw)
In-Reply-To: <20250911134648.58945-1-jackabt.amazon@gmail.com>
From: Jack Thomson <jackabt@amazon.com>
Adding __gmem_abort and __user_mem_abort that preserve -EAGAIN results.
These will be used by the pre-fault implementation which needs to retry
on -EAGAIN.
Also add an optional page_size output parameter to __user_mem_abort to
return the VMA page size, which will be needed for pre-faulting.
No functional changes are intended
Signed-off-by: Jack Thomson <jackabt@amazon.com>
---
arch/arm64/kvm/mmu.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index a36426ccd9b5..082e7d8ae655 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -1521,9 +1521,9 @@ static void adjust_nested_fault_perms(struct kvm_s2_trans *nested,
#define KVM_PGTABLE_WALK_MEMABORT_FLAGS (KVM_PGTABLE_WALK_HANDLE_FAULT | KVM_PGTABLE_WALK_SHARED)
-static int gmem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
- struct kvm_s2_trans *nested,
- struct kvm_memory_slot *memslot, bool is_perm)
+static int __gmem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
+ struct kvm_s2_trans *nested,
+ struct kvm_memory_slot *memslot, bool is_perm)
{
bool write_fault, exec_fault, writable;
enum kvm_pgtable_walk_flags flags = KVM_PGTABLE_WALK_MEMABORT_FLAGS;
@@ -1592,13 +1592,22 @@ static int gmem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
if (writable && !ret)
mark_page_dirty_in_slot(kvm, memslot, gfn);
+ return ret;
+}
+
+static int gmem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
+ struct kvm_s2_trans *nested,
+ struct kvm_memory_slot *memslot, bool is_perm)
+{
+ int ret = __gmem_abort(vcpu, fault_ipa, nested, memslot, is_perm);
return ret != -EAGAIN ? ret : 0;
}
-static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
- struct kvm_s2_trans *nested,
- struct kvm_memory_slot *memslot, unsigned long hva,
- bool fault_is_perm)
+static int __user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
+ struct kvm_s2_trans *nested,
+ struct kvm_memory_slot *memslot,
+ long *page_size, unsigned long hva,
+ bool fault_is_perm)
{
int ret = 0;
bool topup_memcache;
@@ -1871,10 +1880,23 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
kvm_release_faultin_page(kvm, page, !!ret, writable);
kvm_fault_unlock(kvm);
+ if (page_size)
+ *page_size = vma_pagesize;
+
/* Mark the page dirty only if the fault is handled successfully */
if (writable && !ret)
mark_page_dirty_in_slot(kvm, memslot, gfn);
+ return ret;
+}
+
+static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
+ struct kvm_s2_trans *nested,
+ struct kvm_memory_slot *memslot, unsigned long hva,
+ bool fault_is_perm)
+{
+ int ret = __user_mem_abort(vcpu, fault_ipa, nested, memslot, NULL,
+ hva, fault_is_perm);
return ret != -EAGAIN ? ret : 0;
}
--
2.43.0
next prev parent reply other threads:[~2025-09-11 13:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-11 13:46 [PATCH 0/6] KVM ARM64 pre_fault_memory Jack Thomson
2025-09-11 13:46 ` Jack Thomson [this message]
2025-09-11 18:27 ` [PATCH 1/6] KVM: arm64: Add __gmem_abort and __user_mem_abort Oliver Upton
2025-09-11 13:46 ` [PATCH 2/6] KVM: arm64: Add KVM_PGTABLE_WALK_PRE_FAULT walk flag Jack Thomson
2025-09-11 13:46 ` [PATCH 3/6] KVM: arm64: Add pre_fault_memory implementation Jack Thomson
2025-09-11 18:42 ` Oliver Upton
2025-09-29 13:59 ` Thomson, Jack
2025-09-30 0:53 ` Oliver Upton
2025-09-11 13:46 ` [PATCH 4/6] KVM: selftests: Fix unaligned mmap allocations Jack Thomson
2025-09-11 13:46 ` [PATCH 5/6] KVM: selftests: Enable pre_fault_memory_test for arm64 Jack Thomson
2025-09-11 13:46 ` [PATCH 6/6] KVM: selftests: Add option for different backing in pre-fault tests Jack Thomson
2025-09-11 18:56 ` [PATCH 0/6] KVM ARM64 pre_fault_memory Oliver Upton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250911134648.58945-2-jackabt.amazon@gmail.com \
--to=jackabt.amazon@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=isaku.yamahata@intel.com \
--cc=jackabt@amazon.com \
--cc=joey.gouly@arm.com \
--cc=kalyazin@amazon.co.uk \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=roypat@amazon.co.uk \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox