Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BootInfo: Add tls_align #241

Merged
merged 1 commit into from
Dec 4, 2021
Merged

BootInfo: Add tls_align #241

merged 1 commit into from
Dec 4, 2021

Conversation

mkroening
Copy link
Member

@mkroening mkroening commented Dec 2, 2021

@mkroening mkroening self-assigned this Dec 2, 2021
@mkroening mkroening marked this pull request as ready for review December 2, 2021 23:20
@mkroening
Copy link
Member Author

bors r+

bors bot added a commit that referenced this pull request Dec 3, 2021
241: BootInfo: Add tls_align r=mkroening a=mkroening

See

* hermit-os/kernel#311

Co-authored-by: Martin Kröning <mkroening@posteo.net>
@bors
Copy link
Contributor

bors bot commented Dec 3, 2021

Timed out.

@stlankes
Copy link
Collaborator

stlankes commented Dec 4, 2021

bors r+

bors bot added a commit that referenced this pull request Dec 4, 2021
241: BootInfo: Add tls_align r=stlankes a=mkroening

See

* hermit-os/kernel#311

Co-authored-by: Martin Kröning <mkroening@posteo.net>
@bors
Copy link
Contributor

bors bot commented Dec 4, 2021

Build failed:

@stlankes
Copy link
Collaborator

stlankes commented Dec 4, 2021

bors r+

bors bot added a commit that referenced this pull request Dec 4, 2021
241: BootInfo: Add tls_align r=stlankes a=mkroening

See

* hermit-os/kernel#311

Co-authored-by: Martin Kröning <mkroening@posteo.net>
@bors
Copy link
Contributor

bors bot commented Dec 4, 2021

Build failed:

@stlankes
Copy link
Collaborator

stlankes commented Dec 4, 2021

bors r+

bors bot added a commit that referenced this pull request Dec 4, 2021
241: BootInfo: Add tls_align r=stlankes a=mkroening

See

* hermit-os/kernel#311

Co-authored-by: Martin Kröning <mkroening@posteo.net>
@bors
Copy link
Contributor

bors bot commented Dec 4, 2021

Build failed:

@stlankes
Copy link
Collaborator

stlankes commented Dec 4, 2021

bors r+

@bors bors bot merged commit f68c4e3 into hermit-os:master Dec 4, 2021
@mkroening mkroening deleted the tls-align branch December 4, 2021 15:59
bors bot added a commit to hermit-os/kernel that referenced this pull request Dec 4, 2021
311: Fix thread pointer calculation, rework TaskTLS r=mkroening a=mkroening

Closes hermit-os/hermit-rs#170. 🎉 

Replaces #305.

Depends on:

* hermit-os/loader#46
* hermit-os/uhyve#241

The cause of the issue is the calculation of the thread pointer:

```python
# Current calculation (wrong)
thread_ptr = tls_block_ptr + round(tls_len, 32)

# Correct calculation
thread_ptr = tls_block_ptr + round(tls_len, tls_align)
# round(tls_len, tls_align) is called tls_offset
```

This is fixed in the first two commits of this PR.

The later commits completely rework the `TaskTLS` struct. I did this to better understand the problem. The old comments were partly outdated and wrong. Also the code was not very rusty. I replaced manual memory allocations with `Box`es and restructured and recommented the code.

Co-authored-by: Martin Kröning <mkroening@posteo.net>
bors bot added a commit to hermit-os/kernel that referenced this pull request Dec 4, 2021
311: Fix thread pointer calculation, rework TaskTLS r=mkroening a=mkroening

Closes hermit-os/hermit-rs#170. 🎉 

Replaces #305.

Depends on:

* hermit-os/loader#46
* hermit-os/uhyve#241

The cause of the issue is the calculation of the thread pointer:

```python
# Current calculation (wrong)
thread_ptr = tls_block_ptr + round(tls_len, 32)

# Correct calculation
thread_ptr = tls_block_ptr + round(tls_len, tls_align)
# round(tls_len, tls_align) is called tls_offset
```

This is fixed in the first two commits of this PR.

The later commits completely rework the `TaskTLS` struct. I did this to better understand the problem. The old comments were partly outdated and wrong. Also the code was not very rusty. I replaced manual memory allocations with `Box`es and restructured and recommented the code.

Co-authored-by: Martin Kröning <mkroening@posteo.net>
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.

None yet

2 participants