From nobody Wed Dec 29 10:16:49 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 060821923EC0; Wed, 29 Dec 2021 10:16:50 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JP6l547v1z4mmw; Wed, 29 Dec 2021 10:16:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6F01123135; Wed, 29 Dec 2021 10:16:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BTAGnal061136; Wed, 29 Dec 2021 10:16:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BTAGn1W061135; Wed, 29 Dec 2021 10:16:49 GMT (envelope-from git) Date: Wed, 29 Dec 2021 10:16:49 GMT Message-Id: <202112291016.1BTAGn1W061135@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: 28e0603813cd - stable/13 - Don't fail changing props for unmapped DMAP memory List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 28e0603813cd8584045bcdeae061e1a333b4e134 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640773009; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=J3z6v8qdSQglN9x9qEvH8giN7OGHRwm9D6H8+dHH1oA=; b=JKmjxhx9VpWMnY1bJpD3qkdhHxKkRgKzi+UINQGiaWNrxF/zhCJSSJoKd/Po23uET+oZU1 DE0XnNrZok2mdaDydwwHD5WcBYOwlFur5757zZ+mcI+Mav77M0oHiX8UjWL4zfnanu2WdB tp//b+dslYlvyHXaYg9ilCC7Bhk6qboYWVP3+4jLY5ZY902BF74+YsvpekPUdfrAaZwDUU 941dAF06vai2OBaP05ujV1uRKmuIOaaTcb+B+HERrBLSpGSmxZdb49xqxLSxJxnAZ5/CLP Ny7ciQsxs9Dt0Uv3zcgE30ZAWOwiM4kBpehU5g1LmCt1eW9TjxTyq03ShKVIgw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640773009; a=rsa-sha256; cv=none; b=ghZJAEnBi+R6I4QAAcvpZzXPFdTM4HtoAN8/baQcmcow1iF4hGh+p6hIiXA3ZX0JFkTZ48 t9Fq8sXnfUlAHLWonqneAnr1WFLVMuE7ipBpHuGT6MlAb1O5iZIAbAz7nXTkeQQSvk1KBj Diye4mSFe+uBgwBAu/WhpQp8FGZ2ztHklSEF/Vmj30Ir2iBWMH2I7+DuD36ctd6f0V9Chz OKxQK5fxern0cLypP8EDsR9LfOUNdov+ay/vqEWsbVjXwEWXz7nbJPIc5Iv/ZFsY7U+za0 8g2y8lVl8WPdCHpNKZeNuLdlMjoomdaqB8hCiQjUgtlCFQZyZMII4gqarMtXMw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=28e0603813cd8584045bcdeae061e1a333b4e134 commit 28e0603813cd8584045bcdeae061e1a333b4e134 Author: Andrew Turner AuthorDate: 2021-12-14 18:09:47 +0000 Commit: Andrew Turner CommitDate: 2021-12-29 10:05:14 +0000 Don't fail changing props for unmapped DMAP memory When recursing in pmap_change_props_locked we may fail because there is no pte. This shouldn't be considered a fail as it may happen in a few cases, e.g. there are multiple normal memory ranges with device memory between them. Reported by: cperciva Tested by: cperciva Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33459 (cherry picked from commit 69cfbd669e34aaaa49f4caed49bd7df93d4115b2) --- sys/arm64/arm64/pmap.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 793126fcf58d..6eab5fa5ecd9 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -383,7 +383,7 @@ static void pmap_abort_ptp(pmap_t pmap, vm_offset_t va, vm_page_t mpte); static bool pmap_activate_int(pmap_t pmap); static void pmap_alloc_asid(pmap_t pmap); static int pmap_change_props_locked(vm_offset_t va, vm_size_t size, - vm_prot_t prot, int mode); + vm_prot_t prot, int mode, bool skip_unmapped); static pt_entry_t *pmap_demote_l1(pmap_t pmap, pt_entry_t *l1, vm_offset_t va); static pt_entry_t *pmap_demote_l2_locked(pmap_t pmap, pt_entry_t *l2, vm_offset_t va, struct rwlock **lockp); @@ -6115,7 +6115,7 @@ pmap_change_attr(vm_offset_t va, vm_size_t size, int mode) int error; PMAP_LOCK(kernel_pmap); - error = pmap_change_props_locked(va, size, PROT_NONE, mode); + error = pmap_change_props_locked(va, size, PROT_NONE, mode, false); PMAP_UNLOCK(kernel_pmap); return (error); } @@ -6137,14 +6137,14 @@ pmap_change_prot(vm_offset_t va, vm_size_t size, vm_prot_t prot) return (EINVAL); PMAP_LOCK(kernel_pmap); - error = pmap_change_props_locked(va, size, prot, -1); + error = pmap_change_props_locked(va, size, prot, -1, false); PMAP_UNLOCK(kernel_pmap); return (error); } static int pmap_change_props_locked(vm_offset_t va, vm_size_t size, vm_prot_t prot, - int mode) + int mode, bool skip_unmapped) { vm_offset_t base, offset, tmpva; vm_size_t pte_size; @@ -6196,13 +6196,14 @@ pmap_change_props_locked(vm_offset_t va, vm_size_t size, vm_prot_t prot, for (tmpva = base; tmpva < base + size; ) { ptep = pmap_pte(kernel_pmap, tmpva, &lvl); - if (ptep == NULL) + if (ptep == NULL && !skip_unmapped) { return (EINVAL); - - if ((pmap_load(ptep) & mask) == bits) { + } else if ((ptep == NULL && skip_unmapped) || + (pmap_load(ptep) & mask) == bits) { /* - * We already have the correct attribute, - * ignore this entry. + * We already have the correct attribute or there + * is no memory mapped at this address and we are + * skipping unmapped memory. */ switch (lvl) { default: @@ -6269,7 +6270,7 @@ pmap_change_props_locked(vm_offset_t va, vm_size_t size, vm_prot_t prot, */ rv = pmap_change_props_locked( PHYS_TO_DMAP(pa), pte_size, - prot, mode); + prot, mode, true); if (rv != 0) return (rv); }