All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/power/64: Fix page-table setup for temporary text mapping
@ 2018-04-19 18:26 Joerg Roedel
  2018-04-19 18:28 ` Joerg Roedel
  2018-04-20  9:55 ` [tip:x86/urgent] " tip-bot for Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Joerg Roedel @ 2018-04-19 18:26 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar
  Cc: rjw, pavel, hpa, Michal Kubecek, Borislav Petkov, x86, linux-pm,
	linux-kernel, Joerg Roedel

From: Joerg Roedel <jroedel@suse.de>

When we have a 4-level page-table there is no p4d, so we map
the pud in the pgd. The old code before commit fb43d6cb91ef
already did that.

With the change from above commit we end up with an invalid
page-table which causes undefined behavior. In one report it
caused triple faults.

Fix it by changing the p4d back to pud so that we have a
correct page-table.

Reported-by: Borislav Petkov <bp@suse.de>
Fixes: fb43d6cb91ef ('x86/mm: Do not auto-massage page protections')
Tested-by: Michal Kubecek <mkubecek@suse.cz>
Tested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 arch/x86/power/hibernate_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c
index 48b14b534897..ccf4a49bb065 100644
--- a/arch/x86/power/hibernate_64.c
+++ b/arch/x86/power/hibernate_64.c
@@ -98,7 +98,7 @@ static int set_up_temporary_text_mapping(pgd_t *pgd)
 		set_pgd(pgd + pgd_index(restore_jump_address), new_pgd);
 	} else {
 		/* No p4d for 4-level paging: point the pgd to the pud page table */
-		pgd_t new_pgd = __pgd(__pa(p4d) | pgprot_val(pgtable_prot));
+		pgd_t new_pgd = __pgd(__pa(pud) | pgprot_val(pgtable_prot));
 		set_pgd(pgd + pgd_index(restore_jump_address), new_pgd);
 	}
 
-- 
2.13.6

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/power/64: Fix page-table setup for temporary text mapping
  2018-04-19 18:26 [PATCH] x86/power/64: Fix page-table setup for temporary text mapping Joerg Roedel
@ 2018-04-19 18:28 ` Joerg Roedel
  2018-04-20  9:55 ` [tip:x86/urgent] " tip-bot for Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2018-04-19 18:28 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Thomas Gleixner, Ingo Molnar, rjw, pavel, hpa, Michal Kubecek,
	Borislav Petkov, x86, linux-pm, linux-kernel, Dave Hansen

Adding Dave Hansen to Cc, forgot that in the initial post.

On Thu, Apr 19, 2018 at 08:26:00PM +0200, Joerg Roedel wrote:
> From: Joerg Roedel <jroedel@suse.de>
> 
> When we have a 4-level page-table there is no p4d, so we map
> the pud in the pgd. The old code before commit fb43d6cb91ef
> already did that.
> 
> With the change from above commit we end up with an invalid
> page-table which causes undefined behavior. In one report it
> caused triple faults.
> 
> Fix it by changing the p4d back to pud so that we have a
> correct page-table.
> 
> Reported-by: Borislav Petkov <bp@suse.de>
> Fixes: fb43d6cb91ef ('x86/mm: Do not auto-massage page protections')
> Tested-by: Michal Kubecek <mkubecek@suse.cz>
> Tested-by: Borislav Petkov <bp@suse.de>
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
> ---
>  arch/x86/power/hibernate_64.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c
> index 48b14b534897..ccf4a49bb065 100644
> --- a/arch/x86/power/hibernate_64.c
> +++ b/arch/x86/power/hibernate_64.c
> @@ -98,7 +98,7 @@ static int set_up_temporary_text_mapping(pgd_t *pgd)
>  		set_pgd(pgd + pgd_index(restore_jump_address), new_pgd);
>  	} else {
>  		/* No p4d for 4-level paging: point the pgd to the pud page table */
> -		pgd_t new_pgd = __pgd(__pa(p4d) | pgprot_val(pgtable_prot));
> +		pgd_t new_pgd = __pgd(__pa(pud) | pgprot_val(pgtable_prot));
>  		set_pgd(pgd + pgd_index(restore_jump_address), new_pgd);
>  	}
>  
> -- 
> 2.13.6

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/urgent] x86/power/64: Fix page-table setup for temporary text mapping
  2018-04-19 18:26 [PATCH] x86/power/64: Fix page-table setup for temporary text mapping Joerg Roedel
  2018-04-19 18:28 ` Joerg Roedel
@ 2018-04-20  9:55 ` tip-bot for Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Joerg Roedel @ 2018-04-20  9:55 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: bp, jroedel, dave.hansen, hpa, mkubecek, linux-kernel, mingo, tglx

Commit-ID:  05189820da23fc87ee2a7d87c20257f298af27f4
Gitweb:     https://git.kernel.org/tip/05189820da23fc87ee2a7d87c20257f298af27f4
Author:     Joerg Roedel <jroedel@suse.de>
AuthorDate: Thu, 19 Apr 2018 20:26:00 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 20 Apr 2018 11:52:00 +0200

x86/power/64: Fix page-table setup for temporary text mapping

On a system with 4-level page-tables there is no p4d, so the pud in the pgd
should be mapped. The old code before commit fb43d6cb91ef already did that.

The change from above commit causes an invalid page-table which causes
undefined behavior. In one report it caused triple faults.

Fix it by changing the p4d back to pud.

Fixes: fb43d6cb91ef ('x86/mm: Do not auto-massage page protections')
Reported-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michal Kubecek <mkubecek@suse.cz>
Tested-by: Borislav Petkov <bp@suse.de>
Cc: linux-pm@vger.kernel.org
Cc: rjw@rjwysocki.net
Cc: pavel@ucw.cz
Cc: hpa@zytor.com
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lkml.kernel.org/r/1524162360-26179-1-git-send-email-joro@8bytes.org

---
 arch/x86/power/hibernate_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c
index 48b14b534897..ccf4a49bb065 100644
--- a/arch/x86/power/hibernate_64.c
+++ b/arch/x86/power/hibernate_64.c
@@ -98,7 +98,7 @@ static int set_up_temporary_text_mapping(pgd_t *pgd)
 		set_pgd(pgd + pgd_index(restore_jump_address), new_pgd);
 	} else {
 		/* No p4d for 4-level paging: point the pgd to the pud page table */
-		pgd_t new_pgd = __pgd(__pa(p4d) | pgprot_val(pgtable_prot));
+		pgd_t new_pgd = __pgd(__pa(pud) | pgprot_val(pgtable_prot));
 		set_pgd(pgd + pgd_index(restore_jump_address), new_pgd);
 	}
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-20  9:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19 18:26 [PATCH] x86/power/64: Fix page-table setup for temporary text mapping Joerg Roedel
2018-04-19 18:28 ` Joerg Roedel
2018-04-20  9:55 ` [tip:x86/urgent] " tip-bot for Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.