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

Re: [PATCH v4 1/8] x86/boot: make "vga=current" work with graphics modes


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 4 Apr 2022 16:49:28 +0200
  • 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=cY2/U7HQ2GVDu9OVSig0xymFmXpVMQst6H3h4SZSRNs=; b=NRjfuelYNyX/ivTwdVb5RyM3Uj1suCqYgmEyEL/++OC6jWlM64ISg03ISHrX6LmHaFua450Q+ir7wYvU0fwQDduc84cNN0VnhoBFE+ao6xg/0Hfovyq2C5oQRiLp3HpBvnOU3Qf+Ys2OVJKdA6SmQef9z8OjBmmHQErUJRXlCD1ZlXWoTQTaDxyDGRANmboVT7sproc8FPVaBS7j5iRfKTw8XlkvuXsOYIRiiBA9Nk9wx2uqYw6SoYTvN01P3JIzPVDzpaQueVDjFrfZqyhWhyriNUO2Vw59BWBl7xMOkTvEeHNylZ+ZiH+IWNxsTMvBRfBHXwRsZZgA8HvG0igvrA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HhMUoAXA0GiQII/q2iV+qMo3gCzNwwdxtMXHz/1x7R14iEaivL7s/ROl42DaHMNE1eivZncXGf941KrpGXE4qiRZ2Uuy1qBaC+oFrNCJA1vSwvJURgl6xPu7di4sOOk3vphmC8shZivQ3IzD0DOJ39khymltUkAZaluaqi/IoM7F3ZFsTjBjFL63JLd5p55KQkVYbxn1A352XE4HVZFoaoGf1LwgVBlpUnzZNX2GDvOu0Cgu2n/lN4N+hKIG9r0jwb1kPc4F45ZhrrY9GZIbgxTncPcgyad4UVYvIY6knxlSfBYzl2h8ga0GDeAv8KCNC69IFkdszLmkDIWtixTmtg==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "community.manager@xxxxxxxxxxxxxx" <community.manager@xxxxxxxxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Mon, 04 Apr 2022 14:49:49 +0000
  • Ironport-data: A9a23:KgcvaarCkYbTKMgHIX2Yv3Q23KteBmLVZRIvgKrLsJaIsI4StFCzt garIBnSOPeIMGD3L992Ydyy8B4Cu57TytBqTlZvqn0xEH8U8ZuZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlVEliefQAOCU5NfsYkidfyc9IMsaoU8lyrZRbrJA24DjWVvR4 Y+q+qUzBXf+s9JKGjNMg068gEsHUMTa4Fv0aXRnOJinFHeH/5UkJMp3yZOZdhMUcaENdgKOf M7RzanRw4/s10xF5uVJMFrMWhZirrb6ZWBig5fNMkSoqkAqSicais7XOBeAAKv+Zvrgc91Zk b1wWZKMpQgBLrDmmrwgU0RjTDxSNq5U/ILKClySvpnGp6HGWyOEL/RGCUg3OcsT+/ptAHEI/ vsdQNwPRknd3aTsmuv9E7QywJR4RCXoFNp3VnVI1zbWAOxgWZnea67L+cVZzHE7gcUm8fP2O ZVINGMzN0uojxtnHQg0GcJkoOOToHDBKz99uH+viow67D2GpOB2+Oe0a4eEEjCQfu1emUOdu 2TH43W/BxgcPdOS0xKV/3S0nOjNkCjnHoUIG9WQ1vNsmkzV+WUVBzUfT179qv684mahX/pPJ kpS/TA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/UUlWZjXYwXb6IUhZAD/XlSDIwLEEvBmc0a+d FVfY/hDcttABKnhyizhBgu/DXsZAV4Iv6+eDlMhiTPuAIm30yQzCMjtbkidzk7hdAAoqJ/lp T525RT5cBzp/AtHNFA7cc6MLyK4z/2MGTx2Fz7GyWUKEhAAQOJl6LK
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Mar 31, 2022 at 11:44:10AM +0200, Jan Beulich wrote:
> GrUB2 can be told to leave the screen in the graphics mode it has been
> using (or any other one), via "set gfxpayload=keep" (or suitable
> variants thereof). In this case we can avoid doing another mode switch
> ourselves. This in particular avoids possibly setting the screen to a
> less desirable mode: On one of my test systems the set of modes
> reported available by the VESA BIOS depends on whether the interposed
> KVM switch has that machine set as the active one. If it's not active,
> only modes up to 1024x768 get reported, while when active 1280x1024
> modes are also included. For things to always work with an explicitly
> specified mode (via the "vga=" option), that mode therefore needs be a
> 1024x768 one.
> 
> For some reason this only works for me with "multiboot2" (and
> "module2"); "multiboot" (and "module") still forces the screen into text
> mode, despite my reading of the sources suggesting otherwise.
> 
> For starters I'm limiting this to graphics modes; I do think this ought
> to also work for text modes, but
> - I can't tell whether GrUB2 can set any text mode other than 80x25
>   (I've only found plain "text" to be valid as a "gfxpayload" setting),
> - I'm uncertain whether supporting that is worth it, since I'm uncertain
>   how many people would be running their systems/screens in text mode,
> - I'd like to limit the amount of code added to the realmode trampoline.
> 
> For starters I'm also limiting mode information retrieval to raw BIOS
> accesses. This will allow things to work (in principle) also with other
> boot environments where a graphics mode can be left in place. The
> downside is that this then still is dependent upon switching back to
> real mode, so retrieving the needed information from multiboot info is
> likely going to be desirable down the road.

I'm unsure, what's the benefit from retrieving this information from
the VESA blob rather than from multiboot(2) structures?

Is it because we require a VESA mode to be set before we parse the
multiboot information?

> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> I'm not convinced boot_vid_mode really needs setting here; I'm doing so
> mainly because setvesabysize also does.
> ---
> v4: Add changelog entry.
> v2: Use 0x9b instead of 0x99 for attributes check: I think the value
>     used by check_vesa also wants to be converted, to match vesa2's.
>     (Perhaps the value wants to become a #define, albeit before doing so
>     I'd question the requirement of the mode to be a color one.)
> 
> --- a/CHANGELOG.md
> +++ b/CHANGELOG.md
> @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog
>  
>  ## [unstable 
> UNRELEASED](https://xenbits.xen.org/gitweb/?p=xen.git;a=shortlog;h=staging) - 
> TBD
>  
> +### Changed
> + - On x86 "vga=current" can now be used together with GrUB2's gfxpayload 
> setting. Note that
> +   this requires use of "multiboot2" (and "module2") as the GrUB commands 
> loading Xen.
> +
>  ### Removed / support downgraded
>   - dropped support for the (x86-only) "vesa-mtrr" and "vesa-remap" command 
> line options
>  
> --- a/xen/arch/x86/boot/video.S
> +++ b/xen/arch/x86/boot/video.S
> @@ -575,7 +575,6 @@ set14:  movw    $0x1111, %ax
>          movb    $0x01, %ah              # Define cursor scan lines 11-12
>          movw    $0x0b0c, %cx
>          int     $0x10
> -set_current:
>          stc
>          ret
>  
> @@ -693,6 +692,39 @@ vga_modes:
>          .word   VIDEO_80x60, 0x50,0x3c,0        # 80x60
>  vga_modes_end:
>  
> +# If the current mode is a VESA graphics one, obtain its parameters.
> +set_current:
> +        leaw    vesa_glob_info, %di
> +        movw    $0x4f00, %ax
> +        int     $0x10
> +        cmpw    $0x004f, %ax
> +        jne     .Lsetc_done

You don't seem to make use of the information fetched here? I guess
this is somehow required to access the other functions?

> +        movw    $0x4f03, %ax

It would help readability to have defines for those values, ie:
VESA_GET_CURRENT_MODE or some such (not that you need to do it here,
just a comment).

> +        int     $0x10
> +        cmpw    $0x004f, %ax
> +        jne     .Lsetc_done
> +
> +        leaw    vesa_mode_info, %di     # Get mode information structure
> +        movw    %bx, %cx
> +        movw    $0x4f01, %ax
> +        int     $0x10
> +        cmpw    $0x004f, %ax
> +        jne     .Lsetc_done
> +
> +        movb    (%di), %al              # Check mode attributes
> +        andb    $0x9b, %al
> +        cmpb    $0x9b, %al

So you also check that the reserved D1 bit is set to 1 as mandated by
the spec. This is slightly different than what's done in check_vesa,
would you mind adding a define for this an unifying with check_vesa?

Thanks, Roger.



 


Rackspace

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