KVM
Functions
vgic-v2-cpuif-proxy.c File Reference
#include <hyp/adjust_pc.h>
#include <linux/compiler.h>
#include <linux/irqchip/arm-gic.h>
#include <linux/kvm_host.h>
#include <linux/swab.h>
#include <asm/kvm_emulate.h>
#include <asm/kvm_hyp.h>
#include <asm/kvm_mmu.h>
Include dependency graph for vgic-v2-cpuif-proxy.c:

Go to the source code of this file.

Functions

static bool __is_be (struct kvm_vcpu *vcpu)
 
int __vgic_v2_perform_cpuif_access (struct kvm_vcpu *vcpu)
 

Function Documentation

◆ __is_be()

static bool __is_be ( struct kvm_vcpu *  vcpu)
static

Definition at line 18 of file vgic-v2-cpuif-proxy.c.

19 {
20  if (vcpu_mode_is_32bit(vcpu))
21  return !!(read_sysreg_el2(SYS_SPSR) & PSR_AA32_E_BIT);
22 
23  return !!(read_sysreg(SCTLR_EL1) & SCTLR_ELx_EE);
24 }
Here is the caller graph for this function:

◆ __vgic_v2_perform_cpuif_access()

int __vgic_v2_perform_cpuif_access ( struct kvm_vcpu *  vcpu)

Definition at line 37 of file vgic-v2-cpuif-proxy.c.

38 {
39  struct kvm *kvm = kern_hyp_va(vcpu->kvm);
40  struct vgic_dist *vgic = &kvm->arch.vgic;
41  phys_addr_t fault_ipa;
42  void __iomem *addr;
43  int rd;
44 
45  /* Build the full address */
46  fault_ipa = kvm_vcpu_get_fault_ipa(vcpu);
47  fault_ipa |= kvm_vcpu_get_hfar(vcpu) & GENMASK(11, 0);
48 
49  /* If not for GICV, move on */
50  if (fault_ipa < vgic->vgic_cpu_base ||
51  fault_ipa >= (vgic->vgic_cpu_base + KVM_VGIC_V2_CPU_SIZE))
52  return 0;
53 
54  /* Reject anything but a 32bit access */
55  if (kvm_vcpu_dabt_get_as(vcpu) != sizeof(u32)) {
56  __kvm_skip_instr(vcpu);
57  return -1;
58  }
59 
60  /* Not aligned? Don't bother */
61  if (fault_ipa & 3) {
62  __kvm_skip_instr(vcpu);
63  return -1;
64  }
65 
66  rd = kvm_vcpu_dabt_get_rd(vcpu);
68  addr += fault_ipa - vgic->vgic_cpu_base;
69 
70  if (kvm_vcpu_dabt_iswrite(vcpu)) {
71  u32 data = vcpu_get_reg(vcpu, rd);
72  if (__is_be(vcpu)) {
73  /* guest pre-swabbed data, undo this for writel() */
74  data = __kvm_swab32(data);
75  }
76  writel_relaxed(data, addr);
77  } else {
78  u32 data = readl_relaxed(addr);
79  if (__is_be(vcpu)) {
80  /* guest expects swabbed data */
81  data = __kvm_swab32(data);
82  }
83  vcpu_set_reg(vcpu, rd, data);
84  }
85 
86  __kvm_skip_instr(vcpu);
87 
88  return 1;
89 }
static void __kvm_skip_instr(struct kvm_vcpu *vcpu)
Definition: adjust_pc.h:33
struct vgic_global kvm_vgic_global_state
gpa_t vgic_cpu_base
Definition: arm_vgic.h:250
void __iomem * vcpu_hyp_va
Definition: arm_vgic.h:54
static bool __is_be(struct kvm_vcpu *vcpu)
Here is the call graph for this function:
Here is the caller graph for this function: