Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2107682imu; Sun, 16 Dec 2018 17:11:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/XmcJvBb+TLgAJlsdbV/fjKYCkDTdIeRBGjLeLUOJY4uKglrCUTI+ueTgXDlDJDydG9L9zH X-Received: by 2002:a62:61c3:: with SMTP id v186mr11179016pfb.55.1545009099467; Sun, 16 Dec 2018 17:11:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545009099; cv=none; d=google.com; s=arc-20160816; b=ZJjbPUw3dwRCqu8l4jbdaAX9Of9COkpcZmZonQWs6XHyLpt0GPkq5Aa24Njha3HqfV JefQXns9vN7d/DtNVND9PQtGqq7NyfIwmH/T8PBtw21mpZfuQ2conOAZDSkQEIpZHK+C VWywF2WGtZaR7Wgvtb6c4arUtd9p8nASdOmxzixaIwXqFhTu/74lEXjxneYsumzhHzkA LHg/Tzv7fPFSAK6MKW2V8Qz4zlMX2w4+sGeREj4utq1gINsXKqReNUKN08PZN0MUAfOv 42DQC/lulDx+hkaGBdonHu2Q6I8qm+SWXvIW8DYbw9iNlT6glSLnD8p0ONyKaDCtF9nC HWHg== 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; bh=RLBzhPcHCw5y23X2c8XISTny6O88CKddvLaAMCWvl7E=; b=hL9PPRN7BwRvWe4TLSOKTU7EgjDMNYHvmDhWTOxXSn0k1M/Zn2mhqGyxTvYliz2BVa EGXtB4fYG4O7sLKJx8S70j5kQrGZteNBlDmlGhnLhKt6J89cB2qbrRQV6dKO+KbvUaoh hNoHcizYYKVKMrLIGroHYEkUFhVpEWWoMQ95ivRrQwj3wdycYPPjqJhMjZNsIn1Zn2Dm FctY1x7t01HDzWQS8nTQkTupedJW26O7cEI5AGiKFoynAiFWy9SiPKJzxdK/UQhDGg9E ivPp19aTuwi1b06hTo8251TN5D/HoRaDYIXBB1ywKb4QYqrZ8XfEf9A17/quFpzZc+sP WYLw== 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 184si9768693pgj.329.2018.12.16.17.11.24; Sun, 16 Dec 2018 17:11:39 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731184AbeLQA7X (ORCPT + 99 others); Sun, 16 Dec 2018 19:59:23 -0500 Received: from 216-12-86-13.cv.mvl.ntelos.net ([216.12.86.13]:59172 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726209AbeLQA7W (ORCPT ); Sun, 16 Dec 2018 19:59:22 -0500 Received: from dalias by brightrain.aerifal.cx with local (Exim 3.15 #2) id 1gYhFb-0006Mq-00; Mon, 17 Dec 2018 00:59:15 +0000 Date: Sun, 16 Dec 2018 19:59:15 -0500 From: Rich Felker To: Andy Lutomirski Cc: "Maciej W. Rozycki" , Linux MIPS Mailing List , LKML , Paul Burton , David Daney , Ralf Baechle , Paul Burton , James Hogan Subject: Re: Fixing MIPS delay slot emulation weakness? Message-ID: <20181217005915.GH23599@brightrain.aerifal.cx> References: <20181215225009.GB23599@brightrain.aerifal.cx> <20181216023259.GE23599@brightrain.aerifal.cx> <20181216181336.GG23599@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 16, 2018 at 10:59:19AM -0800, Andy Lutomirski wrote: > On Sun, Dec 16, 2018 at 10:13 AM Rich Felker wrote: > > > > On Sun, Dec 16, 2018 at 01:50:13PM +0000, Maciej W. Rozycki wrote: > > > On Sat, 15 Dec 2018, Rich Felker wrote: > > > > > > > > > It doesn't help that information about that is scattered across many > > > documents. You can check for the NODS flag in the opcodes library from > > > binutils though, which is almost 100% accurate, except for the SYNC > > > instructions, for semantic reasons (i.e. they are allowed, but we don't > > > want GAS to reorder them). Most of the disallowed stuff is in the > > > microMIPS instruction set, due to encodings that execute as hardware > > > macros. > > > > I think it suffices to emulate what compilers generate in delay slots, > > which should be fairly minimal and stable. At the very least we could > > enumerate everything GCC and LLVM already emit there, and get them to > > upstream a policy of not adding new insns as fpu-delay-slot-allowed. > > If someone is writing asm by hand to do ridiculous things in the delay > > slot with random ISA extensions, they shouldn't expect it to work. > > I feel like I have to ask: the real thing preventing emulation is that > new nonstandard instructions might get used in FPU delay slots on > non-FPU-supporting hardware? This seems utterly nuts. If you're > using custom ISA extensions, why on Earth are you also using emulated > floating point instructions? You're targetting a specific known CPU > if you do this, so you should use only instructions that actually work > on that CPU. Floating point is in the standard ABI, despite some models not having fpu. This is what mandates floating point emulation. The reason you have to be able to emulate or execute-out-of-line other instructions is that there are floating point branch instructions bc1f and bc1t (maybe others too?) with a delay slot, and if the branch is being taken, you need some mechanism to cause the instruction in the delay slot to still get executed. (If the branch is not taken you can just increment PC and let it happen as a non-delay-slot.) So in theory it's possible that there's a cpu model with fancy new core instructions but no fpu. In this case, you would need the capability to emulate or execute-out-of-line these instructions. But I have no idea if such cpu models actually exist. If not, the concern can probably be ignored and it suffices to emulate just the parts of the base ISA that are valid in delay slots. Rich