linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: make set_pmd_at() paravirt aware
@ 2019-02-10  7:40 Juergen Gross
  2019-02-10  7:52 ` [tip:x86/urgent] x86/mm: Make " tip-bot for Juergen Gross
  2019-02-10 18:14 ` [PATCH] x86: make " Linus Torvalds
  0 siblings, 2 replies; 4+ messages in thread
From: Juergen Gross @ 2019-02-10  7:40 UTC (permalink / raw)
  To: linux-kernel, xen-devel, x86
  Cc: boris.ostrovsky, sstabellini, hpa, tglx, mingo, bp, linux,
	torvalds, Juergen Gross

set_pmd_at() calls native_set_pmd() unconditionally on x86. This was
fine as long as only huge page entries were written via set_pmd_at(),
as Xen pv guests don't support those.

Commit 2c91bd4a4e2e53 ("mm: speed up mremap by 20x on large regions")
introduced a usage of set_pmd_at() possible on pv guests, leading to
failures like:

[17035.016433] BUG: unable to handle kernel paging request at ffff888023e26778
[17035.025887] #PF error: [PROT] [WRITE]
[17035.035146] PGD 2a2a067 P4D 2a2a067 PUD 2a2b067 PMD 7fe01067 PTE 8010000023e26065
[17035.044371] Oops: 0003 [#1] SMP NOPTI
[17035.053720] CPU: 3 PID: 28310 Comm: apt-get Not tainted 5.0.0-rc5-20190208-thp-net-florian-rtl8169-eric-doflr+ #1
[17035.063440] Hardware name: MSI MS-7640/890FXA-GD70 (MS-7640)  , BIOS V1.8B1 09/13/2010
[17035.072635] RIP: e030:move_page_tables+0x7c1/0xae0
[17035.081585] Code: ce 00 48 8b 03 31 ff 48 89 44 24 20 e8 9e 72 e4 ff 66 90 48 89 c6 48 89 df e8 8b 89 e4 ff 66 90 48 8b 44 24 20 b9 0c 00 00 00 <48> 89 45 00 41 f6 46 52 40 0f 85 3f 02 00 00 49 8b 7e 40 45 31 c0
[17035.100225] RSP: e02b:ffffc90000f2bd40 EFLAGS: 00010282
[17035.109208] RAX: 0000000475e42067 RBX: ffff888023e267e0 RCX: 000000000000000c
[17035.118332] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000201
[17035.127378] RBP: ffff888023e26778 R08: aaaaaaaaaaaaaaaa R09: 000000051c1d9000
[17035.136310] R10: deadbeefdeadf00d R11: ffff88807fc17000 R12: 00007fc59fa00000
[17035.145433] R13: ffffea00008f89a8 R14: ffff88801c2286c0 R15: 00007fc59f800000
[17035.154171] FS:  00007fc5a5591100(0000) GS:ffff88807d4c0000(0000) knlGS:0000000000000000
[17035.162730] CS:  e030 DS: 0000 ES: 0000 CR0: 0000000080050033
[17035.171180] CR2: ffff888023e26778 CR3: 000000001c3f6000 CR4: 0000000000000660
[17035.179545] Call Trace:
[17035.187736]  move_vma.isra.3+0xd1/0x2d0
[17035.195837]  __se_sys_mremap+0x3c6/0x5b0
[17035.203986]  do_syscall_64+0x49/0x100
[17035.212109]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[17035.219971] RIP: 0033:0x7fc5a453527a
[17035.227558] Code: 73 01 c3 48 8b 0d 1e fc 2a 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 19 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d ee fb 2a 00 f7 d8 64 89 01 48
[17035.243255] RSP: 002b:00007ffda22d96f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000019
[17035.251121] RAX: ffffffffffffffda RBX: 0000557d40923a30 RCX: 00007fc5a453527a
[17035.258986] RDX: 0000000001a00000 RSI: 0000000001900000 RDI: 00007fc59f7ff000
[17035.267127] RBP: 0000000001a00000 R08: 0000000000000020 R09: 0000000000000040
[17035.275259] R10: 0000000000000001 R11: 0000000000000246 R12: 00007fc59f7ff060
[17035.282681] R13: 00007fc59f7ff000 R14: 0000557d40923a30 R15: 0000557d40829aa0
[17035.290322] Modules linked in:
[17035.297875] CR2: ffff888023e26778
[17035.305405] ---[ end trace 6ff49f09286816b6 ]---

Make set_pmd_at() paravirt aware by just letting it use set_pmd().

Fixes: 2c91bd4a4e2e53 ("mm: speed up mremap by 20x on large regions")
Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/include/asm/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 40616e805292..2779ace16d23 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1065,7 +1065,7 @@ static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr,
 static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
 			      pmd_t *pmdp, pmd_t pmd)
 {
-	native_set_pmd(pmdp, pmd);
+	set_pmd(pmdp, pmd);
 }
 
 static inline void set_pud_at(struct mm_struct *mm, unsigned long addr,
-- 
2.16.4


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

* [tip:x86/urgent] x86/mm: Make set_pmd_at() paravirt aware
  2019-02-10  7:40 [PATCH] x86: make set_pmd_at() paravirt aware Juergen Gross
@ 2019-02-10  7:52 ` tip-bot for Juergen Gross
  2019-02-10 18:14 ` [PATCH] x86: make " Linus Torvalds
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Juergen Gross @ 2019-02-10  7:52 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux, jgross, linux-kernel, hpa, mingo, tglx

Commit-ID:  20e55bc17dd01f13cec0eb17e76e9511b23963ef
Gitweb:     https://git.kernel.org/tip/20e55bc17dd01f13cec0eb17e76e9511b23963ef
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Sun, 10 Feb 2019 08:40:56 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 10 Feb 2019 08:47:12 +0100

x86/mm: Make set_pmd_at() paravirt aware

set_pmd_at() calls native_set_pmd() unconditionally on x86. This was
fine as long as only huge page entries were written via set_pmd_at(),
as Xen pv guests don't support those.

Commit 2c91bd4a4e2e53 ("mm: speed up mremap by 20x on large regions")
introduced a usage of set_pmd_at() possible on pv guests, leading to
failures like:

BUG: unable to handle kernel paging request at ffff888023e26778
#PF error: [PROT] [WRITE]
RIP: e030:move_page_tables+0x7c1/0xae0
move_vma.isra.3+0xd1/0x2d0
__se_sys_mremap+0x3c6/0x5b0
 do_syscall_64+0x49/0x100
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Make set_pmd_at() paravirt aware by just letting it use set_pmd().

Fixes: 2c91bd4a4e2e53 ("mm: speed up mremap by 20x on large regions")
Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: xen-devel@lists.xenproject.org
Cc: boris.ostrovsky@oracle.com
Cc: sstabellini@kernel.org
Cc: hpa@zytor.com
Cc: bp@alien8.de
Cc: torvalds@linux-foundation.org
Link: https://lkml.kernel.org/r/20190210074056.11842-1-jgross@suse.com

---
 arch/x86/include/asm/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 40616e805292..2779ace16d23 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1065,7 +1065,7 @@ static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr,
 static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
 			      pmd_t *pmdp, pmd_t pmd)
 {
-	native_set_pmd(pmdp, pmd);
+	set_pmd(pmdp, pmd);
 }
 
 static inline void set_pud_at(struct mm_struct *mm, unsigned long addr,

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

* Re: [PATCH] x86: make set_pmd_at() paravirt aware
  2019-02-10  7:40 [PATCH] x86: make set_pmd_at() paravirt aware Juergen Gross
  2019-02-10  7:52 ` [tip:x86/urgent] x86/mm: Make " tip-bot for Juergen Gross
@ 2019-02-10 18:14 ` Linus Torvalds
  2019-02-10 18:47   ` Juergen Gross
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Torvalds @ 2019-02-10 18:14 UTC (permalink / raw)
  To: Juergen Gross
  Cc: Linux List Kernel Mailing, xen-devel, the arch/x86 maintainers,
	Boris Ostrovsky, sstabellini, Peter Anvin, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Sander Eikelenboom

On Sat, Feb 9, 2019 at 11:41 PM Juergen Gross <jgross@suse.com> wrote:
>
> Make set_pmd_at() paravirt aware by just letting it use set_pmd().

Well, that was simpler than I worried.

Just checking: Is this purely an x86 issue? ARM is ok perhaps because
there's no PV support?

             Linus

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

* Re: [PATCH] x86: make set_pmd_at() paravirt aware
  2019-02-10 18:14 ` [PATCH] x86: make " Linus Torvalds
@ 2019-02-10 18:47   ` Juergen Gross
  0 siblings, 0 replies; 4+ messages in thread
From: Juergen Gross @ 2019-02-10 18:47 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Linux List Kernel Mailing, xen-devel, the arch/x86 maintainers,
	Boris Ostrovsky, sstabellini, Peter Anvin, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Sander Eikelenboom

On 10/02/2019 19:14, Linus Torvalds wrote:
> On Sat, Feb 9, 2019 at 11:41 PM Juergen Gross <jgross@suse.com> wrote:
>>
>> Make set_pmd_at() paravirt aware by just letting it use set_pmd().
> 
> Well, that was simpler than I worried.
> 
> Just checking: Is this purely an x86 issue? ARM is ok perhaps because
> there's no PV support?

Correct.


Juergen

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

end of thread, other threads:[~2019-02-10 18:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-10  7:40 [PATCH] x86: make set_pmd_at() paravirt aware Juergen Gross
2019-02-10  7:52 ` [tip:x86/urgent] x86/mm: Make " tip-bot for Juergen Gross
2019-02-10 18:14 ` [PATCH] x86: make " Linus Torvalds
2019-02-10 18:47   ` Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).