Skip to content

Commit

Permalink
arch,pt: add frame finder for virtual address functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Nov 13, 2023
1 parent c812745 commit 256a324
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions arch/x86/pagetables.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,27 @@ int get_user_va_mfn_order(void *va, mfn_t *mfn, unsigned int *order) {
return err;
}

static frame_t *get_va_frame(const cr3_t *cr3_ptr, const void *va) {
frame_t *frame = NULL;
unsigned int order;
mfn_t mfn;

spin_lock(&vmap_lock);
if (get_va_mfn_order(cr3_ptr, va, &mfn, &order) == 0)
frame = find_mfn_frame(mfn, order);
spin_unlock(&vmap_lock);

return frame;
}

frame_t *get_kern_va_frame(const void *va) {
return get_va_frame(&cr3, va);
}

frame_t *get_user_va_frame(const void *va) {
return get_va_frame(&user_cr3, va);
}

void init_pagetables(void) {
init_tmp_mapping();

Expand Down
3 changes: 3 additions & 0 deletions include/arch/x86/pagetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ extern void dump_user_pagetable_va(void *va);
extern int get_kern_va_mfn_order(void *va, mfn_t *mfn, unsigned int *order);
extern int get_user_va_mfn_order(void *va, mfn_t *mfn, unsigned int *order);

extern frame_t *get_kern_va_frame(const void *va);
extern frame_t *get_user_va_frame(const void *va);

#endif /* __ASSEMBLY__ */

#endif /* KTF_PAGETABLE_H */

0 comments on commit 256a324

Please sign in to comment.