diff mbox series

[kvm-unit-tests] x86: efi: Fix pagetable creation

Message ID 20220406123312.12986-1-varad.gautam@suse.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests] x86: efi: Fix pagetable creation | expand

Commit Message

Varad Gautam April 6, 2022, 12:33 p.m. UTC
setup_page_table() ends up filling invalid page table entries
at ptl2 due to improper typecasting. This sometimes leads to
unhandled pagefaults when writing to APIC registers. Fix it.

Fixes: e6f65fa464 ("x86 UEFI: Set up page tables")
Signed-off-by: Varad Gautam <varad.gautam@suse.com>
---
 lib/x86/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Bonzini April 13, 2022, 9 p.m. UTC | #1
On 4/6/22 14:33, Varad Gautam wrote:
> setup_page_table() ends up filling invalid page table entries
> at ptl2 due to improper typecasting. This sometimes leads to
> unhandled pagefaults when writing to APIC registers. Fix it.
> 
> Fixes: e6f65fa464 ("x86 UEFI: Set up page tables")
> Signed-off-by: Varad Gautam <varad.gautam@suse.com>
> ---
>   lib/x86/setup.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/x86/setup.c b/lib/x86/setup.c
> index bbd3468..7bc7c93 100644
> --- a/lib/x86/setup.c
> +++ b/lib/x86/setup.c
> @@ -258,7 +258,7 @@ static void setup_page_table(void)
>   	curr_pt = (pgd_t *)&ptl2;
>   	flags |= PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_PAGE_SIZE_MASK | PT_GLOBAL_MASK;
>   	for (i = 0; i < 4 * 512; i++)	{
> -		curr_pt[i] = ((phys_addr_t)(i << 21)) | flags;
> +		curr_pt[i] = ((phys_addr_t) i << 21) | flags;
>   	}
>   
>   	if (amd_sev_es_enabled()) {

Applied, thanks.

Paolo
diff mbox series

Patch

diff --git a/lib/x86/setup.c b/lib/x86/setup.c
index bbd3468..7bc7c93 100644
--- a/lib/x86/setup.c
+++ b/lib/x86/setup.c
@@ -258,7 +258,7 @@  static void setup_page_table(void)
 	curr_pt = (pgd_t *)&ptl2;
 	flags |= PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_PAGE_SIZE_MASK | PT_GLOBAL_MASK;
 	for (i = 0; i < 4 * 512; i++)	{
-		curr_pt[i] = ((phys_addr_t)(i << 21)) | flags;
+		curr_pt[i] = ((phys_addr_t) i << 21) | flags;
 	}
 
 	if (amd_sev_es_enabled()) {