From patchwork Thu Aug 8 13:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 13757422 Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E49FAEEA9 for ; Thu, 8 Aug 2024 13:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122167; cv=none; b=RDkTf1c1H2RM2VyIRgtmDLUzeQtXka4TXOjcGWUSrDlk4GDIcrvr1zAPAI8P+3mHHRgOv+tDyeOfIgkTT+dRppmhymrJl411aPrx4gxex1mB142ZCC8+hWLHx37AAerRPXTVdmRY+G32450QOpg02IvOFbzH6aefmISxC2EApWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122167; c=relaxed/simple; bh=cqguEQOOz9SxEfl7Q34++2N6CN96V1dOcnzn+wHexno=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uQ4t3ix1TeP0WRL224DYNiDcuk6FiC20KQi56lgUeTZAmFzsu9JJyFu81m1/fD7T80FQyVF50mhjFTMihdB8Nv5oRrawd83tKjuqfbJICRfuo+9iiitYICn2a4Ul7eg6scs/MEteBjyq7EqX32iywgptdD/IG9ZLwIV1CCFOLKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=KEk8LKSH; arc=none smtp.client-ip=91.218.175.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="KEk8LKSH" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1723122160; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lU26pXhquuCdnTqhFaYsIK4k779MOEn2WOTwMpCQRsk=; b=KEk8LKSH4I5EZ1+/rpAaibTsGN+xSZVA4AwyBXmJogf4eKElKP91SbIJBdvX/fwIK5uJ2Y yDYDP5LhwB3WkGQBCRhlhb6zTnxlc8QhDzKqgfOCGR5DvyIzowAhT5yC8wpqpQwijqi/0x PieYZwWQ149rGS1mQphqEdT63/JQ8FE= From: Andrew Jones To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: pbonzini@redhat.com, thuth@redhat.com, atishp@rivosinc.com, cade.richard@berkeley.edu, jamestiotio@gmail.com Subject: [kvm-unit-tests PATCH 1/3] lib: Add limits.h Date: Thu, 8 Aug 2024 15:02:31 +0200 Message-ID: <20240808130229.47415-6-andrew.jones@linux.dev> In-Reply-To: <20240808130229.47415-5-andrew.jones@linux.dev> References: <20240808130229.47415-5-andrew.jones@linux.dev> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT We already include limits.h from a couple places (libfdt and the sbi test for riscv). We should provide our own limits.h rather than depend on the build environment as some cross environments may not support it (building riscv with a ilp32d toolchain fails, for example). We guard each definition to ensure we only provide them when the sizes match our expectations. If something is strange then the define won't be created, and either the includer won't notice since it wasn't used or the build will break and limits.h can be extended. Signed-off-by: Andrew Jones --- lib/limits.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/limits.h diff --git a/lib/limits.h b/lib/limits.h new file mode 100644 index 000000000000..234ef5325f92 --- /dev/null +++ b/lib/limits.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LIMITS_H_ +#define _LIMITS_H_ + +#if __CHAR_BIT__ == 8 +# if __CHAR_UNSIGNED__ +# define CHAR_MIN 0 +# define CHAR_MAX __UINT8_MAX__ +# else +# define CHAR_MAX __INT8_MAX__ +# define CHAR_MIN (-CHAR_MAX - 1) +# endif +#endif + +#if __SHRT_WIDTH__ == 16 +#define SHRT_MAX __INT16_MAX__ +#define SHRT_MIN (-SHRT_MAX - 1) +#define USHRT_MAX __UINT16_MAX__ +#endif + +#if __INT_WIDTH__ == 32 +#define INT_MAX __INT32_MAX__ +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX __UINT32_MAX__ +#endif + +#if __LONG_WIDTH__ == 64 +#define LONG_MAX __INT64_MAX__ +#define LONG_MIN (-LONG_MAX - 1) +#define ULONG_MAX __UINT64_MAX__ +#elif __LONG_WIDTH__ == 32 +#define LONG_MAX __INT32_MAX__ +#define LONG_MIN (-LONG_MAX - 1) +#define ULONG_MAX __UINT32_MAX__ +#endif + +#if __LONG_LONG_WIDTH__ == 64 +#define LLONG_MAX __INT64_MAX__ +#define LLONG_MIN (-LLONG_MAX - 1) +#define ULLONG_MAX __UINT64_MAX__ +#endif + +#endif /* _LIMITS_H_ */ From patchwork Thu Aug 8 13:02:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 13757423 Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00F7518CC04 for ; Thu, 8 Aug 2024 13:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122171; cv=none; b=rw74KNESrr87OiauVF5mLdioqACl3DT0RqczGqZa651h4Hcp2d3MTC1noiP7X/501JW61/IG0PgnLQf+yaXOWeb/LMAJiu/Jz+VrHI41bh6h0Rn8zEzX/44P1Ycev4bLZo1UJ2f4j281UoJU8VaiQGp2BY2lW1qHU4icc/PQAyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122171; c=relaxed/simple; bh=CgK8IQsCFIqZyQM74+tfbF6V14abW0bGt2YLw7wtktQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ti4C+eLGSHZh5jdOPYla142HYKfrbDGATJ1+vVXkMuhlWXz7szVpNpIw9CNxHqAggzxiI97Pi/p5IXAX2hejrZgiU13oH4+Hmx+fnAI0w7avtIWi6K6GCodZ6ZmDE1Y5uuYQU4nLs6XcrH4LY8Q85amBThd/My2AT+BvY9DyvFI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=eK+6voUl; arc=none smtp.client-ip=95.215.58.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="eK+6voUl" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1723122164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HzOqAtg2J4AwG0o9+R6F8Ao/GNJA6cEB1EV+uLHrR9g=; b=eK+6voUlAQAFDJWcVObJNNagx1HJp0V/94MIslPF8AgyQtKN9x0NbRZ2X5/NUwNTf1nzmW zyp3jaHOveh6VGXL1OMTagZYZ07HjGZdLg0SsZl/7JVVwtimtaXORCozqSn/0A68U9ZDxl aunyfqoVrn92SmGBdvhzHeiuZddCaws= From: Andrew Jones To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: pbonzini@redhat.com, thuth@redhat.com, atishp@rivosinc.com, cade.richard@berkeley.edu, jamestiotio@gmail.com Subject: [kvm-unit-tests PATCH 2/3] riscv: Build with explicit ABI Date: Thu, 8 Aug 2024 15:02:32 +0200 Message-ID: <20240808130229.47415-7-andrew.jones@linux.dev> In-Reply-To: <20240808130229.47415-5-andrew.jones@linux.dev> References: <20240808130229.47415-5-andrew.jones@linux.dev> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT If we add -mabi to the command line then compilers that are built to support multiple ABIs may be used for both rv32 and rv64 builds, so add it for that reason. We also need the right linker flags, so add those too and throw in a trimming of the ISA string (drop fd) in order to keep it minimal. Signed-off-by: Andrew Jones --- riscv/Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/riscv/Makefile b/riscv/Makefile index b0cd613fcd8c..7906cef7f199 100644 --- a/riscv/Makefile +++ b/riscv/Makefile @@ -64,13 +64,15 @@ define arch_elf_check = $(error $(1) has unsupported reloc types)) endef -ISA_COMMON = mafdc_zicsr_zifencei_zihintpause +ISA_COMMON = imac_zicsr_zifencei_zihintpause ifeq ($(ARCH),riscv64) -CFLAGS += -march=rv64i$(ISA_COMMON) -CFLAGS += -DCONFIG_64BIT +CFLAGS += -DCONFIG_64BIT +CFLAGS += -mabi=lp64 -march=rv64$(ISA_COMMON) +LDFLAGS += -melf64lriscv else ifeq ($(ARCH),riscv32) -CFLAGS += -march=rv32i$(ISA_COMMON) +CFLAGS += -mabi=ilp32 -march=rv32$(ISA_COMMON) +LDFLAGS += -melf32lriscv endif CFLAGS += -DCONFIG_RELOC CFLAGS += -mcmodel=medany From patchwork Thu Aug 8 13:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 13757424 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92CD9EEA9 for ; Thu, 8 Aug 2024 13:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122172; cv=none; b=lcJ68MVDc1Dd9Np2X9sb+Axdu8R4bImfweDU5LWELhrIaD1D1sLC1FToZ2OMkOL3vUyk0U509CiS2Qo62gJkMNcHqOmt47pk0mXRtZimgZxH4Ci77bbEyD+vleyk7Oabj3YrykincT5dvKKQEm1N2bqafOZqAocdrN790bkKLWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723122172; c=relaxed/simple; bh=ns01SJLnHrxjWzd1fo9WyCo3K/MLEdtkRAmZR+YmjKM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W8E0GsjZLcEYdJk7+pgwj7giz+8vyePV07SsBfVkg/KwXNqU5HDMKCYcmTnhZ0m++CRDZerhTkf3p6E6evfvq2AdWW+Ay7bkpCLeTTraYsiE0JXB0IKqo8dMkskBdLjBj3rMeI0EJfkFhiAK56GnZo9YfFzvxz10uJzFCmTxRuk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=LvV4IiDy; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="LvV4IiDy" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1723122166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g54ATMTIXJG375b5OzuX0KxWMWCaU+/qcXwlqHIObZg=; b=LvV4IiDyBczFFuN4Y2t0kutoKNImwR5K6AsR+Ow4hKnzXJGKzn1LnXvHuklYxdQUXov4ci tSRHdAoz3RsXBQAEHYM0PC/SQ3TD1w+Z8K0IxJgPqstrH0wY2d4NvUOEMWOWoPC28uHSNk eLvsP2/sq7XJDB4a13yNAnzQ5e93upo= From: Andrew Jones To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: pbonzini@redhat.com, thuth@redhat.com, atishp@rivosinc.com, cade.richard@berkeley.edu, jamestiotio@gmail.com Subject: [kvm-unit-tests PATCH 3/3] riscv: Extend gitlab CI Date: Thu, 8 Aug 2024 15:02:33 +0200 Message-ID: <20240808130229.47415-8-andrew.jones@linux.dev> In-Reply-To: <20240808130229.47415-5-andrew.jones@linux.dev> References: <20240808130229.47415-5-andrew.jones@linux.dev> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Fedora's riscv64 gcc supports ilp32 so enable 32-bit RISCV testing. And use the out-of-tree template for the 32-bit build to get that covered too. Also add EFI build testing and, since Fedora has been updated which brings in a later QEMU, we can now use the 'max' cpu type. Signed-off-by: Andrew Jones --- .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e0eb85a94910..ffbed7c8d301 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -133,18 +133,42 @@ build-ppc64le: | tee results.txt - if grep -q FAIL results.txt ; then exit 1 ; fi -# build-riscv32: -# Fedora doesn't package a riscv32 compiler for QEMU. Oh, well. +build-riscv32: + extends: .outoftree_template + script: + - dnf install -y qemu-system-riscv gcc-riscv64-linux-gnu + - ./configure --arch=riscv32 --cross-prefix=riscv64-linux-gnu- + - make -j2 + - printf "FOO=foo\nBAR=bar\nBAZ=baz\nMVENDORID=0\nMARCHID=0\nMIMPID=0\n" >test-env + - ACCEL=tcg KVM_UNIT_TESTS_ENV=test-env ./run_tests.sh + selftest + sbi + | tee results.txt + - grep -q PASS results.txt && ! grep -q FAIL results.txt -# Select 'rv64' with PROCESSOR_OVERRIDE in case QEMU is too old to have 'max' build-riscv64: extends: .intree_template script: - dnf install -y qemu-system-riscv gcc-riscv64-linux-gnu - ./configure --arch=riscv64 --cross-prefix=riscv64-linux-gnu- - make -j2 - - printf "FOO=foo\nBAR=bar\nBAZ=baz\nMVENDORID=0\n" >test-env - - PROCESSOR_OVERRIDE=rv64 ACCEL=tcg KVM_UNIT_TESTS_ENV=test-env ./run_tests.sh + - printf "FOO=foo\nBAR=bar\nBAZ=baz\nMVENDORID=0\nMARCHID=0\nMIMPID=0\n" >test-env + - ACCEL=tcg KVM_UNIT_TESTS_ENV=test-env ./run_tests.sh + selftest + sbi + | tee results.txt + - grep -q PASS results.txt && ! grep -q FAIL results.txt + +build-riscv64-efi: + extends: .intree_template + script: + - dnf install -y edk2-riscv64 qemu-system-riscv gcc-riscv64-linux-gnu + - cp /usr/share/edk2/riscv/RISCV_VIRT_CODE.fd . + - truncate -s 32M RISCV_VIRT_CODE.fd + - ./configure --arch=riscv64 --cross-prefix=riscv64-linux-gnu- --enable-efi + - make -j2 + - printf "FOO=foo\nBAR=bar\nBAZ=baz\nMVENDORID=0\nMARCHID=0\nMIMPID=0\n" >test-env + - ACCEL=tcg KVM_UNIT_TESTS_ENV=test-env ./run_tests.sh selftest sbi | tee results.txt