[kernel] Add automatic verification to syscalls

Since we have a DSL for specifying syscalls, we can create a verificaton
method for each syscall that can cover most argument (and eventually
capability) verification instead of doing it piecemeal in each syscall
implementation, which can be more error-prone.

Now a new _syscall_verify_* function exists for every syscall, which
calls the real implementation. The syscall table for the syscall handler
now maps to these verify functions.

Other changes:

- Updated the definition grammar to allow options to have a "key:value"
  style, to eventually support capabilities.
- Added an "optional" option for parameters that says a syscall will
  accept a null value.
- Some bonnibel fixes, as definition file changes weren't always
  properly causing updates in the build dep graph.
- The syscall implementation function signatures are no longer exposed
  in syscall.h. Also, the unused syscall enum has been removed.
This commit is contained in:
Justin C. Miller
2022-01-16 15:11:58 -08:00
parent e845379b1e
commit e0246df26b
21 changed files with 415 additions and 219 deletions

View File

@@ -141,6 +141,7 @@ class Module:
inputs = []
parse_deps = []
parse_dep = "${module_dir}/.parse_dep.phony"
for start in self.sources:
source = start
@@ -148,6 +149,11 @@ class Module:
while source and source.action:
output = source.output
if source.action.parse_deps:
oodeps = [parse_dep]
else:
oodeps = []
if source.action.rule:
build.newline()
build.build(
@@ -156,6 +162,7 @@ class Module:
inputs = source.input,
implicit = list(map(resolve, source.deps)) +
list(source.action.deps),
order_only = oodeps,
variables = {"name": source.name},
)
@@ -167,7 +174,6 @@ class Module:
source = output
parse_dep = "${module_dir}/.parse_dep.phony"
build.newline()
build.build(
rule = "touch",
@@ -183,7 +189,7 @@ class Module:
rule = self.kind,
outputs = output,
inputs = inputs,
implicit = [parse_dep] + libs,
implicit = libs,
order_only = order_only,
)

View File

@@ -3,6 +3,7 @@ class Action:
implicit = property(lambda self: False)
rule = property(lambda self: None)
deps = property(lambda self: tuple())
parse_deps = property(lambda self: False)
def __init__(self, name):
self.__name = name
@@ -14,6 +15,7 @@ class Action:
class Compile(Action):
rule = property(lambda self: f'compile_{self.name}')
deps = property(lambda self: ("${module_dir}/.parse_dep.phony",))
parse_deps = property(lambda self: True)
def __init__(self, name, suffix = ".o"):
super().__init__(name)