aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/kernel/vmem.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-07-07 14:34:39 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-07-07 14:34:39 +0300
commitd592abd8ccc4026c51e196777031eb65c4acc4de (patch)
treebfcffec608ede13653a21a56a5b731a4178ecda3 /arch/riscv64/kernel/vmem.c
parentd1c5e2700add7627e22c49a6021f200f03e8a62b (diff)
downloadkmi-d592abd8ccc4026c51e196777031eb65c4acc4de.tar.gz
kmi-d592abd8ccc4026c51e196777031eb65c4acc4de.zip
misc fixes
+ Align kernel to 2MiB boundary in u-boot + Optimize alignment functions a little bit, should still have to check on real hardware but 'feels' more clean + Add early boot debugging + Put extra cores we aren't ready to account for to sleep if/when they boot. + Make BASE_PAGE_SIZE constant on riscv64/32, helps the compiler with some alignment checks among other things.
Diffstat (limited to 'arch/riscv64/kernel/vmem.c')
-rw-r--r--arch/riscv64/kernel/vmem.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c
index 0aa35cc..cb1eba0 100644
--- a/arch/riscv64/kernel/vmem.c
+++ b/arch/riscv64/kernel/vmem.c
@@ -420,11 +420,15 @@ __aligned(4096) struct vmem bootvmem;
* it. */
__aligned(4096) struct vmem kvmem;
+/* adding a third page entry would let us map the kernel at any 4KiB boundary
+ * but eh, Linux seems fine with 2MiB so I guess I shall be as well. */
+
struct vmem *init_mapping()
{
rpc_pages = order_size(MM_O1) / BASE_PAGE_SIZE;
kvmem.leaf[0] = (struct vmem *)to_pte(get_load_addr(),
- VM_A | VM_G | VM_D | VM_R | VM_W | VM_X | VM_V);
+ VM_A | VM_G | VM_D | VM_R | VM_W |
+ VM_X | VM_V);
__populate_dmap(&bootvmem);
populate_kvmem(&bootvmem);
@@ -462,6 +466,13 @@ void destroy_vmem(struct vmem *b)
__destroy_branch(b);
}
+/**
+ * Helper for mapping in the kernel virtual page.
+ * Remember that the kernel lives on its own in a 2MiB (riscv64) region at
+ * VM_KERNEL, and \ref __va() and \ref __pa() won't directly work on it.
+ *
+ * @param b Branch to map kernel into.
+ */
static void map_kernel(struct vmem *b)
{
/* slightly worried about this not being guaranteed to be pc relative,