xen/arm: mm: fix nr_second calculation in setup_frametable_mappings
PATCH 1/1 xen/arm: mm: fix nr_second calculation in setup_frametable_mappings
To ARM64, "frametable_size >> SECOND_SHIFT" means the number of second level entries, not the number of second level pages.
"DIV_ROUND_UP(frametable_size >> SECOND_SHIFT, LPAE_ENTRIES)" is the correct way to calculate the second level pages needed for frametable mapping.
--- xen/arch/arm/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/mm.c +1 -1
@@ -767,7 +767,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) base_mfn =alloc_boot_pages (frametable_size >>PAGE_SHIFT ,32 <<(20 -12 ));#ifdef CONFIG_ARM_64 - nr_second = frametable_size >>SECOND_SHIFT ; + nr_second =DIV_ROUND_UP (frametable_size >>SECOND_SHIFT ,LPAE_ENTRIES ); second_base =alloc_boot_pages (nr_second,1 ); second =mfn_to_virt (second_base);for ( i =0 ; i < nr_second; i++ )
Signature · 7 lines
2.6.2 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Hi Peng,
Quoted 6 lines · Peng Fan
To ARM64, "
frametable_size>>SECOND_SHIFT" means the number of second level entries, not the number of second level pages."
DIV_ROUND_UP(frametable_size >> SECOND_SHIFT, LPAE_ENTRIES)" is the correct way to calculate the second level pages needed for frametable mapping.
Good catch!
Quoted 12 lines
Signed-off-by Peng Fan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Julien Grall <[email protected]>--- xen/arch/arm/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/mm.c +0
-0
xen/arch/arm/mm.c void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) · line 770
Quoted 5 lines
xen/arch/arm/mm.c +1
-1@@ -767,7 +767,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) base_mfn =alloc_boot_pages (frametable_size >>PAGE_SHIFT ,32 <<(20 -12 ));#ifdef CONFIG_ARM_64 - nr_second = frametable_size >>SECOND_SHIFT ; + nr_second =DIV_ROUND_UP (frametable_size >>SECOND_SHIFT ,LPAE_ENTRIES );
I think the following would be clearer:
ROUNDUP(frametable_size, FIRST_SIZE) >> FIRST_SHIFT;
This would also benefit a comment to explain that second level of page table are populating.
xen/arch/arm/mm.c void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) · line 773
Quoted 4 lines
xen/arch/arm/mm.c +0
-0second_base =alloc_boot_pages (nr_second,1 ); second =mfn_to_virt (second_base);for ( i =0 ; i < nr_second; i++ )
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Hi Julien,
Quoted 26 lines · Julien Grall
Hi Peng,
Quoted 6 lines · Peng Fan
To ARM64, "
frametable_size>>SECOND_SHIFT" means the number of second level entries, not the number of second level pages."
DIV_ROUND_UP(frametable_size >> SECOND_SHIFT, LPAE_ENTRIES)" is the correct way to calculate the second level pages needed for frametable mapping.Good catch!
Quoted 14 lines
Signed-off-by Peng Fan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Julien Grall <[email protected]>--- xen/arch/arm/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/mm.c +0
-0@@ -767,7 +767,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) base_mfn =alloc_boot_pages (frametable_size >>PAGE_SHIFT ,32 <<(20 -12 ));
Quoted 8 lines
xen/arch/arm/mm.c void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) · line 770
Quoted 3 lines
xen/arch/arm/mm.c +1
-1#ifdef CONFIG_ARM_64 - nr_second = frametable_size >>SECOND_SHIFT ; + nr_second =DIV_ROUND_UP (frametable_size >>SECOND_SHIFT ,LPAE_ENTRIES );I think the following would be clearer:
ROUNDUP(frametable_size, FIRST_SIZE)>>FIRST_SHIFT;
Agree.
Quoted 3 lines
This would also benefit a comment to explain that second level of page table are populating.
Do you mean I need to add a comment for the upper code?
For the commit log, I would like to change to this:
"
To ARM64, "frametable_size >> SECOND_SHIFT" means the number of second level entries, not the number of second level pages.
"ROUNDUP(frametable_size, FIRST_SIZE) >> FIRST_SHIFT" which means the number of the first level entries(the number of second level pages), is the correct one that should be used.
"
How do you think?
Thanks,
Peng.
Quoted 10 lines
xen/arch/arm/mm.c void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) · line 773
Quoted 5 lines
xen/arch/arm/mm.c +0
-0second_base =alloc_boot_pages (nr_second,1 ); second =mfn_to_virt (second_base);for ( i =0 ; i < nr_second; i++ )Regards,
Signature · 1 line
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 38 lines · Peng Fan
Hi Julien,
Quoted 26 lines · Julien Grall
Hi Peng,
Quoted 6 lines · Peng Fan
To ARM64, "
frametable_size>>SECOND_SHIFT" means the number of second level entries, not the number of second level pages."
DIV_ROUND_UP(frametable_size >> SECOND_SHIFT, LPAE_ENTRIES)" is the correct way to calculate the second level pages needed for frametable mapping.Good catch!
Quoted 14 lines
Signed-off-by Peng Fan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Julien Grall <[email protected]>--- xen/arch/arm/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/mm.c +0
-0@@ -767,7 +767,7 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) base_mfn =alloc_boot_pages (frametable_size >>PAGE_SHIFT ,32 <<(20 -12 ));Quoted 8 lines
xen/arch/arm/mm.c void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) · line 770
Quoted 3 lines
xen/arch/arm/mm.c +1
-1#ifdef CONFIG_ARM_64 - nr_second = frametable_size >>SECOND_SHIFT ; + nr_second =DIV_ROUND_UP (frametable_size >>SECOND_SHIFT ,LPAE_ENTRIES );I think the following would be clearer:
ROUNDUP(frametable_size, FIRST_SIZE)>>FIRST_SHIFT;
Quoted 7 lines
Agree.
Quoted 3 lines
This would also benefit a comment to explain that second level of page table are populating.
Do you mean I need to add a comment for the upper code?
Yes.
Quoted 4 lines
For the commit log, I would like to change to this:
"
To ARM64, "frametable_size>>SECOND_SHIFT" means the number
On ARM64,
s/means/computes/
Quoted 3 lines
of second level entries, not the number of second level pages.
"
ROUNDUP(frametable_size, FIRST_SIZE)>>FIRST_SHIFT" which means
s/means/computes/
Quoted 1 line
the number of the first level entries(the number of second level pages),
missing space after "entries"
Quoted 2 lines
is the correct one that should be used.
"
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel