From patchwork Sun Feb 6 19:28:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12736679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6EAD2C4332F for ; Sun, 6 Feb 2022 19:29:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.266314.459994 (Exim 4.92) (envelope-from ) id 1nGnDK-0001mv-Em; Sun, 06 Feb 2022 19:28:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 266314.459994; Sun, 06 Feb 2022 19:28:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nGnDK-0001mo-Bo; Sun, 06 Feb 2022 19:28:46 +0000 Received: by outflank-mailman (input) for mailman id 266314; Sun, 06 Feb 2022 19:28:45 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nGnDJ-0001Yz-9u for xen-devel@lists.xenproject.org; Sun, 06 Feb 2022 19:28:45 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nGnDJ-0005sk-2e; Sun, 06 Feb 2022 19:28:45 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nGnDI-0007Ok-Pk; Sun, 06 Feb 2022 19:28:45 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=afEtY43khqyixlLlQcgO+P5/SZzjDhtwscVQfHzNp6w=; b=3VtDXi3lemG7IAYf+DmdTdw7XG 49nHZrGfVfH6KIvICROvXnt8LH95v6Sej6Sy7FnViBrQXDiaJJb1l+o+QRrc1ldMXYFjpYQAv1eYJ X3NDNAzLRWK5CGxby0CF8bXGWhzQaeQ333HMRgF785hVqYEJTA4e9biey1Mb5SmPPmyI=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: ehem+xen@m5p.com, Julien Grall , Jan Beulich Subject: [PATCH RFC 1/3] xen/efi: Always query the console information and get GOP Date: Sun, 6 Feb 2022 19:28:37 +0000 Message-Id: <20220206192839.75711-2-julien@xen.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220206192839.75711-1-julien@xen.org> References: <20220206192839.75711-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall Currently, the EFI stub will only query the console information and get the GOP when using the configuration file. However, GRUB is never providing the a configuration file. So the EFI framebuffer will not be usable at least on Arm (support will be added in a follow-up patch). Move out the code outside of the configuration file section. Take the opportunity to remove the variable 'size' which was set but never used (interestingly GCC is only complaining if it is initialization when declaring the variable). With this change, GCC 8.3 will complain of argc potentially been used unitiatlized. I suspect this is because the argc will be iniitalized and used in a different if code-blocks. Yet they are using the same check. Signed-off-by: Julien Grall ---- It is not entirely clear to me why the GOP was only fetched when the configuration file is used. I have tested this on RPI4 and it seems to work. Any chance this was done to workaround an x86 platform? --- xen/common/efi/boot.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 12fd0844bd55..80e4e32623c4 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1129,9 +1129,11 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) static EFI_GUID __initdata shim_lock_guid = SHIM_LOCK_PROTOCOL_GUID; EFI_LOADED_IMAGE *loaded_image; EFI_STATUS status; - unsigned int i, argc; + /* Initialize argc to stop GCC complaining */ + unsigned int i, argc = 0; CHAR16 **argv, *file_name, *cfg_file_name = NULL, *options = NULL; - UINTN gop_mode = ~0; + UINTN gop_mode = ~0, cols = 0, rows = 0; + EFI_SHIM_LOCK_PROTOCOL *shim_lock; EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL; union string section = { NULL }, name; @@ -1219,18 +1221,16 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) efi_arch_relocate_image(0); + if ( StdOut->QueryMode(StdOut, StdOut->Mode->Mode, + &cols, &rows) == EFI_SUCCESS ) + efi_arch_console_init(cols, rows); + + gop = efi_get_gop(); + if ( use_cfg_file ) { EFI_FILE_HANDLE dir_handle; - UINTN depth, cols, rows, size; - - size = cols = rows = depth = 0; - - if ( StdOut->QueryMode(StdOut, StdOut->Mode->Mode, - &cols, &rows) == EFI_SUCCESS ) - efi_arch_console_init(cols, rows); - - gop = efi_get_gop(); + UINTN depth = 0; /* Get the file system interface. */ dir_handle = get_parent_handle(loaded_image, &file_name); From patchwork Sun Feb 6 19:28:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12736677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5488AC433F5 for ; Sun, 6 Feb 2022 19:29:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.266315.460006 (Exim 4.92) (envelope-from ) id 1nGnDN-00023b-Mu; Sun, 06 Feb 2022 19:28:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 266315.460006; Sun, 06 Feb 2022 19:28:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nGnDN-00023R-Iu; Sun, 06 Feb 2022 19:28:49 +0000 Received: by outflank-mailman (input) for mailman id 266315; Sun, 06 Feb 2022 19:28:47 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nGnDL-00022Q-QV for xen-devel@lists.xenproject.org; Sun, 06 Feb 2022 19:28:47 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nGnDK-0005sy-RB; Sun, 06 Feb 2022 19:28:46 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nGnDK-0007Ok-FF; Sun, 06 Feb 2022 19:28:46 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=At0G3eg7j5P+J2/OwNksy7nZbwWKktpJk5zKue+aCUs=; b=ubR3d92i9BDoPIkoIXp2mhYIb+ OBGSxCNFxlOWArOHyLQStiLI8orDDJLe7W6wH2VaGjZTPh+GKndo7thAHa/ONpx42PpiFkxPfRzHM QPKZ8bfPIEYszy/WgqPggHewJbd7npapB6sb9Pqprmztr/xL2FLSohFz8x5NyRaTfsjI=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: ehem+xen@m5p.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH RFC 2/3] xen/arm: efi: Introduce and fill the vga_console_info Date: Sun, 6 Feb 2022 19:28:38 +0000 Message-Id: <20220206192839.75711-3-julien@xen.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220206192839.75711-1-julien@xen.org> References: <20220206192839.75711-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall In a follow-up patch will we want to add support for EFI framebuffer in dom0. Yet, Xen may not use the framebuffer, so it would be ideal to not have to enable CONFIG_VIDEO/CONFIG_VGA. Introduce vga_console_info in a hacky way and move the code to fill it up from x86 to common. Signed-off-by: Julien Grall ---- This is a bit of a hack. Sent early to gather opinion on whether we should enable allow Dom0 to use the EFI Framebuffer even if Xen is built with CONFIG_VIDEO=n on Arm. --- xen/arch/arm/efi/efi-boot.h | 6 --- xen/arch/arm/setup.c | 4 ++ xen/arch/x86/efi/efi-boot.h | 72 ------------------------------------ xen/common/efi/boot.c | 74 ++++++++++++++++++++++++++++++++++++- xen/include/xen/vga.h | 2 +- 5 files changed, 78 insertions(+), 80 deletions(-) diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h index ae8627134e5a..17a3d46c59ae 100644 --- a/xen/arch/arm/efi/efi-boot.h +++ b/xen/arch/arm/efi/efi-boot.h @@ -1000,12 +1000,6 @@ static void __init efi_arch_console_init(UINTN cols, UINTN rows) { } -static void __init efi_arch_video_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, - UINTN info_size, - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info) -{ -} - static void __init efi_arch_flush_dcache_area(const void *vaddr, UINTN size) { __flush_dcache_area(vaddr, size); diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index d5d0792ed48a..a336ee58179c 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -71,6 +71,10 @@ static unsigned long opt_xenheap_megabytes __initdata; integer_param("xenheap_megabytes", opt_xenheap_megabytes); #endif +#ifndef CONFIG_VIDEO +struct xen_vga_console_info vga_console_info; +#endif + domid_t __read_mostly max_init_domid; static __used void init_done(void) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index f69509a2103a..cba3fa75a475 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -3,7 +3,6 @@ * is intended to be included by common/efi/boot.c _only_, and * therefore can define arch specific global variables. */ -#include #include #include #include @@ -497,77 +496,6 @@ static void __init efi_arch_console_init(UINTN cols, UINTN rows) #endif } -static void __init efi_arch_video_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, - UINTN info_size, - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info) -{ -#ifdef CONFIG_VIDEO - int bpp = 0; - - switch ( mode_info->PixelFormat ) - { - case PixelRedGreenBlueReserved8BitPerColor: - vga_console_info.u.vesa_lfb.red_pos = 0; - vga_console_info.u.vesa_lfb.red_size = 8; - vga_console_info.u.vesa_lfb.green_pos = 8; - vga_console_info.u.vesa_lfb.green_size = 8; - vga_console_info.u.vesa_lfb.blue_pos = 16; - vga_console_info.u.vesa_lfb.blue_size = 8; - vga_console_info.u.vesa_lfb.rsvd_pos = 24; - vga_console_info.u.vesa_lfb.rsvd_size = 8; - bpp = 32; - break; - case PixelBlueGreenRedReserved8BitPerColor: - vga_console_info.u.vesa_lfb.red_pos = 16; - vga_console_info.u.vesa_lfb.red_size = 8; - vga_console_info.u.vesa_lfb.green_pos = 8; - vga_console_info.u.vesa_lfb.green_size = 8; - vga_console_info.u.vesa_lfb.blue_pos = 0; - vga_console_info.u.vesa_lfb.blue_size = 8; - vga_console_info.u.vesa_lfb.rsvd_pos = 24; - vga_console_info.u.vesa_lfb.rsvd_size = 8; - bpp = 32; - break; - case PixelBitMask: - bpp = set_color(mode_info->PixelInformation.RedMask, bpp, - &vga_console_info.u.vesa_lfb.red_pos, - &vga_console_info.u.vesa_lfb.red_size); - bpp = set_color(mode_info->PixelInformation.GreenMask, bpp, - &vga_console_info.u.vesa_lfb.green_pos, - &vga_console_info.u.vesa_lfb.green_size); - bpp = set_color(mode_info->PixelInformation.BlueMask, bpp, - &vga_console_info.u.vesa_lfb.blue_pos, - &vga_console_info.u.vesa_lfb.blue_size); - if ( mode_info->PixelInformation.ReservedMask ) - bpp = set_color(mode_info->PixelInformation.ReservedMask, bpp, - &vga_console_info.u.vesa_lfb.rsvd_pos, - &vga_console_info.u.vesa_lfb.rsvd_size); - if ( bpp > 0 ) - break; - /* fall through */ - default: - PrintErr(L"Current graphics mode is unsupported!\r\n"); - bpp = 0; - break; - } - if ( bpp > 0 ) - { - vga_console_info.video_type = XEN_VGATYPE_EFI_LFB; - vga_console_info.u.vesa_lfb.gbl_caps = 2; /* possibly non-VGA */ - vga_console_info.u.vesa_lfb.width = - mode_info->HorizontalResolution; - vga_console_info.u.vesa_lfb.height = mode_info->VerticalResolution; - vga_console_info.u.vesa_lfb.bits_per_pixel = bpp; - vga_console_info.u.vesa_lfb.bytes_per_line = - (mode_info->PixelsPerScanLine * bpp + 7) >> 3; - vga_console_info.u.vesa_lfb.lfb_base = gop->Mode->FrameBufferBase; - vga_console_info.u.vesa_lfb.ext_lfb_base = gop->Mode->FrameBufferBase >> 32; - vga_console_info.u.vesa_lfb.lfb_size = - (gop->Mode->FrameBufferSize + 0xffff) >> 16; - } -#endif -} - static void __init efi_arch_memory_setup(void) { unsigned int i; diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 80e4e32623c4..2bc38ae40fff 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -20,6 +20,7 @@ #endif #include #include +#include #ifdef CONFIG_X86 /* * Keep this arch-specific modified include in the common file, as moving @@ -1025,6 +1026,77 @@ static void __init efi_get_apple_properties(void) } } +static void __init efi_video_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, + UINTN info_size, + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info) +{ +#if defined(CONFIG_VIDEO) || defined(CONFIG_ARM) + int bpp = 0; + + switch ( mode_info->PixelFormat ) + { + case PixelRedGreenBlueReserved8BitPerColor: + vga_console_info.u.vesa_lfb.red_pos = 0; + vga_console_info.u.vesa_lfb.red_size = 8; + vga_console_info.u.vesa_lfb.green_pos = 8; + vga_console_info.u.vesa_lfb.green_size = 8; + vga_console_info.u.vesa_lfb.blue_pos = 16; + vga_console_info.u.vesa_lfb.blue_size = 8; + vga_console_info.u.vesa_lfb.rsvd_pos = 24; + vga_console_info.u.vesa_lfb.rsvd_size = 8; + bpp = 32; + break; + case PixelBlueGreenRedReserved8BitPerColor: + vga_console_info.u.vesa_lfb.red_pos = 16; + vga_console_info.u.vesa_lfb.red_size = 8; + vga_console_info.u.vesa_lfb.green_pos = 8; + vga_console_info.u.vesa_lfb.green_size = 8; + vga_console_info.u.vesa_lfb.blue_pos = 0; + vga_console_info.u.vesa_lfb.blue_size = 8; + vga_console_info.u.vesa_lfb.rsvd_pos = 24; + vga_console_info.u.vesa_lfb.rsvd_size = 8; + bpp = 32; + break; + case PixelBitMask: + bpp = set_color(mode_info->PixelInformation.RedMask, bpp, + &vga_console_info.u.vesa_lfb.red_pos, + &vga_console_info.u.vesa_lfb.red_size); + bpp = set_color(mode_info->PixelInformation.GreenMask, bpp, + &vga_console_info.u.vesa_lfb.green_pos, + &vga_console_info.u.vesa_lfb.green_size); + bpp = set_color(mode_info->PixelInformation.BlueMask, bpp, + &vga_console_info.u.vesa_lfb.blue_pos, + &vga_console_info.u.vesa_lfb.blue_size); + if ( mode_info->PixelInformation.ReservedMask ) + bpp = set_color(mode_info->PixelInformation.ReservedMask, bpp, + &vga_console_info.u.vesa_lfb.rsvd_pos, + &vga_console_info.u.vesa_lfb.rsvd_size); + if ( bpp > 0 ) + break; + /* fall through */ + default: + PrintErr(L"Current graphics mode is unsupported!\r\n"); + bpp = 0; + break; + } + if ( bpp > 0 ) + { + vga_console_info.video_type = XEN_VGATYPE_EFI_LFB; + vga_console_info.u.vesa_lfb.gbl_caps = 2; /* possibly non-VGA */ + vga_console_info.u.vesa_lfb.width = + mode_info->HorizontalResolution; + vga_console_info.u.vesa_lfb.height = mode_info->VerticalResolution; + vga_console_info.u.vesa_lfb.bits_per_pixel = bpp; + vga_console_info.u.vesa_lfb.bytes_per_line = + (mode_info->PixelsPerScanLine * bpp + 7) >> 3; + vga_console_info.u.vesa_lfb.lfb_base = gop->Mode->FrameBufferBase; + vga_console_info.u.vesa_lfb.ext_lfb_base = gop->Mode->FrameBufferBase >> 32; + vga_console_info.u.vesa_lfb.lfb_size = + (gop->Mode->FrameBufferSize + 0xffff) >> 16; + } +#endif +} + static void __init efi_set_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, UINTN gop_mode) { EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; @@ -1042,7 +1114,7 @@ static void __init efi_set_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, UINTN gop /* Get graphics and frame buffer info. */ status = gop->QueryMode(gop, gop->Mode->Mode, &info_size, &mode_info); if ( !EFI_ERROR(status) ) - efi_arch_video_init(gop, info_size, mode_info); + efi_video_init(gop, info_size, mode_info); } #define INVALID_VIRTUAL_ADDRESS (0xBAAADUL << \ diff --git a/xen/include/xen/vga.h b/xen/include/xen/vga.h index f72b63d446b1..39b4c2eae198 100644 --- a/xen/include/xen/vga.h +++ b/xen/include/xen/vga.h @@ -11,7 +11,7 @@ #include -#ifdef CONFIG_VGA +#if defined(CONFIG_VGA) || defined(CONFIG_ARM) extern struct xen_vga_console_info vga_console_info; #endif From patchwork Sun Feb 6 19:28:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12736678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1E90C433FE for ; Sun, 6 Feb 2022 19:29:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.266316.460017 (Exim 4.92) (envelope-from ) id 1nGnDP-0002Lo-V2; Sun, 06 Feb 2022 19:28:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 266316.460017; Sun, 06 Feb 2022 19:28:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nGnDP-0002Lf-Qg; Sun, 06 Feb 2022 19:28:51 +0000 Received: by outflank-mailman (input) for mailman id 266316; Sun, 06 Feb 2022 19:28:50 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nGnDO-0002J7-OM for xen-devel@lists.xenproject.org; Sun, 06 Feb 2022 19:28:50 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nGnDM-0005t8-Ch; Sun, 06 Feb 2022 19:28:48 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nGnDM-0007Ok-4h; Sun, 06 Feb 2022 19:28:48 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=dwa+CM0UGV4Uyu3tQxS0S6kaMZiyK2FzF7bR+EHTABc=; b=ppyd+fukvMObK1Y2M4+VtmDg6w 3E8oAypWDgoe7HSHp252yR2ftQtXhjHOYNlRTy4MoqwvT51uHuVZLl9dB/ukzZCJH1NS+SvloMmQd Ptj9JPP1BFMPwyEdx/+W+vz5LmL8AvDtspb/bndh37q80j1sTFckn+2CWLZiMNoCFwdU=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: ehem+xen@m5p.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu Subject: [PATCH RFC 3/3] xen: Introduce a platform sub-op to retrieve the VGA information Date: Sun, 6 Feb 2022 19:28:39 +0000 Message-Id: <20220206192839.75711-4-julien@xen.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220206192839.75711-1-julien@xen.org> References: <20220206192839.75711-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall When using EFI, the VGA information is fetched using the EFI boot services. However, Xen will have exited the boot services. Therefore, we need to find a different way to pass the information to dom0. For PV dom0, they are part of the start_info. But this is not something that exists on Arm. So the best way would to be to use a hypercall. For now the structure layout is based on dom0_vga_console_info for convenience. I am open on another proposal. Signed-off-by: Julien Grall ---- TODO: - Check the structure size has not changed (I would like to avoid bumping the platform interface). --- xen/arch/arm/platform_hypercall.c | 15 +++++++++++++++ xen/include/public/platform.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/xen/arch/arm/platform_hypercall.c b/xen/arch/arm/platform_hypercall.c index 8efac7ee602a..78ad328e2ab8 100644 --- a/xen/arch/arm/platform_hypercall.c +++ b/xen/arch/arm/platform_hypercall.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,20 @@ long do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op) ret = -EINVAL; break; + case XENPF_firmware_info: + switch ( op->u.firmware_info.type ) + { + case XEN_FW_VGA_INFO: + BUILD_BUG_ON(sizeof(op->u.firmware_info.u.vga) != + sizeof(vga_console_info)); + memcpy(&op->u.firmware_info.u.vga, &vga_console_info, + sizeof(vga_console_info)); + if ( __copy_to_guest(u_xenpf_op, op, 1) ) + ret = -EFAULT; + break; + } + break; + default: ret = -ENOSYS; break; diff --git a/xen/include/public/platform.h b/xen/include/public/platform.h index a4c0eb62249a..4de42ce6cbc5 100644 --- a/xen/include/public/platform.h +++ b/xen/include/public/platform.h @@ -244,6 +244,7 @@ DEFINE_XEN_GUEST_HANDLE(xenpf_efi_runtime_call_t); #define XEN_FW_EFI_PCI_ROM 5 #define XEN_FW_EFI_APPLE_PROPERTIES 6 #define XEN_FW_KBD_SHIFT_FLAGS 5 +#define XEN_FW_VGA_INFO 6 struct xenpf_firmware_info { /* IN variables. */ uint32_t type; @@ -311,6 +312,7 @@ struct xenpf_firmware_info { /* Int16, Fn02: Get keyboard shift flags. */ uint8_t kbd_shift_flags; /* XEN_FW_KBD_SHIFT_FLAGS */ + struct dom0_vga_console_info vga; } u; }; typedef struct xenpf_firmware_info xenpf_firmware_info_t;