Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2931812ybx; Fri, 8 Nov 2019 11:26:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyGKNWJNVgUHUUtvRFkOiQ/lidrqA3kVijQnZmJ11yRa9/tLGZ6s4l+VrdYXb2Xlqb606kw X-Received: by 2002:aa7:c301:: with SMTP id l1mr11916150edq.209.1573241196116; Fri, 08 Nov 2019 11:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573241196; cv=none; d=google.com; s=arc-20160816; b=rGQP+PyJS31MrOLhl5fhfYnjFzXIJ7xWlcbGhasKlpN0zf+8Hq/lL5EBu4n4pmFIDK SOh5qfd3YdNEuRA3g/PpYiLSQWBzyqYwdo870RmxyzUpCgfzg/Lv7KY/T5pLG+oDFP08 0aN+B01rCaVgPKPj+aBWy99rsgfHhreXLOyMsbMAoKQyyjCeViKFWJqh90k+uCk6Xkke /jr6BEOXafKpEDqgq2H93tlZ2f1iavNF557XZzp2TdIY3RxlUArWS9ItmY6GwDzbmokU f1BHx4r3F5TFjBsyRqYnZaG2BuIbGiw2vPek99lPaGpogJGgF7zpULK4OlWs0x+xJIO/ Orig== 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=xk88z10vXzt9cacCl1FcWyeQnARxRMh48TuQxNvUMBc=; b=cf9pOaDRA1iYWgVYA8UU7Gx0FCJ422qdmyRhFs15rdONEc7AHCLazphbP+orFaqcSW ERC/ryRF9JVZmIR5bUgV5xR/OLYagpTKESBKcOtn+sd6zuMB5X5ryYIRcbAYaVabsp7W qiNPxk+o3nta0dYIzgYlU2aXCekAJaV2YDUSnPrQXRv4JrtNzCXZhuT4HRyRErYIou7W xI+lX/Zq0onU7TJsnAsRXHnEPLAHdha1z8WsLo0UfNFov0NaFRXvgvUaQSUx3Jckakr0 hDb5CMrLiY9u6HWEa5juy7YrzVEGSBq0w2Zm1b/m5dP65faHOJJlV25FOIORs4pYSy4y HPMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2HaTW9Qm; 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 z15si4289885eju.310.2019.11.08.11.26.13; Fri, 08 Nov 2019 11:26:36 -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=2HaTW9Qm; 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 S1732758AbfKHSyG (ORCPT + 99 others); Fri, 8 Nov 2019 13:54:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:50982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730159AbfKHSyE (ORCPT ); Fri, 8 Nov 2019 13:54:04 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 0408121D7B; Fri, 8 Nov 2019 18:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239243; bh=GZYCxa1+7YPlTXGEUUOzjNNiqpEQPXud0B+UNLeQQxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2HaTW9QmTYkEhNzsVZX04/BQQ4dq70zUe74B+xK21XCCfBtc0+ZXrs67k/TqFJKOS Twza0jYpNpIaIGK7nAT6xjAhTfOcDUV5nCyoKTDZ3bS4DzOcferVPUoKQSbmSI6D2y kxebtsTRQaa8AQJX6xSFLTFIVTNyeBb+tlGZ9N5k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , "linus.walleij@linaro.org, rmk+kernel@armlinux.org.uk, Ard Biesheuvel" , Russell King , Tony Lindgren , Marc Zyngier , "David A. Long" , Ard Biesheuvel Subject: [PATCH 4.4 49/75] ARM: spectre-v2: warn about incorrect context switching functions Date: Fri, 8 Nov 2019 19:50:06 +0100 Message-Id: <20191108174753.409295560@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174708.135680837@linuxfoundation.org> References: <20191108174708.135680837@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: Russell King Commit c44f366ea7c85e1be27d08f2f0880f4120698125 upstream. Warn at error level if the context switching function is not what we are expecting. This can happen with big.Little systems, which we currently do not support. Signed-off-by: Russell King Boot-tested-by: Tony Lindgren Reviewed-by: Tony Lindgren Acked-by: Marc Zyngier Signed-off-by: David A. Long Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm/mm/proc-v7-bugs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/arch/arm/mm/proc-v7-bugs.c +++ b/arch/arm/mm/proc-v7-bugs.c @@ -12,6 +12,8 @@ #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR DEFINE_PER_CPU(harden_branch_predictor_fn_t, harden_branch_predictor_fn); +extern void cpu_v7_iciallu_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm); +extern void cpu_v7_bpiall_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm); extern void cpu_v7_smc_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm); extern void cpu_v7_hvc_switch_mm(phys_addr_t pgd_phys, struct mm_struct *mm); @@ -50,6 +52,8 @@ static void cpu_v7_spectre_init(void) case ARM_CPU_PART_CORTEX_A17: case ARM_CPU_PART_CORTEX_A73: case ARM_CPU_PART_CORTEX_A75: + if (processor.switch_mm != cpu_v7_bpiall_switch_mm) + goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = harden_branch_predictor_bpiall; spectre_v2_method = "BPIALL"; @@ -57,6 +61,8 @@ static void cpu_v7_spectre_init(void) case ARM_CPU_PART_CORTEX_A15: case ARM_CPU_PART_BRAHMA_B15: + if (processor.switch_mm != cpu_v7_iciallu_switch_mm) + goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = harden_branch_predictor_iciallu; spectre_v2_method = "ICIALLU"; @@ -82,6 +88,8 @@ static void cpu_v7_spectre_init(void) ARM_SMCCC_ARCH_WORKAROUND_1, &res); if ((int)res.a0 != 0) break; + if (processor.switch_mm != cpu_v7_hvc_switch_mm && cpu) + goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = call_hvc_arch_workaround_1; processor.switch_mm = cpu_v7_hvc_switch_mm; @@ -93,6 +101,8 @@ static void cpu_v7_spectre_init(void) ARM_SMCCC_ARCH_WORKAROUND_1, &res); if ((int)res.a0 != 0) break; + if (processor.switch_mm != cpu_v7_smc_switch_mm && cpu) + goto bl_error; per_cpu(harden_branch_predictor_fn, cpu) = call_smc_arch_workaround_1; processor.switch_mm = cpu_v7_smc_switch_mm; @@ -109,6 +119,11 @@ static void cpu_v7_spectre_init(void) if (spectre_v2_method) pr_info("CPU%u: Spectre v2: using %s workaround\n", smp_processor_id(), spectre_v2_method); + return; + +bl_error: + pr_err("CPU%u: Spectre v2: incorrect context switching function, system vulnerable\n", + cpu); } #else static void cpu_v7_spectre_init(void)