Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1925842imm; Thu, 24 May 2018 03:03:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrYgK+5sJZoYlKs9XVpWu3HC2+wHKer0wqgDO0m9PohQwFP2PgDDmc71ZM8hoRAmoi4yvnq X-Received: by 2002:a17:902:7283:: with SMTP id d3-v6mr6792905pll.192.1527156184517; Thu, 24 May 2018 03:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156184; cv=none; d=google.com; s=arc-20160816; b=uJAMWJVdF4XH81n6aU3VkiO7MqmlkEgMvIwXbeZG/D2KAqakrt2Udu98cd+wDhyFlC +PpJHAGYd2EhJQ4+qKql1KlL4uyTN9VtyS/njOYd7YPCczZfHt3L0bYSmy97Cow2v/E0 fd7+vW1YscHdZpXykU/k0LOjTxmbIr6Icti5F33l2Vw1VRzPlYxBsowjz9kcLDaWSRug AKxI2eTio1QwOnE/mXiJ0iOZL3GN/10R2Vbyze+wnxa6XmnRuSnwO61U8yjEo4IhGgia PmJObsHGEVYM79yVazIOc086/KdXaqoFJ+4GJjtTttlMnEG08xNXnU8XuU7iNxg/gbAo hnvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=v2VpXqipmljw9ImwWyI/524zC+Dfocjoi0lBhgs5cV8=; b=cZF02XJY7BkBH+juD5ELnnuteteIKahkIyD1pCpF1LpxWym3xu9I8InvpuNuORy0BN zgiD0kagqM0q66AaiDJNOeSU/xgxsEo41RyIQF9MeP9qVlk23s+yUMLrM63E4j3UACvt KMluk/J2oArpkR1bd+GLJ+oKhJUo6N839KdtFGw7C584PoQKzBxp5csxTeSDpgaZPp50 VzFqszhUFxH07yQsB/YoZaZihy2o3ZhXz/fPVQIfk75cNf+H62yH/ZD7ybPBLsz887pb riOtxme9xWV8pW0HYqFQsNxiOFwevudjp4dC6k8P6zNBs9/UvNzk8WTtEHBUhWhp8IhI MoSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GXXWLr8n; 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 k127-v6si16207842pgk.256.2018.05.24.03.02.50; Thu, 24 May 2018 03:03:04 -0700 (PDT) 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=GXXWLr8n; 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 S1030934AbeEXKB0 (ORCPT + 99 others); Thu, 24 May 2018 06:01:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:46478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030878AbeEXKBR (ORCPT ); Thu, 24 May 2018 06:01:17 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 B60992088E; Thu, 24 May 2018 10:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156077; bh=neBuka5dlKaIAv5gz8g0nwsfGTJGwa4cNZHpFCco2Dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GXXWLr8n6mszkXqwjJF66WjneKGWKC1K3ee4jz8jpPCP5mwirKy2XTeyOuaktE1om I7sLxado0YVh2/Lrutem5jJ7+2+UlA77ZJIDZQS1Yw6IkozWXPAoU2C3R4QeXErGJd 8VUlPGjwdhmrPeqq2C526MlP2i2Ra5t4EniVOywI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Martin Schwidefsky Subject: [PATCH 4.16 054/161] s390: correct nospec auto detection init order Date: Thu, 24 May 2018 11:37:59 +0200 Message-Id: <20180524093024.923002276@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Schwidefsky [ Upstream commit 6a3d1e81a434fc311f224b8be77258bafc18ccc6 ] With CONFIG_EXPOLINE_AUTO=y the call of spectre_v2_auto_early() via early_initcall is done *after* the early_param functions. This overwrites any settings done with the nobp/no_spectre_v2/spectre_v2 parameters. The code patching for the kernel is done after the evaluation of the early parameters but before the early_initcall is done. The end result is a kernel image that is patched correctly but the kernel modules are not. Make sure that the nospec auto detection function is called before the early parameters are evaluated and before the code patching is done. Fixes: 6e179d64126b ("s390: add automatic detection of the spectre defense") Signed-off-by: Martin Schwidefsky Signed-off-by: Greg Kroah-Hartman --- arch/s390/include/asm/nospec-branch.h | 1 + arch/s390/kernel/nospec-branch.c | 8 ++------ arch/s390/kernel/setup.c | 3 +++ 3 files changed, 6 insertions(+), 6 deletions(-) --- a/arch/s390/include/asm/nospec-branch.h +++ b/arch/s390/include/asm/nospec-branch.h @@ -9,6 +9,7 @@ extern int nospec_disable; void nospec_init_branches(void); +void nospec_auto_detect(void); void nospec_revert(s32 *start, s32 *end); #endif /* __ASSEMBLY__ */ --- a/arch/s390/kernel/nospec-branch.c +++ b/arch/s390/kernel/nospec-branch.c @@ -72,7 +72,7 @@ static int __init nospectre_v2_setup_ear } early_param("nospectre_v2", nospectre_v2_setup_early); -static int __init spectre_v2_auto_early(void) +void __init nospec_auto_detect(void) { if (IS_ENABLED(CC_USING_EXPOLINE)) { /* @@ -87,11 +87,7 @@ static int __init spectre_v2_auto_early( * nobp setting decides what is done, this depends on the * CONFIG_KERNEL_NP option and the nobp/nospec parameters. */ - return 0; } -#ifdef CONFIG_EXPOLINE_AUTO -early_initcall(spectre_v2_auto_early); -#endif static int __init spectre_v2_setup_early(char *str) { @@ -102,7 +98,7 @@ static int __init spectre_v2_setup_early if (str && !strncmp(str, "off", 3)) nospec_disable = 1; if (str && !strncmp(str, "auto", 4)) - spectre_v2_auto_early(); + nospec_auto_detect(); return 0; } early_param("spectre_v2", spectre_v2_setup_early); --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -893,6 +893,9 @@ void __init setup_arch(char **cmdline_p) init_mm.end_data = (unsigned long) &_edata; init_mm.brk = (unsigned long) &_end; + if (IS_ENABLED(CONFIG_EXPOLINE_AUTO)) + nospec_auto_detect(); + parse_early_param(); #ifdef CONFIG_CRASH_DUMP /* Deactivate elfcorehdr= kernel parameter */