Skip to content

Commit 4e6db84

Browse files
committed
Merge tag 'v6.6.63' into 6.6-main
This is the 6.6.63 stable release # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmdAl4gACgkQONu9yGCS # aT6iCBAAqTvp0BGFFl+7pVb9SpCxaxleK3tzs1X3q6dZpk1p6bI34GCHMlWGQZRR # Iy1DzLcmrJd22frPOZ3PZyWOpAvz7VcU9I/2PhNfG4Ge3aPw0Q9Cs6I+9E51msJA # njRIDUcozBTX1dsQV/g56Pzefvq+W0X1Z6XlipAYqcZRrJHkZoL6WL4vgmpEFdEf # Nk3u3QT67vALCnIxbtm7h2NZSwWFpRbW1VXDe0R7bxWb8q0ZRIsgoJiUroZatx4Y # YejggnVNjRHqytSuNqHF8BtJzGHRD/0n+IMUih3oVSLLkzZSLriaWXGuXzQGpzDG # FTDHyu77I12f5HSv5ftc2dMupb6RL9ICR1uuc/WppjWgP5xLd2ULSlwlaKQsk6IF # v2wdzlOol15TDKqi+D4D1p+eUeSqzMUDYalAUAlX3/gOr69/2EYhgqwsND5NdXFJ # NqKadL29R3a4DT/NOLqklLcUQlRBTwkQnV4k167+YKjwC6EYOrHFzr6xqKeqD+Dr # OpNg5rKM7HB0VGobvw++uwHHSMYkdLeuSUNdFzEU2tL0N1YqlNxKs0YtrbOT0l1q # l7VCOSzHHkkYmyRU+zfo2k5LtUSROSGM5qqkHFQvpA/ikFWahIMyjiAlxjkO6pgm # vCGQnYSV0lO4Vsa5F131fkwGA0LTBFFRymUGN+QMIvj0jtUFADA= # =EXuo # -----END PGP SIGNATURE----- # gpg: Signature made Fri Nov 22 15:39:04 2024 CET # gpg: using RSA key 647F28654894E3BD457199BE38DBBDC86092693E # gpg: Can't check signature: No public key
2 parents fa30e3f + bff3e13 commit 4e6db84

File tree

83 files changed

+819
-424
lines changed

Some content is hidden

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

83 files changed

+819
-424
lines changed

Makefile

Lines changed: 1 addition & 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 = 6
4-
SUBLEVEL = 62
4+
SUBLEVEL = 63
55
EXTRAVERSION =
66
NAME = Pinguïn Aangedreven
77

arch/arm/kernel/head.S

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,27 +252,31 @@ __create_page_tables:
252252
*/
253253
add r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_ENTRY_ORDER)
254254
ldr r6, =(_end - 1)
255+
256+
/* For XIP, kernel_sec_start/kernel_sec_end are currently in RO memory */
257+
#ifndef CONFIG_XIP_KERNEL
255258
adr_l r5, kernel_sec_start @ _pa(kernel_sec_start)
256259
#if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32
257260
str r8, [r5, #4] @ Save physical start of kernel (BE)
258261
#else
259262
str r8, [r5] @ Save physical start of kernel (LE)
263+
#endif
260264
#endif
261265
orr r3, r8, r7 @ Add the MMU flags
262266
add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ENTRY_ORDER)
263267
1: str r3, [r0], #1 << PMD_ENTRY_ORDER
264268
add r3, r3, #1 << SECTION_SHIFT
265269
cmp r0, r6
266270
bls 1b
271+
#ifndef CONFIG_XIP_KERNEL
267272
eor r3, r3, r7 @ Remove the MMU flags
268273
adr_l r5, kernel_sec_end @ _pa(kernel_sec_end)
269274
#if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32
270275
str r3, [r5, #4] @ Save physical end of kernel (BE)
271276
#else
272277
str r3, [r5] @ Save physical end of kernel (LE)
273278
#endif
274-
275-
#ifdef CONFIG_XIP_KERNEL
279+
#else
276280
/*
277281
* Map the kernel image separately as it is not located in RAM.
278282
*/

arch/arm/mm/mmu.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,18 +1402,6 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
14021402
create_mapping(&map);
14031403
}
14041404

1405-
/*
1406-
* Map the kernel if it is XIP.
1407-
* It is always first in the modulearea.
1408-
*/
1409-
#ifdef CONFIG_XIP_KERNEL
1410-
map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
1411-
map.virtual = MODULES_VADDR;
1412-
map.length = ((unsigned long)_exiprom - map.virtual + ~SECTION_MASK) & SECTION_MASK;
1413-
map.type = MT_ROM;
1414-
create_mapping(&map);
1415-
#endif
1416-
14171405
/*
14181406
* Map the cache flushing regions.
14191407
*/
@@ -1603,12 +1591,27 @@ static void __init map_kernel(void)
16031591
* This will only persist until we turn on proper memory management later on
16041592
* and we remap the whole kernel with page granularity.
16051593
*/
1594+
#ifdef CONFIG_XIP_KERNEL
1595+
phys_addr_t kernel_nx_start = kernel_sec_start;
1596+
#else
16061597
phys_addr_t kernel_x_start = kernel_sec_start;
16071598
phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
16081599
phys_addr_t kernel_nx_start = kernel_x_end;
1600+
#endif
16091601
phys_addr_t kernel_nx_end = kernel_sec_end;
16101602
struct map_desc map;
16111603

1604+
/*
1605+
* Map the kernel if it is XIP.
1606+
* It is always first in the modulearea.
1607+
*/
1608+
#ifdef CONFIG_XIP_KERNEL
1609+
map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
1610+
map.virtual = MODULES_VADDR;
1611+
map.length = ((unsigned long)_exiprom - map.virtual + ~SECTION_MASK) & SECTION_MASK;
1612+
map.type = MT_ROM;
1613+
create_mapping(&map);
1614+
#else
16121615
map.pfn = __phys_to_pfn(kernel_x_start);
16131616
map.virtual = __phys_to_virt(kernel_x_start);
16141617
map.length = kernel_x_end - kernel_x_start;
@@ -1618,7 +1621,7 @@ static void __init map_kernel(void)
16181621
/* If the nx part is small it may end up covered by the tail of the RWX section */
16191622
if (kernel_x_end == kernel_nx_end)
16201623
return;
1621-
1624+
#endif
16221625
map.pfn = __phys_to_pfn(kernel_nx_start);
16231626
map.virtual = __phys_to_virt(kernel_nx_start);
16241627
map.length = kernel_nx_end - kernel_nx_start;
@@ -1763,6 +1766,11 @@ void __init paging_init(const struct machine_desc *mdesc)
17631766
{
17641767
void *zero_page;
17651768

1769+
#ifdef CONFIG_XIP_KERNEL
1770+
/* Store the kernel RW RAM region start/end in these variables */
1771+
kernel_sec_start = CONFIG_PHYS_OFFSET & SECTION_MASK;
1772+
kernel_sec_end = round_up(__pa(_end), SECTION_SIZE);
1773+
#endif
17661774
pr_debug("physical kernel sections: 0x%08llx-0x%08llx\n",
17671775
kernel_sec_start, kernel_sec_end);
17681776

arch/arm64/include/asm/mman.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#define __ASM_MMAN_H__
44

55
#include <linux/compiler.h>
6+
#include <linux/fs.h>
7+
#include <linux/shmem_fs.h>
68
#include <linux/types.h>
79
#include <uapi/asm/mman.h>
810

@@ -21,19 +23,21 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
2123
}
2224
#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
2325

24-
static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
26+
static inline unsigned long arch_calc_vm_flag_bits(struct file *file,
27+
unsigned long flags)
2528
{
2629
/*
2730
* Only allow MTE on anonymous mappings as these are guaranteed to be
2831
* backed by tags-capable memory. The vm_flags may be overridden by a
2932
* filesystem supporting MTE (RAM-based).
3033
*/
31-
if (system_supports_mte() && (flags & MAP_ANONYMOUS))
34+
if (system_supports_mte() &&
35+
((flags & MAP_ANONYMOUS) || shmem_file(file)))
3236
return VM_MTE_ALLOWED;
3337

3438
return 0;
3539
}
36-
#define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags)
40+
#define arch_calc_vm_flag_bits(file, flags) arch_calc_vm_flag_bits(file, flags)
3741

3842
static inline bool arch_validate_prot(unsigned long prot,
3943
unsigned long addr __always_unused)

arch/loongarch/include/asm/kasan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
/* KAsan shadow memory start right after vmalloc. */
5252
#define KASAN_SHADOW_START round_up(KFENCE_AREA_END, PGDIR_SIZE)
5353
#define KASAN_SHADOW_SIZE (XKVRANGE_VC_SHADOW_END - XKPRANGE_CC_KASAN_OFFSET)
54-
#define KASAN_SHADOW_END round_up(KASAN_SHADOW_START + KASAN_SHADOW_SIZE, PGDIR_SIZE)
54+
#define KASAN_SHADOW_END (round_up(KASAN_SHADOW_START + KASAN_SHADOW_SIZE, PGDIR_SIZE) - 1)
5555

5656
#define XKPRANGE_CC_SHADOW_OFFSET (KASAN_SHADOW_START + XKPRANGE_CC_KASAN_OFFSET)
5757
#define XKPRANGE_UC_SHADOW_OFFSET (KASAN_SHADOW_START + XKPRANGE_UC_KASAN_OFFSET)

arch/loongarch/kernel/smp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static void __init fdt_smp_setup(void)
272272
__cpu_number_map[cpuid] = cpu;
273273
__cpu_logical_map[cpu] = cpuid;
274274

275-
early_numa_add_cpu(cpu, 0);
275+
early_numa_add_cpu(cpuid, 0);
276276
set_cpuid_to_node(cpuid, 0);
277277
}
278278

arch/loongarch/mm/kasan_init.c

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313

1414
static pgd_t kasan_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);
1515

16+
#ifdef __PAGETABLE_P4D_FOLDED
17+
#define __pgd_none(early, pgd) (0)
18+
#else
19+
#define __pgd_none(early, pgd) (early ? (pgd_val(pgd) == 0) : \
20+
(__pa(pgd_val(pgd)) == (unsigned long)__pa(kasan_early_shadow_p4d)))
21+
#endif
22+
1623
#ifdef __PAGETABLE_PUD_FOLDED
1724
#define __p4d_none(early, p4d) (0)
1825
#else
@@ -142,6 +149,19 @@ static pud_t *__init kasan_pud_offset(p4d_t *p4dp, unsigned long addr, int node,
142149
return pud_offset(p4dp, addr);
143150
}
144151

152+
static p4d_t *__init kasan_p4d_offset(pgd_t *pgdp, unsigned long addr, int node, bool early)
153+
{
154+
if (__pgd_none(early, pgdp_get(pgdp))) {
155+
phys_addr_t p4d_phys = early ?
156+
__pa_symbol(kasan_early_shadow_p4d) : kasan_alloc_zeroed_page(node);
157+
if (!early)
158+
memcpy(__va(p4d_phys), kasan_early_shadow_p4d, sizeof(kasan_early_shadow_p4d));
159+
pgd_populate(&init_mm, pgdp, (p4d_t *)__va(p4d_phys));
160+
}
161+
162+
return p4d_offset(pgdp, addr);
163+
}
164+
145165
static void __init kasan_pte_populate(pmd_t *pmdp, unsigned long addr,
146166
unsigned long end, int node, bool early)
147167
{
@@ -178,19 +198,19 @@ static void __init kasan_pud_populate(p4d_t *p4dp, unsigned long addr,
178198
do {
179199
next = pud_addr_end(addr, end);
180200
kasan_pmd_populate(pudp, addr, next, node, early);
181-
} while (pudp++, addr = next, addr != end);
201+
} while (pudp++, addr = next, addr != end && __pud_none(early, READ_ONCE(*pudp)));
182202
}
183203

184204
static void __init kasan_p4d_populate(pgd_t *pgdp, unsigned long addr,
185205
unsigned long end, int node, bool early)
186206
{
187207
unsigned long next;
188-
p4d_t *p4dp = p4d_offset(pgdp, addr);
208+
p4d_t *p4dp = kasan_p4d_offset(pgdp, addr, node, early);
189209

190210
do {
191211
next = p4d_addr_end(addr, end);
192212
kasan_pud_populate(p4dp, addr, next, node, early);
193-
} while (p4dp++, addr = next, addr != end);
213+
} while (p4dp++, addr = next, addr != end && __p4d_none(early, READ_ONCE(*p4dp)));
194214
}
195215

196216
static void __init kasan_pgd_populate(unsigned long addr, unsigned long end,
@@ -218,7 +238,7 @@ static void __init kasan_map_populate(unsigned long start, unsigned long end,
218238
asmlinkage void __init kasan_early_init(void)
219239
{
220240
BUILD_BUG_ON(!IS_ALIGNED(KASAN_SHADOW_START, PGDIR_SIZE));
221-
BUILD_BUG_ON(!IS_ALIGNED(KASAN_SHADOW_END, PGDIR_SIZE));
241+
BUILD_BUG_ON(!IS_ALIGNED(KASAN_SHADOW_END + 1, PGDIR_SIZE));
222242
}
223243

224244
static inline void kasan_set_pgd(pgd_t *pgdp, pgd_t pgdval)
@@ -233,7 +253,7 @@ static void __init clear_pgds(unsigned long start, unsigned long end)
233253
* swapper_pg_dir. pgd_clear() can't be used
234254
* here because it's nop on 2,3-level pagetable setups
235255
*/
236-
for (; start < end; start += PGDIR_SIZE)
256+
for (; start < end; start = pgd_addr_end(start, end))
237257
kasan_set_pgd((pgd_t *)pgd_offset_k(start), __pgd(0));
238258
}
239259

@@ -242,6 +262,17 @@ void __init kasan_init(void)
242262
u64 i;
243263
phys_addr_t pa_start, pa_end;
244264

265+
/*
266+
* If PGDIR_SIZE is too large for cpu_vabits, KASAN_SHADOW_END will
267+
* overflow UINTPTR_MAX and then looks like a user space address.
268+
* For example, PGDIR_SIZE of CONFIG_4KB_4LEVEL is 2^39, which is too
269+
* large for Loongson-2K series whose cpu_vabits = 39.
270+
*/
271+
if (KASAN_SHADOW_END < vm_map_base) {
272+
pr_warn("PGDIR_SIZE too large for cpu_vabits, KernelAddressSanitizer disabled.\n");
273+
return;
274+
}
275+
245276
/*
246277
* PGD was populated as invalid_pmd_table or invalid_pud_table
247278
* in pagetable_init() which depends on how many levels of page

arch/parisc/include/asm/mman.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef __ASM_MMAN_H__
33
#define __ASM_MMAN_H__
44

5+
#include <linux/fs.h>
56
#include <uapi/asm/mman.h>
67

78
/* PARISC cannot allow mdwe as it needs writable stacks */
@@ -11,7 +12,7 @@ static inline bool arch_memory_deny_write_exec_supported(void)
1112
}
1213
#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported
1314

14-
static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
15+
static inline unsigned long arch_calc_vm_flag_bits(struct file *file, unsigned long flags)
1516
{
1617
/*
1718
* The stack on parisc grows upwards, so if userspace requests memory
@@ -23,6 +24,6 @@ static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
2324

2425
return 0;
2526
}
26-
#define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags)
27+
#define arch_calc_vm_flag_bits(file, flags) arch_calc_vm_flag_bits(file, flags)
2728

2829
#endif /* __ASM_MMAN_H__ */

arch/x86/kvm/lapic.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,19 +2603,26 @@ void kvm_apic_update_apicv(struct kvm_vcpu *vcpu)
26032603
{
26042604
struct kvm_lapic *apic = vcpu->arch.apic;
26052605

2606-
if (apic->apicv_active) {
2607-
/* irr_pending is always true when apicv is activated. */
2608-
apic->irr_pending = true;
2606+
/*
2607+
* When APICv is enabled, KVM must always search the IRR for a pending
2608+
* IRQ, as other vCPUs and devices can set IRR bits even if the vCPU
2609+
* isn't running. If APICv is disabled, KVM _should_ search the IRR
2610+
* for a pending IRQ. But KVM currently doesn't ensure *all* hardware,
2611+
* e.g. CPUs and IOMMUs, has seen the change in state, i.e. searching
2612+
* the IRR at this time could race with IRQ delivery from hardware that
2613+
* still sees APICv as being enabled.
2614+
*
2615+
* FIXME: Ensure other vCPUs and devices observe the change in APICv
2616+
* state prior to updating KVM's metadata caches, so that KVM
2617+
* can safely search the IRR and set irr_pending accordingly.
2618+
*/
2619+
apic->irr_pending = true;
2620+
2621+
if (apic->apicv_active)
26092622
apic->isr_count = 1;
2610-
} else {
2611-
/*
2612-
* Don't clear irr_pending, searching the IRR can race with
2613-
* updates from the CPU as APICv is still active from hardware's
2614-
* perspective. The flag will be cleared as appropriate when
2615-
* KVM injects the interrupt.
2616-
*/
2623+
else
26172624
apic->isr_count = count_vectors(apic->regs + APIC_ISR);
2618-
}
2625+
26192626
apic->highest_isr_cache = -1;
26202627
}
26212628

arch/x86/kvm/vmx/nested.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,11 +1150,14 @@ static void nested_vmx_transition_tlb_flush(struct kvm_vcpu *vcpu,
11501150
kvm_make_request(KVM_REQ_HV_TLB_FLUSH, vcpu);
11511151

11521152
/*
1153-
* If vmcs12 doesn't use VPID, L1 expects linear and combined mappings
1154-
* for *all* contexts to be flushed on VM-Enter/VM-Exit, i.e. it's a
1155-
* full TLB flush from the guest's perspective. This is required even
1156-
* if VPID is disabled in the host as KVM may need to synchronize the
1157-
* MMU in response to the guest TLB flush.
1153+
* If VPID is disabled, then guest TLB accesses use VPID=0, i.e. the
1154+
* same VPID as the host, and so architecturally, linear and combined
1155+
* mappings for VPID=0 must be flushed at VM-Enter and VM-Exit. KVM
1156+
* emulates L2 sharing L1's VPID=0 by using vpid01 while running L2,
1157+
* and so KVM must also emulate TLB flush of VPID=0, i.e. vpid01. This
1158+
* is required if VPID is disabled in KVM, as a TLB flush (there are no
1159+
* VPIDs) still occurs from L1's perspective, and KVM may need to
1160+
* synchronize the MMU in response to the guest TLB flush.
11581161
*
11591162
* Note, using TLB_FLUSH_GUEST is correct even if nested EPT is in use.
11601163
* EPT is a special snowflake, as guest-physical mappings aren't
@@ -2229,6 +2232,17 @@ static void prepare_vmcs02_early_rare(struct vcpu_vmx *vmx,
22292232

22302233
vmcs_write64(VMCS_LINK_POINTER, INVALID_GPA);
22312234

2235+
/*
2236+
* If VPID is disabled, then guest TLB accesses use VPID=0, i.e. the
2237+
* same VPID as the host. Emulate this behavior by using vpid01 for L2
2238+
* if VPID is disabled in vmcs12. Note, if VPID is disabled, VM-Enter
2239+
* and VM-Exit are architecturally required to flush VPID=0, but *only*
2240+
* VPID=0. I.e. using vpid02 would be ok (so long as KVM emulates the
2241+
* required flushes), but doing so would cause KVM to over-flush. E.g.
2242+
* if L1 runs L2 X with VPID12=1, then runs L2 Y with VPID12 disabled,
2243+
* and then runs L2 X again, then KVM can and should retain TLB entries
2244+
* for VPID12=1.
2245+
*/
22322246
if (enable_vpid) {
22332247
if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02)
22342248
vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->nested.vpid02);
@@ -5827,6 +5841,12 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
58275841
return nested_vmx_fail(vcpu,
58285842
VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
58295843

5844+
/*
5845+
* Always flush the effective vpid02, i.e. never flush the current VPID
5846+
* and never explicitly flush vpid01. INVVPID targets a VPID, not a
5847+
* VMCS, and so whether or not the current vmcs12 has VPID enabled is
5848+
* irrelevant (and there may not be a loaded vmcs12).
5849+
*/
58305850
vpid02 = nested_get_vpid02(vcpu);
58315851
switch (type) {
58325852
case VMX_VPID_EXTENT_INDIVIDUAL_ADDR:

0 commit comments

Comments
 (0)