Are there anything wrong with below inline assembly code? I encountered "Illegal instruction (core dumped)" when running the function spinlock_lock.
void spinlock_lock(struct spinlock * lock) {
int a;
__asm__ __volatile__("movl %0, %%eax;"
"test %%eax, %%eax;"
"jnz spinlock_lock;"
:"=r"(a)
:"r"(lock->cmos_lock)
:"eax");
__asm__ __volatile__ ("lock; cmpxchg %%edx, %0\n"
:"=r"(a)
:"r"(lock->cmos_lock)
:"edx", "memory");