Page MenuHomeFreeBSD

hyperv: Allow userland to ro-mmap reference TSC page
ClosedPublic

Authored by sepherosa_gmail.com on Dec 13 2016, 8:17 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 7, 9:24 AM
Unknown Object (File)
Sun, Apr 7, 9:23 AM
Unknown Object (File)
Mar 5 2024, 5:13 PM
Unknown Object (File)
Mar 5 2024, 1:40 AM
Unknown Object (File)
Mar 4 2024, 1:44 AM
Unknown Object (File)
Feb 22 2024, 2:51 PM
Unknown Object (File)
Dec 22 2023, 12:23 PM
Unknown Object (File)
Dec 22 2023, 12:22 PM
Subscribers
None

Details

Diff Detail

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

Event Timeline

sepherosa_gmail.com retitled this revision from to hyperv: Allow userland to ro-mmap reference TSC page.
sepherosa_gmail.com updated this object.
sepherosa_gmail.com edited the test plan for this revision. (Show Details)
sys/dev/hyperv/include/hyperv.h
69 ↗(On Diff #22859)

Why do not need packed ? ABI layout should be already correct.

I doubt that compiler and linker can ensure the requested alignment. Also IMO you should provide explicit padding at the end of the structure.

78 ↗(On Diff #22859)

Again, packed is useless there.

sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
94 ↗(On Diff #22859)

Do not check nprot argument, VM does not pass useful permission to drivers.
If HV allows write to the page, you might want to ensure that device is never opened for write, by checking the mode value in d_open(). Otherwise just ignore that.

sys/dev/hyperv/include/hyperv.h
69 ↗(On Diff #22859)

"packed" is not removed, it is there. Or do you mean why "packed" is needed? Since this struct may change and the layout may not promise "packed" later on, I'd prefer to keep the "packed".

The "aligned" is used to do the implicit padding here, the memory of this struct is allocated w/ busdma(9) w/ proper alignment. I considered the explicit padding, it would look like:
uint8_t tsc_rsvd[PAGE_SIZE - 24];
This does not look nice to me.

78 ↗(On Diff #22859)

That's old code, I don't want to mix changes here. And well, it's used by PDU between VM and hypervisor, I'd prefer to keep the "packed".

sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
94 ↗(On Diff #22859)

Heh, interesting. I will adjust the d_mmap and add d_open then.

Use d_open to prevent write mmap, pointed out by kib

sys/dev/hyperv/include/hyperv.h
69 ↗(On Diff #22859)

This was a typo. I do not see a need in the packed there.

And yes, I prefer explicit padding. This, together with the assert about the structure size, makes future modifications easier, in fact.

kib edited edge metadata.
This revision is now accepted and ready to land.Dec 14 2016, 8:50 AM
This revision was automatically updated to reflect the committed changes.