Skip to content

Commit 5f5a5da

Browse files
committed
Merge tag 'v6.18.30' into rpi-6.18.y
This is the 6.18.30 stable release
2 parents b68b3ce + 52dc660 commit 5f5a5da

265 files changed

Lines changed: 2445 additions & 1133 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
File renamed without changes.

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 6
33
PATCHLEVEL = 18
4-
SUBLEVEL = 29
4+
SUBLEVEL = 30
55
EXTRAVERSION =
66
NAME = Baby Opossum Posse
77

@@ -483,6 +483,8 @@ export rust_common_flags := --edition=2021 \
483483
-Wclippy::as_ptr_cast_mut \
484484
-Wclippy::as_underscore \
485485
-Wclippy::cast_lossless \
486+
-Aclippy::collapsible_if \
487+
-Aclippy::collapsible_match \
486488
-Wclippy::ignored_unit_patterns \
487489
-Wclippy::mut_mut \
488490
-Wclippy::needless_bitwise_bool \

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ static inline bool __vcpu_has_feature(const struct kvm_arch *ka, int feature)
14761476
#define kvm_vcpu_has_feature(k, f) __vcpu_has_feature(&(k)->arch, (f))
14771477
#define vcpu_has_feature(v, f) __vcpu_has_feature(&(v)->kvm->arch, (f))
14781478

1479-
#define kvm_vcpu_initialized(v) vcpu_get_flag(vcpu, VCPU_INITIALIZED)
1479+
#define kvm_vcpu_initialized(v) vcpu_get_flag(v, VCPU_INITIALIZED)
14801480

14811481
int kvm_trng_call(struct kvm_vcpu *vcpu);
14821482
#ifdef CONFIG_KVM

arch/arm64/kernel/ptrace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,8 @@ static int sve_set_common(struct task_struct *target,
957957
}
958958

959959
/* Always zero V regs, FPSR, and FPCR */
960-
memset(&current->thread.uw.fpsimd_state, 0,
961-
sizeof(current->thread.uw.fpsimd_state));
960+
memset(&target->thread.uw.fpsimd_state, 0,
961+
sizeof(target->thread.uw.fpsimd_state));
962962

963963
/* Registers: FPSIMD-only case */
964964

arch/arm64/kernel/signal.c

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,45 @@ struct rt_sigframe_user_layout {
6767
unsigned long end_offset;
6868
};
6969

70+
#define TERMINATOR_SIZE round_up(sizeof(struct _aarch64_ctx), 16)
71+
#define EXTRA_CONTEXT_SIZE round_up(sizeof(struct extra_context), 16)
72+
7073
/*
7174
* Holds any EL0-controlled state that influences unprivileged memory accesses.
7275
* This includes both accesses done in userspace and uaccess done in the kernel.
7376
*
7477
* This state needs to be carefully managed to ensure that it doesn't cause
7578
* uaccess to fail when setting up the signal frame, and the signal handler
7679
* itself also expects a well-defined state when entered.
80+
*
81+
* The struct should be zero-initialised. Its members should only be accessed
82+
* via the accessors below. __valid_fields tracks which of the fields are valid
83+
* (have been set to some value).
7784
*/
7885
struct user_access_state {
79-
u64 por_el0;
86+
unsigned int __valid_fields;
87+
u64 __por_el0;
8088
};
8189

82-
#define TERMINATOR_SIZE round_up(sizeof(struct _aarch64_ctx), 16)
83-
#define EXTRA_CONTEXT_SIZE round_up(sizeof(struct extra_context), 16)
90+
#define UA_STATE_HAS_POR_EL0 BIT(0)
91+
92+
static void set_ua_state_por_el0(struct user_access_state *ua_state,
93+
u64 por_el0)
94+
{
95+
ua_state->__por_el0 = por_el0;
96+
ua_state->__valid_fields |= UA_STATE_HAS_POR_EL0;
97+
}
98+
99+
static int get_ua_state_por_el0(const struct user_access_state *ua_state,
100+
u64 *por_el0)
101+
{
102+
if (ua_state->__valid_fields & UA_STATE_HAS_POR_EL0) {
103+
*por_el0 = ua_state->__por_el0;
104+
return 0;
105+
}
106+
107+
return -ENOENT;
108+
}
84109

85110
/*
86111
* Save the user access state into ua_state and reset it to disable any
@@ -94,7 +119,7 @@ static void save_reset_user_access_state(struct user_access_state *ua_state)
94119
for (int pkey = 0; pkey < arch_max_pkey(); pkey++)
95120
por_enable_all |= POR_ELx_PERM_PREP(pkey, POE_RWX);
96121

97-
ua_state->por_el0 = read_sysreg_s(SYS_POR_EL0);
122+
set_ua_state_por_el0(ua_state, read_sysreg_s(SYS_POR_EL0));
98123
write_sysreg_s(por_enable_all, SYS_POR_EL0);
99124
/*
100125
* No ISB required as we can tolerate spurious Overlay faults -
@@ -122,8 +147,10 @@ static void set_handler_user_access_state(void)
122147
*/
123148
static void restore_user_access_state(const struct user_access_state *ua_state)
124149
{
125-
if (system_supports_poe())
126-
write_sysreg_s(ua_state->por_el0, SYS_POR_EL0);
150+
u64 por_el0;
151+
152+
if (get_ua_state_por_el0(ua_state, &por_el0) == 0)
153+
write_sysreg_s(por_el0, SYS_POR_EL0);
127154
}
128155

129156
static void init_user_layout(struct rt_sigframe_user_layout *user)
@@ -333,11 +360,16 @@ static int restore_fpmr_context(struct user_ctxs *user)
333360
static int preserve_poe_context(struct poe_context __user *ctx,
334361
const struct user_access_state *ua_state)
335362
{
336-
int err = 0;
363+
int err;
364+
u64 por_el0;
365+
366+
err = get_ua_state_por_el0(ua_state, &por_el0);
367+
if (WARN_ON_ONCE(err))
368+
return err;
337369

338370
__put_user_error(POE_MAGIC, &ctx->head.magic, err);
339371
__put_user_error(sizeof(*ctx), &ctx->head.size, err);
340-
__put_user_error(ua_state->por_el0, &ctx->por_el0, err);
372+
__put_user_error(por_el0, &ctx->por_el0, err);
341373

342374
return err;
343375
}
@@ -353,7 +385,7 @@ static int restore_poe_context(struct user_ctxs *user,
353385

354386
__get_user_error(por_el0, &(user->poe->por_el0), err);
355387
if (!err)
356-
ua_state->por_el0 = por_el0;
388+
set_ua_state_por_el0(ua_state, por_el0);
357389

358390
return err;
359391
}
@@ -1095,7 +1127,7 @@ SYSCALL_DEFINE0(rt_sigreturn)
10951127
{
10961128
struct pt_regs *regs = current_pt_regs();
10971129
struct rt_sigframe __user *frame;
1098-
struct user_access_state ua_state;
1130+
struct user_access_state ua_state = {};
10991131

11001132
/* Always make any pending restarted system calls return -EINTR */
11011133
current->restart_block.fn = do_no_restart_syscall;
@@ -1507,7 +1539,7 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
15071539
{
15081540
struct rt_sigframe_user_layout user;
15091541
struct rt_sigframe __user *frame;
1510-
struct user_access_state ua_state;
1542+
struct user_access_state ua_state = {};
15111543
int err = 0;
15121544

15131545
fpsimd_save_and_flush_current_state();

arch/arm64/kvm/arm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,10 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
755755
{
756756
bool irq_lines = *vcpu_hcr(v) & (HCR_VI | HCR_VF | HCR_VSE);
757757

758+
irq_lines |= (!irqchip_in_kernel(v->kvm) &&
759+
(kvm_timer_should_notify_user(v) ||
760+
kvm_pmu_should_notify_user(v)));
761+
758762
return ((irq_lines || kvm_vgic_vcpu_pending_irq(v))
759763
&& !kvm_arm_vcpu_stopped(v) && !v->arch.pause);
760764
}

arch/arm64/kvm/config.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ struct reg_feat_map_desc {
127127
}
128128

129129
#define FEAT_SPE ID_AA64DFR0_EL1, PMSVer, IMP
130-
#define FEAT_SPE_FnE ID_AA64DFR0_EL1, PMSVer, V1P2
131130
#define FEAT_BRBE ID_AA64DFR0_EL1, BRBE, IMP
132131
#define FEAT_TRC_SR ID_AA64DFR0_EL1, TraceVer, IMP
133132
#define FEAT_PMUv3 ID_AA64DFR0_EL1, PMUVer, IMP
@@ -188,7 +187,7 @@ struct reg_feat_map_desc {
188187
#define FEAT_SRMASK ID_AA64MMFR4_EL1, SRMASK, IMP
189188
#define FEAT_PoPS ID_AA64MMFR4_EL1, PoPS, IMP
190189
#define FEAT_PFAR ID_AA64PFR1_EL1, PFAR, IMP
191-
#define FEAT_Debugv8p9 ID_AA64DFR0_EL1, PMUVer, V3P9
190+
#define FEAT_Debugv8p9 ID_AA64DFR0_EL1, DebugVer, V8P9
192191
#define FEAT_PMUv3_SS ID_AA64DFR0_EL1, PMSS, IMP
193192
#define FEAT_SEBEP ID_AA64DFR0_EL1, SEBEP, IMP
194193
#define FEAT_EBEP ID_AA64DFR1_EL1, EBEP, IMP
@@ -294,6 +293,16 @@ static bool feat_spe_fds(struct kvm *kvm)
294293
(read_sysreg_s(SYS_PMSIDR_EL1) & PMSIDR_EL1_FDS));
295294
}
296295

296+
static bool feat_spe_fne(struct kvm *kvm)
297+
{
298+
/*
299+
* Revisit this if KVM ever supports SPE -- this really should
300+
* look at the guest's view of PMSIDR_EL1.
301+
*/
302+
return (kvm_has_feat(kvm, FEAT_SPEv1p2) &&
303+
(read_sysreg_s(SYS_PMSIDR_EL1) & PMSIDR_EL1_FnE));
304+
}
305+
297306
static bool feat_trbe_mpam(struct kvm *kvm)
298307
{
299308
/*
@@ -547,7 +556,7 @@ static const struct reg_bits_to_feat_map hdfgrtr_feat_map[] = {
547556
HDFGRTR_EL2_PMBPTR_EL1 |
548557
HDFGRTR_EL2_PMBLIMITR_EL1,
549558
FEAT_SPE),
550-
NEEDS_FEAT(HDFGRTR_EL2_nPMSNEVFR_EL1, FEAT_SPE_FnE),
559+
NEEDS_FEAT(HDFGRTR_EL2_nPMSNEVFR_EL1, feat_spe_fne),
551560
NEEDS_FEAT(HDFGRTR_EL2_nBRBDATA |
552561
HDFGRTR_EL2_nBRBCTL |
553562
HDFGRTR_EL2_nBRBIDR,
@@ -615,7 +624,7 @@ static const struct reg_bits_to_feat_map hdfgwtr_feat_map[] = {
615624
HDFGWTR_EL2_PMBPTR_EL1 |
616625
HDFGWTR_EL2_PMBLIMITR_EL1,
617626
FEAT_SPE),
618-
NEEDS_FEAT(HDFGWTR_EL2_nPMSNEVFR_EL1, FEAT_SPE_FnE),
627+
NEEDS_FEAT(HDFGWTR_EL2_nPMSNEVFR_EL1, feat_spe_fne),
619628
NEEDS_FEAT(HDFGWTR_EL2_nBRBDATA |
620629
HDFGWTR_EL2_nBRBCTL,
621630
FEAT_BRBE),

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

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ struct pkvm_hyp_vcpu *pkvm_load_hyp_vcpu(pkvm_handle_t handle,
259259
if (!hyp_vm || hyp_vm->kvm.created_vcpus <= vcpu_idx)
260260
goto unlock;
261261

262-
hyp_vcpu = hyp_vm->vcpus[vcpu_idx];
262+
/* Pairs with smp_store_release() in register_hyp_vcpu(). */
263+
hyp_vcpu = smp_load_acquire(&hyp_vm->vcpus[vcpu_idx]);
263264
if (!hyp_vcpu)
264265
goto unlock;
265266

@@ -801,12 +802,30 @@ int __pkvm_init_vm(struct kvm *host_kvm, unsigned long vm_hva,
801802
* the page-aligned size of 'struct pkvm_hyp_vcpu'.
802803
* Return 0 on success, negative error code on failure.
803804
*/
805+
static int register_hyp_vcpu(struct pkvm_hyp_vm *hyp_vm,
806+
struct pkvm_hyp_vcpu *hyp_vcpu)
807+
{
808+
unsigned int idx = hyp_vcpu->vcpu.vcpu_idx;
809+
810+
if (idx >= hyp_vm->kvm.created_vcpus)
811+
return -EINVAL;
812+
813+
if (hyp_vm->vcpus[idx])
814+
return -EINVAL;
815+
816+
/*
817+
* Ensure the hyp_vcpu is initialised before publishing it to
818+
* the vCPU-load path via 'hyp_vm->vcpus[]'.
819+
*/
820+
smp_store_release(&hyp_vm->vcpus[idx], hyp_vcpu);
821+
return 0;
822+
}
823+
804824
int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu,
805825
unsigned long vcpu_hva)
806826
{
807827
struct pkvm_hyp_vcpu *hyp_vcpu;
808828
struct pkvm_hyp_vm *hyp_vm;
809-
unsigned int idx;
810829
int ret;
811830

812831
hyp_vcpu = map_donated_memory(vcpu_hva, sizeof(*hyp_vcpu));
@@ -825,18 +844,11 @@ int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu,
825844
if (ret)
826845
goto unlock;
827846

828-
idx = hyp_vcpu->vcpu.vcpu_idx;
829-
if (idx >= hyp_vm->kvm.created_vcpus) {
830-
ret = -EINVAL;
831-
goto unlock;
832-
}
833-
834-
if (hyp_vm->vcpus[idx]) {
835-
ret = -EINVAL;
836-
goto unlock;
847+
ret = register_hyp_vcpu(hyp_vm, hyp_vcpu);
848+
if (ret) {
849+
unpin_host_vcpu(host_vcpu);
850+
unpin_host_sve_state(hyp_vcpu);
837851
}
838-
839-
hyp_vm->vcpus[idx] = hyp_vcpu;
840852
unlock:
841853
hyp_spin_unlock(&vm_table_lock);
842854

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,15 @@ void __noreturn __pkvm_init_finalise(void)
312312
};
313313
pkvm_pgtable.mm_ops = &pkvm_pgtable_mm_ops;
314314

315-
ret = fix_host_ownership();
315+
ret = fix_hyp_pgtable_refcnt();
316316
if (ret)
317317
goto out;
318318

319-
ret = fix_hyp_pgtable_refcnt();
319+
ret = hyp_create_fixmap();
320320
if (ret)
321321
goto out;
322322

323-
ret = hyp_create_fixmap();
323+
ret = fix_host_ownership();
324324
if (ret)
325325
goto out;
326326

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static int vgic_mmio_uaccess_write_v2_misc(struct kvm_vcpu *vcpu,
9191
* migration from old kernels to new kernels with legacy
9292
* userspace.
9393
*/
94-
reg = FIELD_GET(GICD_IIDR_REVISION_MASK, reg);
94+
reg = FIELD_GET(GICD_IIDR_REVISION_MASK, val);
9595
switch (reg) {
9696
case KVM_VGIC_IMP_REV_2:
9797
case KVM_VGIC_IMP_REV_3:

0 commit comments

Comments
 (0)