From patchwork Thu Oct 24 12:48:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 177441 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2142365ill; Thu, 24 Oct 2019 05:49:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlsHiwvkf5YSZujjKrPc8b/T0kqyXwkHDgQRsSqMY7JVBmO3QbH8N75muyA37kq+PiiP0Y X-Received: by 2002:a50:8d8a:: with SMTP id r10mr43593973edh.302.1571921363379; Thu, 24 Oct 2019 05:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571921363; cv=none; d=google.com; s=arc-20160816; b=xkAqjGxOlGy3HDEtOznngi60hGFr9pkamK4NOUPGh6Bd0T64FtYfOiWRMRmxDMpKJB 5GIR799ZOMK1bcakXHcCVgHKodBxMF32WVNYrwTQBoTybCYNux+HZpRi8e1slOizPlOw 2ri1D1vqDCWqxj7JnAiy9stpsXieF8cXPnIjIN8mjnAkiiCznoKXGkppFmiTcGgOU41h pZ94RP3s9/kOnG9yowW1NxoVtHw0b+/Ye1j5uC7rmpDJqMN51CG3cqR5Tg/IVIU+/5rZ lZK+fz7R3b58lVgeAOSxfK3jntHH5nIS7z5dvsVgB0eI7yVo6RwllA38K4YeFFkxa2cC GOww== 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=sLjpPo16BUXqgtETbNvCqL8m7bz3Xv6uHZcWSOprkhQ=; b=Po1rUW5wFuegS0E0UEphm+0bJa40FEJnvU5DDB6XfGyUt5fVEDUZ0T6ftgPZvh3she 8kck4eC1ey7vJ7UnVY+PW/tJCXC6kR8uVEkZ9mNrZVyigUdFMuqMVZlt3tarcbTWn0Gk oEk0Dww5AtjuEWnmZMqyB4131QXZYel97HbtMoHopOG6Qm81iM3HiaKYSSg4lDsQazAq RHbwEzkJ1YWO/d4el+Y1oqSX7qJrPguDp6frn08s/A5JUxWrL/+PKWx+OWdlG0vj6Qfx pQXdJgovHHCIzJLYn33a2c8fI3ARkxHsNuU2Yh62/KKLLTUOAq2dH4cy3/zZo32DGF2z Znfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jvMa2mUe; 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.23; Thu, 24 Oct 2019 05:49:23 -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=jvMa2mUe; 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 S2502059AbfJXMtW (ORCPT + 14 others); Thu, 24 Oct 2019 08:49:22 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55002 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729266AbfJXMtW (ORCPT ); Thu, 24 Oct 2019 08:49:22 -0400 Received: by mail-wm1-f67.google.com with SMTP id g7so2689601wmk.4 for ; Thu, 24 Oct 2019 05:49:19 -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=sLjpPo16BUXqgtETbNvCqL8m7bz3Xv6uHZcWSOprkhQ=; b=jvMa2mUeTs/AokHLcpBZw5HvSADZmzz0PSxskVwkIsxU5+wE0E1Ym+p4MhWXVNjJR8 NP75mE/6Xq1W9hlQ8vGIvdqsT35CHMWwaog/yXZzvTuQ+hyFJZ40x1BiE/QPLh/q+5dj sWYbEr17BQfnbz76ouKtQgZSx02+K55IrgpMExAjDFyfKm3dg3qyhW14/8tBETGV6QXS WV4/DSBYVlNbEomlEcpUUZjYDvW8lmMaMuq7n+bO0AyjKXhAOQ2Lv1X8eqZPRHiZOIVn z1qY9b683aSj/91WXK0J9BbLeqSYxOCVN4/jBXpl8+lm1YCOA5TMYFCzAZkX+rgI5eRu eOHg== 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=sLjpPo16BUXqgtETbNvCqL8m7bz3Xv6uHZcWSOprkhQ=; b=B6gWkkcTaR/06CD+/odbUM8NhvSp2nOCFs0ucKB+/pkSY7mLtCx52pqQdTWJqYwCij iuRR9f1yNshzEG9b+koZJRbM/yutMpufvH4OiYQPx1ySE5GHwDUW4Et2p9KzN1VMMbMv 1HobsqslOz8DRoqyg6cxHcVTtLAw9vcBXBhxMiUj4JzdauATRKzhTYBB8E44TOlc53IV /sKRqniaqOhJobrUfpCJTi9hwPrIKU4N8QFSaYBeqvWgn0omuAst8NDpI50wAAtmPeqm 52KPCFQWeHF2J120EYXVNPGd5KsoN8rpEK9Gsf93nwDp3ei0LGb9cbfLbRKUL7pvrQPN 74hA== X-Gm-Message-State: APjAAAU4tqwTARypU00hMEE+BEGOZYJCWQmkgqpiOIFkwE2Nbw4+708H 1LcZl6Bw1cspnWjC8fsVNPSoj0Oh7T7dy4gK X-Received: by 2002:a1c:4d14:: with SMTP id o20mr4981709wmh.7.1571921357128; Thu, 24 Oct 2019 05:49:17 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 05:49:16 -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 19/48] arm64: capabilities: Allow features based on local CPU scope Date: Thu, 24 Oct 2019 14:48:04 +0200 Message-Id: <20191024124833.4158-20-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 fbd890b9b8497bab04c1d338bd97579a7bc53fab ] So far we have treated the feature capabilities as system wide and this wouldn't help with features that could be detected locally on one or more CPUs (e.g, KPTI, Software prefetch). This patch splits the feature detection to two phases : 1) Local CPU features are checked on all boot time active CPUs. 2) System wide features are checked only once after all CPUs are active. 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 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 291f8899b37f..dda06f3436c2 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -485,6 +485,7 @@ static void __init init_cpu_ftr_reg(u32 sys_reg, u64 new) } extern const struct arm64_cpu_capabilities arm64_errata[]; +static const struct arm64_cpu_capabilities arm64_features[]; static void update_cpu_capabilities(const struct arm64_cpu_capabilities *caps, u16 scope_mask, const char *info); @@ -526,11 +527,12 @@ 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. + * Run the errata work around and local feature checks on the + * boot CPU, once we have initialised the cpu feature infrastructure. */ update_cpu_capabilities(arm64_errata, SCOPE_LOCAL_CPU, "enabling workaround for"); + update_cpu_capabilities(arm64_features, SCOPE_LOCAL_CPU, "detected:"); } static void update_cpu_ftr_reg(struct arm64_ftr_reg *reg, u64 new) @@ -1349,15 +1351,18 @@ void check_local_cpu_capabilities(void) /* * If we haven't finalised the system capabilities, this CPU gets - * a chance to update the errata work arounds. + * a chance to update the errata work arounds and local features. * Otherwise, this CPU should verify that it has all the system * advertised capabilities. */ - if (!sys_caps_initialised) + if (!sys_caps_initialised) { update_cpu_capabilities(arm64_errata, SCOPE_LOCAL_CPU, "enabling workaround for"); - else + update_cpu_capabilities(arm64_features, SCOPE_LOCAL_CPU, + "detected:"); + } else { verify_local_cpu_capabilities(); + } } DEFINE_STATIC_KEY_FALSE(arm64_const_caps_ready); @@ -1382,7 +1387,7 @@ void __init setup_cpu_features(void) int cls; /* Set the CPU feature capabilies */ - update_cpu_capabilities(arm64_features, SCOPE_ALL, "detected:"); + update_cpu_capabilities(arm64_features, SCOPE_SYSTEM, "detected:"); update_cpu_capabilities(arm64_errata, SCOPE_SYSTEM, "enabling workaround for"); enable_cpu_capabilities(arm64_features, SCOPE_ALL);