From owner-svn-src-all@freebsd.org Thu Dec 12 18:27:55 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4EBC71D8299; Thu, 12 Dec 2019 18:27:55 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47Yj2z1LZmz3xbK; Thu, 12 Dec 2019 18:27:55 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 28F2727C86; Thu, 12 Dec 2019 18:27:55 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBCIRs3a063751; Thu, 12 Dec 2019 18:27:54 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBCIRsco063749; Thu, 12 Dec 2019 18:27:54 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201912121827.xBCIRsco063749@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Thu, 12 Dec 2019 18:27:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355659 - in head/sys/arm64: arm64 include X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: in head/sys/arm64: arm64 include X-SVN-Commit-Revision: 355659 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Dec 2019 18:27:55 -0000 Author: andrew Date: Thu Dec 12 18:27:54 2019 New Revision: 355659 URL: https://svnweb.freebsd.org/changeset/base/355659 Log: Add comments and macros to the tcr_el1 setting code to help understand it. This code is non-obvious when reading for the first time. To help with understanding of it add comments explaining what it's doing. While here use macros from armreg.h rather than magic numbers. Sponsored by: DARPA, AFRL Modified: head/sys/arm64/arm64/locore.S head/sys/arm64/include/armreg.h Modified: head/sys/arm64/arm64/locore.S ============================================================================== --- head/sys/arm64/arm64/locore.S Thu Dec 12 18:16:32 2019 (r355658) +++ head/sys/arm64/arm64/locore.S Thu Dec 12 18:27:54 2019 (r355659) @@ -688,14 +688,23 @@ start_mmu: */ ldr x2, tcr mrs x3, id_aa64mmfr0_el1 - bfi x2, x3, #32, #3 - and x3, x3, #0xF0 - cmp x3, #0x20 + + /* Copy the bottom 3 bits from id_aa64mmfr0_el1 into TCR.IPS */ + bfi x2, x3, #(TCR_IPS_SHIFT), #(TCR_IPS_WIDTH) + and x3, x3, #(ID_AA64MMFR0_ASIDBits_MASK) + + /* Check if the HW supports 16 bit ASIDS */ + cmp x3, #(ID_AA64MMFR0_ASIDBits_16) + /* If so x3 == 1, else x3 == 0 */ cset x3, eq - bfi x2, x3, #36, #1 + /* Set TCR.AS with x3 */ + bfi x2, x3, #(TCR_ASID_SHIFT), #(TCR_ASID_WIDTH) + msr tcr_el1, x2 - /* Setup SCTLR */ + /* + * Setup SCTLR. + */ ldr x2, sctlr_set ldr x3, sctlr_clear mrs x1, sctlr_el1 Modified: head/sys/arm64/include/armreg.h ============================================================================== --- head/sys/arm64/include/armreg.h Thu Dec 12 18:16:32 2019 (r355658) +++ head/sys/arm64/include/armreg.h Thu Dec 12 18:27:54 2019 (r355659) @@ -619,9 +619,12 @@ #define PSR_FLAGS 0xf0000000 /* TCR_EL1 - Translation Control Register */ -#define TCR_ASID_16 (0x1UL << 36) +#define TCR_ASID_SHIFT 36 +#define TCR_ASID_WIDTH 1 +#define TCR_ASID_16 (0x1UL << TCR_ASID_SHIFT) #define TCR_IPS_SHIFT 32 +#define TCR_IPS_WIDTH 3 #define TCR_IPS_32BIT (0 << TCR_IPS_SHIFT) #define TCR_IPS_36BIT (1 << TCR_IPS_SHIFT) #define TCR_IPS_40BIT (2 << TCR_IPS_SHIFT)