All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
	"community.manager@xenproject.org"
	<community.manager@xenproject.org>,
	Henry Wang <Henry.Wang@arm.com>
Subject: Re: [PATCH v4 1/8] x86/boot: make "vga=current" work with graphics modes
Date: Mon, 4 Apr 2022 16:49:28 +0200	[thread overview]
Message-ID: <YksFeCB3bcXBGfDe@Air-de-Roger> (raw)
In-Reply-To: <3fb7f3e9-a6cf-4f8e-1141-100848b1bdd0@suse.com>

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@suse.com>
> ---
> 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.


  reply	other threads:[~2022-04-04 14:50 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31  9:42 [PATCH v4 0/8] x86/boot: (mostly) video mode handling adjustments Jan Beulich
2022-03-31  9:44 ` [PATCH v4 1/8] x86/boot: make "vga=current" work with graphics modes Jan Beulich
2022-04-04 14:49   ` Roger Pau Monné [this message]
2022-04-04 15:50     ` Jan Beulich
2022-04-05  8:24       ` Roger Pau Monné
2022-04-05  8:36         ` Jan Beulich
2022-04-05  8:45   ` Roger Pau Monné
2022-04-06 14:23     ` Jan Beulich
2022-04-11  9:50       ` Ping: " Jan Beulich
2022-04-11 10:11         ` Henry Wang
2022-04-11 10:14           ` Jan Beulich
2022-04-11 10:30             ` Henry Wang
2022-03-31  9:45 ` [PATCH v4 2/8] x86/boot: obtain video info from boot loader Jan Beulich
2022-04-05  9:35   ` Roger Pau Monné
2022-04-05 10:57     ` Jan Beulich
2022-04-05 11:34       ` Roger Pau Monné
2022-03-31  9:45 ` [PATCH v4 3/8] x86/EFI: retrieve EDID Jan Beulich
2022-04-01 10:15   ` Luca Fancellu
2022-04-05 10:27   ` Roger Pau Monné
2022-04-05 14:36     ` Jan Beulich
2022-04-05 15:47       ` Roger Pau Monné
2022-04-06  8:44         ` Jan Beulich
2022-04-06  9:34           ` Roger Pau Monné
2022-04-06 12:40             ` Jan Beulich
2022-04-06 14:14               ` Roger Pau Monné
2022-04-06 14:21                 ` Jan Beulich
2022-04-06 14:24   ` Jan Beulich
2022-04-06 14:34   ` Bertrand Marquis
2022-03-31  9:48 ` [PATCH v4 4/8] x86/boot: simplify mode_table Jan Beulich
2022-04-05 10:44   ` Roger Pau Monné
2022-03-31  9:49 ` [PATCH v4 5/8] x86/boot: fold branches in video handling code Jan Beulich
2022-04-05 10:55   ` Roger Pau Monné
2022-03-31  9:50 ` [PATCH v4 6/8] x86/boot: fold/replace moves " Jan Beulich
2022-04-05 11:13   ` Roger Pau Monné
2022-03-31  9:50 ` [PATCH v4 7/8] x86/boot: LEA -> MOV " Jan Beulich
2022-04-05 11:28   ` Roger Pau Monné
2022-03-31  9:51 ` [PATCH v4 8/8] x86/boot: fold two MOVs into an ADD Jan Beulich
2022-04-05 11:29   ` Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YksFeCB3bcXBGfDe@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=Henry.Wang@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=community.manager@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.