Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1018708ybe; Wed, 4 Sep 2019 11:13:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiIEhpAqBJul3jLGdnbYkkoJZIrLc5b/P45EXg2i5xluB2Z2xSOPPvYwCi8sQv6NhEleiQ X-Received: by 2002:a63:2026:: with SMTP id g38mr35497788pgg.172.1567620807169; Wed, 04 Sep 2019 11:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620807; cv=none; d=google.com; s=arc-20160816; b=GW2dwKDV3jziS3r2y/TRISiKyzEr6xHH0LaDzAyMTiywCl5sy3fS3Gw3HoufrRCsbQ M6e6iqi8659/2PbccNAshhHnSpR2V27GT1FylXw/okIJqp7dNs4EY38PDF2HI1axtDjL xSfz+68ZZyZ6xRjRCcED+BxzKjb/rGACrqlU4igrdaK23q3cHjx6yLCnohMrJL7xBIH1 krxnxNH3VtnSl4TpfTJSBQtKjFfCl0lsDgYxHPr0W8K+YL+WkeNJ9CtCO1yaH3dh3B5F LFrWRKzmf7wTm7KSmphLDeqzFmN1cdjmVcs6URwU7acAcvkpd/MaCZ3zdIWcVtRMbyku hnFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SlrW7RqbafkUel/eiPVhnawaMLQ2bVtlWZu6c7753yQ=; b=XelKhVYg++R8ID8YhsoH223+tyT3kOMY0H97JjA/GuP/rS5dwKVZw5iQzExGKYvITG THzUMlrjRTJfdrra405AitvlENBPZaHvWt1fd8YUfPe9aqGhtid3YXJChM/wq8anuz5J 4pgdddh4XKw1WK+WzAa+rqz6uI1Z7UvbXf4U6J9G8NRQJvlQloF7wK+78VgRiIOyLXhN W8gUAGGdglR5xGrv/e5LSz9CGyRoszZ6DbX3+K3B/kuPxzQAyKWsE2YI07SD54JLZheb tLWKHEw5CVj5auN1xshHiS8kmncAbRV1ZxeLxXqrjmJ/GiaadQ7EJNtSbyJFOtBX3BAR 70iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iNsg+xPI; 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 w14si17893418plp.212.2019.09.04.11.13.10; Wed, 04 Sep 2019 11:13:27 -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=iNsg+xPI; 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 S2390105AbfIDSKa (ORCPT + 99 others); Wed, 4 Sep 2019 14:10:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:54060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389398AbfIDSK2 (ORCPT ); Wed, 4 Sep 2019 14:10:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 6CE2F22CEA; Wed, 4 Sep 2019 18:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620628; bh=KrPtQpgU7KtViUDDEEXsHPNbJbqCycwcitUbwT9Qoy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iNsg+xPI8DnbsydnLs29l+dysrhB+hqzpwQdwe9mymDFI135V4Q886Qvarc0xbllR BMnGwbUce7Z8FEL9Lm0JfgUrj2yUN5qdr5/7GLO3hX5ZqalkssvnP7ggzJU8QONcNk VcmxjDc4J476VGvxj2bbHfj8dGWmSilv6jOrVoyo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Schwab , Paul Walmsley , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.2 035/143] riscv: fix flush_tlb_range() end address for flush_tlb_page() Date: Wed, 4 Sep 2019 19:52:58 +0200 Message-Id: <20190904175315.422903595@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit eb93685847a9055283d05951c1b205e737f38533 ] The RISC-V kernel implementation of flush_tlb_page() when CONFIG_SMP is set is wrong. It passes zero to flush_tlb_range() as the final address to flush, but it should be at least 'addr'. Some other Linux architecture ports use the beginning address to flush, plus PAGE_SIZE, as the final address to flush. This might flush slightly more than what's needed, but it seems unlikely that being more clever would improve anything. So let's just take that implementation for now. While here, convert the macro into a static inline function, primarily to avoid unintentional multiple evaluations of 'addr'. This second version of the patch fixes a coding style issue found by Christoph Hellwig . Reported-by: Andreas Schwab Signed-off-by: Paul Walmsley Reviewed-by: Christoph Hellwig Signed-off-by: Sasha Levin --- arch/riscv/include/asm/tlbflush.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/tlbflush.h b/arch/riscv/include/asm/tlbflush.h index 687dd19735a7e..4d9bbe8438bf6 100644 --- a/arch/riscv/include/asm/tlbflush.h +++ b/arch/riscv/include/asm/tlbflush.h @@ -53,10 +53,17 @@ static inline void remote_sfence_vma(struct cpumask *cmask, unsigned long start, } #define flush_tlb_all() sbi_remote_sfence_vma(NULL, 0, -1) -#define flush_tlb_page(vma, addr) flush_tlb_range(vma, addr, 0) + #define flush_tlb_range(vma, start, end) \ remote_sfence_vma(mm_cpumask((vma)->vm_mm), start, (end) - (start)) -#define flush_tlb_mm(mm) \ + +static inline void flush_tlb_page(struct vm_area_struct *vma, + unsigned long addr) +{ + flush_tlb_range(vma, addr, addr + PAGE_SIZE); +} + +#define flush_tlb_mm(mm) \ remote_sfence_vma(mm_cpumask(mm), 0, -1) #endif /* CONFIG_SMP */ -- 2.20.1