Skip to content

Get mips64(el)-linux working and start testing it #21095

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

Merged
merged 10 commits into from
Aug 23, 2024

Conversation

alexrp
Copy link
Member

@alexrp alexrp commented Aug 16, 2024

No description provided.

@alexrp alexrp marked this pull request as draft August 16, 2024 10:12
@alexrp alexrp marked this pull request as ready for review August 17, 2024 10:04
@alexrp
Copy link
Member Author

alexrp commented Aug 17, 2024

This should be ready for review.

@alexrp alexrp force-pushed the mips64-tests branch 2 times, most recently from dd9545f to cb069d3 Compare August 17, 2024 21:27
alexrp added 10 commits August 18, 2024 07:27
The kernel sets r7 to 0 (success) or -1 (error), and stores the result in r2.
When r7 is -1 and the result is positive, it needs to be negated to get the
errno value that higher-level code, such as errnoFromSyscall(), expects to see.

The old code was missing the check that r2 is positive, but was also doing the
r7 check incorrectly; since it can only be set to 0 or -1, the blez instruction
would always branch.

In practice, this fix is necessary for e.g. the ENOSYS error to be interpreted
correctly. This manifested as hitting an unreachable branch when calling
process_vm_readv() in std.debug.MemoryAccessor.
It is usually generic, so no point having it in arch bits.
These take 3-4 minutes to run on my machine, i.e. they're not affected by the
LLVM compilation speed bug that affects mips32.
Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

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

This doubles the amount of time CI runs take. Let's proceed and see if it is manageable.

If it's too much, perhaps one category of testing can be performed on master branch only, and then any breakage can be reverted.

Comment on lines 16 to 20
\\ syscall
\\ blez $7, 1f
\\ beq $7, $zero, 1f
\\ blez $2, 1f
\\ dsubu $2, $0, $2
\\ 1:
Copy link
Member

Choose a reason for hiding this comment

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

The equivalent musl code for all these syscall functions has only one daddu instruction followed by syscall. Any reason we can't do that?

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason we don't have that is because musl mixes inline assembly and C logic: https://git.musl-libc.org/cgit/musl/tree/arch/mips64/syscall_arch.h#n38

We could of course do the same, but I thought I'd just keep things simple.

Copy link
Member

Choose a reason for hiding this comment

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

it's not really related to C logic, it's just using C syntax to get values in and out of registers. Zig's constraint strings are powerful enough to do the same. You're already doing it with ={$2} to get the value out. You can do the same thing with the input values.

	register long r4 __asm__("$4") = a;

is just

: "[a] {$4}" (a),

in zig.

@andrewrk andrewrk merged commit ee84ded into ziglang:master Aug 23, 2024
10 checks passed
@alexrp
Copy link
Member Author

alexrp commented Aug 23, 2024

This doubles the amount of time CI runs take. Let's proceed and see if it is manageable.

@andrewrk that's because the CI results here were from before #21125 was merged. The extreme slowdown observed for MIPS is specific to O32; N64 runs in a normal amount of time.

@andrewrk
Copy link
Member

I see, thank you for pointing that out.

@alexrp alexrp deleted the mips64-tests branch August 23, 2024 07:27
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.

2 participants