Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2135801imu; Sun, 16 Dec 2018 17:57:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/WRNWECeSbrGrvoipVCicBIFbmbsmjwIs0Jb2kINbFXm7DNzRa9JdQeufMggxgkYpJHpBms X-Received: by 2002:a17:902:264:: with SMTP id 91mr11143574plc.108.1545011850626; Sun, 16 Dec 2018 17:57:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545011850; cv=none; d=google.com; s=arc-20160816; b=Jj+0dkEzREXGHIwSTOSYs8uCfRii7NvcepAJ6vSuS1ojqXI4pUPQwOLJX7d+ytjD9r J0GYXCTIMExkFC9ehXwvlS4chTdccEifvUE3u3LYMD+q7jA3VtmLEKIQ9QmMd/4wXsCU MERCpQwBgOPGVURBberRjUyiLARH+PaOMbHiV9H58EklVbajYL0CylaES5iZJuEB4PbD edOByzTi19kCUr/dT7Ni5Hcw2b58pMiohC772oT8YpVhScuSshKsYEt0nXCAC79LIHcV BbWavfa935pJYDxPalB1KCNPzJ724f111ZmmdjThJzmgA0hhF9fu+M0J424OZgFI6WF9 1LPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=zN7p1XaKRCLkJAtOiwo4U9ntxFnFD9+e5x5pxHuS4Ss=; b=QxFY16yK4VFRNMOq/X+tfoUdEA5YOPRIsx23UxQRZEzeMTymRBMgQjzSRugnFMoQOf n2vuO65opnZ2wtb8XL2vNCxvlrCn2DLMEsqC8kKUUzQENj06f3ENiBx7Qn5fyeassi0k KOZHPHMMekPuu5glCKf7UThUqiKBAlpbKUXj6+6QJ3YTZtTj2XlrxQMocu/oNxWPbjKt Bm7lQpOi7MLqpQ4AT9guCLzEWWSimRr3Qx0k8dmSNZ3njZM7qQufSODzqrFMEsj0YQ1B 9S45oJ7CplXv6ABLCLs1ADRoeIWtkQmMjfe4yZQ85B2/qtRmtxPEVP4grEOOgEAyDHYL StOQ== 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 r17si9697866pgh.299.2018.12.16.17.57.15; Sun, 16 Dec 2018 17:57:30 -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 S1731304AbeLQBzb (ORCPT + 99 others); Sun, 16 Dec 2018 20:55:31 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:44646 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbeLQBzb (ORCPT ); Sun, 16 Dec 2018 20:55:31 -0500 Received: (from localhost user: 'macro', uid#1010) by eddie.linux-mips.org with ESMTP id S23992280AbeLQBz2KRwHq (ORCPT ); Mon, 17 Dec 2018 02:55:28 +0100 Date: Mon, 17 Dec 2018 01:55:28 +0000 (GMT) From: "Maciej W. Rozycki" To: Rich Felker cc: Andy Lutomirski , Linux MIPS Mailing List , LKML , Paul Burton , David Daney , Ralf Baechle , Paul Burton , James Hogan Subject: Re: Fixing MIPS delay slot emulation weakness? In-Reply-To: <20181217005915.GH23599@brightrain.aerifal.cx> Message-ID: References: <20181215225009.GB23599@brightrain.aerifal.cx> <20181216023259.GE23599@brightrain.aerifal.cx> <20181216181336.GG23599@brightrain.aerifal.cx> <20181217005915.GH23599@brightrain.aerifal.cx> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 16 Dec 2018, Rich Felker wrote: > 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. What do you call "a cpu model with fancy new core instructions"? We've gone through 4 legacy MIPS base ISA revisions (I to IV) and then 4 modern ones that matter (R1 to R5; R4 was left out and R6 actually does not have FPU branch delay slots), plus a bunch of ASEs (Application Specific Extensions), such as DSP, MDMX, MIPS-3D, MSA, etc., each defining further instructions. And then the microMIPS R3 and R5 ISAs (R6 uses a different instruction encoding and does not have delay slots at all). The MIPS16 ISA does not count however, even though it has delay slots and we support it, because it does not have FPU instructions, let alone ones that require delay slot emulation. Some of the ASEs do not matter, e.g. we don't support MDMX in Linux as it has user state we don't handle with context switches, and MIPS-3D and MSA both imply an FPU, so software making use of them won't run with our FPU emulation anyway as these ASEs' instructions are not emulated. Anything else is potentially required. As to actual implementations I believe all the Cavium Octeon line CPUs (David, please correct me if I am wrong) have no FPU and they have vendor extensions beyond the base ISA + ASE instruction set. Arguably you could say that their additional instructions should not be scheduled into FPU branch delay slots then, however the toolchain will happily do that, as I wrote before. I don't fully remember what the situation is WRT NetLogic/Broadcom XLR and XLP chips. They do have vendor extensions, though IIRC they do have an FPU too. But then we have the "nofpu" kernel parameter anyway, which forces FPU emulation for any hardware, so we need to emulate delay slots in that mode with any hardware. I'm afraid the problem is complex to solve overall, which is why we still have issues, 18 years on from the inclusion of the FPU emulator: commit 4c55adaa6d06e5533aebaceea7640ecf10952231 Author: Ralf Baechle Date: Sat Nov 25 04:49:46 2000 +0000 Kernel FPU emulator, chain saw edition. (in the LMO GIT repo) and I think actually running the delay-slot instruction (with a possible exception for things like ADDIUPC) rather than interpreting it is the only feasible solution. I'm not involved with MIPS architecture development anymore though and at this point I only care about the few legacy platforms I have been taking care of since forever, such as the DECstation port, for which our current emulation solution suffices, so I am not going to commit myself to making any inventions in this area. I hope my input is valuable though and will help someone working on this. Maciej