Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp963897lqt; Fri, 19 Apr 2024 16:53:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZLvJheCC1ieFn0RucA93wwsVtAPo/yNvE8GScdWhi1hyOhbyltNSjc6w8lPB9EPmAGvI14blwP4kiQAhx4Ke7u6sV1FzFSH0/C1/Klw== X-Google-Smtp-Source: AGHT+IEDEBHkhONRvMNKce2K6SK0CMWf+q8GxMfNy+dRNF+1OA7dV2KTUiCfGBpu1LgZ4hyU/VxY X-Received: by 2002:a17:902:cf0b:b0:1dd:76f0:3dde with SMTP id i11-20020a170902cf0b00b001dd76f03ddemr4015244plg.31.1713570799380; Fri, 19 Apr 2024 16:53:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713570799; cv=pass; d=google.com; s=arc-20160816; b=ubnwGPVrXIwGGwHaDE2SCTu2jxA8hIqWGDS+oLTk1YTqWVfhgfGiYB75iXcdBbDbGJ 1isPzB6Ajw4uUYuZld7YJSzhBplbt6Xk/1sCT9e6cmYIjguwJSBAt4CcWiE08DELruy4 mOF4RQqgJCd16qM0G7nE7gf2BrR1JUYCtWVePAE6tImLNS8UR1LLT9c0EhkUzPYaf2eg aj555/AqZKt0u1ZwaqDzW+NUUqkhc0OMzbmy/05WLeh9DApwKxJmeXclvSpV3tDOR+jL 3Q93RfN/7c7HQKwlMztmfH/6IG5xgAHxLM1mOOId4jYSLH0dYd23qMS3vPAQEun3BHTl N/uw== 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=z7fJWkZ4T7GjqwnZHLiFaBRNsKIE6v81MvuCrwEofW0=; b=GNQ49cC2koCg8VZT6sOQj7HlvAJnem8p9a10oyB4RrfjJmaU9WspwPIzn8mO66p4I1 UeZ6PHFluAPppJJpNUbBm5Do4F6yW0giQMVvTlf0lymS8sbaHiDi9fLP4aM1NNT5pKXK eU2F9F9MsVMjvDfLJLjEUAp/4Wec5ciIauVaXj0xf7bbY6pp2I3r5P/LB7x9vtUws5PQ oFmrUpaKd6HmtYwE26hpwXTdRdabOHg2Y+kXiQORZrrUcEHnKPSMApNrg3emunwDUuFK mmOzij9uCnbkFGdV3+NCS2F9GTm8OJwIKyJdUn/gTQjzkWxV9aavQl0Q+NC0i+Afp3sG Sa9Q==; 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=R1cP8Dpg; 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-152040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152040-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e2-20020a170902784200b001e9219222b3si279315pln.271.2024.04.19.16.53.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 16:53:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=R1cP8Dpg; 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-152040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152040-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AA798B2171A for ; Fri, 19 Apr 2024 23:53:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8880B14A4FC; Fri, 19 Apr 2024 23:48:19 +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="R1cP8Dpg" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 1D4BF14A090 for ; Fri, 19 Apr 2024 23:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713570498; cv=none; b=ipiq2rrstE9J6Uvyrm9yNAhFyFs/bnrRk+ypru4fMgL6AIfaJTHZZxxFfHxuEA5KN/zXdj5/r6N6XDZP5e2tGTrWpz542dIud58QRAWIBkjEjXMcEJDhOrFvki0lxMlLsf/ixFSf2GzmDN0YIWH20VnICPP+nLtV0dEns2tIs90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713570498; c=relaxed/simple; bh=UaK2BRG2cCYtJekJX1v+X6A/okSCrPqUNYx/jYqyhvE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YrGPeGhrX9DJoL5BqriOCcrVmOqaJtTQ3iVAV+Zzkgl7ngGYX9cxNE082S13o8p7A0cL3bX9XbFdtbFkwaQ3KzjJs9NjKxDbamBKQVoDBhruUSqD/ZjyNRH8YlKS71/PpNESZ9nO4KW2aYm6tcOFR8x9Lv7z4+Ybp0gZgfLYkuw= 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=R1cP8Dpg; arc=none smtp.client-ip=209.85.214.182 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-f182.google.com with SMTP id d9443c01a7336-1e5b6e8f662so21356475ad.0 for ; Fri, 19 Apr 2024 16:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713570496; x=1714175296; 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=R1cP8Dpgo597D/H83qoWU5TeX2vS/G3Xr4ZnAaD3m2136aEYd8SPaawMOqVAnjusmo tEln3rpyh9muW1iVXnChEBd4jyc8O1FM66nKPhCJW/ic4V3kVPHJwn1VYAW8yB/CYo8K 8pxfeI7jWihQ0sMWN7EZ7ppUN4Ip9jXO+YacstIUNTIljpx1/GK6SDXIY5wx2YPvhBbV /C8K+WrS3C9dmyhLT1zmUC088TgRk0N1y3tmnsfa2VKN7EEoKNWL1z9hLlyOkish/5y+ RcsQIfEo0MYYhgzgGDvWmFnxqmWxeKq3jOOMwS5T0t4GnzAbSzafFXdjwtKQRUqRPMAI y0aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713570496; x=1714175296; 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=wktgB4+JK+8aTQhjUH1chhaqZ1xF/cbpUFQPvC4DjnqLTrqje78hFbloff4Ysm2f9f ARbBvLDWKnMEE3+s+FhCMftKZZsIbmV27Has1UpMfd6/msoT6ckbRGO74cyZbTAOff/l l8QeT8IrDSog5dRrTI6hU3N6kDh0OiFwS9a2qPsNXy1XZnqYTQf5CgNJZp4WTUCCLqyb GI4GXQ4BCVQWuoJZXdVsLTorQ8terVd6yoiMYvaR8EsmRnoY+6F8VBSHwXg8NvvRGsC6 zsGxr3gGchHdF92dHNYuFbOTFol7mMQI8vDchitOex7xgPeYlPE/LQwH4/J4zu2AD7Y7 2+Pw== X-Gm-Message-State: AOJu0YxVSvuNSEKpFIFcAFuAgOZDR0QHf97V3lSSIC+8mfjEHbmX6/z9 xi9bP41R2130pxeUrjXa3AdK7nPycYM9aygHqYO8Eym9wcWuYIbj9ZndJg04AiRUjeA6bSwW0JO m X-Received: by 2002:a17:902:f605:b0:1dd:dde1:31dc with SMTP id n5-20020a170902f60500b001dddde131dcmr4970560plg.26.1713570495784; Fri, 19 Apr 2024 16:48:15 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id w17-20020a170902d11100b001e42f215f33sm3924017plw.85.2024.04.19.16.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 16:48:15 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Anup Patel , samuel.holland@sifive.com, 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 v8 17/24] KVM: riscv: selftests: Move sbi definitions to its own header file Date: Sat, 20 Apr 2024 08:17:33 -0700 Message-Id: <20240420151741.962500-18-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240420151741.962500-1-atishp@rivosinc.com> References: <20240420151741.962500-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