Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5306436rwi; Mon, 17 Oct 2022 19:16:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6C2ykt0jPyJOZ860FvZTIdlLC+XUSOIOEVA/PlAmWNJ0fiRYk0CKubCIhoccZKy2HVIyrY X-Received: by 2002:a17:906:9bc3:b0:78d:816f:3743 with SMTP id de3-20020a1709069bc300b0078d816f3743mr549687ejc.380.1666059401419; Mon, 17 Oct 2022 19:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666059401; cv=none; d=google.com; s=arc-20160816; b=lLtktUJZ0r4wz7RR6O7QDxQqUSodLIDttcU3LawSdptJFH867SaRXA+V3O+RnUXGrb 8+w/qmYCEdcnnEvS7o5Uu3jrR9yFvEDprjmujyZ4yN5BUTF9I5EQhONVLCP7XCTXByYB iPKEv66JMGMT4/DaSrRsIj0On3PFOb3oA/M5gYowGhTUrrlbkEhPyelvjGyGHcGWhsGN aPXQeG3ovAJpKe0tFzZV0V8urSiVRiuhd9GEYoF7hJmFaVq+2tMukOb4n1d35fujkw7R /ibC5yJ+HHSzmyR2yutbTLsITjcvNZV3Z+zVMSyQXnO7+1Vaddwn3Y/ZuLTJ2qJF0pi0 RIQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=o5yozFEHHAr15WownkU5KRLUJc++jIAhSMPZUVIex18=; b=pgWSbY5Wb2OnwNQrQofj7Y6/bIego6eA/fmBigyGgt8KnCyd1jqHpPyL3Xb+N1TlVA 6ngItFtiGrYIgE3ZcZ7v3utnaIyLZ1oj17z2yLvigMjw8OYOyiqw1fVydwyqvTOkEAZc UMkaQ3FB1nRgs6Kj708n6R3c7KCz1U/Ip7EQuXIX8YyM1an02V5K0BQZuUSwEoYltPbx blld29DJmguIbUgqtWqvS6BoZAd8F16mPB6ZsbRH401jhYFXj2tPrwp9qg3C6c/EqBkl dvN/fbeWlYzJvXAb2vdGaApX5HuurzQ6zikC73NUwf/d0PNao4e+9vjOu8Vq/X8g42W0 bfiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nsfq06HS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr41-20020a1709073fa900b0078debc9d30esi10455518ejc.29.2022.10.17.19.16.15; Mon, 17 Oct 2022 19:16:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nsfq06HS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbiJRB7e (ORCPT + 99 others); Mon, 17 Oct 2022 21:59:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbiJRB7b (ORCPT ); Mon, 17 Oct 2022 21:59:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 145E1101B; Mon, 17 Oct 2022 18:59:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9CB8FB81BF0; Tue, 18 Oct 2022 01:59:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C48AC4347C; Tue, 18 Oct 2022 01:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666058364; bh=afqllA9B+pLQ3PQHZjpVZ98NziD/czmrfnB4F3JDvfY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nsfq06HSNWpqo/8lAVbttFBI+Ee1jSsAlYogNkalZXJHyDKO0GihPIbbo53psvYsH scSQSVKz6/hGQa2PMClA8DgVmvUKZphQ5idYXf+VaH3yRTBLlnJ7boXm2bnJnlqIsy iXdf/z39dDfx0MeKUWrOU1XZiyyzGhO4dM0B5JF7GKgAbPCQDAdg9JltHezdCQoOIu OcYgbdso+KWq5tgBoB+vDS6pOi87/Ovz/WJ7HwtYUeKxbPo3ygyRpC/epH8Bircfyk zcu8jD6rD0EpWUNoyEUPAVCzwN5dYLmHNO0wE6p1eo0htOTYN32zHKRnbEF8AsKbzn 9sBPlJZMH1YHQ== Received: by mail-ej1-f41.google.com with SMTP id w18so28919716ejq.11; Mon, 17 Oct 2022 18:59:24 -0700 (PDT) X-Gm-Message-State: ACrzQf2rPQjQjAooV1mbne7IY4I/gOZXiLUNcOSLJJO3RqGuSWe8Zize twrE/r0NcMAECTb0DkaygMISdzJGCW08JE7ns+4= X-Received: by 2002:a17:907:7f05:b0:78d:e869:f2fe with SMTP id qf5-20020a1709077f0500b0078de869f2femr452896ejc.684.1666058362517; Mon, 17 Oct 2022 18:59:22 -0700 (PDT) MIME-Version: 1.0 References: <20221017125209.2639531-1-chenhuacai@loongson.cn> <39ea2a6fee654b68974ef38237a61e80@AcuMS.aculab.com> In-Reply-To: From: Huacai Chen Date: Tue, 18 Oct 2022 09:59:09 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V3] LoongArch: Add unaligned access support To: Xi Ruoyao Cc: David Laight , Huacai Chen , Arnd Bergmann , "loongarch@lists.linux.dev" , "linux-arch@vger.kernel.org" , Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Mon, Oct 17, 2022 at 10:20 PM Xi Ruoyao wrote: > > On Mon, 2022-10-17 at 13:11 +0000, David Laight wrote: > > From: Huacai Chen > > > Sent: 17 October 2022 13:52 > > > > > > Loongson-2 series (Loongson-2K500, Loongson-2K1000) don't support > > > unaligned access in hardware, while Loongson-3 series (Loongson-3A5000, > > > Loongson-3C5000) are configurable whether support unaligned access in > > > hardware. This patch add unaligned access emulation for those LoongArch > > > processors without hardware support. > > > > > ..... > > > + } else if (insn.reg2i12_format.opcode == fstd_op || > > > + insn.reg3_format.opcode == fstxd_op) { > > > + value = read_fpr(insn.reg2i12_format.rd); > > > + res = unaligned_write(addr, value, 8); > > > + if (res) > > > + goto fault; > > > + } else if (insn.reg2i12_format.opcode == fsts_op || > > > + insn.reg3_format.opcode == fstxs_op) { > > > + value = read_fpr(insn.reg2i12_format.rd); > > > + res = unaligned_write(addr, value, 4); > > > + if (res) > > > + goto fault; > > > > Are those right? > > Shouldn't something be converting from 'double' to > > 'float' in there? > > And generating SIGFPE (?) if the exponent is out of range. > > To me it looks right. > > The semantic of FST.S does not include conversion. It just stores the > lower 32 bits of a floating-point register into the memory. If someone > attempts to use FST.S to convert a double into a float, it's a > programming error. Agree. > > -- > Xi Ruoyao > School of Aerospace Science and Technology, Xidian University