Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5080761ybf; Wed, 4 Mar 2020 16:58:53 -0800 (PST) X-Google-Smtp-Source: ADFU+vuWxGKk08mDlp+s9+zxtAj4fd1SuCVciCXLf1Wc9QMvXaex2GUWFlC/6tNyjVgDaujBKVr1 X-Received: by 2002:a9d:7a59:: with SMTP id z25mr4723242otm.315.1583369933374; Wed, 04 Mar 2020 16:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583369933; cv=none; d=google.com; s=arc-20160816; b=I6OQOBO1AYWQTl1B9N6CCcL2apH4Ash0B9qaYWeUpQkc4ToPqVwofh39/2oazJAIsq Fho9WysuY5u55T/tRobs0OBBqo38Q9/aYBhVw/EtnSwIUdrzg10SFEPnThpFG2CUGGut 0VFGqDhbjZliWUue/YyJIgtVNMR1k9+AYAfENNPlWqNPndzTTd234dWVSHqtVYJ3yHJs Gn8ZGwTOXnwBIjRAoiwe9Af3hAMZtXEvyNtZ6IGm2ARnam177vp17OMrJWKcgHe7Rku0 tA0kfpNcvLjia4R8umz+kfYku0khlmpBVGVSKkwiz4tUPUgP4sXqqGZpoIWJfgskBAgC wiZA== 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 :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=o9J+supnrYLSUg8HBVX6gCsPDHMxj5Rl4InzzMMgNk4=; b=VRY4jRuGGAT28x02MepVEW2X1OuIBbQrzXRfc+FQOCgysBKwYF0rU8/bbUFIUv8z/N r5RIJId82i8PV1o72iZutv+N6QnqfJKAcsay0fTi2cWEypG7kyKZNMG2O4TSHrMxSCJy duwWWASbOvvU9DsRNbv+pSfE14+mtXWQJURb+ctEqvaw+PPLPPebaQVd47gv9QuQAvaI aaWQL+Ou8S/Ojoxi/00ZGqbSYcfAehG4ivb0x2B6LUECvGyO2y8EIfW2B/hL9q5bDIrl XwmmJ38cswyrMRKN5CzKQGzkWpHI7wgPKfJfvsBClcUiV11cOZ4gT/OoRFyjlWd6ZXqh mp2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=hQ+wDCVa; 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 l74si2107373oib.233.2020.03.04.16.58.42; Wed, 04 Mar 2020 16:58:53 -0800 (PST) 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=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=hQ+wDCVa; 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 S1725948AbgCEA5r (ORCPT + 99 others); Wed, 4 Mar 2020 19:57:47 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41873 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbgCEA5q (ORCPT ); Wed, 4 Mar 2020 19:57:46 -0500 Received: by mail-pg1-f196.google.com with SMTP id b1so1871251pgm.8 for ; Wed, 04 Mar 2020 16:57:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=o9J+supnrYLSUg8HBVX6gCsPDHMxj5Rl4InzzMMgNk4=; b=hQ+wDCVa7veVaJOhswZk31E6FovSFwVCXjKkZlGb9+jgYG+l3dTnq4geE0epl3SxRI NSnKJfat/3r9aLQUlt3YeW8qEtcAIlpPEvBe/7ZeoGsMa6PE430uieuyq5TFAO5eiFp4 91JSSEx7G5SiDY4luoBPcluAqk3EL83j0I57DQPd9Hi4FJ/kKRjNybyqAuPzad4ryisR 98Hr9aU5zKVbnqqMT4bsr+q6HpbCOOrlvqO7tX5Uq086/Yaoact3aTdhiLWuYjhL0aA8 ivwsIhYpHA7gpkGF24f2+1kjwqtnps6vlbBtH+iR8f8dHX7S2I2gUZRAbhlt/IVdU9/m ofFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=o9J+supnrYLSUg8HBVX6gCsPDHMxj5Rl4InzzMMgNk4=; b=hWwM+ZyNYK3w48cym9aYLkDJZQoOyGzQ7rUjlSSULJlSO7WLhjOiUmDwXmx0UJ/PHP lLUDmVAgZyB2ysQMY7WGQoqjPGrrxVJ1LjnUGGmsneCD2gHVRaGMXofplTjTJ3B8nVOH yij5UpL9Pvfwc11G65Z7MrkzQHZZv4ogA5Jq5UBHAog/puSx0CZhngmEjTuthmMTDEIB o7HktgwExLVHiI7h0AAQj+ddN3fFgXWM1cTMXxpPC1PiXhQNFv5W991dKF3BhHhIheV7 0T9PPUXXxhptxUvnQZPpIDdgJBHJbK2T3S58RyBu/nl75jgjcN66+Nd07fnDabVPTUEH XoCA== X-Gm-Message-State: ANhLgQ1cSRvMdnQPVXyq1k211bLRrYJjgbkMumo7vzBMOSXruPQkDJzI mWTDAb4Zc8SMd7G4eqTMmt7LyA== X-Received: by 2002:a62:e20e:: with SMTP id a14mr5669133pfi.138.1583369864936; Wed, 04 Mar 2020 16:57:44 -0800 (PST) Received: from localhost ([2620:0:1000:2514:23a5:d584:6a92:3e3c]) by smtp.gmail.com with ESMTPSA id d82sm12867200pfd.187.2020.03.04.16.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 16:57:43 -0800 (PST) Date: Wed, 04 Mar 2020 16:57:43 -0800 (PST) X-Google-Original-Date: Wed, 04 Mar 2020 16:28:27 PST (-0800) Subject: Re: [PATCH 2/8] riscv: add ARCH_HAS_SET_DIRECT_MAP support In-Reply-To: <20200217083223.2011-3-zong.li@sifive.com> CC: Paul Walmsley , aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, zong.li@sifive.com From: Palmer Dabbelt To: zong.li@sifive.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 17 Feb 2020 00:32:17 PST (-0800), zong.li@sifive.com wrote: > Add set_direct_map_*() functions for setting the direct map alias for > the page to its default permissions and to an invalid state that cannot > be cached in a TLB. (See d253ca0c ("x86/mm/cpa: Add set_direct_map_*() > functions")) Add a similar implementation for RISC-V. > > Signed-off-by: Zong Li > --- > arch/riscv/Kconfig | 1 + > arch/riscv/include/asm/set_memory.h | 3 +++ > arch/riscv/mm/pageattr.c | 24 ++++++++++++++++++++++++ > 3 files changed, 28 insertions(+) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 76ed36543b3a..07bf1a7c0dd2 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -60,6 +60,7 @@ config RISCV > select HAVE_EBPF_JIT if 64BIT > select EDAC_SUPPORT > select ARCH_HAS_GIGANTIC_PAGE > + select ARCH_HAS_SET_DIRECT_MAP > select ARCH_HAS_SET_MEMORY > select ARCH_WANT_HUGE_PMD_SHARE if 64BIT > select SPARSEMEM_STATIC if 32BIT > diff --git a/arch/riscv/include/asm/set_memory.h b/arch/riscv/include/asm/set_memory.h > index 936f08063566..a9783a878dca 100644 > --- a/arch/riscv/include/asm/set_memory.h > +++ b/arch/riscv/include/asm/set_memory.h > @@ -14,4 +14,7 @@ int set_memory_rw(unsigned long addr, int numpages); > int set_memory_x(unsigned long addr, int numpages); > int set_memory_nx(unsigned long addr, int numpages); > > +int set_direct_map_invalid_noflush(struct page *page); > +int set_direct_map_default_noflush(struct page *page); > + > #endif /* _ASM_RISCV_SET_MEMORY_H */ > diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c > index fcd59ef2835b..7be6cd67e2ef 100644 > --- a/arch/riscv/mm/pageattr.c > +++ b/arch/riscv/mm/pageattr.c > @@ -148,3 +148,27 @@ int set_memory_nx(unsigned long addr, int numpages) > { > return __set_memory(addr, numpages, __pgprot(0), __pgprot(_PAGE_EXEC)); > } > + > +int set_direct_map_invalid_noflush(struct page *page) > +{ > + unsigned long start = (unsigned long)page_address(page); > + unsigned long end = start + PAGE_SIZE; > + struct pageattr_masks masks = { > + .set_mask = __pgprot(0), > + .clear_mask = __pgprot(_PAGE_PRESENT) > + }; > + > + return walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); > +} > + > +int set_direct_map_default_noflush(struct page *page) > +{ > + unsigned long start = (unsigned long)page_address(page); > + unsigned long end = start + PAGE_SIZE; > + struct pageattr_masks masks = { > + .set_mask = PAGE_KERNEL, > + .clear_mask = __pgprot(0) > + }; > + > + return walk_page_range(&init_mm, start, end, &pageattr_ops, &masks); > +} Reviewed-by: Palmer Dabbelt