Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1553640pxb; Tue, 8 Feb 2022 22:05:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJySpmOYGASxtfAwQmh47uchsXMWt/OP0raCcu1ZMWftdH+dYQ3AZNzHk+VdNw3ZQ+iqA9aI X-Received: by 2002:a05:6a00:8cc:: with SMTP id s12mr626958pfu.45.1644386714976; Tue, 08 Feb 2022 22:05:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644386714; cv=none; d=google.com; s=arc-20160816; b=lQlp7EceEcHflx0QpkOXuBrlAR7o+vpu9VyoCjzxWcq8accl9o/k/0tzfbJfcmnqjp mbqLGve9J6enTd7sTh0XhImFoLpLUz9t/M1SAODuqXRxierMk9v8/ac/JvuF5dQqwBdB SmeFwzpEMxydhf0Ydo6YK/c/P+j/oCr6uzp2WTydR4iLCJiDna6a3FdG5jZ28Au8Yx8i egTsivPX4Frt8eSB80BCmN78wPHU7vH+e0ey5+TpjGQ2QR1h9AtSwuVboq3XT5Jmuujj 7xDxHDCLaejXs3P96j70EgXHPeUKV1UHWPjVanYH6YuPj01rt73J6w+VJZ+kbZsr0ze6 069w== 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 :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=t5FgH2YJXOPf/xxPjv6QRrKmo/4kA2ug0zb3e+u3Xao=; b=u6onYIrIxT5QCB+C0w39UAUfel3j/x/8PeoEry6DhtQHi4h5WrnXyPcpgL5EVBLph4 NUKO1iNs2qGczh05Xtq28FxqqylbpT/dcHAyDM17WqOTfwBAqBXTlrx09ZtDYGQdroFB 9YhSVPAHeMdpP+3nOpb4f8tn4eYnml/GWQ1ELXR392ndCyiW/KojscfR9AyjUX7OyLdn Z+a8dekL0bthw1ALg21psrlP6fmPEKlfVQ1K1eq/JW4pRQCPicCT4OD6EwnhELX7vHkx R1JENwNOs6YFVWD0l7lhUB4qlQb8ORi2MIMi+CyME8l3g4CKF0glx+oEIse3jMCfnkj3 j+Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=zIbTskgg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f3si13995822pgc.246.2022.02.08.22.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:05:14 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=zIbTskgg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7F1AEC00693D; Tue, 8 Feb 2022 21:53:22 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343623AbiBICoC (ORCPT + 99 others); Tue, 8 Feb 2022 21:44:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbiBIBNZ (ORCPT ); Tue, 8 Feb 2022 20:13:25 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1977EC061576 for ; Tue, 8 Feb 2022 17:13:24 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id d9-20020a17090a498900b001b8bb1d00e7so700532pjh.3 for ; Tue, 08 Feb 2022 17:13:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=t5FgH2YJXOPf/xxPjv6QRrKmo/4kA2ug0zb3e+u3Xao=; b=zIbTskggTwuJ8Cs4sq0rq+triPMJ73QwqJeAJl8rQPFbTgi9R6UFxKykUlvi2LoERU JfrHtLoOEo2RSK7qLDy3j0ClM1pKefSYA/drHmfx4QjoQzLJnW2Km/A5MIhKulJwl9Qv jhkGIKcGThJzb+5tYP9Iyh0pn5HgLF/ba+Q9AR8Q3k9b3cKxTwZbWZ9D4aKYsijihkOe lpZM1ZR+9/hhfA3fWhGbyfHdzF9Pi3vGiDrlGNkkacJ/7zITVO8irSIW3xVovn540T2p +QWlc3FWZdjDBSBgODptqPqPSjLdv3glClBxbuSCWJv0QMkMZrnl266Jo4je6sRoA4q1 igCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=t5FgH2YJXOPf/xxPjv6QRrKmo/4kA2ug0zb3e+u3Xao=; b=Mb83jUSj6gBUKiNHLIUCsfMwKSUdPgUNx1qa1GO3vYebGn+hcE3Ky34dM27gswQNgw YU8keKNyD+QwepQuObuDMNpUnQZa8HweIuCRI/UkxTFP4+RoHyLGEhOx3dRCqVa5AVBF dYXw6JziWGNFgGpebgGl296JJwx5sTTTEG8e8g9LdG/T6bIwp48fLZqm7VPbaSVxZ06i 8b0ae8Q4NRV4tbMjokOwcr978phqWvb7KJgvhNvTDPuYU3BiX/v+N++nZpFxzq9iigKg p6SgLPqUeVIglwzooBc5BfEa7VKYwsFynb8sViTKQ5UH4HTZmcIYtHo1hR6ncfI1aYrJ Z+hw== X-Gm-Message-State: AOAM533Ps7wFsEA2yGav0rtJBsqJbU4CTkrN57DkfjOjMAsrEkrjpP7D SbxLqfXs6e3eM9c6ZQ6yk5Zazw== X-Received: by 2002:a17:903:228c:: with SMTP id b12mr6801223plh.36.1644369203436; Tue, 08 Feb 2022 17:13:23 -0800 (PST) Received: from localhost ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id pg2sm4559295pjb.54.2022.02.08.17.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 17:13:22 -0800 (PST) Date: Tue, 08 Feb 2022 17:13:22 -0800 (PST) X-Google-Original-Date: Tue, 08 Feb 2022 17:12:33 PST (-0800) Subject: Re: [PATCH] riscv: extable: fix err reg writing in dedicated uaccess handler In-Reply-To: <20220123090417.630-1-jszhang@kernel.org> CC: Paul Walmsley , aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, mchitale@ventanamicro.com From: Palmer Dabbelt To: jszhang@kernel.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,SPF_HELO_PASS,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 On Sun, 23 Jan 2022 01:04:17 PST (-0800), jszhang@kernel.org wrote: > Mayuresh reported commit 20802d8d477d ("riscv: extable: add a dedicated > uaccess handler") breaks the writev02 test case in LTP. This is due to > the err reg isn't correctly set with the errno(-EFAULT in writev02 > case). First of all, the err and zero regs are reg numbers rather than > reg offsets in struct pt_regs; Secondly, regs_set_gpr() should write > the regs when offset isn't zero(zero means epc) > > Fix it by correcting regs_set_gpr() logic and passing the correct reg > offset to it. > > Reported-by: Mayuresh Chitale > Fixes: 20802d8d477d ("riscv: extable: add a dedicated uaccess handler") > Signed-off-by: Jisheng Zhang > --- > arch/riscv/mm/extable.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/riscv/mm/extable.c b/arch/riscv/mm/extable.c > index 05978f78579f..35484d830fd6 100644 > --- a/arch/riscv/mm/extable.c > +++ b/arch/riscv/mm/extable.c > @@ -33,7 +33,7 @@ static inline void regs_set_gpr(struct pt_regs *regs, unsigned int offset, > if (unlikely(offset > MAX_REG_OFFSET)) > return; > > - if (!offset) > + if (offset) > *(unsigned long *)((unsigned long)regs + offset) = val; > } > > @@ -43,8 +43,8 @@ static bool ex_handler_uaccess_err_zero(const struct exception_table_entry *ex, > int reg_err = FIELD_GET(EX_DATA_REG_ERR, ex->data); > int reg_zero = FIELD_GET(EX_DATA_REG_ZERO, ex->data); > > - regs_set_gpr(regs, reg_err, -EFAULT); > - regs_set_gpr(regs, reg_zero, 0); > + regs_set_gpr(regs, reg_err * sizeof(unsigned long), -EFAULT); > + regs_set_gpr(regs, reg_zero * sizeof(unsigned long), 0); > > regs->epc = get_ex_fixup(ex); > return true; Thanks, this is on fixes. I'm not sure if it's saner to have these be register numbers rather than offsets, but regs_get_register is this way so it's probably better to have them match.