Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp96487lqg; Wed, 10 Apr 2024 17:14:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVnZ1tNOZPGny0BGo/boKc/V933B3aBLndvNOHFB1FYOsHE4MSUupbhHsXgdRl5g9W0AYrLHi3iNFfPoAarkaiYgYR0yPYNuXAIEzUweg== X-Google-Smtp-Source: AGHT+IHYBZyJvo24ELrvPrnDyEoArFOhQKSwz206AiySrE1d2RZPWx97gW51ZTCX0jZMv0s1vohm X-Received: by 2002:a17:906:24d2:b0:a51:dfaf:1176 with SMTP id f18-20020a17090624d200b00a51dfaf1176mr2561598ejb.6.1712794459548; Wed, 10 Apr 2024 17:14:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712794459; cv=pass; d=google.com; s=arc-20160816; b=EL130uSdSepa15dU1TWNvEKTGXGIPmancYSv6oFX4CIaecblxaLwTxiAPbBPG/y+kT V6Sx+/3Ss0WVFKidgq67DD4Drq2VDFq59Pi51YVazX9W68BzzwyDbabP5tR8DfUioKGz HBNTm2HNxYQvjl2tjJL3C0eVX+08DE9zfbal06xDfc3lsN/FRcwWyD+e8DUkxLttkpNI VVLMntsfcVAwJpsGikDUWDc2a4IGkfbOC4WSeKwnEOMg+gQ6bVulwFZJmKCNOjGC5QI1 2XN6gMFOPSEqVf/d0CE7KunwThj8ZmCqctkWnc0t4OxGv4GbzR31TbPGAmAJ8SGQpTt/ 229Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BPwZXE2XSKrr96afFvE5Ak7Tq3sKjSlK1s+9Ond0wds=; fh=TV5tejk3Dt07dcNlLLEipj9Q2R7EhRc35yPyoZNpTh8=; b=urAe+HkAS0YJ3VAFRu9tNzcRK2cDxYTY/5DbP90o8CVtK0AgGdKSueJ613BpNyUe+M ZswKOBVwnnbmyCn/d7Zis2b6Ya8k+JKMC79sdjfK8zesVyFqF7jRqCiMxd5YKiBa4QIo oVha/hULSRv71ISd/aHTCQ2EIwBKyMCUF5Gi/1J88qRI/ZB/VuvRcB4TBQ4AnyaDNuEu 6/BthjG+qetM0M0cFtI4fF/Lnm73gHTPUoH0uUbC0kABG8yFD1ILy/XAwo2B8O6l/DoK 7GNl/10VmTVWdO9ubjG/QOFxcpykAX6RYeR50QSFONeYoU8aKI72iderKA87Kp+8BB5P S8nQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=T52YTDwN; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-139572-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139572-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qk30-20020a1709077f9e00b00a4e256a82ccsi165497ejc.232.2024.04.10.17.14.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 17:14:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139572-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=T52YTDwN; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-139572-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139572-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 223DC1F246F9 for ; Thu, 11 Apr 2024 00:14:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29D4D40BE1; Thu, 11 Apr 2024 00:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="T52YTDwN" Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 544603E47A for ; Thu, 11 Apr 2024 00:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712794137; cv=none; b=fB3/ODUcNQ55tAvD0wB8Uqsuc6QflUCspEvf3iSP1aOn5XjRtARRQKK6n/cwWvddR7oC9K1Nb25l4WRluFfkLoHIpxJ/Imfov2MdWWa1SYMcULC/4LCG0HmZN0AGif6/piES1FTHps9cTnYoh/2PmJaFsnIhjwMtCFXD+M6hpfg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712794137; c=relaxed/simple; bh=UaK2BRG2cCYtJekJX1v+X6A/okSCrPqUNYx/jYqyhvE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oL3L+kBI7Q6ogYKh4m/+9pKnpXfd5ZKCcBxTWaD9IvT169H2YKbd+tWS2140Gf68COrw9XfKV/uXNDFQVHznQCNZuz+oLiGgqoDmmDGGhDArR/NDIZZg3ZMVdUF/FatB4iBC350JPxl8OMTJQYLjkdJ65TwOfi9a7j0QlwDP0/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=T52YTDwN; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1e2b1cd446fso53934475ad.3 for ; Wed, 10 Apr 2024 17:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712794134; x=1713398934; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BPwZXE2XSKrr96afFvE5Ak7Tq3sKjSlK1s+9Ond0wds=; b=T52YTDwNbpRrOtUPwZFt77fxueemsGzrN7k63xqN4fyIvW0suujG0vPIoFjzPV+s63 iCoggZ/jG08Rwv+pQj2ehhUgv7WYp0TO2OyamRQP62FCGuIDpfoh9/Nn7nmwXiH3Ej+u mSLMcF0w63ki4Fv1X93mQ4FqXxswaqlSnmPLFVz3eM4lKZBldZoxFUd2wuy+DR3z+mjB 9e5I2G4qRtYaaRPeAzM07qhiCLqQT45U+PEmlcDTWPbSm4EQYsl8GRr5kyVtdWq7hQ9s eAMQABxbYHdqVZNQJEdq2AOT2lxR8HAByuhSLBwn0Vbr0abtXDthoKY2+32IYNU02P8r EnzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712794134; x=1713398934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BPwZXE2XSKrr96afFvE5Ak7Tq3sKjSlK1s+9Ond0wds=; b=gyvKPa0IVd1XCqeZC7O/GJzri1Sv8CX2mZuU+LUxIZ64Mp4nn7gXge4T9ot4fos5zR q19SPW3yiY8MjZaSBCLXmWZ9QACq9/ibCVFw8bOxu6aPxnsejgDwoCQZOHGLfTTJ8ArI e6ql3gRba8/rQYECxUyQor0WOMWOFD7WoKrSYDwD+n48loKIjOCqG0n4JSHHf6YOZp+E zzfykGzMvuS1w7yOV30C0JNEHVKk3dP1zoWrKIErwuX5eP0HM94Ly4Ad0TQXx5fvDsxx SJmx+PTLHT2pOw2Fm+daD639GwcP6ibzt5S4vdhV/Umm8+rD+e6bQx7nj8gE6kgWTYKT Fi5g== X-Gm-Message-State: AOJu0YziKncKSvEdR2bjMu6ElO4vNGFQQNIRIp08fmS7/JnuGuFYBRJF hLJHOasVZt446Bz6uK/3YZ3+BHu5WTMt8dd/ICyaLQEPCyJGAB92/7DZPchUVwe/8hI3KskZIqO Q X-Received: by 2002:a17:902:c94d:b0:1e2:6152:3439 with SMTP id i13-20020a170902c94d00b001e261523439mr4102847pla.6.1712794133940; Wed, 10 Apr 2024 17:08:53 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id f7-20020a170902684700b001e3d8a70780sm130351pln.171.2024.04.10.17.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 17:08:53 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Alexey Makhalov , Anup Patel , Atish Patra , Broadcom internal kernel review list , Conor Dooley , Juergen Gross , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Shuah Khan , virtualization@lists.linux.dev, Will Deacon , x86@kernel.org Subject: [PATCH v6 17/24] KVM: riscv: selftests: Move sbi definitions to its own header file Date: Wed, 10 Apr 2024 17:07:45 -0700 Message-Id: <20240411000752.955910-18-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411000752.955910-1-atishp@rivosinc.com> References: <20240411000752.955910-1-atishp@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The SBI definitions will continue to grow. Move the sbi related definitions to its own header file from processor.h Suggested-by: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- .../selftests/kvm/include/riscv/processor.h | 39 --------------- .../testing/selftests/kvm/include/riscv/sbi.h | 50 +++++++++++++++++++ .../selftests/kvm/include/riscv/ucall.h | 1 + tools/testing/selftests/kvm/steal_time.c | 4 +- 4 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/riscv/sbi.h diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h index ce473fe251dd..3b9cb39327ff 100644 --- a/tools/testing/selftests/kvm/include/riscv/processor.h +++ b/tools/testing/selftests/kvm/include/riscv/processor.h @@ -154,45 +154,6 @@ void vm_install_interrupt_handler(struct kvm_vm *vm, exception_handler_fn handle #define PGTBL_PAGE_SIZE PGTBL_L0_BLOCK_SIZE #define PGTBL_PAGE_SIZE_SHIFT PGTBL_L0_BLOCK_SHIFT -/* SBI return error codes */ -#define SBI_SUCCESS 0 -#define SBI_ERR_FAILURE -1 -#define SBI_ERR_NOT_SUPPORTED -2 -#define SBI_ERR_INVALID_PARAM -3 -#define SBI_ERR_DENIED -4 -#define SBI_ERR_INVALID_ADDRESS -5 -#define SBI_ERR_ALREADY_AVAILABLE -6 -#define SBI_ERR_ALREADY_STARTED -7 -#define SBI_ERR_ALREADY_STOPPED -8 - -#define SBI_EXT_EXPERIMENTAL_START 0x08000000 -#define SBI_EXT_EXPERIMENTAL_END 0x08FFFFFF - -#define KVM_RISCV_SELFTESTS_SBI_EXT SBI_EXT_EXPERIMENTAL_END -#define KVM_RISCV_SELFTESTS_SBI_UCALL 0 -#define KVM_RISCV_SELFTESTS_SBI_UNEXP 1 - -enum sbi_ext_id { - SBI_EXT_BASE = 0x10, - SBI_EXT_STA = 0x535441, -}; - -enum sbi_ext_base_fid { - SBI_EXT_BASE_PROBE_EXT = 3, -}; - -struct sbiret { - long error; - long value; -}; - -struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, - unsigned long arg1, unsigned long arg2, - unsigned long arg3, unsigned long arg4, - unsigned long arg5); - -bool guest_sbi_probe_extension(int extid, long *out_val); - static inline void local_irq_enable(void) { csr_set(CSR_SSTATUS, SR_SIE); diff --git a/tools/testing/selftests/kvm/include/riscv/sbi.h b/tools/testing/selftests/kvm/include/riscv/sbi.h new file mode 100644 index 000000000000..ba04f2dec7b5 --- /dev/null +++ b/tools/testing/selftests/kvm/include/riscv/sbi.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * RISC-V SBI specific definitions + * + * Copyright (C) 2024 Rivos Inc. + */ + +#ifndef SELFTEST_KVM_SBI_H +#define SELFTEST_KVM_SBI_H + +/* SBI return error codes */ +#define SBI_SUCCESS 0 +#define SBI_ERR_FAILURE -1 +#define SBI_ERR_NOT_SUPPORTED -2 +#define SBI_ERR_INVALID_PARAM -3 +#define SBI_ERR_DENIED -4 +#define SBI_ERR_INVALID_ADDRESS -5 +#define SBI_ERR_ALREADY_AVAILABLE -6 +#define SBI_ERR_ALREADY_STARTED -7 +#define SBI_ERR_ALREADY_STOPPED -8 + +#define SBI_EXT_EXPERIMENTAL_START 0x08000000 +#define SBI_EXT_EXPERIMENTAL_END 0x08FFFFFF + +#define KVM_RISCV_SELFTESTS_SBI_EXT SBI_EXT_EXPERIMENTAL_END +#define KVM_RISCV_SELFTESTS_SBI_UCALL 0 +#define KVM_RISCV_SELFTESTS_SBI_UNEXP 1 + +enum sbi_ext_id { + SBI_EXT_BASE = 0x10, + SBI_EXT_STA = 0x535441, +}; + +enum sbi_ext_base_fid { + SBI_EXT_BASE_PROBE_EXT = 3, +}; + +struct sbiret { + long error; + long value; +}; + +struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5); + +bool guest_sbi_probe_extension(int extid, long *out_val); + +#endif /* SELFTEST_KVM_SBI_H */ diff --git a/tools/testing/selftests/kvm/include/riscv/ucall.h b/tools/testing/selftests/kvm/include/riscv/ucall.h index be46eb32ec27..a695ae36f3e0 100644 --- a/tools/testing/selftests/kvm/include/riscv/ucall.h +++ b/tools/testing/selftests/kvm/include/riscv/ucall.h @@ -3,6 +3,7 @@ #define SELFTEST_KVM_UCALL_H #include "processor.h" +#include "sbi.h" #define UCALL_EXIT_REASON KVM_EXIT_RISCV_SBI diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c index bae0c5026f82..2ff82c7fd926 100644 --- a/tools/testing/selftests/kvm/steal_time.c +++ b/tools/testing/selftests/kvm/steal_time.c @@ -11,7 +11,9 @@ #include #include #include -#ifndef __riscv +#ifdef __riscv +#include "sbi.h" +#else #include #endif -- 2.34.1