Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5900250imb; Fri, 8 Mar 2019 05:05:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwiM9JQb5DjbHHJK1ED9+Zf/smHsLyP9g4cGnU/Uf+/LjQazjbLkmi8wSXHEPXKXxXG748K X-Received: by 2002:a62:e017:: with SMTP id f23mr18223937pfh.152.1552050306244; Fri, 08 Mar 2019 05:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552050306; cv=none; d=google.com; s=arc-20160816; b=DzKzRN37d3MFFG+dylPwu+49g+pB4cBouyv3gklvenGc5BxEBf7rh1Lm/vRy4wjGzd i0xpSaM9N+Vjz9Ao20Y/tPkCTDrcMNNeMSUYrL1zMlU8MnlFO2lD+03JbU+tzv5/qs8T nG0MS2uX4JzMhBuouILCoIc10kuQ6pehxMDTxNRDup/PnGqc3DYuvk0IudQzOcJYW9lF GcbdFf9A10nz3uz+MYWl250w+4ueZifxWa2W+gjr6GoilX4yzZCGWhmAhKJ8yn5KGz0e Hhkt5rJjjyU0SJoydnUK5XgmMhk2i0ypkmiyPmWSKvQRGQ6Asq/sCgc0KE5aYDbtoEFI ZxhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7Lpg+rqirbTygpYeDSwcDvA2Zmk0H1bAOmx+pWMPu1c=; b=wc00+0kCj6ZTkBLwMpcm6uGULLAiIVtY5KMfGGPBNJF4dESaIYkhedkZOqugWK/1lX zVkV1BP1DIfnlWoCz8IZ2imwLIQDUgCtUgxPd2oM6JwoJwGnIj+aRY9srLZOcKv2jldt Ox3QAO12AGjrpQ10Hf92bgv71J4sRT+AGgS43vG6GTvR8USa33xteA0M26KR7P2QZC7E OX06qcCLGktzNpM7iNKl+cfZdSwCiUe4KgFszXCe+ddHjXWLs5CmBu7nLJ9ttzVu3t0e ss/KI1YqNyCZBHHwvRTcchAr88gWQaT9ZLlXWU/t3kwvnVWuO0YqO5+FtT6ZG1NJJpnF DYFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a5RNhJJj; 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 q9si6986169pll.404.2019.03.08.05.04.50; Fri, 08 Mar 2019 05:05:06 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=a5RNhJJj; 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 S1727947AbfCHNAG (ORCPT + 99 others); Fri, 8 Mar 2019 08:00:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:36936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbfCHNAE (ORCPT ); Fri, 8 Mar 2019 08:00:04 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F117820661; Fri, 8 Mar 2019 13:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552050003; bh=EreNsZxfCtGj1UwHD657sGNgtuFQhti5dnsDHyGoZvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a5RNhJJjY0wvvkUH0ZjZ8MtTauaASu5qrc96G3A6HJkIBZ8fDVSkuzubSljjBSOtY fbSF6ph23OwsXEC6hbTPcmx84pW5pK5uB54TyzZVGQ9SV1LPrUfCKdLsgv7GgMtme+ /gNhXJn93SJ6/qn4R30ePPKVU41gPB3QnuOnBRkc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pitam Mitra , "Kirill A. Shutemov" , Thomas Gleixner , Bockjoo Kim , bp@alien8.de, hpa@zytor.com Subject: [PATCH 4.19 54/68] x86/boot/compressed/64: Do not read legacy ROM on EFI system Date: Fri, 8 Mar 2019 13:50:24 +0100 Message-Id: <20190308124913.293894540@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190308124910.696595153@linuxfoundation.org> References: <20190308124910.696595153@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kirill A. Shutemov commit 6f913de3231e1d70a871135b38219da7810df218 upstream. EFI systems do not necessarily provide a legacy ROM. If the ROM is missing the memory is not mapped at all. Trying to dereference values in the legacy ROM area leads to a crash on Macbook Pro. Only look for values in the legacy ROM area for non-EFI system. Fixes: 3548e131ec6a ("x86/boot/compressed/64: Find a place for 32-bit trampoline") Reported-by: Pitam Mitra Signed-off-by: Kirill A. Shutemov Signed-off-by: Thomas Gleixner Tested-by: Bockjoo Kim Cc: bp@alien8.de Cc: hpa@zytor.com Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20190219075224.35058-1-kirill.shutemov@linux.intel.com Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202351 Signed-off-by: Greg Kroah-Hartman --- arch/x86/boot/compressed/pgtable_64.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) --- a/arch/x86/boot/compressed/pgtable_64.c +++ b/arch/x86/boot/compressed/pgtable_64.c @@ -1,5 +1,7 @@ +#include #include #include +#include #include "pgtable.h" #include "../string.h" @@ -37,9 +39,10 @@ int cmdline_find_option_bool(const char static unsigned long find_trampoline_placement(void) { - unsigned long bios_start, ebda_start; + unsigned long bios_start = 0, ebda_start = 0; unsigned long trampoline_start; struct boot_e820_entry *entry; + char *signature; int i; /* @@ -47,8 +50,18 @@ static unsigned long find_trampoline_pla * This code is based on reserve_bios_regions(). */ - ebda_start = *(unsigned short *)0x40e << 4; - bios_start = *(unsigned short *)0x413 << 10; + /* + * EFI systems may not provide legacy ROM. The memory may not be mapped + * at all. + * + * Only look for values in the legacy ROM for non-EFI system. + */ + signature = (char *)&boot_params->efi_info.efi_loader_signature; + if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) && + strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) { + ebda_start = *(unsigned short *)0x40e << 4; + bios_start = *(unsigned short *)0x413 << 10; + } if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX) bios_start = BIOS_START_MAX;