Skip to contentSkip to conversation

❌ FAIL (91/181 SKIPPED): Test report for for-kernelci (6.2.0-rc5, arm-next, 2e84eedb)

PATCH In review [email protected] 5 participants 10 messages Jan 25, 2023 – Jan 27, 2023 arm64

lore
Share & tools
lore
#0 lore raw

Hi, we tested your kernel and here are the results:

Overall result: FAILED
Merge: OK
Compile: OK
Test: FAILED

Kernel information:
Commit message: Merge branch 'for-next/core' into for-kernelci

You can find all the details about the test run at
https://datawarehouse.cki-project.org/kcidb/checkouts/66828

One or more kernel tests failed:
Unrecognized or new issues:
aarch64 - kdump - kexec_boot
Logs: https://datawarehouse.cki-project.org/kcidb/tests/6799495

We also see the following known issues which are not related to your changes:
Issue: [aarch64][coresight_etm4x][kernel 5.19.0] coresight-etm4x: probe of ARMHC500:20 failed with error -17
URL: https://lore.kernel.org/all/CA+QYu4ogiTa1V20aqxFqBrMH0z927YNNN2O=CKma+=M_8E81iQ@mail.gmail.com/
Affected tests:
aarch64 - Boot test
aarch64 - Reboot test
Issue: Storage block - storage fio numa: Performance comparison: min:40535 * 1.15 < max:81259
URL: https://bugzilla.redhat.com/show_bug.cgi?id=2032094
Affected tests:
aarch64 - Storage - block - storage fio numa
Issue: stress: stress-ng - memory: (panic) Comm: systemd-oomd Not tainted 6.1.0-rc3
URL: https://gitlab.com/redhat/centos-stream/tests/kernel/kernel-tests/-/issues/1461
Affected tests:
aarch64 - stress: stress-ng - memory
Issue: CIFS Connectathon: SELinux prevents mount.cifs, request-key and cifs.idmap
URL: https://gitlab.com/redhat/centos-stream/tests/kernel/kernel-tests/-/issues/1525
Affected tests:
aarch64 - CIFS Connectathon
Issue: Regression in iSCSI login negotiation | rx_data returned -13, expecting 48
URL: https://bugzilla.redhat.com/show_bug.cgi?id=2162738
Affected tests:
aarch64 - Storage - targetcli basic
Issue: xfstests: generic/174 - wrong fs type, bad option, bad superblock
URL: https://gitlab.com/redhat/centos-stream/tests/kernel/kernel-tests/-/issues/843
Affected tests:
aarch64 - xfstests - xfs
Issue: xfstests - _check_xfs_filesystem: filesystem on /dev/nvme0n1p4 is inconsistent (r)
URL: https://bugzilla.redhat.com/show_bug.cgi?id=1989409
Affected tests:
aarch64 - xfstests - btrfs

If you find a failure unrelated to your changes, please ask the test maintainer to review it. This will prevent the failures from being incorrectly reported in the future.

Please reply to this email if you have any questions about the tests that we ran or if you have any suggestions on how to make future tests more effective.

        ,-.   ,-.
       ( C ) ( K )  Continuous
        `-',-.`-'   Kernel
          ( I )     Integration
           `-'

______________________________________________________________________________

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#1 lore raw

[+Mark and Ard in case they have ideas]

Quoted 11 lines · On Wed, Jan 25, 2023 at 09:21:19AM -0000, [email protected] wrote:

Hi, we tested your kernel and here are the results:

Overall result: FAILED
Merge: OK
Compile: OK
Test: FAILED

Kernel information:
Commit message: Merge branch 'for-next/core' into for-kernelci

Quoted 7 lines

You can find all the details about the test run at
https://datawarehouse.cki-project.org/kcidb/checkouts/66828

One or more kernel tests failed:
Unrecognized or new issues:
aarch64 - kdump - kexec_boot
Logs: https://datawarehouse.cki-project.org/kcidb/tests/6799495

This looks like we run into an undefined instruction when we jump to the kexec relocation code. Do you know if the failure is reproducible, and is the log identical each time?

I'm struggling a bit for ideas at the moment, given that we're not taking a translation fault so the page-table isn't _completely_ mad.

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

reviewer
#2 lore raw

Re: ? FAIL (91/181 SKIPPED): Test report for for-kernelci (6.2.0-rc5, arm-next, 2e84eedb)

Quoted 22 lines · Will Deacon

[+Mark and Ard in case they have ideas]

Quoted 11 lines · On Wed, Jan 25, 2023 at 09:21:19AM -0000, [email protected] wrote:

Hi, we tested your kernel and here are the results:

Overall result: FAILED
Merge: OK
Compile: OK
Test: FAILED

Kernel information:
Commit message: Merge branch 'for-next/core' into for-kernelci

Quoted 7 lines

You can find all the details about the test run at
https://datawarehouse.cki-project.org/kcidb/checkouts/66828

One or more kernel tests failed:
Unrecognized or new issues:
aarch64 - kdump - kexec_boot
Logs: https://datawarehouse.cki-project.org/kcidb/tests/6799495

Quoted 6 lines

This looks like we run into an undefined instruction when we jump to the kexec relocation code. Do you know if the failure is reproducible, and is the log identical each time?

I'm struggling a bit for ideas at the moment, given that we're not taking a translation fault so the page-table isn't _completely_ mad.

Clearly it's gone well enough to cause an UNDEFINED exception rather than an abort, but it's worth noting that we *do* take a fault within the handler, since:

| [12214.505526] Code: bad PC value

... means that aarch64_insn_read() faulted within dump_kernel_instr().

So I'd suspect we've done something UNPREDICTABLE here, or we're missing some barriers and/or synchronization.

The log indicates this is a QEMU KVM RM on a ThunderX2 host, so I'll see if I can reproduce this locally...

Thanks,
Mark.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

reviewer
#3 lore raw

Re: ? FAIL (91/181 SKIPPED): Test report for for-kernelci (6.2.0-rc5, arm-next, 2e84eedb)

In reply to Will Deacon
Quoted 17 lines · Will Deacon

[+Mark and Ard in case they have ideas]

Quoted 14 lines · On Wed, Jan 25, 2023 at 09:21:19AM -0000, [email protected] wrote:

Hi, we tested your kernel and here are the results:

Overall result: FAILED
Merge: OK
Compile: OK
Test: FAILED

Kernel information:
Commit message: Merge branch 'for-next/core' into for-kernelci

You can find all the details about the test run at
https://datawarehouse.cki-project.org/kcidb/checkouts/66828

Quoted 8 lines
Quoted 4 lines

One or more kernel tests failed:
Unrecognized or new issues:
aarch64 - kdump - kexec_boot
Logs: https://datawarehouse.cki-project.org/kcidb/tests/6799495

This looks like we run into an undefined instruction when we jump to the kexec relocation code. Do you know if the failure is reproducible, and is the log identical each time?

I had a go in a QEMU KVM VM on ThunderX2, and a QEMU KVM TCG VM. With defconfig I don't see the issue, but with the config from the test run link above I consistently see the issue both under KVM and TCG (logs below).

It should be simple enough to figure out which config option is tickling this; I'll go dig in to that..

KVM:

| # ./kexec --reuse-cmdline -f Image 
| [   46.965800] kexec_core: Starting new kernel
| [   47.143641] psci: CPU1 killed (polled 0 ms)
| [   47.233653] psci: CPU2 killed (polled 0 ms)
| [   47.323465] psci: CPU3 killed (polled 0 ms)
| [   47.324776] Bye!
| [   47.327072] Internal error: Oops - Undefined instruction: 0000000002000000 [#1] SMP
| [   47.328510] Modules linked in:
| [   47.329086] CPU: 0 PID: 259 Comm: kexec Not tainted 6.2.0-rc5+ #3
| [   47.330223] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
| [   47.331497] pstate: 604003c5 (nZCv DAIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
| [   47.332782] pc : 0x43a95000
| [   47.333338] lr : machine_kexec+0x190/0x1e0
| [   47.334169] sp : ffff80000d293b70
| [   47.334845] x29: ffff80000d293b70 x28: ffff000002cc0000 x27: 0000000000000000
| [   47.336292] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
| [   47.337744] x23: ffff80000a837858 x22: 0000000048ec9000 x21: 0000000000000010
| [   47.339192] x20: 00000000adc83000 x19: ffff000000827000 x18: 0000000000000006
| [   47.340638] x17: ffff800075a61000 x16: ffff800008000000 x15: ffff80000d293658
| [   47.342085] x14: 0000000000000000 x13: ffff80000d2937f7 x12: ffff80000a7ff6e0
| [   47.343530] x11: 00000000ffffdfff x10: ffff80000a8ef8e0 x9 : ffff80000813ef00
| [   47.344976] x8 : 000000000002ffe8 x7 : c0000000ffffdfff x6 : 00000000000affa8
| [   47.346431] x5 : 0000000000001fff x4 : 0000000000000001 x3 : ffff80000a0a3008
| [   47.347877] x2 : ffff80000a8220f8 x1 : 0000000043a95000 x0 : ffff000000827000
| [   47.349334] Call trace:
| [   47.349834]  0x43a95000
| [   47.350338]  kernel_kexec+0x88/0x100
| [   47.351070]  __do_sys_reboot+0x108/0x268
| [   47.351873]  __arm64_sys_reboot+0x2c/0x40
| [   47.352689]  invoke_syscall+0x78/0x108
| [   47.353458]  el0_svc_common.constprop.0+0x4c/0x100
| [   47.354426]  do_el0_svc+0x34/0x50
| [   47.355102]  el0_svc+0x34/0x108
| [   47.355747]  el0t_64_sync_handler+0xf4/0x120
| [   47.356617]  el0t_64_sync+0x194/0x198
| [   47.357374] Code: bad PC value
| [   47.357999] ---[ end trace 0000000000000000 ]---
| [   47.358937] Kernel panic - not syncing: Oops - Undefined instruction: Fatal exception
| [   47.360515] Kernel Offset: disabled
| [   47.361230] CPU features: 0x002000,00050108,c8004203
| [   47.362232] Memory Limit: none

TCG:

| #  ./kexec --reuse-cmdline -f Image
| [   94.257277] kvm: exiting hardware virtualization
| [   94.315790] kexec_core: Starting new kernel
| [   94.447279] psci: CPU1 killed (polled 0 ms)
| [   94.542471] psci: CPU2 killed (polled 0 ms)
| [   94.643061] psci: CPU3 killed (polled 0 ms)
| [   94.657775] Bye!
| [   94.659186] Internal error: Oops - Undefined instruction: 0000000002000000 [#1] SMP
| [   94.660439] Modules linked in:
| [   94.662160] CPU: 0 PID: 258 Comm: kexec Not tainted 6.2.0-rc5+ #3
| [   94.662936] Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
| [   94.663793] pstate: 61400bc9 (nZCv DAIF +PAN -UAO -TCO +DIT -SSBS BTYPE=-c)
| [   94.664470] pc : 0x43a95000
| [   94.665780] lr : machine_kexec+0x190/0x1e0
| [   94.667025] sp : ffff80000d1f3ac0
| [   94.667346] x29: ffff80000d1f3ac0 x28: ffff000002014380 x27: 0000000000000000
| [   94.668315] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
| [   94.668970] x23: ffff80000a837858 x22: 0000000048b06000 x21: 0000000000000010
| [   94.669618] x20: 00000000adc83000 x19: ffff000000805c00 x18: 0000000000000006
| [   94.670253] x17: 0000000000000000 x16: 0000000000000000 x15: ffff80000d1f35a8
| [   94.670895] x14: 0000000000000000 x13: ffff80000d1f3747 x12: ffff80000a7ff6e0
| [   94.671538] x11: 00000000ffffdfff x10: ffff80000a8ef8e0 x9 : ffff80000813ef00
| [   94.672279] x8 : 000000000002ffe8 x7 : c0000000ffffdfff x6 : 00000000000affa8
| [   94.672926] x5 : 0000000000000000 x4 : 0000000000000002 x3 : ffff80000a0a3008
| [   94.673572] x2 : ffff80000a8220f8 x1 : 0000000043a95000 x0 : ffff000000805c00
| [   94.674430] Call trace:
| [   94.674750]  0x43a95000
| [   94.675133]  kernel_kexec+0x88/0x100
| [   94.675492]  __do_sys_reboot+0x108/0x268
| [   94.675863]  __arm64_sys_reboot+0x2c/0x40
| [   94.676230]  invoke_syscall+0x78/0x108
| [   94.676581]  el0_svc_common.constprop.0+0x4c/0x100
| [   94.676990]  do_el0_svc+0x34/0x50
| [   94.677299]  el0_svc+0x34/0x108
| [   94.677630]  el0t_64_sync_handler+0xf4/0x120
| [   94.678004]  el0t_64_sync+0x194/0x198
| [   94.678716] Code: bad PC value
| [   94.679828] ---[ end trace 0000000000000000 ]---
| [   94.680585] Kernel panic - not syncing: Oops - Undefined instruction: Fatal exception
| [   94.681870] Kernel Offset: disabled
| [   94.682241] CPU features: 0x000000,0075016b,4d23e33f
| [   94.683007] Memory Limit: none

Thanks,
Mark.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#4 lore raw

Re: ? FAIL (91/181 SKIPPED): Test report for for-kernelci (6.2.0-rc5, arm-next, 2e84eedb)

Quoted 27 lines · Mark Rutland
Quoted 17 lines · Will Deacon

[+Mark and Ard in case they have ideas]

Quoted 14 lines · On Wed, Jan 25, 2023 at 09:21:19AM -0000, [email protected] wrote:

Hi, we tested your kernel and here are the results:

Overall result: FAILED
Merge: OK
Compile: OK
Test: FAILED

Kernel information:
Commit message: Merge branch 'for-next/core' into for-kernelci

You can find all the details about the test run at
https://datawarehouse.cki-project.org/kcidb/checkouts/66828

Quoted 8 lines
Quoted 4 lines

One or more kernel tests failed:
Unrecognized or new issues:
aarch64 - kdump - kexec_boot
Logs: https://datawarehouse.cki-project.org/kcidb/tests/6799495

This looks like we run into an undefined instruction when we jump to the kexec relocation code. Do you know if the failure is reproducible, and is the log identical each time?

Quoted 6 lines

I had a go in a QEMU KVM VM on ThunderX2, and a QEMU KVM TCG VM. With defconfig I don't see the issue, but with the config from the test run link above I consistently see the issue both under KVM and TCG (logs below).

It should be simple enough to figure out which config option is tickling this; I'll go dig in to that..

Cheers, Mark. If you get a chance, it's probably also worth testing vanilla -rc5 to confirm that it's a regression in our queue (which we could assumedly bisect if necessary).

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

reviewer
#5 lore raw

Re: ? FAIL (91/181 SKIPPED): Test report for for-kernelci (6.2.0-rc5, arm-next, 2e84eedb)

Quoted 32 lines · Will Deacon
Quoted 31 lines · Mark Rutland
Quoted 17 lines · Will Deacon

[+Mark and Ard in case they have ideas]

Quoted 14 lines · On Wed, Jan 25, 2023 at 09:21:19AM -0000, [email protected] wrote:

Hi, we tested your kernel and here are the results:

Overall result: FAILED
Merge: OK
Compile: OK
Test: FAILED

Kernel information:
Commit message: Merge branch 'for-next/core' into for-kernelci

You can find all the details about the test run at
https://datawarehouse.cki-project.org/kcidb/checkouts/66828

Quoted 8 lines
Quoted 4 lines

One or more kernel tests failed:
Unrecognized or new issues:
aarch64 - kdump - kexec_boot
Logs: https://datawarehouse.cki-project.org/kcidb/tests/6799495

This looks like we run into an undefined instruction when we jump to the kexec relocation code. Do you know if the failure is reproducible, and is the log identical each time?

I had a go in a QEMU KVM VM on ThunderX2, and a QEMU KVM TCG VM. With defconfig I don't see the issue, but with the config from the test run link above I consistently see the issue both under KVM and TCG (logs below).

Quoted 6 lines
Quoted 2 lines

It should be simple enough to figure out which config option is tickling this; I'll go dig in to that..

Cheers, Mark. If you get a chance, it's probably also worth testing vanilla -rc5 to confirm that it's a regression in our queue (which we could assumedly bisect if necessary).

I have met the enemy, and he is me:

| git bisect start
| # good: [2241ab53cbb5cdb08a6b2d4688feb13971058f65] Linux 6.2-rc5
| git bisect good 2241ab53cbb5cdb08a6b2d4688feb13971058f65
| # bad: [2e84eedb182e43a9113c2c83cc3373c2ae99ce19] Merge branch 'for-next/core' into for-kernelci
| git bisect bad 2e84eedb182e43a9113c2c83cc3373c2ae99ce19
| # good: [3eb1b41fba97a1586e3ecca8c10547071f541567] kselftest/arm64: Add coverage of SME 2 and 2.1 hwcaps
| git bisect good 3eb1b41fba97a1586e3ecca8c10547071f541567
| # good: [daac835347a52d9d141be281e4657cc08a360e97] kselftest/arm64: Correct buffer size for SME ZA storage
| git bisect good daac835347a52d9d141be281e4657cc08a360e97
| # bad: [baaf553d3bc330697c68a00f96cf11f4edfeac7e] arm64: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS
| git bisect bad baaf553d3bc330697c68a00f96cf11f4edfeac7e
| # good: [47a15aa544279d34e14e17ca3b5855e39b946cec] arm64: Extend support for CONFIG_FUNCTION_ALIGNMENT
| git bisect good 47a15aa544279d34e14e17ca3b5855e39b946cec
| # good: [e4ecbe83fd1a5428d5458de04a3404f1b5444429] arm64: patching: Add aarch64_insn_write_literal_u64()
| git bisect good e4ecbe83fd1a5428d5458de04a3404f1b5444429
| # good: [90955d778ad7873964a271852b1f24d31e00248b] arm64: ftrace: Update stale comment
| git bisect good 90955d778ad7873964a271852b1f24d31e00248b
| # first bad commit: [baaf553d3bc330697c68a00f96cf11f4edfeac7e] arm64: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS

It looks like this is down to the function alignment; reverting that commit makes it go away, but if ia add:

| diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
| index 6914f6bf41e22..8dafeea05864e 100644
| --- a/arch/arm64/Kconfig
| +++ b/arch/arm64/Kconfig
| @@ -123,7 +123,7 @@ config ARM64
|         select DMA_DIRECT_REMAP
|         select EDAC_SUPPORT
|         select FRAME_POINTER
| -       select FUNCTION_ALIGNMENT_4B
| +       select FUNCTION_ALIGNMENT_8B    # HACK HACK HACK
|         select GENERIC_ALLOCATOR
|         select GENERIC_ARCH_TOPOLOGY
|         select GENERIC_CLOCKEVENTS_BROADCAST

... then it blows up again.

So we're probably doing a clever address calculation in the kexec idmap code that ends up being wrong when the code gets shuffled a bit; possibly a mismatched caller/callee alignment.

I'll dig a bit more...

Mark.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#6 lore raw

Re: ? FAIL (91/181 SKIPPED): Test report for for-kernelci (6.2.0-rc5, arm-next, 2e84eedb)

Quoted 78 lines · Mark Rutland
Quoted 32 lines · Will Deacon
Quoted 31 lines · Mark Rutland
Quoted 17 lines · Will Deacon

[+Mark and Ard in case they have ideas]

Quoted 14 lines · On Wed, Jan 25, 2023 at 09:21:19AM -0000, [email protected] wrote:

Hi, we tested your kernel and here are the results:

Overall result: FAILED
Merge: OK
Compile: OK
Test: FAILED

Kernel information:
Commit message: Merge branch 'for-next/core' into for-kernelci

You can find all the details about the test run at
https://datawarehouse.cki-project.org/kcidb/checkouts/66828

Quoted 8 lines
Quoted 4 lines

One or more kernel tests failed:
Unrecognized or new issues:
aarch64 - kdump - kexec_boot
Logs: https://datawarehouse.cki-project.org/kcidb/tests/6799495

This looks like we run into an undefined instruction when we jump to the kexec relocation code. Do you know if the failure is reproducible, and is the log identical each time?

I had a go in a QEMU KVM VM on ThunderX2, and a QEMU KVM TCG VM. With defconfig I don't see the issue, but with the config from the test run link above I consistently see the issue both under KVM and TCG (logs below).

Quoted 6 lines
Quoted 2 lines

It should be simple enough to figure out which config option is tickling this; I'll go dig in to that..

Cheers, Mark. If you get a chance, it's probably also worth testing vanilla -rc5 to confirm that it's a regression in our queue (which we could assumedly bisect if necessary).

I have met the enemy, and he is me:

| git bisect start
| # good: [2241ab53cbb5cdb08a6b2d4688feb13971058f65] Linux 6.2-rc5
| git bisect good 2241ab53cbb5cdb08a6b2d4688feb13971058f65
| # bad: [2e84eedb182e43a9113c2c83cc3373c2ae99ce19] Merge branch 'for-next/core' into for-kernelci
| git bisect bad 2e84eedb182e43a9113c2c83cc3373c2ae99ce19
| # good: [3eb1b41fba97a1586e3ecca8c10547071f541567] kselftest/arm64: Add coverage of SME 2 and 2.1 hwcaps
| git bisect good 3eb1b41fba97a1586e3ecca8c10547071f541567
| # good: [daac835347a52d9d141be281e4657cc08a360e97] kselftest/arm64: Correct buffer size for SME ZA storage
| git bisect good daac835347a52d9d141be281e4657cc08a360e97
| # bad: [baaf553d3bc330697c68a00f96cf11f4edfeac7e] arm64: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS
| git bisect bad baaf553d3bc330697c68a00f96cf11f4edfeac7e
| # good: [47a15aa544279d34e14e17ca3b5855e39b946cec] arm64: Extend support for CONFIG_FUNCTION_ALIGNMENT
| git bisect good 47a15aa544279d34e14e17ca3b5855e39b946cec
| # good: [e4ecbe83fd1a5428d5458de04a3404f1b5444429] arm64: patching: Add aarch64_insn_write_literal_u64()
| git bisect good e4ecbe83fd1a5428d5458de04a3404f1b5444429
| # good: [90955d778ad7873964a271852b1f24d31e00248b] arm64: ftrace: Update stale comment
| git bisect good 90955d778ad7873964a271852b1f24d31e00248b
| # first bad commit: [baaf553d3bc330697c68a00f96cf11f4edfeac7e] arm64: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS

It looks like this is down to the function alignment; reverting that commit makes it go away, but if ia add:

| diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
| index 6914f6bf41e22..8dafeea05864e 100644
| --- a/arch/arm64/Kconfig
| +++ b/arch/arm64/Kconfig
| @@ -123,7 +123,7 @@ config ARM64
|         select DMA_DIRECT_REMAP
|         select EDAC_SUPPORT
|         select FRAME_POINTER
| -       select FUNCTION_ALIGNMENT_4B
| +       select FUNCTION_ALIGNMENT_8B    # HACK HACK HACK
|         select GENERIC_ALLOCATOR
|         select GENERIC_ARCH_TOPOLOGY
|         select GENERIC_CLOCKEVENTS_BROADCAST
Quoted 6 lines

... then it blows up again.

So we're probably doing a clever address calculation in the kexec idmap code that ends up being wrong when the code gets shuffled a bit; possibly a mismatched caller/callee alignment.

$ grep -1 arm64_reloca System.map
ffff80000b0320fc T __relocate_new_kernel_start
ffff80000b032100 T arm64_relocate_new_kernel
ffff80000b032220 T __relocate_new_kernel_end

so the alignment results in arm64_relocate_new_kernel() appearing past the start of the section, and the kexec code takes the address of the section not the function symbol.

Something like the below should fix it, although it would arguably be better to clean up the kexec code (but I'm reluctant to make a clean spot)

index 407415a5163ab62f..89720ec2d830d51c 100644

arch/arm64/kernel/vmlinux.lds.S +1 -0
@@ -102,6 +102,7 @@ jiffies = jiffies_64;
 
 #ifdef CONFIG_KEXEC_CORE
 #define KEXEC_TEXT                                     \
+       . = ALIGN(64);                                  \
        __relocate_new_kernel_start = .;                \
        *(.kexec_relocate.text)                         \
        __relocate_new_kernel_end = .;

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

reviewer
#7 lore raw

PATCH 1/1 arm64: avoid executing padding bytes during kexec / hibernation (WAS: Re: ? FAIL (91/181 SKIPPED): Test report for for-kernelci (6.2.0-rc5, arm-next, 2e84eedb))

Adding James, since this affects hibernate too.

Quoted 86 lines · Ard Biesheuvel
Quoted 78 lines · Mark Rutland
Quoted 32 lines · Will Deacon
Quoted 31 lines · Mark Rutland
Quoted 17 lines · Will Deacon

[+Mark and Ard in case they have ideas]

Quoted 14 lines · On Wed, Jan 25, 2023 at 09:21:19AM -0000, [email protected] wrote:

Hi, we tested your kernel and here are the results:

Overall result: FAILED
Merge: OK
Compile: OK
Test: FAILED

Kernel information:
Commit message: Merge branch 'for-next/core' into for-kernelci

You can find all the details about the test run at
https://datawarehouse.cki-project.org/kcidb/checkouts/66828

Quoted 8 lines
Quoted 4 lines

One or more kernel tests failed:
Unrecognized or new issues:
aarch64 - kdump - kexec_boot
Logs: https://datawarehouse.cki-project.org/kcidb/tests/6799495

This looks like we run into an undefined instruction when we jump to the kexec relocation code. Do you know if the failure is reproducible, and is the log identical each time?

I had a go in a QEMU KVM VM on ThunderX2, and a QEMU KVM TCG VM. With defconfig I don't see the issue, but with the config from the test run link above I consistently see the issue both under KVM and TCG (logs below).

Quoted 6 lines
Quoted 2 lines

It should be simple enough to figure out which config option is tickling this; I'll go dig in to that..

Cheers, Mark. If you get a chance, it's probably also worth testing vanilla -rc5 to confirm that it's a regression in our queue (which we could assumedly bisect if necessary).

I have met the enemy, and he is me:

| git bisect start
| # good: [2241ab53cbb5cdb08a6b2d4688feb13971058f65] Linux 6.2-rc5
| git bisect good 2241ab53cbb5cdb08a6b2d4688feb13971058f65
| # bad: [2e84eedb182e43a9113c2c83cc3373c2ae99ce19] Merge branch 'for-next/core' into for-kernelci
| git bisect bad 2e84eedb182e43a9113c2c83cc3373c2ae99ce19
| # good: [3eb1b41fba97a1586e3ecca8c10547071f541567] kselftest/arm64: Add coverage of SME 2 and 2.1 hwcaps
| git bisect good 3eb1b41fba97a1586e3ecca8c10547071f541567
| # good: [daac835347a52d9d141be281e4657cc08a360e97] kselftest/arm64: Correct buffer size for SME ZA storage
| git bisect good daac835347a52d9d141be281e4657cc08a360e97
| # bad: [baaf553d3bc330697c68a00f96cf11f4edfeac7e] arm64: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS
| git bisect bad baaf553d3bc330697c68a00f96cf11f4edfeac7e
| # good: [47a15aa544279d34e14e17ca3b5855e39b946cec] arm64: Extend support for CONFIG_FUNCTION_ALIGNMENT
| git bisect good 47a15aa544279d34e14e17ca3b5855e39b946cec
| # good: [e4ecbe83fd1a5428d5458de04a3404f1b5444429] arm64: patching: Add aarch64_insn_write_literal_u64()
| git bisect good e4ecbe83fd1a5428d5458de04a3404f1b5444429
| # good: [90955d778ad7873964a271852b1f24d31e00248b] arm64: ftrace: Update stale comment
| git bisect good 90955d778ad7873964a271852b1f24d31e00248b
| # first bad commit: [baaf553d3bc330697c68a00f96cf11f4edfeac7e] arm64: Implement HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS

It looks like this is down to the function alignment; reverting that commit makes it go away, but if ia add:

| diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
| index 6914f6bf41e22..8dafeea05864e 100644
| --- a/arch/arm64/Kconfig
| +++ b/arch/arm64/Kconfig
| @@ -123,7 +123,7 @@ config ARM64
|         select DMA_DIRECT_REMAP
|         select EDAC_SUPPORT
|         select FRAME_POINTER
| -       select FUNCTION_ALIGNMENT_4B
| +       select FUNCTION_ALIGNMENT_8B    # HACK HACK HACK
|         select GENERIC_ALLOCATOR
|         select GENERIC_ARCH_TOPOLOGY
|         select GENERIC_CLOCKEVENTS_BROADCAST
Quoted 6 lines

... then it blows up again.

So we're probably doing a clever address calculation in the kexec idmap code that ends up being wrong when the code gets shuffled a bit; possibly a mismatched caller/callee alignment.

Quoted 8 lines
$ grep -1 arm64_reloca System.map
ffff80000b0320fc T __relocate_new_kernel_start
ffff80000b032100 T arm64_relocate_new_kernel
ffff80000b032220 T __relocate_new_kernel_end

so the alignment results in arm64_relocate_new_kernel() appearing past the start of the section, and the kexec code takes the address of the section not the function symbol.

Yup, and we do the same for hibernation with swsusp_arch_suspend_exit vs __hibernate_exit_text_start. AFAICT those are the only places we end up relying upon alignment that we don't already have (e.g. the KPTI trampoline section is already page-aligned).

Quoted 8 lines

Something like the below should fix it, although it would arguably be better to clean up the kexec code (but I'm reluctant to make a clean spot)

index 407415a5163ab62f..89720ec2d830d51c 100644

arch/arm64/kernel/vmlinux.lds.S jiffies = jiffies_64; · line 108

Quoted 7 lines
arch/arm64/kernel/vmlinux.lds.S +1 -0
@@ -102,6 +102,7 @@ jiffies = jiffies_64;
 
 #ifdef CONFIG_KEXEC_CORE
 #define KEXEC_TEXT                                     \
+       . = ALIGN(64);                                  \
        __relocate_new_kernel_start = .;                \
        *(.kexec_relocate.text)                         \
        __relocate_new_kernel_end = .;

Yep, and there's ALIGN_FUNCTION() for exactly this purpose.

I had a quick look at making the kexec and hibernation code figure out the offset between the start of the section and the function, and it wasn't very pretty, so I think for now we should just place an assertion in the linker script.

With all that in mind, I came up with the patch below, which works for me with ftrace and/or CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B selected.

Thanks,
Mark

---->8----
From 8c82c71d810be311f10703b91563a301e56be910 Mon Sep 17 00:00:00 2001
From: Mark Rutland <[email protected]>
Date: Fri, 27 Jan 2023 11:08:20 +0000
Subject: [PATCH] arm64: avoid executing padding bytes during kexec /
hibernation

Currently we rely on the HIBERNATE_TEXT section starting with the entry point to swsusp_arch_suspend_exit, and the KEXEC_TEXT section starting with the entry point to arm64_relocate_new_kernel. In both cases we copy the entire section into a dynamically-allocated page, and then later branch to the start of this page.

SYM_FUNC_START() will align the function entry points to CONFIG_FUNCTION_ALIGNMENT, and when the linker later processes the assembled code it will place padding bytes before the function entry point if the location counter was not already sufficiently aligned. The linker happens to use the value zero for these padding bytes.

This padding may end up being applied whenever CONFIG_FUNCTION_ALIGNMENT is greater than 4, which can be the case with CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B=y or CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS=y.

When such padding is applied, attempting to kexec or resume from hibernate will result ina crash: the kernel will branch to the padding bytes as the start of the dynamically-allocated page, and as those bytes are zero they will decode as UDF #0, which reliably triggers an UNDEFINED exception. For example:

| # ./kexec --reuse-cmdline -f Image
| [   46.965800] kexec_core: Starting new kernel
| [   47.143641] psci: CPU1 killed (polled 0 ms)
| [   47.233653] psci: CPU2 killed (polled 0 ms)
| [   47.323465] psci: CPU3 killed (polled 0 ms)
| [   47.324776] Bye!
| [   47.327072] Internal error: Oops - Undefined instruction: 0000000002000000 [#1] SMP
| [   47.328510] Modules linked in:
| [   47.329086] CPU: 0 PID: 259 Comm: kexec Not tainted 6.2.0-rc5+ #3
| [   47.330223] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
| [   47.331497] pstate: 604003c5 (nZCv DAIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
| [   47.332782] pc : 0x43a95000
| [   47.333338] lr : machine_kexec+0x190/0x1e0
| [   47.334169] sp : ffff80000d293b70
| [   47.334845] x29: ffff80000d293b70 x28: ffff000002cc0000 x27: 0000000000000000
| [   47.336292] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
| [   47.337744] x23: ffff80000a837858 x22: 0000000048ec9000 x21: 0000000000000010
| [   47.339192] x20: 00000000adc83000 x19: ffff000000827000 x18: 0000000000000006
| [   47.340638] x17: ffff800075a61000 x16: ffff800008000000 x15: ffff80000d293658
| [   47.342085] x14: 0000000000000000 x13: ffff80000d2937f7 x12: ffff80000a7ff6e0
| [   47.343530] x11: 00000000ffffdfff x10: ffff80000a8ef8e0 x9 : ffff80000813ef00
| [   47.344976] x8 : 000000000002ffe8 x7 : c0000000ffffdfff x6 : 00000000000affa8
| [   47.346431] x5 : 0000000000001fff x4 : 0000000000000001 x3 : ffff80000a0a3008
| [   47.347877] x2 : ffff80000a8220f8 x1 : 0000000043a95000 x0 : ffff000000827000
| [   47.349334] Call trace:
| [   47.349834]  0x43a95000
| [   47.350338]  kernel_kexec+0x88/0x100
| [   47.351070]  __do_sys_reboot+0x108/0x268
| [   47.351873]  __arm64_sys_reboot+0x2c/0x40
| [   47.352689]  invoke_syscall+0x78/0x108
| [   47.353458]  el0_svc_common.constprop.0+0x4c/0x100
| [   47.354426]  do_el0_svc+0x34/0x50
| [   47.355102]  el0_svc+0x34/0x108
| [   47.355747]  el0t_64_sync_handler+0xf4/0x120
| [   47.356617]  el0t_64_sync+0x194/0x198
| [   47.357374] Code: bad PC value
| [   47.357999] ---[ end trace 0000000000000000 ]---
| [   47.358937] Kernel panic - not syncing: Oops - Undefined instruction: Fatal exception
| [   47.360515] Kernel Offset: disabled
| [   47.361230] CPU features: 0x002000,00050108,c8004203
| [   47.362232] Memory Limit: none

Note: Unfortunately the code dump reports "bad PC value" as it attempts to dump some instructions prior to the UDF (i.e. before the start of the page), and terminates early upon a fault, obscuring the problem.

This patch fixes this issue by aligning the section starter markes to CONFIG_FUNCTION_ALIGNMENT using the ALIGN_FUNCTION() helper, which ensures that the linker never needs to place padding bytes within the section. Assertions are added to verify each section begins with the function we expect, making our implicit requirement explicit.

In future it might be nice to rework the kexec and hibernation code to decouple the section start from the entry point, but that involves much more significant changes that come with a higher risk of error, so I've tried to keep this fix as simple as possible for now.

Fixes 47a15aa544279d34 ("arm64: Extend support for CONFIG_FUNCTION_ALIGNMENT")
Cc Ard Biesheuvel <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc James Morse <[email protected]>
Cc Will Deacon <[email protected]>
---
 arch/arm64/kernel/vmlinux.lds.S | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/kernel/vmlinux.lds.S +6 -0
index 407415a5163ab..1a43df27a2046 100644
@@ -93,6 +93,7 @@ jiffies = jiffies_64;
 
 #ifdef CONFIG_HIBERNATION
 #define HIBERNATE_TEXT					\
+	ALIGN_FUNCTION();				\
 	__hibernate_exit_text_start = .;		\
 	*(.hibernate_exit.text)				\
 	__hibernate_exit_text_end = .;
@@ -102,6 +103,7 @@ jiffies = jiffies_64;
 
 #ifdef CONFIG_KEXEC_CORE
 #define KEXEC_TEXT					\
+	ALIGN_FUNCTION();				\
 	__relocate_new_kernel_start = .;		\
 	*(.kexec_relocate.text)				\
 	__relocate_new_kernel_end = .;
@@ -355,6 +357,8 @@ ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
 #ifdef CONFIG_HIBERNATION
 ASSERT(__hibernate_exit_text_end - __hibernate_exit_text_start <= SZ_4K,
        "Hibernate exit text is bigger than 4 KiB")
+ASSERT(__hibernate_exit_text_start == swsusp_arch_suspend_exit,
+       "Hibernate exit text does not start with swsusp_arch_suspend_exit")
 #endif
 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
 ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) <= 3*PAGE_SIZE,
@@ -381,4 +385,6 @@ ASSERT(swapper_pg_dir - tramp_pg_dir == TRAMP_SWAPPER_OFFSET,
 ASSERT(__relocate_new_kernel_end - __relocate_new_kernel_start <= SZ_4K,
        "kexec relocation code is bigger than 4 KiB")
 ASSERT(KEXEC_CONTROL_PAGE_SIZE >= SZ_4K, "KEXEC_CONTROL_PAGE_SIZE is broken")
+ASSERT(__relocate_new_kernel_start == arm64_relocate_new_kernel,
+       "kexec control page does not start with arm64_relocate_new_kernel")
 #endif
Signature · 7 lines
2.30.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v1 1/1
#8 lore raw

Re: [PATCH] arm64: avoid executing padding bytes during kexec / hibernation (WAS: Re: ? FAIL (91/181 SKIPPED): Test report for for-kernelci (6.2.0-rc5, arm-next, 2e84eedb))

Quoted 6 lines · Mark Rutland

Adding James, since this affects hibernate too.

Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Mark Rutland

...

Quoted 153 lines
Quoted 23 lines
Quoted 16 lines

It looks like this is down to the function alignment; reverting that commit makes it go away, but if ia add:

| diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
| index 6914f6bf41e22..8dafeea05864e 100644
| --- a/arch/arm64/Kconfig
| +++ b/arch/arm64/Kconfig
| @@ -123,7 +123,7 @@ config ARM64
|         select DMA_DIRECT_REMAP
|         select EDAC_SUPPORT
|         select FRAME_POINTER
| -       select FUNCTION_ALIGNMENT_4B
| +       select FUNCTION_ALIGNMENT_8B    # HACK HACK HACK
|         select GENERIC_ALLOCATOR
|         select GENERIC_ARCH_TOPOLOGY
|         select GENERIC_CLOCKEVENTS_BROADCAST
Quoted 6 lines

... then it blows up again.

So we're probably doing a clever address calculation in the kexec idmap code that ends up being wrong when the code gets shuffled a bit; possibly a mismatched caller/callee alignment.

Quoted 8 lines
$ grep -1 arm64_reloca System.map
ffff80000b0320fc T __relocate_new_kernel_start
ffff80000b032100 T arm64_relocate_new_kernel
ffff80000b032220 T __relocate_new_kernel_end

so the alignment results in arm64_relocate_new_kernel() appearing past the start of the section, and the kexec code takes the address of the section not the function symbol.

Yup, and we do the same for hibernation with swsusp_arch_suspend_exit vs __hibernate_exit_text_start. AFAICT those are the only places we end up relying upon alignment that we don't already have (e.g. the KPTI trampoline section is already page-aligned).

Quoted 8 lines

Something like the below should fix it, although it would arguably be better to clean up the kexec code (but I'm reluctant to make a clean spot)

index 407415a5163ab62f..89720ec2d830d51c 100644

arch/arm64/kernel/vmlinux.lds.S jiffies = jiffies_64; · line 108

Quoted 7 lines
arch/arm64/kernel/vmlinux.lds.S +1 -0
@@ -102,6 +102,7 @@ jiffies = jiffies_64;
 
 #ifdef CONFIG_KEXEC_CORE
 #define KEXEC_TEXT                                     \
+       . = ALIGN(64);                                  \
        __relocate_new_kernel_start = .;                \
        *(.kexec_relocate.text)                         \
        __relocate_new_kernel_end = .;

Yep, and there's ALIGN_FUNCTION() for exactly this purpose.

I had a quick look at making the kexec and hibernation code figure out the offset between the start of the section and the function, and it wasn't very pretty, so I think for now we should just place an assertion in the linker script.

With all that in mind, I came up with the patch below, which works for me with ftrace and/or CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B selected.

Thanks,
Mark

---->8----
From 8c82c71d810be311f10703b91563a301e56be910 Mon Sep 17 00:00:00 2001
From: Mark Rutland <[email protected]>
Date: Fri, 27 Jan 2023 11:08:20 +0000
Subject: [PATCH] arm64: avoid executing padding bytes during kexec /
hibernation

Currently we rely on the HIBERNATE_TEXT section starting with the entry point to swsusp_arch_suspend_exit, and the KEXEC_TEXT section starting with the entry point to arm64_relocate_new_kernel. In both cases we copy the entire section into a dynamically-allocated page, and then later branch to the start of this page.

SYM_FUNC_START() will align the function entry points to CONFIG_FUNCTION_ALIGNMENT, and when the linker later processes the assembled code it will place padding bytes before the function entry point if the location counter was not already sufficiently aligned. The linker happens to use the value zero for these padding bytes.

This padding may end up being applied whenever CONFIG_FUNCTION_ALIGNMENT is greater than 4, which can be the case with CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B=y or CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS=y.

When such padding is applied, attempting to kexec or resume from hibernate will result ina crash: the kernel will branch to the padding bytes as the start of the dynamically-allocated page, and as those bytes are zero they will decode as UDF #0, which reliably triggers an UNDEFINED exception. For example:

| # ./kexec --reuse-cmdline -f Image
| [   46.965800] kexec_core: Starting new kernel
| [   47.143641] psci: CPU1 killed (polled 0 ms)
| [   47.233653] psci: CPU2 killed (polled 0 ms)
| [   47.323465] psci: CPU3 killed (polled 0 ms)
| [   47.324776] Bye!
| [   47.327072] Internal error: Oops - Undefined instruction: 0000000002000000 [#1] SMP
| [   47.328510] Modules linked in:
| [   47.329086] CPU: 0 PID: 259 Comm: kexec Not tainted 6.2.0-rc5+ #3
| [   47.330223] Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
| [   47.331497] pstate: 604003c5 (nZCv DAIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
| [   47.332782] pc : 0x43a95000
| [   47.333338] lr : machine_kexec+0x190/0x1e0
| [   47.334169] sp : ffff80000d293b70
| [   47.334845] x29: ffff80000d293b70 x28: ffff000002cc0000 x27: 0000000000000000
| [   47.336292] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
| [   47.337744] x23: ffff80000a837858 x22: 0000000048ec9000 x21: 0000000000000010
| [   47.339192] x20: 00000000adc83000 x19: ffff000000827000 x18: 0000000000000006
| [   47.340638] x17: ffff800075a61000 x16: ffff800008000000 x15: ffff80000d293658
| [   47.342085] x14: 0000000000000000 x13: ffff80000d2937f7 x12: ffff80000a7ff6e0
| [   47.343530] x11: 00000000ffffdfff x10: ffff80000a8ef8e0 x9 : ffff80000813ef00
| [   47.344976] x8 : 000000000002ffe8 x7 : c0000000ffffdfff x6 : 00000000000affa8
| [   47.346431] x5 : 0000000000001fff x4 : 0000000000000001 x3 : ffff80000a0a3008
| [   47.347877] x2 : ffff80000a8220f8 x1 : 0000000043a95000 x0 : ffff000000827000
| [   47.349334] Call trace:
| [   47.349834]  0x43a95000
| [   47.350338]  kernel_kexec+0x88/0x100
| [   47.351070]  __do_sys_reboot+0x108/0x268
| [   47.351873]  __arm64_sys_reboot+0x2c/0x40
| [   47.352689]  invoke_syscall+0x78/0x108
| [   47.353458]  el0_svc_common.constprop.0+0x4c/0x100
| [   47.354426]  do_el0_svc+0x34/0x50
| [   47.355102]  el0_svc+0x34/0x108
| [   47.355747]  el0t_64_sync_handler+0xf4/0x120
| [   47.356617]  el0t_64_sync+0x194/0x198
| [   47.357374] Code: bad PC value
| [   47.357999] ---[ end trace 0000000000000000 ]---
| [   47.358937] Kernel panic - not syncing: Oops - Undefined instruction: Fatal exception
| [   47.360515] Kernel Offset: disabled
| [   47.361230] CPU features: 0x002000,00050108,c8004203
| [   47.362232] Memory Limit: none

Note: Unfortunately the code dump reports "bad PC value" as it attempts to dump some instructions prior to the UDF (i.e. before the start of the page), and terminates early upon a fault, obscuring the problem.

This patch fixes this issue by aligning the section starter markes to CONFIG_FUNCTION_ALIGNMENT using the ALIGN_FUNCTION() helper, which ensures that the linker never needs to place padding bytes within the section. Assertions are added to verify each section begins with the function we expect, making our implicit requirement explicit.

In future it might be nice to rework the kexec and hibernation code to decouple the section start from the entry point, but that involves much more significant changes that come with a higher risk of error, so I've tried to keep this fix as simple as possible for now.

Quoted 8 lines
Fixes 47a15aa544279d34 ("arm64: Extend support for CONFIG_FUNCTION_ALIGNMENT")
Cc Ard Biesheuvel <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc James Morse <[email protected]>
Cc Will Deacon <[email protected]>
Quoted 41 lines
---
 arch/arm64/kernel/vmlinux.lds.S | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/kernel/vmlinux.lds.S +6 -1
index 407415a5163ab..1a43df27a2046 100644
@@ -93,6 +93,7 @@ jiffies = jiffies_64;
 
 #ifdef CONFIG_HIBERNATION
 #define HIBERNATE_TEXT                                 \
+       ALIGN_FUNCTION();                               \
        __hibernate_exit_text_start = .;                \
        *(.hibernate_exit.text)                         \
        __hibernate_exit_text_end = .;
@@ -102,6 +103,7 @@ jiffies = jiffies_64;
 
 #ifdef CONFIG_KEXEC_CORE
 #define KEXEC_TEXT                                     \
+       ALIGN_FUNCTION();                               \
        __relocate_new_kernel_start = .;                \
        *(.kexec_relocate.text)                         \
        __relocate_new_kernel_end = .;
@@ -355,6 +357,8 @@ ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
 #ifdef CONFIG_HIBERNATION
 ASSERT(__hibernate_exit_text_end - __hibernate_exit_text_start <= SZ_4K,
        "Hibernate exit text is bigger than 4 KiB")
+ASSERT(__hibernate_exit_text_start == swsusp_arch_suspend_exit,
+       "Hibernate exit text does not start with swsusp_arch_suspend_exit")
 #endif
 #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
 ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) <= 3*PAGE_SIZE,
@@ -381,4 +385,6 @@ ASSERT(swapper_pg_dir - tramp_pg_dir == TRAMP_SWAPPER_OFFSET,
 ASSERT(__relocate_new_kernel_end - __relocate_new_kernel_start <= SZ_4K,
        "kexec relocation code is bigger than 4 KiB")
 ASSERT(KEXEC_CONTROL_PAGE_SIZE >= SZ_4K, "KEXEC_CONTROL_PAGE_SIZE is broken")
+ASSERT(__relocate_new_kernel_start == arm64_relocate_new_kernel,
+       "kexec control page does not start with arm64_relocate_new_kernel")
 #endif
--
Quoted 2 lines

2.30.2

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#9 lore raw

Re: [PATCH] arm64: avoid executing padding bytes during kexec / hibernation (WAS: Re: ? FAIL (91/181 SKIPPED): Test report for for-kernelci (6.2.0-rc5, arm-next, 2e84eedb))

In reply to Mark Rutland
Quoted 11 lines · Mark Rutland

From 8c82c71d810be311f10703b91563a301e56be910 Mon Sep 17 00:00:00 2001
From: Mark Rutland <[email protected]>
Date: Fri, 27 Jan 2023 11:08:20 +0000
Subject: [PATCH] arm64: avoid executing padding bytes during kexec /
hibernation

Currently we rely on the HIBERNATE_TEXT section starting with the entry point to swsusp_arch_suspend_exit, and the KEXEC_TEXT section starting with the entry point to arm64_relocate_new_kernel. In both cases we copy the entire section into a dynamically-allocated page, and then later branch to the start of this page.

Queued on top of the arm64 for-next/ftrace branch. Thanks.

Signature · 6 lines
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel