Page MenuHomeFreeBSD

RISC-V: use physmem to manage physical memory
ClosedPublic

Authored by mhorne on Mar 22 2020, 6:38 PM.
Tags
None
Referenced Files
F103162022: D24154.diff
Thu, Nov 21, 6:29 PM
Unknown Object (File)
Thu, Nov 21, 4:59 AM
Unknown Object (File)
Thu, Nov 7, 4:02 PM
Unknown Object (File)
Thu, Nov 7, 3:32 PM
Unknown Object (File)
Fri, Nov 1, 9:43 PM
Unknown Object (File)
Oct 17 2024, 11:28 AM
Unknown Object (File)
Oct 14 2024, 9:53 PM
Unknown Object (File)
Oct 14 2024, 6:01 PM
Subscribers

Details

Summary

Replace our hand-rolled functions with the generic ones provided by
kern/subr_physmem.c. This greatly simplifies the initialization of
physical memory regions and kernel globals.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I've found this to fail to boot, because it didn't reserve memory for the DTB (supplied by BBL). I'm not entirely sure if that's a result of an issue with your patch, or if there's something wrong in our local tree.

How is the DTB memory supposed to be reserved?

The following fixes the immediate problem for me:

@@ -806,9 +808,11 @@ initriscv(struct riscv_bootparams *rvbp)
 #ifdef FDT
        try_load_dtb(kmdp, rvbp->dtbp_virt);
 #endif
+       /* Reserve memory for the DTB. */
+       physmem_exclude_region(rvbp->dtbp_phys, L2_SIZE, EXFLAG_NOALLOC);
In D24154#532404, @kp wrote:

I've found this to fail to boot, because it didn't reserve memory for the DTB (supplied by BBL). I'm not entirely sure if that's a result of an issue with your patch, or if there's something wrong in our local tree.

How is the DTB memory supposed to be reserved?

The following fixes the immediate problem for me:

@@ -806,9 +808,11 @@ initriscv(struct riscv_bootparams *rvbp)
 #ifdef FDT
        try_load_dtb(kmdp, rvbp->dtbp_virt);
 #endif
+       /* Reserve memory for the DTB. */
+       physmem_exclude_region(rvbp->dtbp_phys, L2_SIZE, EXFLAG_NOALLOC);

Looks like I missed linking one of the parents. This patch also depends on D24152.

Looks like I missed linking one of the parents. This patch also depends on D24152.

Thanks! I should have realised. I'd already seen the other patch, but somehow neglected to include it in my tests.

sys/riscv/riscv/machdep.c
858 ↗(On Diff #69943)

Do you prefer to use square brackets for a single line statements?

Ping. Any opposition to this one? I would like to commit the set of patches soon.

These changes look good. I can confirm that this works.

Keep physmap globals in machdep.c.

This revision was not accepted when it landed; it landed in state Needs Review.Apr 19 2020, 12:18 AM
This revision was automatically updated to reflect the committed changes.