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

RISC-V port fixes (part I) #2518

Merged
merged 2 commits into from
Nov 21, 2024
Merged

Conversation

mihalicyn
Copy link
Member

@mihalicyn mihalicyn commented Nov 17, 2024

Some follow-up fixes for CRIU port on RISC-V.

cc @ancientmodern @Cryolitia @felicitia

We don't need to have compel/arch/riscv64/plugins/std/syscalls/syscalls.S
tracked in git. It is autogenerated. We also need to update our .gitignore
to ignore autogenerated files with syscall tables.

Signed-off-by: Alexander Mikhalitsyn <[email protected]>
@mihalicyn
Copy link
Member Author

Earlier I mentioned that I had experienced not only TASK_SIZE-related issue but also crashes on later stages. But after I've got an upstream 6.12-rc7 kernel running on my board it started to work. Most likely I was experiencing some kernel bug and also it was kernel without torvalds/linux@ce4f78f fix which can also affect my earlier testing.

We need to dynamically calculate TASK_SIZE depending
on the MMU on RISC-V system. [We are using analogical
approach on aarch64/ppc64le.]

This change was tested on physical machine:
StarFive VisionFive 2
isa		: rv64imafdc_zicntr_zicsr_zifencei_zihpm_zca_zcd_zba_zbb
mmu		: sv39
uarch		: sifive,u74-mc
mvendorid	: 0x489
marchid		: 0x8000000000000007
mimpid		: 0x4210427
hart isa	: rv64imafdc_zicntr_zicsr_zifencei_zihpm_zca_zcd_zba_zbb

Signed-off-by: Alexander Mikhalitsyn <[email protected]>
Copy link
Member

@ancientmodern ancientmodern left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@avagin avagin merged commit 1452c76 into checkpoint-restore:criu-dev Nov 21, 2024
38 of 42 checks passed
unsigned long task_size;

for (task_size = TASK_SIZE_MIN; task_size < TASK_SIZE_MAX; task_size <<= 1)
if (munmap((void *)task_size, page_size()))
Copy link
Member

Choose a reason for hiding this comment

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

I merged it because I was thinking that I'd reviewed it already.

I think this munamp can unmap something useful and trigger sigsegv.

Copy link
Member Author

@mihalicyn mihalicyn Nov 22, 2024

Choose a reason for hiding this comment

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

Hmm, actually, we are using the same approach for other architectures:

unsigned long compel_task_size(void)

unsigned long compel_task_size(void)

But that's an interesting point and probably I should try to find a cleaner way to determine a task size across all architectures we have then.

But taking into account that it's not a new and dirty hack I introduced but rather reusing an existing and time-proven method I think it's good enough to be there.

Upd: A first thing that comes into my mind is to replace munmap with some "safer" syscall like madvise. But it's still requires investigation...

Upd: we can also do mmap before munmap.

Copy link
Member

Choose a reason for hiding this comment

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

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