From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Schwidefsky Subject: Re: [patch 10/12] [PATCH] kvm-s390: storage key interface Date: Mon, 12 Dec 2011 11:06:23 +0100 Message-ID: <20111212110623.7535c819@de.ibm.com> References: <20111210123529.379102332@de.ibm.com> <20111210123707.571900097@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Avi Kivity , Marcelo Tossati , Christian Borntraeger , Heiko Carstens , Cornelia Huck , KVM , Joachim von Buttlar , Jens Freimann , Constantin Werner , agraf@suse.de To: Carsten Otte Return-path: Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:48021 "EHLO e06smtp16.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750748Ab1LLKGf (ORCPT ); Mon, 12 Dec 2011 05:06:35 -0500 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 12 Dec 2011 10:06:33 -0000 Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBCA6QGI2719994 for ; Mon, 12 Dec 2011 10:06:26 GMT Received: from d06av08.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBCA6OUv026704 for ; Mon, 12 Dec 2011 10:06:25 GMT In-Reply-To: <20111210123707.571900097@de.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sat, 10 Dec 2011 13:35:39 +0100 Carsten Otte wrote: > --- a/arch/s390/mm/pgtable.c > +++ b/arch/s390/mm/pgtable.c > @@ -393,6 +393,33 @@ out_unmap: > } > EXPORT_SYMBOL_GPL(gmap_map_segment); > > +static pmd_t *__pmdp_for_addr(struct mm_struct *mm, unsigned long addr) > +{ > + struct vm_area_struct *vma; > + pgd_t *pgd; > + pud_t *pud; > + pmd_t *pmd; > + > + vma = find_vma(mm, addr); > + if (!vma || (vma->vm_start > addr)) > + return ERR_PTR(-EFAULT); > + > + pgd = pgd_offset(mm, addr); > + pud = pud_alloc(mm, pgd, addr); > + if (!pud) > + return ERR_PTR(-ENOMEM); > + > + pmd = pmd_alloc(mm, pud, addr); > + if (!pmd) > + return ERR_PTR(-ENOMEM); > + > + if (!pmd_present(*pmd) && > + __pte_alloc(mm, vma, pmd, addr)) > + return ERR_PTR(-ENOMEM); > + > + return pmd; > +} > + > /* > * this function is assumed to be called with mmap_sem held > */ The __pmdp_for_addr function is fine for the usage in __gmap_fault. > @@ -806,6 +820,26 @@ int s390_enable_sie(void) > } > EXPORT_SYMBOL_GPL(s390_enable_sie); > > +pte_t *ptep_for_addr(unsigned long addr) > +{ > + pmd_t *pmd; > + pte_t *pte; > + > + down_read(¤t->mm->mmap_sem); > + > + pmd = __pmdp_for_addr(current->mm, addr); > + if (IS_ERR(pmd)) { > + pte = (pte_t *)pmd; > + goto up_out; > + } > + > + pte = pte_offset(pmd, addr); > +up_out: > + up_read(¤t->mm->mmap_sem); > + return pte; > +} > +EXPORT_SYMBOL_GPL(ptep_for_addr); > + > #if defined(CONFIG_DEBUG_PAGEALLOC) && defined(CONFIG_HIBERNATION) > bool kernel_page_present(struct page *page) > { There is a fundamental locking sanfu. The pointer the the page table entry is only valid until the mmap_sem is released. The down_read/up_read has to be done in the caller. -- blue skies, Martin. "Reality continues to ruin my life." - Calvin.