From owner-dev-commits-src-main@freebsd.org Wed Jan 13 21:35:34 2021 Return-Path: Delivered-To: dev-commits-src-main@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 EC9AB4E97ED; Wed, 13 Jan 2021 21:35:34 +0000 (UTC) (envelope-from mhorne063@gmail.com) Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DGLMp6FHZz3p5V; Wed, 13 Jan 2021 21:35:34 +0000 (UTC) (envelope-from mhorne063@gmail.com) Received: by mail-qk1-x731.google.com with SMTP id w79so4224128qkb.5; Wed, 13 Jan 2021 13:35:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Si/25qAHFaL3vMN1+BHzjKe2mSw/N8l/nZf3XfVwt+k=; b=S/xmJ2f/hVyQfe06OujQkcQA7qhhQsw8H/cLyz5z2PP67a6KB09nY2Ff0NtlV3Kj17 CZyoypIiPU1fOcEwdk8YMj8IW7Clgzle5zjgcgIlcU1/JNeNs+IHtCmMDS5hu1tX8lzd C9ajN0u++3WMH1gZVT/c2s4MtNl4MSuACk9y4rDAnDhSe4uTkVCaqBL6e9wRFq9m0e4B RoaL5Rv9vrU1wKRnYilBD9GTf3FyVlwpObNnHkcVaVlkJBy6ODMdyTEN1xexmT/J5wtb JtKX+xAm4WuZ19hCqtTpFyIA7kelLp7IUaSKaaIl3TxpvT9x1LBk7f/4ytxff65/X1kz +Oaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Si/25qAHFaL3vMN1+BHzjKe2mSw/N8l/nZf3XfVwt+k=; b=s2Byo/0LB0nrd0YMajGKpN2C172avyWX3PKPqvtZD93ms1qiT1z4+eXiVIyeSus7tJ a5AAWymhY1CHmJfc4D+ASihs2mId6x/tT1QRUUCiIMsenrhbGKxr3iQfkB1swO1cbZac nQxgrfKWZxkRrEAh6KtemMHJ1Wfrr7NfARQARxtX8X8Q698K6BCZ9koqA0XLzhnmRyEj UctcDaZezblNkWFCowactIoOJwEnerR5PqFs3/LXQHLzHo8rnvbUON59oROrA2D5TwXj nQmTB5BEu83MxeTZjHXjOBX1SIQ1bMJ2DuSK/hK15GdaUzjrKz/IJl37m4cKaGKNVZdB n6pQ== X-Gm-Message-State: AOAM5314VDh6QLn6YdYVQmTnj5NHdKYIqNuV4snU2/R8x6e5nGb/xSFj BYkgnuagBoABVJsskD9h1L7im+HUbAIssEgoHTof9fZAmiM= X-Google-Smtp-Source: ABdhPJwNAWmUvnuxVejMQ46eglviRL3C/j0rXg04w160EiQIpdgoGiWmuSvAz2kHRQp9i76axXHC5CLrekBkczakPBw= X-Received: by 2002:a5b:1c1:: with SMTP id f1mr3726449ybp.212.1610573733728; Wed, 13 Jan 2021 13:35:33 -0800 (PST) MIME-Version: 1.0 References: <202101132128.10DLS8ZH018542@gitrepo.freebsd.org> In-Reply-To: <202101132128.10DLS8ZH018542@gitrepo.freebsd.org> From: Mitchell Horne Date: Wed, 13 Jan 2021 17:35:22 -0400 Message-ID: Subject: Re: git: 818390ce0ca5 - main - arm64: fix early devmap assertion To: Mitchell Horne Cc: src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4DGLMp6FHZz3p5V X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2021 21:35:35 -0000 On Wed, Jan 13, 2021 at 5:28 PM Mitchell Horne wrote: > > The branch main has been updated by mhorne: > > URL: https://cgit.FreeBSD.org/src/commit/?id=818390ce0ca539300dd15d7a817784f1e3f7a9b8 > > commit 818390ce0ca539300dd15d7a817784f1e3f7a9b8 > Author: Mitchell Horne > AuthorDate: 2021-01-13 18:30:50 +0000 > Commit: Mitchell Horne > CommitDate: 2021-01-13 21:27:44 +0000 > > arm64: fix early devmap assertion > > The purpose of this KASSERT is to ensure that we do not run out of space > in the early devmap. However, the devmap grew beyond its initial size of > 2MB in r336519, and this assertion did not grow with it. > > A devmap mapping of a 1080p framebuffer requires 1920x1080 bytes, or > 1.977 MB, so it is just barely able to fit without triggering the > assertion, provided no other devices are mapped before it. With the > addition of `options GDB` in GENERIC by bbfa199cbc16, the uart is now > mapped for the purposes of a debug port, before mapping the framebuffer. > The presence of both these conditions pushes the selected virtual > address just below the threshold, triggering the assertion. > > To fix this, use the correct size of the devmap, defined by > PMAP_MAPDEV_EARLY_SIZE. Since this code is shared with RISC-V, define > it for that platform as well (although it is a different size). > > PR: 25241 Sigh. This should be PR 252541. Mitchell > Reported by: gbe > MFC after: 3 days > Sponsored by: The FreeBSD Foundation > --- > sys/kern/subr_devmap.c | 2 +- > sys/riscv/include/vmparam.h | 1 + > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/sys/kern/subr_devmap.c b/sys/kern/subr_devmap.c > index 581e85086f0f..8e07199b7f73 100644 > --- a/sys/kern/subr_devmap.c > +++ b/sys/kern/subr_devmap.c > @@ -275,7 +275,7 @@ pmap_mapdev(vm_offset_t pa, vm_size_t size) > if (early_boot) { > akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size); > va = akva_devmap_vaddr; > - KASSERT(va >= VM_MAX_KERNEL_ADDRESS - L2_SIZE, > + KASSERT(va >= VM_MAX_KERNEL_ADDRESS - PMAP_MAPDEV_EARLY_SIZE, > ("Too many early devmap mappings")); > } else > #endif > diff --git a/sys/riscv/include/vmparam.h b/sys/riscv/include/vmparam.h > index f3cab1074454..9580ab3e1218 100644 > --- a/sys/riscv/include/vmparam.h > +++ b/sys/riscv/include/vmparam.h > @@ -235,6 +235,7 @@ extern vm_offset_t init_pt_va; > #define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ > > #define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS > +#define PMAP_MAPDEV_EARLY_SIZE (L2_SIZE * 2) > > /* > * No non-transparent large page support in the pmap.