Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2939227imm; Thu, 24 May 2018 19:29:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoo41Hk1a4JPcQRgHz7FRrcob0qeQQde9D7qrDUBW7zLcDn3Je3rnl+2uPjBQJSiSdZteEz X-Received: by 2002:a17:902:7841:: with SMTP id e1-v6mr568535pln.197.1527215361528; Thu, 24 May 2018 19:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527215361; cv=none; d=google.com; s=arc-20160816; b=aH5YXjcGFji3kBuqmlmWqV1K6iUk/PWNgBqWRMvxmUCNQPa76oZ/fQTQ4urRVxdeCt DAYGw71Ikg6cQoACd8aADpldW1puGO0FOTS2K6qQruBigGn65UvBTFR5a737UVMjPZTK 7n+yfcWAZK018Js2/fbT/9HoyM5+d4LRxkDDOOx7HSTZBFeVIyh0Tg84nh92gRzoiyN3 OyGs2R3GzzemGleOZR7U6Y//xpEKbsQnm+QE9bQvKhkwfhbqkd78GT7pBYwF7t8ME/v+ vhmJlBhljU/uPPAPq7spHLrvTD9A+bJRi88BoT/iJ5LaQZoB0drduXPnlhkzb6UVfO6O oU8A== 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=hUQrp4q9BvHL1cnKQawt02oj9oxtZtFIai3QoI41UOE=; b=fzg1+J9M4Ado/daeNbbfQ5ZXTVWZlOHnvdpo9xTyH0RNvMH88lqGi4rwqEbGwWNZr7 6MXAUlo80H6JCJiP6pml1FpxQ8DgvfwqBYieSEX+xDIU58OYzj8laVPjfw7j3dadyWuT 5S3jaiG/vqx/JqXllx9zKxOIVxhc/6DVkpMCxp+Fd/vzii745XduYATM3/AzWIeh8lLV hVOrbqZ2QjOSsUcq4m0jYm47edrgATroMWCdsH1O4eFYKp36kLezEEF/d7sKFboZn6JJ z71UsIyfO/g8P8m5x0fv5CfS6PQFYgn2gtcVhSvz5NeiTAqA+zwgsdld/hCXKCSxEXUy 4bBw== 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 127-v6si4195647pge.159.2018.05.24.19.29.07; Thu, 24 May 2018 19:29:21 -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 S1031957AbeEXQg1 (ORCPT + 99 others); Thu, 24 May 2018 12:36:27 -0400 Received: from 9pmail.ess.barracuda.com ([64.235.150.224]:58353 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031199AbeEXQgZ (ORCPT ); Thu, 24 May 2018 12:36:25 -0400 Received: from mipsdag01.mipstec.com (mail1.mips.com [12.201.5.31]) by mx2.ess.sfj.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=NO); Thu, 24 May 2018 16:36:18 +0000 Received: from mipsdag02.mipstec.com (10.20.40.47) by mipsdag01.mipstec.com (10.20.40.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Thu, 24 May 2018 09:36:21 -0700 Received: from localhost (10.20.2.29) by mipsdag02.mipstec.com (10.20.40.47) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 24 May 2018 09:36:21 -0700 Date: Thu, 24 May 2018 09:36:17 -0700 From: Paul Burton To: "Maciej W. Rozycki" , James Hogan , Ralf Baechle CC: , , Subject: Re: [PATCH] MIPS: prctl: Disallow FRE without FR with PR_SET_FP_MODE requests Message-ID: <20180524163617.dts46enhigc2yjfo@pburton-laptop> References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180512 X-BESS-ID: 1527179778-298553-3491-57502-1 X-BESS-VER: 2018.6-r1805181819 X-BESS-Apparent-Source-IP: 12.201.5.31 X-BESS-Outbound-Spam-Score: 0.01 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.193318 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.01 BSF_SC0_SA_TO_FROM_DOMAIN_MATCH META: Sender Domain Matches Recipient Domain 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.01 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_SC0_SA_TO_FROM_DOMAIN_MATCH, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maciej, On Tue, May 15, 2018 at 11:04:44PM +0100, Maciej W. Rozycki wrote: > Having PR_FP_MODE_FRE (i.e. Config5.FRE) set without PR_FP_MODE_FR (i.e. > Status.FR) is not supported as the lone purpose of Config5.FRE is to > emulate Status.FR=0 handling on FPU hardware that has Status.FR=1 > hardwired[1][2]. Also we do not handle this case elsewhere, and assume > throughout our code that TIF_HYBRID_FPREGS and TIF_32BIT_FPREGS cannot > be set both at once for a task, leading to inconsistent behaviour if > this does happen. Reviewing the code I think we should actually end up with FR=1 in this case, because neither __own_fpu() nor the FPU emulator depend on the value of TIF_32BIT_FPREGS if TIF_HYBRID_FPREGS is set. So it's not too awful & I don't see the kernel doing anything too crazy, but it definitely isn't what the user asked for. > Return unsuccessfully then from prctl(2) PR_SET_FP_MODE calls requesting > PR_FP_MODE_FRE to be set with PR_FP_MODE_FR clear. This corresponds to > modes allowed by `mips_set_personality_fp'. Looks good to me: Reviewed-by: Paul Burton Thanks, Paul > References: > > [1] "MIPS Architecture For Programmers, Vol. III: MIPS32 / microMIPS32 > Privileged Resource Architecture", Imagination Technologies, > Document Number: MD00090, Revision 6.02, July 10, 2015, Table 9.69 > "Config5 Register Field Descriptions", p. 262 > > [2] "MIPS Architecture For Programmers, Volume III: MIPS64 / microMIPS64 > Privileged Resource Architecture", Imagination Technologies, > Document Number: MD00091, Revision 6.03, December 22, 2015, Table > 9.72 "Config5 Register Field Descriptions", p. 288 > > Cc: stable@vger.kernel.org # 4.0+ > Fixes: 9791554b45a2 ("MIPS,prctl: add PR_[GS]ET_FP_MODE prctl options for MIPS") > Signed-off-by: Maciej W. Rozycki > --- > arch/mips/kernel/process.c | 4 ++++ > 1 file changed, 4 insertions(+) > > linux-mips-set-process-fp-mode-fr-fre.diff > Index: linux/arch/mips/kernel/process.c > =================================================================== > --- linux.orig/arch/mips/kernel/process.c 2018-05-12 22:52:11.000000000 +0100 > +++ linux/arch/mips/kernel/process.c 2018-05-12 23:07:15.147112000 +0100 > @@ -721,6 +721,10 @@ int mips_set_process_fp_mode(struct task > if (value & ~known_bits) > return -EOPNOTSUPP; > > + /* Setting FRE without FR is not supported. */ > + if ((value & (PR_FP_MODE_FR | PR_FP_MODE_FRE)) == PR_FP_MODE_FRE) > + return -EOPNOTSUPP; > + > /* Avoid inadvertently triggering emulation */ > if ((value & PR_FP_MODE_FR) && raw_cpu_has_fpu && > !(raw_current_cpu_data.fpu_id & MIPS_FPIR_F64)) >