x86/AMD-Vi: Miscs patch to fix and clean up ivrs override
v4 cover x86/AMD-Vi: Miscs patch to fix and clean up ivrs override
From: Suravee Suthikulpanit <[email protected]>
Changes from V3:
- Split the patches into 3 since there are changes from multiple authors
- Clean up code and fix logics
Jan Beulich (1):
x86/AMD-Vi: Overrides special->handle in IVRS IOAPIC
Suravee Suthikulpanit (2):
x86/AMD-Vi: Clean up code for handling IVRS IOAPIC override x86/AMD-Vi: Fix IVRS HPET special->handle override
xen/drivers/passthrough/amd/iommu_acpi.c | 51 ++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 13 deletions(-)
Signature · 1 line
1.8.1.2
PATCH v4 1/3 x86/AMD-Vi: Overrides special->handle in IVRS IOAPIC
From: Jan Beulich <[email protected]>
This patch handles the case when IVRS IOAPIC contains invalid special->handle, which mainly caused by firmware bugs. This allows users to override the invalid handle with command option ivrs_ioapic[<handle>]=<sbdf>.
--- xen/drivers/passthrough/amd/iommu_acpi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
xen/drivers/passthrough/amd/iommu_acpi.c +20 -0
@@ -708,6 +708,26 @@ static u16 __init parse_ivhd_device_special(case ACPI_IVHD_IOAPIC :if ( !iommu_intremap )break ; + +/* Handling the ivrs_ioapic overriding */ + apic =find_first_bit (ioapic_cmdline,ARRAY_SIZE (ioapic_sbdf)); +while ( apic <ARRAY_SIZE (ioapic_sbdf) ) + { +if ( ioapic_sbdf[apic].bdf == bdf && + ioapic_sbdf[apic].seg == seg ) +break ; + apic =find_next_bit (ioapic_cmdline,ARRAY_SIZE (ioapic_sbdf), + apic +1 ); + } +if ( apic <ARRAY_SIZE (ioapic_sbdf) ) + { +AMD_IOMMU_DEBUG ("IVHD: Command line override present for IO-APIC %#x " +"(IVRS: %#x devID %04x:%02x:%02x.%u)\n" , + apic, special->handle, seg,PCI_BUS (bdf), +PCI_SLOT (bdf),PCI_FUNC (bdf)); +break ; + } +/* * Some BIOSes have IOAPIC broken entries so we check for IVRS * consistency here --- whether entry's IOAPIC ID is valid and
Signature · 1 line
1.8.1.2
PATCH v4 2/3 x86/AMD-Vi: Clean up code for handling IVRS IOAPIC override
In reply to [email protected]From: Suravee Suthikulpanit <[email protected]>
Add more info in debug message, and remove unnecessary logic.
--- xen/drivers/passthrough/amd/iommu_acpi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
xen/drivers/passthrough/amd/iommu_acpi.c +3 -6
@@ -698,9 +698,9 @@ static u16 __init parse_ivhd_device_special(return 0 ; } -AMD_IOMMU_DEBUG ("IVHD Special: %04x:%02x:%02x.%u variety %#x handle %#x\n" , +AMD_IOMMU_DEBUG ("IVHD Special: %04x:%02x:%02x.%u variety %#x handle %#x used_id %#x\n" , seg,PCI_BUS (bdf),PCI_SLOT (bdf),PCI_FUNC (bdf), - special->variety, special->handle); + special->variety, special->handle, special->used_id);add_ivrs_mapping_entry (bdf, bdf, special->header.data_setting, iommu); switch ( special->variety )
@@ -745,10 +745,7 @@ static u16 __init parse_ivhd_device_special(return 0 ; } -if (test_bit (special->handle, ioapic_cmdline) ) -AMD_IOMMU_DEBUG ("IVHD: Command line override present for IO-APIC %#x\n" , - special->handle); -else if ( ioapic_sbdf[special->handle].pin_2_idx ) +if ( ioapic_sbdf[special->handle].pin_2_idx ) {if ( ioapic_sbdf[special->handle].bdf == bdf && ioapic_sbdf[special->handle].seg == seg )
Signature · 1 line
1.8.1.2
Re: [PATCH 2/3] x86/AMD-Vi: Clean up code for handling IVRS IOAPIC override
xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_special( · line 748
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 14.09.13 at 01:30, <[email protected]> wrote:
xen/drivers/passthrough/amd/iommu_acpi.c +1
-4@@ -745,10 +745,7 @@ static u16 __init parse_ivhd_device_special(return 0 ; } -if (test_bit (special->handle, ioapic_cmdline) ) -AMD_IOMMU_DEBUG ("IVHD: Command line override present for IO-APIC %#x\n" , - special->handle); -else if ( ioapic_sbdf[special->handle].pin_2_idx ) +if ( ioapic_sbdf[special->handle].pin_2_idx )
Once again: Why is this unnecessary?
Jan
Re: [PATCH 2/3] x86/AMD-Vi: Clean up code for handling IVRS IOAPIC override
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 14.09.13 at 01:30, <[email protected]> wrote:
xen/drivers/passthrough/amd/iommu_acpi.c +0
-0@@ -745,10 +745,7 @@ static u16 __init parse_ivhd_device_special(return 0 ; }
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_special( · line 748
Quoted 5 lines
xen/drivers/passthrough/amd/iommu_acpi.c +1
-4-if (test_bit (special->handle, ioapic_cmdline) ) -AMD_IOMMU_DEBUG ("IVHD: Command line override present for IO-APIC %#x\n" , - special->handle); -else if ( ioapic_sbdf[special->handle].pin_2_idx ) +if ( ioapic_sbdf[special->handle].pin_2_idx )Once again: Why is this unnecessary?
Jan
Ok... you are right. This part should handles the case when the IVRS entry has bad BDF.
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v4 3/3 x86/AMD-Vi: Fix IVRS HPET special->handle override
In reply to [email protected]From: Suravee Suthikulpanit <[email protected]>
The current logic does not handle the case when HPET special->handle is invalid in IVRS. On such system, the following message is shown:
(XEN) AMD-Vi: Failed to setup HPET MSI remapping: Wrong HPET
This patch will allow the ivrs_hpet[<handle>]=<sbdf> to override the IVRS.
--- xen/drivers/passthrough/amd/iommu_acpi.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
xen/drivers/passthrough/amd/iommu_acpi.c +15 -7
@@ -671,6 +671,7 @@ static void __init parse_ivrs_hpet(char *str)if ( !s || *s )return ; + hpet_sbdf.id = id; hpet_sbdf.bdf =PCI_BDF (bus, dev, func); hpet_sbdf.seg = seg; hpet_sbdf.cmdline =1 ;
@@ -787,19 +788,26 @@ static u16 __init parse_ivhd_device_special( }break ;case ACPI_IVHD_HPET : +if ( hpet_sbdf.cmdline ) + { +AMD_IOMMU_DEBUG ("IVHD: Command line override present for HPET %#x " +"(IVRS: %#x devID %04x:%02x:%02x.%u)\n" , + hpet_sbdf.id, special->handle, seg,PCI_BUS (bdf), +PCI_SLOT (bdf),PCI_FUNC (bdf)); + hpet_sbdf.iommu = iommu; +break ; + } +/* set device id of hpet */ -if ( hpet_sbdf.iommu || - (hpet_sbdf.cmdline && hpet_sbdf.id != special->handle) ) +if ( hpet_sbdf.iommu ) {printk (XENLOG_WARNING "Only one IVHD HPET entry is supported\n" );break ; } + hpet_sbdf.id = special->handle; -if ( !hpet_sbdf.cmdline ) - { - hpet_sbdf.bdf = bdf; - hpet_sbdf.seg = seg; - } + hpet_sbdf.bdf = bdf; + hpet_sbdf.seg = seg; hpet_sbdf.iommu = iommu;break ;default :
Signature · 1 line
1.8.1.2
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 14.09.13 at 01:30, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The current logic does not handle the case when HPET
special->handleis invalid in IVRS. On such system, the following message is shown:(XEN) AMD-Vi: Failed to setup HPET MSI remapping: Wrong HPET
This patch will allow the ivrs_hpet[<handle>]=<sbdf> to override the IVRS.
Signed-off-by Suravee Suthikulpanit <[email protected]>--- xen/drivers/passthrough/amd/iommu_acpi.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)xen/drivers/passthrough/amd/iommu_acpi.c +1
-0@@ -671,6 +671,7 @@ static void __init parse_ivrs_hpet(char *str)if ( !s || *s )return ; + hpet_sbdf.id = id; hpet_sbdf.bdf =PCI_BDF (bus, dev, func); hpet_sbdf.seg = seg; hpet_sbdf.cmdline =1 ;
xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_special( · line 797
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7
-0@@ -787,19 +788,26 @@ static u16 __init parse_ivhd_device_special( }break ;case ACPI_IVHD_HPET : +if ( hpet_sbdf.cmdline ) + { +AMD_IOMMU_DEBUG ("IVHD: Command line override present for HPET %#x " +"(IVRS: %#x devID %04x:%02x:%02x.%u)\n" , + hpet_sbdf.id, special->handle, seg,PCI_BUS (bdf), +PCI_SLOT (bdf),PCI_FUNC (bdf)); + hpet_sbdf.iommu = iommu;
This (unconditional) assignment is what the earlier logic attempted to avoid: We must not blindly set this (and in particular not blindly overwrite a previously set valid value), and in order to do so we need to know whether to trust devid or handle. I'm therefore going to apply only the first hunk - being a clear and obvious bug fix - for the time being.
Jan
Quoted 25 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7
-7+break ; + } +/* set device id of hpet */ -if ( hpet_sbdf.iommu || - (hpet_sbdf.cmdline && hpet_sbdf.id != special->handle) ) +if ( hpet_sbdf.iommu ) {printk (XENLOG_WARNING "Only one IVHD HPET entry is supported\n" );break ; } + hpet_sbdf.id = special->handle; -if ( !hpet_sbdf.cmdline ) - { - hpet_sbdf.bdf = bdf; - hpet_sbdf.seg = seg; - } + hpet_sbdf.bdf = bdf; + hpet_sbdf.seg = seg; hpet_sbdf.iommu = iommu;break ;default :Signature · 1 line
1.8.1.2
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 47 lines · Jan Beulich
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 14.09.13 at 01:30, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The current logic does not handle the case when HPET
special->handleis invalid in IVRS. On such system, the following message is shown:(XEN) AMD-Vi: Failed to setup HPET MSI remapping: Wrong HPET
This patch will allow the ivrs_hpet[<handle>]=<sbdf> to override the IVRS.
Signed-off-by Suravee Suthikulpanit <[email protected]>--- xen/drivers/passthrough/amd/iommu_acpi.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)xen/drivers/passthrough/amd/iommu_acpi.c +1
-0@@ -671,6 +671,7 @@ static void __init parse_ivrs_hpet(char *str)if ( !s || *s )return ; + hpet_sbdf.id = id; hpet_sbdf.bdf =PCI_BDF (bus, dev, func); hpet_sbdf.seg = seg; hpet_sbdf.cmdline =1 ;xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_special( · line 797
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7
-0@@ -787,19 +788,26 @@ static u16 __init parse_ivhd_device_special( }break ;case ACPI_IVHD_HPET : +if ( hpet_sbdf.cmdline ) + { +AMD_IOMMU_DEBUG ("IVHD: Command line override present for HPET %#x " +"(IVRS: %#x devID %04x:%02x:%02x.%u)\n" , + hpet_sbdf.id, special->handle, seg,PCI_BUS (bdf), +PCI_SLOT (bdf),PCI_FUNC (bdf)); + hpet_sbdf.iommu = iommu;This (unconditional) assignment is what the earlier logic attempted to avoid: We must not blindly set this (and in particular not blindly overwrite a previously set valid value), and in order to do so we need to know whether to trust devid or handle. I'm therefore going to apply only the first hunk - being a clear and obvious bug fix - for the time being.
Quoted 1 line
Jan
But since we only allow one HPET in the system, and if users want to override the one that is in the IVRS (the buggy one) we should allow this, right? Otherwise, if the special->handle doesn't match, it would end up causing this logic to complain about multiple HPETs.
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 17.09.13 at 16:10, Suravee Suthikulpanit <[email protected]>
Quoted 49 lines · wrote:
Quoted 25 lines · Jan Beulich
Quoted 25 lines
Quoted 1 line
Quoted 1 line · On 14.09.13 at 01:30, <[email protected]> wrote:
From: Suravee Suthikulpanit <[email protected]>
The current logic does not handle the case when HPET
special->handleis invalid in IVRS. On such system, the following message is shown:(XEN) AMD-Vi: Failed to setup HPET MSI remapping: Wrong HPET
This patch will allow the ivrs_hpet[<handle>]=<sbdf> to override the IVRS.
Signed-off-by Suravee Suthikulpanit <[email protected]>--- xen/drivers/passthrough/amd/iommu_acpi.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)xen/drivers/passthrough/amd/iommu_acpi.c +0
-0@@ -671,6 +671,7 @@ static void __init parse_ivrs_hpet(char *str)if ( !s || *s )return ;Quoted 11 lines
xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_special( · line 793
Quoted 11 lines
xen/drivers/passthrough/amd/iommu_acpi.c +4
-0+ hpet_sbdf.id = id; hpet_sbdf.bdf =PCI_BDF (bus, dev, func); hpet_sbdf.seg = seg; hpet_sbdf.cmdline =1 ;@@ -787,19 +788,26 @@ static u16 __init parse_ivhd_device_special( }break ;case ACPI_IVHD_HPET : +if ( hpet_sbdf.cmdline ) + { + AMD_IOMMU_DEBUG("IVHD: Command line override present for HPET%#x "
Quoted 11 lines
xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_special( · line 797
Quoted 4 lines
xen/drivers/passthrough/amd/iommu_acpi.c +4
-0+"(IVRS: %#x devID %04x:%02x:%02x.%u)\n" , + hpet_sbdf.id, special->handle, seg,PCI_BUS (bdf), + PCI_SLOT(bdf), PCI_FUNC(bdf)); + hpet_sbdf.iommu = iommu;This (unconditional) assignment is what the earlier logic attempted to avoid: We must not blindly set this (and in particular not blindly overwrite a previously set valid value), and in order to do so we need to know whether to trust devid or handle. I'm therefore going to apply only the first hunk - being a clear and obvious bug fix - for the time being.
Quoted 5 lines
But since we only allow one HPET in the system, and if users want to override the one that is in the IVRS (the buggy one)
we should allow this, right? Otherwise, if thespecial->handledoesn't match, it would end up causing this logic to complain
about multiple HPETs.
We must not allow multiple HPET entries in the ACPI tables to confuse us and store a bad IOMMU pointer. And yes, we also must not wrongly complain about multiple HEPTs.
Jan
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 7 lines
This (unconditional) assignment is what the earlier logic attempted
Quoted 6 lines
Quoted 6 lines
to avoid: We must not blindly set this (and in particular not blindly overwrite a previously set valid value), and in order to do so we need to know whether to trust devid or handle. I'm therefore going to apply only the first hunk - being a clear and obvious bug fix - for the time being.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
But since we only allow one HPET in the system, and if users want to override the one that is in the IVRS (the buggy one)
we should allow this, right? Otherwise, if thespecial->handledoesn't match, it would end up causing this logic to complain
about multiple HPETs.We must not allow multiple HPET entries in the ACPI tables to confuse us and store a bad IOMMU pointer.
I understand this part and agree. Currently, the patch does not allow multiple HPET in the system. If user specifies the ivrs_hpet, that will be the one that get used, and ignore the one that is in the IVRS. Although, it will be pointing to the IOMMU which lists HPET in the IVRS.
However, if IVRS is listing multiple HPETs in different IOMMUs, then it will just default to the first IOMMU. I don't see this case happening though since HPET is in the Southbridge which only has one in the system.
Am I missing any thing?
Suravee
Quoted 3 lines
And yes, we also must not wrongly complain about multiple HEPTs.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 20.09.13 at 23:38, Suravee Suthikulanit <[email protected]>
Quoted 22 lines · wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 7 lines
This (unconditional) assignment is what the earlier logic attempted
Quoted 6 lines
Quoted 6 lines
to avoid: We must not blindly set this (and in particular not blindly overwrite a previously set valid value), and in order to do so we need to know whether to trust devid or handle. I'm therefore going to apply only the first hunk - being a clear and obvious bug fix - for the time being.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
But since we only allow one HPET in the system, and if users want to override the one that is in the IVRS (the buggy one)
we should allow this, right? Otherwise, if thespecial->handledoesn't match, it would end up causing this logic to complain
about multiple HPETs.We must not allow multiple HPET entries in the ACPI tables to confuse us and store a bad IOMMU pointer.
I understand this part and agree. Currently, the patch does not allow multiple HPET in the system.
If user specifies theivrs_hpet, that will be the one that get used, and ignore the one that
is in the IVRS. Although, it will be pointing to the IOMMU which lists HPET in the IVRS.
Quoted 6 lines
However, if IVRS is listing multiple HPETs in different IOMMUs, then it will just default to the first IOMMU.
I don't see this case happening though since HPET is in the Southbridge which only has one in the system.Am I missing any thing?
Yes - there's no guarantee that (especially in a multi-node system) there's just one HPET. Nor do the ACPI tables have any indication there this would always be the case. Even if _all_ current systems only have a single HPET (which I don't think you can guarantee), we shouldn't code in a latent bug like this.
Jan
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 30 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 20.09.13 at 23:38, Suravee Suthikulanit <[email protected]>
Quoted 22 lines · wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 7 lines
This (unconditional) assignment is what the earlier logic attempted
Quoted 6 lines
Quoted 6 lines
to avoid: We must not blindly set this (and in particular not blindly overwrite a previously set valid value), and in order to do so we need to know whether to trust devid or handle. I'm therefore going to apply only the first hunk - being a clear and obvious bug fix - for the time being.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
But since we only allow one HPET in the system, and if users want to override the one that is in the IVRS (the buggy one)
we should allow this, right? Otherwise, if thespecial->handledoesn't match, it would end up causing this logic to complain
about multiple HPETs.We must not allow multiple HPET entries in the ACPI tables to confuse us and store a bad IOMMU pointer.
I understand this part and agree. Currently, the patch does not allow multiple HPET in the system.
If user specifies theivrs_hpet, that will be the one that get used, and ignore the one that
is in the IVRS. Although, it will be pointing to the IOMMU which lists HPET in the IVRS.Quoted 6 lines
However, if IVRS is listing multiple HPETs in different IOMMUs, then it will just default to the first IOMMU.
I don't see this case happening though since HPET is in the Southbridge which only has one in the system.Am I missing any thing?
Quoted 8 lines
Yes - there's no guarantee that (especially in a multi-node system) there's just one HPET. Nor do the ACPI tables have any indication there this would always be the case. Even if _all_ current systems only have a single HPET (which I don't think you can guarantee), we shouldn't code in a latent bug like this.
Jan
I am a bit confused on what you want to do. I believe all the systems at this point should have only one HPET. That's why the code only has one data structure for initialize one HPET. Are you expecting that certain systems could have more than one HPETs?
Alternatively, I can try matching on the "SBDF" assuming that IVRS doesn't screw up the SBDF part of the HPET special entry.
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 38 lines · Suravee Suthikulpanit
Quoted 37 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 20.09.13 at 23:38, Suravee Suthikulanit <[email protected]>
Quoted 22 lines · wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 7 lines
This (unconditional) assignment is what the earlier logic attempted
Quoted 6 lines
Quoted 6 lines
to avoid: We must not blindly set this (and in particular not blindly overwrite a previously set valid value), and in order to do so we need to know whether to trust devid or handle. I'm therefore going to apply only the first hunk - being a clear and obvious bug fix - for the time being.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
But since we only allow one HPET in the system, and if users want to override the one that is in the IVRS (the buggy one)
we should allow this, right? Otherwise, if thespecial->handledoesn't match, it would end up causing this logic to complain
about multiple HPETs.We must not allow multiple HPET entries in the ACPI tables to confuse us and store a bad IOMMU pointer.
I understand this part and agree. Currently, the patch does not allow multiple HPET in the system.
If user specifies theivrs_hpet, that will be the one that get used, and ignore the one that
is in the IVRS. Although, it will be pointing to the IOMMU which lists HPET in the IVRS.Quoted 6 lines
However, if IVRS is listing multiple HPETs in different IOMMUs, then it will just default to the first IOMMU.
I don't see this case happening though since HPET is in the Southbridge which only has one in the system.Am I missing any thing?
Yes - there's no guarantee that (especially in a multi-node system) there's just one HPET. Nor do the ACPI tables have any indication there this would always be the case. Even if _all_ current systems only have a single HPET (which I don't think you can guarantee), we shouldn't code in a latent bug like this.
Quoted 8 lines
Quoted 1 line
Jan
I am a bit confused on what you want to do. I believe all the systems at this point
should have only one HPET. That's why the code only has one data structure for
initialize one HPET. Are you expecting that certain systems could have more than
one HPETs?
Amongst the test servers we have, I have plenty of examples of AMD hardware with anything up to 8 HPETs in the system. (See for reference my HPET stack overflow thread)
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 40 lines · Andrew Cooper
Quoted 39 lines · Suravee Suthikulpanit
Quoted 38 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 20.09.13 at 23:38, Suravee Suthikulanit<[email protected]>
Quoted 22 lines · wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 7 lines
This (unconditional) assignment is what the earlier logic attempted
Quoted 6 lines
Quoted 6 lines
to avoid: We must not blindly set this (and in particular not blindly overwrite a previously set valid value), and in order to do so we need to know whether to trust devid or handle. I'm therefore going to apply only the first hunk - being a clear and obvious bug fix - for the time being.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
But since we only allow one HPET in the system, and if users want to override the one that is in the IVRS (the buggy one)
we should allow this, right? Otherwise, if thespecial->handledoesn't match, it would end up causing this logic to complain
about multiple HPETs.We must not allow multiple HPET entries in the ACPI tables to confuse us and store a bad IOMMU pointer.
I understand this part and agree. Currently, the patch does not allow multiple HPET in the system.
If user specifies theivrs_hpet, that will be the one that get used, and ignore the one that
is in the IVRS. Although, it will be pointing to the IOMMU which lists HPET in the IVRS.Quoted 6 lines
However, if IVRS is listing multiple HPETs in different IOMMUs, then it will just default to the first IOMMU.
I don't see this case happening though since HPET is in the Southbridge which only has one in the system.Am I missing any thing?
Yes - there's no guarantee that (especially in a multi-node system) there's just one HPET. Nor do the ACPI tables have any indication there this would always be the case. Even if _all_ current systems only have a single HPET (which I don't think you can guarantee), we shouldn't code in a latent bug like this.
Jan
Quoted 8 lines
Quoted 4 lines
I am a bit confused on what you want to do. I believe all the systems at this point should have only one HPET. That's why the code only has one data structure for initialize one HPET. Are you expecting that certain systems could have more than one HPETs?
Amongst the test servers we have, I have plenty of examples of AMD hardware with anything up to 8 HPETs in the system. (See for reference my HPET stack overflow thread)
~Andrew
Andrew,
From the hpet-overflow-full-stackdump.tar.gz here (http://lists.xen.org/archives/html/xen-devel/2013-08/msg01667.html),
I inspect the files, and foundout that this is an Intel system. Are you sure that you are seeing more than 1 HPET on an AMD system? As far as I know, I don't this that is how the platforms are designed.
Would you mind sending the output from "acpidump" for the "HPET" table from the system you have? Also, would you provide the detail of the system?
Thank you,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
In reply to Andrew CooperQuoted 4 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Amongst the test servers we have, I have plenty of examples of AMD hardware with anything up to 8 HPETs in the system. (See for reference my HPET stack overflow thread)
That's HPET counters afaict, not HPETs.
Jan
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
In reply to Suravee SuthikulpanitQuoted 8 lines
Quoted 1 line
Quoted 1 line · Suravee Suthikulpanit
I am a bit confused on what you want to do. I believe all the systems at this point
should have only one HPET. That's why the code only has one data structure for
initialize one HPET. Are you expecting that certain systems could have more than
one HPETs?
Of course. The code assuming just one HPET is wrong in the first place, so I'm really not looking towards making matters worse. The only valid a priori information we have is that there's exactly one HPET nominated as the legacy replacement one (through the ACPI HPET table), but there could be more (as said, this is quite likely on multi-node NUMA systems).
Quoted 3 lines
Alternatively, I can try matching on the "SBDF" assuming that IVRS doesn't screw up
the SBDF part of the HPET special entry.
As long as we only support one, we should be prepared for either ID or SBDF to be wrong, and should (for maximum flexibility) probably allow matching in both directions. Or you'd need to propose a new way of associating the IOMMU with the HPET.
Jan
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Suravee Suthikulpanit
I am a bit confused on what you want to do. I believe all the systems at this point
should have only one HPET. That's why the code only has one data structure for
initialize one HPET. Are you expecting that certain systems could have more than
one HPETs?
Quoted 6 lines
Of course. The code assuming just one HPET is wrong in the first place, so I'm really not looking towards making matters worse. The only valid a priori information we have is that there's exactly one HPET nominated as the legacy replacement one (through the ACPI HPET table), but there could be more (as said, this is quite likely on multi-node NUMA systems).
Ok, after looking into Intel HPET specification, I can see that the spec allows a particular system to have multiple HPETs. And Jan was correct that only one is required to be listed in the APCI HPET table. The rest are listed in ACPI namespace.
I look at the "arch/x86/hpet.c" and saw that this supports discovery in the ACPI HPET table. However, there is only one "hpet_address" and "hpet_blockid", which are initialized in the "arch/x86/acpi/boot.c: acpi_parse_hpet()". If the code were to support more than one HPET, this would have to be changed also. Do you expect these to change as well?
Also, I don't see the code that would walk the ACPI namespace anywhere. Does it exist?
FYI, I have checked with the hardware platforms team, and there is no AMD systems with multiple southbridge (HPET is in the southbridge). I also check on the system with 2 SR56xx chips ( each contains an IOMMU), and there is only one southbridge.
Suravee
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Suravee Suthikulanit
Ok, after looking into Intel HPET specification, I can see that the spec allows a particular system
to have multiple HPETs. And Jan was correct that only one is required to be listed in the APCI HPET table.
The rest are listed in ACPI namespace.
Quoted 7 lines
I look at the "
arch/x86/hpet.c" and saw that this supports discovery in the ACPI HPET table.
However, there is only one "hpet_address" and "hpet_blockid", which are initialized in the
"arch/x86/acpi/boot.c:acpi_parse_hpet()". If the code were to support more than one HPET,
this would have to be changed also. Do you expect these to change as well?
This second paragraph contradicts what you correctly describe in the first: There's only one required to be listed in the ACPI HPET table, and hence that code isn't expected to change.
Quoted 2 lines
Also, I don't see the code that would walk the ACPI namespace anywhere. Does it exist?
In Dom0, yes. But the information not getting passed down is of no relevance here: All we care about is how to correctly find the IOMMU for the one HPET we use, which ought to work no matter how many HPETs there are in the system.
Jan
Re: [PATCH 3/3] x86/AMD-Vi: Fix IVRS HPET special->handle override
Quoted 18 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Suravee Suthikulanit
Ok, after looking into Intel HPET specification, I can see that the spec allows a particular system
to have multiple HPETs. And Jan was correct that only one is required to be listed in the APCI HPET table.
The rest are listed in ACPI namespace.Quoted 7 lines
I look at the "
arch/x86/hpet.c" and saw that this supports discovery in the ACPI HPET table.
However, there is only one "hpet_address" and "hpet_blockid", which are initialized in the
"arch/x86/acpi/boot.c:acpi_parse_hpet()". If the code were to support more than one HPET,
this would have to be changed also. Do you expect these to change as well?This second paragraph contradicts what you correctly describe in the first: There's only one required to be listed in the ACPI HPET table, and hence that code isn't expected to change.
Quoted 8 lines
Quoted 2 lines
Also, I don't see the code that would walk the ACPI namespace anywhere. Does it exist?
In Dom0, yes. But the information not getting passed down is of no relevance here: All we care about is how to correctly find the IOMMU for the one HPET we use, which ought to work no matter how many HPETs there are in the system.
Jan
Actually, I found out that "struct hpet_sbdf.iommu" is not used anywhere. We should be able to get rid of this, and it should now be simpler logic. I'll remove this in my next patch.
Suravee