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

arch/x86: make use of z_bss_zero() and z_data_copy() #19456

Closed
ghost opened this issue Sep 28, 2019 · 4 comments
Closed

arch/x86: make use of z_bss_zero() and z_data_copy() #19456

ghost opened this issue Sep 28, 2019 · 4 comments
Labels
area: X86 x86 Architecture (32-bit) Enhancement Changes/Updates/Additions to existing features
Milestone

Comments

@ghost
Copy link

ghost commented Sep 28, 2019

For reasons that are not immediately obvious, the 32-bit x86 code does not use the kernel functions supplied to zero the BSS and initialize other data regions. This should probably be changed.

Note that at the same time, x86-optimized implementations of memset() memcpy() et al. could/should be added to the minimal libc if gcc doesn't supply decent builtin implementations.

@ghost ghost added Enhancement Changes/Updates/Additions to existing features area: X86 x86 Architecture (32-bit) labels Sep 28, 2019
@ghost ghost added this to the v2.1.0 milestone Sep 28, 2019
@ghost ghost self-assigned this Sep 28, 2019
@andrewboie
Copy link
Contributor

For reasons that are not immediately obvious, the 32-bit x86 code does not use the kernel functions supplied to zero the BSS and initialize other data regions. This should probably be changed.

Think this was left in because memset()/memcpy() weren't using SSE like the handcrafted assembly does for x86.

Note that at the same time, x86-optimized implementations of memset() memcpy() et al. could/should be added to the minimal libc if gcc doesn't supply decent builtin implementations.

AFAIK GCC currently isn't, would be great to remedy this.

@ghost
Copy link
Author

ghost commented Oct 2, 2019

@andrewboie It looks like, at a minimum, the zeroing of the app_shmem stuff in ia32/crt0.S is redundant, as this recurs again at z_app_shmem_bss_zero(), no?

@andrewboie
Copy link
Contributor

andrewboie commented Oct 2, 2019

@andrewboie It looks like, at a minimum, the zeroing of the app_shmem stuff in ia32/crt0.S is redundant, as this recurs again at z_app_shmem_bss_zero(), no?

@gnuless The code in crt0.S does the XIP copy of the app_smem data into the proper place if XIP is turned on, to copy it out of ROM. I'm assuming you're looking at around line 232 in crt0.S. This could easily use z_data_copy(). IIRC this sits right next to kernel data and the copy could probably be combined.

z_app_shmem_bss_zero() is special, it goes through the subsections in the app_smem data section, which is really a set of:

---------------  <-- _app_smem_start
partition1 data
---------------
partition1 bss
---------------
partition2 data
---------------
partition2 bss
---------------
...
---------------
partitionN data
---------------
partitionN bss
--------------- <-- _app_smem_end

And zeroes just those BSS sub-sections.
This is organized this way since you set MPU/MMU regions, for example for partition1, to cover both data and bss for the individual partitions, so they are adjacent. So a thread granted access to partition1 would have an MMU/MPU region granted which covered both partition1 data and partition1 bss.

@ghost
Copy link
Author

ghost commented Oct 2, 2019

Yep, whoops, I was mistaken there.

@ghost ghost closed this as completed Oct 18, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: X86 x86 Architecture (32-bit) Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

1 participant