Skip to content

Commit 2847b2a

Browse files
committed
sysfs: support linear_maps
This patch builds on a previous one to track linear maps and adds new OSv specific pseudo file /sys/osv/memory/linear_maps: x86_64 example) 0x40200000 0x200000 7c7434 rwxp n kernel 0xffff800000000000 0 40000000 rwxp n main 0xffff8000000f0000 0xf0000 10000 rwxp n dmi 0xffff8000000f5a00 0xf5a00 247 rwxp n smbios 0xffff800040000000 0x40000000 3ffdd000 rwxp n main 0xffff80007fe00000 0x7fe00000 200000 rwxp n acpi 0xffff8000febd1000 0xfebd1000 1000 rwxp n pci_bar 0xffff8000febd2000 0xfebd2000 1000 rwxp n pci_bar 0xffff8000fec00000 0xfec00000 1000 rwxp n ioapic 0xffff900000000000 0 40000000 rwxp n page 0xffff900040000000 0x40000000 3ffdd000 rwxp n page 0xffffa00000000000 0 40000000 rwxp n mempool 0xffffa00040000000 0x40000000 3ffdd000 rwxp n mempool aarch64 example) 0x8000000 0x8000000 10000 rwxp d gic_dist 0x8010000 0x8010000 10000 rwxp d gic_cpu 0x9000000 0x9000000 1000 rwxp d pl011 0x9010000 0x9010000 1000 rwxp d pl031 0x10000000 0x10000000 2eff0000 rwxp d pci_mem 0x3eff0000 0x3eff0000 10000 rwxp d pci_io 0x40000000 0x40000000 6d3000 rwxp n kernel 0x4010000000 0x4010000000 10000000 rwxp d pci_cfg 0xffff80000a000000 0xa000000 200 rwxp n virtio_mmio_cfg 0xffff80000a000200 0xa000200 200 rwxp n virtio_mmio_cfg 0xffff80000a000400 0xa000400 200 rwxp n virtio_mmio_cfg 0xffff80000a000600 0xa000600 200 rwxp n virtio_mmio_cfg 0xffff80000a000800 0xa000800 200 rwxp n virtio_mmio_cfg 0xffff80000a000a00 0xa000a00 200 rwxp n virtio_mmio_cfg 0xffff80000a000c00 0xa000c00 200 rwxp n virtio_mmio_cfg 0xffff80000a000e00 0xa000e00 200 rwxp n virtio_mmio_cfg 0xffff8000406d3000 0x406d3000 7f92d000 rwxp n main 0xffff9000406d3000 0x406d3000 7f92d000 rwxp n page 0xffffa000406d3000 0x406d3000 7f92d000 rwxp n mempool Signed-off-by: Waldemar Kozaczuk <[email protected]>
1 parent 913fedf commit 2847b2a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

core/mmu.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,18 @@ linear_vma::linear_vma(void* virt, phys phys, size_t size, mattr mem_attr, const
18791879
linear_vma::~linear_vma() {
18801880
}
18811881

1882+
std::string sysfs_linear_maps() {
1883+
std::ostringstream os;
1884+
WITH_LOCK(linear_vma_set_mutex.for_read()) {
1885+
for(auto *vma : linear_vma_set) {
1886+
char mattr = vma->_mem_attr == mmu::mattr::normal ? 'n' : 'd';
1887+
osv::fprintf(os, "%18x %18x %12x rwxp %c %s\n",
1888+
vma->_virt_addr, (void*)vma->_phys_addr, vma->_size, mattr, vma->_name.c_str());
1889+
}
1890+
}
1891+
return os.str();
1892+
}
1893+
18821894
void linear_map(void* _virt, phys addr, size_t size, const char* name,
18831895
size_t slop, mattr mem_attr)
18841896
{

fs/sysfs/sysfs_vnops.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ sysfs_mount(mount* mp, const char *dev, int flags, const void* data)
9595
auto memory = make_shared<pseudo_dir_node>(inode_count++);
9696
memory->add("free_page_ranges", inode_count++, sysfs_free_page_ranges);
9797
memory->add("pools", inode_count++, sysfs_memory_pools);
98+
memory->add("linear_maps", inode_count++, mmu::sysfs_linear_maps);
9899

99100
auto osv_extension = make_shared<pseudo_dir_node>(inode_count++);
100101
osv_extension->add("memory", memory);

include/osv/mmu.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ error advise(void* addr, size_t size, int advice);
330330
void vm_fault(uintptr_t addr, exception_frame* ef);
331331

332332
std::string procfs_maps();
333+
std::string sysfs_linear_maps();
333334

334335
unsigned long all_vmas_size();
335336

0 commit comments

Comments
 (0)