arm.c (8a5eb2d210807e7dbe9ece7075533014cf4b9c27) | arm.c (52882b9c7a761b2b4e44717d6fbd1ed94c601b7f) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2012 - Virtual Open Systems and Columbia University 4 * Author: Christoffer Dall <c.dall@virtualopensystems.com> 5 */ 6 7#include <linux/bug.h> 8#include <linux/cpu_pm.h> --- 134 unchanged lines hidden (view full) --- 143 cpumask_copy(kvm->arch.supported_cpus, cpu_possible_mask); 144 145 ret = kvm_init_stage2_mmu(kvm, &kvm->arch.mmu, type); 146 if (ret) 147 goto err_free_cpumask; 148 149 kvm_vgic_early_init(kvm); 150 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2012 - Virtual Open Systems and Columbia University 4 * Author: Christoffer Dall <c.dall@virtualopensystems.com> 5 */ 6 7#include <linux/bug.h> 8#include <linux/cpu_pm.h> --- 134 unchanged lines hidden (view full) --- 143 cpumask_copy(kvm->arch.supported_cpus, cpu_possible_mask); 144 145 ret = kvm_init_stage2_mmu(kvm, &kvm->arch.mmu, type); 146 if (ret) 147 goto err_free_cpumask; 148 149 kvm_vgic_early_init(kvm); 150 |
151 kvm_timer_init_vm(kvm); 152 | |
153 /* The maximum number of VCPUs is limited by the host's GIC model */ 154 kvm->max_vcpus = kvm_arm_default_max_vcpus(); 155 156 set_default_spectre(kvm); 157 kvm_arm_init_hypercalls(kvm); 158 159 /* 160 * Initialise the default PMUver before there is a chance to --- 56 unchanged lines hidden (view full) --- 217 case KVM_CAP_VCPU_EVENTS: 218 case KVM_CAP_ARM_IRQ_LINE_LAYOUT_2: 219 case KVM_CAP_ARM_NISV_TO_USER: 220 case KVM_CAP_ARM_INJECT_EXT_DABT: 221 case KVM_CAP_SET_GUEST_DEBUG: 222 case KVM_CAP_VCPU_ATTRIBUTES: 223 case KVM_CAP_PTP_KVM: 224 case KVM_CAP_ARM_SYSTEM_SUSPEND: | 151 /* The maximum number of VCPUs is limited by the host's GIC model */ 152 kvm->max_vcpus = kvm_arm_default_max_vcpus(); 153 154 set_default_spectre(kvm); 155 kvm_arm_init_hypercalls(kvm); 156 157 /* 158 * Initialise the default PMUver before there is a chance to --- 56 unchanged lines hidden (view full) --- 215 case KVM_CAP_VCPU_EVENTS: 216 case KVM_CAP_ARM_IRQ_LINE_LAYOUT_2: 217 case KVM_CAP_ARM_NISV_TO_USER: 218 case KVM_CAP_ARM_INJECT_EXT_DABT: 219 case KVM_CAP_SET_GUEST_DEBUG: 220 case KVM_CAP_VCPU_ATTRIBUTES: 221 case KVM_CAP_PTP_KVM: 222 case KVM_CAP_ARM_SYSTEM_SUSPEND: |
225 case KVM_CAP_COUNTER_OFFSET: | 223 case KVM_CAP_IRQFD_RESAMPLE: |
226 r = 1; 227 break; 228 case KVM_CAP_SET_GUEST_DEBUG2: 229 return KVM_GUESTDBG_VALID_MASK; 230 case KVM_CAP_ARM_SET_DEVICE_ADDR: 231 r = 1; 232 break; 233 case KVM_CAP_NR_VCPUS: --- 1243 unchanged lines hidden (view full) --- 1477 } 1478 case KVM_ARM_MTE_COPY_TAGS: { 1479 struct kvm_arm_copy_mte_tags copy_tags; 1480 1481 if (copy_from_user(©_tags, argp, sizeof(copy_tags))) 1482 return -EFAULT; 1483 return kvm_vm_ioctl_mte_copy_tags(kvm, ©_tags); 1484 } | 224 r = 1; 225 break; 226 case KVM_CAP_SET_GUEST_DEBUG2: 227 return KVM_GUESTDBG_VALID_MASK; 228 case KVM_CAP_ARM_SET_DEVICE_ADDR: 229 r = 1; 230 break; 231 case KVM_CAP_NR_VCPUS: --- 1243 unchanged lines hidden (view full) --- 1475 } 1476 case KVM_ARM_MTE_COPY_TAGS: { 1477 struct kvm_arm_copy_mte_tags copy_tags; 1478 1479 if (copy_from_user(©_tags, argp, sizeof(copy_tags))) 1480 return -EFAULT; 1481 return kvm_vm_ioctl_mte_copy_tags(kvm, ©_tags); 1482 } |
1485 case KVM_ARM_SET_COUNTER_OFFSET: { 1486 struct kvm_arm_counter_offset offset; 1487 1488 if (copy_from_user(&offset, argp, sizeof(offset))) 1489 return -EFAULT; 1490 return kvm_vm_ioctl_set_counter_offset(kvm, &offset); 1491 } | |
1492 default: 1493 return -EINVAL; 1494 } 1495} 1496 | 1483 default: 1484 return -EINVAL; 1485 } 1486} 1487 |
1497/* unlocks vcpus from @vcpu_lock_idx and smaller */ 1498static void unlock_vcpus(struct kvm *kvm, int vcpu_lock_idx) 1499{ 1500 struct kvm_vcpu *tmp_vcpu; 1501 1502 for (; vcpu_lock_idx >= 0; vcpu_lock_idx--) { 1503 tmp_vcpu = kvm_get_vcpu(kvm, vcpu_lock_idx); 1504 mutex_unlock(&tmp_vcpu->mutex); 1505 } 1506} 1507 1508void unlock_all_vcpus(struct kvm *kvm) 1509{ 1510 lockdep_assert_held(&kvm->lock); 1511 1512 unlock_vcpus(kvm, atomic_read(&kvm->online_vcpus) - 1); 1513} 1514 1515/* Returns true if all vcpus were locked, false otherwise */ 1516bool lock_all_vcpus(struct kvm *kvm) 1517{ 1518 struct kvm_vcpu *tmp_vcpu; 1519 unsigned long c; 1520 1521 lockdep_assert_held(&kvm->lock); 1522 1523 /* 1524 * Any time a vcpu is in an ioctl (including running), the 1525 * core KVM code tries to grab the vcpu->mutex. 1526 * 1527 * By grabbing the vcpu->mutex of all VCPUs we ensure that no 1528 * other VCPUs can fiddle with the state while we access it. 1529 */ 1530 kvm_for_each_vcpu(c, tmp_vcpu, kvm) { 1531 if (!mutex_trylock(&tmp_vcpu->mutex)) { 1532 unlock_vcpus(kvm, c - 1); 1533 return false; 1534 } 1535 } 1536 1537 return true; 1538} 1539 | |
1540static unsigned long nvhe_percpu_size(void) 1541{ 1542 return (unsigned long)CHOOSE_NVHE_SYM(__per_cpu_end) - 1543 (unsigned long)CHOOSE_NVHE_SYM(__per_cpu_start); 1544} 1545 1546static unsigned long nvhe_percpu_order(void) 1547{ --- 845 unchanged lines hidden --- | 1488static unsigned long nvhe_percpu_size(void) 1489{ 1490 return (unsigned long)CHOOSE_NVHE_SYM(__per_cpu_end) - 1491 (unsigned long)CHOOSE_NVHE_SYM(__per_cpu_start); 1492} 1493 1494static unsigned long nvhe_percpu_order(void) 1495{ --- 845 unchanged lines hidden --- |