On 09/20/2017 11:31 PM, Konrad Rzeszutek Wilk wrote:
By default when using objcopy we lose the alignment when we copy it from
xen-syms -
with the result that alignment (on ARM32 for example) can be 1:
[Nr] Name Type Addr Off Size ES Flg Lk Inf
Al
..
[ 6] .livepatch.depend PROGBITS 00000000 000093 000024 00 A 0 0
1
That, combined with wacky offset means it will be loaded in
memory with the wrong alignment:
(XEN) livepatch.c:425: livepatch: xen_bye_world: Loaded .livepatch.depends at
000a08043
And later we crash as the .livepatch.depends is not aligned to four bytes, while
the xen_build_id_check expects the code to be four byte aligned and we
get an hypervisor crash (on ARM32):
(XEN) CPU0: Unexpected Trap: Data Abort
(XEN) ----[ Xen-4.10Hello World arm32 debug=y Not tainted ]----
(XEN) CPU: 0
(XEN) PC: 002400a0 xen_build_id_check+0x8/0xe8
..snip..
(XEN) Xen call trace:
(XEN) [<002400a0>] xen_build_id_check+0x8/0xe8 (PC)
(XEN) [<0021a9c0>] livepatch_op+0x768/0x1610 (LR)
(XEN) [<0023bbe4>] do_sysctl+0x9c8/0xa9c
(XEN) [<002673c4>] do_trap_guest_sync+0x11e0/0x177c
(XEN) [<0026b6a0>] entry.o#return_from_trap+0/0x4
(XEN)
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) CPU0: Unexpected Trap: Data Abort
This fix forces all the test-cases to be built with a
.livepatch.depends structure containing the build-id extracted from
the hypervisor (except the xen_bye_world test-case).
We use the 'mkhex' tool instead of 'xxd' as the end result is an 'unsigned'
instead of 'char' type array - which naturally forces the alignment to be of
four.
Also the 'mkhex' tools allows us to pass the section name as parameter.
The end result is much better alignment:
[ 7] .livepatch.depend PROGBITS 00000000 000094 000024 00 A 0 0
4
Note that thanks to 'unsigned int .. __note_depends' the symbol becomes
global:
$ readelf --symbols *.livepatch | grep depen
23: 0000000000000000 36 OBJECT GLOBAL HIDDEN 6 note_depends
49: 0000000000000000 36 OBJECT GLOBAL HIDDEN 17 note_depends
16: 0000000000000000 36 OBJECT GLOBAL HIDDEN 3 note_depends
21: 0000000000000000 36 OBJECT GLOBAL HIDDEN 6 note_depends
See patch titled: "livepatch/arm/x86: Rename note_depends symbol from
test-cases."
which fixes this.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.w...@oracle.com>
---
Cc: Jan Beulich <jbeul...@suse.com>
Cc: Andrew Cooper <andrew.coop...@citrix.com>
Cc: Ian Jackson <ian.jack...@eu.citrix.com>
Cc: Wei Liu <wei.l...@citrix.com>
Acked-by: Ross Lagerwall <ross.lagerw...@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel