32 #ifdef HAVE_CROSS_STATE 42 #include <sys/types.h> 61 void (*callback_function)(void);
75 extern void rootsim_cross_state_dependency_handler(
void);
78 void ecs_secondary(
void) {
82 long long target_address =
fault_info.target_address;
83 unsigned char *faulting_insn = (
unsigned char *)
fault_info.rip;
91 x86_disassemble_instruction(faulting_insn, &i, &insn_disasm,
DATA_64 |
ADDR_64);
93 if(!IS_STRING(&insn_disasm)) {
94 span = insn_disasm.span;
100 page_req.write_mode = IS_MEMWR(&insn_disasm);
101 page_req.base_address = (
void *)(target_address & (~((
long long)PAGE_SIZE-1)));
102 page_req.count = ((target_address + span) & (~((
long long)PAGE_SIZE-1)))/PAGE_SIZE - (
long long)page_req.base_address/PAGE_SIZE + 1;
120 void ecs_initiate(
void) {
154 void ECS(
void) __attribute__((__used__));
159 rootsim_error(
true,
"----ERROR---- ECS in Silent Execution LP[%d] Hit:%llu Timestamp:%f\n",
165 printf(
"muori male\n");
174 case ECS_MAJOR_FAULT:
178 case ECS_MINOR_FAULT:
183 case ECS_CHANGE_PAGE_PRIVILEGE:
189 rootsim_error(
true,
"Impossible condition! Aborting...\n");
194 void ecs_init(
void) {
196 ioctl_fd = open(
"/dev/ktblmgr", O_RDONLY);
197 if (ioctl_fd <= -1) {
198 rootsim_error(
true,
"Error in opening special device file. ROOT-Sim is compiled for using the ktblmgr linux kernel module, which seems to be not loaded.");
203 void lp_alloc_thread_init(
void) {
209 ioctl(ioctl_fd, IOCTL_SET_ANCESTOR_PGD,NULL);
210 lp_memory_ioctl_info.ds = -1;
211 ptr = get_base_pointer(LP0);
212 lp_memory_ioctl_info.addr = ptr;
213 lp_memory_ioctl_info.mapped_processes =
n_prc_tot;
215 callback_function = rootsim_cross_state_dependency_handler;
216 lp_memory_ioctl_info.callback = (ulong) callback_function;
221 ioctl(ioctl_fd, IOCTL_SET_VM_RANGE, &lp_memory_ioctl_info);
227 void lp_alloc_schedule(
void) {
233 sched_info.count =
current->ECS_index + 1;
234 sched_info.objects = (
unsigned int*)
current->ECS_synch_table;
237 ioctl(ioctl_fd,IOCTL_SCHEDULE_ON_PGD, &sched_info);
241 void lp_alloc_deschedule(
void) {
245 ioctl(ioctl_fd,IOCTL_UNSCHEDULE_ON_PGD,
pgd_ds);
248 void setup_ecs_on_segment(
msg_t *msg) {
258 sched_info.base_address = get_base_pointer(msg->sender);
259 ioctl(ioctl_fd, IOCTL_PROTECT_REMOTE_LP, &sched_info);
263 void lp_alloc_thread_fini(
void) {
266 void ecs_send_pages(
msg_t *msg) {
273 the_pages->write_mode = the_request->write_mode;
274 the_pages->base_address = the_request->base_address;
275 the_pages->count = the_request->count;
280 memcpy(the_pages->buffer, the_request->base_address, the_request->count * PAGE_SIZE);
291 void ecs_install_pages(
msg_t *msg) {
298 memcpy(the_pages->base_address, the_pages->buffer, the_pages->count * PAGE_SIZE);
304 sched_info.base_address = the_pages->base_address;
305 sched_info.page_count = the_pages->count;
306 sched_info.write_mode = the_pages->write_mode;
315 void unblock_synchronized_objects(
struct lp_struct *lp) {
319 for(i = 1; i <= lp->ECS_index; i++) {
325 lp->wait_on_rendezvous = 0;
329 void remote_memory_init(
void) {
332 (void)get_segment(lp->
gid);
ECS protocol: a remote LP is asked for a certain set of pages.
unsigned long long generate_mark(struct lp_struct *lp)
User-Level Threads Headers.
#define ADDR_64
Address fields in instructions are 64-bits.
x86 ISA disassembler header
Core ROOT-Sim functionalities.
void msg_to_hdr(msg_hdr_t *hdr, msg_t *msg)
Convert a message to a message header.
unsigned int to_int
The LID numerical value.
The ROOT-Sim scheduler main module header.
__thread struct lp_struct * current
This is a per-thread variable pointing to the block state of the LP currently scheduled.
unsigned int find_kernel_by_gid(GID_t gid)
ECS protocol: start synchronizing two LPs for a page fault.
#define list_insert(li, key_name, data)
Insert a new node in the list.
__thread msg_t * current_evt
Memory Manager main header.
#define long_jmp(env, val)
#define DATA_64
Data fields in instructions are 64-bits.
__thread kernel_context_t kernel_context
This is the execution context of the simulation kernel.
ECS protocol: the destination LP can resume its normal execution.
void Send(msg_t *msg)
Send a message.
unsigned long long rendezvous_mark
Unique identifier of the message, used for antimessages.
void pack_msg(msg_t **msg, GID_t sender, GID_t receiver, int type, simtime_t timestamp, simtime_t send_time, size_t size, void *payload)
Pack a message in a platform-level data structure.
GID_t gid
Global ID of the LP.
short unsigned int state
Current execution state of the LP.
LID_t lid
Local ID of the LP.
static __thread fault_info_t fault_info
Per Worker-Thread Fault Info Structure.
Message envelope definition. This is used to handle the output queue and stores information needed to...
ECS protocol: the sender LP is giving a lease on a set of pages.
static __thread int pgd_ds
Per Worker-Thread Memory View.
static ioctl_info lp_memory_ioctl_info
This variable keeps track of information needed by the Linux Kernel Module for activating cross-LP me...
unsigned int n_prc_tot
Total number of logical processes running in the simulation.
msg_hdr_t * get_msg_hdr_from_slab(struct lp_struct *lp)
Get a buffer to keep a message header.
#define unlikely(exp)
Optimize the branch as likely not taken.
unsigned int kid
Identifier of the local kernel.