Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp506316imd; Thu, 1 Nov 2018 00:32:17 -0700 (PDT) X-Google-Smtp-Source: AJdET5dLKTHSpfe7d/FIk8pcRbaXXJTbAsKGDnWQSw1/PNgU6fO749m2VZUI3x9UFTKC2syZMpGH X-Received: by 2002:a17:902:1ab:: with SMTP id b40-v6mr6704890plb.82.1541057537268; Thu, 01 Nov 2018 00:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541057537; cv=none; d=google.com; s=arc-20160816; b=XupYEZ5br5KdbKwdtVgVMvAbS0sZsJCfoy+dM3GxJ6y7EgIpmJ2hYYNoeQLbhkO7bh BV4aQ+KgcopS3QyBDZYkEzkP/XknEl/YtfCWlTymhaZruWNoiNuhhpkqZxy+xWpEk/vE 4Y0toyM44vWqcdTBOpYDmKb/nzlGp6teTmsPJ54IWExxjQVJ6YqErZL0n0xIHQFfDNHO crMCCrzxUc08lT0AjeKP7TT53qDPy6k3y0KrwRrZb5WlfbF/c3WQUs7bPeaGTJ7JD/cu cURXSpK2Bs3GhorQqtV6URfAdarW7v9WJRqfRT6Q+NunojdtyGWwBvDv5bYL8SLDJs9/ 0GWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=BHZTwzT1AqZSRQEzvW6fRp+/BnXzzDFBGzg16AGJJWc=; b=gSvYZ7Qn50PczirdCtRWFpiHKAY7aCS99e7JL8BEb7Mttduzwrf3ft2fqTp+h0jPDM b6Da6JYznoFiWKEg4I8Q5BVyUJudPO/PWlRITCCmfUpOzd3edwXBLflH3jyjQlXghRw5 Q/1QhqYCdpSXrdTzIp51bYxlw5XTxs3tAzBzpdaTriMx/4RDQke1JYSWTd6wNt9m5vmP dti8oDsQRfZsWj9v+O6sadhVWbMzQ4KI+jgRkmqOcAIRfgneSGzl73+JzjD7LrJAITzv EdDyJpV+dFdLBRLUNJPQLGtdgliNu9Agrqzas/mqy3Z6jm4mlAb00Jy0mUxgS3qxxdO6 MWgA== 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 b9-v6si30604894pgl.446.2018.11.01.00.32.02; Thu, 01 Nov 2018 00:32:17 -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 S1727999AbeKAQTF (ORCPT + 99 others); Thu, 1 Nov 2018 12:19:05 -0400 Received: from 59-120-53-16.HINET-IP.hinet.net ([59.120.53.16]:58609 "EHLO ATCSQR.andestech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727788AbeKAQTE (ORCPT ); Thu, 1 Nov 2018 12:19:04 -0400 Received: from mail.andestech.com (atcpcs16.andestech.com [10.0.1.222]) by ATCSQR.andestech.com with ESMTP id wA17HwGi070150; Thu, 1 Nov 2018 15:17:58 +0800 (GMT-8) (envelope-from vincentc@andestech.com) Received: from atcsqa06.andestech.com (10.0.15.65) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.123.3; Thu, 1 Nov 2018 15:17:05 +0800 From: Vincent Chen To: , CC: , , Subject: [PATCH v3 0/5] nds32 FPU port Date: Thu, 1 Nov 2018 15:16:56 +0800 Message-ID: X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.15.65] X-DNSRBL: X-MAIL: ATCSQR.andestech.com wA17HwGi070150 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch set contains basic components for supporting the nds32 FPU, such as exception handlers and context switch for FPU registers. By default, the lazy FPU scheme is supported and the user can configure it via CONFIG_LZAY_FPU. In addition, a floating point emulator is required to handle all arithmetic of denormalized number because it is not supported by the nds32 FPU. As mentioned above, the nds32 FPU does not support denormalized number This means the denormalized operands and results are not permitted. If an instruction contains denormalized operands, the nds32 FPU will raise an denormalized input exception to inform kernel to deal with this instruction. If the result of the instruction is a denormalized number, normally nds32 FPU will treat it as an underflow case and round the result to an appropriate value based on current rounding mode. Obviously, there is a precision gap for tininess number. To reduce this precision gap, kernel will enable the underflow trap by default to direct all underflow cases to the floating pointer emulator. By the floating pointer emulator, the correct denormalized number can be derived in kernel and return to the user program. The feature can be configured by CONFIG_SUPPORT_DENORMAL_ARITHMETIC, and if the precision requirement is not critical for tininess number, user may disables this feature to keep performance. The implementation of floating point emulator is based on soft-fp which is located in include/math-emu folder. However, soft-fp is too outdated to pass the current compiler check. The needed modifications for soft-fp are included in this patch set Changes in v3: - Kernel with FPU support enabled still can run on a CPU without FPU - Rename CONFIG_UNLAZY_FPU to CONFIG_LAYZ_FPU - Rename _switch() to _switch_fpu() - Store FPU context when kernel suspends - Modify the comments in code and patch Changes in v2: - Remove the initilzation for floating pointer register before entering to signal handler. Vincent Chen (5): nds32: nds32 FPU port nds32: Support FP emulation nds32: support denormalized result through FP emulator math-emu/op-2.h: Use statement expressions to prevent negative constant shift math-emu/soft-fp.h: (_FP_ROUND_ZERO) cast 0 to void to fix warning arch/nds32/Kconfig | 1 + arch/nds32/Kconfig.cpu | 34 +++ arch/nds32/Makefile | 11 + arch/nds32/include/asm/bitfield.h | 15 ++ arch/nds32/include/asm/elf.h | 11 + arch/nds32/include/asm/fpu.h | 126 +++++++++++ arch/nds32/include/asm/fpuemu.h | 32 +++ arch/nds32/include/asm/nds32_fpu_inst.h | 109 +++++++++ arch/nds32/include/asm/processor.h | 7 + arch/nds32/include/asm/sfp-machine.h | 158 +++++++++++++ arch/nds32/include/asm/syscalls.h | 1 + arch/nds32/include/uapi/asm/auxvec.h | 7 + arch/nds32/include/uapi/asm/sigcontext.h | 14 ++ arch/nds32/include/uapi/asm/udftrap.h | 13 + arch/nds32/include/uapi/asm/unistd.h | 2 + arch/nds32/kernel/Makefile | 10 + arch/nds32/kernel/ex-entry.S | 24 ++- arch/nds32/kernel/ex-exit.S | 13 +- arch/nds32/kernel/ex-scall.S | 8 +- arch/nds32/kernel/fpu.c | 269 ++++++++++++++++++++++ arch/nds32/kernel/process.c | 64 +++++- arch/nds32/kernel/setup.c | 12 +- arch/nds32/kernel/signal.c | 62 +++++- arch/nds32/kernel/sleep.S | 2 + arch/nds32/kernel/sys_nds32.c | 32 +++ arch/nds32/kernel/traps.c | 16 ++ arch/nds32/math-emu/Makefile | 7 + arch/nds32/math-emu/faddd.c | 24 ++ arch/nds32/math-emu/fadds.c | 24 ++ arch/nds32/math-emu/fcmpd.c | 24 ++ arch/nds32/math-emu/fcmps.c | 24 ++ arch/nds32/math-emu/fd2s.c | 22 ++ arch/nds32/math-emu/fdivd.c | 27 +++ arch/nds32/math-emu/fdivs.c | 26 +++ arch/nds32/math-emu/fmuld.c | 23 ++ arch/nds32/math-emu/fmuls.c | 23 ++ arch/nds32/math-emu/fnegd.c | 21 ++ arch/nds32/math-emu/fnegs.c | 21 ++ arch/nds32/math-emu/fpuemu.c | 357 ++++++++++++++++++++++++++++++ arch/nds32/math-emu/fs2d.c | 23 ++ arch/nds32/math-emu/fsqrtd.c | 21 ++ arch/nds32/math-emu/fsqrts.c | 21 ++ arch/nds32/math-emu/fsubd.c | 27 +++ arch/nds32/math-emu/fsubs.c | 27 +++ include/math-emu/op-2.h | 97 ++++----- include/math-emu/soft-fp.h | 2 +- 46 files changed, 1827 insertions(+), 67 deletions(-) create mode 100644 arch/nds32/include/asm/fpu.h create mode 100644 arch/nds32/include/asm/fpuemu.h create mode 100644 arch/nds32/include/asm/nds32_fpu_inst.h create mode 100644 arch/nds32/include/asm/sfp-machine.h create mode 100644 arch/nds32/include/uapi/asm/udftrap.h create mode 100644 arch/nds32/kernel/fpu.c create mode 100644 arch/nds32/math-emu/Makefile create mode 100644 arch/nds32/math-emu/faddd.c create mode 100644 arch/nds32/math-emu/fadds.c create mode 100644 arch/nds32/math-emu/fcmpd.c create mode 100644 arch/nds32/math-emu/fcmps.c create mode 100644 arch/nds32/math-emu/fd2s.c create mode 100644 arch/nds32/math-emu/fdivd.c create mode 100644 arch/nds32/math-emu/fdivs.c create mode 100644 arch/nds32/math-emu/fmuld.c create mode 100644 arch/nds32/math-emu/fmuls.c create mode 100644 arch/nds32/math-emu/fnegd.c create mode 100644 arch/nds32/math-emu/fnegs.c create mode 100644 arch/nds32/math-emu/fpuemu.c create mode 100644 arch/nds32/math-emu/fs2d.c create mode 100644 arch/nds32/math-emu/fsqrtd.c create mode 100644 arch/nds32/math-emu/fsqrts.c create mode 100644 arch/nds32/math-emu/fsubd.c create mode 100644 arch/nds32/math-emu/fsubs.c