From owner-freebsd-hackers@freebsd.org Tue Oct 13 00:02:54 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8B7F9D1231 for ; Tue, 13 Oct 2015 00:02:54 +0000 (UTC) (envelope-from alc@rice.edu) Received: from pp1.rice.edu (proofpoint1.mail.rice.edu [128.42.201.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E306D2A; Tue, 13 Oct 2015 00:02:53 +0000 (UTC) (envelope-from alc@rice.edu) Received: from pps.filterd (pp1.rice.edu [127.0.0.1]) by pp1.rice.edu (8.15.0.59/8.15.0.59) with SMTP id t9CNwkb8013517; Mon, 12 Oct 2015 19:02:47 -0500 Received: from mh11.mail.rice.edu (mh11.mail.rice.edu [128.42.199.30]) by pp1.rice.edu with ESMTP id 1xgny700rm-1; Mon, 12 Oct 2015 19:02:47 -0500 X-Virus-Scanned: by amavis-2.7.0 at mh11.mail.rice.edu, auth channel Received: from 108-254-203-201.lightspeed.hstntx.sbcglobal.net (108-254-203-201.lightspeed.hstntx.sbcglobal.net [108.254.203.201]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) (Authenticated sender: alc) by mh11.mail.rice.edu (Postfix) with ESMTPSA id D5ADC4C025A; Mon, 12 Oct 2015 19:02:46 -0500 (CDT) Subject: Re: kernel pages superpage promotion/demotion To: suresh gumpula , alc@freebsd.org References: Cc: "freebsd-hackers@freebsd.org" From: Alan Cox Message-ID: <561C4A26.4000408@rice.edu> Date: Mon, 12 Oct 2015 19:02:46 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 kscore.is_bulkscore=0 kscore.compositescore=1 compositescore=0.9 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 kscore.is_spamscore=0 rbsscore=0.9 spamscore=0 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1507310000 definitions=main-1510120291 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Oct 2015 00:02:54 -0000 On 10/12/2015 18:39, suresh gumpula wrote: > Thanks a lot for quick reply Alan. > The super page promotion/demotion of kernel allocations is done in > 9.1 also I assume . Please confirm. > Yes. > Regarding write protection, I am trying to chase a corruption of uma > zone allocation, so I was looking at pmap_protect(9). > And thinking of using something like pmap_protect(kernel_pmap, sva , > eva, VMPROT_READ); to write protect sva to eva of a zone allocation > return address. > So can pmap_protect(9) be used for this purpose ? > Yes. However, you can't reenable write access, or in general upgrade access, with pmap_protect(). You'll need to use pmap_kextract(), PHYS_TO_VM_PAGE(), and pmap_enter() to recreate the mapping with write access. > > > > On Mon, Oct 12, 2015 at 6:43 PM, Alan Cox > wrote: > > > > On Mon, Oct 12, 2015 at 3:11 PM, suresh gumpula > > wrote: > > Hi, > I understand that user space VM map pages dynamically > promoted/demoted to super page > if the kernel thinks that it gains the performance. > The question is , does this apply to kernel map pages > too ? > > > > Yes, it applies to memory allocated for UMA zones, malloc(9), and > contigmalloc(9). > > > > And is it possible to write protect kernel address space VA with > pmap_protect(9). Since the protection is per 4k page, I > see this > routine tries to demote to 4k page. > Or this is only for user space maps to support mprotect(2) > and gdb > watchpoints. > Do we have any other API to write protect kernel addresses > which come from > UMA zone allocations ? > > > > No. > > Can you please try to describe what are you trying to do at a > higher level? > >