From patchwork Sat Jul 11 03:55:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 11657665 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 EDA2F618 for ; Sat, 11 Jul 2020 04:01:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 C61632075F for ; Sat, 11 Jul 2020 04:01:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Dyt+R+YS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=dabbelt-com.20150623.gappssmtp.com header.i=@dabbelt-com.20150623.gappssmtp.com header.b="OCGtNKv0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C61632075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zAPQjnqEqjCyTgBUNuiEZYPvZg0VX9DHN9O4wQ29wpU=; b=Dyt+R+YSySgO2Bjfpol/2gkzL 0XB7DPAfkSJpFEn3DY+DtOuWMO1OR2RDDinijM2dw24iEafveCuVGo4rHtcoAGHTX9iYibIhHsJ/Q MtD/WhoZNfNB9e79O6L73RLkFyvQF31cOZf71DdMyfUq2wwpVyU3QsQMXzwj7XW7klTiiukuCMOO0 SszZPiFGAY/TJ5aRrNbm+pYEz8Nwo1dAMyQ/lxDc5qcIEjqAk0jqt+exCSR66bJusvJL4o2n3yccU PCsEVloJb8iSO/6asaivtNiJLUpY0xsb9fEKQzYQE+f81FKp3K9LNQoeDsTouCUWOA4/mTVfve9hP EPhxY3/dQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ju6fh-0001Zk-ND; Sat, 11 Jul 2020 03:59:29 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ju6fa-0001Tx-Rs for linux-arm-kernel@lists.infradead.org; Sat, 11 Jul 2020 03:59:24 +0000 Received: by mail-pj1-x1044.google.com with SMTP id f16so3441005pjt.0 for ; Fri, 10 Jul 2020 20:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:cc:from:to; bh=P9MdyjVmHGjCLFd0myvGNT7BnRX3ygM0xdoKm/Ke/yY=; b=OCGtNKv0K4oDex1LzcuU+H5ZX76sTLShGnUcL9b36TQHeg3xbV6WkQgdMY9YVcpQ5i M8uXX+kjRjByWZNr8CgbQkEvnu3xP9SjNb5qMqTnjgiynqfGtrHJKMTGWTp4WZiYZ8Um zfwDpSnA6sFHCy6wMJYCreoMknhufE+qPeTdXneRp1mUWyOtqrofcJf/ZJrlTvBJ5LE/ vuV9MfwJ+USJ8aIBta8yKYbf/tC02W3Eho0XKDqWMgqgxgSS2N3uwcKPFFJLC/TFLKGt lv4cVafzWSoDTps9H7QoWxLaxybqJJxK1KnfFQwN+tG/gvV7wCENPgacFK/3lUfb6Sq4 UUxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:cc:from:to; bh=P9MdyjVmHGjCLFd0myvGNT7BnRX3ygM0xdoKm/Ke/yY=; b=Uv5OkqsLqgqKnAPjllPaDb5h+xBNaxr8nPJquAho365ekEkZw+PR30uenupGmzJEi2 gpuKKxCiw8VtXh2w7+7xK5Vu8q8+l/Ff0CCWZw5GNOOGSWYZ7YwI6npVcr/sbuhBOndc oMoag3sdwH6z6JhrWsd/sWwMx5Jf+Q/BJ2cMU9PIn1C7P/a17AzdRGF9WGmSxFHdr+rb KJNTPlffMH4L9w8yNOtOtu031Rp42u1gcFQSs1+i7qINZkH0jAlSQgyp2hIx874dEAax LyS3bQ3BhgFcEsVpBMnXVwUTLHzNU96951/KHu+mYsSU7JO7P4xq0LR8F5GN0tJkVF9b Wcog== X-Gm-Message-State: AOAM532ekdhgmwYN8g07+T3nVT65OKjLqzLnrHb71ggWsKB+xShwtDDF jdmvoVUMz3OEOOgdmmlf/FVYBw== X-Google-Smtp-Source: ABdhPJwxW+RayJdKkQ+JS7dT23gKNMK/oVXiknZXTWv/h3U+LQOqYbYRHyKYc4j42/P36M4Hzv2Mdg== X-Received: by 2002:a17:902:b084:: with SMTP id p4mr37584442plr.58.1594439960312; Fri, 10 Jul 2020 20:59:20 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id bx18sm7168249pjb.49.2020.07.10.20.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 20:59:19 -0700 (PDT) Subject: [PATCH 1/3] lib: Add a generic copy_oldmem_page() Date: Fri, 10 Jul 2020 20:55:42 -0700 Message-Id: <20200711035544.2832154-2-palmer@dabbelt.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog In-Reply-To: <20200711035544.2832154-1-palmer@dabbelt.com> References: <20200711035544.2832154-1-palmer@dabbelt.com> MIME-Version: 1.0 From: Palmer Dabbelt To: mick@ics.forth.gr X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200710_235923_095182_46A4D800 X-CRM114-Status: GOOD ( 22.89 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, gregory.0xf0@gmail.com, peterz@infradead.org, catalin.marinas@arm.com, linus.walleij@linaro.org, Palmer Dabbelt , brendanhiggins@google.com, elver@google.com, glider@google.com, krzk@kernel.org, mchehab+samsung@kernel.org, will@kernel.org, mingo@kernel.org, uwe@kleine-koenig.org, takahiro.akashi@linaro.org, paulmck@kernel.org, masahiroy@kernel.org, linux@armlinux.org.uk, willy@infradead.org, rppt@linux.ibm.com, bgolaszewski@baylibre.com, kernel-team@android.com, pmladek@suse.com, zaslonko@linux.ibm.com, keescook@chromium.org, Arnd Bergmann , broonie@kernel.org, matti.vaittinen@fi.rohmeurope.com, ben-linux@fluff.org, dan.j.williams@intel.com, linux-arm-kernel@lists.infradead.org, davidgow@google.com, rdunlap@infradead.org, Nick Desaulniers , linux-kernel@vger.kernel.org, mhiramat@kernel.org, ardb@kernel.org, akpm@linux-foundation.org, davem@davemloft.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Palmer Dabbelt A version of this that is identical to the arm64 version was recently copied into the RISC-V port while adding kexec() support. Instead I'd like to put a shared copy in lib/ and use it from the various ports. Signed-off-by: Palmer Dabbelt --- lib/Kconfig | 3 +++ lib/Makefile | 2 ++ lib/copy_oldmem_page.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 lib/copy_oldmem_page.c diff --git a/lib/Kconfig b/lib/Kconfig index df3f3da95990..25544abc9547 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -676,3 +676,6 @@ config GENERIC_LIB_CMPDI2 config GENERIC_LIB_UCMPDI2 bool + +config GENERIC_LIB_COPY_OLDMEM_PAGE + bool diff --git a/lib/Makefile b/lib/Makefile index b1c42c10073b..30d57d8b32b1 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -318,3 +318,5 @@ obj-$(CONFIG_OBJAGG) += objagg.o # KUnit tests obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o + +obj-$(CONFIG_GENERIC_LIB_COPY_OLDMEM_PAGE) += copy_oldmem_page.o diff --git a/lib/copy_oldmem_page.c b/lib/copy_oldmem_page.c new file mode 100644 index 000000000000..f0090027218a --- /dev/null +++ b/lib/copy_oldmem_page.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Routines for doing kexec-based kdump + * + * Originally part of arch/arm64/kernel/crash_dump.c + * Copyright (C) 2017 Linaro Limited + * Author: AKASHI Takahiro + */ + +#include +#include +#include + +/** + * copy_oldmem_page() - copy one page from old kernel memory + * @pfn: page frame number to be copied + * @buf: buffer where the copied page is placed + * @csize: number of bytes to copy + * @offset: offset in bytes into the page + * @userbuf: if set, @buf is in a user address space + * + * This function copies one page from old kernel memory into buffer pointed by + * @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes + * copied or negative error in case of failure. + */ +ssize_t copy_oldmem_page(unsigned long pfn, char *buf, + size_t csize, unsigned long offset, + int userbuf) +{ + void *vaddr; + + if (!csize) + return 0; + + vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB); + if (!vaddr) + return -ENOMEM; + + if (userbuf) { + if (copy_to_user((char __user *)buf, vaddr + offset, csize)) { + memunmap(vaddr); + return -EFAULT; + } + } else { + memcpy(buf, vaddr + offset, csize); + } + + memunmap(vaddr); + + return csize; +} From patchwork Sat Jul 11 03:55:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 11657661 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 9C29613B1 for ; Sat, 11 Jul 2020 04:01:16 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 74CB42075F for ; Sat, 11 Jul 2020 04:01:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WVAFkfsS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=dabbelt-com.20150623.gappssmtp.com header.i=@dabbelt-com.20150623.gappssmtp.com header.b="Dzt/iMd0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74CB42075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=96T74Dl/nfpz1SFOctNgylfj4H8B1FwARe0TiAGmkyI=; b=WVAFkfsSMssK7pU55uuJVstEk 08TnBFQVpwO8UatRJ88BIuzADzr0q/+/c3PtC8kqSFx79/mCpKoC7wz0VjJ/DRL8ocSKav4EKDv7+ rlp6D7Bf2QDLmGUKkGHhPmoMM8XIYk013hL73ogw3ezl5tREENKtqCEN4zJBskTrbW9UbfRinfEXX LudyEoUPDgOQ2keo0Diw3Mj63BqSYtqeityiSVytHDKlgC+8DF7nD0+TWWUreLzuAU2c0HC9zxt4T +COU9hEO+KALkGkhGQIxsOnkklAvAtSvCmdVaiZj85yAlqRsboErAzXtqTer/8aCwPIR9kEqQueMi AjQxf/swg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ju6fm-0001b2-Pz; Sat, 11 Jul 2020 03:59:34 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ju6fb-0001Um-KA for linux-arm-kernel@lists.infradead.org; Sat, 11 Jul 2020 03:59:28 +0000 Received: by mail-pj1-x1044.google.com with SMTP id b92so3432637pjc.4 for ; Fri, 10 Jul 2020 20:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:cc:from:to; bh=wantLvKFQ7sTWJpeW6b72Xahd71W/Sz84V8SEQBvlmI=; b=Dzt/iMd0Hum1aoS+SHRvQmVGrLKShehT79ai0Ryv1Ow+zSH+jbU0jjwYtZpVk67aiV 1HiQkGeRmLeAWouzpK1njvMU2hi9+aOIhncWTl6oQ+CiXqBFME3Tc+7U9VAWwS72ayBO i4/YP6ES0V92NTI30DjTMpG9aSkH+3JhVVkmxvDnnaNIIPtpvjyArJAnu4W+RkJ4veM8 PIn/5mchWUuc/cp8woLUw2vYx4IlJ21mUQrd3f74UNhii/G8w9nQ90zOGCgF8ZZJLRaW 116tQlsVrG9tfuLFIQGA+Kt9aGH+2nCXkDBm44G01dcOxh5CZ4GyVHQ6fAxIVPBEg+qo Icug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:cc:from:to; bh=wantLvKFQ7sTWJpeW6b72Xahd71W/Sz84V8SEQBvlmI=; b=bcqMFjXDA1g92cd4r+gbOCrgi1ElTzeEPGGIipxMGek/1GwaTevfdxgkvNCXVgxEsp vm9czKaCq8OQh2XmVkLLY+FL13STUr9oo/ltZ0YQ0LmT41tHmMIHEZDmnUjxcdqPB8F5 5hf1WWuQS8cOw0rlnaQlr7fa2edQYLGbGWG/+Dg0UcqH0OKNKUm6lPymptdJa7A58vLu /9IKQzP9harCV8lTLGVXCRF4iRXbT596yKmpkG5+cOsXxaiMpfaJGz6hYgFnDfTJWDUk HMj3wt3qrIzPQoRwKpY/dBuD06uW0fF9Iv+Xuzwnj+F9x6axzUx/XlXUCagpoWTWJ34M JlXA== X-Gm-Message-State: AOAM530AFgD8ZRcRXa8gTA0Tn1laFSpddhU0IGjDB2ZNFFZhF3f5qU/l B4fI2XsKu/mVmfuUjmoar7gN+Q== X-Google-Smtp-Source: ABdhPJx/QGm0euUPP1vS4ZGSr12gxaH7Z/02J8eMRGjwMOHJlhMMz4ZQIbxP9ubJpQt+MkD/3WtArg== X-Received: by 2002:a17:902:bb96:: with SMTP id m22mr5383732pls.6.1594439961667; Fri, 10 Jul 2020 20:59:21 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id q24sm7718285pfg.34.2020.07.10.20.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 20:59:21 -0700 (PDT) Subject: [PATCH 2/3] arm: Use the new generic copy_oldmem_page() Date: Fri, 10 Jul 2020 20:55:43 -0700 Message-Id: <20200711035544.2832154-3-palmer@dabbelt.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog In-Reply-To: <20200711035544.2832154-1-palmer@dabbelt.com> References: <20200711035544.2832154-1-palmer@dabbelt.com> MIME-Version: 1.0 From: Palmer Dabbelt To: mick@ics.forth.gr X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200710_235923_738333_7E748135 X-CRM114-Status: GOOD ( 19.85 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, gregory.0xf0@gmail.com, peterz@infradead.org, catalin.marinas@arm.com, linus.walleij@linaro.org, Palmer Dabbelt , brendanhiggins@google.com, elver@google.com, glider@google.com, krzk@kernel.org, mchehab+samsung@kernel.org, will@kernel.org, mingo@kernel.org, uwe@kleine-koenig.org, takahiro.akashi@linaro.org, paulmck@kernel.org, masahiroy@kernel.org, linux@armlinux.org.uk, willy@infradead.org, rppt@linux.ibm.com, bgolaszewski@baylibre.com, kernel-team@android.com, pmladek@suse.com, zaslonko@linux.ibm.com, keescook@chromium.org, Arnd Bergmann , broonie@kernel.org, matti.vaittinen@fi.rohmeurope.com, ben-linux@fluff.org, dan.j.williams@intel.com, linux-arm-kernel@lists.infradead.org, davidgow@google.com, rdunlap@infradead.org, Nick Desaulniers , linux-kernel@vger.kernel.org, mhiramat@kernel.org, ardb@kernel.org, akpm@linux-foundation.org, davem@davemloft.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Palmer Dabbelt This is exactly the same as the arm64 code, which I just into lib/ to avoid copying it into the RISC-V port. This builds with defconfig and with CRASH_DUMP=y. Signed-off-by: Palmer Dabbelt Reviewed-by: Linus Walleij --- arch/arm/Kconfig | 1 + arch/arm/kernel/Makefile | 1 - arch/arm/kernel/crash_dump.c | 54 ------------------------------------ 3 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 arch/arm/kernel/crash_dump.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2ac74904a3ce..dfbeb14e9673 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1933,6 +1933,7 @@ config ATAGS_PROC config CRASH_DUMP bool "Build kdump crash kernel (EXPERIMENTAL)" + select GENERIC_LIB_COPY_OLDMEM_PAGE help Generate crash dump after being started by kexec. This should be normally only set in special crash dump kernels which are diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 89e5d864e923..b5310a90dfe4 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -65,7 +65,6 @@ obj-$(CONFIG_KGDB) += kgdb.o patch.o obj-$(CONFIG_ARM_UNWIND) += unwind.o obj-$(CONFIG_HAVE_TCM) += tcm.o obj-$(CONFIG_OF) += devtree.o -obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_SWP_EMULATE) += swp_emulate.o CFLAGS_swp_emulate.o := -Wa,-march=armv7-a obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o diff --git a/arch/arm/kernel/crash_dump.c b/arch/arm/kernel/crash_dump.c deleted file mode 100644 index 53cb92435392..000000000000 --- a/arch/arm/kernel/crash_dump.c +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * arch/arm/kernel/crash_dump.c - * - * Copyright (C) 2010 Nokia Corporation. - * Author: Mika Westerberg - * - * This code is taken from arch/x86/kernel/crash_dump_64.c - * Created by: Hariprasad Nellitheertha (hari@in.ibm.com) - * Copyright (C) IBM Corporation, 2004. All rights reserved - */ - -#include -#include -#include -#include - -/** - * copy_oldmem_page() - copy one page from old kernel memory - * @pfn: page frame number to be copied - * @buf: buffer where the copied page is placed - * @csize: number of bytes to copy - * @offset: offset in bytes into the page - * @userbuf: if set, @buf is int he user address space - * - * This function copies one page from old kernel memory into buffer pointed by - * @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes - * copied or negative error in case of failure. - */ -ssize_t copy_oldmem_page(unsigned long pfn, char *buf, - size_t csize, unsigned long offset, - int userbuf) -{ - void *vaddr; - - if (!csize) - return 0; - - vaddr = ioremap(__pfn_to_phys(pfn), PAGE_SIZE); - if (!vaddr) - return -ENOMEM; - - if (userbuf) { - if (copy_to_user(buf, vaddr + offset, csize)) { - iounmap(vaddr); - return -EFAULT; - } - } else { - memcpy(buf, vaddr + offset, csize); - } - - iounmap(vaddr); - return csize; -} From patchwork Sat Jul 11 03:55:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 11657663 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 057ED618 for ; Sat, 11 Jul 2020 04:01:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 D38402075F for ; Sat, 11 Jul 2020 04:01:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0A89Viy7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=dabbelt-com.20150623.gappssmtp.com header.i=@dabbelt-com.20150623.gappssmtp.com header.b="tQOPOFgt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D38402075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9mNticA2oDkdgCo6QZTRdScyN+n8T6VocXLf9p5BOfs=; b=0A89Viy7qfiMBCSQw7L6THg9t 3mS/fhP9xXaVMqQSuYXZ5c/s9reF3Zujoz+yLlSw0j2l44G9WMNMPE3wqMjdCRUEJDk/qmkoxPdbS bMW3J9Qiay/pUxM68ErKmm36Jj4xpHIZLsBNJqd3AXdmIv3HCjG0qQferfpjHDA3CEpThKxLwtd7D Ze7UToe6jvSOCjTpbWl0MPWi+t06VOEpk3azeIdVs0+TEDn2F6zQvKq2ETlF+8s8xLNcGyOgxidqU typ26ZcyUnCzCtZSHyh0rv4TqwfqPwRJHAm1Sw+oMZd9XZJ5fVQ5hSHSnJ2xqyQBbyec20Ot7yaOt xenR1Gzhw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ju6fo-0001bK-JV; Sat, 11 Jul 2020 03:59:36 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ju6fd-0001XG-2O for linux-arm-kernel@lists.infradead.org; Sat, 11 Jul 2020 03:59:31 +0000 Received: by mail-pg1-x541.google.com with SMTP id l63so3375539pge.12 for ; Fri, 10 Jul 2020 20:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:cc:from:to; bh=Wf2KClM6Tk5kmhkj4X2FnIK/p9JJMcXyJrf5eWEAU70=; b=tQOPOFgtewhe4q5nXYz43DV8Ob8tcit3pVPeQ5TjI8XCSGeWy0QqpfT1poT6OTp9qZ YjFz2pfaGqF7Im0Xa0etUyPumohyomrxVS6dAiZjGplSskgBqcJ0W4i3tH4EqmgTAuLI ray0SmDHhfL0JbGHQmiGEkARHu/0ZLfEjKmfczdYDEi+Tcg619FSyL6RkdvSs0W+Wimc egdq14P+9oRqZeBP0QFzd73I+cTpaCrwB0w8T86McEFZgKrVKr43mtk2lMzhnGnCOlot mGekL5N/WGkfxCgmTsZV1BlX/R4q2iZ1fZuZTMXA02bsAG5A6A+6o11l/VbpxUFuQpn8 OU5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:cc:from:to; bh=Wf2KClM6Tk5kmhkj4X2FnIK/p9JJMcXyJrf5eWEAU70=; b=BKmsJfIBVS167docqNOl8BGrVIeM9efZsHbAzolKOViqAeEWH+blu1n0zejpv52A4b uhM/2I8Uzi1oMg4Mjfm+J1toE/dB+5kXxzmqBSXyfEAKmikoDRhTb0pqYJ2emnXE5t1t TpAp4M0GRIu6vWI9FQo9n+LiVla3CSvhr/o28lkzj9Ferta0O1Qj/Ibs3MdbbQ4rd39u ccqfoSJusYr4UMrL0FHaStHbYnUHp02SdPJ+E0W/JX/y1eybpMuuOvLubx8rKlgKPQJA OW6LNojcCpJI1Thf+hZbUc6wPemkhk8Hgsr9L3YSYCDaSf1VU6ZAOrZ0fwdvWHQmvlhn ZWdQ== X-Gm-Message-State: AOAM531yXbleHTS5SnbdE/SzpbJPKqy4R35873gDxA2SmAcA2Nl4oFEM RgnC7h0nZjbZfUOvFXTG0qHYlw== X-Google-Smtp-Source: ABdhPJzMofsLQD9Z2uTdicmms83eUcQQbTxAg1eUW9k4rQlfm5rNXPzgR+F3lg7A+gscikb7UdwrtQ== X-Received: by 2002:aa7:9ec5:: with SMTP id r5mr17529907pfq.86.1594439963157; Fri, 10 Jul 2020 20:59:23 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id j17sm6811709pgn.87.2020.07.10.20.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 20:59:22 -0700 (PDT) Subject: [PATCH 3/3] arm64: Use the new generic copy_oldmem_page() Date: Fri, 10 Jul 2020 20:55:44 -0700 Message-Id: <20200711035544.2832154-4-palmer@dabbelt.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog In-Reply-To: <20200711035544.2832154-1-palmer@dabbelt.com> References: <20200711035544.2832154-1-palmer@dabbelt.com> MIME-Version: 1.0 From: Palmer Dabbelt To: mick@ics.forth.gr X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200710_235925_201456_265A18B1 X-CRM114-Status: GOOD ( 18.52 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, gregory.0xf0@gmail.com, peterz@infradead.org, catalin.marinas@arm.com, linus.walleij@linaro.org, Palmer Dabbelt , brendanhiggins@google.com, elver@google.com, glider@google.com, krzk@kernel.org, mchehab+samsung@kernel.org, will@kernel.org, mingo@kernel.org, uwe@kleine-koenig.org, takahiro.akashi@linaro.org, paulmck@kernel.org, masahiroy@kernel.org, linux@armlinux.org.uk, willy@infradead.org, rppt@linux.ibm.com, bgolaszewski@baylibre.com, kernel-team@android.com, pmladek@suse.com, zaslonko@linux.ibm.com, keescook@chromium.org, Arnd Bergmann , broonie@kernel.org, matti.vaittinen@fi.rohmeurope.com, ben-linux@fluff.org, dan.j.williams@intel.com, linux-arm-kernel@lists.infradead.org, davidgow@google.com, rdunlap@infradead.org, Nick Desaulniers , linux-kernel@vger.kernel.org, mhiramat@kernel.org, ardb@kernel.org, akpm@linux-foundation.org, davem@davemloft.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Palmer Dabbelt This is exactly the same as the arm64 code, which I just into lib/ to avoid copying it into the RISC-V port. This builds with defconfig. Signed-off-by: Palmer Dabbelt Acked-by: Catalin Marinas --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/crash_dump.c | 39 ---------------------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 66dc41fd49f2..55b27d56b163 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1109,6 +1109,7 @@ comment "Support for PE file signature verification disabled" config CRASH_DUMP bool "Build kdump crash kernel" + select GENERIC_LIB_COPY_OLDMEM_PAGE help Generate crash dump after being started by kexec. This should be normally only set in special crash dump kernels which are diff --git a/arch/arm64/kernel/crash_dump.c b/arch/arm64/kernel/crash_dump.c index e6e284265f19..197b92c249ba 100644 --- a/arch/arm64/kernel/crash_dump.c +++ b/arch/arm64/kernel/crash_dump.c @@ -13,45 +13,6 @@ #include #include -/** - * copy_oldmem_page() - copy one page from old kernel memory - * @pfn: page frame number to be copied - * @buf: buffer where the copied page is placed - * @csize: number of bytes to copy - * @offset: offset in bytes into the page - * @userbuf: if set, @buf is in a user address space - * - * This function copies one page from old kernel memory into buffer pointed by - * @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes - * copied or negative error in case of failure. - */ -ssize_t copy_oldmem_page(unsigned long pfn, char *buf, - size_t csize, unsigned long offset, - int userbuf) -{ - void *vaddr; - - if (!csize) - return 0; - - vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB); - if (!vaddr) - return -ENOMEM; - - if (userbuf) { - if (copy_to_user((char __user *)buf, vaddr + offset, csize)) { - memunmap(vaddr); - return -EFAULT; - } - } else { - memcpy(buf, vaddr + offset, csize); - } - - memunmap(vaddr); - - return csize; -} - /** * elfcorehdr_read - read from ELF core header * @buf: buffer where the data is placed