Unverified Commit 9b1d9abe authored by Palmer Dabbelt's avatar Palmer Dabbelt
Browse files

Merge patch series "tools: selftests: riscv: Fix compiler warnings"

Christoph Muellner <christoph.muellner@vrull.eu> says:

From: Christoph Müllner <christoph.muellner@vrull.eu>

When building the RISC-V selftests with a riscv32 compiler I ran into
a couple of compiler warnings. While riscv32 support for these tests is
questionable, the fixes are so trivial that it is probably best to simply
apply them.

Note that the missing-include patch and some format string warnings
are also relevant for riscv64.

* b4-shazam-merge:
  tools: selftests: riscv: Fix compile warnings in mm tests
  tools: selftests: riscv: Fix compile warnings in vector tests
  tools: selftests: riscv: Add missing include for vector test
  tools: selftests: riscv: Fix compile warnings in cbo
  tools: selftests: riscv: Fix compile warnings in hwprobe

Link: https://lore.kernel.org/r/20231123185821.2272504-1-christoph.muellner@vrull.eu


Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parents 54d7431a 12c16919
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ static void test_zicboz(void *arg)
	block_size = pair.value;
	ksft_test_result(rc == 0 && pair.key == RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE &&
			 is_power_of_2(block_size), "Zicboz block size\n");
	ksft_print_msg("Zicboz block size: %ld\n", block_size);
	ksft_print_msg("Zicboz block size: %llu\n", block_size);

	illegal_insn = false;
	cbo_zero(&mem[block_size]);
@@ -121,7 +121,7 @@ static void test_zicboz(void *arg)
		for (j = 0; j < block_size; ++j) {
			if (mem[i * block_size + j] != expected) {
				ksft_test_result_fail("cbo.zero check\n");
				ksft_print_msg("cbo.zero check: mem[%d] != 0x%x\n",
				ksft_print_msg("cbo.zero check: mem[%llu] != 0x%x\n",
					       i * block_size + j, expected);
				return;
			}
@@ -201,7 +201,7 @@ int main(int argc, char **argv)
	pair.key = RISCV_HWPROBE_KEY_IMA_EXT_0;
	rc = riscv_hwprobe(&pair, 1, sizeof(cpu_set_t), (unsigned long *)&cpus, 0);
	if (rc < 0)
		ksft_exit_fail_msg("hwprobe() failed with %d\n", rc);
		ksft_exit_fail_msg("hwprobe() failed with %ld\n", rc);
	assert(rc == 0 && pair.key == RISCV_HWPROBE_KEY_IMA_EXT_0);

	if (pair.value & RISCV_HWPROBE_EXT_ZICBOZ) {
+2 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ int main(int argc, char **argv)
		/* Fail if the kernel claims not to recognize a base key. */
		if ((i < 4) && (pairs[i].key != i))
			ksft_exit_fail_msg("Failed to recognize base key: key != i, "
					   "key=%ld, i=%ld\n", pairs[i].key, i);
					   "key=%lld, i=%ld\n", pairs[i].key, i);

		if (pairs[i].key != RISCV_HWPROBE_KEY_BASE_BEHAVIOR)
			continue;
@@ -37,7 +37,7 @@ int main(int argc, char **argv)
		if (pairs[i].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA)
			continue;

		ksft_exit_fail_msg("Unexpected pair: (%ld, %ld)\n", pairs[i].key, pairs[i].value);
		ksft_exit_fail_msg("Unexpected pair: (%lld, %llu)\n", pairs[i].key, pairs[i].value);
	}

	out = riscv_hwprobe(pairs, 8, 0, 0, 0);
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ struct addresses {
	int *on_56_addr;
};

// Only works on 64 bit
#if __riscv_xlen == 64
static inline void do_mmaps(struct addresses *mmap_addresses)
{
	/*
@@ -50,6 +52,7 @@ static inline void do_mmaps(struct addresses *mmap_addresses)
	mmap_addresses->on_56_addr =
		mmap(on_56_bits, 5 * sizeof(int), prot, flags, 0, 0);
}
#endif /* __riscv_xlen == 64 */

static inline int memory_layout(void)
{
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ int main(void)

	datap = malloc(MAX_VSIZE);
	if (!datap) {
		ksft_test_result_fail("fail to allocate memory for size = %lu\n", MAX_VSIZE);
		ksft_test_result_fail("fail to allocate memory for size = %d\n", MAX_VSIZE);
		exit(-1);
	}

+3 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only

#include <linux/wait.h>

#define THIS_PROGRAM "./vstate_exec_nolibc"

int main(int argc, char **argv)
Loading