From owner-svn-src-head@FreeBSD.ORG Sun Sep 7 18:32:43 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EAA081A1; Sun, 7 Sep 2014 18:32:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (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 CA7231BEF; Sun, 7 Sep 2014 18:32:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s87IWgRY035306; Sun, 7 Sep 2014 18:32:42 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s87IWgNx035305; Sun, 7 Sep 2014 18:32:42 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201409071832.s87IWgNx035305@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sun, 7 Sep 2014 18:32:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271232 - head/sys/arm/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Sep 2014 18:32:43 -0000 Author: andrew Date: Sun Sep 7 18:32:42 2014 New Revision: 271232 URL: http://svnweb.freebsd.org/changeset/base/271232 Log: Generalise the va to pa code and use it when starting secondary cores Reviewed by: ian@, rpaulo@ Differential Revision: https://reviews.freebsd.org/D736 Modified: head/sys/arm/arm/locore.S Modified: head/sys/arm/arm/locore.S ============================================================================== --- head/sys/arm/arm/locore.S Sun Sep 7 18:30:29 2014 (r271231) +++ head/sys/arm/arm/locore.S Sun Sep 7 18:32:42 2014 (r271232) @@ -152,21 +152,7 @@ Lunmapped: /* Find the delta between VA and PA */ adr r0, Lpagetable - ldr r1, [r0] - sub r2, r1, r0 - /* At this point: r2 = VA - PA */ - - /* - * Find the physical address of the table. After these two - * instructions: - * r1 = va(pagetable) - * - * r0 = va(pagetable) - (VA - PA) - * = va(pagetable) - VA + PA - * = pa(pagetable) - */ - ldr r1, [r0, #4] - sub r0, r1, r2 + bl translate_va_to_pa #ifndef _ARM_ARCH_6 /* @@ -289,6 +275,41 @@ virt_done: /* NOTREACHED */ END(_start) +#define VA_TO_PA_POINTER(name, table) \ +name: ;\ + .word . ;\ + .word table + +/* + * Returns the physical address of a magic va to pa pointer. + * r0 - The pagetable data pointer. This must be built using the + * VA_TO_PA_POINTER macro. + * e.g. + * VA_TO_PA_POINTER(Lpagetable, pagetable) + * ... + * adr r0, Lpagetable + * bl translate_va_to_pa + * r0 will now contain the physical address of pagetable + * r1, r2 - Trashed + */ +translate_va_to_pa: + ldr r1, [r0] + sub r2, r1, r0 + /* At this point: r2 = VA - PA */ + + /* + * Find the physical address of the table. After these two + * instructions: + * r1 = va(pagetable) + * + * r0 = va(pagetable) - (VA - PA) + * = va(pagetable) - VA + PA + * = pa(pagetable) + */ + ldr r1, [r0, #4] + sub r0, r1, r2 + RET + /* * Builds the page table * r0 - The table base address @@ -320,9 +341,7 @@ build_pagetables: RET -Lpagetable: - .word . - .word pagetable +VA_TO_PA_POINTER(Lpagetable, pagetable) Lvirtaddr: .word KERNVIRTADDR @@ -368,8 +387,7 @@ pagetable: .Lmpvirt_done: .word mpvirt_done -Lstartup_pagetable_secondary: - .word temp_pagetable +VA_TO_PA_POINTER(Lstartup_pagetable_secondary, temp_pagetable) ASENTRY_NP(mpentry) @@ -396,10 +414,12 @@ ASENTRY_NP(mpentry) bl armv7_idcache_inv_all /* Modifies r0-r3, ip */ #endif - ldr r0, Lstartup_pagetable_secondary - bic r0, r0, #0xf0000000 - orr r0, r0, #PHYSADDR + /* Load the page table physical address */ + adr r0, Lstartup_pagetable_secondary + bl translate_va_to_pa + /* Load the address the secondary page table */ ldr r0, [r0] + orr r0, r0, #2 /* Set TTB shared memory flag */ mcr p15, 0, r0, c2, c0, 0 /* Set TTB */ mcr p15, 0, r0, c8, c7, 0 /* Flush TLB */