From owner-svn-src-head@freebsd.org Wed Sep 16 23:46:21 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0BC429CE2C0; Wed, 16 Sep 2015 23:46:21 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org (repo.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 F10E51A4C; Wed, 16 Sep 2015 23:46:20 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8GNkKa5062085; Wed, 16 Sep 2015 23:46:20 GMT (envelope-from zbb@FreeBSD.org) Received: (from zbb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8GNkKXn062084; Wed, 16 Sep 2015 23:46:20 GMT (envelope-from zbb@FreeBSD.org) Message-Id: <201509162346.t8GNkKXn062084@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: zbb set sender to zbb@FreeBSD.org using -f From: Zbigniew Bodek Date: Wed, 16 Sep 2015 23:46:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287883 - head/sys/arm64/arm64 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.20 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: Wed, 16 Sep 2015 23:46:21 -0000 Author: zbb Date: Wed Sep 16 23:46:20 2015 New Revision: 287883 URL: https://svnweb.freebsd.org/changeset/base/287883 Log: Release memory for CPUs that fail to init on ARM64 cpu_init_fdt will now release memory allocated for structures serving CPUs that have failed to init. Obtained from: Semihalf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3297 Modified: head/sys/arm64/arm64/mp_machdep.c Modified: head/sys/arm64/arm64/mp_machdep.c ============================================================================== --- head/sys/arm64/arm64/mp_machdep.c Wed Sep 16 23:34:51 2015 (r287882) +++ head/sys/arm64/arm64/mp_machdep.c Wed Sep 16 23:46:20 2015 (r287883) @@ -352,7 +352,6 @@ cpu_init_fdt(u_int id, phandle_t node, u if (id == 0) return (1); - CPU_SET(id, &all_cpus); pcpup = &__pcpu[id]; pcpu_init(pcpup, id, sizeof(struct pcpu)); @@ -371,8 +370,17 @@ cpu_init_fdt(u_int id, phandle_t node, u pa = pmap_extract(kernel_pmap, (vm_offset_t)mpentry); err = psci_cpu_on(target_cpu, pa, id); - if (err != PSCI_RETVAL_SUCCESS) - printf("Failed to start CPU %u\n", id); + if (err != PSCI_RETVAL_SUCCESS) { + /* Panic here if INVARIANTS are enabled */ + KASSERT(0, ("Failed to start CPU %u (%lx)\n", id, target_cpu)); + + pcpu_destroy(pcpup); + kmem_free(kernel_arena, (vm_offset_t)dpcpu[id - 1], DPCPU_SIZE); + dpcpu[id - 1] = NULL; + /* Notify the user that the CPU failed to start */ + printf("Failed to start CPU %u (%lx)\n", id, target_cpu); + } else + CPU_SET(id, &all_cpus); return (1); }