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: 103290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2720257vqr; Mon, 5 Jun 2023 07:20:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ptsNW814Zaj6qnSDR+WIqv76V0NKcv5L9f/EFk+b4crgkgtovi6XXmMC2hh5EFmaRsDF2 X-Received: by 2002:a05:6359:324:b0:129:ca25:6486 with SMTP id ef36-20020a056359032400b00129ca256486mr920339rwb.29.1685974833337; Mon, 05 Jun 2023 07:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685974833; cv=none; d=google.com; s=arc-20160816; b=MSgUAxfEp98r7AtS9FUzwgnyvzSCg6nHgUdSoksUMMFSICM+rd9sEY6CYRXWsXbgiI x/gwQXu+Rdw4QKWy1c503c8ZSSbUrW+qeqCKds9c9adhGnolsMEY/gvSBcv8EkYdhBmg +AnkCgmR1EL5dPRwhroGO7RrQN3NfJo4GNXUiO2rCY5WP+aDvQQOhBuOHlPOLNcx4iBU WzeZB/3rpm4dDC+1ktzOcdgMucV7VYPvNmaa0u50Xf3VqCfc/HCI93EMuxaO7RaNIZ49 4bYI9tRZE263RRuLdNoiZuCz9FhwmewvSMEV9lOv4NI2YU/Y43vTFF7id3KmbGMRuMJ8 burQ== 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=flAU8Kxin3DTwjlsDB2c7PPQk1Z5ZpuKbdc2pbw8unw=; b=MxIhEw+wcTbDaFGUDuk3A0TtG9GKeKEbMAsA5cdCnI8mH7yLeCiweBwwPCrveZneoX PhfS7UqnMiyX2+4qyGqy9s/mcnEJfjY6hV8Sy3cEgS+K2ljdNgjC811Q7IcwCchrT5gO nA3NFOZMpMppuWzju4VBQ9WqO+2VsKjCxyA6MBTHTJ0yQkP7HODUP8c7XBzfnKTBiO/o bCzI8smcivU32fFrsbWG4qOtAx0x5HZK1frHJjUte5UFlKHJwglBPMKd7vftL1IkYGDt vC6qNOu0nuxN4zKODGnSs0z8xeMAHpTtnk29rEdBPQ9fbE9GQ5N6BOAqjMjgHVUyu60l CpmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=01ZIvxV6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="/4wSTnir"; 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 x18-20020a17090aca1200b00235dc16de3asi7481860pjt.16.2023.06.05.07.20.21; Mon, 05 Jun 2023 07:20:33 -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=01ZIvxV6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="/4wSTnir"; 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 S229878AbjFEOJU (ORCPT + 99 others); Mon, 5 Jun 2023 10:09:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234202AbjFEOIe (ORCPT ); Mon, 5 Jun 2023 10:08:34 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C7F100; 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=1685974096; 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=flAU8Kxin3DTwjlsDB2c7PPQk1Z5ZpuKbdc2pbw8unw=; b=01ZIvxV6sxX09zqB3WyumyD0LvvmROtUBVIF0ZqM4rO+ZZhUJ2SmASKrZCxcT4jKoX8QAX DLx5s/Lya2T14dzSIOracDvgT2/7XNCJHisM9sobybXZJHuXKueHojVKSTEu7QRCXw9Fmo xy4f7vt99CoY+/R4JMLUG/cZgaho3m1JIy5pzh5RJ6XInxkh/XiSXUiD65bQu4nNXQaXjA H3D5ShFiOvV6PsmhooKgNVYswfr0bvi4TkFo2kV14rRvrv+sxbtn7tOQBNri3q7y18QHGN A0YGlk9HXc/z5gwN55ZyJERL0YuCvLm/I/C2IsfY28MIT+31rFqAfioy7U8TFg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685974096; 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=flAU8Kxin3DTwjlsDB2c7PPQk1Z5ZpuKbdc2pbw8unw=; b=/4wSTnir7TH5e1pHiPxpNRw7d7duAyR8PMw4cgM23e76Qrrzxb/BpyMTEpk+ZfyQvDMF3V iKMGwLBtn997Q4Bg== 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: Have only one set_mtrr() variant Cc: Juergen Gross , "Borislav Petkov (AMD)" , Michael Kelley , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230502120931.20719-8-jgross@suse.com> References: <20230502120931.20719-8-jgross@suse.com> MIME-Version: 1.0 Message-ID: <168597409590.404.1718981891238519233.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?1767872746950510382?= X-GMAIL-MSGID: =?utf-8?q?1767872746950510382?= The following commit has been merged into the x86/mtrr branch of tip: Commit-ID: 34cf2d19552bbe3b72b34fc859a19cd5070c466a Gitweb: https://git.kernel.org/tip/34cf2d19552bbe3b72b34fc859a19cd5070c466a Author: Juergen Gross AuthorDate: Tue, 02 May 2023 14:09:22 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Thu, 01 Jun 2023 15:04:32 +02:00 x86/mtrr: Have only one set_mtrr() variant Today there are two variants of set_mtrr(): one calling stop_machine() and one calling stop_machine_cpuslocked(). The first one (set_mtrr()) has only one caller, and this caller is running only when resuming from suspend when the interrupts are still off and only one CPU is active. Additionally this code is used only on rather old 32-bit CPUs not supporting SMP. For these reasons the first variant can be replaced by a simple call of mtrr_if->set(). Rename the second variant set_mtrr_cpuslocked() to set_mtrr() now that there is only one variant left, in order to have a shorter function name. Signed-off-by: Juergen Gross Signed-off-by: Borislav Petkov (AMD) Tested-by: Michael Kelley Link: https://lore.kernel.org/r/20230502120931.20719-8-jgross@suse.com Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/mtrr/mtrr.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c index 85113af..007ecca 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.c +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c @@ -173,20 +173,8 @@ static inline int types_compatible(mtrr_type type1, mtrr_type type2) * Note that the mechanism is the same for UP systems, too; all the SMP stuff * becomes nops. */ -static void -set_mtrr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type type) -{ - struct set_mtrr_data data = { .smp_reg = reg, - .smp_base = base, - .smp_size = size, - .smp_type = type - }; - - stop_machine(mtrr_rendezvous_handler, &data, cpu_online_mask); -} - -static void set_mtrr_cpuslocked(unsigned int reg, unsigned long base, - unsigned long size, mtrr_type type) +static void set_mtrr(unsigned int reg, unsigned long base, unsigned long size, + mtrr_type type) { struct set_mtrr_data data = { .smp_reg = reg, .smp_base = base, @@ -316,7 +304,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, /* Search for an empty MTRR */ i = mtrr_if->get_free_region(base, size, replace); if (i >= 0) { - set_mtrr_cpuslocked(i, base, size, type); + set_mtrr(i, base, size, type); if (likely(replace < 0)) { mtrr_usage_table[i] = 1; } else { @@ -324,7 +312,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, if (increment) mtrr_usage_table[i]++; if (unlikely(replace != i)) { - set_mtrr_cpuslocked(replace, 0, 0, 0); + set_mtrr(replace, 0, 0, 0); mtrr_usage_table[replace] = 0; } } @@ -452,7 +440,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) goto out; } if (--mtrr_usage_table[reg] < 1) - set_mtrr_cpuslocked(reg, 0, 0, 0); + set_mtrr(reg, 0, 0, 0); error = reg; out: mutex_unlock(&mtrr_mutex); @@ -582,9 +570,9 @@ static void mtrr_restore(void) for (i = 0; i < num_var_ranges; i++) { if (mtrr_value[i].lsize) { - set_mtrr(i, mtrr_value[i].lbase, - mtrr_value[i].lsize, - mtrr_value[i].ltype); + mtrr_if->set(i, mtrr_value[i].lbase, + mtrr_value[i].lsize, + mtrr_value[i].ltype); } } }