tree: https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git kvm-arm64/nv-wip-v5.0-rc1 head: 688c386ca096f2c1f2eee386697586c88df5d5bc commit: fbdecc14dd15c696fd86d28247a9b95b4635b8b1 [44/75] KVM: arm64: nv: Forward the guest hypervisor's stage 2 permission faults config: arm-axm55xx_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout fbdecc14dd15c696fd86d28247a9b95b4635b8b1 # save the attached .config to linux build tree GCC_VERSION=7.2.0 make.cross ARCH=arm All errors (new ones prefixed by >>): ^~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1439:13: note: expected 'struct kvm_s2_mmu *' but argument is of type 'struct kvm_s2_mmu *' static void stage2_wp_pmds(struct kvm_s2_mmu *mmu, pud_t *pud, ^~~~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1472:14: warning: unused variable 'kvm' [-Wunused-variable] struct kvm *kvm = mmu->kvm; ^~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: At top level: arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1496:36: warning: 'struct kvm_s2_mmu' declared inside parameter list will not be visible outside of this definition or declaration static void stage2_wp_range(struct kvm_s2_mmu *mmu, phys_addr_t addr, phys_addr_t end) ^~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'stage2_wp_range': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1498:23: error: dereferencing pointer to incomplete type 'struct kvm_s2_mmu' struct kvm *kvm = mmu->kvm; ^~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1518:19: error: passing argument 1 of 'stage2_wp_puds' from incompatible pointer type [-Werror=incompatible-pointer-types] stage2_wp_puds(mmu, pgd, addr, next); ^~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1469:14: note: expected 'struct kvm_s2_mmu *' but argument is of type 'struct kvm_s2_mmu *' static void stage2_wp_puds(struct kvm_s2_mmu *mmu, pgd_t *pgd, ^~~~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_mmu_wp_memory_region': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1543:28: error: 'struct kvm_arch' has no member named 'mmu' stage2_wp_range(&kvm->arch.mmu, start, end); ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_mmu_write_protect_pt_masked': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1567:28: error: 'struct kvm_arch' has no member named 'mmu' stage2_wp_range(&kvm->arch.mmu, start, end); ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: At top level: arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1665:13: warning: 'struct kvm_s2_trans' declared inside parameter list will not be visible outside of this definition or declaration struct kvm_s2_trans *nested, ^~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'user_mem_abort': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1682:37: error: 'struct kvm_vcpu_arch' has no member named 'hw_mmu' struct kvm_s2_mmu *mmu = vcpu->arch.hw_mmu; ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1709:6: error: implicit declaration of function 'kvm_is_shadow_s2_fault'; did you mean 'kvm_is_write_fault'? [-Werror=implicit-function-declaration] if (kvm_is_shadow_s2_fault(vcpu)) { ^~~~~~~~~~~~~~~~~~~~~~ kvm_is_write_fault arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1710:15: error: dereferencing pointer to incomplete type 'struct kvm_s2_trans' ipa = nested->output; ^~ In file included from include/asm-generic/bug.h:18:0, from arch/arm/include/asm/bug.h:60, from include/linux/bug.h:5, from include/linux/mmdebug.h:5, from include/linux/mm.h:9, from include/linux/mman.h:5, from arch/arm/kvm/../../../virt/kvm/arm/mmu.c:19: include/linux/kernel.h:870:2: error: first argument to '__builtin_choose_expr' not a constant __builtin_choose_expr(__safe_cmp(x, y), \ ^ include/linux/kernel.h:879:19: note: in expansion of macro '__careful_cmp' #define min(x, y) __careful_cmp(x, y, <) ^~~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1717:18: note: in expansion of macro 'min' max_map_size = min(nested->block_size, max_map_size); ^~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1810:47: error: passing argument 1 of 'stage2_is_exec' from incompatible pointer type [-Werror=incompatible-pointer-types] (fault_status == FSC_PERM && stage2_is_exec(mmu, fault_ipa)); ^~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1188:13: note: expected 'struct kvm_s2_mmu *' but argument is of type 'struct kvm_s2_mmu *' static bool stage2_is_exec(struct kvm_s2_mmu *mmu, phys_addr_t addr) ^~~~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1822:29: error: passing argument 1 of 'stage2_set_pud_huge' from incompatible pointer type [-Werror=incompatible-pointer-types] ret = stage2_set_pud_huge(mmu, memcache, fault_ipa, &new_pud); ^~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1112:12: note: expected 'struct kvm_s2_mmu *' but argument is of type 'struct kvm_s2_mmu *' static int stage2_set_pud_huge(struct kvm_s2_mmu *mmu, ^~~~~~~~~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1834:29: error: passing argument 1 of 'stage2_set_pmd_huge' from incompatible pointer type [-Werror=incompatible-pointer-types] ret = stage2_set_pmd_huge(mmu, memcache, fault_ipa, &new_pmd); ^~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1064:12: note: expected 'struct kvm_s2_mmu *' but argument is of type 'struct kvm_s2_mmu *' static int stage2_set_pmd_huge(struct kvm_s2_mmu *mmu, ^~~~~~~~~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1846:24: error: passing argument 1 of 'stage2_set_pte' from incompatible pointer type [-Werror=incompatible-pointer-types] ret = stage2_set_pte(mmu, memcache, fault_ipa, &new_pte, flags); ^~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1207:12: note: expected 'struct kvm_s2_mmu *' but argument is of type 'struct kvm_s2_mmu *' static int stage2_set_pte(struct kvm_s2_mmu *mmu, ^~~~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'handle_access_fault': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1875:39: error: 'struct kvm_vcpu_arch' has no member named 'hw_mmu' if (!stage2_get_leaf_entry(vcpu->arch.hw_mmu, fault_ipa, &pud, &pmd, &pte)) ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_handle_guest_abort': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1916:22: error: storage size of 'nested_trans' isn't known struct kvm_s2_trans nested_trans; ^~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1975:9: error: implicit declaration of function 'kvm_walk_nested_s2'; did you mean 'kvm_inject_nested_irq'? [-Werror=implicit-function-declaration] ret = kvm_walk_nested_s2(vcpu, fault_ipa, &nested_trans); ^~~~~~~~~~~~~~~~~~ kvm_inject_nested_irq arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1977:4: error: implicit declaration of function 'kvm_inject_s2_fault'; did you mean 'kvm_inject_pabt'? [-Werror=implicit-function-declaration] kvm_inject_s2_fault(vcpu, nested_trans.esr); ^~~~~~~~~~~~~~~~~~~ kvm_inject_pabt >> arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1982:9: error: implicit declaration of function 'kvm_s2_handle_perm_fault'; did you mean 'handle_mm_fault'? [-Werror=implicit-function-declaration] ret = kvm_s2_handle_perm_fault(vcpu, fault_ipa, &nested_trans); ^~~~~~~~~~~~~~~~~~~~~~~~ handle_mm_fault arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1916:22: warning: unused variable 'nested_trans' [-Wunused-variable] struct kvm_s2_trans nested_trans; ^~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_unmap_hva_handler': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2082:35: error: 'struct kvm_arch' has no member named 'mmu' kvm_unmap_stage2_range(&kvm->arch.mmu, gpa, size); ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_unmap_hva_range': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2089:16: error: 'struct kvm_arch' has no member named 'mmu' if (!kvm->arch.mmu.pgd) ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_set_spte_handler': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2109:27: error: 'struct kvm_arch' has no member named 'mmu' stage2_set_pte(&kvm->arch.mmu, NULL, gpa, pte, 0); ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_set_spte_hva': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2120:16: error: 'struct kvm_arch' has no member named 'mmu' if (!kvm->arch.mmu.pgd) ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_age_hva_handler': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2143:39: error: 'struct kvm_arch' has no member named 'mmu' if (!stage2_get_leaf_entry(&kvm->arch.mmu, gpa, &pud, &pmd, &pte)) ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_test_age_hva_handler': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2161:39: error: 'struct kvm_arch' has no member named 'mmu' if (!stage2_get_leaf_entry(&kvm->arch.mmu, gpa, &pud, &pmd, &pte)) ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_age_hva': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2174:16: error: 'struct kvm_arch' has no member named 'mmu' if (!kvm->arch.mmu.pgd) ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_test_age_hva': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2182:16: error: 'struct kvm_arch' has no member named 'mmu' if (!kvm->arch.mmu.pgd) ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_arch_prepare_memory_region': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2395:36: error: 'struct kvm_arch' has no member named 'mmu' kvm_unmap_stage2_range(&kvm->arch.mmu, mem->guest_phys_addr, mem->memory_size); ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2397:34: error: 'struct kvm_arch' has no member named 'mmu' stage2_flush_memslot(&kvm->arch.mmu, memslot); ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_arch_flush_shadow_all': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2423:27: error: 'struct kvm_arch' has no member named 'nested_mmus_size' for (i = 0; i < kvm->arch.nested_mmus_size; i++) { ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2424:38: error: 'struct kvm_arch' has no member named 'nested_mmus' struct kvm_s2_mmu *mmu = &kvm->arch.nested_mmus[i]; ^ In file included from arch/arm/include/asm/bug.h:60:0, from include/linux/bug.h:5, from include/linux/mmdebug.h:5, from include/linux/mm.h:9, from include/linux/mman.h:5, from arch/arm/kvm/../../../virt/kvm/arm/mmu.c:19: arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2426:14: error: dereferencing pointer to incomplete type 'struct kvm_s2_mmu' WARN_ON(mmu->usage_count > 0); ^ include/asm-generic/bug.h:122:25: note: in definition of macro 'WARN_ON' int __ret_warn_on = !!(condition); \ ^~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2429:24: error: passing argument 1 of 'kvm_free_stage2_pgd' from incompatible pointer type [-Werror=incompatible-pointer-types] kvm_free_stage2_pgd(mmu); ^~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1005:6: note: expected 'struct kvm_s2_mmu *' but argument is of type 'struct kvm_s2_mmu *' void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu) ^~~~~~~~~~~~~~~~~~~ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2431:17: error: 'struct kvm_arch' has no member named 'nested_mmus' kfree(kvm->arch.nested_mmus); ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2432:11: error: 'struct kvm_arch' has no member named 'nested_mmus' kvm->arch.nested_mmus = NULL; ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2433:11: error: 'struct kvm_arch' has no member named 'nested_mmus_size' kvm->arch.nested_mmus_size = 0; ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2434:32: error: 'struct kvm_arch' has no member named 'mmu' kvm_free_stage2_pgd(&kvm->arch.mmu); ^ arch/arm/kvm/../../../virt/kvm/arm/mmu.c: In function 'kvm_arch_flush_shadow_memslot': arch/arm/kvm/../../../virt/kvm/arm/mmu.c:2444:35: error: 'struct kvm_arch' has no member named 'mmu' kvm_unmap_stage2_range(&kvm->arch.mmu, gpa, size); ^ cc1: some warnings being treated as errors vim +1982 arch/arm/kvm/../../../virt/kvm/arm/mmu.c 1897 1898 /** 1899 * kvm_handle_guest_abort - handles all 2nd stage aborts 1900 * @vcpu: the VCPU pointer 1901 * @run: the kvm_run structure 1902 * 1903 * Any abort that gets to the host is almost guaranteed to be caused by a 1904 * missing second stage translation table entry, which can mean that either the 1905 * guest simply needs more memory and we must allocate an appropriate page or it 1906 * can mean that the guest tried to access I/O memory, which is emulated by user 1907 * space. The distinction is based on the IPA causing the fault and whether this 1908 * memory region has been registered as standard RAM by user space. 1909 */ 1910 int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run) 1911 { 1912 unsigned long fault_status; 1913 phys_addr_t fault_ipa; /* The address we faulted on */ 1914 phys_addr_t ipa; /* Always the IPA in the L1 guest phys space */ 1915 struct kvm_memory_slot *memslot; 1916 struct kvm_s2_trans nested_trans; 1917 unsigned long hva; 1918 bool is_iabt, write_fault, writable; 1919 gfn_t gfn; 1920 int ret, idx; 1921 1922 fault_status = kvm_vcpu_trap_get_fault_type(vcpu); 1923 1924 fault_ipa = kvm_vcpu_get_fault_ipa(vcpu); 1925 ipa = fault_ipa = kvm_vcpu_get_fault_ipa(vcpu); 1926 is_iabt = kvm_vcpu_trap_is_iabt(vcpu); 1927 1928 /* Synchronous External Abort? */ 1929 if (kvm_vcpu_dabt_isextabt(vcpu)) { 1930 /* 1931 * For RAS the host kernel may handle this abort. 1932 * There is no need to pass the error into the guest. 1933 */ 1934 if (!handle_guest_sea(fault_ipa, kvm_vcpu_get_hsr(vcpu))) 1935 return 1; 1936 1937 if (unlikely(!is_iabt)) { 1938 kvm_inject_vabt(vcpu); 1939 return 1; 1940 } 1941 } 1942 1943 trace_kvm_guest_fault(*vcpu_pc(vcpu), kvm_vcpu_get_hsr(vcpu), 1944 kvm_vcpu_get_hfar(vcpu), fault_ipa); 1945 1946 /* Check the stage-2 fault is trans. fault or write fault */ 1947 if (fault_status != FSC_FAULT && fault_status != FSC_PERM && 1948 fault_status != FSC_ACCESS) { 1949 /* 1950 * We must never see an address size fault on shadow stage 2 1951 * page table walk, because we would have injected an addr 1952 * size fault when we walked the nested s2 page and not 1953 * create the shadow entry. 1954 */ 1955 kvm_err("Unsupported FSC: EC=%#x xFSC=%#lx ESR_EL2=%#lx\n", 1956 kvm_vcpu_trap_get_class(vcpu), 1957 (unsigned long)kvm_vcpu_trap_get_fault(vcpu), 1958 (unsigned long)kvm_vcpu_get_hsr(vcpu)); 1959 return -EFAULT; 1960 } 1961 1962 idx = srcu_read_lock(&vcpu->kvm->srcu); 1963 1964 /* 1965 * We may have faulted on a shadow stage 2 page table if we are 1966 * running a nested guest. In this case, we have to resovle the L2 1967 * IPA to the L1 IPA first, before knowing what kind of memory should 1968 * back the L1 IPA. 1969 * 1970 * If the shadow stage 2 page table walk faults, then we simply inject 1971 * this to the guest and carry on. 1972 */ 1973 if (kvm_is_shadow_s2_fault(vcpu)) { 1974 nested_trans.esr = 0; > 1975 ret = kvm_walk_nested_s2(vcpu, fault_ipa, &nested_trans); 1976 if (nested_trans.esr) 1977 kvm_inject_s2_fault(vcpu, nested_trans.esr); 1978 if (ret) 1979 goto out_unlock; 1980 1981 nested_trans.esr = 0; > 1982 ret = kvm_s2_handle_perm_fault(vcpu, fault_ipa, &nested_trans); 1983 if (nested_trans.esr) 1984 kvm_inject_s2_fault(vcpu, nested_trans.esr); 1985 if (ret) 1986 goto out_unlock; 1987 1988 ipa = nested_trans.output; 1989 } 1990 1991 gfn = ipa >> PAGE_SHIFT; 1992 memslot = gfn_to_memslot(vcpu->kvm, gfn); 1993 hva = gfn_to_hva_memslot_prot(memslot, gfn, &writable); 1994 write_fault = kvm_is_write_fault(vcpu); 1995 if (kvm_is_error_hva(hva) || (write_fault && !writable)) { 1996 if (is_iabt) { 1997 /* Prefetch Abort on I/O address */ 1998 kvm_inject_pabt(vcpu, kvm_vcpu_get_hfar(vcpu)); 1999 ret = 1; 2000 goto out_unlock; 2001 } 2002 2003 /* 2004 * Check for a cache maintenance operation. Since we 2005 * ended-up here, we know it is outside of any memory 2006 * slot. But we can't find out if that is for a device, 2007 * or if the guest is just being stupid. The only thing 2008 * we know for sure is that this range cannot be cached. 2009 * 2010 * So let's assume that the guest is just being 2011 * cautious, and skip the instruction. 2012 */ 2013 if (kvm_vcpu_dabt_is_cm(vcpu)) { 2014 kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); 2015 ret = 1; 2016 goto out_unlock; 2017 } 2018 2019 /* 2020 * The IPA is reported as [MAX:12], so we need to 2021 * complement it with the bottom 12 bits from the 2022 * faulting VA. This is always 12 bits, irrespective 2023 * of the page size. 2024 */ 2025 ipa |= kvm_vcpu_get_hfar(vcpu) & ((1 << 12) - 1); 2026 ret = io_mem_abort(vcpu, run, ipa); 2027 goto out_unlock; 2028 } 2029 2030 /* Userspace should not be able to register out-of-bounds IPAs */ 2031 VM_BUG_ON(ipa >= kvm_phys_size(vcpu->kvm)); 2032 2033 if (fault_status == FSC_ACCESS) { 2034 handle_access_fault(vcpu, fault_ipa); 2035 ret = 1; 2036 goto out_unlock; 2037 } 2038 2039 ret = user_mem_abort(vcpu, fault_ipa, &nested_trans, 2040 memslot, hva, fault_status); 2041 if (ret == 0) 2042 ret = 1; 2043 out_unlock: 2044 srcu_read_unlock(&vcpu->kvm->srcu, idx); 2045 return ret; 2046 } 2047 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Attachment:
.config.gz
Description: application/gzip
_______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm