xen/arm: p2m: fix pa_range_info for 52-bit pa range
PATCH 1/1 xen/arm: p2m: fix pa_range_info for 52-bit pa range
Currently the pa_range_info for the 52-bit pa range advertizes that the p2m root table consists of 8 concatenated tables at level 3, which does not make much sense.
In order to support the 52-bit pa size with 4KB granule, the p2m root table needs to be configured either as a single table at level -1 or as 16 concatenated tables at level 0.
Since, currently there is not support for level -1, set the root_order and sl0 fields of the corresponding pa_range_info according to the second approach.
--- xen/arch/arm/p2m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/p2m.c +1 -1
@@ -2251,7 +2251,7 @@ void __init setup_virt_paging(void) [3] = { 42, 22/*22*/, 3, 1 }, [4] = { 44, 20/*20*/, 0, 2 }, [5] = { 48, 16/*16*/, 0, 2 }, - [6] = { 52, 12/*12*/, 3, 3 }, + [6] = { 52, 12/*12*/, 4, 2 }, [7 ] = {0 }/* Invalid */ };
Signature · 1 line
2.34.1
Hi Xenia,
Quoted 5 lines · Xenia Ragiadakou
Currently the
pa_range_infofor the 52-bit pa range advertizes that the p2m root table consists of 8 concatenated tables at level 3, which does not make much sense.
I think the current code advertises 8 concatenated tables at level -1 (sl0=3 -> root_level=-1) which is obviously incorrect, but the commit msg should be updated.
Funnily enough p2m_root_level is unsigned so it would lead to overflow (p2m_root_level would end up with (1 << 32) - 1 instead of -1).
Quoted 8 lines
In order to support the 52-bit pa size with 4KB granule, the p2m root table needs to be configured either as a single table at level -1 or as 16 concatenated tables at level 0.
Since, currently there is not support for level -1, set theroot_orderand sl0 fields of the correspondingpa_range_infoaccording to the second approach.Signed-off-by Xenia Ragiadakou <[email protected]>
~Michal
On 10/18/22 12:02, Michal Orzel wrote:
Hi Michal,
Quoted 10 lines
Hi Xenia,
Quoted 5 lines · Xenia Ragiadakou
Currently the
pa_range_infofor the 52-bit pa range advertizes that the p2m root table consists of 8 concatenated tables at level 3, which does not make much sense.I think the current code advertises 8 concatenated tables at level -1 (sl0=3 -> root_level=-1) which is obviously incorrect, but the commit msg should be updated.
I did the same mistake in my email but I did not want to hijack the thread that 's why I did not come back to correct my error. According to the manual, to support 52-bit pa range with 4KB granule with the root table at level -1, you need to set SL2=1 and SL0=0. SL0=3 configures the root table at level 3.
Quoted 2 lines
Funnily enough
p2m_root_levelis unsigned so it would lead to overflow (p2m_root_levelwould end up with (1 << 32) - 1 instead of -1).
Actually, currently, there is no support at all in XEN neither for LPA (LPA support for 4KB is not checked, VCTR DS and SL2 are not set etc) nor level -1 (the root table level is determined only based on sl0, the number of possible levels is hardcoded to 4 in many places etc). I don't think that there is even support for accessing other than the first table of concatenated root tables but I need to verify that (I assume this based on the way LPAE_TABLE_INDEX_GS is implemented).
This entry is populated in the pa_range_info table just to prevent XEN from falling into this if ( pa_range >= ARRAY_SIZE(pa_range_info) || !pa_range_info[pa_range].pabits )
panic("Unknown encoding of ID_AA64MMFR0_EL1.PARange %x\n",pa_range);
Quoted 14 lines
Quoted 9 lines
In order to support the 52-bit pa size with 4KB granule, the p2m root table needs to be configured either as a single table at level -1 or as 16 concatenated tables at level 0.
Since, currently there is not support for level -1, set theroot_orderand sl0 fields of the correspondingpa_range_infoaccording to the second approach.Signed-off-by Xenia Ragiadakou <[email protected]>Reviewed-by Michal Orzel <[email protected]>~Michal
Signature · 1 line
Xenia
Hi Xenia,
Quoted 12 lines · Xenia Ragiadakou
On 10/18/22 12:02, Michal Orzel wrote:
Hi Michal,
Quoted 8 lines
Hi Xenia,
Quoted 5 lines · Xenia Ragiadakou
Currently the
pa_range_infofor the 52-bit pa range advertizes that the p2m root table consists of 8 concatenated tables at level 3, which does not make much sense.
Quoted 6 lines
Quoted 2 lines
I think the current code advertises 8 concatenated tables at level -1 (sl0=3 -> root_level=-1) which is obviously incorrect, but the commit msg should be updated.
I did the same mistake in my email but I did not want to hijack the thread that 's why I did not come back to correct my error. According to the manual, to support 52-bit pa range with 4KB granule with the root table at level -1, you need to set SL2=1 and SL0=0. SL0=3 configures the root table at level 3.
Which section are you reading? Looking at the definition of VTCR_EL2.SL0 (D17-6375, ARM DDI 0487I.a), the field has different meaning depending on whether the feature TTST (Small translation table) is present.
SL0 would be reserved when TTST is not present. That said, it looks like LPA requires TTST.
Quoted 2 lines
Quoted 2 lines
Funnily enough
p2m_root_levelis unsigned so it would lead to overflow
Did you mean underflow rather than overflow?
Quoted 3 lines
Quoted 1 line
(
p2m_root_levelwould end up with (1 << 32) - 1 instead of -1).Actually, currently, there is no support at all in XEN neither for LPA (LPA support for 4KB is not checked, VCTR DS and SL2 are not set etc) nor level -1 (the root table level is determined only based on sl0, the number of possible levels is hardcoded to 4 in many places etc). I don't think that there is even support for accessing other than the first table of concatenated root tables but I need to verify that (I assume this based on the way
LPAE_TABLE_INDEX_GSis implemented).
I am not sure I understand this. Are you saying that concatenation can be used for non-root table?
Quoted 5 lines
This entry is populated in the
pa_range_infotable just to prevent XEN from falling into this if (pa_range>=ARRAY_SIZE(pa_range_info)|| !pa_range_info[pa_range].pabits )
panic("Unknown encoding of ID_AA64MMFR0_EL1.PARange %x\n",pa_range);
I think it would be worth to point out in the commit message that the value is not used so far. So this is only update for correctness.
Cheers,
Signature · 1 line
Julien Grall
On 10/18/22 13:56, Julien Grall wrote:
Hi Julien,
Quoted 18 lines
Hi Xenia,
Quoted 15 lines · Xenia Ragiadakou
On 10/18/22 12:02, Michal Orzel wrote:
Hi Michal,
Quoted 10 lines
Hi Xenia,
Quoted 5 lines · Xenia Ragiadakou
Currently the
pa_range_infofor the 52-bit pa range advertizes that the p2m root table consists of 8 concatenated tables at level 3, which does not make much sense.I think the current code advertises 8 concatenated tables at level -1 (sl0=3 -> root_level=-1) which is obviously incorrect, but the commit msg should be updated.
Quoted 7 lines
Quoted 3 lines
I did the same mistake in my email but I did not want to hijack the thread that 's why I did not come back to correct my error. According to the manual, to support 52-bit pa range with 4KB granule with the root table at level -1, you need to set SL2=1 and SL0=0. SL0=3 configures the root table at level 3.
Which section are you reading? Looking at the definition of VTCR_EL2.SL0 (D17-6375, ARM DDI 0487I.a), the field has different meaning depending on whether the feature TTST (Small translation table) is present.
SL0 would be reserved when TTST is not present. That said, it looks like LPA requires TTST.
I 'm referring to the table Table D8-12 "4KB granule, determining stage 2 initial lookup level" (D8-5103, ARM DDI 0487I.a). With 4KB granule, for having the root table at level 3, TTST is required, yes.
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
Funnily enough
p2m_root_levelis unsigned so it would lead to overflowDid you mean underflow rather than overflow?
Quoted 3 lines
Quoted 1 line
(
p2m_root_levelwould end up with (1 << 32) - 1 instead of -1).Actually, currently, there is no support at all in XEN neither for LPA (LPA support for 4KB is not checked, VCTR DS and SL2 are not set etc) nor level -1 (the root table level is determined only based on sl0, the number of possible levels is hardcoded to 4 in many places etc). I don't think that there is even support for accessing other than the first table of concatenated root tables but I need to verify that (I assume this based on the way
LPAE_TABLE_INDEX_GSis implemented).I am not sure I understand this. Are you saying that concatenation can be used for non-root table?
No, the contrary. I cannot see how it can work out of the box given the current implementation. Because the mask applied to get the table index is limited to the size of a single table.
Quoted 7 lines
Quoted 5 lines
This entry is populated in the
pa_range_infotable just to prevent XEN from falling into this if (pa_range>=ARRAY_SIZE(pa_range_info)|| !pa_range_info[pa_range].pabits )panic("Unknown encoding of ID_AA64MMFR0_EL1.PARange %x\n", pa_range);I think it would be worth to point out in the commit message that the value is not used so far. So this is only update for correctness.
Sure.
Do I need a Fixes tag even though the previous code, effectively, was not breaking anything?
Quoted 3 lines
Cheers,
Signature · 1 line
Xenia
Hi Xenia,
Quoted 10 lines · Xenia Ragiadakou
Currently the
pa_range_infofor the 52-bit pa range advertizes that the p2m root table consists of 8 concatenated tables at level 3, which does not make much sense.
In order to support the 52-bit pa size with 4KB granule, the p2m root table needs to be configured either as a single table at level -1 or as 16 concatenated tables at level 0.
Since, currently there is not support for level -1, set theroot_orderand sl0 fields of the correspondingpa_range_infoaccording to the second approach.
Please add a Fixes tag. Also, it would be good to provide a reference to the Arm Arm (paragraph + version) so it is easier to find where your values come from.
Cheers,
Quoted 18 lines
Signed-off-by Xenia Ragiadakou <[email protected]>--- xen/arch/arm/p2m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/p2m.c +1
-1@@ -2251,7 +2251,7 @@ void __init setup_virt_paging(void) [3] = { 42, 22/*22*/, 3, 1 }, [4] = { 44, 20/*20*/, 0, 2 }, [5] = { 48, 16/*16*/, 0, 2 }, - [6] = { 52, 12/*12*/, 3, 3 }, + [6] = { 52, 12/*12*/, 4, 2 }, [7 ] = {0 }/* Invalid */ };
Signature · 1 line
Julien Grall