* linux-next: manual merge of the risc-v tree with the mm tree
@ 2026-10-12 15:59 Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-10-12 15:59 UTC (permalink / raw)
To: Palmer Dabbelt, Paul Walmsley
Cc: Andrew Morton, David Hildenbrand, Jisheng Zhang,
Linux Kernel Mailing List, Linux Next Mailing List,
Mike Rapoport, Muchun Song, Paul Walmsley, Vlastimil Babka
[-- Attachment #1: Type: text/plain, Size: 11118 bytes --]
Hi all,
Today's linux-next merge of the risc-v tree got a conflict in:
arch/riscv/mm/init.c
between commit:
f02f1d1437449 ("riscv/mm: fix hotplug page-table destructor handling")
from the mm tree and commit:
79113093e9dc3 ("riscv: convert pgtable_l4|l5_enabled to inline function")
from the risc-v tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --combined arch/riscv/mm/init.c
index 6f6b04795bb23,e2b738ca90cf3..0000000000000
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@@ -6,6 -6,11 +6,11 @@@
* Nick Kossifidis <mick@ics.forth.gr>
*/
+ #ifdef CONFIG_64BIT
+ /* riscv_has_extension_likely() cannot be used this early */
+ #define USE_EARLY_PGTABLE_LEVELS
+ #endif
+
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/memblock.h>
@@@ -22,7 -27,6 +27,7 @@@
#include <linux/hugetlb.h>
#include <linux/kfence.h>
#include <linux/execmem.h>
+#include <linux/vmemmap-optimization.h>
#include <asm/alternative.h>
#include <asm/fixmap.h>
@@@ -53,10 -57,8 +58,8 @@@ u64 satp_mode __ro_after_init = SATP_MO
EXPORT_SYMBOL(satp_mode);
#ifdef CONFIG_64BIT
- bool pgtable_l4_enabled __ro_after_init = true;
- bool pgtable_l5_enabled __ro_after_init = true;
- EXPORT_SYMBOL(pgtable_l4_enabled);
- EXPORT_SYMBOL(pgtable_l5_enabled);
+ bool _pgtable_l4_enabled __ro_after_init = true;
+ bool _pgtable_l5_enabled __ro_after_init = true;
#endif
phys_addr_t phys_ram_base __ro_after_init;
@@@ -186,7 -188,7 +189,7 @@@ void __init arch_mm_preinit(void
*/
unsigned long size =
DIV_ROUND_UP(memblock_phys_mem_size(), 1024);
- swiotlb_adjust_size(min(swiotlb_size_or_default(), size));
+ swiotlb_adjust_size(min(swiotlb_default_pool_size(), size));
swiotlb = true;
swiotlb_flags |= SWIOTLB_ANY;
}
@@@ -653,23 -655,23 +656,23 @@@ static void __meminit create_p4d_mappin
}
#define pgd_next_t p4d_t
- #define alloc_pgd_next(__va) (pgtable_l5_enabled ? \
- pt_ops.alloc_p4d(__va) : (pgtable_l4_enabled ? \
+ #define alloc_pgd_next(__va) (pgtable_l5_enabled() ? \
+ pt_ops.alloc_p4d(__va) : (pgtable_l4_enabled() ? \
pt_ops.alloc_pud(__va) : pt_ops.alloc_pmd(__va)))
- #define get_pgd_next_virt(__pa) (pgtable_l5_enabled ? \
- pt_ops.get_p4d_virt(__pa) : (pgd_next_t *)(pgtable_l4_enabled ? \
+ #define get_pgd_next_virt(__pa) (pgtable_l5_enabled() ? \
+ pt_ops.get_p4d_virt(__pa) : (pgd_next_t *)(pgtable_l4_enabled() ? \
pt_ops.get_pud_virt(__pa) : (pud_t *)pt_ops.get_pmd_virt(__pa)))
#define create_pgd_next_mapping(__nextp, __va, __pa, __sz, __prot) \
- (pgtable_l5_enabled ? \
+ (pgtable_l5_enabled() ? \
create_p4d_mapping(__nextp, __va, __pa, __sz, __prot) : \
- (pgtable_l4_enabled ? \
+ (pgtable_l4_enabled() ? \
create_pud_mapping((pud_t *)__nextp, __va, __pa, __sz, __prot) : \
create_pmd_mapping((pmd_t *)__nextp, __va, __pa, __sz, __prot)))
- #define fixmap_pgd_next (pgtable_l5_enabled ? \
- (uintptr_t)fixmap_p4d : (pgtable_l4_enabled ? \
+ #define fixmap_pgd_next (pgtable_l5_enabled() ? \
+ (uintptr_t)fixmap_p4d : (pgtable_l4_enabled() ? \
(uintptr_t)fixmap_pud : (uintptr_t)fixmap_pmd))
- #define trampoline_pgd_next (pgtable_l5_enabled ? \
- (uintptr_t)trampoline_p4d : (pgtable_l4_enabled ? \
+ #define trampoline_pgd_next (pgtable_l5_enabled() ? \
+ (uintptr_t)trampoline_p4d : (pgtable_l4_enabled() ? \
(uintptr_t)trampoline_pud : (uintptr_t)trampoline_pmd))
#else
#define pgd_next_t pte_t
@@@ -714,11 -716,11 +717,11 @@@ static uintptr_t __meminit best_map_siz
if (debug_pagealloc_enabled())
return PAGE_SIZE;
- if (pgtable_l5_enabled &&
+ if (pgtable_l5_enabled() &&
!(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE)
return P4D_SIZE;
- if (pgtable_l4_enabled &&
+ if (pgtable_l4_enabled() &&
!(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE)
return PUD_SIZE;
@@@ -770,14 -772,14 +773,14 @@@ u64 __pi_set_satp_mode_from_fdt(uintptr
static void __init disable_pgtable_l5(void)
{
- pgtable_l5_enabled = false;
+ _pgtable_l5_enabled = false;
kernel_map.page_offset = PAGE_OFFSET_L4;
satp_mode = SATP_MODE_48;
}
static void __init disable_pgtable_l4(void)
{
- pgtable_l4_enabled = false;
+ _pgtable_l4_enabled = false;
kernel_map.page_offset = PAGE_OFFSET_L3;
satp_mode = SATP_MODE_39;
}
@@@ -840,6 -842,14 +843,14 @@@ static __init void set_satp_mode(uintpt
kernel_map.page_offset = PAGE_OFFSET_L5;
+ /* Fall back to SV48 if RISCV_ISA_SV57 isn't enabled */
+ if (!IS_ENABLED(CONFIG_RISCV_ISA_SV57) && satp_mode_limit == 0)
+ satp_mode_limit = SATP_MODE_48;
+
+ /* Fall back to SV39 if RISCV_ISA_SV48 isn't enabled */
+ if (!IS_ENABLED(CONFIG_RISCV_ISA_SV48) && satp_mode_limit == SATP_MODE_48)
+ satp_mode_limit = SATP_MODE_39;
+
if (satp_mode_limit == SATP_MODE_48) {
disable_pgtable_l5();
} else if (satp_mode_limit == SATP_MODE_39) {
@@@ -868,7 -878,7 +879,7 @@@ retry
create_pgd_mapping(early_pg_dir,
set_satp_mode_pmd,
- pgtable_l5_enabled ?
+ pgtable_l5_enabled() ?
(uintptr_t)early_p4d : (uintptr_t)early_pud,
PGDIR_SIZE, PAGE_TABLE);
@@@ -880,7 -890,7 +891,7 @@@
local_flush_tlb_all();
if (hw_satp != identity_satp) {
- if (pgtable_l5_enabled) {
+ if (pgtable_l5_enabled()) {
disable_pgtable_l5();
memset(early_pg_dir, 0, PAGE_SIZE);
goto retry;
@@@ -893,6 -903,10 +904,10 @@@ out
memset(early_p4d, 0, PAGE_SIZE);
memset(early_pud, 0, PAGE_SIZE);
memset(early_pmd, 0, PAGE_SIZE);
+ if (pgtable_l4_enabled())
+ set_bit(RISCV_ISA_EXT_SV48, riscv_isa);
+ if (pgtable_l5_enabled())
+ set_bit(RISCV_ISA_EXT_SV57, riscv_isa);
}
#endif
@@@ -1121,11 -1135,11 +1136,11 @@@ asmlinkage void __init setup_vm(uintptr
#ifndef __PAGETABLE_PMD_FOLDED
/* Setup fixmap P4D and PUD */
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
create_p4d_mapping(fixmap_p4d, FIXADDR_START,
(uintptr_t)fixmap_pud, P4D_SIZE, PAGE_TABLE);
/* Setup fixmap PUD and PMD */
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
create_pud_mapping(fixmap_pud, FIXADDR_START,
(uintptr_t)fixmap_pmd, PUD_SIZE, PAGE_TABLE);
create_pmd_mapping(fixmap_pmd, FIXADDR_START,
@@@ -1133,10 -1147,10 +1148,10 @@@
/* Setup trampoline PGD and PMD */
create_pgd_mapping(trampoline_pg_dir, kernel_map.virt_addr,
trampoline_pgd_next, PGDIR_SIZE, PAGE_TABLE);
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
create_p4d_mapping(trampoline_p4d, kernel_map.virt_addr,
(uintptr_t)trampoline_pud, P4D_SIZE, PAGE_TABLE);
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
create_pud_mapping(trampoline_pud, kernel_map.virt_addr,
(uintptr_t)trampoline_pmd, PUD_SIZE, PAGE_TABLE);
create_pmd_mapping(trampoline_pmd, kernel_map.virt_addr,
@@@ -1407,7 -1421,7 +1422,7 @@@ static void __init preallocate_pgd_page
if (!p4d)
goto failed;
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
continue;
lvl = "pud";
@@@ -1415,7 -1429,7 +1430,7 @@@
if (!pud)
goto failed;
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
continue;
lvl = "pmd";
@@@ -1486,17 -1500,10 +1501,17 @@@ struct execmem_info __init *execmem_arc
#endif /* CONFIG_EXECMEM */
#ifdef CONFIG_MEMORY_HOTPLUG
+static void __meminit free_pgtable_page(struct page *page)
+{
+ if (PageReserved(page))
+ free_reserved_page(page);
+ else
+ pagetable_free(page_ptdesc(page));
+}
+
static void __meminit free_pte_table(pte_t *pte_start, pmd_t *pmd)
{
struct page *page = pmd_page(*pmd);
- struct ptdesc *ptdesc = page_ptdesc(page);
pte_t *pte;
int i;
@@@ -1506,13 -1513,18 +1521,13 @@@
return;
}
- pagetable_dtor(ptdesc);
- if (PageReserved(page))
- free_reserved_page(page);
- else
- pagetable_free(ptdesc);
+ free_pgtable_page(page);
pmd_clear(pmd);
}
-static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud, bool is_vmemmap)
+static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud)
{
struct page *page = pud_page(*pud);
- struct ptdesc *ptdesc = page_ptdesc(page);
pmd_t *pmd;
int i;
@@@ -1522,7 -1534,12 +1537,7 @@@
return;
}
- if (!is_vmemmap)
- pagetable_dtor(ptdesc);
- if (PageReserved(page))
- free_reserved_page(page);
- else
- pagetable_free(ptdesc);
+ free_pgtable_page(page);
pud_clear(pud);
}
@@@ -1538,7 -1555,10 +1553,7 @@@ static void __meminit free_pud_table(pu
return;
}
- if (PageReserved(page))
- free_reserved_page(page);
- else
- __free_pages(page, 0);
+ free_pgtable_page(page);
p4d_clear(p4d);
}
@@@ -1621,13 -1641,13 +1636,13 @@@ static void __meminit remove_pud_mappin
for (; addr < end; addr = next) {
next = pud_addr_end(addr, end);
- pudp = pgtable_l4_enabled ? pud_base + pud_index(addr) : pud_base;
+ pudp = pgtable_l4_enabled() ? pud_base + pud_index(addr) : pud_base;
pud = pudp_get(pudp);
if (!pud_present(pud))
continue;
if (pud_leaf(pud)) {
- if (pgtable_l4_enabled) {
+ if (pgtable_l4_enabled()) {
pud_clear(pudp);
if (is_vmemmap)
free_vmemmap_storage(pud_page(pud), PUD_SIZE, altmap);
@@@ -1638,8 -1658,8 +1653,8 @@@
pmd_base = pmd_offset(pudp, 0);
remove_pmd_mapping(pmd_base, addr, next, is_vmemmap, altmap);
- if (pgtable_l4_enabled)
- free_pmd_table(pmd_base, pudp);
+ if (pgtable_l4_enabled())
+ free_pmd_table(pmd_base, pudp, is_vmemmap);
}
}
@@@ -1652,13 -1672,13 +1667,13 @@@ static void __meminit remove_p4d_mappin
for (; addr < end; addr = next) {
next = p4d_addr_end(addr, end);
- p4dp = pgtable_l5_enabled ? p4d_base + p4d_index(addr) : p4d_base;
+ p4dp = pgtable_l5_enabled() ? p4d_base + p4d_index(addr) : p4d_base;
p4d = p4dp_get(p4dp);
if (!p4d_present(p4d))
continue;
if (p4d_leaf(p4d)) {
- if (pgtable_l5_enabled) {
+ if (pgtable_l5_enabled()) {
p4d_clear(p4dp);
if (is_vmemmap)
free_vmemmap_storage(p4d_page(p4d), P4D_SIZE, altmap);
@@@ -1669,7 -1689,7 +1684,7 @@@
pud_base = pud_offset(p4dp, 0);
remove_pud_mapping(pud_base, addr, next, is_vmemmap, altmap);
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
free_pud_table(pud_base, p4dp);
}
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: linux-next: manual merge of the risc-v tree with the mm tree
2025-04-03 23:54 Stephen Rothwell
@ 2025-04-06 23:35 ` Stephen Rothwell
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Rothwell @ 2025-04-06 23:35 UTC (permalink / raw)
To: Andrew Morton
Cc: Palmer Dabbelt, Paul Walmsley, Alexandre Ghiti,
Andrew Bresticker, Linux Kernel Mailing List,
Linux Next Mailing List, Matthew Wilcox (Oracle)
[-- Attachment #1: Type: text/plain, Size: 1657 bytes --]
Hi all,
On Fri, 4 Apr 2025 10:54:40 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the risc-v tree got a conflict in:
>
> arch/riscv/include/asm/pgtable.h
>
> between commit:
>
> 012d57e6ee75 ("mm: introduce a common definition of mk_pte()")
>
> from the mm tree and commit:
>
> 03dc00a2b678 ("riscv: Support huge pfnmaps")
>
> from the risc-v tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging. You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
>
>
> diff --cc arch/riscv/include/asm/pgtable.h
> index 293a7776fe07,428e48e5f57d..000000000000
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@@ -339,6 -343,16 +343,14 @@@ static inline pte_t pfn_pte(unsigned lo
> return __pte((pfn << _PAGE_PFN_SHIFT) | prot_val);
> }
>
> -#define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot)
> -
> + #define pte_pgprot pte_pgprot
> + static inline pgprot_t pte_pgprot(pte_t pte)
> + {
> + unsigned long pfn = pte_pfn(pte);
> +
> + return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte));
> + }
> +
> static inline int pte_present(pte_t pte)
> {
> return (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
This is now a conflict between the mm tree and Linus' tree.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* linux-next: manual merge of the risc-v tree with the mm tree
@ 2025-04-03 23:54 Stephen Rothwell
2025-04-06 23:35 ` Stephen Rothwell
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Rothwell @ 2025-04-03 23:54 UTC (permalink / raw)
To: Palmer Dabbelt, Paul Walmsley, Andrew Morton
Cc: Alexandre Ghiti, Andrew Bresticker, Linux Kernel Mailing List,
Linux Next Mailing List, Matthew Wilcox (Oracle)
[-- Attachment #1: Type: text/plain, Size: 1421 bytes --]
Hi all,
Today's linux-next merge of the risc-v tree got a conflict in:
arch/riscv/include/asm/pgtable.h
between commit:
012d57e6ee75 ("mm: introduce a common definition of mk_pte()")
from the mm tree and commit:
03dc00a2b678 ("riscv: Support huge pfnmaps")
from the risc-v tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
--
Cheers,
Stephen Rothwell
diff --cc arch/riscv/include/asm/pgtable.h
index 293a7776fe07,428e48e5f57d..000000000000
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@@ -339,6 -343,16 +343,14 @@@ static inline pte_t pfn_pte(unsigned lo
return __pte((pfn << _PAGE_PFN_SHIFT) | prot_val);
}
-#define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot)
-
+ #define pte_pgprot pte_pgprot
+ static inline pgprot_t pte_pgprot(pte_t pte)
+ {
+ unsigned long pfn = pte_pfn(pte);
+
+ return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte));
+ }
+
static inline int pte_present(pte_t pte)
{
return (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-12 15:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-12 15:59 linux-next: manual merge of the risc-v tree with the mm tree Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2025-04-03 23:54 Stephen Rothwell
2025-04-06 23:35 ` Stephen Rothwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®