[PATCH v2] efi/arm: dump UEFI runtime page tables for ARM

Kefeng Wang posted 1 patch 1 year, 6 months ago
arch/arm/include/asm/ptdump.h      | 1 +
arch/arm64/include/asm/ptdump.h    | 1 +
drivers/firmware/efi/arm-runtime.c | 4 ++--
3 files changed, 4 insertions(+), 2 deletions(-)
[PATCH v2] efi/arm: dump UEFI runtime page tables for ARM
Posted by Kefeng Wang 1 year, 6 months ago
UEFI runtime page tables dump only for ARM64 at present,
but ARM support EFI and ARM_PTDUMP_DEBUGFS now. Since
ARM could potentially execute with a 1G/3G user/kernel
split, choosing 1G as the upper limit for UEFI runtime
end, with this, we could enable UEFI runtime page tables.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
v2: update upper limit for ARM, only build test due to
    my qemu without UEFI boot support.
 arch/arm/include/asm/ptdump.h      | 1 +
 arch/arm64/include/asm/ptdump.h    | 1 +
 drivers/firmware/efi/arm-runtime.c | 4 ++--
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/ptdump.h b/arch/arm/include/asm/ptdump.h
index 0c2d3d0d4cc6..aad1d034136c 100644
--- a/arch/arm/include/asm/ptdump.h
+++ b/arch/arm/include/asm/ptdump.h
@@ -21,6 +21,7 @@ struct ptdump_info {
 
 void ptdump_walk_pgd(struct seq_file *s, struct ptdump_info *info);
 #ifdef CONFIG_ARM_PTDUMP_DEBUGFS
+#define EFI_RUNTIME_MAP_END	SZ_1G
 void ptdump_debugfs_register(struct ptdump_info *info, const char *name);
 #else
 static inline void ptdump_debugfs_register(struct ptdump_info *info,
diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h
index b1dd7ecff7ef..581caac525b0 100644
--- a/arch/arm64/include/asm/ptdump.h
+++ b/arch/arm64/include/asm/ptdump.h
@@ -23,6 +23,7 @@ struct ptdump_info {
 
 void ptdump_walk(struct seq_file *s, struct ptdump_info *info);
 #ifdef CONFIG_PTDUMP_DEBUGFS
+#define EFI_RUNTIME_MAP_END	DEFAULT_MAP_WINDOW_64
 void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name);
 #else
 static inline void ptdump_debugfs_register(struct ptdump_info *info,
diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
index 3359ae2adf24..8f8ae479061b 100644
--- a/drivers/firmware/efi/arm-runtime.c
+++ b/drivers/firmware/efi/arm-runtime.c
@@ -25,14 +25,14 @@
 #include <asm/mmu.h>
 #include <asm/pgalloc.h>
 
-#if defined(CONFIG_PTDUMP_DEBUGFS) && defined(CONFIG_ARM64)
+#if defined(CONFIG_PTDUMP_DEBUGFS) || defined(CONFIG_ARM_PTDUMP_DEBUGFS)
 #include <asm/ptdump.h>
 
 static struct ptdump_info efi_ptdump_info = {
 	.mm		= &efi_mm,
 	.markers	= (struct addr_marker[]){
 		{ 0,				"UEFI runtime start" },
-		{ DEFAULT_MAP_WINDOW_64,	"UEFI runtime end" },
+		{ EFI_RUNTIME_MAP_END,		"UEFI runtime end" },
 		{ -1,				NULL }
 	},
 	.base_addr	= 0,
-- 
2.35.3
Re: [PATCH v2] efi/arm: dump UEFI runtime page tables for ARM
Posted by Catalin Marinas 1 year, 6 months ago
On Fri, Sep 30, 2022 at 06:10:24PM +0800, Kefeng Wang wrote:
> UEFI runtime page tables dump only for ARM64 at present,
> but ARM support EFI and ARM_PTDUMP_DEBUGFS now. Since
> ARM could potentially execute with a 1G/3G user/kernel
> split, choosing 1G as the upper limit for UEFI runtime
> end, with this, we could enable UEFI runtime page tables.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Since this is not an update for arm64, I presume it will go in via
either the EFI or the arm32 tree.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Re: [PATCH v2] efi/arm: dump UEFI runtime page tables for ARM
Posted by Kefeng Wang 1 year, 6 months ago
Sorry, forget to Cc Ard and efi maillist, do it now.

On 2022/9/30 18:10, Kefeng Wang wrote:
> UEFI runtime page tables dump only for ARM64 at present,
> but ARM support EFI and ARM_PTDUMP_DEBUGFS now. Since
> ARM could potentially execute with a 1G/3G user/kernel
> split, choosing 1G as the upper limit for UEFI runtime
> end, with this, we could enable UEFI runtime page tables.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> v2: update upper limit for ARM, only build test due to
>      my qemu without UEFI boot support.
>   arch/arm/include/asm/ptdump.h      | 1 +
>   arch/arm64/include/asm/ptdump.h    | 1 +
>   drivers/firmware/efi/arm-runtime.c | 4 ++--
>   3 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/include/asm/ptdump.h b/arch/arm/include/asm/ptdump.h
> index 0c2d3d0d4cc6..aad1d034136c 100644
> --- a/arch/arm/include/asm/ptdump.h
> +++ b/arch/arm/include/asm/ptdump.h
> @@ -21,6 +21,7 @@ struct ptdump_info {
>   
>   void ptdump_walk_pgd(struct seq_file *s, struct ptdump_info *info);
>   #ifdef CONFIG_ARM_PTDUMP_DEBUGFS
> +#define EFI_RUNTIME_MAP_END	SZ_1G
>   void ptdump_debugfs_register(struct ptdump_info *info, const char *name);
>   #else
>   static inline void ptdump_debugfs_register(struct ptdump_info *info,
> diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h
> index b1dd7ecff7ef..581caac525b0 100644
> --- a/arch/arm64/include/asm/ptdump.h
> +++ b/arch/arm64/include/asm/ptdump.h
> @@ -23,6 +23,7 @@ struct ptdump_info {
>   
>   void ptdump_walk(struct seq_file *s, struct ptdump_info *info);
>   #ifdef CONFIG_PTDUMP_DEBUGFS
> +#define EFI_RUNTIME_MAP_END	DEFAULT_MAP_WINDOW_64
>   void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name);
>   #else
>   static inline void ptdump_debugfs_register(struct ptdump_info *info,
> diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
> index 3359ae2adf24..8f8ae479061b 100644
> --- a/drivers/firmware/efi/arm-runtime.c
> +++ b/drivers/firmware/efi/arm-runtime.c
> @@ -25,14 +25,14 @@
>   #include <asm/mmu.h>
>   #include <asm/pgalloc.h>
>   
> -#if defined(CONFIG_PTDUMP_DEBUGFS) && defined(CONFIG_ARM64)
> +#if defined(CONFIG_PTDUMP_DEBUGFS) || defined(CONFIG_ARM_PTDUMP_DEBUGFS)
>   #include <asm/ptdump.h>
>   
>   static struct ptdump_info efi_ptdump_info = {
>   	.mm		= &efi_mm,
>   	.markers	= (struct addr_marker[]){
>   		{ 0,				"UEFI runtime start" },
> -		{ DEFAULT_MAP_WINDOW_64,	"UEFI runtime end" },
> +		{ EFI_RUNTIME_MAP_END,		"UEFI runtime end" },
>   		{ -1,				NULL }
>   	},
>   	.base_addr	= 0,
Re: [PATCH v2] efi/arm: dump UEFI runtime page tables for ARM
Posted by Ard Biesheuvel 1 year, 6 months ago
On Sat, 8 Oct 2022 at 08:37, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> Sorry, forget to Cc Ard and efi maillist, do it now.
>
> On 2022/9/30 18:10, Kefeng Wang wrote:
> > UEFI runtime page tables dump only for ARM64 at present,
> > but ARM support EFI and ARM_PTDUMP_DEBUGFS now. Since
> > ARM could potentially execute with a 1G/3G user/kernel
> > split, choosing 1G as the upper limit for UEFI runtime
> > end, with this, we could enable UEFI runtime page tables.
> >
> > Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> > ---
> > v2: update upper limit for ARM, only build test due to
> >      my qemu without UEFI boot support.

Tested-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>




/ # cat /sys/kernel/debug/efi_page_tables
---[ UEFI runtime start ]---
0x20005000-0x20112000        1076K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
0x20112000-0x20114000           8K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
0x20114000-0x20117000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
0x20117000-0x20118000           4K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
0x20118000-0x2011b000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
0x2011b000-0x2011c000           4K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
0x2011c000-0x2011f000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
0x2011f000-0x2017c000         372K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
0x2017c000-0x20183000          28K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
0x20183000-0x20186000          12K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
0x20186000-0x20189000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
0x20189000-0x2018a000           4K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
0x2018a000-0x2018d000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
0x2018d000-0x2018e000           4K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
0x2018e000-0x20191000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
0x20191000-0x20193000           8K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
0x20193000-0x20195000           8K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
0x201a5000-0x203fd000        2400K PTE KERNEL      RW x  SHD MEM/CACHED/WBWA
0x20400000-0x24400000          64M PGD IO          RW NX SHD
0x24400000-0x24401000           4K PTE IO          RW NX SHD DEV/SHARED
---[ UEFI runtime end ]---

> >   arch/arm/include/asm/ptdump.h      | 1 +
> >   arch/arm64/include/asm/ptdump.h    | 1 +
> >   drivers/firmware/efi/arm-runtime.c | 4 ++--
> >   3 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/include/asm/ptdump.h b/arch/arm/include/asm/ptdump.h
> > index 0c2d3d0d4cc6..aad1d034136c 100644
> > --- a/arch/arm/include/asm/ptdump.h
> > +++ b/arch/arm/include/asm/ptdump.h
> > @@ -21,6 +21,7 @@ struct ptdump_info {
> >
> >   void ptdump_walk_pgd(struct seq_file *s, struct ptdump_info *info);
> >   #ifdef CONFIG_ARM_PTDUMP_DEBUGFS
> > +#define EFI_RUNTIME_MAP_END  SZ_1G
> >   void ptdump_debugfs_register(struct ptdump_info *info, const char *name);
> >   #else
> >   static inline void ptdump_debugfs_register(struct ptdump_info *info,
> > diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h
> > index b1dd7ecff7ef..581caac525b0 100644
> > --- a/arch/arm64/include/asm/ptdump.h
> > +++ b/arch/arm64/include/asm/ptdump.h
> > @@ -23,6 +23,7 @@ struct ptdump_info {
> >
> >   void ptdump_walk(struct seq_file *s, struct ptdump_info *info);
> >   #ifdef CONFIG_PTDUMP_DEBUGFS
> > +#define EFI_RUNTIME_MAP_END  DEFAULT_MAP_WINDOW_64
> >   void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name);
> >   #else
> >   static inline void ptdump_debugfs_register(struct ptdump_info *info,
> > diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
> > index 3359ae2adf24..8f8ae479061b 100644
> > --- a/drivers/firmware/efi/arm-runtime.c
> > +++ b/drivers/firmware/efi/arm-runtime.c
> > @@ -25,14 +25,14 @@
> >   #include <asm/mmu.h>
> >   #include <asm/pgalloc.h>
> >
> > -#if defined(CONFIG_PTDUMP_DEBUGFS) && defined(CONFIG_ARM64)
> > +#if defined(CONFIG_PTDUMP_DEBUGFS) || defined(CONFIG_ARM_PTDUMP_DEBUGFS)
> >   #include <asm/ptdump.h>
> >
> >   static struct ptdump_info efi_ptdump_info = {
> >       .mm             = &efi_mm,
> >       .markers        = (struct addr_marker[]){
> >               { 0,                            "UEFI runtime start" },
> > -             { DEFAULT_MAP_WINDOW_64,        "UEFI runtime end" },
> > +             { EFI_RUNTIME_MAP_END,          "UEFI runtime end" },
> >               { -1,                           NULL }
> >       },
> >       .base_addr      = 0,
Re: [PATCH v2] efi/arm: dump UEFI runtime page tables for ARM
Posted by Kefeng Wang 1 year, 6 months ago
On 2022/10/10 17:47, Ard Biesheuvel wrote:
> On Sat, 8 Oct 2022 at 08:37, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> Sorry, forget to Cc Ard and efi maillist, do it now.
>>
>> On 2022/9/30 18:10, Kefeng Wang wrote:
>>> UEFI runtime page tables dump only for ARM64 at present,
>>> but ARM support EFI and ARM_PTDUMP_DEBUGFS now. Since
>>> ARM could potentially execute with a 1G/3G user/kernel
>>> split, choosing 1G as the upper limit for UEFI runtime
>>> end, with this, we could enable UEFI runtime page tables.
>>>
>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>>> ---
>>> v2: update upper limit for ARM, only build test due to
>>>       my qemu without UEFI boot support.
> Tested-by: Ard Biesheuvel <ardb@kernel.org>
> Acked-by: Ard Biesheuvel <ardb@kernel.org>
>
Many thanks:)
>
>
> / # cat /sys/kernel/debug/efi_page_tables
> ---[ UEFI runtime start ]---
> 0x20005000-0x20112000        1076K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
> 0x20112000-0x20114000           8K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
> 0x20114000-0x20117000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
> 0x20117000-0x20118000           4K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
> 0x20118000-0x2011b000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
> 0x2011b000-0x2011c000           4K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
> 0x2011c000-0x2011f000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
> 0x2011f000-0x2017c000         372K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
> 0x2017c000-0x20183000          28K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
> 0x20183000-0x20186000          12K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
> 0x20186000-0x20189000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
> 0x20189000-0x2018a000           4K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
> 0x2018a000-0x2018d000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
> 0x2018d000-0x2018e000           4K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
> 0x2018e000-0x20191000          12K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
> 0x20191000-0x20193000           8K PTE KERNEL      ro x  SHD MEM/CACHED/WBWA
> 0x20193000-0x20195000           8K PTE KERNEL      RW NX SHD MEM/CACHED/WBWA
> 0x201a5000-0x203fd000        2400K PTE KERNEL      RW x  SHD MEM/CACHED/WBWA
> 0x20400000-0x24400000          64M PGD IO          RW NX SHD
> 0x24400000-0x24401000           4K PTE IO          RW NX SHD DEV/SHARED
> ---[ UEFI runtime end ]---
>
>>>    arch/arm/include/asm/ptdump.h      | 1 +
>>>    arch/arm64/include/asm/ptdump.h    | 1 +
>>>    drivers/firmware/efi/arm-runtime.c | 4 ++--
>>>    3 files changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/arm/include/asm/ptdump.h b/arch/arm/include/asm/ptdump.h
>>> index 0c2d3d0d4cc6..aad1d034136c 100644
>>> --- a/arch/arm/include/asm/ptdump.h
>>> +++ b/arch/arm/include/asm/ptdump.h
>>> @@ -21,6 +21,7 @@ struct ptdump_info {
>>>
>>>    void ptdump_walk_pgd(struct seq_file *s, struct ptdump_info *info);
>>>    #ifdef CONFIG_ARM_PTDUMP_DEBUGFS
>>> +#define EFI_RUNTIME_MAP_END  SZ_1G
>>>    void ptdump_debugfs_register(struct ptdump_info *info, const char *name);
>>>    #else
>>>    static inline void ptdump_debugfs_register(struct ptdump_info *info,
>>> diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h
>>> index b1dd7ecff7ef..581caac525b0 100644
>>> --- a/arch/arm64/include/asm/ptdump.h
>>> +++ b/arch/arm64/include/asm/ptdump.h
>>> @@ -23,6 +23,7 @@ struct ptdump_info {
>>>
>>>    void ptdump_walk(struct seq_file *s, struct ptdump_info *info);
>>>    #ifdef CONFIG_PTDUMP_DEBUGFS
>>> +#define EFI_RUNTIME_MAP_END  DEFAULT_MAP_WINDOW_64
>>>    void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name);
>>>    #else
>>>    static inline void ptdump_debugfs_register(struct ptdump_info *info,
>>> diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
>>> index 3359ae2adf24..8f8ae479061b 100644
>>> --- a/drivers/firmware/efi/arm-runtime.c
>>> +++ b/drivers/firmware/efi/arm-runtime.c
>>> @@ -25,14 +25,14 @@
>>>    #include <asm/mmu.h>
>>>    #include <asm/pgalloc.h>
>>>
>>> -#if defined(CONFIG_PTDUMP_DEBUGFS) && defined(CONFIG_ARM64)
>>> +#if defined(CONFIG_PTDUMP_DEBUGFS) || defined(CONFIG_ARM_PTDUMP_DEBUGFS)
>>>    #include <asm/ptdump.h>
>>>
>>>    static struct ptdump_info efi_ptdump_info = {
>>>        .mm             = &efi_mm,
>>>        .markers        = (struct addr_marker[]){
>>>                { 0,                            "UEFI runtime start" },
>>> -             { DEFAULT_MAP_WINDOW_64,        "UEFI runtime end" },
>>> +             { EFI_RUNTIME_MAP_END,          "UEFI runtime end" },
>>>                { -1,                           NULL }
>>>        },
>>>        .base_addr      = 0,
> .