tlb.cc (5917:7d7df4ad7486) tlb.cc (5965:71f8d7c12619)
1/*
2 * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
3 * All rights reserved.
4 *
5 * Redistribution and use of this software in source and binary forms,
6 * with or without modification, are permitted provided that the
7 * following conditions are met:
8 *

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

570 SegAttr csAttr = tc->readMiscRegNoEffect(MISCREG_CS_ATTR);
571 // If we're not in 64-bit mode, do protection/limit checks
572 if (!efer.lma || !csAttr.longMode) {
573 DPRINTF(TLB, "Not in long mode. Checking segment protection.\n");
574 // Check for a NULL segment selector.
575 if (!tc->readMiscRegNoEffect(MISCREG_SEG_SEL(seg)))
576 return new GeneralProtection(0);
577 bool expandDown = false;
1/*
2 * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
3 * All rights reserved.
4 *
5 * Redistribution and use of this software in source and binary forms,
6 * with or without modification, are permitted provided that the
7 * following conditions are met:
8 *

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

570 SegAttr csAttr = tc->readMiscRegNoEffect(MISCREG_CS_ATTR);
571 // If we're not in 64-bit mode, do protection/limit checks
572 if (!efer.lma || !csAttr.longMode) {
573 DPRINTF(TLB, "Not in long mode. Checking segment protection.\n");
574 // Check for a NULL segment selector.
575 if (!tc->readMiscRegNoEffect(MISCREG_SEG_SEL(seg)))
576 return new GeneralProtection(0);
577 bool expandDown = false;
578 SegAttr attr = tc->readMiscRegNoEffect(MISCREG_SEG_ATTR(seg));
578 if (seg >= SEGMENT_REG_ES && seg <= SEGMENT_REG_HS) {
579 if (seg >= SEGMENT_REG_ES && seg <= SEGMENT_REG_HS) {
579 SegAttr attr = tc->readMiscRegNoEffect(MISCREG_SEG_ATTR(seg));
580 if (!attr.writable && write)
581 return new GeneralProtection(0);
582 if (!attr.readable && !write && !execute)
583 return new GeneralProtection(0);
584 expandDown = attr.expandDown;
580 if (!attr.writable && write)
581 return new GeneralProtection(0);
582 if (!attr.readable && !write && !execute)
583 return new GeneralProtection(0);
584 expandDown = attr.expandDown;
585
585 }
586 Addr base = tc->readMiscRegNoEffect(MISCREG_SEG_BASE(seg));
587 Addr limit = tc->readMiscRegNoEffect(MISCREG_SEG_LIMIT(seg));
586 }
587 Addr base = tc->readMiscRegNoEffect(MISCREG_SEG_BASE(seg));
588 Addr limit = tc->readMiscRegNoEffect(MISCREG_SEG_LIMIT(seg));
589 // This assumes we're not in 64 bit mode. If we were, the default
590 // address size is 64 bits, overridable to 32.
591 int size = 32;
592 bool sizeOverride = (flags & (AddrSizeFlagBit << FlagShift));
593 if (csAttr.defaultSize && sizeOverride ||
594 !csAttr.defaultSize && !sizeOverride)
595 size = 16;
596 Addr offset = bits(vaddr - base, size-1, 0);
597 Addr endOffset = offset + req->getSize() - 1;
588 if (expandDown) {
589 DPRINTF(TLB, "Checking an expand down segment.\n");
598 if (expandDown) {
599 DPRINTF(TLB, "Checking an expand down segment.\n");
590 // We don't have to worry about the access going around the
591 // end of memory because accesses will be broken up into
592 // pieces at boundaries aligned on sizes smaller than an
593 // entire address space. We do have to worry about the limit
594 // being less than the base.
595 if (limit < base) {
596 if (limit < vaddr + req->getSize() && vaddr < base)
597 return new GeneralProtection(0);
598 } else {
599 if (limit < vaddr + req->getSize())
600 return new GeneralProtection(0);
601 }
600 warn_once("Expand down segments are untested.\n");
601 if (offset <= limit || endOffset <= limit)
602 return new GeneralProtection(0);
602 } else {
603 } else {
603 if (limit < base) {
604 if (vaddr <= limit || vaddr + req->getSize() >= base)
605 return new GeneralProtection(0);
606 } else {
607 if (vaddr <= limit && vaddr + req->getSize() >= base)
608 return new GeneralProtection(0);
609 }
604 if (offset > limit || endOffset > limit)
605 return new GeneralProtection(0);
610 }
611 }
612 // If paging is enabled, do the translation.
613 if (cr0.pg) {
614 DPRINTF(TLB, "Paging enabled.\n");
615 // The vaddr already has the segment base applied.
616 TlbEntry *entry = lookup(vaddr);
617 if (!entry) {

--- 179 unchanged lines hidden ---
606 }
607 }
608 // If paging is enabled, do the translation.
609 if (cr0.pg) {
610 DPRINTF(TLB, "Paging enabled.\n");
611 // The vaddr already has the segment base applied.
612 TlbEntry *entry = lookup(vaddr);
613 if (!entry) {

--- 179 unchanged lines hidden ---