xen/arm: Do not allocate pte entries for MAP_SMALL_PAGES
PATCH 1/1 xen/arm: Do not allocate pte entries for MAP_SMALL_PAGES
From: Vijaya Kumar K <[email protected]>
On x86, for the pages mapped with PAGE_HYPERVISOR attribute non-leaf page tables are allocated with valid pte entries. and with MAP_SMALL_PAGES attribute only non-leaf page tables are allocated with invalid (valid bit set to 0) pte entries. However on arm this is not the case. On arm for the pages mapped with PAGE_HYPERVISOR and MAP_SMALL_PAGES both non-leaf and leaf level page table are allocated with valid bit in pte entries.
This behaviour in arm makes common vmap code fail to allocate memory beyond 128MB as described below.
In vmap_init, map_pages_to_xen() is called for mapping vm_bitmap. Initially one page of vm_bitmap is allocated and mapped using PAGE_HYPERVISOR attribute.
For the rest of vm_bitmap pages, MAP_SMALL_PAGES attribute is used to map.
In ARM for both PAGE_HYPERVISOR and MAP_SMALL_PAGES, valid bit is set to 1 in pte entry for these mapping.
In vma_alloc(), map_pages_to_xen() is failing for >128MB because for this next vm_bitmap page the mapping is already set in vm_init() with valid bit set in pte entry. So map_pages_to_xen() in ARM returns error.
With this patch, MAP_SMALL_PAGES attribute will only allocate non-leaf page tables only.
Here we use bit[16] in the attribute flag to know if leaf page tables should be allocated or not.
This bit is set only for MAP_SMALL_PAGES attribute.
--- xen/arch/arm/mm.c | 9 ++++++--- xen/include/asm-arm/page.h | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-)
xen/arch/arm/mm.c +6 -3
@@ -865,9 +865,12 @@ static int create_xen_entries(enum xenmap_operation op, addr, mfn);return -EINVAL ; } - pte =mfn_to_xen_entry (mfn, ai); - pte.pt.table =1 ; -write_pte (&third[third_table_offset (addr)], pte); +if ( !(ai &PTE_INVALID ) ) + { + pte =mfn_to_xen_entry (mfn, (ai &0xffff )); + pte.pt.table =1 ; +write_pte (&third[third_table_offset (addr)], pte); + }break ;case REMOVE :if ( !third[third_table_offset (addr)].pt.valid )
xen/include/asm-arm/page.h +7 -1
@@ -61,10 +61,16 @@#define DEV_WC BUFFERABLE#define DEV_CACHED WRITEBACK +/* bit 16 in the Attribute index can be used to know if +* PTE entry should be added or not. This is useful +* when ONLY non-leaf page table entries need to allocated +*/ +#define PTE_INVALID (0x1 << 16) +#define PAGE_HYPERVISOR (WRITEALLOC)#define PAGE_HYPERVISOR_NOCACHE (DEV_SHARED)#define PAGE_HYPERVISOR_WC (DEV_WC) -#define MAP_SMALL_PAGES PAGE_HYPERVISOR +#define MAP_SMALL_PAGES (PAGE_HYPERVISOR | (PTE_INVALID))/* * Stage 2 Memory Type.
Signature · 1 line
1.7.9.5
Hello Vijay,
Quoted 47 lines · On 18/02/2015 12:56, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
On x86, for the pages mapped with
PAGE_HYPERVISORattribute non-leaf page tables are allocated with valid pte entries. and withMAP_SMALL_PAGESattribute only non-leaf page tables are allocated with invalid (valid bit set to 0) pte entries. However on arm this is not the case. On arm for the pages mapped withPAGE_HYPERVISORandMAP_SMALL_PAGESboth non-leaf and leaf level page table are allocated with valid bit in pte entries.This behaviour in arm makes common vmap code fail to allocate memory beyond 128MB as described below.
In
vmap_init,map_pages_to_xen()is called for mappingvm_bitmap. Initially one page ofvm_bitmapis allocated and mapped usingPAGE_HYPERVISORattribute.
For the rest ofvm_bitmappages,MAP_SMALL_PAGESattribute is used to map.In ARM for both
PAGE_HYPERVISORandMAP_SMALL_PAGES, valid bit is set to 1 in pte entry for these mapping.In
vma_alloc(),map_pages_to_xen()is failing for >128MB because for this nextvm_bitmappage the mapping is already set invm_init()with valid bit set in pte entry. Somap_pages_to_xen()in ARM returns error.With this patch,
MAP_SMALL_PAGESattribute will only allocate non-leaf page tables only.Here we use bit[16] in the attribute flag to know if leaf page tables should be allocated or not.
This bit is set only for
MAP_SMALL_PAGESattribute.Signed-off-by Vijaya Kumar K<[email protected]>--- xen/arch/arm/mm.c | 9 ++++++--- xen/include/asm-arm/page.h | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-)xen/arch/arm/mm.c +0
-0
xen/arch/arm/mm.c static int create_xen_entries(enum xenmap_operation op, · line 868
Quoted 7 lines
xen/arch/arm/mm.c +1
-3@@ -865,9 +865,12 @@ static int create_xen_entries(enum xenmap_operation op, addr, mfn);return -EINVAL ; } - pte =mfn_to_xen_entry (mfn, ai); - pte.pt.table =1 ; -write_pte (&third[third_table_offset (addr)], pte); +if ( !(ai &PTE_INVALID ) )
you could do if ( ai & PTE_INVALID ) break; It would avoid a new level of indentation.
Also, I would rename ai to flags as the variable is not anymore an attribute index.
xen/arch/arm/mm.c static int create_xen_entries(enum xenmap_operation op, · line 870
Quoted 2 lines
xen/arch/arm/mm.c +2
-0+ { + pte =mfn_to_xen_entry (mfn, (ai &0xffff ));
Please introduce a new macro for the mask.
Quoted 11 lines
xen/arch/arm/mm.c +3
-0+ pte.pt.table =1 ; +write_pte (&third[third_table_offset (addr)], pte); + }break ;case REMOVE :if ( !third[third_table_offset (addr)].pt.valid )xen/include/asm-arm/page.h +0
-0
xen/include/asm-arm/page.h line 68
Quoted 8 lines
xen/include/asm-arm/page.h +5
-0@@ -61,10 +61,16 @@#define DEV_WC BUFFERABLE#define DEV_CACHED WRITEBACK +/* bit 16 in the Attribute index can be used to know if +* PTE entry should be added or not. This is useful +* when ONLY non-leaf page table entries need to allocated +*/ +#define PTE_INVALID (0x1 << 16)
It makes more sense to introduce a PTE_PRESENT flags compare to PTE_INVALID. The former has more meaning that the latter.
Regards,
Signature · 1 line
Julien Grall
Quoted 4 lines · Julien Grall
xen/arch/arm/mm.c static int create_xen_entries(enum xenmap_operation op, · line 870
Quoted 2 lines
xen/arch/arm/mm.c +2
-0+ { + pte =mfn_to_xen_entry (mfn, (ai &0xffff ));Please introduce a new macro for the mask.
Better would be a pte_foo accessor, similar (if not identical) to x86's pte_get_flags. So pte_get_flags(ai) or so.
Quoted 15 lines
Quoted 15 lines
xen/arch/arm/mm.c +3
-0+ pte.pt.table =1 ; +write_pte (&third[third_table_offset (addr)], pte); + }break ;case REMOVE :if ( !third[third_table_offset (addr)].pt.valid )xen/include/asm-arm/page.h +0
-0@@ -61,10 +61,16 @@#define DEV_WC BUFFERABLE#define DEV_CACHED WRITEBACK
Quoted 8 lines
xen/include/asm-arm/page.h line 68
Quoted 5 lines
xen/include/asm-arm/page.h +5
-0+/* bit 16 in the Attribute index can be used to know if +* PTE entry should be added or not. This is useful +* when ONLY non-leaf page table entries need to allocated +*/ +#define PTE_INVALID (0x1 << 16)It makes more sense to introduce a
PTE_PRESENTflags compare toPTE_INVALID. The former has more meaning that the latter.
Agreed that PTE_PRESENT is the way to go. Ideally this could all be done via the lpae_pt_t type, but I suspect that might turn out to be tricky.
#define PTE_PRESENT ((struct lpae_t){ .pt.present = 1 }).bits
probably doesn't work, I'm not even sure if this sort of thing is possible. If not then "#define PTE_PRESET (1ULL<<0)".
Hi Ian,
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Julien Grall
xen/arch/arm/mm.c static int create_xen_entries(enum xenmap_operation op, · line 870
Quoted 2 lines
xen/arch/arm/mm.c +2
-0+ { + pte =mfn_to_xen_entry (mfn, (ai &0xffff ));Please introduce a new macro for the mask.
Better would be a
pte_fooaccessor, similar (if not identical) to x86'spte_get_flags. Sopte_get_flags(ai)or so.
I'm not able to find a such function in x86. Did you intend to mean pte_flags_to_cacheattr?
Quoted 25 lines
Quoted 16 lines
Quoted 16 lines
xen/arch/arm/mm.c +3
-0+ pte.pt.table =1 ; +write_pte (&third[third_table_offset (addr)], pte); + }break ;case REMOVE :if ( !third[third_table_offset (addr)].pt.valid )xen/include/asm-arm/page.h +0
-0@@ -61,10 +61,16 @@#define DEV_WC BUFFERABLE#define DEV_CACHED WRITEBACKQuoted 8 lines
xen/include/asm-arm/page.h line 68
Quoted 5 lines
xen/include/asm-arm/page.h +5
-0+/* bit 16 in the Attribute index can be used to know if +* PTE entry should be added or not. This is useful +* when ONLY non-leaf page table entries need to allocated +*/ +#define PTE_INVALID (0x1 << 16)It makes more sense to introduce a
PTE_PRESENTflags compare toPTE_INVALID. The former has more meaning that the latter.
Quoted 2 lines
Agreed that
PTE_PRESENTis the way to go. Ideally this could all be done via thelpae_pt_ttype, but I suspect that might turn out to be tricky.
I don't think it's a good idea to re-use lpae_pt_t type for this purpose. We might decide to introduce flags which won't be set in the final PTE.
In another side, using PTE_PRESENT would require to introduce a PAGE_AVAIL0 (or smth similar).
Quoted 4 lines
#define
PTE_PRESENT((struct lpae_t){ .pt.present = 1 }).bitsprobably doesn't work, I'm not even sure if this sort of thing is possible. If not then "#define
PTE_PRESET(1ULL<<0)".
The attribute index (write-alloc, buferrable...) is using the less significant 3 bits. So I was suggesting to use the top of the word.
Regards,
Signature · 1 line
Julien Grall
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 24.02.15 at 10:38, <[email protected]> wrote:
Quoted 4 lines · Ian Campbell
Quoted 3 lines · Julien Grall
Quoted 2 lines
xen/arch/arm/mm.c +2
-0+ { + pte =mfn_to_xen_entry (mfn, (ai &0xffff ));
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Please introduce a new macro for the mask.
Better would be a
pte_fooaccessor, similar (if not identical) to x86'spte_get_flags. Sopte_get_flags(ai)or so.I'm not able to find a such function in x86. Did you intend to mean
pte_flags_to_cacheattr?
get_pte_flags()
Jan
Quoted 7 lines · Julien Grall
Hi Ian,
Quoted 4 lines · Ian Campbell
Quoted 3 lines · Julien Grall
Quoted 2 lines
xen/arch/arm/mm.c +2
-0+ { + pte =mfn_to_xen_entry (mfn, (ai &0xffff ));
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Please introduce a new macro for the mask.
Better would be a
pte_fooaccessor, similar (if not identical) to x86'spte_get_flags. Sopte_get_flags(ai)or so.I'm not able to find a such function in x86. Did you intend to mean
pte_flags_to_cacheattr?
It's actually get_pte_flags.
Quoted 2 lines
In another side, using
PTE_PRESENTwould require to introduce aPAGE_AVAIL0(or smth similar).
Why?
Quoted 7 lines
Quoted 4 lines
#define
PTE_PRESENT((struct lpae_t){ .pt.present = 1 }).bitsprobably doesn't work, I'm not even sure if this sort of thing is possible. If not then "#define
PTE_PRESET(1ULL<<0)".The attribute index (write-alloc, buferrable...) is using the less significant 3 bits. So I was suggesting to use the top of the word.
I was suggesting to use bits 2..4 as in the real PTE, to be more similar to the x86 interpretation of this argument.
Ian.
Quoted 16 lines · Ian Campbell
Quoted 7 lines · Julien Grall
Hi Ian,
Quoted 4 lines · Ian Campbell
Quoted 3 lines · Julien Grall
Quoted 2 lines
xen/arch/arm/mm.c +2
-0+ { + pte =mfn_to_xen_entry (mfn, (ai &0xffff ));Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Please introduce a new macro for the mask.
Better would be a
pte_fooaccessor, similar (if not identical) to x86'spte_get_flags. Sopte_get_flags(ai)or so.I'm not able to find a such function in x86. Did you intend to mean
pte_flags_to_cacheattr?
Quoted 6 lines
It's actually
get_pte_flags.Quoted 2 lines
In another side, using
PTE_PRESENTwould require to introduce aPAGE_AVAIL0(or smth similar).Why?
If we have only a bit PTE_PRESENT, how do you define MAP_SMALL_PAGES?
Anyway, I guess introduce a separate helper would help here.
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
#define
PTE_PRESENT((struct lpae_t){ .pt.present = 1 }).bitsprobably doesn't work, I'm not even sure if this sort of thing is possible. If not then "#define
PTE_PRESET(1ULL<<0)".The attribute index (write-alloc, buferrable...) is using the less significant 3 bits. So I was suggesting to use the top of the word.
I was suggesting to use bits 2..4 as in the real PTE, to be more similar to the x86 interpretation of this argument.
I don't think we have to follow how x86 interpret this argument. This is just a series of flags and may or may not match a bit in the PTE.
For instance, in the case of MAP_SMALL_PAGES, we don't have to write the final PTE.
Regards,
Signature · 1 line
Julien Grall
Quoted 17 lines · Julien Grall
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Julien Grall
Hi Ian,
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Julien Grall
xen/arch/arm/mm.c static int create_xen_entries(enum xenmap_operation op, · line 870
Quoted 2 lines
xen/arch/arm/mm.c +2
-0+ { + pte =mfn_to_xen_entry (mfn, (ai &0xffff ));Please introduce a new macro for the mask.
Better would be a
pte_fooaccessor, similar (if not identical) to x86'spte_get_flags. Sopte_get_flags(ai)or so.I'm not able to find a such function in x86. Did you intend to mean
pte_flags_to_cacheattr?
Quoted 8 lines
Quoted 6 lines
It's actually
get_pte_flags.Quoted 2 lines
In another side, using
PTE_PRESENTwould require to introduce aPAGE_AVAIL0(or smth similar).Why?
If we have only a bit
PTE_PRESENT, how do you defineMAP_SMALL_PAGES?
Oh right, yes, I was thinking that would use some other bit, either an avail bit or reusing the table bit or something.
Quoted 7 lines
Anyway, I guess introduce a separate helper would help here.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
#define
PTE_PRESENT((struct lpae_t){ .pt.present = 1 }).bitsprobably doesn't work, I'm not even sure if this sort of thing is possible. If not then "#define
PTE_PRESET(1ULL<<0)".
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
The attribute index (write-alloc, buferrable...) is using the less significant 3 bits. So I was suggesting to use the top of the word.
I was suggesting to use bits 2..4 as in the real PTE, to be more similar to the x86 interpretation of this argument.
I don't think we have to follow how x86 interpret this argument. This is just a series of flags and may or may not match a bit in the PTE.
Not matching x86 here has already led to one set of confusion.
I'm not saying with have to match x86, but we should strongly consider it and not just run with what we have now because it is a smaller change.
Ian.
Quoted 8 lines · Ian Campbell
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
#define
PTE_PRESENT((struct lpae_t){ .pt.present = 1 }).bitsprobably doesn't work, I'm not even sure if this sort of thing is possible. If not then "#define
PTE_PRESET(1ULL<<0)".The attribute index (write-alloc, buferrable...) is using the less significant 3 bits. So I was suggesting to use the top of the word.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I was suggesting to use bits 2..4 as in the real PTE, to be more similar to the x86 interpretation of this argument.
I don't think we have to follow how x86 interpret this argument. This is just a series of flags and may or may not match a bit in the PTE.
Not matching x86 here has already led to one set of confusion.
That was a misunderstanding of the define. Without Jan's explanation I would not have understand the purpose of this define.
Quoted 3 lines
I'm not saying with have to match x86, but we should strongly consider it and not just run with what we have now because it is a smaller change.
lpae_t is an uint64_t and flags an unsigned int, so we will have to check that any bits we have to modified is effectively living on the less significant word.
Also, a smaller change would allow us to backport the patch to Xen 4.5.
Regards,
Signature · 1 line
Julien Grall
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 24.02.15 at 14:47, <[email protected]> wrote:
lpae_tis anuint64_tand flags an unsigned int, so we will have to check that any bits we have to modified is effectively living on the less significant word.
Or, upon extraction, fold all flags into something fitting into 32 bits, like we do on x86.
Jan
Quoted 17 lines · Julien Grall
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Julien Grall
Hi Ian,
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Julien Grall
xen/arch/arm/mm.c static int create_xen_entries(enum xenmap_operation op, · line 870
Quoted 2 lines
xen/arch/arm/mm.c +2
-0+ { + pte =mfn_to_xen_entry (mfn, (ai &0xffff ));Please introduce a new macro for the mask.
Better would be a
pte_fooaccessor, similar (if not identical) to x86'spte_get_flags. Sopte_get_flags(ai)or so.I'm not able to find a such function in x86. Did you intend to mean
pte_flags_to_cacheattr?
Quoted 8 lines
Quoted 6 lines
It's actually
get_pte_flags.Quoted 2 lines
In another side, using
PTE_PRESENTwould require to introduce aPAGE_AVAIL0(or smth similar).Why?
If we have only a bit
PTE_PRESENT, how do you defineMAP_SMALL_PAGES?
MAP_SMALL_PAGES is already defined as WRITE_ALLOC which occupies lower 3 bits what is need for PAGE_AVAIL0?
Below definitions should suffice?
-#define PTE_INVALID (0x1 << 16)
+#define PTE_PRESENT (0x1 << 16)
-#define PAGE_HYPERVISOR (WRITEALLOC)
-#define PAGE_HYPERVISOR_NOCACHE (DEV_SHARED)
-#define PAGE_HYPERVISOR_WC (DEV_WC) -#define MAP_SMALL_PAGES (PAGE_HYPERVISOR | (PTE_INVALID)) +#define PAGE_HYPERVISOR ((WRITEALLOC) | PTE_PRESENT )
+#define PAGE_HYPERVISOR_NOCACHE ((DEV_SHARED) | PTE_PRESENT )
+#define PAGE_HYPERVISOR_WC ((DEV_WC) | PTE_PRESENT )
+#define MAP_SMALL_PAGES (WRITEALLOC)
+
+#define is_pte_present(x) ((x) & PTE_PRESENT) +#define get_pte_flags(x) ((x) & 0x7)
Quoted 24 lines
Anyway, I guess introduce a separate helper would help here.
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
#define
PTE_PRESENT((struct lpae_t){ .pt.present = 1 }).bitsprobably doesn't work, I'm not even sure if this sort of thing is possible. If not then "#define
PTE_PRESET(1ULL<<0)".The attribute index (write-alloc, buferrable...) is using the less significant 3 bits. So I was suggesting to use the top of the word.
I was suggesting to use bits 2..4 as in the real PTE, to be more similar to the x86 interpretation of this argument.
I don't think we have to follow how x86 interpret this argument. This is just a series of flags and may or may not match a bit in the PTE.
For instance, in the case of
MAP_SMALL_PAGES, we don't have to write the final PTE.Regards,
--
Julien Grall
Quoted 23 lines · Vijay Kilari
Quoted 22 lines · Julien Grall
Quoted 21 lines · Ian Campbell
Quoted 7 lines · Julien Grall
Hi Ian,
Quoted 4 lines · Ian Campbell
Quoted 3 lines · Julien Grall
Quoted 2 lines
(quoted diff) +2
-0+ { + pte = mfn_to_xen_entry(mfn, (ai & 0xffff));Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Please introduce a new macro for the mask.
Better would be a
pte_fooaccessor, similar (if not identical) to x86'spte_get_flags. Sopte_get_flags(ai)or so.I'm not able to find a such function in x86. Did you intend to mean
pte_flags_to_cacheattr?It's actually
get_pte_flags.Quoted 2 lines
In another side, using
PTE_PRESENTwould require to introduce aPAGE_AVAIL0(or smth similar).
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Why?
If we have only a bit
PTE_PRESENT, how do you defineMAP_SMALL_PAGES?
MAP_SMALL_PAGESis already defined asWRITE_ALLOCwhich occupies lower 3 bits what is need forPAGE_AVAIL0?Below definitions should suffice?
I think so. You don't need the ()s around DEV_* and WRITE_ALLOC etc in the PAGE_* definitions.
A comment on the format of the bit packing done here would also be useful e.g. "16: present\n2:0: pte attributes field" in a little block comment above this stuff, below the DEV_* stuff.
PAGE_PRESENT might be more in keepign that PTE_PRESENT, since this isn't a PTE bit pattern.
Quoted 40 lines
(quoted diff) +8
-5-#define PTE_INVALID (0x1 << 16) +#define PTE_PRESENT (0x1 << 16) -#define PAGE_HYPERVISOR (WRITEALLOC) -#define PAGE_HYPERVISOR_NOCACHE (DEV_SHARED) -#define PAGE_HYPERVISOR_WC (DEV_WC) -#define MAP_SMALL_PAGES (PAGE_HYPERVISOR | (PTE_INVALID)) +#define PAGE_HYPERVISOR ((WRITEALLOC) | PTE_PRESENT ) +#define PAGE_HYPERVISOR_NOCACHE ((DEV_SHARED) | PTE_PRESENT ) +#define PAGE_HYPERVISOR_WC ((DEV_WC) | PTE_PRESENT ) +#define MAP_SMALL_PAGES (WRITEALLOC) + +#define is_pte_present(x) ((x) & PTE_PRESENT) +#define get_pte_flags(x) ((x) & 0x7)Quoted 26 lines
Anyway, I guess introduce a separate helper would help here.
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
#define
PTE_PRESENT((struct lpae_t){ .pt.present = 1 }).bitsprobably doesn't work, I'm not even sure if this sort of thing is possible. If not then "#define
PTE_PRESET(1ULL<<0)".The attribute index (write-alloc, buferrable...) is using the less significant 3 bits. So I was suggesting to use the top of the word.
I was suggesting to use bits 2..4 as in the real PTE, to be more similar to the x86 interpretation of this argument.
I don't think we have to follow how x86 interpret this argument. This is just a series of flags and may or may not match a bit in the PTE.
For instance, in the case of
MAP_SMALL_PAGES, we don't have to write the final PTE.Regards,
--
Julien Grall
Hi Ian,
Quoted 28 lines · Ian Campbell
Quoted 27 lines · Vijay Kilari
Quoted 25 lines · Julien Grall
Quoted 16 lines · Ian Campbell
Quoted 7 lines · Julien Grall
Hi Ian,
Quoted 4 lines · Ian Campbell
Quoted 3 lines · Julien Grall
Quoted 2 lines
(quoted diff) +2
-0+ { + pte = mfn_to_xen_entry(mfn, (ai & 0xffff));Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Please introduce a new macro for the mask.
Better would be a
pte_fooaccessor, similar (if not identical) to x86'spte_get_flags. Sopte_get_flags(ai)or so.I'm not able to find a such function in x86. Did you intend to mean
pte_flags_to_cacheattr?Quoted 6 lines
It's actually
get_pte_flags.Quoted 2 lines
In another side, using
PTE_PRESENTwould require to introduce aPAGE_AVAIL0(or smth similar).Why?
If we have only a bit
PTE_PRESENT, how do you defineMAP_SMALL_PAGES?
Quoted 7 lines
Quoted 4 lines
MAP_SMALL_PAGESis already defined asWRITE_ALLOCwhich occupies lower 3 bits what is need forPAGE_AVAIL0?Below definitions should suffice?
I think so. You don't need the ()s around DEV_* and
WRITE_ALLOCetc in the PAGE_* definitions.
I'm not sure to follow here. Do you think MAP_SMALL_PAGES should be defined as WRITE_ALLOC?
Quoted 6 lines
A comment on the format of the bit packing done here would also be useful e.g. "16: present\n2:0: pte attributes field" in a little block comment above this stuff, below the DEV_* stuff.
PAGE_PRESENTmight be more in keepign thatPTE_PRESENT, since this isn't a PTE bit pattern.
Sounds good to me.
Regards,
Signature · 1 line
Julien Grall
Quoted 34 lines · Julien Grall
Hi Ian,
Quoted 31 lines · Ian Campbell
Quoted 30 lines · Vijay Kilari
Quoted 17 lines · Julien Grall
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Julien Grall
Hi Ian,
Quoted 8 lines · Ian Campbell
Quoted 4 lines · Julien Grall
Review
Quoted 2 lines
(quoted diff) +2
-0+ { + pte = mfn_to_xen_entry(mfn, (ai & 0xffff));Please introduce a new macro for the mask.
Better would be a
pte_fooaccessor, similar (if not identical) to x86'spte_get_flags. Sopte_get_flags(ai)or so.I'm not able to find a such function in x86. Did you intend to mean
pte_flags_to_cacheattr?Quoted 8 lines
Quoted 6 lines
It's actually
get_pte_flags.Quoted 2 lines
In another side, using
PTE_PRESENTwould require to introduce aPAGE_AVAIL0(or smth similar).Why?
If we have only a bit
PTE_PRESENT, how do you defineMAP_SMALL_PAGES?
MAP_SMALL_PAGESis already defined asWRITE_ALLOCwhich occupies lower 3 bits what is need forPAGE_AVAIL0?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Below definitions should suffice?
I think so. You don't need the ()s around DEV_* and
WRITE_ALLOCetc in the PAGE_* definitions.I'm not sure to follow here. Do you think
MAP_SMALL_PAGESshould be defined asWRITE_ALLOC?
Sorry I just meant that:
+#define PAGE_HYPERVISOR_WC ((DEV_WC) | PTE_PRESENT )
should be just:
+#define PAGE_HYPERVISOR_WC (DEV_WC | PTE_PRESENT )
etc, no need for the inner-()s.
MAP_SMALL_PAGES was correct as
+#define MAP_SMALL_PAGES (WRITEALLOC)
Ian
Quoted 11 lines · Ian Campbell
Quoted 2 lines
I'm not sure to follow here. Do you think
MAP_SMALL_PAGESshould be defined asWRITE_ALLOC?Sorry I just meant that:
+#definePAGE_HYPERVISOR_WC((DEV_WC) |PTE_PRESENT)
should be just:
+#definePAGE_HYPERVISOR_WC(DEV_WC|PTE_PRESENT)
etc, no need for the inner-()s.
MAP_SMALL_PAGESwas correct as
+#defineMAP_SMALL_PAGES(WRITEALLOC)
I wanted to check the definition of MAP_SMALL_PAGES you were agreed.
I think using WRITEALLOC here is confusing. There is no resulting PTE and therefore WRITEALLOC will never be set.
I think it would be better to have a separate helper (as you suggested on a previous mail).
Regards,
Signature · 1 line
Julien Grall
Quoted 14 lines · Julien Grall
Quoted 11 lines · Ian Campbell
Quoted 2 lines
I'm not sure to follow here. Do you think
MAP_SMALL_PAGESshould be defined asWRITE_ALLOC?Sorry I just meant that:
+#definePAGE_HYPERVISOR_WC((DEV_WC) |PTE_PRESENT)
should be just:
+#definePAGE_HYPERVISOR_WC(DEV_WC|PTE_PRESENT)
etc, no need for the inner-()s.
MAP_SMALL_PAGESwas correct as
+#defineMAP_SMALL_PAGES(WRITEALLOC)
Quoted 7 lines
I wanted to check the definition of
MAP_SMALL_PAGESyou were agreed.I think using WRITEALLOC here is confusing. There is no resulting PTE and therefore WRITEALLOC will never be set.
I think it would be better to have a separate helper (as you suggested on a previous mail).
Ah yes, I'd forgotten I'd thought of that. A separate helper to provision an empty PT range would indeed be the best thing here.
Quoted 3 lines
Regards,