• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 #ifdef CHCORE_ENABLE_FMAP
13 
14 #ifndef OBJECT_USER_FAULT_H
15 #define OBJECT_USER_FAULT_H
16 
17 #include <ipc/notification.h>
18 #include <common/lock.h>
19 
20 /* User ring buffer node */
21 struct user_fault_msg {
22     badge_t fault_badge;
23     vaddr_t fault_va;
24 };
25 
26 /**
27  * Save pending thread, and enqueue them when user mapping finished
28  */
29 struct fault_pending_thread {
30     /* Use (fault_badge, fault_va) as key to find the pending thread */
31     badge_t fault_badge;
32     vaddr_t fault_va;
33 
34     struct thread *thread;
35 
36     struct list_head node;
37 };
38 
39 /**
40  * A fmap_fault_pool is ownered by a vmspace(cap_group)
41  * If thread call sys_user_fault_register,
42  * we will create a fmap_fault_pool for the cap_group,
43  * and add to fmap_fault_pool_list.
44  */
45 struct fmap_fault_pool {
46     badge_t cap_group_badge;
47     struct notification *notific;
48     struct ring_buffer *msg_buffer_kva;
49 
50     /* fault pending thread list */
51     struct list_head pending_threads;
52 
53     struct lock lock;
54     struct list_head node;
55 };
56 
57 extern struct lock fmap_fault_pool_list_lock;
58 extern struct list_head fmap_fault_pool_list;
59 
60 void handle_user_fault(struct pmobject *pmo, vaddr_t fault_va);
61 
62 /* Syscalls */
63 int sys_user_fault_register(cap_t notific_cap, vaddr_t msg_buffer);
64 int sys_user_fault_map(badge_t client_badge, vaddr_t fault_va, vaddr_t remap_va,
65                        bool copy, unsigned long perm);
66 
67 #endif /* OBJECT_USER_FAULT_H */
68 
69 #endif
70