Bug 444781 - MIPS: wrong syscall numbers used
Summary: MIPS: wrong syscall numbers used
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-01 15:08 UTC by Hauke Mehrtens
Modified: 2021-11-01 15:09 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
[PATCH] mips: Fix new syscall numbers (5.50 KB, patch)
2021-11-01 15:08 UTC, Hauke Mehrtens
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hauke Mehrtens 2021-11-01 15:08:39 UTC
Created attachment 143104 [details]
[PATCH] mips: Fix new syscall numbers

MIPS uses special syscall numbers on Linux, we can not use the vki/vki-scnums-32bit-linux.h and vki/vki-scnums-shared-linux.h files on MIPS.
With valgrind 3.18.1 on MIPS 32 BE I am getting this error message with dropbear and musl 1.2.2
```
root@OpenWrt:/# valgrind ssh 192.168.10.3
==1910== Memcheck, a memory error detector
==1910== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1910== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==1910== Command: ssh 192.168.10.3
==1910== 
==1910== Conditional jump or move depends on uninitialised value(s)
==1910==    at 0x407E198: ??? (in /lib/libc.so)
==1910==    by 0x4091BCC: ??? (in /lib/libc.so)
==1910== 
==1910== Conditional jump or move depends on uninitialised value(s)
==1910==    at 0x407D77C: ??? (in /lib/libc.so)
==1910==    by 0x407DCA0: ??? (in /lib/libc.so)
==1910== 
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
==1910== Conditional jump or move depends on uninitialised value(s)
==1910==    at 0x407E198: ??? (in /lib/libc.so)
==1910==    by 0x4057F64: ??? (in /lib/libc.so)
==1910== 
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
--1910-- WARNING: unhandled mips32-linux syscall: 4403
--1910-- You may be able to write your own handler.
--1910-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--1910-- Nevertheless we consider this a bug.  Please report
--1910-- it at http://valgrind.org/support/bug_reports.html.
.....
```
I expect that it detects the syscall mumber 4403 as the valid syscall clock_gettime64.

OpenWrt master with musl 1.2.2 and Linux 5.10 with valgrind 3.18.1 on MIPS BE 32 bit on MIPS malta in qemu. 

The attached patch fixes the problem. I only really tested the clock_gettime64 syscall on MIPS 32 BE, but not the rest. My test application do not issue these syscalls.