Skip to content

Conversation

@rottaran
Copy link
Collaborator

Store state of execution contexts in user accessible memory frames. This includes the CPU and FPU registers. The objective is to enable easier access to suspended threads for user-mode trap handlers and thread management.

Integration into the musl pthreads support code is still pending.

… to pass a 64bit val from set() to bind(); initialized more of the invocation buf, this is likely at the wrong place
…ew thread state address if the frame was changed while the EC was loaded
… to pass a 64bit val from set() to bind(); initialized more of the invocation buf, this is likely at the wrong place
…ew thread state address if the frame was changed while the EC was loaded
@kubanrob kubanrob marked this pull request as ready for review February 25, 2020 16:21
@rottaran
Copy link
Collaborator Author

Creating pthreads works again. However, not all of the allocated kernel objects are deleted after the thread has finished.

Copy link
Collaborator

@kubanrob kubanrob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, compiles, haven't tested it ... I added some comments for nitpicking.

{
MLOG_INFO(mlog::ec, "EC setEntryPoint", DVARhex(rip));
threadState.rip = rip;
if (!state) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need a return value if it can fail.

Comment on lines +345 to +348
if (state) {
state->threadState.fs_base = fs;
state->threadState.gs_base = gs;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to return an error code to our unsuspecting user.

void ExecutionContext::handleTrap()
{
auto ctx = &threadState;
auto ctx = &state->threadState;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that state != nullptr?

getLocalPlace().setCR3(info.table); // without reload if not changed
}
// Reload the address space and thread state address if they have changed
getLocalPlace().setCR3(page_table); // without reload if not changed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be very careful never to set CR3 to nullptr. Maybe assert page_table != nullptr or at least use the default/fallback system PML4 as a "null" value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

store thread state and fpu state in a memory frame rename ThreadState::maySysret

3 participants