From owner-svn-src-all@freebsd.org Fri Apr 24 18:47:58 2020 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 5282F2BF135; Fri, 24 Apr 2020 18:47:58 +0000 (UTC) (envelope-from markj@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 49838G1ZMSz3yNZ; Fri, 24 Apr 2020 18:47:58 +0000 (UTC) (envelope-from markj@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 3130C22827; Fri, 24 Apr 2020 18:47:58 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03OIlved091965; Fri, 24 Apr 2020 18:47:57 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03OIlvoX091964; Fri, 24 Apr 2020 18:47:57 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202004241847.03OIlvoX091964@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 24 Apr 2020 18:47:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360277 - head/sys/arm64/arm64 X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/arm64/arm64 X-SVN-Commit-Revision: 360277 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: Fri, 24 Apr 2020 18:47:58 -0000 Author: markj Date: Fri Apr 24 18:47:57 2020 New Revision: 360277 URL: https://svnweb.freebsd.org/changeset/base/360277 Log: Fix handling of 1GB mappings in the arm64 minidump code. For such mappings we need to dump 512 page table pages, not one, and they need to be included in the pmap size recorded in the minidump header. MFC after: 2 weeks Sponsored by: Juniper Networks, Klara Inc. Modified: head/sys/arm64/arm64/minidump_machdep.c Modified: head/sys/arm64/arm64/minidump_machdep.c ============================================================================== --- head/sys/arm64/arm64/minidump_machdep.c Fri Apr 24 18:47:42 2020 (r360276) +++ head/sys/arm64/arm64/minidump_machdep.c Fri Apr 24 18:47:57 2020 (r360277) @@ -34,8 +34,6 @@ __FBSDID("$FreeBSD$"); #include "opt_watchdog.h" -#include "opt_watchdog.h" - #include #include #include @@ -68,7 +66,7 @@ static size_t fragsz; static void *dump_va; static size_t counter, progress, dumpsize; -static uint64_t tmpbuffer[PAGE_SIZE / sizeof(uint64_t)]; +static uint64_t tmpbuffer[Ln_ENTRIES]; CTASSERT(sizeof(*vm_page_dump) == 8); @@ -210,16 +208,14 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t int minidumpsys(struct dumperinfo *di) { + struct minidumphdr mdhdr; pd_entry_t *l0, *l1, *l2; pt_entry_t *l3; - uint32_t pmapsize; vm_offset_t va; vm_paddr_t pa; - int error; uint64_t bits; - int i, bit; - int retry_count; - struct minidumphdr mdhdr; + uint32_t pmapsize; + int bit, error, i, j, retry_count; retry_count = 0; retry: @@ -231,11 +227,15 @@ minidumpsys(struct dumperinfo *di) if (!pmap_get_tables(pmap_kernel(), va, &l0, &l1, &l2, &l3)) continue; - /* We should always be using the l2 table for kvm */ - if (l2 == NULL) - continue; - - if ((*l2 & ATTR_DESCR_MASK) == L2_BLOCK) { + if ((*l1 & ATTR_DESCR_MASK) == L1_BLOCK) { + pa = *l1 & ~ATTR_MASK; + for (i = 0; i < Ln_ENTRIES * Ln_ENTRIES; + i++, pa += PAGE_SIZE) + if (is_dumpable(pa)) + dump_add_page(pa); + pmapsize += (Ln_ENTRIES - 1) * PAGE_SIZE; + va += L1_SIZE - L2_SIZE; + } else if ((*l2 & ATTR_DESCR_MASK) == L2_BLOCK) { pa = *l2 & ~ATTR_MASK; for (i = 0; i < Ln_ENTRIES; i++, pa += PAGE_SIZE) { if (is_dumpable(pa)) @@ -327,25 +327,31 @@ minidumpsys(struct dumperinfo *di) error = blk_flush(di); if (error) goto fail; - } else if (l2 == NULL) { + } else if ((*l1 & ATTR_DESCR_MASK) == L1_BLOCK) { + /* + * Handle a 1GB block mapping: write out 512 fake L2 + * pages. + */ pa = (*l1 & ~ATTR_MASK) | (va & L1_OFFSET); - /* Generate fake l3 entries based upon the l1 entry */ for (i = 0; i < Ln_ENTRIES; i++) { - tmpbuffer[i] = pa + (i * PAGE_SIZE) | - ATTR_DEFAULT | L3_PAGE; + for (j = 0; j < Ln_ENTRIES; j++) { + tmpbuffer[j] = pa + i * L2_SIZE + + j * PAGE_SIZE | ATTR_DEFAULT | + L3_PAGE; + } + error = blk_write(di, (char *)&tmpbuffer, 0, + PAGE_SIZE); + if (error) + goto fail; } - /* We always write a page, even if it is zero */ - error = blk_write(di, (char *)&tmpbuffer, 0, PAGE_SIZE); - if (error) - goto fail; /* flush, in case we reuse tmpbuffer in the same block*/ error = blk_flush(di); if (error) goto fail; bzero(&tmpbuffer, sizeof(tmpbuffer)); + va += L1_SIZE - L2_SIZE; } else if ((*l2 & ATTR_DESCR_MASK) == L2_BLOCK) { - /* TODO: Handle an invalid L2 entry */ pa = (*l2 & ~ATTR_MASK) | (va & L2_OFFSET); /* Generate fake l3 entries based upon the l1 entry */ @@ -353,7 +359,6 @@ minidumpsys(struct dumperinfo *di) tmpbuffer[i] = pa + (i * PAGE_SIZE) | ATTR_DEFAULT | L3_PAGE; } - /* We always write a page, even if it is zero */ error = blk_write(di, (char *)&tmpbuffer, 0, PAGE_SIZE); if (error) goto fail; @@ -366,7 +371,6 @@ minidumpsys(struct dumperinfo *di) } else { pa = *l2 & ~ATTR_MASK; - /* We always write a page, even if it is zero */ error = blk_write(di, NULL, pa, PAGE_SIZE); if (error) goto fail;