arm64: One fix and one improvement
cover arm64: One fix and one improvement
Fix the loading of argc. Nikos reported an issue with its alignment while testing target-efi (aligned to four bytes is OK, as long as we only load four bytes like we should). Also, take a patch developed while working on target-efi which can make debugging a bit more convenient (by doing some subtraction for the test developer).
Andrew Jones (2):
arm64: argc is an int
arm64: Output PC load offset on unhandled exceptions
arm/cstart64.S | 2 +- arm/flat.lds | 1 + lib/arm64/processor.c | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
2.26.3
PATCH 1/2 arm64: argc is an int
If argc isn't aligned to eight bytes then loading it as if it's eight bytes wide is a bad idea. It's only four bytes wide, so we should only load four bytes.
--- arm/cstart64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arm/cstart64.S +1 -1
@@ -100,7 +100,7 @@ start: 1: /* run the test */ adrp x0, __argc - ldr x0, [x0, :lo12:__argc] + ldr w0, [x0, :lo12:__argc] adrp x1, __argv add x1, x1, :lo12:__argv adrp x2, __environ
Signature · 1 line
2.26.3
Re: [PATCH kvm-unit-tests 1/2] arm64: argc is an int
Quoted 6 lines · Andrew Jones
If argc isn't aligned to eight bytes then loading it as if it's eight bytes wide is a bad idea. It's only four bytes wide, so we should only load four bytes.
Reported-by Nikos Nikoleris <[email protected]>Signed-off-by Andrew Jones <[email protected]>
Thanks for fixing this.
Quoted 18 lines
--- arm/cstart64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arm/cstart64.S +1
-1@@ -100,7 +100,7 @@ start: 1: /* run the test */ adrp x0, __argc - ldr x0, [x0, :lo12:__argc] + ldr w0, [x0, :lo12:__argc] adrp x1, __argv add x1, x1, :lo12:__argv adrp x2, __environ
PATCH 2/2 arm64: Output PC load offset on unhandled exceptions
In reply to Andrew JonesSince for arm64 we can load the unit tests at different addresses, then let's make it easier to debug by calculating the PC offset for the user. The offset can then be directly used when looking at the disassembly of the test's elf file.
--- arm/flat.lds | 1 + lib/arm64/processor.c | 7 +++++++ 2 files changed, 8 insertions(+)
arm/flat.lds +1 -0
@@ -1,6 +1,7 @@ SECTIONS { + PROVIDE(_text = .); .text : { *(.init) *(.text) *(.text.*) } . = ALIGN(64K); PROVIDE(etext = .);
lib/arm64/processor.c +7 -0
@@ -99,12 +99,19 @@ bool get_far(unsigned int esr, unsigned long *far)return false; } +extern unsigned long _text; +static void bad_exception (enum vector v,struct pt_regs *regs,unsigned int esr,bool esr_valid,bool bad_vector) {unsigned long far;bool far_valid =get_far (esr, &far);unsigned int ec = esr >>ESR_EL1_EC_SHIFT ; +uintptr_t text = (uintptr_t )&_text; + +printf ("Load address: %" PRIxPTR"\n" , text); +printf ("PC: %" PRIxPTR" PC offset: %" PRIxPTR"\n" , + (uintptr_t )regs->pc, (uintptr_t )regs->pc - text);if (bad_vector) {if (v <VECTOR_MAX )
Signature · 1 line
2.26.3
Re: [PATCH kvm-unit-tests 2/2] arm64: Output PC load offset on unhandled exceptions
Quoted 6 lines · Andrew Jones
Since for arm64 we can load the unit tests at different addresses, then let's make it easier to debug by calculating the PC offset for the user. The offset can then be directly used when looking at the disassembly of the test's elf file.
Signed-off-by Andrew Jones <[email protected]
Quoted 42 lines
--- arm/flat.lds | 1 + lib/arm64/processor.c | 7 +++++++ 2 files changed, 8 insertions(+)arm/flat.lds +1
-0@@ -1,6 +1,7 @@ SECTIONS { + PROVIDE(_text = .); .text : { *(.init) *(.text) *(.text.*) } . = ALIGN(64K); PROVIDE(etext = .);lib/arm64/processor.c +7
-0@@ -99,12 +99,19 @@ bool get_far(unsigned int esr, unsigned long *far)return false; } +extern unsigned long _text; +static void bad_exception (enum vector v,struct pt_regs *regs,unsigned int esr,bool esr_valid,bool bad_vector) {unsigned long far;bool far_valid =get_far (esr, &far);unsigned int ec = esr >>ESR_EL1_EC_SHIFT ; +uintptr_t text = (uintptr_t )&_text; + +printf ("Load address: %" PRIxPTR"\n" , text); +printf ("PC: %" PRIxPTR" PC offset: %" PRIxPTR"\n" , + (uintptr_t )regs->pc, (uintptr_t )regs->pc - text);if (bad_vector) {if (v <VECTOR_MAX )
Andrew Jones
AppliedQuoted 6 lines · Andrew Jones
Fix the loading of argc. Nikos reported an issue with its alignment while testing target-efi (aligned to four bytes is OK, as long as we only load four bytes like we should). Also, take a patch developed while working on target-efi which can make debugging a bit more convenient (by doing some subtraction for the test developer).
Quoted 12 lines
Andrew Jones (2):
arm64: argc is an int
arm64: Output PC load offset on unhandled exceptionsarm/cstart64.S | 2 +- arm/flat.lds | 1 + lib/arm64/processor.c | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)Signature · 1 line
2.26.3
Thanks for the review, Nikos!
Applied to arm/queue
https://gitlab.com/rhdrjones/kvm-unit-tests/-/commits/arm/queue
Thanks,
drew