Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13478265ybl; Sun, 29 Dec 2019 12:52:43 -0800 (PST) X-Google-Smtp-Source: APXvYqxklImZAPwEVVKVBH1XbqTKYr4zjpoBW87Q5CB5ItGpDsP4V+o0TpuVavUep4usQcHyuVze X-Received: by 2002:a05:6830:596:: with SMTP id c22mr67753598oth.188.1577652763571; Sun, 29 Dec 2019 12:52:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652763; cv=none; d=google.com; s=arc-20160816; b=aLcuUX2SBGxVvENxA2sBwv9RNmApfUj91noNNlDaLerXA9GhtLyG4ZptykIVfhAZHd oDTWFb+d4r4DlFDymQMcNxgP/ens5CiDfT0jYXzDZfbsv1ghabG+NX9Rp+NSfwDqNYKP xu2UqcB3EVwe0XSeuApGnJ4tBTRTQ5HGEqNM4aELSVjigv4yIswSEJgoXioD8mgQ3jiW 2GqVddmNZ/ejTuqG/gd+3EGpfo9KhuuwLyziGvM/rZcf3BU0JQS3sDCHOSVFM64s2e+Q GXstg0N7Tv+n5jrESg10+spjEHj6k1lbq8mVvuWplF3MEkj4Wt7/8fOTJui7jmZBh1Fe 7Tjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=tAjd1uiPZsuPFI/UJM6eJ4os9/hBTboJTt1j2UJRT1M=; b=pieP43Y5zGrVHMcRXwUCLU8o9i/68hXHw47WwY1WV4hNGT7lzHNa7XgNojg90qLr56 3IsYfBGQIdcPPuwdqD9xHNbAmzYZJWk9l+RsSV0p8tqZWVqiiee8NPH2qH6taQh7xywd 324ykyShD52GI7U/7/CyOWpjkjEj0HrkqYah1mJoBxGY35xsrQpJPDGNv5EaPw2e8kPs 25y4gBAM+57mUIsDoJKbFcCs3Dz9wuOrsRe9EDFrAK82/TRKtuPKv8kY0rDWNoQRTdVd za7Ns1xj2SpIn0PCib0JZwY1dpOVD4uhUTq0l5SIjH/s7tMr0nYAB48KQvljXf9L0L96 GYvg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12si17823280oib.254.2019.12.29.12.52.32; Sun, 29 Dec 2019 12:52:43 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727198AbfL2S7Q (ORCPT + 99 others); Sun, 29 Dec 2019 13:59:16 -0500 Received: from mail-pj1-f44.google.com ([209.85.216.44]:37871 "EHLO mail-pj1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726455AbfL2S7Q (ORCPT ); Sun, 29 Dec 2019 13:59:16 -0500 Received: by mail-pj1-f44.google.com with SMTP id m13so7228435pjb.2; Sun, 29 Dec 2019 10:59:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tAjd1uiPZsuPFI/UJM6eJ4os9/hBTboJTt1j2UJRT1M=; b=CZARm84kbG98zgPD5UEbtdUgulL4TlM3icq008J2nAAx+xWwAu+V2hFdpFhNXfRidJ rkVYLty8+lKTh6WWWjKpTE0wHpdl2Cq0gZdYryQFVmlVKTqviKTVl93wzhZxEZhg2Vu3 GfQzxGDwgoazbEkXTYmlDmccSvWGP8ataVVjw9xiQ1ApTKVOvbxTed2MrHojaaxH+qIA DP4s1B05quEMoVNMVhjOF83ExM3F/7N1OuOyxBSQSmBrrQr/43PXrteGwPULwXmRc7mM jQD2QroDMdMEDGNMt52dIEzShskUrMgQX3NQIvAjraxfIWOFBjQtPXGh5L1rtZNL4Nd0 82Gw== X-Gm-Message-State: APjAAAWvphhCHwDDYC/yex8bMfGNHoyLznxTp0/QuXRGNEKdfYkMLPO3 EsgrKaKNqANMvj35WvWeT6c= X-Received: by 2002:a17:902:8f96:: with SMTP id z22mr62219611plo.11.1577645954756; Sun, 29 Dec 2019 10:59:14 -0800 (PST) Received: from localhost ([2601:646:8a00:9810:5af3:56d9:f882:39d4]) by smtp.gmail.com with ESMTPSA id v13sm48565741pgc.54.2019.12.29.10.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:59:13 -0800 (PST) Date: Sun, 29 Dec 2019 11:01:23 -0800 From: Paul Burton To: "Maciej W. Rozycki" Cc: David Laight , "linux-mips@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: RE: [PATCH] MIPS: Use __copy_{to,from}_user() for emulated FP loads/stores Message-ID: <20191229190123.ju24cz7thuvybejs@lantea.localdomain> References: <20191203204933.1642259-1-paulburton@kernel.org> <20191204154048.eotzglp4rdlx4yzl@lantea.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maciej, On Thu, Dec 26, 2019 at 03:01:06AM +0000, Maciej W. Rozycki wrote: > On Wed, 4 Dec 2019, David Laight wrote: > > > We used to have separate get_user_unaligned() & put_user_unaligned() > > > which would suggest that it's expected that get_user() & put_user() > > > require their accesses be aligned, but they were removed by commit > > > 3170d8d226c2 ("kill {__,}{get,put}_user_unaligned()") in v4.13. > > > > > > But perhaps we should just take the second AdEL exception & recover via > > > the fixups table. We definitely don't right now... Needs further > > > investigation... > > > > get/put_user can fault because the user page is absent (etc). > > So there must be code to 'expect' a fault on those instructions. > > As I recall we only emulate unaligned accesses with a subset of integer > load/store instructions (and then only if TIF_FIXADE is set, which is the > default), and never with FP load/store instructions. Consequently I see > no point in doing this in the FP emulator either and I think these ought > to just send SIGBUS instead. Otherwise you'll end up with user code that > works differently depending on whether the FP hardware is real or > emulated, which is really bad. That might simplify things here, but it's incorrect. I'm fairly certain the intent is that emulate_load_store_insn() handles all non-FP loads & stores (though looking at it we're missing some instructions added in r6). More importantly though we've been emulating FP loads & stores since v3.10 which introduced the change alongside microMIPS support in commit 102cedc32a6e ("MIPS: microMIPS: Floating point support."). The commit contains no description of why, and I'm not aware of any reason microMIPS specifically would need this so I suspect that commit bundled this change for no good reason... It's also worth noting that some hardware will handle unaligned FP loads/stores, which means having the emulator reject them will result in more of a visible difference to userland. ie. on some hardware they'll work just fine, but on some you'd get SIGBUS. So I do think emulating them makes some sense - just as for non-FP loads & stores it lets userland not care whether the hardware will handle them, so long as it's not performance critical code. If we knew that had never been used then perhaps we could enforce the alignment requirement (and maybe that's what you recall doing), but since we've been emulating them for the past 6 years it's too late for that now. Thanks, Paul