Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp904414rwb; Wed, 28 Sep 2022 10:28:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5xiqCwkfSqUhtG7WZaqic4TuHlVfbkFW1bTRFH9hJ+GuJTmOdyBJb7JP9jAQfVhfKAoIlX X-Received: by 2002:aa7:c549:0:b0:457:421d:449c with SMTP id s9-20020aa7c549000000b00457421d449cmr17997422edr.260.1664386127590; Wed, 28 Sep 2022 10:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664386127; cv=none; d=google.com; s=arc-20160816; b=psHp2+oDgI/2jTVEQg5imv1Py0o/LQadZE78kn092RtP/EMv/WRF6mTCDBVYeOdCGf 2ceChwjb+J5AQEQekHjQUn8yhO253VPuF55raq1Ehb5tlGZ88PX0ADzAPZTDOy5K8WlI LyVeN9UqGoqehjOGLy1/jVtYO8uWo2e5uibk74AKhiCiGVAK5re/GOzxQXA3+l1vUGjh uG1XH1qU4BuBVaLu27QZ+rCk1FtFQI05WnyMNN6Z7dtnGWnYUXxbRYg517n1G4addwD7 4NeicUQh9GhUCCndEb/j7iAfd2i8FGlj5z4agsDDMWcuLEd6dvd31LenN4oTr9vb+1Uq Haog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WaGpA9Je9H07sCeEfaw6oqmp71ONkeh2idDIs+QiNXw=; b=Qmr0LcSXnNhvPk/tiXTdivC1YswaHu/G8PS++686geE8IRhTjD0oTap9F4dT4hCFj9 FBt3Fci24SSAY9efQ3ba7MFnh8J0jZWiIrPgLf1s9dxXWuESRLo+Hja01nan9FUPS2ID 1BUWIFiY/6w4OxP18Thpc29II+ZK9yLSZJmff5sh2sYcce5ayvQb7Zr9YFyjLlHcV+RA HH0JDfbAZ3d4qXVnUyDp+uQSYs0vYyH37+/WhlV9ZjhHvKXuGNmBiIrKFSrQKGudFfdT 6sY4xFJmNVrAxi2mBvNdln+k+V+NbvaUsw5zNVeMo7guLag8zOtNiWh9QTz6OYYJEjzJ CxsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=DZcvbNRX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r28-20020a056402035c00b00442296a8407si4968766edw.629.2022.09.28.10.28.21; Wed, 28 Sep 2022 10:28:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=DZcvbNRX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233404AbiI1QjF (ORCPT + 99 others); Wed, 28 Sep 2022 12:39:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbiI1QjD (ORCPT ); Wed, 28 Sep 2022 12:39:03 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF0A4B6D66 for ; Wed, 28 Sep 2022 09:39:02 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7ee329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7ee:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 766591EC058B; Wed, 28 Sep 2022 18:38:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1664383137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=WaGpA9Je9H07sCeEfaw6oqmp71ONkeh2idDIs+QiNXw=; b=DZcvbNRXx2Ancght4ZlZ/Tft8TaDUM8B3ldBqhHG86Hy1epnLbUlFhhQ+Ht9AiojDkivYp wXGnXOeGZRdXLMUzyXRJMK1gZIdERaWXQWvJykGQum66YWiFkgdPDcrZZJ58ZMQKgOAc1O OJfJQTVogRRVqJLW2rlenyDqNyZZmw0= Date: Wed, 28 Sep 2022 18:38:53 +0200 From: Borislav Petkov To: Eric DeVolder Cc: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com Subject: Re: [PATCH v12 7/7] x86/crash: Add x86 crash hotplug support Message-ID: References: <20220909210509.6286-1-eric.devolder@oracle.com> <20220909210509.6286-8-eric.devolder@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 28, 2022 at 06:07:24PM +0200, Borislav Petkov wrote: > #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_MEMORY_HOTPLUG) > /* Ensure elfcorehdr segment large enough for hotplug changes */ > @@ -407,9 +408,8 @@ int crash_load_segments(struct kimage *image) > image->elf_headers_sz = kbuf.memsz; > image->elfcorehdr_index = image->nr_segments; > image->elfcorehdr_index_valid = true; And that ifdeffery above can be made more readable too: diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index a526c893abe8..7aab6e942761 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -399,16 +399,15 @@ int crash_load_segments(struct kimage *image) image->elf_headers_sz = kbuf.bufsz; kbuf.memsz = kbuf.bufsz; -#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_MEMORY_HOTPLUG) /* Ensure elfcorehdr segment large enough for hotplug changes */ - kbuf.memsz = - (CONFIG_NR_CPUS_DEFAULT + CONFIG_CRASH_MAX_MEMORY_RANGES) * - sizeof(Elf64_Phdr); - /* Mark as usable to crash kernel, else crash kernel fails on boot */ - image->elf_headers_sz = kbuf.memsz; - image->elfcorehdr_index = image->nr_segments; - image->elfcorehdr_index_valid = true; -#endif + if (IS_ENABLED(CONFIG_CRASH_MAX_MEMORY_RANGES)) { + kbuf.memsz = (CONFIG_NR_CPUS_DEFAULT + CONFIG_CRASH_MAX_MEMORY_RANGES) * sizeof(Elf64_Phdr); + + /* Mark as usable to crash kernel, else crash kernel fails on boot */ + image->elf_headers_sz = kbuf.memsz; + image->elfcorehdr_index = image->nr_segments; + image->elfcorehdr_index_valid = true; + } kbuf.buf_align = ELF_CORE_HEADER_ALIGN; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette