Received: by 10.223.148.5 with SMTP id 5csp5965803wrq; Wed, 17 Jan 2018 07:51:18 -0800 (PST) X-Google-Smtp-Source: ACJfBovWCR1LyzgZ47kWcplsoY6u7DXdHduVWx9eJsPnO1nJ4JcKgGQ8dTOkUXi40OqGcfLfekVg X-Received: by 10.99.108.8 with SMTP id h8mr10921107pgc.46.1516204278394; Wed, 17 Jan 2018 07:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516204278; cv=none; d=google.com; s=arc-20160816; b=dhcY/WhhT4xx4ph4WrmvZDiu1RCzqpzl02DNVeOWJLG27cAJV38LxUObxSuYSPrWNY IzmSpvAqMEuwm4UjWiUK9JPhdAOKvDfn/k68U4aOyjNSmpqAN7KUgPKRQ/xNX5ZANxlv ER60TLHKIQYzb6xHFazOv4+/bDjyGRH9e8jVqAgakmV9F/eNoINDzYRx1TecDEzOQxZH DMCoSR4HG6vAKM7wn1SXzEFzb8MltBZ/+oN6F3RQip/zdo103ykZWFLpBngMK0hgQW8x FnYHaZCFl376FfHeYLzFFjkWv9fmjH+YZzVY7BR+T5+0imvq6Al81rvpQnTZ+BK/QAK3 h/aA== 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:dkim-signature:arc-authentication-results; bh=S4lJciVcAD1PljNQVtV2IDZSNr9nvgfG41Ue7yERcEw=; b=THlvlcUsic5TULJ8lW3YMVr8+jLrBC4QBXqH9joL+HMT2Zu3ZhMOivYhTgVC41mbI2 7mo6UVbasX2GgVew9sNP43+h9dVz81EWGEJlUZlyBVROG0x/hUUTJZgyTJ2mYscPfln9 cgzGGSIkVNe/lo0lUAydMt7pxlgle1DGKlfZSmXBgvDMp5I8ScwITfcGfsjCjS2izNr6 vZnvANUu9a92kzlhDwxY7FPttQEBK/eXgtFx5NWEKhHNgFPO0JY9blZHzWybEjRvk8RM m1s10PQk+PBOx/BLUP/y/k9EF7KHz1osP1xzrQsp/6GWcmXlvybW1XurKQGu3pPAHoSf i9qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=Uh7c8BlR; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2si4696386plj.712.2018.01.17.07.51.04; Wed, 17 Jan 2018 07:51:18 -0800 (PST) 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; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=Uh7c8BlR; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753822AbeAQPuR (ORCPT + 99 others); Wed, 17 Jan 2018 10:50:17 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:57020 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753636AbeAQPuP (ORCPT ); Wed, 17 Jan 2018 10:50:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=S4lJciVcAD1PljNQVtV2IDZSNr9nvgfG41Ue7yERcEw=; b=Uh7c8BlRL5/aH4NgftXyqEctWV8V/hzM3BDaOaSZLAl0NZJ/6ZGY/ixEzClsf4qk/HfCZMKW0qy6qx4EaxHYyyhtEMkuQYk+FO1OfCdiJ+SyoclWF8DtLr6gNZCiE8Ykl7oVQrfzTZZjcUeZh51wIsPh1peqEHBLTV1Yc1IlSvQ=; Received: from n2100.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:4f86]:51553) by pandora.armlinux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1ebpyY-0006vH-Lx; Wed, 17 Jan 2018 15:50:06 +0000 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.76) (envelope-from ) id 1ebpyR-0004r0-RL; Wed, 17 Jan 2018 15:49:59 +0000 Date: Wed, 17 Jan 2018 15:49:59 +0000 From: Russell King - ARM Linux To: Dave Martin Cc: linux-arch@vger.kernel.org, Arnd Bergmann , Nicolas Pitre , Tony Lindgren , Catalin Marinas , Tyler Baicar , Will Deacon , linux-kernel@vger.kernel.org, Oleg Nesterov , James Morse , "Eric W. Biederman" , Olof Johansson , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, Al Viro Subject: Re: [PATCH 07/11] signal/arm64: Document conflicts with SI_USER and SIGFPE, SIGTRAP, SIGBUS Message-ID: <20180117154959.GP17719@n2100.armlinux.org.uk> References: <87373b6ghs.fsf@xmission.com> <20180112005940.23279-7-ebiederm@xmission.com> <20180115163028.GU22781@e103592.cambridge.arm.com> <87h8rnox3c.fsf@xmission.com> <20180116172407.GA22781@e103592.cambridge.arm.com> <871sipl9p9.fsf@xmission.com> <20180117115708.GM17719@n2100.armlinux.org.uk> <20180117121505.GD22781@e103592.cambridge.arm.com> <20180117123752.GN17719@n2100.armlinux.org.uk> <20180117153731.GG22781@e103592.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180117153731.GG22781@e103592.cambridge.arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 17, 2018 at 03:37:31PM +0000, Dave Martin wrote: > On Wed, Jan 17, 2018 at 12:37:52PM +0000, Russell King - ARM Linux wrote: > > On Wed, Jan 17, 2018 at 12:15:05PM +0000, Dave Martin wrote: > > > On Wed, Jan 17, 2018 at 11:57:09AM +0000, Russell King - ARM Linux wrote: > > [...] > > > > > VFP used to use force_sig_info(), but it seems to be really the wrong > > > > call to use. force_sig_info() checks whether the program decided to > > > > ignore or block the signal, and if it did, replaces the signal handler > > > > with the default handler and unblocks the signal. > > > > > > > > Are you really suggesting that FP all FP signals should get this > > > > treatment? > > > > > > feenableexcept(FE_OVERFLOW) kind of means "I can't run safely past > > > an fp overflow exception, please signal me instead". > > > > > > If the process also blocked SIGFPE, that could be taken to mean > > > "I can't run safely past an fp overflow exception _and_ I can't > > > take SIGFPE either" ... i.e., if an fp overflow happens there is > > > no way to proceed and it's really fatal. > > > > > > What SIG_IGN ought to mean is rather more debatable, but again, > > > the process could be asking for two opposite things: guarantee a > > > SIGFPE is delivered instead of running past an fp exception, and > > > also guarantee that SIGFPE is _not_ delivered. > > > > > > It looks like arm and arm64 are different from most other arches > > > (including x86) here, but I'm not sure what is considered correct, and > > > it looks like the answer is not standardised. There's a possibility > > > that some software goes subtly wrong on arm/arm64 where on other arches > > > it would get terminated with SIGKILL. > > > > > > Whether this matters depends on how harmless the fp exception is to > > > the work of the program. I think if an exception is set to trap > > > via feenableexcept() then that's a strong hint the programmer thinks > > > that exception is not harmless. OTOH, trapping is not always > > > available anyway... > > > > Like many of these things, there is no clear answer. It's a set of > > conflicting requirements, and as you point out, even if you've called > > feenableexcept(), you are not guaranteed to get a trap. > > > > However, do remember that FP exceptions on ARM hardware are already > > asynchronous - they get reported by the _next_ FP operation to the one > > that caused them, which means they could be raised by a library function > > sometime after it occured (when the library function decides to save the > > FP registers to the stack before it makes use of them.) It's entirely > > possible that the library function has blocked FP signals temporarily > > (not explicitly, just decided to block all signals while it does > > something sensitive) and will unblock them again afterwards - at which > > point we get the SIGFPE, and it would be quite right to deliver that > > signal to the user SIGFPE handler, rather than forcing it onto the > > program mid-library function. > > > > It's also possible that SIGFPE could be blocked by another signal handler > > having been invoked, and it triggers the latent generation of the SIGFPE. > > > > I'd be more inclined to agree with you if VFP exceptions were synchronous > > but they aren't. > > Hmmm, it looks like imprecise fp exception traps are disallowed from > ARMv8 onwards. I guess they made more sense when the FPU really was a > coprocessor, or at least semidetached from the integer core. > > I think force_sig_info() makes sense here if and only if the traps > are guaranteed to be precise, so we probably should use this on arm64. > Not arm though (alpha doesn't either, if I understand the code > correctly.) > > Does that make sense? > > Apparently, few recent cores (at least ARM's own ones) support fp > exception trapping anyway... 1176 may be the most recent. ... and that makes the feenableexcept() argument about "A program really wants to know" moot. It can enable the exceptions in the FPSCR but its never going to receive a SIGFPE on CPUs that don't do exception trapping. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up