Xen-Devel Archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/platform: make XENPF_get_dom0_console actually usable
@ 2023-02-13 14:51 Jan Beulich
  2023-02-14  7:21 ` Jan Beulich
  2023-03-13 13:45 ` Roger Pau Monné
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2023-02-13 14:51 UTC (permalink / raw
  To: xen-devel@lists.xenproject.org
  Cc: Andrew Cooper, Wei Liu, Roger Pau Monné

struct dom0_vga_console_info has been extended in the past, and it may
be extended again. The use in PV Dom0's start info already covers for
that by supplying the size of the provided data. For the recently
introduced platform-op size needs providing similarly. Go the easiest
available route and simply supply size via the hypercall return value.

While there also add a build-time check that possibly future growth of
the struct won't affect xen_platform_op_t's size.

Fixes: 4dd160583c79 ("x86/platform: introduce hypercall to get initial video console settings")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Noticed while trying to actually use the new hypercall in Linux.

--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -841,6 +841,8 @@ ret_t do_platform_op(
 
 #ifdef CONFIG_VIDEO
     case XENPF_get_dom0_console:
+        BUILD_BUG_ON(sizeof(op->u.dom0_console) > sizeof(op->u.pad));
+        ret = sizeof(op->u.dom0_console);
         if ( !fill_console_start_info(&op->u.dom0_console) )
         {
             ret = -ENODEV;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/platform: make XENPF_get_dom0_console actually usable
  2023-02-13 14:51 [PATCH] x86/platform: make XENPF_get_dom0_console actually usable Jan Beulich
@ 2023-02-14  7:21 ` Jan Beulich
  2023-03-13 13:45 ` Roger Pau Monné
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2023-02-14  7:21 UTC (permalink / raw
  To: xen-devel@lists.xenproject.org
  Cc: Andrew Cooper, Wei Liu, Roger Pau Monné

On 13.02.2023 15:51, Jan Beulich wrote:
> struct dom0_vga_console_info has been extended in the past, and it may
> be extended again. The use in PV Dom0's start info already covers for
> that by supplying the size of the provided data. For the recently
> introduced platform-op size needs providing similarly. Go the easiest
> available route and simply supply size via the hypercall return value.
> 
> While there also add a build-time check that possibly future growth of
> the struct won't affect xen_platform_op_t's size.
> 
> Fixes: 4dd160583c79 ("x86/platform: introduce hypercall to get initial video console settings")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> Noticed while trying to actually use the new hypercall in Linux.
> 
> --- a/xen/arch/x86/platform_hypercall.c
> +++ b/xen/arch/x86/platform_hypercall.c
> @@ -841,6 +841,8 @@ ret_t do_platform_op(
>  
>  #ifdef CONFIG_VIDEO
>      case XENPF_get_dom0_console:
> +        BUILD_BUG_ON(sizeof(op->u.dom0_console) > sizeof(op->u.pad));
> +        ret = sizeof(op->u.dom0_console);
>          if ( !fill_console_start_info(&op->u.dom0_console) )
>          {
>              ret = -ENODEV;
> 

Thinking about it, I've added the hunk below.

Jan

--- a/xen/include/public/platform.h
+++ b/xen/include/public/platform.h
@@ -605,7 +605,11 @@ struct xenpf_symdata {
 typedef struct xenpf_symdata xenpf_symdata_t;
 DEFINE_XEN_GUEST_HANDLE(xenpf_symdata_t);
 
-/* Fetch the video console information and mode setup by Xen. */
+/*
+ * Fetch the video console information and mode setup by Xen.  A non-
+ * negative return value indicates the size of the (part of the) structure
+ * which was filled.
+ */
 #define XENPF_get_dom0_console 64
 typedef struct dom0_vga_console_info xenpf_dom0_console_t;
 DEFINE_XEN_GUEST_HANDLE(xenpf_dom0_console_t);



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/platform: make XENPF_get_dom0_console actually usable
  2023-02-13 14:51 [PATCH] x86/platform: make XENPF_get_dom0_console actually usable Jan Beulich
  2023-02-14  7:21 ` Jan Beulich
@ 2023-03-13 13:45 ` Roger Pau Monné
  1 sibling, 0 replies; 3+ messages in thread
From: Roger Pau Monné @ 2023-03-13 13:45 UTC (permalink / raw
  To: Jan Beulich; +Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Wei Liu

On Mon, Feb 13, 2023 at 03:51:50PM +0100, Jan Beulich wrote:
> struct dom0_vga_console_info has been extended in the past, and it may
> be extended again. The use in PV Dom0's start info already covers for
> that by supplying the size of the provided data. For the recently
> introduced platform-op size needs providing similarly. Go the easiest
> available route and simply supply size via the hypercall return value.
> 
> While there also add a build-time check that possibly future growth of
> the struct won't affect xen_platform_op_t's size.
> 
> Fixes: 4dd160583c79 ("x86/platform: introduce hypercall to get initial video console settings")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Roger Pau Monné <roger.pau@citrix.com>

With the added comment.

Thanks, Roger.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-13 13:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-13 14:51 [PATCH] x86/platform: make XENPF_get_dom0_console actually usable Jan Beulich
2023-02-14  7:21 ` Jan Beulich
2023-03-13 13:45 ` Roger Pau Monné

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).