On Sat, Jun 12, 2021 at 11:31:28PM -0600, Theo de Raadt wrote:
> Why not wrap all the ppc_altivec = 1 lines in #ifdef ALTIVEC
> 
> Or at the end of cpuattach, #ifndef ALTIVEC, zero the variable.
> 
> Obviously the sysctl should indicate 0, if the code support is missing.
> The sysctl isn't exposing if the cpu has the feature; it is exposing
> of the cpu+kernel have all the required support..

I'm suggesting the patch below to force machdep.altivec=0 if kernel
support is not there.

With this patch on a kernel without 'option ALTIVEC', the pixman
tests pass (while they get SIGILL without the patch)

PS: To run the pixman tests, build pixman with make -f
Makefile.bsd-wrapper and then: cd obj/tests ; make check
(the tests are sorted by run time and running all of them can take
hours; I've interrupted them after cover-test)

Index: cpu.c
===================================================================
RCS file: /cvs/OpenBSD/src/sys/arch/macppc/macppc/cpu.c,v
retrieving revision 1.83
diff -u -p -u -r1.83 cpu.c
--- cpu.c       29 May 2020 04:42:24 -0000      1.83
+++ cpu.c       13 Jun 2021 06:23:38 -0000
@@ -275,6 +275,9 @@ cpuattach(struct device *parent, struct 
                snprintf(cpu_model, sizeof(cpu_model), "Version %x", cpu);
                break;
        }
+#ifndef ALTIVEC                        /* altivec support absent from kernel */
+       ppc_altivec = 0;
+#endif
        snprintf(cpu_model + strlen(cpu_model),
            sizeof(cpu_model) - strlen(cpu_model),
            " (Revision 0x%x)", pvr & 0xffff);

-- 
Matthieu Herrb

Reply via email to