Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp828706pxu; Mon, 23 Nov 2020 05:21:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6FGpvyoQNIpnWZa4Auq2+oxrNvPoMRApFab4Yz3ddMJWH+XPI5FQatgUwBg1GpOJ+1WNR X-Received: by 2002:a17:906:268c:: with SMTP id t12mr42254724ejc.377.1606137706059; Mon, 23 Nov 2020 05:21:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606137706; cv=none; d=google.com; s=arc-20160816; b=I2aUXcf4DxHSITd2XkN9+t1V9hnpqbyJ989qNX4f9YTRqda2evj1Eog0bqpBNPmIh8 x1JqdPm36MBo+PRUhXPndE47oI5SG+yEcJKx0Yfe/dQlq4xQkTOLajogtELWn/1p3k9R WAtbobDaENBZeADxRP8kXiI1/CyeoHoMnrYQuOschdy6he400STdhHDaQGTQnqFDS/nD EPK6ssi9yWhHi/CTnQlfT5vcH/fBzGwZQjL5FJeWqHqKT4NzuaGHS24eTk4RzaQKNXQR sisoR5D73BaZGRibE44Kq6j4y9gk/bHyAEvaLvKBEA8MhesWuGPep/6Yy/+YwZBP1J1N eeiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N9xGUiIgmOdeBMWtxy7E+9U0U1/uY+RF2ZZ6lH2Y17o=; b=ao5E+fG0tv9pP4XMrQtn/fW6OdQ+sDyLQZ14HXKjsL1R7iLT5J6RM1RMbVv92UtukX ODhfUH0GC+jS5gW31YCM3klla9krUI4YmCyYVfTk35ZjvAvWuL6ZEXnPBzG88M/YmDyc lCtfanM1/Y32JJxpK+pNqLPF4S76tT+zMk140GM501lENGFwUP03QNa80qMmSXOH5YIs xl0BW7940Zl4rRp9OEUFJ9djLDYmQblTsj4g3C3hZA3DottOv0/wyIArhXlRi37+3EQP QHz9pvN1N/gG69ywJrPUlBIhrHnQUNpMst7UTSzrIzcb4T3vcta2ppT0R8cuHn8cgj2U lZ2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uB4WbdXo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si6865578edb.92.2020.11.23.05.21.23; Mon, 23 Nov 2020 05:21:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uB4WbdXo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732414AbgKWMkI (ORCPT + 99 others); Mon, 23 Nov 2020 07:40:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:52808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732400AbgKWMkF (ORCPT ); Mon, 23 Nov 2020 07:40:05 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3946620732; Mon, 23 Nov 2020 12:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135203; bh=oqkeIbWPCbIgmY9+bquH2m/ZuvMZuBZj97pZZzTEU4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uB4WbdXo9AKudNX55nvlAwwv0o461RCqfncvnvV8ZfQ+Wb7xzh7n/ggX0l6YU61Cn R0ONFJzpfKdSbvwNdDgRaQsuco3uru7/wKwsZTamBl6ZcHzVfPXU9BtCsZu3XRIuny fzqf5kVyQLwE/IcyFhlhiVc/xBa1jQAUrbcQSAdo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Filippov Subject: [PATCH 5.4 142/158] xtensa: disable preemption around cache alias management calls Date: Mon, 23 Nov 2020 13:22:50 +0100 Message-Id: <20201123121826.789722567@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Max Filippov commit 3a860d165eb5f4d7cf0bf81ef6a5b5c5e1754422 upstream. Although cache alias management calls set up and tear down TLB entries and fast_second_level_miss is able to restore TLB entry should it be evicted they absolutely cannot preempt each other because they use the same TLBTEMP area for different purposes. Disable preemption around all cache alias management calls to enforce that. Cc: stable@vger.kernel.org Signed-off-by: Max Filippov Signed-off-by: Greg Kroah-Hartman --- arch/xtensa/mm/cache.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/arch/xtensa/mm/cache.c +++ b/arch/xtensa/mm/cache.c @@ -71,8 +71,10 @@ static inline void kmap_invalidate_coher kvaddr = TLBTEMP_BASE_1 + (page_to_phys(page) & DCACHE_ALIAS_MASK); + preempt_disable(); __invalidate_dcache_page_alias(kvaddr, page_to_phys(page)); + preempt_enable(); } } } @@ -157,6 +159,7 @@ void flush_dcache_page(struct page *page if (!alias && !mapping) return; + preempt_disable(); virt = TLBTEMP_BASE_1 + (phys & DCACHE_ALIAS_MASK); __flush_invalidate_dcache_page_alias(virt, phys); @@ -167,6 +170,7 @@ void flush_dcache_page(struct page *page if (mapping) __invalidate_icache_page_alias(virt, phys); + preempt_enable(); } /* There shouldn't be an entry in the cache for this page anymore. */ @@ -200,8 +204,10 @@ void local_flush_cache_page(struct vm_ar unsigned long phys = page_to_phys(pfn_to_page(pfn)); unsigned long virt = TLBTEMP_BASE_1 + (address & DCACHE_ALIAS_MASK); + preempt_disable(); __flush_invalidate_dcache_page_alias(virt, phys); __invalidate_icache_page_alias(virt, phys); + preempt_enable(); } EXPORT_SYMBOL(local_flush_cache_page); @@ -228,11 +234,13 @@ update_mmu_cache(struct vm_area_struct * unsigned long phys = page_to_phys(page); unsigned long tmp; + preempt_disable(); tmp = TLBTEMP_BASE_1 + (phys & DCACHE_ALIAS_MASK); __flush_invalidate_dcache_page_alias(tmp, phys); tmp = TLBTEMP_BASE_1 + (addr & DCACHE_ALIAS_MASK); __flush_invalidate_dcache_page_alias(tmp, phys); __invalidate_icache_page_alias(tmp, phys); + preempt_enable(); clear_bit(PG_arch_1, &page->flags); } @@ -266,7 +274,9 @@ void copy_to_user_page(struct vm_area_st if (alias) { unsigned long t = TLBTEMP_BASE_1 + (vaddr & DCACHE_ALIAS_MASK); + preempt_disable(); __flush_invalidate_dcache_page_alias(t, phys); + preempt_enable(); } /* Copy data */ @@ -281,9 +291,11 @@ void copy_to_user_page(struct vm_area_st if (alias) { unsigned long t = TLBTEMP_BASE_1 + (vaddr & DCACHE_ALIAS_MASK); + preempt_disable(); __flush_invalidate_dcache_range((unsigned long) dst, len); if ((vma->vm_flags & VM_EXEC) != 0) __invalidate_icache_page_alias(t, phys); + preempt_enable(); } else if ((vma->vm_flags & VM_EXEC) != 0) { __flush_dcache_range((unsigned long)dst,len); @@ -305,7 +317,9 @@ extern void copy_from_user_page(struct v if (alias) { unsigned long t = TLBTEMP_BASE_1 + (vaddr & DCACHE_ALIAS_MASK); + preempt_disable(); __flush_invalidate_dcache_page_alias(t, phys); + preempt_enable(); } memcpy(dst, src, len);