From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f46.google.com (mail-yx1-f46.google.com [74.125.224.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93B43395AE9 for ; Mon, 3 Aug 2026 23:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785800453; cv=none; b=VPWPUL3mdJ9dBoS0hWLacvY1vh3d6N6FzaCJxeOEKp+WWbQIwZ2Z/lPgxD8HadBxFG/DEzkNlvAO/J57MGQXt92klv6GJcLmOlnIRudLfM99jgmN4d0ODcQsjCe95ihTWgvVRXDjgyECHv9msP1YgC8sWXtKOAyNfmml7rNon3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785800453; c=relaxed/simple; bh=YZg1odxiWek0UxsP57a8f13DBqPUmymS1YIGamKZW+Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Sa3RMqxvc+GQgw/A83JNzTHnUsr7NzZ4xusXlhTDyM7xhy4y4Ad3CHEuAbaFgpZnBpSwrvKNJwff/MxZLnnQhuh/UvyrtacQOrqp6+opxJTPWK1mjzC0neXsSNnKqwdmU/OPWFOHveGlIAGcuxNAfsUUOL1nX5cI3rRMQCNGqmE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B06zjzZI; arc=none smtp.client-ip=74.125.224.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B06zjzZI" Received: by mail-yx1-f46.google.com with SMTP id 956f58d0204a3-667971437d6so5502859d50.2 for ; Mon, 03 Aug 2026 16:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785800449; x=1786405249; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iXt2lHl6V6DYOxKrsChpRVwvJNwCDOvF3knLtupIoSg=; b=B06zjzZIb4DrxrL4KvqLlHDn9RGSsjwqhOhkwKhmOUr9TLQKClY+YqrK7vqY70jjEJ PwgsgeL7uh2DbOLRXvkOgG1AwXVmafNqOf7G1692yDq4+UHUuOeNnisRffLMVcmfE6QC LLGxOaqZUWJDebuW0nkJKWitu7udF1/8aPzTjtBPkCbymJ/Hxp1FEOumvUBBj/OE8dOT u/2iwVKLoECCOPnyy0E+vV8pKFBdbGJnhreHvqGYuX0BFucddECVDaCwsyw2z6oobVsu lNn/1muTrj3YbiRuvVBLIm9IkZIqAH+VHQ3PBfvD9oW7FU3LvpIBG4t0xbZl6UpNtexw CVBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785800449; x=1786405249; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=iXt2lHl6V6DYOxKrsChpRVwvJNwCDOvF3knLtupIoSg=; b=R7xHg/jodEMsVy1+SoeaGZDEfeAbZkv/itqkDSdgPcdFFAq1qTtmcEI4YJrRTlCXzq h409jIoRxWdBFcD1T6teor3G0SLmRcJr6OD9j+RCsFzlNqIayEumeWF+lWX/3cWbrdrs KyYQHh5rTLvuAV6Ws1+b458V7B/9ms+PXBEXCe3FFnsXChWD6hDBmbBezQE2aWB5wBfn FlBI8kLAL2xN87T4n02LDYgVx1aV6fm3g07e+ZdBXCr2IGL9SB/D2MrCrpFQhP3FLyVY cWtsfVmzDWjWHKtUTuspEmTCMv/DkWFTkUDoRCfAsMWawEhX86HUSEcbRgnqtBXQkck8 VqbA== X-Forwarded-Encrypted: i=1; AHgh+RqDuMgG1Zk+cVyy08CIpkQK3bNhSnDyk3XFABE1xNfeMjrGbFlDMuz1i5wDYENgHge+OtOpR+CiAQXxagQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxQuFNYcvdt9KMrZ3RAazXz2pj2ZgrjIIF27lD0yTOz+gkfDbYy u15AGymPuuRkWlwsNZKCgefr0UqzOsFUnhrXIYWWqYNGz10wRBz4TcDJ X-Gm-Gg: AR+sD127oWwP+1MWbnxM2bo2he9MYvahWXmFRWvsC3FQFIGuvVXkTh7TzEQC8WsZ2+M 9haKD0o5CV0knL8INNpoKOT6AinUkftF0ZNyMm/brcuNnmKCAo1S5DAJ8A2SltkoW+1qiEj2m2w mKW2wqkxeHAMdB0MiwO7vhTQUxAxQgAm4Bq4zIlWEPfP3r68eJ9JTyAVMtNoR58LzDAi2fV5svh tF2Mn61c7NrtJ6OopNEDi1UquNWBEiyrQimGvM1ncU9Gysun1IKs5hCVjYX+8hU6ZYxs+5BZSYE 6B725gcccvDr5q88CAduHV3zYnrUPdFZni38TzJ5MkrD+Id85pVjqDa21esHNX6+0sBcOTwY/Zu txn71xoG0b+hcal44euuXLiKrzjENtfb/jgDgx8OAXS4Q3oGlEQLlsNNdo+p3dgeS3kjsTS9zts pw3ZYX7PDDcoQt7g3YYiDdHHCzzZjVjUmurtLXlROtu8mLKwDGnuG3saXQs80xKHk5kNIAcjw= X-Received: by 2002:a05:690e:480a:b0:668:8f89:762 with SMTP id 956f58d0204a3-6694efd03bamr9722268d50.1.1785800449430; Mon, 03 Aug 2026 16:40:49 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-66948b98babsm6681712d50.0.2026.08.03.16.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 16:40:48 -0700 (PDT) From: Matt Turner Date: Mon, 03 Aug 2026 19:40:45 -0400 Subject: [PATCH 1/3] alpha: fix ieee_swcr_to_fpcr setting FPCR_DNOD unconditionally Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260803-alpha-fp-exceptions-v1-1-c99d75608e60@gmail.com> References: <20260803-alpha-fp-exceptions-v1-0-c99d75608e60@gmail.com> In-Reply-To: <20260803-alpha-fp-exceptions-v1-0-c99d75608e60@gmail.com> To: Richard Henderson , Matt Turner , Magnus Lindholm Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, "David S. Miller" , Andreas Larsson , stable@vger.kernel.org X-Mailer: b4 0.14.3 ieee_swcr_to_fpcr() converts the software IEEE trap-enable and status bits kept in thread_info.ieee_state into the hardware FPCR format. It contained: fp |= (~sw & IEEE_TRAP_ENABLE_DNO) << 41; FPCR_DNOD (bit 47) disables denormal operand traps: with it set the hardware handles a denormal operand itself, treating it as zero, instead of trapping for software completion. The intent was to set DNOD when the user has not asked for SIGFPE on denormal operands, but IEEE_TRAP_ENABLE_DNO is clear by default, so ieee_swcr_to_fpcr(0) always set DNOD. Instructions built with the software completion suffix therefore never trapped on a denormal operand. The hardware silently substituted zero and produced wrong results, affecting every program compiled with -mieee and default FPU settings, glibc included. Set FPCR_DNOD only when IEEE_MAP_DMZ is requested, which is exactly the case where flushing denormal inputs to zero is what the user asked for. DNOD then encodes MAP_DMZ, which ieee_fpcr_to_swcr() already recovers from FPCR_DNZ, so drop its attempt to recover IEEE_TRAP_ENABLE_DNO from DNOD; the DNO trap enable lives solely in ieee_state. Both functions are in a uapi header, so the encoding change is visible to userspace, but nothing outside the kernel is known to depend on DNOD carrying the DNO trap enable, and the kernel is the only writer of the FPCR. This must not be backported on its own. Re-enabling denormal operand traps exposes a second bug, fixed in the following patch: those traps usually find an exact result, and for an exact result the emulator did not write the FPCR back, leaving hardware-fabricated exception bits visible to user space. Taken alone this change would make spurious exception flags more common. The bug predates the git history, so there is no commit to reference in a Fixes tag. Cc: stable@vger.kernel.org # 5.15+ Signed-off-by: Matt Turner --- arch/alpha/include/uapi/asm/fpu.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/alpha/include/uapi/asm/fpu.h b/arch/alpha/include/uapi/asm/fpu.h index cea9eafa056f..d28dc36786e2 100644 --- a/arch/alpha/include/uapi/asm/fpu.h +++ b/arch/alpha/include/uapi/asm/fpu.h @@ -101,7 +101,12 @@ ieee_swcr_to_fpcr(unsigned long sw) | IEEE_TRAP_ENABLE_OVF)) << 48; fp |= (~sw & (IEEE_TRAP_ENABLE_UNF | IEEE_TRAP_ENABLE_INE)) << 57; fp |= (sw & IEEE_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0); - fp |= (~sw & IEEE_TRAP_ENABLE_DNO) << 41; + /* + * Disable denormal operand traps only when denormal inputs are to be + * flushed to zero. Otherwise they must keep trapping, so that /S + * instructions reach the kernel emulation handler. + */ + fp |= (sw & IEEE_MAP_DMZ ? FPCR_DNOD : 0); return fp; } @@ -116,7 +121,6 @@ ieee_fpcr_to_swcr(unsigned long fp) | IEEE_TRAP_ENABLE_OVF); sw |= (~fp >> 57) & (IEEE_TRAP_ENABLE_UNF | IEEE_TRAP_ENABLE_INE); sw |= (fp >> 47) & IEEE_MAP_UMZ; - sw |= (~fp >> 41) & IEEE_TRAP_ENABLE_DNO; return sw; } -- 2.54.0