xen/pci: try to reserve MCFG areas earlier
PATCH 1/1 xen/pci: try to reserve MCFG areas earlier
If MCFG area is not reserved in E820, Xen by default will defer its usage until Dom0 registers it explicitly after ACPI parser recognizes it as a reserved resource in DSDT. Having it reserved in E820 is not mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2) and firmware is free to keep a hole E820 in that place. Xen doesn't know what exactly is inside this hole since it lacks full ACPI view of the platform therefore it's potentially harmful to access MCFG region without additional checks as some machines are known to provide inconsistent information on the size of the region.
Now xen_mcfg_late() runs after acpi_init() which is too late as some basic PCI enumeration starts exactly there. Trying to register a device prior to MCFG reservation causes multiple problems with PCIe extended capability initializations in Xen (e.g. SR-IOV VF BAR sizing). There are no convenient hooks for us to subscribe to so try to register MCFG areas earlier upon the first invocation of xen_add_device(). Keep the existing initcall in case information of MCFG areas is updated later in acpi_init().
--- drivers/xen/pci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/xen/pci.c +14 -1
@@ -29,6 +29,9 @@#include "../pci/pci.h" #ifdef CONFIG_PCI_MMCONFIG #include <asm/pci_x86.h> + +static int xen_mcfg_late (void ); +static bool __read_mostly pci_mcfg_reserved = false;#endif static bool __read_mostly pci_seg_supported = true;
@@ -41,6 +44,16 @@ static int xen_add_device(struct device *dev)struct pci_dev *physfn = pci_dev->physfn;#endif +#ifdef CONFIG_PCI_MMCONFIG +/* +* Try to reserve MCFG areas discovered so far early on first invocation +* due to this being potentially called from inside of acpi_init +*/ +if (!pci_mcfg_reserved) { +xen_mcfg_late (); + pci_mcfg_reserved = true; + } +#endif if (pci_seg_supported) {struct {struct physdev_pci_device_add add;
@@ -213,7 +226,7 @@ static int __init register_xen_pci_notifier(void)arch_initcall (register_xen_pci_notifier);#ifdef CONFIG_PCI_MMCONFIG -static int __init xen_mcfg_late (void ) +static int xen_mcfg_late (void ) {struct pci_mmcfg_region *cfg;int rc;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Igor Druzhinin
If MCFG area is not reserved in E820, Xen by default will defer its usage until Dom0 registers it explicitly after ACPI parser recognizes it as a reserved resource in DSDT. Having it reserved in E820 is not mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2) and firmware is free to keep a hole E820 in that place. Xen doesn't know what exactly is inside this hole since it lacks full ACPI view of the platform therefore it's potentially harmful to access MCFG region without additional checks as some machines are known to provide inconsistent information on the size of the region.
Irrespective of this being a good change, I've had another thought while reading this paragraph, for a hypervisor side control: Linux has a "memopt=" command line option allowing fine grained control over the E820 map. We could have something similar to allow inserting an E820_RESERVED region into a hole (it would be the responsibility of the admin to guarantee no other conflicts, i.e. it should generally be used only if e.g. the MCFG is indeed known to live at the specified place, and being properly represented in the ACPI tables). Thoughts?
Jan
Quoted 11 lines · Jan Beulich
Quoted 9 lines · Igor Druzhinin
If MCFG area is not reserved in E820, Xen by default will defer its usage until Dom0 registers it explicitly after ACPI parser recognizes it as a reserved resource in DSDT. Having it reserved in E820 is not mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2) and firmware is free to keep a hole E820 in that place. Xen doesn't know what exactly is inside this hole since it lacks full ACPI view of the platform therefore it's potentially harmful to access MCFG region without additional checks as some machines are known to provide inconsistent information on the size of the region.
Quoted 9 lines
Irrespective of this being a good change, I've had another thought while reading this paragraph, for a hypervisor side control: Linux has a "memopt=" command line option allowing fine grained control over the E820 map. We could have something similar to allow inserting an
E820_RESERVEDregion into a hole (it would be the responsibility of the admin to guarantee no other conflicts, i.e. it should generally be used only if e.g. the MCFG is indeed known to live at the specified place, and being properly represented in the ACPI tables). Thoughts?
What other use cases can you think of in case we'd have this option? From the top of my head, it might be providing a memmap for a second Xen after doing kexec from Xen to Xen.
What benefits do you think it might have over just accepting a hole using "mcfg=relaxed" option from admin perspective?
Igor
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 22 lines · Igor Druzhinin
Quoted 11 lines · Jan Beulich
Quoted 9 lines · Igor Druzhinin
If MCFG area is not reserved in E820, Xen by default will defer its usage until Dom0 registers it explicitly after ACPI parser recognizes it as a reserved resource in DSDT. Having it reserved in E820 is not mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2) and firmware is free to keep a hole E820 in that place. Xen doesn't know what exactly is inside this hole since it lacks full ACPI view of the platform therefore it's potentially harmful to access MCFG region without additional checks as some machines are known to provide inconsistent information on the size of the region.
Quoted 9 lines
Irrespective of this being a good change, I've had another thought while reading this paragraph, for a hypervisor side control: Linux has a "memopt=" command line option allowing fine grained control over the E820 map. We could have something similar to allow inserting an
E820_RESERVEDregion into a hole (it would be the responsibility of the admin to guarantee no other conflicts, i.e. it should generally be used only if e.g. the MCFG is indeed known to live at the specified place, and being properly represented in the ACPI tables). Thoughts?
Quoted 6 lines
What other use cases can you think of in case we'd have this option? From the top of my head, it might be providing a memmap for a second Xen after doing kexec from Xen to Xen.
What benefits do you think it might have over just accepting a hole using "mcfg=relaxed" option from admin perspective?
It wouldn't be MCFG-specific, i.e. it could also be used to e.g. convert holes to E820_RESERVED to silence VT-d's respective RMRR warning. Plus by inserting the entry into our own E820 we'd also propagate it to users of XENMEM_machine_memory_map.
Jan
Quoted 10 lines · Igor Druzhinin
If MCFG area is not reserved in E820, Xen by default will defer its usage until Dom0 registers it explicitly after ACPI parser recognizes it as a reserved resource in DSDT. Having it reserved in E820 is not mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2) and firmware is free to keep a hole E820 in that place. Xen doesn't know what exactly is inside this hole since it lacks full ACPI view of the platform therefore it's potentially harmful to access MCFG region without additional checks as some machines are known to provide inconsistent information on the size of the region.
Quoted 6 lines
Now
xen_mcfg_late()runs afteracpi_init()which is too late as some basic PCI enumeration starts exactly there. Trying to register a device prior to MCFG reservation causes multiple problems with PCIe extended capability initializations in Xen (e.g. SR-IOV VF BAR sizing). There are no convenient hooks for us to subscribe to so try to register MCFG areas earlier upon the first invocation ofxen_add_device().
Where is MCFG parsed? pci_arch_init()?
-boris
Quoted 4 lines
Keep the
existing initcall in case information of MCFG areas is updated later inacpi_init().
Quoted 19 lines · Boris Ostrovsky
Quoted 10 lines · Igor Druzhinin
If MCFG area is not reserved in E820, Xen by default will defer its usage until Dom0 registers it explicitly after ACPI parser recognizes it as a reserved resource in DSDT. Having it reserved in E820 is not mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2) and firmware is free to keep a hole E820 in that place. Xen doesn't know what exactly is inside this hole since it lacks full ACPI view of the platform therefore it's potentially harmful to access MCFG region without additional checks as some machines are known to provide inconsistent information on the size of the region.
Quoted 6 lines
Now
xen_mcfg_late()runs afteracpi_init()which is too late as some basic PCI enumeration starts exactly there. Trying to register a device prior to MCFG reservation causes multiple problems with PCIe extended capability initializations in Xen (e.g. SR-IOV VF BAR sizing). There are no convenient hooks for us to subscribe to so try to register MCFG areas earlier upon the first invocation ofxen_add_device().
Quoted 1 line
Where is MCFG parsed?
pci_arch_init()?
It happens twice:
1) first time early one in pci_arch_init() that is arch_initcall - that time pci_mmcfg_list will be freed immediately there because MCFG area is not reserved in E820;
2) second time late one in acpi_init() which is subsystem_initcall right before where PCI enumeration starts - this time ACPI tables will be checked for a reserved resource and pci_mmcfg_list will be finally populated.
The problem is that on a system that doesn't have MCFG area reserved in E820 pci_mmcfg_list is empty before acpi_init() and our PCI hooks are called in the same place. So MCFG is still not in use by Xen at this point since we haven't reached our xen_mcfg_late().
Igor
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 30 lines · Igor Druzhinin
Quoted 11 lines · Boris Ostrovsky
Quoted 10 lines · Igor Druzhinin
If MCFG area is not reserved in E820, Xen by default will defer its usage until Dom0 registers it explicitly after ACPI parser recognizes it as a reserved resource in DSDT. Having it reserved in E820 is not mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2) and firmware is free to keep a hole E820 in that place. Xen doesn't know what exactly is inside this hole since it lacks full ACPI view of the platform therefore it's potentially harmful to access MCFG region without additional checks as some machines are known to provide inconsistent information on the size of the region.
Quoted 8 lines
Quoted 6 lines
Now
xen_mcfg_late()runs afteracpi_init()which is too late as some basic PCI enumeration starts exactly there. Trying to register a device prior to MCFG reservation causes multiple problems with PCIe extended capability initializations in Xen (e.g. SR-IOV VF BAR sizing). There are no convenient hooks for us to subscribe to so try to register MCFG areas earlier upon the first invocation ofxen_add_device().Where is MCFG parsed?
pci_arch_init()?It happens twice:
1) first time early one inpci_arch_init()that isarch_initcall- that timepci_mmcfg_listwill be freed immediately there because MCFG area is not reserved in E820;
2) second time late one inacpi_init()which issubsystem_initcallright before where PCI enumeration starts - this time ACPI tables will be checked for a reserved resource andpci_mmcfg_listwill be finally populated.
Quoted 4 lines
The problem is that on a system that doesn't have MCFG area reserved in E820
pci_mmcfg_listis empty beforeacpi_init()and our PCI hooks are called in the same place. So MCFG is still not in use by Xen at this point since we haven't reached ourxen_mcfg_late().
Would it be possible for us to parse MCFG ourselves in pci_xen_init()? I realize that we'd be doing this twice (or maybe even three times since apparently both pci_arch_init() and acpi_ini() do it).
-boris
Quoted 20 lines · Boris Ostrovsky
Quoted 13 lines · Igor Druzhinin
Quoted 3 lines · Boris Ostrovsky
Where is MCFG parsed?
pci_arch_init()?Quoted 1 line
It happens twice:
1) first time early one in
pci_arch_init()that isarch_initcall- that timepci_mmcfg_listwill be freed immediately there because MCFG area is not reserved in E820;
2) second time late one inacpi_init()which issubsystem_initcallright before where PCI enumeration starts - this time ACPI tables will be checked for a reserved resource andpci_mmcfg_listwill be finally populated.Quoted 4 lines
The problem is that on a system that doesn't have MCFG area reserved in E820
pci_mmcfg_listis empty beforeacpi_init()and our PCI hooks are called in the same place. So MCFG is still not in use by Xen at this point since we haven't reached ourxen_mcfg_late().
Quoted 4 lines
Would it be possible for us to parse MCFG ourselves in
pci_xen_init()? I realize that we'd be doing this twice (or maybe even three times since apparently both pci_arch_init() andacpi_ini()do it).
I don't thine it makes sense:
a) it needs to be done after ACPI is initialized since we need to parse it to figure out the exact reserved region - that's why it's currently done in acpi_init() (see commit message for the reasons why)
b) given (a) we cannot do it ourselves before acpi_init and after is too late as we're already past ACPI PCI enumeration
c) we'd have to do it in the same place I call xen_mcfg_late() and it'd be code duplication of what's already done by the existing code.
Igor
Quoted 18 lines · Igor Druzhinin
Quoted 17 lines · Boris Ostrovsky
Quoted 15 lines · Igor Druzhinin
Quoted 2 lines · Boris Ostrovsky
Where is MCFG parsed?
pci_arch_init()?Quoted 1 line
It happens twice:
1) first time early one in
pci_arch_init()that isarch_initcall- that timepci_mmcfg_listwill be freed immediately there because MCFG area is not reserved in E820;
2) second time late one inacpi_init()which issubsystem_initcallright before where PCI enumeration starts - this time ACPI tables will be checked for a reserved resource andpci_mmcfg_listwill be finally populated.The problem is that on a system that doesn't have MCFG area reserved in E820
pci_mmcfg_listis empty beforeacpi_init()and our PCI hooks are called in the same place. So MCFG is still not in use by Xen at this point since we haven't reached ourxen_mcfg_late().
Quoted 8 lines
Quoted 4 lines
Would it be possible for us to parse MCFG ourselves in
pci_xen_init()? I realize that we'd be doing this twice (or maybe even three times since apparently both pci_arch_init() andacpi_ini()do it).I don't thine it makes sense:
a) it needs to be done after ACPI is initialized since we need to parse it to figure out the exact reserved region - that's why it's currently done inacpi_init()(see commit message for the reasons why)
Hmm... We should be able to parse ACPI tables by the time pci_arch_init() is called. In fact, if you look at pci_mmcfg_early_init() you will see that it does just that.
Quoted 4 lines
b) given (a) we cannot do it ourselves before
acpi_initand after is too late as we're already past ACPI PCI enumeration
c) we'd have to do it in the same place I callxen_mcfg_late()and it'd be code duplication of what's already done by the existing code.
If we manage to parse MCFG ourselves early then maybe we won't not need xen_mcfg_late()? We can call PHYSDEVOP_pci_mmcfg_reserved right away.
-boris
Quoted 23 lines · Boris Ostrovsky
Quoted 22 lines · Igor Druzhinin
Quoted 21 lines · Boris Ostrovsky
Quoted 11 lines · Igor Druzhinin
Quoted 2 lines · Boris Ostrovsky
Where is MCFG parsed?
pci_arch_init()?Quoted 1 line
It happens twice:
1) first time early one in
pci_arch_init()that isarch_initcall- that timepci_mmcfg_listwill be freed immediately there because MCFG area is not reserved in E820;
2) second time late one inacpi_init()which issubsystem_initcallright before where PCI enumeration starts - this time ACPI tables will be checked for a reserved resource andpci_mmcfg_listwill be finally populated.Quoted 4 lines
The problem is that on a system that doesn't have MCFG area reserved in E820
pci_mmcfg_listis empty beforeacpi_init()and our PCI hooks are called in the same place. So MCFG is still not in use by Xen at this point since we haven't reached ourxen_mcfg_late().Would it be possible for us to parse MCFG ourselves in
pci_xen_init()? I realize that we'd be doing this twice (or maybe even three times since apparently both pci_arch_init() andacpi_ini()do it).
Quoted 9 lines
Quoted 4 lines
I don't thine it makes sense:
a) it needs to be done after ACPI is initialized since we need to parse it to figure out the exact reserved region - that's why it's currently done inacpi_init()(see commit message for the reasons why)Hmm... We should be able to parse ACPI tables by the time
pci_arch_init()is called. In fact, if you look atpci_mmcfg_early_init()you will see that it does just that.
The point is not to parse MCFG after acpi_init but to parse DSDT for reserved resource which could be done only after ACPI initialization.
Quoted 8 lines
Quoted 4 lines
b) given (a) we cannot do it ourselves before
acpi_initand after is too late as we're already past ACPI PCI enumeration
c) we'd have to do it in the same place I callxen_mcfg_late()and it'd be code duplication of what's already done by the existing code.If we manage to parse MCFG ourselves early then maybe we won't not need
xen_mcfg_late()? We can callPHYSDEVOP_pci_mmcfg_reservedright away.
Again, this cannot be done untile acpi_init finishes basic setup to parse DSDT.
Igor
Quoted 27 lines · Igor Druzhinin
Quoted 26 lines · Boris Ostrovsky
Quoted 25 lines · Igor Druzhinin
Quoted 12 lines · Boris Ostrovsky
Quoted 11 lines · Igor Druzhinin
Quoted 2 lines · Boris Ostrovsky
Where is MCFG parsed?
pci_arch_init()?Quoted 1 line
It happens twice:
1) first time early one in
pci_arch_init()that isarch_initcall- that timepci_mmcfg_listwill be freed immediately there because MCFG area is not reserved in E820;
2) second time late one inacpi_init()which issubsystem_initcallright before where PCI enumeration starts - this time ACPI tables will be checked for a reserved resource andpci_mmcfg_listwill be finally populated.Quoted 8 lines
Quoted 4 lines
The problem is that on a system that doesn't have MCFG area reserved in E820
pci_mmcfg_listis empty beforeacpi_init()and our PCI hooks are called in the same place. So MCFG is still not in use by Xen at this point since we haven't reached ourxen_mcfg_late().Would it be possible for us to parse MCFG ourselves in
pci_xen_init()? I realize that we'd be doing this twice (or maybe even three times since apparently both pci_arch_init() andacpi_ini()do it).I don't thine it makes sense:
a) it needs to be done after ACPI is initialized since we need to parse it to figure out the exact reserved region - that's why it's currently done inacpi_init()(see commit message for the reasons why)
Quoted 6 lines
Quoted 4 lines
Hmm... We should be able to parse ACPI tables by the time
pci_arch_init()is called. In fact, if you look atpci_mmcfg_early_init()you will see that it does just that.The point is not to parse MCFG after
acpi_initbut to parse DSDT for reserved resource which could be done only after ACPI initialization.
OK, I think I understand now what you are trying to do --- you are essentially trying to account for the range inserted by setup_mcfg_map(), right?
The other question I have is why you think it's worth keeping xen_mcfg_late() as a late initcall. How could MCFG info be updated between acpi_init() and late_initcalls being run? I'd think it can only happen when a new device is hotplugged.
-boris
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines
b) given (a) we cannot do it ourselves before
acpi_initand after is too late as we're already past ACPI PCI enumeration
c) we'd have to do it in the same place I callxen_mcfg_late()and it'd be code duplication of what's already done by the existing code.If we manage to parse MCFG ourselves early then maybe we won't not need
xen_mcfg_late()? We can callPHYSDEVOP_pci_mmcfg_reservedright away.Again, this cannot be done untile
acpi_initfinishes basic setup to parse DSDT.Igor
Quoted 32 lines · Boris Ostrovsky
Quoted 31 lines · Igor Druzhinin
Quoted 30 lines · Boris Ostrovsky
Quoted 17 lines · Igor Druzhinin
Quoted 16 lines · Boris Ostrovsky
Quoted 15 lines · Igor Druzhinin
Quoted 2 lines · Boris Ostrovsky
Where is MCFG parsed?
pci_arch_init()?Quoted 1 line
It happens twice:
1) first time early one in
pci_arch_init()that isarch_initcall- that timepci_mmcfg_listwill be freed immediately there because MCFG area is not reserved in E820;
2) second time late one inacpi_init()which issubsystem_initcallright before where PCI enumeration starts - this time ACPI tables will be checked for a reserved resource andpci_mmcfg_listwill be finally populated.The problem is that on a system that doesn't have MCFG area reserved in E820
pci_mmcfg_listis empty beforeacpi_init()and our PCI hooks are called in the same place. So MCFG is still not in use by Xen at this point since we haven't reached ourxen_mcfg_late().Quoted 8 lines
Quoted 4 lines
Would it be possible for us to parse MCFG ourselves in
pci_xen_init()? I realize that we'd be doing this twice (or maybe even three times since apparently both pci_arch_init() andacpi_ini()do it).I don't thine it makes sense:
a) it needs to be done after ACPI is initialized since we need to parse it to figure out the exact reserved region - that's why it's currently done inacpi_init()(see commit message for the reasons why)Hmm... We should be able to parse ACPI tables by the time
pci_arch_init()is called. In fact, if you look atpci_mmcfg_early_init()you will see that it does just that.
Quoted 7 lines
Quoted 2 lines
The point is not to parse MCFG after
acpi_initbut to parse DSDT for reserved resource which could be done only after ACPI initialization.OK, I think I understand now what you are trying to do --- you are essentially trying to account for the range inserted by
setup_mcfg_map(), right?
Actually, pci_mmcfg_late_init() that's called out of acpi_init() - that's where MCFG areas are properly sized. setup_mcfg_map() is mostly for bus hotplug where MCFG area is discovered by evaluating _CBA method; for cold-plugged buses it just confirms that MCFG area is already registered because it is mandated for them to be in MCFG table at boot time.
Quoted 5 lines
The other question I have is why you think it's worth keeping
xen_mcfg_late()as a late initcall. How could MCFG info be updated betweenacpi_init()andlate_initcallsbeing run? I'd think it can only happen when a new device is hotplugged.
It was a precaution against setup_mcfg_map() calls that might add new areas that are not in MCFG table but for some reason have _CBA method. It's obviously a "firmware is broken" scenario so I don't have strong feelings to keep it here. Will prefer to remove in v2 if you want.
Igor
Quoted 33 lines · Igor Druzhinin
Quoted 32 lines · Boris Ostrovsky
Quoted 31 lines · Igor Druzhinin
Quoted 30 lines · Boris Ostrovsky
Quoted 17 lines · Igor Druzhinin
Quoted 16 lines · Boris Ostrovsky
Quoted 15 lines · Igor Druzhinin
Quoted 2 lines · Boris Ostrovsky
Where is MCFG parsed?
pci_arch_init()?Quoted 1 line
It happens twice:
1) first time early one in
pci_arch_init()that isarch_initcall- that timepci_mmcfg_listwill be freed immediately there because MCFG area is not reserved in E820;
2) second time late one inacpi_init()which issubsystem_initcallright before where PCI enumeration starts - this time ACPI tables will be checked for a reserved resource andpci_mmcfg_listwill be finally populated.The problem is that on a system that doesn't have MCFG area reserved in E820
pci_mmcfg_listis empty beforeacpi_init()and our PCI hooks are called in the same place. So MCFG is still not in use by Xen at this point since we haven't reached ourxen_mcfg_late().Quoted 8 lines
Quoted 4 lines
Would it be possible for us to parse MCFG ourselves in
pci_xen_init()? I realize that we'd be doing this twice (or maybe even three times since apparently both pci_arch_init() andacpi_ini()do it).I don't thine it makes sense:
a) it needs to be done after ACPI is initialized since we need to parse it to figure out the exact reserved region - that's why it's currently done inacpi_init()(see commit message for the reasons why)Hmm... We should be able to parse ACPI tables by the time
pci_arch_init()is called. In fact, if you look atpci_mmcfg_early_init()you will see that it does just that.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
The point is not to parse MCFG after
acpi_initbut to parse DSDT for reserved resource which could be done only after ACPI initialization.OK, I think I understand now what you are trying to do --- you are essentially trying to account for the range inserted by
setup_mcfg_map(), right?Actually,
pci_mmcfg_late_init()that's called out ofacpi_init()- that's where MCFG areas are properly sized.
pci_mmcfg_late_init() reads the (static) MCFG, which doesn't need DSDT parsing, does it? setup_mcfg_map() OTOH does need it as it uses data from _CBA (or is it _CRS?), and I think that's why we can't parse MCFG prior to acpi_init(). So what I said above indeed won't work.
Quoted 10 lines
setup_mcfg_map()is mostly
for bus hotplug where MCFG area is discovered by evaluating_CBAmethod; for cold-plugged buses it just confirms that MCFG area is already registered because it is mandated for them to be in MCFG table at boot time.Quoted 5 lines
The other question I have is why you think it's worth keeping
xen_mcfg_late()as a late initcall. How could MCFG info be updated betweenacpi_init()andlate_initcallsbeing run? I'd think it can only happen when a new device is hotplugged.
Quoted 4 lines
It was a precaution against
setup_mcfg_map()calls that might add new areas that are not in MCFG table but for some reason have_CBAmethod. It's obviously a "firmware is broken" scenario so I don't have strong feelings to keep it here. Will prefer to remove in v2 if you want.
Isn't setup_mcfg_map() called before the first xen_add_device() which is where you are calling xen_mcfg_late()?
-boris
Quoted 20 lines · Boris Ostrovsky
Quoted 19 lines · Igor Druzhinin
Quoted 18 lines · Boris Ostrovsky
Quoted 17 lines · Igor Druzhinin
Quoted 6 lines · Boris Ostrovsky
Quoted 5 lines · Igor Druzhinin
Quoted 4 lines · Boris Ostrovsky
Would it be possible for us to parse MCFG ourselves in
pci_xen_init()? I realize that we'd be doing this twice (or maybe even three times since apparently both pci_arch_init() andacpi_ini()do it).Quoted 8 lines
Quoted 4 lines
I don't thine it makes sense:
a) it needs to be done after ACPI is initialized since we need to parse it to figure out the exact reserved region - that's why it's currently done inacpi_init()(see commit message for the reasons why)Hmm... We should be able to parse ACPI tables by the time
pci_arch_init()is called. In fact, if you look atpci_mmcfg_early_init()you will see that it does just that.The point is not to parse MCFG after
acpi_initbut to parse DSDT for reserved resource which could be done only after ACPI initialization.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
OK, I think I understand now what you are trying to do --- you are essentially trying to account for the range inserted by
setup_mcfg_map(), right?Actually,
pci_mmcfg_late_init()that's called out ofacpi_init()- that's where MCFG areas are properly sized.
pci_mmcfg_late_init()reads the (static) MCFG, which doesn't need DSDT parsing, does it?setup_mcfg_map()OTOH does need it as it uses data from_CBA(or is it_CRS?), and I think that's why we can't parse MCFG prior toacpi_init(). So what I said above indeed won't work.
No, it uses is_acpi_reserved() (it's called indirectly so might be well hidden) to parse DSDT to find a reserved resource in it and size MCFG area accordingly. setup_mcfg_map() is called for every root bus discovered and indeed tries to evaluate _CBA but at this point pci_mmcfg_late_init() has already finished MCFG registration for every cold-plugged bus (which information is described in MCFG table) so those calls are dummy.
Quoted 10 lines
Quoted 10 lines
setup_mcfg_map()is mostly
for bus hotplug where MCFG area is discovered by evaluating_CBAmethod; for cold-plugged buses it just confirms that MCFG area is already registered because it is mandated for them to be in MCFG table at boot time.Quoted 5 lines
The other question I have is why you think it's worth keeping
xen_mcfg_late()as a late initcall. How could MCFG info be updated betweenacpi_init()andlate_initcallsbeing run? I'd think it can only happen when a new device is hotplugged.
Quoted 7 lines
Quoted 4 lines
It was a precaution against
setup_mcfg_map()calls that might add new areas that are not in MCFG table but for some reason have_CBAmethod. It's obviously a "firmware is broken" scenario so I don't have strong feelings to keep it here. Will prefer to remove in v2 if you want.Isn't
setup_mcfg_map()called before the firstxen_add_device()which is where you are callingxen_mcfg_late()?
setup_mcfg_map() calls are done in order of root bus discovery which happens *after* the previous root bus has been enumerated. So the order
is: call setup_mcfg_map() for root bus 0, find that pci_mmcfg_late_init() has finished MCFG area registration, perform PCI enumeration of bus 0, call xen_add_device() for every device there, call setup_mcfg_map() for root bus X, etc.
Igor
Quoted 8 lines · Igor Druzhinin
Quoted 6 lines · Boris Ostrovsky
Quoted 2 lines · Igor Druzhinin
Actually,
pci_mmcfg_late_init()that's called out ofacpi_init()- that's where MCFG areas are properly sized.
pci_mmcfg_late_init()reads the (static) MCFG, which doesn't need DSDT parsing, does it?setup_mcfg_map()OTOH does need it as it uses data from_CBA(or is it_CRS?), and I think that's why we can't parse MCFG prior toacpi_init(). So what I said above indeed won't work.
Quoted 7 lines
No, it uses
is_acpi_reserved()(it's called indirectly so might be well hidden) to parse DSDT to find a reserved resource in it and size MCFG area accordingly.setup_mcfg_map()is called for every root bus discovered and indeed tries to evaluate_CBAbut at this pointpci_mmcfg_late_init()has already finished MCFG registration for every cold-plugged bus (which information is described in MCFG table) so those calls are dummy.
I don't think they're strictly dummy. Even for boot time available devices iirc there's no strict requirement for there to be respective data in MCFG. Such a requirement exists only for devices which are actually needed to start the OS (disk or network, perhaps video or alike), or maybe even just its loader.
Jan
Quoted 17 lines · Jan Beulich
Quoted 8 lines · Igor Druzhinin
Quoted 6 lines · Boris Ostrovsky
Quoted 2 lines · Igor Druzhinin
Actually,
pci_mmcfg_late_init()that's called out ofacpi_init()- that's where MCFG areas are properly sized.
pci_mmcfg_late_init()reads the (static) MCFG, which doesn't need DSDT parsing, does it?setup_mcfg_map()OTOH does need it as it uses data from_CBA(or is it_CRS?), and I think that's why we can't parse MCFG prior toacpi_init(). So what I said above indeed won't work.Quoted 7 lines
No, it uses
is_acpi_reserved()(it's called indirectly so might be well hidden) to parse DSDT to find a reserved resource in it and size MCFG area accordingly.setup_mcfg_map()is called for every root bus discovered and indeed tries to evaluate_CBAbut at this pointpci_mmcfg_late_init()has already finished MCFG registration for every cold-plugged bus (which information is described in MCFG table) so those calls are dummy.
Quoted 6 lines
I don't think they're strictly dummy. Even for boot time available devices iirc there's no strict requirement for there to be respective data in MCFG. Such a requirement exists only for devices which are actually needed to start the OS (disk or network, perhaps video or alike), or maybe even just its loader.
This was my interpretation of 4.1.3 of "PCI Frimware specification":
"Memory mapped configuration base addresses for non-hot pluggable host bridges must be described using MCFG table." Although, I admit that "non-hot pluggable" might mean available at boot as well.
Igor
Quoted 25 lines · Igor Druzhinin
Quoted 24 lines · Boris Ostrovsky
Quoted 23 lines · Igor Druzhinin
Quoted 22 lines · Boris Ostrovsky
Quoted 11 lines · Igor Druzhinin
Quoted 10 lines · Boris Ostrovsky
Quoted 9 lines · Igor Druzhinin
Quoted 4 lines · Boris Ostrovsky
Would it be possible for us to parse MCFG ourselves in
pci_xen_init()? I realize that we'd be doing this twice (or maybe even three times since apparently both pci_arch_init() andacpi_ini()do it).I don't thine it makes sense:
a) it needs to be done after ACPI is initialized since we need to parse it to figure out the exact reserved region - that's why it's currently done inacpi_init()(see commit message for the reasons why)Quoted 6 lines
Quoted 4 lines
Hmm... We should be able to parse ACPI tables by the time
pci_arch_init()is called. In fact, if you look atpci_mmcfg_early_init()you will see that it does just that.The point is not to parse MCFG after
acpi_initbut to parse DSDT for reserved resource which could be done only after ACPI initialization.OK, I think I understand now what you are trying to do --- you are essentially trying to account for the range inserted by
setup_mcfg_map(), right?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Actually,
pci_mmcfg_late_init()that's called out ofacpi_init()- that's where MCFG areas are properly sized.
pci_mmcfg_late_init()reads the (static) MCFG, which doesn't need DSDT parsing, does it?setup_mcfg_map()OTOH does need it as it uses data from_CBA(or is it_CRS?), and I think that's why we can't parse MCFG prior toacpi_init(). So what I said above indeed won't work.No, it uses
is_acpi_reserved()(it's called indirectly so might be well hidden) to parse DSDT to find a reserved resource in it and size MCFG area accordingly.
Right, I see it. Thanks for the explanation.
Quoted 20 lines
setup_mcfg_map()is called for every root bus
discovered and indeed tries to evaluate_CBAbut at this pointpci_mmcfg_late_init()has already finished MCFG registration for every cold-plugged bus (which information is described in MCFG table) so those calls are dummy.Quoted 14 lines
Quoted 14 lines
setup_mcfg_map()is mostly
for bus hotplug where MCFG area is discovered by evaluating_CBAmethod; for cold-plugged buses it just confirms that MCFG area is already registered because it is mandated for them to be in MCFG table at boot time.Quoted 5 lines
The other question I have is why you think it's worth keeping
xen_mcfg_late()as a late initcall. How could MCFG info be updated betweenacpi_init()andlate_initcallsbeing run? I'd think it can only happen when a new device is hotplugged.It was a precaution against
setup_mcfg_map()calls that might add new areas that are not in MCFG table but for some reason have_CBAmethod. It's obviously a "firmware is broken" scenario so I don't have strong feelings to keep it here. Will prefer to remove in v2 if you want.
Quoted 8 lines
Quoted 2 lines
Isn't
setup_mcfg_map()called before the firstxen_add_device()which is where you are callingxen_mcfg_late()?
setup_mcfg_map()calls are done in order of root bus discovery which happens *after* the previous root bus has been enumerated. So the order
is: callsetup_mcfg_map()for root bus 0, find thatpci_mmcfg_late_init()has finished MCFG area registration, perform PCI enumeration of bus 0, callxen_add_device()for every device there, callsetup_mcfg_map()for root bus X, etc.
Ah, yes. Multiple busses.
If that's the case then why don't we need to call xen_mcfg_late() for the first device on each bus?
-boris
Quoted 23 lines · Boris Ostrovsky
Quoted 13 lines · Igor Druzhinin
Quoted 12 lines · Boris Ostrovsky
Quoted 11 lines · Igor Druzhinin
Quoted 5 lines · Boris Ostrovsky
The other question I have is why you think it's worth keeping
xen_mcfg_late()as a late initcall. How could MCFG info be updated betweenacpi_init()andlate_initcallsbeing run? I'd think it can only happen when a new device is hotplugged.It was a precaution against
setup_mcfg_map()calls that might add new areas that are not in MCFG table but for some reason have_CBAmethod. It's obviously a "firmware is broken" scenario so I don't have strong feelings to keep it here. Will prefer to remove in v2 if you want.Quoted 8 lines
Quoted 2 lines
Isn't
setup_mcfg_map()called before the firstxen_add_device()which is where you are callingxen_mcfg_late()?
setup_mcfg_map()calls are done in order of root bus discovery which happens *after* the previous root bus has been enumerated. So the order
is: callsetup_mcfg_map()for root bus 0, find thatpci_mmcfg_late_init()has finished MCFG area registration, perform PCI enumeration of bus 0, callxen_add_device()for every device there, callsetup_mcfg_map()for root bus X, etc.
Quoted 5 lines
Ah, yes. Multiple busses.
If that's the case then why don't we need to call
xen_mcfg_late()for the first device on each bus?
Ideally, yes - we'd like to call it for every bus discovered. But boot time buses are already in MCFG (otherwise system boot might not simply work as Jan pointed out) so it's not strictly required. The only case is a potential PCI bus hot-plug but I'm not sure it actually works in practice and we certainly didn't support it before. It might be solved theoretically by subscribing to acpi_bus_type that is available after acpi_init().
Igor
Quoted 28 lines · Igor Druzhinin
Quoted 22 lines · Boris Ostrovsky
Quoted 13 lines · Igor Druzhinin
Quoted 12 lines · Boris Ostrovsky
Quoted 11 lines · Igor Druzhinin
Quoted 5 lines · Boris Ostrovsky
The other question I have is why you think it's worth keeping
xen_mcfg_late()as a late initcall. How could MCFG info be updated betweenacpi_init()andlate_initcallsbeing run? I'd think it can only happen when a new device is hotplugged.It was a precaution against
setup_mcfg_map()calls that might add new areas that are not in MCFG table but for some reason have_CBAmethod. It's obviously a "firmware is broken" scenario so I don't have strong feelings to keep it here. Will prefer to remove in v2 if you want.Quoted 8 lines
Quoted 2 lines
Isn't
setup_mcfg_map()called before the firstxen_add_device()which is where you are callingxen_mcfg_late()?
setup_mcfg_map()calls are done in order of root bus discovery which happens *after* the previous root bus has been enumerated. So the order
is: callsetup_mcfg_map()for root bus 0, find thatpci_mmcfg_late_init()has finished MCFG area registration, perform PCI enumeration of bus 0, callxen_add_device()for every device there, callsetup_mcfg_map()for root bus X, etc.Quoted 5 lines
Ah, yes. Multiple busses.
If that's the case then why don't we need to call
xen_mcfg_late()for the first device on each bus?
Quoted 7 lines
Ideally, yes - we'd like to call it for every bus discovered. But boot time buses are already in MCFG (otherwise system boot might not simply work as Jan pointed out) so it's not strictly required. The only case is a potential PCI bus hot-plug but I'm not sure it actually works in practice and we certainly didn't support it before. It might be solved theoretically by subscribing to
acpi_bus_typethat is available afteracpi_init().
OK. Then *I think* we can drop late_initcall() but I would really like to hear when others think.
-boris
Quoted 37 lines · Boris Ostrovsky
Quoted 28 lines · Igor Druzhinin
Quoted 22 lines · Boris Ostrovsky
Quoted 13 lines · Igor Druzhinin
Quoted 12 lines · Boris Ostrovsky
Quoted 11 lines · Igor Druzhinin
Quoted 5 lines · Boris Ostrovsky
The other question I have is why you think it's worth keeping
xen_mcfg_late()as a late initcall. How could MCFG info be updated betweenacpi_init()andlate_initcallsbeing run? I'd think it can only happen when a new device is hotplugged.It was a precaution against
setup_mcfg_map()calls that might add new areas that are not in MCFG table but for some reason have_CBAmethod. It's obviously a "firmware is broken" scenario so I don't have strong feelings to keep it here. Will prefer to remove in v2 if you want.Quoted 8 lines
Quoted 2 lines
Isn't
setup_mcfg_map()called before the firstxen_add_device()which is where you are callingxen_mcfg_late()?
setup_mcfg_map()calls are done in order of root bus discovery which happens *after* the previous root bus has been enumerated. So the order
is: callsetup_mcfg_map()for root bus 0, find thatpci_mmcfg_late_init()has finished MCFG area registration, perform PCI enumeration of bus 0, callxen_add_device()for every device there, callsetup_mcfg_map()for root bus X, etc.Quoted 5 lines
Ah, yes. Multiple busses.
If that's the case then why don't we need to call
xen_mcfg_late()for the first device on each bus?Quoted 7 lines
Ideally, yes - we'd like to call it for every bus discovered. But boot time buses are already in MCFG (otherwise system boot might not simply work as Jan pointed out) so it's not strictly required. The only case is a potential PCI bus hot-plug but I'm not sure it actually works in practice and we certainly didn't support it before. It might be solved theoretically by subscribing to
acpi_bus_typethat is available afteracpi_init().
Quoted 3 lines
OK. Then *I think* we can drop
late_initcall()but I would really like to hear when others think.
Another thing that I implied by "not supporting" but want to explicitly call out is that currently Xen will refuse reserving any MCFG area unless it actually existed in MCFG table at boot. I don't clearly understand reasoning behind it but it might be worth relaxing at least size matching restriction on Xen side now with this change.
Igor
Quoted 5 lines · Igor Druzhinin
Another thing that I implied by "not supporting" but want to explicitly call out is that currently Xen will refuse reserving any MCFG area unless it actually existed in MCFG table at boot. I don't clearly understand reasoning behind it but it might be worth relaxing at least size matching restriction on Xen side now with this change.
I guess it's because no-one had a system were it would be needed, and hence could be tested.
Jan
Quoted 37 lines · Igor Druzhinin
Quoted 36 lines · Boris Ostrovsky
Quoted 35 lines · Igor Druzhinin
Quoted 22 lines · Boris Ostrovsky
Quoted 13 lines · Igor Druzhinin
Quoted 12 lines · Boris Ostrovsky
Quoted 11 lines · Igor Druzhinin
Quoted 5 lines · Boris Ostrovsky
The other question I have is why you think it's worth keeping
xen_mcfg_late()as a late initcall. How could MCFG info be updated betweenacpi_init()andlate_initcallsbeing run? I'd think it can only happen when a new device is hotplugged.It was a precaution against
setup_mcfg_map()calls that might add new areas that are not in MCFG table but for some reason have_CBAmethod. It's obviously a "firmware is broken" scenario so I don't have strong feelings to keep it here. Will prefer to remove in v2 if you want.Quoted 8 lines
Quoted 2 lines
Isn't
setup_mcfg_map()called before the firstxen_add_device()which is where you are callingxen_mcfg_late()?
setup_mcfg_map()calls are done in order of root bus discovery which happens *after* the previous root bus has been enumerated. So the order
is: callsetup_mcfg_map()for root bus 0, find thatpci_mmcfg_late_init()has finished MCFG area registration, perform PCI enumeration of bus 0, callxen_add_device()for every device there, callsetup_mcfg_map()for root bus X, etc.Quoted 5 lines
Ah, yes. Multiple busses.
If that's the case then why don't we need to call
xen_mcfg_late()for the first device on each bus?Ideally, yes - we'd like to call it for every bus discovered. But boot time buses are already in MCFG (otherwise system boot might not simply work as Jan pointed out) so it's not strictly required. The only case is a potential PCI bus hot-plug but I'm not sure it actually works in practice and we certainly didn't support it before. It might be solved theoretically by subscribing to
acpi_bus_typethat is available afteracpi_init().
Quoted 2 lines
Quoted 2 lines
OK. Then *I think* we can drop
late_initcall()but I would really like to hear when others think.
Since noone commented then can you send a v2 with second patch removing the late call?
Also, in the first patch please limit the scope of pci_mcfg_reserved to just xen_add_device().
-boris
Quoted 13 lines
Quoted 1 line
Another thing that I implied by "not supporting" but want to explicitly call out is that currently Xen will refuse reserving any MCFG area unless it actually existed in MCFG table at boot. I don't clearly understand reasoning behind it but it might be worth relaxing at least size matching restriction on Xen side now with this change.
Igor
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel