Page MenuHomeFreeBSD

Add a sysctl to fetch virtual address space layout info
ClosedPublic

Authored by markj on Dec 31 2021, 3:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 7 2024, 3:52 PM
Unknown Object (File)
Feb 23 2024, 11:36 AM
Unknown Object (File)
Feb 6 2024, 4:13 AM
Unknown Object (File)
Dec 27 2023, 11:54 PM
Unknown Object (File)
Dec 24 2023, 5:27 AM
Unknown Object (File)
Dec 23 2023, 1:12 AM
Unknown Object (File)
Dec 12 2023, 12:24 AM
Unknown Object (File)
Nov 28 2023, 8:54 AM
Subscribers

Details

Summary

Use it to implement some logic in the kern_copyin test (rather than
assuming that PS_STRINGS is fixed by the ABI).

Diff Detail

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

Event Timeline

markj requested review of this revision.Dec 31 2021, 3:14 PM
sys/sys/user.h
605

I think it would be useful to pack all the information from struct vm_map and struct vmspace, which is potentially useful to userspace, into this kinfo.

For instance, all non-kernel flags from vm_map->flags, event though they are available by proccontrol, could be usefully reported there. All vm_Xsize and vm_Xaddr should be exported as well.

I think it is debatable but worth considering anon_loc and vm_stkgap (the later depends on the outcome of the stackgap rework, to be discussed in other place).

Please bump __FreeBSD_version for this change.

I have a use case for qemu-user for this, and am quite keen on knowing the whole address space, not just kvm_max_user_address (though that would be useful). Linux exports a set of ranges that are mapped that is used to find a 'hole' big enough for the guest.

hmmm, I could do the stuff I need in qemu w/o a version bump and it would likely be better in case this is MFC'd

In D33708#762020, @imp wrote:

Please bump __FreeBSD_version for this change.

I have a use case for qemu-user for this, and am quite keen on knowing the whole address space, not just kvm_max_user_address (though that would be useful). Linux exports a set of ranges that are mapped that is used to find a 'hole' big enough for the guest.

Isn't this already available via KERN_PROC_VMMAP? What information do you need, exactly?

In D33708#762020, @imp wrote:

Please bump __FreeBSD_version for this change.

I have a use case for qemu-user for this, and am quite keen on knowing the whole address space, not just kvm_max_user_address (though that would be useful). Linux exports a set of ranges that are mapped that is used to find a 'hole' big enough for the guest.

Isn't this already available via KERN_PROC_VMMAP? What information do you need, exactly?

I'll have to look at that. I think that may be what I need.

markj marked an inline comment as done.

Export more fields.

What about exporting pmap pm_stats as well?

sys/kern/kern_proc.c
3234

Why not do vm_map_min()/max() instead? sv_*user are only templates, and e.g. map_at_zero changes vm_map_min().

3243

I do not like the tie of the kernel-internal flags to the sysctl output, it moves them into ABI. IMO it should be the dedicated flags, translated.

In D33708#766133, @kib wrote:

What about exporting pmap pm_stats as well?

It seems rather orthogonal to the purpose of this sysctl, which exposes static information. The resident count can be obtained already in kinfo_proc.

sys/kern/kern_proc.c
3260

I copied the handling of 32-bit procs from sysctl_kern_proc_sigfastblk(), but this munging is ugly. Perhaps the compat32 fields should be defined as uint64_t instead, or the native kinfo_vm_layout definition should use uint64_t everywhere.

kib added inline comments.
sys/kern/kern_proc.c
3214

namelen is used only once?

This revision is now accepted and ready to land.Jan 14 2022, 5:57 PM