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

Add support for MTD ioctls #3908

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

kempniu
Copy link
Contributor

@kempniu kempniu commented Jan 28, 2025

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mtd/mtdchar.c?h=v6.13#n822

A limited subset of these ioctls can be tested without a physical MTD device by running:

sudo modprobe nandsim
sudo chown "${USER}" /dev/mtd1
git clone --depth 1 --recurse-submodules https://github.com/kempniu/yafut.git
cd yafut/
cmake -Bbuild && cmake --build build
dd if=/dev/urandom bs=32k count=1 | tee garbage-in | rr record build/yafut -d /dev/mtd1 -v -v -w -i - -o /garbage   
rr replay -a -M
rr record build/yafut -d /dev/mtd1 -v -v -r -i /garbage -o garbage-out
rr replay -a -M
sha256sum garbage-in garbage-out

@kempniu
Copy link
Contributor Author

kempniu commented Jan 29, 2025

The Android build fails because it uses Android NDK r25c, which was released in July 2022 and therefore does not contain the definitions of the MEMREAD ioctl and struct mtd_read_req, which first appeared in Linux kernel 6.1, which was released in December 2022. AFAICT, Android NDK r25c is no longer supported.

I verified that this PR builds fine with Android NDK r26d (September 2023) or any newer version - the latest stable Android NDK release is r27c (July 2024):

diff --git a/.android/Dockerfile b/.android/Dockerfile
index 62fb2cd5..8557eefc 100644
--- a/.android/Dockerfile
+++ b/.android/Dockerfile
@@ -1,6 +1,6 @@
 FROM ubuntu:latest
 
-ARG ndk_version=r25c
+ARG ndk_version=r27c
 
 RUN apt-get update && apt-get install -y \
     build-essential \

@rocallahan
Copy link
Collaborator

Thanks for the PR. I'm a bit swamped so I might need another week to get to it.
We usually deal with new syscalls and types etc by copying their definitions into rr when needed --- kernel_supplement.h for stuff used by rr itself and util.h or the tests themselves when used in tests.

@khuey
Copy link
Collaborator

khuey commented Jan 29, 2025

I'll look at bumping Android's NDK version later this week. Thanks for doing the legwork there :)

@khuey
Copy link
Collaborator

khuey commented Feb 3, 2025

Alright lets rebase this and verify that CI passes now that we're on r27c.

@kempniu kempniu force-pushed the add-support-for-mtd-ioctls branch from fd7ba4f to 18e9f27 Compare February 3, 2025 05:21
@khuey khuey merged commit b57615e into rr-debugger:master Feb 3, 2025
5 checks passed
@khuey
Copy link
Collaborator

khuey commented Feb 3, 2025

Thanks!

@kempniu kempniu deleted the add-support-for-mtd-ioctls branch February 3, 2025 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants