Skip to content

Commit 7a18b04

Browse files
MrChromeboxjackpot51
authored andcommitted
drivers/intel/gma: Fix alignment of extended VBT in opregion
Intel's reference implementation in Slimbootloader pads the area allocated for the extended VBT to the nearest 512-byte boundary, which strongly suggests that the Windows driver expects the same. TEST=build/boot Linux 6.9, Win11 on starlabs/starlite_adl, verify VBT read properly by OS. Change-Id: Ib3784eea6eb929ffec9672fc123b833c11c057e8 Signed-off-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/86275 Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
1 parent e59db8f commit 7a18b04

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/drivers/intel/gma/opregion.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static inline bool uses_relative_vbt_addr(opregion_header_t *header)
287287
* values correctly for the opregion.
288288
*/
289289
static void opregion_add_ext_vbt(igd_opregion_t *opregion, uint8_t *ext_vbt,
290-
optionrom_vbt_t *vbt)
290+
optionrom_vbt_t *vbt, size_t ext_vbt_size)
291291
{
292292
opregion_header_t *header = &opregion->header;
293293
/* Copy VBT into extended VBT region (at offset 8 KiB) */
@@ -301,7 +301,7 @@ static void opregion_add_ext_vbt(igd_opregion_t *opregion, uint8_t *ext_vbt,
301301
else
302302
opregion->mailbox3.rvda = (uintptr_t)ext_vbt;
303303

304-
opregion->mailbox3.rvds = vbt->hdr_vbt_size;
304+
opregion->mailbox3.rvds = ext_vbt_size;
305305
}
306306

307307
/* Initialize IGD OpRegion, called from ACPI code and OS drivers */
@@ -311,6 +311,7 @@ enum cb_err intel_gma_init_igd_opregion(void)
311311
struct region_device rdev;
312312
optionrom_vbt_t *vbt = NULL;
313313
size_t opregion_size = sizeof(igd_opregion_t);
314+
size_t ext_vbt_size;
314315

315316
if (acpi_is_wakeup_s3())
316317
return intel_gma_restore_opregion();
@@ -331,7 +332,9 @@ enum cb_err intel_gma_init_igd_opregion(void)
331332
}
332333

333334
/* Add the space for the extended VBT header even if it's not used */
334-
opregion_size += vbt->hdr_vbt_size;
335+
/* Align the VBT to nearest 512 byte boundary */
336+
ext_vbt_size = ALIGN_UP(vbt->hdr_vbt_size, 512);
337+
opregion_size += ext_vbt_size;
335338

336339
opregion = cbmem_add(CBMEM_ID_IGD_OPREGION, opregion_size);
337340
if (!opregion) {
@@ -353,7 +356,7 @@ enum cb_err intel_gma_init_igd_opregion(void)
353356
if (is_ext_vbt_required(opregion, vbt)) {
354357
/* Place extended VBT just after opregion */
355358
uint8_t *ext_vbt = (uint8_t *)opregion + sizeof(*opregion);
356-
opregion_add_ext_vbt(opregion, ext_vbt, vbt);
359+
opregion_add_ext_vbt(opregion, ext_vbt, vbt, ext_vbt_size);
357360
} else {
358361
/* Raw VBT size which can fit in gvd1 */
359362
memcpy(opregion->vbt.gvd1, vbt, vbt->hdr_vbt_size);

0 commit comments

Comments
 (0)