Skip to content

Commit

Permalink
* Disabled a half-done optimization that was causing problems.
Browse files Browse the repository at this point in the history
  ^ We attempted to avoid addrspace switches when just pulling a kernel thread,
    since the kernel is mapped into all addrspaces.
  ^ However, this caused the taskStream to point to the kernel thread (and
    by extension, the kernel process), while simultaneously pointing potentially
    to an addrspace that was not the kernel addrspace.
  ^ This caused problems with top-level page table entry propagation.

* Wrote a decent chunk of fplainn::Zum::enumerateChildDevices.
  ^ Returns an array of device IDs, one 32-bit integer for each ID that the
    device reported in the cycle.
  ^ If callers wish to know which /new/ devices were reported, they will
    have to, for now at least, though most likely in perpetuity, save a list of
    the child devices on their target device before calling
    enumerateChildDevices.

* Made sure that all page-mapping component pages (l0 accessor, l1
  accessor/modifier) have PAGING_L?_CACHE_WRITE_THROUGH set.

* Properly integrated the support code on the page-fault end, for the top-level
  __kvaddrspace change propagation sequence.

Improvements:
* We can now print all processes, their IDs and vaddrspace info, for debugging.
  • Loading branch information
latentPrion committed Jul 15, 2015
1 parent 36bd961 commit 47caeba
Show file tree
Hide file tree
Showing 17 changed files with 413 additions and 58 deletions.
35 changes: 27 additions & 8 deletions core/__kthreads/x8632/__korientationMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,14 @@ printf(NOTICE ORIENT"orient 3.\n");
for (;FOREVER;) { asm volatile("hlt\n\t"); };
}

void __kecrCb(MessageStream::sHeader *msgIt);

void __kotp(MessageStream::sHeader *msgIt)
{
fplainn::Zum::sZumMsg *msg = (fplainn::Zum::sZumMsg *)msgIt;
udi_enumerate_cb_t *ecb = &msg->info.params.enumerate.cb;
udi_instance_attr_list_t a[2];
udi_filter_element_t f[2];
sMovableMemObject<udi_filter_element_t, 2> tf;

printf(NOTICE"here, finished enum req.\n");
printf(NOTICE ORIENT"msg 0x%p: %d attr @0x%p, %d filt @0x%p.\n",
Expand All @@ -468,14 +470,31 @@ printf(NOTICE"here, finished enum req.\n");
ecb->filter_list_length,
ecb->filter_list);

floodplainn.zum.getEnumerateReqAttrsAndFilters(ecb, a, f);
for (uarch_t i=0; i<ecb->attr_valid_length; i++) {
printf(CC"\tattr %s.\n", ecb->attr_list[i].attr_name);
};
floodplainn.zum.getEnumerateReqAttrsAndFilters(ecb, a, tf.a);

for (uarch_t i=0; i<ecb->filter_list_length; i++) {
printf(CC"\tfilt %s.\n", ecb->filter_list[i].attr_name);
{
ecb->filter_list_length = 2;
ecb->filter_list = tf.a;
};

// floodplainn.zum.enumerateChildrenReq(CC"by-id", ecb, 0, 0);
ecb->attr_valid_length = 0;
ecb->attr_list = NULL;
floodplainn.zum.enumerateChildrenReq(
CC"by-id", ecb, 0,
new __kCallback(&__kecrCb));
}

void __kecrCb(MessageStream::sHeader *msgIt)
{
fplainn::Zum::sZumMsg *msg = (fplainn::Zum::sZumMsg *)msgIt;

printf(NOTICE"Here, enumChildren done. %d new child IDs in buffer.\n",
msg->info.params.enumerateChildren.nDeviceIds);

for (uarch_t i=0; i<msg->info.params.enumerateChildren.nDeviceIds; i++)
{
printf(NOTICE"New child: %s/%d.\n",
msg->info.path,
msg->info.params.enumerateChildren.deviceIdsHandle[i]);
};
}
1 change: 0 additions & 1 deletion core/arch/x8632/wPRanger_getLevelRanges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ void getLevelRanges(
*l2End = (endAddr & PAGING_L2_VADDR_MASK) >> PAGING_L2_VADDR_SHIFT;
#endif
}

6 changes: 4 additions & 2 deletions core/arch/x8632/wPRanger_mapInc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ status_t walkerPageRanger::mapInc(
l0Entry;

*level1Modifier = vaddrSpace->level0Accessor.rsrc
->entries[l0Current];
->entries[l0Current]
| PAGING_L0_CACHE_WRITE_THROUGH;

// Flush the l1 accessor from the TLB.
tlbControl::flushSingleEntry((void *)level1Accessor);
Expand Down Expand Up @@ -120,7 +121,8 @@ status_t walkerPageRanger::mapInc(
level1Accessor->entries[l1Current] = l1Entry;

*level2Modifier =
level1Accessor->entries[l1Current];
level1Accessor->entries[l1Current]
| PAGING_L2_CACHE_WRITE_THROUGH;

tlbControl::flushSingleEntry(
(void *)level2Accessor);
Expand Down
6 changes: 4 additions & 2 deletions core/arch/x8632/wPRanger_mapNoInc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ status_t walkerPageRanger::mapNoInc(
l0Entry;

*level1Modifier = vaddrSpace->level0Accessor.rsrc
->entries[l0Current];
->entries[l0Current]
| PAGING_L1_CACHE_WRITE_THROUGH;

// Flush the l1 accessor from the TLB.
tlbControl::flushSingleEntry((void *)level1Accessor);
Expand Down Expand Up @@ -116,7 +117,8 @@ status_t walkerPageRanger::mapNoInc(
level1Accessor->entries[l1Current] = l1Entry;

*level2Modifier =
level1Accessor->entries[l1Current];
level1Accessor->entries[l1Current]
| PAGING_L2_CACHE_WRITE_THROUGH;

tlbControl::flushSingleEntry(
(void *)level2Accessor);
Expand Down
35 changes: 27 additions & 8 deletions core/arch/x8632/x8632_pageFault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <arch/debug.h>
#include <__kstdlib/__kflagManipulation.h>
#include <__kclasses/debugPipe.h>
#include <__kclasses/memReservoir.h>
#include <kernel/common/panic.h>
#include <kernel/common/process.h>
#include <kernel/common/cpuTrib/cpuTrib.h>
Expand Down Expand Up @@ -94,13 +95,17 @@ status_t x8632_page_fault(RegisterContext *regs, ubit8)
paddr_t pmap;
uarch_t __kflags;
Thread *currThread=NULL;
sbit8 panicWorthy=0, traceStack=0, printArgs=0;
sbit8 panicWorthy=0, traceStack=0, printArgs=0,
topLevelPropagated=0, printVaddrspaceInfo=0;

currThread = cpuTrib.getCurrentCpuStream()->taskStream.getCurrentThread();
vaddrSpaceStream = currThread->parent->getVaddrSpaceStream();

if (faultAddr >= (void *)ARCH_MEMORY___KLOAD_VADDR_BASE)
{ __kpropagateTopLevelVaddrSpaceChanges(faultAddr); };
{
topLevelPropagated = __kpropagateTopLevelVaddrSpaceChanges(
faultAddr);
};

status = walkerPageRanger::lookup(
&vaddrSpaceStream->vaddrSpace,
Expand Down Expand Up @@ -139,7 +144,7 @@ status_t x8632_page_fault(RegisterContext *regs, ubit8)

case WPRANGER_STATUS_HEAP_GUARDPAGE:
panicWorthy = 1;
//traceStack = 1;
traceStack = 1;

printf(FATAL"Encountered a heap guardpage; heap corrupted\n"
"\tVaddr: 0x%p, EIP 0x%p\n"
Expand Down Expand Up @@ -172,13 +177,19 @@ status_t x8632_page_fault(RegisterContext *regs, ubit8)
break;

case WPRANGER_STATUS_BACKED:
if (topLevelPropagated) { break; };

// Either COW, or simple access perms violation.
panicWorthy = 1;
//traceStack = 1;
printf(FATAL"Kernel faulted on a backed page. Probably access "
"perms violation, or unintentional COW\n"
"Vaddr: 0x%p. EIP 0x%p.\n",
faultAddr, regs->eip);
traceStack = 1;
printVaddrspaceInfo = 1;
printf(FATAL"BACKED page faulted. Access perms violation or "
"unintended COW?\n"
"\tVaddr: 0x%p, __kf 0x%x. EIP 0x%p. Errcode 0x%x "
"TID 0x%x.\n",
faultAddr, __kflags, regs->eip, regs->errorCode,
cpuTrib.getCurrentCpuStream()->taskStream
.getCurrentThread()->getFullId());

break;

Expand All @@ -203,6 +214,14 @@ status_t x8632_page_fault(RegisterContext *regs, ubit8)
break;
};

if (printVaddrspaceInfo)
{
printf(NOTICE"TID 0x%x, L0v 0x%p, L0p 0x%P.\n",
currThread->getFullId(),
vaddrSpaceStream->vaddrSpace.level0Accessor.rsrc,
vaddrSpaceStream->vaddrSpace.level0Paddr);
};

if (traceStack)
{
debug::sStackDescriptor currStackDesc;
Expand Down
12 changes: 9 additions & 3 deletions core/commonlibs/drivers/zrootdev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void zrootdev_usage_ind(udi_usage_cb_t *cb, udi_ubit8_t resource_level)
udi_usage_res(cb);
}

ubit32 ___=0;
void zrootdev_enumerate_req(
udi_enumerate_cb_t *cb, udi_ubit8_t enumeration_level
)
Expand All @@ -28,15 +29,20 @@ printf(NOTICE"enum!\tcb 0x%p, %d attr @0x%p, %d filt @0x%p.\n",
cb->attr_valid_length, cb->attr_list,
cb->filter_list_length, cb->filter_list);

for (uarch_t i=0; i<cb->attr_valid_length; i++) {
/* for (uarch_t i=0; i<cb->attr_valid_length; i++) {
printf(CC"\tattr %s.\n", cb->attr_list[i].attr_name);
};
for (uarch_t i=0; i<cb->filter_list_length; i++) {
printf(CC"\tfilt %s.\n", cb->filter_list[i].attr_name);
};
};*/

udi_enumerate_ack(cb, UDI_ENUMERATE_LEAF, 0);
if (___ >3) {
udi_enumerate_ack(cb, UDI_ENUMERATE_DONE, 0);
} else {
cb->child_ID = ___++;
udi_enumerate_ack(cb, UDI_ENUMERATE_OK, 0);
};
}

void zrootdev_devmgmt_req(
Expand Down
1 change: 0 additions & 1 deletion core/include/kernel/common/floodplainn/floodplainn.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,3 @@ public Tributary//, public vfs::DirectoryOperations
extern Floodplainn floodplainn;

#endif

2 changes: 2 additions & 0 deletions core/include/kernel/common/floodplainn/zum.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ class fplainn::Zum
udi_enumerate_cb_t cb;

uarch_t flags;
uarch_t nDeviceIds;
ubit32 *deviceIdsHandle;
} enumerateChildren;
} params;
};
Expand Down
2 changes: 2 additions & 0 deletions core/include/kernel/common/processTrib/processTrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ public Tributary

error_t destroyStream(void);

void dumpProcessesAndVaddrspaces(void);

private:
void fillOutPrioClasses(void);
error_t getNewProcessId(processId_t *ret);
Expand Down
10 changes: 10 additions & 0 deletions core/include/kernel/common/vaddrSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ class VaddrSpace

~VaddrSpace(void);

void dumpAllNonEmpty(void);
void dumpAllPresent(void);
status_t getTopLevelAddrState(void *vaddr)
{
return getTopLevelAddrState(
(uintptr_t)vaddr >> PAGING_L0_VADDR_SHIFT);
}

status_t getTopLevelAddrState(uarch_t entry);

public:
// Uses a recursive lock, take note.
SharedResourceGroup<RecursiveLock, sPagingLevel0 *> level0Accessor;
Expand Down
4 changes: 2 additions & 2 deletions core/kernel/common/__kclassInstances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ InterruptTrib interruptTrib;
MemoryTrib memoryTrib;
DebugTrib debugTrib;
MemReservoir memReservoir(&processTrib.__kgetStream()->memoryStream);
CpuTrib cpuTrib;
CpuTrib cpuTrib;
DebugPipe __kdebug;
TaskTrib taskTrib;
CachePool cachePool;
ExecTrib execTrib;
VfsTrib vfsTrib;
VfsTrib vfsTrib;
DistributaryTrib distributaryTrib;
Floodplainn floodplainn;

Loading

0 comments on commit 47caeba

Please sign in to comment.