From patchwork Thu Apr 19 18:26:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10351445 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A6E4B602B7 for ; Thu, 19 Apr 2018 18:26:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 957492434C for ; Thu, 19 Apr 2018 18:26:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89F97283AF; Thu, 19 Apr 2018 18:26:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F388F2434C for ; Thu, 19 Apr 2018 18:26:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752976AbeDSS0H (ORCPT ); Thu, 19 Apr 2018 14:26:07 -0400 Received: from 8bytes.org ([81.169.241.247]:51022 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752937AbeDSS0H (ORCPT ); Thu, 19 Apr 2018 14:26:07 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 9FE99459; Thu, 19 Apr 2018 20:26:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1524162365; bh=3JpBt3mX6fqF9gMKNxhP70orHsoVwj4V8Mt2QST3oXQ=; h=From:To:Cc:Subject:Date:From; b=JRsxAN7SMiUNEalGoI2RPhW9a6/WGbcq35fc7lrvon79skuclx4RrNDECBMW5lPtt Ptl4LAmM2gxJo/nemtVWUCZTEdwD5dqkr1DqkrdKbyfeBRPrsUp2xGKxIgNvgeVTDe H44v4lRIx8Y0h9T+5o0WrX1eTzNOwuAzD1Pi4RTDIooF8ZUShf1EdlKr0jBel0Ja16 DKAQTHxauCfXEO91ojrG9G4Z4wNR4fCOMaRRovgrdYB+Ta5F3U+45xNptH10IF6Tai htJqQokweiRTcgbYDX75DXqVbo56rQ8C03fSUgFxEagoOlKbo109Bpcg0Qv8LvN77k v09UyFdxM4ciw== From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar Cc: rjw@rjwysocki.net, pavel@ucw.cz, hpa@zytor.com, Michal Kubecek , Borislav Petkov , x86@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH] x86/power/64: Fix page-table setup for temporary text mapping Date: Thu, 19 Apr 2018 20:26:00 +0200 Message-Id: <1524162360-26179-1-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel 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 Fixes: fb43d6cb91ef ('x86/mm: Do not auto-massage page protections') Tested-by: Michal Kubecek Tested-by: Borislav Petkov Signed-off-by: Joerg Roedel --- 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); }