KVM
Functions
fault.h File Reference
#include <asm/kvm_asm.h>
#include <asm/kvm_emulate.h>
#include <asm/kvm_hyp.h>
#include <asm/kvm_mmu.h>
Include dependency graph for fault.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static bool __translate_far_to_hpfar (u64 far, u64 *hpfar)
 
static bool __get_fault_info (u64 esr, struct kvm_vcpu_fault_info *fault)
 

Function Documentation

◆ __get_fault_info()

static bool __get_fault_info ( u64  esr,
struct kvm_vcpu_fault_info *  fault 
)
inlinestatic

Definition at line 44 of file fault.h.

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 }
static bool __translate_far_to_hpfar(u64 far, u64 *hpfar)
Definition: fault.h:15
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __translate_far_to_hpfar()

static bool __translate_far_to_hpfar ( u64  far,
u64 *  hpfar 
)
inlinestatic

Definition at line 15 of file fault.h.

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 }
Here is the caller graph for this function: