Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull KVM fixes from Paolo Bonzini:
"Fixes for interrupt controller emulation in ARM/ARM64 and x86, plus a
one-liner x86 KVM guest fix"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: x86: Update APICv on APIC reset
KVM: VMX: Do not fully reset PI descriptor on vCPU reset
kvm: Return -ENODEV from update_persistent_clock
KVM: arm/arm64: vgic-its: Check GITS_BASER Valid bit before saving tables
KVM: arm/arm64: vgic-its: Check CBASER/BASER validity before enabling the ITS
KVM: arm/arm64: vgic-its: Fix vgic_its_restore_collection_table returned value
KVM: arm/arm64: vgic-its: Fix return value for device table restore
arm/arm64: kvm: Disable branch profiling in HYP code
arm/arm64: kvm: Move initialization completion message
arm/arm64: KVM: set right LR register value for 32 bit guest when inject abort
KVM: arm64: its: Fix missing dynamic allocation check in scan_its_table

+87 -53
+2 -4
arch/arm/kvm/emulate.c
··· 227 227 u32 return_offset = (is_thumb) ? 2 : 4; 228 228 229 229 kvm_update_psr(vcpu, UND_MODE); 230 - *vcpu_reg(vcpu, 14) = *vcpu_pc(vcpu) - return_offset; 230 + *vcpu_reg(vcpu, 14) = *vcpu_pc(vcpu) + return_offset; 231 231 232 232 /* Branch to exception vector */ 233 233 *vcpu_pc(vcpu) = exc_vector_base(vcpu) + vect_offset; ··· 239 239 */ 240 240 static void inject_abt(struct kvm_vcpu *vcpu, bool is_pabt, unsigned long addr) 241 241 { 242 - unsigned long cpsr = *vcpu_cpsr(vcpu); 243 - bool is_thumb = (cpsr & PSR_T_BIT); 244 242 u32 vect_offset; 245 - u32 return_offset = (is_thumb) ? 4 : 0; 243 + u32 return_offset = (is_pabt) ? 4 : 8; 246 244 bool is_lpae; 247 245 248 246 kvm_update_psr(vcpu, ABT_MODE);
+1 -1
arch/arm/kvm/hyp/Makefile
··· 3 3 # Makefile for Kernel-based Virtual Machine module, HYP part 4 4 # 5 5 6 - ccflags-y += -fno-stack-protector 6 + ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING 7 7 8 8 KVM=../../../../virt/kvm 9 9
+1 -1
arch/arm64/kvm/hyp/Makefile
··· 3 3 # Makefile for Kernel-based Virtual Machine module, HYP part 4 4 # 5 5 6 - ccflags-y += -fno-stack-protector 6 + ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING 7 7 8 8 KVM=../../../../virt/kvm 9 9
+15 -1
arch/arm64/kvm/inject_fault.c
··· 33 33 #define LOWER_EL_AArch64_VECTOR 0x400 34 34 #define LOWER_EL_AArch32_VECTOR 0x600 35 35 36 + /* 37 + * Table taken from ARMv8 ARM DDI0487B-B, table G1-10. 38 + */ 39 + static const u8 return_offsets[8][2] = { 40 + [0] = { 0, 0 }, /* Reset, unused */ 41 + [1] = { 4, 2 }, /* Undefined */ 42 + [2] = { 0, 0 }, /* SVC, unused */ 43 + [3] = { 4, 4 }, /* Prefetch abort */ 44 + [4] = { 8, 8 }, /* Data abort */ 45 + [5] = { 0, 0 }, /* HVC, unused */ 46 + [6] = { 4, 4 }, /* IRQ, unused */ 47 + [7] = { 4, 4 }, /* FIQ, unused */ 48 + }; 49 + 36 50 static void prepare_fault32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset) 37 51 { 38 52 unsigned long cpsr; 39 53 unsigned long new_spsr_value = *vcpu_cpsr(vcpu); 40 54 bool is_thumb = (new_spsr_value & COMPAT_PSR_T_BIT); 41 - u32 return_offset = (is_thumb) ? 4 : 0; 55 + u32 return_offset = return_offsets[vect_offset >> 2][is_thumb]; 42 56 u32 sctlr = vcpu_cp15(vcpu, c1_SCTLR); 43 57 44 58 cpsr = mode | COMPAT_PSR_I_BIT;
+1 -1
arch/x86/kernel/kvmclock.c
··· 79 79 80 80 static int kvm_set_wallclock(const struct timespec *now) 81 81 { 82 - return -1; 82 + return -ENODEV; 83 83 } 84 84 85 85 static u64 kvm_clock_read(void)
+5
arch/x86/kvm/lapic.c
··· 1992 1992 vcpu->arch.apic_base | MSR_IA32_APICBASE_BSP); 1993 1993 vcpu->arch.pv_eoi.msr_val = 0; 1994 1994 apic_update_ppr(apic); 1995 + if (vcpu->arch.apicv_active) { 1996 + kvm_x86_ops->apicv_post_state_restore(vcpu); 1997 + kvm_x86_ops->hwapic_irr_update(vcpu, -1); 1998 + kvm_x86_ops->hwapic_isr_update(vcpu, -1); 1999 + } 1995 2000 1996 2001 vcpu->arch.apic_arb_prio = 0; 1997 2002 vcpu->arch.apic_attention = 0;
-3
arch/x86/kvm/vmx.c
··· 5619 5619 5620 5620 kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu); 5621 5621 5622 - if (kvm_vcpu_apicv_active(vcpu)) 5623 - memset(&vmx->pi_desc, 0, sizeof(struct pi_desc)); 5624 - 5625 5622 if (vmx->vpid != 0) 5626 5623 vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); 5627 5624
+14 -17
virt/kvm/arm/arm.c
··· 1326 1326 { 1327 1327 int cpu; 1328 1328 1329 - if (is_kernel_in_hyp_mode()) 1330 - return; 1331 - 1332 1329 free_hyp_pgds(); 1333 1330 for_each_possible_cpu(cpu) 1334 1331 free_page(per_cpu(kvm_arm_hyp_stack_page, cpu)); 1335 1332 hyp_cpu_pm_exit(); 1336 - } 1337 - 1338 - static int init_vhe_mode(void) 1339 - { 1340 - kvm_info("VHE mode initialized successfully\n"); 1341 - return 0; 1342 1333 } 1343 1334 1344 1335 /** ··· 1412 1421 } 1413 1422 } 1414 1423 1415 - kvm_info("Hyp mode initialized successfully\n"); 1416 - 1417 1424 return 0; 1418 1425 1419 1426 out_err: ··· 1445 1456 { 1446 1457 int err; 1447 1458 int ret, cpu; 1459 + bool in_hyp_mode; 1448 1460 1449 1461 if (!is_hyp_mode_available()) { 1450 1462 kvm_err("HYP mode not available\n"); ··· 1464 1474 if (err) 1465 1475 return err; 1466 1476 1467 - if (is_kernel_in_hyp_mode()) 1468 - err = init_vhe_mode(); 1469 - else 1477 + in_hyp_mode = is_kernel_in_hyp_mode(); 1478 + 1479 + if (!in_hyp_mode) { 1470 1480 err = init_hyp_mode(); 1471 - if (err) 1472 - goto out_err; 1481 + if (err) 1482 + goto out_err; 1483 + } 1473 1484 1474 1485 err = init_subsystems(); 1475 1486 if (err) 1476 1487 goto out_hyp; 1477 1488 1489 + if (in_hyp_mode) 1490 + kvm_info("VHE mode initialized successfully\n"); 1491 + else 1492 + kvm_info("Hyp mode initialized successfully\n"); 1493 + 1478 1494 return 0; 1479 1495 1480 1496 out_hyp: 1481 - teardown_hyp_mode(); 1497 + if (!in_hyp_mode) 1498 + teardown_hyp_mode(); 1482 1499 out_err: 1483 1500 teardown_common_resources(); 1484 1501 return err;
+48 -25
virt/kvm/arm/vgic/vgic-its.c
··· 1466 1466 { 1467 1467 mutex_lock(&its->cmd_lock); 1468 1468 1469 + /* 1470 + * It is UNPREDICTABLE to enable the ITS if any of the CBASER or 1471 + * device/collection BASER are invalid 1472 + */ 1473 + if (!its->enabled && (val & GITS_CTLR_ENABLE) && 1474 + (!(its->baser_device_table & GITS_BASER_VALID) || 1475 + !(its->baser_coll_table & GITS_BASER_VALID) || 1476 + !(its->cbaser & GITS_CBASER_VALID))) 1477 + goto out; 1478 + 1469 1479 its->enabled = !!(val & GITS_CTLR_ENABLE); 1470 1480 1471 1481 /* ··· 1484 1474 */ 1485 1475 vgic_its_process_commands(kvm, its); 1486 1476 1477 + out: 1487 1478 mutex_unlock(&its->cmd_lock); 1488 1479 } 1489 1480 ··· 1812 1801 static int scan_its_table(struct vgic_its *its, gpa_t base, int size, int esz, 1813 1802 int start_id, entry_fn_t fn, void *opaque) 1814 1803 { 1815 - void *entry = kzalloc(esz, GFP_KERNEL); 1816 1804 struct kvm *kvm = its->dev->kvm; 1817 1805 unsigned long len = size; 1818 1806 int id = start_id; 1819 1807 gpa_t gpa = base; 1808 + char entry[esz]; 1820 1809 int ret; 1810 + 1811 + memset(entry, 0, esz); 1821 1812 1822 1813 while (len > 0) { 1823 1814 int next_offset; ··· 1827 1814 1828 1815 ret = kvm_read_guest(kvm, gpa, entry, esz); 1829 1816 if (ret) 1830 - goto out; 1817 + return ret; 1831 1818 1832 1819 next_offset = fn(its, id, entry, opaque); 1833 - if (next_offset <= 0) { 1834 - ret = next_offset; 1835 - goto out; 1836 - } 1820 + if (next_offset <= 0) 1821 + return next_offset; 1837 1822 1838 1823 byte_offset = next_offset * esz; 1839 1824 id += next_offset; 1840 1825 gpa += byte_offset; 1841 1826 len -= byte_offset; 1842 1827 } 1843 - ret = 1; 1844 - 1845 - out: 1846 - kfree(entry); 1847 - return ret; 1828 + return 1; 1848 1829 } 1849 1830 1850 1831 /** ··· 1947 1940 return 0; 1948 1941 } 1949 1942 1943 + /** 1944 + * vgic_its_restore_itt - restore the ITT of a device 1945 + * 1946 + * @its: its handle 1947 + * @dev: device handle 1948 + * 1949 + * Return 0 on success, < 0 on error 1950 + */ 1950 1951 static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev) 1951 1952 { 1952 1953 const struct vgic_its_abi *abi = vgic_its_get_abi(its); ··· 1965 1950 1966 1951 ret = scan_its_table(its, base, max_size, ite_esz, 0, 1967 1952 vgic_its_restore_ite, dev); 1953 + 1954 + /* scan_its_table returns +1 if all ITEs are invalid */ 1955 + if (ret > 0) 1956 + ret = 0; 1968 1957 1969 1958 return ret; 1970 1959 } ··· 2067 2048 static int vgic_its_save_device_tables(struct vgic_its *its) 2068 2049 { 2069 2050 const struct vgic_its_abi *abi = vgic_its_get_abi(its); 2051 + u64 baser = its->baser_device_table; 2070 2052 struct its_device *dev; 2071 2053 int dte_esz = abi->dte_esz; 2072 - u64 baser; 2073 2054 2074 - baser = its->baser_device_table; 2055 + if (!(baser & GITS_BASER_VALID)) 2056 + return 0; 2075 2057 2076 2058 list_sort(NULL, &its->device_list, vgic_its_device_cmp); 2077 2059 ··· 2127 2107 ret = scan_its_table(its, gpa, SZ_64K, dte_esz, 2128 2108 l2_start_id, vgic_its_restore_dte, NULL); 2129 2109 2130 - if (ret <= 0) 2131 - return ret; 2132 - 2133 - return 1; 2110 + return ret; 2134 2111 } 2135 2112 2136 2113 /** ··· 2157 2140 vgic_its_restore_dte, NULL); 2158 2141 } 2159 2142 2143 + /* scan_its_table returns +1 if all entries are invalid */ 2160 2144 if (ret > 0) 2161 - ret = -EINVAL; 2145 + ret = 0; 2162 2146 2163 2147 return ret; 2164 2148 } ··· 2216 2198 static int vgic_its_save_collection_table(struct vgic_its *its) 2217 2199 { 2218 2200 const struct vgic_its_abi *abi = vgic_its_get_abi(its); 2201 + u64 baser = its->baser_coll_table; 2202 + gpa_t gpa = BASER_ADDRESS(baser); 2219 2203 struct its_collection *collection; 2220 2204 u64 val; 2221 - gpa_t gpa; 2222 2205 size_t max_size, filled = 0; 2223 2206 int ret, cte_esz = abi->cte_esz; 2224 2207 2225 - gpa = BASER_ADDRESS(its->baser_coll_table); 2226 - if (!gpa) 2208 + if (!(baser & GITS_BASER_VALID)) 2227 2209 return 0; 2228 2210 2229 - max_size = GITS_BASER_NR_PAGES(its->baser_coll_table) * SZ_64K; 2211 + max_size = GITS_BASER_NR_PAGES(baser) * SZ_64K; 2230 2212 2231 2213 list_for_each_entry(collection, &its->collection_list, coll_list) { 2232 2214 ret = vgic_its_save_cte(its, collection, gpa, cte_esz); ··· 2257 2239 static int vgic_its_restore_collection_table(struct vgic_its *its) 2258 2240 { 2259 2241 const struct vgic_its_abi *abi = vgic_its_get_abi(its); 2242 + u64 baser = its->baser_coll_table; 2260 2243 int cte_esz = abi->cte_esz; 2261 2244 size_t max_size, read = 0; 2262 2245 gpa_t gpa; 2263 2246 int ret; 2264 2247 2265 - if (!(its->baser_coll_table & GITS_BASER_VALID)) 2248 + if (!(baser & GITS_BASER_VALID)) 2266 2249 return 0; 2267 2250 2268 - gpa = BASER_ADDRESS(its->baser_coll_table); 2251 + gpa = BASER_ADDRESS(baser); 2269 2252 2270 - max_size = GITS_BASER_NR_PAGES(its->baser_coll_table) * SZ_64K; 2253 + max_size = GITS_BASER_NR_PAGES(baser) * SZ_64K; 2271 2254 2272 2255 while (read < max_size) { 2273 2256 ret = vgic_its_restore_cte(its, gpa, cte_esz); ··· 2277 2258 gpa += cte_esz; 2278 2259 read += cte_esz; 2279 2260 } 2261 + 2262 + if (ret > 0) 2263 + return 0; 2264 + 2280 2265 return ret; 2281 2266 } 2282 2267