xen/arm64: Branch predictor hardening (XSA-254 variant 2)
cover xen/arm64: Branch predictor hardening (XSA-254 variant 2)
Hi all,
This series provides a framework for mitigating branch predictor hardening on Arm64 on exception entry.
It also implements a dummy PSCI "VERSION" call as the hook for affected Cortex-A CPUs. This will invalidate the predictor state with the latest Arm Trusted Firmware patches which will appear at [1] and SoC vendors with affected CPUs are strongly encouraged to update. We plan to switch to a more efficient, special-purpose call when it is available and the PSCI spec has been updated accordingly.
For more information about the impact of this issue and the software mitigations for Arm processors, please see http://www.arm.com/security-update.
Julien Grall (5):
xen/arm: Introduce enable callback to enable a capabilities on each
online CPU
xen/arm64: Add missing MIDR values for Cortex-A72, A73 and A75 xen/arm: cpuerrata: Add MIDR_ALL_VERSIONS
xen/arm64: Add skeleton to harden the branch predictor aliasing
attacks
xen/arm64: Implement branch predictor hardening for affected Cortex-A
CPUs
xen/arch/arm/Kconfig | 20 ++++ xen/arch/arm/arm64/Makefile | 1 + xen/arch/arm/arm64/bpi.S | 89 +++++++++++++++++ xen/arch/arm/cpuerrata.c | 203 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/cpufeature.c | 29 ++++++ xen/arch/arm/setup.c | 1 + xen/arch/arm/traps.c | 5 +- xen/include/asm-arm/cpuerrata.h | 2 + xen/include/asm-arm/cpufeature.h | 6 +- xen/include/asm-arm/processor.h | 11 ++- 10 files changed, 363 insertions(+), 4 deletions(-) create mode 100644 xen/arch/arm/arm64/bpi.S
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/5 xen/arm: Introduce enable callback to enable a capabilities on each online CPU
Once Xen knows what features/workarounds present on the platform, it might be necessary to configure each online CPU.
Introduce a new callback "enable" that will be called on each online CPU to configure the "capability".
The code is based on Linux v4.14 (where cpufeature.c comes from), the explanation of why using stop_machine_run is kept as we have similar problem in the future.
Lastly introduce enable_errata_workaround that will be called once CPUs have booted and before the hardware domain is created.
This is part of XSA-254.
--- xen/arch/arm/cpuerrata.c | 6 ++++++ xen/arch/arm/cpufeature.c | 29 +++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 1 + xen/include/asm-arm/cpuerrata.h | 1 + xen/include/asm-arm/cpufeature.h | 3 +++ 5 files changed, 40 insertions(+)
xen/arch/arm/cpuerrata.c +6 -0
@@ -64,6 +64,12 @@ void check_local_cpu_errata(void) {update_cpu_capabilities (arm_errata,"enabled workaround for" ); } + +void __init enable_errata_workarounds (void ) +{ +enable_cpu_capabilities (arm_errata); +} +/* * Local variables: * mode: C
xen/arch/arm/cpufeature.c +29 -0
@@ -19,6 +19,7 @@#include <xen/types.h> #include <xen/init.h> #include <xen/smp.h> +#include <xen/stop_machine.h> #include <asm/cpufeature.h> DECLARE_BITMAP (cpu_hwcaps,ARM_NCAPS );
@@ -40,6 +41,34 @@ void update_cpu_capabilities(const struct arm_cpu_capabilities *caps, }/* +* Run through the enabled capabilities and enable() it on all active +* CPUs. +*/ +void __init enable_cpu_capabilities (const struct arm_cpu_capabilities *caps) +{ +for ( ; caps->matches; caps++ ) + { +if ( !cpus_have_cap (caps->capability) ) +continue ; + +if ( caps->enable ) + { +int ret; + +/* +* Use stop_machine_run() as it schedules the work allowing +* us to modify PSTATE, instead of on_each_cpu() which uses +* an IPI, giving us a PSTATE that disappears when we +* return. +*/ + ret =stop_machine_run (caps->enable, (void *)caps,NR_CPUS ); +/* stop_machine_run should never fail at this stage of the boot. */ +BUG_ON (ret); + } + } +} + +/* * Local variables: * mode: C * c-file-style: "BSD"
xen/arch/arm/setup.c +1 -0
@@ -849,6 +849,7 @@ void __init start_xen(unsigned long boot_phys_offset,* stop_machine (tasklets initialized via an initcall). */ apply_alternatives_all (); +enable_errata_workarounds ();/* Create initial domain 0. */ /* The vGIC for DOM0 is exactly emulating the hardware GIC */
xen/include/asm-arm/cpuerrata.h +1 -0
@@ -5,6 +5,7 @@#include <asm/alternative.h> void check_local_cpu_errata (void ); +void enable_errata_workarounds (void );#ifdef CONFIG_HAS_ALTERNATIVE
xen/include/asm-arm/cpufeature.h +3 -0
@@ -74,6 +74,7 @@ struct arm_cpu_capabilities {const char *desc;u16 capability;bool (*matches)(const struct arm_cpu_capabilities *); +int (*enable)(void *);/* Called on every active CPUs */ union { struct { /* To be used for eratum handling only */ u32 midr_model;
@@ -85,6 +86,8 @@ struct arm_cpu_capabilities {void update_cpu_capabilities (const struct arm_cpu_capabilities *caps,const char *info); +void enable_cpu_capabilities (const struct arm_cpu_capabilities *caps); +#endif /* __ASSEMBLY__ */ #endif
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU
Quoted 10 lines · Julien Grall
Once Xen knows what features/workarounds present on the platform, it might be necessary to configure each online CPU.
Introduce a new callback "enable" that will be called on each online CPU to configure the "capability".
The code is based on Linux v4.14 (where
cpufeature.ccomes from), the explanation of why usingstop_machine_runis kept as we have similar problem in the future.
Quoted 6 lines
Lastly introduce
enable_errata_workaroundthat will be called once CPUs have booted and before the hardware domain is created.This is part of XSA-254.
Signed-of-by Julien Grall <[email protected]>
If you took the code from Linux, you need to add the original Signed-off-by from the Linux commit. Aside from that:
Quoted 120 lines
--- xen/arch/arm/cpuerrata.c | 6 ++++++ xen/arch/arm/cpufeature.c | 29 +++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 1 + xen/include/asm-arm/cpuerrata.h | 1 + xen/include/asm-arm/cpufeature.h | 3 +++ 5 files changed, 40 insertions(+)xen/arch/arm/cpuerrata.c +6
-0@@ -64,6 +64,12 @@ void check_local_cpu_errata(void) {update_cpu_capabilities (arm_errata,"enabled workaround for" ); } + +void __init enable_errata_workarounds (void ) +{ +enable_cpu_capabilities (arm_errata); +} +/* * Local variables: * mode: C xen/arch/arm/cpufeature.c +29
-0@@ -19,6 +19,7 @@#include <xen/types.h> #include <xen/init.h> #include <xen/smp.h> +#include <xen/stop_machine.h> #include <asm/cpufeature.h> DECLARE_BITMAP (cpu_hwcaps,ARM_NCAPS );@@ -40,6 +41,34 @@ void update_cpu_capabilities(const struct arm_cpu_capabilities *caps, }/* +* Run through the enabled capabilities and enable() it on all active +* CPUs. +*/ +void __init enable_cpu_capabilities (const struct arm_cpu_capabilities *caps) +{ +for ( ; caps->matches; caps++ ) + { +if ( !cpus_have_cap (caps->capability) ) +continue ; + +if ( caps->enable ) + { +int ret; + +/* +* Use stop_machine_run() as it schedules the work allowing +* us to modify PSTATE, instead of on_each_cpu() which uses +* an IPI, giving us a PSTATE that disappears when we +* return. +*/ + ret =stop_machine_run (caps->enable, (void *)caps,NR_CPUS ); +/* stop_machine_run should never fail at this stage of the boot. */ +BUG_ON (ret); + } + } +} + +/* * Local variables: * mode: C * c-file-style: "BSD" xen/arch/arm/setup.c +1
-0@@ -849,6 +849,7 @@ void __init start_xen(unsigned long boot_phys_offset,* stop_machine (tasklets initialized via an initcall). */ apply_alternatives_all (); +enable_errata_workarounds ();/* Create initial domain 0. */ /* The vGIC for DOM0 is exactly emulating the hardware GIC */ xen/include/asm-arm/cpuerrata.h +1
-0@@ -5,6 +5,7 @@#include <asm/alternative.h> void check_local_cpu_errata (void ); +void enable_errata_workarounds (void );#ifdef CONFIG_HAS_ALTERNATIVE xen/include/asm-arm/cpufeature.h +3
-0@@ -74,6 +74,7 @@ struct arm_cpu_capabilities {const char *desc;u16 capability;bool (*matches)(const struct arm_cpu_capabilities *); +int (*enable)(void *);/* Called on every active CPUs */ union { struct { /* To be used for eratum handling only */ u32 midr_model;@@ -85,6 +86,8 @@ struct arm_cpu_capabilities {void update_cpu_capabilities (const struct arm_cpu_capabilities *caps,const char *info); +void enable_cpu_capabilities (const struct arm_cpu_capabilities *caps); +#endif /* __ASSEMBLY__ */ #endif Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU
Hi Stefano,
Quoted 14 lines · Stefano Stabellini
Quoted 13 lines · Julien Grall
Once Xen knows what features/workarounds present on the platform, it might be necessary to configure each online CPU.
Introduce a new callback "enable" that will be called on each online CPU to configure the "capability".
The code is based on Linux v4.14 (where
cpufeature.ccomes from), the explanation of why usingstop_machine_runis kept as we have similar problem in the future.Lastly introduce
enable_errata_workaroundthat will be called once CPUs have booted and before the hardware domain is created.
Quoted 6 lines
Quoted 3 lines
This is part of XSA-254.
Signed-of-by Julien Grall <[email protected]>If you took the code from Linux, you need to add the original Signed-off-by from the Linux commit. Aside from that:
There are multiple commits touching this function. So I followed what we did in similar situation. By that I mean, mentioning the code was taken from Linux and not gathered the signed-off-by.
If you really want, I can gather all the signed-off-by of the commit touching this function.
Cheers,
Quoted 124 lines
Reviewed-by Stefano Stabellini <[email protected]>Quoted 120 lines
--- xen/arch/arm/cpuerrata.c | 6 ++++++ xen/arch/arm/cpufeature.c | 29 +++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 1 + xen/include/asm-arm/cpuerrata.h | 1 + xen/include/asm-arm/cpufeature.h | 3 +++ 5 files changed, 40 insertions(+)xen/arch/arm/cpuerrata.c +6
-0@@ -64,6 +64,12 @@ void check_local_cpu_errata(void) {update_cpu_capabilities (arm_errata,"enabled workaround for" ); } + +void __init enable_errata_workarounds (void ) +{ +enable_cpu_capabilities (arm_errata); +} +/* * Local variables: * mode: C xen/arch/arm/cpufeature.c +29
-0@@ -19,6 +19,7 @@#include <xen/types.h> #include <xen/init.h> #include <xen/smp.h> +#include <xen/stop_machine.h> #include <asm/cpufeature.h> DECLARE_BITMAP (cpu_hwcaps,ARM_NCAPS );@@ -40,6 +41,34 @@ void update_cpu_capabilities(const struct arm_cpu_capabilities *caps, }/* +* Run through the enabled capabilities and enable() it on all active +* CPUs. +*/ +void __init enable_cpu_capabilities (const struct arm_cpu_capabilities *caps) +{ +for ( ; caps->matches; caps++ ) + { +if ( !cpus_have_cap (caps->capability) ) +continue ; + +if ( caps->enable ) + { +int ret; + +/* +* Use stop_machine_run() as it schedules the work allowing +* us to modify PSTATE, instead of on_each_cpu() which uses +* an IPI, giving us a PSTATE that disappears when we +* return. +*/ + ret =stop_machine_run (caps->enable, (void *)caps,NR_CPUS ); +/* stop_machine_run should never fail at this stage of the boot. */ +BUG_ON (ret); + } + } +} + +/* * Local variables: * mode: C * c-file-style: "BSD" xen/arch/arm/setup.c +1
-0@@ -849,6 +849,7 @@ void __init start_xen(unsigned long boot_phys_offset,* stop_machine (tasklets initialized via an initcall). */ apply_alternatives_all (); +enable_errata_workarounds ();/* Create initial domain 0. */ /* The vGIC for DOM0 is exactly emulating the hardware GIC */ xen/include/asm-arm/cpuerrata.h +1
-0@@ -5,6 +5,7 @@#include <asm/alternative.h> void check_local_cpu_errata (void ); +void enable_errata_workarounds (void );#ifdef CONFIG_HAS_ALTERNATIVE xen/include/asm-arm/cpufeature.h +3
-0@@ -74,6 +74,7 @@ struct arm_cpu_capabilities {const char *desc;u16 capability;bool (*matches)(const struct arm_cpu_capabilities *); +int (*enable)(void *);/* Called on every active CPUs */ union { struct { /* To be used for eratum handling only */ u32 midr_model;@@ -85,6 +86,8 @@ struct arm_cpu_capabilities {void update_cpu_capabilities (const struct arm_cpu_capabilities *caps,const char *info); +void enable_cpu_capabilities (const struct arm_cpu_capabilities *caps); +#endif /* __ASSEMBLY__ */ #endif Signature · 1 line
2.11.0
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU
Quoted 23 lines · Julien Grall
Hi Stefano,
Quoted 16 lines · Stefano Stabellini
Quoted 15 lines · Julien Grall
Once Xen knows what features/workarounds present on the platform, it might be necessary to configure each online CPU.
Introduce a new callback "enable" that will be called on each online CPU to configure the "capability".
The code is based on Linux v4.14 (where
cpufeature.ccomes from), the explanation of why usingstop_machine_runis kept as we have similar problem in the future.Lastly introduce
enable_errata_workaroundthat will be called once CPUs have booted and before the hardware domain is created.This is part of XSA-254.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-of-by Julien Grall <[email protected]>If you took the code from Linux, you need to add the original Signed-off-by from the Linux commit. Aside from that:
There are multiple commits touching this function. So I followed what we did in similar situation. By that I mean, mentioning the code was taken from Linux and not gathered the signed-off-by.
If you really want, I can gather all the signed-off-by of the commit touching this function.
If there are a lot of then, you may want to consider adding a README.source file instead. There are a few examples in tree and they are also mentioned in CONTRIBUTING files Lars
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU
Hi Lars,
Quoted 24 lines · Lars Kurth
Quoted 24 lines · On 17 Jan 2018, at 10:31, Julien Grall <[email protected]…
Hi Stefano,
Quoted 17 lines · Stefano Stabellini
Quoted 16 lines · Julien Grall
Once Xen knows what features/workarounds present on the platform, it might be necessary to configure each online CPU.
Introduce a new callback "enable" that will be called on each online CPU to configure the "capability".
The code is based on Linux v4.14 (where
cpufeature.ccomes from), the explanation of why usingstop_machine_runis kept as we have similar problem in the future.Lastly introduce
enable_errata_workaroundthat will be called once CPUs have booted and before the hardware domain is created.This is part of XSA-254.
Signed-of-by Julien Grall <[email protected] <mailto:[email protected]>>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
If you took the code from Linux, you need to add the original Signed-off-by from the Linux commit. Aside from that:
There are multiple commits touching this function. So I followed what we did in similar situation. By that I mean, mentioning the code was taken from Linux and not gathered the signed-off-by.
If you really want, I can gather all the signed-off-by of the commit touching this function.
If there are a lot of then, you may want to consider adding a README.source file instead. There are a few examples in tree and they are also mentioned in CONTRIBUTING files
I am not sure to understand your suggestion here. I spotted only one CONTRIBUTING file and it only list the license.
Regarding README.source, this is covering file and contain the same mention as in the commit message. As this is a single function. Isn't the commit message enough?
Lastly, we do have quite a bit of code in Xen coming from Linux (or other project). A lot of them are not listed in README.source/CONTRIBUTING. But only mention in the commit message (not necessarily with Signed-off-by tag).
So I am quite interested to know what is the normal procedure here.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU
Hi Julien,
Quoted 6 lines · Julien Grall
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
If you took the code from Linux, you need to add the original Signed-off-by from the Linux commit. Aside from that:
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
There are multiple commits touching this function. So I followed what we did in similar situation. By that I mean, mentioning the code was taken from Linux and not gathered the signed-off-by.
If you really want, I can gather all the signed-off-by of the commit touching this function.
If there are a lot of then, you may want to consider adding a README.source file instead. There are a few examples in tree and they are also mentioned in CONTRIBUTING files
I am not sure to understand your suggestion here. I spotted only one CONTRIBUTING file and it only list the license.
I was suggesting to create a README.source in the xen arm tree seomwhere where you can list imports.
Quoted 1 line
Regarding README.source, this is covering file and contain the same mention as in the commit message. As this is a single function. Isn't the commit message enough?
From a legal viewpoint it is enough.
The reason why we created the README.source file is because it is very easy to miss code imports when they are mentioned in commit messages.
Normally this isn't a problem: only if we ever have to relicense the code or if someone does code archeology
When we relicensed the ACPI builder, it created all sorts of problems as outlined in https://www.slideshare.net/xen_com_mgr/ossa17-mixed-license-foss-projects <https://www.slideshare.net/xen_com_mgr/ossa17-mixed-license-foss-projects>
Quoted 1 line
Lastly, we do have quite a bit of code in Xen coming from Linux (or other project). A lot of them are not listed in README.source/CONTRIBUTING. But only mention in the commit message (not necessarily with Signed-off-by tag).
That is true: which is why I have started fixing these, whenever I found them and moved such information to README.source.
Quoted 1 line
So I am quite interested to know what is the normal procedure here.
I think:
* Doing this via Signed-off-by tag is sufficient for a one-off-import
* I would prefer if people added import related info README.source files (and also in the commit message)
Does this make sense?
Lars
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU
Quoted 5 lines · Lars Kurth
Regarding README.source, this is covering file and contain the same mention as in the commit message. As this is a single function. Isn't the commit message enough?
From a legal viewpoint it is enough.
If that is enough from a legal viewpoint, then it is enough for me.
However, from a legal viewpoint, I thought we needed to explicitly mention all the original signed-off-bys because Julien is not actually the copyright holder for that function, hence, we need to add the signed-off-bys of all the missing copyright holders.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Lars Kurth
Regarding README.source, this is covering file and contain the same mention as in the commit message. As this is a single function. Isn't the commit message enough?
Quoted 8 lines
Quoted 1 line
From a legal viewpoint it is enough.
If that is enough from a legal viewpoint, then it is enough for me.
However, from a legal viewpoint, I thought we needed to explicitly mention all the original signed-off-bys because Julien is not actually the copyright holder for that function, hence, we need to add the signed-off-bys of all the missing copyright holders.
Actually, reading again the Developer’s Certificate of Origin, it states:
"The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file"
so I think Lars is right. In that case, there is no need to resubmit this series, I'll commit to staging as is. If tests go well, I'll backport it to the stable trees.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
XSA-254 SP2 for ARM (was Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU)
(+ Security team)
Hi Stefano,
Quoted 15 lines · Stefano Stabellini
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Lars Kurth
Regarding README.source, this is covering file and contain the same mention as in the commit message. As this is a single function. Isn't the commit message enough?
Quoted 8 lines
Quoted 1 line
From a legal viewpoint it is enough.
If that is enough from a legal viewpoint, then it is enough for me.
However, from a legal viewpoint, I thought we needed to explicitly mention all the original signed-off-bys because Julien is not actually the copyright holder for that function, hence, we need to add the signed-off-bys of all the missing copyright holders.
Quoted 8 lines
Actually, reading again the Developer’s Certificate of Origin, it states:
"The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file"
so I think Lars is right. In that case, there is no need to resubmit this series, I'll commit to staging as is. If tests go well, I'll backport it to the stable trees.
Thank you! I have created branches with patches backported up to Xen 4.8. With minor changes:
- Xen 4.10: No changes
- Xen 4.9:
* minor conflict in some files
* compilation failure in cpuerrata.c (__virt_to_mfn does not exist)
- Xen 4.8:
* conflict in some files (one medium as the number of "features" is
different)
* compilation failure in cpuerrata.c (__virt_to_mfn does not exist)
The branches can be found on xenbits [1] : xsa-254-sp2-X.XX where X.XX is the version of Xen.
Xen 4.7 and earlier does not have cpufeature/cpuerrata infrastructure and will require backport. The only difficulty here should be finding the list of commits required.
Also, we probably want to update the XSA pointing to the patches. So if someone wants to backport to Xen 4.7 (or earlier) they can. Any opinions?
Cheers,
[1] https://xenbits.xen.org/git-http/people/julieng/xen-unstable.git
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: XSA-254 SP2 for ARM (was Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU)
Quoted 50 lines · Julien Grall
(+ Security team)
Hi Stefano,
Quoted 27 lines · Stefano Stabellini
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Lars Kurth
Regarding README.source, this is covering file and contain the
same mention as in the commit message. As this is a single function. Isn't the commit message
enough?Quoted 8 lines
Quoted 1 line
From a legal viewpoint it is enough.
If that is enough from a legal viewpoint, then it is enough for me.
However, from a legal viewpoint, I thought we needed to explicitly mention all the original signed-off-bys because Julien is not actually the copyright holder for that function, hence, we need to add the signed-off-bys of all the missing copyright holders.
Actually, reading again the Developer’s Certificate of Origin, it states:
"The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file"
Quoted 3 lines
so I think Lars is right. In that case, there is no need to resubmit this series, I'll commit to staging as is. If tests go well, I'll backport it to the stable trees.
Thank you! I have created branches with patches backported up to Xen 4.8. With minor changes:
- Xen 4.10: No changes
- Xen 4.9:
* minor conflict in some files
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)
- Xen 4.8:
* conflict in some files (one medium as the number of "features" is
different)
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)The branches can be found on xenbits [1] : xsa-254-sp2-X.XX where X.XX is the version of Xen.
Quoted 6 lines
Xen 4.7 and earlier does not have cpufeature/cpuerrata infrastructure and will require backport. The only difficulty here should be finding the list of commits required.
Also, we probably want to update the XSA pointing to the patches. So if someone wants to backport to Xen 4.7 (or earlier) they can. Any opinions?
Thank you, Julien. Ideally, I would like to do the backports after OSSTest passes its tests on those changes. In practice, for the sake of mitigating SP2 as soon as possible, tomorrow (Friday) I might do the backports anyway, if OSSTest is still behind on other problems.
I don't think that backporting cpufeature/cpuerrata to 4.7 should be too convoluted, I'll give that a go as well.
Once done, I'll provide the list of commits to the xen security list so that the XSA advisory can be updated appropriately.
Cheers,
Stefano
Quoted 3 lines
Cheers,
[1] https://xenbits.xen.org/git-http/people/julieng/xen-unstable.git
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: XSA-254 SP2 for ARM (was Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU)
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 18.01.18 at 21:28, <[email protected]> wrote:
Thank you, Julien. Ideally, I would like to do the backports after OSSTest passes its tests on those changes. In practice, for the sake of mitigating SP2 as soon as possible, tomorrow (Friday) I might do the backports anyway, if OSSTest is still behind on other problems.
Please avoid touching the 4.8 tree for the moment, until 4.8.3 has been tagged.
Thanks, Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: XSA-254 SP2 for ARM (was Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU)
Quoted 8 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 18.01.18 at 21:28, <[email protected]> wrote:
Thank you, Julien. Ideally, I would like to do the backports after OSSTest passes its tests on those changes. In practice, for the sake of mitigating SP2 as soon as possible, tomorrow (Friday) I might do the backports anyway, if OSSTest is still behind on other problems.
Please avoid touching the 4.8 tree for the moment, until 4.8.3 has been tagged.
Many thanks for the head's up, I'll wait.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: XSA-254 SP2 for ARM (was Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU)
In reply to Julien GrallQuoted 50 lines · Julien Grall
(+ Security team)
Hi Stefano,
Quoted 27 lines · Stefano Stabellini
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Lars Kurth
Regarding README.source, this is covering file and contain the
same mention as in the commit message. As this is a single function. Isn't the commit message
enough?Quoted 8 lines
Quoted 1 line
From a legal viewpoint it is enough.
If that is enough from a legal viewpoint, then it is enough for me.
However, from a legal viewpoint, I thought we needed to explicitly mention all the original signed-off-bys because Julien is not actually the copyright holder for that function, hence, we need to add the signed-off-bys of all the missing copyright holders.
Actually, reading again the Developer’s Certificate of Origin, it states:
"The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file"
Quoted 3 lines
so I think Lars is right. In that case, there is no need to resubmit this series, I'll commit to staging as is. If tests go well, I'll backport it to the stable trees.
Thank you! I have created branches with patches backported up to Xen 4.8. With minor changes:
- Xen 4.10: No changes
- Xen 4.9:
* minor conflict in some files
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)
- Xen 4.8:
* conflict in some files (one medium as the number of "features" is
different)
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)The branches can be found on xenbits [1] : xsa-254-sp2-X.XX where X.XX is the version of Xen.
Quoted 6 lines
Xen 4.7 and earlier does not have cpufeature/cpuerrata infrastructure and will require backport. The only difficulty here should be finding the list of commits required.
Also, we probably want to update the XSA pointing to the patches. So if someone wants to backport to Xen 4.7 (or earlier) they can. Any opinions?
These are the commits for the XSA 254 mitigation for the arm64 architecture:
staging-4.10b829d42829c1ff626a02756acae4dd482fc20c9a0f7a4faafb2d79920cc63457cfca3e03990af4ccd1f4283a1d8405a480b4121e1efcfaec8bbdbffacae6e1572f39a1906be0fc3bdaf49fe514c6a9c0928112900e5b4a92ccebb2eea11665fd76aa0f0d728fadb586a2a14a244dabd70463bcc1654ecc85
staging-4.92ec7ccbffc6b788f65e55498e4347c1ee3a44b0150450c1f33dc72f2138a671d738934f796be33183790833ef16b95653424ec9b145e460ec1a56d16fba48eff18c02d716c95b92df804a755620be82e9f79e8d846e8413c828f5fc7cc6ac733728dff00a2567d6b54b7b187ecc0165021b6dd07dafaf06a
staging-4.8946dd2eefae2faeecbeb9662e66935c8070f64f585990bf53addcdb0ce8e458a3d8fad199710ac59cf0b584c8c5030588bc47a3614ad860af7482c5344139fed7c794eb4e47a9bb93061e325bd57fe8c6f6786ef0d7f7025860d360f6b1267193ffd1b27
For staging-4.7, I made the backports and tested them as well. They look correct. However, given that it was more complex than initially though, I would appreciate if you could give it a look as well (I haven't pushed it staging-4.7 yet):
git://xenbits.xen.org/people/sstabellini/xen-unstable.git staging-4.7-xsa254
Thanks!
- Stefano
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: XSA-254 SP2 for ARM (was Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU)
Hi Stefano,
Quoted 77 lines · Stefano Stabellini
Quoted 50 lines · Julien Grall
(+ Security team)
Hi Stefano,
Quoted 27 lines · Stefano Stabellini
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Lars Kurth
Regarding README.source, this is covering file and contain the
same mention as in the commit message. As this is a single function. Isn't the commit message
enough?Quoted 8 lines
Quoted 1 line
From a legal viewpoint it is enough.
If that is enough from a legal viewpoint, then it is enough for me.
However, from a legal viewpoint, I thought we needed to explicitly mention all the original signed-off-bys because Julien is not actually the copyright holder for that function, hence, we need to add the signed-off-bys of all the missing copyright holders.
Actually, reading again the Developer’s Certificate of Origin, it states:
"The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file"
Quoted 3 lines
so I think Lars is right. In that case, there is no need to resubmit this series, I'll commit to staging as is. If tests go well, I'll backport it to the stable trees.
Thank you! I have created branches with patches backported up to Xen 4.8. With minor changes:
- Xen 4.10: No changes
- Xen 4.9:
* minor conflict in some files
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)
- Xen 4.8:
* conflict in some files (one medium as the number of "features" is
different)
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)The branches can be found on xenbits [1] : xsa-254-sp2-X.XX where X.XX is the version of Xen.
Quoted 6 lines
Xen 4.7 and earlier does not have cpufeature/cpuerrata infrastructure and will require backport. The only difficulty here should be finding the list of commits required.
Also, we probably want to update the XSA pointing to the patches. So if someone wants to backport to Xen 4.7 (or earlier) they can. Any opinions?
These are the commits for the XSA 254 mitigation for the arm64 architecture:
staging-4.10
b829d42829c1ff626a02756acae4dd482fc20c9a0f7a4faafb2d79920cc63457cfca3e03990af4ccd1f4283a1d8405a480b4121e1efcfaec8bbdbffacae6e1572f39a1906be0fc3bdaf49fe514c6a9c0928112900e5b4a92ccebb2eea11665fd76aa0f0d728fadb586a2a14a244dabd70463bcc1654ecc85staging-4.9
2ec7ccbffc6b788f65e55498e4347c1ee3a44b0150450c1f33dc72f2138a671d738934f796be33183790833ef16b95653424ec9b145e460ec1a56d16fba48eff18c02d716c95b92df804a755620be82e9f79e8d846e8413c828f5fc7cc6ac733728dff00a2567d6b54b7b187ecc0165021b6dd07dafaf06a
Quoted 6 lines
staging-4.8
946dd2eefae2faeecbeb9662e66935c8070f64f585990bf53addcdb0ce8e458a3d8fad199710ac59cf0b584c8c5030588bc47a3614ad860af7482c5344139fed7c794eb4e47a9bb93061e325bd57fe8c6f6786ef0d7f7025860d360f6b1267193ffd1b27
Something looks quite odd. The commit message have two cherry-pick commit ID.
Why didn't you just merged the branches I provided?
Quoted 7 lines
For staging-4.7, I made the backports and tested them as well. They look correct. However, given that it was more complex than initially though, I would appreciate if you could give it a look as well (I haven't pushed it staging-4.7 yet):
git://xenbits.xen.org/people/sstabellini/xen-unstable.gitstaging-4.7-xsa254
I will have a look.
Cheers,
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: XSA-254 SP2 for ARM (was Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU)
Quoted 87 lines · Julien Grall
Hi Stefano,
Quoted 77 lines · Stefano Stabellini
Quoted 50 lines · Julien Grall
(+ Security team)
Hi Stefano,
Quoted 27 lines · Stefano Stabellini
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Lars Kurth
Regarding README.source, this is covering file and contain the
same mention as in the commit message. As this is a single function. Isn't the commit message
enough?Quoted 8 lines
Quoted 1 line
From a legal viewpoint it is enough.
If that is enough from a legal viewpoint, then it is enough for me.
However, from a legal viewpoint, I thought we needed to explicitly mention all the original signed-off-bys because Julien is not actually the copyright holder for that function, hence, we need to add the signed-off-bys of all the missing copyright holders.
Actually, reading again the Developer’s Certificate of Origin, it states:
"The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file"
Quoted 3 lines
so I think Lars is right. In that case, there is no need to resubmit this series, I'll commit to staging as is. If tests go well, I'll backport it to the stable trees.
Thank you! I have created branches with patches backported up to Xen 4.8. With minor changes:
- Xen 4.10: No changes
- Xen 4.9:
* minor conflict in some files
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)
- Xen 4.8:
* conflict in some files (one medium as the number of "features" is
different)
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)The branches can be found on xenbits [1] : xsa-254-sp2-X.XX where X.XX is the version of Xen.
Quoted 6 lines
Xen 4.7 and earlier does not have cpufeature/cpuerrata infrastructure and will require backport. The only difficulty here should be finding the list of commits required.
Also, we probably want to update the XSA pointing to the patches. So if someone wants to backport to Xen 4.7 (or earlier) they can. Any opinions?
These are the commits for the XSA 254 mitigation for the arm64 architecture:
staging-4.10
b829d42829c1ff626a02756acae4dd482fc20c9a0f7a4faafb2d79920cc63457cfca3e03990af4ccd1f4283a1d8405a480b4121e1efcfaec8bbdbffacae6e1572f39a1906be0fc3bdaf49fe514c6a9c0928112900e5b4a92ccebb2eea11665fd76aa0f0d728fadb586a2a14a244dabd70463bcc1654ecc85staging-4.9
2ec7ccbffc6b788f65e55498e4347c1ee3a44b0150450c1f33dc72f2138a671d738934f796be33183790833ef16b95653424ec9b145e460ec1a56d16fba48eff18c02d716c95b92df804a755620be82e9f79e8d846e8413c828f5fc7cc6ac733728dff00a2567d6b54b7b187ecc0165021b6dd07dafaf06aQuoted 6 lines
staging-4.8
946dd2eefae2faeecbeb9662e66935c8070f64f585990bf53addcdb0ce8e458a3d8fad199710ac59cf0b584c8c5030588bc47a3614ad860af7482c5344139fed7c794eb4e47a9bb93061e325bd57fe8c6f6786ef0d7f7025860d360f6b1267193ffd1b27
Quoted 3 lines
Something looks quite odd. The commit message have two cherry-pick commit ID.
Why didn't you just merged the branches I provided?
Basically I did the backports on my own, then I double-checked that they matched your own version of the backports. I did it for safety: this way we can be quite sure that the backports are good, or both of us did exactly the same mistakes :-)
It was very helpful to have branches to compare against, thank you for that.
Quoted 9 lines
Quoted 7 lines
For staging-4.7, I made the backports and tested them as well. They look correct. However, given that it was more complex than initially though, I would appreciate if you could give it a look as well (I haven't pushed it staging-4.7 yet):
git://xenbits.xen.org/people/sstabellini/xen-unstable.gitstaging-4.7-xsa254I will have a look.
Thanks again!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: XSA-254 SP2 for ARM (was Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU)
Hi,
Quoted 90 lines · Stefano Stabellini
Quoted 89 lines · Julien Grall
Hi Stefano,
Quoted 77 lines · Stefano Stabellini
Quoted 50 lines · Julien Grall
(+ Security team)
Hi Stefano,
Quoted 27 lines · Stefano Stabellini
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Lars Kurth
Regarding README.source, this is covering file and contain the
same mention as in the commit message. As this is a single function. Isn't the commit message
enough?Quoted 8 lines
Quoted 1 line
From a legal viewpoint it is enough.
If that is enough from a legal viewpoint, then it is enough for me.
However, from a legal viewpoint, I thought we needed to explicitly mention all the original signed-off-bys because Julien is not actually the copyright holder for that function, hence, we need to add the signed-off-bys of all the missing copyright holders.
Actually, reading again the Developer’s Certificate of Origin, it states:
"The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file"
Quoted 3 lines
so I think Lars is right. In that case, there is no need to resubmit this series, I'll commit to staging as is. If tests go well, I'll backport it to the stable trees.
Thank you! I have created branches with patches backported up to Xen 4.8. With minor changes:
- Xen 4.10: No changes
- Xen 4.9:
* minor conflict in some files
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)
- Xen 4.8:
* conflict in some files (one medium as the number of "features" is
different)
* compilation failure incpuerrata.c(__virt_to_mfndoes not exist)The branches can be found on xenbits [1] : xsa-254-sp2-X.XX where X.XX is the version of Xen.
Quoted 6 lines
Xen 4.7 and earlier does not have cpufeature/cpuerrata infrastructure and will require backport. The only difficulty here should be finding the list of commits required.
Also, we probably want to update the XSA pointing to the patches. So if someone wants to backport to Xen 4.7 (or earlier) they can. Any opinions?
These are the commits for the XSA 254 mitigation for the arm64 architecture:
staging-4.10
b829d42829c1ff626a02756acae4dd482fc20c9a0f7a4faafb2d79920cc63457cfca3e03990af4ccd1f4283a1d8405a480b4121e1efcfaec8bbdbffacae6e1572f39a1906be0fc3bdaf49fe514c6a9c0928112900e5b4a92ccebb2eea11665fd76aa0f0d728fadb586a2a14a244dabd70463bcc1654ecc85staging-4.9
2ec7ccbffc6b788f65e55498e4347c1ee3a44b0150450c1f33dc72f2138a671d738934f796be33183790833ef16b95653424ec9b145e460ec1a56d16fba48eff18c02d716c95b92df804a755620be82e9f79e8d846e8413c828f5fc7cc6ac733728dff00a2567d6b54b7b187ecc0165021b6dd07dafaf06aQuoted 6 lines
staging-4.8
946dd2eefae2faeecbeb9662e66935c8070f64f585990bf53addcdb0ce8e458a3d8fad199710ac59cf0b584c8c5030588bc47a3614ad860af7482c5344139fed7c794eb4e47a9bb93061e325bd57fe8c6f6786ef0d7f7025860d360f6b1267193ffd1b27Something looks quite odd. The commit message have two cherry-pick commit ID.
Quoted 8 lines
Quoted 1 line
Why didn't you just merged the branches I provided?
Basically I did the backports on my own, then I double-checked that they matched your own version of the backports. I did it for safety: this way we can be quite sure that the backports are good, or both of us did exactly the same mistakes :-)
It was very helpful to have branches to compare against, thank you for that.
I also double checked it yesterday because I wasn't sure what you did :).
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
For staging-4.7, I made the backports and tested them as well. They look correct. However, given that it was more complex than initially though, I would appreciate if you could give it a look as well (I haven't pushed it staging-4.7 yet):
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
git://xenbits.xen.org/people/sstabellini/xen-unstable.gitstaging-4.7-xsa254I will have a look.
Thanks again!
This looks good to me. Thank you for backporting them to 4.7.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: XSA-254 SP2 for ARM (was Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU)
Quoted 132 lines · Julien Grall
Hi,
Quoted 110 lines · Stefano Stabellini
Quoted 109 lines · Julien Grall
Hi Stefano,
Quoted 95 lines · Stefano Stabellini
Quoted 70 lines · Julien Grall
(+ Security team)
Hi Stefano,
Quoted 36 lines · Stefano Stabellini
Quoted 11 lines · Stefano Stabellini
Quoted 9 lines · Lars Kurth
Regarding README.source, this is covering file and
contain the
same mention as in the commit message. As this is a single function.
Isn't the commit message
enough?From a legal viewpoint it is enough.
Quoted 8 lines
If that is enough from a legal viewpoint, then it is enough for me.
However, from a legal viewpoint, I thought we needed to explicitly mention all the original signed-off-bys because Julien is not actually
the copyright holder for that function, hence, we need to add the signed-off-bys of all the missing copyright holders.Actually, reading again the Developer’s Certificate of Origin, it states:
"The contribution is based upon previous work that, to the best of my
knowledge, is covered under an appropriate open source license and I have
the right under that license to submit that work with modifications, whether
created in whole or in part by me, under the same open source license
(unless I am permitted to submit under a different license), as indicated in
the file"Quoted 3 lines
so I think Lars is right. In that case, there is no need to resubmit this series, I'll commit to staging as is. If tests go well, I'll backport it to the stable trees.
Thank you! I have created branches with patches backported up to Xen 4.8. With
minor changes:- Xen 4.10: No changes
- Xen 4.9:
* minor conflict in some files
* compilation failure incpuerrata.c(__virt_to_mfndoes not
exist)
- Xen 4.8:
* conflict in some files (one medium as the number of
"features" is
different)
* compilation failure incpuerrata.c(__virt_to_mfndoes not
exist)The branches can be found on xenbits [1] : xsa-254-sp2-X.XX where X.XX is the
version of Xen.Xen 4.7 and earlier does not have cpufeature/cpuerrata infrastructure and will
require backport. The only difficulty here should be finding the list of
commits required.Quoted 4 lines
Also, we probably want to update the XSA pointing to the patches. So if
someone wants to backport to Xen 4.7 (or earlier) they can. Any opinions?These are the commits for the XSA 254 mitigation for the arm64 architecture:
staging-4.10
b829d42829c1ff626a02756acae4dd482fc20c9a0f7a4faafb2d79920cc63457cfca3e03990af4ccd1f4283a1d8405a480b4121e1efcfaec8bbdbffacae6e1572f39a1906be0fc3bdaf49fe514c6a9c0928112900e5b4a92ccebb2eea11665fd76aa0f0d728fadb586a2a14a244dabd70463bcc1654ecc85staging-4.9
2ec7ccbffc6b788f65e55498e4347c1ee3a44b0150450c1f33dc72f2138a671d738934f796be33183790833ef16b95653424ec9b145e460ec1a56d16fba48eff18c02d716c95b92df804a755620be82e9f79e8d846e8413c828f5fc7cc6ac733728dff00a2567d6b54b7b187ecc0165021b6dd07dafaf06aQuoted 6 lines
staging-4.8
946dd2eefae2faeecbeb9662e66935c8070f64f585990bf53addcdb0ce8e458a3d8fad199710ac59cf0b584c8c5030588bc47a3614ad860af7482c5344139fed7c794eb4e47a9bb93061e325bd57fe8c6f6786ef0d7f7025860d360f6b1267193ffd1b27Something looks quite odd. The commit message have two cherry-pick commit ID.
Quoted 8 lines
Quoted 1 line
Why didn't you just merged the branches I provided?
Basically I did the backports on my own, then I double-checked that they matched your own version of the backports. I did it for safety: this way we can be quite sure that the backports are good, or both of us did exactly the same mistakes :-)
It was very helpful to have branches to compare against, thank you for that.I also double checked it yesterday because I wasn't sure what you did :).
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
For staging-4.7, I made the backports and tested them as well. They look correct. However, given that it was more complex than initially though, I would appreciate if you could give it a look as well (I haven't pushed it staging-4.7 yet):
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
git://xenbits.xen.org/people/sstabellini/xen-unstable.git
staging-4.7-xsa254I will have a look.
Thanks again!
This looks good to me. Thank you for backporting them to 4.7.
Thank you! I pushed the branch, these are the relevant commits for 4.7:
fd884d6 xen/arm64: Implement branch predictor hardening for affected Cortex-A CPUs 50c68df xen/arm64: Add skeleton to harden the branch predictor aliasing attacks 1bdcc9f xen/arm: cpuerrata: Add MIDR_ALL_VERSIONS
2914ef5 xen/arm64: Add missing MIDR values for Cortex-A72, A73 and A75 62b9706 xen/arm: Introduce enable callback to enable a capabilities on each online CPU 624abdc xen/arm: Detect silicon revision and set cap bits accordingly d7b73ed xen/arm: cpufeature: Provide an helper to check if a capability is supported 112c49c xen/arm: Add cpu_hwcap bitmap
a5b0fa4 xen/arm: Add macros to handle the MIDR
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU
In reply to Lars KurthQuoted 1 line · Lars Kurth
Hi Julien,
Hi Lars,
Quoted 11 lines
Quoted 11 lines · On 17 Jan 2018, at 12:31, Julien Grall <[email protected]…
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If you took the code from Linux, you need to add the original Signed-off-by from the Linux commit. Aside from that:
There are multiple commits touching this function. So I followed what we did in similar situation. By that I mean, mentioning the code was taken from Linux and not gathered the signed-off-by.
If you really want, I can gather all the signed-off-by of the commit touching this function.
If there are a lot of then, you may want to consider adding a README.source file instead. There are a few examples in tree and they are also mentioned in CONTRIBUTING files
Quoted 8 lines
Quoted 1 line
I am not sure to understand your suggestion here. I spotted only one CONTRIBUTING file and it only list the license.
I was suggesting to create a README.source in the xen arm tree seomwhere where you can list imports.
Quoted 1 line
Regarding README.source, this is covering file and contain the same mention as in the commit message. As this is a single function. Isn't the commit message enough?
From a legal viewpoint it is enough.
The reason why we created the README.source file is because it is very easy to miss code imports when they are mentioned in commit messages.
I understand that.
Quoted 8 lines
Normally this isn't a problem: only if we ever have to relicense the code or if someone does code archeology
When we relicensed the ACPI builder, it created all sorts of problems as outlined in https://www.slideshare.net/xen_com_mgr/ossa17-mixed-license-foss-projectsQuoted 1 line
Lastly, we do have quite a bit of code in Xen coming from Linux (or other project). A lot of them are not listed in README.source/CONTRIBUTING. But only mention in the commit message (not necessarily with Signed-off-by tag).
That is true: which is why I have started fixing these, whenever I found them and moved such information to README.source.
Quoted 7 lines
Quoted 1 line
So I am quite interested to know what is the normal procedure here.
I think:
* Doing this via Signed-off-by tag is sufficient for a one-off-import
* I would prefer if people added import related info README.source files (and also in the commit message)Does this make sense?
I think it makes sense. Do you expect to see the README.source per-directory? Or one at top level?
Cheers,
Quoted 2 lines
Lars
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 1/5] xen/arm: Introduce enable callback to enable a capabilities on each online CPU
Hi Julien,
Quoted 7 lines · Julien Grall
Quoted 1 line · Lars Kurth
Hi Julien,
Hi Lars,
...
Quoted 11 lines
Quoted 9 lines
Normally this isn't a problem: only if we ever have to relicense the code or if someone does code archeology
When we relicensed the ACPI builder, it created all sorts of problems as outlined in https://www.slideshare.net/xen_com_mgr/ossa17-mixed-license-foss-projects <https://www.slideshare.net/xen_com_mgr/ossa17-mixed-license-foss-projects>Quoted 1 line
Lastly, we do have quite a bit of code in Xen coming from Linux (or other project). A lot of them are not listed in README.source/CONTRIBUTING. But only mention in the commit message (not necessarily with Signed-off-by tag).
That is true: which is why I have started fixing these, whenever I found them and moved such information to README.source.
Quoted 1 line
So I am quite interested to know what is the normal procedure here.
I think:
* Doing this via Signed-off-by tag is sufficient for a one-off-import
* I would prefer if people added import related info README.source files (and also in the commit message) Does this make sense?I think it makes sense. Do you expect to see the README.source per-directory? Or one at top level?
I think one somewhere at the top level of the ARM tree is sufficient. It depends on how often you import code. It shouldn't block the series. Just something to do at some point Lars
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/5 xen/arm64: Add missing MIDR values for Cortex-A72, A73 and A75
In reply to Julien GrallCortex-A72, A73 and A75 MIDR will be used to a follow-up for hardening the branch predictor.
This is part of XSA-254.
--- xen/include/asm-arm/processor.h | 6 ++++++ 1 file changed, 6 insertions(+)
xen/include/asm-arm/processor.h +6 -0
@@ -47,10 +47,16 @@#define ARM_CPU_PART_CORTEX_A15 0xC0F#define ARM_CPU_PART_CORTEX_A53 0xD03#define ARM_CPU_PART_CORTEX_A57 0xD07 +#define ARM_CPU_PART_CORTEX_A72 0xD08 +#define ARM_CPU_PART_CORTEX_A73 0xD09 +#define ARM_CPU_PART_CORTEX_A75 0xD0A#define MIDR_CORTEX_A15 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A15)#define MIDR_CORTEX_A53 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53)#define MIDR_CORTEX_A57 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57) +#define MIDR_CORTEX_A72 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A72) +#define MIDR_CORTEX_A73 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A73) +#define MIDR_CORTEX_A75 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A75)/* MPIDR Multiprocessor Affinity Register */ #define _MPIDR_UP (30)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 2/5] xen/arm64: Add missing MIDR values for Cortex-A72, A73 and A75
Quoted 6 lines · Julien Grall
Cortex-A72, A73 and A75 MIDR will be used to a follow-up for hardening the branch predictor.
This is part of XSA-254.
Signed-off-by Julien Grall <[email protected]>
Quoted 28 lines
--- xen/include/asm-arm/processor.h | 6 ++++++ 1 file changed, 6 insertions(+)xen/include/asm-arm/processor.h +6
-0@@ -47,10 +47,16 @@#define ARM_CPU_PART_CORTEX_A15 0xC0F#define ARM_CPU_PART_CORTEX_A53 0xD03#define ARM_CPU_PART_CORTEX_A57 0xD07 +#define ARM_CPU_PART_CORTEX_A72 0xD08 +#define ARM_CPU_PART_CORTEX_A73 0xD09 +#define ARM_CPU_PART_CORTEX_A75 0xD0A#define MIDR_CORTEX_A15 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A15)#define MIDR_CORTEX_A53 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53)#define MIDR_CORTEX_A57 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57) +#define MIDR_CORTEX_A72 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A72) +#define MIDR_CORTEX_A73 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A73) +#define MIDR_CORTEX_A75 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A75)/* MPIDR Multiprocessor Affinity Register */ #define _MPIDR_UP (30)Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/5 xen/arm: cpuerrata: Add MIDR_ALL_VERSIONS
In reply to Julien GrallIntroduce a new macro MIDR_ALL_VERSIONS to match all variant/revision of a given CPU model.
This is part of XSA-254.
--- xen/arch/arm/cpuerrata.c | 6 ++++++ 1 file changed, 6 insertions(+)
xen/arch/arm/cpuerrata.c +6 -0
@@ -7,6 +7,12 @@ .midr_range_min = min, \ .midr_range_max = max +#define MIDR_ALL_VERSIONS (model) \ + .matches = is_affected_midr_range, \ + .midr_model = model, \ + .midr_range_min = 0, \ + .midr_range_max = (MIDR_VARIANT_MASK | MIDR_REVISION_MASK) +static bool __maybe_unused is_affected_midr_range (const struct arm_cpu_capabilities *entry) {
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 3/5] xen/arm: cpuerrata: Add MIDR_ALL_VERSIONS
Quoted 6 lines · Julien Grall
Introduce a new macro
MIDR_ALL_VERSIONSto match all variant/revision of a given CPU model.This is part of XSA-254.
Signed-off-by Julien Grall <[email protected]>
Quoted 24 lines
--- xen/arch/arm/cpuerrata.c | 6 ++++++ 1 file changed, 6 insertions(+)xen/arch/arm/cpuerrata.c +6
-0@@ -7,6 +7,12 @@ .midr_range_min = min, \ .midr_range_max = max +#define MIDR_ALL_VERSIONS (model) \ + .matches = is_affected_midr_range, \ + .midr_model = model, \ + .midr_range_min = 0, \ + .midr_range_max = (MIDR_VARIANT_MASK | MIDR_REVISION_MASK) +static bool __maybe_unused is_affected_midr_range (const struct arm_cpu_capabilities *entry) {Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 4/5 xen/arm64: Add skeleton to harden the branch predictor aliasing attacks
In reply to Julien GrallAliasing attacked against CPU branch predictors can allow an attacker to redirect speculative control flow on some CPUs and potentially divulge information from one context to another.
This patch adds initial skeleton code behind a new Kconfig option to enable implementation-specific mitigations against these attacks for CPUs that are affected.
Most of the mitigations will have to be applied when entering to the hypervisor from the guest context. For safety, it is applied at every exception entry. So there are potential for optimizing when receiving an exception at the same level.
Because the attack is against branch predictor, it is not possible to safely use branch instruction before the mitigation is applied. Therefore, this has to be done in the vector entry before jump to the helper handling a given exception.
On Arm64, each vector can hold 32 instructions. This leave us 31 instructions for the mitigation. The last one is the branch instruction to the helper.
Because a platform may have CPUs with different micro-architectures, per-CPU vector table needs to be provided. Realistically, only a few different mitigations will be necessary. So provide a small set of vector tables. They will be re-used and patch with the mitigations on-demand.
This is based on the work done in Linux (see [1]).
This is part of XSA-254.
[1] git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
branch ktpi
--- xen/arch/arm/Kconfig | 20 ++++++ xen/arch/arm/arm64/Makefile | 1 + xen/arch/arm/arm64/bpi.S | 64 ++++++++++++++++++ xen/arch/arm/cpuerrata.c | 142 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/traps.c | 5 +- xen/include/asm-arm/cpuerrata.h | 1 + xen/include/asm-arm/cpufeature.h | 3 +- xen/include/asm-arm/processor.h | 5 +- 8 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 xen/arch/arm/arm64/bpi.S
xen/arch/arm/Kconfig +20 -0
@@ -171,6 +171,26 @@ config ARM64_ERRATUM_834220 endmenu +config HARDEN_BRANCH_PREDICTOR + bool "Harden the branch predictor against aliasing attacks" if EXPERT + default y + help + Speculation attacks against some high-performance processors rely on + being able to manipulate the branch predictor for a victim context by + executing aliasing branches in the attacker context. Such attacks + can be partially mitigated against by clearing internal branch + predictor state and limiting the prediction logic in some situations. + + This config option will take CPU-specific actions to harden the + branch predictor against aliasing attacks and may rely on specific + instruction sequences or control bits being set by the system + firmware. + + If unsure, say Y. + +config ARM64_HARDEN_BRANCH_PREDICTOR + def_bool y if ARM_64 && HARDEN_BRANCH_PREDICTOR + source "common/Kconfig" source "drivers/Kconfig"
xen/arch/arm/arm64/Makefile +1 -0
@@ -1,6 +1,7 @@ subdir-y += lib obj-y += cache.o +obj-$(CONFIG_HARDEN_BRANCH_PREDICTOR) += bpi.o obj-$(EARLY_PRINTK) += debug.o obj-y += domctl.o obj-y += domain.o
xen/arch/arm/arm64/bpi.S new file +64 -0
64 lines not on this page · raw message
xen/arch/arm/cpuerrata.c +142 -0
148 lines not on this page · raw message
xen/arch/arm/traps.c +4 -1
@@ -160,7 +160,10 @@ __initcall(update_serrors_cpu_caps);void init_traps (void ) { -/* Setup Hyp vector base */ +/* +* Setup Hyp vector base. Note they might get updated with the +* branch predictor hardening. +*/ WRITE_SYSREG ((vaddr_t )hyp_traps_vector,VBAR_EL2 );/* Trap Debug and Performance Monitor accesses */
xen/include/asm-arm/cpuerrata.h +1 -0
@@ -1,6 +1,7 @@#ifndef __ARM_CPUERRATA_H__#define __ARM_CPUERRATA_H__ +#include <xen/percpu.h> #include <asm/cpufeature.h> #include <asm/alternative.h>
xen/include/asm-arm/cpufeature.h +2 -1
@@ -42,8 +42,9 @@#define LIVEPATCH_FEATURE 4#define SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT 5#define SKIP_CTXT_SWITCH_SERROR_SYNC 6 +#define ARM_HARDEN_BRANCH_PREDICTOR 7 -#define ARM_NCAPS 7 +#define ARM_NCAPS 8#ifndef __ASSEMBLY__
xen/include/asm-arm/processor.h +3 -2
@@ -385,8 +385,9 @@ struct cpuinfo_arm { unsigned long fp:4; /* Floating Point */ unsigned long simd:4; /* Advanced SIMD */ unsigned long gic:4; /* GIC support */ - unsigned long __res0:4; -unsigned long __res1; + unsigned long __res0:28; + unsigned long csv2:4; + unsigned long __res1:4; }; } pfr64;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 4/5] xen/arm64: Add skeleton to harden the branch predictor aliasing attacks
Quoted 28 lines · Julien Grall
Aliasing attacked against CPU branch predictors can allow an attacker to redirect speculative control flow on some CPUs and potentially divulge information from one context to another.
This patch adds initial skeleton code behind a new
Kconfigoption to enable implementation-specific mitigations against these attacks for CPUs that are affected.Most of the mitigations will have to be applied when entering to the hypervisor from the guest context. For safety, it is applied at every exception entry. So there are potential for optimizing when receiving an exception at the same level.
Because the attack is against branch predictor, it is not possible to safely use branch instruction before the mitigation is applied. Therefore, this has to be done in the vector entry before jump to the helper handling a given exception.
On Arm64, each vector can hold 32 instructions. This leave us 31 instructions for the mitigation. The last one is the branch instruction to the helper.
Because a platform may have CPUs with different micro-architectures, per-CPU vector table needs to be provided. Realistically, only a few different mitigations will be necessary. So provide a small set of vector tables. They will be re-used and patch with the mitigations on-demand.
Quoted 6 lines
This is based on the work done in Linux (see [1]).
This is part of XSA-254.
[1]
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
branch ktpi
If mentioning the original commit/branch is sufficient, then OK. Otherwise, if we need to explicitly mention all the copyright holders, then please add all the required signed-off-bys.
Quoted 298 lines
Signed-off-by Julien Grall <[email protected]>--- xen/arch/arm/Kconfig | 20 ++++++ xen/arch/arm/arm64/Makefile | 1 + xen/arch/arm/arm64/bpi.S | 64 ++++++++++++++++++ xen/arch/arm/cpuerrata.c | 142 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/traps.c | 5 +- xen/include/asm-arm/cpuerrata.h | 1 + xen/include/asm-arm/cpufeature.h | 3 +- xen/include/asm-arm/processor.h | 5 +- 8 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 xen/arch/arm/arm64/bpi.Sxen/arch/arm/Kconfig +20
-0@@ -171,6 +171,26 @@ config ARM64_ERRATUM_834220 endmenu +config HARDEN_BRANCH_PREDICTOR + bool "Harden the branch predictor against aliasing attacks" if EXPERT + default y + help + Speculation attacks against some high-performance processors rely on + being able to manipulate the branch predictor for a victim context by + executing aliasing branches in the attacker context. Such attacks + can be partially mitigated against by clearing internal branch + predictor state and limiting the prediction logic in some situations. + + This config option will take CPU-specific actions to harden the + branch predictor against aliasing attacks and may rely on specific + instruction sequences or control bits being set by the system + firmware. + + If unsure, say Y. + +config ARM64_HARDEN_BRANCH_PREDICTOR + def_bool y if ARM_64 && HARDEN_BRANCH_PREDICTOR + source "common/Kconfig" source "drivers/Kconfig"xen/arch/arm/arm64/Makefile +1
-0@@ -1,6 +1,7 @@ subdir-y += lib obj-y += cache.o +obj-$(CONFIG_HARDEN_BRANCH_PREDICTOR) += bpi.o obj-$(EARLY_PRINTK) += debug.o obj-y += domctl.o obj-y += domain.oxen/arch/arm/arm64/bpi.S new file +64
-0@@ -0,0 +1,64 @@ +/* + * Contains CPU specific branch predictor invalidation sequences + * + * Copyright (C) 2018 ARM Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +.macro ventry target + .rept 31 + nop + .endr + b \target +.endm + +.macro vectors target + ventry \target + 0x000 + ventry \target + 0x080 + ventry \target + 0x100 + ventry \target + 0x180 + + ventry \target + 0x200 + ventry \target + 0x280 + ventry \target + 0x300 + ventry \target + 0x380 + + ventry \target + 0x400 + ventry \target + 0x480 + ventry \target + 0x500 + ventry \target + 0x580 + + ventry \target + 0x600 + ventry \target + 0x680 + ventry \target + 0x700 + ventry \target + 0x780 +.endm + +/* + * Populate 4 vector tables. This will cover up to 4 different + * micro-architectures in a system. + */ + .align 11 +ENTRY(__bp_harden_hyp_vecs_start) + .rept 4 + vectors hyp_traps_vector + .endr +ENTRY(__bp_harden_hyp_vecs_end) + +/* + * Local variables: + * mode: ASM + * indent-tabs-mode: nil + * End: + */xen/arch/arm/cpuerrata.c +140
-0@@ -1,6 +1,148 @@ +#include <xen/cpumask.h> +#include <xen/mm.h> +#include <xen/sizes.h> +#include <xen/smp.h> +#include <xen/spinlock.h> +#include <xen/vmap.h> #include <asm/cpufeature.h> #include <asm/cpuerrata.h> +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn (va) _mfn(__virt_to_mfn(va)) + +/* Hardening Branch predictor code for Arm64 */ +#ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR + +#define VECTOR_TABLE_SIZE SZ_2K + +/* +* Number of available table vectors (this should be in-sync with +* arch/arm64/bpi.S +*/ +#define NR_BPI_HYP_VECS 4 + +extern char __bp_harden_hyp_vecs_start[], __bp_harden_hyp_vecs_end[]; + +/* +* Key for each slot. This is used to find whether a specific workaround +* had a slot assigned. +* +* The key is virtual address of the vector workaround +*/ +static uintptr_t bp_harden_slot_key[NR_BPI_HYP_VECS ]; + +/* +* [hyp_vec_start, hyp_vec_end[ corresponds to the first 31 instructions +* of each vector. The last (i.e 32th) instruction is used to branch to +* the original entry. +* +* Those instructions will be copied on each vector to harden them. +*/ +static bool copy_hyp_vect_bpi (unsigned int slot,const char *hyp_vec_start, +const char *hyp_vec_end) +{ +void *dst_remapped; +const void *dst = __bp_harden_hyp_vecs_start + slot *VECTOR_TABLE_SIZE ; +unsigned int i; +mfn_t dst_mfn =virt_to_mfn (dst); + +BUG_ON (((hyp_vec_end - hyp_vec_start) /4 ) >31 ); + +/* +* Vectors are part of the text that are mapped read-only. So re-map +* the vector table to be able to update vectors. +*/ + dst_remapped =__vmap (&dst_mfn, +1UL <<get_order_from_bytes (VECTOR_TABLE_SIZE ), +1 ,1 ,PAGE_HYPERVISOR ,VMAP_DEFAULT ); +if ( !dst_remapped ) +return false; + + dst_remapped += (vaddr_t )dst & ~PAGE_MASK ; + +for ( i =0 ; i <VECTOR_TABLE_SIZE ; i +=0x80 ) + { +memcpy (dst_remapped + i, hyp_vec_start, hyp_vec_end - hyp_vec_start); + } + +clean_dcache_va_range (dst_remapped,VECTOR_TABLE_SIZE ); +invalidate_icache (); + +vunmap (dst_remapped); + +return true; +} + +static bool __maybe_unused +install_bp_hardening_vec (const struct arm_cpu_capabilities *entry, +const char *hyp_vec_start, +const char *hyp_vec_end) +{ +static int last_slot =-1 ; +static DEFINE_SPINLOCK (bp_lock); +unsigned int i, slot =-1 ; +bool ret = true; + +/* +* Enable callbacks are called on every CPU based on the +* capabilities. So double-check whether the CPU matches the +* entry. +*/ +if ( !entry->matches (entry) ) +return true; +/* +* No need to install hardened vector when the processor has +* ID_AA64PRF0_EL1.CSV2 set. +*/ +if ( cpu_data[smp_processor_id ()].pfr64.csv2 ) +return true; + +spin_lock (&bp_lock); +/* +* Look up whether the hardening vector had a slot already +* assigned. +*/ +for ( i =0 ; i <4 ; i++ ) + { +if ( bp_harden_slot_key[i] == (uintptr_t )hyp_vec_start ) + { + slot = i; +break ; + } + } + +if ( slot ==-1 ) + { + last_slot++; +/* Check we don't overrun the number of slots available. */ +BUG_ON (NR_BPI_HYP_VECS <= last_slot); + + slot = last_slot; + ret =copy_hyp_vect_bpi (slot, hyp_vec_start, hyp_vec_end); + +/* Only update the slot if the copy succeeded. */ +if ( ret ) + bp_harden_slot_key[slot] = (uintptr_t )hyp_vec_start; + } + +if ( ret ) + { +/* Install the new vector table. */ +WRITE_SYSREG ((vaddr_t)(__bp_harden_hyp_vecs_start + slot *VECTOR_TABLE_SIZE ), +VBAR_EL2 ); +isb (); + } + +spin_unlock (&bp_lock); + +return ret; +} + +#endif /* CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR */ +#define MIDR_RANGE (model, min, max) \ .matches = is_affected_midr_range, \ .midr_model = model, \xen/arch/arm/traps.c +4
-1@@ -160,7 +160,10 @@ __initcall(update_serrors_cpu_caps);void init_traps (void ) { -/* Setup Hyp vector base */ +/* +* Setup Hyp vector base. Note they might get updated with the +* branch predictor hardening. +*/ WRITE_SYSREG ((vaddr_t )hyp_traps_vector,VBAR_EL2 );/* Trap Debug and Performance Monitor accesses */ xen/include/asm-arm/cpuerrata.h +0
-0
xen/include/asm-arm/cpuerrata.h line 4
Quoted 4 lines
xen/include/asm-arm/cpuerrata.h +1
-0@@ -1,6 +1,7 @@#ifndef __ARM_CPUERRATA_H__#define __ARM_CPUERRATA_H__ +#include <xen/percpu.h>
This doesn't seem to be necessary?
In any case:
Quoted 24 lines
xen/include/asm-arm/cpuerrata.h +0
-0#include <asm/cpufeature.h> #include <asm/alternative.h> xen/include/asm-arm/cpufeature.h +2
-1@@ -42,8 +42,9 @@#define LIVEPATCH_FEATURE 4#define SKIP_SYNCHRONIZE_SERROR_ENTRY_EXIT 5#define SKIP_CTXT_SWITCH_SERROR_SYNC 6 +#define ARM_HARDEN_BRANCH_PREDICTOR 7 -#define ARM_NCAPS 7 +#define ARM_NCAPS 8#ifndef __ASSEMBLY__xen/include/asm-arm/processor.h +0
-0@@ -385,8 +385,9 @@ struct cpuinfo_arm { unsigned long fp:4; /* Floating Point */
xen/include/asm-arm/processor.h struct cpuinfo_arm { · line 393
Quoted 10 lines
xen/include/asm-arm/processor.h +3
-2unsigned long simd:4; /* Advanced SIMD */ unsigned long gic:4; /* GIC support */ - unsigned long __res0:4; -unsigned long __res1; + unsigned long __res0:28; + unsigned long csv2:4; + unsigned long __res1:4; }; } pfr64;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 4/5] xen/arm64: Add skeleton to harden the branch predictor aliasing attacks
Hi Stefano,
Quoted 9 lines · Stefano Stabellini
Quoted 8 lines · Julien Grall
xen/include/asm-arm/cpuerrata.h +0
-0@@ -1,6 +1,7 @@#ifndef __ARM_CPUERRATA_H__#define __ARM_CPUERRATA_H__
Quoted 3 lines
xen/include/asm-arm/cpuerrata.h line 4
Quoted 1 line
xen/include/asm-arm/cpuerrata.h +1
-0+#include <xen/percpu.h> This doesn't seem to be necessary?
You are right. My original plan was based on Linux which use per-cpu variable. But I scratched that as it was possible to simplify the code.
I will send a patch to remove it.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 5/5 xen/arm64: Implement branch predictor hardening for affected Cortex-A CPUs
In reply to Julien GrallCortex-A57, A72, A73 and A75 are susceptible to branch predictor aliasing and can theoritically be attacked by malicious code.
This patch implements a PSCI-based mitigation for these CPUs when available. The call into firmware will invalidate the branch predictor state, preventing any malicious entries from affection other victim contexts.
Ported from Linux git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
branch kpti.
This is part of XSA-254.
--- xen/arch/arm/arm64/bpi.S | 25 ++++++++++++++++++++++++ xen/arch/arm/cpuerrata.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+)
xen/arch/arm/arm64/bpi.S +25 -0
@@ -56,6 +56,31 @@ ENTRY(__bp_harden_hyp_vecs_start) .endr ENTRY(__bp_harden_hyp_vecs_end) +ENTRY(__psci_hyp_bp_inval_start) + sub sp, sp, #(8 * 18) + stp x16, x17, [sp, #(16 * 0)] + stp x14, x15, [sp, #(16 * 1)] + stp x12, x13, [sp, #(16 * 2)] + stp x10, x11, [sp, #(16 * 3)] + stp x8, x9, [sp, #(16 * 4)] + stp x6, x7, [sp, #(16 * 5)] + stp x4, x5, [sp, #(16 * 6)] + stp x2, x3, [sp, #(16 * 7)] + stp x0, x1, [sp, #(16 * 8)] + mov x0, #0x84000000 + smc #0 + ldp x16, x17, [sp, #(16 * 0)] + ldp x14, x15, [sp, #(16 * 1)] + ldp x12, x13, [sp, #(16 * 2)] + ldp x10, x11, [sp, #(16 * 3)] + ldp x8, x9, [sp, #(16 * 4)] + ldp x6, x7, [sp, #(16 * 5)] + ldp x4, x5, [sp, #(16 * 6)] + ldp x2, x3, [sp, #(16 * 7)] + ldp x0, x1, [sp, #(16 * 8)] + add sp, sp, #(8 * 18) +ENTRY(__psci_hyp_bp_inval_end) + /* * Local variables: * mode: ASM
xen/arch/arm/cpuerrata.c +49 -0
69 lines not on this page · raw message
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/5] xen/arm64: Implement branch predictor hardening for affected Cortex-A CPUs
Quoted 120 lines · Julien Grall
Cortex-A57, A72, A73 and A75 are susceptible to branch predictor aliasing and can theoritically be attacked by malicious code.
This patch implements a PSCI-based mitigation for these CPUs when available. The call into firmware will invalidate the branch predictor state, preventing any malicious entries from affection other victim contexts.
Ported from Linux
git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
branch kpti.Signed-off-by Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>This is part of XSA-254.
Signed-off-by Julien Grall <[email protected]>--- xen/arch/arm/arm64/bpi.S | 25 ++++++++++++++++++++++++ xen/arch/arm/cpuerrata.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+)xen/arch/arm/arm64/bpi.S +25
-0@@ -56,6 +56,31 @@ ENTRY(__bp_harden_hyp_vecs_start) .endr ENTRY(__bp_harden_hyp_vecs_end) +ENTRY(__psci_hyp_bp_inval_start) + sub sp, sp, #(8 * 18) + stp x16, x17, [sp, #(16 * 0)] + stp x14, x15, [sp, #(16 * 1)] + stp x12, x13, [sp, #(16 * 2)] + stp x10, x11, [sp, #(16 * 3)] + stp x8, x9, [sp, #(16 * 4)] + stp x6, x7, [sp, #(16 * 5)] + stp x4, x5, [sp, #(16 * 6)] + stp x2, x3, [sp, #(16 * 7)] + stp x0, x1, [sp, #(16 * 8)] + mov x0, #0x84000000 + smc #0 + ldp x16, x17, [sp, #(16 * 0)] + ldp x14, x15, [sp, #(16 * 1)] + ldp x12, x13, [sp, #(16 * 2)] + ldp x10, x11, [sp, #(16 * 3)] + ldp x8, x9, [sp, #(16 * 4)] + ldp x6, x7, [sp, #(16 * 5)] + ldp x4, x5, [sp, #(16 * 6)] + ldp x2, x3, [sp, #(16 * 7)] + ldp x0, x1, [sp, #(16 * 8)] + add sp, sp, #(8 * 18) +ENTRY(__psci_hyp_bp_inval_end) + /* * Local variables: * mode: ASMxen/arch/arm/cpuerrata.c +38
-0@@ -4,8 +4,10 @@#include <xen/smp.h> #include <xen/spinlock.h> #include <xen/vmap.h> +#include <xen/warning.h> #include <asm/cpufeature.h> #include <asm/cpuerrata.h> +#include <asm/psci.h> /* Override macros from asm/page.h to make them work with mfn_t */ #undef virt_to_mfn@@ -141,6 +143,31 @@ install_bp_hardening_vec(const struct arm_cpu_capabilities *entry, return ret; } +extern char __psci_hyp_bp_inval_start[], __psci_hyp_bp_inval_end[]; + +static int enable_psci_bp_hardening (void *data) +{ +bool ret = true; +static bool warned = false; + +/* +* The mitigation is using PSCI version function to invalidate the +* branch predictor. This function is only available with PSCI 0.2 +* and later. +*/ +if ( psci_ver >=PSCI_VERSION (0 ,2 ) ) + ret =install_bp_hardening_vec (data, __psci_hyp_bp_inval_start, + __psci_hyp_bp_inval_end); +else if ( !warned ) + { +ASSERT (system_state < SYS_STATE_active); +warning_add ("PSCI 0.2 or later is required for the branch predictor hardening.\n" ); + warned = true; + } + +return !ret; +} +#endif /* CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR */ #define MIDR_RANGE (model, min, max) \@@ -205,6 +232,28 @@ static const struct arm_cpu_capabilities arm_errata[] = { (1 << MIDR_VARIANT_SHIFT) | 2), },#endif +#ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), + .enable = enable_psci_bp_hardening, + }, + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A72), + .enable = enable_psci_bp_hardening, + },
xen/arch/arm/cpuerrata.c static const struct arm_cpu_capabilities arm_errata[] = { · line 255
Quoted 10 lines
xen/arch/arm/cpuerrata.c +10
-0+ { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, +MIDR_ALL_VERSIONS (MIDR_CORTEX_A73 ), + .enable = enable_psci_bp_hardening, + }, + { + .capability =ARM_HARDEN_BRANCH_PREDICTOR , +MIDR_ALL_VERSIONS (MIDR_CORTEX_A75 ), + .enable = enable_psci_bp_hardening, + },
We need to add a basic description in the desc field as it is printed by update_cpu_capabilities.
Quoted 7 lines
xen/arch/arm/cpuerrata.c +1
-0+#endif {}, };Signature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/5] xen/arm64: Implement branch predictor hardening for affected Cortex-A CPUs
Hi Stefano,
Quoted 22 lines · Stefano Stabellini
Quoted 21 lines · Julien Grall
#define MIDR_RANGE(model, min, max) \xen/arch/arm/cpuerrata.c +16
-0@@ -205,6 +232,28 @@ static const struct arm_cpu_capabilities arm_errata[] = { (1 << MIDR_VARIANT_SHIFT) | 2), },#endif +#ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), + .enable = enable_psci_bp_hardening, + }, + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A72), + .enable = enable_psci_bp_hardening, + }, + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), + .enable = enable_psci_bp_hardening, + },
Quoted 8 lines
xen/arch/arm/cpuerrata.c static const struct arm_cpu_capabilities arm_errata[] = { · line 255
Quoted 5 lines
xen/arch/arm/cpuerrata.c +5
-0+ { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, +MIDR_ALL_VERSIONS (MIDR_CORTEX_A75 ), + .enable = enable_psci_bp_hardening, + },We need to add a basic description in the desc field as it is printed by
update_cpu_capabilities.
desc field is not mandatory, and in that case I think the print would be confusing. At the difference of the other errata, we have more check in install_bp_hardening_vec that may result to skip the hardening.
The errata here is covering all variant/revision of A75 models for safety reason. Arm has introduced a new field ID_AA64PFR0_EL1.CSV2 to tell whether a branch predictor trained in one context will affect speculative execution in another context. This field is checked in install_bp_hardening_vec so you avoid to harden the vector tables and small performance hit.
IHMO, it would be better to have a per-CPU message in install_bp_hardening_vec announcing whether the vector tables has been harden and the kind of hardening.
What do you think?
Cheers,
Quoted 9 lines
Quoted 9 lines
xen/arch/arm/cpuerrata.c +1
-0+#endif {}, };Signature · 1 line
2.11.0
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/5] xen/arm64: Implement branch predictor hardening for affected Cortex-A CPUs
Quoted 45 lines · Julien Grall
Hi Stefano,
Quoted 23 lines · Stefano Stabellini
Quoted 22 lines · Julien Grall
#define MIDR_RANGE(model, min, max) \xen/arch/arm/cpuerrata.c +16
-0@@ -205,6 +232,28 @@ static const struct arm_cpu_capabilities arm_errata[] = { (1 << MIDR_VARIANT_SHIFT) | 2), }, #endif +#ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), + .enable = enable_psci_bp_hardening, + }, + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A72), + .enable = enable_psci_bp_hardening, + }, + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), + .enable = enable_psci_bp_hardening, + },Quoted 8 lines
xen/arch/arm/cpuerrata.c static const struct arm_cpu_capabilities arm_errata[] = { · line 255
Quoted 5 lines
xen/arch/arm/cpuerrata.c +5
-0+ { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, +MIDR_ALL_VERSIONS (MIDR_CORTEX_A75 ), + .enable = enable_psci_bp_hardening, + },We need to add a basic description in the desc field as it is printed by
update_cpu_capabilities.desc field is not mandatory, and in that case I think the print would be confusing. At the difference of the other errata, we have more check in
install_bp_hardening_vecthat may result to skip the hardening.The errata here is covering all variant/revision of A75 models for safety reason. Arm has introduced a new field ID_AA64PFR0_EL1.CSV2 to tell whether a branch predictor trained in one context will affect speculative execution in another context. This field is checked in
install_bp_hardening_vecso you avoid to harden the vector tables and small performance hit.
Quoted 5 lines
IHMO, it would be better to have a per-CPU message in
install_bp_hardening_vecannouncing whether the vector tables has been harden and the kind of hardening.What do you think?
I understand what you are saying and I agree with you. Maybe we should change update_cpu_capabilities to print "detected need for workaround:
blah" but you don't have to do it in this series.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/5] xen/arm64: Implement branch predictor hardening for affected Cortex-A CPUs
Hi,
Quoted 50 lines · Stefano Stabellini
Quoted 49 lines · Julien Grall
Hi Stefano,
Quoted 23 lines · Stefano Stabellini
Quoted 22 lines · Julien Grall
#define MIDR_RANGE(model, min, max) \xen/arch/arm/cpuerrata.c +16
-0@@ -205,6 +232,28 @@ static const struct arm_cpu_capabilities arm_errata[] = { (1 << MIDR_VARIANT_SHIFT) | 2), }, #endif +#ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), + .enable = enable_psci_bp_hardening, + }, + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A72), + .enable = enable_psci_bp_hardening, + }, + { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, + MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), + .enable = enable_psci_bp_hardening, + },Quoted 8 lines
xen/arch/arm/cpuerrata.c static const struct arm_cpu_capabilities arm_errata[] = { · line 255
Quoted 5 lines
xen/arch/arm/cpuerrata.c +5
-0+ { + .capability = ARM_HARDEN_BRANCH_PREDICTOR, +MIDR_ALL_VERSIONS (MIDR_CORTEX_A75 ), + .enable = enable_psci_bp_hardening, + },We need to add a basic description in the desc field as it is printed by
update_cpu_capabilities.desc field is not mandatory, and in that case I think the print would be confusing. At the difference of the other errata, we have more check in
install_bp_hardening_vecthat may result to skip the hardening.The errata here is covering all variant/revision of A75 models for safety reason. Arm has introduced a new field ID_AA64PFR0_EL1.CSV2 to tell whether a branch predictor trained in one context will affect speculative execution in another context. This field is checked in
install_bp_hardening_vecso you avoid to harden the vector tables and small performance hit.IHMO, it would be better to have a per-CPU message in
install_bp_hardening_vecannouncing whether the vector tables has been harden and the kind of hardening.
Quoted 5 lines
Quoted 1 line
What do you think?
I understand what you are saying and I agree with you. Maybe we should change
update_cpu_capabilitiesto print "detected need for workaround:
blah" but you don't have to do it in this series.
"need for workaround..." is not entirely true for the branch predictor hardening. It is more a "may need". I still prefer the per-CPU message "CPU%u will %s on guest exit"
%u is the CPU number. %s will be the name of the call/instruction to execute.
The rationale behind is branch predictor hardening may be different on each CPU (think big.LITTLE) so code executed will be different. This differ from the other errata that will be applied for all CPUs.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel