x86/xen: populate boot_params with EDD data
Subsystems (2)
PATCH 1/1 x86/xen: populate boot_params with EDD data
From: David Vrabel <[email protected]>
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/.
--- arch/x86/xen/enlighten.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-)
arch/x86/xen/enlighten.c +57 -0
@@ -31,6 +31,7 @@#include <linux/pci.h> #include <linux/gfp.h> #include <linux/memblock.h> +#include <linux/edd.h> #include <xen/xen.h> #include <xen/events.h>
@@ -1306,6 +1307,60 @@ static const struct machine_ops xen_machine_ops __initconst = { .emergency_restart = xen_emergency_restart, }; +#if defined(CONFIG_EDD ) || defined(CONFIG_EDD_MODULE ) +static void __init load_edd (void ) +{ +struct xen_platform_op op; +struct edd_info *edd_info; +u32 *mbr_signature; +unsigned nr; +int ret; + + edd_info = boot_params.eddbuf; + mbr_signature = boot_params.edd_mbr_sig_buffer; + + op.cmd = XENPF_firmware_info; + + op.u.firmware_info.type =XEN_FW_DISK_INFO ; +for (nr =0 ; nr <EDDMAXNR ; nr++) { +struct edd_info *info = edd_info + nr; + + op.u.firmware_info.index = nr; + info->params.length =sizeof (info->params); +set_xen_guest_handle (op.u.firmware_info.u.disk_info.edd_params, + &info->params); + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + +#define C (x) info->x = op.u.firmware_info.u.disk_info.x +C (device); +C (version); +C (interface_support); +C (legacy_max_cylinder); +C (legacy_max_head); +C (legacy_sectors_per_track); +#undef C + } + boot_params.eddbuf_entries = nr; + + op.u.firmware_info.type =XEN_FW_DISK_MBR_SIGNATURE ; +for (nr =0 ; nr <EDD_MBR_SIG_MAX ; nr++) { + op.u.firmware_info.index = nr; + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature; + } + boot_params.edd_mbr_sig_buf_entries = nr; +} +#else +static inline void __init load_edd (void ) +{ +} +#endif + +/* * Set up the GDT and segment registers for -fstack-protector. Until * we do this, we have to be careful not to call any stack-protected
@@ -1508,6 +1563,8 @@ asmlinkage void __init xen_start_kernel(void)/* Avoid searching for BIOS MP tables */ x86_init.mpparse.find_smp_config = x86_init_noop; x86_init.mpparse.get_smp_config = x86_init_uint_noop; + +load_edd (); }#ifdef CONFIG_PCI /* PCI BIOS service won't work from a PV guest. */
Signature · 1 line
1.7.2.5
arch/x86/xen/enlighten.c static const struct machine_ops xen_machine_ops __initconst = { · line 1310
Quoted 6 lines
Quoted 1 line
Quoted 1 line · David Vrabel
arch/x86/xen/enlighten.c +1
-0@@ -1306,6 +1307,60 @@ static const struct machine_ops xen_machine_ops __initconst = { .emergency_restart = xen_emergency_restart, }; +#if defined(CONFIG_EDD ) || defined(CONFIG_EDD_MODULE )
This is
#if IS_ENABLED(CONFIG_EDD)
nowadays.
Quoted 41 lines
arch/x86/xen/enlighten.c +41
-0+static void __init load_edd (void ) +{ +struct xen_platform_op op; +struct edd_info *edd_info; +u32 *mbr_signature; +unsigned nr; +int ret; + + edd_info = boot_params.eddbuf; + mbr_signature = boot_params.edd_mbr_sig_buffer; + + op.cmd = XENPF_firmware_info; + + op.u.firmware_info.type =XEN_FW_DISK_INFO ; +for (nr =0 ; nr <EDDMAXNR ; nr++) { +struct edd_info *info = edd_info + nr; + + op.u.firmware_info.index = nr; + info->params.length =sizeof (info->params); +set_xen_guest_handle (op.u.firmware_info.u.disk_info.edd_params, + &info->params); + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + +#define C (x) info->x = op.u.firmware_info.u.disk_info.x +C (device); +C (version); +C (interface_support); +C (legacy_max_cylinder); +C (legacy_max_head); +C (legacy_sectors_per_track); +#undef C + } + boot_params.eddbuf_entries = nr; + + op.u.firmware_info.type =XEN_FW_DISK_MBR_SIGNATURE ; +for (nr =0 ; nr <EDD_MBR_SIG_MAX ; nr++) { + op.u.firmware_info.index = nr; + ret =HYPERVISOR_dom0_op (&op); +if (ret)
arch/x86/xen/enlighten.c static const struct machine_ops xen_machine_ops __initconst = { · line 1361
Quoted 10 lines
arch/x86/xen/enlighten.c +10
-0+break ; + mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature; + } + boot_params.edd_mbr_sig_buf_entries = nr; +} +#else +static inline void __init load_edd (void ) +{ +} +#endif
And if you put the conditionals inside the curly braces, you can avoid the else portion here altogether.
Jan
Quoted 10 lines · Jan Beulich
arch/x86/xen/enlighten.c static const struct machine_ops xen_machine_ops __initconst = { · line 1361
Quoted 7 lines
Quoted 1 line
Quoted 1 line · David Vrabel
arch/x86/xen/enlighten.c +6
-0+} +#else +static inline void __init load_edd (void ) +{ +} +#endif And if you put the conditionals inside the curly braces, you can avoid the else portion here altogether.
I thought the #if around the whole function was the standard pattern. Konrad, what's your opinion here?
David
Quoted 12 lines · David Vrabel
Quoted 10 lines · Jan Beulich
arch/x86/xen/enlighten.c static const struct machine_ops xen_machine_ops __initconst = { · line 1361
Quoted 7 lines
Quoted 1 line
Quoted 1 line · David Vrabel
arch/x86/xen/enlighten.c +6
-0+} +#else +static inline void __init load_edd (void ) +{ +} +#endif And if you put the conditionals inside the curly braces, you can avoid the else portion here altogether.
Quoted 2 lines
I thought the #if around the whole function was the standard pattern. Konrad, what's your opinion here?
That is the way to do it in the header files.
You are not doing this in a header, I would go with what Jan suggested and just do the #ifdef CONFIG_EDD.. inside the function.
Also just for completness, lets call the function 'xen_load_edd'
Quoted 8 lines
David
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 1/1 x86/xen: populate boot_params with EDD data
From: David Vrabel <[email protected]>
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/.
---
v3:
- load_edd() -> xen_boot_params_init_edd()
v2:
- use IS_ENABLED()
- #if in the function looks more readable
--- arch/x86/xen/enlighten.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-)
arch/x86/xen/enlighten.c +52 -0
@@ -31,6 +31,7 @@#include <linux/pci.h> #include <linux/gfp.h> #include <linux/memblock.h> +#include <linux/edd.h> #include <xen/xen.h> #include <xen/events.h>
@@ -1306,6 +1307,55 @@ static const struct machine_ops xen_machine_ops __initconst = { .emergency_restart = xen_emergency_restart, }; +static void __init xen_boot_params_init_edd (void ) +{ +#if IS_ENABLED (CONFIG_EDD ) +struct xen_platform_op op; +struct edd_info *edd_info; +u32 *mbr_signature; +unsigned nr; +int ret; + + edd_info = boot_params.eddbuf; + mbr_signature = boot_params.edd_mbr_sig_buffer; + + op.cmd = XENPF_firmware_info; + + op.u.firmware_info.type =XEN_FW_DISK_INFO ; +for (nr =0 ; nr <EDDMAXNR ; nr++) { +struct edd_info *info = edd_info + nr; + + op.u.firmware_info.index = nr; + info->params.length =sizeof (info->params); +set_xen_guest_handle (op.u.firmware_info.u.disk_info.edd_params, + &info->params); + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + +#define C (x) info->x = op.u.firmware_info.u.disk_info.x +C (device); +C (version); +C (interface_support); +C (legacy_max_cylinder); +C (legacy_max_head); +C (legacy_sectors_per_track); +#undef C + } + boot_params.eddbuf_entries = nr; + + op.u.firmware_info.type =XEN_FW_DISK_MBR_SIGNATURE ; +for (nr =0 ; nr <EDD_MBR_SIG_MAX ; nr++) { + op.u.firmware_info.index = nr; + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature; + } + boot_params.edd_mbr_sig_buf_entries = nr; +#endif +} +/* * Set up the GDT and segment registers for -fstack-protector. Until * 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)/* Avoid searching for BIOS MP tables */ x86_init.mpparse.find_smp_config = x86_init_noop; x86_init.mpparse.get_smp_config = x86_init_uint_noop; + +xen_boot_params_init_edd (); }#ifdef CONFIG_PCI /* PCI BIOS service won't work from a PV guest. */
Signature · 1 line
1.7.2.5
PATCH v2 1/1 x86/xen: populate boot_params with EDD data
In reply to Jan BeulichFrom: David Vrabel <[email protected]>
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/.
---
v2:
- use IS_ENABLED()
- #if in the function looks more readable
--- arch/x86/xen/enlighten.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-)
arch/x86/xen/enlighten.c +52 -0
@@ -31,6 +31,7 @@#include <linux/pci.h> #include <linux/gfp.h> #include <linux/memblock.h> +#include <linux/edd.h> #include <xen/xen.h> #include <xen/events.h>
@@ -1306,6 +1307,55 @@ static const struct machine_ops xen_machine_ops __initconst = { .emergency_restart = xen_emergency_restart, }; +static void __init load_edd (void ) +{ +#if IS_ENABLED (CONFIG_EDD ) +struct xen_platform_op op; +struct edd_info *edd_info; +u32 *mbr_signature; +unsigned nr; +int ret; + + edd_info = boot_params.eddbuf; + mbr_signature = boot_params.edd_mbr_sig_buffer; + + op.cmd = XENPF_firmware_info; + + op.u.firmware_info.type =XEN_FW_DISK_INFO ; +for (nr =0 ; nr <EDDMAXNR ; nr++) { +struct edd_info *info = edd_info + nr; + + op.u.firmware_info.index = nr; + info->params.length =sizeof (info->params); +set_xen_guest_handle (op.u.firmware_info.u.disk_info.edd_params, + &info->params); + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + +#define C (x) info->x = op.u.firmware_info.u.disk_info.x +C (device); +C (version); +C (interface_support); +C (legacy_max_cylinder); +C (legacy_max_head); +C (legacy_sectors_per_track); +#undef C + } + boot_params.eddbuf_entries = nr; + + op.u.firmware_info.type =XEN_FW_DISK_MBR_SIGNATURE ; +for (nr =0 ; nr <EDD_MBR_SIG_MAX ; nr++) { + op.u.firmware_info.index = nr; + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature; + } + boot_params.edd_mbr_sig_buf_entries = nr; +#endif +} +/* * Set up the GDT and segment registers for -fstack-protector. Until * 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)/* Avoid searching for BIOS MP tables */ x86_init.mpparse.find_smp_config = x86_init_noop; x86_init.mpparse.get_smp_config = x86_init_uint_noop; + +load_edd (); }#ifdef CONFIG_PCI /* PCI BIOS service won't work from a PV guest. */
Signature · 1 line
1.7.2.5
Quoted 8 lines
Quoted 1 line
Quoted 1 line · David Vrabel
From: David Vrabel <[email protected]>
During early setup of a dom0 kernel, populate
boot_paramswith 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 <[email protected]>
Quoted 76 lines
arch/x86/xen/enlighten.c +50
-0@@ -31,6 +31,7 @@#include <linux/pci.h> #include <linux/gfp.h> #include <linux/memblock.h> +#include <linux/edd.h> #include <xen/xen.h> #include <xen/events.h> @@ -1306,6 +1307,55 @@ static const struct machine_ops xen_machine_ops__initconst = { .emergency_restart = xen_emergency_restart, }; +static void __init load_edd (void ) +{ +#if IS_ENABLED (CONFIG_EDD ) +struct xen_platform_op op; +struct edd_info *edd_info; +u32 *mbr_signature; +unsigned nr; +int ret; + + edd_info = boot_params.eddbuf; + mbr_signature = boot_params.edd_mbr_sig_buffer; + + op.cmd = XENPF_firmware_info; + + op.u.firmware_info.type =XEN_FW_DISK_INFO ; +for (nr =0 ; nr <EDDMAXNR ; nr++) { +struct edd_info *info = edd_info + nr; + + op.u.firmware_info.index = nr; + info->params.length =sizeof (info->params); +set_xen_guest_handle (op.u.firmware_info.u.disk_info.edd_params, + &info->params); + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + +#define C (x) info->x = op.u.firmware_info.u.disk_info.x +C (device); +C (version); +C (interface_support); +C (legacy_max_cylinder); +C (legacy_max_head); +C (legacy_sectors_per_track); +#undef C + } + boot_params.eddbuf_entries = nr; + + op.u.firmware_info.type =XEN_FW_DISK_MBR_SIGNATURE ; +for (nr =0 ; nr <EDD_MBR_SIG_MAX ; nr++) { + op.u.firmware_info.index = nr; + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature; + } + boot_params.edd_mbr_sig_buf_entries = nr; +#endif +} +/* * Set up the GDT and segment registers for -fstack-protector. Until * we do this, we have to be careful not to call any stack-protected
arch/x86/xen/enlighten.c +2
-0@@ -1508,6 +1558,8 @@ asmlinkage void __init xen_start_kernel(void)/* Avoid searching for BIOS MP tables */ x86_init.mpparse.find_smp_config = x86_init_noop; x86_init.mpparse.get_smp_config = x86_init_uint_noop; + +load_edd (); }#ifdef CONFIG_PCI /* PCI BIOS service won't work from a PV guest. */
Quoted 63 lines · David Vrabel
From: David Vrabel <[email protected]>
During early setup of a dom0 kernel, populate
boot_paramswith 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 <[email protected]>--- arch/x86/xen/enlighten.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-)arch/x86/xen/enlighten.c +37
-0@@ -31,6 +31,7 @@#include <linux/pci.h> #include <linux/gfp.h> #include <linux/memblock.h> +#include <linux/edd.h> #include <xen/xen.h> #include <xen/events.h> @@ -1306,6 +1307,60 @@ static const struct machine_ops xen_machine_ops __initconst = { .emergency_restart = xen_emergency_restart, }; +#if defined(CONFIG_EDD ) || defined(CONFIG_EDD_MODULE ) +static void __init load_edd (void ) +{ +struct xen_platform_op op; +struct edd_info *edd_info; +u32 *mbr_signature; +unsigned nr; +int ret; + + edd_info = boot_params.eddbuf; + mbr_signature = boot_params.edd_mbr_sig_buffer; + + op.cmd = XENPF_firmware_info; + + op.u.firmware_info.type =XEN_FW_DISK_INFO ; +for (nr =0 ; nr <EDDMAXNR ; nr++) { +struct edd_info *info = edd_info + nr; + + op.u.firmware_info.index = nr; + info->params.length =sizeof (info->params); +set_xen_guest_handle (op.u.firmware_info.u.disk_info.edd_params, + &info->params); + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + +#define C (x) info->x = op.u.firmware_info.u.disk_info.x +C (device); +C (version); +C (interface_support); +C (legacy_max_cylinder); +C (legacy_max_head); +C (legacy_sectors_per_track); +#undef C + } + boot_params.eddbuf_entries = nr;
arch/x86/xen/enlighten.c static const struct machine_ops xen_machine_ops __initconst = { · line 1355
Quoted 10 lines
arch/x86/xen/enlighten.c +10
-0+ + op.u.firmware_info.type =XEN_FW_DISK_MBR_SIGNATURE ; +for (nr =0 ; nr <EDD_MBR_SIG_MAX ; nr++) { + op.u.firmware_info.index = nr; + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature; + } + boot_params.edd_mbr_sig_buf_entries = nr;
If those two loops end up terminating at different spots (say first one ends at nr=1, and the second at nr=5), is that going to present a problem?
Should we have some form of 'min(nr_earlier, nr)' to clamp down in case of weird oddities?
Quoted 23 lines
arch/x86/xen/enlighten.c +10
-0+} +#else +static inline void __init load_edd (void ) +{ +} +#endif + +/* * Set up the GDT and segment registers for -fstack-protector. Until * we do this, we have to be careful not to call any stack-protected @@ -1508,6 +1563,8 @@ asmlinkage void __init xen_start_kernel(void)/* Avoid searching for BIOS MP tables */ x86_init.mpparse.find_smp_config = x86_init_noop; x86_init.mpparse.get_smp_config = x86_init_uint_noop; + +load_edd (); }#ifdef CONFIG_PCI /* PCI BIOS service won't work from a PV guest. */ Signature · 1 line
1.7.2.5
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · David Vrabel
From: David Vrabel <[email protected]>
During early setup of a dom0 kernel, populate
boot_paramswith the Enhanced Disk Drive (EDD) and MBR signature data. This makes information on the BIOS boot device available in/sys/firmware/edd/.
[...]
Quoted 57 lines
Quoted 42 lines
arch/x86/xen/enlighten.c +36
-0@@ -1306,6 +1307,60 @@ static const struct machine_ops xen_machine_ops __initconst = { .emergency_restart = xen_emergency_restart, }; +#if defined(CONFIG_EDD ) || defined(CONFIG_EDD_MODULE ) +static void __init load_edd (void ) +{ +struct xen_platform_op op; +struct edd_info *edd_info; +u32 *mbr_signature; +unsigned nr; +int ret; + + edd_info = boot_params.eddbuf; + mbr_signature = boot_params.edd_mbr_sig_buffer; + + op.cmd = XENPF_firmware_info; + + op.u.firmware_info.type =XEN_FW_DISK_INFO ; +for (nr =0 ; nr <EDDMAXNR ; nr++) { +struct edd_info *info = edd_info + nr; + + op.u.firmware_info.index = nr; + info->params.length =sizeof (info->params); +set_xen_guest_handle (op.u.firmware_info.u.disk_info.edd_params, + &info->params); + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + +#define C (x) info->x = op.u.firmware_info.u.disk_info.x +C (device); +C (version); +C (interface_support); +C (legacy_max_cylinder); +C (legacy_max_head); +C (legacy_sectors_per_track); +#undef C + } + boot_params.eddbuf_entries = nr;arch/x86/xen/enlighten.c static const struct machine_ops xen_machine_ops __initconst = { · line 1355
Quoted 10 lines
arch/x86/xen/enlighten.c +10
-0+ + op.u.firmware_info.type =XEN_FW_DISK_MBR_SIGNATURE ; +for (nr =0 ; nr <EDD_MBR_SIG_MAX ; nr++) { + op.u.firmware_info.index = nr; + ret =HYPERVISOR_dom0_op (&op); +if (ret) +break ; + mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature; + } + boot_params.edd_mbr_sig_buf_entries = nr;If those two loops end up terminating at different spots (say first one ends at nr=1, and the second at nr=5), is that going to present a problem?
Quoted 2 lines
Should we have some form of '
min(nr_earlier, nr)' to clamp down in case of weird oddities?
The edd firmware driver looks to correctly handle this -- it will only show attributes for things that exist.
David