From patchwork Mon Jun 5 14:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 103279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2712901vqr; Mon, 5 Jun 2023 07:10:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74mtgq/7fHIryVdR5tXCzJY8GBIL6Se6/Lj1DVtCzqJZDEZ6tGwBk6mfeU1GzuqsfFfEwD X-Received: by 2002:a05:6a20:2d2c:b0:10c:c9ac:14c6 with SMTP id g44-20020a056a202d2c00b0010cc9ac14c6mr2014835pzl.39.1685974206289; Mon, 05 Jun 2023 07:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685974206; cv=none; d=google.com; s=arc-20160816; b=xcm2RoWHrGERySnVT7GjSZTojUaVHXWLYfuNlLGWTvJaUAN+X35RmTgSZB2XZPrVro e6LEq8VFCt9vLpEzy3JtBssJjJbMYgxTNapYgBjED2rt9gaz7N/23uErhiQY6/QZqHWD ipNw1hAUib1nk3016L9zPvjn37kzJ8Gv4APKmyPL7k79Zit22QELamlyC93AwF9F8D27 2zgvCYOYwcUsjEIZDld3od09o0dXXaXGRd55xvW5aEIi+aS0TyeIDWNYiPgP3gZAIDSI GMH6SuW3D5riIHmjkwWAGJgQH+zgRcE1vR5X/hjhnpTQoeO6ddL6cvtCCPswIEe4Cz2F 79Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=YwL6GodePffgzteSztSoNrAzEEzWjnEMobKmSpbgnQQ=; b=oxT1ZArmSbVn9VR+SmPfqFqZePbOHFjzgZGx8HykKCcXUW47ilcOMLnnRU5LtcbfZs efHkHOG8uBehQ1pitvOXgtbmhBzly74nNozVwZczBnCfDXilhwH971PBrNgOaXUWGdc2 9EYqaSdY8EaHm8MTjjEqCG1/DIEfPcdrQnkiB2JPE+udg1kLP1DUXMlc8p2MBvlTaYfR rnyXDLPqwmee9Z1fVw8XknlCErE4arjnqsMfxRn+wV9PTuJRVtwRgmlEhBczJqe28IA4 ujWZoNZKBFAKqF5wROcFJGPqM6lZh8rzz4iOPdoqNcj42rk7vB4FpUxPevDn9A+/aatA CY5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uK6l0WMs; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t186-20020a6381c3000000b0053eee37e16asi5597737pgd.522.2023.06.05.07.09.53; Mon, 05 Jun 2023 07:10:06 -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=@linutronix.de header.s=2020 header.b=uK6l0WMs; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234480AbjFEOJL (ORCPT + 99 others); Mon, 5 Jun 2023 10:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233906AbjFEOIe (ORCPT ); Mon, 5 Jun 2023 10:08:34 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55F50115; Mon, 5 Jun 2023 07:08:18 -0700 (PDT) Date: Mon, 05 Jun 2023 14:08:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685974095; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YwL6GodePffgzteSztSoNrAzEEzWjnEMobKmSpbgnQQ=; b=uK6l0WMsdT7fj+9rUg/aUp0Iq67pniMOOwTOApfQNVo0tfrH5AYE9f3SN3CQzeIK4pyGb6 Qd9P0hlt0EAVqa+HmQUAPKfhcnR8lgmsXvsRM9xFWX01198VoD95vT1Zu0DPG4p+1K3QbT Z8XI5IncSH8KCpwTrQF0QFQr+o7Cox1ZTZhjeDk13jiCT8x+rzOzRFSW+8m6j2SgQuKXcO 8KcKZRlZWliYeU9BcnnF2FojHiE82Wesci5/B9jA0YFvjBsrwlkk+nfQIryWMDLW0EAOVB FSmo1bv5bKInObRqpX4ijXGzmCvT2iMlO8fnPAPj6L/lK0QiZhP5w3CeRRrpKg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685974095; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YwL6GodePffgzteSztSoNrAzEEzWjnEMobKmSpbgnQQ=; b=5eAgTBwoZlrTmE1Xv+jLB4gvVGMJ3u9wsHZEtYW2NPfNde6CFe8feZyIz5IeaKFxGRWTlu E9pGNyrLyaBq0hBg== From: "tip-bot2 for Juergen Gross" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mtrr] x86/mtrr: Allocate mtrr_value array dynamically Cc: Juergen Gross , "Borislav Petkov (AMD)" , Michael Kelley , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230502120931.20719-10-jgross@suse.com> References: <20230502120931.20719-10-jgross@suse.com> MIME-Version: 1.0 Message-ID: <168597409531.404.16021958975934147782.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767872089440887612?= X-GMAIL-MSGID: =?utf-8?q?1767872089440887612?= The following commit has been merged into the x86/mtrr branch of tip: Commit-ID: 961c6a4326643e6588352b7f1f5d77364415386f Gitweb: https://git.kernel.org/tip/961c6a4326643e6588352b7f1f5d77364415386f Author: Juergen Gross AuthorDate: Tue, 02 May 2023 14:09:24 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Thu, 01 Jun 2023 15:04:33 +02:00 x86/mtrr: Allocate mtrr_value array dynamically The mtrr_value[] array is a static variable which is used only in a few configurations. Consuming 6kB is ridiculous for this case, especially as the array doesn't need to be that large and it can easily be allocated dynamically. Signed-off-by: Juergen Gross Signed-off-by: Borislav Petkov (AMD) Tested-by: Michael Kelley Link: https://lore.kernel.org/r/20230502120931.20719-10-jgross@suse.com Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/mtrr/legacy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mtrr/legacy.c b/arch/x86/kernel/cpu/mtrr/legacy.c index 7d379fb..d25882f 100644 --- a/arch/x86/kernel/cpu/mtrr/legacy.c +++ b/arch/x86/kernel/cpu/mtrr/legacy.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include +#include #include #include #include @@ -38,12 +39,15 @@ struct mtrr_value { unsigned long lsize; }; -static struct mtrr_value mtrr_value[MTRR_MAX_VAR_RANGES]; +static struct mtrr_value *mtrr_value; static int mtrr_save(void) { int i; + if (!mtrr_value) + return -ENOMEM; + for (i = 0; i < num_var_ranges; i++) { mtrr_if->get(i, &mtrr_value[i].lbase, &mtrr_value[i].lsize, @@ -72,6 +76,8 @@ static struct syscore_ops mtrr_syscore_ops = { void mtrr_register_syscore(void) { + mtrr_value = kcalloc(num_var_ranges, sizeof(*mtrr_value), GFP_KERNEL); + /* * The CPU has no MTRR and seems to not support SMP. They have * specific drivers, we use a tricky method to support