From patchwork Wed Nov 7 16:43:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 150425 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5387314ljp; Wed, 7 Nov 2018 08:44:17 -0800 (PST) X-Received: by 2002:a0c:b5e3:: with SMTP id o35mr999644qvf.164.1541609057674; Wed, 07 Nov 2018 08:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541609057; cv=none; d=google.com; s=arc-20160816; b=okEGVGhtrYF7QWvHM+Pu8avszI7y8KWlm9o1bFBKv1wl4AkPCbncNC5lDUhWOL/feX hI8rXzTbqLxcRPdoINOxuVtCNc9FXQRKtmT1cDt/kyGvC9eQezQdOJhhPAnE+MTgi/be sHxhgB3KVcCN4y3i1/DHBEZI0+AdbqR8duQSd1DArmWEeDURbMlTQdmAC1ccetfxC/sq XXhh3Bdz/fiYkTAg5oYYmy+qPK5pxLXRZh+94L8NWIACRV6+uZcAi28jGxTjjn0xJIVN NHqAmyfFOmAS0gr7H23zPbKb+O3gBY49YgTl7tkg2NwWJ/LeYq57yQO7ootw3BcCv0tz BkKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PtvOdRYgxdWqiincDIf4CTD/BFKZK9uYA9vLMv5udX0=; b=thCDRAe+sTNb+C09qumUdpDey/4xOKNbBAPnxnIqZqxSrGMuTAtceyI2g6xgl6AzJx iUi+IRk0Pib/KAArYLJehfOMCTqvb1t57T5DhfRcg92Rgt8ZSz4hijBebMJricxRjKp+ Vu7gX9TkpDY0FmEaE6ehV6Khf0MFdDWQ54UkZjx9FD/HMtoAzjzeD6Iz79WxBITL+JEJ b4PI/Qm/5j5Jkt0prV4fUjT0PqRYADGOqBhVKr74V+JliX4XXJ9E+yVYKZNexqnZLTUv nT3Hn/fvxRKrIjnClpIOLuJn5ZT1YwbScH+PpEY7kZUCFaS3xSOleB0iB4vG7QUYgOxa VpIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jZbPxQHX; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c4-v6sor650664qkf.66.2018.11.07.08.44.17 for (Google Transport Security); Wed, 07 Nov 2018 08:44:17 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jZbPxQHX; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PtvOdRYgxdWqiincDIf4CTD/BFKZK9uYA9vLMv5udX0=; b=jZbPxQHXsx/AtCQM6241luZEGARIqXb67sDpdR6xmC9wiCKYkSBl/8tPw/BH0pPUbW bhiYO6xBVpzhiiHEMZJtYA87jCu7pey5GE/h1em+fQciStOTFLBe+NIg8eDQK+qA21Qw 80C++OvwvptpUwr8Q/per3CoGjzV63izcLGoU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PtvOdRYgxdWqiincDIf4CTD/BFKZK9uYA9vLMv5udX0=; b=mGMUUpbWZ4I0/LLAlceW9bE9hE3yXgx5Sdf0IpOIWtiHktspNPhi/QX7NJ/iGLXqdN KdimSXJiNv7qcdh+fRNrwpeIkeC3Dm4AhD+F6c9bZPJyjGPa3kPYDZSvTtHg1cMOBEH0 29xyMYJlN8e/gXzYMwTQj0P8EI4rx3cIdVlNq0ucvCf/Yy2pedtiCz4Amzujq4VhZyOw ZK0mVJR+jQJLy71NrrX2isZ3d41o5sifsBWpMzdjWoKick13XAAomEGdQ5Y/xOyLAedC 0au28phSXzMUCSs+2e3u9uAyM/EVprJqTO+Ugks9M6tIqXWg6X1Pe7CPW71Yq7b1wlLY yprA== X-Gm-Message-State: AGRZ1gKv6YX+t1nHHE1ObQxUM9pkFr41FzikHBIn2KmGVR0YN8YNANaD YztsFUa7zeYDBis9g7Zx1GH2iXkq X-Google-Smtp-Source: AJdET5dcsmcrc3Y5K1bSVoPK0xh+QOyl09SqlF2Hfi+vYXKeUOuV9KE/cDJjilQY4CxPgCSG+nzBJg== X-Received: by 2002:a37:b683:: with SMTP id g125-v6mr878954qkf.179.1541609057170; Wed, 07 Nov 2018 08:44:17 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 96-v6sm681817qtc.56.2018.11.07.08.44.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 08:44:16 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.9 V2 10/24] ARM: spectre-v2: warn about incorrect context switching functions Date: Wed, 7 Nov 2018 11:43:48 -0500 Message-Id: <20181107164402.9380-11-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181107164402.9380-1-dave.long@linaro.org> References: <20181107164402.9380-1-dave.long@linaro.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 --- arch/arm/mm/proc-v7-bugs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.17.1 diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c index da25a38e1897..5544b82a2e7a 100644 --- 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)