# Linux Kernel Module Cheat
The perfect emulation setup to study and develop the <<linux-kernel>> v5.9.2, kernel modules, <<qemu-buildroot-setup,QEMU>>, <<gem5-buildroot-setup,gem5>> and x86_64, ARMv7 and ARMv8 <<userland-assembly,userland>> and <<baremetal-setup,baremetal>> assembly, <<c,ANSI C>>, <<cpp,C++>> and <<posix,POSIX>>. <<gdb>> and <<kgdb>> just work. Powered by <<about-the-qemu-buildroot-setup,Buildroot>> and <<about-the-baremetal-setup,crosstool-NG>>. Highly automated. Thoroughly documented. Automated <<test-this-repo,tests>>.

###### 24.21.2.2.1. gem5 `Request` in `AtomicSimpleCPU`

In `AtomicSimpleCPU`, a single packet of each type is kept for the entire CPU, e.g.:

    RequestPtr ifetch_req;

and it gets created at construction time:

    AtomicSimpleCPU::AtomicSimpleCPU(AtomicSimpleCPUParams *p)
    {
        ifetch_req = std::make_shared<Request>();

and then it gets modified for each request:

    setupFetchRequest(ifetch_req);

which does:

    req->setVirt(fetchPC, sizeof(MachInst), Request::INST_FETCH,
                    instMasterId(), instAddr);

Virtual to physical address translation done by the CPU stores the physical address:

    fault = thread->dtb->translateAtomic(req, thread->getTC(),
                                            BaseTLB::Read);

which eventually calls e.g. on fs with MMU enabled:

    Fault
    TLB::translateMmuOn(ThreadContext* tc, const RequestPtr &req, Mode mode,
                        Translation *translation, bool &delay, bool timing,
                        bool functional, Addr vaddr,
                        ArmFault::TranMethod tranMethod)
    {
        req->setPaddr(pa);