tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
linux compat code vs netbsd kernel-internal negative error numbers
hi folks.
my laptop has been crashing in i915 the last few days and we finally
tracked down the cause. cv_wait_sig() can return ERESTART, which has
the value of -3. when linux code returns errors it often does it
encoded in a pointer, and in the low negative range, so typically a
return value is 0, or negative errno. this means that -ERESTART turns
into positive 3 and then eg, our PTR_ERR() macro asserts that the
errno is not less than zero.
so, the basic problem is that netbsd errnos are in the range -6 ..
95, linux has them all positive, and declares special handling for
negative values in many cases, and these aren't easy to reconcile.
there are two ways i can see to fix this.
- all errno interactions with linux style code bases need to have
their values mapped to/from linux in all cases, and that the
mapped values probably need to be unique. it may be that only
ERESTART needs handling (could only remap this, and assert the
others aren't set.) this means updating a lot of code, though
the vast majority have a common comment.
- re-number these for netbsd. i am running a kernel where the
negative values have 255 addded to them. (current ELAST is 96,
so there's quite a lot of space left.)
the first one means not changing our old style for kernel-only
errors, but i'm really a fan of that anyway. the second does
mean giving up a minor ability to check quickly (user errno should
be a small positive number, vs, range or similiar check. i could
not find any of these checks anyway, so maybe not a real issue.)
i think i prefer the second because it is both simpler to deal with
means not having to constantly patch new code for the remap, but it
does seem disappointing to have to give up this "feature" so we can
have nice things.
any suggestions or preferences?
.mrg.
Home |
Main Index |
Thread Index |
Old Index