[kitten] 2 new revisions pushed by kevin.pe...@gmail.com on 2013-08-28 00:01 GMT

4 views
Skip to first unread message

kit...@googlecode.com

unread,
Aug 27, 2013, 8:02:02 PM8/27/13
to kitten-...@googlegroups.com
2 new revisions:

Revision: 7fa9049c3e59
Branch: default
Author: Angen Zheng <angen...@gmail.com>
Date: Thu Aug 22 11:28:39 2013 UTC
Log: Fixup palacios OS hooks and sockets code for recent palacios
interface...
http://code.google.com/p/kitten/source/detail?r=7fa9049c3e59

Revision: 44c1cfedbdc0
Branch: default
Author: Kevin Pedretti <ktp...@sandia.gov>
Date: Thu Aug 22 11:54:44 2013 UTC
Log: Fix .config include. It was silently getting dropped previously.
http://code.google.com/p/kitten/source/detail?r=44c1cfedbdc0

==============================================================================
Revision: 7fa9049c3e59
Branch: default
Author: Angen Zheng <angen...@gmail.com>
Date: Thu Aug 22 11:28:39 2013 UTC
Log: Fixup palacios OS hooks and sockets code for recent palacios
interface changes.
http://code.google.com/p/kitten/source/detail?r=7fa9049c3e59

Modified:
/arch/x86_64/kernel/palacios/palacios.c
/arch/x86_64/kernel/palacios/palacios.h
/arch/x86_64/kernel/palacios/palacios_socket.c

=======================================
--- /arch/x86_64/kernel/palacios/palacios.c Wed Feb 20 18:14:37 2013 UTC
+++ /arch/x86_64/kernel/palacios/palacios.c Thu Aug 22 11:28:39 2013 UTC
@@ -69,23 +69,6 @@

v3_deliver_keyboard_event(g_vm_guest, &event);
}
-
-/**
- * Sends a mouse event to Palacios for handling.
- */
-void
-send_mouse_to_palacios(
- unsigned char packet[3]
-)
-{
- if (!g_vm_guest)
- return;
-
- struct v3_mouse_event event;
- memcpy(event.data, packet, 3);
-
- v3_deliver_mouse_event(g_vm_guest, &event);
-}

/**
* Sends a timer tick event to Palacios for handling.
@@ -107,27 +90,34 @@

/**
* Prints a message to the console.
+ * TODO: Prefix print messages with vm->name and vcore
*/
static void
palacios_print(
- const char * fmt,
+ void * vm,
+ int vcore,
+ const char * format,
...
)
{
va_list ap;
- va_start(ap, fmt);
- vprintk(fmt, ap);
+ va_start(ap, format);
+ vprintk(format, ap);
va_end(ap);
}

/**
* Allocates a contiguous region of pages of the requested size.
* Returns the physical address of the first page in the region.
+ *
+ * TODO: Actually use node_id and constraint arguments
*/
static void *
palacios_allocate_pages(
int num_pages,
- unsigned int alignment // must be power of two
+ unsigned int alignment, // must be power of two
+ int node_id,
+ int constraint
)
{
struct pmem_region result;
@@ -374,6 +364,17 @@
{
schedule();
}
+
+/**
+ * Puts the caller to sleep 'usec' microseconds.
+ */
+static void
+palacios_sleep_cpu(
+ unsigned int usec
+)
+{
+ schedule_timeout(usec * 1000);
+}

/**
* Creates a kernel thread.
@@ -433,6 +434,34 @@
{
spin_unlock((spinlock_t *)mutex);
}
+
+/**
+ * Locks a mutex and disables interrupts.
+ * Return value should be passed to the corresponding
+ * palacios_mutex_unlock_irqrestore() as the flags argument.
+ */
+static void *
+palacios_mutex_lock_irqsave(
+ void * mutex,
+ int must_spin
+)
+{
+ unsigned long flags;
+ spin_lock_irqsave((spinlock_t *)mutex, flags);
+ return (void *) flags;
+}
+
+/**
+ * Unlocks a mutex and, if indicated by flags argument, restores
interrupts.
+ */
+static void
+palacios_mutex_unlock_irqrestore(
+ void * mutex,
+ void * flags
+)
+{
+ spin_unlock_irqrestore((spinlock_t *)mutex, (unsigned long)flags);
+}

/**
* Structure used by the Palacios hypervisor to interface with the host
kernel.
@@ -450,10 +479,13 @@
.get_cpu_khz = palacios_get_cpu_khz,
.start_kernel_thread = palacios_start_kernel_thread,
.yield_cpu = palacios_yield_cpu,
+ .sleep_cpu = palacios_sleep_cpu,
.mutex_alloc = palacios_mutex_alloc,
.mutex_free = palacios_mutex_free,
.mutex_lock = palacios_mutex_lock,
.mutex_unlock = palacios_mutex_unlock,
+ .mutex_lock_irqsave = palacios_mutex_lock_irqsave,
+ .mutex_unlock_irqrestore = palacios_mutex_unlock_irqrestore,
.get_cpu = palacios_get_cpu,
.interrupt_cpu = palacios_interrupt_cpu,
.call_on_cpu = palacios_xcall,
=======================================
--- /arch/x86_64/kernel/palacios/palacios.h Thu Apr 16 22:23:21 2009 UTC
+++ /arch/x86_64/kernel/palacios/palacios.h Thu Aug 22 11:28:39 2013 UTC
@@ -8,7 +8,6 @@
* These are used by the kernel to forward events to Palacios.
*/
extern void send_key_to_palacios(unsigned char status, unsigned char
scan_code);
-extern void send_mouse_to_palacios(unsigned char packet[3]);
extern void send_tick_to_palacios(unsigned int period_us);

#endif
=======================================
--- /arch/x86_64/kernel/palacios/palacios_socket.c Tue Apr 12 16:06:38 2011
UTC
+++ /arch/x86_64/kernel/palacios/palacios_socket.c Thu Aug 22 11:28:39 2013
UTC
@@ -26,12 +26,15 @@
#include <lwip/tcpip.h>
#include <lwk/driver.h>

+typedef int palacios_socket;
+
//ignore the arguments given here currently
-static int
+static void *
palacios_tcp_socket(
const int bufsize,
const int nodelay,
- const int nonblocking
+ const int nonblocking,
+ void * private_data
)
{
int sock = lwip_socket(PF_INET, SOCK_STREAM, 0);
@@ -40,29 +43,40 @@
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
&nodelay, sizeof(nodelay));
}
-
- return sock;
+
+ palacios_socket *sock_ptr = (palacios_socket *)
kmem_alloc(sizeof(palacios_socket));
+ *sock_ptr = sock;
+
+ return sock_ptr;
}

//ignore the arguments given here currently
-static int
+static void *
palacios_udp_socket(
const int bufsize,
- const int nonblocking
+ const int nonblocking,
+ void * private_data
)
{
- return lwip_socket(PF_INET, SOCK_DGRAM, 0);
+ int sock = lwip_socket(PF_INET, SOCK_DGRAM, 0);
+
+ palacios_socket *sock_ptr = (palacios_socket *)
kmem_alloc(sizeof(palacios_socket));
+ *sock_ptr = sock;
+
+ return sock_ptr;
}

static void
-palacios_close(int sock)
+palacios_close(void * sock_ptr)
{
- lwip_close(sock);
+ palacios_socket *sock = (palacios_socket *) sock_ptr;
+ lwip_close(*sock);
+ kmem_free(sock);
}

static int
palacios_bind_socket(
- const int sock,
+ const void * sock_ptr,
const int port
)
{
@@ -71,22 +85,25 @@
addr.sin_family = AF_INET;
addr.sin_port = htons( port );
addr.sin_addr.s_addr = INADDR_ANY;
+
+ palacios_socket *sock = (palacios_socket *) sock_ptr;

- return lwip_bind(sock, (struct sockaddr*) &addr, sizeof(addr));
+ return lwip_bind(*sock, (struct sockaddr *) &addr, sizeof(addr));
}

static int
palacios_listen(
- const int sock,
+ const void * sock_ptr,
int backlog
)
{
- return lwip_listen(sock, backlog);
+ palacios_socket *sock = (palacios_socket *) sock_ptr;
+ return lwip_listen(*sock, backlog);
}

-static int
+static void *
palacios_accept(
- const int sock,
+ const void * sock_ptr,
unsigned int * remote_ip,
unsigned int * port
)
@@ -94,15 +111,18 @@
struct sockaddr_in client;
socklen_t len;
int client_sock;
-
- client_sock = lwip_accept(sock, (struct sockaddr *) &client, &len);
+ palacios_socket *sock = (palacios_socket *) sock_ptr;
+ client_sock = lwip_accept(*sock, (struct sockaddr *) &client, &len);

if (client.sin_family == AF_INET) {
- *port = ntohs (client.sin_port);
+ *port = ntohs (client.sin_port);
*remote_ip = ntohl(client.sin_addr.s_addr);
}

- return client_sock;
+ palacios_socket *client_sock_ptr = (palacios_socket *)
kmem_alloc(sizeof(palacios_socket));
+ *client_sock_ptr = client_sock;
+
+ return client_sock_ptr;
}

static int
@@ -118,7 +138,7 @@

static int
palacios_connect_to_ip(
- const int sock,
+ const void * sock_ptr,
const int hostip,
const int port
)
@@ -129,32 +149,36 @@
client.sin_port = htons( port );
client.sin_addr.s_addr = htonl(hostip);

- return lwip_connect(sock, (struct sockaddr *) &client, sizeof(client));
+ palacios_socket *sock = (palacios_socket *) sock_ptr;
+
+ return lwip_connect(*sock, (struct sockaddr *) &client, sizeof(client));
}

static int
palacios_send(
- const int sock,
+ const void * sock_ptr,
const char * buf,
const int len
)
{
- return lwip_write(sock, buf, len);
+ palacios_socket *sock = (palacios_socket *) sock_ptr;
+ return lwip_write(*sock, buf, len);
}

static int
palacios_recv(
- const int sock,
+ const void * sock_ptr,
char * buf,
const int len
)
{
- return lwip_read(sock, buf, len);
+ palacios_socket *sock = (palacios_socket *) sock_ptr;
+ return lwip_read(*sock, buf, len);
}

static int
palacios_sendto_ip(
- const int sock,
+ const void * sock_ptr,
const int ip_addr,
const int port,
const char * buf,
@@ -166,13 +190,13 @@
dst.sin_family = AF_INET;
dst.sin_port = htons(port);
dst.sin_addr.s_addr = htonl(ip_addr);
-
- return lwip_sendto(sock, buf, len, 0, (struct sockaddr *) &dst,
sizeof(dst));
+ palacios_socket *sock = (palacios_socket *) sock_ptr;
+ return lwip_sendto(*sock, buf, len, 0, (struct sockaddr *) &dst,
sizeof(dst));
}

static int
palacios_recvfrom_ip(
- const int sock,
+ const void * sock_ptr,
const int ip_addr,
const int port,
char * buf,
@@ -186,15 +210,15 @@
src.sin_port = htons(port);
src.sin_addr.s_addr = htonl(ip_addr);
alen = sizeof(src);
-
- return lwip_recvfrom(sock, buf, len, 0 /*unsigned int flags*/, (struct
sockaddr *) &src, &alen);
+ palacios_socket *sock = (palacios_socket *) sock_ptr;
+ return lwip_recvfrom(*sock, buf, len, 0 /*unsigned int flags*/, (struct
sockaddr *) &src, &alen);
}

struct v3_socket_hooks palacios_sock_hooks = {
.tcp_socket = palacios_tcp_socket,
.udp_socket = palacios_udp_socket,
.close = palacios_close,
- .bind_socket = palacios_bind_socket,
+ .bind = palacios_bind_socket,
.listen = palacios_listen,
.accept = palacios_accept,
.select = palacios_select,

==============================================================================
Revision: 44c1cfedbdc0
Branch: default
Author: Kevin Pedretti <ktp...@sandia.gov>
Date: Thu Aug 22 11:54:44 2013 UTC
Log: Fix .config include. It was silently getting dropped previously.
http://code.google.com/p/kitten/source/detail?r=44c1cfedbdc0

Modified:
/user/Makefile.header

=======================================
--- /user/Makefile.header Wed Aug 7 19:54:32 2013 UTC
+++ /user/Makefile.header Thu Aug 22 11:54:44 2013 UTC
@@ -1,14 +1,12 @@
# Copyright (c) 2008, Sandia National Laboratories

-# Include .config to get build options
-ifdef CONFIG
-include $O/$(CONFIG)
-endif
-
# Default to building in the current directory, unless
# overridden by the calling Makefile or on the command line.
O=$(shell pwd)

+# Include .config to get build options
+include $(O)/$(BASE)/../.config
+
# Default if srctree is not defined...
# do not truncate the absolute paths
ifndef srctree
Reply all
Reply to author
Forward
0 new messages