From 2b37373c48282bd21c1d9cfabf850b3672e7f2cb Mon Sep 17 00:00:00 2001 From: Alfredo Dal'Ava Junior Date: Thu, 5 Mar 2020 14:13:22 +0000 Subject: [PATCH] [PowerPC64] restrict memcpy/bcopy optimization to POWER ISA >=V2.07 VSX instructions were added in POWER ISA V2.06 (POWER7), but it requires data to be word-aligned. Such requirement was removed in ISA V2.07B (POWER8). Since current memcpy/bcopy optimization relies on VSX instructions handling misalignment transparently, and kernel doesn't currently implement an alignment error handler, this optimzation should be restrict to ISA V2.07 onwards. SIGBUS on stxvd2x instruction was reproduced in POWER7+ CPU. Reviewed by: luporl, jhibbits, bdragon Approved by: jhibbits (mentor) Differential Revision: https://reviews.freebsd.org/D23958 --- lib/libc/powerpc64/string/bcopy_resolver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/libc/powerpc64/string/bcopy_resolver.c b/lib/libc/powerpc64/string/bcopy_resolver.c index aaaf81a1c2a7..34b88d6ccbe4 100644 --- a/lib/libc/powerpc64/string/bcopy_resolver.c +++ b/lib/libc/powerpc64/string/bcopy_resolver.c @@ -61,7 +61,12 @@ FN_RET FN_NAME_VSX FN_PARAMS; DEFINE_UIFUNC(, FN_RET, FN_NAME, FN_PARAMS) { - if (cpu_features & PPC_FEATURE_HAS_VSX) + /* VSX instructions were added in POWER ISA 2.06, + * however it requires data to be word-aligned. + * Since POWER ISA 2.07B this is solved transparently + * by the hardware + */ + if (cpu_features2 & PPC_FEATURE2_ARCH_2_07) return (FN_NAME_VSX); else return (FN_NAME_NOVSX);