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

Fix unaligned access with LTO #1

Merged
merged 1 commit into from
Jan 6, 2020

Conversation

goshdarnharris
Copy link

Force 4 byte alignment on USB buffers. Chibios casts these buffers to size_t* before dereferencing them (os/hal/src/hal_buffers.c:633, among other locations); in some cases this can result in an unaligned access if LTO decides to shift things around. Ideally the chibios API would express this alignment precondition, but this will ensure that all accesses to these buffers are aligned.

There are several more APIs in which chibios performs an unsafe cast, but as far as I can tell this is the only one that might result in an unaligned access to QMK data.

I've been able to reliably reproduce this crash in the following configuration:

  • docker build on tzarc/qmk_firmware:chibios-upgrade
  • target onekey/stm32f0_disco:rgb
  • disable NKRO
  • enable RGBLIGHT
  • enable UNICODE
  • enable LTO

This fix works for the same configuration and a few permutations (enable/disable NKRO & UNICODE). Also tested with :default as configured on tzarc/chibios-upgrade.

Description

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@tzarc tzarc merged this pull request into tzarc:chibios-upgrade Jan 6, 2020
tzarc pushed a commit that referenced this pull request Jan 8, 2020
…atrix timeout. (qmk#7688)

* Added KidBrazil custom keymap for CRKBD
-Custom Font
-Custom OLED output

* Added missing readme

* Oled Timeout Update for KidBrazil Keymap (#1)

* Setup Oled timeout based on simple timer

* Cleaned up comments and added timeout for LEDs

* Fixed some small errors

* Updated oled timout with matrix scan

* Updated oled timout with matrix scan

* Update withou eeprom

* Update timer code

* Use process user instead of keymap

* Added ifdef to protect oledtimer

* Updated with half timeout state for logo

* Removed middle tier timer

* Final cleanup of unused files

* Updated code as per suggestions & requests

* Second round of revisions

* Updated keymap to better handle LED timeout
- Added boolean to hold LED state
- Added init function to set rgb to known state
- Modified RGB_TOG to work with noeeprom commands

* Finished adding the timeout for OLED and testing on CRKBD

* Updated documentation

* fixed the timeout logic so it works as intended

* Update keyboards/crkbd/keymaps/kidbrazil/README.md
tzarc pushed a commit that referenced this pull request Jan 27, 2020
…eout. (qmk#7901)

* Added KidBrazil custom keymap for CRKBD
-Custom Font
-Custom OLED output

* Added missing readme

* Oled Timeout Update for KidBrazil Keymap (#1)

* Setup Oled timeout based on simple timer

* Cleaned up comments and added timeout for LEDs

* Fixed some small errors

* Updated oled timout with matrix scan

* Updated oled timout with matrix scan

* Update withou eeprom

* Update timer code

* Use process user instead of keymap

* Added ifdef to protect oledtimer

* Updated with half timeout state for logo

* Removed middle tier timer

* Final cleanup of unused files

* Updated code as per suggestions & requests

* Second round of revisions

* Updated keymap to better handle LED timeout
- Added boolean to hold LED state
- Added init function to set rgb to known state
- Modified RGB_TOG to work with noeeprom commands

* Finished adding the timeout for OLED and testing on CRKBD

* Updated documentation

* fixed the timeout logic so it works as intended

* Added initial limits to color settings

* Added layer reset as part of the iddle timeout process

* Split Keymap into more manageable files

* Finalizing RGB Layer status on CRKBD
- Refactored OLED timeout to deal only with oled
- If user remains iddle on game layer for too long it will switch to
default
- LED / OLED iddle working
- Minor changes to _SYM layer
- Removed some rgb controls from keyboard due to layer dependent RGB
colors

* Update keyboards/crkbd/keymaps/kidbrazil/keymap.c

Used suggestion from Drashna to replace EEPROM_RESET with shorter version.

Co-Authored-By: Drashna Jaelre <[email protected]>

* Update keyboards/crkbd/keymaps/kidbrazil/keymap.c

Co-Authored-By: Drashna Jaelre <[email protected]>

* Implemented drashna's comment

Co-authored-by: Drashna Jaelre <[email protected]>
tzarc pushed a commit that referenced this pull request Feb 24, 2020
Fixing complexity

remove lambda

PR review fixes #1

Removing unneccesary string substitution

Handle -a and specified files

Complexity rewrite, use pathlib
tzarc pushed a commit that referenced this pull request May 7, 2020
* New keymap layout for dztech/dz65rgb/keymaps

* New keymap layout for dztech/dz65rgb/keymaps
- Conding conventions fixes

* Fix typo in Leader Key table

* PR qmk#8199 Feedback Commit #1

* Fixed data types and function names - Simplified accent macros by removing repetition - Added selection wrap macros - readme.md doc updated with changes

* PR qmk#8199 second feedback commit - Clarified function names, variables names and comments

* Fix: accent output fix _grave  <==> _circumflex

* dry fixes on led set_color with hsv and led blinking code blocks
tzarc pushed a commit that referenced this pull request Aug 4, 2022
* Userspace: muppetjones (#1)

Add and update lily58 to work with userspace
Add and update kyria keymap to work with userspace
Add and update planck keymap with userspace
Add etchamouse code and docs to userpace
Add userspace
Update mouse encoder for smoother movement.
Encoder + mouse
Added casemodes by andrewjrae

* Rollback lily58 state reader and add missing GPL

* Apply suggestions from code review

Co-authored-by: Drashna Jaelre <[email protected]>
Co-authored-by: Joel Challis <[email protected]>

* fix lily58 keymap

* Updates to user and lily for muppetjones.

Updated parameters for etchamouse for smoother mouse movement. Updated lily keymap and userspace to actually work together.

* Update keyboards/lily58/keymaps/muppetjones/config.h

Co-authored-by: Drashna Jaelre <[email protected]>

* Updated keymaps and userspace

* Little more cleanup.

* Update keyboards/lily58/keymaps/muppetjones/rules.mk

Co-authored-by: Ryan <[email protected]>

* Rollback accidental libchibios update

* Apply suggestions from code review

Co-authored-by: Drashna Jaelre <[email protected]>

* Update kyria keymap

* Move kyria keymap to splitkb/kyria

* Update planck keymap

* Remove all changes to keyboards/lily58/lib/layer_state_reader.c

* Update lily58 keymap

* Recommended change

* Update keymap readme

* Update kyria keymap and userspace

* Apply suggestions from code review

Co-authored-by: Drashna Jaelre <[email protected]>

* Renamed users/muppetjones/README.md to lc

* Update keyboards/lily58/keymaps/muppetjones/config.h

Co-authored-by: Drashna Jaelre <[email protected]>

Co-authored-by: Drashna Jaelre <[email protected]>
Co-authored-by: Joel Challis <[email protected]>
Co-authored-by: Ryan <[email protected]>
tzarc pushed a commit that referenced this pull request Oct 5, 2022
tzarc added a commit that referenced this pull request Mar 2, 2024
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.

2 participants