From owner-svn-src-all@freebsd.org Fri Feb 1 20:46:48 2019 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 85A6614C0526; Fri, 1 Feb 2019 20:46:48 +0000 (UTC) (envelope-from kib@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 25D4E80DE9; Fri, 1 Feb 2019 20:46:48 +0000 (UTC) (envelope-from kib@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 EDC30242F4; Fri, 1 Feb 2019 20:46:47 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x11KklWm081667; Fri, 1 Feb 2019 20:46:47 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x11KklBT081666; Fri, 1 Feb 2019 20:46:47 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201902012046.x11KklBT081666@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 1 Feb 2019 20:46:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343667 - head/sys/x86/x86 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/x86/x86 X-SVN-Commit-Revision: 343667 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 25D4E80DE9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.950,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] 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: Fri, 01 Feb 2019 20:46:48 -0000 Author: kib Date: Fri Feb 1 20:46:47 2019 New Revision: 343667 URL: https://svnweb.freebsd.org/changeset/base/343667 Log: x86: correctly limit max memory resource address.. CPU and buses can manage up to the limit reported by cpu_maxphyaddr, so set mem_rman to the value returned by cpu_getmaxphyaddr(). For the PAE mode, it was missed both when rman_res_t was increased to uintmax_t, and from the PAE merge commit. When importing smaps or dump_avail chunks into memory rman, do not blindly ignore resources which ends above the limit, chomp them instead if start is below the limit. The same change was already done to i386 add_physmap_entry(). Based on the submission by: bde MFC after: 2 months Modified: head/sys/x86/x86/nexus.c Modified: head/sys/x86/x86/nexus.c ============================================================================== --- head/sys/x86/x86/nexus.c Fri Feb 1 20:42:49 2019 (r343666) +++ head/sys/x86/x86/nexus.c Fri Feb 1 20:46:47 2019 (r343667) @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -269,11 +270,7 @@ nexus_init_resources(void) panic("nexus_init_resources port_rman"); mem_rman.rm_start = 0; -#ifndef PAE - mem_rman.rm_end = BUS_SPACE_MAXADDR; -#else - mem_rman.rm_end = ((1ULL << cpu_maxphyaddr) - 1); -#endif + mem_rman.rm_end = cpu_getmaxphyaddr(); mem_rman.rm_type = RMAN_ARRAY; mem_rman.rm_descr = "I/O memory addresses"; if (rman_init(&mem_rman) @@ -787,6 +784,7 @@ ram_attach(device_t dev) { struct bios_smap *smapbase, *smap, *smapend; struct resource *res; + rman_res_t length; vm_paddr_t *p; caddr_t kmdp; uint32_t smapsize; @@ -807,16 +805,12 @@ ram_attach(device_t dev) if (smap->type != SMAP_TYPE_MEMORY || smap->length == 0) continue; -#ifdef __i386__ - /* - * Resources use long's to track resources, so - * we can't include memory regions above 4GB. - */ - if (smap->base > ~0ul) + if (smap->base > mem_rman.rm_end) continue; -#endif + length = smap->base + smap->length > mem_rman.rm_end ? + mem_rman.rm_end - smap->base : smap->length; error = bus_set_resource(dev, SYS_RES_MEMORY, rid, - smap->base, smap->length); + smap->base, length); if (error) panic( "ram_attach: resource %d failed set with %d", @@ -841,16 +835,12 @@ ram_attach(device_t dev) * segment is 0. */ for (rid = 0, p = dump_avail; p[1] != 0; rid++, p += 2) { -#ifdef PAE - /* - * Resources use long's to track resources, so we can't - * include memory regions above 4GB. - */ - if (p[0] > ~0ul) + if (p[0] > mem_rman.rm_end) break; -#endif + length = (p[1] > mem_rman.rm_end ? mem_rman.rm_end : p[1]) - + p[0]; error = bus_set_resource(dev, SYS_RES_MEMORY, rid, p[0], - p[1] - p[0]); + length); if (error) panic("ram_attach: resource %d failed set with %d", rid, error);