From minios-devel-bounces@lists.xenproject.org Tue Sep 01 08:07:33 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 01 Sep 2020 08:07:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kD1KE-00082p-9l; Tue, 01 Sep 2020 08:07:30 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gYvl=CK=gmail.com=cristianvijelie@srs-us1.protection.inumbo.net>)
 id 1kD1KD-00082k-7S
 for minios-devel@lists.xen.org; Tue, 01 Sep 2020 08:07:29 +0000
X-Inumbo-ID: 44bb47a3-b656-468e-97a0-3a7136e8b881
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 44bb47a3-b656-468e-97a0-3a7136e8b881;
 Tue, 01 Sep 2020 08:07:27 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id m6so442054wrn.0
 for <minios-devel@lists.xen.org>; Tue, 01 Sep 2020 01:07:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=l/RtoJloWPH+wMrlluBXYYGyaTvSAQdGQAwZpbcr7jU=;
 b=fgdq+pBb3HOQnAaIG7YNe/USjVC6n2xk2KcjRtMumtbWZdkI/Xf6Lg8XQfz8LGkfCh
 MEKPS5+zMcaoFZeUgT/k528FGTA9pJ6lCpx0D01qgJ8jabGZDwP/k5mMWYbDCu9Xd4wp
 xpc3eOMTG70TEwwGGAp73G9ofCpS7Cczz1ekKMbuNJOioNL54QToCXpZLgrBh2Q6Hyks
 4X9afw85AL7PCLSRhlfQ06CtnLj7bg9ukenXohGghI5nvvM2Re1o9xVlARWvBrE2rMxz
 WdzIHXr+99LHfVt4PlZXk5AmdqEW9d/st7hjzSR2gGvib070ERMEQ2I6nUro8s/KUgCr
 9ioA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=l/RtoJloWPH+wMrlluBXYYGyaTvSAQdGQAwZpbcr7jU=;
 b=Kbn1RgY5eOelYUV86a3M7AQPNqFkOP3n30Zv4KLoXhHSpuvyW8h+IK0PIazcXn8N5C
 h4BnRD+kfgIX46mlH9sw4Rb0tLjlROzSZbXVE6G3Ah1Ml+AsP3BVQ3jFQoaZfoZFvbx5
 G56OGsZavXyvcsm/g0OFBX+eFuqmr+m4A4aCHj+nPr6VzskPIXcQZ2I9pVtdbknvWxKa
 XgteAD/aHkvfAE56WA06hyKXYxSj6UPcwCNbnBKflemYdXbCH8sC5ucNXaModGlUgfJJ
 DO4rjqjOITVyj+ZaM9EoeyQGzDW7if4qZWW159xjtWlD4XwpEkqDrHw++HmUCgccJoGJ
 B/oA==
X-Gm-Message-State: AOAM531Fw+UQxdarH8DBrYCTIz6Baxsft0uFplfuZvIh28CI7kZTBAQq
 BiSWq5lfoQtyvDmN94UeMy6VN1GpvXeVaw==
X-Google-Smtp-Source: ABdhPJyvhPvHfsxiXQBZW+CbF5BeNXQLh6shkvBDsCuRlQyzhgj776vc+v/VMikyoEM9Z/weaMtVzA==
X-Received: by 2002:a5d:6291:: with SMTP id k17mr550740wru.130.1598947646514; 
 Tue, 01 Sep 2020 01:07:26 -0700 (PDT)
Received: from localhost.localdomain ([2a00:5dc0:ffff:0:f59c:14e1:f34a:a241])
 by smtp.gmail.com with ESMTPSA id
 v12sm988003wri.47.2020.09.01.01.07.25
 for <minios-devel@lists.xen.org>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 01 Sep 2020 01:07:25 -0700 (PDT)
From: cristianvijelie@gmail.com
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH] Made ukmpi and uklock interrupt-context-safe
Date: Tue,  1 Sep 2020 11:07:24 +0300
Message-Id: <20200901080724.10867-1-cristianvijelie@gmail.com>
X-Mailer: git-send-email 2.25.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

From: Cristian Vijelie <cristianvijelie@gmail.com>

For semaphore and mutex, the only change needed for now was to create some
aliases to some inlined functions, that can be called in an interupt context,
in 'uk/isr/mutex.h' and 'uk/isr/semaphore.h'.

For mbox, I moved the functions that can be called in an interupt context to
a separate sorce file, 'mbox_isr.c', and I also moved some static inlined
functions needed by both mbox and mbox_isr in the mbox.h header, along with
th definition of struct uk_mbox.

Signed-off-by: Cristian Vijelie <cristianvijelie@gmail.com>
---
 include/uk/isr/mbox.h       | 13 +++++++++
 include/uk/isr/mutex.h      |  8 ++++++
 include/uk/isr/semaphore.h  |  8 ++++++
 lib/ukmpi/Makefile.uk       |  1 +
 lib/ukmpi/include/uk/mbox.h | 54 ++++++++++++++++++++++++++++++++++++-
 lib/ukmpi/mbox.c            | 54 -------------------------------------
 lib/ukmpi/mbox_isr.c        | 39 +++++++++++++++++++++++++++
 7 files changed, 122 insertions(+), 55 deletions(-)
 create mode 100644 include/uk/isr/mbox.h
 create mode 100644 include/uk/isr/mutex.h
 create mode 100644 include/uk/isr/semaphore.h
 create mode 100644 lib/ukmpi/mbox_isr.c

diff --git a/include/uk/isr/mbox.h b/include/uk/isr/mbox.h
new file mode 100644
index 0000000..ef70939
--- /dev/null
+++ b/include/uk/isr/mbox.h
@@ -0,0 +1,13 @@
+#ifndef __MBOX_ISR_H__
+#define __MBOX_ISR_H__
+
+#include <uk/mbox.h>
+
+#if CONFIG_LIBUKMPI_MBOX
+
+int uk_mbox_post_try_isr(struct uk_mbox *m, void *msg);
+int uk_mbox_recv_try_isr(struct uk_mbox *m, void **msg);
+
+#endif /* CONFIG_LIBUKMPI_MBOX */
+
+#endif /* __MBOX_ISR_H__ */
\ No newline at end of file
diff --git a/include/uk/isr/mutex.h b/include/uk/isr/mutex.h
new file mode 100644
index 0000000..06d51f8
--- /dev/null
+++ b/include/uk/isr/mutex.h
@@ -0,0 +1,8 @@
+#ifndef __UK_ISR_MUTEX_H__
+#define __UK_ISR_MUTEX_H__
+
+#include <uk/mutex.h>
+
+#define uk_mutex_trylock_isr(x) uk_mutex_trylock(x)
+
+#endif /* __UK_ISR_MUTEX_H__ */
\ No newline at end of file
diff --git a/include/uk/isr/semaphore.h b/include/uk/isr/semaphore.h
new file mode 100644
index 0000000..b187f1f
--- /dev/null
+++ b/include/uk/isr/semaphore.h
@@ -0,0 +1,8 @@
+#ifndef __UK_ISR_SEMAPHORE_H__
+#define __UK_ISR_SEMAPHORE_H__
+
+#include <uk/semaphore.h>
+
+#define uk_semaphore_down_try_isr(x) uk_semaphore_down_try(x)
+
+#endif /* __UK_ISR_SEMAPHORE_H__ */
\ No newline at end of file
diff --git a/lib/ukmpi/Makefile.uk b/lib/ukmpi/Makefile.uk
index fc8a360..49df296 100644
--- a/lib/ukmpi/Makefile.uk
+++ b/lib/ukmpi/Makefile.uk
@@ -4,3 +4,4 @@ CINCLUDES-$(CONFIG_LIBUKMPI)   += -I$(LIBUKMPI_BASE)/include
 CXXINCLUDES-$(CONFIG_LIBUKMPI) += -I$(LIBUKMPI_BASE)/include
 
 LIBUKMPI_SRCS-$(CONFIG_LIBUKMPI_MBOX) += $(LIBUKMPI_BASE)/mbox.c
+LIBUKMPI_SRCS-$(CONFIG_LIBUKMPI_MBOX) += $(LIBUKMPI_BASE)/mbox_isr.c|isr
diff --git a/lib/ukmpi/include/uk/mbox.h b/lib/ukmpi/include/uk/mbox.h
index 19b1ecc..37146d6 100644
--- a/lib/ukmpi/include/uk/mbox.h
+++ b/lib/ukmpi/include/uk/mbox.h
@@ -47,7 +47,15 @@
 extern "C" {
 #endif /* __cplusplus */
 
-struct uk_mbox;
+struct uk_mbox {
+	size_t len;
+	struct uk_semaphore readsem;
+	long readpos;
+	struct uk_semaphore writesem;
+	long writepos;
+
+	void *msgs[];
+};
 
 struct uk_mbox *uk_mbox_create(struct uk_alloc *a, size_t size);
 void uk_mbox_free(struct uk_alloc *a, struct uk_mbox *m);
@@ -60,6 +68,50 @@ void uk_mbox_recv(struct uk_mbox *m, void **msg);
 int uk_mbox_recv_try(struct uk_mbox *m, void **msg);
 __nsec uk_mbox_recv_to(struct uk_mbox *m, void **msg, __nsec timeout);
 
+/* Posts the "msg" to the mailbox, internal version that actually does the
+ * post.
+ */
+static inline void _do_mbox_post(struct uk_mbox *m, void *msg)
+{
+	/* The caller got a semaphore token, so we are now allowed to increment
+	 * writer, but we still need to prevent concurrency between writers
+	 * (interrupt handler vs main)
+	 */
+	unsigned long irqf;
+
+	UK_ASSERT(m);
+
+	irqf = ukplat_lcpu_save_irqf();
+	m->msgs[m->writepos] = msg;
+	m->writepos = (m->writepos + 1) % m->len;
+	UK_ASSERT(m->readpos != m->writepos);
+	ukplat_lcpu_restore_irqf(irqf);
+	uk_pr_debug("Posted message %p to mailbox %p\n", msg, m);
+
+	uk_semaphore_up(&m->readsem);
+}
+
+/*
+ * Fetch a message from a mailbox. Internal version that actually does the
+ * fetch.
+ */
+static inline void *_do_mbox_recv(struct uk_mbox *m)
+{
+	unsigned long irqf;
+	void *ret;
+
+	uk_pr_debug("Receive message from mailbox %p\n", m);
+	irqf = ukplat_lcpu_save_irqf();
+	UK_ASSERT(m->readpos != m->writepos);
+	ret = m->msgs[m->readpos];
+	m->readpos = (m->readpos + 1) % m->len;
+	ukplat_lcpu_restore_irqf(irqf);
+
+	uk_semaphore_up(&m->writesem);
+
+	return ret;
+}
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/lib/ukmpi/mbox.c b/lib/ukmpi/mbox.c
index 149a667..b223ced 100644
--- a/lib/ukmpi/mbox.c
+++ b/lib/ukmpi/mbox.c
@@ -2,16 +2,6 @@
 #include <uk/assert.h>
 #include <uk/arch/limits.h>
 
-struct uk_mbox {
-	size_t len;
-	struct uk_semaphore readsem;
-	long readpos;
-	struct uk_semaphore writesem;
-	long writepos;
-
-	void *msgs[];
-};
-
 struct uk_mbox *uk_mbox_create(struct uk_alloc *a, size_t size)
 {
 	struct uk_mbox *m;
@@ -49,29 +39,6 @@ void uk_mbox_free(struct uk_alloc *a, struct uk_mbox *m)
 	uk_free(a, m);
 }
 
-/* Posts the "msg" to the mailbox, internal version that actually does the
- * post.
- */
-static inline void _do_mbox_post(struct uk_mbox *m, void *msg)
-{
-	/* The caller got a semaphore token, so we are now allowed to increment
-	 * writer, but we still need to prevent concurrency between writers
-	 * (interrupt handler vs main)
-	 */
-	unsigned long irqf;
-
-	UK_ASSERT(m);
-
-	irqf = ukplat_lcpu_save_irqf();
-	m->msgs[m->writepos] = msg;
-	m->writepos = (m->writepos + 1) % m->len;
-	UK_ASSERT(m->readpos != m->writepos);
-	ukplat_lcpu_restore_irqf(irqf);
-	uk_pr_debug("Posted message %p to mailbox %p\n", msg, m);
-
-	uk_semaphore_up(&m->readsem);
-}
-
 void uk_mbox_post(struct uk_mbox *m, void *msg)
 {
 	/* The caller got a semaphore token, so we are now allowed to increment
@@ -106,27 +73,6 @@ __nsec uk_mbox_post_to(struct uk_mbox *m, void *msg, __nsec timeout)
 	return ret;
 }
 
-/*
- * Fetch a message from a mailbox. Internal version that actually does the
- * fetch.
- */
-static inline void *_do_mbox_recv(struct uk_mbox *m)
-{
-	unsigned long irqf;
-	void *ret;
-
-	uk_pr_debug("Receive message from mailbox %p\n", m);
-	irqf = ukplat_lcpu_save_irqf();
-	UK_ASSERT(m->readpos != m->writepos);
-	ret = m->msgs[m->readpos];
-	m->readpos = (m->readpos + 1) % m->len;
-	ukplat_lcpu_restore_irqf(irqf);
-
-	uk_semaphore_up(&m->writesem);
-
-	return ret;
-}
-
 /* Blocks the thread until a message arrives in the mailbox.
  * The `*msg` argument will point to the received message.
  * If the `msg` parameter was set to NULL, the received message is dropped.
diff --git a/lib/ukmpi/mbox_isr.c b/lib/ukmpi/mbox_isr.c
new file mode 100644
index 0000000..43cd516
--- /dev/null
+++ b/lib/ukmpi/mbox_isr.c
@@ -0,0 +1,39 @@
+#include <uk/isr/mbox.h>
+#include <uk/assert.h>
+
+int uk_mbox_post_try_isr(struct uk_mbox *m, void *msg)
+{
+	UK_ASSERT(m);
+
+	if (!uk_semaphore_down_try(&m->writesem))
+		return -ENOBUFS;
+	_do_mbox_post(m, msg);
+	return 0;
+}
+
+/* This is similar to uk_mbox_fetch, however if a message is not
+ * present in the mailbox, it immediately returns with the code
+ * SYS_MBOX_EMPTY. On success 0 is returned.
+ *
+ * To allow for efficient implementations, this can be defined as a
+ * function-like macro in sys_arch.h instead of a normal function. For
+ * example, a naive implementation could be:
+ *   #define uk_mbox_tryfetch(mbox,msg) \
+ *     uk_mbox_fetch(mbox,msg,1)
+ * although this would introduce unnecessary delays.
+ */
+
+int uk_mbox_recv_try_isr(struct uk_mbox *m, void **msg)
+{
+	void *rmsg;
+
+	UK_ASSERT(m);
+
+	if (!uk_semaphore_down_try(&m->readsem))
+		return -ENOMSG;
+
+	rmsg =  _do_mbox_recv(m);
+	if (msg)
+		*msg = rmsg;
+	return 0;
+}
\ No newline at end of file
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Thu Sep 03 16:25:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 03 Sep 2020 16:25:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kDs38-00058V-4T; Thu, 03 Sep 2020 16:25:22 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=bOgh=CM=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kDs37-00058P-41
 for minios-devel@lists.xen.org; Thu, 03 Sep 2020 16:25:21 +0000
X-Inumbo-ID: c7776505-c055-40ea-9bc1-95fc2ab6e72b
Received: from mx.upb.ro (unknown [141.85.13.250])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c7776505-c055-40ea-9bc1-95fc2ab6e72b;
 Thu, 03 Sep 2020 16:25:18 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 3EEADB5617CC;
 Thu,  3 Sep 2020 19:25:17 +0300 (EEST)
Received: from mx.upb.ro ([127.0.0.1])
 by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id jqN2UdliXYRV; Thu,  3 Sep 2020 19:25:15 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 6667BB561CBF;
 Thu,  3 Sep 2020 19:25:15 +0300 (EEST)
X-Virus-Scanned: amavisd-new at upb.ro
Received: from mx.upb.ro ([127.0.0.1])
 by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id RwUzegPAwaLN; Thu,  3 Sep 2020 19:25:15 +0300 (EEST)
Received: from localhost.localdomain (5-12-253-103.residential.rdsnet.ro
 [5.12.253.103]) by mx.upb.ro (Postfix) with ESMTPSA id CF506B5617CC;
 Thu,  3 Sep 2020 19:25:14 +0300 (EEST)
From: Costin Lupu <costin.lupu@cs.pub.ro>
To: minios-devel@lists.xen.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	jbeulich@suse.com
Subject: [PATCH] mini-os: netfront: Fix netfront init when no netmask or
 gateway are provided
Date: Thu,  3 Sep 2020 19:25:11 +0300
Message-Id: <20200903162511.23581-1-costin.lupu@cs.pub.ro>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Commit 1b8ed31f introduced support for reading netmask and gateway values
from Xenstore. However it did not take care of the initial scenario when
these values are not provided and that is what this patch tries to fix.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
---
 netfront.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/netfront.c b/netfront.c
index 205484b..1a30945 100644
--- a/netfront.c
+++ b/netfront.c
@@ -376,9 +376,9 @@ out:
 	}
     if (ip)
         *ip =3D strdup(ldev->ip);
-    if (mask)
+    if (mask && ldev->mask)
         *mask =3D strdup(ldev->mask);
-    if (gw)
+    if (gw && ldev->gw)
         *gw =3D strdup(ldev->gw);
=20
 err:
--=20
2.20.1



From minios-devel-bounces@lists.xenproject.org Thu Sep 03 16:32:16 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 03 Sep 2020 16:32:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kDs9l-0006Bk-1r; Thu, 03 Sep 2020 16:32:13 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=nrSa=CM=ens-lyon.org=samuel.thibault@srs-us1.protection.inumbo.net>)
 id 1kDs9k-0006Bf-8a
 for minios-devel@lists.xen.org; Thu, 03 Sep 2020 16:32:12 +0000
X-Inumbo-ID: e52373d5-b65e-4134-a3c8-39f80501edb4
Received: from hera.aquilenet.fr (unknown [2a0c:e300::1])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e52373d5-b65e-4134-a3c8-39f80501edb4;
 Thu, 03 Sep 2020 16:32:10 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id AB383B898;
 Thu,  3 Sep 2020 18:32:09 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id ma5_iWzElzGa; Thu,  3 Sep 2020 18:32:09 +0200 (CEST)
Received: from function.home (unknown
 [IPv6:2a01:cb19:956:1b00:9eb6:d0ff:fe88:c3c7])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id F2219B75D;
 Thu,  3 Sep 2020 18:32:08 +0200 (CEST)
Received: from samy by function.home with local (Exim 4.94)
 (envelope-from <samuel.thibault@ens-lyon.org>)
 id 1kDs9f-0001vq-QS; Thu, 03 Sep 2020 18:32:07 +0200
Date: Thu, 3 Sep 2020 18:32:07 +0200
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Costin Lupu <costin.lupu@cs.pub.ro>
Cc: minios-devel@lists.xen.org, wl@xen.org, jbeulich@suse.com
Subject: Re: [PATCH] mini-os: netfront: Fix netfront init when no netmask or
 gateway are provided
Message-ID: <20200903163207.wsyurx4xxstrnl7m@function>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 Costin Lupu <costin.lupu@cs.pub.ro>, minios-devel@lists.xen.org,
 wl@xen.org, jbeulich@suse.com
References: <20200903162511.23581-1-costin.lupu@cs.pub.ro>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20200903162511.23581-1-costin.lupu@cs.pub.ro>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Costin Lupu, le jeu. 03 sept. 2020 19:25:11 +0300, a ecrit:
> Commit 1b8ed31f introduced support for reading netmask and gateway values
> from Xenstore. However it did not take care of the initial scenario when
> these values are not provided and that is what this patch tries to fix.
> 
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Thanks!

> ---
>  netfront.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/netfront.c b/netfront.c
> index 205484b..1a30945 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -376,9 +376,9 @@ out:
>  	}
>      if (ip)
>          *ip = strdup(ldev->ip);
> -    if (mask)
> +    if (mask && ldev->mask)
>          *mask = strdup(ldev->mask);
> -    if (gw)
> +    if (gw && ldev->gw)
>          *gw = strdup(ldev->gw);
>  
>  err:
> -- 
> 2.20.1
> 


From minios-devel-bounces@lists.xenproject.org Fri Sep 04 06:45:00 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 04 Sep 2020 06:45:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kE5Sz-00023d-Lv; Fri, 04 Sep 2020 06:44:57 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=saQb=CN=suse.com=jbeulich@srs-us1.protection.inumbo.net>)
 id 1kE5Sy-00023Y-OJ
 for minios-devel@lists.xen.org; Fri, 04 Sep 2020 06:44:56 +0000
X-Inumbo-ID: 8d9270c1-3312-4492-871a-694db3125079
Received: from mx2.suse.de (unknown [195.135.220.15])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 8d9270c1-3312-4492-871a-694db3125079;
 Fri, 04 Sep 2020 06:44:55 +0000 (UTC)
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay2.suse.de (unknown [195.135.221.27])
 by mx2.suse.de (Postfix) with ESMTP id 06B16AC2F;
 Fri,  4 Sep 2020 06:44:54 +0000 (UTC)
Subject: Re: [PATCH] mini-os: netfront: Fix netfront init when no netmask or
 gateway are provided
To: Costin Lupu <costin.lupu@cs.pub.ro>
Cc: minios-devel@lists.xen.org, samuel.thibault@ens-lyon.org, wl@xen.org
References: <20200903162511.23581-1-costin.lupu@cs.pub.ro>
From: Jan Beulich <jbeulich@suse.com>
Message-ID: <e22e2b27-e6f4-8657-7ca1-1e2c85a3d365@suse.com>
Date: Fri, 4 Sep 2020 08:45:04 +0200
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101
 Thunderbird/68.12.0
MIME-Version: 1.0
In-Reply-To: <20200903162511.23581-1-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

On 03.09.2020 18:25, Costin Lupu wrote:
> Commit 1b8ed31f introduced support for reading netmask and gateway values
> from Xenstore. However it did not take care of the initial scenario when
> these values are not provided and that is what this patch tries to fix.
> 

Once again
Reported-by: Jan Beulich <jbeulich@suse.com>
or some such. You've made me (again) analyze breakage (still assuming
it is as suspected, since as said I had no data to actually prove my
suspicion, and it's not clear whether you've confirmed it really is,
or whether you've simply made the change "just in case"), so in one
way or another I'd like this to be expressed. I'm sorry for being a
little angry here, but after the first breakage I think you should
really have looked out for everything else going smoothly.

> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> ---
>  netfront.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/netfront.c b/netfront.c
> index 205484b..1a30945 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -376,9 +376,9 @@ out:
>  	}
>      if (ip)
>          *ip = strdup(ldev->ip);
> -    if (mask)
> +    if (mask && ldev->mask)
>          *mask = strdup(ldev->mask);
> -    if (gw)
> +    if (gw && ldev->gw)
>          *gw = strdup(ldev->gw);

So this introduces a (not written down afaict) requirement for the
caller to pre-initialize *mask and *gw, if passing non-NULL into
here. I'd have expected

    if (ip)
        *ip = strdup(ldev->ip);
    if (mask)
        *mask = ldev->mask ? strdup(ldev->mask) : NULL;
    if (gw)
        *gw = ldev->gw ? strdup(ldev->gw) : NULL;

(or something substantially similar) instead. Sorry for being picky.

As an aside I'm also wondering how in your new model one would
express address and gateway with the caller passing NULL just
for mask. Furthermore I think the conventional n.n.n.n/<width>
way of expressing a mask would also be useful to be recognized.

Jan


From minios-devel-bounces@lists.xenproject.org Fri Sep 04 10:40:40 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 04 Sep 2020 10:40:40 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kE993-0003DZ-HK; Fri, 04 Sep 2020 10:40:37 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ezOh=CN=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kE992-0003DU-CR
 for minios-devel@lists.xen.org; Fri, 04 Sep 2020 10:40:36 +0000
X-Inumbo-ID: 1a3760f5-851a-446b-9d68-c2112abe5bf5
Received: from mx.upb.ro (unknown [141.85.13.230])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 1a3760f5-851a-446b-9d68-c2112abe5bf5;
 Fri, 04 Sep 2020 10:40:34 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 58C5BB561EA0;
 Fri,  4 Sep 2020 13:40:33 +0300 (EEST)
Received: from mx.upb.ro ([127.0.0.1])
 by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id GEOXr6td_xgC; Fri,  4 Sep 2020 13:40:31 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 3D630B561F08;
 Fri,  4 Sep 2020 13:40:31 +0300 (EEST)
X-Virus-Scanned: amavisd-new at upb.ro
Received: from mx.upb.ro ([127.0.0.1])
 by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id ODriVx-0z5mM; Fri,  4 Sep 2020 13:40:31 +0300 (EEST)
Received: from localhost.localdomain (5-12-253-103.residential.rdsnet.ro
 [5.12.253.103]) by mx.upb.ro (Postfix) with ESMTPSA id C3BD9B561EA0;
 Fri,  4 Sep 2020 13:40:30 +0300 (EEST)
From: Costin Lupu <costin.lupu@cs.pub.ro>
To: minios-devel@lists.xen.org
Cc: samuel.thibault@ens-lyon.org,
	wl@xen.org,
	jbeulich@suse.com
Subject: [PATCH v2] mini-os: netfront: Fix parsing of IP value provided by
 Xenstore
Date: Fri,  4 Sep 2020 13:40:23 +0300
Message-Id: <20200904104023.22313-1-costin.lupu@cs.pub.ro>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch fixes the following issues:
- commit 1b8ed31f introduced support for reading netmask and gateway valu=
es
  from Xenstore. However it did not take care of the initial scenario whe=
n
  these values are not provided.
- gateway is not set when passing mask=3DNULL to _init_netfront()
- mini-os crashes when IP is not provided at all in the xl config file.

The current implementation supports only dot-decimal representations of I=
P,
netmask and gateway.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
---
 netfront.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/netfront.c b/netfront.c
index 205484b..d066bd9 100644
--- a/netfront.c
+++ b/netfront.c
@@ -375,11 +375,11 @@ out:
         rawmac[5] =3D ldev->rawmac[5];
 	}
     if (ip)
-        *ip =3D strdup(ldev->ip);
+        *ip =3D ldev->ip ? strdup(ldev->ip) : NULL;
     if (mask)
-        *mask =3D strdup(ldev->mask);
+        *mask =3D ldev->mask ? strdup(ldev->mask) : NULL;
     if (gw)
-        *gw =3D strdup(ldev->gw);
+        *gw =3D ldev->gw ? strdup(ldev->gw) : NULL;
=20
 err:
     return dev;
@@ -524,23 +524,23 @@ done:
         }
=20
         if (ip) {
-            char *p;
-
             snprintf(path, sizeof(path), "%s/ip", dev->backend);
             xenbus_read(XBT_NIL, path, ip);
=20
-            if (mask) {
+            if (*ip) {
+                char *p;
+
                 p =3D strchr(*ip, ' ');
                 if (p) {
                     *p++ =3D '\0';
-                    *mask =3D p;
+                    if (mask)
+                        *mask =3D p;
=20
-                    if (gw) {
-                        p =3D strchr(p, ' ');
-                        if (p) {
-                            *p++ =3D '\0';
+                    p =3D strchr(p, ' ');
+                    if (p) {
+                        *p++ =3D '\0';
+                        if (gw)
                             *gw =3D p;
-                        }
                     }
                 }
             }
--=20
2.20.1



From minios-devel-bounces@lists.xenproject.org Sun Sep 06 22:11:03 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 06 Sep 2020 22:11:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kF2sG-0004bY-VQ; Sun, 06 Sep 2020 22:11:00 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=w/PO=CP=ens-lyon.org=samuel.thibault@srs-us1.protection.inumbo.net>)
 id 1kF2sF-0004bT-Qg
 for minios-devel@lists.xen.org; Sun, 06 Sep 2020 22:10:59 +0000
X-Inumbo-ID: 74aeb17d-4b5f-462f-9bea-6b1e688978e3
Received: from hera.aquilenet.fr (unknown [185.233.100.1])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 74aeb17d-4b5f-462f-9bea-6b1e688978e3;
 Sun, 06 Sep 2020 22:10:58 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 102D4DAB;
 Mon,  7 Sep 2020 00:10:57 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id T4EHMCVEUD8P; Mon,  7 Sep 2020 00:10:56 +0200 (CEST)
Received: from function (lfbn-bor-1-797-11.w86-234.abo.wanadoo.fr
 [86.234.239.11])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 1F42C169;
 Mon,  7 Sep 2020 00:10:56 +0200 (CEST)
Received: from samy by function with local (Exim 4.94)
 (envelope-from <samuel.thibault@ens-lyon.org>)
 id 1kF2sB-006CO7-04; Mon, 07 Sep 2020 00:10:55 +0200
Date: Mon, 7 Sep 2020 00:10:54 +0200
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Costin Lupu <costin.lupu@cs.pub.ro>
Cc: minios-devel@lists.xen.org, wl@xen.org, jbeulich@suse.com
Subject: Re: [PATCH v2] mini-os: netfront: Fix parsing of IP value provided
 by Xenstore
Message-ID: <20200906221054.cq6tonp7avbsiz6h@function>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 Costin Lupu <costin.lupu@cs.pub.ro>, minios-devel@lists.xen.org,
 wl@xen.org, jbeulich@suse.com
References: <20200904104023.22313-1-costin.lupu@cs.pub.ro>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20200904104023.22313-1-costin.lupu@cs.pub.ro>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Costin Lupu, le ven. 04 sept. 2020 13:40:23 +0300, a ecrit:
> This patch fixes the following issues:
> - commit 1b8ed31f introduced support for reading netmask and gateway values
>   from Xenstore. However it did not take care of the initial scenario when
>   these values are not provided.
> - gateway is not set when passing mask=NULL to _init_netfront()
> - mini-os crashes when IP is not provided at all in the xl config file.
> 
> The current implementation supports only dot-decimal representations of IP,
> netmask and gateway.
> 
> Reported-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  netfront.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/netfront.c b/netfront.c
> index 205484b..d066bd9 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -375,11 +375,11 @@ out:
>          rawmac[5] = ldev->rawmac[5];
>  	}
>      if (ip)
> -        *ip = strdup(ldev->ip);
> +        *ip = ldev->ip ? strdup(ldev->ip) : NULL;
>      if (mask)
> -        *mask = strdup(ldev->mask);
> +        *mask = ldev->mask ? strdup(ldev->mask) : NULL;
>      if (gw)
> -        *gw = strdup(ldev->gw);
> +        *gw = ldev->gw ? strdup(ldev->gw) : NULL;
>  
>  err:
>      return dev;
> @@ -524,23 +524,23 @@ done:
>          }
>  
>          if (ip) {
> -            char *p;
> -
>              snprintf(path, sizeof(path), "%s/ip", dev->backend);
>              xenbus_read(XBT_NIL, path, ip);
>  
> -            if (mask) {
> +            if (*ip) {
> +                char *p;
> +
>                  p = strchr(*ip, ' ');
>                  if (p) {
>                      *p++ = '\0';
> -                    *mask = p;
> +                    if (mask)
> +                        *mask = p;
>  
> -                    if (gw) {
> -                        p = strchr(p, ' ');
> -                        if (p) {
> -                            *p++ = '\0';
> +                    p = strchr(p, ' ');
> +                    if (p) {
> +                        *p++ = '\0';
> +                        if (gw)
>                              *gw = p;
> -                        }
>                      }
>                  }
>              }
> -- 
> 2.20.1


From minios-devel-bounces@lists.xenproject.org Mon Sep 07 14:54:29 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 07 Sep 2020 14:54:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kFIXK-0003RX-2j; Mon, 07 Sep 2020 14:54:26 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=QCjB=CM=gmail.com=gabi.mocanu98@srs-us1.protection.inumbo.net>)
 id 1kDuRg-0003Ak-P8
 for minios-devel@lists.xen.org; Thu, 03 Sep 2020 18:58:52 +0000
X-Inumbo-ID: d4888022-5ea2-4521-ae5a-ccdf294d7420
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d4888022-5ea2-4521-ae5a-ccdf294d7420;
 Thu, 03 Sep 2020 18:58:46 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id z1so4377703wrt.3
 for <minios-devel@lists.xen.org>; Thu, 03 Sep 2020 11:58:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references;
 bh=11Z5LcNkADrikAX+lTGayauvLsHMyBqvEvkF3n5xu/g=;
 b=O7h2bsbKh1SjuhgcUA8ph41jzsrwB5kYEBrkRBwM26MA/ScrtkK6qkj3GvT8oAnOVX
 SpmB3M704ybinzTWsnMVcxqrc6s7sdqCMHeXva3UXKhvCnpr2R9LQU95+GCL8yrq4k8g
 07OFxUIUHLgFo5OzjRHgqALEbLuAEoME9VgR5mzvBM+HjKFUu1QWKM31OVz06J2BPP81
 BgWk1QneRhMXxiYovm/jMfa26awPJhTvBrLbV6MQh8xziVvwMBbi4Y0mlSDiYKT8GDCv
 IHBTHxyFQcphbzXHrBXBVdOgCvrNdXHh6JtYTvCXGiTOUuE0wHmE1lAYAeIlA65xkBV1
 784A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references;
 bh=11Z5LcNkADrikAX+lTGayauvLsHMyBqvEvkF3n5xu/g=;
 b=oS/SPDiG7RnaZ+Cg17ZfjL8hIPzT5y0vUYqoDr629B3NvXkyWlSGHrn02zI0mdM10O
 T5gOu89aaTXeo4+yL5aFWkl3LHkOa2Enfyxf5bk6lei9DDlMz5s3iUqsXowDGlnScRLe
 HploBXf4qFv4ss1TO/MpKqiwyP4pkSgyrHlgAlJoPtmVW6BtW1xHjdX2I8CXISft+3/1
 9C763XrMV+16C2JybcTPNpMBKW2r3I4xlp0xYf7KWYBLRuBJER02rEj013S4a47eVUXH
 CZZ1aEmNTG5+ymkOPEZ6R86gjEXyQqJDKLAJRAoHbTp9sTrmg/be9pzjPXcsuf4p7OGh
 62Bw==
X-Gm-Message-State: AOAM530Sus/IbBWz75GzBVCyOwb8j3ZvsTvqx3tupQza+bvSYbilvIpl
 5Z9zUVCy4Ii5ssMTNKc+x5EuS49yDb72lgNF
X-Google-Smtp-Source: ABdhPJy0MyVre6cZjJJQqKHBr+BbQZgfU6h9HvRPqChVBqT35x915FpwjkyznSnwBPO0bqCr1smB6g==
X-Received: by 2002:adf:dd44:: with SMTP id u4mr3745534wrm.22.1599159525688;
 Thu, 03 Sep 2020 11:58:45 -0700 (PDT)
Received: from localhost.localdomain ([188.173.197.103])
 by smtp.gmail.com with ESMTPSA id y6sm6038198wrt.80.2020.09.03.11.58.44
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 03 Sep 2020 11:58:45 -0700 (PDT)
From: gabrielmocanu <gabi.mocanu98@gmail.com>
To: minios-devel@lists.xen.org
Cc: Simon Kuenzer <simon.kuenzer@neclab.eu>,
 gabrielmocanu <gabi.mocanu98@gmail.com>
Subject: [PATCH 2/4] Create another header file mode.h and define macro and
 k_mode_t here. Change close to sys_close and change some error messages.
Date: Thu,  3 Sep 2020 21:58:40 +0300
Message-Id: <20200903185842.19073-2-gabi.mocanu98@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200903185842.19073-1-gabi.mocanu98@gmail.com>
References: <20200903185842.19073-1-gabi.mocanu98@gmail.com>
X-Mailman-Approved-At: Mon, 07 Sep 2020 14:54:24 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: gabrielmocanu <gabi.mocanu98@gmail.com>
---
 plat/linuxu/include/linuxu/mode.h |  8 +++++
 plat/linuxu/memory.c              | 49 ++++++++++++++-----------------
 2 files changed, 30 insertions(+), 27 deletions(-)
 create mode 100644 plat/linuxu/include/linuxu/mode.h

diff --git a/plat/linuxu/include/linuxu/mode.h b/plat/linuxu/include/linuxu/mode.h
new file mode 100644
index 0000000..ac2f40e
--- /dev/null
+++ b/plat/linuxu/include/linuxu/mode.h
@@ -0,0 +1,8 @@
+#ifndef __LINUXU_MODE_H__
+#define __LINUXU_MODE_H__
+
+#define K_O_RDONLY 0x0000
+
+typedef unsigned k_mode_t;
+
+#endif /* __LINUXU_MODE_H__ */
diff --git a/plat/linuxu/memory.c b/plat/linuxu/memory.c
index 842debe..7c67d53 100644
--- a/plat/linuxu/memory.c
+++ b/plat/linuxu/memory.c
@@ -42,18 +42,14 @@
 #include <uk/plat/memory.h>
 #include <uk/libparam.h>
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
 
 #define MB2B (1024 * 1024)
 
 static __u32 heap_size = CONFIG_LINUXU_DEFAULT_HEAPMB;
 UK_LIB_PARAM(heap_size, __u32);
 
-static const char *initrd_file = NULL;
-UK_LIB_PARAM_STR(initrd_file);
+static const char *initrd = NULL;
+UK_LIB_PARAM_STR(initrd);
 
 static int __linuxu_plat_heap_init(void)
 {
@@ -71,7 +67,7 @@ static int __linuxu_plat_heap_init(void)
 		if (PTRISERR(pret)) {
 			rc = PTR2ERR(pret);
 			uk_pr_err("Failed to allocate memory for heap: %d\n",
-				  rc);
+				   rc);
 		} else
 			_liblinuxuplat_opts.heap.base = pret;
 	}
@@ -83,16 +79,16 @@ static int __linuxu_plat_initrd_init(void)
 {
 	void *pret;
 	int rc = 0;
-	struct stat file_info;
+	struct k_stat file_info;
 
-	if (initrd_file == NULL) {
+	if (initrd == NULL) {
 		uk_pr_debug("No initrd present.\n");
 	} else {
-		uk_pr_debug("Mapping in initrd file: %s\n", initrd_file);
-		int initrd_fd = sys_open(initrd_file, O_RDONLY, 0);
+		uk_pr_debug("Mapping in initrd file: %s\n", initrd);
+		int initrd_fd = sys_open(initrd, K_O_RDONLY, 0);
 
 		if (initrd_fd < 0) {
-			uk_pr_err("Failed to open intrd file");
+			uk_pr_crit("Failed to open %s for initrd\n", initrd);
 			return -1;
 		}
 
@@ -100,8 +96,8 @@ static int __linuxu_plat_initrd_init(void)
 		 * Find initrd file size
 		 */
 		if (sys_fstat(initrd_fd, &file_info) < 0) {
-			uk_pr_err("sys_fstat failed for initrd file");
-			close(initrd_fd);
+			uk_pr_crit("sys_fstat failed for initrd file\n");
+			sys_close(initrd_fd);
 			return -1;
 		}
 		_liblinuxuplat_opts.initrd.len = file_info.st_size;
@@ -109,22 +105,21 @@ static int __linuxu_plat_initrd_init(void)
 		 * Allocate initrd memory
 		 */
 		if (_liblinuxuplat_opts.initrd.len > 0) {
-			pret = sys_mmap((void *)_liblinuxuplat_opts.heap.len,
+			pret = sys_mmap(NULL,
 					_liblinuxuplat_opts.initrd.len,
 					PROT_READ | PROT_WRITE | PROT_EXEC,
 					MAP_PRIVATE, initrd_fd, 0);
 			if (PTRISERR(pret)) {
 				rc = PTR2ERR(pret);
-				uk_pr_err("Failed to allocate memory for initrd: %d\n",
-					  rc);
-				close(initrd_fd);
+				uk_pr_crit("Failed to memory-map initrd: %d\n", rc);
+				sys_close(initrd_fd);
 				return -1;
 			}
 			_liblinuxuplat_opts.initrd.base = pret;
 		} else {
-			uk_pr_err("Empty initrd file given.\n");
-			close(initrd_fd);
-			return -1;
+			uk_pr_info("Ignoring empty initrd file.\n");
+			sys_close(initrd_fd);
+			return 0;
 		}
 	}
 	return rc;
@@ -160,11 +155,11 @@ int ukplat_memregion_get(int i, struct ukplat_memregion_desc *m)
 	UK_ASSERT(m);
 
 	if (i == 0 && _liblinuxuplat_opts.heap.base) {
-		m->base = _liblinuxuplat_opts.heap.base;
-		m->len = _liblinuxuplat_opts.heap.len;
+		m->base  = _liblinuxuplat_opts.heap.base;
+		m->len   = _liblinuxuplat_opts.heap.len;
 		m->flags = UKPLAT_MEMRF_ALLOCATABLE;
 #if CONFIG_UKPLAT_MEMRNAME
-		m->name = "heap";
+		m->name  = "heap";
 #endif
 		ret = 0;
 	} else if ((i == 0 && !_liblinuxuplat_opts.heap.base
@@ -180,11 +175,11 @@ int ukplat_memregion_get(int i, struct ukplat_memregion_desc *m)
 		ret = 0;
 	} else {
 		/* invalid memory region index or no heap allocated */
-		m->base = __NULL;
-		m->len = 0;
+		m->base  = __NULL;
+		m->len   = 0;
 		m->flags = 0x0;
 #if CONFIG_UKPLAT_MEMRNAME
-		m->name = __NULL;
+		m->name  = __NULL;
 #endif
 		ret = -1;
 	}
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 07 14:54:29 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 07 Sep 2020 14:54:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kFIXK-0003Rh-5q; Mon, 07 Sep 2020 14:54:26 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=QCjB=CM=gmail.com=gabi.mocanu98@srs-us1.protection.inumbo.net>)
 id 1kDuRq-0003Ak-PT
 for minios-devel@lists.xen.org; Thu, 03 Sep 2020 18:59:02 +0000
X-Inumbo-ID: 51836e44-17c4-4549-9b1e-2282be14ad90
Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 51836e44-17c4-4549-9b1e-2282be14ad90;
 Thu, 03 Sep 2020 18:58:48 +0000 (UTC)
Received: by mail-wm1-x342.google.com with SMTP id b79so3897548wmb.4
 for <minios-devel@lists.xen.org>; Thu, 03 Sep 2020 11:58:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references;
 bh=dki7kwIVbvtu+rUEgrTXD+KI4Q6KehKs+YEeVAtjlrg=;
 b=Ovz9b4GX81+T3HaeGdB7tW/TcOYyOGxhrhrXM9wxjxRii64eQqb+C3seTmlM9F0dlI
 XUEm7U6TSnLeD6tffgSil1dmEgoHF8Bcn/pyyefZ4DpeIRbVYUtDcaL377f7dhks5cDw
 7Rvt+Q18Auch67KPrabb0QXSs4oCNuNtSklpJi9VC/Nla0mHlVZqIVNeMA5O+2Ek9/Gd
 A5FP2g9USXtyvbcnvO4k34KJAkdnrrxLvwU4zgV5E3qXyWr506vQ94k0bUx0EYXnVNO7
 Jb273sOWnOwMTXQ+VT/EHpGgSG3CG75Xe66XHEniu10iRxTlThJAVWHiePUuw3J6d+aM
 X4EA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references;
 bh=dki7kwIVbvtu+rUEgrTXD+KI4Q6KehKs+YEeVAtjlrg=;
 b=UUIeI0lIER+iQ8u+g6oT6Mj7Un9Z76BH/N4Zq6KRkbRTtkdnNwBh9Ed6hazpn7LlQ7
 RxhPFkEaXqMblfJ9aMJRO1N4DMFlvV/32vZLo+y9MK0RlvuGgPK4GjXT/TPEwZ134+CK
 3uuCjKQITAoWhHHplWHK5lM7JgeYAOCiYlqii/KBfVkoMJdnf6OdlQDGcLqOuFfeiPJE
 Wg271OfHCVAJEjDy8TzfuMmiSEKqXIRIDE3cR4bJ96XIGnn8JU50R9ArUxNWXOt0B+qA
 W6YsdUiLL84ehDC9kfo8l2p9yqfXygF6xBbNCgq5yh4aTSKnam865dibSG5l2x8gacuc
 v9vQ==
X-Gm-Message-State: AOAM533V3Yc7MnsD10iaF0qrm4S9A4dh9cezCI71Oxz2NMt1BiZrJErm
 MSAuRxV2bsTvgiu5NBRqLyyYVdd13PUK1gnF
X-Google-Smtp-Source: ABdhPJyfZ75pgZ/v9LruI6cvivsfsQZeiKvBRltkMt0/HdiVUPcmkLHULiPNEnFON3NZlk2Jn+Pg+A==
X-Received: by 2002:a1c:a506:: with SMTP id o6mr3820331wme.3.1599159527727;
 Thu, 03 Sep 2020 11:58:47 -0700 (PDT)
Received: from localhost.localdomain ([188.173.197.103])
 by smtp.gmail.com with ESMTPSA id y6sm6038198wrt.80.2020.09.03.11.58.46
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 03 Sep 2020 11:58:47 -0700 (PDT)
From: gabrielmocanu <gabi.mocanu98@gmail.com>
To: minios-devel@lists.xen.org
Cc: Simon Kuenzer <simon.kuenzer@neclab.eu>,
 gabrielmocanu <gabi.mocanu98@gmail.com>
Subject: [PATCH 4/4] Change if-else-endif block and modify Config.uk to
 autoselect RamFS and ukcpio library
Date: Thu,  3 Sep 2020 21:58:42 +0300
Message-Id: <20200903185842.19073-4-gabi.mocanu98@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200903185842.19073-1-gabi.mocanu98@gmail.com>
References: <20200903185842.19073-1-gabi.mocanu98@gmail.com>
X-Mailman-Approved-At: Mon, 07 Sep 2020 14:54:24 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: gabrielmocanu <gabi.mocanu98@gmail.com>
---
 lib/Makefile.uk       |  2 +-
 lib/vfscore/Config.uk | 17 +++++++++-------
 lib/vfscore/rootfs.c  | 45 ++++++++++++++++++++++---------------------
 3 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/lib/Makefile.uk b/lib/Makefile.uk
index 1503e73..28c3d78 100644
--- a/lib/Makefile.uk
+++ b/lib/Makefile.uk
@@ -20,7 +20,7 @@ $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/fdt))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/syscall_shim))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/vfscore))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ramfs))
-$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/cpio))
+$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukcpio))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/devfs))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/9pfs))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uklock))
diff --git a/lib/vfscore/Config.uk b/lib/vfscore/Config.uk
index ef969bf..9938b12 100644
--- a/lib/vfscore/Config.uk
+++ b/lib/vfscore/Config.uk
@@ -9,9 +9,6 @@ config LIBVFSCORE
 if LIBVFSCORE
 menu "vfscore: Configuration"
 
-config LIBCPIO
-    bool "cpio: general cpio archive extraction"
-    default n
 
 config LIBINITRAMFS
     bool "initramfs: extract the given cpio file to /"
@@ -50,6 +47,11 @@ if LIBVFSCORE_AUTOMOUNT_ROOTFS
 		select LIBUK9P
 		select LIB9PFS
 
+    config LIBVFSCORE_ROOTFS_INITRD
+    bool "InitRD"
+    select LIBRAMFS
+    select LIBUKCPIO
+
 		config LIBVFSCORE_ROOTFS_CUSTOM
 		bool "Custom argument"
 		help
@@ -73,13 +75,14 @@ if LIBVFSCORE_AUTOMOUNT_ROOTFS
 	string
 	default "ramfs" if LIBVFSCORE_ROOTFS_RAMFS
 	default "9pfs" if LIBVFSCORE_ROOTFS_9PFS
-	default LIBVFSCORE_ROOTFS_CUSTOM_ARG if LIBVFSCORE_ROOTFS_CUSTOM
+	default "initrd" if LIBVFSCORE_ROOTFS_INITRD
+  default LIBVFSCORE_ROOTFS_CUSTOM_ARG if LIBVFSCORE_ROOTFS_CUSTOM
 	default ""
 
 	# The root device option is hidden for RamFS and 9PFS
 	config LIBVFSCORE_ROOTDEV
 	string "Default root device"
-	depends on !LIBVFSCORE_ROOTFS_RAMFS
+	depends on !LIBVFSCORE_ROOTFS_RAMFS && !LIBVFSCORE_ROOTFS_INITRD
 	default "rootfs" if LIBVFSCORE_ROOTFS_9PFS
 	default ""
 	help
@@ -90,7 +93,7 @@ if LIBVFSCORE_AUTOMOUNT_ROOTFS
 	# The root flags is hidden for RamFS
 	config LIBVFSCORE_ROOTFLAGS
 	hex "Default root mount flags"
-	depends on !LIBVFSCORE_ROOTFS_RAMFS
+	depends on !LIBVFSCORE_ROOTFS_RAMFS && !LIBVFSCORE_ROOTFS_INITRD
 	default 0x0
 	help
 		Mount flags.
@@ -98,7 +101,7 @@ if LIBVFSCORE_AUTOMOUNT_ROOTFS
 	# The root options are hidden for RamFS
 	config LIBVFSCORE_ROOTOPTS
 	string "Default root mount options"
-	depends on !LIBVFSCORE_ROOTFS_RAMFS
+	depends on !LIBVFSCORE_ROOTFS_RAMFS && !LIBVFSCORE_ROOTFS_INITRD
 	default ""
 	help
 		Usually a comma-separated list of additional mount
diff --git a/lib/vfscore/rootfs.c b/lib/vfscore/rootfs.c
index 78dbe3a..e83eec8 100644
--- a/lib/vfscore/rootfs.c
+++ b/lib/vfscore/rootfs.c
@@ -85,32 +85,33 @@ static int vfscore_rootfs(void)
 		return -1;
 	}
 
-#ifdef CONFIG_LIBINITRAMFS
-	struct ukplat_memregion_desc memregion_desc;
-	int initrd;
-	enum cpio_error error;
+#if CONFIG_LIBUKCPIO && CONFIG_LIBRAMFS
+	if (strncmp(rootfs, "initrd", 5) == 0) {
+		struct ukplat_memregion_desc initrd;
+		enum ukcpio_error error;
 
-	initrd = ukplat_memregion_find_initrd0(&memregion_desc);
-	if (initrd != -1) {
-		ukplat_memregion_get(initrd, &memregion_desc);
-		if (mount("", "/", "ramfs", 0, NULL) < 0)
-			return -CPIO_MOUNT_FAILED;
+		if (ukplat_memregion_find_initrd0(&initrd) < 0){
+			uk_pr_crit("Could not find an initrd!\n");
+			return -1;
+		}
 
-		error =
-		    cpio_extract("/", memregion_desc.base, memregion_desc.len);
-		if (error < 0)
-			uk_pr_err("Failed to mount initrd\n");
-		return error;
-	}
-	uk_pr_err("Failed to mount initrd\n");
-	return -CPIO_NO_MEMREGION;
-#else
-	uk_pr_info("Mount %s to /...\n", rootfs);
-	if (mount(rootdev, "/", rootfs, rootflags, rootopts) != 0) {
-		uk_pr_crit("Failed to mount /: %d\n", errno);
-		return -1;
+		if (mount("", "/", "ramfs", 0, NULL) != 0) {
+			uk_pr_crit("Failed to mount ramfs to /: %d\n",
+				   errno);
+			return -1;
+		}
+
+		error = ukcpio_extract("/", initrd.base, initrd.len);
+		if (error < 0) {
+			uk_pr_crit("Failed to extract cpio archive to /: %d\n",
+				   error);
+			return -1;
+		}
+
+		return 0;
 	}
 #endif
+
 	return 0;
 }
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 07 14:54:29 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 07 Sep 2020 14:54:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kFIXK-0003Rc-4C; Mon, 07 Sep 2020 14:54:26 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=QCjB=CM=gmail.com=gabi.mocanu98@srs-us1.protection.inumbo.net>)
 id 1kDuRl-0003Ak-PI
 for minios-devel@lists.xen.org; Thu, 03 Sep 2020 18:58:57 +0000
X-Inumbo-ID: acadccff-ac94-4e39-8ff5-ff195351dd90
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id acadccff-ac94-4e39-8ff5-ff195351dd90;
 Thu, 03 Sep 2020 18:58:48 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id k15so4315275wrn.10
 for <minios-devel@lists.xen.org>; Thu, 03 Sep 2020 11:58:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references;
 bh=dG1WDLt7adna+lf1t4ihPoTKGl6ACRMdy/c7hBdqiZQ=;
 b=jIZNu8JjMz1B3DY+PbGswvFyXRoaxzci/jp/np6a2FqXuLpUGBEuNBfzH+B2ELSAg0
 Ddcm2DLx38visaR8uIQU3DQ4ML8iY8SZX8u5tWNZ//8R7XACTdoC+tsvykJiP+6QtNQ0
 iWdyDehgBY0QIW3AdzjUqGfhdxqj9VvcIbYn5/dMFwWw4a82Qv6WyOvNJX7VdALtmH3l
 R3g5Cqj4T8MAswF4l4apSM5fQ6h2w5huCwUz807DxZ3hIkPAsu/h/8kh5eYDw1tiXg+E
 RRp92mFDQgruPOnpK3fEd/6IykzyXQl+zOjBhymOfAJuvNR42CtCmwubUvCjgFCSdYin
 X+Tw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references;
 bh=dG1WDLt7adna+lf1t4ihPoTKGl6ACRMdy/c7hBdqiZQ=;
 b=fLbb5RpjQfQf9WtbF5WIC4rF/HzqUC7l4HL2I57OpHk0f8wTB5JY47bp1KQls7cbIg
 nB15CP91FAF+C8IcSgo6Df+7hefpPPAbI1QH2/sRyh4NeSlHuJHELBIjae1hJoEvBc35
 OFoUu1FZfGK4Sr2EKZ83Vn7WugljOHXQXagqfgGxEIaJjzfAXOyvSzCBkk4NSCdUS6rN
 ak3HaQnYUMZhmdjE/dq3XZAorTDVM5s7FbVu8ijSt7wWr/WDCFNX4nm3Uhl2iTtelpxC
 2sSEDlDyj6uBmmfitFs/X36C+GqSTPIu6fr69+V6UeISvWcS+JQfqxpDxvCup+0ogYik
 i3uQ==
X-Gm-Message-State: AOAM532sbfylXCgmxvpka/h71LCT7wg/oFWJlyb9QB+jOrDwigj8r6UY
 v2CX8TV7Jjw980xVvHskrn9uy+9Sp94iEW4z
X-Google-Smtp-Source: ABdhPJwQpRcTYaQCz8dHDN3o3nW37O6dmKZ42vftn4Us42gJyDs9h0+SRzlrjh7aRV6Ky7VzkWjV1A==
X-Received: by 2002:a5d:684b:: with SMTP id o11mr4090269wrw.101.1599159526716; 
 Thu, 03 Sep 2020 11:58:46 -0700 (PDT)
Received: from localhost.localdomain ([188.173.197.103])
 by smtp.gmail.com with ESMTPSA id y6sm6038198wrt.80.2020.09.03.11.58.45
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 03 Sep 2020 11:58:46 -0700 (PDT)
From: gabrielmocanu <gabi.mocanu98@gmail.com>
To: minios-devel@lists.xen.org
Cc: Simon Kuenzer <simon.kuenzer@neclab.eu>,
 gabrielmocanu <gabi.mocanu98@gmail.com>
Subject: [PATCH 3/4] Rename cpio to ukcpio and create Config.uk for the cpio
Date: Thu,  3 Sep 2020 21:58:41 +0300
Message-Id: <20200903185842.19073-3-gabi.mocanu98@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200903185842.19073-1-gabi.mocanu98@gmail.com>
References: <20200903185842.19073-1-gabi.mocanu98@gmail.com>
X-Mailman-Approved-At: Mon, 07 Sep 2020 14:54:24 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: gabrielmocanu <gabi.mocanu98@gmail.com>
---
 lib/cpio/Makefile.uk                   |   7 -
 lib/cpio/exportsyms.uk                 |   1 -
 lib/ukcpio/Config.uk                   |   4 +
 lib/ukcpio/Makefile.uk                 |   7 +
 lib/{cpio => ukcpio}/cpio.c            | 188 +++++++++++++++----------
 lib/ukcpio/exportsyms.uk               |   1 +
 lib/{cpio => ukcpio}/include/uk/cpio.h |  49 ++++---
 7 files changed, 155 insertions(+), 102 deletions(-)
 delete mode 100644 lib/cpio/Makefile.uk
 delete mode 100644 lib/cpio/exportsyms.uk
 create mode 100644 lib/ukcpio/Config.uk
 create mode 100644 lib/ukcpio/Makefile.uk
 rename lib/{cpio => ukcpio}/cpio.c (56%)
 create mode 100644 lib/ukcpio/exportsyms.uk
 rename lib/{cpio => ukcpio}/include/uk/cpio.h (76%)

diff --git a/lib/cpio/Makefile.uk b/lib/cpio/Makefile.uk
deleted file mode 100644
index c3411bf..0000000
--- a/lib/cpio/Makefile.uk
+++ /dev/null
@@ -1,7 +0,0 @@
-$(eval $(call addlib_s,libcpio,$(CONFIG_LIBCPIO)))
-
-# LIBCPIO_CFLAGS-$(call gcc_version_ge,8,0) += -Wno-cast-function-type
-
-CINCLUDES-$(CONFIG_LIBCPIO) += -I$(LIBCPIO_BASE)/include
-CXXINCLUDES-$(CONFIG_LIBCPIO) += -I$(LIBCPIO_BASE)/include
-LIBCPIO_SRCS-y += $(LIBCPIO_BASE)/cpio.c
diff --git a/lib/cpio/exportsyms.uk b/lib/cpio/exportsyms.uk
deleted file mode 100644
index 090dd8d..0000000
--- a/lib/cpio/exportsyms.uk
+++ /dev/null
@@ -1 +0,0 @@
-cpio_extract
diff --git a/lib/ukcpio/Config.uk b/lib/ukcpio/Config.uk
new file mode 100644
index 0000000..5c412db
--- /dev/null
+++ b/lib/ukcpio/Config.uk
@@ -0,0 +1,4 @@
+config LIBUKCPIO
+  bool "ukcpio: CPIO archive extraction"
+  depends on LIBVFSCORE
+  default n
diff --git a/lib/ukcpio/Makefile.uk b/lib/ukcpio/Makefile.uk
new file mode 100644
index 0000000..b601e96
--- /dev/null
+++ b/lib/ukcpio/Makefile.uk
@@ -0,0 +1,7 @@
+$(eval $(call addlib_s,libukcpio,$(CONFIG_LIBUKCPIO)))
+
+# LIBUKCPIO_CFLAGS-$(call gcc_version_ge,8,0) += -Wno-cast-function-type
+
+CINCLUDES-$(CONFIG_LIBUKCPIO) += -I$(LIBUKCPIO_BASE)/include
+CXXINCLUDES-$(CONFIG_LIBUKCPIO) += -I$(LIBUKCPIO_BASE)/include
+LIBUKCPIO_SRCS-y += $(LIBUKCPIO_BASE)/cpio.c
diff --git a/lib/cpio/cpio.c b/lib/ukcpio/cpio.c
similarity index 56%
rename from lib/cpio/cpio.c
rename to lib/ukcpio/cpio.c
index e27e99b..1b7386e 100644
--- a/lib/cpio/cpio.c
+++ b/lib/ukcpio/cpio.c
@@ -31,14 +31,15 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
  */
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <stdbool.h>
+#include <stdint.h>
 
+#include <uk/assert.h>
+#include <uk/print.h>
 #include <uk/cpio.h>
 #include <uk/essentials.h>
 #include <sys/mount.h>
@@ -46,8 +47,8 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#define CPIO_MAGIC_NEWC "070701"
-#define CPIO_MAGIC_CRC "070702"
+#define UKCPIO_MAGIC_NEWC "070701"
+#define UKCPIO_MAGIC_CRC "070702"
 #define FILE_TYPE_MASK 0170000
 #define DIRECTORY_BITS 040000
 #define FILE_BITS 0100000
@@ -58,7 +59,11 @@
 #define IS_FILE(mode) IS_FILE_OF_TYPE((mode), (FILE_BITS))
 #define IS_DIR(mode) IS_FILE_OF_TYPE((mode), (DIRECTORY_BITS))
 
-#define GET_MODE(hdr) ((mode_t)strhex8_to_u32((hdr)->mode))
+
+#define s8hex_to_u32(buf) ((uint32_t) snhex_to_int((buf), 8))
+#define GET_MODE(hdr) ((mode_t)s8hex_to_u32((hdr)->mode))
+
+#define filename(header) ((const char *)header + sizeof(struct cpio_header))
 
 struct cpio_header {
 	char magic[6];
@@ -77,10 +82,10 @@ struct cpio_header {
 	char chksum[8];
 };
 
-static bool valid_magic(struct cpio_header *header)
+static int valid_magic(struct cpio_header *header)
 {
-	return memcmp(header->magic, CPIO_MAGIC_NEWC, 6) == 0
-	       || memcmp(header->magic, CPIO_MAGIC_CRC, 6) == 0;
+	return memcmp(header->magic, UKCPIO_MAGIC_NEWC, 6) == 0
+	       || memcmp(header->magic, UKCPIO_MAGIC_CRC, 6) == 0;
 }
 
 /* Function to convert len digits of hexadecimal string loc
@@ -88,105 +93,127 @@ static bool valid_magic(struct cpio_header *header)
  * Returns the converted unsigned integer value on success.
  * Returns 0 on error.
  */
-static unsigned int snhex_to_int(size_t len, char *loc)
+static unsigned int snhex_to_int(const char *buf, size_t count)
 {
-	int val = 0;
+	unsigned int val = 0;
 	size_t i;
 
-	for (i = 0; i < len; i++) {
+  UK_ASSERT(buf);
+
+	for (i = 0; i < count; i++) {
 		val *= 16;
-		if (*(loc + i) >= '0' && *(loc + i) <= '9')
-			val += (*(loc + i) - '0');
-		else if (*(loc + i) >= 'A' && *(loc + i) <= 'F')
-			val += (*(loc + i) - 'A') + 10;
-		else if (*(loc + i) >= 'a' && *(loc + i) <= 'f')
-			val += (*(loc + i) - 'a') + 10;
+		if (buf[i] >= '0' && buf[i] <= '9')
+			val += (buf[i] - '0');
+		else if (buf[i] >= 'A' && buf[i] <= 'F')
+			val += (buf[i] - 'A') + 10;
+		else if (buf[i] >= 'a' && buf[i] <= 'f')
+			val += (buf[i] - 'a') + 10;
 		else
 			return 0;
 	}
 	return val;
 }
 
-static uint32_t strhex8_to_u32(char *loc)
+static char *absolute_path(const char *prefix,const char *path)
 {
-	return snhex_to_int(8, loc);
-}
+  int add_slash;
+  size_t prefix_len;
+  size_t path_len;
+  size_t abs_path_len;
+  char *abs_path;
 
-static inline char *filename(struct cpio_header *header)
-{
-	return (char *)header + sizeof(struct cpio_header);
-}
+  UK_ASSERT(prefix);
+  UK_ASSERT(path);
+
+  prefix_len = strlen(prefix);
+  path_len = strlen(path);
+
+  add_slash = prefix[prefix_len - 1] == '/' ? 0 : 1;
+  abs_path_len = prefix_len + add_slash + path_len + 1;
+
+  abs_path = malloc(abs_path_len);
 
-static char *absolute_path(char *path_to_prepend, char *path)
-{
-	int dir_slash_included =
-	    *(path_to_prepend + strlen(path_to_prepend) - 1) == '/' ? 1 : 2;
-	char *abs_path = (char *)malloc(strlen(path) + strlen(path_to_prepend)
-					+ dir_slash_included);
 	if (abs_path == NULL)
 		return NULL;
-	memcpy(abs_path, path_to_prepend, strlen(path_to_prepend));
-	if (dir_slash_included == 2)
-		*(abs_path + strlen(path_to_prepend)) = '/';
-	memcpy(abs_path + strlen(path_to_prepend) + dir_slash_included - 1,
-	       path, strlen(path));
-	*(abs_path + strlen(path) + strlen(path_to_prepend) + dir_slash_included
-	  - 1) = '\0';
+
+	memcpy(abs_path, prefix, prefix_len);
+	if (add_slash)
+		abs_path[prefix_len] = '/';
+  memcpy(&abs_path[prefix_len + add_slash], path, path_len);
+
+  abs_path[abs_path_len - 1] = '\0';
 	return abs_path;
 }
 
-static enum cpio_error read_section(struct cpio_header **header_ptr,
-				    char *mount_loc, uintptr_t last)
+static enum ukcpio_error read_section(struct cpio_header **header_ptr,
+				    const char *dest, uintptr_t last)
 {
-	if (strcmp(filename(*header_ptr), "TRAILER!!!") == 0) {
+
+  enum ukcpio_error error = UKCPIO_SUCCESS;
+  int fd;
+  struct cpio_header *header;
+  char *path_from_root;
+  mode_t header_mode;
+  uint32_t header_filesize;
+  uint32_t header_namesize;
+  char *data_location;
+  uint32_t bytes_to_write;
+  int bytes_written;
+  struct cpio_header *next_header;
+
+  if (strcmp(filename(*header_ptr), "TRAILER!!!") == 0) {
 		*header_ptr = NULL;
-		return CPIO_SUCCESS;
+		return UKCPIO_SUCCESS;
 	}
 
 	if (!valid_magic(*header_ptr)) {
 		*header_ptr = NULL;
-		return -CPIO_INVALID_HEADER;
+		return -UKCPIO_INVALID_HEADER;
 	}
 
-	if (mount_loc == NULL) {
-		*header_ptr = NULL;
-		return -CPIO_NO_MOUNT_LOCATION;
-	}
+  UK_ASSERT(dest);
 
-	struct cpio_header *header = *header_ptr;
-	char *path_from_root = absolute_path(mount_loc, filename(header));
+	header = *header_ptr;
+	path_from_root = absolute_path(dest, filename(header));
 
 	if (path_from_root == NULL) {
 		*header_ptr = NULL;
-		return -CPIO_NOMEM;
+		error = -UKCPIO_NOMEM;
+    goto out;
 	}
-	mode_t header_mode = GET_MODE(header);
-	uint32_t header_filesize = strhex8_to_u32(header->filesize);
-	uint32_t header_namesize = strhex8_to_u32(header->namesize);
+
+	header_mode = GET_MODE(header);
+	header_filesize = s8hex_to_u32(header->filesize);
+	header_namesize = s8hex_to_u32(header->namesize);
 
 	if ((uintptr_t)header + sizeof(struct cpio_header) > last) {
 		*header_ptr = NULL;
-		return -CPIO_MALFORMED_FILE;
+    error = -UKCPIO_MALFORMED_FILE;
+    goto out;
 	}
+
 	if (IS_FILE(header_mode) && header_filesize != 0) {
-		uk_pr_debug("Creating file %s...\n", path_from_root);
-		int fd = open(path_from_root, O_CREAT | O_RDWR);
+		uk_pr_info("Extracting %s...\n", path_from_root);
+		fd = open(path_from_root, O_CREAT | O_RDWR);
 
 		if (fd < 0) {
 			*header_ptr = NULL;
-			return -CPIO_FILE_CREATE_FAILED;
+			error = -UKCPIO_FILE_CREATE_FAILED;
+      goto out;
 		}
-		uk_pr_debug("File %s created\n", path_from_root);
-		char *data_location = (char *)ALIGN_4(
+
+		data_location = (char *)ALIGN_4(
 		    (char *)(header) + sizeof(struct cpio_header)
 		    + header_namesize);
 
 		if ((uintptr_t)data_location + header_filesize > last) {
 			*header_ptr = NULL;
-			return -CPIO_MALFORMED_FILE;
+			error = -UKCPIO_MALFORMED_FILE;
+      goto out;
 		}
-		uint32_t bytes_to_write = header_filesize;
-		int bytes_written = 0;
+
+		bytes_to_write = header_filesize;
+		bytes_written = 0;
 
 		while (bytes_to_write > 0) {
 			if ((bytes_written =
@@ -194,46 +221,57 @@ static enum cpio_error read_section(struct cpio_header **header_ptr,
 				       bytes_to_write))
 			    < 0) {
 				*header_ptr = NULL;
-				return -CPIO_FILE_WRITE_FAILED;
+				error = -UKCPIO_FILE_WRITE_FAILED;
+        goto out;
 			}
 			bytes_to_write -= bytes_written;
 		}
+
 		if (chmod(path_from_root, header_mode & 0777) < 0)
-			uk_pr_info("chmod on file %s failed\n", path_from_root);
+			uk_pr_err("Failed to chmod %s\n", path_from_root);
+
 		if (close(fd) < 0) {
 			*header_ptr = NULL;
-			return -CPIO_FILE_CLOSE_FAILED;
+			error = -UKCPIO_FILE_CLOSE_FAILED;
+      goto out;
 		}
 	} else if (IS_DIR(header_mode)) {
+		uk_pr_info("Extracting %s...\n", path_from_root);
 		if (strcmp(".", filename(header)) != 0
 		    && mkdir(path_from_root, header_mode & 0777) < 0) {
 			*header_ptr = NULL;
-			return -CPIO_MKDIR_FAILED;
+			error = -UKCPIO_MKDIR_FAILED;
+      goto out;
 		}
 	}
-	free(path_from_root);
-	struct cpio_header *next_header = (struct cpio_header *)ALIGN_4(
+
+  next_header = (struct cpio_header *)ALIGN_4(
 	    (char *)header + sizeof(struct cpio_header) + header_namesize);
 
 	next_header = (struct cpio_header *)ALIGN_4((char *)next_header
 						    + header_filesize);
+
 	*header_ptr = next_header;
-	return CPIO_SUCCESS;
+	
+  out:
+    free(path_from_root);
+    return error;
 }
 
-enum cpio_error cpio_extract(char *mount_loc, void *memory_region, size_t len)
+enum ukcpio_error ukcpio_extract(const char *dest, void *buf, size_t buflen)
 {
-	enum cpio_error error = CPIO_SUCCESS;
-	struct cpio_header *header = (struct cpio_header *)(memory_region);
+	enum ukcpio_error error = UKCPIO_SUCCESS;
+	struct cpio_header *header = (struct cpio_header *)(buf);
 	struct cpio_header **header_ptr = &header;
 	uintptr_t end = (uintptr_t)header;
 
-	if (mount_loc == NULL)
-		return -CPIO_NO_MOUNT_LOCATION;
+	if (dest == NULL)
+		return -UKCPIO_NODEST;
 
-	while (error == CPIO_SUCCESS && header != NULL) {
-		error = read_section(header_ptr, mount_loc, end + len);
+	while (!error && header) {
+		error = read_section(header_ptr, dest, end + buflen);
 		header = *header_ptr;
 	}
+
 	return error;
 }
diff --git a/lib/ukcpio/exportsyms.uk b/lib/ukcpio/exportsyms.uk
new file mode 100644
index 0000000..c25c393
--- /dev/null
+++ b/lib/ukcpio/exportsyms.uk
@@ -0,0 +1 @@
+ukcpio_extract
diff --git a/lib/cpio/include/uk/cpio.h b/lib/ukcpio/include/uk/cpio.h
similarity index 76%
rename from lib/cpio/include/uk/cpio.h
rename to lib/ukcpio/include/uk/cpio.h
index 86bc002..41ac05e 100644
--- a/lib/cpio/include/uk/cpio.h
+++ b/lib/ukcpio/include/uk/cpio.h
@@ -31,27 +31,38 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
  */
 
-#ifndef __CPIO_H__
-#define __CPIO_H__
-#include <uk/plat/memory.h>
-
-enum cpio_error {
-	CPIO_SUCCESS = 0,
-	CPIO_INVALID_HEADER,
-	CPIO_FILE_CREATE_FAILED,
-	CPIO_FILE_WRITE_FAILED,
-	CPIO_FILE_CHMOD_FAILED,
-	CPIO_FILE_CLOSE_FAILED,
-	CPIO_MKDIR_FAILED,
-	CPIO_MOUNT_FAILED,
-	CPIO_NO_MEMREGION,
-	CPIO_MALFORMED_FILE,
-	CPIO_NOMEM,
-	CPIO_NO_MOUNT_LOCATION
+#ifndef __UK_CPIO_H__
+#define __UK_CPIO_H__
+
+#ifdef __cplusplus
+extern C {
+#endif /* __cplusplus */
+
+
+/**
+ * Include also the case of unsupported headers
+ */
+
+enum ukcpio_error {
+	UKCPIO_SUCCESS = 0,
+	UKCPIO_INVALID_HEADER,
+	UKCPIO_FILE_CREATE_FAILED,
+	UKCPIO_FILE_WRITE_FAILED,
+	UKCPIO_FILE_CHMOD_FAILED,
+	UKCPIO_FILE_CLOSE_FAILED,
+	UKCPIO_MKDIR_FAILED,
+	UKCPIO_MALFORMED_FILE,
+	UKCPIO_NOMEM,
+	UKCPIO_NODEST,
+  UKCPIO_MOUNT_FAILED
 };
 
-enum cpio_error cpio_extract(char *loc, void *mem, size_t len);
+enum ukcpio_error ukcpio_extract(const char *dest, void *buf, size_t buflen);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
 #endif /*__CPIO_H__*/
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 07 14:54:29 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 07 Sep 2020 14:54:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kFIXK-0003RS-1P; Mon, 07 Sep 2020 14:54:26 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=QCjB=CM=gmail.com=gabi.mocanu98@srs-us1.protection.inumbo.net>)
 id 1kDuRb-0003Ak-Vh
 for minios-devel@lists.xen.org; Thu, 03 Sep 2020 18:58:48 +0000
X-Inumbo-ID: 0a1bdd03-ea40-4543-971a-bf9dd0f6f612
Received: from mail-wr1-x444.google.com (unknown [2a00:1450:4864:20::444])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 0a1bdd03-ea40-4543-971a-bf9dd0f6f612;
 Thu, 03 Sep 2020 18:58:45 +0000 (UTC)
Received: by mail-wr1-x444.google.com with SMTP id z4so4357147wrr.4
 for <minios-devel@lists.xen.org>; Thu, 03 Sep 2020 11:58:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id;
 bh=Hu+1yMQlAqGregLLa2IxOlANAospAUMyL5+AcQ3EZE8=;
 b=UeVrQtbUa5PkFO6fhiMI2xVLWL5s1iZ8xNTjFuzW7kJcIBuONW70wBJ+tSXU0/yZX0
 iILEcEZnS4QSK/hbARcPfAtKSer2huulSVxOt+vSzG/wUuZ6bWybBt2m8rR2iKsF37dv
 zs0Z877SR3fFO51i4vmlvTWmfIrZ8IbMO5w6jQEGq6vmOazOmtttNzQ8Jf+1SQCh5X48
 8ACQRNChM9ovRSS2szmGUo5mUf3Sy3+XUBu6PwmuIRtuiFYulZToFksrEVnXkXlGMNJ/
 JoHEOnj2AtOwcxv6TAFU+Ajpb6IPpJgVGiLUy1+pAAqwsZHyOEuyi55cbx9VPvfc1xA3
 FnHA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id;
 bh=Hu+1yMQlAqGregLLa2IxOlANAospAUMyL5+AcQ3EZE8=;
 b=rsePANpwknjcQEh0iXmmDnWRUQ2R93fzYq5JsGzFZk/wfwQp5fOKQHMcLKXj8vmfiu
 g5P6+vO39QzN4eLyzEhKwFN3wGmuW4kPr0VaXS050HY4muXf75+Mg1zzOaeyn/a28mhi
 BQwwkDflI20NpgUOymCZaAbpiJp08Xn7AzYuwkZOT9JJNklxEZm6QbYxsxUM6aK4/Yt8
 Qs9YZhy0XX3TOrm43cuqqSPp/bxIMZIuHMtQNERQpagBIEUWGNuX5Wz+tdWXS5txVO5u
 Bg8BR1hs+vSdJkQhLcLVbDirF9AdT6S6ra55cn4XWLAusACyTR4P0TaZK/wKpdh3nRCs
 +VrQ==
X-Gm-Message-State: AOAM532AWQkNqkHLtI/pvF6g562ev2BkJN2iwOTIfoKXUOb6q5Gh/rn2
 CZ2vWm8aRVOXEKev6stuDLFX2bmsaHaAQeDF
X-Google-Smtp-Source: ABdhPJyrfZET42XmFpLpP1ia/JRI+Tgd1o8fWqNHmHbW7Ws5GiY5M58KeMeL9k7ADZRxJzLgIBYyIg==
X-Received: by 2002:a5d:568d:: with SMTP id f13mr3817078wrv.303.1599159524759; 
 Thu, 03 Sep 2020 11:58:44 -0700 (PDT)
Received: from localhost.localdomain ([188.173.197.103])
 by smtp.gmail.com with ESMTPSA id y6sm6038198wrt.80.2020.09.03.11.58.43
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 03 Sep 2020 11:58:44 -0700 (PDT)
From: gabrielmocanu <gabi.mocanu98@gmail.com>
To: minios-devel@lists.xen.org
Cc: Simon Kuenzer <simon.kuenzer@neclab.eu>,
 gabrielmocanu <gabi.mocanu98@gmail.com>
Subject: [PATCH 1/4] Define struct k_stat in a header file and modify mode_t
 to k_mode_t as convention
Date: Thu,  3 Sep 2020 21:58:39 +0300
Message-Id: <20200903185842.19073-1-gabi.mocanu98@gmail.com>
X-Mailer: git-send-email 2.17.1
X-Mailman-Approved-At: Mon, 07 Sep 2020 14:54:24 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: gabrielmocanu <gabi.mocanu98@gmail.com>
---
 plat/linuxu/include/linuxu/stat.h    | 39 ++++++++++++++++++++++++++++
 plat/linuxu/include/linuxu/syscall.h |  9 +++++--
 2 files changed, 46 insertions(+), 2 deletions(-)
 create mode 100644 plat/linuxu/include/linuxu/stat.h

diff --git a/plat/linuxu/include/linuxu/stat.h b/plat/linuxu/include/linuxu/stat.h
new file mode 100644
index 0000000..d500b0a
--- /dev/null
+++ b/plat/linuxu/include/linuxu/stat.h
@@ -0,0 +1,39 @@
+#ifndef __LINUXU_STAT_H__
+#define __LINUXU_STAT_H__
+
+#include <linuxu/time.h>
+#include <linuxu/mode.h>
+
+typedef __u64 k_dev_t;
+typedef __u64 k_ino_t;
+typedef __u32 k_nlink_t;
+typedef unsigned k_uid_t;
+typedef unsigned k_gid_t;
+typedef unsigned k_id_t;
+typedef __off k_off_t;
+typedef long k_blksize_t;
+typedef __s64 k_blkcnt_t;
+
+
+struct k_stat {
+  
+  k_dev_t st_dev;
+  k_ino_t st_ino;
+  k_nlink_t st_nlink;
+
+  k_mode_t st_mode;
+  k_uid_t st_uit;
+  k_gid_t st_gid;
+  unsigned int __pad0;
+  k_dev_t st_rdev;
+  k_off_t st_size;
+  k_blksize_t st_blksize;
+  k_blkcnt_t st_blocks;
+
+  struct k_timespec st_atim;
+  struct k_timespec st_mtim;
+  struct k_timespec st_ctim;
+
+};
+
+#endif /* __LINUXU_STAT_H__ */
diff --git a/plat/linuxu/include/linuxu/syscall.h b/plat/linuxu/include/linuxu/syscall.h
index c703b32..1b590b1 100644
--- a/plat/linuxu/include/linuxu/syscall.h
+++ b/plat/linuxu/include/linuxu/syscall.h
@@ -39,6 +39,7 @@
 #include <linuxu/time.h>
 #include <sys/types.h>
 #include <linuxu/signal.h>
+#include <linuxu/stat.h>
 
 #if defined __X86_64__
 #include <linuxu/syscall-x86_64.h>
@@ -71,9 +72,13 @@ static inline ssize_t sys_write(int fd, const char *buf, size_t len)
 				  (long) (len));
 }
 
-struct stat;
+static inline ssize_t sys_close(int fd)
+{
+  return (ssize_t) syscall1(__SC_CLOSE,
+          (long) (fd));
+}
 
-static inline int sys_fstat(int fd, struct stat *statbuf)
+static inline int sys_fstat(int fd, struct k_stat *statbuf)
 {
 	return (int)syscall2(__SC_FSTAT, (long)(fd), (long)(statbuf));
 }
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 12:22:18 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 12:22:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHnUv-0000Qu-M1; Mon, 14 Sep 2020 12:22:17 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHnUu-0000Qp-EA
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 12:22:16 +0000
X-Inumbo-ID: c7a6b8c4-b655-428c-becd-2891b5347d16
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id c7a6b8c4-b655-428c-becd-2891b5347d16;
 Mon, 14 Sep 2020 12:22:14 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 68D9FF22A9;
 Mon, 14 Sep 2020 14:22:13 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
 by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id lut4KYkBUp0u; Mon, 14 Sep 2020 14:22:13 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 4109FF21A3
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 14:22:11 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 14:22:07 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 1/5] include: Provide ANSI control sequence helper
Date: Mon, 14 Sep 2020 14:21:59 +0200
Message-ID: <20200914122203.17509-2-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
References: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Provide ANSI control sequence helper macros with <uk/plat/console.h>. Those
helpers and definitions can be used by console programs and ANSI console
drivers (e.g., VGA).

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 include/uk/plat/console.h | 65 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 63 insertions(+), 2 deletions(-)

diff --git a/include/uk/plat/console.h b/include/uk/plat/console.h
index 8c496ec4..514e88d6 100644
--- a/include/uk/plat/console.h
+++ b/include/uk/plat/console.h
@@ -29,17 +29,78 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- *
- * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
  */
 
 #ifndef __UKPLAT_CONSOLE_H__
 #define __UKPLAT_CONSOLE_H__
 
+#include <uk/essentials.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+/**
+ * ANSI control sequence helpers
+ */
+#define __UK_ANSI_INTRO			"\033["
+#define __UK_ANSI_CMD0(cmd)		__UK_ANSI_INTRO cmd
+#define __UK_ANSI_CMD1(cmd, arg)	__UK_ANSI_INTRO arg cmd
+#define __UK_ANSI_CMD2(cmd, arg0, arg1)	__UK_ANSI_INTRO arg0 ";" arg1 cmd
+#define UK_ANSI_CLEARLINE		__UK_ANSI_CMD0("K")
+#define UK_ANSI_CLEARSCREEN		__UK_ANSI_CMD1("J", "2")
+#define UK_ANSI_HOME			__UK_ANSI_CMD0("H")
+#define UK_ANSI_UP(n)			__UK_ANSI_CMD1("A", STRINGIFY(n))
+#define UK_ANSI_DOWN(n)			__UK_ANSI_CMD1("B", STRINGIFY(n))
+#define UK_ANSI_RIGHT(n)		__UK_ANSI_CMD1("C"; STRINGIFY(n))
+#define UK_ANSI_LEFT(n)			__UK_ANSI_CMD1("D", STRINGIFY(n))
+#define UK_ANSI_POS(l, c)		__UK_ANSI_CMD2("H", STRINGIFY(l), \
+						       STRINGIFY(c))
+
+#define __UK_ANSI_MOD1(m)		__UK_ANSI_CMD1("m", m)
+#define __UK_ANSI_MOD2(m0, m1)		__UK_ANSI_CMD2("m", m0, m1)
+#define UK_ANSI_MOD_RESET		__UK_ANSI_MOD1("0")
+#define UK_ANSI_MOD_BOLD		__UK_ANSI_MOD1("1")
+#define UK_ANSI_MOD_UNDERSCORE		__UK_ANSI_MOD1("4")
+#define UK_ANSI_MOD_BLINK		__UK_ANSI_MOD1("5")
+#define UK_ANSI_MOD_INVERT		__UK_ANSI_MOD1("7")
+#define UK_ANSI_MOD_HIDE		__UK_ANSI_MOD1("8")
+
+#define __UK_ANSI_MOD_COLOR_FG0		"30"
+#define __UK_ANSI_MOD_COLOR_FG1		"31"
+#define __UK_ANSI_MOD_COLOR_FG2		"32"
+#define __UK_ANSI_MOD_COLOR_FG3		"33"
+#define __UK_ANSI_MOD_COLOR_FG4		"34"
+#define __UK_ANSI_MOD_COLOR_FG5		"35"
+#define __UK_ANSI_MOD_COLOR_FG6		"36"
+#define __UK_ANSI_MOD_COLOR_FG7		"37"
+#define __UK_ANSI_MOD_COLOR_BG0		"40"
+#define __UK_ANSI_MOD_COLOR_BG1		"41"
+#define __UK_ANSI_MOD_COLOR_BG2		"42"
+#define __UK_ANSI_MOD_COLOR_BG3		"43"
+#define __UK_ANSI_MOD_COLOR_BG4		"44"
+#define __UK_ANSI_MOD_COLOR_BG5		"45"
+#define __UK_ANSI_MOD_COLOR_BG6		"46"
+#define __UK_ANSI_MOD_COLOR_BG7		"47"
+
+#define UK_ANSI_MOD_COLOR(fg, bg)	__UK_ANSI_MOD2( \
+					 UK_CONCAT(__UK_ANSI_MOD_COLOR_FG, fg),\
+					 UK_CONCAT(__UK_ANSI_MOD_COLOR_BG, bg))
+#define UK_ANSI_MOD_COLORFG(fg)		__UK_ANSI_MOD1( \
+					 UK_CONCAT(__UK_ANSI_MOD_COLOR_FG, fg))
+#define UK_ANSI_MOD_COLORBG(bg)		__UK_ANSI_MOD1( \
+					 UK_CONCAT(__UK_ANSI_MOD_COLOR_BG, bg))
+
+#define UK_ANSI_COLOR_BLACK		0
+#define UK_ANSI_COLOR_RED		1
+#define UK_ANSI_COLOR_GREEN		2
+#define UK_ANSI_COLOR_YELLOW		3
+#define UK_ANSI_COLOR_BLUE		4
+#define UK_ANSI_COLOR_MAGENTA		5
+#define UK_ANSI_COLOR_CYAN		6
+#define UK_ANSI_COLOR_WHITE		7
+
+
 /**
  * Outputs a string to kernel console
  * Note that printing does not stop on null termination
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 12:22:18 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 12:22:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHnUt-0000Qi-Kf; Mon, 14 Sep 2020 12:22:15 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHnUs-0000Qd-3O
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 12:22:14 +0000
X-Inumbo-ID: de76d2ce-e088-4667-8171-b752c9088b9d
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id de76d2ce-e088-4667-8171-b752c9088b9d;
 Mon, 14 Sep 2020 12:22:12 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 686D9F22AC;
 Mon, 14 Sep 2020 14:22:11 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
 by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id xwiIfYQZpV7j; Mon, 14 Sep 2020 14:22:11 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 31871F21A3
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 14:22:09 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 14:22:05 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 0/5]  New banner logo and colored output
Date: Mon, 14 Sep 2020 14:21:58 +0200
Message-ID: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: puck.office.hd (192.168.24.91) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This series adds new text-mode Unikraft banners that are close to
the official project logo. Additionally, the series adds options
to enable colored output for ukdebug and the banners on
ANSI-compatible terminals.

Simon Kuenzer (5):
  include: Provide ANSI control sequence helper
  lib/ukdebug: Option to hide source code locations from messages
  lib/ukdebug: Option for colored output format
  lib/ukboot: Additional Unikraft banners
  lib/ukboot: ANSI-colored Unikraft banners

 include/uk/plat/console.h |  65 ++++++++++++++++-
 lib/ukboot/Config.uk      |  66 +++++++++++++++++-
 lib/ukboot/Makefile.uk    |   3 +
 lib/ukboot/banner.c       | 142 ++++++++++++++++++++++++++++++++++++++
 lib/ukboot/banner.h       |  50 ++++++++++++++
 lib/ukboot/boot.c         |  11 +--
 lib/ukdebug/Config.uk     |  12 ++++
 lib/ukdebug/print.c       |  95 +++++++++++++++++++++----
 8 files changed, 416 insertions(+), 28 deletions(-)
 create mode 100644 lib/ukboot/banner.c
 create mode 100644 lib/ukboot/banner.h

-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 12:47:00 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 12:47:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHnsp-0002hf-3t; Mon, 14 Sep 2020 12:46:59 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHnso-0002ha-Bu
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 12:46:58 +0000
X-Inumbo-ID: ee117468-fdc5-4c18-9d36-e921514ef7ba
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id ee117468-fdc5-4c18-9d36-e921514ef7ba;
 Mon, 14 Sep 2020 12:46:56 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 7161BF22AF;
 Mon, 14 Sep 2020 14:46:55 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
 by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id h2D5rv7AoRcT; Mon, 14 Sep 2020 14:46:55 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 15B1BF22AC
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 14:46:53 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 14:46:52 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 2/5] lib/ukdebug: Option to hide source code
 locations from messages
Date: Mon, 14 Sep 2020 14:46:35 +0200
Message-ID: <20200914124638.17813-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
References: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Provides an option to hide the source code location of each ukdebug
message.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukdebug/Config.uk |  4 ++++
 lib/ukdebug/print.c   | 10 ++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/ukdebug/Config.uk b/lib/ukdebug/Config.uk
index c844d9a2..799593b8 100644
--- a/lib/ukdebug/Config.uk
+++ b/lib/ukdebug/Config.uk
@@ -69,6 +69,10 @@ config LIBUKDEBUG_PRINT_STACK
 	bool "Print bottom address of stack in messages"
 	default n
 
+config LIBUKDEBUG_PRINT_SRCNAME
+	bool "Print source code location of messages"
+	default y
+
 config LIBUKDEBUG_ENABLE_ASSERT
 	bool "Enable assertions"
 	default y
diff --git a/lib/ukdebug/print.c b/lib/ukdebug/print.c
index e34199c8..1a12898e 100644
--- a/lib/ukdebug/print.c
+++ b/lib/ukdebug/print.c
@@ -31,8 +31,6 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- *
- * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
  */
 
 #include "snprintf.h"
@@ -104,8 +102,10 @@ static void _print_stack(struct _vprint_console *cons)
 #endif
 
 static void _vprint(struct _vprint_console *cons,
-		    int lvl, const char *libname, const char *srcname,
-		    unsigned int srcline, const char *fmt, va_list ap)
+		    int lvl, const char *libname,
+		    const char *srcname __maybe_unused,
+		    unsigned int srcline __maybe_unused,
+		    const char *fmt, va_list ap)
 {
 	char lbuf[BUFLEN];
 	int len, llen;
@@ -163,6 +163,7 @@ static void _vprint(struct _vprint_console *cons,
 					   strlen(libname));
 				cons->cout("] ", 2);
 			}
+#if CONFIG_LIBUKDEBUG_PRINT_SRCNAME
 			if (srcname) {
 				char lnobuf[6];
 
@@ -174,6 +175,7 @@ static void _vprint(struct _vprint_console *cons,
 							 "%-5u", srcline));
 				cons->cout(": ", 2);
 			}
+#endif
 			cons->newline = 0;
 		}
 
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 12:48:04 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 12:48:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHnts-0002jO-7q; Mon, 14 Sep 2020 12:48:04 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHntr-0002jJ-6W
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 12:48:03 +0000
X-Inumbo-ID: 1f6dc992-905f-4562-bee4-d8e6d0fb9db2
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 1f6dc992-905f-4562-bee4-d8e6d0fb9db2;
 Mon, 14 Sep 2020 12:48:00 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 0A19E103E75;
 Mon, 14 Sep 2020 14:48:00 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-a.office.hd)
Received: from mailer1.neclab.eu ([127.0.0.1])
 by localhost (atlas-a.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Ei44feMHDxO2; Mon, 14 Sep 2020 14:47:59 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id DD0F4FFEE2
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 14:47:59 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 14:47:59 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 3/5] lib/ukdebug: Option for colored output format
Date: Mon, 14 Sep 2020 14:47:55 +0200
Message-ID: <20200914124757.17872-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
References: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: puck.office.hd (192.168.24.91) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Colors! This commit makes use of ANSI control sequences to color console
output when activated by the user configuration.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukdebug/Config.uk |  8 ++++
 lib/ukdebug/print.c   | 85 +++++++++++++++++++++++++++++++++++++------
 2 files changed, 82 insertions(+), 11 deletions(-)

diff --git a/lib/ukdebug/Config.uk b/lib/ukdebug/Config.uk
index 799593b8..e4177bec 100644
--- a/lib/ukdebug/Config.uk
+++ b/lib/ukdebug/Config.uk
@@ -73,6 +73,14 @@ config LIBUKDEBUG_PRINT_SRCNAME
 	bool "Print source code location of messages"
 	default y
 
+config LIBUKDEBUG_ANSI_COLOR
+	bool "Colored output"
+	default n
+	help
+	  Use ANSI control sequences to colorize console output.
+	  Before activating this option, please make sure that
+	  your console output/display supports ANSI.
+
 config LIBUKDEBUG_ENABLE_ASSERT
 	bool "Enable assertions"
 	default y
diff --git a/lib/ukdebug/print.c b/lib/ukdebug/print.c
index 1a12898e..6dbcda06 100644
--- a/lib/ukdebug/print.c
+++ b/lib/ukdebug/print.c
@@ -45,6 +45,44 @@
 #include <uk/errptr.h>
 #include <uk/arch/lcpu.h>
 
+#if CONFIG_LIBUKDEBUG_ANSI_COLOR
+#define LVLC_RESET	UK_ANSI_MOD_RESET
+#define LVLC_TS		UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_GREEN)
+#define LVLC_SP		UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_BLUE)
+#define LVLC_LIBNAME	UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_YELLOW)
+#define LVLC_SRCNAME	UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_CYAN)
+#define LVLC_DEBUG	UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_WHITE)
+#define LVLC_KERN	UK_ANSI_MOD_BOLD \
+			UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_BLUE)
+#define LVLC_INFO	UK_ANSI_MOD_BOLD \
+			UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_GREEN)
+#define LVLC_WARN	UK_ANSI_MOD_BOLD \
+			UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_YELLOW)
+#define LVLC_ERROR	UK_ANSI_MOD_BOLD \
+			UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_RED)
+#define LVLC_ERROR_MSG	UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_RED)
+#define LVLC_CRIT	UK_ANSI_MOD_BOLD \
+			UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_WHITE) \
+			UK_ANSI_MOD_COLORBG(UK_ANSI_COLOR_RED)
+
+#define LVLC_CRIT_MSG	UK_ANSI_MOD_BOLD \
+			UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_RED)
+#else
+#define LVLC_RESET	""
+#define LVLC_TS		""
+#define LVLC_SP		""
+#define LVLC_LIBNAME	""
+#define LVLC_SRCNAME	""
+#define LVLC_DEBUG	""
+#define LVLC_KERN	""
+#define LVLC_INFO	""
+#define LVLC_WARN	""
+#define LVLC_ERROR	""
+#define LVLC_ERROR_MSG	""
+#define LVLC_CRIT	""
+#define LVLC_CRIT_MSG	""
+#endif /* !CONFIG_LIBUKDEBUG_ANSI_COLOR */
+
 #define BUFLEN 192
 /* special level for printk redirection, used internally only */
 #define KLVL_DEBUG (-1)
@@ -81,7 +119,8 @@ static void _print_timestamp(struct _vprint_console *cons)
 	__nsec rem_usec = ukarch_time_subsec(nansec);
 
 	rem_usec = ukarch_time_nsec_to_usec(rem_usec);
-	len = __uk_snprintf(buf, BUFLEN, "[%5" __PRInsec ".%06" __PRInsec "] ",
+	len = __uk_snprintf(buf, BUFLEN, LVLC_RESET LVLC_TS
+			    "[%5" __PRInsec ".%06" __PRInsec "] ",
 			    sec, rem_usec);
 	cons->cout((char *)buf, len);
 }
@@ -96,7 +135,8 @@ static void _print_stack(struct _vprint_console *cons)
 
 	stackb = (ukarch_read_sp() & STACK_MASK_TOP) + __STACK_SIZE;
 
-	len = __uk_snprintf(buf, BUFLEN, "<%p> ", (void *) stackb);
+	len = __uk_snprintf(buf, BUFLEN, LVLC_RESET LVLC_SP
+			    "<%p> ", (void *) stackb);
 	cons->cout((char *)buf, len);
 }
 #endif
@@ -113,21 +153,25 @@ static void _vprint(struct _vprint_console *cons,
 	const char *lptr = NULL;
 	const char *nlptr = NULL;
 
+	/*
+	 * Note: We reset the console colors earlier in order to exclude
+	 *       background colors for trailing white spaces.
+	 */
 	switch (lvl) {
 	case KLVL_DEBUG:
-		msghdr = "dbg:  ";
+		msghdr = LVLC_RESET LVLC_DEBUG "dbg:" LVLC_RESET "  ";
 		break;
 	case KLVL_CRIT:
-		msghdr = "CRIT: ";
+		msghdr = LVLC_RESET LVLC_CRIT  "CRIT:" LVLC_RESET " ";
 		break;
 	case KLVL_ERR:
-		msghdr = "ERR:  ";
+		msghdr = LVLC_RESET LVLC_ERROR "ERR:" LVLC_RESET "  ";
 		break;
 	case KLVL_WARN:
-		msghdr = "Warn: ";
+		msghdr = LVLC_RESET LVLC_WARN  "Warn:" LVLC_RESET " ";
 		break;
 	case KLVL_INFO:
-		msghdr = "Info: ";
+		msghdr = LVLC_RESET LVLC_INFO  "Info:" LVLC_RESET " ";
 		break;
 	default:
 		/* unknown type: ignore */
@@ -153,12 +197,13 @@ static void _vprint(struct _vprint_console *cons,
 #if CONFIG_LIBUKDEBUG_PRINT_TIME
 			_print_timestamp(cons);
 #endif
-			cons->cout(DECONST(char *, msghdr), 6);
+			cons->cout(DECONST(char *, msghdr), strlen(msghdr));
 #if CONFIG_LIBUKDEBUG_PRINT_STACK
 			_print_stack(cons);
 #endif
 			if (libname) {
-				cons->cout("[", 1);
+				cons->cout(LVLC_RESET LVLC_LIBNAME "[",
+					   strlen(LVLC_RESET LVLC_LIBNAME) + 1);
 				cons->cout(DECONST(char *, libname),
 					   strlen(libname));
 				cons->cout("] ", 2);
@@ -167,13 +212,15 @@ static void _vprint(struct _vprint_console *cons,
 			if (srcname) {
 				char lnobuf[6];
 
+				cons->cout(LVLC_RESET LVLC_SRCNAME "<",
+					   strlen(LVLC_RESET LVLC_SRCNAME) + 1);
 				cons->cout(DECONST(char *, srcname),
 					   strlen(srcname));
 				cons->cout(" @ ", 3);
 				cons->cout(lnobuf,
 					   __uk_snprintf(lnobuf, sizeof(lnobuf),
-							 "%-5u", srcline));
-				cons->cout(": ", 2);
+							 "%4u", srcline));
+				cons->cout("> ", 2);
 			}
 #endif
 			cons->newline = 0;
@@ -186,7 +233,23 @@ static void _vprint(struct _vprint_console *cons,
 		} else {
 			llen = len;
 		}
+
+		/* Message body */
+		switch (lvl) {
+		case KLVL_CRIT:
+			cons->cout(LVLC_RESET LVLC_CRIT_MSG,
+				   strlen(LVLC_RESET LVLC_CRIT_MSG));
+			break;
+		case KLVL_ERR:
+			cons->cout(LVLC_RESET LVLC_ERROR_MSG,
+				   strlen(LVLC_RESET LVLC_ERROR_MSG));
+			break;
+		default:
+			cons->cout(LVLC_RESET, strlen(LVLC_RESET));
+		}
 		cons->cout((char *)lptr, llen);
+		cons->cout(LVLC_RESET, strlen(LVLC_RESET));
+
 		len -= llen;
 		lptr = nlptr + 1;
 	}
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 12:48:09 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 12:48:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHntx-0002jz-9U; Mon, 14 Sep 2020 12:48:09 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHntw-0002js-K4
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 12:48:08 +0000
X-Inumbo-ID: 9930eb89-7b26-4e65-b95b-c747dfe2585e
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 9930eb89-7b26-4e65-b95b-c747dfe2585e;
 Mon, 14 Sep 2020 12:48:06 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 56F8CF22AC;
 Mon, 14 Sep 2020 14:48:05 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
 by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Asn29yoBPc7S; Mon, 14 Sep 2020 14:48:05 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 27BAFF22A9
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 14:48:03 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 14:48:02 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 4/5] lib/ukboot: Additional Unikraft banners
Date: Mon, 14 Sep 2020 14:47:56 +0200
Message-ID: <20200914124757.17872-2-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914124757.17872-1-simon.kuenzer@neclab.eu>
References: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
 <20200914124757.17872-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Adds additional Unikraft banners to choose from. The "Powered by" banners are
intended to be the text-version of the official Unikraft project logo. The most
compatible variant (non-UTF8, non-extended ASCII) is set as the new default.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukboot/Config.uk   | 30 +++++++++++++--
 lib/ukboot/Makefile.uk |  3 ++
 lib/ukboot/banner.c    | 84 ++++++++++++++++++++++++++++++++++++++++++
 lib/ukboot/banner.h    | 50 +++++++++++++++++++++++++
 lib/ukboot/boot.c      | 11 ++----
 5 files changed, 167 insertions(+), 11 deletions(-)
 create mode 100644 lib/ukboot/banner.c
 create mode 100644 lib/ukboot/banner.h

diff --git a/lib/ukboot/Config.uk b/lib/ukboot/Config.uk
index 07139e2b..55550fe3 100644
--- a/lib/ukboot/Config.uk
+++ b/lib/ukboot/Config.uk
@@ -9,9 +9,33 @@ menuconfig LIBUKBOOT
 	# FIXME: binary buddy allocator is hard-coded for now
 
 if LIBUKBOOT
-	config LIBUKBOOT_BANNER
-	bool "Show Unikraft banner"
-	default y
+	choice LIBUKBOOT_BANNER
+	prompt "Unikraft banner"
+	default LIBUKBOOT_BANNER_POWEREDBY
+		config LIBUKBOOT_BANNER_NONE
+		bool "None"
+
+		config LIBUKBOOT_BANNER_MINIMAL
+		bool "One liner"
+
+		config LIBUKBOOT_BANNER_CLASSIC
+		bool "Classic banner"
+
+		config LIBUKBOOT_BANNER_POWEREDBY
+		bool "Powered by Unikraft"
+
+		config LIBUKBOOT_BANNER_POWEREDBY_EA
+		bool "Powered by Unikraft (ASCII)"
+		help
+		  Please make sure that your console display supports
+		  extended ASCII characters
+
+		config LIBUKBOOT_BANNER_POWEREDBY_U8
+		bool "Powered by Unikraft (UTF-8)"
+		help
+		  Please make sure that your console display supports
+		  UTF-8
+	endchoice
 
 	config LIBUKBOOT_MAXNBARGS
 	int "Maximum number of arguments (max. size of argv)"
diff --git a/lib/ukboot/Makefile.uk b/lib/ukboot/Makefile.uk
index ea052019..9c10e5e4 100644
--- a/lib/ukboot/Makefile.uk
+++ b/lib/ukboot/Makefile.uk
@@ -5,6 +5,9 @@ CXXINCLUDES-$(CONFIG_LIBUKBOOT)	+= -I$(LIBUKBOOT_BASE)/include
 
 LIBUKBOOT_SRCS-y += $(LIBUKBOOT_BASE)/boot.c
 LIBUKBOOT_SRCS-y += $(LIBUKBOOT_BASE)/version.c
+ifneq ($(CONFIG_LIBUKBOOT_BANNER_NONE),y)
+LIBUKBOOT_SRCS-y += $(LIBUKBOOT_BASE)/banner.c
+endif
 
 # The main() is in the separate library to fool the LTO. Which is
 # trying to resolve the main() function call to whatever is available
diff --git a/lib/ukboot/banner.c b/lib/ukboot/banner.c
new file mode 100644
index 00000000..bc45b6aa
--- /dev/null
+++ b/lib/ukboot/banner.c
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Unikraft Banner
+ *
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation.
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <uk/config.h>
+#include <stdio.h>
+
+
+void print_banner(FILE *out) {
+#if CONFIG_LIBUKBOOT_BANNER_POWEREDBY
+	fprintf(out, "Powered by\n");
+	fprintf(out, "o.   .o       _ _               __ _\n");
+	fprintf(out, "Oo   Oo  ___ (_) | __ __  __ _ ' _) :_\n");
+	fprintf(out, "oO   oO ' _ `| | |/ /  _)' _` | |_|  _)\n");
+	fprintf(out, "oOo oOO| | | | |   (| | | (_) |  _) :_\n");
+	fprintf(out, " OoOoO ._, ._:_:_,\\_._,  .__,_:_, \\___)\n");
+	fprintf(out, "%39s\n",
+		STRINGIFY(UK_CODENAME) " " STRINGIFY(UK_FULLVERSION));
+
+#elif CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA
+	fprintf(out, "Powered by\n");
+	fprintf(out, "\xDF\xFE   \xFE\xDC       _ _               __ _\n");
+	fprintf(out, "\xDF\xFE   \xDF\xDC  ___ (_) | __ __  __ _ ' _) :_\n");
+	fprintf(out, "\xDC\xDF   \xDC\xFE ' _ `| | |/ /  _)' _` | |_|  _)\n");
+	fprintf(out, "\xFE\xDF\xFE \xFE\xDC\xDF| | | | |   (| | | (_) |  _) :_\n");
+	fprintf(out, " \xFE\xDC\xDF\xDC\xFE ._, ._:_:_,\\_._,  .__,_:_, \\___)\n");
+	fprintf(out, "%39s\n",
+		STRINGIFY(UK_CODENAME) " " STRINGIFY(UK_FULLVERSION));
+
+#elif CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8
+	fprintf(out, "Powered by\n");
+	fprintf(out, "■▖   ▖■       _ _               __ _\n");
+	fprintf(out, "■▚   ■▞  ___ (_) | __ __  __ _ ´ _) :_\n");
+	fprintf(out, "▀■   ■▄ ´ _ `| | |/ /  _)´ _` | |_|  _)\n");
+	fprintf(out, "▄▀▄ ▗▀▄| | | | |   (| | | (_) |  _) :_\n");
+	fprintf(out, " ▚▄■▄▞ ._, ._:_:_,\\_._,  .__,_:_, \\___)\n");
+	fprintf(out, "%39s\n",
+		STRINGIFY(UK_CODENAME) " " STRINGIFY(UK_FULLVERSION));
+
+#elif CONFIG_LIBUKBOOT_BANNER_CLASSIC
+	fprintf(out, "Welcome to  _ __             _____\n");
+	fprintf(out, " __ _____  (_) /__ _______ _/ _/ /_\n");
+	fprintf(out, "/ // / _ \\/ /  '_// __/ _ `/ _/ __/\n");
+	fprintf(out, "\\_,_/_//_/_/_/\\_\\/_/  \\_,_/_/ \\__/\n");
+	fprintf(out, "%35s\n",
+		STRINGIFY(UK_CODENAME) " " STRINGIFY(UK_FULLVERSION));
+
+#else /* CONFIG_LIBUKBOOT_BANNER_MINIMAL  */
+	fprintf(out, "Powered by Unikraft " STRINGIFY(UK_CODENAME)
+		" (" STRINGIFY(UK_FULLVERSION) ")\n");
+#endif
+}
diff --git a/lib/ukboot/banner.h b/lib/ukboot/banner.h
new file mode 100644
index 00000000..906a4acb
--- /dev/null
+++ b/lib/ukboot/banner.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Unikraft Banner
+ *
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation.
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIBUKBOOT_BANNER_H_
+#define _LIBUKBOOT_BANNER_H_
+
+#include <uk/config.h>
+#include <uk/essentials.h>
+#include <stdio.h>
+
+#if CONFIG_LIBUKBOOT_BANNER_NONE
+static inline void print_banner(FILE *out __unused) { }
+#else
+void print_banner(FILE *out);
+#endif
+
+#endif /* _LIBUKBOOT_BANNER_H_ */
diff --git a/lib/ukboot/boot.c b/lib/ukboot/boot.c
index 3e92812d..a4e12bf7 100644
--- a/lib/ukboot/boot.c
+++ b/lib/ukboot/boot.c
@@ -66,6 +66,7 @@
 #if CONFIG_LIBUKSP
 #include <uk/sp.h>
 #endif
+#include "banner.h"
 
 int main(int argc, char *argv[]) __weak;
 
@@ -101,15 +102,9 @@ static void main_thread_func(void *arg)
 		}
 	}
 
-#if CONFIG_LIBUKBOOT_BANNER
-	printf("Welcome to  _ __             _____\n");
-	printf(" __ _____  (_) /__ _______ _/ _/ /_\n");
-	printf("/ // / _ \\/ /  '_// __/ _ `/ _/ __/\n");
-	printf("\\_,_/_//_/_/_/\\_\\/_/  \\_,_/_/ \\__/\n");
-	printf("%35s\n",
-	       STRINGIFY(UK_CODENAME) " " STRINGIFY(UK_FULLVERSION));
+	print_banner(stdout);
 	fflush(stdout);
-#endif
+
 	/*
 	 * Application
 	 *
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 12:48:43 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 12:48:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHnuV-0002m6-Cx; Mon, 14 Sep 2020 12:48:43 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHnuU-0002ly-6G
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 12:48:42 +0000
X-Inumbo-ID: d6da5188-f02b-4b99-ba2b-68f4ccab888d
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d6da5188-f02b-4b99-ba2b-68f4ccab888d;
 Mon, 14 Sep 2020 12:48:40 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 276A2104022;
 Mon, 14 Sep 2020 14:48:40 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-a.office.hd)
Received: from mailer1.neclab.eu ([127.0.0.1])
 by localhost (atlas-a.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id KgVrCk31TwRI; Mon, 14 Sep 2020 14:48:40 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 0645D103FC6
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 14:48:40 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 14:48:39 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 5/5] lib/ukboot: ANSI-colored Unikraft banners
Date: Mon, 14 Sep 2020 14:48:35 +0200
Message-ID: <20200914124835.17933-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
References: <20200914122203.17509-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: puck.office.hd (192.168.24.91) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Provide two ANSI-colored versions (blue, gray) for each of the
"Powered by" banners.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukboot/Config.uk |  36 +++++++++++++++
 lib/ukboot/banner.c  | 106 +++++++++++++++++++++++++++++++++----------
 2 files changed, 118 insertions(+), 24 deletions(-)

diff --git a/lib/ukboot/Config.uk b/lib/ukboot/Config.uk
index 55550fe3..57cf1e36 100644
--- a/lib/ukboot/Config.uk
+++ b/lib/ukboot/Config.uk
@@ -24,17 +24,53 @@ if LIBUKBOOT
 		config LIBUKBOOT_BANNER_POWEREDBY
 		bool "Powered by Unikraft"
 
+		config LIBUKBOOT_BANNER_POWEREDBY_ANSI
+		bool "Powered by Unikraft (blue, ANSI)"
+		help
+		  Please make sure that your console display supports
+		  ANSI colors
+
+		config LIBUKBOOT_BANNER_POWEREDBY_ANSI2
+		bool "Powered by Unikraft (gray, ANSI)"
+		help
+		  Please make sure that your console display supports
+		  ANSI colors
+
 		config LIBUKBOOT_BANNER_POWEREDBY_EA
 		bool "Powered by Unikraft (ASCII)"
 		help
 		  Please make sure that your console display supports
 		  extended ASCII characters
 
+		config LIBUKBOOT_BANNER_POWEREDBY_EAANSI
+		bool "Powered by Unikraft (ASCII, blue, ANSI)"
+		help
+		  Please make sure that your console display supports
+		  extended ASCII characters and ANSI colors
+
+		config LIBUKBOOT_BANNER_POWEREDBY_EAANSI2
+		bool "Powered by Unikraft (ASCII, gray, ANSI)"
+		help
+		  Please make sure that your console display supports
+		  extended ASCII characters and ANSI colors
+
 		config LIBUKBOOT_BANNER_POWEREDBY_U8
 		bool "Powered by Unikraft (UTF-8)"
 		help
 		  Please make sure that your console display supports
 		  UTF-8
+
+		config LIBUKBOOT_BANNER_POWEREDBY_U8ANSI
+		bool "Powered by Unikraft (UTF-8, blue, ANSI)"
+		help
+		  Please make sure that your console display supports
+		  UTF-8 and ANSI colors
+
+		config LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2
+		bool "Powered by Unikraft (UTF-8, gray, ANSI)"
+		help
+		  Please make sure that your console display supports
+		  UTF-8 and ANSI colors
 	endchoice
 
 	config LIBUKBOOT_MAXNBARGS
diff --git a/lib/ukboot/banner.c b/lib/ukboot/banner.c
index bc45b6aa..16660822 100644
--- a/lib/ukboot/banner.c
+++ b/lib/ukboot/banner.c
@@ -35,38 +35,96 @@
  */
 
 #include <uk/config.h>
+#include <uk/plat/console.h>
 #include <stdio.h>
 
+/*
+ * Color palette
+ */
+#if CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI || \
+    CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI || \
+    CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI
+/* Blue version (ANSI) */
+#define B_RST UK_ANSI_MOD_RESET
+#define B_TXT UK_ANSI_MOD_RESET UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_WHITE)
+#define B_LTR UK_ANSI_MOD_RESET UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_BLUE)
+#define B_HL0 UK_ANSI_MOD_BOLD  UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_RED)
+#define B_HL1 UK_ANSI_MOD_RESET UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_RED)
+#define B_HL2 UK_ANSI_MOD_BOLD  UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_BLUE)
+#define B_HL3 UK_ANSI_MOD_RESET UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_BLUE)
+#elif CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2 || \
+      CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2 || \
+      CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2
+/* Gray version (ANSI) */
+#define B_RST UK_ANSI_MOD_RESET
+#define B_TXT UK_ANSI_MOD_RESET UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_WHITE)
+#define B_LTR UK_ANSI_MOD_BOLD  UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_BLACK)
+#define B_HL0 UK_ANSI_MOD_BOLD  UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_RED)
+#define B_HL1 UK_ANSI_MOD_RESET UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_RED)
+#define B_HL2 B_TXT
+#define B_HL3 B_LTR
+#else
+/* No colors */
+#define B_RST ""
+#define B_TXT B_RST
+#define B_LTR B_RST
+#define B_HL0 B_RST
+#define B_HL1 B_RST
+#define B_HL2 B_RST
+#define B_HL3 B_RST
+#endif
+
 
 void print_banner(FILE *out) {
-#if CONFIG_LIBUKBOOT_BANNER_POWEREDBY
-	fprintf(out, "Powered by\n");
-	fprintf(out, "o.   .o       _ _               __ _\n");
-	fprintf(out, "Oo   Oo  ___ (_) | __ __  __ _ ' _) :_\n");
-	fprintf(out, "oO   oO ' _ `| | |/ /  _)' _` | |_|  _)\n");
-	fprintf(out, "oOo oOO| | | | |   (| | | (_) |  _) :_\n");
-	fprintf(out, " OoOoO ._, ._:_:_,\\_._,  .__,_:_, \\___)\n");
-	fprintf(out, "%39s\n",
+#if CONFIG_LIBUKBOOT_BANNER_POWEREDBY || \
+    CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI || \
+    CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2
+	fprintf(out, B_TXT "Powered by\n");
+	fprintf(out, B_HL2 "o" B_HL1 ".   " B_HL2 "." B_HL3 "o"
+		B_LTR "       _ _               __ _\n");
+	fprintf(out, B_HL0 "O" B_HL2 "o   " B_HL1 "O" B_HL0 "o"
+		B_LTR "  ___ (_) | __ __  __ _ ' _) :_\n");
+	fprintf(out, B_HL3 "o" B_HL0 "O   " B_HL2 "o" B_HL3 "O"
+		B_LTR " ' _ `| | |/ /  _)' _` | |_|  _)\n");
+	fprintf(out, B_HL1 "o" B_HL2 "Oo " B_HL1 "o" B_HL3 "O" B_HL1 "O"
+		B_LTR "| | | | |   (| | | (_) |  _) :_\n");
+	fprintf(out, B_HL3 " O" B_HL0 "o" B_HL3 "O" B_HL2 "o" B_HL3 "O "
+		B_LTR "._, ._:_:_,\\_._,  .__,_:_, \\___)\n");
+	fprintf(out, B_TXT "%39s" B_RST "\n",
 		STRINGIFY(UK_CODENAME) " " STRINGIFY(UK_FULLVERSION));
 
-#elif CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA
-	fprintf(out, "Powered by\n");
-	fprintf(out, "\xDF\xFE   \xFE\xDC       _ _               __ _\n");
-	fprintf(out, "\xDF\xFE   \xDF\xDC  ___ (_) | __ __  __ _ ' _) :_\n");
-	fprintf(out, "\xDC\xDF   \xDC\xFE ' _ `| | |/ /  _)' _` | |_|  _)\n");
-	fprintf(out, "\xFE\xDF\xFE \xFE\xDC\xDF| | | | |   (| | | (_) |  _) :_\n");
-	fprintf(out, " \xFE\xDC\xDF\xDC\xFE ._, ._:_:_,\\_._,  .__,_:_, \\___)\n");
-	fprintf(out, "%39s\n",
+#elif CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA ||		\
+      CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI ||	\
+      CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2
+	fprintf(out, B_TXT "Powered by\n");
+	fprintf(out, B_HL2 "\xDF" B_HL1 "\xFE   " B_HL2 "\xFE" B_HL3 "\xDC"
+		B_LTR "       _ _               __ _\n");
+	fprintf(out, B_HL0 "\xDF" B_HL2 "\xFE   " B_HL1 "\xDF" B_HL0 "\xDC"
+		B_LTR "  ___ (_) | __ __  __ _ ' _) :_\n");
+	fprintf(out, B_HL3 "\xDC" B_HL0 "\xDF   " B_HL2 "\xDC" B_HL3 "\xFE"
+		B_LTR " ' _ `| | |/ /  _)' _` | |_|  _)\n");
+	fprintf(out, B_HL1 "\xFE" B_HL2 "\xDF\xFE " B_HL1 "\xFE" B_HL3 "\xDC" B_HL1 "\xDF"
+		B_LTR "| | | | |   (| | | (_) |  _) :_\n");
+	fprintf(out, B_HL3 " \xFE" B_HL0 "\xDC" B_HL3 "\xDF" B_HL2 "\xDC" B_HL3 "\xFE "
+		B_LTR "._, ._:_:_,\\_._,  .__,_:_, \\___)\n");
+	fprintf(out, B_TXT "%39s" B_RST "\n",
 		STRINGIFY(UK_CODENAME) " " STRINGIFY(UK_FULLVERSION));
 
-#elif CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8
-	fprintf(out, "Powered by\n");
-	fprintf(out, "■▖   ▖■       _ _               __ _\n");
-	fprintf(out, "■▚   ■▞  ___ (_) | __ __  __ _ ´ _) :_\n");
-	fprintf(out, "▀■   ■▄ ´ _ `| | |/ /  _)´ _` | |_|  _)\n");
-	fprintf(out, "▄▀▄ ▗▀▄| | | | |   (| | | (_) |  _) :_\n");
-	fprintf(out, " ▚▄■▄▞ ._, ._:_:_,\\_._,  .__,_:_, \\___)\n");
-	fprintf(out, "%39s\n",
+#elif CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8 ||		\
+	CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI ||	\
+	CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2
+	fprintf(out, B_TXT "Powered by\n");
+	fprintf(out, B_HL2 "■" B_HL1 "▖   " B_HL2 "▖" B_HL3 "■"
+		B_LTR "       _ _               __ _\n");
+	fprintf(out, B_HL0 "■" B_HL2 "▚   " B_HL1 "■" B_HL0 "▞"
+		B_LTR "  ___ (_) | __ __  __ _ ´ _) :_\n");
+	fprintf(out, B_HL3 "▀" B_HL0 "■   " B_HL2 "■" B_HL3 "▄"
+		B_LTR " ´ _ `| | |/ /  _)´ _` | |_|  _)\n");
+	fprintf(out, B_HL1 "▄" B_HL2 "▀▄ " B_HL1 "▗" B_HL3 "▀" B_HL1 "▄"
+		B_LTR "| | | | |   (| | | (_) |  _) :_\n");
+	fprintf(out, B_HL3 " ▚" B_HL0 "▄" B_HL3 "■" B_HL2 "▄" B_HL3 "▞"
+		B_LTR " ._, ._:_:_,\\_._,  .__,_:_, \\___)\n");
+	fprintf(out, B_TXT "%39s" B_RST "\n",
 		STRINGIFY(UK_CODENAME) " " STRINGIFY(UK_FULLVERSION));
 
 #elif CONFIG_LIBUKBOOT_BANNER_CLASSIC
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 13:18:43 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 13:18:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHoNU-0005Lp-NZ; Mon, 14 Sep 2020 13:18:40 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=bRBf=CV=gmail.com=punitagrawal@srs-us1.protection.inumbo.net>)
 id 1kH3N5-0004jl-9h
 for minios-devel@lists.xenproject.org; Sat, 12 Sep 2020 11:07:07 +0000
X-Inumbo-ID: 5631a655-c71b-4f86-a359-a0d1076c78fc
Received: from mail-pl1-x641.google.com (unknown [2607:f8b0:4864:20::641])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 5631a655-c71b-4f86-a359-a0d1076c78fc;
 Sat, 12 Sep 2020 11:07:06 +0000 (UTC)
Received: by mail-pl1-x641.google.com with SMTP id g21so828706plq.1
 for <minios-devel@lists.xenproject.org>; Sat, 12 Sep 2020 04:07:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:user-agent:mime-version;
 bh=6NZWcgpJiW2MmWgXiBLlDZtJxaYVk44HgT08A4cm3S8=;
 b=LIlJ+qkPrMQN8embXuRw74sFUmZDz2UzGvXg6pjjHCx89WjNk7Mb/aZIKEDKLZJ1qO
 a5hNLVP9h82J0rP0sxN1fUkyOdXyLCnEjVXi9pDSQlbidguqs3KXjYbNHF2rwQzmmZdX
 MUe+vIi0zXqUnmcUZf7ScFOCqvzIz4MguN8gRGl4ejNm5Ty4BW5EBNJofy91cr44Fco+
 uEplMshxBIskrU8mVNBce3+tgyaX2YJYOxCY39jb5jNKblGczFNiUwfeM3rk0BomBd19
 lPHRBaOnyw2NOBZ5Db4gVl4gIAAPBzaWrsAhqoo3tYeGwC6DQUo2IGBSbiHQYgFgK1oL
 HHLg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent
 :mime-version;
 bh=6NZWcgpJiW2MmWgXiBLlDZtJxaYVk44HgT08A4cm3S8=;
 b=Bp6eippGc4cbGAS1Z5mRl/O35gaeR+lLTWb5oP6D1ZA8DjOrWG66uUIcSnEUjpysEM
 NoJY005yhai7u8eJgQ/11GtfqqPqOihBMc3SAQgDCZHYJRHVwU2m7qskFYF9NP1kdtJn
 KclBG8zVuqC8SSa1a7UqaFbBzlD5SMIAywnGzJ1g870B/cy28nDfxsszZn4QtshK3k2O
 mTNhzjk7+zPiDCNguYiqhcOAfkPJWIlGqvZntO5xHmjPbjZXv4Mi/hYAC87Wlz84272p
 ZPY2e6XJoj7exKu5GDFXtquhkqro+PFyQoF1U0azOqM/MaRZ2LrYl0ove+CgIMCWAz4w
 PoXQ==
X-Gm-Message-State: AOAM533HSxVAQqS69qoaeZryBR1wwtGQfMtZH1FCL40Y+caPApz3YDxw
 zl7Yx+4AeHxiD2jKkC3ywVaToY6JGe4cSw==
X-Google-Smtp-Source: ABdhPJzsOnKy8mHYI5WmTgkFEBxSTVE3OR2d8xvYp1MB0cDA1ey6IeyA1dPJy4Djio4OPb+iEJ9wfQ==
X-Received: by 2002:a17:902:b682:: with SMTP id
 c2mr5927255pls.89.1599908825489; 
 Sat, 12 Sep 2020 04:07:05 -0700 (PDT)
Received: from localhost ([2405:6580:31a1:500:a00:27ff:fe82:e36e])
 by smtp.gmail.com with ESMTPSA id c127sm4868165pfa.165.2020.09.12.04.07.04
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 12 Sep 2020 04:07:04 -0700 (PDT)
From: Punit Agrawal <punitagrawal@gmail.com>
To: minios-devel@lists.xenproject.org
Cc: unikraft@listserv.neclab.eu
Subject: Unikraft - Compile error on arm64
Date: Sat, 12 Sep 2020 19:53:01 +0900
Message-ID: <87h7s3clma.fsf@tinker>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Mailman-Approved-At: Mon, 14 Sep 2020 13:18:39 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi,

I am seeing compile errors when building hello world application on
arm64 running Debian Bullseye.

2020-09-12 09:45:55 INFO     LD      helloworld_kvm-arm64.dbg
/usr/bin/ld: /home/punit/src/unikraft/apps/helloworld/build/helloworld_kvm-arm64.o: in function `__uk_test_and_clear_bit':
/home/punit/src/unikraft/unikraft/include/uk/bitops.h:284: undefined reference to `__aarch64_ldclr1_relax'
/home/punit/src/unikraft/unikraft/include/uk/bitops.h:284:(.text+0x508): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__aarch64_ldclr1_relax'
/usr/bin/ld: /home/punit/src/unikraft/apps/helloworld/build/helloworld_kvm-arm64.o: in function `__uk_test_and_set_bit':
/home/punit/src/unikraft/unikraft/include/uk/bitops.h:328: undefined reference to `__aarch64_ldset1_relax'
/home/punit/src/unikraft/unikraft/include/uk/bitops.h:328:(.text+0x2cc0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__aarch64_ldset1_relax'
collect2: error: ld returned 1 exit status

It seems that using "-no-pie" causes the helpers for builtin atomics to
go missing on arm64. A quick hack to drop the "-no-pie" leads to
conflicts with "-r".

For reference, the compiler version is -

% gcc --version
gcc (Debian 10.2.0-6) 10.2.0

I was wondering what I am doing wrong. Any suggestions on how to resolve
this?

Thanks,
Punit


From minios-devel-bounces@lists.xenproject.org Mon Sep 14 13:47:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 13:47:49 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHopf-00085d-Lt; Mon, 14 Sep 2020 13:47:47 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHopf-00085X-9e
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 13:47:47 +0000
X-Inumbo-ID: 569bf8ce-5605-41ad-9577-cda3b2bceed1
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 569bf8ce-5605-41ad-9577-cda3b2bceed1;
 Mon, 14 Sep 2020 13:47:45 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 45994F22B1;
 Mon, 14 Sep 2020 15:47:44 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
 by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 0YanMfcWp-pg; Mon, 14 Sep 2020 15:47:44 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 0CBEBF21A7
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 15:47:42 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 15:47:41 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/APPHELLOWORLD PATCH 0/6] Monkey animation
Date: Mon, 14 Sep 2020 15:47:31 +0200
Message-ID: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch series replaces the fish animation with a moving monkey.
The monkey is colored according to the selected Unikraft banner
with ukboot.

This patch series depends on changes to the Unikraft base provided
by series 1537:
https://patchwork.unikraft.org/project/unikraft/list/?series=1537

Simon Kuenzer (6):
  Add comment to closing of feature macros (`#endif`)
  Use nanosleep
  Monkey animation
  Enable compiling main.c without Unikraft
  Monkey: Add place holders for colors
  Colored monkey with colored Unikraft banner

 main.c   |  53 +++++++------
 monkey.h | 224 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 253 insertions(+), 24 deletions(-)
 create mode 100644 monkey.h

-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 13:48:28 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 13:48:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHoqK-00087A-PE; Mon, 14 Sep 2020 13:48:28 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHoqJ-000875-Vd
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 13:48:28 +0000
X-Inumbo-ID: 0b5ef44f-b241-4ed6-89da-2f7bad9cc486
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 0b5ef44f-b241-4ed6-89da-2f7bad9cc486;
 Mon, 14 Sep 2020 13:48:26 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id B42CE103E75;
 Mon, 14 Sep 2020 15:48:25 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-a.office.hd)
Received: from mailer1.neclab.eu ([127.0.0.1])
 by localhost (atlas-a.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Dj2mHMfHOzeQ; Mon, 14 Sep 2020 15:48:25 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 93F01FFEDD
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 15:48:25 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 15:48:25 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/APPHELLOWORLD PATCH 1/6] Add comment to closing of feature
 macros (`#endif`)
Date: Mon, 14 Sep 2020 15:48:21 +0200
Message-ID: <20200914134821.18253-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
References: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: puck.office.hd (192.168.24.91) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Applies best practices for feature macros with multi-line code blocks:
Adds a comment with the corresponding feature macro name after `#endif`
directive.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c
index c442058..a0d6a73 100644
--- a/main.c
+++ b/main.c
@@ -20,13 +20,14 @@ static const char *spinner[] = {
 	" <'((<       ",
 	"<'((<        ",
 };
-#endif
+#endif /* CONFIG_APPHELLOWORLD_SPINNER */
 
 int main(int argc, char *argv[])
 {
 #if CONFIG_APPHELLOWORLD_PRINTARGS || CONFIG_APPHELLOWORLD_SPINNER
 	int i;
 #endif
+
 	printf("Hello world!\n");
 
 #if CONFIG_APPHELLOWORLD_PRINTARGS
@@ -34,7 +35,7 @@ int main(int argc, char *argv[])
 	for (i=0; i<argc; ++i)
 		printf(" \"%s\"", argv[i]);
 	printf("\n");
-#endif
+#endif /* CONFIG_APPHELLOWORLD_PRINTARGS */
 
 #if CONFIG_APPHELLOWORLD_SPINNER
 	i = 0;
@@ -44,5 +45,5 @@ int main(int argc, char *argv[])
 		printf("\r%s", spinner[i++]);
 		sleep(1);
 	}
-#endif
+#endif /* CONFIG_APPHELLOWORLD_SPINNER */
 }
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 13:48:41 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 13:48:41 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHoqX-000886-RV; Mon, 14 Sep 2020 13:48:41 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHoqX-000880-Ak
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 13:48:41 +0000
X-Inumbo-ID: d4b76a36-8bc9-427c-b3be-32333e8993df
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d4b76a36-8bc9-427c-b3be-32333e8993df;
 Mon, 14 Sep 2020 13:48:40 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id BB806F22B1;
 Mon, 14 Sep 2020 15:48:39 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
 by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 6CErGsAK8B5W; Mon, 14 Sep 2020 15:48:39 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 958C4F21A7
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 15:48:37 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 15:48:37 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/APPHELLOWORLD PATCH 2/6] Use nanosleep
Date: Mon, 14 Sep 2020 15:48:33 +0200
Message-ID: <20200914134834.18308-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
References: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Introduces `millisleep()` in order to enable shorter sleep times than in
seconds.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 main.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index a0d6a73..4d4210e 100644
--- a/main.c
+++ b/main.c
@@ -1,11 +1,13 @@
 #include <stdio.h>
-#include <unistd.h>
 #include <uk/essentials.h>
 
 /* Import user configuration: */
 #include <uk/config.h>
 
 #if CONFIG_APPHELLOWORLD_SPINNER
+#include <time.h>
+#include <errno.h>
+
 static const char *spinner[] = {
 	">))'>        ",
 	" >))'>       ",
@@ -20,6 +22,18 @@ static const char *spinner[] = {
 	" <'((<       ",
 	"<'((<        ",
 };
+
+static void millisleep(unsigned int millisec)
+{
+	struct timespec ts;
+	int ret;
+
+	ts.tv_sec = millisec / 1000;
+	ts.tv_nsec = (millisec % 1000) * 1000000;
+	do
+		ret = nanosleep(&ts, &ts);
+	while (ret && errno == EINTR);
+}
 #endif /* CONFIG_APPHELLOWORLD_SPINNER */
 
 int main(int argc, char *argv[])
@@ -43,7 +57,7 @@ int main(int argc, char *argv[])
 	while (1) {
 		i %= ARRAY_SIZE(spinner);
 		printf("\r%s", spinner[i++]);
-		sleep(1);
+		millisleep(1000);
 	}
 #endif /* CONFIG_APPHELLOWORLD_SPINNER */
 }
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 13:49:05 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 13:49:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHoqv-0008BH-EV; Mon, 14 Sep 2020 13:49:05 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHoqu-0008B6-0E
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 13:49:04 +0000
X-Inumbo-ID: c3674c81-eed9-44c3-a77a-0333aa3281e9
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c3674c81-eed9-44c3-a77a-0333aa3281e9;
 Mon, 14 Sep 2020 13:49:02 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 1517E103E75;
 Mon, 14 Sep 2020 15:49:02 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-a.office.hd)
Received: from mailer1.neclab.eu ([127.0.0.1])
 by localhost (atlas-a.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 5WYUjLvzprrI; Mon, 14 Sep 2020 15:49:01 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id E8C0AFFAD0
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 15:49:01 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 15:49:01 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/APPHELLOWORLD PATCH 3/6] Monkey animation
Date: Mon, 14 Sep 2020 15:48:58 +0200
Message-ID: <20200914134858.18414-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
References: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: puck.office.hd (192.168.24.91) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Replaces the fish animation with an animated 3-liner ASCII
monkey.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 main.c   |  30 +++-------
 monkey.h | 180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 189 insertions(+), 21 deletions(-)
 create mode 100644 monkey.h

diff --git a/main.c b/main.c
index 4d4210e..5b07817 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,4 @@
 #include <stdio.h>
-#include <uk/essentials.h>
 
 /* Import user configuration: */
 #include <uk/config.h>
@@ -7,21 +6,7 @@
 #if CONFIG_APPHELLOWORLD_SPINNER
 #include <time.h>
 #include <errno.h>
-
-static const char *spinner[] = {
-	">))'>        ",
-	" >))'>       ",
-	"  >))'>      ",
-	"   >))'>     ",
-	"    >))'o    ",
-	"     >))'>°  ",
-	"     <'((< ° ",
-	"    <'((<   '",
-	"   <'((<     ",
-	"  <'((<      ",
-	" <'((<       ",
-	"<'((<        ",
-};
+#include "monkey.h"
 
 static void millisleep(unsigned int millisec)
 {
@@ -53,11 +38,14 @@ int main(int argc, char *argv[])
 
 #if CONFIG_APPHELLOWORLD_SPINNER
 	i = 0;
-	printf("\n");
-	while (1) {
-		i %= ARRAY_SIZE(spinner);
-		printf("\r%s", spinner[i++]);
-		millisleep(1000);
+	printf("\n\n\n");
+	for (;;) {
+		i %= (monkey3_frame_count * 3);
+		printf("\r\033[2A %s \n", monkey3[i++]);
+		printf(" %s \n",          monkey3[i++]);
+		printf(" %s ",            monkey3[i++]);
+		fflush(stdout);
+		millisleep(250);
 	}
 #endif /* CONFIG_APPHELLOWORLD_SPINNER */
 }
diff --git a/monkey.h b/monkey.h
new file mode 100644
index 0000000..36c65b0
--- /dev/null
+++ b/monkey.h
@@ -0,0 +1,180 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Unikraft Monkey Animation
+ *
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation.
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MONKEY_H
+#define MONKEY_H
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif /* ARRAY_SIZE */
+
+static const char *monkey3[] = {
+	"     _               ",
+	"   c'_'o  .--'       ",
+	"   (| |)_/           ",
+
+	"     _               ",
+	"   c'o'o  .--.       ",
+	"   (| |)_/           ",
+
+	"     _               ",
+	"   c'_'o  .-.        ",
+	"   (| |)_/   `       ",
+
+	"     _               ",
+	"   c'o'o  .--.       ",
+	"   (| |)_/           ",
+
+	"     _               ",
+	"   c'_'o  .--'       ",
+	"   (| |)_/           ",
+
+	"     _               ",
+	"   c'_'o  .--.       ",
+	"   (| |)_/           ",
+
+	"     _               ",
+	"   c'_'o  .-.        ",
+	"   (| |)_/   `       ",
+
+	"     _               ",
+	"   c'_'o  .--.       ",
+	"   (| |)_/           ",
+
+	"     _               ",
+	"   c-_-o  .--'       ",
+	"   (| |)_/           ",
+
+	"     _               ",
+	"   c'_'o  .--.       ",
+	"   (| |)_/           ",
+
+	"     _               ",
+	"   c'_'o  .-.        ",
+	"   (| |)_/   `       ",
+
+	"     _               ",
+	"   c'_'o  .--.       ",
+	"   (| |)_/           ",
+
+	".---    _            ",
+	"`--,___c \".          ",
+	"   (,--( \\           ",
+
+	".--      _           ",
+	"`---,___c \".         ",
+	"    ( \\-(,           ",
+
+	".-        _          ",
+	"`---'\\___c \".        ",
+	"     (,--( \\         ",
+
+	".    _     _         ",
+	"`---' \\___c \".       ",
+	"      ( \\-(,         ",
+
+	"     _      _        ",
+	"`---' `,___c \".      ",
+	"       (,--( \\       ",
+
+	"     _       _       ",
+	" ---' `-,___c \".     ",
+	"        ( \\-(,       ",
+
+	"     _        _      ",
+	"  --' `--,___c \".    ",
+	"         (,--( \\     ",
+
+	"     _         _     ",
+	"   -' `---,___c \".   ",
+	"          ( \\-(,     ",
+
+	"     _          _    ",
+	"    ' `---'\\___c \".  ",
+	"           (,--( \\   ",
+
+	"     _     _     _   ",
+	"      `---' \\___c \". ",
+	"            ( \\-(,   ",
+
+	"           _    _    ",
+	"      `---' | c   o  ",
+	"            \\_(|,|)  ",
+
+	"             _  .---.",
+	"           .\" o___,-'",
+	"            / )--,)  ",
+
+	"            _    ---.",
+	"          .\" o___,--'",
+	"            ,)-/ )   ",
+
+	"           _      --.",
+	"         .\" o___,---'",
+	"          / )--,)    ",
+
+	"          _        -.",
+	"        .\" o___/`---'",
+	"          ,)-/ )     ",
+
+	"         _     _    .",
+	"       .\" o___/ `---'",
+	"        / )--,)      ",
+
+	"        _      _     ",
+	"      .\" o___,' `---'",
+	"        ,)-/ )       ",
+
+	"       _       _     ",
+	"     .\" o___,-' `--- ",
+	"      / )--,)        ",
+
+	"      _        _     ",
+	"    .\" o___,--' `--  ",
+	"      ,)-/ )         ",
+
+	"     _         _     ",
+	"   .\" o___,---' `-   ",
+	"     / )-,)          ",
+
+	"    _          _     ",
+	"  .\" o___,----' `    ",
+	"    ,)-/ )           ",
+};
+
+#define monkey3_frame_count (ARRAY_SIZE(monkey3) / 3)
+
+#endif /* MONKEY_H */
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 13:49:18 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 13:49:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHor8-0008Ds-IF; Mon, 14 Sep 2020 13:49:18 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHor7-0008De-55
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 13:49:17 +0000
X-Inumbo-ID: bbb89bcb-00d8-4ce8-ad33-e54b4f18bca7
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id bbb89bcb-00d8-4ce8-ad33-e54b4f18bca7;
 Mon, 14 Sep 2020 13:49:14 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 991DF103E75;
 Mon, 14 Sep 2020 15:49:13 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-a.office.hd)
Received: from mailer1.neclab.eu ([127.0.0.1])
 by localhost (atlas-a.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id vatGASPV9K4Q; Mon, 14 Sep 2020 15:49:13 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 72369FFAD0
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 15:49:13 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 15:49:13 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/APPHELLOWORLD PATCH 4/6] Enable compiling main.c without
 Unikraft
Date: Mon, 14 Sep 2020 15:49:10 +0200
Message-ID: <20200914134910.18469-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
References: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Enables compiling the "Hello World" application directly with gcc:
`gcc main.c`. This is for demo purposes.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/main.c b/main.c
index 5b07817..0a14cb0 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,9 @@
 #include <stdio.h>
 
 /* Import user configuration: */
+#ifdef __Unikraft__
 #include <uk/config.h>
+#endif /* __Unikraft__ */
 
 #if CONFIG_APPHELLOWORLD_SPINNER
 #include <time.h>
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 13:49:42 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 13:49:42 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHorW-0008Fe-L4; Mon, 14 Sep 2020 13:49:42 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHorV-0008FZ-Pf
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 13:49:41 +0000
X-Inumbo-ID: c7451bbb-9169-4a2c-9ed0-636f26cd9a9b
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c7451bbb-9169-4a2c-9ed0-636f26cd9a9b;
 Mon, 14 Sep 2020 13:49:40 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id BE988F22B1;
 Mon, 14 Sep 2020 15:49:39 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
 by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id hhBrV1D4Uiuv; Mon, 14 Sep 2020 15:49:39 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 96114F21A7
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 15:49:37 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 15:49:37 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/APPHELLOWORLD PATCH 5/6] Monkey: Add place holders for
 colors
Date: Mon, 14 Sep 2020 15:49:34 +0200
Message-ID: <20200914134934.18579-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
References: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: puck.office.hd (192.168.24.91) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Adds place holder macros for coloring the monkey with
escape sequences.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 monkey.h | 207 +++++++++++++++++++++++++++++--------------------------
 1 file changed, 108 insertions(+), 99 deletions(-)

diff --git a/monkey.h b/monkey.h
index 36c65b0..ee079f5 100644
--- a/monkey.h
+++ b/monkey.h
@@ -41,138 +41,147 @@
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #endif /* ARRAY_SIZE */
 
+#ifndef MONKEY_COLORS
+/* No colors */
+#define MC_RST   ""
+#define MC_BODY  MC_RST
+#define MC_FACE  MC_RST
+#define MC_EYE   MC_RST
+#define MC_MOUTH MC_RST
+#endif /* !MONKEY_COLORS */
+
 static const char *monkey3[] = {
-	"     _               ",
-	"   c'_'o  .--'       ",
-	"   (| |)_/           ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "_" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".--'" MC_RST "       ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "           ",
 
-	"     _               ",
-	"   c'o'o  .--.       ",
-	"   (| |)_/           ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "o" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".--." MC_RST "       ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "           ",
 
-	"     _               ",
-	"   c'_'o  .-.        ",
-	"   (| |)_/   `       ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "_" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".-." MC_RST "        ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "   " MC_BODY "`" MC_RST "       ",
 
-	"     _               ",
-	"   c'o'o  .--.       ",
-	"   (| |)_/           ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "o" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".--." MC_RST "       ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "           ",
 
-	"     _               ",
-	"   c'_'o  .--'       ",
-	"   (| |)_/           ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "_" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".--'" MC_RST "       ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "           ",
 
-	"     _               ",
-	"   c'_'o  .--.       ",
-	"   (| |)_/           ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "_" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".--." MC_RST "       ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "           ",
 
-	"     _               ",
-	"   c'_'o  .-.        ",
-	"   (| |)_/   `       ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "_" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".-." MC_RST "        ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "   " MC_BODY "`" MC_RST "       ",
 
-	"     _               ",
-	"   c'_'o  .--.       ",
-	"   (| |)_/           ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "_" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".--." MC_RST "       ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "           ",
 
-	"     _               ",
-	"   c-_-o  .--'       ",
-	"   (| |)_/           ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c-" MC_MOUTH "_" MC_FACE "-o" MC_RST "  " MC_BODY ".--'" MC_RST "       ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "           ",
 
-	"     _               ",
-	"   c'_'o  .--.       ",
-	"   (| |)_/           ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "_" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".--." MC_RST "       ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "           ",
 
-	"     _               ",
-	"   c'_'o  .-.        ",
-	"   (| |)_/   `       ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "_" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".-." MC_RST "        ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "   " MC_BODY "`" MC_RST "       ",
 
-	"     _               ",
-	"   c'_'o  .--.       ",
-	"   (| |)_/           ",
+	MC_RST "     " MC_BODY "_" MC_RST "               ",
+	MC_RST "   " MC_FACE "c" MC_EYE "'" MC_MOUTH "_" MC_EYE "'" MC_FACE "o" MC_RST "  " MC_BODY ".--." MC_RST "       ",
+	MC_RST "   " MC_BODY "(| |)_/" MC_RST "           ",
 
-	".---    _            ",
-	"`--,___c \".          ",
-	"   (,--( \\           ",
+	MC_BODY ".---" MC_RST "    " MC_BODY "_" MC_RST "            ",
+	MC_BODY "`--,___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST "          ",
+	MC_RST "   " MC_BODY "(,--( \\" MC_RST "           ",
 
-	".--      _           ",
-	"`---,___c \".         ",
-	"    ( \\-(,           ",
+	MC_BODY ".--" MC_RST "      " MC_BODY "_" MC_RST "           ",
+	MC_BODY "`---,___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST "         ",
+	MC_RST "    " MC_BODY "( \\-(," MC_RST "           ",
 
-	".-        _          ",
-	"`---'\\___c \".        ",
-	"     (,--( \\         ",
+	MC_BODY ".-" MC_RST "        " MC_BODY "_" MC_RST "          ",
+	MC_BODY "`---'\\___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST "        ",
+	MC_RST "     " MC_BODY "(,--( \\" MC_RST "         ",
 
-	".    _     _         ",
-	"`---' \\___c \".       ",
-	"      ( \\-(,         ",
+	MC_BODY "." MC_RST "    " MC_BODY "_" MC_RST "     " MC_BODY "_" MC_RST "         ",
+	MC_BODY "`---'" MC_RST " " MC_BODY "\\___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST "       ",
+	MC_RST "      " MC_BODY "( \\-(," MC_RST "         ",
 
-	"     _      _        ",
-	"`---' `,___c \".      ",
-	"       (,--( \\       ",
+	MC_RST "     " MC_BODY "_" MC_RST "      " MC_BODY "_" MC_RST "        ",
+	MC_BODY "`---'" MC_RST " " MC_BODY "`,___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST "      ",
+	MC_RST "       " MC_BODY "(,--( \\" MC_RST "       ",
 
-	"     _       _       ",
-	" ---' `-,___c \".     ",
-	"        ( \\-(,       ",
+	MC_RST "     " MC_BODY "_" MC_RST "       " MC_BODY "_" MC_RST "       ",
+	MC_RST " " MC_BODY "---'" MC_RST " " MC_BODY "`-,___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST "     ",
+	MC_RST "        " MC_BODY "( \\-(," MC_RST "       ",
 
-	"     _        _      ",
-	"  --' `--,___c \".    ",
-	"         (,--( \\     ",
+	MC_RST "     " MC_BODY "_" MC_RST "        " MC_BODY "_" MC_RST "      ",
+	MC_RST "  " MC_BODY "--'" MC_RST " " MC_BODY "`--,___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST "    ",
+	MC_RST "         " MC_BODY "(,--( \\" MC_RST "     ",
 
-	"     _         _     ",
-	"   -' `---,___c \".   ",
-	"          ( \\-(,     ",
+	MC_RST "     " MC_BODY "_" MC_RST "         " MC_BODY "_" MC_RST "     ",
+	MC_RST "   " MC_BODY "-'" MC_RST " " MC_BODY "`---,___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST "   ",
+	MC_RST "          " MC_BODY "( \\-(," MC_RST "     ",
 
-	"     _          _    ",
-	"    ' `---'\\___c \".  ",
-	"           (,--( \\   ",
+	MC_RST "     " MC_BODY "_" MC_RST "          " MC_BODY "_" MC_RST "    ",
+	MC_RST "    " MC_BODY "'" MC_RST " " MC_BODY "`---'\\___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST "  ",
+	MC_RST "           " MC_BODY "(,--( \\" MC_RST "   ",
 
-	"     _     _     _   ",
-	"      `---' \\___c \". ",
-	"            ( \\-(,   ",
+	MC_RST "     " MC_BODY "_" MC_RST "     " MC_BODY "_" MC_RST "     " MC_BODY "_" MC_RST "   ",
+	MC_RST "      " MC_BODY "`---'" MC_RST " " MC_BODY "\\___" MC_FACE "c " MC_EYE "\"" MC_MOUTH "." MC_RST " ",
+	MC_RST "            " MC_BODY "( \\-(," MC_RST "   ",
 
-	"           _    _    ",
-	"      `---' | c   o  ",
-	"            \\_(|,|)  ",
+	MC_RST "           " MC_BODY "_" MC_RST "    " MC_BODY "_" MC_RST "    ",
+	MC_RST "      " MC_BODY "`---'" MC_RST " " MC_BODY "|" MC_RST " " MC_FACE "c" MC_BODY "   " MC_FACE "o" MC_RST "  ",
+	MC_RST "            " MC_BODY "\\_(|,|)" MC_RST "  ",
 
-	"             _  .---.",
-	"           .\" o___,-'",
-	"            / )--,)  ",
+	MC_RST "             " MC_BODY "_" MC_RST "  " MC_BODY ".---." MC_RST,
+	MC_RST "           " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___,-'" MC_RST,
+	MC_RST "            " MC_BODY "/ )--,)" MC_RST "  ",
 
-	"            _    ---.",
-	"          .\" o___,--'",
-	"            ,)-/ )   ",
+	MC_RST "            " MC_BODY "_" MC_RST "    " MC_BODY "---." MC_RST,
+	MC_RST "          " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___,--'" MC_RST,
+	MC_RST "            " MC_BODY ",)-/ )" MC_RST "   ",
 
-	"           _      --.",
-	"         .\" o___,---'",
-	"          / )--,)    ",
+	MC_RST "           " MC_BODY "_" MC_RST "      " MC_BODY "--." MC_RST,
+	MC_RST "         " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___,---'" MC_RST,
+	MC_RST "          " MC_BODY "/ )--,)" MC_RST "    ",
 
-	"          _        -.",
-	"        .\" o___/`---'",
-	"          ,)-/ )     ",
+	MC_RST "          " MC_BODY "_" MC_RST "        " MC_BODY "-." MC_RST,
+	MC_RST "        " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___/`---'" MC_RST,
+	MC_RST "          " MC_BODY ",)-/ )" MC_RST "     ",
 
-	"         _     _    .",
-	"       .\" o___/ `---'",
-	"        / )--,)      ",
+	MC_RST "         " MC_BODY "_" MC_RST "     " MC_BODY "_" MC_RST "    " MC_BODY "." MC_RST,
+	MC_RST "       " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___/" MC_RST " " MC_BODY "`---'" MC_RST,
+	MC_RST "        " MC_BODY "/ )--,)" MC_RST "      ",
 
-	"        _      _     ",
-	"      .\" o___,' `---'",
-	"        ,)-/ )       ",
+	MC_RST "        " MC_BODY "_" MC_RST "      " MC_BODY "_" MC_RST "     ",
+	MC_RST "      " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___,'" MC_RST " " MC_BODY "`---'" MC_RST,
+	MC_RST "        " MC_BODY ",)-/ )" MC_RST "       ",
 
-	"       _       _     ",
-	"     .\" o___,-' `--- ",
-	"      / )--,)        ",
+	MC_RST "       " MC_BODY "_" MC_RST "       " MC_BODY "_" MC_RST "     ",
+	MC_RST "     " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___,-'" MC_RST " " MC_BODY "`---" MC_RST " ",
+	MC_RST "      " MC_BODY "/ )--,)" MC_RST "        ",
 
-	"      _        _     ",
-	"    .\" o___,--' `--  ",
-	"      ,)-/ )         ",
+	MC_RST "      " MC_BODY "_" MC_RST "        " MC_BODY "_" MC_RST "     ",
+	MC_RST "    " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___,--'" MC_RST " " MC_BODY "`--" MC_RST "  ",
+	MC_RST "      " MC_BODY ",)-/ )" MC_RST "         ",
 
-	"     _         _     ",
-	"   .\" o___,---' `-   ",
-	"     / )-,)          ",
+	MC_RST "     " MC_BODY "_" MC_RST "         " MC_BODY "_" MC_RST "     ",
+	MC_RST "   " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___,---'" MC_RST " " MC_BODY "`-" MC_RST "   ",
+	MC_RST "     " MC_BODY "/ )-,)" MC_RST "          ",
 
-	"    _          _     ",
-	"  .\" o___,----' `    ",
-	"    ,)-/ )           ",
+	MC_RST "    " MC_BODY "_" MC_RST "          " MC_BODY "_" MC_RST "     ",
+	MC_RST "  " MC_MOUTH "." MC_EYE "\"" MC_FACE " o" MC_BODY "___,----'" MC_RST " " MC_BODY "`" MC_RST "    ",
+	MC_RST "    " MC_BODY ",)-/ )" MC_RST "           ",
 };
 
 #define monkey3_frame_count (ARRAY_SIZE(monkey3) / 3)
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 14 13:49:54 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 14 Sep 2020 13:49:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kHori-0008Hx-1v; Mon, 14 Sep 2020 13:49:54 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TRLV=CX=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kHorg-0008HR-Bs
 for minios-devel@lists.xen.org; Mon, 14 Sep 2020 13:49:52 +0000
X-Inumbo-ID: d107b978-916e-458b-9606-2cca7a36e7c0
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d107b978-916e-458b-9606-2cca7a36e7c0;
 Mon, 14 Sep 2020 13:49:51 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 6F643104022;
 Mon, 14 Sep 2020 15:49:50 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-a.office.hd)
Received: from mailer1.neclab.eu ([127.0.0.1])
 by localhost (atlas-a.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id WKuZ7UOFkrWJ; Mon, 14 Sep 2020 15:49:50 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 4F078103E75
 for <minios-devel@lists.xen.org>; Mon, 14 Sep 2020 15:49:50 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 14 Sep
 2020 15:49:50 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/APPHELLOWORLD PATCH 6/6] Colored monkey with colored
 Unikraft banner
Date: Mon, 14 Sep 2020 15:49:46 +0200
Message-ID: <20200914134946.18642-1-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
References: <20200914134737.18184-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To puck.office.hd
 (192.168.24.91)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Color monkey with ANSI control sequences when the Unikraft banner (shown by
lib/ukboot) was colored, too.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 monkey.h | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/monkey.h b/monkey.h
index ee079f5..017fc23 100644
--- a/monkey.h
+++ b/monkey.h
@@ -37,10 +37,45 @@
 #ifndef MONKEY_H
 #define MONKEY_H
 
+#ifdef __Unikraft__
+#include <uk/config.h>
+#include <uk/plat/console.h>
+#endif /* __Unikraft__ */
+
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #endif /* ARRAY_SIZE */
 
+#if !MONKEY_COLORS && __Unikraft__
+#if CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI || \
+    CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI || \
+    CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI
+/*
+ * Gray monkey for blue Unikraft logo
+ */
+#define MC_RST   UK_ANSI_MOD_RESET
+#define MC_BODY  MC_RST UK_ANSI_MOD_BOLD UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_BLACK)
+#define MC_FACE  MC_RST UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_WHITE)
+#define MC_EYE   MC_RST /* terminal default color */
+#define MC_MOUTH MC_FACE
+#define MONKEY_COLORS
+
+#elif CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2 || \
+      CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2 || \
+      CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2
+/*
+ * Brown monkey for gray Unikraft logo
+ */
+#define MC_RST   UK_ANSI_MOD_RESET
+#define MC_BODY  MC_RST UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_YELLOW)
+#define MC_FACE  MC_RST UK_ANSI_MOD_BOLD UK_ANSI_MOD_COLORFG(UK_ANSI_COLOR_YELLOW)
+#define MC_EYE   MC_RST /* terminal default color */
+#define MC_MOUTH MC_FACE
+#define MONKEY_COLORS
+
+#endif
+#endif /* !MONKEY_COLORS && __Unikraft__ */
+
 #ifndef MONKEY_COLORS
 /* No colors */
 #define MC_RST   ""
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Fri Sep 18 08:51:20 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 18 Sep 2020 08:51:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kJC6t-0007Ui-4g; Fri, 18 Sep 2020 08:51:15 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=pNnR=C3=gmail.com=razvand@srs-us1.protection.inumbo.net>)
 id 1kJC6s-0007Ua-Aa
 for minios-devel@lists.xenproject.org; Fri, 18 Sep 2020 08:51:14 +0000
X-Inumbo-ID: 320e6b9f-0dca-4a93-8464-c8d71b0ec22a
Received: from mail-wm1-x32f.google.com (unknown [2a00:1450:4864:20::32f])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 320e6b9f-0dca-4a93-8464-c8d71b0ec22a;
 Fri, 18 Sep 2020 08:51:11 +0000 (UTC)
Received: by mail-wm1-x32f.google.com with SMTP id w2so4527163wmi.1
 for <minios-devel@lists.xenproject.org>; Fri, 18 Sep 2020 01:51:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=/xrastMVlhniVYzu4nqbHkDT38KkggfSJ7arEHWIl74=;
 b=ViF/X8cQOKPq2n6w1i9e+1m3uzVfLPf59Jiao1gKCgJ+4ib7XD6Ja1wFecAWoWhZz8
 tWJhKwto07kIbftKTYdIJ2uYqZK0pqFkLd5ToOQ6hDyErJnZ5JZEHl4qlVDMG/qmdEBF
 Sd8uI3laYM2ac8Lo1tWozQ5ONLyljUutZ/Q2su9s9DvxP8xDcStZUhxgZaPH7hVPku0X
 tomkxT3lfQ/WqURuMTi4zaRYpxDUaxsst6k8iRpWjhuMVaV6M4iVHIucU1rB3qlUtAbz
 vhdjTb7xaj6vk5dnnqBtVqCyKWwgy9r3pa62NCohvjJwL8IZhBJYj1ZxVRND55PidGKA
 mSZw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:from:to:cc:subject:references:date
 :in-reply-to:message-id:user-agent:mime-version;
 bh=/xrastMVlhniVYzu4nqbHkDT38KkggfSJ7arEHWIl74=;
 b=ffaVtIluyP7hM9CTwT1+2hpovdXfeRMrdr1G7ygwILaPIQ3/noMegRjlTlI2fTrCK6
 YXDNQX/rAK4t+SLc2RZJ3b+/IFwPQy8Gz63EExxPpjSuF1O+9N2kyLSlUikfutTEtAWD
 Ep66foVXxlH16bjNdm3jKktuae7RkBN18SqdIzaf9eJiDIt0dl3+5cTAs1FIc5dCUn7c
 cD0yacuDhYZL13BzHP6RZRGx0FMkyP6Gpj9/o0deuzSMSnFmEoC8Wbt0DF3IO+gWBp2z
 1cCwBhXHlhfJffIKr/94yoO+5FRuQHoOcK4fmJpA5tlcqWe9JfehuDKjRkOFnxjIoiZC
 JE5g==
X-Gm-Message-State: AOAM530B4M4yihRR6BM65OMt0Wd63THBBJwkDfM5G9bGTuMvUqjcBJU9
 UWOIYPe5EWBWYN2vA/rOLrQ=
X-Google-Smtp-Source: ABdhPJxWrnu26pDbhdFWDnUl3ySIcrgHdnxnPezLX4rwS3IKABL345zPmpEwmf8wgm7ij1CT71SdDQ==
X-Received: by 2002:a1c:80cd:: with SMTP id
 b196mr14502052wmd.104.1600419069954; 
 Fri, 18 Sep 2020 01:51:09 -0700 (PDT)
Received: from localhost ([141.85.233.147])
 by smtp.gmail.com with ESMTPSA id i16sm3912781wrq.73.2020.09.18.01.51.08
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Fri, 18 Sep 2020 01:51:08 -0700 (PDT)
From: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
To: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
Cc: <minios-devel@lists.xenproject.org>
Subject: Re: [UNIKRAFT/LIBTINYALLOC PATCH] Initial port of tinyalloc to
 Unikraft
References: <cover.1593602546.git.hugo.lefeuvre@neclab.eu>
 <41d946015ecaa34e0f93ebc433506d95fb7f9469.1593602546.git.hugo.lefeuvre@neclab.eu>
Date: Fri, 18 Sep 2020 11:51:07 +0300
In-Reply-To: <41d946015ecaa34e0f93ebc433506d95fb7f9469.1593602546.git.hugo.lefeuvre@neclab.eu>
 (Hugo Lefeuvre's message of "Wed, 1 Jul 2020 13:26:10 +0200")
Message-ID: <86lfh779j8.fsf@drone.cs.pub.ro>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi, Hugo.

I tested tinyalloc on linuxu and KVM, it works.

Why did you name the structure "struct tinyalloc", without the uk_
prefix as is the case with the other allocators (i.e. "struct
uk_bbpalloc" and "struct uk_allocregion").

When selecting tinyalloc in the configuration screen, the malloc
compatibility interface should also be automatically selected. It's not
obvious it has to be selected and one may miss it.

There's another comment inline.

Razvan

Hugo Lefeuvre <hugo.lefeuvre@neclab.eu> writes:
> Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> ---
>  Config.uk                                          |  32 +++
>  Makefile.uk                                        |  73 +++++
>  glue.c                                             | 101 +++++++
>  include/uk/tinyalloc.h                             |  48 ++++
>  main-tree.patch                                    |  45 +++
>  .../0001-do-not-store-heap-info-statically.patch   | 312 +++++++++++++++++++++
>  6 files changed, 611 insertions(+)
>  create mode 100644 Config.uk
>  create mode 100644 Makefile.uk
>  create mode 100644 glue.c
>  create mode 100644 include/uk/tinyalloc.h
>  create mode 100644 main-tree.patch
>  create mode 100644 patches/0001-do-not-store-heap-info-statically.patch
>
> diff --git a/Config.uk b/Config.uk
> new file mode 100644
> index 0000000..4b9d127
> --- /dev/null
> +++ b/Config.uk
> @@ -0,0 +1,32 @@
> +menuconfig LIBTINYALLOC
> +	   bool "tinyalloc - sequential fit, linked list based tiny allocator"
> +	   default y
> +
> +if LIBTINYALLOC
> +	config LIBTINYALLOC_DISABLE_SPLIT
> +		bool "Disable block splitting"
> +		default n
> +		help
> +			If splitting is enabled, split blocks according to split
> +			threshold.
> +
> +	config LIBTINYALLOC_DISABLE_COMPACT
> +		bool "Disable block compaction"
> +		default n
> +		help
> +			If compaction is enabled, sort blocks into the free
> +			list, merge if appropriate. Otherwise blocks are just
> +			added as new head of the free list.
> +
> +	config LIBTINYALLOC_HEAP_BLOCKS
> +		int "Number of available heap blocks"
> +		default 2048
> +
> +	config LIBTINYALLOC_SPLIT_THRESH
> +		int "Split threshold, in bytes"
> +		default 16
> +
> +	config LIBTINYALLOC_ALIGNMENT
> +		int "Standard allocation alignment, in bytes"
> +		default 8
> +endif
> diff --git a/Makefile.uk b/Makefile.uk
> new file mode 100644
> index 0000000..21aa8fe
> --- /dev/null
> +++ b/Makefile.uk
> @@ -0,0 +1,73 @@
> +#  libtinyalloc Makefile.uc
> +#
> +#  Authors: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> +#
> +#  Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
> +#
> +#  Redistribution and use in source and binary forms, with or without
> +#  modification, are permitted provided that the following conditions
> +#  are met:
> +#
> +#  1. Redistributions of source code must retain the above copyright
> +#     notice, this list of conditions and the following disclaimer.
> +#  2. Redistributions in binary form must reproduce the above copyright
> +#     notice, this list of conditions and the following disclaimer in the
> +#     documentation and/or other materials provided with the distribution.
> +#  3. Neither the name of the copyright holder nor the names of its
> +#     contributors may be used to endorse or promote products derived from
> +#     this software without specific prior written permission.
> +#
> +#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> +#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> +#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> +#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> +#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> +#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> +#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> +#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> +#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> +#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> +#  POSSIBILITY OF SUCH DAMAGE.
> +
> +################################################################################
> +# Library registration
> +################################################################################
> +$(eval $(call addlib_s,libtinyalloc,$(CONFIG_LIBTINYALLOC)))
> +
> +################################################################################
> +# Sources
> +################################################################################
> +LIBTINYALLOC_VERSION=96450f32d80fe7d23f6aa5426046143e57801bc4
> +LIBTINYALLOC_URL=https://github.com/thi-ng/tinyalloc/archive/$(LIBTINYALLOC_VERSION).zip
> +LIBTINYALLOC_DIR=tinyalloc-$(LIBTINYALLOC_VERSION)
> +
> +LIBTINYALLOC_PATCHDIR=$(LIBTINYALLOC_BASE)/patches
> +$(eval $(call fetch,libtinyalloc,$(LIBTINYALLOC_URL),$(LIBTINYALLOC_VERSION).zip))
> +$(eval $(call patch,libtinyalloc,$(LIBTINYALLOC_PATCHDIR),$(LIBTINYALLOC_DIR)))
> +
> +################################################################################
> +# Helpers
> +################################################################################
> +LIBTINYALLOC=$(LIBTINYALLOC_ORIGIN)/$(LIBTINYALLOC_DIR)
> +
> +################################################################################
> +# Library includes
> +################################################################################
> +CINCLUDES-$(CONFIG_LIBTINYALLOC) += -I$(LIBTINYALLOC_BASE)     \
> +                                    -I$(LIBTINYALLOC_BASE)/include \
> +			            -I$(LIBTINYALLOC)
> +
> +################################################################################
> +# Global flags
> +################################################################################
> +#LIBTINYALLOC_CFLAGS-y += -D_POSIX_SOURCE -D_GNU_SOURCE -D__GNU__
> +
> +################################################################################
> +# Glue code
> +################################################################################
> +LIBTINYALLOC_SRCS-y += $(LIBTINYALLOC_BASE)/glue.c
> +
> +################################################################################
> +# Sources
> +################################################################################
> +LIBTINYALLOC_SRCS-y += $(LIBTINYALLOC)/tinyalloc.c
> diff --git a/glue.c b/glue.c
> new file mode 100644
> index 0000000..9266e92
> --- /dev/null
> +++ b/glue.c
> @@ -0,0 +1,101 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Authors: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> + *
> + * Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of the copyright holder nor the names of its
> + *    contributors may be used to endorse or promote products derived from
> + *    this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> + * POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#include <uk/tinyalloc.h>
> +#include <uk/alloc_impl.h>
> +#include <string.h> /* for memset */
> +#include <tinyalloc.h>
> +
> +static void *uk_tinyalloc_malloc(struct uk_alloc *a, size_t size)
> +{
> +	struct tinyalloc *b;
> +
> +	b = (struct tinyalloc *)&a->priv;
> +	return ta_alloc(b, size);
> +}
> +
> +static void uk_tinyalloc_free(struct uk_alloc *a, void *ptr)
> +{
> +	struct tinyalloc *b;
> +
> +	b = (struct tinyalloc *)&a->priv;
> +	ta_free(b, ptr);
> +}
> +
> +/* initialization */
> +
> +struct uk_alloc *uk_tinyalloc_init(void *base, size_t len)
> +{
> +	struct uk_alloc *a;
> +	struct tinyalloc *b;
> +	size_t metalen;
> +
> +	/* TODO: This port does not support multiple memory regions yet. Because
> +	 * of the multiboot layout, the first region might be a single page, so
> +	 * we simply ignore it.
> +	 */
> +	if (len <= __PAGE_SIZE)
> +		return NULL;
> +
> +	/* Allocate space for allocator descriptor */
> +	metalen = sizeof(*a) + sizeof(*b);
> +
> +	/* enough space for allocator available? */
> +	if (metalen > len) {
> +		uk_pr_err("Not enough space for allocator: %"__PRIsz
> +			  " B required but only %"__PRIuptr" B usable\n",
> +			  metalen, len);
> +		return NULL;
> +	}
> +
> +	/* store allocator metadata on the heap, just before the memory pool */
> +	a = (struct uk_alloc *)base;
> +	b = (struct tinyalloc *)&a->priv;
> +	memset(a, 0, metalen);
> +
> +	uk_pr_info("Initialize tinyalloc allocator @ 0x%" __PRIuptr ", len %"
> +			__PRIsz"\n", (uintptr_t)a, len);
> +
> +	ta_init(b, base + metalen, base + len, CONFIG_LIBTINYALLOC_HEAP_BLOCKS,
> +		CONFIG_LIBTINYALLOC_SPLIT_THRESH,
> +		CONFIG_LIBTINYALLOC_ALIGNMENT);
> +
> +	if (!a) {
> +		uk_pr_err("Failed to allocate memory for uk_alloc structure!\n");
> +		return NULL;
> +	}

Shouldn't this be if (!b)?

> +	uk_alloc_init_malloc_ifmalloc(a, uk_tinyalloc_malloc,
> +					 uk_tinyalloc_free, NULL);
> +
> +	return a;
> +}
> diff --git a/include/uk/tinyalloc.h b/include/uk/tinyalloc.h
> new file mode 100644
> index 0000000..87290ed
> --- /dev/null
> +++ b/include/uk/tinyalloc.h
> @@ -0,0 +1,48 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Authors: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> + *
> + * Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of the copyright holder nor the names of its
> + *    contributors may be used to endorse or promote products derived from
> + *    this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> + * POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#ifndef __LIBTINYALLOC_H__
> +#define __LIBTINYALLOC_H__
> +
> +#include <uk/alloc.h>
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +struct uk_alloc *uk_tinyalloc_init(void *base, size_t len);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* __LIBTINYALLOC_H__ */
> diff --git a/main-tree.patch b/main-tree.patch
> new file mode 100644
> index 0000000..40bb096
> --- /dev/null
> +++ b/main-tree.patch
> @@ -0,0 +1,45 @@
> +From: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> +Subject: Add tinyalloc entry to the menuconfig and initialize it
> +diff --git a/lib/ukboot/Config.uk b/lib/ukboot/Config.uk
> +index a888bc1c..694762fa 100644
> +--- a/lib/ukboot/Config.uk
> ++++ b/lib/ukboot/Config.uk
> +@@ -32,6 +32,16 @@ if LIBUKBOOT
> + 		  Satisfy allocation as fast as possible. No support for free().
> + 		  Refer to help in ukallocregion for more information.
> + 
> ++		config LIBUKBOOT_INITTINYALLOC
> ++		bool "tinyalloc"
> ++		select LIBTINYALLOC
> ++		help
> ++		  Minimalist allocator implementation, meant for use in systems
> ++		  with unmanaged linear memory such as WebAssembly or embedded
> ++		  systems. tinyalloc is highly configurable and offers high
> ++		  performance and reasonable memory usage when used and
> ++		  configured appropriately.
> ++
> + 		config LIBUKBOOT_NOALLOC
> + 		bool "No memory allocator"
> + 
> +diff --git a/lib/ukboot/boot.c b/lib/ukboot/boot.c
> +index 4e749aa5..b8bf0a20 100644
> +--- a/lib/ukboot/boot.c
> ++++ b/lib/ukboot/boot.c
> +@@ -45,6 +45,8 @@
> + #include <uk/allocbbuddy.h>
> + #elif CONFIG_LIBUKBOOT_INITREGION
> + #include <uk/allocregion.h>
> ++#elif CONFIG_LIBUKBOOT_INITTINYALLOC
> ++#include <uk/tinyalloc.h>
> + #endif
> + #if CONFIG_LIBUKSCHED
> + #include <uk/sched.h>
> +@@ -233,6 +235,8 @@ void ukplat_entry(int argc, char *argv[])
> + 			a = uk_allocbbuddy_init(md.base, md.len);
> + #elif CONFIG_LIBUKBOOT_INITREGION
> + 			a = uk_allocregion_init(md.base, md.len);
> ++#elif CONFIG_LIBUKBOOT_INITTINYALLOC
> ++			a = uk_tinyalloc_init(md.base, md.len);
> + #endif
> + 		} else {
> + 			uk_alloc_addmem(a, md.base, md.len);
> diff --git a/patches/0001-do-not-store-heap-info-statically.patch b/patches/0001-do-not-store-heap-info-statically.patch
> new file mode 100644
> index 0000000..fd7b953
> --- /dev/null
> +++ b/patches/0001-do-not-store-heap-info-statically.patch
> @@ -0,0 +1,312 @@
> +From: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> +Subject: Adapt tinyalloc interface to Unikraft
> + - avoid statics: create a struct tinyalloc to store allocator metadata
> + - pass struct metadata as argument to allocation functions
> +diff -urNp tinyalloc-orig/tinyalloc.c tinyalloc-patched/tinyalloc.c
> +--- tinyalloc-orig/tinyalloc.c	2019-08-17 23:56:45.000000000 +0200
> ++++ tinyalloc-patched/tinyalloc.c	2020-06-30 10:34:24.945558078 +0200
> +@@ -9,36 +9,16 @@ extern void print_i(size_t);
> + #define print_i(X)
> + #endif
> + 
> +-typedef struct Block Block;
> +-
> +-struct Block {
> +-    void *addr;
> +-    Block *next;
> +-    size_t size;
> +-};
> +-
> +-typedef struct {
> +-    Block *free;   // first free block
> +-    Block *used;   // first used block
> +-    Block *fresh;  // first available blank block
> +-    size_t top;    // top free addr
> +-    Block *blocks;
> +-} Heap;
> +-
> +-static Heap *heap = NULL;
> +-static void *heap_limit = NULL;
> +-static size_t heap_split_thresh;
> +-static size_t heap_alignment;
> +-static size_t heap_max_blocks;
> +-
> + /**
> +  * If compaction is enabled, inserts block
> +  * into free list, sorted by addr.
> +  * If disabled, add block has new head of
> +  * the free list.
> +  */
> +-static void insert_block(Block *block) {
> +-#ifndef TA_DISABLE_COMPACT
> ++static void insert_block(struct tinyalloc *a, Block *block) {
> ++    Heap *heap = a->heap;
> ++
> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_COMPACT
> +     Block *ptr  = heap->free;
> +     Block *prev = NULL;
> +     while (ptr != NULL) {
> +@@ -66,8 +46,10 @@ static void insert_block(Block *block) {
> + #endif
> + }
> + 
> +-#ifndef TA_DISABLE_COMPACT
> +-static void release_blocks(Block *scan, Block *to) {
> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_COMPACT
> ++static void release_blocks(struct tinyalloc *a, Block *scan, Block *to) {
> ++    Heap *heap = a->heap;
> ++
> +     Block *scan_next;
> +     while (scan != to) {
> +         print_s("release");
> +@@ -81,7 +63,9 @@ static void release_blocks(Block *scan,
> +     }
> + }
> + 
> +-static void compact() {
> ++static void compact(struct tinyalloc *a) {
> ++    Heap *heap = a->heap;
> ++
> +     Block *ptr = heap->free;
> +     Block *prev;
> +     Block *scan;
> +@@ -103,7 +87,7 @@ static void compact() {
> +             ptr->size   = new_size;
> +             Block *next = prev->next;
> +             // make merged blocks available
> +-            release_blocks(ptr->next, prev->next);
> ++            release_blocks(a, ptr->next, prev->next);
> +             // relink
> +             ptr->next = next;
> +         }
> +@@ -112,30 +96,36 @@ static void compact() {
> + }
> + #endif
> + 
> +-bool ta_init(const void *base, const void *limit, const size_t heap_blocks, const size_t split_thresh, const size_t alignment) {
> +-    heap = (Heap *)base;
> +-    heap_limit = limit;
> +-    heap_split_thresh = split_thresh;
> +-    heap_alignment = alignment;
> +-    heap_max_blocks = heap_blocks;
> ++void ta_init(struct tinyalloc *a, const void *base, const void *limit,
> ++             const size_t heap_blocks, const size_t split_thresh,
> ++             const size_t alignment) {
> ++    Heap *heap;
> ++
> ++    a->heap = (Heap *)base;
> ++    a->heap_limit = limit;
> ++    a->heap_split_thresh = split_thresh;
> ++    a->heap_alignment = alignment;
> ++    a->heap_max_blocks = heap_blocks;
> + 
> ++    heap = a->heap;
> +     heap->free   = NULL;
> +     heap->used   = NULL;
> ++    heap->blocks = (Block*) ((size_t)base + sizeof(Heap));
> +     heap->fresh  = heap->blocks;
> +     heap->top    = (size_t)base + sizeof(Heap) + heap_blocks * sizeof(Block);
> +-    heap->blocks = base + sizeof(Heap);
> + 
> +     Block *block = heap->blocks;
> +-    size_t i     = heap_max_blocks - 1;
> ++    size_t i     = a->heap_max_blocks - 1;
> +     while (i--) {
> +         block->next = block + 1;
> +         block++;
> +     }
> +     block->next = NULL;
> +-    return true;
> + }
> + 
> +-bool ta_free(void *free) {
> ++void ta_free(struct tinyalloc *a, void *free) {
> ++    Heap *heap = a->heap;
> ++
> +     Block *block = heap->used;
> +     Block *prev  = NULL;
> +     while (block != NULL) {
> +@@ -145,25 +135,28 @@ bool ta_free(void *free) {
> +             } else {
> +                 heap->used = block->next;
> +             }
> +-            insert_block(block);
> +-#ifndef TA_DISABLE_COMPACT
> +-            compact();
> ++            insert_block(a, block);
> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_COMPACT
> ++            compact(a);
> + #endif
> +-            return true;
> ++            return;
> +         }
> +         prev  = block;
> +         block = block->next;
> +     }
> +-    return false;
> ++    return;
> + }
> + 
> +-static Block *alloc_block(size_t num) {
> ++static Block *alloc_block(struct tinyalloc *a, size_t num) {
> ++    Heap *heap = a->heap;
> ++
> +     Block *ptr  = heap->free;
> +     Block *prev = NULL;
> +     size_t top  = heap->top;
> +-    num         = (num + heap_alignment - 1) & -heap_alignment;
> ++    num         = (num + a->heap_alignment - 1) & - a->heap_alignment;
> +     while (ptr != NULL) {
> +-        const int is_top = ((size_t)ptr->addr + ptr->size >= top) && ((size_t)ptr->addr + num <= heap_limit);
> ++        const int is_top = ((size_t)ptr->addr + ptr->size >= top)
> ++		        && ((size_t)ptr->addr + num <= a->heap_limit);
> +         if (is_top || ptr->size >= num) {
> +             if (prev != NULL) {
> +                 prev->next = ptr->next;
> +@@ -176,10 +169,10 @@ static Block *alloc_block(size_t num) {
> +                 print_s("resize top block");
> +                 ptr->size = num;
> +                 heap->top = (size_t)ptr->addr + num;
> +-#ifndef TA_DISABLE_SPLIT
> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_SPLIT
> +             } else if (heap->fresh != NULL) {
> +                 size_t excess = ptr->size - num;
> +-                if (excess >= heap_split_thresh) {
> ++                if (excess >= a->heap_split_thresh) {
> +                     ptr->size    = num;
> +                     Block *split = heap->fresh;
> +                     heap->fresh  = split->next;
> +@@ -187,9 +180,9 @@ static Block *alloc_block(size_t num) {
> +                     print_s("split");
> +                     print_i((size_t)split->addr);
> +                     split->size = excess;
> +-                    insert_block(split);
> +-#ifndef TA_DISABLE_COMPACT
> +-                    compact();
> ++                    insert_block(a, split);
> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_COMPACT
> ++                    compact(a);
> + #endif
> +                 }
> + #endif
> +@@ -199,10 +192,11 @@ static Block *alloc_block(size_t num) {
> +         prev = ptr;
> +         ptr  = ptr->next;
> +     }
> ++
> +     // no matching free blocks
> +     // see if any other blocks available
> +     size_t new_top = top + num;
> +-    if (heap->fresh != NULL && new_top <= heap_limit) {
> ++    if (heap->fresh != NULL && new_top <= (size_t)a->heap_limit) {
> +         ptr         = heap->fresh;
> +         heap->fresh = ptr->next;
> +         ptr->addr   = (void *)top;
> +@@ -212,11 +206,12 @@ static Block *alloc_block(size_t num) {
> +         heap->top   = new_top;
> +         return ptr;
> +     }
> ++
> +     return NULL;
> + }
> + 
> +-void *ta_alloc(size_t num) {
> +-    Block *block = alloc_block(num);
> ++void *ta_alloc(struct tinyalloc *a, size_t num) {
> ++    Block *block = alloc_block(a, num);
> +     if (block != NULL) {
> +         return block->addr;
> +     }
> +@@ -236,9 +231,9 @@ static void memclear(void *ptr, size_t n
> +     }
> + }
> + 
> +-void *ta_calloc(size_t num, size_t size) {
> ++void *ta_calloc(struct tinyalloc *a, size_t num, size_t size) {
> +     num *= size;
> +-    Block *block = alloc_block(num);
> ++    Block *block = alloc_block(a, num);
> +     if (block != NULL) {
> +         memclear(block->addr, num);
> +         return block->addr;
> +@@ -255,18 +250,21 @@ static size_t count_blocks(Block *ptr) {
> +     return num;
> + }
> + 
> +-size_t ta_num_free() {
> ++size_t ta_num_free(struct tinyalloc *a) {
> ++    Heap *heap = a->heap;
> +     return count_blocks(heap->free);
> + }
> + 
> +-size_t ta_num_used() {
> ++size_t ta_num_used(struct tinyalloc *a) {
> ++    Heap *heap = a->heap;
> +     return count_blocks(heap->used);
> + }
> + 
> +-size_t ta_num_fresh() {
> ++size_t ta_num_fresh(struct tinyalloc *a) {
> ++    Heap *heap = a->heap;
> +     return count_blocks(heap->fresh);
> + }
> + 
> +-bool ta_check() {
> +-    return heap_max_blocks == ta_num_free() + ta_num_used() + ta_num_fresh();
> ++bool ta_check(struct tinyalloc *a) {
> ++    return a->heap_max_blocks == ta_num_free(a) + ta_num_used(a) + ta_num_fresh(a);
> + }
> +diff -urNp tinyalloc-orig/tinyalloc.h tinyalloc-patched/tinyalloc.h
> +--- tinyalloc-orig/tinyalloc.h	2019-08-17 23:56:45.000000000 +0200
> ++++ tinyalloc-patched/tinyalloc.h	2020-06-30 10:38:59.734724059 +0200
> +@@ -1,12 +1,41 @@
> + #include <stdbool.h>
> + #include <stddef.h>
> + 
> +-bool ta_init(const void *base, const void *limit, const size_t heap_blocks, const size_t split_thresh, const size_t alignment);
> +-void *ta_alloc(size_t num);
> +-void *ta_calloc(size_t num, size_t size);
> +-bool ta_free(void *ptr);
> +-
> +-size_t ta_num_free();
> +-size_t ta_num_used();
> +-size_t ta_num_fresh();
> +-bool ta_check();
> ++typedef struct Block Block;
> ++
> ++struct Block {
> ++    void *addr;
> ++    Block *next;
> ++    size_t size;
> ++};
> ++
> ++typedef struct {
> ++    Block *free;   // first free block
> ++    Block *used;   // first used block
> ++    Block *fresh;  // first available blank block
> ++    size_t top;    // top free addr
> ++    Block *blocks;
> ++} Heap;
> ++
> ++struct tinyalloc {
> ++    Heap *heap;
> ++    void *heap_limit;
> ++    size_t heap_split_thresh;
> ++    size_t heap_alignment;
> ++    size_t heap_max_blocks;
> ++};
> ++
> ++void ta_init(struct tinyalloc *a, const void *base, const void *limit,
> ++             const size_t heap_blocks, const size_t split_thresh,
> ++             const size_t alignment);
> ++
> ++void *ta_alloc(struct tinyalloc *a, size_t num);
> ++void *ta_calloc(struct tinyalloc *a, size_t num, size_t size);
> ++void  ta_free(struct tinyalloc *a, void *ptr);
> ++int   ta_posix_memalign(struct tinyalloc *a, void **memptr, size_t align,
> ++			size_t size);
> ++
> ++size_t ta_num_free(struct tinyalloc *a);
> ++size_t ta_num_used(struct tinyalloc *a);
> ++size_t ta_num_fresh(struct tinyalloc *a);
> ++bool   ta_check(struct tinyalloc *a);


From minios-devel-bounces@lists.xenproject.org Fri Sep 18 09:15:19 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 18 Sep 2020 09:15:19 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kJCU9-0000pn-15; Fri, 18 Sep 2020 09:15:17 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=pNnR=C3=gmail.com=razvand@srs-us1.protection.inumbo.net>)
 id 1kJCU7-0000pi-Aw
 for minios-devel@lists.xen.org; Fri, 18 Sep 2020 09:15:15 +0000
X-Inumbo-ID: 3fdb9900-7042-469c-8fe1-7e33e5e1a909
Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 3fdb9900-7042-469c-8fe1-7e33e5e1a909;
 Fri, 18 Sep 2020 09:15:12 +0000 (UTC)
Received: by mail-wm1-x343.google.com with SMTP id q9so4593975wmj.2
 for <minios-devel@lists.xen.org>; Fri, 18 Sep 2020 02:15:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version:content-transfer-encoding;
 bh=XagM+rcnRY8VjT3R7XShkX5w6sncoCzbtd16bs7Kl60=;
 b=czk1UBxujyDc7cUq2Szl6IZ1KQLQBdVjrdQHLPadz7t9DtEbKX3XQedZz+m0ymUOFh
 MIXNf1RimeF06Xn1/M+GFuh5aRyfQMzJ+vySrdoajsWICrLSpQxlR01LDRg8VJPCUh/5
 C4QQ2wzy1YYlSr/KcDjMcI2INbPLILegIBGMSv2I/yj9Ir0EfU3yBYCj/fsg68/e4rwa
 HvVN/yNUKkRTH5yyLt6r+Gcpj6Iqj1lIG/F97hsrNTL1h67NqkxiorEqQHdQSVfNuxLD
 lmALb4G8SwnYErXD5T7sjVGSBpYEWps/3dJPxpjPx93tDDuktikrZMud5X2GShB8IGpm
 G5MA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:from:to:cc:subject:references:date
 :in-reply-to:message-id:user-agent:mime-version
 :content-transfer-encoding;
 bh=XagM+rcnRY8VjT3R7XShkX5w6sncoCzbtd16bs7Kl60=;
 b=WdmOJEpsAW++AIDG1wykjy5fGcp2o3h7mpb2Wre3mCmUvmvOqcCsF5NWGRJABCfkKs
 bcpXh3mBJgUx8A94aRmBr7zisRsjj/sVL0Vzjx7VngxiYbm0Q6N5N3hnVBwwP4JCJmPN
 iUM+6J3u5+v4Hx3lwmlZ09BEMC5CSYozCxP12H2GMT0hfkm64jS/a73/MvtwKIvlB2cV
 6p79yMkdYpikESg7HFsqEW27xnQeO1bFvzK5jl2/Zd6TuKmp6QGXL8v3paCPiiP6pk4l
 6nW7d3coX0Eo9MHXEejjUE7Ajk+WhjG4S9qKsGxPBUWta8LqYGUzTMJV7hqWE4qdhWYo
 GcPw==
X-Gm-Message-State: AOAM532uJHpN1uySrhoSv978IDZrmrLtvT9xByGvHsRl7SmfNFqYkLZ8
 A7SLQMhEnHyQ8fMd+lQ2ODs=
X-Google-Smtp-Source: ABdhPJweJI+IE6tIziF9dqejfLyyensNlTJXwhUN/1OETBtlX6lLddRFEoWZoe3E5KRgekREobdqwg==
X-Received: by 2002:a1c:32c6:: with SMTP id y189mr13688382wmy.51.1600420510881; 
 Fri, 18 Sep 2020 02:15:10 -0700 (PDT)
Received: from localhost ([141.85.233.147])
 by smtp.gmail.com with ESMTPSA id t202sm4023781wmt.14.2020.09.18.02.15.09
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Fri, 18 Sep 2020 02:15:10 -0700 (PDT)
From: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
To: Alice Suiu <alicesuiu17@gmail.com>
Cc: felipe.huici@neclab.eu, florian.schmidt@neclab.eu,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, minios-devel@lists.xen.org,
 costin.lupu@cs.pub.ro
Subject: Re: [Minios-devel] [UNIKRAFT/NEWLIB PATCH] include/endian.h Define
 the __bswap16, __bswap32,
 __bswap64 builtin functions only if the compilation is done with gcc
References: <20200301191336.24672-1-alicesuiu17@gmail.com>
 <20200301191336.24672-2-alicesuiu17@gmail.com>
 <ca5ecb2f-8f76-9bf0-aac9-72bfa5bb2438@neclab.eu>
 <CAD2TrnC7Z9_bKk5gFx2U=PmyTJyaxfCsVSPY_AG+RsLLAGfLCg@mail.gmail.com>
 <86lfjioazb.fsf@drone.cs.pub.ro> <864kq6jity.fsf@drone.cs.pub.ro>
Date: Fri, 18 Sep 2020 12:15:09 +0300
In-Reply-To: <864kq6jity.fsf@drone.cs.pub.ro> (Razvan Deaconescu's message of
 "Fri, 17 Jul 2020 17:51:21 +0300")
Message-ID: <868sd75tuq.fsf@drone.cs.pub.ro>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Felipe, Simon, please see the discussion below.

Do you have any suggestions? Should I just make a decision and submit
updated patches?

Razvan

Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> writes:
> Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> writes:
>> Alice Suiu <alicesuiu17@gmail.com> writes:
>>> =C3=8En joi, 2 apr. 2020 la 19:56, Simon Kuenzer <simon.kuenzer@neclab.=
eu> a scris:
>>>> Hi Alice,
>>>>
>>>> I have a question to this patch:
>>>>
>>>> On 01.03.20 20:13, alicesuiu wrote:
>>>> > Signed-off-by: Alice Suiu <alicesuiu17@gmail.com>
>>>> > ---
>>>> >   include/endian.h | 2 ++
>>>> >   1 file changed, 2 insertions(+)
>>>> >
>>>> > diff --git a/include/endian.h b/include/endian.h
>>>> > index 3c8a752..63d3650 100644
>>>> > --- a/include/endian.h
>>>> > +++ b/include/endian.h
>>>> > @@ -41,6 +41,7 @@
>>>> >
>>>> >   #include <stdint.h>
>>>> >
>>>> > +#ifndef __clang__
>>>> >   static inline uint16_t __bswap16(uint16_t __x)
>>>> >   {
>>>> >       return __x<<8 | __x>>8;
>>>> > @@ -55,6 +56,7 @@ static inline uint64_t __bswap64(uint64_t __x)
>>>> >   {
>>>> >       return (__bswap32(__x)+0ULL)<<32 | __bswap32(__x>>32);
>>>> >   }
>>>> > +#endif
>>>>
>>>> Doesn't GCC has a builtin for this and does clang has one, too? We also
>>>> need to make sure that clang is not introducing libc replacements as
>>>> default. On GCC that broke the printing with nolibc...
>>>
>>> Hi Simon,
>>>
>>> Yes, GCC doesn't have these builtin functions, but clang has them. When=
 I
>>> use nolibc + clang, I don't receive errors. But when I use newlib [1] +
>>> clang [2], I receive errors because both have these builtin functions.
>>
>> Both GCC and Clang have define the `__builtin_bswapXY()` builtins. The
>> actual issue is a different behavior between the two compilers: the
>> simultaneous definition of a macro `__bswapXY` and a function
>> `__bswapXY`; GCC doesn't complain, but Clang does. See the sample
>> here[3].
>>
>> This is happening in Unikraft because the Unikraft core libraries are
>> using a minimized Unikraft newlib library[4], while the Unikraft app is
>> using the upstream (complete) newlib library[5]. In the end there are
>> two `endian.h` files: one in the Unikraft newlib[6], another one in the
>> upstream newlib (<repo>/newlib/libc/include/machine/endian.h). The
>> Unikraft newlib version of `endian.h` defines `__bswapXY` as inline
>> functions, whereas the upstream newlib defines them as macros. This
>> results in an error from Clang; GCC doesn't mind, though it's an issue
>> having multiple definitions for the same thing (even if one is a macro
>> or one is a function).
>>
>> Ideally you wouldn't have multiple headers with the same content. But
>> given the way Unikraft is created (with the core libraries not requiring
>> the upstream newlib version, only the minimal Unikraft newlib) we need
>> both of them.
>>
>> The proper way to fix this is to make the two compatible: update the
>> Unikraft newlib `endian.h` definitions using the ones from the upstream
>> newlib, as in the patch below[7]. This works for GCC and Clang.
>>
>> Simon, does this patch look OK to you? If yes, I will send it to the
>> mailing list and we can reject the current one.
>
> There's a cleaner solution, as we discussed, today: removing the
> __bswapXY() parts and including the upstream version of endian.h, as in
> the patch below.
>
> There's also the option of removing the endian.h file altogether and
> updating the calling functions. I looked into Unikraft core libs, newlib
> and lwip, and removing it works; but I don't know about other libraries
> that may be using the endian.h file. To be on the safe side, I favor the
> patch below.
>
> -----
> diff --git a/include/endian.h b/include/endian.h
> index 3c8a752..f09c312 100644
> --- a/include/endian.h
> +++ b/include/endian.h
> @@ -27,6 +27,8 @@
>  #ifndef _ENDIAN_H
>  #define _ENDIAN_H
>=20=20
> +#include <machine/endian.h>
> +
>  #define __LITTLE_ENDIAN 1234
>  #define __BIG_ENDIAN 4321
>  #define __PDP_ENDIAN 3412
> @@ -41,21 +43,6 @@
>=20=20
>  #include <stdint.h>
>=20=20
> -static inline uint16_t __bswap16(uint16_t __x)
> -{
> -       return __x<<8 | __x>>8;
> -}
> -
> -static inline uint32_t __bswap32(uint32_t __x)
> -{
> -       return __x>>24 | (__x>>8&0xff00) | (__x<<8&0xff0000) | __x<<24;
> -}
> -
> -static inline uint64_t __bswap64(uint64_t __x)
> -{
> -       return (__bswap32(__x)+0ULL)<<32 | __bswap32(__x>>32);
> -}
> -
>  #if __BYTE_ORDER =3D=3D __LITTLE_ENDIAN
>  #define htobe16(x) __bswap16(x)
>  #define be16toh(x) __bswap16(x)
> -----
>
> Razvan


From minios-devel-bounces@lists.xenproject.org Fri Sep 18 09:17:52 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 18 Sep 2020 09:17:52 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kJCWe-0000vB-Au; Fri, 18 Sep 2020 09:17:52 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=pNnR=C3=gmail.com=razvand@srs-us1.protection.inumbo.net>)
 id 1kJCWc-0000v6-PX
 for minios-devel@lists.xen.org; Fri, 18 Sep 2020 09:17:50 +0000
X-Inumbo-ID: 4d640341-61c5-423e-855c-d75d4712361e
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 4d640341-61c5-423e-855c-d75d4712361e;
 Fri, 18 Sep 2020 09:17:49 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id z1so4874514wrt.3
 for <minios-devel@lists.xen.org>; Fri, 18 Sep 2020 02:17:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=+SHTjpJcl3SRkl7n0YmU5tUyFQkobR97DIbXpnltGCk=;
 b=PHl+elZUnMOqYn4/4MXGDhIyYLK5zDoLn/2KWPIcbw0k9OQK8dmIBd9HPFn254Y05l
 9HC6BqMzF0dEK7+49D4n2gUnx/YPL6cG9ya0trxTxvJUJ5BdvHRbFQodRJjhVxIdAJRo
 xcfXycD0OIHBr3gDQe6+Tv+c/a+ua/ziCICWWyWiAlPcqPGVb6qx3o0ogOazSOm587LG
 iqqv/+8T7gBjCpcfTNCKsoGeNjvnFtgiZxPtSSjzGZHo5RFBt/jm3DL6oRdcCT6YJz1i
 ge5WC0aPgAM9c42HfLqJtpmRfa29pgbXuyonV1JReOvl4BegDZWv3ITUn3JWjSQRASsb
 Eh9Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:from:to:cc:subject:references:date
 :in-reply-to:message-id:user-agent:mime-version;
 bh=+SHTjpJcl3SRkl7n0YmU5tUyFQkobR97DIbXpnltGCk=;
 b=nyHpil2n7j3V+oKJdRfu+0lJ+ROKv4opZz8uATDRdmrZizfjbgdbecnAOVi8S9G+yO
 4dm2SXghrp2jtrKgqbN+KuBqiy3prorKWm80eAHVbB9DrFam3RFV+rNbSmKZvF0i831G
 6kvjmQNOexo92Aubsx8i0gQD/SPBkgFU2xy5D3V1kQo1CritjzfQnSkQCOwOe3Qens/a
 0RiKZWZ0O46S/lGjmVgh9DRtOs6VPLACLJT26VxAIjycEokaoyJ2UYH7A/CyvIuWBdZA
 hOerbSGo1DWiWFO5LQLkzylk3m6Afl/jt8Ner15F6qT/soMR5E7sNfZPBrSlEfVVPLZu
 1Fcw==
X-Gm-Message-State: AOAM533lGf1nFtxIQIL2veqeeprjPJOn2VzWtBJPluXJACVE1fbJGIob
 mAqs2i3dRFDbIDiQ4s33xJ0=
X-Google-Smtp-Source: ABdhPJy5dMveKu3Tt8Zde4tfOSxoAduKcwyZRXgHTLkm0xMMywLlzQwzRFIMqzVsuz+A12QAD/lL3A==
X-Received: by 2002:adf:ed12:: with SMTP id a18mr38795647wro.178.1600420668342; 
 Fri, 18 Sep 2020 02:17:48 -0700 (PDT)
Received: from localhost ([141.85.233.147])
 by smtp.gmail.com with ESMTPSA id t1sm3717120wmi.16.2020.09.18.02.17.47
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Fri, 18 Sep 2020 02:17:47 -0700 (PDT)
From: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
To: Felipe Huici <felipe.huici@neclab.eu>
Cc: minios-devel@lists.xen.org
Subject: Re: [UNIKRAFT/LIBICU PATCH 0/2] Introducing libicu port to Unikraft
References: <20200416195724.18620-1-felipe.huici@neclab.eu>
 <86d04uo7hr.fsf@drone.cs.pub.ro> <867dv2kyvw.fsf@drone.cs.pub.ro>
Date: Fri, 18 Sep 2020 12:17:47 +0300
In-Reply-To: <867dv2kyvw.fsf@drone.cs.pub.ro> (Razvan Deaconescu's message of
 "Fri, 17 Jul 2020 17:19:15 +0300")
Message-ID: <864knv5tqc.fsf@drone.cs.pub.ro>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> writes:
> Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> writes:
>> Hi, Felipe.
>>
>> I built the libicu library, everything is OK.
>>
>> But the header files are not included in the Makefile commands that
>> build the application. I used the libicu API in the main.c (application
>> source code file) and it fails to find header files.
>>
>> The header files are included in the Makefile commands to build the
>> library files:
>> ---
>> ... -I/home/razvan/projects/unicore/unikraft/apps/app-helloworld.git/build/libicu/origin/source/common
>> -I/home/razvan/projects/unicore/unikraft/apps/app-helloworld.git/build/libicu/origin/source/i18n
>> ...
>> ---
>>
>> The Makefile.uk file looks OK to me. Do you know what the problem might be?
>
> Simon highlighted the issue in Makefile.uk. It uses CONFIG_ICU instead
> of CONFIG_LIBICU. Once this is fixed, everything works OK. Like this:
>
> ----
> CINCLUDES-$(CONFIG_LIBICU)   += -I$(LIBICU_SRC)/common  
> CINCLUDES-$(CONFIG_LIBICU)   += -I$(LIBICU_SRC)/i18n            
> CXXINCLUDES-$(CONFIG_LIBICU) += -I$(LIBICU_SRC)/common      
> CXXINCLUDES-$(CONFIG_LIBICU) += -I$(LIBICU_SRC)/i18n
> ---

Hi, Felipe.

Please see the discussion above. That change is all that's required to
have libicu ready for upstream.

Razvan

>> Felipe Huici <felipe.huici@neclab.eu> writes:
>>> This is our initial port of the International Components for Unicode library to Unikraft.
>>>
>>> Felipe Huici (2):
>>>   Introduce icu to Unikraft.
>>>   Add documentation
>>>
>>>  .gitignore      |  27 +++
>>>  CODING_STYLE.md |   4 +
>>>  CONTRIBUTING.md |   4 +
>>>  COPYING.md      |  30 ++++
>>>  Config.uk       |  14 ++
>>>  MAINTAINERS.md  |  10 ++
>>>  Makefile.uk     | 466 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>  README.md       |  10 ++
>>>  8 files changed, 565 insertions(+)
>>>  create mode 100644 .gitignore
>>>  create mode 100644 CODING_STYLE.md
>>>  create mode 100644 CONTRIBUTING.md
>>>  create mode 100644 COPYING.md
>>>  create mode 100644 Config.uk
>>>  create mode 100644 MAINTAINERS.md
>>>  create mode 100644 Makefile.uk
>>>  create mode 100644 README.md


From minios-devel-bounces@lists.xenproject.org Fri Sep 18 09:24:45 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 18 Sep 2020 09:24:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kJCdH-0001hD-Sj; Fri, 18 Sep 2020 09:24:43 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=pNnR=C3=gmail.com=razvand@srs-us1.protection.inumbo.net>)
 id 1kJCdG-0001h8-Pk
 for minios-devel@lists.xenproject.org; Fri, 18 Sep 2020 09:24:42 +0000
X-Inumbo-ID: 767b5227-999e-48c9-9572-7d5d052f74a3
Received: from mail-wm1-x32d.google.com (unknown [2a00:1450:4864:20::32d])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 767b5227-999e-48c9-9572-7d5d052f74a3;
 Fri, 18 Sep 2020 09:24:39 +0000 (UTC)
Received: by mail-wm1-x32d.google.com with SMTP id x23so4609888wmi.3
 for <minios-devel@lists.xenproject.org>; Fri, 18 Sep 2020 02:24:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=vJHytOEe8n/fThqYlTvYSvIz5Wk3Bi1Q4c38iJZlyME=;
 b=LqvaBwBdV29xzxP5wBXWkvQ8XYuCSjCXxk+IUq/CVcUUIqppYcm2x2KbHYQXx6XjGr
 a1fWGnaiREz2vXqyVJo/oFpAUIrvnXC3v/uEyC+I9NFuOI0hQZdKIk5hCHb3naTsC5Q1
 huUoHQnMKrTC/xrM/Jd2ZtGdIsJPzJvL8mFu/ZcZMTv7Ft9+ZRqYJy+P/SrU7uxLJCwb
 ITyhgVOctsdcCyWDqVloOTANOSG1Uo+4QE37C5ToW7m8IfRXwHZfLOgPtTDDhilul1mb
 JqfWwmR+wYHNDNWpLQhogr2iW4lRRMNujmStz3+w6sLyBf+czZ5UcsCywlIVeEMRffX4
 bKAw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:from:to:cc:subject:references:date
 :in-reply-to:message-id:user-agent:mime-version;
 bh=vJHytOEe8n/fThqYlTvYSvIz5Wk3Bi1Q4c38iJZlyME=;
 b=BfNwKEEUk3yo3uMA3tV7DiGJJozve5TnCk5QVL0gk5uO8C0351b8TSUiz9A5vGDs4y
 bDfZ/zuh/0uSuvBEzVXQmzEZKno86HHJGpeZVcOCuvtEyLbWiB7akseKYwQE+0CB/ms5
 Ey9OlHoPU7QPodT4Vb6ErjQOxSgSCVy2p6QsVU7y1Ayrtbwt3bPXwDkgZT67ngiZ4p5d
 zKnS+b1qzkcMNsHBf2XNDKCFzm40RrMZlIfGYqIOX9MqMcni2nDtQKIElcVLj0ivB76g
 WH+mRAOpEaF+B8V5xKNOv1ZV9ZqxRT+ptSX4E/qakukTZbgv2ZxfLhy0H/fHvPUI9NCa
 NEUw==
X-Gm-Message-State: AOAM532bj9AL12MYcGqr5MYAoOwt3sa9OOK6/ogqUnPlzVuBH1Ew60c+
 WeBkn4hTpNvUkRL/rgbpIyI=
X-Google-Smtp-Source: ABdhPJwRMG4NuT4WpmIC6uYH+RCduhG9Rdut8rcaOExoEZGPBWm0MZA1pvQb8Os5ZvUZknteTyc8vw==
X-Received: by 2002:a1c:e3c3:: with SMTP id
 a186mr15586710wmh.189.1600421078025; 
 Fri, 18 Sep 2020 02:24:38 -0700 (PDT)
Received: from localhost ([141.85.233.147])
 by smtp.gmail.com with ESMTPSA id n4sm4113578wrp.61.2020.09.18.02.24.37
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Fri, 18 Sep 2020 02:24:37 -0700 (PDT)
From: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
To: Hugo Lefeuvre <hle@owl.eu.com>
Cc: <minios-devel@lists.xenproject.org>
Subject: Re: [UNIKRAFT/LIBTINYALLOC PATCH] Initial port of tinyalloc to
 Unikraft
References: <cover.1593602546.git.hugo.lefeuvre@neclab.eu>
 <41d946015ecaa34e0f93ebc433506d95fb7f9469.1593602546.git.hugo.lefeuvre@neclab.eu>
 <86lfh779j8.fsf@drone.cs.pub.ro>
Date: Fri, 18 Sep 2020 12:24:36 +0300
In-Reply-To: <86lfh779j8.fsf@drone.cs.pub.ro> (Razvan Deaconescu's message of
 "Fri, 18 Sep 2020 11:51:07 +0300")
Message-ID: <86zh5n4euj.fsf@drone.cs.pub.ro>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

I added Hugo with his non-NEC e-mail address.

Razvan

Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> writes:
> Hi, Hugo.
>
> I tested tinyalloc on linuxu and KVM, it works.
>
> Why did you name the structure "struct tinyalloc", without the uk_
> prefix as is the case with the other allocators (i.e. "struct
> uk_bbpalloc" and "struct uk_allocregion").
>
> When selecting tinyalloc in the configuration screen, the malloc
> compatibility interface should also be automatically selected. It's not
> obvious it has to be selected and one may miss it.
>
> There's another comment inline.
>
> Razvan
>
> Hugo Lefeuvre <hugo.lefeuvre@neclab.eu> writes:
>> Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
>> ---
>>  Config.uk                                          |  32 +++
>>  Makefile.uk                                        |  73 +++++
>>  glue.c                                             | 101 +++++++
>>  include/uk/tinyalloc.h                             |  48 ++++
>>  main-tree.patch                                    |  45 +++
>>  .../0001-do-not-store-heap-info-statically.patch   | 312 +++++++++++++++++++++
>>  6 files changed, 611 insertions(+)
>>  create mode 100644 Config.uk
>>  create mode 100644 Makefile.uk
>>  create mode 100644 glue.c
>>  create mode 100644 include/uk/tinyalloc.h
>>  create mode 100644 main-tree.patch
>>  create mode 100644 patches/0001-do-not-store-heap-info-statically.patch
>>
>> diff --git a/Config.uk b/Config.uk
>> new file mode 100644
>> index 0000000..4b9d127
>> --- /dev/null
>> +++ b/Config.uk
>> @@ -0,0 +1,32 @@
>> +menuconfig LIBTINYALLOC
>> +	   bool "tinyalloc - sequential fit, linked list based tiny allocator"
>> +	   default y
>> +
>> +if LIBTINYALLOC
>> +	config LIBTINYALLOC_DISABLE_SPLIT
>> +		bool "Disable block splitting"
>> +		default n
>> +		help
>> +			If splitting is enabled, split blocks according to split
>> +			threshold.
>> +
>> +	config LIBTINYALLOC_DISABLE_COMPACT
>> +		bool "Disable block compaction"
>> +		default n
>> +		help
>> +			If compaction is enabled, sort blocks into the free
>> +			list, merge if appropriate. Otherwise blocks are just
>> +			added as new head of the free list.
>> +
>> +	config LIBTINYALLOC_HEAP_BLOCKS
>> +		int "Number of available heap blocks"
>> +		default 2048
>> +
>> +	config LIBTINYALLOC_SPLIT_THRESH
>> +		int "Split threshold, in bytes"
>> +		default 16
>> +
>> +	config LIBTINYALLOC_ALIGNMENT
>> +		int "Standard allocation alignment, in bytes"
>> +		default 8
>> +endif
>> diff --git a/Makefile.uk b/Makefile.uk
>> new file mode 100644
>> index 0000000..21aa8fe
>> --- /dev/null
>> +++ b/Makefile.uk
>> @@ -0,0 +1,73 @@
>> +#  libtinyalloc Makefile.uc
>> +#
>> +#  Authors: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
>> +#
>> +#  Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
>> +#
>> +#  Redistribution and use in source and binary forms, with or without
>> +#  modification, are permitted provided that the following conditions
>> +#  are met:
>> +#
>> +#  1. Redistributions of source code must retain the above copyright
>> +#     notice, this list of conditions and the following disclaimer.
>> +#  2. Redistributions in binary form must reproduce the above copyright
>> +#     notice, this list of conditions and the following disclaimer in the
>> +#     documentation and/or other materials provided with the distribution.
>> +#  3. Neither the name of the copyright holder nor the names of its
>> +#     contributors may be used to endorse or promote products derived from
>> +#     this software without specific prior written permission.
>> +#
>> +#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
>> +#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
>> +#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
>> +#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
>> +#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> +#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
>> +#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
>> +#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
>> +#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
>> +#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
>> +#  POSSIBILITY OF SUCH DAMAGE.
>> +
>> +################################################################################
>> +# Library registration
>> +################################################################################
>> +$(eval $(call addlib_s,libtinyalloc,$(CONFIG_LIBTINYALLOC)))
>> +
>> +################################################################################
>> +# Sources
>> +################################################################################
>> +LIBTINYALLOC_VERSION=96450f32d80fe7d23f6aa5426046143e57801bc4
>> +LIBTINYALLOC_URL=https://github.com/thi-ng/tinyalloc/archive/$(LIBTINYALLOC_VERSION).zip
>> +LIBTINYALLOC_DIR=tinyalloc-$(LIBTINYALLOC_VERSION)
>> +
>> +LIBTINYALLOC_PATCHDIR=$(LIBTINYALLOC_BASE)/patches
>> +$(eval $(call fetch,libtinyalloc,$(LIBTINYALLOC_URL),$(LIBTINYALLOC_VERSION).zip))
>> +$(eval $(call patch,libtinyalloc,$(LIBTINYALLOC_PATCHDIR),$(LIBTINYALLOC_DIR)))
>> +
>> +################################################################################
>> +# Helpers
>> +################################################################################
>> +LIBTINYALLOC=$(LIBTINYALLOC_ORIGIN)/$(LIBTINYALLOC_DIR)
>> +
>> +################################################################################
>> +# Library includes
>> +################################################################################
>> +CINCLUDES-$(CONFIG_LIBTINYALLOC) += -I$(LIBTINYALLOC_BASE)     \
>> +                                    -I$(LIBTINYALLOC_BASE)/include \
>> +			            -I$(LIBTINYALLOC)
>> +
>> +################################################################################
>> +# Global flags
>> +################################################################################
>> +#LIBTINYALLOC_CFLAGS-y += -D_POSIX_SOURCE -D_GNU_SOURCE -D__GNU__
>> +
>> +################################################################################
>> +# Glue code
>> +################################################################################
>> +LIBTINYALLOC_SRCS-y += $(LIBTINYALLOC_BASE)/glue.c
>> +
>> +################################################################################
>> +# Sources
>> +################################################################################
>> +LIBTINYALLOC_SRCS-y += $(LIBTINYALLOC)/tinyalloc.c
>> diff --git a/glue.c b/glue.c
>> new file mode 100644
>> index 0000000..9266e92
>> --- /dev/null
>> +++ b/glue.c
>> @@ -0,0 +1,101 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause */
>> +/*
>> + * Authors: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
>> + *
>> + * Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + *
>> + * 1. Redistributions of source code must retain the above copyright
>> + *    notice, this list of conditions and the following disclaimer.
>> + * 2. Redistributions in binary form must reproduce the above copyright
>> + *    notice, this list of conditions and the following disclaimer in the
>> + *    documentation and/or other materials provided with the distribution.
>> + * 3. Neither the name of the copyright holder nor the names of its
>> + *    contributors may be used to endorse or promote products derived from
>> + *    this software without specific prior written permission.
>> + *
>> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
>> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
>> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
>> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
>> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
>> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
>> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
>> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
>> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
>> + * POSSIBILITY OF SUCH DAMAGE.
>> + */
>> +
>> +#include <uk/tinyalloc.h>
>> +#include <uk/alloc_impl.h>
>> +#include <string.h> /* for memset */
>> +#include <tinyalloc.h>
>> +
>> +static void *uk_tinyalloc_malloc(struct uk_alloc *a, size_t size)
>> +{
>> +	struct tinyalloc *b;
>> +
>> +	b = (struct tinyalloc *)&a->priv;
>> +	return ta_alloc(b, size);
>> +}
>> +
>> +static void uk_tinyalloc_free(struct uk_alloc *a, void *ptr)
>> +{
>> +	struct tinyalloc *b;
>> +
>> +	b = (struct tinyalloc *)&a->priv;
>> +	ta_free(b, ptr);
>> +}
>> +
>> +/* initialization */
>> +
>> +struct uk_alloc *uk_tinyalloc_init(void *base, size_t len)
>> +{
>> +	struct uk_alloc *a;
>> +	struct tinyalloc *b;
>> +	size_t metalen;
>> +
>> +	/* TODO: This port does not support multiple memory regions yet. Because
>> +	 * of the multiboot layout, the first region might be a single page, so
>> +	 * we simply ignore it.
>> +	 */
>> +	if (len <= __PAGE_SIZE)
>> +		return NULL;
>> +
>> +	/* Allocate space for allocator descriptor */
>> +	metalen = sizeof(*a) + sizeof(*b);
>> +
>> +	/* enough space for allocator available? */
>> +	if (metalen > len) {
>> +		uk_pr_err("Not enough space for allocator: %"__PRIsz
>> +			  " B required but only %"__PRIuptr" B usable\n",
>> +			  metalen, len);
>> +		return NULL;
>> +	}
>> +
>> +	/* store allocator metadata on the heap, just before the memory pool */
>> +	a = (struct uk_alloc *)base;
>> +	b = (struct tinyalloc *)&a->priv;
>> +	memset(a, 0, metalen);
>> +
>> +	uk_pr_info("Initialize tinyalloc allocator @ 0x%" __PRIuptr ", len %"
>> +			__PRIsz"\n", (uintptr_t)a, len);
>> +
>> +	ta_init(b, base + metalen, base + len, CONFIG_LIBTINYALLOC_HEAP_BLOCKS,
>> +		CONFIG_LIBTINYALLOC_SPLIT_THRESH,
>> +		CONFIG_LIBTINYALLOC_ALIGNMENT);
>> +
>> +	if (!a) {
>> +		uk_pr_err("Failed to allocate memory for uk_alloc structure!\n");
>> +		return NULL;
>> +	}
>
> Shouldn't this be if (!b)?
>
>> +	uk_alloc_init_malloc_ifmalloc(a, uk_tinyalloc_malloc,
>> +					 uk_tinyalloc_free, NULL);
>> +
>> +	return a;
>> +}
>> diff --git a/include/uk/tinyalloc.h b/include/uk/tinyalloc.h
>> new file mode 100644
>> index 0000000..87290ed
>> --- /dev/null
>> +++ b/include/uk/tinyalloc.h
>> @@ -0,0 +1,48 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause */
>> +/*
>> + * Authors: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
>> + *
>> + * Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + *
>> + * 1. Redistributions of source code must retain the above copyright
>> + *    notice, this list of conditions and the following disclaimer.
>> + * 2. Redistributions in binary form must reproduce the above copyright
>> + *    notice, this list of conditions and the following disclaimer in the
>> + *    documentation and/or other materials provided with the distribution.
>> + * 3. Neither the name of the copyright holder nor the names of its
>> + *    contributors may be used to endorse or promote products derived from
>> + *    this software without specific prior written permission.
>> + *
>> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
>> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
>> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
>> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
>> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
>> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
>> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
>> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
>> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
>> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
>> + * POSSIBILITY OF SUCH DAMAGE.
>> + */
>> +
>> +#ifndef __LIBTINYALLOC_H__
>> +#define __LIBTINYALLOC_H__
>> +
>> +#include <uk/alloc.h>
>> +
>> +#ifdef __cplusplus
>> +extern "C" {
>> +#endif
>> +
>> +struct uk_alloc *uk_tinyalloc_init(void *base, size_t len);
>> +
>> +#ifdef __cplusplus
>> +}
>> +#endif
>> +
>> +#endif /* __LIBTINYALLOC_H__ */
>> diff --git a/main-tree.patch b/main-tree.patch
>> new file mode 100644
>> index 0000000..40bb096
>> --- /dev/null
>> +++ b/main-tree.patch
>> @@ -0,0 +1,45 @@
>> +From: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
>> +Subject: Add tinyalloc entry to the menuconfig and initialize it
>> +diff --git a/lib/ukboot/Config.uk b/lib/ukboot/Config.uk
>> +index a888bc1c..694762fa 100644
>> +--- a/lib/ukboot/Config.uk
>> ++++ b/lib/ukboot/Config.uk
>> +@@ -32,6 +32,16 @@ if LIBUKBOOT
>> + 		  Satisfy allocation as fast as possible. No support for free().
>> + 		  Refer to help in ukallocregion for more information.
>> + 
>> ++		config LIBUKBOOT_INITTINYALLOC
>> ++		bool "tinyalloc"
>> ++		select LIBTINYALLOC
>> ++		help
>> ++		  Minimalist allocator implementation, meant for use in systems
>> ++		  with unmanaged linear memory such as WebAssembly or embedded
>> ++		  systems. tinyalloc is highly configurable and offers high
>> ++		  performance and reasonable memory usage when used and
>> ++		  configured appropriately.
>> ++
>> + 		config LIBUKBOOT_NOALLOC
>> + 		bool "No memory allocator"
>> + 
>> +diff --git a/lib/ukboot/boot.c b/lib/ukboot/boot.c
>> +index 4e749aa5..b8bf0a20 100644
>> +--- a/lib/ukboot/boot.c
>> ++++ b/lib/ukboot/boot.c
>> +@@ -45,6 +45,8 @@
>> + #include <uk/allocbbuddy.h>
>> + #elif CONFIG_LIBUKBOOT_INITREGION
>> + #include <uk/allocregion.h>
>> ++#elif CONFIG_LIBUKBOOT_INITTINYALLOC
>> ++#include <uk/tinyalloc.h>
>> + #endif
>> + #if CONFIG_LIBUKSCHED
>> + #include <uk/sched.h>
>> +@@ -233,6 +235,8 @@ void ukplat_entry(int argc, char *argv[])
>> + 			a = uk_allocbbuddy_init(md.base, md.len);
>> + #elif CONFIG_LIBUKBOOT_INITREGION
>> + 			a = uk_allocregion_init(md.base, md.len);
>> ++#elif CONFIG_LIBUKBOOT_INITTINYALLOC
>> ++			a = uk_tinyalloc_init(md.base, md.len);
>> + #endif
>> + 		} else {
>> + 			uk_alloc_addmem(a, md.base, md.len);
>> diff --git a/patches/0001-do-not-store-heap-info-statically.patch b/patches/0001-do-not-store-heap-info-statically.patch
>> new file mode 100644
>> index 0000000..fd7b953
>> --- /dev/null
>> +++ b/patches/0001-do-not-store-heap-info-statically.patch
>> @@ -0,0 +1,312 @@
>> +From: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
>> +Subject: Adapt tinyalloc interface to Unikraft
>> + - avoid statics: create a struct tinyalloc to store allocator metadata
>> + - pass struct metadata as argument to allocation functions
>> +diff -urNp tinyalloc-orig/tinyalloc.c tinyalloc-patched/tinyalloc.c
>> +--- tinyalloc-orig/tinyalloc.c	2019-08-17 23:56:45.000000000 +0200
>> ++++ tinyalloc-patched/tinyalloc.c	2020-06-30 10:34:24.945558078 +0200
>> +@@ -9,36 +9,16 @@ extern void print_i(size_t);
>> + #define print_i(X)
>> + #endif
>> + 
>> +-typedef struct Block Block;
>> +-
>> +-struct Block {
>> +-    void *addr;
>> +-    Block *next;
>> +-    size_t size;
>> +-};
>> +-
>> +-typedef struct {
>> +-    Block *free;   // first free block
>> +-    Block *used;   // first used block
>> +-    Block *fresh;  // first available blank block
>> +-    size_t top;    // top free addr
>> +-    Block *blocks;
>> +-} Heap;
>> +-
>> +-static Heap *heap = NULL;
>> +-static void *heap_limit = NULL;
>> +-static size_t heap_split_thresh;
>> +-static size_t heap_alignment;
>> +-static size_t heap_max_blocks;
>> +-
>> + /**
>> +  * If compaction is enabled, inserts block
>> +  * into free list, sorted by addr.
>> +  * If disabled, add block has new head of
>> +  * the free list.
>> +  */
>> +-static void insert_block(Block *block) {
>> +-#ifndef TA_DISABLE_COMPACT
>> ++static void insert_block(struct tinyalloc *a, Block *block) {
>> ++    Heap *heap = a->heap;
>> ++
>> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_COMPACT
>> +     Block *ptr  = heap->free;
>> +     Block *prev = NULL;
>> +     while (ptr != NULL) {
>> +@@ -66,8 +46,10 @@ static void insert_block(Block *block) {
>> + #endif
>> + }
>> + 
>> +-#ifndef TA_DISABLE_COMPACT
>> +-static void release_blocks(Block *scan, Block *to) {
>> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_COMPACT
>> ++static void release_blocks(struct tinyalloc *a, Block *scan, Block *to) {
>> ++    Heap *heap = a->heap;
>> ++
>> +     Block *scan_next;
>> +     while (scan != to) {
>> +         print_s("release");
>> +@@ -81,7 +63,9 @@ static void release_blocks(Block *scan,
>> +     }
>> + }
>> + 
>> +-static void compact() {
>> ++static void compact(struct tinyalloc *a) {
>> ++    Heap *heap = a->heap;
>> ++
>> +     Block *ptr = heap->free;
>> +     Block *prev;
>> +     Block *scan;
>> +@@ -103,7 +87,7 @@ static void compact() {
>> +             ptr->size   = new_size;
>> +             Block *next = prev->next;
>> +             // make merged blocks available
>> +-            release_blocks(ptr->next, prev->next);
>> ++            release_blocks(a, ptr->next, prev->next);
>> +             // relink
>> +             ptr->next = next;
>> +         }
>> +@@ -112,30 +96,36 @@ static void compact() {
>> + }
>> + #endif
>> + 
>> +-bool ta_init(const void *base, const void *limit, const size_t heap_blocks, const size_t split_thresh, const size_t alignment) {
>> +-    heap = (Heap *)base;
>> +-    heap_limit = limit;
>> +-    heap_split_thresh = split_thresh;
>> +-    heap_alignment = alignment;
>> +-    heap_max_blocks = heap_blocks;
>> ++void ta_init(struct tinyalloc *a, const void *base, const void *limit,
>> ++             const size_t heap_blocks, const size_t split_thresh,
>> ++             const size_t alignment) {
>> ++    Heap *heap;
>> ++
>> ++    a->heap = (Heap *)base;
>> ++    a->heap_limit = limit;
>> ++    a->heap_split_thresh = split_thresh;
>> ++    a->heap_alignment = alignment;
>> ++    a->heap_max_blocks = heap_blocks;
>> + 
>> ++    heap = a->heap;
>> +     heap->free   = NULL;
>> +     heap->used   = NULL;
>> ++    heap->blocks = (Block*) ((size_t)base + sizeof(Heap));
>> +     heap->fresh  = heap->blocks;
>> +     heap->top    = (size_t)base + sizeof(Heap) + heap_blocks * sizeof(Block);
>> +-    heap->blocks = base + sizeof(Heap);
>> + 
>> +     Block *block = heap->blocks;
>> +-    size_t i     = heap_max_blocks - 1;
>> ++    size_t i     = a->heap_max_blocks - 1;
>> +     while (i--) {
>> +         block->next = block + 1;
>> +         block++;
>> +     }
>> +     block->next = NULL;
>> +-    return true;
>> + }
>> + 
>> +-bool ta_free(void *free) {
>> ++void ta_free(struct tinyalloc *a, void *free) {
>> ++    Heap *heap = a->heap;
>> ++
>> +     Block *block = heap->used;
>> +     Block *prev  = NULL;
>> +     while (block != NULL) {
>> +@@ -145,25 +135,28 @@ bool ta_free(void *free) {
>> +             } else {
>> +                 heap->used = block->next;
>> +             }
>> +-            insert_block(block);
>> +-#ifndef TA_DISABLE_COMPACT
>> +-            compact();
>> ++            insert_block(a, block);
>> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_COMPACT
>> ++            compact(a);
>> + #endif
>> +-            return true;
>> ++            return;
>> +         }
>> +         prev  = block;
>> +         block = block->next;
>> +     }
>> +-    return false;
>> ++    return;
>> + }
>> + 
>> +-static Block *alloc_block(size_t num) {
>> ++static Block *alloc_block(struct tinyalloc *a, size_t num) {
>> ++    Heap *heap = a->heap;
>> ++
>> +     Block *ptr  = heap->free;
>> +     Block *prev = NULL;
>> +     size_t top  = heap->top;
>> +-    num         = (num + heap_alignment - 1) & -heap_alignment;
>> ++    num         = (num + a->heap_alignment - 1) & - a->heap_alignment;
>> +     while (ptr != NULL) {
>> +-        const int is_top = ((size_t)ptr->addr + ptr->size >= top) && ((size_t)ptr->addr + num <= heap_limit);
>> ++        const int is_top = ((size_t)ptr->addr + ptr->size >= top)
>> ++		        && ((size_t)ptr->addr + num <= a->heap_limit);
>> +         if (is_top || ptr->size >= num) {
>> +             if (prev != NULL) {
>> +                 prev->next = ptr->next;
>> +@@ -176,10 +169,10 @@ static Block *alloc_block(size_t num) {
>> +                 print_s("resize top block");
>> +                 ptr->size = num;
>> +                 heap->top = (size_t)ptr->addr + num;
>> +-#ifndef TA_DISABLE_SPLIT
>> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_SPLIT
>> +             } else if (heap->fresh != NULL) {
>> +                 size_t excess = ptr->size - num;
>> +-                if (excess >= heap_split_thresh) {
>> ++                if (excess >= a->heap_split_thresh) {
>> +                     ptr->size    = num;
>> +                     Block *split = heap->fresh;
>> +                     heap->fresh  = split->next;
>> +@@ -187,9 +180,9 @@ static Block *alloc_block(size_t num) {
>> +                     print_s("split");
>> +                     print_i((size_t)split->addr);
>> +                     split->size = excess;
>> +-                    insert_block(split);
>> +-#ifndef TA_DISABLE_COMPACT
>> +-                    compact();
>> ++                    insert_block(a, split);
>> ++#ifndef CONFIG_LIBTINYALLOC_DISABLE_COMPACT
>> ++                    compact(a);
>> + #endif
>> +                 }
>> + #endif
>> +@@ -199,10 +192,11 @@ static Block *alloc_block(size_t num) {
>> +         prev = ptr;
>> +         ptr  = ptr->next;
>> +     }
>> ++
>> +     // no matching free blocks
>> +     // see if any other blocks available
>> +     size_t new_top = top + num;
>> +-    if (heap->fresh != NULL && new_top <= heap_limit) {
>> ++    if (heap->fresh != NULL && new_top <= (size_t)a->heap_limit) {
>> +         ptr         = heap->fresh;
>> +         heap->fresh = ptr->next;
>> +         ptr->addr   = (void *)top;
>> +@@ -212,11 +206,12 @@ static Block *alloc_block(size_t num) {
>> +         heap->top   = new_top;
>> +         return ptr;
>> +     }
>> ++
>> +     return NULL;
>> + }
>> + 
>> +-void *ta_alloc(size_t num) {
>> +-    Block *block = alloc_block(num);
>> ++void *ta_alloc(struct tinyalloc *a, size_t num) {
>> ++    Block *block = alloc_block(a, num);
>> +     if (block != NULL) {
>> +         return block->addr;
>> +     }
>> +@@ -236,9 +231,9 @@ static void memclear(void *ptr, size_t n
>> +     }
>> + }
>> + 
>> +-void *ta_calloc(size_t num, size_t size) {
>> ++void *ta_calloc(struct tinyalloc *a, size_t num, size_t size) {
>> +     num *= size;
>> +-    Block *block = alloc_block(num);
>> ++    Block *block = alloc_block(a, num);
>> +     if (block != NULL) {
>> +         memclear(block->addr, num);
>> +         return block->addr;
>> +@@ -255,18 +250,21 @@ static size_t count_blocks(Block *ptr) {
>> +     return num;
>> + }
>> + 
>> +-size_t ta_num_free() {
>> ++size_t ta_num_free(struct tinyalloc *a) {
>> ++    Heap *heap = a->heap;
>> +     return count_blocks(heap->free);
>> + }
>> + 
>> +-size_t ta_num_used() {
>> ++size_t ta_num_used(struct tinyalloc *a) {
>> ++    Heap *heap = a->heap;
>> +     return count_blocks(heap->used);
>> + }
>> + 
>> +-size_t ta_num_fresh() {
>> ++size_t ta_num_fresh(struct tinyalloc *a) {
>> ++    Heap *heap = a->heap;
>> +     return count_blocks(heap->fresh);
>> + }
>> + 
>> +-bool ta_check() {
>> +-    return heap_max_blocks == ta_num_free() + ta_num_used() + ta_num_fresh();
>> ++bool ta_check(struct tinyalloc *a) {
>> ++    return a->heap_max_blocks == ta_num_free(a) + ta_num_used(a) + ta_num_fresh(a);
>> + }
>> +diff -urNp tinyalloc-orig/tinyalloc.h tinyalloc-patched/tinyalloc.h
>> +--- tinyalloc-orig/tinyalloc.h	2019-08-17 23:56:45.000000000 +0200
>> ++++ tinyalloc-patched/tinyalloc.h	2020-06-30 10:38:59.734724059 +0200
>> +@@ -1,12 +1,41 @@
>> + #include <stdbool.h>
>> + #include <stddef.h>
>> + 
>> +-bool ta_init(const void *base, const void *limit, const size_t heap_blocks, const size_t split_thresh, const size_t alignment);
>> +-void *ta_alloc(size_t num);
>> +-void *ta_calloc(size_t num, size_t size);
>> +-bool ta_free(void *ptr);
>> +-
>> +-size_t ta_num_free();
>> +-size_t ta_num_used();
>> +-size_t ta_num_fresh();
>> +-bool ta_check();
>> ++typedef struct Block Block;
>> ++
>> ++struct Block {
>> ++    void *addr;
>> ++    Block *next;
>> ++    size_t size;
>> ++};
>> ++
>> ++typedef struct {
>> ++    Block *free;   // first free block
>> ++    Block *used;   // first used block
>> ++    Block *fresh;  // first available blank block
>> ++    size_t top;    // top free addr
>> ++    Block *blocks;
>> ++} Heap;
>> ++
>> ++struct tinyalloc {
>> ++    Heap *heap;
>> ++    void *heap_limit;
>> ++    size_t heap_split_thresh;
>> ++    size_t heap_alignment;
>> ++    size_t heap_max_blocks;
>> ++};
>> ++
>> ++void ta_init(struct tinyalloc *a, const void *base, const void *limit,
>> ++             const size_t heap_blocks, const size_t split_thresh,
>> ++             const size_t alignment);
>> ++
>> ++void *ta_alloc(struct tinyalloc *a, size_t num);
>> ++void *ta_calloc(struct tinyalloc *a, size_t num, size_t size);
>> ++void  ta_free(struct tinyalloc *a, void *ptr);
>> ++int   ta_posix_memalign(struct tinyalloc *a, void **memptr, size_t align,
>> ++			size_t size);
>> ++
>> ++size_t ta_num_free(struct tinyalloc *a);
>> ++size_t ta_num_used(struct tinyalloc *a);
>> ++size_t ta_num_fresh(struct tinyalloc *a);
>> ++bool   ta_check(struct tinyalloc *a);


From minios-devel-bounces@lists.xenproject.org Fri Sep 18 09:58:44 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 18 Sep 2020 09:58:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kJDA5-0004G7-CI; Fri, 18 Sep 2020 09:58:37 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=pNnR=C3=gmail.com=razvand@srs-us1.protection.inumbo.net>)
 id 1kJDA3-0004G2-TV
 for minios-devel@lists.xenproject.org; Fri, 18 Sep 2020 09:58:36 +0000
X-Inumbo-ID: 3b6b1440-690d-4e69-8342-9df4d9aa8385
Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 3b6b1440-690d-4e69-8342-9df4d9aa8385;
 Fri, 18 Sep 2020 09:58:33 +0000 (UTC)
Received: by mail-wm1-x341.google.com with SMTP id z9so4921005wmk.1
 for <minios-devel@lists.xenproject.org>; Fri, 18 Sep 2020 02:58:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=dQ5D5HMzktwQl7qjdCFh0sx0x6HkdNzBXroGHIj4DCs=;
 b=chkxmhCH19rEazfZ1cBYzdAbfqNMzRIQM2Cznut4ds4xXXM0DTxzcxIMiD5fMP4Fgc
 mVXZJ2mNGKdUwWWmtMQIf2w3MwT4sQ7ChEIYS9vVAH+YvodUm16gYpWvLwEk7es96bVK
 Da2FSmiAwrM6KZ3FUlta52E04bSQnXzVw/nJ8h6Z3tYvorQTCshu/gdSmk618toEzYik
 2v+UibPof8rOweQQe4eXzzcEroQTO4TyJtNExHTJSlLRmJS1d9g3soiEiPO7Ouak0MGI
 VU3/FGcE+2vDxnMFnrweQa5EUGDtdx4s/4WojUzqH8yNeWfFwNx5VkmlASkyY5T8Ema3
 D+nw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:from:to:cc:subject:references:date
 :in-reply-to:message-id:user-agent:mime-version;
 bh=dQ5D5HMzktwQl7qjdCFh0sx0x6HkdNzBXroGHIj4DCs=;
 b=hulA6tjGRFSdHStXTlx+bjzPcJcYefFe79p2N70KJdhloI/nHJs8t82XuH2X4ozVmx
 u6f1GcA+2FXJWvZWJ+4FQYRJCuwqHPtZBWaHE79pM4zREl+notACmB4nEpiM/gSWRYGL
 Nb5c6amlr9j0mwabJ/E+UsGsvKYhw+4rRShIBBSvg9clRIvfdEUWlzCFp528Hx1hVnjV
 hmRhgm3DILp4JlUOS7aNVBGjD2Vrb3rRFQMTQlcjJSS1Z8LfMBSF4VUza4dlMn6KRhjq
 56PcmCzTkKc51nhUwd30ujsyx/pX9k7HDxIrwIa7MrI0LuV+oDmjSoxU//dMlq6EYak/
 b2Vw==
X-Gm-Message-State: AOAM533oUsYKQNAalSdzpLV2Bty/OdviXW1v3NVCaTAiI80/9hPb2xwy
 OGHJC3W+Yo7d6GLoUwzMhds=
X-Google-Smtp-Source: ABdhPJzlPaNomVUUiJolmiJespj8949raba/79GkGtKtk6dY6XEa+scqVUHkWLsZxLgQqm9kjGAFMA==
X-Received: by 2002:a7b:c401:: with SMTP id k1mr2611650wmi.120.1600423112264; 
 Fri, 18 Sep 2020 02:58:32 -0700 (PDT)
Received: from localhost ([141.85.233.147])
 by smtp.gmail.com with ESMTPSA id y5sm4064924wmg.21.2020.09.18.02.58.31
 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);
 Fri, 18 Sep 2020 02:58:31 -0700 (PDT)
From: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
To: Hugo Lefeuvre <hle@owl.eu.com>
Cc: <minios-devel@lists.xenproject.org>
Subject: Re: [UNIKRAFT/LIBTLSF PATCH v2] Initial port of TLSF to Unikraft
References: <cover.1593603394.git.hugo.lefeuvre@neclab.eu>
 <78be00dc6e5eebe282eee77f6373e81028a38c46.1593603394.git.hugo.lefeuvre@neclab.eu>
Date: Fri, 18 Sep 2020 12:58:31 +0300
In-Reply-To: <78be00dc6e5eebe282eee77f6373e81028a38c46.1593603394.git.hugo.lefeuvre@neclab.eu>
 (Hugo Lefeuvre's message of "Wed, 1 Jul 2020 13:37:56 +0200")
Message-ID: <861riz4da0.fsf@drone.cs.pub.ro>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi, Hugo.

It works, I tested on KVM and linuxu.

I only have the comment I made for libtinyalloc:
---
When selecting tinyalloc in the configuration screen, the malloc
compatibility interface should also be automatically selected. It's not
obvious it has to be selected and one may miss it.
---

Other than that, all good.

Razvan

Hugo Lefeuvre <hugo.lefeuvre@neclab.eu> writes:
> Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> ---
>  Config.uk                                          |  20 +++
>  Makefile.uk                                        |  77 ++++++++++
>  README.md                                          |  12 ++
>  glue.c                                             |  77 ++++++++++
>  include/uk/tlsf.h                                  |  48 +++++++
>  main-tree.patch                                    |  42 ++++++
>  ...onfig-vars-and-parametrize-tlsf-interface.patch | 160 +++++++++++++++++++++
>  7 files changed, 436 insertions(+)
>  create mode 100644 Config.uk
>  create mode 100644 Makefile.uk
>  create mode 100644 README.md
>  create mode 100644 glue.c
>  create mode 100644 include/uk/tlsf.h
>  create mode 100644 main-tree.patch
>  create mode 100644 patches/config-vars-and-parametrize-tlsf-interface.patch
>
> diff --git a/Config.uk b/Config.uk
> new file mode 100644
> index 0000000..29732d0
> --- /dev/null
> +++ b/Config.uk
> @@ -0,0 +1,20 @@
> +menuconfig LIBTLSF
> +	   bool "TLSF - real-time dynamic memory allocator"
> +	   select LIBUKALLOC_IFMALLOC
> +	   default n
> +
> +if LIBTLSF
> +	config TLSF_LOG2_SLI
> +		int "log2 of second level index (SLI)"
> +		default 5
> +		help
> +			The Second Level Index subdivides linearily the first level lists.
> +
> +			The SLI has to be a power of two and is here represented as log2
> +			of the number of second level divisions.
> +
> +			For instance, TLSF_LOG2_SLI = 5 implies 32 second level divisions.
> +
> +			Higher values of SLI imply less fragmentation, at the cost of an
> +			increased space overhead of metadata.
> +endif
> diff --git a/Makefile.uk b/Makefile.uk
> new file mode 100644
> index 0000000..373181e
> --- /dev/null
> +++ b/Makefile.uk
> @@ -0,0 +1,77 @@
> +#  libtlsf Makefile.uk
> +#
> +#  Authors: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> +#
> +#
> +#  Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
> +#
> +#  Redistribution and use in source and binary forms, with or without
> +#  modification, are permitted provided that the following conditions
> +#  are met:
> +#
> +#  1. Redistributions of source code must retain the above copyright
> +#     notice, this list of conditions and the following disclaimer.
> +#  2. Redistributions in binary form must reproduce the above copyright
> +#     notice, this list of conditions and the following disclaimer in the
> +#     documentation and/or other materials provided with the distribution.
> +#  3. Neither the name of the copyright holder nor the names of its
> +#     contributors may be used to endorse or promote products derived from
> +#     this software without specific prior written permission.
> +#
> +#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> +#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> +#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> +#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> +#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> +#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> +#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> +#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> +#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> +#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> +#  POSSIBILITY OF SUCH DAMAGE.
> +
> +################################################################################
> +# Library registration
> +################################################################################
> +$(eval $(call addlib_s,libtlsf,$(CONFIG_LIBTLSF)))
> +
> +################################################################################
> +# Sources
> +################################################################################
> +LIBTLSF_VERSION=2.4.6
> +LIBTLSF_URL=http://wks.gii.upv.es/tlsf/files/src/TLSF-$(LIBTLSF_VERSION).tbz2
> +LIBTLSF_DIR=TLSF-$(LIBTLSF_VERSION)
> +
> +LIBTLSF_PATCHDIR=$(LIBTLSF_BASE)/patches
> +$(eval $(call fetch,libtlsf,$(LIBTLSF_URL),TLSF-$(LIBTLSF_VERSION).tbz2))
> +$(eval $(call patch,libtlsf,$(LIBTLSF_PATCHDIR),$(LIBTLSF_DIR)))
> +
> +################################################################################
> +# Helpers
> +################################################################################
> +LIBTLSF=$(LIBTLSF_ORIGIN)/$(LIBTLSF_DIR)
> +
> +################################################################################
> +# Library includes
> +################################################################################
> +
> +CINCLUDES-$(CONFIG_LIBTLSF) +=	-I$(LIBTLSF_BASE)		\
> +				-I$(LIBTLSF_BASE)/include	\
> +				-I$(LIBTLSF)/src
> +
> +################################################################################
> +# Global flags
> +################################################################################
> +
> +# no locks, no sbrk, no mmap
> +CFLAGS-$(CONFIG_LIBTLSF) +=  -DTLSF_USE_LOCKS=0 -DUSE_MMAP=0 -DUSE_SBRK=0
> +
> +################################################################################
> +# Glue code
> +################################################################################
> +LIBTLSF_SRCS-y += $(LIBTLSF_BASE)/glue.c
> +
> +################################################################################
> +# Sources
> +################################################################################
> +LIBTLSF_SRCS-y += $(LIBTLSF)/src/tlsf.c
> diff --git a/README.md b/README.md
> new file mode 100644
> index 0000000..2e665a3
> --- /dev/null
> +++ b/README.md
> @@ -0,0 +1,12 @@
> +TLSF for Unikraft
> +=================
> +
> +This is the port of the TLSF [0] general-purpose memory allocator for Unikraft
> +as an external library.
> +
> +How to use this allocator in your unikernel application:
> +
> +- apply main-tree.patch to the main tree
> +- select "TLSF" in `ukboot > Default memory allocator`
> +
> +[0] http://www.gii.upv.es/tlsf/
> diff --git a/glue.c b/glue.c
> new file mode 100644
> index 0000000..8becfe9
> --- /dev/null
> +++ b/glue.c
> @@ -0,0 +1,77 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Authors: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> + *
> + * Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of the copyright holder nor the names of its
> + *    contributors may be used to endorse or promote products derived from
> + *    this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> + * POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#include <uk/tlsf.h>
> +#include <uk/alloc_impl.h>
> +#include <tlsf.h>
> +
> +/* malloc interface */
> +
> +static void *uk_tlsf_malloc(struct uk_alloc *a, size_t size)
> +{
> +	return tlsf_malloc(size, (void *)((uintptr_t) a +
> +					sizeof(struct uk_alloc)));
> +}
> +
> +static void uk_tlsf_free(struct uk_alloc *a, void *ptr)
> +{
> +	tlsf_free(ptr, (void *)((uintptr_t) a + sizeof(struct uk_alloc)));
> +}
> +
> +/* initialization */
> +
> +struct uk_alloc *uk_tlsf_init(void *base, size_t len)
> +{
> +	struct uk_alloc *a;
> +	size_t res;
> +
> +	/* enough space for allocator available? */
> +	if (sizeof(*a) > len) {
> +		uk_pr_err("Not enough space for allocator: %" __PRIsz
> +			  " B required but only %" __PRIuptr" B usable\n",
> +			  sizeof(*a), len);
> +		return NULL;
> +	}
> +
> +	/* store allocator metadata on the heap, just before the memory pool */
> +	a = (struct uk_alloc *)base;
> +	uk_pr_info("Initialize tlsf allocator @ 0x%" __PRIuptr ", len %"
> +			__PRIsz"\n", (uintptr_t)a, len);
> +
> +	res = init_memory_pool(len - sizeof(*a), base + sizeof(*a));
> +	if (res == (size_t)-1)
> +		return NULL;
> +
> +	uk_alloc_init_malloc_ifmalloc(a, uk_tlsf_malloc, uk_tlsf_free, NULL);
> +
> +	return a;
> +}
> diff --git a/include/uk/tlsf.h b/include/uk/tlsf.h
> new file mode 100644
> index 0000000..3e3482a
> --- /dev/null
> +++ b/include/uk/tlsf.h
> @@ -0,0 +1,48 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Authors: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> + *
> + * Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of the copyright holder nor the names of its
> + *    contributors may be used to endorse or promote products derived from
> + *    this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> + * POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#ifndef __LIBTLSF_H__
> +#define __LIBTLSF_H__
> +
> +#include <uk/alloc.h>
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +struct uk_alloc *uk_tlsf_init(void *base, size_t len);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* __LIBTLSF_H__ */
> diff --git a/main-tree.patch b/main-tree.patch
> new file mode 100644
> index 0000000..ca66278
> --- /dev/null
> +++ b/main-tree.patch
> @@ -0,0 +1,42 @@
> +From: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> +Subject: Add TLSF entry to the menuconfig and initialize it
> +diff --git a/lib/ukboot/Config.uk b/lib/ukboot/Config.uk
> +index a888bc1c..b79b370e 100644
> +--- a/lib/ukboot/Config.uk
> ++++ b/lib/ukboot/Config.uk
> +@@ -32,6 +32,13 @@ if LIBUKBOOT
> + 		  Satisfy allocation as fast as possible. No support for free().
> + 		  Refer to help in ukallocregion for more information.
> + 
> ++		config LIBUKBOOT_INITTLSF
> ++		bool "TLSF"
> ++		select LIBTLSF
> ++		help
> ++		  Real-time allocator. Bounded fragmentation, allocation, and
> ++		  deallocation.
> ++
> + 		config LIBUKBOOT_NOALLOC
> + 		bool "No memory allocator"
> + 
> +diff --git a/lib/ukboot/boot.c b/lib/ukboot/boot.c
> +index 4e749aa5..37aafd70 100644
> +--- a/lib/ukboot/boot.c
> ++++ b/lib/ukboot/boot.c
> +@@ -45,6 +45,8 @@
> + #include <uk/allocbbuddy.h>
> + #elif CONFIG_LIBUKBOOT_INITREGION
> + #include <uk/allocregion.h>
> ++#elif CONFIG_LIBUKBOOT_INITTLSF
> ++#include <uk/tlsf.h>
> + #endif
> + #if CONFIG_LIBUKSCHED
> + #include <uk/sched.h>
> +@@ -233,6 +235,8 @@ void ukplat_entry(int argc, char *argv[])
> + 			a = uk_allocbbuddy_init(md.base, md.len);
> + #elif CONFIG_LIBUKBOOT_INITREGION
> + 			a = uk_allocregion_init(md.base, md.len);
> ++#elif CONFIG_LIBUKBOOT_INITTLSF
> ++			a = uk_tlsf_init(md.base, md.len);
> + #endif
> + 		} else {
> + 			uk_alloc_addmem(a, md.base, md.len);
> diff --git a/patches/config-vars-and-parametrize-tlsf-interface.patch b/patches/config-vars-and-parametrize-tlsf-interface.patch
> new file mode 100644
> index 0000000..e77cf56
> --- /dev/null
> +++ b/patches/config-vars-and-parametrize-tlsf-interface.patch
> @@ -0,0 +1,160 @@
> +From: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
> +Subject: Adapt TLSF interface to Unikraft
> + - expose MAX_LOG2_SLI, users might want to modify this
> + - do not rely on static metadata; pass it as argument to the allocation
> +   interface
> +diff -urNp TLSF-2.4.6/src/tlsf.c TLSF-patched/src/tlsf.c
> +--- TLSF-2.4.6/src/tlsf.c	2009-10-06 11:25:15.000000000 +0200
> ++++ TLSF-patched/src/tlsf.c	2020-06-26 13:49:03.231027270 +0200
> +@@ -74,7 +74,6 @@
> + #define	USE_SBRK 	(0)
> + #endif
> + 
> +-
> + #if TLSF_USE_LOCKS
> + #include "target.h"
> + #else
> +@@ -129,7 +128,7 @@
> + #define BLOCK_ALIGN (sizeof(void *) * 2)
> + 
> + #define MAX_FLI		(30)
> +-#define MAX_LOG2_SLI	(5)
> ++#define MAX_LOG2_SLI	CONFIG_TLSF_LOG2_SLI
> + #define MAX_SLI		(1 << MAX_LOG2_SLI)     /* MAX_SLI = 2^MAX_LOG2_SLI */
> + 
> + #define FLI_OFFSET	(6)     /* tlsf structure just will manage blocks bigger */
> +@@ -451,8 +450,6 @@ static __inline__ bhdr_t *process_area(v
> + /******************** Begin of the allocator code *****************/
> + /******************************************************************/
> + 
> +-static char *mp = NULL;         /* Default memory pool. */
> +-
> + /******************************************************************/
> + size_t init_memory_pool(size_t mem_pool_size, void *mem_pool)
> + {
> +@@ -472,13 +469,10 @@ size_t init_memory_pool(size_t mem_pool_
> +     tlsf = (tlsf_t *) mem_pool;
> +     /* Check if already initialised */
> +     if (tlsf->tlsf_signature == TLSF_SIGNATURE) {
> +-        mp = mem_pool;
> +-        b = GET_NEXT_BLOCK(mp, ROUNDUP_SIZE(sizeof(tlsf_t)));
> ++        b = GET_NEXT_BLOCK(mem_pool, ROUNDUP_SIZE(sizeof(tlsf_t)));
> +         return b->size & BLOCK_SIZE;
> +     }
> + 
> +-    mp = mem_pool;
> +-
> +     /* Zeroing the memory pool */
> +     memset(mem_pool, 0, sizeof(tlsf_t));
> + 
> +@@ -615,13 +609,13 @@ void destroy_memory_pool(void *mem_pool)
> + 
> + 
> + /******************************************************************/
> +-void *tlsf_malloc(size_t size)
> ++void *tlsf_malloc(size_t size, void *mem_pool)
> + {
> + /******************************************************************/
> +     void *ret;
> + 
> + #if USE_MMAP || USE_SBRK
> +-    if (!mp) {
> ++    if (!mem_pool) {
> +         size_t area_size;
> +         void *area;
> + 
> +@@ -634,60 +628,60 @@ void *tlsf_malloc(size_t size)
> +     }
> + #endif
> + 
> +-    TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
> ++    TLSF_ACQUIRE_LOCK(&((tlsf_t *)mem_pool)->lock);
> + 
> +-    ret = malloc_ex(size, mp);
> ++    ret = malloc_ex(size, mem_pool);
> + 
> +-    TLSF_RELEASE_LOCK(&((tlsf_t *)mp)->lock);
> ++    TLSF_RELEASE_LOCK(&((tlsf_t *)mem_pool)->lock);
> + 
> +     return ret;
> + }
> + 
> + /******************************************************************/
> +-void tlsf_free(void *ptr)
> ++void tlsf_free(void *ptr, void *mem_pool)
> + {
> + /******************************************************************/
> + 
> +-    TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
> ++    TLSF_ACQUIRE_LOCK(&((tlsf_t *)mem_pool)->lock);
> + 
> +-    free_ex(ptr, mp);
> ++    free_ex(ptr, mem_pool);
> + 
> +-    TLSF_RELEASE_LOCK(&((tlsf_t *)mp)->lock);
> ++    TLSF_RELEASE_LOCK(&((tlsf_t *)mem_pool)->lock);
> + 
> + }
> + 
> + /******************************************************************/
> +-void *tlsf_realloc(void *ptr, size_t size)
> ++void *tlsf_realloc(void *ptr, size_t size, void *mem_pool)
> + {
> + /******************************************************************/
> +     void *ret;
> + 
> + #if USE_MMAP || USE_SBRK
> +-	if (!mp) {
> +-		return tlsf_malloc(size);
> ++	if (!mem_pool) {
> ++		return tlsf_malloc(size, mem_pool);
> + 	}
> + #endif
> + 
> +-    TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
> ++    TLSF_ACQUIRE_LOCK(&((tlsf_t *)mem_pool)->lock);
> + 
> +-    ret = realloc_ex(ptr, size, mp);
> ++    ret = realloc_ex(ptr, size, mem_pool);
> + 
> +-    TLSF_RELEASE_LOCK(&((tlsf_t *)mp)->lock);
> ++    TLSF_RELEASE_LOCK(&((tlsf_t *)mem_pool)->lock);
> + 
> +     return ret;
> + }
> + 
> + /******************************************************************/
> +-void *tlsf_calloc(size_t nelem, size_t elem_size)
> ++void *tlsf_calloc(size_t nelem, size_t elem_size, void *mem_pool)
> + {
> + /******************************************************************/
> +     void *ret;
> + 
> +-    TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
> ++    TLSF_ACQUIRE_LOCK(&((tlsf_t *)mem_pool)->lock);
> + 
> +-    ret = calloc_ex(nelem, elem_size, mp);
> ++    ret = calloc_ex(nelem, elem_size, mem_pool);
> + 
> +-    TLSF_RELEASE_LOCK(&((tlsf_t *)mp)->lock);
> ++    TLSF_RELEASE_LOCK(&((tlsf_t *)mem_pool)->lock);
> + 
> +     return ret;
> + }
> +diff -urNp TLSF-2.4.6/src/tlsf.h TLSF-patched/src/tlsf.h
> +--- TLSF-2.4.6/src/tlsf.h	2009-10-06 11:25:22.000000000 +0200
> ++++ TLSF-patched/src/tlsf.h	2020-06-26 09:24:01.159699745 +0200
> +@@ -31,9 +31,9 @@ extern void free_ex(void *, void *);
> + extern void *realloc_ex(void *, size_t, void *);
> + extern void *calloc_ex(size_t, size_t, void *);
> + 
> +-extern void *tlsf_malloc(size_t size);
> +-extern void tlsf_free(void *ptr);
> +-extern void *tlsf_realloc(void *ptr, size_t size);
> +-extern void *tlsf_calloc(size_t nelem, size_t elem_size);
> ++extern void *tlsf_malloc(size_t size, void *);
> ++extern void tlsf_free(void *ptr, void *);
> ++extern void *tlsf_realloc(void *ptr, size_t size, void *);
> ++extern void *tlsf_calloc(size_t nelem, size_t elem_size, void *);
> + 
> + #endif


From minios-devel-bounces@lists.xenproject.org Fri Sep 18 11:33:19 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 18 Sep 2020 11:33:19 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kJEdj-0004Hn-60; Fri, 18 Sep 2020 11:33:19 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=R1+5=C3=cs.pub.ro=razvan.deaconescu@srs-us1.protection.inumbo.net>)
 id 1kJEdh-0004HT-GQ
 for minios-devel@lists.xen.org; Fri, 18 Sep 2020 11:33:17 +0000
X-Inumbo-ID: 5c30073a-3cb7-4b0a-b994-436bddc63943
Received: from mx.upb.ro (unknown [141.85.13.210])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 5c30073a-3cb7-4b0a-b994-436bddc63943;
 Fri, 18 Sep 2020 11:33:15 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 09A77B561DB8;
 Fri, 18 Sep 2020 14:33:15 +0300 (EEST)
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
Received: from mx.upb.ro ([127.0.0.1])
 by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id Kx-GEx8Ybd3V; Fri, 18 Sep 2020 14:33:13 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 0AF4DB561DD0;
 Fri, 18 Sep 2020 14:33:13 +0300 (EEST)
X-Virus-Scanned: amavisd-new at upb.ro
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
Received: from mx.upb.ro ([127.0.0.1])
 by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id Zo0g1krMeSRy; Fri, 18 Sep 2020 14:33:12 +0300 (EEST)
Received: from localhost.localdomain (unknown [62.121.83.2])
 by mx.upb.ro (Postfix) with ESMTPSA id A1803B561DB8;
 Fri, 18 Sep 2020 14:33:12 +0300 (EEST)
From: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Subject: [PATCH v2 1/1] include/endian.h: Remove bswap* duplicate definitions
Date: Fri, 18 Sep 2020 14:32:51 +0300
Message-Id: <ec3b375248799803ca5346a8eb9573d8f71e2e72.1600428471.git.razvan.deaconescu@cs.pub.ro>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <cover.1600428471.git.razvan.deaconescu@cs.pub.ro>
References: <cover.1600428471.git.razvan.deaconescu@cs.pub.ro>
In-Reply-To: <cover.1600428471.git.razvan.deaconescu@cs.pub.ro>
References: <cover.1600428471.git.razvan.deaconescu@cs.pub.ro>
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Using Clang results in compilation errors regarding the `__bswapXY` and
`__builtin_bswapXY` functions. There are simultaneously a definition of
a macro `__bswapXY` and a definition of a function `__bswapXY`; GCC
doesn't complain, but Clang does.

This is happening in Unikraft because the Unikraft core libraries are
using a minimized Unikraft newlib library[4], while the Unikraft app is
using the upstream (complete) newlib library[5]. In the end there are
two `endian.h` files: one in the Unikraft newlib[6], another one in the
upstream newlib (<repo>/newlib/libc/include/machine/endian.h). The
Unikraft newlib version of `endian.h` defines `__bswapXY` as inline
functions, whereas the upstream newlib defines them as macros. This
results in an error from Clang; GCC doesn't mind, though it's an issue
having multiple definitions for the same thing (even if one is a macro
or one is a function).

This commit fixes the issue. It removes the `__bswapXY` parts from the
Unikraft version of `endian.h` and includes the upstream version of
`endian.h`.

Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
---
 include/endian.h | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/include/endian.h b/include/endian.h
index 3c8a752..f09c312 100644
--- a/include/endian.h
+++ b/include/endian.h
@@ -27,6 +27,8 @@
 #ifndef _ENDIAN_H
 #define _ENDIAN_H
 
+#include <machine/endian.h>
+
 #define __LITTLE_ENDIAN 1234
 #define __BIG_ENDIAN 4321
 #define __PDP_ENDIAN 3412
@@ -41,21 +43,6 @@
 
 #include <stdint.h>
 
-static inline uint16_t __bswap16(uint16_t __x)
-{
-	return __x<<8 | __x>>8;
-}
-
-static inline uint32_t __bswap32(uint32_t __x)
-{
-	return __x>>24 | (__x>>8&0xff00) | (__x<<8&0xff0000) | __x<<24;
-}
-
-static inline uint64_t __bswap64(uint64_t __x)
-{
-	return (__bswap32(__x)+0ULL)<<32 | __bswap32(__x>>32);
-}
-
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define htobe16(x) __bswap16(x)
 #define be16toh(x) __bswap16(x)
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri Sep 18 11:33:21 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 18 Sep 2020 11:33:21 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kJEde-0004HY-4U; Fri, 18 Sep 2020 11:33:14 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=R1+5=C3=cs.pub.ro=razvan.deaconescu@srs-us1.protection.inumbo.net>)
 id 1kJEdc-0004HT-Qp
 for minios-devel@lists.xen.org; Fri, 18 Sep 2020 11:33:12 +0000
X-Inumbo-ID: e50fb7d1-5228-44cc-b91c-348827d45555
Received: from mx.upb.ro (unknown [141.85.13.230])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id e50fb7d1-5228-44cc-b91c-348827d45555;
 Fri, 18 Sep 2020 11:33:10 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 70DC1B561DB0;
 Fri, 18 Sep 2020 14:33:09 +0300 (EEST)
Received: from mx.upb.ro ([127.0.0.1])
 by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id CySgRaoXTEzh; Fri, 18 Sep 2020 14:33:07 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 5C95CB561DB8;
 Fri, 18 Sep 2020 14:33:07 +0300 (EEST)
X-Virus-Scanned: amavisd-new at upb.ro
Received: from mx.upb.ro ([127.0.0.1])
 by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id zL6tXtNSOiT1; Fri, 18 Sep 2020 14:33:07 +0300 (EEST)
Received: from localhost.localdomain (unknown [62.121.83.2])
 by mx.upb.ro (Postfix) with ESMTPSA id EBB66B561DB0;
 Fri, 18 Sep 2020 14:33:06 +0300 (EEST)
From: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Subject: [PATCH v2 0/1] Fix clang compilation issue with bswap*
Date: Fri, 18 Sep 2020 14:32:50 +0300
Message-Id: <cover.1600428471.git.razvan.deaconescu@cs.pub.ro>
X-Mailer: git-send-email 2.17.1
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Using Clang results in compilation errors regarding the `__bswapXY` and
`__builtin_bswapXY` functions. There are simultaneously a definition of
a macro `__bswapXY` and a definition of a function `__bswapXY`; GCC
doesn't complain, but Clang does.

This patch fixes it. It's a rework of Alice Suiu's initial submission:
https://patchwork.unikraft.org/patch/737267/

Razvan Deaconescu (1):
  include/endian.h: Remove bswap* duplicate definitions

 include/endian.h | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Sep 21 09:25:57 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 21 Sep 2020 09:25:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kKI53-000459-DU; Mon, 21 Sep 2020 09:25:53 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gTJF=C3=gmail.com=punitagrawal@srs-us1.protection.inumbo.net>)
 id 1kJPE6-0006Pv-8Z
 for minios-devel@lists.xenproject.org; Fri, 18 Sep 2020 22:51:34 +0000
X-Inumbo-ID: 78b6628c-8a47-4f72-aa12-45b84abb37d8
Received: from mail-pl1-x632.google.com (unknown [2607:f8b0:4864:20::632])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 78b6628c-8a47-4f72-aa12-45b84abb37d8;
 Fri, 18 Sep 2020 22:51:33 +0000 (UTC)
Received: by mail-pl1-x632.google.com with SMTP id d19so3762983pld.0
 for <minios-devel@lists.xenproject.org>; Fri, 18 Sep 2020 15:51:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=O9eKnD0tkf2uqqIqjgTxwlADI260wQx3q+rIKogVSkc=;
 b=IBwqxy5FyfXKEiJHPDNokqnAufuI+onpgsf9oqhqdaB0+PsmRA7csiYYntrVbWkqFY
 3l6qm/zLPEfINNZVHiotKYR8AHayGwz7Son4wusOT4cOSJKAB8cILlfEsHcNZf4C08+y
 GGZSOfb4HRODQSjdschPVGvPBv/20f+kl8Z98ZI3ykhLLTyBePnNRl3wloi1HBjQSbmm
 22U6jKQe3+a5NUM2p5YDf3B4kKkGmrBrzYcMmrXmxv/IHXmq5u7g13N2Ul81c5e9kw3r
 aL5vulqnw0IbVhURIFbrNoOk5ALfCmTqw8SHBbAgdPQR4D9HJnLQSvekLbt/3Rdwly36
 JIvw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=O9eKnD0tkf2uqqIqjgTxwlADI260wQx3q+rIKogVSkc=;
 b=sYh14rWacrtHodl8SQPDYLkrdEjrujIgfNH7/m2f63ibOQdvC06jRuqASaIb8lyI92
 26WHz4p6g5bfqtcgS+u5+jRLGJFH/1wHgIGITZ5BHcGtUaJ7r+y/XY2dBtoYtpQkggxO
 jidy0s+/q9tSwl1j6MjFK2VpTOUtXQjG6fgnA153ztfhIN4ziQYU7UnTqaTsI8BqcpVo
 VPNEuJMSHnTCh69Toz7JGtKbMYNPcZxwQG0X8fxQ91yfqAZvbUr+7WJMVxpgxk9pV+pb
 ef4CYDhyiTrfM2yc9w6TKGcEct4zuIGewOEsm4NsTvzuqTVHFviEiPJNPmYUQ5e4812/
 NW6A==
X-Gm-Message-State: AOAM530LN6cYPsYyJAuTPBLm96+ShPoLP42UV7l5bPXxCAU5am2MlQX+
 HZj2eTervNR8c3adJxjfmDOf17iXYmGh7HHYarRrrJhVVac=
X-Google-Smtp-Source: ABdhPJwownVIDZ0DoyKJi22FCItYDh1WQNG3UNaiburfSxw1aVavdk71Dhjd33aVijqu7CfbbwJjPrdLKFPmpPm0P1s=
X-Received: by 2002:a17:90a:7c44:: with SMTP id
 e4mr13826726pjl.167.1600469492385; 
 Fri, 18 Sep 2020 15:51:32 -0700 (PDT)
MIME-Version: 1.0
References: <87h7s3clma.fsf@tinker>
 <CAD4BONcEaE4c9GxBDr4gccEeBER_PzzF8QajurGFLPpkAmMaBA@mail.gmail.com>
In-Reply-To: <CAD4BONcEaE4c9GxBDr4gccEeBER_PzzF8QajurGFLPpkAmMaBA@mail.gmail.com>
From: Punit Agrawal <punitagrawal@gmail.com>
Date: Sat, 19 Sep 2020 07:51:21 +0900
Message-ID: <CAD4BONdYkYNQRJKLA+gO0Xeum4Uya0HsHT5spqpyCmtxWAAuBQ@mail.gmail.com>
Subject: Re: Unikraft - Compile error on arm64
To: minios-devel@lists.xenproject.org
Cc: unikraft@listserv.neclab.eu, justin.he@arm.com
Content-Type: text/plain; charset="UTF-8"
X-Mailman-Approved-At: Mon, 21 Sep 2020 09:25:52 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

[ Resending after correcting Jia's email. Apologies for the extra copy ]

On Sat, Sep 19, 2020 at 7:48 AM Punit Agrawal <punitagrawal@gmail.com> wrote:
>
> [ +Jia He as he seems to be looking at the arm64 port ]
>
> An update below.
>
> On Sat, Sep 12, 2020 at 8:07 PM Punit Agrawal <punitagrawal@gmail.com> wrote:
>
> [...]
>
> > It seems that using "-no-pie" causes the helpers for builtin atomics to
> > go missing on arm64. A quick hack to drop the "-no-pie" leads to
> > conflicts with "-r".
>
> Turns out this is not quite what's happening. The problem was the
> missing flags to pull in libgcc.
>
> Incidentally, pulling the latest changes on the staging branch fixed
> the issue. See eddaa9b242 ("build: Link libgcc at the end of the link
> options list"). Not sure why the commit was missing from my repo last
> week.
>
> Although it fixes the missing atomic helpers, now I get a different
> error message -
>
> /usr/bin/ld: /home/punit/src/unikraft/apps/helloworld/build/helloworld_kvm-arm64.o:
> in function `init_have_lse_atomics':
> lse-init.o:(.text.startup+0xbc): undefined reference to `__getauxval'
> lse-init.o:(.text.startup+0xbc): relocation truncated to fit:
> R_AARCH64_CALL26 against undefined symbol `__getauxval'
> collect2: error: ld returned 1 exit status
> make[2]: *** [/home/punit/src/unikraft/unikraft/plat/kvm/Linker.uk:24:
> /home/punit/src/unikraft/apps/helloworld/build/helloworld_kvm-arm64.dbg]
> Error 1
> make[1]: *** [Makefile:973: sub-make] Error 2
> make[1]: Leaving directory '/home/punit/src/unikraft/unikraft'
> make: *** [Makefile:6: all] Error 2
>
> __getauxval is provided by libc but it's not being linked here. musl
> carries the symbol but is not being included in the libraries being
> linked for the "Helloworld" app.
>
> Any suggestions on how to get past this one?
>
> Thanks,
> Punit


From minios-devel-bounces@lists.xenproject.org Mon Sep 21 09:25:59 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 21 Sep 2020 09:25:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kKI53-000454-CB; Mon, 21 Sep 2020 09:25:53 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=gTJF=C3=gmail.com=punitagrawal@srs-us1.protection.inumbo.net>)
 id 1kJPBC-0005hG-35
 for minios-devel@lists.xenproject.org; Fri, 18 Sep 2020 22:48:34 +0000
X-Inumbo-ID: e42f0549-b900-45f5-802f-410199c1ae0a
Received: from mail-pf1-x42d.google.com (unknown [2607:f8b0:4864:20::42d])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e42f0549-b900-45f5-802f-410199c1ae0a;
 Fri, 18 Sep 2020 22:48:33 +0000 (UTC)
Received: by mail-pf1-x42d.google.com with SMTP id w7so4370042pfi.4
 for <minios-devel@lists.xenproject.org>; Fri, 18 Sep 2020 15:48:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=Jqb2ap8+cD2nVjIBW22ysxLdif48ZgqiDwR8CzFSpoE=;
 b=B+GQsnr5nBQHFT9AMZlgiVHMD68cI2r0j48Te28KiJKhKfe8XP0U/JRAvh208+bj2b
 GvP3wxcvQxtyBjU5MO2TT+1ETmbM2Ca8gg7w14P70OfsFVW0FLBUV6KvtUerXLTSguWK
 sL2u34DZymR0oB8Ay2/hQ0HNEoxef+T9AOmaBy5eOD5H1W7miVk+BJsqNOi74b0K+UKg
 cdXO8WhHq0/J6N2muzLf9JBEZB8DKAKETRI52unN8DORXquRgzOURwGRGgWfaW85Btay
 5Yq9IzNtigKQiyTkgbn5VztFHrxJb23jTHXhbobmnAUl5erjf/GcfDOpdafG6KL/dxog
 6X6Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=Jqb2ap8+cD2nVjIBW22ysxLdif48ZgqiDwR8CzFSpoE=;
 b=JZXmPeyEerfp38EbtfZi+5J2/rPpkaVtkSCxaNbDgwNteVGIJuUXH1FJ2XUcOg+7Bm
 LuqaHsLcjjH5AKpT8wTzRKbNid8/kOBEoQAZavAAFFSlNC3rh4DhSDut1ffsJ7dX/BUJ
 qjdWk77FlRB4a+k+ztX1w88NVttc1+NOYBqjqMWY6uWxnjEBvzs/7j5GFPE1lFL/PY16
 J878SNRsD/MXgijT8LTcQgJ+gxjPoMBAzLuLvSpieUXWSwuu0HhlfYUJTpUijwiCaBuw
 3Dgh5Y4X0D0sc8WnsCgGFtfgkhm0SKMzWn1r1AG+tVfj4yYqRi2vJeA62EV6MiDA5VxR
 SFXQ==
X-Gm-Message-State: AOAM530c1utt7xpEgF0QH6j4Xm78apWsYHDEqR6UEYd0N3dJUrirCQkJ
 NYzlWEXEoIN9EWvOcDiKvTtLTtllbojc86ByfCyTEgsUyLDOfQ==
X-Google-Smtp-Source: ABdhPJycmg+pQF0YSbHYQ5bbxT6QyKsgIrPqjfOI2+YLICZ9d1kbn2ZZhloTzdA5brS0XwQ4DqvhF0+4lmUO24eAWsE=
X-Received: by 2002:a62:3001:0:b029:142:2501:39e3 with SMTP id
 w1-20020a6230010000b0290142250139e3mr17011645pfw.50.1600469311881; Fri, 18
 Sep 2020 15:48:31 -0700 (PDT)
MIME-Version: 1.0
References: <87h7s3clma.fsf@tinker>
In-Reply-To: <87h7s3clma.fsf@tinker>
From: Punit Agrawal <punitagrawal@gmail.com>
Date: Sat, 19 Sep 2020 07:48:21 +0900
Message-ID: <CAD4BONcEaE4c9GxBDr4gccEeBER_PzzF8QajurGFLPpkAmMaBA@mail.gmail.com>
Subject: Re: Unikraft - Compile error on arm64
To: minios-devel@lists.xenproject.org
Cc: unikraft@listserv.neclab.eu, jia.he@arm.com
Content-Type: text/plain; charset="UTF-8"
X-Mailman-Approved-At: Mon, 21 Sep 2020 09:25:52 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

[ +Jia He as he seems to be looking at the arm64 port ]

An update below.

On Sat, Sep 12, 2020 at 8:07 PM Punit Agrawal <punitagrawal@gmail.com> wrote:

[...]

> It seems that using "-no-pie" causes the helpers for builtin atomics to
> go missing on arm64. A quick hack to drop the "-no-pie" leads to
> conflicts with "-r".

Turns out this is not quite what's happening. The problem was the
missing flags to pull in libgcc.

Incidentally, pulling the latest changes on the staging branch fixed
the issue. See eddaa9b242 ("build: Link libgcc at the end of the link
options list"). Not sure why the commit was missing from my repo last
week.

Although it fixes the missing atomic helpers, now I get a different
error message -

/usr/bin/ld: /home/punit/src/unikraft/apps/helloworld/build/helloworld_kvm-arm64.o:
in function `init_have_lse_atomics':
lse-init.o:(.text.startup+0xbc): undefined reference to `__getauxval'
lse-init.o:(.text.startup+0xbc): relocation truncated to fit:
R_AARCH64_CALL26 against undefined symbol `__getauxval'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/punit/src/unikraft/unikraft/plat/kvm/Linker.uk:24:
/home/punit/src/unikraft/apps/helloworld/build/helloworld_kvm-arm64.dbg]
Error 1
make[1]: *** [Makefile:973: sub-make] Error 2
make[1]: Leaving directory '/home/punit/src/unikraft/unikraft'
make: *** [Makefile:6: all] Error 2

__getauxval is provided by libc but it's not being linked here. musl
carries the symbol but is not being included in the libraries being
linked for the "Helloworld" app.

Any suggestions on how to get past this one?

Thanks,
Punit


From minios-devel-bounces@lists.xenproject.org Tue Sep 22 10:58:34 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 22 Sep 2020 10:58:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kKg0F-0002eM-OZ; Tue, 22 Sep 2020 10:58:31 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=1J9w=C7=suse.com=jgross@srs-us1.protection.inumbo.net>)
 id 1kKg0E-0002eB-MD
 for minios-devel@lists.xenproject.org; Tue, 22 Sep 2020 10:58:30 +0000
X-Inumbo-ID: 1e491c93-2f47-4a9a-9042-e020bb228108
Received: from mx2.suse.de (unknown [195.135.220.15])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 1e491c93-2f47-4a9a-9042-e020bb228108;
 Tue, 22 Sep 2020 10:58:29 +0000 (UTC)
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
 t=1600772308;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding;
 bh=/nDVjs2/5IIOEfLogSRalGlMj00tL33mRUyuagMoW00=;
 b=Pa/F6yNn5XFlOaw+AL0haAAIUm2vuo1k4uuy0TyYMBevI8dNi+esrRqhWXieetEoxLJJPV
 SzgXv9pGK5UxmVmk2wGBOJq3EBvyfHlHBeb2J8AL3YveQLlBcAQLKCXFzoXW4DNSUZxwc2
 c0sLdCns7sKTonRQNZJfsi3uZkxtshI=
Received: from relay2.suse.de (unknown [195.135.221.27])
 by mx2.suse.de (Postfix) with ESMTP id 63E35AD85;
 Tue, 22 Sep 2020 10:59:05 +0000 (UTC)
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross <jgross@suse.com>
Subject: [PATCH 0/2] mini-os: netfront: fix some issues
Date: Tue, 22 Sep 2020 12:58:24 +0200
Message-Id: <20200922105826.26274-1-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Fix two issues in mini-os netfront:

- undo init_netfront interface change and replace it with an alternative
- fix mini-os suspend/resume handling in netfront

Juergen Gross (2):
  mini-os: netfront: retrieve netmask and gateway via extra function
  mini-os: netfront: fix suspend/resume handling

 include/netfront.h |   4 +-
 lwip-net.c         |   4 +-
 netfront.c         | 173 ++++++++++++++++++++-------------------------
 test.c             |   2 +-
 4 files changed, 84 insertions(+), 99 deletions(-)

-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Sep 22 10:58:35 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 22 Sep 2020 10:58:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kKg0G-0002eT-Q0; Tue, 22 Sep 2020 10:58:32 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=1J9w=C7=suse.com=jgross@srs-us1.protection.inumbo.net>)
 id 1kKg0F-0002eH-M0
 for minios-devel@lists.xenproject.org; Tue, 22 Sep 2020 10:58:31 +0000
X-Inumbo-ID: a67fb3fc-4d5f-4935-b168-97b0d23d49c5
Received: from mx2.suse.de (unknown [195.135.220.15])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a67fb3fc-4d5f-4935-b168-97b0d23d49c5;
 Tue, 22 Sep 2020 10:58:29 +0000 (UTC)
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
 t=1600772308;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=gvV/6AUBRn3iyr7G7MIQr6c1JY593oPOEHum75Oq12E=;
 b=fPqa7Nk/C5Rdqdxq00C3hckZjNbLUH41347bJRZu1nmecYQjdOqYr5X05x1ajHVG++9udt
 WOqN9IJj4cuV1Snbcilg1G2FaA76ZCs4zn+KRVYpebDk5qIgSouYNeSiSoUJJ9p2UPxhRG
 yIGzlQTIpTdY6H8XM9jotsgB8W0mt9s=
Received: from relay2.suse.de (unknown [195.135.221.27])
 by mx2.suse.de (Postfix) with ESMTP id 813F0AE09;
 Tue, 22 Sep 2020 10:59:05 +0000 (UTC)
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross <jgross@suse.com>
Subject: [PATCH 1/2] mini-os: netfront: retrieve netmask and gateway via extra
 function
Date: Tue, 22 Sep 2020 12:58:25 +0200
Message-Id: <20200922105826.26274-2-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200922105826.26274-1-jgross@suse.com>
References: <20200922105826.26274-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Commit 1b8ed31f4ce40 ("mini-os: netfront: Read netmask and gateway from
Xenstore") modified init_netfront() to take two additional parameters.
This broke the Xen build as init_netfront() is used in grub stubdom,
too.

So instead of tightly coupling Mini-OS and Xen build via this interface
modification undo this change of init_netfront() and add two other
functions for retrieving the netmask and gateway for a network device.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/netfront.h |  4 +++-
 lwip-net.c         |  4 +++-
 netfront.c         | 21 +++++++++++++++------
 test.c             |  2 +-
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/include/netfront.h b/include/netfront.h
index bc3080e..ec641c8 100644
--- a/include/netfront.h
+++ b/include/netfront.h
@@ -7,7 +7,9 @@ struct netfront_dev *init_netfront(char *nodename,
                                    void (*netif_rx)(unsigned char *data,
                                                     int len, void* arg),
                                    unsigned char rawmac[6],
-                                   char **ip, char **mask, char **gw);
+                                   char **ip);
+char *netfront_get_netmask(struct netfront_dev *dev);
+char *netfront_get_gateway(struct netfront_dev *dev);
 void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
 void shutdown_netfront(struct netfront_dev *dev);
 void suspend_netfront(void);
diff --git a/lwip-net.c b/lwip-net.c
index 80d1c8f..7e0d871 100644
--- a/lwip-net.c
+++ b/lwip-net.c
@@ -347,7 +347,9 @@ void start_networking(void)
 
   tprintk("Waiting for network.\n");
 
-  dev = init_netfront(NULL, NULL, rawmac, &ip, &netmask_str, &gw_str);
+  dev = init_netfront(NULL, NULL, rawmac, &ip);
+  netmask_str = netfront_get_netmask(dev);
+  gw_str = netfront_get_gateway(dev);
   
   if (ip) {
     ipaddr.addr = inet_addr(ip);
diff --git a/netfront.c b/netfront.c
index 205484b..9057908 100644
--- a/netfront.c
+++ b/netfront.c
@@ -65,6 +65,8 @@ struct netfront_dev {
 
     void (*netif_rx)(unsigned char* data, int len, void* arg);
     void *netif_rx_arg;
+
+    struct netfront_dev_list *ldev;
 };
 
 struct netfront_dev_list {
@@ -303,7 +305,7 @@ struct netfront_dev *init_netfront(char *_nodename,
                                    void (*thenetif_rx)(unsigned char* data,
                                                        int len, void* arg),
                                    unsigned char rawmac[6],
-                                   char **ip, char **mask, char **gw)
+                                   char **ip)
 {
     char nodename[256];
     struct netfront_dev *dev;
@@ -347,6 +349,7 @@ struct netfront_dev *init_netfront(char *_nodename,
     memset(ldev, 0, sizeof(struct netfront_dev_list));
 
     if (_init_netfront(dev, ldev->rawmac, &(ldev->ip), &(ldev->mask), &(ldev->gw))) {
+        dev->ldev = ldev;
         ldev->dev = dev;
         ldev->refcount = 1;
         ldev->next = NULL;
@@ -376,15 +379,21 @@ out:
 	}
     if (ip)
         *ip = strdup(ldev->ip);
-    if (mask)
-        *mask = strdup(ldev->mask);
-    if (gw)
-        *gw = strdup(ldev->gw);
 
 err:
     return dev;
 }
 
+char *netfront_get_netmask(struct netfront_dev *dev)
+{
+    return dev->ldev->mask ? strdup(dev->ldev->mask) : NULL;
+}
+
+char *netfront_get_gateway(struct netfront_dev *dev)
+{
+    return dev->ldev->gw ? strdup(dev->ldev->gw) : NULL;
+}
+
 static struct netfront_dev *_init_netfront(struct netfront_dev *dev,
 					   unsigned char rawmac[6],
 					   char **ip, char **mask, char **gw)
@@ -576,7 +585,7 @@ error:
 int netfront_tap_open(char *nodename) {
     struct netfront_dev *dev;
 
-    dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL, NULL, NULL);
+    dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL);
     if (!dev) {
 	printk("TAP open failed\n");
 	errno = EIO;
diff --git a/test.c b/test.c
index 2e5f7f9..42a2666 100644
--- a/test.c
+++ b/test.c
@@ -91,7 +91,7 @@ static struct semaphore net_sem = __SEMAPHORE_INITIALIZER(net_sem, 0);
 
 static void netfront_thread(void *p)
 {
-    net_dev = init_netfront(NULL, NULL, NULL, NULL, NULL, NULL);
+    net_dev = init_netfront(NULL, NULL, NULL, NULL);
     up(&net_sem);
 }
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Sep 22 10:58:42 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 22 Sep 2020 10:58:42 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kKg0Q-0002hC-Cy; Tue, 22 Sep 2020 10:58:42 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=1J9w=C7=suse.com=jgross@srs-us1.protection.inumbo.net>)
 id 1kKg0P-0002eH-HA
 for minios-devel@lists.xenproject.org; Tue, 22 Sep 2020 10:58:41 +0000
X-Inumbo-ID: 76342151-97be-4589-ba7d-37626c0cc51e
Received: from mx2.suse.de (unknown [195.135.220.15])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 76342151-97be-4589-ba7d-37626c0cc51e;
 Tue, 22 Sep 2020 10:58:29 +0000 (UTC)
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1;
 t=1600772309;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=YmJEzG7WE6ySO04WKdM+x0q6b5S1uIVl7WRmYPejCdQ=;
 b=dKVaG9CnFcHwH5IIYZ4o+wPNPBlTRMa9xHVMaOqg/5YJMT9GBrjcbQjBgdwgOBEujNikM1
 RB7G/jp9PAp7vTBkuo/Y5yxgLEOM+IiKJBnaeuvCVQNqLFZaAsR1xhqFpAEFcAjgO8Bp8F
 31Xz+Nzqd0t/qisYDRJSl584T7qLtMY=
Received: from relay2.suse.de (unknown [195.135.221.27])
 by mx2.suse.de (Postfix) with ESMTP id A82E4B22E;
 Tue, 22 Sep 2020 10:59:05 +0000 (UTC)
From: Juergen Gross <jgross@suse.com>
To: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org
Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross <jgross@suse.com>
Subject: [PATCH 2/2] mini-os: netfront: fix suspend/resume handling
Date: Tue, 22 Sep 2020 12:58:26 +0200
Message-Id: <20200922105826.26274-3-jgross@suse.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200922105826.26274-1-jgross@suse.com>
References: <20200922105826.26274-1-jgross@suse.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Suspend/resume handling of netfront is completely broken from the
beginning. Commit d225f4012d69a1 ("Save/Restore Support: Add
suspend/restore support for netfront") introduced a new structure
netfront_dev_list referencing the real struct netfront_dev elements.
This list is used to setup the devices when resuming again.

Unfortunately the netfront_dev elements are released during suspend,
so at resume time those references will be stale.

Fix this whole mess by dropping struct netfront_dev_list again and
link the netfront_dev elements directly into a list. When suspending
don't free those elements.

The ip-address, netmask and gateway strings can just be released when
suspending and reread from xenstore at resume time.

Fixes: d225f4012d69a1 ("Save/Restore Support: Add suspend/restore support for netfront")
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 netfront.c | 162 ++++++++++++++++++++++-------------------------------
 1 file changed, 67 insertions(+), 95 deletions(-)

diff --git a/netfront.c b/netfront.c
index 9057908..2075410 100644
--- a/netfront.c
+++ b/netfront.c
@@ -36,6 +36,8 @@ struct net_buffer {
 };
 
 struct netfront_dev {
+    int refcount;
+
     domid_t dom;
 
     unsigned short tx_freelist[NET_TX_RING_SIZE + 1];
@@ -66,27 +68,19 @@ struct netfront_dev {
     void (*netif_rx)(unsigned char* data, int len, void* arg);
     void *netif_rx_arg;
 
-    struct netfront_dev_list *ldev;
-};
-
-struct netfront_dev_list {
-    struct netfront_dev *dev;
     unsigned char rawmac[6];
     char *ip;
     char *mask;
     char *gw;
 
-    int refcount;
-
-    struct netfront_dev_list *next;
+    struct netfront_dev *next;
 };
 
-static struct netfront_dev_list *dev_list = NULL;
+static struct netfront_dev *dev_list = NULL;
 
 void init_rx_buffers(struct netfront_dev *dev);
-static struct netfront_dev *_init_netfront(struct netfront_dev *dev,
-                                           unsigned char rawmac[6], char **ip, char **mask, char **gw);
-static void _shutdown_netfront(struct netfront_dev *dev);
+static struct netfront_dev *_init_netfront(struct netfront_dev *dev);
+static int _shutdown_netfront(struct netfront_dev *dev);
 void netfront_set_rx_handler(struct netfront_dev *dev,
                              void (*thenetif_rx)(unsigned char *data, int len,
                                                  void *arg),
@@ -276,6 +270,7 @@ static void free_netfront(struct netfront_dev *dev)
     mask_evtchn(dev->evtchn);
 
     free(dev->mac);
+    free(dev->ip);
     free(dev->backend);
 
     gnttab_end_access(dev->rx_ring_ref);
@@ -309,8 +304,7 @@ struct netfront_dev *init_netfront(char *_nodename,
 {
     char nodename[256];
     struct netfront_dev *dev;
-    struct netfront_dev_list *ldev = NULL;
-    struct netfront_dev_list *list = NULL;
+    struct netfront_dev *list;
     static int netfrontends = 0;
 
     if (!_nodename)
@@ -321,10 +315,9 @@ struct netfront_dev *init_netfront(char *_nodename,
     }
 
     /* Check if the device is already initialized */
-    for (list = dev_list; list != NULL; list = list->next) {
-        if (strcmp(nodename, list->dev->nodename) == 0) {
-            list->refcount++;
-            dev = list->dev;
+    for (dev = dev_list; dev != NULL; dev = dev->next) {
+        if (strcmp(nodename, dev->nodename) == 0) {
+            dev->refcount++;
             if (thenetif_rx)
                 netfront_set_rx_handler(dev, thenetif_rx, NULL);
             goto out;
@@ -345,40 +338,34 @@ struct netfront_dev *init_netfront(char *_nodename,
     dev->netif_rx = thenetif_rx;
     dev->netif_rx_arg = NULL;
 
-    ldev = malloc(sizeof(struct netfront_dev_list));
-    memset(ldev, 0, sizeof(struct netfront_dev_list));
-
-    if (_init_netfront(dev, ldev->rawmac, &(ldev->ip), &(ldev->mask), &(ldev->gw))) {
-        dev->ldev = ldev;
-        ldev->dev = dev;
-        ldev->refcount = 1;
-        ldev->next = NULL;
+    if (_init_netfront(dev)) {
+        dev->refcount = 1;
+        dev->next = NULL;
 
         if (!dev_list) {
-            dev_list = ldev;
+            dev_list = dev;
         } else {
             for (list = dev_list; list->next != NULL; list = list->next)
                 ;
-            list->next = ldev;
-		}
+            list->next = dev;
+        }
         netfrontends++;
     } else {
-        free(ldev);
         dev = NULL;
         goto err;
     }
 
 out:
     if (rawmac) {
-        rawmac[0] = ldev->rawmac[0];
-        rawmac[1] = ldev->rawmac[1];
-        rawmac[2] = ldev->rawmac[2];
-        rawmac[3] = ldev->rawmac[3];
-        rawmac[4] = ldev->rawmac[4];
-        rawmac[5] = ldev->rawmac[5];
+        rawmac[0] = dev->rawmac[0];
+        rawmac[1] = dev->rawmac[1];
+        rawmac[2] = dev->rawmac[2];
+        rawmac[3] = dev->rawmac[3];
+        rawmac[4] = dev->rawmac[4];
+        rawmac[5] = dev->rawmac[5];
 	}
     if (ip)
-        *ip = strdup(ldev->ip);
+        *ip = strdup(dev->ip);
 
 err:
     return dev;
@@ -386,17 +373,15 @@ err:
 
 char *netfront_get_netmask(struct netfront_dev *dev)
 {
-    return dev->ldev->mask ? strdup(dev->ldev->mask) : NULL;
+    return dev->mask ? strdup(dev->mask) : NULL;
 }
 
 char *netfront_get_gateway(struct netfront_dev *dev)
 {
-    return dev->ldev->gw ? strdup(dev->ldev->gw) : NULL;
+    return dev->gw ? strdup(dev->gw) : NULL;
 }
 
-static struct netfront_dev *_init_netfront(struct netfront_dev *dev,
-					   unsigned char rawmac[6],
-					   char **ip, char **mask, char **gw)
+static struct netfront_dev *_init_netfront(struct netfront_dev *dev)
 {
     xenbus_transaction_t xbt;
     char* err = NULL;
@@ -518,6 +503,8 @@ done:
     {
         XenbusState state;
         char path[strlen(dev->backend) + strlen("/state") + 1];
+        char *p;
+
         snprintf(path, sizeof(path), "%s/state", dev->backend);
 
         xenbus_watch_path_token(XBT_NIL, path, path, &dev->events);
@@ -532,26 +519,18 @@ done:
             goto error;
         }
 
-        if (ip) {
-            char *p;
-
-            snprintf(path, sizeof(path), "%s/ip", dev->backend);
-            xenbus_read(XBT_NIL, path, ip);
-
-            if (mask) {
-                p = strchr(*ip, ' ');
-                if (p) {
-                    *p++ = '\0';
-                    *mask = p;
-
-                    if (gw) {
-                        p = strchr(p, ' ');
-                        if (p) {
-                            *p++ = '\0';
-                            *gw = p;
-                        }
-                    }
-                }
+        snprintf(path, sizeof(path), "%s/ip", dev->backend);
+        xenbus_read(XBT_NIL, path, &dev->ip);
+
+        p = strchr(dev->ip, ' ');
+        if (p) {
+            *p++ = '\0';
+            dev->mask = p;
+
+            p = strchr(p, ' ');
+            if (p) {
+                *p++ = '\0';
+                dev->gw = p;
             }
         }
     }
@@ -563,14 +542,13 @@ done:
     /* Special conversion specifier 'hh' needed for __ia64__. Without
      * this mini-os panics with 'Unaligned reference'.
      */
-    if (rawmac)
-        sscanf(dev->mac,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
-               &rawmac[0],
-               &rawmac[1],
-               &rawmac[2],
-               &rawmac[3],
-               &rawmac[4],
-               &rawmac[5]);
+    sscanf(dev->mac,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+           &dev->rawmac[0],
+           &dev->rawmac[1],
+           &dev->rawmac[2],
+           &dev->rawmac[3],
+           &dev->rawmac[4],
+           &dev->rawmac[5]);
 
     return dev;
 
@@ -600,38 +578,33 @@ int netfront_tap_open(char *nodename) {
 
 void shutdown_netfront(struct netfront_dev *dev)
 {
-    struct netfront_dev_list *list = NULL;
-    struct netfront_dev_list *to_del = NULL;
+    struct netfront_dev *list;
 
     /* Check this is a valid device */
-    for (list = dev_list; list != NULL; list = list->next) {
-        if (list->dev == dev)
-            break;
-    }
+    for (list = dev_list; list != NULL && list != dev; list = list->next);
 
     if (!list) {
         printk("Trying to shutdown an invalid netfront device (%p)\n", dev);
         return;
     }
 
-    list->refcount--;
-    if (list->refcount == 0) {
-        _shutdown_netfront(dev);
+    dev->refcount--;
+    if (dev->refcount == 0) {
+        if (_shutdown_netfront(dev))
+            return;
 
-        to_del = list;
-        if (to_del == dev_list) {
-            free(to_del);
-			dev_list = NULL;
+        if (dev == dev_list) {
+            dev_list = NULL;
         } else {
-            for (list = dev_list; list->next != to_del; list = list->next)
+            for (list = dev_list; list->next != dev; list = list->next)
                 ;
-            list->next = to_del->next;
-            free(to_del);
+            list->next = dev->next;
         }
+        free_netfront(dev);
     }
 }
 
-static void _shutdown_netfront(struct netfront_dev *dev)
+static int _shutdown_netfront(struct netfront_dev *dev)
 {
     char* err = NULL, *err2;
     XenbusState state;
@@ -692,24 +665,23 @@ close:
     err2 = xenbus_rm(XBT_NIL, nodename);
     free(err2);
 
-    if (!err)
-        free_netfront(dev);
+    return err ? -EBUSY : 0;
 }
 
 void suspend_netfront(void)
 {
-    struct netfront_dev_list *list;
+    struct netfront_dev *dev;
 
-    for (list = dev_list; list != NULL; list = list->next)
-        _shutdown_netfront(list->dev);
+    for (dev = dev_list; dev != NULL; dev = dev->next)
+        _shutdown_netfront(dev);
 }
 
 void resume_netfront(void)
 {
-    struct netfront_dev_list *list;
+    struct netfront_dev *dev;
 
-    for (list = dev_list; list != NULL; list = list->next)
-        _init_netfront(list->dev, NULL, NULL, NULL, NULL);
+    for (dev = dev_list; dev != NULL; dev = dev->next)
+        _init_netfront(dev);
 }
 
 void init_rx_buffers(struct netfront_dev *dev)
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Tue Sep 22 20:10:39 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 22 Sep 2020 20:10:39 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kKocU-0003ot-TM; Tue, 22 Sep 2020 20:10:34 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=BMKS=C7=ens-lyon.org=samuel.thibault@srs-us1.protection.inumbo.net>)
 id 1kKocT-0003oM-VH
 for minios-devel@lists.xenproject.org; Tue, 22 Sep 2020 20:10:33 +0000
X-Inumbo-ID: 7f6df8b7-e141-4628-860d-acb38605fae0
Received: from hera.aquilenet.fr (unknown [185.233.100.1])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 7f6df8b7-e141-4628-860d-acb38605fae0;
 Tue, 22 Sep 2020 20:10:26 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 999B3C30;
 Tue, 22 Sep 2020 22:10:25 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id dp7Ncpw9qDYY; Tue, 22 Sep 2020 22:10:24 +0200 (CEST)
Received: from function (lfbn-bor-1-56-204.w90-50.abo.wanadoo.fr
 [90.50.148.204])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 69949BA6;
 Tue, 22 Sep 2020 22:10:24 +0200 (CEST)
Received: from samy by function with local (Exim 4.94)
 (envelope-from <samuel.thibault@ens-lyon.org>)
 id 1kKoaC-000Aa9-R3; Tue, 22 Sep 2020 22:08:12 +0200
Date: Tue, 22 Sep 2020 22:08:12 +0200
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
 wl@xen.org
Subject: Re: [PATCH 1/2] mini-os: netfront: retrieve netmask and gateway via
 extra function
Message-ID: <20200922200812.exxxucoxj27pe3ob@function>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org, wl@xen.org
References: <20200922105826.26274-1-jgross@suse.com>
 <20200922105826.26274-2-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20200922105826.26274-2-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Juergen Gross, le mar. 22 sept. 2020 12:58:25 +0200, a ecrit:
> Commit 1b8ed31f4ce40 ("mini-os: netfront: Read netmask and gateway from
> Xenstore") modified init_netfront() to take two additional parameters.
> This broke the Xen build as init_netfront() is used in grub stubdom,
> too.
> 
> So instead of tightly coupling Mini-OS and Xen build via this interface
> modification undo this change of init_netfront() and add two other
> functions for retrieving the netmask and gateway for a network device.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  include/netfront.h |  4 +++-
>  lwip-net.c         |  4 +++-
>  netfront.c         | 21 +++++++++++++++------
>  test.c             |  2 +-
>  4 files changed, 22 insertions(+), 9 deletions(-)
> 
> diff --git a/include/netfront.h b/include/netfront.h
> index bc3080e..ec641c8 100644
> --- a/include/netfront.h
> +++ b/include/netfront.h
> @@ -7,7 +7,9 @@ struct netfront_dev *init_netfront(char *nodename,
>                                     void (*netif_rx)(unsigned char *data,
>                                                      int len, void* arg),
>                                     unsigned char rawmac[6],
> -                                   char **ip, char **mask, char **gw);
> +                                   char **ip);
> +char *netfront_get_netmask(struct netfront_dev *dev);
> +char *netfront_get_gateway(struct netfront_dev *dev);
>  void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
>  void shutdown_netfront(struct netfront_dev *dev);
>  void suspend_netfront(void);
> diff --git a/lwip-net.c b/lwip-net.c
> index 80d1c8f..7e0d871 100644
> --- a/lwip-net.c
> +++ b/lwip-net.c
> @@ -347,7 +347,9 @@ void start_networking(void)
>  
>    tprintk("Waiting for network.\n");
>  
> -  dev = init_netfront(NULL, NULL, rawmac, &ip, &netmask_str, &gw_str);
> +  dev = init_netfront(NULL, NULL, rawmac, &ip);
> +  netmask_str = netfront_get_netmask(dev);
> +  gw_str = netfront_get_gateway(dev);
>    
>    if (ip) {
>      ipaddr.addr = inet_addr(ip);
> diff --git a/netfront.c b/netfront.c
> index 205484b..9057908 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -65,6 +65,8 @@ struct netfront_dev {
>  
>      void (*netif_rx)(unsigned char* data, int len, void* arg);
>      void *netif_rx_arg;
> +
> +    struct netfront_dev_list *ldev;
>  };
>  
>  struct netfront_dev_list {
> @@ -303,7 +305,7 @@ struct netfront_dev *init_netfront(char *_nodename,
>                                     void (*thenetif_rx)(unsigned char* data,
>                                                         int len, void* arg),
>                                     unsigned char rawmac[6],
> -                                   char **ip, char **mask, char **gw)
> +                                   char **ip)
>  {
>      char nodename[256];
>      struct netfront_dev *dev;
> @@ -347,6 +349,7 @@ struct netfront_dev *init_netfront(char *_nodename,
>      memset(ldev, 0, sizeof(struct netfront_dev_list));
>  
>      if (_init_netfront(dev, ldev->rawmac, &(ldev->ip), &(ldev->mask), &(ldev->gw))) {
> +        dev->ldev = ldev;
>          ldev->dev = dev;
>          ldev->refcount = 1;
>          ldev->next = NULL;
> @@ -376,15 +379,21 @@ out:
>  	}
>      if (ip)
>          *ip = strdup(ldev->ip);
> -    if (mask)
> -        *mask = strdup(ldev->mask);
> -    if (gw)
> -        *gw = strdup(ldev->gw);
>  
>  err:
>      return dev;
>  }
>  
> +char *netfront_get_netmask(struct netfront_dev *dev)
> +{
> +    return dev->ldev->mask ? strdup(dev->ldev->mask) : NULL;
> +}
> +
> +char *netfront_get_gateway(struct netfront_dev *dev)
> +{
> +    return dev->ldev->gw ? strdup(dev->ldev->gw) : NULL;
> +}
> +
>  static struct netfront_dev *_init_netfront(struct netfront_dev *dev,
>  					   unsigned char rawmac[6],
>  					   char **ip, char **mask, char **gw)
> @@ -576,7 +585,7 @@ error:
>  int netfront_tap_open(char *nodename) {
>      struct netfront_dev *dev;
>  
> -    dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL, NULL, NULL);
> +    dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL);
>      if (!dev) {
>  	printk("TAP open failed\n");
>  	errno = EIO;
> diff --git a/test.c b/test.c
> index 2e5f7f9..42a2666 100644
> --- a/test.c
> +++ b/test.c
> @@ -91,7 +91,7 @@ static struct semaphore net_sem = __SEMAPHORE_INITIALIZER(net_sem, 0);
>  
>  static void netfront_thread(void *p)
>  {
> -    net_dev = init_netfront(NULL, NULL, NULL, NULL, NULL, NULL);
> +    net_dev = init_netfront(NULL, NULL, NULL, NULL);
>      up(&net_sem);
>  }
>  #endif
> -- 
> 2.26.2
> 

-- 
Samuel
<k> faut en profiter, aujourd'hui, les blagues bidon sont à 100 dollars
 -+- #sos-bourse -+-


From minios-devel-bounces@lists.xenproject.org Tue Sep 22 20:10:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 22 Sep 2020 20:10:49 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kKocj-0003sq-75; Tue, 22 Sep 2020 20:10:49 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=BMKS=C7=ens-lyon.org=samuel.thibault@srs-us1.protection.inumbo.net>)
 id 1kKoch-0003sQ-Gd
 for minios-devel@lists.xenproject.org; Tue, 22 Sep 2020 20:10:47 +0000
X-Inumbo-ID: d1a4d7f5-1430-4614-b2b3-bb95a1cc6f1f
Received: from hera.aquilenet.fr (unknown [185.233.100.1])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id d1a4d7f5-1430-4614-b2b3-bb95a1cc6f1f;
 Tue, 22 Sep 2020 20:10:41 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 09D90C30;
 Tue, 22 Sep 2020 22:10:41 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id pxryrwfwi30i; Tue, 22 Sep 2020 22:10:39 +0200 (CEST)
Received: from function (lfbn-bor-1-56-204.w90-50.abo.wanadoo.fr
 [90.50.148.204])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id AF8B0BA6;
 Tue, 22 Sep 2020 22:10:39 +0200 (CEST)
Received: from samy by function with local (Exim 4.94)
 (envelope-from <samuel.thibault@ens-lyon.org>)
 id 1kKoaS-000AaP-7w; Tue, 22 Sep 2020 22:08:28 +0200
Date: Tue, 22 Sep 2020 22:08:28 +0200
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
 wl@xen.org
Subject: Re: [PATCH 2/2] mini-os: netfront: fix suspend/resume handling
Message-ID: <20200922200828.lh22kzmlgktbooma@function>
Mail-Followup-To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
 Juergen Gross <jgross@suse.com>, minios-devel@lists.xenproject.org,
 xen-devel@lists.xenproject.org, wl@xen.org
References: <20200922105826.26274-1-jgross@suse.com>
 <20200922105826.26274-3-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20200922105826.26274-3-jgross@suse.com>
Organization: I am not organized
User-Agent: NeoMutt/20170609 (1.8.3)
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Juergen Gross, le mar. 22 sept. 2020 12:58:26 +0200, a ecrit:
> Suspend/resume handling of netfront is completely broken from the
> beginning. Commit d225f4012d69a1 ("Save/Restore Support: Add
> suspend/restore support for netfront") introduced a new structure
> netfront_dev_list referencing the real struct netfront_dev elements.
> This list is used to setup the devices when resuming again.
> 
> Unfortunately the netfront_dev elements are released during suspend,
> so at resume time those references will be stale.
> 
> Fix this whole mess by dropping struct netfront_dev_list again and
> link the netfront_dev elements directly into a list. When suspending
> don't free those elements.
> 
> The ip-address, netmask and gateway strings can just be released when
> suspending and reread from xenstore at resume time.
> 
> Fixes: d225f4012d69a1 ("Save/Restore Support: Add suspend/restore support for netfront")
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  netfront.c | 162 ++++++++++++++++++++++-------------------------------
>  1 file changed, 67 insertions(+), 95 deletions(-)
> 
> diff --git a/netfront.c b/netfront.c
> index 9057908..2075410 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -36,6 +36,8 @@ struct net_buffer {
>  };
>  
>  struct netfront_dev {
> +    int refcount;
> +
>      domid_t dom;
>  
>      unsigned short tx_freelist[NET_TX_RING_SIZE + 1];
> @@ -66,27 +68,19 @@ struct netfront_dev {
>      void (*netif_rx)(unsigned char* data, int len, void* arg);
>      void *netif_rx_arg;
>  
> -    struct netfront_dev_list *ldev;
> -};
> -
> -struct netfront_dev_list {
> -    struct netfront_dev *dev;
>      unsigned char rawmac[6];
>      char *ip;
>      char *mask;
>      char *gw;
>  
> -    int refcount;
> -
> -    struct netfront_dev_list *next;
> +    struct netfront_dev *next;
>  };
>  
> -static struct netfront_dev_list *dev_list = NULL;
> +static struct netfront_dev *dev_list = NULL;
>  
>  void init_rx_buffers(struct netfront_dev *dev);
> -static struct netfront_dev *_init_netfront(struct netfront_dev *dev,
> -                                           unsigned char rawmac[6], char **ip, char **mask, char **gw);
> -static void _shutdown_netfront(struct netfront_dev *dev);
> +static struct netfront_dev *_init_netfront(struct netfront_dev *dev);
> +static int _shutdown_netfront(struct netfront_dev *dev);
>  void netfront_set_rx_handler(struct netfront_dev *dev,
>                               void (*thenetif_rx)(unsigned char *data, int len,
>                                                   void *arg),
> @@ -276,6 +270,7 @@ static void free_netfront(struct netfront_dev *dev)
>      mask_evtchn(dev->evtchn);
>  
>      free(dev->mac);
> +    free(dev->ip);
>      free(dev->backend);
>  
>      gnttab_end_access(dev->rx_ring_ref);
> @@ -309,8 +304,7 @@ struct netfront_dev *init_netfront(char *_nodename,
>  {
>      char nodename[256];
>      struct netfront_dev *dev;
> -    struct netfront_dev_list *ldev = NULL;
> -    struct netfront_dev_list *list = NULL;
> +    struct netfront_dev *list;
>      static int netfrontends = 0;
>  
>      if (!_nodename)
> @@ -321,10 +315,9 @@ struct netfront_dev *init_netfront(char *_nodename,
>      }
>  
>      /* Check if the device is already initialized */
> -    for (list = dev_list; list != NULL; list = list->next) {
> -        if (strcmp(nodename, list->dev->nodename) == 0) {
> -            list->refcount++;
> -            dev = list->dev;
> +    for (dev = dev_list; dev != NULL; dev = dev->next) {
> +        if (strcmp(nodename, dev->nodename) == 0) {
> +            dev->refcount++;
>              if (thenetif_rx)
>                  netfront_set_rx_handler(dev, thenetif_rx, NULL);
>              goto out;
> @@ -345,40 +338,34 @@ struct netfront_dev *init_netfront(char *_nodename,
>      dev->netif_rx = thenetif_rx;
>      dev->netif_rx_arg = NULL;
>  
> -    ldev = malloc(sizeof(struct netfront_dev_list));
> -    memset(ldev, 0, sizeof(struct netfront_dev_list));
> -
> -    if (_init_netfront(dev, ldev->rawmac, &(ldev->ip), &(ldev->mask), &(ldev->gw))) {
> -        dev->ldev = ldev;
> -        ldev->dev = dev;
> -        ldev->refcount = 1;
> -        ldev->next = NULL;
> +    if (_init_netfront(dev)) {
> +        dev->refcount = 1;
> +        dev->next = NULL;
>  
>          if (!dev_list) {
> -            dev_list = ldev;
> +            dev_list = dev;
>          } else {
>              for (list = dev_list; list->next != NULL; list = list->next)
>                  ;
> -            list->next = ldev;
> -		}
> +            list->next = dev;
> +        }
>          netfrontends++;
>      } else {
> -        free(ldev);
>          dev = NULL;
>          goto err;
>      }
>  
>  out:
>      if (rawmac) {
> -        rawmac[0] = ldev->rawmac[0];
> -        rawmac[1] = ldev->rawmac[1];
> -        rawmac[2] = ldev->rawmac[2];
> -        rawmac[3] = ldev->rawmac[3];
> -        rawmac[4] = ldev->rawmac[4];
> -        rawmac[5] = ldev->rawmac[5];
> +        rawmac[0] = dev->rawmac[0];
> +        rawmac[1] = dev->rawmac[1];
> +        rawmac[2] = dev->rawmac[2];
> +        rawmac[3] = dev->rawmac[3];
> +        rawmac[4] = dev->rawmac[4];
> +        rawmac[5] = dev->rawmac[5];
>  	}
>      if (ip)
> -        *ip = strdup(ldev->ip);
> +        *ip = strdup(dev->ip);
>  
>  err:
>      return dev;
> @@ -386,17 +373,15 @@ err:
>  
>  char *netfront_get_netmask(struct netfront_dev *dev)
>  {
> -    return dev->ldev->mask ? strdup(dev->ldev->mask) : NULL;
> +    return dev->mask ? strdup(dev->mask) : NULL;
>  }
>  
>  char *netfront_get_gateway(struct netfront_dev *dev)
>  {
> -    return dev->ldev->gw ? strdup(dev->ldev->gw) : NULL;
> +    return dev->gw ? strdup(dev->gw) : NULL;
>  }
>  
> -static struct netfront_dev *_init_netfront(struct netfront_dev *dev,
> -					   unsigned char rawmac[6],
> -					   char **ip, char **mask, char **gw)
> +static struct netfront_dev *_init_netfront(struct netfront_dev *dev)
>  {
>      xenbus_transaction_t xbt;
>      char* err = NULL;
> @@ -518,6 +503,8 @@ done:
>      {
>          XenbusState state;
>          char path[strlen(dev->backend) + strlen("/state") + 1];
> +        char *p;
> +
>          snprintf(path, sizeof(path), "%s/state", dev->backend);
>  
>          xenbus_watch_path_token(XBT_NIL, path, path, &dev->events);
> @@ -532,26 +519,18 @@ done:
>              goto error;
>          }
>  
> -        if (ip) {
> -            char *p;
> -
> -            snprintf(path, sizeof(path), "%s/ip", dev->backend);
> -            xenbus_read(XBT_NIL, path, ip);
> -
> -            if (mask) {
> -                p = strchr(*ip, ' ');
> -                if (p) {
> -                    *p++ = '\0';
> -                    *mask = p;
> -
> -                    if (gw) {
> -                        p = strchr(p, ' ');
> -                        if (p) {
> -                            *p++ = '\0';
> -                            *gw = p;
> -                        }
> -                    }
> -                }
> +        snprintf(path, sizeof(path), "%s/ip", dev->backend);
> +        xenbus_read(XBT_NIL, path, &dev->ip);
> +
> +        p = strchr(dev->ip, ' ');
> +        if (p) {
> +            *p++ = '\0';
> +            dev->mask = p;
> +
> +            p = strchr(p, ' ');
> +            if (p) {
> +                *p++ = '\0';
> +                dev->gw = p;
>              }
>          }
>      }
> @@ -563,14 +542,13 @@ done:
>      /* Special conversion specifier 'hh' needed for __ia64__. Without
>       * this mini-os panics with 'Unaligned reference'.
>       */
> -    if (rawmac)
> -        sscanf(dev->mac,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
> -               &rawmac[0],
> -               &rawmac[1],
> -               &rawmac[2],
> -               &rawmac[3],
> -               &rawmac[4],
> -               &rawmac[5]);
> +    sscanf(dev->mac,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
> +           &dev->rawmac[0],
> +           &dev->rawmac[1],
> +           &dev->rawmac[2],
> +           &dev->rawmac[3],
> +           &dev->rawmac[4],
> +           &dev->rawmac[5]);
>  
>      return dev;
>  
> @@ -600,38 +578,33 @@ int netfront_tap_open(char *nodename) {
>  
>  void shutdown_netfront(struct netfront_dev *dev)
>  {
> -    struct netfront_dev_list *list = NULL;
> -    struct netfront_dev_list *to_del = NULL;
> +    struct netfront_dev *list;
>  
>      /* Check this is a valid device */
> -    for (list = dev_list; list != NULL; list = list->next) {
> -        if (list->dev == dev)
> -            break;
> -    }
> +    for (list = dev_list; list != NULL && list != dev; list = list->next);
>  
>      if (!list) {
>          printk("Trying to shutdown an invalid netfront device (%p)\n", dev);
>          return;
>      }
>  
> -    list->refcount--;
> -    if (list->refcount == 0) {
> -        _shutdown_netfront(dev);
> +    dev->refcount--;
> +    if (dev->refcount == 0) {
> +        if (_shutdown_netfront(dev))
> +            return;
>  
> -        to_del = list;
> -        if (to_del == dev_list) {
> -            free(to_del);
> -			dev_list = NULL;
> +        if (dev == dev_list) {
> +            dev_list = NULL;
>          } else {
> -            for (list = dev_list; list->next != to_del; list = list->next)
> +            for (list = dev_list; list->next != dev; list = list->next)
>                  ;
> -            list->next = to_del->next;
> -            free(to_del);
> +            list->next = dev->next;
>          }
> +        free_netfront(dev);
>      }
>  }
>  
> -static void _shutdown_netfront(struct netfront_dev *dev)
> +static int _shutdown_netfront(struct netfront_dev *dev)
>  {
>      char* err = NULL, *err2;
>      XenbusState state;
> @@ -692,24 +665,23 @@ close:
>      err2 = xenbus_rm(XBT_NIL, nodename);
>      free(err2);
>  
> -    if (!err)
> -        free_netfront(dev);
> +    return err ? -EBUSY : 0;
>  }
>  
>  void suspend_netfront(void)
>  {
> -    struct netfront_dev_list *list;
> +    struct netfront_dev *dev;
>  
> -    for (list = dev_list; list != NULL; list = list->next)
> -        _shutdown_netfront(list->dev);
> +    for (dev = dev_list; dev != NULL; dev = dev->next)
> +        _shutdown_netfront(dev);
>  }
>  
>  void resume_netfront(void)
>  {
> -    struct netfront_dev_list *list;
> +    struct netfront_dev *dev;
>  
> -    for (list = dev_list; list != NULL; list = list->next)
> -        _init_netfront(list->dev, NULL, NULL, NULL, NULL);
> +    for (dev = dev_list; dev != NULL; dev = dev->next)
> +        _init_netfront(dev);
>  }
>  
>  void init_rx_buffers(struct netfront_dev *dev)
> -- 
> 2.26.2
> 

-- 
Samuel
 tohi.cybercable.fr (212.198.0.3) si une personne se reconnait derriere
 cette adresse que ce soit un pirate ou une victime qu'il se manifeste,
 cette personne pourrait bien etre un petit malin
 -+- Fred in NPC : Mamaaaaan, y a le routeur qui veut me hacker -+-


From minios-devel-bounces@lists.xenproject.org Thu Sep 24 07:47:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 24 Sep 2020 07:47:11 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kLLy6-0006En-8R; Thu, 24 Sep 2020 07:47:06 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=24Kt=DB=hotmail.com=wrotki@srs-us1.protection.inumbo.net>)
 id 1kLLy4-0006Ei-5W
 for minios-devel@lists.xenproject.org; Thu, 24 Sep 2020 07:47:04 +0000
X-Inumbo-ID: 00a116d5-bfae-44d9-b037-25354ebb18c4
Received: from NAM10-MW2-obe.outbound.protection.outlook.com (unknown
 [40.92.42.21]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 00a116d5-bfae-44d9-b037-25354ebb18c4;
 Thu, 24 Sep 2020 07:47:02 +0000 (UTC)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=i8dLcakiRWIcQlQnWvzipJ9ck37hpnTlb51l0bMd+8W1PiulPot7yopObtDi4d14pSmZIxlxoeyiOfR9glkPfpuULufRKu6RV+HW/AwThx4UW8+zedPUqGBv1PSr2nP+jDnvRlE68q9Jc0duCRHHuPCCNSBsyirspNf2EWHWFywfadWakZMC+CiCUKNHYZRq5iB1h5MTwLTObi+pRELXX3RZcV7vY+70gW44ZOxTVsRxKLpFa/xw5WyREffTHXe9UH/ynkSsRh4bWg4AVG4ZfT6f9JUJesJtSBp/ZImdMzolQcjqBdJRf8a3YhuPcdjuhTW1vjfPLMCej9yL6nYc3w==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=hQRZ8eP1ozH/sKpsVfmEEoDT6AjNT0yD/TKhL3l4Hr8=;
 b=VN2K54G1N6IG7+RbyGvWgFZapjSu+NbNQSFWkDlaCXpBCL625397ADRQKMXVXxFkVwxic4KBARPtBeb/pIF5eOYVy+FRSZriMODTELUYnBP9Pk54eQFgwJhOZr1UeKAkq+4m8cVYIDgxjQ33fuN2fS/BVvPoNlwcJEhiszYyT9ydz0CJCvWsz8uEI/bc9YtGsJJdP2uhgy2bIYeeiGtunClmblcjbKB7Vtgo2GFRt7V7jOFwWqld3fCcTviKmmuWPjTerQjajUasqP627z0gCna/8UHd6j4SMYbLeXLJtuZl4keDsqO5mKNiB9cYBA5zBLv5hgD0n6ivxh0s2VixnA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
 dkim=none; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=hQRZ8eP1ozH/sKpsVfmEEoDT6AjNT0yD/TKhL3l4Hr8=;
 b=Lqi26Mvs31DYRR7Fec9IvpiwesmgjND1hZnyAcMm+FFTxy5Ygqd0QrLU1ixyh5T2CwJ7zlOctcUTEV9qiPm+6NfQVKa7Ow00pintBqjfSZIvidwcw+kWJsAb0FtAldUUOhENEspxBb2H2QeOtvFpARqkeYPLFD6HzaTMYqWiehvirICJoNTDc4QZzKbNqpiBspJqDc7iIKhTvCnGMlJH+vIb9MUJvfEFquPUy0Rkcucm7FC8hf5eOmhLoQOvLpE0Pd/HvnXijHOhJGlFqcrwurrlPt7DEzehq0hvhvgFA1MAYZ0caExVwrrPL3lNAlFl2plf5t6Z5kkutWEbqy6Nlw==
Received: from DM6NAM10FT018.eop-nam10.prod.protection.outlook.com
 (2a01:111:e400:7e86::41) by
 DM6NAM10HT245.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::375)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.21; Thu, 24 Sep
 2020 07:47:00 +0000
Received: from MWHPR0401MB3594.namprd04.prod.outlook.com
 (2a01:111:e400:7e86::43) by DM6NAM10FT018.mail.protection.outlook.com
 (2a01:111:e400:7e86::401) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.21 via Frontend
 Transport; Thu, 24 Sep 2020 07:47:00 +0000
X-IncomingTopHeaderMarker: OriginalChecksum:C0A172A5E90B32F52E59CBC2AC3A6848BAC30D6D1E548CEAE45E7D4BDE23ACF7;
 UpperCasedChecksum:C85AF426398EDD02EDBD12261AC21EE7957D09DAB260A6AD864640FB211C38E4;
 SizeAsReceived:7555; Count:46
Received: from MWHPR0401MB3594.namprd04.prod.outlook.com
 ([fe80::48ba:518e:d6bc:ca1b]) by MWHPR0401MB3594.namprd04.prod.outlook.com
 ([fe80::48ba:518e:d6bc:ca1b%7]) with mapi id 15.20.3391.019; Thu, 24 Sep 2020
 07:47:00 +0000
From: Mariusz Borsa <wrotki@hotmail.com>
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Subject: Unikraft unikernel - allocate memory page at predefined ritual address
Message-ID: <MWHPR0401MB3594F5B6689612C5484D3578D3390@MWHPR0401MB3594.namprd04.prod.outlook.com>
Date: Thu, 24 Sep 2020 00:46:58 -0700
To: minios-devel@lists.xenproject.org
X-Mailer: Apple Mail (2.3608.120.23.2.1)
X-ClientProxiedBy: CO2PR04CA0091.namprd04.prod.outlook.com
 (2603:10b6:104:6::17) To MWHPR0401MB3594.namprd04.prod.outlook.com
 (2603:10b6:301:7d::25)
X-Microsoft-Original-Message-ID: <8666611D-33E0-4D96-B023-95A6AA95444B@hotmail.com>
MIME-Version: 1.0
X-MS-Exchange-MessageSentRepresentingType: 1
Received: from [IPv6:2601:600:9580:b5f0:1cf5:4601:66f5:709]
 (2601:600:9580:b5f0:1cf5:4601:66f5:709) by
 CO2PR04CA0091.namprd04.prod.outlook.com (2603:10b6:104:6::17) with Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.3391.14 via Frontend Transport; Thu, 24 Sep 2020 07:47:00 +0000
X-Mailer: Apple Mail (2.3608.120.23.2.1)
X-Microsoft-Original-Message-ID: <8666611D-33E0-4D96-B023-95A6AA95444B@hotmail.com>
X-TMN: [iSwzDOeQbLqJN0A6ZkPV2a/SB/by/Zf3gKF9sZnI8LYhWlOpyOMcj6t+XDownxHL]
X-MS-PublicTrafficType: Email
X-IncomingHeaderCount: 46
X-EOPAttributedMessage: 0
X-MS-Office365-Filtering-Correlation-Id: 3b8ac4c4-c5c9-46ed-7975-08d8605e053f
X-MS-TrafficTypeDiagnostic: DM6NAM10HT245:
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: NuFsNJLiMmEd0YYUXRHqmVkfiGTq7EsYsTuO6Y6MU5zVSQDZxsDKiiMGEj7ltrst9uxZfXYWWCD21a80wIJXPUKNdy+nbF/kyiMAKSOtnhJqOCGDhmtZ16nxieUjnmfEBeXCtjqnw1TnkNgmzkanv55b+CQtDE7PVPmvdmxEeFOpJ8vzjldEQe90NQHwAdw0PVE76RGEYPH9ZxPX4pBILg==
X-MS-Exchange-AntiSpam-MessageData: lxec/3LM/bhhHu/7yNXl2upqulOSQsafFMCsSPldeFjFWhOUNMN3ObR6VoxN+DuCy7KdEsW5kYWsfvO9DKMTdECLhVBOel6ScfEia1YQpsTQsfyBg3a768d2O097ObsNmmk2R6p7nRrjzGb9KbRIuvx4XOS/tLV1FCtHpI28nIBll4eWk7aINdEjU3RxLw5KB6yt6+31mW+GLoInZebfCA==
X-OriginatorOrg: hotmail.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 3b8ac4c4-c5c9-46ed-7975-08d8605e053f
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 07:47:00.8251 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-CrossTenant-AuthSource: DM6NAM10FT018.eop-nam10.prod.protection.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Anonymous
X-MS-Exchange-CrossTenant-FromEntityHeader: Internet
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM10HT245
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi

What would be the right way to do that, when I start from the helloworld ex=
ample? Should I use mmap with MAP_FIXED option as I would do under Linux? O=
r is there a way to call something lower on the stack?=20

Or to reformulate the question - since the unikernel is well, a kernel - wh=
at would be the simplest way to have it allocate a virtual memory page at p=
redetermined virtual address?

Thanks
Mariusz Borsa=


From minios-devel-bounces@lists.xenproject.org Tue Sep 29 08:35:28 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 29 Sep 2020 08:35:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNB6Y-0000Ky-QB; Tue, 29 Sep 2020 08:35:22 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=uAvy=DG=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kNB6X-0000Kt-4b
 for minios-devel@lists.xenproject.org; Tue, 29 Sep 2020 08:35:21 +0000
X-Inumbo-ID: 933bc195-947a-46b2-9cde-3e4bd2f3943c
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 933bc195-947a-46b2-9cde-3e4bd2f3943c;
 Tue, 29 Sep 2020 08:35:18 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 165A5F229B;
 Tue, 29 Sep 2020 10:35:17 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
 by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 3PRNQQEw2b-D; Tue, 29 Sep 2020 10:35:16 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from puck.office.hd (puck.office.hd [192.168.24.91])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id C8054F229A;
 Tue, 29 Sep 2020 10:35:12 +0200 (CEST)
Received: from puck.office.hd (192.168.24.91) by puck.office.hd
 (192.168.24.91) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 29 Sep
 2020 10:35:12 +0200
Received: from puck.office.hd ([192.168.126.12]) by puck.office.hd
 ([192.168.126.12]) with mapi id 15.01.1979.006; Tue, 29 Sep 2020 10:35:12
 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: Mariusz Borsa <wrotki@hotmail.com>, "minios-devel@lists.xenproject.org"
 <minios-devel@lists.xenproject.org>
Subject: Re: Unikraft unikernel - allocate memory page at predefined ritual
 address
Thread-Topic: Unikraft unikernel - allocate memory page at predefined ritual
 address
Thread-Index: AQHWkkcNOYtXi4tzjU+VorvMJYI04Kl/UlWA
Date: Tue, 29 Sep 2020 08:35:12 +0000
Message-ID: <1F170708-ECF0-4472-81E5-3C06D672CBB0@neclab.eu>
References: <MWHPR0401MB3594F5B6689612C5484D3578D3390@MWHPR0401MB3594.namprd04.prod.outlook.com>
In-Reply-To: <MWHPR0401MB3594F5B6689612C5484D3578D3390@MWHPR0401MB3594.namprd04.prod.outlook.com>
Accept-Language: en-GB, gl-ES, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
user-agent: Microsoft-MacOutlook/10.10.1a.200914
x-originating-ip: [192.168.24.96]
Content-Type: text/plain; charset="utf-8"
Content-ID: <3B76675EE359E64CA35AD9ED6A7DD0C9@office.hd>
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

SGkgTWFyaXVzeiwNCg0KeW91IGNhbiB1c2UgbWFsbG9jKCkgYXMgaWYgeW91IHdvdWxkIHByb2dy
YW0gZm9yIHVzZXIgc3BhY2UuIEl0IGlzIHByb3ZpZGVkIGJ5IG91ciBpbnRlcm5hbCBsaWJjIChu
b2xpYmMpICBvciBldmVuIHdpdGggb3VyIG5ld2xpYiBvciBtdXNsIHBvcnRzLiBJdCB3aWxsIGdl
dCB0cmFuc2xhdGVkIHRvIHVrX2FsbG9jKCkgZnJvbSB0aGUgdWthbGxvYyBsaWJyYXJ5LiBUaGlz
IGxpYnJhcnkgZG9lcyB0aGUgbG93LWxldmVsIGhlYXAgbWFuYWdlbWVudC4NCkZvciBkb2luZyBt
bWFwKCkgb3BlcmF0aW9ucywgeW91IGNhbiBzZWxlY3QgYHVrbW1hcGAuIEhvd2V2ZXIsIHRoZSBp
dHMgaW1wbGVtZW50YXRpb24gaXMgcmVhbGx5IGxpbWl0ZWQgYXQgdGhlIG1vbWVudC4gV2UgaGF2
ZSBjb2RlIGluIHRoZSB3b3JrcyBmb3IgZG9pbmcgcGFnZSB0YWJsZSBtb2RpZmljYXRpb25zIGlu
IG9yZGVyIHRvIGRvIHByb3BlciBhbGxvY2F0aW9ucyB3aXRoIG1tYXAoKS4NCg0KVGhhbmtzLA0K
DQpTaW1vbg0KDQoNCu+7v09uIDI0LjA5LjIwLCAwOTo0OCwgIk1pbmlvcy1kZXZlbCBvbiBiZWhh
bGYgb2YgTWFyaXVzeiBCb3JzYSIgPG1pbmlvcy1kZXZlbC1ib3VuY2VzQGxpc3RzLnhlbnByb2pl
Y3Qub3JnIG9uIGJlaGFsZiBvZiB3cm90a2lAaG90bWFpbC5jb20+IHdyb3RlOg0KDQogICAgSGkN
CiAgICANCiAgICBXaGF0IHdvdWxkIGJlIHRoZSByaWdodCB3YXkgdG8gZG8gdGhhdCwgd2hlbiBJ
IHN0YXJ0IGZyb20gdGhlIGhlbGxvd29ybGQgZXhhbXBsZT8gU2hvdWxkIEkgdXNlIG1tYXAgd2l0
aCBNQVBfRklYRUQgb3B0aW9uIGFzIEkgd291bGQgZG8gdW5kZXIgTGludXg/IE9yIGlzIHRoZXJl
IGEgd2F5IHRvIGNhbGwgc29tZXRoaW5nIGxvd2VyIG9uIHRoZSBzdGFjaz8gDQogICAgDQogICAg
T3IgdG8gcmVmb3JtdWxhdGUgdGhlIHF1ZXN0aW9uIC0gc2luY2UgdGhlIHVuaWtlcm5lbCBpcyB3
ZWxsLCBhIGtlcm5lbCAtIHdoYXQgd291bGQgYmUgdGhlIHNpbXBsZXN0IHdheSB0byBoYXZlIGl0
IGFsbG9jYXRlIGEgdmlydHVhbCBtZW1vcnkgcGFnZSBhdCBwcmVkZXRlcm1pbmVkIHZpcnR1YWwg
YWRkcmVzcz8NCiAgICANCiAgICBUaGFua3MNCiAgICBNYXJpdXN6IEJvcnNhDQogICAgDQoNCg==


From minios-devel-bounces@lists.xenproject.org Tue Sep 29 08:43:44 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 29 Sep 2020 08:43:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNBEd-0001Bq-Mx; Tue, 29 Sep 2020 08:43:43 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=uAvy=DG=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kNBEc-0001Bi-Hd
 for minios-devel@lists.xen.org; Tue, 29 Sep 2020 08:43:42 +0000
X-Inumbo-ID: 83d86709-c8b6-4e1b-9d1d-ff83b79acbaa
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 83d86709-c8b6-4e1b-9d1d-ff83b79acbaa;
 Tue, 29 Sep 2020 08:43:40 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 51B81F229C;
 Tue, 29 Sep 2020 10:43:39 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
 by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Cxy3JXaFfndb; Tue, 29 Sep 2020 10:43:39 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from Oberon.office.hd (Oberon.office.hd [192.168.24.90])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 1A98DF229A;
 Tue, 29 Sep 2020 10:43:35 +0200 (CEST)
Received: from puck.office.hd (192.168.24.91) by Oberon.office.hd
 (192.168.24.90) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 29 Sep
 2020 10:43:34 +0200
Received: from puck.office.hd ([192.168.126.12]) by puck.office.hd
 ([192.168.126.12]) with mapi id 15.01.1979.006; Tue, 29 Sep 2020 10:43:34
 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: Jason Long <hack3rcon@yahoo.com>, "minios-devel@lists.xen.org"
 <minios-devel@lists.xen.org>
Subject: Re: The difference between Unikraft and MiniOS.
Thread-Topic: The difference between Unikraft and MiniOS.
Thread-Index: AQHWfVLwNFeFC17F5U6SoVy1nYu5XKl/fpUA
Date: Tue, 29 Sep 2020 08:43:34 +0000
Message-ID: <08C02B12-8893-476A-A9FA-A73B84974C97@neclab.eu>
References: <2136227700.4433719.1598105673578.ref@mail.yahoo.com>
 <2136227700.4433719.1598105673578@mail.yahoo.com>
In-Reply-To: <2136227700.4433719.1598105673578@mail.yahoo.com>
Accept-Language: en-GB, gl-ES, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
user-agent: Microsoft-MacOutlook/10.10.1a.200914
x-originating-ip: [192.168.24.96]
Content-Type: multipart/alternative;
 boundary="_000_08C02B128893476AA9FAA73B84974C97neclabeu_"
MIME-Version: 1.0
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

--_000_08C02B128893476AA9FAA73B84974C97neclabeu_
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64

SGkgSmFzb24sDQoNCnRoYW5rcyBhIGxvdCBmb3IgeW91ciBxdWVzdGlvbi4gQm90aCBwcm9qZWN0
cyBhcmUgVW5pa2VybmVscywgd2hlcmUgTWluaS1PUyBpcyB0aGUgb2xkZXIgcHJvamVjdC4gSXRz
IG9yaWdpbmFsIHB1cnBvc2Ugd2FzIHRvIGRlbW9uc3RyYXRlIHRoZSBYZW4gaHlwZXJ2aXNvciBp
bnRlcmZhY2UuIEFzIGZhciBhcyBJIGtub3csIGl0IGlzIHVzZWQgdG9kYXkgaW4gc29tZSBYZW4g
ZGVwbG95bWVudHMgYXMgYmFzaXMgZm9yIHN0dWIgZG9tYWlucyAoZS5nLiwgUUVNVSkgYW5kIHJ1
bm5pbmcgdGhlIFhlblN0b3JlIHNlcGFyYXRlbHkgZnJvbSBEb20wLiBNYWluIG9idmlvdXMgZGlm
ZmVyZW5jZSB0byBVbmlrcmFmdCBpcyB0aGF0IE1pbmlPUyB3b3JrcyBqdXN0IHdpdGggWGVuLg0K
DQpXaXRoIFVuaWtyYWZ0IHdlIHRyeSB0byBwcm92aWRlIGEgZnJhbWV3b3JrIGZvciBidWlsZGlu
ZyBzcGVjaWFsaXplZCBVbmlrZXJuZWxzIGFjcm9zcyBkaWZmZXJlbnQgcGxhdGZvcm1zLCB3aGVy
ZSBYZW4gb3IgS1ZNIGFyZSBqdXN0IHR3byBvZiB0aGVtLiBUaGUgcHJvamVjdCBpcyB5b3VuZ2Vy
IGFuZCB3ZSBhcmUgd29ya2luZyBoZWF2aWx5IHRvIGRldmVsb3AgYSBsaWJyYXJ5IHBvb2wgd2hl
cmUgeW91IGJhc2ljYWxseSBwaWNrIGFuZCBjaG9vc2UgT1MgZnVuY3Rpb25hbGl0eSB0aGF0IHlv
dSBuZWVkIGZvciB5b3VyIFVuaWtlcm5lbC4NCg0KSSBob3BlIEkgY291bGQgYW5zd2VyIHlvdXIg
cXVlc3Rpb24uIExldCB1cyBrbm93IGlmIHlvdSBoYXZlIG1vcmUuDQoNClRoYW5rcywNCg0KU2lt
b24NCg0KRnJvbTogTWluaW9zLWRldmVsIDxtaW5pb3MtZGV2ZWwtYm91bmNlc0BsaXN0cy54ZW5w
cm9qZWN0Lm9yZz4gb24gYmVoYWxmIG9mIEphc29uIExvbmcgPGhhY2szcmNvbkB5YWhvby5jb20+
DQpSZXBseS1UbzogSmFzb24gTG9uZyA8aGFjazNyY29uQHlhaG9vLmNvbT4NCkRhdGU6IEZyaWRh
eSwgMjguIEF1Z3VzdCAyMDIwIGF0IDE3OjUwDQpUbzogIm1pbmlvcy1kZXZlbEBsaXN0cy54ZW4u
b3JnIiA8bWluaW9zLWRldmVsQGxpc3RzLnhlbi5vcmc+DQpTdWJqZWN0OiBUaGUgZGlmZmVyZW5j
ZSBiZXR3ZWVuIFVuaWtyYWZ0IGFuZCBNaW5pT1MuDQoNCkhlbGxvLA0KV2hhdCBpcyB0aGUgZGlm
ZmVyZW5jZSBiZXR3ZWVuIHRoZSBVbmlrcmFmdCBhbmQgTWluaU9TPw0KDQpUaGFua3MuDQo=

--_000_08C02B128893476AA9FAA73B84974C97neclabeu_
Content-Type: text/html; charset="utf-8"
Content-ID: <E1CB0DE66540574893961E17AC50A194@office.hd>
Content-Transfer-Encoding: base64

PGh0bWwgeG1sbnM6bz0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6b2ZmaWNlIiB4
bWxuczp3PSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTp3b3JkIiB4bWxuczptPSJo
dHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS8yMDA0LzEyL29tbWwiIHhtbG5zPSJo
dHRwOi8vd3d3LnczLm9yZy9UUi9SRUMtaHRtbDQwIj4NCjxoZWFkPg0KPG1ldGEgaHR0cC1lcXVp
dj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9dXRmLTgiPg0KPG1l
dGEgbmFtZT0iR2VuZXJhdG9yIiBjb250ZW50PSJNaWNyb3NvZnQgV29yZCAxNSAoZmlsdGVyZWQg
bWVkaXVtKSI+DQo8c3R5bGU+PCEtLQ0KLyogRm9udCBEZWZpbml0aW9ucyAqLw0KQGZvbnQtZmFj
ZQ0KCXtmb250LWZhbWlseToiQ2FtYnJpYSBNYXRoIjsNCglwYW5vc2UtMToyIDQgNSAzIDUgNCA2
IDMgMiA0O30NCkBmb250LWZhY2UNCgl7Zm9udC1mYW1pbHk6Q2FsaWJyaTsNCglwYW5vc2UtMToy
IDE1IDUgMiAyIDIgNCAzIDIgNDt9DQpAZm9udC1mYWNlDQoJe2ZvbnQtZmFtaWx5Ok1lbmxvOw0K
CXBhbm9zZS0xOjIgMTEgNiA5IDMgOCA0IDIgMiA0O30NCkBmb250LWZhY2UNCgl7Zm9udC1mYW1p
bHk6IlRpbWVzIE5ldyBSb21hbiBcKEJvZHkgQ1NcKSI7DQoJcGFub3NlLTE6MiAyIDYgMyA1IDQg
NSAyIDMgNDt9DQovKiBTdHlsZSBEZWZpbml0aW9ucyAqLw0KcC5Nc29Ob3JtYWwsIGxpLk1zb05v
cm1hbCwgZGl2Lk1zb05vcm1hbA0KCXttYXJnaW46MGNtOw0KCW1hcmdpbi1ib3R0b206LjAwMDFw
dDsNCglmb250LXNpemU6MTEuMHB0Ow0KCWZvbnQtZmFtaWx5OiJDYWxpYnJpIixzYW5zLXNlcmlm
O30NCmE6bGluaywgc3Bhbi5Nc29IeXBlcmxpbmsNCgl7bXNvLXN0eWxlLXByaW9yaXR5Ojk5Ow0K
CWNvbG9yOiMwNTYzQzE7DQoJdGV4dC1kZWNvcmF0aW9uOnVuZGVybGluZTt9DQphOnZpc2l0ZWQs
IHNwYW4uTXNvSHlwZXJsaW5rRm9sbG93ZWQNCgl7bXNvLXN0eWxlLXByaW9yaXR5Ojk5Ow0KCWNv
bG9yOiM5NTRGNzI7DQoJdGV4dC1kZWNvcmF0aW9uOnVuZGVybGluZTt9DQpwLm1zb25vcm1hbDAs
IGxpLm1zb25vcm1hbDAsIGRpdi5tc29ub3JtYWwwDQoJe21zby1zdHlsZS1uYW1lOm1zb25vcm1h
bDsNCgltc28tbWFyZ2luLXRvcC1hbHQ6YXV0bzsNCgltYXJnaW4tcmlnaHQ6MGNtOw0KCW1zby1t
YXJnaW4tYm90dG9tLWFsdDphdXRvOw0KCW1hcmdpbi1sZWZ0OjBjbTsNCglmb250LXNpemU6MTEu
MHB0Ow0KCWZvbnQtZmFtaWx5OiJDYWxpYnJpIixzYW5zLXNlcmlmO30NCnNwYW4uRW1haWxTdHls
ZTE4DQoJe21zby1zdHlsZS10eXBlOnBlcnNvbmFsLXJlcGx5Ow0KCWZvbnQtZmFtaWx5Ok1lbmxv
Ow0KCWNvbG9yOndpbmRvd3RleHQ7DQoJZm9udC13ZWlnaHQ6bm9ybWFsOw0KCWZvbnQtc3R5bGU6
bm9ybWFsOw0KCXRleHQtZGVjb3JhdGlvbjpub25lIG5vbmU7fQ0KLk1zb0NocERlZmF1bHQNCgl7
bXNvLXN0eWxlLXR5cGU6ZXhwb3J0LW9ubHk7DQoJZm9udC1zaXplOjEwLjBwdDt9DQpAcGFnZSBX
b3JkU2VjdGlvbjENCgl7c2l6ZTo2MTIuMHB0IDc5Mi4wcHQ7DQoJbWFyZ2luOjcwLjg1cHQgNzAu
ODVwdCAyLjBjbSA3MC44NXB0O30NCmRpdi5Xb3JkU2VjdGlvbjENCgl7cGFnZTpXb3JkU2VjdGlv
bjE7fQ0KLS0+PC9zdHlsZT4NCjwvaGVhZD4NCjxib2R5IGxhbmc9IkRFIiBsaW5rPSIjMDU2M0Mx
IiB2bGluaz0iIzk1NEY3MiI+DQo8ZGl2IGNsYXNzPSJXb3JkU2VjdGlvbjEiPg0KPHAgY2xhc3M9
Ik1zb05vcm1hbCI+PHNwYW4gc3R5bGU9ImZvbnQtZmFtaWx5Ok1lbmxvIj5IaSBKYXNvbiw8bzpw
PjwvbzpwPjwvc3Bhbj48L3A+DQo8cCBjbGFzcz0iTXNvTm9ybWFsIj48c3BhbiBzdHlsZT0iZm9u
dC1mYW1pbHk6TWVubG8iPjxvOnA+Jm5ic3A7PC9vOnA+PC9zcGFuPjwvcD4NCjxwIGNsYXNzPSJN
c29Ob3JtYWwiPjxzcGFuIGxhbmc9IkVOLVVTIiBzdHlsZT0iZm9udC1mYW1pbHk6TWVubG8iPnRo
YW5rcyBhIGxvdCBmb3IgeW91ciBxdWVzdGlvbi4gQm90aCBwcm9qZWN0cyBhcmUgVW5pa2VybmVs
cywgd2hlcmUgTWluaS1PUyBpcyB0aGUgb2xkZXIgcHJvamVjdC4gSXRzIG9yaWdpbmFsIHB1cnBv
c2Ugd2FzIHRvIGRlbW9uc3RyYXRlIHRoZSBYZW4gaHlwZXJ2aXNvciBpbnRlcmZhY2UuIEFzIGZh
ciBhcyBJIGtub3csIGl0IGlzDQogdXNlZCB0b2RheSBpbiBzb21lIFhlbiBkZXBsb3ltZW50cyBh
cyBiYXNpcyBmb3Igc3R1YiBkb21haW5zIChlLmcuLCBRRU1VKSBhbmQgcnVubmluZyB0aGUgWGVu
U3RvcmUgc2VwYXJhdGVseSBmcm9tIERvbTAuIE1haW4gb2J2aW91cyBkaWZmZXJlbmNlIHRvIFVu
aWtyYWZ0IGlzIHRoYXQgTWluaU9TIHdvcmtzIGp1c3Qgd2l0aCBYZW4uPG86cD48L286cD48L3Nw
YW4+PC9wPg0KPHAgY2xhc3M9Ik1zb05vcm1hbCI+PHNwYW4gbGFuZz0iRU4tVVMiIHN0eWxlPSJm
b250LWZhbWlseTpNZW5sbyI+PG86cD4mbmJzcDs8L286cD48L3NwYW4+PC9wPg0KPHAgY2xhc3M9
Ik1zb05vcm1hbCI+PHNwYW4gbGFuZz0iRU4tVVMiIHN0eWxlPSJmb250LWZhbWlseTpNZW5sbyI+
V2l0aCBVbmlrcmFmdCB3ZSB0cnkgdG8gcHJvdmlkZSBhIGZyYW1ld29yayBmb3IgYnVpbGRpbmcg
c3BlY2lhbGl6ZWQgVW5pa2VybmVscyBhY3Jvc3MgZGlmZmVyZW50IHBsYXRmb3Jtcywgd2hlcmUg
WGVuIG9yIEtWTSBhcmUganVzdCB0d28gb2YgdGhlbS4gVGhlIHByb2plY3QgaXMgeW91bmdlciBh
bmQgd2UgYXJlIHdvcmtpbmcgaGVhdmlseQ0KIHRvIGRldmVsb3AgYSBsaWJyYXJ5IHBvb2wgd2hl
cmUgeW91IGJhc2ljYWxseSBwaWNrIGFuZCBjaG9vc2UgT1MgZnVuY3Rpb25hbGl0eSB0aGF0IHlv
dSBuZWVkIGZvciB5b3VyIFVuaWtlcm5lbC48bzpwPjwvbzpwPjwvc3Bhbj48L3A+DQo8cCBjbGFz
cz0iTXNvTm9ybWFsIj48c3BhbiBsYW5nPSJFTi1VUyIgc3R5bGU9ImZvbnQtZmFtaWx5Ok1lbmxv
Ij48bzpwPiZuYnNwOzwvbzpwPjwvc3Bhbj48L3A+DQo8cCBjbGFzcz0iTXNvTm9ybWFsIj48c3Bh
biBsYW5nPSJFTi1VUyIgc3R5bGU9ImZvbnQtZmFtaWx5Ok1lbmxvIj5JIGhvcGUgSSBjb3VsZCBh
bnN3ZXIgeW91ciBxdWVzdGlvbi4gTGV0IHVzIGtub3cgaWYgeW91IGhhdmUgbW9yZS48bzpwPjwv
bzpwPjwvc3Bhbj48L3A+DQo8cCBjbGFzcz0iTXNvTm9ybWFsIj48c3BhbiBsYW5nPSJFTi1VUyIg
c3R5bGU9ImZvbnQtZmFtaWx5Ok1lbmxvIj48bzpwPiZuYnNwOzwvbzpwPjwvc3Bhbj48L3A+DQo8
cCBjbGFzcz0iTXNvTm9ybWFsIj48c3BhbiBsYW5nPSJFTi1VUyIgc3R5bGU9ImZvbnQtZmFtaWx5
Ok1lbmxvIj5UaGFua3MsPG86cD48L286cD48L3NwYW4+PC9wPg0KPHAgY2xhc3M9Ik1zb05vcm1h
bCI+PHNwYW4gbGFuZz0iRU4tVVMiIHN0eWxlPSJmb250LWZhbWlseTpNZW5sbyI+PG86cD4mbmJz
cDs8L286cD48L3NwYW4+PC9wPg0KPHAgY2xhc3M9Ik1zb05vcm1hbCI+PHNwYW4gbGFuZz0iRU4t
VVMiIHN0eWxlPSJmb250LWZhbWlseTpNZW5sbyI+U2ltb248bzpwPjwvbzpwPjwvc3Bhbj48L3A+
DQo8cCBjbGFzcz0iTXNvTm9ybWFsIj48c3BhbiBsYW5nPSJFTi1VUyIgc3R5bGU9ImZvbnQtZmFt
aWx5Ok1lbmxvIj48bzpwPiZuYnNwOzwvbzpwPjwvc3Bhbj48L3A+DQo8ZGl2IHN0eWxlPSJib3Jk
ZXI6bm9uZTtib3JkZXItdG9wOnNvbGlkICNCNUM0REYgMS4wcHQ7cGFkZGluZzozLjBwdCAwY20g
MGNtIDBjbSI+DQo8cCBjbGFzcz0iTXNvTm9ybWFsIiBzdHlsZT0ibWFyZ2luLWxlZnQ6MzYuMHB0
Ij48Yj48c3BhbiBsYW5nPSJFTi1VUyIgc3R5bGU9ImZvbnQtc2l6ZToxMi4wcHQ7Y29sb3I6Ymxh
Y2siPkZyb206DQo8L3NwYW4+PC9iPjxzcGFuIGxhbmc9IkVOLVVTIiBzdHlsZT0iZm9udC1zaXpl
OjEyLjBwdDtjb2xvcjpibGFjayI+TWluaW9zLWRldmVsICZsdDttaW5pb3MtZGV2ZWwtYm91bmNl
c0BsaXN0cy54ZW5wcm9qZWN0Lm9yZyZndDsgb24gYmVoYWxmIG9mIEphc29uIExvbmcgJmx0O2hh
Y2szcmNvbkB5YWhvby5jb20mZ3Q7PGJyPg0KPGI+UmVwbHktVG86IDwvYj5KYXNvbiBMb25nICZs
dDtoYWNrM3Jjb25AeWFob28uY29tJmd0Ozxicj4NCjxiPkRhdGU6IDwvYj5GcmlkYXksIDI4LiA8
L3NwYW4+PHNwYW4gc3R5bGU9ImZvbnQtc2l6ZToxMi4wcHQ7Y29sb3I6YmxhY2siPkF1Z3VzdCAy
MDIwIGF0IDE3OjUwPGJyPg0KPGI+VG86IDwvYj4mcXVvdDttaW5pb3MtZGV2ZWxAbGlzdHMueGVu
Lm9yZyZxdW90OyAmbHQ7bWluaW9zLWRldmVsQGxpc3RzLnhlbi5vcmcmZ3Q7PGJyPg0KPGI+U3Vi
amVjdDogPC9iPlRoZSBkaWZmZXJlbmNlIGJldHdlZW4gVW5pa3JhZnQgYW5kIE1pbmlPUy48bzpw
PjwvbzpwPjwvc3Bhbj48L3A+DQo8L2Rpdj4NCjxkaXY+DQo8cCBjbGFzcz0iTXNvTm9ybWFsIiBz
dHlsZT0ibWFyZ2luLWxlZnQ6MzYuMHB0Ij48bzpwPiZuYnNwOzwvbzpwPjwvcD4NCjwvZGl2Pg0K
PHAgY2xhc3M9Ik1zb05vcm1hbCIgc3R5bGU9Im1hcmdpbi1sZWZ0OjM2LjBwdCI+SGVsbG8sIDxv
OnA+PC9vOnA+PC9wPg0KPGRpdj4NCjxwIGNsYXNzPSJNc29Ob3JtYWwiIHN0eWxlPSJtYXJnaW4t
bGVmdDozNi4wcHQiPldoYXQgaXMgdGhlIGRpZmZlcmVuY2UgYmV0d2VlbiB0aGUgVW5pa3JhZnQg
YW5kIE1pbmlPUz88bzpwPjwvbzpwPjwvcD4NCjwvZGl2Pg0KPGRpdj4NCjxwIGNsYXNzPSJNc29O
b3JtYWwiIHN0eWxlPSJtYXJnaW4tbGVmdDozNi4wcHQiPjxvOnA+Jm5ic3A7PC9vOnA+PC9wPg0K
PC9kaXY+DQo8ZGl2IGlkPSJ5TWFpbF9jdXJzb3JFbGVtZW50VHJhY2tlcl8xNTk4MTA1NjUwMjIx
Ij4NCjxwIGNsYXNzPSJNc29Ob3JtYWwiIHN0eWxlPSJtYXJnaW4tbGVmdDozNi4wcHQiPlRoYW5r
cy48bzpwPjwvbzpwPjwvcD4NCjwvZGl2Pg0KPC9kaXY+DQo8L2JvZHk+DQo8L2h0bWw+DQo=

--_000_08C02B128893476AA9FAA73B84974C97neclabeu_--


From minios-devel-bounces@lists.xenproject.org Tue Sep 29 08:55:05 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 29 Sep 2020 08:55:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNBPb-0002Dy-S4; Tue, 29 Sep 2020 08:55:03 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=uAvy=DG=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kNBPb-0002Dt-FX
 for minios-devel@lists.xen.org; Tue, 29 Sep 2020 08:55:03 +0000
X-Inumbo-ID: 0a3d41c1-4d00-4dc3-a8a6-1326fc7174d9
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 0a3d41c1-4d00-4dc3-a8a6-1326fc7174d9;
 Tue, 29 Sep 2020 08:55:01 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 4C83E1039AC;
 Tue, 29 Sep 2020 10:55:00 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-a.office.hd)
Received: from mailer1.neclab.eu ([127.0.0.1])
 by localhost (atlas-a.office.hd [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id fGa_3C4lhVSc; Tue, 29 Sep 2020 10:55:00 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 2630C102E45;
 Tue, 29 Sep 2020 10:55:00 +0200 (CEST)
Received: from puck.office.hd (192.168.24.91) by titania.office.hd
 (192.168.24.89) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 29 Sep
 2020 10:54:59 +0200
Received: from puck.office.hd ([192.168.126.12]) by puck.office.hd
 ([192.168.126.12]) with mapi id 15.01.1979.006; Tue, 29 Sep 2020 10:54:59
 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: felix nasch <felix.nasch@gmail.com>, "minios-devel@lists.xen.org"
 <minios-devel@lists.xen.org>
Subject: Re: mounting files/directory into unikraft app
Thread-Topic: mounting files/directory into unikraft app
Thread-Index: AQHWehSopl4SWRziJ0qc5QHnSFqwgKl/iEKA
Date: Tue, 29 Sep 2020 08:54:59 +0000
Message-ID: <238E171F-9237-4AFB-BBC0-7A7518BA7B58@neclab.eu>
References: <CAMEmTtXLPNPjGLenfH2Jhq=-HszQwwZzVoPXbB1FE5GQUnTNjQ@mail.gmail.com>
In-Reply-To: <CAMEmTtXLPNPjGLenfH2Jhq=-HszQwwZzVoPXbB1FE5GQUnTNjQ@mail.gmail.com>
Accept-Language: en-GB, gl-ES, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
user-agent: Microsoft-MacOutlook/10.10.1a.200914
x-originating-ip: [192.168.24.96]
Content-Type: text/plain; charset="utf-8"
Content-ID: <5D83D69F4C85334CB81904FD70F0AD75@office.hd>
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

SGksDQoNCmN1cnJlbnRseSB3ZSBoYXZlIGFuIGltcGxlbWVudGF0aW9uIG9mIDlwZnMgZm9yIEtW
TSBhbmQgWGVuIHRoYXQgeW91IGNvdWxkIHVzZSBmb3Igc29tZXRoaW5nIGxpa2UgeW91IGFyZSBk
b2luZy4gVGhlIG1lbnRpb25lZCBwYXJhbWV0ZXIgaW4gbGliLXB5dGhvbjMgcmVsYXRlcyB0byB0
aGUgUUVNVSBjb21tYW5kIGxpbmUgZm9yIHRoZSBLVk0gc2V0dXAuIEluIGdlbmVyYWwgaXQgaXMg
aW1wb3J0YW50IHRoYXQgdGhlIGdpdmVuIHRhZyBpcyB1c2VkIHdpdGhpbiBVbmlrcmFmdCBhcyBk
ZXZpY2UgbmFtZSBpbiBvcmRlciB0byBzdWNjZWVkIHdpdGggbW91bnRpbmcuDQoNClRoYW5rcywN
Cg0KU2ltb24NCg0K77u/T24gMjQuMDguMjAsIDE0OjQ3LCAiTWluaW9zLWRldmVsIG9uIGJlaGFs
ZiBvZiBmZWxpeCBuYXNjaCIgPG1pbmlvcy1kZXZlbC1ib3VuY2VzQGxpc3RzLnhlbnByb2plY3Qu
b3JnIG9uIGJlaGFsZiBvZiBmZWxpeC5uYXNjaEBnbWFpbC5jb20+IHdyb3RlOg0KDQogICAgSGks
DQogICAgDQogICAgSSBhbSB3b3JraW5nIG9uIHZpcnR1YWwgbWFjaGluZSBpbnRyb3NwZWN0aW9u
IHdpdGggdGhlIGluc3BlY3RvciBhcyBhDQogICAgdW5pa3JhZnQgYXBwbGljYXRpb24uIEZvciB0
aGlzLCBJIG5lZWQgdG8gYWNjZXNzIHNvbWUgdmlydHVhbCBmaWxlcw0KICAgIHByb3ZpZGVkIGJ5
IHhlbi4NCiAgICANCiAgICBFc3NlbnRpYWxseSwgSSBuZWVkIHRvIG1hcCBhIGZldyBmaWxlcywg
bGlrZSBlLmcuICIvZGV2L3hlbi9wcml2Y21kIg0KICAgIGludG8gbXkgdW5pa3JhZnQgYXBwbGlj
YXRpb24uIEhvd2V2ZXIsIEkgZG9udCB1bmRlcnN0YW5kIGhvdyB0byBkbw0KICAgIHRoYXQuIFRo
ZXJlIGFyZSBzb21lIGhpbnRzIGluIGUuZy4NCiAgICBodHRwczovL2dpdGh1Yi5jb20vdW5pa3Jh
ZnQvbGliLXB5dGhvbjMgLCBidXQgaSBhbSBub3QgZXZlbiBzdXJlIHdoZXJlDQogICAgdG8gcGxh
Y2UgdGhlIG1lbnRpb25lZCAgLWZzZGV2IGFuZCAtZGV2aWNlIHBhcmFtZXRlcnMuLi4NCiAgICAN
CiAgICBDYW4geW91IGdpdmUgc29tZSBhZHZpY2Ugb24gaG93IHRvIGFjY29tcGxpc2ggdGhpcz8N
CiAgICANCiAgICBUaGFua3MuIDopDQogICAgDQogICAgDQoNCg==


From minios-devel-bounces@lists.xenproject.org Wed Sep 30 11:26:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 30 Sep 2020 11:26:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.573.1966 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNaFN-0005nJ-3h; Wed, 30 Sep 2020 11:26:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 573.1966; Wed, 30 Sep 2020 11:26:09 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNaFN-0005nC-05; Wed, 30 Sep 2020 11:26:09 +0000
Received: by outflank-mailman (input) for mailman id 573;
 Wed, 30 Sep 2020 10:55:40 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
 id 1kNZls-00032V-Ng
 for minios-devel@lists.xen.org; Wed, 30 Sep 2020 10:55:40 +0000
Received: from mail-ed1-x542.google.com (unknown [2a00:1450:4864:20::542])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a9c9cf1b-9f8b-4d8d-8245-5b0a32b2f972;
 Wed, 30 Sep 2020 10:55:39 +0000 (UTC)
Received: by mail-ed1-x542.google.com with SMTP id c8so1328679edv.5
 for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 03:55:39 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
 by smtp.gmail.com with ESMTPSA id os15sm1232535ejb.61.2020.09.30.03.55.36
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 30 Sep 2020 03:55:37 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
	id 1kNZls-00032V-Ng
	for minios-devel@lists.xen.org; Wed, 30 Sep 2020 10:55:40 +0000
X-Inumbo-ID: a9c9cf1b-9f8b-4d8d-8245-5b0a32b2f972
Received: from mail-ed1-x542.google.com (unknown [2a00:1450:4864:20::542])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id a9c9cf1b-9f8b-4d8d-8245-5b0a32b2f972;
	Wed, 30 Sep 2020 10:55:39 +0000 (UTC)
Received: by mail-ed1-x542.google.com with SMTP id c8so1328679edv.5
        for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 03:55:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:to:cc:subject:date:message-id:mime-version
         :content-transfer-encoding;
        bh=Au5QHOE+/BSlJhDt/rAI0GVQrZ4M1AuJ2LBJYRXAqpQ=;
        b=J+bwatbNNJx0MRebOOA28HsYwOzQjCezUMcVRbS2sWdWMNKxYUAMybu9k4D/ASalnd
         dRyQIzNFaMBqaH6qFHap8+uir1E0KOfbaMQ77VjtDReAXTdClXHsTmJ63FecmYiG7q3d
         BjVzVg30Jzx9P9NHmJcPfTHB//dEgzqbBHn8C5UFA2OEVjWAXnEdRGQ6ETX1Bs99l6bT
         lrR64Bz6t4HbjMWI05fawKLKAsQHc2NY33ZGVQiWZsqkV53nin7YA97PgjJJcr1ePET5
         4kNbpFoCHNfESnx6vdsGwJPAqgBL0SOEm5Qny7RiFTdl8mfk4+Xp/XTFmy/lyY3TFC/0
         MAzA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
         :content-transfer-encoding;
        bh=Au5QHOE+/BSlJhDt/rAI0GVQrZ4M1AuJ2LBJYRXAqpQ=;
        b=H5rAW4iRqhltNnew7GkuKnSyaSOOG7qnyjpxzmJGQqLaDccPHTPdlfubNklIUlTzt/
         iNwNxeAyunuJ4KeMhIERa/WipSlDHfLdF+HySDyL4IEbF+zXos2Lg7GbKgEfq6wg6TKr
         wV0XGmSUqfLT/24iwW217NPZu0IbgDTvl4BUDg3khIDuBBWedTuaMHm8RAgvpA9uAOj9
         l4z//LCHpCYb3mDMuBh21urQnmeA8CvEn1kPeIkNXH5/fLa1ia97gQ0osgO6TA+ICHzP
         dgKgG+NUpBcVFCoglzCW23qdO0OebiC08abHzSiAddiwchXWo6UrMRN74n1Fn81VXGVU
         2l8A==
X-Gm-Message-State: AOAM531i5B16SyCMlilQOPuCNsdDke0iCvMRIvz8780hlskW4bY2t8bP
	MVgFyJKzAI7XG0qDj4rezzNhGsvc02kfcQ==
X-Google-Smtp-Source: ABdhPJwqn/K31RWgV0Nz3CUkuKHUg81/BL/my++PxLTsrLMAKmWAPI7GupdMQH2DykgwUcYyYTrSXA==
X-Received: by 2002:aa7:c649:: with SMTP id z9mr2000373edr.12.1601463337789;
        Wed, 30 Sep 2020 03:55:37 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
        by smtp.gmail.com with ESMTPSA id os15sm1232535ejb.61.2020.09.30.03.55.36
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 30 Sep 2020 03:55:37 -0700 (PDT)
From: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
To: minios-devel@lists.xen.org
Cc: cezar.craciunoiu@gmail.com,
	felipe.huici@neclab.eu
Subject: [PATCH 1/3] Add all information files and Config.uk needed
Date: Wed, 30 Sep 2020 13:55:29 +0300
Message-Id: <20200930105531.4435-1-cezar.craciunoiu@gmail.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

README.md contains all the information needed to make the library
work with any app running on Linuxu/KVM.

Config.uk selects all the internal libraries needed for p11-kit
on Linuxu to work. For p11-kit to work on KVM, LIBUKSP calls must be
added as glue code.

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
---
 .gitignore      | 27 +++++++++++++++++++++++++++
 CODING_STYLE.md |  4 ++++
 CONTRIBUTING.md |  4 ++++
 COPYING.md      | 39 +++++++++++++++++++++++++++++++++++++++
 Config.uk       | 23 +++++++++++++++++++++++
 MAINTAINERS.md  | 11 +++++++++++
 README.md       | 21 +++++++++++++++++++++
 7 files changed, 129 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 CODING_STYLE.md
 create mode 100644 CONTRIBUTING.md
 create mode 100644 COPYING.md
 create mode 100644 Config.uk
 create mode 100644 MAINTAINERS.md
 create mode 100644 README.md

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..75d2fd3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,27 @@
+*.depend
+*.o
+*.a
+*.d
+*.so
+*.orig
+*.rej
+*.bak
+*.swp
+*~
+,*
+\#*\#
+.\#*
+\#_*\#
+.\#_*
+!.gitignore
+.*
+
+# gnu global files
+GPATH
+GRTAGS
+GSYMS
+GTAGS
+
+# cscope files
+cscope.*
+ncscope.*
diff --git a/CODING_STYLE.md b/CODING_STYLE.md
new file mode 100644
index 0000000..5730041
--- /dev/null
+++ b/CODING_STYLE.md
@@ -0,0 +1,4 @@
+Coding Style
+============
+
+Please refer to the `CODING_STYLE.md` file in the main Unikraft repository.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..14f6ac6
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,4 @@
+Contributing to Unikraft
+========================
+
+Please refer to the `CONTRIBUTING.md` file in the main Unikraft repository.
diff --git a/COPYING.md b/COPYING.md
new file mode 100644
index 0000000..0bf9c42
--- /dev/null
+++ b/COPYING.md
@@ -0,0 +1,39 @@
+License
+=======
+
+Unikraft p11-kit wrappers
+----------------------------------
+
+This repository contains wrapper code to build p11-kit with Unikraft.
+Each C code file in this repository should declare who is the
+copyright owner and under which terms and conditions the code is
+licensed. If such a licence note is missing, the following copyright
+notice will apply:
+
+	Copyright (c) Year, Institution. All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions
+	are met:
+
+	1. Redistributions of source code must retain the above copyright
+	   notice, this list of conditions and the following disclaimer.
+	2. Redistributions in binary form must reproduce the above copyright
+	   notice, this list of conditions and the following disclaimer in the
+	   documentation and/or other materials provided with the distribution.
+	3. Neither the name of the copyright holder nor the names of its
+	   contributors may be used to endorse or promote products derived from
+	   this software without specific prior written permission.
+
+	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+	AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+	ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+	LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+	CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+	POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/Config.uk b/Config.uk
new file mode 100644
index 0000000..4fdfc2a
--- /dev/null
+++ b/Config.uk
@@ -0,0 +1,23 @@
+menuconfig LIBP11KIT
+	bool "libp11-kit - load and enumerate PKCS#11 modules"
+	select LIBNOLIBC if !HAVE_LIBC
+	select LIBUKALLOC
+	select LIBPOSIX_LIBDL
+	select LIBUKMMAP
+	select LIBUKSP
+	select LIBUKBOOT
+	select LIBUKBUS
+	select LIBPOSIX_SYSINFO
+	default n
+
+if LIBP11KIT
+	choice TESTS
+		prompt "TESTS"
+		default TESTS_ACTIVATED
+
+		config TESTS_ACTIVATED
+			bool "YES"
+		config TESTS_DEACTIVATED
+			bool "NO"
+	endchoice
+endif
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
new file mode 100644
index 0000000..9c5d8d1
--- /dev/null
+++ b/MAINTAINERS.md
@@ -0,0 +1,11 @@
+Maintainers List
+================
+
+For notes on how to read this information, please refer to `MAINTAINERS.md` in
+the main Unikraft repository.
+
+	LIBP11-KIT-UNIKRAFT
+	M:	Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
+	M:	Felipe Huici <felipe.huici@neclab.eu>
+	L:	minios-devel@lists.xen.org
+	F: *
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..baddf94
--- /dev/null
+++ b/README.md
@@ -0,0 +1,21 @@
+p11-kit for Unikraft
+=============================
+
+This is the port of p11-kit for Unikraft as an external library.It
+depends on the following libraries that need to be added to `Makefile`
+in this order:
+
+* networking, e.g `lwip`
+* multi-threading, e.g `pthread-embedded`
+* libc, e.g `newlib`
+
+For the build to be successful, `meson` and `ninja` will have to be installed.
+
+The library is compatible with Linuxu and KVM.
+
+For KVM to work, two additional things must be done:
+* The stack protector calls in `glue.c` must be enabled
+* `ppoll` must be disabled in `lwip`
+
+Please refer to the `README.md` as well as the documentation in the `doc/`
+subdirectory of the main unikraft repository.
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Wed Sep 30 11:26:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 30 Sep 2020 11:26:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.577.1973 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNaFN-0005o1-B2; Wed, 30 Sep 2020 11:26:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 577.1973; Wed, 30 Sep 2020 11:26:09 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNaFN-0005nh-3u; Wed, 30 Sep 2020 11:26:09 +0000
Received: by outflank-mailman (input) for mailman id 577;
 Wed, 30 Sep 2020 10:55:50 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
 id 1kNZm2-00032V-Fe
 for minios-devel@lists.xen.org; Wed, 30 Sep 2020 10:55:50 +0000
Received: from mail-ej1-x62f.google.com (unknown [2a00:1450:4864:20::62f])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id afedc46d-88eb-40fd-8c2c-710689ac7e78;
 Wed, 30 Sep 2020 10:55:41 +0000 (UTC)
Received: by mail-ej1-x62f.google.com with SMTP id o8so2106068ejb.10
 for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 03:55:41 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
 by smtp.gmail.com with ESMTPSA id os15sm1232535ejb.61.2020.09.30.03.55.38
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 30 Sep 2020 03:55:39 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
	id 1kNZm2-00032V-Fe
	for minios-devel@lists.xen.org; Wed, 30 Sep 2020 10:55:50 +0000
X-Inumbo-ID: afedc46d-88eb-40fd-8c2c-710689ac7e78
Received: from mail-ej1-x62f.google.com (unknown [2a00:1450:4864:20::62f])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id afedc46d-88eb-40fd-8c2c-710689ac7e78;
	Wed, 30 Sep 2020 10:55:41 +0000 (UTC)
Received: by mail-ej1-x62f.google.com with SMTP id o8so2106068ejb.10
        for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 03:55:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:to:cc:subject:date:message-id:in-reply-to:references
         :mime-version:content-transfer-encoding;
        bh=Z4L/ofaA0fqBQ7lzNgZ0t1N7DcYc5aEaEAWRUTvwJco=;
        b=rqXUsWXmBpLXc/t+466FszbpeE79ZupqxtBwRH8iqGRq7Gmwcprz7q30IyAzRlI0Xp
         rH7wWtHQWvUjKspxjd5FGq2TD8mc6FZ/qORHGyBQEHbFV8/V0yBjcHssnQS+nPTfUzbR
         N/7elHfh8ddxD3GvzPteAWzXPIaXEt4C9g+opLNzZnmrPGG7KnyPlyDoXzeGqZ7w5oNh
         C2cCsPJ2mC4B82i0dloPjFi2t+E5bal/pF4tUniOFgKyCnse3rscu03AnyFJ9w9v/Pcm
         /1xiqRlYi1UY20fi43Z0HmT/PMUTrpRogDS+jDewlITMNSJyE0c7Q3Bu181EM8gMxUi7
         uavw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
         :references:mime-version:content-transfer-encoding;
        bh=Z4L/ofaA0fqBQ7lzNgZ0t1N7DcYc5aEaEAWRUTvwJco=;
        b=h8byMgstXkOrLxrrJaBmFVjrPvTYolf6ftvGMQ5CtlWdnauuDoF3ceeI2EtoWmqWJC
         ytyrpJLpVEmizJLjViZyaL1fky5sdsiAemrbXgrO3MIT+UcpeDzsrmYWwLjc4p2euki5
         jKuLvk73eW51IRugmd4o/sU+Uf0Zib6D/G/v1fxU839cSmQHV1quSzr/Fzjqzzw7s9Uo
         NCe0XA9OdeGU+FsOzQzdjA0/DeD6JfQf/KTRHT9a7kGIKW4wX6JdtZQBNkXX5kTZQhQk
         yJH1X+8E/Tapz4oJCM8kjOEdLashNPrfCZKIc5gZUDoXsbHQ/Mb4b51CO1LNnkgFR4a6
         9JhA==
X-Gm-Message-State: AOAM532Tt/ADsEbSKc101SnqAeIVKkm185Hgxk6qK9OX0K4zmAm3TLW7
	q1g82viIZzM8aVFiftWzn1nYQkasjMzMwQ==
X-Google-Smtp-Source: ABdhPJxfXtF4cyjFd7NPiNVYgwCZl3O1UshvfgyRAn0aG6ILqEwbOyBmiBcr8qOqe0Y7dh0l7tLK8A==
X-Received: by 2002:a17:907:4276:: with SMTP id nq6mr2044156ejb.246.1601463339994;
        Wed, 30 Sep 2020 03:55:39 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
        by smtp.gmail.com with ESMTPSA id os15sm1232535ejb.61.2020.09.30.03.55.38
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 30 Sep 2020 03:55:39 -0700 (PDT)
From: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
To: minios-devel@lists.xen.org
Cc: cezar.craciunoiu@gmail.com,
	felipe.huici@neclab.eu
Subject: [PATCH 3/3] Add Makefile.uk with all the build logic needed
Date: Wed, 30 Sep 2020 13:55:31 +0300
Message-Id: <20200930105531.4435-3-cezar.craciunoiu@gmail.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200930105531.4435-1-cezar.craciunoiu@gmail.com>
References: <20200930105531.4435-1-cezar.craciunoiu@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The makefile uses the build system of the library (meson + ninja)
first to generate the object files in such a way that they compile
successfully. Afterwards they are linked with the object files from
unikraft.
Test object files can be added by making 'TESTS' 'YES' in menuconfig.

The only problem of this approach is that meson checks the system
first for available functions, components, etc. Because of this,
it checks the host system, not the future guest OS.

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
---
 Makefile.uk | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)
 create mode 100644 Makefile.uk

diff --git a/Makefile.uk b/Makefile.uk
new file mode 100644
index 0000000..9e26177
--- /dev/null
+++ b/Makefile.uk
@@ -0,0 +1,123 @@
+#  libp11kit Makefile.uk
+#
+#  Authors: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
+#
+#  Copyright (c) 2020, Politehnica University of Bucharest. All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#  3. Neither the name of the copyright holder nor the names of its
+#     contributors may be used to endorse or promote products derived from
+#     this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#  POSSIBILITY OF SUCH DAMAGE.
+#
+#  THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+#
+
+################################################################################
+# Library registration
+################################################################################
+$(eval $(call addlib_s,libp11kit,$(CONFIG_LIBP11KIT)))
+
+################################################################################
+# Sources
+################################################################################
+LIBP11KIT_VER=0.23.21
+LIBP11KIT_URL=https://github.com/p11-glue/p11-kit/archive/$(LIBP11KIT_VER).zip
+$(eval $(call fetch,libp11kit,$(LIBP11KIT_URL)))
+
+################################################################################
+# Helpers
+################################################################################
+LIBP11KIT_PATH=$(LIBP11KIT_ORIGIN)/p11-kit-$(LIBP11KIT_VER)
+LIBP11KIT_BUILD_PATH=$(LIBP11KIT_PATH)/_build
+LIBP11KIT_COMM_BUILD_PATH=$(LIBP11KIT_BUILD_PATH)/common/92a5dc0@@p11-common@sta
+LIBP11KIT_P11_BUILD_PATH=$(LIBP11KIT_BUILD_PATH)/p11-kit/077403d@@p11-kit@sha
+LIBP11KIT_COMM_TESTS_PATH=$(LIBP11KIT_BUILD_PATH)/common/92a5dc0@@p11-test@sta
+
+################################################################################
+# Library includes
+################################################################################
+LIBP11KIT_COMM_INCLUDES-y += -I$(LIBP11KIT_PATH)
+CXXINCLUDES-$(CONFIG_LIBP11KIT) += -I$(LIBP11KIT_PATH)
+CINCLUDES-$(CONFIG_LIBP11KIT) += -I$(LIBP11KIT_PATH)
+
+LIBP11KIT_CINCLUDES += -I$(LIBP11KIT_PATH)
+LIBP11KIT_CXXINCLUDES += -I$(LIBP11KIT_PATH)
+
+################################################################################
+# Global flags
+################################################################################
+LIBP11KIT_SUPPRESS_FLAGS += -Wno-unused-parameter \
+	-Wno-unused-variable -Wno-unused-value -Wno-unused-function \
+	-Wno-missing-field-initializers -Wno-implicit-fallthrough
+LIBP11KIT_CFLAGS-y += $(LIBP11KIT_SUPPRESS_FLAGS) \
+	-Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
+LIBP11KIT_CXXFLAGS-y += $(LIBP11KIT_SUPPRESS_FLAGS)
+
+################################################################################
+# Library sources
+################################################################################
+UK_ALIBS-y += $(LIBP11KIT_BUILD_PATH)/p11-kit/libp11-kit-internal.a
+UK_ALIBS-y += $(LIBP11KIT_BUILD_PATH)/common/libp11-library.a
+
+LIBP11KIT_SRCS-y += $(LIBP11KIT_BASE)/glue.c
+
+UK_OLIBS-y += $(LIBP11KIT_P11_BUILD_PATH)/iter.c.o
+UK_OLIBS-y += $(LIBP11KIT_P11_BUILD_PATH)/messages.c.o
+UK_OLIBS-y += $(LIBP11KIT_P11_BUILD_PATH)/modules.c.o
+UK_OLIBS-y += $(LIBP11KIT_P11_BUILD_PATH)/pin.c.o
+UK_OLIBS-y += $(LIBP11KIT_P11_BUILD_PATH)/proxy.c.o
+UK_OLIBS-y += $(LIBP11KIT_P11_BUILD_PATH)/proxy-init.c.o
+UK_OLIBS-y += $(LIBP11KIT_P11_BUILD_PATH)/rpc-server.c.o
+UK_OLIBS-y += $(LIBP11KIT_P11_BUILD_PATH)/uri.c.o
+UK_OLIBS-y += $(LIBP11KIT_P11_BUILD_PATH)/util.c.o
+
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/argv.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/attrs.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/debug.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/hash.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/message.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/runtime.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/vsock.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/array.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/buffer.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/constants.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/dict.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/lexer.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/path.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_BUILD_PATH)/url.c.o
+
+ifdef CONFIG_TESTS_ACTIVATED
+UK_OLIBS-y += $(LIBP11KIT_COMM_TESTS_PATH)/mock.c.o
+UK_OLIBS-y += $(LIBP11KIT_COMM_TESTS_PATH)/test.c.o
+endif
+
+################################################################################
+# P11-kit prepare
+################################################################################
+# Use the native build system to generate the object files, then link them
+
+$(LIBP11KIT_BUILD)/.prepared: $(LIBP11KIT_BUILD)/.origin
+	$(call verbose_cmd,CONFIG,libsoldeploy: $(notdir $@), \
+	cd $(LIBP11KIT_PATH) && meson _build && ninja -C _build)
+
+UK_PREPARE-$(CONFIG_LIBP11KIT) += $(LIBP11KIT_BUILD)/.prepared
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Wed Sep 30 11:26:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 30 Sep 2020 11:26:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.575.1970 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNaFN-0005ng-8U; Wed, 30 Sep 2020 11:26:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 575.1970; Wed, 30 Sep 2020 11:26:09 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNaFN-0005nU-1l; Wed, 30 Sep 2020 11:26:09 +0000
Received: by outflank-mailman (input) for mailman id 575;
 Wed, 30 Sep 2020 10:55:45 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
 id 1kNZlx-00032V-FX
 for minios-devel@lists.xen.org; Wed, 30 Sep 2020 10:55:45 +0000
Received: from mail-ej1-x644.google.com (unknown [2a00:1450:4864:20::644])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 02284cb1-ec81-46e0-b53a-aa744cb44e69;
 Wed, 30 Sep 2020 10:55:40 +0000 (UTC)
Received: by mail-ej1-x644.google.com with SMTP id i26so2086095ejb.12
 for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 03:55:40 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
 by smtp.gmail.com with ESMTPSA id os15sm1232535ejb.61.2020.09.30.03.55.37
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 30 Sep 2020 03:55:38 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
	id 1kNZlx-00032V-FX
	for minios-devel@lists.xen.org; Wed, 30 Sep 2020 10:55:45 +0000
X-Inumbo-ID: 02284cb1-ec81-46e0-b53a-aa744cb44e69
Received: from mail-ej1-x644.google.com (unknown [2a00:1450:4864:20::644])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 02284cb1-ec81-46e0-b53a-aa744cb44e69;
	Wed, 30 Sep 2020 10:55:40 +0000 (UTC)
Received: by mail-ej1-x644.google.com with SMTP id i26so2086095ejb.12
        for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 03:55:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:to:cc:subject:date:message-id:in-reply-to:references
         :mime-version:content-transfer-encoding;
        bh=TrEuj8mb7fOOq4D+AmBF6HfCD6vBCbkScMbu4Ru+0UE=;
        b=KHGDKK218fB89QyxlcQHN6sOl5Xccpy0up98yTX2ZtkwearjGV/g+fNOkTsYjyYBWd
         w8Jrdn2rywOjUNcZpLEEndWqftGvk3yyMxgeuWByKO0JllKFVa298DElYNskZtqmcfei
         zuOYx596KlV+3PiWJxVk7oLn5zagwTaSPvZU6i2qBidd6Kko5jz8J/wTKRRqBoZNtnFA
         /d3Z6UA1A36S7IfpHVzUqS9bghGW38+ihHbSFoL0E11M2NZZYvfwLwWVyFuojlO1L9+4
         th33fO4xOwocTXWAhgNiNvsBLcXkitMwTa1K4hRrIorCUCAC7PnwRkj4/YFERIT1sqfn
         aoZQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
         :references:mime-version:content-transfer-encoding;
        bh=TrEuj8mb7fOOq4D+AmBF6HfCD6vBCbkScMbu4Ru+0UE=;
        b=OoGWJld18SZmpjerBsDLYtcdMX8Sj9GOgQvY1BJ+OYsXSabUZlaP/tUpo6RW5F8DT3
         XRkyEuRg19vNxHyKW4BmulY2A6yjTjTHrnjtqd7pC1JMfL5SILY8PDwJJ5Txq/gpanXU
         by9sgJqtz83xCC5U7Bi046oac3zWk2KrobCDP25a4kJ76eamLo/J0pVyu7b1dOJ8kTq5
         eERyxmMTrEuUZIsr1t/5NESHD75CRyOgBAi4y+9BftTyXhzdT7ZXW53WiAYhyewQKQ/G
         qn+nmcZQ8uRYTxet1zxTzLWau3r+TXE5jWof2QOk5bMYACg7EN3Zt3lAdIYpsuZXcF/3
         Mtfg==
X-Gm-Message-State: AOAM532Z9o9b9/YMwEZQ6MJqO5ob6Udk3jFUAXBkUQdfX8HkhLMEaoj1
	KpLj1eyB2/F0D4ijZwUfwY1NMZ3OWaKKDg==
X-Google-Smtp-Source: ABdhPJwufCxiWAvxUoqdSOJaikIqOfrBGmatjQrN3QwW2XTpacIH9c0ckTQQenW322TbGDfcZURHkA==
X-Received: by 2002:a17:906:49cb:: with SMTP id w11mr2041096ejv.530.1601463338834;
        Wed, 30 Sep 2020 03:55:38 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
        by smtp.gmail.com with ESMTPSA id os15sm1232535ejb.61.2020.09.30.03.55.37
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 30 Sep 2020 03:55:38 -0700 (PDT)
From: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
To: minios-devel@lists.xen.org
Cc: cezar.craciunoiu@gmail.com,
	felipe.huici@neclab.eu
Subject: [PATCH 2/3] Add necessary functions as glue code for unikraft
Date: Wed, 30 Sep 2020 13:55:30 +0300
Message-Id: <20200930105531.4435-2-cezar.craciunoiu@gmail.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200930105531.4435-1-cezar.craciunoiu@gmail.com>
References: <20200930105531.4435-1-cezar.craciunoiu@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Most of the glue code added comes from the compat.c source file in
the library. Because of the separate build system, it could not
choose only what functions are needed by unikraft, so they needed
to be added by hand. All of these are below their copyright header.

Some additional function stubs were needed for a successful
compilation. These one are placed first.

The global variable stderr is not initialized in a fully correct way.
It was added because library object files used stderr as a variable
and newlib used stderr as a define.
Right now, in certain situations, printing to stderr does not work,
but it only happens when errors were met, anyway.

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
---
 glue.c | 337 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 337 insertions(+)
 create mode 100644 glue.c

diff --git a/glue.c b/glue.c
new file mode 100644
index 0000000..5d71dd7
--- /dev/null
+++ b/glue.c
@@ -0,0 +1,337 @@
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <sys/resource.h>
+#include <assert.h>
+#include <setjmp.h>
+
+/* Needed because unikraft does not include a stderr variable in newlib */
+#define stderr_redefined stderr
+#undef stderr
+FILE *stderr;
+
+void __assert_fail(const char *assertion, const char *file,
+		unsigned int line, const char *function)
+{
+	/* Workaround */
+	stderr = stderr_redefined;
+	if (function)
+		fprintf(stderr, "%s:%d: %s: %s", file, line,
+			function, assertion);
+	else
+		fprintf(stderr, "%s:%d: %s", file, line, assertion);
+	abort();
+}
+
+int *__errno_location(void)
+{
+	return NULL;
+}
+
+unsigned short int **__ctype_b_loc(void)
+{
+	return NULL;
+}
+
+const char *getprogname(void)
+{
+	return NULL;
+}
+
+/* Stack guard empty calls for KVM */
+#ifdef PLAT_KVM
+void _setjmp(jmp_buf buf)
+{
+	;
+}
+
+void __stack_chk_fail(void)
+{
+	/* Workaround */
+	stderr = stderr_redefined;
+}
+
+void __stack_chk_guard(void)
+{
+	/* Workaround */
+	stderr = stderr_redefined;
+}
+#endif
+
+int stat64(const char *path, struct stat *buf)
+{
+	return stat(path, buf);
+}
+
+/* No varargs support */
+int open64(const char *pathname, int oflag, ...)
+{
+	return open(pathname, oflag);
+}
+
+/* No varargs support */
+int fcntl64(int fd, int cmd, ...)
+{
+	return fcntl(fd, cmd);
+}
+
+FILE *fopen64(const char *filename, const char *type)
+{
+	return fopen(filename, type);
+}
+
+int mkstemp64(char *template)
+{
+	return mkstemp(template);
+}
+
+/*
+ * Copyright (c) 2011 Collabora Ltd.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *     * Redistributions of source code must retain the above
+ *       copyright notice, this list of conditions and the
+ *       following disclaimer.
+ *     * Redistributions in binary form must reproduce the
+ *       above copyright notice, this list of conditions and
+ *       the following disclaimer in the documentation and/or
+ *       other materials provided with the distribution.
+ *     * The names of contributors to this software may not be
+ *       used to endorse or promote products derived from this
+ *       software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * Author: Stef Walter <stefw@collabora.co.uk>
+ *
+ * THE DISCLAIMER ABOVE APPLIES TO ALL THE FUNCTIONS BELOW IT.
+ */
+
+char *strconcat(const char *first, ...)
+{
+	size_t length = 0;
+	const char *arg;
+	char *result, *at;
+	va_list va;
+
+	va_start(va, first);
+
+	for (arg = first; arg; arg = va_arg(va, const char *)) {
+		size_t old_length = length;
+
+		length += strlen(arg);
+		if (length < old_length) {
+			va_end(va);
+			return NULL;
+		}
+	}
+
+	va_end(va);
+
+	at = result = malloc(length + 1);
+	if (result == NULL)
+		return NULL;
+
+	va_start(va, first);
+
+	for (arg = first; arg; arg = va_arg(va, const char *)) {
+		length = strlen(arg);
+		memcpy(at, arg, length);
+		at += length;
+	}
+
+	va_end(va);
+
+	*at = 0;
+	return result;
+}
+
+void *memdup(const void *data, size_t length)
+{
+	void *dup;
+
+	if (!data)
+		return NULL;
+
+	dup = malloc(length);
+	if (dup != NULL)
+		memcpy(dup, data, length);
+
+	return dup;
+}
+
+int p11_ascii_tolower(int c)
+{
+	if (c >= 'A' && c <= 'Z')
+		return 'a' + (c - 'A');
+	return c;
+}
+
+int p11_ascii_toupper(int c)
+{
+	if (c >= 'a' && c <= 'z')
+		return 'A' + (c - 'a');
+	return c;
+}
+
+struct _p11_mmap {
+	int fd;
+	void *data;
+	size_t size;
+};
+
+typedef struct _p11_mmap p11_mmap;
+
+p11_mmap *p11_mmap_open(const char *path, struct stat *sb,
+			void **data, size_t *size)
+{
+	struct stat stb;
+	p11_mmap *map;
+
+	map = calloc(1, sizeof(p11_mmap));
+	if (map == NULL)
+		return NULL;
+
+	map->fd = open(path, O_RDONLY | O_CLOEXEC);
+	if (map->fd == -1) {
+		free(map);
+		return NULL;
+	}
+
+	if (sb == NULL) {
+		sb = &stb;
+		if (fstat(map->fd, &stb) < 0) {
+			close(map->fd);
+			free(map);
+			return NULL;
+		}
+	}
+
+	/* Workaround for broken ZFS on Linux */
+	if (S_ISDIR(sb->st_mode)) {
+		errno = EISDIR;
+		close(map->fd);
+		free(map);
+		return NULL;
+	}
+
+	if (sb->st_size == 0) {
+		*data = "";
+		*size = 0;
+		return map;
+	}
+
+	map->size = sb->st_size;
+	map->data = mmap(NULL, map->size, PROT_READ, MAP_PRIVATE, map->fd, 0);
+	if (map->data == MAP_FAILED) {
+		close(map->fd);
+		free(map);
+		return NULL;
+	}
+
+	*data = map->data;
+	*size = map->size;
+	return map;
+}
+
+void p11_mmap_close(p11_mmap *map)
+{
+	if (map->size)
+		munmap(map->data, map->size);
+	close(map->fd);
+	free(map);
+}
+
+void p11_dl_close(void *dl)
+{
+	(void) dlclose(dl);
+}
+
+char *p11_dl_error(void)
+{
+	const char *msg = dlerror();
+
+	return msg ? strdup(msg) : NULL;
+}
+
+int fdwalk(int (*cb) (void *data, int fd), void *data)
+{
+	int open_max;
+	int res = 0;
+	int fd;
+	struct rlimit rl;
+
+	/* No /proc, brute force */
+	if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_max != RLIM_INFINITY)
+		open_max = rl.rlim_max;
+	else
+		open_max = sysconf(_SC_OPEN_MAX);
+
+	for (fd = 0; fd < open_max; fd++) {
+		res = cb(data, fd);
+		if (res != 0)
+			break;
+	}
+
+	return res;
+}
+
+#define AT_SECURE 23
+
+unsigned long getauxval(unsigned long type)
+{
+	static unsigned long secure;
+	static unsigned char check_secure_initialized;
+
+	/*
+	 * This is the only one our stand-in impl supports and is
+	 * also the only type we define in compat.h header
+	 */
+	assert(type == AT_SECURE);
+
+	if (!check_secure_initialized) {
+		uid_t ruid, euid, suid;
+		gid_t rgid, egid, sgid;
+
+		if (getresuid(&ruid, &euid, &suid) != 0 ||
+		    getresgid(&rgid, &egid, &sgid) != 0) {
+			suid = ruid = getuid();
+			sgid = rgid = getgid();
+			euid = geteuid();
+			egid = getegid();
+		}
+
+		secure = (ruid != euid || ruid != suid ||
+			rgid != egid || rgid != sgid);
+		check_secure_initialized = 1;
+	}
+
+	return secure;
+}
+
+char *secure_getenv(const char *name)
+{
+	if (getauxval(AT_SECURE))
+		return NULL;
+	return getenv(name);
+}
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Wed Sep 30 11:26:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 30 Sep 2020 11:26:11 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNaFM-0005n7-Uw; Wed, 30 Sep 2020 11:26:08 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=h52Z=DE=gmail.com=lrbarbulescu@srs-us1.protection.inumbo.net>)
 id 1kMTFE-0003jI-Lf
 for minios-devel@lists.xen.org; Sun, 27 Sep 2020 09:45:24 +0000
X-Inumbo-ID: 18633be8-5d7c-4177-bfa9-887d99259051
Received: from mail-ej1-x632.google.com (unknown [2a00:1450:4864:20::632])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 18633be8-5d7c-4177-bfa9-887d99259051;
 Sun, 27 Sep 2020 09:45:16 +0000 (UTC)
Received: by mail-ej1-x632.google.com with SMTP id j11so4335436ejk.0
 for <minios-devel@lists.xen.org>; Sun, 27 Sep 2020 02:45:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=mZ+vj8CCT9cJkscyhA0QMxIo/91liW39FNevn8PtJJQ=;
 b=G9woIRdiGrIhRWK+rzLbYsvHTax124L8F/9UfBK55WrHISvscAqU/mD7VyFlvEJeml
 qAeiiQeOO00sryuU4vEt/WIEOZpRJY5BxOuG5wKARjIWzACRb8cZgl++TzgybWOep3GI
 +mnT2yYskBSSRGttZ45HPxPED6akJjut49mbFrwo+JbD0SOl5KkVu7Gmx5w5PNuk54Ob
 sKZQI8RPe4ljs7SiY1C5/H5PRQbb/pXdzKLOqkfdXBEfJQiMaS8QRDhRHsRDBFQ1yrqI
 ZlCHkUnK7fDbgg9973a5UBjf3qQ5ML5YbB21QmLoQ4xR0omhFEgzKAqxCxc3OcEu9mxN
 XzdA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=mZ+vj8CCT9cJkscyhA0QMxIo/91liW39FNevn8PtJJQ=;
 b=ZyVKeImuNO7M7qeJSDnD3LcsfKQJ3GBf1R4HvgWnw5ZcG8/OG08Ah2NIsvf4TWsfPz
 tb9dmqsiq31Z1wD0SzW173LfE9ptZjHeGAVXuMBm2vTNDnPGU48eB0qwNX8uzUKI3MXH
 YOzRNZw21IlWYwCTQAPJw0VTbgvCHp1WzjEbAMUwaHhsxfe2hP44XehEEYELOt8quhKo
 q50fWjuLYazy9f6ljy7Y56mPxtMG20bnur7pR+SCFUgLLHnXosN8f27oxF3WWB62Rld9
 kOW7DpQyqlonEW+CMfR+qZOM+sp0Qc05qYp50HrAjK+kuZw874rhhOQTh6XsfMM5qx2w
 OxOw==
X-Gm-Message-State: AOAM531SW3KHopvsmDlyCPWiOipCs7vHzln58USzGg8Na3RC2T3WzVFq
 EoMD476gatGxwlQoYWQUAg1dL9n8W33i8Q==
X-Google-Smtp-Source: ABdhPJymT6h8EUOVQS57pIU9pbti0a27Yo49+qlDM1qFtpDk4kVc5nHJUZoC2TxkvbpQ45B2ObYRuQ==
X-Received: by 2002:a17:906:bcfc:: with SMTP id
 op28mr10959629ejb.248.1601199914803; 
 Sun, 27 Sep 2020 02:45:14 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8317:b300:20a5:43fd:f98d:6934])
 by smtp.gmail.com with ESMTPSA id jr9sm5949650ejb.87.2020.09.27.02.45.13
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 27 Sep 2020 02:45:14 -0700 (PDT)
From: Laurentiu Barbulescu <lrbarbulescu@gmail.com>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	Laurentiu Barbulescu <lrbarbulescu@gmail.com>
Subject: [UNIKRAFT/LIBTASN1, 2/2] Add Makefile.uk
Date: Sun, 27 Sep 2020 12:45:01 +0300
Message-Id: <34dae8a1bcd089c97075277c18ef200de3bba974.1601197200.git.lrbarbulescu@gmail.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <cover.1601197200.git.lrbarbulescu@gmail.com>
References: <cover.1601197200.git.lrbarbulescu@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Mailman-Approved-At: Wed, 30 Sep 2020 11:26:07 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: Laurentiu Barbulescu <lrbarbulescu@gmail.com>
---
 Makefile.uk | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 121 insertions(+)
 create mode 100644 Makefile.uk

diff --git a/Makefile.uk b/Makefile.uk
new file mode 100644
index 0000000..75573a2
--- /dev/null
+++ b/Makefile.uk
@@ -0,0 +1,121 @@
+#  SPDX-License-Identifier: BSD-3-Clause
+#
+#  libtasn1 Makefile.uk
+#
+#  Authors: Laurentiu Barbulescu <lrbarbulescu@gmail.com>
+#
+#  Copyright (c) 2019, University Politehnica of Bucharest. All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#  3. Neither the name of the copyright holder nor the names of its
+#     contributors may be used to endorse or promote products derived from
+#     this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#  POSSIBILITY OF SUCH DAMAGE.
+#
+#  THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+#
+
+################################################################################
+# Library registration
+################################################################################
+$(eval $(call addlib_s,libtasn1,$(CONFIG_LIBTASN1)))
+
+################################################################################
+# Original sources
+################################################################################
+LIBTASN1_VERSION = 4.16.0
+LIBTASN1_URL = http://ftp.gnu.org/gnu/libtasn1/libtasn1-$(LIBTASN1_VERSION).tar.gz
+LIBTASN1_SUBDIR = libtasn1-$(LIBTASN1_VERSION)
+$(eval $(call fetch,libtasn1,$(LIBTASN1_URL)))
+
+# LIBTASN1_PATCHDIR=$(LIBTASN1_BASE)/patches
+# $(eval $(call patch,libtasn1,$(LIBTASN1_PATCHDIR),$(LIBTASN1_SUBDIR)))
+
+################################################################################
+# Helpers
+################################################################################
+LIBTASN1_EXTRACTED = $(LIBTASN1_ORIGIN)/libtasn1-$(LIBTASN1_VERSION)
+
+################################################################################
+# Library includes
+################################################################################
+LIBTASN1_COMMON_INCLUDES-y     += -I$(LIBTASN1_EXTRACTED)/lib
+LIBTASN1_COMMON_INCLUDES-y     += -I$(LIBTASN1_EXTRACTED)/lib/gl
+LIBTASN1_COMMON_INCLUDES-y     += -I$(LIBTASN1_EXTRACTED)/lib/includes
+
+CINCLUDES-$(CONFIG_LIBTASN1)   += $(LIBTASN1_COMMON_INCLUDES-y)
+CXXINCLUDES-$(CONFIG_LIBTASN1) += $(LIBTASN1_COMMON_INCLUDES-y)
+
+LIBTASN1_CINCLUDES   += -I$(LIBTASN1_EXTRACTED)
+LIBTASN1_CXXINCLUDES += -I$(LIBTASN1_EXTRACTED)
+
+################################################################################
+# Global flags
+################################################################################
+# Suppress flags
+LIBTASN1_SUPPRESS_FLAGS += -Wno-unused-parameter -Wno-type-limits
+LIBTASN1_CFLAGS-y   += $(LIBTASN1_SUPPRESS_FLAGS)
+LIBTASN1_CXXFLAGS-y += $(LIBTASN1_SUPPRESS_FLAGS)
+
+# Preprocessing symbols
+LIBTASN1_DEFINES    += -DHAVE_CONFIG_H
+LIBTASN1_CFLAGS-y   += $(LIBTASN1_DEFINES)
+LIBTASN1_CXXFLAGS-y += $(LIBTASN1_DEFINES)
+
+################################################################################
+# LIBTASN1 code
+################################################################################
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/ASN1.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/coding.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/decoding.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/element.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/errors.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/gstr.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/parser_aux.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/structure.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/version.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/gl/c-ctype.c
+LIBTASN1_SRCS-y += $(LIBTASN1_EXTRACTED)/lib/gl/strverscmp.c
+
+################################################################################
+# LIBTASN1 prepare
+################################################################################
+# Run ./configure
+$(LIBTASN1_EXTRACTED)/config.status: $(LIBTASN1_BUILD)/.origin
+	$(call verbose_cmd,CONFIG,libtasn1: $(notdir $@), \
+		cd $(LIBTASN1_EXTRACTED) && ./configure)
+
+# Use the native build system to generate limits.h
+$(LIBTASN1_EXTRACTED)/lib/gl/limits.h: $(LIBTASN1_BUILD)/.origin
+	$(call verbose_cmd,CONFIG,libtasn1: $(notdir $@), \
+		cd $(LIBTASN1_EXTRACTED)/lib/gl && make limits.h)
+# Use the native build system to generate string.h
+$(LIBTASN1_EXTRACTED)/lib/gl/string.h: $(LIBTASN1_BUILD)/.origin
+	$(call verbose_cmd,CONFIG,libtasn1: $(notdir $@), \
+		cd $(LIBTASN1_EXTRACTED)/lib/gl && make string.h)
+
+LIBTASN1_PREPARED_DEPS = $(LIBTASN1_EXTRACTED)/config.status \
+						 $(LIBTASN1_EXTRACTED)/lib/gl/limits.h \
+						 $(LIBTASN1_EXTRACTED)/lib/gl/string.h 
+$(LIBTASN1_BUILD)/.prepared: $(LIBTASN1_PREPARED_DEPS)
+
+UK_PREPARE += $(LIBTASN1_BUILD)/.prepared
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Wed Sep 30 11:26:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 30 Sep 2020 11:26:11 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNaFM-0005n2-Ta; Wed, 30 Sep 2020 11:26:08 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=h52Z=DE=gmail.com=lrbarbulescu@srs-us1.protection.inumbo.net>)
 id 1kMTF9-0003jI-Ld
 for minios-devel@lists.xen.org; Sun, 27 Sep 2020 09:45:19 +0000
X-Inumbo-ID: 530642d9-273b-4e19-83dc-281c7cdf1e77
Received: from mail-ed1-x533.google.com (unknown [2a00:1450:4864:20::533])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 530642d9-273b-4e19-83dc-281c7cdf1e77;
 Sun, 27 Sep 2020 09:45:14 +0000 (UTC)
Received: by mail-ed1-x533.google.com with SMTP id n13so6854742edo.10
 for <minios-devel@lists.xen.org>; Sun, 27 Sep 2020 02:45:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=LZeMpOO8ErVYvB8BiWZg2FhBL0tgsqw278IHysglzEQ=;
 b=JYdQksfXoXJL+NZAMaeQ71Q/a0WQnLGc4N9/X6UWtvYpEb1/+5N3Vcii3lOOTce4JM
 iColWRkPXITSY6lyfO6TFnBojt/vuHd3PKSfeO7MqUxVgwotuuS5E9Pbju1WHek///g3
 lWFUgP4X0UvsCSkoFeXXEs2C8sLvq2grcCjml19nF+c+U47xWaWcRFDk1erUjJrw6d4e
 BRM/bk35nED7QqcoB3akr8PmsHU4ieR7IizIdu5fsc1xVfJMn+LZs7F3O8YQawv2qZ7g
 v/XQ+HZMk1YreCFl4HvnJorXZlCS7srjkQEmmTZ6wud7W0SugKZStuOoPsNIUPLw6UjC
 CLRw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=LZeMpOO8ErVYvB8BiWZg2FhBL0tgsqw278IHysglzEQ=;
 b=jbpmTahpYCtuofQTez/38rkIxvxnsX6m2v+lqtgCbubGncyvTnTBrF6MKFMapCUFiX
 GNrOlJOkDzfUPRDcBAo4HVeDTd6eIgq6MWlW4tdJFuJnIgXx97gl80RUclp8Ey9UAIi+
 HjOfPpXf7VwJqHvUKebEpZLwqf4JGudlxhgAWkuS1LOPDhEOJ7kegRU423gkEHmTz3/w
 WujU52W0YfvIaLbJonBlzUH2oR0A8tjLYLfcTikvaoUlW67a87LQTALHbXTdyOebKyW/
 AeLVoZXD1urGNoOQX/7S5R2ueWjRi1GThFaqkhFU/TjMDwQcEADwsXInwNqzijpP5Wmi
 db7Q==
X-Gm-Message-State: AOAM530RYxS4GdFAj6hrbtOWob6YDXsqnPMG3RdoCdkLOLiIzwS+CaNs
 ECTdlcPwUH0z8H/zOpKXT8gHpCO4MsgL5A==
X-Google-Smtp-Source: ABdhPJyYHI7wwL8b3kXkwO2ADfw8nem4qYWoAP8ntwqAJ2BlMkONwPCTvwgBVhg64py1VYcLAWdnmA==
X-Received: by 2002:a05:6402:14d4:: with SMTP id
 f20mr10085090edx.291.1601199913549; 
 Sun, 27 Sep 2020 02:45:13 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8317:b300:20a5:43fd:f98d:6934])
 by smtp.gmail.com with ESMTPSA id jr9sm5949650ejb.87.2020.09.27.02.45.12
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 27 Sep 2020 02:45:13 -0700 (PDT)
From: Laurentiu Barbulescu <lrbarbulescu@gmail.com>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	Laurentiu Barbulescu <lrbarbulescu@gmail.com>
Subject: [UNIKRAFT/LIBTASN1, 1/2] Introduce library skeleton
Date: Sun, 27 Sep 2020 12:45:00 +0300
Message-Id: <17bf8ad66446102859a5dec4a2263acbedab99d2.1601197200.git.lrbarbulescu@gmail.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <cover.1601197200.git.lrbarbulescu@gmail.com>
References: <cover.1601197200.git.lrbarbulescu@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Mailman-Approved-At: Wed, 30 Sep 2020 11:26:07 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: Laurentiu Barbulescu <lrbarbulescu@gmail.com>
---
 .gitignore      | 27 +++++++++++++++++++++++++++
 CODING_STYLE.md |  4 ++++
 CONTRIBUTING.md |  4 ++++
 COPYING.md      | 38 ++++++++++++++++++++++++++++++++++++++
 Config.uk       |  4 ++++
 MAINTAINERS.md  | 11 +++++++++++
 README.md       | 29 +++++++++++++++++++++++++++++
 7 files changed, 117 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 CODING_STYLE.md
 create mode 100644 CONTRIBUTING.md
 create mode 100644 COPYING.md
 create mode 100644 Config.uk
 create mode 100644 MAINTAINERS.md
 create mode 100644 README.md

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..75d2fd3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,27 @@
+*.depend
+*.o
+*.a
+*.d
+*.so
+*.orig
+*.rej
+*.bak
+*.swp
+*~
+,*
+\#*\#
+.\#*
+\#_*\#
+.\#_*
+!.gitignore
+.*
+
+# gnu global files
+GPATH
+GRTAGS
+GSYMS
+GTAGS
+
+# cscope files
+cscope.*
+ncscope.*
diff --git a/CODING_STYLE.md b/CODING_STYLE.md
new file mode 100644
index 0000000..5730041
--- /dev/null
+++ b/CODING_STYLE.md
@@ -0,0 +1,4 @@
+Coding Style
+============
+
+Please refer to the `CODING_STYLE.md` file in the main Unikraft repository.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..14f6ac6
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,4 @@
+Contributing to Unikraft
+========================
+
+Please refer to the `CONTRIBUTING.md` file in the main Unikraft repository.
diff --git a/COPYING.md b/COPYING.md
new file mode 100644
index 0000000..b65a5a7
--- /dev/null
+++ b/COPYING.md
@@ -0,0 +1,38 @@
+License
+=======
+
+Unikraft libtasn1 wrappers
+--------------------------
+
+This repository contains wrapper code to build libtasn1 with Unikraft.
+Each C code file in this repository should declare who is the
+copyright owner and under which terms and conditions the code is
+licensed. If such a licence note is missing, the following copyright
+notice will apply:
+
+	Copyright (c) Year, Institution. All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions
+	are met:
+
+	1. Redistributions of source code must retain the above copyright
+	   notice, this list of conditions and the following disclaimer.
+	2. Redistributions in binary form must reproduce the above copyright
+	   notice, this list of conditions and the following disclaimer in the
+	   documentation and/or other materials provided with the distribution.
+	3. Neither the name of the copyright holder nor the names of its
+	   contributors may be used to endorse or promote products derived from
+	   this software without specific prior written permission.
+
+	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+	AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+	ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+	LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+	CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+	POSSIBILITY OF SUCH DAMAGE.
diff --git a/Config.uk b/Config.uk
new file mode 100644
index 0000000..443e5ff
--- /dev/null
+++ b/Config.uk
@@ -0,0 +1,4 @@
+config LIBTASN1
+	bool "libtasn1 - Manage ASN.1 structures"
+	default n
+	select LIBNEWLIBC
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
new file mode 100644
index 0000000..3632ef2
--- /dev/null
+++ b/MAINTAINERS.md
@@ -0,0 +1,11 @@
+Maintainers List
+================
+
+For notes on how to read this information, please refer to `MAINTAINERS.md` in
+the main Unikraft repository.
+
+	LIBTASN1-UNIKRAFT
+	M:	Laurentiu Barbulescu <lrbarbulescu@gmail.com>
+	M:	Felipe Huici <felipe.huici@neclab.eu>
+	L:	minios-devel@lists.xen.org
+	F: *
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..dbf0fdc
--- /dev/null
+++ b/README.md
@@ -0,0 +1,29 @@
+libtasn1 for Unikraft
+=====================
+
+This is the port of libtasn1 4.16.0 for Unikraft as external library.
+
+libtasn1 depends on libc(e.g. newlib), so please ensure you add the following line to the `LIBS` variable in the `Makefile`:
+
+...$(UK_LIBS)/libtasn1:$(UK_LIBS)/newlib...
+
+Using the root filesystem
+-------------------------
+
+We will use the 9pfs support for filesystems. To enable it, you'll need to select the following menu options, all under "Library Configuration":
+- `vfscore: VFS Core Interface`
+- `Automatically mount a root filesysytem (/)` from `vfscore: Configuration`
+- `9PFS` for `Default root filesystem` from `vfscore: Configuration`
+- `devfs: devfs file system`
+- `Mount /dev during boot` from `devfs: devfs file system`
+
+With the 9pfs support enabled, all you have to do is to provide the right Qemu parameters in order for Unikraft to mount the filesystem:
+```
+-fsdev local,id=myid,path=<some directory>,security_model=none \
+-device virtio-9p-pci,fsdev=myid,mount_tag=rootfs,disable-modern=on,disable-legacy=off
+```
+Further information
+-------------------
+
+Please refer to the `README.md` as well as the documentation in the `doc/`
+subdirectory of the main unikraft repository.
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Wed Sep 30 11:26:13 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 30 Sep 2020 11:26:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNaFM-0005mx-SB; Wed, 30 Sep 2020 11:26:08 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=h52Z=DE=gmail.com=lrbarbulescu@srs-us1.protection.inumbo.net>)
 id 1kMTF4-0003jI-QR
 for minios-devel@lists.xen.org; Sun, 27 Sep 2020 09:45:14 +0000
X-Inumbo-ID: b56136e9-2127-4bb0-aff6-c416faf09f55
Received: from mail-ed1-x52a.google.com (unknown [2a00:1450:4864:20::52a])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id b56136e9-2127-4bb0-aff6-c416faf09f55;
 Sun, 27 Sep 2020 09:45:13 +0000 (UTC)
Received: by mail-ed1-x52a.google.com with SMTP id n22so6875905edt.4
 for <minios-devel@lists.xen.org>; Sun, 27 Sep 2020 02:45:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=NN3bGhqA7cn4SvVqflUwVSer0DBaf8fc3A0asYslTOE=;
 b=ekuEeViWmCdSZxmTJ0+HK+PZ3K/M3ekwcHp+zMk/KCPUVMymKPlVM5SrRY/bnj9rHs
 Z/zeEUtKGSgibKySAQov7DVbNu47mJMqbje2uU9e4uS1WWIwtvC/d3zf3WSAVEzea63q
 urIgcY4g7KD3soNR77A7HPC/aFT/pSovdzvUuYcvMqRyUOQ85ra0ntdnLix5ThpYD/8V
 KXSch+XXcU5i7V547Hz8otY8eNt5MxjIxv9BmF/Cpq1RwJykddE31GvB5nCby2xAcwMu
 EKS6n98yOrljb4yEYJWdERzcp1iGurxSpa0h3gM1EN1HK5sCqV2uRAuYHiF9WLe6DgrA
 9A/w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=NN3bGhqA7cn4SvVqflUwVSer0DBaf8fc3A0asYslTOE=;
 b=UxeIAktsgiKS8PpJhxxCUia5z2wHqfptho5Yg4iJ5aIlj0NbKYYLWaVx7IvImA6J6h
 mig+ukk1vjiVTa0WZTZSiZIXoHGTZjg0LyGADCGB1Higkwn7GaLuqv3jUZlpcrZxTFAS
 prMWe2PkEuYevG+WE8V3HAzG8X+3UQBxyacuj6rJg4hYrm9yE5HkC0Y+rX9QQCnkjZPV
 TJk2asWItXNJPh8k4h7xbNLbdDdk9/34QOFkYlI9UZcwoVKffD6KQBfjiW9ukW3l8kIO
 xu4S3khAPxF62V0H36ANwRCiMzZeLO8lMEbug+pH02adoAoF1P8fz8SvFewxysn7UuI4
 a8dA==
X-Gm-Message-State: AOAM530A3LAhEuA91F9P6q4Q3On5kTqOZW3bRbTLhwR2vGoGK1tUMvC1
 kEnyGrZXc+7Ko+jK49zlfV3vDmFiYSo=
X-Google-Smtp-Source: ABdhPJww2MxTbEcMY9N1Q3+SQlfAA+VitWhwQVNsV0KxD4QZ9RDLwK1NB4+GHvGNgyZnnbEZWse2Zg==
X-Received: by 2002:aa7:c38a:: with SMTP id k10mr10580483edq.325.1601199912497; 
 Sun, 27 Sep 2020 02:45:12 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8317:b300:20a5:43fd:f98d:6934])
 by smtp.gmail.com with ESMTPSA id jr9sm5949650ejb.87.2020.09.27.02.45.11
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 27 Sep 2020 02:45:12 -0700 (PDT)
From: Laurentiu Barbulescu <lrbarbulescu@gmail.com>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	Laurentiu Barbulescu <lrbarbulescu@gmail.com>
Subject: [UNIKRAFT/LIBTASN1, 0/2] Initial port of libtasn1 on Unikraft
Date: Sun, 27 Sep 2020 12:44:59 +0300
Message-Id: <cover.1601197200.git.lrbarbulescu@gmail.com>
X-Mailer: git-send-email 2.25.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Mailman-Approved-At: Wed, 30 Sep 2020 11:26:07 +0000
X-BeenThere: minios-devel@lists.xenproject.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

The libtasn1 library provides Abstract Syntax Notation One (ASN.1, as specified
by the X.680 ITU-T recommendation) parsing and structures management, and
Distinguished Encoding Rules (DER, as per X.690) encoding and decoding functions.

Laurentiu Barbulescu (2):
  Introduce library skeleton
  Add Makefile.uk

-- 
2.25.1



