On 01.09.25 14:02, Eugen Hristev wrote:


On 9/1/25 13:01, David Hildenbrand wrote:
What do you think ?

Looks a bit over-engineered, and will require us to import a header
(likely kmemdump.h) in these files, which I don't really enjoy.

I would start simple, without any such macro-magic. It's a very simple
function after all, and likely you won't end up having many of these?


Thanks David, I will do it as you suggested and see what comes out of it.

I have one side question you might know much better to answer:
As we have a start and a size for each region, this start is a virtual
address. The firmware/coprocessor that reads the memory and dumps it,
requires physical addresses.

Right. I was asking myself the same question while reviewing: should we
directly export physical ranges here instead of virtual ones. I guess
virtual ones is ok.

In patch 22/29, some areas are registered using
memblock_phys_alloc_try_nid() which allocates physical.
In this case , phys_to_virt() didn't work for me, it was returning a
wrong address. I used __va() and this worked. So there is a difference
between them.

memblock_alloc_internal() calls memblock_alloc_range_nid() to then perform a phys_to_virt().

memblock_phys_alloc_try_nid() calls memblock_alloc_range_nid() without the phys_to_virt().

So it's rather surprising the a phys_to_virt() would not work in that case.

Maybe for these cases where you export the area through a new helper, you can just export the physical addr + length instead.

Then, it's also clear that this area is actually physically contiguous.



What do you suggest to use to retrieve that
address ? virt_to_phys might be problematic, __pa or __pa_symbol? or
better lm_alias ?

All areas should either come from memblock or be global variables, right?

I would like to be able to register from anywhere. For example someone
debugging their driver, to just register kmalloc'ed struct.
Other use case is to register dma coherent CMA areas.

Then probably better to export physical addresses (that you need either way) directly from the helpers you have to add.



IIRC, virt_to_phys() should work for these. Did you run into any
problems with them or why do you think virt_to_phys could be problematic?


I am pondering about whether it would work in all cases, considering
it's source code comments that it shall not be used because it does not
work for any address.

Yeah, it does for example not work for kernel stacks IIRC.

--
Cheers

David / dhildenb


Reply via email to