Deleted Added
sdiff udiff text old ( 12406:86bde4a026b5 ) new ( 12455:c88f0b37f433 )
full compact
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 615 unchanged lines hidden (view full) ---

624 const StaticInstPtr &inst)
625{
626 if (FullSystem) {
627 SparcFaultBase::invoke(tc, inst);
628 return;
629 }
630
631 Process *p = tc->getProcessPtr();
632 TlbEntry *entry = p->pTable->lookup(vaddr);
633 panic_if(!entry, "Tried to execute unmapped address %#x.\n", vaddr);
634
635 Addr alignedvaddr = p->pTable->pageAlign(vaddr);
636
637 // Grab fields used during instruction translation to figure out
638 // which context to use.
639 uint64_t tlbdata = tc->readMiscRegNoEffect(MISCREG_TLB_DATA);
640
641 // Inside a VM, a real address is the address that guest OS would
642 // interpret to be a physical address. To map to the physical address,
643 // it still needs to undergo a translation. The instruction
644 // translation code in the SPARC ITLB code assumes that the context is
645 // zero (kernel-level) if real addressing is being used.
646 bool is_real_address = !bits(tlbdata, 4);
647
648 // The SPARC ITLB code assumes that traps are executed in context
649 // zero so we carry that assumption through here.
650 bool trapped = bits(tlbdata, 18, 16) > 0;
651
652 // The primary context acts as a PASID. It allows the MMU to
653 // distinguish between virtual addresses that would alias to the
654 // same physical address (if two or more processes shared the same
655 // virtual address mapping).
656 int primary_context = bits(tlbdata, 47, 32);
657
658 // The partition id distinguishes between virtualized environments.
659 int const partition_id = 0;
660
661 // Given the assumptions in the translateInst code in the SPARC ITLB,
662 // the logic works out to the following for the context.
663 int context_id = (is_real_address || trapped) ? 0 : primary_context;
664
665 // Insert the TLB entry.
666 // The entry specifying whether the address is "real" is set to
667 // false for syscall emulation mode regardless of whether the
668 // address is real in preceding code. Not sure sure that this is
669 // correct, but also not sure if it matters at all.
670 dynamic_cast<TLB *>(tc->getITBPtr())->
671 insert(alignedvaddr, partition_id, context_id, false, entry->pte);
672}
673
674void
675FastDataAccessMMUMiss::invoke(ThreadContext *tc, const StaticInstPtr &inst)
676{
677 if (FullSystem) {
678 SparcFaultBase::invoke(tc, inst);
679 return;
680 }
681
682 Process *p = tc->getProcessPtr();
683 TlbEntry *entry = p->pTable->lookup(vaddr);
684 if (!entry && p->fixupStackFault(vaddr))
685 entry = p->pTable->lookup(vaddr);
686 panic_if(!entry, "Tried to access unmapped address %#x.\n", vaddr);
687
688 Addr alignedvaddr = p->pTable->pageAlign(vaddr);
689
690 // Grab fields used during data translation to figure out
691 // which context to use.
692 uint64_t tlbdata = tc->readMiscRegNoEffect(MISCREG_TLB_DATA);
693
694 // The primary context acts as a PASID. It allows the MMU to
695 // distinguish between virtual addresses that would alias to the
696 // same physical address (if two or more processes shared the same
697 // virtual address mapping). There's a secondary context used in the
698 // DTLB translation code, but it should __probably__ be zero for
699 // syscall emulation code. (The secondary context is used by Solaris
700 // to allow kernel privilege code to access user space code:
701 // [ISBN 0-13-022496-0]:PG199.)
702 int primary_context = bits(tlbdata, 47, 32);
703
704 // "Hyper-Privileged Mode" is in use. There are three main modes of
705 // operation for Sparc: Hyper-Privileged Mode, Privileged Mode, and
706 // User Mode.
707 int hpriv = bits(tlbdata, 0);
708
709 // Reset, Error and Debug state is in use. Something horrible has
710 // happened or the system is operating in Reset Mode.
711 int red = bits(tlbdata, 1);
712
713 // Inside a VM, a real address is the address that guest OS would
714 // interpret to be a physical address. To map to the physical address,
715 // it still needs to undergo a translation. The instruction
716 // translation code in the SPARC ITLB code assumes that the context is
717 // zero (kernel-level) if real addressing is being used.
718 int is_real_address = !bits(tlbdata, 5);
719
720 // Grab the address space identifier register from the thread context.
721 // XXX: Inspecting how setMiscReg and setMiscRegNoEffect behave for
722 // MISCREG_ASI causes me to think that the ASI register implementation
723 // might be bugged. The NoEffect variant changes the ASI register
724 // value in the architectural state while the normal variant changes
725 // the context field in the thread context's currently decoded request
726 // but does not directly affect the ASI register value in the
727 // architectural state. The ASI values and the context field in the
728 // request packet seem to have completely different uses.
729 MiscReg reg_asi = tc->readMiscRegNoEffect(MISCREG_ASI);
730 ASI asi = static_cast<ASI>(reg_asi);
731
732 // The SPARC DTLB code assumes that traps are executed in context
733 // zero if the asi value is ASI_IMPLICIT (which is 0x0). There's also
734 // an assumption that the nucleus address space is being used, but
735 // the context is the relevant issue since we need to pass it to TLB.
736 bool trapped = bits(tlbdata, 18, 16) > 0;
737
738 // Given the assumptions in the translateData code in the SPARC DTLB,
739 // the logic works out to the following for the context.
740 int context_id = ((!hpriv && !red && is_real_address) ||
741 asiIsReal(asi) ||
742 (trapped && asi == ASI_IMPLICIT))
743 ? 0 : primary_context;
744
745 // The partition id distinguishes between virtualized environments.
746 int const partition_id = 0;
747
748 // Insert the TLB entry.
749 // The entry specifying whether the address is "real" is set to
750 // false for syscall emulation mode regardless of whether the
751 // address is real in preceding code. Not sure sure that this is
752 // correct, but also not sure if it matters at all.
753 dynamic_cast<TLB *>(tc->getDTBPtr())->
754 insert(alignedvaddr, partition_id, context_id, false, entry->pte);
755}
756
757void
758SpillNNormal::invoke(ThreadContext *tc, const StaticInstPtr &inst)
759{
760 if (FullSystem) {
761 SparcFaultBase::invoke(tc, inst);
762 return;

--- 61 unchanged lines hidden ---