x86/mm/pat: Fix L1TF stable backport for CPA
Subsystems (3)
PATCH 1/1 x86/mm/pat: Fix L1TF stable backport for CPA
From: Andi Kleen <[email protected]>
Patch for stable only to fix boot resets caused by the L1TF patches.
Stable trees reverted the following patch
Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"
This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is
commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.but the L1TF patch backported here
x86/mm/pat: Make set_memory_np() L1TF safe
commit 958f79b9ee55dfaf00c8106ed1c22a2919e0028b upstream
set_memory_np() is used to mark kernel mappings not present, but it has it's own open coded mechanism which does not have the L1TF protection of inverting the address bits.
assumed that cpa->pfn contains a PFN. With the above patch reverted it does not, which causes the PMD to be set to an incorrect address shifted by 12 bits, which can cause early boot reset on some systems, like an Apollo Lake embedded system.
Convert the address to a PFN before passing it to pmd_pfn()
Thanks to Bernhard for bisecting and testing.
--- arch/x86/mm/pageattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/pageattr.c +1 -1
@@ -1006,7 +1006,7 @@ static int populate_pmd(struct cpa_data *cpa, pmd =pmd_offset (pud, start); -set_pmd (pmd,pmd_mkhuge (pfn_pmd (cpa->pfn, +set_pmd (pmd,pmd_mkhuge (pfn_pmd (cpa->pfn >>PAGE_SHIFT ,canon_pgprot (pmd_pgprot)))); start +=PMD_SIZE ;
Signature · 1 line
2.17.1
Quoted 30 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Patch for stable only to fix boot resets caused by the L1TF patches.
Stable trees reverted the following patch
Revert "x86/mm/pat: Ensure
cpa->pfnonly contains page frame numbers"This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.but the L1TF patch backported here
x86/mm/pat: Make
set_memory_np()L1TF safecommit
958f79b9ee55dfaf00c8106ed1c22a2919e0028bupstream
set_memory_np()is used to mark kernel mappings not present, but it has it's own open coded mechanism which does not have the L1TF protection of inverting the address bits.assumed that
cpa->pfncontains a PFN. With the above patch reverted it does not, which causes the PMD to be set to an incorrect address shifted by 12 bits, which can cause early boot reset on some systems, like an Apollo Lake embedded system.Convert the address to a PFN before passing it to
pmd_pfn()Thanks to Bernhard for bisecting and testing.
Quoted 7 lines
Cc [email protected] # 4.4 and 4.9Reported-by Bernhard Kaindl <[email protected]>Tested-by Bernhard Kaindl <[email protected]>Signed-off-by Andi Kleen <[email protected]>--- arch/x86/mm/pageattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks for this, now queued up.
greg k-h
Quoted 21 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Patch for stable only to fix boot resets caused by the L1TF patches.
Stable trees reverted the following patch
Revert "x86/mm/pat: Ensure
cpa->pfnonly contains page frame numbers"This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.but the L1TF patch backported here
x86/mm/pat: Make
set_memory_np()L1TF safecommit
958f79b9ee55dfaf00c8106ed1c22a2919e0028bupstream
set_memory_np()is used to mark kernel mappings not present, but it has it's own open coded mechanism which does not have the L1TF protection of inverting the address bits.
Quoted 9 lines
assumed that
cpa->pfncontains a PFN. With the above patch reverted it does not, which causes the PMD to be set to an incorrect address shifted by 12 bits, which can cause early boot reset on some systems, like an Apollo Lake embedded system.Convert the address to a PFN before passing it to
pmd_pfn()Thanks to Bernhard for bisecting and testing.
Thanks a lot to you for tracking it down, and sorry for messing it up.
Quoted 1 line
Cc [email protected] # 4.4 and 4.9
LGTM for v4.4.y but ... are you sure that this patch applies to v4.9.y ? Commit edc3b9129cec is 'native' in v4.9.y and has not been reverted there.
$ git log --oneline v4.4..linux-4.9.y | grep "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers" edc3b9129cec x86/mm/pat: Ensure cpa->pfn only contains page frame numbers
Guenter
Quoted 20 lines
Reported-by Bernhard Kaindl <[email protected]>Tested-by Bernhard Kaindl <[email protected]>Signed-off-by Andi Kleen <[email protected]>--- arch/x86/mm/pageattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/mm/pageattr.c +1
-1@@ -1006,7 +1006,7 @@ static int populate_pmd(struct cpa_data *cpa, pmd =pmd_offset (pud, start); -set_pmd (pmd,pmd_mkhuge (pfn_pmd (cpa->pfn, +set_pmd (pmd,pmd_mkhuge (pfn_pmd (cpa->pfn >>PAGE_SHIFT ,canon_pgprot (pmd_pgprot)))); start +=PMD_SIZE ;
Quoted 4 lines
Quoted 1 line
Cc [email protected] # 4.4 and 4.9LGTM for v4.4.y but ... are you sure that this patch applies to v4.9.y ? Commit
edc3b9129cecis 'native' in v4.9.y and has not been reverted there.
You're right. I thought it was needed for 4.9 too, but yes it has the CPA pfn patch. So for 4.9 the patch is not needed and in fact incorrect.
The original report was for 4.4.
Greg can you please revert/remove it again for 4.9?
-Andi
Quoted 11 lines · Andi Kleen
Quoted 4 lines
Quoted 1 line
Cc [email protected] # 4.4 and 4.9LGTM for v4.4.y but ... are you sure that this patch applies to v4.9.y ? Commit
edc3b9129cecis 'native' in v4.9.y and has not been reverted there.You're right. I thought it was needed for 4.9 too, but yes it has the CPA pfn patch. So for 4.9 the patch is not needed and in fact incorrect.
The original report was for 4.4.
Greg can you please revert/remove it again for 4.9?
Now dropped, thanks.
greg k-h
Quoted 43 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Patch for stable only to fix boot resets caused by the L1TF patches.
Stable trees reverted the following patch
Revert "x86/mm/pat: Ensure
cpa->pfnonly contains page frame numbers"This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.but the L1TF patch backported here
x86/mm/pat: Make
set_memory_np()L1TF safecommit
958f79b9ee55dfaf00c8106ed1c22a2919e0028bupstream
set_memory_np()is used to mark kernel mappings not present, but it has it's own open coded mechanism which does not have the L1TF protection of inverting the address bits.assumed that
cpa->pfncontains a PFN. With the above patch reverted it does not, which causes the PMD to be set to an incorrect address shifted by 12 bits, which can cause early boot reset on some systems, like an Apollo Lake embedded system.Convert the address to a PFN before passing it to
pmd_pfn()Thanks to Bernhard for bisecting and testing.
Cc [email protected] # 4.4 and 4.9Reported-by Bernhard Kaindl <[email protected]>Tested-by Bernhard Kaindl <[email protected]>Signed-off-by Andi Kleen <[email protected]>--- arch/x86/mm/pageattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/mm/pageattr.c +0
-0
arch/x86/mm/pageattr.c static int populate_pmd(struct cpa_data *cpa, · line 1010
Quoted 6 lines
arch/x86/mm/pageattr.c +1
-1@@ -1006,7 +1006,7 @@ static int populate_pmd(struct cpa_data *cpa, pmd =pmd_offset (pud, start); -set_pmd (pmd,pmd_mkhuge (pfn_pmd (cpa->pfn, +set_pmd (pmd,pmd_mkhuge (pfn_pmd (cpa->pfn >>PAGE_SHIFT ,canon_pgprot (pmd_pgprot))));
And what about populate_pud?
set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn,
canon_pgprot(pud_pgprot))));
start += PUD_SIZE;
cpa->pfn += PUD_SIZE;thanks,
Signature · 2 lines
js suse labs
Quoted 6 lines
And what about
populate_pud?set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn, canon_pgprot(pud_pgprot)))); start += PUD_SIZE; cpa->pfn += PUD_SIZE;
Yes you're right. That case needs to be fixed too.
Are you sending a patch, or should I?
-Andi
PATCH v2 1/1 x86/mm/pat: Fix L1TF stable backport for CPA, 2nd call
Mostly recycling the commit log from adaba23ccd7d which fixed populate_pmd, but did not fix populate_pud. The same problem exists there.
Stable trees reverted the following patch:
Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"
This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is
commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.but the L1TF patch 02ff2769edbc backported here
x86/mm/pat: Make set_memory_np() L1TF safe
commit 958f79b9ee55dfaf00c8106ed1c22a2919e0028b upstream
set_memory_np() is used to mark kernel mappings not present, but it has it's own open coded mechanism which does not have the L1TF protection of inverting the address bits.
assumed that cpa->pfn contains a PFN. With the above patch reverted it does not, which causes the PUD to be set to an incorrect address shifted by 12 bits, which can cause various failures.
Convert the address to a PFN before passing it to pud_pfn().
This is a 4.4 stable only patch to fix the L1TF patches backport there.
--- arch/x86/mm/pageattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/pageattr.c +1 -1
@@ -1079,7 +1079,7 @@ static int populate_pud(struct cpa_data *cpa, unsigned long start, pgd_t *pgd,* Map everything starting from the Gb boundary, possibly with 1G pages */ while (end - start >=PUD_SIZE ) { -set_pud (pud,pud_mkhuge (pfn_pud (cpa->pfn, +set_pud (pud,pud_mkhuge (pfn_pud (cpa->pfn >>PAGE_SHIFT ,canon_pgprot (pud_pgprot)))); start +=PUD_SIZE ;
Signature · 1 line
2.18.0
Greg KH
maintainerRe: [PATCH v2 for 4.4] x86/mm/pat: Fix L1TF stable backport for CPA, 2nd call
Quoted 26 lines · Jiri Slaby
Mostly recycling the commit log from
adaba23ccd7dwhich fixedpopulate_pmd, but did not fixpopulate_pud. The same problem exists there.Stable trees reverted the following patch:
Revert "x86/mm/pat: Ensurecpa->pfnonly contains page frame numbers"This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.but the L1TF patch
02ff2769edbcbackported herex86/mm/pat: Make
set_memory_np()L1TF safecommit
958f79b9ee55dfaf00c8106ed1c22a2919e0028bupstream
set_memory_np()is used to mark kernel mappings not present, but it has it's own open coded mechanism which does not have the L1TF protection of inverting the address bits.assumed that
cpa->pfncontains a PFN. With the above patch reverted it does not, which causes the PUD to be set to an incorrect address shifted by 12 bits, which can cause various failures.Convert the address to a PFN before passing it to
pud_pfn().
Quoted 8 lines
This is a 4.4 stable only patch to fix the L1TF patches backport there.
Cc [email protected] # 4.4-onlyCc Andi Kleen <[email protected]>Signed-off-by Jiri Slaby <[email protected]>--- arch/x86/mm/pageattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks for this, now queued up.
greg k-h
Greg KH
maintainerQuoted 10 lines · Andi Kleen
Quoted 6 lines
And what about
populate_pud?set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn, canon_pgprot(pud_pgprot)))); start += PUD_SIZE; cpa->pfn += PUD_SIZE;Yes you're right. That case needs to be fixed too.
Are you sending a patch, or should I?
Someone needs to. Please?
greg k-h
Quoted 5 lines · Greg KH
Quoted 4 lines · Andi Kleen
Quoted 4 lines
And what about
populate_pud?set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn, canon_pgprot(pud_pgprot))));
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
start += PUD_SIZE; cpa->pfn += PUD_SIZE;Yes you're right. That case needs to be fixed too.
Are you sending a patch, or should I?
Someone needs to. Please?
You already released 4.4.x with the patch :):
commit 15898df477269c981dc1ae5afa39e1bb65e1db0a
Author: Jiri Slaby <[email protected]> Date: Fri Sep 7 11:13:07 2018 +0200
x86/mm/pat: Fix L1TF stable backport for CPA, 2nd call
thanks,
Signature · 2 lines
js suse labs
Greg KH
maintainerQuoted 15 lines · Jiri Slaby
Quoted 5 lines · Greg KH
Quoted 4 lines · Andi Kleen
Quoted 4 lines
And what about
populate_pud?set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn, canon_pgprot(pud_pgprot))));Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
start += PUD_SIZE; cpa->pfn += PUD_SIZE;Yes you're right. That case needs to be fixed too.
Are you sending a patch, or should I?
Someone needs to. Please?
Quoted 8 lines
You already released 4.4.x with the patch :):
commit
15898df477269c981dc1ae5afa39e1bb65e1db0aAuthor: Jiri Slaby <[email protected]> Date: Fri Sep 7 11:13:07 2018 +0200x86/mm/pat: Fix L1TF stable backport for CPA, 2nd call
Ugh, nevermind, sorry for the noise :)
greg k-h