From owner-svn-src-all@freebsd.org Wed Apr 4 02:13:28 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B9C3F863E7; Wed, 4 Apr 2018 02:13:28 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D299481EAF; Wed, 4 Apr 2018 02:13:27 +0000 (UTC) (envelope-from jhibbits@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 CD6F155A5; Wed, 4 Apr 2018 02:13:27 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w342DRhs043971; Wed, 4 Apr 2018 02:13:27 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w342DRG8043970; Wed, 4 Apr 2018 02:13:27 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201804040213.w342DRG8043970@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 4 Apr 2018 02:13:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331970 - head/sys/powerpc/booke X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/booke X-SVN-Commit-Revision: 331970 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.25 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: Wed, 04 Apr 2018 02:13:28 -0000 Author: jhibbits Date: Wed Apr 4 02:13:27 2018 New Revision: 331970 URL: https://svnweb.freebsd.org/changeset/base/331970 Log: Correct the ilog2() for calculating memory sizes. TLB1 can handle ranges up to 4GB (through e5500, larger in e6500), but ilog2() took a unsigned int, which maxes out at 4GB-1, but truncates silently. Increase the input range to the largest supported, at least for 64-bit targets. This lets the DMAP be completely mapped, instead of only 1GB blocks with it assuming being fully mapped. Modified: head/sys/powerpc/booke/pmap.c Modified: head/sys/powerpc/booke/pmap.c ============================================================================== --- head/sys/powerpc/booke/pmap.c Wed Apr 4 02:00:10 2018 (r331969) +++ head/sys/powerpc/booke/pmap.c Wed Apr 4 02:13:27 2018 (r331970) @@ -234,7 +234,7 @@ static vm_size_t tlb1_mapin_region(vm_offset_t, vm_pad static vm_size_t tsize2size(unsigned int); static unsigned int size2tsize(vm_size_t); -static unsigned int ilog2(unsigned int); +static unsigned int ilog2(unsigned long); static void set_mas4_defaults(void); @@ -4020,12 +4020,17 @@ tlb1_write_entry(tlb_entry_t *e, unsigned int idx) * Return the largest uint value log such that 2^log <= num. */ static unsigned int -ilog2(unsigned int num) +ilog2(unsigned long num) { - int lz; + long lz; +#ifdef __powerpc64__ + __asm ("cntlzd %0, %1" : "=r" (lz) : "r" (num)); + return (63 - lz); +#else __asm ("cntlzw %0, %1" : "=r" (lz) : "r" (num)); return (31 - lz); +#endif } /* @@ -4163,7 +4168,8 @@ tlb1_mapin_region(vm_offset_t va, vm_paddr_t pa, vm_si for (idx = 0; idx < nents; idx++) { pgsz = pgs[idx]; - debugf("%u: %llx -> %x, size=%x\n", idx, pa, va, pgsz); + debugf("%u: %llx -> %jx, size=%jx\n", idx, pa, + (uintmax_t)va, (uintmax_t)pgsz); tlb1_set_entry(va, pa, pgsz, _TLB_ENTRY_SHARED | _TLB_ENTRY_MEM); pa += pgsz;