From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E791C43331 for ; Fri, 27 Mar 2020 16:56:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EBAEC2074A for ; Fri, 27 Mar 2020 16:56:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PDxDGkxW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBAEC2074A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cFcsuZOJc9Bj1ypgHf5C4ajxPgItINrtgrrzdonhiZU=; b=PDxDGkxWCyOTqT LVdV422+8e/iBIJlEOU+8oE3ymjRcUHoMYnJsWQPZk8BKJktzvCkAYWsiBLNrVd2cRi6a9+mYnu76 7vl7QSd5nxP4b/MPxEPWu1fkNdUtpv0FwPnO+Qw175MOHH9jTSMyRl1keRrZkVqnf0wGCFtEibf/p TC4UlzUbxqy0YBT4gqugQ1DL/WWIg7PYNQ9/IZxxYg3Uqb9oUVW0VKHkN9gVEv2qa3iZl9u1w3sFU ETKn3Ls5iKYvwgK7TiE/FaJS6e9ycF1BRMy/h7TpFiRpvG8XoJGdBa+yIdHeDfengWRoyfhri0DYO bN5ehWfRpocpU/Uuvuqg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jHsHH-00067D-Oo; Fri, 27 Mar 2020 16:56:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jHsHE-00065w-6p; Fri, 27 Mar 2020 16:56:13 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 16AFF1FB; Fri, 27 Mar 2020 09:56:11 -0700 (PDT) Received: from [172.16.1.108] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9FF4A3F71E; Fri, 27 Mar 2020 09:56:09 -0700 (PDT) Subject: Re: [PATCH 1/3] kexec: Prevent removal of memory in use by a loaded kexec image To: David Hildenbrand References: <20200326180730.4754-1-james.morse@arm.com> <20200326180730.4754-2-james.morse@arm.com> <321e6bf7-e898-7701-dd60-6c25237ff9cd@redhat.com> From: James Morse Openpgp: preference=signencrypt Message-ID: Date: Fri, 27 Mar 2020 16:56:04 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <321e6bf7-e898-7701-dd60-6c25237ff9cd@redhat.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200327_095612_296866_A5AF745D X-CRM114-Status: GOOD ( 17.59 ) 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: Anshuman Khandual , Catalin Marinas , Bhupesh Sharma , kexec@lists.infradead.org, linux-mm@kvack.org, Eric Biederman , Andrew Morton , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi David, On 3/27/20 9:30 AM, David Hildenbrand wrote: > On 26.03.20 19:07, James Morse wrote: >> An image loaded for kexec is not stored in place, instead its segments >> are scattered through memory, and are re-assembled when needed. In the >> meantime, the target memory may have been removed. >> >> Because mm is not aware that this memory is still in use, it allows it >> to be removed. >> >> Add a memory notifier to prevent the removal of memory regions that >> overlap with a loaded kexec image segment. e.g., when triggered from the >> Qemu console: >> | kexec_core: memory region in use >> | memory memory32: Offline failed. >> >> Signed-off-by: James Morse >> --- >> kernel/kexec_core.c | 56 +++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 56 insertions(+) >> >> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c >> index c19c0dad1ebe..ba1d91e868ca 100644 >> --- a/kernel/kexec_core.c >> +++ b/kernel/kexec_core.c > E.g., in kernel/kexec_core.c:kimage_alloc_pages() > > "SetPageReserved(pages + i);" > > Pages that are reserved cannot get offlined. How are you able to trigger > that before this patch? (where is the allocation path for kexec, which > will not set the pages reserved?) This sets page reserved on the memory it gets back from alloc_pages() in kimage_alloc_pages(). This is when you load the image[0]. The problem I see is for the target or destination memory once you execute the image. Once machine_kexec() runs, it tries to write to this, assuming it is still present... How can I make the commit message clearer? 're-assembled' and 'target memory' aren't quite cutting it, is there are a correct term to use? (destination?) Thanks, James [0] Just to convince myself: | kimage_alloc_pages+0x30/0x15c | kimage_alloc_page+0x210/0x7d8 | kimage_load_segment+0x14c/0x8c8 | __arm64_sys_kexec_load+0x4f0/0x720 | do_el0_svc+0x13c/0x3c0 | el0_sync_handler+0x9c/0x3c0 | el0_sync+0x158/0x180 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel