~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm64/kvm/hyp/include/hyp/fault.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright (C) 2015 - ARM Ltd
  4  * Author: Marc Zyngier <marc.zyngier@arm.com>
  5  */
  6 
  7 #ifndef __ARM64_KVM_HYP_FAULT_H__
  8 #define __ARM64_KVM_HYP_FAULT_H__
  9 
 10 #include <asm/kvm_asm.h>
 11 #include <asm/kvm_emulate.h>
 12 #include <asm/kvm_hyp.h>
 13 #include <asm/kvm_mmu.h>
 14 
 15 static inline bool __translate_far_to_hpfar(u64 far, u64 *hpfar)
 16 {
 17         u64 par, tmp;
 18 
 19         /*
 20          * Resolve the IPA the hard way using the guest VA.
 21          *
 22          * Stage-1 translation already validated the memory access
 23          * rights. As such, we can use the EL1 translation regime, and
 24          * don't have to distinguish between EL0 and EL1 access.
 25          *
 26          * We do need to save/restore PAR_EL1 though, as we haven't
 27          * saved the guest context yet, and we may return early...
 28          */
 29         par = read_sysreg_par();
 30         if (!__kvm_at("s1e1r", far))
 31                 tmp = read_sysreg_par();
 32         else
 33                 tmp = SYS_PAR_EL1_F; /* back to the guest */
 34         write_sysreg(par, par_el1);
 35 
 36         if (unlikely(tmp & SYS_PAR_EL1_F))
 37                 return false; /* Translation failed, back to guest */
 38 
 39         /* Convert PAR to HPFAR format */
 40         *hpfar = PAR_TO_HPFAR(tmp);
 41         return true;
 42 }
 43 
 44 static inline bool __get_fault_info(u64 esr, struct kvm_vcpu_fault_info *fault)
 45 {
 46         u64 hpfar, far;
 47 
 48         far = read_sysreg_el2(SYS_FAR);
 49 
 50         /*
 51          * The HPFAR can be invalid if the stage 2 fault did not
 52          * happen during a stage 1 page table walk (the ESR_EL2.S1PTW
 53          * bit is clear) and one of the two following cases are true:
 54          *   1. The fault was due to a permission fault
 55          *   2. The processor carries errata 834220
 56          *
 57          * Therefore, for all non S1PTW faults where we either have a
 58          * permission fault or the errata workaround is enabled, we
 59          * resolve the IPA using the AT instruction.
 60          */
 61         if (!(esr & ESR_ELx_S1PTW) &&
 62             (cpus_have_final_cap(ARM64_WORKAROUND_834220) ||
 63              esr_fsc_is_permission_fault(esr))) {
 64                 if (!__translate_far_to_hpfar(far, &hpfar))
 65                         return false;
 66         } else {
 67                 hpfar = read_sysreg(hpfar_el2);
 68         }
 69 
 70         fault->far_el2 = far;
 71         fault->hpfar_el2 = hpfar;
 72         return true;
 73 }
 74 
 75 #endif
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php