Skip to content

Commit 022d3f0

Browse files
committed
Merge branch kvm-arm64/misc into kvmarm/next
* kvm-arm64/misc: : Miscellaneous updates : : - Convert CPACR_EL1_TTA to the new, generated system register : definitions. : : - Serialize toggling CPACR_EL1.SMEN to avoid unexpected exceptions when : accessing SVCR in the host. : : - Avoid quiescing the guest if a vCPU accesses its own redistributor's : SGIs/PPIs, eliminating the need to IPI. Largely an optimization for : nested virtualization, as the L1 accesses the affected registers : rather often. : : - Conversion to kstrtobool() : : - Common definition of INVALID_GPA across architectures : : - Enable CONFIG_USERFAULTFD for CI runs of KVM selftests KVM: arm64: Fix non-kerneldoc comments KVM: selftests: Enable USERFAULTFD KVM: selftests: Remove redundant setbuf() arm64/sysreg: clean up some inconsistent indenting KVM: MMU: Make the definition of 'INVALID_GPA' common KVM: arm64: vgic-v3: Use kstrtobool() instead of strtobool() KVM: arm64: vgic-v3: Limit IPI-ing when accessing GICR_{C,S}ACTIVER0 KVM: arm64: Synchronize SMEN on vcpu schedule out KVM: arm64: Kill CPACR_EL1_TTA definition Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
2 parents e4f7417 + 67d953d commit 022d3f0

15 files changed

Lines changed: 27 additions & 33 deletions

File tree

arch/arm64/include/asm/kvm_arm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@
347347
ECN(SOFTSTP_CUR), ECN(WATCHPT_LOW), ECN(WATCHPT_CUR), \
348348
ECN(BKPT32), ECN(VECTOR32), ECN(BRK64)
349349

350-
#define CPACR_EL1_TTA (1 << 28)
351350
#define CPACR_EL1_DEFAULT (CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN |\
352351
CPACR_EL1_ZEN_EL1EN)
353352

arch/arm64/include/asm/kvm_host.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,12 @@ void kvm_arm_vmid_clear_active(void);
918918

919919
static inline void kvm_arm_pvtime_vcpu_init(struct kvm_vcpu_arch *vcpu_arch)
920920
{
921-
vcpu_arch->steal.base = GPA_INVALID;
921+
vcpu_arch->steal.base = INVALID_GPA;
922922
}
923923

924924
static inline bool kvm_arm_is_pvtime_enabled(struct kvm_vcpu_arch *vcpu_arch)
925925
{
926-
return (vcpu_arch->steal.base != GPA_INVALID);
926+
return (vcpu_arch->steal.base != INVALID_GPA);
927927
}
928928

929929
void kvm_set_sei_esr(struct kvm_vcpu *vcpu, u64 syndrome);

arch/arm64/kvm/arm.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,9 +1922,7 @@ static int __init kvm_hyp_init_protection(u32 hyp_va_bits)
19221922
return 0;
19231923
}
19241924

1925-
/**
1926-
* Inits Hyp-mode on all online CPUs
1927-
*/
1925+
/* Inits Hyp-mode on all online CPUs */
19281926
static int __init init_hyp_mode(void)
19291927
{
19301928
u32 hyp_va_bits;
@@ -2200,9 +2198,7 @@ void kvm_arch_irq_bypass_start(struct irq_bypass_consumer *cons)
22002198
kvm_arm_resume_guest(irqfd->kvm);
22012199
}
22022200

2203-
/**
2204-
* Initialize Hyp-mode and memory mappings on all CPUs.
2205-
*/
2201+
/* Initialize Hyp-mode and memory mappings on all CPUs */
22062202
static __init int kvm_arm_init(void)
22072203
{
22082204
int err;

arch/arm64/kvm/fpsimd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
184184
sysreg_clear_set(CPACR_EL1,
185185
CPACR_EL1_SMEN_EL0EN,
186186
CPACR_EL1_SMEN_EL1EN);
187+
isb();
187188
}
188189

189190
if (vcpu->arch.fp_state == FP_STATE_GUEST_OWNED) {

arch/arm64/kvm/hyp/vhe/switch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
4040
___activate_traps(vcpu);
4141

4242
val = read_sysreg(cpacr_el1);
43-
val |= CPACR_EL1_TTA;
43+
val |= CPACR_ELx_TTA;
4444
val &= ~(CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN |
4545
CPACR_EL1_SMEN_EL0EN | CPACR_EL1_SMEN_EL1EN);
4646

arch/arm64/kvm/hypercalls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
198198
break;
199199
case ARM_SMCCC_HV_PV_TIME_ST:
200200
gpa = kvm_init_stolen_time(vcpu);
201-
if (gpa != GPA_INVALID)
201+
if (gpa != INVALID_GPA)
202202
val[0] = gpa;
203203
break;
204204
case ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID:

arch/arm64/kvm/pvtime.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void kvm_update_stolen_time(struct kvm_vcpu *vcpu)
1919
u64 steal = 0;
2020
int idx;
2121

22-
if (base == GPA_INVALID)
22+
if (base == INVALID_GPA)
2323
return;
2424

2525
idx = srcu_read_lock(&kvm->srcu);
@@ -40,7 +40,7 @@ long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu)
4040
switch (feature) {
4141
case ARM_SMCCC_HV_PV_TIME_FEATURES:
4242
case ARM_SMCCC_HV_PV_TIME_ST:
43-
if (vcpu->arch.steal.base != GPA_INVALID)
43+
if (vcpu->arch.steal.base != INVALID_GPA)
4444
val = SMCCC_RET_SUCCESS;
4545
break;
4646
}
@@ -54,7 +54,7 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu)
5454
struct kvm *kvm = vcpu->kvm;
5555
u64 base = vcpu->arch.steal.base;
5656

57-
if (base == GPA_INVALID)
57+
if (base == INVALID_GPA)
5858
return base;
5959

6060
/*
@@ -89,7 +89,7 @@ int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu,
8989
return -EFAULT;
9090
if (!IS_ALIGNED(ipa, 64))
9191
return -EINVAL;
92-
if (vcpu->arch.steal.base != GPA_INVALID)
92+
if (vcpu->arch.steal.base != INVALID_GPA)
9393
return -EEXIST;
9494

9595
/* Check the address is in a valid memslot */

arch/arm64/kvm/sys_regs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void vcpu_write_sys_reg(struct kvm_vcpu *vcpu, u64 val, int reg)
7979
__vcpu_write_sys_reg_to_cpu(val, reg))
8080
return;
8181

82-
__vcpu_sys_reg(vcpu, reg) = val;
82+
__vcpu_sys_reg(vcpu, reg) = val;
8383
}
8484

8585
/* CSSELR values; used to index KVM_REG_ARM_DEMUX_ID_CCSIDR */

arch/arm64/kvm/vgic/vgic-mmio.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,10 @@ int vgic_uaccess_write_cpending(struct kvm_vcpu *vcpu,
473473
* active state can be overwritten when the VCPU's state is synced coming back
474474
* from the guest.
475475
*
476-
* For shared interrupts as well as GICv3 private interrupts, we have to
477-
* stop all the VCPUs because interrupts can be migrated while we don't hold
478-
* the IRQ locks and we don't want to be chasing moving targets.
476+
* For shared interrupts as well as GICv3 private interrupts accessed from the
477+
* non-owning CPU, we have to stop all the VCPUs because interrupts can be
478+
* migrated while we don't hold the IRQ locks and we don't want to be chasing
479+
* moving targets.
479480
*
480481
* For GICv2 private interrupts we don't have to do anything because
481482
* userspace accesses to the VGIC state already require all VCPUs to be
@@ -484,15 +485,17 @@ int vgic_uaccess_write_cpending(struct kvm_vcpu *vcpu,
484485
*/
485486
static void vgic_access_active_prepare(struct kvm_vcpu *vcpu, u32 intid)
486487
{
487-
if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3 ||
488+
if ((vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3 &&
489+
vcpu != kvm_get_running_vcpu()) ||
488490
intid >= VGIC_NR_PRIVATE_IRQS)
489491
kvm_arm_halt_guest(vcpu->kvm);
490492
}
491493

492494
/* See vgic_access_active_prepare */
493495
static void vgic_access_active_finish(struct kvm_vcpu *vcpu, u32 intid)
494496
{
495-
if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3 ||
497+
if ((vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3 &&
498+
vcpu != kvm_get_running_vcpu()) ||
496499
intid >= VGIC_NR_PRIVATE_IRQS)
497500
kvm_arm_resume_guest(vcpu->kvm);
498501
}

arch/arm64/kvm/vgic/vgic-v3.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/irqchip/arm-gic-v3.h>
44
#include <linux/irq.h>
55
#include <linux/irqdomain.h>
6+
#include <linux/kstrtox.h>
67
#include <linux/kvm.h>
78
#include <linux/kvm_host.h>
89
#include <kvm/arm_vgic.h>
@@ -587,25 +588,25 @@ DEFINE_STATIC_KEY_FALSE(vgic_v3_cpuif_trap);
587588

588589
static int __init early_group0_trap_cfg(char *buf)
589590
{
590-
return strtobool(buf, &group0_trap);
591+
return kstrtobool(buf, &group0_trap);
591592
}
592593
early_param("kvm-arm.vgic_v3_group0_trap", early_group0_trap_cfg);
593594

594595
static int __init early_group1_trap_cfg(char *buf)
595596
{
596-
return strtobool(buf, &group1_trap);
597+
return kstrtobool(buf, &group1_trap);
597598
}
598599
early_param("kvm-arm.vgic_v3_group1_trap", early_group1_trap_cfg);
599600

600601
static int __init early_common_trap_cfg(char *buf)
601602
{
602-
return strtobool(buf, &common_trap);
603+
return kstrtobool(buf, &common_trap);
603604
}
604605
early_param("kvm-arm.vgic_v3_common_trap", early_common_trap_cfg);
605606

606607
static int __init early_gicv4_enable(char *buf)
607608
{
608-
return strtobool(buf, &gicv4_enable);
609+
return kstrtobool(buf, &gicv4_enable);
609610
}
610611
early_param("kvm-arm.vgic_v4_enable", early_gicv4_enable);
611612

0 commit comments

Comments
 (0)