-
Notifications
You must be signed in to change notification settings - Fork 15
"ID map text too big or misaligned" after LLD commit 86d24193a9eb45d7bf3745fc2de96cd4e197b08a #812
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
Comments
Looking at the file: /*
* The HYP init code and ID map text can't be longer than a page each,
* and should not cross a page boundary.
*/
ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
"ID map text too big or misaligned") The commit in question (mine), should round up the thunk section size to 4k when the cortex-a53 or cortex-a8 errata patch is on. This was to prevent LLD not converging when there was a very large binary and the addition of thunks kept generating more patches ad inifinitum. By rounding the size of the thunk section to 4k this prevented the addition of a thunk disturbing the address of following sections modulo 4k (the errata is sensitive to address modulo 4k). if At the moment the only way to fix that is to either ensure that the section doesn't contain a thunk, or turn off the errata patches. In the long term if it is required to have thunks and errata patches and have the total size < 4k, then we'll need to do one of: I'm on vacation right now, but if this is critical I can look at it. Option 2 should be fairly simple to implement. |
I think this can wait until after your vacation :) enjoy! |
I've submitted https://reviews.llvm.org/D72344 to only turn this on for OutputSections that are larger than the ThunkSectionSpacing which is close to 128 Mb. I'd be grateful if you could give it a try. I was initially confident that this would work for assertion but looking at the linker script in more detail this might not be enough. I initially thought If the allyesconfig is still failing I'll have to think again. I can't think of many universally good answers here. Thoughts:
|
Unfortunately, with D72344 applied and building v5.5-rc5 arm64 allyesconfig, I still see this error :( |
@nathanchance Do you have easy-to-reproduce command(s)? Edit: I can reproduce. My Linux repository is at make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CC=~/llvm/Release/bin/clang LD=~/llvm/Release/bin/ld.lld O=out/arm64 KCONFIG_ALLCONFIG=~/Dev/ClangBuiltLinux/tc-build/kernel/le.config allyesconfig Image.gz -j 30 After I make a change to lld, I can run make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CC=~/llvm/Release/bin/clang LD=~/llvm/Release/bin/ld.lld O=out/arm64 KCONFIG_ALLCONFIG=~/Dev/ClangBuiltLinux/tc-build/kernel/le.config Image.gz Linker output:
|
@MaskRay this is enough for me with 5.5-rc5:
|
Thanks for the reproducible commands. I'll take a look and see what I can come up with. |
Looking at the map file the overall size of the .text OutputSection is indeed > 128 MiB so my check on the OutputSection size won't be enough. The size of the code between __idmap_text_start and __idmap_text_end is < 2 KiB. There looks to be only 1 thunk generated for the InputSectionDescription, but that would be enough to fail the assertion. I've got one urgent thing I need to do first before I can get back to this, at worst case it might be first thing next week, but hopefully I'll have something before then. |
Apologies for the delay, I've uploaded a new fix to https://reviews.llvm.org/D72344 I've made it so that the ThunkSection has its size rounded up when:
|
I can confirm this fixes the build error on my end! I have no other real way to test if this is a correct fix or not, I'll leave that to the patch reviewers :) thanks for the fix! |
In D71281 a fix was put in to round up the size of a ThunkSection to the nearest 4KiB when performing errata patching. This fixed a problem with a very large instrumented program that had thunks and patches mutually trigger each other. Unfortunately it triggers an assertion failure in an AArch64 allyesconfig build of the kernel. There is a specific assertion preventing an InputSectionDescription being larger than 4KiB. This will always trigger if there is at least one Thunk needed in that InputSectionDescription, which is possible for an allyesconfig build. Abstractly the problem case is: .text : { *(.text) ; ... . = ALIGN(SZ_4K); __idmap_text_start = .; *(.idmap.text) __idmap_text_end = .; ... } The assertion checks that __idmap_text_end - __idmap_start is < 4 KiB. Note that there is more than one InputSectionDescription in the OutputSection so we can't just restrict the fix to OutputSections smaller than 4 KiB. The fix presented here limits the D71281 to InputSectionDescriptions that meet the following conditions: 1.) The OutputSection is bigger than the thunkSectionSpacing so adding thunks will affect the addresses of following code. 2.) The InputSectionDescription is larger than 4 KiB. This will prevent any assertion failures that an InputSectionDescription is < 4 KiB in size. We do this at ThunkSection creation time as at this point we know that the addresses are stable and up to date prior to adding the thunks as assignAddresses() will have been called immediately prior to thunk generation. The fix reverts the two tests affected by D71281 to their original state as they no longer need the 4KiB size roundup. I've added simpler tests to check for D71281 when the OutputSection size is larger than the ThunkSection spacing. Fixes ClangBuiltLinux/linux#812 Differential Revision: https://reviews.llvm.org/D72344
I've requested that the commit that fixes this be added to LLVM 10 since it missed the branch: https://llvm.org/pr44764 |
In D71281 a fix was put in to round up the size of a ThunkSection to the nearest 4KiB when performing errata patching. This fixed a problem with a very large instrumented program that had thunks and patches mutually trigger each other. Unfortunately it triggers an assertion failure in an AArch64 allyesconfig build of the kernel. There is a specific assertion preventing an InputSectionDescription being larger than 4KiB. This will always trigger if there is at least one Thunk needed in that InputSectionDescription, which is possible for an allyesconfig build. Abstractly the problem case is: .text : { *(.text) ; ... . = ALIGN(SZ_4K); __idmap_text_start = .; *(.idmap.text) __idmap_text_end = .; ... } The assertion checks that __idmap_text_end - __idmap_start is < 4 KiB. Note that there is more than one InputSectionDescription in the OutputSection so we can't just restrict the fix to OutputSections smaller than 4 KiB. The fix presented here limits the D71281 to InputSectionDescriptions that meet the following conditions: 1.) The OutputSection is bigger than the thunkSectionSpacing so adding thunks will affect the addresses of following code. 2.) The InputSectionDescription is larger than 4 KiB. This will prevent any assertion failures that an InputSectionDescription is < 4 KiB in size. We do this at ThunkSection creation time as at this point we know that the addresses are stable and up to date prior to adding the thunks as assignAddresses() will have been called immediately prior to thunk generation. The fix reverts the two tests affected by D71281 to their original state as they no longer need the 4KiB size roundup. I've added simpler tests to check for D71281 when the OutputSection size is larger than the ThunkSection spacing. Fixes ClangBuiltLinux/linux#812 Differential Revision: https://reviews.llvm.org/D72344 (cherry picked from commit 01ad4c8)
In D71281 a fix was put in to round up the size of a ThunkSection to the nearest 4KiB when performing errata patching. This fixed a problem with a very large instrumented program that had thunks and patches mutually trigger each other. Unfortunately it triggers an assertion failure in an AArch64 allyesconfig build of the kernel. There is a specific assertion preventing an InputSectionDescription being larger than 4KiB. This will always trigger if there is at least one Thunk needed in that InputSectionDescription, which is possible for an allyesconfig build. Abstractly the problem case is: .text : { *(.text) ; ... . = ALIGN(SZ_4K); __idmap_text_start = .; *(.idmap.text) __idmap_text_end = .; ... } The assertion checks that __idmap_text_end - __idmap_start is < 4 KiB. Note that there is more than one InputSectionDescription in the OutputSection so we can't just restrict the fix to OutputSections smaller than 4 KiB. The fix presented here limits the D71281 to InputSectionDescriptions that meet the following conditions: 1.) The OutputSection is bigger than the thunkSectionSpacing so adding thunks will affect the addresses of following code. 2.) The InputSectionDescription is larger than 4 KiB. This will prevent any assertion failures that an InputSectionDescription is < 4 KiB in size. We do this at ThunkSection creation time as at this point we know that the addresses are stable and up to date prior to adding the thunks as assignAddresses() will have been called immediately prior to thunk generation. The fix reverts the two tests affected by D71281 to their original state as they no longer need the 4KiB size roundup. I've added simpler tests to check for D71281 when the OutputSection size is larger than the ThunkSection spacing. Fixes ClangBuiltLinux/linux#812 Differential Revision: https://reviews.llvm.org/D72344 (cherry picked from commit 501f912)
Building arm64 allyesconfig after llvm/llvm-project@86d2419 results in a failed assertion in the arm64 linking script:
https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/vmlinux.lds.S#L265-L266
Bisect log:
I've done no investigation past this. I tested mainline at torvalds@e31736d.
The text was updated successfully, but these errors were encountered: