mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-26 11:28:28 +00:00
5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
201 lines
4.7 KiB
C
201 lines
4.7 KiB
C
/*
|
|
* Software emulation of some PPC instructions for the 8xx core.
|
|
*
|
|
* Copyright (C) 1998 Dan Malek (dmalek@jlc.net)
|
|
*
|
|
* Software floating emuation for the MPC8xx processor. I did this mostly
|
|
* because it was easier than trying to get the libraries compiled for
|
|
* software floating point. The goal is still to get the libraries done,
|
|
* but I lost patience and needed some hacks to at least get init and
|
|
* shells running. The first problem is the setjmp/longjmp that save
|
|
* and restore the floating point registers.
|
|
*
|
|
* For this emulation, our working registers are found on the register
|
|
* save area.
|
|
*/
|
|
|
|
#include <linux/errno.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/stddef.h>
|
|
#include <linux/unistd.h>
|
|
#include <linux/ptrace.h>
|
|
#include <linux/user.h>
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
#include <asm/uaccess.h>
|
|
#include <asm/system.h>
|
|
#include <asm/io.h>
|
|
|
|
/* Eventually we may need a look-up table, but this works for now.
|
|
*/
|
|
#define LFS 48
|
|
#define LFD 50
|
|
#define LFDU 51
|
|
#define STFD 54
|
|
#define STFDU 55
|
|
#define FMR 63
|
|
|
|
void print_8xx_pte(struct mm_struct *mm, unsigned long addr)
|
|
{
|
|
pgd_t *pgd;
|
|
pmd_t *pmd;
|
|
pte_t *pte;
|
|
|
|
printk(" pte @ 0x%8lx: ", addr);
|
|
pgd = pgd_offset(mm, addr & PAGE_MASK);
|
|
if (pgd) {
|
|
pmd = pmd_offset(pud_offset(pgd, addr & PAGE_MASK),
|
|
addr & PAGE_MASK);
|
|
if (pmd && pmd_present(*pmd)) {
|
|
pte = pte_offset_kernel(pmd, addr & PAGE_MASK);
|
|
if (pte) {
|
|
printk(" (0x%08lx)->(0x%08lx)->0x%08lx\n",
|
|
(long)pgd, (long)pte, (long)pte_val(*pte));
|
|
#define pp ((long)pte_val(*pte))
|
|
printk(" RPN: %05lx PP: %lx SPS: %lx SH: %lx "
|
|
"CI: %lx v: %lx\n",
|
|
pp>>12, /* rpn */
|
|
(pp>>10)&3, /* pp */
|
|
(pp>>3)&1, /* small */
|
|
(pp>>2)&1, /* shared */
|
|
(pp>>1)&1, /* cache inhibit */
|
|
pp&1 /* valid */
|
|
);
|
|
#undef pp
|
|
}
|
|
else {
|
|
printk("no pte\n");
|
|
}
|
|
}
|
|
else {
|
|
printk("no pmd\n");
|
|
}
|
|
}
|
|
else {
|
|
printk("no pgd\n");
|
|
}
|
|
}
|
|
|
|
int get_8xx_pte(struct mm_struct *mm, unsigned long addr)
|
|
{
|
|
pgd_t *pgd;
|
|
pmd_t *pmd;
|
|
pte_t *pte;
|
|
int retval = 0;
|
|
|
|
pgd = pgd_offset(mm, addr & PAGE_MASK);
|
|
if (pgd) {
|
|
pmd = pmd_offset(pud_offset(pgd, addr & PAGE_MASK),
|
|
addr & PAGE_MASK);
|
|
if (pmd && pmd_present(*pmd)) {
|
|
pte = pte_offset_kernel(pmd, addr & PAGE_MASK);
|
|
if (pte) {
|
|
retval = (int)pte_val(*pte);
|
|
}
|
|
}
|
|
}
|
|
return retval;
|
|
}
|
|
|
|
/*
|
|
* We return 0 on success, 1 on unimplemented instruction, and EFAULT
|
|
* if a load/store faulted.
|
|
*/
|
|
int Soft_emulate_8xx(struct pt_regs *regs)
|
|
{
|
|
u32 inst, instword;
|
|
u32 flreg, idxreg, disp;
|
|
int retval;
|
|
s16 sdisp;
|
|
u32 *ea, *ip;
|
|
|
|
retval = 0;
|
|
|
|
instword = *((u32 *)regs->nip);
|
|
inst = instword >> 26;
|
|
|
|
flreg = (instword >> 21) & 0x1f;
|
|
idxreg = (instword >> 16) & 0x1f;
|
|
disp = instword & 0xffff;
|
|
|
|
ea = (u32 *)(regs->gpr[idxreg] + disp);
|
|
ip = (u32 *)¤t->thread.TS_FPR(flreg);
|
|
|
|
switch ( inst )
|
|
{
|
|
case LFD:
|
|
/* this is a 16 bit quantity that is sign extended
|
|
* so use a signed short here -- Cort
|
|
*/
|
|
sdisp = (instword & 0xffff);
|
|
ea = (u32 *)(regs->gpr[idxreg] + sdisp);
|
|
if (copy_from_user(ip, ea, sizeof(double)))
|
|
retval = -EFAULT;
|
|
break;
|
|
|
|
case LFDU:
|
|
if (copy_from_user(ip, ea, sizeof(double)))
|
|
retval = -EFAULT;
|
|
else
|
|
regs->gpr[idxreg] = (u32)ea;
|
|
break;
|
|
case LFS:
|
|
sdisp = (instword & 0xffff);
|
|
ea = (u32 *)(regs->gpr[idxreg] + sdisp);
|
|
if (copy_from_user(ip, ea, sizeof(float)))
|
|
retval = -EFAULT;
|
|
break;
|
|
case STFD:
|
|
/* this is a 16 bit quantity that is sign extended
|
|
* so use a signed short here -- Cort
|
|
*/
|
|
sdisp = (instword & 0xffff);
|
|
ea = (u32 *)(regs->gpr[idxreg] + sdisp);
|
|
if (copy_to_user(ea, ip, sizeof(double)))
|
|
retval = -EFAULT;
|
|
break;
|
|
|
|
case STFDU:
|
|
if (copy_to_user(ea, ip, sizeof(double)))
|
|
retval = -EFAULT;
|
|
else
|
|
regs->gpr[idxreg] = (u32)ea;
|
|
break;
|
|
case FMR:
|
|
/* assume this is a fp move -- Cort */
|
|
memcpy(ip, ¤t->thread.TS_FPR((instword>>11)&0x1f),
|
|
sizeof(double));
|
|
break;
|
|
default:
|
|
retval = 1;
|
|
printk("Bad emulation %s/%d\n"
|
|
" NIP: %08lx instruction: %08x opcode: %x "
|
|
"A: %x B: %x C: %x code: %x rc: %x\n",
|
|
current->comm,current->pid,
|
|
regs->nip,
|
|
instword,inst,
|
|
(instword>>16)&0x1f,
|
|
(instword>>11)&0x1f,
|
|
(instword>>6)&0x1f,
|
|
(instword>>1)&0x3ff,
|
|
instword&1);
|
|
{
|
|
int pa;
|
|
print_8xx_pte(current->mm,regs->nip);
|
|
pa = get_8xx_pte(current->mm,regs->nip) & PAGE_MASK;
|
|
pa |= (regs->nip & ~PAGE_MASK);
|
|
pa = (unsigned long)__va(pa);
|
|
printk("Kernel VA for NIP %x ", pa);
|
|
print_8xx_pte(current->mm,pa);
|
|
}
|
|
}
|
|
|
|
if (retval == 0)
|
|
regs->nip += 4;
|
|
|
|
return retval;
|
|
}
|