Bug 194974 - Limit /dev/mem access to addresses in phys_avail[] - i.e. actual memory
Summary: Limit /dev/mem access to addresses in phys_avail[] - i.e. actual memory
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-12 22:17 UTC by Ed Maste
Modified: 2018-01-23 05:23 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2014-11-12 22:17:35 UTC
Running a mismatched lsof on my ~10.1 desktop resulted in an MCA report and hard hang:

MCA: Bank 1, Status 0xbf80000000200001
MCA: Global Cap 0x0000000000000c09, Status 0x0000000000000005
MCA: Vendor "GenuineIntel", ID 0x306a9, APIC ID 2
MCA: CPU 2 UNCOR PCC unclassified error
MCA: Address 0xfee00080
MCA: Misc 0x86
MCA: Bank 1, Status 0xbf80000000200001
MCA: Global Cap 0x0000000000000c09, Status 0x0000000000000005
MCA: Vendor "GenuineIntel", ID 0x306a9, APIC ID 3
MCA: CPU 3 UNCOR PCC unclassified error
MCA: Address 0xfee00080
MCA: Misc 0x86

Discussed with jhb@, presumably this happens after access to some device register. We should by default limit /dev/mem access to addresses in phys_avail[], but include a sysctl to enable such access for expert debugging.
Comment 1 Larry Rosenman freebsd_committer 2014-11-13 16:21:40 UTC
Let me know if I need to get Vic involved.

Larry Rosenman
Maintainer, sysutils/lsof
Comment 2 Alan Cox freebsd_committer 2015-01-02 17:30:18 UTC
Use dump_avail[] rather than phys_avail[].  Between the time that we first initialize phys_avail[] and finally execute vm_page_startup(), we remove pages from phys_avail[] for various purposes.  Also, dump_avail[] includes pages containing the kernel code and data that are excluded from phys_avail[].  In summary, dump_avail[] more accurately describes the physical memory of the machine.

See the arm version of this code.  It already implements the check against dump_avail[].