From nobody Wed Nov 19 17:51:02 2025 X-Original-To: freebsd-hackers@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 4dBTYf2Bvjz6J2px for ; Wed, 19 Nov 2025 17:51:18 +0000 (UTC) (envelope-from friedrichdoku2030@u.northwestern.edu) Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) (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 "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dBTYd2zHNz3QFn for ; Wed, 19 Nov 2025 17:51:17 +0000 (UTC) (envelope-from friedrichdoku2030@u.northwestern.edu) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=u-northwestern-edu.20230601.gappssmtp.com header.s=20230601 header.b=JQhxpA5y; dmarc=pass (policy=none) header.from=northwestern.edu; spf=pass (mx1.freebsd.org: domain of friedrichdoku2030@u.northwestern.edu designates 2607:f8b0:4864:20::32c as permitted sender) smtp.mailfrom=friedrichdoku2030@u.northwestern.edu Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-7c6dca2455bso872551a34.3 for ; Wed, 19 Nov 2025 09:51:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=u-northwestern-edu.20230601.gappssmtp.com; s=20230601; t=1763574674; x=1764179474; darn=freebsd.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=iR5SYpsw72N58jB+PtuDQwaA+/48AjmhBhmPPwr2tQ0=; b=JQhxpA5y1SxDhKY0wwuqIdvNCXydX9ltJk+2C7z8A9ZfVCc967ZmPOAYL4yrkU53VS ZcGAkMkRNiKl1edwWH479kC/2V+qJ/0ncPnnNj5mIl9aojPAVfYXXmjVV01KMoadf8fM IhOT0HvsrLDM3wOhpV3STqgwkLHCxE1mCPXC1aA3LMcAD65S+xCFIKBBi8DCkALRjW2M wEKlepB0rMy60USXg1wkUjdCv3oe+3nEIf0UzzmQvSNk7YdafwlXFqSlvTieCpkttz6s OocC5IaYeT564QGpvlap90rfAFSOBVvrev2lpIQCHXSATOmYsMySU7os+EvvDoE9cLHH mKEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763574674; x=1764179474; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iR5SYpsw72N58jB+PtuDQwaA+/48AjmhBhmPPwr2tQ0=; b=NLSrEAAFNJ8cfPTCG5PMMva8i4S+wnin5dPB9oHvQNvHPH0Nqu6ZoSh6xA4GYb1ceZ AORu0ED/4eOyHGh1iV2nw6mYwJdDlnbKi1QGcNV38LTpO2VAzSIb0am3UGNbFSCIa1Vk mEcaefUJVAd4cDLgfjaOWhFQl38gylQN7H+1fnV6GpRtmmlIVewxWqa1ybQBZCsGHVk4 FI18/5g+Ya5hVBtdczz6S7g4yI6SVmvDc/PkGAmwBLgWzLb5cnIR9rlYhh/uMNwETvg/ SfgQHF4viLTp304/69qIhSrziH3r6vYy1Xh42DW7jjjGb/Mizwfw+cIBritHMjIp/boF /ULA== X-Gm-Message-State: AOJu0YwfrXQjausoDetaBkmCEZ5tQY6UQMd/Z49DAzFHhcmYfMWVN9WX 2pWzU3hxjESlZaEvPt/2a9FqGr/SXuNxD1X955QeWPLpLunNPO47Alk+xGoICKITseeKAcKXB17 anEBrm+p8nT1yJ6VDVUc++jvH/bo1FrbHma4GiyVD+QCa7XYJ7cHSG1NNCQ== X-Gm-Gg: ASbGncvrn+MIBGAVGoBbg8Cm2mFALQKP/NULTA7DE5JFV7UFENqSvfyls7PVdZDC00p nt4L67H4zut9AIID4ZsZY663tEDHc9fDhlO3XUKEJJy3GYp7+UagRzFI3k/nPgS/X0k/Rk/qqP0 w7QksGRsCyL01/IxIzdKx6FzWm3VjBhv6vPH3OZTFppZ/DESLj30khEsYzhjW+IPkM+6UlSnoxJ Q/FPBJxyJQodu9TNir0HSNq7g3TY6VN5Q0STt8tVfhDpUXb9Y5pZewVNLW9I5o2H2dMTr70yfnO xlZ/QaGSwSOXYD0OTPm2GCwnieMzFDewtaMC8o5k9zv1pnQ7vVIn2xC5UvH1J0XpwA4= X-Google-Smtp-Source: AGHT+IES6y48HByua0xsnZJUC1JMebHPJ94aZ2QZg/AGEtVcAxvAuLSwU9iV0x42sdx5IREqgs0WOVsivNBNZNqGEGg= X-Received: by 2002:a05:6820:a246:b0:657:4bf1:f3a9 with SMTP id 006d021491bc7-65782ab5dd8mr67042eaf.2.1763574674678; Wed, 19 Nov 2025 09:51:14 -0800 (PST) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 From: Friedrich Doku Date: Wed, 19 Nov 2025 11:51:02 -0600 X-Gm-Features: AWmQ_bk0JhpyUnFSL6CN1bJ3_S0R8kByqJEKzb5qPXpLzMU6AHEDjF0vR2riXuI Message-ID: Subject: Kernel panic when using pmap_extract_and_hold() to check physical-to-virtual address mapping To: freebsd-hackers@freebsd.org Content-Type: multipart/alternative; boundary="00000000000004f4370643f63a69" X-Spamd-Bar: --- X-Spamd-Result: default: False [-4.00 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.997]; DMARC_POLICY_ALLOW(-0.50)[northwestern.edu,none]; R_DKIM_ALLOW(-0.20)[u-northwestern-edu.20230601.gappssmtp.com:s=20230601]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_ONE(0.00)[1]; BLOCKLISTDE_FAIL(0.00)[2607:f8b0:4864:20::32c:server fail]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::32c:from]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_LAST(0.00)[]; DKIM_TRACE(0.00)[u-northwestern-edu.20230601.gappssmtp.com:+] X-Rspamd-Queue-Id: 4dBTYd2zHNz3QFn --00000000000004f4370643f63a69 Content-Type: text/plain; charset="UTF-8" Hello, We want to see if a specific physical address is mapped into the virtual address space of a user space process. We are trying to do this from the kernel, but we are running into issues with trying to use pmap_extract, specifically we get the following kernel panic: panic: mtx_lock() of spin mutex (invalid) The pmap pointer comes from: 1. pfind(target_pid) - gets the process structure 2. p->p_vmspace - gets the vmspace from the process 3. vmspace_pmap(p->p_vmspace) - extracts the pmap from vmspace Then I'm iterating through vm_map entries with VM_MAP_ENTRY_FOREACH() and calling pmap_extract_and_hold(pmap, va, VM_PROT_READ) for each virtual address. The crash happens when calling pmap_extract_and_hold(). I suspect it's trying to acquire pmap locks that conflict with something. I'm trying to find which virtual address maps to a given physical address in a user space process. I'm doing this from a kernel module via sysctl handler. Best, Friedy --00000000000004f4370643f63a69 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hello,

We want to see if a specific physical address is mapped into the=20 virtual address space of a user space process. We are trying to do this=20 from the kernel, but we are running into issues with trying to use=20 pmap_extract, specifically we get the following kernel panic:

panic: mtx_lock() of spin mutex (invalid)

The pmap pointer comes from:

  1. pfind(target_pid) - gets the process structure
  2. p->p_vmsp= ace - gets the vmspace from the process
  3. vmspace_pmap(p->p_vmspac= e) - extracts the pmap from vmspace

Then I'm iterating through vm_map entries with VM_MAP_ENTRY_FOREACH(= ) and calling pmap_extract_and_hold(pmap, va, VM_PROT_READ) for each=20 virtual address.

The crash happens when calling pmap_extract_and_hold(). I suspect=20 it's trying to acquire pmap locks that conflict with something.

I'm trying to find which virtual address maps to a given physical=20 address in a user space process. I'm doing this from a kernel module vi= a sysctl handler.

Best,=C2=A0
Friedy


--00000000000004f4370643f63a69--