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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 77B0CC28CBC for ; Sat, 9 May 2020 15:18:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 27E1E20820 for ; Sat, 9 May 2020 15:18:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27E1E20820 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xmission.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7ED7E900009; Sat, 9 May 2020 11:18:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C4C28E0003; Sat, 9 May 2020 11:18:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DA7B900009; Sat, 9 May 2020 11:18:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 535B68E0003 for ; Sat, 9 May 2020 11:18:21 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 07D83181AEF1A for ; Sat, 9 May 2020 15:18:21 +0000 (UTC) X-FDA: 76797536802.01.steam42_48d1e2cc31c5e X-HE-Tag: steam42_48d1e2cc31c5e X-Filterd-Recvd-Size: 6442 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Sat, 9 May 2020 15:18:20 +0000 (UTC) Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jXRF4-0002RL-57; Sat, 09 May 2020 09:18:18 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jXRF3-00073s-70; Sat, 09 May 2020 09:18:18 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: David Hildenbrand Cc: James Morse , kexec@lists.infradead.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Dave Young , Baoquan He References: <20200501165701.24587-1-james.morse@arm.com> <40b07632-b044-d1cd-96a2-81eec3da93e7@redhat.com> Date: Sat, 09 May 2020 10:14:49 -0500 In-Reply-To: <40b07632-b044-d1cd-96a2-81eec3da93e7@redhat.com> (David Hildenbrand's message of "Fri, 1 May 2020 19:26:39 +0200") Message-ID: <8736892l92.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1jXRF3-00073s-70;;;mid=<8736892l92.fsf@x220.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/78Q2ZzN+DiVqOLa3MERJ4/bRoZCWRbLY= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] kexec: Discard loaded image on memory hotplug X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) 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: David Hildenbrand writes: > On 01.05.20 18:57, James Morse wrote: >> On x86, the kexec payload contains a copy of the current memory map. >> If memory is added or removed, this copy of the memory map becomes >> stale. Getting this wrong may prevent the next kernel from booting. >> The first kernel may die if it tries to re-assemble the next kernel >> in memory that has been removed. >> >> Discard the loaded kexec image when the memory map changes, user-space >> should reload it. >> >> Kdump is unaffected, as it is placed within the crashkernel reserved >> memory area and only uses this memory. The stale memory map may affect >> generation of the vmcore, but the kdump kernel should be in a position >> to validate it. >> >> Signed-off-by: James Morse >> --- >> This patch obsoletes: >> * kexec/memory_hotplug: Prevent removal and accidental use >> https://lore.kernel.org/linux-arm-kernel/20200326180730.4754-1-james.morse@arm.com/ >> >> kernel/kexec_core.c | 40 ++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 40 insertions(+) >> >> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c >> index c19c0dad1ebe..e1901e5bd4b5 100644 >> --- a/kernel/kexec_core.c >> +++ b/kernel/kexec_core.c >> @@ -12,6 +12,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -22,10 +23,12 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -1219,3 +1222,40 @@ void __weak arch_kexec_protect_crashkres(void) >> >> void __weak arch_kexec_unprotect_crashkres(void) >> {} >> + >> +/* >> + * If the memory layout changes, any loaded kexec image should be evicted >> + * as it may contain a copy of the (now stale) memory map. This also means >> + * we don't need to check the memory is still present when re-assembling the >> + * new kernel at machine_kexec() time. >> + */ > > Onlining/offlining is not a change of the memory map. Phrasing it that way is non-sense. What is important is memory available in the system. A memory map is just a reflection upon that, a memory map is not the definition of truth. So if this notifier reflects when memory is coming and going on the system this is a reasonable approach. Do these notifiers might fire for special kinds of memory that should only be used for very special purposes? This change with the addition of some filters say to limit taking action to MEM_ONLINE and MEM_OFFLINE looks reasonable to me. Probably also filtering out special kinds of memory that is not gernally useful. Eric 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=-6.8 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 autolearn=unavailable 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 59857C28CBC for ; Sat, 9 May 2020 15:18:42 +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 0A3122072F for ; Sat, 9 May 2020 15:18:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bxJu5oEU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A3122072F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xmission.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:Subject:MIME-Version:Message-ID: In-Reply-To:Date:References:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aG9xWFyThwJY8kdOlasSgLC+GMGIGwfdN40F+rUIWeE=; b=bxJu5oEU/y+hev b/SvlNR50T8pBwJf44B8y+wPV9Be6v9kkdUc6B225knAD0sQAOVTjqJpRzhjDWV1kWDa8lPjcbT8S YGysPFtpNQQ+rnaicbLqBjqENEv+9yuLv69N6BKS+XCC/sO/bB2XxqkB9oTWSvfY4c+IbYY8By3po 3WttIqSCzpTDsjKojke8ANYAquu8uVJWHKz7XEOMoLOPGA2yM6R5JGWmDlKZS7jxT2LiscyTDZhmt v7R7RFM9kDW1JokHF2E76P5CmYDB8eJzzdd/YPgQQjpPwwillG949D6b4HqnvvLRxqQt3vJt56uwJ r+9jprxcxlTS1Ako1NEA==; 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 1jXRFR-0003WQ-AC; Sat, 09 May 2020 15:18:41 +0000 Received: from out02.mta.xmission.com ([166.70.13.232]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jXRFN-0003TB-8A; Sat, 09 May 2020 15:18:39 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jXRF4-0002RL-57; Sat, 09 May 2020 09:18:18 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jXRF3-00073s-70; Sat, 09 May 2020 09:18:18 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: David Hildenbrand References: <20200501165701.24587-1-james.morse@arm.com> <40b07632-b044-d1cd-96a2-81eec3da93e7@redhat.com> Date: Sat, 09 May 2020 10:14:49 -0500 In-Reply-To: <40b07632-b044-d1cd-96a2-81eec3da93e7@redhat.com> (David Hildenbrand's message of "Fri, 1 May 2020 19:26:39 +0200") Message-ID: <8736892l92.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=1jXRF3-00073s-70; ; ; mid=<8736892l92.fsf@x220.int.ebiederm.org>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.160.95; ; ; frm=ebiederm@xmission.com; ; ; spf=neutral X-XM-AID: U2FsdGVkX1/78Q2ZzN+DiVqOLa3MERJ4/bRoZCWRbLY= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] kexec: Discard loaded image on memory hotplug X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200509_081837_289183_AA1829A0 X-CRM114-Status: GOOD ( 12.79 ) 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: Baoquan He , kexec@lists.infradead.org, linux-mm@kvack.org, James Morse , Dave Young , 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 David Hildenbrand writes: > On 01.05.20 18:57, James Morse wrote: >> On x86, the kexec payload contains a copy of the current memory map. >> If memory is added or removed, this copy of the memory map becomes >> stale. Getting this wrong may prevent the next kernel from booting. >> The first kernel may die if it tries to re-assemble the next kernel >> in memory that has been removed. >> >> Discard the loaded kexec image when the memory map changes, user-space >> should reload it. >> >> Kdump is unaffected, as it is placed within the crashkernel reserved >> memory area and only uses this memory. The stale memory map may affect >> generation of the vmcore, but the kdump kernel should be in a position >> to validate it. >> >> Signed-off-by: James Morse >> --- >> This patch obsoletes: >> * kexec/memory_hotplug: Prevent removal and accidental use >> https://lore.kernel.org/linux-arm-kernel/20200326180730.4754-1-james.morse@arm.com/ >> >> kernel/kexec_core.c | 40 ++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 40 insertions(+) >> >> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c >> index c19c0dad1ebe..e1901e5bd4b5 100644 >> --- a/kernel/kexec_core.c >> +++ b/kernel/kexec_core.c >> @@ -12,6 +12,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -22,10 +23,12 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -1219,3 +1222,40 @@ void __weak arch_kexec_protect_crashkres(void) >> >> void __weak arch_kexec_unprotect_crashkres(void) >> {} >> + >> +/* >> + * If the memory layout changes, any loaded kexec image should be evicted >> + * as it may contain a copy of the (now stale) memory map. This also means >> + * we don't need to check the memory is still present when re-assembling the >> + * new kernel at machine_kexec() time. >> + */ > > Onlining/offlining is not a change of the memory map. Phrasing it that way is non-sense. What is important is memory available in the system. A memory map is just a reflection upon that, a memory map is not the definition of truth. So if this notifier reflects when memory is coming and going on the system this is a reasonable approach. Do these notifiers might fire for special kinds of memory that should only be used for very special purposes? This change with the addition of some filters say to limit taking action to MEM_ONLINE and MEM_OFFLINE looks reasonable to me. Probably also filtering out special kinds of memory that is not gernally useful. Eric _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: From: ebiederm@xmission.com (Eric W. Biederman) References: <20200501165701.24587-1-james.morse@arm.com> <40b07632-b044-d1cd-96a2-81eec3da93e7@redhat.com> Date: Sat, 09 May 2020 10:14:49 -0500 In-Reply-To: <40b07632-b044-d1cd-96a2-81eec3da93e7@redhat.com> (David Hildenbrand's message of "Fri, 1 May 2020 19:26:39 +0200") Message-ID: <8736892l92.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Subject: Re: [PATCH] kexec: Discard loaded image on memory hotplug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: David Hildenbrand Cc: Baoquan He , kexec@lists.infradead.org, linux-mm@kvack.org, James Morse , Dave Young , linux-arm-kernel@lists.infradead.org David Hildenbrand writes: > On 01.05.20 18:57, James Morse wrote: >> On x86, the kexec payload contains a copy of the current memory map. >> If memory is added or removed, this copy of the memory map becomes >> stale. Getting this wrong may prevent the next kernel from booting. >> The first kernel may die if it tries to re-assemble the next kernel >> in memory that has been removed. >> >> Discard the loaded kexec image when the memory map changes, user-space >> should reload it. >> >> Kdump is unaffected, as it is placed within the crashkernel reserved >> memory area and only uses this memory. The stale memory map may affect >> generation of the vmcore, but the kdump kernel should be in a position >> to validate it. >> >> Signed-off-by: James Morse >> --- >> This patch obsoletes: >> * kexec/memory_hotplug: Prevent removal and accidental use >> https://lore.kernel.org/linux-arm-kernel/20200326180730.4754-1-james.morse@arm.com/ >> >> kernel/kexec_core.c | 40 ++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 40 insertions(+) >> >> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c >> index c19c0dad1ebe..e1901e5bd4b5 100644 >> --- a/kernel/kexec_core.c >> +++ b/kernel/kexec_core.c >> @@ -12,6 +12,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -22,10 +23,12 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -1219,3 +1222,40 @@ void __weak arch_kexec_protect_crashkres(void) >> >> void __weak arch_kexec_unprotect_crashkres(void) >> {} >> + >> +/* >> + * If the memory layout changes, any loaded kexec image should be evicted >> + * as it may contain a copy of the (now stale) memory map. This also means >> + * we don't need to check the memory is still present when re-assembling the >> + * new kernel at machine_kexec() time. >> + */ > > Onlining/offlining is not a change of the memory map. Phrasing it that way is non-sense. What is important is memory available in the system. A memory map is just a reflection upon that, a memory map is not the definition of truth. So if this notifier reflects when memory is coming and going on the system this is a reasonable approach. Do these notifiers might fire for special kinds of memory that should only be used for very special purposes? This change with the addition of some filters say to limit taking action to MEM_ONLINE and MEM_OFFLINE looks reasonable to me. Probably also filtering out special kinds of memory that is not gernally useful. Eric _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec