From patchwork Tue Sep 18 19:18:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 1474521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 114A0DF24C for ; Tue, 18 Sep 2012 19:20:21 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TE3JK-0006Ow-3d; Tue, 18 Sep 2012 19:18:18 +0000 Received: from mail-vc0-f177.google.com ([209.85.220.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TE3JG-0006Oi-Ks for linux-arm-kernel@lists.infradead.org; Tue, 18 Sep 2012 19:18:15 +0000 Received: by vcqp16 with SMTP id p16so278145vcq.36 for ; Tue, 18 Sep 2012 12:18:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=Wx++2Uel3yArpeBoAnpAWnCWHG/6OKozHH3Juc9DvOk=; b=hdRE3q2WFq6s5pbKwPTS78kD5GltuQhwQiocW0pVjQsszfw4scTH2ejySpLmvxTz0K Y//7F0JLdTqfmuhBWb9qSvk9egcJLsd5JV+TndGRJ5sy/eyeskhXwT8tLyQy6z7YRZ+Q +1sWfDm59GzBnpIK3e+LPelz768Ctjmxtj3VgnK6FaZdD7VXeHhdf/IvT5TDe+iNe8vw IvG8K2fjljcYiqNobjMoHIG3M+J94MK6lTC+M+ttyzvIJGk3GjA4AhZeHF335rgFq/Q/ 88gAe7XCqOblod34vpkWBR5lOR0gRycTdrwqKGQ5u8jm7ryr1k7fH2oPeGyW4scBpc7p WQHg== MIME-Version: 1.0 Received: by 10.58.247.165 with SMTP id yf5mr513554vec.50.1347995892319; Tue, 18 Sep 2012 12:18:12 -0700 (PDT) Received: by 10.58.127.97 with HTTP; Tue, 18 Sep 2012 12:18:12 -0700 (PDT) X-Originating-IP: [128.59.22.176] In-Reply-To: <20120918122308.GJ32204@mudshark.cambridge.arm.com> References: <20120915153359.21241.86002.stgit@ubuntu> <20120915153436.21241.95691.stgit@ubuntu> <20120918122308.GJ32204@mudshark.cambridge.arm.com> Date: Tue, 18 Sep 2012 15:18:12 -0400 Message-ID: Subject: Re: [PATCH 01/15] ARM: add mem_type prot_pte accessor From: Christoffer Dall To: Will Deacon X-Gm-Message-State: ALoCoQnYHRbtvINb8k/XW0WSskEseDEHWRb03qGYHC3urGhhFFm1nH4RYYnXb/EvGD3hSWicmsjl X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.177 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: "linux-arm-kernel@lists.infradead.org" , "kvm@vger.kernel.org" , "kvmarm@lists.cs.columbia.edu" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Tue, Sep 18, 2012 at 8:23 AM, Will Deacon wrote: > On Sat, Sep 15, 2012 at 04:34:36PM +0100, Christoffer Dall wrote: >> From: Marc Zyngier >> >> The KVM hypervisor mmu code requires access to the mem_type prot_pte >> field when setting up page tables pointing to a device. Unfortunately, >> the mem_type structure is opaque. >> >> Add an accessor (get_mem_type_prot_pte()) to retrieve the prot_pte >> value. >> >> Signed-off-by: Marc Zyngier >> Signed-off-by: Christoffer Dall >> --- >> arch/arm/include/asm/mach/map.h | 1 + >> arch/arm/mm/mmu.c | 6 ++++++ >> 2 files changed, 7 insertions(+) >> >> diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h >> index a6efcdd..3787c9f 100644 >> --- a/arch/arm/include/asm/mach/map.h >> +++ b/arch/arm/include/asm/mach/map.h >> @@ -37,6 +37,7 @@ extern void iotable_init(struct map_desc *, int); >> >> struct mem_type; >> extern const struct mem_type *get_mem_type(unsigned int type); >> +extern pteval_t get_mem_type_prot_pte(unsigned int type); >> /* >> * external interface to remap single page with appropriate type >> */ >> diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c >> index 4c2d045..76bf4f5 100644 >> --- a/arch/arm/mm/mmu.c >> +++ b/arch/arm/mm/mmu.c >> @@ -301,6 +301,12 @@ const struct mem_type *get_mem_type(unsigned int type) >> } >> EXPORT_SYMBOL(get_mem_type); >> >> +pteval_t get_mem_type_prot_pte(unsigned int type) >> +{ >> + return get_mem_type(type)->prot_pte; >> +} >> +EXPORT_SYMBOL(get_mem_type_prot_pte); >> + > > get_mem_type can return NULL, so you should probably pass the error through > rather than dereferencing it. > right, I guess callers can check against 0, since L_PTE_PRESENT should always be there. diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index a153fd4..f2b6287 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -305,7 +305,9 @@ EXPORT_SYMBOL(get_mem_type); pteval_t get_mem_type_prot_pte(unsigned int type) { - return get_mem_type(type)->prot_pte; + if (get_mem_type(type)) + return get_mem_type(type)->prot_pte; + return 0; } EXPORT_SYMBOL(get_mem_type_prot_pte);