diff --git a/kernel.spec b/kernel.spec index 1cb43d0d5..08be22d3b 100644 --- a/kernel.spec +++ b/kernel.spec @@ -880,6 +880,15 @@ Patch528: netfilter_ppc_fix.patch # https://github.com/sifive/riscv-linux/commits/dev/paulw/cpufreq-dt-aloe-v5.3-rc4 Patch570: 0002-SiFive-Unleashed-CPUFreq.patch +# https://patchwork.kernel.org/patch/11297277/ +Patch571: riscv-fix-kconfig.patch + +# https://patchwork.kernel.org/patch/11297561/ +Patch572: riscv-fix-sparsemem-vmemmap.patch + +# https://patchwork.kernel.org/patch/11299999/ +Patch573: riscv-fix-seccomp-invalid-syscall.patch + # END OF PATCH DEFINITIONS %endif diff --git a/riscv-fix-kconfig.patch b/riscv-fix-kconfig.patch new file mode 100644 index 000000000..4f9450e3e --- /dev/null +++ b/riscv-fix-kconfig.patch @@ -0,0 +1,119 @@ +From patchwork Tue Dec 17 11:15:16 2019 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Andreas Schwab +X-Patchwork-Id: 11297277 +Return-Path: + +Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org + [172.30.200.123]) + by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAF3D930 + for ; + Tue, 17 Dec 2019 11:15:24 +0000 (UTC) +Received: from bombadil.infradead.org (bombadil.infradead.org + [198.137.202.133]) + (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) + (No client certificate requested) + by mail.kernel.org (Postfix) with ESMTPS id 9843020733 + for ; + Tue, 17 Dec 2019 11:15:24 +0000 (UTC) +Authentication-Results: mail.kernel.org; + dkim=pass (2048-bit key) header.d=lists.infradead.org + header.i=@lists.infradead.org header.b="LRlwkjxA" +DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9843020733 +Authentication-Results: mail.kernel.org; + dmarc=none (p=none dis=none) header.from=suse.de +Authentication-Results: mail.kernel.org; + spf=none + smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org +DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; + d=lists.infradead.org; s=bombadil.20170209; h=Sender:Cc:List-Subscribe: + List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: + MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:To:From:Reply-To: + Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: + Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; + bh=POCsPLaJniMTgraBSW2EtFrG0OqZrVUn3jzMxkZE6E0=; b=LRlwkjxASmk5L7n8yiiJ/5+2j + 11l3groGCplnOWqpZX+tR9Mp6js4uI/qIvcHIMgGuzOThEyYsRQxl3dzF3kczDpY1od7z81XaXi9c + Xmvmz3VcCJxlX6I3BptscF6ym9eyTsfGnRbeXllaQ76DPD00kHgcC3KEhExy1eT0xYKQiIUH6Lr1f + 9BZxntJbVkzAU3jWex9CweMCeowv+l5uN4FURyUBvl1dEzJtHLhAEsDhnaIw2XXD/NraIbaPCVfqa + g7ABY1IuDXMG8cWhKnIZrESwXN1owVeZzN0tEwEmSX1ix3kZIvv+i7RdiHJXvBtl3x3lsZs1WEHsV + nkcg2huLw==; +Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) + by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) + id 1ihAp0-0003ps-Td; Tue, 17 Dec 2019 11:15:22 +0000 +Received: from mx2.suse.de ([195.135.220.15]) + by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) + id 1ihAox-0003jh-74 + for linux-riscv@lists.infradead.org; Tue, 17 Dec 2019 11:15:20 +0000 +X-Virus-Scanned: by amavisd-new at test-mx.suse.de +Received: from relay2.suse.de (unknown [195.135.220.254]) + by mx2.suse.de (Postfix) with ESMTP id 5F4F5AC59; + Tue, 17 Dec 2019 11:15:17 +0000 (UTC) +From: Andreas Schwab +To: linux-riscv@lists.infradead.org +Subject: [PATCH] riscv: Fix use of undefined config option CONFIG_CONFIG_MMU +References: +X-Yow: .. I want FORTY-TWO TRYNEL FLOATATION SYSTEMS installed within + SIX AND A HALF HOURS!!! +Date: Tue, 17 Dec 2019 12:15:16 +0100 +In-Reply-To: (Andreas Schwab's message of "Tue, 17 + Dec 2019 11:41:51 +0100") +Message-ID: +User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) +MIME-Version: 1.0 +X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 +X-CRM114-CacheID: sfid-20191217_031519_411449_C1500CC1 +X-CRM114-Status: GOOD ( 11.75 ) +X-Spam-Score: -2.3 (--) +X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: + Content analysis details: (-2.3 points) + pts rule name description + ---- ---------------------- + -------------------------------------------------- + -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, + medium trust [195.135.220.15 listed in list.dnswl.org] + -0.0 SPF_PASS SPF: sender matches SPF record + 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) + [195.135.220.15 listed in wl.mailspike.net] + 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record + 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders +X-BeenThere: linux-riscv@lists.infradead.org +X-Mailman-Version: 2.1.29 +Precedence: list +List-Id: +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Cc: Anup Patel , Christoph Hellwig , + Paul Walmsley +Sender: "linux-riscv" +Errors-To: + linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org + +In Kconfig files, config options are written without the CONFIG_ prefix. + +Fixes: 6bd33e1ece52 ("riscv: add nommu support") +Signed-off-by: Andreas Schwab +Reviewed-by: Anup Patel +--- + arch/riscv/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig +index b7fc77c0e860..298662e72572 100644 +--- a/arch/riscv/Kconfig ++++ b/arch/riscv/Kconfig +@@ -156,7 +156,7 @@ config GENERIC_HWEIGHT + def_bool y + + config FIX_EARLYCON_MEM +- def_bool CONFIG_MMU ++ def_bool MMU + + config PGTABLE_LEVELS + int diff --git a/riscv-fix-seccomp-invalid-syscall.patch b/riscv-fix-seccomp-invalid-syscall.patch new file mode 100644 index 000000000..137de109e --- /dev/null +++ b/riscv-fix-seccomp-invalid-syscall.patch @@ -0,0 +1,167 @@ +From patchwork Wed Dec 18 08:47:56 2019 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: David Abdurachmanov +X-Patchwork-Id: 11299999 +Return-Path: + +Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org + [172.30.200.123]) + by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7943F13A4 + for ; + Wed, 18 Dec 2019 08:48:11 +0000 (UTC) +Received: from bombadil.infradead.org (bombadil.infradead.org + [198.137.202.133]) + (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) + (No client certificate requested) + by mail.kernel.org (Postfix) with ESMTPS id 55ABE21582 + for ; + Wed, 18 Dec 2019 08:48:11 +0000 (UTC) +Authentication-Results: mail.kernel.org; + dkim=pass (2048-bit key) header.d=lists.infradead.org + header.i=@lists.infradead.org header.b="YAb5GBl9"; + dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com + header.b="XLksOQyi" +DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55ABE21582 +Authentication-Results: mail.kernel.org; + dmarc=fail (p=none dis=none) header.from=gmail.com +Authentication-Results: mail.kernel.org; + spf=none + smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org +DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; + d=lists.infradead.org; s=bombadil.20170209; h=Sender:Cc:List-Subscribe: + List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: + Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:To:From: + Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: + Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: + List-Owner; bh=yaG+oMd4gi7zP4mz5z7EHKsmoy3fZzIJMA/I7rfBMDo=; b=YAb5GBl94x1IG3 + iILZE1QIDO5VSDvcWWJuSNX8AuJDaq+D2VWoF12BACAPysaBgFL+SWNVuOKZBae9L4d/9oEp+oH4H + idGshCWKWzzaAJb1ASOXLNk/EVvZvMHHDZzZpM3jJJoq0zpq8cNry8oreATriqYExqp+GS04ORJTD + uhor0GYHH7AJvDac6j355Dh3R4J+8KJ6CNQeQalfShQ5HTaF99dTSFxeXz8fl+IbtY2EOuGVUOUTu + NgolBoVesgx6bWzJx1tq5xaFa/CrmAgMx69NSF4ppboUND8TkABdjHNJLMnkmZt4xrJxMCyZwWM+D + MpEkxe2oTzg2/R4N04yA==; +Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) + by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) + id 1ihV05-0001my-IZ; Wed, 18 Dec 2019 08:48:09 +0000 +Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) + by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) + id 1ihV03-0001mP-4D + for linux-riscv@lists.infradead.org; Wed, 18 Dec 2019 08:48:08 +0000 +Received: by mail-wr1-x444.google.com with SMTP id z3so1330121wru.3 + for ; Wed, 18 Dec 2019 00:48:06 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; + h=from:to:cc:subject:date:message-id:mime-version + :content-transfer-encoding; + bh=yaG+oMd4gi7zP4mz5z7EHKsmoy3fZzIJMA/I7rfBMDo=; + b=XLksOQyij2bqKFaP3kJv3LCTxtA0gwK4VkT/nP1+JoLVzqS3ZrcHhUHe3SyROsL8yl + Z7mZ5s4l54fd5fOYNaVm9qWA1Afh6gnJ9YpiJfS14FlGrKHnWmK1asfSZsv6hQ5ulYtG + rRYO43iOhTfwA5Lzf15/OtV85ksLsJhXhOprZ8seP7yOj59yKNDmxIL1swQj+ilQdHVw + HAYZ3DzGLgwf08Z9scf2gtHRQbxZMDTfKElk9Yd6iFsPEDKAA1AZRjbQdQ3hXhwLcrGy + xUbEJjZvjPHz0+rzgDXWTkanIsXQc7RyyIpSa2REGBCGkoJQrvwryrlqzZncPGzPANFJ + BzLA== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20161025; + h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version + :content-transfer-encoding; + bh=yaG+oMd4gi7zP4mz5z7EHKsmoy3fZzIJMA/I7rfBMDo=; + b=XgPDUVNpI+/5CkkQlA3IABSVX0kW/B8Nfrh0eYiwLGBGUysywEXYxM1/D6oAZ8g+5M + BU8WU0WoC1BFRkJq13ewZzRKW3B7USPA8A3TLMsgokLA88eLJIhaU5ujVzbGqgKJfhbp + g2m7pEmDbI6lMl4uO//UMLfxxK3wbIMFwV5ysY4Z7SwssqkoqP0KtDBMY6F4fE2tsFOP + MRYPqMd5GTs/4uU/065KsUk46pyjdUm0ZBJUEpiPJlhtojH8V3PJFOv0J5/epJfpzFZ6 + dIkHJpJ/B2WZgLGPouINmlABHdQ+/Bg1eU+4ZYmvryGkovJAcvyEf9jFSKMDZoDZ25N/ + mc7Q== +X-Gm-Message-State: APjAAAUP3FAnPljNebrJA0wO+Rg373UuuTRJqk+Cwu6c5ShuUmncPyT0 + HDzSJz7h02hhR2ohv09upss= +X-Google-Smtp-Source: + APXvYqwzQr73+H1pnvdEfcVdXui7/DNx4znwqvuycyoJkS7uGWF785qxUNpJgwQ0jTQq41H6f4fD1A== +X-Received: by 2002:a5d:52c4:: with SMTP id r4mr1342304wrv.368.1576658885608; + Wed, 18 Dec 2019 00:48:05 -0800 (PST) +Received: from localhost.localdomain (78-63-27-146.static.zebra.lt. + [78.63.27.146]) + by smtp.gmail.com with ESMTPSA id f207sm1885138wme.9.2019.12.18.00.48.04 + (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); + Wed, 18 Dec 2019 00:48:05 -0800 (PST) +From: David Abdurachmanov +X-Google-Original-From: David Abdurachmanov +To: Paul Walmsley , + Palmer Dabbelt , Albert Ou , + David Abdurachmanov , + Kees Cook , Anup Patel , + Vincent Chen , + Valentin Schneider , + Thomas Gleixner , Bin Meng , + linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org +Subject: [PATCH] riscv: reject invalid syscalls below -1 +Date: Wed, 18 Dec 2019 10:47:56 +0200 +Message-Id: <20191218084757.904971-1-david.abdurachmanov@sifive.com> +X-Mailer: git-send-email 2.24.1 +MIME-Version: 1.0 +X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 +X-CRM114-CacheID: sfid-20191218_004807_165702_4FF6CC7C +X-CRM114-Status: UNSURE ( 8.57 ) +X-CRM114-Notice: Please train this message. +X-Spam-Score: -0.2 (/) +X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: + Content analysis details: (-0.2 points) + pts rule name description + ---- ---------------------- + -------------------------------------------------- + -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, + no trust [2a00:1450:4864:20:0:0:0:444 listed in] + [list.dnswl.org] + -0.0 SPF_PASS SPF: sender matches SPF record + 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record + 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider (david.abdurachmanov[at]gmail.com) + 0.1 DKIM_SIGNED Message has a DKIM or DK signature, + not necessarily + valid + -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature + -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from + author's domain + -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from + envelope-from domain +X-BeenThere: linux-riscv@lists.infradead.org +X-Mailman-Version: 2.1.29 +Precedence: list +List-Id: +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Cc: david.abdurachmanov@gmail.com +Sender: "linux-riscv" +Errors-To: + linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org + +Running "stress-ng --enosys 4 -t 20 -v" showed a large number of kernel oops +with "Unable to handle kernel paging request at virtual address" message. This +happens when enosys stressor starts testing random non-valid syscalls. + +I forgot to redirect any syscall below -1 to sys_ni_syscall. + +With the patch kernel oops messages are gone while running stress-ng enosys +stressor. + +Signed-off-by: David Abdurachmanov +Fixes: 5340627e3fe0 ("riscv: add support for SECCOMP and SECCOMP_FILTER") +--- + arch/riscv/kernel/entry.S | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S +index a1349ca64669..e163b7b64c86 100644 +--- a/arch/riscv/kernel/entry.S ++++ b/arch/riscv/kernel/entry.S +@@ -246,6 +246,7 @@ check_syscall_nr: + */ + li t1, -1 + beq a7, t1, ret_from_syscall_rejected ++ blt a7, t1, 1f + /* Call syscall */ + la s0, sys_call_table + slli t0, a7, RISCV_LGPTR diff --git a/riscv-fix-sparsemem-vmemmap.patch b/riscv-fix-sparsemem-vmemmap.patch new file mode 100644 index 000000000..48cea4179 --- /dev/null +++ b/riscv-fix-sparsemem-vmemmap.patch @@ -0,0 +1,213 @@ +From patchwork Wed Dec 18 08:28:11 2019 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: David Abdurachmanov +X-Patchwork-Id: 11299899 +Return-Path: + +Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org + [172.30.200.123]) + by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF5576C1 + for ; + Wed, 18 Dec 2019 08:28:28 +0000 (UTC) +Received: from bombadil.infradead.org (bombadil.infradead.org + [198.137.202.133]) + (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) + (No client certificate requested) + by mail.kernel.org (Postfix) with ESMTPS id CC5A620717 + for ; + Wed, 18 Dec 2019 08:28:28 +0000 (UTC) +Authentication-Results: mail.kernel.org; + dkim=pass (2048-bit key) header.d=lists.infradead.org + header.i=@lists.infradead.org header.b="SdZ1R67c"; + dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com + header.b="Lp1KSgZ6" +DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC5A620717 +Authentication-Results: mail.kernel.org; + dmarc=fail (p=none dis=none) header.from=gmail.com +Authentication-Results: mail.kernel.org; + spf=none + smtp.mailfrom=linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org +DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; + d=lists.infradead.org; s=bombadil.20170209; h=Sender:Cc:List-Subscribe: + List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: + Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:To:From: + Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: + Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: + List-Owner; bh=yMJjOAhIzheu14B4aOvGzeJWtYIQ1QEezPPz+lKiEmE=; b=SdZ1R67ccpMerI + VXstQNP7XbJS1wN4lM8ktTI2nVEbKuPwPvJ5Zwu3uL22lOCgM5tupnWntuhDoehy5pJ4mQJQbJ/lk + Wdpq1YuQMEDCiFK5HnIk5cwGmSIiVoOmnlNluXy87O2xUncAEZe9eL4cg82luT4/Qs74/8t4zwsP4 + s6VLHefzBkw/UNnIre0uWke6m/PBgWxFZyauXZRrPEwtvlsJm4Hmh164TlNIL7c0VHBsstQLWowMs + VEWV4O+yVAhaJZQIbwXrldynQNvQQHIN9pOwmaj3k6P15Z1ryStTQURXl8elURX3lnbE8ALfQ/e66 + hr6QRo2mudUXkcRgg9kg==; +Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) + by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) + id 1ihUh1-00072Q-4P; Wed, 18 Dec 2019 08:28:27 +0000 +Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) + by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) + id 1ihUgy-00071z-05 + for linux-riscv@lists.infradead.org; Wed, 18 Dec 2019 08:28:25 +0000 +Received: by mail-wr1-x441.google.com with SMTP id y17so1255160wrh.5 + for ; Wed, 18 Dec 2019 00:28:23 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; + h=from:to:cc:subject:date:message-id:mime-version + :content-transfer-encoding; + bh=yMJjOAhIzheu14B4aOvGzeJWtYIQ1QEezPPz+lKiEmE=; + b=Lp1KSgZ6INSYA5JSybOiENZq20hSCbKyoto/I24wVBb9/7qnO7zYlauk/WO2Z3tlLw + MAZ77NiEZCoKXUFBkIlh0d/FMyRUQl0vadGHWJzySQOEqYPZUBl41NU9JPeKcN3yqn7r + E1XZjGTpYA583Dw4d8X5Pq41EqRVvTTOWhmQ2N2MLn8KUETtRAWKlxYXsDIG105vFlp4 + cIkhLSp9B6wt6oiYzr+mYnO+qcHHrUNz0VuDfsj5znzwj7qifVWHl8ae43M/Bdd8+41K + dwm2W03a3As+A3UM7DMhkHsmlw0AT3PcxXoYpBf0ZbkbGZtt43r/2Mka7asYsi6T4dDp + j/yw== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20161025; + h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version + :content-transfer-encoding; + bh=yMJjOAhIzheu14B4aOvGzeJWtYIQ1QEezPPz+lKiEmE=; + b=pzOGRdPUCjpRL2ZA8+frHdiOdYSdxr/XKe+AJmro0hHQZsm6FVdg7HLRX5PzuXnxkF + 6Tx1XgOETDlubI6k/3vZSjqG09cJrqxn8T6Q81aDmQxtJQgauGOwXJ3mFVnf171EfLkA + 1YW3To34j0VkIHgTjLftnMMr1dVo5uRNI5gMZFMEaZh90bMUFxULVO64TCm0jXO6MmsY + Xych7Gy237eW+oAcAduWo+EWqQjYnGeQRxlU6WVCcP5qo2MBN9fvwW4H1W36m5H/F4/j + KJ24tiDgxjbdAogMaJmGj8LKaO9/yVQ/qncH4IYW0fECu1jWiGsNipiaUkf/pobK2l6i + L3dQ== +X-Gm-Message-State: APjAAAXx6Kjsq9rgfc17iUAYqFcpYHxCOtYmkK0ng2E/ZepiFbt9vwtL + i4si1g6vKifpgKFsrU1ZWdZd2/CFFvo= +X-Google-Smtp-Source: + APXvYqz2hPmvQA+b5bhpb/9dzuG9/IQOYezjagYgbzpVHXDchyUxdy2KJFxpptGjOdA6bt8fP/Q/TQ== +X-Received: by 2002:a5d:608a:: with SMTP id w10mr1268616wrt.136.1576657702457; + Wed, 18 Dec 2019 00:28:22 -0800 (PST) +Received: from localhost.localdomain (78-63-27-146.static.zebra.lt. + [78.63.27.146]) + by smtp.gmail.com with ESMTPSA id o4sm1683699wrx.25.2019.12.18.00.28.20 + (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); + Wed, 18 Dec 2019 00:28:21 -0800 (PST) +From: David Abdurachmanov +X-Google-Original-From: David Abdurachmanov +To: Paul Walmsley , + Palmer Dabbelt , Albert Ou , + Anup Patel , Mike Rapoport , + Greentime Hu , + David Abdurachmanov , + "Stefan O'Rear" , Yash Shah , + Logan Gunthorpe , + Thomas Gleixner , linux-riscv@lists.infradead.org, + linux-kernel@vger.kernel.org +Subject: [PATCH v2] define vmemmap before pfn_to_page calls +Date: Wed, 18 Dec 2019 10:28:11 +0200 +Message-Id: <20191218082814.895851-1-david.abdurachmanov@sifive.com> +X-Mailer: git-send-email 2.24.1 +MIME-Version: 1.0 +X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 +X-CRM114-CacheID: sfid-20191218_002824_067174_8F1FFA3C +X-CRM114-Status: GOOD ( 10.29 ) +X-Spam-Score: -0.2 (/) +X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: + Content analysis details: (-0.2 points) + pts rule name description + ---- ---------------------- + -------------------------------------------------- + -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, + no trust [2a00:1450:4864:20:0:0:0:441 listed in] + [list.dnswl.org] + -0.0 SPF_PASS SPF: sender matches SPF record + 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record + 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider (david.abdurachmanov[at]gmail.com) + 0.1 DKIM_SIGNED Message has a DKIM or DK signature, + not necessarily + valid + -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature + -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from + author's domain + -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from + envelope-from domain +X-BeenThere: linux-riscv@lists.infradead.org +X-Mailman-Version: 2.1.29 +Precedence: list +List-Id: +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Cc: david.abdurachmanov@gmail.com +Sender: "linux-riscv" +Errors-To: + linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org + +pfn_to_page & page_to_pfn depend on vmemmap being available before the calls +if kernel is configured with CONFIG_SPARSEMEM_VMEMMAP=y. This was caused +by NOMMU changes which moved vmemmap definition bellow functions definitions +calling pfn_to_page & page_to_pfn. + +Noticed while compiled 5.5-rc2 kernel for Fedora/RISCV. + +v2: +- Add a comment for vmemmap in source + +Signed-off-by: David Abdurachmanov +Fixes: 6bd33e1ece52 ("riscv: add nommu support") +Reviewed-by: Anup Patel +--- + arch/riscv/include/asm/pgtable.h | 38 ++++++++++++++++++-------------- + 1 file changed, 21 insertions(+), 17 deletions(-) + +diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h +index 7ff0ed4f292e..36ae01761352 100644 +--- a/arch/riscv/include/asm/pgtable.h ++++ b/arch/riscv/include/asm/pgtable.h +@@ -90,6 +90,27 @@ extern pgd_t swapper_pg_dir[]; + #define __S110 PAGE_SHARED_EXEC + #define __S111 PAGE_SHARED_EXEC + ++#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) ++#define VMALLOC_END (PAGE_OFFSET - 1) ++#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) ++ ++/* ++ * Roughly size the vmemmap space to be large enough to fit enough ++ * struct pages to map half the virtual address space. Then ++ * position vmemmap directly below the VMALLOC region. ++ */ ++#define VMEMMAP_SHIFT \ ++ (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT) ++#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT) ++#define VMEMMAP_END (VMALLOC_START - 1) ++#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) ++ ++/* ++ * Define vmemmap for pfn_to_page & page_to_pfn calls. Needed if kernel ++ * is configured with CONFIG_SPARSEMEM_VMEMMAP enabled. ++ */ ++#define vmemmap ((struct page *)VMEMMAP_START) ++ + static inline int pmd_present(pmd_t pmd) + { + return (pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROT_NONE)); +@@ -400,23 +421,6 @@ 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) +- +-/* +- * Roughly size the vmemmap space to be large enough to fit enough +- * struct pages to map half the virtual address space. Then +- * position vmemmap directly below the VMALLOC region. +- */ +-#define VMEMMAP_SHIFT \ +- (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT) +-#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT) +-#define VMEMMAP_END (VMALLOC_START - 1) +-#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) +- +-#define vmemmap ((struct page *)VMEMMAP_START) +- + #define PCI_IO_SIZE SZ_16M + #define PCI_IO_END VMEMMAP_START + #define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE)