From nobody Fri Mar 29 02:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1558015731; cv=none; d=zoho.com; s=zohoarc; b=dsmJpUx2GmKGNsXz8ZZNlhRj2Ycuic9/VHOKK5NAOq9DqLlgZ77plXgTxyOkHN2gd9ZlkK2bjhaJUzCVCfK22oY3wXzy2eCmLUlyDiJsqbal53oXRKt1c3Spa6QdlDfOmzbEl5ryoFeTcvgKDbTFqtl7yiwOlriRz3v8ykP+kqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558015731; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7YJNqoBUEnfF8aem9Z5RdbCdcJrfhkO6Y7orCS6jA7g=; b=AqxMFoHq/qz5EOmOrPyW5r8ylPbizSU2gHVj1V1HGJF2OCtA/iGN6txGI4X3RnvIOLbhi55Pi50lpxpxPVACgFB7VDYd5FFAEvz/Oe+7+nnoLeKOPXDGZSN2vahhqeVnD2H8tzv2vF5N3IZ0c0QkhpTPUVNtjzqtxK2zHTsHkoI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1558015730989862.1469041754252; Thu, 16 May 2019 07:08:50 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hRH2q-0003Ga-8t; Thu, 16 May 2019 14:07:40 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hRH2p-0003GG-0O for xen-devel@lists.xenproject.org; Thu, 16 May 2019 14:07:39 +0000 Received: from new3-smtp.messagingengine.com (unknown [66.111.4.229]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f56af040-77e3-11e9-a6cc-9be0d19d668a; Thu, 16 May 2019 14:07:37 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id DD68127139; Thu, 16 May 2019 10:07:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Thu, 16 May 2019 10:07:36 -0400 Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id A682B8005C; Thu, 16 May 2019 10:07:34 -0400 (EDT) X-Inumbo-ID: f56af040-77e3-11e9-a6cc-9be0d19d668a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:in-reply-to:message-id:mime-version :references:references:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=k/MxUXlCXO45yWYQz PiBmG4TQveeGnYL5RqpcShgmY8=; b=PZ3Ldg53YXqh78vf4V7pHmJqS1Rc2QxtU eUESuSCYqO7ciGOzyB7nWdOj8+lvAki+crxvRSt6ESZGZEBHMbx751sPagzJpWeM zWWPNnIeDlVuY7dEsW/Vc/qIzKyYgzaP22W1HBWQbEnCzDKzovFh7Xwfkgw+XQZ0 lPIqtkYdQcS3rVQs3zCgB6YUJMm2nEU5mdoSY7f7+3z6au20FjDG9URMD0XB2diS kdHhu5+WoYWJyg+5cq2Bbk+47nQms62TmkE58bWcUYMeEKmMoGHom0Ky9Xm/QHrv uy28YgR7hSFLuxkpcVQtBT7p5w5veZ25q00L99OgmC6cyP9hsz7Tg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddttddgieelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gotffhvedqqdfjughrqdfuuhhsphgvtghtqdhlohifucdlhedmnecujfgurhephffvufff kffojghfgggjfhgtgfesthekredtredtjeenucfhrhhomhepofgrrhgvkhcuofgrrhgtii ihkhhofihskhhiqdfikphrvggtkhhiuceomhgrrhhmrghrvghksehinhhvihhsihgslhgv thhhihhnghhslhgrsgdrtghomheqnecuffhomhgrihhnpeguohhmtddrihhnfhhonecukf hppeeluddrieehrdefgedrfeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrghrmhgr rhgvkhesihhnvhhishhisghlvghthhhinhhgshhlrggsrdgtohhmnecuvehluhhsthgvrh fuihiivgeptd X-ME-Proxy: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Thu, 16 May 2019 16:07:29 +0200 Message-Id: <93faeff91ee3e14320b5048818badc38460143e7.1558015595.git-series.marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: References: MIME-Version: 1.0 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 1/1] xen: fix handling framebuffer located above 4GB X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Tim Deegan , Julien Grall , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On some machines (for example Thinkpad P52), UEFI GOP reports framebuffer located above 4GB (0x4000000000 on that machine). This address does not fit in {xen,dom0}_vga_console_info.u.vesa_lfb.lfb_base field, which is 32bit. The overflow here cause all kind of memory corruption when anything tries to write something on the screen, starting with zeroing the whole framebuffer in vesa_init(). Fix this similar to how it's done in Linux: add ext_lfb_base field at the end of the structure, to hold upper 32bits of the address. Since the field is added at the end of the structure, it will work with older Linux versions too (other than using possibly truncated address - no worse than without this change). Thanks to ABI containing size of the structure (start_info.console.dom0.info_size), Linux can detect when this field is present and use it appropriately then. Since this change public interface and use __XEN_INTERFACE_VERSION__, bump __XEN_LATEST_INTERFACE_VERSION__. Note: if/when backporting this change to Xen <=3D 4.12, #if in xen.h needs to be extended with " || defined(__XEN__)". Signed-off-by: Marek Marczykowski-G=C3=B3recki Reviewed-by: Jan Beulich --- Changes in v2: - guard ext_lfb_base with #if __XEN_INTERFACE_VERSION__, but always include whe building Xen itself - add a helper function for lfb_base Changes in v3: - add padding field - add parentheses around << - unwrap format string per coding style, restore 0x - drop #if defined(__XEN__) needed only in backport - bump __XEN_LATEST_INTERFACE_VERSION__ --- xen/arch/x86/efi/efi-boot.h | 1 + xen/drivers/video/vesa.c | 14 +++++++++----- xen/include/public/xen-compat.h | 2 +- xen/include/public/xen.h | 5 +++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 5789d2c..7a13a30 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -550,6 +550,7 @@ static void __init efi_arch_video_init(EFI_GRAPHICS_OUT= PUT_PROTOCOL *gop, vga_console_info.u.vesa_lfb.bytes_per_line =3D (mode_info->PixelsPerScanLine * bpp + 7) >> 3; vga_console_info.u.vesa_lfb.lfb_base =3D gop->Mode->FrameBufferBas= e; + vga_console_info.u.vesa_lfb.ext_lfb_base =3D gop->Mode->FrameBuffe= rBase >> 32; vga_console_info.u.vesa_lfb.lfb_size =3D (gop->Mode->FrameBufferSize + 0xffff) >> 16; } diff --git a/xen/drivers/video/vesa.c b/xen/drivers/video/vesa.c index 26d4962..9cf4bad 100644 --- a/xen/drivers/video/vesa.c +++ b/xen/drivers/video/vesa.c @@ -40,6 +40,11 @@ static int __init parse_font_height(const char *s) } custom_param("font", parse_font_height); =20 +static inline paddr_t lfb_base(void) +{ + return (paddr_t)((vlfb_info.ext_lfb_base) << 32) | vlfb_info.lfb_base; +} + void __init vesa_early_init(void) { unsigned int vram_vmode; @@ -97,15 +102,14 @@ void __init vesa_init(void) lfbp.text_columns =3D vlfb_info.width / font->width; lfbp.text_rows =3D vlfb_info.height / font->height; =20 - lfbp.lfb =3D lfb =3D ioremap(vlfb_info.lfb_base, vram_remap); + lfbp.lfb =3D lfb =3D ioremap(lfb_base(), vram_remap); if ( !lfb ) return; =20 memset(lfb, 0, vram_remap); =20 - printk(XENLOG_INFO "vesafb: framebuffer at %#x, mapped to 0x%p, " - "using %uk, total %uk\n", - vlfb_info.lfb_base, lfb, + printk(XENLOG_INFO "vesafb: framebuffer at 0x%" PRIpaddr ", mapped to = 0x%p, using %uk, total %uk\n", + lfb_base(), lfb, vram_remap >> 10, vram_total >> 10); printk(XENLOG_INFO "vesafb: mode is %dx%dx%u, linelength=3D%d, font %u= x%u\n", vlfb_info.width, vlfb_info.height, @@ -167,7 +171,7 @@ void __init vesa_mtrr_init(void) =20 /* Try and find a power of two to add */ do { - rc =3D mtrr_add(vlfb_info.lfb_base, size_total, type, 1); + rc =3D mtrr_add(lfb_base(), size_total, type, 1); size_total >>=3D 1; } while ( (size_total >=3D PAGE_SIZE) && (rc =3D=3D -EINVAL) ); } diff --git a/xen/include/public/xen-compat.h b/xen/include/public/xen-compa= t.h index 6fabca1..6708132 100644 --- a/xen/include/public/xen-compat.h +++ b/xen/include/public/xen-compat.h @@ -27,7 +27,7 @@ #ifndef __XEN_PUBLIC_XEN_COMPAT_H__ #define __XEN_PUBLIC_XEN_COMPAT_H__ =20 -#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040a00 +#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040d00 =20 #if defined(__XEN__) || defined(__XEN_TOOLS__) /* Xen is built with matching headers and implements the latest interface.= */ diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index ccdffc0..4676521 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -923,6 +923,11 @@ typedef struct dom0_vga_console_info { /* Mode attributes (offset 0x0, VESA command 0x4f01). */ uint16_t mode_attrs; #endif +#if __XEN_INTERFACE_VERSION__ >=3D 0x00040d00 + uint16_t _pad; + /* high 32 bits of lfb_base */ + uint32_t ext_lfb_base; +#endif } vesa_lfb; } u; } dom0_vga_console_info_t; --=20 git-series 0.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel