Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4463222rwi; Mon, 17 Oct 2022 06:39:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4DHjKaBRCFgrfT+PwCbe5v674MGcXjOyH3p6i8hfiZn+uugvqRMX7LL9G3cTaHSGUPgu0d X-Received: by 2002:a65:6955:0:b0:439:a99b:bca5 with SMTP id w21-20020a656955000000b00439a99bbca5mr10792163pgq.80.1666013964006; Mon, 17 Oct 2022 06:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666013964; cv=none; d=google.com; s=arc-20160816; b=iwrNt8oofmfu1A5WdADEdGp8xkr/L9YTJVe8c6527lT+fCeT1PSBdQTiD0PutiOJ4x O+4YxgmkB7TcIBuHIzExS5csVBQBpYqQcmP5CEpY8TJtqA3azihT/y+iiQwZ+Af46trv dvESqpYIZv2kSQEu2S1uJssGyZckjln1ln7wCUXJBLViBjfU9CscCV1vS/dtU/58gJr0 edBWdj2/ssZb43i6fK9iWbc+TteC+Lb7F2hO/XOS/S0PODNLkMK7ab5DvbglrEP/brUb 6VklKmOpRvZmVqor2UEWPqg8nLIuSibarAQgCYyHLJ78VFrZM+9rl0PJXCwmhsnHn9WL BdtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=Tqeo7MbUIWkomf6djozuwMAucc1gVA0T5FM82YGGTT0=; b=IIdPrTZJRxfXpIUEtRY8uWDp0xGMxD4ICMiuycymOthmss8COgj2PpBJWG039l2IvZ L0c/W7zJmzQnCcslmX0fFnSJ4DX65LsNn9Ja3wcfykroZn6BSgAwh9KQcG36Th3RZ4hw X41CgIQQMlVzqTNBXN4E0O3q8PyHf2AYSc6zEm8pxUaRJTEHBPdSDjpQ+Ab3H6dybN/7 qTpW8TLlxyBEmGgQm0gMYag6veLHqy9dQStYJHJhoJUcTgmXe497FM+LnZNqZ2ylpUTe s2NlRGgsWbufS7H+m7bKpM5DzIG+ASWpv8O+v9dJrUATNlJ13jeBXDFShR+fVNHQsez8 +gaA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne12-20020a17090b374c00b0020291c96b13si10464236pjb.121.2022.10.17.06.39.10; Mon, 17 Oct 2022 06:39:23 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbiJQNLf convert rfc822-to-8bit (ORCPT + 99 others); Mon, 17 Oct 2022 09:11:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbiJQNLd (ORCPT ); Mon, 17 Oct 2022 09:11:33 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A96C12BD4 for ; Mon, 17 Oct 2022 06:11:29 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-220-pP_sGcqFMfKL-aotPu7y3w-1; Mon, 17 Oct 2022 14:11:26 +0100 X-MC-Unique: pP_sGcqFMfKL-aotPu7y3w-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 17 Oct 2022 14:11:24 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.042; Mon, 17 Oct 2022 14:11:24 +0100 From: David Laight To: 'Huacai Chen' , Arnd Bergmann , Huacai Chen CC: "loongarch@lists.linux.dev" , "linux-arch@vger.kernel.org" , Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH V3] LoongArch: Add unaligned access support Thread-Topic: [PATCH V3] LoongArch: Add unaligned access support Thread-Index: AQHY4ieF1YXwdHBLG0is9Yy/swO7xa4SjkhQ Date: Mon, 17 Oct 2022 13:11:24 +0000 Message-ID: <39ea2a6fee654b68974ef38237a61e80@AcuMS.aculab.com> References: <20221017125209.2639531-1-chenhuacai@loongson.cn> In-Reply-To: <20221017125209.2639531-1-chenhuacai@loongson.cn> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 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. (And the same for write_fpr().) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)