Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2648628pxk; Mon, 14 Sep 2020 20:59:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhoA6SxpUYQ2mmFOHAzpF8QPk9Lui3qOOHaM/eMG9DjSIixzoZYwHE6KmOgKSfPn1QUrch X-Received: by 2002:a17:906:6b0b:: with SMTP id q11mr18522878ejr.412.1600142379141; Mon, 14 Sep 2020 20:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600142379; cv=none; d=google.com; s=arc-20160816; b=qqwVh5NcBSe293xjJ+lNVu+pnVd0BQ7DMGOYdFF57aYqSwP9G0OiJtXaiv3ERyW2KI uyTsCf5GJBCahFR8DtiHQ0qc/Ub+3iMVmQoDH5PEk17xCu3XeGr9/5o9pjQ1fVEZF7lU mVF52f2apl9AKMPz+zfo0WTXoO/UpFwPc7ckgbYuLZRDa3pIXvizlQAQamb0HAhorQmF hrobSDVSa26e+PocB50Cw2rw6QtfRNUnSlS9RmgDJPcAJks9IXvHJGspNgeKIX82V7qA LyrDZR9x2C/c8yoeGHcJwD7WPG1uXloCe7J+qtXZD16Stf/Et1bS+zAu7LzLGV7V6+uB d3qg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=pMJdPDx6ekVB7YXwuHGF9tRuH4E5JE+NQDZ61jgQOAI=; b=EDcRXscc8bPN1HAiAtdbU2I5XXnla8kpMgFs6RORyEOFqxuoRLZLjPVc6EDg8U6sHq 1Fi+J6jCOZb3wkXjvXmTahHELjT7G84SwpPIWbZtAPhxD8C9Bi5s5CeDMFiX4tdVO9uf 3RsIt3x8YQdpVs7ZnyBe5oEbpPqbw/aoud9Qk+pRDJ+szd+btO3rKpsq/HjaUw4MwuTo wqxKTk1yBKFA6QjbdiVCnAb21JCsbZys3EZ6TqqibvxYun0UXxjhyXuvGTZIwiIY0DxG RX/cZM8QXtHg9rm3rZwy4v9wsCF9tgQx/YjIj74l5D6+149nAYm1gaTYO5zVP2XrM2OT +FeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=XsWUXcEg; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si5071551edq.434.2020.09.14.20.59.15; Mon, 14 Sep 2020 20:59:39 -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=@sifive.com header.s=google header.b=XsWUXcEg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726087AbgIOD6d (ORCPT + 99 others); Mon, 14 Sep 2020 23:58:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726034AbgIOD61 (ORCPT ); Mon, 14 Sep 2020 23:58:27 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22D1EC06174A for ; Mon, 14 Sep 2020 20:58:26 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id p15so1119381qvk.5 for ; Mon, 14 Sep 2020 20:58:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=pMJdPDx6ekVB7YXwuHGF9tRuH4E5JE+NQDZ61jgQOAI=; b=XsWUXcEgYKKv3P64NV7Q3vzVgQRBa9DgiVHKTpZ0+n70fDfEpFHaX09lAAeS8cJyuo qJ6RFZ0fTnH6BODhgwBlyaSbUVDL02our7WLYqeVYwWp9xFvas+p/MZzmZuUh9NMv44S 6EPLUug67II6U9d7QmLhSmwCQVk+UncJJxDGpNOXjG+3CEaJcEEM2MuiWmvJOUw/ZsQE r9oVRAbzFOYVT1Wm8CtyMG2+IlY0w7OLYzrLrBPLz88rfrrWGLwthdQZxSN0i2ZCjUac RRWM4PTvxsjDGYU+UfDVM7zJMQA06pr0gdywnyHZdJhrs0/LuAPRNie/VKn8OwDqr/sO n8nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=pMJdPDx6ekVB7YXwuHGF9tRuH4E5JE+NQDZ61jgQOAI=; b=Z8yVgFUc5cxw4pnaKouB39Y5QZf9dgfd98pQqXEwUKyl8XhHSBECIKx3xtCTHxItXU 51pIUqL6sQG3Oml4FRiFHLG7vwwHT58eIKOHPvzsWqZ0/ZOzOUQoMhINapVYU3SmjS4N dTjxFhXNzth3nZ8LriP+1E0d0bVQ2cyPcMTk7hBHVjfMVnRDn2WPV5vSVCCmQukf23cM 9Vi3CgiTnqZaIhLdr7unqB3LCKTgfFX//nyAE4oCSqC1bMZ6gzYnYUQ7ADrLJ1G9ajDx jJnoO4vysz3Hdzyjtm/9y8RyfghBGRGnhkI6atDaRn+5GMDv3ucie4mbvY76bYsj3N1a RFLQ== X-Gm-Message-State: AOAM532X0x12IX4tsaEK4qvvXv49RZ4JzxhF8hwe20j224AJx5AZ2w+i 6AqjN4xyX61DNEJ3z1luHpAhIqbXM2hwQvt++bZcgQ== X-Received: by 2002:a0c:e649:: with SMTP id c9mr15787689qvn.16.1600142305934; Mon, 14 Sep 2020 20:58:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greentime Hu Date: Tue, 15 Sep 2020 11:58:13 +0800 Message-ID: Subject: Re: [PATCH] riscv: Add sfence.vma after page table changed To: Palmer Dabbelt Cc: Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Anup Patel , linux-riscv , Linux Kernel Mailing List , Albert Ou , Paul Walmsley , Syven Wang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Palmer Dabbelt =E6=96=BC 2020=E5=B9=B48=E6=9C=885=E6= =97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8A=E5=8D=8810:03=E5=AF=AB=E9=81=93=EF=BC= =9A > > On Mon, 03 Aug 2020 20:29:32 PDT (-0700), anup@brainfault.org wrote: > > On Tue, Aug 4, 2020 at 8:32 AM Greentime Hu w= rote: > >> > >> This patch addes local_flush_tlb_page(addr) to use sfence.vma after th= e > > > > s/addes/adds > > > >> page table changed. That address will be used immediately in > >> memset(nextp, 0, PAGE_SIZE) to cause this issue so we should add the > >> sfence.vma before we use it. > > > > Alternate version of this commit description can be: > > > > Invalidate local TLB after both set_pet() and clear_pte() because the > > address can be used immediately after page table change. > > > >> Fixes: f2c17aabc917 ("RISC-V: Implement compile-time fixed mappings") > >> > >> Reported-by: Syven Wang > >> Signed-off-by: Syven Wang > >> Signed-off-by: Greentime Hu > >> --- > >> arch/riscv/mm/init.c | 7 +++---- > >> 1 file changed, 3 insertions(+), 4 deletions(-) > >> > >> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > >> index f4adb3684f3d..29b0f7108054 100644 > >> --- a/arch/riscv/mm/init.c > >> +++ b/arch/riscv/mm/init.c > >> @@ -202,12 +202,11 @@ void __set_fixmap(enum fixed_addresses idx, phys= _addr_t phys, pgprot_t prot) > >> > >> ptep =3D &fixmap_pte[pte_index(addr)]; > >> > >> - if (pgprot_val(prot)) { > >> + if (pgprot_val(prot)) > >> set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, prot)); > >> - } else { > >> + else > >> pte_clear(&init_mm, addr, ptep); > >> - local_flush_tlb_page(addr); > >> - } > >> + local_flush_tlb_page(addr); > >> } > > arm64 appears to be upgrading all set_pte()s on valid kernel mappings to > include the fence. It looks like the message from 7f0b1bf04511 ("arm64: = Fix > barriers used for page table modifications") is out of date, as I can't f= ind > create_mapping() any more. If that was some generic kernel thing then we > should probably upgrade ours as well, but if it was arch/arm64/ code then= this > approach seems fine as __set_fixmap() isn't on the hot path -- I guess th= is is > fine either way, but there may be other issues that the arm64 approach fi= xes. > > Do you guys happen to remember what was going on here? Hi Palmer, Some architectures add cache writeback in set_pte(), just like nds32, csky. https://github.com/torvalds/linux/blob/master/arch/nds32/include/asm/pgtabl= e.h#L213 https://github.com/torvalds/linux/blob/master/arch/csky/include/asm/pgtable= .h#L104 Would you like to pick this patch or should I send another patch to implement it in set_pte()?