forked from microsoft/WSL2-Linux-Kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'x86-rwsem-for-linus' of git://git.kernel.org/pub/scm/li…
…nux/kernel/git/tip/linux-2.6-tip * 'x86-rwsem-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86-64, rwsem: Avoid store forwarding hazard in __downgrade_write x86-64, rwsem: 64-bit xadd rwsem implementation x86: Fix breakage of UML from the changes in the rwsem system x86-64: support native xadd rwsem implementation x86: clean up rwsem type system
- Loading branch information
Showing
5 changed files
with
123 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* x86-64 rwsem wrappers | ||
* | ||
* This interfaces the inline asm code to the slow-path | ||
* C routines. We need to save the call-clobbered regs | ||
* that the asm does not mark as clobbered, and move the | ||
* argument from %rax to %rdi. | ||
* | ||
* NOTE! We don't need to save %rax, because the functions | ||
* will always return the semaphore pointer in %rax (which | ||
* is also the input argument to these helpers) | ||
* | ||
* The following can clobber %rdx because the asm clobbers it: | ||
* call_rwsem_down_write_failed | ||
* call_rwsem_wake | ||
* but %rdi, %rsi, %rcx, %r8-r11 always need saving. | ||
*/ | ||
|
||
#include <linux/linkage.h> | ||
#include <asm/rwlock.h> | ||
#include <asm/alternative-asm.h> | ||
#include <asm/frame.h> | ||
#include <asm/dwarf2.h> | ||
|
||
#define save_common_regs \ | ||
pushq %rdi; \ | ||
pushq %rsi; \ | ||
pushq %rcx; \ | ||
pushq %r8; \ | ||
pushq %r9; \ | ||
pushq %r10; \ | ||
pushq %r11 | ||
|
||
#define restore_common_regs \ | ||
popq %r11; \ | ||
popq %r10; \ | ||
popq %r9; \ | ||
popq %r8; \ | ||
popq %rcx; \ | ||
popq %rsi; \ | ||
popq %rdi | ||
|
||
/* Fix up special calling conventions */ | ||
ENTRY(call_rwsem_down_read_failed) | ||
save_common_regs | ||
pushq %rdx | ||
movq %rax,%rdi | ||
call rwsem_down_read_failed | ||
popq %rdx | ||
restore_common_regs | ||
ret | ||
ENDPROC(call_rwsem_down_read_failed) | ||
|
||
ENTRY(call_rwsem_down_write_failed) | ||
save_common_regs | ||
movq %rax,%rdi | ||
call rwsem_down_write_failed | ||
restore_common_regs | ||
ret | ||
ENDPROC(call_rwsem_down_write_failed) | ||
|
||
ENTRY(call_rwsem_wake) | ||
decw %dx /* do nothing if still outstanding active readers */ | ||
jnz 1f | ||
save_common_regs | ||
movq %rax,%rdi | ||
call rwsem_wake | ||
restore_common_regs | ||
1: ret | ||
ENDPROC(call_rwsem_wake) | ||
|
||
/* Fix up special calling conventions */ | ||
ENTRY(call_rwsem_downgrade_wake) | ||
save_common_regs | ||
pushq %rdx | ||
movq %rax,%rdi | ||
call rwsem_downgrade_wake | ||
popq %rdx | ||
restore_common_regs | ||
ret | ||
ENDPROC(call_rwsem_downgrade_wake) |