Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3384708lkq; Mon, 23 Nov 2020 04:28:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/oE3TBfZg/oMxZerK8ZZFhCH1Cgcff7eG3bY3YH+fONUZYApkRTgoJZZVXZT/x4OoozY2 X-Received: by 2002:a17:906:4482:: with SMTP id y2mr9643371ejo.342.1606134524733; Mon, 23 Nov 2020 04:28:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606134524; cv=none; d=google.com; s=arc-20160816; b=JHxdRX+shx0RShir9wKWAQYQd+UTW8GriqWdNU9xSxJHyxxUULNN0WoQo5hdKV6RIR krxYu8sUNj6tvZRoMx5tZcUxVuY46h5x0yZCWzZOK8BGG7QeHEV3qFgTHmeHSJTUydGM kK/2tD43TIQYj2fTgiNqpb3el/JKuiCFytXacc2JaLVBoJQTaiwPK6D0PKfqpdz9ct1b YqiEG8KK2pEqWGPmESp5oTR1UEt97lbg1vCyd4Rho4eZOIucEp8tT4zlEm3bmeRnyF6Y +kLe4b5lnDfnWmt1Ay+yuc8z7BJrJCfaQhbG2Nk06P63EnBToMdRMWMDnbEIusciQ6E6 AnVw== 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=2dkXf3lAtdGW8v6HYd60BlFbyeXr3srHAI0yGsaYZvM=; b=fOrY5Dn8FGot+EfNmxqRy0fPLJOROZ7jOFFTyLqwd3dKdtHNGau/Ta3NtPfifkhh5l ++PqesIzMST8h2iHZaYTGuKKHr/pQUctTCU6YntdvTQjrMcLnwUpHSSVqnVUx1UfYCSe +fx9GkVoM025nvfQWWcrKnWR0cAG/7S5CNF9s/qoiXNtX3g+z6T75ikl5u277nObdXcK zyY6HWOTL0c9obzYc93nY8lm+ySaJyc1NaONo0o87MhCDOgwkLdS5RDvPGUO5fuaRqWL vU9nXkaQg5LhFlCLIeLlQVQjNb39CWJauejpwt5ryFzxnqv8YZMocfWpgvVUenCX9Up2 pJwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xryB2eKF; 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 q3si6299599edr.472.2020.11.23.04.28.21; Mon, 23 Nov 2020 04:28:44 -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=xryB2eKF; 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 S1729678AbgKWMXt (ORCPT + 99 others); Mon, 23 Nov 2020 07:23:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:33064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729348AbgKWMXr (ORCPT ); Mon, 23 Nov 2020 07:23:47 -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 3228D20728; Mon, 23 Nov 2020 12:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134225; bh=gAAlDzrUMGhNxuLu2C37sf4hCUqOH66NvBy+b0HPFcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xryB2eKFXnfqhub2XaaLXK+ABcRE2B+jxkplM8aizbCUteJj9WDT0+2GNnmYVVewR pkU4eACkHWVoZ5OTizHmJosCWbqpXrxMP4z0yKy/plsvBe4i9qW0U1ptCwyy1yVUn2 1QdbPAtrqNIQ4qb3aQ0fmMZH1GodWBFLMIS1+fHA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Filippov Subject: [PATCH 4.4 32/38] xtensa: disable preemption around cache alias management calls Date: Mon, 23 Nov 2020 13:22:18 +0100 Message-Id: <20201123121805.833825108@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121804.306030358@linuxfoundation.org> References: <20201123121804.306030358@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 @@ -74,8 +74,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(); } } } @@ -162,6 +164,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); @@ -172,6 +175,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. */ @@ -204,8 +208,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(); } #endif @@ -231,11 +237,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); } @@ -269,7 +277,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 */ @@ -284,9 +294,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); @@ -308,7 +320,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);