T119: kernel, spawnd, fish: Use dispatcher invocations to dump capability information
authorMoritz Hoffmann <moritz.hoffmann@inf.ethz.ch>
Mon, 15 Jun 2015 14:40:27 +0000 (16:40 +0200)
committerMoritz Hoffmann <moritz.hoffmann@inf.ethz.ch>
Tue, 16 Jun 2015 11:37:41 +0000 (13:37 +0200)
Signed-off-by: Moritz Hoffmann <moritz.hoffmann@inf.ethz.ch>

12 files changed:
if/spawn.if
include/arch/x86_64/barrelfish/invocations_arch.h
include/barrelfish/spawn_client.h
include/barrelfish_kpi/capabilities.h
kernel/arch/x86_64/syscall.c
kernel/include/sys_debug.h [new file with mode: 0644]
kernel/include/syscall.h
kernel/sys_debug.c
lib/barrelfish/spawn_client.c
usr/fish/fish_common.c
usr/monitor/monitor_server.c
usr/spawnd/service.c

index 81cedc4..2c2e4aa 100644 (file)
@@ -36,4 +36,7 @@ interface spawn "Interface to spawn domains" {
 
     rpc status(in domainid domain_id, out ps_entry ps_entry, out char argv[len],
               out errval err);
+
+    // Capability debugging
+    rpc dump_capabilities(in domainid domain_id, out errval err);
 };
index 6c46d44..e3f6ec3 100644 (file)
@@ -382,6 +382,11 @@ static inline errval_t invoke_dispatcher_dump_ptables(struct capref dispcap)
     return cap_invoke1(dispcap, DispatcherCmd_DumpPTables).error;
 }
 
+static inline errval_t invoke_dispatcher_dump_capabilities(struct capref dispcap)
+{
+    return cap_invoke1(dispcap, DispatcherCmd_DumpCapabilities).error;
+}
+
 static inline errval_t invoke_perfmon_activate(struct capref perfmon_cap,
                                                uint8_t event, uint8_t perf_umask,
                                                bool kernel, uint8_t counter_id,
index b90a1a3..3a83a09 100644 (file)
@@ -59,6 +59,7 @@ errval_t alloc_inheritcn_with_caps(struct capref *inheritcn_capp,
                                    struct capref sidcap,
                                    struct capref kernelcap);
 
+errval_t spawn_dump_capabilities(domainid_t domainid);
 __END_DECLS
 
 #endif // BARRELFISH_SPAWN_CLIENT_H
index eba95c4..41b30ed 100644 (file)
@@ -218,7 +218,8 @@ enum dispatcher_cmd {
     DispatcherCmd_Properties,       ///< Set dispatcher properties
     DispatcherCmd_PerfMon,          ///< Performance monitoring
     DispatcherCmd_SetupGuest,       ///< Set up the DCB of a guest domain
-    DispatcherCmd_DumpPTables       ///< Dump hw page tables of dispatcher
+    DispatcherCmd_DumpPTables,      ///< Dump hw page tables of dispatcher
+    DispatcherCmd_DumpCapabilities  ///< Dump capabilities of dispatcher
 };
 
 /**
index c79a8cf..50217ca 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <kernel.h>
 #include <kcb.h>
+#include <sys_debug.h>
 #include <syscall.h>
 #include <barrelfish_kpi/syscalls.h>
 #include <mdb/mdb.h>
@@ -742,6 +743,20 @@ static struct sysret dispatcher_dump_ptables(struct capability *cap,
     return SYSRET(SYS_ERR_OK);
 }
 
+static struct sysret dispatcher_dump_capabilities(struct capability *cap,
+                                             int cmd, uintptr_t *args)
+{
+    assert(cap->type == ObjType_Dispatcher);
+
+    printf("dispatcher_dump_capabilities\n");
+
+    struct dcb *dispatcher = cap->u.dispatcher.dcb;
+
+    errval_t err = debug_print_cababilities(dispatcher);
+
+    return SYSRET(err);
+}
+
 /*
  * \brief Activate performance monitoring
  *
@@ -912,6 +927,7 @@ static invocation_handler_t invocations[ObjType_Num][CAP_MAX_CMD] = {
         [DispatcherCmd_SetupGuest] = handle_dispatcher_setup_guest,
 #endif
         [DispatcherCmd_DumpPTables]  = dispatcher_dump_ptables,
+        [DispatcherCmd_DumpCapabilities] = dispatcher_dump_capabilities
     },
     [ObjType_KernelControlBlock] = {
         [FrameCmd_Identify] = handle_kcb_identify,
diff --git a/kernel/include/sys_debug.h b/kernel/include/sys_debug.h
new file mode 100644 (file)
index 0000000..fd50efb
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * \file
+ * \brief Arch-generic system calls implementation.
+ */
+
+/*
+ * Copyright (c) 2007, 2008, 2009, 2010, 2012, ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#ifndef KERNEL_SYS_DEBUG_H
+#define KERNEL_SYS_DEBUG_H
+
+#include <kernel.h>
+#include <barrelfish_kpi/cpu.h>
+#include <barrelfish_kpi/dispatcher_shared_target.h>
+#include <barrelfish_kpi/types.h>
+#include <capabilities.h>
+
+/*
+ * System calls for debug output.
+ */
+struct sysret
+sys_debug_print_capabilities(void);
+
+errval_t
+debug_print_cababilities(struct dcb *dispatcher);
+
+#endif
index 250e8b4..ae6c9c0 100644 (file)
@@ -113,10 +113,4 @@ struct sysret sys_monitor_clear_step(capaddr_t ret_cn_addr,
                                      uint8_t ret_cn_bits,
                                      cslot_t ret_slot);
 
-/*
- * System calls for debug output.
- */
-struct sysret
-sys_debug_print_capabilities(void);
-
 #endif
index 17a82f0..91dbf09 100644 (file)
@@ -15,6 +15,7 @@
 #include <kernel.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys_debug.h>
 #include <syscall.h>
 #include <barrelfish_kpi/init.h>
 #include <barrelfish_kpi/syscalls.h>
@@ -162,7 +163,8 @@ static bool sys_debug_print_capabilities_check_cnode(struct cte *cte, struct cte
     return false;
 }
 
-static errval_t sys_debug_print_capabilities_cb(struct cte *cte, void *data) {
+static errval_t
+sys_debug_print_capabilities_cb(struct cte *cte, void *data) {
 //    printk(LOG_NOTE, "cte=%p\n", cte);
 
     struct dcb *my_dcb = (struct dcb *) data;
@@ -200,17 +202,22 @@ static errval_t sys_debug_print_capabilities_cb(struct cte *cte, void *data) {
         get_dispatcher_shared_generic(handle);
 
     if (my_dcb == dcb) {
-        printk(LOG_NOTE, "disp->name=%s\n", disp->name);
+//        printk(LOG_NOTE, "disp->name=%s\n", disp->name);
         caps_debug_print(cte, NULL);
     }
 
     return SYS_ERR_OK;
 }
 
+errval_t
+debug_print_cababilities(struct dcb *dispatcher) {
+    return mdb_traverse(MDB_TRAVERSAL_ORDER_ASCENDING, sys_debug_print_capabilities_cb, dispatcher);
+}
+
 struct sysret
 sys_debug_print_capabilities(void) {
 
-    errval_t err = mdb_traverse(MDB_TRAVERSAL_ORDER_ASCENDING, sys_debug_print_capabilities_cb, dcb_current);
+    errval_t err = debug_print_cababilities(dcb_current);
 
     return SYSRET(err);
 }
index 39302ff..904549d 100644 (file)
@@ -611,6 +611,28 @@ errval_t spawn_get_status(uint8_t domain, struct spawn_ps_entry *pse,
 }
 
 /**
+ * \brief Dump capabilities for a given domain
+ */
+errval_t spawn_dump_capabilities(domainid_t domainid)
+{
+    errval_t err, reterr;
+
+    err = bind_client(disp_get_core_id());
+    if (err_is_fail(err)) {
+        return err;
+    }
+    struct spawn_rpc_client *cl = get_spawn_rpc_client(disp_get_core_id());
+    assert(cl != NULL);
+
+    err = cl->vtbl.dump_capabilities(cl, domainid, &reterr);
+    if (err_is_fail(err)) {
+        return err;
+    }
+
+    return reterr;
+}
+
+/**
  * \brief Utility function to create an inherit cnode
  * and copy caps into it.
  *
index 1fe4117..a83fa82 100644 (file)
@@ -124,15 +124,16 @@ static int print_cspace(int argc, char *argv[])
     return EXIT_SUCCESS;
 }
 
-static int debug_print_caps(int argc, char *argv[]) {
+static int dump_caps(int argc, char *argv[]) {
     errval_t err;
-    if (argc > 1 && strncmp("monitor", argv[1], 7)) {
-        err = monitor_debug_print_cababilities();
+    if (argc > 1) {
+        domainid_t domain = strtol(argv[1], NULL, 10);
+        err = spawn_dump_capabilities(domain);
     } else {
         err = sys_debug_print_capabilities();
     }
     if (err_is_fail(err)) {
-        printf("%s: error debug print cababilities: %s\n", argv[0], err_getstring(err));
+        printf("%s: error dumping capabilities: %s\n", argv[0], err_getstring(err));
         DEBUG_ERR(err, "Error\n");
         return EXIT_FAILURE;
     }
@@ -1230,7 +1231,7 @@ static struct cmd commands[] = {
     {"src", src, "Execute the list of commands in a file"},
     {"printenv", printenv, "Display environment variables"},
     {"free", freecmd, "Display amount of free memory in the system"},
-    {"debug_print_caps", debug_print_caps, "Display cspace debug information"},
+    {"dump_caps", dump_caps, "Display cspace debug information"},
 };
 
 static void getline(char *input, size_t size)
index 1b0e11c..62b8fa6 100644 (file)
@@ -805,10 +805,6 @@ static void migrate_dispatcher_request(struct monitor_binding *b,
    printf("%s:%d\n", __FUNCTION__, __LINE__);
 }
 
-static void debug_print_capabilities(struct monitor_binding *b) {
-    sys_debug_print_capabilities();
-}
-
 struct monitor_rx_vtbl the_table = {
     .alloc_iref_request = alloc_iref_request,
 
@@ -834,8 +830,6 @@ struct monitor_rx_vtbl the_table = {
     .span_domain_request    = span_domain_request,
 
     .migrate_dispatcher_request = migrate_dispatcher_request,
-
-    .debug_print_capabilities = debug_print_capabilities
 };
 
 errval_t monitor_client_setup(struct spawninfo *si)
index 073f6f0..74bf3e3 100644 (file)
@@ -24,6 +24,7 @@
 #include <if/spawn_defs.h>
 #include <if/monitor_blocking_rpcclient_defs.h>
 #include <barrelfish/dispatcher_arch.h>
+#include <barrelfish/invocations_arch.h>
 
 #include "internal.h"
 #include "ps.h"
@@ -635,6 +636,26 @@ static void status_handler(struct spawn_binding *b, domainid_t domainid)
     }
 }
 
+
+static errval_t dump_capabilities(domainid_t domainid) {
+    struct ps_entry *ps = ps_get(domainid);
+
+    if(ps == NULL) {
+        return SPAWN_ERR_DOMAIN_NOTFOUND;
+    }
+
+    return invoke_dispatcher_dump_capabilities(ps->dcb);
+}
+
+static void dump_capabilities_handler(struct spawn_binding *b, domainid_t domainid) {
+    errval_t err = dump_capabilities(domainid);
+
+    err = b->tx_vtbl.dump_capabilities_response(b, NOP_CONT, err);
+    if(err_is_fail(err)) {
+        DEBUG_ERR(err, "debug_print_capabilities_response");
+    }
+}
+
 static struct spawn_rx_vtbl rx_vtbl = {
     .spawn_domain_call = spawn_handler,
     .spawn_domain_with_caps_call = spawn_with_caps_handler,
@@ -644,6 +665,7 @@ static struct spawn_rx_vtbl rx_vtbl = {
     .wait_call = wait_handler,
     .get_domainlist_call = get_domainlist_handler,
     .status_call = status_handler,
+    .dump_capabilities_call = dump_capabilities_handler
 };
 
 static void export_cb(void *st, errval_t err, iref_t iref)