Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
phoenix-os
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
PhoeniX
phoenix-os
Commits
68d07bdf
Unverified
Commit
68d07bdf
authored
May 23, 2019
by
PhoeniX
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix stack-related exception on process exit
parent
05d9ba75
Pipeline
#1847
passed with stages
in 31 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
syscall.cpp
src/platform/syscall.cpp
+5
-2
process.cpp
src/process/process.cpp
+5
-3
No files found.
src/platform/syscall.cpp
View file @
68d07bdf
...
...
@@ -17,11 +17,14 @@ static void syscall_puts(uintptr_t strptr) {
static
void
syscall_exit
(
int
code
)
{
ProcessManager
*
manager
=
ProcessManager
::
getManager
();
Process
*
process
=
manager
->
currentProcess
();
void
*
rsp
;
asm
volatile
(
"mov %%rsp, %q0; and $~0xFFF, %q0"
:
"=r"
(
rsp
));
Pagetable
::
Entry
*
pt
;
asm
volatile
(
"mov %%cr3, %q0"
:
"=r"
(
pt
));
Pagetable
::
Entry
*
pte
=
Pagetable
::
Entry
::
find
(
rsp
,
pt
);
asm
volatile
(
"callq _ZN7Process4exitEi;"
"sti;"
"sti;
movq $0, %q2;
"
"jmp _ZN14ProcessManager12process_loopEv"
::
"D"
(
process
),
"S"
(
code
)
::
"D"
(
process
),
"S"
(
code
)
,
"a"
(
pte
)
);
}
...
...
src/process/process.cpp
View file @
68d07bdf
...
...
@@ -16,6 +16,7 @@ Process::Process() {
_aslrStack
=
RAND
::
get
<
uintptr_t
>
(
0x40000000llu
,
0x80000000llu
)
<<
12
;
}
Process
::~
Process
()
{
void
*
rsp
;
asm
volatile
(
"mov %%rsp, %q0; and $~0xFFF, %q0"
:
"=r"
(
rsp
));
if
(
pagetable
!=
nullptr
)
{
PTE
addr
;
for
(
uintptr_t
ptx
=
0
;
ptx
<
512
;
ptx
++
)
{
...
...
@@ -38,10 +39,11 @@ Process::~Process() {
if
(
!
addr
.
present
)
continue
;
void
*
page
=
addr
.
getPtr
();
if
(
uintptr_t
(
page
)
=
=
((
ptx
<<
(
12
+
9
+
9
+
9
))
uintptr_t
ptaddr
=
((
ptx
<<
(
12
+
9
+
9
+
9
))
|
(
pdx
<<
(
12
+
9
+
9
))
|
(
pdpx
<<
(
12
+
9
))
|
(
pml4x
<<
(
12
))))
continue
;
|
(
pdpx
<<
(
12
+
9
))
|
(
pml4x
<<
(
12
)));
if
(
page
==
rsp
)
continue
;
if
(
uintptr_t
(
page
)
==
ptaddr
)
continue
;
Pagetable
::
free
(
page
);
}
Pagetable
::
free
(
ppml4e
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment