From nobody Tue Dec 21 13:06:38 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 F40FB18F4785; Tue, 21 Dec 2021 13:06:38 +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 4JJGtk53wBz3GMM; Tue, 21 Dec 2021 13:06:38 +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 8E4E91BE9; Tue, 21 Dec 2021 13:06:38 +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 1BLD6ceh087237; Tue, 21 Dec 2021 13:06:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BLD6cPC087236; Tue, 21 Dec 2021 13:06:38 GMT (envelope-from git) Date: Tue, 21 Dec 2021 13:06:38 GMT Message-Id: <202112211306.1BLD6cPC087236@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 69cfbd669e34 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 69cfbd669e34aaaa49f4caed49bd7df93d4115b2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640091998; 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=WHSzoB6CMgekR8MHoKq/snjBKVIYWRO4D/MPodbxVmE=; b=PrNtcvbwDDHVrJEYFijuWpv5L7m3HLEhH5/9xlzTAeVc3FMNZxi5jlBvSl7eInY+JbKs06 IPTKLQJ8VfbT48/Pw2e2mcv1dsENHEdY9TDxBMlTtUwNE0/6Uzc3kSTsLkVHugzfOGKoAc 6nU9DGSfFkfw/87dYQQQOvL7UPH+koZm3AE/ZbQESo7MSnTO9iLxKJzVMBnvUIMFxhxK6X QMmT0859SZ2XOnwsZ9Ljcw5BgTxPuYs2W5eLW0aUUDP2rz/fHGuKcHBn5CGfCfhbREvafb pjCOyhGGwqtojZFHQARCmVBkGwusRbsFdC+d4SzBkgGCogbfhWdXCrnbhaYoMg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640091998; a=rsa-sha256; cv=none; b=SZfZtQJAOgy5aD22C71byiB+lprp3CvYqVsi2J27ujZ+kKJuJ4Myy2d0b+1OxNgHOK7iim DIhx5PSl1vwfUQs7dMGgP+iJhNC34KiHv2544EDyFchd/QnxQIrE5XfXLKbuhY9Udk6cER Z8cIyHeJxhprKhdjFRBtcmb/i4rQc0l2sByfumvYFSDupr6/SVi2W0gwyhMOcXVO9wt11W fnZtZfoNhXfepwpuz1v+jdr4LuxtNhCEuQjtTeckY49pEGADK49btu8bJGD8mYqFSyVS5T ZqrDf4EUGiZ6XgqFqmGYFklBqekdAd+VP5qQQOwHVxw7fakdJFAhw/RzlvIl2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=69cfbd669e34aaaa49f4caed49bd7df93d4115b2 commit 69cfbd669e34aaaa49f4caed49bd7df93d4115b2 Author: Andrew Turner AuthorDate: 2021-12-14 18:09:47 +0000 Commit: Andrew Turner CommitDate: 2021-12-21 13:06:27 +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 --- 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 d50c544cc863..e69d0f9c1d81 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); @@ -5937,7 +5937,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); } @@ -5959,14 +5959,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; @@ -6018,13 +6018,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: @@ -6091,7 +6092,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); }