bdc8725399a8bc3e10e5106f95eed4118562b2b7
[openwrt/staging/stintel.git] /
1 From 7a291e75b7793f1fbd0ad9ad39ae35a2b091d84b Mon Sep 17 00:00:00 2001
2 From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
3 Date: Tue, 26 Jul 2016 16:12:30 +0300
4 Subject: [PATCH] arm/arm64 KVM: allow specifying s2 prot bits when mapping i/o
5
6 Add parameter allowing to specify s2 page table
7 protection and type bits and update the callers
8 accordingly.
9 The parameter will be used in a forthcoming patch.
10
11 Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
12 ---
13 arch/arm/include/asm/kvm_mmu.h | 3 ++-
14 arch/arm64/include/asm/kvm_mmu.h | 3 ++-
15 virt/kvm/arm/mmu.c | 8 +++++---
16 virt/kvm/arm/vgic/vgic-v2.c | 3 ++-
17 4 files changed, 11 insertions(+), 6 deletions(-)
18
19 --- a/arch/arm/include/asm/kvm_mmu.h
20 +++ b/arch/arm/include/asm/kvm_mmu.h
21 @@ -55,7 +55,8 @@ void stage2_unmap_vm(struct kvm *kvm);
22 int kvm_alloc_stage2_pgd(struct kvm *kvm);
23 void kvm_free_stage2_pgd(struct kvm *kvm);
24 int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
25 - phys_addr_t pa, unsigned long size, bool writable);
26 + phys_addr_t pa, unsigned long size, bool writable,
27 + pgprot_t prot);
28
29 int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run);
30
31 --- a/arch/arm64/include/asm/kvm_mmu.h
32 +++ b/arch/arm64/include/asm/kvm_mmu.h
33 @@ -156,7 +156,8 @@ void stage2_unmap_vm(struct kvm *kvm);
34 int kvm_alloc_stage2_pgd(struct kvm *kvm);
35 void kvm_free_stage2_pgd(struct kvm *kvm);
36 int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
37 - phys_addr_t pa, unsigned long size, bool writable);
38 + phys_addr_t pa, unsigned long size, bool writable,
39 + pgprot_t prot);
40
41 int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run);
42
43 --- a/virt/kvm/arm/mmu.c
44 +++ b/virt/kvm/arm/mmu.c
45 @@ -1341,9 +1341,11 @@ static int stage2_pudp_test_and_clear_yo
46 * @guest_ipa: The IPA at which to insert the mapping
47 * @pa: The physical address of the device
48 * @size: The size of the mapping
49 + * @prot: S2 page translation bits
50 */
51 int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
52 - phys_addr_t pa, unsigned long size, bool writable)
53 + phys_addr_t pa, unsigned long size, bool writable,
54 + pgprot_t prot)
55 {
56 phys_addr_t addr, end;
57 int ret = 0;
58 @@ -1354,7 +1356,7 @@ int kvm_phys_addr_ioremap(struct kvm *kv
59 pfn = __phys_to_pfn(pa);
60
61 for (addr = guest_ipa; addr < end; addr += PAGE_SIZE) {
62 - pte_t pte = kvm_pfn_pte(pfn, PAGE_S2_DEVICE);
63 + pte_t pte = kvm_pfn_pte(pfn, prot);
64
65 if (writable)
66 pte = kvm_s2pte_mkwrite(pte);
67 @@ -2361,7 +2363,7 @@ int kvm_arch_prepare_memory_region(struc
68
69 ret = kvm_phys_addr_ioremap(kvm, gpa, pa,
70 vm_end - vm_start,
71 - writable);
72 + writable, PAGE_S2_DEVICE);
73 if (ret)
74 break;
75 }
76 --- a/virt/kvm/arm/vgic/vgic-v2.c
77 +++ b/virt/kvm/arm/vgic/vgic-v2.c
78 @@ -341,7 +341,8 @@ int vgic_v2_map_resources(struct kvm *kv
79 if (!static_branch_unlikely(&vgic_v2_cpuif_trap)) {
80 ret = kvm_phys_addr_ioremap(kvm, dist->vgic_cpu_base,
81 kvm_vgic_global_state.vcpu_base,
82 - KVM_VGIC_V2_CPU_SIZE, true);
83 + KVM_VGIC_V2_CPU_SIZE, true,
84 + PAGE_S2_DEVICE);
85 if (ret) {
86 kvm_err("Unable to remap VGIC CPU to VCPU\n");
87 goto out;