Skip to content

Commit

Permalink
sysfs: support linear_maps
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
wkozaczuk committed Mar 31, 2022
1 parent 913fedf commit 2847b2a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/mmu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,18 @@ linear_vma::linear_vma(void* virt, phys phys, size_t size, mattr mem_attr, const
linear_vma::~linear_vma() {
}

std::string sysfs_linear_maps() {
std::ostringstream os;
WITH_LOCK(linear_vma_set_mutex.for_read()) {
for(auto *vma : linear_vma_set) {
char mattr = vma->_mem_attr == mmu::mattr::normal ? 'n' : 'd';
osv::fprintf(os, "%18x %18x %12x rwxp %c %s\n",
vma->_virt_addr, (void*)vma->_phys_addr, vma->_size, mattr, vma->_name.c_str());
}
}
return os.str();
}

void linear_map(void* _virt, phys addr, size_t size, const char* name,
size_t slop, mattr mem_attr)
{
Expand Down
1 change: 1 addition & 0 deletions fs/sysfs/sysfs_vnops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ sysfs_mount(mount* mp, const char *dev, int flags, const void* data)
auto memory = make_shared<pseudo_dir_node>(inode_count++);
memory->add("free_page_ranges", inode_count++, sysfs_free_page_ranges);
memory->add("pools", inode_count++, sysfs_memory_pools);
memory->add("linear_maps", inode_count++, mmu::sysfs_linear_maps);

auto osv_extension = make_shared<pseudo_dir_node>(inode_count++);
osv_extension->add("memory", memory);
Expand Down
1 change: 1 addition & 0 deletions include/osv/mmu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ error advise(void* addr, size_t size, int advice);
void vm_fault(uintptr_t addr, exception_frame* ef);

std::string procfs_maps();
std::string sysfs_linear_maps();

unsigned long all_vmas_size();

Expand Down

0 comments on commit 2847b2a

Please sign in to comment.