|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCHv3 19/25] plat/kvm: arm64: Calculate pagetable size dynamically by image size
Hello Wei Chen, Please find the comments inline: Thanks & Regards Sharan On 12/13/18 10:15 AM, Wei Chen wrote: The previous L3 page table size is a fixed value based on the assumption that, image size will not exceed 2MB. But that's not true, some applications like node.js will be about 40MB after converting to Unikernel. So in this patch, we calculate the page table size by real image size. In order to mapping the image occupied memory to L3 page table, we round up the image size with 2MB. If we don't round up the image size with 2MB. Some memory that is not occupied by image but shared the same 2MB block with image tail will be unmapped in page table. Signed-off-by: Wei Chen <wei.chen@xxxxxxx> --- plat/common/include/sections.h | 31 +++++++++++++++++++++++++ plat/kvm/arm/entry64.S | 36 +++++++++++++++++++++++++++-- plat/kvm/arm/pagetable64.S | 4 +++- plat/kvm/arm/setup.c | 2 +- plat/kvm/include/kvm-arm/arm64/mm.h | 14 ++++++----- 5 files changed, 77 insertions(+), 10 deletions(-) diff --git a/plat/common/include/sections.h b/plat/common/include/sections.h index b32389c..5342e42 100644 --- a/plat/common/include/sections.h +++ b/plat/common/include/sections.h @@ -35,6 +35,7 @@ #ifndef __PLAT_CMN_SECTIONS_H__ #define __PLAT_CMN_SECTIONS_H__+#ifndef __ASSEMBLY__/* * Following global variables are defined in image link scripts, and some * variables are optional and may be unavailable on some architectures @@ -94,4 +95,34 @@ extern char _end[]; #define __BSS_START __uk_image_symbol(__bss_start) #define __END __uk_image_symbol(_end)+#endif /*__ASSEMBLY__ */+ +/* + * Because the section is 4KB alignment, and we will assign different + * attributes for different sections. We roundup image size to 2MB to + * avoid making holes in L3 table + * + * L2 table + * |-----------| L3 table + * | 2MB |===>|-----------| + * |-----------| | 4KB | entry#0 + * |-----------| + * | ... | + * | | + * |-----------| + * | 4KB | entry# for last page of real image + * |-----------| + * | 4KB | entry# for round up memory + * |-----------| + * | ... | + * |-----------| + * | 4KB | entry#511 + * |-----------| + * If we don't roundup the image size to 2MB, some memory that is not + * occupied by image but shared the same 2MB block with image tail will + * not be mapped in page table. + */ +#define IMAGE_ROUNDUP_SHIFT 20 Shouldn't this be 21, if we want to round to 2MB? +#define IMAGE_ROUNDUP_SIZE (0x1 << (IMAGE_ROUNDUP_SHIFT)) + #endif /* __PLAT_CMN_SECTIONS_H__ */ diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S index d08b49e..867772f 100644 --- a/plat/kvm/arm/entry64.S +++ b/plat/kvm/arm/entry64.S @@ -35,6 +35,12 @@ #include <uk/asm.h> #include <kvm-arm/mm.h> #include <arm/cpu_defs.h> +#include <sections.h> + +.global page_table_size +.data +page_table_size: + .dword 0x0/** The registers used by _libkvmplat_start: @@ -43,6 +49,29 @@.textENTRY(_libkvmplat_entry) + /* Caculate the image size */ s/caculate/calculate + ldr x25, =_dtb + ldr x26, =_end + mov x15, x25 + sub x15, x26, x15 + + /* Round up the size to 2MB */ + mov x17, #(IMAGE_ROUNDUP_SIZE - 1) + add x15, x15, x17 + lsr x15, x15, #IMAGE_ROUNDUP_SHIFT + lsl x15, x15, #IMAGE_ROUNDUP_SHIFT + + /* + * How many bytes would be used for L3_TABLE + * ((x15 >> 21) << 12) + */ + lsr x17, x15, #9 + + /* Total bytes for pagetable */ + add x17, x17, #L0_TABLE_SIZE + add x17, x17, #L1_TABLE_SIZE + add x17, x17, #L2_TABLE_SIZE +/* _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |