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

Auto max pa #6543

Merged
merged 3 commits into from
Dec 14, 2023
Merged

Auto max pa #6543

merged 3 commits into from
Dec 14, 2023

Conversation

jenswi-linaro
Copy link
Contributor

No description provided.

unsigned int b = 0;

if (IS_ENABLED(CFG_AUTO_MAX_PA_BITS))
return size_bits;
Copy link
Contributor

Choose a reason for hiding this comment

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

size_bits is an index in const uint8_t map[] = { 32, 36, 40, 42, 44, 48, 52, };, not the size in bits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes and no. It's an index in that map, but it's also the PARange field in ID_AA64MMFR0_EL1 and the IPS field in TCR_EL1.

Copy link
Contributor

Choose a reason for hiding this comment

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

right, my bad. This si ok.

uint8_t b = CFG_CORE_ARM64_PA_BITS;

if (IS_ENABLED(CFG_AUTO_MAX_PA_BITS)) {
const uint8_t map[] = { 32, 36, 40, 42, 44, 48, 52, };
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe too much code in an inline function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, it's a bit on the heavy side. Would you prefer to move this into core/arch/arm/mm/core_mmu.c or even core/arch/arm/mm/core_mmu_lpae.c?

Copy link
Contributor

Choose a reason for hiding this comment

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

core_mmu_lpae.c

unsigned int b = 0;

if (IS_ENABLED(CFG_AUTO_MAX_PA_BITS))
return size_bits;
Copy link
Contributor

Choose a reason for hiding this comment

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

right, my bad. This si ok.

@jenswi-linaro
Copy link
Contributor Author

Update


COMPILE_TIME_ASSERT(CFG_CORE_ARM64_PA_BITS >= 32);
static_assert(CFG_CORE_ARM64_PA_BITS >= 32);
static_assert(CFG_CORE_ARM64_PA_BITS <= 52);
Copy link
Contributor

Choose a reason for hiding this comment

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

This function never returns TCR_PS_BITS_4PB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll update.

const uint8_t map[] = { 32, 36, 40, 42, 44, 48, 52, };
unsigned int size_bits = get_physical_addr_size_bits();

size_bits = MIN(size_bits, ARRAY_SIZE(map) - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

assert(size_bits < ARRAY_SIZE(map))?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to be future-proof. If Arm adds another value it's nice not to cause any breakage.

@jenswi-linaro
Copy link
Contributor Author

Update

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

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

Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> for commits
"core: arm64.h: add read_id_aa64mmfr0_el1()" and
"core: add CFG_AUTO_MAX_PA_BITS".

Acked-by: Etienne Carriere <etienne.carriere@foss.st.com> for commit
"plat-vexpress: use CFG_AUTO_MAX_PA_BITS on virtual platforms".

Add a read function for the system register ID_AA64MMFR0_EL1 and the
mask ID_AA64MMFR0_EL1_PARANGE_MASK to extract the PARange field.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
Add the configuration variable CFG_AUTO_MAX_PA_BITS that enables
automatic discovery of maximal PA supported by the hardware.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
By default set CFG_AUTO_MAX_PA_BITS=y on the virtual platforms fvp and
qemu_armv8a to allow automatic configuration of the maximal supported
physical address.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
@jenswi-linaro
Copy link
Contributor Author

Tags applied

@jforissier jforissier merged commit efc4076 into OP-TEE:master Dec 14, 2023
8 checks passed
@jenswi-linaro jenswi-linaro deleted the auto_max_pa branch December 14, 2023 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants