mirror of
https://github.com/adulau/aha.git
synced 2025-01-03 22:53:18 +00:00
Blackfin: kgdb: fix up error return values
The Blackfin kgdb code was all passing back positive errno values when it really should have been using negative errno values. Reported-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
a43b739f25
commit
11aca0e735
1 changed files with 30 additions and 25 deletions
|
@ -466,7 +466,7 @@ static int validate_memory_access_address(unsigned long addr, int size)
|
||||||
int cpu = raw_smp_processor_id();
|
int cpu = raw_smp_processor_id();
|
||||||
|
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return EFAULT;
|
return -EFAULT;
|
||||||
if (addr >= 0x1000 && (addr + size) <= physical_mem_end)
|
if (addr >= 0x1000 && (addr + size) <= physical_mem_end)
|
||||||
return 0;
|
return 0;
|
||||||
if (addr >= SYSMMR_BASE)
|
if (addr >= SYSMMR_BASE)
|
||||||
|
@ -498,7 +498,7 @@ static int validate_memory_access_address(unsigned long addr, int size)
|
||||||
if (IN_MEM(addr, size, L2_START, L2_LENGTH))
|
if (IN_MEM(addr, size, L2_START, L2_LENGTH))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -508,14 +508,15 @@ static int validate_memory_access_address(unsigned long addr, int size)
|
||||||
int kgdb_mem2hex(char *mem, char *buf, int count)
|
int kgdb_mem2hex(char *mem, char *buf, int count)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int err = 0;
|
int err;
|
||||||
unsigned char *pch;
|
unsigned char *pch;
|
||||||
unsigned short mmr16;
|
unsigned short mmr16;
|
||||||
unsigned long mmr32;
|
unsigned long mmr32;
|
||||||
int cpu = raw_smp_processor_id();
|
int cpu = raw_smp_processor_id();
|
||||||
|
|
||||||
if (validate_memory_access_address((unsigned long)mem, count))
|
err = validate_memory_access_address((unsigned long)mem, count);
|
||||||
return EFAULT;
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use the upper half of buf as an intermediate buffer for the
|
* We use the upper half of buf as an intermediate buffer for the
|
||||||
|
@ -533,7 +534,7 @@ int kgdb_mem2hex(char *mem, char *buf, int count)
|
||||||
*tmp++ = *pch++;
|
*tmp++ = *pch++;
|
||||||
tmp -= 2;
|
tmp -= 2;
|
||||||
} else
|
} else
|
||||||
err = EFAULT;
|
err = -EFAULT;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if ((unsigned int)mem % 4 == 0) {
|
if ((unsigned int)mem % 4 == 0) {
|
||||||
|
@ -545,10 +546,10 @@ int kgdb_mem2hex(char *mem, char *buf, int count)
|
||||||
*tmp++ = *pch++;
|
*tmp++ = *pch++;
|
||||||
tmp -= 4;
|
tmp -= 4;
|
||||||
} else
|
} else
|
||||||
err = EFAULT;
|
err = -EFAULT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err = EFAULT;
|
err = -EFAULT;
|
||||||
}
|
}
|
||||||
} else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH))
|
} else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH))
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
@ -557,7 +558,7 @@ int kgdb_mem2hex(char *mem, char *buf, int count)
|
||||||
) {
|
) {
|
||||||
/* access L1 instruction SRAM*/
|
/* access L1 instruction SRAM*/
|
||||||
if (dma_memcpy(tmp, mem, count) == NULL)
|
if (dma_memcpy(tmp, mem, count) == NULL)
|
||||||
err = EFAULT;
|
err = -EFAULT;
|
||||||
} else
|
} else
|
||||||
err = probe_kernel_read(tmp, mem, count);
|
err = probe_kernel_read(tmp, mem, count);
|
||||||
|
|
||||||
|
@ -585,7 +586,7 @@ int kgdb_ebin2mem(char *buf, char *mem, int count)
|
||||||
char *tmp_new;
|
char *tmp_new;
|
||||||
unsigned short *mmr16;
|
unsigned short *mmr16;
|
||||||
unsigned long *mmr32;
|
unsigned long *mmr32;
|
||||||
int err = 0;
|
int err;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
int cpu = raw_smp_processor_id();
|
int cpu = raw_smp_processor_id();
|
||||||
|
|
||||||
|
@ -601,8 +602,9 @@ int kgdb_ebin2mem(char *buf, char *mem, int count)
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (validate_memory_access_address((unsigned long)mem, size))
|
err = validate_memory_access_address((unsigned long)mem, size);
|
||||||
return EFAULT;
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
if ((unsigned int)mem >= SYSMMR_BASE) { /*access MMR registers*/
|
if ((unsigned int)mem >= SYSMMR_BASE) { /*access MMR registers*/
|
||||||
switch (size) {
|
switch (size) {
|
||||||
|
@ -611,17 +613,17 @@ int kgdb_ebin2mem(char *buf, char *mem, int count)
|
||||||
mmr16 = (unsigned short *)buf;
|
mmr16 = (unsigned short *)buf;
|
||||||
*(unsigned short *)mem = *mmr16;
|
*(unsigned short *)mem = *mmr16;
|
||||||
} else
|
} else
|
||||||
return EFAULT;
|
err = -EFAULT;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if ((unsigned int)mem % 4 == 0) {
|
if ((unsigned int)mem % 4 == 0) {
|
||||||
mmr32 = (unsigned long *)buf;
|
mmr32 = (unsigned long *)buf;
|
||||||
*(unsigned long *)mem = *mmr32;
|
*(unsigned long *)mem = *mmr32;
|
||||||
} else
|
} else
|
||||||
return EFAULT;
|
err = -EFAULT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return EFAULT;
|
err = -EFAULT;
|
||||||
}
|
}
|
||||||
} else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH))
|
} else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH))
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
@ -630,7 +632,7 @@ int kgdb_ebin2mem(char *buf, char *mem, int count)
|
||||||
) {
|
) {
|
||||||
/* access L1 instruction SRAM */
|
/* access L1 instruction SRAM */
|
||||||
if (dma_memcpy(mem, buf, size) == NULL)
|
if (dma_memcpy(mem, buf, size) == NULL)
|
||||||
err = EFAULT;
|
err = -EFAULT;
|
||||||
} else
|
} else
|
||||||
err = probe_kernel_write(mem, buf, size);
|
err = probe_kernel_write(mem, buf, size);
|
||||||
|
|
||||||
|
@ -648,10 +650,12 @@ int kgdb_hex2mem(char *buf, char *mem, int count)
|
||||||
char *tmp_hex;
|
char *tmp_hex;
|
||||||
unsigned short *mmr16;
|
unsigned short *mmr16;
|
||||||
unsigned long *mmr32;
|
unsigned long *mmr32;
|
||||||
|
int err;
|
||||||
int cpu = raw_smp_processor_id();
|
int cpu = raw_smp_processor_id();
|
||||||
|
|
||||||
if (validate_memory_access_address((unsigned long)mem, count))
|
err = validate_memory_access_address((unsigned long)mem, count);
|
||||||
return EFAULT;
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use the upper half of buf as an intermediate buffer for the
|
* We use the upper half of buf as an intermediate buffer for the
|
||||||
|
@ -673,17 +677,17 @@ int kgdb_hex2mem(char *buf, char *mem, int count)
|
||||||
mmr16 = (unsigned short *)tmp_raw;
|
mmr16 = (unsigned short *)tmp_raw;
|
||||||
*(unsigned short *)mem = *mmr16;
|
*(unsigned short *)mem = *mmr16;
|
||||||
} else
|
} else
|
||||||
return EFAULT;
|
err = -EFAULT;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if ((unsigned int)mem % 4 == 0) {
|
if ((unsigned int)mem % 4 == 0) {
|
||||||
mmr32 = (unsigned long *)tmp_raw;
|
mmr32 = (unsigned long *)tmp_raw;
|
||||||
*(unsigned long *)mem = *mmr32;
|
*(unsigned long *)mem = *mmr32;
|
||||||
} else
|
} else
|
||||||
return EFAULT;
|
err = -EFAULT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return EFAULT;
|
err = -EFAULT;
|
||||||
}
|
}
|
||||||
} else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH))
|
} else if ((cpu == 0 && IN_MEM(mem, count, L1_CODE_START, L1_CODE_LENGTH))
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
@ -692,10 +696,11 @@ int kgdb_hex2mem(char *buf, char *mem, int count)
|
||||||
) {
|
) {
|
||||||
/* access L1 instruction SRAM */
|
/* access L1 instruction SRAM */
|
||||||
if (dma_memcpy(mem, tmp_raw, count) == NULL)
|
if (dma_memcpy(mem, tmp_raw, count) == NULL)
|
||||||
return EFAULT;
|
err = -EFAULT;
|
||||||
} else
|
} else
|
||||||
return probe_kernel_write(mem, tmp_raw, count);
|
err = probe_kernel_write(mem, tmp_raw, count);
|
||||||
return 0;
|
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kgdb_validate_break_address(unsigned long addr)
|
int kgdb_validate_break_address(unsigned long addr)
|
||||||
|
@ -715,7 +720,7 @@ int kgdb_validate_break_address(unsigned long addr)
|
||||||
if (IN_MEM(addr, BREAK_INSTR_SIZE, L2_START, L2_LENGTH))
|
if (IN_MEM(addr, BREAK_INSTR_SIZE, L2_START, L2_LENGTH))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
|
int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
|
||||||
|
|
Loading…
Reference in a new issue