{"push_id":3153707153,"size":1,"distinct_size":1,"ref":"refs/heads/read-phys-offset-from-kcore-upstream-v2","head":"0094f2407b62106c615dd25cb8a9532ecedee11e","before":"674d2ef8f18b172c28a9e8f173834ee75825a74b","commits":[{"sha":"0094f2407b62106c615dd25cb8a9532ecedee11e","author":{"name":"Bhupesh Sharma","email":"6c4cf59e0b52117638464629480b895734ef22d2@redhat.com"},"message":"arm64: Add support to read PHYS_OFFSET from 'kcore' - pt_note or pt_load (if available)\n\nOn certain arm64 platforms, it has been noticed that due\nto a hole at the start of physical ram exposed to kernel\n(i.e. it doesn't start from address 0), the kernel still\ncalculates the 'memstart_addr' kernel variable as 0.\n\nWhereas the SYSTEM_RAM or IOMEM_RESERVED range in '/proc/iomem'\nwould carry a first entry whose start address is non-zero\n(as the physical ram exposed to the kernel starts from a\nnon-zero address).\n\nIn such cases, if we rely on '/proc/iomem' entries to\ncalculate the phys_offset, then we will have mismatch\nbetween the user-space and kernel space 'PHYS_OFFSET'\nvalue. The present 'kexec-tools' code does the same\nin 'get_memory_ranges_iomem_cb()' function when it makes\na call to 'set_phys_offset()'. This can cause the vmcore\ngenerated via 'kexec-tools' to miss the last few bytes as\nthe first '/proc/iomem' starts from a non-zero address.\n\nPlease see [0] for the original bug-report from Yanjiang Jin.\n\nThe same can be fixed in the following manner:\n\n1. For newer kernel (>= 4.19, with commit 23c85094fe1895caefdd\n[\"proc/kcore: add vmcoreinfo note to /proc/kcore\"] available),\n'kcore' contains a new PT_NOTE which carries the VMCOREINFO\ninformation.\n\nIf the same is available, one should prefer the same to\nretrieve 'PHYS_OFFSET' value exported by the kernel as this\nis now the standard interface exposed by kernel for sharing\nmachine specific details with the user-land as per\nthe arm64 kernel maintainers (see [1]) .\n\n2. For older kernels, we can try and determine the PHYS_OFFSET\nvalue from PT_LOAD segments inside 'kcore' via some jugglery\nof the correct virtual and physical address combinations.\n\nAs a fallback, we still support getting the PHYS_OFFSET values\nfrom '/proc/iomem', to maintain backward compatibility.\n\nTesting:\n-------\n- Tested on my apm-mustang and qualcomm amberwing board with upstream\n  kernel (4.20.0-rc7) for both KASLR and non-KASLR boot cases.\n\nReferences:\n-----------\n[0] https://www.spinics.net/lists/kexec/msg20618.html\n[1] https://www.mail-archive.com/kexec@lists.infradead.org/msg20300.html\n\nReported-by: Yanjiang Jin <yanjiang.jin@hxt-semitech.com>\nSigned-off-by: Bhupesh Sharma <bhsharma@redhat.com>","distinct":true,"url":"https://api.github.com/repos/bhupesh-sharma/kexec-tools/commits/0094f2407b62106c615dd25cb8a9532ecedee11e"}]}
{"actor":{"display_login":"bhupesh-sharma"}}