From: Marc Zyngier <maz@kernel.org> mainline inclusion from mainline-v7.1-rc1 commit c6f4d84643498bc855e2f6719a3233ded0e2dc63 category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/10374 CVE: NA Reference: https://github.com/torvalds/linux/commit/c6f4d84643498bc855e2f6719a3233ded0e... -------------------------------- commit c6f4d84643498bc855e2f6719a3233ded0e2dc63 upstream In order to make it clearer what gets updated or not during fault handling, move a set of information that losely represents the fault context. This gets populated early, from handle_mem_abort(), and gets passed along as a const pointer. user_mem_abort()'s signature is majorly improved in doing so, and kvm_s2_fault loses a bunch of fields. gmem_abort() will get a similar treatment down the line. [Backport note] Adapted for OLK-6.6: - Only the kvm_s2_fault_desc structure and the user_mem_abort() signature change are backported. The upstream commit also introduces struct kvm_s2_fault and splits user_mem_abort() into helpers, but OLK-6.6's user_mem_abort() carries vendor-specific handling, so that split is intentionally omitted. - The struct kvm_s1_trans *result argument is kept as a separate parameter and is not part of kvm_s2_fault_desc. PVM-specific data structures and control flow are not restructured by this series. - fault_status, shadow_seq and walk_seq are OLK-6.6-specific and are kept as separate arguments, so user_mem_abort() drops from 8 to 5 parameters (6 once kvm_s2_fault_result is added by a later patch). - This is a pure prerequisite cleanup and has no functional change. Tested-by: Fuad Tabba <tabba@google.com> Reviewed-by: Fuad Tabba <tabba@google.com> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Yanan Wang <wangyanan55@huawei.com> --- arch/arm64/kvm/mmu.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index f24c297787a4..c01338229510 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1597,12 +1597,22 @@ static int adjust_shadow_s1_prots(struct kvm_vcpu *vcpu, return 0; } -static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, +struct kvm_s2_fault_desc { + struct kvm_vcpu *vcpu; + phys_addr_t fault_ipa; + struct kvm_memory_slot *memslot; + unsigned long hva; +}; + +static int user_mem_abort(const struct kvm_s2_fault_desc *s2fd, struct kvm_s1_trans *result, - struct kvm_memory_slot *memslot, unsigned long hva, unsigned long fault_status, unsigned long shadow_seq, unsigned long walk_seq) { + struct kvm_vcpu *vcpu = s2fd->vcpu; + phys_addr_t fault_ipa = s2fd->fault_ipa; + struct kvm_memory_slot *memslot = s2fd->memslot; + unsigned long hva = s2fd->hva; int ret = 0; bool write_fault, writable, force_pte = false; bool exec_fault, mte_allowed; @@ -2126,8 +2136,14 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu) goto out_unlock; } - ret = user_mem_abort(vcpu, fault_ipa, result, memslot, hva, - fault_status, shadow_seq, walk_seq); + const struct kvm_s2_fault_desc s2fd = { + .vcpu = vcpu, + .fault_ipa = fault_ipa, + .memslot = memslot, + .hva = hva, + }; + + ret = user_mem_abort(&s2fd, result, fault_status, shadow_seq, walk_seq); if (ret == 0) ret = 1; out: -- 2.43.0