From owner-svn-src-stable-11@freebsd.org Sat Apr 14 17:41:55 2018 Return-Path: Delivered-To: svn-src-stable-11@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 913D0F8C46D; Sat, 14 Apr 2018 17:41:55 +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.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 45D1C69D7B; Sat, 14 Apr 2018 17:41:55 +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 40DAE2B5E9; Sat, 14 Apr 2018 17:41:55 +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 w3EHftiR093680; Sat, 14 Apr 2018 17:41:55 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3EHfsY9093677; Sat, 14 Apr 2018 17:41:54 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201804141741.w3EHfsY9093677@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 14 Apr 2018 17:41:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332505 - in stable/11/sys: amd64/amd64 vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 vm X-SVN-Commit-Revision: 332505 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Apr 2018 17:41:55 -0000 Author: kib Date: Sat Apr 14 17:41:54 2018 New Revision: 332505 URL: https://svnweb.freebsd.org/changeset/base/332505 Log: MFC r332182: Handle Skylake-X errata SKZ63. Modified: stable/11/sys/amd64/amd64/pmap.c stable/11/sys/vm/vm_page.c stable/11/sys/vm/vm_page.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/pmap.c ============================================================================== --- stable/11/sys/amd64/amd64/pmap.c Sat Apr 14 17:33:16 2018 (r332504) +++ stable/11/sys/amd64/amd64/pmap.c Sat Apr 14 17:41:54 2018 (r332505) @@ -1224,7 +1224,35 @@ pmap_init(void) struct pmap_preinit_mapping *ppim; vm_page_t mpte; vm_size_t s; - int error, i, pv_npg; + int error, i, pv_npg, ret, skz63; + + /* Detect bare-metal Skylake Server and Skylake-X. */ + if (vm_guest == VM_GUEST_NO && cpu_vendor_id == CPU_VENDOR_INTEL && + CPUID_TO_FAMILY(cpu_id) == 0x6 && CPUID_TO_MODEL(cpu_id) == 0x55) { + /* + * Skylake-X errata SKZ63. Processor May Hang When + * Executing Code In an HLE Transaction Region between + * 40000000H and 403FFFFFH. + * + * Mark the pages in the range as preallocated. It + * seems to be impossible to distinguish between + * Skylake Server and Skylake X. + */ + skz63 = 1; + TUNABLE_INT_FETCH("hw.skz63_enable", &skz63); + if (skz63 != 0) { + if (bootverbose) + printf("SKZ63: skipping 4M RAM starting " + "at physical 1G\n"); + for (i = 0; i < atop(0x400000); i++) { + ret = vm_page_blacklist_add(0x40000000 + + ptoa(i), FALSE); + if (!ret && bootverbose) + printf("page at %#lx already used\n", + 0x40000000 + ptoa(i)); + } + } + } /* * Initialize the vm page array entries for the kernel pmap's Modified: stable/11/sys/vm/vm_page.c ============================================================================== --- stable/11/sys/vm/vm_page.c Sat Apr 14 17:33:16 2018 (r332504) +++ stable/11/sys/vm/vm_page.c Sat Apr 14 17:41:54 2018 (r332505) @@ -292,6 +292,27 @@ vm_page_blacklist_next(char **list, char *end) return (0); } +bool +vm_page_blacklist_add(vm_paddr_t pa, bool verbose) +{ + vm_page_t m; + int ret; + + m = vm_phys_paddr_to_vm_page(pa); + if (m == NULL) + return (true); /* page does not exist, no failure */ + + mtx_lock(&vm_page_queue_free_mtx); + ret = vm_phys_unfree_page(m); + mtx_unlock(&vm_page_queue_free_mtx); + if (ret) { + TAILQ_INSERT_TAIL(&blacklist_head, m, listq); + if (verbose) + printf("Skipping page with pa 0x%jx\n", (uintmax_t)pa); + } + return (ret); +} + /* * vm_page_blacklist_check: * @@ -303,26 +324,13 @@ static void vm_page_blacklist_check(char *list, char *end) { vm_paddr_t pa; - vm_page_t m; char *next; - int ret; next = list; while (next != NULL) { if ((pa = vm_page_blacklist_next(&next, end)) == 0) continue; - m = vm_phys_paddr_to_vm_page(pa); - if (m == NULL) - continue; - mtx_lock(&vm_page_queue_free_mtx); - ret = vm_phys_unfree_page(m); - mtx_unlock(&vm_page_queue_free_mtx); - if (ret == TRUE) { - TAILQ_INSERT_TAIL(&blacklist_head, m, listq); - if (bootverbose) - printf("Skipping page with pa 0x%jx\n", - (uintmax_t)pa); - } + vm_page_blacklist_add(pa, bootverbose); } } Modified: stable/11/sys/vm/vm_page.h ============================================================================== --- stable/11/sys/vm/vm_page.h Sat Apr 14 17:33:16 2018 (r332504) +++ stable/11/sys/vm/vm_page.h Sat Apr 14 17:41:54 2018 (r332505) @@ -474,6 +474,7 @@ vm_page_t vm_page_alloc_contig(vm_object_t object, vm_ u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, vm_memattr_t memattr); vm_page_t vm_page_alloc_freelist(int, int); +bool vm_page_blacklist_add(vm_paddr_t pa, bool verbose); void vm_page_change_lock(vm_page_t m, struct mtx **mtx); vm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int); int vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags,