Page MenuHomeFreeBSD

Clean up initialization of phys_avail.
ClosedPublic

Authored by markj on Dec 6 2018, 10:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 8, 1:26 AM
Unknown Object (File)
Wed, Apr 3, 3:54 PM
Unknown Object (File)
Sat, Mar 30, 5:11 PM
Unknown Object (File)
Mar 13 2024, 8:03 AM
Unknown Object (File)
Mar 4 2024, 9:06 AM
Unknown Object (File)
Jan 14 2024, 9:14 AM
Unknown Object (File)
Dec 25 2023, 6:04 AM
Unknown Object (File)
Dec 22 2023, 9:56 PM
Subscribers

Details

Summary
  • Get rid of kern_delta. Its definition makes no sense: KERNBASE is a virtual address and kernstart is a physical address.
  • Don't use avail_slot to index into physmap[], that just appears to be bug.
  • Simplify the first stage of phys_avail[] initialization by avoiding the extra external if statement.
  • Clean up and fix some comments for the second stage of phys_avail[] initialization.
  • Rmeove some dead stores.
Test Plan

Booted under QEMU and spike. Used EARLY_PRINTF to verify
some values.

Diff Detail

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

Event Timeline

markj added reviewers: br, jhb.

This is inspired by PR 231515?

Also, I wonder if in general it would be simpler if we had a single loop to populate phys_avail[] at the end that just split regions as necessary to skip over '[kernstart, freemempos (but PA instead of VA)]'?

sys/riscv/riscv/pmap.c
607 ↗(On Diff #51689)

I think used_map_slot can be removed. I think the result of these lines is:

used_map_slot = map_slot;

/* Various bits that don't change map_slot. */

map_slot = used_map_slot;
609 ↗(On Diff #51689)

What is the purpose of this section of code? The loop that walks L2 slots results in 'va' being set, but then 'va' isn't used in the rest of the function AFAICT. The old version set 'pa' that wasn't used either. The arm64 pmap_bootstrap() uses 'va' and 'pa' in a call to pmap_bootstrap_l2() before the call to pmap_bootstrap_l3(), but riscv doesn't have a pmap_bootstrap_l2()?

markj marked 3 inline comments as done.
  • Further cleanup based on feedback.
In D18464#393352, @jhb wrote:

This is inspired by PR 231515?

Yes.

Also, I wonder if in general it would be simpler if we had a single loop to populate phys_avail[] at the end that just split regions as necessary to skip over '[kernstart, freemempos (but PA instead of VA)]'?

It seems to be simpler, I did that in the latest upload.

sys/riscv/riscv/pmap.c
609 ↗(On Diff #51689)

I agree that it doesn't do anything, so I removed it for now.

Sorry, I missed the last upload of this.

This revision is now accepted and ready to land.Dec 13 2018, 10:03 PM
This revision was automatically updated to reflect the committed changes.