ISR6 when switching to user mode on adding a breakpoint
Posted: Sat Aug 22, 2020 7:06 pm
Hello guys,
I am in the process of adding user mode support to my OS. I am able to switch to user mode:
(gdb) c
Continuing.
(gdb) l
111 // lock_scheduler();
112 // schedule();
113 // unlock_scheduler();
114 switch_usr_mode();
115 // printf("Back to kernel_main..\n");
116 for(;;) {
117
118 }
119 }
120
But if I add a break point at any place in my switch_user_mode assembly code, the jump to user mode fails:
(gdb) b switch_usr_mode
Breakpoint 5 at 0x103ad2: file task_sw.s, line 38.
(gdb) c
Continuing.
Breakpoint 5, switch_usr_mode () at task_sw.s:38
38 cli
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
isr6 () at idt_flush.s:34
34 ISR_NOERR 6<---------------??
Weird thing is, if I modify my assembly code to look like this:
global switch_usr_mode
extern task_user
switch_usr_mode:
cli
mov ax, 0x23
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp
push long 0x23
push eax
pushf
pop eax
or eax, 0x200
push eax
push long 0x1B
push task_user
iret
cont:
ret
That is, jump to task_user(), then I don't fault even if I put a break point in my switch_user_mode code.
(gdb)
task_user () at kernel.c:67
67 void task_user () {
I am not sure why this is happening. Has anyone else experienced this. Really appreciate it if anyone could give any sort of pointers on this.
Link to my repo: https://github.com/Crescent92/testOS/bl ... k_sw.s#L53
I am in the process of adding user mode support to my OS. I am able to switch to user mode:
(gdb) c
Continuing.
(gdb) l
111 // lock_scheduler();
112 // schedule();
113 // unlock_scheduler();
114 switch_usr_mode();
115 // printf("Back to kernel_main..\n");
116 for(;;) {
117
118 }
119 }
120
But if I add a break point at any place in my switch_user_mode assembly code, the jump to user mode fails:
(gdb) b switch_usr_mode
Breakpoint 5 at 0x103ad2: file task_sw.s, line 38.
(gdb) c
Continuing.
Breakpoint 5, switch_usr_mode () at task_sw.s:38
38 cli
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
isr6 () at idt_flush.s:34
34 ISR_NOERR 6<---------------??
Weird thing is, if I modify my assembly code to look like this:
global switch_usr_mode
extern task_user
switch_usr_mode:
cli
mov ax, 0x23
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp
push long 0x23
push eax
pushf
pop eax
or eax, 0x200
push eax
push long 0x1B
push task_user
iret
cont:
ret
That is, jump to task_user(), then I don't fault even if I put a break point in my switch_user_mode code.
(gdb)
task_user () at kernel.c:67
67 void task_user () {
I am not sure why this is happening. Has anyone else experienced this. Really appreciate it if anyone could give any sort of pointers on this.
Link to my repo: https://github.com/Crescent92/testOS/bl ... k_sw.s#L53