Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp911324rwr; Wed, 19 Apr 2023 15:18:45 -0700 (PDT) X-Google-Smtp-Source: AKy350ZfdQvU/VaKH+RWz97Q5lkwMqY6V415LNjte4++rDipAnTbph+bcpH/yxc71uwkDtMiPGBc X-Received: by 2002:a05:6a20:e617:b0:ef:ef0a:f92a with SMTP id my23-20020a056a20e61700b000efef0af92amr66232pzb.25.1681942725386; Wed, 19 Apr 2023 15:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681942725; cv=none; d=google.com; s=arc-20160816; b=qmoK/fs2N7WjJMZGYaxJx8lrrXExxMZocCpvDRJnlYxPyiM7nx+Y39ysgXNJkZ3h8l unAYBs5m+WtTWj2AArEYBf4DczSjOStb+92sfr4FydRBIJzTOEf1fAKp9yrqbdwGK1/h Ba60Ps7TtW7TxaP6mo1m2BMTmP8VDTJfoZ2r4ez6eqNXHXGjiXf73eFHTkvDzN2zDDna 0eI3ahvlVnQsGxugux86Af+PBnJ61tzoxaneLseXU05WleWvG7k+5ThS4QB4RjD1uiGD JHhrs7CelgantEoQcVoIiDlN8Gmw5zAFobV+3rIPngrbEKeu2vEmFFRpAYV9hHm2vxYa A+5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TviUiXCC6v39lMS4rfPLGE9Pfx0aaxYAF0PLkJZJ+44=; b=ELf8wwlShJhHGsGU5qzcCmDaFjBhHMxfGiDG4qewDGQfySg1OfwtaNp8hwjz4/pDOI sd2/GG8ERtvL8qVOfKrXiJwtm1zMDn36gMiJpxj2ozYGFm+KimLIlbWeRKXIFGW1vqYJ mv7aRNAhJex6Y2gzDuyALpoRiR+n4X4Ytb3EnCSGAVw6U94fUb4NYBLe8MeRTle+X0JN nwsiyW1QHD6L5AR8NjLBwdG/g39i3stLGancqHCcOEqRdovGC+fAtpTVj5hDWyGYcu+b JqVix6DfXVNEDLt0Dpbj6grC1JPx9d0ga2mxWNTIFTB0ixlD2AQeaZLiVo9rfreRpid4 Upow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=fw3FXTdD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a17090a974300b00230ca3efcf3si1714pjw.158.2023.04.19.15.18.34; Wed, 19 Apr 2023 15:18:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=fw3FXTdD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbjDSWRl (ORCPT + 99 others); Wed, 19 Apr 2023 18:17:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbjDSWRf (ORCPT ); Wed, 19 Apr 2023 18:17:35 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2BF61721 for ; Wed, 19 Apr 2023 15:17:34 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1a92513abebso5352485ad.2 for ; Wed, 19 Apr 2023 15:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681942654; x=1684534654; 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=TviUiXCC6v39lMS4rfPLGE9Pfx0aaxYAF0PLkJZJ+44=; b=fw3FXTdDZVAQaqNcpqxhJ5jCbeJxZbbRCeUP7dUA0xboMzGhByaEInJPZwYw9bXQXk ARHWS0qP1pZrTXclentFqb6h5U2ua9sUZm6vZcXmwvDFczjrVihV2Nra1Jc2/WF5XyU2 0JadbkEFEI0//guHLR6qxF3JNYLlwaQIZD991cfubV5PenBiFCNtb6hgKaPgRSq66vCg e+VFqjLE6civs190GuIRI3K+ZsW+0KEkHzSOhGggkx8qfJ2wZO5KlkmScX+zwalNjqk6 RuMOo25mdsFietap8z25HKARP1geAiwoigenSaj60oBOp8w+6PxBWZ/NPdxHu1rx5LuB U5bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681942654; x=1684534654; 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=TviUiXCC6v39lMS4rfPLGE9Pfx0aaxYAF0PLkJZJ+44=; b=OtLynDOCQvumOYOMTSUbP8tljYRyEJw53eA9iwFn0CEwE/JrJeKo3wbkujwhHDQ6eT XbMBXAgDXpy4nO+M4mfRamP3t01wtKvJB14jfT2xlmGaDU9grJr0B94EZ11xc7ZO/b4m m2xOWKMR16hCxHjiWezRzFYweDUQj2pNCm+Y32lhRKCIYJ4FSxMQ8BjGI5mpnB35VSGl 93+f+fMHON55VSKfKgqK+J7QL1gm12gxAvsFNTmy5e3d71jiJ1yXNf6JsAn3YLccTZ/+ hJwLDjkWK1fM////9hVfi8GWRlSwVo4pPfMkeaywJjQLetkAXPl8azNzfZ+Nc4NlRxy/ 2JTQ== X-Gm-Message-State: AAQBX9dfMr9lST1O/iFKKguAiYKP6BdZ3gXrvuD8ArV4oyWLX35OZy/q NRbl8oGShqwM6Fvqiu7eRDhre5ft5XaEvjQ2elI= X-Received: by 2002:a17:902:e80a:b0:1a1:cc5a:b04 with SMTP id u10-20020a170902e80a00b001a1cc5a0b04mr8122719plg.3.1681942654045; Wed, 19 Apr 2023 15:17:34 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id jn11-20020a170903050b00b00196807b5189sm11619190plb.292.2023.04.19.15.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:17:33 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Christoph Hellwig , Conor Dooley , Greg Kroah-Hartman , Guo Ren , Heiko Stuebner , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Mayuresh Chitale , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC 02/48] RISC-V: KVM: Improve KVM error reporting to the user space Date: Wed, 19 Apr 2023 15:16:30 -0700 Message-Id: <20230419221716.3603068-3-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419221716.3603068-1-atishp@rivosinc.com> References: <20230419221716.3603068-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds RISC-V specific cause for ioctl run failure. For now, it will be used for the below two cases: 1. Insufficient IMSIC files if VM is configured to run in HWACCEL mode 2. TSM is unable to run run_vcpu SBI call for TVMs KVM also uses a custom scause bit(48) to distinguish this case from regular vcpu exit causes. Signed-off-by: Atish Patra --- arch/riscv/include/asm/csr.h | 2 ++ arch/riscv/include/uapi/asm/kvm.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 3176355..e78503a 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -96,6 +96,8 @@ #define EXC_VIRTUAL_INST_FAULT 22 #define EXC_STORE_GUEST_PAGE_FAULT 23 +#define EXC_CUSTOM_KVM_COVE_RUN_FAIL 48 + /* PMP configuration */ #define PMP_R 0x01 #define PMP_W 0x02 diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index b41d0e7..11440df 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -245,6 +245,10 @@ enum KVM_RISCV_SBI_EXT_ID { /* One single KVM irqchip, ie. the AIA */ #define KVM_NR_IRQCHIPS 1 +/* run->fail_entry.hardware_entry_failure_reason codes. */ +#define KVM_EXIT_FAIL_ENTRY_IMSIC_FILE_UNAVAILABLE (1ULL << 0) +#define KVM_EXIT_FAIL_ENTRY_COVE_RUN_VCPU (1ULL << 1) + #endif #endif /* __LINUX_KVM_RISCV_H */ -- 2.25.1