Use the implementation from Arceos with the relevant modifications. Ref: https://github.com/rcore-os/arceos