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

--- 61 unchanged lines hidden ---