hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c
....@@ -1,19 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2012-2015 - ARM Ltd
34 * Author: Marc Zyngier <marc.zyngier@arm.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License version 2 as
7
- * published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
165 */
6
+
7
+#include <hyp/adjust_pc.h>
178
189 #include <linux/compiler.h>
1910 #include <linux/irqchip/arm-gic.h>
....@@ -24,10 +15,10 @@
2415 #include <asm/kvm_hyp.h>
2516 #include <asm/kvm_mmu.h>
2617
27
-static bool __hyp_text __is_be(struct kvm_vcpu *vcpu)
18
+static bool __is_be(struct kvm_vcpu *vcpu)
2819 {
2920 if (vcpu_mode_is_32bit(vcpu))
30
- return !!(read_sysreg_el2(spsr) & PSR_AA32_E_BIT);
21
+ return !!(read_sysreg_el2(SYS_SPSR) & PSR_AA32_E_BIT);
3122
3223 return !!(read_sysreg(SCTLR_EL1) & SCTLR_ELx_EE);
3324 }
....@@ -41,9 +32,9 @@
4132 * Returns:
4233 * 1: GICV access successfully performed
4334 * 0: Not a GICV access
44
- * -1: Illegal GICV access
35
+ * -1: Illegal GICV access successfully performed
4536 */
46
-int __hyp_text __vgic_v2_perform_cpuif_access(struct kvm_vcpu *vcpu)
37
+int __vgic_v2_perform_cpuif_access(struct kvm_vcpu *vcpu)
4738 {
4839 struct kvm *kvm = kern_hyp_va(vcpu->kvm);
4940 struct vgic_dist *vgic = &kvm->arch.vgic;
....@@ -61,32 +52,38 @@
6152 return 0;
6253
6354 /* Reject anything but a 32bit access */
64
- if (kvm_vcpu_dabt_get_as(vcpu) != sizeof(u32))
55
+ if (kvm_vcpu_dabt_get_as(vcpu) != sizeof(u32)) {
56
+ __kvm_skip_instr(vcpu);
6557 return -1;
58
+ }
6659
6760 /* Not aligned? Don't bother */
68
- if (fault_ipa & 3)
61
+ if (fault_ipa & 3) {
62
+ __kvm_skip_instr(vcpu);
6963 return -1;
64
+ }
7065
7166 rd = kvm_vcpu_dabt_get_rd(vcpu);
72
- addr = hyp_symbol_addr(kvm_vgic_global_state)->vcpu_hyp_va;
67
+ addr = kvm_vgic_global_state.vcpu_hyp_va;
7368 addr += fault_ipa - vgic->vgic_cpu_base;
7469
7570 if (kvm_vcpu_dabt_iswrite(vcpu)) {
7671 u32 data = vcpu_get_reg(vcpu, rd);
7772 if (__is_be(vcpu)) {
7873 /* guest pre-swabbed data, undo this for writel() */
79
- data = swab32(data);
74
+ data = __kvm_swab32(data);
8075 }
8176 writel_relaxed(data, addr);
8277 } else {
8378 u32 data = readl_relaxed(addr);
8479 if (__is_be(vcpu)) {
8580 /* guest expects swabbed data */
86
- data = swab32(data);
81
+ data = __kvm_swab32(data);
8782 }
8883 vcpu_set_reg(vcpu, rd, data);
8984 }
9085
86
+ __kvm_skip_instr(vcpu);
87
+
9188 return 1;
9289 }