From patchwork Wed Feb 13 17:46:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10810531 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 299556C2 for ; Wed, 13 Feb 2019 17:46:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 141F32DA44 for ; Wed, 13 Feb 2019 17:46:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07A0A2DC12; Wed, 13 Feb 2019 17:46: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 A38712DA44 for ; Wed, 13 Feb 2019 17:46:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F2E78E0001; Wed, 13 Feb 2019 12:46:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6CAEE8E0002; Wed, 13 Feb 2019 12:46:38 -0500 (EST) 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 5B8508E0001; Wed, 13 Feb 2019 12:46:38 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 0ED408E0002 for ; Wed, 13 Feb 2019 12:46:38 -0500 (EST) Received: by mail-pl1-f199.google.com with SMTP id b4so2203854plb.9 for ; Wed, 13 Feb 2019 09:46:38 -0800 (PST) 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=EqKUxXuSonkTTvkNlEundh14K2DWfFZ464FMZZAxl7E=; b=jqkqhSDwf2CVBKDbUw7GZai0Yf0u2RhpKCAs3xWKXFnt97GFRF/zmtoEs8vNp9V7lt VfqqfHM9mccwbladE7GXn8Ns/1wwiWFEG5CPX/F9jE1/91DppZ61WLg7JN/LBWMZhGCA Ptd7f+mpKs6DijkwIUZusStPqFPVGZ4MS8kjFgUh7m5OW29u5V9GhAD03ACPUtaw0MkN HBqJC3ZGELjRKIaHco9UdWNTM64dd67giM8JowFDNOovk+EfV0yHMpwni/jTEl6RfL6o xibJy1uDOd8LdIQRnI1ewh6y3ITpvYXDCzf1mGBryFGQY8g/NAiDdPS4dmoH0qIMUZVh zdHw== X-Gm-Message-State: AHQUAubFRO4yFPnSRQaPicGXutA8wkmb1fH8/cAa1k0KPWSR9g0aV7pK vuPyPAtj8mU40eUxf1v4FyjnTKQWFVGijTlc4YEA1BK7uVT4kYzK1L/krOCKbsukINPiP7mRSHI /LBjRMo6Qc3guuHGTapdVGLqUGZ0j51mZpvByLI3R9z1VfrJQhB+DmvvuPj2bFfI= X-Received: by 2002:a63:730c:: with SMTP id o12mr1515112pgc.270.1550079997661; Wed, 13 Feb 2019 09:46:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IYrvCgzMiuq4+XYVfuXqJoq+I1LBayaSeqqkrUk7MfgJL1yNu7wuryEX2T5yrGi5o6Zf4gF X-Received: by 2002:a63:730c:: with SMTP id o12mr1515073pgc.270.1550079997009; Wed, 13 Feb 2019 09:46:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550079997; cv=none; d=google.com; s=arc-20160816; b=oTRcWyTMBb2G1Rwc03YrN1bUn1D0Gci38nuw2ycRHtu6pk47NMY9GnN/sE8QljDckB NvPBEtVYKBtzOHgPJ0/EILALoicUeR4s6QLNB2DZfBVymqklF7KRhGQ80bNP6ZIT5JcE Uy796tQCqK0M6vz+AcKTewwpPEhhraxwtIkxS61fly9/p3f36EDuRZ2cxRjA8edTPT9b 9cfj1Q4KYVuO081Ap2iSVbi0+VA57a6F3TMJY3iGeQHukQBs5e2et7lETX9ff4SSmazn dycsrLUYE3mi+SnQeFCG+DI5M9INzLXy6v4hir+LMFf/DiyviiI/kMcTM2yfRUkgsoPt f6gA== 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=EqKUxXuSonkTTvkNlEundh14K2DWfFZ464FMZZAxl7E=; b=zQY7tp1gVl9ZtOl+fJdctGwFpL4sMizNndgptfMq6Fmg9q153QyQP6fSsN9aR5hAhi 4tbmAh3Z1xKfWDgSU1wyQBXvhm80mnb2BgHK5Gk029DN/+XU7O/0a/lDhjowggrzM5BP gs4l5YmlN4U6a9Uo5NGdtQuJ+YH1tj3s+ESxkJNUxFLsLNK2SrVYg8URsUAaGQztrywA RfZ0vh66y94ENmr0ElRKvj8Yo6GK3q3w2SVKGJVHECa0cO8pYXJM16BPV5fcyIcrDf5K 28z6mzPEDFZqxs07kGZrHgtGtC1kLMXD6gG/WXmWRZssVr9mstOmtLruK7HP98r+1Y+B Pbhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=THQG++2+; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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 s123si9221148pfb.274.2019.02.13.09.46.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 09:46:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+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=THQG++2+; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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=EqKUxXuSonkTTvkNlEundh14K2DWfFZ464FMZZAxl7E=; b=THQG++2+MpmCSvwZtsq9Qoqqqf 4pcV87lepVdvEDJawizc06v8uTJiifCdLqFWYhdT2wo4PD9BaqH6zGTNiEp4I1icDbm/v2UL84LFW I5UqL2g2H2Pl6/sv5Tsvv6pO0pe4rvW135XYLfzY8clFVkZW9YzvAZnUJvCdvHkBAOQYCJfg4ttSc 0U8FgGhAo9WR3OToYDnniks3nmuixZ9J1jvkgv2/DupTXIq1+zsvahcU2fDanry73ZPvYVSbxdwfK MO5KmpsBmOx19exAMgTEt9dwA302YaEAsaG8HnynUyR4xy7Q7WTpW5V4DB6ufo//uv7BsJw1a5yoY MWRZjbPQ==; Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtyc3-0006YY-Vg; Wed, 13 Feb 2019 17:46:24 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Alexander Viro , Russell King , Catalin Marinas , Will Deacon , Guan Xuetao , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] mm: unexport free_reserved_area Date: Wed, 13 Feb 2019 18:46:14 +0100 Message-Id: <20190213174621.29297-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213174621.29297-1-hch@lst.de> References: <20190213174621.29297-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 function is only used by built-in code, which makes perfect sense given the purpose of it. Signed-off-by: Christoph Hellwig --- mm/page_alloc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 35fdde041f5c..45f12a42709d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7255,7 +7255,6 @@ unsigned long free_reserved_area(void *start, void *end, int poison, const char return pages; } -EXPORT_SYMBOL(free_reserved_area); #ifdef CONFIG_HIGHMEM void free_highmem_page(struct page *page) From patchwork Wed Feb 13 17:46:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10810527 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 BDB7D1399 for ; Wed, 13 Feb 2019 17:46:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7CB02DA44 for ; Wed, 13 Feb 2019 17:46:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98AA72DC12; Wed, 13 Feb 2019 17:46:39 +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 341922DA44 for ; Wed, 13 Feb 2019 17:46:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 323BD8E0003; Wed, 13 Feb 2019 12:46:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2D2AB8E0001; Wed, 13 Feb 2019 12:46:38 -0500 (EST) 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 1C14D8E0003; Wed, 13 Feb 2019 12:46:38 -0500 (EST) 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 CEC268E0001 for ; Wed, 13 Feb 2019 12:46:37 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id i11so2175217pgb.8 for ; Wed, 13 Feb 2019 09:46:37 -0800 (PST) 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=F4/kzC3jhV0MG/GU79iUnwgEUzLi55LAygewrfHKenM=; b=dc0qsAfeehstPghqVXj8/4RUM+3tZcXcgMvGSs95xemVWbz5QrDgi0EnE6ibH7Ss1v brWo8tsSxOi7HOb0rQp4JLvS5aaOz2vkPtNdpoI/2MLrLm0CwHRBOlaezEUo12rQ66nN sWSaZ5ofkNrgUTJLzjacs7sSUUkUheeH5HTY4p7aDdvDAXUB9KcGFsOPsm5iXkS2PMyo OJ2p/e6E4+pFsWmZTybGXcP5+2HVimM10Qo6eXkK1/7/Pxem/w15T1TjkPnECq6neifP fmHWNHQW1IeQ7TEk6P5abHHazAm/9oOmt0C0sXPksPXAd0RAgigb+inHpXcSXxy3mqUL +zCQ== X-Gm-Message-State: AHQUAuZqkPe0hMj3E1HInGfSy3HE+3WP2OpClIHJfKnuv5/3hapMBPID +oABMnIGWFqxFjlXTyedb4kSfS1wqbLzLlrUuZYpcjuk4W/vSNHDKkcvIdinps2Y0mddX91o33B HgOw0bguIuLEADez9ReaVnjIVCaQeYQ97n1Le9zYWvRiY2bNISqlvaeE2r5BA5pU= X-Received: by 2002:a17:902:bf44:: with SMTP id u4mr1657260pls.5.1550079997319; Wed, 13 Feb 2019 09:46:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IbchJaIDQZTz71HP47iCZ61a8WuKt3qgIcEOdGhqcIzcamsEPnom4OV1PtFE8U4Lih+je0M X-Received: by 2002:a17:902:bf44:: with SMTP id u4mr1657203pls.5.1550079996668; Wed, 13 Feb 2019 09:46:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550079996; cv=none; d=google.com; s=arc-20160816; b=j4JuZgN56OdC5ZmMH4UXNBwg8sLVR6Ul/LwSvifmXwB7h9DjyN5DXKi3ozAeFcQGwK lJAMku4x7CTF2pWT2gNhhypeDBQHQMxH51ejPbyI5o7ttWdgvrTTz5aDCBL1N408Pb6q Ih3EE3kdh6H707AIP6fNyh9QaMaLIW2SmUW3vCtPm0qeLRNTU3JE+tHDZF9ppbPBKKSY mYTVCUJqVaTunHXYQZOaROku4u+Da5OtElCXO34rOiajsXCDyTO+Josb7ii1OLPPcYiz sw/6WDTMVz5jPfcr6nfKOR8yQLh4xE6nMeH19giyaffoWyAbq2QhxUcNe5QXosjNqM5R 6j3Q== 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=F4/kzC3jhV0MG/GU79iUnwgEUzLi55LAygewrfHKenM=; b=XX5qLBvQgkdg1uRjqgGxrRcZhTPdC2zqpwc21rxVU1KuvDhbUsl3AE8Y7hFYSNnc3f IYvez7Vd4uDoti0RHoGeHPMh0SgaMqYgd6RCk1snWScKylPjZo0pi+bMgI68DN6T7oqv KjtmNaMhkNDmoCCZYz8Jc7bfcW1eO4xMIDxR/ZEl8Wig5sEyFGFgfYAukKWh8yQiB0GV 1zoltfox8pDBajn8IMGM6h8O/kncHp2xc6LlBRNjZ6a+58aZ3eBfPyb13E44bOjRqKe8 Rb326wqHtBA/YVxXYVJyEWfk9W/FvX7n2Q57RoD2W+bY7kwI496kvQmXyvGdKJbDHRgR tZqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=gQxXEPxP; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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 l7si16386178plt.25.2019.02.13.09.46.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 09:46:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+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=gQxXEPxP; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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=F4/kzC3jhV0MG/GU79iUnwgEUzLi55LAygewrfHKenM=; b=gQxXEPxPM3+F0T3U4GrV1QDT1/ G8JSf7aTTJH0Wm8ThrbxnywTU+9gC3SCujimS7i+k4jV+0kYzkR9T5bE6J6qMz8R69EvvquZ+BYkC giznrEBe2MPuigbD81fsRbVr20J+tnbTCD2ElwFoZQRaBsSxAgXctZfP/N8afNaMWbw7KUg7rSgRw imGWvaU6BoLgo2suacMCl1aoWRUjEc3wL+ynJkG2OzcA1/4w/ENho5QWA85w7bGk3MwMH5GpzyUgv ndP++oI6sc5Np/qaIrkyzz5nJyTdWXsYisJPrpGx0Hv4i1uHeXZ3/u64uiafHU1uWuyMbE4k6j6Kx 1YSxWilA==; Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtyc6-0006aL-C8; Wed, 13 Feb 2019 17:46:26 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Alexander Viro , Russell King , Catalin Marinas , Will Deacon , Guan Xuetao , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] initramfs: free initrd memory if opening /initrd.image fails Date: Wed, 13 Feb 2019 18:46:15 +0100 Message-Id: <20190213174621.29297-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213174621.29297-1-hch@lst.de> References: <20190213174621.29297-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 free the initrd memory for all successful or error cases except for the case where opening /initrd.image fails, which looks like an oversight. Signed-off-by: Christoph Hellwig Reviewed-by: Steven Price --- init/initramfs.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 7cea802d00ef..1cba6bbeeb75 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -610,13 +610,12 @@ static int __init populate_rootfs(void) printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n"); err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start); - if (!err) { - free_initrd(); + if (!err) goto done; - } else { - clean_rootfs(); - unpack_to_rootfs(__initramfs_start, __initramfs_size); - } + + clean_rootfs(); + unpack_to_rootfs(__initramfs_start, __initramfs_size); + printk(KERN_INFO "rootfs image is not initramfs (%s)" "; looks like an initrd\n", err); fd = ksys_open("/initrd.image", @@ -630,7 +629,6 @@ static int __init populate_rootfs(void) written, initrd_end - initrd_start); ksys_close(fd); - free_initrd(); } done: /* empty statement */; @@ -642,9 +640,9 @@ static int __init populate_rootfs(void) printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); clean_rootfs(); } - free_initrd(); #endif } + free_initrd(); flush_delayed_fput(); return 0; } From patchwork Wed Feb 13 17:46:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10810533 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 88BD76C2 for ; Wed, 13 Feb 2019 17:46:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 728682DA44 for ; Wed, 13 Feb 2019 17:46:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 664A92DC12; Wed, 13 Feb 2019 17:46:47 +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 EF8672DA44 for ; Wed, 13 Feb 2019 17:46:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E3608E0005; Wed, 13 Feb 2019 12:46:42 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5BA688E0002; Wed, 13 Feb 2019 12:46:42 -0500 (EST) 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 45A3D8E0005; Wed, 13 Feb 2019 12:46:42 -0500 (EST) 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 064238E0002 for ; Wed, 13 Feb 2019 12:46:42 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id f5so2166496pgh.14 for ; Wed, 13 Feb 2019 09:46:41 -0800 (PST) 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=q/GsTlT+ECFpftqfq5k/mQtxX2EW5CCRqGhMzVEtitc=; b=J3EAGqKeXwZlLr2G25SqZwgx4kOIyxj0jSl/jc3Fby7/rkhzz8Mn7/M+EdZ0W4OMur 23pb/5HyzNtQt6hWCmF0xX/WNjukVjvK+xgRupq/SbD9rvw58QZok3BgE2QITJKocZan f2QeUjO6ouluhBpNaNO5u2Qu0cZ/aB8PCIb/j53Ptbey0kPCkqpYSF6RXpSNdJgXqMuX st8+7AvvHz/Q3eF0w6p5H6NRlQ1BgQdRvCF6H/10j9iLVzDHd0RcCHkqdJkqown3lZlv uPiWO07QwR9BvZKHJKWOgMp+Jz2mHh7gthHFYI3kZvl2SiVOMRm82deJMoBcMGeOFl0z Q9pA== X-Gm-Message-State: AHQUAua/TWphvFjyIvInG6qt/eo4Yt1Cs9S9Ktn2x1rshyjH/Jn5ECU+ BEpbAobLYLk0sUWbJP0kUXVUNs5ulZi8tOlCGK67UraRUBnp9jdnVR7yDnTY0MkyMMDxrsU9U++ jSfRkIGcw/mUyp1lP3sJM/EEdb/Y5YW4Gnftj2BtRSPLxbcK1oSc4dkZ/QetO3Ro= X-Received: by 2002:a17:902:7043:: with SMTP id h3mr1622202plt.213.1550080001669; Wed, 13 Feb 2019 09:46:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IbCR5p8XUH4RENIx+IQjogefsHS6LSPpIErlKwb54K+BQoaA0IfpqgPrnNQddTFyIyofpqi X-Received: by 2002:a17:902:7043:: with SMTP id h3mr1622149plt.213.1550080000935; Wed, 13 Feb 2019 09:46:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550080000; cv=none; d=google.com; s=arc-20160816; b=OSbV7kQPGOQP7Xv/2xT0spPDtlBngi0+5gbMToPWgMxvn7ZMgeOhvo8WzA9wgxaUks go3XyBqEXurSVT8naHt0HFrS7cAi5h/ohuEUPO/rK+IG8ZtAht+5gwt1t9obZ1gGihUs ZmWxe5acqMZHo4gbo06xfQs8QIjGRKCbS0+sxVd0sENr5pMu/feBV/uk3TsVDTbxxMil 1n2mN+C9d8e+iga0ldMTn4NJhXQSbbAlHIxsQXAY3rnzRi5laBCrM79ozZg67I+liMbH 1V6FPpQ+j9fLOtV0j7DZKEBCx+I7Ap/lm60EyPA9tIquTTHNMszUxT3vELR0unaasUvE f/zw== 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=q/GsTlT+ECFpftqfq5k/mQtxX2EW5CCRqGhMzVEtitc=; b=LFXZ35y156v77666IOtmT0UpbDIp0q2hP7b4d9v1T1DlvNYUrubeIRBIBdqgCNwsEa FQMCBhhtXj9aT1FwuLnxHC6TSh1jpFm3YVv2dIV9ioMbff3bRx20cXtJNXaDEUfw5iD6 Uo1DN0ats+WJhVId+I8i3mJrFBYLWTs5h6eOesyvR5W7aVBfNnpUHGWzaLLYACco6l40 GaYZlXtfjZzsD7dgvSOk05NqpAgYbFEVR34PMdwA3wE+slSri8lS5aROlo9eX9qEfH/f iR/j9v6aVKCVU1bkRnbg3mouP4pLYSCvmZKjxpZzHKmUtjgw6OrE8hLf8/ODoc0tXJbU yFjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=j+GlGmMr; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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 b8si15118745pgw.561.2019.02.13.09.46.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 09:46:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+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=j+GlGmMr; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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=q/GsTlT+ECFpftqfq5k/mQtxX2EW5CCRqGhMzVEtitc=; b=j+GlGmMrZEMKKkxVGVeWrOeCNf OpvdrArdcf4v2LZLSf8deFfFDjNklkFFvoMrGpyc6bh0ARkbv9TC+LEpMnFI7zyTEVyR+jJXBdWEO WjebbfBh/vKLmC+YhE4I8h8MDF1llpL4RWEDnfZwipht7XoE+dQs2ffjzZG34cnAbssJTfldObG+D yAJ1JnHattAnJAB3xPtzpm6CmdyI60v8334Cn3z8QQi+Ykgh5PLV2TR0Kn1d3Pj1WyZvMLARh3FSA BYGLda+8yUMBdyuJ4+JmotBhqZDG5uyVi2R6iUU0mkH8nTotRR0mvr/fcBbHawpNMWaV5OLjeUV2l Hs+Op+pg==; Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtyc8-0006cs-PL; Wed, 13 Feb 2019 17:46:29 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Alexander Viro , Russell King , Catalin Marinas , Will Deacon , Guan Xuetao , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] initramfs: cleanup initrd freeing Date: Wed, 13 Feb 2019 18:46:16 +0100 Message-Id: <20190213174621.29297-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213174621.29297-1-hch@lst.de> References: <20190213174621.29297-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 Factor the kexec logic into a separate helper, and then inline the rest of free_initrd into the only caller. Signed-off-by: Christoph Hellwig --- init/initramfs.c | 53 +++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 1cba6bbeeb75..6c2ed1d7276e 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -518,37 +518,35 @@ extern unsigned long __initramfs_size; #include #include -static void __init free_initrd(void) -{ #ifdef CONFIG_KEXEC_CORE +static bool kexec_free_initrd(void) +{ unsigned long crashk_start = (unsigned long)__va(crashk_res.start); unsigned long crashk_end = (unsigned long)__va(crashk_res.end); -#endif - if (do_retain_initrd) - goto skip; -#ifdef CONFIG_KEXEC_CORE /* * If the initrd region is overlapped with crashkernel reserved region, * free only memory that is not part of crashkernel region. */ - if (initrd_start < crashk_end && initrd_end > crashk_start) { - /* - * Initialize initrd memory region since the kexec boot does - * not do. - */ - memset((void *)initrd_start, 0, initrd_end - initrd_start); - if (initrd_start < crashk_start) - free_initrd_mem(initrd_start, crashk_start); - if (initrd_end > crashk_end) - free_initrd_mem(crashk_end, initrd_end); - } else -#endif - free_initrd_mem(initrd_start, initrd_end); -skip: - initrd_start = 0; - initrd_end = 0; + if (initrd_start >= crashk_end || initrd_end <= crashk_start) + return false; + + /* + * Initialize initrd memory region since the kexec boot does not do. + */ + memset((void *)initrd_start, 0, initrd_end - initrd_start); + if (initrd_start < crashk_start) + free_initrd_mem(initrd_start, crashk_start); + if (initrd_end > crashk_end) + free_initrd_mem(crashk_end, initrd_end); + return true; } +#else +static inline bool kexec_free_initrd(void) +{ + return false; +} +#endif /* CONFIG_KEXEC_CORE */ #define BUF_SIZE 1024 static void __init clean_rootfs(void) @@ -642,7 +640,16 @@ static int __init populate_rootfs(void) } #endif } - free_initrd(); + + /* + * If the initrd region is overlapped with crashkernel reserved region, + * free only memory that is not part of crashkernel region. + */ + if (!do_retain_initrd && !kexec_free_initrd()) + free_initrd_mem(initrd_start, initrd_end); + initrd_start = 0; + initrd_end = 0; + flush_delayed_fput(); return 0; } From patchwork Wed Feb 13 17:46:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10810537 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 0BFA01399 for ; Wed, 13 Feb 2019 17:46:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB9C92DA6F for ; Wed, 13 Feb 2019 17:46:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF3462E141; Wed, 13 Feb 2019 17:46: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 750582DA6F for ; Wed, 13 Feb 2019 17:46:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19CFD8E0006; Wed, 13 Feb 2019 12:46:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1512A8E0002; Wed, 13 Feb 2019 12:46:44 -0500 (EST) 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 017CD8E0006; Wed, 13 Feb 2019 12:46:43 -0500 (EST) 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 A95EF8E0002 for ; Wed, 13 Feb 2019 12:46:43 -0500 (EST) Received: by mail-pl1-f198.google.com with SMTP id x14so2216638pln.5 for ; Wed, 13 Feb 2019 09:46:43 -0800 (PST) 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=BQw99tH11D4Psdp+C10nNaKh7Npv1/BdP3rwuJ1L/lY=; b=KLOx9f+b8yP0yDhquf5qyiRHFUHHOqCqAU9HnxiABT1qvNbb3HdcG7kRe5T86FF4a+ sxItu/nEOsz1MuRLkgEDndFhER0GVWM16gar2MX/1QuGV4UcBUWBO+BQptwEvNE7wt52 XJ1lfaFVSZ6QWFCtU9WaMHoPPGUHs1jPdglBtlJ9vnr3f0eQeM8+168hS9jrlV9doNuf 5vlLC9fyG249WHDJtDCDXlUIaGZA/QKtyBwP+1BimDSqr3w6UKUNJ0NSdIUgUaUlkNEi pyn4tFAa7XEeyG1QJ0J47DaIJQf7amghrtKm3idlu1diAs+s4bw6WQeQ6Xcd/vBTocFi 85pA== X-Gm-Message-State: AHQUAuZn7jI6jgo9jk5GDC38BAm/y0zF9Mc9zRw7xeEMzAVdv/K/6VDL llIuHh4w5br7vXx5oJI5pQQsMoPyvTSPfme4N3l/PnqRON71IuM6TicGRd3cv+KGjuocjpC4uDV A+EYGTEN4kNuAEcB+4EvOpg4kU4Q0MrrjON2nTpnzaVoVJmQhE8RxWndDO0JoRB0= X-Received: by 2002:a17:902:6949:: with SMTP id k9mr1691267plt.188.1550080003336; Wed, 13 Feb 2019 09:46:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IbsQTiKSmWd4qbGDY6Sd9jFZfTGlidqIn0Bdx2Tmn4FI0mdSd1TQTepfImTqnQFti378Q0E X-Received: by 2002:a17:902:6949:: with SMTP id k9mr1691227plt.188.1550080002670; Wed, 13 Feb 2019 09:46:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550080002; cv=none; d=google.com; s=arc-20160816; b=tIhd68XSs8+jBcmOmiuOPBswVlQBBGXvSNaf4RNRxkB+poPWR6CdLaBAM1PYiRTPi7 w/CVCMYjJ6bHltKmWcuzFrzoPjAWDNpAXdS4Ir6iWGFfxl2+X4F0MXMD7ODjQs2SpFuF EwSzvxPW3lF3gUXnSLhXayJGx1CS/Q8vqMgIVc3hZoCKWC0lIpjMJl0h5D3nMBJsUsNw X/SJPM9fODn0/6a11g8YP5UyTrxvSpNaSeJUpM9vphTpnStKmudWaLmMmlt/Jw2vBMvg bgRX0CMPT9UGZ7A84qx0dgYgxqOcpiSwL4ZZGryTICw1Ac0MA083elnd0vaR2jQOwAbW mQ5w== 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=BQw99tH11D4Psdp+C10nNaKh7Npv1/BdP3rwuJ1L/lY=; b=YDuSlnrZwKfqRuhf1aNLIGcL53Zy5kBRFAkBKHVJYpnvLmv3Fge+qFjVmMtsIAfWER pSGlixYX5OQRJoL2yujV/Ab4Z+kdkyBw31RRXK86GLos7LlXe7lg3ofV8b3YflbnVJ2C D/0bR6cJvF30F1JKwkxCiEX2vl501P6V96Iwv0SnEqJlXBUdhJyW9sKax22wonYh6G1h A+8Yf/4vtlGaILzJnHLQOloMd42XHyzO4k5y16OfgfSiB8SPu3+JdmhbgyYvGxXJXIDh o+DUvgOlM36rzkxLj7pMdZQp7APIxsMJY1F5ArY7C2gvRpvpzdxadRdnKKAUhkQOOXnp I02Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=PC0tXF87; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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 79si16132773pgb.351.2019.02.13.09.46.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 09:46:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+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=PC0tXF87; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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=BQw99tH11D4Psdp+C10nNaKh7Npv1/BdP3rwuJ1L/lY=; b=PC0tXF87R/V9iw6qGhuVO3esea CcjsC7X+SdSz7Bxxf/NyWSDtWTft0xTNQGkdfjtppDQgBofPdXPTYOap+FMX9vsjU/cbU217D7ady ZOz0q/nGrV8SFf4ZuOPklMxRIoIj18hbZi7KJk3d4rWFyqeqVWylAERdx7BI40awG35quaiQPEVjt H9REOlJWN7zBsyL4mgWwaBhQJnYMD6wizSf1fSQkyEpVe8u4IXhXPlgdq6pC5kQttpVdpz1GZsabE t4gSQ6rY2vtmg+eWQVgsuEkw+BsJsjfT7rtTflqYb+sPzJa4EifzT+A3eKVxJBQfrxVLSJg3v6FBO GCd2vPhA==; Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtycB-0006gW-B2; Wed, 13 Feb 2019 17:46:31 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Alexander Viro , Russell King , Catalin Marinas , Will Deacon , Guan Xuetao , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/8] initramfs: factor out a helper to populate the initrd image Date: Wed, 13 Feb 2019 18:46:17 +0100 Message-Id: <20190213174621.29297-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213174621.29297-1-hch@lst.de> References: <20190213174621.29297-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 will allow for cleaner code sharing in the caller. Signed-off-by: Christoph Hellwig --- init/initramfs.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 6c2ed1d7276e..c2e9a8845e98 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -595,6 +595,28 @@ static void __init clean_rootfs(void) kfree(buf); } +#ifdef CONFIG_BLK_DEV_RAM +static void populate_initrd_image(char *err) +{ + ssize_t written; + int fd; + + unpack_to_rootfs(__initramfs_start, __initramfs_size); + + printk(KERN_INFO "rootfs image is not initramfs (%s); looks like an initrd\n", + err); + fd = ksys_open("/initrd.image", O_WRONLY | O_CREAT, 0700); + if (fd < 0) + return; + + written = xwrite(fd, (char *)initrd_start, initrd_end - initrd_start); + if (written != initrd_end - initrd_start) + pr_err("/initrd.image: incomplete write (%zd != %ld)\n", + written, initrd_end - initrd_start); + ksys_close(fd); +} +#endif /* CONFIG_BLK_DEV_RAM */ + static int __init populate_rootfs(void) { /* Load the built in initramfs */ @@ -604,7 +626,6 @@ static int __init populate_rootfs(void) /* If available load the bootloader supplied initrd */ if (initrd_start && !IS_ENABLED(CONFIG_INITRAMFS_FORCE)) { #ifdef CONFIG_BLK_DEV_RAM - int fd; printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n"); err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start); @@ -612,22 +633,7 @@ static int __init populate_rootfs(void) goto done; clean_rootfs(); - unpack_to_rootfs(__initramfs_start, __initramfs_size); - - printk(KERN_INFO "rootfs image is not initramfs (%s)" - "; looks like an initrd\n", err); - fd = ksys_open("/initrd.image", - O_WRONLY|O_CREAT, 0700); - if (fd >= 0) { - ssize_t written = xwrite(fd, (char *)initrd_start, - initrd_end - initrd_start); - - if (written != initrd_end - initrd_start) - pr_err("/initrd.image: incomplete write (%zd != %ld)\n", - written, initrd_end - initrd_start); - - ksys_close(fd); - } + populate_initrd_image(err); done: /* empty statement */; #else From patchwork Wed Feb 13 17:46:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10810539 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 E013A1399 for ; Wed, 13 Feb 2019 17:46:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAA462DA44 for ; Wed, 13 Feb 2019 17:46:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE9082DC12; Wed, 13 Feb 2019 17:46:52 +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 55FA62DA44 for ; Wed, 13 Feb 2019 17:46:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71F3E8E0007; Wed, 13 Feb 2019 12:46:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6D3478E0002; Wed, 13 Feb 2019 12:46:48 -0500 (EST) 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 482598E0007; Wed, 13 Feb 2019 12:46:48 -0500 (EST) 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 034828E0002 for ; Wed, 13 Feb 2019 12:46:48 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id a72so486360pfj.19 for ; Wed, 13 Feb 2019 09:46:47 -0800 (PST) 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=fTdHUPsgYRu4VneoajaxB1/e1nadjQ3WHuZL105MHUY=; b=aydpIUYzi5oQllZMB/CG7tVZULp70lcHcsUetSiZCqXH0Px8kcGOQ6YppaV7fT5FCq oDmtB3vB/kO78nmIayZu11wCVGhyt7DCgdsQrMxCSBldcs91Wmn4VQK1HKdQs2x5ZPzU AlG0iiFXKlt12jWrtoLt46kzbXuCfKZA+uc1zw6JRtPquZ6bJeFsXFYpTyWsbQexCu/1 GjR3rZjS29NSEo75ObFDkfYu6GFXI8AC/0HwM+FdFsh/MxJfS0I21EogpXH9RmEOa1MF ryOuAZXphjnDNQOJXarCfm0YcUDZ7shJf+aZV4z70PhMfQCC0Z+TojTN10sGt9Tpn4sD AdNg== X-Gm-Message-State: AHQUAuYbtwHqJwDk5CgICzTJCDGiD8EoT8laTfYPKtvqisQ5gjJwwltT wYEERcQNaA+7VepeUO+AC4QZiRX/Y3jMX2eSTvjDpcmY1pRUUVEYp6vSVVVnKJOpMZi0etNsXA0 REoMmhWqmXipl7hjePyVTQahz+dx8tVQR6tCDiG0Duf9fg8NxYAKSXFkYLgjnFJU= X-Received: by 2002:a62:1c45:: with SMTP id c66mr1636467pfc.90.1550080007677; Wed, 13 Feb 2019 09:46:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IZV5MU4wGOHIkUvZEyWXlwP5cbknvIB/ZHaqtR+on9PaX0DcUT2k63z+k03rTqNcq2Wp4mk X-Received: by 2002:a62:1c45:: with SMTP id c66mr1636425pfc.90.1550080006993; Wed, 13 Feb 2019 09:46:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550080006; cv=none; d=google.com; s=arc-20160816; b=VLbAnkMKFoh0hWKHN1jHZyuIFlZG54xeiPhucEmx1CnHMIEC1Wbp8NOmtlRy98sajk 3vNQvawdvSAXyJBwC/DUstvwrpw4syp0Fdo0uit2U8o4OQq+WrggcR+sIxT/vsvLxHuU sOyB4h7B0Twz/6ysU5B5l2rlTt6Xp7oCIUX6O7bJDCHwmzrpTfais6EhqKSL6NVUztEL wl4drKEmCtn/d+nTwXY22HKYC8E50sLtd2rzf7+ReYWXjuc0vA+xDHQfKgYN6KYxw58p bDyJxYQUhycr0xYB0qg+EOj7wFg6vAFoVm/hEPLK28yH/MMxyGREBSZC9AF1FNTGTwsQ K0AA== 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=fTdHUPsgYRu4VneoajaxB1/e1nadjQ3WHuZL105MHUY=; b=0IQlb6oNCXoig0WXPxR6C0T4BQJ2Jc4Gb5fYOuNHhNCpYYpVdQqUjIDC0e1ifs+nII Kdf9ePy5v5EkdXKjY7BuF9cQruMtQeisXw4V05i1lSTWrOO71i6X5k4g8r9KtNtd+lYj zPyyyi9T9mxJrkAeaRCh4RsVSlqqQLhTY/NqpeNhaGQUnfadwaTgIo0mIox3u+YHFV0H /Fw+ym8dquQonts2XRib+0tzqmpSWNRx1E1mOiIGU3ILeiA0KmndgNG3LHkJCSntZMSr Skt1Eo+dyZIHvD4q+zXgDNMnZCQGWIQd3PeTCS54pVlvONAsomxn0IyD/dwSari8pnAH z8mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=WNJwYLVh; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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 a1si14841144pgw.142.2019.02.13.09.46.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 09:46:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+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=WNJwYLVh; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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=fTdHUPsgYRu4VneoajaxB1/e1nadjQ3WHuZL105MHUY=; b=WNJwYLVhSQl1R0/3jqf/I4YZNY hOjgUb5Fd0oKnOtL6U2GbrsZrqM+RLTi+gkXwZTbHuD6rPN1DtGjkl0FxIamC0O++xHvh3FAqXTxn LkHfHYNxmpgwmRlok7rtvWs31VllCpAFPsVPCDOhiwmeYugfSXaGBNUM3mEeRysJag3eb58o7DXlN nxcWjHweOwduHENFmeadafi5Gjql10SaL2euZZsZ0SQbJvVZyR/NmXq4F86h2CVoSs6iNwkfhxJCv WAdGAiI4nraWBAF749N3f/+NHlnupVRcz5Z2G78dPjoYqHmphoc6xj0D4ixjunMox31yfbCIUH7ya WENCLhxw==; Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtycD-0006kA-Ph; Wed, 13 Feb 2019 17:46:34 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Alexander Viro , Russell King , Catalin Marinas , Will Deacon , Guan Xuetao , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/8] initramfs: cleanup populate_rootfs Date: Wed, 13 Feb 2019 18:46:18 +0100 Message-Id: <20190213174621.29297-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213174621.29297-1-hch@lst.de> References: <20190213174621.29297-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 code for kernels that support ramdisks or not is mostly the same. Unify it by using an IS_ENABLED for the info message, and moving the error message into a stub for populate_initrd_image. Signed-off-by: Christoph Hellwig --- init/initramfs.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index c2e9a8845e98..c55e08f72fad 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -615,6 +615,11 @@ static void populate_initrd_image(char *err) written, initrd_end - initrd_start); ksys_close(fd); } +#else +static void populate_initrd_image(char *err) +{ + printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); +} #endif /* CONFIG_BLK_DEV_RAM */ static int __init populate_rootfs(void) @@ -623,30 +628,22 @@ static int __init populate_rootfs(void) char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size); if (err) panic("%s", err); /* Failed to decompress INTERNAL initramfs */ - /* If available load the bootloader supplied initrd */ - if (initrd_start && !IS_ENABLED(CONFIG_INITRAMFS_FORCE)) { -#ifdef CONFIG_BLK_DEV_RAM + + if (!initrd_start || IS_ENABLED(CONFIG_INITRAMFS_FORCE)) + goto done; + + if (IS_ENABLED(CONFIG_BLK_DEV_RAM)) printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n"); - err = unpack_to_rootfs((char *)initrd_start, - initrd_end - initrd_start); - if (!err) - goto done; + else + printk(KERN_INFO "Unpacking initramfs...\n"); + err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start); + if (err) { clean_rootfs(); populate_initrd_image(err); - done: - /* empty statement */; -#else - printk(KERN_INFO "Unpacking initramfs...\n"); - err = unpack_to_rootfs((char *)initrd_start, - initrd_end - initrd_start); - if (err) { - printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); - clean_rootfs(); - } -#endif } +done: /* * If the initrd region is overlapped with crashkernel reserved region, * free only memory that is not part of crashkernel region. From patchwork Wed Feb 13 17:46:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10810541 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 2E7FB6C2 for ; Wed, 13 Feb 2019 17:46:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 192B42DA6F for ; Wed, 13 Feb 2019 17:46:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CFCA2E144; Wed, 13 Feb 2019 17:46: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 63E412DA44 for ; Wed, 13 Feb 2019 17:46:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 856B38E0008; Wed, 13 Feb 2019 12:46:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 806C18E0002; Wed, 13 Feb 2019 12:46:52 -0500 (EST) 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 6CBC18E0008; Wed, 13 Feb 2019 12:46:52 -0500 (EST) 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 328378E0002 for ; Wed, 13 Feb 2019 12:46:52 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id x134so2409384pfd.18 for ; Wed, 13 Feb 2019 09:46:52 -0800 (PST) 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=xvt6WU53rbr8sNdP0Yb1NGTBLO4wbx68oDDxR14icuI=; b=df4RYMb0t9eBV555+yuwj1J14MVL74tCPMUQKzQGbStkCU8Wn3QB5JzPvX8Ydi9ufH HfetdgWlLCaDt45dH4l+QEGdkIKGe6FmyCGU9a8WQjB0TidLsWPpvM943hFKF0C2ZPAT 4IgaoI2k8KglEV4jAO0w4+SLnZ8bmmF97/mo/DjVwmlqTe6e+XND0HzoudSNdpIZnTTg u8t4dJsAwrE2TqI3IAK+K5eWW21N5RcsCYlmJmqPJD8cz5VNxpDxKhPj2Ywegw8tewXu R6eVXWsBq5saJi5jKCMZx//Yu0WdlxPyyeVUwXOJDrKYNrgjAfBd8sv+4yrL86cH6yWD TUxg== X-Gm-Message-State: AHQUAubkrEPy9MztN7kXaFyi8Ue9Md/yCRpkpxb5fSIEcjbOkC3/pptN 5rM2v/VQhWnvoVXAv3BOCxgs715NCaz6Sp2EQv/ccw0qWMMg97Y6bSrb3S59+u0/cWpfGb5ssgZ LHZOZY00K/9x1aihfDb4ufYAULTd0qLT0VRtIaKDpNKWgmXifDxUk/0b9WUZlTZY= X-Received: by 2002:a17:902:b190:: with SMTP id s16mr1664647plr.262.1550080011839; Wed, 13 Feb 2019 09:46:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IYKy1CAKNZfI8jcTT4yG8P0HRKRwPkOH304uiY0fyRJ5Bxh3cgm2brg+XRWYcoJ/FVgtjp5 X-Received: by 2002:a17:902:b190:: with SMTP id s16mr1664591plr.262.1550080010958; Wed, 13 Feb 2019 09:46:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550080010; cv=none; d=google.com; s=arc-20160816; b=xvUS2CnH1GBB6FSWgQwC1HQ2sXpkiHBifIeG99SwuHL14hQ+jduqEKCQ4YWpv+xVWZ 8uRqGGS9wkrTpq6sMrhJQE/vIbYyVSm5UhyU7FvIpMcsZVy0hacf2zxooFL7viQ6QpNE MCBDLJPyjsIGuygtTKoepQ67PXHau5Bg3VjERsE+E4FkWR5tZKQkB37r7s2Dg/HN5Mpz FVU3AFGPiJh48I4ajInyQDwsysZmHTlSeYLUa443GvUKDG6UVwZ2JvrjP6GpPXoIEzcy 3we4g3lS04eVICeVGdOT+s4daxlan4amopydveHBvt1YQ1Qi21p/NI9E8ZkOoIg4YLdm J+Aw== 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=xvt6WU53rbr8sNdP0Yb1NGTBLO4wbx68oDDxR14icuI=; b=lT62k5rz3EXiQIyB2kg8tcvnGUuSOAsgwnpSc6VYvlZTrwWxHzIoyC/LgDPnUY+xwv T7q+utz1fTDiMtnEMUj6JgqHPAhfc/HOxl5WfJHe6IGkURCvDExZuzOaHkDWguB2mTPg UWFbB/pnoJp/4sft01/PCDpmyaBcpE0YR3FBb69GBxqkAd6wa7KqQHXN5EyQKKyrY/8W uqiiuG5TfFfi2KtphQ06a7lMJqPlDW+bfISm+QOkudHtV+KQRd8bSSXyTIZPMyeUqak/ m25Hk3f185OPbmAeciQuq0uj40Htl7KMblaexJ/G9wOrpC7ScxQzfv9t+9Kyy2V2ET9+ 5bXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=S9a+FpHz; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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 c24si3268134pgj.60.2019.02.13.09.46.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 09:46:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+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=S9a+FpHz; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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=xvt6WU53rbr8sNdP0Yb1NGTBLO4wbx68oDDxR14icuI=; b=S9a+FpHz9N7pHPMLFcQrjIrVde 2FSeyLwLkJxfNzZOyzDImwRp8/FeSFdTaCC4uWFz2EhvuPdsxDfnLPBBsUB1oVKhZsWUfvReA0hU6 LlgoGq1VPbK11Sm/6h/uNQYtWK0yQmfSWxJgO5JRr8o6nshpRcrygSLUptwIxd8QyIn//z6RwO0jg ki0yErJygvCwZVIgZwc6kdA3PCjYqf1oUFOZK9h0XgKcHI0YaLXRjnVkG2H9PnK6V0gB+aiGwDAqX U8T/OyCycuiG1IabDteq9CsVkZdw97Ntn/VMTw+fowZHqF2QN35VcHI2G8wmvdKox5GosMv5A3LSG N8TqdOpQ==; Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtycG-0006nL-7m; Wed, 13 Feb 2019 17:46:36 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Alexander Viro , Russell King , Catalin Marinas , Will Deacon , Guan Xuetao , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] initramfs: move the legacy keepinitrd parameter to core code Date: Wed, 13 Feb 2019 18:46:19 +0100 Message-Id: <20190213174621.29297-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213174621.29297-1-hch@lst.de> References: <20190213174621.29297-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 No need to handle the freeing disable in arch code when we already have a core hook (and a different name for the option) for it. Signed-off-by: Christoph Hellwig Acked-by: Catalin Marinas --- arch/Kconfig | 7 +++++++ arch/arm/Kconfig | 1 + arch/arm/mm/init.c | 25 ++++++------------------- arch/arm64/Kconfig | 1 + arch/arm64/mm/init.c | 17 ++--------------- arch/unicore32/Kconfig | 1 + arch/unicore32/mm/init.c | 14 +------------- init/initramfs.c | 9 +++++++++ 8 files changed, 28 insertions(+), 47 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 4cfb6de48f79..d2bf5db0805f 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -245,6 +245,13 @@ config ARCH_HAS_FORTIFY_SOURCE An architecture should select this when it can successfully build and run with CONFIG_FORTIFY_SOURCE. +# +# Select if the arch provides a historic keepinit alias for the retain_initrd +# command line option +# +config ARCH_HAS_KEEPINITRD + bool + # Select if arch has all set_memory_ro/rw/x/nx() functions in asm/cacheflush.h config ARCH_HAS_SET_MEMORY bool diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 664e918e2624..4c99a29a8ec7 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -8,6 +8,7 @@ config ARM select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE + select ARCH_HAS_KEEPINITRD select ARCH_HAS_KCOV select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL if ARM_LPAE diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 478ea8b7db87..d0ccbfab94db 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -752,27 +752,14 @@ void free_initmem(void) } #ifdef CONFIG_BLK_DEV_INITRD - -static int keep_initrd; - void free_initrd_mem(unsigned long start, unsigned long end) { - if (!keep_initrd) { - if (start == initrd_start) - start = round_down(start, PAGE_SIZE); - if (end == initrd_end) - end = round_up(end, PAGE_SIZE); + if (start == initrd_start) + start = round_down(start, PAGE_SIZE); + if (end == initrd_end) + end = round_up(end, PAGE_SIZE); - poison_init_mem((void *)start, PAGE_ALIGN(end) - start); - free_reserved_area((void *)start, (void *)end, -1, "initrd"); - } + poison_init_mem((void *)start, PAGE_ALIGN(end) - start); + free_reserved_area((void *)start, (void *)end, -1, "initrd"); } - -static int __init keepinitrd_setup(char *__unused) -{ - keep_initrd = 1; - return 1; -} - -__setup("keepinitrd", keepinitrd_setup); #endif diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index a4168d366127..74c89b628afd 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -19,6 +19,7 @@ config ARM64 select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE if (MEMORY_ISOLATION && COMPACTION) || CMA + select ARCH_HAS_KEEPINITRD select ARCH_HAS_KCOV select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 7205a9085b4d..019c790d8d56 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -622,24 +622,11 @@ void free_initmem(void) } #ifdef CONFIG_BLK_DEV_INITRD - -static int keep_initrd __initdata; - void __init free_initrd_mem(unsigned long start, unsigned long end) { - if (!keep_initrd) { - free_reserved_area((void *)start, (void *)end, 0, "initrd"); - memblock_free(__virt_to_phys(start), end - start); - } -} - -static int __init keepinitrd_setup(char *__unused) -{ - keep_initrd = 1; - return 1; + free_reserved_area((void *)start, (void *)end, 0, "initrd"); + memblock_free(__virt_to_phys(start), end - start); } - -__setup("keepinitrd", keepinitrd_setup); #endif /* diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig index c3a41bfe161b..b924c11e3ff9 100644 --- a/arch/unicore32/Kconfig +++ b/arch/unicore32/Kconfig @@ -2,6 +2,7 @@ config UNICORE32 def_bool y select ARCH_HAS_DEVMEM_IS_ALLOWED + select ARCH_HAS_KEEPINITRD select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO select HAVE_GENERIC_DMA_COHERENT diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index 85ef2c624090..e3f4f791e10a 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c @@ -318,20 +318,8 @@ void free_initmem(void) } #ifdef CONFIG_BLK_DEV_INITRD - -static int keep_initrd; - void free_initrd_mem(unsigned long start, unsigned long end) { - if (!keep_initrd) - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} - -static int __init keepinitrd_setup(char *__unused) -{ - keep_initrd = 1; - return 1; + free_reserved_area((void *)start, (void *)end, -1, "initrd"); } - -__setup("keepinitrd", keepinitrd_setup); #endif diff --git a/init/initramfs.c b/init/initramfs.c index c55e08f72fad..cf8bf014873f 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -513,6 +513,15 @@ static int __init retain_initrd_param(char *str) } __setup("retain_initrd", retain_initrd_param); +#ifdef CONFIG_ARCH_HAS_KEEPINITRD +static int __init keepinitrd_setup(char *__unused) +{ + do_retain_initrd = 1; + return 1; +} +__setup("keepinitrd", keepinitrd_setup); +#endif + extern char __initramfs_start[]; extern unsigned long __initramfs_size; #include From patchwork Wed Feb 13 17:46:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10810547 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 174F96C2 for ; Wed, 13 Feb 2019 17:47:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3A002DA60 for ; Wed, 13 Feb 2019 17:47:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4F6C2E141; Wed, 13 Feb 2019 17:47:03 +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 2202E2DA60 for ; Wed, 13 Feb 2019 17:47:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E19B8E000A; Wed, 13 Feb 2019 12:46:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5924A8E0002; Wed, 13 Feb 2019 12:46:58 -0500 (EST) 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 4A9EF8E000A; Wed, 13 Feb 2019 12:46:58 -0500 (EST) 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 0AD048E0002 for ; Wed, 13 Feb 2019 12:46:58 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id f3so2168341pgq.13 for ; Wed, 13 Feb 2019 09:46:58 -0800 (PST) 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=PrNOrZHUtDO30vN/fIi9FDRbb/3B7XAAJkaxXZrg5oY=; b=HC1EwQ3wSawtKT/PdbjLv7vhuGNPwDzSScUJYv30Lx3xpYDHF8iYt983M+jTP+0Jy+ K3zGAhm5o2YmZQLcdQPmLO5AhPlNtK6zUcIoZ0qJ9lC/6hcnYRMyFrFFIjQN2FtKPBb9 EDE9PDZI/oJYYalkmOHtTA2517Zopbi1yC2bHfuhbcvu5zOPTXQ/HlM23Im51vS4pbRJ 5uda+QLV/AjePhG7dnRX7C3GhWS6TUAIEgUfHaFOqhgPY4Ds3jbLxD6nN4Eb8jdFmvAf 91w1jf9pHfQLqG+NwrsZCvFMvYjxdFQh3zDa5GdY4SuLZlpbCRYOICXVNup+nG+iAiol m7iw== X-Gm-Message-State: AHQUAubVjOfcQ6SV8vYLCh+EU8dZI+40yqvnfBCAtSIZrJ72BuYi9v/7 xPhnhxajlqaSgnAePATq+ZyaGG8tgYjW52wcZL3n8GjOcHRhZ32DSsdwefvu/O7YXPk3cRqVGQh gASvWhQPHm6ntWLEYgufP6diQ2ktoY+D/18EFgwecOROj7v2jdIzhfNeqfaTpttw= X-Received: by 2002:a63:160d:: with SMTP id w13mr1470628pgl.85.1550080017701; Wed, 13 Feb 2019 09:46:57 -0800 (PST) X-Google-Smtp-Source: AHgI3IagMQVHp1xmowyLotaWH+zYY9qcwep6qVJmBNZL6Ix7oU+MQqERHcs4vxC75KrmI09Yjpy+ X-Received: by 2002:a63:160d:: with SMTP id w13mr1470512pgl.85.1550080015849; Wed, 13 Feb 2019 09:46:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550080015; cv=none; d=google.com; s=arc-20160816; b=R+D6MK7piHaXulD/JZzPHCibedKEYzZdpQm9pGI01rJYCSjiRnFKqGu2o8+b6nfoOc ynQ+wTNMsE3GkCYJBeXh09OwJsUg067gz97kRJYyywmecEjtU1aSdoB4EG0ClUFuOaCd EwszBrMURtX27ckhdtN+4n74M1Q1TWpOeYXEivlOfMry3OI5wUJemYg4LV3zhW01V3OY vgLkBdxx0dvCNO20bk7tentbrphHuPqwfAC5Z2sAf2o4roehR/mt3tmer7x1RRnchlaF +0jKT2RYJpE5IdNiMZwB6eHUp/KMC8G1TgFl5kmqxkETyxG9LbfeJyvzlesbWs+x5/Pf 75PA== 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=PrNOrZHUtDO30vN/fIi9FDRbb/3B7XAAJkaxXZrg5oY=; b=M15ap++I8CEpCyG7QaeLrEjCQShi6SnyBI0yPWmQuVy0sWGv6zAnV++2bTyc0SB1AF 4D1eqsb3aJiGXnpHgtAX9gjXY5wjzm4TAoXvjwYOkjK3E/EvZeEdpcopnCukW6TSHcXK lnerY3YV7fs/WF+F8ysJ1186WrjY5Mzdqv5qPLmj4eBgaMjis3S9vjLTj1EIWE3Y7aKn mRK1mwQmppz78qaCHylL8ZaGrfL0t2+nCI+rVc3YmtEfj3W/hzBDiWfjEqu9PJhROfvS UqlgnsofNEQd0u5DtsECdurXRyLareTW6gajj1sa9WDZNOCXwZuaCug/4bCbtpHU4H2F FdXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=tCEM6Wk7; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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 x6si4491017pgp.367.2019.02.13.09.46.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 09:46:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+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=tCEM6Wk7; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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=PrNOrZHUtDO30vN/fIi9FDRbb/3B7XAAJkaxXZrg5oY=; b=tCEM6Wk7WB51JtayIYCq/rBjvK OFbhI9keM+O8AX5RSorJz8SBS7+tKzeF4xklxv5mV112Do5791tI2VCLZM9xV682E7ItQbcD6Ds8j G+0eORJMo+eyypbAMHb49J+6GbOWHOpLtddFl3OjSxJJSglh5FYCaozRhLkXT5lNmVmdTM9qW5yhO H9Gf9MLmIWYnMo+rqTcgAuJRI9i+xkSrgkOc41NY+D1MUGjhqvdgc4h8t8tc/7w4fZiKs6bEhAFKx xvy5VYVufLmchIF87QS3gm99ifTQYaIbu7H5ZYEcObgt6TeaNz1OTj0A/oQmDJe0E58XKCmNf/6IX 0KfT+qAQ==; Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtycI-0006qw-Pn; Wed, 13 Feb 2019 17:46:39 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Alexander Viro , Russell King , Catalin Marinas , Will Deacon , Guan Xuetao , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] initramfs: proide a generic free_initrd_mem implementation Date: Wed, 13 Feb 2019 18:46:20 +0100 Message-Id: <20190213174621.29297-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213174621.29297-1-hch@lst.de> References: <20190213174621.29297-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 For most architectures free_initrd_mem just expands to the same free_reserved_area call. Provide that as a generic implementation marked __weak. Signed-off-by: Christoph Hellwig Acked-by: Geert Uytterhoeven --- arch/alpha/mm/init.c | 8 -------- arch/arc/mm/init.c | 7 ------- arch/c6x/mm/init.c | 7 ------- arch/h8300/mm/init.c | 8 -------- arch/m68k/mm/init.c | 7 ------- arch/microblaze/mm/init.c | 7 ------- arch/nds32/mm/init.c | 7 ------- arch/nios2/mm/init.c | 7 ------- arch/openrisc/mm/init.c | 7 ------- arch/parisc/mm/init.c | 7 ------- arch/powerpc/mm/mem.c | 7 ------- arch/sh/mm/init.c | 7 ------- arch/um/kernel/mem.c | 7 ------- arch/unicore32/mm/init.c | 7 ------- init/initramfs.c | 5 +++++ 15 files changed, 5 insertions(+), 100 deletions(-) diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c index a42fc5c4db89..97f4940f11e3 100644 --- a/arch/alpha/mm/init.c +++ b/arch/alpha/mm/init.c @@ -291,11 +291,3 @@ free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -void -free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c index e1ab2d7f1d64..c357a3bd1532 100644 --- a/arch/arc/mm/init.c +++ b/arch/arc/mm/init.c @@ -214,10 +214,3 @@ void __ref free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c index af5ada0520be..5504b71254f6 100644 --- a/arch/c6x/mm/init.c +++ b/arch/c6x/mm/init.c @@ -67,13 +67,6 @@ void __init mem_init(void) mem_init_print_info(NULL); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void __init free_initmem(void) { free_initmem_default(-1); diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c index 6519252ac4db..2eff00de2b78 100644 --- a/arch/h8300/mm/init.c +++ b/arch/h8300/mm/init.c @@ -101,14 +101,6 @@ void __init mem_init(void) mem_init_print_info(NULL); } - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void free_initmem(void) { diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c index 933c33e76a48..c62e41563bb9 100644 --- a/arch/m68k/mm/init.c +++ b/arch/m68k/mm/init.c @@ -144,10 +144,3 @@ void __init mem_init(void) init_pointer_tables(); mem_init_print_info(NULL); } - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index b17fd8aafd64..3bd32de46abb 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c @@ -186,13 +186,6 @@ void __init setup_memory(void) paging_init(); } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void free_initmem(void) { free_initmem_default(-1); diff --git a/arch/nds32/mm/init.c b/arch/nds32/mm/init.c index 253f79fc7196..c02e10ac5e76 100644 --- a/arch/nds32/mm/init.c +++ b/arch/nds32/mm/init.c @@ -249,13 +249,6 @@ void free_initmem(void) free_initmem_default(-1); } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags) { diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index 16cea5776b87..60736a725883 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c @@ -82,13 +82,6 @@ void __init mmu_init(void) flush_tlb_all(); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void __ref free_initmem(void) { free_initmem_default(-1); diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c index d157310eb377..d0d94a4391d4 100644 --- a/arch/openrisc/mm/init.c +++ b/arch/openrisc/mm/init.c @@ -221,13 +221,6 @@ void __init mem_init(void) return; } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - void free_initmem(void) { free_initmem_default(-1); diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index 059187a3ded7..1b445e206ca8 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -935,10 +935,3 @@ void flush_tlb_all(void) spin_unlock(&sid_lock); } #endif - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 33cc6f676fa6..976c706a64e2 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -388,13 +388,6 @@ void free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - /* * This is called when a page has been modified by the kernel. * It just marks the page as not i-cache clean. We do the i-cache diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index a8e5c0e00fca..2fa824336ec2 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -410,13 +410,6 @@ void free_initmem(void) free_initmem_default(-1); } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - #ifdef CONFIG_MEMORY_HOTPLUG int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, bool want_memblock) diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index 799b571a8f88..48b24b63b10d 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -172,13 +172,6 @@ void free_initmem(void) { } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif - /* Allocate and free page tables. */ pgd_t *pgd_alloc(struct mm_struct *mm) diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index e3f4f791e10a..01271ce52ef9 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c @@ -316,10 +316,3 @@ void free_initmem(void) { free_initmem_default(-1); } - -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, -1, "initrd"); -} -#endif diff --git a/init/initramfs.c b/init/initramfs.c index cf8bf014873f..f3aaa58ac63d 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -527,6 +527,11 @@ extern unsigned long __initramfs_size; #include #include +void __weak free_initrd_mem(unsigned long start, unsigned long end) +{ + free_reserved_area((void *)start, (void *)end, -1, "initrd"); +} + #ifdef CONFIG_KEXEC_CORE static bool kexec_free_initrd(void) { From patchwork Wed Feb 13 17:46:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10810545 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 4886E14E1 for ; Wed, 13 Feb 2019 17:47:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 334F92DA60 for ; Wed, 13 Feb 2019 17:47:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 256F72DC12; Wed, 13 Feb 2019 17:47:00 +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 9C0E62E147 for ; Wed, 13 Feb 2019 17:46:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE8328E0009; Wed, 13 Feb 2019 12:46:57 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C995A8E0002; Wed, 13 Feb 2019 12:46:57 -0500 (EST) 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 B38578E0009; Wed, 13 Feb 2019 12:46:57 -0500 (EST) 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 736578E0002 for ; Wed, 13 Feb 2019 12:46:57 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id t72so2404048pfi.21 for ; Wed, 13 Feb 2019 09:46:57 -0800 (PST) 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=scDNPfor2+o2sRXISwjXU4Ei4L2S2/i4alFAOpD2+h8=; b=tYRg09Z2Ac0qtu+D9I1seh6JP414Sl+7WVm3M8CdxT3+15Fs5nyoJmntyPC0lq8YUe rgnUkj+CGrIIPPVoSEPfNMJFV4wMM448Z+vqLsl2dMoXm2nmTLVwfFP4N5U2JYiANpxP TIfAkpsDrH6izZcC9M5ihVxRBdt7uyrsCbE/kHw6XdGwRzn+sibnC8YKF2HsD8RQYcBQ y1lmskzG9QrcxEIHnw2iUSlYzXXqNaW95sHU0LiS40s6VtDzhG1HZ7XJ+DDm0pe9O4/8 n9C835/Lt48SdHQ3CrMQ1zzrNemeiKrvbD9xo1uUwp0zB9co0Vtj9NWJ/m4Oz3OT0YbJ a1Og== X-Gm-Message-State: AHQUAuY1k+ckAwfg8f8onc/koKz6ONUPtU+bVQpIUXXK6xW7NI8KqvRm AH9y3njiK6l00y3IK1CmxZW7eqpyrgZP4uHWN+rEZN4+z+VTTdyS1F4/aQ9PwR5U/C6/T0KP0fG IqIjmhsBdjFBeJ3f6FIxDJ7kNrn2cLLhwfXpn5JWQbIt5nHMkGZHEMKLxIMXSZT0= X-Received: by 2002:a63:ea06:: with SMTP id c6mr1521816pgi.162.1550080017116; Wed, 13 Feb 2019 09:46:57 -0800 (PST) X-Google-Smtp-Source: AHgI3IbZ+n1o4nvZySVQRNaFKTcDy4CcZJ7aHoQ1dqSB4BFiTkne7DIqJHBK5cy0B6awFXT3W5Ie X-Received: by 2002:a63:ea06:: with SMTP id c6mr1521773pgi.162.1550080016336; Wed, 13 Feb 2019 09:46:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550080016; cv=none; d=google.com; s=arc-20160816; b=Zc9/Ykqitj/RnsgtWlwHCFWLFUtIG1kIbRw6QU8Q6m2bnSLjwsDppUk6CRE+RZ7WUM dlyhzXo3+pOwXexzs27tjrnUf/xCZloGguHnGuwAB8/fDUBsFqydPHoVxZ5tOAY73fmr ieXTx/52R6c1L7ZfeKssf0jcn8R+yw74Q8R9WEqGJvbZoykbNcgk1ws7HnYcpfdVZKKm mYkYpXa7SskjCqyQiHl9bHLBxsuo19T0rCn+aqV96LrGaD99m++mGQj7xpK/oDPWAI17 s1wwQ0Nkcp+gno4sUIOdZu9cjzJ0TrCVksPo1wx7AZjsMx1eoqNjQhksuHIw3+6MjxdA hdzQ== 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=scDNPfor2+o2sRXISwjXU4Ei4L2S2/i4alFAOpD2+h8=; b=dVFZpifeXB8vJsPJyuGcyCTQwJv1Hf0umaRhtOdKNPa4EeWNC3rR8eajsG+8jy7VvR yhQWOveSw5V7StNn+FFonQRHvG9GUyg+9uYTAlgOBl6DcO/WEGsa5m/TaZ2MfqeY6aSB sZC9V5wyjheMmUVW/nMU7ATwfZ+BU7LUj7EleGUQOTJRPSkjPpwGsQS5jbDp9YzM2sTI abdJCd3KQ1u9zvp1eM2sGFW+5PdZX1CafSlN2X9H/TQqxMJCMg2KlsuerUQfgRojALi7 hUMkRUcNQZ62AQonELUrKBU8AOHQYUfrAB3QU9Jt5ENiJEYhTgfVfLi1dwkNVNUAKIR+ eNYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b="IJwpSI/X"; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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 c11si15588823pgj.255.2019.02.13.09.46.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 09:46:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+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="IJwpSI/X"; spf=pass (google.com: best guess record for domain of batv+b68490c3fe13e616ccfb+5652+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+b68490c3fe13e616ccfb+5652+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=scDNPfor2+o2sRXISwjXU4Ei4L2S2/i4alFAOpD2+h8=; b=IJwpSI/XRhEAwk7ZzJEGRkrw9d jGjt38pnhTVOHXpxC14ac+cB89UHoVWK5xl6vc120cHNKmjpAJe+WlWjQ4411nbOc6irZz0FSwmem 4K7YXZvxLlhchihXJusyTq2KxOmh3Zire4J5JN9xn6Re3evnof3iJ9ozTK2DfNuGitsjCl4FEapYi jYEMJuAD4CvXUs/CjaxTOmI88L14bw049dP5+0t9rYM7cS+FnwGI9GlykHqqfk23Lorutp4E7xxym w0T8xV3/mfnDmG6FHmInh3GObANIk6lnQCvDs8uFmsghKNjU++Q/j5wo9Z4/gT6TVNzUcZIWiJK34 fGtsADkA==; Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtycL-0006ux-DF; Wed, 13 Feb 2019 17:46:41 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Alexander Viro , Russell King , Catalin Marinas , Will Deacon , Guan Xuetao , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/8] initramfs: poison freed initrd memory Date: Wed, 13 Feb 2019 18:46:21 +0100 Message-Id: <20190213174621.29297-9-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190213174621.29297-1-hch@lst.de> References: <20190213174621.29297-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 Various architectures including x86 poison the freed initrd memory. Do the same in the generic free_initrd_mem implementation and switch a few more architectures that are identical to the generic code over to it now. Signed-off-by: Christoph Hellwig --- arch/mips/mm/init.c | 8 -------- arch/s390/mm/init.c | 8 -------- arch/sparc/mm/init_32.c | 8 -------- arch/sparc/mm/init_64.c | 8 -------- init/initramfs.c | 3 ++- 5 files changed, 2 insertions(+), 33 deletions(-) diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index b521d8e2d359..a9a977d75838 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -492,14 +492,6 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end) printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10); } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, - "initrd"); -} -#endif - void (*free_init_pages_eva)(void *begin, void *end) = NULL; void __ref free_initmem(void) diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 3e82f66d5c61..25e3113091ea 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -154,14 +154,6 @@ void free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, - "initrd"); -} -#endif - unsigned long memory_block_size_bytes(void) { /* diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index d900952bfc5f..f0dbc0bde70f 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c @@ -299,14 +299,6 @@ void free_initmem (void) free_initmem_default(POISON_FREE_INITMEM); } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, - "initrd"); -} -#endif - void sparc_flush_page_to_ram(struct page *page) { unsigned long vaddr = (unsigned long)page_address(page); diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index b4221d3727d0..4179f0e11fd5 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -2602,14 +2602,6 @@ void free_initmem(void) } } -#ifdef CONFIG_BLK_DEV_INITRD -void free_initrd_mem(unsigned long start, unsigned long end) -{ - free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, - "initrd"); -} -#endif - pgprot_t PAGE_KERNEL __read_mostly; EXPORT_SYMBOL(PAGE_KERNEL); diff --git a/init/initramfs.c b/init/initramfs.c index f3aaa58ac63d..4a42ff3a2bd1 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -529,7 +529,8 @@ extern unsigned long __initramfs_size; void __weak free_initrd_mem(unsigned long start, unsigned long end) { - free_reserved_area((void *)start, (void *)end, -1, "initrd"); + free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, + "initrd"); } #ifdef CONFIG_KEXEC_CORE