From patchwork Thu Oct 24 12:48:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 177439 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2142247ill; Thu, 24 Oct 2019 05:49:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJ70p49EALwQ2HnQl+mx2Knb2pajw5hWev1x/A4VlmFK5fPvfATFQM+YOxDJHfsy2rSzKF X-Received: by 2002:a17:906:6a09:: with SMTP id o9mr1356078ejr.289.1571921357597; Thu, 24 Oct 2019 05:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571921357; cv=none; d=google.com; s=arc-20160816; b=KR/dr5xabyFCemLa1DSzf7wDinQ8R8jXjTNL0FgjxUEkCTLtGMC9knTahPwsIaMsiB J3nroblQjDAuUAlmUqANHlTlxh5I8W0UbIWxjqrgiuiDV6G3D1d9+1JYodLZgBiJdKMz aAYnO0AhnubgCgjpPy/xjzkpZ1pAgZqvDxgGum16cFESJiPc85b4IGohz/GXN+BpBbt0 x6aSh/SJ3FFrqB+5S7ZErmcHOXPiJzeCB/FJ+NrgSvHrL+JYwffdgptkXcpXsVDG2JD/ vJvORstfAUXQ44yMyxoecKyKHW/zEIh0ohW9JJRaZVYz9+PG0oTbitm9AJJnwVO7Onwi fFRg== 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=l/0r/zgR6xJuYBaKWXZiKnEuixSvKC06vXoCFw+H5e4=; b=N87aaXplJ+Sb+tf3+sNBdNXh4+wzn/2FdofJ5hEm57hdH76xK0ffwzKiT8vCrjDl0+ S3DQT3cymO1VPsi0Vzi55SogVDynHYsFTo3IGWdeDViOc0u589h48YNdse2LETqCLft1 HKLf2gMOrUKrUemLFFyB0tDzgUQ7UE2+SB5imliYhbYAcB593ZZkvq3JuqlPno7dM4DD g+Vu0ZKEmXCxgxL+Mfba3yBIWZc/eGWDF2NZOaF4eLNKul1FIIYi5Hr3OnzTunJHbd0O 6+jgTCaodktzrmxJazb+kaIUR2B9thhVFq8dRGXGozTVYIK5kdSmPJADWZEusI1/bRyY LcvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bXm2C9dj; 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.17; Thu, 24 Oct 2019 05:49:17 -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=bXm2C9dj; 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 S1729570AbfJXMtQ (ORCPT + 14 others); Thu, 24 Oct 2019 08:49:16 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37078 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729502AbfJXMtQ (ORCPT ); Thu, 24 Oct 2019 08:49:16 -0400 Received: by mail-wr1-f68.google.com with SMTP id e11so17238062wrv.4 for ; Thu, 24 Oct 2019 05:49:15 -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=l/0r/zgR6xJuYBaKWXZiKnEuixSvKC06vXoCFw+H5e4=; b=bXm2C9dj2eGIy0kN2RVPrrZdiBlrjgGpEejRJfdDgCCZBdKjARXhHmEP/HEEauVLtB ozQC+4STIsgUMtsLa+rhrR27NkgTFvH7frHJ/G/wJPiZ65QrQ5xv0gWDAVfxgVrYmlY4 8IyTmCdwowh7bPXOcUAe1Drypes6sQy1hPiD5raETsryS1yy8zWTbBX6BThuJc7Oz6jH KJilwLFsAVJmgiNpqccduU+drQ8CTwEugKh31DGCqO0g4IcFDzatpb3lfRDEIQm730KL f5J+wPV86FJO4HNuTMUekHqCuZ5SzudE0hHxT6v5nvs8UaG87HDnkk08oeLGIOUvtCJf kWbA== 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=l/0r/zgR6xJuYBaKWXZiKnEuixSvKC06vXoCFw+H5e4=; b=GNJq5dkHzHms38L5wCxd8PiM5JLkGaDXJcbOkQJ89sgdQDvHj73FJ2ILb/DTlPQS0k /O44jn3KulhZJSeTwd3lHjQvhNUvaucnl5dTbHW1hFc2ykva/SA5u1tk2MNXvEvF0VV0 2y4/8L1aiCBNyxabprhPlePukRgSmEwnSVCeHfOQJ/3vbdt+aeHLiEK5UkTGzP9dU1oY D7AJJWlFDo6ZeD+0qfrUu9vLJdHq7OqOmMHl1FKaw10iooq8DpWgJPwEEpDCl9806OOK hgGaTHvnKP3tdCQzKlR4DQNiMkHn6YZwGAUQ7qJcLIlNmaW9kCzkzcwojuQnU/qAVFK5 mInw== X-Gm-Message-State: APjAAAUkHv8TLR7bDNubjVgxmLywoPcMaz8Rr0F2lppXQWdMex9zyOWb dROZ6aLnL03foJ7sIHHx3zXVL6t70iqDh5k/ X-Received: by 2002:adf:fe81:: with SMTP id l1mr3609124wrr.165.1571921354250; Thu, 24 Oct 2019 05:49:14 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 05:49:13 -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 , Dave Martin , Will Deacon Subject: [PATCH for-stable-4.14 17/48] arm64: capabilities: Prepare for grouping features and errata work arounds Date: Thu, 24 Oct 2019 14:48:02 +0200 Message-Id: <20191024124833.4158-18-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 600b9c919c2f4d07a7bf67864086aa3432224674 ] We are about to group the handling of all capabilities (features and errata workarounds). This patch open codes the wrapper routines to make it easier to merge the handling. Reviewed-by: Dave Martin Signed-off-by: Suzuki K Poulose Signed-off-by: Will Deacon Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/cpufeature.c | 58 ++++++-------------- 1 file changed, 18 insertions(+), 40 deletions(-) -- 2.20.1 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index b88871d5f179..bc76597abe7b 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -485,7 +485,8 @@ static void __init init_cpu_ftr_reg(u32 sys_reg, u64 new) } extern const struct arm64_cpu_capabilities arm64_errata[]; -static void update_cpu_errata_workarounds(void); +static void update_cpu_capabilities(const struct arm64_cpu_capabilities *caps, + u16 scope_mask, const char *info); void __init init_cpu_features(struct cpuinfo_arm64 *info) { @@ -528,7 +529,8 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info) * Run the errata work around checks on the boot CPU, once we have * initialised the cpu feature infrastructure. */ - update_cpu_errata_workarounds(); + update_cpu_capabilities(arm64_errata, SCOPE_ALL, + "enabling workaround for"); } static void update_cpu_ftr_reg(struct arm64_ftr_reg *reg, u64 new) @@ -1312,33 +1314,6 @@ verify_local_elf_hwcaps(const struct arm64_cpu_capabilities *caps) } } -static void verify_local_cpu_features(void) -{ - if (!__verify_local_cpu_caps(arm64_features, SCOPE_ALL)) - cpu_die_early(); -} - -/* - * 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) -{ - if (!__verify_local_cpu_caps(arm64_errata, SCOPE_ALL)) - cpu_die_early(); -} - -static void update_cpu_errata_workarounds(void) -{ - update_cpu_capabilities(arm64_errata, SCOPE_ALL, - "enabling workaround for"); -} - -static void __init enable_errata_workarounds(void) -{ - enable_cpu_capabilities(arm64_errata, SCOPE_ALL); -} /* * Run through the enabled system capabilities and enable() it on this CPU. @@ -1350,8 +1325,15 @@ static void __init enable_errata_workarounds(void) */ static void verify_local_cpu_capabilities(void) { - verify_local_cpu_errata_workarounds(); - verify_local_cpu_features(); + /* + * 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. + */ + if (!__verify_local_cpu_caps(arm64_errata, SCOPE_ALL)) + cpu_die_early(); + if (!__verify_local_cpu_caps(arm64_features, SCOPE_ALL)) + cpu_die_early(); verify_local_elf_hwcaps(arm64_elf_hwcaps); if (system_supports_32bit_el0()) verify_local_elf_hwcaps(compat_elf_hwcaps); @@ -1372,17 +1354,12 @@ void check_local_cpu_capabilities(void) * advertised capabilities. */ if (!sys_caps_initialised) - update_cpu_errata_workarounds(); + update_cpu_capabilities(arm64_errata, SCOPE_ALL, + "enabling workaround for"); else verify_local_cpu_capabilities(); } -static void __init setup_feature_capabilities(void) -{ - update_cpu_capabilities(arm64_features, SCOPE_ALL, "detected:"); - enable_cpu_capabilities(arm64_features, SCOPE_ALL); -} - DEFINE_STATIC_KEY_FALSE(arm64_const_caps_ready); EXPORT_SYMBOL(arm64_const_caps_ready); @@ -1405,8 +1382,9 @@ void __init setup_cpu_features(void) int cls; /* Set the CPU feature capabilies */ - setup_feature_capabilities(); - enable_errata_workarounds(); + update_cpu_capabilities(arm64_features, SCOPE_ALL, "detected:"); + enable_cpu_capabilities(arm64_features, SCOPE_ALL); + enable_cpu_capabilities(arm64_errata, SCOPE_ALL); mark_const_caps_ready(); setup_elf_hwcaps(arm64_elf_hwcaps);