Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2485700imu; Tue, 6 Nov 2018 15:47:07 -0800 (PST) X-Google-Smtp-Source: AJdET5c62z2RI2BiZlMHXFUEB4IlmD/3eC3+w7Dob+vThi98s9Wh2niBU6WH0+GZlGrAHc8Amz01 X-Received: by 2002:a63:f141:: with SMTP id o1mr25787442pgk.134.1541548027894; Tue, 06 Nov 2018 15:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541548027; cv=none; d=google.com; s=arc-20160816; b=n6JcEDBPNY4g4GY9/i5kSuBeMjxt24ClrZMN6bJyLk4/pL5SykkeURybLIJpUmmnJ+ 70NIUKP8UUM7kL6XmVuiJ8H0qNcUPSsq93LJr0I8PjIwA0g44k3NAk7iBV6hmY+4AKPr zQ/nFPibXgVUaZFCpmHhy2oYftUCIoPTvUtOHGk1OfnzEnITzsXDbMo+zPvt4peUksH1 SOsdJkkbNtaDyvn0W5Hwe2UcqCfA2HkHOnK6Byn7nfp/hcuHZ6PJJJhQgOeOUdSUCWWA ZR2EPfxnIwjbn/h8zz8RxtGRO/wjONri/ItP2lj0/kGOQSt1oUIMmyCgjAnR+pkV+5YH /IlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=3mZx8qDroV6FAU5EZ6pqnwSrOu6KAm56fCYs5Ed1eNo=; b=0yIA4C98mnuk249EoDMpJ7eCL6PHJb7pHVJyqLshDViaB/katIxZ9/Fm3oGQxFlBqj AxRpHJz4OfzMRT2vEecHI/zfs5TqQqQx2ZHzezDOVi1OMNmmC6LapA15ov086uOpUcXZ ho1gMwNEV/HxSU02GZGfTAl561p5Y3MN5PS+7pqt4ThbnU6ESzTfFikuPZ9As+VGWzqQ hoHaLyRWAj2j6qH48PgddRe06VVLupw0+lfF0KfEpT8PufPOL4rwO3DGEru7WMhYPdFN FQD8G1pmfkZVv/nQCsVMb24IwR4MUN2vb9yeCgrC9ebNxQbn6X4f2SOuuhGj2Lb9Qv3k PRhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=ZVsYIaBT; 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 f1-v6si32584818pfg.121.2018.11.06.15.46.52; Tue, 06 Nov 2018 15:47:07 -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=pass header.i=@sifive.com header.s=google header.b=ZVsYIaBT; 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 S1730996AbeKGJNi (ORCPT + 99 others); Wed, 7 Nov 2018 04:13:38 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42048 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727222AbeKGJNh (ORCPT ); Wed, 7 Nov 2018 04:13:37 -0500 Received: by mail-pf1-f194.google.com with SMTP id u10-v6so1103388pfn.9 for ; Tue, 06 Nov 2018 15:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=3mZx8qDroV6FAU5EZ6pqnwSrOu6KAm56fCYs5Ed1eNo=; b=ZVsYIaBTty5C4Sa9GGFzh1uVTd+nkurOgr8rifxK5Oin+N0y2s4MUGZTORikfExSMf /zPh0ODraQS0ksvXesdg+Fru56wUZ6hLVMt4/ZH16z8YseNx/CJ0atKYKUqCbBZWfdOf E9jHO0SX4PK9H7SZG31PO5VJj9IdrXgDT0Fnv4L2u4zhXjOpKK/bUW2jbT5tpRvfAJ5d eOE2uOrrcpYsAzl04Fuo3Oh0qOA8blnANQRZVGX8Rtu4/ugMlSem+oFMkEUi3kSgYWjj uBW3Z7vq4OvRDR3b9qTB1jqYR2yAjxx7/ztNJik1gC5F1QoHiaIJFzvDs5wT+6hdqldj 5nVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=3mZx8qDroV6FAU5EZ6pqnwSrOu6KAm56fCYs5Ed1eNo=; b=SgFk4jy+M8xYT5g8rntXQW/SFPMAu9XWMCrUSxIA01i7ZPU2lv4PMYSSW7lcQ1dePX MbBTLR7KfpqiIVU7ks4647fktgn7jv0QcziwCURlFyNTL+TdFeUxhPkiSjUOB8kDiPoq Z4BdZvY1wgrrGkAgoCywv0m9GETTpT8MSlbXqQ6AOeEzxWKbvCxrpaJPjuoS7jhuCsJQ IAA2K6geM7NvUDVZgmQRz2aOlV5WXqrcCoAc8IrnK/sut7JvDqgpDE41cfree/fI6qe6 l21yz5SSw2gM3lEJQScG2/bLTBw9KT/Kch9A0w40qq1pyU1uiTQvINzf/4ngHYKjPRYm 7wrg== X-Gm-Message-State: AGRZ1gK7O6b+ZVYcC1fv4RrDMRNHyZ7XN/Lpbv4qHD//njZu78FrtYse mxvSqS/wCordgi5aG74QeM1D6Q== X-Received: by 2002:a65:63d3:: with SMTP id n19mr3377444pgv.179.1541547952958; Tue, 06 Nov 2018 15:45:52 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id z2sm15440462pgu.4.2018.11.06.15.45.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 15:45:52 -0800 (PST) Date: Tue, 06 Nov 2018 15:45:52 -0800 (PST) X-Google-Original-Date: Tue, 06 Nov 2018 15:41:54 PST (-0800) Subject: Re: [RFC 0/2] RISC-V: A proposal to add vendor-specific code In-Reply-To: <20181105065807.GA1286@andestech.com> CC: aou@eecs.berkeley.edu, Arnd Bergmann , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, greentime@andestech.com, alankao@andestech.com, vincentc@andestech.com, zong@andestech.com, deanbo422@gmail.com, kito@andestech.com From: Palmer Dabbelt To: vincentc@andestech.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 04 Nov 2018 22:58:07 PST (-0800), vincentc@andestech.com wrote: > On Fri, Nov 02, 2018 at 01:48:57AM +0800, Karsten Merker wrote: >> On Wed, Oct 31, 2018 at 10:27:05AM -0700, Palmer Dabbelt wrote: >> > On Wed, 31 Oct 2018 04:16:10 PDT (-0700), anup@brainfault.org wrote: >> > > On Wed, Oct 31, 2018 at 4:06 PM Vincent Chen wrote: >> > > > >> > > > RISC-V permits each vendor to develop respective extension ISA based >> > > > on RISC-V standard ISA. This means that these vendor-specific features >> > > > may be compatible to their compiler and CPU. Therefore, each vendor may >> > > > be considered a sub-architecture of RISC-V. Currently, vendors do not >> > > > have the appropriate examples to add these specific features to the >> > > > kernel. In this RFC set, we propose an infrastructure that vendor can >> > > > easily hook their specific features into kernel. The first commit is >> > > > the main body of this infrastructure. In the second commit, we provide >> > > > a solution that allows dma_map_ops() to work without cache coherent >> > > > agent support. Cache coherent agent is unsupported for low-end CPUs in >> > > > the AndeStar RISC-V series. In order for Linux to run on these CPUs, we >> > > > need this solution to overcome the limitation of cache coherent agent >> > > > support. Hence, it also can be used as an example for the first commit. >> > > > >> > > > I am glad to discuss any ideas, so if you have any idea, please give >> > > > me some feedback. >> > > > >> > > I agree that we need a place for vendor-specific ISA extensions and >> > > having vendor-specific directories is also good. >> > > >> > > What I don't support is the approach of having compile time selection >> > > of vendor-specific ISA extension. >> > > >> > > We should have runtime probing for compatible vendor-specific ISA >> > > extension. Also, it should be possible to link multiple vendor-specific >> > > SA extensions to same kernel image. This way we can have a single >> > > kernel image (along with various vendor-specific ISA extensions) which >> > > works on variety of targets/hosts. >> > > >> > > As an example or runtime probing you can look at how IRQCHIP or >> > > CLOCKSOURCE drivers are probed. The vendor-specific ISA extension >> > > hooks should called in similar fashion. >> > >> > Yes, I agree. My biggest concern here is that we ensure that >> > one kernel can boot on implementations from all vendors. I >> > haven't had a chance to look at the patches yet, but it should >> > be possible to: >> > >> > * Build a kernel that has vendor-specific code from multiple vendors. >> > * Detect the implementation an run time and select the correct extra >> > code. >> >> From a distro point of view we definitely want to have one kernel >> image that is bootable everywhere. Debian won't support any >> platform that requires a per-platform or per-vendor kernel, and I >> assume that the same will be true for Fedora and Suse. >> >> One thing that I have stumbled upon while looking at the patches >> is that they seem to assume that X-type ISA extensions are >> strictly per vendor. Although that is probably true in the >> majority of cases, it doesn't necessarily have to be - I could >> e.g. imagine that the DSP extensions from the PULP cores might >> be used by multiple vendors. If such an extension would have >> state that needs to be saved on context switch, it would need >> corresponding kernel support. Using "PULP" (or any other >> open-source project) as the vendor in such a case leads to >> another potential issue: the patches base everything on a JEDEC >> vendor ID that is compared to the contents of the mvendorid CSR, >> but such a JEDEC vendor ID usually doesn't exist for open-source >> implementations; the majority of those have mvendorid set to >> zero. >> > Many thanks for kinds of comments. I quickly synthesize the comments and > list them as below. > 1. The kernel image shall include all vendor-specific code. > 2. This kernel image can only enable particular vendor-specific features > based on the CPU vendor in the running platform. > - The runtime probing mechanism can refer to arm32/arm64, powerpc, > IRQCHIP driver or CLOCKSOURCE driver > - For some cases, such as open-source projects, using CSR $mvendorid > to identify the compatibility is not appropriate. > I think the above requirements are reasonable, but I have questions about > the first requirement in practice. As far as I know, vendors are allowed > to add specific instructions and CSRs which are incompatible with other > vendors to their own ISA extensions. If I understand the first requirement > correctly, it implies that we need a "super" RISC-V toolchain. This "super" > RISC-V toolchain should recognize all kinds of vendor-specific instructions > and CSRs, so that it can compile vendor sources into objects successfully; > then it should recognize all kinds of vendor-specific relocations, so that > it can link the objects successfully. Each of them is not trivial at the > time of this proposal and in foreseeable future. > > If it will take a long time to complete this "super" toolchain, I suppose > the infrastructure in this RFC might be a temporary solution before it is > ready. This scheme does not suffer the compilation problems caused by the > lack of the super toolchain because the selection of vendor-specific ISA > extension is determined at compile time. In addition, the mechanism for > checking compatibility at runtime ensures that the kernel with > vendor-specific feature runs on CPUs of other vendors just like pure > RISC-V kernel. In other words, this scheme, to some extent, satisfies the > requirements that one kernel image is bootable everywhere. I don't want anything in the kernel that can't be compiled by upstream GCC, as that will be a huge mess. As far as I'm concerned, the best way to move forward is to figure out how each style of extension can be integrated. Right now, what I see is: * Performance counters. Here we should be safe, as there's an ISA-mandated space in which to put non-standard performance counters. The support here is just figuring out how to interpret the bits. This naturally fits into our current device-tree based mechanisms for probing hardware, and will be easy to maintain in the kernel. * Cache management. It appears these are currently being described as instructions, which means they won't compile by default. Here I think the best bet is to rely on the SBI, and if that's too slow to build a "SBI VDSO" mechanism to accelerate the relevant bits. It is a bit of a headache, but we're not going to have anything standardized here quickly. If those are the only two concerns then I think we're OK. Are there any other extension you're worried about?