Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1832470imm; Mon, 3 Sep 2018 10:35:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbCx95y9M7Ja2MOYIUXrzHZlPK/H3ZvckgZGlfjRNduUjhoe14D4h4KdGCduB3dGeI02ka2 X-Received: by 2002:a17:902:24e1:: with SMTP id l30-v6mr29709051plg.315.1535996108855; Mon, 03 Sep 2018 10:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535996108; cv=none; d=google.com; s=arc-20160816; b=BrOZ6qKkOlhgR/dUh7sU1+BBZXqEE2bayqyuC7vsl8xGCCC2mpOfdUpubWAGZoV7GU BssRLGSGDXzC5L7oz7abdGlMh8XNpOP6d00HnSzP9j6yb1rkTuwg7t0PZ9vxdVjP165b 7eyT9yJl/FLK2t/JnQn5CtR/ewapXTrvQbNw0r7wUdOJvcQ+GLtzgr//p185fP3PYoga TIxgFZsdbFlLp3zJNArluYdNJWLrXOvHsxVAZxf6hYGgFwy6JTI0QTgtEzOlkbHsEo+m 3eCxwksWHZXotDISGzWTAx6vmaqF6HmKfqPeHCdP5ksnMjYi0EzsULMMQHkDl+Fm7jB4 3tCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=qJ6bROVHeaxJQoyOyy+XGlvUY6/gM5hb/09Tta7lVE8=; b=xQoHDFytjUhKEYFLXZcU/CKlOu92Z59fCLN0PXCjZFV7n/z5JcBY7kMIOrWU8zyzKw bAZpEx9wN/rOvwxzxi9jXv/8UugHcweNLm8wsGhxlzLCn5thOF7wYCZu1tSrS5Wg9Fog jBQg6vtuodIWfLiytNsDlgOrJ2DSlX10zXqffL0+U5Tj4UE038QhOl8dHB/bUxphCAGD m49JBOV0RtfHvJoX1HWm6HPwgn5NDa25L9ltha/XqTmdtT5c2wyEgnQLJg33M5Up1yL+ 5d8xbOBXZjOf3DRK1jpJM0b5Gdmc+lCWK4cx8VE3latSpYJQzPmT8HFZhmu6Tbk7eE2t ckhA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5-v6si17004324pgw.343.2018.09.03.10.34.53; Mon, 03 Sep 2018 10:35:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731072AbeICVyR (ORCPT + 99 others); Mon, 3 Sep 2018 17:54:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47616 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728253AbeICVyQ (ORCPT ); Mon, 3 Sep 2018 17:54:16 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EB4F2D24; Mon, 3 Sep 2018 17:33:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Catalin Marinas , Will Deacon , Suzuki K Poulose Subject: [PATCH 4.18 029/123] arm64: Fix mismatched cache line size detection Date: Mon, 3 Sep 2018 18:56:13 +0200 Message-Id: <20180903165720.726434146@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165719.499675257@linuxfoundation.org> References: <20180903165719.499675257@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Suzuki K Poulose commit 4c4a39dd5fe2d13e2d2fa5fceb8ef95d19fc389a upstream. If there is a mismatch in the I/D min line size, we must always use the system wide safe value both in applications and in the kernel, while performing cache operations. However, we have been checking more bits than just the min line sizes, which triggers false negatives. We may need to trap the user accesses in such cases, but not necessarily patch the kernel. This patch fixes the check to do the right thing as advertised. A new capability will be added to check mismatches in other fields and ensure we trap the CTR accesses. Fixes: be68a8aaf925 ("arm64: cpufeature: Fix CTR_EL0 field definitions") Cc: Cc: Mark Rutland Cc: Catalin Marinas Reported-by: Will Deacon Signed-off-by: Suzuki K Poulose Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/cache.h | 4 ++++ arch/arm64/kernel/cpu_errata.c | 6 ++++-- arch/arm64/kernel/cpufeature.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) --- a/arch/arm64/include/asm/cache.h +++ b/arch/arm64/include/asm/cache.h @@ -21,12 +21,16 @@ #define CTR_L1IP_SHIFT 14 #define CTR_L1IP_MASK 3 #define CTR_DMINLINE_SHIFT 16 +#define CTR_IMINLINE_SHIFT 0 #define CTR_ERG_SHIFT 20 #define CTR_CWG_SHIFT 24 #define CTR_CWG_MASK 15 #define CTR_IDC_SHIFT 28 #define CTR_DIC_SHIFT 29 +#define CTR_CACHE_MINLINE_MASK \ + (0xf << CTR_DMINLINE_SHIFT | 0xf << CTR_IMINLINE_SHIFT) + #define CTR_L1IP(ctr) (((ctr) >> CTR_L1IP_SHIFT) & CTR_L1IP_MASK) #define ICACHE_POLICY_VPIPT 0 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -68,9 +68,11 @@ static bool has_mismatched_cache_line_size(const struct arm64_cpu_capabilities *entry, int scope) { + u64 mask = CTR_CACHE_MINLINE_MASK; + WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); - return (read_cpuid_cachetype() & arm64_ftr_reg_ctrel0.strict_mask) != - (arm64_ftr_reg_ctrel0.sys_val & arm64_ftr_reg_ctrel0.strict_mask); + return (read_cpuid_cachetype() & mask) != + (arm64_ftr_reg_ctrel0.sys_val & mask); } static void --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -214,7 +214,7 @@ static const struct arm64_ftr_bits ftr_c * If we have differing I-cache policies, report it as the weakest - VIPT. */ ARM64_FTR_BITS(FTR_VISIBLE, FTR_NONSTRICT, FTR_EXACT, 14, 2, ICACHE_POLICY_VIPT), /* L1Ip */ - ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), /* IminLine */ + ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, CTR_IMINLINE_SHIFT, 4, 0), ARM64_FTR_END, };