Skip to content

Commit dbd4af5

Browse files
Alexey Dobriyantorvalds
authored andcommitted
proc: fixup map_files test on arm
https://bugs.linaro.org/show_bug.cgi?id=3782 Turns out arm doesn't permit mapping address 0, so try minimum virtual address instead. Link: http://lkml.kernel.org/r/20181113165446.GA28157@avx2 Signed-off-by: Alexey Dobriyan <[email protected]> Reported-by: Rafael David Tinoco <[email protected]> Tested-by: Rafael David Tinoco <[email protected]> Acked-by: Cyrill Gorcunov <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8de456c commit dbd4af5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tools/testing/selftests/proc/proc-self-map-files-002.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1414
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*/
16-
/* Test readlink /proc/self/map_files/... with address 0. */
16+
/* Test readlink /proc/self/map_files/... with minimum address. */
1717
#include <errno.h>
1818
#include <sys/types.h>
1919
#include <sys/stat.h>
@@ -47,6 +47,11 @@ static void fail(const char *fmt, unsigned long a, unsigned long b)
4747
int main(void)
4848
{
4949
const unsigned int PAGE_SIZE = sysconf(_SC_PAGESIZE);
50+
#ifdef __arm__
51+
unsigned long va = 2 * PAGE_SIZE;
52+
#else
53+
unsigned long va = 0;
54+
#endif
5055
void *p;
5156
int fd;
5257
unsigned long a, b;
@@ -55,7 +60,7 @@ int main(void)
5560
if (fd == -1)
5661
return 1;
5762

58-
p = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_PRIVATE|MAP_FILE|MAP_FIXED, fd, 0);
63+
p = mmap((void *)va, PAGE_SIZE, PROT_NONE, MAP_PRIVATE|MAP_FILE|MAP_FIXED, fd, 0);
5964
if (p == MAP_FAILED) {
6065
if (errno == EPERM)
6166
return 2;

0 commit comments

Comments
 (0)