tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Another kvm user can go away?
On Fri, 30 Dec 2016, Simon Burge wrote:
One thing to be careful of is 64-bit safe alignment of the sysctl
structures. The first structure is ok:
+/* info for a single kernhist */
+struct sysctl_history_list_entry {
+ uint32_t shle_nameoffset;
+ uint32_t shle_numentries;
+ uint32_t shle_nextfree;
+ uint32_t shle_filler;
+};
But for the second structure, I don't think the "struct timeval" is
64-bit alignment safe (unless something has changed in the last few
years):
+/* info for a single history event */
+struct sysctl_history_event {
+ struct timeval she_tv;
+ uint64_t she_callnumber;
+ uint64_t she_values[4];
+ uint32_t she_cpunum;
+ uint32_t she_fmtoffset;
+ uint32_t she_funcoffset;
+ uint32_t she_filler;
+};
Some of the original sysctl stuff used uint32_t for the seconds part of
a timeval, but I suspect you'd want to use a uint64_t nowadays. You
might end up with something like:
struct sysctl_history_event {
uint64_t she_tv_sec;
uint32_t she_tv_usec;
uint32_t she_pad1;
uint64_t she_callnumber;
uint64_t she_values[4];
...
Any suggestions on how to ensure proper alignment? There doesn't seem
to be any way to kmem_allocate() what alignment is needed... :) It
seems to currently always provide 64-bit (8-byte) alignment, but the man
page makes no guarantees.
I guess I could allocate an extra 8 bytes, and then manipulate the
returned address... But that just "feels wrong". :)
+------------------+--------------------------+------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+
Home |
Main Index |
Thread Index |
Old Index