From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: Carsten Otte <cotte@de.ibm.com>
Cc: Avi Kivity <avi@redhat.com>,
Marcelo Tossati <mtosatti@redhat.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
KVM <kvm@vger.kernel.org>,
Joachim von Buttlar <joachim_von_buttlar@de.ibm.com>,
Jens Freimann <jfrei@de.ibm.com>,
Constantin Werner <constantin.werner@de.ibm.com>,
agraf@suse.de
Subject: Re: [patch 10/12] [PATCH] kvm-s390: storage key interface
Date: Mon, 12 Dec 2011 11:06:23 +0100 [thread overview]
Message-ID: <20111212110623.7535c819@de.ibm.com> (raw)
In-Reply-To: <20111210123707.571900097@de.ibm.com>
On Sat, 10 Dec 2011 13:35:39 +0100
Carsten Otte <cotte@de.ibm.com> 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.
next prev parent reply other threads:[~2011-12-12 10:06 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-10 12:35 [patch 00/12] Ucontrol patchset V5 Carsten Otte
2011-12-10 12:35 ` [patch 01/12] [PATCH] kvm-s390: add parameter for KVM_CREATE_VM Carsten Otte
2011-12-12 9:13 ` Avi Kivity
2011-12-12 9:19 ` Carsten Otte
2011-12-10 12:35 ` [patch 02/12] [PATCH] kvm-s390-ucontrol: per vcpu address spaces Carsten Otte
2011-12-10 12:35 ` [patch 03/12] [PATCH] kvm-s390-ucontrol: export page faults to user Carsten Otte
2011-12-10 12:35 ` [patch 04/12] [PATCH] kvm-s390-ucontrol: export SIE control block " Carsten Otte
2011-12-10 12:35 ` [patch 05/12] [PATCH] kvm-s390-ucontrol: disable in-kernel handling of SIE intercepts Carsten Otte
2011-12-10 12:35 ` [patch 06/12] [PATCH] kvm-s390-ucontrol: disable in-kernel irq stack Carsten Otte
2011-12-10 12:35 ` [patch 07/12] [PATCH] kvm-s390-ucontrol: interface to inject faults on a vcpu page table Carsten Otte
2011-12-10 12:35 ` [patch 08/12] [PATCH] kvm-s390-ucontrol: disable sca Carsten Otte
2011-12-10 12:35 ` [patch 09/12] [PATCH] kvm-s390: fix assumption for KVM_MAX_VCPUS Carsten Otte
2011-12-10 12:35 ` [patch 10/12] [PATCH] kvm-s390: storage key interface Carsten Otte
2011-12-11 21:57 ` Heiko Carstens
2011-12-12 10:06 ` Martin Schwidefsky [this message]
2011-12-10 12:35 ` [patch 11/12] [PATCH] kvm-s390-ucontrol: announce capability for user controlled vms Carsten Otte
2011-12-10 12:35 ` [patch 12/12] [PATCH] kvm-s390: Fix return code for unknown ioctl numbers Carsten Otte
2011-12-12 9:15 ` [patch 00/12] Ucontrol patchset V5 Avi Kivity
2011-12-12 9:44 ` Carsten Otte
2011-12-12 9:49 ` Avi Kivity
2011-12-12 9:49 ` Carsten Otte
-- strict thread matches above, loose matches on Subject: below --
2011-12-14 12:23 [patch 00/12] Ucontrol patchset V6 Carsten Otte
2011-12-14 12:23 ` [patch 10/12] [PATCH] kvm-s390: storage key interface Carsten Otte
2011-12-15 10:28 ` Carsten Otte
2011-12-15 16:11 ` Heiko Carstens
2011-12-15 16:49 ` Christian Borntraeger
2011-12-15 17:18 ` Heiko Carstens
2011-12-15 17:14 ` Martin Schwidefsky
2011-12-09 12:49 [patch 00/12] Ucontrol patchset V4 Carsten Otte
2011-12-09 12:49 ` [patch 10/12] [PATCH] kvm-s390: storage key interface Carsten Otte
2011-12-09 13:46 ` Heiko Carstens
2011-12-10 11:36 ` Carsten Otte
2011-12-09 11:23 [patch 00/12] Ucontrol patches V3 Carsten Otte
2011-12-09 11:23 ` [patch 10/12] [PATCH] kvm-s390: storage key interface Carsten Otte
2011-12-09 12:04 ` Heiko Carstens
[not found] ` <OFEDB7DC8E.0D8BE463-ONC1257961.004633DF-C1257961.0046C1E7@de.ibm.com>
2011-12-09 13:37 ` Carsten Otte
2011-12-08 9:12 [patch 00/12] Ucontrol patchset V2 Carsten Otte
2011-12-08 9:12 ` [patch 10/12] [PATCH] kvm-s390: storage key interface Carsten Otte
2011-12-01 12:57 [patch 00/12] User controlled virtual machines Carsten Otte
2011-12-01 12:57 ` [patch 10/12] [PATCH] kvm-s390: storage key interface Carsten Otte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111212110623.7535c819@de.ibm.com \
--to=schwidefsky@de.ibm.com \
--cc=agraf@suse.de \
--cc=avi@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=constantin.werner@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=cotte@de.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=jfrei@de.ibm.com \
--cc=joachim_von_buttlar@de.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).