From 298636079d912d0936f8156a609fe74b839c547b Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 9 Jul 2024 17:35:56 +0300 Subject: allow mapping null page + User has to 'free' the 0 page before it becomes accessible to mapping. Probably worth noting that this is likely VERY niche and mainly concerns stuff like certain kinds of emulators that I'm still eons from implementing, but still. Unbacked pages can also be useful for some kinds of notifications, like 'if someone writes to this page, please report it to me with this ID' or whatever, I remember seeing some discussion about it somewhere but that's also not really relevant for the moment. Most significantly, at least with the current design, after the null page is freed it becomes available for use to regular req_mem() calls, so users should probably using locks around memory requests. That's probably a good idea anyway as internally the kernal has to lock the virtual memory, and without a scheduler it might cause threads to spin for a while in the kernel which is rather bad. --- src/uapi/conf.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/uapi/conf.c') diff --git a/src/uapi/conf.c b/src/uapi/conf.c index 3a45d30..c8ec964 100644 --- a/src/uapi/conf.c +++ b/src/uapi/conf.c @@ -42,9 +42,10 @@ size_t rpc_stack_size() * * @param t Current tcb. * @param param Parameter to read. + * @param d0 Optional data argument for parameter. * @return \ref OK and parameter value. */ -SYSCALL_DEFINE1(conf_get)(struct tcb *t, sys_arg_t param) +SYSCALL_DEFINE2(conf_get)(struct tcb *t, sys_arg_t param, sys_arg_t d0) { /* anyone can read any current parameter, I don't think they should be * hidden. */ @@ -66,6 +67,15 @@ SYSCALL_DEFINE1(conf_get)(struct tcb *t, sys_arg_t param) val = get_ram_size(); break; + case CONF_PAGE_SIZE: + if (d0 < 0 || d0 > max_order()) { + val = 0; + break; + } + + val = order_size(d0); + break; + default: return_args1(t, ERR_NF); } -- cgit v1.3