[kernel] Add a request IOPL syscall

Using the new ability to modify user rflags, add a syscall for a process
to request its IOPL be changed.
This commit is contained in:
Justin C. Miller
2021-12-23 17:02:39 -08:00
parent fd93023440
commit cade24a7ce
2 changed files with 20 additions and 0 deletions

View File

@@ -26,4 +26,10 @@ object system : kobject {
param size size # Size of the area, in pages
param flags uint32 # Flags to apply to the created VMA
}
# Request the kernel change the IOPL for this process. The only values
# that make sense are 0 and 3.
method request_iopl {
param iopl uint # The IOPL to set for this process
}
}

View File

@@ -1,6 +1,7 @@
#include "j6/errors.h"
#include "j6/types.h"
#include "cpu.h"
#include "device_manager.h"
#include "frame_allocator.h"
#include "log.h"
@@ -77,4 +78,17 @@ system_map_phys(j6_handle_t handle, j6_handle_t * area, uintptr_t phys, size_t s
return j6_status_ok;
}
j6_status_t
system_request_iopl(j6_handle_t handle, unsigned iopl)
{
// TODO: check capabilities on sys handle
if (iopl != 0 && iopl != 3)
return j6_err_invalid_arg;
constexpr uint64_t mask = 3 << 12;
cpu_data &cpu = current_cpu();
cpu.rflags3 = (cpu.rflags3 & ~mask) | ((iopl << 12) & mask);
return j6_status_ok;
}
} // namespace syscalls