Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp866680pxb; Tue, 1 Feb 2022 12:04:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeEPzJYHKmEgoa890u6X10Kww1/J/bsORiZLBghAurMXLyyYWba0bJlixUnyT7B2+sNHQf X-Received: by 2002:a62:ce83:: with SMTP id y125mr26516372pfg.6.1643745842181; Tue, 01 Feb 2022 12:04:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745842; cv=none; d=google.com; s=arc-20160816; b=c3WknartHzWrk6txLPABQ0UGrjlJEQ/QAqL0Q8ktic0CULaCMOb5DcBrb55Pnz36eD dcztr7dqk3ijC1m90hhI+VJeboyliovjM4OEjZ9jw+w5Pd4fez0e0FQvrgfWeQjx33Vk WVcAH3wCQMJ4YHnwG2hnKyyiTLmXNE4Eoxtg6xkxCZ849GNW/P7BKPKzKJ14JlnlG2xn gedlH95c8ph1rPFjArr92W2Tb6qsSg1zfMTo0NwWTtz+nEJa5qjsAuVzmlEjomgmkGZw 6FNYSZeyd041TIXtU8tFaxkr6Viq3kGJ/LmzJ8sV42uqpYA5ZdzBwGy69pBC7rQ4Z7IK Cpjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7JWH9pBXNhhgkU2OtlM2msSS+ndGR54Qcf6l6k7/iAc=; b=Irtfuh1SONXnPIea3wsHIGAbPMIVuepK1ongJiDxHoKFUC4yRghDZKPvALzFc4UIJJ pkn6H/hbsOWRHnMNA3wMcyv/GbZeqY/88hAAyXUMQlK05WvTH5MwU6AY6xGCDI/Z+Dey K2M+2xTNP/QNAaBQBxQe1OyimOu+plKolSwuZQbqROaU7gQFcOEsNRimrdvn039P1XXQ 5J2NTV5cunwKyvxOjyKhUoWXnT94yvkf7HMbwo1/19ou+hImYfcv+KZJXLRwHMcLLWpE 7ObPa9kJpW6E/QAT8n0HrilJUNZ80FsnfH3CXLVctSvtnqoJB38YCi/dbz73SB1pYQHD 36tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uPSNJNb+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si20303023plh.398.2022.02.01.12.03.50; Tue, 01 Feb 2022 12:04:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uPSNJNb+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376269AbiAaLRV (ORCPT + 99 others); Mon, 31 Jan 2022 06:17:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377313AbiAaLJz (ORCPT ); Mon, 31 Jan 2022 06:09:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6B97C0604D9; Mon, 31 Jan 2022 03:07:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 66E2560FE1; Mon, 31 Jan 2022 11:07:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47722C340E8; Mon, 31 Jan 2022 11:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627238; bh=RlAyw1yro2XvdUgx7Zcqs3E/pvyLS4SrAYRZUEphfIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uPSNJNb+rlkTpqENVBN/Tu8OhPcEgNJDEQT+qv8+LQoI4UZ0PmK5KWIGpR1nOc6m/ lJPtq/V9NYdD2FD2JxvCG20ymVik2K8zEXL5y32+g1NCIXvMOe0zewD0zbBR0P0mAL fZn34KDu55dntJ7Lp9VYyEqEL5Sz14IakSWpFkj0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeremy Kerr , Matthew Garrett , Aditya Garg , Orlando Chamberlain , Ard Biesheuvel Subject: [PATCH 5.15 019/171] efi: runtime: avoid EFIv2 runtime services on Apple x86 machines Date: Mon, 31 Jan 2022 11:54:44 +0100 Message-Id: <20220131105230.669004093@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105229.959216821@linuxfoundation.org> References: <20220131105229.959216821@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel commit f5390cd0b43c2e54c7cf5506c7da4a37c5cef746 upstream. Aditya reports [0] that his recent MacbookPro crashes in the firmware when using the variable services at runtime. The culprit appears to be a call to QueryVariableInfo(), which we did not use to call on Apple x86 machines in the past as they only upgraded from EFI v1.10 to EFI v2.40 firmware fairly recently, and QueryVariableInfo() (along with UpdateCapsule() et al) was added in EFI v2.00. The only runtime service introduced in EFI v2.00 that we actually use in Linux is QueryVariableInfo(), as the capsule based ones are optional, generally not used at runtime (all the LVFS/fwupd firmware update infrastructure uses helper EFI programs that invoke capsule update at boot time, not runtime), and not implemented by Apple machines in the first place. QueryVariableInfo() is used to 'safely' set variables, i.e., only when there is enough space. This prevents machines with buggy firmwares from corrupting their NVRAMs when they run out of space. Given that Apple machines have been using EFI v1.10 services only for the longest time (the EFI v2.0 spec was released in 2006, and Linux support for the newly introduced runtime services was added in 2011, but the MacbookPro12,1 released in 2015 still claims to be EFI v1.10 only), let's avoid the EFI v2.0 ones on all Apple x86 machines. [0] https://lore.kernel.org/all/6D757C75-65B1-468B-842D-10410081A8E4@live.com/ Cc: Cc: Jeremy Kerr Cc: Matthew Garrett Reported-by: Aditya Garg Tested-by: Orlando Chamberlain Signed-off-by: Ard Biesheuvel Tested-by: Aditya Garg Link: https://bugzilla.kernel.org/show_bug.cgi?id=215277 Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/efi.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -719,6 +719,13 @@ void __init efi_systab_report_header(con systab_hdr->revision >> 16, systab_hdr->revision & 0xffff, vendor); + + if (IS_ENABLED(CONFIG_X86_64) && + systab_hdr->revision > EFI_1_10_SYSTEM_TABLE_REVISION && + !strcmp(vendor, "Apple")) { + pr_info("Apple Mac detected, using EFI v1.10 runtime services only\n"); + efi.runtime_version = EFI_1_10_SYSTEM_TABLE_REVISION; + } } static __initdata char memory_type_name[][13] = {