Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1680454imm; Thu, 21 Jun 2018 00:21:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKuRxhSLSfyKCe5X6X2JXp8bHdiwOiPfem1eDzS3svJAGtSdSbdbkVWU3FOPthJv+TCV1VW X-Received: by 2002:a17:902:1081:: with SMTP id c1-v6mr27192747pla.153.1529565719553; Thu, 21 Jun 2018 00:21:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529565719; cv=none; d=google.com; s=arc-20160816; b=ckwJRId7kT9orlTk2tNbA0Hs2yqbG2hR1udFrwHC15w2do9SZjHdFWL9lzqX+nl7Tf qEBw0I5jN1k5hwRQ0o+HRxx5oc234235zWXWXrwXlB+67KQDyDjQWSSzS37tVJ7lQGKW maE/hb1vax8EXJxfpkA7lB11nONj1oq0yfOCmVwTLPu8oVxTyLd7qLui3u6nbuC/vz3U EnM0g4vjk9h8S1Qrlx0vnLoWKSdNO6svyv2QtG2HoKmz1086kM6b7Zy7+rMyvoyhZRHv Bh571cYCkuc/FOmOTjszJjBvYFslUTQrQ6hmCw0jVhEgABEUjIqj2D8Lh17QvboD4SH9 Qa9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=mkkNsCNckfY0SaehoH8ak8v8aOPrf4ib5GuNu2XASr8=; b=Ch2tKA7O0fzFEn6yWEw7JzkzEjRSaBJl1mgNntmDAkHBWwKKQArsgS4Ip+2LR4HVj+ bl4fRbobsdgOpdxh/fgD9wWfzutZ1MqDINIfFEUSaIuR/DNuhDi1QPu1F3zRiM8nmvR5 /muYS/EHvVcZneKz/EX48HChmePPhA29jsgPRramikj+gYxB5UHuD+u6g13xQIaZ0/uA 0uo4kGF1CMVqa6jtn+99fCCtmwk/iyyi7er9CaXjAIYbtoPYFzSzOfLLDd7gFcmqVwnP BF/3KbNizc5FF+1qWcPsbMhZlzaDQYexlr+sRrcHFT/wHUsuuvLl1op1bMroFYvYMdcE VUhw== 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 r63-v6si3950916plb.366.2018.06.21.00.21.44; Thu, 21 Jun 2018 00:21:59 -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 S1754259AbeFUHUL (ORCPT + 99 others); Thu, 21 Jun 2018 03:20:11 -0400 Received: from exmail.andestech.com ([59.124.169.137]:11558 "EHLO ATCSQR.andestech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754204AbeFUHUK (ORCPT ); Thu, 21 Jun 2018 03:20:10 -0400 Received: from mail.andestech.com (atcpcs16.andestech.com [10.0.1.222]) by ATCSQR.andestech.com with ESMTP id w5L7Irrw083498; Thu, 21 Jun 2018 15:18:53 +0800 (GMT-8) (envelope-from alankao@andestech.com) Received: from andestech.com (10.0.1.85) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.123.3; Thu, 21 Jun 2018 15:19:15 +0800 Date: Thu, 21 Jun 2018 15:19:16 +0800 From: Alan Kao To: Christoph Hellwig CC: Greentime Hu , Palmer Dabbelt , , Zong Li , Albert Ou , Subject: Re: [PATCH] riscv: Add support to no-FPU systems Message-ID: <20180621071915.GA5053@andestech.com> References: <1529544276-28103-1-git-send-email-alankao@andestech.com> <20180621063938.GB19319@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180621063938.GB19319@infradead.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [10.0.1.85] X-DNSRBL: X-MAIL: ATCSQR.andestech.com w5L7Irrw083498 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 20, 2018 at 11:39:38PM -0700, Christoph Hellwig wrote: > > +ifeq ($(CONFIG_FPU),y) > > KBUILD_AFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_ARCH_A)fd$(KBUILD_ARCH_C) > > +else > > +KBUILD_AFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_ARCH_A)$(KBUILD_ARCH_C) > > +endif > > Can we refactor that KBUILD_ARCH code into something like > > riscv-march-y := > riscv-march-$(CONFIG_ARCH_RV32I) += rv32im > riscv-march-$(CONFIG_ARCH_RV64I) += rv64im > riscv-march-$(CONFIG_RISCV_ISA_A) += a > riscv-march-$(CONFIG_FPU) += fd > riscv-march-$(CONFIG_RISCV_ISA_C) += c > > KBUILD_CFLAGS += -march=$(riscv-march-y) > That's neat, sure. > > +#ifdef CONFIG_FPU > > regs->sstatus = SR_SPIE /* User mode, irqs on */ | SR_FS_INITIAL; > > +#else > > + regs->sstatus = SR_SPIE | SR_FS_OFF; > > +#endif > > Having the comment in one branch, but not the other is odd. I'd be > tempted to just remove t entirely, but if not it should be move up > or duplicated. > I'll move that comment up. > > int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) > > { > > +#ifdef CONFIG_FPU > > fstate_save(src, task_pt_regs(src)); > > +#endif > > Please provide a !CONFIG_FPU stub for fstate_save, please. > > > } It's OK to do this to fstate_save/restore, and > > +#endif > > > > static long restore_sigcontext(struct pt_regs *regs, > > struct sigcontext __user *sc) > > @@ -63,6 +65,7 @@ static long restore_sigcontext(struct pt_regs *regs, > > err = __copy_from_user(regs, &sc->sc_regs, sizeof(sc->sc_regs)); > > if (unlikely(err)) > > return err; > > +#ifdef CONFIG_FPU > > /* Restore the floating-point state. */ > > err = restore_d_state(regs, &sc->sc_fpregs.d); > > if (unlikely(err)) > > @@ -76,6 +79,7 @@ static long restore_sigcontext(struct pt_regs *regs, > > if (value != 0) > > return -EINVAL; > > } > > +#endif > > Same here. > it's also OK to do so to restore_d_state/save_d_state. But what to do with the following __get_user/__put_user calls? Can I rename existing restore_d_state to __restore_d_state, and create a new function restore_d_state which includes the original restore_d_state/__get_user pair, and the same to save_d_state? > > @@ -127,11 +131,13 @@ static long setup_sigcontext(struct rt_sigframe __user *frame, > > size_t i; > > /* sc_regs is structured the same as the start of pt_regs */ > > err = __copy_to_user(&sc->sc_regs, regs, sizeof(sc->sc_regs)); > > +#ifdef CONFIG_FPU > > /* Save the floating-point state. */ > > err |= save_d_state(regs, &sc->sc_fpregs.d); > > /* We support no other extension state at this time. */ > > for (i = 0; i < ARRAY_SIZE(sc->sc_fpregs.q.reserved); i++) > > err |= __put_user(0, &sc->sc_fpregs.q.reserved[i]); > > +#endif > > Same here. > Thanks, Alan