Skip to content

Commit 40c493d

Browse files
committed
Merge tag 'v6.12.19' into 6.12-main
This is the 6.12.19 stable release # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmfSyWAACgkQONu9yGCS # aT6h9hAAvinuPh+swTPtOpS13M1LPZ0hkby6MZ8zHWBRNlG3n+OYz8D2nwKFyckw # kHcAdNJs4CrrguAEUdY4j7I/V/nFF47NhyyStOfg7EUPEZe1mnEEw8VRGuqlUJGM # YEtlQq3hl4rfwjQVEcgHrcYCjPMH1h0PTBruvwuwpQZKQwXTS+U6NRCOhasUjyqo # UPYceOK2sJwYjoFqVbj+xLzITnzrfZVppgxQuWfMkABp+kKWCZ+uEFV/PzqvqVJW # J0nAFuNKH1CSEEgqCR1QqONT7tMPTObQYrbaDTqmab2aHj5l0qBEzt3I91orm4S/ # 6ajAVOxe5HOKbDw7j3Gzdq9dVh51gnC8dMw2xOmmDeA/+Q5aTMQH7RsyAJQQwohd # r9JJwMc+DO1w5tX7jOfua1BSMCD2tNdXt9M6PdiBv7fD6KQL1+hxCTbv4qKi/lOb # AoNeYSfWIi8zly8IRBpKHd4XDAKyqQUxNnjrCjPXs3Ej/d9EuXMymScUC08aFPEc # sjFxNCXzx7AnAEHfiHlsz6OuSxU1TwVX7E1Yet93nq6dDMOYiWaf6Xhw9U/3UyIQ # vr50VnucvJbPhwYGpfV4gT0TZicaLgDyrxYYE3jTrBBEwUFT2QlVLs6iRH3ci9Dg # TyfnfH9/HArOuBE4SNCYULDJlRIKkVzhKOIrqJWGovKpc5D1QtA= # =xsPz # -----END PGP SIGNATURE----- # gpg: Signature made Thu Mar 13 13:02:40 2025 CET # gpg: using RSA key 647F28654894E3BD457199BE38DBBDC86092693E # gpg: Can't check signature: No public key
2 parents 0d56f71 + e9cc806 commit 40c493d

File tree

335 files changed

+6008
-2448
lines changed

Some content is hidden

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

335 files changed

+6008
-2448
lines changed

.clippy.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
check-private-items = true
4+
5+
disallowed-macros = [
6+
# The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate
7+
# it here, see: https://github.com/rust-lang/rust-clippy/issues/11303.
8+
{ path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" },
9+
]

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ modules.order
103103
# We don't want to ignore the following even if they are dot-files
104104
#
105105
!.clang-format
106+
!.clippy.toml
106107
!.cocciconfig
107108
!.editorconfig
108109
!.get_maintainer.ignore

Documentation/admin-guide/sysctl/kernel.rst

+11
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ pid>/``).
212212
This value defaults to 0.
213213
214214

215+
core_sort_vma
216+
=============
217+
218+
The default coredump writes VMAs in address order. By setting
219+
``core_sort_vma`` to 1, VMAs will be written from smallest size
220+
to largest size. This is known to break at least elfutils, but
221+
can be handy when dealing with very large (and truncated)
222+
coredumps where the more useful debugging details are included
223+
in the smaller VMAs.
224+
225+
215226
core_uses_pid
216227
=============
217228

Documentation/rust/coding-guidelines.rst

+146
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,149 @@ The equivalent in Rust may look like (ignoring documentation):
227227
That is, the equivalent of ``GPIO_LINE_DIRECTION_IN`` would be referred to as
228228
``gpio::LineDirection::In``. In particular, it should not be named
229229
``gpio::gpio_line_direction::GPIO_LINE_DIRECTION_IN``.
230+
231+
232+
Lints
233+
-----
234+
235+
In Rust, it is possible to ``allow`` particular warnings (diagnostics, lints)
236+
locally, making the compiler ignore instances of a given warning within a given
237+
function, module, block, etc.
238+
239+
It is similar to ``#pragma GCC diagnostic push`` + ``ignored`` + ``pop`` in C
240+
[#]_:
241+
242+
.. code-block:: c
243+
244+
#pragma GCC diagnostic push
245+
#pragma GCC diagnostic ignored "-Wunused-function"
246+
static void f(void) {}
247+
#pragma GCC diagnostic pop
248+
249+
.. [#] In this particular case, the kernel's ``__{always,maybe}_unused``
250+
attributes (C23's ``[[maybe_unused]]``) may be used; however, the example
251+
is meant to reflect the equivalent lint in Rust discussed afterwards.
252+
253+
But way less verbose:
254+
255+
.. code-block:: rust
256+
257+
#[allow(dead_code)]
258+
fn f() {}
259+
260+
By that virtue, it makes it possible to comfortably enable more diagnostics by
261+
default (i.e. outside ``W=`` levels). In particular, those that may have some
262+
false positives but that are otherwise quite useful to keep enabled to catch
263+
potential mistakes.
264+
265+
On top of that, Rust provides the ``expect`` attribute which takes this further.
266+
It makes the compiler warn if the warning was not produced. For instance, the
267+
following will ensure that, when ``f()`` is called somewhere, we will have to
268+
remove the attribute:
269+
270+
.. code-block:: rust
271+
272+
#[expect(dead_code)]
273+
fn f() {}
274+
275+
If we do not, we get a warning from the compiler::
276+
277+
warning: this lint expectation is unfulfilled
278+
--> x.rs:3:10
279+
|
280+
3 | #[expect(dead_code)]
281+
| ^^^^^^^^^
282+
|
283+
= note: `#[warn(unfulfilled_lint_expectations)]` on by default
284+
285+
This means that ``expect``\ s do not get forgotten when they are not needed, which
286+
may happen in several situations, e.g.:
287+
288+
- Temporary attributes added while developing.
289+
290+
- Improvements in lints in the compiler, Clippy or custom tools which may
291+
remove a false positive.
292+
293+
- When the lint is not needed anymore because it was expected that it would be
294+
removed at some point, such as the ``dead_code`` example above.
295+
296+
It also increases the visibility of the remaining ``allow``\ s and reduces the
297+
chance of misapplying one.
298+
299+
Thus prefer ``expect`` over ``allow`` unless:
300+
301+
- Conditional compilation triggers the warning in some cases but not others.
302+
303+
If there are only a few cases where the warning triggers (or does not
304+
trigger) compared to the total number of cases, then one may consider using
305+
a conditional ``expect`` (i.e. ``cfg_attr(..., expect(...))``). Otherwise,
306+
it is likely simpler to just use ``allow``.
307+
308+
- Inside macros, when the different invocations may create expanded code that
309+
triggers the warning in some cases but not in others.
310+
311+
- When code may trigger a warning for some architectures but not others, such
312+
as an ``as`` cast to a C FFI type.
313+
314+
As a more developed example, consider for instance this program:
315+
316+
.. code-block:: rust
317+
318+
fn g() {}
319+
320+
fn main() {
321+
#[cfg(CONFIG_X)]
322+
g();
323+
}
324+
325+
Here, function ``g()`` is dead code if ``CONFIG_X`` is not set. Can we use
326+
``expect`` here?
327+
328+
.. code-block:: rust
329+
330+
#[expect(dead_code)]
331+
fn g() {}
332+
333+
fn main() {
334+
#[cfg(CONFIG_X)]
335+
g();
336+
}
337+
338+
This would emit a lint if ``CONFIG_X`` is set, since it is not dead code in that
339+
configuration. Therefore, in cases like this, we cannot use ``expect`` as-is.
340+
341+
A simple possibility is using ``allow``:
342+
343+
.. code-block:: rust
344+
345+
#[allow(dead_code)]
346+
fn g() {}
347+
348+
fn main() {
349+
#[cfg(CONFIG_X)]
350+
g();
351+
}
352+
353+
An alternative would be using a conditional ``expect``:
354+
355+
.. code-block:: rust
356+
357+
#[cfg_attr(not(CONFIG_X), expect(dead_code))]
358+
fn g() {}
359+
360+
fn main() {
361+
#[cfg(CONFIG_X)]
362+
g();
363+
}
364+
365+
This would ensure that, if someone introduces another call to ``g()`` somewhere
366+
(e.g. unconditionally), then it would be spotted that it is not dead code
367+
anymore. However, the ``cfg_attr`` is more complex than a simple ``allow``.
368+
369+
Therefore, it is likely that it is not worth using conditional ``expect``\ s when
370+
more than one or two configurations are involved or when the lint may be
371+
triggered due to non-local changes (such as ``dead_code``).
372+
373+
For more information about diagnostics in Rust, please see:
374+
375+
https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html

MAINTAINERS

+8
Original file line numberDiff line numberDiff line change
@@ -20178,13 +20178,21 @@ B: https://github.com/Rust-for-Linux/linux/issues
2017820178
C: zulip://rust-for-linux.zulipchat.com
2017920179
P: https://rust-for-linux.com/contributing
2018020180
T: git https://github.com/Rust-for-Linux/linux.git rust-next
20181+
F: .clippy.toml
2018120182
F: Documentation/rust/
2018220183
F: rust/
2018320184
F: samples/rust/
2018420185
F: scripts/*rust*
2018520186
F: tools/testing/selftests/rust/
2018620187
K: \b(?i:rust)\b
2018720188

20189+
RUST [ALLOC]
20190+
M: Danilo Krummrich <[email protected]>
20191+
20192+
S: Maintained
20193+
F: rust/kernel/alloc.rs
20194+
F: rust/kernel/alloc/
20195+
2018820196
RXRPC SOCKETS (AF_RXRPC)
2018920197
M: David Howells <[email protected]>
2019020198
M: Marc Dionne <[email protected]>

Makefile

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
VERSION = 6
33
PATCHLEVEL = 12
4-
SUBLEVEL = 18
4+
SUBLEVEL = 19
55
EXTRAVERSION =
66
NAME = Baby Opossum Posse
77

@@ -446,19 +446,23 @@ KBUILD_USERLDFLAGS := $(USERLDFLAGS)
446446
export rust_common_flags := --edition=2021 \
447447
-Zbinary_dep_depinfo=y \
448448
-Astable_features \
449-
-Dunsafe_op_in_unsafe_fn \
450449
-Dnon_ascii_idents \
450+
-Dunsafe_op_in_unsafe_fn \
451+
-Wmissing_docs \
451452
-Wrust_2018_idioms \
452453
-Wunreachable_pub \
453-
-Wmissing_docs \
454-
-Wrustdoc::missing_crate_level_docs \
455454
-Wclippy::all \
455+
-Wclippy::ignored_unit_patterns \
456456
-Wclippy::mut_mut \
457457
-Wclippy::needless_bitwise_bool \
458458
-Wclippy::needless_continue \
459459
-Aclippy::needless_lifetimes \
460460
-Wclippy::no_mangle_with_rust_abi \
461-
-Wclippy::dbg_macro
461+
-Wclippy::undocumented_unsafe_blocks \
462+
-Wclippy::unnecessary_safety_comment \
463+
-Wclippy::unnecessary_safety_doc \
464+
-Wrustdoc::missing_crate_level_docs \
465+
-Wrustdoc::unescaped_backticks
462466

463467
KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) \
464468
$(HOSTCFLAGS) -I $(srctree)/scripts/include
@@ -583,6 +587,9 @@ endif
583587
# Allows the usage of unstable features in stable compilers.
584588
export RUSTC_BOOTSTRAP := 1
585589

590+
# Allows finding `.clippy.toml` in out-of-srctree builds.
591+
export CLIPPY_CONF_DIR := $(srctree)
592+
586593
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC HOSTPKG_CONFIG
587594
export RUSTC RUSTDOC RUSTFMT RUSTC_OR_CLIPPY_QUIET RUSTC_OR_CLIPPY BINDGEN
588595
export HOSTRUSTC KBUILD_HOSTRUSTFLAGS
@@ -1060,6 +1067,11 @@ endif
10601067
KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
10611068
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
10621069

1070+
# userspace programs are linked via the compiler, use the correct linker
1071+
ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_LD_IS_LLD),yy)
1072+
KBUILD_USERLDFLAGS += --ld-path=$(LD)
1073+
endif
1074+
10631075
# make the checker run with the right architecture
10641076
CHECKFLAGS += --arch=$(ARCH)
10651077

arch/arm64/include/asm/hugetlb.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ extern int huge_ptep_set_access_flags(struct vm_area_struct *vma,
3434
unsigned long addr, pte_t *ptep,
3535
pte_t pte, int dirty);
3636
#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR
37-
extern pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
38-
unsigned long addr, pte_t *ptep);
37+
extern pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
38+
pte_t *ptep, unsigned long sz);
3939
#define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT
4040
extern void huge_ptep_set_wrprotect(struct mm_struct *mm,
4141
unsigned long addr, pte_t *ptep);

arch/arm64/mm/hugetlbpage.c

+25-36
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,11 @@ static int find_num_contig(struct mm_struct *mm, unsigned long addr,
100100

101101
static inline int num_contig_ptes(unsigned long size, size_t *pgsize)
102102
{
103-
int contig_ptes = 0;
103+
int contig_ptes = 1;
104104

105105
*pgsize = size;
106106

107107
switch (size) {
108-
#ifndef __PAGETABLE_PMD_FOLDED
109-
case PUD_SIZE:
110-
if (pud_sect_supported())
111-
contig_ptes = 1;
112-
break;
113-
#endif
114-
case PMD_SIZE:
115-
contig_ptes = 1;
116-
break;
117108
case CONT_PMD_SIZE:
118109
*pgsize = PMD_SIZE;
119110
contig_ptes = CONT_PMDS;
@@ -122,6 +113,8 @@ static inline int num_contig_ptes(unsigned long size, size_t *pgsize)
122113
*pgsize = PAGE_SIZE;
123114
contig_ptes = CONT_PTES;
124115
break;
116+
default:
117+
WARN_ON(!__hugetlb_valid_size(size));
125118
}
126119

127120
return contig_ptes;
@@ -163,24 +156,23 @@ static pte_t get_clear_contig(struct mm_struct *mm,
163156
unsigned long pgsize,
164157
unsigned long ncontig)
165158
{
166-
pte_t orig_pte = __ptep_get(ptep);
167-
unsigned long i;
168-
169-
for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) {
170-
pte_t pte = __ptep_get_and_clear(mm, addr, ptep);
171-
172-
/*
173-
* If HW_AFDBM is enabled, then the HW could turn on
174-
* the dirty or accessed bit for any page in the set,
175-
* so check them all.
176-
*/
177-
if (pte_dirty(pte))
178-
orig_pte = pte_mkdirty(orig_pte);
179-
180-
if (pte_young(pte))
181-
orig_pte = pte_mkyoung(orig_pte);
159+
pte_t pte, tmp_pte;
160+
bool present;
161+
162+
pte = __ptep_get_and_clear(mm, addr, ptep);
163+
present = pte_present(pte);
164+
while (--ncontig) {
165+
ptep++;
166+
addr += pgsize;
167+
tmp_pte = __ptep_get_and_clear(mm, addr, ptep);
168+
if (present) {
169+
if (pte_dirty(tmp_pte))
170+
pte = pte_mkdirty(pte);
171+
if (pte_young(tmp_pte))
172+
pte = pte_mkyoung(pte);
173+
}
182174
}
183-
return orig_pte;
175+
return pte;
184176
}
185177

186178
static pte_t get_clear_contig_flush(struct mm_struct *mm,
@@ -385,18 +377,13 @@ void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
385377
__pte_clear(mm, addr, ptep);
386378
}
387379

388-
pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
389-
unsigned long addr, pte_t *ptep)
380+
pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
381+
pte_t *ptep, unsigned long sz)
390382
{
391383
int ncontig;
392384
size_t pgsize;
393-
pte_t orig_pte = __ptep_get(ptep);
394-
395-
if (!pte_cont(orig_pte))
396-
return __ptep_get_and_clear(mm, addr, ptep);
397-
398-
ncontig = find_num_contig(mm, addr, ptep, &pgsize);
399385

386+
ncontig = num_contig_ptes(sz, &pgsize);
400387
return get_clear_contig(mm, addr, ptep, pgsize, ncontig);
401388
}
402389

@@ -538,6 +525,8 @@ bool __init arch_hugetlb_valid_size(unsigned long size)
538525

539526
pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
540527
{
528+
unsigned long psize = huge_page_size(hstate_vma(vma));
529+
541530
if (alternative_has_cap_unlikely(ARM64_WORKAROUND_2645198)) {
542531
/*
543532
* Break-before-make (BBM) is required for all user space mappings
@@ -547,7 +536,7 @@ pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addr
547536
if (pte_user_exec(__ptep_get(ptep)))
548537
return huge_ptep_clear_flush(vma, addr, ptep);
549538
}
550-
return huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
539+
return huge_ptep_get_and_clear(vma->vm_mm, addr, ptep, psize);
551540
}
552541

553542
void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep,

0 commit comments

Comments
 (0)