From patchwork Tue Jul 20 08:50:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akira Tsukamoto X-Patchwork-Id: 12387803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA7F1C07E95 for ; Tue, 20 Jul 2021 08:51:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 74CE661209 for ; Tue, 20 Jul 2021 08:51:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74CE661209 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=FftgNMbAZlOqfRsP097EYuCIUUi8Yj5XBit7e6354+w=; b=A3QnzYOWl+JrrF0maIvm/eMLZE A8bCcNNLPg4trQdECU/n5R7vGUUKst4pPBgjGy97lzWzRfblNNbQzQo/CukC5k8oYYTWovhfo3sKX lNXrVUk8Z7uLvffSuUGrAqwsGoOZzAgpfHay6Oi+m2R2jipPdo3/K3uwnYtThH/oswUGbGRm3pPBy no3c314Fw82WVnGRk39XjuYPzhGz69NuL3wTpLe8vDURBSWcddGKXCsRwyA3YkM4yo4rV3H2GIm7Y KAf/O1TcZJAJkZDudE/8RtToKQqxWkdngqdG6UC1X0nwyhHJPj9r1cEISVsoysCvsjiH3tLw/6s+f OxOjhAgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lSw-00CHby-TN; Tue, 20 Jul 2021 08:51:02 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lSu-00CHax-2O for linux-riscv@lists.infradead.org; Tue, 20 Jul 2021 08:51:01 +0000 Received: by mail-pg1-x529.google.com with SMTP id a6so14571459pgw.3 for ; Tue, 20 Jul 2021 01:50:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=hyHfreQCGU1n08jflxUm3GD5Es1OvyJ8VlqC19lqeQY=; b=FbegROJ90Iif54xm+O2OALn405pyfAJ8145JLRjkETF6hKetoYcN0nnEQ5/AjABZWW 6rZp7tgx2uBFBfBMrmRllXU0Igs7FKFLMVgxFexiOUiEs9sz3WKjb27K+zfbwjdMw4rI kxKq92ERO02d7NXieZ6mDNNe514vyrET7Ju2BJX6rn4v1tsIXVmmB5bA16d0Nzg8ivYQ 4ijlXfz7a7lIuyF8spDdmsM5QHnnmUm17Rref03RXj6Yopo38nW+pqJdZSBgzyjXK1fH O2ut3/96E27HBd4yokYh/917EnXg4GgTG/41FlbesLf+GrLDmLjZV35mSXMpxajqmFFm RsNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hyHfreQCGU1n08jflxUm3GD5Es1OvyJ8VlqC19lqeQY=; b=VLsUFho48ye23DgMnv/WmOf+KwBwNt+iz1/K51kshsek8lztGnxQLgxnyPcaQGVSYS 5EWkaChgflJP0vGVIn5YBxwEts6yOaJ7D4JC98s1/SxOdxF9M6lHKd5LAuOMimAhFBi9 L+i9LVfIDXb3VItxsSC0d/1iuycn86R4uZ25YMRfQQnKzpaESe3czPp8jtiOrNnfYMOv JXFBkqpxFHG7jSZYzyjVTcqob+ApJ+NmtaKjKXbVFbAztd46mScw96Y5m0V1GqoFjz5g hggjVQrgjn2VxD+8SaSh1I4uYa8LrZ4spu8eCxQ1KA+rrDBmkZZB1f2hGLQ2MRn1qnV8 99CA== X-Gm-Message-State: AOAM530cbqQ3gYU44nYbgUtpAB00beamaZCkKxTLFuKhHY6H73GG/5Oe JFn61TENbdG4GBh7DUyZXqk= X-Google-Smtp-Source: ABdhPJxq5NwFbLCn786YXAAZfvZ5Y0RKQPaxTlLcGvNw8E60U5x7oPuMNvXy8Z9gVpdSlWVx0bVXHw== X-Received: by 2002:a65:5284:: with SMTP id y4mr10889779pgp.19.1626771058139; Tue, 20 Jul 2021 01:50:58 -0700 (PDT) Received: from [192.168.1.153] (M106072041033.v4.enabler.ne.jp. [106.72.41.33]) by smtp.gmail.com with ESMTPSA id n5sm22829381pfv.29.2021.07.20.01.50.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Jul 2021 01:50:57 -0700 (PDT) Subject: [PATCH 1/4] riscv: __asm_copy_to-from_user: Fix: overrun copy To: Paul Walmsley , Palmer Dabbelt , Guenter Roeck , Geert Uytterhoeven , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <37097718-c472-025a-2058-55667badc5b9@gmail.com> From: Akira Tsukamoto Message-ID: <415f9adf-8dd6-2467-8e74-0ed9d5cdfed9@gmail.com> Date: Tue, 20 Jul 2021 17:50:52 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <37097718-c472-025a-2058-55667badc5b9@gmail.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_015100_164337_B5B337C6 X-CRM114-Status: GOOD ( 10.91 ) 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 There were two causes for the overrun memory access. The threshold size was too small. The aligning dst require one SZREG and unrolling word copy requires 8*SZREG, total have to be at least 9*SZREG. Inside the unrolling copy, the subtracting -(8*SZREG-1) would make iteration happening one extra loop. Proper value is -(8*SZREG). Signed-off-by: Akira Tsukamoto --- arch/riscv/lib/uaccess.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S index bceb0629e440..8bbeca89a93f 100644 --- a/arch/riscv/lib/uaccess.S +++ b/arch/riscv/lib/uaccess.S @@ -35,7 +35,7 @@ ENTRY(__asm_copy_from_user) /* * Use byte copy only if too small. */ - li a3, 8*SZREG /* size must be larger than size in word_copy */ + li a3, 9*SZREG /* size must be larger than size in word_copy */ bltu a2, a3, .Lbyte_copy_tail /* @@ -75,7 +75,7 @@ ENTRY(__asm_copy_from_user) * a3 - a1 & mask:(SZREG-1) * t0 - end of aligned dst */ - addi t0, t0, -(8*SZREG-1) /* not to over run */ + addi t0, t0, -(8*SZREG) /* not to over run */ 2: fixup REG_L a4, 0(a1), 10f fixup REG_L a5, SZREG(a1), 10f @@ -97,7 +97,7 @@ ENTRY(__asm_copy_from_user) addi a1, a1, 8*SZREG bltu a0, t0, 2b - addi t0, t0, 8*SZREG-1 /* revert to original value */ + addi t0, t0, 8*SZREG /* revert to original value */ j .Lbyte_copy_tail .Lshift_copy: From patchwork Tue Jul 20 08:51:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akira Tsukamoto X-Patchwork-Id: 12387805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B6BFC636C8 for ; Tue, 20 Jul 2021 08:52:09 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6A6D461209 for ; Tue, 20 Jul 2021 08:52:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A6D461209 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3/ifXeJOSEKpXjyWUuoEahW7SW8zLtwtPSdRzwli84A=; b=lBsWipBkllJIuMvlTaw7i+nabH pRJoqCdQq0qVtWDQ8d2RBB8DLJiojUEtMFDLhmm7JV3HHHnwg7kmvHRf0du9kn8k4/sEpFaZz5vOy u7OKbXBbYGsya2C7fjYAYwJAICechIVcZFhOGLJrm4Jzg6g5UpxgpFwOK5ZHXcPDL/1+JBNyjF7lA /xu8nsyPEe8RJBwut4y+1p9rDbprj4xIOL5ere3XxTKyLYxFm7Qt8P8RM5eDe56un7Q3Aljf99oMS zYK6Ky0XFWY0MUpJywi8BMn1XWD+htB91ZmwxYRQCFGM6W9hghLkDhNdxE2JAOx0XQZdLzCdsHyrf x6Wt3y0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lTm-00CHmh-O7; Tue, 20 Jul 2021 08:51:54 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lTj-00CHlw-EF for linux-riscv@lists.infradead.org; Tue, 20 Jul 2021 08:51:52 +0000 Received: by mail-pl1-x629.google.com with SMTP id o8so11093762plg.11 for ; Tue, 20 Jul 2021 01:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=aTo/UaN/uIwO2OnmcLf1Lt/oTHeOCsH/C4eq+JFYMqI=; b=FdF6KxfXqg4yzB+3kblIIryje5mWoAjr5ZUjta4Ib2MBg2eJbhNJzUfoY+9kQT9F1V nXlVx7lzes9NycArJ/ycbBVl2h7sGllfG4rCV3pJTyCWQdWtnlRANLZhsTDRi9ZFSOpg AppXUyVUO9bQXnVzpW5lIFX/1KwHLvb2V6beq6CQDrfXHq2gQOOa/aSZkywOJOC2Ukvj DOfnZsUrjx2u/uXyrZuxpyK8cXXeFeHanEKztIajUbZUHJVTj4Ic10Vqgq6uLICy2NTx bNJiEaT+Lh/JSlCXNDoOp9sbz6yIOqOBnzHb7BaYtbSyybGBxF+hxGXUH1+WzwMdZLFD dfsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aTo/UaN/uIwO2OnmcLf1Lt/oTHeOCsH/C4eq+JFYMqI=; b=nb4Bt+k1CFs8JqDbosI3JQVoiv+RfBNUZXvcT/LNzLPKhnfbt2BxmUf4fCXzv7AhS1 Hf9OFrPEYQ8alK46P2uv22hsDNNoCFDPRjI7T0nmjVuLzhaaoi6LuxJIMreukj3kXDCS /E1IiNkb5rhm2hqU/sOh1NmzwfP1tNIPmB++0OZdetLr+93qd00hn6FDX0ZG9lJjSr5P TcC4bSzGF2QZCNjpGq7Uf3/tosAL9XaZzForXr5nZqAXtkPU3HAvQ5X50HR6cTui8sGi UJ/LsvvVudDY80gvmCbmY5C5KkGwq8rLy20GisrjD6arAQx/pyaqydeYdVx5ieKVus1G pHhA== X-Gm-Message-State: AOAM531+HUaXafzDgWp9z7U3GMnhllPeb1vDe0CXeTaDo4g20hBuQ67w 2dt4e982HItmvthK2z7dCms= X-Google-Smtp-Source: ABdhPJxzkHbKv6A4saCiIqD0Ek9+anWOZa0lmykmowFKmIYPEIifzYM70dRvTR2asELYuBGgEXurqg== X-Received: by 2002:a17:902:b418:b029:12a:edee:a7ff with SMTP id x24-20020a170902b418b029012aedeea7ffmr22916098plr.59.1626771110340; Tue, 20 Jul 2021 01:51:50 -0700 (PDT) Received: from [192.168.1.153] (M106072041033.v4.enabler.ne.jp. [106.72.41.33]) by smtp.gmail.com with ESMTPSA id b184sm18479456pfg.72.2021.07.20.01.51.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Jul 2021 01:51:49 -0700 (PDT) Subject: [PATCH 2/4] riscv: __asm_copy_to-from_user: Fix: fail on RV32 To: Paul Walmsley , Palmer Dabbelt , Guenter Roeck , Geert Uytterhoeven , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <37097718-c472-025a-2058-55667badc5b9@gmail.com> From: Akira Tsukamoto Message-ID: <93a6ae3b-3271-5edb-0a1b-260ba789f3f1@gmail.com> Date: Tue, 20 Jul 2021 17:51:45 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <37097718-c472-025a-2058-55667badc5b9@gmail.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_015151_538449_0D86F0C4 X-CRM114-Status: GOOD ( 11.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 Had a bug when converting bytes to bits when the cpu was rv32. The a3 contains the number of bytes and multiple of 8 would be the bits. The LGREG is holding 2 for RV32 and 3 for RV32, so to achieve multiple of 8 it must always be constant 3. The 2 was mistakenly used for rv32. Signed-off-by: Akira Tsukamoto --- arch/riscv/lib/uaccess.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S index 8bbeca89a93f..279876821969 100644 --- a/arch/riscv/lib/uaccess.S +++ b/arch/riscv/lib/uaccess.S @@ -125,7 +125,7 @@ ENTRY(__asm_copy_from_user) * t3 - prev shift * t4 - current shift */ - slli t3, a3, LGREG + slli t3, a3, 3 /* converting bytes in a3 to bits */ li a5, SZREG*8 sub t4, a5, t3 From patchwork Tue Jul 20 08:52:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akira Tsukamoto X-Patchwork-Id: 12387807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D94BBC07E95 for ; Tue, 20 Jul 2021 08:52:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9C46061209 for ; Tue, 20 Jul 2021 08:52:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C46061209 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Wm0qzHi5rJb9ilR5PFjAHO0aGcGtR7KdY7NpsDNMLPU=; b=ZSk/SLHqKtfsxouUUemCwKQR9g ChCHxzXeDT6rfmJs+2Zosx8SJl8GwzG5PNnYRrB3n2TEdddtIzZhI6Ixy/lBnYj4xYgssTfkD7LU7 zUZXZAa4qOVZrhCBuZZMMpVdiZwRw19Vyh0gNIiUY17MqQLxAixs6vsSa5BZDOFQJ/gYhFuk2+nFe y+jlngB3HhEXj5XVIegHRn6LdYj+aMI0s6d5VNKh0RNqS9U+FZKMsD6R4FiXKK4BmVJbBMXBT+2k9 ZjTePEbqIkAO9lm+sloZkS7TIkxXMSXXrf66sfkGRrE0MzDkLY2dzbOj/6gJc1ERkac4Eaif8Bd+Q 3qqVo1hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lUc-00CI1n-QC; Tue, 20 Jul 2021 08:52:46 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lUa-00CI0F-1V for linux-riscv@lists.infradead.org; Tue, 20 Jul 2021 08:52:45 +0000 Received: by mail-pf1-x42c.google.com with SMTP id u126so11275895pfb.8 for ; Tue, 20 Jul 2021 01:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=neBt+345X0N5pli5WyJQPDvAFg6VejoZfkgDTygaWmY=; b=WFzVlBxJfFJmdQwW3MeqB8pkEgcsPE24Lo8VfUrq1KnWREpx/3uZNT7zDLu79GZl2d Z96qv/hLA/MGTILMdJR77VAsy2lythcah0SF5i5yWe2UQX1N4arLhq0b9vU+8zNaM1ly V2qoChJ09NocNMFgJEOBcaunPEmZiqg1tDbakPHsq9TZ3Xl1s/8fYMWsVOwMYkA3cW52 zbaB8FwnHTVz5G6VkcxaR/RiyS+Sr5z0ehYWcPmKWaatwNxMuOd0q/1tYIHzQwXusgrf at/mQZwHGu5/Q7BrYXzrWf0NU3ps4M5P9hfydVZBOnLmFNonFnWdWOCfKTtjooh5vchd 0QiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=neBt+345X0N5pli5WyJQPDvAFg6VejoZfkgDTygaWmY=; b=hQQyUMiuAqDvJoCiHXVoXXIAhBNBSoz8KmQ+jasqnYzHmPMBfpZLak/yl0JgSI2mZo IvsdFDPyK310FebNwe63E8p4YEA8oQWQeoTLHDWAULMS6FIoBiFc8y0M7d/Wf4vhULGw wLMQtTRoshvJK/WRccrXKF2+8VFBZqXqRG1Imtx7nJeGiMo/Mw2rgyeCubaAIa5K7frC 9I6KMiXu9hZDbn00MWoFSDeVTHkjW6J09M1DzqC/iuCwR9FRO4WcCl/OeNx7XvWwS5g+ 7ApcyHKV76hVj53vuPQXFoPAUtjYNlxeuvVd/Lt1RcJuzxEeqBmkbhu/CXUS8Zs+SYI9 1Z7Q== X-Gm-Message-State: AOAM530HEKbGafA1ZFTEYL0ZftfYmoFC4ifBWbTSsWQ2wrVeaCpc0LUk 1b5z900LPn6VpiDgU4hPJIM= X-Google-Smtp-Source: ABdhPJxOmVRYcAJYPBUAwlqoDVHc2s48l811SwUXYECZw7ET/6/Yv9yG1V3cLT2ITW2OkAYGi4gm9g== X-Received: by 2002:a65:63cf:: with SMTP id n15mr4668241pgv.392.1626771161295; Tue, 20 Jul 2021 01:52:41 -0700 (PDT) Received: from [192.168.1.153] (M106072041033.v4.enabler.ne.jp. [106.72.41.33]) by smtp.gmail.com with ESMTPSA id i6sm17126099pfa.44.2021.07.20.01.52.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Jul 2021 01:52:41 -0700 (PDT) Subject: [PATCH 3/4] riscv: __asm_copy_to-from_user: Remove unnecessary size check To: Paul Walmsley , Palmer Dabbelt , Guenter Roeck , Geert Uytterhoeven , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <37097718-c472-025a-2058-55667badc5b9@gmail.com> From: Akira Tsukamoto Message-ID: <94d4ec76-a987-348e-71ce-473511d44787@gmail.com> Date: Tue, 20 Jul 2021 17:52:36 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <37097718-c472-025a-2058-55667badc5b9@gmail.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_015244_140662_2AF6AD17 X-CRM114-Status: UNSURE ( 9.22 ) X-CRM114-Notice: Please train this message. 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 Clean up: The size of 0 will be evaluated in the next step. Not required here. Signed-off-by: Akira Tsukamoto --- arch/riscv/lib/uaccess.S | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S index 279876821969..54d497a03164 100644 --- a/arch/riscv/lib/uaccess.S +++ b/arch/riscv/lib/uaccess.S @@ -30,7 +30,6 @@ ENTRY(__asm_copy_from_user) * t0 - end of uncopied dst */ add t0, a0, a2 - bgtu a0, t0, 5f /* * Use byte copy only if too small. From patchwork Tue Jul 20 08:53:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akira Tsukamoto X-Patchwork-Id: 12387833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5836AC07E9B for ; Tue, 20 Jul 2021 08:53:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2548261209 for ; Tue, 20 Jul 2021 08:53:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2548261209 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zsb/NW4LeJ3ZNhnykQaTj2+DLXDYvVNTJur2f6ALCKk=; b=RbXRWT1n8NeMlqF1j3b8uix+y+ FOTsWR+n6VV58kaW0IWEqRE2JEEijo1jta5h+AQP7P0sDOjzl6p15LUb6R9lkRcaiRSl3y7+ylYiB vMTBa0aN04NwwOG19eK81cwR7OSis9+DpSxBLaMCD1JvWsbcv7LnaVO5va9lh7LjW22SvodgrEvZc 3tzWpwfuQXkWk6xJsD78x8q6DfyNyLcGqHKVNM4Ho2GIb/CCJa+nLoYefFdPCbMJmj/2gu2VGNrEh CsBeBumZtXk7F321vLoNStV8vneiQcfwFgl2ZhHAkEIf1CAWrWmFAL45GY7VCU09cz3RJaS3wzSfI OCCYUcCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lVM-00CIIj-HZ; Tue, 20 Jul 2021 08:53:32 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lVJ-00CIHK-Kn for linux-riscv@lists.infradead.org; Tue, 20 Jul 2021 08:53:31 +0000 Received: by mail-pj1-x102c.google.com with SMTP id d9-20020a17090ae289b0290172f971883bso1514210pjz.1 for ; Tue, 20 Jul 2021 01:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=iZ11XlQ/7LpvSWqpfLjYjm5v/1yKJ1MGXqTuOdCwXh4=; b=Sd2kIfTvXXfKi0494oKwDhzLl9t6+qHQ0y9S6DpyTVWMiJ20Mr8LG2sRSNXFo+aPax EBmAJ22daE/xFihfPX1dqF4A6Av6BMFF2M1mML3NzEMu88A9cV6eyMBSoZjVUT3YkKSb lfcKRx51h3aanM7YhezfUXC9JU+DEv1v9K4s8/dLB1TsEtFBoUq5ItmLuCAW7C35c3kB YLd3i8+Kr4EdAl/OHnIFSpV1mx4TDXrYpzhwE1ICm8ZPvrhgm0tB+ZoxHDGTyxKbU1Eb LS36UzpBcXKte4R6z8sH+i5WjiS8Jous+gXC5HFWlRbmBC15tx3S4MBOOdZQXUUoGCJa WapA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=iZ11XlQ/7LpvSWqpfLjYjm5v/1yKJ1MGXqTuOdCwXh4=; b=n/CyWA0JXwIPw7guRAhqLQp93uDTj0SpuNlGHtKWrZxc+7z6X97rBfBNsrxrFNlLY1 WGq8jv7qT7jXDs4WRC5LtV0BosUqmDEz+Fw46GWLKXiqC6ZGrxTLnrMkUiLRqwPgOiHo jPOzz/pSVn/Zjs0Zvueo4C+LhuP/Tq8wi2erxJC3kLsim6qbGwwnbZkaNVBla79ZGkKK K3j0Mt/yEYz5pweS7CPwVCmlakXoFqejLe38J14f/lFzlkYa2NGES1O7EUGFZYlHhRMv q6eI4oBtYGTGwLZm6NsLCFtiz9GVfnxsgzmE+JXNDKepTuPgNaQpaKsYbBXdOKpKCIBd ZxzA== X-Gm-Message-State: AOAM533SgKmB5Y1K05WS0PkTkZnvjNhhMfo9PxFYQ6pexccIIWw2bjIh 41D6tTjACxuhex/TQZwyQ/k= X-Google-Smtp-Source: ABdhPJwOvzonlcX/HWjjXzujzIEk+xCMC3woFJ4KKx1NW8wFFacD8C/pXaILCf05nRSjHuiVCUuhRA== X-Received: by 2002:a17:90b:1d84:: with SMTP id pf4mr28729285pjb.166.1626771208547; Tue, 20 Jul 2021 01:53:28 -0700 (PDT) Received: from [192.168.1.153] (M106072041033.v4.enabler.ne.jp. [106.72.41.33]) by smtp.gmail.com with ESMTPSA id z15sm25461191pgc.13.2021.07.20.01.53.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Jul 2021 01:53:28 -0700 (PDT) Subject: [PATCH 4/4] riscv: __asm_copy_to-from_user: Fix: Typos in comments To: Paul Walmsley , Palmer Dabbelt , Guenter Roeck , Geert Uytterhoeven , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <37097718-c472-025a-2058-55667badc5b9@gmail.com> From: Akira Tsukamoto Message-ID: <23960a08-22aa-c0dd-57aa-80e73d6859ab@gmail.com> Date: Tue, 20 Jul 2021 17:53:23 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <37097718-c472-025a-2058-55667badc5b9@gmail.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_015329_725219_0BD1B731 X-CRM114-Status: GOOD ( 13.53 ) 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 Fixing typos and grammar mistakes and using more intuitive label name. Signed-off-by: Akira Tsukamoto --- arch/riscv/lib/uaccess.S | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S index 54d497a03164..63bc691cff91 100644 --- a/arch/riscv/lib/uaccess.S +++ b/arch/riscv/lib/uaccess.S @@ -33,19 +33,20 @@ ENTRY(__asm_copy_from_user) /* * Use byte copy only if too small. + * SZREG holds 4 for RV32 and 8 for RV64 */ li a3, 9*SZREG /* size must be larger than size in word_copy */ bltu a2, a3, .Lbyte_copy_tail /* - * Copy first bytes until dst is align to word boundary. + * Copy first bytes until dst is aligned to word boundary. * a0 - start of dst * t1 - start of aligned dst */ addi t1, a0, SZREG-1 andi t1, t1, ~(SZREG-1) /* dst is already aligned, skip */ - beq a0, t1, .Lskip_first_bytes + beq a0, t1, .Lskip_align_dst 1: /* a5 - one byte for copying data */ fixup lb a5, 0(a1), 10f @@ -54,7 +55,7 @@ ENTRY(__asm_copy_from_user) addi a0, a0, 1 /* dst */ bltu a0, t1, 1b /* t1 - start of aligned dst */ -.Lskip_first_bytes: +.Lskip_align_dst: /* * Now dst is aligned. * Use shift-copy if src is misaligned. @@ -71,7 +72,6 @@ ENTRY(__asm_copy_from_user) * * a0 - start of aligned dst * a1 - start of aligned src - * a3 - a1 & mask:(SZREG-1) * t0 - end of aligned dst */ addi t0, t0, -(8*SZREG) /* not to over run */ @@ -106,7 +106,7 @@ ENTRY(__asm_copy_from_user) * For misaligned copy we still perform aligned word copy, but * we need to use the value fetched from the previous iteration and * do some shifts. - * This is safe because reading less than a word size. + * This is safe because reading is less than a word size. * * a0 - start of aligned dst * a1 - start of src @@ -116,7 +116,7 @@ ENTRY(__asm_copy_from_user) */ /* calculating aligned word boundary for dst */ andi t1, t0, ~(SZREG-1) - /* Converting unaligned src to aligned arc */ + /* Converting unaligned src to aligned src */ andi a1, a1, ~(SZREG-1) /* @@ -128,7 +128,7 @@ ENTRY(__asm_copy_from_user) li a5, SZREG*8 sub t4, a5, t3 - /* Load the first word to combine with seceond word */ + /* Load the first word to combine with second word */ fixup REG_L a5, 0(a1), 10f 3: @@ -160,7 +160,7 @@ ENTRY(__asm_copy_from_user) * a1 - start of remaining src * t0 - end of remaining dst */ - bgeu a0, t0, 5f + bgeu a0, t0, .Lout_copy_user /* check if end of copy */ 4: fixup lb a5, 0(a1), 10f addi a1, a1, 1 /* src */ @@ -168,7 +168,7 @@ ENTRY(__asm_copy_from_user) addi a0, a0, 1 /* dst */ bltu a0, t0, 4b /* t0 - end of dst */ -5: +.Lout_copy_user: /* Disable access to user memory */ csrc CSR_STATUS, t6 li a0, 0