tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: RFC: New userspace fetch/store API




> On Feb 24, 2019, at 10:28 AM, David Holland <dholland-tech%netbsd.org@localhost> wrote:
> 
> No, even if you know what the alignment's supposed to be, you can't
> legally check it. Or maybe you can, but it's in any event tangled in a
> bunch of language-lawyering.
> 
> Also, these days you can expect the compiler to simply remove such
> checks on the grounds that all pointers to types with required
> alignment are expected to be already aligned.

Grumble, mumble… ok, fair.

> The ones I remember looking at (which is not all of them, and probably
> not alpha) didn't test onfault until they got to we_re_toast, meaning
> any fault is already covered. But in any event it's free at runtime
> (the sense of free I meant) because you only get to it when a trap
> would otherwise be triggering a panic.

I guess I’ll audit them as part of the process.

> It's only not free on architectures where there are special
> instructions for accessing usermode and they need to be explicitly
> checked for failure rather than using on-fault logic; in that case you
> might also need an explicit alignment check to avoid allowing bad
> pointers to trigger a panic. That check should be in the MD code for
> such ports. (If there even are any... I think there exist machines
> that work this way, not sure we run on any of them.) 

m68k uses special instructions to access user space (well, “the other address space”) … but they also don’t have alignment constraints.  Hilarious!

-- thorpej



Home | Main Index | Thread Index | Old Index