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 #46

Merged
merged 1 commit into from
Dec 3, 2021
Merged

BootInfo: Add tls_align #46

merged 1 commit into from
Dec 3, 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 bors bot merged commit 3fd49e9 into hermit-os:master Dec 3, 2021
@mkroening mkroening deleted the tls-align branch December 3, 2021 19:10
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.

1 participant