Re: [PATCH v4 3/4] liveupdate: luo_session: include linux/mm.h for virt/phys translation

Pratyush Yadav <[email protected]>
Newsgroups org.kernel.vger.linux-efi,dev.linux.lists.loongarch,org.infradead.lists.kexec,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest,org.kvack.linux-mm
Message-ID <[email protected]>
On Mon, Aug 10 2026, Pratyush Yadav wrote:

> On Mon, Aug 10 2026, Huacai Chen wrote:
>
>> Hi, George,
>>
>> This should be the 2nd patch.
>
> Agreed.
>
> With that done,
>
> Reviewed-by: Pratyush Yadav <[email protected]>

Actually, I take this back. Sashiko has found some problems. See below.

>
>>
>> Huacai
>>
>> On Fri, Aug 7, 2026 at 6:39 PM George Guo <[email protected]> wrote:
>>>
>>> From: George Guo <[email protected]>
>>>
>>> luo_session.c calls virt_to_phys() and phys_to_virt(). On LoongArch with
>>> CONFIG_KFENCE=y, these macros (in arch/loongarch/include/asm/io.h) expand
>>> to offset_in_page() and page_address(), both declared in <linux/mm.h>.

https://sashiko.dev/#/patchset/[email protected]

    Is this description accurate? Looking at luo_session.c, it does not actually
    call virt_to_phys().
    The implicit declaration error appears to originate from arch_kfence_init_pool()
    in arch/loongarch/include/asm/kfence.h, which is implicitly included via
    <linux/slab.h>.
    arch/loongarch/include/asm/kfence.h:arch_kfence_init_pool() {
        ...
                    virt_to_phys((void *)kfence_pool), PAGE_KERNEL);
        ...
    }
    Could the fix be applied to the architecture header instead, to prevent any
    other kernel C file on LoongArch with CONFIG_KFENCE=y from suffering the same
    build failure if it includes <linux/slab.h> before <linux/mm.h>?

I at least don't see any virt_to_phys() or phys_to_virt() in
luo_session.c. So you need to go and take another look at what the real
problem is and what the fix should be.

>>>
>>> Since luo_session.c only includes <linux/io.h>, the translation unit fails
>>> to build with CONFIG_KFENCE=y:
>>>
>>>   asm/io.h: error: implicit declaration of function 'offset_in_page'
>>>   asm/io.h: error: implicit declaration of function 'page_address'
>>>
>>> Add the missing include to fix these build errors.
>>>
>>> Co-developed-by: Kexin Liu <[email protected]>
>>> Signed-off-by: Kexin Liu <[email protected]>
>>> Signed-off-by: George Guo <[email protected]>
>>> Acked-by: Mike Rapoport (Microsoft) <[email protected]>
>>> ---
>>>  kernel/liveupdate/luo_session.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c
>>> index f38b5b18f3f8..31490ac7b63d 100644
>>> --- a/kernel/liveupdate/luo_session.c
>>> +++ b/kernel/liveupdate/luo_session.c
>>> @@ -94,6 +94,7 @@
>>>  #include <linux/kho/abi/luo.h>
>>>  #include <linux/list.h>
>>>  #include <linux/liveupdate.h>
>>> +#include <linux/mm.h>
>>>  #include <linux/mutex.h>
>>>  #include <linux/rwsem.h>
>>>  #include <linux/slab.h>
>>> --
>>> 2.53.0
>>>
>>>

-- 
Regards,
Pratyush Yadav
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.