Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4126628ybc; Thu, 14 Nov 2019 22:27:34 -0800 (PST) X-Google-Smtp-Source: APXvYqz4OioviUGK3pn5nnWceOyhwt6XFeJaAYMPJoCHN4P9iV3DPouORHVhUKmS686AG+QH3SJg X-Received: by 2002:a17:906:48b:: with SMTP id f11mr11355709eja.225.1573799254258; Thu, 14 Nov 2019 22:27:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573799254; cv=none; d=google.com; s=arc-20160816; b=BhKLsm1AzRQg0ZCYGC5ARMIlBu+TqmHGRD/VPtJsJ5n15ZH46OwoRcy/5W7CzuZU9+ YRDca6oGzLhctL0rXTfnvsgxkTg4iQXEz+vM+ZnclRk0HkuGG6u/HuBsz7CnDI+S3nck USxfrWStb9IriGx6fOcL3GwTGXf5I6yCg5xX63l1beyj1OCash19Suzbwb7mpwZd03Rk LmIkrH2O9RTLjAsu32u4e63pv49WALNt9QMg1GYI/wt3hoOwZKMRPOT9SQD7J7TnT2zr wkUqmQzfcBj3YaGfZFgnrr0eFrULUoHS4/7l4WQRdMztiZ387JAdbUw3WOM792jJyRFn tZ9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AvvdwUFfZcZt8GtNHvnDyXYAuDx/+IxTMUFOlJbH2rE=; b=Ahyn4PWRqFiqrC+DQTz4l8Z3Gxe4eJnRh5T3L3r0plJgXrkSKJvh5UKqgZF193qZgg zQrWVWnbfpY1W7WGfET8cYYC6Z04AYtOgt93e2yCurJMRigcejK+A7kxPMgtNA+xv94U IljPx3L38L59OindxrgFgvieI7gOF5kyruzZfHdlNmNU+0w80H6v5nAn+HFGW31oy1rg xVJ8RKYtYR9yRRkZLU4ww1bPlvBj+GYLoDzHARKjjjj05/Jq8dAqOhcRX3Vk7pJnK1NI vFktx//UlgOHLhXy6fVv7Qoh6/wqjVsnVnmP7w091agNLBp0hD77n17mCty1CIIb/LHP Zqqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PmJucgYo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si4833910ejz.344.2019.11.14.22.27.08; Thu, 14 Nov 2019 22:27:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PmJucgYo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727897AbfKOGWz (ORCPT + 99 others); Fri, 15 Nov 2019 01:22:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:52422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727868AbfKOGWw (ORCPT ); Fri, 15 Nov 2019 01:22:52 -0500 Received: from localhost (unknown [104.132.150.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AAF9720637; Fri, 15 Nov 2019 06:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573798971; bh=7qrlrb8rSjnvQiBDqWsbVKN+RN131lilHKx8YobWuiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PmJucgYo9UjBEgiaUM1u0NQzO/FYvC8Zfp4aPVm7fCaySmMz+ClF2ztOiRInaJt5l jvvHMoacz1XktigrXMd9S0fVlhWIl9cuhhw+5YBkrPmp0xhuncWF9amoDqesYLQn7q nXU7VoSysyG0b1FDjwgX7HprGYPFzyFaWJ3L8xtM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tyler Hicks , Paolo Bonzini , Thomas Gleixner , Ben Hutchings Subject: [PATCH 4.9 27/31] cpu/speculation: Uninline and export CPU mitigations helpers Date: Fri, 15 Nov 2019 14:20:56 +0800 Message-Id: <20191115062019.904435211@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191115062009.813108457@linuxfoundation.org> References: <20191115062009.813108457@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tyler Hicks commit 731dc9df975a5da21237a18c3384f811a7a41cc6 upstream. A kernel module may need to check the value of the "mitigations=" kernel command line parameter as part of its setup when the module needs to perform software mitigations for a CPU flaw. Uninline and export the helper functions surrounding the cpu_mitigations enum to allow for their usage from a module. Lastly, privatize the enum and cpu_mitigations variable since the value of cpu_mitigations can be checked with the exported helper functions. Signed-off-by: Tyler Hicks Signed-off-by: Paolo Bonzini Signed-off-by: Thomas Gleixner Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- include/linux/cpu.h | 25 ++----------------------- kernel/cpu.c | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 24 deletions(-) --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -287,28 +287,7 @@ static inline int cpuhp_smt_enable(void) static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; } #endif -/* - * These are used for a global "mitigations=" cmdline option for toggling - * optional CPU mitigations. - */ -enum cpu_mitigations { - CPU_MITIGATIONS_OFF, - CPU_MITIGATIONS_AUTO, - CPU_MITIGATIONS_AUTO_NOSMT, -}; - -extern enum cpu_mitigations cpu_mitigations; - -/* mitigations=off */ -static inline bool cpu_mitigations_off(void) -{ - return cpu_mitigations == CPU_MITIGATIONS_OFF; -} - -/* mitigations=auto,nosmt */ -static inline bool cpu_mitigations_auto_nosmt(void) -{ - return cpu_mitigations == CPU_MITIGATIONS_AUTO_NOSMT; -} +extern bool cpu_mitigations_off(void); +extern bool cpu_mitigations_auto_nosmt(void); #endif /* _LINUX_CPU_H_ */ --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -2235,7 +2235,18 @@ void __init boot_cpu_hotplug_init(void) this_cpu_write(cpuhp_state.state, CPUHP_ONLINE); } -enum cpu_mitigations cpu_mitigations __ro_after_init = CPU_MITIGATIONS_AUTO; +/* + * These are used for a global "mitigations=" cmdline option for toggling + * optional CPU mitigations. + */ +enum cpu_mitigations { + CPU_MITIGATIONS_OFF, + CPU_MITIGATIONS_AUTO, + CPU_MITIGATIONS_AUTO_NOSMT, +}; + +static enum cpu_mitigations cpu_mitigations __ro_after_init = + CPU_MITIGATIONS_AUTO; static int __init mitigations_parse_cmdline(char *arg) { @@ -2252,3 +2263,17 @@ static int __init mitigations_parse_cmdl return 0; } early_param("mitigations", mitigations_parse_cmdline); + +/* mitigations=off */ +bool cpu_mitigations_off(void) +{ + return cpu_mitigations == CPU_MITIGATIONS_OFF; +} +EXPORT_SYMBOL_GPL(cpu_mitigations_off); + +/* mitigations=auto,nosmt */ +bool cpu_mitigations_auto_nosmt(void) +{ + return cpu_mitigations == CPU_MITIGATIONS_AUTO_NOSMT; +} +EXPORT_SYMBOL_GPL(cpu_mitigations_auto_nosmt);