Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2070584pxa; Sun, 16 Aug 2020 22:49:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoyuWjS3wtCAjfdqLu9Hd2ksv2zk6K0ZbIvKW3EhLADMzMZkC/mNq7wVU9D/jcV79E7IA+ X-Received: by 2002:a17:906:198e:: with SMTP id g14mr13270443ejd.266.1597643385075; Sun, 16 Aug 2020 22:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597643385; cv=none; d=google.com; s=arc-20160816; b=VSmZBN/jp4TN/XkfyZzJaAUCdjHIWPb+FIsmhqiwPUb6ws6Qh732XZ9pCwT/0OLlt0 Plb4R7Xgr1vbiHqbtNuCiExDoLSKj4XXhC3u7C2aYlLl+i3gv8ridhKVG+mUniXN4IUZ 4Gou8Tz/GedIGB1ejXqse+7ZGhflrHZYTPt8pVTzSogDplYEymWi/zTAHlZhmXuFgucb EhG14D/aVHYoQKFbiP14bnQK3UWFQNh9W45wcE7ZqSLL1LeH6FXgnSEe75XJsbLZ+XPQ INubKSdKKpAT3Xh/odvqayeLy2XVGierlyxOBCNRQekXbtTzDymx0Mh66XquJn0fooaz gS0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=CB2oQyAbpWex8VC8PKdfz+9dTRLaxpaTQWif/j+4ZkM=; b=1CuBa8BI4ahxzy6rWtJvlEoMySOGZWqXa+Y4s70JH3jizq1yrNT7ntEneJjDl+Ny+e 04ltI3rSEQzcbeUyDDL8O+H6uBp3SfNgIrghhd1PvP8zlnPD1HIFfwP3blEe6ahXn+Lm s8EyismsEHxznsX7DhOZP/npIUmAxyTZ2Qodav0l6t6y7slup5Xk/261xZ4073dSCZ8M 0stXZgu4M6crf7SnZRdjhGDYt4DIRqImPRBPBZNlZSvljPgIjhDzI8S9LFQscgn34mRb qVwZXkKc6EDRbe9aVKXoSTvWx0YfdbKSXp5xV4H1RTQfSUHSRy2BJGr8jOpwfreAaLfx EIFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si10159782ejc.49.2020.08.16.22.49.22; Sun, 16 Aug 2020 22:49:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726819AbgHQFsD (ORCPT + 99 others); Mon, 17 Aug 2020 01:48:03 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:36056 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbgHQFsA (ORCPT ); Mon, 17 Aug 2020 01:48:00 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4BVNP51ZDlz9tytp; Mon, 17 Aug 2020 07:47:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id QRHWJm_0Kott; Mon, 17 Aug 2020 07:47:53 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4BVNP50bKHz9tytl; Mon, 17 Aug 2020 07:47:53 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DACB58B772; Mon, 17 Aug 2020 07:47:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 6QK3ZqyPopiP; Mon, 17 Aug 2020 07:47:57 +0200 (CEST) Received: from po17688vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.104]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A4F488B75B; Mon, 17 Aug 2020 07:47:57 +0200 (CEST) Received: by po17688vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 68B3465CDD; Mon, 17 Aug 2020 05:47:57 +0000 (UTC) Message-Id: <698df8387555765b70ea42e4a7fa48141c309c1f.1597643221.git.christophe.leroy@csgroup.eu> In-Reply-To: <0eb61cf0dc66d781d47deb2228498cd61d03a754.1597643221.git.christophe.leroy@csgroup.eu> References: <0eb61cf0dc66d781d47deb2228498cd61d03a754.1597643221.git.christophe.leroy@csgroup.eu> From: Christophe Leroy Subject: [PATCH v1 3/4] powerpc/process: Remove useless #ifdef CONFIG_SPE To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 17 Aug 2020 05:47:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cpu_has_feature(CPU_FTR_SPE) returns false when CONFIG_SPE is not set. There is no need to enclose the test in an #ifdef CONFIG_SPE. Remove it. CPU_FTR_SPE only exists on 32 bits. Define it as 0 on 64 bits. We have a couple of places like: #ifdef CONFIG_SPE if (cpu_has_feature(CPU_FTR_SPE)) { do_something_that_requires_CONFIG_SPE } else { return -EINVAL; } #else return -EINVAL; #endif Replace them by a cleaner version: if (cpu_has_feature(CPU_FTR_SPE)) { #ifdef CONFIG_SPE do_something_that_requires_CONFIG_SPE #endif } else { return -EINVAL; } When CONFIG_SPE is not set, this resolves to an unconditional return of -EINVAL Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/cputable.h | 1 + arch/powerpc/kernel/process.c | 21 +++++++-------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h index fdddb822d564..cc21dbcc6794 100644 --- a/arch/powerpc/include/asm/cputable.h +++ b/arch/powerpc/include/asm/cputable.h @@ -165,6 +165,7 @@ static inline void cpu_feature_keys_init(void) { } #else /* CONFIG_PPC32 */ /* Define these to 0 for the sake of tests in common code */ #define CPU_FTR_PPC_LE (0) +#define CPU_FTR_SPE (0) #endif /* diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 360415689f8a..7090c99a60d9 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -413,10 +413,8 @@ static int __init init_msr_all_available(void) msr_all_available |= MSR_VEC; if (cpu_has_feature(CPU_FTR_VSX)) msr_all_available |= MSR_VSX; -#ifdef CONFIG_SPE if (cpu_has_feature(CPU_FTR_SPE)) msr_all_available |= MSR_SPE; -#endif return 0; } @@ -446,10 +444,8 @@ void giveup_all(struct task_struct *tsk) #endif if (usermsr & MSR_VEC) __giveup_altivec(tsk); -#ifdef CONFIG_SPE if (usermsr & MSR_SPE) __giveup_spe(tsk); -#endif msr_check_and_clear(msr_all_available); } @@ -1843,7 +1839,6 @@ int set_fpexc_mode(struct task_struct *tsk, unsigned int val) * fpexc_mode. fpexc_mode is also used for setting FP exception * mode (asyn, precise, disabled) for 'Classic' FP. */ if (val & PR_FP_EXC_SW_ENABLE) { -#ifdef CONFIG_SPE if (cpu_has_feature(CPU_FTR_SPE)) { /* * When the sticky exception bits are set @@ -1857,16 +1852,15 @@ int set_fpexc_mode(struct task_struct *tsk, unsigned int val) * anyway to restore the prctl settings from * the saved environment. */ +#ifdef CONFIG_SPE tsk->thread.spefscr_last = mfspr(SPRN_SPEFSCR); tsk->thread.fpexc_mode = val & (PR_FP_EXC_SW_ENABLE | PR_FP_ALL_EXCEPT); +#endif return 0; } else { return -EINVAL; } -#else - return -EINVAL; -#endif } /* on a CONFIG_SPE this does not hurt us. The bits that @@ -1887,8 +1881,7 @@ int get_fpexc_mode(struct task_struct *tsk, unsigned long adr) { unsigned int val; - if (tsk->thread.fpexc_mode & PR_FP_EXC_SW_ENABLE) -#ifdef CONFIG_SPE + if (tsk->thread.fpexc_mode & PR_FP_EXC_SW_ENABLE) { if (cpu_has_feature(CPU_FTR_SPE)) { /* * When the sticky exception bits are set @@ -1902,15 +1895,15 @@ int get_fpexc_mode(struct task_struct *tsk, unsigned long adr) * anyway to restore the prctl settings from * the saved environment. */ +#ifdef CONFIG_SPE tsk->thread.spefscr_last = mfspr(SPRN_SPEFSCR); val = tsk->thread.fpexc_mode; +#endif } else return -EINVAL; -#else - return -EINVAL; -#endif - else + } else { val = __unpack_fe01(tsk->thread.fpexc_mode); + } return put_user(val, (unsigned int __user *) adr); } -- 2.25.0