Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp179919imd; Wed, 31 Oct 2018 16:56:17 -0700 (PDT) X-Google-Smtp-Source: AJdET5dzELLQOb7y4EiwwT6qMHbrgnmruZzwuYv/UJucCmBhCRw8tdIrE6p+41w94xP3XCmQWovp X-Received: by 2002:a63:a35c:: with SMTP id v28mr5027017pgn.205.1541030177776; Wed, 31 Oct 2018 16:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541030177; cv=none; d=google.com; s=arc-20160816; b=LRmxLLRggCeva3DTbRYXZo/wEgJ5UXcKgtdy0SjUq+ULFgXcplQ6fAqygvRzd7h//f O18xoZ5xwAT5j3XS7IfQoT/ZqyB3RD8bBCz+JIzNjwHCqhEDopF5t+Tm7tqa3jBtTM68 il3ufogdZA9sbQMClVB8j9yNEq2cKnCDV0VQhQj991p/VXJtnsRTHi0IRmCUGUgy+8b3 1Vjmh+TW1gYonq/+xJpIW687yD6rNyAVjAdZ5ZyvKpqXt9g7ROARzWuS93tFtuiVHmUw MWDL8A0rfCjJkhCqd3pTWjLXsyL8e2c3xz0M85oc9UCjxHVptT25eSi0oqdMSxd+5f/x 4clQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=GRZUfaLgh/m62pSMY0UKhafXu0pk9KIDIVQF/yUQeRk=; b=iTiPTfhUuBN01z6Rj/atDD7SUBUv5NiuVyXim2jnifDdKz6R4Nzq5L5GVgsJ6YYONw sO3CvBuzRrMCMEMvUHkfIzKMlx6AAWebW+OI1+ZgUgE0Rg9KWTmO8lVlWtk3sDl2g+gX IG3V80t6AmG2sjfOLfnUsUkiFB+maFuWFRW60EFp2BZvTsjVUVAeAzKJOOJuYvv9CzNf 5baJLNFhAumYhzD2OfhVaAXNEKkV0bMUxs15tOpK85Fc05+8J9anGSPgrOU4EHSnS4Ys WKtsY/q/b2qEk6LYxT2hCHTqcwot7i0MWtKIJYbtfj8QIG3obaw9wny5xH3cEY0BA/go Uhiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CJIgkllD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w27-v6si25301650pga.258.2018.10.31.16.56.02; Wed, 31 Oct 2018 16:56:17 -0700 (PDT) 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=CJIgkllD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727205AbeKAIGB (ORCPT + 99 others); Thu, 1 Nov 2018 04:06:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:52610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726532AbeKAIGA (ORCPT ); Thu, 1 Nov 2018 04:06:00 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A663A2082E; Wed, 31 Oct 2018 23:05:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027150; bh=ToxnrrhxxSr0PfB0tmJ2tkh02ll8nPU8XTq3Jj5S3NY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CJIgkllDSxgsPDYo9ZtlhMYvT1kXS+10kqgmU9q/wDrQc8tZ7CqInYgNqIezvqi48 7jWrh0he+NgbhetVDR8gS4bWuYhPosNfSq4Z/9xn/Qq7CnaTwWaRQJQAXJzx5J7XZr TfHj2Q9NojeAyQb7i4XKzIbvnNObW0esgbH//6s0= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Suzuki K Poulose , Philip Elcan , Shanker Donthineni , Mark Rutland , Will Deacon , Catalin Marinas , Sasha Levin Subject: [PATCH AUTOSEL 4.19 008/146] arm64: cpufeature: ctr: Fix cpu capability check for late CPUs Date: Wed, 31 Oct 2018 19:03:23 -0400 Message-Id: <20181031230541.28822-8-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suzuki K Poulose [ Upstream commit 8ab66cbe63aeaf9e5970fb4aaef1c660fca59321 ] The matches() routine for a capability must honor the "scope" passed to it and return the proper results. i.e, when passed with SCOPE_LOCAL_CPU, it should check the status of the capability on the current CPU. This is used by verify_local_cpu_capabilities() on a late secondary CPU to make sure that it's compliant with the established system features. However, ARM64_HAS_CACHE_{IDC/DIC} always checks the system wide registers and this could mean that a late secondary CPU could return "true" (since the CPU hasn't updated the system wide registers yet) and thus lead the system in an inconsistent state, where the system assumes it has IDC/DIC feature, while the new CPU doesn't. Fixes: commit 6ae4b6e0578886eb36 ("arm64: Add support for new control bits CTR_EL0.DIC and CTR_EL0.IDC") Cc: Philip Elcan Cc: Shanker Donthineni Cc: Mark Rutland Cc: Will Deacon Signed-off-by: Suzuki K Poulose Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- arch/arm64/kernel/cpufeature.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index e238b7932096..93f69d82225d 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -848,15 +848,29 @@ static bool has_no_fpsimd(const struct arm64_cpu_capabilities *entry, int __unus } static bool has_cache_idc(const struct arm64_cpu_capabilities *entry, - int __unused) + int scope) { - return read_sanitised_ftr_reg(SYS_CTR_EL0) & BIT(CTR_IDC_SHIFT); + u64 ctr; + + if (scope == SCOPE_SYSTEM) + ctr = arm64_ftr_reg_ctrel0.sys_val; + else + ctr = read_cpuid_cachetype(); + + return ctr & BIT(CTR_IDC_SHIFT); } static bool has_cache_dic(const struct arm64_cpu_capabilities *entry, - int __unused) + int scope) { - return read_sanitised_ftr_reg(SYS_CTR_EL0) & BIT(CTR_DIC_SHIFT); + u64 ctr; + + if (scope == SCOPE_SYSTEM) + ctr = arm64_ftr_reg_ctrel0.sys_val; + else + ctr = read_cpuid_cachetype(); + + return ctr & BIT(CTR_DIC_SHIFT); } #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -- 2.17.1