From patchwork Thu Oct 24 12:47:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 177434 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2142107ill; Thu, 24 Oct 2019 05:49:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwr5xKR2pBiDs95h42jxVBJZg4s1fK1Q6/zgx3oY7ePzS1z2kCSOYNmrnuHsydEXrMbkD0q X-Received: by 2002:a05:6402:1614:: with SMTP id f20mr1924159edv.202.1571921349757; Thu, 24 Oct 2019 05:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571921349; cv=none; d=google.com; s=arc-20160816; b=XjVC9zqtDINymCJuOK4mh2VviwbYnoPeXItEzr4tCIPssJscdRWpwmdoa8ViPR8lgr oMgBYf90G06wdMP1kTPaz69dvBI+tPpLOW3fFSeP8pBOGbQLlKFI1k30IXepm05y+c0z n/3AWXff4Yy1aT5JkeNqlY5CxvXZlUcNgsvRrMUfo2wBB0z2uUKpMVuSc2KlHXk9PDus prESUNYBxbNv/lmv7T0AbBUY6aR7FAL12dUL5tEvYCez7rW6r6JJpdufo1UlN5w7wr4l n17dqebcl/iG/p/FXIS4uc0J5I0F/XvE1AC6zcXKS4qFyJYW81go4IQxD5XL03x08FV5 HNbQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CXPr/BDLhB8VgHesX559NGxXMEjwYFeQywhBIXkvp8M=; b=cqnKwJr1TN0s5Tjh67LuZYn+OoZ2t/0q6X3pRPYd38WcYIveZzSExQP3glYunsRSlD bNWn6xh2maLOZ8/4RrtR4yX1WErgVAOM/pxqGYpNvIm7GD8BoBUS4i27p++/ddErk29Z 33UV5HrboHu0C/abchrEscAEV+rw7M+peHWc0SzT8n1u7ucq5s7AhCNBxsQtarqKvgGx xInQTZ3jWArZm56mYLz+B3SrL0cbcQ0KWtNuQx6uF7WlVkEuL5HVlIeVOGv8GmqoiLYu L9FzpsQox0u9s4/wZ6YleTvSeLq42nx+CqcIWDALW22mNJlUO6sHaY0eN7Uj/sCGdlMA D1Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cikGTBdP; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si12973378eda.251.2019.10.24.05.49.09; Thu, 24 Oct 2019 05:49:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=cikGTBdP; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727913AbfJXMtJ (ORCPT + 14 others); Thu, 24 Oct 2019 08:49:09 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42541 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728684AbfJXMtI (ORCPT ); Thu, 24 Oct 2019 08:49:08 -0400 Received: by mail-wr1-f67.google.com with SMTP id r1so16139544wrs.9 for ; Thu, 24 Oct 2019 05:49:07 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=CXPr/BDLhB8VgHesX559NGxXMEjwYFeQywhBIXkvp8M=; b=cikGTBdPCjQ44Aa9bWbYKu9zjRu4yYFDTg30vWHwVZIgug8e1hjosT+FneFALm+Rex C0N1ZxW5//wEFS7mdzZy5qeFtSuc1cQlGmrBGYPeHGQk42iefcs9DZCigtMymuibN7Gb 2SYgJItTwv5MjWGFpvEL2VWQ4pcJPzaUD800YICtyE/sqyGbyslXJvC+1vL0JySppDon 0ZSH7m+GA4PEKNNdUqH8XBGowbT+wA27+Pbue3/KGgJsfIor1EK3gqb+OG8EPtE+f8zt nZwcNcI636BlAy6WYR7UwnpZbrepCgoZpLJSkS/j/YIgrmX7XyrpPViA5UmfiYK+G2LW Acxg== 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:mime-version:content-transfer-encoding; bh=CXPr/BDLhB8VgHesX559NGxXMEjwYFeQywhBIXkvp8M=; b=Lbu08Yt5iREVroAd/T8gRsROPnab0kuYdtPHvRNBy3ynJzAtU2J7hjmyaqdDBpGREH Knr5ZxbTEMoXFtlFH+9uW9bgDTpeWGoOAXD5t3ppugiarVbX2BdvkTEsFJ4pnuuYu8aX MY3Y96LTWofw2EL/HLZN2KPxhv1UIl9xbqxyD3NdL34CsBtv46WsP40zGTdnD46q8lsh ybPFP2PoNiuWW70rnhcUL3k5KqeX7HsB8KaJD6tuxDmhe1e/sUlgIHLQadYWgeiV0aX+ x7b4W1OUE3NTiNMbWdmzbUXcIwoTX1kB9QWPv1DNny/P4TRI2sJlPBGUw+P1vHADhdmo 6AJQ== X-Gm-Message-State: APjAAAUmbBF6q4VLyc8tH4pNz+Z0EQwzxbYP65Di+dpQGCg8zSiGA6lu vGWsfLjRhA6Vp+MLxWJqJIBMuEJ3YpMA5W/6 X-Received: by 2002:adf:e982:: with SMTP id h2mr3525294wrm.53.1571921346487; Thu, 24 Oct 2019 05:49:06 -0700 (PDT) Received: from localhost.localdomain (aaubervilliers-681-1-126-126.w90-88.abo.wanadoo.fr. [90.88.7.126]) by smtp.gmail.com with ESMTPSA id j22sm29111038wrd.41.2019.10.24.05.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 05:49:05 -0700 (PDT) From: Ard Biesheuvel To: stable@vger.kernel.org Cc: Ard Biesheuvel , Will Deacon , Catalin Marinas , Marc Zyngier , Mark Rutland , Suzuki K Poulose , Jeremy Linton , Andre Przywara , Alexandru Elisei , Will Deacon , Marc Zyngier , Dave Martin Subject: [PATCH for-stable-4.14 12/48] arm64: capabilities: Move errata processing code Date: Thu, 24 Oct 2019 14:47:57 +0200 Message-Id: <20191024124833.4158-13-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024124833.4158-1-ard.biesheuvel@linaro.org> References: <20191024124833.4158-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Suzuki K Poulose [ Upstream commit 1e89baed5d50d2b8d9fd420830902570270703f1 ] We have errata work around processing code in cpu_errata.c, which calls back into helpers defined in cpufeature.c. Now that we are going to make the handling of capabilities generic, by adding the information to each capability, move the errata work around specific processing code. No functional changes. Cc: Will Deacon Cc: Marc Zyngier Cc: Mark Rutland Cc: Andre Przywara Reviewed-by: Dave Martin Signed-off-by: Suzuki K Poulose Signed-off-by: Will Deacon Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/cpufeature.h | 7 ---- arch/arm64/kernel/cpu_errata.c | 33 --------------- arch/arm64/kernel/cpufeature.c | 43 ++++++++++++++++++-- 3 files changed, 40 insertions(+), 43 deletions(-) -- 2.20.1 diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index bff4d95db039..22ebede86100 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -230,15 +230,8 @@ static inline bool id_aa64pfr0_32bit_el0(u64 pfr0) } void __init setup_cpu_features(void); - -void update_cpu_capabilities(const struct arm64_cpu_capabilities *caps, - const char *info); -void enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps); void check_local_cpu_capabilities(void); -void update_cpu_errata_workarounds(void); -void __init enable_errata_workarounds(void); -void verify_local_cpu_errata_workarounds(void); u64 read_sanitised_ftr_reg(u32 id); diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index 3c2a68d766a2..f1885beb2588 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -621,36 +621,3 @@ const struct arm64_cpu_capabilities arm64_errata[] = { { } }; - -/* - * The CPU Errata work arounds are detected and applied at boot time - * and the related information is freed soon after. If the new CPU requires - * an errata not detected at boot, fail this CPU. - */ -void verify_local_cpu_errata_workarounds(void) -{ - const struct arm64_cpu_capabilities *caps = arm64_errata; - - for (; caps->matches; caps++) { - if (cpus_have_cap(caps->capability)) { - if (caps->cpu_enable) - caps->cpu_enable(caps); - } else if (caps->matches(caps, SCOPE_LOCAL_CPU)) { - pr_crit("CPU%d: Requires work around for %s, not detected" - " at boot time\n", - smp_processor_id(), - caps->desc ? : "an erratum"); - cpu_die_early(); - } - } -} - -void update_cpu_errata_workarounds(void) -{ - update_cpu_capabilities(arm64_errata, "enabling workaround for"); -} - -void __init enable_errata_workarounds(void) -{ - enable_cpu_capabilities(arm64_errata); -} diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 1269d496db0a..353464b82d61 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -484,6 +484,9 @@ static void __init init_cpu_ftr_reg(u32 sys_reg, u64 new) reg->user_mask = user_mask; } +extern const struct arm64_cpu_capabilities arm64_errata[]; +static void update_cpu_errata_workarounds(void); + void __init init_cpu_features(struct cpuinfo_arm64 *info) { /* Before we start using the tables, make sure it is sorted */ @@ -1160,8 +1163,8 @@ static bool __this_cpu_has_cap(const struct arm64_cpu_capabilities *cap_array, return false; } -void update_cpu_capabilities(const struct arm64_cpu_capabilities *caps, - const char *info) +static void update_cpu_capabilities(const struct arm64_cpu_capabilities *caps, + const char *info) { for (; caps->matches; caps++) { if (!caps->matches(caps, caps->def_scope)) @@ -1185,7 +1188,8 @@ static int __enable_cpu_capability(void *arg) * Run through the enabled capabilities and enable() it on all active * CPUs */ -void __init enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps) +static void __init +enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps) { for (; caps->matches; caps++) { unsigned int num = caps->capability; @@ -1267,6 +1271,39 @@ verify_local_cpu_features(const struct arm64_cpu_capabilities *caps_list) } } +/* + * The CPU Errata work arounds are detected and applied at boot time + * and the related information is freed soon after. If the new CPU requires + * an errata not detected at boot, fail this CPU. + */ +static void verify_local_cpu_errata_workarounds(void) +{ + const struct arm64_cpu_capabilities *caps = arm64_errata; + + for (; caps->matches; caps++) { + if (cpus_have_cap(caps->capability)) { + if (caps->cpu_enable) + caps->cpu_enable(caps); + } else if (caps->matches(caps, SCOPE_LOCAL_CPU)) { + pr_crit("CPU%d: Requires work around for %s, not detected" + " at boot time\n", + smp_processor_id(), + caps->desc ? : "an erratum"); + cpu_die_early(); + } + } +} + +static void update_cpu_errata_workarounds(void) +{ + update_cpu_capabilities(arm64_errata, "enabling workaround for"); +} + +static void __init enable_errata_workarounds(void) +{ + enable_cpu_capabilities(arm64_errata); +} + /* * Run through the enabled system capabilities and enable() it on this CPU. * The capabilities were decided based on the available CPUs at the boot time.