Skip to content

Commit 822ca7f

Browse files
author
Marc Zyngier
committed
Merge branch kvm-arm64/misc-5.19 into kvmarm-master/next
* kvm-arm64/misc-5.19: : . : Misc fixes and general improvements for KVMM/arm64: : : - Better handle out of sequence sysregs in the global tables : : - Remove a couple of unnecessary loads from constant pool : : - Drop unnecessary pKVM checks : : - Add all known M1 implementations to the SEIS workaround : : - Cleanup kerneldoc warnings : . KVM: arm64: vgic-v3: List M1 Pro/Max as requiring the SEIS workaround KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler KVM: arm64: nvhe: Eliminate kernel-doc warnings KVM: arm64: Avoid unnecessary absolute addressing via literals KVM: arm64: Print emulated register table name when it is unsorted KVM: arm64: Don't BUG_ON() if emulated register table is unsorted Signed-off-by: Marc Zyngier <maz@kernel.org>
2 parents 8794b4f + cae8893 commit 822ca7f

8 files changed

Lines changed: 46 additions & 47 deletions

File tree

arch/arm64/include/asm/cputype.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@
118118

119119
#define APPLE_CPU_PART_M1_ICESTORM 0x022
120120
#define APPLE_CPU_PART_M1_FIRESTORM 0x023
121+
#define APPLE_CPU_PART_M1_ICESTORM_PRO 0x024
122+
#define APPLE_CPU_PART_M1_FIRESTORM_PRO 0x025
123+
#define APPLE_CPU_PART_M1_ICESTORM_MAX 0x028
124+
#define APPLE_CPU_PART_M1_FIRESTORM_MAX 0x029
121125

122126
#define MIDR_CORTEX_A53 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53)
123127
#define MIDR_CORTEX_A57 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57)
@@ -164,6 +168,10 @@
164168
#define MIDR_HISI_TSV110 MIDR_CPU_MODEL(ARM_CPU_IMP_HISI, HISI_CPU_PART_TSV110)
165169
#define MIDR_APPLE_M1_ICESTORM MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM)
166170
#define MIDR_APPLE_M1_FIRESTORM MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM)
171+
#define MIDR_APPLE_M1_ICESTORM_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM_PRO)
172+
#define MIDR_APPLE_M1_FIRESTORM_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_PRO)
173+
#define MIDR_APPLE_M1_ICESTORM_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM_MAX)
174+
#define MIDR_APPLE_M1_FIRESTORM_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_MAX)
167175

168176
/* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and v1r0) */
169177
#define MIDR_FUJITSU_ERRATUM_010001 MIDR_FUJITSU_A64FX

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ int kvm_handle_cp10_id(struct kvm_vcpu *vcpu);
705705

706706
void kvm_reset_sys_regs(struct kvm_vcpu *vcpu);
707707

708-
void kvm_sys_reg_table_init(void);
708+
int kvm_sys_reg_table_init(void);
709709

710710
/* MMIO helpers */
711711
void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data);

arch/arm64/kvm/arm.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,8 +1829,6 @@ static int init_subsystems(void)
18291829

18301830
kvm_register_perf_callbacks(NULL);
18311831

1832-
kvm_sys_reg_table_init();
1833-
18341832
out:
18351833
if (err || !is_protected_kvm_enabled())
18361834
on_each_cpu(_kvm_arch_hardware_disable, NULL, 1);
@@ -2189,6 +2187,12 @@ int kvm_arch_init(void *opaque)
21892187
return -ENODEV;
21902188
}
21912189

2190+
err = kvm_sys_reg_table_init();
2191+
if (err) {
2192+
kvm_info("Error initializing system register tables");
2193+
return err;
2194+
}
2195+
21922196
in_hyp_mode = is_kernel_in_hyp_mode();
21932197

21942198
if (cpus_have_final_cap(ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE) ||

arch/arm64/kvm/hyp/nvhe/host.S

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ SYM_FUNC_START(__hyp_do_panic)
8080
mov lr, #(PSR_F_BIT | PSR_I_BIT | PSR_A_BIT | PSR_D_BIT |\
8181
PSR_MODE_EL1h)
8282
msr spsr_el2, lr
83-
ldr lr, =nvhe_hyp_panic_handler
83+
adr_l lr, nvhe_hyp_panic_handler
8484
hyp_kimg_va lr, x6
8585
msr elr_el2, lr
8686

@@ -125,13 +125,11 @@ alternative_else_nop_endif
125125
add sp, sp, #16
126126
/*
127127
* Compute the idmap address of __kvm_handle_stub_hvc and
128-
* jump there. Since we use kimage_voffset, do not use the
129-
* HYP VA for __kvm_handle_stub_hvc, but the kernel VA instead
130-
* (by loading it from the constant pool).
128+
* jump there.
131129
*
132130
* Preserve x0-x4, which may contain stub parameters.
133131
*/
134-
ldr x5, =__kvm_handle_stub_hvc
132+
adr_l x5, __kvm_handle_stub_hvc
135133
hyp_pa x5, x6
136134
br x5
137135
SYM_FUNC_END(__host_hvc)

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

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static void __hyp_vgic_restore_state(struct kvm_vcpu *vcpu)
150150
}
151151
}
152152

153-
/**
153+
/*
154154
* Disable host events, enable guest events
155155
*/
156156
#ifdef CONFIG_HW_PERF_EVENTS
@@ -167,7 +167,7 @@ static bool __pmu_switch_to_guest(struct kvm_vcpu *vcpu)
167167
return (pmu->events_host || pmu->events_guest);
168168
}
169169

170-
/**
170+
/*
171171
* Disable guest events, enable host events
172172
*/
173173
static void __pmu_switch_to_host(struct kvm_vcpu *vcpu)
@@ -185,7 +185,7 @@ static void __pmu_switch_to_host(struct kvm_vcpu *vcpu)
185185
#define __pmu_switch_to_host(v) do {} while (0)
186186
#endif
187187

188-
/**
188+
/*
189189
* Handler for protected VM MSR, MRS or System instruction execution in AArch64.
190190
*
191191
* Returns true if the hypervisor has handled the exit, and control should go
@@ -202,23 +202,6 @@ static bool kvm_handle_pvm_sys64(struct kvm_vcpu *vcpu, u64 *exit_code)
202202
kvm_handle_pvm_sysreg(vcpu, exit_code));
203203
}
204204

205-
/**
206-
* Handler for protected floating-point and Advanced SIMD accesses.
207-
*
208-
* Returns true if the hypervisor has handled the exit, and control should go
209-
* back to the guest, or false if it hasn't.
210-
*/
211-
static bool kvm_handle_pvm_fpsimd(struct kvm_vcpu *vcpu, u64 *exit_code)
212-
{
213-
/* Linux guests assume support for floating-point and Advanced SIMD. */
214-
BUILD_BUG_ON(!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_FP),
215-
PVM_ID_AA64PFR0_ALLOW));
216-
BUILD_BUG_ON(!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_ASIMD),
217-
PVM_ID_AA64PFR0_ALLOW));
218-
219-
return kvm_hyp_handle_fpsimd(vcpu, exit_code);
220-
}
221-
222205
static const exit_handler_fn hyp_exit_handlers[] = {
223206
[0 ... ESR_ELx_EC_MAX] = NULL,
224207
[ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,
@@ -234,7 +217,7 @@ static const exit_handler_fn pvm_exit_handlers[] = {
234217
[0 ... ESR_ELx_EC_MAX] = NULL,
235218
[ESR_ELx_EC_SYS64] = kvm_handle_pvm_sys64,
236219
[ESR_ELx_EC_SVE] = kvm_handle_pvm_restricted,
237-
[ESR_ELx_EC_FP_ASIMD] = kvm_handle_pvm_fpsimd,
220+
[ESR_ELx_EC_FP_ASIMD] = kvm_hyp_handle_fpsimd,
238221
[ESR_ELx_EC_IABT_LOW] = kvm_hyp_handle_iabt_low,
239222
[ESR_ELx_EC_DABT_LOW] = kvm_hyp_handle_dabt_low,
240223
[ESR_ELx_EC_PAC] = kvm_hyp_handle_ptrauth,

arch/arm64/kvm/hyp/nvhe/sys_regs.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ static u64 get_pvm_id_aa64pfr0(const struct kvm_vcpu *vcpu)
9090
u64 set_mask = 0;
9191
u64 allow_mask = PVM_ID_AA64PFR0_ALLOW;
9292

93-
if (!vcpu_has_sve(vcpu))
94-
allow_mask &= ~ARM64_FEATURE_MASK(ID_AA64PFR0_SVE);
95-
9693
set_mask |= get_restricted_features_unsigned(id_aa64pfr0_el1_sys_val,
9794
PVM_ID_AA64PFR0_RESTRICT_UNSIGNED);
9895

arch/arm64/kvm/sys_regs.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,25 +2198,24 @@ static const struct sys_reg_desc cp15_64_regs[] = {
21982198
{ SYS_DESC(SYS_AARCH32_CNTP_CVAL), access_arch_timer },
21992199
};
22002200

2201-
static int check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
2202-
bool is_32)
2201+
static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
2202+
bool is_32)
22032203
{
22042204
unsigned int i;
22052205

22062206
for (i = 0; i < n; i++) {
22072207
if (!is_32 && table[i].reg && !table[i].reset) {
2208-
kvm_err("sys_reg table %p entry %d has lacks reset\n",
2209-
table, i);
2210-
return 1;
2208+
kvm_err("sys_reg table %pS entry %d lacks reset\n", &table[i], i);
2209+
return false;
22112210
}
22122211

22132212
if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
2214-
kvm_err("sys_reg table %p out of order (%d)\n", table, i - 1);
2215-
return 1;
2213+
kvm_err("sys_reg table %pS entry %d out of order\n", &table[i - 1], i - 1);
2214+
return false;
22162215
}
22172216
}
22182217

2219-
return 0;
2218+
return true;
22202219
}
22212220

22222221
int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu)
@@ -3008,18 +3007,22 @@ int kvm_arm_copy_sys_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices)
30083007
return write_demux_regids(uindices);
30093008
}
30103009

3011-
void kvm_sys_reg_table_init(void)
3010+
int kvm_sys_reg_table_init(void)
30123011
{
3012+
bool valid = true;
30133013
unsigned int i;
30143014
struct sys_reg_desc clidr;
30153015

30163016
/* Make sure tables are unique and in order. */
3017-
BUG_ON(check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false));
3018-
BUG_ON(check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true));
3019-
BUG_ON(check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true));
3020-
BUG_ON(check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true));
3021-
BUG_ON(check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true));
3022-
BUG_ON(check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false));
3017+
valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
3018+
valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
3019+
valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
3020+
valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
3021+
valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
3022+
valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
3023+
3024+
if (!valid)
3025+
return -EINVAL;
30233026

30243027
/* We abuse the reset function to overwrite the table itself. */
30253028
for (i = 0; i < ARRAY_SIZE(invariant_sys_regs); i++)
@@ -3042,4 +3045,6 @@ void kvm_sys_reg_table_init(void)
30423045
break;
30433046
/* Clear all higher bits. */
30443047
cache_levels &= (1 << (i*3))-1;
3048+
3049+
return 0;
30453050
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@ early_param("kvm-arm.vgic_v4_enable", early_gicv4_enable);
612612
static const struct midr_range broken_seis[] = {
613613
MIDR_ALL_VERSIONS(MIDR_APPLE_M1_ICESTORM),
614614
MIDR_ALL_VERSIONS(MIDR_APPLE_M1_FIRESTORM),
615+
MIDR_ALL_VERSIONS(MIDR_APPLE_M1_ICESTORM_PRO),
616+
MIDR_ALL_VERSIONS(MIDR_APPLE_M1_FIRESTORM_PRO),
617+
MIDR_ALL_VERSIONS(MIDR_APPLE_M1_ICESTORM_MAX),
618+
MIDR_ALL_VERSIONS(MIDR_APPLE_M1_FIRESTORM_MAX),
615619
{},
616620
};
617621

0 commit comments

Comments
 (0)