Page MenuHomeFreeBSD

makesyscalls.lua: improve syscall ordering validation
ClosedPublic

Authored by kevans on Aug 4 2020, 2:13 PM.

Details

Summary

There were two separate issues here:

1.) #if/#else wasn't taken into account at all for maxsyscall figures, but
2.) We didn't validate contiguous syscall numbers anyways...

This kind of inconsistency is bad as we don't currently ensure explicit
indexing of, e.g., the sysent array if one syscall is unimplemented/missing.
This could be fixed and might be more robust, but it's also good to have the
"documentation" that comes from being explicit as to what the missing
syscalls are.

The new version looks much like the awk version; stash off the current
'last highest syscall seen' if we hit an #if, restore to that if we hit an
#else, and make sure that we're explicitly always defining the next syscall.

The logic at the tail end of process_syscall_def that moves maxsyscall has
been 'cleaned up' a little since we're now ensuring that it's monotonically
increasing earlier in the function. At the moment I think it's unlikely we'd
see range-definitions that are not UNIMPL, but there's no reason to
specifically handle that case for bumping maxsyscall there.

This change was provoked by reading the commit message for rS363832 and
realizing that this validation hadn't been included in the initial rewrite
to lua.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kevans requested review of this revision.Aug 4 2020, 2:13 PM

I'm a little skeptical the #if code makes sense. I suspect it might be a historical artifact.

This revision is now accepted and ready to land.Aug 4 2020, 7:33 PM

I'm a little skeptical the #if code makes sense. I suspect it might be a historical artifact.

It's necessary now because of, e.g., freebsd32/syscalls.master; there's an if/else block where we define different variants of the same block of syscalls. If we can get rid of that, I reckon that logic can go away.

I'm a little skeptical the #if code makes sense. I suspect it might be a historical artifact.

It's necessary now because of, e.g., freebsd32/syscalls.master; there's an if/else block where we define different variants of the same block of syscalls. If we can get rid of that, I reckon that logic can go away.

Right, I forgot about that, it's been too long since I looked at generating compat/freebsd32/* from kern/syscalls.master. We'll want to do that automatically (I guess as something that conditionally expands to int pad, along with splitting the off_ts.)