Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xlat_tables: PLAT_VIRT_ADDR_SPACE_SIZE must be long long #1018

Closed

Conversation

etienne-lms
Copy link
Contributor

PLAT_VIRT_ADDR_SPACE_SIZE may reach 4GByte, hence overflowing a 32bit
storage media. This change insures PLAT_VIRT_ADDR_SPACE_SIZE is defined
(and handled) as a long long unsigned value.

This change updates legacy and v2 versions of the xlat_table library.

Change-Id: I9176cc13cbd54aa8a5a6374b7b663f8d79e10604
Signed-off-by: Yann Gautier yann.gautier@st.com
Signed-off-by: Etienne Carriere etienne.carriere@st.com

PLAT_VIRT_ADDR_SPACE_SIZE may reach 4GByte, hence overflowing a 32bit
storage media. This change insures PLAT_VIRT_ADDR_SPACE_SIZE is defined
(and handled) as a long long unsigned value.

This change updates legacy and v2 versions of the xlat_table library.

Change-Id: I9176cc13cbd54aa8a5a6374b7b663f8d79e10604
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
@ssg-bot
Copy link

ssg-bot commented Jul 3, 2017

Can one of the admins verify this patch?

@@ -127,13 +127,13 @@ void enable_mmu_secure(unsigned int flags)
ttbcr = TTBCR_EAE_BIT |
TTBCR_SH0_NON_SHAREABLE | TTBCR_RGN0_OUTER_NC |
TTBCR_RGN0_INNER_NC |
(32 - __builtin_ctzl((uintptr_t)PLAT_VIRT_ADDR_SPACE_SIZE));
(32 - __builtin_ctzll(PLAT_VIRT_ADDR_SPACE_SIZE));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add the change to lib/xlat_tables/aarch64/xlat_tables.c as well for consistency.

} else {
/* Inner & outer WBWA & shareable. */
ttbcr = TTBCR_EAE_BIT |
TTBCR_SH0_INNER_SHAREABLE | TTBCR_RGN0_OUTER_WBA |
TTBCR_RGN0_INNER_WBA |
(32 - __builtin_ctzl((uintptr_t)PLAT_VIRT_ADDR_SPACE_SIZE));
(32 - __builtin_ctzll(PLAT_VIRT_ADDR_SPACE_SIZE));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@@ -51,13 +51,13 @@

# error "PLAT_VIRT_ADDR_SPACE_SIZE is too big."

#elif PLAT_VIRT_ADDR_SPACE_SIZE > (1 << L1_XLAT_ADDRESS_SHIFT)
#elif PLAT_VIRT_ADDR_SPACE_SIZE > (1ULL << L1_XLAT_ADDRESS_SHIFT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really required? L1_XLAT_ADDRESS_SHIFT is 30 , so 1 << 30 is still within unsigned int range. Perhaps 1U would suffice ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That depends on whether the firmware is going to support or not 16KB and 64KB pages at some point, as it means that the shift for a L1 entry would be 36 or 42 respectively.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, in that case, this change need to be done in lib/xlat_tables_v2/aarch64/xlat_tables_arch.h as well.


# define XLAT_TABLE_LEVEL_BASE 1
# define NUM_BASE_LEVEL_ENTRIES \
(PLAT_VIRT_ADDR_SPACE_SIZE >> L1_XLAT_ADDRESS_SHIFT)

#elif PLAT_VIRT_ADDR_SPACE_SIZE >= (1 << (32 - TTBCR_TxSZ_MAX))
#elif PLAT_VIRT_ADDR_SPACE_SIZE >= (1ULL << (32 - TTBCR_TxSZ_MAX))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@@ -201,12 +201,12 @@ void init_xlat_tables_arch(unsigned long long max_pa)
/* Inner & outer non-cacheable non-shareable. */\
tcr = TCR_SH_NON_SHAREABLE | \
TCR_RGN_OUTER_NC | TCR_RGN_INNER_NC | \
(64 - __builtin_ctzl(PLAT_VIRT_ADDR_SPACE_SIZE));\
(64 - __builtin_ctzll(PLAT_VIRT_ADDR_SPACE_SIZE));\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has to be made in lib/xlat_tables_v2/aarch32/xlat_tables_arch.c as well.

} else { \
/* Inner & outer WBWA & shareable. */ \
tcr = TCR_SH_INNER_SHAREABLE | \
TCR_RGN_OUTER_WBA | TCR_RGN_INNER_WBA | \
(64 - __builtin_ctzl(PLAT_VIRT_ADDR_SPACE_SIZE));\
(64 - __builtin_ctzll(PLAT_VIRT_ADDR_SPACE_SIZE));\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Copy link
Contributor

@davidcunado-arm davidcunado-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments from Soby.

sandrine-bailleux-arm added a commit to sandrine-bailleux-arm/arm-trusted-firmware that referenced this pull request Jul 25, 2017
Fix the type length and signedness of some of the constants and
variables used in the translation table library.

This patch supersedes Pull Request ARM-software#1018:
ARM-software#1018

Change-Id: Ibd45faf7a4fb428a0bf71c752551d35800212fb2
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
sandrine-bailleux-arm added a commit to sandrine-bailleux-arm/arm-trusted-firmware that referenced this pull request Jul 26, 2017
Fix the type length and signedness of some of the constants and
variables used in the translation table library.

This patch supersedes Pull Request ARM-software#1018:
ARM-software#1018

Change-Id: Ibd45faf7a4fb428a0bf71c752551d35800212fb2
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
@danh-arm
Copy link
Contributor

Superseded by #1035

@danh-arm danh-arm closed this Jul 26, 2017
@etienne-lms etienne-lms deleted the longlong-vspace branch August 18, 2017 13:08
kph pushed a commit to platinasystems/arm-trusted-firmware that referenced this pull request Feb 27, 2020
Fix the type length and signedness of some of the constants and
variables used in the translation table library.

This patch supersedes Pull Request #1018:
ARM-software/arm-trusted-firmware#1018

Change-Id: Ibd45faf7a4fb428a0bf71c752551d35800212fb2
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants