|
@@ -18,11 +18,20 @@
|
|
#include <linux/compiler.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/irqchip/arm-gic.h>
|
|
#include <linux/irqchip/arm-gic.h>
|
|
#include <linux/kvm_host.h>
|
|
#include <linux/kvm_host.h>
|
|
|
|
+#include <linux/swab.h>
|
|
|
|
|
|
#include <asm/kvm_emulate.h>
|
|
#include <asm/kvm_emulate.h>
|
|
#include <asm/kvm_hyp.h>
|
|
#include <asm/kvm_hyp.h>
|
|
#include <asm/kvm_mmu.h>
|
|
#include <asm/kvm_mmu.h>
|
|
|
|
|
|
|
|
+static bool __hyp_text __is_be(struct kvm_vcpu *vcpu)
|
|
|
|
+{
|
|
|
|
+ if (vcpu_mode_is_32bit(vcpu))
|
|
|
|
+ return !!(read_sysreg_el2(spsr) & COMPAT_PSR_E_BIT);
|
|
|
|
+
|
|
|
|
+ return !!(read_sysreg(SCTLR_EL1) & SCTLR_ELx_EE);
|
|
|
|
+}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* __vgic_v2_perform_cpuif_access -- perform a GICV access on behalf of the
|
|
* __vgic_v2_perform_cpuif_access -- perform a GICV access on behalf of the
|
|
* guest.
|
|
* guest.
|
|
@@ -64,14 +73,19 @@ int __hyp_text __vgic_v2_perform_cpuif_access(struct kvm_vcpu *vcpu)
|
|
addr += fault_ipa - vgic->vgic_cpu_base;
|
|
addr += fault_ipa - vgic->vgic_cpu_base;
|
|
|
|
|
|
if (kvm_vcpu_dabt_iswrite(vcpu)) {
|
|
if (kvm_vcpu_dabt_iswrite(vcpu)) {
|
|
- u32 data = vcpu_data_guest_to_host(vcpu,
|
|
|
|
- vcpu_get_reg(vcpu, rd),
|
|
|
|
- sizeof(u32));
|
|
|
|
|
|
+ u32 data = vcpu_get_reg(vcpu, rd);
|
|
|
|
+ if (__is_be(vcpu)) {
|
|
|
|
+ /* guest pre-swabbed data, undo this for writel() */
|
|
|
|
+ data = swab32(data);
|
|
|
|
+ }
|
|
writel_relaxed(data, addr);
|
|
writel_relaxed(data, addr);
|
|
} else {
|
|
} else {
|
|
u32 data = readl_relaxed(addr);
|
|
u32 data = readl_relaxed(addr);
|
|
- vcpu_set_reg(vcpu, rd, vcpu_data_host_to_guest(vcpu, data,
|
|
|
|
- sizeof(u32)));
|
|
|
|
|
|
+ if (__is_be(vcpu)) {
|
|
|
|
+ /* guest expects swabbed data */
|
|
|
|
+ data = swab32(data);
|
|
|
|
+ }
|
|
|
|
+ vcpu_set_reg(vcpu, rd, data);
|
|
}
|
|
}
|
|
|
|
|
|
return 1;
|
|
return 1;
|