summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/riscv/mm/mmap_bottomup.c
blob: 1757d19ca89b1bc06e6f9391440f502dd74adcbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: GPL-2.0-only
#include <sys/mman.h>
#include <mmap_test.h>

#include "../../kselftest_harness.h"

TEST(infinite_rlimit)
{
// Only works on 64 bit
#if __riscv_xlen == 64
	struct addresses mmap_addresses;

	EXPECT_EQ(BOTTOM_UP, memory_layout());

	do_mmaps(&mmap_addresses);

	EXPECT_NE(MAP_FAILED, mmap_addresses.no_hint);
	EXPECT_NE(MAP_FAILED, mmap_addresses.on_37_addr);
	EXPECT_NE(MAP_FAILED, mmap_addresses.on_38_addr);
	EXPECT_NE(MAP_FAILED, mmap_addresses.on_46_addr);
	EXPECT_NE(MAP_FAILED, mmap_addresses.on_47_addr);
	EXPECT_NE(MAP_FAILED, mmap_addresses.on_55_addr);
	EXPECT_NE(MAP_FAILED, mmap_addresses.on_56_addr);

	EXPECT_GT(1UL << 47, (unsigned long)mmap_addresses.no_hint);
	EXPECT_GT(1UL << 38, (unsigned long)mmap_addresses.on_37_addr);
	EXPECT_GT(1UL << 38, (unsigned long)mmap_addresses.on_38_addr);
	EXPECT_GT(1UL << 38, (unsigned long)mmap_addresses.on_46_addr);
	EXPECT_GT(1UL << 47, (unsigned long)mmap_addresses.on_47_addr);
	EXPECT_GT(1UL << 47, (unsigned long)mmap_addresses.on_55_addr);
	EXPECT_GT(1UL << 56, (unsigned long)mmap_addresses.on_56_addr);
#endif
}

TEST_HARNESS_MAIN