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 0962FC433F5 for ; Sun, 23 Jan 2022 15:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238025AbiAWPoz (ORCPT ); Sun, 23 Jan 2022 10:44:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238020AbiAWPoy (ORCPT ); Sun, 23 Jan 2022 10:44:54 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA7F1C06173B for ; Sun, 23 Jan 2022 07:44:53 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id a13so9116989wrh.9 for ; Sun, 23 Jan 2022 07:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=nfUCrgltiuESmGAEDtw9bdfISibes8TAv+qKIXGxuic=; b=Zz1rjr+Oaa1cFDW4Ogh1s0Dc6tRdjPe3+yJjgn9CXxfzgEto8FZ+qBc5OOqQt+wg2g 86VMddvrTwe3r5BvseJWhSMizn31JbvnKgcrDhig3JnZk2XCLXgzqSWUC8NhyhnFEHQK 0FP1z/IIQY1a0DG8xZ6zAWheMH4h2tsovocf5EFaEYtIY04+mKB3Y6qB986mMyv3y8Zv 9ftdyp/cOWHazPHa9Zw6WnzHDb9q/rJgkv7k6VhCc30hD+4ZhueqoZcV5oLRNWJoJbyW rM+QaanVdc47C5HuUlHcN5c2Ekg8LZhLqcWlk/wBjm4g33CRo5QHhKE4uZaghxiD5MRn 3zvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=nfUCrgltiuESmGAEDtw9bdfISibes8TAv+qKIXGxuic=; b=TvMvU2sZStq7ZNuBbXRSb64jS415tzuFuNfToW4YslncbSX2Gi/qzqcIfnH02TteaJ SUSz2VgZC9eCOztVzThT8FX4dbdiGx3LnslSY/MBzUGzSkWgx4hrFyT+kG2I6AsIsmGm LK0DZuHu8cgoqdMXeOZ4LoZNN1odfJ8YV/HeEYtjaDiJRqIdq/T+6yeEMb+t7HSW7DhB hjnTvlH0l7VOGZ8Ucxds5syJerA/6ogc3wIVH4+Y+D/JW4jT3sBFDuau/+Ez5T+PIStX tIwOC1XqNpUx5E52lXGGUjjhvaL/PCMTx2V7WGRTXyXFBUwTaBadX7JEAihCWjleEK3C WBZQ== X-Gm-Message-State: AOAM532B4SlVSPfEZzQI+fDfmVC8viaXP1BTDyovcOm+xoou0EWNykxs C3rXTkJrqNHoJ0pgNsK5ubV2MQ== X-Google-Smtp-Source: ABdhPJwuMCafdMGqKQ6AEE1aYdBVnMGozvO8SH5XCkPG9PcCYPue5hINzJBa4ikKxPcemlyvyMc8ZQ== X-Received: by 2002:adf:f192:: with SMTP id h18mr358315wro.314.1642952692393; Sun, 23 Jan 2022 07:44:52 -0800 (PST) Received: from smtpclient.apple (global-5-142.nat-2.net.cam.ac.uk. [131.111.5.142]) by smtp.gmail.com with ESMTPSA id l7sm13366441wrs.104.2022.01.23.07.44.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Jan 2022 07:44:52 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Subject: Re: [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison. From: Jessica Clarke In-Reply-To: <20220123034518.3717116-1-michael@michaelkloos.com> Date: Sun, 23 Jan 2022 15:44:51 +0000 Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <485047B2-E566-4679-87CF-C4B3CAFEF108@jrtc27.com> References: <20220123034518.3717116-1-michael@michaelkloos.com> To: "Michael T. Kloos" X-Mailer: Apple Mail (2.3693.40.0.1.81) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23 Jan 2022, at 03:45, Michael T. Kloos = wrote: >=20 > 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. >=20 > 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. >=20 > Added half-word and, if built for 64-bit, double-word copy. >=20 > Migrated to the newer assembler annotations from the now = deprecated > ones. >=20 > Commit Message Edited on Jan 22 2022: Fixed some typos. >=20 > [v2] >=20 > 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=E2=80=99s binutils=E2=80= =99s 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 96987C433EF for ; Sun, 23 Jan 2022 15:58:34 +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:To:References:Message-Id:Cc:Date: In-Reply-To:From:Subject:Mime-Version:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sEF6Jn0mdXoYKeR6SUKrDj1cNyHMNUeTj6+cFVFGGLU=; b=W9xFdf0Ey4GVwa Hzcd5GtwDc7VmpC0C/PPBShqW/ab3ah8Ovm4y/CDCkkl/xJWgJQUOyvRA8k8+p3jWKfUIsJ8Nekx2 KGVv3xSZaMkP5TNIhcljtCCOLGbfmXJyv5W6qeXf4zDdJ0CBr5dzuEbTPVcky45p7TxqbwsWvUUCx 4hmg7kqoyxDJd4+4CijajoXzW0lNaP7OW0wzEDUYk/L4TBIFqX2mQ5P47zERIyilQYWdm9zbRzQIE XyIymKMrAgd2KgGt12IsHCXzwv+ycnqYsN8pwAhFK3AXvyK9LScfsBarWgqhI6IfHGmTLylxI8kER lN7eGSNdFRYAQpbMUD4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBfG3-001ENd-Aq; Sun, 23 Jan 2022 15:58:23 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBf31-0019ra-1c for linux-riscv@lists.infradead.org; Sun, 23 Jan 2022 15:44:56 +0000 Received: by mail-wr1-x436.google.com with SMTP id e8so7358678wrc.0 for ; Sun, 23 Jan 2022 07:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=nfUCrgltiuESmGAEDtw9bdfISibes8TAv+qKIXGxuic=; b=Zz1rjr+Oaa1cFDW4Ogh1s0Dc6tRdjPe3+yJjgn9CXxfzgEto8FZ+qBc5OOqQt+wg2g 86VMddvrTwe3r5BvseJWhSMizn31JbvnKgcrDhig3JnZk2XCLXgzqSWUC8NhyhnFEHQK 0FP1z/IIQY1a0DG8xZ6zAWheMH4h2tsovocf5EFaEYtIY04+mKB3Y6qB986mMyv3y8Zv 9ftdyp/cOWHazPHa9Zw6WnzHDb9q/rJgkv7k6VhCc30hD+4ZhueqoZcV5oLRNWJoJbyW rM+QaanVdc47C5HuUlHcN5c2Ekg8LZhLqcWlk/wBjm4g33CRo5QHhKE4uZaghxiD5MRn 3zvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=nfUCrgltiuESmGAEDtw9bdfISibes8TAv+qKIXGxuic=; b=Jio5k8EO0HH+Ipo2cao+cXypqi1DAM7SlnxhWCL+zorfyeYutpkYkTmOLxhGCW0qeh Ikr4lWWbyD/m11qmopgIP8JpwcGBjl+yXirf8/TX3ccx4Kl2hMi5j0CSQT+8xQroF+83 Ige7lFz548jdZUSPIvFZq4iIkpiSK1LaYM+VRVbVPv2BvRh3kNkG8UCP/FP9NWCnSQHO zWXzH0zbc1ZNqHMbzUcnTDRhgFYW227pXVrnuGCzkVC2LHTQIa3DfRegyt3UddcYrUlc aR+Koh89zmI0W9QEz1e4HEgXbDCR6c2wr/8Q6/z+SgGwLzuHq1x2musfjtA/KzYt8fV4 rxrw== X-Gm-Message-State: AOAM533ZSrmJEbEI/ElLnzVBCz6K2BXsEChQ9F19noxI+IvEL2mQ56Wv sMNRFOlw6xFL5OIMI/NvRjR6Tg== X-Google-Smtp-Source: ABdhPJwuMCafdMGqKQ6AEE1aYdBVnMGozvO8SH5XCkPG9PcCYPue5hINzJBa4ikKxPcemlyvyMc8ZQ== X-Received: by 2002:adf:f192:: with SMTP id h18mr358315wro.314.1642952692393; Sun, 23 Jan 2022 07:44:52 -0800 (PST) Received: from smtpclient.apple (global-5-142.nat-2.net.cam.ac.uk. [131.111.5.142]) by smtp.gmail.com with ESMTPSA id l7sm13366441wrs.104.2022.01.23.07.44.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Jan 2022 07:44:52 -0800 (PST) Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Subject: Re: [PATCH v2] Fixed: Misaligned memory access. Fixed pointer comparison. From: Jessica Clarke In-Reply-To: <20220123034518.3717116-1-michael@michaelkloos.com> Date: Sun, 23 Jan 2022 15:44:51 +0000 Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv , linux-kernel@vger.kernel.org Message-Id: <485047B2-E566-4679-87CF-C4B3CAFEF108@jrtc27.com> References: <20220123034518.3717116-1-michael@michaelkloos.com> To: "Michael T. Kloos" X-Mailer: Apple Mail (2.3693.40.0.1.81) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220123_074455_180221_282EA918 X-CRM114-Status: GOOD ( 16.74 ) 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 T24gMjMgSmFuIDIwMjIsIGF0IDAzOjQ1LCBNaWNoYWVsIFQuIEtsb29zIDxtaWNoYWVsQG1pY2hh ZWxrbG9vcy5jb20+IHdyb3RlOgo+IAo+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