Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-31 Thread Greg Kroah-Hartman
On Fri, Aug 31, 2018 at 07:24:08AM +0100, Guillaume Tucker wrote:
> On 24/08/18 21:32, Guenter Roeck wrote:
> > On Fri, Aug 24, 2018 at 01:16:18PM -0700, Roland Dreier wrote:
> >>> Sounds great. I'll hold off with sending my RFT series and wait for your
> >>> test results. I think we'll also need d367cef0a7f0c6 ("x86/mm/pat: Fix
> >>> boot crash when 1GB pages are not supported by the CPU").
> >>
> >> Sure, makes sense - I don't have any EFI systems with CPUs old enough
> >> not to support 1G pages but that looks reasonable.  I'll pull that
> >> into my tree as well.
> >>
> > kernelci reported a crash on a CPU which doesn't support 1G pages.
> > See https://kernelci.org/boot/id/5b7d39ea59b514c03796ba9c/
> 
> Looks like this has now been fixed with Andi's patch in 4.4.153:
> 
>   "x86/mm/pat: Fix L1TF stable backport for CPA"
> 
> I can confirm this platform is now booting fine in kernelci:
> 
>   http://lava.streamtester.net/scheduler/job/146195

Wonderful, thanks for letting us know.

greg k-h


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-30 Thread Guillaume Tucker
On 24/08/18 21:32, Guenter Roeck wrote:
> On Fri, Aug 24, 2018 at 01:16:18PM -0700, Roland Dreier wrote:
>>> Sounds great. I'll hold off with sending my RFT series and wait for your
>>> test results. I think we'll also need d367cef0a7f0c6 ("x86/mm/pat: Fix
>>> boot crash when 1GB pages are not supported by the CPU").
>>
>> Sure, makes sense - I don't have any EFI systems with CPUs old enough
>> not to support 1G pages but that looks reasonable.  I'll pull that
>> into my tree as well.
>>
> kernelci reported a crash on a CPU which doesn't support 1G pages.
> See https://kernelci.org/boot/id/5b7d39ea59b514c03796ba9c/

Looks like this has now been fixed with Andi's patch in 4.4.153:

  "x86/mm/pat: Fix L1TF stable backport for CPA"

I can confirm this platform is now booting fine in kernelci:

  http://lava.streamtester.net/scheduler/job/146195

Thanks,
Guillaume


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-30 Thread Greg Kroah-Hartman
On Wed, Aug 29, 2018 at 12:58:00PM -0700, Roland Dreier wrote:
> > > Perhaps just the patch that Andi posted to the stable list helps out
> > > here?
> > >
> >
> > For reference:
> >
> > https://www.spinics.net/lists/stable/msg253357.html
> >
> > That would be the most straightforward and simple fix, so I would prefer
> > to go with it if it works.
> 
> Sorry for being slow, it turned out to take a slightly bigger stack of
> patches to get everything working.
> 
> I agree, Andi's simple fix is better anyway.

So 4.4.153 works fine for you now?

thanks,

greg k-h


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-29 Thread Roland Dreier
> > Perhaps just the patch that Andi posted to the stable list helps out
> > here?
> >
>
> For reference:
>
> https://www.spinics.net/lists/stable/msg253357.html
>
> That would be the most straightforward and simple fix, so I would prefer
> to go with it if it works.

Sorry for being slow, it turned out to take a slightly bigger stack of
patches to get everything working.

I agree, Andi's simple fix is better anyway.

 - R.


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-25 Thread Guenter Roeck

On 08/25/2018 08:07 AM, Greg Kroah-Hartman wrote:

On Sat, Aug 25, 2018 at 06:52:32AM -0700, Guenter Roeck wrote:

Hi Roland,

On 08/24/2018 01:04 PM, Roland Dreier wrote:

Ok, so what patch should be reverted?  I'm seeing other reports of
problems all around this same area, but I can't figure out exactly what
to do.


Are any of those reports public?  If so can you point me at them, I'm
curious if the symptoms match up.

I don't think we want to revert anything.  I think you should pull in
edc3b9129cec and at least the first three patches that Ben listed:

21cdb6b56843 x86/mm: Page align the '_end' symbol to avoid pfn conversion bugs
b61a76f8850d x86/efi: Map RAM into the identity page table for mixed mode
753b11ef8e92 x86/efi: Setup separate EFI page tables in kexec paths

the first patch takes a bit of massaging (mostly because some of it is
already touched by 02ff2769edbc, which keeps the changes from
edc3b9129cec, and so we can drop a good bit when applying).  The other
three apply cleanly.

I'm currently testing that and can send you the state of my tree in a bit.



Have you made any progress ? On my side I am still out of luck since I can not
reproduce the problem.


Perhaps just the patch that Andi posted to the stable list helps out
here?



For reference:

https://www.spinics.net/lists/stable/msg253357.html

That would be the most straightforward and simple fix, so I would prefer
to go with it if it works.

Guenter


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-25 Thread Greg Kroah-Hartman
On Sat, Aug 25, 2018 at 06:52:32AM -0700, Guenter Roeck wrote:
> Hi Roland,
> 
> On 08/24/2018 01:04 PM, Roland Dreier wrote:
> > > Ok, so what patch should be reverted?  I'm seeing other reports of
> > > problems all around this same area, but I can't figure out exactly what
> > > to do.
> > 
> > Are any of those reports public?  If so can you point me at them, I'm
> > curious if the symptoms match up.
> > 
> > I don't think we want to revert anything.  I think you should pull in
> > edc3b9129cec and at least the first three patches that Ben listed:
> > 
> > 21cdb6b56843 x86/mm: Page align the '_end' symbol to avoid pfn conversion 
> > bugs
> > b61a76f8850d x86/efi: Map RAM into the identity page table for mixed mode
> > 753b11ef8e92 x86/efi: Setup separate EFI page tables in kexec paths
> > 
> > the first patch takes a bit of massaging (mostly because some of it is
> > already touched by 02ff2769edbc, which keeps the changes from
> > edc3b9129cec, and so we can drop a good bit when applying).  The other
> > three apply cleanly.
> > 
> > I'm currently testing that and can send you the state of my tree in a bit.
> > 
> 
> Have you made any progress ? On my side I am still out of luck since I can not
> reproduce the problem.

Perhaps just the patch that Andi posted to the stable list helps out
here?

Roland, can you try just that?

thanks,

greg k-h


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-25 Thread Guenter Roeck

Hi Roland,

On 08/24/2018 01:04 PM, Roland Dreier wrote:

Ok, so what patch should be reverted?  I'm seeing other reports of
problems all around this same area, but I can't figure out exactly what
to do.


Are any of those reports public?  If so can you point me at them, I'm
curious if the symptoms match up.

I don't think we want to revert anything.  I think you should pull in
edc3b9129cec and at least the first three patches that Ben listed:

21cdb6b56843 x86/mm: Page align the '_end' symbol to avoid pfn conversion bugs
b61a76f8850d x86/efi: Map RAM into the identity page table for mixed mode
753b11ef8e92 x86/efi: Setup separate EFI page tables in kexec paths

the first patch takes a bit of massaging (mostly because some of it is
already touched by 02ff2769edbc, which keeps the changes from
edc3b9129cec, and so we can drop a good bit when applying).  The other
three apply cleanly.

I'm currently testing that and can send you the state of my tree in a bit.



Have you made any progress ? On my side I am still out of luck since I can not
reproduce the problem.

Thanks,
Guenter


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Guenter Roeck
+Andi Kleen 

On Fri, Aug 24, 2018 at 01:04:09PM -0700, Roland Dreier wrote:
> > Ok, so what patch should be reverted?  I'm seeing other reports of
> > problems all around this same area, but I can't figure out exactly what
> > to do.
> 
> Are any of those reports public?  If so can you point me at them, I'm
> curious if the symptoms match up.
> 
> I don't think we want to revert anything.  I think you should pull in
> edc3b9129cec and at least the first three patches that Ben listed:
> 
> 21cdb6b56843 x86/mm: Page align the '_end' symbol to avoid pfn conversion bugs
> b61a76f8850d x86/efi: Map RAM into the identity page table for mixed mode
> 753b11ef8e92 x86/efi: Setup separate EFI page tables in kexec paths
> 
> the first patch takes a bit of massaging (mostly because some of it is
> already touched by 02ff2769edbc, which keeps the changes from
> edc3b9129cec, and so we can drop a good bit when applying).  The other
> three apply cleanly.
> 
> I'm currently testing that and can send you the state of my tree in a bit.
> 
>  - R.


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Guenter Roeck
On Fri, Aug 24, 2018 at 01:16:18PM -0700, Roland Dreier wrote:
> > Sounds great. I'll hold off with sending my RFT series and wait for your
> > test results. I think we'll also need d367cef0a7f0c6 ("x86/mm/pat: Fix
> > boot crash when 1GB pages are not supported by the CPU").
> 
> Sure, makes sense - I don't have any EFI systems with CPUs old enough
> not to support 1G pages but that looks reasonable.  I'll pull that
> into my tree as well.
> 
kernelci reported a crash on a CPU which doesn't support 1G pages.
See https://kernelci.org/boot/id/5b7d39ea59b514c03796ba9c/

Guenter


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Roland Dreier
> Sounds great. I'll hold off with sending my RFT series and wait for your
> test results. I think we'll also need d367cef0a7f0c6 ("x86/mm/pat: Fix
> boot crash when 1GB pages are not supported by the CPU").

Sure, makes sense - I don't have any EFI systems with CPUs old enough
not to support 1G pages but that looks reasonable.  I'll pull that
into my tree as well.

 - R.


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Guenter Roeck
On Fri, Aug 24, 2018 at 01:04:09PM -0700, Roland Dreier wrote:
> > Ok, so what patch should be reverted?  I'm seeing other reports of
> > problems all around this same area, but I can't figure out exactly what
> > to do.
> 
> Are any of those reports public?  If so can you point me at them, I'm
> curious if the symptoms match up.
> 
> I don't think we want to revert anything.  I think you should pull in
> edc3b9129cec and at least the first three patches that Ben listed:
> 
> 21cdb6b56843 x86/mm: Page align the '_end' symbol to avoid pfn conversion bugs
> b61a76f8850d x86/efi: Map RAM into the identity page table for mixed mode
> 753b11ef8e92 x86/efi: Setup separate EFI page tables in kexec paths
> 
> the first patch takes a bit of massaging (mostly because some of it is
> already touched by 02ff2769edbc, which keeps the changes from
> edc3b9129cec, and so we can drop a good bit when applying).  The other
> three apply cleanly.
> 
> I'm currently testing that and can send you the state of my tree in a bit.
> 

Sounds great. I'll hold off with sending my RFT series and wait for your
test results. I think we'll also need d367cef0a7f0c6 ("x86/mm/pat: Fix
boot crash when 1GB pages are not supported by the CPU").

Thanks,
Guenter


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Guenter Roeck
On Fri, Aug 24, 2018 at 09:17:49PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Aug 24, 2018 at 10:08:28AM -0700, Roland Dreier wrote:
> > > See
> > > .
> > 
> > Thanks!  I'm not using SGI UV and I'm not using kexec, so I guess I
> > sidestepped most of those issues.  Greg, I think we need to unrevert
> > the cpa->pfn change (otherwise the L1TF fix probably gets pretty
> > messy) and I guess pull in the other patches that Ben mentions.
> 
> Ok, so what patch should be reverted?  I'm seeing other reports of
> problems all around this same area, but I can't figure out exactly what
> to do.
> 
> Guenter, any ideas?
> 
I think we'll need to reapply 87e2bd898d3a ("x86/mm/pat: Ensure cpa->pfn only
contains page frame numbers"), and possibly apply d367cef0a7f0 ("x86/mm/pat:
Fix boot crash when 1GB pages are not supported by the CPU"). Both require
conflict resolutions, but they are quite straightforward. I am not sure
about the other EFI patches.

I am going to send the backports as RFT in a minute. Problem is that I don't
have an EFI system at hand and can not test if this fixes the problem
(or maybe introduces a new one), so someone will need to step in and do
those tests.

Guenter


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Roland Dreier
> Ok, so what patch should be reverted?  I'm seeing other reports of
> problems all around this same area, but I can't figure out exactly what
> to do.

Are any of those reports public?  If so can you point me at them, I'm
curious if the symptoms match up.

I don't think we want to revert anything.  I think you should pull in
edc3b9129cec and at least the first three patches that Ben listed:

21cdb6b56843 x86/mm: Page align the '_end' symbol to avoid pfn conversion bugs
b61a76f8850d x86/efi: Map RAM into the identity page table for mixed mode
753b11ef8e92 x86/efi: Setup separate EFI page tables in kexec paths

the first patch takes a bit of massaging (mostly because some of it is
already touched by 02ff2769edbc, which keeps the changes from
edc3b9129cec, and so we can drop a good bit when applying).  The other
three apply cleanly.

I'm currently testing that and can send you the state of my tree in a bit.

 - R.


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Greg Kroah-Hartman
On Fri, Aug 24, 2018 at 10:08:28AM -0700, Roland Dreier wrote:
> > See
> > .
> 
> Thanks!  I'm not using SGI UV and I'm not using kexec, so I guess I
> sidestepped most of those issues.  Greg, I think we need to unrevert
> the cpa->pfn change (otherwise the L1TF fix probably gets pretty
> messy) and I guess pull in the other patches that Ben mentions.

Ok, so what patch should be reverted?  I'm seeing other reports of
problems all around this same area, but I can't figure out exactly what
to do.

Guenter, any ideas?

thanks,

greg k-h


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Roland Dreier
> See
> .

Thanks!  I'm not using SGI UV and I'm not using kexec, so I guess I
sidestepped most of those issues.  Greg, I think we need to unrevert
the cpa->pfn change (otherwise the L1TF fix probably gets pretty
messy) and I guess pull in the other patches that Ben mentions.

 - R.


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Ben Hutchings
On Wed, 2018-08-22 at 17:48 -0700, Roland Dreier wrote:
> On Fri, Dec 15, 2017 at 2:20 AM Greg Kroah-Hartman
> >  wrote:
> > This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is
> > commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.
> > 
> > Turns there was too many other issues with this patch to make it viable
> > for the stable tree.
> 
> This was sort of a long time ago, but does anyone remember why this
> needed to be reverted from 4.4?

See
.

Ben.

> The reason I ask is that without this, commit 02ff2769edbc /
> "x86/mm/pat: Make set_memory_np() L1TF safe" in 4.4.148 is broken.
> That patch has
> 
> -   set_pud(pud, __pud(cpa->pfn | _PAGE_PSE |
> -  massage_pgprot(pud_pgprot)));
> +   set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn,
> +  canon_pgprot(pud_pgprot;
> 
> (and similarly for pmds) but pfn_pud() is operating on page frame
> numbers and __pud(cpa->pfn... in the old code is operating on physical
> addresses.
> 
> This is bad enough that 4.4.148 and all newer 4.4.y crash early in
> boot on some EFI systems that I have.
> 
> For now I am re-applying the "ensure cpa->pfn only contains page frame
> numbers" patch, ported on top of 4.4.151.
> 
>  - R.
> 
-- 
Ben Hutchings, Software Developer Codethink Ltd
https://www.codethink.co.uk/ Dale House, 35 Dale Street
 Manchester, M1 2HF, United Kingdom


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-24 Thread Matt Fleming
On Thu, 23 Aug, at 09:37:28AM, Roland Dreier wrote:
> > > This is bad enough that 4.4.148 and all newer 4.4.y crash early in
> > > boot on some EFI systems that I have.
> >
> > Ugh, not good.
> >
> > > For now I am re-applying the "ensure cpa->pfn only contains page frame
> > > numbers" patch, ported on top of 4.4.151.
> >
> > I can try to add it back and see what blows up, want me to attempt that?
> 
> Not sure what to say... the current state is obviously broken.  If you
> look at what 02ff2769edbc is doing, it's clear that we're now shifting
> cpa->pfn by PAGE_SHIFT where we weren't before, so we're putting bogus
> values in the page table.  And this is enough that my server system
> booting with EFI crashes early in boot efi_enter_virtual_mode() with
> the symptom that NX is improperly set on some pages (booting with
> "noexec=off" fixes things, although obviously I don't want to run that
> way).  FWIW I can confirm that reverting the single patch 02ff2769edbc
> fixes things, as does the cpa->pfn fix I mentioned above.
> 
> It's hard for me to make a call on applying "ensure cpa->pfn only
> contains page frame numbers" without knowing the problems it caused
> before.  The patch looks fine to me and I definitely need it, but
> maybe it exposes some other bug elsewhere?  Maybe Ben or Matt remember
> more above why this was reverted in 4.4.106?  Otherwise I'd say yeah,
> we should re-apply it, since I don't think we want to revert
> 02ff2769edbc.

For the record, I wasn't even aware it had been reverted.


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-23 Thread Roland Dreier
> > This is bad enough that 4.4.148 and all newer 4.4.y crash early in
> > boot on some EFI systems that I have.
>
> Ugh, not good.
>
> > For now I am re-applying the "ensure cpa->pfn only contains page frame
> > numbers" patch, ported on top of 4.4.151.
>
> I can try to add it back and see what blows up, want me to attempt that?

Not sure what to say... the current state is obviously broken.  If you
look at what 02ff2769edbc is doing, it's clear that we're now shifting
cpa->pfn by PAGE_SHIFT where we weren't before, so we're putting bogus
values in the page table.  And this is enough that my server system
booting with EFI crashes early in boot efi_enter_virtual_mode() with
the symptom that NX is improperly set on some pages (booting with
"noexec=off" fixes things, although obviously I don't want to run that
way).  FWIW I can confirm that reverting the single patch 02ff2769edbc
fixes things, as does the cpa->pfn fix I mentioned above.

It's hard for me to make a call on applying "ensure cpa->pfn only
contains page frame numbers" without knowing the problems it caused
before.  The patch looks fine to me and I definitely need it, but
maybe it exposes some other bug elsewhere?  Maybe Ben or Matt remember
more above why this was reverted in 4.4.106?  Otherwise I'd say yeah,
we should re-apply it, since I don't think we want to revert
02ff2769edbc.

 - R.


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-22 Thread Greg Kroah-Hartman
On Wed, Aug 22, 2018 at 05:48:32PM -0700, Roland Dreier wrote:
> On Fri, Dec 15, 2017 at 2:20 AM Greg Kroah-Hartman
>  wrote:
> > This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is
> > commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.
> >
> > Turns there was too many other issues with this patch to make it viable
> > for the stable tree.
> 
> This was sort of a long time ago, but does anyone remember why this
> needed to be reverted from 4.4?

I tried to dig through my old emails, but could not find anything,
sorry.

> The reason I ask is that without this, commit 02ff2769edbc /
> "x86/mm/pat: Make set_memory_np() L1TF safe" in 4.4.148 is broken.
> That patch has
> 
> -   set_pud(pud, __pud(cpa->pfn | _PAGE_PSE |
> -  massage_pgprot(pud_pgprot)));
> +   set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn,
> +  canon_pgprot(pud_pgprot;
> 
> (and similarly for pmds) but pfn_pud() is operating on page frame
> numbers and __pud(cpa->pfn... in the old code is operating on physical
> addresses.
> 
> This is bad enough that 4.4.148 and all newer 4.4.y crash early in
> boot on some EFI systems that I have.

Ugh, not good.

> For now I am re-applying the "ensure cpa->pfn only contains page frame
> numbers" patch, ported on top of 4.4.151.

I can try to add it back and see what blows up, want me to attempt that?
:)

thanks,

greg k-h


Re: [PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2018-08-22 Thread Roland Dreier
On Fri, Dec 15, 2017 at 2:20 AM Greg Kroah-Hartman
 wrote:
> This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is
> commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.
>
> Turns there was too many other issues with this patch to make it viable
> for the stable tree.

This was sort of a long time ago, but does anyone remember why this
needed to be reverted from 4.4?

The reason I ask is that without this, commit 02ff2769edbc /
"x86/mm/pat: Make set_memory_np() L1TF safe" in 4.4.148 is broken.
That patch has

-   set_pud(pud, __pud(cpa->pfn | _PAGE_PSE |
-  massage_pgprot(pud_pgprot)));
+   set_pud(pud, pud_mkhuge(pfn_pud(cpa->pfn,
+  canon_pgprot(pud_pgprot;

(and similarly for pmds) but pfn_pud() is operating on page frame
numbers and __pud(cpa->pfn... in the old code is operating on physical
addresses.

This is bad enough that 4.4.148 and all newer 4.4.y crash early in
boot on some EFI systems that I have.

For now I am re-applying the "ensure cpa->pfn only contains page frame
numbers" patch, ported on top of 4.4.151.

 - R.


[PATCH 4.4 103/105] Revert "x86/mm/pat: Ensure cpa->pfn only contains page frame numbers"

2017-12-15 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Greg Kroah-Hartman 

This reverts commit 87e2bd898d3a79a8c609f183180adac47879a2a4 which is
commit edc3b9129cecd0f0857112136f5b8b1bc1d45918 upstream.

Turns there was too many other issues with this patch to make it viable
for the stable tree.

Reported-by: Ben Hutchings 
Cc: Matt Fleming 
Cc: Borislav Petkov 
Cc: Andrew Morton 
Cc: Andy Lutomirski 
Cc: Andy Lutomirski 
Cc: Ard Biesheuvel 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Dave Jones 
Cc: Denys Vlasenko 
Cc: H. Peter Anvin 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Sai Praneeth Prakhya 
Cc: Stephen Smalley 
Cc: Thomas Gleixner 
Cc: Toshi Kani 
Cc: linux-efi@vger.kernel.org
Cc: Ingo Molnar 
Cc: "Ghannam, Yazen" 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/x86/mm/pageattr.c |   17 +++--
 arch/x86/platform/efi/efi_64.c |   16 ++--
 2 files changed, 17 insertions(+), 16 deletions(-)

--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -911,10 +911,15 @@ static void populate_pte(struct cpa_data
pte = pte_offset_kernel(pmd, start);
 
while (num_pages-- && start < end) {
-   set_pte(pte, pfn_pte(cpa->pfn, pgprot));
+
+   /* deal with the NX bit */
+   if (!(pgprot_val(pgprot) & _PAGE_NX))
+   cpa->pfn &= ~_PAGE_NX;
+
+   set_pte(pte, pfn_pte(cpa->pfn >> PAGE_SHIFT, pgprot));
 
start+= PAGE_SIZE;
-   cpa->pfn++;
+   cpa->pfn += PAGE_SIZE;
pte++;
}
 }
@@ -970,11 +975,11 @@ static int populate_pmd(struct cpa_data
 
pmd = pmd_offset(pud, start);
 
-   set_pmd(pmd, __pmd(cpa->pfn << PAGE_SHIFT | _PAGE_PSE |
+   set_pmd(pmd, __pmd(cpa->pfn | _PAGE_PSE |
   massage_pgprot(pmd_pgprot)));
 
start += PMD_SIZE;
-   cpa->pfn  += PMD_SIZE >> PAGE_SHIFT;
+   cpa->pfn  += PMD_SIZE;
cur_pages += PMD_SIZE >> PAGE_SHIFT;
}
 
@@ -1043,11 +1048,11 @@ static int populate_pud(struct cpa_data
 * Map everything starting from the Gb boundary, possibly with 1G pages
 */
while (end - start >= PUD_SIZE) {
-   set_pud(pud, __pud(cpa->pfn << PAGE_SHIFT | _PAGE_PSE |
+   set_pud(pud, __pud(cpa->pfn | _PAGE_PSE |
   massage_pgprot(pud_pgprot)));
 
start += PUD_SIZE;
-   cpa->pfn  += PUD_SIZE >> PAGE_SHIFT;
+   cpa->pfn  += PUD_SIZE;
cur_pages += PUD_SIZE >> PAGE_SHIFT;
pud++;
}
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -143,7 +143,7 @@ void efi_sync_low_kernel_mappings(void)
 
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 {
-   unsigned long pfn, text;
+   unsigned long text;
struct page *page;
unsigned npages;
pgd_t *pgd;
@@ -160,8 +160,7 @@ int __init efi_setup_page_tables(unsigne
 * and ident-map those pages containing the map before calling
 * phys_efi_set_virtual_address_map().
 */
-   pfn = pa_memmap >> PAGE_SHIFT;
-   if (kernel_map_pages_in_pgd(pgd, pfn, pa_memmap, num_pages, _PAGE_NX)) {
+   if (kernel_map_pages_in_pgd(pgd, pa_memmap, pa_memmap, num_pages, 
_PAGE_NX)) {
pr_err("Error ident-mapping new memmap (0x%lx)!\n", pa_memmap);
return 1;
}
@@ -186,9 +185,8 @@ int __init efi_setup_page_tables(unsigne
 
npages = (_end - _text) >> PAGE_SHIFT;
text = __pa(_text);
-   pfn = text >> PAGE_SHIFT;
 
-   if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, 0)) {
+   if (kernel_map_pages_in_pgd(pgd, text >> PAGE_SHIFT, text, npages, 0)) {
pr_err("Failed to map kernel text 1:1\n");
return 1;
}
@@ -206,14 +204,12 @@ void __init efi_cleanup_page_tables(unsi
 static void __init __map_region(efi_memory_desc_t *md, u64 va)
 {
pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd);
-   unsigned long flags = 0;
-   unsigned long pfn;
+   unsigned long pf = 0;
 
if (!(md->attribute & EFI_MEMORY_WB))
-   flags |= _PAGE_PCD;
+   pf |= _PAGE_PCD;
 
-   pfn = md->phys_addr >> PAGE_SHIFT;
-   if (kernel_map_pages_in_pgd(pgd, pfn, va, md->num_pages, flags))
+   if (kernel_map_pages_in_pgd(pgd, md->phys_addr, va, md->num_pages, pf))
pr_warn("Error mapping PA 0x%llx -> VA 0x%llx!\n",
   md->phys_addr, va);
 }


--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html