[kernel] Add missing zero_ok changes

This change adds some changes I missed as part of the previous (see
da5c1e9) zero_ok change.
This commit is contained in:
Justin C. Miller
2022-01-30 20:38:51 -08:00
parent 5e1e056623
commit 2aef7176ab
8 changed files with 27 additions and 42 deletions

View File

@@ -98,11 +98,12 @@ for id, scope, method in syscalls.methods:
args.append("self_obj")
type = f"obj::{scope.cname} *"
handles.append((type, "self", get_caps(method.options, scope)))
handles.append((scope.cname, "self", get_caps(method.options, scope)))
objparams.append((type, "self"))
for param in method.params:
needs_obj = param.type.needs_object(param.options)
needs_handle = ("handle" in param.options) or needs_obj
for type, suffix in param.type.c_names(param.options):
arg = f"{param.name}{suffix}"
@@ -110,17 +111,22 @@ for id, scope, method in syscalls.methods:
for type, suffix in param.type.cxx_names(param.options):
arg = f"{param.name}{suffix}"
cxxargdefs.append(f"{type} {arg}")
if needs_obj:
handles.append((type, arg, get_caps(param.options, param.type.object)))
objparams.append((type, arg))
args.append(f"{arg}_obj")
if needs_handle:
handles.append((param.type.object.cname, arg, get_caps(param.options, param.type.object)))
if needs_obj:
objparams.append((type, arg))
args.append(f"{arg}_obj")
cxxargdefs.append(f"{type} {arg}")
else:
args.append(f"{arg}_handle")
cxxargdefs.append(f"obj::handle *{arg}_handle")
break
else:
cxxargdefs.append(f"{type} {arg}")
args.append(arg)
if not needs_obj and param.caps:
if not needs_handle and param.caps:
handles.append((
f"obj::{param.type.object.cname}",
arg, get_caps(param.options, param.type.object)))
@@ -152,10 +158,7 @@ for id, scope, method in syscalls.methods:
cog.outl()
for type, arg, caps in handles:
if type.endswith('*'):
type = type[:-1].strip()
cog.outl(f" obj::handle *{arg}_handle = get_handle<typename {type}>({arg});")
cog.outl(f" obj::handle *{arg}_handle = get_handle<typename obj::{type}>({arg});")
cog.outl(f" if (!{arg}_handle) return j6_err_invalid_arg;")
if caps:

View File

@@ -28,11 +28,6 @@ endpoint_send(endpoint *self, uint64_t tag, const void * data, size_t data_len)
j6_status_t
endpoint_receive(endpoint *self, uint64_t * tag, void * data, size_t * data_len, uint64_t timeout)
{
// Data is marked optional, but we need the length, and if length > 0,
// data is not optional.
if (!data_len || (*data_len && !data))
return j6_err_invalid_arg;
// Use local variables instead of the passed-in pointers, since
// they may get filled in when the sender is running, which means
// a different user VM space would be active.

View File

@@ -11,9 +11,6 @@ namespace syscalls {
j6_status_t
handle_list(j6_handle_t *handles, size_t *handles_len)
{
if (!handles_len || (*handles_len && !handles))
return j6_err_invalid_arg;
process &p = process::current();
size_t requested = *handles_len;
@@ -26,16 +23,12 @@ handle_list(j6_handle_t *handles, size_t *handles_len)
}
j6_status_t
handle_clone(j6_handle_t orig, j6_handle_t *clone, uint32_t mask)
handle_clone(handle *orig, j6_handle_t *clone, uint32_t mask)
{
handle *orig_handle = get_handle<kobject>(orig);
if (!orig_handle)
return j6_err_invalid_arg;
process &p = process::current();
*clone = p.add_handle(
orig_handle->object,
orig_handle->caps() & mask);
orig->object,
orig->caps() & mask);
return j6_status_ok;
}

View File

@@ -13,7 +13,7 @@ j6_status_t
process_create(j6_handle_t *self)
{
process *p = construct_handle<process>(self);
log::debug(logs::task, "Process %llx created", p->koid());
log::info(logs::task, "Process %llx created", p->koid());
return j6_status_ok;
}
@@ -22,7 +22,7 @@ process_kill(process *self)
{
process &p = process::current();
log::debug(logs::task, "Process %llx killed by process %llx", self->koid(), p.koid());
log::info(logs::task, "Process %llx killed by process %llx", self->koid(), p.koid());
self->exit(-1u);
return j6_status_ok;
@@ -32,7 +32,7 @@ j6_status_t
process_exit(int32_t status)
{
process &p = process::current();
log::debug(logs::task, "Process %llx exiting with code %d", p.koid(), status);
log::info(logs::task, "Process %llx exiting with code %d", p.koid(), status);
p.exit(status);
@@ -41,13 +41,12 @@ process_exit(int32_t status)
}
j6_status_t
process_give_handle(process *self, j6_handle_t target, j6_handle_t *received)
process_give_handle(process *self, handle *target, j6_handle_t *received)
{
handle *target_handle = get_handle<kobject>(target);
j6_handle_t out = self->add_handle(target_handle->object, target_handle->caps());
j6_handle_t out = self->add_handle(target->object, target->caps());
if (received)
*received = out;
return j6_status_ok;
}

View File

@@ -39,11 +39,6 @@ noop()
j6_status_t
system_get_log(system *self, void *buffer, size_t *buffer_len)
{
// Buffer is marked optional, but we need the length, and if length > 0,
// buffer is not optional.
if (!buffer_len || (*buffer_len && !buffer))
return j6_err_invalid_arg;
size_t orig_size = *buffer_len;
*buffer_len = g_logger.get_entry(buffer, *buffer_len);
if (!g_logger.has_log())