1 |
To check SSE3 availability compile this: |
2 |
|
3 |
############################## |
4 |
|
5 |
#include <stdint.h> |
6 |
|
7 |
uint8_t __attribute__((aligned(64))) current[64]; |
8 |
uint8_t previous[64]; |
9 |
|
10 |
int main() |
11 |
{ |
12 |
int i; |
13 |
uint64_t result; |
14 |
uint32_t _eax, _ebx, _ecx, _edx; |
15 |
uint8_t _cpuid[13]; |
16 |
uint32_t *_cpuid0 = (uint32_t*) _cpuid; |
17 |
uint32_t *_cpuid1 = (uint32_t*) ( _cpuid + 4 ); |
18 |
uint32_t *_cpuid2 = (uint32_t*) ( _cpuid + 8 ); |
19 |
uint8_t *ptr0 = current; |
20 |
uint8_t *ptr1 = previous; |
21 |
|
22 |
__asm__ __volatile__ ( |
23 |
"cpuid\n" |
24 |
: "=a" (_eax), |
25 |
"=b" (*_cpuid0), "=d" (*_cpuid1), "=c" (*_cpuid2) |
26 |
: "a" (0) ); |
27 |
_cpuid[12] = 0; |
28 |
printf( "cpuid(0) returns %d (%s)\n", _eax, _cpuid ); |
29 |
__asm__ __volatile__ ( |
30 |
"cpuid\n" |
31 |
: "=a" (_eax), "=b" (_ebx), "=c" (_ecx), "=d" (_edx) |
32 |
: "a" (1) ); |
33 |
printf( "cpuid(1) returns %08x %08x %08x %08x\n", |
34 |
_eax, _ebx, _ecx, _edx ); |
35 |
memset( current, 0xaa, 64 ); |
36 |
memset( previous, 0x55, 64 ); |
37 |
for( i = 0; i < 4; i ++ ) { |
38 |
__asm__ __volatile__ ( |
39 |
"movdqa %0, %%xmm0\n" |
40 |
"movdqu %1, %%xmm1\n" |
41 |
"psadbw %%xmm1, %%xmm0\n" |
42 |
"paddw %%xmm0, %%xmm2\n" |
43 |
"haddps %%xmm2, %%xmm2\n" |
44 |
"haddps %%xmm2, %%xmm2\n" |
45 |
: : "m" (*ptr0), |
46 |
"m" (*ptr1) : "xmm0", "xmm1", "xmm2" ); |
47 |
ptr0 += 16; |
48 |
ptr1 += 16; |
49 |
} |
50 |
__asm__ __volatile__ ( |
51 |
"movq %%xmm2, %0\n" |
52 |
: "=m" (result) ); |
53 |
printf( "Result is %llu\n", result ); |
54 |
} |
55 |
|
56 |
###################### |
57 |
|
58 |
Compile it: |
59 |
|
60 |
# gcc -Wall test_pni.c -o test_pni |
61 |
# ./test_pni |
62 |
|
63 |
If it runs ok you have SSE3, if it fails not. |
64 |
|
65 |
Cheers |
66 |
|
67 |
|
68 |
On 9/4/06, lunaslide <lunaslide@××.org> wrote: |
69 |
> |
70 |
> Ed W wrote: |
71 |
> > lunaslide wrote: |
72 |
> >> You should be able to just install a generic gentoo if necessary, then |
73 |
> >> change the profile over, change make.conf CFLAGS and 'emerge -e world' |
74 |
> >> (possibly twice to get all the software rebuilt with the hardened |
75 |
> >> toolchain) and have it running 64bit hardened. Putting |
76 |
> >> '-march=athlon64 -msse3' in your CFLAGS should get you what you want. |
77 |
> >> Do not use -O3, it's unstable and generally not worth it anyway. |
78 |
> > |
79 |
> > Is this really true? There are some notes in the 64 bit install doc |
80 |
> > saying that it's *not* this easy and that some stuff needs to be |
81 |
> > changed, especially to support a mixed 32/64 bit environment? Something |
82 |
> > about multi-lib? |
83 |
> > |
84 |
> > Ed W |
85 |
> |
86 |
> You're referring to running 32bit programs on a 64bit OS. That does |
87 |
> require the multilib stuff. But rebuilding the whole system from |
88 |
> scratch with emerge -e world will build everything 64 bit. And if I |
89 |
> recall correctly, when I was doing this with my box, it built two |
90 |
> versions of glibc and portage even warned me it was doing so. So it |
91 |
> might be building multilib just as a result of rebuilding the system |
92 |
> 64bit. |
93 |
> |
94 |
> I'm just delving into this lately though, so someone please correct me |
95 |
> if I misunderstood it. |
96 |
> |
97 |
> -- |
98 |
> lunaslide * * * * |
99 |
> * * * * * * * |
100 |
> We can't have lasting peace unless we work actively and vigorously |
101 |
> to bring about conditions of freedom and justice in the world. |
102 |
> * * - Harry Truman at West Point, 1952 * * |
103 |
> * * |
104 |
> * * * * * * |
105 |
> -- |
106 |
> gentoo-hardened@g.o mailing list |
107 |
> |
108 |
> |