[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] efifb: ignore frame buffer with invalid configuration


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Fri, 18 Nov 2022 15:11:32 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZjEZzFkTYxDknDXb49z3xsoGFctbINBUhrfuN4m+sNs=; b=MtUd77mC2PrJDJEcWuihQmjS3D6s1bPJNVST+/UNmeW7CzmJL6shWv5YhvJL3q1Web/f0kf2mKr1zgY6/OL0df7JgJLp8erUGMMpe5/BiWJzAK8+CvPFOzVQP1CKZ4VF2j4AMl8Mo5DE/26+nyOUJXKJ9LTsG18ww/v0uBPLBr08mPadZWw/kHdW2rdFgo/lLBupqrx+Ta2TUHq73ClnfMPuDOqQtwHSuIYMlrnw4XSWrAo+GlyJVv/QbFkpwHRETTRprmTaNhQ1YLgemVZs/OCVkckegRJxnJuEVdwYZgrlWcHlUHIjo8gevqXIge6c20p7keR1Z0hFCcFhg75XoA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l+MtVd7SiFYw3welXT2juuK0NzWjzFKmjz/T3gESV0HiEBkTA12RiilasXJHUTCyV+fPBdkHpd3YPXwfEr/343U1hNz0TmynDrZ8ca/Xxg7PesFka9rV8Z6Q6HDEdE4GElsYxF/RLTIc7+nq2xUC7X8I4CNjHlcfX3cne+CPwHTW88GcGBhSotHva2h7CJLHpd+6lgoFRl7ieqMjGQooewm+x9ppypZLxSJqeTGjVCJzrPlhUSwr7Uraj9TG0AanAsdXkOcoyZRqgdAjkypexo1s+gDsdcEFmo/oLi79VAZcfIocjnNJZpqt+KHJBe6vBj0nfoaiOsTD4H0x0RdjNQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 18 Nov 2022 14:12:16 +0000
  • Ironport-data: A9a23:4nVGYaqGt4JFWB+MHEbpNMITOTteBmI/ZBIvgKrLsJaIsI4StFCzt garIBmEbPbfNGSkKYhzO9u38BtSv5CEy4dnTwFpqSszEisR8ZuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpAFc+E0/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKm06W1wUmAWP6gR5gaHzilNVvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXADwIbgmyp8am+eKqc/k2jd0ja8PsF5xK7xmMzRmBZRonabbqZvyQoPN9gnI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jemraYSEEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTCN5LS+PhqaYCbFu73SsXAUROcGWAraeHzU+TfYpBd xE9w397xUQ13AnxJjXnZDWorXjBshMCVt54F+wh9BrL2qfS+xyeBGUPUnhGctNOnM08SCEu1 1SJt8j0HjEpu7qQIVqC8p+EoDX0PjIaRVLufgcBRAoBptXm/oc6i0uVSs45SfDkyNroBTv33 jaG6jAkgKkehtIK0KP9+k3bhzWrpd7CSQtdChjrY19JJzhRPOaND7FEI3CBhRqcBO51lmW8g UU=
  • Ironport-hdrordr: A9a23:xH49G6sFINE3B5h0i23JpqWW7skCAoAji2hC6mlwRA09TyXGra 2TdaUgvyMc1gx7ZJhBo7+90We7MBHhHPlOkPEs1NaZLXDbUQ6TQL2KgrGSpwEIdxefygc/79 YcT0EBMqyWMbESt6+TjmiF+r4bsaO6GcuT9ILjJhlWPGJXg/YK1XYDNu/XKDwDeCB2Qb4CUL aM7MtOoDStPVwRc8SAH3EAG8TTutHRk5riQBgeQzoq8hOHgz+E4KPzV0Hw5GZXbxp/hZMZtU TVmQ3w4auu99m91x/nzmfWq7hGhdf7zdNHJcqUzuwYMC/lhAqEbJloH5eCoDc2iuey70tCqq iEnz4Qe+BIr1/BdGC8phXgnyHmzTYV8nfnjXuVm2Hqr8DVTC8zT5Mpv/MuTjLpr24b+P1s2q NC2GyU87JREBP7hSz4o/zFTQtjmEaYqWcr1cQTk3tce40Db6I5l/1pwGplVLM7WA7q4oEuF+ djSOna+fZtaFufK0vUu2F+qebcLUgbL1OjeAwvq8aV2z9ZkDRS1E0D3vESmX8G6dYUV4REz/ 6sCNUlqJh+CustKY5tDuYIRsW6TkbXRwjXDW6UKVP7UIkaJnP2rYLt6rld3pDmRHUx9up9pH 39aiIYiYZrEHieSfFmnac7uCwleV/NEggEkapllttEUr6VfsuaDcTMciFtryKamYRgPiTqYY fOBHtoOY6dEYKXI/cu4+TfYeghFZBMarxhhv8LH3Szn+nsFqrG8sTmTde7HsudLd9jYBK1Pk c+
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On one of my boxes when the HDMI cable is not plugged in the
FrameBufferBase of the EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE structure is
set to 0 by the firmware (while some of the other fields looking
plausible).

Such (bogus address) ends up mapped in vesa_init(), and since it
overlaps with a RAM region the whole system goes down pretty badly,
see:

(XEN) vesafb: framebuffer at 0x0000000000000000, mapped to 0xffff82c000201000, 
using 35209k, total 35209k
(XEN) vesafb: mode is 0x37557x32, linelength=960, font 8x16
(XEN) vesafb: Truecolor: size=8:8:8:8, shift=24:0:8:16
(XEN) (XEN) (XEN) (XEN) (XEN) (XEN) (XEN) (XEN) �ERROR: Class:0; Subclass:0; 
Operation: 0
ERROR: No ConOut
ERROR: No ConIn

Do like Linux and prevent using the EFI Frame Buffer if the base
address is 0.  This is inline with the logic in Linuxes
fb_base_is_valid() function at drivers/video/fbdev/efifb.c v6.0.9.

See also Linux commit 133bb070e94ab41d750c6f2160c8843e46f11b78 for
further reference.

Also prevent using Frame Buffers that have a 0 height or width, as
those are also invalid.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v1:
 - Print a message.
 - Also refuse configurations with height or width == 0.
---
 xen/arch/x86/efi/efi-boot.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index e82ac9daa7..27f928ed3c 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -506,6 +506,13 @@ static void __init 
efi_arch_video_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop,
 #ifdef CONFIG_VIDEO
     int bpp = 0;
 
+    if ( !gop->Mode->FrameBufferBase || !mode_info->HorizontalResolution ||
+         !mode_info->VerticalResolution )
+    {
+        PrintErr(L"Invalid Frame Buffer configuration found\r\n");
+        return;
+    }
+
     switch ( mode_info->PixelFormat )
     {
     case PixelRedGreenBlueReserved8BitPerColor:
-- 
2.37.3




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.