From patchwork Tue Apr 4 15:27:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96736 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp248083qgd; Tue, 4 Apr 2017 08:28:01 -0700 (PDT) X-Received: by 10.84.209.133 with SMTP id y5mr29572632plh.25.1491319681791; Tue, 04 Apr 2017 08:28:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5si17812030pga.100.2017.04.04.08.28.01; Tue, 04 Apr 2017 08:28:01 -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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754345AbdDDP2A (ORCPT + 25 others); Tue, 4 Apr 2017 11:28:00 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:35108 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754198AbdDDP14 (ORCPT ); Tue, 4 Apr 2017 11:27:56 -0400 Received: by mail-wm0-f42.google.com with SMTP id y22so28666367wmh.0 for ; Tue, 04 Apr 2017 08:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LjaFjajdwrSxiInqInTs/DvpKX2ruEZ9watTTMDq+5Y=; b=Uf28dn4wJaUsZI+FHU3yJqpFMLQH6oQY97ZA2IOItMgh01p1KB4uc7M+MpHKHzj+Q7 UhSMtWVoIVi/qWyhVq7BINfTVVEorwoBSNCyzUX1JjU5H/DxoagO9l6yOP94ZlJ4GUmI bmAPULzaQc3KSkiMkc3QFJ4AozjvsbhLT5lV4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LjaFjajdwrSxiInqInTs/DvpKX2ruEZ9watTTMDq+5Y=; b=C3aSDGzTmIgx+vFN2Sk1j0ycicaI8M46sEfjJJ5Eev5wukpyg+Tyv7a5vdmnZhuEXa EAdwZCVjyI7B5nMeBebJQ4R6TC+NZ+41IeP93awPJc8oL15S4ychuSR06L6zuvESKUnJ F9CPAGzlQ/faLYoNJK179TeVs0mW2vLSW5ZdnQnqkwlY95agB3tAM6MzQH1VIyvyd+tG PRdILUnKBUFA+hANz4cw2ZA9YKf4Z84phrsWzXChH3Bys5ZeMRD9Rqt8PJouCFdxuhKM ZfikV3eBL1rPe14j+fuQR+uTb2EHcflVULGpF1Rrv2bm69f/hljqNHE4YxUFFD24dgve WZiQ== X-Gm-Message-State: AFeK/H28dvIN8yMj9ZglOsDCGDd1+8MH/LZ8peplHT9bS7W2/FIioj5j f9laP/nf15JDGNXS X-Received: by 10.28.113.12 with SMTP id m12mr14939213wmc.18.1491319674991; Tue, 04 Apr 2017 08:27:54 -0700 (PDT) Received: from localhost.localdomain ([160.163.145.113]) by smtp.gmail.com with ESMTPSA id n53sm4421205wrn.28.2017.04.04.08.27.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 08:27:54 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: leif.lindholm@linaro.org, lorenzo.pieralisi@arm.com, "Cohen, Eugene" , Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] efi/libstub: Skip GOP with PIXEL_BLT_ONLY format Date: Tue, 4 Apr 2017 16:27:43 +0100 Message-Id: <20170404152744.26687-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170404152744.26687-1-ard.biesheuvel@linaro.org> References: <20170404152744.26687-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Cohen, Eugene" The UEFI Specification permits Graphics Output Protocol (GOP) instances without direct framebuffer access. This is indicated in the Mode structure with a PixelFormat enumeration value of PIXEL_BLT_ONLY. Given that the kernel does not know how to drive a Blt() only framebuffer (which is only permitted before ExitBootServices() anyway), we should disregard such framebuffers when looking for a GOP instance that is suitable for use as the boot console. So modify the EFI GOP initialization to not use a PIXEL_BLT_ONLY instance, preventing attempts later in boot to use an invalid screen_info.lfb_base address. Fixes: 9822504c1fa5 ("efifb: Enable the efi-framebuffer platform driver ...") Signed-off-by: Eugene Cohen [ardb: - move Blt() only check into the loop - clarify that Blt() only GOPs are unusable by the kernel] Cc: Matt Fleming Cc: # v4.7+ Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/gop.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.9.3 diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c index 932742e4cf23..24c461dea7af 100644 --- a/drivers/firmware/efi/libstub/gop.c +++ b/drivers/firmware/efi/libstub/gop.c @@ -149,7 +149,8 @@ setup_gop32(efi_system_table_t *sys_table_arg, struct screen_info *si, status = __gop_query32(sys_table_arg, gop32, &info, &size, ¤t_fb_base); - if (status == EFI_SUCCESS && (!first_gop || conout_found)) { + if (status == EFI_SUCCESS && (!first_gop || conout_found) && + info->pixel_format != PIXEL_BLT_ONLY) { /* * Systems that use the UEFI Console Splitter may * provide multiple GOP devices, not all of which are @@ -266,7 +267,8 @@ setup_gop64(efi_system_table_t *sys_table_arg, struct screen_info *si, status = __gop_query64(sys_table_arg, gop64, &info, &size, ¤t_fb_base); - if (status == EFI_SUCCESS && (!first_gop || conout_found)) { + if (status == EFI_SUCCESS && (!first_gop || conout_found) && + info->pixel_format != PIXEL_BLT_ONLY) { /* * Systems that use the UEFI Console Splitter may * provide multiple GOP devices, not all of which are From patchwork Tue Apr 4 15:27:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96737 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp248209qgd; Tue, 4 Apr 2017 08:28:19 -0700 (PDT) X-Received: by 10.84.211.97 with SMTP id b88mr30173835pli.113.1491319699888; Tue, 04 Apr 2017 08:28:19 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7si17824184pgn.97.2017.04.04.08.28.19; Tue, 04 Apr 2017 08:28:19 -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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754425AbdDDP2I (ORCPT + 25 others); Tue, 4 Apr 2017 11:28:08 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:38325 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753804AbdDDP17 (ORCPT ); Tue, 4 Apr 2017 11:27:59 -0400 Received: by mail-wm0-f46.google.com with SMTP id t189so31285206wmt.1 for ; Tue, 04 Apr 2017 08:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e6M+xugzcovcCd7APfm4cWPF+lU826rBLm5qBqVxvYs=; b=dXk2+36SeZ3DiMzDJmZpc4HMid/c0mWu0RkcGPtx6Mm7PVoOCs8u+5qc9H50Vu6UJ5 xjSeZejzR1YTDfJhooyLqFgB85Lq2ZiJwoJIypsmuEsSvcZxbzFkadAf9CwKdm6NHPPK 0JCRuMgdbo5kVVZAQV2K6heFahP0AUey6id/0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e6M+xugzcovcCd7APfm4cWPF+lU826rBLm5qBqVxvYs=; b=OBdOqfDILp7wZv10F/nZ856lVei5n6n008mbERcRqrGuhXNMNhPmMYFVNoupc34rAS PdBMsMNvLTrQorLi2l0HWMFO7EQ74jrGL013H2NZpazxYcScL5Md7YqNXyKnuyZXGNQ4 S9CkYfFBrGuJk1oLux2pqLf0XBDh/hzMkhleghpfxNsArVaHqW+aoQIJDhWY6+cbNYj8 n8dPM5AP1WGJQXpZJK5ANzWrHkEaLUrYvh6/JNb2ES71ufLSELqTqEHuI99GLKRQgnnv JUMwpZPg/slXKAChUsCHFvWQW9iz9bgqckkKbIOJ6lcmExHNc4kZ9GLJ+Y0jAddfBHAS vxnA== X-Gm-Message-State: AFeK/H0B9tZFkxwydl1ZezTcuynh5gw2U7JBPpTMctkYIEKBMvvPQsoR la+eLWp4eV1o54Ge X-Received: by 10.28.12.147 with SMTP id 141mr15437543wmm.8.1491319677648; Tue, 04 Apr 2017 08:27:57 -0700 (PDT) Received: from localhost.localdomain ([160.163.145.113]) by smtp.gmail.com with ESMTPSA id n53sm4421205wrn.28.2017.04.04.08.27.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 08:27:56 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: leif.lindholm@linaro.org, lorenzo.pieralisi@arm.com, Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] efifb: Avoid reconfiguration of BAR that covers the framebuffer Date: Tue, 4 Apr 2017 16:27:44 +0100 Message-Id: <20170404152744.26687-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170404152744.26687-1-ard.biesheuvel@linaro.org> References: <20170404152744.26687-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On UEFI systems, the PCI subsystem is enumerated by the firmware, and if a graphical framebuffer is exposed by a PCI device, its base address and size are exposed to the OS via the Graphics Output Protocol (GOP). On arm64 PCI systems, the entire PCI hierarchy is reconfigured from scratch at boot. This may result in the GOP framebuffer address to become stale, if the BAR covering the framebuffer is modified. This will cause the framebuffer to become unresponsive, and may in some cases result in unpredictable behavior if the range is reassigned to another device. So add a non-x86 quirk to the EFI fb driver to find the BAR associated with the GOP base address, and claim the BAR resource so that the PCI core will not move it. Fixes: 9822504c1fa5 ("efifb: Enable the efi-framebuffer platform driver ...") Cc: # v4.7+ Cc: Matt Fleming Cc: Peter Jones Signed-off-by: Ard Biesheuvel --- drivers/video/fbdev/efifb.c | 66 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) -- 2.9.3 diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index 8c4dc1e1f94f..758960b6aec9 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include