.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2012-2015 - ARM Ltd |
---|
3 | 4 | * 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/>. |
---|
16 | 5 | */ |
---|
| 6 | + |
---|
| 7 | +#include <hyp/adjust_pc.h> |
---|
17 | 8 | |
---|
18 | 9 | #include <linux/compiler.h> |
---|
19 | 10 | #include <linux/irqchip/arm-gic.h> |
---|
.. | .. |
---|
24 | 15 | #include <asm/kvm_hyp.h> |
---|
25 | 16 | #include <asm/kvm_mmu.h> |
---|
26 | 17 | |
---|
27 | | -static bool __hyp_text __is_be(struct kvm_vcpu *vcpu) |
---|
| 18 | +static bool __is_be(struct kvm_vcpu *vcpu) |
---|
28 | 19 | { |
---|
29 | 20 | 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); |
---|
31 | 22 | |
---|
32 | 23 | return !!(read_sysreg(SCTLR_EL1) & SCTLR_ELx_EE); |
---|
33 | 24 | } |
---|
.. | .. |
---|
41 | 32 | * Returns: |
---|
42 | 33 | * 1: GICV access successfully performed |
---|
43 | 34 | * 0: Not a GICV access |
---|
44 | | - * -1: Illegal GICV access |
---|
| 35 | + * -1: Illegal GICV access successfully performed |
---|
45 | 36 | */ |
---|
46 | | -int __hyp_text __vgic_v2_perform_cpuif_access(struct kvm_vcpu *vcpu) |
---|
| 37 | +int __vgic_v2_perform_cpuif_access(struct kvm_vcpu *vcpu) |
---|
47 | 38 | { |
---|
48 | 39 | struct kvm *kvm = kern_hyp_va(vcpu->kvm); |
---|
49 | 40 | struct vgic_dist *vgic = &kvm->arch.vgic; |
---|
.. | .. |
---|
61 | 52 | return 0; |
---|
62 | 53 | |
---|
63 | 54 | /* 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); |
---|
65 | 57 | return -1; |
---|
| 58 | + } |
---|
66 | 59 | |
---|
67 | 60 | /* Not aligned? Don't bother */ |
---|
68 | | - if (fault_ipa & 3) |
---|
| 61 | + if (fault_ipa & 3) { |
---|
| 62 | + __kvm_skip_instr(vcpu); |
---|
69 | 63 | return -1; |
---|
| 64 | + } |
---|
70 | 65 | |
---|
71 | 66 | 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; |
---|
73 | 68 | addr += fault_ipa - vgic->vgic_cpu_base; |
---|
74 | 69 | |
---|
75 | 70 | if (kvm_vcpu_dabt_iswrite(vcpu)) { |
---|
76 | 71 | u32 data = vcpu_get_reg(vcpu, rd); |
---|
77 | 72 | if (__is_be(vcpu)) { |
---|
78 | 73 | /* guest pre-swabbed data, undo this for writel() */ |
---|
79 | | - data = swab32(data); |
---|
| 74 | + data = __kvm_swab32(data); |
---|
80 | 75 | } |
---|
81 | 76 | writel_relaxed(data, addr); |
---|
82 | 77 | } else { |
---|
83 | 78 | u32 data = readl_relaxed(addr); |
---|
84 | 79 | if (__is_be(vcpu)) { |
---|
85 | 80 | /* guest expects swabbed data */ |
---|
86 | | - data = swab32(data); |
---|
| 81 | + data = __kvm_swab32(data); |
---|
87 | 82 | } |
---|
88 | 83 | vcpu_set_reg(vcpu, rd, data); |
---|
89 | 84 | } |
---|
90 | 85 | |
---|
| 86 | + __kvm_skip_instr(vcpu); |
---|
| 87 | + |
---|
91 | 88 | return 1; |
---|
92 | 89 | } |
---|