From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755980AbcA3CtQ (ORCPT ); Fri, 29 Jan 2016 21:49:16 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:65512 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754157AbcA3CtN (ORCPT ); Fri, 29 Jan 2016 21:49:13 -0500 Message-ID: <56AC2462.20506@huawei.com> Date: Sat, 30 Jan 2016 10:48:02 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Mark Rutland CC: Ard Biesheuvel , Laura Abbott , Catalin Marinas , Will Deacon , Kees Cook , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , zhong jiang , , Hanjun Guo Subject: Re: [PATCH] arm64: Allow vmalloc regions to be set with set_memory_* References: <1452635187-8057-1-git-send-email-labbott@fedoraproject.org> <20160118115640.GK21067@leverpostej> <56A97328.9070003@huawei.com> <20160128105138.GE17123@leverpostej> <56A9FFBD.8030303@huawei.com> <20160128142746.GL17123@leverpostej> <56AABEA4.3010301@huawei.com> <20160129110252.GB17038@leverpostej> In-Reply-To: <20160129110252.GB17038@leverpostej> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.56AC2471.0094,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 0c7ca5aed2a0a0e23dce94840f57e078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/1/29 19:02, Mark Rutland wrote: > On Fri, Jan 29, 2016 at 09:21:40AM +0800, Xishi Qiu wrote: >> On 2016/1/28 22:27, Mark Rutland wrote: >>> On Thu, Jan 28, 2016 at 07:47:09PM +0800, Xishi Qiu wrote: >>>> Hi Mark, >>>> >>>> Is it safe in the following path? >>>> >>>> alloc the whole linear map section >>> >>> I don't understand what you mean by this, you will need to elaborate. >>> The terms "alloc" and "section" can mean a number of different things in >>> this context. >>> >>>> cpu A write something on it >>>> cpu B write something on it >>>> cpu C set read only flag and call flush_tlb_kernel_range() >>> >>> If you want to modify a portion of the linear map, this will not work. >>> Modfiying the linear map in this manner is not safe. >>> >>> If you want an alias of the linear map which was mapped using pages, and >>> you wanted to change that alias, that could work. >>> >> >> Hi Mark, >> >> I mean I change the whole section(maybe 1G?) in linear map. > > If you mean something that was mapped with a section (i.e. a block entry > in some level of page table), then no. The linear map is not open to > this kind of change, as portions of the region may be in use elsewhere > within Linux. > >> In our software, kernel create mapping(linear map) on special memory, >> and >> it is separated from buddy system, the service manage the special memory itself. > > This is not what the linear map is for. What exactly is this "special > memory"? > > Is it some persistent memory? > > Is it normal memory that you wish to use for some communication with > other agents and/or DMA? > > Is it normal memory that you simply have a special use-case for? > >> And the service alloc/free the memory based on the physical address, so if >> the service want to change the prot dynamically, vmalloc doesn't work, and >> fixmap is a little complex. > > Without further explanation of your use-case, this doesn't make sense to > me. I don't understand why the physical address matters -- that implies > you have other agents accessing this memory. If that's the case, I don't > see what changing the permissions buys you. > > Regardless, it sounds like either we're missing some infrastructure, or > you are mis-using existing APIs. > >> I think if I create the spacial memory in 4kb, then the service could >> use set_memory_ro() directly, right? > > Perhaps. If it's a vmalloc'd area, then yes (once Ard's patch to allow > that is in). I have more general concerns with your approach, in that I > still do not understand the problem you are trying to solve. > Hi Mark, Thanks for your reply. Maybe I didn't express it clearly, sorry for it. The abstract process is the following: 1. do not create a large block, use 4kb for all of the memory(regardless of performance). setup_arch->paging_init()->map_mem()->__map_memblock()->create_mapping() 2. alloc a page and get the the linear mapping address. 3. modify judgment condition of the function set_memory_ro(), so it could handle the linear mapping range. 4. use set_memory_ro() to change the prot flag of the page which we get in step 2. Is it safe? Thanks, Xishi Qiu > Thanks, > Mark. > > . >