Skip to contentSkip to conversation

xen/x86: obtain upper 32 bits of video frame buffer address for Dom0

PATCH Applied Jan Beulich 3 participants 7 messages Jan 4, 2022 – Jan 7, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/x86: obtain upper 32 bits of video frame buffer address for Dom0

The hypervisor has been supplying this information for a couple of major releases. Make use of it. The need to set a flag in the capabilities field also points out that the prior setting of that field from the hypervisor interface's gbl_caps one was wrong, so that code gets deleted (there's also no equivalent of this in native boot code).

arch/x86/xen/vga.c +8 -4
@@ -63,13 +63,17 @@ void __init xen_init_vga(const struct do
 		}
 
 		if (size >= offsetof(struct dom0_vga_console_info,
-				     u.vesa_lfb.gbl_caps)
-		    + sizeof(info->u.vesa_lfb.gbl_caps))
-			screen_info->capabilities = info->u.vesa_lfb.gbl_caps;
-		if (size >= offsetof(struct dom0_vga_console_info,
 				     u.vesa_lfb.mode_attrs)
 		    + sizeof(info->u.vesa_lfb.mode_attrs))
 			screen_info->vesa_attributes = info->u.vesa_lfb.mode_attrs;
+
+		if (size >= offsetof(struct dom0_vga_console_info,
+				     u.vesa_lfb.ext_lfb_base)
+		    + sizeof(info->u.vesa_lfb.ext_lfb_base)
+		    && info->u.vesa_lfb.ext_lfb_base) {
+			screen_info->ext_lfb_base = info->u.vesa_lfb.ext_lfb_base;
+			screen_info->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
+		}
 		break;
 	}
 }
include/xen/interface/xen.h +3 -0
@@ -722,6 +722,9 @@ struct dom0_vga_console_info {
 			uint32_t gbl_caps;
 			/* Mode attributes (offset 0x0, VESA command 0x4f01). */
 			uint16_t mode_attrs;
+			uint16_t pad;
+			/* high 32 bits of lfb_base */
+			uint32_t ext_lfb_base;
 		} vesa_lfb;
 	} u;
 };
#1 lore raw
Quoted 11 lines · Jan Beulich

The hypervisor has been supplying this information for a couple of major releases. Make use of it. The need to set a flag in the capabilities field also points out that the prior setting of that field from the hypervisor interface's gbl_caps one was wrong, so that code gets deleted (there's also no equivalent of this in native boot code).

arch/x86/xen/vga.c void __init xen_init_vga(const struct do · line 67

Quoted 9 lines
arch/x86/xen/vga.c +0 -4
@@ -63,13 +63,17 @@ void __init xen_init_vga(const struct do
  		}
 
  		if (size >= offsetof(struct dom0_vga_console_info,
-				     u.vesa_lfb.gbl_caps)
-		    + sizeof(info->u.vesa_lfb.gbl_caps))
-			screen_info->capabilities = info->u.vesa_lfb.gbl_caps;
-		if (size >= offsetof(struct dom0_vga_console_info,
  				     u.vesa_lfb.mode_attrs)
  		    + sizeof(info->u.vesa_lfb.mode_attrs))

Do we still need this test? All 4.0+ hypervisors will have mode_attrs.

-boris

Quoted 25 lines
arch/x86/xen/vga.c +8 -0
  			screen_info->vesa_attributes = info->u.vesa_lfb.mode_attrs;
+
+		if (size >= offsetof(struct dom0_vga_console_info,
+				     u.vesa_lfb.ext_lfb_base)
+		    + sizeof(info->u.vesa_lfb.ext_lfb_base)
+		    && info->u.vesa_lfb.ext_lfb_base) {
+			screen_info->ext_lfb_base = info->u.vesa_lfb.ext_lfb_base;
+			screen_info->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
+		}
  		break;
  	}
  }
include/xen/interface/xen.h +3 -0
@@ -722,6 +722,9 @@ struct dom0_vga_console_info {
  			uint32_t gbl_caps;
  			/* Mode attributes (offset 0x0, VESA command 0x4f01). */
  			uint16_t mode_attrs;
+			uint16_t pad;
+			/* high 32 bits of lfb_base */
+			uint32_t ext_lfb_base;
  		} vesa_lfb;
  	} u;
  };
#2 lore raw
Quoted 15 lines · Boris Ostrovsky
Quoted 13 lines · Jan Beulich

The hypervisor has been supplying this information for a couple of major releases. Make use of it. The need to set a flag in the capabilities field also points out that the prior setting of that field from the hypervisor interface's gbl_caps one was wrong, so that code gets deleted (there's also no equivalent of this in native boot code).

arch/x86/xen/vga.c +0 -0
@@ -63,13 +63,17 @@ void __init xen_init_vga(const struct do
  		}
 
Quoted 10 lines

arch/x86/xen/vga.c void __init xen_init_vga(const struct do · line 67

Quoted 7 lines
arch/x86/xen/vga.c +0 -4
  		if (size >= offsetof(struct dom0_vga_console_info,
-				     u.vesa_lfb.gbl_caps)
-		    + sizeof(info->u.vesa_lfb.gbl_caps))
-			screen_info->capabilities = info->u.vesa_lfb.gbl_caps;
-		if (size >= offsetof(struct dom0_vga_console_info,
  				     u.vesa_lfb.mode_attrs)
  		    + sizeof(info->u.vesa_lfb.mode_attrs))

Do we still need this test? All 4.0+ hypervisors will have mode_attrs.

Perhaps this could also be dropped, but unlike the capabilities part I'd view this as an unrelated change. Furthermore even a new hypervisor would be free to omit the field, provided it also sets size low enough.

Jan

#3 lore raw
Quoted 24 lines · Jan Beulich
Quoted 14 lines · Boris Ostrovsky
Quoted 13 lines · Jan Beulich

The hypervisor has been supplying this information for a couple of major releases. Make use of it. The need to set a flag in the capabilities field also points out that the prior setting of that field from the hypervisor interface's gbl_caps one was wrong, so that code gets deleted (there's also no equivalent of this in native boot code).

arch/x86/xen/vga.c +0 -0
@@ -63,13 +63,17 @@ void __init xen_init_vga(const struct do
   		}
 
Quoted 9 lines

arch/x86/xen/vga.c void __init xen_init_vga(const struct do · line 67

Quoted 7 lines
arch/x86/xen/vga.c +0 -4
   		if (size >= offsetof(struct dom0_vga_console_info,
-				     u.vesa_lfb.gbl_caps)
-		    + sizeof(info->u.vesa_lfb.gbl_caps))
-			screen_info->capabilities = info->u.vesa_lfb.gbl_caps;
-		if (size >= offsetof(struct dom0_vga_console_info,
   				     u.vesa_lfb.mode_attrs)
   		    + sizeof(info->u.vesa_lfb.mode_attrs))

Do we still need this test? All 4.0+ hypervisors will have mode_attrs.

Quoted 2 lines

Perhaps this could also be dropped, but unlike the capabilities part I'd view this as an unrelated change.

Right.

Quoted 2 lines

Furthermore even a new hypervisor
would be free to omit the field, provided it also sets size low enough.

If this is allowed, how would we deal with hypervisor dropping some other random field here? Have we had a precedent of this happening?

I think it's safe to drop these checks. In fact, most of them in this function (except for the last one, obviously).

-boris

#4 lore raw
Quoted 30 lines · Boris Ostrovsky
Quoted 24 lines · Jan Beulich
Quoted 14 lines · Boris Ostrovsky
Quoted 13 lines · Jan Beulich

The hypervisor has been supplying this information for a couple of major releases. Make use of it. The need to set a flag in the capabilities field also points out that the prior setting of that field from the hypervisor interface's gbl_caps one was wrong, so that code gets deleted (there's also no equivalent of this in native boot code).

arch/x86/xen/vga.c +0 -0
@@ -63,13 +63,17 @@ void __init xen_init_vga(const struct do
   		}
 
Quoted 9 lines

arch/x86/xen/vga.c void __init xen_init_vga(const struct do · line 67

Quoted 7 lines
arch/x86/xen/vga.c +0 -4
   		if (size >= offsetof(struct dom0_vga_console_info,
-				     u.vesa_lfb.gbl_caps)
-		    + sizeof(info->u.vesa_lfb.gbl_caps))
-			screen_info->capabilities = info->u.vesa_lfb.gbl_caps;
-		if (size >= offsetof(struct dom0_vga_console_info,
   				     u.vesa_lfb.mode_attrs)
   		    + sizeof(info->u.vesa_lfb.mode_attrs))

Do we still need this test? All 4.0+ hypervisors will have mode_attrs.

Quoted 2 lines

Perhaps this could also be dropped, but unlike the capabilities part I'd view this as an unrelated change.

Quoted 8 lines

Right.

Quoted 2 lines

Furthermore even a new hypervisor
would be free to omit the field, provided it also sets size low enough.

If this is allowed, how would we deal with hypervisor dropping some other random field here?

Random fields can't be dropped, or very old Dom0 kernels might break. It's only the "extensions" that have been added later which we can expect consumers to properly deal with (by checking whether they're covered by the supplied size).

Quoted 1 line

Have we had a precedent of this happening?

No. But doing so wouldn't violate the ABI.

Anyway - I'd appreciate if the patch at hand could be taken independent of possible further adjustments here, as it addresses an issue observed in the field.

Jan

reviewer Reviewed-by
#5 lore raw
Quoted 4 lines · Jan Beulich

Anyway - I'd appreciate if the patch at hand could be taken independent of possible further adjustments here, as it addresses an issue observed in the field.

maintainer Applied
#6 lore raw
In reply to Jan Beulich
Quoted 7 lines · Jan Beulich

The hypervisor has been supplying this information for a couple of major releases. Make use of it. The need to set a flag in the capabilities field also points out that the prior setting of that field from the hypervisor interface's gbl_caps one was wrong, so that code gets deleted (there's also no equivalent of this in native boot code).

Pushed to xen/tip.git for-linus-5.17

Juergen