Skip to content
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

[Bug]arm64: Initialize sctrl_el1 when running fork #15857

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

W-M-R
Copy link
Contributor

@W-M-R W-M-R commented Feb 18, 2025

Note: Please adhere to Contributing Guidelines.

Summary

arm64: Initialize sctrl_el1 when running fork

Impact

If fork does not initialize sctrl_el1 in arm64 platform, it will cause the child process to start incorrectly and the system to crash.

Testing

CI

@github-actions github-actions bot added Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: XS The size of the change in this PR is very small labels Feb 18, 2025
@lupyuen
Copy link
Member

lupyuen commented Feb 18, 2025

@nuttxpr test qemu-armv8a:netnsh

@nuttxpr
Copy link

nuttxpr commented Feb 18, 2025

[Experimental Bot, please feedback here]

Build and Test Successful (qemu-armv8a:netnsh)
https://gitlab.com/lupyuen/nuttx-build-log/-/snippets/4808026

$ git clone https://github.com/W-M-R/nuttx nuttx --branch mte-sctlr
$ git clone https://github.com/apache/nuttx-apps apps --branch master
$ pushd nuttx
$ git reset --hard HEAD
HEAD is now at 3742be91c3 arm64: Initialize sctrl_el1 when running fork
$ popd
$ pushd apps
$ git reset --hard HEAD
HEAD is now at 62894b9ba examples/spislave_test: Add user data receive
$ popd
NuttX Source: https://github.com/apache/nuttx/tree/3742be91c3f0c98001f311700f0aca89a53075f3
NuttX Apps: https://github.com/apache/nuttx-apps/tree/62894b9baf2978815ceec454e53118e6d83c84f6
$ cd nuttx
$ tools/configure.sh qemu-armv8a:netnsh
$ make -j
$ dd if=/dev/zero of=./mydisk-1gb.img bs=1M count=1024
$ qemu-system-aarch64 --version
QEMU emulator version 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.5)
$ qemu-system-aarch64 -cpu cortex-a53 -nographic -machine virt,virtualization=on,gic-version=3 -chardev stdio,id=con,mux=on -serial chardev:con -global virtio-mmio.force-legacy=false -device virtio-serial-device,bus=virtio-mmio-bus.0 -chardev socket,telnet=on,host=127.0.0.1,port=3450,server=on,wait=off,id=foo -device virtconsole,chardev=foo -device virtio-rng-device,bus=virtio-mmio-bus.1 -netdev user,id=u1,hostfwd=tcp:127.0.0.1:10023-10.0.2.15:23,hostfwd=tcp:127.0.0.1:15001-10.0.2.15:5001 -device virtio-net-device,netdev=u1,bus=virtio-mmio-bus.2 -drive file=./mydisk-1gb.img,if=none,format=raw,id=hd -device virtio-blk-device,bus=virtio-mmio-bus.3,drive=hd -mon chardev=con,mode=readline -kernel ./nuttx
nsh> uname -a
NuttX  0.0.0 3742be91c3 Feb 18 2025 20:17:34 arm64 qemu-armv8a
nsh> ostest
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     7be7000  7be7000
ordblks         8        6
mxordblk  7b91f38  7b8fef8
uordblks    51878    54c48
fordblks  7b95788  7b923b8
user_main: Exiting
ostest_main: Exiting with status 0

Copy link
Member

@lupyuen lupyuen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested OK with OSTest on Arm64 QEMU. Thanks :-)

@lupyuen
Copy link
Member

lupyuen commented Feb 18, 2025

@W-M-R Please remember to:

  • Fill in the Commit Description: 3742be9
  • Remove this from the PR Description: 'Note: Please adhere to..."
  • Could you explain why we need to init sctrl_el1 when running fork, and why it wasn't done earlier? Please fill in the PR Description. Thanks :-)

@W-M-R
Copy link
Contributor Author

W-M-R commented Feb 19, 2025

@W-M-R Please remember to:

  • Fill in the Commit Description: 3742be9
  • Remove this from the PR Description: 'Note: Please adhere to..."
  • Could you explain why we need to init sctrl_el1 when running fork, and why it wasn't done earlier? Please fill in the PR Description. Thanks :-)

OK

@W-M-R W-M-R changed the title arm64: Initialize sctrl_el1 when running fork [Bug]arm64: Initialize sctrl_el1 when running fork Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: XS The size of the change in this PR is very small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants