Skip to content

Commit 96f28bc

Browse files
David Vrabelkonradwilk
authored andcommitted
x86/xen: populate boot_params with EDD data
During early setup of a dom0 kernel, populate boot_params with the Enhanced Disk Drive (EDD) and MBR signature data. This makes information on the BIOS boot device available in /sys/firmware/edd/. Signed-off-by: David Vrabel <david.vrabel@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
1 parent 31880c3 commit 96f28bc

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

arch/x86/xen/enlighten.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/pci.h>
3232
#include <linux/gfp.h>
3333
#include <linux/memblock.h>
34+
#include <linux/edd.h>
3435

3536
#include <xen/xen.h>
3637
#include <xen/events.h>
@@ -1306,6 +1307,55 @@ static const struct machine_ops xen_machine_ops __initconst = {
13061307
.emergency_restart = xen_emergency_restart,
13071308
};
13081309

1310+
static void __init xen_boot_params_init_edd(void)
1311+
{
1312+
#if IS_ENABLED(CONFIG_EDD)
1313+
struct xen_platform_op op;
1314+
struct edd_info *edd_info;
1315+
u32 *mbr_signature;
1316+
unsigned nr;
1317+
int ret;
1318+
1319+
edd_info = boot_params.eddbuf;
1320+
mbr_signature = boot_params.edd_mbr_sig_buffer;
1321+
1322+
op.cmd = XENPF_firmware_info;
1323+
1324+
op.u.firmware_info.type = XEN_FW_DISK_INFO;
1325+
for (nr = 0; nr < EDDMAXNR; nr++) {
1326+
struct edd_info *info = edd_info + nr;
1327+
1328+
op.u.firmware_info.index = nr;
1329+
info->params.length = sizeof(info->params);
1330+
set_xen_guest_handle(op.u.firmware_info.u.disk_info.edd_params,
1331+
&info->params);
1332+
ret = HYPERVISOR_dom0_op(&op);
1333+
if (ret)
1334+
break;
1335+
1336+
#define C(x) info->x = op.u.firmware_info.u.disk_info.x
1337+
C(device);
1338+
C(version);
1339+
C(interface_support);
1340+
C(legacy_max_cylinder);
1341+
C(legacy_max_head);
1342+
C(legacy_sectors_per_track);
1343+
#undef C
1344+
}
1345+
boot_params.eddbuf_entries = nr;
1346+
1347+
op.u.firmware_info.type = XEN_FW_DISK_MBR_SIGNATURE;
1348+
for (nr = 0; nr < EDD_MBR_SIG_MAX; nr++) {
1349+
op.u.firmware_info.index = nr;
1350+
ret = HYPERVISOR_dom0_op(&op);
1351+
if (ret)
1352+
break;
1353+
mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature;
1354+
}
1355+
boot_params.edd_mbr_sig_buf_entries = nr;
1356+
#endif
1357+
}
1358+
13091359
/*
13101360
* Set up the GDT and segment registers for -fstack-protector. Until
13111361
* we do this, we have to be careful not to call any stack-protected
@@ -1508,6 +1558,8 @@ asmlinkage void __init xen_start_kernel(void)
15081558
/* Avoid searching for BIOS MP tables */
15091559
x86_init.mpparse.find_smp_config = x86_init_noop;
15101560
x86_init.mpparse.get_smp_config = x86_init_uint_noop;
1561+
1562+
xen_boot_params_init_edd();
15111563
}
15121564
#ifdef CONFIG_PCI
15131565
/* PCI BIOS service won't work from a PV guest. */

0 commit comments

Comments
 (0)