ANDROID: KVM: arm64: Include .note.gnu.property in .hyp.rodata

Since .hyp.rodata sections of pKVM modules are emitted with SHT_MERGE,
ld.ldd feels free to attempt merging it with other sections.
Unfortunately, the pKVM module linker script doesn't always place them
in output sections, hence causing link failures:

  ld.lld: error: drivers/misc/pkvm-pl011/hyp/kvm_nvhe.tmp.o:(.hyp.rodata):
  offset is outside the section

In practice, ld.ldd only seems to attempt merging .note.gnu.property with
.hyp.rodata. To work around the problem, make sure to explicitely place
the .note.gnu.property in .hyp.rodata from the start, hence preventing
ld.ldd from trying to optimize further.

A preferable solution would be to teach ld.lld that merging pKVM modules
sections is a bad idea, or to make sure the sections are not emitted
with SHT_MERGE to begin with, but we couldn't find an obvious way to make
that happen. This workaround is nothing more than a pratical compromise.

Bug: 244543039
Reported-by: Will Deacon <will@kernel.org>
Suggested-by: Will Deacon <will@kernel.org>
Change-Id: Iae902bdfd21915f552e218515cd77881a95fef2d
Signed-off-by: Quentin Perret <qperret@google.com>
This commit is contained in:
Quentin Perret
2022-12-07 09:24:51 +00:00
parent 6e84750015
commit 4deb454ebf

View File

@@ -22,7 +22,7 @@ SECTIONS {
.hyp.rodata : {
HYP_SECTION_SYMBOL_NAME(.rodata) = .;
__hypmod_rodata_start = .;
*(.rodata .rodata.*)
*(.rodata .rodata.* .note.gnu.property)
BYTE(0)
__hypmod_rodata_end = .;
}