2015-11-09 18:07:24

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [PATCH v4 RESEND 4/11] x86/asm: Fix pud/pmd interfaces to handle large PAT bit

On 09/17/2015 02:24 PM, Toshi Kani wrote:
> Now that we have pud/pmd mask interfaces, which handle pfn & flags
> mask properly for the large PAT bit.
>
> Fix pud/pmd pfn & flags interfaces by replacing PTE_PFN_MASK and
> PTE_FLAGS_MASK with the pud/pmd mask interfaces.
>
> Suggested-by: Juergen Gross <[email protected]>
> Signed-off-by: Toshi Kani <[email protected]>
> Cc: Juergen Gross <[email protected]>
> Cc: Konrad Wilk <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: H. Peter Anvin <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> ---
> arch/x86/include/asm/pgtable.h | 14 ++++++++------
> arch/x86/include/asm/pgtable_types.h | 4 ++--
> 2 files changed, 10 insertions(+), 8 deletions(-)
>


Looks like this commit is causing this splat for 32-bit kernels. I am
attaching my config file, just in case.

-boris


[ 8.905943] page:eea45000 count:0 mapcount:-128 mapping: (null) index:0x0
[ 8.913041] flags: 0x40000000()
[ 8.916293] page dumped because: VM_BUG_ON_PAGE(page_mapcount(page) < 0)
[ 8.923204] ------------[ cut here ]------------
[ 8.927958] kernel BUG at /home/build/linux-boris/mm/huge_memory.c:1485!
[ 8.934860] invalid opcode: 0000 [#1] SMP
[ 8.939094] Modules linked in: ahci libahci ata_generic skge r8169 firewire_ohci mii libata qla2xxx(+) scsi_transport_fc scsi_mod radeon tpm_infineon ttm backlight wmi acpi_cpufreq tpm_tis
[ 8.956548] CPU: 2 PID: 1758 Comm: modprobe Not tainted 4.3.0upstream-09269-gce5c2d2 #1
[ 8.964792] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS 080014 07/18/2008
[ 8.975991] task: ed84e600 ti: f6458000 task.ti: f6458000
[ 8.981552] EIP: 0060:[<c11bde80>] EFLAGS: 00010246 CPU: 2
[ 8.987203] EIP is at zap_huge_pmd+0x240/0x260
[ 8.991778] EAX: 00000000 EBX: f6459eb0 ECX: 00000292 EDX: 00000292
[ 8.998234] ESI: f6634d98 EDI: eea45000 EBP: f6459dc8 ESP: f6459d98
[ 8.998355] ata1: SATA link down (SStatus 0 SControl 300)
[ 9.000330] ata2: SATA link down (SStatus 0 SControl 300)
[ 9.015804] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[ 9.021364] CR0: 8005003b CR2: b75b21a0 CR3: 3655b880 CR4: 000006f0
[ 9.027818] Stack:
[ 9.029885] 00000080 00000000 80000002 ee795000 80000002 ffe00000 00000000 ffffff7f
[ 9.037930] eee6169c f70c5e40 b6600000 f6634d98 f6459e78 c119a7c8 b6600000 80000002
[ 9.045972] 00000003 c18992f4 c18992f0 00000003 00000286 f6459e0c c10db5f0 00000000
[ 9.054018] Call Trace:
[ 9.056537] [<c119a7c8>] unmap_single_vma+0x6e8/0x7c0
[ 9.061829] [<c10db5f0>] ? __wake_up+0x40/0x50
[ 9.063587] firewire_core 0000:08:05.0: created device fw0: GUID 000000001a1a2f03, S800
[ 9.074736] [<c119a8e7>] unmap_vmas+0x47/0x80
[ 9.079312] [<c11a0c44>] unmap_region+0x74/0xc0
[ 9.084067] [<c11a2d50>] do_munmap+0x1b0/0x280
[ 9.088732] [<c11a2e58>] vm_munmap+0x38/0x50
[ 9.093218] [<c11a2e88>] SyS_munmap+0x18/0x20
[ 9.097795] [<c1003861>] do_fast_syscall_32+0xa1/0x270
[ 9.103176] [<c1095400>] ? __do_page_fault+0x430/0x430
[ 9.108559] [<c169de51>] sysenter_past_esp+0x36/0x55
[ 9.113761] Code: 00 e9 05 fe ff ff 90 8d 74 26 00 0f 0b eb fe ba 4c e1 7a c1 89 f8 e8 f0 91 fd ff 0f 0b eb fe ba 6c e1 7a c1 89 f8 e8 e0 91 fd ff <0f> 0b eb fe ba c4 e1 7a c1 89 f8 e8 d0 91 fd ff 0f 0b eb fe 8d
[ 9.133727] EIP: [<c11bde80>] zap_huge_pmd+0x240/0x260 SS:ESP 0068:f6459d98
[ 9.140929] ---[ end trace cba8fb1fc2e2e78a ]---
[ 9.143363] scsi host5: qla2xxx
[ 9.148416] qla2xxx [0000:04:07.1]-00fb:5: QLogic QLE2362 - PCI-Express to 2Gb FC, Dual Channel.
[ 9.148420] qla2xxx [0000:04:07.1]-00fc:5: ISP2322: PCI-X (133 MHz) @ 0000:04:07.1 hdma+ host#=5 fw=3.03.28 IPX.
[ 9.152282] ata4: softreset failed (device not ready)
[ 9.152284] ata4: applying PMP SRST workaround and retrying
[ 9.153282] ata3: softreset failed (device not ready)
[ 9.153284] ata3: applying PMP SRST workaround and retrying
[ 9.190361] Kernel panic - not syncing: Fatal exception
[ 9.195764] Kernel Offset: disabled
[ 9.199354] ---[ end Kernel panic - not syncing: Fatal exception



Attachments:
32b.config (97.42 kB)

2015-11-09 19:20:50

by Kani, Toshimitsu

[permalink] [raw]
Subject: Re: [PATCH v4 RESEND 4/11] x86/asm: Fix pud/pmd interfaces to handle large PAT bit

On Mon, 2015-11-09 at 13:06 -0500, Boris Ostrovsky wrote:
> On 09/17/2015 02:24 PM, Toshi Kani wrote:
> > Now that we have pud/pmd mask interfaces, which handle pfn & flags
> > mask properly for the large PAT bit.
> >
> > Fix pud/pmd pfn & flags interfaces by replacing PTE_PFN_MASK and
> > PTE_FLAGS_MASK with the pud/pmd mask interfaces.
> >
> > Suggested-by: Juergen Gross <[email protected]>
> > Signed-off-by: Toshi Kani <[email protected]>
> > Cc: Juergen Gross <[email protected]>
> > Cc: Konrad Wilk <[email protected]>
> > Cc: Thomas Gleixner <[email protected]>
> > Cc: H. Peter Anvin <[email protected]>
> > Cc: Ingo Molnar <[email protected]>
> > Cc: Borislav Petkov <[email protected]>
> > ---
> > arch/x86/include/asm/pgtable.h | 14 ++++++++------
> > arch/x86/include/asm/pgtable_types.h | 4 ++--
> > 2 files changed, 10 insertions(+), 8 deletions(-)
> >
>
>
> Looks like this commit is causing this splat for 32-bit kernels. I am
> attaching my config file, just in case.

Thanks for the report! I'd like to reproduce the issue since I am not sure how
this change caused it...

I tried to build a kernel with the attached config file, and got the following
error. Not sure what I am missing.

----
$ make -j24 ARCH=i386
:
LD drivers/built-in.o
LINK vmlinux
./.config: line 44: $'\r': command not found
Makefile:929: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 127
----

Do you have steps to reproduce the issue? Or do you see it during boot-time?

Thanks,
-Toshi

2015-11-09 19:40:23

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [PATCH v4 RESEND 4/11] x86/asm: Fix pud/pmd interfaces to handle large PAT bit

On 11/09/2015 02:16 PM, Toshi Kani wrote:
> On Mon, 2015-11-09 at 13:06 -0500, Boris Ostrovsky wrote:
>> On 09/17/2015 02:24 PM, Toshi Kani wrote:
>>> Now that we have pud/pmd mask interfaces, which handle pfn & flags
>>> mask properly for the large PAT bit.
>>>
>>> Fix pud/pmd pfn & flags interfaces by replacing PTE_PFN_MASK and
>>> PTE_FLAGS_MASK with the pud/pmd mask interfaces.
>>>
>>> Suggested-by: Juergen Gross <[email protected]>
>>> Signed-off-by: Toshi Kani <[email protected]>
>>> Cc: Juergen Gross <[email protected]>
>>> Cc: Konrad Wilk <[email protected]>
>>> Cc: Thomas Gleixner <[email protected]>
>>> Cc: H. Peter Anvin <[email protected]>
>>> Cc: Ingo Molnar <[email protected]>
>>> Cc: Borislav Petkov <[email protected]>
>>> ---
>>> arch/x86/include/asm/pgtable.h | 14 ++++++++------
>>> arch/x86/include/asm/pgtable_types.h | 4 ++--
>>> 2 files changed, 10 insertions(+), 8 deletions(-)
>>>
>>
>> Looks like this commit is causing this splat for 32-bit kernels. I am
>> attaching my config file, just in case.
> Thanks for the report! I'd like to reproduce the issue since I am not sure how
> this change caused it...
>
> I tried to build a kernel with the attached config file, and got the following
> error. Not sure what I am missing.
>
> ----
> $ make -j24 ARCH=i386
> :
> LD drivers/built-in.o
> LINK vmlinux
> ./.config: line 44: $'\r': command not found

I wonder whether my email client added ^Ms to the file that I send. It
shouldn't have.

> Makefile:929: recipe for target 'vmlinux' failed
> make: *** [vmlinux] Error 127
> ----
>
> Do you have steps to reproduce the issue? Or do you see it during boot-time?

This always happens just after system has booted, it may still be going
over init scripts. I am booting with ramdisk, don't know whether it has
anything to do with this problem.

FWIW, it looks like pmd_pfn_mask() inline is causing this. Reverting it
alone makes this crash go away.


-boris

2015-11-09 20:10:59

by Kirill A. Shutemov

[permalink] [raw]
Subject: Re: [PATCH v4 RESEND 4/11] x86/asm: Fix pud/pmd interfaces to handle large PAT bit

On Mon, Nov 09, 2015 at 12:16:41PM -0700, Toshi Kani wrote:
> On Mon, 2015-11-09 at 13:06 -0500, Boris Ostrovsky wrote:
> > On 09/17/2015 02:24 PM, Toshi Kani wrote:
> > > Now that we have pud/pmd mask interfaces, which handle pfn & flags
> > > mask properly for the large PAT bit.
> > >
> > > Fix pud/pmd pfn & flags interfaces by replacing PTE_PFN_MASK and
> > > PTE_FLAGS_MASK with the pud/pmd mask interfaces.
> > >
> > > Suggested-by: Juergen Gross <[email protected]>
> > > Signed-off-by: Toshi Kani <[email protected]>
> > > Cc: Juergen Gross <[email protected]>
> > > Cc: Konrad Wilk <[email protected]>
> > > Cc: Thomas Gleixner <[email protected]>
> > > Cc: H. Peter Anvin <[email protected]>
> > > Cc: Ingo Molnar <[email protected]>
> > > Cc: Borislav Petkov <[email protected]>
> > > ---
> > > arch/x86/include/asm/pgtable.h | 14 ++++++++------
> > > arch/x86/include/asm/pgtable_types.h | 4 ++--
> > > 2 files changed, 10 insertions(+), 8 deletions(-)
> > >
> >
> >
> > Looks like this commit is causing this splat for 32-bit kernels. I am
> > attaching my config file, just in case.
>
> Thanks for the report! I'd like to reproduce the issue since I am not sure how
> this change caused it...
>
> I tried to build a kernel with the attached config file, and got the following
> error. Not sure what I am missing.

The problem is that PMD_PAGE_MASK as well as PUD_PAGE_MASK are 'unsigned
long', not 'unsigned long long'. So on 32-bit with PAE enabled your
pmd_pfn_mask()/pud_pfn_mask() will truncate bits 32..43 of pmd/pudval and
you'll never get proper page frame for pages above 4G.

--
Kirill A. Shutemov

2015-11-09 20:47:14

by Kirill A. Shutemov

[permalink] [raw]
Subject: Re: [PATCH v4 RESEND 4/11] x86/asm: Fix pud/pmd interfaces to handle large PAT bit

On Mon, Nov 09, 2015 at 02:39:31PM -0500, Boris Ostrovsky wrote:
> On 11/09/2015 02:16 PM, Toshi Kani wrote:
> >On Mon, 2015-11-09 at 13:06 -0500, Boris Ostrovsky wrote:
> >>On 09/17/2015 02:24 PM, Toshi Kani wrote:
> >>>Now that we have pud/pmd mask interfaces, which handle pfn & flags
> >>>mask properly for the large PAT bit.
> >>>
> >>>Fix pud/pmd pfn & flags interfaces by replacing PTE_PFN_MASK and
> >>>PTE_FLAGS_MASK with the pud/pmd mask interfaces.
> >>>
> >>>Suggested-by: Juergen Gross <[email protected]>
> >>>Signed-off-by: Toshi Kani <[email protected]>
> >>>Cc: Juergen Gross <[email protected]>
> >>>Cc: Konrad Wilk <[email protected]>
> >>>Cc: Thomas Gleixner <[email protected]>
> >>>Cc: H. Peter Anvin <[email protected]>
> >>>Cc: Ingo Molnar <[email protected]>
> >>>Cc: Borislav Petkov <[email protected]>
> >>>---
> >>> arch/x86/include/asm/pgtable.h | 14 ++++++++------
> >>> arch/x86/include/asm/pgtable_types.h | 4 ++--
> >>> 2 files changed, 10 insertions(+), 8 deletions(-)
> >>>
> >>
> >>Looks like this commit is causing this splat for 32-bit kernels. I am
> >>attaching my config file, just in case.
> >Thanks for the report! I'd like to reproduce the issue since I am not sure how
> >this change caused it...
> >
> >I tried to build a kernel with the attached config file, and got the following
> >error. Not sure what I am missing.
> >
> >----
> >$ make -j24 ARCH=i386
> > :
> > LD drivers/built-in.o
> > LINK vmlinux
> >./.config: line 44: $'\r': command not found
>
> I wonder whether my email client added ^Ms to the file that I send. It
> shouldn't have.
>
> >Makefile:929: recipe for target 'vmlinux' failed
> >make: *** [vmlinux] Error 127
> >----
> >
> >Do you have steps to reproduce the issue? Or do you see it during boot-time?
>
> This always happens just after system has booted, it may still be going over
> init scripts. I am booting with ramdisk, don't know whether it has anything
> to do with this problem.
>
> FWIW, it looks like pmd_pfn_mask() inline is causing this. Reverting it
> alone makes this crash go away.

Could you check the patch below?

diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index dd5b0aa9dd2f..c1e797266ce9 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -279,17 +279,14 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
static inline pudval_t pud_pfn_mask(pud_t pud)
{
if (native_pud_val(pud) & _PAGE_PSE)
- return PUD_PAGE_MASK & PHYSICAL_PAGE_MASK;
+ return ~((1ULL << PUD_SHIFT) - 1) & PHYSICAL_PAGE_MASK;
else
return PTE_PFN_MASK;
}

static inline pudval_t pud_flags_mask(pud_t pud)
{
- if (native_pud_val(pud) & _PAGE_PSE)
- return ~(PUD_PAGE_MASK & (pudval_t)PHYSICAL_PAGE_MASK);
- else
- return ~PTE_PFN_MASK;
+ return ~pud_pfn_mask(pud);
}

static inline pudval_t pud_flags(pud_t pud)
@@ -300,17 +297,14 @@ static inline pudval_t pud_flags(pud_t pud)
static inline pmdval_t pmd_pfn_mask(pmd_t pmd)
{
if (native_pmd_val(pmd) & _PAGE_PSE)
- return PMD_PAGE_MASK & PHYSICAL_PAGE_MASK;
+ return ~((1ULL << PMD_SHIFT) - 1) & PHYSICAL_PAGE_MASK;
else
return PTE_PFN_MASK;
}

static inline pmdval_t pmd_flags_mask(pmd_t pmd)
{
- if (native_pmd_val(pmd) & _PAGE_PSE)
- return ~(PMD_PAGE_MASK & (pmdval_t)PHYSICAL_PAGE_MASK);
- else
- return ~PTE_PFN_MASK;
+ return ~pmd_pfn_mask(pmd);
}

static inline pmdval_t pmd_flags(pmd_t pmd)
--
Kirill A. Shutemov

2015-11-09 21:14:38

by Kani, Toshimitsu

[permalink] [raw]
Subject: Re: [PATCH v4 RESEND 4/11] x86/asm: Fix pud/pmd interfaces to handle large PAT bit

On Mon, 2015-11-09 at 22:10 +0200, Kirill A. Shutemov wrote:
> On Mon, Nov 09, 2015 at 12:16:41PM -0700, Toshi Kani wrote:
> > On Mon, 2015-11-09 at 13:06 -0500, Boris Ostrovsky wrote:
> > > On 09/17/2015 02:24 PM, Toshi Kani wrote:
> > > > Now that we have pud/pmd mask interfaces, which handle pfn & flags
> > > > mask properly for the large PAT bit.
> > > >
> > > > Fix pud/pmd pfn & flags interfaces by replacing PTE_PFN_MASK and
> > > > PTE_FLAGS_MASK with the pud/pmd mask interfaces.
> > > >
> > > > Suggested-by: Juergen Gross <[email protected]>
> > > > Signed-off-by: Toshi Kani <[email protected]>
> > > > Cc: Juergen Gross <[email protected]>
> > > > Cc: Konrad Wilk <[email protected]>
> > > > Cc: Thomas Gleixner <[email protected]>
> > > > Cc: H. Peter Anvin <[email protected]>
> > > > Cc: Ingo Molnar <[email protected]>
> > > > Cc: Borislav Petkov <[email protected]>
> > > > ---
> > > > arch/x86/include/asm/pgtable.h | 14 ++++++++------
> > > > arch/x86/include/asm/pgtable_types.h | 4 ++--
> > > > 2 files changed, 10 insertions(+), 8 deletions(-)
> > > >
> > >
> > >
> > > Looks like this commit is causing this splat for 32-bit kernels. I am
> > > attaching my config file, just in case.
> >
> > Thanks for the report! I'd like to reproduce the issue since I am not sure
> > how this change caused it...
> >
> > I tried to build a kernel with the attached config file, and got the
> > following error. Not sure what I am missing.
>
> The problem is that PMD_PAGE_MASK as well as PUD_PAGE_MASK are 'unsigned
> long', not 'unsigned long long'. So on 32-bit with PAE enabled your
> pmd_pfn_mask()/pud_pfn_mask() will truncate bits 32..43 of pmd/pudval and
> you'll never get proper page frame for pages above 4G.

Thanks Kirill! Yes, this explains the issue. Since I did not change these
MASKs, and I tested 32-bit kernels on a small system, I was not able to catch
this issue...
-Toshi

2015-11-09 22:37:39

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [PATCH v4 RESEND 4/11] x86/asm: Fix pud/pmd interfaces to handle large PAT bit

On 11/09/2015 03:47 PM, Kirill A. Shutemov wrote:
> On Mon, Nov 09, 2015 at 02:39:31PM -0500, Boris Ostrovsky wrote:
>> On 11/09/2015 02:16 PM, Toshi Kani wrote:
>>> On Mon, 2015-11-09 at 13:06 -0500, Boris Ostrovsky wrote:
>>>> On 09/17/2015 02:24 PM, Toshi Kani wrote:
>>>>> Now that we have pud/pmd mask interfaces, which handle pfn & flags
>>>>> mask properly for the large PAT bit.
>>>>>
>>>>> Fix pud/pmd pfn & flags interfaces by replacing PTE_PFN_MASK and
>>>>> PTE_FLAGS_MASK with the pud/pmd mask interfaces.
>>>>>
>>>>> Suggested-by: Juergen Gross <[email protected]>
>>>>> Signed-off-by: Toshi Kani <[email protected]>
>>>>> Cc: Juergen Gross <[email protected]>
>>>>> Cc: Konrad Wilk <[email protected]>
>>>>> Cc: Thomas Gleixner <[email protected]>
>>>>> Cc: H. Peter Anvin <[email protected]>
>>>>> Cc: Ingo Molnar <[email protected]>
>>>>> Cc: Borislav Petkov <[email protected]>
>>>>> ---
>>>>> arch/x86/include/asm/pgtable.h | 14 ++++++++------
>>>>> arch/x86/include/asm/pgtable_types.h | 4 ++--
>>>>> 2 files changed, 10 insertions(+), 8 deletions(-)
>>>>>
>>>> Looks like this commit is causing this splat for 32-bit kernels. I am
>>>> attaching my config file, just in case.
>>> Thanks for the report! I'd like to reproduce the issue since I am not sure how
>>> this change caused it...
>>>
>>> I tried to build a kernel with the attached config file, and got the following
>>> error. Not sure what I am missing.
>>>
>>> ----
>>> $ make -j24 ARCH=i386
>>> :
>>> LD drivers/built-in.o
>>> LINK vmlinux
>>> ./.config: line 44: $'\r': command not found
>> I wonder whether my email client added ^Ms to the file that I send. It
>> shouldn't have.
>>
>>> Makefile:929: recipe for target 'vmlinux' failed
>>> make: *** [vmlinux] Error 127
>>> ----
>>>
>>> Do you have steps to reproduce the issue? Or do you see it during boot-time?
>> This always happens just after system has booted, it may still be going over
>> init scripts. I am booting with ramdisk, don't know whether it has anything
>> to do with this problem.
>>
>> FWIW, it looks like pmd_pfn_mask() inline is causing this. Reverting it
>> alone makes this crash go away.
> Could you check the patch below?


I does fix the problem on baremetal, thanks. My 32-bit Xen guests still
fail which I thought was the same issue but now that I looked at it more
carefully it has different signature.

-boris


>
> diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
> index dd5b0aa9dd2f..c1e797266ce9 100644
> --- a/arch/x86/include/asm/pgtable_types.h
> +++ b/arch/x86/include/asm/pgtable_types.h
> @@ -279,17 +279,14 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
> static inline pudval_t pud_pfn_mask(pud_t pud)
> {
> if (native_pud_val(pud) & _PAGE_PSE)
> - return PUD_PAGE_MASK & PHYSICAL_PAGE_MASK;
> + return ~((1ULL << PUD_SHIFT) - 1) & PHYSICAL_PAGE_MASK;
> else
> return PTE_PFN_MASK;
> }
>
> static inline pudval_t pud_flags_mask(pud_t pud)
> {
> - if (native_pud_val(pud) & _PAGE_PSE)
> - return ~(PUD_PAGE_MASK & (pudval_t)PHYSICAL_PAGE_MASK);
> - else
> - return ~PTE_PFN_MASK;
> + return ~pud_pfn_mask(pud);
> }
>
> static inline pudval_t pud_flags(pud_t pud)
> @@ -300,17 +297,14 @@ static inline pudval_t pud_flags(pud_t pud)
> static inline pmdval_t pmd_pfn_mask(pmd_t pmd)
> {
> if (native_pmd_val(pmd) & _PAGE_PSE)
> - return PMD_PAGE_MASK & PHYSICAL_PAGE_MASK;
> + return ~((1ULL << PMD_SHIFT) - 1) & PHYSICAL_PAGE_MASK;
> else
> return PTE_PFN_MASK;
> }
>
> static inline pmdval_t pmd_flags_mask(pmd_t pmd)
> {
> - if (native_pmd_val(pmd) & _PAGE_PSE)
> - return ~(PMD_PAGE_MASK & (pmdval_t)PHYSICAL_PAGE_MASK);
> - else
> - return ~PTE_PFN_MASK;
> + return ~pmd_pfn_mask(pmd);
> }
>
> static inline pmdval_t pmd_flags(pmd_t pmd)

2015-11-09 23:23:04

by Kani, Toshimitsu

[permalink] [raw]
Subject: Re: [PATCH v4 RESEND 4/11] x86/asm: Fix pud/pmd interfaces to handle large PAT bit

On Mon, 2015-11-09 at 17:36 -0500, Boris Ostrovsky wrote:
> On 11/09/2015 03:47 PM, Kirill A. Shutemov wrote:
> > On Mon, Nov 09, 2015 at 02:39:31PM -0500, Boris Ostrovsky wrote:
> > > On 11/09/2015 02:16 PM, Toshi Kani wrote:
> > > > On Mon, 2015-11-09 at 13:06 -0500, Boris Ostrovsky wrote:
> > > > > On 09/17/2015 02:24 PM, Toshi Kani wrote:
> > > > > > Now that we have pud/pmd mask interfaces, which handle pfn & flags
> > > > > > mask properly for the large PAT bit.
> > > > > >
> > > > > > Fix pud/pmd pfn & flags interfaces by replacing PTE_PFN_MASK and
> > > > > > PTE_FLAGS_MASK with the pud/pmd mask interfaces.
> > > > > >
> > > > > > Suggested-by: Juergen Gross <[email protected]>
> > > > > > Signed-off-by: Toshi Kani <[email protected]>
> > > > > > Cc: Juergen Gross <[email protected]>
> > > > > > Cc: Konrad Wilk <[email protected]>
> > > > > > Cc: Thomas Gleixner <[email protected]>
> > > > > > Cc: H. Peter Anvin <[email protected]>
> > > > > > Cc: Ingo Molnar <[email protected]>
> > > > > > Cc: Borislav Petkov <[email protected]>
> > > > > > ---
> > > > > > arch/x86/include/asm/pgtable.h | 14 ++++++++------
> > > > > > arch/x86/include/asm/pgtable_types.h | 4 ++--
> > > > > > 2 files changed, 10 insertions(+), 8 deletions(-)
> > > > > >
> > > > > Looks like this commit is causing this splat for 32-bit kernels. I am
> > > > > attaching my config file, just in case.
> > > > Thanks for the report! I'd like to reproduce the issue since I am not
> > > > sure how
> > > > this change caused it...
> > > >
> > > > I tried to build a kernel with the attached config file, and got the
> > > > following
> > > > error. Not sure what I am missing.
> > > >
> > > > ----
> > > > $ make -j24 ARCH=i386
> > > > :
> > > > LD drivers/built-in.o
> > > > LINK vmlinux
> > > > ./.config: line 44: $'\r': command not found
> > > I wonder whether my email client added ^Ms to the file that I send. It
> > > shouldn't have.
> > >
> > > > Makefile:929: recipe for target 'vmlinux' failed
> > > > make: *** [vmlinux] Error 127
> > > > ----
> > > >
> > > > Do you have steps to reproduce the issue? Or do you see it during boot
> > > > -time?
> > > This always happens just after system has booted, it may still be going
> > > over
> > > init scripts. I am booting with ramdisk, don't know whether it has
> > > anything
> > > to do with this problem.
> > >
> > > FWIW, it looks like pmd_pfn_mask() inline is causing this. Reverting it
> > > alone makes this crash go away.
> > Could you check the patch below?
>
>
> I does fix the problem on baremetal, thanks. My 32-bit Xen guests still
> fail which I thought was the same issue but now that I looked at it more
> carefully it has different signature.

I do not think Xen is hitting this, but I think page_level_mask() has the same
issue for a long time. I will set up 32-bit env on a system with >4GB memory to
verify this.

Thanks,
-Toshi

2015-11-10 00:44:42

by Kani, Toshimitsu

[permalink] [raw]
Subject: Re: [PATCH v4 RESEND 4/11] x86/asm: Fix pud/pmd interfaces to handle large PAT bit

On Mon, 2015-11-09 at 16:18 -0700, Toshi Kani wrote:
> On Mon, 2015-11-09 at 17:36 -0500, Boris Ostrovsky wrote:
> > On 11/09/2015 03:47 PM, Kirill A. Shutemov wrote:
> > > On Mon, Nov 09, 2015 at 02:39:31PM -0500, Boris Ostrovsky wrote:
> > > > On 11/09/2015 02:16 PM, Toshi Kani wrote:
:
> > > >
> > > > FWIW, it looks like pmd_pfn_mask() inline is causing this. Reverting it
> > > > alone makes this crash go away.
> > > Could you check the patch below?
> >
> >
> > I does fix the problem on baremetal, thanks. My 32-bit Xen guests still
> > fail which I thought was the same issue but now that I looked at it more
> > carefully it has different signature.
>
> I do not think Xen is hitting this, but I think page_level_mask() has the same
> issue for a long time. I will set up 32-bit env on a system with >4GB memory
> to verify this.

As Kirill explained me in his code review comment for *PAGE_MASK, page_level_mas
k() is fine as it is used for virtual addresses.

-Toshi