Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp523607rwb; Fri, 13 Jan 2023 00:24:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXs12J3yLTsjc1g3qS+4Q8t5svIwR6mKA/PKt/y+TSetABCWQfcZ4etTyYEsI8GZSsoAh7Xn X-Received: by 2002:a05:6a20:b044:b0:ad:dee3:302 with SMTP id dx4-20020a056a20b04400b000addee30302mr76688503pzb.56.1673598268522; Fri, 13 Jan 2023 00:24:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673598268; cv=none; d=google.com; s=arc-20160816; b=T4ODVAzRtm2FY7u0+vtUFOyPlTMxRX2CR2kX1YZQ+IUwbXx42KP2HO2dqc9Iv50Ibr r+sYUfskUhAg7HD3n3MabxPCmD8jnc5GDMev5/GygeZbU//+3sjnG10TAVMsr+In7cbA baHP3EfZ2n0vOzRKXdrxMogT1J4RuQf57lpuu4ti8lAW3se80VSBsqzrosw25kFbC6Fe yFl+FR+pdp0x6xVGir7CoKmxHYSkV+9J47IZVP3QMHD5aHIsAeEWrHvYCLbqh7kr4LyU 6GK3qE5CkjOvhYxv1uLyc3bRvwPPg3rzYnuC99+2gtqd1C/KXHJmdLP7nU3X3p84pcEm Na/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nsdFs6pzrliWUStfNOl1FM9T1mI6Xi1uicxIBR+DHR0=; b=tk0uUX23lFvTzJJkEMSL4f342V5jMfRyDAG6BhOXwM8NgjXD1Q8lHcMnMY34rleaPp fCJmOO/9JNOj6AmD7o/51kSxbb4V2mXfLevhZUJl6TJ/g4qgNPWoYQlJyAnOGWrfNLDt paq3iu+1W/HW6NgrQYITmgVZC1myC4StgjroDychd+yFIJcNrPuMiqpsSkYCL8gEhhyL mnv6TiHqUDGrAMAvDjkaGsP6cvj/QvYgyhvl7HbGE/JzRA08cg+18LunUYUOQVFLxKiG 9RtpI8TA1A63fX34LAXsyVLVtlWZi1XNuDouzQPh+p1R3w4QT15liRoTOhs7PwJw7ejO n6sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=bxg1JS8f; 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 u129-20020a637987000000b00499413885dfsi20815150pgc.291.2023.01.13.00.24.22; Fri, 13 Jan 2023 00:24:28 -0800 (PST) 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=@ventanamicro.com header.s=google header.b=bxg1JS8f; 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 S240323AbjAMHmk (ORCPT + 50 others); Fri, 13 Jan 2023 02:42:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236408AbjAMHmI (ORCPT ); Fri, 13 Jan 2023 02:42:08 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9E241B9E6 for ; Thu, 12 Jan 2023 23:42:06 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id j16so30039825edw.11 for ; Thu, 12 Jan 2023 23:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=nsdFs6pzrliWUStfNOl1FM9T1mI6Xi1uicxIBR+DHR0=; b=bxg1JS8fp+9+/+7/09+z6yzY2UJpMRs52IaTtZs4uChAsUtbFr3/5xjnZ2k8aPLFrI EC7tEE24pKzHsigOYR9z4BFbxC3/iEJXOK4WREzE3Z5Tcyny0ZpGcnLUIEMwUotRlpcw lZM6FwML+lEJGVYZbFzIBaHIBU3qh2tCXZauGMuuEutvJfiZlhEMsdpTJct0SRkdCtng sarYsRN7TiRqDEFGwgYGG3cYJ9RZYwCGxxBJASK4jBlhtMTWrFsmRl8cyIlCAj3WdBJj Lav4o1Cr+KDqYPabyg43TRivHDBRAqpf8rmkN2uM/3MbrhNm/ZyVGTnJiuNAXW6Dlo1s exyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nsdFs6pzrliWUStfNOl1FM9T1mI6Xi1uicxIBR+DHR0=; b=qpTJ6k9qky9RJCe0MVRDoa8M79rEnrpVhZzm0QnafGg0zhT4RFYXMFMCmYaSA5RcJD RIZfV4C2+h816wr0a2vHjbXSZrDPdeVG7PaXlCfjzdfxJIAks6yRjUVhFiFxruen2Kqf IZS0/cHySA94pwDjFZEEpMgHEfuAjxHA+s2BjGpqVPoq4fnUvKLsn9J1m20trbQS4dnm 4x0AW94UhLLJEiGrX7/YDMOgybuDSKXKbK7ibHRPhmj4UIMl4EPvsz97TAAflAacqOvJ bdpeTmh96EgYeVdfSDT+D9V0CxkvPKFQP1E3TBh+b3dfdiTwSmvwLtvDgRZAB7FKOAmm Sxnw== X-Gm-Message-State: AFqh2kpLREvR5YBet39Eno2FfynJ9GYxR5m114RXfqaN8TlmTo2045ex RRCnT7phctthduv3PbLrX8E1LA== X-Received: by 2002:aa7:c393:0:b0:499:b604:4de6 with SMTP id k19-20020aa7c393000000b00499b6044de6mr14363452edq.25.1673595725444; Thu, 12 Jan 2023 23:42:05 -0800 (PST) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id l15-20020aa7c3cf000000b00467481df198sm7904083edr.48.2023.01.12.23.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 23:42:05 -0800 (PST) Date: Fri, 13 Jan 2023 08:42:04 +0100 From: Andrew Jones To: Atish Kumar Patra Cc: linux-kernel@vger.kernel.org, Anup Patel , Atish Patra , Guo Ren , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Sergey Matyukevich , Eric Lin , Will Deacon Subject: Re: [PATCH v2 04/11] RISC-V: KVM: Modify SBI extension handler to return SBI error code Message-ID: <20230113074204.p3wmeer2o3penunt@orel> References: <20221215170046.2010255-1-atishp@rivosinc.com> <20221215170046.2010255-5-atishp@rivosinc.com> <20230112110444.jjbmgslr6dspxwbh@orel> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 On Thu, Jan 12, 2023 at 10:47:13AM -0800, Atish Kumar Patra wrote: > On Thu, Jan 12, 2023 at 3:04 AM Andrew Jones wrote: > > > > On Thu, Dec 15, 2022 at 09:00:39AM -0800, Atish Patra wrote: ... > > > + * and forwards the error to the userspace. > > > + */ > > > + if (ret < 0) { > > > + next_sepc = false; > > > + goto ecall_done; > > > + } > > > > Shouldn't this ret < 0 check go above the "Handle special error cases..." > > block? > > > > Why ? I thought if an extension handler has both utrap updated and > returns an error, > user space redirection should take precedence. Let me know if it is wrong. My thinking was that utrap cannot be trusted if the handler returned an error. The handler may not even have had a chance to set it before hitting the error condition. IOW, we should check 'ret' right after the handler call. If it's < 0, then from the caller's perspective the handler didn't execute due to a KVM failure and it should be reported to userspace. Thanks, drew