Page MenuHomeFreeBSD

libkvm: Fix the kvm_walk_pages in amd64
ClosedPublic

Authored by emaste on Feb 13 2019, 9:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 16 2024, 6:15 PM
Unknown Object (File)
Feb 8 2024, 6:31 PM
Unknown Object (File)
Feb 8 2024, 10:33 AM
Unknown Object (File)
Feb 2 2024, 10:09 AM
Unknown Object (File)
Jan 13 2024, 12:16 AM
Unknown Object (File)
Dec 21 2023, 5:13 AM
Unknown Object (File)
Dec 20 2023, 12:52 AM
Unknown Object (File)
Dec 11 2023, 12:07 AM
Subscribers

Details

Summary

kvm_walk_pages did not work at all on amd64. Fixed it so that it correctly accesses the bitmap instead of going past it's length.

submitted by: Bora Ozarslan borako.ozarslan@gmail.com

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/libkvm/kvm_minidump_amd64.c
373 ↗(On Diff #53890)

Whitespace nit: s/){/) {/

Will should really review this since he added this API.

For the first part of the the hunk, the current code invokes a single callback for each superpage passing in the length of the superpage. The patch just splits this up into 512 4K calls instead. I think the old code there is probably more correct and efficient even though the comment is stale and implies the loop used by the new code. I think the kvm_bitmap_next changes are the actual fixes?

will requested changes to this revision.Oct 11 2019, 5:17 PM

Thanks for the add!

In D19183#479806, @jhb wrote:

For the first part of the the hunk, the current code invokes a single callback for each superpage passing in the length of the superpage. The patch just splits this up into 512 4K calls instead. I think the old code there is probably more correct and efficient even though the comment is stale and implies the loop used by the new code.

Yes, the comment is obviously stale, from a much earlier version of the implementation. I think the patch should instead fix the comment. Requesting this change.

I think the kvm_bitmap_next changes are the actual fixes?

Yes. I think this part of the change is correct (though I prefer the constant vs bare 8s). *idx and first_invalid were meant to use bits as units. It seems the correctness of the previous version was not properly validated. Thanks!

lib/libkvm/kvm_private.c
786

Why? The constant makes clear this number is derived from the number of bits in an bm->map.

This revision now requires changes to proceed.Oct 11 2019, 5:17 PM
lib/libkvm/kvm_private.c
786

I almost made the same comment (in the name of having a smaller diff), but then I noticed that _kvm_bitmap_set() uses bare 8's.

lib/libkvm/kvm_private.c
786

Good point, but if we are changing anything here, I'd fix that usage to match, rather than the other way around.

emaste updated this revision to Diff 99023.
emaste edited reviewers, added: borako.ozarslan_gmail.com; removed: emaste.

Limit to just the _kvm_bitmap_next changes, restoring use of CHAR_BIT.
Comment can be fixed in a separate change.

lib/libkvm/kvm_private.c
795–796

just 1U I guess, will update locally

This revision was not accepted when it landed; it landed in state Needs Review.Dec 10 2021, 7:16 PM
This revision was automatically updated to reflect the committed changes.