arm64: vgic-v3: Add ITS doorbell region in Dom0 stage-2
RFC PATCH 1/1 arm64: vgic-v3: Add ITS doorbell region in Dom0 stage-2
From: Manish Jaggi <[email protected]>
This patch introduces a function vgic_map_translation_space for mapping ITS 64K translater space for doorbells in dom0 stage-2.
It is required as dom0 PCI devices behined SMMU wont be able to write MSIs.
This function is called from vgic_v3_its_init_domain only for hardware domain.
This patch is also required for testing
[RFC 00/11] acpi: arm: IORT Support for Xen [1]
+ [2] [RFC v4 0/8] SMMUv3 driver
[1] https://lists.xenproject.org/archives/html/xen-devel/2018-01/msg00007.html
[2] https://lists.xen.org/archives/html/xen-devel/2017-12/msg01294.html
--- xen/arch/arm/vgic-v3-its.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
xen/arch/arm/vgic-v3-its.c +26 -0
@@ -1511,6 +1511,30 @@ unsigned int vgic_v3_its_count(const struct domain *d)return ret; } +static int vgic_map_translation_space (struct domain *d,paddr_t guest_addr) +{ +u64 addr, size; +int ret; + addr = guest_addr +SZ_64K ; + size =SZ_64K ; + + ret =map_mmio_regions (d, +paddr_to_pfn (addr &PAGE_MASK ), +DIV_ROUND_UP (size,PAGE_SIZE ), +paddr_to_pfn (addr &PAGE_MASK )); + +if ( ret ) + { +printk (XENLOG_ERR "Unable to map to dom%d access to" +" 0x%" PRIx64" - 0x%" PRIx64"\n" , + d->domain_id, + addr &PAGE_MASK ,PAGE_ALIGN (addr + size) -1 ); + } + +return ret; + +} +/* * For a hardware domain, this will iterate over the host ITSes * and map one virtual ITS per host ITS at the same address.
@@ -1541,6 +1565,8 @@ int vgic_v3_its_init_domain(struct domain *d)return ret; else d->arch.vgic.has_its = true; + +vgic_map_translation_space (d, hw_its->addr); } }
Signature · 7 lines
2.14.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Manish,
Quoted 5 lines · On 18/01/18 06:15, [email protected] wrote:
From: Manish Jaggi <[email protected]>
This patch introduces a function
vgic_map_translation_spacefor mapping ITS 64K translater space for doorbells in dom0 stage-2.
It is required as dom0 PCI devices behined SMMU wont be able to write MSIs.
s/behined/behind/
also there a two spaces after SMMU. One should be enough.
Quoted 2 lines
This function is called from
vgic_v3_its_init_domainonly for hardware domain.
This is really confusing. You mix dom0 and hardware domain in the same commit. Please use only "hardware domain".
Quoted 7 lines
This patch is also required for testing
[RFC 00/11] acpi: arm: IORT Support for Xen [1]
+ [2] [RFC v4 0/8] SMMUv3 driver[1] https://lists.xenproject.org/archives/html/xen-devel/2018-01/msg00007.html
[2] https://lists.xen.org/archives/html/xen-devel/2017-12/msg01294.html
Anything after "This patch..." does not seem to be relevant in the commit. You might want to add that after --- so it get stripped after committing.
Quoted 11 lines
Signed-off-by Manish Jaggi <[email protected]>--- xen/arch/arm/vgic-v3-its.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)xen/arch/arm/vgic-v3-its.c +0
-0
xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct domain *d) · line 1514
Quoted 4 lines
xen/arch/arm/vgic-v3-its.c +1
-0@@ -1511,6 +1511,30 @@ unsigned int vgic_v3_its_count(const struct domain *d)return ret; } +static int vgic_map_translation_space (struct domain *d,paddr_t guest_addr)
This function is quite confusing. What is guest_addr? It looks like it is the base address of the ITS but it is not very clear here.
xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct domain *d) · line 1516
Quoted 2 lines
xen/arch/arm/vgic-v3-its.c +2
-0+{ +u64 addr, size;
This should be paddr_t.
xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct domain *d) · line 1517
Quoted 1 line
xen/arch/arm/vgic-v3-its.c +1
-0+int ret;
Newline here please.
xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct domain *d) · line 1524
Quoted 7 lines
xen/arch/arm/vgic-v3-its.c +7
-0+ addr = guest_addr +SZ_64K ; + size =SZ_64K ; + + ret =map_mmio_regions (d, +paddr_to_pfn (addr &PAGE_MASK ), +DIV_ROUND_UP (size,PAGE_SIZE ), +paddr_to_pfn (addr &PAGE_MASK ));
You are assuming a 1:1 mapping in the domain. Nowhere you explain that assumption nor that it will not work for guest. At least you need an ASSERT(is_domain_direct_mapped(d)).
Furthermore, as we discussed yesterday I would expect a big fat comment that this need to be revisited when DomU support will be added as it may not be safe to map the Doorbell in page-tables used by the processor.
Quoted 17 lines
xen/arch/arm/vgic-v3-its.c +13
-0+ +if ( ret ) + { +printk (XENLOG_ERR "Unable to map to dom%d access to" +" 0x%" PRIx64" - 0x%" PRIx64"\n" , + d->domain_id, + addr &PAGE_MASK ,PAGE_ALIGN (addr + size) -1 ); + } + +return ret; + +} +/* * For a hardware domain, this will iterate over the host ITSes * and map one virtual ITS per host ITS at the same address.
xen/arch/arm/vgic-v3-its.c int vgic_v3_its_init_domain(struct domain *d) · line 1569
Quoted 5 lines
xen/arch/arm/vgic-v3-its.c +2
-0@@ -1541,6 +1565,8 @@ int vgic_v3_its_init_domain(struct domain *d)return ret; else d->arch.vgic.has_its = true; + +vgic_map_translation_space (d, hw_its->addr);
Your new function may return an error. Therefore you should test it.
xen/arch/arm/vgic-v3-its.c int vgic_v3_its_init_domain(struct domain *d) · line 1572
Quoted 4 lines
xen/arch/arm/vgic-v3-its.c +0
-0} }
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 1 line · Julien Grall
Hi Manish,
Hi Julien,
Quoted 12 lines · On 18/01/18 06:15, [email protected] wrote:
Quoted 5 lines
From: Manish Jaggi <[email protected]>
This patch introduces a function
vgic_map_translation_spacefor mapping ITS 64K translater space for doorbells in dom0 stage-2.
It is required as dom0 PCI devices behined SMMU wont be able to write MSIs.s/behined/behind/
also there a two spaces after SMMU. One should be enough.
ok
Quoted 4 lines
Quoted 2 lines
This function is called from
vgic_v3_its_init_domainonly for hardware domain.This is really confusing. You mix dom0 and hardware domain in the same commit. Please use only "hardware domain".
I stressed this here as this function is only called for hardware domain, if you see line 1550
|if ( is_hardware_domain(d) ) is checked.|
Quoted 9 lines
Quoted 7 lines
This patch is also required for testing
[RFC 00/11] acpi: arm: IORT Support for Xen [1]
+ [2] [RFC v4 0/8] SMMUv3 driver
[1] https://lists.xenproject.org/archives/html/xen-devel/2018-01/msg00007.html
[2] https://lists.xen.org/archives/html/xen-devel/2017-12/msg01294.htmlAnything after "This patch..." does not seem to be relevant in the commit. You might want to add that after --- so it get stripped after committing.
ok
Quoted 7 lines
Quoted 7 lines
Signed-off-by Manish Jaggi <[email protected]>---
xen/arch/arm/vgic-v3-its.c| 26 ++++++++++++++++++++++++++1 file changed, 26 insertions(+)
Quoted 11 lines
xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct · line 1514
Quoted 9 lines
xen/arch/arm/vgic-v3-its.c +0
-0@@ -1511,6 +1511,30 @@ unsigned int vgic_v3_its_count(const struct domain *d) return ret; } +static int vgic_map_translation_space(struct domain *d, paddr_t guest_addr)This function is quite confusing. What is
guest_addr? It looks like it is the base address of the ITS but it is not very clear here.
ok I will change the name.
Quoted 18 lines
xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct domain *d) · line 1516
Quoted 3 lines
xen/arch/arm/vgic-v3-its.c +2
-0+{ + u64 addr, size;This should be
paddr_t.xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct domain *d) · line 1517
Quoted 1 line
xen/arch/arm/vgic-v3-its.c +1
-0+ int ret;Newline here please.
xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct domain *d) · line 1524
Quoted 7 lines
xen/arch/arm/vgic-v3-its.c +7
-0+ addr = guest_addr + SZ_64K; + size = SZ_64K; + + ret = map_mmio_regions(d, + paddr_to_pfn(addr & PAGE_MASK), + DIV_ROUND_UP(size, PAGE_SIZE), + paddr_to_pfn(addr & PAGE_MASK));
Quoted 3 lines
You are assuming a 1:1 mapping in the domain. Nowhere you explain that assumption nor that it will not work for guest. At least you need an ASSERT(is_domain_direct_mapped(d)).
Furthermore, as we discussed yesterday I would expect a big fat comment that this need to be revisited when DomU support will be added as it may not be safe to map the Doorbell in page-tables used by the processor.
I think you didnt read the commit log properly, this function is *only* called for hardware domain. So there is no question of DomU. Request you to please see the code again.
|int vgic_v3_its_init_domain(struct domain *d) { ... if ( is_hardware_domain(d) ) { struct host_its *hw_its; list_for_each_entry(hw_its, &host_its_list, entry) { ... vgic_map_translation_space(d, hw_its->addr); } } ... } |
Quoted 16 lines
Quoted 16 lines
xen/arch/arm/vgic-v3-its.c +13
-0+ + if ( ret ) + { + printk(XENLOG_ERR "Unable to map to dom%d access to" + " 0x%"PRIx64" - 0x%"PRIx64"\n", + d->domain_id, + addr & PAGE_MASK, PAGE_ALIGN(addr + size) - 1); + } + + return ret; + +} + /** For a hardware domain, this will iterate over the host ITSes
Quoted 8 lines
Quoted 7 lines
* and map one virtual ITS per host ITS at the same address.
xen/arch/arm/vgic-v3-its.c +0
-0@@ -1541,6 +1565,8 @@ int vgic_v3_its_init_domain(struct domain *d) return ret;else
d->arch.vgic.has_its= true;
+
+vgic_map_translation_space(d, hw_its->addr);Your new function may return an error. Therefore you should test it.
yes, I thought we will focus more is this is the right place to add this test code.
Quoted 7 lines
Quoted 4 lines
}
}Cheers,
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi,
Quoted 15 lines · Manish Jaggi
Quoted 1 line · Julien Grall
Hi Manish,
Hi Julien,
Quoted 10 lines · On 18/01/18 06:15, [email protected] wrote:
Quoted 5 lines
From: Manish Jaggi <[email protected]>
This patch introduces a function
vgic_map_translation_spacefor mapping ITS 64K translater space for doorbells in dom0 stage-2.
It is required as dom0 PCI devices behined SMMU wont be able to write MSIs.s/behined/behind/
Quoted 8 lines
Quoted 2 lines
also there a two spaces after SMMU. One should be enough.
ok
Quoted 4 lines
Quoted 2 lines
This function is called from
vgic_v3_its_init_domainonly for hardware domain.This is really confusing. You mix dom0 and hardware domain in the same commit. Please use only "hardware domain".
I stressed this here as this function is only called for hardware domain, if you see line 1550
So why are you using the word Dom0 everywhere else? I keep asking you to use the term "Hardware Domain".
Quoted 49 lines
|if (
is_hardware_domain(d)) is checked.|Quoted 9 lines
Quoted 7 lines
This patch is also required for testing
[RFC 00/11] acpi: arm: IORT Support for Xen [1]
+ [2] [RFC v4 0/8] SMMUv3 driver
[1] https://lists.xenproject.org/archives/html/xen-devel/2018-01/msg00007.html
[2] https://lists.xen.org/archives/html/xen-devel/2017-12/msg01294.htmlAnything after "This patch..." does not seem to be relevant in the commit. You might want to add that after --- so it get stripped after committing.
ok
Quoted 7 lines
Quoted 7 lines
Signed-off-by Manish Jaggi <[email protected]>---
xen/arch/arm/vgic-v3-its.c| 26 ++++++++++++++++++++++++++1 file changed, 26 insertions(+)Quoted 11 lines
xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct · line 1514
Quoted 9 lines
xen/arch/arm/vgic-v3-its.c +0
-0@@ -1511,6 +1511,30 @@ unsigned int vgic_v3_its_count(const struct domain *d) return ret; } +static int vgic_map_translation_space(struct domain *d, paddr_t guest_addr)This function is quite confusing. What is
guest_addr? It looks like it is the base address of the ITS but it is not very clear here.ok I will change the name.
Quoted 18 lines
xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct domain *d) · line 1516
Quoted 3 lines
xen/arch/arm/vgic-v3-its.c +2
-0+{ + u64 addr, size;This should be
paddr_t.xen/arch/arm/vgic-v3-its.c unsigned int vgic_v3_its_count(const struct domain *d) · line 1517
Quoted 1 line
xen/arch/arm/vgic-v3-its.c +1
-0+ int ret;Newline here please.
Quoted 7 lines
xen/arch/arm/vgic-v3-its.c +7
-0+ addr = guest_addr + SZ_64K; + size = SZ_64K; + + ret = map_mmio_regions(d, + paddr_to_pfn(addr & PAGE_MASK), + DIV_ROUND_UP(size, PAGE_SIZE), + paddr_to_pfn(addr & PAGE_MASK));
Quoted 5 lines
Quoted 3 lines
You are assuming a 1:1 mapping in the domain. Nowhere you explain that assumption nor that it will not work for guest. At least you need an ASSERT(is_domain_direct_mapped(d)).
Furthermore, as we discussed yesterday I would expect a big fat comment that this need to be revisited when DomU support will be added as it may not be safe to map the Doorbell in page-tables used by the processor.
I think you didnt read the commit log properly, this function is *only* called for hardware domain. So there is no question of DomU. Request you to please see the code again.
I read properly the commit log... and my point still stands. This function is name vgic_map_translation_space. How a developer would guess that it can't be used for other domain than the hardware domain and direct mapped? More that you pass a domain pointer...
Quoted 11 lines
Quoted 10 lines
Quoted 9 lines
xen/arch/arm/vgic-v3-its.c +0
-0/** For a hardware domain, this will iterate over the host ITSes * and map one virtual ITS per host ITS at the same address.
xen/arch/arm/vgic-v3-its.c +0
-0@@ -1541,6 +1565,8 @@ int vgic_v3_its_init_domain(struct domain *d) return ret;else
d->arch.vgic.has_its= true;
+
+vgic_map_translation_space(d, hw_its->addr);Your new function may return an error. Therefore you should test it.
yes, I thought we will focus more is this is the right place to add this test code.
This is not difficult to check error return in a first draft. Please stop sending patch that are full of coding style error or half done (without even mentioning it).
This is rather annoying and a way to miss that afterwards.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel