xen: arm: correctly write release target in smp_spin_table_cpu_up
PATCH 1/1 xen: arm: correctly write release target in smp_spin_table_cpu_up
flush_xen_data_tlb_range_va() is clearly bogus since it flushes the tlb, not the data cache. Perhaps what was meant was flush_xen_dcache(), but the address was mapped with ioremap_nocache and hence isn't cached in the first place. Accesses should be via writeq though, so do that.
--- xen/arch/arm/arm64/smpboot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
xen/arch/arm/arm64/smpboot.c +1 -2
@@ -32,8 +32,7 @@ static int __init smp_spin_table_cpu_up(int cpu)return -EFAULT ; } - release[0 ] =__pa (init_secondary); -flush_xen_data_tlb_range_va ((vaddr_t )release,sizeof (*release)); +writeq (__pa (init_secondary), release);iounmap (release);
Signature · 1 line
1.7.10.4
Quoted 6 lines · Ian Campbell
flush_xen_data_tlb_range_va()is clearly bogus since it flushes the tlb, not the data cache. Perhaps what was meant wasflush_xen_dcache(), but the address was mapped withioremap_nocacheand hence isn't cached in the first place. Accesses should be via writeq though, so do that.Signed-off-by Ian Campbell <[email protected]>
Quoted 19 lines
--- xen/arch/arm/arm64/smpboot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)xen/arch/arm/arm64/smpboot.c +1
-2@@ -32,8 +32,7 @@ static int __init smp_spin_table_cpu_up(int cpu)return -EFAULT ; } - release[0 ] =__pa (init_secondary); -flush_xen_data_tlb_range_va ((vaddr_t )release,sizeof (*release)); +writeq (__pa (init_secondary), release);iounmap (release);
Signature · 1 line
Julien Grall
Quoted 8 lines · Julien Grall
Quoted 6 lines · Ian Campbell
flush_xen_data_tlb_range_va()is clearly bogus since it flushes the tlb, not the data cache. Perhaps what was meant wasflush_xen_dcache(), but the address was mapped withioremap_nocacheand hence isn't cached in the first place. Accesses should be via writeq though, so do that.Signed-off-by Ian Campbell <[email protected]>Acked-by Julien Grall <[email protected]>
Thanks. I think release wise this can wait for 4.5, the flush is unnecessary but not harmful.
While the use of writeq is needed for the additional barriers which it adds it's not strictly needed here because there is no prior write to sequence against (and ioremap_nocache has a barrier in it).
Unless removing this pointless flush makes some analysis of the use of the functions less confusing perhaps?
However thinking about the writeq barriers to lead me to notice the lack of a recommended dsb() before the subsequent use of sev(), which is needed to ensure that the write has occurred before we wake the other processor. We get away with this because the iounmap in the middle does a write_pte which has a dsb in it. Phew! Still. for 4.5:
8<-----
Quoted 1 line
From
aab391b98760cc8417e06512848cf83dd5d71b5cMon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Wed, 15 Jan 2014 14:49:04 +0000
Subject: [PATCH] xen: arm: add barrier before sev in smp_spin_table_cpu_up
This ensures that the writeq to the release address has occurred.
In reality there is a dsb() in the iounmap() (in the e entual write_pte()) but make it explicit.
The ARMv8 ARM recommends that sev() is usually accompanied by a dsb(), the only other uses are in the v7 spinlock code which includes a dsb() already.
--- xen/arch/arm/arm64/smpboot.c | 1 + 1 file changed, 1 insertion(+)
xen/arch/arm/arm64/smpboot.c +1 -0
@@ -36,6 +36,7 @@ static int __init smp_spin_table_cpu_up(int cpu)iounmap (release); +dsb ();sev ();return cpu_up_send_sgi (cpu);
Signature · 1 line
1.7.10.4
Quoted 13 lines · Ian Campbell
Quoted 8 lines · Julien Grall
Quoted 6 lines · Ian Campbell
flush_xen_data_tlb_range_va()is clearly bogus since it flushes the tlb, not the data cache. Perhaps what was meant wasflush_xen_dcache(), but the address was mapped withioremap_nocacheand hence isn't cached in the first place. Accesses should be via writeq though, so do that.Signed-off-by Ian Campbell <[email protected]>Acked-by Julien Grall <[email protected]>Thanks. I think release wise this can wait for 4.5, the flush is unnecessary but not harmful.
Quoted 6 lines
While the use of writeq is needed for the additional barriers which it adds it's not strictly needed here because there is no prior write to sequence against (and
ioremap_nocachehas a barrier in it).Unless removing this pointless flush makes some analysis of the use of the functions less confusing perhaps?
For code comprehension, it's better. I think this patch is like "arm:
flush TLB on all CPUs when setting and ...". It's not harmful when Xen is used but it helps readability.
Quoted 8 lines
However thinking about the writeq barriers to lead me to notice the lack of a recommended
dsb()before the subsequent use ofsev(), which is needed to ensure that the write has occurred before we wake the other processor. We get away with this because the iounmap in the middle does awrite_ptewhich has a dsb in it. Phew! Still. for 4.5:8<-----
Quoted 8 lines
From
aab391b98760cc8417e06512848cf83dd5d71b5cMon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Wed, 15 Jan 2014 14:49:04 +0000
Subject: [PATCH] xen: arm: add barrier before sev insmp_spin_table_cpu_upThis ensures that the writeq to the release address has occurred.
In reality there is a
dsb()in theiounmap()(in the e entualwrite_pte()) but
e entual? Did you function write_pte()?
Quoted 24 lines
make it explicit.
The ARMv8 ARM recommends that
sev()is usually accompanied by adsb(), the only other uses are in the v7 spinlock code which includes adsb()already.Signed-off-by Ian Campbell <[email protected]>--- xen/arch/arm/arm64/smpboot.c | 1 + 1 file changed, 1 insertion(+)xen/arch/arm/arm64/smpboot.c +1
-0@@ -36,6 +36,7 @@ static int __init smp_spin_table_cpu_up(int cpu)iounmap (release); +dsb ();sev ();return cpu_up_send_sgi (cpu);
Signature · 1 line
Julien Grall
Quoted 18 lines · Julien Grall
Quoted 17 lines · Ian Campbell
Quoted 8 lines · Julien Grall
Quoted 6 lines · Ian Campbell
flush_xen_data_tlb_range_va()is clearly bogus since it flushes the tlb, not the data cache. Perhaps what was meant wasflush_xen_dcache(), but the address was mapped withioremap_nocacheand hence isn't cached in the first place. Accesses should be via writeq though, so do that.Signed-off-by Ian Campbell <[email protected]>Acked-by Julien Grall <[email protected]>Thanks. I think release wise this can wait for 4.5, the flush is unnecessary but not harmful.
While the use of writeq is needed for the additional barriers which it adds it's not strictly needed here because there is no prior write to sequence against (and
ioremap_nocachehas a barrier in it).
Quoted 6 lines
Quoted 2 lines
Unless removing this pointless flush makes some analysis of the use of the functions less confusing perhaps?
For code comprehension, it's better. I think this patch is like "arm:
flush TLB on all CPUs when setting and ...". It's not harmful when Xen is used but it helps readability.
True, I'm not sure I'm comfortable hanging a freeze exception on that though.
Quoted 14 lines
Quoted 14 lines
However thinking about the writeq barriers to lead me to notice the lack of a recommended
dsb()before the subsequent use ofsev(), which is needed to ensure that the write has occurred before we wake the other processor. We get away with this because the iounmap in the middle does awrite_ptewhich has a dsb in it. Phew! Still. for 4.5:8<-----
From
aab391b98760cc8417e06512848cf83dd5d71b5cMon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Wed, 15 Jan 2014 14:49:04 +0000
Subject: [PATCH] xen: arm: add barrier before sev insmp_spin_table_cpu_up
Quoted 5 lines
Quoted 3 lines
This ensures that the writeq to the release address has occurred.
In reality there is a
dsb()in theiounmap()(in the e entualwrite_pte()) bute entual? Did you function
write_pte()?
s/ /v/ => eventual. Oops.
Ian Campbell
AppliedQuoted 8 lines · Julien Grall
Quoted 6 lines · Ian Campbell
flush_xen_data_tlb_range_va()is clearly bogus since it flushes the tlb, not the data cache. Perhaps what was meant wasflush_xen_dcache(), but the address was mapped withioremap_nocacheand hence isn't cached in the first place. Accesses should be via writeq though, so do that.Signed-off-by Ian Campbell <[email protected]>Acked-by Julien Grall <[email protected]>
applied, thanks.