mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 10:46:25 +00:00
lx_emul: fix spinlock implementation for ARM
Since Linux does not use the arch-independent spinlock structs for ARM, we must use different members when accessing the lock value. genodelabs/genode#4499
This commit is contained in:
parent
ba04aab75f
commit
4cdba04c88
20
repos/dde_linux/src/include/spec/arm/lx_emul/arch_spinlock.h
Normal file
20
repos/dde_linux/src/include/spec/arm/lx_emul/arch_spinlock.h
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* \brief Architecture-specific accessors to spinlock types for lx_emul
|
||||
* \author Johannes Schlatow
|
||||
* \date 2022-04-04
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#ifndef _LX_EMUL__ARCH_SPINLOCK_H_
|
||||
#define _LX_EMUL__ARCH_SPINLOCK_H_
|
||||
|
||||
#define SPINLOCK_VALUE_PTR(lock) (atomic_t*)&lock->raw_lock.slock
|
||||
#define RWLOCK_VALUE(lock) lock->raw_lock.lock
|
||||
|
||||
#endif /*_LX_EMUL__ARCH_SPINLOCK_H_ */
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* \brief Architecture-specific accessors to spinlock types for lx_emul
|
||||
* \author Johannes Schlatow
|
||||
* \date 2022-04-04
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#ifndef _LX_EMUL__ARCH_SPINLOCK_H_
|
||||
#define _LX_EMUL__ARCH_SPINLOCK_H_
|
||||
|
||||
#define SPINLOCK_VALUE_PTR(lock) &lock->raw_lock.val
|
||||
#define RWLOCK_VALUE(lock) lock->raw_lock.wlocked
|
||||
|
||||
#endif /*_LX_EMUL__ARCH_SPINLOCK_H_ */
|
20
repos/dde_linux/src/include/spec/x86/lx_emul/arch_spinlock.h
Normal file
20
repos/dde_linux/src/include/spec/x86/lx_emul/arch_spinlock.h
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* \brief Architecture-specific accessors to spinlock types for lx_emul
|
||||
* \author Johannes Schlatow
|
||||
* \date 2022-04-04
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Genode Labs GmbH
|
||||
*
|
||||
* This file is distributed under the terms of the GNU General Public License
|
||||
* version 2.
|
||||
*/
|
||||
|
||||
#ifndef _LX_EMUL__ARCH_SPINLOCK_H_
|
||||
#define _LX_EMUL__ARCH_SPINLOCK_H_
|
||||
|
||||
#define SPINLOCK_VALUE_PTR(lock) &lock->raw_lock.val
|
||||
#define RWLOCK_VALUE(lock) lock->raw_lock.wlocked
|
||||
|
||||
#endif /*_LX_EMUL__ARCH_SPINLOCK_H_ */
|
@ -19,13 +19,15 @@
|
||||
#include <lx_emul/debug.h>
|
||||
#include <lx_emul/task.h>
|
||||
|
||||
#include <lx_emul/arch_spinlock.h>
|
||||
|
||||
void __lockfunc _raw_spin_lock(raw_spinlock_t * lock)
|
||||
{
|
||||
if (atomic_read(&lock->raw_lock.val)) {
|
||||
if (atomic_read(SPINLOCK_VALUE_PTR(lock))) {
|
||||
printk("Error: spinlock contention!");
|
||||
lx_emul_trace_and_stop(__func__);
|
||||
}
|
||||
atomic_set(&lock->raw_lock.val, 1);
|
||||
atomic_set(SPINLOCK_VALUE_PTR(lock), 1);
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +42,7 @@ unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t * lock)
|
||||
|
||||
void __lockfunc _raw_spin_unlock(raw_spinlock_t * lock)
|
||||
{
|
||||
atomic_set(&lock->raw_lock.val, 0);
|
||||
atomic_set(SPINLOCK_VALUE_PTR(lock), 0);
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +69,7 @@ void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t * lock)
|
||||
int __lockfunc _raw_spin_trylock(raw_spinlock_t * lock)
|
||||
{
|
||||
|
||||
if (atomic_read(&lock->raw_lock.val))
|
||||
if (atomic_read(SPINLOCK_VALUE_PTR(lock)))
|
||||
return 0;
|
||||
|
||||
_raw_spin_lock(lock);
|
||||
@ -77,15 +79,15 @@ int __lockfunc _raw_spin_trylock(raw_spinlock_t * lock)
|
||||
|
||||
void __lockfunc _raw_write_lock(rwlock_t * lock)
|
||||
{
|
||||
if (lock->raw_lock.wlocked) {
|
||||
if (RWLOCK_VALUE(lock)) {
|
||||
printk("Error: rwlock contention!");
|
||||
lx_emul_trace_and_stop(__func__);
|
||||
}
|
||||
lock->raw_lock.wlocked = 1;
|
||||
RWLOCK_VALUE(lock) = 1;
|
||||
}
|
||||
|
||||
|
||||
void __lockfunc _raw_write_unlock(rwlock_t * lock)
|
||||
{
|
||||
lock->raw_lock.wlocked = 0;
|
||||
RWLOCK_VALUE(lock) = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user