Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4157904pxv; Mon, 19 Jul 2021 18:46:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb3kaLXboFEQD/Kt6RKuTs41DP/o3g2t3+eWzubvkynaY+4+XcbADcIrQMGxowCWbCtJqx X-Received: by 2002:a5e:9918:: with SMTP id t24mr13356510ioj.24.1626745606750; Mon, 19 Jul 2021 18:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626745606; cv=none; d=google.com; s=arc-20160816; b=s3rbMO57PgR0sB0HWXMqvx8wQhp1+kZISD2EGL1AjPqrdc2gb8oKeQL9ZRtA2ZzQ58 cqk7iWJTcE+81qo5tfxTX86bkgkDkwvgppSSWCEmrC7kLjbWOLJAKLLJ6J1GQvGOrLqU jaoXjh9DbRVtXTPrbA3iRLSZSokf2zJSxFpwvVBCEzwnlonQ1DANZmH2LuDJzgYhUjP4 +5IhxtJMK8w42GQ9K1uasL9abD0hE7NUvKbovOiaGcRQACgcg0Z/NRNJTMfpI/rklIsV fspRJyWFbPZzXoxANoOdpgKNN5P0np/27W2qd2zFNy6ajGHEL46hc4XyX4nc9ALKliHf vq7g== 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=fkm6LZnfTqp/BthOG3rjm7Ue6RagtTuSJN/PWuQRzpc=; b=Sbnz2HlPDje2UxaD7fwtGs9+j3giod5slUFEnvWFmGbMKAKWMKAZkp12g33Am1/Fvj BHmU1PF2OTqDLYXR3lRUMAW0vJw8PQAM5nk5G2viOHqpoZ3DjzMNGnXLmMafqfv0PfEy MUpbhGFcYoeqIrWfoLgWHrZefp66gndmcPowDkWsWPiIokcO2rIwLRZ2k4SwMbN4WIgY El3Gvs1vS8mMs8t+V6Ld8/gnYlaQZSxlW/H7EH9kCF6adZknlhKNr/zVCk5tuv7VIY6f R/pV/Z61+RO54P/5vV/oFgsfSFi1Omc/7YowCrS2rL0LTDITZ1URUT/RLrXeXLzeqkua CLqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TfXzEb+o; 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 c1si12498563ilr.98.2021.07.19.18.46.34; Mon, 19 Jul 2021 18:46:46 -0700 (PDT) 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=TfXzEb+o; 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 S1344620AbhGSPCc (ORCPT + 99 others); Mon, 19 Jul 2021 11:02:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:60580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243621AbhGSOkU (ORCPT ); Mon, 19 Jul 2021 10:40:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 582C261073; Mon, 19 Jul 2021 15:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626708058; bh=Nj0Udr4R71nGxE+aMr8O49t+TEjcRM2tKiepHUjqTXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TfXzEb+oWFiUEp5RotncrGOSuO4ql2tfrpMNHuJ/FinH7IFqK/Boe0EEuLQOsvpev 8lA+AHml7+PdJxgQeAneEeJmqgdska8hkcjYxLImD4XabN57Sp2bUCLcquHXRDwhmc 9+H/CpMDrDTWJ+4nWzVaGp77mIOXfynxG53DGn3I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bibo Mao , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 4.14 164/315] hugetlb: clear huge pte during flush function on mips platform Date: Mon, 19 Jul 2021 16:50:53 +0200 Message-Id: <20210719144948.287487214@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@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: Bibo Mao [ Upstream commit 33ae8f801ad8bec48e886d368739feb2816478f2 ] If multiple threads are accessing the same huge page at the same time, hugetlb_cow will be called if one thread write the COW huge page. And function huge_ptep_clear_flush is called to notify other threads to clear the huge pte tlb entry. The other threads clear the huge pte tlb entry and reload it from page table, the reload huge pte entry may be old. This patch fixes this issue on mips platform, and it clears huge pte entry before notifying other threads to flush current huge page entry, it is similar with other architectures. Signed-off-by: Bibo Mao Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/include/asm/hugetlb.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h index 982bc0685330..4747a4694669 100644 --- a/arch/mips/include/asm/hugetlb.h +++ b/arch/mips/include/asm/hugetlb.h @@ -67,7 +67,13 @@ static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm, static inline void huge_ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) { - flush_tlb_page(vma, addr & huge_page_mask(hstate_vma(vma))); + /* + * clear the huge pte entry firstly, so that the other smp threads will + * not get old pte entry after finishing flush_tlb_page and before + * setting new huge pte entry + */ + huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); + flush_tlb_page(vma, addr); } static inline int huge_pte_none(pte_t pte) -- 2.30.2