]>
Commit | Line | Data |
---|---|---|
b9ec40af CL |
1 | /* |
2 | * This program is free software; you can redistribute it and/or | |
3 | * modify it under the terms of the GNU General Public License | |
4 | * as published by the Free Software Foundation; version 2 | |
5 | * of the License. | |
6 | * | |
7 | */ | |
8 | #include <linux/linkage.h> | |
3f635721 | 9 | #include <asm/percpu.h> |
d7c3f8ce | 10 | |
b9ec40af CL |
11 | .text |
12 | ||
13 | /* | |
14 | * Inputs: | |
15 | * %rsi : memory location to compare | |
16 | * %rax : low 64 bits of old value | |
17 | * %rdx : high 64 bits of old value | |
18 | * %rbx : low 64 bits of new value | |
19 | * %rcx : high 64 bits of new value | |
20 | * %al : Operation successful | |
21 | */ | |
22 | ENTRY(this_cpu_cmpxchg16b_emu) | |
b9ec40af CL |
23 | |
24 | # | |
25 | # Emulate 'cmpxchg16b %gs:(%rsi)' except we return the result in %al not | |
26 | # via the ZF. Caller will access %al to get result. | |
27 | # | |
28 | # Note that this is only useful for a cpuops operation. Meaning that we | |
29 | # do *not* have a fully atomic operation but just an operation that is | |
30 | # *atomic* on a single cpu (as provided by the this_cpu_xx class of | |
31 | # macros). | |
32 | # | |
131484c8 | 33 | pushfq |
b9ec40af CL |
34 | cli |
35 | ||
3f635721 JB |
36 | cmpq PER_CPU_VAR((%rsi)), %rax |
37 | jne .Lnot_same | |
38 | cmpq PER_CPU_VAR(8(%rsi)), %rdx | |
39 | jne .Lnot_same | |
b9ec40af | 40 | |
3f635721 JB |
41 | movq %rbx, PER_CPU_VAR((%rsi)) |
42 | movq %rcx, PER_CPU_VAR(8(%rsi)) | |
b9ec40af | 43 | |
131484c8 | 44 | popfq |
b9ec40af CL |
45 | mov $1, %al |
46 | ret | |
47 | ||
3f635721 | 48 | .Lnot_same: |
131484c8 | 49 | popfq |
b9ec40af CL |
50 | xor %al,%al |
51 | ret | |
52 | ||
b9ec40af | 53 | ENDPROC(this_cpu_cmpxchg16b_emu) |