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: 1474511 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A3B54DF24C for ; Tue, 18 Sep 2012 19:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754261Ab2IRTSO (ORCPT ); Tue, 18 Sep 2012 15:18:14 -0400 Received: from mail-vb0-f46.google.com ([209.85.212.46]:62470 "EHLO mail-vb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754011Ab2IRTSM (ORCPT ); Tue, 18 Sep 2012 15:18:12 -0400 Received: by vbbff1 with SMTP id ff1so265512vbb.19 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=PF5rAoAoTJk+UbFP7337/LYMA3fobdLWJFp0gUymN/jSzdiVYwzGicJLyB+XynhB8B 6DWyXA/vriWS+P7QWpRcWhD6Z4njcOi35WochLkQ/MFFiWX81ms6JitxTzFJVk5YVFgW XQeuNV6viXGaYjIAmRwFY+6KK0gnH3sqRduMYQndJ0VJCVLMpIlLQ3mqR6hI1BMIkSCq cnxSfwPsVzxWJ8+HfNW91rv8kHOEJBTLYi2xxoOl4T+BPEpHGMnIXLOSbNxd0rZHi7aR iukCiBO5KOUfJ1Vu+r98fN80b6YGhDujOp21IKfKMcxgmfZ/2V7bsGCiexmjCVoizCkW jnVg== 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 Cc: "kvm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" X-Gm-Message-State: ALoCoQlKRDvm4Q3sojTsjowy8/P9aMJJJZP7kJm2v/ILhsk0xz7MjzXqPGOctGeQKVOOyd1t5w5F Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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. the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); -- To unsubscribe from this list: send the line "unsubscribe kvm" in