Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp872787imm; Wed, 23 May 2018 06:55:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq6Ucx2BbZZBWU4TEJoXOXk54J1VtuY6Jv2Cn+bP++D7rIuRTBhkfh7FzNbTh5NylBxZZED X-Received: by 2002:a65:6101:: with SMTP id z1-v6mr2481731pgu.23.1527083729069; Wed, 23 May 2018 06:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527083729; cv=none; d=google.com; s=arc-20160816; b=tipOCPagSzcAmstVeOfccrl+uZYxbKx7PhIb8QUjepZvrIZ46S2Q6bwbq1PzrUt7q3 DR1Cs8OSN5keWgw/eyzELQnGGP2Dl76f5FUTHoFD43hbzqjP40nSkqxgXC1taYRjQm/k GVymXy+Suh1qTbheS2LA3uYrRGKY4k92UNlWLKRagPDZ+2MPWd/TdG34jo1OyNzemdLl bapkc+/TIwuUHyfI5FMAt9Yk+dbtZhKLnP27UewKBU9w50kRhrV8zg343P6yEE1rRYmr ZMQNcdqdEDaGn2GKVLOT0dt4KGCiNLvCrlrpq58jQ2R/UoHCoKps/90TIYYQkpxmw0/J nuUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=ZlQeskBbKzWAc8q/rr3R0agf/ZNaaq0frXGLYCX+yII=; b=QY2nsjEK4WLYk4S2+yHwPzEE19XSBYVo5BV5T/vV6cQFJVMBksdztkZkVEitkNjl7l 1nNawyQX6mlMu8qbXMazvQnZsNwZ0dy/Gdd6BDF6O8CUlc2xxPyDQipFmCIGr6dGspiS LpdY4tmpMTDs5wZIAyAZHY6FB/6gDhWQIGpRgGNuk9FepZ7iinUsJSwkA4tBHdztToyX b361n6NpQjdfh0pMQvRgc0WCqoXSX8ycN+q1dAZF7bzhnXKOPQjIrzopx/ZvsSU9wHxW PESf290PVuq5aMo3QKnaJmsBKjf9r9bPwlM4lg5bxfWLPET5BikQLAnMJcF9TLk7YBVa BJ5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si5834483plj.216.2018.05.23.06.54.40; Wed, 23 May 2018 06:55:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933117AbeEWNuY (ORCPT + 99 others); Wed, 23 May 2018 09:50:24 -0400 Received: from 9pmail.ess.barracuda.com ([64.235.150.224]:32911 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932941AbeEWNuX (ORCPT ); Wed, 23 May 2018 09:50:23 -0400 Received: from mipsdag02.mipstec.com (mail2.mips.com [12.201.5.32]) by mx28.ess.sfj.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=NO); Wed, 23 May 2018 13:50:17 +0000 Received: from mredfearn-linux.mipstec.com (192.168.155.41) by mipsdag02.mipstec.com (10.20.40.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Wed, 23 May 2018 06:40:09 -0700 From: Matt Redfearn To: James Hogan , Ralf Baechle CC: , Matt Redfearn , Subject: [PATCH v3 2/2] MIPS: memset.S: Add comments to fault fixup handlers Date: Wed, 23 May 2018 14:39:59 +0100 Message-ID: <1527082799-14704-2-git-send-email-matt.redfearn@mips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527082799-14704-1-git-send-email-matt.redfearn@mips.com> References: <1527082799-14704-1-git-send-email-matt.redfearn@mips.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.155.41] X-ClientProxiedBy: mipsdag03.mipstec.com (10.20.40.48) To mipsdag02.mipstec.com (10.20.40.47) X-BESS-ID: 1527083416-637138-32316-228975-1 X-BESS-VER: 2018.6-r1805181819 X-BESS-Apparent-Source-IP: 12.201.5.32 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.193286 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is not immediately obvious what the expected inputs to these fault handlers is and how they calculate the number of unset bytes. Having stared deeply at this in order to fix some corner cases, add some comments to assist those who follow. Signed-off-by: Matt Redfearn --- Changes in v3: - Update comment on .Lbyte_fixup to reflect corrected behavior Changes in v2: - Add comments to fault handlers in new, separate, patch. arch/mips/lib/memset.S | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/mips/lib/memset.S b/arch/mips/lib/memset.S index fac26ce64b2..3a6f34ef5ff 100644 --- a/arch/mips/lib/memset.S +++ b/arch/mips/lib/memset.S @@ -232,16 +232,25 @@ #ifdef CONFIG_CPU_MIPSR6 .Lbyte_fixup\@: + /* + * unset_bytes = (#bytes - (#unaligned bytes)) - (-#unaligned bytes remaining + 1) + 1 + * a2 = a2 - t0 + 1 + */ PTR_SUBU a2, t0 jr ra PTR_ADDIU a2, 1 #endif /* CONFIG_CPU_MIPSR6 */ .Lfirst_fixup\@: + /* unset_bytes already in a2 */ jr ra nop .Lfwd_fixup\@: + /* + * unset_bytes = partial_start_addr + #bytes - fault_addr + * a2 = t1 + (a2 & 3f) - $28->task->BUADDR + */ PTR_L t0, TI_TASK($28) andi a2, 0x3f LONG_L t0, THREAD_BUADDR(t0) @@ -250,6 +259,10 @@ LONG_SUBU a2, t0 .Lpartial_fixup\@: + /* + * unset_bytes = partial_end_addr + #bytes - fault_addr + * a2 = a0 + (a2 & STORMASK) - $28->task->BUADDR + */ PTR_L t0, TI_TASK($28) andi a2, STORMASK LONG_L t0, THREAD_BUADDR(t0) @@ -258,10 +271,15 @@ LONG_SUBU a2, t0 .Llast_fixup\@: + /* unset_bytes already in a2 */ jr ra nop .Lsmall_fixup\@: + /* + * unset_bytes = end_addr - current_addr + 1 + * a2 = t1 - a0 + 1 + */ PTR_SUBU a2, t1, a0 jr ra PTR_ADDIU a2, 1 -- 2.7.4