aarch64 haskell: implement isValidVTableRoot

The C code has an unnecessary name indirection via isValidNativeRoot
here, which I replicated to make more obvious what maps to what.
Eventually this should disappear.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
This commit is contained in:
Gerwin Klein 2022-02-11 14:53:55 +11:00 committed by Gerwin Klein
parent 33f060e249
commit 4262144dfd
1 changed files with 12 additions and 5 deletions

View File

@ -458,17 +458,24 @@ getHWASID asid = do
{- Helper Functions -}
isVTableRoot :: Capability -> Bool
isVTableRoot (ArchObjectCap (PageTableCap { capPTTopLevel = True })) = True
isVTableRoot _ = False
-- FIXME AARCH64: name indirection kept here for sync with C; both (C and
-- Haskell) should define isValidVTableRoot directly
isValidNativeRoot :: Capability -> Bool
isValidNativeRoot cap = isValidVTableRoot cap && isJust (capPTMappedAddress (capCap cap))
isValidVTableRoot :: Capability -> Bool
isValidVTableRoot = isValidNativeRoot
checkValidIPCBuffer :: VPtr -> Capability -> KernelF SyscallError ()
checkValidIPCBuffer vptr (ArchObjectCap (FrameCap {capFIsDevice = False})) = do
when (vptr .&. mask ipcBufferSizeBits /= 0) $ throw AlignmentError
return ()
checkValidIPCBuffer _ _ = throw IllegalOperation
isValidVTableRoot :: Capability -> Bool
isValidVTableRoot
(ArchObjectCap (PageTableCap { capPTMappedAddress = Just _ })) = True
isValidVTableRoot _ = False
maskVMRights :: VMRights -> CapRights -> VMRights
maskVMRights r m = case (r, capAllowRead m, capAllowWrite m) of
(VMReadOnly, True, _) -> VMReadOnly