From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D74E3C433EF for ; Sun, 23 Jan 2022 17:15:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239174AbiAWRPH (ORCPT ); Sun, 23 Jan 2022 12:15:07 -0500 Received: from m228-6.mailgun.net ([159.135.228.6]:55877 "EHLO m228-6.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239108AbiAWRPG (ORCPT ); Sun, 23 Jan 2022 12:15:06 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=michaelkloos.com; q=dns/txt; s=k1; t=1642958106; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: From: References: Cc: To: Subject: MIME-Version: Date: Message-ID: Sender; bh=KMCKo4cpOIFU5Z2gsr3EOOcDEAmZ5XEZ/k/AX4zaDbA=; b=bBjK088xo1ObtreG6xEsbIqQcjZZvwloJ/7WIwD51x/E9qj1cBQ2HRSZTWhhvCh/sQF2AfcA LArShW7hQnzW8U70B+GEPoT1HwLL0LKLnN2x0ntNjQS8mluD4hsWXXbGDat5Nk2QBReNigca t+EPclzBoH33dCczyB8+vV3RlR8= X-Mailgun-Sending-Ip: 159.135.228.6 X-Mailgun-Sid: WyI5NjYzNiIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgIjQ4Y2MwIl0= Received: from drop1.michaelkloos.com (drop1.michaelkloos.com [67.205.190.89]) by smtp-out-n05.prod.us-west-2.postgun.com with SMTP id 61ed8d16e0071250cf5a03b8 (version=TLS1.3, cipher=TLS_AES_128_GCM_SHA256); Sun, 23 Jan 2022 17:15:02 GMT Sender: michael@michaelkloos.com Received: from [192.168.0.104] (cpe-173-88-115-50.columbus.res.rr.com [173.88.115.50]) by drop1.michaelkloos.com (Postfix) with ESMTPSA id 425B240249; Sun, 23 Jan 2022 17:15:01 +0000 (UTC) Message-ID: <3607326c-9d39-a9e7-8e14-65aaef2094fd@michaelkloos.com> Date: Sun, 23 Jan 2022 12:15:00 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison. Content-Language: en-US To: Jessica Clarke Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv , linux-kernel@vger.kernel.org References: <20220123034518.3717116-1-michael@michaelkloos.com> <485047B2-E566-4679-87CF-C4B3CAFEF108@jrtc27.com> From: "Michael T. Kloos" In-Reply-To: <485047B2-E566-4679-87CF-C4B3CAFEF108@jrtc27.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yes, you are correct, but while I am not that knowledgeable in the kernel build system, I believe that in many build systems, binutils "as" is usually called by the "gcc" wrapper, rather than being executed directly. This allows for the C preprocessor to be easily and automatically run over *.S files first. Binutils "as" doesn't care about suffix. It just assembles. "gcc" will check and call the other tools as necessary to build. Perhaps I should have been more specific in my language. However, I was trying to refer to the 2 different build systems in their entirety, not their individually sub-components because I had originally test built with gcc, not clang. Michael On 1/23/22 10:44, Jessica Clarke wrote: > On 23 Jan 2022, at 03:45, Michael T. Kloos wrote: >> Rewrote the riscv memmove() assembly implementation. The >> previous implementation did not check memory alignment and it >> compared 2 pointers with a signed comparison. The misaligned >> memory access would cause the kernel to crash on systems that >> did not emulate it in firmware and did not support it in hardware. >> Firmware emulation is slow and may not exist. Additionally, >> hardware support may not exist and would likely still run slower >> than aligned accesses even if it did. The RISC-V spec does not >> guarantee that support for misaligned memory accesses will exist. >> It should not be depended on. >> >> This patch now checks for the maximum granularity of co-alignment >> between the pointers and copies them with that, using single-byte >> copy for any unaligned data at their terminations. It also now uses >> unsigned comparison for the pointers. >> >> Added half-word and, if built for 64-bit, double-word copy. >> >> Migrated to the newer assembler annotations from the now deprecated >> ones. >> >> Commit Message Edited on Jan 22 2022: Fixed some typos. >> >> [v2] >> >> Per kernel test robot, I have fixed the build under clang. This >> was broken due to a difference between gcc and clang, clang requiring >> explict zero offsets the jalr instruction. gcc allowed them to be >> omitted if zero. > Unlike LLVM, GCC does not have an assembler, that’s binutils’s GNU as. > > Jess > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F37B6C433F5 for ; Sun, 23 Jan 2022 17:15:19 +0000 (UTC) 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:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rzcOVAqzDxNVNBRrG2r2x6FRJsziWZCJ66rUDVFjMp0=; b=r/wXd+6IyPcPMP ZnyWhFqx1LTSi7YmgEKxpPKGdCnEoqPT46gjezPJbve7xUa3K2ULw8DYBlWFeIKDgTZqNhu0WD1yW Ronab0kb+gNb2YktYVLHivG+hQdj1flZSM0MJ/ru5vVwaYO0mWTcy4ViwWa2Yes56mAwznkb/yqR4 2+oXopYCG0oGPxXVBvybDN//b7zi6ROajICqnpxKgjQH4GqYVcZFLxCGTmNFrXHqiRhvJ2iz3mEHJ 5Avq25AcV1FUVo9EFncJeaVHeAAsJ/PhOok5CH+gGZ07lH7aNphMxE0fQItCGbHSlzPmeAjuXBXHv 9ow5hlQBAA7NJww7BNyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBgSN-001Shm-ST; Sun, 23 Jan 2022 17:15:11 +0000 Received: from m228-6.mailgun.net ([159.135.228.6]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBgSI-001Sg7-DN for linux-riscv@lists.infradead.org; Sun, 23 Jan 2022 17:15:08 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=michaelkloos.com; q=dns/txt; s=k1; t=1642958106; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: From: References: Cc: To: Subject: MIME-Version: Date: Message-ID: Sender; bh=KMCKo4cpOIFU5Z2gsr3EOOcDEAmZ5XEZ/k/AX4zaDbA=; b=bBjK088xo1ObtreG6xEsbIqQcjZZvwloJ/7WIwD51x/E9qj1cBQ2HRSZTWhhvCh/sQF2AfcA LArShW7hQnzW8U70B+GEPoT1HwLL0LKLnN2x0ntNjQS8mluD4hsWXXbGDat5Nk2QBReNigca t+EPclzBoH33dCczyB8+vV3RlR8= X-Mailgun-Sending-Ip: 159.135.228.6 X-Mailgun-Sid: WyIxOGJjMSIsICJsaW51eC1yaXNjdkBsaXN0cy5pbmZyYWRlYWQub3JnIiwgIjQ4Y2MwIl0= Received: from drop1.michaelkloos.com (drop1.michaelkloos.com [67.205.190.89]) by smtp-out-n05.prod.us-west-2.postgun.com with SMTP id 61ed8d16e0071250cf5a03b6 (version=TLS1.3, cipher=TLS_AES_128_GCM_SHA256); Sun, 23 Jan 2022 17:15:02 GMT Received: from [192.168.0.104] (cpe-173-88-115-50.columbus.res.rr.com [173.88.115.50]) by drop1.michaelkloos.com (Postfix) with ESMTPSA id 425B240249; Sun, 23 Jan 2022 17:15:01 +0000 (UTC) Message-ID: <3607326c-9d39-a9e7-8e14-65aaef2094fd@michaelkloos.com> Date: Sun, 23 Jan 2022 12:15:00 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison. Content-Language: en-US To: Jessica Clarke Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv , linux-kernel@vger.kernel.org References: <20220123034518.3717116-1-michael@michaelkloos.com> <485047B2-E566-4679-87CF-C4B3CAFEF108@jrtc27.com> From: "Michael T. Kloos" In-Reply-To: <485047B2-E566-4679-87CF-C4B3CAFEF108@jrtc27.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220123_091506_572021_59E2C72A X-CRM114-Status: GOOD ( 17.10 ) 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org WWVzLCB5b3UgYXJlIGNvcnJlY3QsIGJ1dCB3aGlsZSBJIGFtIG5vdCB0aGF0IGtub3dsZWRnZWFi bGUgaW4gdGhlIGtlcm5lbApidWlsZCBzeXN0ZW0sIEkgYmVsaWV2ZSB0aGF0IGluIG1hbnkgYnVp bGQgc3lzdGVtcywgYmludXRpbHMgImFzIiBpcyB1c3VhbGx5CmNhbGxlZCBieSB0aGUgImdjYyIg d3JhcHBlciwgcmF0aGVyIHRoYW4gYmVpbmcgZXhlY3V0ZWQgZGlyZWN0bHkuICBUaGlzCmFsbG93 cyBmb3IgdGhlIEMgcHJlcHJvY2Vzc29yIHRvIGJlIGVhc2lseSBhbmQgYXV0b21hdG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