Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2990842imm; Sun, 1 Jul 2018 09:51:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf8BQ759l7tGOF3FlcjhkQJ1Bjy7IBMN0iRvHinizVtiwiXCzJx+u0j9uIQOL+vs3UbGHha X-Received: by 2002:a65:6143:: with SMTP id o3-v6mr5987985pgv.52.1530463883625; Sun, 01 Jul 2018 09:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530463883; cv=none; d=google.com; s=arc-20160816; b=EZgqipmdagSl7Jv8m/+nBfkNzIygZWH7rmsVIDrrGRqQNx+U1QTPYr07c1Sp+0QRzH pSRH0qGyn4CNhHmTKP6u4sNCLxwGC93/Wj8BsWvrtZfF80K21t4om/oRovQKHMCxwcfA IfZFnbJRQ8dfs1SNEW2wd1yHa0Y3W+Qrj4Is+2fOhINYlrqse7PFeibrAqS6o7GrvRNv Loc5S+v6AEr0TSwg3jXPUpnz/iHsb+rZJwQ6+a713mYgpm12GjKC3SFYKB93QR9PZdCR AHeKeMMLUa3TqrlShUG4X1wNCue5BPurEP6mnQlI4b6vJA+9eH24tWkDwDp8TnL9pk3o h/4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=R5hTXkkgXw2r8o+Tk8BsKbP/MdLcav/XbiQwqTjCWBE=; b=gNcigfliRM5eVBT1AKiBN+rV5nE8LHKiA3q4xfeQxtk2KlW3RPmLV9e/T6saLRPNe8 SJcRpXMwiSTpoKYnSERlcPq9GL07MSFld5ZKWuAfbSZRrDqg7abv+PnSyoRqKJ+fTWz6 1AxHB6HzWHatp6jAXKwSchXwFKhEXONiaYsCyqYiGYQuDML2oH7B3GOx3zI0kyMPcIrt GQnPxRN0D8bA5GdkHBrIUfgxVZnHwEezENaJ/+icvQDN2nWeCUOFpJzu6xxMyGk5i3Ch MW0dzvIc5WwWvBLRpXVchIsNtglcoUGwXFXWaQtB7DIpszk3GeoZJrUsEIqhChvjr4n4 RpBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23-v6si13671099pfh.266.2018.07.01.09.51.09; Sun, 01 Jul 2018 09:51:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965891AbeGAQtr (ORCPT + 99 others); Sun, 1 Jul 2018 12:49:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38518 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032543AbeGAQql (ORCPT ); Sun, 1 Jul 2018 12:46:41 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0A19DACC; Sun, 1 Jul 2018 16:46:40 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Kirill A. Shutemov" , Ard Biesheuvel , Andrey Ryabinin , Baoquan He , Linus Torvalds , Matt Fleming , Peter Zijlstra , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.17 217/220] x86/efi: Fix efi_call_phys_epilog() with CONFIG_X86_5LEVEL=y Date: Sun, 1 Jul 2018 18:24:01 +0200 Message-Id: <20180701160917.204993240@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kirill A. Shutemov commit cfe19577047e74cdac5826adbdc2337d8437f8fb upstream. Open-coded page table entry checks don't work correctly when we fold the page table level at runtime. pgd_present() on 4-level paging machine always returns true, but open-coded version of the check may return false-negative result and we silently skip the rest of the loop body in efi_call_phys_epilog(). Replace open-coded checks with proper helpers. Signed-off-by: Kirill A. Shutemov Acked-by: Ard Biesheuvel Cc: Andrey Ryabinin Cc: Baoquan He Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: stable@vger.kernel.org # v4.12+ Fixes: 94133e46a0f5 ("x86/efi: Correct EFI identity mapping under 'efi=old_map' when KASLR is enabled") Link: http://lkml.kernel.org/r/20180625120852.18300-1-kirill.shutemov@linux.intel.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/platform/efi/efi_64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -166,14 +166,14 @@ void __init efi_call_phys_epilog(pgd_t * pgd = pgd_offset_k(pgd_idx * PGDIR_SIZE); set_pgd(pgd_offset_k(pgd_idx * PGDIR_SIZE), save_pgd[pgd_idx]); - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) + if (!pgd_present(*pgd)) continue; for (i = 0; i < PTRS_PER_P4D; i++) { p4d = p4d_offset(pgd, pgd_idx * PGDIR_SIZE + i * P4D_SIZE); - if (!(p4d_val(*p4d) & _PAGE_PRESENT)) + if (!p4d_present(*p4d)) continue; pud = (pud_t *)p4d_page_vaddr(*p4d);