From patchwork Tue Apr 16 18:44:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13632350 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87931C4345F for ; Tue, 16 Apr 2024 18:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Nz9HhLzBk2E6QIlsa1K+VgksQHzPZVq4QqQq/zmTnVE=; b=jf9tMO+wU51f5t wnyC5d2PW7PaWD1uEtkO0It3iH2+3a8uLYNE4TvzOszl6fMzqJAG0cgJzM9fBzgrQbmZyll3nqQnV ss7qj15tEW0Nd/FPBpJbgox13LYIgYDBDxDezCRvFB2Q9XIB7Tm/ZyQzggw5fQBkHXNb8RgXGuogR MMRiIslj5IL6qgzF2lGBr7xbrWYywubLX+hA7mgNWvuMTTKrl/2pvWNUw4KMlhC2zNc6PkD2+N7Ow y1mdN7G5yZ15SHEfyi9HF5CScwV1muJAeSzhRIog8WLDOSVZyfaJydLIW8HlJx0qMeBHsG2auBbBB /VpMBfS8+6+zyI0SAdXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwnos-0000000DNLz-2Smt; Tue, 16 Apr 2024 18:46:14 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwnnr-0000000DMX8-0nVR for linux-riscv@bombadil.infradead.org; Tue, 16 Apr 2024 18:45:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=BPwZXE2XSKrr96afFvE5Ak7Tq3sKjSlK1s+9Ond0wds=; b=GlmBe0bbFaSYgtXR00pR2qy/y+ QDXzd7krMePd7bqXzo9hhkKTCfgBNScLHQUGb9oA3e1iorGXUy+9Nw07KImYccHRYZvu3otP0uC8t o3rl1onZfTA5tuZbu5LqqKO8lyNyHqxhMGK5DJgwYcqSjIQDV/oB5ptQ7BEf36DAlJWjFq+tp811F 0/VZAisyUxtQPltlfxTpGfaCLO/K6rWu0/1mt11ple5JiW66TP0O/dvOvDSP9jKOUxum8TEWt8KVw bQdZU1M57UuQF19fu4kCVuNlbTtsxklj6tOGBHfyl4nutOqFrCu8FNf+RQmc3FroW/yywBPR6like 3pAJLa7Q==; Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwnnn-0000000BCKV-0Tu5 for linux-riscv@lists.infradead.org; Tue, 16 Apr 2024 18:45:09 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5cf2d73a183so27004a12.1 for ; Tue, 16 Apr 2024 11:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713293105; x=1713897905; darn=lists.infradead.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=WON60YUJgDUJX73DKL+veGSkmtoYqfr2+oap5e6DQhvGTymje8Xdn9A8NzSWHnSFwR BWfrvze+ZRxxquOMd1z0wpzceK83McuGVr0FOEPfg9IJetBVwiGxHcGmc3N9gpD1fRkG wWD3RFPScjSKpVk8CLat4DOzxvH4DFRbehwFGEQ9AbYEnZMxRJaOptLuzxF9/UHz9aTj lZZVB3nuxPH0n9hHzi7XrPrE5sICcdShqD81GOjW+mnQCIKEZzeCGCP03t0DTA623b+9 GrBitJJB1/qAerSSVIwBtMynJlEOjNKo8A9JuwBKV7gRPSQ9gLlb8TwEStKDLhvJJwkm WLwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713293105; x=1713897905; 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=LcBQd2lG1Xq+ObjDceCcx8462dGOfFx0NLB0DtPBHQnbgIIU9bPeQEx+7hbQPJBtm6 100dVEw84fRBGwWD/N3tSjFEwUMjo8BSwRTC78tjbP1xhnEMEeIsXOeTNdK9HxlFLda+ ClmdDAogFghdivZX2tNiVaFIcUp+3RiBwDhIfTD59EPHqHOgNIkZhJSWO01X4tbkRJSV nMK3xG4sJLAcyEALQ9sE2PkoklGVV3BZCbnRgcdLDo1Yx7f55/8UB97FY5bjKhtxGirW 7aCivKL4Bf79hyVC3CRF8VetjGfO2+PnxwQFzPpgeTX4axaAhnaaih7XlaR+KRrZobQi grwQ== X-Forwarded-Encrypted: i=1; AJvYcCVLtpYoprEoKCl6R6u4C0niuZ+BC8uWW9LLEPT/JyiMCTefnz1CSuWE6L/ei2ImBFL9EBDGoogCN7A3iEgoQgMEZ3lWf9NLEVk86LnQgvkS X-Gm-Message-State: AOJu0YzrCK3YxYC61CTZMUWW/qzJNnpx/WSfJBDwYtGSwgKt+yovitZ6 9/s7YVPZroQBcCpgIgfwxW52UXuHjpNcjttuu1YWBBM8cwjFY252wQd8Sl+8Z1MzGFHrn8UT9yf Z X-Google-Smtp-Source: AGHT+IH6JXsKkO3xbtfURi3HkE13t+2Zv4Xx/du238E0XQDh49Eof10sng+t6oktprn2xKoV8DG2yQ== X-Received: by 2002:a17:90a:f105:b0:2a7:8674:a0c8 with SMTP id cc5-20020a17090af10500b002a78674a0c8mr4586203pjb.1.1713293105488; Tue, 16 Apr 2024 11:45:05 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id o19-20020a17090aac1300b002a269828bb8sm8883645pjq.40.2024.04.16.11.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:45:05 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Anup Patel , 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 v7 17/24] KVM: riscv: selftests: Move sbi definitions to its own header file Date: Tue, 16 Apr 2024 11:44:14 -0700 Message-Id: <20240416184421.3693802-18-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416184421.3693802-1-atishp@rivosinc.com> References: <20240416184421.3693802-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240416_194507_878062_3563F27D X-CRM114-Status: GOOD ( 14.84 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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