From patchwork Mon Jun 24 05:42:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFE0976 for ; Mon, 24 Jun 2019 05:43:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFE8B28B01 for ; Mon, 24 Jun 2019 05:43:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3F8028B1E; Mon, 24 Jun 2019 05:43:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46FB528B01 for ; Mon, 24 Jun 2019 05:43:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EC726B0006; Mon, 24 Jun 2019 01:43:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 84D4E8E0002; Mon, 24 Jun 2019 01:43:24 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EE2B8E0001; Mon, 24 Jun 2019 01:43:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 3A2276B0006 for ; Mon, 24 Jun 2019 01:43:24 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id u10so6697972plq.21 for ; Sun, 23 Jun 2019 22:43:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZFBwbC42pF4/ydEOSJ4y75ZnrJb+ZBbMm/qFm7Ht5k0=; b=jnaemqpwnNPB/pLqTJVHeLwZ1jk5P4Tzt498iiCteRS/i962W5I9HRXQKVrMyyhFqU R9wle4Qdr0DfbHMWldoyEZXF7vKiKjzWMbT0wi6j+gN47EUpqX4MbH2XrJlulT7fYb4R QxpQsOgnJOpzb+FYgIyDqA0tVG6aT0uAUrbrHVFrwnZRXgYFVs4a7alo/iBZyGDOQKJZ +V91Av/sEl7uK3pqDhaB8Q9MEhjlLHxGX+1EgNBndXmYFQA+5bgLVwBQVi0C9qGOqCc1 lqu1zzI5HYLrs+5ALN5CmjGQVDsP57KLr59G+MOpyKSH1Zg37y929aMbCtxCJvFTdWck LlLQ== X-Gm-Message-State: APjAAAWwEEmqtZVOj+PYfT7WhBw4jQVXLdEsGmogS3JpPOVVlsRAhsi0 MG9XHpWRKt7FVm6g/MQWz8La0ejvDJILh+B/cFvf4b00Gnw72pJ2EP+WiX6PQW3+SWtm8HprDyQ ClfxoLdcGZx0ZBpTSEI4vHyaYwxbN5jFr1Ei1VIoquHGR/dGAoIPIlGdmLwbQs0Q= X-Received: by 2002:a17:902:9a04:: with SMTP id v4mr49098374plp.95.1561355003830; Sun, 23 Jun 2019 22:43:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqytUiRbzAtVQa82mhCY8D/HFM8P0FMV2QIYtqSeVSdy1qzniV1mOMjovpCpZpkX5+wuA5Bb X-Received: by 2002:a17:902:9a04:: with SMTP id v4mr49098281plp.95.1561355002114; Sun, 23 Jun 2019 22:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355002; cv=none; d=google.com; s=arc-20160816; b=w6s0YhHojmN9l3g6LJR+GQnr3D5U/mdi2JVl4e2HhXcNIg3/XS1lXdcP8aVYPxq0+W 1n7ZTfpPEPWJi+dzVDcJJLBkqA78EN0pc/jINtMn+wMH+KFvsIkllEIKEmLILzKXUkU3 u6ATlfcKYI38drDLGe9C5Ls+uRGm7N2dMx95c0N+LajmQutr3dFNRIykMzLRECg2Ao4c iX60khFfg+0fOq3ovyEf0segO9ttT6PO85EMN/d3zPtYYEfPbajCMdQ5AIVflLeR8zef bvZe8MWBQ+UOa9MtRqm2e/Hq/EwdFC0ovutDPni9pF5kty6TxBbzx4aq0WpwHt+nz+yM 59TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ZFBwbC42pF4/ydEOSJ4y75ZnrJb+ZBbMm/qFm7Ht5k0=; b=WkSKakf3z2LvuwkZm9LT4Bq3g/Pl7MAxpHaXmISJYMD/d6lnmobD3w1Vg2ZH7JSsCy DIV77eJ0d9eghxoUxKj1+VymAS8BPJ6htn36ImdTdPrLp5DubyasbcRqYNxe3wAFI4dc mmzxgmFGqbDOy5AVr/G06CC3nBnJvosFtEtJ7udkxO+OPG+UhYxWXKHBp75hxMlw1yMt MxMoiHiMUaWOitHb3x6OM45oxpXTr8Mi4vzP79QV6mPAvVhuHaH/7ydosocJb6WuBI4e ShVRHJQi4EtdsSI/ShslpBQB9ubHV42UpANX439l4j+naxiOiSgBfORgC6YzXnw2ZdW+ lFrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=X6al4PUP; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id h15si4511857plr.23.2019.06.23.22.43.21 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=X6al4PUP; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZFBwbC42pF4/ydEOSJ4y75ZnrJb+ZBbMm/qFm7Ht5k0=; b=X6al4PUPrJG3GXXDCc+GVTzTlg 2TSkJtcBJThDHIeyPeJiS8/uksAhamtWEZqHOR7790Zoc05bZD4vgnQfeFrUhpgVmS6Wtj34h+Zp8 LauTUq5EVZOKR9tSXliqJAsyWJ+cFEkaJ7oZfe4j7mDAwtXbxzD6go0vThELFfQTkD5IxmXoNvw0o L0gFZrRUmOexC+mmTGo11vv5/KRkjFhwZXlKYQGHpUZD90U1hUU3pTX0qmaYFxdQRVfkjVqmPirtZ pukuQReHO+bDQdEoXqU6Ycu/nnJkbAVTVnG3qUyQ0Az1wVOLQPr8aw2Y0GyezJJ14dT8hSXtMfQ9y 0CzY8sZA==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHl8-00064U-KY; Mon, 24 Jun 2019 05:43:19 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vladimir Murzin Subject: [PATCH 01/17] mm: provide a print_vma_addr stub for !CONFIG_MMU Date: Mon, 24 Jun 2019 07:42:55 +0200 Message-Id: <20190624054311.30256-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig Reviewed-by: Vladimir Murzin --- include/linux/mm.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index dd0b5f4e1e45..69843ee0c5f8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2756,7 +2756,13 @@ extern int randomize_va_space; #endif const char * arch_vma_name(struct vm_area_struct *vma); +#ifdef CONFIG_MMU void print_vma_addr(char *prefix, unsigned long rip); +#else +static inline void print_vma_addr(char *prefix, unsigned long rip) +{ +} +#endif void *sparse_buffer_alloc(unsigned long size); struct page *sparse_mem_map_populate(unsigned long pnum, int nid, From patchwork Mon Jun 24 05:42:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 230931805 for ; Mon, 24 Jun 2019 05:43:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 140C428B01 for ; Mon, 24 Jun 2019 05:43:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0815228B1E; Mon, 24 Jun 2019 05:43:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F11528B01 for ; Mon, 24 Jun 2019 05:43:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 911DE6B0007; Mon, 24 Jun 2019 01:43:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 89C278E0002; Mon, 24 Jun 2019 01:43:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73D968E0001; Mon, 24 Jun 2019 01:43:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 3BB116B0007 for ; Mon, 24 Jun 2019 01:43:26 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id v6so8656896pgh.6 for ; Sun, 23 Jun 2019 22:43:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=uHFTnl4vUjrNVYTFv2dDUy+7np+VKavI9He7Ga2MW2s=; b=BDz3l/LsrfQZrcgmpsYBZ77lzky+dPg8LpZHiW9muyylR4QXgkk0R1RlhyqD+N0/ty 7ihAS6T1oxZ+zRxXiB6iTpAAps4wIiV0eZiQRKa0vIQCXDdlCoR0h2pph0Ga5zrKF7Wu eeC0D0kernOIEJP/yj15wHN82InJKoFssHjsIchf197NbO8P0ixOcoVdDjfZm6C5ZntK cqh8xltdCBJ0SDIWp2VovpF0gTXZSvPAVnaYf8JoIIdjQCEtwNGhdulYGIER50NxVtnl rWryp3rOk6DMJqcc1tDgK8WN5HfTqzGmztUhQ2RbjrNqSwYcn1to5RyK5AoGSMbpT/6c LAcg== X-Gm-Message-State: APjAAAXzrCIoXGkZO/NptDNdTMAVLD6Tr+/GSvrs5X38zfnx0KoDtyrl IlJDFjU49OhzkwuP8AMgWB71AL9SY2admoKQts9r/Z3mOVb7XnuGSVOaOeEnTbFwcbSqPYRBWrF t4PevdKa5wh8kn6NR3iOKyQbGiO/YttWwM3BAuXEk8krK3yt0uL5cbpPnSbZ9LYU= X-Received: by 2002:a17:902:b94a:: with SMTP id h10mr34935373pls.125.1561355005913; Sun, 23 Jun 2019 22:43:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlECX38QEkkgnpa5gn+mdPXoNJZJO3sToq0O9nkumTAGuVOfGO0J547AlJ4pVmlhrWVpin X-Received: by 2002:a17:902:b94a:: with SMTP id h10mr34935339pls.125.1561355005294; Sun, 23 Jun 2019 22:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355005; cv=none; d=google.com; s=arc-20160816; b=nHnpNptsVd7jdojpesiC/owpoeXfMsLEGGBiqHJ3RrtCXQqe7LFKEDuuhvsZzoQhp0 S7R/Bprf6Dw5qE+aZ7U/9RB+IBIMPErv9njTsdlfeLQhJovLzxfQPZRCOdskMA3ONUs6 R6L49ZcX4kSi24PImCP/1dBETZa9VWIQTfB4N7n9H3amHXMCnCUjxFVHa27HtOUE/6H3 uwosgfXwZuFq0tScOZ7ge7pgnNfO2fpes3+bI00JA5siDbnjacEpTT+i/Xl/WCXACDo7 nNzAIyJRv/KqSX8sL4YC7yst2OA3c9ZDWiiu24hr5AHplj6hlLb+9E8RRXuvDLHz51cP n0wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=uHFTnl4vUjrNVYTFv2dDUy+7np+VKavI9He7Ga2MW2s=; b=gMUjo3HOLIi63Hxnl2NwKjNMVkHrTD3QqGWBblhMOmwdPXq+cK9C8NJfWtdeZhkiyN yakfy3ti7mWdrckIlRvYlKSi5NSERQSHWudPEGPxaxd2n/yRuNDga2kRKhDl+walMTFV hxCd0i93pVspsZvQrQDBCn8yZVBUC6wOmN3IKgXu7Rd+zdya5bkZvRFq9xg4+goH9uCt 8sIC5xjdCAR7ZPFwqiO4FBkEY/HuHdzgNlrXTMFqENzCuXHolAXURyCl0n0bRbGWmZHH l9cPkG8hcuRHlSlY2WNuuCRKRXNpB2sNUaC9XNMwSibQdAuP3tAwNpRrUyBhHwwnEeOU 8zYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=m8UBJ+0X; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id s62si9769558pjc.75.2019.06.23.22.43.25 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=m8UBJ+0X; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uHFTnl4vUjrNVYTFv2dDUy+7np+VKavI9He7Ga2MW2s=; b=m8UBJ+0XcFZ7O7trRjCFun/kpM ZZL9L8R5+7n1in9B7bBJFc+moU0JB6Hi14/as4UhSBatyUxxcjhzsdYC6kDe3REVcjNaNW5RX3Fza C7X9mCLwL3zA7GmD9WbrUJDOy6dtV3finn/OvuiwPpTghqZu7fQlcGpPZwA7yPEAuVDAm6/tHnW3I hX0KhA8ptgDt+HbonwtMMPc7CPE9Lo25J7clA4oa2UPWbkXTT8GAWx4HWmjFSd3S2S9AyvJatTWdx HcphWkJ03sWY5Z74c2jp+RNrCmbNpU9pJ91z9gGz1xiJzbkVWkQ1rEC/P9e68pcZCYm5ie7s48ZEu /Usxr9xQ==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlC-00065N-AR; Mon, 24 Jun 2019 05:43:23 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/17] mm: stub out all of swapops.h for !CONFIG_MMU Date: Mon, 24 Jun 2019 07:42:56 +0200 Message-Id: <20190624054311.30256-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The whole header file deals with swap entries and PTEs, none of which can exist for nommu builds. Signed-off-by: Christoph Hellwig --- include/linux/swapops.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/swapops.h b/include/linux/swapops.h index 4d961668e5fc..b02922556846 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h @@ -6,6 +6,8 @@ #include #include +#ifdef CONFIG_MMU + /* * swapcache pages are stored in the swapper_space radix tree. We want to * get good packing density in that tree, so the index should be dense in @@ -50,13 +52,11 @@ static inline pgoff_t swp_offset(swp_entry_t entry) return entry.val & SWP_OFFSET_MASK; } -#ifdef CONFIG_MMU /* check whether a pte points to a swap entry */ static inline int is_swap_pte(pte_t pte) { return !pte_none(pte) && !pte_present(pte); } -#endif /* * Convert the arch-dependent pte representation of a swp_entry_t into an @@ -375,4 +375,5 @@ static inline int non_swap_entry(swp_entry_t entry) } #endif +#endif /* CONFIG_MMU */ #endif /* _LINUX_SWAPOPS_H */ From patchwork Mon Jun 24 05:42:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3CD276 for ; Mon, 24 Jun 2019 05:43:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C50BA28B01 for ; Mon, 24 Jun 2019 05:43:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B91DE28B1E; Mon, 24 Jun 2019 05:43:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AC8028B01 for ; Mon, 24 Jun 2019 05:43:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A9146B0008; Mon, 24 Jun 2019 01:43:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 42FEC8E0002; Mon, 24 Jun 2019 01:43:29 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31D678E0001; Mon, 24 Jun 2019 01:43:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id F007B6B0008 for ; Mon, 24 Jun 2019 01:43:28 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id bb9so6726825plb.2 for ; Sun, 23 Jun 2019 22:43:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dGgF55hFtmmmZc+ieAzS4XO99ZIShl4dVYuogqe2WpY=; b=h6cU5z94bif5aS8SjblqrBF8S/0cqI5GtupIvSsr45UmGkUhfCzKLsP8Wk/z9Mdlyr Sw9hVDaZuC4ZNEu4jg0eWoTRiZf4Po838AFTZ7v6MyAQbIzHJJ+i5oNV7ivygeUVPqYF wajygIjsPzosVHajLVs2xWh/bG7yZn+JLK+yse+7aMOM26gV+MENKCigG/Z8Qx58sMZM 1l97E+Bei874Bbk5kk00cKogZXlkqrA+j5pxoq/b9v5EE5d5hEqgiFkyZP+VC3Ihun+n v0u33Apm/DbiTYoOE4hZngkXBnFZ78kqxvUpRSbQFRwZaNwyBd0iF04yxMMJfQvMHIQh /B+A== X-Gm-Message-State: APjAAAVPEETG0XSQCvAHfhom0sW88ucbmweRCb9y1Ri3KbCbNXPeCcjp VxOX/WgHIuCXlUlno5GE09fXzUfB4VMDQOdnWXhSSEg0K/u2Rhz8KIIkcJCbmoh+hmr1PVmHc2+ yEBpSVz/jz7lrveeuqWYnAWYECf9dZF4oyg6SyiZGf7pdxrwH7PvlzEL82Hpr3Fs= X-Received: by 2002:a17:90a:ba94:: with SMTP id t20mr23597640pjr.116.1561355008655; Sun, 23 Jun 2019 22:43:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTl6hB2AVkfbG3v76yxi4IOhRmbQZB3Fgd7xDOSALWZ1rIIMLpuMUKf9s3i+i/muBlpMQB X-Received: by 2002:a17:90a:ba94:: with SMTP id t20mr23597579pjr.116.1561355007908; Sun, 23 Jun 2019 22:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355007; cv=none; d=google.com; s=arc-20160816; b=Qm+WokjI9/N6N9fEbecMdV/1IpJ0kXV8Y1tpzVa7a2TwSnsEgsB21OtRoBbhmS7+AB C9kqOW0ItztDER++Bg59BtwDMmqVs9tnftjC1RNck7z5z1Bi3wSc17T05T5QCB0HDFKX +xuctMGZEhopFKGL4jzzKcI0C0vR4A+8N33B7KhMeBQEvk4h8TkTR5jg5jELGYVKJsR0 KEFsFzUYnRwcOLNTzeaLDx12KJD7DTvnhgZzXW9lRK8ZFt1SBydzAQHAzLyWRz38G9U3 Y8f8Ps0ecc/ASBbSC0COmTRZmSjHOhE4mhjNyNmpDx0DJMxEF962qdc0mGYiBnvKRDOK kJlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=dGgF55hFtmmmZc+ieAzS4XO99ZIShl4dVYuogqe2WpY=; b=SI0lT/uwdB1uADlesJYvSS2ivQCKCyIUZQ30TnSPMSh2+okNXXQuhKmmZLdenafg5l oYgXo3vdvZVq21dWQb8NBFnNw6Mf71TRtM4Bdf83nMFFj3sjjrueFswi5TK7uwStcClQ W+m9rgTJzSJTbFZPPfZcPe8f/fI/7GkiZj9lqU+8kmf0xaNTb9iqYeEuK7RgDKRoYny5 Hw/BX5zOeWKCMe8UGjU1MAuvZFKySzWLeZFck50sq2enjQaLIsCeWmpuaTokity/mJwv ftjpwp4Rr4ZOJ4rv7A+/5Yt2exQL58wTevUG6oF/qSDa5h1MZGYXooVlm77cZCFu44Ws huzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=oQ+2sb4O; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id m19si26085pgb.523.2019.06.23.22.43.27 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=oQ+2sb4O; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dGgF55hFtmmmZc+ieAzS4XO99ZIShl4dVYuogqe2WpY=; b=oQ+2sb4O0ME8d5ABjk4P58q0nw GIsnV3dmJ/XiMyp6DvmASmc4e5qGID3C66YIiTWRuy/o8Ws3yDWphOJBSiduNIzLdTKUaicf/eT5+ +J8xkvIy0OgTS9FXTCwbHDLUDO2czpVwB8TGgdLKOE/Fc+tVqHBSOvSMYLGLtsPKFswRD0EGvJ0bp AFIsQdQU3ONiJIJ4edKqFETEQtDQuKbY9oUUthtrbn2nDZik41DPsPUguFaOzAHoYKZvQzRL+t5LX BJKN5z/viz/nDZY3Ue8edIuv8pyfQgby9aJmhKEnEVq4ZKaEnbDqV0pszHiwm9V55p3Pa861BFO6P BV4LEQ5Q==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlG-00068k-3f; Mon, 24 Jun 2019 05:43:26 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vladimir Murzin Subject: [PATCH 03/17] mm/nommu: fix the MAP_UNINITIALIZED flag Date: Mon, 24 Jun 2019 07:42:57 +0200 Message-Id: <20190624054311.30256-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We can't expose UAPI symbols differently based on CONFIG_ symbols, as userspace won't have them available. Instead always define the flag, but only respect it based on the config option. Signed-off-by: Christoph Hellwig Reviewed-by: Vladimir Murzin --- arch/xtensa/include/uapi/asm/mman.h | 6 +----- include/uapi/asm-generic/mman-common.h | 8 +++----- mm/nommu.c | 4 +++- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/xtensa/include/uapi/asm/mman.h b/arch/xtensa/include/uapi/asm/mman.h index be726062412b..ebbb48842190 100644 --- a/arch/xtensa/include/uapi/asm/mman.h +++ b/arch/xtensa/include/uapi/asm/mman.h @@ -56,12 +56,8 @@ #define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x80000 /* create a huge page mapping */ #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ -#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be +#define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be * uninitialized */ -#else -# define MAP_UNINITIALIZED 0x0 /* Don't support this flag */ -#endif /* * Flags for msync diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h index abd238d0f7a4..cb556b430e71 100644 --- a/include/uapi/asm-generic/mman-common.h +++ b/include/uapi/asm-generic/mman-common.h @@ -19,15 +19,13 @@ #define MAP_TYPE 0x0f /* Mask for type of mapping */ #define MAP_FIXED 0x10 /* Interpret addr exactly */ #define MAP_ANONYMOUS 0x20 /* don't use a file */ -#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be uninitialized */ -#else -# define MAP_UNINITIALIZED 0x0 /* Don't support this flag */ -#endif /* 0x0100 - 0x80000 flags are defined in asm-generic/mman.h */ #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ +#define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be + * uninitialized */ + /* * Flags for mlock */ diff --git a/mm/nommu.c b/mm/nommu.c index d8c02fbe03b5..ec75a0dffd4f 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -1349,7 +1349,9 @@ unsigned long do_mmap(struct file *file, add_nommu_region(region); /* clear anonymous mappings that don't ask for uninitialized data */ - if (!vma->vm_file && !(flags & MAP_UNINITIALIZED)) + if (!vma->vm_file && + (!IS_ENABLED(CONFIG_MMAP_ALLOW_UNINITIALIZED) || + !(flags & MAP_UNINITIALIZED))) memset((void *)region->vm_start, 0, region->vm_end - region->vm_start); From patchwork Mon Jun 24 05:42:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4439B186E for ; Mon, 24 Jun 2019 05:43:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3408A28B01 for ; Mon, 24 Jun 2019 05:43:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 282DD28B1E; Mon, 24 Jun 2019 05:43:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2F3128B0B for ; Mon, 24 Jun 2019 05:43:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 875556B000A; Mon, 24 Jun 2019 01:43:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 828A98E0002; Mon, 24 Jun 2019 01:43:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C8518E0001; Mon, 24 Jun 2019 01:43:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 3889F6B000A for ; Mon, 24 Jun 2019 01:43:32 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id e25so7730461pfn.5 for ; Sun, 23 Jun 2019 22:43:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vOVF1bL6OtEC3ny1W9eKFWhCTN+KLHMSW/CBbgd+PKs=; b=m7EMl+CYL0IvyQ1rIBJkDHliKN2yH8GTwtOBdn9b6TimLif5+M2vW1+qafeW+8Kuv9 0Iot5Wk61gJC4dqk3BH3mJVpRrQ64cF5OF69qH8DZGTat2VTYysj/Zpd4Vn2/ar5Ao5H oOMYJ9YxbnJOptx68H+VfbwBVG9mKISOleyg6GKIH7BRW0HABK9U5dF353DUxKy4e4Qu Y4mLFF9Q8ExOWmMvvNYCg2r46b56GwcdTi8wBR7TfnJEM0DMHeWotBOmJZbDoVcvDTvK Wp++XNtrdQ5XzgNfwvmPEVFyCGr+M3/7ruNMZeft8BQ4630NTqw6KNNdUijHiGRcpL5f S5kw== X-Gm-Message-State: APjAAAWYz0jf7YKYRYCHfKkx/xF7dRltMWHeQnDbx6a5O8+fzL8zOn6H 4128MhufJgYeVwWfK4i8wjBhDsgVoeO2GDbUg0T2Vy1lpk+vc05EXE/7x8CZEN9b8rjj9x4iPoG N7W6dYKCZhgfICEgvIgOC36ZfHsXxVFllMdHl5JhybK+ZdbrTf8nyk3IeHCqGshM= X-Received: by 2002:a17:902:9a06:: with SMTP id v6mr126590331plp.71.1561355011936; Sun, 23 Jun 2019 22:43:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzF4Zk91TP1MN6SUwV8sd6k/ioG9RPddAdTF/PhCC1/YvtC2Hu2JATlAjZudawhnA5rYh+S X-Received: by 2002:a17:902:9a06:: with SMTP id v6mr126590296plp.71.1561355011312; Sun, 23 Jun 2019 22:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355011; cv=none; d=google.com; s=arc-20160816; b=g8BkWHw1xR+2IePjy3xLMlF8VGjrOvpK8/PD57Eya5vyVN0Jj2rOoW2R6SW1K/t4UX LLvQyVExnN9zqG2+dqjN2hdl1U6EK0l7htd/T8RygTg08KoBqDuBsKJ+Vi7NgdM8up83 pkh3iPe/6LXj+xo6w9QsjR5y90ppbwSCSLj0uaKn0YYcO9sRZOWzEMOV723GRMIBTXkk nG0012zklYh7bfmnU8KLXbJ82e/z1Ns+IHuq1MwemD133vFEl1/IhihnHx19+5yMJGE6 Vb9/2pKztoyK6LPbcvnVqmzSglPKkoTpCCvSN1EaSqgD88tz2SUIdlvnsTVlimlM9YDS uRBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=vOVF1bL6OtEC3ny1W9eKFWhCTN+KLHMSW/CBbgd+PKs=; b=S971J1WgGKJ69AiYM18meSYJAjXlX6pZPnX+ySFmokTio7+OMFoT3z3iQ5PvoZBhVd 7rRr9juaYE/dl4XVug/FL/qfJJWdNxoTUtwWNIOkq+5GsHdXPzG4N9uy+fMOpC84Vgwa ZBc5uYh6NyS+zCd7sky+ZsNS2VR+wxcV2xRk1o6Po/oRjQjwZtDrl+DvhrpMzEeIZPvU BZlaMm5+J2F1yA03SwmqUYURvmT8etpo3b64cvGE5q3GkK+MfWMskaynUn9Epbtln/gZ RTEUkPKczFbJtwMcFvaKyFrpi8PtJHVoqtjTIvDVz+D77ZywqkiarnKd/06sANWwvNxT /wqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=fMawuu3O; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 31si9532924plf.195.2019.06.23.22.43.31 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=fMawuu3O; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vOVF1bL6OtEC3ny1W9eKFWhCTN+KLHMSW/CBbgd+PKs=; b=fMawuu3Opqat44vDe3HBjfC2NV U5+fXW3mv7s7Jlh5elWKOcphZfFUedF1vGm+7MYpefOZ9keuy6mkobCiyuiWMY5CLEcGsBYr3epoG m757TAQi2HxXtEeXw31FzGZsYfQbEb96/9Ia45hV6LD8/DMRBoIc4DCLBiY6bHE3E/pVumBkLBY5w zQsrCXvA58a8v8QR10iyNRva5OtbMApi6LzDxtYh6XUzs8CFb1qIBB/sbzkWkI0sjoTbtb5hHeHM8 YgjPe0IwJKPuJTnzuw0MJiDrV8RqIWDzx9q3MB2qJlJKHNWksaE9721c9vrJkODjAmgxyXQOo4sY+ 3XbUdhVw==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlJ-0006Cb-Dy; Mon, 24 Jun 2019 05:43:29 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/17] irqchip/sifive-plic: set max threshold for ignored handlers Date: Mon, 24 Jun 2019 07:42:58 +0200 Message-Id: <20190624054311.30256-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When running in M-mode we still the S-mode plic handlers in the DT. Ignore them by setting the maximum threshold. Signed-off-by: Christoph Hellwig --- drivers/irqchip/irq-sifive-plic.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index cf755964f2f8..c72c036aea76 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -244,6 +244,7 @@ static int __init plic_init(struct device_node *node, struct plic_handler *handler; irq_hw_number_t hwirq; int cpu, hartid; + u32 threshold = 0; if (of_irq_parse_one(node, i, &parent)) { pr_err("failed to parse parent for context %d.\n", i); @@ -266,10 +267,16 @@ static int __init plic_init(struct device_node *node, continue; } + /* + * When running in M-mode we need to ignore the S-mode handler. + * Here we assume it always comes later, but that might be a + * little fragile. + */ handler = per_cpu_ptr(&plic_handlers, cpu); if (handler->present) { pr_warn("handler already present for context %d.\n", i); - continue; + threshold = 0xffffffff; + goto done; } handler->present = true; @@ -279,8 +286,9 @@ static int __init plic_init(struct device_node *node, handler->enable_base = plic_regs + ENABLE_BASE + i * ENABLE_PER_HART; +done: /* priority must be > threshold to trigger an interrupt */ - writel(0, handler->hart_base + CONTEXT_THRESHOLD); + writel(threshold, handler->hart_base + CONTEXT_THRESHOLD); for (hwirq = 1; hwirq <= nr_irqs; hwirq++) plic_toggle(handler, hwirq, 0); nr_handlers++; From patchwork Mon Jun 24 05:42:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC55A76 for ; Mon, 24 Jun 2019 05:43:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD56028B01 for ; Mon, 24 Jun 2019 05:43:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C161A28B1E; Mon, 24 Jun 2019 05:43:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68B8028B01 for ; Mon, 24 Jun 2019 05:43:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEAD26B000C; Mon, 24 Jun 2019 01:43:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A9A258E0002; Mon, 24 Jun 2019 01:43:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95FC78E0001; Mon, 24 Jun 2019 01:43:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 5E2CA6B000C for ; Mon, 24 Jun 2019 01:43:36 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id e16so8656514pga.4 for ; Sun, 23 Jun 2019 22:43:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+l3vwi8bsor/tja9ZheW5y8DiiO/mW8k6zhZ4E83rTI=; b=d1kQGqThxpnY2dOW9jnL3+2Nmdkf3QfHw/4glHsNq8gHQSkVAv0hs2rfYCjdZIzsby Rs53lTtEUaAFyHXNb1oiQlzV/Rra0w5+pkqSzRKghPdjnZzE87M0dJlFkNZip5DyOfBB KKQ+BVxDXPcKISCPJjFffNJYKf/moUu7TcZMJm6ekdNMBfinDM5zFuMZg1hfkgvyhBIK Wol4Q0gJPftR6fcl6iryTIKP5Ml3gNTjT07F4X3bedA5k7yj/D11dWsuMY8Y8zG+DFyC QsI8WQjuijGRUEOWHrdsY/iOxL/0gVqy57cb+PBqXR0zqUREfr9XOcKvE5VabUIRoP3k mCqA== X-Gm-Message-State: APjAAAUxScIkd/hOYw8N7zBdTtm7IalrDoiUOZJvHfjfdiJZdZBswusy XdRbTBEuyXA9A2KkDWXDPi0RG1kS79ffFinJsmlhJPQMDrQ+RfKB9YxfBjNFTfUICSMz+GyvVa0 HinaDfgDX6rROG3ANCzNMepNU69hSUGqHe04fNXBVKWp3bSkuBhrAyok2cbMJlRg= X-Received: by 2002:a63:4d4a:: with SMTP id n10mr25503356pgl.396.1561355015880; Sun, 23 Jun 2019 22:43:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRpSa8egB44ZhzGuHXSc9m34KUWRyHUs8nXSUxyLldkbe4wwhv/fJEKzq8a7gcbNeUFpTt X-Received: by 2002:a63:4d4a:: with SMTP id n10mr25503321pgl.396.1561355015170; Sun, 23 Jun 2019 22:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355015; cv=none; d=google.com; s=arc-20160816; b=oxA+onsqcOwAkR/i9tIrJpKjHHBQhr/wjNrq2UMgkRxUTe0Aut2v6iZLlrchk9jvqA bXLYEVSh1FRW+RPFEnAD00rOGt79yqNYBVXh/0MNeqJR1FlKgqoAza9IzrlQ24T3bFWi u+DxXiOCocNhb/ABxqyKzjHHDoUtyZe0bHQLFjA2wgGBVRznSiHeIwTyltXO1zlGYzPn W0PnFOd74rRcIVd6P8CPQUFugKlF9wFJbjiRzsxFC6dZ5bj5CAddpYsziG+boE/ikFfV WA7JjUilEaAJp9Y9jAgHDNgzNq7yJYXZACfpJsYr4GzNIF0DIsNXLaY+nUjUaFhAS5qD owdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+l3vwi8bsor/tja9ZheW5y8DiiO/mW8k6zhZ4E83rTI=; b=hI9gp6tJ4N/+d+4RRS9NrZ/CIdzuEE4k93r6xVE5O6ybvg9k/uNCajgyqnaEpTTDkn a95RllwTrjbJ3HnrqTfxwLgzG9c3qv1SsnT0NWrMWSAjCsTL2I/EkTrbIxEaFgBZzuTH COg7QNvoIn9sdXdbYjfI6dFuoVlO2iELjNsA0eDATvng8g1Nyx7fkfCzjxESC5zl5tNN foQjXqFzDsTh7xED7Bv1dpdduNTeNzRVBypqVrX8F8ZbtqxDNxoc7d9IOBVxWlo+J6eM YPU+RmYQwmIt5m0cBR0Q46Iffky+ZBWb2zcs2FUL0bQ7+DW+456ZGsTSZQjOjGHxQL6P fPSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=mAvADQ+c; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 6si9627376plb.345.2019.06.23.22.43.35 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=mAvADQ+c; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+l3vwi8bsor/tja9ZheW5y8DiiO/mW8k6zhZ4E83rTI=; b=mAvADQ+cwTdSv+lt/UrCLAQIca 0dD4dqEu4sMMNiFBL7leKtPj9jibj22MJ0jwgHB3KU5zu4mlrT2QfCgV56BTu/m9YZiG5Nr1uUm84 y1PwMD41gPqcy/8w1H7CcUsZnBbdXBxDp9rR/8b7435grnEb/8gn616L6xirlmp6IkDOHezq54Jci M+NToc3yEOIoREpCO/yTJs29tuZDuvF0ETJp51nUCIKg/w2K4HNxKopP12CaHADIOpvmDhFTgD5Qr WovcnekXgMnBwUh7ex4C90RWdFHYis/U2RnDWbeNGhclz0LrvcsC3mzmXItVAbQVafsOja8CpIj2P g7pyPeTQ==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlM-0006Fu-LS; Mon, 24 Jun 2019 05:43:33 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/17] riscv: use CSR_SATP instead of the legacy sptbr name in switch_mm Date: Mon, 24 Jun 2019 07:42:59 +0200 Message-Id: <20190624054311.30256-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Switch to our own constant for the satp register instead of using the old name from a legacy version of the privileged spec. Signed-off-by: Christoph Hellwig Reviewed-by: Atish Patra --- arch/riscv/mm/context.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c index 89ceb3cbe218..beeb5d7f92ea 100644 --- a/arch/riscv/mm/context.c +++ b/arch/riscv/mm/context.c @@ -57,12 +57,7 @@ void switch_mm(struct mm_struct *prev, struct mm_struct *next, cpumask_clear_cpu(cpu, mm_cpumask(prev)); cpumask_set_cpu(cpu, mm_cpumask(next)); - /* - * Use the old spbtr name instead of using the current satp - * name to support binutils 2.29 which doesn't know about the - * privileged ISA 1.10 yet. - */ - csr_write(sptbr, virt_to_pfn(next->pgd) | SATP_MODE); + csr_write(CSR_SATP, virt_to_pfn(next->pgd) | SATP_MODE); local_flush_tlb_all(); flush_icache_deferred(next); From patchwork Mon Jun 24 05:43:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DDF61805 for ; Mon, 24 Jun 2019 05:43:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E63228B0B for ; Mon, 24 Jun 2019 05:43:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42FCC28B30; Mon, 24 Jun 2019 05:43:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEA4628B0B for ; Mon, 24 Jun 2019 05:43:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 457066B000D; Mon, 24 Jun 2019 01:43:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 408168E0002; Mon, 24 Jun 2019 01:43:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A6B68E0001; Mon, 24 Jun 2019 01:43:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id E9AD86B000D for ; Mon, 24 Jun 2019 01:43:39 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id d190so8880307pfa.0 for ; Sun, 23 Jun 2019 22:43:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5WJArPRhLKawZExF1a/OJKFWf27gCJZIRATflv1f+LA=; b=q2Dveix6wpMta/ym3PQ/cVjiUkSvrQDzXCQBPo4iT2EIZF3HQ4sePz9r9DADD1PUit JPALFWnIccWPNCOdp5V/jwojE0RrYFS6ctdeHnRP+qO8KJR2SlaWntMQ1TV64QxQGPLT 5DYQfu7QIwjK0X3jjY0cKa+LVtQvu4cnHstAWREnwunPY3fflnS5jiZlNSIMCatVAo/c 1tNkXUMfUu3e5zTI6mlkwyBIIqrgG/4XzQ6xraKqndhgokj7XI5DiH4HU2BIoDVFq8lV tcXZJd7jyK6Fs9GOijsTG4AVaqTHw0cmzU5m7C7IYj3CeEyCq7blB59pLYGkEro0FABM AXHg== X-Gm-Message-State: APjAAAUvdbM1m0g/mGARQlPYg6fMNE8fdAFyvge5GsRHgsx484JHSlUJ 3XOZGXmtNO/Eg+Mp8YbzXA4Fj8vSM2lIRlcr/SPRtcVqXvaoJLuafe9aqQmNeG5zGMk2Ne1MjvT ob+/S0h8aBA+P7WfAWhshvDwo2olwiFYP3pfcIFJrYDHFw/+yoD14MiwBgFcI5M8= X-Received: by 2002:a63:7945:: with SMTP id u66mr5025540pgc.127.1561355019489; Sun, 23 Jun 2019 22:43:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqz379UeVOpSClnSb+pjSENLDD2UAa2vzt4WlD3jMgoLaY5k3RU+CbgAIqwNslSQckpECHv8 X-Received: by 2002:a63:7945:: with SMTP id u66mr5025499pgc.127.1561355018735; Sun, 23 Jun 2019 22:43:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355018; cv=none; d=google.com; s=arc-20160816; b=kV9hRarkVYAQ61urPlzmfVM5aGSQx6NUkQmhEwIFfgd+MHBr3CkUZR1e/dH0D7v+67 rf5MZ3We70QnMKYwcHIzAzRwlkKIgxlzuDOCttBYXUofoPgfDLQxq9wc94dZCQYshtD9 pDNESCusCaXJRPe/ITCnPxNop8u8sikMgjN0SSPyFDbgACuHH1RCeol1t6eryeze6HV0 6HBHxMzQqUNsf2oa0wvV81yHJX53Gk091Fg8CV/OvJeNsarjFY7DyGZHGF7Nw9WYsw8/ gG6XL+bROZAGTBojzJL0UNxXRHu6BwVrz/gC1ilJAX/RuaJVbGf+5GUrzcHXD189lk4D gW3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=5WJArPRhLKawZExF1a/OJKFWf27gCJZIRATflv1f+LA=; b=R6QmQxrBuHvqtimsPJhEQNWDsT0+ALNAKAhAPQACf8qqiD64mQZhoSwz6Y5lmovd2a Chin28CrKWrme1c0LwWm2g9eeszuKqdi7LMxD+OJo3yap4E22aukPxTsb009TrrVSX9d y4+pDZ73qdQy4lySs326VVNf9ejXVSYnleDUVwltGRtAXMfaHOzJZ6eg576ZpxNfzWAM LmcwMJVYKE1EAIjNh7GbDxY7H8FP5faUcTvnlvoQIxDlhRwPlkZa6m1dcjsUn3hY7/Ly imRY+azAkq4enRP5yZ2vz0eAYS9pz8MdUsdeyU6AJhRbwBF4FvwU0Z2IUYhrsNI0+7e5 QMjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=YNs3gx+c; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id n1si3813539plk.388.2019.06.23.22.43.38 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=YNs3gx+c; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5WJArPRhLKawZExF1a/OJKFWf27gCJZIRATflv1f+LA=; b=YNs3gx+cZZv1ocI36RZcvQyY9T QTQAtNYVUae846VvayO26Eo+iWXkBfk4QXQM6mmZ5W6Zx0yJsWF18x+cP04E4Yy/Qu+9KKD8R4nRm HUfGGHLa7joE4G/VLRECg18AwszpPm3Dm/vU5chIb9rtFkH8A/EDQCh6t/mX19oO6tHcN1wx9YlGf J9IRgkwvTb8sJ4unejzwORv8IR/ev5ze7WeDv/2sC7ro8hXmHsJjeh4WUn9fJNDBEKBqyzxGctyDo nOQDQkr2twVVOQPP4YTh47PUmzt9r88vq5a82lkOHFOHV54/hbA3uXyXBxpCBr+tJrhKc77DWOAZG ZY9VAwnA==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlP-0006JM-V8; Mon, 24 Jun 2019 05:43:36 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/17] riscv: refactor the IPI code Date: Mon, 24 Jun 2019 07:43:00 +0200 Message-Id: <20190624054311.30256-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This prepare for adding native non-SBI IPI code. Signed-off-by: Christoph Hellwig --- arch/riscv/kernel/smp.c | 55 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 5a9834503a2f..8cd730239613 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -78,13 +78,38 @@ static void ipi_stop(void) wait_for_interrupt(); } +static void send_ipi_mask(const struct cpumask *mask, enum ipi_message_type op) +{ + int cpuid, hartid; + struct cpumask hartid_mask; + + cpumask_clear(&hartid_mask); + mb(); + for_each_cpu(cpuid, mask) { + set_bit(op, &ipi_data[cpuid].bits); + hartid = cpuid_to_hartid_map(cpuid); + cpumask_set_cpu(hartid, &hartid_mask); + } + mb(); + sbi_send_ipi(cpumask_bits(&hartid_mask)); +} + +static void send_ipi_single(int cpu, enum ipi_message_type op) +{ + send_ipi_mask(cpumask_of(cpu), op); +} + +static inline void clear_ipi(void) +{ + csr_clear(CSR_SIP, SIE_SSIE); +} + void riscv_software_interrupt(void) { unsigned long *pending_ipis = &ipi_data[smp_processor_id()].bits; unsigned long *stats = ipi_data[smp_processor_id()].stats; - /* Clear pending IPI */ - csr_clear(CSR_SIP, SIE_SSIE); + clear_ipi(); while (true) { unsigned long ops; @@ -118,23 +143,6 @@ void riscv_software_interrupt(void) } } -static void -send_ipi_message(const struct cpumask *to_whom, enum ipi_message_type operation) -{ - int cpuid, hartid; - struct cpumask hartid_mask; - - cpumask_clear(&hartid_mask); - mb(); - for_each_cpu(cpuid, to_whom) { - set_bit(operation, &ipi_data[cpuid].bits); - hartid = cpuid_to_hartid_map(cpuid); - cpumask_set_cpu(hartid, &hartid_mask); - } - mb(); - sbi_send_ipi(cpumask_bits(&hartid_mask)); -} - static const char * const ipi_names[] = { [IPI_RESCHEDULE] = "Rescheduling interrupts", [IPI_CALL_FUNC] = "Function call interrupts", @@ -156,12 +164,12 @@ void show_ipi_stats(struct seq_file *p, int prec) void arch_send_call_function_ipi_mask(struct cpumask *mask) { - send_ipi_message(mask, IPI_CALL_FUNC); + send_ipi_mask(mask, IPI_CALL_FUNC); } void arch_send_call_function_single_ipi(int cpu) { - send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC); + send_ipi_single(cpu, IPI_CALL_FUNC); } void smp_send_stop(void) @@ -176,7 +184,7 @@ void smp_send_stop(void) if (system_state <= SYSTEM_RUNNING) pr_crit("SMP: stopping secondary CPUs\n"); - send_ipi_message(&mask, IPI_CPU_STOP); + send_ipi_mask(&mask, IPI_CPU_STOP); } /* Wait up to one second for other CPUs to stop */ @@ -191,6 +199,5 @@ void smp_send_stop(void) void smp_send_reschedule(int cpu) { - send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE); + send_ipi_single(cpu, IPI_RESCHEDULE); } - From patchwork Mon Jun 24 05:43:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F5F276 for ; Mon, 24 Jun 2019 05:43:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E5BD28B1E for ; Mon, 24 Jun 2019 05:43:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 426A528B30; Mon, 24 Jun 2019 05:43:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 643D428B01 for ; Mon, 24 Jun 2019 05:43:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE5776B000E; Mon, 24 Jun 2019 01:43:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A968B8E0002; Mon, 24 Jun 2019 01:43:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95F1E8E0001; Mon, 24 Jun 2019 01:43:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 4F4B96B000E for ; Mon, 24 Jun 2019 01:43:44 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id d190so8880411pfa.0 for ; Sun, 23 Jun 2019 22:43:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1VZ6olXsDVo05r/vw9X1fL97B9kBEGZBrL4NWLVZjSo=; b=h1x3EQugIQLAmyXAcT76CoCqv0jIdavGsJK11OI91jxJ/qCZsZyxQ3AbRNWc9JSQDv 4zIhBth/FMWl/DdqciqQHck6b/LrS3gSL2Mk/u5X3Z3XS9AKWiCvggSuQak+ijDqA4ss cBlBV0Vld08RNJ0qqdZ6u8L77YuNxlGN3mCdUKqnQ1rkInDnED2E1H/o5S0LTF77sGr8 TeEpyyaAw2tbvgqw8xq0FrflRKKpm/h1Ha2EHSsrTaNUJU+rT5UE0d7pA6fkXdB9Os0x bEKlGg5m2RWXsubheksPzNwNxUILGnzkREexEDOMAwpt1zIMgTkxvTfv0Gx1kwB4ZIjp bPzA== X-Gm-Message-State: APjAAAWdkF0dHKol+pTKUT/rHfHGjZQQyXY9r85xcP3H9B2Kud4raOW/ sm3UtW0OkbR/nWOfZgACcIEjXHRYIseTvJlnWsMUiamXHVd/S8YQB6usx2W/q/XXZDmyFzm+sok XzVP98fKCDb8mB1SwQIqh0oy5hhb7agTh6asOoMsq6Hk/ODYOWbzytTjiWo8iPQE= X-Received: by 2002:a63:6ecf:: with SMTP id j198mr31072484pgc.437.1561355023800; Sun, 23 Jun 2019 22:43:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6Zcl6n+cGps1DW8CqxmVVpCX9Gncu7ig2hUB4h8A3349CUoH7x0vDbYNduhLTwR7SOivK X-Received: by 2002:a63:6ecf:: with SMTP id j198mr31072399pgc.437.1561355022021; Sun, 23 Jun 2019 22:43:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355022; cv=none; d=google.com; s=arc-20160816; b=X8AkRDNVEN2CRR1gMhr4GHhJC2+Nw95TNDFmATMZlmkAXu/mhXGCSiQm4eZzMueD6b E1rg0gvmiGl4Oj1a6ccUZVAWBK00agLSH3x9BvN0izYfTNxTvVLI16mYYsSNjsYsnThG 5bjWHI1Su10XWkCptpk4M5cghBuG6VJQOXEwK0XIEx0k5ueV26s+5/m8q664HiFlHOTb o0wk1/JW4UKWn7tKD3LI+sU3YH7fTdwbPMPFzhQNCADZh+ZGrY1lkwC4zUdkeABwy/8u GJJdj5FD7FevLItxed5LuSBEaC9wdcpBU6tXTgjSrxgfEky8rLpnTdbpy2FSxAdTEatr 316w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=1VZ6olXsDVo05r/vw9X1fL97B9kBEGZBrL4NWLVZjSo=; b=HP8VfUYLB9dguW6kZG7iSYzNc+RVPByrJk+lL+3qLDaXdxW693RdCddXrF8TeFUbF2 WR5pjkdLYL6uomObREcMfRXPfCN0Afz5rNtY88kQg8gEaSawvDTU6szGSJwe6FfJ6tvJ m1ZJs9zb0s0PsNzkCnzoaiyIJTXf96e7UUKpmLRkYSYhfp/bECD/aNkZ6hKkyN9dvCHD rHjTCFdX2Hc6avAB9nR8ysJQrIPPgRnMdSN3aIZnrxfWbKXFWkJBgn8lA9B2UzBsIZcu /k/9X1Brn7OzXB9IOnONAa7w5h6R9nzll6m0fl8gKFkGIWEz5Fpr9Or1FxjOT35gfxPp fAjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=GKUpgTkc; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id m189si6121892pgm.443.2019.06.23.22.43.41 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=GKUpgTkc; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1VZ6olXsDVo05r/vw9X1fL97B9kBEGZBrL4NWLVZjSo=; b=GKUpgTkcH9KHT88jamoPKh70p0 IN3GblQ49Fz2anYIBJH7aTQZ0xqbFdD8hT5MLUwbtcjVnJIy2DauGHkm+xIsciUMIf1OKtmmfYwEt wCBC+maxFEehgksaA0UJBvBOoYmz1xR7reNeaSdaEKKoWZQAkgmFmX2LjpMGgEGQ3zacxTxVAQT0s Gl/VQ2VeTsNUPIRdk/TT4xG0gOZK4ui6tgVIO1dg5YyM0REv0A0Kg+cuBeHDJe6kuPu0qVD76xbr4 SwqjVj9pHx9KEZ4BfM+TGyv9852VBWtbrBqFEp3etkkZfTt54X971ljna9EbRfH8WyghJZJBIwdjp PXAsqc8g==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlT-0006NA-9z; Mon, 24 Jun 2019 05:43:40 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/17] riscv: abstract out CSR names for supervisor vs machine mode Date: Mon, 24 Jun 2019 07:43:01 +0200 Message-Id: <20190624054311.30256-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Many of the privileged CSRs exist in a supervisor and machine version that are used very similarly. Provide a new X-naming layer so that we don't have to ifdef everywhere for M-mode Linux support. Contains contributions from Damien Le Moal . Signed-off-by: Christoph Hellwig Reviewed-by: Atish Patra --- arch/riscv/Kconfig | 4 ++ arch/riscv/include/asm/asm.h | 6 +++ arch/riscv/include/asm/csr.h | 58 ++++++++++++++++++++++++++-- arch/riscv/include/asm/irqflags.h | 12 +++--- arch/riscv/include/asm/processor.h | 2 +- arch/riscv/include/asm/ptrace.h | 16 ++++---- arch/riscv/include/asm/switch_to.h | 8 ++-- arch/riscv/kernel/asm-offsets.c | 8 ++-- arch/riscv/kernel/entry.S | 62 ++++++++++++++++-------------- arch/riscv/kernel/fpu.S | 8 ++-- arch/riscv/kernel/head.S | 12 +++--- arch/riscv/kernel/irq.c | 4 +- arch/riscv/kernel/process.c | 15 ++++---- arch/riscv/kernel/signal.c | 21 +++++----- arch/riscv/kernel/traps.c | 16 ++++---- arch/riscv/lib/uaccess.S | 12 +++--- arch/riscv/mm/extable.c | 4 +- arch/riscv/mm/fault.c | 6 +-- drivers/clocksource/timer-riscv.c | 8 ++-- drivers/irqchip/irq-sifive-plic.c | 4 +- 20 files changed, 177 insertions(+), 109 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 2c19baa8d6c3..2185481d1589 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -52,6 +52,10 @@ config RISCV select ARCH_HAS_MMIOWB select HAVE_EBPF_JIT if 64BIT +# set if we run in machine mode, cleared if we run in supervisor mode +config M_MODE + bool + config MMU def_bool y diff --git a/arch/riscv/include/asm/asm.h b/arch/riscv/include/asm/asm.h index 5a02b7d50940..14604f01e9f8 100644 --- a/arch/riscv/include/asm/asm.h +++ b/arch/riscv/include/asm/asm.h @@ -65,4 +65,10 @@ #error "Unexpected __SIZEOF_SHORT__" #endif +#ifdef CONFIG_M_MODE +# define Xret mret +#else +# define Xret sret +#endif + #endif /* _ASM_RISCV_ASM_H */ diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index a18923fa23c8..026a761835b7 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -11,8 +11,11 @@ /* Status register flags */ #define SR_SIE _AC(0x00000002, UL) /* Supervisor Interrupt Enable */ +#define SR_MIE _AC(0x00000008, UL) /* Machine Interrupt Enable */ #define SR_SPIE _AC(0x00000020, UL) /* Previous Supervisor IE */ +#define SR_MPIE _AC(0x00000080, UL) /* Previous Machine IE */ #define SR_SPP _AC(0x00000100, UL) /* Previously Supervisor */ +#define SR_MPP _AC(0x00001800, UL) /* Previously Machine */ #define SR_SUM _AC(0x00040000, UL) /* Supervisor User Memory Access */ #define SR_FS _AC(0x00006000, UL) /* Floating-point Status */ @@ -44,8 +47,8 @@ #define SATP_MODE SATP_MODE_39 #endif -/* SCAUSE */ -#define SCAUSE_IRQ_FLAG (_AC(1, UL) << (__riscv_xlen - 1)) +/* *CAUSE */ +#define XCAUSE_IRQ_FLAG (_AC(1, UL) << (__riscv_xlen - 1)) #define IRQ_U_SOFT 0 #define IRQ_S_SOFT 1 @@ -67,11 +70,26 @@ #define EXC_LOAD_PAGE_FAULT 13 #define EXC_STORE_PAGE_FAULT 15 -/* SIE (Interrupt Enable) and SIP (Interrupt Pending) flags */ +/* MIE / MIP flags: */ +#define MIE_MSIE (_AC(0x1, UL) << IRQ_M_SOFT) +#define MIE_MTIE (_AC(0x1, UL) << IRQ_M_TIMER) +#define MIE_MEIE (_AC(0x1, UL) << IRQ_M_EXT) + +/* SIE / SIP flags: */ #define SIE_SSIE (_AC(0x1, UL) << IRQ_S_SOFT) #define SIE_STIE (_AC(0x1, UL) << IRQ_S_TIMER) #define SIE_SEIE (_AC(0x1, UL) << IRQ_S_EXT) +/* symbolic CSR names: */ +#define CSR_MSTATUS 0x300 +#define CSR_MIE 0x304 +#define CSR_MTVEC 0x305 +#define CSR_MSCRATCH 0x340 +#define CSR_MEPC 0x341 +#define CSR_MCAUSE 0x342 +#define CSR_MTVAL 0x343 +#define CSR_MIP 0x344 + #define CSR_CYCLE 0xc00 #define CSR_TIME 0xc01 #define CSR_INSTRET 0xc02 @@ -89,6 +107,40 @@ #define CSR_TIMEH 0xc81 #define CSR_INSTRETH 0xc82 +#ifdef CONFIG_M_MODE +# define CSR_XSTATUS CSR_MSTATUS +# define CSR_XIE CSR_MIE +# define CSR_XTVEC CSR_MTVEC +# define CSR_XSCRATCH CSR_MSCRATCH +# define CSR_XEPC CSR_MEPC +# define CSR_XCAUSE CSR_MCAUSE +# define CSR_XTVAL CSR_MTVAL +# define CSR_XIP CSR_MIP + +# define SR_XIE SR_MIE +# define SR_XPIE SR_MPIE +# define SR_XPP SR_MPP + +# define XIE_XTIE MIE_MTIE +# define XIE_XEIE MIE_MEIE +#else /* CONFIG_M_MODE */ +# define CSR_XSTATUS CSR_SSTATUS +# define CSR_XIE CSR_SIE +# define CSR_XTVEC CSR_STVEC +# define CSR_XSCRATCH CSR_SSCRATCH +# define CSR_XEPC CSR_SEPC +# define CSR_XCAUSE CSR_SCAUSE +# define CSR_XTVAL CSR_STVAL +# define CSR_XIP CSR_SIP + +# define SR_XIE SR_SIE +# define SR_XPIE SR_SPIE +# define SR_XPP SR_SPP + +# define XIE_XTIE SIE_STIE +# define XIE_XEIE SIE_SEIE +#endif /* CONFIG_M_MODE */ + #ifndef __ASSEMBLY__ #define csr_swap(csr, val) \ diff --git a/arch/riscv/include/asm/irqflags.h b/arch/riscv/include/asm/irqflags.h index e70f647ce3b7..ba2828a37d72 100644 --- a/arch/riscv/include/asm/irqflags.h +++ b/arch/riscv/include/asm/irqflags.h @@ -13,31 +13,31 @@ /* read interrupt enabled status */ static inline unsigned long arch_local_save_flags(void) { - return csr_read(CSR_SSTATUS); + return csr_read(CSR_XSTATUS); } /* unconditionally enable interrupts */ static inline void arch_local_irq_enable(void) { - csr_set(CSR_SSTATUS, SR_SIE); + csr_set(CSR_XSTATUS, SR_XIE); } /* unconditionally disable interrupts */ static inline void arch_local_irq_disable(void) { - csr_clear(CSR_SSTATUS, SR_SIE); + csr_clear(CSR_XSTATUS, SR_XIE); } /* get status and disable interrupts */ static inline unsigned long arch_local_irq_save(void) { - return csr_read_clear(CSR_SSTATUS, SR_SIE); + return csr_read_clear(CSR_XSTATUS, SR_XIE); } /* test flags */ static inline int arch_irqs_disabled_flags(unsigned long flags) { - return !(flags & SR_SIE); + return !(flags & SR_XIE); } /* test hardware interrupt enable bit */ @@ -49,7 +49,7 @@ static inline int arch_irqs_disabled(void) /* set interrupt enabled status */ static inline void arch_local_irq_restore(unsigned long flags) { - csr_set(CSR_SSTATUS, flags & SR_SIE); + csr_set(CSR_XSTATUS, flags & SR_XIE); } #endif /* _ASM_RISCV_IRQFLAGS_H */ diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index f539149d04c2..46f825e34575 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -42,7 +42,7 @@ struct thread_struct { ((struct pt_regs *)(task_stack_page(tsk) + THREAD_SIZE \ - ALIGN(sizeof(struct pt_regs), STACK_ALIGN))) -#define KSTK_EIP(tsk) (task_pt_regs(tsk)->sepc) +#define KSTK_EIP(tsk) (task_pt_regs(tsk)->xepc) #define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp) diff --git a/arch/riscv/include/asm/ptrace.h b/arch/riscv/include/asm/ptrace.h index d48d1e13973c..7684d81d0e84 100644 --- a/arch/riscv/include/asm/ptrace.h +++ b/arch/riscv/include/asm/ptrace.h @@ -12,7 +12,7 @@ #ifndef __ASSEMBLY__ struct pt_regs { - unsigned long sepc; + unsigned long xepc; unsigned long ra; unsigned long sp; unsigned long gp; @@ -44,10 +44,10 @@ struct pt_regs { unsigned long t4; unsigned long t5; unsigned long t6; - /* Supervisor CSRs */ - unsigned long sstatus; - unsigned long sbadaddr; - unsigned long scause; + /* Supervisor/Machine CSRs */ + unsigned long xstatus; + unsigned long xbadaddr; + unsigned long xcause; /* a0 value before the syscall */ unsigned long orig_a0; }; @@ -58,18 +58,18 @@ struct pt_regs { #define REG_FMT "%08lx" #endif -#define user_mode(regs) (((regs)->sstatus & SR_SPP) == 0) +#define user_mode(regs) (((regs)->xstatus & SR_XPP) == 0) /* Helpers for working with the instruction pointer */ static inline unsigned long instruction_pointer(struct pt_regs *regs) { - return regs->sepc; + return regs->xepc; } static inline void instruction_pointer_set(struct pt_regs *regs, unsigned long val) { - regs->sepc = val; + regs->xepc = val; } #define profile_pc(regs) instruction_pointer(regs) diff --git a/arch/riscv/include/asm/switch_to.h b/arch/riscv/include/asm/switch_to.h index 853b65ef656d..4cbe33bb5dd7 100644 --- a/arch/riscv/include/asm/switch_to.h +++ b/arch/riscv/include/asm/switch_to.h @@ -16,13 +16,13 @@ extern void __fstate_restore(struct task_struct *restore_from); static inline void __fstate_clean(struct pt_regs *regs) { - regs->sstatus |= (regs->sstatus & ~(SR_FS)) | SR_FS_CLEAN; + regs->xstatus |= (regs->xstatus & ~(SR_FS)) | SR_FS_CLEAN; } static inline void fstate_save(struct task_struct *task, struct pt_regs *regs) { - if ((regs->sstatus & SR_FS) == SR_FS_DIRTY) { + if ((regs->xstatus & SR_FS) == SR_FS_DIRTY) { __fstate_save(task); __fstate_clean(regs); } @@ -31,7 +31,7 @@ static inline void fstate_save(struct task_struct *task, static inline void fstate_restore(struct task_struct *task, struct pt_regs *regs) { - if ((regs->sstatus & SR_FS) != SR_FS_OFF) { + if ((regs->xstatus & SR_FS) != SR_FS_OFF) { __fstate_restore(task); __fstate_clean(regs); } @@ -43,7 +43,7 @@ static inline void __switch_to_aux(struct task_struct *prev, struct pt_regs *regs; regs = task_pt_regs(prev); - if (unlikely(regs->sstatus & SR_SD)) + if (unlikely(regs->xstatus & SR_SD)) fstate_save(prev, regs); fstate_restore(next, task_pt_regs(next)); } diff --git a/arch/riscv/kernel/asm-offsets.c b/arch/riscv/kernel/asm-offsets.c index 9f5628c38ac9..d631ad41917b 100644 --- a/arch/riscv/kernel/asm-offsets.c +++ b/arch/riscv/kernel/asm-offsets.c @@ -71,7 +71,7 @@ void asm_offsets(void) OFFSET(TASK_THREAD_FCSR, task_struct, thread.fstate.fcsr); DEFINE(PT_SIZE, sizeof(struct pt_regs)); - OFFSET(PT_SEPC, pt_regs, sepc); + OFFSET(PT_XEPC, pt_regs, xepc); OFFSET(PT_RA, pt_regs, ra); OFFSET(PT_FP, pt_regs, s0); OFFSET(PT_S0, pt_regs, s0); @@ -105,9 +105,9 @@ void asm_offsets(void) OFFSET(PT_T6, pt_regs, t6); OFFSET(PT_GP, pt_regs, gp); OFFSET(PT_ORIG_A0, pt_regs, orig_a0); - OFFSET(PT_SSTATUS, pt_regs, sstatus); - OFFSET(PT_SBADADDR, pt_regs, sbadaddr); - OFFSET(PT_SCAUSE, pt_regs, scause); + OFFSET(PT_XSTATUS, pt_regs, xstatus); + OFFSET(PT_XBADADDR, pt_regs, xbadaddr); + OFFSET(PT_XCAUSE, pt_regs, xcause); /* * THREAD_{F,X}* might be larger than a S-type offset can handle, but diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S index bc7a56e1ca6f..b722ce20dc20 100644 --- a/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S @@ -26,14 +26,14 @@ /* * If coming from userspace, preserve the user thread pointer and load - * the kernel thread pointer. If we came from the kernel, sscratch - * will contain 0, and we should continue on the current TP. + * the kernel thread pointer. If we came from the kernel, the scratch + * register will contain 0, and we should continue on the current TP. */ - csrrw tp, CSR_SSCRATCH, tp + csrrw tp, CSR_XSCRATCH, tp bnez tp, _save_context _restore_kernel_tpsp: - csrr tp, CSR_SSCRATCH + csrr tp, CSR_XSCRATCH REG_S sp, TASK_TI_KERNEL_SP(tp) _save_context: REG_S sp, TASK_TI_USER_SP(tp) @@ -79,16 +79,16 @@ _save_context: li t0, SR_SUM | SR_FS REG_L s0, TASK_TI_USER_SP(tp) - csrrc s1, CSR_SSTATUS, t0 - csrr s2, CSR_SEPC - csrr s3, CSR_STVAL - csrr s4, CSR_SCAUSE - csrr s5, CSR_SSCRATCH + csrrc s1, CSR_XSTATUS, t0 + csrr s2, CSR_XEPC + csrr s3, CSR_XTVAL + csrr s4, CSR_XCAUSE + csrr s5, CSR_XSCRATCH REG_S s0, PT_SP(sp) - REG_S s1, PT_SSTATUS(sp) - REG_S s2, PT_SEPC(sp) - REG_S s3, PT_SBADADDR(sp) - REG_S s4, PT_SCAUSE(sp) + REG_S s1, PT_XSTATUS(sp) + REG_S s2, PT_XEPC(sp) + REG_S s3, PT_XBADADDR(sp) + REG_S s4, PT_XCAUSE(sp) REG_S s5, PT_TP(sp) .endm @@ -97,10 +97,10 @@ _save_context: * registers from the stack. */ .macro RESTORE_ALL - REG_L a0, PT_SSTATUS(sp) - REG_L a2, PT_SEPC(sp) - csrw CSR_SSTATUS, a0 - csrw CSR_SEPC, a2 + REG_L a0, PT_XSTATUS(sp) + REG_L a2, PT_XEPC(sp) + csrw CSR_XSTATUS, a0 + csrw CSR_XEPC, a2 REG_L x1, PT_RA(sp) REG_L x3, PT_GP(sp) @@ -144,10 +144,10 @@ ENTRY(handle_exception) SAVE_ALL /* - * Set sscratch register to 0, so that if a recursive exception + * Set the scratch register to 0, so that if a recursive exception * occurs, the exception vector knows it came from the kernel */ - csrw CSR_SSCRATCH, x0 + csrw CSR_XSCRATCH, x0 /* Load the global pointer */ .option push @@ -167,7 +167,7 @@ ENTRY(handle_exception) tail do_IRQ 1: /* Exceptions run with interrupts enabled */ - csrs sstatus, SR_SIE + csrs CSR_XSTATUS, SR_XIE /* Handle syscalls */ li t0, EXC_SYSCALL @@ -194,7 +194,7 @@ handle_syscall: * scall instruction on sret */ addi s2, s2, 0x4 - REG_S s2, PT_SEPC(sp) + REG_S s2, PT_XEPC(sp) /* Trace syscalls, but only if requested by the user. */ REG_L t0, TASK_TI_FLAGS(tp) andi t0, t0, _TIF_SYSCALL_WORK @@ -221,9 +221,15 @@ ret_from_syscall: bnez t0, handle_syscall_trace_exit ret_from_exception: - REG_L s0, PT_SSTATUS(sp) - csrc sstatus, SR_SIE + REG_L s0, PT_XSTATUS(sp) + csrc CSR_XSTATUS, SR_XIE +#ifdef CONFIG_M_MODE + /* the MPP value is too large to be used as an immediate arg for addi */ + li t0, SR_MPP + and s0, s0, t0 +#else andi s0, s0, SR_SPP +#endif bnez s0, resume_kernel resume_userspace: @@ -237,14 +243,14 @@ resume_userspace: REG_S s0, TASK_TI_KERNEL_SP(tp) /* - * Save TP into sscratch, so we can find the kernel data structures - * again. + * Save TP into the scratch register , so we can find the kernel data + * structures again. */ - csrw CSR_SSCRATCH, tp + csrw CSR_XSCRATCH, tp restore_all: RESTORE_ALL - sret + Xret #if IS_ENABLED(CONFIG_PREEMPT) resume_kernel: @@ -265,7 +271,7 @@ work_pending: bnez s1, work_resched work_notifysig: /* Handle pending signals and notify-resume requests */ - csrs sstatus, SR_SIE /* Enable interrupts for do_notify_resume() */ + csrs CSR_XSTATUS, SR_XIE /* Enable interrupts for do_notify_resume() */ move a0, sp /* pt_regs */ move a1, s0 /* current_thread_info->flags */ tail do_notify_resume diff --git a/arch/riscv/kernel/fpu.S b/arch/riscv/kernel/fpu.S index 1defb0618aff..1dade31f4564 100644 --- a/arch/riscv/kernel/fpu.S +++ b/arch/riscv/kernel/fpu.S @@ -23,7 +23,7 @@ ENTRY(__fstate_save) li a2, TASK_THREAD_F0 add a0, a0, a2 li t1, SR_FS - csrs sstatus, t1 + csrs CSR_XSTATUS, t1 frcsr t0 fsd f0, TASK_THREAD_F0_F0(a0) fsd f1, TASK_THREAD_F1_F0(a0) @@ -58,7 +58,7 @@ ENTRY(__fstate_save) fsd f30, TASK_THREAD_F30_F0(a0) fsd f31, TASK_THREAD_F31_F0(a0) sw t0, TASK_THREAD_FCSR_F0(a0) - csrc sstatus, t1 + csrc CSR_XSTATUS, t1 ret ENDPROC(__fstate_save) @@ -67,7 +67,7 @@ ENTRY(__fstate_restore) add a0, a0, a2 li t1, SR_FS lw t0, TASK_THREAD_FCSR_F0(a0) - csrs sstatus, t1 + csrs CSR_XSTATUS, t1 fld f0, TASK_THREAD_F0_F0(a0) fld f1, TASK_THREAD_F1_F0(a0) fld f2, TASK_THREAD_F2_F0(a0) @@ -101,6 +101,6 @@ ENTRY(__fstate_restore) fld f30, TASK_THREAD_F30_F0(a0) fld f31, TASK_THREAD_F31_F0(a0) fscsr t0 - csrc sstatus, t1 + csrc CSR_XSTATUS, t1 ret ENDPROC(__fstate_restore) diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 4e46f31072da..e5fa5481aa99 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -15,8 +15,8 @@ __INIT ENTRY(_start) /* Mask all interrupts */ - csrw CSR_SIE, zero - csrw CSR_SIP, zero + csrw CSR_XIE, zero + csrw CSR_XIP, zero /* Load the global pointer */ .option push @@ -29,7 +29,7 @@ ENTRY(_start) * floating point in kernel space */ li t0, SR_FS - csrc sstatus, t0 + csrc CSR_XSTATUS, t0 /* Pick one hart to run the main boot sequence */ la a3, hart_lottery @@ -78,7 +78,7 @@ relocate: /* Point stvec to virtual address of intruction after satp write */ la a0, 1f add a0, a0, a1 - csrw CSR_STVEC, a0 + csrw CSR_XTVEC, a0 /* Compute satp for kernel page tables, but don't load it yet */ la a2, swapper_pg_dir @@ -101,7 +101,7 @@ relocate: 1: /* Set trap vector to spin forever to help debug */ la a0, .Lsecondary_park - csrw CSR_STVEC, a0 + csrw CSR_XTVEC, a0 /* Reload the global pointer */ .option push @@ -127,7 +127,7 @@ relocate: /* Set trap vector to spin forever to help debug */ la a3, .Lsecondary_park - csrw CSR_STVEC, a3 + csrw CSR_XTVEC, a3 slli a3, a0, LGREG la a1, __cpu_up_stack_pointer diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c index 6d8659388c49..804ff70bb853 100644 --- a/arch/riscv/kernel/irq.c +++ b/arch/riscv/kernel/irq.c @@ -29,7 +29,7 @@ asmlinkage void __irq_entry do_IRQ(struct pt_regs *regs) struct pt_regs *old_regs = set_irq_regs(regs); irq_enter(); - switch (regs->scause & ~SCAUSE_IRQ_FLAG) { + switch (regs->xcause & ~XCAUSE_IRQ_FLAG) { case INTERRUPT_CAUSE_TIMER: riscv_timer_interrupt(); break; @@ -46,7 +46,7 @@ asmlinkage void __irq_entry do_IRQ(struct pt_regs *regs) handle_arch_irq(regs); break; default: - pr_alert("unexpected interrupt cause 0x%lx", regs->scause); + pr_alert("unexpected interrupt cause 0x%lx", regs->xcause); BUG(); } irq_exit(); diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c index f23794bd1e90..1f03920d07d3 100644 --- a/arch/riscv/kernel/process.c +++ b/arch/riscv/kernel/process.c @@ -34,7 +34,7 @@ void show_regs(struct pt_regs *regs) show_regs_print_info(KERN_DEFAULT); pr_cont("sepc: " REG_FMT " ra : " REG_FMT " sp : " REG_FMT "\n", - regs->sepc, regs->ra, regs->sp); + regs->xepc, regs->ra, regs->sp); pr_cont(" gp : " REG_FMT " tp : " REG_FMT " t0 : " REG_FMT "\n", regs->gp, regs->tp, regs->t0); pr_cont(" t1 : " REG_FMT " t2 : " REG_FMT " s0 : " REG_FMT "\n", @@ -56,17 +56,17 @@ void show_regs(struct pt_regs *regs) pr_cont(" t5 : " REG_FMT " t6 : " REG_FMT "\n", regs->t5, regs->t6); - pr_cont("sstatus: " REG_FMT " sbadaddr: " REG_FMT " scause: " REG_FMT "\n", - regs->sstatus, regs->sbadaddr, regs->scause); + pr_cont("status: " REG_FMT " badaddr: " REG_FMT " cause: " REG_FMT "\n", + regs->xstatus, regs->xbadaddr, regs->xcause); } void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp) { - regs->sstatus = SR_SPIE; + regs->xstatus = SR_XPIE; if (has_fpu) - regs->sstatus |= SR_FS_INITIAL; - regs->sepc = pc; + regs->xstatus |= SR_FS_INITIAL; + regs->xepc = pc; regs->sp = sp; set_fs(USER_DS); } @@ -101,7 +101,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, const register unsigned long gp __asm__ ("gp"); memset(childregs, 0, sizeof(struct pt_regs)); childregs->gp = gp; - childregs->sstatus = SR_SPP | SR_SPIE; /* Supervisor, irqs on */ + /* Supervisor/Machine, irqs on: */ + childregs->xstatus = SR_XPP | SR_XPIE; p->thread.ra = (unsigned long)ret_from_kernel_thread; p->thread.s[0] = usp; /* fn */ diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c index 1fe1b02e44d0..dfb26b64e17a 100644 --- a/arch/riscv/kernel/signal.c +++ b/arch/riscv/kernel/signal.c @@ -124,7 +124,7 @@ SYSCALL_DEFINE0(rt_sigreturn) pr_info_ratelimited( "%s[%d]: bad frame in %s: frame=%p pc=%p sp=%p\n", task->comm, task_pid_nr(task), __func__, - frame, (void *)regs->sepc, (void *)regs->sp); + frame, (void *)regs->xepc, (void *)regs->sp); } force_sig(SIGSEGV, task); return 0; @@ -199,7 +199,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, * We always pass siginfo and mcontext, regardless of SA_SIGINFO, * since some things rely on this (e.g. glibc's debug/segfault.c). */ - regs->sepc = (unsigned long)ksig->ka.sa.sa_handler; + regs->xepc = (unsigned long)ksig->ka.sa.sa_handler; regs->sp = (unsigned long)frame; regs->a0 = ksig->sig; /* a0: signal number */ regs->a1 = (unsigned long)(&frame->info); /* a1: siginfo pointer */ @@ -208,7 +208,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, #if DEBUG_SIG pr_info("SIG deliver (%s:%d): sig=%d pc=%p ra=%p sp=%p\n", current->comm, task_pid_nr(current), ksig->sig, - (void *)regs->sepc, (void *)regs->ra, frame); + (void *)regs->xepc, (void *)regs->ra, frame); #endif return 0; @@ -220,10 +220,9 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) int ret; /* Are we from a system call? */ - if (regs->scause == EXC_SYSCALL) { + if (regs->xcause == EXC_SYSCALL) { /* Avoid additional syscall restarting via ret_from_exception */ - regs->scause = -1UL; - + regs->xcause = -1UL; /* If so, check system call restarting.. */ switch (regs->a0) { case -ERESTART_RESTARTBLOCK: @@ -239,7 +238,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) /* fallthrough */ case -ERESTARTNOINTR: regs->a0 = regs->orig_a0; - regs->sepc -= 0x4; + regs->xepc -= 0x4; break; } } @@ -261,9 +260,9 @@ static void do_signal(struct pt_regs *regs) } /* Did we come from a system call? */ - if (regs->scause == EXC_SYSCALL) { + if (regs->xcause == EXC_SYSCALL) { /* Avoid additional syscall restarting via ret_from_exception */ - regs->scause = -1UL; + regs->xcause = -1UL; /* Restart the system call - no handlers present */ switch (regs->a0) { @@ -271,12 +270,12 @@ static void do_signal(struct pt_regs *regs) case -ERESTARTSYS: case -ERESTARTNOINTR: regs->a0 = regs->orig_a0; - regs->sepc -= 0x4; + regs->xepc -= 0x4; break; case -ERESTART_RESTARTBLOCK: regs->a0 = regs->orig_a0; regs->a7 = __NR_restart_syscall; - regs->sepc -= 0x4; + regs->xepc -= 0x4; break; } } diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 6b32190ba73c..e028276928f8 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -40,7 +40,7 @@ void die(struct pt_regs *regs, const char *str) print_modules(); show_regs(regs); - ret = notify_die(DIE_OOPS, str, regs, 0, regs->scause, SIGSEGV); + ret = notify_die(DIE_OOPS, str, regs, 0, regs->xcause, SIGSEGV); bust_spinlocks(0); add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); @@ -84,7 +84,7 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code, #define DO_ERROR_INFO(name, signo, code, str) \ asmlinkage void name(struct pt_regs *regs) \ { \ - do_trap_error(regs, signo, code, regs->sepc, "Oops - " str); \ + do_trap_error(regs, signo, code, regs->xepc, "Oops - " str); \ } DO_ERROR_INFO(do_trap_unknown, @@ -127,12 +127,12 @@ asmlinkage void do_trap_break(struct pt_regs *regs) if (!user_mode(regs)) { enum bug_trap_type type; - type = report_bug(regs->sepc, regs); + type = report_bug(regs->xepc, regs); switch (type) { case BUG_TRAP_TYPE_NONE: break; case BUG_TRAP_TYPE_WARN: - regs->sepc += get_break_insn_length(regs->sepc); + regs->xepc += get_break_insn_length(regs->xepc); break; case BUG_TRAP_TYPE_BUG: die(regs, "Kernel BUG"); @@ -140,7 +140,7 @@ asmlinkage void do_trap_break(struct pt_regs *regs) } #endif /* CONFIG_GENERIC_BUG */ - force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)(regs->sepc), current); + force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)(regs->xepc), current); } #ifdef CONFIG_GENERIC_BUG @@ -165,9 +165,9 @@ void __init trap_init(void) * Set sup0 scratch register to 0, indicating to exception vector * that we are presently executing in the kernel */ - csr_write(CSR_SSCRATCH, 0); + csr_write(CSR_XSCRATCH, 0); /* Set the exception vector address */ - csr_write(CSR_STVEC, &handle_exception); + csr_write(CSR_XTVEC, &handle_exception); /* Enable all interrupts */ - csr_write(CSR_SIE, -1); + csr_write(CSR_XIE, -1); } diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S index 399e6f0c2d98..f47a2ea4dc89 100644 --- a/arch/riscv/lib/uaccess.S +++ b/arch/riscv/lib/uaccess.S @@ -18,7 +18,7 @@ ENTRY(__asm_copy_from_user) /* Enable access to user memory */ li t6, SR_SUM - csrs sstatus, t6 + csrs CSR_XSTATUS, t6 add a3, a1, a2 /* Use word-oriented copy only if low-order bits match */ @@ -47,7 +47,7 @@ ENTRY(__asm_copy_from_user) 3: /* Disable access to user memory */ - csrc sstatus, t6 + csrc CSR_XSTATUS, t6 li a0, 0 ret 4: /* Edge case: unalignment */ @@ -72,7 +72,7 @@ ENTRY(__clear_user) /* Enable access to user memory */ li t6, SR_SUM - csrs sstatus, t6 + csrs CSR_XSTATUS, t6 add a3, a0, a1 addi t0, a0, SZREG-1 @@ -94,7 +94,7 @@ ENTRY(__clear_user) 3: /* Disable access to user memory */ - csrc sstatus, t6 + csrc CSR_XSTATUS, t6 li a0, 0 ret 4: /* Edge case: unalignment */ @@ -114,11 +114,11 @@ ENDPROC(__clear_user) /* Fixup code for __copy_user(10) and __clear_user(11) */ 10: /* Disable access to user memory */ - csrs sstatus, t6 + csrs CSR_XSTATUS, t6 mv a0, a2 ret 11: - csrs sstatus, t6 + csrs CSR_XSTATUS, t6 mv a0, a1 ret .previous diff --git a/arch/riscv/mm/extable.c b/arch/riscv/mm/extable.c index 7aed9178d365..e0659deeb16b 100644 --- a/arch/riscv/mm/extable.c +++ b/arch/riscv/mm/extable.c @@ -15,9 +15,9 @@ int fixup_exception(struct pt_regs *regs) { const struct exception_table_entry *fixup; - fixup = search_exception_tables(regs->sepc); + fixup = search_exception_tables(regs->xepc); if (fixup) { - regs->sepc = fixup->fixup; + regs->xepc = fixup->fixup; return 1; } return 0; diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c index 3e2708c626a8..377248e45bba 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -32,8 +32,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs) int code = SEGV_MAPERR; vm_fault_t fault; - cause = regs->scause; - addr = regs->sbadaddr; + cause = regs->xcause; + addr = regs->xbadaddr; tsk = current; mm = tsk->mm; @@ -51,7 +51,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs) goto vmalloc_fault; /* Enable interrupts if they were enabled in the parent context. */ - if (likely(regs->sstatus & SR_SPIE)) + if (likely(regs->xstatus & SR_XPIE)) local_irq_enable(); /* diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c index 5e6038fbf115..2e2d363faabf 100644 --- a/drivers/clocksource/timer-riscv.c +++ b/drivers/clocksource/timer-riscv.c @@ -28,7 +28,7 @@ static int riscv_clock_next_event(unsigned long delta, struct clock_event_device *ce) { - csr_set(sie, SIE_STIE); + csr_set(CSR_XIE, XIE_XTIE); sbi_set_timer(get_cycles64() + delta); return 0; } @@ -70,13 +70,13 @@ static int riscv_timer_starting_cpu(unsigned int cpu) ce->cpumask = cpumask_of(cpu); clockevents_config_and_register(ce, riscv_timebase, 100, 0x7fffffff); - csr_set(sie, SIE_STIE); + csr_set(CSR_XIE, XIE_XTIE); return 0; } static int riscv_timer_dying_cpu(unsigned int cpu) { - csr_clear(sie, SIE_STIE); + csr_clear(CSR_XIE, XIE_XTIE); return 0; } @@ -85,7 +85,7 @@ void riscv_timer_interrupt(void) { struct clock_event_device *evdev = this_cpu_ptr(&riscv_clock_event); - csr_clear(sie, SIE_STIE); + csr_clear(CSR_XIE, XIE_XTIE); evdev->event_handler(evdev); } diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index c72c036aea76..4ee96ac90ea4 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -179,7 +179,7 @@ static void plic_handle_irq(struct pt_regs *regs) WARN_ON_ONCE(!handler->present); - csr_clear(sie, SIE_SEIE); + csr_clear(CSR_XIE, XIE_XEIE); while ((hwirq = readl(claim))) { int irq = irq_find_mapping(plic_irqdomain, hwirq); @@ -190,7 +190,7 @@ static void plic_handle_irq(struct pt_regs *regs) generic_handle_irq(irq); writel(hwirq, claim); } - csr_set(sie, SIE_SEIE); + csr_set(CSR_XIE, XIE_XEIE); } /* From patchwork Mon Jun 24 05:43:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F74C76 for ; Mon, 24 Jun 2019 05:43:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3D0828B01 for ; Mon, 24 Jun 2019 05:43:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E69CB28B0B; Mon, 24 Jun 2019 05:43:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8664828B1E for ; Mon, 24 Jun 2019 05:43:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 31DD56B0010; Mon, 24 Jun 2019 01:43:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2CE2F8E0002; Mon, 24 Jun 2019 01:43:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 149438E0001; Mon, 24 Jun 2019 01:43:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id D349E6B0010 for ; Mon, 24 Jun 2019 01:43:45 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id o6so6694613plk.23 for ; Sun, 23 Jun 2019 22:43:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5S44G7hi9/oDzUjI/c4UDpw03IJ9UksvFQEQlTe28Is=; b=Xk+rgskVt1ulw03KNrr3LKMfDtl7xmESC2MA0+aluDJlJ3x/1Fb70IfU+1f/hSIanI 7JToVRf73GqxjT2l9qPRkKc9b28HaM064ujqSG9GNPPWLacsA65WfIhM2gkuuNFZSW3i hSfhHdpuq4U6RaqHY6sqDmFDPOwF47rKAEcadEcI38nt66QCHHvQWvWUULsiL0atiJeq h688T1EAFRGBYtA+ulorzA+dWuLPEav+Vj33DWWyWp9dqg9f47ykdfILbuT8hy791EwH T1JCAAaoKqwAvDruji5gNSTkRFf8ucgCRVrrsP8RV9zlHOZFEFtEtR+O5Fnaw6CGTLlh CMIQ== X-Gm-Message-State: APjAAAUroAA5+6tnkaJnIvU5S3wmEJmrgpnfYjtGG9AnXBDBPSBajRrL MrcNTLjVfaKrtUiASzfs3aqAuZzgDe0jxAKgWXupv2h6bh2pwaX69bdnlu5ewBZOUbMbmjnKL6Y 1ocfkFOr8nL1Zd2v0zW5xX538K6wnuvAWdcJ3sLfhD5CC3Hkfdmb9i+CI9UlPXvM= X-Received: by 2002:a17:902:2983:: with SMTP id h3mr102611899plb.45.1561355025553; Sun, 23 Jun 2019 22:43:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMujMgF7ixBBjEDnveoRey6DVPpX7Vb9L0sTtvwQHWruZp8u1G0ecL5zXVcPHpOx/vy/ot X-Received: by 2002:a17:902:2983:: with SMTP id h3mr102611856plb.45.1561355024896; Sun, 23 Jun 2019 22:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355024; cv=none; d=google.com; s=arc-20160816; b=pRRTe8h+FHPBrozCx3LcqSH7Gd6PVaAW0EyfFSqi3/4DZaClvW6j+5tVPLGVNxTj9X xcWgDGqf/kiUD3hLH6htUO1NY9FeDs94H5hbwNtlZXUGysM2zCeEBtL3aKZykgElnsTe 0MgUPJBvS346d6MpGJathA+TWjRmpvlSC8CtbgyR+UXa85OwR+jHrvMMbYccClr20dwV O0e+LX2sj+nTcu7YS1HteMi9QUtfrTdDt2PtZovxwCMtUK9zt83V2GaIixfmRC9adkEq o77BBwqaym+Awvix+gDk16RHHusYQUngzSfAKnUsE40gn099HvU5VYxAuiWuGyQdZ3It oE9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=5S44G7hi9/oDzUjI/c4UDpw03IJ9UksvFQEQlTe28Is=; b=nZacdINX93Jq6ZoWwSeinidyAOaBriiRh2nR6kH3HjbXcxTf8TjXm4j90iAq3wqgEz rfFVorLZWk80uPPIS4jICHomJuLn5SUXYI8wYjzySvO0rUUwsSg3AyIt87uWKR4P3MUs S5cSQboqzBdzXvkQNCHpb0xJt6AeHtd89BtY0hQFDx5DiFOnjg3qwE+aqkZOuV7C6xLx JVNBld2GLZbJSCjnONhoV3ZxZMbr07h5LFigDh7v5Jf1gcj57V7Swt2R6LT256TT42OC GOFicmRpnje9X9jLhl8pUerc5C91McMwHGVPigiQioUaUOmEFma2fOL09m1Edm86uP0G Z9iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=bOJanL5M; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id x8si9238760pln.298.2019.06.23.22.43.44 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=bOJanL5M; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5S44G7hi9/oDzUjI/c4UDpw03IJ9UksvFQEQlTe28Is=; b=bOJanL5MMnc/t7xSRwNl23fs0K aeNomPXq+bdVmfGjm7QRaFm9ieHxtd8szKCB8LzF3VBt+56T9bWIcSx3l2sZ3yrFCt8hsBXSUggZ+ +1vAATxtqrhDYJxKiEsAQfkE+e61DJiYbUXXQTpvfNkDBQWEsG+N6s77wOacZ+peImRSnwjUjAtDn OCXkGgA4IVqSHPmT7He01n2msBaxwwg7D79sLkzAgVdMIqYmqCXIl9UKMggE7wL7HO5tpiBlBM7hq Ogdeuv7YAqIa7B4iM21XQMBymT3miTYC6nVRevqkNpks/Yd7ZnY34qKnata1FuJIiiypv/Q4OyDxk pfsmhyLg==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlW-0006Ra-NN; Mon, 24 Jun 2019 05:43:43 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/17] riscv: improve the default power off implementation Date: Mon, 24 Jun 2019 07:43:02 +0200 Message-Id: <20190624054311.30256-9-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Only call the SBI code if we are not running in M mode, and if we didn't do the SBI call, or it didn't succeed call wfi in a loop to at least save some power. Signed-off-by: Christoph Hellwig Reviewed-by: Atish Patra --- arch/riscv/kernel/reset.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c index d0fe623bfb8f..2f5ca379747e 100644 --- a/arch/riscv/kernel/reset.c +++ b/arch/riscv/kernel/reset.c @@ -8,8 +8,11 @@ static void default_power_off(void) { +#ifndef CONFIG_M_MODE sbi_shutdown(); - while (1); +#endif + while (1) + wait_for_interrupt(); } void (*pm_power_off)(void) = default_power_off; From patchwork Mon Jun 24 05:43:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A37F1805 for ; Mon, 24 Jun 2019 05:43:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AE4B28B01 for ; Mon, 24 Jun 2019 05:43:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F79728B1E; Mon, 24 Jun 2019 05:43:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9326928B01 for ; Mon, 24 Jun 2019 05:43:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73E896B0266; Mon, 24 Jun 2019 01:43:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A0658E0002; Mon, 24 Jun 2019 01:43:49 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53F9C8E0001; Mon, 24 Jun 2019 01:43:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 1D92C6B0266 for ; Mon, 24 Jun 2019 01:43:49 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id q14so7186477pff.8 for ; Sun, 23 Jun 2019 22:43:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=skB+ZnavO/i7RNPtU2wJ23sFxTsqRf+NEErVUiBdRM8=; b=c6ZyxVjlTQkweNZ1Q2CPU6ibLt/yBq0MtrBby2eJPHC63SxkaJ9vU9S6xdcFpjnVud xWNj/PssM6b2C07Oc7tG3V2HGlaPBdqzCDCn3agqfiJzo/jhngX+A1m1w88vnCrloRAM UHLtNXL+GPVCrDOzQqgUno0XD/m2xW+0RrnsQlUz2DIvl2nplY8kgy3IbOmBkLIjjoXn xICOZKJCZIWYGG8JjGFPhsY/67dL8QpXoYwqjhfQGp7Mex/7qnsaRYWudr4KxZZjZbzz VuAQmlKVMoVksL+8GzOTdvAewLOD6/TJ1O6G+1nkj6pYwnNS2NRYqXsUZdS62ygLRipi iDxg== X-Gm-Message-State: APjAAAWHDlh1ewE7ljyGfQM412HKLVRWlP4X6PFw6Q3pm/kxrK5QLtr4 Pr0jaSTxRYfJE5IplcN4qFzvVD9LMF0xAE66O8Ctedbh4mYVNCbopLTaQouGTDHVIyuywBkf9bF clcjZ5z6+i6209VhC5t4odijGzq/iyDkw0oZHOVjSBMbZOOK8PI4zpfKbqOznoaA= X-Received: by 2002:a63:9d82:: with SMTP id i124mr4220910pgd.155.1561355028728; Sun, 23 Jun 2019 22:43:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0n+nCoQdVtfyv30K/oUurfX3T2KNjS5MTekTy1tp+wsm5LJHud2U0f1clULsrWXbC6o/K X-Received: by 2002:a63:9d82:: with SMTP id i124mr4220865pgd.155.1561355027862; Sun, 23 Jun 2019 22:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355027; cv=none; d=google.com; s=arc-20160816; b=E4yW1b+uWaNUJn0+1RAiZOYGck3XfQdGI9TEtCuax0BUlA1r6jw1KlYjcBPHxh4vo3 Mr009jEl4S027WNC61tAn4sERezc4Xy8OU+xOqzvwq+0Z7DibruDH4/SGFRRhBGZxauV k/L3ftZZg2nzx8qdCxQ+dJDRs/1Id8LfTn91h7TsWtyUEkSt8gXpKfbtMk3Ir3H7vjTB 7sSjEIurau3qbwJvHWtw9YwGWg3Es9FJGI7ucY5BPBPgccN50/U6FdPAJE28tPcGzbBM rmZVL+BMTbkyM5bc8B6/ORf/BP6zaGollFgG+1AxOAw4Azhd6N8g3PJi32m/cYrAA0Ge GWmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=skB+ZnavO/i7RNPtU2wJ23sFxTsqRf+NEErVUiBdRM8=; b=tDKykeFtSHj9BS4In/oaCr82c/lQMKG0iVQYiijZoRQXISyLM7LM4erW+GZ+tUh5B/ QqeliVqbGIY2BstAOoIUgMw9Nz/TIKDnQHQTKgyXAGd78tzdh4XSbkk+eJ1DXxEO9eNi bg2TFdeO6oE7jtFbA///n+1rZqIaPy5SgL8gKSTA8E5fogkWmGxV/NowDtqpUDPbVv07 vL5nkY17lrimLp2Hvp1LYwcz+RdHgidoY+H1fNzF43KcB0Z2GZDOAQVoyQaTRIbUWtRv Db+GQyoIdLfCsCbY74G58sXOrk13tS1rHl9dT6lE3iU91KMBJRtvj3CUoyZ/HYeFiWId 3Z/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=t+2vO2nF; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id l6si10225035pgl.444.2019.06.23.22.43.47 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=t+2vO2nF; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=skB+ZnavO/i7RNPtU2wJ23sFxTsqRf+NEErVUiBdRM8=; b=t+2vO2nFTl72dJHuKdBfsPVdXB PpN4mUwQTM7uVVMBYemMWRy7TO6gT0foijMGEEFeKV4uMpaJeS7qSaL5ucgqPVCxwZrtbPlPp19Da aqyr1nEhcizmT1bqw0YevN+FGcf0/OYne3Oepy6C+pN0QROZYbNapyQkwh5WhJpTkQZiTywAon4cA r85QDsSSL1jXX30Ue8PHJp9qgNOGx/Zwc7vrTgAy5NwVztpDW8OlKMsoqOwaUNpk5k8xj3sWraNC4 RTk3jha4jQXHwplpwmyxVqldpftE7xCFg0DjpblKhPjvOPMSDLEZR4e+gDg/zk4OBHuakmfmsrQmz 3x0/tFLw==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlZ-0006UH-Uw; Mon, 24 Jun 2019 05:43:46 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/17] riscv: provide a flat entry loader Date: Mon, 24 Jun 2019 07:43:03 +0200 Message-Id: <20190624054311.30256-10-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This allows just loading the kernel at a pre-set address without qemu going bonkers trying to map the ELF file. Signed-off-by: Christoph Hellwig --- arch/riscv/Makefile | 13 +++++++++---- arch/riscv/boot/Makefile | 7 ++++++- arch/riscv/boot/loader.S | 8 ++++++++ arch/riscv/boot/loader.lds | 14 ++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 arch/riscv/boot/loader.S create mode 100644 arch/riscv/boot/loader.lds diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 6b0741c9f348..69dbb6cb72f3 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -84,13 +84,18 @@ PHONY += vdso_install vdso_install: $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@ -all: Image.gz +ifeq ($(CONFIG_M_MODE),y) +KBUILD_IMAGE := $(boot)/loader +else +KBUILD_IMAGE := $(boot)/Image.gz +endif +BOOT_TARGETS := Image Image.gz loader -Image: vmlinux - $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ +all: $(notdir $(KBUILD_IMAGE)) -Image.%: Image +$(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ + @$(kecho) ' Kernel: $(boot)/$@ is ready' zinstall install: $(Q)$(MAKE) $(build)=$(boot) $@ diff --git a/arch/riscv/boot/Makefile b/arch/riscv/boot/Makefile index 0990a9fdbe5d..32d2addeddba 100644 --- a/arch/riscv/boot/Makefile +++ b/arch/riscv/boot/Makefile @@ -16,7 +16,7 @@ OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S -targets := Image +targets := Image loader $(obj)/Image: vmlinux FORCE $(call if_changed,objcopy) @@ -24,6 +24,11 @@ $(obj)/Image: vmlinux FORCE $(obj)/Image.gz: $(obj)/Image FORCE $(call if_changed,gzip) +loader.o: $(src)/loader.S $(obj)/Image + +$(obj)/loader: $(obj)/loader.o $(obj)/Image FORCE + $(Q)$(LD) -T $(src)/loader.lds -o $@ $(obj)/loader.o + install: $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ $(obj)/Image System.map "$(INSTALL_PATH)" diff --git a/arch/riscv/boot/loader.S b/arch/riscv/boot/loader.S new file mode 100644 index 000000000000..5586e2610dbb --- /dev/null +++ b/arch/riscv/boot/loader.S @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 + + .align 4 + .section .payload, "ax", %progbits + .globl _start +_start: + .incbin "arch/riscv/boot/Image" + diff --git a/arch/riscv/boot/loader.lds b/arch/riscv/boot/loader.lds new file mode 100644 index 000000000000..da9efd57bf44 --- /dev/null +++ b/arch/riscv/boot/loader.lds @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +OUTPUT_ARCH(riscv) +ENTRY(_start) + +SECTIONS +{ + . = 0x80000000; + + .payload : { + *(.payload) + . = ALIGN(8); + } +} From patchwork Mon Jun 24 05:43:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012191 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E1A876 for ; Mon, 24 Jun 2019 05:43:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F70628B01 for ; Mon, 24 Jun 2019 05:43:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23A8428B1E; Mon, 24 Jun 2019 05:43:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC61928B01 for ; Mon, 24 Jun 2019 05:43:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14AD46B0269; Mon, 24 Jun 2019 01:43:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0D4258E0002; Mon, 24 Jun 2019 01:43:53 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDDBF8E0001; Mon, 24 Jun 2019 01:43:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id B63AF6B0269 for ; Mon, 24 Jun 2019 01:43:52 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id h15so8889471pfn.3 for ; Sun, 23 Jun 2019 22:43:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=43pRHKdJKqNssrr4/Vc0cDK/nlhOlcebDC3ttvLu+nk=; b=KCbBhmDH83M83DQEFHZPkQ7z6vKyOlnrbQp0sL/kUCZh2TZAQOo9DZUlTwl/oDhWiT Sh4U8ag2sVzlwIIhQ/Rf1jNCv6xHf6RFOedr93i+MstrE452dBdAUUUnR31FMcmEa5qH Up9qblPs+cGqwwUxxn//Pu8BNv23zL8mB7gWR9sjfU9wItIDFsjxAIiZyFveuAKXQZ2V XIsgNpMpSpxbHtM+d0P++h8OhalReg3ZTGTYAETWP9mOvHV+igWjcLEy2MUxZibA6DWY aBOYW3Duvt9RO9JdokE2Ali3V5jAMxuPkEVrAyENozxawD9HtxXqI/U3KCPwJGehYWyo gr/A== X-Gm-Message-State: APjAAAVHnX/jAMzeo/I7p44rhHq+e4Apyt8QsrkHLpWHdeuAF9qSwZAY H6qFdmHS1uuJLeVGy5KiJQJjTsOOY4JrzmpKsxMxLa/cewQU4WCHYBz0gr3yP2Du1M1FpPURD72 xzS6z65ZtSpOUzJjwry+X7DViyADy1Gg5r+1dckvFfKMcJlF9lGxYkQ69O5dQHGc= X-Received: by 2002:a65:524b:: with SMTP id q11mr30301876pgp.384.1561355032332; Sun, 23 Jun 2019 22:43:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5olcSIoAIqovBqj5sngIHCt9o6TL9a07GwkC2N5QP3+HfQfF7gEjS+DKS1cZau/vcTvn/ X-Received: by 2002:a65:524b:: with SMTP id q11mr30301850pgp.384.1561355031609; Sun, 23 Jun 2019 22:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355031; cv=none; d=google.com; s=arc-20160816; b=UqDVHz7DKs5UGeWeDcc6AT4qZegXM/31jr69r59a6PPLTPJL1BaVe04AQCUVs05Uyp JFH8fjRIWs2fjUqByy1nS+p7V7sAxuJ2aqONPX2TI47i8+x00Ok6eB5CEd1qxVzQDJck 9EIzMMV98XCx4KuBbTQR3/6zNaqQKf322fnp429g0bBVDwfXymDsiSd4H3bdqNFdEFDw Y0YfLzWoBzhg3GmslfA2f8bN3WHlzWcYx8uKZPZUoglW7nUKVyNaoVSVsVOOMsiByxNP xCTha8+JhN865hSbeDF8Eusw4zsqwgyiBNHjXwEK4j+mxzIUU9Vb+hhIpqCHhpb+iqWf lv3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=43pRHKdJKqNssrr4/Vc0cDK/nlhOlcebDC3ttvLu+nk=; b=TBfHnuB5chHYRGNVQJAfIh8iu3d64ha5JbnbGiAsTj6aN4HyeVFgTWet3CSMWwNYMd qJR1bB1wVvDq4EobMd0Rh7YeqFPtKWE8blFp8d+rLf867uwttma9+mvkIB0vszCvDWKn Cfwue5EJvOO39XwErJPv4BtRWsOmjyUQL3HgJQ060X3x4FvAyWbpUuWSDNsawdOJw9bh S3UhCGERXXa7RjVDaFFuD4AaduwoY9sM8kNGnwp4QSmdqmnqg4o4NYednr16YsSqC7Sx 6ltqEnwe68jcgRalQ3pwfxTV5im4zPuIWRQ/naiWVekedyMbx/+PoP/65We17xxhSUF/ 6s4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ox0Bj2s2; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 59si10154952plp.90.2019.06.23.22.43.51 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ox0Bj2s2; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=43pRHKdJKqNssrr4/Vc0cDK/nlhOlcebDC3ttvLu+nk=; b=Ox0Bj2s2AYtMiNqOyzVUJu1aca 4Zw5sJu947Gj5rs0jUIlbbOtlbwYiuHZ0nJ1wtQi79umOkWFdlOji03dK+QH22LmwJp2C8vJ56/Fw VBYObyjWlQcJ9h5SQj6t76j0JD5TudW+arpOJd2w7RxIDG8pwuO4dR1jb3JpSDfRzc7ZczKYWm7vh QI2c2xxg9ZuRIDvDgzexiDXDbZSYqdKgNNN3aPwHwGLG857aQEXAdzB2Nf4gvK+YbgR5Imuqbwebr zBivLC6z+ob0BD9JpbwnxUy0vPPLYKipdDiBzZ5jLr7Jy5pym/AnznE86d12FYY1jmZQrC/xeH+IC s5lNwFPQ==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHld-0006Xj-5S; Mon, 24 Jun 2019 05:43:49 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Damien Le Moal Subject: [PATCH 10/17] riscv: read the hart ID from mhartid on boot Date: Mon, 24 Jun 2019 07:43:04 +0200 Message-Id: <20190624054311.30256-11-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Damien Le Moal When in M-Mode, we can use the mhartid CSR to get the ID of the running HART. Doing so, direct M-Mode boot without firmware is possible. Signed-off-by: Damien Le Moal Signed-off-by: Christoph Hellwig Reviewed-by: Atish Patra --- arch/riscv/kernel/head.S | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index e5fa5481aa99..a4c170e41a34 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -18,6 +18,14 @@ ENTRY(_start) csrw CSR_XIE, zero csrw CSR_XIP, zero +#ifdef CONFIG_M_MODE + /* + * The hartid in a0 is expected later on, and we have no firmware + * to hand it to us. + */ + csrr a0, mhartid +#endif + /* Load the global pointer */ .option push .option norelax From patchwork Mon Jun 24 05:43:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF8061805 for ; Mon, 24 Jun 2019 05:43:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CED1428B01 for ; Mon, 24 Jun 2019 05:43:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C297028B0B; Mon, 24 Jun 2019 05:43:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0881928B2C for ; Mon, 24 Jun 2019 05:43:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6798C6B026A; Mon, 24 Jun 2019 01:43:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 62BDA8E0002; Mon, 24 Jun 2019 01:43:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42F2D8E0001; Mon, 24 Jun 2019 01:43:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 0A3206B026A for ; Mon, 24 Jun 2019 01:43:56 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id s195so8644991pgs.13 for ; Sun, 23 Jun 2019 22:43:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=f/LMSlxfhI7zBN2HPhyn2vXf7Q0YVjnn4dkhV1o/cCs=; b=Zofyg/8i2F+YS7MXXJS6oE9hFzABhkbj0gt+YvmlvBTUMf3qKrYm5HR8cBVylqda5C Zk1rEHhR3ucKmm+9LSt/TLjFfkkkDvjo1nNInEDAEfzU/Ba+CO5zD3pCpei8AeXq5Kl1 eT7i5ELB+/+NMqKN+7qGxFzMHIerJpXSiCLQz90akkXo329Z6wmWjHpPHFgklbz6rCn5 JFsQK3cqPJrStHJr5npmg+9eiqRNX5BwTeKdRngGtv3OTLFrlmJohtB44qbiErJnjZDf mBinrcvtZ/tfAF8YQLZGYGJMl6hBfVpF9wffJFE6Q7VTwu3fxle3dFCHNPFrCaVoQ5b8 h2Tw== X-Gm-Message-State: APjAAAVGN8rfUv8bgnYKnnCA0l7KuPLqWTGavj6NiwITZMBi19EBvuB+ PyLNReZBKI8UvLtFEhisKl5dQA4574V1F7m5k3yWo5oOOol44ExK2Y5z05umcez4OCODH4O29yA 5aVstoaCO0xePvc2OG7zvCOD+qV6EhH25emoQxDplTaD+ebWRvmEWxG3rD0Y882g= X-Received: by 2002:a17:90a:ba93:: with SMTP id t19mr22381012pjr.139.1561355035675; Sun, 23 Jun 2019 22:43:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcoZaM2ponF/yyjOpkkZx6gm/5qorYrIhZHuplJP9+DCuWBPsKaKeoO/yliR4FHLA/q/+6 X-Received: by 2002:a17:90a:ba93:: with SMTP id t19mr22380959pjr.139.1561355034695; Sun, 23 Jun 2019 22:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355034; cv=none; d=google.com; s=arc-20160816; b=INj3v7UtsR1APZCI5zPhaEKTyICYEDCCFLzjiKELSQmVcH2ItlAFuPZIeBzX1YOj5d Q5e05QMNfBfFGSruSFPMmjomvpzOIsXcR/kM6quHue6xcQ6/oO0bU7vy9L6e63YBf5A5 IYzK09U3rFB4AC2hbuIikqiSronzZ7MuYhokwnFf8+iNbTfICWe4IDmL18xcrSjtx330 sx/wkWu66eCod8GfBoHyHNVojnF+3B5pjYYiGdjsG440YEtPy+J1qC1q9D7WwI8/yGCK eN6Szl6lq3o8gPiVB0V8qYo8Y07VIW6v9xX4S5O54gL8I+gcsnkDuJlwNYNkV4sxC1co 0wOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=f/LMSlxfhI7zBN2HPhyn2vXf7Q0YVjnn4dkhV1o/cCs=; b=gN6nGoT1yaLlQJ5qLvrl5BNUGQkloHLKbuvDRSn0tZlWZU2uO+yjCYQyVOGTBoQBL9 MCXZwkSZ/SHgFI5IZwzCSJ3PntzVHgV93lLCxwLnAgAjTQRrZN/0dF4I4ciyFoNW9bAu Ev+Pbb05SzrtufAUEf7THjUYyh0vvh+MeqQjE4/XS2Ffs/dWCdPUsGjOCKZDDy/y86a/ BHscc7T74mmZZLFB7jSxrgRB+YXNAnsohe/eWXurrBHWTpz2U94UfGCgdOT0zqvqtX1B Kzn9EjLnMgQbDA/Y7ERLF05ZH5Otip9kkLJzB75YEJMS/AXjh4xHqCADL7jE2BcmYfwX Nggg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=pE4dI02l; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 33si9368165pli.144.2019.06.23.22.43.54 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=pE4dI02l; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=f/LMSlxfhI7zBN2HPhyn2vXf7Q0YVjnn4dkhV1o/cCs=; b=pE4dI02lDFfkAV82lMiqZforjy SG8akkDP/ZbgaSrs+ci1Ww+ClWN3TIs/e2BGmih9m1XnFy7suJnKZb7wRpi2ZLabuo7kIxpKfX173 TbXzu+w+qPkAIwKYjE6uwsy++/t3xcQbwOIWoVI9LMjU+hM3TIbsmlWMl2FIQInTv4tc3NxFPb2KG Z0/2oVjWC8zT/BhhTsD57BD0nMkDQKjDr6maNaiBp1ev3xHz2Y+/4nO8OL1XSf6G8mTiEm88Gjplr VfPkrdYotaO/y0aV4AjWWDBr65EuvWHwT+5P8pSs8zTVVQWUtrm7HCf9hutHyKpw/HLo63mGonrFG P5RplXeQ==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlg-0006c3-P1; Mon, 24 Jun 2019 05:43:53 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/17] riscv: provide native clint access for M-mode Date: Mon, 24 Jun 2019 07:43:05 +0200 Message-Id: <20190624054311.30256-12-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP RISC-V has the concept of a cpu level interrupt controller. Part of it is expose as bits in the status registers, and 2 new CSRs per privilege level in the instruction set, but the machanisms to trigger IPIs and timer events, as well as reading the actual timer value are not specified in the RISC-V spec but usually delegated to a block of MMIO registers. This patch adds support for those MMIO registers in the timer and IPI code. For now only the SiFive layout also supported by a few other implementations is supported, but the code should be easily extensible to others in the future. Signed-off-by: Christoph Hellwig --- arch/riscv/include/asm/clint.h | 40 +++++++++++++++++++++++++++ arch/riscv/include/asm/timex.h | 17 ++++++++++++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/clint.c | 45 +++++++++++++++++++++++++++++++ arch/riscv/kernel/setup.c | 2 ++ arch/riscv/kernel/smp.c | 24 +++++++++++++++++ arch/riscv/kernel/smpboot.c | 3 +++ drivers/clocksource/timer-riscv.c | 16 ++++++++--- 8 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 arch/riscv/include/asm/clint.h create mode 100644 arch/riscv/kernel/clint.c diff --git a/arch/riscv/include/asm/clint.h b/arch/riscv/include/asm/clint.h new file mode 100644 index 000000000000..46d182d9a4db --- /dev/null +++ b/arch/riscv/include/asm/clint.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef _ASM_CLINT_H +#define _ASM_CLINT_H 1 + +#include + +#ifdef CONFIG_M_MODE +extern u32 __iomem *clint_ipi_base; +extern u64 __iomem *clint_time_val; +extern u64 __iomem *clint_time_cmp; + +void clint_init_boot_cpu(void); + +static inline void clint_send_ipi(unsigned long hartid) +{ + writel(1, clint_ipi_base + hartid); +} + +static inline void clint_clear_ipi(unsigned long hartid) +{ + writel(0, clint_ipi_base + hartid); +} + +static inline u64 clint_read_timer(void) +{ + return readq_relaxed(clint_time_val); +} + +static inline void clint_set_timer(unsigned long delta) +{ + writeq_relaxed(clint_read_timer() + delta, + clint_time_cmp + cpuid_to_hartid_map(smp_processor_id())); +} + +#else +#define clint_init_boot_cpu() do { } while (0) +#define clint_clear_ipi(hartid) do { } while (0) +#endif /* CONFIG_M_MODE */ + +#endif /* _ASM_CLINT_H */ diff --git a/arch/riscv/include/asm/timex.h b/arch/riscv/include/asm/timex.h index 6a703ec9d796..bf907997f107 100644 --- a/arch/riscv/include/asm/timex.h +++ b/arch/riscv/include/asm/timex.h @@ -10,6 +10,22 @@ typedef unsigned long cycles_t; +#ifdef CONFIG_M_MODE + +#include +#include + +static inline cycles_t get_cycles(void) +{ +#ifdef CONFIG_64BIT + return readq_relaxed(clint_time_val); +#else + return readl_relaxed(clint_time_val); +#endif +} +#define get_cycles get_cycles + +#else /* CONFIG_M_MODE */ static inline cycles_t get_cycles_inline(void) { cycles_t n; @@ -40,6 +56,7 @@ static inline uint64_t get_cycles64(void) return ((u64)hi << 32) | lo; } #endif +#endif /* CONFIG_M_MODE */ #define ARCH_HAS_READ_CURRENT_TIMER diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 2420d37d96de..f933c04f89db 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -29,6 +29,7 @@ obj-y += vdso.o obj-y += cacheinfo.o obj-y += vdso/ +obj-$(CONFIG_M_MODE) += clint.o obj-$(CONFIG_FPU) += fpu.o obj-$(CONFIG_SMP) += smpboot.o obj-$(CONFIG_SMP) += smp.o diff --git a/arch/riscv/kernel/clint.c b/arch/riscv/kernel/clint.c new file mode 100644 index 000000000000..15b9e7fa5416 --- /dev/null +++ b/arch/riscv/kernel/clint.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 Christoph Hellwig. + */ + +#include +#include +#include +#include +#include +#include + +/* + * This is the layout used by the SiFive clint, which is also shared by the qemu + * virt platform, and the Kendryte KD210 at least. + */ +#define CLINT_IPI_OFF 0 +#define CLINT_TIME_VAL_OFF 0xbff8 +#define CLINT_TIME_CMP_OFF 0x4000; + +u32 __iomem *clint_ipi_base; +u64 __iomem *clint_time_val; +u64 __iomem *clint_time_cmp; + +void clint_init_boot_cpu(void) +{ + struct device_node *np; + void __iomem *base; + + np = of_find_compatible_node(NULL, NULL, "riscv,clint0"); + if (!np) { + panic("clint not found"); + return; + } + + base = of_iomap(np, 0); + if (!base) + panic("could not map CLINT"); + + clint_ipi_base = base + CLINT_IPI_OFF; + clint_time_val = base + CLINT_TIME_VAL_OFF; + clint_time_cmp = base + CLINT_TIME_CMP_OFF; + + clint_clear_ipi(boot_cpu_hartid); +} diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index b92e6831d1ec..2892d82f474c 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -67,6 +68,7 @@ void __init setup_arch(char **cmdline_p) setup_bootmem(); paging_init(); unflatten_device_tree(); + clint_init_boot_cpu(); #ifdef CONFIG_SWIOTLB swiotlb_init(1); diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 8cd730239613..ee8599a7ca48 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -13,7 +13,9 @@ #include #include #include +#include +#include #include #include #include @@ -78,6 +80,27 @@ static void ipi_stop(void) wait_for_interrupt(); } +#ifdef CONFIG_M_MODE +static inline void send_ipi_single(int cpu, enum ipi_message_type op) +{ + set_bit(op, &ipi_data[cpu].bits); + clint_send_ipi(cpuid_to_hartid_map(cpu)); +} + +static inline void send_ipi_mask(const struct cpumask *mask, + enum ipi_message_type op) +{ + int cpu; + + for_each_cpu(cpu, mask) + send_ipi_single(cpu, op); +} + +static inline void clear_ipi(void) +{ + clint_clear_ipi(cpuid_to_hartid_map(smp_processor_id())); +} +#else /* CONFIG_M_MODE */ static void send_ipi_mask(const struct cpumask *mask, enum ipi_message_type op) { int cpuid, hartid; @@ -103,6 +126,7 @@ static inline void clear_ipi(void) { csr_clear(CSR_SIP, SIE_SSIE); } +#endif /* CONFIG_M_MODE */ void riscv_software_interrupt(void) { diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 7462a44304fe..1b7678d86ec8 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -132,6 +133,8 @@ asmlinkage void __init smp_callin(void) { struct mm_struct *mm = &init_mm; + clint_clear_ipi(cpuid_to_hartid_map(smp_processor_id())); + /* All kernel threads share the same mm context. */ mmgrab(mm); current->active_mm = mm; diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c index 2e2d363faabf..008af21611d9 100644 --- a/drivers/clocksource/timer-riscv.c +++ b/drivers/clocksource/timer-riscv.c @@ -24,12 +24,16 @@ * operations on the current hart. There is guaranteed to be exactly one timer * per hart on all RISC-V systems. */ - static int riscv_clock_next_event(unsigned long delta, struct clock_event_device *ce) { csr_set(CSR_XIE, XIE_XTIE); + +#ifdef CONFIG_M_MODE + clint_set_timer(delta); +#else sbi_set_timer(get_cycles64() + delta); +#endif return 0; } @@ -45,14 +49,18 @@ static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { * within one tick of each other, so while this could technically go * backwards when hopping between CPUs, practically it won't happen. */ -static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs) +static u64 riscv_sched_clock(void) { +#ifdef CONFIG_M_MODE + return clint_read_timer(); +#else return get_cycles64(); +#endif } -static u64 riscv_sched_clock(void) +static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs) { - return get_cycles64(); + return riscv_sched_clock(); } static DEFINE_PER_CPU(struct clocksource, riscv_clocksource) = { From patchwork Mon Jun 24 05:43:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DCB276 for ; Mon, 24 Jun 2019 05:44:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F368B28B01 for ; Mon, 24 Jun 2019 05:44:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E787628B1E; Mon, 24 Jun 2019 05:44:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 802D428B01 for ; Mon, 24 Jun 2019 05:44:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20D336B026B; Mon, 24 Jun 2019 01:43:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 196868E0002; Mon, 24 Jun 2019 01:43:59 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00FC78E0001; Mon, 24 Jun 2019 01:43:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id BC5C26B026B for ; Mon, 24 Jun 2019 01:43:58 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id b10so8618303pgb.22 for ; Sun, 23 Jun 2019 22:43:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QKrZKqm9xX7/gKntli3kjDV0bZW8VwVWFoBUswi6ZbI=; b=ZsHTxkSMKSS0UF6qALUW8Dx9obhaqtujRawY1rE4bGrlkJbc57sttXTckXbxNsZqyd e5fvC8vcYkYSEVON2nDC48XipLpPC+QrhQbBlMiN/IiPB+XEeNRvl6dJYlSAQRhVYjOB K2IJLnDMR1+uDGJVHd6SVgjLf0Nuv4NnnZ7VhitB6PsYKHnbm3ncgNjBT/d7/PK6RE3s DfqKezFTW6ohTI/LTwkq3HLB5OyaVedrkZeVWGwQOAdBYBoc7I73GwgrwGGmAcg1McTi cQsrrVLBOU1UopSSjTVfyfqTn+eCGFe2xPkNICUjwT98eCGUG71ybVuLiFA3C51i+MWz +mtQ== X-Gm-Message-State: APjAAAVhNmlTpIesB9fKUceHTDofASKp+p2QLKE/tT+TXBhgZV5153EK QkJYFc/LU0BTQ+mT2sa5FfyTO+AjQ85JSNlty5xjbVnvhT/HxOO/IEZIFvsjhmOeucdNPtGvdPY pbIhVDGBQYXtiv40Ce9JUR+FxAsHD3M0tFHW0bsuW9PdUxZxlZFqdb65IxWkjsjE= X-Received: by 2002:a17:90a:af8b:: with SMTP id w11mr22695336pjq.135.1561355038465; Sun, 23 Jun 2019 22:43:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLDD6S0gkc+LfrDuhRbsjGEYt4acfTkgeYfhcu+aaxIjwTVpeH2z5CgxegsedjAKFMYtB/ X-Received: by 2002:a17:90a:af8b:: with SMTP id w11mr22695289pjq.135.1561355037740; Sun, 23 Jun 2019 22:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355037; cv=none; d=google.com; s=arc-20160816; b=Ys2D/M8w2OLQC0uwXaNQqKnyHsRMsi5LoXYvwwbAN2yErY3aPNMPALLy04sKkxFwlt naBP+BvVODlrE4Oih/Ll54uoeQzTo/sakDJlRXMygEKCFF8HEeHzjgPPqiNZrbJFcheB bwI/p40PCfETJly7V886e/x41/NjsaBivKg4dQwlwwvJ7kYk9EEAPj3OmJIwgMuXTvFK x9AIVrWhK6/cu52B57OAphI46bFJ8tUzKpVa1RfZywml83lHcbf2v1RKnD1KHtzeAmCR nuH7eNp0BkEf8wQqcPn2zzWSp8TwVeyIPxhd333XML0ydhFLI+keiPj/tkgFmlpnNCe+ BK3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=QKrZKqm9xX7/gKntli3kjDV0bZW8VwVWFoBUswi6ZbI=; b=bG1BOzRU1Qp6id1gmuDNiZb2qJix1oczy/zafEKob/jJSBGP1TLQeGeQfCheFL6UCV bJgZH+ZnjamOGsYKttZUMJHqI8qI6V/46HdSXReZVK8959870FdeeXICEpu1bdQWJ9D9 P7WBCIomVwETSdKMgIrF/gUNT1gOeqD3ppVpPz31E6kr3JQNiRb0w19GeJhsDv7X/usk p3w9IICyBSmv1XhIsoNb0j0/E3cxfWZIQHAXKrAIYneJUANt5MtylsBAWQAUlXpMAxd4 x+EoRJm+zRhLSXAPUCaFUQBOgXW0Mwnip9b31UvjJqr+KQhDlWMbB0aGzQDWNeQtJqO5 QZSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=DsBS4El+; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id z22si9120394pgh.458.2019.06.23.22.43.57 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:43:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=DsBS4El+; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QKrZKqm9xX7/gKntli3kjDV0bZW8VwVWFoBUswi6ZbI=; b=DsBS4El+mIDdDpYL3biKUdVRJ/ gRsHj2wUwnw4hOCIz4900CEw/5hNBn83QXaN/N05RmdL9tzK/1lSSI2iqYVahKMo0XaXpwbjdtPKY 6fusC2JxKNUi6Wcy0DXpKqNMuKP3VS4bgMDOkykPUY3EwbA92QOKfS/y0+A1ROpcg74mXxa1pHNsX 9CDeIJ4QBgCUmvopkpBdjN2FiVF9Xk0wvrMzGPRniCqFcnTi6ht8NvrkQmjx+LMwEtdRQIot497Y4 RLH6FazV3C/man5B6AAVTMf3gveCXvtw/C+Z1o9GZMvhIJFNTotzhkFBiUgBSrkjzl4YyRHeCmXX9 6f7Z39Vg==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlj-0006gQ-Me; Mon, 24 Jun 2019 05:43:56 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/17] riscv: implement remote sfence.i natively for M-mode Date: Mon, 24 Jun 2019 07:43:06 +0200 Message-Id: <20190624054311.30256-13-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The RISC-V ISA only supports flushing the instruction cache for the local CPU core. For normal S-mode Linux remote flushing is offloaded to machine mode using ecalls, but for M-mode Linux we'll have to do it ourselves. Use the same implementation as all the existing open source SBI implementations by just doing an IPI to all remote cores to execute th sfence.i instruction on every live core. Signed-off-by: Christoph Hellwig --- arch/riscv/mm/cacheflush.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c index 9ebcff8ba263..10875ea1065e 100644 --- a/arch/riscv/mm/cacheflush.c +++ b/arch/riscv/mm/cacheflush.c @@ -10,10 +10,35 @@ #include +#ifdef CONFIG_M_MODE +static void ipi_remote_fence_i(void *info) +{ + return local_flush_icache_all(); +} + +void flush_icache_all(void) +{ + on_each_cpu(ipi_remote_fence_i, NULL, 1); +} + +static void flush_icache_cpumask(const cpumask_t *mask) +{ + on_each_cpu_mask(mask, ipi_remote_fence_i, NULL, 1); +} +#else /* CONFIG_M_MODE */ void flush_icache_all(void) { sbi_remote_fence_i(NULL); } +static void flush_icache_cpumask(const cpumask_t *mask) +{ + cpumask_t hmask; + + cpumask_clear(&hmask); + riscv_cpuid_to_hartid_mask(mask, &hmask); + sbi_remote_fence_i(hmask.bits); +} +#endif /* CONFIG_M_MODE */ /* * Performs an icache flush for the given MM context. RISC-V has no direct @@ -28,7 +53,7 @@ void flush_icache_all(void) void flush_icache_mm(struct mm_struct *mm, bool local) { unsigned int cpu; - cpumask_t others, hmask, *mask; + cpumask_t others, *mask; preempt_disable(); @@ -47,9 +72,7 @@ void flush_icache_mm(struct mm_struct *mm, bool local) cpumask_andnot(&others, mm_cpumask(mm), cpumask_of(cpu)); local |= cpumask_empty(&others); if (mm != current->active_mm || !local) { - cpumask_clear(&hmask); - riscv_cpuid_to_hartid_mask(&others, &hmask); - sbi_remote_fence_i(hmask.bits); + flush_icache_cpumask(&others); } else { /* * It's assumed that at least one strongly ordered operation is From patchwork Mon Jun 24 05:43:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E94381805 for ; Mon, 24 Jun 2019 05:44:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA88528B01 for ; Mon, 24 Jun 2019 05:44:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE9E328B1E; Mon, 24 Jun 2019 05:44:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B71528B01 for ; Mon, 24 Jun 2019 05:44:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 288F96B026C; Mon, 24 Jun 2019 01:44:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0D5158E0002; Mon, 24 Jun 2019 01:44:02 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F03AD8E0001; Mon, 24 Jun 2019 01:44:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id C11376B026C for ; Mon, 24 Jun 2019 01:44:01 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id i35so7471768pgi.18 for ; Sun, 23 Jun 2019 22:44:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4ocWky3c08iK0yepv2gQs0SBg5KjT+xunPaTv4oC5uw=; b=n7P3NfhtRJNWH8BwopS9QABrtImuImM+50L9aptjPu2VuA7UanscUPFTUGZ8H32VRJ 4vhB3irjrv6n3jDpiEkLgVCRYZL//iQ5Qg1ROjBMdXdvGqh3G1qKu3eW3o+KpFKMhi9c cKJTE0xT0f7KJPdxIXFsUzOKtZe4sQ34oHjtbnE0WjUwCn8QP3ItEJQmySVXpIoBkEAB kQZJSM4NDbOivBYmT5mwbkhumwUfehp4dOGMnDZ7xxd8pWXapWk4l6LOS1tGIkZ66LqE ieM93FzW8fv3A1lRtJiO41Gno4iHnaumbJ6+oC0CaCM8MiXT+B9Yw5RYhxD65fiUXxeI Xgyg== X-Gm-Message-State: APjAAAV+QLmXo1NDZ4Kx0Krpr475Sm86Ujhu9nM+8i5SbllE9avMiiC3 6mkQ1Kt406rdPiovZ3U9yPPD10YBwvaeay5SjvK5yQXjUNPh7vUksHcSygfYiEdv0CtKvwcoPrz hMlFp1lds2hx/hGQH5nz9zT5SAy8blTjd7OT4hyz1lqPLzOmAqR9jwbtvTLl/ido= X-Received: by 2002:a63:6c4a:: with SMTP id h71mr30711570pgc.331.1561355041369; Sun, 23 Jun 2019 22:44:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHiYDk8fiYfV2nWyKAFJH04lHSl7lLxD5VylnwhuZC5IoKeP/cF9ceO1WchHR54cXgUedT X-Received: by 2002:a63:6c4a:: with SMTP id h71mr30711535pgc.331.1561355040692; Sun, 23 Jun 2019 22:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355040; cv=none; d=google.com; s=arc-20160816; b=jeIAz2iNyeXBpW+bCUsQ+pJKLvcD/+/V0lf9cOTUG8oWCynrKqRG6Y769IfOe4Ze27 rV9z/lipliOQehJlwjJATKoxC1KVAJNwHyx463kK7Ln9AehcbmT+0mkXtha3KJQ7YqaO ARPwqzQ3Cw5HdLA6ZjlFNQUQTYNY5XVWPVSmYrf54+sUz4FdajGxLIJqwlgXzbsJKB8/ tCgQ9w5y4lWD88kJoWFyY307ScIQIDnmrx8ZVYymvUZkaLcuAWcun2vJ40FzoQOeD/Oq Uu69IaT7tVu5GwRYKRMzLppXqK4hzjgMGl/Vo2dGBHHAVM1VIo3MQsM1s6argJ1xUwMh Jpxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=4ocWky3c08iK0yepv2gQs0SBg5KjT+xunPaTv4oC5uw=; b=A1KesBzb3QgO6vr8mtbtO16yDiPDcCIrq4iSObIoqFHuLYzy1bqPZZCTVv7pFw8su0 RU/4+J1q9Vetap5pzAkEVfQS0WXuHZe2LD9tRziuilCa4oKuWMkSw7Njy3igwafIlPpt EGXWfoIuXkj7rD4kk1lvIn5Nhf7r8ydNZVZ0+ASTlDhgUTvV+5pjlXbKxFIDNmUmebHE ljMVqIqZKnoibUtsktZX7Jp8BDGxU82UCqTMqfspriJn1LWcYWYwBjIzWYY2PGLaLYN/ /ou9JQNz5HWAAQbJUVBbaaJLJ9SfOt34vSYQCL4ynLiC/4PQGW/zvcWKUt6d2RJFpBsZ 6/2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=r5n6pCeH; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id a5si8870615pgt.281.2019.06.23.22.44.00 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:44:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=r5n6pCeH; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4ocWky3c08iK0yepv2gQs0SBg5KjT+xunPaTv4oC5uw=; b=r5n6pCeH/gadzSXK5KdI2Tqxv8 YODK6eN48ucCegAYBApmU91XF9qDbVsH6tKFA77OewDRe6wqTI7SOkxxGuNy9Sqic+I0WUPShkgI5 Q1lzoYmneNbpVbOUPj+V3mJQXEi+aDzQsaS8iujdNcz5g+2YOFVvO09khJr31WiotohZZLvZ1sZxX Au7/D6AWMmPm2BTMHXivfuRi7XYiZI3SmPmvmgQznl97DnHs/ShMX+Jt4xrDoWzclv6O8NDl/VF15 MEZtZEouwgD3Ybb8UXfWgU8hWoGgN6ZUV08QMBzBJNpFVg/90QTwtKFUM9bKrgLFEMLNGW7/C5meg uw+VkyYQ==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHln-0006kL-1n; Mon, 24 Jun 2019 05:43:59 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/17] riscv: poison SBI calls for M-mode Date: Mon, 24 Jun 2019 07:43:07 +0200 Message-Id: <20190624054311.30256-14-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP There is no SBI when we run in M-mode, so fail the compile for any code trying to use SBI calls. Signed-off-by: Christoph Hellwig --- arch/riscv/include/asm/sbi.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 21134b3ef404..1e17f07eadaf 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -8,6 +8,7 @@ #include +#ifndef CONFIG_M_MODE #define SBI_SET_TIMER 0 #define SBI_CONSOLE_PUTCHAR 1 #define SBI_CONSOLE_GETCHAR 2 @@ -94,4 +95,5 @@ static inline void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask, SBI_CALL_4(SBI_REMOTE_SFENCE_VMA_ASID, hart_mask, start, size, asid); } -#endif +#endif /* CONFIG_M_MODE */ +#endif /* _ASM_RISCV_SBI_H */ From patchwork Mon Jun 24 05:43:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AFFC186E for ; Mon, 24 Jun 2019 05:44:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C5BF28B01 for ; Mon, 24 Jun 2019 05:44:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1106528B1E; Mon, 24 Jun 2019 05:44:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D35E28B0B for ; Mon, 24 Jun 2019 05:44:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0CC86B026D; Mon, 24 Jun 2019 01:44:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ABD848E0002; Mon, 24 Jun 2019 01:44:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 985B48E0001; Mon, 24 Jun 2019 01:44:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 624CD6B026D for ; Mon, 24 Jun 2019 01:44:05 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id d190so8880877pfa.0 for ; Sun, 23 Jun 2019 22:44:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UZgDc4NqB64labXbUkmbFOqDnFwUTKKO+bOXvo7uUrA=; b=RbKoRkqrgPO2AmpWP+9UYOSS4nICfGN4/0HMQziAF2fX9k/QcMJ68EdhzHSbOES/64 tnrEuT8VHeacQVIhob9ujNz9vAOwZDvLW96DFs1MgcQ3tyk6gmue5YLCQhON6PBNIjrU YeVAqEvHQvwxUom4rMIKrlnatTTzwRkXt5NV2TqNYIkhCm+742Nae7ZS5Tn26dtwmKVO LiTC0JflR6W5XDg7K/QGbEfHay8KA16QidIZyTE/xVkMDtffVq3CqOEhq0p6QZTDyYta KbNV1d7/JEZqkygYAvHYjRoy8d19iTdMm1/go5chQiJAhoVfTrGmvEb2D4h7pQbjOqod Z2Tg== X-Gm-Message-State: APjAAAXNTiXWO6LnG8eCBY1SZQua0362LxIlFZMB45v6JzqLWH5Cic0K IWYLK8YprAZC0MXt2Z7tR/I2mIIn2ErpVVIL++iKHDi/7zjJ8/lCq6U56HjqglHJEJP/BHhTWVr d1hUZBAEK5BvNjptGYmN/UhzsgWkqeuGRhgAHBiXg1u5XSewEH8Ywmg3kqDWBD6Y= X-Received: by 2002:a65:5a0a:: with SMTP id y10mr3624171pgs.369.1561355044967; Sun, 23 Jun 2019 22:44:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqygq9Da9KnxTAPwiYHNgmUkAnyPHkmX+t/ECFR18UcwPgmiW9qLHysW/lbrmKsnVBGDcJyY X-Received: by 2002:a65:5a0a:: with SMTP id y10mr3624144pgs.369.1561355044289; Sun, 23 Jun 2019 22:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355044; cv=none; d=google.com; s=arc-20160816; b=jTHoIFbFI9pa7LUZIrvtZ62L4MViymsTvBx2iOTrlvmgTlEaBgcjY7gYec1tyI55bA I9J8AZWrweO/6/bwx4rUqgvJpZdEB0RNn6E+UVSBwznaVyyleWUSN3VYQ8x97vS5ZM24 Du07XRrha9wwj4NQpQzzWLNKItExrwGM9st18Fu2RLrwmzK5xUloqB/MjwnIOh7UuZD+ YjuaqJUOKsrLxSIQxp6PHX9/R8bDFeqbTwDuCzXcGowl772630ih4C0fCvHJehcikY3Q KQFcLTmtsUqYeswCae7OkmwOUnDMul+61d3GGseit0QprIKKSgI/5nsAIejBBkiaJ9iN FJjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=UZgDc4NqB64labXbUkmbFOqDnFwUTKKO+bOXvo7uUrA=; b=feVDyxqRmpmX4nc8c9I/fydJi410Zz2umhDhfhbI3qbbj2h5dQMqR09wHGL1V+78/f 4R4y5DgsGLPaYE+4TlUQfqyy+C1MZBhJ/FmZ4Uqf3whmadb4JCaOZZuYhM/KLuBQrDO/ kiaKz+UZTne0UwHCMVI4PziNbxEfR6jTOdfe5tNfACcxNgQr7pSBouKfF0/om3HFeY67 UCJ2k3nfloj5ior2xTd5lJD7JNFaRWUVTASnBd/wkV6vUT13yfjuF8CpsbZX1SW1pRhH WZ4fixBthjdcAcRImjpNeJANS3Cs2FmYTSzxAHZppgfYboosWQzpKYqghLu2IR2e7YXR HzTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=WQf5kvD0; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id t14si9300179pgh.128.2019.06.23.22.44.04 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:44:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=WQf5kvD0; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UZgDc4NqB64labXbUkmbFOqDnFwUTKKO+bOXvo7uUrA=; b=WQf5kvD0iLeHL+gjoj9J2oADBP LqKMXZw+Mj+AhxwqQumEt4dck7OeMldp9+qZsUi7B2njdhoQu5EYx9HMGkX0f6BZ50q5dRuZ4z1fT xjcJ3Fxh0FopxWvWOfSUIS1qMVI2flIkOXrIJjRCUtiJX4VPtxJ6BqxCmUsRQFXIKQBfkdmEbJqU2 d5oaTF/5MSXuHffMrBZ4jDAip4f6sbJx9s0dN/zB1w1MPlJBup2k3r5CKECJxiVwJZGWMOqr1ikMr hiKgwcLxeGK0RQ1cUvdJ7t06nuZ2LkDd2cyrhv+BNWPPFaOpNgO6utQQ/35pKQ6GLaWc7jrmveRbx yy5XiOIg==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlq-0006o6-Ir; Mon, 24 Jun 2019 05:44:03 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/17] riscv: don't allow selecting SBI-based drivers for M-mode Date: Mon, 24 Jun 2019 07:43:08 +0200 Message-Id: <20190624054311.30256-15-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Damien Le Moal Do not allow selecting SBI related options with MMU option not set. Signed-off-by: Damien Le Moal Signed-off-by: Christoph Hellwig --- drivers/tty/hvc/Kconfig | 2 +- drivers/tty/serial/Kconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/hvc/Kconfig b/drivers/tty/hvc/Kconfig index 4d22b911111f..5a1ab6b536ff 100644 --- a/drivers/tty/hvc/Kconfig +++ b/drivers/tty/hvc/Kconfig @@ -89,7 +89,7 @@ config HVC_DCC config HVC_RISCV_SBI bool "RISC-V SBI console support" - depends on RISCV + depends on RISCV && !M_MODE select HVC_DRIVER help This enables support for console output via RISC-V SBI calls, which diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 0d31251e04cc..59dba9f9e466 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -88,7 +88,7 @@ config SERIAL_EARLYCON_ARM_SEMIHOST config SERIAL_EARLYCON_RISCV_SBI bool "Early console using RISC-V SBI" - depends on RISCV + depends on RISCV && !M_MODE select SERIAL_CORE select SERIAL_CORE_CONSOLE select SERIAL_EARLYCON From patchwork Mon Jun 24 05:43:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D64C76 for ; Mon, 24 Jun 2019 05:44:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F00F28B01 for ; Mon, 24 Jun 2019 05:44:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23A4828B2C; Mon, 24 Jun 2019 05:44:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A030E28B01 for ; Mon, 24 Jun 2019 05:44:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51AD46B026E; Mon, 24 Jun 2019 01:44:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4A3A68E0002; Mon, 24 Jun 2019 01:44:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F62C8E0001; Mon, 24 Jun 2019 01:44:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id F023D6B026E for ; Mon, 24 Jun 2019 01:44:08 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id x18so8871575pfj.4 for ; Sun, 23 Jun 2019 22:44:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+BjmfBU5ZU5hXn/L4jPTIPV2WW0RF6JWpSgCnxtzPjA=; b=coHwwRbiwtER7Y6bvPfHltIHaUdFRn0Y5P//nKMzDBBo2jZdpgdjDSun4Pr0I2JBga N1beBAIr8YiI9m7HgE82HklbzQeQ09stjYY10Son0wTdmAsNvopdOED2uHZ6XADDRLWD TEnbRk61osCPVqc9KWKoz3NMq7+UqEOr0PqC3PKm2JTPuZqcf3AW9A+nMNQAGZgRyKu+ F/VnjuR1w0cUEBcRmVjX1FEEAPnojdu+PmuxD8WEJQt3ptalRHtyhMP1gKKVnagbpZ35 69O+Tx+tYd/HyY8bZzatGtymd4xveVHiJtBfMJu3iemSSicbh1UMt2fSFH4EospHfP4C 1yiw== X-Gm-Message-State: APjAAAV0jlDcerW1APdEDCZUk5HuIePfDoR2V4O5u36jCne0GMZhJnmt Geu2FISbSSgtbFWeb+IgjGk0mrKyTr5tqCMRIRVVWPnA46AmDJl94sqT7nrqn48TXcRImqVAhUT 2Ide+Xx43GpGasyXBI/6w6/gONeVBPEAUoZml+xGGqD60qsCdgWz56px04XywpCc= X-Received: by 2002:a17:902:b594:: with SMTP id a20mr1747159pls.259.1561355048675; Sun, 23 Jun 2019 22:44:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzv6t69oZYIvS94VY4/QSetWIrTkiD5mOvSSb+xu/1BrMfS3FQO41iIR+jLR+LnlgC7GVwS X-Received: by 2002:a17:902:b594:: with SMTP id a20mr1747131pls.259.1561355048045; Sun, 23 Jun 2019 22:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355048; cv=none; d=google.com; s=arc-20160816; b=kLWv3xIw5WUCt4OHRKr7NalegY8QFfKK44eokCZEbUl6Sph96k50LzCDlKtCF+X3de jOJ8GdODSHTO1jtv7ck1U9sRXjMp6Q+w8555u2o+PklVtnNCTOLwPZtvWzTualL7Naes NsrJItjL19+8rC630+j8Mbupid20MY0z7hpBSDPApLZNXAGBji9GWB6YjN/eefFBfitU 2UlghpFuMHIJkcedTRRBBZBIMu6Q6usAa3EYR11Za1t1wmuO3bHZIs8Zmk1uCa/cFi67 qvfJR8Q4nU+hXIfj/yMRvMG9J8k9pjjGc7WHsX3CcgSbJrRKeOn4tGRNwT0ZU4OQ8eld EVMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+BjmfBU5ZU5hXn/L4jPTIPV2WW0RF6JWpSgCnxtzPjA=; b=0zzjZgYpUBUusKA/xEJoQLKJv9YlNScz6bBae1P7iEq/IUUoWpnzgAPOxO7IOdg56D njI8lUpPe9AESuRzP5wyUqmqer2fhNBpyM5jCSDYRBvk2ZrAXY2O7byYqIm7COZWOXEk +VN/9pc7HHVkhnm6wAGrIH44iBkHvSw5nb+x3QT8dq2Y/ifubvBuOaFLWyj8flhkEqyy tJNxAl+7XFUP3h8yDjcdL3RcGtdZlf8z3h2zOlSMDbSN2QvRb4Va6TWWL379oIKCoYYf 95wIIw1xvrjwH94cXhLT/6VfvxsOhaMLDQWw95yR4PxN2rUJ9SPINaurNoLSmgqqZFBS u4mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=aGN6dTub; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id d31si9363045pla.84.2019.06.23.22.44.07 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:44:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=aGN6dTub; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+BjmfBU5ZU5hXn/L4jPTIPV2WW0RF6JWpSgCnxtzPjA=; b=aGN6dTubD0D69mjO3WVEYJFyjB 5y1YlY/6WZAOlD+aKcYvIOSCcaua7/aYGOliKS7XJuG4hrrjZ8LENcRaGw3h5Qxcn3tfYP+glU6+8 mawXoplRfU0xqHBf5u8/l3kyzWnAhIMkD8V+mrzNMUQYSaO+kjzJcogITGDZnZKasWvnBP9oNNDgK hj3dWYDaI2wLnybTsj2wZ6SjoTGq1z5k6vzU9VlJQhSORsNP5/hU0NvVargMZNfFhht1yqHP2bUto Utoklu47DO5TT2RGMSMPZhgFQ9KoMDLkL98EyoGYczUHATr8gAs+6BZbwI6bJ6VBLCCW0dmXV/Ie/ GJwuemoA==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlu-0006sF-4K; Mon, 24 Jun 2019 05:44:06 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/17] riscv: use the correct interrupt levels for M-mode Date: Mon, 24 Jun 2019 07:43:09 +0200 Message-Id: <20190624054311.30256-16-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The numerical levels for External/Timer/Software interrupts differ between S-mode and M-mode. Signed-off-by: Christoph Hellwig --- arch/riscv/kernel/irq.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/irq.c b/arch/riscv/kernel/irq.c index 804ff70bb853..9566aabbe50b 100644 --- a/arch/riscv/kernel/irq.c +++ b/arch/riscv/kernel/irq.c @@ -14,9 +14,15 @@ /* * Possible interrupt causes: */ -#define INTERRUPT_CAUSE_SOFTWARE IRQ_S_SOFT -#define INTERRUPT_CAUSE_TIMER IRQ_S_TIMER -#define INTERRUPT_CAUSE_EXTERNAL IRQ_S_EXT +#ifdef CONFIG_M_MODE +# define INTERRUPT_CAUSE_SOFTWARE IRQ_M_SOFT +# define INTERRUPT_CAUSE_TIMER IRQ_M_TIMER +# define INTERRUPT_CAUSE_EXTERNAL IRQ_M_EXT +#else +# define INTERRUPT_CAUSE_SOFTWARE IRQ_S_SOFT +# define INTERRUPT_CAUSE_TIMER IRQ_S_TIMER +# define INTERRUPT_CAUSE_EXTERNAL IRQ_S_EXT +#endif /* CONFIG_M_MODE */ int arch_show_interrupts(struct seq_file *p, int prec) { From patchwork Mon Jun 24 05:43:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72A731805 for ; Mon, 24 Jun 2019 05:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 641E228B01 for ; Mon, 24 Jun 2019 05:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56CC228B1E; Mon, 24 Jun 2019 05:44:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C767C28B01 for ; Mon, 24 Jun 2019 05:44:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB73D8E0002; Mon, 24 Jun 2019 01:44:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E66EB8E0001; Mon, 24 Jun 2019 01:44:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D321E8E0002; Mon, 24 Jun 2019 01:44:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 96ED38E0001 for ; Mon, 24 Jun 2019 01:44:12 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id i3so6713708plb.8 for ; Sun, 23 Jun 2019 22:44:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Oojq5kWgKyQ3wQ3E9C05rFdmIhyLa9IRTYHnqrokUgc=; b=AxuiJO7H6RRF85vS8IjU4JlCcSFvujx0Az3aXf3PWWQgC4UZOQlJe/MBLVpZ00n9LQ tdFdzz/aMTtkFElah/XOS/K0j8FBwADFCH8wv1wl6Zu6B10OtmyhcMaQ9a3mgoAeBcEm +zrV8mUrTcTYWGe0KcxzcSFsCUXOCxDYdLEz7jpoHWL3eUqCnolKSxdUrueN4n8IJrU2 cU31rBEAUPbz9nTQMY3Ltg1vPxf6U4Mf0CX9vLSgHQjGRcqd7jLaD86uSru9xxc55Ubk q8H9aW8UToHqDd3guZlo3jbSC1d5DcTVuVKy/iFwqbZYlAQLtUJIgG2AmmKYyipKROoW fQNg== X-Gm-Message-State: APjAAAVkukksG+d07kIsXJoiLwZrOCqAlCjSCW1QsASyatHOFIVSmwnv rfXlJr/4+EFSAEoKEfKjdxnTdj8raHiRFh+REDn8AyuMrYgc86n2VRHlIRC4SzANbLIZjlx137e N4X1NP4aUVr6SPhZiUIWbSf3Xwvnfx2DKITIQL/eVS2xTXX6gSU2yWrkgFwRCbHs= X-Received: by 2002:a17:902:6506:: with SMTP id b6mr4051240plk.253.1561355052287; Sun, 23 Jun 2019 22:44:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzs2iVYl4xWML0o8sW+MSlKJSUQE0Gsg+cy7Id3vZdP3r/ozhE088Wo5sofqPwtlv8wDQYf X-Received: by 2002:a17:902:6506:: with SMTP id b6mr4051208plk.253.1561355051591; Sun, 23 Jun 2019 22:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355051; cv=none; d=google.com; s=arc-20160816; b=ycreli+Zyv/t8J79ICHZ9jO08pzXmlbuUmOpow+UT0lyknVYW78c4EF6bDbR3Ic8x0 TcntzCsUfc2DOtCVKcoPHMVYCfRlLFl8YhO4gb3WCHjQDRIOytwCFNYfg3iL8F5xR/gl avt4myw2XfVX0GgPdYsd2SRu+nMsiS2GWQaDEyhEQLKmIg1RvphIOgbSIvSj7NlY5S9n TtsFh6JjbgvTZbGsPG/iV+1YEAM1WifPAbt328LmW0dEVqlsMTDZo0HAWYmCMgkaC4FP RAFPayosFrG/8xRx+GTqqARcggDTb8SswsfEVnenFctuvC3mJFbUNXcbEF9NedfX0ps3 e24A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Oojq5kWgKyQ3wQ3E9C05rFdmIhyLa9IRTYHnqrokUgc=; b=cf13SKOIOJhhqTF5Ouur6VurfnvEoPdd79tJfEFW4Erfb7e97Uqm7TJ4tAH1o0yoC1 US+MXLhm0a3z2Y4vAJ6bkbQrm919gsqPMzhgx3De44BAll0YLZyvW7RKA4u+nRAYR0Z0 +i/AkD+R48yioqr72BzZ1zHvCW1vAu1qksClWXz9o8rP2os3LKxPV/zzNavYVytuP6fh VkK4J0mc1lzqXUfwHCOUCD7FqMrbFMa7t0U3+FnElru8hikIz0hco6dcOzWrjpLsLUP7 n6yyknKx3Efuwp11q09WYmXtbYXvSjIyqylvG4ta1NloE/oGJK9JJidF1QoWZoXbkaCf WtUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=gnB13sR1; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id b5si9257237pgw.366.2019.06.23.22.44.11 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:44:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=gnB13sR1; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Oojq5kWgKyQ3wQ3E9C05rFdmIhyLa9IRTYHnqrokUgc=; b=gnB13sR18GLBVsZsJwTxXb3EoD RRnxn3LyhiZ85fsirsfi0/PTcHqG5BX2kl6hnhlYAvACZsBMRqnU+VN9heGqIyOqfKj4Y+DzHF+qG FBpb826uJvdE6kBG30tQDqbcLaDAhuht4VzYt3QALTZCTBJhCAkz8UDaWDpUfi5AIuFQpWwXtxyG6 YGXhaX2RwwRQHYabQiatM/eh/PDre8svDzJ+cA31dr1wLXLgknNIgtU7bLY+iowRrA+Wj8GYC+7g2 dPge0M3eqUFDdQ5vFL5GoOX9SQe6x9QwhNG54tBvjS0aGNkmO/ULNw0ib5I6lzxS0y3gwcdSxTuZs 5QY+sAXg==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHlx-0006wG-E0; Mon, 24 Jun 2019 05:44:10 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/17] riscv: clear the instruction cache and all registers when booting Date: Mon, 24 Jun 2019 07:43:10 +0200 Message-Id: <20190624054311.30256-17-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When we get booted we want a clear slate without any leaks from previous supervisors or the firmware. Flush the instruction cache and then clear all registers to known good values. This is really important for the upcoming nommu support that runs on M-mode, but can't really harm when running in S-mode either. Vaguely based on the concepts from opensbi. Signed-off-by: Christoph Hellwig --- arch/riscv/kernel/head.S | 85 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index a4c170e41a34..74feb17737b4 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -11,6 +11,7 @@ #include #include #include +#include __INIT ENTRY(_start) @@ -19,6 +20,12 @@ ENTRY(_start) csrw CSR_XIP, zero #ifdef CONFIG_M_MODE + /* flush the instruction cache */ + fence.i + + /* Reset all registers except ra, a0, a1 */ + call reset_regs + /* * The hartid in a0 is expected later on, and we have no firmware * to hand it to us. @@ -168,6 +175,84 @@ relocate: j .Lsecondary_park END(_start) +#ifdef CONFIG_M_MODE +ENTRY(reset_regs) + li sp, 0 + li gp, 0 + li tp, 0 + li t0, 0 + li t1, 0 + li t2, 0 + li s0, 0 + li s1, 0 + li a2, 0 + li a3, 0 + li a4, 0 + li a5, 0 + li a6, 0 + li a7, 0 + li s2, 0 + li s3, 0 + li s4, 0 + li s5, 0 + li s6, 0 + li s7, 0 + li s8, 0 + li s9, 0 + li s10, 0 + li s11, 0 + li t3, 0 + li t4, 0 + li t5, 0 + li t6, 0 + csrw sscratch, 0 + +#ifdef CONFIG_FPU + csrr t0, misa + andi t0, t0, (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D) + bnez t0, .Lreset_regs_done + + li t1, SR_FS + csrs sstatus, t1 + fmv.s.x f0, zero + fmv.s.x f1, zero + fmv.s.x f2, zero + fmv.s.x f3, zero + fmv.s.x f4, zero + fmv.s.x f5, zero + fmv.s.x f6, zero + fmv.s.x f7, zero + fmv.s.x f8, zero + fmv.s.x f9, zero + fmv.s.x f10, zero + fmv.s.x f11, zero + fmv.s.x f12, zero + fmv.s.x f13, zero + fmv.s.x f14, zero + fmv.s.x f15, zero + fmv.s.x f16, zero + fmv.s.x f17, zero + fmv.s.x f18, zero + fmv.s.x f19, zero + fmv.s.x f20, zero + fmv.s.x f21, zero + fmv.s.x f22, zero + fmv.s.x f23, zero + fmv.s.x f24, zero + fmv.s.x f25, zero + fmv.s.x f26, zero + fmv.s.x f27, zero + fmv.s.x f28, zero + fmv.s.x f29, zero + fmv.s.x f30, zero + fmv.s.x f31, zero + csrw fcsr, 0 +#endif /* CONFIG_FPU */ +.Lreset_regs_done: + ret +END(reset_regs) +#endif /* CONFIG_M_MODE */ + __PAGE_ALIGNED_BSS /* Empty zero page */ .balign PAGE_SIZE From patchwork Mon Jun 24 05:43:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11012219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C52576 for ; Mon, 24 Jun 2019 05:44:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B15328B01 for ; Mon, 24 Jun 2019 05:44:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F7BD28B1E; Mon, 24 Jun 2019 05:44:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07D8728B0B for ; Mon, 24 Jun 2019 05:44:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D3D28E0003; Mon, 24 Jun 2019 01:44:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9846E8E0001; Mon, 24 Jun 2019 01:44:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84CFA8E0003; Mon, 24 Jun 2019 01:44:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 4027D8E0001 for ; Mon, 24 Jun 2019 01:44:18 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id e7so6713468plt.13 for ; Sun, 23 Jun 2019 22:44:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bADdo+Mbgo83CtlWv1N78ekIJfVsXi0DKzmLCwrP8tg=; b=essct5xBQuJgHWDhHrOQgW6K1nPTsL7YZhIqNASgJNZSmjrU8e1RYl5t9ukSr7Jo0Q cTg6dg/6Tcktq6He55tcAdw4HM0FAn8nCIIPseMTFSL3NeLc/jR4HHH235NtWApqyRa7 D+sYEnDzpO9Jy/ETm6ItT6Dv3J3CAFFELWUNQ23UA31qFkFC2NI/SS0JGq7gwAOkNgZc CxumAJnuTvZLYybMUvIUG/ZLwIbjto8iy4YWKZKgGxQOjolI+AnBcPwWVvza+XRDTHH9 wlxN49PyRxFRqU4GSFt01CGyjCxTNSpipNUZCKrAy+QKXO/XH664B1MhjhLm7jZcTTUz lRUw== X-Gm-Message-State: APjAAAUWIBi3qYqJOtslB4j2QQR5uGhToITdO6srCpBeVtkIe9MymFQv L2EQjao7lwX37oIiAzPm+p692rdnhlLcZ2HN3TS/Sou5N08JFLZHmzB75ewG8+ezZZojiDQuhiz ZGzyLKJNDzVlH0ClNNe/M4VWybjClk2tNy8XcjBdEdJxeRAwvJtbpkBaOixX3Mcw= X-Received: by 2002:a65:64d5:: with SMTP id t21mr31851512pgv.310.1561355057661; Sun, 23 Jun 2019 22:44:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3Iz9Hdr4Bvg+FoOZi3zR+1rr3sgfcOH3y4RzqqCz8CXnYJ8jua/LfUjTbURmql4dVAtdP X-Received: by 2002:a65:64d5:: with SMTP id t21mr31851431pgv.310.1561355055908; Sun, 23 Jun 2019 22:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561355055; cv=none; d=google.com; s=arc-20160816; b=xdQsj2oZiB/vLYsZVwacDwoTY1BoaDjXVDHtH/wXzD2tow4BuOG6oab6D0J8e1dFcJ 2DxdF1ZogqB1Nthk20sLDkanMSSynWsAfvM2r+JY877uQ+A5RUNGHwgDX1MWdD1zdSXJ 1x04R5Gum6LhqptJn8xFPFHO+Jpt+LZ/q/tU9yuOcILsDm+i4uonIrf+8p13HM53T5kH wOfKGurnZHlMkPtCNqh+x6ZTbYkUJOHdOf+7fF3Am4s+7msoRydR60gPHrPTpxP5029K hDjWFa5lrTn3rcxSxT+c8A/qWRGBWKyzvN29gZ6iYygS9n5pnr3yQeGsl0Y9RQIgmY5t zSeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=bADdo+Mbgo83CtlWv1N78ekIJfVsXi0DKzmLCwrP8tg=; b=L1VCeSaFNjqztYbSO2ItbTHwfUmreDmjQv8VfL18KaudgkIT+cM6mz1jGWIoPe705J iMdFcbhiOGD+sHwSB+f1UYueraF479EC9FMiFPkuz5Cm9kTm6qunHcHl5n0ndQXcwh2N PqtA3RLRAHh+jzTgwkMfyZsT6zDeqpgbed8uoceWU8y7S1cWy6mAq32tkjPqy7gZXDAB kdzXtmQxUOXg4Pb4sfLACoySPm/Ds58MFSD19Um24MWx6qEIdWmpE4A05NSnoSkaXAgy i0+22L1aTS7pCzaroRtCz9g1uDTxFdzQIWEhkKhzN8pvZIsBzsO0zkWDdwZxjzPuIWU3 FQcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=qd1xnqNv; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id z9si9699636pju.2.2019.06.23.22.44.15 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 23 Jun 2019 22:44:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=qd1xnqNv; spf=pass (google.com: best guess record for domain of batv+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+84882ec255bc51113d1a+5783+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bADdo+Mbgo83CtlWv1N78ekIJfVsXi0DKzmLCwrP8tg=; b=qd1xnqNviXPK/Xv6R3erTR19ca BglzCnfB64T6lcv4qB6UeYPhVn0XAS2/7naeKyyP0p226JTodY2ENHArPQP5dvxJvMdBVopDLGDf/ XWrgkr5BmlKGJWiDZzAQfedCYZ0p4DCY1GutTDRl4EkEXW683vVl2MLs5daJB32yAT/EQJenXC+PP eERHLfGa3uuY+EenzP3Ubi/XsuS4jrGoPJp/CMsdF+imUqy73OVXX30vFDU+bYQP/3u1iToOYHk/d 7BOxatu+2BN+gOxT5SNF0xXqcfUSmbJT0U4WmYkPpB3Q1hBSHTRs7MVr7Jdky9R9URnI37aLbl0Vw leweGmEw==; Received: from 213-225-6-159.nat.highway.a1.net ([213.225.6.159] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hfHm1-0006zd-03; Mon, 24 Jun 2019 05:44:13 +0000 From: Christoph Hellwig To: Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/17] riscv: add nommu support Date: Mon, 24 Jun 2019 07:43:11 +0200 Message-Id: <20190624054311.30256-18-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190624054311.30256-1-hch@lst.de> References: <20190624054311.30256-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The kernel runs in M-mode without using page tables, and thus can't run bare metal without help from additional firmware. Most of the patch is just stubbing out code not needed without page tables, but there is an interesting detail in the signals implementation: - The normal RISC-V syscall ABI only implements rt_sigreturn as VDSO entry point, but the ELF VDSO is not supported for nommu Linux. We instead copy the code to call the syscall onto the stack. In addition to enabling the nommu code a new defconfig for a small kernel image that can run in nommu mode on qemu is also provided, to run a kernel in qemu you can use the following command line: qemu-system-riscv64 -smp 2 -m 64 -machine virt -nographic \ -kernel arch/riscv/boot/loader \ -drive file=rootfs.ext2,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 Contains contributions from Damien Le Moal . Signed-off-by: Christoph Hellwig --- arch/riscv/Kconfig | 24 +++++--- arch/riscv/configs/nommu_virt_defconfig | 78 +++++++++++++++++++++++++ arch/riscv/include/asm/elf.h | 4 +- arch/riscv/include/asm/futex.h | 6 ++ arch/riscv/include/asm/io.h | 4 ++ arch/riscv/include/asm/mmu.h | 3 + arch/riscv/include/asm/page.h | 12 +++- arch/riscv/include/asm/pgalloc.h | 2 + arch/riscv/include/asm/pgtable.h | 38 ++++++++---- arch/riscv/include/asm/tlbflush.h | 7 ++- arch/riscv/include/asm/uaccess.h | 4 ++ arch/riscv/kernel/Makefile | 3 +- arch/riscv/kernel/entry.S | 11 ++++ arch/riscv/kernel/head.S | 6 ++ arch/riscv/kernel/signal.c | 17 +++++- arch/riscv/lib/Makefile | 8 +-- arch/riscv/mm/Makefile | 3 +- arch/riscv/mm/cacheflush.c | 2 + arch/riscv/mm/context.c | 2 + arch/riscv/mm/init.c | 2 + 20 files changed, 200 insertions(+), 36 deletions(-) create mode 100644 arch/riscv/configs/nommu_virt_defconfig diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 2185481d1589..f36f337c7570 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -26,13 +26,13 @@ config RISCV select GENERIC_IRQ_SHOW select GENERIC_PCI_IOMAP select GENERIC_SCHED_CLOCK - select GENERIC_STRNCPY_FROM_USER - select GENERIC_STRNLEN_USER + select GENERIC_STRNCPY_FROM_USER if MMU + select GENERIC_STRNLEN_USER if MMU select GENERIC_SMP_IDLE_THREAD select GENERIC_ATOMIC64 if !64BIT select HAVE_ARCH_AUDITSYSCALL select HAVE_MEMBLOCK_NODE_MAP - select HAVE_DMA_CONTIGUOUS + select HAVE_DMA_CONTIGUOUS if MMU select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_PERF_EVENTS select HAVE_SYSCALL_TRACEPOINTS @@ -47,6 +47,7 @@ config RISCV select PCI_DOMAINS_GENERIC if PCI select PCI_MSI if PCI select RISCV_TIMER + select UACCESS_MEMCPY if !MMU select GENERIC_IRQ_MULTI_HANDLER select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_MMIOWB @@ -55,9 +56,14 @@ config RISCV # set if we run in machine mode, cleared if we run in supervisor mode config M_MODE bool + default y if !MMU config MMU - def_bool y + bool "MMU-based Paged Memory Management Support" + default y + help + Select if you want MMU-based virtualised addressing space + support by paged memory management. If unsure, say 'Y'. config ZONE_DMA32 bool @@ -66,6 +72,7 @@ config ZONE_DMA32 config PAGE_OFFSET hex default 0xC0000000 if 32BIT && MAXPHYSMEM_2GB + default 0x80000000 if 64BIT && !MMU default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB @@ -93,7 +100,7 @@ config GENERIC_HWEIGHT def_bool y config FIX_EARLYCON_MEM - def_bool y + def_bool CONFIG_MMU config PGTABLE_LEVELS int @@ -116,6 +123,7 @@ config ARCH_RV32I select GENERIC_LIB_ASHRDI3 select GENERIC_LIB_LSHRDI3 select GENERIC_LIB_UCMPDI2 + select MMU config ARCH_RV64I bool "RV64I" @@ -124,9 +132,9 @@ config ARCH_RV64I select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FTRACE_MCOUNT_RECORD - select HAVE_DYNAMIC_FTRACE - select HAVE_DYNAMIC_FTRACE_WITH_REGS - select SWIOTLB + select HAVE_DYNAMIC_FTRACE if MMU + select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE + select SWIOTLB if MMU endchoice diff --git a/arch/riscv/configs/nommu_virt_defconfig b/arch/riscv/configs/nommu_virt_defconfig new file mode 100644 index 000000000000..cf74e179bf90 --- /dev/null +++ b/arch/riscv/configs/nommu_virt_defconfig @@ -0,0 +1,78 @@ +# CONFIG_CPU_ISOLATION is not set +CONFIG_LOG_BUF_SHIFT=16 +CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=12 +CONFIG_BLK_DEV_INITRD=y +# CONFIG_RD_BZIP2 is not set +# CONFIG_RD_LZMA is not set +# CONFIG_RD_XZ is not set +# CONFIG_RD_LZO is not set +# CONFIG_RD_LZ4 is not set +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +CONFIG_EXPERT=y +# CONFIG_SYSFS_SYSCALL is not set +# CONFIG_FHANDLE is not set +# CONFIG_BASE_FULL is not set +# CONFIG_EPOLL is not set +# CONFIG_SIGNALFD is not set +# CONFIG_TIMERFD is not set +# CONFIG_EVENTFD is not set +# CONFIG_AIO is not set +# CONFIG_IO_URING is not set +# CONFIG_ADVISE_SYSCALLS is not set +# CONFIG_MEMBARRIER is not set +# CONFIG_KALLSYMS is not set +# CONFIG_VM_EVENT_COUNTERS is not set +# CONFIG_COMPAT_BRK is not set +CONFIG_SLOB=y +# CONFIG_SLAB_MERGE_DEFAULT is not set +# CONFIG_MMU is not set +CONFIG_MAXPHYSMEM_2GB=y +CONFIG_SMP=y +CONFIG_CMDLINE="root=/dev/vda rw earlycon=uart8250,mmio,0x10000000,115200n8 console=ttyS0" +CONFIG_CMDLINE_FORCE=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_MSDOS_PARTITION is not set +# CONFIG_EFI_PARTITION is not set +# CONFIG_MQ_IOSCHED_DEADLINE is not set +# CONFIG_MQ_IOSCHED_KYBER is not set +CONFIG_BINFMT_FLAT=y +# CONFIG_COREDUMP is not set +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +# CONFIG_FW_LOADER is not set +# CONFIG_ALLOW_DEV_COREDUMP is not set +CONFIG_VIRTIO_BLK=y +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_SERIO is not set +# CONFIG_LEGACY_PTYS is not set +# CONFIG_LDISC_AUTOLOAD is not set +# CONFIG_DEVMEM is not set +CONFIG_SERIAL_8250=y +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=1 +CONFIG_SERIAL_8250_RUNTIME_UARTS=1 +CONFIG_SERIAL_OF_PLATFORM=y +# CONFIG_HW_RANDOM is not set +# CONFIG_HWMON is not set +# CONFIG_LCD_CLASS_DEVICE is not set +# CONFIG_BACKLIGHT_CLASS_DEVICE is not set +# CONFIG_VGA_CONSOLE is not set +# CONFIG_HID is not set +# CONFIG_USB_SUPPORT is not set +CONFIG_VIRTIO_MMIO=y +CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y +CONFIG_SIFIVE_PLIC=y +# CONFIG_VALIDATE_FS_PARSER is not set +CONFIG_EXT2_FS=y +# CONFIG_DNOTIFY is not set +# CONFIG_INOTIFY_USER is not set +# CONFIG_MISC_FILESYSTEMS is not set +CONFIG_LSM="[]" +CONFIG_PRINTK_TIME=y +# CONFIG_SCHED_DEBUG is not set +# CONFIG_RCU_TRACE is not set +# CONFIG_FTRACE is not set +# CONFIG_RUNTIME_TESTING_MENU is not set diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h index ef04084bf0de..d83a4efd052b 100644 --- a/arch/riscv/include/asm/elf.h +++ b/arch/riscv/include/asm/elf.h @@ -56,16 +56,16 @@ extern unsigned long elf_hwcap; */ #define ELF_PLATFORM (NULL) +#ifdef CONFIG_MMU #define ARCH_DLINFO \ do { \ NEW_AUX_ENT(AT_SYSINFO_EHDR, \ (elf_addr_t)current->mm->context.vdso); \ } while (0) - - #define ARCH_HAS_SETUP_ADDITIONAL_PAGES struct linux_binprm; extern int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp); +#endif /* CONFIG_MMU */ #endif /* _ASM_RISCV_ELF_H */ diff --git a/arch/riscv/include/asm/futex.h b/arch/riscv/include/asm/futex.h index 4ad6409c4647..418564b96dc4 100644 --- a/arch/riscv/include/asm/futex.h +++ b/arch/riscv/include/asm/futex.h @@ -12,6 +12,12 @@ #include #include +/* We don't even really need the extable code, but for now keep it simple */ +#ifndef CONFIG_MMU +#define __enable_user_access() do { } while (0) +#define __disable_user_access() do { } while (0) +#endif + #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ { \ uintptr_t tmp; \ diff --git a/arch/riscv/include/asm/io.h b/arch/riscv/include/asm/io.h index fc1189ad3777..d39a8f03e85e 100644 --- a/arch/riscv/include/asm/io.h +++ b/arch/riscv/include/asm/io.h @@ -14,6 +14,7 @@ #include #include +#ifdef CONFIG_MMU extern void __iomem *ioremap(phys_addr_t offset, unsigned long size); /* @@ -26,6 +27,9 @@ extern void __iomem *ioremap(phys_addr_t offset, unsigned long size); #define ioremap_wt(addr, size) ioremap((addr), (size)) extern void iounmap(volatile void __iomem *addr); +#else +#define pgprot_noncached(x) (x) +#endif /* CONFIG_MMU */ /* Generic IO read/write. These perform native-endian accesses. */ #define __raw_writeb __raw_writeb diff --git a/arch/riscv/include/asm/mmu.h b/arch/riscv/include/asm/mmu.h index 151476fb58cb..967eacb01ab5 100644 --- a/arch/riscv/include/asm/mmu.h +++ b/arch/riscv/include/asm/mmu.h @@ -10,6 +10,9 @@ #ifndef __ASSEMBLY__ typedef struct { +#ifndef CONFIG_MMU + unsigned long end_brk; +#endif void *vdso; #ifdef CONFIG_SMP /* A local icache flush is needed before user execution can resume. */ diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h index 8ddb6c7fedac..df0256a9a965 100644 --- a/arch/riscv/include/asm/page.h +++ b/arch/riscv/include/asm/page.h @@ -78,8 +78,14 @@ typedef struct page *pgtable_t; #define PTE_FMT "%08lx" #endif +#ifdef CONFIG_MMU extern unsigned long va_pa_offset; extern unsigned long pfn_base; +#define ARCH_PFN_OFFSET (pfn_base) +#else +#define va_pa_offset 0 +#define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT) +#endif /* CONFIG_MMU */ extern unsigned long max_low_pfn; extern unsigned long min_low_pfn; @@ -101,9 +107,7 @@ extern unsigned long min_low_pfn; #define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr))) #define pfn_valid(pfn) \ - (((pfn) >= pfn_base) && (((pfn)-pfn_base) < max_mapnr)) - -#define ARCH_PFN_OFFSET (pfn_base) + (((pfn) >= ARCH_PFN_OFFSET) && (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)) #endif /* __ASSEMBLY__ */ @@ -115,8 +119,10 @@ extern unsigned long min_low_pfn; #include #include +#ifdef CONFIG_MMU /* vDSO support */ /* We do define AT_SYSINFO_EHDR but don't use the gate mechanism */ #define __HAVE_ARCH_GATE_AREA +#endif /* CONFIG_MMU */ #endif /* _ASM_RISCV_PAGE_H */ diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h index eb8b0195f27f..8d60c862d2f9 100644 --- a/arch/riscv/include/asm/pgalloc.h +++ b/arch/riscv/include/asm/pgalloc.h @@ -10,6 +10,7 @@ #include #include +#ifdef CONFIG_MMU static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) { @@ -106,6 +107,7 @@ do { \ pgtable_page_dtor(pte); \ tlb_remove_page((tlb), pte); \ } while (0) +#endif /* CONFIG_MMU */ static inline void check_pgt_cache(void) { diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index f7c3f7de15f2..dd6a63648e4a 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -24,6 +24,7 @@ #include #endif /* CONFIG_64BIT */ +#ifdef CONFIG_MMU /* Number of entries in the page global directory */ #define PTRS_PER_PGD (PAGE_SIZE / sizeof(pgd_t)) /* Number of entries in the page table */ @@ -31,7 +32,6 @@ /* Number of PGD entries that a user-mode program can use */ #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) -#define FIRST_USER_ADDRESS 0 /* Page protection bits */ #define _PAGE_BASE (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_USER) @@ -81,13 +81,6 @@ extern pgd_t swapper_pg_dir[]; #define __S110 PAGE_SHARED_EXEC #define __S111 PAGE_SHARED_EXEC -/* - * ZERO_PAGE is a global shared page that is always zero, - * used for zero-mapped memory areas, etc. - */ -extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; -#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) - static inline int pmd_present(pmd_t pmd) { return (pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROT_NONE)); @@ -392,6 +385,18 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma, #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) +#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) +#define VMALLOC_END (PAGE_OFFSET - 1) +#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) + +#else /* CONFIG_MMU */ + +#define PAGE_KERNEL __pgprot(0) +#define swapper_pg_dir NULL +#define VMALLOC_START 0 + +#endif /* CONFIG_MMU */ + #ifdef CONFIG_FLATMEM #define kern_addr_valid(addr) (1) /* FIXME */ #endif @@ -404,10 +409,7 @@ static inline void pgtable_cache_init(void) /* No page table caches to initialize */ } -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) -#define VMALLOC_END (PAGE_OFFSET - 1) -#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) - +#ifdef CONFIG_MMU /* * Task size is 0x40000000000 for RV64 or 0xb800000 for RV32. * Note that PGDIR_SIZE must evenly divide TASK_SIZE. @@ -417,6 +419,18 @@ static inline void pgtable_cache_init(void) #else #define TASK_SIZE VMALLOC_START #endif +#else /* CONFIG_MMU */ +#define TASK_SIZE 0xffffffffUL +#endif /* !CONFIG_MMU */ + +#define FIRST_USER_ADDRESS 0 + +/* + * ZERO_PAGE is a global shared page that is always zero, + * used for zero-mapped memory areas, etc. + */ +extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]; +#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) #include diff --git a/arch/riscv/include/asm/tlbflush.h b/arch/riscv/include/asm/tlbflush.h index 687dd19735a7..f127b3d17ec2 100644 --- a/arch/riscv/include/asm/tlbflush.h +++ b/arch/riscv/include/asm/tlbflush.h @@ -10,6 +10,7 @@ #include #include +#ifdef CONFIG_MMU /* * Flush entire local TLB. 'sfence.vma' implicitly fences with the instruction * cache as well, so a 'fence.i' is not necessary. @@ -24,8 +25,12 @@ static inline void local_flush_tlb_page(unsigned long addr) { __asm__ __volatile__ ("sfence.vma %0" : : "r" (addr) : "memory"); } +#else /* CONFIG_MMU */ +#define local_flush_tlb_all() do { } while (0) +#define local_flush_tlb_page(addr) do { } while (0) +#endif /* CONFIG_MMU */ -#ifndef CONFIG_SMP +#if !defined(CONFIG_SMP) || !defined(CONFIG_MMU) #define flush_tlb_all() local_flush_tlb_all() #define flush_tlb_page(vma, addr) local_flush_tlb_page(addr) diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h index e076437cfafe..f462a183a9c2 100644 --- a/arch/riscv/include/asm/uaccess.h +++ b/arch/riscv/include/asm/uaccess.h @@ -11,6 +11,7 @@ /* * User space memory access functions */ +#ifdef CONFIG_MMU #include #include #include @@ -475,4 +476,7 @@ unsigned long __must_check clear_user(void __user *to, unsigned long n) __ret; \ }) +#else /* CONFIG_MMU */ +#include +#endif /* CONFIG_MMU */ #endif /* _ASM_RISCV_UACCESS_H */ diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index f933c04f89db..d720666283d6 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -25,9 +25,8 @@ obj-y += time.o obj-y += traps.o obj-y += riscv_ksyms.o obj-y += stacktrace.o -obj-y += vdso.o obj-y += cacheinfo.o -obj-y += vdso/ +obj-$(CONFIG_MMU) += vdso.o vdso/ obj-$(CONFIG_M_MODE) += clint.o obj-$(CONFIG_FPU) += fpu.o diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S index b722ce20dc20..0e040573d6a8 100644 --- a/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S @@ -370,6 +370,10 @@ ENTRY(__switch_to) ret ENDPROC(__switch_to) +#ifndef CONFIG_MMU +#define do_page_fault do_trap_unknown +#endif + .section ".rodata" /* Exception vector table */ ENTRY(excp_vect_table) @@ -391,3 +395,10 @@ ENTRY(excp_vect_table) RISCV_PTR do_page_fault /* store page fault */ excp_vect_table_end: END(excp_vect_table) + +#ifndef CONFIG_MMU +ENTRY(__user_rt_sigreturn) + li a7, __NR_rt_sigreturn + scall +END(__user_rt_sigreturn) +#endif diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 74feb17737b4..405bd6ccf44a 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -68,10 +68,12 @@ clear_bss_done: la a2, boot_cpu_hartid REG_S a0, (a2) +#ifdef CONFIG_MMU /* Initialize page tables and relocate to virtual addresses */ la sp, init_thread_union + THREAD_SIZE call setup_vm call relocate +#endif /* CONFIG_MMU */ /* Restore C environment */ la tp, init_task @@ -83,6 +85,7 @@ clear_bss_done: call parse_dtb tail start_kernel +#ifdef CONFIG_MMU relocate: /* Relocate return address */ li a1, PAGE_OFFSET @@ -134,6 +137,7 @@ relocate: sfence.vma ret +#endif /* CONFIG_MMU */ .Lsecondary_start: #ifdef CONFIG_SMP @@ -162,8 +166,10 @@ relocate: beqz tp, .Lwait_for_cpu_up fence +#ifdef CONFIG_MMU /* Enable virtual memory and relocate to virtual address */ call relocate +#endif tail smp_callin #endif diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c index dfb26b64e17a..7de7e539b25b 100644 --- a/arch/riscv/kernel/signal.c +++ b/arch/riscv/kernel/signal.c @@ -17,11 +17,16 @@ #include #include +extern u32 __user_rt_sigreturn[2]; + #define DEBUG_SIG 0 struct rt_sigframe { struct siginfo info; struct ucontext uc; +#ifndef CONFIG_MMU + u32 sigreturn_code[2]; +#endif }; #ifdef CONFIG_FPU @@ -166,7 +171,6 @@ static inline void __user *get_sigframe(struct ksignal *ksig, return (void __user *)sp; } - static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs) { @@ -189,8 +193,19 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, return -EFAULT; /* Set up to return from userspace. */ +#ifdef CONFIG_MMU regs->ra = (unsigned long)VDSO_SYMBOL( current->mm->context.vdso, rt_sigreturn); +#else + /* + * For the nommu case we don't have a VDSO. Instead we push two + * instructions to call the rt_sigreturn syscall onto the user stack. + */ + if (copy_to_user(&frame->sigreturn_code, __user_rt_sigreturn, + sizeof(frame->sigreturn_code))) + return -EFAULT; + regs->ra = (unsigned long)&frame->sigreturn_code;; +#endif /* CONFIG_MMU */ /* * Set up registers for signal handler. diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index 8e364ebf37de..5382e42d0cba 100644 --- a/arch/riscv/lib/Makefile +++ b/arch/riscv/lib/Makefile @@ -2,8 +2,6 @@ lib-y += delay.o lib-y += memcpy.o lib-y += memset.o -lib-y += uaccess.o - -lib-$(CONFIG_64BIT) += tishift.o - -lib-$(CONFIG_32BIT) += udivdi3.o +lib-$(CONFIG_MMU) += uaccess.o +lib-$(CONFIG_64BIT) += tishift.o +lib-$(CONFIG_32BIT) += udivdi3.o diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile index fc51d3b7876e..8fc2fd148b06 100644 --- a/arch/riscv/mm/Makefile +++ b/arch/riscv/mm/Makefile @@ -6,9 +6,8 @@ CFLAGS_REMOVE_init.o = -pg endif obj-y += init.o -obj-y += fault.o obj-y += extable.o -obj-y += ioremap.o +obj-$(CONFIG_MMU) += fault.o ioremap.o obj-y += cacheflush.o obj-y += context.o obj-y += sifive_l2_cache.o diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c index 10875ea1065e..0fc69eedc921 100644 --- a/arch/riscv/mm/cacheflush.c +++ b/arch/riscv/mm/cacheflush.c @@ -90,6 +90,7 @@ void flush_icache_mm(struct mm_struct *mm, bool local) #endif /* CONFIG_SMP */ +#ifdef CONFIG_MMU void flush_icache_pte(pte_t pte) { struct page *page = pte_page(pte); @@ -97,3 +98,4 @@ void flush_icache_pte(pte_t pte) if (!test_and_set_bit(PG_dcache_clean, &page->flags)) flush_icache_all(); } +#endif /* CONFIG_MMU */ diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c index beeb5d7f92ea..073ff12a838a 100644 --- a/arch/riscv/mm/context.c +++ b/arch/riscv/mm/context.c @@ -57,8 +57,10 @@ void switch_mm(struct mm_struct *prev, struct mm_struct *next, cpumask_clear_cpu(cpu, mm_cpumask(prev)); cpumask_set_cpu(cpu, mm_cpumask(next)); +#ifdef CONFIG_MMU csr_write(CSR_SATP, virt_to_pfn(next->pgd) | SATP_MODE); local_flush_tlb_all(); +#endif flush_icache_deferred(next); } diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 84747d7a1e85..782be273e714 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -142,6 +142,7 @@ void __init setup_bootmem(void) } } +#ifdef CONFIG_MMU unsigned long va_pa_offset; EXPORT_SYMBOL(va_pa_offset); unsigned long pfn_base; @@ -247,3 +248,4 @@ asmlinkage void __init setup_vm(void) __pgprot(_PAGE_TABLE)); #endif } +#endif /* CONFIG_MMU */