From minios-devel-bounces@lists.xenproject.org Sat May 02 15:16:12 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 15:16:12 +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 1jUts9-0004uu-1R; Sat, 02 May 2020 15:16:09 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=Iq85=6Q=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jUts7-0004up-NK
 for minios-devel@lists.xen.org; Sat, 02 May 2020 15:16:07 +0000
X-Inumbo-ID: d819a716-8c87-11ea-ae69-bc764e2007e4
Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d819a716-8c87-11ea-ae69-bc764e2007e4;
 Sat, 02 May 2020 15:16:06 +0000 (UTC)
Received: by mail-wr1-x443.google.com with SMTP id l18so4676031wrn.6
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 08:16: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:mime-version
 :content-transfer-encoding;
 bh=bcaAjUcDafsmWVsd0G697rhmFUS/hStDzHYqRQFeBx0=;
 b=MX+E2mI2ErZTkflTr1O1XMiFjEexBd0vngVACgZWx9EGJWAdee8qq2lPCOC6u1YDmz
 wZUV0PyvBmm4chkf8iXkIMwZmuRmEasaOMSxdAESm5mRy8Q/Qj5K7wzC41lxkqYNbn0y
 Qx4k7Z8lxhrYopBGeLX64Mg2BNiXleaGsEvd/qaeSOGrLNJihCOeWZbA1gozoB6rGqLs
 fNQLBthxw4vELK0C2NqYeps4+lUVZ1VKalUcDGBmyLqaGjKgPVergOuebwFLD8FBaUOW
 xpbZ1igqQDwff41YzaQN/nxv6i8xSjJoCISguoooe3qXw1Gib4DIvE9SMQWxku/sm47C
 yeIQ==
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=bcaAjUcDafsmWVsd0G697rhmFUS/hStDzHYqRQFeBx0=;
 b=Wug+Hfjzj8hin1XmCIb0R1Ik8QLcubtrENUBTg9squ51MbHwFvewqv4qDL6mqFdKLY
 7DaGHi6xNAhgPfftZN63XvuQHzWTtwQBGL+Z6blINaDe+QHR7ZQBklFbAY/CEVWwa3VY
 SlfitRfKjGi1rp2AHMaIuAgV54X4bCBqquk1l3k2hAdU/GGG/HrGCTaP2KhM2p9JF3kv
 IFvNuVhJmfYF67pMrVlHGIKEKXSd0B2shoKwl4bSKHAX6IyUKHnTheColOcMZUjykiIV
 c0vF7ryPZGfaIPDDZoAcZc9JR2KgzFR78ebP4QNmuNxjcyuDQfy0ugNxcbrMfT48KxAE
 q4ag==
X-Gm-Message-State: AGi0PuauY8maZqRiukLZmmWze5BoXb4M91eZlFvFopfKGsQHFY0IQdMD
 5hS2NkKc2sarTpHCjRRIRLzpg4qbnE0=
X-Google-Smtp-Source: APiQypK9djk3jxVD/ucGB2Pu9Hx/mjqx6C4JJXD9ocTT1ie/+iSh//5NgFheXBOXl89RRM6yWAiERw==
X-Received: by 2002:adf:e483:: with SMTP id i3mr9151972wrm.88.1588432565605;
 Sat, 02 May 2020 08:16:05 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id u12sm4793822wmu.25.2020.05.02.08.16.04
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 08:16:05 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 0/7] General 9pfs and vfscore improvements
Date: Sat,  2 May 2020 16:13:33 +0100
Message-Id: <20200502151340.92959-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch series adds general 9pfs and vfscore improvements, both for
correctness and for performance.

After applying this patchlist on staging, all python3.7 autotest
filesystem-related tests are passing.

Cristian Banu (7):
  lib/uk9p: Rewrite serialization
  lib/uk9p: Use uk_trace instead of uk_pr_debug
  lib/uk9p: Use fixed-size request buffers
  lib/uk9p: Recycle uk_9preq allocations
  lib/vfscore: Fix double refcounting bug
  lib/vfscore: Expose max fds to sysconf
  lib/9pfs: Simplify the logic for removes

 lib/9pfs/9pfs_vfsops.c             |   7 +-
 lib/9pfs/9pfs_vnops.c              |  39 +--
 lib/posix-sysinfo/sysinfo.c        |  10 +
 lib/uk9p/9p.c                      | 447 +++++++++++++++++++----------
 lib/uk9p/9pdev.c                   | 123 +++++---
 lib/uk9p/9preq.c                   | 396 ++-----------------------
 lib/uk9p/exportsyms.uk             |   7 -
 lib/uk9p/include/uk/9pdev.h        |  38 +--
 lib/uk9p/include/uk/9pdev_core.h   |   2 +
 lib/uk9p/include/uk/9preq.h        | 283 +++++++++++++-----
 lib/vfscore/fd.c                   |   2 -
 lib/vfscore/include/vfscore/file.h |   3 +
 lib/vfscore/syscalls.c             |   6 +-
 13 files changed, 660 insertions(+), 703 deletions(-)

-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 02 15:16:13 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 15:16: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 1jUtsD-0004vD-36; Sat, 02 May 2020 15:16: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=Iq85=6Q=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jUtsC-0004v1-Kk
 for minios-devel@lists.xen.org; Sat, 02 May 2020 15:16:12 +0000
X-Inumbo-ID: d921f9ce-8c87-11ea-b07b-bc764e2007e4
Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d921f9ce-8c87-11ea-b07b-bc764e2007e4;
 Sat, 02 May 2020 15:16:08 +0000 (UTC)
Received: by mail-wm1-x342.google.com with SMTP id u16so3497588wmc.5
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 08:16:08 -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=uzF9WzTzIoMexdBVgOhCGhATQzaJaxL+Bq3edgg/Rkk=;
 b=EKQ6X3KkFsKA5MH4dsGX7N80KNRVOYNtqsRwoq14diax7fV3Ku5uakphfNiTrkhFY0
 vRXMEfW1Oi8vvlKRSUhsBf65h1emYnlfq0Mo7F+bjXYzOLEIW3Ox/y3Qa067vh1G2CAB
 eNrf4mv720ZyDmz9OOGjN2pVMffXE/Nk7op6YNzJUR79vsHO9XwJMsHiT8dQhMpLfyI/
 GQ3g4HHQo2vJ3zEUh71OY4QAV+GJAD06DdVmoN+aIYE61aMlJ/Dz1AYBp/lQ13JE6kBQ
 VbkhGmmGGkSpYtDVApS9Qi7ytpE3SsWP15tCiqPkkn0NpfGatAZjUJW5Xwyg9oAtS9c+
 wPZw==
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=uzF9WzTzIoMexdBVgOhCGhATQzaJaxL+Bq3edgg/Rkk=;
 b=EMEX66bFErRjCEqfY5qA4wAeR/11CaDswXTCbGg2JJcStcbTFw2v0H1jaIchqFGI4Y
 Fdt7B6YTkIQePhVKkbRX4QFpUTvu8AkzS5V7OkarIfhHeCpvlX7yBCX7HhgJKVu7O9i8
 RXLCo79P5+rcaO89PSJ+YuqN3EjmcSUKsQ0W3TqOfOhAMRkVvz067IvQJTH2sMbM4mZ8
 vrFEs93dgCsOcxICSu3L1Z1O/RBGZcqnA4VdbTJOGyuFv2I0P/cFYCzJ9U8VMpQ2/EvS
 k4Y1M0TByBL2BN55NT4hhbXf/FSj9KUvn+5fDvUS10eMKtBCrhTdETFt2ZxQV7tUBXnE
 O4dw==
X-Gm-Message-State: AGi0PuaX0xa607ie8RQVKh7VcZNvIp46TCQn0iNfwOUFMXpRSglSKT3e
 doBOcuI3JEJKSFypm6Tiq5xw4OhpyDM=
X-Google-Smtp-Source: APiQypLlguspsXnIKcucVDjj0g+5bA6wGqpgC4dvfI+3v042kg6S5qJ365Yz7MuQGILw2AGZ3duKsw==
X-Received: by 2002:a7b:c213:: with SMTP id x19mr4889450wmi.53.1588432567192; 
 Sat, 02 May 2020 08:16:07 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id u12sm4793822wmu.25.2020.05.02.08.16.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 08:16:06 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 2/7] lib/uk9p: Use uk_trace instead of uk_pr_debug
Date: Sat,  2 May 2020 16:13:35 +0100
Message-Id: <20200502151340.92959-3-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200502151340.92959-1-cristb@gmail.com>
References: <20200502151340.92959-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch enables nanosecond-resolution tracing of 9pfs performance
without the added noise of having to output the message; the same
mechanism can also be used to inspect the behavior of the protocol.

Excerpt from the output traces for a read() with in-depth tracing:
607016885  uk_9p_trace_read               fid 2 offset 61440 count 4096
607020599  uk_9p_trace_request_allocated
607020627  uk_9p_trace_ready              tag 0
607023469  uk_9p_trace_sent               tag 0
607062214  uk_9p_trace_received           tag 0
607062258  uk_9p_trace_read_end           count 4096

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/9p.c | 205 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 145 insertions(+), 60 deletions(-)

diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index 638555b..d6ba3cf 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -40,16 +40,40 @@
 #include <uk/9preq.h>
 #include <uk/9pfid.h>
 
+/*
+ * Define UK_DEBUG_TRACE to enable traces in this file.
+ * Also define UK_9P_INDEPTH_TRACES to enable more in-depth traces.
+ *
+ * These lines must be added before including uk/trace.h.
+ */
+#include <uk/trace.h>
+
+UK_TRACEPOINT(uk_9p_trace_ready, "tag %u", uint16_t);
+UK_TRACEPOINT(uk_9p_trace_sent, "tag %u", uint16_t);
+UK_TRACEPOINT(uk_9p_trace_received, "tag %u", uint16_t);
+UK_TRACEPOINT(uk_9p_trace_request_allocated, "");
+
 static inline int send_and_wait_zc(struct uk_9pdev *dev, struct uk_9preq *req,
 		enum uk_9preq_zcdir zc_dir, void *zc_buf, uint32_t zc_size,
 		uint32_t zc_offset)
 {
 	int rc;
 
-	if ((rc = uk_9preq_ready(req, zc_dir, zc_buf, zc_size, zc_offset)) ||
-		(rc = uk_9pdev_request(dev, req)) ||
-		(rc = uk_9preq_waitreply(req)))
+	if ((rc = uk_9preq_ready(req, zc_dir, zc_buf, zc_size, zc_offset)))
+		return rc;
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_ready(req->tag);
+#endif
+	if ((rc = uk_9pdev_request(dev, req)))
 		return rc;
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_sent(req->tag);
+#endif
+	if ((rc = uk_9preq_waitreply(req)))
+		return rc;
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_received(req->tag);
+#endif
 
 	return 0;
 }
@@ -60,6 +84,10 @@ static inline int send_and_wait_no_zc(struct uk_9pdev *dev,
 	return send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
 }
 
+UK_TRACEPOINT(uk_9p_trace_version, "msize %u version %s",
+		uint32_t, const char *);
+UK_TRACEPOINT(uk_9p_trace_version_end, "msize %u", uint32_t);
+
 struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 		const char *requested, struct uk_9p_str *received)
 {
@@ -68,14 +96,16 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 	int rc = 0;
 	uint32_t new_msize;
 
+	uk_9p_trace_version(dev->msize, requested);
 	uk_9p_str_init(&requested_str, requested);
 
 	req = uk_9pdev_req_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return req;
 
-	uk_pr_debug("TVERSION msize %u version %s\n",
-			dev->msize, requested);
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
 
 	if ((rc = uk_9preq_write32(req, dev->msize)) ||
 		(rc = uk_9preq_writestr(req, &requested_str)) ||
@@ -83,9 +113,7 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 		(rc = uk_9preq_read32(req, &new_msize)) ||
 		(rc = uk_9preq_readstr(req, received)))
 		goto free;
-
-	uk_pr_debug("RVERSION msize %u version %.*s\n", new_msize,
-			received->size, received->data);
+	uk_9p_trace_version_end(new_msize);
 
 	/*
 	 * Note: the 9P specification mentions that new_msize <= dev->msize.
@@ -103,6 +131,11 @@ free:
 	return ERR2PTR(rc);
 }
 
+UK_TRACEPOINT(uk_9p_trace_attach, "fid %u afid %u uname %s aname %s n_uname %u",
+		uint32_t, uint32_t, const char *, const char *, uint32_t);
+UK_TRACEPOINT(uk_9p_trace_attach_end, "qid type %u version %u path %lu",
+		uint32_t, uint32_t, uint64_t);
+
 struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
 		const char *uname, const char *aname, uint32_t n_uname)
 {
@@ -119,16 +152,18 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
 	if (PTRISERR(fid))
 		return fid;
 
+	uk_9p_trace_attach(fid->fid, afid, uname, aname, n_uname);
+
 	req = uk_9pdev_req_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
 	if (PTRISERR(req)) {
 		uk_9pdev_fid_release(fid);
 		return (void *)req;
 	}
 
-	uk_pr_debug("TATTACH fid %u afid %u uname %s aname %s n_uname %u\n",
-			fid->fid, afid, uname, aname, n_uname);
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
 
-	rc = 0;
 	if ((rc = uk_9preq_write32(req, fid->fid)) ||
 		(rc = uk_9preq_write32(req, afid)) ||
 		(rc = uk_9preq_writestr(req, &uname_str)) ||
@@ -137,11 +172,8 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
 		(rc = send_and_wait_no_zc(dev, req)) ||
 		(rc = uk_9preq_readqid(req, &fid->qid)))
 		goto free;
-
 	uk_9pdev_req_remove(dev, req);
-
-	uk_pr_debug("RATTACH qid type %u version %u path %lu\n",
-			fid->qid.type, fid->qid.version, fid->qid.path);
+	uk_9p_trace_attach_end(fid->qid.type, fid->qid.version, fid->qid.path);
 
 	return fid;
 
@@ -151,26 +183,38 @@ free:
 	return ERR2PTR(rc);
 }
 
+UK_TRACEPOINT(uk_9p_trace_flush, "oldtag %u", uint32_t);
+UK_TRACEPOINT(uk_9p_trace_flush_end, "");
+
 int uk_9p_flush(struct uk_9pdev *dev, uint16_t oldtag)
 {
 	struct uk_9preq *req;
 	int rc = 0;
 
+	uk_9p_trace_flush(oldtag);
+
 	req = uk_9pdev_req_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_pr_debug("TFLUSH oldtag %u\n", oldtag);
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
+
 	if ((rc = uk_9preq_write16(req, oldtag)) ||
 		(rc = send_and_wait_no_zc(dev, req)))
 		goto out;
-	uk_pr_debug("RFLUSH\n");
+	uk_9p_trace_flush_end();
 
 out:
 	uk_9pdev_req_remove(dev, req);
 	return rc;
 }
 
+UK_TRACEPOINT(uk_9p_trace_walk, "fid %u newfid %u name %s",
+		uint32_t, uint32_t, const char *);
+UK_TRACEPOINT(uk_9p_trace_walk_end, "nwqid %u", uint32_t);
+
 struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		const char *name)
 {
@@ -187,6 +231,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	if (PTRISERR(newfid))
 		return newfid;
 
+	uk_9p_trace_walk(fid->fid, newfid->fid, name ? name : "<NULL>");
 	nwname = name ? 1 : 0;
 
 	req = uk_9pdev_req_create(dev, UK_9P_TWALK, __PAGE_SIZE);
@@ -195,22 +240,16 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		goto out;
 	}
 
-	if (name) {
-		uk_pr_debug("TWALK fid %u newfid %u nwname %d name %s\n",
-				fid->fid, newfid->fid, nwname, name);
-		if ((rc = uk_9preq_write32(req, fid->fid)) ||
-			(rc = uk_9preq_write32(req, newfid->fid)) ||
-			(rc = uk_9preq_write16(req, nwname)) ||
-			(rc = uk_9preq_writestr(req, &name_str)))
-			goto out;
-	} else {
-		uk_pr_debug("TWALK fid %u newfid %u nwname %d\n",
-				fid->fid, newfid->fid, nwname);
-		if ((rc = uk_9preq_write32(req, fid->fid)) ||
-			(rc = uk_9preq_write32(req, newfid->fid)) ||
-			(rc = uk_9preq_write16(req, nwname)))
-			goto out;
-	}
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
+
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write32(req, newfid->fid)) ||
+		(rc = uk_9preq_write16(req, nwname)))
+		goto out;
+	if (name && (rc = uk_9preq_writestr(req, &name_str)))
+		goto out;
 
 	if ((rc = send_and_wait_no_zc(dev, req))) {
 		/*
@@ -224,7 +263,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	if ((rc = uk_9preq_read16(req, &nwqid)))
 		goto out;
 
-	uk_pr_debug("RWALK nwqid %u\n", nwqid);
+	uk_9p_trace_walk_end(nwqid);
 
 	if (nwqid != nwname) {
 		rc = -ENOENT;
@@ -247,16 +286,24 @@ out:
 	return newfid;
 }
 
+UK_TRACEPOINT(uk_9p_trace_open, "fid %u mode %u", uint32_t, uint32_t);
+UK_TRACEPOINT(uk_9p_trace_open_end,
+		"qid type %u version %u path %lu, iounit %u",
+		uint32_t, uint32_t, uint64_t, uint32_t);
+
 int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
 {
 	struct uk_9preq *req;
 	int rc = 0;
 
+	uk_9p_trace_open(fid->fid, mode);
 	req = uk_9pdev_req_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
 
 	if ((rc = uk_9preq_write32(req, fid->fid)) ||
 		(rc = uk_9preq_write8(req, mode)) ||
@@ -265,8 +312,7 @@ int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
 		(rc = uk_9preq_read32(req, &fid->iounit)))
 		goto out;
 
-	uk_pr_debug("ROPEN qid type %u version %u path %lu iounit %u\n",
-			fid->qid.type, fid->qid.version, fid->qid.path,
+	uk_9p_trace_open_end(fid->qid.type, fid->qid.version, fid->qid.path,
 			fid->iounit);
 
 out:
@@ -274,6 +320,11 @@ out:
 	return rc;
 }
 
+UK_TRACEPOINT(uk_9p_trace_create, "fid %u mode %u", uint32_t, uint32_t);
+UK_TRACEPOINT(uk_9p_trace_create_end,
+		"qid type %u version %u path %lu, iounit %u",
+		uint32_t, uint32_t, uint64_t, uint32_t);
+
 int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		const char *name, uint32_t perm, uint8_t mode,
 		const char *extension)
@@ -283,6 +334,7 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	struct uk_9p_str extension_str;
 	int rc = 0;
 
+	uk_9p_trace_create(fid->fid, mode);
 	uk_9p_str_init(&name_str, name);
 	uk_9p_str_init(&extension_str, extension);
 
@@ -290,7 +342,9 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
 
 	if ((rc = uk_9preq_write32(req, fid->fid)) ||
 		(rc = uk_9preq_writestr(req, &name_str)) ||
@@ -301,9 +355,7 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		(rc = uk_9preq_readqid(req, &fid->qid)) ||
 		(rc = uk_9preq_read32(req, &fid->iounit)))
 		goto out;
-
-	uk_pr_debug("RCREATE qid type %u version %u path %lu iounit %u\n",
-			fid->qid.type, fid->qid.version, fid->qid.path,
+	uk_9p_trace_create_end(fid->qid.type, fid->qid.version, fid->qid.path,
 			fid->iounit);
 
 out:
@@ -311,11 +363,16 @@ out:
 	return rc;
 }
 
+UK_TRACEPOINT(uk_9p_trace_remove, "fid %u", uint32_t);
+UK_TRACEPOINT(uk_9p_trace_remove_end, "");
+
 int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
 {
 	struct uk_9preq *req;
 	int rc = 0;
 
+	uk_9p_trace_remove(fid->fid);
+
 	/* The fid is considered invalid even if the remove fails. */
 	fid->was_removed = 1;
 
@@ -323,17 +380,23 @@ int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_pr_debug("TREMOVE fid %u\n", fid->fid);
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
+
 	if ((rc = uk_9preq_write32(req, fid->fid)) ||
 		(rc = send_and_wait_no_zc(dev, req)))
 		goto out;
-	uk_pr_debug("RREMOVE\n");
+	uk_9p_trace_remove_end();
 
 out:
 	uk_9pdev_req_remove(dev, req);
 	return rc;
 }
 
+UK_TRACEPOINT(uk_9p_trace_clunk, "fid %u", uint32_t);
+UK_TRACEPOINT(uk_9p_trace_clunk_end, "");
+
 int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
 {
 	struct uk_9preq *req;
@@ -346,34 +409,41 @@ int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_pr_debug("TCLUNK fid %u\n", fid->fid);
+	uk_9p_trace_clunk(fid->fid);
 	if ((rc = uk_9preq_write32(req, fid->fid)) ||
 		(rc = send_and_wait_no_zc(dev, req)))
 		goto out;
-	uk_pr_debug("RCLUNK\n");
+	uk_9p_trace_clunk_end();
 
 out:
 	uk_9pdev_req_remove(dev, req);
 	return rc;
 }
 
+UK_TRACEPOINT(uk_9p_trace_read, "fid %u offset %lu count %u",
+		uint32_t, uint64_t, uint32_t);
+UK_TRACEPOINT(uk_9p_trace_read_end, "count %u", uint32_t);
+
 int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		uint64_t offset, uint32_t count, char *buf)
 {
 	struct uk_9preq *req;
 	int64_t rc;
 
+	uk_9p_trace_read(fid->fid, offset, count);
+
 	if (fid->iounit != 0)
 		count = MIN(count, fid->iounit);
 	count = MIN(count, dev->msize - 11);
 
-	uk_pr_debug("TREAD fid %u offset %lu count %u\n", fid->fid,
-			offset, count);
-
 	req = uk_9pdev_req_create(dev, UK_9P_TREAD, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
+
 	if ((rc = uk_9preq_write32(req, fid->fid)) ||
 		(rc = uk_9preq_write64(req, offset)) ||
 		(rc = uk_9preq_write32(req, count)) ||
@@ -381,8 +451,7 @@ int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
 				       count, 11)) ||
 		(rc = uk_9preq_read32(req, &count)))
 		goto out;
-
-	uk_pr_debug("RREAD count %u\n", count);
+	uk_9p_trace_read_end(count);
 
 	rc = count;
 
@@ -391,21 +460,28 @@ out:
 	return rc;
 }
 
+UK_TRACEPOINT(uk_9p_trace_write, "fid %u offset %lu count %u",
+		uint32_t, uint64_t, uint32_t);
+UK_TRACEPOINT(uk_9p_trace_write_end, "count %u", uint32_t);
+
 int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		uint64_t offset, uint32_t count, const char *buf)
 {
 	struct uk_9preq *req;
 	int64_t rc;
 
+	uk_9p_trace_write(fid->fid, offset, count);
 	count = MIN(count, fid->iounit);
 	count = MIN(count, dev->msize - 23);
 
-	uk_pr_debug("TWRITE fid %u offset %lu count %u\n", fid->fid,
-			offset, count);
 	req = uk_9pdev_req_create(dev, UK_9P_TWRITE, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
+
 	if ((rc = uk_9preq_write32(req, fid->fid)) ||
 		(rc = uk_9preq_write64(req, offset)) ||
 		(rc = uk_9preq_write32(req, count)) ||
@@ -413,8 +489,7 @@ int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
 				(void *)buf, count, 23)) ||
 		(rc = uk_9preq_read32(req, &count)))
 		goto out;
-
-	uk_pr_debug("RWRITE count %u\n", count);
+	uk_9p_trace_write_end(count);
 
 	rc = count;
 
@@ -423,6 +498,9 @@ out:
 	return rc;
 }
 
+UK_TRACEPOINT(uk_9p_trace_stat, "fid %u", uint32_t);
+UK_TRACEPOINT(uk_9p_trace_stat_end, "");
+
 struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		struct uk_9p_stat *stat)
 {
@@ -430,19 +508,21 @@ struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	int rc = 0;
 	uint16_t dummy;
 
+	uk_9p_trace_stat(fid->fid);
 	req = uk_9pdev_req_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return req;
 
-	uk_pr_debug("TSTAT fid %u\n", fid->fid);
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
 
 	if ((rc = uk_9preq_write32(req, fid->fid)) ||
 		(rc = send_and_wait_no_zc(dev, req)) ||
 		(rc = uk_9preq_read16(req, &dummy)) ||
 		(rc = uk_9preq_readstat(req, stat)))
 		goto out;
-
-	uk_pr_debug("RSTAT\n");
+	uk_9p_trace_stat_end();
 
 	return req;
 
@@ -451,6 +531,9 @@ out:
 	return ERR2PTR(rc);
 }
 
+UK_TRACEPOINT(uk_9p_trace_wstat, "fid %u", uint32_t);
+UK_TRACEPOINT(uk_9p_trace_wstat_end, "");
+
 int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		struct uk_9p_stat *stat)
 {
@@ -458,11 +541,14 @@ int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	int rc = 0;
 	uint16_t *dummy;
 
+	uk_9p_trace_wstat(fid->fid);
 	req = uk_9pdev_req_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_pr_debug("TWSTAT fid %u\n", fid->fid);
+#ifdef UK_9P_INDEPTH_TRACES
+	uk_9p_trace_request_allocated();
+#endif
 
 	if ((rc = uk_9preq_write32(req, fid->fid)))
 		goto out;
@@ -475,8 +561,7 @@ int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 
 	if ((rc = send_and_wait_no_zc(dev, req)))
 		goto out;
-
-	uk_pr_debug("RWSTAT\n");
+	uk_9p_trace_wstat_end();
 
 out:
 	uk_9pdev_req_remove(dev, req);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 02 15:16:18 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 15:16: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 1jUtsI-0004vl-5B; Sat, 02 May 2020 15:16:18 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=Iq85=6Q=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jUtsH-0004vg-K8
 for minios-devel@lists.xen.org; Sat, 02 May 2020 15:16:17 +0000
X-Inumbo-ID: d9866cec-8c87-11ea-9887-bc764e2007e4
Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d9866cec-8c87-11ea-9887-bc764e2007e4;
 Sat, 02 May 2020 15:16:09 +0000 (UTC)
Received: by mail-wm1-x341.google.com with SMTP id g12so3497654wmh.3
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 08:16:09 -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=QnhQJrThw0pOgIjdq3sRyMAFqvaje1Fe/tM7/7ql+aE=;
 b=LxTpCRm/EIoF4LKbBQZZw0br0+50MpnL0lIzLy6pDJ6Q2r9/mHWslDLOVDX4beyptn
 ihUJmAW17CE5WjxdVqgoxV0CCTZknoK9o71FgYqqRMmDuRsYWI+c+FEjEm3Paj+wPgVO
 RET5kZykTNFoGOQXJ4fILm8O+xxrJHiPjN6/tzbgEquunNQXVL0YsRByC6ssu8ii7KIw
 6g6wTiVxOKZ0dJPGtS58UbG112D5QjOaJRj5XrjEeYst1zGPDvGiF1TG3RWgRGghJSJg
 pzErza99qTP0v21g88TaDD9qagJ1yRygFkZGs1a0Fn7FGFtjxBx/d0V6U86FWrC7IZNk
 Vr8A==
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=QnhQJrThw0pOgIjdq3sRyMAFqvaje1Fe/tM7/7ql+aE=;
 b=o6h6RV6XtxeKT9Lal+6oIaX1hWmeQHZqUdN6+fwTjQJD/5PAJOa5OvVIR0HLZ7wvLJ
 Ia22AFV9c8DSYXN219O+mMG7jHvBEr7LW9JqQ6aPPgYl1Cfg/+mYCKAyzAe6S6xh9/rJ
 gSGaDSWBJYJ9D0bnJITU9NLdyD4XG0sjLO1/h2U3umdBzuZHPGxzZtwGDMH9HggjW+R+
 eLfq66L+kDMlwp4nHOvxVuax74ZCpPEuaV5mCVtk+IrRcs+uqenQ/lLVl8UEtdxdw+ik
 de1KwCk58Bn6H1cowaOCXtJyFQ6iHTlCbq7HPsESaOcNKbCpxzkunRswR2sUnVRSmbiv
 oVIg==
X-Gm-Message-State: AGi0PuYusc8SEGy/hUX0dFx3BSM7y9X1WIZB0+RAqsZMTSwwuT4XOKF+
 ArLhw1uHE7W85pMWwZyCWMUllhp/MN4=
X-Google-Smtp-Source: APiQypIslmCV0a5ngq2b1HAPW1t9qCBdvJIa9SKc/2M2UyyyWWtoxfS1idC2TTA+Q3N67uY74lBpMg==
X-Received: by 2002:a1c:9d84:: with SMTP id g126mr4673090wme.184.1588432567834; 
 Sat, 02 May 2020 08:16:07 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id u12sm4793822wmu.25.2020.05.02.08.16.07
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 08:16:07 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 3/7] lib/uk9p: Use fixed-size request buffers
Date: Sat,  2 May 2020 16:13:36 +0100
Message-Id: <20200502151340.92959-4-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200502151340.92959-1-cristb@gmail.com>
References: <20200502151340.92959-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Use fixed-size request buffers instead of dynamically allocating new
receive and transmit buffers for each new request. This reduces the
number of calls to uk_alloc from 3 to 1 per each uk_9pdev_req_create()
call.

Allocating a request is faster by roughly 2.5 microseconds. The
previous patch in this patch series shows a 3.7us delay between read
and request_allocated. The excerpt below shows roughly 1us delay.
This performance benefit is observed at a larger scale as well (in
latency and throughput benchmarks).

Excerpt from the output traces for a read() with in-depth traces:

882362702  uk_9p_trace_read               fid 2 offset 61440 count 4096
882363707  uk_9p_trace_request_allocated
882363736  uk_9p_trace_ready              tag 0
882366471  uk_9p_trace_sent               tag 0
882405347  uk_9p_trace_received           tag 0
882405387  uk_9p_trace_read_end           count 4096

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/9p.c               | 24 ++++++------
 lib/uk9p/9pdev.c            | 11 +++---
 lib/uk9p/9preq.c            | 76 ++++++++-----------------------------
 lib/uk9p/include/uk/9pdev.h |  5 +--
 lib/uk9p/include/uk/9preq.h | 31 +++++++++++++--
 5 files changed, 63 insertions(+), 84 deletions(-)

diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index d6ba3cf..b49ac98 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -99,7 +99,7 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 	uk_9p_trace_version(dev->msize, requested);
 	uk_9p_str_init(&requested_str, requested);
 
-	req = uk_9pdev_req_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TVERSION);
 	if (PTRISERR(req))
 		return req;
 
@@ -154,7 +154,7 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
 
 	uk_9p_trace_attach(fid->fid, afid, uname, aname, n_uname);
 
-	req = uk_9pdev_req_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TATTACH);
 	if (PTRISERR(req)) {
 		uk_9pdev_fid_release(fid);
 		return (void *)req;
@@ -193,7 +193,7 @@ int uk_9p_flush(struct uk_9pdev *dev, uint16_t oldtag)
 
 	uk_9p_trace_flush(oldtag);
 
-	req = uk_9pdev_req_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TFLUSH);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -234,7 +234,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	uk_9p_trace_walk(fid->fid, newfid->fid, name ? name : "<NULL>");
 	nwname = name ? 1 : 0;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TWALK, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TWALK);
 	if (PTRISERR(req)) {
 		rc = PTR2ERR(req);
 		goto out;
@@ -297,7 +297,7 @@ int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
 	int rc = 0;
 
 	uk_9p_trace_open(fid->fid, mode);
-	req = uk_9pdev_req_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TOPEN);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -338,7 +338,7 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	uk_9p_str_init(&name_str, name);
 	uk_9p_str_init(&extension_str, extension);
 
-	req = uk_9pdev_req_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TCREATE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -376,7 +376,7 @@ int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
 	/* The fid is considered invalid even if the remove fails. */
 	fid->was_removed = 1;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TREMOVE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -405,7 +405,7 @@ int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
 	if (fid->was_removed)
 		return 0;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TCLUNK);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -436,7 +436,7 @@ int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		count = MIN(count, fid->iounit);
 	count = MIN(count, dev->msize - 11);
 
-	req = uk_9pdev_req_create(dev, UK_9P_TREAD, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TREAD);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -474,7 +474,7 @@ int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	count = MIN(count, fid->iounit);
 	count = MIN(count, dev->msize - 23);
 
-	req = uk_9pdev_req_create(dev, UK_9P_TWRITE, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TWRITE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -509,7 +509,7 @@ struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	uint16_t dummy;
 
 	uk_9p_trace_stat(fid->fid);
-	req = uk_9pdev_req_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TSTAT);
 	if (PTRISERR(req))
 		return req;
 
@@ -542,7 +542,7 @@ int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	uint16_t *dummy;
 
 	uk_9p_trace_wstat(fid->fid);
-	req = uk_9pdev_req_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
+	req = uk_9pdev_req_create(dev, UK_9P_TWSTAT);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
index 1d7e09b..40a4daa 100644
--- a/lib/uk9p/9pdev.c
+++ b/lib/uk9p/9pdev.c
@@ -288,8 +288,7 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev)
 #endif
 }
 
-struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
-				uint32_t size)
+struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type)
 {
 	struct uk_9preq *req;
 	int rc = 0;
@@ -298,14 +297,16 @@ struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
 
 	UK_ASSERT(dev);
 
-	size = MIN(size, dev->msize);
-
-	req = uk_9preq_alloc(dev->a, size);
+	req = uk_9preq_alloc(dev->a);
 	if (req == NULL) {
 		rc = -ENOMEM;
 		goto out;
 	}
 
+	/* Shouldn't exceed the msize on non-zerocopy buffers, just in case. */
+	req->recv.size = MIN(req->recv.size, dev->msize);
+	req->xmit.size = MIN(req->xmit.size, dev->msize);
+
 	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
 	if (type == UK_9P_TVERSION)
 		tag = UK_9P_NOTAG;
diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
index 997f772..d44e684 100644
--- a/lib/uk9p/9preq.c
+++ b/lib/uk9p/9preq.c
@@ -45,51 +45,28 @@
 #include <uk/wait.h>
 #endif
 
-static int _fcall_alloc(struct uk_alloc *a, struct uk_9preq_fcall *f,
-			uint32_t size)
-{
-	UK_ASSERT(a);
-	UK_ASSERT(f);
-	UK_ASSERT(size > 0);
-
-	f->buf = uk_calloc(a, size, sizeof(char));
-	if (f->buf == NULL)
-		return -ENOMEM;
-
-	f->size = size;
-	f->offset = 0;
-	f->zc_buf = NULL;
-	f->zc_size = 0;
-	f->zc_offset = 0;
-
-	return 0;
-}
-
-static void _fcall_free(struct uk_alloc *a, struct uk_9preq_fcall *f)
-{
-	UK_ASSERT(a);
-	UK_ASSERT(f);
-
-	if (f->buf)
-		uk_free(a, f->buf);
-}
-
-struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a, uint32_t size)
+struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a)
 {
 	struct uk_9preq *req;
-	int rc;
 
 	req = uk_calloc(a, 1, sizeof(*req));
 	if (req == NULL)
-		goto out;
+		return NULL;
 
-	rc = _fcall_alloc(a, &req->xmit, size);
-	if (rc < 0)
-		goto out_free;
+	req->xmit.buf = req->xmit_buf;
+	req->recv.buf = req->recv_buf;
+	req->xmit.size = req->recv.size = UK_9P_BUFSIZE;
+	req->xmit.zc_buf = req->recv.zc_buf = NULL;
+	req->xmit.zc_size = req->recv.zc_size = 0;
+	req->xmit.zc_offset = req->recv.zc_offset = 0;
 
-	rc = _fcall_alloc(a, &req->recv, MAX(size, UK_9P_RERROR_MAXSIZE));
-	if (rc < 0)
-		goto out_free;
+	/*
+	 * Assume the header has already been written.
+	 * The header itself will be written on uk_9preq_ready(), when the
+	 * actual message size is known.
+	 */
+	req->xmit.offset = UK_9P_HEADER_SIZE;
+	req->recv.offset = 0;
 
 	UK_INIT_LIST_HEAD(&req->_list);
 	req->_a = a;
@@ -98,28 +75,7 @@ struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a, uint32_t size)
 	uk_waitq_init(&req->wq);
 #endif
 
-	/*
-	 * Assume the header has already been written.
-	 * The header itself will be written on uk_9preq_ready(), when the
-	 * actual message size is known.
-	 */
-	req->xmit.offset = UK_9P_HEADER_SIZE;
-
 	return req;
-
-out_free:
-	_fcall_free(a, &req->recv);
-	_fcall_free(a, &req->xmit);
-	uk_free(a, req);
-out:
-	return NULL;
-}
-
-static void _req_free(struct uk_9preq *req)
-{
-	_fcall_free(req->_a, &req->recv);
-	_fcall_free(req->_a, &req->xmit);
-	uk_free(req->_a, req);
 }
 
 void uk_9preq_get(struct uk_9preq *req)
@@ -133,7 +89,7 @@ int uk_9preq_put(struct uk_9preq *req)
 
 	last = uk_refcount_release(&req->refcount);
 	if (last)
-		_req_free(req);
+		uk_free(req->_a, req);
 
 	return last;
 }
diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
index 04ff523..1225336 100644
--- a/lib/uk9p/include/uk/9pdev.h
+++ b/lib/uk9p/include/uk/9pdev.h
@@ -114,15 +114,12 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev);
  *   The Unikraft 9P Device.
  * @param type
  *   Transmit type of the request, e.g. Tversion, Tread, and so on.
- * @param size
- *   The maximum size for the receive and send buffers.
  * @return
  *   If not an error pointer, the created request.
  *   Otherwise, the error in creating the request:
  *   - ENOMEM: No memory for the request or no available tags.
  */
-struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
-				uint32_t size);
+struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type);
 
 /**
  * Looks up a request based on the given tag. This is generally used by
diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
index b9713e2..ed883d2 100644
--- a/lib/uk9p/include/uk/9preq.h
+++ b/lib/uk9p/include/uk/9preq.h
@@ -63,6 +63,16 @@ extern "C" {
  */
 #define UK_9P_RERROR_MAXSIZE            141U
 
+/*
+ * The transmit and receive buffer size.
+ *
+ * The buffer size is not expected to exceed 1K: reads and writes are
+ * zero-copy; on-the-wire size of a stat structure should not exceed
+ * 1K -- its base size is 61, along with the lengths for name, uid,
+ * gid, muid and extension strings.
+ */
+#define UK_9P_BUFSIZE			1024U
+
 /**
  * @internal
  *
@@ -125,8 +135,23 @@ enum uk_9preq_state {
  *  referenced anymore. A call to uk_9pdev_req_remove() is mandatory to
  *  correctly free this and remove it from the list of requests managed
  *  by the 9p device.
+ *
+ *  Should fit within one page.
  */
 struct uk_9preq {
+	/*
+	 * Fixed-size buffer for transmit, used for most messages.
+	 * Large messages will always zero-copy from the user-provided
+	 * buffer (on Twrite).
+	 */
+	uint8_t				xmit_buf[UK_9P_BUFSIZE];
+	/*
+	 * Fixed-size buffer for receive, used for most messages.
+	 * Large messages will always zero-copy into the user-provided
+	 * buffer (on Tread).
+	 */
+	uint8_t				recv_buf[UK_9P_BUFSIZE];
+	/* 2 KB offset in the structure here. */
 	/* Transmit fcall. */
 	struct uk_9preq_fcall           xmit;
 	/* Receive fcall. */
@@ -147,6 +172,8 @@ struct uk_9preq {
 #endif
 };
 
+UK_CTASSERT(sizeof(struct uk_9preq) <= __PAGE_SIZE);
+
 /**
  * @internal
  * Allocates a 9p request.
@@ -154,13 +181,11 @@ struct uk_9preq {
  *
  * @param a
  *   Allocator to use.
- * @param size
- *   Minimum size of the receive and transmit buffers.
  * @return
  *   - (==NULL): Out of memory.
  *   - (!=NULL): Successful.
  */
-struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a, uint32_t size);
+struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a);
 
 /**
  * Gets the 9p request, incrementing the reference count.
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 02 15:16:23 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 15:16:23 +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 1jUtsN-0004wq-7v; Sat, 02 May 2020 15:16:23 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=Iq85=6Q=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jUtsM-0004wc-KS
 for minios-devel@lists.xen.org; Sat, 02 May 2020 15:16:22 +0000
X-Inumbo-ID: d911e5b6-8c87-11ea-b9cf-bc764e2007e4
Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d911e5b6-8c87-11ea-b9cf-bc764e2007e4;
 Sat, 02 May 2020 15:16:08 +0000 (UTC)
Received: by mail-wm1-x341.google.com with SMTP id v8so11943630wma.0
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 08:16:08 -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=tuCWVvB0Zqapa/VOpyeYbbbV6Ek4GOdGpWPGm+zCsKE=;
 b=sMnzCtqPrIlsCpDW+xKyUbLwxnz9owCDqGxviGrwhc8Gsw82QpTLvDGoNRMWLUm1gC
 LoKAAfVOhQLhPUvwS6qvyQbNSOXWe6jf9AzuvoiSKcZMbUyzd5roILmsqL6f/0js5PzR
 5nBPROqUgbKhAwQmLYf2nug+WbfmyTeLvizjLdvBM50nPp9kzp6QEfAAyvPsQU7eHYRU
 4mmZJ9tQu6T2ZEGkxyrAozR792Be8PFt99wzLaRK6bNnrAFSerG2vSlUHTn2S+gHpVQa
 aMhD20LP5JwbnE0K5+s6cerCWqs9a5OmVWGQZ4scEDMwOPty5cLm8X5p8HbcgiBtXXrv
 Jvtg==
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=tuCWVvB0Zqapa/VOpyeYbbbV6Ek4GOdGpWPGm+zCsKE=;
 b=nJQogcFphSR8FjjLGQ38f1Yasgt8f0qYJ+hPuPA0+4fno/PW8afdWynKFPEpKz0/Jd
 i/D0T6HyIFTI18T4oNZz830d9mCLglQg+2MJ4TX/XMV7iuAsvpQofM8OMgG1GwkqNw/O
 imc0OYwTZxjW5bSnhySjYFf1iIcH21wa9X4ACKod5hfAkBOlNoF2d0sb7cM9qYOdCTBN
 WRgJTc2HePRJhdL9o64cWY0WyjmWrc3OBmYGaYo3qiVc0rFJ5MODXMtLCwnWmYci7Rpg
 BmGV9IE+Wifzl3iQ4gD4/qmyptjzbBMYdl4aY1tGDml0AlQm3Gsfjj95H41ijwe+cZD+
 1+OA==
X-Gm-Message-State: AGi0PuZrqWK5kasxeltVmC+WBG8EQux7XytaR2usMT682MoVyFtrORbp
 ZUuykvuQ/jWBIzAg2zhikROWOD96Y90=
X-Google-Smtp-Source: APiQypKNjBzFLwtDRx2W6/GxaPmNQry3QE4EyLzOqU+AA6Cb+0hQl+toeQ6Ao4WKYhSlt9cr+gfflg==
X-Received: by 2002:a1c:b757:: with SMTP id h84mr5029440wmf.188.1588432566452; 
 Sat, 02 May 2020 08:16:06 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id u12sm4793822wmu.25.2020.05.02.08.16.05
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 08:16:05 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 1/7] lib/uk9p: Rewrite serialization
Date: Sat,  2 May 2020 16:13:34 +0100
Message-Id: <20200502151340.92959-2-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200502151340.92959-1-cristb@gmail.com>
References: <20200502151340.92959-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch rewrites serialization in a type-safe way: compiler can
issue warnings if the data types don't match.  Previously the types
were hidden behind a va_list and thus unchecked.

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/9pfs/9pfs_vnops.c       |   2 +-
 lib/uk9p/9p.c               | 302 ++++++++++++++++++++--------------
 lib/uk9p/9pdev.c            |  36 -----
 lib/uk9p/9preq.c            | 314 ++----------------------------------
 lib/uk9p/exportsyms.uk      |   7 -
 lib/uk9p/include/uk/9pdev.h |  23 ---
 lib/uk9p/include/uk/9preq.h | 239 ++++++++++++++++++++-------
 7 files changed, 376 insertions(+), 547 deletions(-)

diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
index 5e6a7bb..6d3ece3 100644
--- a/lib/9pfs/9pfs_vnops.c
+++ b/lib/9pfs/9pfs_vnops.c
@@ -409,7 +409,7 @@ again:
 	fake_request.recv.size = fd->readdir_sz;
 	fake_request.recv.offset = fd->readdir_off;
 	fake_request.state = UK_9PREQ_RECEIVED;
-	rc = uk_9preq_deserialize(&fake_request, "S", &stat);
+	rc = uk_9preq_readstat(&fake_request, &stat);
 
 	if (rc == -ENOBUFS) {
 		/*
diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index eb4c2dc..638555b 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -40,28 +40,49 @@
 #include <uk/9preq.h>
 #include <uk/9pfid.h>
 
+static inline int send_and_wait_zc(struct uk_9pdev *dev, struct uk_9preq *req,
+		enum uk_9preq_zcdir zc_dir, void *zc_buf, uint32_t zc_size,
+		uint32_t zc_offset)
+{
+	int rc;
+
+	if ((rc = uk_9preq_ready(req, zc_dir, zc_buf, zc_size, zc_offset)) ||
+		(rc = uk_9pdev_request(dev, req)) ||
+		(rc = uk_9preq_waitreply(req)))
+		return rc;
+
+	return 0;
+}
+
+static inline int send_and_wait_no_zc(struct uk_9pdev *dev,
+		struct uk_9preq *req)
+{
+	return send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
+}
+
 struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 		const char *requested, struct uk_9p_str *received)
 {
 	struct uk_9p_str requested_str;
 	struct uk_9preq *req;
-	int rc;
+	int rc = 0;
 	uint32_t new_msize;
 
 	uk_9p_str_init(&requested_str, requested);
 
-	uk_pr_debug("TVERSION msize %u version %s\n",
-			dev->msize, requested);
-
-	req = uk_9pdev_call(dev, UK_9P_TVERSION, __PAGE_SIZE, "ds",
-			dev->msize, &requested_str);
+	req = uk_9pdev_req_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return req;
 
-	rc = uk_9preq_deserialize(req, "ds", &new_msize, received);
+	uk_pr_debug("TVERSION msize %u version %s\n",
+			dev->msize, requested);
 
-	if (rc)
-		return ERR2PTR(rc);
+	if ((rc = uk_9preq_write32(req, dev->msize)) ||
+		(rc = uk_9preq_writestr(req, &requested_str)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_read32(req, &new_msize)) ||
+		(rc = uk_9preq_readstr(req, received)))
+		goto free;
 
 	uk_pr_debug("RVERSION msize %u version %.*s\n", new_msize,
 			received->size, received->data);
@@ -76,6 +97,10 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 		uk_pr_debug("Invalid new message size.\n");
 
 	return req;
+
+free:
+	uk_9pdev_req_remove(dev, req);
+	return ERR2PTR(rc);
 }
 
 struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
@@ -94,43 +119,56 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
 	if (PTRISERR(fid))
 		return fid;
 
-	uk_pr_debug("TATTACH fid %u afid %u uname %s aname %s n_uname %u\n",
-			fid->fid, afid, uname, aname, n_uname);
-
-	req = uk_9pdev_call(dev, UK_9P_TATTACH, __PAGE_SIZE, "ddssd",
-			fid->fid, afid, &uname_str, &aname_str, n_uname);
+	req = uk_9pdev_req_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
 	if (PTRISERR(req)) {
 		uk_9pdev_fid_release(fid);
 		return (void *)req;
 	}
 
-	rc = uk_9preq_deserialize(req, "Q", &fid->qid);
+	uk_pr_debug("TATTACH fid %u afid %u uname %s aname %s n_uname %u\n",
+			fid->fid, afid, uname, aname, n_uname);
+
+	rc = 0;
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write32(req, afid)) ||
+		(rc = uk_9preq_writestr(req, &uname_str)) ||
+		(rc = uk_9preq_writestr(req, &aname_str)) ||
+		(rc = uk_9preq_write32(req, n_uname)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_readqid(req, &fid->qid)))
+		goto free;
+
 	uk_9pdev_req_remove(dev, req);
 
 	uk_pr_debug("RATTACH qid type %u version %u path %lu\n",
 			fid->qid.type, fid->qid.version, fid->qid.path);
 
-	if (rc < 0) {
-		uk_9pdev_fid_release(fid);
-		return ERR2PTR(rc);
-	}
-
 	return fid;
+
+free:
+	uk_9pdev_fid_release(fid);
+	uk_9pdev_req_remove(dev, req);
+	return ERR2PTR(rc);
 }
 
 int uk_9p_flush(struct uk_9pdev *dev, uint16_t oldtag)
 {
 	struct uk_9preq *req;
+	int rc = 0;
 
-	uk_pr_debug("TFLUSH oldtag %u\n", oldtag);
-	req = uk_9pdev_call(dev, UK_9P_TFLUSH, __PAGE_SIZE, "w", oldtag);
+	req = uk_9pdev_req_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
+	uk_pr_debug("TFLUSH oldtag %u\n", oldtag);
+	if ((rc = uk_9preq_write16(req, oldtag)) ||
+		(rc = send_and_wait_no_zc(dev, req)))
+		goto out;
 	uk_pr_debug("RFLUSH\n");
-	uk_9pdev_req_remove(dev, req);
 
-	return 0;
+out:
+	uk_9pdev_req_remove(dev, req);
+	return rc;
 }
 
 struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
@@ -141,7 +179,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	struct uk_9p_str name_str;
 	uint16_t nwqid;
 	uint16_t nwname;
-	int rc;
+	int rc = 0;
 
 	uk_9p_str_init(&name_str, name);
 
@@ -151,51 +189,56 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 
 	nwname = name ? 1 : 0;
 
+	req = uk_9pdev_req_create(dev, UK_9P_TWALK, __PAGE_SIZE);
+	if (PTRISERR(req)) {
+		rc = PTR2ERR(req);
+		goto out;
+	}
+
 	if (name) {
 		uk_pr_debug("TWALK fid %u newfid %u nwname %d name %s\n",
 				fid->fid, newfid->fid, nwname, name);
-		req = uk_9pdev_call(dev, UK_9P_TWALK, __PAGE_SIZE, "ddws",
-				fid->fid, newfid->fid, nwname, &name_str);
+		if ((rc = uk_9preq_write32(req, fid->fid)) ||
+			(rc = uk_9preq_write32(req, newfid->fid)) ||
+			(rc = uk_9preq_write16(req, nwname)) ||
+			(rc = uk_9preq_writestr(req, &name_str)))
+			goto out;
 	} else {
 		uk_pr_debug("TWALK fid %u newfid %u nwname %d\n",
 				fid->fid, newfid->fid, nwname);
-		req = uk_9pdev_call(dev, UK_9P_TWALK, __PAGE_SIZE, "ddw",
-				fid->fid, newfid->fid, nwname);
+		if ((rc = uk_9preq_write32(req, fid->fid)) ||
+			(rc = uk_9preq_write32(req, newfid->fid)) ||
+			(rc = uk_9preq_write16(req, nwname)))
+			goto out;
 	}
 
-	if (PTRISERR(req)) {
+	if ((rc = send_and_wait_no_zc(dev, req))) {
 		/*
 		 * Don't clunk if request has finished with error, as the fid
 		 * is invalid.
 		 */
 		newfid->was_removed = 1;
-		rc = PTR2ERR(req);
 		goto out;
 	}
 
-	rc = uk_9preq_deserialize(req, "w", &nwqid);
-	if (rc < 0)
-		goto out_req;
+	if ((rc = uk_9preq_read16(req, &nwqid)))
+		goto out;
 
 	uk_pr_debug("RWALK nwqid %u\n", nwqid);
 
 	if (nwqid != nwname) {
 		rc = -ENOENT;
-		goto out_req;
+		goto out;
 	}
 
-
 	if (nwname) {
-		rc = uk_9preq_deserialize(req, "Q", &newfid->qid);
-		if (rc < 0)
-			goto out_req;
+		if ((rc = uk_9preq_readqid(req, &newfid->qid)))
+			goto out;
 	} else
 		newfid->qid = fid->qid;
 
-	rc = 0;
-out_req:
-	uk_9pdev_req_remove(dev, req);
 out:
+	uk_9pdev_req_remove(dev, req);
 	if (rc) {
 		uk_9pdev_fid_release(newfid);
 		return ERR2PTR(rc);
@@ -207,22 +250,27 @@ out:
 int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
 {
 	struct uk_9preq *req;
-	int rc;
-
-	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
+	int rc = 0;
 
-	req = uk_9pdev_call(dev, UK_9P_TOPEN, __PAGE_SIZE, "db",
-			fid->fid, mode);
+	req = uk_9pdev_req_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	rc = uk_9preq_deserialize(req, "Qd", &fid->qid, &fid->iounit);
-	uk_9pdev_req_remove(dev, req);
+	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
+
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write8(req, mode)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_readqid(req, &fid->qid)) ||
+		(rc = uk_9preq_read32(req, &fid->iounit)))
+		goto out;
 
 	uk_pr_debug("ROPEN qid type %u version %u path %lu iounit %u\n",
 			fid->qid.type, fid->qid.version, fid->qid.path,
 			fid->iounit);
 
+out:
+	uk_9pdev_req_remove(dev, req);
 	return rc;
 }
 
@@ -233,63 +281,80 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	struct uk_9preq *req;
 	struct uk_9p_str name_str;
 	struct uk_9p_str extension_str;
-	int rc;
+	int rc = 0;
 
 	uk_9p_str_init(&name_str, name);
 	uk_9p_str_init(&extension_str, extension);
 
-	uk_pr_debug("TCREATE fid %u name %s perm %u mode %u ext %s\n",
-			fid->fid, name, perm, mode, extension);
-
-	req = uk_9pdev_call(dev, UK_9P_TCREATE, __PAGE_SIZE, "dsdbs",
-			fid->fid, &name_str, perm, mode, &extension_str);
+	req = uk_9pdev_req_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	rc = uk_9preq_deserialize(req, "Qd", &fid->qid, &fid->iounit);
-	uk_9pdev_req_remove(dev, req);
+	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
+
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_writestr(req, &name_str)) ||
+		(rc = uk_9preq_write32(req, perm)) ||
+		(rc = uk_9preq_write8(req, mode)) ||
+		(rc = uk_9preq_writestr(req, &extension_str)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_readqid(req, &fid->qid)) ||
+		(rc = uk_9preq_read32(req, &fid->iounit)))
+		goto out;
 
 	uk_pr_debug("RCREATE qid type %u version %u path %lu iounit %u\n",
 			fid->qid.type, fid->qid.version, fid->qid.path,
 			fid->iounit);
 
+out:
+	uk_9pdev_req_remove(dev, req);
 	return rc;
 }
 
 int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
 {
 	struct uk_9preq *req;
+	int rc = 0;
 
 	/* The fid is considered invalid even if the remove fails. */
 	fid->was_removed = 1;
 
-	uk_pr_debug("TREMOVE fid %u\n", fid->fid);
-	req = uk_9pdev_call(dev, UK_9P_TREMOVE, __PAGE_SIZE, "d", fid->fid);
+	req = uk_9pdev_req_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_9pdev_req_remove(dev, req);
+	uk_pr_debug("TREMOVE fid %u\n", fid->fid);
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = send_and_wait_no_zc(dev, req)))
+		goto out;
 	uk_pr_debug("RREMOVE\n");
 
-	return 0;
+out:
+	uk_9pdev_req_remove(dev, req);
+	return rc;
 }
 
 int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
 {
 	struct uk_9preq *req;
+	int rc = 0;
 
 	if (fid->was_removed)
 		return 0;
 
-	uk_pr_debug("TCLUNK fid %u\n", fid->fid);
-	req = uk_9pdev_call(dev, UK_9P_TCLUNK, __PAGE_SIZE, "d", fid->fid);
+	req = uk_9pdev_req_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_9pdev_req_remove(dev, req);
+	uk_pr_debug("TCLUNK fid %u\n", fid->fid);
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = send_and_wait_no_zc(dev, req)))
+		goto out;
 	uk_pr_debug("RCLUNK\n");
 
-	return 0;
+out:
+	uk_9pdev_req_remove(dev, req);
+	return rc;
 }
 
 int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
@@ -309,24 +374,12 @@ int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	rc = uk_9preq_serialize(req, "dqd", fid->fid, offset, count);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_READ, buf, count, 11);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9pdev_request(dev, req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_waitreply(req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_deserialize(req, "d", &count);
-	if (rc < 0)
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write64(req, offset)) ||
+		(rc = uk_9preq_write32(req, count)) ||
+		(rc = send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_READ, buf,
+				       count, 11)) ||
+		(rc = uk_9preq_read32(req, &count)))
 		goto out;
 
 	uk_pr_debug("RREAD count %u\n", count);
@@ -353,24 +406,12 @@ int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	rc = uk_9preq_serialize(req, "dqd", fid->fid, offset, count);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_WRITE, (void *)buf, count, 23);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9pdev_request(dev, req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_waitreply(req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_deserialize(req, "d", &count);
-	if (rc < 0)
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write64(req, offset)) ||
+		(rc = uk_9preq_write32(req, count)) ||
+		(rc = send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_WRITE,
+				(void *)buf, count, 23)) ||
+		(rc = uk_9preq_read32(req, &count)))
 		goto out;
 
 	uk_pr_debug("RWRITE count %u\n", count);
@@ -386,45 +427,58 @@ struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		struct uk_9p_stat *stat)
 {
 	struct uk_9preq *req;
-	int rc;
+	int rc = 0;
 	uint16_t dummy;
 
-	uk_pr_debug("TSTAT fid %u\n", fid->fid);
-	req = uk_9pdev_call(dev, UK_9P_TSTAT, __PAGE_SIZE, "d", fid->fid);
+	req = uk_9pdev_req_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return req;
 
-	rc = uk_9preq_deserialize(req, "wS", &dummy, stat);
-	if (rc)
-		return ERR2PTR(rc);
+	uk_pr_debug("TSTAT fid %u\n", fid->fid);
+
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_read16(req, &dummy)) ||
+		(rc = uk_9preq_readstat(req, stat)))
+		goto out;
+
 	uk_pr_debug("RSTAT\n");
 
 	return req;
+
+out:
+	uk_9pdev_req_remove(dev, req);
+	return ERR2PTR(rc);
 }
 
 int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		struct uk_9p_stat *stat)
 {
 	struct uk_9preq *req;
+	int rc = 0;
+	uint16_t *dummy;
 
-	/*
-	 * The packed size of stat is 61 bytes + the size occupied by the
-	 * strings.
-	 */
-	stat->size = 61;
-	stat->size += stat->name.size;
-	stat->size += stat->uid.size;
-	stat->size += stat->gid.size;
-	stat->size += stat->muid.size;
-	stat->size += stat->extension.size;
-
-	uk_pr_debug("TWSTAT fid %u\n", fid->fid);
-	req = uk_9pdev_call(dev, UK_9P_TWSTAT, __PAGE_SIZE, "dwS", fid->fid,
-			stat->size + 2, stat);
+	req = uk_9pdev_req_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
-	uk_9pdev_req_remove(dev, req);
-	uk_pr_debug("RWSTAT");
 
-	return 0;
+	uk_pr_debug("TWSTAT fid %u\n", fid->fid);
+
+	if ((rc = uk_9preq_write32(req, fid->fid)))
+		goto out;
+
+	dummy = (uint16_t *)(req->xmit.buf + req->xmit.offset);
+	if ((rc = uk_9preq_write16(req, 0)) ||
+		(rc = uk_9preq_writestat(req, stat)))
+		goto out;
+	*dummy = stat->size + 2;
+
+	if ((rc = send_and_wait_no_zc(dev, req)))
+		goto out;
+
+	uk_pr_debug("RWSTAT\n");
+
+out:
+	uk_9pdev_req_remove(dev, req);
+	return rc;
 }
diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
index 14ea7ca..1d7e09b 100644
--- a/lib/uk9p/9pdev.c
+++ b/lib/uk9p/9pdev.c
@@ -288,42 +288,6 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev)
 #endif
 }
 
-struct uk_9preq *uk_9pdev_call(struct uk_9pdev *dev, uint8_t type,
-			uint32_t size, const char *fmt, ...)
-{
-	struct uk_9preq *req;
-	va_list vl;
-	int rc;
-
-	req = uk_9pdev_req_create(dev, type, size);
-	if (PTRISERR(req))
-		return req;
-
-	va_start(vl, fmt);
-	rc = uk_9preq_vserialize(req, fmt, vl);
-	va_end(vl);
-
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9pdev_request(dev, req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_waitreply(req);
-	if (rc < 0)
-		goto out;
-
-	return req;
-out:
-	uk_9pdev_req_remove(dev, req);
-	return ERR2PTR(rc);
-}
-
 struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
 				uint32_t size)
 {
diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
index 0fc4b1e..997f772 100644
--- a/lib/uk9p/9preq.c
+++ b/lib/uk9p/9preq.c
@@ -138,293 +138,6 @@ int uk_9preq_put(struct uk_9preq *req)
 	return last;
 }
 
-static int _fcall_write(struct uk_9preq_fcall *fcall, const void *buf,
-		uint32_t size)
-{
-	if (fcall->offset + size > fcall->size)
-		return -ENOBUFS;
-
-	memcpy((char *)fcall->buf + fcall->offset, buf, size);
-	fcall->offset += size;
-	return 0;
-}
-
-static int _fcall_serialize(struct uk_9preq_fcall *f, const char *fmt, ...);
-
-static int _fcall_vserialize(struct uk_9preq_fcall *fcall, const char *fmt,
-			va_list vl)
-{
-	int rc = 0;
-
-	while (*fmt) {
-		switch (*fmt) {
-		case 'b': {
-			uint8_t x;
-
-			x = va_arg(vl, unsigned int);
-			rc = _fcall_write(fcall, &x, sizeof(x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'w': {
-			uint16_t x;
-
-			x = va_arg(vl, unsigned int);
-			rc = _fcall_write(fcall, &x, sizeof(x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'd': {
-			uint32_t x;
-
-			x = va_arg(vl, uint32_t);
-			rc = _fcall_write(fcall, &x, sizeof(x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'q': {
-			uint64_t x;
-
-			x = va_arg(vl, uint64_t);
-			rc = _fcall_write(fcall, &x, sizeof(x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 's': {
-			struct uk_9p_str *p;
-
-			p = va_arg(vl, struct uk_9p_str *);
-			rc = _fcall_write(fcall, &p->size, sizeof(p->size));
-			if (rc < 0)
-				goto out;
-			rc = _fcall_write(fcall, p->data, p->size);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'Q': {
-			struct uk_9p_qid *p;
-
-			p = va_arg(vl, struct uk_9p_qid *);
-			rc = _fcall_serialize(fcall, "bdq", p->type,
-					p->version, p->path);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'S': {
-			struct uk_9p_stat *p;
-
-			p = va_arg(vl, struct uk_9p_stat *);
-			rc = _fcall_serialize(fcall, "wwdQdddqsssssddd",
-					p->size, p->type, p->dev, &p->qid,
-					p->mode, p->atime, p->mtime, p->length,
-					&p->name, &p->uid, &p->gid, &p->muid,
-					&p->extension, p->n_uid, p->n_gid,
-					p->n_muid);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		default:
-			rc = -EINVAL;
-			goto out;
-		}
-
-		fmt++;
-	}
-
-out:
-	return rc;
-}
-
-static int _fcall_serialize(struct uk_9preq_fcall *f, const char *fmt, ...)
-{
-	va_list vl;
-	int rc;
-
-	va_start(vl, fmt);
-	rc = _fcall_vserialize(f, fmt, vl);
-	va_end(vl);
-
-	return rc;
-}
-
-int uk_9preq_vserialize(struct uk_9preq *req, const char *fmt, va_list vl)
-{
-	int rc;
-
-	UK_ASSERT(req);
-	UK_ASSERT(UK_READ_ONCE(req->state) == UK_9PREQ_INITIALIZED);
-	rc = _fcall_vserialize(&req->xmit, fmt, vl);
-
-	return rc;
-}
-
-int uk_9preq_serialize(struct uk_9preq *req, const char *fmt, ...)
-{
-	va_list vl;
-	int rc;
-
-	va_start(vl, fmt);
-	rc = uk_9preq_vserialize(req, fmt, vl);
-	va_end(vl);
-
-	return rc;
-}
-
-static int _fcall_read(struct uk_9preq_fcall *fcall, void *buf, uint32_t size)
-{
-	if (fcall->offset + size > fcall->size)
-		return -ENOBUFS;
-
-	memcpy(buf, (char *)fcall->buf + fcall->offset, size);
-	fcall->offset += size;
-	return 0;
-}
-
-static int _fcall_deserialize(struct uk_9preq_fcall *f, const char *fmt, ...);
-
-static int _fcall_vdeserialize(struct uk_9preq_fcall *fcall,
-			      const char *fmt,
-			      va_list vl)
-{
-	int rc = 0;
-
-	while (*fmt) {
-		switch (*fmt) {
-		case 'b': {
-			uint8_t *x;
-
-			x = va_arg(vl, uint8_t *);
-			rc = _fcall_read(fcall, x, sizeof(*x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'w': {
-			uint16_t *x;
-
-			x = va_arg(vl, uint16_t *);
-			rc = _fcall_read(fcall, x, sizeof(*x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'd': {
-			uint32_t *x;
-
-			x = va_arg(vl, uint32_t *);
-			rc = _fcall_read(fcall, x, sizeof(*x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'q': {
-			uint64_t *x;
-
-			x = va_arg(vl, uint64_t *);
-			rc = _fcall_read(fcall, x, sizeof(*x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 's': {
-			struct uk_9p_str *p;
-
-			p = va_arg(vl, struct uk_9p_str *);
-			rc = _fcall_read(fcall, &p->size, sizeof(p->size));
-			if (rc < 0)
-				goto out;
-			p->data = (char *)fcall->buf + fcall->offset;
-			fcall->offset += p->size;
-			break;
-		}
-		case 'Q': {
-			struct uk_9p_qid *p;
-
-			p = va_arg(vl, struct uk_9p_qid *);
-			rc = _fcall_deserialize(fcall, "bdq", &p->type,
-					&p->version, &p->path);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'S': {
-			struct uk_9p_stat *p;
-
-			p = va_arg(vl, struct uk_9p_stat *);
-			rc = _fcall_deserialize(fcall, "wwdQdddqsssssddd",
-					&p->size, &p->type, &p->dev, &p->qid,
-					&p->mode, &p->atime, &p->mtime,
-					&p->length, &p->name, &p->uid, &p->gid,
-					&p->muid, &p->extension, &p->n_uid,
-					&p->n_gid, &p->n_muid);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		default:
-			rc = -EINVAL;
-			goto out;
-		}
-
-		fmt++;
-	}
-
-out:
-	return rc;
-}
-
-static int _fcall_deserialize(struct uk_9preq_fcall *f, const char *fmt, ...)
-{
-	va_list vl;
-	int rc;
-
-	va_start(vl, fmt);
-	rc = _fcall_vdeserialize(f, fmt, vl);
-	va_end(vl);
-
-	return rc;
-}
-
-int uk_9preq_vdeserialize(struct uk_9preq *req, const char *fmt, va_list vl)
-{
-	int rc;
-
-	UK_ASSERT(req);
-	UK_ASSERT(UK_READ_ONCE(req->state) == UK_9PREQ_RECEIVED);
-	rc = _fcall_vdeserialize(&req->recv, fmt, vl);
-
-	return rc;
-}
-
-int uk_9preq_deserialize(struct uk_9preq *req, const char *fmt, ...)
-{
-	va_list vl;
-	int rc;
-
-	va_start(vl, fmt);
-	rc = uk_9preq_vdeserialize(req, fmt, vl);
-	va_end(vl);
-
-	return rc;
-}
-
-int uk_9preq_copy_to(struct uk_9preq *req, void *buf, uint32_t size)
-{
-	return _fcall_read(&req->recv, buf, size);
-}
-
-int uk_9preq_copy_from(struct uk_9preq *req, const void *buf, uint32_t size)
-{
-	return _fcall_write(&req->xmit, buf, size);
-}
-
 int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
 		void *zc_buf, uint32_t zc_size, uint32_t zc_offset)
 {
@@ -434,10 +147,8 @@ int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
 
 	UK_ASSERT(req);
 
-	if (UK_READ_ONCE(req->state) != UK_9PREQ_INITIALIZED) {
-		rc = -EIO;
-		goto out;
-	}
+	if (UK_READ_ONCE(req->state) != UK_9PREQ_INITIALIZED)
+		return -EIO;
 
 	/* Save current offset as the size of the message. */
 	total_size = req->xmit.offset;
@@ -448,10 +159,10 @@ int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
 
 	/* Serialize the header. */
 	req->xmit.offset = 0;
-	rc = uk_9preq_serialize(req, "dbw", total_size_with_zc, req->xmit.type,
-			req->tag);
-	if (rc < 0)
-		goto out;
+	if ((rc = uk_9preq_write32(req, total_size_with_zc)) < 0 ||
+		(rc = uk_9preq_write8(req, req->xmit.type)) < 0 ||
+		(rc = uk_9preq_write16(req, req->tag)) < 0)
+		return rc;
 
 	/* Reset offset and size to sane values. */
 	req->xmit.offset = 0;
@@ -474,8 +185,7 @@ int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
 	/* Update the state. */
 	UK_WRITE_ONCE(req->state, UK_9PREQ_READY);
 
-out:
-	return rc;
+	return 0;
 }
 
 int uk_9preq_receive_cb(struct uk_9preq *req, uint32_t recv_size)
@@ -495,8 +205,10 @@ int uk_9preq_receive_cb(struct uk_9preq *req, uint32_t recv_size)
 	/* Deserialize the header into request fields. */
 	req->recv.offset = 0;
 	req->recv.size = recv_size;
-	rc = _fcall_deserialize(&req->recv, "dbw", &size,
-			&req->recv.type, &tag);
+	if ((rc = uk_9preq_read32(req, &size)) < 0 ||
+		(rc = uk_9preq_read8(req, &req->recv.type)) < 0 ||
+		(rc = uk_9preq_read16(req, &tag)) < 0)
+		return rc;
 
 	/* Check sanity of deserialized values. */
 	if (rc < 0)
@@ -557,8 +269,8 @@ int uk_9preq_error(struct uk_9preq *req)
 	 */
 	UK_BUGON(req->recv.offset != UK_9P_HEADER_SIZE);
 
-	rc = uk_9preq_deserialize(req, "sd", &error, &errcode);
-	if (rc < 0)
+	if ((rc = uk_9preq_readstr(req, &error)) < 0 ||
+		(rc = uk_9preq_read32(req, &errcode)) < 0)
 		return rc;
 
 	uk_pr_debug("RERROR %.*s %d\n", error.size, error.data, errcode);
diff --git a/lib/uk9p/exportsyms.uk b/lib/uk9p/exportsyms.uk
index aae9e8a..7f8e7dd 100644
--- a/lib/uk9p/exportsyms.uk
+++ b/lib/uk9p/exportsyms.uk
@@ -5,12 +5,6 @@ uk_9pdev_trans_set_default
 
 uk_9preq_get
 uk_9preq_put
-uk_9preq_vserialize
-uk_9preq_serialize
-uk_9preq_vdeserialize
-uk_9preq_deserialize
-uk_9preq_copy_to
-uk_9preq_copy_from
 uk_9preq_receive_cb
 uk_9preq_waitreply
 uk_9preq_error
@@ -19,7 +13,6 @@ uk_9pdev_connect
 uk_9pdev_disconnect
 uk_9pdev_request
 uk_9pdev_xmit_notify
-uk_9pdev_call
 uk_9pdev_set_msize
 uk_9pdev_get_msize
 
diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
index 139498f..04ff523 100644
--- a/lib/uk9p/include/uk/9pdev.h
+++ b/lib/uk9p/include/uk/9pdev.h
@@ -107,29 +107,6 @@ int uk_9pdev_request(struct uk_9pdev *dev, struct uk_9preq *req);
  */
 void uk_9pdev_xmit_notify(struct uk_9pdev *dev);
 
-/**
- * Creates and sends 9P request to the given 9P device, serializing it with
- * the given arguments. This function acts as a shorthand for the explicit
- * calls to req_create(), serialize(), ready(), request(), waitreply().
- *
- * @param dev
- *   The Unikraft 9P Device.
- * @param type
- *   Transmit type of the request, e.g. Tversion, Tread, and so on.
- * @param size
- *   The maximum size for the receive and send buffers.
- * @param fmt
- *   The format of the data to be serialized, in the way uk_9preq_serialize()
- *   expects it.
- * @param ...
- *   The arguments to be serialized.
- * @return
- *   - (!PTRISERR): The 9p request in the UK_9PREQ_RECEIVED state.
- *   - PTRISERR: The error code with which any of the steps failed.
- */
-struct uk_9preq *uk_9pdev_call(struct uk_9pdev *dev, uint8_t type,
-			uint32_t size, const char *fmt, ...);
-
 /**
  * Create a new request, automatically allocating its tag, based on its type.
  *
diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
index ee4d2af..b9713e2 100644
--- a/lib/uk9p/include/uk/9preq.h
+++ b/lib/uk9p/include/uk/9preq.h
@@ -41,6 +41,7 @@
 #include <uk/essentials.h>
 #include <uk/list.h>
 #include <uk/refcount.h>
+#include <uk/9p_core.h>
 #if CONFIG_LIBUKSCHED
 #include <uk/wait_types.h>
 #endif
@@ -181,61 +182,6 @@ void uk_9preq_get(struct uk_9preq *req);
  */
 int uk_9preq_put(struct uk_9preq *req);
 
-/*
- * The following family of serialization and deserialization functions work
- * by employing a printf-like formatting mechanism for data types supported by
- * the 9p protocol:
- * - 'b': byte (uint8_t)
- * - 'w': word (uint16_t)
- * - 'd': double-word (uint32_t)
- * - 'q': quad-word (uint64_t)
- * - 's': uk_9p_str *
- * - 'S': uk_9p_stat *
- *
- * Similarly to vprintf(), the vserialize() and vdeserialize() functions take
- * a va_list instead of a variable number of arguments.
- *
- * Possible return values:
- * - 0: Operation successful.
- * - (-EINVAL): Invalid format specifier.
- * - (-ENOBUFS): End of buffer reached.
- */
-
-int uk_9preq_vserialize(struct uk_9preq *req, const char *fmt, va_list vl);
-int uk_9preq_serialize(struct uk_9preq *req, const char *fmt, ...);
-int uk_9preq_vdeserialize(struct uk_9preq *req, const char *fmt, va_list vl);
-int uk_9preq_deserialize(struct uk_9preq *req, const char *fmt, ...);
-
-/**
- * Copies raw data from the request receive buffer to the provided buffer.
- *
- * @param req
- *   Reference to the 9p request.
- * @param buf
- *   Destination buffer.
- * @param size
- *   Amount to copy.
- * Possible return values:
- * - 0: Operation successful.
- * - (-ENOBUFS): End of buffer reached.
- */
-int uk_9preq_copy_to(struct uk_9preq *req, void *buf, uint32_t size);
-
-/**
- * Copies raw data from the provided buffer to the request transmission buffer.
- *
- * @param req
- *   Reference to the 9p request.
- * @param buf
- *   Source buffer.
- * @param size
- *   Amount to copy.
- * Possible return values:
- * - 0: Operation successful.
- * - (-ENOBUFS): End of buffer reached.
- */
-int uk_9preq_copy_from(struct uk_9preq *req, const void *buf, uint32_t size);
-
 /**
  * Marks the given request as being ready, transitioning between states
  * INITIALIZED and READY.
@@ -293,6 +239,189 @@ int uk_9preq_waitreply(struct uk_9preq *req);
  */
 int uk_9preq_error(struct uk_9preq *req);
 
+/*
+ * The following family of serialization and deserialization functions
+ * are used for writing the 'base' types the 9p protocol supports.
+ *
+ * These are defined in the header for better performance by not necessarily
+ * incurring a function call penalty if called from outside uk9p.
+ *
+ * Provided functions:
+ * - uk_9preq_{read,write}buf
+ * - uk_9preq_{read,write}8
+ * - uk_9preq_{read,write}16
+ * - uk_9preq_{read,write}32
+ * - uk_9preq_{read,write}64
+ * - uk_9preq_{read,write}qid
+ * - uk_9preq_{read,write}str
+ * - uk_9preq_{read,write}stat
+ *
+ * For qid, str and stat, read and write always take a pointer.
+ * For all other types, write takes the argument by value.
+ *
+ * Possible return values:
+ * - 0: Operation successful.
+ * - (-ENOBUFS): End of buffer reached.
+ */
+
+static inline int uk_9preq_writebuf(struct uk_9preq *req, const void *buf,
+		uint32_t size)
+{
+	if (req->xmit.offset + size > req->xmit.size)
+		return -ENOBUFS;
+
+	memcpy((char *)req->xmit.buf + req->xmit.offset, buf, size);
+	req->xmit.offset += size;
+	return 0;
+}
+
+static inline int uk_9preq_readbuf(struct uk_9preq *req, void *buf,
+		uint32_t size)
+{
+	if (req->recv.offset + size > req->recv.size)
+		return -ENOBUFS;
+
+	memcpy(buf, (char *)req->recv.buf + req->recv.offset, size);
+	req->recv.offset += size;
+	return 0;
+}
+
+#define _UK_9PREQ_DEFINE_WRITE_FN(name, ctype) \
+static inline int uk_9preq_##name(struct uk_9preq *req, ctype val) \
+{ \
+	return uk_9preq_writebuf(req, &val, sizeof(val)); \
+}
+
+_UK_9PREQ_DEFINE_WRITE_FN(write8, uint8_t)
+_UK_9PREQ_DEFINE_WRITE_FN(write16, uint16_t)
+_UK_9PREQ_DEFINE_WRITE_FN(write32, uint32_t)
+_UK_9PREQ_DEFINE_WRITE_FN(write64, uint64_t)
+
+#undef _UK_9PREQ_DEFINE_WRITE_FN
+
+static inline int uk_9preq_writeqid(struct uk_9preq *req, struct uk_9p_qid *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_write8(req, val->type)) ||
+		(rc = uk_9preq_write32(req, val->version)) ||
+		(rc = uk_9preq_write64(req, val->path)))
+		return rc;
+
+	return 0;
+}
+
+static inline int uk_9preq_writestr(struct uk_9preq *req, struct uk_9p_str *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_write16(req, val->size)) ||
+		(rc = uk_9preq_writebuf(req, val->data, val->size)))
+		return rc;
+
+	return 0;
+}
+
+static inline int uk_9preq_writestat(struct uk_9preq *req,
+		struct uk_9p_stat *val)
+{
+	int rc;
+
+	val->size = 61;
+	val->size += val->name.size;
+	val->size += val->uid.size;
+	val->size += val->gid.size;
+	val->size += val->muid.size;
+	val->size += val->extension.size;
+
+	if ((rc = uk_9preq_write16(req, val->size)) ||
+		(rc = uk_9preq_write16(req, val->type)) ||
+		(rc = uk_9preq_write32(req, val->dev)) ||
+		(rc = uk_9preq_writeqid(req, &val->qid)) ||
+		(rc = uk_9preq_write32(req, val->mode)) ||
+		(rc = uk_9preq_write32(req, val->atime)) ||
+		(rc = uk_9preq_write32(req, val->mtime)) ||
+		(rc = uk_9preq_write64(req, val->length)) ||
+		(rc = uk_9preq_writestr(req, &val->name)) ||
+		(rc = uk_9preq_writestr(req, &val->uid)) ||
+		(rc = uk_9preq_writestr(req, &val->gid)) ||
+		(rc = uk_9preq_writestr(req, &val->muid)) ||
+		(rc = uk_9preq_writestr(req, &val->extension)) ||
+		(rc = uk_9preq_write32(req, val->n_uid)) ||
+		(rc = uk_9preq_write32(req, val->n_gid)) ||
+		(rc = uk_9preq_write32(req, val->n_muid)))
+		return rc;
+
+	return 0;
+}
+
+#define _UK_9PREQ_DEFINE_READ_FN(name, ctype) \
+static inline int uk_9preq_##name(struct uk_9preq *req, ctype * val) \
+{ \
+	return uk_9preq_readbuf(req, val, sizeof(*val)); \
+}
+
+_UK_9PREQ_DEFINE_READ_FN(read8, uint8_t)
+_UK_9PREQ_DEFINE_READ_FN(read16, uint16_t)
+_UK_9PREQ_DEFINE_READ_FN(read32, uint32_t)
+_UK_9PREQ_DEFINE_READ_FN(read64, uint64_t)
+
+#undef _UK_9PREQ_DEFINE_READ_FN
+
+static inline int uk_9preq_readqid(struct uk_9preq *req, struct uk_9p_qid *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_read8(req, &val->type)) ||
+		(rc = uk_9preq_read32(req, &val->version)) ||
+		(rc = uk_9preq_read64(req, &val->path)))
+		return rc;
+
+	return 0;
+}
+
+static inline int uk_9preq_readstr(struct uk_9preq *req, struct uk_9p_str *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_read16(req, &val->size)))
+		return rc;
+
+	/* Optimized string read, does not allocate memory. */
+	val->data = (char *)req->recv.buf + req->recv.offset;
+	req->recv.offset += val->size;
+	if (req->recv.offset > req->recv.size)
+		return -ENOBUFS;
+
+	return 0;
+}
+
+static inline int uk_9preq_readstat(struct uk_9preq *req,
+		struct uk_9p_stat *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_read16(req, &val->size)) ||
+		(rc = uk_9preq_read16(req, &val->type)) ||
+		(rc = uk_9preq_read32(req, &val->dev)) ||
+		(rc = uk_9preq_readqid(req, &val->qid)) ||
+		(rc = uk_9preq_read32(req, &val->mode)) ||
+		(rc = uk_9preq_read32(req, &val->atime)) ||
+		(rc = uk_9preq_read32(req, &val->mtime)) ||
+		(rc = uk_9preq_read64(req, &val->length)) ||
+		(rc = uk_9preq_readstr(req, &val->name)) ||
+		(rc = uk_9preq_readstr(req, &val->uid)) ||
+		(rc = uk_9preq_readstr(req, &val->gid)) ||
+		(rc = uk_9preq_readstr(req, &val->muid)) ||
+		(rc = uk_9preq_readstr(req, &val->extension)) ||
+		(rc = uk_9preq_read32(req, &val->n_uid)) ||
+		(rc = uk_9preq_read32(req, &val->n_gid)) ||
+		(rc = uk_9preq_read32(req, &val->n_muid)))
+		return rc;
+
+	return 0;
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 02 15:16:28 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 15:16: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 1jUtsS-0004y0-B2; Sat, 02 May 2020 15:16: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=Iq85=6Q=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jUtsR-0004xp-Kn
 for minios-devel@lists.xen.org; Sat, 02 May 2020 15:16:27 +0000
X-Inumbo-ID: da1bb8ce-8c87-11ea-9887-bc764e2007e4
Received: from mail-wr1-x444.google.com (unknown [2a00:1450:4864:20::444])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id da1bb8ce-8c87-11ea-9887-bc764e2007e4;
 Sat, 02 May 2020 15:16:10 +0000 (UTC)
Received: by mail-wr1-x444.google.com with SMTP id l18so4676185wrn.6
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 08:16:10 -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=gbm4txP5s/OOd43tbpUC90iGwWTdumxnAVxlyQ0anG0=;
 b=pEkSOrAE9DH4D/dCznuOx+FxwPFf7eBGK38smN06h4ccmCsby56J9jNonVCS/NyH7g
 MEzkeIYVCEoAUPCEw7hbAWuQDP8QVjQU7m18klLa8PXWPaV+wZZps9aVgwDnGgZKLBJ2
 X2SpoG/XBIZHm8OTeqHnLdNiY7Um5QTg/cP/W0YG9OJSC+Tp8Pxab97h0i+4d55mEGa3
 4a/hb6rWp1mIzzzPmCAEMAJk6VE8eypJKKfi2m6bUQRYsekc2wvpbq6NOwBlhE0Er7/A
 bydlKwe2TCbJsez0AhU1Mi0P2/nFCD7Qd10w5j0j9q0PryX7ZAfAxhRdYI+kfDQphKqN
 2Dvg==
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=gbm4txP5s/OOd43tbpUC90iGwWTdumxnAVxlyQ0anG0=;
 b=bvAjJBRNmj1RedRI52oe/iMLSDtAGKW7sCS5ryENpRf2yXsvGg9Cpr+y307/t/MiJs
 dVZkr+Tp2oF/WjL1/oCuc3yNcIW539jMu+ChyRnQzXseP6XObzx/CCN6qhlz+d0mVKxG
 9DSLm6fIWqmCD2kzeXZdFZNZzNce2/+96AfxJmmK6jOaYO54/eNEsADD69fEo3RxjMSA
 yz96V2cFzGEB3Ln57vuNBWSmuYAXAP2HLR08UfyJTu0O0DW4fLBmAeGiuyIpK22ycCuA
 BmRG5+DAC/LXSB6rwyClRroaug5P4cU+nGmaCpOIcguV4pVOCsLH7Ucq2EqkBsRXL6np
 ekKQ==
X-Gm-Message-State: AGi0PuZ2t9RE5ia0S10bE0HWk9uCpicQ5jV3ETsmJDK2O+5CaqWIy/48
 kVIf/7ZuXT2/JQpdmYQEtWXporOUhdw=
X-Google-Smtp-Source: APiQypI2HFGrbLurN+qmMzd28o6O4VydibMWgZXXvksckxVBDYnyg8nNT4D7XK7K4sJTWnjIR4Cikg==
X-Received: by 2002:adf:9d85:: with SMTP id p5mr10187047wre.101.1588432568964; 
 Sat, 02 May 2020 08:16:08 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id u12sm4793822wmu.25.2020.05.02.08.16.08
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 08:16:08 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 5/7] lib/vfscore: Fix double refcounting bug
Date: Sat,  2 May 2020 16:13:38 +0100
Message-Id: <20200502151340.92959-6-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200502151340.92959-1-cristb@gmail.com>
References: <20200502151340.92959-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch removes the `dref()` line in `sys_open` which would result
in an unbounded growth of the refcount. open() would take two
references: one via dentry_lookup() in namei(), and the other via
dref(); close() would release only one reference via drele().

As to the comment also deleted in this patch, it is true that OSv uses
intrusive_ptr, however it is created with the second argument
add_ref = false, hence the "std::move()" comment below in the original
OSv source code.

Now close() correctly releases the dentry if there are no open files
left.

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/vfscore/syscalls.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/vfscore/syscalls.c b/lib/vfscore/syscalls.c
index 9a132b7..ce51274 100644
--- a/lib/vfscore/syscalls.c
+++ b/lib/vfscore/syscalls.c
@@ -205,8 +205,10 @@ sys_open(char *path, int flags, mode_t mode, struct vfscore_file **fpp)
 	fhold(fp);
 	fp->f_flags = flags;
 
-	// OSv was using a intrusive_ptr which was increasing the refcount
-	dref(dp);
+	/*
+	 * Don't need to increase refcount here, we already hold a reference
+	 * to dp from namei().
+	 */
 	// change to std::move once dp is a dentry_ref
 	fp->f_dentry = dp;
 	dp = NULL;
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 02 15:16:33 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 15:16: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 1jUtsX-0004zO-Ck; Sat, 02 May 2020 15:16:33 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=Iq85=6Q=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jUtsW-0004zD-KN
 for minios-devel@lists.xen.org; Sat, 02 May 2020 15:16:32 +0000
X-Inumbo-ID: d9d7f4cc-8c87-11ea-9887-bc764e2007e4
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d9d7f4cc-8c87-11ea-9887-bc764e2007e4;
 Sat, 02 May 2020 15:16:09 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id o27so10102315wra.12
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 08:16:09 -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=czwtDG4hoBdYCmIFefIH6phE9/KHLK8vSfoaRtSxCmQ=;
 b=txIg3ytYyR3exqRfxHtZLm+SRJ5HCa5qYtsP+8EPfFETXMsPvuNpfGoxABW616h2IS
 g4feTG/e5y6zkoHsrTz8NUPdeFUH7ldcOmcSaQzN5wHDY9N+6LdkKb7ZPceuLGBJf4ng
 whOCdgnaN2tfUDbCmxC48eoaQkc7ziKT+4kJNIEhAF9z5sbPhLrBl/Izw4TD/vKijsPP
 hUvWBH4NURWeKRC89sUewf5Vu0o0fjPgShkK+DGtzYBkwO8Oyi/xYOXSxojgmNtAp9E+
 E/WC+qVkNBOe87iopqdHYiF1/ZjEqO2VdioDrMFDoKxKWLuCQVwvZAyD9evctLPz5j7b
 C2VA==
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=czwtDG4hoBdYCmIFefIH6phE9/KHLK8vSfoaRtSxCmQ=;
 b=pUKWtIqOG04tCzv99G5ddRBXjjdp1wcr2AUp9crJSeAlmgWQvCcquGD5iTDD9sXzKN
 PS88PN36EML1+KlwBEbRtku1TG2fWyn2yPOvWXM2Gmn9aYHWefpon3j6B/idKFlZN5b3
 wQz8dgQzo54UWTdRfHGd1lDXFxZu54tg5dVNivCqWCYYXFr5sRLE9SY0JT6GIa/pD6E6
 hEaP283QkLjDuL5uI3jq+TBK9YZ6hqLAXtbEH6N3cMX0S/fHMJQbaTSAV0mnHF2rBRG0
 gG6FREfgHTDY6/LlchefBkh2BJYBKuPE16mH3++AVWSODZJscQyqKYAKKzGQibYgVTIr
 Nt3g==
X-Gm-Message-State: AGi0PuYuIWnAtf63i28j6UCkD5A+QZzXXmVLxcZIMgBV1kdn/gzNnmy3
 Wj8SlJDfkiTOCZ/269vjM2WwKGgs/5I=
X-Google-Smtp-Source: APiQypI+5K73Rww2fK4CNNTsySFpuxojeWRhbwj5yBFo2tntfSe3MN52rXKGDy5hHqxY5u6SCrLsag==
X-Received: by 2002:adf:c414:: with SMTP id v20mr7475831wrf.379.1588432568433; 
 Sat, 02 May 2020 08:16:08 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id u12sm4793822wmu.25.2020.05.02.08.16.07
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 08:16:08 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 4/7] lib/uk9p: Recycle uk_9preq allocations
Date: Sat,  2 May 2020 16:13:37 +0100
Message-Id: <20200502151340.92959-5-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200502151340.92959-1-cristb@gmail.com>
References: <20200502151340.92959-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Each 9p device keeps a free-list of 9p requests. This allows
allocations to take much less time, as usually the workflow of a 9p
device is synchronous: create request, wait for reply, process it,
repeat. This approach avoids the allocation performance hit on
subsequent request creations.

Results below indicate that request_allocated takes < 100ns,
as opposed to 1us (previous commit in this patch series).

In the sample below, the read() now spends most of the time (~99.7%)
either notifying the host or waiting for a reply. At this scale,
even uk_traces are probably noisy and the "real" time might be lower
by a relatively large amount.

Excerpt from the uk traces on a read() call with in-depth tracing:

1846467237  uk_9p_trace_read               fid 2 offset 61440 count 4096
1846467321  uk_9p_trace_request_allocated
1846467350  uk_9p_trace_ready              tag 0
1846470161  uk_9p_trace_sent               tag 0
1846508851  uk_9p_trace_received           tag 0
1846508889  uk_9p_trace_read_end           count 4096

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/9pdev.c                 | 78 +++++++++++++++++++++++++++++---
 lib/uk9p/9preq.c                 | 14 ++----
 lib/uk9p/include/uk/9pdev.h      | 10 ++++
 lib/uk9p/include/uk/9pdev_core.h |  2 +
 lib/uk9p/include/uk/9preq.h      | 15 +++---
 5 files changed, 93 insertions(+), 26 deletions(-)

diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
index 40a4daa..42c5058 100644
--- a/lib/uk9p/9pdev.c
+++ b/lib/uk9p/9pdev.c
@@ -132,6 +132,7 @@ static void _req_mgmt_init(struct uk_9pdev_req_mgmt *req_mgmt)
 	ukarch_spin_lock_init(&req_mgmt->spinlock);
 	uk_bitmap_zero(req_mgmt->tag_bm, UK_9P_NUMTAGS);
 	UK_INIT_LIST_HEAD(&req_mgmt->req_list);
+	UK_INIT_LIST_HEAD(&req_mgmt->req_free_list);
 }
 
 static void _req_mgmt_add_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
@@ -141,6 +142,21 @@ static void _req_mgmt_add_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
 	uk_list_add(&req->_list, &req_mgmt->req_list);
 }
 
+static struct uk_9preq *
+_req_mgmt_from_freelist_locked(struct uk_9pdev_req_mgmt *req_mgmt)
+{
+	struct uk_9preq *req;
+
+	if (uk_list_empty(&req_mgmt->req_free_list))
+		return NULL;
+
+	req = uk_list_first_entry(&req_mgmt->req_free_list,
+			struct uk_9preq, _list);
+	uk_list_del(&req->_list);
+
+	return req;
+}
+
 static void _req_mgmt_del_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
 				struct uk_9preq *req)
 {
@@ -148,6 +164,12 @@ static void _req_mgmt_del_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
 	uk_list_del(&req->_list);
 }
 
+static void _req_mgmt_req_to_freelist_locked(struct uk_9pdev_req_mgmt *req_mgmt,
+				struct uk_9preq *req)
+{
+	uk_list_add(&req->_list, &req_mgmt->req_free_list);
+}
+
 static uint16_t _req_mgmt_next_tag_locked(struct uk_9pdev_req_mgmt *req_mgmt)
 {
 	return uk_find_next_zero_bit(req_mgmt->tag_bm, UK_9P_NUMTAGS, 0);
@@ -164,10 +186,24 @@ static void _req_mgmt_cleanup(struct uk_9pdev_req_mgmt *req_mgmt __unused)
 		tag = req->tag;
 		_req_mgmt_del_req_locked(req_mgmt, req);
 		if (!uk_9preq_put(req)) {
-			uk_pr_warn("Tag %d still has references on cleanup.\n",
+			/* If in the future these references get released, mark
+			 * _dev as NULL so uk_9pdev_req_to_freelist doesn't
+			 * attempt to place them in an invalid memory region.
+			 *
+			 * As _dev is not used for any other purpose, this
+			 * doesn't impact any other logic related to 9p request
+			 * processing.
+			 */
+			req->_dev = NULL;
+			uk_pr_err("Tag %d still has references on cleanup.\n",
 				tag);
 		}
 	}
+	uk_list_for_each_entry_safe(req, reqn, &req_mgmt->req_free_list,
+			_list) {
+		uk_list_del(&req->_list);
+		uk_free(req->_a, req);
+	}
 	ukplat_spin_unlock_irqrestore(&req_mgmt->spinlock, flags);
 }
 
@@ -297,17 +333,35 @@ struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type)
 
 	UK_ASSERT(dev);
 
-	req = uk_9preq_alloc(dev->a);
-	if (req == NULL) {
-		rc = -ENOMEM;
-		goto out;
+	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
+	if (!(req = _req_mgmt_from_freelist_locked(&dev->_req_mgmt))) {
+		/* Don't allocate with the spinlock held. */
+		ukplat_spin_unlock_irqrestore(&dev->_req_mgmt.spinlock, flags);
+		req = uk_calloc(dev->a, 1, sizeof(*req));
+		if (req == NULL) {
+			rc = -ENOMEM;
+			goto out;
+		}
+		req->_dev = dev;
+		/*
+		 * Duplicate this, instead of using req->_dev, as we can't rely
+		 * on the value of _dev at time of free. Check comment in
+		 * _req_mgmt_cleanup.
+		 */
+		req->_a = dev->a;
+		ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
 	}
 
+	uk_9preq_init(req);
+
+	/* If request was from the free list, it should already belong to the
+	 * dev. */
+	UK_ASSERT(req->_dev == dev);
+
 	/* Shouldn't exceed the msize on non-zerocopy buffers, just in case. */
 	req->recv.size = MIN(req->recv.size, dev->msize);
 	req->xmit.size = MIN(req->xmit.size, dev->msize);
 
-	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
 	if (type == UK_9P_TVERSION)
 		tag = UK_9P_NOTAG;
 	else
@@ -360,6 +414,18 @@ int uk_9pdev_req_remove(struct uk_9pdev *dev, struct uk_9preq *req)
 	return uk_9preq_put(req);
 }
 
+void uk_9pdev_req_to_freelist(struct uk_9pdev *dev, struct uk_9preq *req)
+{
+	unsigned long flags;
+
+	if (!dev)
+		return;
+
+	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
+	_req_mgmt_req_to_freelist_locked(&dev->_req_mgmt, req);
+	ukplat_spin_unlock_irqrestore(&dev->_req_mgmt.spinlock, flags);
+}
+
 struct uk_9pfid *uk_9pdev_fid_create(struct uk_9pdev *dev)
 {
 	struct uk_9pfid *fid = NULL;
diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
index d44e684..edc462c 100644
--- a/lib/uk9p/9preq.c
+++ b/lib/uk9p/9preq.c
@@ -35,6 +35,7 @@
 #include <string.h>
 #include <uk/config.h>
 #include <uk/9preq.h>
+#include <uk/9pdev.h>
 #include <uk/9p_core.h>
 #include <uk/list.h>
 #include <uk/refcount.h>
@@ -45,14 +46,8 @@
 #include <uk/wait.h>
 #endif
 
-struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a)
+void uk_9preq_init(struct uk_9preq *req)
 {
-	struct uk_9preq *req;
-
-	req = uk_calloc(a, 1, sizeof(*req));
-	if (req == NULL)
-		return NULL;
-
 	req->xmit.buf = req->xmit_buf;
 	req->recv.buf = req->recv_buf;
 	req->xmit.size = req->recv.size = UK_9P_BUFSIZE;
@@ -69,13 +64,10 @@ struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a)
 	req->recv.offset = 0;
 
 	UK_INIT_LIST_HEAD(&req->_list);
-	req->_a = a;
 	uk_refcount_init(&req->refcount, 1);
 #if CONFIG_LIBUKSCHED
 	uk_waitq_init(&req->wq);
 #endif
-
-	return req;
 }
 
 void uk_9preq_get(struct uk_9preq *req)
@@ -89,7 +81,7 @@ int uk_9preq_put(struct uk_9preq *req)
 
 	last = uk_refcount_release(&req->refcount);
 	if (last)
-		uk_free(req->_a, req);
+		uk_9pdev_req_to_freelist(req->_dev, req);
 
 	return last;
 }
diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
index 1225336..560ba8f 100644
--- a/lib/uk9p/include/uk/9pdev.h
+++ b/lib/uk9p/include/uk/9pdev.h
@@ -149,6 +149,16 @@ struct uk_9preq *uk_9pdev_req_lookup(struct uk_9pdev *dev, uint16_t tag);
  */
 int uk_9pdev_req_remove(struct uk_9pdev *dev, struct uk_9preq *req);
 
+/**
+ * Places the given request on the 9p device's request freelist.
+ *
+ * @param dev
+ *   The Unikraft 9P Device. If NULL, doesn't place the request on the freelist.
+ * @param req
+ *   The request to be placed on the freelist.
+ */
+void uk_9pdev_req_to_freelist(struct uk_9pdev *dev, struct uk_9preq *req);
+
 /**
  * Creates a FID associated with the given 9P device.
  *
diff --git a/lib/uk9p/include/uk/9pdev_core.h b/lib/uk9p/include/uk/9pdev_core.h
index 38864ac..fcad1ef 100644
--- a/lib/uk9p/include/uk/9pdev_core.h
+++ b/lib/uk9p/include/uk/9pdev_core.h
@@ -120,6 +120,8 @@ struct uk_9pdev_req_mgmt {
 	unsigned long                   tag_bm[UK_BITS_TO_LONGS(UK_9P_NUMTAGS)];
 	/* List of requests allocated and not yet removed. */
 	struct uk_list_head             req_list;
+	/* Free-list of requests. */
+	struct uk_list_head		req_free_list;
 };
 
 /**
diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
index ed883d2..aad8d42 100644
--- a/lib/uk9p/include/uk/9preq.h
+++ b/lib/uk9p/include/uk/9preq.h
@@ -162,6 +162,8 @@ struct uk_9preq {
 	uint16_t                        tag;
 	/* Entry into the list of requests (API-internal). */
 	struct uk_list_head             _list;
+	/* @internal 9P device this request belongs to. */
+	struct uk_9pdev                 *_dev;
 	/* @internal Allocator used to allocate this request. */
 	struct uk_alloc                 *_a;
 	/* Tracks the number of references to this structure. */
@@ -176,16 +178,10 @@ UK_CTASSERT(sizeof(struct uk_9preq) <= __PAGE_SIZE);
 
 /**
  * @internal
- * Allocates a 9p request.
+ * Initializes a 9P request.
  * Should not be used directly, use uk_9pdev_req_create() instead.
- *
- * @param a
- *   Allocator to use.
- * @return
- *   - (==NULL): Out of memory.
- *   - (!=NULL): Successful.
  */
-struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a);
+void uk_9preq_init(struct uk_9preq *req);
 
 /**
  * Gets the 9p request, incrementing the reference count.
@@ -197,7 +193,8 @@ void uk_9preq_get(struct uk_9preq *req);
 
 /**
  * Puts the 9p request, decrementing the reference count.
- * If this was the last live reference, the memory will be freed.
+ * If this was the last live reference, it will be placed on the asociated
+ * device's request freelist.
  *
  * @param req
  *   Reference to the 9p request.
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 02 15:16:38 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 15:16:38 +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 1jUtsc-00050d-EI; Sat, 02 May 2020 15:16:38 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=Iq85=6Q=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jUtsb-00050V-Kj
 for minios-devel@lists.xen.org; Sat, 02 May 2020 15:16:37 +0000
X-Inumbo-ID: da79d86e-8c87-11ea-9887-bc764e2007e4
Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id da79d86e-8c87-11ea-9887-bc764e2007e4;
 Sat, 02 May 2020 15:16:10 +0000 (UTC)
Received: by mail-wr1-x441.google.com with SMTP id s8so5104854wrt.9
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 08:16:10 -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=vz06YVQDMtA+AQso+ib6pld7xDIMUQTLtUzOhfEz8Ws=;
 b=AMNYRQ6zeiFTcuxGJxtKGP8x7SzkniXhSPXAhksIXga8RmEoFsYyFb7Mir9ZCEgWzH
 uAybUmGjVuWHoapq+L9fX/BueYK4OQOqlhNa/vBxtBolOC8BOr/q1RmLPmWZBLRFz5cp
 4A11ygC+F22FOSkyUxG0GM7pVZgeuAqUg1rcIANa+1LyXzNc2OM1LmitOsBbn3vSdsBs
 kKQBE1PnFno9Md0yfka5WY6zGNQR9yrdkHYaQXF7UVKWWVo5ZNeTkfrxALmNoZW+kUGz
 c8JZGG4JtA+fWx6IX6Gn/wh1lC4Q1VndePblOAnziwaUKrcZsA/lsbso5faDkFiuUi7C
 T26Q==
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=vz06YVQDMtA+AQso+ib6pld7xDIMUQTLtUzOhfEz8Ws=;
 b=Vm+OJIgULixjx4Ml2XLRzBrHHrpig9ITjSI2mGjkzArbM/URtt03VrigUGa3zH89BJ
 4LumPG5Y/3vmRRGo/S2Jtq7DbX2WVro9X3YJwobd9vR0/f54hWPf253YUq5FLez9miOz
 bOVbOrbDLIa16QhI+wPMSsaWG2Xi5k9bWuIPWlK/tes9IDlWG4RMW/ydGKn/t8i8L6KP
 u4ENCkq/J3fgj78IAw2iEN6j3AI/R0/tXMe07EvQm+P+BrupexfQFB2Z0LQkdx3mEiUv
 ypbcqJ3/rdjzi2Xj6b3n03n50gJ2c6YkAC7f/ZzdLLlvdfJs9tw9b4hbJC1m6h7gkT2s
 K8ZA==
X-Gm-Message-State: AGi0PuZedQTiCPKE/qOYnSeKCsNpjrsT3wIR3FKPVDFrvLub9179sQP/
 iBtc/OlOuwsmU30epOqE+pOBI/2ZNOo=
X-Google-Smtp-Source: APiQypKAZMtDItLK08jOVfNvpYjnw6AQNcmonBZGYbkRuAckoJOpW2iyQvtbnTqju9LizsznGUUn3Q==
X-Received: by 2002:a5d:4e02:: with SMTP id p2mr10465969wrt.302.1588432569589; 
 Sat, 02 May 2020 08:16:09 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id u12sm4793822wmu.25.2020.05.02.08.16.09
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 08:16:09 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 6/7] lib/vfscore: Expose max fds to sysconf
Date: Sat,  2 May 2020 16:13:39 +0100
Message-Id: <20200502151340.92959-7-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200502151340.92959-1-cristb@gmail.com>
References: <20200502151340.92959-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Expose FDTABLE_MAX_FILES from vfscore as the return value of
sysconf(_SC_OPEN_MAX) if CONFIG_LIBVFSCORE is enabled.

This allows language runtimes to inspect the number of active
fds (e.g. for tests).

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/posix-sysinfo/sysinfo.c        | 10 ++++++++++
 lib/vfscore/fd.c                   |  2 --
 lib/vfscore/include/vfscore/file.h |  3 +++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/posix-sysinfo/sysinfo.c b/lib/posix-sysinfo/sysinfo.c
index 7bcfc8b..075f320 100644
--- a/lib/posix-sysinfo/sysinfo.c
+++ b/lib/posix-sysinfo/sysinfo.c
@@ -43,6 +43,11 @@
 #include <sys/sysinfo.h>
 #include <uk/syscall.h>
 
+#if CONFIG_LIBVFSCORE
+/* For FDTABLE_MAX_FILES. */
+#include <vfscore/file.h>
+#endif
+
 static struct utsname utsname = {
 	.sysname	= "Unikraft",
 	.nodename	= "unikraft",
@@ -85,6 +90,11 @@ long sysconf(int name)
 	if (name == _SC_PAGESIZE)
 		return __PAGE_SIZE;
 
+#if CONFIG_LIBVFSCORE
+	if (name == _SC_OPEN_MAX)
+		return FDTABLE_MAX_FILES;
+#endif
+
 	return 0;
 }
 
diff --git a/lib/vfscore/fd.c b/lib/vfscore/fd.c
index 684ea50..956846f 100644
--- a/lib/vfscore/fd.c
+++ b/lib/vfscore/fd.c
@@ -42,8 +42,6 @@
 #include <errno.h>
 #include <uk/ctors.h>
 
-#define FDTABLE_MAX_FILES 1024
-
 void init_stdio(void);
 
 struct fdtable {
diff --git a/lib/vfscore/include/vfscore/file.h b/lib/vfscore/include/vfscore/file.h
index be23974..ec45a08 100644
--- a/lib/vfscore/include/vfscore/file.h
+++ b/lib/vfscore/include/vfscore/file.h
@@ -80,6 +80,9 @@ int fdrop(struct vfscore_file* fp);
 
 #define FOF_OFFSET  0x0800    /* Use the offset in uio argument */
 
+/* Used from posix-sysinfo to determine sysconf(_SC_OPEN_MAX). */
+#define FDTABLE_MAX_FILES 1024
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 02 15:16:43 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 15:16: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 1jUtsh-00051n-G3; Sat, 02 May 2020 15:16: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=Iq85=6Q=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jUtsg-00051W-LG
 for minios-devel@lists.xen.org; Sat, 02 May 2020 15:16:42 +0000
X-Inumbo-ID: dacb3e2a-8c87-11ea-b9cf-bc764e2007e4
Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id dacb3e2a-8c87-11ea-b9cf-bc764e2007e4;
 Sat, 02 May 2020 15:16:11 +0000 (UTC)
Received: by mail-wm1-x343.google.com with SMTP id 188so3283400wmc.2
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 08:16:11 -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=e1yxLT+QQNdUcz5+5myZxCYNnd2hjbWcU855uAmL9Go=;
 b=ILW1kTJzPs+cGtoxoDYTogELNwORJVxB0Gzq1rTutrOyCdCc4yMmraG1cxEkLIsdNm
 xHMqwYA20wOO7J7A+uQsiaerJcQCaDxOP8rLc26lCnC5uhxDO5AbvekS193YU4YT1jAq
 C0mm7Nzwe2A1SdyIFCBVmCD+85iwYerNY7h+GeFJW7f+50vLl1Fx+MAnvrGeDlg6rb6c
 hehSXDlh7VDfRlOyEihY2SpdjgK7d5iY8xMcP3LgaP3nDI0IIp3Wz+2Izfru2yBNudRD
 nbr8L5lXnnX8ODbf0QBYWkCMQQ4dsukw6d456DuOMK+qxArI16tBmsKhalrfk05WHRd6
 dfjg==
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=e1yxLT+QQNdUcz5+5myZxCYNnd2hjbWcU855uAmL9Go=;
 b=GVWYz+FWhNL23NcrRndHTE1O26Jec1nk2d6xHryXiPYDZTRc1H2nLU3bE8365SAqHj
 MsgRjcKshWXCJjOTHxUu7DFDx/J+lCNwmNDk+nkH6MGXDZK0TT3YW7MMW8m3tv5sxON5
 rBl4OlCjkxkX6WToHGjhSM6I6yDQMcKJdA09isB8LAqedmCrwrf3ve8KqHRRHLGnnXKW
 tgBglzpheA1DCoyyLt9tvndyCp9jOL/E7BHj3ZJ8MLHrPsaZlG9la7woAl6qeV9bBzPC
 RRtXKdNihVMsI6eO09B4esdBZeuwEK1cU6DqCqncwktgMgYmpr2WmH60Chfm5QRP8YUd
 LPZQ==
X-Gm-Message-State: AGi0PuY1zrBZg8P/JGWVrPC1JTT7RTwYPSNd0rGi8pzjIatW1CKgDGCp
 nL+Fi2QW8ppyBi01SSFBiNCKRzkrTk4=
X-Google-Smtp-Source: APiQypK9BmL6yclgJnUUJF7hjb0Ql8/ZfkvjJORH9gxwYYGxoalwfcuRxmOmR3BeXzVdvkpx0Y41aQ==
X-Received: by 2002:a7b:cf2b:: with SMTP id m11mr4740969wmg.147.1588432570191; 
 Sat, 02 May 2020 08:16:10 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id u12sm4793822wmu.25.2020.05.02.08.16.09
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 08:16:09 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 7/7] lib/9pfs: Simplify the logic for removes
Date: Sat,  2 May 2020 16:13:40 +0100
Message-Id: <20200502151340.92959-8-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200502151340.92959-1-cristb@gmail.com>
References: <20200502151340.92959-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

The logic for unlinking is simplified, either:
- there are no open files, remove now;
- there are open files, defer until all open files are closed

This is now possible since successive open and closes update
the dentry reference count correctly, so VOP_INACTIVE is called
in time to free the fid before the qid starts being reused
on the server-side (and we get an inode collision).

This also means that on unmounting, releasing all non-root
dentries and calling vfscore_release_mp_dentries() for m_covered
and m_root is enough to ensure all fids are clunked before
disconnecting.

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/9pfs/9pfs_vfsops.c |  7 +++----
 lib/9pfs/9pfs_vnops.c  | 37 +++++++++++--------------------------
 2 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/lib/9pfs/9pfs_vfsops.c b/lib/9pfs/9pfs_vfsops.c
index accb3a5..5293b22 100644
--- a/lib/9pfs/9pfs_vfsops.c
+++ b/lib/9pfs/9pfs_vfsops.c
@@ -169,11 +169,10 @@ static void uk_9pfs_release_tree_fids(struct dentry *d)
 {
 	struct dentry *p;
 
-	uk_list_for_each_entry(p, &d->d_child_list, d_child_link)
+	uk_list_for_each_entry(p, &d->d_child_list, d_child_link) {
 		uk_9pfs_release_tree_fids(p);
-
-	if (d->d_vnode->v_data)
-		uk_9pfs_free_vnode_data(d->d_vnode);
+		drele(p);
+	}
 }
 
 static int uk_9pfs_unmount(struct mount *mp, int flags __unused)
diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
index 6d3ece3..c81c82a 100644
--- a/lib/9pfs/9pfs_vnops.c
+++ b/lib/9pfs/9pfs_vnops.c
@@ -147,7 +147,7 @@ void uk_9pfs_free_vnode_data(struct vnode *vp)
 	struct uk_9pdev *dev = UK_9PFS_MD(vp->v_mount)->dev;
 	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
 
-	if (nd->nb_open_files > 0)
+	if (!vp->v_data)
 		return;
 
 	if (nd->removed)
@@ -158,20 +158,6 @@ void uk_9pfs_free_vnode_data(struct vnode *vp)
 	vp->v_data = NULL;
 }
 
-/*
- * The closing variant of the function will enforce freeing the associated
- * resources only if the vnode was removed via an unlink/rmdir operation.
- */
-static void uk_9pfs_free_vnode_data_closing(struct vnode *vp)
-{
-	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
-
-	if (!nd->removed)
-		return;
-
-	uk_9pfs_free_vnode_data(vp);
-}
-
 static int uk_9pfs_open(struct vfscore_file *file)
 {
 	struct uk_9pdev *dev = UK_9PFS_MD(file->f_dentry->d_mount)->dev;
@@ -222,7 +208,6 @@ static int uk_9pfs_close(struct vnode *vn __unused, struct vfscore_file *file)
 	uk_9pfid_put(fd->fid);
 	free(fd);
 	UK_9PFS_ND(file->f_dentry->d_vnode)->nb_open_files--;
-	uk_9pfs_free_vnode_data_closing(file->f_dentry->d_vnode);
 
 	return 0;
 }
@@ -327,22 +312,22 @@ static int uk_9pfs_remove_generic(struct vnode *dvp, struct vnode *vp)
 {
 	struct uk_9pdev *dev = UK_9PFS_MD(dvp->v_mount)->dev;
 	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
-	int rc = 0;
-
-	if (!nd->removed && !nd->nb_open_files)
-		rc = uk_9p_remove(dev, nd->fid);
-	else
-		nd->removed = true;
-
-	uk_9pfs_free_vnode_data(vp);
 
-	return -rc;
+	return -uk_9p_remove(dev, nd->fid);
 }
 
 static int uk_9pfs_remove(struct vnode *dvp, struct vnode *vp,
 		char *name __unused)
 {
-	return uk_9pfs_remove_generic(dvp, vp);
+	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
+	int rc = 0;
+
+	if (!nd->nb_open_files)
+		rc = uk_9pfs_remove_generic(dvp, vp);
+	else
+		nd->removed = true;
+
+	return rc;
 }
 
 static int uk_9pfs_mkdir(struct vnode *dvp, char *name, mode_t mode)
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:22:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:22: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 1jUwm7-0004sw-Cr; Sat, 02 May 2020 18:22:07 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwm5-0004sr-QT
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:22:05 +0000
X-Inumbo-ID: d2d4cdc0-8ca1-11ea-9887-bc764e2007e4
Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d2d4cdc0-8ca1-11ea-9887-bc764e2007e4;
 Sat, 02 May 2020 18:22:04 +0000 (UTC)
Received: by mail-wr1-x443.google.com with SMTP id j1so15875973wrt.1
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:04 -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=0YARV0xAbgzHKQY0D4B/0N37S2tGGvFp+HwKK0pCOl4=;
 b=KXMdGf9OX3v6qZiYO9fDQBDmjLXxBjgxdN+h+rWl+cTJwm88QVo9SmIHiWksdkCjb2
 oexrUyZsKgY78vqUsV63IRZ2L6/L6Klbk9+rLBL6C235Z6DKF+EiTxBy+wu0p/+L5W9f
 uI3AyPZkN6VTXr8/foH2S+WPqlstX/xCWNuVINvTFiO9xMDWPMuNlAeeqZTQZmTusW0q
 KL8PNt0835pAzSh3lp8Z6RCo/5fvqax93qdaDB+7+ecjsZOKI8k6RV3MN+3k6t7ldexu
 dC1DoC1XurH3etKl2WvQvB1JFMDR5J4Ri+ruaZr/O04rG+zmmPC+8nenZ+GhCIKY5V2C
 0B2A==
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=0YARV0xAbgzHKQY0D4B/0N37S2tGGvFp+HwKK0pCOl4=;
 b=NnTJy5V3mXnSgFs31AttzGWOUG7g15MpRoOo12pPSUBRdPYBTyzwDEDhd5RzdfkHKP
 tFas1v4ESmYlxOucn7gcPE34eeY+WDfyKggJvIlneV19GCliBi0mzRfdyMAsk/Tt65jq
 +lpXY15RSynSiDYlWW3jI5j0pN0P0xtU2nGQ7Ftz1//ehSAZP2RwEStQHf923gj+d7Wo
 e2LERRf3rOeIl0sd8Tp/LP09o3l23iHADZ28RSV/rhUsHVWsUzjqNj00o2KpJKYyvPAl
 YsqtHmbTH//6RXYTzsIGxk5BlFi+9FdTS0tglSSUw35IOgnkFgllIDHuTMlzFVYVykOc
 sX0Q==
X-Gm-Message-State: AGi0PuaFvgVOWbp8XCiHQgW/tj/xIepuggWPhRr5051wXpp4TSV5n39S
 4/5D0hhxNaUp8lth/QmzymkHagQJKu8=
X-Google-Smtp-Source: APiQypKeVQilk5NwcHvkWHTgZXXqdVa8jpkmfb5mD9WQsURd6NjuVJFBlRgnXBqIgJxPGfHL6QiYJQ==
X-Received: by 2002:a05:6000:11cd:: with SMTP id
 i13mr10203734wrx.120.1588443723645; 
 Sat, 02 May 2020 11:22:03 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.02
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:03 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 01/11] lib/vfscore: Add the macro UK_SYSCALL_R_DEFINE
 for dup
Date: Sat,  2 May 2020 21:18:25 +0300
Message-Id: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Adds the macro UK_SYSCALL_R_DEFINE for `dup` in order to
be registered to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 7c61013..5a287ed 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -1386,7 +1386,7 @@ UK_TRACEPOINT(trace_vfs_dup_err, "%d", int);
 /*
  * Duplicate a file descriptor
  */
-int dup(int oldfd)
+UK_SYSCALL_R_DEFINE(int, dup, int, oldfd)
 {
 	struct vfscore_file *fp;
 	int newfd;
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:22:25 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:22:25 +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 1jUwmP-0004tp-Ff; Sat, 02 May 2020 18:22:25 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwmO-0004tj-B9
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:22:24 +0000
X-Inumbo-ID: de1c5a68-8ca1-11ea-b9cf-bc764e2007e4
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id de1c5a68-8ca1-11ea-b9cf-bc764e2007e4;
 Sat, 02 May 2020 18:22:23 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id d15so15863863wrx.3
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:23 -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=4EeBHehF5ngRplrZugeu7V77I0rAlLzKJb9z1ucK8/E=;
 b=J68bbqT0RxJIJ6tUHGNo2aTGUskchiet58FX5ipLywW4fcn3HDoz8VUvJb9+x/cEgW
 tsPGLwlYMhB0mLEIwbNC0X+BTXsC0AwWyA8qibxB7sBWpDT+5B923qky/TBLJbePi69V
 Mu4Vp3Q+uhyQ29I9IljOOvtQGzOxGDqTiJz1XUZBb+aLkdegyFXN8/MsHf/DQ2iH2eFX
 eWV7Xj5yMSncv4wxSH/LLsXJX41lKi/3ql3kyfFjYyV44+/NdCcaKJiOkXNruudn9iok
 xeB9tsTi6un21qCVcybsaMogNM75SuS8LCd9LjigzK5NC3h5WDVi+xZSs1PFRr/4/xz1
 6a1g==
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=4EeBHehF5ngRplrZugeu7V77I0rAlLzKJb9z1ucK8/E=;
 b=jO4ZYzi+BcmWQJYYPC4pgz69pv0wypp5qjt+o24nbEYrr+QQ6EDWddJC4/hxkYdsk7
 tZ6zUp2e9gT/frTtGO65EOpH0awEcr2nEcg+Nxp7xoHsL3cLsKvJkRG7sM5WLtYNRrIX
 PWnawObi1O4VUJQrHTsk1+TuERxv04ye6GrVleuv8SIjWItaIbWH8m+hwuiMY9rLJipK
 JOQUg+cf91Q7n2BECBVUA2cMlQ+IAUiXlpKtFzYckm4cHxxJzTmmQ+RQzLhq1iIHZY4x
 KJS61yCJXR8HtKpqpWbXl5VI3xsEa8XQiDMR9InlmzBb/HBggUa7u1bjqejl5zxjTUSz
 omog==
X-Gm-Message-State: AGi0PuaMKQpDMERLrkTO46yVyEn7k8eCEBixl7dgRZa4/kRKzeIM7VWB
 UEDxE1vOtiLslo4tHl/RBZy5bZBeZjI=
X-Google-Smtp-Source: APiQypJk0yMImPtbLOI4rN4aY4nKJC2m69cuwpiAjXQ/BmbCwIbvenTGY8nVFFnPFvNnf7vIusuDlA==
X-Received: by 2002:adf:ca0e:: with SMTP id o14mr11169215wrh.254.1588443742666; 
 Sat, 02 May 2020 11:22:22 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.21
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:22 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 02/11] lib/vfscore: Register `pwritev` to syscall_shim
Date: Sat,  2 May 2020 21:18:26 +0300
Message-Id: <20200502181835.6724-2-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `pwritev` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  1 +
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 12 ++++++------
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 5906a40..aea4470 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -44,3 +44,4 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fchdir-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup3-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup2-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pwritev-4
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 037537c..b54a6a1 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -79,6 +79,8 @@ closedir
 pread
 pwrite
 pwritev
+uk_syscall_e_pwritev
+uk_syscall_r_pwritev
 readv
 uk_syscall_e_readv
 uk_syscall_r_readv
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 5a287ed..3edcd49 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -418,7 +418,8 @@ UK_TRACEPOINT(trace_vfs_pwritev, "%d %p 0x%x 0x%x", int, const struct iovec*,
 UK_TRACEPOINT(trace_vfs_pwritev_ret, "0x%x", ssize_t);
 UK_TRACEPOINT(trace_vfs_pwritev_err, "%d", int);
 
-ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
+UK_SYSCALL_R_DEFINE(ssize_t, pwritev, int, fd, const struct iovec*, iov,
+			int, iovcnt, off_t, offset)
 {
 	struct vfscore_file *fp;
 	size_t bytes;
@@ -427,20 +428,19 @@ ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
 	trace_vfs_pwritev(fd, iov, iovcnt, offset);
 	error = fget(fd, &fp);
 	if (error)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_write(fp, iov, iovcnt, offset, &bytes);
 	fdrop(fp);
 
 	if (has_error(error, bytes))
-		goto out_errno;
+		goto out_error;
 	trace_vfs_pwritev_ret(bytes);
 	return bytes;
 
-	out_errno:
+	out_error:
 	trace_vfs_pwritev_err(error);
-	errno = error;
-	return -1;
+	return -error;
 }
 LFS64(pwritev);
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:22:30 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:22:30 +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 1jUwmU-0004uZ-H9; Sat, 02 May 2020 18:22: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=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwmT-0004uP-BM
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:22:29 +0000
X-Inumbo-ID: deb7a086-8ca1-11ea-ae69-bc764e2007e4
Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id deb7a086-8ca1-11ea-ae69-bc764e2007e4;
 Sat, 02 May 2020 18:22:24 +0000 (UTC)
Received: by mail-wr1-x443.google.com with SMTP id d15so15863905wrx.3
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:24 -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=K+3HsDks+0tT66AQvVMTEYvUPczxbhrS//Om9DkLMUs=;
 b=NsWRpOLD61K+D0tNwexd04gF9oWZKnX6barC+lIDPF5SFQ2LUaL1OkALPhGcDrIHT+
 FaddeOpdQYUo9p7XtVR/5u+WseKOS25WZwZVjW596Df4lt21x5CyEbw6liI32xszhpOx
 wlYtuJGFbuzklMHLv0SZrCy5DdX8j/kdp68fwZ90yEQfrXAxiZi2CA0mDjLYTkAjwwFo
 PPaZ+xdytGC0STfQAkaiY/tx40fSyYCUGYSN/Cay4qD/XNgrPY1W+czfuL5RYKKg0gRU
 cbWYcWS7ebvEWMY5JAosCMqj83fHZXsDKT+WiF78HDOeMmZ8+Fy20LQM37Fy+L02EbM9
 JrPw==
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=K+3HsDks+0tT66AQvVMTEYvUPczxbhrS//Om9DkLMUs=;
 b=Fq84z6DBpGF4GW7Opi1p+6/oE4e3t1d03lAHiQ78xiFg8Yfbw3FBJ90E1KG3cA+1LI
 4vs9agAzQqeW6DENcZGx1RBncbn2fRKQMoIJxnK8icpOI/34HtIfczB8lQHSQlbMVhmS
 r4nvXLT3szdmFq7FTNEk55IpvjLQZ/6Z2R//c5/Aflp72Ay2x2evckldj5J0bdsrG8f5
 /Z8EbaDFuAj1tARf3yqBGHgXK/76E+oncb0YRYwToMEOsQ9qylfydUBnM65zm5cFQjEd
 M2YgswFY5A+gyz8RnEcaqIWjjQbJ6rwzEYzYej6gHVOSmxN9e5DXAE2khYcfRxIJwbvY
 CJxQ==
X-Gm-Message-State: AGi0PuZ9lhnXK9rLU0TJytt41nKv11Mb/vPLBo2W8qmkLbc2fDdOaoXu
 gWmKLCGiI1aHiWretlGZpGJiq+cL0Eo=
X-Google-Smtp-Source: APiQypKD40Q2WxHuB4s1c77Wl5UHiDo7tyMYZWifUtRowKs9oUiK1Cro8bmkR63R5fA8hnA6VXsV9g==
X-Received: by 2002:a5d:694a:: with SMTP id r10mr10364830wrw.228.1588443743676; 
 Sat, 02 May 2020 11:22:23 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.22
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:23 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 03/11] lib/vfscore: Register `utimes` to syscall_shim
Date: Sat,  2 May 2020 21:18:27 +0300
Message-Id: <20200502181835.6724-3-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `utimes` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 13 ++++++++-----
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index aea4470..c2064d9 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -44,4 +44,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fchdir-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup3-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup2-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pwritev-4
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pwritev-4
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += utimes-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index b54a6a1..44ff969 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -161,6 +161,8 @@ futimesat
 utimensat
 futimens
 utimes
+uk_syscall_e_utimes
+uk_syscall_r_utimes
 lutimes
 posix_fadvise
 scandir
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 3edcd49..51417b9 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -1931,21 +1931,24 @@ static int do_utimes(const char *pathname, const struct timeval times[2], int fl
 
 	error = task_conv(t, pathname, 0, path);
 	if (error) {
-		trace_vfs_utimes_err(error);
-		return libc_error(error);
+		goto out_error;
 	}
 
 	error = sys_utimes(path, times, flags);
 	if (error) {
-		trace_vfs_utimes_err(error);
-		return libc_error(error);
+		goto out_error;
 	}
 
 	trace_vfs_utimes_ret();
 	return 0;
+
+	out_error:
+	trace_vfs_utimes_err(error);
+	return -error;
 }
 
-int utimes(const char *pathname, const struct timeval times[2])
+UK_SYSCALL_R_DEFINE(int, utimes, const char*, pathname,
+	const struct timeval*, times)
 {
 	return do_utimes(pathname, times, 0);
 }
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:22:35 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:22: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 1jUwmZ-0004vS-Id; Sat, 02 May 2020 18:22:35 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwmY-0004vE-Bc
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:22:34 +0000
X-Inumbo-ID: df64013c-8ca1-11ea-9887-bc764e2007e4
Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id df64013c-8ca1-11ea-9887-bc764e2007e4;
 Sat, 02 May 2020 18:22:25 +0000 (UTC)
Received: by mail-wm1-x344.google.com with SMTP id y24so3926472wma.4
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:25 -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=YpfjQIGzI7ha8jVmvkzMJFtlBydIrfGpD6cz1IDHkHk=;
 b=kOIvmnnVPpzLoB6XWEKHTYmLBBKC+k94LCdQ4DIrhaeJ4qVCCDU+IOHcQFc41oOGwo
 B7zFPCdzsDzMjwW67uHRUxFjEPGpjq8UJvabIkDpV4a0ftCnhFoN9ent+tbJDcutKUen
 5IYDo7o7i14xnR+6WcRsXwWXLXdXTuqkXwgEmp4EjhfY5Y4Lr2w4O++FWyRCT13cjU44
 AqGuGay9YdyNqhM4dm9bKoaTjrjHxxjvkeN82k4NDuorppNjaEKCNm2hGw977CEz+xy6
 v/e+yc3fkogbZtz6UJ3+0Bf35BdbChxqEogCM/TwDu/vJmPk7XXPzQkA9yFhZIBhG9kR
 iLqQ==
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=YpfjQIGzI7ha8jVmvkzMJFtlBydIrfGpD6cz1IDHkHk=;
 b=PfLKkmMjMQZ2E16O3MA9VqkR20dZ6QjtIMgvNpLgwjSN9tjAJRFWEfHPMScb/fIadM
 eWpPWO1kPRojPQipmVyHbrBPbH1BtMsjDEUCL2ss3SC8p4M891zErTUotEmiqeOu9bO5
 Zw94tHMcj/EI84MWL1VNU5yV0Bms4anomdDJ5Q9fjpEBusB11GZJ2tZW0zI4+F/izKyx
 CyFzq1Lanq25oYrZ/L75ZnVcKZXQrjmM83xsAI+ranYQKOYa+G7Z3TycW99dEqT0VkEk
 s8jMdVxaauAJS5yq3FL2ysZqs9gjl/tgJNKuG0qIjlOuK5QC6jDy7G9TkiB6Aqkg2+HI
 oK/g==
X-Gm-Message-State: AGi0PubjLbCarhWxhh6ITYip08M0G7y9qCtApOyhwcFA2jw/Sd8eytuI
 cT057GspzMwSLxsnNI5yusIlIcCN6IA=
X-Google-Smtp-Source: APiQypJo4OBwFgA/74y2QOoE6ausoA8I88zZCb/qNL4BkaTP2jXH2ccl98noMl0nHeUBx3j3zhSz1A==
X-Received: by 2002:a7b:c772:: with SMTP id x18mr5990721wmk.39.1588443744766; 
 Sat, 02 May 2020 11:22:24 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.23
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:24 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 04/11] lib/vfscore: Register `mknod` to syscall_shim
Date: Sat,  2 May 2020 21:18:28 +0300
Message-Id: <20200502181835.6724-4-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `mknod` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 12 +++++-------
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index c2064d9..45d3bcb 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -45,4 +45,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup3-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup2-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pwritev-4
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += utimes-2
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += utimes-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mknod-3
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 44ff969..67f3fa8 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -89,6 +89,8 @@ truncate
 uk_syscall_e_truncate
 uk_syscall_r_truncate
 mknod
+uk_syscall_e_mknod
+uk_syscall_r_mknod
 preadv
 ioctl
 fdatasync
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 51417b9..d9496bf 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -237,27 +237,25 @@ int __xmknod(int ver, const char *pathname, mode_t mode, dev_t *dev __unused)
 
 	trace_vfs_mknod(pathname, mode, *dev);
 	if ((error = task_conv(t, pathname, VWRITE, path)) != 0)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_mknod(path, mode);
 	if (error)
-		goto out_errno;
+		goto out_error;
 
 	trace_vfs_mknod_ret();
 	return 0;
 
-	out_errno:
+	out_error:
 	trace_vfs_mknod_err(error);
-	errno = error;
-	return -1;
+	return -error;
 }
 
-int mknod(const char *pathname, mode_t mode, dev_t dev)
+UK_SYSCALL_R_DEFINE(int, mknod, const char*, pathname, mode_t, mode, dev_t, dev)
 {
 	return __xmknod(0, pathname, mode, &dev);
 }
 
-
 UK_TRACEPOINT(trace_vfs_lseek, "%d 0x%x %d", int, off_t, int);
 UK_TRACEPOINT(trace_vfs_lseek_ret, "0x%x", off_t);
 UK_TRACEPOINT(trace_vfs_lseek_err, "%d", int);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:22:40 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:22: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 1jUwme-0004wo-KT; Sat, 02 May 2020 18:22: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=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwmd-0004wc-Ai
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:22:39 +0000
X-Inumbo-ID: dffade0e-8ca1-11ea-9887-bc764e2007e4
Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id dffade0e-8ca1-11ea-9887-bc764e2007e4;
 Sat, 02 May 2020 18:22:26 +0000 (UTC)
Received: by mail-wm1-x342.google.com with SMTP id k12so3656903wmj.3
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:26 -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=gi+jL9jIY4OvKmSm6XstKZLO1gUDnaFQ+m4paZmaUvE=;
 b=YfefhcvIFSWI/HJPgYbZV4auKC/0xZ+GL9Ptgtt/pKkpgpO8sXOS8YMe7eunE8jPq9
 ySDR+uJ270nsiQTyd4yn8K/o5HWcPehw6aO9XfHRdkgkrSOKJrgtnu0rpoytFLtL75FS
 khOeugWXEds6WrYyam7l6/5fKPtVd8Rdp04btZOT4FX6OeXsdt2sK1PCBcSqz+jKJmkd
 mGhsXNVTgMsnjLufcSyMaDpWLkQ/U14gtpKzS9SD3Fh6d2EHY57ZC7wRBlLIUyke92Y7
 3+cs4TdF154b1ED+A/IBuU9DG78eKmjFDt7llHCkj9m5VErIHxa31J+j2rUeFsNt66Gn
 JWBA==
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=gi+jL9jIY4OvKmSm6XstKZLO1gUDnaFQ+m4paZmaUvE=;
 b=KDnEojhCh5Mdvl9QRUQawnL8nzPSOhl1bq2JaybLZbY8VoPH88xvf0VEU/WyNJjqTX
 VJQz34+YbEzcNKaSNws+T9QaWQKC7pdLqMkM46xOtU2wJ3F00AvwRWMUE9Eubg+wG6bv
 VIhDYWTwajR6mGNH25RAhYTnftO34OUqJJWu0AkDz5yIj2PaH3K2LQYoJKCGYYnKAkzs
 SNQq5SHb4l5CX/kMlj98mNyO+5Pu34QCn2ZSGx+iu5lR4Zd/Yuvaij7w26x3kGmJEwFT
 qQgg/XSXhXJF1KB87EK+QKevhKlT1X8Z02YYlZjmdqbgrpcevjMlMW0hGVQA44wuopDE
 drrQ==
X-Gm-Message-State: AGi0PuZMfqec1CIZc4NbGwbuc6r+IUYt/AX9v1yIUC489JA19t2o8IBe
 KHA6sXNJdtKa0Phfk5ISN7EPFqBjJ2Q=
X-Google-Smtp-Source: APiQypKhNRZRAIxbrYkPyWIVdrkFsfWv0pE227Ove1uj4FuHyQ//y3jdu1WPK4m1wrKiWZqGfsqsNg==
X-Received: by 2002:a1c:1bcb:: with SMTP id b194mr5971254wmb.4.1588443745734; 
 Sat, 02 May 2020 11:22:25 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.24
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:25 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 05/11] lib/vfscore: Register `rmdir` to syscall_shim
Date: Sat,  2 May 2020 21:18:29 +0300
Message-Id: <20200502181835.6724-5-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `rmdir` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 14 +++++++-------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 45d3bcb..56d3e4f 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -46,4 +46,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup3-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup2-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pwritev-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += utimes-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mknod-3
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mknod-3
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rmdir-1
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 67f3fa8..d615eb8 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -100,6 +100,8 @@ rewinddir
 telldir
 seekdir
 rmdir
+uk_syscall_e_rmdir
+uk_syscall_r_rmdir
 fchdir
 uk_syscall_e_fchdir
 uk_syscall_r_fchdir
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index d9496bf..b0af047 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -879,7 +879,7 @@ UK_TRACEPOINT(trace_vfs_rmdir, "\"%s\"", const char*);
 UK_TRACEPOINT(trace_vfs_rmdir_ret, "");
 UK_TRACEPOINT(trace_vfs_rmdir_err, "%d", int);
 
-int rmdir(const char *pathname)
+UK_SYSCALL_R_DEFINE(int, rmdir, const char*, pathname)
 {
 	struct task *t = main_task;
 	char path[PATH_MAX];
@@ -888,19 +888,19 @@ int rmdir(const char *pathname)
 	trace_vfs_rmdir(pathname);
 	error = ENOENT;
 	if (pathname == NULL)
-		goto out_errno;
+		goto out_error;
 	if ((error = task_conv(t, pathname, VWRITE, path)) != 0)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_rmdir(path);
 	if (error)
-		goto out_errno;
+		goto out_error;
 	trace_vfs_rmdir_ret();
 	return 0;
-	out_errno:
+
+	out_error:
 	trace_vfs_rmdir_err(error);
-	errno = error;
-	return -1;
+	return -error;
 }
 
 static void
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:22:45 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:22: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 1jUwmj-0004xi-ME; Sat, 02 May 2020 18:22: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=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwmi-0004xY-BY
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:22:44 +0000
X-Inumbo-ID: e0a0ba4a-8ca1-11ea-b07b-bc764e2007e4
Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e0a0ba4a-8ca1-11ea-b07b-bc764e2007e4;
 Sat, 02 May 2020 18:22:27 +0000 (UTC)
Received: by mail-wm1-x341.google.com with SMTP id r26so3939423wmh.0
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:27 -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=5oES3Sx9zUvAtTa8m99aH3P+Fku5E7v8Kl3w5Etefnw=;
 b=C1H7C+sx31/H9V0o2Axb9OxhbwxEQG13SYQxCu3diwBu+fW8KMyKFLzuCmsaxr38tE
 GwAyJW6BXxLqSsG5eaNsGLtx5JKKvxsT9U5l8C1jnOcAELPAxqgeyldK/WsacY5hwIe1
 3XO6GPJQAFwUiyQI8R80OHqD3rfSu5p76jtLV25uLFfQXk1zPf2Uyx7Z8JcxYaH26O4+
 6ptNuRdNhN6xcSBnEzJ29BRlR3tFblKfpT0WJDwzZ14JZdTmJAcHolWMJwMphUFjDKCw
 gfseU+7j9mnTeAu/3gnEWk1WlOJSNEfR/V+Owpbrd+U2w8bILfVaBF/es7FA+FkFO+kC
 ZPiQ==
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=5oES3Sx9zUvAtTa8m99aH3P+Fku5E7v8Kl3w5Etefnw=;
 b=FaCAo6B+2hKsp4fYNFd8XzA82LpgxIt9mrAxiGAa37POU/c9//5PTmqzM/9kqdmv3Z
 x2+CkEmtPRTN43kM6+TPyZH14IHGOStLwbYi35xTGGkNflLlFDEo25IiLkFzsCuI32Eg
 BRHw24mD8zhqWERCHlPN2S1xIwp6zV8FK/BVZh3irX6IRjP5w/ruKkhPHraCsf7lnu9I
 w6XLDwSHPIN7usjCVkNrMJ7jUJJaUE/55/D/lQ8BQE3cJQlDgtOitHTexY3QUwYNhV1I
 cxpjK3cyCSUJV7Qzd8eunkNVPAHdKj5VZVxq/cwFyNmJVjD6gqkFTMhKLarOHbiKLiml
 itaQ==
X-Gm-Message-State: AGi0PuZv8pfXeYfcayQlABfF4IN8nKBCUIq8ALM8+Cl1+kGlnNEgRsgR
 k/F6be0UnvEyNkX6ZmOrCGUxZzAbpJg=
X-Google-Smtp-Source: APiQypK9aILaP2tmWLVTKYBANEJGqLy8Mi2Rd0FeTXTgGF1xILreY3QozMqnoaWDKjlHQmVuvMTp9g==
X-Received: by 2002:a05:600c:1:: with SMTP id g1mr5549696wmc.142.1588443746863; 
 Sat, 02 May 2020 11:22:26 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.25
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:26 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 06/11] lib/vfscore: Register `rename` to syscall_shim
Date: Sat,  2 May 2020 21:18:30 +0300
Message-Id: <20200502181835.6724-6-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `rename` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 20 ++++++++++----------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 56d3e4f..63fc806 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -47,4 +47,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup2-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pwritev-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += utimes-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mknod-3
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rmdir-1
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rmdir-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rename-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index d615eb8..4a8a4f4 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -144,6 +144,8 @@ fstatfs
 eaccess
 euidaccess
 rename
+uk_syscall_e_rename
+uk_syscall_r_rename
 __xmknod
 __xstat
 __lxstat
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index b0af047..41c81f5 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -932,7 +932,7 @@ UK_TRACEPOINT(trace_vfs_rename, "\"%s\" \"%s\"", const char*, const char*);
 UK_TRACEPOINT(trace_vfs_rename_ret, "");
 UK_TRACEPOINT(trace_vfs_rename_err, "%d", int);
 
-int rename(const char *oldpath, const char *newpath)
+UK_SYSCALL_R_DEFINE(int, rename, const char*, oldpath, const char*, newpath)
 {
 	trace_vfs_rename(oldpath, newpath);
 	struct task *t = main_task;
@@ -942,35 +942,35 @@ int rename(const char *oldpath, const char *newpath)
 
 	error = ENOENT;
 	if (null_or_empty(oldpath) || null_or_empty(newpath))
-		goto out_errno;
+		goto out_error;
 
 	get_last_component(oldpath, src);
 	if (!strcmp(src, ".") || !strcmp(src, "..")) {
 		error = EINVAL;
-		goto out_errno;
+		goto out_error;
 	}
 
 	get_last_component(newpath, dest);
 	if (!strcmp(dest, ".") || !strcmp(dest, "..")) {
 		error = EINVAL;
-		goto out_errno;
+		goto out_error;
 	}
 
 	if ((error = task_conv(t, oldpath, VREAD, src)) != 0)
-		goto out_errno;
+		goto out_error;
 
 	if ((error = task_conv(t, newpath, VWRITE, dest)) != 0)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_rename(src, dest);
 	if (error)
-		goto out_errno;
+		goto out_error;
 	trace_vfs_rename_ret();
 	return 0;
-	out_errno:
+
+	out_error:
 	trace_vfs_rename_err(error);
-	errno = error;
-	return -1;
+	return -error;
 }
 
 UK_TRACEPOINT(trace_vfs_chdir, "\"%s\"", const char*);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:22:50 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:22:50 +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 1jUwmo-0004yk-Nz; Sat, 02 May 2020 18:22: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=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwmn-0004ya-Bo
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:22:49 +0000
X-Inumbo-ID: e12d3dda-8ca1-11ea-9887-bc764e2007e4
Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e12d3dda-8ca1-11ea-9887-bc764e2007e4;
 Sat, 02 May 2020 18:22:28 +0000 (UTC)
Received: by mail-wm1-x344.google.com with SMTP id k12so3656956wmj.3
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:28 -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=02lBu0drKeAxwHRM9onBqol7IezB8vjUdPORDunfCAE=;
 b=cgBr7EyJWn7OOvskdBILauo053OXe3q5ztHGUlp4252T5Ce79G/TBVpbP5cgdKLznw
 A27bWGGxUqwLcrPqUM/dVwmD6IX5dGC33ZtOMzr6S2my2Emq2SFIDtgSYa2npghDGfL0
 NNZcKeeRc8vRqc6L1tk6dlPT9pGwDGDJkWz8GzgY6m6CZ8BN5mYmJE5h7bGNBlf/gYLO
 vRJMb4IWF2lL0Gl26s6vk3qq82ZXxETH101POOx1Be7aVhTSM0nm9h5V7gJvKWfF7APU
 Ae5UWJP1oAJFlUHOrCprqJGcB6X4vktW9Og6NxreafTsCpyFqGL5gRR6kHvFSCv4BD7Z
 BQeA==
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=02lBu0drKeAxwHRM9onBqol7IezB8vjUdPORDunfCAE=;
 b=GmU4CkLFwX7g3vC2lOPPbwJqEXHoDkZZjAGlnX3PjBh/0/B21ll8RxnB0c23FggSWi
 ntd76D+xWnbf2rRZ3mv3IkGM1nAcy2MuUKTihrE4ngksRXkT2Uhbq6M9UEmHsk6X08tA
 n7G6Gc1Ps2MIAByBWiPnB3+ij69wCle6HtaZmDJ8uBonfwETxaNVVca7+SRj92TSs6+C
 Cj6R+WVGdZG2CHcSXe5BzrEXzvdWBgNYjoRhlgdF9w6vheBU43nCRjodNVqPF6uCJbIi
 JNpGFxOcftueWBNH2m2Fwee8UVh7YWLHWKH0ABXyWnxuwK7apcy8DBPKIlzXYfcH/osQ
 HNKw==
X-Gm-Message-State: AGi0PuYOJW/ItfvrIbJmNihq5Tej6luM41CnnygFAzXyGSEIaW8+kYwJ
 OviS1rE/RWmdRdkskzhC6d+bVMTzGvw=
X-Google-Smtp-Source: APiQypIUegwihvDE3MFWcDpuKaO9pOn5k7CIQ1scyGNIcbR0PaB9of5l9dwlk2Z/u+7mcPbQ2VH9Og==
X-Received: by 2002:a1c:6a08:: with SMTP id f8mr5401074wmc.132.1588443747815; 
 Sat, 02 May 2020 11:22:27 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.26
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:27 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 07/11] lib/vfscore: Register `fsync` and `fdatasync`
 to syscall_shim
Date: Sat,  2 May 2020 21:18:31 +0300
Message-Id: <20200502181835.6724-7-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `fsync` and `fdatasync` system calls to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  4 +++-
 lib/vfscore/exportsyms.uk |  4 ++++
 lib/vfscore/main.c        | 13 ++++++-------
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 63fc806..a643c03 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -48,4 +48,6 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pwritev-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += utimes-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mknod-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rmdir-1
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rename-2
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rename-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fsync-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fdatasync-1
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 4a8a4f4..d297957 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -25,6 +25,8 @@ uk_syscall_e_read
 uk_syscall_r_read
 mkdir
 fsync
+uk_syscall_e_fsync
+uk_syscall_r_fsync
 fstat
 uk_syscall_e_fstat
 uk_syscall_r_fstat
@@ -94,6 +96,8 @@ uk_syscall_r_mknod
 preadv
 ioctl
 fdatasync
+uk_syscall_e_fdatasync
+uk_syscall_r_fdatasync
 fdopendir
 dirfd
 rewinddir
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 41c81f5..25da26b 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -489,7 +489,7 @@ UK_TRACEPOINT(trace_vfs_fsync, "%d", int);
 UK_TRACEPOINT(trace_vfs_fsync_ret, "");
 UK_TRACEPOINT(trace_vfs_fsync_err, "%d", int);
 
-int fsync(int fd)
+UK_SYSCALL_R_DEFINE(int, fsync, int, fd)
 {
 	struct vfscore_file *fp;
 	int error;
@@ -497,23 +497,22 @@ int fsync(int fd)
 	trace_vfs_fsync(fd);
 	error = fget(fd, &fp);
 	if (error)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_fsync(fp);
 	fdrop(fp);
 
 	if (error)
-		goto out_errno;
+		goto out_error;
 	trace_vfs_fsync_ret();
 	return 0;
 
-	out_errno:
+	out_error:
 	trace_vfs_fsync_err(error);
-	errno = error;
-	return -1;
+	return -error;
 }
 
-int fdatasync(int fd)
+UK_SYSCALL_R_DEFINE(int, fdatasync, int, fd)
 {
 	// TODO: See if we can do less than fsync().
 	return fsync(fd);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:22:55 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:22:55 +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 1jUwmt-0004zr-RD; Sat, 02 May 2020 18:22:55 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwms-0004zg-Cd
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:22:54 +0000
X-Inumbo-ID: e1beaa7c-8ca1-11ea-b9cf-bc764e2007e4
Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e1beaa7c-8ca1-11ea-b9cf-bc764e2007e4;
 Sat, 02 May 2020 18:22:29 +0000 (UTC)
Received: by mail-wm1-x342.google.com with SMTP id r26so3939539wmh.0
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:29 -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=syGoLtOwEvMmZD4ZjngCd5FEKNGqs4eSg9spRGAuEtE=;
 b=LuX6drLpQp0mQbakW9FhEmK/3ppPEEDH917w1I7IDEcgWU5eTpIal4EeyO/6RS90Id
 lmwOXJ4d8tvVL6lUeL7HzBaF4GJlbRaJnIHVBLgUo2IHWnFKPPVcNUUi0htOomxO0C8I
 VJu9pQZEbqFou8SWVX0sWNAV0lp+klTMrUU9xyCop5+TN4/8TAGi8/+XzAfRQAAoE6bL
 7TANX9VWFJKmeLt+GBQHM+aH/BbUVt1HuPijSnS1qeK5+OkOp5iBUmXzdFFyCm4luE9b
 E72X/c+AjjxjZG6v3PLit33aeZvI98hCVZp5fYXVzkKzUp7aqOMZ05qlCqEau76Y+Xn7
 C0iw==
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=syGoLtOwEvMmZD4ZjngCd5FEKNGqs4eSg9spRGAuEtE=;
 b=nhUTu8ClEAX1kDungECmfd54yhDdNUefwb13VPppdaEfGoGIZZER5e4JdJZ5LmoNuH
 EGvVrLOi6oFrYB1BDqZBX5+7Jtphd8z3JmUJyOVcBYGnwhRDXY1z75S9hoYsb8OwZ4kK
 V88evIJ2wf1wINAuWgrtMPslyD0MOYllRPxPVJRGhmaKKtL/70g1ubInK6RZw61jnH6s
 m9HHJRNbnc6EAcHfDdtP6zac3mQzAI9zMZzXU11ex2MC1oJa3tYG2cM3yEu26fssu/d2
 12x8dD3MjZz8uZOHY1E0HCRvv8xxnD4J6GVPxjKRGPHy35gaKdvlK0WB6t92aAMfLNIa
 6HFQ==
X-Gm-Message-State: AGi0PuZToKcEuDpjmoTHlL3s6UbNvoBvtazcc1bLIQAeyPFEXK9riMG0
 gOHp3rqlOWO+hN7GIqmDL4tAhT1V4yA=
X-Google-Smtp-Source: APiQypJbJYVdgPCBlIU9EUqtBMrlgbCfw68QfXIFB6ye5YLaYW3kjvCglcoDvIj5a5SP52ue6HsF3A==
X-Received: by 2002:a1c:ab45:: with SMTP id u66mr5541549wme.152.1588443748765; 
 Sat, 02 May 2020 11:22:28 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.27
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:28 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 08/11] lib/vfscore: Register `preadv` to syscall_shim
Date: Sat,  2 May 2020 21:18:32 +0300
Message-Id: <20200502181835.6724-8-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `preadv` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 12 ++++++------
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index a643c03..5c64046 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -50,4 +50,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mknod-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rmdir-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rename-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fsync-1
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fdatasync-1
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fdatasync-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += preadv-4
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index d297957..46c7437 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -94,6 +94,8 @@ mknod
 uk_syscall_e_mknod
 uk_syscall_r_mknod
 preadv
+uk_syscall_e_preadv
+uk_syscall_r_preadv
 ioctl
 fdatasync
 uk_syscall_e_fdatasync
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 25da26b..e7b0e90 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -381,7 +381,8 @@ UK_SYSCALL_DEFINE(ssize_t, write, int, fd, const void *, buf, size_t, count)
 	return pwrite(fd, buf, count, -1);
 }
 
-ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
+UK_SYSCALL_R_DEFINE(ssize_t, preadv, int, fd, const struct iovec*, iov,
+	int, iovcnt, off_t, offset)
 {
 	struct vfscore_file *fp;
 	size_t bytes;
@@ -389,18 +390,17 @@ ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
 
 	error = fget(fd, &fp);
 	if (error)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_read(fp, iov, iovcnt, offset, &bytes);
 	fdrop(fp);
 
 	if (has_error(error, bytes))
-		goto out_errno;
+		goto out_error;
 	return bytes;
 
-	out_errno:
-	errno = error;
-	return -1;
+	out_error:
+	return -error;
 }
 
 LFS64(preadv);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:23:00 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:23: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 1jUwmy-00051j-Su; Sat, 02 May 2020 18:23: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=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwmx-00051X-Cf
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:22:59 +0000
X-Inumbo-ID: e2506930-8ca1-11ea-ae69-bc764e2007e4
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e2506930-8ca1-11ea-ae69-bc764e2007e4;
 Sat, 02 May 2020 18:22:30 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id d15so15864211wrx.3
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:30 -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=4l1C6DPlyAGAPF2maBFAhnYhPzwG1V/c6S0Ro2bUrpU=;
 b=DwDKKTcjoheuRiAU5x5eFxmiQqfUgiUijETLm47B87RlrOodITl6NlFPP1LGzUqZB5
 nqNGPQ5H8yJHDHksesF0o48+HtKftwx1JYr+k4mPc9roDKplt/DPExgXk/w3g24HTJvB
 wWI1hfuAxKRP9UiDiJNfCru0jgjXJ6duPaWeNfAq0jz/EJmeKzWUbYzlqP/QGmDSzm0a
 Ak/Xa6FIlg/Ml6SNkSJUWEB2Qdm0VkyZdR/rU79wGnOzSO6UFTtfJ+UnxvtRrckywPoK
 PNU/iEaVxUco65dkQEJwzomg4LSVxTQkxYfsrpfqBv4FDg5mSYsHF+V5onhMe/tuPw8B
 4f5g==
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=4l1C6DPlyAGAPF2maBFAhnYhPzwG1V/c6S0Ro2bUrpU=;
 b=NcVz4NZLpyLniU4BlNzN/5RRbIUuhKo0W29lHcls0nHJtoh56jp+uewirSDCFRLk87
 hetrwKnhlGWiqzK5mqqvh5eNuyDU8Zl2BLrxYqqNbEx0uNpbn9p+AGuNz5DQELtjo1fI
 en0uf764N0ChSEqNPAPl55iQTIeFluaSHMvDUgm+d6rCgHIr4JoYoK8TFl2Zc1JXgrga
 OA+zhx/6IPm1BehBy7po0JGoDFASIcOHSV2X0N/hMNwQ3JIxK48qn7tuI22LGA7nHbLX
 T45jP+1xiEH4w/kZZBaFKHLsQkotNo7fF/fkDsSe+AjqfT4BO/HDaUN2mg/zzJFh23gr
 3bDw==
X-Gm-Message-State: AGi0Pua0PisP/noYkgFs/HTpRjZ9bvcuHRewMc1pYlntsv79uf8Qo1g8
 3VnItyomYq4og0/hVnLcayq9SAmd5aI=
X-Google-Smtp-Source: APiQypIazfIALibDLjiWpnhIETk17laX0A8UaGv++I3U8Xrgb0ZM9a2KLrLbJLIORVAWP27SwyYd2Q==
X-Received: by 2002:adf:f24c:: with SMTP id b12mr10327208wrp.359.1588443749681; 
 Sat, 02 May 2020 11:22:29 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.28
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:29 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 09/11] lib/vfscore: Register `umask` to syscall_shim
Date: Sat,  2 May 2020 21:18:33 +0300
Message-Id: <20200502181835.6724-9-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `umask` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   | 3 ++-
 lib/vfscore/exportsyms.uk | 2 ++
 lib/vfscore/main.c        | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 5c64046..c7025bd 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -51,4 +51,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rmdir-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rename-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fsync-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fdatasync-1
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += preadv-4
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += preadv-4
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += umask-1
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 46c7437..b9c29b1 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -132,6 +132,8 @@ uk_syscall_r_lseek
 uk_syscall_e_writev
 uk_syscall_r_writev
 umask
+uk_syscall_e_umask
+uk_syscall_r_umask
 dentry_alloc
 dentry_init
 dentry_lookup
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index e7b0e90..18cf17c 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -2138,7 +2138,7 @@ int posix_fadvise(int fd __unused, off_t offset __unused, off_t len __unused,
 }
 LFS64(posix_fadvise);
 
-mode_t umask(mode_t newmask)
+UK_SYSCALL_R_DEFINE(mode_t, umask, mode_t, newmask)
 {
 	return ukarch_exchange_n(&global_umask, newmask);
 }
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:23:05 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:23: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 1jUwn3-00052g-UX; Sat, 02 May 2020 18:23: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=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwn2-00052T-Bp
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:23:04 +0000
X-Inumbo-ID: e2d9b744-8ca1-11ea-ae69-bc764e2007e4
Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e2d9b744-8ca1-11ea-ae69-bc764e2007e4;
 Sat, 02 May 2020 18:22:31 +0000 (UTC)
Received: by mail-wr1-x443.google.com with SMTP id d15so15864253wrx.3
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:31 -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=Vhdoc3X8kNigNqYL1M7BlJ2QSMXoSEullIJxIi2ceDs=;
 b=sde/JFZxOGz5+Halhi1C3SLqFtV/SpYujI2AJSz2XKdEugChhmKxSGAn6EbeM4rac9
 kpv6hyeJr1HFD6q9qup2SGVKyjibXb/tyuhPHJ5rbN3V+ZfjBFi/JNIWTnxsEehyh2a/
 e9LmV2nvMWbfkDXEqKTyE2W9tSUWFOXvGzUeR3TYmWhMPeZtAvjnna3st2ezX79ohSs+
 ThhF9UptLBJTEOggHauZ9UE/tjQJJcxZ118Xjl4LOQWfTqmOrATFJge3tp6EDr428ri2
 VlKVVcBJjcirIaKvZ1i/UCaLTT+hia9pkChZWHUpMoY5jVv57kaAGO68Bm7Itp8ypgY9
 xElA==
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=Vhdoc3X8kNigNqYL1M7BlJ2QSMXoSEullIJxIi2ceDs=;
 b=n2OxoQcNEhhw2FX9Xnnn34MxHQtkCZpbZ7ImhqMNFqGzhxnFH7/l16xmdqxEOnBZlW
 5lZIZXkiTo712d3/7MOcl0SvY5ZdVMZaIOfXN26ZfE/Q5neAlXRHePb/Tz2NoXvYOsaN
 Sg0kVYaysgtp0qzzSs1vbheopKqnO8HAomdfqA80nOrMF4+t0y8sPwmvMWTVtPUGawae
 CA/9j8bfwGZRXbThYBfju/vLsPxuFNhAB00XsrihgdSQJjBU4JEKKxLkw0jw+8y+0HMA
 uEStDGc+CPd5bO+kzU9XvcdlANKvWz5f7ac23HgOySeZ+zGzQvN9AQpQIzLtkWJgqwvt
 HnNQ==
X-Gm-Message-State: AGi0PuYkN3WHJ5n0yG2tLqv14zBUWyadrn+QSE+ep+9XnYTiatJHNl/F
 NCh6uwDAuejFIUvda+ls9WMLc1bPDyE=
X-Google-Smtp-Source: APiQypL8FllkqKmzjUdvpvQcs4OYdHDo6degJW88S69L+LstcDaAzjKISoCZv7wGOo6k9u3o+wJPeg==
X-Received: by 2002:adf:dd83:: with SMTP id x3mr10158573wrl.298.1588443750627; 
 Sat, 02 May 2020 11:22:30 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.29
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:30 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 10/11] lib/vfscore: Register `lstat` to syscall_shim
Date: Sat,  2 May 2020 21:18:34 +0300
Message-Id: <20200502181835.6724-10-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `lstat` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 14 +++++++-------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index c7025bd..dfd33d6 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -52,4 +52,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rename-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fsync-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fdatasync-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += preadv-4
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += umask-1
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += umask-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += lstat-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index b9c29b1..6061c85 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -71,6 +71,8 @@ uk_syscall_r_chdir
 fstatat
 statfs
 lstat
+uk_syscall_e_lstat
+uk_syscall_r_lstat
 lchown
 openat
 opendir
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 18cf17c..8f955ff 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -1209,25 +1209,25 @@ int __lxstat(int ver __unused, const char *pathname, struct stat *st)
 
 	error = task_conv(t, pathname, 0, path);
 	if (error) {
-		errno = error;
-		trace_vfs_lstat_err(error);
-		return (-1);
+		goto out_error;
 	}
 
 	error = sys_lstat(path, st);
 	if (error) {
-		errno = error;
-		trace_vfs_lstat_err(error);
-		return (-1);
+		goto out_error;
 	}
 
 	trace_vfs_lstat_ret();
 	return 0;
+
+	out_error:
+	trace_vfs_lstat_err(error);
+	return -error;
 }
 
 LFS64(__lxstat);
 
-int lstat(const char *pathname, struct stat *st)
+UK_SYSCALL_R_DEFINE(int, lstat, const char*, pathname, struct stat*, st)
 {
 	return __lxstat(1, pathname, st);
 }
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 02 18:23:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 02 May 2020 18:23: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 1jUwn8-00053f-W3; Sat, 02 May 2020 18:23:10 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=N59r=6Q=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jUwn7-00053Q-CA
 for minios-devel@lists.xen.org; Sat, 02 May 2020 18:23:09 +0000
X-Inumbo-ID: e3e9f86a-8ca1-11ea-9887-bc764e2007e4
Received: from mail-wr1-x444.google.com (unknown [2a00:1450:4864:20::444])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e3e9f86a-8ca1-11ea-9887-bc764e2007e4;
 Sat, 02 May 2020 18:22:33 +0000 (UTC)
Received: by mail-wr1-x444.google.com with SMTP id h9so5515995wrt.0
 for <minios-devel@lists.xen.org>; Sat, 02 May 2020 11:22:33 -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=7YS6inZ1rhroSTZ/kmpJTarGVWBpk79j0gi1jyqa2xA=;
 b=rT8EeWjts2hb2PfkD2lwBxZHRx8NKRNA0kNLQiLbs6x/BCt02oGPWVxN7mgWPTD6/4
 0uSHiR50iOk+TaY33hJdmCm/Uk1BH7SbL3Y+NNklmpWiBH75Il7VfeRsLIF7wPwiDcS4
 eDRiEZzrzhRfrep/AngeeWzhhawTzglCVf2D9M/Edj2NihrEEuHBsCW/e2jR8F2xlALB
 M9ERkT3Pd7ZhjTDFl9ZfJKejkJB9y74L+l+b7zTUU+xbap1Ie2Pon8A/hb8lhOHojihE
 h1PRJbWA0KSgp15qxeW9363psbcV4d7hIeIs93GUYQjkmaTqyUF43C/MI6w5I0gUFv1W
 d2gA==
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=7YS6inZ1rhroSTZ/kmpJTarGVWBpk79j0gi1jyqa2xA=;
 b=D7mZtr6ma290WySLE+NZj+qL5U9OcpdeEZggif59zMJVewA+xbgPSgcmXPKDs7+2xg
 qMWJxGaOu1D6V4uv49lMnws5SOiOyuIYygmk8HZHybqX38jCzNbS8aVrD+uydD9CHEre
 4du8VkMK5wr4eeC9k6v1avPCzt0In3JxjYWWGpzwQSEkn2+NOltZ360JtimGmRQCn2tT
 7U+X/vFaJhttTTOv72h7IXcDFT+TXzY3TxnIslAXS09JETlVIMwI+wB2AegoVNjrIVDf
 /fuLJWfG1ldlFvdLu8Px09LkH3G55hH92OTVMsSszbZdGtlai6JGBsAFa2oS6hY0R32m
 e4pg==
X-Gm-Message-State: AGi0PuaKVSqWfitHqcHv3tJYzdxuV/heQGjzLmgcgvLfm1v4335Jv2oG
 i5mRuUuJqKCJFihZO0LziQCwu9ruZQY=
X-Google-Smtp-Source: APiQypIgvvzmLRSk642FkGO0Sn0souizdDOtNVB73Bi18G3aSW/904Z6XsqFl5Wxqc5cZVUEHMdJNA==
X-Received: by 2002:adf:d088:: with SMTP id y8mr9761475wrh.23.1588443751537;
 Sat, 02 May 2020 11:22:31 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id g6sm10650683wrw.34.2020.05.02.11.22.30
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 02 May 2020 11:22:31 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 11/11] lib/vfscore: Register `flock` to syscall_shim
Date: Sat,  2 May 2020 21:18:35 +0300
Message-Id: <20200502181835.6724-11-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200502181835.6724-1-raducanu.costi@gmail.com>
References: <20200502181835.6724-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `flock` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 12 +++++++++---
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index dfd33d6..e7f327a 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -53,4 +53,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fsync-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fdatasync-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += preadv-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += umask-1
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += lstat-2
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += lstat-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += flock-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 6061c85..20595e1 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -31,6 +31,8 @@ fstat
 uk_syscall_e_fstat
 uk_syscall_r_fstat
 flock
+uk_syscall_e_flock
+uk_syscall_r_flock
 fhold
 fdrop
 fget
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 8f955ff..746dd7f 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -605,12 +605,14 @@ int fstatat(int dirfd, const char *path, struct stat *st, int flags)
 
 LFS64(fstatat);
 
-int flock(int fd, int operation)
+UK_SYSCALL_R_DEFINE(int, flock, int, fd, int, operation)
 {
 	struct vfscore_file *file;
+	int error;
 
 	if (!fget(fd, &file)) {
-		return libc_error(EBADF);
+		error = EBADF;
+		goto out_error;
 	}
 
 	switch (operation) {
@@ -621,10 +623,14 @@ int flock(int fd, int operation)
 	case LOCK_UN:
 		break;
 	default:
-		return libc_error(EINVAL);
+		error = EINVAL;
+		goto out_error;
 	}
 
 	return 0;
+
+	out_error:
+	return -error;
 }
 
 UK_TRACEPOINT(trace_vfs_readdir, "%d %p", int, struct dirent*);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon May 04 09:18:16 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 04 May 2020 09:18: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 1jVXEr-0005Xf-Ly; Mon, 04 May 2020 09:18: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=vslG=6S=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jVXEr-0005Xa-9K
 for minios-devel@lists.xen.org; Mon, 04 May 2020 09:18:13 +0000
X-Inumbo-ID: 2c891faa-8de8-11ea-ae69-bc764e2007e4
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 2c891faa-8de8-11ea-ae69-bc764e2007e4;
 Mon, 04 May 2020 09:18:11 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 66D1EF2029;
 Mon,  4 May 2020 11:18:10 +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 TVM-MdbG19GR; Mon,  4 May 2020 11:18:10 +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 3A232F2017
 for <minios-devel@lists.xen.org>; Mon,  4 May 2020 11:18:08 +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.1713.5; Mon, 4 May 2020
 11:18:07 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
Subject: [UNIKRAFT PATCH] lib/ukdebug: asmdump: Stop on decoding errors
Date: Mon, 4 May 2020 11:18:05 +0200
Message-ID: <20200504091805.6726-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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Checks for errors that may occur during instruction decoding with
libzydis.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukdebug/asmdump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/ukdebug/asmdump.c b/lib/ukdebug/asmdump.c
index f73b0d65..7f992930 100644
--- a/lib/ukdebug/asmdump.c
+++ b/lib/ukdebug/asmdump.c
@@ -76,7 +76,8 @@ static int _asmdump(struct out_dev *o,
 
 	while (count) {
 		addr = ((__uptr) instr) + offset;
-		ZydisDecoderDecodeBuffer(&dcr, (const void *) addr, 16, &ins);
+		if (!ZYAN_SUCCESS(ZydisDecoderDecodeBuffer(&dcr, (const void *) addr, 16, &ins)))
+			break;
 		ZydisFormatterFormatInstruction(&fmt, &ins, buf, sizeof(buf),
 						addr);
 		ret = outf(o, "%08"__PRIuptr" <+%d>: %hs\n", addr, offset, buf);
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 04 09:49:29 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 04 May 2020 09:49: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 1jVXj5-0008ET-Ug; Mon, 04 May 2020 09:49:27 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=vslG=6S=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jVXj3-0008EO-Uq
 for minios-devel@lists.xen.org; Mon, 04 May 2020 09:49:25 +0000
X-Inumbo-ID: 88cd38d8-8dec-11ea-ae69-bc764e2007e4
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 88cd38d8-8dec-11ea-ae69-bc764e2007e4;
 Mon, 04 May 2020 09:49:24 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 23791F2029;
 Mon,  4 May 2020 11:49:23 +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 dOt4WWH8SJVH; Mon,  4 May 2020 11:49:23 +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 EDEDBF2017
 for <minios-devel@lists.xen.org>; Mon,  4 May 2020 11:49:20 +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.1713.5; Mon, 4 May 2020
 11:49:20 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
Subject: [UNIKRAFT PATCH] lib/ukdebug: uk_asmndumpd(), uk_asmndumpk()
Date: Mon, 4 May 2020 11:49:16 +0200
Message-ID: <20200504094916.8277-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: titania.office.hd (192.168.24.89) 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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Introduces uk_asmndumpd() and uk_asmndumpk(). They are a variant of
uk_asmdumpd() and uk_asmdumpk(). However, they take the number of bytes
instead of number of instructions as argument for the decoding range.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukdebug/asmdump.c            | 74 ++++++++++++++++++++++++++++++++
 lib/ukdebug/exportsyms.uk        |  2 +
 lib/ukdebug/include/uk/asmdump.h | 35 +++++++++++++++
 3 files changed, 111 insertions(+)

diff --git a/lib/ukdebug/asmdump.c b/lib/ukdebug/asmdump.c
index 7f992930..8001ca0c 100644
--- a/lib/ukdebug/asmdump.c
+++ b/lib/ukdebug/asmdump.c
@@ -91,6 +91,60 @@ static int _asmdump(struct out_dev *o,
 
 	return total;
 }
+
+/**
+ * Disassemble <len> bytes with zydis starting
+ * with instruction at <instr>
+ */
+static int _asmndump(struct out_dev *o,
+		     const void *instr, size_t len)
+{
+	ZydisDecoder dcr;
+	ZydisFormatter fmt;
+	ZydisDecodedInstruction ins;
+	char buf[128];
+	int offset = 0;
+	int ret, total = 0;
+	__uptr addr = (__uptr) instr;
+
+#if __X86_32__
+	if (!ZYAN_SUCCESS(ZydisDecoderInit(&dcr,
+					   ZYDIS_MACHINE_MODE_LONG_COMPAT_32,
+					   ZYDIS_ADDRESS_WIDTH_32)))
+		return -1;
+#elif __X86_64__
+	if (!ZYAN_SUCCESS(ZydisDecoderInit(&dcr,
+					   ZYDIS_MACHINE_MODE_LONG_64,
+					   ZYDIS_ADDRESS_WIDTH_64)))
+		return -1;
+#else
+#error libzydis: Unsupported architecture
+#endif
+
+	if (!ZYAN_SUCCESS(ZydisFormatterInit(&fmt,
+					     ZYDIS_FORMATTER_STYLE_ATT)))
+		return -1;
+
+	while (len) {
+		addr = ((__uptr) instr) + offset;
+		if (!ZYAN_SUCCESS(ZydisDecoderDecodeBuffer(&dcr,
+							   (const void *) addr,
+							   MIN(16u, len),
+							   &ins)))
+			break;
+		ZydisFormatterFormatInstruction(&fmt, &ins, buf, sizeof(buf),
+						addr);
+		ret = outf(o, "%08"__PRIuptr" <+%d>: %hs\n", addr, offset, buf);
+		if (ret < 0)
+			return ret;
+
+		total += ret;
+		offset += ins.length;
+		len -= ins.length;
+	}
+
+	return total;
+}
 #else /* CONFIG_LIBZYDIS */
 #error No supported disassembler backend available.
 #endif /* CONFIG_LIBZYDIS */
@@ -105,6 +159,16 @@ void _uk_asmdumpd(const char *libname, const char *srcname,
 	_asmdump(&o, instr, instr_count);
 }
 
+void _uk_asmndumpd(const char *libname, const char *srcname,
+		   unsigned int srcline, const void *instr,
+		   size_t len)
+{
+	struct out_dev o;
+
+	out_dev_init_debug(&o, libname, srcname, srcline);
+	_asmndump(&o, instr, len);
+}
+
 #if CONFIG_LIBUKDEBUG_PRINTK
 void _uk_asmdumpk(int lvl, const char *libname,
 		  const char *srcname, unsigned int srcline,
@@ -115,4 +179,14 @@ void _uk_asmdumpk(int lvl, const char *libname,
 	out_dev_init_kern(&o, lvl, libname, srcname, srcline);
 	_asmdump(&o, instr, instr_count);
 }
+
+void _uk_asmndumpk(int lvl, const char *libname,
+		   const char *srcname, unsigned int srcline,
+		   const void *instr, size_t len)
+{
+	struct out_dev o;
+
+	out_dev_init_kern(&o, lvl, libname, srcname, srcline);
+	_asmndump(&o, instr, len);
+}
 #endif /* CONFIG_LIBUKDEBUG_PRINTK */
diff --git a/lib/ukdebug/exportsyms.uk b/lib/ukdebug/exportsyms.uk
index f1e19900..6f001813 100644
--- a/lib/ukdebug/exportsyms.uk
+++ b/lib/ukdebug/exportsyms.uk
@@ -8,6 +8,8 @@ uk_hexdumpd
 _uk_hexdumpd
 _uk_hexdumpk
 _uk_asmdumpd
+_uk_asmndumpd
 _uk_asmdumpk
+_uk_asmndumpk
 uk_trace_buffer_free
 uk_trace_buffer_writep
diff --git a/lib/ukdebug/include/uk/asmdump.h b/lib/ukdebug/include/uk/asmdump.h
index a0468810..0bbefe0b 100644
--- a/lib/ukdebug/include/uk/asmdump.h
+++ b/lib/ukdebug/include/uk/asmdump.h
@@ -81,10 +81,22 @@ void _uk_asmdumpd(const char *libname, const char *srcname,
 #define uk_asmdumpd(instr, instr_count)					\
 	_uk_asmdumpd(__STR_LIBNAME__, __STR_BASENAME__,			\
 		     __LINE__, (instr), (instr_count))
+
+void _uk_asmndumpd(const char *libname, const char *srcname,
+		   unsigned int srcline, const void *instr,
+		   size_t len);
+
+#define uk_asmndumpd(instr, len)					\
+	_uk_asmndumpd(__STR_LIBNAME__, __STR_BASENAME__,		\
+		      __LINE__, (instr), (len))
 #else /* (defined UK_DEBUG) || CONFIG_LIBUKDEBUG_PRINTD */
 static inline void uk_asmdumpd(const void *instr __unused,
 			      unsigned int instr_count __unused)
 {}
+
+static inline void uk_asmndumpd(const void *instr __unused,
+				size_t len __unused)
+{}
 #endif
 
 #if CONFIG_LIBUKDEBUG_PRINTK
@@ -99,10 +111,25 @@ void _uk_asmdumpk(int lvl, const char *libname, const char *srcname,
 			_uk_asmdumpk((lvl), __STR_LIBNAME__, __STR_BASENAME__, \
 				     __LINE__, (instr), (instr_count));	\
 	} while (0)
+
+void _uk_asmndumpk(int lvl, const char *libname, const char *srcname,
+		   unsigned int srcline, const void *instr,
+		   size_t len);
+
+#define uk_asmndumpk(lvl, instr, len)					\
+	do {                                                            \
+		if ((lvl) <= KLVL_MAX)                                  \
+			_uk_asmdumpk((lvl), __STR_LIBNAME__, __STR_BASENAME__, \
+				     __LINE__, (instr), (len));		\
+	} while (0)
 #else /* CONFIG_LIBUKDEBUG_PRINTK */
 static inline void uk_asmdumpk(int lvl __unused, const void *instr __unused,
 			      unsigned int instr_count __unused)
 {}
+
+static inline void uk_asmndumpk(int lvl __unused, const void *instr __unused,
+				size_t len __unused)
+{}
 #endif /* CONFIG_LIBUKDEBUG_PRINTK */
 
 #else /* Backends */
@@ -114,10 +141,18 @@ static inline void uk_asmdumpd(const void *instr __unused,
 			       unsigned int instr_count __unused)
 {}
 
+static inline void uk_asmndumpd(const void *instr __unused,
+				size_t len __unused)
+{}
+
 #if CONFIG_LIBUKDEBUG_PRINTK
 static inline void uk_asmdumpk(int lvl __unused, const void *instr __unused,
 			       unsigned int instr_count __unused)
 {}
+
+static inline void uk_asmndumpk(int lvl __unused, const void *instr __unused,
+				size_t len __unused)
+{}
 #endif /* CONFIG_LIBUKDEBUG_PRINTK */
 
 #endif /* Backends */
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 04 09:56:32 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 04 May 2020 09:56:32 +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 1jVXpu-0000kh-5D; Mon, 04 May 2020 09:56:30 +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=vslG=6S=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jVXps-0000kc-VQ
 for minios-devel@lists.xen.org; Mon, 04 May 2020 09:56:29 +0000
X-Inumbo-ID: 851dec0e-8ded-11ea-9d0a-12813bfff9fa
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 851dec0e-8ded-11ea-9d0a-12813bfff9fa;
 Mon, 04 May 2020 09:56:27 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 8965910419E;
 Mon,  4 May 2020 11:56:26 +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 36hmDLl-FadL; Mon,  4 May 2020 11:56:26 +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 61819103C26
 for <minios-devel@lists.xen.org>; Mon,  4 May 2020 11:56:26 +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.1713.5; Mon, 4 May 2020
 11:56:26 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
Subject: [UNIKRAFT PATCH v2] lib/ukdebug: uk_asmdumpk(),
 uk_asmdumpn(): Stop decoding on errors
Date: Mon, 4 May 2020 11:56:20 +0200
Message-ID: <20200504095620.11015-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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Checks for errors that may occur during instruction decoding with
libzydis.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukdebug/asmdump.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/ukdebug/asmdump.c b/lib/ukdebug/asmdump.c
index f73b0d65..f860533c 100644
--- a/lib/ukdebug/asmdump.c
+++ b/lib/ukdebug/asmdump.c
@@ -43,7 +43,7 @@
 
 /**
  * Disassemble <num_ins> instructions with zydis starting
- * with instruction at <addr>
+ * with instruction at <instr>
  */
 static int _asmdump(struct out_dev *o,
 		   const void *instr, unsigned int count)
@@ -76,7 +76,10 @@ static int _asmdump(struct out_dev *o,
 
 	while (count) {
 		addr = ((__uptr) instr) + offset;
-		ZydisDecoderDecodeBuffer(&dcr, (const void *) addr, 16, &ins);
+		if (!ZYAN_SUCCESS(ZydisDecoderDecodeBuffer(&dcr,
+							   (const void *) addr,
+							   16, &ins)))
+			break;
 		ZydisFormatterFormatInstruction(&fmt, &ins, buf, sizeof(buf),
 						addr);
 		ret = outf(o, "%08"__PRIuptr" <+%d>: %hs\n", addr, offset, buf);
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 04 09:58:22 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 04 May 2020 09:58:22 +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 1jVXrh-0000q3-Ar; Mon, 04 May 2020 09:58:21 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=vslG=6S=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jVXrf-0000px-T2
 for minios-devel@lists.xen.org; Mon, 04 May 2020 09:58:19 +0000
X-Inumbo-ID: c79adde4-8ded-11ea-b9cf-bc764e2007e4
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c79adde4-8ded-11ea-b9cf-bc764e2007e4;
 Mon, 04 May 2020 09:58:19 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 02EFBF2029;
 Mon,  4 May 2020 11:58:18 +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 Joc0JRz8ew2v; Mon,  4 May 2020 11:58:17 +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 B2CE8F2017
 for <minios-devel@lists.xen.org>; Mon,  4 May 2020 11:58:15 +0200 (CEST)
Received: from [10.7.0.24] (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.1713.5; Mon, 4 May 2020
 11:58:15 +0200
Subject: Re: [UNIKRAFT PATCH] lib/ukdebug: asmdump: Stop on decoding errors
To: <minios-devel@lists.xen.org>
References: <20200504091805.6726-1-simon.kuenzer@neclab.eu>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <6fabe7c1-2e1f-d6b0-9abb-1724a666a54d@neclab.eu>
Date: Mon, 4 May 2020 11:58:02 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0)
 Gecko/20100101 Thunderbird/68.7.0
MIME-Version: 1.0
In-Reply-To: <20200504091805.6726-1-simon.kuenzer@neclab.eu>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Sorry, please ignore this patch. I sent a v2.

Thanks,

Simon

On 04.05.20 11:18, Simon Kuenzer wrote:
> Checks for errors that may occur during instruction decoding with
> libzydis.
> 
> Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
> ---
>   lib/ukdebug/asmdump.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/ukdebug/asmdump.c b/lib/ukdebug/asmdump.c
> index f73b0d65..7f992930 100644
> --- a/lib/ukdebug/asmdump.c
> +++ b/lib/ukdebug/asmdump.c
> @@ -76,7 +76,8 @@ static int _asmdump(struct out_dev *o,
>   
>   	while (count) {
>   		addr = ((__uptr) instr) + offset;
> -		ZydisDecoderDecodeBuffer(&dcr, (const void *) addr, 16, &ins);
> +		if (!ZYAN_SUCCESS(ZydisDecoderDecodeBuffer(&dcr, (const void *) addr, 16, &ins)))
> +			break;
>   		ZydisFormatterFormatInstruction(&fmt, &ins, buf, sizeof(buf),
>   						addr);
>   		ret = outf(o, "%08"__PRIuptr" <+%d>: %hs\n", addr, offset, buf);
> 


From minios-devel-bounces@lists.xenproject.org Mon May 04 23:35:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 04 May 2020 23:35: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 1jVkcL-00056F-Bx; Mon, 04 May 2020 23:35:21 +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=Z8GS=6S=upb.ro=vlad_andrei.badoiu@srs-us1.protection.inumbo.net>)
 id 1jVkcJ-000560-22
 for minios-devel@lists.xen.org; Mon, 04 May 2020 23:35:20 +0000
X-Inumbo-ID: e8622aec-8e5f-11ea-9d64-12813bfff9fa
Received: from mx.upb.ro (unknown [141.85.13.220])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id e8622aec-8e5f-11ea-9d64-12813bfff9fa;
 Mon, 04 May 2020 23:35:16 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 86591B5627BA;
 Tue,  5 May 2020 02:35:14 +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 3LNlyIA7wHOz; Tue,  5 May 2020 02:35:12 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 72777B5627BD;
 Tue,  5 May 2020 02:35:12 +0300 (EEST)
DKIM-Filter: OpenDKIM Filter v2.10.3 mx.upb.ro 72777B5627BD
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upb.ro;
 s=96342B8A-77E4-11E5-BA93-D93D0963A2DF; t=1588635312;
 bh=MRh4kHCBOfA0wEbHfopxNFOE2CFJgUkaoaO3+xlur7k=;
 h=From:To:Date:Message-Id:MIME-Version;
 b=QSaTsOLxAnqGRFazF8329CvjGMgV31NHTmYrp7SZXobdQFKHuuGvJyKMqmx6ZR3NN
 XrBqj0OA3bbRcZ7JEz9/HloEnrXqUHq3SsOibHD8uNYG6u0x0u5vlOXx8pLGyPy800
 FW4d6/8ZsMjlmggA5kzlPIgt84uvesWexdOVU0CE=
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 oG2-XzTMBY_x; Tue,  5 May 2020 02:35:12 +0300 (EEST)
Received: from localhost.localdomain (unknown [188.25.131.222])
 by mx.upb.ro (Postfix) with ESMTPSA id 2C36DB5627BA;
 Tue,  5 May 2020 02:35:12 +0300 (EEST)
From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v5 3/3] lib/ukboot: Initialize the canary value at
 boot
Date: Tue,  5 May 2020 02:35:06 +0300
Message-Id: <20200504233506.7573-4-vlad_andrei.badoiu@upb.ro>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200504233506.7573-1-vlad_andrei.badoiu@upb.ro>
References: <20200504233506.7573-1-vlad_andrei.badoiu@upb.ro>
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>
Cc: simon.kuenzer@neclab.eu,
 =?UTF-8?q?Vlad-Andrei=20B=C4=82DOIU=20=2878692=29?=
 <vlad_andrei.badoiu@stud.acs.upb.ro>,
 Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

From: Vlad-Andrei B=C4=82DOIU (78692) <vlad_andrei.badoiu@stud.acs.upb.ro=
>

We initialize the canary value right after all the internal libraries
have loaded.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
---
 lib/ukboot/boot.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/ukboot/boot.c b/lib/ukboot/boot.c
index e8a2ac79..3cdeb03b 100644
--- a/lib/ukboot/boot.c
+++ b/lib/ukboot/boot.c
@@ -61,6 +61,9 @@
 #ifdef CONFIG_LIBUKLIBPARAM
 #include <uk/libparam.h>
 #endif /* CONFIG_LIBUKLIBPARAM */
+#if CONFIG_LIBUKSP
+#include <uk/sp.h>
+#endif
=20
 int main(int argc, char *argv[]) __weak;
=20
@@ -185,6 +188,14 @@ void ukplat_entry(int argc, char *argv[])
 	struct uk_sched *s =3D NULL;
 	struct uk_thread *main_thread =3D NULL;
 #endif
+
+	/* We use a macro because if we were to use a function we
+	 * would not be able to return from the function if we have
+	 * changed the stack protector inside the function */
+#if CONFIG_LIBUKSP
+	UKSP_INIT_CANARY();
+#endif
+
 	uk_ctor_func_t *ctorfn;
=20
 	uk_pr_info("Unikraft constructor table at %p - %p\n",
--=20
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 04 23:35:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 04 May 2020 23:35: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 1jVkcL-00056A-Ag; Mon, 04 May 2020 23:35:21 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Z8GS=6S=upb.ro=vlad_andrei.badoiu@srs-us1.protection.inumbo.net>)
 id 1jVkcJ-000561-T4
 for minios-devel@lists.xen.org; Mon, 04 May 2020 23:35:20 +0000
X-Inumbo-ID: e89b3922-8e5f-11ea-9887-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e89b3922-8e5f-11ea-9887-bc764e2007e4;
 Mon, 04 May 2020 23:35:17 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 289E7B5627AF;
 Tue,  5 May 2020 02:35:16 +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 0_5l2tHFTWta; Tue,  5 May 2020 02:35:11 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 9D732B5627A3;
 Tue,  5 May 2020 02:35:11 +0300 (EEST)
DKIM-Filter: OpenDKIM Filter v2.10.3 mx.upb.ro 9D732B5627A3
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upb.ro;
 s=96342B8A-77E4-11E5-BA93-D93D0963A2DF; t=1588635311;
 bh=9KY9KLEN3cEVoSzHJL2iipqYqstxnFDFkYDSl0DZwKA=;
 h=From:To:Date:Message-Id:MIME-Version;
 b=c6fv2SnHVufNWI46gOEH1GH1qGUglHWWo2abn8BP8SMEZ3j7USUCJIaHfx+ye+Lum
 8Qx4R1h8vGBXMlOZDp17S6osTPI8/vRhPN7bEDwXxrJ8jSVeDdfJ5KJmX+mm5UXRXn
 ZFYSNtV3DN4scF0bRgLVEgBy2HscTGDuDEi0Yly4=
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 6x0mPigHR4ZY; Tue,  5 May 2020 02:35:11 +0300 (EEST)
Received: from localhost.localdomain (unknown [188.25.131.222])
 by mx.upb.ro (Postfix) with ESMTPSA id 552D8B5626D7;
 Tue,  5 May 2020 02:35:11 +0300 (EEST)
From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v5 0/3] lib/uksp: Introduce uksp library
Date: Tue,  5 May 2020 02:35:03 +0300
Message-Id: <20200504233506.7573-1-vlad_andrei.badoiu@upb.ro>
X-Mailer: git-send-email 2.20.1
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>
Cc: simon.kuenzer@neclab.eu, Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Currently, we provide a basic implementation of stack smashing
protection that has a global value for all threads. The value
can be either be randomly initialized at boot or precompiled.

Changes since v1:
* We now use a choice based config option for the stack protector level.
* Since
the last version we added the regulat and strong stack protector
options.

Changes since v2:
* Renamed the library to uksp

Changes since v3:
* Added config option for constant value/random source for the canary.
* Updated the config
* Updated library title
* Moved uksp/stackprotector.h to uk/sp.h
* Added current stack pointer to the crash message


Changes since v4:
* rebased over staging
* removed STACKPROTECTOR_NONE
* removed type on license
* __stack_chk_guard is now a const, we use the DECONST macro to change
its value
* renamed INIT_STACK_CANARY to UKSP_INIT_CANARY=20
* ukarch_read_sp() is now used to get the sp
* fixed several typos
* moved makefile build flags to patch 1
* added added a comment on why do we use a macro for initialization

Vlad-Andrei B=C4=82DOIU (78692) (3):
  lib/uksp: Introduce uksp library
  build: Add option to toggle the stack protection
  lib/ukboot: Initialize the canary value at boot

 Makefile.uk              |  6 ++++-
 lib/Makefile.uk          |  1 +
 lib/ukboot/boot.c        | 11 ++++++++
 lib/uksp/Config.uk       | 46 +++++++++++++++++++++++++++++++++
 lib/uksp/Makefile.uk     |  9 +++++++
 lib/uksp/exportsyms.uk   |  2 ++
 lib/uksp/include/uk/sp.h | 56 ++++++++++++++++++++++++++++++++++++++++
 lib/uksp/ssp.c           | 52 +++++++++++++++++++++++++++++++++++++
 8 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 lib/uksp/Config.uk
 create mode 100644 lib/uksp/Makefile.uk
 create mode 100644 lib/uksp/exportsyms.uk
 create mode 100644 lib/uksp/include/uk/sp.h
 create mode 100644 lib/uksp/ssp.c

--=20
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 04 23:35:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 04 May 2020 23:35: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 1jVkcO-00056t-DT; Mon, 04 May 2020 23:35:24 +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=Z8GS=6S=upb.ro=vlad_andrei.badoiu@srs-us1.protection.inumbo.net>)
 id 1jVkcN-00056W-RO
 for minios-devel@lists.xen.org; Mon, 04 May 2020 23:35:23 +0000
X-Inumbo-ID: e8c5045a-8e5f-11ea-9d64-12813bfff9fa
Received: from mx.upb.ro (unknown [141.85.13.240])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id e8c5045a-8e5f-11ea-9d64-12813bfff9fa;
 Mon, 04 May 2020 23:35:17 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 6C39FB5626D7;
 Tue,  5 May 2020 02:35:16 +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 aKm4j65F98_j; Tue,  5 May 2020 02:35:12 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id DED9FB5627B0;
 Tue,  5 May 2020 02:35:11 +0300 (EEST)
DKIM-Filter: OpenDKIM Filter v2.10.3 mx.upb.ro DED9FB5627B0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upb.ro;
 s=96342B8A-77E4-11E5-BA93-D93D0963A2DF; t=1588635311;
 bh=5k0n66mjQzqTEZYEBveprxYDY/SG7tfi0Gjg0KkZE1c=;
 h=From:To:Date:Message-Id:MIME-Version;
 b=CIRUG4CGZM8kEMVvPgHQZnrfkDT21CaUYhYWPjabnj/pe1Ngz94F5uTQ/8QWOFIOO
 5zZQk4exq0xH0iDLn1C46hX15pWRfuG25hp4WLbw99RLrya/rkBDZpUwDI1uVoG5wd
 qGgkqHU5N6OBx20e5FuMhYoiKKkbM5b8KFKOPsf4=
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 fGK3jkeEmAT7; Tue,  5 May 2020 02:35:11 +0300 (EEST)
Received: from localhost.localdomain (unknown [188.25.131.222])
 by mx.upb.ro (Postfix) with ESMTPSA id 8F3D6B56279A;
 Tue,  5 May 2020 02:35:11 +0300 (EEST)
From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v5 1/3] lib/uksp: Introduce uksp library
Date: Tue,  5 May 2020 02:35:04 +0300
Message-Id: <20200504233506.7573-2-vlad_andrei.badoiu@upb.ro>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200504233506.7573-1-vlad_andrei.badoiu@upb.ro>
References: <20200504233506.7573-1-vlad_andrei.badoiu@upb.ro>
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>
Cc: simon.kuenzer@neclab.eu,
 =?UTF-8?q?Vlad-Andrei=20B=C4=82DOIU=20=2878692=29?=
 <vlad_andrei.badoiu@stud.acs.upb.ro>,
 Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

From: Vlad-Andrei B=C4=82DOIU (78692) <vlad_andrei.badoiu@stud.acs.upb.ro=
>

This library provides the necessary functionalities for the stack
protector.

A make clean is required when toggling the stack smashing protection
option.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
---
 lib/Makefile.uk          |  1 +
 lib/uksp/Config.uk       | 46 +++++++++++++++++++++++++++++++++
 lib/uksp/Makefile.uk     |  9 +++++++
 lib/uksp/exportsyms.uk   |  2 ++
 lib/uksp/include/uk/sp.h | 56 ++++++++++++++++++++++++++++++++++++++++
 lib/uksp/ssp.c           | 52 +++++++++++++++++++++++++++++++++++++
 6 files changed, 166 insertions(+)
 create mode 100644 lib/uksp/Config.uk
 create mode 100644 lib/uksp/Makefile.uk
 create mode 100644 lib/uksp/exportsyms.uk
 create mode 100644 lib/uksp/include/uk/sp.h
 create mode 100644 lib/uksp/ssp.c

diff --git a/lib/Makefile.uk b/lib/Makefile.uk
index aa7e7302..c02a3c50 100644
--- a/lib/Makefile.uk
+++ b/lib/Makefile.uk
@@ -34,3 +34,4 @@ $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uktime)=
)
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukmmap))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukblkdev))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/posix-process))
+$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uksp))
diff --git a/lib/uksp/Config.uk b/lib/uksp/Config.uk
new file mode 100644
index 00000000..0881ddec
--- /dev/null
+++ b/lib/uksp/Config.uk
@@ -0,0 +1,46 @@
+config LIBUKSP
+	bool "uksp: Stack protector"
+	select HAVE_STACKPROTECTOR
+	default n
+
+if LIBUKSP
+choice
+	prompt "Stack protector level"
+	default STACKPROTECTOR_REGULAR
+	help
+	  Set the stack protector level
+
+config STACKPROTECTOR_REGULAR
+	bool "Regular"
+	help
+		Regular stack protector, use -fstack-protector.
+
+config STACKPROTECTOR_STRONG
+	bool "Strong"
+	help
+		Strong stack protector, use -fstack-protector-strong.
+
+config STACKPROTECTOR_ALL
+	bool "All"
+	help
+		Protect all functions, use -fstack-protector-all.
+endchoice
+
+choice
+	prompt "Canary Value"
+	default LIBUKSP_VALUE_USECONSTANT
+
+config LIBUKSP_VALUE_USECONSTANT
+	bool "Compiled-in constant"
+
+config LIBUKSP_VALUE_RANDOM
+	bool "Random variable"
+	select LIBUKSWRAND
+endchoice
+
+config LIBUKSP_VALUE_CONSTANT
+	int "Canary value"
+	depends on LIBUKSP_VALUE_USECONSTANT
+	default 42
+
+endif
diff --git a/lib/uksp/Makefile.uk b/lib/uksp/Makefile.uk
new file mode 100644
index 00000000..4e591231
--- /dev/null
+++ b/lib/uksp/Makefile.uk
@@ -0,0 +1,9 @@
+$(eval $(call addlib_s,libuksp,$(CONFIG_LIBUKSP)))
+
+CINCLUDES-y +=3D -I$(LIBUKSP_BASE)/include
+
+LIBUKSP_SRCS-y +=3D $(LIBUKSP_BASE)/ssp.c
+
+COMPFLAGS-$(CONFIG_STACKPROTECTOR_REGULAR)	+=3D -fstack-protector -mstac=
k-protector-guard=3Dglobal
+COMPFLAGS-$(CONFIG_STACKPROTECTOR_STRONG)	+=3D -fstack-protector-strong =
-mstack-protector-guard=3Dglobal
+COMPFLAGS-$(CONFIG_STACKPROTECTOR_ALL)		+=3D -fstack-protector-all -msta=
ck-protector-guard=3Dglobal
diff --git a/lib/uksp/exportsyms.uk b/lib/uksp/exportsyms.uk
new file mode 100644
index 00000000..fbc319e7
--- /dev/null
+++ b/lib/uksp/exportsyms.uk
@@ -0,0 +1,2 @@
+__stack_chk_fail
+__stack_chk_guard
diff --git a/lib/uksp/include/uk/sp.h b/lib/uksp/include/uk/sp.h
new file mode 100644
index 00000000..f1da724d
--- /dev/null
+++ b/lib/uksp/include/uk/sp.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
+ *
+ * Copyright (c) 2019, University Politehnica of Bucharest. All rights r=
eserved.
+ *
+ * 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 th=
e
+ *    documentation and/or other materials provided with the distributio=
n.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived fr=
om
+ *    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 PU=
RPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTOR=
S 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 BUSIN=
ESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER =
IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS=
E)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED O=
F THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __UK_STACKPROTECTOR_H__
+#define __UK_STACKPROTECTOR_H__
+
+#include <uk/swrand.h>
+#include <uk/config.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const unsigned long __stack_chk_guard;
+
+#ifdef CONFIG_LIBUKSP_VALUE_RANDOM
+#define UKSP_INIT_CANARY() (*(DECONST(unsigned long *, &__stack_chk_guar=
d)) \
+		=3D uk_swrand_randr())
+#else
+#define UKSP_INIT_CANARY()
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UK_STACKPROTECTOR_H__ */
diff --git a/lib/uksp/ssp.c b/lib/uksp/ssp.c
new file mode 100644
index 00000000..d0d10114
--- /dev/null
+++ b/lib/uksp/ssp.c
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Badoiu Vlad-Andrei <vlad_andrei.badoiu@stud.acs.upb.ro>
+ *
+ * Copyright (c) 2019, University Politehnica of Bucharest. All rights r=
eserved.
+ *
+ * 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 th=
e
+ *    documentation and/or other materials provided with the distributio=
n.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived fr=
om
+ *    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 PU=
RPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTOR=
S 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 BUSIN=
ESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER =
IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS=
E)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED O=
F THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <uk/assert.h>
+#include <uk/swrand.h>
+#include <uk/config.h>
+#include <uk/ctors.h>
+#include <uk/thread.h>
+
+#ifdef CONFIG_LIBUKSP_VALUE_USECONSTANT
+const unsigned long __stack_chk_guard =3D CONFIG_LIBUKSP_VALUE_CONSTANT;
+#else
+const unsigned long __stack_chk_guard =3D 0xDEADBEEF;
+#endif
+
+__attribute__((noreturn))
+void __stack_chk_fail(void)
+{
+	unsigned long sp;
+
+	sp =3D ukarch_read_sp() & STACK_MASK_TOP;
+	UK_CRASH("Stack smashing detected. SP %p\n", (void *) sp);
+}
--=20
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 04 23:35:25 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 04 May 2020 23:35:25 +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 1jVkcP-00057K-Ey; Mon, 04 May 2020 23:35:25 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Z8GS=6S=upb.ro=vlad_andrei.badoiu@srs-us1.protection.inumbo.net>)
 id 1jVkcO-000579-Or
 for minios-devel@lists.xen.org; Mon, 04 May 2020 23:35:24 +0000
X-Inumbo-ID: e8ca9398-8e5f-11ea-ae69-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.220])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e8ca9398-8e5f-11ea-ae69-bc764e2007e4;
 Mon, 04 May 2020 23:35:17 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 77AAEB562794;
 Tue,  5 May 2020 02:35:16 +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 OrIohmWFqSiH; Tue,  5 May 2020 02:35:12 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 389E8B5627BB;
 Tue,  5 May 2020 02:35:12 +0300 (EEST)
DKIM-Filter: OpenDKIM Filter v2.10.3 mx.upb.ro 389E8B5627BB
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upb.ro;
 s=96342B8A-77E4-11E5-BA93-D93D0963A2DF; t=1588635312;
 bh=r0fZOKQttaFANBkqe1TWNOEtNS+IpWGLxRlgpcYFVD4=;
 h=From:To:Date:Message-Id:MIME-Version;
 b=Zbgk56j6F0r9fHz6ofarl1VWjNSCclPFNXSfiu3aUwaMByTMpBiNuLXp+UWkbF8R/
 SqslWZ119hL7i3fFJsD+TpAMIPbkpm+Vf4ePFHVUC95CohV8zpIUvRVhfR2LT3O5RW
 OYy2yhXfeQ4OqRsAZymjVTKO7/aMFfvCSopuLq7M=
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 Bib2ZXYmq9JE; Tue,  5 May 2020 02:35:12 +0300 (EEST)
Received: from localhost.localdomain (unknown [188.25.131.222])
 by mx.upb.ro (Postfix) with ESMTPSA id D8B5FB5627AF;
 Tue,  5 May 2020 02:35:11 +0300 (EEST)
From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v5 2/3] build: Add option to toggle the stack
 protection
Date: Tue,  5 May 2020 02:35:05 +0300
Message-Id: <20200504233506.7573-3-vlad_andrei.badoiu@upb.ro>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200504233506.7573-1-vlad_andrei.badoiu@upb.ro>
References: <20200504233506.7573-1-vlad_andrei.badoiu@upb.ro>
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>
Cc: simon.kuenzer@neclab.eu,
 =?UTF-8?q?Vlad-Andrei=20B=C4=82DOIU=20=2878692=29?=
 <vlad_andrei.badoiu@stud.acs.upb.ro>,
 Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

From: Vlad-Andrei B=C4=82DOIU (78692) <vlad_andrei.badoiu@stud.acs.upb.ro=
>

This patch adds build option to select different stack protection
levels.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
---
 Makefile.uk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Makefile.uk b/Makefile.uk
index 1d6d060a..a7fbf3e5 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -6,9 +6,13 @@
=20
 COMPFLAGS    +=3D -nostdinc -nostdlib
 COMPFLAGS    +=3D -U __linux__ -U __FreeBSD__ -U __sun__
-COMPFLAGS    +=3D -fno-stack-protector -fno-omit-frame-pointer -fno-tree=
-sra
+COMPFLAGS    +=3D -fno-omit-frame-pointer -fno-tree-sra
 COMPFLAGS    +=3D -Wall -Wextra
=20
+ifneq ($(HAVE_STACKPROTECTOR),y)
+COMPFLAGS    +=3D -fno-stack-protector
+endif
+
 ASFLAGS      +=3D -D__ASSEMBLY__
=20
 ASINCLUDES   +=3D -I$(CONFIG_UK_BASE)/include
--=20
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 04 23:38:21 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 04 May 2020 23:38: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 1jVkfE-0005Cf-NX; Mon, 04 May 2020 23:38:20 +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=Z8GS=6S=upb.ro=vlad_andrei.badoiu@srs-us1.protection.inumbo.net>)
 id 1jVkfD-0005Ca-Pe
 for minios-devel@lists.xen.org; Mon, 04 May 2020 23:38:19 +0000
X-Inumbo-ID: 54a94f15-8e60-11ea-9d64-12813bfff9fa
Received: from mx.upb.ro (unknown [141.85.13.220])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 54a94f15-8e60-11ea-9d64-12813bfff9fa;
 Mon, 04 May 2020 23:38:19 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 1852BB56279A;
 Tue,  5 May 2020 02:38:18 +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 gAnoc-_2e0ZD; Tue,  5 May 2020 02:38:11 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 44E29B5627A3;
 Tue,  5 May 2020 02:38:11 +0300 (EEST)
DKIM-Filter: OpenDKIM Filter v2.10.3 mx.upb.ro 44E29B5627A3
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upb.ro;
 s=96342B8A-77E4-11E5-BA93-D93D0963A2DF; t=1588635491;
 bh=zr0Dp07r/AyWlwe4JMYXEmo8vb8WCf0Nq1J6w9d7q/w=;
 h=To:From:Message-ID:Date:MIME-Version;
 b=cHKLpMaCz+r9O4GdepuytmZ0j7v6DCnb4oqy5FYeiyo2naQ+x2qvUbGnMDQ6h6dMz
 pbPiucS40xnw/32vUJl/Iu3EIObq/9fkKtBO0KCn0zblZCTvpgscVkPpakfPpykNKu
 ksWokmPsuiBmTn+7e05ixdMej9RHIFxYxrXpymHU=
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 bvseUHzAGxZS; Tue,  5 May 2020 02:38:11 +0300 (EEST)
Received: from [192.168.0.131] (unknown [188.25.131.222])
 by mx.upb.ro (Postfix) with ESMTPSA id DEB6DB56269C;
 Tue,  5 May 2020 02:38:10 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v4 0/4] lib/uksp: Introduce uksp library
To: Simon Kuenzer <simon.kuenzer@neclab.eu>,
 =?UTF-8?Q?Vlad-Andrei_B=c4=82DOIU_=2878692=29?=
 <vlad_andrei.badoiu@stud.acs.upb.ro>,
 "minios-devel@lists.xen.org" <minios-devel@lists.xen.org>
References: <20200204140950.23832-1-vlad_andrei.badoiu@stud.acs.upb.ro>
 <81a9832f-fac1-5cc3-dd51-8e3a92ccc36e@neclab.eu>
From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Message-ID: <6e3ee272-35a5-0545-c0ac-aecb2652d179@upb.ro>
Date: Tue, 5 May 2020 02:38:10 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.4.1
MIME-Version: 1.0
In-Reply-To: <81a9832f-fac1-5cc3-dd51-8e3a92ccc36e@neclab.eu>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
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>
Cc: "felipe.huici@neclab.eu" <felipe.huici@neclab.eu>,
 "sharan.santhanam@neclab.eu" <sharan.santhanam@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi Simon,

Thank you for the suggestions. They are insightful and improve the=20
overall quality of this patch series. I have sent a v5 with all the=20
requested changes.

Cheers,

Vlad

On 18.03.2020 15:27, Simon Kuenzer wrote:
> Hi Vlad,
>
> thanks a lot for your work. I have some suggestion inline in each=20
> patch. Let me know what you think.
>
> Thanks,
>
> Simon
>
> On 04.02.20 15:09, Vlad-Andrei B=C4=82DOIU (78692) wrote:
>> Currently, we provide a basic implementation of stack smashing
>> protection that
>> has a global value for all threads. The value is randomly initialized
>> during the
>> boot. Finally, this option might help us detect bugs caused by stack
>> overflows.
>>
>> Changes since v1:
>> * We now use a choice based config option for the stack protector leve=
l.
>> * Since
>> the last version we added the regulat and strong stack protector
>> options.
>>
>> Changes since v2:
>> * Renamed the library to uksp
>>
>> Changes since v3:
>> * Added config option for constant value/random source for the canary.
>> * Updated the config
>> * Updated library title
>> * Moved uksp/stackprotector.h to uk/sp.h
>> * Added current stack pointer to the crash message
>>
>> Vlad-Andrei Badoiu (2):
>> =C2=A0=C2=A0 Move UK_SWRAND_CTOR_PRIO to uk/swrand.h
>> =C2=A0=C2=A0 lib/ukboot: Initialize the canary value at boot
>>
>> Vlad-Andrei B=C4=82DOIU (78692) (2):
>> =C2=A0=C2=A0 lib/uksp: Introduce uksp library
>> =C2=A0=C2=A0 build: Add option to toggle the stack protection
>>
>> =C2=A0 Makefile.uk=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
| 10 ++++--
>> =C2=A0 lib/Config.uk=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 4=
 +++
>> =C2=A0 lib/Makefile.uk=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 1 +
>> =C2=A0 lib/ukboot/boot.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 8 +++++
>> =C2=A0 lib/uksp/Config.uk=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 51 ++++++++++++++++++++++++++++
>> =C2=A0 lib/uksp/Makefile.uk=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 21 ++++++++++++
>> =C2=A0 lib/uksp/exportsyms.uk=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 |=C2=A0 2 ++
>> =C2=A0 lib/uksp/include/uk/sp.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 | 58 ++++++++++++++++++++++++++++++++
>> =C2=A0 lib/uksp/ssp.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 50 ++++++++++=
+++++++++++++++++
>> =C2=A0 lib/ukswrand/include/uk/swrand.h |=C2=A0 2 ++
>> =C2=A0 lib/ukswrand/swrand.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 --
>> =C2=A0 11 files changed, 205 insertions(+), 4 deletions(-)
>> =C2=A0 create mode 100644 lib/uksp/Config.uk
>> =C2=A0 create mode 100644 lib/uksp/Makefile.uk
>> =C2=A0 create mode 100644 lib/uksp/exportsyms.uk
>> =C2=A0 create mode 100644 lib/uksp/include/uk/sp.h
>> =C2=A0 create mode 100644 lib/uksp/ssp.c
>>


From minios-devel-bounces@lists.xenproject.org Tue May 05 18:18:51 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 05 May 2020 18:18:51 +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 1jW29X-0008Gw-0A; Tue, 05 May 2020 18:18: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=WdR1=6T=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jW29W-0008Gp-2Y
 for minios-devel@lists.xen.org; Tue, 05 May 2020 18:18:46 +0000
X-Inumbo-ID: d9dce14a-8efc-11ea-9887-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.230])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d9dce14a-8efc-11ea-9887-bc764e2007e4;
 Tue, 05 May 2020 18:18:43 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 1E4F6B562710;
 Tue,  5 May 2020 21:18:42 +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 6awzOExp-zIB; Tue,  5 May 2020 21:18:40 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 2BC8AB56207A;
 Tue,  5 May 2020 21:18:40 +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 BQ_z3y9YaWuz; Tue,  5 May 2020 21:18:40 +0300 (EEST)
Received: from [192.168.1.35] (unknown [86.121.66.46])
 by mx.upb.ro (Postfix) with ESMTPSA id F1B46B562071;
 Tue,  5 May 2020 21:18:39 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH 5/7] lib/vfscore: Fix double refcounting bug
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200502151340.92959-1-cristb@gmail.com>
 <20200502151340.92959-6-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <9eba324e-7217-aeda-2849-de3fe349380e@cs.pub.ro>
Date: Tue, 5 May 2020 21:18:39 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.7.0
MIME-Version: 1.0
In-Reply-To: <20200502151340.92959-6-cristb@gmail.com>
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>

Thanks for fixing this, Cristi! We needed it for a long time, so it
helps us a great deal. I'll upstream this now and we shall skip it from
the v2.

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/2/20 6:13 PM, Cristian Banu wrote:
> This patch removes the `dref()` line in `sys_open` which would result
> in an unbounded growth of the refcount. open() would take two
> references: one via dentry_lookup() in namei(), and the other via
> dref(); close() would release only one reference via drele().
> 
> As to the comment also deleted in this patch, it is true that OSv uses
> intrusive_ptr, however it is created with the second argument
> add_ref = false, hence the "std::move()" comment below in the original
> OSv source code.
> 
> Now close() correctly releases the dentry if there are no open files
> left.
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/vfscore/syscalls.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/vfscore/syscalls.c b/lib/vfscore/syscalls.c
> index 9a132b7..ce51274 100644
> --- a/lib/vfscore/syscalls.c
> +++ b/lib/vfscore/syscalls.c
> @@ -205,8 +205,10 @@ sys_open(char *path, int flags, mode_t mode, struct vfscore_file **fpp)
>  	fhold(fp);
>  	fp->f_flags = flags;
>  
> -	// OSv was using a intrusive_ptr which was increasing the refcount
> -	dref(dp);
> +	/*
> +	 * Don't need to increase refcount here, we already hold a reference
> +	 * to dp from namei().
> +	 */
>  	// change to std::move once dp is a dentry_ref
>  	fp->f_dentry = dp;
>  	dp = NULL;
> 


From minios-devel-bounces@lists.xenproject.org Tue May 05 18:20:03 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 05 May 2020 18:20: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 1jW2Ak-0008Ni-4R; Tue, 05 May 2020 18:20:02 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=WdR1=6T=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jW2Aj-0008Ii-4k
 for minios-devel@lists.xen.org; Tue, 05 May 2020 18:20:01 +0000
X-Inumbo-ID: 074f02ca-8efd-11ea-b07b-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.210])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 074f02ca-8efd-11ea-b07b-bc764e2007e4;
 Tue, 05 May 2020 18:19:59 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id A1FD2B562386;
 Tue,  5 May 2020 21:19:58 +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 BCx2pDLybzMU; Tue,  5 May 2020 21:19:56 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 9D03AB562612;
 Tue,  5 May 2020 21:19:56 +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 4p22ZTZvoHMu; Tue,  5 May 2020 21:19:56 +0300 (EEST)
Received: from [192.168.1.35] (unknown [86.121.66.46])
 by mx.upb.ro (Postfix) with ESMTPSA id 5BFB6B56207A;
 Tue,  5 May 2020 21:19:56 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH 6/7] lib/vfscore: Expose max fds to sysconf
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200502151340.92959-1-cristb@gmail.com>
 <20200502151340.92959-7-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <bafdfb5e-bf17-4746-a38e-37ce030c8b78@cs.pub.ro>
Date: Tue, 5 May 2020 21:19:56 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.7.0
MIME-Version: 1.0
In-Reply-To: <20200502151340.92959-7-cristb@gmail.com>
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>

Thanks for adding this, Cristi!
I'll upstream this now and we shall skip it from the v2.

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/2/20 6:13 PM, Cristian Banu wrote:
> Expose FDTABLE_MAX_FILES from vfscore as the return value of
> sysconf(_SC_OPEN_MAX) if CONFIG_LIBVFSCORE is enabled.
> 
> This allows language runtimes to inspect the number of active
> fds (e.g. for tests).
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/posix-sysinfo/sysinfo.c        | 10 ++++++++++
>  lib/vfscore/fd.c                   |  2 --
>  lib/vfscore/include/vfscore/file.h |  3 +++
>  3 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/posix-sysinfo/sysinfo.c b/lib/posix-sysinfo/sysinfo.c
> index 7bcfc8b..075f320 100644
> --- a/lib/posix-sysinfo/sysinfo.c
> +++ b/lib/posix-sysinfo/sysinfo.c
> @@ -43,6 +43,11 @@
>  #include <sys/sysinfo.h>
>  #include <uk/syscall.h>
>  
> +#if CONFIG_LIBVFSCORE
> +/* For FDTABLE_MAX_FILES. */
> +#include <vfscore/file.h>
> +#endif
> +
>  static struct utsname utsname = {
>  	.sysname	= "Unikraft",
>  	.nodename	= "unikraft",
> @@ -85,6 +90,11 @@ long sysconf(int name)
>  	if (name == _SC_PAGESIZE)
>  		return __PAGE_SIZE;
>  
> +#if CONFIG_LIBVFSCORE
> +	if (name == _SC_OPEN_MAX)
> +		return FDTABLE_MAX_FILES;
> +#endif
> +
>  	return 0;
>  }
>  
> diff --git a/lib/vfscore/fd.c b/lib/vfscore/fd.c
> index 684ea50..956846f 100644
> --- a/lib/vfscore/fd.c
> +++ b/lib/vfscore/fd.c
> @@ -42,8 +42,6 @@
>  #include <errno.h>
>  #include <uk/ctors.h>
>  
> -#define FDTABLE_MAX_FILES 1024
> -
>  void init_stdio(void);
>  
>  struct fdtable {
> diff --git a/lib/vfscore/include/vfscore/file.h b/lib/vfscore/include/vfscore/file.h
> index be23974..ec45a08 100644
> --- a/lib/vfscore/include/vfscore/file.h
> +++ b/lib/vfscore/include/vfscore/file.h
> @@ -80,6 +80,9 @@ int fdrop(struct vfscore_file* fp);
>  
>  #define FOF_OFFSET  0x0800    /* Use the offset in uio argument */
>  
> +/* Used from posix-sysinfo to determine sysconf(_SC_OPEN_MAX). */
> +#define FDTABLE_MAX_FILES 1024
> +
>  #ifdef __cplusplus
>  }
>  #endif
> 


From minios-devel-bounces@lists.xenproject.org Wed May 06 10:02:16 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 06 May 2020 10:02: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 1jWGsZ-0002Fm-4d; Wed, 06 May 2020 10:02: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=B39o=6U=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jWGsX-0002Fe-Mf
 for minios-devel@lists.xen.org; Wed, 06 May 2020 10:02:13 +0000
X-Inumbo-ID: a73333b4-8f80-11ea-b07b-bc764e2007e4
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a73333b4-8f80-11ea-b07b-bc764e2007e4;
 Wed, 06 May 2020 10:02:11 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id CFB97100227;
 Wed,  6 May 2020 12:02:10 +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 xkoWBWDYtr7W; Wed,  6 May 2020 12:02:10 +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 928C5FF994
 for <minios-devel@lists.xen.org>; Wed,  6 May 2020 12:02:10 +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.1713.5; Wed, 6 May 2020
 12:02:10 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
Subject: [UNIKRAFT PATCH] lib/syscall_shim: Support system calls without
 arguments
Date: Wed, 6 May 2020 12:02:01 +0200
Message-ID: <20200506100201.22654-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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

The macros `UK_SYSCALL_DEFINE()`, `UK_SYSCALL_R_DEFINE()`,
`UK_LLSYSCALL_DEFINE()`, and `UK_LLSYSCALL_R_DEFINE()` did not support
defining system calls that do not have input parameters (e.g.,
`getppid`). The definition for empty argument lists was
missing (`UK_ARG_MAP0`).

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/syscall_shim/include/uk/syscall.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/syscall_shim/include/uk/syscall.h b/lib/syscall_shim/include/uk/syscall.h
index a3b79d41..1be4ab91 100644
--- a/lib/syscall_shim/include/uk/syscall.h
+++ b/lib/syscall_shim/include/uk/syscall.h
@@ -93,6 +93,7 @@ typedef long uk_syscall_arg_t;
 #define __UK_NAME2SCALLE_FN(name) UK_CONCAT(uk_syscall_e_, name)
 #define __UK_NAME2SCALLR_FN(name) UK_CONCAT(uk_syscall_r_, name)
 
+#define UK_ARG_MAP0(...)
 #define UK_ARG_MAP1(m, type, arg) m(type, arg)
 #define UK_ARG_MAP2(m, type, arg, ...) m(type, arg), UK_ARG_MAP1(m, __VA_ARGS__)
 #define UK_ARG_MAP3(m, type, arg, ...) m(type, arg), UK_ARG_MAP2(m, __VA_ARGS__)
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Sat May 09 06:32:00 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 06:32: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 1jXJ1g-0001Fp-TM; Sat, 09 May 2020 06:31:56 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=vNso=6X=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jXJ1f-0001Fk-2n
 for minios-devel@lists.xen.org; Sat, 09 May 2020 06:31:55 +0000
X-Inumbo-ID: c560b2ae-91be-11ea-9887-bc764e2007e4
Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c560b2ae-91be-11ea-9887-bc764e2007e4;
 Sat, 09 May 2020 06:31:53 +0000 (UTC)
Received: by mail-wm1-x342.google.com with SMTP id f134so221498wmf.1
 for <minios-devel@lists.xen.org>; Fri, 08 May 2020 23:31:53 -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=Ryp+6SffhPlcGOp7WDvIhzxUiSUWewtjhi5m21qQtPg=;
 b=PW8pgKQRUYeMq14QNhC3CypdoLxdvMEcbvk+NxjVzdsCuFO+d3fASj1FkjRVFNhgyq
 pBlEcsl1ESsKMvzrIHvQJMfz04RgzrpaIFnrccvdmw22MyrZ9IzsTzOZdGk5FbE4hSOW
 UGak2JA1YAx9znTJSkyagBwpNRIJRuWhjfX+zCtUIpONBQATe0R0YY2zA5QEXzNX+vyB
 GKzhFxPMZeNQud6zF/eaEj0zoKfHcqgpQXDDlHdFHynshCO20p8MTWfWe66grz66RW/p
 qnrr47gFw9prkPUhttA7V783O02XnFcpWuLVGk8gM1wVw+htsTDpT7A+iNim3OpFiwcr
 LWlA==
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=Ryp+6SffhPlcGOp7WDvIhzxUiSUWewtjhi5m21qQtPg=;
 b=DFC2l4eqn/qTAgSl58v1IuGCHrdvG7QdgD5nQP/AmYYivt3xbxTf6SghSBPxfIW86c
 Vh3O19jPQaJs0jbwwcUqrsEcevdsBjlHuTnFj+GQoksFonFXzTkREbuQHGeoz+q51Bzr
 DF2WRUFYkX1ngwIWEzi/q/Rx3gI3LYsrbt3KEtH3C5oAXtGLfBlTuHxWC1Sw+6RtqMIV
 5ohl0XNek6i6WH42gcyPSfYCfBF6IDynXGeYrO2g+EYptUTeAetoT8nEjYmOpx0Xc46t
 pOVWXPfoKDELqMSk/5moyMRg+i3DzJYlzKn53Y39/05g3mXHLkX4+/TiM1lQ7JilQfnQ
 yfDQ==
X-Gm-Message-State: AGi0PuY5x7EK0lgGorSNanqkdlrzimaaGLcDJLeQie6BCTLf5/wCoa3D
 nlhzpxJCKt6PXsRszU0C6gHF9FNxEQE=
X-Google-Smtp-Source: APiQypIp5Pp6GZ5aVaXy0grIUAW1XTj4p69Q8RxddC/9i5GylXpGlM1joxgyhJdq7s9Tjl924ICdYA==
X-Received: by 2002:a1c:9d8c:: with SMTP id g134mr20516668wme.79.1589005912252; 
 Fri, 08 May 2020 23:31:52 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id 17sm15914719wmo.2.2020.05.08.23.31.51
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 May 2020 23:31:51 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 1/8] lib/vfscore: Register `unlink` to syscall_shim
Date: Sat,  9 May 2020 09:29:39 +0300
Message-Id: <20200509062946.9638-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `unlink` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 14 +++++++-------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index e7f327a..ad06a4b 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -54,4 +54,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fdatasync-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += preadv-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += umask-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += lstat-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += flock-2
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += flock-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += unlink-1
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 20595e1..47d50a2 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -64,6 +64,8 @@ link
 uk_syscall_e_link
 uk_syscall_r_link
 unlink
+uk_syscall_e_unlink
+uk_syscall_r_unlink
 getcwd
 chown
 chroot
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 746dd7f..fcf4873 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -1135,7 +1135,7 @@ UK_TRACEPOINT(trace_vfs_unlink, "\"%s\"", const char*);
 UK_TRACEPOINT(trace_vfs_unlink_ret, "");
 UK_TRACEPOINT(trace_vfs_unlink_err, "%d", int);
 
-int unlink(const char *pathname)
+UK_SYSCALL_R_DEFINE(int, unlink, const char*, pathname)
 {
 	trace_vfs_unlink(pathname);
 	struct task *t = main_task;
@@ -1144,19 +1144,19 @@ int unlink(const char *pathname)
 
 	error = ENOENT;
 	if (pathname == NULL)
-		goto out_errno;
+		goto out_error;
 	if ((error = task_conv(t, pathname, VWRITE, path)) != 0)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_unlink(path);
 	if (error)
-		goto out_errno;
+		goto out_error;
 	trace_vfs_unlink_ret();
 	return 0;
-	out_errno:
+
+	out_error:
 	trace_vfs_unlink_err(error);
-	errno = error;
-	return -1;
+	return -error;
 }
 
 UK_TRACEPOINT(trace_vfs_stat, "\"%s\" %p", const char*, struct stat*);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 09 06:32:00 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 06:32: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 1jXJ1k-0001GC-Uu; Sat, 09 May 2020 06:32: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=vNso=6X=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jXJ1j-0001Fy-DS
 for minios-devel@lists.xen.org; Sat, 09 May 2020 06:31:59 +0000
X-Inumbo-ID: c5db51c6-91be-11ea-ae69-bc764e2007e4
Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c5db51c6-91be-11ea-ae69-bc764e2007e4;
 Sat, 09 May 2020 06:31:54 +0000 (UTC)
Received: by mail-wm1-x341.google.com with SMTP id m24so2770277wml.2
 for <minios-devel@lists.xen.org>; Fri, 08 May 2020 23:31:54 -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=rT/XpZ0k858hbeOWwA+Zw6y2CbfefyMYaK1GDcwwRpI=;
 b=VP9qx4cdq/SmigygcnbyGEu3rXsZ5OLgK3+pud4rDdtck637zX/RFKGsx79ikpt5Hf
 zPdYv26xyTnpkPLqaI/25G9bo1C2SMGNWCe3Wx4rSJluhCu9lfp19/aqUEElec5EK1Pj
 PRkDpKk6O2Ke5reyWHjiKV96mskYQzIgV/jlcUOuKSKx7wlwPIERMI3sVgUrCQ7pJXjr
 FnzIKOncEh2YXPs3ZqDj0TcQxjoWHEhyHNk/I01LdMrsms54njQoHrBV3evc8HOoflgZ
 gX3niv9yCMzqIH0Til5kZ+aWiNKbpstg/iA+sWBbkAY0paJz+OxFLqgK+7KUy6Lhey/5
 a3dQ==
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=rT/XpZ0k858hbeOWwA+Zw6y2CbfefyMYaK1GDcwwRpI=;
 b=rXzWHSuoUXN7DvVKbXtjIsFytrl55euDriGYcFkbTOqQS2SkWHL9VD4t+xVI+ThxX1
 jiW0YAlqVr69JVZr6cbVvfvUcl8hvit4jzmTXgJV3dDALKee7du5UyVj8grannMs7hQE
 /9xWrFYmG9TxGRjOItFOlbRsdzgJUm70IBc1lQwJ5GSVnDN11ysg4a0zSpXkplX9HKbi
 xpbXhSPKeZBNgdZvhW9CHhpCTgFLMRb/pFPJwZj3KU6XC9nRGEQ76961E4LFDxn7kwyX
 /z+woviQE3gEcOcwPnt2Sr3xTpkH44z0Prcli7K7COuvA6Fyq20AyK7l5CMmpDDvA7I9
 4oVA==
X-Gm-Message-State: AGi0PuYQj3X1prtAiTz40kwJaGINRYSiyMYrfbOZP7WYKfT4IE/V1nH8
 WKQJc4UPosnLhUTOFr2m1QQ6ArSjlGI=
X-Google-Smtp-Source: APiQypKK147TrPGj1GLSIrthcHId/SL+Izl1VM6GcA2brUbftaWdk2UE4pi1ihmLWxrlBDRXBUPXzg==
X-Received: by 2002:a05:600c:2293:: with SMTP id
 19mr11404109wmf.121.1589005913146; 
 Fri, 08 May 2020 23:31:53 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id 17sm15914719wmo.2.2020.05.08.23.31.52
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 May 2020 23:31:52 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 2/8] lib/vfscore: Register `stat` to syscall_shim
Date: Sat,  9 May 2020 09:29:40 +0300
Message-Id: <20200509062946.9638-2-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200509062946.9638-1-raducanu.costi@gmail.com>
References: <20200509062946.9638-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `stat` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 15 +++++++--------
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index ad06a4b..c8451e7 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -55,4 +55,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += preadv-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += umask-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += lstat-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += flock-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += unlink-1
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += unlink-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += stat-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 47d50a2..3e9642b 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -40,6 +40,8 @@ ftruncate
 uk_syscall_e_ftruncate
 uk_syscall_r_ftruncate
 stat
+uk_syscall_e_stat
+uk_syscall_r_stat
 chmod
 uk_syscall_e_chmod
 uk_syscall_r_chmod
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index fcf4873..db190b9 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -1173,28 +1173,27 @@ int __xstat(int ver __unused, const char *pathname, struct stat *st)
 
 	error = task_conv(t, pathname, 0, path);
 	if (error)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_stat(path, st);
 	if (error)
-		goto out_errno;
+		goto out_error;
 	trace_vfs_stat_ret();
 	return 0;
 
-	out_errno:
+	out_error:
 	trace_vfs_stat_err(error);
-	errno = error;
-	return -1;
+	return -error;
 }
 
 LFS64(__xstat);
 
-int stat(const char *pathname, struct stat *st)
+UK_SYSCALL_R_DEFINE(int, stat, const char*, pathname, struct stat*, st)
 {
 	if (!pathname) {
-		errno = EINVAL;
-		return -1;
+		return -EINVAL;
 	}
+
 	return __xstat(1, pathname, st);
 }
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 09 06:32:06 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 06:32:06 +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 1jXJ1q-0001Go-0N; Sat, 09 May 2020 06:32:06 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=vNso=6X=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jXJ1o-0001Gc-EA
 for minios-devel@lists.xen.org; Sat, 09 May 2020 06:32:04 +0000
X-Inumbo-ID: c687e986-91be-11ea-b9cf-bc764e2007e4
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c687e986-91be-11ea-b9cf-bc764e2007e4;
 Sat, 09 May 2020 06:31:55 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id j5so4416117wrq.2
 for <minios-devel@lists.xen.org>; Fri, 08 May 2020 23:31:55 -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=BiRS7qv4YW6SD6nbFG6TZN9UNlpgC488t3fLLpjRbmE=;
 b=CTmiMcvAFiZeBJA6qvuQS8v+ahZ3ghDr7cFevXG58+wWca8wz8X0RmNOUUtjpic0x+
 Kwefmzbur2LUb/ZfNRFfKIwf2zbSY4hVXEfHXeA+v+I43ip53FeZ6FP7ibwx9ASxlI//
 jDsEUTUo7bSso2cBHAk45wF1R7sHi+GByV2BQPOjy1FfLdlIVDnocDCR6JxshK+awVlv
 zlYYJo5qcbmqPz9/O7yzZeZxoGXWd4JTj9PNlyDsLeJBgAsKZcfLkruGMfRkFEDQIbbH
 xseQJ0kLijPz3nNIC0ViTr8lgGT3MmI8DwRAYPhUJnUp7GCLMX5DCKQKiFFZanwM4zV8
 DdHQ==
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=BiRS7qv4YW6SD6nbFG6TZN9UNlpgC488t3fLLpjRbmE=;
 b=fLdBOXPi60U8p2HRYf3TUiD+60chfXK4AGP+Nn5G3KH9syXQLVHKoYgbU2+M8OHzwH
 eU7shiGMRlGeDzvnORSnws3IfwamrANpT4pcaDtDGdbWmfP4ifpR4qa0nTxMhaVsVFGZ
 TIwKPxNuMZ/RfAmSmIJ/OZrCbQnhpvPPYDJPH2p2iqlDHRPxT1x/vL/+hoKLjfSJRR/e
 Nz2zT+tf/3r4GGnIFgp9sbF0RIB7Hd4C5CRsErcsA0pZzus1oV70bChlmeH3T07+omtO
 6SE5TDcbhZRc+rtvWNPFY1s/6MLi2X66B0x4B6nvSIKXZtgYnOvPSPhk3FGGXFLxc5Xh
 RvAg==
X-Gm-Message-State: AGi0PubNB+D9Ecn60aEpMsK+NowHY1t0g5i+CwiOHX2Aq7nNxUQD8ECq
 41fSVQNTVDNwfKf+jZf4mrrko+ARhcI=
X-Google-Smtp-Source: APiQypK8hwd0RF2/OvKoK24/saDoWo3kTmXGFLCDrODTw5yl9r0IpEkVNhyN2JrDLYKVy5PNVeTiIg==
X-Received: by 2002:a5d:50ce:: with SMTP id f14mr7326877wrt.251.1589005914186; 
 Fri, 08 May 2020 23:31:54 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id 17sm15914719wmo.2.2020.05.08.23.31.53
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 May 2020 23:31:53 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 3/8] lib/vfscore: Register `open` to syscall_shim
Date: Sat,  9 May 2020 09:29:41 +0300
Message-Id: <20200509062946.9638-3-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200509062946.9638-1-raducanu.costi@gmail.com>
References: <20200509062946.9638-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `open` system call to syscall_shim library.
The signature of the `open` library call is different from signature
of the `open` syscall, forcing us to use the macro UK_LLSYSCALL_R_DEFINE.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 42 ++++++++++++++++++++++-----------------
 3 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index c8451e7..1fe5eb6 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -56,4 +56,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += umask-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += lstat-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += flock-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += unlink-1
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += stat-2
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += stat-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += open-3
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 3e9642b..7e2f7ea 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -13,6 +13,8 @@ vfscore_vop_einval
 vfscore_vop_eperm
 vfscore_vop_erofs
 open
+uk_syscall_e_open
+uk_syscall_r_open
 creat
 write
 uk_syscall_e_write
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index db190b9..1bbbbd4 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -84,16 +84,8 @@ UK_TRACEPOINT(trace_vfs_open_err, "%d", int);
 
 struct task *main_task;	/* we only have a single process */
 
-int open(const char *pathname, int flags, ...)
+UK_LLSYSCALL_R_DEFINE(int, open, const char*, pathname, int, flags, mode_t, mode)
 {
-	mode_t mode = 0;
-	if (flags & O_CREAT) {
-		va_list ap;
-		va_start(ap, flags);
-		mode = apply_umask(va_arg(ap, mode_t));
-		va_end(ap);
-	}
-
 	trace_vfs_open(pathname, flags, mode);
 
 	struct task *t = main_task;
@@ -117,11 +109,11 @@ int open(const char *pathname, int flags, ...)
 
 	error = task_conv(t, pathname, acc, path);
 	if (error)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_open(path, flags, mode, &fp);
 	if (error)
-		goto out_errno;
+		goto out_error;
 
 	error = fdalloc(fp, &fd);
 	if (error)
@@ -132,10 +124,22 @@ int open(const char *pathname, int flags, ...)
 
 	out_fput:
 	fdrop(fp);
-	out_errno:
-	errno = error;
+	out_error:
 	trace_vfs_open_err(error);
-	return -1;
+	return -error;
+}
+
+int open(const char *pathname, int flags, ...)
+{
+	mode_t mode = 0;
+	if (flags & O_CREAT) {
+		va_list ap;
+		va_start(ap, flags);
+		mode = apply_umask(va_arg(ap, mode_t));
+		va_end(ap);
+	}
+
+	return uk_syscall_e_open((long int)pathname, flags, mode);
 }
 
 LFS64(open);
@@ -151,7 +155,7 @@ int openat(int dirfd, const char *pathname, int flags, ...)
 	}
 
 	if (pathname[0] == '/' || dirfd == AT_FDCWD) {
-		return open(pathname, flags, mode);
+		return uk_syscall_e_open((long int)pathname, flags, mode);
 	}
 
 	struct vfscore_file *fp;
@@ -172,7 +176,7 @@ int openat(int dirfd, const char *pathname, int flags, ...)
 	strlcat(p, "/", PATH_MAX);
 	strlcat(p, pathname, PATH_MAX);
 
-	error = open(p, flags, mode);
+	error = uk_syscall_e_open((long int)p, flags, mode);
 
 	vn_unlock(vp);
 	fdrop(fp);
@@ -183,7 +187,8 @@ LFS64(openat);
 
 int creat(const char *pathname, mode_t mode)
 {
-	return open(pathname, O_CREAT|O_WRONLY|O_TRUNC, mode);
+	return uk_syscall_e_open((long int) pathname,
+		O_CREAT|O_WRONLY|O_TRUNC, mode);
 }
 LFS64(creat);
 
@@ -646,6 +651,7 @@ DIR *opendir(const char *path)
 {
 	DIR *dir;
 	struct stat st;
+	mode_t mode = 0;
 
 	dir = malloc(sizeof(*dir));
 	if (!dir) {
@@ -653,7 +659,7 @@ DIR *opendir(const char *path)
 		goto out_err;
 	}
 
-	dir->fd = open(path, O_RDONLY);
+	dir->fd = uk_syscall_e_open((long int)path, O_RDONLY, mode);
 	if (dir->fd < 0)
 		goto out_free_dir;
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 09 06:32:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 06:32: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 1jXJ1v-0001Hr-21; Sat, 09 May 2020 06:32:11 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=vNso=6X=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jXJ1t-0001HY-E7
 for minios-devel@lists.xen.org; Sat, 09 May 2020 06:32:09 +0000
X-Inumbo-ID: c7164b40-91be-11ea-9887-bc764e2007e4
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c7164b40-91be-11ea-9887-bc764e2007e4;
 Sat, 09 May 2020 06:31:56 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id s8so4392212wrt.9
 for <minios-devel@lists.xen.org>; Fri, 08 May 2020 23:31:56 -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=cyhVnqydbCBJcJtyzJlt2HIWIJE/B+tR5vf78gnh168=;
 b=tBRtlyI/eRsXrdbxva0WhbKSs1oGaO+9+pGu65t3lJ0rbF1Mh0e+XLRyGvpzg0iKJl
 Z138Ba0a6AocqRe+fHTeYqE9ZkaJau/51Aur1fD1210pRuB4L74aW0Z/ZYwAxoTb48Qs
 PRXYSNkoAJLkMeCXRFZhR/YA5hUHGQaRhdkJpJgQGQOHYhX0gOlyZLH8Rko2pDSPZBjE
 0mt9GNYjYqFXYmTvf88lNE+SzXw148P4IRz19caFstujG9TsZy8MWBUg9lzsRzlDcrgr
 Ivxe/BiwMfzb5A54NNSTfJQxqBvIsp2e++lRl6hNfrvY5LehwpWwquCMolw+xxP+4QLm
 dOwA==
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=cyhVnqydbCBJcJtyzJlt2HIWIJE/B+tR5vf78gnh168=;
 b=ldWGdV01Nxx5fkAIcdJTzNGnmJs9+BCISkf/NbU4hXuCPM9PHAmbtBQDwMLnHP2Y74
 TABLsOF8z3aEkvgZIPZrob2bzc8/pNRMXuSDp0jX1S1c/rQ6Iv4g32Nsz7cKqYDEGDM4
 MA8TyTXTO7BANxaDu5wnRwP14qkFaoNrrfAFDYWIYr9RIMhVvi+ctjceWyaE3a0VSScL
 Xr/GSmv6GIsISBszzEjL6bQpNrBB72l38GjBFs8m5Dg6roNYVJ5wpzxk8zlkMjLhP/r5
 2E6jFTVwvsM3e93Tu+pmblIKZl6432xb3trwUl98vjbxq+UAGbX/Lmtxsy0EMnvDuu95
 fiUQ==
X-Gm-Message-State: AGi0PuZC/77ZhHysCfoOM56BPp31SXvyaBUx+l+sY4A9IJ51xMFUIY+Y
 PNZwnKt2LIB0+C+iQjMSJYbPepqNucs=
X-Google-Smtp-Source: APiQypK9Zc13ulRf2dzBTT1TZ3jA6iJmfDaFJyR4hcWI11rAvGLKnNX/aKgp+ilvKtoJweB2gZcd2A==
X-Received: by 2002:adf:e2c2:: with SMTP id d2mr7425883wrj.55.1589005915224;
 Fri, 08 May 2020 23:31:55 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id 17sm15914719wmo.2.2020.05.08.23.31.54
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 May 2020 23:31:54 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 4/8] lib/vfscore: Register `mkdir` to syscall_shim
Date: Sat,  9 May 2020 09:29:42 +0300
Message-Id: <20200509062946.9638-4-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200509062946.9638-1-raducanu.costi@gmail.com>
References: <20200509062946.9638-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `mkdir` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 13 ++++++-------
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 1fe5eb6..8f04e45 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -57,4 +57,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += lstat-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += flock-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += unlink-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += stat-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += open-3
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += open-3
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mkdir-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 7e2f7ea..307dd5f 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -26,6 +26,8 @@ read
 uk_syscall_e_read
 uk_syscall_r_read
 mkdir
+uk_syscall_e_mkdir
+uk_syscall_r_mkdir
 fsync
 uk_syscall_e_fsync
 uk_syscall_r_fsync
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 1bbbbd4..e5b3a16 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -862,8 +862,7 @@ UK_TRACEPOINT(trace_vfs_mkdir, "\"%s\" 0%0o", const char*, mode_t);
 UK_TRACEPOINT(trace_vfs_mkdir_ret, "");
 UK_TRACEPOINT(trace_vfs_mkdir_err, "%d", int);
 
-int
-mkdir(const char *pathname, mode_t mode)
+UK_SYSCALL_R_DEFINE(int, mkdir, const char*, pathname, mode_t, mode)
 {
 	struct task *t = main_task;
 	char path[PATH_MAX];
@@ -873,17 +872,17 @@ mkdir(const char *pathname, mode_t mode)
 
 	trace_vfs_mkdir(pathname, mode);
 	if ((error = task_conv(t, pathname, VWRITE, path)) != 0)
-		goto out_errno;
+		goto out_error;
 
 	error = sys_mkdir(path, mode);
 	if (error)
-		goto out_errno;
+		goto out_error;
 	trace_vfs_mkdir_ret();
 	return 0;
-	out_errno:
+
+	out_error:
 	trace_vfs_mkdir_err(error);
-	errno = error;
-	return -1;
+	return -error;
 }
 
 UK_TRACEPOINT(trace_vfs_rmdir, "\"%s\"", const char*);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 09 06:32:16 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 06: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 1jXJ20-0001Ip-3c; Sat, 09 May 2020 06:32:16 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=vNso=6X=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jXJ1y-0001IZ-FU
 for minios-devel@lists.xen.org; Sat, 09 May 2020 06:32:14 +0000
X-Inumbo-ID: c79e725e-91be-11ea-9887-bc764e2007e4
Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c79e725e-91be-11ea-9887-bc764e2007e4;
 Sat, 09 May 2020 06:31:57 +0000 (UTC)
Received: by mail-wm1-x341.google.com with SMTP id f134so221571wmf.1
 for <minios-devel@lists.xen.org>; Fri, 08 May 2020 23:31:57 -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=SQIdg6TnjoeuRcUdTyaXNJxgAyMJlAjtzDj36SV1CAQ=;
 b=UrSk0oxi8ltj20bvYjPwO4FTGtI+hHLRgUnJyGuUjkKDjKq3kdbUicRwgYohYBUxyK
 Itge9fnWY/9e4M7HByLDv9+vFigqG4OLE6yt0SXe0S0KXvK4s8ip6ufrH2XtHTwb4C4R
 gVCXx1TZGuKQamiaOxZh5u6Lz9ftLlLYn5LlDkWuLPOoy+QTIZDdhsY/shf0Txa0N8sH
 fWQwyPGp0Qfg/TMgYVH7nErB5q9X6ppZ2dARYyebuY/y+rqmNluviuRh5dUJ+OAfvHq0
 ahhiImiLLa/QtyHyFOJhFaCZIOMAHtTyiLpL282T9fFddkmSbrElNB0H+/rbUB5xLhqx
 tgRw==
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=SQIdg6TnjoeuRcUdTyaXNJxgAyMJlAjtzDj36SV1CAQ=;
 b=gdgx7JJP8CMAXQ9KEymbTre2Nm+t8vVk5IUSNaFBb3sDYqRttDcw6lCmAaNTbNNw0o
 kJL3Zo9IJRrOAqX8Oq9AJ2fdCfDeU8M6hRWH4DNfmH/0qsLxPYA1p8NhVtsNNkmaEmYD
 1PqlYmGSB8yMK42JbIuuPbjfyUda31CufIjTDv2FUPedvnO82pWqvEzW3lm81NXazYjQ
 siaTIL+4KjFTiAH8GkQKw/C1aEnmbCYfJXvYepCgyl/XdXkz9Byx377C51PncBsx2nu7
 X14LVmL+uKErv81691Qzsjew10JSfUPhm0CcQXzuXimoBzDSSGOIwVMzlkUylFZhtPc6
 eFfw==
X-Gm-Message-State: AGi0PuZKTxlm3byAnJh51v+z7BBmI+accXQvlQNLfjyQeorysDcWM5Ip
 Favaey8RzxRzKFSEXQ9leRywBA24fEk=
X-Google-Smtp-Source: APiQypKMOeOTH83fgWKSep3uSuY6xUP+o/FP1EZR6vr2XjzpZzTNVo1DJHvbrzD49178ulM+mSiKGw==
X-Received: by 2002:a1c:c242:: with SMTP id s63mr9891271wmf.180.1589005916184; 
 Fri, 08 May 2020 23:31:56 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id 17sm15914719wmo.2.2020.05.08.23.31.55
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 May 2020 23:31:55 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 5/8] lib/vfscore: Register `creat` to syscall_shim
Date: Sat,  9 May 2020 09:29:43 +0300
Message-Id: <20200509062946.9638-5-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200509062946.9638-1-raducanu.costi@gmail.com>
References: <20200509062946.9638-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `creat` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   | 3 ++-
 lib/vfscore/exportsyms.uk | 2 ++
 lib/vfscore/main.c        | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 8f04e45..5b2c4fb 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -58,4 +58,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += flock-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += unlink-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += stat-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += open-3
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mkdir-2
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mkdir-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += creat-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 307dd5f..34c6540 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -16,6 +16,8 @@ open
 uk_syscall_e_open
 uk_syscall_r_open
 creat
+uk_syscall_e_creat
+uk_syscall_r_creat
 write
 uk_syscall_e_write
 uk_syscall_r_write
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index e5b3a16..c026796 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -185,11 +185,12 @@ int openat(int dirfd, const char *pathname, int flags, ...)
 }
 LFS64(openat);
 
-int creat(const char *pathname, mode_t mode)
+UK_SYSCALL_R_DEFINE(int, creat, const char*, pathname, mode_t, mode)
 {
 	return uk_syscall_e_open((long int) pathname,
 		O_CREAT|O_WRONLY|O_TRUNC, mode);
 }
+
 LFS64(creat);
 
 UK_TRACEPOINT(trace_vfs_close, "%d", int);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 09 06:32:21 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 06:32: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 1jXJ25-0001Jh-5H; Sat, 09 May 2020 06:32:21 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=vNso=6X=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jXJ23-0001JU-FD
 for minios-devel@lists.xen.org; Sat, 09 May 2020 06:32:19 +0000
X-Inumbo-ID: c849429c-91be-11ea-9887-bc764e2007e4
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c849429c-91be-11ea-9887-bc764e2007e4;
 Sat, 09 May 2020 06:31:58 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id l18so4390242wrn.6
 for <minios-devel@lists.xen.org>; Fri, 08 May 2020 23:31:58 -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=fQQ3SU2EHtRL8837k+bdazFCbgPJYyTP1FR0xhKzA8k=;
 b=JDiS9WylhbsYVEDm5g0vgkM+Gem+6uk2G49PEWRaAoYyooRrVKWoIgwnnqjWAlxb6w
 9/ZRZvwcISEFfYEKjPoewUF/bRsi90thm7zB89oR/7/q52OksTB4kHWCK//V7wQpl5AL
 GkJlkwpfYNqH+nowy1Vt1IYy20apmUtVYTwfJlPt/g5hPlwETvhy08kc/L6cVrc3PUwn
 nnr49DdzDRroSCU3m5yKaT05j5vNM9EugOd+w5d04DFZ3cvhy2Sg+HFp9p6gqKJ1KmVn
 6Ibx3bw6k47jReUf8BiSKM10W7G5C7ViWgN5s95zkjMRErPFYfj99pgbVnt2M9eeMxt9
 AIZw==
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=fQQ3SU2EHtRL8837k+bdazFCbgPJYyTP1FR0xhKzA8k=;
 b=YOHsBxBj0OGGvUrDlCzvIX71c85A2RU/4ZLKUh5v2R0WladyV+xD6OX8o0w6lEI8I7
 5dBejIx4IfrDzsntHly2vWUVpvxO61n8rNrTQENEm/sYclorhWmJlPhuHJ5nJn9ndA51
 OIKxkSoBZewzHboHKPILmApeQJ2540Cqjsfa5EBxilUUYBtJblArb/85diTw7gUYYTzg
 MTdpku72VS5GzhLSs8vAdpDoTj00DynXEJnGbkhYG4RyIg5OFQsWTvUzcUnDCkX8Ib/j
 /wDW6zUQUuaV4J3CopyYmDz8vyYbn3HcqFpTbZ76Pqwlctk9R3Aev5Uc1sVO9+R2gwQ6
 mhsg==
X-Gm-Message-State: AGi0PuaqOtKtdY6YM71pLYPKCrcM5zye7sKikseSYr2EpZCpa7SeEZ0z
 mC/5JBJoJGu5MkBAgwopWxcMHTmdse4=
X-Google-Smtp-Source: APiQypLNGg8huG19XIfGFOLakZAm6QqamhFvXJvGku8cK3hHAvV40YdrKQeWtWRHhBM//Jrxcil9KQ==
X-Received: by 2002:a5d:6284:: with SMTP id k4mr7327197wru.40.1589005917090;
 Fri, 08 May 2020 23:31:57 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id 17sm15914719wmo.2.2020.05.08.23.31.56
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 May 2020 23:31:56 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 6/8] lib/vfscore: Register `symlink` to syscall_shim
Date: Sat,  9 May 2020 09:29:44 +0300
Message-Id: <20200509062946.9638-6-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200509062946.9638-1-raducanu.costi@gmail.com>
References: <20200509062946.9638-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `symlink` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   |  3 ++-
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 14 +++++++-------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 5b2c4fb..fcd5c8c 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -59,4 +59,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += unlink-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += stat-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += open-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mkdir-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += creat-2
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += creat-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += symlink-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 34c6540..413ea99 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -126,6 +126,8 @@ fchdir
 uk_syscall_e_fchdir
 uk_syscall_r_fchdir
 symlink
+uk_syscall_e_symlink
+uk_syscall_r_symlink
 statvfs
 fstatvfs
 access
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index c026796..fa43e0e 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -1113,7 +1113,7 @@ UK_TRACEPOINT(trace_vfs_symlink, "oldpath=%s, newpath=%s", const char*,
 UK_TRACEPOINT(trace_vfs_symlink_ret, "");
 UK_TRACEPOINT(trace_vfs_symlink_err, "errno=%d", int);
 
-int symlink(const char *oldpath, const char *newpath)
+UK_SYSCALL_R_DEFINE(int, symlink, const char*, oldpath, const char*, newpath)
 {
 	int error;
 
@@ -1121,20 +1121,20 @@ int symlink(const char *oldpath, const char *newpath)
 
 	error = ENOENT;
 	if (oldpath == NULL || newpath == NULL) {
-		errno = ENOENT;
-		trace_vfs_symlink_err(error);
-		return (-1);
+		goto out_error;
 	}
 
 	error = sys_symlink(oldpath, newpath);
 	if (error) {
-		errno = error;
-		trace_vfs_symlink_err(error);
-		return (-1);
+		goto out_error;
 	}
 
 	trace_vfs_symlink_ret();
 	return 0;
+
+	out_error:
+	trace_vfs_symlink_err(error);
+	return -error;
 }
 
 UK_TRACEPOINT(trace_vfs_unlink, "\"%s\"", const char*);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 09 06:32:26 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 06:32:26 +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 1jXJ2A-0001L1-7r; Sat, 09 May 2020 06:32: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=vNso=6X=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jXJ28-0001Ka-EK
 for minios-devel@lists.xen.org; Sat, 09 May 2020 06:32:24 +0000
X-Inumbo-ID: c8d7f3ca-91be-11ea-9887-bc764e2007e4
Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c8d7f3ca-91be-11ea-9887-bc764e2007e4;
 Sat, 09 May 2020 06:31:59 +0000 (UTC)
Received: by mail-wm1-x344.google.com with SMTP id e26so12395846wmk.5
 for <minios-devel@lists.xen.org>; Fri, 08 May 2020 23:31:59 -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=nPQ4gBQlTxEIq2xvDzCkDAgdWb0AmenDkeZY+zws/0c=;
 b=Sfhx9m9SV9qvHUA2WanYwUAWp/sy/qHhsI/1lASu/PTrp1Zy3P12GCiU7/cSAziOAB
 amWFLmLorQbQYEkS3PeQ0MlXFQBCXk5ByAvBJJijv8hGHmq9jR8in9iP2WAZxYBRIYst
 NOvXdVU3Yk5aOo8YdJ9B4dHfgsCN0uPP4U0Jp0wxpKdzkDbNu0lvT/fTW/UdzLJxkKnU
 t1VYu7rHoSSL4RYOu4ILvI1xUroJT2cevOU7oCswTff3RbaCAN0giIUJeNu4Fb5gb9JO
 lVylwQN4hRvCyPBQH68i6qFTo1KW2CxJg/C3N5QJA8zbBVv0JLk1ldm6zUR42Rwg1uwB
 tkYg==
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=nPQ4gBQlTxEIq2xvDzCkDAgdWb0AmenDkeZY+zws/0c=;
 b=WVjM8OXkxX51zevhSDK/VkekxbohsDiZTFeqcQNCnt2pMW6PfkUyYOn13lD/YId7QU
 T9m/lgFTuoX5oJHX69Mb8NuYOJxiG1d8wK5y3Ou7LrAkkPO8ctYpyThJaw3/gqqdKaHt
 5ff2PGDsIf9/rsfk4nNZteVG8OYrZvs52KIIme3qgH2yURXPq1VMDHM5ZQpPgJM2IPj4
 tt+B4cwXnVzwdRQFklmz3kKTtIXk3ztgjUDpPYYQX8U37i3XNhRr5DtkY0cXs3iB63An
 k3kjYFSrxiCmn1vO2Yb7pnm6aoYL3aTkK3BgwtkRTXRzrSiRFdlKHOFz7J+f6Waj7yqy
 PfBA==
X-Gm-Message-State: AGi0PuZW8/LyZD/A5av2L8RUBEiXZko/RqEtyh2f+mfWRP7CrgxEqgsD
 KrzaRA8WkpUqLzRnvPQqHm7q+AI75uQ=
X-Google-Smtp-Source: APiQypIC2Cztq1VApgF8WG5ljjJs+VMzgMnCvKNZfmcftFYVXvR7J95/R1+JFVF9qW0hqYeiC1298Q==
X-Received: by 2002:a05:600c:22d3:: with SMTP id
 19mr20870016wmg.110.1589005918216; 
 Fri, 08 May 2020 23:31:58 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id 17sm15914719wmo.2.2020.05.08.23.31.57
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 May 2020 23:31:57 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 7/8] lib/vfscore: Register `pipe` to syscall_shim
Date: Sat,  9 May 2020 09:29:45 +0300
Message-Id: <20200509062946.9638-7-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200509062946.9638-1-raducanu.costi@gmail.com>
References: <20200509062946.9638-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `pipe` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   | 3 ++-
 lib/vfscore/exportsyms.uk | 2 ++
 lib/vfscore/pipe.c        | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index fcd5c8c..25088b8 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -60,4 +60,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += stat-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += open-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mkdir-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += creat-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += symlink-2
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += symlink-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pipe-1
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 413ea99..bb489ab 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -184,6 +184,8 @@ vn_stat
 vn_unlock
 vfs_busy
 pipe
+uk_syscall_e_pipe
+uk_syscall_r_pipe
 pipe2
 mkfifo
 futimes
diff --git a/lib/vfscore/pipe.c b/lib/vfscore/pipe.c
index 8d38296..e35862d 100644
--- a/lib/vfscore/pipe.c
+++ b/lib/vfscore/pipe.c
@@ -41,6 +41,7 @@
 #include <vfscore/mount.h>
 #include <vfscore/vnode.h>
 #include <uk/wait.h>
+#include <uk/syscall.h>
 #include <sys/ioctl.h>
 
 /* We use the default size in Linux kernel */
@@ -536,7 +537,7 @@ ERR_EXIT:
 	return ret;
 }
 
-int pipe(int pipefd[2])
+UK_SYSCALL_R_DEFINE(int, pipe, int*, pipefd)
 {
 	int ret = 0;
 	int r_fd, w_fd;
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 09 06:32:30 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 06:32:30 +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 1jXJ2E-0001M5-9S; Sat, 09 May 2020 06:32: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=vNso=6X=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jXJ2D-0001Ly-Eb
 for minios-devel@lists.xen.org; Sat, 09 May 2020 06:32:29 +0000
X-Inumbo-ID: c96d9236-91be-11ea-b9cf-bc764e2007e4
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c96d9236-91be-11ea-b9cf-bc764e2007e4;
 Sat, 09 May 2020 06:32:00 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id w7so4381508wre.13
 for <minios-devel@lists.xen.org>; Fri, 08 May 2020 23:32:00 -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=R2y/K5enEsLY4CJZj7CzKXVa2wegL+epzQyxLdpDj3M=;
 b=dBV+7E+4YLB7sz0Pxz/YpdG1bYi03B8XSozKz6kucEAYU+8IUMmuDQcXByPSur/yna
 JYstTQcUHV+Hvz3MftYJDdf1Ac0zayQlHu4H+oqDJPHN2CeJYgsCHHM5RI2P3VVron++
 Zpg69+udMZpj4SICZ7GjLaW3tV24GyVXYDXWSFNVzQQnoh663b7yD97anItYZx5/eHgX
 D5t8GL7qMAx5wgZzvwUwpMRZNqJBKUh/77+raOZgMDLvCAbyKdKcmusI0JClr1Ap25CX
 fNSzMBPk5mFoH3qLX/K17kCg4YXLxmvJj0YHaH3WFXrA4jp8ntOB8hf4WCmEHq/0X3iJ
 Kc8w==
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=R2y/K5enEsLY4CJZj7CzKXVa2wegL+epzQyxLdpDj3M=;
 b=TM7gU/OgNxsBzHPsUAa1JsGdHQYAMKFcw8txOz56F1q7oojpOxlj6L7ZDGhtIi7p8s
 8Qbt7ThnJHGEbtoYUvnozN++dsYLembFFaNufdCAQeeM5Nvb74k8DYMt09FzSkykg408
 czzZFdhtJLl1QUNNDrSbNVKdLQsVi7t+mGX/6KJ12//Dy7hApXF8rcTy0hlKpMBCcTuR
 mb/Fk2aZeNsSpSuwyweIuhQGFM8WYUX/D5gDY9YYzH1ra0rd4x+sMTF7kZXQAVoq3Qtc
 KteX7KWck49rOSIS2f0Z5tCkxDm2vlR+5EMykoQGZDep0BaAujP1rS43Wf71C0JRahIS
 XtdQ==
X-Gm-Message-State: AGi0PubaV+p1GyxqCbezDlONeOmR5jHVaTqKk2KvQR7DmIY/ddzJh6JG
 cnLXiGaesdnKUdV9rF87qk8Y22pNH9g=
X-Google-Smtp-Source: APiQypI+OElq3HbwMPMKvv5orMR3vFN7rhlpkAxU+Evn7ZRxhFlXP+OEMsYjueJ9hJ3XoN9DPKk+PQ==
X-Received: by 2002:adf:fac5:: with SMTP id a5mr7387149wrs.210.1589005919163; 
 Fri, 08 May 2020 23:31:59 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id 17sm15914719wmo.2.2020.05.08.23.31.58
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 08 May 2020 23:31:58 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 8/8] lib/vfscore: Register `pipe2` to syscall_shim
Date: Sat,  9 May 2020 09:29:46 +0300
Message-Id: <20200509062946.9638-8-raducanu.costi@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200509062946.9638-1-raducanu.costi@gmail.com>
References: <20200509062946.9638-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Registers `pipe2` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 lib/vfscore/Makefile.uk   | 3 ++-
 lib/vfscore/exportsyms.uk | 2 ++
 lib/vfscore/pipe.c        | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 25088b8..69f612f 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -61,4 +61,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += open-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mkdir-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += creat-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += symlink-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pipe-1
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pipe-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pipe2-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index bb489ab..af1b199 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -187,6 +187,8 @@ pipe
 uk_syscall_e_pipe
 uk_syscall_r_pipe
 pipe2
+uk_syscall_e_pipe2
+uk_syscall_r_pipe2
 mkfifo
 futimes
 futimesat
diff --git a/lib/vfscore/pipe.c b/lib/vfscore/pipe.c
index e35862d..c340859 100644
--- a/lib/vfscore/pipe.c
+++ b/lib/vfscore/pipe.c
@@ -574,7 +574,7 @@ ERR_EXIT:
 }
 
 /* TODO find a more efficient way to implement pipe2() */
-int pipe2(int pipefd[2], int flags)
+UK_SYSCALL_R_DEFINE(int, pipe2, int*, pipefd, int, flags)
 {
 	int rc;
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:17 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44:17 +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 1jXSaE-0002A0-GY; Sat, 09 May 2020 16:44:14 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSaD-00029v-32
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:13 +0000
X-Inumbo-ID: 4f3ddeb6-9214-11ea-b07b-bc764e2007e4
Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 4f3ddeb6-9214-11ea-b07b-bc764e2007e4;
 Sat, 09 May 2020 16:44:12 +0000 (UTC)
Received: by mail-wm1-x341.google.com with SMTP id e26so13351551wmk.5
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44:11 -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=RllLU4/hD40vzMt18jMSiScY2rYzhMpBOs2x/smAUAs=;
 b=GNudeHLi495xqWVnNCXDWyQPayLpW8+rWtn3Bv7DpN7wT6bE0VB1gvIi+AxmB3UC0c
 F1NUmr6uz1RsNM3FcbeKKIYeSuQMAAKLK/a9eTADTX0Nq/3lC3lxlIisLIYdXU2oT8w/
 dJA93hDwn4KCrvvj0TaXNWa+KtryS8g9xnXxqAnrLcMIWKUFJX5+rkY6FbFOGkkwhzWv
 /GGRdAx/FT4L8drk4Rj86fjZpWo7CY3Qxnuc+WddUUrCRWhE91D1a0avn4zD9yxFGBTU
 VyHGNpS6pwbhVxsE7L7kYDlO4Pwy72+fPnmcjPmUMpv5W9u+ct6+yG6x/xR3hAjEKtBp
 XBTg==
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=RllLU4/hD40vzMt18jMSiScY2rYzhMpBOs2x/smAUAs=;
 b=DukSEjSc2oXl4Ixr+j9gLqbwjXwGeIQsPrIjeg75hVe9YhmZvavXWb8+RC6faBafJi
 KWovfOnTFprYvk5syNDgJFykyjVOTmFoNhqiUHNstw1mFxUCLlcs1mYPvdPZOviw71bk
 DyrHRrqIqeYOpIyMbWRuFHFhcoak7v8rCc38qQvsIboyQN8acYOknCW3PGRJU5jPlIvF
 ve/Zn7RXS/x0I0vQWmKZ/fxS8J8Ng4rtxZ/raUakxGP6dAXsHXWOjgPbZPW7LKAeBdCC
 NosZhAVs2ulGJ/oGqu6ekFXt7ADtVQ9SZvQzhTPVX1uNJ1tIz1fDasxFhPDoWMi4kxaI
 cP6Q==
X-Gm-Message-State: AGi0PuZhMXzSF7q5OI3NSw8dXSFsA35Y7eQzWM0Z0LeXdwrWwevmiM+V
 ewT6m/4flMtwrRmQ+JB37Oj/UMhnfUQ=
X-Google-Smtp-Source: APiQypLyalTI7Lu7IBL8zFud8j22mbUAbpuDh0VMFloGvpfBmmAtoTlcLPffDy92LlynvRAq7GbjYQ==
X-Received: by 2002:a7b:cd04:: with SMTP id f4mr21118841wmj.3.1589042650941;
 Sat, 09 May 2020 09:44:10 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.10
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:10 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 0/9] General 9pfs and vfscore improvements
Date: Sat,  9 May 2020 17:44:04 +0100
Message-Id: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch series adds general 9pfs improvements, for correctness,
readability and performance.

Changes since v1:
- The vfscore improvements have been upstreamed directly from v1, so
they are no longer present in v2.
- Split the serialization rewrite patch into four smaller patches.
- Removed the `uk_9p_trace_message{,_end}` traces, as they were too
verbose.
- Fixed a typo in a uk_9p_version comment.

Cristian Banu (9):
  lib/uk9p: Add new serialization mechanism
  lib/uk9p: Switch to using the new serialization
  lib/uk9p: Delete the old serialization
  lib/uk9p: Simplify uk_9p_walk serialization
  lib/uk9p: Add uk_traces
  lib/uk9p: Change severity of uk_9p_version log
  lib/uk9p: Use fixed-size request buffers
  lib/uk9p: Recycle uk_9preq allocations
  lib/9pfs: Simplify the logic for removes

 lib/9pfs/9pfs_vfsops.c           |   7 +-
 lib/9pfs/9pfs_vnops.c            |  39 +--
 lib/uk9p/9p.c                    | 341 +++++++++++++++-----------
 lib/uk9p/9pdev.c                 | 125 ++++++----
 lib/uk9p/9preq.c                 | 396 +++----------------------------
 lib/uk9p/exportsyms.uk           |   7 -
 lib/uk9p/include/uk/9pdev.h      |  38 +--
 lib/uk9p/include/uk/9pdev_core.h |   2 +
 lib/uk9p/include/uk/9preq.h      | 283 ++++++++++++++++------
 9 files changed, 559 insertions(+), 679 deletions(-)

-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:19 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44: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 1jXSaJ-0002AN-I8; Sat, 09 May 2020 16:44:19 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSaH-0002A7-VP
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:18 +0000
X-Inumbo-ID: 4fba0a2c-9214-11ea-b9cf-bc764e2007e4
Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 4fba0a2c-9214-11ea-b9cf-bc764e2007e4;
 Sat, 09 May 2020 16:44:12 +0000 (UTC)
Received: by mail-wm1-x341.google.com with SMTP id f134so1179443wmf.1
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44:12 -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=90RJSGFiO4ALdh0E1H54wW8gupSfMclNbe0IuXzkdcQ=;
 b=hMLtpA2MOiTWSS8CFjUPauBETEi6Ka5JvrFpsgj5Gmom9f8tj6WS6wejJOAdnwmbcU
 +gF9rHyDvoL6FoaBJx/9s2EXpcOgPqUJAOClo6qUWVcQUHc6Qc7JLUA6vxj+Gz0wM94u
 TwsWPkEl2svmNgD27XPQIoDC5vqb/q8xU5GdVNow9iZwHnO/lEeLBYQ6Ju83Z6IfuSAI
 PfEZEuyI0fCp4rfrAtaYv2nkNnbE7K53V6xRblJUBXIF3SR1e/98YWpS/7piF3WQBPsi
 kaUV1z6KYQQD1Am7MMmLntsaERwb1Wj17PAZvWiB3Crp4UY19ZfmIWs4ZQJ+jDtNKAVL
 1ZTA==
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=90RJSGFiO4ALdh0E1H54wW8gupSfMclNbe0IuXzkdcQ=;
 b=gmu+/sKov2RMfP6Ag006QPvaZ0ItZMPwtNZvHsFnUSo0yzeTA7yYbJgMSw7dCQbGex
 lDc1o0l4bLv7agRecqtKjveWnaEbQ7BAljmJFK4Ah61iNGWT/lIRBy3OgwNf3m38H3vg
 XnmlaDHZxHzQryPxSixQFGEzDZPXfwnTdBQ1jQhfA2p3s3uAjnqbz2s2jB3zNkRKVQbY
 MjCjeK45I5kHmXR1YCqmXqccJ0fjfNHfHsjxr6Gs86hB/j0kWBz1G5pPKnwf+h9ATv0g
 WFC/UnNPYJKU5YZN1uj+W+g4jRwMvoTUuZyDBMe/Lg3fA16XN2iZIdVvi5oOkL8bI0LP
 Iteg==
X-Gm-Message-State: AGi0PubdqFLe+PlSzkPELUPnihBLqQkRq09y9iEx9gSL9Me3s1qttHIZ
 33MzXfkg7TS/LJzzA07gCK7Wi7WcBAs=
X-Google-Smtp-Source: APiQypJ7uwy1n6Ic+/CKPZ97AxRxeHxM+fZJHSEwX+fBg3LA2jXEJ36FMW3k9S4opZTiZw7zn4hsWg==
X-Received: by 2002:a1c:9cca:: with SMTP id f193mr21401076wme.71.1589042651686; 
 Sat, 09 May 2020 09:44:11 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.11
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:11 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 1/9] lib/uk9p: Add new serialization mechanism
Date: Sat,  9 May 2020 17:44:05 +0100
Message-Id: <20200509164413.38078-2-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200509164413.38078-1-cristb@gmail.com>
References: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch implements serialization in a type-safe way: the compiler can
issue warnings if the data types don't match.  Previously the types were
hidden behind a va_list and thus unchecked.

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/include/uk/9preq.h | 184 ++++++++++++++++++++++++++++++++++++
 1 file changed, 184 insertions(+)

diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
index ee4d2af..70c1b03 100644
--- a/lib/uk9p/include/uk/9preq.h
+++ b/lib/uk9p/include/uk/9preq.h
@@ -41,6 +41,7 @@
 #include <uk/essentials.h>
 #include <uk/list.h>
 #include <uk/refcount.h>
+#include <uk/9p_core.h>
 #if CONFIG_LIBUKSCHED
 #include <uk/wait_types.h>
 #endif
@@ -293,6 +294,189 @@ int uk_9preq_waitreply(struct uk_9preq *req);
  */
 int uk_9preq_error(struct uk_9preq *req);
 
+/*
+ * The following family of serialization and deserialization functions
+ * are used for writing the 'base' types the 9p protocol supports.
+ *
+ * These are defined in the header for better performance by not necessarily
+ * incurring a function call penalty if called from outside uk9p.
+ *
+ * Provided functions:
+ * - uk_9preq_{read,write}buf
+ * - uk_9preq_{read,write}8
+ * - uk_9preq_{read,write}16
+ * - uk_9preq_{read,write}32
+ * - uk_9preq_{read,write}64
+ * - uk_9preq_{read,write}qid
+ * - uk_9preq_{read,write}str
+ * - uk_9preq_{read,write}stat
+ *
+ * For qid, str and stat, read and write always take a pointer.
+ * For all other types, write takes the argument by value.
+ *
+ * Possible return values:
+ * - 0: Operation successful.
+ * - (-ENOBUFS): End of buffer reached.
+ */
+
+static inline int uk_9preq_writebuf(struct uk_9preq *req, const void *buf,
+		uint32_t size)
+{
+	if (req->xmit.offset + size > req->xmit.size)
+		return -ENOBUFS;
+
+	memcpy((char *)req->xmit.buf + req->xmit.offset, buf, size);
+	req->xmit.offset += size;
+	return 0;
+}
+
+static inline int uk_9preq_readbuf(struct uk_9preq *req, void *buf,
+		uint32_t size)
+{
+	if (req->recv.offset + size > req->recv.size)
+		return -ENOBUFS;
+
+	memcpy(buf, (char *)req->recv.buf + req->recv.offset, size);
+	req->recv.offset += size;
+	return 0;
+}
+
+#define _UK_9PREQ_DEFINE_WRITE_FN(name, ctype) \
+static inline int uk_9preq_##name(struct uk_9preq *req, ctype val) \
+{ \
+	return uk_9preq_writebuf(req, &val, sizeof(val)); \
+}
+
+_UK_9PREQ_DEFINE_WRITE_FN(write8, uint8_t)
+_UK_9PREQ_DEFINE_WRITE_FN(write16, uint16_t)
+_UK_9PREQ_DEFINE_WRITE_FN(write32, uint32_t)
+_UK_9PREQ_DEFINE_WRITE_FN(write64, uint64_t)
+
+#undef _UK_9PREQ_DEFINE_WRITE_FN
+
+static inline int uk_9preq_writeqid(struct uk_9preq *req, struct uk_9p_qid *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_write8(req, val->type)) ||
+		(rc = uk_9preq_write32(req, val->version)) ||
+		(rc = uk_9preq_write64(req, val->path)))
+		return rc;
+
+	return 0;
+}
+
+static inline int uk_9preq_writestr(struct uk_9preq *req, struct uk_9p_str *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_write16(req, val->size)) ||
+		(rc = uk_9preq_writebuf(req, val->data, val->size)))
+		return rc;
+
+	return 0;
+}
+
+static inline int uk_9preq_writestat(struct uk_9preq *req,
+		struct uk_9p_stat *val)
+{
+	int rc;
+
+	val->size = 61;
+	val->size += val->name.size;
+	val->size += val->uid.size;
+	val->size += val->gid.size;
+	val->size += val->muid.size;
+	val->size += val->extension.size;
+
+	if ((rc = uk_9preq_write16(req, val->size)) ||
+		(rc = uk_9preq_write16(req, val->type)) ||
+		(rc = uk_9preq_write32(req, val->dev)) ||
+		(rc = uk_9preq_writeqid(req, &val->qid)) ||
+		(rc = uk_9preq_write32(req, val->mode)) ||
+		(rc = uk_9preq_write32(req, val->atime)) ||
+		(rc = uk_9preq_write32(req, val->mtime)) ||
+		(rc = uk_9preq_write64(req, val->length)) ||
+		(rc = uk_9preq_writestr(req, &val->name)) ||
+		(rc = uk_9preq_writestr(req, &val->uid)) ||
+		(rc = uk_9preq_writestr(req, &val->gid)) ||
+		(rc = uk_9preq_writestr(req, &val->muid)) ||
+		(rc = uk_9preq_writestr(req, &val->extension)) ||
+		(rc = uk_9preq_write32(req, val->n_uid)) ||
+		(rc = uk_9preq_write32(req, val->n_gid)) ||
+		(rc = uk_9preq_write32(req, val->n_muid)))
+		return rc;
+
+	return 0;
+}
+
+#define _UK_9PREQ_DEFINE_READ_FN(name, ctype) \
+static inline int uk_9preq_##name(struct uk_9preq *req, ctype * val) \
+{ \
+	return uk_9preq_readbuf(req, val, sizeof(*val)); \
+}
+
+_UK_9PREQ_DEFINE_READ_FN(read8, uint8_t)
+_UK_9PREQ_DEFINE_READ_FN(read16, uint16_t)
+_UK_9PREQ_DEFINE_READ_FN(read32, uint32_t)
+_UK_9PREQ_DEFINE_READ_FN(read64, uint64_t)
+
+#undef _UK_9PREQ_DEFINE_READ_FN
+
+static inline int uk_9preq_readqid(struct uk_9preq *req, struct uk_9p_qid *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_read8(req, &val->type)) ||
+		(rc = uk_9preq_read32(req, &val->version)) ||
+		(rc = uk_9preq_read64(req, &val->path)))
+		return rc;
+
+	return 0;
+}
+
+static inline int uk_9preq_readstr(struct uk_9preq *req, struct uk_9p_str *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_read16(req, &val->size)))
+		return rc;
+
+	/* Optimized string read, does not allocate memory. */
+	val->data = (char *)req->recv.buf + req->recv.offset;
+	req->recv.offset += val->size;
+	if (req->recv.offset > req->recv.size)
+		return -ENOBUFS;
+
+	return 0;
+}
+
+static inline int uk_9preq_readstat(struct uk_9preq *req,
+		struct uk_9p_stat *val)
+{
+	int rc;
+
+	if ((rc = uk_9preq_read16(req, &val->size)) ||
+		(rc = uk_9preq_read16(req, &val->type)) ||
+		(rc = uk_9preq_read32(req, &val->dev)) ||
+		(rc = uk_9preq_readqid(req, &val->qid)) ||
+		(rc = uk_9preq_read32(req, &val->mode)) ||
+		(rc = uk_9preq_read32(req, &val->atime)) ||
+		(rc = uk_9preq_read32(req, &val->mtime)) ||
+		(rc = uk_9preq_read64(req, &val->length)) ||
+		(rc = uk_9preq_readstr(req, &val->name)) ||
+		(rc = uk_9preq_readstr(req, &val->uid)) ||
+		(rc = uk_9preq_readstr(req, &val->gid)) ||
+		(rc = uk_9preq_readstr(req, &val->muid)) ||
+		(rc = uk_9preq_readstr(req, &val->extension)) ||
+		(rc = uk_9preq_read32(req, &val->n_uid)) ||
+		(rc = uk_9preq_read32(req, &val->n_gid)) ||
+		(rc = uk_9preq_read32(req, &val->n_muid)))
+		return rc;
+
+	return 0;
+}
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44: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 1jXSaO-0002B2-Jk; Sat, 09 May 2020 16:44:24 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSaM-0002Ar-VU
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:23 +0000
X-Inumbo-ID: 5091612a-9214-11ea-b07b-bc764e2007e4
Received: from mail-wm1-x333.google.com (unknown [2a00:1450:4864:20::333])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 5091612a-9214-11ea-b07b-bc764e2007e4;
 Sat, 09 May 2020 16:44:14 +0000 (UTC)
Received: by mail-wm1-x333.google.com with SMTP id m12so8434898wmc.0
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44: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=AyvGTwMhA9GW9Hxd2bjdKIDCPE2oYcmsZAdX5g5kDnY=;
 b=nsh63GTdm3/e2mtJODNX0Sq71nhy5ix5zAPgv5pW9YrNLSdT45M7X5cTjvn26Rd8s1
 CNpd6+BUDa/89HivE3X9DDzqM+0MDhQO2r5BE8BHpvTlWaBen9sfqDE6x1OP97290s85
 tuMZWHHNP4L3EAecpC6ouQ0f6gOXgJsSUDFvES/Uaxu/iRaPFsMAB7t6P5q73Mqvy9Ww
 M1maZ51oH9do0S1s2hXO2kOPnM66J10Uy7fnOT05qIlh/KswMDFRw6ezA7BXwAQDKvK9
 wF3kcBtDPdJSI5SEj+wjBAVdE5POK/L64lDaypgCIQ6WfWDmlYdHrYPUgifGBlU7QLJ5
 3xBQ==
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=AyvGTwMhA9GW9Hxd2bjdKIDCPE2oYcmsZAdX5g5kDnY=;
 b=uPNbKbSRM1/WWSwVVWSethMJTIw/y1OJdOV31Az7xHRboxUpOSJT9RLQIG/UWbWzOw
 MizBtkLmk+HIE4gh5H7SxxQRmwAb5rP8yWFA34DbLHIKj10hXFm6stjm8myhSge/DyTm
 JGou0tXIkI94wvv1d5obY/ReXGrGggCEzKoxb0Sx7OppYrDv0N6tkSvmsm7pguZvn7vv
 0GyxUphKZazDgyxPz0ExJifdS4POmMZMsL79jcuji12JbmwYijlWY7IhmzHQ2zUB3IT4
 b71mjacN1W43TvwEt9jzV+7Oi0UHvd1wPAQNjBGIOpYUDABcMesa44Ia6up14Xs+nibJ
 h4aQ==
X-Gm-Message-State: AGi0PuYPFv21hinOxO9Ug6O9d3LO/ZEt/aJf9vFFRpYLOt2G7IteaovP
 O4JJUvFPQ/+V+eHC8cRRf5+Gsd02GiA=
X-Google-Smtp-Source: APiQypImqK37RWNWg/gim4cvsl/4LwyK7c9qv+nGdwJRp9feWy6+bljgxdJ+mltEfj5UDuoo3NUslw==
X-Received: by 2002:a7b:c147:: with SMTP id z7mr23493094wmi.52.1589042652737; 
 Sat, 09 May 2020 09:44:12 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.11
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:11 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 2/9] lib/uk9p: Switch to using the new
 serialization
Date: Sat,  9 May 2020 17:44:06 +0100
Message-Id: <20200509164413.38078-3-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200509164413.38078-1-cristb@gmail.com>
References: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch migrates 9p.c and 9pfs to use the new serialization
implementation.

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/9pfs/9pfs_vnops.c |   2 +-
 lib/uk9p/9p.c         | 302 +++++++++++++++++++++++++-----------------
 lib/uk9p/9preq.c      |  27 ++--
 3 files changed, 192 insertions(+), 139 deletions(-)

diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
index 5e6a7bb..6d3ece3 100644
--- a/lib/9pfs/9pfs_vnops.c
+++ b/lib/9pfs/9pfs_vnops.c
@@ -409,7 +409,7 @@ again:
 	fake_request.recv.size = fd->readdir_sz;
 	fake_request.recv.offset = fd->readdir_off;
 	fake_request.state = UK_9PREQ_RECEIVED;
-	rc = uk_9preq_deserialize(&fake_request, "S", &stat);
+	rc = uk_9preq_readstat(&fake_request, &stat);
 
 	if (rc == -ENOBUFS) {
 		/*
diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index eb4c2dc..638555b 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -40,28 +40,49 @@
 #include <uk/9preq.h>
 #include <uk/9pfid.h>
 
+static inline int send_and_wait_zc(struct uk_9pdev *dev, struct uk_9preq *req,
+		enum uk_9preq_zcdir zc_dir, void *zc_buf, uint32_t zc_size,
+		uint32_t zc_offset)
+{
+	int rc;
+
+	if ((rc = uk_9preq_ready(req, zc_dir, zc_buf, zc_size, zc_offset)) ||
+		(rc = uk_9pdev_request(dev, req)) ||
+		(rc = uk_9preq_waitreply(req)))
+		return rc;
+
+	return 0;
+}
+
+static inline int send_and_wait_no_zc(struct uk_9pdev *dev,
+		struct uk_9preq *req)
+{
+	return send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
+}
+
 struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 		const char *requested, struct uk_9p_str *received)
 {
 	struct uk_9p_str requested_str;
 	struct uk_9preq *req;
-	int rc;
+	int rc = 0;
 	uint32_t new_msize;
 
 	uk_9p_str_init(&requested_str, requested);
 
-	uk_pr_debug("TVERSION msize %u version %s\n",
-			dev->msize, requested);
-
-	req = uk_9pdev_call(dev, UK_9P_TVERSION, __PAGE_SIZE, "ds",
-			dev->msize, &requested_str);
+	req = uk_9pdev_req_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return req;
 
-	rc = uk_9preq_deserialize(req, "ds", &new_msize, received);
+	uk_pr_debug("TVERSION msize %u version %s\n",
+			dev->msize, requested);
 
-	if (rc)
-		return ERR2PTR(rc);
+	if ((rc = uk_9preq_write32(req, dev->msize)) ||
+		(rc = uk_9preq_writestr(req, &requested_str)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_read32(req, &new_msize)) ||
+		(rc = uk_9preq_readstr(req, received)))
+		goto free;
 
 	uk_pr_debug("RVERSION msize %u version %.*s\n", new_msize,
 			received->size, received->data);
@@ -76,6 +97,10 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 		uk_pr_debug("Invalid new message size.\n");
 
 	return req;
+
+free:
+	uk_9pdev_req_remove(dev, req);
+	return ERR2PTR(rc);
 }
 
 struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
@@ -94,43 +119,56 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
 	if (PTRISERR(fid))
 		return fid;
 
-	uk_pr_debug("TATTACH fid %u afid %u uname %s aname %s n_uname %u\n",
-			fid->fid, afid, uname, aname, n_uname);
-
-	req = uk_9pdev_call(dev, UK_9P_TATTACH, __PAGE_SIZE, "ddssd",
-			fid->fid, afid, &uname_str, &aname_str, n_uname);
+	req = uk_9pdev_req_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
 	if (PTRISERR(req)) {
 		uk_9pdev_fid_release(fid);
 		return (void *)req;
 	}
 
-	rc = uk_9preq_deserialize(req, "Q", &fid->qid);
+	uk_pr_debug("TATTACH fid %u afid %u uname %s aname %s n_uname %u\n",
+			fid->fid, afid, uname, aname, n_uname);
+
+	rc = 0;
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write32(req, afid)) ||
+		(rc = uk_9preq_writestr(req, &uname_str)) ||
+		(rc = uk_9preq_writestr(req, &aname_str)) ||
+		(rc = uk_9preq_write32(req, n_uname)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_readqid(req, &fid->qid)))
+		goto free;
+
 	uk_9pdev_req_remove(dev, req);
 
 	uk_pr_debug("RATTACH qid type %u version %u path %lu\n",
 			fid->qid.type, fid->qid.version, fid->qid.path);
 
-	if (rc < 0) {
-		uk_9pdev_fid_release(fid);
-		return ERR2PTR(rc);
-	}
-
 	return fid;
+
+free:
+	uk_9pdev_fid_release(fid);
+	uk_9pdev_req_remove(dev, req);
+	return ERR2PTR(rc);
 }
 
 int uk_9p_flush(struct uk_9pdev *dev, uint16_t oldtag)
 {
 	struct uk_9preq *req;
+	int rc = 0;
 
-	uk_pr_debug("TFLUSH oldtag %u\n", oldtag);
-	req = uk_9pdev_call(dev, UK_9P_TFLUSH, __PAGE_SIZE, "w", oldtag);
+	req = uk_9pdev_req_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
+	uk_pr_debug("TFLUSH oldtag %u\n", oldtag);
+	if ((rc = uk_9preq_write16(req, oldtag)) ||
+		(rc = send_and_wait_no_zc(dev, req)))
+		goto out;
 	uk_pr_debug("RFLUSH\n");
-	uk_9pdev_req_remove(dev, req);
 
-	return 0;
+out:
+	uk_9pdev_req_remove(dev, req);
+	return rc;
 }
 
 struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
@@ -141,7 +179,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	struct uk_9p_str name_str;
 	uint16_t nwqid;
 	uint16_t nwname;
-	int rc;
+	int rc = 0;
 
 	uk_9p_str_init(&name_str, name);
 
@@ -151,51 +189,56 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 
 	nwname = name ? 1 : 0;
 
+	req = uk_9pdev_req_create(dev, UK_9P_TWALK, __PAGE_SIZE);
+	if (PTRISERR(req)) {
+		rc = PTR2ERR(req);
+		goto out;
+	}
+
 	if (name) {
 		uk_pr_debug("TWALK fid %u newfid %u nwname %d name %s\n",
 				fid->fid, newfid->fid, nwname, name);
-		req = uk_9pdev_call(dev, UK_9P_TWALK, __PAGE_SIZE, "ddws",
-				fid->fid, newfid->fid, nwname, &name_str);
+		if ((rc = uk_9preq_write32(req, fid->fid)) ||
+			(rc = uk_9preq_write32(req, newfid->fid)) ||
+			(rc = uk_9preq_write16(req, nwname)) ||
+			(rc = uk_9preq_writestr(req, &name_str)))
+			goto out;
 	} else {
 		uk_pr_debug("TWALK fid %u newfid %u nwname %d\n",
 				fid->fid, newfid->fid, nwname);
-		req = uk_9pdev_call(dev, UK_9P_TWALK, __PAGE_SIZE, "ddw",
-				fid->fid, newfid->fid, nwname);
+		if ((rc = uk_9preq_write32(req, fid->fid)) ||
+			(rc = uk_9preq_write32(req, newfid->fid)) ||
+			(rc = uk_9preq_write16(req, nwname)))
+			goto out;
 	}
 
-	if (PTRISERR(req)) {
+	if ((rc = send_and_wait_no_zc(dev, req))) {
 		/*
 		 * Don't clunk if request has finished with error, as the fid
 		 * is invalid.
 		 */
 		newfid->was_removed = 1;
-		rc = PTR2ERR(req);
 		goto out;
 	}
 
-	rc = uk_9preq_deserialize(req, "w", &nwqid);
-	if (rc < 0)
-		goto out_req;
+	if ((rc = uk_9preq_read16(req, &nwqid)))
+		goto out;
 
 	uk_pr_debug("RWALK nwqid %u\n", nwqid);
 
 	if (nwqid != nwname) {
 		rc = -ENOENT;
-		goto out_req;
+		goto out;
 	}
 
-
 	if (nwname) {
-		rc = uk_9preq_deserialize(req, "Q", &newfid->qid);
-		if (rc < 0)
-			goto out_req;
+		if ((rc = uk_9preq_readqid(req, &newfid->qid)))
+			goto out;
 	} else
 		newfid->qid = fid->qid;
 
-	rc = 0;
-out_req:
-	uk_9pdev_req_remove(dev, req);
 out:
+	uk_9pdev_req_remove(dev, req);
 	if (rc) {
 		uk_9pdev_fid_release(newfid);
 		return ERR2PTR(rc);
@@ -207,22 +250,27 @@ out:
 int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
 {
 	struct uk_9preq *req;
-	int rc;
-
-	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
+	int rc = 0;
 
-	req = uk_9pdev_call(dev, UK_9P_TOPEN, __PAGE_SIZE, "db",
-			fid->fid, mode);
+	req = uk_9pdev_req_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	rc = uk_9preq_deserialize(req, "Qd", &fid->qid, &fid->iounit);
-	uk_9pdev_req_remove(dev, req);
+	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
+
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write8(req, mode)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_readqid(req, &fid->qid)) ||
+		(rc = uk_9preq_read32(req, &fid->iounit)))
+		goto out;
 
 	uk_pr_debug("ROPEN qid type %u version %u path %lu iounit %u\n",
 			fid->qid.type, fid->qid.version, fid->qid.path,
 			fid->iounit);
 
+out:
+	uk_9pdev_req_remove(dev, req);
 	return rc;
 }
 
@@ -233,63 +281,80 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	struct uk_9preq *req;
 	struct uk_9p_str name_str;
 	struct uk_9p_str extension_str;
-	int rc;
+	int rc = 0;
 
 	uk_9p_str_init(&name_str, name);
 	uk_9p_str_init(&extension_str, extension);
 
-	uk_pr_debug("TCREATE fid %u name %s perm %u mode %u ext %s\n",
-			fid->fid, name, perm, mode, extension);
-
-	req = uk_9pdev_call(dev, UK_9P_TCREATE, __PAGE_SIZE, "dsdbs",
-			fid->fid, &name_str, perm, mode, &extension_str);
+	req = uk_9pdev_req_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	rc = uk_9preq_deserialize(req, "Qd", &fid->qid, &fid->iounit);
-	uk_9pdev_req_remove(dev, req);
+	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
+
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_writestr(req, &name_str)) ||
+		(rc = uk_9preq_write32(req, perm)) ||
+		(rc = uk_9preq_write8(req, mode)) ||
+		(rc = uk_9preq_writestr(req, &extension_str)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_readqid(req, &fid->qid)) ||
+		(rc = uk_9preq_read32(req, &fid->iounit)))
+		goto out;
 
 	uk_pr_debug("RCREATE qid type %u version %u path %lu iounit %u\n",
 			fid->qid.type, fid->qid.version, fid->qid.path,
 			fid->iounit);
 
+out:
+	uk_9pdev_req_remove(dev, req);
 	return rc;
 }
 
 int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
 {
 	struct uk_9preq *req;
+	int rc = 0;
 
 	/* The fid is considered invalid even if the remove fails. */
 	fid->was_removed = 1;
 
-	uk_pr_debug("TREMOVE fid %u\n", fid->fid);
-	req = uk_9pdev_call(dev, UK_9P_TREMOVE, __PAGE_SIZE, "d", fid->fid);
+	req = uk_9pdev_req_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_9pdev_req_remove(dev, req);
+	uk_pr_debug("TREMOVE fid %u\n", fid->fid);
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = send_and_wait_no_zc(dev, req)))
+		goto out;
 	uk_pr_debug("RREMOVE\n");
 
-	return 0;
+out:
+	uk_9pdev_req_remove(dev, req);
+	return rc;
 }
 
 int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
 {
 	struct uk_9preq *req;
+	int rc = 0;
 
 	if (fid->was_removed)
 		return 0;
 
-	uk_pr_debug("TCLUNK fid %u\n", fid->fid);
-	req = uk_9pdev_call(dev, UK_9P_TCLUNK, __PAGE_SIZE, "d", fid->fid);
+	req = uk_9pdev_req_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	uk_9pdev_req_remove(dev, req);
+	uk_pr_debug("TCLUNK fid %u\n", fid->fid);
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = send_and_wait_no_zc(dev, req)))
+		goto out;
 	uk_pr_debug("RCLUNK\n");
 
-	return 0;
+out:
+	uk_9pdev_req_remove(dev, req);
+	return rc;
 }
 
 int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
@@ -309,24 +374,12 @@ int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	rc = uk_9preq_serialize(req, "dqd", fid->fid, offset, count);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_READ, buf, count, 11);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9pdev_request(dev, req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_waitreply(req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_deserialize(req, "d", &count);
-	if (rc < 0)
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write64(req, offset)) ||
+		(rc = uk_9preq_write32(req, count)) ||
+		(rc = send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_READ, buf,
+				       count, 11)) ||
+		(rc = uk_9preq_read32(req, &count)))
 		goto out;
 
 	uk_pr_debug("RREAD count %u\n", count);
@@ -353,24 +406,12 @@ int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-	rc = uk_9preq_serialize(req, "dqd", fid->fid, offset, count);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_WRITE, (void *)buf, count, 23);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9pdev_request(dev, req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_waitreply(req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_deserialize(req, "d", &count);
-	if (rc < 0)
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write64(req, offset)) ||
+		(rc = uk_9preq_write32(req, count)) ||
+		(rc = send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_WRITE,
+				(void *)buf, count, 23)) ||
+		(rc = uk_9preq_read32(req, &count)))
 		goto out;
 
 	uk_pr_debug("RWRITE count %u\n", count);
@@ -386,45 +427,58 @@ struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		struct uk_9p_stat *stat)
 {
 	struct uk_9preq *req;
-	int rc;
+	int rc = 0;
 	uint16_t dummy;
 
-	uk_pr_debug("TSTAT fid %u\n", fid->fid);
-	req = uk_9pdev_call(dev, UK_9P_TSTAT, __PAGE_SIZE, "d", fid->fid);
+	req = uk_9pdev_req_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return req;
 
-	rc = uk_9preq_deserialize(req, "wS", &dummy, stat);
-	if (rc)
-		return ERR2PTR(rc);
+	uk_pr_debug("TSTAT fid %u\n", fid->fid);
+
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = send_and_wait_no_zc(dev, req)) ||
+		(rc = uk_9preq_read16(req, &dummy)) ||
+		(rc = uk_9preq_readstat(req, stat)))
+		goto out;
+
 	uk_pr_debug("RSTAT\n");
 
 	return req;
+
+out:
+	uk_9pdev_req_remove(dev, req);
+	return ERR2PTR(rc);
 }
 
 int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		struct uk_9p_stat *stat)
 {
 	struct uk_9preq *req;
+	int rc = 0;
+	uint16_t *dummy;
 
-	/*
-	 * The packed size of stat is 61 bytes + the size occupied by the
-	 * strings.
-	 */
-	stat->size = 61;
-	stat->size += stat->name.size;
-	stat->size += stat->uid.size;
-	stat->size += stat->gid.size;
-	stat->size += stat->muid.size;
-	stat->size += stat->extension.size;
-
-	uk_pr_debug("TWSTAT fid %u\n", fid->fid);
-	req = uk_9pdev_call(dev, UK_9P_TWSTAT, __PAGE_SIZE, "dwS", fid->fid,
-			stat->size + 2, stat);
+	req = uk_9pdev_req_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
-	uk_9pdev_req_remove(dev, req);
-	uk_pr_debug("RWSTAT");
 
-	return 0;
+	uk_pr_debug("TWSTAT fid %u\n", fid->fid);
+
+	if ((rc = uk_9preq_write32(req, fid->fid)))
+		goto out;
+
+	dummy = (uint16_t *)(req->xmit.buf + req->xmit.offset);
+	if ((rc = uk_9preq_write16(req, 0)) ||
+		(rc = uk_9preq_writestat(req, stat)))
+		goto out;
+	*dummy = stat->size + 2;
+
+	if ((rc = send_and_wait_no_zc(dev, req)))
+		goto out;
+
+	uk_pr_debug("RWSTAT\n");
+
+out:
+	uk_9pdev_req_remove(dev, req);
+	return rc;
 }
diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
index 0fc4b1e..8d787e7 100644
--- a/lib/uk9p/9preq.c
+++ b/lib/uk9p/9preq.c
@@ -434,10 +434,8 @@ int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
 
 	UK_ASSERT(req);
 
-	if (UK_READ_ONCE(req->state) != UK_9PREQ_INITIALIZED) {
-		rc = -EIO;
-		goto out;
-	}
+	if (UK_READ_ONCE(req->state) != UK_9PREQ_INITIALIZED)
+		return -EIO;
 
 	/* Save current offset as the size of the message. */
 	total_size = req->xmit.offset;
@@ -448,10 +446,10 @@ int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
 
 	/* Serialize the header. */
 	req->xmit.offset = 0;
-	rc = uk_9preq_serialize(req, "dbw", total_size_with_zc, req->xmit.type,
-			req->tag);
-	if (rc < 0)
-		goto out;
+	if ((rc = uk_9preq_write32(req, total_size_with_zc)) < 0 ||
+		(rc = uk_9preq_write8(req, req->xmit.type)) < 0 ||
+		(rc = uk_9preq_write16(req, req->tag)) < 0)
+		return rc;
 
 	/* Reset offset and size to sane values. */
 	req->xmit.offset = 0;
@@ -474,8 +472,7 @@ int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
 	/* Update the state. */
 	UK_WRITE_ONCE(req->state, UK_9PREQ_READY);
 
-out:
-	return rc;
+	return 0;
 }
 
 int uk_9preq_receive_cb(struct uk_9preq *req, uint32_t recv_size)
@@ -495,8 +492,10 @@ int uk_9preq_receive_cb(struct uk_9preq *req, uint32_t recv_size)
 	/* Deserialize the header into request fields. */
 	req->recv.offset = 0;
 	req->recv.size = recv_size;
-	rc = _fcall_deserialize(&req->recv, "dbw", &size,
-			&req->recv.type, &tag);
+	if ((rc = uk_9preq_read32(req, &size)) < 0 ||
+		(rc = uk_9preq_read8(req, &req->recv.type)) < 0 ||
+		(rc = uk_9preq_read16(req, &tag)) < 0)
+		return rc;
 
 	/* Check sanity of deserialized values. */
 	if (rc < 0)
@@ -557,8 +556,8 @@ int uk_9preq_error(struct uk_9preq *req)
 	 */
 	UK_BUGON(req->recv.offset != UK_9P_HEADER_SIZE);
 
-	rc = uk_9preq_deserialize(req, "sd", &error, &errcode);
-	if (rc < 0)
+	if ((rc = uk_9preq_readstr(req, &error)) < 0 ||
+		(rc = uk_9preq_read32(req, &errcode)) < 0)
 		return rc;
 
 	uk_pr_debug("RERROR %.*s %d\n", error.size, error.data, errcode);
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:29 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44: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 1jXSaT-0002C9-MP; Sat, 09 May 2020 16:44:29 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSaR-0002Bs-Vd
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:28 +0000
X-Inumbo-ID: 5138f976-9214-11ea-b9cf-bc764e2007e4
Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 5138f976-9214-11ea-b9cf-bc764e2007e4;
 Sat, 09 May 2020 16:44:15 +0000 (UTC)
Received: by mail-wm1-x343.google.com with SMTP id e26so13351670wmk.5
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44:15 -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=FEuM8NPhHotbE6zkG/VlmOfPyyVD5cPGz65fLkfZCaY=;
 b=EQTTTSgiJQPSJckrCo/HBrfMIp2FkhA9cdT6wbGkUVrYbUWEpi1PMEJ6lSr/zAPlDX
 mBX4hICuVsUTeVs6nTxXJNZthVqP9KPWlY5nOpaLY7aO/2B8QuNSzpjSglMq0/tJgHsw
 +/2/bms3dghjZGarGkceSmVbl0zQEnTEBXg57ZQa/BJFS/kK+RjS1Uf5wtpjSh3bsMOI
 d564TOuMhTWORJAAoh78OEiuwAzu+0AJIJaGmWOixfdKcnZAkiWR3nGdoS+pj/7MZQMo
 9RPXj7fe0ZJFrB5ZbYXcghnpzM9JNMFkvQiWnOasQ97+AUaqL9sx5kJrKXsms990Y3cz
 1mAQ==
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=FEuM8NPhHotbE6zkG/VlmOfPyyVD5cPGz65fLkfZCaY=;
 b=qTE+rm940M2ujUstMsaxg9KwnRlcW5sAr66PtCIK/1ksaWVMVc5xxPLHd6VCP3JWEA
 pxdjTqp+75wxnLDB+d8OldJzfDgbwiXcbdc2Npn6jGHod04hMyP8TUW9Vguy439wt7Rb
 HhRl42KuNE0P120nehHOIhTW9UIXL+FEqe9+cvJd0XDGWB9ZxcvRASsTAoc8OvlCDUV9
 Th7VXnLs3FcdhKTH6Lt5vbV7pPLl4WOwUFOYntyr8b06lBhv+Pq6o1ZR6EQXlhyviCy9
 YYEe6jyKkagqXcxORwXky5VWpw4fz+COnUjN7xpUqQbHkgt8978qiwAmXfOGapvAu+dG
 vHoA==
X-Gm-Message-State: AGi0PuYzbt5QApEdGk5IveTg2b9Tt3M2PHohCmzyIDv650+a5AYYNNEc
 fkEJ7Gx8dBfY12KZYFHkTMvJYAzM8ec=
X-Google-Smtp-Source: APiQypKAbboyiLbZa+t+h42+GsrCfvhQ8X+StoQvpC0+Ik4Rjoj1jVLjeBbz864t/s9u6yELqP35KQ==
X-Received: by 2002:a05:600c:2c53:: with SMTP id
 r19mr23373982wmg.40.1589042654268; 
 Sat, 09 May 2020 09:44:14 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.13
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:13 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 4/9] lib/uk9p: Simplify uk_9p_walk serialization
Date: Sat,  9 May 2020 17:44:08 +0100
Message-Id: <20200509164413.38078-5-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200509164413.38078-1-cristb@gmail.com>
References: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Unifies two if branches with common code in uk_9p_walk.

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/9p.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index 638555b..f17a938 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -195,22 +195,15 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 		goto out;
 	}
 
-	if (name) {
-		uk_pr_debug("TWALK fid %u newfid %u nwname %d name %s\n",
-				fid->fid, newfid->fid, nwname, name);
-		if ((rc = uk_9preq_write32(req, fid->fid)) ||
-			(rc = uk_9preq_write32(req, newfid->fid)) ||
-			(rc = uk_9preq_write16(req, nwname)) ||
-			(rc = uk_9preq_writestr(req, &name_str)))
-			goto out;
-	} else {
-		uk_pr_debug("TWALK fid %u newfid %u nwname %d\n",
-				fid->fid, newfid->fid, nwname);
-		if ((rc = uk_9preq_write32(req, fid->fid)) ||
-			(rc = uk_9preq_write32(req, newfid->fid)) ||
-			(rc = uk_9preq_write16(req, nwname)))
-			goto out;
-	}
+	uk_pr_debug("TWALK fid %u newfid %u nwname %d name %s\n",
+		fid->fid, newfid->fid, nwname, name ? name : "<NULL>");
+
+	if ((rc = uk_9preq_write32(req, fid->fid)) ||
+		(rc = uk_9preq_write32(req, newfid->fid)) ||
+		(rc = uk_9preq_write16(req, nwname)))
+		goto out;
+	if (name && (rc = uk_9preq_writestr(req, &name_str)))
+		goto out;
 
 	if ((rc = send_and_wait_no_zc(dev, req))) {
 		/*
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:34 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44: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 1jXSaY-0002D3-O4; Sat, 09 May 2020 16:44:34 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSaW-0002Cn-Vs
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:33 +0000
X-Inumbo-ID: 50e9a70e-9214-11ea-b07b-bc764e2007e4
Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 50e9a70e-9214-11ea-b07b-bc764e2007e4;
 Sat, 09 May 2020 16:44:14 +0000 (UTC)
Received: by mail-wm1-x342.google.com with SMTP id e26so13351655wmk.5
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44: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=keLdRcTlIgaucL1hPA1CyuE9eifSEDMIW8B/APSHr+Q=;
 b=Mu7HEW4psxsfPzw/QXXesAhsgblvIXwX1sWuNhMVU1VZINBQxqO0DO647BGt473KoI
 GwuzC1uCmQO0xnBBjnwmpJsHzuGs1emuZM1DMPsyK6bVBdPxmghnTTgMB4AsLlPYLCR3
 WNrFvFsMg3EUNaZfbufOxw18IIL6VzDNfZS2LsLlCW2ILMsZBMeEfs7ctNT9F07YP0qa
 vvg6JhzOnqauUT82MAv16sDIgNrg7R0XVmSdA+2iCMpGUmImutA7t0uLTHRzluf+h50S
 1bNi5XQP75mTOd289xWjxmyzJbdv370v08iGlSsWISM/glVW9LgTDAAUcyC0K0mF3EgH
 X6KA==
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=keLdRcTlIgaucL1hPA1CyuE9eifSEDMIW8B/APSHr+Q=;
 b=Xu0f6SV+Vv7CGPKMwk14Ox6anVSRsrNTdUv0MDQ7pZFDtQVzewxDymBMOaKLRclgm7
 4KiePZ0+dbGe1I6V1nzV1hfM0xbidwYS6GZ3UC1pZVx7Mhr8iPnZVElqnOegspvnCciI
 K98Z/EATvbEUJ8NHvYFEWxB0y3wl1BcjoD/jq1obIzzoW2XOQ+kXUkTYtSGlqgEOVSUM
 A0//IT4F4Is1DMXj4h6mb639kbzbOrrK539QFiEBgyn2Vwc6XavYByMOruXdpbyJ3hgb
 IDE2Mv/ZUJ6Xsb1KiioGXis7QPGc8tFXILwUtaGFf3arSulTOUJ4FIyZW+qXDLuCBnSG
 b0mw==
X-Gm-Message-State: AGi0PuZPNQm4tsTX+KUun6cuYRrBkhDDrTbeaQWAzSqOZAPOZo1YYa3z
 obqy1a3bii3zN2CiXdHM7oVv5fZj91k=
X-Google-Smtp-Source: APiQypKHxF7VKyfVb+d6O0KmoTyy0fZ6N4weeAmn+IXpB9YynGTXrKsRUfWvwJJ+1iEUtMMvNQ98kQ==
X-Received: by 2002:a7b:c456:: with SMTP id l22mr21502957wmi.148.1589042653373; 
 Sat, 09 May 2020 09:44:13 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.12
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:12 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 3/9] lib/uk9p: Delete the old serialization
Date: Sat,  9 May 2020 17:44:07 +0100
Message-Id: <20200509164413.38078-4-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200509164413.38078-1-cristb@gmail.com>
References: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch deletes the old serialization implementation and removes
the functions from exportsyms.uk.

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/9pdev.c            |  36 -----
 lib/uk9p/9preq.c            | 287 ------------------------------------
 lib/uk9p/exportsyms.uk      |   7 -
 lib/uk9p/include/uk/9pdev.h |  23 ---
 lib/uk9p/include/uk/9preq.h |  55 -------
 5 files changed, 408 deletions(-)

diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
index 14ea7ca..1d7e09b 100644
--- a/lib/uk9p/9pdev.c
+++ b/lib/uk9p/9pdev.c
@@ -288,42 +288,6 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev)
 #endif
 }
 
-struct uk_9preq *uk_9pdev_call(struct uk_9pdev *dev, uint8_t type,
-			uint32_t size, const char *fmt, ...)
-{
-	struct uk_9preq *req;
-	va_list vl;
-	int rc;
-
-	req = uk_9pdev_req_create(dev, type, size);
-	if (PTRISERR(req))
-		return req;
-
-	va_start(vl, fmt);
-	rc = uk_9preq_vserialize(req, fmt, vl);
-	va_end(vl);
-
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9pdev_request(dev, req);
-	if (rc < 0)
-		goto out;
-
-	rc = uk_9preq_waitreply(req);
-	if (rc < 0)
-		goto out;
-
-	return req;
-out:
-	uk_9pdev_req_remove(dev, req);
-	return ERR2PTR(rc);
-}
-
 struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
 				uint32_t size)
 {
diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
index 8d787e7..997f772 100644
--- a/lib/uk9p/9preq.c
+++ b/lib/uk9p/9preq.c
@@ -138,293 +138,6 @@ int uk_9preq_put(struct uk_9preq *req)
 	return last;
 }
 
-static int _fcall_write(struct uk_9preq_fcall *fcall, const void *buf,
-		uint32_t size)
-{
-	if (fcall->offset + size > fcall->size)
-		return -ENOBUFS;
-
-	memcpy((char *)fcall->buf + fcall->offset, buf, size);
-	fcall->offset += size;
-	return 0;
-}
-
-static int _fcall_serialize(struct uk_9preq_fcall *f, const char *fmt, ...);
-
-static int _fcall_vserialize(struct uk_9preq_fcall *fcall, const char *fmt,
-			va_list vl)
-{
-	int rc = 0;
-
-	while (*fmt) {
-		switch (*fmt) {
-		case 'b': {
-			uint8_t x;
-
-			x = va_arg(vl, unsigned int);
-			rc = _fcall_write(fcall, &x, sizeof(x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'w': {
-			uint16_t x;
-
-			x = va_arg(vl, unsigned int);
-			rc = _fcall_write(fcall, &x, sizeof(x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'd': {
-			uint32_t x;
-
-			x = va_arg(vl, uint32_t);
-			rc = _fcall_write(fcall, &x, sizeof(x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'q': {
-			uint64_t x;
-
-			x = va_arg(vl, uint64_t);
-			rc = _fcall_write(fcall, &x, sizeof(x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 's': {
-			struct uk_9p_str *p;
-
-			p = va_arg(vl, struct uk_9p_str *);
-			rc = _fcall_write(fcall, &p->size, sizeof(p->size));
-			if (rc < 0)
-				goto out;
-			rc = _fcall_write(fcall, p->data, p->size);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'Q': {
-			struct uk_9p_qid *p;
-
-			p = va_arg(vl, struct uk_9p_qid *);
-			rc = _fcall_serialize(fcall, "bdq", p->type,
-					p->version, p->path);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'S': {
-			struct uk_9p_stat *p;
-
-			p = va_arg(vl, struct uk_9p_stat *);
-			rc = _fcall_serialize(fcall, "wwdQdddqsssssddd",
-					p->size, p->type, p->dev, &p->qid,
-					p->mode, p->atime, p->mtime, p->length,
-					&p->name, &p->uid, &p->gid, &p->muid,
-					&p->extension, p->n_uid, p->n_gid,
-					p->n_muid);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		default:
-			rc = -EINVAL;
-			goto out;
-		}
-
-		fmt++;
-	}
-
-out:
-	return rc;
-}
-
-static int _fcall_serialize(struct uk_9preq_fcall *f, const char *fmt, ...)
-{
-	va_list vl;
-	int rc;
-
-	va_start(vl, fmt);
-	rc = _fcall_vserialize(f, fmt, vl);
-	va_end(vl);
-
-	return rc;
-}
-
-int uk_9preq_vserialize(struct uk_9preq *req, const char *fmt, va_list vl)
-{
-	int rc;
-
-	UK_ASSERT(req);
-	UK_ASSERT(UK_READ_ONCE(req->state) == UK_9PREQ_INITIALIZED);
-	rc = _fcall_vserialize(&req->xmit, fmt, vl);
-
-	return rc;
-}
-
-int uk_9preq_serialize(struct uk_9preq *req, const char *fmt, ...)
-{
-	va_list vl;
-	int rc;
-
-	va_start(vl, fmt);
-	rc = uk_9preq_vserialize(req, fmt, vl);
-	va_end(vl);
-
-	return rc;
-}
-
-static int _fcall_read(struct uk_9preq_fcall *fcall, void *buf, uint32_t size)
-{
-	if (fcall->offset + size > fcall->size)
-		return -ENOBUFS;
-
-	memcpy(buf, (char *)fcall->buf + fcall->offset, size);
-	fcall->offset += size;
-	return 0;
-}
-
-static int _fcall_deserialize(struct uk_9preq_fcall *f, const char *fmt, ...);
-
-static int _fcall_vdeserialize(struct uk_9preq_fcall *fcall,
-			      const char *fmt,
-			      va_list vl)
-{
-	int rc = 0;
-
-	while (*fmt) {
-		switch (*fmt) {
-		case 'b': {
-			uint8_t *x;
-
-			x = va_arg(vl, uint8_t *);
-			rc = _fcall_read(fcall, x, sizeof(*x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'w': {
-			uint16_t *x;
-
-			x = va_arg(vl, uint16_t *);
-			rc = _fcall_read(fcall, x, sizeof(*x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'd': {
-			uint32_t *x;
-
-			x = va_arg(vl, uint32_t *);
-			rc = _fcall_read(fcall, x, sizeof(*x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'q': {
-			uint64_t *x;
-
-			x = va_arg(vl, uint64_t *);
-			rc = _fcall_read(fcall, x, sizeof(*x));
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 's': {
-			struct uk_9p_str *p;
-
-			p = va_arg(vl, struct uk_9p_str *);
-			rc = _fcall_read(fcall, &p->size, sizeof(p->size));
-			if (rc < 0)
-				goto out;
-			p->data = (char *)fcall->buf + fcall->offset;
-			fcall->offset += p->size;
-			break;
-		}
-		case 'Q': {
-			struct uk_9p_qid *p;
-
-			p = va_arg(vl, struct uk_9p_qid *);
-			rc = _fcall_deserialize(fcall, "bdq", &p->type,
-					&p->version, &p->path);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		case 'S': {
-			struct uk_9p_stat *p;
-
-			p = va_arg(vl, struct uk_9p_stat *);
-			rc = _fcall_deserialize(fcall, "wwdQdddqsssssddd",
-					&p->size, &p->type, &p->dev, &p->qid,
-					&p->mode, &p->atime, &p->mtime,
-					&p->length, &p->name, &p->uid, &p->gid,
-					&p->muid, &p->extension, &p->n_uid,
-					&p->n_gid, &p->n_muid);
-			if (rc < 0)
-				goto out;
-			break;
-		}
-		default:
-			rc = -EINVAL;
-			goto out;
-		}
-
-		fmt++;
-	}
-
-out:
-	return rc;
-}
-
-static int _fcall_deserialize(struct uk_9preq_fcall *f, const char *fmt, ...)
-{
-	va_list vl;
-	int rc;
-
-	va_start(vl, fmt);
-	rc = _fcall_vdeserialize(f, fmt, vl);
-	va_end(vl);
-
-	return rc;
-}
-
-int uk_9preq_vdeserialize(struct uk_9preq *req, const char *fmt, va_list vl)
-{
-	int rc;
-
-	UK_ASSERT(req);
-	UK_ASSERT(UK_READ_ONCE(req->state) == UK_9PREQ_RECEIVED);
-	rc = _fcall_vdeserialize(&req->recv, fmt, vl);
-
-	return rc;
-}
-
-int uk_9preq_deserialize(struct uk_9preq *req, const char *fmt, ...)
-{
-	va_list vl;
-	int rc;
-
-	va_start(vl, fmt);
-	rc = uk_9preq_vdeserialize(req, fmt, vl);
-	va_end(vl);
-
-	return rc;
-}
-
-int uk_9preq_copy_to(struct uk_9preq *req, void *buf, uint32_t size)
-{
-	return _fcall_read(&req->recv, buf, size);
-}
-
-int uk_9preq_copy_from(struct uk_9preq *req, const void *buf, uint32_t size)
-{
-	return _fcall_write(&req->xmit, buf, size);
-}
-
 int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
 		void *zc_buf, uint32_t zc_size, uint32_t zc_offset)
 {
diff --git a/lib/uk9p/exportsyms.uk b/lib/uk9p/exportsyms.uk
index aae9e8a..7f8e7dd 100644
--- a/lib/uk9p/exportsyms.uk
+++ b/lib/uk9p/exportsyms.uk
@@ -5,12 +5,6 @@ uk_9pdev_trans_set_default
 
 uk_9preq_get
 uk_9preq_put
-uk_9preq_vserialize
-uk_9preq_serialize
-uk_9preq_vdeserialize
-uk_9preq_deserialize
-uk_9preq_copy_to
-uk_9preq_copy_from
 uk_9preq_receive_cb
 uk_9preq_waitreply
 uk_9preq_error
@@ -19,7 +13,6 @@ uk_9pdev_connect
 uk_9pdev_disconnect
 uk_9pdev_request
 uk_9pdev_xmit_notify
-uk_9pdev_call
 uk_9pdev_set_msize
 uk_9pdev_get_msize
 
diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
index 139498f..04ff523 100644
--- a/lib/uk9p/include/uk/9pdev.h
+++ b/lib/uk9p/include/uk/9pdev.h
@@ -107,29 +107,6 @@ int uk_9pdev_request(struct uk_9pdev *dev, struct uk_9preq *req);
  */
 void uk_9pdev_xmit_notify(struct uk_9pdev *dev);
 
-/**
- * Creates and sends 9P request to the given 9P device, serializing it with
- * the given arguments. This function acts as a shorthand for the explicit
- * calls to req_create(), serialize(), ready(), request(), waitreply().
- *
- * @param dev
- *   The Unikraft 9P Device.
- * @param type
- *   Transmit type of the request, e.g. Tversion, Tread, and so on.
- * @param size
- *   The maximum size for the receive and send buffers.
- * @param fmt
- *   The format of the data to be serialized, in the way uk_9preq_serialize()
- *   expects it.
- * @param ...
- *   The arguments to be serialized.
- * @return
- *   - (!PTRISERR): The 9p request in the UK_9PREQ_RECEIVED state.
- *   - PTRISERR: The error code with which any of the steps failed.
- */
-struct uk_9preq *uk_9pdev_call(struct uk_9pdev *dev, uint8_t type,
-			uint32_t size, const char *fmt, ...);
-
 /**
  * Create a new request, automatically allocating its tag, based on its type.
  *
diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
index 70c1b03..b9713e2 100644
--- a/lib/uk9p/include/uk/9preq.h
+++ b/lib/uk9p/include/uk/9preq.h
@@ -182,61 +182,6 @@ void uk_9preq_get(struct uk_9preq *req);
  */
 int uk_9preq_put(struct uk_9preq *req);
 
-/*
- * The following family of serialization and deserialization functions work
- * by employing a printf-like formatting mechanism for data types supported by
- * the 9p protocol:
- * - 'b': byte (uint8_t)
- * - 'w': word (uint16_t)
- * - 'd': double-word (uint32_t)
- * - 'q': quad-word (uint64_t)
- * - 's': uk_9p_str *
- * - 'S': uk_9p_stat *
- *
- * Similarly to vprintf(), the vserialize() and vdeserialize() functions take
- * a va_list instead of a variable number of arguments.
- *
- * Possible return values:
- * - 0: Operation successful.
- * - (-EINVAL): Invalid format specifier.
- * - (-ENOBUFS): End of buffer reached.
- */
-
-int uk_9preq_vserialize(struct uk_9preq *req, const char *fmt, va_list vl);
-int uk_9preq_serialize(struct uk_9preq *req, const char *fmt, ...);
-int uk_9preq_vdeserialize(struct uk_9preq *req, const char *fmt, va_list vl);
-int uk_9preq_deserialize(struct uk_9preq *req, const char *fmt, ...);
-
-/**
- * Copies raw data from the request receive buffer to the provided buffer.
- *
- * @param req
- *   Reference to the 9p request.
- * @param buf
- *   Destination buffer.
- * @param size
- *   Amount to copy.
- * Possible return values:
- * - 0: Operation successful.
- * - (-ENOBUFS): End of buffer reached.
- */
-int uk_9preq_copy_to(struct uk_9preq *req, void *buf, uint32_t size);
-
-/**
- * Copies raw data from the provided buffer to the request transmission buffer.
- *
- * @param req
- *   Reference to the 9p request.
- * @param buf
- *   Source buffer.
- * @param size
- *   Amount to copy.
- * Possible return values:
- * - 0: Operation successful.
- * - (-ENOBUFS): End of buffer reached.
- */
-int uk_9preq_copy_from(struct uk_9preq *req, const void *buf, uint32_t size);
-
 /**
  * Marks the given request as being ready, transitioning between states
  * INITIALIZED and READY.
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:38 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44:38 +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 1jXSac-0002Dr-Pn; Sat, 09 May 2020 16:44:38 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSab-0002Dh-VX
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:38 +0000
X-Inumbo-ID: 51e86a82-9214-11ea-9887-bc764e2007e4
Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 51e86a82-9214-11ea-9887-bc764e2007e4;
 Sat, 09 May 2020 16:44:16 +0000 (UTC)
Received: by mail-wm1-x344.google.com with SMTP id h4so13351720wmb.4
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44: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=uldVg55fDNGCatbPNrb/8nNx0gO25Fl/1yrvHSIvbk4=;
 b=bDNC760k/XCd4L7LDZXrANRGOwKLi09xM1IH9G9Iq5Xhq6tBUflOzhKqMFhvWGpTiY
 5LPqbCl9tOoovDGS43nOOI0w7oa7SZvDR6CrydEfYPG43BqKSHQaVoS7ki6oCp1N/Vj1
 YWN5oYe4qIhXAj2UVSwjQeCxV70x4Fjvl9lxmUJoiiHtgKkKhRDNkJYHaVaOxH5Z/XVd
 xTcOy4OOknFXY9rBZtgdsbwkIF7aRfcrHtVM4ir6siSdBcZCPn8hePvLlBIhnqv9vSdx
 sJdFb+woXlQo7asga/3kkYwJuBuIFwYDgfYol5o1tFj5PYFjfVh0usk3jmGpmmqBl/B9
 uItQ==
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=uldVg55fDNGCatbPNrb/8nNx0gO25Fl/1yrvHSIvbk4=;
 b=crxO3hFtdWcg872SoUnBPMfhxW+HdP3KdB+gM3Z3thGB6Eui5T5U6PKzwrJBNT65qR
 teEIxkBi8n0kZ3McHoBix7lxUiBcnNWU40q03VxOsCaJ8hfm02llWVwC+zPpyK945+A2
 2gsaOXN8uRp8Qg1Xr8mXlvuM3wv+SUyrQFtx1Myqpg5QgefI8OC13wxsidU8FFKW6V4x
 oUJuD/K6qNCKdKg90V+siLECVZoo9BPvhT3MkmCVTHvRNn2PAFu9PU6vaRsyOP05l4NN
 2Czb45gzg6Q/Cg+gmifD6DvUT9ZsvtUqMIbJNYtsTz11+Eh+fOM4cD0/A7hN3Jr76jke
 u8Tw==
X-Gm-Message-State: AGi0PuZFQ4nKa+HO+1G7RvRHFGRuQ104YxU3MXx0KmiqOQoILknRw0jC
 t4FZU86CWWJZS5Mo65rNv5R5zIaGiJA=
X-Google-Smtp-Source: APiQypId9QEo1HrercLoHJmnJ2gxDHig2yPtVKR/wQFmG4/k8miEBMuKVmq+tV+IqjPOhNmIBoiS1g==
X-Received: by 2002:a1c:abc3:: with SMTP id u186mr21508590wme.42.1589042655194; 
 Sat, 09 May 2020 09:44:15 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.14
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:14 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 5/9] lib/uk9p: Add uk_traces
Date: Sat,  9 May 2020 17:44:09 +0100
Message-Id: <20200509164413.38078-6-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200509164413.38078-1-cristb@gmail.com>
References: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch enables nanosecond-resolution tracing of 9pfs performance.

Excerpt from the output traces for a read():
2167560470  uk_9p_trace_request_create
2167564237  uk_9p_trace_request_allocated
2167564277  uk_9p_trace_ready              tag 0
2167567134  uk_9p_trace_sent               tag 0
2167625854  uk_9p_trace_received           tag 0

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/9p.c | 57 +++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 42 insertions(+), 15 deletions(-)

diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index f17a938..14ba299 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -39,6 +39,13 @@
 #include <uk/9pdev.h>
 #include <uk/9preq.h>
 #include <uk/9pfid.h>
+#include <uk/trace.h>
+
+UK_TRACEPOINT(uk_9p_trace_request_create, "");
+UK_TRACEPOINT(uk_9p_trace_request_allocated, "");
+UK_TRACEPOINT(uk_9p_trace_ready, "tag %u", uint16_t);
+UK_TRACEPOINT(uk_9p_trace_sent, "tag %u", uint16_t);
+UK_TRACEPOINT(uk_9p_trace_received, "tag %u", uint16_t);
 
 static inline int send_and_wait_zc(struct uk_9pdev *dev, struct uk_9preq *req,
 		enum uk_9preq_zcdir zc_dir, void *zc_buf, uint32_t zc_size,
@@ -46,10 +53,17 @@ static inline int send_and_wait_zc(struct uk_9pdev *dev, struct uk_9preq *req,
 {
 	int rc;
 
-	if ((rc = uk_9preq_ready(req, zc_dir, zc_buf, zc_size, zc_offset)) ||
-		(rc = uk_9pdev_request(dev, req)) ||
-		(rc = uk_9preq_waitreply(req)))
+	if ((rc = uk_9preq_ready(req, zc_dir, zc_buf, zc_size, zc_offset)))
+		return rc;
+	uk_9p_trace_ready(req->tag);
+
+	if ((rc = uk_9pdev_request(dev, req)))
 		return rc;
+	uk_9p_trace_sent(req->tag);
+
+	if ((rc = uk_9preq_waitreply(req)))
+		return rc;
+	uk_9p_trace_received(req->tag);
 
 	return 0;
 }
@@ -60,6 +74,19 @@ static inline int send_and_wait_no_zc(struct uk_9pdev *dev,
 	return send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
 }
 
+static struct uk_9preq *request_create(struct uk_9pdev *dev,
+		uint8_t type, uint32_t size)
+{
+	struct uk_9preq *req;
+
+	uk_9p_trace_request_create();
+	req = uk_9pdev_req_create(dev, type, size);
+	if (!PTRISERR(req))
+		uk_9p_trace_request_allocated();
+
+	return req;
+}
+
 struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 		const char *requested, struct uk_9p_str *received)
 {
@@ -70,7 +97,7 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 
 	uk_9p_str_init(&requested_str, requested);
 
-	req = uk_9pdev_req_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return req;
 
@@ -119,7 +146,7 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
 	if (PTRISERR(fid))
 		return fid;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
 	if (PTRISERR(req)) {
 		uk_9pdev_fid_release(fid);
 		return (void *)req;
@@ -156,7 +183,7 @@ int uk_9p_flush(struct uk_9pdev *dev, uint16_t oldtag)
 	struct uk_9preq *req;
 	int rc = 0;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -189,7 +216,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 
 	nwname = name ? 1 : 0;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TWALK, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TWALK, __PAGE_SIZE);
 	if (PTRISERR(req)) {
 		rc = PTR2ERR(req);
 		goto out;
@@ -245,7 +272,7 @@ int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
 	struct uk_9preq *req;
 	int rc = 0;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -279,7 +306,7 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	uk_9p_str_init(&name_str, name);
 	uk_9p_str_init(&extension_str, extension);
 
-	req = uk_9pdev_req_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -312,7 +339,7 @@ int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
 	/* The fid is considered invalid even if the remove fails. */
 	fid->was_removed = 1;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -335,7 +362,7 @@ int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
 	if (fid->was_removed)
 		return 0;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -363,7 +390,7 @@ int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	uk_pr_debug("TREAD fid %u offset %lu count %u\n", fid->fid,
 			offset, count);
 
-	req = uk_9pdev_req_create(dev, UK_9P_TREAD, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TREAD, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -395,7 +422,7 @@ int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
 
 	uk_pr_debug("TWRITE fid %u offset %lu count %u\n", fid->fid,
 			offset, count);
-	req = uk_9pdev_req_create(dev, UK_9P_TWRITE, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TWRITE, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -423,7 +450,7 @@ struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	int rc = 0;
 	uint16_t dummy;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return req;
 
@@ -451,7 +478,7 @@ int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	int rc = 0;
 	uint16_t *dummy;
 
-	req = uk_9pdev_req_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:44 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44: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 1jXSai-0002FH-RM; Sat, 09 May 2020 16:44:44 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSag-0002Ej-WD
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:43 +0000
X-Inumbo-ID: 52391f22-9214-11ea-9887-bc764e2007e4
Received: from mail-wm1-x32a.google.com (unknown [2a00:1450:4864:20::32a])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 52391f22-9214-11ea-9887-bc764e2007e4;
 Sat, 09 May 2020 16:44:16 +0000 (UTC)
Received: by mail-wm1-x32a.google.com with SMTP id m24so3724664wml.2
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44: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=gqx8YQU017x5k9DNntATFIDW8pRQdO0ybfuoiuhQ0kE=;
 b=FIB71UR+OlRCTL5fhKT3sEWsl6UIomQ67c/I2mx+eu+ioJIgXW0EQPvMKzVcatv74X
 JBz/i/FmEKuzwt8xlv4EVD1sGornUc5kr2tSZZXTfd/ZEB/byOFcD3oEyHUV/aUfllB6
 WzxK34bQ/f5W2d2ZLglIULzUM+GV78UfS673b4QEKIRUHi5a9b9eqsBGZK1a7r182SQy
 qbIM6vGKNNhOf2zz9xnNZZDhU4lXF+wASp+/JPPhi+GVKNe6fRJrWHfJ7825CkmXCoX6
 Hc6ak1kxYV4c4YecBvft9j8lqfv9XQvjcQWZ/zhZbwO/aKuT22ZoDYccWqMr2CkeKLOJ
 oCXg==
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=gqx8YQU017x5k9DNntATFIDW8pRQdO0ybfuoiuhQ0kE=;
 b=K0lsrsw8Y7AbzJo71VVzgqoKtQFLiqHp/XowwBroQ5l9xxlpx1pCK2I05cVPwWwk7J
 rCbE8Efyi7qfo8p7jPwUmrVifGZddhlxayo7LE60ItD6qbpnmGJP4M8KlkCfp/Yw8X9a
 VS/9W6FDKuatnxLqzuBRLuWyWpYFqYg6sOYH8OEjqTJP8CoaIapQvW50MGkXDirzdtyq
 giZfgMecw74Ryrt1cHaHTeSi0BtDz1A+tQghlj+fv0c2MG0DA1WuHXFDqVlOtABdfWt8
 FpGx6QgEedCyMUOULNJc7a0qhqGcNMCWjdBAjeQh6wGMxnS329yRtbr0vGIwqBPpghba
 300A==
X-Gm-Message-State: AGi0PuYstABfvXHUfzg4h70dg1oD+X6w4fFLuqVib+zbcvj3PvOsX58P
 IjKbwyRpTgdkeuPMbfIDgjbRsz+UuJ4=
X-Google-Smtp-Source: APiQypJ5yuLl7MFUbg3rzXBK982ssvKn7GwM7cN1CLYMs3a3autuct+OFWfCfB0+j9XQ7ldYd0o1JQ==
X-Received: by 2002:a1c:e2c5:: with SMTP id z188mr11292840wmg.35.1589042655948; 
 Sat, 09 May 2020 09:44:15 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.15
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:15 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 6/9] lib/uk9p: Change severity of uk_9p_version log
Date: Sat,  9 May 2020 17:44:10 +0100
Message-Id: <20200509164413.38078-7-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200509164413.38078-1-cristb@gmail.com>
References: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Even though 9p can continue execution if the negotiated message
size violates the 9p specification, this should be a warning,
not a debug message.

Also fixes a typo "Howevver".

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/9p.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index 14ba299..4acb0c6 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -116,12 +116,12 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 
 	/*
 	 * Note: the 9P specification mentions that new_msize <= dev->msize.
-	 * Howevver, execution can continue even if the invariant is violated
+	 * However, execution can continue even if the invariant is violated
 	 * and set_msize() fails, as the old message size is always within the
 	 * accepted limit.
 	 */
 	if (!uk_9pdev_set_msize(dev, new_msize))
-		uk_pr_debug("Invalid new message size.\n");
+		uk_pr_warn("Invalid new message size.\n");
 
 	return req;
 
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:48 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44:48 +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 1jXSam-0002GA-U3; Sat, 09 May 2020 16:44:48 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSal-0002Fy-Vz
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:48 +0000
X-Inumbo-ID: 52fe9bd0-9214-11ea-b9cf-bc764e2007e4
Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 52fe9bd0-9214-11ea-b9cf-bc764e2007e4;
 Sat, 09 May 2020 16:44:18 +0000 (UTC)
Received: by mail-wm1-x342.google.com with SMTP id y24so14056192wma.4
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44:18 -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=P12soIaRs90yA66WZDQaCTGaLYUeSuVbkpTYfngW/ko=;
 b=mfoJ5hproMOjKkj4AXNVf/1Fun2qyQCnNVIlVv0YRF0eg6bpsS9Xvj9qCwc5Iqz32j
 saMtOurNtpyR+BXYGopRJQmrTY3Qih1Egpz8U1smw8rbUuh1rZWwu3P4ybf2MlJqRxL8
 rmaigvHDSW+5JJDtbuG1JboDh3B78nYoosjCrxmgt2WWAbEHpvt2FO0WykPwiLx2UFOX
 C4uKdOMAKqBDkq6j++q+oPWmXYV/9DiqXpRAv4agRVMp6Pogs6I+cwimlPHuc7kInqnU
 VZO9+ujD7sdi9LTlWWlsmzlSpUqAh3MSjkJpqHE9Rn4QY9LidI6t8ZPvVpKIiJJsxXkl
 E14A==
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=P12soIaRs90yA66WZDQaCTGaLYUeSuVbkpTYfngW/ko=;
 b=OkbPQHOBZqzD1WcxrKVUpNuUtIwmewhrv3hrbfAscnXT5qNsiikXsA2L1FwwWBFLT8
 n2y5+tZwDHjWghcsQQQUvIAyeAYbhpVJ0/2QhLQdJ+sLKn4bvX5jh6DENg3htfBCdsjt
 UWkWOxU3jlxDJwgRftCmFKDKq1gwQGufaRoLXJHSMvRhGlTjHT0SzK3yVl4AvjhgFKfb
 dRPLQVvyhWy9ZjxzfwKzWCSZXCiyID9w4/E6ZPzX41J+CtpBm5isLApRgfHdX2su2Cc7
 iww9DyYPFxXN6TkcMuKwD0JgAQLrwN2iXsEG9VMDB44fFj0a0c00V8hwajO60Yx257TK
 O/fA==
X-Gm-Message-State: AGi0PuZbpj3vP/GqFxSbUrjJLaB8QAMxZRSo/wF1w/JrY2mn6lx8wZ0I
 WizJVSUu2B49/esdnWZJPKw67hQ4hdI=
X-Google-Smtp-Source: APiQypKbnbh8rBpbKMGCZXfWUZKVDVO/Q09jRIQlUNlN6jHDN8/u7seaXhoPzL5B7/i/lNYDSOlAYQ==
X-Received: by 2002:a1c:7e4e:: with SMTP id z75mr17088588wmc.41.1589042656942; 
 Sat, 09 May 2020 09:44:16 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.16
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:16 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 7/9] lib/uk9p: Use fixed-size request buffers
Date: Sat,  9 May 2020 17:44:11 +0100
Message-Id: <20200509164413.38078-8-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200509164413.38078-1-cristb@gmail.com>
References: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Use fixed-size request buffers instead of dynamically allocating new
receive and transmit buffers for each new request. This reduces the
number of calls to uk_alloc from 3 to 1 per each uk_9pdev_req_create()
call.

Allocating a request is faster by roughly 2.5 microseconds. The
previous patch in this patch series shows a 3.7us delay between read
and request_allocated. The excerpt below shows roughly 1us delay.
This performance benefit is observed at a larger scale as well (in
latency and throughput benchmarks).

Excerpt from the output traces for a read():

1350682319  uk_9p_trace_request_create
1350683329  uk_9p_trace_request_allocated
1350683375  uk_9p_trace_ready              tag 0
1350686009  uk_9p_trace_sent               tag 0
1350748124  uk_9p_trace_received           tag 0

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/9p.c               | 29 +++++++-------
 lib/uk9p/9pdev.c            | 11 +++---
 lib/uk9p/9preq.c            | 76 ++++++++-----------------------------
 lib/uk9p/include/uk/9pdev.h |  5 +--
 lib/uk9p/include/uk/9preq.h | 31 +++++++++++++--
 5 files changed, 65 insertions(+), 87 deletions(-)

diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index 4acb0c6..9ac7e8a 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -74,13 +74,12 @@ static inline int send_and_wait_no_zc(struct uk_9pdev *dev,
 	return send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
 }
 
-static struct uk_9preq *request_create(struct uk_9pdev *dev,
-		uint8_t type, uint32_t size)
+static struct uk_9preq *request_create(struct uk_9pdev *dev, uint8_t type)
 {
 	struct uk_9preq *req;
 
 	uk_9p_trace_request_create();
-	req = uk_9pdev_req_create(dev, type, size);
+	req = uk_9pdev_req_create(dev, type);
 	if (!PTRISERR(req))
 		uk_9p_trace_request_allocated();
 
@@ -97,7 +96,7 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
 
 	uk_9p_str_init(&requested_str, requested);
 
-	req = request_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TVERSION);
 	if (PTRISERR(req))
 		return req;
 
@@ -146,7 +145,7 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
 	if (PTRISERR(fid))
 		return fid;
 
-	req = request_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TATTACH);
 	if (PTRISERR(req)) {
 		uk_9pdev_fid_release(fid);
 		return (void *)req;
@@ -183,7 +182,7 @@ int uk_9p_flush(struct uk_9pdev *dev, uint16_t oldtag)
 	struct uk_9preq *req;
 	int rc = 0;
 
-	req = request_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TFLUSH);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -216,7 +215,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
 
 	nwname = name ? 1 : 0;
 
-	req = request_create(dev, UK_9P_TWALK, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TWALK);
 	if (PTRISERR(req)) {
 		rc = PTR2ERR(req);
 		goto out;
@@ -272,7 +271,7 @@ int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
 	struct uk_9preq *req;
 	int rc = 0;
 
-	req = request_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TOPEN);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -306,7 +305,7 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	uk_9p_str_init(&name_str, name);
 	uk_9p_str_init(&extension_str, extension);
 
-	req = request_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TCREATE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -339,7 +338,7 @@ int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
 	/* The fid is considered invalid even if the remove fails. */
 	fid->was_removed = 1;
 
-	req = request_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TREMOVE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -362,7 +361,7 @@ int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
 	if (fid->was_removed)
 		return 0;
 
-	req = request_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TCLUNK);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -390,7 +389,7 @@ int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	uk_pr_debug("TREAD fid %u offset %lu count %u\n", fid->fid,
 			offset, count);
 
-	req = request_create(dev, UK_9P_TREAD, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TREAD);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -422,7 +421,7 @@ int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
 
 	uk_pr_debug("TWRITE fid %u offset %lu count %u\n", fid->fid,
 			offset, count);
-	req = request_create(dev, UK_9P_TWRITE, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TWRITE);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
@@ -450,7 +449,7 @@ struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	int rc = 0;
 	uint16_t dummy;
 
-	req = request_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TSTAT);
 	if (PTRISERR(req))
 		return req;
 
@@ -478,7 +477,7 @@ int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
 	int rc = 0;
 	uint16_t *dummy;
 
-	req = request_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
+	req = request_create(dev, UK_9P_TWSTAT);
 	if (PTRISERR(req))
 		return PTR2ERR(req);
 
diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
index 1d7e09b..40a4daa 100644
--- a/lib/uk9p/9pdev.c
+++ b/lib/uk9p/9pdev.c
@@ -288,8 +288,7 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev)
 #endif
 }
 
-struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
-				uint32_t size)
+struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type)
 {
 	struct uk_9preq *req;
 	int rc = 0;
@@ -298,14 +297,16 @@ struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
 
 	UK_ASSERT(dev);
 
-	size = MIN(size, dev->msize);
-
-	req = uk_9preq_alloc(dev->a, size);
+	req = uk_9preq_alloc(dev->a);
 	if (req == NULL) {
 		rc = -ENOMEM;
 		goto out;
 	}
 
+	/* Shouldn't exceed the msize on non-zerocopy buffers, just in case. */
+	req->recv.size = MIN(req->recv.size, dev->msize);
+	req->xmit.size = MIN(req->xmit.size, dev->msize);
+
 	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
 	if (type == UK_9P_TVERSION)
 		tag = UK_9P_NOTAG;
diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
index 997f772..d44e684 100644
--- a/lib/uk9p/9preq.c
+++ b/lib/uk9p/9preq.c
@@ -45,51 +45,28 @@
 #include <uk/wait.h>
 #endif
 
-static int _fcall_alloc(struct uk_alloc *a, struct uk_9preq_fcall *f,
-			uint32_t size)
-{
-	UK_ASSERT(a);
-	UK_ASSERT(f);
-	UK_ASSERT(size > 0);
-
-	f->buf = uk_calloc(a, size, sizeof(char));
-	if (f->buf == NULL)
-		return -ENOMEM;
-
-	f->size = size;
-	f->offset = 0;
-	f->zc_buf = NULL;
-	f->zc_size = 0;
-	f->zc_offset = 0;
-
-	return 0;
-}
-
-static void _fcall_free(struct uk_alloc *a, struct uk_9preq_fcall *f)
-{
-	UK_ASSERT(a);
-	UK_ASSERT(f);
-
-	if (f->buf)
-		uk_free(a, f->buf);
-}
-
-struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a, uint32_t size)
+struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a)
 {
 	struct uk_9preq *req;
-	int rc;
 
 	req = uk_calloc(a, 1, sizeof(*req));
 	if (req == NULL)
-		goto out;
+		return NULL;
 
-	rc = _fcall_alloc(a, &req->xmit, size);
-	if (rc < 0)
-		goto out_free;
+	req->xmit.buf = req->xmit_buf;
+	req->recv.buf = req->recv_buf;
+	req->xmit.size = req->recv.size = UK_9P_BUFSIZE;
+	req->xmit.zc_buf = req->recv.zc_buf = NULL;
+	req->xmit.zc_size = req->recv.zc_size = 0;
+	req->xmit.zc_offset = req->recv.zc_offset = 0;
 
-	rc = _fcall_alloc(a, &req->recv, MAX(size, UK_9P_RERROR_MAXSIZE));
-	if (rc < 0)
-		goto out_free;
+	/*
+	 * Assume the header has already been written.
+	 * The header itself will be written on uk_9preq_ready(), when the
+	 * actual message size is known.
+	 */
+	req->xmit.offset = UK_9P_HEADER_SIZE;
+	req->recv.offset = 0;
 
 	UK_INIT_LIST_HEAD(&req->_list);
 	req->_a = a;
@@ -98,28 +75,7 @@ struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a, uint32_t size)
 	uk_waitq_init(&req->wq);
 #endif
 
-	/*
-	 * Assume the header has already been written.
-	 * The header itself will be written on uk_9preq_ready(), when the
-	 * actual message size is known.
-	 */
-	req->xmit.offset = UK_9P_HEADER_SIZE;
-
 	return req;
-
-out_free:
-	_fcall_free(a, &req->recv);
-	_fcall_free(a, &req->xmit);
-	uk_free(a, req);
-out:
-	return NULL;
-}
-
-static void _req_free(struct uk_9preq *req)
-{
-	_fcall_free(req->_a, &req->recv);
-	_fcall_free(req->_a, &req->xmit);
-	uk_free(req->_a, req);
 }
 
 void uk_9preq_get(struct uk_9preq *req)
@@ -133,7 +89,7 @@ int uk_9preq_put(struct uk_9preq *req)
 
 	last = uk_refcount_release(&req->refcount);
 	if (last)
-		_req_free(req);
+		uk_free(req->_a, req);
 
 	return last;
 }
diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
index 04ff523..1225336 100644
--- a/lib/uk9p/include/uk/9pdev.h
+++ b/lib/uk9p/include/uk/9pdev.h
@@ -114,15 +114,12 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev);
  *   The Unikraft 9P Device.
  * @param type
  *   Transmit type of the request, e.g. Tversion, Tread, and so on.
- * @param size
- *   The maximum size for the receive and send buffers.
  * @return
  *   If not an error pointer, the created request.
  *   Otherwise, the error in creating the request:
  *   - ENOMEM: No memory for the request or no available tags.
  */
-struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
-				uint32_t size);
+struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type);
 
 /**
  * Looks up a request based on the given tag. This is generally used by
diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
index b9713e2..ed883d2 100644
--- a/lib/uk9p/include/uk/9preq.h
+++ b/lib/uk9p/include/uk/9preq.h
@@ -63,6 +63,16 @@ extern "C" {
  */
 #define UK_9P_RERROR_MAXSIZE            141U
 
+/*
+ * The transmit and receive buffer size.
+ *
+ * The buffer size is not expected to exceed 1K: reads and writes are
+ * zero-copy; on-the-wire size of a stat structure should not exceed
+ * 1K -- its base size is 61, along with the lengths for name, uid,
+ * gid, muid and extension strings.
+ */
+#define UK_9P_BUFSIZE			1024U
+
 /**
  * @internal
  *
@@ -125,8 +135,23 @@ enum uk_9preq_state {
  *  referenced anymore. A call to uk_9pdev_req_remove() is mandatory to
  *  correctly free this and remove it from the list of requests managed
  *  by the 9p device.
+ *
+ *  Should fit within one page.
  */
 struct uk_9preq {
+	/*
+	 * Fixed-size buffer for transmit, used for most messages.
+	 * Large messages will always zero-copy from the user-provided
+	 * buffer (on Twrite).
+	 */
+	uint8_t				xmit_buf[UK_9P_BUFSIZE];
+	/*
+	 * Fixed-size buffer for receive, used for most messages.
+	 * Large messages will always zero-copy into the user-provided
+	 * buffer (on Tread).
+	 */
+	uint8_t				recv_buf[UK_9P_BUFSIZE];
+	/* 2 KB offset in the structure here. */
 	/* Transmit fcall. */
 	struct uk_9preq_fcall           xmit;
 	/* Receive fcall. */
@@ -147,6 +172,8 @@ struct uk_9preq {
 #endif
 };
 
+UK_CTASSERT(sizeof(struct uk_9preq) <= __PAGE_SIZE);
+
 /**
  * @internal
  * Allocates a 9p request.
@@ -154,13 +181,11 @@ struct uk_9preq {
  *
  * @param a
  *   Allocator to use.
- * @param size
- *   Minimum size of the receive and transmit buffers.
  * @return
  *   - (==NULL): Out of memory.
  *   - (!=NULL): Successful.
  */
-struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a, uint32_t size);
+struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a);
 
 /**
  * Gets the 9p request, incrementing the reference count.
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:54 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44: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 1jXSar-0002HU-Vm; Sat, 09 May 2020 16:44: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=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSaq-0002H5-Vk
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:53 +0000
X-Inumbo-ID: 53525cb6-9214-11ea-b07b-bc764e2007e4
Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 53525cb6-9214-11ea-b07b-bc764e2007e4;
 Sat, 09 May 2020 16:44:18 +0000 (UTC)
Received: by mail-wm1-x344.google.com with SMTP id e26so13351783wmk.5
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44:18 -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=wEjXOR5NZ4y9prIyavFlhU6Jn4hBOUV6zBnxk6Mstrw=;
 b=Qj5uImDMPanzRWk66+OvS/yv4Bc+4NDuA27T5jCynFO/WPnq//EDOkSgkbvoYZMtgk
 XF+7E+VOUfbmxRrclVt8CruGCwZpSswFeLXY0nwuCd/LAJCVSjX7WujFjCuWvZBaYb+J
 eT/hmIMrWGrUrvOWnAvprZwjsXfwq4pxn8WhbbsCJm8HtmPmNQdcdxZ2ospwUG5OUN57
 uuSSIafrOkXrClT1Yxd2+ZLcera9Kax7ZlRCmCpIQHzy0dNz7MzvHPZX7fGL4Owb5K5Z
 qd5W1ztkyLn8ZK5ZTHESAT80P6dTtWo/CeIYH6jVuJg1IYPmz7nYnqUD/7mhq4b75goo
 udCg==
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=wEjXOR5NZ4y9prIyavFlhU6Jn4hBOUV6zBnxk6Mstrw=;
 b=Mzfwbr+nCNxNqPRQL0j48RqifCsCKmgAuXZoLXyB0uR1p2dYsszSX6+Ri7grnSUz36
 0EdTraSa5sHIpjbVGImJidTt3XnU1SBL1+zLR2At3+5G/qiD/juEHuGsoTBmnLLtyUZs
 VoxVDxxcu+etOKc7QGYaREpeU2A9M90vDfiO8Ce8QZuegHWFyST4XzX1NO+iTouiQWkT
 mtwjm03rP/RPrneltzpLMrr2cTgLpLrZ2bEdU8/Pm8xMbeX2KLY6G/jsD4eGRwBGkNHi
 8+NCuYArvWvre0NfUhFwO2bcOKkrjoAZ2C6zTIDKWUqE6mCwvJn/xX4eRWzslQJH3jJv
 bmeA==
X-Gm-Message-State: AGi0PuaxfO5uGee8SXaPKPfpIqLH0NlTzukBuYSqBqcIBGK2d+i7tBhA
 E4/0ZGSEpJ9FFvFJ+hjG0gq+WjxqAA0=
X-Google-Smtp-Source: APiQypLqYFwpEN+HEZX38JIJgAfKfCgemULLQlG4PIAXlmnq7BnRMaDnzm5kNNFYtSQbBmp322hPAw==
X-Received: by 2002:a7b:c5d3:: with SMTP id n19mr14918062wmk.21.1589042657643; 
 Sat, 09 May 2020 09:44:17 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.16
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:17 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 8/9] lib/uk9p: Recycle uk_9preq allocations
Date: Sat,  9 May 2020 17:44:12 +0100
Message-Id: <20200509164413.38078-9-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200509164413.38078-1-cristb@gmail.com>
References: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Each 9p device keeps a free-list of 9p requests. This allows
allocations to take much less time, as usually the workflow of a 9p
device is synchronous: create request, wait for reply, process it,
repeat. This approach avoids the allocation performance hit on
subsequent request creations.

Results below indicate that request_allocated takes < 100ns,
as opposed to 1us (previous commit in this patch series).

In the sample below, the read() now spends most of the time (~99.8%)
either notifying the host or waiting for a reply. At this scale,
even uk_traces are probably noisy and the "real" time might be lower
by a relatively large amount.

Excerpt from the uk traces on a read():

500281499  uk_9p_trace_request_create
500281570  uk_9p_trace_request_allocated
500281603  uk_9p_trace_ready              tag 0
500283423  uk_9p_trace_sent               tag 0
500347243  uk_9p_trace_received           tag 0

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/uk9p/9pdev.c                 | 80 +++++++++++++++++++++++++++++---
 lib/uk9p/9preq.c                 | 14 ++----
 lib/uk9p/include/uk/9pdev.h      | 10 ++++
 lib/uk9p/include/uk/9pdev_core.h |  2 +
 lib/uk9p/include/uk/9preq.h      | 15 +++---
 5 files changed, 95 insertions(+), 26 deletions(-)

diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
index 40a4daa..bdd6a84 100644
--- a/lib/uk9p/9pdev.c
+++ b/lib/uk9p/9pdev.c
@@ -132,6 +132,7 @@ static void _req_mgmt_init(struct uk_9pdev_req_mgmt *req_mgmt)
 	ukarch_spin_lock_init(&req_mgmt->spinlock);
 	uk_bitmap_zero(req_mgmt->tag_bm, UK_9P_NUMTAGS);
 	UK_INIT_LIST_HEAD(&req_mgmt->req_list);
+	UK_INIT_LIST_HEAD(&req_mgmt->req_free_list);
 }
 
 static void _req_mgmt_add_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
@@ -141,6 +142,21 @@ static void _req_mgmt_add_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
 	uk_list_add(&req->_list, &req_mgmt->req_list);
 }
 
+static struct uk_9preq *
+_req_mgmt_from_freelist_locked(struct uk_9pdev_req_mgmt *req_mgmt)
+{
+	struct uk_9preq *req;
+
+	if (uk_list_empty(&req_mgmt->req_free_list))
+		return NULL;
+
+	req = uk_list_first_entry(&req_mgmt->req_free_list,
+			struct uk_9preq, _list);
+	uk_list_del(&req->_list);
+
+	return req;
+}
+
 static void _req_mgmt_del_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
 				struct uk_9preq *req)
 {
@@ -148,6 +164,12 @@ static void _req_mgmt_del_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
 	uk_list_del(&req->_list);
 }
 
+static void _req_mgmt_req_to_freelist_locked(struct uk_9pdev_req_mgmt *req_mgmt,
+				struct uk_9preq *req)
+{
+	uk_list_add(&req->_list, &req_mgmt->req_free_list);
+}
+
 static uint16_t _req_mgmt_next_tag_locked(struct uk_9pdev_req_mgmt *req_mgmt)
 {
 	return uk_find_next_zero_bit(req_mgmt->tag_bm, UK_9P_NUMTAGS, 0);
@@ -164,10 +186,24 @@ static void _req_mgmt_cleanup(struct uk_9pdev_req_mgmt *req_mgmt __unused)
 		tag = req->tag;
 		_req_mgmt_del_req_locked(req_mgmt, req);
 		if (!uk_9preq_put(req)) {
-			uk_pr_warn("Tag %d still has references on cleanup.\n",
+			/* If in the future these references get released, mark
+			 * _dev as NULL so uk_9pdev_req_to_freelist doesn't
+			 * attempt to place them in an invalid memory region.
+			 *
+			 * As _dev is not used for any other purpose, this
+			 * doesn't impact any other logic related to 9p request
+			 * processing.
+			 */
+			req->_dev = NULL;
+			uk_pr_err("Tag %d still has references on cleanup.\n",
 				tag);
 		}
 	}
+	uk_list_for_each_entry_safe(req, reqn, &req_mgmt->req_free_list,
+			_list) {
+		uk_list_del(&req->_list);
+		uk_free(req->_a, req);
+	}
 	ukplat_spin_unlock_irqrestore(&req_mgmt->spinlock, flags);
 }
 
@@ -297,17 +333,37 @@ struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type)
 
 	UK_ASSERT(dev);
 
-	req = uk_9preq_alloc(dev->a);
-	if (req == NULL) {
-		rc = -ENOMEM;
-		goto out;
+	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
+	if (!(req = _req_mgmt_from_freelist_locked(&dev->_req_mgmt))) {
+		/* Don't allocate with the spinlock held. */
+		ukplat_spin_unlock_irqrestore(&dev->_req_mgmt.spinlock, flags);
+		req = uk_calloc(dev->a, 1, sizeof(*req));
+		if (req == NULL) {
+			rc = -ENOMEM;
+			goto out;
+		}
+		req->_dev = dev;
+		/*
+		 * Duplicate this, instead of using req->_dev, as we can't rely
+		 * on the value of _dev at time of free. Check comment in
+		 * _req_mgmt_cleanup.
+		 */
+		req->_a = dev->a;
+		ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
 	}
 
+	uk_9preq_init(req);
+
+	/*
+	 * If request was from the free list, it should already belong to the
+	 * dev.
+	 */
+	UK_ASSERT(req->_dev == dev);
+
 	/* Shouldn't exceed the msize on non-zerocopy buffers, just in case. */
 	req->recv.size = MIN(req->recv.size, dev->msize);
 	req->xmit.size = MIN(req->xmit.size, dev->msize);
 
-	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
 	if (type == UK_9P_TVERSION)
 		tag = UK_9P_NOTAG;
 	else
@@ -360,6 +416,18 @@ int uk_9pdev_req_remove(struct uk_9pdev *dev, struct uk_9preq *req)
 	return uk_9preq_put(req);
 }
 
+void uk_9pdev_req_to_freelist(struct uk_9pdev *dev, struct uk_9preq *req)
+{
+	unsigned long flags;
+
+	if (!dev)
+		return;
+
+	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
+	_req_mgmt_req_to_freelist_locked(&dev->_req_mgmt, req);
+	ukplat_spin_unlock_irqrestore(&dev->_req_mgmt.spinlock, flags);
+}
+
 struct uk_9pfid *uk_9pdev_fid_create(struct uk_9pdev *dev)
 {
 	struct uk_9pfid *fid = NULL;
diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
index d44e684..edc462c 100644
--- a/lib/uk9p/9preq.c
+++ b/lib/uk9p/9preq.c
@@ -35,6 +35,7 @@
 #include <string.h>
 #include <uk/config.h>
 #include <uk/9preq.h>
+#include <uk/9pdev.h>
 #include <uk/9p_core.h>
 #include <uk/list.h>
 #include <uk/refcount.h>
@@ -45,14 +46,8 @@
 #include <uk/wait.h>
 #endif
 
-struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a)
+void uk_9preq_init(struct uk_9preq *req)
 {
-	struct uk_9preq *req;
-
-	req = uk_calloc(a, 1, sizeof(*req));
-	if (req == NULL)
-		return NULL;
-
 	req->xmit.buf = req->xmit_buf;
 	req->recv.buf = req->recv_buf;
 	req->xmit.size = req->recv.size = UK_9P_BUFSIZE;
@@ -69,13 +64,10 @@ struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a)
 	req->recv.offset = 0;
 
 	UK_INIT_LIST_HEAD(&req->_list);
-	req->_a = a;
 	uk_refcount_init(&req->refcount, 1);
 #if CONFIG_LIBUKSCHED
 	uk_waitq_init(&req->wq);
 #endif
-
-	return req;
 }
 
 void uk_9preq_get(struct uk_9preq *req)
@@ -89,7 +81,7 @@ int uk_9preq_put(struct uk_9preq *req)
 
 	last = uk_refcount_release(&req->refcount);
 	if (last)
-		uk_free(req->_a, req);
+		uk_9pdev_req_to_freelist(req->_dev, req);
 
 	return last;
 }
diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
index 1225336..560ba8f 100644
--- a/lib/uk9p/include/uk/9pdev.h
+++ b/lib/uk9p/include/uk/9pdev.h
@@ -149,6 +149,16 @@ struct uk_9preq *uk_9pdev_req_lookup(struct uk_9pdev *dev, uint16_t tag);
  */
 int uk_9pdev_req_remove(struct uk_9pdev *dev, struct uk_9preq *req);
 
+/**
+ * Places the given request on the 9p device's request freelist.
+ *
+ * @param dev
+ *   The Unikraft 9P Device. If NULL, doesn't place the request on the freelist.
+ * @param req
+ *   The request to be placed on the freelist.
+ */
+void uk_9pdev_req_to_freelist(struct uk_9pdev *dev, struct uk_9preq *req);
+
 /**
  * Creates a FID associated with the given 9P device.
  *
diff --git a/lib/uk9p/include/uk/9pdev_core.h b/lib/uk9p/include/uk/9pdev_core.h
index 38864ac..fcad1ef 100644
--- a/lib/uk9p/include/uk/9pdev_core.h
+++ b/lib/uk9p/include/uk/9pdev_core.h
@@ -120,6 +120,8 @@ struct uk_9pdev_req_mgmt {
 	unsigned long                   tag_bm[UK_BITS_TO_LONGS(UK_9P_NUMTAGS)];
 	/* List of requests allocated and not yet removed. */
 	struct uk_list_head             req_list;
+	/* Free-list of requests. */
+	struct uk_list_head		req_free_list;
 };
 
 /**
diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
index ed883d2..aad8d42 100644
--- a/lib/uk9p/include/uk/9preq.h
+++ b/lib/uk9p/include/uk/9preq.h
@@ -162,6 +162,8 @@ struct uk_9preq {
 	uint16_t                        tag;
 	/* Entry into the list of requests (API-internal). */
 	struct uk_list_head             _list;
+	/* @internal 9P device this request belongs to. */
+	struct uk_9pdev                 *_dev;
 	/* @internal Allocator used to allocate this request. */
 	struct uk_alloc                 *_a;
 	/* Tracks the number of references to this structure. */
@@ -176,16 +178,10 @@ UK_CTASSERT(sizeof(struct uk_9preq) <= __PAGE_SIZE);
 
 /**
  * @internal
- * Allocates a 9p request.
+ * Initializes a 9P request.
  * Should not be used directly, use uk_9pdev_req_create() instead.
- *
- * @param a
- *   Allocator to use.
- * @return
- *   - (==NULL): Out of memory.
- *   - (!=NULL): Successful.
  */
-struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a);
+void uk_9preq_init(struct uk_9preq *req);
 
 /**
  * Gets the 9p request, incrementing the reference count.
@@ -197,7 +193,8 @@ void uk_9preq_get(struct uk_9preq *req);
 
 /**
  * Puts the 9p request, decrementing the reference count.
- * If this was the last live reference, the memory will be freed.
+ * If this was the last live reference, it will be placed on the asociated
+ * device's request freelist.
  *
  * @param req
  *   Reference to the 9p request.
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Sat May 09 16:44:59 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 09 May 2020 16:44: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 1jXSax-0002Iv-15; Sat, 09 May 2020 16:44: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=uJFB=6X=gmail.com=cristb@srs-us1.protection.inumbo.net>)
 id 1jXSaw-0002IG-0l
 for minios-devel@lists.xen.org; Sat, 09 May 2020 16:44:58 +0000
X-Inumbo-ID: 53942484-9214-11ea-b07b-bc764e2007e4
Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 53942484-9214-11ea-b07b-bc764e2007e4;
 Sat, 09 May 2020 16:44:19 +0000 (UTC)
Received: by mail-wr1-x441.google.com with SMTP id 50so5043293wrc.11
 for <minios-devel@lists.xen.org>; Sat, 09 May 2020 09:44:19 -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=e1yxLT+QQNdUcz5+5myZxCYNnd2hjbWcU855uAmL9Go=;
 b=vL3+P476s8Sk9T8mQIWdYrlqDIVqZtbT+262btOKovbGS//kdOAgbRe3g8NVZllg8S
 4HmlC0X837qXKZ7lo2RJUUs/7sXHBKm43W3vVXiLT3svdE6qllpYNceBMN7cKGQJYisg
 ZzRt2nC0Id7ou2M+rCgb6HAOaerFScoNqbNSnDJOmRvqCEhgiCEqLrGA9Eg6ike2jJ5b
 7jQJruWj16sqlUpM7nkSM6vu+/MSQcuORgEOLaaWVqVsIdr3O7Nf9Db6uy7Qp+dRQGr2
 Ypxketcs+BSqjeEIFguyMf4pIa4hjj9zjiwc0pbxKqMtKNz/CGYKN8TcXJZg/Kig7Msy
 whHw==
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=e1yxLT+QQNdUcz5+5myZxCYNnd2hjbWcU855uAmL9Go=;
 b=BklTcir0omwSb0D99px0MX3aaOOMcPhnpduS4YKeGld0E1fkXS8Gm4o+m5wg3d0RQj
 9gOF1lXeOiV+X3baLL1+MF+mv08gCOcsI4qDI4I+kxkNJGwtoNTXyaDdm4WuPQOYRrsp
 JSntdDPIbOoNNbK9pY7+Y/zFHssibVnAxZktuATBmX7/6RH1BPZWD65/ctqYOBb6BJjo
 u/uznJMhvWlCcMHI4lEyoSQDHStx/wrpcbfnF1C2ilcqUgrSrv478XkBYEda5CvNXVrT
 v/aPKfPL8NfGnBzgl7rfvJ3hZmbtvPRpUTOBj9WwFENs23mXec4zr747yz9ktyksrgQg
 24ew==
X-Gm-Message-State: AGi0Pub1gDpUZlntxuevSRzqxEUxoPHXAopZ6K9eXiRhguZ3PerZ4272
 I2si9RcHvMsGDXAeWreHBeMscT+36Ks=
X-Google-Smtp-Source: APiQypJtZ0G61DYfIsZh937BssGo6V80EfFY9o2XBw61bkNnMPt6SK8l/Hv8ggE9W767Jdtfvcu/5w==
X-Received: by 2002:a05:6000:85:: with SMTP id
 m5mr8601213wrx.281.1589042658186; 
 Sat, 09 May 2020 09:44:18 -0700 (PDT)
Received: from localhost.localdomain ([2a01:4b00:9d37:300:c82b:4bf7:97bb:6048])
 by smtp.gmail.com with ESMTPSA id l5sm17876306wmi.22.2020.05.09.09.44.17
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 09 May 2020 09:44:17 -0700 (PDT)
From: Cristian Banu <cristb@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH v2 9/9] lib/9pfs: Simplify the logic for removes
Date: Sat,  9 May 2020 17:44:13 +0100
Message-Id: <20200509164413.38078-10-cristb@gmail.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20200509164413.38078-1-cristb@gmail.com>
References: <20200509164413.38078-1-cristb@gmail.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>
Cc: costin.lupu@cs.pub.ro, Cristian Banu <cristb@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

The logic for unlinking is simplified, either:
- there are no open files, remove now;
- there are open files, defer until all open files are closed

This is now possible since successive open and closes update
the dentry reference count correctly, so VOP_INACTIVE is called
in time to free the fid before the qid starts being reused
on the server-side (and we get an inode collision).

This also means that on unmounting, releasing all non-root
dentries and calling vfscore_release_mp_dentries() for m_covered
and m_root is enough to ensure all fids are clunked before
disconnecting.

Signed-off-by: Cristian Banu <cristb@gmail.com>
---
 lib/9pfs/9pfs_vfsops.c |  7 +++----
 lib/9pfs/9pfs_vnops.c  | 37 +++++++++++--------------------------
 2 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/lib/9pfs/9pfs_vfsops.c b/lib/9pfs/9pfs_vfsops.c
index accb3a5..5293b22 100644
--- a/lib/9pfs/9pfs_vfsops.c
+++ b/lib/9pfs/9pfs_vfsops.c
@@ -169,11 +169,10 @@ static void uk_9pfs_release_tree_fids(struct dentry *d)
 {
 	struct dentry *p;
 
-	uk_list_for_each_entry(p, &d->d_child_list, d_child_link)
+	uk_list_for_each_entry(p, &d->d_child_list, d_child_link) {
 		uk_9pfs_release_tree_fids(p);
-
-	if (d->d_vnode->v_data)
-		uk_9pfs_free_vnode_data(d->d_vnode);
+		drele(p);
+	}
 }
 
 static int uk_9pfs_unmount(struct mount *mp, int flags __unused)
diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
index 6d3ece3..c81c82a 100644
--- a/lib/9pfs/9pfs_vnops.c
+++ b/lib/9pfs/9pfs_vnops.c
@@ -147,7 +147,7 @@ void uk_9pfs_free_vnode_data(struct vnode *vp)
 	struct uk_9pdev *dev = UK_9PFS_MD(vp->v_mount)->dev;
 	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
 
-	if (nd->nb_open_files > 0)
+	if (!vp->v_data)
 		return;
 
 	if (nd->removed)
@@ -158,20 +158,6 @@ void uk_9pfs_free_vnode_data(struct vnode *vp)
 	vp->v_data = NULL;
 }
 
-/*
- * The closing variant of the function will enforce freeing the associated
- * resources only if the vnode was removed via an unlink/rmdir operation.
- */
-static void uk_9pfs_free_vnode_data_closing(struct vnode *vp)
-{
-	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
-
-	if (!nd->removed)
-		return;
-
-	uk_9pfs_free_vnode_data(vp);
-}
-
 static int uk_9pfs_open(struct vfscore_file *file)
 {
 	struct uk_9pdev *dev = UK_9PFS_MD(file->f_dentry->d_mount)->dev;
@@ -222,7 +208,6 @@ static int uk_9pfs_close(struct vnode *vn __unused, struct vfscore_file *file)
 	uk_9pfid_put(fd->fid);
 	free(fd);
 	UK_9PFS_ND(file->f_dentry->d_vnode)->nb_open_files--;
-	uk_9pfs_free_vnode_data_closing(file->f_dentry->d_vnode);
 
 	return 0;
 }
@@ -327,22 +312,22 @@ static int uk_9pfs_remove_generic(struct vnode *dvp, struct vnode *vp)
 {
 	struct uk_9pdev *dev = UK_9PFS_MD(dvp->v_mount)->dev;
 	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
-	int rc = 0;
-
-	if (!nd->removed && !nd->nb_open_files)
-		rc = uk_9p_remove(dev, nd->fid);
-	else
-		nd->removed = true;
-
-	uk_9pfs_free_vnode_data(vp);
 
-	return -rc;
+	return -uk_9p_remove(dev, nd->fid);
 }
 
 static int uk_9pfs_remove(struct vnode *dvp, struct vnode *vp,
 		char *name __unused)
 {
-	return uk_9pfs_remove_generic(dvp, vp);
+	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
+	int rc = 0;
+
+	if (!nd->nb_open_files)
+		rc = uk_9pfs_remove_generic(dvp, vp);
+	else
+		nd->removed = true;
+
+	return rc;
 }
 
 static int uk_9pfs_mkdir(struct vnode *dvp, char *name, mode_t mode)
-- 
2.26.2



From minios-devel-bounces@lists.xenproject.org Mon May 11 00:54:20 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 11 May 2020 00:54: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 1jXwi1-000390-5l; Mon, 11 May 2020 00:54: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=Vak5=6Z=upb.ro=vlad_andrei.badoiu@srs-us1.protection.inumbo.net>)
 id 1jXwi0-00038v-60
 for minios-devel@lists.xen.org; Mon, 11 May 2020 00:54:16 +0000
X-Inumbo-ID: eddff7e4-9321-11ea-ae69-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.5])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id eddff7e4-9321-11ea-ae69-bc764e2007e4;
 Mon, 11 May 2020 00:54:13 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 9061AB5626C9;
 Mon, 11 May 2020 03:54:11 +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 D6eUZ4ililz7; Mon, 11 May 2020 03:54:09 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 95336B5626D0;
 Mon, 11 May 2020 03:54:09 +0300 (EEST)
DKIM-Filter: OpenDKIM Filter v2.10.3 mx.upb.ro 95336B5626D0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upb.ro;
 s=96342B8A-77E4-11E5-BA93-D93D0963A2DF; t=1589158449;
 bh=VE7HSWdmpsbjMyc9a1KkfRWO9voC7qZLL/m+kU7t718=;
 h=From:To:Date:Message-Id:MIME-Version;
 b=ZC/pJH5Z8EZOrj0r6qR0sttDFrh/zLTm8s/vVswoc4TWc/0SnaV4dxJF3lgSRh9JV
 L79O1ocU1O6CtSuGExrjSftd0B44SfORLKFWwB6/4WE42SiSHY4JlT06HBRFn02DrW
 wwXlFux+RSIiVnyLFKa2/3Kj0Lt2X+6t64eTIA+U=
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 u1h-qFBIsuKE; Mon, 11 May 2020 03:54:09 +0300 (EEST)
Received: from localhost.localdomain (unknown [188.27.169.187])
 by mx.upb.ro (Postfix) with ESMTPSA id 4A97EB5626C1;
 Mon, 11 May 2020 03:54:09 +0300 (EEST)
From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 1/1] build: Add -fno-split-stack
Date: Mon, 11 May 2020 03:54:06 +0300
Message-Id: <20200511005406.1451-1-vlad_andrei.badoiu@upb.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>
Cc: simon.kuenzer@neclab.eu, Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Until recently we have been using -fno-split-stack for GO source.
This flag was dropped by mistake in the recent commits.
We add this flag back since LD does not have full split stack
support.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
---
 Makefile.uk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.uk b/Makefile.uk
index 1d6d060a..2c102989 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -6,7 +6,7 @@
=20
 COMPFLAGS    +=3D -nostdinc -nostdlib
 COMPFLAGS    +=3D -U __linux__ -U __FreeBSD__ -U __sun__
-COMPFLAGS    +=3D -fno-stack-protector -fno-omit-frame-pointer -fno-tree=
-sra
+COMPFLAGS    +=3D -fno-stack-protector -fno-omit-frame-pointer -fno-tree=
-sra -fno-split-stack
 COMPFLAGS    +=3D -Wall -Wextra
=20
 ASFLAGS      +=3D -D__ASSEMBLY__
--=20
2.20.1



From minios-devel-bounces@lists.xenproject.org Tue May 12 12:07:58 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 12 May 2020 12:07:58 +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 1jYThS-0005od-NU; Tue, 12 May 2020 12:07: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=Demm=62=lancaster.ac.uk=a.jung@srs-us1.protection.inumbo.net>)
 id 1jYThQ-0005oY-RL
 for minios-devel@lists.xenproject.org; Tue, 12 May 2020 12:07:52 +0000
X-Inumbo-ID: 32c017e0-9449-11ea-b07b-bc764e2007e4
Received: from GBR01-CWL-obe.outbound.protection.outlook.com (unknown
 [40.107.11.116]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 32c017e0-9449-11ea-b07b-bc764e2007e4;
 Tue, 12 May 2020 12:07:50 +0000 (UTC)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=S/uNqRus5JUne+4lseee6CeAfdTrx5auP5tYnBhi8+M0HW/ppr857GNAriVJzrSsOrFtcRk14et5IXxBjSYNoH6I67mdLfpsghf4MlgVJZEleKvAxeg1SLByK3cy7tsK3pfcOVs/+Ej+xtVSXhGHTgW7k8KQIYIpt4HUdjFONNvnLtXvJk4Ow9CF5CGDKEZxuKrwDNb2igfFe28QvQ3/RgYCuH/yua9/b/s3ej8oNWxuuFe7jN+ToEBUncQUCuepRiohmEnNLpESV+3lZoaI3NVnAcENNLzhdByErBNYkAdcIKSN7+2GsLbQZgwUDKEkQwnIfVC0fBZWyf2BCzeY4w==
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=No+uKsSORLduwxRJgNlYY2KDu0G4HXMgNy9U/uiYcAI=;
 b=N9MJqGREP0CNTXSddj5z+M3EFPfdHDA14bvaP4pu+BUgzzewJWCcOePW6NHSBE2Oms89/tkfSZjoyIv08VoHaaT+M4kjgE8Um8+fabNfho4onqgPKpZ+ijHfCtdUCDR5TJYyt4EvTJAtcH+uIaVJl4SGgkq71aH1Kk96XkUVtQ38EpZ6Q4A5pWgiqSWGCqY3AsX8yulrkNZuo5OvDKw+MvWn/DOVu9VXktDlqPjPkdK5dA5CRgQ35KSK3tg4HzOyhDNaI+zimItew59lofvZRVhgc6CbavaCbB/8HTjla0UvJGl3xBAHSYCWhooYMIxXltsemoSqV25ZIe4Od0RahA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=lancaster.ac.uk; dmarc=pass action=none
 header.from=lancaster.ac.uk; dkim=pass header.d=lancaster.ac.uk; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=livelancsac.onmicrosoft.com; s=selector2-livelancsac-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=No+uKsSORLduwxRJgNlYY2KDu0G4HXMgNy9U/uiYcAI=;
 b=kZno5oDBpUf9xpNTVAQERGXDpGlfjpK3zklp9BhIukNvcqc6Xf5Pg803Kq+5XNB/H84ljGz1FqnDlanXO34J8tM/sUSQ4QnNMuZCxnmfTLEB+d6idQqPq38uYZ4W4BI7WDoCDR8pF+mH+eAJGXl/+9g4u8U8lgyjgbYPJob9u0c=
Received: from LNXP265MB1468.GBRP265.PROD.OUTLOOK.COM (20.176.134.21) by
 LNXP265MB0011.GBRP265.PROD.OUTLOOK.COM (10.166.178.140) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.2979.33; Tue, 12 May 2020 12:07:48 +0000
Received: from LNXP265MB1468.GBRP265.PROD.OUTLOOK.COM
 ([fe80::540a:e897:7b7b:a73a]) by LNXP265MB1468.GBRP265.PROD.OUTLOOK.COM
 ([fe80::540a:e897:7b7b:a73a%2]) with mapi id 15.20.2979.033; Tue, 12 May 2020
 12:07:48 +0000
From: "Jung, Alexander" <a.jung@lancaster.ac.uk>
To: "minios-devel@lists.xenproject.org" <minios-devel@lists.xenproject.org>
Subject: Re: [UNIKRAFT/LIB-PCRE V2] Makefile.uk: Update symbolic link
 generation
Thread-Topic: [UNIKRAFT/LIB-PCRE V2] Makefile.uk: Update symbolic link
 generation
Thread-Index: AQHWKFXzyVFLyf+a4UGXdyCYUKMImQ==
Date: Tue, 12 May 2020 12:07:48 +0000
Message-ID: <246D30D4-9153-422A-8F5A-D48A448A5389@lancaster.ac.uk>
References: <20200427135638.28690-1-gaulthier.gain@uliege.be>
In-Reply-To: <20200427135638.28690-1-gaulthier.gain@uliege.be>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
user-agent: Microsoft-MacOutlook/16.36.20041300
authentication-results: lists.xenproject.org; dkim=none (message not signed)
 header.d=none;lists.xenproject.org; dmarc=none action=none
 header.from=lancaster.ac.uk;
x-originating-ip: [77.190.170.160]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 5a81fb7b-eace-4caa-647a-08d7f66d1672
x-ms-traffictypediagnostic: LNXP265MB0011:
x-microsoft-antispam-prvs: <LNXP265MB0011F3C225ED2C8C5772568ECEBE0@LNXP265MB0011.GBRP265.PROD.OUTLOOK.COM>
x-ms-oob-tlc-oobclassifiers: OLM:8273;
x-forefront-prvs: 0401647B7F
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: gbApmdOvtpri4psXG1USWgLepyqgUwf2Prqv4woTixYtDTg9yDckGHVx1PzBhboG6L2M3y3T8FPjmxbKiUOM0nYUpHnfiYMq9kt1pMY4Qsyj7fY9bmpZSfkWB79qLTYD3nHdBB5Zh2LxHxvKypzL6WxqdoLQkLGpWS76eUKae1v3hu/JmyTABpbv5ZrB2sR0OpJOP6TJ7iHdJ2vBQuTMOxOe98Nm5uyGzKlTzPeVlcmHRdUTbcSxVTsLjLiKmnfzEix6nwndJDYxPlx5E97wMuHJDVF9ft91W8t+RgXjfWTF/DoCn7mXb91ayP99EGGdIkAqDiE3EbYyqvwVDGJ4uMLpafQujbfrO2ZaNDAWZraNM9X24UBholDmvrWD3R7Shdf6EFkND/IBLkYJM3O1uVg6dVEHsl/lQkqF0nU7rdiuMk7vCfTIzfeMQOOJAu4TvpIfbsRPEDS0jFeL1AfwKElMm1J54vZNFxpgIJfmvKo7/W2ucPQhOy5aoEN3+aNtIqvDc4Rjfskv5wP4zQzl/A==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:LNXP265MB1468.GBRP265.PROD.OUTLOOK.COM; PTR:; CAT:NONE;
 SFTY:;
 SFS:(4636009)(376002)(366004)(346002)(136003)(396003)(39860400002)(33430700001)(786003)(15650500001)(8676002)(6916009)(2616005)(36756003)(66946007)(76116006)(66446008)(66556008)(91956017)(64756008)(54906003)(316002)(66476007)(26005)(186003)(6506007)(8936002)(2906002)(33440700001)(6486002)(6512007)(33656002)(5660300002)(86362001)(4326008)(478600001)(71200400001);
 DIR:OUT; SFP:1102; 
x-ms-exchange-antispam-messagedata: WighivPavcASEubL5L3/2gwSUVZDFNdNzuGXGmqYo5iWKzaeG2oHMdtI7+26SRYv4wwxBSFPnWrc4gSUh5y5q5MpWjfmgqFFIJh0YaFbHO9tUfxX0psc8gwsUxMhtSR3xJ1ChHMg4RAYeSCG0Yb/94qGgeYYzN85iPpMEtgP2q1kOCWrpJJNxboFGeqKl4y1Nq53GMPBTYQGejgFI4GyxbdPywo7QeJCzg2pTrEct6fWBggNV6fB8yL4OmcYplM+1OME1OUcbj9L5Z+YRgg7ivPuo5TLXRNdCgXaDBgLgXaAnIJtZ8eT4fPZhPMEaEMxpazwcPFuQ3uM4iplxBaLdBOdBKHGVJk5rUkRqjo4A8RcPOY7PP4F9l2J8IU1s6EJDgUMSTu8k4dY9ujejMzzEjHqH9U1s+atiEC+Ir+jzgRLteQ+1lTEC/OQ0Vemm+9EWce3W8Fn+46X04o5zTH2v5I+M5heNApUe/ACY5rl1gcCseuXK8alr++li6bRR8c0
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="utf-8"
Content-ID: <43732EFF7D79344D84CEE31A52D1049E@GBRP265.PROD.OUTLOOK.COM>
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-OriginatorOrg: lancaster.ac.uk
X-MS-Exchange-CrossTenant-Network-Message-Id: 5a81fb7b-eace-4caa-647a-08d7f66d1672
X-MS-Exchange-CrossTenant-originalarrivaltime: 12 May 2020 12:07:48.3828 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 9c9bcd11-977a-4e9c-a9a0-bc734090164a
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: KoEeejbnSJiM5v0wq8iwvODKgqMWAtW/PueY1dMiWZl3NMi9VL4c9iI8WHrdXYigrCChRuEeNIUGTHg1oMow0Q==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: LNXP265MB0011
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>
Cc: "felipe.huici@neclab.eu" <felipe.huici@neclab.eu>,
 gaulthier gain <gaulthier.gain@uliege.be>,
 "costin.lupu@cs.pub.ro" <costin.lupu@cs.pub.ro>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

VGhlcmUgYXJlIHR3byBzb2x2ZXMgZm9yIHRoaXMgcHJvYmxlbSwgdGhpcyBpcyB0aGUgZmlyc3Qg
YW5kIA0KYmV0dGVyIGFwcHJvYWNoLg0KDQpUaGUgYWx0ZXJuYXRpdmUgaXMgc2ltcGx5IGFkZCBw
Y3JlX2NoYXJ0YWJsZXMuYy5kaXN0IHRvIHRoZSBsaXN0DQpvZiBMSUJQQ1JFX1BSRVBBUkVEX0RF
UFMuICBUaGlzIHdpbGwgcHJldmVudCB0aGUgZmlsZSBmcm9tIGJlaW5nDQp0YXJnZXRlZCBieSBt
YWtlIG9uIHN1YnNlcXVlbnQgYnVpbGRzICh3aGVyZWluIHRoaXMgcGF0Y2ggZml4ZXMpLg0KSG93
ZXZlciwgYWZ0ZXIgcmV2aWV3aW5nIHRoZSBwY3JlIHNvdXJjZSBjb2RlIGl0c2VsZiwgaXQgYWxz
bw0KdXNlcyB0aGUgLWYgZmxhZyB0byBkaXN0cmlidXRlIHRoZSAuZGlzdCBmaWxlIHRodXMgbWFr
aW5nIHRoaXMNCnRoZSBiZXR0ZXIgc29sdmUuDQoNClRoYW5rcyENCg0KUmV2aWV3ZWQtYnk6IEFs
ZXhhbmRlciBKdW5nIDxhLmp1bmdAbGFuY3MuYWMudWs+DQoNCu+7v09uIDI3LjA0LjIwLCAxNTo1
NywgIm1pbmlvcy1kZXZlbC1ib3VuY2VzQGxpc3RzLnhlbnByb2plY3Qub3JnIG9uIGJlaGFsZiBv
ZiBnYXVsdGhpZXIuZ2FpbkB1bGllZ2UuYmUiIDxtaW5pb3MtZGV2ZWwtYm91bmNlc0BsaXN0cy54
ZW5wcm9qZWN0Lm9yZyBvbiBiZWhhbGYgb2YgZ2F1bHRoaWVyLmdhaW5AdWxpZWdlLmJlPiB3cm90
ZToNCg0KRnJvbTogZ2F1bHRoaWVyIGdhaW4gPGdhdWx0aGllci5nYWluQHVsaWVnZS5iZT4NCg0K
RHVyaW5nIHRoZSBjcmVhdGlvbiBvZiB0aGUgInBjcmVfY2hhcnRhYmxlcy5jIiBzeW1saW5rLCBh
biBlcnJvcg0KY2FuIGFwcGVhciBpZiB0aGUgZmlsZSBhbHJlYWR5IGV4aXN0cy4gVGhpcyBwYXRj
aCBmaXhlcyB0aGlzIGlzc3VlDQpieSBhZGRpbmcgdGhlIC1mIG9wdGlvbiB3aGljaCByZW1vdmVz
IGV4aXN0aW5nIGRlc3RpbmF0aW9uIGZpbGVzLg0KDQpDaGFuZ2VzIHYyOg0KLSBJbiBhZGRpdGlv
biwgd2UgYWxzbyB1cGRhdGVkIHRoZSBsYWJlbCB3aXRoICJIT1NUTE4iLg0KDQpTaWduZWQtb2Zm
LWJ5OiBnYXVsdGhpZXIgZ2FpbiA8Z2F1bHRoaWVyLmdhaW5AdWxpZWdlLmJlPg0KLS0tDQogTWFr
ZWZpbGUudWsgfCA0ICsrLS0NCiAxIGZpbGUgY2hhbmdlZCwgMiBpbnNlcnRpb25zKCspLCAyIGRl
bGV0aW9ucygtKQ0KDQpkaWZmIC0tZ2l0IGEvTWFrZWZpbGUudWsgYi9NYWtlZmlsZS51aw0KaW5k
ZXggZmVlNTFjOC4uMDQ0NGM3ZCAxMDA2NDQNCi0tLSBhL01ha2VmaWxlLnVrDQorKysgYi9NYWtl
ZmlsZS51aw0KQEAgLTEyMiw4ICsxMjIsOCBAQCAkKExJQlBDUkVfRVhUUkFDVEVEKS9jb25maWcu
c3RhdHVzOiAkKExJQlBDUkVfQlVJTEQpLy5vcmlnaW4NCg0KICMgQ3JlYXRlIHBjcmVfY2hhcnRh
Ymxlcy5jIHN5bWxpbmsNCiAkKExJQlBDUkVfRVhUUkFDVEVEKS9wY3JlX2NoYXJ0YWJsZXMuYzog
JChMSUJQQ1JFX0VYVFJBQ1RFRCkvY29uZmlnLnN0YXR1cw0KLQkkKGNhbGwgdmVyYm9zZV9jbWQs
TElOSyxsaWJwY3JlOiAkKG5vdGRpciAkQCksIFwNCi0JCWNkICQoTElCUENSRV9FWFRSQUNURUQp
ICYmIGxuIC1zIHBjcmVfY2hhcnRhYmxlcy5jLmRpc3QgJEApDQorCSQoY2FsbCB2ZXJib3NlX2Nt
ZCxIT1NUTE4sbGlicGNyZTogJChub3RkaXIgJEApLCBcDQorCQljZCAkKExJQlBDUkVfRVhUUkFD
VEVEKSAmJiBsbiAtZnMgcGNyZV9jaGFydGFibGVzLmMuZGlzdCAkQCkNCg0KIExJQlBDUkVfUFJF
UEFSRURfREVQUyA9IFwNCiAJJChMSUJQQ1JFX0VYVFJBQ1RFRCkvY29uZmlnLnN0YXR1cyBcDQot
LSANCjIuMTcuMQ0KDQoNCg==


From minios-devel-bounces@lists.xenproject.org Wed May 13 08:57:09 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 13 May 2020 08:57: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 1jYnCL-0006AO-VS; Wed, 13 May 2020 08:57: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=z9xS=63=gmail.com=jiakernel2@srs-us1.protection.inumbo.net>)
 id 1jYnCK-0006AJ-Bl
 for minios-devel@lists.xenproject.org; Wed, 13 May 2020 08:57:04 +0000
X-Inumbo-ID: b67bb84c-94f7-11ea-ae69-bc764e2007e4
Received: from mail-pj1-x1042.google.com (unknown [2607:f8b0:4864:20::1042])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id b67bb84c-94f7-11ea-ae69-bc764e2007e4;
 Wed, 13 May 2020 08:57:03 +0000 (UTC)
Received: by mail-pj1-x1042.google.com with SMTP id j13so681640pjm.2
 for <minios-devel@lists.xenproject.org>; Wed, 13 May 2020 01:57:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:subject:to:cc:references:message-id:date:user-agent
 :mime-version:in-reply-to:content-transfer-encoding;
 bh=6hR2LFZLp+t5K4wU+iX5wiyrOugcmUdyamAiN4tX4JE=;
 b=GhnY0qRu5LfacsXBJtIopYXPuNnvZZC5ARoL66GVQXxr3C0iU6riON+dy0U4o1ptDW
 DOXauI991qr0R3fhIkfwrqAAu75KDDfV+rFFOxMPwt8cWej/AN8aMA8nJPgxguTaEdE1
 RHqXUxKrf/u3+/gAHTKO+gRI/dVm/9vJ8BpH2Spus94VojsU1t6vw4vuMncOk64tJtRC
 y2my8hqmrfqnWgEcIrju+SnWjzgI52R9w1ORj4XypkYBPDSxeZeQ6SeE8dtdd5mDe7zQ
 /RHCbpVaVIQ8Ytnmp7SiZGoDQ9pN8LEUdd/qtOte6Qttqu5fhb6B92SOjNdrfQ6PUciY
 2H6Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:subject:to:cc:references:message-id:date
 :user-agent:mime-version:in-reply-to:content-transfer-encoding;
 bh=6hR2LFZLp+t5K4wU+iX5wiyrOugcmUdyamAiN4tX4JE=;
 b=QjwQ2ms/k9ON+hzah9nG95eVP2zyxBbwWl/t9wF0/NwOqYi8vc3C7zTeqtCXPwjpOo
 XtxOPgCrKUowePnL2qqPAIoaSRKRZrLP3IRqyuiSPPDaEIQUk62KDpng0PemzFE3AlTV
 ++PRnDCGa3WggiNX92HSuCTHnmU0AnSXebft48/cM0fb2W71s2GjlS5SYXXqOHD1bpBR
 kDMkXdlU6+KuRGVq64fffJyDtO9FtyMemdILuFeLdeUeQ73FoDrTJfz6HmoGaVvx3bkV
 WgMRE7MMouYvziMAOZ/L3Ey5VWHic3I1LUK/bBgbCOnzsxRDqIcjkM0NQL02dAzSSCCj
 jaQQ==
X-Gm-Message-State: AGi0PubGvTAakYyTgkjS1NjftitXmncaEiK6nWuKZ5+636CMgSdpVZ/m
 olY7J/7kdeX1ecnUjOxgGwI=
X-Google-Smtp-Source: APiQypKFNAYxCwu9d33WL9z10LRXYidbuxYb1puhmU0T0zg2AOxu/5K4QvMDW9BE8RD89oUDHzv2ig==
X-Received: by 2002:a17:90a:2c08:: with SMTP id
 m8mr32609438pjd.102.1589360222307; 
 Wed, 13 May 2020 01:57:02 -0700 (PDT)
Received: from [0.0.0.0] ([45.76.223.48])
 by smtp.gmail.com with ESMTPSA id cc8sm14770690pjb.11.2020.05.13.01.56.54
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 13 May 2020 01:57:01 -0700 (PDT)
From: Jia He <jiakernel2@gmail.com>
Subject: Re: [Minios-devel] [UNIKRAFT PATCH RFC 00/23] Impelment virtio_mmio
 and pci ecam controller for arm64 kvm plat
To: Felipe Huici <Felipe.Huici@neclab.eu>, Jia He <Justin.He@arm.com>,
 "minios-devel@lists.xenproject.org" <minios-devel@lists.xenproject.org>
References: <20200306045035.45387-1-justin.he@arm.com>
 <748393D5-263B-4288-AB00-EA76B27E104A@neclab.eu>
Message-ID: <a0622cee-5b92-0612-9cfa-a258246a89a5@gmail.com>
Date: Wed, 13 May 2020 16:56:50 +0800
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <748393D5-263B-4288-AB00-EA76B27E104A@neclab.eu>
Content-Type: text/plain; charset=utf-8; format=flowed
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>
Cc: Kaly Xin <Kaly.Xin@arm.com>, Simon Kuenzer <simon.kuenzer@neclab.eu>,
 "nd@arm.com" <nd@arm.com>, Julien Grall <julien.grall@xen.org>,
 Sharan Santhanam <Sharan.Santhanam@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi Felipe, thank you very much for your testing and comments.

And sorry for the late response.

On 2020/3/13 18:00, Felipe Huici wrote:
> Hi Justin,
>
> Thanks so much for the series, it's great to have networking going on arm64! I've tested it against http reply and it works fine. However, I have a number of issues with the series:
>
> 1. It doesn't build against newlib, which precludes running a large set of applications (e.g., Redis, nginx, sqlite, etc.). The fix here is simple:
Yes, I only tested it with nolibc, will fix it when building against newlib soon.
> diff --git a/lib/fdt/fdt_addresses.c b/lib/fdt/fdt_addresses.c
> index b362b41..30c7ff5 100644
> --- a/lib/fdt/fdt_addresses.c
> +++ b/lib/fdt/fdt_addresses.c
> @@ -60,7 +60,7 @@
>
>   int fdt_address_cells(const void *fdt, int nodeoffset)
>   {
> -       __u32 cells;
> +       uint32_t cells;
>          int parent;
>          int off = nodeoffset;
>          int *prop;
> @@ -81,7 +81,7 @@ int fdt_address_cells(const void *fdt, int nodeoffset)
>
>   int fdt_size_cells(const void *fdt, int nodeoffset)
>   {
> -       __u32 cells;
> +       uint32_t cells;
>          int parent;
>          int off = nodeoffset;
>          int *prop;
>
> 2. I get a large number of (spurious?) error messages such as:
>
> [    0.036700] ERR:  [libkvmpf] platform_bus.c @ 180  : Platform Failed to initialize device driver, ret(-19)
>
> Things work despite these, should these really be errors?
No, they aren't errors. Will fix it in next version
> 3. There's a large number of compilation warnings (too many to list here)
Will fix it
> 4. When setting ukdebug's Kernel message level to "Show all types of messages" I get a register dump during boot:
>
> [    0.073966] Info: [libkvmpci] pci_ecam.c @ 370  :  -> imaplen=90
> [    0.074064] Info: [libkvmpci] pci_ecam.c @ 325  :  -> match=0 (imaplen=86)
> [    0.075033] Info: [libkvmpci] pci_ecam.c @ 370  :  -> imaplen=80
> [    0.075131] Info: [libkvmpci] pci_ecam.c @ 325  :  -> match=1 (imaplen=76)
> [    0.076096] Info: [libkvmpci] pci_ecam.c @ 370  :  -> imaplen=70
> [    0.076193] Info: [libkvmpci] pci_ecam.c @ 388  :  -> new parent: 0x175cOF
> [    0.076313] Info: [libkvmpci] pci_ecam.c @ 289  :  -> got it !
> [    0.076417] Info: [libkvmpci] pci_bus_arm64.c @ 100  : pci dev base(0x3eff0040) irq(37)
> [    0.076547] Info: [libkvmvirtio] virtio_pci.c @ 379  : Added virtio-pci device 1009
> [    0.076668] Info: [libkvmvirtio] virtio_pci.c @ 381  : Added virtio-pci subsystem_device_id 0009
> [    0.076885] Info: [libkvmvirtio] virtio_bus.c @ 129  : Virtio device 0x7ffc3010 initialized
> [    0.077322] CRIT: [libkvmplat] traps.c @ 67   : Unikraft: EL1 sync trap caught
> [    0.077468] CRIT: [libkvmplat] traps.c @ 39   : Unikraft: Dump registers:
> [    0.077598] CRIT: [libkvmplat] traps.c @ 40   : SP       : 0x00000000402cfce0
> ESR_EL1  : 0x0000000096000010
> ELR_EL1  : 0x0000000040106a88
> LR (x30) : 0x000000004010a13c
> PSTATE   : 0x0000000020000345
> FAR_EL1  : 0x000000003eff0060
> x00 ~ x03: 0x000000003eff0060 0x000000003eff0056 0x000000007ffd0010 0x000000000000ff03
> [    0.078162] CRIT: [libkvmplat] traps.c @ 50   : x04 ~ x07: 0x00000000000000ff 0xffffffffc100ffaa 0x000000000000ff03 0x00000000402cfe00
> [    0.078363] CRIT: [libkvmplat] traps.c @ 50   : x08 ~ x11: 0x00000000012dfdaa 0x000000003effff59 0x0000000000000000 0x0000000000000016
> [    0.078556] CRIT: [libkvmplat] traps.c @ 50   : x12 ~ x15: 0x000000003eff0040 0x00000000402dfd10 0x0000000000000000 0x0000000000000000
> [    0.078752] CRIT: [libkvmplat] traps.c @ 50   : x16 ~ x19: 0x000000000000000a 0x0000000000000000 0x0000000000000000 0x000000007ffc4010
> [    0.078945] CRIT: [libkvmplat] traps.c @ 50   : x20 ~ x23: 0x0000000079000001 0x000000004026d000 0x0000000000000001 0x0000000000000001
> [    0.079143] CRIT: [libkvmplat] traps.c @ 50   : x24 ~ x27: 0x000000004023e000 0x000000004023e000 0x0000000040257168 0x0000020000000000
> [    0.079356] CRIT: [libkvmplat] traps.c @ 53   : x28 ~ x29: 0x000000004023e000 0x00000000402dfd10
> [    0.079513] Info: [libkvmplat] shutdown.c @ 35   : Unikraft halted

I never saw this error in my local test env. Could you please share your

qemu command line ?

> 5. I've tested the series against nginx: it inits fine, and I can ping the network stack, but nginx itself doesn't reply to HTTP/wget requests, not sure why...please let me know if you'd like to replicate this.

Could you also give me some instructions about how to

setup the nginx. In my local test, I used a remote browser (firefox) to get the

webpage in unikraft httpreply app.

---
Cheers,
Justin (Jia He)



From minios-devel-bounces@lists.xenproject.org Thu May 14 07:16:58 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 14 May 2020 07:16:58 +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 1jZ86z-00070C-7N; Thu, 14 May 2020 07:16:57 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=dSID=64=gmail.com=jiakernel2@srs-us1.protection.inumbo.net>)
 id 1jZ86y-000703-Aw
 for minios-devel@lists.xenproject.org; Thu, 14 May 2020 07:16:56 +0000
X-Inumbo-ID: e3fdcc5e-95b2-11ea-ae69-bc764e2007e4
Received: from mail-pg1-x543.google.com (unknown [2607:f8b0:4864:20::543])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e3fdcc5e-95b2-11ea-ae69-bc764e2007e4;
 Thu, 14 May 2020 07:16:55 +0000 (UTC)
Received: by mail-pg1-x543.google.com with SMTP id t11so900608pgg.2
 for <minios-devel@lists.xenproject.org>; Thu, 14 May 2020 00:16:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-transfer-encoding;
 bh=LMcLFYDsDz/7UQdNGj2s8siA+6fCHnDhhFTeHnDXbcE=;
 b=Zk4bteCZ24/a8h6biLCYW+4tGJLjncwp9tpOE6h5zOh9enrwsACePbtzuk3irSl/eR
 umV5owth1hZj1CWizv4KK0UJMuEX8jjO6waCrYZkgd99+YIgfGdU6p1p7RxRQpUaJuaS
 wkLaFP3sZmSrzRZ/FNn3j1cgMubehFC0sA/bBakea8j4YHwYBKkeiskBZKXVyBu2JXky
 rzU+qTp1/F0RDZrbm+lxcRpkmNIXlv9X1S6dYJmw8SvvBzinIQ+a/N3+dUsER4uCAwia
 WwczotD/bAYcl5iVBRmW8NjDZv6Q978r2jw6yMCrMW/a1nglSFvG4j5YWcl19mSa7lxg
 qdvA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:subject:to:cc:references:from:message-id:date
 :user-agent:mime-version:in-reply-to:content-transfer-encoding;
 bh=LMcLFYDsDz/7UQdNGj2s8siA+6fCHnDhhFTeHnDXbcE=;
 b=QYEAT+TYYfNIA9E3Lm3owUfwvQ1Ru9y46VcaVBtpVt5hqkyQ0FPmvfzP7swsTi4qwF
 YlacLXiZfadxHTIEfut9+CFsxoR4/wES7mpd4idOuSVfZy/FuLzWBimqPkBDzxQEap1j
 +OCsksnwH0llGfdh+1A0it5a2Hk2ygRYZYXBNprVZDQWScJZHoTQ3yeiht6fo1RNi6cy
 Q8pnxcZTgt5Du4TLz4xbqNe8zaU+J/Hdsb5sAOTkquOtvzbryB2wqpx7Uqk8y979yea8
 gd2UVFrDE3ezBTqapKbVRTVwCI3f/hRNDNfZkZ8AYaMQg7Fg/6EEqHI8XD+Cv+lOwZjt
 32/w==
X-Gm-Message-State: AOAM533wW99EQkT3ZeReeqXu9eAutAfwlNR//sfIcX0xJVGCuPiFv3K/
 f2kJ1Rb6Xq3Z80XgwppA+dY=
X-Google-Smtp-Source: ABdhPJxdt6PCRO3VlWmipc6ICv/lSWwr1TCcHXmNSOAdTybM1cjQ89ps0i2uhMm4A8GlM/8Y/QTB5w==
X-Received: by 2002:a63:de49:: with SMTP id y9mr2764995pgi.435.1589440614428; 
 Thu, 14 May 2020 00:16:54 -0700 (PDT)
Received: from [0.0.0.0] ([45.76.223.48])
 by smtp.gmail.com with ESMTPSA id c84sm1537193pfb.153.2020.05.14.00.16.51
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 14 May 2020 00:16:53 -0700 (PDT)
Subject: Re: [Minios-devel] [UNIKRAFT PATCH RFC 00/23] Impelment virtio_mmio
 and pci ecam controller for arm64 kvm plat
To: Felipe Huici <Felipe.Huici@neclab.eu>, Jia He <Justin.He@arm.com>,
 "minios-devel@lists.xenproject.org" <minios-devel@lists.xenproject.org>
References: <20200306045035.45387-1-justin.he@arm.com>
 <748393D5-263B-4288-AB00-EA76B27E104A@neclab.eu>
From: Jia He <jiakernel2@gmail.com>
Message-ID: <b2d8551e-0c59-789e-c3c6-5c8b98d7ab0f@gmail.com>
Date: Thu, 14 May 2020 15:16:48 +0800
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <748393D5-263B-4288-AB00-EA76B27E104A@neclab.eu>
Content-Type: text/plain; charset=utf-8; format=flowed
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>
Cc: Kaly Xin <Kaly.Xin@arm.com>, Simon Kuenzer <simon.kuenzer@neclab.eu>,
 "nd@arm.com" <nd@arm.com>, Julien Grall <julien.grall@xen.org>,
 Sharan Santhanam <Sharan.Santhanam@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi Felipe

For your mentioned crashing issue, it was caused by missing important memory 
barrier.

It can be fixed by below patch(with newlib), I will figure out the graceful way 
to add

the mb.

--- a/plat/drivers/include/virtio/virtqueue.h
+++ b/plat/drivers/include/virtio/virtqueue.h
@@ -285,6 +285,7 @@ static inline void virtqueue_host_notify(struct virtqueue *vq)

         if (vq->vq_notify_host && virtqueue_notify_enabled(vq)) {
                 uk_pr_debug("notify queue %d\n", vq->queue_id);
+               dmb(oshst);
                 vq->vq_notify_host(vq->vdev, vq->queue_id);
         }
  }

I will continue to setup the nginx env.

---
Cheers,
Justin (Jia He)


On 2020/3/13 18:00, Felipe Huici wrote:
> Hi Justin,
>
> Thanks so much for the series, it's great to have networking going on arm64! I've tested it against http reply and it works fine. However, I have a number of issues with the series:
>
> 1. It doesn't build against newlib, which precludes running a large set of applications (e.g., Redis, nginx, sqlite, etc.). The fix here is simple:
>
> diff --git a/lib/fdt/fdt_addresses.c b/lib/fdt/fdt_addresses.c
> index b362b41..30c7ff5 100644
> --- a/lib/fdt/fdt_addresses.c
> +++ b/lib/fdt/fdt_addresses.c
> @@ -60,7 +60,7 @@
>
>   int fdt_address_cells(const void *fdt, int nodeoffset)
>   {
> -       __u32 cells;
> +       uint32_t cells;
>          int parent;
>          int off = nodeoffset;
>          int *prop;
> @@ -81,7 +81,7 @@ int fdt_address_cells(const void *fdt, int nodeoffset)
>
>   int fdt_size_cells(const void *fdt, int nodeoffset)
>   {
> -       __u32 cells;
> +       uint32_t cells;
>          int parent;
>          int off = nodeoffset;
>          int *prop;
>
> 2. I get a large number of (spurious?) error messages such as:
>
> [    0.036700] ERR:  [libkvmpf] platform_bus.c @ 180  : Platform Failed to initialize device driver, ret(-19)
>
> Things work despite these, should these really be errors?
>
> 3. There's a large number of compilation warnings (too many to list here)
>
> 4. When setting ukdebug's Kernel message level to "Show all types of messages" I get a register dump during boot:
>
> [    0.073966] Info: [libkvmpci] pci_ecam.c @ 370  :  -> imaplen=90
> [    0.074064] Info: [libkvmpci] pci_ecam.c @ 325  :  -> match=0 (imaplen=86)
> [    0.075033] Info: [libkvmpci] pci_ecam.c @ 370  :  -> imaplen=80
> [    0.075131] Info: [libkvmpci] pci_ecam.c @ 325  :  -> match=1 (imaplen=76)
> [    0.076096] Info: [libkvmpci] pci_ecam.c @ 370  :  -> imaplen=70
> [    0.076193] Info: [libkvmpci] pci_ecam.c @ 388  :  -> new parent: 0x175cOF
> [    0.076313] Info: [libkvmpci] pci_ecam.c @ 289  :  -> got it !
> [    0.076417] Info: [libkvmpci] pci_bus_arm64.c @ 100  : pci dev base(0x3eff0040) irq(37)
> [    0.076547] Info: [libkvmvirtio] virtio_pci.c @ 379  : Added virtio-pci device 1009
> [    0.076668] Info: [libkvmvirtio] virtio_pci.c @ 381  : Added virtio-pci subsystem_device_id 0009
> [    0.076885] Info: [libkvmvirtio] virtio_bus.c @ 129  : Virtio device 0x7ffc3010 initialized
> [    0.077322] CRIT: [libkvmplat] traps.c @ 67   : Unikraft: EL1 sync trap caught
> [    0.077468] CRIT: [libkvmplat] traps.c @ 39   : Unikraft: Dump registers:
> [    0.077598] CRIT: [libkvmplat] traps.c @ 40   : SP       : 0x00000000402cfce0
> ESR_EL1  : 0x0000000096000010
> ELR_EL1  : 0x0000000040106a88
> LR (x30) : 0x000000004010a13c
> PSTATE   : 0x0000000020000345
> FAR_EL1  : 0x000000003eff0060
> x00 ~ x03: 0x000000003eff0060 0x000000003eff0056 0x000000007ffd0010 0x000000000000ff03
> [    0.078162] CRIT: [libkvmplat] traps.c @ 50   : x04 ~ x07: 0x00000000000000ff 0xffffffffc100ffaa 0x000000000000ff03 0x00000000402cfe00
> [    0.078363] CRIT: [libkvmplat] traps.c @ 50   : x08 ~ x11: 0x00000000012dfdaa 0x000000003effff59 0x0000000000000000 0x0000000000000016
> [    0.078556] CRIT: [libkvmplat] traps.c @ 50   : x12 ~ x15: 0x000000003eff0040 0x00000000402dfd10 0x0000000000000000 0x0000000000000000
> [    0.078752] CRIT: [libkvmplat] traps.c @ 50   : x16 ~ x19: 0x000000000000000a 0x0000000000000000 0x0000000000000000 0x000000007ffc4010
> [    0.078945] CRIT: [libkvmplat] traps.c @ 50   : x20 ~ x23: 0x0000000079000001 0x000000004026d000 0x0000000000000001 0x0000000000000001
> [    0.079143] CRIT: [libkvmplat] traps.c @ 50   : x24 ~ x27: 0x000000004023e000 0x000000004023e000 0x0000000040257168 0x0000020000000000
> [    0.079356] CRIT: [libkvmplat] traps.c @ 53   : x28 ~ x29: 0x000000004023e000 0x00000000402dfd10
> [    0.079513] Info: [libkvmplat] shutdown.c @ 35   : Unikraft halted
>
> 5. I've tested the series against nginx: it inits fine, and I can ping the network stack, but nginx itself doesn't reply to HTTP/wget requests, not sure why...please let me know if you'd like to replicate this.
>
> Thanks,
>
> -- Felipe
>
> ﻿On 06.03.20, 05:50, "Jia He" <Justin.He@arm.com> wrote:
>
>      To support virtio-* family device, we have 2 choices (virtio mmio, virtio pci)
>      on arm64 kvm plat. This patch series enable the support of virtio mmio. virtio
>      pci needs pci controller ECAM mode in arm64 Unikraft.
>      
>      Previously, I proposed a separated series at [1], Julien had given some
>      comments including using fdt_get_address and refining the platform device
>      probing sequence. This series address them, but prevent changing too much
>      in original virtio mmio series.
>      
>      Patch 1-5 implement the platform bus and virtio mmio skeleton.
>      Patch 8-9 implement the pci ecam skeleton
>      Patch 10-12 introduce the new probing interface for virtio mmio and pci
>            on arm.
>      Patch 7,13-16 lib/fdt or ofw/fdt changes
>      Patch 17-18 split the arch specific pci bus codes into different directory
>      Others are bug fixing or building system changes.
>      
>      I set it as "RFC" since I haven't resolved all the compilation warnings or
>      checkpatch issues. Even single patch might not compilable. But I tested
>      the whole series, it works fine in both virtio mmio and virtio pci for
>      net device. The test case is a simple httpreply app.
>      
>      test qemu cmdline:
>      - for virtio mmio
>      -device virtio-net-device,id=net1,netdev=hostnet1,mac=52:54:00:09:a4:38
>      - for virtio pci
>      -device virtio-net-pci,id=net0,netdev=hostnet0,mac=52:54:00:09:a4:31,disable-modern=on
>      
>      Jia He (23):
>        plat/virtio: Introduce several helpers for virtio ring
>        plat/platform: Introduce new platform bus
>        plat/virtio: Support virtio_cread/cwrite on arm64
>        plat/virtio: Add new virtio_mmio device/driver on arm64
>        build: Enable the platform bus and virtio_mmio device on arm64
>        plat/kvm: arm64: Fix arm64 memory layout for pcie ecam
>        plat/ofw: Export fdt_find_irq_parent_offset
>        plat/pci_ecam: Introduce pci/pci_ecam.h
>        plat/pci_ecam: Introduce pci ecam skeleton
>        lib/ukbus: Adjust default bus register priority
>        plat/platform_bus: Add probe/match nterface for platform devices
>        plat/virtio_mmio: Implement platform probe for virtio_mmio
>        plat/ofw: Support completed ranges mapping
>        lib/fdt: Fix fdt_address_cell and fdt_size_cell
>        plat/ofw: add fdt_node_offset_idx_by_compatible_list
>        plat/ofw: Add fdt_prop_read_bool
>        plat/pci_bus: Split specific code into arch directory
>        plat/pci_bus: arm64: Implement arch specific add/probe interfaces on
>          arm64
>        build: make KVM_PCI default enable on arm64
>        plat/pci_bus: change the type of pci_device.base from u16 to unsigned
>          long
>        build: Enable pci library on arm64
>        plat/virtio: Fix virtio net device mac negotiation
>        plat/virtio: Change the type of irq,base from u16 to u64 for arm64
>      
>       lib/fdt/exportsyms.uk                       |   1 +
>       lib/fdt/fdt_addresses.c                     |  57 +-
>       lib/ukbus/include/uk/bus.h                  |  16 +-
>       plat/common/arm/pci_bus_arm64.c             | 204 +++++++
>       plat/common/include/arm/arm64/cpu_defs.h    |   3 +
>       plat/common/include/pci/pci_bus.h           | 105 +++-
>       plat/common/include/pci/pci_ecam.h          | 101 ++++
>       plat/common/include/platform_bus.h          | 116 ++++
>       plat/common/pci_bus.c                       | 167 +-----
>       plat/common/pci_ecam.c                      | 524 ++++++++++++++++++
>       plat/common/platform_bus.c                  | 238 ++++++++
>       plat/common/x86/pci_bus_x86.c               | 174 ++++++
>       plat/drivers/include/ofw/fdt.h              |  63 +++
>       plat/drivers/include/virtio/virtio_config.h |  63 ++-
>       plat/drivers/include/virtio/virtio_mmio.h   | 137 +++++
>       plat/drivers/include/virtio/virtqueue.h     |  33 ++
>       plat/drivers/ofw/fdt.c                      |  81 ++-
>       plat/drivers/virtio/virtio_mmio.c           | 567 ++++++++++++++++++++
>       plat/drivers/virtio/virtio_net.c            |  12 +-
>       plat/drivers/virtio/virtio_pci.c            |   6 +-
>       plat/drivers/virtio/virtio_ring.c           |  32 ++
>       plat/kvm/Config.uk                          |  14 +-
>       plat/kvm/Makefile.uk                        |  29 +-
>       plat/kvm/arm/pagetable64.S                  |  22 +-
>       24 files changed, 2537 insertions(+), 228 deletions(-)
>       create mode 100644 plat/common/arm/pci_bus_arm64.c
>       create mode 100644 plat/common/include/pci/pci_ecam.h
>       create mode 100644 plat/common/include/platform_bus.h
>       create mode 100644 plat/common/pci_ecam.c
>       create mode 100644 plat/common/platform_bus.c
>       create mode 100644 plat/common/x86/pci_bus_x86.c
>       create mode 100644 plat/drivers/include/virtio/virtio_mmio.h
>       create mode 100644 plat/drivers/virtio/virtio_mmio.c
>      
>      --
>      2.17.1
>      
>      
>
> _______________________________________________
> Minios-devel mailing list
> Minios-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/minios-devel



From minios-devel-bounces@lists.xenproject.org Thu May 14 13:06:58 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 14 May 2020 13:06:58 +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 1jZDZg-0000WQ-Aw; Thu, 14 May 2020 13:06:56 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=0xww=64=upb.ro=vlad_andrei.badoiu@srs-us1.protection.inumbo.net>)
 id 1jZDZe-0000WG-LX
 for minios-devel@lists.xen.org; Thu, 14 May 2020 13:06:55 +0000
X-Inumbo-ID: c60010a0-95e3-11ea-ae69-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.210])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c60010a0-95e3-11ea-ae69-bc764e2007e4;
 Thu, 14 May 2020 13:06:50 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id A0AD1B56232A;
 Thu, 14 May 2020 16:06:49 +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 l2_-bvy7Ra5b; Thu, 14 May 2020 16:06:47 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 8C64AB56261F;
 Thu, 14 May 2020 16:06:47 +0300 (EEST)
DKIM-Filter: OpenDKIM Filter v2.10.3 mx.upb.ro 8C64AB56261F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=upb.ro;
 s=96342B8A-77E4-11E5-BA93-D93D0963A2DF; t=1589461607;
 bh=zwgf3TYl6vyeYHGttcdWk5tERWdVTKBJHu3ekWkvtWw=;
 h=From:To:Date:Message-Id:MIME-Version;
 b=bsyQRdMnFN5rxlB5VW6DURwfo399h1QNJjrG/iPlF55XaCgjNpaQnKgkxdOc9LeoO
 89rTRpKHGDDAVEmRZfaeBCuzFUdKprpxcNnMVO2jzGhp94EL6bcGk7uYBnVOeiFv7T
 262JjoPRJXn8UxaNZAI9CRAJIjSqw0Etcgj3/Uos=
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 P4spAyQE1qHT; Thu, 14 May 2020 16:06:47 +0300 (EEST)
Received: from localhost.localdomain (unknown [188.27.169.187])
 by mx.upb.ro (Postfix) with ESMTPSA id 5664BB56232A;
 Thu, 14 May 2020 16:06:47 +0300 (EEST)
From: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 1/1] Add in6addr_loopback
Date: Thu, 14 May 2020 16:06:41 +0300
Message-Id: <20200514130641.12330-1-vlad_andrei.badoiu@upb.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>
Cc: felipe.huici@neclab.eu, Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Bind9 uses the in6addr_loopback symbol. We add this
symbol in a separate c file, in6addr_loopback.c.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
---
 Makefile.uk          | 1 +
 in6addr_loopback.c   | 3 +++
 include/netinet/in.h | 2 ++
 3 files changed, 6 insertions(+)
 create mode 100644 in6addr_loopback.c

diff --git a/Makefile.uk b/Makefile.uk
index d3c6c9c..be05dc5 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -128,6 +128,7 @@ LIBLWIP_SRCS-$(CONFIG_LWIP_SOCKET) +=3D $(LIBLWIP_EXT=
RACTED)/api/sockets.c
 LIBLWIP_SRCS-y +=3D $(LIBLWIP_EXTRACTED)/netif/ethernet.c
 LIBLWIP_SRCS-$(CONFIG_LWIP_UKNETDEV) +=3D $(LIBLWIP_BASE)/netbuf.c|unikr=
aft
 LIBLWIP_SRCS-$(CONFIG_LWIP_UKNETDEV) +=3D $(LIBLWIP_BASE)/uknetdev.c|uni=
kraft
+LIBLWIP_SRCS-$(CONFIG_LWIP_IPV6) +=3D $(LIBLWIP_BASE)/in6addr_loopback.c=
|unikraft
=20
 ########################################################################=
########
 # IPv4
diff --git a/in6addr_loopback.c b/in6addr_loopback.c
new file mode 100644
index 0000000..b96005b
--- /dev/null
+++ b/in6addr_loopback.c
@@ -0,0 +1,3 @@
+#include <netinet/in.h>
+
+const struct in6_addr in6addr_loopback =3D IN6ADDR_LOOPBACK_INIT;
diff --git a/include/netinet/in.h b/include/netinet/in.h
index 00d7fd4..aea7490 100644
--- a/include/netinet/in.h
+++ b/include/netinet/in.h
@@ -41,6 +41,8 @@ struct group_source_req {
=20
=20
 #ifdef CONFIG_LWIP_IPV6
+extern const struct in6_addr in6addr_any, in6addr_loopback;
+
 #define IPV6_ADDRFORM           1
 #define IPV6_2292PKTINFO        2
 #define IPV6_2292HOPOPTS        3
--=20
2.20.1



From minios-devel-bounces@lists.xenproject.org Thu May 14 18:59:31 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 14 May 2020 18:59:31 +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 1jZJ4p-0003dw-2y; Thu, 14 May 2020 18:59:27 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=9WCJ=64=gmail.com=radunicolau102@srs-us1.protection.inumbo.net>)
 id 1jZJ4n-0003dr-Fq
 for minios-devel@lists.xen.org; Thu, 14 May 2020 18:59:25 +0000
X-Inumbo-ID: 06da9ff6-9615-11ea-9887-bc764e2007e4
Received: from mail-oo1-xc42.google.com (unknown [2607:f8b0:4864:20::c42])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 06da9ff6-9615-11ea-9887-bc764e2007e4;
 Thu, 14 May 2020 18:59:24 +0000 (UTC)
Received: by mail-oo1-xc42.google.com with SMTP id g22so946131oop.13
 for <minios-devel@lists.xen.org>; Thu, 14 May 2020 11:59:24 -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=LlZ8LTLHvLuGbeGhRoP9g5t6MWpoZ2ODFHiqmQqaHug=;
 b=PxjXwtYR2js8tjruBBp1lup+0bF45x6jWVEKu7sP6WFfoX047Avh5OG5zZOoSdBMSz
 1Qfob+QQYlb94Sgs+fQeZTPrIk647KsrE7NDWip49m1w5R0wQsD2w3vywFCt4VNAndqf
 tplLaiybipOiuT/rHtedngLV2vOUjYBwLdkZW7Eqiw16eSEe6Zs2z+75e6slJSDvpE5g
 IpbEEwlrraalg3E7sX6tKV1vuYrMnDixZMZZISrzNHExc9ebBSlPrBuRO6WDOLq8a1bU
 il4KWA0aPtjYsKDnX5EKmSQFwrvfUD9S6sVFEEsVxFd/iVOIDffqsOqyYNUImdp/QRpa
 7pNg==
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=LlZ8LTLHvLuGbeGhRoP9g5t6MWpoZ2ODFHiqmQqaHug=;
 b=Y83ObIUkAYvsiytdbxSUHAF/KVlW9pjxPW2a+tGuTBE+TPmSvVn5x3RyZoLXjhqhn6
 XRefpnKo28oYE3MGTQwTDHEhkXw3XhXQ1HfmKS7PB0NkU+i3dvglEvKGYCX4b8c916oR
 6iitnJRSFscsl2S78mXibS5DELJP4rObwmEwSbmdFuOAMYaxu2kA2c09U49rSJCVzZ0T
 LBy7eIm0NGGTZLlueXAgXfwJiadKxvxIo9jvXw40G4287Wc1lKSddkszk5+NX7hgOlza
 V7ve5cPbkGRW2mm3KipPz+Ia81HFnxjGpR5b7P10fLxSbJHPf/w+1v4puuLr9BIiUx42
 NUug==
X-Gm-Message-State: AOAM530pLGvwirLq+LOh30XQ3eg6BtWYBzSVsqN3EcctgYbbQIcYHnZ9
 MwjpvZ5WdGcexe+lYi4DAcs0hTh8U59qdvHJTJzEgvWa
X-Google-Smtp-Source: ABdhPJyHVpzkxnUB915X9ZAN9Vip8irvrzPxDOYKfV/cxogY/qOd5gq4u+jV43Qe6/yygiHrsWleh2g8AbmRPzt7nMI=
X-Received: by 2002:a4a:9806:: with SMTP id y6mr4760929ooi.57.1589482763825;
 Thu, 14 May 2020 11:59:23 -0700 (PDT)
MIME-Version: 1.0
References: <20200303150800.30150-1-costin.lupu@cs.pub.ro>
In-Reply-To: <20200303150800.30150-1-costin.lupu@cs.pub.ro>
From: Radu Nicolau <radunicolau102@gmail.com>
Date: Thu, 14 May 2020 21:59:12 +0300
Message-ID: <CAPGq5zb6sHQFHTg8H7K=N09mbrDjdWE_tpe+dk0CA7YWbLDFnQ@mail.gmail.com>
Subject: Re: [Minios-devel] [UNIKRAFT PATCH] plat/xen: Revisit configuration
 options for PV
To: Costin Lupu <costin.lupu@cs.pub.ro>
Content-Type: multipart/alternative; boundary="00000000000083b4c305a5a04b41"
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>
Cc: minios-devel@lists.xen.org
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

--00000000000083b4c305a5a04b41
Content-Type: text/plain; charset="UTF-8"

Reviewed-by: Radu Nicolau <radunicolau102@gmail.com>


On Tue, Mar 3, 2020 at 5:08 PM Costin Lupu <costin.lupu@cs.pub.ro> wrote:

> This patch tries to fix a few things about the PV configuration:
> * First off, we introduce the hidden XEN_PV option.
> * Next, XEN_PV_BUILD_P2M is used only for PV images on x86_64.
> * Grants might be used for ARM as well (at least that's what minios does).
> But for PV images we enable them by default because we cannot do much
> without it.
> * Xenbus communication needs grants support, so it depends on them. We also
> enable it by default for PV for the same reason we enable grants.
> * In case of Xenbus drivers, it's enough to depend on Xenbus support.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> ---
>  plat/xen/Config.uk | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/plat/xen/Config.uk b/plat/xen/Config.uk
> index 366ab344..364c9528 100644
> --- a/plat/xen/Config.uk
> +++ b/plat/xen/Config.uk
> @@ -19,6 +19,11 @@ config XEN_HVMLITE
>         default n if (ARCH_X86_64 || ARCH_X86_32)
>         default y
>
> +config XEN_PV
> +       bool
> +       default n if XEN_HVMLITE
> +       default y
> +
>  menu "Console Options"
>
>  config XEN_KERNEL_HV_CONSOLE
> @@ -52,6 +57,7 @@ endmenu
>
>  config XEN_PV_BUILD_P2M
>         bool "Create p2m table"
> +       depends on (ARCH_X86_64 && XEN_PV)
>         default n
>         help
>                 Create and initialize physical to machine (p2m) table on a
> PV
> @@ -59,7 +65,8 @@ config XEN_PV_BUILD_P2M
>
>  config XEN_GNTTAB
>         bool "Grant table support"
> -       default y
> +       default y if XEN_PV
> +       default n
>         depends on (ARCH_X86_64)
>         select LIBUKALLOC
>         select LIBUKLOCK
> @@ -70,8 +77,9 @@ config XEN_GNTTAB
>
>  config XEN_XENBUS
>         bool "Xenbus/XenStore driver"
> +       default y if XEN_PV
>         default n
> -       depends on (ARCH_X86_64)
> +       depends on XEN_GNTTAB
>         select LIBUKALLOC
>         select LIBUKSCHED
>         select LIBUKBUS
> @@ -80,8 +88,7 @@ config XEN_XENBUS
>                 XenStore communication API for Xen drivers
>
>  menu "Xenbus Drivers"
> -        depends on XEN_XENBUS
> -        depends on XEN_GNTTAB
> +       depends on XEN_XENBUS
>
>  menuconfig XEN_BLKFRONT
>         bool "Xenbus Blkfront Driver"
> --
> 2.20.1
>
>
> _______________________________________________
> Minios-devel mailing list
> Minios-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/minios-devel

--00000000000083b4c305a5a04b41
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Reviewed-by: Radu Nicolau &lt;<a href=3D"mailto:radunicola=
u102@gmail.com">radunicolau102@gmail.com</a>&gt;<br><div><br></div></div><b=
r><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, =
Mar 3, 2020 at 5:08 PM Costin Lupu &lt;<a href=3D"mailto:costin.lupu@cs.pub=
.ro">costin.lupu@cs.pub.ro</a>&gt; wrote:<br></div><blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,2=
04,204);padding-left:1ex">This patch tries to fix a few things about the PV=
 configuration:<br>
* First off, we introduce the hidden XEN_PV option.<br>
* Next, XEN_PV_BUILD_P2M is used only for PV images on x86_64.<br>
* Grants might be used for ARM as well (at least that&#39;s what minios doe=
s).<br>
But for PV images we enable them by default because we cannot do much<br>
without it.<br>
* Xenbus communication needs grants support, so it depends on them. We also=
<br>
enable it by default for PV for the same reason we enable grants.<br>
* In case of Xenbus drivers, it&#39;s enough to depend on Xenbus support.<b=
r>
<br>
Signed-off-by: Costin Lupu &lt;<a href=3D"mailto:costin.lupu@cs.pub.ro" tar=
get=3D"_blank">costin.lupu@cs.pub.ro</a>&gt;<br>
---<br>
=C2=A0plat/xen/Config.uk | 15 +++++++++++----<br>
=C2=A01 file changed, 11 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/plat/xen/Config.uk b/plat/xen/Config.uk<br>
index 366ab344..364c9528 100644<br>
--- a/plat/xen/Config.uk<br>
+++ b/plat/xen/Config.uk<br>
@@ -19,6 +19,11 @@ config XEN_HVMLITE<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 default n if (ARCH_X86_64 || ARCH_X86_32)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 default y<br>
<br>
+config XEN_PV<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0bool<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0default n if XEN_HVMLITE<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0default y<br>
+<br>
=C2=A0menu &quot;Console Options&quot;<br>
<br>
=C2=A0config XEN_KERNEL_HV_CONSOLE<br>
@@ -52,6 +57,7 @@ endmenu<br>
<br>
=C2=A0config XEN_PV_BUILD_P2M<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool &quot;Create p2m table&quot;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0depends on (ARCH_X86_64 &amp;&amp; XEN_PV)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 default n<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 help<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Create and initiali=
ze physical to machine (p2m) table on a PV<br>
@@ -59,7 +65,8 @@ config XEN_PV_BUILD_P2M<br>
<br>
=C2=A0config XEN_GNTTAB<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool &quot;Grant table support&quot;<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0default y<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0default y if XEN_PV<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0default n<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 depends on (ARCH_X86_64)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 select LIBUKALLOC<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 select LIBUKLOCK<br>
@@ -70,8 +77,9 @@ config XEN_GNTTAB<br>
<br>
=C2=A0config XEN_XENBUS<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool &quot;Xenbus/XenStore driver&quot;<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0default y if XEN_PV<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 default n<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0depends on (ARCH_X86_64)<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0depends on XEN_GNTTAB<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 select LIBUKALLOC<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 select LIBUKSCHED<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 select LIBUKBUS<br>
@@ -80,8 +88,7 @@ config XEN_XENBUS<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 XenStore communicat=
ion API for Xen drivers<br>
<br>
=C2=A0menu &quot;Xenbus Drivers&quot;<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 depends on XEN_XENBUS<br>
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 depends on XEN_GNTTAB<br>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0depends on XEN_XENBUS<br>
<br>
=C2=A0menuconfig XEN_BLKFRONT<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bool &quot;Xenbus Blkfront Driver&quot;<br>
-- <br>
2.20.1<br>
<br>
<br>
_______________________________________________<br>
Minios-devel mailing list<br>
<a href=3D"mailto:Minios-devel@lists.xenproject.org" target=3D"_blank">Mini=
os-devel@lists.xenproject.org</a><br>
<a href=3D"https://lists.xenproject.org/mailman/listinfo/minios-devel" rel=
=3D"noreferrer" target=3D"_blank">https://lists.xenproject.org/mailman/list=
info/minios-devel</a></blockquote></div>

--00000000000083b4c305a5a04b41--


From minios-devel-bounces@lists.xenproject.org Fri May 15 05:53:51 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 15 May 2020 05:53:51 +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 1jZTI4-0004Mw-CA; Fri, 15 May 2020 05:53:48 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=8F1v=65=arm.com=jianyong.wu@srs-us1.protection.inumbo.net>)
 id 1jZTI4-0004Mr-48
 for minios-devel@lists.xenproject.org; Fri, 15 May 2020 05:53:48 +0000
X-Inumbo-ID: 7103ca50-9670-11ea-9887-bc764e2007e4
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTP
 id 7103ca50-9670-11ea-9887-bc764e2007e4;
 Fri, 15 May 2020 05:53:46 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 369001042;
 Thu, 14 May 2020 22:53:46 -0700 (PDT)
Received: from entos-d05.shanghai.arm.com (entos-d05.shanghai.arm.com
 [10.169.40.35])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9CDD53F305;
 Thu, 14 May 2020 22:53:44 -0700 (PDT)
From: Jianyong Wu <jianyong.wu@arm.com>
To: minios-devel@lists.xenproject.org, sharan.santhanam@neclab.eu,
 simon.kuenzer@neclab.eu
Subject: [PATCH] arm64: rewrite io r/w helper to avoid kvm crash.
Date: Fri, 15 May 2020 13:53:25 +0800
Message-Id: <20200515055325.50513-1-jianyong.wu@arm.com>
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>
Cc: jianyong.wu@arm.com, Justin.He@arm.com
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

For now, unikraft will crash on arm64 in kvm mode if it compiled using
optimize mode. Because compiler will choose post-index str intrs to
write device memory. Unluckily, arm64 virtualization extension does only
provides syndrome information for a limited subset of load/store
instructions, that means we can't use load/store with writeback addressing
mode to access mmio device.
To avoid the compiler do those optimization, io read/write helpers should
be rewitten by inline assembly with volatile constraint. After this,
unikraft can work fine on arm64.

Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
---
 plat/common/include/arm/arm64/cpu.h | 84 ++++++++++++++++++++---------
 1 file changed, 59 insertions(+), 25 deletions(-)

diff --git a/plat/common/include/arm/arm64/cpu.h b/plat/common/include/arm/arm64/cpu.h
index 93ad13b..994d2f2 100644
--- a/plat/common/include/arm/arm64/cpu.h
+++ b/plat/common/include/arm/arm64/cpu.h
@@ -41,31 +41,65 @@
 #include <uk/alloc.h>
 #include <uk/assert.h>
 
-/* Define macros to access IO registers */
-#define __IOREG_READ(bits) \
-static inline uint##bits##_t \
-	ioreg_read##bits(const volatile uint##bits##_t *addr) \
-		{ return *addr; }
-
-#define __IOREG_WRITE(bits) \
-static inline void \
-	ioreg_write##bits(volatile uint##bits##_t *addr, \
-						uint##bits##_t value) \
-		{ *addr = value; }
-
-
-#define __IOREG_READ_ALL() __IOREG_READ(8)  \
-			   __IOREG_READ(16) \
-			   __IOREG_READ(32) \
-			   __IOREG_READ(64) \
-
-#define __IOREG_WRITE_ALL()	__IOREG_WRITE(8)  \
-			   __IOREG_WRITE(16) \
-			   __IOREG_WRITE(32) \
-			   __IOREG_WRITE(64) \
-
-__IOREG_READ_ALL()
-__IOREG_WRITE_ALL()
+/*
+ * we should use inline assembly with volatile constrain to access IO
+ * registers to avoid compiler use load/store intrns of writeback
+ * addressing mode which will cause crash when running in kvm mode.
+ */
+static inline uint8_t ioreg_read8(const volatile uint8_t *address)
+{
+	uint8_t value;
+
+	asm volatile ("ldrb %w0, [%1]" : "=r"(value) : "r"(address));
+	return value;
+}
+
+static inline uint16_t ioreg_read16(const volatile uint16_t *address)
+{
+	uint16_t value;
+
+	asm volatile ("ldrh %w0, [%1]" : "=r"(value) : "r"(address));
+	return value;
+}
+
+static inline uint32_t ioreg_read32(const volatile uint32_t *address)
+{
+	uint32_t value;
+
+	asm volatile ("ldr %w0, [%1]" : "=r"(value) : "r"(address));
+	return value;
+}
+
+static inline uint64_t ioreg_read64(const volatile uint64_t *address)
+{
+	uint64_t value;
+
+	asm volatile ("ldr %0, [%1]" : "=r"(value) : "r"(address));
+	return value;
+}
+
+static inline void ioreg_write8(const volatile uint8_t *address, uint8_t value)
+{
+	asm volatile ("strb %w0, [%1]" : : "rZ"(value), "r"(address));
+}
+
+static inline void ioreg_write16(const volatile uint16_t *address,
+				 uint16_t value)
+{
+	asm volatile ("strh %w0, [%1]" : : "rZ"(value), "r"(address));
+}
+
+static inline void ioreg_write32(const volatile uint32_t *address,
+				 uint32_t value)
+{
+	asm volatile ("str %w0, [%1]" : : "rZ"(value), "r"(address));
+}
+
+static inline void ioreg_write64(const volatile uint64_t *address,
+				 uint64_t value)
+{
+	asm volatile ("str %0, [%1]" : : "rZ"(value), "r"(address));
+}
 
 static inline void _init_cpufeatures(void)
 {
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 15 11:52:14 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 15 May 2020 11:52:14 +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 1jZYss-0004UD-RU; Fri, 15 May 2020 11:52:10 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=L+Bk=65=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jZYsr-0004U8-3r
 for minios-devel@lists.xenproject.org; Fri, 15 May 2020 11:52:09 +0000
X-Inumbo-ID: 80f979d2-96a2-11ea-b9cf-bc764e2007e4
Received: from mail-wr1-x42b.google.com (unknown [2a00:1450:4864:20::42b])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 80f979d2-96a2-11ea-b9cf-bc764e2007e4;
 Fri, 15 May 2020 11:52:08 +0000 (UTC)
Received: by mail-wr1-x42b.google.com with SMTP id e16so3190068wra.7
 for <minios-devel@lists.xenproject.org>; Fri, 15 May 2020 04:52:08 -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=RVxCik4IcIMUCI7KsAwBeO8ONMs0sUu2lh6fMqzodzE=;
 b=UEBV+O295ketDFHze9rBnfx0kXnEoObEVgXp1C24bcaD3TTiDfI4kV5nqLkPnk7AWV
 hiW+0Pog9Ffg+7vBM6zVe89Li5OOHCUp5DutL6C3EzVjHVqNUeRka8etzTCznMynVBXB
 BpAckIYlQFPaws2YOWwnqrz0MWUkMU7qT+vs56kK1qzH4DhXvT+GHenB2G1KKcn5qpG0
 wF9rXgByT7VWhq2D8kQlzbzZw5GyQPVeMVXH3hWEsqKzjJa7nQFv8a6DXuuStIipDCv/
 1h4u/m+gYKBC1M9D5S2Lppy4kLx87OYG/f2KZz49V+cqYuDNpcN5ivVzB91VSr0+EHto
 lhWg==
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=RVxCik4IcIMUCI7KsAwBeO8ONMs0sUu2lh6fMqzodzE=;
 b=X7MULpMsVHRS6r+eKs1/65+i7HeRTvNvLusGBlBCYkdjN6h9LUB9Ais0N0dl20kdIX
 H+tHKvzwOv8WAqjDqXuI8f7nxn1EewHoMXD3MEAGglmXIHdWcnH7vfBoI9xxgCEPk9gh
 +eYb1jsQNT9rvrtMklP47jDLKUSubbPWLn/jjlJIUoSVOUqZHzh2Kkxvd9UCPTkizQjX
 GdY9yjv7cpjG+TUx7Ww0OVJndrRwLCn55x7ff4SIqCxNMipCpmKVwlCtyYG9cQ4qR7y1
 hvp0XkWpU7jpiLnErGkVC3yL3KvQvrzGDHzkDFe3fPGBQPI7d+tVWCqvBOyVrzuLWrcb
 AuZA==
X-Gm-Message-State: AOAM5326D61rHEHI0JyGOH8WndXJiSg6PLqacy6oMS8RqaU/aiDYkxwp
 hU/5dCADyFXX6gkL2nWp/+vRRfTneIk=
X-Google-Smtp-Source: ABdhPJzO2n7xsmraG1UYDLOgf7pOe1wOW7qAQj06o70yUmz3b0Dv+3xWKJjxzVglNJB7iVEwUExF9Q==
X-Received: by 2002:adf:9f48:: with SMTP id f8mr3947605wrg.228.1589543527376; 
 Fri, 15 May 2020 04:52:07 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:f09c:5b4e:eb51:5b98])
 by smtp.googlemail.com with ESMTPSA id m6sm3141228wrq.5.2020.05.15.04.52.05
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 15 May 2020 04:52:06 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/LIBTFLITE PATCH V3 0/4]
Date: Fri, 15 May 2020 14:51:56 +0300
Message-Id: <20200515115200.98471-1-murarugeorgec@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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Changes since v1 and v2:
* Improve Readme by adding dependencies and fs info
* Add main example
* Add patch for changing "zu" to "lu"
* Add all dependencies to the Config file

George Muraru (4):
  Library skeleton
  Add Makefile.uk
  Add main app if selected
  Add patches

-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Fri May 15 11:52:15 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 15 May 2020 11:52:15 +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 1jZYsx-0004Ua-Sw; Fri, 15 May 2020 11:52: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=L+Bk=65=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jZYsw-0004UK-0k
 for minios-devel@lists.xenproject.org; Fri, 15 May 2020 11:52:14 +0000
X-Inumbo-ID: 82799db4-96a2-11ea-b9cf-bc764e2007e4
Received: from mail-wr1-x42f.google.com (unknown [2a00:1450:4864:20::42f])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 82799db4-96a2-11ea-b9cf-bc764e2007e4;
 Fri, 15 May 2020 11:52:11 +0000 (UTC)
Received: by mail-wr1-x42f.google.com with SMTP id l11so3258061wru.0
 for <minios-devel@lists.xenproject.org>; Fri, 15 May 2020 04:52:11 -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=hsLcK1zkNDQP1bNWcftPXr7MF6Dp54kXi3r8u6GYPEc=;
 b=dJFHzRU7wdxUjEGEdwSSJ6C7Vj56VTnPu0Cj9KNl1GCafTPBy24qhP/UzbnxEu1/R8
 8AXDtaTCgjQY2Ql47RRImprABQajwnmPepNUGv4GbyeVWlwhYdAGU4tsZURUWZbAuuVx
 WmNtivDo368YuuV2Czj52kNv8BiYg0CoQOtNtwYYSBBr4ztnGioLBXFEioWXuPloNTi3
 ZGAabANvnk1if+7olGsp6TH2HBpcrYRbKEj8yojzO9SkTNEieAqyhhe5fjai5J/vNri9
 bwT6/fKrRghstYdrBk0qQaT2wfgfsWOLZnsbX3n5XVxZsTVdJK35lRLt2Z1zLn/UNR0T
 tuYw==
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=hsLcK1zkNDQP1bNWcftPXr7MF6Dp54kXi3r8u6GYPEc=;
 b=Op0F5VYXLJyqoKFjDic3lelEj1HJdBlblJ5y46aT+yQ17jd/Nk6sgvQ2DuxHlzO6IK
 gbvw97xk0Ptk7/ZXug+X/aoDQOfYvbJGBGdW3dGsfV6+GbzBYjz4FQzpzn//GZ09By1u
 dH7heCscfu9Og1wAVLfKVrH78qxA73YRY0j1FqaBQufFyopom6x1h9FH2FrJrcrJcA4l
 pNcH/OPG98KqY8X/NIoPIYrAexcJVmHUA7c56wss1lhMatvnz574xcTny6VbohbiWG34
 +PesGeBOluKtd9o7qmz+gt1CevzwyAyFOIwi0o8txKf7oG/Y0oT86/XfjqkpFQ4t27Af
 oiAA==
X-Gm-Message-State: AOAM530gdvLRc/94WkhZjo6DFxpqPhX8sHCfTuoRRkBLOH/swVaTMxNS
 vZ9mfkmoR3673lfa7mAmAdbAkaUMxKA=
X-Google-Smtp-Source: ABdhPJx4Izb/7Uzt+R2gl7yh5GrwSHFyJXbcTyyAaEXLZJ7gAHjCz7HT9bk3HkMZ8UrDaaJY9xHm1w==
X-Received: by 2002:adf:ed06:: with SMTP id a6mr3819973wro.8.1589543529776;
 Fri, 15 May 2020 04:52:09 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:f09c:5b4e:eb51:5b98])
 by smtp.googlemail.com with ESMTPSA id m6sm3141228wrq.5.2020.05.15.04.52.08
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 15 May 2020 04:52:09 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/LIBTFLITE PATCH 1/4] Library skeleton
Date: Fri, 15 May 2020 14:51:57 +0300
Message-Id: <20200515115200.98471-2-murarugeorgec@gmail.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20200515115200.98471-1-murarugeorgec@gmail.com>
References: <20200515115200.98471-1-murarugeorgec@gmail.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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: George Muraru <murarugeorgec@gmail.com>
---
 CONTRIBUTING.md |  4 ++++
 COPYING.md      | 38 ++++++++++++++++++++++++++++++++++
 Config.uk       | 50 ++++++++++++++++++++++++++++++++++++++++++++
 MAINTAINERS.md  | 10 +++++++++
 README.md       | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 157 insertions(+)
 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/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..fd1dc8e
--- /dev/null
+++ b/COPYING.md
@@ -0,0 +1,38 @@
+License
+=======
+
+Unikraft tensorflowlite wrappers
+----------------------------------
+
+This repository contains wrapper code to build tensorflowlite 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..8d483a2
--- /dev/null
+++ b/Config.uk
@@ -0,0 +1,50 @@
+menuconfig LIBTFLITE
+    bool "TensorFlowLite - tensorflow lite library"
+    select LIBCXX
+    select LIBNEWLIBC
+    select LIBPOSIX_SYSINFO
+    select LIBPTHREAD_EMBEDDED
+    select LIBCOMPILTER_RT
+    select LIBCOMPILER_RT_ATOMIC
+    select LIBEIGEN
+    select LIBFFT2D
+    select LIBFLATBUFFERS
+    select LIBGEMMLOWP
+    select LIBFARMHASH
+    select LIBUK9P
+    select LIB9PFS
+    select LIBDEVFS
+    select LIBDEVFS_AUTOMOUNT
+    select LIBVFSCORE_AUTOMOUNT_ROOTFS
+    select LIBUKLIBPARAM
+    default n
+
+if LIBTFLITE
+    choice LIBVFSCORE_ROOTFS
+    default LIBVFSCORE_ROOTFS_9PFS
+    endchoice
+endif
+
+if LIBTFLITE
+    config LIBTFLITE_EIGEN_DONT_ALIGN
+    bool "Do not align the buffers used by eigen library"
+    default y
+endif
+
+if LIBTFLITE
+    config LIBTFLITE_BUILD_WITH_RUY
+    bool "Matrix multiplication library"
+    default y
+endif
+
+if LIBTFLITE
+    config LIBTFLITE_BUILD_WITH_NNAPI
+    bool "Build with Neural Network API"
+    default n
+endif
+
+if LIBTFLITE
+    config LIBTFLITE_MAIN_FUNCTION
+	bool "Provide main function"
+	default y
+endif
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
new file mode 100644
index 0000000..f53ffe5
--- /dev/null
+++ b/MAINTAINERS.md
@@ -0,0 +1,10 @@
+Maintainers List
+================
+
+For notes on how to read this information, please refer to `MAINTAINERS.md` in
+the main Unikraft repository.
+
+	LIBGEMMLOWP-UNIKRAFT
+	M:	George Muraru <murarugeorgec@gmail.com>
+	L:	minios-devel@lists.xen.org
+	F: *
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..cc8cfda
--- /dev/null
+++ b/README.md
@@ -0,0 +1,55 @@
+TensorFlowLite for Unikraft
+=============================
+
+This is the port of tensorflowlite as external library
+Please refer to the `README.md` as well as the documentation in the `doc/`
+subdirectory of the main unikraft repository.
+
+## Build
+TensorFlowLite interpreter depends on the following libraries, that need to
+be added to `Makefile` in this order:
+
+* `pthreads`, e.g. `pthread-embedded`
+* `libcxx`
+* `libcxxabi`
+* `libc`, e.g. `newlib`
+* `libunwind`
+* `libcompilerrt`
+* `libgemmlowp`
+* `libflatbuffers`
+* `libfarmhash`
+* `libeigen`
+* `libfft2`
+
+## Root filesystem
+### Creating the filesystem
+TensorFlowLite needs a filesystem which should contain one or more *tflite*
+models. Therefore, the filesystem needs to be created before running the VM. 
+
+### Using the filesystem
+Mounting the filesystem is a transparent operation. All you have to do
+is to provide the right Qemu parameters in order for Unikraft to mount
+the filesystem.  We will use the 9pfs support for filesystems and for
+this you will need to use the following parameters:
+
+```bash
+-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
+```
+You should also use `vfs.rootdev=rootfs` (set by default) to specify the 9pfs mounting
+tag to Unikraft. To enable 9pfs, you'll need to select the following
+menu options, all under `Library Configuration` (this should be already done by the
+`tflite` config file):
+
+* `uk9p: 9p client`
+* `vfscore: VFS Core Interface`
+	  &rarr; `vfscore: Configuration`
+	  &rarr; `Automatically mount a root filesysytem`
+	  &rarr; `Default root filesystem`
+	  &rarr; `9PFS`
+
+## How to run
+Currently, `main.cpp` contains a minimal example for loading a *tflite* model and
+printing the interpreter state. The sample program will try to load the model from
+`mobilenet_v1_1.0_224.tflite` (this model and other models from the same family can
+be downloaded from [here](https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.md))
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Fri May 15 11:52:21 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 15 May 2020 11:52: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 1jZYt2-0004VR-Vb; Fri, 15 May 2020 11:52:20 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=L+Bk=65=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jZYt1-0004VF-0N
 for minios-devel@lists.xenproject.org; Fri, 15 May 2020 11:52:19 +0000
X-Inumbo-ID: 837967c6-96a2-11ea-ae69-bc764e2007e4
Received: from mail-wr1-x431.google.com (unknown [2a00:1450:4864:20::431])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 837967c6-96a2-11ea-ae69-bc764e2007e4;
 Fri, 15 May 2020 11:52:12 +0000 (UTC)
Received: by mail-wr1-x431.google.com with SMTP id i15so3157682wrx.10
 for <minios-devel@lists.xenproject.org>; Fri, 15 May 2020 04:52:12 -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=FCfoX1SKwypRLBLBymFz49ig12oRwE4MSEO1aT0pul0=;
 b=n6r3+DqyyUBmuVe4p9prbD5yvqaBbhxGZf9Q0CcYehLCz3syLIn/Rtzyjz9jy4jQF+
 RcKkk68INlo1lqeOUSDfYVPH/kWiTgtyM3PnTn6+vlN+KbJ2ujo0uGfsJ3Oe1rwTNgZZ
 39ywHXBqpO0aUC0a+zgWt1mAkgoSvmNzpIRAt1ZyLfv692fLGj9+5H2RqugHswVPhmCN
 8j/BVuwOwjkAdKzSscWQ8fHxpmzIIgBlpHL7RwlAhCjxKQLyYVABVl9Ka7VPGcR4lTvv
 xpku1PUrwXvQ5oujUhBaIcTsec2HUuSYFocXeCjGkLMbmKzpqhAPpITJCb7mj3N6J6Nq
 sXlg==
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=FCfoX1SKwypRLBLBymFz49ig12oRwE4MSEO1aT0pul0=;
 b=bggXDwTFW41zWigNsLZZR9Z3dussVXq0f5efH7dzzizyMZLKcCPS3Vu1o8F7WqKsW3
 vtCGK7JkZcQl/zdVtubv3B0uHoTjXhUizXPZb314KOp78O6yMmt//MF5Ct7AunYKmL4i
 gLAVOxdTF1rfEJLDi82n/tTRmVpo5WYcFJL46nLld/yaoBBeH+Pm9URjga99NQGjMwyr
 In9gxLtL/N6naCiF21HmbcaPewKBdkoTquHxsGd3esmgpw/GXWFKGhwXYGvCeEnOSZRe
 ymTNzyRB/dOFhxQFOCgYj7GStbbVLLdWBNY4Fw8VabHsICCa8vzaS0wILaQ3ilfMFX3U
 mY0Q==
X-Gm-Message-State: AOAM531n+IMn1+9BcAMHJmS5Exbxj1noiimekeSdUBBr8v0rF4kWCFzq
 hAQgN78c7JLVyzSfvYGexIPPALzjl5Q=
X-Google-Smtp-Source: ABdhPJyVk5LN7TErDpwuUKpwO09WSBd2F4aIa+hNpYSt1Zn13En1ieSefhWGnnV7mK+pnPEIn8QD0A==
X-Received: by 2002:adf:dc50:: with SMTP id m16mr3892912wrj.329.1589543531396; 
 Fri, 15 May 2020 04:52:11 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:f09c:5b4e:eb51:5b98])
 by smtp.googlemail.com with ESMTPSA id m6sm3141228wrq.5.2020.05.15.04.52.10
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 15 May 2020 04:52:10 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/LIBTFLITE PATCH 2/4] Add Makefile.uk
Date: Fri, 15 May 2020 14:51:58 +0300
Message-Id: <20200515115200.98471-3-murarugeorgec@gmail.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20200515115200.98471-1-murarugeorgec@gmail.com>
References: <20200515115200.98471-1-murarugeorgec@gmail.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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: George Muraru <murarugeorgec@gmail.com>
---
 Makefile.uk | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 167 insertions(+)
 create mode 100644 Makefile.uk

diff --git a/Makefile.uk b/Makefile.uk
new file mode 100644
index 0000000..7223603
--- /dev/null
+++ b/Makefile.uk
@@ -0,0 +1,167 @@
+#  libtensorflow-lite Makefile.uk
+#
+#  Authors: George Muraru <murarugeorgec@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.
+#
+
+$(eval $(call addlib_s,libtflite,$(CONFIG_LIBTFLITE)))
+
+################################################################################
+# Sources
+################################################################################
+LIBTFLITE_VERSION=2.0.1
+LIBTFLITE_PATCHDIR=$(LIBTFLITE_BASE)/patches
+
+LIBTFLITE_URL=https://github.com/tensorflow/tensorflow/archive/v$(LIBTFLITE_VERSION).tar.gz
+$(eval $(call fetch,libtflite,$(LIBTFLITE_URL)))
+$(eval $(call patch,libtflite,$(LIBTFLITE_PATCHDIR),tensorflow-$(LIBTFLITE_VERSION)))
+
+################################################################################
+# Helpers
+################################################################################
+LIBTFLITE_SUBDIR=tensorflow-$(LIBTFLITE_VERSION)
+LIBTFLITE_SRC = $(LIBTFLITE_ORIGIN)/$(LIBTFLITE_SUBDIR)
+
+################################################################################
+# Library includes
+################################################################################
+CXXINCLUDES-$(CONFIG_LIBTFLITE) += -I$(LIBTFLITE_SRC)/
+CXXINCLUDES-$(CONFIG_LIBTFLITE) += -I$(LIBTFLITE_SRC)/tensorflow/lite
+
+
+CINCLUDES-$(CONFIG_LIBTFLITE) += -I$(LIBTFLITE_SRC)/
+CINCLUDES-$(CONFIG_LIBTFLITE) += -I$(LIBTFLITE_SRC)/tensorflow/lite
+
+################################################################################
+# Main code
+################################################################################
+
+ifdef CONFIG_LIBTFLITE_MAIN_FUNCTION
+LIBTFLITE_SRCS-$(CONFIG_LIBTFLITE_MAIN_FUNCTION) += $(LIBTFLITE_BASE)/main.cpp
+endif
+
+################################################################################
+# Global flags
+################################################################################
+LIBTFLITE_SUPPRESS_FLAGS += -Wno-sign-compare -Wno-unused-parameter -Wno-comment \
+                            -Wno-missing-field-initializers -Wno-parantheses \
+                            -Wno-unused-function -Wno-unknown-pragmas
+
+LIBTFLITE_CXXFLAGS-y += $(LIBTFLITE_SUPPRESS_FLAGS)
+LIBTFLITE_CFLAGS-y += $(LIBTFLITE_SUPPRESS_FLAGS)
+
+ifdef CONFIG_LIBTFLITE_BUILD_WITH_RUY
+LIBTFLITE_CXXFLAGS-y += -D TFLITE_WITH_RUY
+LIBTFLITE_CFLAGS-y += -D TFLITE_WITH_RUY
+endif
+
+ifdef CONFIG_LIBTFLITE_EIGEN_DONT_ALIGN
+LIBTFLITE_CXXFLAGS-y += -D EIGEN_DONT_ALIGN
+LIBTFLITE_CFLAGS-y += -D EIGEN_DONT_ALIGN
+endif
+
+################################################################################
+# Library sources
+################################################################################
+MINIMAL_SRCS := $(LIBTFLITE_SRC)/tensorflow/lite/examples/minimal/minimal.cc
+
+
+CORE_CC_ALL_SRCS := \
+            $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/*.cc) \
+            $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/*.c) \
+            $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/c/*.c) \
+            $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/core/*.cc) \
+            $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/core/api/*.cc) \
+            $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/experimental/resource_variable/*.cc) \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/allocator.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/block_map.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/blocking_counter.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/context.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/detect_dotprod.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/kernel_arm32.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/kernel_arm64.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/pack_arm.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/pmu.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/thread_pool.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/trace.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/trmul.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/tune.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/wait.cc \
+            $(LIBTFLITE_SRC)/tensorflow/lite/minimal_logging_default.cc
+
+
+
+CORE_CC_ALL_SRCS += \
+             $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/kernels/*.cc) \
+             $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/kernels/internal/*.cc) \
+             $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/kernels/internal/optimized/*.cc) \
+             $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/kernels/internal/reference/*.cc)
+
+
+CORE_CC_ALL_SRCS := $(sort $(CORE_CC_ALL_SRCS))
+CORE_CC_EXCLUDE_SRCS := \
+                $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/*test.cc) \
+                $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/*/*test.cc) \
+                $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/*/*/*test.cc) \
+                $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/*/*/*/*test.cc) \
+                $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/kernels/*test_main.cc) \
+                $(wildcard $(LIBTFLITE_SRC)/tensorflow/lite/kernels/*test_util.cc) \
+                $(LIBTFLITE_SRC)/tensorflow/lite/experimental/ruy/pmu.cc \
+                $(LIBTFLITE_SRC)/tensorflow/lite/minimal_logging_android.cc \
+                $(LIBTFLITE_SRC)/tensorflow/lite/minimal_logging_ios.cc \
+                $(MINIMAL_SRCS)
+
+
+COMPILE_MANUAL_SRCS := \
+                $(LIBTFLITE_SRC)/tensorflow/lite/kernels/internal/mfcc.cc \
+                $(LIBTFLITE_SRC)/tensorflow/lite/kernels/mfcc.cc
+
+
+ifeq ($(CONFIG_LIBUKMMAP),y)
+CORE_CC_EXCLUDE_SRCS += $(LIBTFLITE_SRC)/tensorflow/lite/mmap_allocation_disabled.cc
+else
+CORE_CC_EXCLUDE_SRCS += $(LIBTFLITE_SRC)/tensorflow/lite/mmap_allocation.cc
+endif
+
+ifeq ($(LIBTFLITE_BUILD_WITH_NNAPI),y)
+CORE_CC_ALL_SRCS += \
+                $(LIBTFLITE_SRC)/tensorflow/lite/delegates/nnapi/nnapi_delegate.cc \
+                $(LIBTFLITE_SRC)/tensorflow/lite/delegates/nnapi/quant_lstm_sup.cc \
+                $(LIBTFLITE_SRC)/tensorflow/lite/nnapi/nnapi_implementation.cc
+else
+CORE_CC_ALL_SRCS += \
+                $(LIBTFLITE_SRC)/tensorflow/lite/delegates/nnapi/nnapi_delegate_disabled.cc \
+                $(LIBTFLITE_SRC)/tensorflow/lite/nnapi/nnapi_implementation_disabled.cc
+endif
+
+LIBTFLITE_SRCS-y += $(filter-out $(CORE_CC_EXCLUDE_SRCS) $(COMPILE_MANUAL_SRCS), $(CORE_CC_ALL_SRCS))
+LIBTFLITE_SRCS-y += $(LIBTFLITE_SRC)/tensorflow/lite/kernels/internal/mfcc.cc|internal
+LIBTFLITE_SRCS-y += $(LIBTFLITE_SRC)/tensorflow/lite/kernels/mfcc.cc|kernels
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Fri May 15 11:52:26 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 15 May 2020 11:52:26 +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 1jZYt8-0004WH-0r; Fri, 15 May 2020 11:52: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=L+Bk=65=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jZYt6-0004W0-1O
 for minios-devel@lists.xenproject.org; Fri, 15 May 2020 11:52:24 +0000
X-Inumbo-ID: 843eeea6-96a2-11ea-b07b-bc764e2007e4
Received: from mail-wr1-x435.google.com (unknown [2a00:1450:4864:20::435])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 843eeea6-96a2-11ea-b07b-bc764e2007e4;
 Fri, 15 May 2020 11:52:14 +0000 (UTC)
Received: by mail-wr1-x435.google.com with SMTP id e16so3190371wra.7
 for <minios-devel@lists.xenproject.org>; Fri, 15 May 2020 04:52: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=LccuAFooEIj5RYX4NZCAECMH5IztBA+yoVgEc8B9dqM=;
 b=MiiD66Y4EGJLgu1S7+6kyQekmc/D8sZYY0yrPD8Wdh1ATUSI3OvX6w2TzmX5zymWYc
 37tNHMw/MZe+RDdqYVPAaQI6OkycJt+//I5UmJXB4ip0M0ZkcLIpG7OfV4IVWJ43z8EG
 wjMvTcQWoC29Lbgl93/dGnLpy0YSeA8SW+UaiudYxOqu+FZ9+s9pHPJB5C9xZq/GEiL2
 D5yZIn2mueLdtoK/2yeJ5wbiTwEuULva/e9mjNajI8mJSGIYNbPraMbGm/b1bQ71lm+f
 SdJspxyJB2FI5olWASOYzOJbGkANYMWc/939iXFr5PP/+HYNnQnbhvkto84cg5plqEVW
 JVpA==
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=LccuAFooEIj5RYX4NZCAECMH5IztBA+yoVgEc8B9dqM=;
 b=pSaMXQwkhZ5kt1wCoeFFfx9CLtHiiVKmD5CdJ10wE9PSeqbJHRegYVX6fTImNUh7Lw
 8/YKcPyS8mu5E1jimJjbi13Ltyv9Id17Nb+lRKLU4COSSriPTydVRKmjtLz57LgQQYVL
 LBAoUbCJUWCFHYHZxvpiIFvhLVdRv3+YN1YmKpuw/3CFj4izwppe16YZhmSGym2ERMU9
 rcU1Xpq70JlfMhHOqn+xWbDCuWzaYScg3Pz5vXE/guHg4AI8QAoNPQZ26XqkWBFlh7NP
 7Q+b5g104gvE55uCysvUQAMsKcyCyKUy6U3ZjcXw5QNatArYQEAOcUrNQUJGAxG5mIZh
 Z5kA==
X-Gm-Message-State: AOAM530teuf3fZfFxai99xQtpmP8/xLxuWBy1acU0BPIim8OWCCv/Z8i
 0Nx7hAhvs+IlXECh+L6S9KGj/XD/GkM=
X-Google-Smtp-Source: ABdhPJyigGTjsSXCQPwFdkug6gJcFamHOAZ94XUGF8SQHAdYCTkgNoApIX+dJFJaujRFRE0gXI9ZiA==
X-Received: by 2002:a5d:5607:: with SMTP id l7mr3972650wrv.370.1589543532862; 
 Fri, 15 May 2020 04:52:12 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:f09c:5b4e:eb51:5b98])
 by smtp.googlemail.com with ESMTPSA id m6sm3141228wrq.5.2020.05.15.04.52.12
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 15 May 2020 04:52:12 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/LIBTFLITE PATCH 3/4] Add main app if selected
Date: Fri, 15 May 2020 14:51:59 +0300
Message-Id: <20200515115200.98471-4-murarugeorgec@gmail.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20200515115200.98471-1-murarugeorgec@gmail.com>
References: <20200515115200.98471-1-murarugeorgec@gmail.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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: George Muraru <murarugeorgec@gmail.com>
---
 main.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 main.cpp

diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..45f9b07
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,56 @@
+/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==============================================================================*/
+#define __clrsbDI2    __NDW(clrsb,2)
+
+#include <cstdio>
+#include "tensorflow/lite/interpreter.h"
+#include "tensorflow/lite/kernels/register.h"
+#include "tensorflow/lite/model.h"
+#include "tensorflow/lite/optional_debug_tools.h"
+
+#include <sys/mount.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+// This is an example that is minimal to read a model
+// from disk and perform inference. There is no data being loaded
+// that is up to you to add as a user.
+//
+// NOTE: Do not add any dependencies to this that cannot be built with
+// the minimal makefile. This example must remain trivial to build with
+// the minimal build tool.
+//
+// Usage: minimal <tflite model>
+
+using namespace tflite;
+
+int main() {
+  const char* filename = "mobilenet_v1_1.0_224.tflite";
+
+  // Load model
+  std::unique_ptr<tflite::FlatBufferModel> model =
+      tflite::FlatBufferModel::BuildFromFile(filename);
+
+  // Build the interpreter
+  tflite::ops::builtin::BuiltinOpResolver resolver;
+  InterpreterBuilder builder(*model, resolver);
+  std::unique_ptr<Interpreter> interpreter;
+  builder(&interpreter);
+
+  printf("=== Interpreter State ===\n");
+  tflite::PrintInterpreterState(interpreter.get());
+
+  return 0;
+}
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Fri May 15 11:52:31 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 15 May 2020 11:52:31 +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 1jZYtD-0004XA-2f; Fri, 15 May 2020 11:52:31 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=L+Bk=65=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jZYtB-0004Wx-0o
 for minios-devel@lists.xenproject.org; Fri, 15 May 2020 11:52:29 +0000
X-Inumbo-ID: 85341246-96a2-11ea-ae69-bc764e2007e4
Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 85341246-96a2-11ea-ae69-bc764e2007e4;
 Fri, 15 May 2020 11:52:15 +0000 (UTC)
Received: by mail-wr1-x443.google.com with SMTP id l17so3213022wrr.4
 for <minios-devel@lists.xenproject.org>; Fri, 15 May 2020 04:52:15 -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=BtlK9Qvgq5g8IfrkDfOdQNQvrZcZOwRHmljIeKnKanU=;
 b=DbIs3iBDURv5g8MTD8Wuj2vWA/xWYPavUV/VAS17fFcjR/eIBG9vBLaRBae0BZZ07W
 +9cTZEOBS60vE7kjrzwEbv2Pn3FuSetZUy8nr1hmVGJMxg6ZWeOh+Buim49P4UDGN2fl
 ojxlWoJVK8zCAeaom0fZgFshecbGG6szSRDSI0BPGZWM+cVsmQQFeIdVFtR3VnZ9khk7
 yOukA31LNurry4STI4HZpviY63PbFl6Q0y1wo+aoQZhTEqk0Hl+2LjDX18RZIKwb+Ay1
 emiXfDS6K/8KBkJVByUR6Sewhbf2JDxdJv5R3Nj3avH0Knof1OJiW+2FCJM1XGRnyTa+
 Spiw==
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=BtlK9Qvgq5g8IfrkDfOdQNQvrZcZOwRHmljIeKnKanU=;
 b=l51vsM4iLoO4pxKjxxuQjUxzpBKtd7DdpM4MPIEy0D+avItYBvUArjCKyJmOXOL5vz
 c/hOS+B5Hp80KXbltDIIPBlFP8dqoN7Su2XEtDHhN3RAulCmD3jfsbNExai60rhBKfWy
 WPRvuABnoHFzh3CZczCoJX+1r9P5YgXL2qfOx/HeyvOiygB5abinItcKjm1g9Pm2UFXj
 +bQ24o5/o3cu0JGjkeWYQULmUqPBcoH6P2CExwcTxmQJTPlG7oTz1zVDQshPRX1D38PV
 i674euImTe9NjZOOySyt8Y3ZziYmXhP5D+0QIOgtaAQdrdFy906mEXwYKIBFlMKHyiaP
 HwJA==
X-Gm-Message-State: AOAM533RdpV5YruzmYE13UuKi2nWtr57ca8s1wD604wPA42QbYi+bAed
 1uSQ3W8HrtlRsQ0K9Kdbd7Q86VXgN8I=
X-Google-Smtp-Source: ABdhPJwR2UoLmAWH+dVmAmA8U3plCdGZbtEbAuf9uWTUyjL58Ii35uhGj8iQP2JDWNjU01iRpxNh4Q==
X-Received: by 2002:a5d:694c:: with SMTP id r12mr3894535wrw.200.1589543534500; 
 Fri, 15 May 2020 04:52:14 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:f09c:5b4e:eb51:5b98])
 by smtp.googlemail.com with ESMTPSA id m6sm3141228wrq.5.2020.05.15.04.52.13
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 15 May 2020 04:52:13 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/LIBTFLITE PATCH 4/4] Add patches
Date: Fri, 15 May 2020 14:52:00 +0300
Message-Id: <20200515115200.98471-5-murarugeorgec@gmail.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20200515115200.98471-1-murarugeorgec@gmail.com>
References: <20200515115200.98471-1-murarugeorgec@gmail.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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: George Muraru <murarugeorgec@gmail.com>
---
 patches/0001-Change-zu-to-lu.patch | 47 ++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 patches/0001-Change-zu-to-lu.patch

diff --git a/patches/0001-Change-zu-to-lu.patch b/patches/0001-Change-zu-to-lu.patch
new file mode 100644
index 0000000..d68a26e
--- /dev/null
+++ b/patches/0001-Change-zu-to-lu.patch
@@ -0,0 +1,47 @@
+From f34b41fd728c06517a1223178af2fbb97dce5dfe Mon Sep 17 00:00:00 2001
+From: George Muraru <murarugeorgec@gmail.com>
+Date: Tue, 21 Apr 2020 23:16:50 +0300
+Subject: [PATCH 1/1] Change zu to lu
+
+---
+ tensorflow/lite/optional_debug_tools.cc | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/tensorflow/lite/optional_debug_tools.cc b/tensorflow/lite/optional_debug_tools.cc
+index a59af3d..c9339b0 100644
+--- a/tensorflow/lite/optional_debug_tools.cc
++++ b/tensorflow/lite/optional_debug_tools.cc
+@@ -80,7 +80,7 @@ const char* AllocTypeName(TfLiteAllocationType type) {
+ 
+ // Prints a dump of what tensors and what nodes are in the interpreter.
+ void PrintInterpreterState(Interpreter* interpreter) {
+-  printf("Interpreter has %zu tensors and %zu nodes\n",
++  printf("Interpreter has %lu tensors and %lu nodes\n",
+          interpreter->tensors_size(), interpreter->nodes_size());
+   printf("Inputs:");
+   PrintIntVector(interpreter->inputs());
+@@ -90,7 +90,7 @@ void PrintInterpreterState(Interpreter* interpreter) {
+   for (size_t tensor_index = 0; tensor_index < interpreter->tensors_size();
+        tensor_index++) {
+     TfLiteTensor* tensor = interpreter->tensor(static_cast<int>(tensor_index));
+-    printf("Tensor %3zu %-20s %10s %15s %10zu bytes (%4.1f MB) ", tensor_index,
++    printf("Tensor %3lu %-20s %10s %15s %10lu bytes (%4.1f MB) ", tensor_index,
+            tensor->name, TensorTypeName(tensor->type),
+            AllocTypeName(tensor->allocation_type), tensor->bytes,
+            (static_cast<float>(tensor->bytes) / (1 << 20)));
+@@ -104,10 +104,10 @@ void PrintInterpreterState(Interpreter* interpreter) {
+     const TfLiteNode& node = node_and_reg->first;
+     const TfLiteRegistration& reg = node_and_reg->second;
+     if (reg.custom_name != nullptr) {
+-      printf("Node %3zu Operator Custom Name %s\n", node_index,
++      printf("Node %3lu Operator Custom Name %s\n", node_index,
+              reg.custom_name);
+     } else {
+-      printf("Node %3zu Operator Builtin Code %3d\n", node_index,
++      printf("Node %3lu Operator Builtin Code %3d\n", node_index,
+              reg.builtin_code);
+     }
+     printf("  Inputs:");
+-- 
+2.17.1
+
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Fri May 15 12:13:51 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 15 May 2020 12:13:51 +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 1jZZDp-0007mX-L6; Fri, 15 May 2020 12:13:49 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=L+Bk=65=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jZZDo-0007lo-Ne
 for minios-devel@lists.xenproject.org; Fri, 15 May 2020 12:13:48 +0000
X-Inumbo-ID: 87985b20-96a5-11ea-b07b-bc764e2007e4
Received: from mail-wm1-x331.google.com (unknown [2a00:1450:4864:20::331])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 87985b20-96a5-11ea-b07b-bc764e2007e4;
 Fri, 15 May 2020 12:13:48 +0000 (UTC)
Received: by mail-wm1-x331.google.com with SMTP id z4so925812wmi.2
 for <minios-devel@lists.xenproject.org>; Fri, 15 May 2020 05:13: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:mime-version
 :content-transfer-encoding;
 bh=XNXLSSAbwCxs8Ztup3N62HDQgyEfIGsc8NpotkduunA=;
 b=gglJZwzpUI4/SyrR6lO5yODbXBGGhzKGVh674LJ2LLLr5Is9i4GQPRPYk9Agy7dWu5
 hW9UcXZKpNMVUj/OV5rLNUuzjEmK/LjsICtuaOoLG350jpK8/fpd6uKl0MCng2ghxKri
 8iMCRoklSq37vlhlNYLa5GOvWnqd8agDNu5m3VQy3U73cEIGfTEnt35Xd/lPcVfFx/v1
 7nmyCwt/W67s0eB7Iob7UYCGKoE6lZJ4kNjlodd0vER6L8Rjz3VTnG5k5TRsF6C+/0IG
 9xDEmcfnGBjuKGm0NGJU6eQaSGTpV8fQibpzO0dIvyQFBV0Oq19WW3JS4DlXYLuZY859
 PWiA==
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=XNXLSSAbwCxs8Ztup3N62HDQgyEfIGsc8NpotkduunA=;
 b=ksCxUQehKDPb7a+UA3Cy6+E+XjKwpLcbZsbVAb/y3t8VqLFZMxTrwisuk4uGgEKn2y
 mv2SxkpV35vSydCJd0NjYPU9cKLHcFJvfaASAtlD45J5AsMV0EpAs8fg1o2uyVvNVqLe
 e8xdoPE+ppaqQxiagobvNcXYnax40v5R1Ndjck1OAZ4c8uCAR3WPgG/ncTu1ugFH3Xgq
 ixtVosVQ8ejF/t9oGnF27PQ018Nu7LFZ/DNhpQ6mRntI6QIiosMSxeufNqr+MwhnM3CN
 j4k+ArmgBc+357DCM/94z0rZs58vnVh6dYP63WHCyAvtybmIXCc1rHb+2uRZ1oLhnXuj
 2++Q==
X-Gm-Message-State: AOAM531bdTHizJHgKU4TwFZhDLIQxqKlnXPmPXOsRU+6aZp05VfPStzn
 QBpaYc+wa/eRfV7TJweLVPSo9gR14Q8=
X-Google-Smtp-Source: ABdhPJzxEu5aZkHBqbFzOq/b4vnWI2glvvq//mYKKQKsuqgodghNv3s/9LLObV2FEEr1jf/Y4V/97w==
X-Received: by 2002:a1c:6344:: with SMTP id x65mr3941551wmb.51.1589544827005; 
 Fri, 15 May 2020 05:13:47 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:f09c:5b4e:eb51:5b98])
 by smtp.googlemail.com with ESMTPSA id 88sm3304624wrq.77.2020.05.15.05.13.45
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 15 May 2020 05:13:46 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/VFSCORE PATCH 0/2]
Date: Fri, 15 May 2020 15:13:34 +0300
Message-Id: <20200515121336.101817-1-murarugeorgec@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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Add quotes to string symbol
Got a warning while trying to use "make kmenuconfig" saying the following:
"warning: style: quotes recommended around default value for string symbol
UK_ARCH (defined at .../unikraft/Config.uk:12)"
 
Setting a specific value to a choice config (from one of the libraries) cannot
overwrite a default value (that is set in Unikraft). It seems this is the case
for our C based Kconfig (from my knowledge we use this) - a default value set
earlier (in Unikraft) has a higher priority than a one set later (in a library).

For solving this issue, one solution is to use "named choices" - did that for
the tensorflowlite porting.

The information is obtained from an issue discussed here[1].
 
[1] https://github.com/zephyrproject-rtos/zephyr/issues/6948

George Muraru (2):
  Quotes to symbol
  Remove default value

 Config.uk             | 2 +-
 lib/vfscore/Config.uk | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Fri May 15 12:13:56 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 15 May 2020 12:13:56 +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 1jZZDw-0007n4-Mo; Fri, 15 May 2020 12:13:56 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=L+Bk=65=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jZZDv-0007mu-US
 for minios-devel@lists.xenproject.org; Fri, 15 May 2020 12:13:55 +0000
X-Inumbo-ID: 8bfb0d02-96a5-11ea-b9cf-bc764e2007e4
Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 8bfb0d02-96a5-11ea-b9cf-bc764e2007e4;
 Fri, 15 May 2020 12:13:55 +0000 (UTC)
Received: by mail-wr1-x443.google.com with SMTP id i15so3235532wrx.10
 for <minios-devel@lists.xenproject.org>; Fri, 15 May 2020 05:13:55 -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=4xIxvMbmSpJtq50VXH4Z5L/he/j00Sw8qu8arnYpNLY=;
 b=TM9UQQW9d3T6TD9HZr1TsX1Q5mS75P8X18bB9YbV9FfIOoiMMYtJ2rT40JbJGplk3L
 IbKR/aHLOcUCOrrp5Il0OsA4Am+EhVRCtDUvOojGeoveTMX7+zwyk+dXN94o7Y7pbmS6
 ByxxmCXIyezL0+wxh445YA6SZR1GuoAkZDQKEvmNSUatlGfj9fBoUc6MeBW3JhkJgkRz
 Jpy4+wCd71JHZtGsVocoprOBVGlgGgZE3OJ3S8ho5flK1Cp/ssPlDQZSKUgEPvBoXbe4
 p2HeN78XP7aAQdHtCDyH558ufjzihfkRnnZPvTDPYwhET5eC7/+yWYyQYB8Q2gJyClsO
 mqmQ==
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=4xIxvMbmSpJtq50VXH4Z5L/he/j00Sw8qu8arnYpNLY=;
 b=mcaTAdmi2Ny8NoWMvcZydpR/JpdFBMtKGOtBPpCBKxqEyLoJspycWEANdQHxRMQJGH
 ir4XwVtMtA015RjKMS63nyKtIiwqyQJsIa+rO1COF5J+ZNO38jsfoLuHp2G0LIPtHjde
 lfhbvWCfKp2o3uj5DTIlZMK+lZuIdhb2sfynTJGEVf5h4dLWtD7booKyeJAikAmxESmm
 MgGLEvnXV9TkJKeezOD8AxB8PAxZAhs4YiQO6A9KBHtvNVHydlI62Q7+bgt12qyFSBkl
 olw/J1bmUzHC/FFtqKwjVlOtVyTmCl8YS542//Ypkadc4Ds+GMdIVmODhe/Yjj1pcWQN
 buYA==
X-Gm-Message-State: AOAM531kvenNQyV3oTygj0zr8rcDtmlnBnrs2k8PqOuqAI0llhVaxsTQ
 v0BGWN8PbRhGRiSoZSyQHFWfJ8mHQX0=
X-Google-Smtp-Source: ABdhPJz7MQYf82mGNW1M97+gkWhsa+MnE9gxJnptiXyteY0qkkV+XBFtf3SpBLmV9wQ5yzB/yCVVaQ==
X-Received: by 2002:adf:8483:: with SMTP id 3mr4029230wrg.206.1589544834411;
 Fri, 15 May 2020 05:13:54 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:f09c:5b4e:eb51:5b98])
 by smtp.googlemail.com with ESMTPSA id 88sm3304624wrq.77.2020.05.15.05.13.53
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 15 May 2020 05:13:53 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/VFSCORE PATCH 1/2] Quotes to symbol
Date: Fri, 15 May 2020 15:13:35 +0300
Message-Id: <20200515121336.101817-2-murarugeorgec@gmail.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20200515121336.101817-1-murarugeorgec@gmail.com>
References: <20200515121336.101817-1-murarugeorgec@gmail.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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: George Muraru <murarugeorgec@gmail.com>
---
 Config.uk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Config.uk b/Config.uk
index 3235b91..1d4143e 100644
--- a/Config.uk
+++ b/Config.uk
@@ -14,7 +14,7 @@ config UK_ARCH
 	default "x86_64" if ARCH_X86_64
 	default "arm64"  if ARCH_ARM_64
 	default "arm"	if ARCH_ARM_32
-	default $(UK_ARCH)
+	default "$(UK_ARCH)"
 
 config NO_APP
 	def_bool $(shell,test $(UK_BASE) = $(UK_APP) && echo y || echo n)
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Fri May 15 12:13:59 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 15 May 2020 12:13: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 1jZZDz-0007nn-OL; Fri, 15 May 2020 12:13: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=L+Bk=65=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jZZDy-0007nX-M7
 for minios-devel@lists.xenproject.org; Fri, 15 May 2020 12:13:58 +0000
X-Inumbo-ID: 8d29b8fe-96a5-11ea-b07b-bc764e2007e4
Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 8d29b8fe-96a5-11ea-b07b-bc764e2007e4;
 Fri, 15 May 2020 12:13:57 +0000 (UTC)
Received: by mail-wm1-x343.google.com with SMTP id f134so2100792wmf.1
 for <minios-devel@lists.xenproject.org>; Fri, 15 May 2020 05:13:57 -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=QZkI/IPWFaENSLx1ddjZAAIawGF8Vc9c2sHGLnVI+6k=;
 b=FuefhjxvSRzZvhNr015ec7sBBjpWM/uNsKRjrA5Fw0tg0SJBXUTDEFK69aho48QZT2
 nftNmCrr1b2aDHENa1eXeV04dTPEUK679i5qJfLExK4LmLPEK38ebC9e0+RxtF3zv3dJ
 oovPYmotP06HkKSqLMX/guc08nrRqwQq4Ky1/2eVKUmJHxHxXv8JBvsHSnCeKEXpUJ75
 XHcolJOnoVICf+Qdikx8ENE++laZrcI2rcfFgBQobljGD7kEjCpd2NAZC4UiIBHXShXu
 +2YinOy33Zaybp4Jae0s0C3Gs1LPrVvsiSCqaqxXljSx8TbfHst+/D4d33M6CArOW7gi
 QNHQ==
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=QZkI/IPWFaENSLx1ddjZAAIawGF8Vc9c2sHGLnVI+6k=;
 b=SOMZbO8Psb/U5FgygJSRWiu9FkcqwPwrGePjeYdDPBdsmRCXNxeh2MBPGq+P3XwIwi
 Xp29gCGVBNtjWfjD3d+41+/p8f74aN4FtRmjds6lrKdGbvZVeMdPG1nqYTQN8x0A+PEi
 A5j11gvRV96JlP0XXoR9ywulLLEE4N10dOany7mLCw9OASO+S1+5ePoacyzjJAxvFy0O
 6OxIpuJubWwXJQ9Y2aex044JHcsDqPNQwP+7dk1/0oyO9xBgNXPBa2dXPI4JuD8dbyG8
 GNChYbh1un9s55bxlXJRA4FxjJ38o8iLmTURXNrXtPhD7k9s5um8xH6ohJC9eeoQ2vTn
 kwFQ==
X-Gm-Message-State: AOAM532upsfttjWBovDPDDGY+ydEYal8Eja13zwkX9IyWAx7OmMkBdJZ
 /kPngdkopyLDXpow1CP3cYLeEiZCk/A=
X-Google-Smtp-Source: ABdhPJwmjOlKkK6+BCuEk1gJx667YSnsWRiawDywEZ725cpOuwUKLD6YOZyP+cU1ZWpcUrm6nmLOrg==
X-Received: by 2002:a7b:c41a:: with SMTP id k26mr3804062wmi.85.1589544836406; 
 Fri, 15 May 2020 05:13:56 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:f09c:5b4e:eb51:5b98])
 by smtp.googlemail.com with ESMTPSA id 88sm3304624wrq.77.2020.05.15.05.13.55
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 15 May 2020 05:13:55 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/VFSCORE PATCH 2/2] Remove default value
Date: Fri, 15 May 2020 15:13:36 +0300
Message-Id: <20200515121336.101817-3-murarugeorgec@gmail.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20200515121336.101817-1-murarugeorgec@gmail.com>
References: <20200515121336.101817-1-murarugeorgec@gmail.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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: George Muraru <murarugeorgec@gmail.com>
---
 lib/vfscore/Config.uk | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/vfscore/Config.uk b/lib/vfscore/Config.uk
index f64810f..212575c 100644
--- a/lib/vfscore/Config.uk
+++ b/lib/vfscore/Config.uk
@@ -28,7 +28,6 @@ help
 if LIBVFSCORE_AUTOMOUNT_ROOTFS
 	choice LIBVFSCORE_ROOTFS
 	prompt "Default root filesystem"
-	default LIBVFSCORE_ROOTFS_RAMFS
 
 		config LIBVFSCORE_ROOTFS_RAMFS
 		bool "RamFS"
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Sat May 16 14:27:18 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 16 May 2020 14:27: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 1jZxmU-000445-SO; Sat, 16 May 2020 14:27:14 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=WrGt=66=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jZxmT-000440-C0
 for minios-devel@lists.xen.org; Sat, 16 May 2020 14:27:13 +0000
X-Inumbo-ID: 5355c5b4-9781-11ea-ae69-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.5])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 5355c5b4-9781-11ea-ae69-bc764e2007e4;
 Sat, 16 May 2020 14:27:10 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 9CF2EB5627F6;
 Sat, 16 May 2020 17:27:08 +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 eB7ZYD24yz9g; Sat, 16 May 2020 17:27:05 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 681D2B5627ED;
 Sat, 16 May 2020 17:27:05 +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 WUjdgukMXKez; Sat, 16 May 2020 17:27:05 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.26.181.84])
 by mx.upb.ro (Postfix) with ESMTPSA id 34194B5627E9;
 Sat, 16 May 2020 17:27:05 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v2 1/9] lib/uk9p: Add new serialization mechanism
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200509164413.38078-1-cristb@gmail.com>
 <20200509164413.38078-2-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <36e04a19-a57d-e9c5-0b3a-6a83306d7a4b@cs.pub.ro>
Date: Sat, 16 May 2020 17:27:04 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200509164413.38078-2-cristb@gmail.com>
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>

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/9/20 7:44 PM, Cristian Banu wrote:
> This patch implements serialization in a type-safe way: the compiler can
> issue warnings if the data types don't match.  Previously the types were
> hidden behind a va_list and thus unchecked.
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/uk9p/include/uk/9preq.h | 184 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 184 insertions(+)
> 
> diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
> index ee4d2af..70c1b03 100644
> --- a/lib/uk9p/include/uk/9preq.h
> +++ b/lib/uk9p/include/uk/9preq.h
> @@ -41,6 +41,7 @@
>  #include <uk/essentials.h>
>  #include <uk/list.h>
>  #include <uk/refcount.h>
> +#include <uk/9p_core.h>
>  #if CONFIG_LIBUKSCHED
>  #include <uk/wait_types.h>
>  #endif
> @@ -293,6 +294,189 @@ int uk_9preq_waitreply(struct uk_9preq *req);
>   */
>  int uk_9preq_error(struct uk_9preq *req);
>  
> +/*
> + * The following family of serialization and deserialization functions
> + * are used for writing the 'base' types the 9p protocol supports.
> + *
> + * These are defined in the header for better performance by not necessarily
> + * incurring a function call penalty if called from outside uk9p.
> + *
> + * Provided functions:
> + * - uk_9preq_{read,write}buf
> + * - uk_9preq_{read,write}8
> + * - uk_9preq_{read,write}16
> + * - uk_9preq_{read,write}32
> + * - uk_9preq_{read,write}64
> + * - uk_9preq_{read,write}qid
> + * - uk_9preq_{read,write}str
> + * - uk_9preq_{read,write}stat
> + *
> + * For qid, str and stat, read and write always take a pointer.
> + * For all other types, write takes the argument by value.
> + *
> + * Possible return values:
> + * - 0: Operation successful.
> + * - (-ENOBUFS): End of buffer reached.
> + */
> +
> +static inline int uk_9preq_writebuf(struct uk_9preq *req, const void *buf,
> +		uint32_t size)
> +{
> +	if (req->xmit.offset + size > req->xmit.size)
> +		return -ENOBUFS;
> +
> +	memcpy((char *)req->xmit.buf + req->xmit.offset, buf, size);
> +	req->xmit.offset += size;
> +	return 0;
> +}
> +
> +static inline int uk_9preq_readbuf(struct uk_9preq *req, void *buf,
> +		uint32_t size)
> +{
> +	if (req->recv.offset + size > req->recv.size)
> +		return -ENOBUFS;
> +
> +	memcpy(buf, (char *)req->recv.buf + req->recv.offset, size);
> +	req->recv.offset += size;
> +	return 0;
> +}
> +
> +#define _UK_9PREQ_DEFINE_WRITE_FN(name, ctype) \
> +static inline int uk_9preq_##name(struct uk_9preq *req, ctype val) \
> +{ \
> +	return uk_9preq_writebuf(req, &val, sizeof(val)); \
> +}
> +
> +_UK_9PREQ_DEFINE_WRITE_FN(write8, uint8_t)
> +_UK_9PREQ_DEFINE_WRITE_FN(write16, uint16_t)
> +_UK_9PREQ_DEFINE_WRITE_FN(write32, uint32_t)
> +_UK_9PREQ_DEFINE_WRITE_FN(write64, uint64_t)
> +
> +#undef _UK_9PREQ_DEFINE_WRITE_FN
> +
> +static inline int uk_9preq_writeqid(struct uk_9preq *req, struct uk_9p_qid *val)
> +{
> +	int rc;
> +
> +	if ((rc = uk_9preq_write8(req, val->type)) ||
> +		(rc = uk_9preq_write32(req, val->version)) ||
> +		(rc = uk_9preq_write64(req, val->path)))
> +		return rc;
> +
> +	return 0;
> +}
> +
> +static inline int uk_9preq_writestr(struct uk_9preq *req, struct uk_9p_str *val)
> +{
> +	int rc;
> +
> +	if ((rc = uk_9preq_write16(req, val->size)) ||
> +		(rc = uk_9preq_writebuf(req, val->data, val->size)))
> +		return rc;
> +
> +	return 0;
> +}
> +
> +static inline int uk_9preq_writestat(struct uk_9preq *req,
> +		struct uk_9p_stat *val)
> +{
> +	int rc;
> +
> +	val->size = 61;
> +	val->size += val->name.size;
> +	val->size += val->uid.size;
> +	val->size += val->gid.size;
> +	val->size += val->muid.size;
> +	val->size += val->extension.size;
> +
> +	if ((rc = uk_9preq_write16(req, val->size)) ||
> +		(rc = uk_9preq_write16(req, val->type)) ||
> +		(rc = uk_9preq_write32(req, val->dev)) ||
> +		(rc = uk_9preq_writeqid(req, &val->qid)) ||
> +		(rc = uk_9preq_write32(req, val->mode)) ||
> +		(rc = uk_9preq_write32(req, val->atime)) ||
> +		(rc = uk_9preq_write32(req, val->mtime)) ||
> +		(rc = uk_9preq_write64(req, val->length)) ||
> +		(rc = uk_9preq_writestr(req, &val->name)) ||
> +		(rc = uk_9preq_writestr(req, &val->uid)) ||
> +		(rc = uk_9preq_writestr(req, &val->gid)) ||
> +		(rc = uk_9preq_writestr(req, &val->muid)) ||
> +		(rc = uk_9preq_writestr(req, &val->extension)) ||
> +		(rc = uk_9preq_write32(req, val->n_uid)) ||
> +		(rc = uk_9preq_write32(req, val->n_gid)) ||
> +		(rc = uk_9preq_write32(req, val->n_muid)))
> +		return rc;
> +
> +	return 0;
> +}
> +
> +#define _UK_9PREQ_DEFINE_READ_FN(name, ctype) \
> +static inline int uk_9preq_##name(struct uk_9preq *req, ctype * val) \
> +{ \
> +	return uk_9preq_readbuf(req, val, sizeof(*val)); \
> +}
> +
> +_UK_9PREQ_DEFINE_READ_FN(read8, uint8_t)
> +_UK_9PREQ_DEFINE_READ_FN(read16, uint16_t)
> +_UK_9PREQ_DEFINE_READ_FN(read32, uint32_t)
> +_UK_9PREQ_DEFINE_READ_FN(read64, uint64_t)
> +
> +#undef _UK_9PREQ_DEFINE_READ_FN
> +
> +static inline int uk_9preq_readqid(struct uk_9preq *req, struct uk_9p_qid *val)
> +{
> +	int rc;
> +
> +	if ((rc = uk_9preq_read8(req, &val->type)) ||
> +		(rc = uk_9preq_read32(req, &val->version)) ||
> +		(rc = uk_9preq_read64(req, &val->path)))
> +		return rc;
> +
> +	return 0;
> +}
> +
> +static inline int uk_9preq_readstr(struct uk_9preq *req, struct uk_9p_str *val)
> +{
> +	int rc;
> +
> +	if ((rc = uk_9preq_read16(req, &val->size)))
> +		return rc;
> +
> +	/* Optimized string read, does not allocate memory. */
> +	val->data = (char *)req->recv.buf + req->recv.offset;
> +	req->recv.offset += val->size;
> +	if (req->recv.offset > req->recv.size)
> +		return -ENOBUFS;
> +
> +	return 0;
> +}
> +
> +static inline int uk_9preq_readstat(struct uk_9preq *req,
> +		struct uk_9p_stat *val)
> +{
> +	int rc;
> +
> +	if ((rc = uk_9preq_read16(req, &val->size)) ||
> +		(rc = uk_9preq_read16(req, &val->type)) ||
> +		(rc = uk_9preq_read32(req, &val->dev)) ||
> +		(rc = uk_9preq_readqid(req, &val->qid)) ||
> +		(rc = uk_9preq_read32(req, &val->mode)) ||
> +		(rc = uk_9preq_read32(req, &val->atime)) ||
> +		(rc = uk_9preq_read32(req, &val->mtime)) ||
> +		(rc = uk_9preq_read64(req, &val->length)) ||
> +		(rc = uk_9preq_readstr(req, &val->name)) ||
> +		(rc = uk_9preq_readstr(req, &val->uid)) ||
> +		(rc = uk_9preq_readstr(req, &val->gid)) ||
> +		(rc = uk_9preq_readstr(req, &val->muid)) ||
> +		(rc = uk_9preq_readstr(req, &val->extension)) ||
> +		(rc = uk_9preq_read32(req, &val->n_uid)) ||
> +		(rc = uk_9preq_read32(req, &val->n_gid)) ||
> +		(rc = uk_9preq_read32(req, &val->n_muid)))
> +		return rc;
> +
> +	return 0;
> +}
> +
>  #ifdef __cplusplus
>  }
>  #endif
> 


From minios-devel-bounces@lists.xenproject.org Sat May 16 14:27:30 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 16 May 2020 14:27:30 +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 1jZxmk-0004AA-UK; Sat, 16 May 2020 14:27: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=WrGt=66=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jZxmk-00049c-1b
 for minios-devel@lists.xen.org; Sat, 16 May 2020 14:27:30 +0000
X-Inumbo-ID: 5e56664e-9781-11ea-ae69-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 5e56664e-9781-11ea-ae69-bc764e2007e4;
 Sat, 16 May 2020 14:27:28 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 88806B562009;
 Sat, 16 May 2020 17:27:27 +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 brarGdeEmA82; Sat, 16 May 2020 17:27:22 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id DA74CB5624E7;
 Sat, 16 May 2020 17:27:22 +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 uwt3KPUiAlEk; Sat, 16 May 2020 17:27:22 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.26.181.84])
 by mx.upb.ro (Postfix) with ESMTPSA id 93927B562009;
 Sat, 16 May 2020 17:27:22 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v2 2/9] lib/uk9p: Switch to using the new
 serialization
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200509164413.38078-1-cristb@gmail.com>
 <20200509164413.38078-3-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <1f28a0b6-6f65-9a4b-7c9e-f51a78e1d63e@cs.pub.ro>
Date: Sat, 16 May 2020 17:27:22 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200509164413.38078-3-cristb@gmail.com>
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>

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/9/20 7:44 PM, Cristian Banu wrote:
> This patch migrates 9p.c and 9pfs to use the new serialization
> implementation.
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/9pfs/9pfs_vnops.c |   2 +-
>  lib/uk9p/9p.c         | 302 +++++++++++++++++++++++++-----------------
>  lib/uk9p/9preq.c      |  27 ++--
>  3 files changed, 192 insertions(+), 139 deletions(-)
> 
> diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
> index 5e6a7bb..6d3ece3 100644
> --- a/lib/9pfs/9pfs_vnops.c
> +++ b/lib/9pfs/9pfs_vnops.c
> @@ -409,7 +409,7 @@ again:
>  	fake_request.recv.size = fd->readdir_sz;
>  	fake_request.recv.offset = fd->readdir_off;
>  	fake_request.state = UK_9PREQ_RECEIVED;
> -	rc = uk_9preq_deserialize(&fake_request, "S", &stat);
> +	rc = uk_9preq_readstat(&fake_request, &stat);
>  
>  	if (rc == -ENOBUFS) {
>  		/*
> diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
> index eb4c2dc..638555b 100644
> --- a/lib/uk9p/9p.c
> +++ b/lib/uk9p/9p.c
> @@ -40,28 +40,49 @@
>  #include <uk/9preq.h>
>  #include <uk/9pfid.h>
>  
> +static inline int send_and_wait_zc(struct uk_9pdev *dev, struct uk_9preq *req,
> +		enum uk_9preq_zcdir zc_dir, void *zc_buf, uint32_t zc_size,
> +		uint32_t zc_offset)
> +{
> +	int rc;
> +
> +	if ((rc = uk_9preq_ready(req, zc_dir, zc_buf, zc_size, zc_offset)) ||
> +		(rc = uk_9pdev_request(dev, req)) ||
> +		(rc = uk_9preq_waitreply(req)))
> +		return rc;
> +
> +	return 0;
> +}
> +
> +static inline int send_and_wait_no_zc(struct uk_9pdev *dev,
> +		struct uk_9preq *req)
> +{
> +	return send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
> +}
> +
>  struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
>  		const char *requested, struct uk_9p_str *received)
>  {
>  	struct uk_9p_str requested_str;
>  	struct uk_9preq *req;
> -	int rc;
> +	int rc = 0;
>  	uint32_t new_msize;
>  
>  	uk_9p_str_init(&requested_str, requested);
>  
> -	uk_pr_debug("TVERSION msize %u version %s\n",
> -			dev->msize, requested);
> -
> -	req = uk_9pdev_call(dev, UK_9P_TVERSION, __PAGE_SIZE, "ds",
> -			dev->msize, &requested_str);
> +	req = uk_9pdev_req_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return req;
>  
> -	rc = uk_9preq_deserialize(req, "ds", &new_msize, received);
> +	uk_pr_debug("TVERSION msize %u version %s\n",
> +			dev->msize, requested);
>  
> -	if (rc)
> -		return ERR2PTR(rc);
> +	if ((rc = uk_9preq_write32(req, dev->msize)) ||
> +		(rc = uk_9preq_writestr(req, &requested_str)) ||
> +		(rc = send_and_wait_no_zc(dev, req)) ||
> +		(rc = uk_9preq_read32(req, &new_msize)) ||
> +		(rc = uk_9preq_readstr(req, received)))
> +		goto free;
>  
>  	uk_pr_debug("RVERSION msize %u version %.*s\n", new_msize,
>  			received->size, received->data);
> @@ -76,6 +97,10 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
>  		uk_pr_debug("Invalid new message size.\n");
>  
>  	return req;
> +
> +free:
> +	uk_9pdev_req_remove(dev, req);
> +	return ERR2PTR(rc);
>  }
>  
>  struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
> @@ -94,43 +119,56 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
>  	if (PTRISERR(fid))
>  		return fid;
>  
> -	uk_pr_debug("TATTACH fid %u afid %u uname %s aname %s n_uname %u\n",
> -			fid->fid, afid, uname, aname, n_uname);
> -
> -	req = uk_9pdev_call(dev, UK_9P_TATTACH, __PAGE_SIZE, "ddssd",
> -			fid->fid, afid, &uname_str, &aname_str, n_uname);
> +	req = uk_9pdev_req_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
>  	if (PTRISERR(req)) {
>  		uk_9pdev_fid_release(fid);
>  		return (void *)req;
>  	}
>  
> -	rc = uk_9preq_deserialize(req, "Q", &fid->qid);
> +	uk_pr_debug("TATTACH fid %u afid %u uname %s aname %s n_uname %u\n",
> +			fid->fid, afid, uname, aname, n_uname);
> +
> +	rc = 0;
> +	if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +		(rc = uk_9preq_write32(req, afid)) ||
> +		(rc = uk_9preq_writestr(req, &uname_str)) ||
> +		(rc = uk_9preq_writestr(req, &aname_str)) ||
> +		(rc = uk_9preq_write32(req, n_uname)) ||
> +		(rc = send_and_wait_no_zc(dev, req)) ||
> +		(rc = uk_9preq_readqid(req, &fid->qid)))
> +		goto free;
> +
>  	uk_9pdev_req_remove(dev, req);
>  
>  	uk_pr_debug("RATTACH qid type %u version %u path %lu\n",
>  			fid->qid.type, fid->qid.version, fid->qid.path);
>  
> -	if (rc < 0) {
> -		uk_9pdev_fid_release(fid);
> -		return ERR2PTR(rc);
> -	}
> -
>  	return fid;
> +
> +free:
> +	uk_9pdev_fid_release(fid);
> +	uk_9pdev_req_remove(dev, req);
> +	return ERR2PTR(rc);
>  }
>  
>  int uk_9p_flush(struct uk_9pdev *dev, uint16_t oldtag)
>  {
>  	struct uk_9preq *req;
> +	int rc = 0;
>  
> -	uk_pr_debug("TFLUSH oldtag %u\n", oldtag);
> -	req = uk_9pdev_call(dev, UK_9P_TFLUSH, __PAGE_SIZE, "w", oldtag);
> +	req = uk_9pdev_req_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> +	uk_pr_debug("TFLUSH oldtag %u\n", oldtag);
> +	if ((rc = uk_9preq_write16(req, oldtag)) ||
> +		(rc = send_and_wait_no_zc(dev, req)))
> +		goto out;
>  	uk_pr_debug("RFLUSH\n");
> -	uk_9pdev_req_remove(dev, req);
>  
> -	return 0;
> +out:
> +	uk_9pdev_req_remove(dev, req);
> +	return rc;
>  }
>  
>  struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
> @@ -141,7 +179,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	struct uk_9p_str name_str;
>  	uint16_t nwqid;
>  	uint16_t nwname;
> -	int rc;
> +	int rc = 0;
>  
>  	uk_9p_str_init(&name_str, name);
>  
> @@ -151,51 +189,56 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  
>  	nwname = name ? 1 : 0;
>  
> +	req = uk_9pdev_req_create(dev, UK_9P_TWALK, __PAGE_SIZE);
> +	if (PTRISERR(req)) {
> +		rc = PTR2ERR(req);
> +		goto out;
> +	}
> +
>  	if (name) {
>  		uk_pr_debug("TWALK fid %u newfid %u nwname %d name %s\n",
>  				fid->fid, newfid->fid, nwname, name);
> -		req = uk_9pdev_call(dev, UK_9P_TWALK, __PAGE_SIZE, "ddws",
> -				fid->fid, newfid->fid, nwname, &name_str);
> +		if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +			(rc = uk_9preq_write32(req, newfid->fid)) ||
> +			(rc = uk_9preq_write16(req, nwname)) ||
> +			(rc = uk_9preq_writestr(req, &name_str)))
> +			goto out;
>  	} else {
>  		uk_pr_debug("TWALK fid %u newfid %u nwname %d\n",
>  				fid->fid, newfid->fid, nwname);
> -		req = uk_9pdev_call(dev, UK_9P_TWALK, __PAGE_SIZE, "ddw",
> -				fid->fid, newfid->fid, nwname);
> +		if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +			(rc = uk_9preq_write32(req, newfid->fid)) ||
> +			(rc = uk_9preq_write16(req, nwname)))
> +			goto out;
>  	}
>  
> -	if (PTRISERR(req)) {
> +	if ((rc = send_and_wait_no_zc(dev, req))) {
>  		/*
>  		 * Don't clunk if request has finished with error, as the fid
>  		 * is invalid.
>  		 */
>  		newfid->was_removed = 1;
> -		rc = PTR2ERR(req);
>  		goto out;
>  	}
>  
> -	rc = uk_9preq_deserialize(req, "w", &nwqid);
> -	if (rc < 0)
> -		goto out_req;
> +	if ((rc = uk_9preq_read16(req, &nwqid)))
> +		goto out;
>  
>  	uk_pr_debug("RWALK nwqid %u\n", nwqid);
>  
>  	if (nwqid != nwname) {
>  		rc = -ENOENT;
> -		goto out_req;
> +		goto out;
>  	}
>  
> -
>  	if (nwname) {
> -		rc = uk_9preq_deserialize(req, "Q", &newfid->qid);
> -		if (rc < 0)
> -			goto out_req;
> +		if ((rc = uk_9preq_readqid(req, &newfid->qid)))
> +			goto out;
>  	} else
>  		newfid->qid = fid->qid;
>  
> -	rc = 0;
> -out_req:
> -	uk_9pdev_req_remove(dev, req);
>  out:
> +	uk_9pdev_req_remove(dev, req);
>  	if (rc) {
>  		uk_9pdev_fid_release(newfid);
>  		return ERR2PTR(rc);
> @@ -207,22 +250,27 @@ out:
>  int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
>  {
>  	struct uk_9preq *req;
> -	int rc;
> -
> -	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
> +	int rc = 0;
>  
> -	req = uk_9pdev_call(dev, UK_9P_TOPEN, __PAGE_SIZE, "db",
> -			fid->fid, mode);
> +	req = uk_9pdev_req_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> -	rc = uk_9preq_deserialize(req, "Qd", &fid->qid, &fid->iounit);
> -	uk_9pdev_req_remove(dev, req);
> +	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
> +
> +	if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +		(rc = uk_9preq_write8(req, mode)) ||
> +		(rc = send_and_wait_no_zc(dev, req)) ||
> +		(rc = uk_9preq_readqid(req, &fid->qid)) ||
> +		(rc = uk_9preq_read32(req, &fid->iounit)))
> +		goto out;
>  
>  	uk_pr_debug("ROPEN qid type %u version %u path %lu iounit %u\n",
>  			fid->qid.type, fid->qid.version, fid->qid.path,
>  			fid->iounit);
>  
> +out:
> +	uk_9pdev_req_remove(dev, req);
>  	return rc;
>  }
>  
> @@ -233,63 +281,80 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	struct uk_9preq *req;
>  	struct uk_9p_str name_str;
>  	struct uk_9p_str extension_str;
> -	int rc;
> +	int rc = 0;
>  
>  	uk_9p_str_init(&name_str, name);
>  	uk_9p_str_init(&extension_str, extension);
>  
> -	uk_pr_debug("TCREATE fid %u name %s perm %u mode %u ext %s\n",
> -			fid->fid, name, perm, mode, extension);
> -
> -	req = uk_9pdev_call(dev, UK_9P_TCREATE, __PAGE_SIZE, "dsdbs",
> -			fid->fid, &name_str, perm, mode, &extension_str);
> +	req = uk_9pdev_req_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> -	rc = uk_9preq_deserialize(req, "Qd", &fid->qid, &fid->iounit);
> -	uk_9pdev_req_remove(dev, req);
> +	uk_pr_debug("TOPEN fid %u mode %u\n", fid->fid, mode);
> +
> +	if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +		(rc = uk_9preq_writestr(req, &name_str)) ||
> +		(rc = uk_9preq_write32(req, perm)) ||
> +		(rc = uk_9preq_write8(req, mode)) ||
> +		(rc = uk_9preq_writestr(req, &extension_str)) ||
> +		(rc = send_and_wait_no_zc(dev, req)) ||
> +		(rc = uk_9preq_readqid(req, &fid->qid)) ||
> +		(rc = uk_9preq_read32(req, &fid->iounit)))
> +		goto out;
>  
>  	uk_pr_debug("RCREATE qid type %u version %u path %lu iounit %u\n",
>  			fid->qid.type, fid->qid.version, fid->qid.path,
>  			fid->iounit);
>  
> +out:
> +	uk_9pdev_req_remove(dev, req);
>  	return rc;
>  }
>  
>  int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
>  {
>  	struct uk_9preq *req;
> +	int rc = 0;
>  
>  	/* The fid is considered invalid even if the remove fails. */
>  	fid->was_removed = 1;
>  
> -	uk_pr_debug("TREMOVE fid %u\n", fid->fid);
> -	req = uk_9pdev_call(dev, UK_9P_TREMOVE, __PAGE_SIZE, "d", fid->fid);
> +	req = uk_9pdev_req_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> -	uk_9pdev_req_remove(dev, req);
> +	uk_pr_debug("TREMOVE fid %u\n", fid->fid);
> +	if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +		(rc = send_and_wait_no_zc(dev, req)))
> +		goto out;
>  	uk_pr_debug("RREMOVE\n");
>  
> -	return 0;
> +out:
> +	uk_9pdev_req_remove(dev, req);
> +	return rc;
>  }
>  
>  int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
>  {
>  	struct uk_9preq *req;
> +	int rc = 0;
>  
>  	if (fid->was_removed)
>  		return 0;
>  
> -	uk_pr_debug("TCLUNK fid %u\n", fid->fid);
> -	req = uk_9pdev_call(dev, UK_9P_TCLUNK, __PAGE_SIZE, "d", fid->fid);
> +	req = uk_9pdev_req_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> -	uk_9pdev_req_remove(dev, req);
> +	uk_pr_debug("TCLUNK fid %u\n", fid->fid);
> +	if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +		(rc = send_and_wait_no_zc(dev, req)))
> +		goto out;
>  	uk_pr_debug("RCLUNK\n");
>  
> -	return 0;
> +out:
> +	uk_9pdev_req_remove(dev, req);
> +	return rc;
>  }
>  
>  int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
> @@ -309,24 +374,12 @@ int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> -	rc = uk_9preq_serialize(req, "dqd", fid->fid, offset, count);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_READ, buf, count, 11);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9pdev_request(dev, req);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9preq_waitreply(req);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9preq_deserialize(req, "d", &count);
> -	if (rc < 0)
> +	if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +		(rc = uk_9preq_write64(req, offset)) ||
> +		(rc = uk_9preq_write32(req, count)) ||
> +		(rc = send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_READ, buf,
> +				       count, 11)) ||
> +		(rc = uk_9preq_read32(req, &count)))
>  		goto out;
>  
>  	uk_pr_debug("RREAD count %u\n", count);
> @@ -353,24 +406,12 @@ int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> -	rc = uk_9preq_serialize(req, "dqd", fid->fid, offset, count);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_WRITE, (void *)buf, count, 23);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9pdev_request(dev, req);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9preq_waitreply(req);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9preq_deserialize(req, "d", &count);
> -	if (rc < 0)
> +	if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +		(rc = uk_9preq_write64(req, offset)) ||
> +		(rc = uk_9preq_write32(req, count)) ||
> +		(rc = send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_WRITE,
> +				(void *)buf, count, 23)) ||
> +		(rc = uk_9preq_read32(req, &count)))
>  		goto out;
>  
>  	uk_pr_debug("RWRITE count %u\n", count);
> @@ -386,45 +427,58 @@ struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  		struct uk_9p_stat *stat)
>  {
>  	struct uk_9preq *req;
> -	int rc;
> +	int rc = 0;
>  	uint16_t dummy;
>  
> -	uk_pr_debug("TSTAT fid %u\n", fid->fid);
> -	req = uk_9pdev_call(dev, UK_9P_TSTAT, __PAGE_SIZE, "d", fid->fid);
> +	req = uk_9pdev_req_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return req;
>  
> -	rc = uk_9preq_deserialize(req, "wS", &dummy, stat);
> -	if (rc)
> -		return ERR2PTR(rc);
> +	uk_pr_debug("TSTAT fid %u\n", fid->fid);
> +
> +	if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +		(rc = send_and_wait_no_zc(dev, req)) ||
> +		(rc = uk_9preq_read16(req, &dummy)) ||
> +		(rc = uk_9preq_readstat(req, stat)))
> +		goto out;
> +
>  	uk_pr_debug("RSTAT\n");
>  
>  	return req;
> +
> +out:
> +	uk_9pdev_req_remove(dev, req);
> +	return ERR2PTR(rc);
>  }
>  
>  int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  		struct uk_9p_stat *stat)
>  {
>  	struct uk_9preq *req;
> +	int rc = 0;
> +	uint16_t *dummy;
>  
> -	/*
> -	 * The packed size of stat is 61 bytes + the size occupied by the
> -	 * strings.
> -	 */
> -	stat->size = 61;
> -	stat->size += stat->name.size;
> -	stat->size += stat->uid.size;
> -	stat->size += stat->gid.size;
> -	stat->size += stat->muid.size;
> -	stat->size += stat->extension.size;
> -
> -	uk_pr_debug("TWSTAT fid %u\n", fid->fid);
> -	req = uk_9pdev_call(dev, UK_9P_TWSTAT, __PAGE_SIZE, "dwS", fid->fid,
> -			stat->size + 2, stat);
> +	req = uk_9pdev_req_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
> -	uk_9pdev_req_remove(dev, req);
> -	uk_pr_debug("RWSTAT");
>  
> -	return 0;
> +	uk_pr_debug("TWSTAT fid %u\n", fid->fid);
> +
> +	if ((rc = uk_9preq_write32(req, fid->fid)))
> +		goto out;
> +
> +	dummy = (uint16_t *)(req->xmit.buf + req->xmit.offset);
> +	if ((rc = uk_9preq_write16(req, 0)) ||
> +		(rc = uk_9preq_writestat(req, stat)))
> +		goto out;
> +	*dummy = stat->size + 2;
> +
> +	if ((rc = send_and_wait_no_zc(dev, req)))
> +		goto out;
> +
> +	uk_pr_debug("RWSTAT\n");
> +
> +out:
> +	uk_9pdev_req_remove(dev, req);
> +	return rc;
>  }
> diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
> index 0fc4b1e..8d787e7 100644
> --- a/lib/uk9p/9preq.c
> +++ b/lib/uk9p/9preq.c
> @@ -434,10 +434,8 @@ int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
>  
>  	UK_ASSERT(req);
>  
> -	if (UK_READ_ONCE(req->state) != UK_9PREQ_INITIALIZED) {
> -		rc = -EIO;
> -		goto out;
> -	}
> +	if (UK_READ_ONCE(req->state) != UK_9PREQ_INITIALIZED)
> +		return -EIO;
>  
>  	/* Save current offset as the size of the message. */
>  	total_size = req->xmit.offset;
> @@ -448,10 +446,10 @@ int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
>  
>  	/* Serialize the header. */
>  	req->xmit.offset = 0;
> -	rc = uk_9preq_serialize(req, "dbw", total_size_with_zc, req->xmit.type,
> -			req->tag);
> -	if (rc < 0)
> -		goto out;
> +	if ((rc = uk_9preq_write32(req, total_size_with_zc)) < 0 ||
> +		(rc = uk_9preq_write8(req, req->xmit.type)) < 0 ||
> +		(rc = uk_9preq_write16(req, req->tag)) < 0)
> +		return rc;
>  
>  	/* Reset offset and size to sane values. */
>  	req->xmit.offset = 0;
> @@ -474,8 +472,7 @@ int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
>  	/* Update the state. */
>  	UK_WRITE_ONCE(req->state, UK_9PREQ_READY);
>  
> -out:
> -	return rc;
> +	return 0;
>  }
>  
>  int uk_9preq_receive_cb(struct uk_9preq *req, uint32_t recv_size)
> @@ -495,8 +492,10 @@ int uk_9preq_receive_cb(struct uk_9preq *req, uint32_t recv_size)
>  	/* Deserialize the header into request fields. */
>  	req->recv.offset = 0;
>  	req->recv.size = recv_size;
> -	rc = _fcall_deserialize(&req->recv, "dbw", &size,
> -			&req->recv.type, &tag);
> +	if ((rc = uk_9preq_read32(req, &size)) < 0 ||
> +		(rc = uk_9preq_read8(req, &req->recv.type)) < 0 ||
> +		(rc = uk_9preq_read16(req, &tag)) < 0)
> +		return rc;
>  
>  	/* Check sanity of deserialized values. */
>  	if (rc < 0)
> @@ -557,8 +556,8 @@ int uk_9preq_error(struct uk_9preq *req)
>  	 */
>  	UK_BUGON(req->recv.offset != UK_9P_HEADER_SIZE);
>  
> -	rc = uk_9preq_deserialize(req, "sd", &error, &errcode);
> -	if (rc < 0)
> +	if ((rc = uk_9preq_readstr(req, &error)) < 0 ||
> +		(rc = uk_9preq_read32(req, &errcode)) < 0)
>  		return rc;
>  
>  	uk_pr_debug("RERROR %.*s %d\n", error.size, error.data, errcode);
> 


From minios-devel-bounces@lists.xenproject.org Sat May 16 14:27:43 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 16 May 2020 14:27: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 1jZxmx-0004B3-01; Sat, 16 May 2020 14:27: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=WrGt=66=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jZxmw-0004Aw-En
 for minios-devel@lists.xen.org; Sat, 16 May 2020 14:27:42 +0000
X-Inumbo-ID: 65f314b0-9781-11ea-a671-12813bfff9fa
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 65f314b0-9781-11ea-a671-12813bfff9fa;
 Sat, 16 May 2020 14:27:41 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 545F4B5624E7;
 Sat, 16 May 2020 17:27:40 +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 L_wlvKY7gZZ3; Sat, 16 May 2020 17:27:36 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 176B7B5627D0;
 Sat, 16 May 2020 17:27:36 +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 gstZg9nN61DZ; Sat, 16 May 2020 17:27:35 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.26.181.84])
 by mx.upb.ro (Postfix) with ESMTPSA id C595BB562302;
 Sat, 16 May 2020 17:27:35 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v2 3/9] lib/uk9p: Delete the old serialization
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200509164413.38078-1-cristb@gmail.com>
 <20200509164413.38078-4-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <2a7b876a-1b50-2900-f314-6189bdc6ebc6@cs.pub.ro>
Date: Sat, 16 May 2020 17:27:35 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200509164413.38078-4-cristb@gmail.com>
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>

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/9/20 7:44 PM, Cristian Banu wrote:
> This patch deletes the old serialization implementation and removes
> the functions from exportsyms.uk.
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/uk9p/9pdev.c            |  36 -----
>  lib/uk9p/9preq.c            | 287 ------------------------------------
>  lib/uk9p/exportsyms.uk      |   7 -
>  lib/uk9p/include/uk/9pdev.h |  23 ---
>  lib/uk9p/include/uk/9preq.h |  55 -------
>  5 files changed, 408 deletions(-)
> 
> diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
> index 14ea7ca..1d7e09b 100644
> --- a/lib/uk9p/9pdev.c
> +++ b/lib/uk9p/9pdev.c
> @@ -288,42 +288,6 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev)
>  #endif
>  }
>  
> -struct uk_9preq *uk_9pdev_call(struct uk_9pdev *dev, uint8_t type,
> -			uint32_t size, const char *fmt, ...)
> -{
> -	struct uk_9preq *req;
> -	va_list vl;
> -	int rc;
> -
> -	req = uk_9pdev_req_create(dev, type, size);
> -	if (PTRISERR(req))
> -		return req;
> -
> -	va_start(vl, fmt);
> -	rc = uk_9preq_vserialize(req, fmt, vl);
> -	va_end(vl);
> -
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9preq_ready(req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9pdev_request(dev, req);
> -	if (rc < 0)
> -		goto out;
> -
> -	rc = uk_9preq_waitreply(req);
> -	if (rc < 0)
> -		goto out;
> -
> -	return req;
> -out:
> -	uk_9pdev_req_remove(dev, req);
> -	return ERR2PTR(rc);
> -}
> -
>  struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
>  				uint32_t size)
>  {
> diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
> index 8d787e7..997f772 100644
> --- a/lib/uk9p/9preq.c
> +++ b/lib/uk9p/9preq.c
> @@ -138,293 +138,6 @@ int uk_9preq_put(struct uk_9preq *req)
>  	return last;
>  }
>  
> -static int _fcall_write(struct uk_9preq_fcall *fcall, const void *buf,
> -		uint32_t size)
> -{
> -	if (fcall->offset + size > fcall->size)
> -		return -ENOBUFS;
> -
> -	memcpy((char *)fcall->buf + fcall->offset, buf, size);
> -	fcall->offset += size;
> -	return 0;
> -}
> -
> -static int _fcall_serialize(struct uk_9preq_fcall *f, const char *fmt, ...);
> -
> -static int _fcall_vserialize(struct uk_9preq_fcall *fcall, const char *fmt,
> -			va_list vl)
> -{
> -	int rc = 0;
> -
> -	while (*fmt) {
> -		switch (*fmt) {
> -		case 'b': {
> -			uint8_t x;
> -
> -			x = va_arg(vl, unsigned int);
> -			rc = _fcall_write(fcall, &x, sizeof(x));
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 'w': {
> -			uint16_t x;
> -
> -			x = va_arg(vl, unsigned int);
> -			rc = _fcall_write(fcall, &x, sizeof(x));
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 'd': {
> -			uint32_t x;
> -
> -			x = va_arg(vl, uint32_t);
> -			rc = _fcall_write(fcall, &x, sizeof(x));
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 'q': {
> -			uint64_t x;
> -
> -			x = va_arg(vl, uint64_t);
> -			rc = _fcall_write(fcall, &x, sizeof(x));
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 's': {
> -			struct uk_9p_str *p;
> -
> -			p = va_arg(vl, struct uk_9p_str *);
> -			rc = _fcall_write(fcall, &p->size, sizeof(p->size));
> -			if (rc < 0)
> -				goto out;
> -			rc = _fcall_write(fcall, p->data, p->size);
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 'Q': {
> -			struct uk_9p_qid *p;
> -
> -			p = va_arg(vl, struct uk_9p_qid *);
> -			rc = _fcall_serialize(fcall, "bdq", p->type,
> -					p->version, p->path);
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 'S': {
> -			struct uk_9p_stat *p;
> -
> -			p = va_arg(vl, struct uk_9p_stat *);
> -			rc = _fcall_serialize(fcall, "wwdQdddqsssssddd",
> -					p->size, p->type, p->dev, &p->qid,
> -					p->mode, p->atime, p->mtime, p->length,
> -					&p->name, &p->uid, &p->gid, &p->muid,
> -					&p->extension, p->n_uid, p->n_gid,
> -					p->n_muid);
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		default:
> -			rc = -EINVAL;
> -			goto out;
> -		}
> -
> -		fmt++;
> -	}
> -
> -out:
> -	return rc;
> -}
> -
> -static int _fcall_serialize(struct uk_9preq_fcall *f, const char *fmt, ...)
> -{
> -	va_list vl;
> -	int rc;
> -
> -	va_start(vl, fmt);
> -	rc = _fcall_vserialize(f, fmt, vl);
> -	va_end(vl);
> -
> -	return rc;
> -}
> -
> -int uk_9preq_vserialize(struct uk_9preq *req, const char *fmt, va_list vl)
> -{
> -	int rc;
> -
> -	UK_ASSERT(req);
> -	UK_ASSERT(UK_READ_ONCE(req->state) == UK_9PREQ_INITIALIZED);
> -	rc = _fcall_vserialize(&req->xmit, fmt, vl);
> -
> -	return rc;
> -}
> -
> -int uk_9preq_serialize(struct uk_9preq *req, const char *fmt, ...)
> -{
> -	va_list vl;
> -	int rc;
> -
> -	va_start(vl, fmt);
> -	rc = uk_9preq_vserialize(req, fmt, vl);
> -	va_end(vl);
> -
> -	return rc;
> -}
> -
> -static int _fcall_read(struct uk_9preq_fcall *fcall, void *buf, uint32_t size)
> -{
> -	if (fcall->offset + size > fcall->size)
> -		return -ENOBUFS;
> -
> -	memcpy(buf, (char *)fcall->buf + fcall->offset, size);
> -	fcall->offset += size;
> -	return 0;
> -}
> -
> -static int _fcall_deserialize(struct uk_9preq_fcall *f, const char *fmt, ...);
> -
> -static int _fcall_vdeserialize(struct uk_9preq_fcall *fcall,
> -			      const char *fmt,
> -			      va_list vl)
> -{
> -	int rc = 0;
> -
> -	while (*fmt) {
> -		switch (*fmt) {
> -		case 'b': {
> -			uint8_t *x;
> -
> -			x = va_arg(vl, uint8_t *);
> -			rc = _fcall_read(fcall, x, sizeof(*x));
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 'w': {
> -			uint16_t *x;
> -
> -			x = va_arg(vl, uint16_t *);
> -			rc = _fcall_read(fcall, x, sizeof(*x));
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 'd': {
> -			uint32_t *x;
> -
> -			x = va_arg(vl, uint32_t *);
> -			rc = _fcall_read(fcall, x, sizeof(*x));
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 'q': {
> -			uint64_t *x;
> -
> -			x = va_arg(vl, uint64_t *);
> -			rc = _fcall_read(fcall, x, sizeof(*x));
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 's': {
> -			struct uk_9p_str *p;
> -
> -			p = va_arg(vl, struct uk_9p_str *);
> -			rc = _fcall_read(fcall, &p->size, sizeof(p->size));
> -			if (rc < 0)
> -				goto out;
> -			p->data = (char *)fcall->buf + fcall->offset;
> -			fcall->offset += p->size;
> -			break;
> -		}
> -		case 'Q': {
> -			struct uk_9p_qid *p;
> -
> -			p = va_arg(vl, struct uk_9p_qid *);
> -			rc = _fcall_deserialize(fcall, "bdq", &p->type,
> -					&p->version, &p->path);
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		case 'S': {
> -			struct uk_9p_stat *p;
> -
> -			p = va_arg(vl, struct uk_9p_stat *);
> -			rc = _fcall_deserialize(fcall, "wwdQdddqsssssddd",
> -					&p->size, &p->type, &p->dev, &p->qid,
> -					&p->mode, &p->atime, &p->mtime,
> -					&p->length, &p->name, &p->uid, &p->gid,
> -					&p->muid, &p->extension, &p->n_uid,
> -					&p->n_gid, &p->n_muid);
> -			if (rc < 0)
> -				goto out;
> -			break;
> -		}
> -		default:
> -			rc = -EINVAL;
> -			goto out;
> -		}
> -
> -		fmt++;
> -	}
> -
> -out:
> -	return rc;
> -}
> -
> -static int _fcall_deserialize(struct uk_9preq_fcall *f, const char *fmt, ...)
> -{
> -	va_list vl;
> -	int rc;
> -
> -	va_start(vl, fmt);
> -	rc = _fcall_vdeserialize(f, fmt, vl);
> -	va_end(vl);
> -
> -	return rc;
> -}
> -
> -int uk_9preq_vdeserialize(struct uk_9preq *req, const char *fmt, va_list vl)
> -{
> -	int rc;
> -
> -	UK_ASSERT(req);
> -	UK_ASSERT(UK_READ_ONCE(req->state) == UK_9PREQ_RECEIVED);
> -	rc = _fcall_vdeserialize(&req->recv, fmt, vl);
> -
> -	return rc;
> -}
> -
> -int uk_9preq_deserialize(struct uk_9preq *req, const char *fmt, ...)
> -{
> -	va_list vl;
> -	int rc;
> -
> -	va_start(vl, fmt);
> -	rc = uk_9preq_vdeserialize(req, fmt, vl);
> -	va_end(vl);
> -
> -	return rc;
> -}
> -
> -int uk_9preq_copy_to(struct uk_9preq *req, void *buf, uint32_t size)
> -{
> -	return _fcall_read(&req->recv, buf, size);
> -}
> -
> -int uk_9preq_copy_from(struct uk_9preq *req, const void *buf, uint32_t size)
> -{
> -	return _fcall_write(&req->xmit, buf, size);
> -}
> -
>  int uk_9preq_ready(struct uk_9preq *req, enum uk_9preq_zcdir zc_dir,
>  		void *zc_buf, uint32_t zc_size, uint32_t zc_offset)
>  {
> diff --git a/lib/uk9p/exportsyms.uk b/lib/uk9p/exportsyms.uk
> index aae9e8a..7f8e7dd 100644
> --- a/lib/uk9p/exportsyms.uk
> +++ b/lib/uk9p/exportsyms.uk
> @@ -5,12 +5,6 @@ uk_9pdev_trans_set_default
>  
>  uk_9preq_get
>  uk_9preq_put
> -uk_9preq_vserialize
> -uk_9preq_serialize
> -uk_9preq_vdeserialize
> -uk_9preq_deserialize
> -uk_9preq_copy_to
> -uk_9preq_copy_from
>  uk_9preq_receive_cb
>  uk_9preq_waitreply
>  uk_9preq_error
> @@ -19,7 +13,6 @@ uk_9pdev_connect
>  uk_9pdev_disconnect
>  uk_9pdev_request
>  uk_9pdev_xmit_notify
> -uk_9pdev_call
>  uk_9pdev_set_msize
>  uk_9pdev_get_msize
>  
> diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
> index 139498f..04ff523 100644
> --- a/lib/uk9p/include/uk/9pdev.h
> +++ b/lib/uk9p/include/uk/9pdev.h
> @@ -107,29 +107,6 @@ int uk_9pdev_request(struct uk_9pdev *dev, struct uk_9preq *req);
>   */
>  void uk_9pdev_xmit_notify(struct uk_9pdev *dev);
>  
> -/**
> - * Creates and sends 9P request to the given 9P device, serializing it with
> - * the given arguments. This function acts as a shorthand for the explicit
> - * calls to req_create(), serialize(), ready(), request(), waitreply().
> - *
> - * @param dev
> - *   The Unikraft 9P Device.
> - * @param type
> - *   Transmit type of the request, e.g. Tversion, Tread, and so on.
> - * @param size
> - *   The maximum size for the receive and send buffers.
> - * @param fmt
> - *   The format of the data to be serialized, in the way uk_9preq_serialize()
> - *   expects it.
> - * @param ...
> - *   The arguments to be serialized.
> - * @return
> - *   - (!PTRISERR): The 9p request in the UK_9PREQ_RECEIVED state.
> - *   - PTRISERR: The error code with which any of the steps failed.
> - */
> -struct uk_9preq *uk_9pdev_call(struct uk_9pdev *dev, uint8_t type,
> -			uint32_t size, const char *fmt, ...);
> -
>  /**
>   * Create a new request, automatically allocating its tag, based on its type.
>   *
> diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
> index 70c1b03..b9713e2 100644
> --- a/lib/uk9p/include/uk/9preq.h
> +++ b/lib/uk9p/include/uk/9preq.h
> @@ -182,61 +182,6 @@ void uk_9preq_get(struct uk_9preq *req);
>   */
>  int uk_9preq_put(struct uk_9preq *req);
>  
> -/*
> - * The following family of serialization and deserialization functions work
> - * by employing a printf-like formatting mechanism for data types supported by
> - * the 9p protocol:
> - * - 'b': byte (uint8_t)
> - * - 'w': word (uint16_t)
> - * - 'd': double-word (uint32_t)
> - * - 'q': quad-word (uint64_t)
> - * - 's': uk_9p_str *
> - * - 'S': uk_9p_stat *
> - *
> - * Similarly to vprintf(), the vserialize() and vdeserialize() functions take
> - * a va_list instead of a variable number of arguments.
> - *
> - * Possible return values:
> - * - 0: Operation successful.
> - * - (-EINVAL): Invalid format specifier.
> - * - (-ENOBUFS): End of buffer reached.
> - */
> -
> -int uk_9preq_vserialize(struct uk_9preq *req, const char *fmt, va_list vl);
> -int uk_9preq_serialize(struct uk_9preq *req, const char *fmt, ...);
> -int uk_9preq_vdeserialize(struct uk_9preq *req, const char *fmt, va_list vl);
> -int uk_9preq_deserialize(struct uk_9preq *req, const char *fmt, ...);
> -
> -/**
> - * Copies raw data from the request receive buffer to the provided buffer.
> - *
> - * @param req
> - *   Reference to the 9p request.
> - * @param buf
> - *   Destination buffer.
> - * @param size
> - *   Amount to copy.
> - * Possible return values:
> - * - 0: Operation successful.
> - * - (-ENOBUFS): End of buffer reached.
> - */
> -int uk_9preq_copy_to(struct uk_9preq *req, void *buf, uint32_t size);
> -
> -/**
> - * Copies raw data from the provided buffer to the request transmission buffer.
> - *
> - * @param req
> - *   Reference to the 9p request.
> - * @param buf
> - *   Source buffer.
> - * @param size
> - *   Amount to copy.
> - * Possible return values:
> - * - 0: Operation successful.
> - * - (-ENOBUFS): End of buffer reached.
> - */
> -int uk_9preq_copy_from(struct uk_9preq *req, const void *buf, uint32_t size);
> -
>  /**
>   * Marks the given request as being ready, transitioning between states
>   * INITIALIZED and READY.
> 


From minios-devel-bounces@lists.xenproject.org Sat May 16 14:27:55 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 16 May 2020 14:27:55 +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 1jZxn9-0004CH-2z; Sat, 16 May 2020 14:27:55 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=WrGt=66=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jZxn8-0004CA-C6
 for minios-devel@lists.xen.org; Sat, 16 May 2020 14:27:54 +0000
X-Inumbo-ID: 6d74320a-9781-11ea-9887-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.5])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 6d74320a-9781-11ea-9887-bc764e2007e4;
 Sat, 16 May 2020 14:27:53 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id DDCEDB5627F6;
 Sat, 16 May 2020 17:27:52 +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 0rU6ITmVgAXY; Sat, 16 May 2020 17:27:50 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 984F7B5627EC;
 Sat, 16 May 2020 17:27:50 +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 uZzE1Pe9jLZw; Sat, 16 May 2020 17:27:50 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.26.181.84])
 by mx.upb.ro (Postfix) with ESMTPSA id 63139B5627E5;
 Sat, 16 May 2020 17:27:50 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v2 4/9] lib/uk9p: Simplify uk_9p_walk
 serialization
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200509164413.38078-1-cristb@gmail.com>
 <20200509164413.38078-5-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <5590be2b-c3f1-72e4-65fa-db41714744c9@cs.pub.ro>
Date: Sat, 16 May 2020 17:27:50 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200509164413.38078-5-cristb@gmail.com>
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>

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/9/20 7:44 PM, Cristian Banu wrote:
> Unifies two if branches with common code in uk_9p_walk.
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/uk9p/9p.c | 25 +++++++++----------------
>  1 file changed, 9 insertions(+), 16 deletions(-)
> 
> diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
> index 638555b..f17a938 100644
> --- a/lib/uk9p/9p.c
> +++ b/lib/uk9p/9p.c
> @@ -195,22 +195,15 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  		goto out;
>  	}
>  
> -	if (name) {
> -		uk_pr_debug("TWALK fid %u newfid %u nwname %d name %s\n",
> -				fid->fid, newfid->fid, nwname, name);
> -		if ((rc = uk_9preq_write32(req, fid->fid)) ||
> -			(rc = uk_9preq_write32(req, newfid->fid)) ||
> -			(rc = uk_9preq_write16(req, nwname)) ||
> -			(rc = uk_9preq_writestr(req, &name_str)))
> -			goto out;
> -	} else {
> -		uk_pr_debug("TWALK fid %u newfid %u nwname %d\n",
> -				fid->fid, newfid->fid, nwname);
> -		if ((rc = uk_9preq_write32(req, fid->fid)) ||
> -			(rc = uk_9preq_write32(req, newfid->fid)) ||
> -			(rc = uk_9preq_write16(req, nwname)))
> -			goto out;
> -	}
> +	uk_pr_debug("TWALK fid %u newfid %u nwname %d name %s\n",
> +		fid->fid, newfid->fid, nwname, name ? name : "<NULL>");
> +
> +	if ((rc = uk_9preq_write32(req, fid->fid)) ||
> +		(rc = uk_9preq_write32(req, newfid->fid)) ||
> +		(rc = uk_9preq_write16(req, nwname)))
> +		goto out;
> +	if (name && (rc = uk_9preq_writestr(req, &name_str)))
> +		goto out;
>  
>  	if ((rc = send_and_wait_no_zc(dev, req))) {
>  		/*
> 


From minios-devel-bounces@lists.xenproject.org Sat May 16 14:28:08 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 16 May 2020 14:28:08 +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 1jZxnM-0004DX-4z; Sat, 16 May 2020 14:28:08 +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=WrGt=66=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jZxnK-0004DJ-Sa
 for minios-devel@lists.xen.org; Sat, 16 May 2020 14:28:06 +0000
X-Inumbo-ID: 74e8bb64-9781-11ea-a671-12813bfff9fa
Received: from mx.upb.ro (unknown [141.85.13.5])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 74e8bb64-9781-11ea-a671-12813bfff9fa;
 Sat, 16 May 2020 14:28:06 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 695E6B562302;
 Sat, 16 May 2020 17:28:05 +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 6yqtTCjmuXx2; Sat, 16 May 2020 17:28:02 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 7A16CB5627AD;
 Sat, 16 May 2020 17:28:02 +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 qyZ9nuE6fOmg; Sat, 16 May 2020 17:28:02 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.26.181.84])
 by mx.upb.ro (Postfix) with ESMTPSA id 41B9DB562704;
 Sat, 16 May 2020 17:28:02 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v2 5/9] lib/uk9p: Add uk_traces
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200509164413.38078-1-cristb@gmail.com>
 <20200509164413.38078-6-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <f79f6bdd-70ba-0274-b7bb-14aa00139352@cs.pub.ro>
Date: Sat, 16 May 2020 17:28:02 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200509164413.38078-6-cristb@gmail.com>
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>

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/9/20 7:44 PM, Cristian Banu wrote:
> This patch enables nanosecond-resolution tracing of 9pfs performance.
> 
> Excerpt from the output traces for a read():
> 2167560470  uk_9p_trace_request_create
> 2167564237  uk_9p_trace_request_allocated
> 2167564277  uk_9p_trace_ready              tag 0
> 2167567134  uk_9p_trace_sent               tag 0
> 2167625854  uk_9p_trace_received           tag 0
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/uk9p/9p.c | 57 +++++++++++++++++++++++++++++++++++++--------------
>  1 file changed, 42 insertions(+), 15 deletions(-)
> 
> diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
> index f17a938..14ba299 100644
> --- a/lib/uk9p/9p.c
> +++ b/lib/uk9p/9p.c
> @@ -39,6 +39,13 @@
>  #include <uk/9pdev.h>
>  #include <uk/9preq.h>
>  #include <uk/9pfid.h>
> +#include <uk/trace.h>
> +
> +UK_TRACEPOINT(uk_9p_trace_request_create, "");
> +UK_TRACEPOINT(uk_9p_trace_request_allocated, "");
> +UK_TRACEPOINT(uk_9p_trace_ready, "tag %u", uint16_t);
> +UK_TRACEPOINT(uk_9p_trace_sent, "tag %u", uint16_t);
> +UK_TRACEPOINT(uk_9p_trace_received, "tag %u", uint16_t);
>  
>  static inline int send_and_wait_zc(struct uk_9pdev *dev, struct uk_9preq *req,
>  		enum uk_9preq_zcdir zc_dir, void *zc_buf, uint32_t zc_size,
> @@ -46,10 +53,17 @@ static inline int send_and_wait_zc(struct uk_9pdev *dev, struct uk_9preq *req,
>  {
>  	int rc;
>  
> -	if ((rc = uk_9preq_ready(req, zc_dir, zc_buf, zc_size, zc_offset)) ||
> -		(rc = uk_9pdev_request(dev, req)) ||
> -		(rc = uk_9preq_waitreply(req)))
> +	if ((rc = uk_9preq_ready(req, zc_dir, zc_buf, zc_size, zc_offset)))
> +		return rc;
> +	uk_9p_trace_ready(req->tag);
> +
> +	if ((rc = uk_9pdev_request(dev, req)))
>  		return rc;
> +	uk_9p_trace_sent(req->tag);
> +
> +	if ((rc = uk_9preq_waitreply(req)))
> +		return rc;
> +	uk_9p_trace_received(req->tag);
>  
>  	return 0;
>  }
> @@ -60,6 +74,19 @@ static inline int send_and_wait_no_zc(struct uk_9pdev *dev,
>  	return send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
>  }
>  
> +static struct uk_9preq *request_create(struct uk_9pdev *dev,
> +		uint8_t type, uint32_t size)
> +{
> +	struct uk_9preq *req;
> +
> +	uk_9p_trace_request_create();
> +	req = uk_9pdev_req_create(dev, type, size);
> +	if (!PTRISERR(req))
> +		uk_9p_trace_request_allocated();
> +
> +	return req;
> +}
> +
>  struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
>  		const char *requested, struct uk_9p_str *received)
>  {
> @@ -70,7 +97,7 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
>  
>  	uk_9p_str_init(&requested_str, requested);
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return req;
>  
> @@ -119,7 +146,7 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
>  	if (PTRISERR(fid))
>  		return fid;
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
>  	if (PTRISERR(req)) {
>  		uk_9pdev_fid_release(fid);
>  		return (void *)req;
> @@ -156,7 +183,7 @@ int uk_9p_flush(struct uk_9pdev *dev, uint16_t oldtag)
>  	struct uk_9preq *req;
>  	int rc = 0;
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -189,7 +216,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  
>  	nwname = name ? 1 : 0;
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TWALK, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TWALK, __PAGE_SIZE);
>  	if (PTRISERR(req)) {
>  		rc = PTR2ERR(req);
>  		goto out;
> @@ -245,7 +272,7 @@ int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
>  	struct uk_9preq *req;
>  	int rc = 0;
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -279,7 +306,7 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	uk_9p_str_init(&name_str, name);
>  	uk_9p_str_init(&extension_str, extension);
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -312,7 +339,7 @@ int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
>  	/* The fid is considered invalid even if the remove fails. */
>  	fid->was_removed = 1;
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -335,7 +362,7 @@ int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
>  	if (fid->was_removed)
>  		return 0;
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -363,7 +390,7 @@ int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	uk_pr_debug("TREAD fid %u offset %lu count %u\n", fid->fid,
>  			offset, count);
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TREAD, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TREAD, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -395,7 +422,7 @@ int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  
>  	uk_pr_debug("TWRITE fid %u offset %lu count %u\n", fid->fid,
>  			offset, count);
> -	req = uk_9pdev_req_create(dev, UK_9P_TWRITE, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TWRITE, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -423,7 +450,7 @@ struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	int rc = 0;
>  	uint16_t dummy;
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return req;
>  
> @@ -451,7 +478,7 @@ int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	int rc = 0;
>  	uint16_t *dummy;
>  
> -	req = uk_9pdev_req_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> 


From minios-devel-bounces@lists.xenproject.org Sat May 16 14:28:21 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 16 May 2020 14:28: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 1jZxnZ-0004EY-6w; Sat, 16 May 2020 14:28:21 +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=WrGt=66=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jZxnX-0004EN-Tu
 for minios-devel@lists.xen.org; Sat, 16 May 2020 14:28:19 +0000
X-Inumbo-ID: 7bf360bd-9781-11ea-a671-12813bfff9fa
Received: from mx.upb.ro (unknown [141.85.13.5])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 7bf360bd-9781-11ea-a671-12813bfff9fa;
 Sat, 16 May 2020 14:28:19 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id B83A2B56217B;
 Sat, 16 May 2020 17:28:18 +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 CQuN1vWsLyhg; Sat, 16 May 2020 17:28:16 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 8E37BB5627D0;
 Sat, 16 May 2020 17:28:16 +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 CBnYoIS5YStK; Sat, 16 May 2020 17:28:16 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.26.181.84])
 by mx.upb.ro (Postfix) with ESMTPSA id 54661B562302;
 Sat, 16 May 2020 17:28:16 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v2 6/9] lib/uk9p: Change severity of
 uk_9p_version log
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200509164413.38078-1-cristb@gmail.com>
 <20200509164413.38078-7-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <8c31d324-793c-3d2a-fc14-c18fa35713c5@cs.pub.ro>
Date: Sat, 16 May 2020 17:28:16 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200509164413.38078-7-cristb@gmail.com>
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>

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/9/20 7:44 PM, Cristian Banu wrote:
> Even though 9p can continue execution if the negotiated message
> size violates the 9p specification, this should be a warning,
> not a debug message.
> 
> Also fixes a typo "Howevver".
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/uk9p/9p.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
> index 14ba299..4acb0c6 100644
> --- a/lib/uk9p/9p.c
> +++ b/lib/uk9p/9p.c
> @@ -116,12 +116,12 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
>  
>  	/*
>  	 * Note: the 9P specification mentions that new_msize <= dev->msize.
> -	 * Howevver, execution can continue even if the invariant is violated
> +	 * However, execution can continue even if the invariant is violated
>  	 * and set_msize() fails, as the old message size is always within the
>  	 * accepted limit.
>  	 */
>  	if (!uk_9pdev_set_msize(dev, new_msize))
> -		uk_pr_debug("Invalid new message size.\n");
> +		uk_pr_warn("Invalid new message size.\n");
>  
>  	return req;
>  
> 


From minios-devel-bounces@lists.xenproject.org Sat May 16 14:28:34 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 16 May 2020 14:28: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 1jZxnm-0004Hk-8s; Sat, 16 May 2020 14:28: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=WrGt=66=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jZxnl-0004Hd-FW
 for minios-devel@lists.xen.org; Sat, 16 May 2020 14:28:33 +0000
X-Inumbo-ID: 84d92f7c-9781-11ea-a671-12813bfff9fa
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 84d92f7c-9781-11ea-a671-12813bfff9fa;
 Sat, 16 May 2020 14:28:33 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 29590B562040;
 Sat, 16 May 2020 17:28:32 +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 R-5qqbXr7G-A; Sat, 16 May 2020 17:28:28 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 46716B5627D0;
 Sat, 16 May 2020 17:28:28 +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 E6CeiRpFNVeN; Sat, 16 May 2020 17:28:28 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.26.181.84])
 by mx.upb.ro (Postfix) with ESMTPSA id 14AC3B562772;
 Sat, 16 May 2020 17:28:28 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v2 7/9] lib/uk9p: Use fixed-size request buffers
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200509164413.38078-1-cristb@gmail.com>
 <20200509164413.38078-8-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <c3b283fc-48e8-759f-f181-3509e9f55a7a@cs.pub.ro>
Date: Sat, 16 May 2020 17:28:27 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200509164413.38078-8-cristb@gmail.com>
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>

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/9/20 7:44 PM, Cristian Banu wrote:
> Use fixed-size request buffers instead of dynamically allocating new
> receive and transmit buffers for each new request. This reduces the
> number of calls to uk_alloc from 3 to 1 per each uk_9pdev_req_create()
> call.
> 
> Allocating a request is faster by roughly 2.5 microseconds. The
> previous patch in this patch series shows a 3.7us delay between read
> and request_allocated. The excerpt below shows roughly 1us delay.
> This performance benefit is observed at a larger scale as well (in
> latency and throughput benchmarks).
> 
> Excerpt from the output traces for a read():
> 
> 1350682319  uk_9p_trace_request_create
> 1350683329  uk_9p_trace_request_allocated
> 1350683375  uk_9p_trace_ready              tag 0
> 1350686009  uk_9p_trace_sent               tag 0
> 1350748124  uk_9p_trace_received           tag 0
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/uk9p/9p.c               | 29 +++++++-------
>  lib/uk9p/9pdev.c            | 11 +++---
>  lib/uk9p/9preq.c            | 76 ++++++++-----------------------------
>  lib/uk9p/include/uk/9pdev.h |  5 +--
>  lib/uk9p/include/uk/9preq.h | 31 +++++++++++++--
>  5 files changed, 65 insertions(+), 87 deletions(-)
> 
> diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
> index 4acb0c6..9ac7e8a 100644
> --- a/lib/uk9p/9p.c
> +++ b/lib/uk9p/9p.c
> @@ -74,13 +74,12 @@ static inline int send_and_wait_no_zc(struct uk_9pdev *dev,
>  	return send_and_wait_zc(dev, req, UK_9PREQ_ZCDIR_NONE, NULL, 0, 0);
>  }
>  
> -static struct uk_9preq *request_create(struct uk_9pdev *dev,
> -		uint8_t type, uint32_t size)
> +static struct uk_9preq *request_create(struct uk_9pdev *dev, uint8_t type)
>  {
>  	struct uk_9preq *req;
>  
>  	uk_9p_trace_request_create();
> -	req = uk_9pdev_req_create(dev, type, size);
> +	req = uk_9pdev_req_create(dev, type);
>  	if (!PTRISERR(req))
>  		uk_9p_trace_request_allocated();
>  
> @@ -97,7 +96,7 @@ struct uk_9preq *uk_9p_version(struct uk_9pdev *dev,
>  
>  	uk_9p_str_init(&requested_str, requested);
>  
> -	req = request_create(dev, UK_9P_TVERSION, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TVERSION);
>  	if (PTRISERR(req))
>  		return req;
>  
> @@ -146,7 +145,7 @@ struct uk_9pfid *uk_9p_attach(struct uk_9pdev *dev, uint32_t afid,
>  	if (PTRISERR(fid))
>  		return fid;
>  
> -	req = request_create(dev, UK_9P_TATTACH, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TATTACH);
>  	if (PTRISERR(req)) {
>  		uk_9pdev_fid_release(fid);
>  		return (void *)req;
> @@ -183,7 +182,7 @@ int uk_9p_flush(struct uk_9pdev *dev, uint16_t oldtag)
>  	struct uk_9preq *req;
>  	int rc = 0;
>  
> -	req = request_create(dev, UK_9P_TFLUSH, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TFLUSH);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -216,7 +215,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  
>  	nwname = name ? 1 : 0;
>  
> -	req = request_create(dev, UK_9P_TWALK, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TWALK);
>  	if (PTRISERR(req)) {
>  		rc = PTR2ERR(req);
>  		goto out;
> @@ -272,7 +271,7 @@ int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
>  	struct uk_9preq *req;
>  	int rc = 0;
>  
> -	req = request_create(dev, UK_9P_TOPEN, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TOPEN);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -306,7 +305,7 @@ int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	uk_9p_str_init(&name_str, name);
>  	uk_9p_str_init(&extension_str, extension);
>  
> -	req = request_create(dev, UK_9P_TCREATE, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TCREATE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -339,7 +338,7 @@ int uk_9p_remove(struct uk_9pdev *dev, struct uk_9pfid *fid)
>  	/* The fid is considered invalid even if the remove fails. */
>  	fid->was_removed = 1;
>  
> -	req = request_create(dev, UK_9P_TREMOVE, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TREMOVE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -362,7 +361,7 @@ int uk_9p_clunk(struct uk_9pdev *dev, struct uk_9pfid *fid)
>  	if (fid->was_removed)
>  		return 0;
>  
> -	req = request_create(dev, UK_9P_TCLUNK, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TCLUNK);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -390,7 +389,7 @@ int64_t uk_9p_read(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	uk_pr_debug("TREAD fid %u offset %lu count %u\n", fid->fid,
>  			offset, count);
>  
> -	req = request_create(dev, UK_9P_TREAD, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TREAD);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -422,7 +421,7 @@ int64_t uk_9p_write(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  
>  	uk_pr_debug("TWRITE fid %u offset %lu count %u\n", fid->fid,
>  			offset, count);
> -	req = request_create(dev, UK_9P_TWRITE, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TWRITE);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> @@ -450,7 +449,7 @@ struct uk_9preq *uk_9p_stat(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	int rc = 0;
>  	uint16_t dummy;
>  
> -	req = request_create(dev, UK_9P_TSTAT, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TSTAT);
>  	if (PTRISERR(req))
>  		return req;
>  
> @@ -478,7 +477,7 @@ int uk_9p_wstat(struct uk_9pdev *dev, struct uk_9pfid *fid,
>  	int rc = 0;
>  	uint16_t *dummy;
>  
> -	req = request_create(dev, UK_9P_TWSTAT, __PAGE_SIZE);
> +	req = request_create(dev, UK_9P_TWSTAT);
>  	if (PTRISERR(req))
>  		return PTR2ERR(req);
>  
> diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
> index 1d7e09b..40a4daa 100644
> --- a/lib/uk9p/9pdev.c
> +++ b/lib/uk9p/9pdev.c
> @@ -288,8 +288,7 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev)
>  #endif
>  }
>  
> -struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
> -				uint32_t size)
> +struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type)
>  {
>  	struct uk_9preq *req;
>  	int rc = 0;
> @@ -298,14 +297,16 @@ struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
>  
>  	UK_ASSERT(dev);
>  
> -	size = MIN(size, dev->msize);
> -
> -	req = uk_9preq_alloc(dev->a, size);
> +	req = uk_9preq_alloc(dev->a);
>  	if (req == NULL) {
>  		rc = -ENOMEM;
>  		goto out;
>  	}
>  
> +	/* Shouldn't exceed the msize on non-zerocopy buffers, just in case. */
> +	req->recv.size = MIN(req->recv.size, dev->msize);
> +	req->xmit.size = MIN(req->xmit.size, dev->msize);
> +
>  	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
>  	if (type == UK_9P_TVERSION)
>  		tag = UK_9P_NOTAG;
> diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
> index 997f772..d44e684 100644
> --- a/lib/uk9p/9preq.c
> +++ b/lib/uk9p/9preq.c
> @@ -45,51 +45,28 @@
>  #include <uk/wait.h>
>  #endif
>  
> -static int _fcall_alloc(struct uk_alloc *a, struct uk_9preq_fcall *f,
> -			uint32_t size)
> -{
> -	UK_ASSERT(a);
> -	UK_ASSERT(f);
> -	UK_ASSERT(size > 0);
> -
> -	f->buf = uk_calloc(a, size, sizeof(char));
> -	if (f->buf == NULL)
> -		return -ENOMEM;
> -
> -	f->size = size;
> -	f->offset = 0;
> -	f->zc_buf = NULL;
> -	f->zc_size = 0;
> -	f->zc_offset = 0;
> -
> -	return 0;
> -}
> -
> -static void _fcall_free(struct uk_alloc *a, struct uk_9preq_fcall *f)
> -{
> -	UK_ASSERT(a);
> -	UK_ASSERT(f);
> -
> -	if (f->buf)
> -		uk_free(a, f->buf);
> -}
> -
> -struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a, uint32_t size)
> +struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a)
>  {
>  	struct uk_9preq *req;
> -	int rc;
>  
>  	req = uk_calloc(a, 1, sizeof(*req));
>  	if (req == NULL)
> -		goto out;
> +		return NULL;
>  
> -	rc = _fcall_alloc(a, &req->xmit, size);
> -	if (rc < 0)
> -		goto out_free;
> +	req->xmit.buf = req->xmit_buf;
> +	req->recv.buf = req->recv_buf;
> +	req->xmit.size = req->recv.size = UK_9P_BUFSIZE;
> +	req->xmit.zc_buf = req->recv.zc_buf = NULL;
> +	req->xmit.zc_size = req->recv.zc_size = 0;
> +	req->xmit.zc_offset = req->recv.zc_offset = 0;
>  
> -	rc = _fcall_alloc(a, &req->recv, MAX(size, UK_9P_RERROR_MAXSIZE));
> -	if (rc < 0)
> -		goto out_free;
> +	/*
> +	 * Assume the header has already been written.
> +	 * The header itself will be written on uk_9preq_ready(), when the
> +	 * actual message size is known.
> +	 */
> +	req->xmit.offset = UK_9P_HEADER_SIZE;
> +	req->recv.offset = 0;
>  
>  	UK_INIT_LIST_HEAD(&req->_list);
>  	req->_a = a;
> @@ -98,28 +75,7 @@ struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a, uint32_t size)
>  	uk_waitq_init(&req->wq);
>  #endif
>  
> -	/*
> -	 * Assume the header has already been written.
> -	 * The header itself will be written on uk_9preq_ready(), when the
> -	 * actual message size is known.
> -	 */
> -	req->xmit.offset = UK_9P_HEADER_SIZE;
> -
>  	return req;
> -
> -out_free:
> -	_fcall_free(a, &req->recv);
> -	_fcall_free(a, &req->xmit);
> -	uk_free(a, req);
> -out:
> -	return NULL;
> -}
> -
> -static void _req_free(struct uk_9preq *req)
> -{
> -	_fcall_free(req->_a, &req->recv);
> -	_fcall_free(req->_a, &req->xmit);
> -	uk_free(req->_a, req);
>  }
>  
>  void uk_9preq_get(struct uk_9preq *req)
> @@ -133,7 +89,7 @@ int uk_9preq_put(struct uk_9preq *req)
>  
>  	last = uk_refcount_release(&req->refcount);
>  	if (last)
> -		_req_free(req);
> +		uk_free(req->_a, req);
>  
>  	return last;
>  }
> diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
> index 04ff523..1225336 100644
> --- a/lib/uk9p/include/uk/9pdev.h
> +++ b/lib/uk9p/include/uk/9pdev.h
> @@ -114,15 +114,12 @@ void uk_9pdev_xmit_notify(struct uk_9pdev *dev);
>   *   The Unikraft 9P Device.
>   * @param type
>   *   Transmit type of the request, e.g. Tversion, Tread, and so on.
> - * @param size
> - *   The maximum size for the receive and send buffers.
>   * @return
>   *   If not an error pointer, the created request.
>   *   Otherwise, the error in creating the request:
>   *   - ENOMEM: No memory for the request or no available tags.
>   */
> -struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type,
> -				uint32_t size);
> +struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type);
>  
>  /**
>   * Looks up a request based on the given tag. This is generally used by
> diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
> index b9713e2..ed883d2 100644
> --- a/lib/uk9p/include/uk/9preq.h
> +++ b/lib/uk9p/include/uk/9preq.h
> @@ -63,6 +63,16 @@ extern "C" {
>   */
>  #define UK_9P_RERROR_MAXSIZE            141U
>  
> +/*
> + * The transmit and receive buffer size.
> + *
> + * The buffer size is not expected to exceed 1K: reads and writes are
> + * zero-copy; on-the-wire size of a stat structure should not exceed
> + * 1K -- its base size is 61, along with the lengths for name, uid,
> + * gid, muid and extension strings.
> + */
> +#define UK_9P_BUFSIZE			1024U
> +
>  /**
>   * @internal
>   *
> @@ -125,8 +135,23 @@ enum uk_9preq_state {
>   *  referenced anymore. A call to uk_9pdev_req_remove() is mandatory to
>   *  correctly free this and remove it from the list of requests managed
>   *  by the 9p device.
> + *
> + *  Should fit within one page.
>   */
>  struct uk_9preq {
> +	/*
> +	 * Fixed-size buffer for transmit, used for most messages.
> +	 * Large messages will always zero-copy from the user-provided
> +	 * buffer (on Twrite).
> +	 */
> +	uint8_t				xmit_buf[UK_9P_BUFSIZE];
> +	/*
> +	 * Fixed-size buffer for receive, used for most messages.
> +	 * Large messages will always zero-copy into the user-provided
> +	 * buffer (on Tread).
> +	 */
> +	uint8_t				recv_buf[UK_9P_BUFSIZE];
> +	/* 2 KB offset in the structure here. */
>  	/* Transmit fcall. */
>  	struct uk_9preq_fcall           xmit;
>  	/* Receive fcall. */
> @@ -147,6 +172,8 @@ struct uk_9preq {
>  #endif
>  };
>  
> +UK_CTASSERT(sizeof(struct uk_9preq) <= __PAGE_SIZE);
> +
>  /**
>   * @internal
>   * Allocates a 9p request.
> @@ -154,13 +181,11 @@ struct uk_9preq {
>   *
>   * @param a
>   *   Allocator to use.
> - * @param size
> - *   Minimum size of the receive and transmit buffers.
>   * @return
>   *   - (==NULL): Out of memory.
>   *   - (!=NULL): Successful.
>   */
> -struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a, uint32_t size);
> +struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a);
>  
>  /**
>   * Gets the 9p request, incrementing the reference count.
> 


From minios-devel-bounces@lists.xenproject.org Sat May 16 14:28:47 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 16 May 2020 14:28:47 +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 1jZxnz-0004Is-Bn; Sat, 16 May 2020 14:28: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=WrGt=66=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jZxny-0004Im-6x
 for minios-devel@lists.xen.org; Sat, 16 May 2020 14:28:46 +0000
X-Inumbo-ID: 8b9b948a-9781-11ea-9887-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.230])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 8b9b948a-9781-11ea-9887-bc764e2007e4;
 Sat, 16 May 2020 14:28:44 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 77D3BB56217B;
 Sat, 16 May 2020 17:28:43 +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 echAB1fpeEfQ; Sat, 16 May 2020 17:28:40 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id E4B81B562302;
 Sat, 16 May 2020 17:28:39 +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 2iAzj4SOO1_y; Sat, 16 May 2020 17:28:39 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.26.181.84])
 by mx.upb.ro (Postfix) with ESMTPSA id AD11DB562040;
 Sat, 16 May 2020 17:28:39 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v2 8/9] lib/uk9p: Recycle uk_9preq allocations
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200509164413.38078-1-cristb@gmail.com>
 <20200509164413.38078-9-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <8e81db1b-7d55-7ca6-aeb1-48b408038d23@cs.pub.ro>
Date: Sat, 16 May 2020 17:28:39 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200509164413.38078-9-cristb@gmail.com>
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>

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/9/20 7:44 PM, Cristian Banu wrote:
> Each 9p device keeps a free-list of 9p requests. This allows
> allocations to take much less time, as usually the workflow of a 9p
> device is synchronous: create request, wait for reply, process it,
> repeat. This approach avoids the allocation performance hit on
> subsequent request creations.
> 
> Results below indicate that request_allocated takes < 100ns,
> as opposed to 1us (previous commit in this patch series).
> 
> In the sample below, the read() now spends most of the time (~99.8%)
> either notifying the host or waiting for a reply. At this scale,
> even uk_traces are probably noisy and the "real" time might be lower
> by a relatively large amount.
> 
> Excerpt from the uk traces on a read():
> 
> 500281499  uk_9p_trace_request_create
> 500281570  uk_9p_trace_request_allocated
> 500281603  uk_9p_trace_ready              tag 0
> 500283423  uk_9p_trace_sent               tag 0
> 500347243  uk_9p_trace_received           tag 0
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/uk9p/9pdev.c                 | 80 +++++++++++++++++++++++++++++---
>  lib/uk9p/9preq.c                 | 14 ++----
>  lib/uk9p/include/uk/9pdev.h      | 10 ++++
>  lib/uk9p/include/uk/9pdev_core.h |  2 +
>  lib/uk9p/include/uk/9preq.h      | 15 +++---
>  5 files changed, 95 insertions(+), 26 deletions(-)
> 
> diff --git a/lib/uk9p/9pdev.c b/lib/uk9p/9pdev.c
> index 40a4daa..bdd6a84 100644
> --- a/lib/uk9p/9pdev.c
> +++ b/lib/uk9p/9pdev.c
> @@ -132,6 +132,7 @@ static void _req_mgmt_init(struct uk_9pdev_req_mgmt *req_mgmt)
>  	ukarch_spin_lock_init(&req_mgmt->spinlock);
>  	uk_bitmap_zero(req_mgmt->tag_bm, UK_9P_NUMTAGS);
>  	UK_INIT_LIST_HEAD(&req_mgmt->req_list);
> +	UK_INIT_LIST_HEAD(&req_mgmt->req_free_list);
>  }
>  
>  static void _req_mgmt_add_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
> @@ -141,6 +142,21 @@ static void _req_mgmt_add_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
>  	uk_list_add(&req->_list, &req_mgmt->req_list);
>  }
>  
> +static struct uk_9preq *
> +_req_mgmt_from_freelist_locked(struct uk_9pdev_req_mgmt *req_mgmt)
> +{
> +	struct uk_9preq *req;
> +
> +	if (uk_list_empty(&req_mgmt->req_free_list))
> +		return NULL;
> +
> +	req = uk_list_first_entry(&req_mgmt->req_free_list,
> +			struct uk_9preq, _list);
> +	uk_list_del(&req->_list);
> +
> +	return req;
> +}
> +
>  static void _req_mgmt_del_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
>  				struct uk_9preq *req)
>  {
> @@ -148,6 +164,12 @@ static void _req_mgmt_del_req_locked(struct uk_9pdev_req_mgmt *req_mgmt,
>  	uk_list_del(&req->_list);
>  }
>  
> +static void _req_mgmt_req_to_freelist_locked(struct uk_9pdev_req_mgmt *req_mgmt,
> +				struct uk_9preq *req)
> +{
> +	uk_list_add(&req->_list, &req_mgmt->req_free_list);
> +}
> +
>  static uint16_t _req_mgmt_next_tag_locked(struct uk_9pdev_req_mgmt *req_mgmt)
>  {
>  	return uk_find_next_zero_bit(req_mgmt->tag_bm, UK_9P_NUMTAGS, 0);
> @@ -164,10 +186,24 @@ static void _req_mgmt_cleanup(struct uk_9pdev_req_mgmt *req_mgmt __unused)
>  		tag = req->tag;
>  		_req_mgmt_del_req_locked(req_mgmt, req);
>  		if (!uk_9preq_put(req)) {
> -			uk_pr_warn("Tag %d still has references on cleanup.\n",
> +			/* If in the future these references get released, mark
> +			 * _dev as NULL so uk_9pdev_req_to_freelist doesn't
> +			 * attempt to place them in an invalid memory region.
> +			 *
> +			 * As _dev is not used for any other purpose, this
> +			 * doesn't impact any other logic related to 9p request
> +			 * processing.
> +			 */
> +			req->_dev = NULL;
> +			uk_pr_err("Tag %d still has references on cleanup.\n",
>  				tag);
>  		}
>  	}
> +	uk_list_for_each_entry_safe(req, reqn, &req_mgmt->req_free_list,
> +			_list) {
> +		uk_list_del(&req->_list);
> +		uk_free(req->_a, req);
> +	}
>  	ukplat_spin_unlock_irqrestore(&req_mgmt->spinlock, flags);
>  }
>  
> @@ -297,17 +333,37 @@ struct uk_9preq *uk_9pdev_req_create(struct uk_9pdev *dev, uint8_t type)
>  
>  	UK_ASSERT(dev);
>  
> -	req = uk_9preq_alloc(dev->a);
> -	if (req == NULL) {
> -		rc = -ENOMEM;
> -		goto out;
> +	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
> +	if (!(req = _req_mgmt_from_freelist_locked(&dev->_req_mgmt))) {
> +		/* Don't allocate with the spinlock held. */
> +		ukplat_spin_unlock_irqrestore(&dev->_req_mgmt.spinlock, flags);
> +		req = uk_calloc(dev->a, 1, sizeof(*req));
> +		if (req == NULL) {
> +			rc = -ENOMEM;
> +			goto out;
> +		}
> +		req->_dev = dev;
> +		/*
> +		 * Duplicate this, instead of using req->_dev, as we can't rely
> +		 * on the value of _dev at time of free. Check comment in
> +		 * _req_mgmt_cleanup.
> +		 */
> +		req->_a = dev->a;
> +		ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
>  	}
>  
> +	uk_9preq_init(req);
> +
> +	/*
> +	 * If request was from the free list, it should already belong to the
> +	 * dev.
> +	 */
> +	UK_ASSERT(req->_dev == dev);
> +
>  	/* Shouldn't exceed the msize on non-zerocopy buffers, just in case. */
>  	req->recv.size = MIN(req->recv.size, dev->msize);
>  	req->xmit.size = MIN(req->xmit.size, dev->msize);
>  
> -	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
>  	if (type == UK_9P_TVERSION)
>  		tag = UK_9P_NOTAG;
>  	else
> @@ -360,6 +416,18 @@ int uk_9pdev_req_remove(struct uk_9pdev *dev, struct uk_9preq *req)
>  	return uk_9preq_put(req);
>  }
>  
> +void uk_9pdev_req_to_freelist(struct uk_9pdev *dev, struct uk_9preq *req)
> +{
> +	unsigned long flags;
> +
> +	if (!dev)
> +		return;
> +
> +	ukplat_spin_lock_irqsave(&dev->_req_mgmt.spinlock, flags);
> +	_req_mgmt_req_to_freelist_locked(&dev->_req_mgmt, req);
> +	ukplat_spin_unlock_irqrestore(&dev->_req_mgmt.spinlock, flags);
> +}
> +
>  struct uk_9pfid *uk_9pdev_fid_create(struct uk_9pdev *dev)
>  {
>  	struct uk_9pfid *fid = NULL;
> diff --git a/lib/uk9p/9preq.c b/lib/uk9p/9preq.c
> index d44e684..edc462c 100644
> --- a/lib/uk9p/9preq.c
> +++ b/lib/uk9p/9preq.c
> @@ -35,6 +35,7 @@
>  #include <string.h>
>  #include <uk/config.h>
>  #include <uk/9preq.h>
> +#include <uk/9pdev.h>
>  #include <uk/9p_core.h>
>  #include <uk/list.h>
>  #include <uk/refcount.h>
> @@ -45,14 +46,8 @@
>  #include <uk/wait.h>
>  #endif
>  
> -struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a)
> +void uk_9preq_init(struct uk_9preq *req)
>  {
> -	struct uk_9preq *req;
> -
> -	req = uk_calloc(a, 1, sizeof(*req));
> -	if (req == NULL)
> -		return NULL;
> -
>  	req->xmit.buf = req->xmit_buf;
>  	req->recv.buf = req->recv_buf;
>  	req->xmit.size = req->recv.size = UK_9P_BUFSIZE;
> @@ -69,13 +64,10 @@ struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a)
>  	req->recv.offset = 0;
>  
>  	UK_INIT_LIST_HEAD(&req->_list);
> -	req->_a = a;
>  	uk_refcount_init(&req->refcount, 1);
>  #if CONFIG_LIBUKSCHED
>  	uk_waitq_init(&req->wq);
>  #endif
> -
> -	return req;
>  }
>  
>  void uk_9preq_get(struct uk_9preq *req)
> @@ -89,7 +81,7 @@ int uk_9preq_put(struct uk_9preq *req)
>  
>  	last = uk_refcount_release(&req->refcount);
>  	if (last)
> -		uk_free(req->_a, req);
> +		uk_9pdev_req_to_freelist(req->_dev, req);
>  
>  	return last;
>  }
> diff --git a/lib/uk9p/include/uk/9pdev.h b/lib/uk9p/include/uk/9pdev.h
> index 1225336..560ba8f 100644
> --- a/lib/uk9p/include/uk/9pdev.h
> +++ b/lib/uk9p/include/uk/9pdev.h
> @@ -149,6 +149,16 @@ struct uk_9preq *uk_9pdev_req_lookup(struct uk_9pdev *dev, uint16_t tag);
>   */
>  int uk_9pdev_req_remove(struct uk_9pdev *dev, struct uk_9preq *req);
>  
> +/**
> + * Places the given request on the 9p device's request freelist.
> + *
> + * @param dev
> + *   The Unikraft 9P Device. If NULL, doesn't place the request on the freelist.
> + * @param req
> + *   The request to be placed on the freelist.
> + */
> +void uk_9pdev_req_to_freelist(struct uk_9pdev *dev, struct uk_9preq *req);
> +
>  /**
>   * Creates a FID associated with the given 9P device.
>   *
> diff --git a/lib/uk9p/include/uk/9pdev_core.h b/lib/uk9p/include/uk/9pdev_core.h
> index 38864ac..fcad1ef 100644
> --- a/lib/uk9p/include/uk/9pdev_core.h
> +++ b/lib/uk9p/include/uk/9pdev_core.h
> @@ -120,6 +120,8 @@ struct uk_9pdev_req_mgmt {
>  	unsigned long                   tag_bm[UK_BITS_TO_LONGS(UK_9P_NUMTAGS)];
>  	/* List of requests allocated and not yet removed. */
>  	struct uk_list_head             req_list;
> +	/* Free-list of requests. */
> +	struct uk_list_head		req_free_list;
>  };
>  
>  /**
> diff --git a/lib/uk9p/include/uk/9preq.h b/lib/uk9p/include/uk/9preq.h
> index ed883d2..aad8d42 100644
> --- a/lib/uk9p/include/uk/9preq.h
> +++ b/lib/uk9p/include/uk/9preq.h
> @@ -162,6 +162,8 @@ struct uk_9preq {
>  	uint16_t                        tag;
>  	/* Entry into the list of requests (API-internal). */
>  	struct uk_list_head             _list;
> +	/* @internal 9P device this request belongs to. */
> +	struct uk_9pdev                 *_dev;
>  	/* @internal Allocator used to allocate this request. */
>  	struct uk_alloc                 *_a;
>  	/* Tracks the number of references to this structure. */
> @@ -176,16 +178,10 @@ UK_CTASSERT(sizeof(struct uk_9preq) <= __PAGE_SIZE);
>  
>  /**
>   * @internal
> - * Allocates a 9p request.
> + * Initializes a 9P request.
>   * Should not be used directly, use uk_9pdev_req_create() instead.
> - *
> - * @param a
> - *   Allocator to use.
> - * @return
> - *   - (==NULL): Out of memory.
> - *   - (!=NULL): Successful.
>   */
> -struct uk_9preq *uk_9preq_alloc(struct uk_alloc *a);
> +void uk_9preq_init(struct uk_9preq *req);
>  
>  /**
>   * Gets the 9p request, incrementing the reference count.
> @@ -197,7 +193,8 @@ void uk_9preq_get(struct uk_9preq *req);
>  
>  /**
>   * Puts the 9p request, decrementing the reference count.
> - * If this was the last live reference, the memory will be freed.
> + * If this was the last live reference, it will be placed on the asociated
> + * device's request freelist.
>   *
>   * @param req
>   *   Reference to the 9p request.
> 


From minios-devel-bounces@lists.xenproject.org Sat May 16 14:28:55 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 16 May 2020 14:28:55 +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 1jZxo7-0004Jm-Da; Sat, 16 May 2020 14:28:55 +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=WrGt=66=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jZxo6-0004Je-2T
 for minios-devel@lists.xen.org; Sat, 16 May 2020 14:28:54 +0000
X-Inumbo-ID: 910c84d8-9781-11ea-a671-12813bfff9fa
Received: from mx.upb.ro (unknown [141.85.13.220])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 910c84d8-9781-11ea-a671-12813bfff9fa;
 Sat, 16 May 2020 14:28:53 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 9E2C6B562040;
 Sat, 16 May 2020 17:28:52 +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 NvLyWBJ4-91f; Sat, 16 May 2020 17:28:50 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 167B2B5627AD;
 Sat, 16 May 2020 17:28:50 +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 GWwoz-hQBnfJ; Sat, 16 May 2020 17:28:50 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.26.181.84])
 by mx.upb.ro (Postfix) with ESMTPSA id D80F8B56217B;
 Sat, 16 May 2020 17:28:49 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v2 9/9] lib/9pfs: Simplify the logic for removes
To: Cristian Banu <cristb@gmail.com>, minios-devel@lists.xen.org
References: <20200509164413.38078-1-cristb@gmail.com>
 <20200509164413.38078-10-cristb@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <f8d3433a-7edb-fcef-7556-75a22fd9e341@cs.pub.ro>
Date: Sat, 16 May 2020 17:28:49 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200509164413.38078-10-cristb@gmail.com>
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>

Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>

On 5/9/20 7:44 PM, Cristian Banu wrote:
> The logic for unlinking is simplified, either:
> - there are no open files, remove now;
> - there are open files, defer until all open files are closed
> 
> This is now possible since successive open and closes update
> the dentry reference count correctly, so VOP_INACTIVE is called
> in time to free the fid before the qid starts being reused
> on the server-side (and we get an inode collision).
> 
> This also means that on unmounting, releasing all non-root
> dentries and calling vfscore_release_mp_dentries() for m_covered
> and m_root is enough to ensure all fids are clunked before
> disconnecting.
> 
> Signed-off-by: Cristian Banu <cristb@gmail.com>
> ---
>  lib/9pfs/9pfs_vfsops.c |  7 +++----
>  lib/9pfs/9pfs_vnops.c  | 37 +++++++++++--------------------------
>  2 files changed, 14 insertions(+), 30 deletions(-)
> 
> diff --git a/lib/9pfs/9pfs_vfsops.c b/lib/9pfs/9pfs_vfsops.c
> index accb3a5..5293b22 100644
> --- a/lib/9pfs/9pfs_vfsops.c
> +++ b/lib/9pfs/9pfs_vfsops.c
> @@ -169,11 +169,10 @@ static void uk_9pfs_release_tree_fids(struct dentry *d)
>  {
>  	struct dentry *p;
>  
> -	uk_list_for_each_entry(p, &d->d_child_list, d_child_link)
> +	uk_list_for_each_entry(p, &d->d_child_list, d_child_link) {
>  		uk_9pfs_release_tree_fids(p);
> -
> -	if (d->d_vnode->v_data)
> -		uk_9pfs_free_vnode_data(d->d_vnode);
> +		drele(p);
> +	}
>  }
>  
>  static int uk_9pfs_unmount(struct mount *mp, int flags __unused)
> diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
> index 6d3ece3..c81c82a 100644
> --- a/lib/9pfs/9pfs_vnops.c
> +++ b/lib/9pfs/9pfs_vnops.c
> @@ -147,7 +147,7 @@ void uk_9pfs_free_vnode_data(struct vnode *vp)
>  	struct uk_9pdev *dev = UK_9PFS_MD(vp->v_mount)->dev;
>  	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
>  
> -	if (nd->nb_open_files > 0)
> +	if (!vp->v_data)
>  		return;
>  
>  	if (nd->removed)
> @@ -158,20 +158,6 @@ void uk_9pfs_free_vnode_data(struct vnode *vp)
>  	vp->v_data = NULL;
>  }
>  
> -/*
> - * The closing variant of the function will enforce freeing the associated
> - * resources only if the vnode was removed via an unlink/rmdir operation.
> - */
> -static void uk_9pfs_free_vnode_data_closing(struct vnode *vp)
> -{
> -	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
> -
> -	if (!nd->removed)
> -		return;
> -
> -	uk_9pfs_free_vnode_data(vp);
> -}
> -
>  static int uk_9pfs_open(struct vfscore_file *file)
>  {
>  	struct uk_9pdev *dev = UK_9PFS_MD(file->f_dentry->d_mount)->dev;
> @@ -222,7 +208,6 @@ static int uk_9pfs_close(struct vnode *vn __unused, struct vfscore_file *file)
>  	uk_9pfid_put(fd->fid);
>  	free(fd);
>  	UK_9PFS_ND(file->f_dentry->d_vnode)->nb_open_files--;
> -	uk_9pfs_free_vnode_data_closing(file->f_dentry->d_vnode);
>  
>  	return 0;
>  }
> @@ -327,22 +312,22 @@ static int uk_9pfs_remove_generic(struct vnode *dvp, struct vnode *vp)
>  {
>  	struct uk_9pdev *dev = UK_9PFS_MD(dvp->v_mount)->dev;
>  	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
> -	int rc = 0;
> -
> -	if (!nd->removed && !nd->nb_open_files)
> -		rc = uk_9p_remove(dev, nd->fid);
> -	else
> -		nd->removed = true;
> -
> -	uk_9pfs_free_vnode_data(vp);
>  
> -	return -rc;
> +	return -uk_9p_remove(dev, nd->fid);
>  }
>  
>  static int uk_9pfs_remove(struct vnode *dvp, struct vnode *vp,
>  		char *name __unused)
>  {
> -	return uk_9pfs_remove_generic(dvp, vp);
> +	struct uk_9pfs_node_data *nd = UK_9PFS_ND(vp);
> +	int rc = 0;
> +
> +	if (!nd->nb_open_files)
> +		rc = uk_9pfs_remove_generic(dvp, vp);
> +	else
> +		nd->removed = true;
> +
> +	return rc;
>  }
>  
>  static int uk_9pfs_mkdir(struct vnode *dvp, char *name, mode_t mode)
> 


From minios-devel-bounces@lists.xenproject.org Sun May 17 12:32:23 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 17 May 2020 12:32:23 +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 1jaISo-0001w0-Kt; Sun, 17 May 2020 12:32:18 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=qe85=67=gmail.com=raducanu.costi@srs-us1.protection.inumbo.net>)
 id 1jaISo-0001vv-2X
 for minios-devel@lists.xen.org; Sun, 17 May 2020 12:32:18 +0000
X-Inumbo-ID: 71776d40-983a-11ea-b07b-bc764e2007e4
Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 71776d40-983a-11ea-b07b-bc764e2007e4;
 Sun, 17 May 2020 12:32:17 +0000 (UTC)
Received: by mail-wr1-x442.google.com with SMTP id e1so8577752wrt.5
 for <minios-devel@lists.xen.org>; Sun, 17 May 2020 05:32:17 -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=3f6HX7TjxqBsNPDnhAlrgZcJCRj3YZj04jNP5DgmJqc=;
 b=IdmUwixOxKGHyRwIlvHP92CTSMPMdwFcowk13kb8+xSb5/ngVkX+oquSjDpBjwsGz6
 zC/h6dNCxUuY9zTcIYnviRbQXm2D42gyX4o6+dd95X2NRsaQhKSsvqPfz1FPmGOY2OSC
 VSWvZDpMrMq/ZETPeogOC1YUIMAk9JMmAzC0wDFzHahMgiEd0Apt1mo98KHOEqqOwgdC
 iu3vbRv9xHXV/4ILkOtqyv/nYoBDz3pkQNGGiOzSIzj101A8zwGatopz1FDA1qCqTP+I
 DeWQHiwsxxWe2vnS5hV3ltOuHJuOn9uVNleeXo/B33fP1vPwGrJB+y3oI6sAZiiw2xGM
 IGfw==
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=3f6HX7TjxqBsNPDnhAlrgZcJCRj3YZj04jNP5DgmJqc=;
 b=TcXwoeFvAN88I4wqoZoFaHcVo+sKIVJuUDwS9IQm8KpPvlcYfZkIbAQ1dxEUTuYhc5
 S86KyK2+deOv5Ev3kSMGE1iFAd9Ob6OS2RiLVvgjL3JTbSjldOWvkOTnUoeaQMmSgsS1
 88zvzMTjJHdgfuj9JEMpgRU0uqa03PnA0/ggoJlNSbJ/+fdURWxHbFnf04UkKk5EaP6F
 2DxbrlusXQLiph9PY62sORPX1FbKP3XFzEdnrrzYWEbbsfPwgqlooYebUNqZ/ykv4JME
 2+zW/409Aj2YU6DsTGKy/+jA3/+SaSabTbwvKb+3IbZdqcunkpH+edMOLnUfSa0J0HGN
 clJA==
X-Gm-Message-State: AOAM533pzjBzUC0OKuraLKJUH2iLKSiqmoodWSEP5F/NoHvX5VaXfYdJ
 j37W2Ugr4F+LUT8Tw+zMkb02iHDQS5A=
X-Google-Smtp-Source: ABdhPJw/HNjkzxU+QTdtVcB0BQDZLgkYUtRW6Yv264ZFOed4e9/YNHhBk2sAqgkfIxyApTKCKxxZ+w==
X-Received: by 2002:adf:b1c1:: with SMTP id r1mr14053641wra.76.1589718736050; 
 Sun, 17 May 2020 05:32:16 -0700 (PDT)
Received: from localhost.localdomain ([188.25.211.20])
 by smtp.gmail.com with ESMTPSA id u74sm12039882wmu.13.2020.05.17.05.32.15
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 17 May 2020 05:32:15 -0700 (PDT)
From: Constantin Raducanu <raducanu.costi@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH] libs/lib-pthread-embedded: Removes exportsyms.uk
 from exports
Date: Sun, 17 May 2020 15:30:07 +0300
Message-Id: <20200517123007.28551-1-raducanu.costi@gmail.com>
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>
Cc: simon.kuenzer@neclab.eu, Constantin Raducanu <raducanu.costi@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Removes the entry from Makefile.uk, which adds the
exportsyms.uk file to the exports variable, because
the library doesn't have a exportsyms.uk file.

Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
---
 Makefile.uk | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Makefile.uk b/Makefile.uk
index b9b7456..4ee37cd 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -59,8 +59,6 @@ LIBPTHREAD-EMBEDDED_CFLAGS-y   += $(LIBPTHREAD-EMBEDDED_SUPPRESS_FLAGS) \
 	-Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
 LIBPTHREAD-EMBEDDED_CXXFLAGS-y += $(LIBPTHREAD-EMBEDDED_SUPPRESS_FLAGS)
 
-LIBPTHREAD-EMBEDDED_EXPORTS = $(LIBPTHREAD-EMBEDDED_BASE)/exportsyms.uk
-
 ################################################################################
 # OS dependencies code - Glue between Unikraft and pthread-embedded
 ################################################################################
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon May 18 11:45:44 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 18 May 2020 11:45: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 1jaeDE-0007Bg-2U; Mon, 18 May 2020 11:45: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=Q6bu=7A=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jaeDC-0007Ba-9P
 for minios-devel@lists.xen.org; Mon, 18 May 2020 11:45:38 +0000
X-Inumbo-ID: 161d7cb4-98fd-11ea-b9cf-bc764e2007e4
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 161d7cb4-98fd-11ea-b9cf-bc764e2007e4;
 Mon, 18 May 2020 11:45:36 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id B54351040A5;
 Mon, 18 May 2020 13:45:34 +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 AeO0rnQFBOAd; Mon, 18 May 2020 13:45:34 +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 80FFB104183;
 Mon, 18 May 2020 13:45:34 +0200 (CEST)
Received: from [10.7.0.24] (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.1713.5; Mon, 18 May
 2020 13:45:33 +0200
Subject: Re: [UNIKRAFT PATCH] libs/lib-pthread-embedded: Removes exportsyms.uk
 from exports
To: Constantin Raducanu <raducanu.costi@gmail.com>,
 <minios-devel@lists.xen.org>
References: <20200517123007.28551-1-raducanu.costi@gmail.com>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <0de8d0f3-b171-879d-af3c-597098fe1f01@neclab.eu>
Date: Mon, 18 May 2020 13:45:33 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0)
 Gecko/20100101 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200517123007.28551-1-raducanu.costi@gmail.com>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
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>

Hi Constantin,

thanks a lot for your work, this is correct. I just found that we have 
the same fix already on the staging branch of this lib. Did you try this 
one for your case already?

Thanks,

Simon

On 17.05.20 14:30, Constantin Raducanu wrote:
> Removes the entry from Makefile.uk, which adds the
> exportsyms.uk file to the exports variable, because
> the library doesn't have a exportsyms.uk file.
> 
> Signed-off-by: Constantin Raducanu <raducanu.costi@gmail.com>
> ---
>   Makefile.uk | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/Makefile.uk b/Makefile.uk
> index b9b7456..4ee37cd 100644
> --- a/Makefile.uk
> +++ b/Makefile.uk
> @@ -59,8 +59,6 @@ LIBPTHREAD-EMBEDDED_CFLAGS-y   += $(LIBPTHREAD-EMBEDDED_SUPPRESS_FLAGS) \
>   	-Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
>   LIBPTHREAD-EMBEDDED_CXXFLAGS-y += $(LIBPTHREAD-EMBEDDED_SUPPRESS_FLAGS)
>   
> -LIBPTHREAD-EMBEDDED_EXPORTS = $(LIBPTHREAD-EMBEDDED_BASE)/exportsyms.uk
> -
>   ################################################################################
>   # OS dependencies code - Glue between Unikraft and pthread-embedded
>   ################################################################################
> 


From minios-devel-bounces@lists.xenproject.org Mon May 18 12:56:59 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 18 May 2020 12:56: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 1jafKC-0004vE-I1; Mon, 18 May 2020 12:56:56 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Q6bu=7A=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jafKB-0004v9-OX
 for minios-devel@lists.xenproject.org; Mon, 18 May 2020 12:56:55 +0000
X-Inumbo-ID: 0bcda9aa-9907-11ea-b9cf-bc764e2007e4
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 0bcda9aa-9907-11ea-b9cf-bc764e2007e4;
 Mon, 18 May 2020 12:56:53 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id AFA5C103F22;
 Mon, 18 May 2020 14:56:52 +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 5nn6K98zE_US; Mon, 18 May 2020 14:56:52 +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 8AB23FFB03;
 Mon, 18 May 2020 14:56:52 +0200 (CEST)
Received: from [10.7.0.24] (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.1713.5; Mon, 18 May
 2020 14:56:52 +0200
Subject: Re: [UNIKRAFT/VFSCORE PATCH 0/2]
To: George Muraru <murarugeorgec@gmail.com>,
 <minios-devel@lists.xenproject.org>
References: <20200515121336.101817-1-murarugeorgec@gmail.com>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <c41cddde-06b9-c199-b281-b1c1841fcd62@neclab.eu>
Date: Mon, 18 May 2020 14:56:51 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0)
 Gecko/20100101 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200515121336.101817-1-murarugeorgec@gmail.com>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) 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>
Cc: Felipe.Huici@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi George,

thanks a lot for your work! Could you provide move these comments within 
the patch description of each patch - otherwise your information gets 
lost when patches get pushed upstream? I think you can send these 
patches without a cover letter and individually. They are not too much 
related, so this would be fine.

Thanks a lot,

Simon

On 15.05.20 14:13, George Muraru wrote:
> Add quotes to string symbol
> Got a warning while trying to use "make kmenuconfig" saying the following:
> "warning: style: quotes recommended around default value for string symbol
> UK_ARCH (defined at .../unikraft/Config.uk:12)"
>   
> Setting a specific value to a choice config (from one of the libraries) cannot
> overwrite a default value (that is set in Unikraft). It seems this is the case
> for our C based Kconfig (from my knowledge we use this) - a default value set
> earlier (in Unikraft) has a higher priority than a one set later (in a library).
> 
> For solving this issue, one solution is to use "named choices" - did that for
> the tensorflowlite porting.
> 
> The information is obtained from an issue discussed here[1].
>   
> [1] https://github.com/zephyrproject-rtos/zephyr/issues/6948
> 
> George Muraru (2):
>    Quotes to symbol
>    Remove default value
> 
>   Config.uk             | 2 +-
>   lib/vfscore/Config.uk | 1 -
>   2 files changed, 1 insertion(+), 2 deletions(-)
> 


From minios-devel-bounces@lists.xenproject.org Mon May 18 13:24:48 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 18 May 2020 13:24:48 +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 1jafl9-00080u-FD; Mon, 18 May 2020 13:24:47 +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=Q6bu=7A=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jafl7-00080o-Ib
 for minios-devel@lists.xen.org; Mon, 18 May 2020 13:24:45 +0000
X-Inumbo-ID: ef2987e8-990a-11ea-a865-12813bfff9fa
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id ef2987e8-990a-11ea-a865-12813bfff9fa;
 Mon, 18 May 2020 13:24:43 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 83CFAF2002;
 Mon, 18 May 2020 15:24:42 +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 lTTZmrhMRDF7; Mon, 18 May 2020 15:24:42 +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 53C95F2001;
 Mon, 18 May 2020 15:24:36 +0200 (CEST)
Received: from [10.7.0.24] (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.1713.5; Mon, 18 May
 2020 15:24:35 +0200
Subject: Re: [UNIKRAFT PATCH 6/7] lib/vfscore: Expose max fds to sysconf
To: Costin Lupu <costin.lupu@cs.pub.ro>, Cristian Banu <cristb@gmail.com>,
 <minios-devel@lists.xen.org>
References: <20200502151340.92959-1-cristb@gmail.com>
 <20200502151340.92959-7-cristb@gmail.com>
 <bafdfb5e-bf17-4746-a38e-37ce030c8b78@cs.pub.ro>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <b64810f5-4f17-6863-2966-a1f2fdb2b1a7@neclab.eu>
Date: Mon, 18 May 2020 15:24:34 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0)
 Gecko/20100101 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <bafdfb5e-bf17-4746-a38e-37ce030c8b78@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
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>

Hey,

I noticed that this commit breaks compiling posix-sysinfo with nolibc 
because _SC_OPEN_MAX is undefined. I guess it is defined with newlib or 
musl, unfortunately not with nolibc but should have been added with this 
patch. We are currently using posix-sysinfo with nolibc for binary 
compatibility use cases where we try to populate the Linux system call 
ABI with a slim kernel libc (nolibc).
@Clupu or @Cristian: Can you review and push a fix that I am going to send?

Thanks,

Simon

On 05.05.20 20:19, Costin Lupu wrote:
> Thanks for adding this, Cristi!
> I'll upstream this now and we shall skip it from the v2.
> 
> Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
> 
> On 5/2/20 6:13 PM, Cristian Banu wrote:
>> Expose FDTABLE_MAX_FILES from vfscore as the return value of
>> sysconf(_SC_OPEN_MAX) if CONFIG_LIBVFSCORE is enabled.
>>
>> This allows language runtimes to inspect the number of active
>> fds (e.g. for tests).
>>
>> Signed-off-by: Cristian Banu <cristb@gmail.com>
>> ---
>>   lib/posix-sysinfo/sysinfo.c        | 10 ++++++++++
>>   lib/vfscore/fd.c                   |  2 --
>>   lib/vfscore/include/vfscore/file.h |  3 +++
>>   3 files changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/posix-sysinfo/sysinfo.c b/lib/posix-sysinfo/sysinfo.c
>> index 7bcfc8b..075f320 100644
>> --- a/lib/posix-sysinfo/sysinfo.c
>> +++ b/lib/posix-sysinfo/sysinfo.c
>> @@ -43,6 +43,11 @@
>>   #include <sys/sysinfo.h>
>>   #include <uk/syscall.h>
>>   
>> +#if CONFIG_LIBVFSCORE
>> +/* For FDTABLE_MAX_FILES. */
>> +#include <vfscore/file.h>
>> +#endif
>> +
>>   static struct utsname utsname = {
>>   	.sysname	= "Unikraft",
>>   	.nodename	= "unikraft",
>> @@ -85,6 +90,11 @@ long sysconf(int name)
>>   	if (name == _SC_PAGESIZE)
>>   		return __PAGE_SIZE;
>>   
>> +#if CONFIG_LIBVFSCORE
>> +	if (name == _SC_OPEN_MAX)
>> +		return FDTABLE_MAX_FILES;
>> +#endif
>> +
>>   	return 0;
>>   }
>>   
>> diff --git a/lib/vfscore/fd.c b/lib/vfscore/fd.c
>> index 684ea50..956846f 100644
>> --- a/lib/vfscore/fd.c
>> +++ b/lib/vfscore/fd.c
>> @@ -42,8 +42,6 @@
>>   #include <errno.h>
>>   #include <uk/ctors.h>
>>   
>> -#define FDTABLE_MAX_FILES 1024
>> -
>>   void init_stdio(void);
>>   
>>   struct fdtable {
>> diff --git a/lib/vfscore/include/vfscore/file.h b/lib/vfscore/include/vfscore/file.h
>> index be23974..ec45a08 100644
>> --- a/lib/vfscore/include/vfscore/file.h
>> +++ b/lib/vfscore/include/vfscore/file.h
>> @@ -80,6 +80,9 @@ int fdrop(struct vfscore_file* fp);
>>   
>>   #define FOF_OFFSET  0x0800    /* Use the offset in uio argument */
>>   
>> +/* Used from posix-sysinfo to determine sysconf(_SC_OPEN_MAX). */
>> +#define FDTABLE_MAX_FILES 1024
>> +
>>   #ifdef __cplusplus
>>   }
>>   #endif
>>
> 


From minios-devel-bounces@lists.xenproject.org Mon May 18 14:23:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 18 May 2020 14:23: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 1jagfc-0005MR-RI; Mon, 18 May 2020 14:23: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=Q6bu=7A=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jagfb-0005MJ-Sy
 for minios-devel@lists.xen.org; Mon, 18 May 2020 14:23:07 +0000
X-Inumbo-ID: 13eb322c-9913-11ea-9887-bc764e2007e4
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 13eb322c-9913-11ea-9887-bc764e2007e4;
 Mon, 18 May 2020 14:23:01 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 426C210138F;
 Mon, 18 May 2020 16:23: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 sIXzgW8B_lrm; Mon, 18 May 2020 16:23:00 +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 21A9DFFA06;
 Mon, 18 May 2020 16:23:00 +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.1713.5; Mon, 18 May
 2020 16:22:59 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
Subject: [PATCH] lib/nolibc: Provide _SC_OPEN_MAX with unistd.h
Date: Mon, 18 May 2020 16:22:50 +0200
Message-ID: <20200518142250.2498-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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Costin Lupu <costin.lupu@cs.pub.ro>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Populates _SC_OPEN_MAX with nolibc. lib/posix-sysinfo uses it with
commit f587ed23 "lib/vfscore: Expose max fds to sysconf".

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/nolibc/include/unistd.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/nolibc/include/unistd.h b/lib/nolibc/include/unistd.h
index 99b5d305..d4cdb581 100644
--- a/lib/nolibc/include/unistd.h
+++ b/lib/nolibc/include/unistd.h
@@ -51,6 +51,7 @@ extern "C" {
 /*
  * Sysconf name values
  */
+#define _SC_OPEN_MAX 4
 #define _SC_PAGESIZE 8
 #define _SC_NPROCESSORS_ONLN 10
 
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 18 14:37:15 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 18 May 2020 14:37:15 +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 1jagtF-0006p8-K6; Mon, 18 May 2020 14:37: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=Q6bu=7A=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jagtE-0006p3-Hs
 for minios-devel@lists.xen.org; Mon, 18 May 2020 14:37:12 +0000
X-Inumbo-ID: 0e93385e-9915-11ea-ae69-bc764e2007e4
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 0e93385e-9915-11ea-ae69-bc764e2007e4;
 Mon, 18 May 2020 14:37:11 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 63F321039E6;
 Mon, 18 May 2020 16:37:10 +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 acoLaGLrG_V9; Mon, 18 May 2020 16:37:10 +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 4331310138F
 for <minios-devel@lists.xen.org>; Mon, 18 May 2020 16:37:10 +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.1713.5; Mon, 18 May
 2020 16:37:09 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
Subject: [UNIKRAFT PATCH] lib/syscall_shim: Include processing of
 $(UK_PROVIDED_SYSCALLS)
Date: Mon, 18 May 2020 16:37:01 +0200
Message-ID: <20200518143701.2966-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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Equivalent to the Unikraft build variables scheme we include
$(UK_PROVIDED_SYSCALLS) as another variable to define the list of
system calls. So far $(UK_PROVIDED_SYSCALLS-y) was used only.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/syscall_shim/Makefile.uk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/syscall_shim/Makefile.uk b/lib/syscall_shim/Makefile.uk
index b758f830..37805c82 100644
--- a/lib/syscall_shim/Makefile.uk
+++ b/lib/syscall_shim/Makefile.uk
@@ -89,7 +89,7 @@ $(LIBSYSCALL_SHIM_BUILD)/libc_stubs.c: $(LIBSYSCALL_SHIM_BASE)/gen_libc_stubs.aw
 
 $(LIBSYSCALL_SHIM_BUILD)/provided_syscalls.h.in.new:
 	$(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \
-		echo $(UK_PROVIDED_SYSCALLS-y) | tr ' ' '\n' > $@)
+		echo $(UK_PROVIDED_SYSCALLS-y) $(UK_PROVIDED_SYSCALLS) | tr ' ' '\n' > $@)
 
 $(LIBSYSCALL_SHIM_INCLUDES_PATH)/syscall_stubs.h.new: $(LIBSYSCALL_SHIM_BASE)/gen_stubs.awk $(LIBSYSCALL_SHIM_TEMPL)
 	$(call build_cmd,GEN,libsyscall_shim,$(notdir $@), \
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 18 14:37:25 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 18 May 2020 14:37:25 +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 1jagtR-0006pp-M0; Mon, 18 May 2020 14:37:25 +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=Q6bu=7A=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jagtR-0006ph-9I
 for minios-devel@lists.xen.org; Mon, 18 May 2020 14:37:25 +0000
X-Inumbo-ID: 15e02b76-9915-11ea-a86b-12813bfff9fa
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 15e02b76-9915-11ea-a86b-12813bfff9fa;
 Mon, 18 May 2020 14:37:23 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 901ACF2001;
 Mon, 18 May 2020 16:37:22 +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 vYCDeghlTJEG; Mon, 18 May 2020 16:37:22 +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 6A443C1F8D
 for <minios-devel@lists.xen.org>; Mon, 18 May 2020 16:37:20 +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.1713.5; Mon, 18 May
 2020 16:37:20 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
Subject: [UNIKRAFT PATCH] lib/syscall_shim: Provide 'print-syscalls' build
 target
Date: Mon, 18 May 2020 16:37:17 +0200
Message-ID: <20200518143717.3034-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: titania.office.hd (192.168.24.89) 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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Provides 'print-syscalls' target that lists currently activated
system calls.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/syscall_shim/Makefile.rules | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 lib/syscall_shim/Makefile.rules

diff --git a/lib/syscall_shim/Makefile.rules b/lib/syscall_shim/Makefile.rules
new file mode 100644
index 00000000..386ff9fe
--- /dev/null
+++ b/lib/syscall_shim/Makefile.rules
@@ -0,0 +1,9 @@
+.PHONY: print-syscalls
+
+ifeq ($(UK_HAVE_DOT_CONFIG),y)
+print-syscalls:
+	@echo $(UK_PROVIDED_SYSCALLS-y) $(UK_PROVIDED_SYSCALLS)
+else
+print-syscalls:
+	$(error Do not have a configuration. Please run one of the configuration targets first)
+endif
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon May 18 14:53:53 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 18 May 2020 14:53:53 +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 1jah9L-0000nX-45; Mon, 18 May 2020 14:53:51 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Q6bu=7A=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jah9K-0000nR-5f
 for minios-devel@lists.xen.org; Mon, 18 May 2020 14:53:50 +0000
X-Inumbo-ID: 61230c5a-9917-11ea-ae69-bc764e2007e4
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 61230c5a-9917-11ea-ae69-bc764e2007e4;
 Mon, 18 May 2020 14:53:48 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id D04D910138F;
 Mon, 18 May 2020 16:53:47 +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 aBGXWkAjCc_W; Mon, 18 May 2020 16:53:47 +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 7F6CB1039E6;
 Mon, 18 May 2020 16:53:47 +0200 (CEST)
Received: from [10.7.0.24] (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.1713.5; Mon, 18 May
 2020 16:53:46 +0200
Subject: Re: [UNIKRAFT PATCH 1/1] build: Add -fno-split-stack
To: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>,
 <minios-devel@lists.xen.org>
References: <20200511005406.1451-1-vlad_andrei.badoiu@upb.ro>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <91d36d12-d232-c111-6e02-425b7355eefe@neclab.eu>
Date: Mon, 18 May 2020 16:53:41 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0)
 Gecko/20100101 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200511005406.1451-1-vlad_andrei.badoiu@upb.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
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>

Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>

On 11.05.20 02:54, Vlad-Andrei Badoiu wrote:
> Until recently we have been using -fno-split-stack for GO source.
> This flag was dropped by mistake in the recent commits.
> We add this flag back since LD does not have full split stack
> support.
> 
> Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
> ---
>   Makefile.uk | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile.uk b/Makefile.uk
> index 1d6d060a..2c102989 100644
> --- a/Makefile.uk
> +++ b/Makefile.uk
> @@ -6,7 +6,7 @@
>   
>   COMPFLAGS    += -nostdinc -nostdlib
>   COMPFLAGS    += -U __linux__ -U __FreeBSD__ -U __sun__
> -COMPFLAGS    += -fno-stack-protector -fno-omit-frame-pointer -fno-tree-sra
> +COMPFLAGS    += -fno-stack-protector -fno-omit-frame-pointer -fno-tree-sra -fno-split-stack
>   COMPFLAGS    += -Wall -Wextra
>   
>   ASFLAGS      += -D__ASSEMBLY__
> 


From minios-devel-bounces@lists.xenproject.org Mon May 18 15:06:23 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 18 May 2020 15:06:23 +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 1jahLS-0001qg-Nu; Mon, 18 May 2020 15:06: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=/+tu=7A=xen.org=julien@srs-us1.protection.inumbo.net>)
 id 1jahLQ-0001qP-SH
 for minios-devel@lists.xenproject.org; Mon, 18 May 2020 15:06:20 +0000
X-Inumbo-ID: 20d012ea-9919-11ea-a870-12813bfff9fa
Received: from mail.xenproject.org (unknown [104.130.215.37])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 20d012ea-9919-11ea-a870-12813bfff9fa;
 Mon, 18 May 2020 15:06:19 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
 s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=VS3lPkvAee7RqXAXOSTrIWlSMcipNWuVniboGanBzdU=; b=f1xuQNz6Sj9KdMauSFSJmWnlNx
 iYaRcG1q4CvrlZHHIBCogNnT60o6jdy2FEhan78sgbGuO2+WGMA/fHFtecyEj41U/C3iYRgafOOYa
 h1ruOUW+wfTCyIwcgPaKFb3fzohm4jZ9CHbhOASIEg98PDWsCMRiMGEyopUfh7RBUpco=;
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <julien@xen.org>)
 id 1jahLO-0002du-Ct; Mon, 18 May 2020 15:06:18 +0000
Received: from 54-240-197-224.amazon.com ([54.240.197.224]
 helo=a483e7b01a66.ant.amazon.com)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89)
 (envelope-from <julien@xen.org>)
 id 1jahLO-0005Mh-6G; Mon, 18 May 2020 15:06:18 +0000
Subject: Re: [PATCH] arm64: rewrite io r/w helper to avoid kvm crash.
To: Jianyong Wu <jianyong.wu@arm.com>, minios-devel@lists.xenproject.org,
 sharan.santhanam@neclab.eu, simon.kuenzer@neclab.eu
References: <20200515055325.50513-1-jianyong.wu@arm.com>
From: Julien Grall <julien@xen.org>
Message-ID: <0879f8f1-6956-80df-ec04-be21a06ccbb5@xen.org>
Date: Mon, 18 May 2020 16:06:16 +0100
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0)
 Gecko/20100101 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200515055325.50513-1-jianyong.wu@arm.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-GB
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>
Cc: Justin.He@arm.com
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi,

On 15/05/2020 06:53, Jianyong Wu wrote:
> For now, unikraft will crash on arm64 in kvm mode if it compiled using

s/it compiled/it was compiled/

> optimize mode. Because compiler will choose post-index str intrs to

s/compiler/a compiler/ or the compiler.

s/intrs/instructions/

> write device memory. Unluckily, arm64 virtualization extension does only
> provides syndrome information for a limited subset of load/store

s/does only provides/only provides/

> instructions, that means we can't use load/store with writeback addressing
> mode to access mmio device.
> To avoid the compiler do those optimization, io read/write helpers should

s/do/to do/ I think.

> be rewitten by inline assembly with volatile constraint. After this,

s/by/using/

> unikraft can work fine on arm64.
> 
> Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
> ---
>   plat/common/include/arm/arm64/cpu.h | 84 ++++++++++++++++++++---------
>   1 file changed, 59 insertions(+), 25 deletions(-)
> 
> diff --git a/plat/common/include/arm/arm64/cpu.h b/plat/common/include/arm/arm64/cpu.h
> index 93ad13b..994d2f2 100644
> --- a/plat/common/include/arm/arm64/cpu.h
> +++ b/plat/common/include/arm/arm64/cpu.h
> @@ -41,31 +41,65 @@
>   #include <uk/alloc.h>
>   #include <uk/assert.h>
>   
> -/* Define macros to access IO registers */
> -#define __IOREG_READ(bits) \
> -static inline uint##bits##_t \
> -	ioreg_read##bits(const volatile uint##bits##_t *addr) \
> -		{ return *addr; }
> -
> -#define __IOREG_WRITE(bits) \
> -static inline void \
> -	ioreg_write##bits(volatile uint##bits##_t *addr, \
> -						uint##bits##_t value) \
> -		{ *addr = value; }
> -
> -
> -#define __IOREG_READ_ALL() __IOREG_READ(8)  \
> -			   __IOREG_READ(16) \
> -			   __IOREG_READ(32) \
> -			   __IOREG_READ(64) \
> -
> -#define __IOREG_WRITE_ALL()	__IOREG_WRITE(8)  \
> -			   __IOREG_WRITE(16) \
> -			   __IOREG_WRITE(32) \
> -			   __IOREG_WRITE(64) \
> -
> -__IOREG_READ_ALL()
> -__IOREG_WRITE_ALL()
> +/*
> + * we should use inline assembly with volatile constrain to access IO

s/constrain/constrainst/

> + * registers to avoid compiler use load/store intrns of writeback
> + * addressing mode which will cause crash when running in kvm mode.

This is not specific to KVM mode. This will happening on any hypervisor 
unless they decode the instruction (which is quite expensive).

> + */
> +static inline uint8_t ioreg_read8(const volatile uint8_t *address)
> +{
> +	uint8_t value;
> +
> +	asm volatile ("ldrb %w0, [%1]" : "=r"(value) : "r"(address));
> +	return value;
> +}
> +
> +static inline uint16_t ioreg_read16(const volatile uint16_t *address)
> +{
> +	uint16_t value;
> +
> +	asm volatile ("ldrh %w0, [%1]" : "=r"(value) : "r"(address));
> +	return value;
> +}
> +
> +static inline uint32_t ioreg_read32(const volatile uint32_t *address)
> +{
> +	uint32_t value;
> +
> +	asm volatile ("ldr %w0, [%1]" : "=r"(value) : "r"(address));
> +	return value;
> +}
> +
> +static inline uint64_t ioreg_read64(const volatile uint64_t *address)
> +{
> +	uint64_t value;
> +
> +	asm volatile ("ldr %0, [%1]" : "=r"(value) : "r"(address));
> +	return value;
> +}
> +
> +static inline void ioreg_write8(const volatile uint8_t *address, uint8_t value)
> +{
> +	asm volatile ("strb %w0, [%1]" : : "rZ"(value), "r"(address));
> +}
> +
> +static inline void ioreg_write16(const volatile uint16_t *address,
> +				 uint16_t value)
> +{
> +	asm volatile ("strh %w0, [%1]" : : "rZ"(value), "r"(address));
> +}
> +
> +static inline void ioreg_write32(const volatile uint32_t *address,
> +				 uint32_t value)
> +{
> +	asm volatile ("str %w0, [%1]" : : "rZ"(value), "r"(address));
> +}
> +
> +static inline void ioreg_write64(const volatile uint64_t *address,
> +				 uint64_t value)
> +{
> +	asm volatile ("str %0, [%1]" : : "rZ"(value), "r"(address));
> +}

NIT: Would it be possible to macro-ize this?

Regardless this question:

Reviewed-by: Julien Grall <julien@xen.org>

Cheers,

-- 
Julien Grall


From minios-devel-bounces@lists.xenproject.org Tue May 19 01:08:30 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 19 May 2020 01:08:30 +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 1jaqk6-0004Zr-93; Tue, 19 May 2020 01:08: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=zVdu=7B=arm.com=jianyong.wu@srs-us1.protection.inumbo.net>)
 id 1jaqk4-0004Zm-Ma
 for minios-devel@lists.xenproject.org; Tue, 19 May 2020 01:08:24 +0000
X-Inumbo-ID: 3b663734-996d-11ea-ae69-bc764e2007e4
Received: from EUR05-AM6-obe.outbound.protection.outlook.com (unknown
 [40.107.22.84]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 3b663734-996d-11ea-ae69-bc764e2007e4;
 Tue, 19 May 2020 01:08:22 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; 
 s=selector2-armh-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=qVC4aifFZfYWrjwOarNrQgqlp3NxIPMrNHZjpgFY91Y=;
 b=zzZlFtHRQqDy6a4TS2baCPfsLBVHPfewPjUEVZJYDq2KIYJ5m984IaaSYRcbRb/P/m84F4NN3v+sVAHxjT2Z8OXCJ2y8yigjEeOFQk4jZ2NAJqaRqxCf7UjJ+ce7oR1wa6cHNmJy+7cdOqhxUx2bAxBz7yMrq4mo1k5num2EnCo=
Received: from MRXP264CA0028.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:14::16)
 by DB6PR0801MB2119.eurprd08.prod.outlook.com (2603:10a6:4:34::9) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Tue, 19 May
 2020 01:08:20 +0000
Received: from VE1EUR03FT022.eop-EUR03.prod.protection.outlook.com
 (2603:10a6:500:14:cafe::36) by MRXP264CA0028.outlook.office365.com
 (2603:10a6:500:14::16) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend
 Transport; Tue, 19 May 2020 01:08:20 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123)
 smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was
 verified) header.d=armh.onmicrosoft.com;lists.xenproject.org;
 dmarc=bestguesspass action=none header.from=arm.com;
Received-SPF: Pass (protection.outlook.com: domain of arm.com designates
 63.35.35.123 as permitted sender) receiver=protection.outlook.com;
 client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com;
Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by
 VE1EUR03FT022.mail.protection.outlook.com (10.152.18.64) with
 Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.3000.19 via Frontend Transport; Tue, 19 May 2020 01:08:19 +0000
Received: ("Tessian outbound 9eabd37e4fee:v57");
 Tue, 19 May 2020 01:08:18 +0000
X-CR-MTA-TID: 64aa7808
Received: from dffcb82b0586.2
 by 64aa7808-outbound-1.mta.getcheckrecipient.com id
 252E1319-3339-4D53-879D-7EAF9DF72FA1.1; 
 Tue, 19 May 2020 01:08:13 +0000
Received: from EUR04-HE1-obe.outbound.protection.outlook.com
 by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id dffcb82b0586.2
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384);
 Tue, 19 May 2020 01:08:13 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=mnNRumcDk9BvoL+ot9HnpFlAIFdTbQgZ1kFKpbpuQP5HSRlQT/O1viZU3EApToHp3RQxlmHLfazCQDSJ/2sR2v57WbGW0pr9Plqchgb4+wRieayxTHLvlZ+FIAVT6AtEIXpr7w6lfl5c6s8uvAowdsjAkWOSJZT6bwoirdPOjyVGGtcRSuALh9aWE9WQ8pQEy7nZRca33uLbBNpuZGlyELn+E7dES6dOlS1AsUjn52GozQ3hBIWA9nddFl17n47RXG2XpnKpF/ZOxZa3Lumus0yVc0McYmdWgkPxKlmgNOpUA87IR39pKgm8ewVJY5XAzCvo4tlTHGrHr20ECIYzQQ==
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=qVC4aifFZfYWrjwOarNrQgqlp3NxIPMrNHZjpgFY91Y=;
 b=Pz3/nHf8aR3kk/R0dKgV+l+EVze/A9ggi3kZcrpO9ty276bHVsHBapXKe/Cpo0yeHT/709G3/hZqSEd/5WLnl1xwoBuXAQIlhcBLlFgdmK8YsVY9JUFiKoDKp59SGaT0AdQyHZRa9/mc2RfHIwkspw5wEMk/ZGiRpWg1OrqGHY52AhQZYj/i/x44uwc1WiqvfEnzzEpzauu7R2XRXlPMAVcp9DtlMTHHdeHrvqV1Zz2CqPvyXm1IWcMFyshBVjgPyPbATYvEY5YGMGBV/q8EnRrLuzItopX8HWfO8zS5Dp4tuNTm2OljldiKp510lyey/AdoZb+BO5NuuDhQ5QDChg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass
 header.d=arm.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; 
 s=selector2-armh-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=qVC4aifFZfYWrjwOarNrQgqlp3NxIPMrNHZjpgFY91Y=;
 b=zzZlFtHRQqDy6a4TS2baCPfsLBVHPfewPjUEVZJYDq2KIYJ5m984IaaSYRcbRb/P/m84F4NN3v+sVAHxjT2Z8OXCJ2y8yigjEeOFQk4jZ2NAJqaRqxCf7UjJ+ce7oR1wa6cHNmJy+7cdOqhxUx2bAxBz7yMrq4mo1k5num2EnCo=
Received: from HE1PR0802MB2555.eurprd08.prod.outlook.com (2603:10a6:3:e0::7)
 by HE1PR0802MB2171.eurprd08.prod.outlook.com (2603:10a6:3:c2::19) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26; Tue, 19 May
 2020 01:08:12 +0000
Received: from HE1PR0802MB2555.eurprd08.prod.outlook.com
 ([fe80::b1eb:9515:4851:8be]) by HE1PR0802MB2555.eurprd08.prod.outlook.com
 ([fe80::b1eb:9515:4851:8be%6]) with mapi id 15.20.3000.034; Tue, 19 May 2020
 01:08:12 +0000
From: Jianyong Wu <Jianyong.Wu@arm.com>
To: Julien Grall <julien@xen.org>, "minios-devel@lists.xenproject.org"
 <minios-devel@lists.xenproject.org>, "sharan.santhanam@neclab.eu"
 <sharan.santhanam@neclab.eu>, "simon.kuenzer@neclab.eu"
 <simon.kuenzer@neclab.eu>
Subject: RE: [PATCH] arm64: rewrite io r/w helper to avoid kvm crash.
Thread-Topic: [PATCH] arm64: rewrite io r/w helper to avoid kvm crash.
Thread-Index: AQHWKn04PmV48qBSqkevun3KI04oeqit9sYAgACmhzA=
Date: Tue, 19 May 2020 01:08:11 +0000
Message-ID: <HE1PR0802MB25552ED2364E92ADA76CDE52F4B90@HE1PR0802MB2555.eurprd08.prod.outlook.com>
References: <20200515055325.50513-1-jianyong.wu@arm.com>
 <0879f8f1-6956-80df-ec04-be21a06ccbb5@xen.org>
In-Reply-To: <0879f8f1-6956-80df-ec04-be21a06ccbb5@xen.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ts-tracking-id: 2d826700-550a-4416-8946-e4111cacfdfc.1
x-checkrecipientchecked: true
Authentication-Results-Original: xen.org; dkim=none (message not signed)
 header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
x-originating-ip: [113.29.88.7]
x-ms-publictraffictype: Email
X-MS-Office365-Filtering-HT: Tenant
X-MS-Office365-Filtering-Correlation-Id: 505e2834-3d1c-4250-08a3-08d7fb911e4e
x-ms-traffictypediagnostic: HE1PR0802MB2171:|DB6PR0801MB2119:
x-ms-exchange-transport-forked: True
X-Microsoft-Antispam-PRVS: <DB6PR0801MB211956C34E770D533FE3FF8BF4B90@DB6PR0801MB2119.eurprd08.prod.outlook.com>
x-checkrecipientrouted: true
nodisclaimer: true
x-ms-oob-tlc-oobclassifiers: OLM:4502;OLM:6790;
x-forefront-prvs: 040866B734
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam-Untrusted: BCL:0;
X-Microsoft-Antispam-Message-Info-Original: k+2saB1he5aUECstWqJzzvbOfs20uUfv8olEkxLNlg2v80mvx+HuzGbwWXNN/KN7tima7bG+dn3ikVl4+41OhcytuYCRzPWbOrHuyS6N6uxYqm4ydDSSsPQNhGPaKEWFKqmIIqdEmr6Zg411jYJe5nJjtgdMTjOUUutLroaFloz04W5Bo7PUFkxHooQGW85kVJeAGfog2Roew3ruBXDR5CwaCX371FXk1S8MK6TCg6ZVllSUNlusXPIHvAE76LmbUohgk+FlNNjJm4UVfgH9OTNiOgJ99mnDUid8ys16ZloRrkRsKjFqGSf1r4fviIR1fdj1dpKJ2s4lvNBwao16K3AWz++RHTCuGE9a+WtzMIH/OktDP71B/nqeK6aTtbn3JXin+LdCLFvNs+VDyKTiZV6Ac4DRvVIjQLqBim46iTNkbwEfYUT60oZqcdWDqKBo
X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en;
 SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:HE1PR0802MB2555.eurprd08.prod.outlook.com;
 PTR:; CAT:NONE; SFTY:;
 SFS:(4636009)(396003)(136003)(39860400002)(346002)(376002)(366004)(26005)(5660300002)(6506007)(316002)(33656002)(53546011)(478600001)(55236004)(71200400001)(4326008)(2906002)(186003)(110136005)(55016002)(86362001)(7696005)(9686003)(66446008)(8676002)(66556008)(8936002)(52536014)(66476007)(76116006)(66946007)(64756008);
 DIR:OUT; SFP:1101; 
x-ms-exchange-antispam-messagedata: pWkoOLmgeqrTNlDIYgZidPBiI+UMr7J8mt26vbyyJ6rcjF/HPFDQT4p8jiGoBE/yHAfhI/1q9beIJQweDhcnl/JbQ9tfbC46jjR9AUSKR+gpNKLStm/Sr94REWiK/jWWnR22HAyl0PphPf9zvVeQf9ff4F305G4ts6A2OkjoNWg5169X/0zPtCBxbG+0PKXpHYm5+a1GQRQNa/bSfHDK/O+FvJBZEfJl/mzUFYcpyvQQlMb4RycdTkXoRDXEwWSPt47TalFRC97Nkgtrvb9ppetjk2ge6ca0iS7xD7yxUGeFOiT3ik+7cOjrYL4AEmpdlG7QXHFqEQSmxdVEgckdvGOLslJ3i9K4JRb0iQPjc5KawVXovfF0MCW4vDTwqx09ZEZMPEx312CgW9D0mhljvblb93Iy1/ZM9vwTifi0UpsZn41LOnzmbBLhoWgeVlH0Nuvj67pl6LBRaFTF9uOXZqJGy9jcQ/vNcPaTYu+ZyKM=
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2171
Original-Authentication-Results: xen.org; dkim=none (message not signed)
 header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
X-EOPAttributedMessage: 0
X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT022.eop-EUR03.prod.protection.outlook.com
X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:;
 IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com;
 PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:;
 SFS:(4636009)(346002)(376002)(136003)(39860400002)(396003)(46966005)(478600001)(33656002)(52536014)(82740400003)(9686003)(86362001)(47076004)(186003)(110136005)(8936002)(4326008)(6506007)(53546011)(336012)(26005)(8676002)(316002)(81166007)(36906005)(70586007)(2906002)(356005)(70206006)(7696005)(55016002)(82310400002)(5660300002);
 DIR:OUT; SFP:1101; 
X-MS-Office365-Filtering-Correlation-Id-Prvs: 717c1808-7495-43d5-b46e-08d7fb9119f2
X-Forefront-PRVS: 040866B734
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: UeJxFPYKTncO5bAV9VIBHKKRiXvrFgqjbLc6qQ2xeNvhOb095y1XVCtjqxPO5qNI/1GFNQ9j0qDsQVGJbLsGG8C+XJni+U0HG2SZGE+gusTU1gAQE4VSG4YPnF30UQGADdRXoz+XS/I6Y1Z5HiD7AcHzfNIX5PE09YyHB1IyCjV7CI+wXa9gDeuKmbXqBK36SastKo/7lYY2B9PXiwGvniiJ9gRfbymvPu7swt4U/kgtoQbsGyxQ0pJ3q+U4tOKbWFV854CB1f2qepwgGX9+0WaTY2Viq4qo7TK5U28hU8YdXL8XlDck4fIUTnpY0ALxXvUzZGafSFiZJDxQiGODlewp+g/QFrY2qtXFO/i0k378FTj85YLXTem3puLRChE1BpUtl+AhuB+wMFjxfsjBv9ZL1lMxMUR8gQfteX19IkL41RqCTFuLC+CJm81M6sIdOAiuvsXrrHkmvo1N5SU2neT202P6T1aw1AYxiHHqWqjifyay8oGhOhG3ajgHEhipLCRGirx3JLe/oLsSGSgvQA==
X-OriginatorOrg: arm.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2020 01:08:19.2448 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 505e2834-3d1c-4250-08a3-08d7fb911e4e
X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123];
 Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2119
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>
Cc: Justin He <Justin.He@arm.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

SGkgSnVsaWVuLA0KDQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IEp1bGll
biBHcmFsbCA8anVsaWVuQHhlbi5vcmc+DQo+IFNlbnQ6IE1vbmRheSwgTWF5IDE4LCAyMDIwIDEx
OjA2IFBNDQo+IFRvOiBKaWFueW9uZyBXdSA8SmlhbnlvbmcuV3VAYXJtLmNvbT47IG1pbmlvcy0N
Cj4gZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmc7IHNoYXJhbi5zYW50aGFuYW1AbmVjbGFiLmV1
Ow0KPiBzaW1vbi5rdWVuemVyQG5lY2xhYi5ldQ0KPiBDYzogSnVzdGluIEhlIDxKdXN0aW4uSGVA
YXJtLmNvbT4NCj4gU3ViamVjdDogUmU6IFtQQVRDSF0gYXJtNjQ6IHJld3JpdGUgaW8gci93IGhl
bHBlciB0byBhdm9pZCBrdm0gY3Jhc2guDQo+DQo+IEhpLA0KPg0KPiBPbiAxNS8wNS8yMDIwIDA2
OjUzLCBKaWFueW9uZyBXdSB3cm90ZToNCj4gPiBGb3Igbm93LCB1bmlrcmFmdCB3aWxsIGNyYXNo
IG9uIGFybTY0IGluIGt2bSBtb2RlIGlmIGl0IGNvbXBpbGVkIHVzaW5nDQo+DQo+IHMvaXQgY29t
cGlsZWQvaXQgd2FzIGNvbXBpbGVkLw0KPg0KSSB3aWxsIGZpeCBhbGwgb2YgdGhlc2Ugc3BlbGxp
bmcgYW5kIGdyYW1tYXIgZmF1bHQuDQoNCj4gPiBvcHRpbWl6ZSBtb2RlLiBCZWNhdXNlIGNvbXBp
bGVyIHdpbGwgY2hvb3NlIHBvc3QtaW5kZXggc3RyIGludHJzIHRvDQo+DQo+IHMvY29tcGlsZXIv
YSBjb21waWxlci8gb3IgdGhlIGNvbXBpbGVyLg0KPg0KPiBzL2ludHJzL2luc3RydWN0aW9ucy8N
Cj4NCj4gPiB3cml0ZSBkZXZpY2UgbWVtb3J5LiBVbmx1Y2tpbHksIGFybTY0IHZpcnR1YWxpemF0
aW9uIGV4dGVuc2lvbiBkb2VzDQo+ID4gb25seSBwcm92aWRlcyBzeW5kcm9tZSBpbmZvcm1hdGlv
biBmb3IgYSBsaW1pdGVkIHN1YnNldCBvZiBsb2FkL3N0b3JlDQo+DQo+IHMvZG9lcyBvbmx5IHBy
b3ZpZGVzL29ubHkgcHJvdmlkZXMvDQo+DQo+ID4gaW5zdHJ1Y3Rpb25zLCB0aGF0IG1lYW5zIHdl
IGNhbid0IHVzZSBsb2FkL3N0b3JlIHdpdGggd3JpdGViYWNrDQo+ID4gYWRkcmVzc2luZyBtb2Rl
IHRvIGFjY2VzcyBtbWlvIGRldmljZS4NCj4gPiBUbyBhdm9pZCB0aGUgY29tcGlsZXIgZG8gdGhv
c2Ugb3B0aW1pemF0aW9uLCBpbyByZWFkL3dyaXRlIGhlbHBlcnMNCj4gPiBzaG91bGQNCj4NCj4g
cy9kby90byBkby8gSSB0aGluay4NCj4NCj4gPiBiZSByZXdpdHRlbiBieSBpbmxpbmUgYXNzZW1i
bHkgd2l0aCB2b2xhdGlsZSBjb25zdHJhaW50LiBBZnRlciB0aGlzLA0KPg0KPiBzL2J5L3VzaW5n
Lw0KPg0KPiA+IHVuaWtyYWZ0IGNhbiB3b3JrIGZpbmUgb24gYXJtNjQuDQo+ID4NCj4gPiBTaWdu
ZWQtb2ZmLWJ5OiBKaWFueW9uZyBXdSA8amlhbnlvbmcud3VAYXJtLmNvbT4NCj4gPiAtLS0NCj4g
PiAgIHBsYXQvY29tbW9uL2luY2x1ZGUvYXJtL2FybTY0L2NwdS5oIHwgODQgKysrKysrKysrKysr
KysrKysrKystLS0NCj4gLS0tLS0tDQo+ID4gICAxIGZpbGUgY2hhbmdlZCwgNTkgaW5zZXJ0aW9u
cygrKSwgMjUgZGVsZXRpb25zKC0pDQo+ID4NCj4gPiBkaWZmIC0tZ2l0IGEvcGxhdC9jb21tb24v
aW5jbHVkZS9hcm0vYXJtNjQvY3B1LmgNCj4gPiBiL3BsYXQvY29tbW9uL2luY2x1ZGUvYXJtL2Fy
bTY0L2NwdS5oDQo+ID4gaW5kZXggOTNhZDEzYi4uOTk0ZDJmMiAxMDA2NDQNCj4gPiAtLS0gYS9w
bGF0L2NvbW1vbi9pbmNsdWRlL2FybS9hcm02NC9jcHUuaA0KPiA+ICsrKyBiL3BsYXQvY29tbW9u
L2luY2x1ZGUvYXJtL2FybTY0L2NwdS5oDQo+ID4gQEAgLTQxLDMxICs0MSw2NSBAQA0KPiA+ICAg
I2luY2x1ZGUgPHVrL2FsbG9jLmg+DQo+ID4gICAjaW5jbHVkZSA8dWsvYXNzZXJ0Lmg+DQo+ID4N
Cj4gPiAtLyogRGVmaW5lIG1hY3JvcyB0byBhY2Nlc3MgSU8gcmVnaXN0ZXJzICovIC0jZGVmaW5l
DQo+ID4gX19JT1JFR19SRUFEKGJpdHMpIFwgLXN0YXRpYyBpbmxpbmUgdWludCMjYml0cyMjX3Qg
XA0KPiA+IC1pb3JlZ19yZWFkIyNiaXRzKGNvbnN0IHZvbGF0aWxlIHVpbnQjI2JpdHMjI190ICph
ZGRyKSBcDQo+ID4gLXsgcmV0dXJuICphZGRyOyB9DQo+ID4gLQ0KPiA+IC0jZGVmaW5lIF9fSU9S
RUdfV1JJVEUoYml0cykgXA0KPiA+IC1zdGF0aWMgaW5saW5lIHZvaWQgXA0KPiA+IC1pb3JlZ193
cml0ZSMjYml0cyh2b2xhdGlsZSB1aW50IyNiaXRzIyNfdCAqYWRkciwgXA0KPiA+IC11aW50IyNi
aXRzIyNfdCB2YWx1ZSkgXA0KPiA+IC17ICphZGRyID0gdmFsdWU7IH0NCj4gPiAtDQo+ID4gLQ0K
PiA+IC0jZGVmaW5lIF9fSU9SRUdfUkVBRF9BTEwoKSBfX0lPUkVHX1JFQUQoOCkgIFwNCj4gPiAt
ICAgX19JT1JFR19SRUFEKDE2KSBcDQo+ID4gLSAgIF9fSU9SRUdfUkVBRCgzMikgXA0KPiA+IC0g
ICBfX0lPUkVHX1JFQUQoNjQpIFwNCj4gPiAtDQo+ID4gLSNkZWZpbmUgX19JT1JFR19XUklURV9B
TEwoKV9fSU9SRUdfV1JJVEUoOCkgIFwNCj4gPiAtICAgX19JT1JFR19XUklURSgxNikgXA0KPiA+
IC0gICBfX0lPUkVHX1dSSVRFKDMyKSBcDQo+ID4gLSAgIF9fSU9SRUdfV1JJVEUoNjQpIFwNCj4g
PiAtDQo+ID4gLV9fSU9SRUdfUkVBRF9BTEwoKQ0KPiA+IC1fX0lPUkVHX1dSSVRFX0FMTCgpDQo+
ID4gKy8qDQo+ID4gKyAqIHdlIHNob3VsZCB1c2UgaW5saW5lIGFzc2VtYmx5IHdpdGggdm9sYXRp
bGUgY29uc3RyYWluIHRvIGFjY2VzcyBJTw0KPg0KPiBzL2NvbnN0cmFpbi9jb25zdHJhaW5zdC8N
Cj4NCj4gPiArICogcmVnaXN0ZXJzIHRvIGF2b2lkIGNvbXBpbGVyIHVzZSBsb2FkL3N0b3JlIGlu
dHJucyBvZiB3cml0ZWJhY2sNCj4gPiArICogYWRkcmVzc2luZyBtb2RlIHdoaWNoIHdpbGwgY2F1
c2UgY3Jhc2ggd2hlbiBydW5uaW5nIGluIGt2bSBtb2RlLg0KPg0KPiBUaGlzIGlzIG5vdCBzcGVj
aWZpYyB0byBLVk0gbW9kZS4gVGhpcyB3aWxsIGhhcHBlbmluZyBvbiBhbnkgaHlwZXJ2aXNvcg0K
PiB1bmxlc3MgdGhleSBkZWNvZGUgdGhlIGluc3RydWN0aW9uICh3aGljaCBpcyBxdWl0ZSBleHBl
bnNpdmUpLg0KPg0KWWVhaCwgc2hvdWxkIG5vdCBzcGVjaWZ5IGh5cGVyIG1vZGUgaGVyZS4NCg0K
VGhhbmtzDQpKaWFueW9uZw0KDQo+ID4gKyAqLw0KPiA+ICtzdGF0aWMgaW5saW5lIHVpbnQ4X3Qg
aW9yZWdfcmVhZDgoY29uc3Qgdm9sYXRpbGUgdWludDhfdCAqYWRkcmVzcykgew0KPiA+ICt1aW50
OF90IHZhbHVlOw0KPiA+ICsNCj4gPiArYXNtIHZvbGF0aWxlICgibGRyYiAldzAsIFslMV0iIDog
Ij1yIih2YWx1ZSkgOiAiciIoYWRkcmVzcykpOw0KPiA+ICtyZXR1cm4gdmFsdWU7DQo+ID4gK30N
Cj4gPiArDQo+ID4gK3N0YXRpYyBpbmxpbmUgdWludDE2X3QgaW9yZWdfcmVhZDE2KGNvbnN0IHZv
bGF0aWxlIHVpbnQxNl90ICphZGRyZXNzKQ0KPiA+ICt7DQo+ID4gK3VpbnQxNl90IHZhbHVlOw0K
PiA+ICsNCj4gPiArYXNtIHZvbGF0aWxlICgibGRyaCAldzAsIFslMV0iIDogIj1yIih2YWx1ZSkg
OiAiciIoYWRkcmVzcykpOw0KPiA+ICtyZXR1cm4gdmFsdWU7DQo+ID4gK30NCj4gPiArDQo+ID4g
K3N0YXRpYyBpbmxpbmUgdWludDMyX3QgaW9yZWdfcmVhZDMyKGNvbnN0IHZvbGF0aWxlIHVpbnQz
Ml90ICphZGRyZXNzKQ0KPiA+ICt7DQo+ID4gK3VpbnQzMl90IHZhbHVlOw0KPiA+ICsNCj4gPiAr
YXNtIHZvbGF0aWxlICgibGRyICV3MCwgWyUxXSIgOiAiPXIiKHZhbHVlKSA6ICJyIihhZGRyZXNz
KSk7DQo+ID4gK3JldHVybiB2YWx1ZTsNCj4gPiArfQ0KPiA+ICsNCj4gPiArc3RhdGljIGlubGlu
ZSB1aW50NjRfdCBpb3JlZ19yZWFkNjQoY29uc3Qgdm9sYXRpbGUgdWludDY0X3QgKmFkZHJlc3Mp
DQo+ID4gK3sNCj4gPiArdWludDY0X3QgdmFsdWU7DQo+ID4gKw0KPiA+ICthc20gdm9sYXRpbGUg
KCJsZHIgJTAsIFslMV0iIDogIj1yIih2YWx1ZSkgOiAiciIoYWRkcmVzcykpOw0KPiA+ICtyZXR1
cm4gdmFsdWU7DQo+ID4gK30NCj4gPiArDQo+ID4gK3N0YXRpYyBpbmxpbmUgdm9pZCBpb3JlZ193
cml0ZTgoY29uc3Qgdm9sYXRpbGUgdWludDhfdCAqYWRkcmVzcywNCj4gPiArdWludDhfdCB2YWx1
ZSkgew0KPiA+ICthc20gdm9sYXRpbGUgKCJzdHJiICV3MCwgWyUxXSIgOiA6ICJyWiIodmFsdWUp
LCAiciIoYWRkcmVzcykpOyB9DQo+ID4gKw0KPiA+ICtzdGF0aWMgaW5saW5lIHZvaWQgaW9yZWdf
d3JpdGUxNihjb25zdCB2b2xhdGlsZSB1aW50MTZfdCAqYWRkcmVzcywNCj4gPiArIHVpbnQxNl90
IHZhbHVlKQ0KPiA+ICt7DQo+ID4gK2FzbSB2b2xhdGlsZSAoInN0cmggJXcwLCBbJTFdIiA6IDog
InJaIih2YWx1ZSksICJyIihhZGRyZXNzKSk7IH0NCj4gPiArDQo+ID4gK3N0YXRpYyBpbmxpbmUg
dm9pZCBpb3JlZ193cml0ZTMyKGNvbnN0IHZvbGF0aWxlIHVpbnQzMl90ICphZGRyZXNzLA0KPiA+
ICsgdWludDMyX3QgdmFsdWUpDQo+ID4gK3sNCj4gPiArYXNtIHZvbGF0aWxlICgic3RyICV3MCwg
WyUxXSIgOiA6ICJyWiIodmFsdWUpLCAiciIoYWRkcmVzcykpOyB9DQo+ID4gKw0KPiA+ICtzdGF0
aWMgaW5saW5lIHZvaWQgaW9yZWdfd3JpdGU2NChjb25zdCB2b2xhdGlsZSB1aW50NjRfdCAqYWRk
cmVzcywNCj4gPiArIHVpbnQ2NF90IHZhbHVlKQ0KPiA+ICt7DQo+ID4gK2FzbSB2b2xhdGlsZSAo
InN0ciAlMCwgWyUxXSIgOiA6ICJyWiIodmFsdWUpLCAiciIoYWRkcmVzcykpOyB9DQo+DQo+IE5J
VDogV291bGQgaXQgYmUgcG9zc2libGUgdG8gbWFjcm8taXplIHRoaXM/DQo+DQo+IFJlZ2FyZGxl
c3MgdGhpcyBxdWVzdGlvbjoNCj4NCj4gUmV2aWV3ZWQtYnk6IEp1bGllbiBHcmFsbCA8anVsaWVu
QHhlbi5vcmc+DQo+DQo+IENoZWVycywNCj4NCj4gLS0NCj4gSnVsaWVuIEdyYWxsDQpJTVBPUlRB
TlQgTk9USUNFOiBUaGUgY29udGVudHMgb2YgdGhpcyBlbWFpbCBhbmQgYW55IGF0dGFjaG1lbnRz
IGFyZSBjb25maWRlbnRpYWwgYW5kIG1heSBhbHNvIGJlIHByaXZpbGVnZWQuIElmIHlvdSBhcmUg
bm90IHRoZSBpbnRlbmRlZCByZWNpcGllbnQsIHBsZWFzZSBub3RpZnkgdGhlIHNlbmRlciBpbW1l
ZGlhdGVseSBhbmQgZG8gbm90IGRpc2Nsb3NlIHRoZSBjb250ZW50cyB0byBhbnkgb3RoZXIgcGVy
c29uLCB1c2UgaXQgZm9yIGFueSBwdXJwb3NlLCBvciBzdG9yZSBvciBjb3B5IHRoZSBpbmZvcm1h
dGlvbiBpbiBhbnkgbWVkaXVtLiBUaGFuayB5b3UuDQo=


From minios-devel-bounces@lists.xenproject.org Wed May 20 09:52:23 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 20 May 2020 09:52:23 +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 1jbLOf-0007pP-4u; Wed, 20 May 2020 09:52:21 +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=ZX5c=7C=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jbLOe-0007pK-3i
 for minios-devel@lists.xenproject.org; Wed, 20 May 2020 09:52:20 +0000
X-Inumbo-ID: 95cccb64-9a7f-11ea-a9dc-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 95cccb64-9a7f-11ea-a9dc-12813bfff9fa;
 Wed, 20 May 2020 09:52:17 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9CB3A31B;
 Wed, 20 May 2020 02:52:16 -0700 (PDT)
Received: from localhost.localdomain (unknown [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2127B3F68F;
 Wed, 20 May 2020 02:52:13 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org,
	Cristian Banu <cristb@gmail.com>
Subject: [[UNIKRAFT PATCH] lib/uk9p,
 9pfs: Change file mode from uint8_t to uint32_t
Date: Wed, 20 May 2020 17:52:05 +0800
Message-Id: <20200520095205.55288-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

At least UK_9P_OEXCL(0x1000) is uint8_t overflowed. To avoid potential
file mode undesigned truncating, change it uint8_t to uint32_t.

Signed-off-by: Jia He <justin.he@arm.com>
---
 lib/9pfs/9pfs_vnops.c    | 6 +++---
 lib/uk9p/9p.c            | 4 ++--
 lib/uk9p/include/uk/9p.h | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/9pfs/9pfs_vnops.c b/lib/9pfs/9pfs_vnops.c
index c81c82a..5a0700c 100644
--- a/lib/9pfs/9pfs_vnops.c
+++ b/lib/9pfs/9pfs_vnops.c
@@ -47,10 +47,10 @@
 
 #include "9pfs.h"
 
-static uint8_t uk_9pfs_open_mode_from_posix_flags(unsigned long flags)
+static uint32_t uk_9pfs_open_mode_from_posix_flags(int flags)
 {
-	uint8_t mode = 0;
-	uint8_t flags_rw = flags & (UK_FREAD | UK_FWRITE);
+	uint32_t mode = 0;
+	uint32_t flags_rw = flags & (UK_FREAD | UK_FWRITE);
 
 	if (flags_rw == UK_FREAD)
 		mode = UK_9P_OREAD;
diff --git a/lib/uk9p/9p.c b/lib/uk9p/9p.c
index 9ac7e8a..abddb60 100644
--- a/lib/uk9p/9p.c
+++ b/lib/uk9p/9p.c
@@ -266,7 +266,7 @@ out:
 	return newfid;
 }
 
-int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode)
+int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint32_t mode)
 {
 	struct uk_9preq *req;
 	int rc = 0;
@@ -294,7 +294,7 @@ out:
 }
 
 int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
-		const char *name, uint32_t perm, uint8_t mode,
+		const char *name, uint32_t perm, uint32_t mode,
 		const char *extension)
 {
 	struct uk_9preq *req;
diff --git a/lib/uk9p/include/uk/9p.h b/lib/uk9p/include/uk/9p.h
index 59d18d9..e91b147 100644
--- a/lib/uk9p/include/uk/9p.h
+++ b/lib/uk9p/include/uk/9p.h
@@ -129,7 +129,7 @@ struct uk_9pfid *uk_9p_walk(struct uk_9pdev *dev, struct uk_9pfid *fid,
  *   - 0: Successful.
  *   - (< 0): An error occurred.
  */
-int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode);
+int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint32_t mode);
 
 /**
  * Creates a new file with the given name in the directory associated with fid,
@@ -153,7 +153,7 @@ int uk_9p_open(struct uk_9pdev *dev, struct uk_9pfid *fid, uint8_t mode);
  *   - (< 0): An error occurred.
  */
 int uk_9p_create(struct uk_9pdev *dev, struct uk_9pfid *fid,
-		const char *name, uint32_t perm, uint8_t mode,
+		const char *name, uint32_t perm, uint32_t mode,
 		const char *extension);
 
 /**
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Wed May 20 09:56:16 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 20 May 2020 09:56: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 1jbLSQ-0007yJ-O9; Wed, 20 May 2020 09:56: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=ZX5c=7C=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jbLSP-0007yD-Tw
 for minios-devel@lists.xenproject.org; Wed, 20 May 2020 09:56:13 +0000
X-Inumbo-ID: 230ecdf6-9a80-11ea-a9dd-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 230ecdf6-9a80-11ea-a9dd-12813bfff9fa;
 Wed, 20 May 2020 09:56:13 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1BC6755D;
 Wed, 20 May 2020 02:56:13 -0700 (PDT)
Received: from localhost.localdomain (unknown [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BF8213F68F;
 Wed, 20 May 2020 02:56:10 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org,
	Costin Lupu <costin.lupu@cs.pub.ro>
Subject: [UNIKRAFT/NEWLIB PATCH] include/fcntl.h: Replace O_NONBLOCK with new
 one on arm
Date: Wed, 20 May 2020 17:56:03 +0800
Message-Id: <20200520095603.55457-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

in newlib _default_fcntl.h, it defines O_NONBLOCK as follows:
\#define _FNONBLOCK      0x4000  /* non blocking I/O (POSIX style) */
But it is different from linux definition(04000=0x800):
\#define O_NONBLOCK	00004000

This difference confused virtio-9p open() syscall. If you open a
file with O_NONBLOCK(is 0x4000 in newlib) and sys_open will regard
it as O_DIRECTORY. At last it returns a ENOTDIR error.

Signed-off-by: Jia He <justin.he@arm.com>
---
 include/fcntl.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/fcntl.h b/include/fcntl.h
index feb4f7c..367c1e6 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -15,6 +15,8 @@
 #define O_DIRECT     040000
 #define O_NOATIME  01000000
 #elif ((defined CONFIG_ARCH_ARM_64) || (defined CONFIG_ARCH_ARM_32))
+#undef O_NONBLOCK
+#define O_NONBLOCK    04000
 #define O_NOFOLLOW  0100000
 #define O_DIRECTORY  040000
 #define O_CLOEXEC  02000000
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Wed May 20 16:14:48 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 20 May 2020 16:14:48 +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 1jbRMj-000286-Kb; Wed, 20 May 2020 16:14: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=Ri8L=7C=stablerock.de=mamu@srs-us1.protection.inumbo.net>)
 id 1jbPK9-0006Um-Pn
 for minios-devel@lists.xenproject.org; Wed, 20 May 2020 14:03:57 +0000
X-Inumbo-ID: bde48fcc-9aa2-11ea-b07b-bc764e2007e4
Received: from mail.stablerock.de (unknown [2a03:4000:21:321::12])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id bde48fcc-9aa2-11ea-b07b-bc764e2007e4;
 Wed, 20 May 2020 14:03:56 +0000 (UTC)
Received: from [IPv6:2a02:908:4f5:7d20:800e:8852:68be:971c] (<unknown>
 [2a02:908:4f5:7d20:800e:8852:68be:971c])
 by srv.stablerock.de (OpenSMTPD) with ESMTPSA id 2079f04c
 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO)
 for <minios-devel@lists.xenproject.org>;
 Wed, 20 May 2020 16:03:54 +0200 (CEST)
To: minios-devel@lists.xenproject.org
From: =?UTF-8?Q?Malte_M=c3=bcnch?= <mamu@stablerock.de>
Subject: Unikraft stock project helloworld-cpp not compiling
X-Pep-Version: 2.0
Message-ID: <47813e2e-14c4-205f-e979-a7b3c7a3b275@stablerock.de>
Date: Wed, 20 May 2020 16:03:54 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------C6B1F6675A33A4BB00086730"
Content-Language: en-US
X-Mailman-Approved-At: Wed, 20 May 2020 16:14:44 +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>

This is a multi-part message in MIME format.
--------------C6B1F6675A33A4BB00086730
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hello Unikraft-devs,

i am not able to compile the current 0.4 Verion of Unikraft with the
Hello-World example written in C++. Here is what i tried:

kraft up -m x86_64 -p kvm helloworld-cpp

The process crashes with the following error:

In file included from
/home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/io=
sfwd:90,
                 from
/home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/io=
s:215,
                 from
/home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/io=
stream:38,
                 from /home/pg635/helloworldcpp/helloworld.cpp:1:
/home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/wc=
har.h:119:15:
fatal error: wchar.h: no such file or directory
 #include_next <wchar.h>
               ^~~~~~~~~

kraft itself works and i am able to compile and run the Helloworld
application written in C.

Looking forward to your replies.

Best
Malte

--------------C6B1F6675A33A4BB00086730
Content-Type: application/pgp-keys;
 name="pEpkey.asc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="pEpkey.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

mQENBF7E8HgBCACqfabDmZ9BCu8QQB/FjlO6RB/4XfM8KIQRSiVzcZkS8aCuOT31
rNkUFfEx4vn9RwfhC+l/v0H2tnbBWQA3BOw73f8ow/aq0M0r02jerZ8ASXRDkcK2
SVXe9MwUL7MjrLcLzsPjM53FZjuelRbbeVpM3BhJpqVH5IR8TyjkwUt1ntn7zH/0
y1O0h5CF4KQ0ViTG7tXGJe1T1rIcvLYQtLyIM8ux7DokI7TCmM8lstu4TF5mjGJd
MgTdhEVyY403HAnpeDWuwaxDY+feZ06h8A2K00YTio6riiyDejeVHknpJjJdVBrX
DFCRXR8foGf6lQMrDwESIXPZpBOsrCzh9F5xABEBAAG0IU1hbHRlIE3DvG5jaCA8
bWFtdUBzdGFibGVyb2NrLmRlPokBVAQTAQgAPhYhBEVd+wXerG+TrWrHizCUUEOI
aJZzBQJexPB5AhsDBQkB4TOABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEDCU
UEOIaJZzNCcH/2ScVytBTar0A+zGw7L0tnkMCJ/RODKDo9UnF8MurBi4HFqiozfd
IegzlFFe8fNImdN0qenXMydnGjK3sYyACF6TLSl0mYIh+JRPnQ8ONsxofqTheITR
XNH6ArgBE+YLqDb6yWv/Ng3pNoo47oeNNpEML6C8S0XDChG5pKHjPomotQViZPQa
exP35PXyE+osyuoB9tAO2uH8KioiN+BRQh9OtNjv+sSQaVZ07ONIVyBSHpiYf2/g
BpxIinQe1rcZxLHlg8T76qlI0D62kdlLpp8niIiCxnpsbxpIk1sH2AGbB0pegCgR
YGlPvecWch641C0JGXzI3/RfcDbobWWTPA+5AQ0EXsTweAEIANAC5t0IwBkzCdP/
qYHIBWbTjsTI8IENRCasmlgQy6gqXmb7jcNGC4aqJwJpLykDLYfZFjXBAtFH8xsp
jWysgTVBMuRUIMW/yi9OCb5tYNrlAqb+PwVbIefcnvbncAx6zTC7zI7DDffYjIMC
uuqsbzVAqZdwl0QXR7I47iwy7WmUuGmiPyVu+btuwrD6rQK6JsPqF/mDdMkaFYVx
z512YoFQ4fkq5fxVewTpW7KCaYdJ+tR6kjcv8yuHqHPdY0eEcUsB0A2v3zIpXeey
dUFV3w1KqMwjI0wiqh3xZmvmzUnio0KNBQHnbTN3yvF2Dgz26lJJI4AiVvanTG5A
VREw76sAEQEAAYkBPAQYAQgAJhYhBEVd+wXerG+TrWrHizCUUEOIaJZzBQJexPB4
AhsMBQkB4TOAAAoJEDCUUEOIaJZzi2YIAKpZgbK1EVXGFn5Vwx237XpUw5apIcup
zTc7g/zAJTs95bKiTtwYQghSKt+LpbyCJiWaJSdN4OYGH5vt+WG/gKKbsmgBWkLu
2oV2amaY2UOs41/8DoNU4+9U4YH9b0p/LNP31NIa528R/Jt3dIg8ana74W1gDigL
jMC5E5ZdHXkfT/n/+bD69ezjeX3mDpBtzDi/hA0CrszHq06qO/Q6BzmkvUzCrxYZ
qNx9Th6WS98Y668rBTk/WxhEp/3f+cbBrNip6popCyoLfscKQai2pydApJmMaMhs
o/tdbc+7pjfyvolIB32drCnvLWdDwcZ6ZB7DdaT39M45nkE+ClAhdTE=3D
=3DpGGV
-----END PGP PUBLIC KEY BLOCK-----

--------------C6B1F6675A33A4BB00086730--


From minios-devel-bounces@lists.xenproject.org Wed May 20 16:14:48 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 20 May 2020 16:14:48 +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 1jbRMj-00028B-M7; Wed, 20 May 2020 16:14: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=Ri8L=7C=stablerock.de=mamu@srs-us1.protection.inumbo.net>)
 id 1jbPPa-0006eN-6n
 for minios-devel@lists.xenproject.org; Wed, 20 May 2020 14:09:34 +0000
X-Inumbo-ID: 86bf4d7e-9aa3-11ea-9887-bc764e2007e4
Received: from mail.stablerock.de (unknown [2a03:4000:21:321::12])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 86bf4d7e-9aa3-11ea-9887-bc764e2007e4;
 Wed, 20 May 2020 14:09:32 +0000 (UTC)
Received: from [IPv6:2a02:908:4f5:7d20:800e:8852:68be:971c] (<unknown>
 [2a02:908:4f5:7d20:800e:8852:68be:971c])
 by srv.stablerock.de (OpenSMTPD) with ESMTPSA id ee91d24d
 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO)
 for <minios-devel@lists.xenproject.org>;
 Wed, 20 May 2020 16:09:31 +0200 (CEST)
To: minios-devel@lists.xenproject.org
From: =?UTF-8?Q?Malte_M=c3=bcnch?= <mamu@stablerock.de>
Subject: Unikraft stock project helloworld-cpp not compiling
X-Pep-Version: 2.0
Message-ID: <af6608ec-7baa-e7d1-2ce5-7cc7b696a98c@stablerock.de>
Date: Wed, 20 May 2020 16:09:32 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------C23CA9D683D325DEF7EEDD71"
Content-Language: en-US
X-Mailman-Approved-At: Wed, 20 May 2020 16:14:44 +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>

This is a multi-part message in MIME format.
--------------C23CA9D683D325DEF7EEDD71
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hello Unikraft-devs,

i am not able to compile the current 0.4 Verion of Unikraft with the
Hello-World example written in C++. Here is what i tried:

kraft up -m x86_64 -p kvm helloworld-cpp

The process crashes with the following error:

In file included from
/home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/io=
sfwd:90,
                 from
/home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/io=
s:215,
                 from
/home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/io=
stream:38,
                 from /home/pg635/helloworldcpp/helloworld.cpp:1:
/home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/wc=
har.h:119:15:
fatal error: wchar.h: no such file or directory
 #include_next <wchar.h>
               ^~~~~~~~~

kraft itself works and i am able to compile and run the Helloworld
application written in C.

Looking forward to your replies.

Best
Malte

--------------C23CA9D683D325DEF7EEDD71
Content-Type: application/pgp-keys;
 name="pEpkey.asc"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="pEpkey.asc"

-----BEGIN PGP PUBLIC KEY BLOCK-----

mQENBF7E8HgBCACqfabDmZ9BCu8QQB/FjlO6RB/4XfM8KIQRSiVzcZkS8aCuOT31
rNkUFfEx4vn9RwfhC+l/v0H2tnbBWQA3BOw73f8ow/aq0M0r02jerZ8ASXRDkcK2
SVXe9MwUL7MjrLcLzsPjM53FZjuelRbbeVpM3BhJpqVH5IR8TyjkwUt1ntn7zH/0
y1O0h5CF4KQ0ViTG7tXGJe1T1rIcvLYQtLyIM8ux7DokI7TCmM8lstu4TF5mjGJd
MgTdhEVyY403HAnpeDWuwaxDY+feZ06h8A2K00YTio6riiyDejeVHknpJjJdVBrX
DFCRXR8foGf6lQMrDwESIXPZpBOsrCzh9F5xABEBAAG0IU1hbHRlIE3DvG5jaCA8
bWFtdUBzdGFibGVyb2NrLmRlPokBVAQTAQgAPhYhBEVd+wXerG+TrWrHizCUUEOI
aJZzBQJexPB5AhsDBQkB4TOABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEDCU
UEOIaJZzNCcH/2ScVytBTar0A+zGw7L0tnkMCJ/RODKDo9UnF8MurBi4HFqiozfd
IegzlFFe8fNImdN0qenXMydnGjK3sYyACF6TLSl0mYIh+JRPnQ8ONsxofqTheITR
XNH6ArgBE+YLqDb6yWv/Ng3pNoo47oeNNpEML6C8S0XDChG5pKHjPomotQViZPQa
exP35PXyE+osyuoB9tAO2uH8KioiN+BRQh9OtNjv+sSQaVZ07ONIVyBSHpiYf2/g
BpxIinQe1rcZxLHlg8T76qlI0D62kdlLpp8niIiCxnpsbxpIk1sH2AGbB0pegCgR
YGlPvecWch641C0JGXzI3/RfcDbobWWTPA+5AQ0EXsTweAEIANAC5t0IwBkzCdP/
qYHIBWbTjsTI8IENRCasmlgQy6gqXmb7jcNGC4aqJwJpLykDLYfZFjXBAtFH8xsp
jWysgTVBMuRUIMW/yi9OCb5tYNrlAqb+PwVbIefcnvbncAx6zTC7zI7DDffYjIMC
uuqsbzVAqZdwl0QXR7I47iwy7WmUuGmiPyVu+btuwrD6rQK6JsPqF/mDdMkaFYVx
z512YoFQ4fkq5fxVewTpW7KCaYdJ+tR6kjcv8yuHqHPdY0eEcUsB0A2v3zIpXeey
dUFV3w1KqMwjI0wiqh3xZmvmzUnio0KNBQHnbTN3yvF2Dgz26lJJI4AiVvanTG5A
VREw76sAEQEAAYkBPAQYAQgAJhYhBEVd+wXerG+TrWrHizCUUEOIaJZzBQJexPB4
AhsMBQkB4TOAAAoJEDCUUEOIaJZzi2YIAKpZgbK1EVXGFn5Vwx237XpUw5apIcup
zTc7g/zAJTs95bKiTtwYQghSKt+LpbyCJiWaJSdN4OYGH5vt+WG/gKKbsmgBWkLu
2oV2amaY2UOs41/8DoNU4+9U4YH9b0p/LNP31NIa528R/Jt3dIg8ana74W1gDigL
jMC5E5ZdHXkfT/n/+bD69ezjeX3mDpBtzDi/hA0CrszHq06qO/Q6BzmkvUzCrxYZ
qNx9Th6WS98Y668rBTk/WxhEp/3f+cbBrNip6popCyoLfscKQai2pydApJmMaMhs
o/tdbc+7pjfyvolIB32drCnvLWdDwcZ6ZB7DdaT39M45nkE+ClAhdTE=3D
=3DpGGV
-----END PGP PUBLIC KEY BLOCK-----

--------------C23CA9D683D325DEF7EEDD71--


From minios-devel-bounces@lists.xenproject.org Wed May 20 16:41:39 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 20 May 2020 16:41: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 1jbRmj-0004cx-Vu; Wed, 20 May 2020 16:41: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=NHGV=7C=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jbRmi-0004cr-OL
 for minios-devel@lists.xen.org; Wed, 20 May 2020 16:41:36 +0000
X-Inumbo-ID: c3eefb58-9ab8-11ea-ae69-bc764e2007e4
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c3eefb58-9ab8-11ea-ae69-bc764e2007e4;
 Wed, 20 May 2020 16:41:34 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id B5D78103F68;
 Wed, 20 May 2020 18:41:33 +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 FAxVxjU-cQ38; Wed, 20 May 2020 18:41:33 +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 94872103F3B
 for <minios-devel@lists.xen.org>; Wed, 20 May 2020 18:41:33 +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.1713.5; Wed, 20 May
 2020 18:41:33 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
Subject: [UNIKRAFT PATCH] lib/syscall_shim: Add option to enable debugging
Date: Wed, 20 May 2020 18:41:30 +0200
Message-ID: <20200520164130.14606-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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Adds an option to enable debug messages for the syscall_shim library only.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/syscall_shim/Config.uk   | 4 ++++
 lib/syscall_shim/Makefile.uk | 1 +
 2 files changed, 5 insertions(+)

diff --git a/lib/syscall_shim/Config.uk b/lib/syscall_shim/Config.uk
index 9c39ed2f..1d90cf7f 100644
--- a/lib/syscall_shim/Config.uk
+++ b/lib/syscall_shim/Config.uk
@@ -34,4 +34,8 @@ if LIBSYSCALL_SHIM
 			requests (e.g., sysenter/sysexit). The handler maps
 			register values accordingly to the Linux ABI standard
 			(see: man syscalls[2]).
+
+	config LIBSYSCALL_SHIM_DEBUG
+		bool "Enable debug messages"
+		default n
 endif
diff --git a/lib/syscall_shim/Makefile.uk b/lib/syscall_shim/Makefile.uk
index 37805c82..55d7488e 100644
--- a/lib/syscall_shim/Makefile.uk
+++ b/lib/syscall_shim/Makefile.uk
@@ -102,6 +102,7 @@ CINCLUDES-y   += -I$(LIBSYSCALL_SHIM_BASE)/include
 CXXINCLUDES-y += -I$(LIBSYSCALL_SHIM_BASE)/include
 
 LIBSYSCALL_SHIM_CINCLUDES += -I$(LIBSYSCALL_SHIM_BASE)
+LIBSYSCALL_SHIM_COMPFLAGS-$(CONFIG_LIBSYSCALL_SHIM_DEBUG) += -DUK_DEBUG
 
 LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall.c
 LIBSYSCALL_SHIM_SRCS-y += $(LIBSYSCALL_SHIM_BUILD)/uk_syscall6.c
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Wed May 20 16:41:57 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 20 May 2020 16:41: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 1jbRn3-0004e5-1p; Wed, 20 May 2020 16:41:57 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=NHGV=7C=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1jbRn1-0004dw-Sh
 for minios-devel@lists.xen.org; Wed, 20 May 2020 16:41:55 +0000
X-Inumbo-ID: cfcf7c04-9ab8-11ea-b07b-bc764e2007e4
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id cfcf7c04-9ab8-11ea-b07b-bc764e2007e4;
 Wed, 20 May 2020 16:41:54 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id A0E56F2003;
 Wed, 20 May 2020 18:41:53 +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 J2ZhkBjk_pwW; Wed, 20 May 2020 18:41:53 +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 795F5F2001
 for <minios-devel@lists.xen.org>; Wed, 20 May 2020 18:41:51 +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.1713.5; Wed, 20 May
 2020 18:41:51 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
Subject: [UNIKRAFT PATCH] lib/syscall_shim: Enable UK_LIBC_SYSCALLS when
 library is unselected
Date: Wed, 20 May 2020 18:41:48 +0200
Message-ID: <20200520164148.14680-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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Always enables UK_LIBC_SYSCALLS as soon as syscall_shim is
disabled. This enables all libc-style wrapper implementations of
system calls (e.g., open(), write()) when system calls are not
enabled. Those wrappers can only be disabled when syscall_shim is
selected and the hidden option LIBSYSCALL_SHIM_NOWRAPPER is set. This
is a very special case that may only be caused by some libcs that are
based on system calls and provide own libc-style wrappers (e.g., musl).

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/syscall_shim/include/uk/syscall.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/syscall_shim/include/uk/syscall.h b/lib/syscall_shim/include/uk/syscall.h
index 1be4ab91..ffa9f1ee 100644
--- a/lib/syscall_shim/include/uk/syscall.h
+++ b/lib/syscall_shim/include/uk/syscall.h
@@ -51,11 +51,11 @@
  * UK_LIBC_SYSCALLS can be set to 0 through compilation flags.
  */
 #ifndef UK_LIBC_SYSCALLS
-#if CONFIG_LIBSYSCALL_SHIM_NOWRAPPER
+#if CONFIG_LIBSYSCALL_SHIM && CONFIG_LIBSYSCALL_SHIM_NOWRAPPER
 #define UK_LIBC_SYSCALLS (0)
 #else
 #define UK_LIBC_SYSCALLS (1)
-#endif /* CONFIG_LIBSYSCALL_SHIM_NOWRAPPER */
+#endif /* CONFIG_LIBSYSCALL_SHIM && CONFIG_LIBSYSCALL_SHIM_NOWRAPPER */
 #endif /* UK_LIBC_SYSCALLS */
 
 #define __uk_scc(X) ((long) (X))
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Thu May 21 11:42:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 21 May 2020 11:42: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 1jbjb3-0008F2-MH; Thu, 21 May 2020 11:42:45 +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=R+as=7D=arm.com=jianyong.wu@srs-us1.protection.inumbo.net>)
 id 1jbjb1-0008Ex-UQ
 for minios-devel@lists.xenproject.org; Thu, 21 May 2020 11:42:43 +0000
X-Inumbo-ID: 2e29014a-9b58-11ea-aaf3-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 2e29014a-9b58-11ea-aaf3-12813bfff9fa;
 Thu, 21 May 2020 11:42:42 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0461530E;
 Thu, 21 May 2020 04:42:42 -0700 (PDT)
Received: from entos-d05.shanghai.arm.com (entos-d05.shanghai.arm.com
 [10.169.40.35])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2A66B3F68F;
 Thu, 21 May 2020 04:42:39 -0700 (PDT)
From: Jianyong Wu <jianyong.wu@arm.com>
To: minios-devel@lists.xenproject.org, sharan.santhanam@neclab.eu,
 simon.kuenzer@neclab.eu
Subject: [PATCH] arm64: rewrite io r/w helper to avoid kvm crash.
Date: Thu, 21 May 2020 19:42:27 +0800
Message-Id: <20200521114227.37703-1-jianyong.wu@arm.com>
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>
Cc: jianyong.wu@arm.com, Justin.He@arm.com
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

For now, unikraft will crash on arm64 in kvm mode if it is compiled using
optimize mode. Because the compiler will choose post-index str intructions
to write device memory. Unluckily, arm64 virtualization extension only
provides syndrome information for a limited subset of load/store
instructions, that means we can't use load/store with writeback addressing
mode to access mmio device.
To avoid the compiler to do those optimization, io read/write helpers
should be rewitten using inline assembly with volatile constraint. After
this, unikraft can work fine on arm64.

Reviewed-by: Julien Grall <julien@xen.org>
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
---
 plat/common/include/arm/arm64/cpu.h | 85 ++++++++++++++++++++---------
 1 file changed, 60 insertions(+), 25 deletions(-)

diff --git a/plat/common/include/arm/arm64/cpu.h b/plat/common/include/arm/arm64/cpu.h
index 93ad13b..fe981eb 100644
--- a/plat/common/include/arm/arm64/cpu.h
+++ b/plat/common/include/arm/arm64/cpu.h
@@ -41,31 +41,66 @@
 #include <uk/alloc.h>
 #include <uk/assert.h>
 
-/* Define macros to access IO registers */
-#define __IOREG_READ(bits) \
-static inline uint##bits##_t \
-	ioreg_read##bits(const volatile uint##bits##_t *addr) \
-		{ return *addr; }
-
-#define __IOREG_WRITE(bits) \
-static inline void \
-	ioreg_write##bits(volatile uint##bits##_t *addr, \
-						uint##bits##_t value) \
-		{ *addr = value; }
-
-
-#define __IOREG_READ_ALL() __IOREG_READ(8)  \
-			   __IOREG_READ(16) \
-			   __IOREG_READ(32) \
-			   __IOREG_READ(64) \
-
-#define __IOREG_WRITE_ALL()	__IOREG_WRITE(8)  \
-			   __IOREG_WRITE(16) \
-			   __IOREG_WRITE(32) \
-			   __IOREG_WRITE(64) \
-
-__IOREG_READ_ALL()
-__IOREG_WRITE_ALL()
+/*
+ * we should use inline assembly with volatile constraint to access mmio
+ * device memory to avoid compiler use load/store instructions of writeback
+ * addressing mode which will cause crash when running in hyper mode
+ * unless they will be decoded by hypervisor.
+ */
+static inline uint8_t ioreg_read8(const volatile uint8_t *address)
+{
+	uint8_t value;
+
+	asm volatile ("ldrb %w0, [%1]" : "=r"(value) : "r"(address));
+	return value;
+}
+
+static inline uint16_t ioreg_read16(const volatile uint16_t *address)
+{
+	uint16_t value;
+
+	asm volatile ("ldrh %w0, [%1]" : "=r"(value) : "r"(address));
+	return value;
+}
+
+static inline uint32_t ioreg_read32(const volatile uint32_t *address)
+{
+	uint32_t value;
+
+	asm volatile ("ldr %w0, [%1]" : "=r"(value) : "r"(address));
+	return value;
+}
+
+static inline uint64_t ioreg_read64(const volatile uint64_t *address)
+{
+	uint64_t value;
+
+	asm volatile ("ldr %0, [%1]" : "=r"(value) : "r"(address));
+	return value;
+}
+
+static inline void ioreg_write8(const volatile uint8_t *address, uint8_t value)
+{
+	asm volatile ("strb %w0, [%1]" : : "rZ"(value), "r"(address));
+}
+
+static inline void ioreg_write16(const volatile uint16_t *address,
+				 uint16_t value)
+{
+	asm volatile ("strh %w0, [%1]" : : "rZ"(value), "r"(address));
+}
+
+static inline void ioreg_write32(const volatile uint32_t *address,
+				 uint32_t value)
+{
+	asm volatile ("str %w0, [%1]" : : "rZ"(value), "r"(address));
+}
+
+static inline void ioreg_write64(const volatile uint64_t *address,
+				 uint64_t value)
+{
+	asm volatile ("str %0, [%1]" : : "rZ"(value), "r"(address));
+}
 
 static inline void _init_cpufeatures(void)
 {
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Thu May 21 18:41:13 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 21 May 2020 18:41: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 1jbq7x-0006UW-P6; Thu, 21 May 2020 18:41:09 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Yo4h=7D=gmail.com=alicesuiu17@srs-us1.protection.inumbo.net>)
 id 1jbq7w-0006UR-4c
 for minios-devel@lists.xen.org; Thu, 21 May 2020 18:41:08 +0000
X-Inumbo-ID: a1672c2e-9b92-11ea-9887-bc764e2007e4
Received: from mail-ej1-x633.google.com (unknown [2a00:1450:4864:20::633])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a1672c2e-9b92-11ea-9887-bc764e2007e4;
 Thu, 21 May 2020 18:41:07 +0000 (UTC)
Received: by mail-ej1-x633.google.com with SMTP id a2so10034234ejb.10
 for <minios-devel@lists.xen.org>; Thu, 21 May 2020 11:41: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;
 bh=XrYewZYpmGalbH5S7VLKDLWjDG/Dx/iPnP2+smWFEhw=;
 b=qXCZ8N1aLijCkQHkCFfHQJjZzJTy0digG7IBE5tZvkcqfb0na+5Lx/w8Mq6JJPNUSW
 Kq3oXixe3JzjYuxAJ5m//faVwYnxDcRqLkYPN2Vifc7HOyuSQCqaAspp0UfPrL5v87tz
 GGK0fHc0SwJ7dzDkRGGoSF3CJiJltBbGNKoqWzeNBeFBN1cU1i4f+ymuUQ3OONo68TYd
 sjW/opwLr3zsO+pfmUu9Ar1jgdX7EQOK/MRuXdCG5nbcWAx6LSOMSG/c+7NCfoxJr5gh
 /WXr5gO9zybeRZ9xHFEvcZvuwh/zgcbd0SFjxBibc+M1tvwaVwBItsqA97l0/rZs2Pdq
 G0cQ==
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=XrYewZYpmGalbH5S7VLKDLWjDG/Dx/iPnP2+smWFEhw=;
 b=KD+XUpQwRT3jmE2y5OVwBfQ89EzFpU5tDu4IyreuKaD6WglJyKNHk9D31XPRQ48WIk
 hBIBOjnlx0hBhl/Uw8o4FaMB2k6Y5BfPvZW5F++FE5okQoVZ3K+CStidEUbTKRRugnu2
 s4Cw2yLpOT7vZ33qEPkNgiOfnpDSu5yQIyPdACFth0t64W9IXMB1oKhW3FhEu57U5eYR
 TJD6vTeuqN498GPMoN3ik7NriSUPVcgvIyNy8zhyD87l2lszN7FBJZdK1PBdJnnhCB++
 llakMqJlkPBDDKfwT9KwXgITyBKmyrLS/DCkbTqsqPHaIODopjE5eAmJpOmjmVG1L2Nw
 OLqA==
X-Gm-Message-State: AOAM5304TKkabF9ZGcNe2dTON9AOCTjd1GBCBQ7O0gZBchoMFkzaHUnP
 6HeltNgKRn16eR3s+Yi4vBNVxLSJwss=
X-Google-Smtp-Source: ABdhPJwiLtuUdMIF5OnFwRHyeFoVolxxGIfs9i5tWbF2ogrmvkYPpyoaMOUzEOGOUNE/ZCMlFNEpxA==
X-Received: by 2002:a17:906:b4e:: with SMTP id
 v14mr4807402ejg.302.1590086465444; 
 Thu, 21 May 2020 11:41:05 -0700 (PDT)
Received: from localhost.localdomain (5-12-60-96.residential.rdsnet.ro.
 [5.12.60.96])
 by smtp.gmail.com with ESMTPSA id p16sm5437593eji.41.2020.05.21.11.41.03
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 21 May 2020 11:41:04 -0700 (PDT)
From: Alice Suiu <alicesuiu17@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 1/3] build: Add PGO and ASAN to MENUCONFIG
Date: Thu, 21 May 2020 21:40:51 +0300
Message-Id: <20200521184053.2364-1-alicesuiu17@gmail.com>
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>
Cc: felipe.huici@neclab.eu, simon.kuenzer@neclab.eu,
 alicesuiu <alicesuiu17@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

From: alicesuiu <alicesuiu17@gmail.com>

Signed-off-by: Alice Suiu <alicesuiu17@gmail.com>
---
 Config.uk   | 40 ++++++++++++++++++++++++++++++++++++++++
 Makefile.uk |  8 ++++++++
 2 files changed, 48 insertions(+)

diff --git a/Config.uk b/Config.uk
index 3235b91..0e21fa2 100644
--- a/Config.uk
+++ b/Config.uk
@@ -86,6 +86,46 @@ config OPTIMIZE_LTO
 		will increase overall building time but creates more efficient
 		Unikraft binaries.
 
+config OPTIMIZE_PGO
+	bool "PGO - Profile-guided optimization"
+	default n
+	help
+		Enables GCC to do code optimizations through PGO.
+
+if OPTIMIZE_PGO
+	choice PGO_PHASES
+	prompt "PGO Options"
+	default NO_PGO
+	help
+		Enables GCC to do code optimizations through PGO.
+
+
+	config OPTIMIZE_PGO_GENERATE
+		bool "profile-generate"
+		help
+			Enables GCC to generate data for code optimization through PGO.
+
+	config OPTIMIZE_PGO_USE
+		bool "profile-use"
+		help
+			Enables GCC to do code optimizations using profile-guided
+			accomplished with PGO.
+
+	config NO_PGO
+		bool "NO-PGO"
+		help
+			Do not optimize with PGO.
+
+	endchoice
+
+endif
+
+config OPTIMIZE_ASAN
+	bool "ASAN - AddressSanitizer"
+	default n
+	help
+		Enables GCC to detects memory corruption bugs.
+
 choice
 	prompt "Debug information level"
 	default DEBUG_SYMBOLS_LVL3
diff --git a/Makefile.uk b/Makefile.uk
index a78afc0..abc5475 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -36,6 +36,14 @@ COMPFLAGS-$(CONFIG_OPTIMIZE_LTO)          += -flto
 LIBLDFLAGS-$(CONFIG_OPTIMIZE_LTO)         += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y)
 LDFLAGS-$(CONFIG_OPTIMIZE_LTO)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y)
 
+# PGO
+COMPFLAGS-$(CONFIG_OPTIMIZE_PGO_GENERATE)          += -fprofile-generate
+LDFLAGS-$(CONFIG_OPTIMIZE_PGO_GENERATE)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fprofile-generate
+
+# ASAN
+COMPFLAGS-$(CONFIG_OPTIMIZE_ASAN)          += -fsanitize=address
+LDFLAGS-$(CONFIG_OPTIMIZE_ASAN)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fsanitize=address
+
 DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0)     += -g0
 DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL1)     += -g1
 DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL2)     += -g2
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Thu May 21 18:41:15 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 21 May 2020 18:41:15 +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 1jbq83-0006Ut-Qw; Thu, 21 May 2020 18:41: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=Yo4h=7D=gmail.com=alicesuiu17@srs-us1.protection.inumbo.net>)
 id 1jbq81-0006Um-VM
 for minios-devel@lists.xen.org; Thu, 21 May 2020 18:41:13 +0000
X-Inumbo-ID: a4b108d2-9b92-11ea-b07b-bc764e2007e4
Received: from mail-ej1-x643.google.com (unknown [2a00:1450:4864:20::643])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a4b108d2-9b92-11ea-b07b-bc764e2007e4;
 Thu, 21 May 2020 18:41:12 +0000 (UTC)
Received: by mail-ej1-x643.google.com with SMTP id n24so10090113ejd.0
 for <minios-devel@lists.xen.org>; Thu, 21 May 2020 11:41:12 -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=9s3lXgColV5l38w6+OeuH8UhAQbkfCKJwfsED0DaA3E=;
 b=fZ/W0fAvJFuzSiPQV9cXpcYT/CJsz8Ms7sAtH6WgdV/QjcWfitgOAs+wz5eLCnQfQX
 wC/gsaaH1V2g7nZAHqkT69tb5Hy1UvOQ0qauE33zuaMEuI5bO48W5qM+Ngo+YYoq2mFl
 WdnM/UEwvJc353D3mS08FwBhCpkcngmV2rFGK+7BGo4gpndtEQcE6oKZM2k80H/Nsohl
 jf71KbE7GrzFHWeL+5JDy4vtxHoPj5tpf0J6H82GqpTA+oZNR+qa2MVSaiC0FiaCUYAK
 ibq+kQWuA6cabC13lMldxA/SQUSpuNEah8KRbelLjaaR6wbj8KHDmv3S2n2JQ+8P3A/R
 VmhA==
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=9s3lXgColV5l38w6+OeuH8UhAQbkfCKJwfsED0DaA3E=;
 b=bs0PFwujgm5AUdQIAdYVR6dMmEeUG+BYA1DgYeRK66LXqU1tOF4H3acFD8cwfHQYTo
 rA8PGeQqL06TOEZi3iho0xzv6HTV4MRThss43+qJUxUPoa05KOoMDgPFOcIr1Qqa2M6w
 nFecBVz3PTwLkPwWjgMkG9QqZ1UGGPkoD6hL/PJurfrmUI5h6nh2OvaoKVg2EmKHgbi2
 fpgYoI8SGmNP4QFd18K/8v+AV1dnwFzKBoyjG5tv8/aCHf/K0qliRcAcd7p604jT0z6O
 IydubW22h8gxUf606VI/ia5Ur4p8yGDu0fLop98cNW+jx63HDGQcO305n86swxZs+wqr
 XmHw==
X-Gm-Message-State: AOAM532dZQ7qmRWYjQMvwmUK1UCnDYc5HNGrn4MrZ84VDGoQ5ORoJBcE
 o1KJEyppz74qHsuWFglGbYlKfKpHYwc=
X-Google-Smtp-Source: ABdhPJxJQbEi/xazOWF0kN2Z6qGmeoUWjJrCKRuOSSe7UQ+/neORz66w+I2feCwhdVYCb2+T8H1bPw==
X-Received: by 2002:a17:907:36d:: with SMTP id
 rs13mr5006342ejb.478.1590086471138; 
 Thu, 21 May 2020 11:41:11 -0700 (PDT)
Received: from localhost.localdomain (5-12-60-96.residential.rdsnet.ro.
 [5.12.60.96])
 by smtp.gmail.com with ESMTPSA id p16sm5437593eji.41.2020.05.21.11.41.10
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 21 May 2020 11:41:10 -0700 (PDT)
From: Alice Suiu <alicesuiu17@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 2/3] plat/kvm,
 build: Implement the profle-generate and profile-use phase for PGO.
Date: Thu, 21 May 2020 21:40:52 +0300
Message-Id: <20200521184053.2364-2-alicesuiu17@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200521184053.2364-1-alicesuiu17@gmail.com>
References: <20200521184053.2364-1-alicesuiu17@gmail.com>
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>
Cc: felipe.huici@neclab.eu, simon.kuenzer@neclab.eu,
 Alice Suiu <alicesuiu17@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Call the __gcov_exit() function in a conditional way (using ifdef guard) in
the function ukplat_terminate(). Thus, the data file (*.gcda) is generated
within the Unikraft filesystem. Use 9pfs to transfer the *.gcda file from Unikraft
to the host system.

Signed-off-by: Alice Suiu <alicesuiu17@gmail.com>
---
 Makefile.uk         |  6 ++++--
 plat/kvm/shutdown.c | 27 +++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/Makefile.uk b/Makefile.uk
index abc5475..e201785 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -36,10 +36,12 @@ COMPFLAGS-$(CONFIG_OPTIMIZE_LTO)          += -flto
 LIBLDFLAGS-$(CONFIG_OPTIMIZE_LTO)         += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y)
 LDFLAGS-$(CONFIG_OPTIMIZE_LTO)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y)
 
-# PGO
-COMPFLAGS-$(CONFIG_OPTIMIZE_PGO_GENERATE)          += -fprofile-generate
+# PGO - profile-generate phase
 LDFLAGS-$(CONFIG_OPTIMIZE_PGO_GENERATE)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fprofile-generate
 
+# PGO - profile-use phase
+LDFLAGS-$(CONFIG_OPTIMIZE_PGO_USE)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -O3 -fprofile-use=main.gcda
+
 # ASAN
 COMPFLAGS-$(CONFIG_OPTIMIZE_ASAN)          += -fsanitize=address
 LDFLAGS-$(CONFIG_OPTIMIZE_ASAN)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fsanitize=address
diff --git a/plat/kvm/shutdown.c b/plat/kvm/shutdown.c
index cce26b7..9ca909f 100644
--- a/plat/kvm/shutdown.c
+++ b/plat/kvm/shutdown.c
@@ -27,11 +27,38 @@
 #include <uk/print.h>
 #include <uk/plat/bootstrap.h>
 
+#if CONFIG_OPTIMIZE_PGO_GENERATE
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#define GCOV_GENERATE_FILE	"/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build/apphelloworld/main.gcda"
+
+void create_hierarchy()
+{
+	mkdir("/home", 0777);
+	mkdir("/home/alice", 0777);
+	mkdir("/home/alice/Documents", 0777);
+	mkdir("/home/alice/Documents/Diploma", 0777);
+	mkdir("/home/alice/Documents/Diploma/Comp-opt", 0777);
+	mkdir("/home/alice/Documents/Diploma/Comp-opt/apps", 0777);
+	mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld", 0777);
+	mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build", 0777);
+	mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build/apphelloworld", 0777);
+}
+
+#endif
+
 static void cpu_halt(void) __noreturn;
 
 /* TODO: implement CPU reset */
 void ukplat_terminate(enum ukplat_gstate request __unused)
 {
+
+#if CONFIG_OPTIMIZE_PGO_GENERATE
+	create_hierarchy();
+	__gcov_exit();
+#endif
+
 	uk_pr_info("Unikraft halted\n");
 
 	/* Try to make system off */
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Thu May 21 18:41:19 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 21 May 2020 18:41: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 1jbq87-0006Vc-Sh; Thu, 21 May 2020 18:41:19 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Yo4h=7D=gmail.com=alicesuiu17@srs-us1.protection.inumbo.net>)
 id 1jbq86-0006VH-06
 for minios-devel@lists.xen.org; Thu, 21 May 2020 18:41:18 +0000
X-Inumbo-ID: a6491cc0-9b92-11ea-b07b-bc764e2007e4
Received: from mail-ej1-x644.google.com (unknown [2a00:1450:4864:20::644])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a6491cc0-9b92-11ea-b07b-bc764e2007e4;
 Thu, 21 May 2020 18:41:15 +0000 (UTC)
Received: by mail-ej1-x644.google.com with SMTP id a2so10034900ejb.10
 for <minios-devel@lists.xen.org>; Thu, 21 May 2020 11:41:15 -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=hZJqcHl3a6PDtIiJQwQjPyDHbqTlud3WNo+32NazOQk=;
 b=aCyMjfi3QlHRMkyBZcgCY+FsBNYTQI10cUe3IQWMlC/OImPA4Bg7AJ9Fgty9EKe2t/
 yYn23QQ1jM0gkr83pGEIAd9Ymg8bIm8g3tJz5cJuAvn73gW2uPTs4qOfvnIeKBE3spJe
 WOTHES3B25RWUknu+1KUVtk14zgGwMEbmZCun5yvPdg7AO0jMDTR0l1osS50AAaYvaIE
 BgmX6MiQU3HZwy43Gba+hcScS6QJrUc9Hy/dvgepneBSsdCjNLuGry+CPmSDUlscKxaw
 qhlzapwR9Klonanm8pHRUJ9WOKm/pE9SCdXBlNP+8w/yMqrdMOpK6lF6e+8XMVSB1C2I
 NwZw==
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=hZJqcHl3a6PDtIiJQwQjPyDHbqTlud3WNo+32NazOQk=;
 b=N9dwJy104m+nEHYn9EAUWmt6oTBMwMo0oEOKJ1L81RHm84yqnlJD3hGh5NvN2E8o+J
 P6AmERIGjux3aUr00KnRtDn72irGCz+/iTBDz1CBsOEufmH0sFLSb5uqEnJK9Hui3/V7
 nL+7VTxtv5+wRy3QOq7K4z1KwaeuBI25t2badVbBaq+qtS+JFrYF4Tw02hUghnwIhh5L
 GbgVcpt02/CMLWVUsBjznLGAdD1fY79oPAbwbVLeq40SAihvBG4ZDRWqXaCpWv/zPfiz
 LhNgr2njwmtjnly6hDcBW+O6sPUjPsXeUuSzDhfzCpPRYCHp/kGlj3wnr3EN1/zJQ5r7
 9Lew==
X-Gm-Message-State: AOAM533Fmgn+mHzp25NKJk8NO+HlyRj2o9a+UPYMZTvd4GIXPVw4FWIo
 SDcd9mwJST6XuXvwnhivtIQ79YKlppw=
X-Google-Smtp-Source: ABdhPJyNRC5+D/HXg255EiFB+JYKBjTOFrUD6YhiijQo0+L3YfK9O5EqcZHu74aEN7QNgAAnsVB7FQ==
X-Received: by 2002:a17:906:bcf8:: with SMTP id
 op24mr4817776ejb.260.1590086473883; 
 Thu, 21 May 2020 11:41:13 -0700 (PDT)
Received: from localhost.localdomain (5-12-60-96.residential.rdsnet.ro.
 [5.12.60.96])
 by smtp.gmail.com with ESMTPSA id p16sm5437593eji.41.2020.05.21.11.41.12
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 21 May 2020 11:41:13 -0700 (PDT)
From: Alice Suiu <alicesuiu17@gmail.com>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT PATCH 3/3] plat/kvm,
 build: Change the default directory in which *.gcda files are
 generated.
Date: Thu, 21 May 2020 21:40:53 +0300
Message-Id: <20200521184053.2364-3-alicesuiu17@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200521184053.2364-1-alicesuiu17@gmail.com>
References: <20200521184053.2364-1-alicesuiu17@gmail.com>
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>
Cc: felipe.huici@neclab.eu, simon.kuenzer@neclab.eu,
 Alice Suiu <alicesuiu17@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Set GCOV_PREFIX and GCOV_PREFIX_STRIP. GCOV_PREFIX is a runtime environment variable
that determines the root directory where the gcov output files (*.gcda) are written.
GCOV_PREFIX_STRIP=X is also a runtime variable and has the effect of stripping X
elements from the path found in the object files.

Thus, the default path in which the *.gcda files were generated was changed with the
help of the two environment variables. Now the files are saved to the path given
exclusively by the GCOV_PREFIX environment variable, GCOV_PREFIX_STRIP being large
enough to skip the entire default path.

Signed-off-by: Alice Suiu <alicesuiu17@gmail.com>
---
 Makefile.uk         |  6 +-----
 plat/kvm/shutdown.c | 34 +++++++++++++++++++++-------------
 2 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/Makefile.uk b/Makefile.uk
index e201785..510769a 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -40,11 +40,7 @@ LDFLAGS-$(CONFIG_OPTIMIZE_LTO)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHF
 LDFLAGS-$(CONFIG_OPTIMIZE_PGO_GENERATE)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fprofile-generate
 
 # PGO - profile-use phase
-LDFLAGS-$(CONFIG_OPTIMIZE_PGO_USE)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -O3 -fprofile-use=main.gcda
-
-# ASAN
-COMPFLAGS-$(CONFIG_OPTIMIZE_ASAN)          += -fsanitize=address
-LDFLAGS-$(CONFIG_OPTIMIZE_ASAN)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fsanitize=address
+LDFLAGS-$(CONFIG_OPTIMIZE_PGO_USE)            += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y) -fprofile-use
 
 DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0)     += -g0
 DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL1)     += -g1
diff --git a/plat/kvm/shutdown.c b/plat/kvm/shutdown.c
index 9ca909f..ad0cd18 100644
--- a/plat/kvm/shutdown.c
+++ b/plat/kvm/shutdown.c
@@ -30,22 +30,30 @@
 #if CONFIG_OPTIMIZE_PGO_GENERATE
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <dirent.h>
 
-#define GCOV_GENERATE_FILE	"/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build/apphelloworld/main.gcda"
+#define GCOV_GENERATED_DIR	"/gcov_profiling"
+#define GCOV_PREFIX_STRIP_LENGTH	"100"
 
-void create_hierarchy()
+void set_path_gcov_files()
 {
-	mkdir("/home", 0777);
-	mkdir("/home/alice", 0777);
-	mkdir("/home/alice/Documents", 0777);
-	mkdir("/home/alice/Documents/Diploma", 0777);
-	mkdir("/home/alice/Documents/Diploma/Comp-opt", 0777);
-	mkdir("/home/alice/Documents/Diploma/Comp-opt/apps", 0777);
-	mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld", 0777);
-	mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build", 0777);
-	mkdir("/home/alice/Documents/Diploma/Comp-opt/apps/helloworld/build/apphelloworld", 0777);
-}
+	const char *gcov_prefix;
+	const char *gcov_strip;
+
+	gcov_prefix = getenv("GCOV_PREFIX");
+	if (!gcov_prefix)
+		setenv("GCOV_PREFIX", GCOV_GENERATED_DIR, 1);
 
+	gcov_strip = getenv("GCOV_PREFIX_STRIP");
+	if (!gcov_strip)
+		setenv("GCOV_PREFIX_STRIP", GCOV_PREFIX_STRIP_LENGTH, 1);
+
+	DIR* dir = opendir(GCOV_GENERATED_DIR);
+	if (dir)
+		closedir(dir);
+	else if (ENOENT == errno)
+		mkdir(GCOV_GENERATED_DIR, 0777);
+}
 #endif
 
 static void cpu_halt(void) __noreturn;
@@ -55,7 +63,7 @@ void ukplat_terminate(enum ukplat_gstate request __unused)
 {
 
 #if CONFIG_OPTIMIZE_PGO_GENERATE
-	create_hierarchy();
+	set_path_gcov_files();
 	__gcov_exit();
 #endif
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Thu May 21 19:18:59 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 21 May 2020 19:18: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 1jbqiW-0000uT-Sw; Thu, 21 May 2020 19:18:56 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Yo4h=7D=gmail.com=alicesuiu17@srs-us1.protection.inumbo.net>)
 id 1jbqiV-0000uO-PL
 for minios-devel@lists.xen.org; Thu, 21 May 2020 19:18:55 +0000
X-Inumbo-ID: e931e29c-9b97-11ea-b07b-bc764e2007e4
Received: from mail-ej1-x641.google.com (unknown [2a00:1450:4864:20::641])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e931e29c-9b97-11ea-b07b-bc764e2007e4;
 Thu, 21 May 2020 19:18:54 +0000 (UTC)
Received: by mail-ej1-x641.google.com with SMTP id a2so10168365ejb.10
 for <minios-devel@lists.xen.org>; Thu, 21 May 2020 12:18:54 -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=R7E4QFH+BfPjnyIIczP01pIVsc+NqY7LrW3qnwBxLGE=;
 b=eVdJ30MUKyttXTMm6eoIcv1V8Aj1vdHiXJPQsc3JTsEcGrggUTWWzkRBSd/BNfIKb7
 SPtnpoq096Yuzknp5ou6Lv10AvRQgOkuBN0gzxx5sNcqXtktaGfvT4kCotFZn/pRNqjN
 7tMhRN9DuaU8xCGng0szHcUs51mry7vuFJrAW27oMHd21OhwKGT1iaItY0GgefYt9N9q
 0vKPHOOa1KEexZphGni506eDcEA9XDR4Mt88l8rPZQWkP2QlgQaAUXl0N5sLhKAj8j5t
 ZbPQWCwvL+Ai7KpX2AQRx2Vn8wPfEL9aB7aDEkUZ0nt500XH/w0iZb1Si/iZIYEBEGai
 AX5w==
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=R7E4QFH+BfPjnyIIczP01pIVsc+NqY7LrW3qnwBxLGE=;
 b=arplDPSujyPcr26w3M9HtshhGP1Kq+upo7yFc6gtMstfQ0YX/+kUibQa38JRqJ7Sjj
 1nUCXL8jZQOPz34a5WdmDl996TsQ79LR1M7RXXTFvHStRSkBkIkM6ie9nK0i46YKRXXq
 dGssHZK5dl2ySD/CICsd8dl00hdRnomdyqLp9Ez6NItkbtkqtjD/OYaJt3rjo3Vvek7I
 tZFrQxv9RvSPjTY/S49zFKYUUFqMr1j2RU71/a6e/tgrY4DCQEX9RTLpMUpYtZKNgAVI
 m2f/gh5Dx3SnBB7zK/CK7mseT1SxNuca5tXGNZ4RDlRHiAPFFthnyzvqUZWdfpjyNxWC
 qX1A==
X-Gm-Message-State: AOAM532Ycw+ziYJRnLAm3qfqwbcfc1ouE7FZeygzYxJmguPzJsnj6kjl
 wctDZ+8gYBuVmms74f1PQ9slS0nmZto=
X-Google-Smtp-Source: ABdhPJxstKZyqjesL8LfxvpxSZuoumFhqHOrF/YaljNnBxa4s2mPKZMlJDijQg7l9S3J+vt9k5IhAw==
X-Received: by 2002:a17:907:9d5:: with SMTP id
 bx21mr4855729ejc.504.1590088733460; 
 Thu, 21 May 2020 12:18:53 -0700 (PDT)
Received: from localhost.localdomain (5-12-60-96.residential.rdsnet.ro.
 [5.12.60.96])
 by smtp.gmail.com with ESMTPSA id m11sm5735733ejq.49.2020.05.21.12.18.52
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 21 May 2020 12:18:52 -0700 (PDT)
From: Alice Suiu <alicesuiu17@gmail.com>
To: minios-devel@lists.xen.org
Subject: [LIBGCC/LIBGCOV PATCH 2/2] Makefile.uk: Enable macros through -D
 compile flag
Date: Thu, 21 May 2020 22:18:44 +0300
Message-Id: <20200521191844.3896-2-alicesuiu17@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200521191844.3896-1-alicesuiu17@gmail.com>
References: <20200521191844.3896-1-alicesuiu17@gmail.com>
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>
Cc: felipe.huici@neclab.eu, Alice Suiu <alicesuiu17@gmail.com>,
 costin.lupu@cs.pub.ro
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Add -D compile flag to generate specific functions for libgcov.

Signed-off-by: Alice Suiu <alicesuiu17@gmail.com>
---
 Makefile.uk                   |   8 +-
 libgcov/include/popcountdi2.c |  39 ++++++++++
 libgcov/include/popcountdi2.h | 137 ++++++++++++++++++++++++++++++++++
 3 files changed, 183 insertions(+), 1 deletion(-)
 create mode 100644 libgcov/include/popcountdi2.c
 create mode 100644 libgcov/include/popcountdi2.h

diff --git a/Makefile.uk b/Makefile.uk
index fe56ad8..fb68c95 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -131,9 +131,15 @@ LIBGCOV_CINCLUDES-y = -I$(LIBGCC_BASE)/libgcov/include \
 		-I$(LIBGCC_BASE)/libgcov/include/config
 
 LIBGCOV_CFLAGS-y += -O2 -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector \
-	-DHAVE_CC_TLS
+	-DHAVE_CC_TLS -DL_gcov_merge_add -DL_gcov_merge_single -DL_gcov_merge_ior -DL_gcov_merge_time_profile -DL_gcov_merge_icall_topn \
+	-DL_gcov_interval_profiler -DL_gcov_interval_profiler_atomic -DL_gcov_pow2_profiler -DL_gcov_pow2_profiler_atomic \
+	-DL_gcov_one_value_profiler -DL_gcov_one_value_profiler_atomic -DL_gcov_average_profiler -DL_gcov_average_profiler_atomic	\
+	-DL_gcov_ior_profiler -DL_gcov_ior_profiler_atomic -DL_gcov_indirect_call_profiler_v2 -DL_gcov_time_profiler -DL_gcov_indirect_call_topn_profiler \
+	-DL_gcov_dump -DL_gcov_flush -DL_gcov_fork -DL_gcov_execl -DL_gcov_execlp -DL_gcov_execle -DL_gcov_execv -DL_gcov_execvp -DL_gcov_execve \
+	-DL_gcov_reset -DL_gcov \
 
 LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-merge.c
 LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-profiler.c
 LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-interface.c
 LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-driver.c
+LIBGCOV_SRCS-y += $(LIBGCOV_BASE)/libgcov/include/popcountdi2.c
diff --git a/libgcov/include/popcountdi2.c b/libgcov/include/popcountdi2.c
new file mode 100644
index 0000000..1009c01
--- /dev/null
+++ b/libgcov/include/popcountdi2.c
@@ -0,0 +1,39 @@
+#include "popcountdi2.h"
+
+const UQItype __popcount_tab[256] =
+{
+    0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
+    1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
+    1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
+    2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
+    1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
+    2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
+    2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
+    3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
+};
+
+int __popcountdi2 (UDWtype x)
+{
+  /* Force table lookup on targets like AVR and RL78 which only
+     pretend they have LIBGCC2_UNITS_PER_WORD 4, but actually
+     have 1, and other small word targets.  */
+#if __SIZEOF_INT__ > 2 && defined (POPCOUNTCST) && __CHAR_BIT__ == 8
+  const DWunion uu = {.ll = x};
+  UWtype x1 = uu.s.low, x2 = uu.s.high;
+  x1 = x1 - ((x1 >> 1) & POPCOUNTCST (0x55));
+  x2 = x2 - ((x2 >> 1) & POPCOUNTCST (0x55));
+  x1 = (x1 & POPCOUNTCST (0x33)) + ((x1 >> 2) & POPCOUNTCST (0x33));
+  x2 = (x2 & POPCOUNTCST (0x33)) + ((x2 >> 2) & POPCOUNTCST (0x33));
+  x1 = (x1 + (x1 >> 4)) & POPCOUNTCST (0x0F);
+  x2 = (x2 + (x2 >> 4)) & POPCOUNTCST (0x0F);
+  x1 += x2;
+  return (x1 * POPCOUNTCST (0x01)) >> (W_TYPE_SIZE - __CHAR_BIT__);
+#else
+  int i, ret = 0;
+
+  for (i = 0; i < 2*W_TYPE_SIZE; i += 8)
+    ret += __popcount_tab[(x >> i) & 0xff];
+
+  return ret;
+#endif
+}
diff --git a/libgcov/include/popcountdi2.h b/libgcov/include/popcountdi2.h
new file mode 100644
index 0000000..becf8fc
--- /dev/null
+++ b/libgcov/include/popcountdi2.h
@@ -0,0 +1,137 @@
+typedef char SINT8;
+typedef unsigned char UINT8;
+typedef unsigned UINT32;
+typedef signed SINT32;
+
+#if __GNUC__ || defined LINUX || defined SUNOS
+typedef unsigned long long UINT64;
+typedef signed long long SINT64;
+#else
+typedef unsigned __int64 UINT64;
+typedef signed __int64 SINT64;
+#endif
+
+#define USItype UINT32;
+#define SItype SINT32;
+#define UDItype UINT64;
+#define DItype SINT64;
+
+typedef		 int QItype	__attribute__ ((mode (QI)));
+typedef unsigned int UQItype	__attribute__ ((mode (QI)));
+typedef		 int HItype	__attribute__ ((mode (HI)));
+typedef unsigned int UHItype	__attribute__ ((mode (HI)));
+#if MIN_UNITS_PER_WORD > 1
+/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1.  */
+typedef 	 int SItype	__attribute__ ((mode (SI)));
+typedef unsigned int USItype	__attribute__ ((mode (SI)));
+#if __SIZEOF_LONG_LONG__ > 4
+/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2.  */
+typedef		 int DItype	__attribute__ ((mode (DI)));
+typedef unsigned int UDItype	__attribute__ ((mode (DI)));
+#if MIN_UNITS_PER_WORD > 4
+/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4.  */
+typedef		 int TItype	__attribute__ ((mode (TI)));
+typedef unsigned int UTItype	__attribute__ ((mode (TI)));
+#endif
+#endif
+#endif
+
+#if LIBGCC2_HAS_HF_MODE
+typedef		float HFtype	__attribute__ ((mode (HF)));
+typedef _Complex float HCtype	__attribute__ ((mode (HC)));
+#endif
+#if LIBGCC2_HAS_SF_MODE
+typedef 	float SFtype	__attribute__ ((mode (SF)));
+typedef _Complex float SCtype	__attribute__ ((mode (SC)));
+#endif
+#if LIBGCC2_HAS_DF_MODE
+typedef		float DFtype	__attribute__ ((mode (DF)));
+typedef _Complex float DCtype	__attribute__ ((mode (DC)));
+#endif
+#if LIBGCC2_HAS_XF_MODE
+typedef		float XFtype	__attribute__ ((mode (XF)));
+typedef _Complex float XCtype	__attribute__ ((mode (XC)));
+#endif
+#if LIBGCC2_HAS_TF_MODE
+typedef		float TFtype	__attribute__ ((mode (TF)));
+typedef _Complex float TCtype	__attribute__ ((mode (TC)));
+#endif
+
+
+#if LIBGCC2_UNITS_PER_WORD == 8
+#define W_TYPE_SIZE (8 * __CHAR_BIT__)
+#define Wtype	DItype
+#define UWtype	UDItype
+#define HWtype	DItype
+#define UHWtype	UDItype
+#define DWtype	TItype
+#define UDWtype	UTItype
+#ifdef LIBGCC2_GNU_PREFIX
+#define __NW(a,b)	__gnu_ ## a ## di ## b
+#define __NDW(a,b)	__gnu_ ## a ## ti ## b
+#else
+#define __NW(a,b)	__ ## a ## di ## b
+#define __NDW(a,b)	__ ## a ## ti ## b
+#endif
+#define COMPAT_SIMODE_TRAPPING_ARITHMETIC
+#elif LIBGCC2_UNITS_PER_WORD == 4
+#define W_TYPE_SIZE (4 * __CHAR_BIT__)
+#define Wtype	SItype
+#define UWtype	USItype
+#define HWtype	SItype
+#define UHWtype	USItype
+#define DWtype	DItype
+#define UDWtype	UDItype
+#ifdef LIBGCC2_GNU_PREFIX
+#define __NW(a,b)	__gnu_ ## a ## si ## b
+#define __NDW(a,b)	__gnu_ ## a ## di ## b
+#else
+#define __NW(a,b)	__ ## a ## si ## b
+#define __NDW(a,b)	__ ## a ## di ## b
+#endif
+#elif LIBGCC2_UNITS_PER_WORD == 2
+#define W_TYPE_SIZE (2 * __CHAR_BIT__)
+#define Wtype	HItype
+#define UWtype	UHItype
+#define HWtype	HItype
+#define UHWtype	UHItype
+#define DWtype	SItype
+#define UDWtype	USItype
+#ifdef LIBGCC2_GNU_PREFIX
+#define __NW(a,b)	__gnu_ ## a ## hi ## b
+#define __NDW(a,b)	__gnu_ ## a ## si ## b
+#else
+#define __NW(a,b)	__ ## a ## hi ## b
+#define __NDW(a,b)	__ ## a ## si ## b
+#endif
+#else
+#define W_TYPE_SIZE __CHAR_BIT__
+#define Wtype	QItype
+#define UWtype  UQItype
+#define HWtype	QItype
+#define UHWtype	UQItype
+#define DWtype	HItype
+#define UDWtype	UHItype
+#ifdef LIBGCC2_GNU_PREFIX
+#define __NW(a,b)	__gnu_ ## a ## qi ## b
+#define __NDW(a,b)	__gnu_ ## a ## hi ## b
+#else
+#define __NW(a,b)	__ ## a ## qi ## b
+#define __NDW(a,b)	__ ## a ## hi ## b
+#endif
+#endif
+
+/* DWstructs are pairs of Wtype values in the order determined by
+   __BYTE_ORDER__.  */
+
+#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
+  struct DWstruct {Wtype high, low;};
+#else
+  struct DWstruct {Wtype low, high;};
+#endif
+
+typedef union
+{
+  struct DWstruct s;
+  DWtype ll;
+} DWunion;
\ No newline at end of file
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Thu May 21 19:19:10 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 21 May 2020 19:19:10 +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 1jbqik-0000vJ-0A; Thu, 21 May 2020 19:19:10 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Yo4h=7D=gmail.com=alicesuiu17@srs-us1.protection.inumbo.net>)
 id 1jbqii-0000v9-6i
 for minios-devel@lists.xen.org; Thu, 21 May 2020 19:19:08 +0000
X-Inumbo-ID: e8f1606e-9b97-11ea-b9cf-bc764e2007e4
Received: from mail-ej1-x631.google.com (unknown [2a00:1450:4864:20::631])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e8f1606e-9b97-11ea-b9cf-bc764e2007e4;
 Thu, 21 May 2020 19:18:54 +0000 (UTC)
Received: by mail-ej1-x631.google.com with SMTP id se13so10174981ejb.9
 for <minios-devel@lists.xen.org>; Thu, 21 May 2020 12:18:54 -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=u1sPL1i0v5qJiG3MalMJRHp0KnN9vND04vYVlcfGWUE=;
 b=facTTB/qxd93O1qsUdQinqtiTnB7guBoHE40HW9OCwxeMbPr3WnvpR30uAeTiJcstS
 4AOi+xJjo9PuD6Sa34BjxzRKLOALtxjkEmqh+O9LXM9tDzUA/74ES4ynZrRJwU6yp/Cy
 cAcsn+4LUwytvr4E+YnQBaVEZ6+8YEGjGVE16MqhKL5NVIqLAN8AhmfXC+EOPT/0+Aq7
 oSxtjqkRSqjUt6lsRBg/V0bV1PWjD8tYuV4qVtRUcx5uBV6nGgqpNLZ3wJlFnR55GuRT
 Wp8qanwcOAi/bmpifEXkUVsQ4VO025SgSqywcM9N83gb9BkTiYKdjsSZQyvZ5MSKPZIH
 Ljcw==
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=u1sPL1i0v5qJiG3MalMJRHp0KnN9vND04vYVlcfGWUE=;
 b=WZ+qyIFWEFgeeM6sU37R22IcpKfEo/TUB3Ar9+iHnwaP3zz+2+3+eOtd6f2qizcOuT
 t/GAStPDNalNaTeQFz/2KPz9visuLPUysn66cp1Pdar4rPsuX06pWf+XVCLNr79KSrpy
 JgriXTa2yKcSeqiovFN0z18wXanV3AWMpnssXskR3nhaXmQxcFs4FTSWgwgXyN4IkeSz
 np6rEs+omNCAke4xdN1EPpbI9Ru1umrdgB9mCs9aTuJBfgV1a/mVPTa5vm/XUU84s7Ke
 l8GjQdqr2lQa1LNzv7GHGvUamQhu3cTkDiiuI2QHNxHAVdc5IAraJ66y1Y95/evECy04
 prCQ==
X-Gm-Message-State: AOAM5328gbl1UzGw1XlZiwVHa6SiCxDPWSyBHRVG6K+Tt/eY2kwmM8rs
 Hzpc305nlyh13chcsS43esp48Q7eTSkyIg==
X-Google-Smtp-Source: ABdhPJzPcdKi59H3SFgQyGAhBvj0dQc76nuS3liZ9VAK/eGN/BoP00lt1x8Mh6EOjUsIxGqyyJJYNg==
X-Received: by 2002:a17:906:2dc8:: with SMTP id
 h8mr5280870eji.108.1590088729021; 
 Thu, 21 May 2020 12:18:49 -0700 (PDT)
Received: from localhost.localdomain (5-12-60-96.residential.rdsnet.ro.
 [5.12.60.96])
 by smtp.gmail.com with ESMTPSA id m11sm5735733ejq.49.2020.05.21.12.18.47
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 21 May 2020 12:18:47 -0700 (PDT)
From: Alice Suiu <alicesuiu17@gmail.com>
To: minios-devel@lists.xen.org
Subject: [LIBGCC/LIBGCOV PATCH 1/2] Port libgcov library
Date: Thu, 21 May 2020 22:18:43 +0300
Message-Id: <20200521191844.3896-1-alicesuiu17@gmail.com>
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>
Cc: felipe.huici@neclab.eu, Alice Suiu <alicesuiu17@gmail.com>,
 costin.lupu@cs.pub.ro
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This port also adds generated headers which can be found in
include/config/ directory and existing headers which can be located in
include/ directory.

Signed-off-by: Alice Suiu <alicesuiu17@gmail.com>
---
 Config.uk                            |    7 +
 Makefile.uk                          |   20 +-
 libgcov/include/ansidecl.h           |  355 ++++
 libgcov/include/config/auto-host.h   | 2419 ++++++++++++++++++++++++++
 libgcov/include/config/auto-target.h |   80 +
 libgcov/include/config/gcov-iov.h    |    4 +
 libgcov/include/config/libgcc_tm.h   |    6 +
 libgcov/include/config/tconfig.h     |   10 +
 libgcov/include/config/tm.h          |   52 +
 libgcov/include/coretypes.h          |  376 ++++
 libgcov/include/defaults.h           | 1478 ++++++++++++++++
 libgcov/include/elf-lib.h            |   36 +
 libgcov/include/filenames.h          |   99 ++
 libgcov/include/gcov-counter.def     |   54 +
 libgcov/include/gcov-io.c            |  987 +++++++++++
 libgcov/include/gcov-io.h            |  424 +++++
 libgcov/include/gcov.h               |   41 +
 libgcov/include/gthr-default.h       |  889 ++++++++++
 libgcov/include/gthr.h               |  154 ++
 libgcov/include/hashtab.h            |  204 +++
 libgcov/include/libgcov.h            |  346 ++++
 libgcov/include/tsystem.h            |  137 ++
 libgcov/include/value-unwind.h       |   25 +
 23 files changed, 8202 insertions(+), 1 deletion(-)
 create mode 100644 libgcov/include/ansidecl.h
 create mode 100644 libgcov/include/config/auto-host.h
 create mode 100644 libgcov/include/config/auto-target.h
 create mode 100644 libgcov/include/config/gcov-iov.h
 create mode 100644 libgcov/include/config/libgcc_tm.h
 create mode 100644 libgcov/include/config/tconfig.h
 create mode 100644 libgcov/include/config/tm.h
 create mode 100644 libgcov/include/coretypes.h
 create mode 100644 libgcov/include/defaults.h
 create mode 100644 libgcov/include/elf-lib.h
 create mode 100644 libgcov/include/filenames.h
 create mode 100644 libgcov/include/gcov-counter.def
 create mode 100644 libgcov/include/gcov-io.c
 create mode 100644 libgcov/include/gcov-io.h
 create mode 100644 libgcov/include/gcov.h
 create mode 100644 libgcov/include/gthr-default.h
 create mode 100644 libgcov/include/gthr.h
 create mode 100644 libgcov/include/hashtab.h
 create mode 100644 libgcov/include/libgcov.h
 create mode 100644 libgcov/include/tsystem.h
 create mode 100644 libgcov/include/value-unwind.h

diff --git a/Config.uk b/Config.uk
index 5aaca7c..89a84b0 100644
--- a/Config.uk
+++ b/Config.uk
@@ -26,4 +26,11 @@ config LIBFFI
 if LIBFFI
 endif
 
+config LIBGCOV
+       bool "libgcov - A Profiling Library"
+       default n
+       select LIBPTHREAD_EMBEDDED
+if LIBGCOV
+endif
+
 endif
diff --git a/Makefile.uk b/Makefile.uk
index d5901e2..fe56ad8 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -42,11 +42,12 @@
 $(eval $(call addlib_s,libgcc,$(CONFIG_LIBGCC)))
 $(eval $(call addlib_s,libbacktrace,$(CONFIG_LIBBACKTRACE)))
 $(eval $(call addlib_s,libffi,$(CONFIG_LIBFFI)))
+$(eval $(call addlib_s,libgcov,$(CONFIG_LIBGCOV)))
 
 ################################################################################
 # Original sources
 ################################################################################
-LIBGCC_VERSION=7.3.0
+LIBGCC_VERSION=7.5.0
 LIBGCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-$(LIBGCC_VERSION)/gcc-$(LIBGCC_VERSION).tar.gz
 LIBGCC_SUBDIR=gcc-$(LIBGCC_VERSION)
 $(eval $(call fetch,libgcc,$(LIBGCC_URL)))
@@ -57,6 +58,7 @@ $(eval $(call fetch,libgcc,$(LIBGCC_URL)))
 LIBGCC_EXTRACTED = $(LIBGCC_ORIGIN)/gcc-$(LIBGCC_VERSION)
 LIBBACKTRACE_EXTRACTED = $(LIBGCC_EXTRACTED)/libbacktrace
 LIBFFI_EXTRACTED = $(LIBGCC_EXTRACTED)/libffi
+LIBGCOV_EXTRACTED = $(LIBGCC_EXTRACTED)/libgcc
 
 ################################################################################
 # Library includes
@@ -70,6 +72,9 @@ CXXINCLUDES-$(CONFIG_LIBBACKTRACE) += -I$(LIBGCC_BASE)/libbacktrace/include
 CINCLUDES-$(CONFIG_LIBFFI)   += -I$(LIBGCC_BASE)/libffi/include
 CXXINCLUDES-$(CONFIG_LIBFFI) += -I$(LIBGCC_BASE)/libffi/include
 
+CINCLUDES-$(CONFIG_LIBGCOV)   += -I$(LIBGCC_BASE)/libgcov/include
+CXXINCLUDES-$(CONFIG_LIBGCOV) += -I$(LIBGCC_BASE)/libgcov/include
+
 ################################################################################
 # libbacktrace code
 ################################################################################
@@ -119,3 +124,16 @@ LIBFFI_SRCS-y += $(LIBFFI_EXTRACTED)/src/raw_api.c
 LIBFFI_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBFFI_EXTRACTED)/src/x86/ffi64.c
 LIBFFI_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBFFI_EXTRACTED)/src/x86/unix64.S
 
+################################################################################
+# libgcov code
+################################################################################
+LIBGCOV_CINCLUDES-y = -I$(LIBGCC_BASE)/libgcov/include \
+		-I$(LIBGCC_BASE)/libgcov/include/config
+
+LIBGCOV_CFLAGS-y += -O2 -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector \
+	-DHAVE_CC_TLS
+
+LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-merge.c
+LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-profiler.c
+LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-interface.c
+LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-driver.c
diff --git a/libgcov/include/ansidecl.h b/libgcov/include/ansidecl.h
new file mode 100644
index 0000000..25f33da
--- /dev/null
+++ b/libgcov/include/ansidecl.h
@@ -0,0 +1,355 @@
+/* ANSI and traditional C compatability macros
+   Copyright (C) 1991-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* ANSI and traditional C compatibility macros
+
+   ANSI C is assumed if __STDC__ is #defined.
+
+   Macro		ANSI C definition	Traditional C definition
+   -----		---- - ----------	----------- - ----------
+   PTR			`void *'		`char *'
+   const		not defined		`'
+   volatile		not defined		`'
+   signed		not defined		`'
+
+   For ease of writing code which uses GCC extensions but needs to be
+   portable to other compilers, we provide the GCC_VERSION macro that
+   simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
+   wrappers around __attribute__.  Also, __extension__ will be #defined
+   to nothing if it doesn't work.  See below.  */
+
+#ifndef	_ANSIDECL_H
+#define _ANSIDECL_H	1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Every source file includes this file,
+   so they will all get the switch for lint.  */
+/* LINTLIBRARY */
+
+/* Using MACRO(x,y) in cpp #if conditionals does not work with some
+   older preprocessors.  Thus we can't define something like this:
+
+#define HAVE_GCC_VERSION(MAJOR, MINOR) \
+  (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
+
+and then test "#if HAVE_GCC_VERSION(2,7)".
+
+So instead we use the macro below and test it against specific values.  */
+
+/* This macro simplifies testing whether we are using gcc, and if it
+   is of a particular minimum version. (Both major & minor numbers are
+   significant.)  This macro will evaluate to 0 if we are not using
+   gcc at all.  */
+#ifndef GCC_VERSION
+#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
+#endif /* GCC_VERSION */
+
+#if defined (__STDC__) || defined(__cplusplus) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
+/* All known AIX compilers implement these things (but don't always
+   define __STDC__).  The RISC/OS MIPS compiler defines these things
+   in SVR4 mode, but does not define __STDC__.  */
+/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other
+   C++ compilers, does not define __STDC__, though it acts as if this
+   was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
+
+#define PTR		void *
+
+#undef const
+#undef volatile
+#undef signed
+
+/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
+   it too, but it's not in C89.  */
+#undef inline
+#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))
+/* it's a keyword */
+#else
+# if GCC_VERSION >= 2007
+#  define inline __inline__   /* __inline__ prevents -pedantic warnings */
+# else
+#  define inline  /* nothing */
+# endif
+#endif
+
+#else	/* Not ANSI C.  */
+
+#define PTR		char *
+
+/* some systems define these in header files for non-ansi mode */
+#undef const
+#undef volatile
+#undef signed
+#undef inline
+#define const
+#define volatile
+#define signed
+#define inline
+
+#endif	/* ANSI C.  */
+
+/* Define macros for some gcc attributes.  This permits us to use the
+   macros freely, and know that they will come into play for the
+   version of gcc in which they are supported.  */
+
+#if (GCC_VERSION < 2007)
+# define __attribute__(x)
+#endif
+
+/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
+#ifndef ATTRIBUTE_MALLOC
+# if (GCC_VERSION >= 2096)
+#  define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define ATTRIBUTE_MALLOC
+# endif /* GNUC >= 2.96 */
+#endif /* ATTRIBUTE_MALLOC */
+
+/* Attributes on labels were valid as of gcc 2.93 and g++ 4.5.  For
+   g++ an attribute on a label must be followed by a semicolon.  */
+#ifndef ATTRIBUTE_UNUSED_LABEL
+# ifndef __cplusplus
+#  if GCC_VERSION >= 2093
+#   define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
+#  else
+#   define ATTRIBUTE_UNUSED_LABEL
+#  endif
+# else
+#  if GCC_VERSION >= 4005
+#   define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED ;
+#  else
+#   define ATTRIBUTE_UNUSED_LABEL
+#  endif
+# endif
+#endif
+
+/* Similarly to ARG_UNUSED below.  Prior to GCC 3.4, the C++ frontend
+   couldn't parse attributes placed after the identifier name, and now
+   the entire compiler is built with C++.  */
+#ifndef ATTRIBUTE_UNUSED
+#if GCC_VERSION >= 3004
+#  define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+#else
+#define ATTRIBUTE_UNUSED
+#endif
+#endif /* ATTRIBUTE_UNUSED */
+
+/* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the
+   identifier name.  */
+#if ! defined(__cplusplus) || (GCC_VERSION >= 3004)
+# define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED
+#else /* !__cplusplus || GNUC >= 3.4 */
+# define ARG_UNUSED(NAME) NAME
+#endif /* !__cplusplus || GNUC >= 3.4 */
+
+#ifndef ATTRIBUTE_NORETURN
+#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#endif /* ATTRIBUTE_NORETURN */
+
+/* Attribute `nonnull' was valid as of gcc 3.3.  */
+#ifndef ATTRIBUTE_NONNULL
+# if (GCC_VERSION >= 3003)
+#  define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
+# else
+#  define ATTRIBUTE_NONNULL(m)
+# endif /* GNUC >= 3.3 */
+#endif /* ATTRIBUTE_NONNULL */
+
+/* Attribute `returns_nonnull' was valid as of gcc 4.9.  */
+#ifndef ATTRIBUTE_RETURNS_NONNULL
+# if (GCC_VERSION >= 4009)
+#  define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
+# else
+#  define ATTRIBUTE_RETURNS_NONNULL
+# endif /* GNUC >= 4.9 */
+#endif /* ATTRIBUTE_RETURNS_NONNULL */
+
+/* Attribute `pure' was valid as of gcc 3.0.  */
+#ifndef ATTRIBUTE_PURE
+# if (GCC_VERSION >= 3000)
+#  define ATTRIBUTE_PURE __attribute__ ((__pure__))
+# else
+#  define ATTRIBUTE_PURE
+# endif /* GNUC >= 3.0 */
+#endif /* ATTRIBUTE_PURE */
+
+/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
+   This was the case for the `printf' format attribute by itself
+   before GCC 3.3, but as of 3.3 we need to add the `nonnull'
+   attribute to retain this behavior.  */
+#ifndef ATTRIBUTE_PRINTF
+#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
+#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
+#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
+#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
+#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
+#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
+#endif /* ATTRIBUTE_PRINTF */
+
+/* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on
+   a function pointer.  Format attributes were allowed on function
+   pointers as of gcc 3.1.  */
+#ifndef ATTRIBUTE_FPTR_PRINTF
+# if (GCC_VERSION >= 3001)
+#  define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n)
+# else
+#  define ATTRIBUTE_FPTR_PRINTF(m, n)
+# endif /* GNUC >= 3.1 */
+# define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2)
+# define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3)
+# define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4)
+# define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5)
+# define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6)
+#endif /* ATTRIBUTE_FPTR_PRINTF */
+
+/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL.  A
+   NULL format specifier was allowed as of gcc 3.3.  */
+#ifndef ATTRIBUTE_NULL_PRINTF
+# if (GCC_VERSION >= 3003)
+#  define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
+# else
+#  define ATTRIBUTE_NULL_PRINTF(m, n)
+# endif /* GNUC >= 3.3 */
+# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
+# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
+# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
+# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
+# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
+#endif /* ATTRIBUTE_NULL_PRINTF */
+
+/* Attribute `sentinel' was valid as of gcc 3.5.  */
+#ifndef ATTRIBUTE_SENTINEL
+# if (GCC_VERSION >= 3005)
+#  define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
+# else
+#  define ATTRIBUTE_SENTINEL
+# endif /* GNUC >= 3.5 */
+#endif /* ATTRIBUTE_SENTINEL */
+
+
+#ifndef ATTRIBUTE_ALIGNED_ALIGNOF
+# if (GCC_VERSION >= 3000)
+#  define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m))))
+# else
+#  define ATTRIBUTE_ALIGNED_ALIGNOF(m)
+# endif /* GNUC >= 3.0 */
+#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
+
+/* Useful for structures whose layout must match some binary specification
+   regardless of the alignment and padding qualities of the compiler.  */
+#ifndef ATTRIBUTE_PACKED
+# define ATTRIBUTE_PACKED __attribute__ ((packed))
+#endif
+
+/* Attribute `hot' and `cold' was valid as of gcc 4.3.  */
+#ifndef ATTRIBUTE_COLD
+# if (GCC_VERSION >= 4003)
+#  define ATTRIBUTE_COLD __attribute__ ((__cold__))
+# else
+#  define ATTRIBUTE_COLD
+# endif /* GNUC >= 4.3 */
+#endif /* ATTRIBUTE_COLD */
+#ifndef ATTRIBUTE_HOT
+# if (GCC_VERSION >= 4003)
+#  define ATTRIBUTE_HOT __attribute__ ((__hot__))
+# else
+#  define ATTRIBUTE_HOT
+# endif /* GNUC >= 4.3 */
+#endif /* ATTRIBUTE_HOT */
+
+/* Attribute 'no_sanitize_undefined' was valid as of gcc 4.9.  */
+#ifndef ATTRIBUTE_NO_SANITIZE_UNDEFINED
+# if (GCC_VERSION >= 4009)
+#  define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined))
+# else
+#  define ATTRIBUTE_NO_SANITIZE_UNDEFINED
+# endif /* GNUC >= 4.9 */
+#endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */
+
+/* We use __extension__ in some places to suppress -pedantic warnings
+   about GCC extensions.  This feature didn't work properly before
+   gcc 2.8.  */
+#if GCC_VERSION < 2008
+#define __extension__
+#endif
+
+/* This is used to declare a const variable which should be visible
+   outside of the current compilation unit.  Use it as
+     EXPORTED_CONST int i = 1;
+   This is because the semantics of const are different in C and C++.
+   "extern const" is permitted in C but it looks strange, and gcc
+   warns about it when -Wc++-compat is not used.  */
+#ifdef __cplusplus
+#define EXPORTED_CONST extern const
+#else
+#define EXPORTED_CONST const
+#endif
+
+/* Be conservative and only use enum bitfields with C++ or GCC.
+   FIXME: provide a complete autoconf test for buggy enum bitfields.  */
+
+#ifdef __cplusplus
+#define ENUM_BITFIELD(TYPE) enum TYPE
+#elif (GCC_VERSION > 2000)
+#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
+#else
+#define ENUM_BITFIELD(TYPE) unsigned int
+#endif
+
+/* C++11 adds the ability to add "override" after an implementation of a
+   virtual function in a subclass, to:
+     (A) document that this is an override of a virtual function
+     (B) allow the compiler to issue a warning if it isn't (e.g. a mismatch
+         of the type signature).
+
+   Similarly, it allows us to add a "final" to indicate that no subclass
+   may subsequently override the vfunc.
+
+   Provide OVERRIDE and FINAL as macros, allowing us to get these benefits
+   when compiling with C++11 support, but without requiring C++11.
+
+   For gcc, use "-std=c++11" to enable C++11 support; gcc 6 onwards enables
+   this by default (actually GNU++14).  */
+
+#if __cplusplus >= 201103
+/* C++11 claims to be available: use it.  final/override were only
+   implemented in 4.7, though.  */
+# if GCC_VERSION < 4007
+#  define OVERRIDE
+#  define FINAL
+# else
+#  define OVERRIDE override
+#  define FINAL final
+# endif
+#elif GCC_VERSION >= 4007
+/* G++ 4.7 supports __final in C++98.  */
+# define OVERRIDE
+# define FINAL __final
+#else
+/* No C++11 support; leave the macros empty: */
+# define OVERRIDE
+# define FINAL
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif	/* ansidecl.h	*/
diff --git a/libgcov/include/config/auto-host.h b/libgcov/include/config/auto-host.h
new file mode 100644
index 0000000..9b81bf2
--- /dev/null
+++ b/libgcov/include/config/auto-host.h
@@ -0,0 +1,2419 @@
+/* auto-host.h.  Generated from config.in by configure.  */
+/* config.in.  Generated from configure.ac by autoheader.  */
+
+/* Define if this compiler should be built as the offload target compiler. */
+#ifndef USED_FOR_TARGET
+/* #undef ACCEL_COMPILER */
+#endif
+
+
+/* Define if building universal (internal helper macro) */
+#ifndef USED_FOR_TARGET
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+#endif
+
+
+/* Define to the assembler option to enable compressed debug sections. */
+#ifndef USED_FOR_TARGET
+#define AS_COMPRESS_DEBUG_OPTION ""
+#endif
+
+
+/* Define to the assembler option to disable compressed debug sections. */
+#ifndef USED_FOR_TARGET
+#define AS_NO_COMPRESS_DEBUG_OPTION ""
+#endif
+
+
+/* Define as the number of bits in a byte, if `limits.h' doesn't. */
+#ifndef USED_FOR_TARGET
+/* #undef CHAR_BIT */
+#endif
+
+
+/* Define to 0/1 if you want more run-time sanity checks. This one gets a grab
+   bag of miscellaneous but relatively cheap checks. */
+#ifndef USED_FOR_TARGET
+#define CHECKING_P 0
+#endif
+
+
+/* Define 0/1 to force the choice for exception handling model. */
+#ifndef USED_FOR_TARGET
+/* #undef CONFIG_SJLJ_EXCEPTIONS */
+#endif
+
+
+/* Define to enable the use of a default assembler. */
+#ifndef USED_FOR_TARGET
+/* #undef DEFAULT_ASSEMBLER */
+#endif
+
+
+/* Define to enable the use of a default linker. */
+#ifndef USED_FOR_TARGET
+/* #undef DEFAULT_LINKER */
+#endif
+
+
+/* Define if you want to use __cxa_atexit, rather than atexit, to register C++
+   destructors for local statics and global objects. This is essential for
+   fully standards-compliant handling of destructors, but requires
+   __cxa_atexit in libc. */
+#ifndef USED_FOR_TARGET
+#define DEFAULT_USE_CXA_ATEXIT 2
+#endif
+
+
+/* The default for -fdiagnostics-color option */
+#ifndef USED_FOR_TARGET
+#define DIAGNOSTICS_COLOR_DEFAULT DIAGNOSTICS_COLOR_AUTO
+#endif
+
+
+/* Define if you want assertions enabled. This is a cheap check. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_ASSERT_CHECKING 1
+#endif
+
+
+/* Define to 1 to specify that we are using the BID decimal floating point
+   format instead of DPD */
+#ifndef USED_FOR_TARGET
+#define ENABLE_DECIMAL_BID_FORMAT 1
+#endif
+
+
+/* Define to 1 to enable decimal float extension to C. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_DECIMAL_FLOAT 1
+#endif
+
+
+/* Define if your target supports default PIE and it is enabled. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_DEFAULT_PIE */
+#endif
+
+
+/* Define if your target supports default stack protector and it is enabled.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_DEFAULT_SSP */
+#endif
+
+
+/* Define if you want more run-time sanity checks for dataflow. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_DF_CHECKING */
+#endif
+
+
+/* Define to 0/1 if you want extra run-time checking that might affect code
+   generation. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_EXTRA_CHECKING 0
+#endif
+
+
+/* Define to 1 to enable fixed-point arithmetic extension to C. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_FIXED_POINT 0
+#endif
+
+
+/* Define if you want fold checked that it never destructs its argument. This
+   is quite expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_FOLD_CHECKING */
+#endif
+
+
+/* Define if you want the garbage collector to operate in maximally paranoid
+   mode, validating the entire heap and collecting garbage at every
+   opportunity. This is extremely expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_GC_ALWAYS_COLLECT */
+#endif
+
+
+/* Define if you want the garbage collector to do object poisoning and other
+   memory allocation checks. This is quite expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_GC_CHECKING */
+#endif
+
+
+/* Define if you want operations on GIMPLE (the basic data structure of the
+   high-level optimizers) to be checked for dynamic type safety at runtime.
+   This is moderately expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_GIMPLE_CHECKING */
+#endif
+
+
+/* Define this to enable support for generating HSAIL. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_HSA */
+#endif
+
+
+/* Define if gcc should always pass --build-id to linker. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_LD_BUILDID */
+#endif
+
+
+/* Define to 1 to enable libquadmath support */
+#ifndef USED_FOR_TARGET
+#define ENABLE_LIBQUADMATH_SUPPORT 1
+#endif
+
+
+/* Define to enable LTO support. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_LTO */
+#endif
+
+
+/* Define to 1 if translation of program messages to the user's native
+   language is requested. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_NLS */
+#endif
+
+
+/* Define this to enable support for offloading. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_OFFLOADING 0
+#endif
+
+
+/* Define to enable plugin support. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_PLUGIN 1
+#endif
+
+
+/* Define if you want all operations on RTL (the basic data structure of the
+   optimizer and back end) to be checked for dynamic type safety at runtime.
+   This is quite expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_RTL_CHECKING */
+#endif
+
+
+/* Define if you want RTL flag accesses to be checked against the RTL codes
+   that are supported for each access macro. This is relatively cheap. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_RTL_FLAG_CHECKING */
+#endif
+
+
+/* Define if you want runtime assertions enabled. This is a cheap check. */
+#define ENABLE_RUNTIME_CHECKING 1
+
+/* Define if you want all operations on trees (the basic data structure of the
+   front ends) to be checked for dynamic type safety at runtime. This is
+   moderately expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_TREE_CHECKING */
+#endif
+
+
+/* Define if you want all gimple types to be verified after gimplifiation.
+   This is cheap. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_TYPES_CHECKING */
+#endif
+
+
+/* Define to get calls to the valgrind runtime enabled. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_VALGRIND_ANNOTATIONS */
+#endif
+
+
+/* Define if you want to run subprograms and generated programs through
+   valgrind (a memory checker). This is extremely expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_VALGRIND_CHECKING */
+#endif
+
+
+/* Define 0/1 if vtable verification feature is enabled. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_VTABLE_VERIFY 0
+#endif
+
+
+/* Define to 1 if installation paths should be looked up in the Windows
+   Registry. Ignored on non-Windows hosts. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_WIN32_REGISTRY */
+#endif
+
+
+/* Define to the name of a file containing a list of extra machine modes for
+   this architecture. */
+#ifndef USED_FOR_TARGET
+#define EXTRA_MODES_FILE "config/i386/i386-modes.def"
+#endif
+
+
+/* Define to enable detailed memory allocation stats gathering. */
+#ifndef USED_FOR_TARGET
+#define GATHER_STATISTICS 0
+#endif
+
+
+/* Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>. */
+#ifndef USED_FOR_TARGET
+#define GWINSZ_IN_SYS_IOCTL 1
+#endif
+
+
+/* mcontext_t fields start with __ */
+#ifndef USED_FOR_TARGET
+/* #undef HAS_MCONTEXT_T_UNDERSCORES */
+#endif
+
+
+/* Define if your assembler supports architecture modifiers. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_ARCHITECTURE_MODIFIERS */
+#endif
+
+
+/* Define if your avr assembler supports --mlink-relax option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_AVR_MLINK_RELAX_OPTION */
+#endif
+
+
+/* Define if your avr assembler supports -mrmw option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_AVR_MRMW_OPTION */
+#endif
+
+
+/* Define if your assembler supports cmpb. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_CMPB */
+#endif
+
+
+/* Define to the level of your assembler's compressed debug section support.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_COMPRESS_DEBUG no
+#endif
+
+
+/* Define if your assembler supports the DCI/ICI instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DCI */
+#endif
+
+
+/* Define if your assembler supports the --debug-prefix-map option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DEBUG_PREFIX_MAP */
+#endif
+
+
+/* Define if your assembler supports DFP instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DFP */
+#endif
+
+
+/* Define if your assembler supports .module. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DOT_MODULE */
+#endif
+
+
+/* Define if your assembler supports DSPR1 mult. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DSPR1_MULT */
+#endif
+
+
+/* Define if your assembler supports .dtprelword. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DTPRELWORD */
+#endif
+
+
+/* Define if your assembler supports dwarf2 .file/.loc directives, and
+   preserves file table indices exactly as given. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DWARF2_DEBUG_LINE */
+#endif
+
+
+/* Define if your assembler supports the R_PPC64_ENTRY relocation. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_ENTRY_MARKERS */
+#endif
+
+
+/* Define if your assembler supports explicit relocations. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_EXPLICIT_RELOCS */
+#endif
+
+
+/* Define if your assembler supports FMAF, HPC, and VIS 3.0 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_FMAF_HPC_VIS3 */
+#endif
+
+
+/* Define if your assembler supports fprnd. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_FPRND */
+#endif
+
+
+/* Define if your assembler supports the --gdwarf2 option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_GDWARF2_DEBUG_FLAG */
+#endif
+
+
+/* Define if your assembler supports .gnu_attribute. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_GNU_ATTRIBUTE */
+#endif
+
+
+/* Define true if the assembler supports '.long foo@GOTOFF'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_GOTOFF_IN_DATA 0
+#endif
+
+
+/* Define if your assembler supports the --gstabs option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_GSTABS_DEBUG_FLAG */
+#endif
+
+
+/* Define if your assembler supports the Sun syntax for cmov. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_CMOV_SUN_SYNTAX */
+#endif
+
+
+/* Define if your assembler supports the subtraction of symbols in different
+   sections. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_DIFF_SECT_DELTA */
+#endif
+
+
+/* Define if your assembler supports the ffreep mnemonic. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_FFREEP */
+#endif
+
+
+/* Define if your assembler uses fildq and fistq mnemonics. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_FILDQ */
+#endif
+
+
+/* Define if your assembler uses filds and fists mnemonics. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_FILDS */
+#endif
+
+
+/* Define 0/1 if your assembler and linker support @GOT. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_GOT32X 0
+#endif
+
+
+/* Define if your assembler supports HLE prefixes. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_HLE */
+#endif
+
+
+/* Define if your assembler supports interunit movq mnemonic. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_INTERUNIT_MOVQ 0
+#endif
+
+
+/* Define if your assembler supports the .quad directive. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_QUAD */
+#endif
+
+
+/* Define if the assembler supports 'rep <insn>, lock <insn>'. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_REP_LOCK_PREFIX */
+#endif
+
+
+/* Define if your assembler supports the sahf mnemonic in 64bit mode. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_SAHF */
+#endif
+
+
+/* Define if your assembler supports the swap suffix. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_SWAP */
+#endif
+
+
+/* Define if your assembler and linker support @tlsgdplt. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_TLSGDPLT */
+#endif
+
+
+/* Define to 1 if your assembler and linker support @tlsldm. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_TLSLDM 0
+#endif
+
+
+/* Define to 1 if your assembler and linker support @tlsldmplt. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_TLSLDMPLT 0
+#endif
+
+
+/* Define 0/1 if your assembler and linker support calling ___tls_get_addr via
+   GOT. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_TLS_GET_ADDR_GOT 0
+#endif
+
+
+/* Define if your assembler supports the 'ud2' mnemonic. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_UD2 */
+#endif
+
+
+/* Define if your assembler supports the lituse_jsrdirect relocation. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_JSRDIRECT_RELOCS */
+#endif
+
+
+/* Define if your assembler supports .sleb128 and .uleb128. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_LEB128 0
+#endif
+
+
+/* Define if your assembler supports LEON instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_LEON */
+#endif
+
+
+/* Define if the assembler won't complain about a line such as # 0 "" 2. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_LINE_ZERO */
+#endif
+
+
+/* Define if your assembler supports ltoffx and ldxmov relocations. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_LTOFFX_LDXMOV_RELOCS */
+#endif
+
+
+/* Define if your assembler supports LWSYNC instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_LWSYNC */
+#endif
+
+
+/* Define if your assembler supports the -mabi option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MABI_OPTION */
+#endif
+
+
+/* Define if your assembler supports .machine and .machinemode. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MACHINE_MACHINEMODE */
+#endif
+
+
+/* Define if your assembler supports mfcr field. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MFCRF */
+#endif
+
+
+/* Define if your assembler supports mffgpr and mftgpr. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MFPGPR */
+#endif
+
+
+/* Define if your Mac OS X assembler supports the -mmacos-version-min option.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MMACOSX_VERSION_MIN_OPTION */
+#endif
+
+
+/* Define if the assembler understands -mnan=. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_NAN */
+#endif
+
+
+/* Define if your assembler supports the -no-mul-bug-abort option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_NO_MUL_BUG_ABORT_OPTION */
+#endif
+
+
+/* Define if the assembler understands -mno-shared. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_NO_SHARED */
+#endif
+
+
+/* Define if your assembler supports offsetable %lo(). */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_OFFSETABLE_LO10 */
+#endif
+
+
+/* Define if your assembler supports popcntb field. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_POPCNTB */
+#endif
+
+
+/* Define if your assembler supports POPCNTD instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_POPCNTD */
+#endif
+
+
+/* Define if your assembler supports POWER8 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_POWER8 */
+#endif
+
+
+/* Define if your assembler supports POWER9 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_POWER9 */
+#endif
+
+
+/* Define if your assembler supports .ref */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_REF */
+#endif
+
+
+/* Define if your assembler supports .register. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
+#endif
+
+
+/* Define if your assembler supports R_PPC_REL16 relocs. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_REL16 */
+#endif
+
+
+/* Define if your assembler supports -relax option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_RELAX_OPTION */
+#endif
+
+
+/* Define if your assembler supports relocs needed by -fpic. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SMALL_PIC_RELOCS */
+#endif
+
+
+/* Define if your assembler supports SPARC4 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC4 */
+#endif
+
+
+/* Define if your assembler supports SPARC5 and VIS 4.0 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC5_VIS4 */
+#endif
+
+/* Define if your assembler supports SPARC6 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC6 */
+#endif
+
+/* Define if your assembler and linker support GOTDATA_OP relocs. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC_GOTDATA_OP */
+#endif
+
+
+/* Define if your assembler and linker support unaligned PC relative relocs.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC_UA_PCREL */
+#endif
+
+
+/* Define if your assembler and linker support unaligned PC relative relocs
+   against hidden symbols. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC_UA_PCREL_HIDDEN */
+#endif
+
+
+/* Define if your assembler supports .stabs. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_STABS_DIRECTIVE */
+#endif
+
+
+/* Define if your assembler and linker support thread-local storage. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_TLS */
+#endif
+
+
+/* Define if your assembler supports arg info for __tls_get_addr. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_TLS_MARKERS */
+#endif
+
+
+/* Define if your assembler supports VSX instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_VSX */
+#endif
+
+
+/* Define if your assembler supports -xbrace_comment option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_XBRACE_COMMENT_OPTION */
+#endif
+
+
+/* Define to 1 if you have the `atoq' function. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_ATOQ */
+#endif
+
+
+/* Define to 1 if you have the `clearerr_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_CLEARERR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `clock' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_CLOCK 1
+#endif
+
+
+/* Define if <time.h> defines clock_t. */
+#ifndef USED_FOR_TARGET
+#define HAVE_CLOCK_T 1
+#endif
+
+
+/* Define 0/1 if your assembler and linker support COMDAT groups. */
+#ifndef USED_FOR_TARGET
+#define HAVE_COMDAT_GROUP 0
+#endif
+
+
+/* Define to 1 if we found a declaration for 'abort', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ABORT 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'asprintf', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ASPRINTF 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'atof', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ATOF 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'atol', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ATOL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'atoll', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ATOLL 1
+#endif
+
+
+/* Define to 1 if you have the declaration of `basename(const char*)', and to
+   0 if you don't. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_BASENAME 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'calloc', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_CALLOC 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'clearerr_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_CLEARERR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'clock', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_CLOCK 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'errno', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ERRNO 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'feof_unlocked', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FEOF_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'ferror_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FERROR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fflush_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FFLUSH_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'ffs', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FFS 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fgetc_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FGETC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fgets_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FGETS_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fileno_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FILENO_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fprintf_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FPRINTF_UNLOCKED 0
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fputc_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FPUTC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fputs_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FPUTS_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fread_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FREAD_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'free', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FREE 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fwrite_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FWRITE_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getchar_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETCHAR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getcwd', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETCWD 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getc_unlocked', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getenv', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETENV 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getopt', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETOPT 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getpagesize', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETPAGESIZE 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getrlimit', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETRLIMIT 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getrusage', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETRUSAGE 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getwd', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETWD 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'ldgetname', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_LDGETNAME 0
+#endif
+
+
+/* Define to 1 if we found a declaration for 'madvise', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_MADVISE 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'malloc', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_MALLOC 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'putchar_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_PUTCHAR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'putc_unlocked', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_PUTC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'realloc', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_REALLOC 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'sbrk', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SBRK 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'setenv', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SETENV 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'setrlimit', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SETRLIMIT 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'sigaltstack', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SIGALTSTACK 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'snprintf', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SNPRINTF 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'stpcpy', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STPCPY 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strnlen', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRNLEN 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strsignal', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRSIGNAL 1
+#endif
+
+
+/* Define to 1 if you have the declaration of `strstr(const char*,const
+   char*)', and to 0 if you don't. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRSTR 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strtol', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRTOL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strtoll', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRTOLL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strtoul', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRTOUL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strtoull', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRTOULL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strverscmp', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRVERSCMP 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'times', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_TIMES 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'unsetenv', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_UNSETENV 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'vasprintf', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_VASPRINTF 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'vsnprintf', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_VSNPRINTF 1
+#endif
+
+
+/* Define to 1 if you have the <direct.h> header file. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_DIRECT_H */
+#endif
+
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DLFCN_H 1
+#endif
+
+
+/* Define to 1 if you have the <ext/hash_map> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_EXT_HASH_MAP 1
+#endif
+
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FCNTL_H 1
+#endif
+
+
+/* Define to 1 if you have the `feof_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FEOF_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `ferror_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FERROR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fflush_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FFLUSH_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fgetc_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FGETC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fgets_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FGETS_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fileno_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FILENO_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fork' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FORK 1
+#endif
+
+
+/* Define to 1 if you have the `fprintf_unlocked' function. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_FPRINTF_UNLOCKED */
+#endif
+
+
+/* Define to 1 if you have the `fputc_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FPUTC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fputs_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FPUTS_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fread_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FREAD_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the <ftw.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FTW_H 1
+#endif
+
+
+/* Define to 1 if you have the `fwrite_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FWRITE_UNLOCKED 1
+#endif
+
+
+/* Define if your assembler supports specifying the alignment of objects
+   allocated using the GAS .comm command. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_ALIGNED_COMM */
+#endif
+
+
+/* Define if your assembler supports .balign and .p2align. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_BALIGN_AND_P2ALIGN */
+#endif
+
+
+/* Define 0/1 if your assembler supports CFI directives. */
+#define HAVE_GAS_CFI_DIRECTIVE 0
+
+/* Define 0/1 if your assembler supports .cfi_personality. */
+#define HAVE_GAS_CFI_PERSONALITY_DIRECTIVE 0
+
+/* Define 0/1 if your assembler supports .cfi_sections. */
+#define HAVE_GAS_CFI_SECTIONS_DIRECTIVE 0
+
+/* Define if your assembler supports the .loc discriminator sub-directive. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_DISCRIMINATOR */
+#endif
+
+
+/* Define if your assembler supports @gnu_unique_object. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_GNU_UNIQUE_OBJECT */
+#endif
+
+
+/* Define if your assembler and linker support .hidden. */
+/* #undef HAVE_GAS_HIDDEN */
+
+/* Define if your assembler supports .lcomm with an alignment field. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_LCOMM_WITH_ALIGNMENT */
+#endif
+
+
+/* Define if your assembler supports .literal16. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_LITERAL16 */
+#endif
+
+
+/* Define if your assembler supports specifying the maximum number of bytes to
+   skip when using the GAS .p2align command. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_MAX_SKIP_P2ALIGN */
+#endif
+
+
+/* Define if your assembler supports the .set micromips directive */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_MICROMIPS */
+#endif
+
+
+/* Define if your assembler supports .nsubspa comdat option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_NSUBSPA_COMDAT */
+#endif
+
+
+/* Define if your assembler and linker support 32-bit section relative relocs
+   via '.secrel32 label'. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_PE_SECREL32_RELOC */
+#endif
+
+
+/* Define if your assembler supports specifying the section flag e. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GAS_SECTION_EXCLUDE 0
+#endif
+
+
+/* Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_GAS_SHF_MERGE 0
+#endif
+
+
+/* Define if your assembler supports .subsection and .subsection -1 starts
+   emitting at the beginning of your section. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_SUBSECTION_ORDERING */
+#endif
+
+
+/* Define if your assembler supports .weak. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_WEAK */
+#endif
+
+
+/* Define if your assembler supports .weakref. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_WEAKREF */
+#endif
+
+
+/* Define to 1 if you have the `getchar_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETCHAR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `getc_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `getrlimit' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETRLIMIT 1
+#endif
+
+
+/* Define to 1 if you have the `getrusage' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETRUSAGE 1
+#endif
+
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETTIMEOFDAY 1
+#endif
+
+
+/* Define to 1 if using GNU as. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GNU_AS 1
+#endif
+
+
+/* Define if your system supports gnu indirect functions. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GNU_INDIRECT_FUNCTION 1
+#endif
+
+
+/* Define to 1 if using GNU ld. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GNU_LD 1
+#endif
+
+
+/* Define if the gold linker supports split stack and is available as a
+   non-default */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GOLD_NON_DEFAULT_SPLIT_STACK */
+#endif
+
+
+/* Define if you have the iconv() function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_ICONV 1
+#endif
+
+
+/* Define to 1 if you have the <iconv.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_ICONV_H 1
+#endif
+
+
+/* Define 0/1 if .init_array/.fini_array sections are available and working.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_INITFINI_ARRAY_SUPPORT 0
+#endif
+
+
+/* Define to 1 if the system has the type `intmax_t'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_INTMAX_T 1
+#endif
+
+
+/* Define to 1 if the system has the type `intptr_t'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_INTPTR_T 1
+#endif
+
+
+/* Define if you have a working <inttypes.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_INTTYPES_H 1
+#endif
+
+
+/* Define to 1 if you have the `kill' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_KILL 1
+#endif
+
+
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+#ifndef USED_FOR_TARGET
+#define HAVE_LANGINFO_CODESET 1
+#endif
+
+
+/* Define to 1 if you have the <langinfo.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LANGINFO_H 1
+#endif
+
+
+/* Define if your <locale.h> file defines LC_MESSAGES. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LC_MESSAGES 1
+#endif
+
+
+/* Define to 1 if you have the <ldfcn.h> header file. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LDFCN_H */
+#endif
+
+
+/* Define if your linker supports --as-needed/--no-as-needed or equivalent
+   options. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_AS_NEEDED */
+#endif
+
+
+/* Define if your linker supports -z bndplt */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_BNDPLT_SUPPORT */
+#endif
+
+
+/* Define if your linker supports --build-id. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_BUILDID */
+#endif
+
+
+/* Define if the linker supports clearing hardware capabilities via mapfile.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_CLEARCAP */
+#endif
+
+
+/* Define to the level of your linker's compressed debug section support. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LD_COMPRESS_DEBUG 0
+#endif
+
+
+/* Define if your linker supports --demangle option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_DEMANGLE */
+#endif
+
+
+/* Define 0/1 if your linker supports CIE v3 in .eh_frame. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LD_EH_FRAME_CIEV3 0
+#endif
+
+
+/* Define if your linker supports .eh_frame_hdr. */
+/* #undef HAVE_LD_EH_FRAME_HDR */
+
+/* Define if your linker supports garbage collection of sections in presence
+   of EH frames. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_EH_GC_SECTIONS */
+#endif
+
+
+/* Define if your linker has buggy garbage collection of sections support when
+   .text.startup.foo like sections are used. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_EH_GC_SECTIONS_BUG */
+#endif
+
+
+/* Define if your PowerPC64 linker supports a large TOC. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_LARGE_TOC */
+#endif
+
+
+/* Define if your PowerPC64 linker only needs function descriptor syms. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_NO_DOT_SYMS */
+#endif
+
+
+/* Define if your linker can relax absolute .eh_frame personality pointers
+   into PC-relative form. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_PERSONALITY_RELAXATION */
+#endif
+
+
+/* Define if your linker supports PIE option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_PIE */
+#endif
+
+
+/* Define 0/1 if your linker supports -pie option with copy reloc. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LD_PIE_COPYRELOC 0
+#endif
+
+
+/* Define if your PowerPC linker has .gnu.attributes long double support. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE */
+#endif
+
+
+/* Define if your linker supports --push-state/--pop-state */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_PUSHPOPSTATE_SUPPORT */
+#endif
+
+
+/* Define if your linker links a mix of read-only and read-write sections into
+   a read-write section. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_RO_RW_SECTION_MIXING */
+#endif
+
+
+/* Define if your linker supports the *_sol2 emulations. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_SOL2_EMULATION */
+#endif
+
+
+/* Define if your linker supports -Bstatic/-Bdynamic or equivalent options. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_STATIC_DYNAMIC */
+#endif
+
+
+/* Define if your linker supports --sysroot. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_SYSROOT */
+#endif
+
+
+/* Define to 1 if you have the <limits.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LIMITS_H 1
+#endif
+
+
+/* Define to 1 if you have the <locale.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LOCALE_H 1
+#endif
+
+
+/* Define to 1 if the system has the type `long long'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LONG_LONG 1
+#endif
+
+
+/* Define to 1 if the system has the type `long long int'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LONG_LONG_INT 1
+#endif
+
+
+/* Define to the level of your linker's plugin support. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LTO_PLUGIN 0
+#endif
+
+
+/* Define to 1 if you have the `madvise' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MADVISE 1
+#endif
+
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MALLOC_H 1
+#endif
+
+
+/* Define to 1 if you have the `mbstowcs' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MBSTOWCS 1
+#endif
+
+
+/* Define if valgrind's memcheck.h header is installed. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_MEMCHECK_H */
+#endif
+
+
+/* Define to 1 if you have the <memory.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MEMORY_H 1
+#endif
+
+
+/* Define to 1 if you have the `mmap' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MMAP 1
+#endif
+
+
+/* Define if mmap with MAP_ANON(YMOUS) works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MMAP_ANON 1
+#endif
+
+
+/* Define if mmap of /dev/zero works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MMAP_DEV_ZERO 1
+#endif
+
+
+/* Define if read-only mmap of a plain file works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MMAP_FILE 1
+#endif
+
+
+/* Define to 1 if you have the `nl_langinfo' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_NL_LANGINFO 1
+#endif
+
+
+/* Define to 1 if you have the `popen' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_POPEN 1
+#endif
+
+
+/* Define to 1 if you have the `putchar_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_PUTCHAR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `putc_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_PUTC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `setlocale' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SETLOCALE 1
+#endif
+
+
+/* Define to 1 if you have the `setrlimit' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SETRLIMIT 1
+#endif
+
+
+/* Define if the system-provided CRTs are present on Solaris. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_SOLARIS_CRTS */
+#endif
+
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STDDEF_H 1
+#endif
+
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STDINT_H 1
+#endif
+
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STDLIB_H 1
+#endif
+
+
+/* Define to 1 if you have the <strings.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STRINGS_H 1
+#endif
+
+
+/* Define to 1 if you have the <string.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STRING_H 1
+#endif
+
+
+/* Define to 1 if you have the `strsignal' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STRSIGNAL 1
+#endif
+
+
+/* Define if <sys/times.h> defines struct tms. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STRUCT_TMS 1
+#endif
+
+
+/* Define if <utility> defines std::swap. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SWAP_IN_UTILITY 1
+#endif
+
+
+/* Define to 1 if you have the `sysconf' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYSCONF 1
+#endif
+
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_FILE_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_MMAN_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_PARAM_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_RESOURCE_H 1
+#endif
+
+
+/* Define if your target C library provides sys/sdt.h */
+/* #undef HAVE_SYS_SDT_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_STAT_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/times.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_TIMES_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_TIME_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_TYPES_H 1
+#endif
+
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_WAIT_H 1
+#endif
+
+
+/* Define to 1 if you have the `times' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_TIMES 1
+#endif
+
+
+/* Define to 1 if you have the <time.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_TIME_H 1
+#endif
+
+
+/* Define to 1 if you have the <tr1/unordered_map> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_TR1_UNORDERED_MAP 1
+#endif
+
+
+/* Define to 1 if the system has the type `uintmax_t'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UINTMAX_T 1
+#endif
+
+
+/* Define to 1 if the system has the type `uintptr_t'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UINTPTR_T 1
+#endif
+
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UNISTD_H 1
+#endif
+
+
+/* Define to 1 if you have the <unordered_map> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UNORDERED_MAP 1
+#endif
+
+
+/* Define to 1 if the system has the type `unsigned long long int'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+#endif
+
+
+/* Define if valgrind's valgrind/memcheck.h header is installed. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_VALGRIND_MEMCHECK_H */
+#endif
+
+
+/* Define to 1 if you have the `vfork' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_VFORK 1
+#endif
+
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_VFORK_H */
+#endif
+
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WCHAR_H 1
+#endif
+
+
+/* Define to 1 if you have the `wcswidth' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WCSWIDTH 1
+#endif
+
+
+/* Define to 1 if `fork' works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WORKING_FORK 1
+#endif
+
+
+/* Define this macro if mbstowcs does not crash when its first argument is
+   NULL. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WORKING_MBSTOWCS 1
+#endif
+
+
+/* Define to 1 if `vfork' works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WORKING_VFORK 1
+#endif
+
+
+/* Define if your assembler supports AIX debug frame section label reference.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_XCOFF_DWARF_EXTRAS */
+#endif
+
+
+/* Define if isl is in use. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_isl */
+#endif
+
+
+/* Define if F_SETLKW supported by fcntl. */
+#ifndef USED_FOR_TARGET
+#define HOST_HAS_F_SETLKW 1
+#endif
+
+
+/* Define as const if the declaration of iconv() needs const. */
+#ifndef USED_FOR_TARGET
+#define ICONV_CONST 
+#endif
+
+
+/* Define if int64_t uses long as underlying type. */
+#ifndef USED_FOR_TARGET
+#define INT64_T_IS_LONG 1
+#endif
+
+
+/* Define to 1 if ld64 supports '-export_dynamic'. */
+#ifndef USED_FOR_TARGET
+/* #undef LD64_HAS_EXPORT_DYNAMIC */
+#endif
+
+
+/* Define to ld64 version. */
+#ifndef USED_FOR_TARGET
+/* #undef LD64_VERSION */
+#endif
+
+
+/* Define to the linker option to ignore unused dependencies. */
+#ifndef USED_FOR_TARGET
+/* #undef LD_AS_NEEDED_OPTION */
+#endif
+
+
+/* Define to the linker option to enable compressed debug sections. */
+#ifndef USED_FOR_TARGET
+#define LD_COMPRESS_DEBUG_OPTION ""
+#endif
+
+
+/* Define to the linker option to enable use of shared objects. */
+#ifndef USED_FOR_TARGET
+/* #undef LD_DYNAMIC_OPTION */
+#endif
+
+
+/* Define to the linker option to keep unused dependencies. */
+#ifndef USED_FOR_TARGET
+/* #undef LD_NO_AS_NEEDED_OPTION */
+#endif
+
+
+/* Define to the linker option to disable use of shared objects. */
+#ifndef USED_FOR_TARGET
+/* #undef LD_STATIC_OPTION */
+#endif
+
+
+/* The linker hash style */
+#ifndef USED_FOR_TARGET
+/* #undef LINKER_HASH_STYLE */
+#endif
+
+
+/* Define to the name of the LTO plugin DSO that must be passed to the
+   linker's -plugin=LIB option. */
+#ifndef USED_FOR_TARGET
+#define LTOPLUGINSONAME "liblto_plugin.so"
+#endif
+
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#ifndef USED_FOR_TARGET
+#define LT_OBJDIR ".libs/"
+#endif
+
+
+/* Define if host mkdir takes a single argument. */
+#ifndef USED_FOR_TARGET
+/* #undef MKDIR_TAKES_ONE_ARG */
+#endif
+
+
+/* Define to offload targets, separated by commas. */
+#ifndef USED_FOR_TARGET
+#define OFFLOAD_TARGETS ""
+#endif
+
+
+/* Define to the address where bug reports for this package should be sent. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_BUGREPORT ""
+#endif
+
+
+/* Define to the full name of this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_NAME ""
+#endif
+
+
+/* Define to the full name and version of this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_STRING ""
+#endif
+
+
+/* Define to the one symbol short name of this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_TARNAME ""
+#endif
+
+
+/* Define to the home page for this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_URL ""
+#endif
+
+
+/* Define to the version of this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_VERSION ""
+#endif
+
+
+/* Specify plugin linker */
+#ifndef USED_FOR_TARGET
+#define PLUGIN_LD_SUFFIX ""
+#endif
+
+
+/* Define to .TOC. alignment forced by your linker. */
+#ifndef USED_FOR_TARGET
+/* #undef POWERPC64_TOC_POINTER_ALIGNMENT */
+#endif
+
+
+/* Define to PREFIX/include if cpp should also search that directory. */
+#ifndef USED_FOR_TARGET
+/* #undef PREFIX_INCLUDE_DIR */
+#endif
+
+
+/* The size of `int', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_INT 4
+#endif
+
+
+/* The size of `long', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_LONG 8
+#endif
+
+
+/* The size of `long long', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_LONG_LONG 8
+#endif
+
+
+/* The size of `short', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_SHORT 2
+#endif
+
+
+/* The size of `void *', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_VOID_P 8
+#endif
+
+
+/* Define to 1 if you have the ANSI C header files. */
+#ifndef USED_FOR_TARGET
+#define STDC_HEADERS 1
+#endif
+
+
+/* Define if you can safely include both <string.h> and <strings.h>. */
+#ifndef USED_FOR_TARGET
+#define STRING_WITH_STRINGS 1
+#endif
+
+
+/* Define if TFmode long double should be the default */
+#ifndef USED_FOR_TARGET
+/* #undef TARGET_DEFAULT_LONG_DOUBLE_128 */
+#endif
+
+
+/* Define if your target C library provides the `dl_iterate_phdr' function. */
+/* #undef TARGET_DL_ITERATE_PHDR */
+
+/* GNU C Library major version number used on the target, or 0. */
+#ifndef USED_FOR_TARGET
+#define TARGET_GLIBC_MAJOR 2
+#endif
+
+
+/* GNU C Library minor version number used on the target, or 0. */
+#ifndef USED_FOR_TARGET
+#define TARGET_GLIBC_MINOR 27
+#endif
+
+
+/* Define if your target C Library provides the AT_HWCAP value in the TCB */
+#ifndef USED_FOR_TARGET
+/* #undef TARGET_LIBC_PROVIDES_HWCAP_IN_TCB */
+#endif
+
+
+/* Define if your target C library provides stack protector support */
+#ifndef USED_FOR_TARGET
+#define TARGET_LIBC_PROVIDES_SSP 1
+#endif
+
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#ifndef USED_FOR_TARGET
+#define TIME_WITH_SYS_TIME 1
+#endif
+
+
+/* Define to the flag used to mark TLS sections if the default (`T') doesn't
+   work. */
+#ifndef USED_FOR_TARGET
+/* #undef TLS_SECTION_ASM_FLAG */
+#endif
+
+
+/* Define if your assembler mis-optimizes .eh_frame data. */
+#ifndef USED_FOR_TARGET
+/* #undef USE_AS_TRADITIONAL_FORMAT */
+#endif
+
+
+/* Define if you want to generate code by default that assumes that the Cygwin
+   DLL exports wrappers to support libstdc++ function replacement. */
+#ifndef USED_FOR_TARGET
+/* #undef USE_CYGWIN_LIBSTDCXX_WRAPPERS */
+#endif
+
+
+/* Define to 1 if the 'long long' type is wider than 'long' but still
+   efficiently supported by the host hardware. */
+#ifndef USED_FOR_TARGET
+/* #undef USE_LONG_LONG_FOR_WIDEST_FAST_INT */
+#endif
+
+
+/* Define if we should use leading underscore on 64 bit mingw targets */
+#ifndef USED_FOR_TARGET
+/* #undef USE_MINGW64_LEADING_UNDERSCORES */
+#endif
+
+
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+
+
+/* Define to be the last component of the Windows registry key under which to
+   look for installation paths. The full key used will be
+   HKEY_LOCAL_MACHINE/SOFTWARE/Free Software Foundation/{WIN32_REGISTRY_KEY}.
+   The default is the GCC version number. */
+#ifndef USED_FOR_TARGET
+/* #undef WIN32_REGISTRY_KEY */
+#endif
+
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* #  undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#ifndef USED_FOR_TARGET
+/* #undef _FILE_OFFSET_BITS */
+#endif
+
+
+/* Define for large files, on AIX-style hosts. */
+#ifndef USED_FOR_TARGET
+/* #undef _LARGE_FILES */
+#endif
+
+
+/* Define to 1 if on MINIX. */
+#ifndef USED_FOR_TARGET
+/* #undef _MINIX */
+#endif
+
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+#ifndef USED_FOR_TARGET
+/* #undef _POSIX_1_SOURCE */
+#endif
+
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#ifndef USED_FOR_TARGET
+/* #undef _POSIX_SOURCE */
+#endif
+
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#ifndef USED_FOR_TARGET
+/* #undef _UINT32_T */
+#endif
+
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#ifndef USED_FOR_TARGET
+/* #undef _UINT64_T */
+#endif
+
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#ifndef USED_FOR_TARGET
+/* #undef _UINT8_T */
+#endif
+
+
+/* Define to `char *' if <sys/types.h> does not define. */
+#ifndef USED_FOR_TARGET
+/* #undef caddr_t */
+#endif
+
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to the type of a signed integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef int16_t */
+#endif
+
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef int32_t */
+#endif
+
+
+/* Define to the type of a signed integer type of width exactly 64 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef int64_t */
+#endif
+
+
+/* Define to the type of a signed integer type of width exactly 8 bits if such
+   a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef int8_t */
+#endif
+
+
+/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
+   not define. */
+#ifndef USED_FOR_TARGET
+/* #undef intmax_t */
+#endif
+
+
+/* Define to the type of a signed integer type wide enough to hold a pointer,
+   if such a type exists, and if the system does not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef intptr_t */
+#endif
+
+
+/* Define to `int' if <sys/types.h> does not define. */
+#ifndef USED_FOR_TARGET
+/* #undef pid_t */
+#endif
+
+
+/* Define to `long' if <sys/resource.h> doesn't define. */
+#ifndef USED_FOR_TARGET
+/* #undef rlim_t */
+#endif
+
+
+/* Define to `int' if <sys/types.h> does not define. */
+#ifndef USED_FOR_TARGET
+/* #undef ssize_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uint16_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uint32_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uint64_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uint8_t */
+#endif
+
+
+/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
+   do not define. */
+#ifndef USED_FOR_TARGET
+/* #undef uintmax_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type wide enough to hold a
+   pointer, if such a type exists, and if the system does not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uintptr_t */
+#endif
+
+
+/* Define as `fork' if `vfork' does not work. */
+#ifndef USED_FOR_TARGET
+/* #undef vfork */
+#endif
+
diff --git a/libgcov/include/config/auto-target.h b/libgcov/include/config/auto-target.h
new file mode 100644
index 0000000..1ab0d1b
--- /dev/null
+++ b/libgcov/include/config/auto-target.h
@@ -0,0 +1,80 @@
+/* auto-target.h.  Generated from config.in by configure.  */
+/* config.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if the target assembler supports thread-local storage. */
+/* #undef HAVE_CC_TLS */
+
+/* Define to 1 if you have the <ftw.h> header file. */
+#define HAVE_FTW_H 1
+
+/* Define if _Unwind_GetIPInfo is available. */
+#define HAVE_GETIPINFO 1
+
+/* Define if the compiler supports init priority. */
+#define HAVE_INIT_PRIORITY 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define if the system-provided CRTs are present on Solaris. */
+/* #undef HAVE_SOLARIS_CRTS */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "GNU C Runtime Library"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "GNU C Runtime Library 1.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libgcc"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.0"
+
+/* The size of `double', as computed by sizeof. */
+#define SIZEOF_DOUBLE 8
+
+/* The size of `long double', as computed by sizeof. */
+#define SIZEOF_LONG_DOUBLE 16
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if the target use emutls for thread-local storage. */
+/* #undef USE_EMUTLS */
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
diff --git a/libgcov/include/config/gcov-iov.h b/libgcov/include/config/gcov-iov.h
new file mode 100644
index 0000000..4f4f2f5
--- /dev/null
+++ b/libgcov/include/config/gcov-iov.h
@@ -0,0 +1,4 @@
+/* Generated automatically by the program `build/gcov-iov'
+   from `7.5.0 (7 5) and  (*)'.  */
+
+#define GCOV_VERSION ((gcov_unsigned_t)0x4137352a)  /* A75* */
diff --git a/libgcov/include/config/libgcc_tm.h b/libgcov/include/config/libgcc_tm.h
new file mode 100644
index 0000000..491425c
--- /dev/null
+++ b/libgcov/include/config/libgcc_tm.h
@@ -0,0 +1,6 @@
+#ifndef LIBGCC_TM_H
+#define LIBGCC_TM_H
+/* Automatically generated by mkheader.sh.  */
+#include "elf-lib.h"
+#include "value-unwind.h"
+#endif /* LIBGCC_TM_H */
diff --git a/libgcov/include/config/tconfig.h b/libgcov/include/config/tconfig.h
new file mode 100644
index 0000000..7ec80a1
--- /dev/null
+++ b/libgcov/include/config/tconfig.h
@@ -0,0 +1,10 @@
+#ifndef GCC_TCONFIG_H
+#define GCC_TCONFIG_H
+#ifndef USED_FOR_TARGET
+# define USED_FOR_TARGET
+#endif
+#include "auto-host.h"
+#ifdef IN_GCC
+# include "ansidecl.h"
+#endif
+#endif /* GCC_TCONFIG_H */
diff --git a/libgcov/include/config/tm.h b/libgcov/include/config/tm.h
new file mode 100644
index 0000000..611fa76
--- /dev/null
+++ b/libgcov/include/config/tm.h
@@ -0,0 +1,52 @@
+#ifndef GCC_TM_H
+#define GCC_TM_H
+#ifndef LIBC_GLIBC
+# define LIBC_GLIBC 1
+#endif
+#ifndef LIBC_UCLIBC
+# define LIBC_UCLIBC 2
+#endif
+#ifndef LIBC_BIONIC
+# define LIBC_BIONIC 3
+#endif
+#ifndef LIBC_MUSL
+# define LIBC_MUSL 4
+#endif
+#ifndef DEFAULT_LIBC
+# define DEFAULT_LIBC LIBC_GLIBC
+#endif
+#ifndef ANDROID_DEFAULT
+# define ANDROID_DEFAULT 0
+#endif
+#ifdef IN_GCC
+# include "options.h"
+# include "insn-constants.h"
+# include "config/vxworks-dummy.h"
+# include "config/i386/biarch64.h"
+# include "config/i386/i386.h"
+# include "config/i386/unix.h"
+# include "config/i386/att.h"
+# include "config/dbxelf.h"
+# include "config/elfos.h"
+# include "config/gnu-user.h"
+# include "config/glibc-stdint.h"
+# include "config/i386/x86-64.h"
+# include "config/i386/gnu-user-common.h"
+# include "config/i386/gnu-user64.h"
+# include "config/linux.h"
+# include "config/linux-android.h"
+# include "config/i386/linux-common.h"
+# include "config/i386/linux64.h"
+# include "config/initfini-array.h"
+#endif
+#if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET
+# include "insn-flags.h"
+#endif
+#if defined IN_GCC && !defined GENERATOR_FILE
+# include "insn-modes.h"
+#endif
+#if defined IN_GCC && defined GENERATOR_FILE && !defined BITS_PER_UNIT
+#include "machmode.h"
+#endif
+# include "defaults.h"
+#endif /* GCC_TM_H */
diff --git a/libgcov/include/coretypes.h b/libgcov/include/coretypes.h
new file mode 100644
index 0000000..8eb33cc
--- /dev/null
+++ b/libgcov/include/coretypes.h
@@ -0,0 +1,376 @@
+/* GCC core type declarations.
+   Copyright (C) 2002-2017 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* Provide forward declarations of core types which are referred to by
+   most of the compiler.  This allows header files to use these types
+   (e.g. in function prototypes) without concern for whether the full
+   definitions are visible.  Some other declarations that need to be
+   universally visible are here, too.
+
+   In the context of tconfig.h, most of these have special definitions
+   which prevent them from being used except in further type
+   declarations.  This is a kludge; the right thing is to avoid
+   including the "tm.h" header set in the context of tconfig.h, but
+   we're not there yet.  */
+
+#ifndef GCC_CORETYPES_H
+#define GCC_CORETYPES_H
+
+#ifndef GTY
+#define GTY(x)  /* nothing - marker for gengtype */
+#endif
+
+#ifndef USED_FOR_TARGET
+
+typedef int64_t gcov_type;
+typedef uint64_t gcov_type_unsigned;
+
+struct bitmap_head;
+typedef struct bitmap_head *bitmap;
+typedef const struct bitmap_head *const_bitmap;
+struct simple_bitmap_def;
+typedef struct simple_bitmap_def *sbitmap;
+typedef const struct simple_bitmap_def *const_sbitmap;
+struct rtx_def;
+typedef struct rtx_def *rtx;
+typedef const struct rtx_def *const_rtx;
+
+/* Subclasses of rtx_def, using indentation to show the class
+   hierarchy, along with the relevant invariant.
+   Where possible, keep this list in the same order as in rtl.def.  */
+class rtx_def;
+  class rtx_expr_list;           /* GET_CODE (X) == EXPR_LIST */
+  class rtx_insn_list;           /* GET_CODE (X) == INSN_LIST */
+  class rtx_sequence;            /* GET_CODE (X) == SEQUENCE */
+  class rtx_insn;
+    class rtx_debug_insn;      /* DEBUG_INSN_P (X) */
+    class rtx_nonjump_insn;    /* NONJUMP_INSN_P (X) */
+    class rtx_jump_insn;       /* JUMP_P (X) */
+    class rtx_call_insn;       /* CALL_P (X) */
+    class rtx_jump_table_data; /* JUMP_TABLE_DATA_P (X) */
+    class rtx_barrier;         /* BARRIER_P (X) */
+    class rtx_code_label;      /* LABEL_P (X) */
+    class rtx_note;            /* NOTE_P (X) */
+
+struct rtvec_def;
+typedef struct rtvec_def *rtvec;
+typedef const struct rtvec_def *const_rtvec;
+struct hwivec_def;
+typedef struct hwivec_def *hwivec;
+typedef const struct hwivec_def *const_hwivec;
+union tree_node;
+typedef union tree_node *tree;
+typedef const union tree_node *const_tree;
+struct gimple;
+typedef gimple *gimple_seq;
+struct gimple_stmt_iterator;
+
+/* Forward decls for leaf gimple subclasses (for individual gimple codes).
+   Keep this in the same order as the corresponding codes in gimple.def.  */
+
+struct gcond;
+struct gdebug;
+struct ggoto;
+struct glabel;
+struct gswitch;
+struct gassign;
+struct gasm;
+struct gcall;
+struct gtransaction;
+struct greturn;
+struct gbind;
+struct gcatch;
+struct geh_filter;
+struct geh_mnt;
+struct geh_else;
+struct gresx;
+struct geh_dispatch;
+struct gphi;
+struct gtry;
+struct gomp_atomic_load;
+struct gomp_atomic_store;
+struct gomp_continue;
+struct gomp_critical;
+struct gomp_ordered;
+struct gomp_for;
+struct gomp_parallel;
+struct gomp_task;
+struct gomp_sections;
+struct gomp_single;
+struct gomp_target;
+struct gomp_teams;
+
+union section;
+typedef union section section;
+struct gcc_options;
+struct cl_target_option;
+struct cl_optimization;
+struct cl_option;
+struct cl_decoded_option;
+struct cl_option_handlers;
+struct diagnostic_context;
+struct pretty_printer;
+
+/* Address space number for named address space support.  */
+typedef unsigned char addr_space_t;
+
+/* The value of addr_space_t that represents the generic address space.  */
+#define ADDR_SPACE_GENERIC 0
+#define ADDR_SPACE_GENERIC_P(AS) ((AS) == ADDR_SPACE_GENERIC)
+
+/* The major intermediate representations of GCC.  */
+enum ir_type {
+  IR_GIMPLE,
+  IR_RTL_CFGRTL,
+  IR_RTL_CFGLAYOUT
+};
+
+/* Provide forward struct declaration so that we don't have to include
+   all of cpplib.h whenever a random prototype includes a pointer.
+   Note that the cpp_reader and cpp_token typedefs remain part of
+   cpplib.h.  */
+
+struct cpp_reader;
+struct cpp_token;
+
+/* The thread-local storage model associated with a given VAR_DECL
+   or SYMBOL_REF.  This isn't used much, but both trees and RTL refer
+   to it, so it's here.  */
+enum tls_model {
+  TLS_MODEL_NONE,
+  TLS_MODEL_EMULATED,
+  TLS_MODEL_REAL,
+  TLS_MODEL_GLOBAL_DYNAMIC = TLS_MODEL_REAL,
+  TLS_MODEL_LOCAL_DYNAMIC,
+  TLS_MODEL_INITIAL_EXEC,
+  TLS_MODEL_LOCAL_EXEC
+};
+
+/* Types of ABI for an offload compiler.  */
+enum offload_abi {
+  OFFLOAD_ABI_UNSET,
+  OFFLOAD_ABI_LP64,
+  OFFLOAD_ABI_ILP32
+};
+
+/* Types of profile update methods.  */
+enum profile_update {
+  PROFILE_UPDATE_SINGLE,
+  PROFILE_UPDATE_ATOMIC,
+  PROFILE_UPDATE_PREFER_ATOMIC
+};
+
+/* Types of unwind/exception handling info that can be generated.  */
+
+enum unwind_info_type
+{
+  UI_NONE,
+  UI_SJLJ,
+  UI_DWARF2,
+  UI_TARGET,
+  UI_SEH
+};
+
+/* Callgraph node profile representation.  */
+enum node_frequency {
+  /* This function most likely won't be executed at all.
+     (set only when profile feedback is available or via function attribute). */
+  NODE_FREQUENCY_UNLIKELY_EXECUTED,
+  /* For functions that are known to be executed once (i.e. constructors, destructors
+     and main function.  */
+  NODE_FREQUENCY_EXECUTED_ONCE,
+  /* The default value.  */
+  NODE_FREQUENCY_NORMAL,
+  /* Optimize this function hard
+     (set only when profile feedback is available or via function attribute). */
+  NODE_FREQUENCY_HOT
+};
+
+/* Ways of optimizing code.  */
+enum optimization_type {
+  /* Prioritize speed over size.  */
+  OPTIMIZE_FOR_SPEED,
+
+  /* Only do things that are good for both size and speed.  */
+  OPTIMIZE_FOR_BOTH,
+
+  /* Prioritize size over speed.  */
+  OPTIMIZE_FOR_SIZE
+};
+
+/* Possible initialization status of a variable.   When requested
+   by the user, this information is tracked and recorded in the DWARF
+   debug information, along with the variable's location.  */
+enum var_init_status
+{
+  VAR_INIT_STATUS_UNKNOWN,
+  VAR_INIT_STATUS_UNINITIALIZED,
+  VAR_INIT_STATUS_INITIALIZED
+};
+
+/* Names for the different levels of -Wstrict-overflow=N.  The numeric
+   values here correspond to N.  */
+enum warn_strict_overflow_code
+{
+  /* Overflow warning that should be issued with -Wall: a questionable
+     construct that is easy to avoid even when using macros.  Example:
+     folding (x + CONSTANT > x) to 1.  */
+  WARN_STRICT_OVERFLOW_ALL = 1,
+  /* Overflow warning about folding a comparison to a constant because
+     of undefined signed overflow, other than cases covered by
+     WARN_STRICT_OVERFLOW_ALL.  Example: folding (abs (x) >= 0) to 1
+     (this is false when x == INT_MIN).  */
+  WARN_STRICT_OVERFLOW_CONDITIONAL = 2,
+  /* Overflow warning about changes to comparisons other than folding
+     them to a constant.  Example: folding (x + 1 > 1) to (x > 0).  */
+  WARN_STRICT_OVERFLOW_COMPARISON = 3,
+  /* Overflow warnings not covered by the above cases.  Example:
+     folding ((x * 10) / 5) to (x * 2).  */
+  WARN_STRICT_OVERFLOW_MISC = 4,
+  /* Overflow warnings about reducing magnitude of constants in
+     comparison.  Example: folding (x + 2 > y) to (x + 1 >= y).  */
+  WARN_STRICT_OVERFLOW_MAGNITUDE = 5
+};
+
+/* The type of an alias set.  Code currently assumes that variables of
+   this type can take the values 0 (the alias set which aliases
+   everything) and -1 (sometimes indicating that the alias set is
+   unknown, sometimes indicating a memory barrier) and -2 (indicating
+   that the alias set should be set to a unique value but has not been
+   set yet).  */
+typedef int alias_set_type;
+
+struct edge_def;
+typedef struct edge_def *edge;
+typedef const struct edge_def *const_edge;
+struct basic_block_def;
+typedef struct basic_block_def *basic_block;
+typedef const struct basic_block_def *const_basic_block;
+
+#if !defined (GENERATOR_FILE)
+# define OBSTACK_CHUNK_SIZE     memory_block_pool::block_size
+# define obstack_chunk_alloc    mempool_obstack_chunk_alloc
+# define obstack_chunk_free     mempool_obstack_chunk_free
+#else
+# define OBSTACK_CHUNK_SIZE     0
+# define obstack_chunk_alloc    xmalloc
+# define obstack_chunk_free     free
+#endif
+
+#define gcc_obstack_init(OBSTACK)				\
+  obstack_specify_allocation ((OBSTACK), OBSTACK_CHUNK_SIZE, 0,	\
+			      obstack_chunk_alloc,		\
+			      obstack_chunk_free)
+
+/* enum reg_class is target specific, so it should not appear in
+   target-independent code or interfaces, like the target hook declarations
+   in target.h.  */
+typedef int reg_class_t;
+
+class rtl_opt_pass;
+
+namespace gcc {
+  class context;
+}
+
+typedef std::pair <tree, tree> tree_pair;
+
+#else
+
+struct _dont_use_rtx_here_;
+struct _dont_use_rtvec_here_;
+struct _dont_use_rtx_insn_here_;
+union _dont_use_tree_here_;
+#define rtx struct _dont_use_rtx_here_ *
+#define const_rtx struct _dont_use_rtx_here_ *
+#define rtvec struct _dont_use_rtvec_here *
+#define const_rtvec struct _dont_use_rtvec_here *
+#define rtx_insn struct _dont_use_rtx_insn_here_
+#define tree union _dont_use_tree_here_ *
+#define const_tree union _dont_use_tree_here_ *
+
+#endif
+
+/* Classes of functions that compiler needs to check
+   whether they are present at the runtime or not.  */
+enum function_class {
+  function_c94,
+  function_c99_misc,
+  function_c99_math_complex,
+  function_sincos,
+  function_c11_misc
+};
+
+/* Enumerate visibility settings.  This is deliberately ordered from most
+   to least visibility.  */
+enum symbol_visibility
+{
+  VISIBILITY_DEFAULT,
+  VISIBILITY_PROTECTED,
+  VISIBILITY_HIDDEN,
+  VISIBILITY_INTERNAL
+};
+
+/* enums used by the targetm.excess_precision hook.  */
+
+enum flt_eval_method
+{
+  FLT_EVAL_METHOD_UNPREDICTABLE = -1,
+  FLT_EVAL_METHOD_PROMOTE_TO_FLOAT = 0,
+  FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE = 1,
+  FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE = 2,
+  FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 = 16
+};
+
+enum excess_precision_type
+{
+  EXCESS_PRECISION_TYPE_IMPLICIT,
+  EXCESS_PRECISION_TYPE_STANDARD,
+  EXCESS_PRECISION_TYPE_FAST
+};
+
+/* Support for user-provided GGC and PCH markers.  The first parameter
+   is a pointer to a pointer, the second a cookie.  */
+typedef void (*gt_pointer_operator) (void *, void *);
+
+#if !defined (HAVE_UCHAR)
+typedef unsigned char uchar;
+#endif
+
+/* Most host source files will require the following headers.  */
+#if !defined (GENERATOR_FILE) && !defined (USED_FOR_TARGET)
+#include "machmode.h"
+#include "signop.h"
+#include "wide-int.h" 
+#include "double-int.h"
+#include "real.h"
+#include "fixed-value.h"
+#include "hash-table.h"
+#include "hash-set.h"
+#include "input.h"
+#include "is-a.h"
+#include "memory-block.h"
+#endif /* GENERATOR_FILE && !USED_FOR_TARGET */
+
+#endif /* coretypes.h */
diff --git a/libgcov/include/defaults.h b/libgcov/include/defaults.h
new file mode 100644
index 0000000..7ad92d9
--- /dev/null
+++ b/libgcov/include/defaults.h
@@ -0,0 +1,1478 @@
+/* Definitions of various defaults for tm.h macros.
+   Copyright (C) 1992-2017 Free Software Foundation, Inc.
+   Contributed by Ron Guilmette (rfg@monkeys.com)
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_DEFAULTS_H
+#define GCC_DEFAULTS_H
+
+/* How to start an assembler comment.  */
+#ifndef ASM_COMMENT_START
+#define ASM_COMMENT_START ";#"
+#endif
+
+/* Store in OUTPUT a string (made with alloca) containing an
+   assembler-name for a local static variable or function named NAME.
+   LABELNO is an integer which is different for each call.  */
+
+#ifndef ASM_PN_FORMAT
+# ifndef NO_DOT_IN_LABEL
+#  define ASM_PN_FORMAT "%s.%lu"
+# else
+#  ifndef NO_DOLLAR_IN_LABEL
+#   define ASM_PN_FORMAT "%s$%lu"
+#  else
+#   define ASM_PN_FORMAT "__%s_%lu"
+#  endif
+# endif
+#endif /* ! ASM_PN_FORMAT */
+
+#ifndef ASM_FORMAT_PRIVATE_NAME
+# define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
+  do { const char *const name_ = (NAME); \
+       char *const output_ = (OUTPUT) = \
+	 (char *) alloca (strlen (name_) + 32); \
+       sprintf (output_, ASM_PN_FORMAT, name_, (unsigned long)(LABELNO)); \
+  } while (0)
+#endif
+
+/* Choose a reasonable default for ASM_OUTPUT_ASCII.  */
+
+#ifndef ASM_OUTPUT_ASCII
+#define ASM_OUTPUT_ASCII(MYFILE, MYSTRING, MYLENGTH) \
+  do {									      \
+    FILE *_hide_asm_out_file = (MYFILE);				      \
+    const unsigned char *_hide_p = (const unsigned char *) (MYSTRING);	      \
+    int _hide_thissize = (MYLENGTH);					      \
+    {									      \
+      FILE *asm_out_file = _hide_asm_out_file;				      \
+      const unsigned char *p = _hide_p;					      \
+      int thissize = _hide_thissize;					      \
+      int i;								      \
+      fprintf (asm_out_file, "\t.ascii \"");				      \
+									      \
+      for (i = 0; i < thissize; i++)					      \
+	{								      \
+	  int c = p[i];			   				      \
+	  if (c == '\"' || c == '\\')					      \
+	    putc ('\\', asm_out_file);					      \
+	  if (ISPRINT (c))						      \
+	    putc (c, asm_out_file);					      \
+	  else								      \
+	    {								      \
+	      fprintf (asm_out_file, "\\%o", c);			      \
+	      /* After an octal-escape, if a digit follows,		      \
+		 terminate one string constant and start another.	      \
+		 The VAX assembler fails to stop reading the escape	      \
+		 after three digits, so this is the only way we		      \
+		 can get it to parse the data properly.  */		      \
+	      if (i < thissize - 1 && ISDIGIT (p[i + 1]))		      \
+		fprintf (asm_out_file, "\"\n\t.ascii \"");		      \
+	  }								      \
+	}								      \
+      fprintf (asm_out_file, "\"\n");					      \
+    }									      \
+  }									      \
+  while (0)
+#endif
+
+/* This is how we tell the assembler to equate two values.  */
+#ifdef SET_ASM_OP
+#ifndef ASM_OUTPUT_DEF
+#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)				\
+ do {	fprintf ((FILE), "%s", SET_ASM_OP);				\
+	assemble_name (FILE, LABEL1);					\
+	fprintf (FILE, ",");						\
+	assemble_name (FILE, LABEL2);					\
+	fprintf (FILE, "\n");						\
+  } while (0)
+#endif
+#endif
+
+#ifndef IFUNC_ASM_TYPE
+#define IFUNC_ASM_TYPE "gnu_indirect_function"
+#endif
+
+#ifndef TLS_COMMON_ASM_OP
+#define TLS_COMMON_ASM_OP ".tls_common"
+#endif
+
+#if defined (HAVE_AS_TLS) && !defined (ASM_OUTPUT_TLS_COMMON)
+#define ASM_OUTPUT_TLS_COMMON(FILE, DECL, NAME, SIZE)			\
+  do									\
+    {									\
+      fprintf ((FILE), "\t%s\t", TLS_COMMON_ASM_OP);			\
+      assemble_name ((FILE), (NAME));					\
+      fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",		\
+	       (SIZE), DECL_ALIGN (DECL) / BITS_PER_UNIT);		\
+    }									\
+  while (0)
+#endif
+
+/* Decide whether to defer emitting the assembler output for an equate
+   of two values.  The default is to not defer output.  */
+#ifndef TARGET_DEFERRED_OUTPUT_DEFS
+#define TARGET_DEFERRED_OUTPUT_DEFS(DECL,TARGET) false
+#endif
+
+/* This is how to output the definition of a user-level label named
+   NAME, such as the label on variable NAME.  */
+
+#ifndef ASM_OUTPUT_LABEL
+#define ASM_OUTPUT_LABEL(FILE,NAME) \
+  do {						\
+    assemble_name ((FILE), (NAME));		\
+    fputs (":\n", (FILE));			\
+  } while (0)
+#endif
+
+/* This is how to output the definition of a user-level label named
+   NAME, such as the label on a function.  */
+
+#ifndef ASM_OUTPUT_FUNCTION_LABEL
+#define ASM_OUTPUT_FUNCTION_LABEL(FILE, NAME, DECL) \
+  ASM_OUTPUT_LABEL ((FILE), (NAME))
+#endif
+
+/* Output the definition of a compiler-generated label named NAME.  */
+#ifndef ASM_OUTPUT_INTERNAL_LABEL
+#define ASM_OUTPUT_INTERNAL_LABEL(FILE,NAME)	\
+  do {						\
+    assemble_name_raw ((FILE), (NAME));		\
+    fputs (":\n", (FILE));			\
+  } while (0)
+#endif
+
+/* This is how to output a reference to a user-level label named NAME.  */
+
+#ifndef ASM_OUTPUT_LABELREF
+#define ASM_OUTPUT_LABELREF(FILE,NAME)  \
+  do {							\
+    fputs (user_label_prefix, (FILE));			\
+    fputs ((NAME), (FILE));				\
+  } while (0);
+#endif
+
+/* Allow target to print debug info labels specially.  This is useful for
+   VLIW targets, since debug info labels should go into the middle of
+   instruction bundles instead of breaking them.  */
+
+#ifndef ASM_OUTPUT_DEBUG_LABEL
+#define ASM_OUTPUT_DEBUG_LABEL(FILE, PREFIX, NUM) \
+  (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM)
+#endif
+
+/* This is how we tell the assembler that a symbol is weak.  */
+#ifndef ASM_OUTPUT_WEAK_ALIAS
+#if defined (ASM_WEAKEN_LABEL) && defined (ASM_OUTPUT_DEF)
+#define ASM_OUTPUT_WEAK_ALIAS(STREAM, NAME, VALUE)	\
+  do							\
+    {							\
+      ASM_WEAKEN_LABEL (STREAM, NAME);			\
+      if (VALUE)					\
+        ASM_OUTPUT_DEF (STREAM, NAME, VALUE);		\
+    }							\
+  while (0)
+#endif
+#endif
+
+/* This is how we tell the assembler that a symbol is a weak alias to
+   another symbol that doesn't require the other symbol to be defined.
+   Uses of the former will turn into weak uses of the latter, i.e.,
+   uses that, in case the latter is undefined, will not cause errors,
+   and will add it to the symbol table as weak undefined.  However, if
+   the latter is referenced directly, a strong reference prevails.  */
+#ifndef ASM_OUTPUT_WEAKREF
+#if defined HAVE_GAS_WEAKREF
+#define ASM_OUTPUT_WEAKREF(FILE, DECL, NAME, VALUE)			\
+  do									\
+    {									\
+      fprintf ((FILE), "\t.weakref\t");					\
+      assemble_name ((FILE), (NAME));					\
+      fprintf ((FILE), ",");						\
+      assemble_name ((FILE), (VALUE));					\
+      fprintf ((FILE), "\n");						\
+    }									\
+  while (0)
+#endif
+#endif
+
+/* How to emit a .type directive.  */
+#ifndef ASM_OUTPUT_TYPE_DIRECTIVE
+#if defined TYPE_ASM_OP && defined TYPE_OPERAND_FMT
+#define ASM_OUTPUT_TYPE_DIRECTIVE(STREAM, NAME, TYPE)	\
+  do							\
+    {							\
+      fputs (TYPE_ASM_OP, STREAM);			\
+      assemble_name (STREAM, NAME);			\
+      fputs (", ", STREAM);				\
+      fprintf (STREAM, TYPE_OPERAND_FMT, TYPE);		\
+      putc ('\n', STREAM);				\
+    }							\
+  while (0)
+#endif
+#endif
+
+/* How to emit a .size directive.  */
+#ifndef ASM_OUTPUT_SIZE_DIRECTIVE
+#ifdef SIZE_ASM_OP
+#define ASM_OUTPUT_SIZE_DIRECTIVE(STREAM, NAME, SIZE)	\
+  do							\
+    {							\
+      HOST_WIDE_INT size_ = (SIZE);			\
+      fputs (SIZE_ASM_OP, STREAM);			\
+      assemble_name (STREAM, NAME);			\
+      fprintf (STREAM, ", " HOST_WIDE_INT_PRINT_DEC "\n", size_); \
+    }							\
+  while (0)
+
+#define ASM_OUTPUT_MEASURED_SIZE(STREAM, NAME)		\
+  do							\
+    {							\
+      fputs (SIZE_ASM_OP, STREAM);			\
+      assemble_name (STREAM, NAME);			\
+      fputs (", .-", STREAM);				\
+      assemble_name (STREAM, NAME);			\
+      putc ('\n', STREAM);				\
+    }							\
+  while (0)
+
+#endif
+#endif
+
+/* This determines whether or not we support weak symbols.  SUPPORTS_WEAK
+   must be a preprocessor constant.  */
+#ifndef SUPPORTS_WEAK
+#if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
+#define SUPPORTS_WEAK 1
+#else
+#define SUPPORTS_WEAK 0
+#endif
+#endif
+
+/* This determines whether or not we support weak symbols during target
+   code generation.  TARGET_SUPPORTS_WEAK can be any valid C expression.  */
+#ifndef TARGET_SUPPORTS_WEAK
+#define TARGET_SUPPORTS_WEAK (SUPPORTS_WEAK)
+#endif
+
+/* This determines whether or not we support the discriminator
+   attribute in the .loc directive.  */
+#ifndef SUPPORTS_DISCRIMINATOR
+#ifdef HAVE_GAS_DISCRIMINATOR
+#define SUPPORTS_DISCRIMINATOR 1
+#else
+#define SUPPORTS_DISCRIMINATOR 0
+#endif
+#endif
+
+/* This determines whether or not we support link-once semantics.  */
+#ifndef SUPPORTS_ONE_ONLY
+#ifdef MAKE_DECL_ONE_ONLY
+#define SUPPORTS_ONE_ONLY 1
+#else
+#define SUPPORTS_ONE_ONLY 0
+#endif
+#endif
+
+/* This determines whether weak symbols must be left out of a static
+   archive's table of contents.  Defining this macro to be nonzero has
+   the consequence that certain symbols will not be made weak that
+   otherwise would be.  The C++ ABI requires this macro to be zero;
+   see the documentation.  */
+#ifndef TARGET_WEAK_NOT_IN_ARCHIVE_TOC
+#define TARGET_WEAK_NOT_IN_ARCHIVE_TOC 0
+#endif
+
+/* This determines whether or not we need linkonce unwind information.  */
+#ifndef TARGET_USES_WEAK_UNWIND_INFO
+#define TARGET_USES_WEAK_UNWIND_INFO 0
+#endif
+
+/* By default, there is no prefix on user-defined symbols.  */
+#ifndef USER_LABEL_PREFIX
+#define USER_LABEL_PREFIX ""
+#endif
+
+/* If the target supports weak symbols, define TARGET_ATTRIBUTE_WEAK to
+   provide a weak attribute.  Else define it to nothing.
+
+   This would normally belong in ansidecl.h, but SUPPORTS_WEAK is
+   not available at that time.
+
+   Note, this is only for use by target files which we know are to be
+   compiled by GCC.  */
+#ifndef TARGET_ATTRIBUTE_WEAK
+# if SUPPORTS_WEAK
+#  define TARGET_ATTRIBUTE_WEAK __attribute__ ((weak))
+# else
+#  define TARGET_ATTRIBUTE_WEAK
+# endif
+#endif
+
+/* By default we can assume that all global symbols are in one namespace,
+   across all shared libraries.  */
+#ifndef MULTIPLE_SYMBOL_SPACES
+# define MULTIPLE_SYMBOL_SPACES 0
+#endif
+
+/* If the target supports init_priority C++ attribute, give
+   SUPPORTS_INIT_PRIORITY a nonzero value.  */
+#ifndef SUPPORTS_INIT_PRIORITY
+#define SUPPORTS_INIT_PRIORITY 1
+#endif /* SUPPORTS_INIT_PRIORITY */
+
+/* If we have a definition of INCOMING_RETURN_ADDR_RTX, assume that
+   the rest of the DWARF 2 frame unwind support is also provided.  */
+#if !defined (DWARF2_UNWIND_INFO) && defined (INCOMING_RETURN_ADDR_RTX)
+#define DWARF2_UNWIND_INFO 1
+#endif
+
+/* If we have named sections, and we're using crtstuff to run ctors,
+   use them for registering eh frame information.  */
+#if defined (TARGET_ASM_NAMED_SECTION) && DWARF2_UNWIND_INFO \
+    && !defined (EH_FRAME_THROUGH_COLLECT2)
+#ifndef EH_FRAME_SECTION_NAME
+#define EH_FRAME_SECTION_NAME ".eh_frame"
+#endif
+#endif
+
+/* On many systems, different EH table encodings are used under
+   difference circumstances.  Some will require runtime relocations;
+   some will not.  For those that do not require runtime relocations,
+   we would like to make the table read-only.  However, since the
+   read-only tables may need to be combined with read-write tables
+   that do require runtime relocation, it is not safe to make the
+   tables read-only unless the linker will merge read-only and
+   read-write sections into a single read-write section.  If your
+   linker does not have this ability, but your system is such that no
+   encoding used with non-PIC code will ever require a runtime
+   relocation, then you can define EH_TABLES_CAN_BE_READ_ONLY to 1 in
+   your target configuration file.  */
+#ifndef EH_TABLES_CAN_BE_READ_ONLY
+#ifdef HAVE_LD_RO_RW_SECTION_MIXING
+#define EH_TABLES_CAN_BE_READ_ONLY 1
+#else
+#define EH_TABLES_CAN_BE_READ_ONLY 0
+#endif
+#endif
+
+/* Provide defaults for stuff that may not be defined when using
+   sjlj exceptions.  */
+#ifndef EH_RETURN_DATA_REGNO
+#define EH_RETURN_DATA_REGNO(N) INVALID_REGNUM
+#endif
+
+/* Offset between the eh handler address and entry in eh tables.  */
+#ifndef RETURN_ADDR_OFFSET
+#define RETURN_ADDR_OFFSET 0
+#endif
+
+#ifndef MASK_RETURN_ADDR
+#define MASK_RETURN_ADDR NULL_RTX
+#endif
+
+/* Number of hardware registers that go into the DWARF-2 unwind info.
+   If not defined, equals FIRST_PSEUDO_REGISTER  */
+
+#ifndef DWARF_FRAME_REGISTERS
+#define DWARF_FRAME_REGISTERS FIRST_PSEUDO_REGISTER
+#endif
+
+/* Offsets recorded in opcodes are a multiple of this alignment factor.  */
+#ifndef DWARF_CIE_DATA_ALIGNMENT
+#ifdef STACK_GROWS_DOWNWARD
+#define DWARF_CIE_DATA_ALIGNMENT (-((int) UNITS_PER_WORD))
+#else
+#define DWARF_CIE_DATA_ALIGNMENT ((int) UNITS_PER_WORD)
+#endif
+#endif
+
+/* The DWARF 2 CFA column which tracks the return address.  Normally this
+   is the column for PC, or the first column after all of the hard
+   registers.  */
+#ifndef DWARF_FRAME_RETURN_COLUMN
+#ifdef PC_REGNUM
+#define DWARF_FRAME_RETURN_COLUMN	DWARF_FRAME_REGNUM (PC_REGNUM)
+#else
+#define DWARF_FRAME_RETURN_COLUMN	DWARF_FRAME_REGISTERS
+#endif
+#endif
+
+/* How to renumber registers for dbx and gdb.  If not defined, assume
+   no renumbering is necessary.  */
+
+#ifndef DBX_REGISTER_NUMBER
+#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
+#endif
+
+/* The mapping from gcc register number to DWARF 2 CFA column number.
+   By default, we just provide columns for all registers.  */
+#ifndef DWARF_FRAME_REGNUM
+#define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
+#endif
+
+/* The mapping from dwarf CFA reg number to internal dwarf reg numbers.  */
+#ifndef DWARF_REG_TO_UNWIND_COLUMN
+#define DWARF_REG_TO_UNWIND_COLUMN(REGNO) (REGNO)
+#endif
+
+/* Map register numbers held in the call frame info that gcc has
+   collected using DWARF_FRAME_REGNUM to those that should be output in
+   .debug_frame and .eh_frame.  */
+#ifndef DWARF2_FRAME_REG_OUT
+#define DWARF2_FRAME_REG_OUT(REGNO, FOR_EH) (REGNO)
+#endif
+
+/* The size of addresses as they appear in the Dwarf 2 data.
+   Some architectures use word addresses to refer to code locations,
+   but Dwarf 2 info always uses byte addresses.  On such machines,
+   Dwarf 2 addresses need to be larger than the architecture's
+   pointers.  */
+#ifndef DWARF2_ADDR_SIZE
+#define DWARF2_ADDR_SIZE ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT)
+#endif
+
+/* The size in bytes of a DWARF field indicating an offset or length
+   relative to a debug info section, specified to be 4 bytes in the
+   DWARF-2 specification.  The SGI/MIPS ABI defines it to be the same
+   as PTR_SIZE.  */
+#ifndef DWARF_OFFSET_SIZE
+#define DWARF_OFFSET_SIZE 4
+#endif
+
+/* The size in bytes of a DWARF 4 type signature.  */
+#ifndef DWARF_TYPE_SIGNATURE_SIZE
+#define DWARF_TYPE_SIGNATURE_SIZE 8
+#endif
+
+/* Default sizes for base C types.  If the sizes are different for
+   your target, you should override these values by defining the
+   appropriate symbols in your tm.h file.  */
+
+#ifndef BITS_PER_WORD
+#define BITS_PER_WORD (BITS_PER_UNIT * UNITS_PER_WORD)
+#endif
+
+#ifndef CHAR_TYPE_SIZE
+#define CHAR_TYPE_SIZE BITS_PER_UNIT
+#endif
+
+#ifndef BOOL_TYPE_SIZE
+/* `bool' has size and alignment `1', on almost all platforms.  */
+#define BOOL_TYPE_SIZE CHAR_TYPE_SIZE
+#endif
+
+#ifndef SHORT_TYPE_SIZE
+#define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
+#endif
+
+#ifndef INT_TYPE_SIZE
+#define INT_TYPE_SIZE BITS_PER_WORD
+#endif
+
+#ifndef LONG_TYPE_SIZE
+#define LONG_TYPE_SIZE BITS_PER_WORD
+#endif
+
+#ifndef LONG_LONG_TYPE_SIZE
+#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
+#endif
+
+#ifndef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
+#endif
+
+#ifndef FLOAT_TYPE_SIZE
+#define FLOAT_TYPE_SIZE BITS_PER_WORD
+#endif
+
+#ifndef DOUBLE_TYPE_SIZE
+#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
+#endif
+
+#ifndef LONG_DOUBLE_TYPE_SIZE
+#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
+#endif
+
+#ifndef DECIMAL32_TYPE_SIZE
+#define DECIMAL32_TYPE_SIZE 32
+#endif
+
+#ifndef DECIMAL64_TYPE_SIZE
+#define DECIMAL64_TYPE_SIZE 64
+#endif
+
+#ifndef DECIMAL128_TYPE_SIZE
+#define DECIMAL128_TYPE_SIZE 128
+#endif
+
+#ifndef SHORT_FRACT_TYPE_SIZE
+#define SHORT_FRACT_TYPE_SIZE BITS_PER_UNIT
+#endif
+
+#ifndef FRACT_TYPE_SIZE
+#define FRACT_TYPE_SIZE (BITS_PER_UNIT * 2)
+#endif
+
+#ifndef LONG_FRACT_TYPE_SIZE
+#define LONG_FRACT_TYPE_SIZE (BITS_PER_UNIT * 4)
+#endif
+
+#ifndef LONG_LONG_FRACT_TYPE_SIZE
+#define LONG_LONG_FRACT_TYPE_SIZE (BITS_PER_UNIT * 8)
+#endif
+
+#ifndef SHORT_ACCUM_TYPE_SIZE
+#define SHORT_ACCUM_TYPE_SIZE (SHORT_FRACT_TYPE_SIZE * 2)
+#endif
+
+#ifndef ACCUM_TYPE_SIZE
+#define ACCUM_TYPE_SIZE (FRACT_TYPE_SIZE * 2)
+#endif
+
+#ifndef LONG_ACCUM_TYPE_SIZE
+#define LONG_ACCUM_TYPE_SIZE (LONG_FRACT_TYPE_SIZE * 2)
+#endif
+
+#ifndef LONG_LONG_ACCUM_TYPE_SIZE
+#define LONG_LONG_ACCUM_TYPE_SIZE (LONG_LONG_FRACT_TYPE_SIZE * 2)
+#endif
+
+/* We let tm.h override the types used here, to handle trivial differences
+   such as the choice of unsigned int or long unsigned int for size_t.
+   When machines start needing nontrivial differences in the size type,
+   it would be best to do something here to figure out automatically
+   from other information what type to use.  */
+
+#ifndef SIZE_TYPE
+#define SIZE_TYPE "long unsigned int"
+#endif
+
+#ifndef SIZETYPE
+#define SIZETYPE SIZE_TYPE
+#endif
+
+#ifndef PID_TYPE
+#define PID_TYPE "int"
+#endif
+
+/* If GCC knows the exact uint_least16_t and uint_least32_t types from
+   <stdint.h>, use them for char16_t and char32_t.  Otherwise, use
+   these guesses; getting the wrong type of a given width will not
+   affect C++ name mangling because in C++ these are distinct types
+   not typedefs.  */
+
+#ifdef UINT_LEAST16_TYPE
+#define CHAR16_TYPE UINT_LEAST16_TYPE
+#else
+#define CHAR16_TYPE "short unsigned int"
+#endif
+
+#ifdef UINT_LEAST32_TYPE
+#define CHAR32_TYPE UINT_LEAST32_TYPE
+#else
+#define CHAR32_TYPE "unsigned int"
+#endif
+
+#ifndef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+#endif
+
+/* WCHAR_TYPE gets overridden by -fshort-wchar.  */
+#define MODIFIED_WCHAR_TYPE \
+	(flag_short_wchar ? "short unsigned int" : WCHAR_TYPE)
+
+#ifndef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "long int"
+#endif
+
+#ifndef WINT_TYPE
+#define WINT_TYPE "unsigned int"
+#endif
+
+#ifndef INTMAX_TYPE
+#define INTMAX_TYPE ((INT_TYPE_SIZE == LONG_LONG_TYPE_SIZE)	\
+		     ? "int"					\
+		     : ((LONG_TYPE_SIZE == LONG_LONG_TYPE_SIZE)	\
+			? "long int"				\
+			: "long long int"))
+#endif
+
+#ifndef UINTMAX_TYPE
+#define UINTMAX_TYPE ((INT_TYPE_SIZE == LONG_LONG_TYPE_SIZE)	\
+		     ? "unsigned int"				\
+		     : ((LONG_TYPE_SIZE == LONG_LONG_TYPE_SIZE)	\
+			? "long unsigned int"			\
+			: "long long unsigned int"))
+#endif
+
+
+/* There are no default definitions of these <stdint.h> types.  */
+
+#ifndef SIG_ATOMIC_TYPE
+#define SIG_ATOMIC_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT8_TYPE
+#define INT8_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT16_TYPE
+#define INT16_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT32_TYPE
+#define INT32_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT64_TYPE
+#define INT64_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT8_TYPE
+#define UINT8_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT16_TYPE
+#define UINT16_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT32_TYPE
+#define UINT32_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT64_TYPE
+#define UINT64_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT_LEAST8_TYPE
+#define INT_LEAST8_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT_LEAST16_TYPE
+#define INT_LEAST16_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT_LEAST32_TYPE
+#define INT_LEAST32_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT_LEAST64_TYPE
+#define INT_LEAST64_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT_LEAST8_TYPE
+#define UINT_LEAST8_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT_LEAST16_TYPE
+#define UINT_LEAST16_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT_LEAST32_TYPE
+#define UINT_LEAST32_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT_LEAST64_TYPE
+#define UINT_LEAST64_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT_FAST8_TYPE
+#define INT_FAST8_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT_FAST16_TYPE
+#define INT_FAST16_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT_FAST32_TYPE
+#define INT_FAST32_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INT_FAST64_TYPE
+#define INT_FAST64_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT_FAST8_TYPE
+#define UINT_FAST8_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT_FAST16_TYPE
+#define UINT_FAST16_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT_FAST32_TYPE
+#define UINT_FAST32_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINT_FAST64_TYPE
+#define UINT_FAST64_TYPE ((const char *) NULL)
+#endif
+
+#ifndef INTPTR_TYPE
+#define INTPTR_TYPE ((const char *) NULL)
+#endif
+
+#ifndef UINTPTR_TYPE
+#define UINTPTR_TYPE ((const char *) NULL)
+#endif
+
+/* Width in bits of a pointer.  Mind the value of the macro `Pmode'.  */
+#ifndef POINTER_SIZE
+#define POINTER_SIZE BITS_PER_WORD
+#endif
+#ifndef POINTER_SIZE_UNITS
+#define POINTER_SIZE_UNITS ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT)
+#endif
+
+
+#ifndef PIC_OFFSET_TABLE_REGNUM
+#define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM
+#endif
+
+#ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
+#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED 0
+#endif
+
+#ifndef TARGET_DLLIMPORT_DECL_ATTRIBUTES
+#define TARGET_DLLIMPORT_DECL_ATTRIBUTES 0
+#endif
+
+#ifndef TARGET_DECLSPEC
+#if TARGET_DLLIMPORT_DECL_ATTRIBUTES
+/* If the target supports the "dllimport" attribute, users are
+   probably used to the "__declspec" syntax.  */
+#define TARGET_DECLSPEC 1
+#else
+#define TARGET_DECLSPEC 0
+#endif
+#endif
+
+/* By default, the preprocessor should be invoked the same way in C++
+   as in C.  */
+#ifndef CPLUSPLUS_CPP_SPEC
+#ifdef CPP_SPEC
+#define CPLUSPLUS_CPP_SPEC CPP_SPEC
+#endif
+#endif
+
+#ifndef ACCUMULATE_OUTGOING_ARGS
+#define ACCUMULATE_OUTGOING_ARGS 0
+#endif
+
+/* By default, use the GNU runtime for Objective C.  */
+#ifndef NEXT_OBJC_RUNTIME
+#define NEXT_OBJC_RUNTIME 0
+#endif
+
+/* Supply a default definition for PUSH_ARGS.  */
+#ifndef PUSH_ARGS
+#ifdef PUSH_ROUNDING
+#define PUSH_ARGS	!ACCUMULATE_OUTGOING_ARGS
+#else
+#define PUSH_ARGS	0
+#endif
+#endif
+
+/* Decide whether a function's arguments should be processed
+   from first to last or from last to first.
+
+   They should if the stack and args grow in opposite directions, but
+   only if we have push insns.  */
+
+#ifdef PUSH_ROUNDING
+
+#ifndef PUSH_ARGS_REVERSED
+#if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
+#define PUSH_ARGS_REVERSED  PUSH_ARGS
+#endif
+#endif
+
+#endif
+
+#ifndef PUSH_ARGS_REVERSED
+#define PUSH_ARGS_REVERSED 0
+#endif
+
+/* Default value for the alignment (in bits) a C conformant malloc has to
+   provide. This default is intended to be safe and always correct.  */
+#ifndef MALLOC_ABI_ALIGNMENT
+#define MALLOC_ABI_ALIGNMENT BITS_PER_WORD
+#endif
+
+/* If PREFERRED_STACK_BOUNDARY is not defined, set it to STACK_BOUNDARY.
+   STACK_BOUNDARY is required.  */
+#ifndef PREFERRED_STACK_BOUNDARY
+#define PREFERRED_STACK_BOUNDARY STACK_BOUNDARY
+#endif
+
+/* Set INCOMING_STACK_BOUNDARY to PREFERRED_STACK_BOUNDARY if it is not
+   defined.  */
+#ifndef INCOMING_STACK_BOUNDARY
+#define INCOMING_STACK_BOUNDARY PREFERRED_STACK_BOUNDARY
+#endif
+
+#ifndef TARGET_DEFAULT_PACK_STRUCT
+#define TARGET_DEFAULT_PACK_STRUCT 0
+#endif
+
+/* By default, the vtable entries are void pointers, the so the alignment
+   is the same as pointer alignment.  The value of this macro specifies
+   the alignment of the vtable entry in bits.  It should be defined only
+   when special alignment is necessary.  */
+#ifndef TARGET_VTABLE_ENTRY_ALIGN
+#define TARGET_VTABLE_ENTRY_ALIGN POINTER_SIZE
+#endif
+
+/* There are a few non-descriptor entries in the vtable at offsets below
+   zero.  If these entries must be padded (say, to preserve the alignment
+   specified by TARGET_VTABLE_ENTRY_ALIGN), set this to the number of
+   words in each data entry.  */
+#ifndef TARGET_VTABLE_DATA_ENTRY_DISTANCE
+#define TARGET_VTABLE_DATA_ENTRY_DISTANCE 1
+#endif
+
+/* Decide whether it is safe to use a local alias for a virtual function
+   when constructing thunks.  */
+#ifndef TARGET_USE_LOCAL_THUNK_ALIAS_P
+#ifdef ASM_OUTPUT_DEF
+#define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) 1
+#else
+#define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) 0
+#endif
+#endif
+
+/* Select a format to encode pointers in exception handling data.  We
+   prefer those that result in fewer dynamic relocations.  Assume no
+   special support here and encode direct references.  */
+#ifndef ASM_PREFERRED_EH_DATA_FORMAT
+#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  DW_EH_PE_absptr
+#endif
+
+/* By default, the C++ compiler will use the lowest bit of the pointer
+   to function to indicate a pointer-to-member-function points to a
+   virtual member function.  However, if FUNCTION_BOUNDARY indicates
+   function addresses aren't always even, the lowest bit of the delta
+   field will be used.  */
+#ifndef TARGET_PTRMEMFUNC_VBIT_LOCATION
+#define TARGET_PTRMEMFUNC_VBIT_LOCATION \
+  (FUNCTION_BOUNDARY >= 2 * BITS_PER_UNIT \
+   ? ptrmemfunc_vbit_in_pfn : ptrmemfunc_vbit_in_delta)
+#endif
+
+#ifndef DEFAULT_GDB_EXTENSIONS
+#define DEFAULT_GDB_EXTENSIONS 1
+#endif
+
+#ifndef SDB_DEBUGGING_INFO
+#define SDB_DEBUGGING_INFO 0
+#endif
+
+/* If more than one debugging type is supported, you must define
+   PREFERRED_DEBUGGING_TYPE to choose the default.  */
+
+#if 1 < (defined (DBX_DEBUGGING_INFO) + (SDB_DEBUGGING_INFO) \
+         + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO) \
+         + defined (VMS_DEBUGGING_INFO))
+#ifndef PREFERRED_DEBUGGING_TYPE
+#error You must define PREFERRED_DEBUGGING_TYPE
+#endif /* no PREFERRED_DEBUGGING_TYPE */
+
+/* If only one debugging format is supported, define PREFERRED_DEBUGGING_TYPE
+   here so other code needn't care.  */
+#elif defined DBX_DEBUGGING_INFO
+#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+
+#elif SDB_DEBUGGING_INFO
+#define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
+
+#elif defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO
+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+
+#elif defined VMS_DEBUGGING_INFO
+#define PREFERRED_DEBUGGING_TYPE VMS_AND_DWARF2_DEBUG
+
+#elif defined XCOFF_DEBUGGING_INFO
+#define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
+
+#else
+/* No debugging format is supported by this target.  */
+#define PREFERRED_DEBUGGING_TYPE NO_DEBUG
+#endif
+
+#ifndef FLOAT_LIB_COMPARE_RETURNS_BOOL
+#define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) false
+#endif
+
+/* True if the targets integer-comparison functions return { 0, 1, 2
+   } to indicate { <, ==, > }.  False if { -1, 0, 1 } is used
+   instead.  The libgcc routines are biased.  */
+#ifndef TARGET_LIB_INT_CMP_BIASED
+#define TARGET_LIB_INT_CMP_BIASED (true)
+#endif
+
+/* If FLOAT_WORDS_BIG_ENDIAN is not defined in the header files,
+   then the word-endianness is the same as for integers.  */
+#ifndef FLOAT_WORDS_BIG_ENDIAN
+#define FLOAT_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
+#endif
+
+#ifndef REG_WORDS_BIG_ENDIAN
+#define REG_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
+#endif
+
+
+#ifndef TARGET_DEC_EVAL_METHOD
+#define TARGET_DEC_EVAL_METHOD 2
+#endif
+
+#ifndef HAS_LONG_COND_BRANCH
+#define HAS_LONG_COND_BRANCH 0
+#endif
+
+#ifndef HAS_LONG_UNCOND_BRANCH
+#define HAS_LONG_UNCOND_BRANCH 0
+#endif
+
+/* Determine whether __cxa_atexit, rather than atexit, is used to
+   register C++ destructors for local statics and global objects.  */
+#ifndef DEFAULT_USE_CXA_ATEXIT
+#define DEFAULT_USE_CXA_ATEXIT 0
+#endif
+
+#if GCC_VERSION >= 3000 && defined IN_GCC
+/* These old constraint macros shouldn't appear anywhere in a
+   configuration using MD constraint definitions.  */
+#endif
+
+/* Determin whether the target runtime library is Bionic */
+#ifndef TARGET_HAS_BIONIC
+#define TARGET_HAS_BIONIC 0
+#endif
+
+/* Indicate that CLZ and CTZ are undefined at zero.  */
+#ifndef CLZ_DEFINED_VALUE_AT_ZERO
+#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
+#endif
+#ifndef CTZ_DEFINED_VALUE_AT_ZERO
+#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
+#endif
+
+/* Provide a default value for STORE_FLAG_VALUE.  */
+#ifndef STORE_FLAG_VALUE
+#define STORE_FLAG_VALUE  1
+#endif
+
+/* This macro is used to determine what the largest unit size that
+   move_by_pieces can use is.  */
+
+/* MOVE_MAX_PIECES is the number of bytes at a time which we can
+   move efficiently, as opposed to  MOVE_MAX which is the maximum
+   number of bytes we can move with a single instruction.  */
+
+#ifndef MOVE_MAX_PIECES
+#define MOVE_MAX_PIECES   MOVE_MAX
+#endif
+
+/* STORE_MAX_PIECES is the number of bytes at a time that we can
+   store efficiently.  Due to internal GCC limitations, this is
+   MOVE_MAX_PIECES limited by the number of bytes GCC can represent
+   for an immediate constant.  */
+
+#ifndef STORE_MAX_PIECES
+#define STORE_MAX_PIECES  MIN (MOVE_MAX_PIECES, 2 * sizeof (HOST_WIDE_INT))
+#endif
+
+/* Likewise for block comparisons.  */
+#ifndef COMPARE_MAX_PIECES
+#define COMPARE_MAX_PIECES  MOVE_MAX_PIECES
+#endif
+
+#ifndef MAX_MOVE_MAX
+#define MAX_MOVE_MAX MOVE_MAX
+#endif
+
+#ifndef MIN_UNITS_PER_WORD
+#define MIN_UNITS_PER_WORD UNITS_PER_WORD
+#endif
+
+#ifndef MAX_BITS_PER_WORD
+#define MAX_BITS_PER_WORD BITS_PER_WORD
+#endif
+
+#ifndef STACK_POINTER_OFFSET
+#define STACK_POINTER_OFFSET    0
+#endif
+
+#ifndef LOCAL_REGNO
+#define LOCAL_REGNO(REGNO)  0
+#endif
+
+#ifndef HONOR_REG_ALLOC_ORDER
+#define HONOR_REG_ALLOC_ORDER 0
+#endif
+
+/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
+   the stack pointer does not matter.  The value is tested only in
+   functions that have frame pointers.  */
+#ifndef EXIT_IGNORE_STACK
+#define EXIT_IGNORE_STACK 0
+#endif
+
+/* Assume that case vectors are not pc-relative.  */
+#ifndef CASE_VECTOR_PC_RELATIVE
+#define CASE_VECTOR_PC_RELATIVE 0
+#endif
+
+/* Force minimum alignment to be able to use the least significant bits
+   for distinguishing descriptor addresses from code addresses.  */
+#define FUNCTION_ALIGNMENT(ALIGN)					\
+  (lang_hooks.custom_function_descriptors				\
+   && targetm.calls.custom_function_descriptors > 0			\
+   ? MAX ((ALIGN),						\
+	  2 * targetm.calls.custom_function_descriptors * BITS_PER_UNIT)\
+   : (ALIGN))
+
+/* Assume that trampolines need function alignment.  */
+#ifndef TRAMPOLINE_ALIGNMENT
+#define TRAMPOLINE_ALIGNMENT FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY)
+#endif
+
+/* Register mappings for target machines without register windows.  */
+#ifndef INCOMING_REGNO
+#define INCOMING_REGNO(N) (N)
+#endif
+
+#ifndef OUTGOING_REGNO
+#define OUTGOING_REGNO(N) (N)
+#endif
+
+#ifndef SHIFT_COUNT_TRUNCATED
+#define SHIFT_COUNT_TRUNCATED 0
+#endif
+
+#ifndef LEGITIMATE_PIC_OPERAND_P
+#define LEGITIMATE_PIC_OPERAND_P(X) 1
+#endif
+
+#ifndef TARGET_MEM_CONSTRAINT
+#define TARGET_MEM_CONSTRAINT 'm'
+#endif
+
+#ifndef REVERSIBLE_CC_MODE
+#define REVERSIBLE_CC_MODE(MODE) 0
+#endif
+
+/* Biggest alignment supported by the object file format of this machine.  */
+#ifndef MAX_OFILE_ALIGNMENT
+#define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
+#endif
+
+#ifndef FRAME_GROWS_DOWNWARD
+#define FRAME_GROWS_DOWNWARD 0
+#endif
+
+#ifndef RETURN_ADDR_IN_PREVIOUS_FRAME
+#define RETURN_ADDR_IN_PREVIOUS_FRAME 0
+#endif
+
+/* On most machines, the CFA coincides with the first incoming parm.  */
+#ifndef ARG_POINTER_CFA_OFFSET
+#define ARG_POINTER_CFA_OFFSET(FNDECL) \
+  (FIRST_PARM_OFFSET (FNDECL) + crtl->args.pretend_args_size)
+#endif
+
+/* On most machines, we use the CFA as DW_AT_frame_base.  */
+#ifndef CFA_FRAME_BASE_OFFSET
+#define CFA_FRAME_BASE_OFFSET(FNDECL) 0
+#endif
+
+/* The offset from the incoming value of %sp to the top of the stack frame
+   for the current function.  */
+#ifndef INCOMING_FRAME_SP_OFFSET
+#define INCOMING_FRAME_SP_OFFSET 0
+#endif
+
+#ifndef HARD_REGNO_NREGS_HAS_PADDING
+#define HARD_REGNO_NREGS_HAS_PADDING(REGNO, MODE) 0
+#define HARD_REGNO_NREGS_WITH_PADDING(REGNO, MODE) -1
+#endif
+
+#ifndef OUTGOING_REG_PARM_STACK_SPACE
+#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 0
+#endif
+
+/* MAX_STACK_ALIGNMENT is the maximum stack alignment guaranteed by
+   the backend.  MAX_SUPPORTED_STACK_ALIGNMENT is the maximum best
+   effort stack alignment supported by the backend.  If the backend
+   supports stack alignment, MAX_SUPPORTED_STACK_ALIGNMENT and
+   MAX_STACK_ALIGNMENT are the same.  Otherwise, the incoming stack
+   boundary will limit the maximum guaranteed stack alignment.  */
+#ifdef MAX_STACK_ALIGNMENT
+#define MAX_SUPPORTED_STACK_ALIGNMENT MAX_STACK_ALIGNMENT
+#else
+#define MAX_STACK_ALIGNMENT STACK_BOUNDARY
+#define MAX_SUPPORTED_STACK_ALIGNMENT PREFERRED_STACK_BOUNDARY
+#endif
+
+#define SUPPORTS_STACK_ALIGNMENT (MAX_STACK_ALIGNMENT > STACK_BOUNDARY)
+
+#ifndef LOCAL_ALIGNMENT
+#define LOCAL_ALIGNMENT(TYPE, ALIGNMENT) ALIGNMENT
+#endif
+
+#ifndef STACK_SLOT_ALIGNMENT
+#define STACK_SLOT_ALIGNMENT(TYPE,MODE,ALIGN) \
+  ((TYPE) ? LOCAL_ALIGNMENT ((TYPE), (ALIGN)) : (ALIGN))
+#endif
+
+#ifndef LOCAL_DECL_ALIGNMENT
+#define LOCAL_DECL_ALIGNMENT(DECL) \
+  LOCAL_ALIGNMENT (TREE_TYPE (DECL), DECL_ALIGN (DECL))
+#endif
+
+#ifndef MINIMUM_ALIGNMENT
+#define MINIMUM_ALIGNMENT(EXP,MODE,ALIGN) (ALIGN)
+#endif
+
+/* Alignment value for attribute ((aligned)).  */
+#ifndef ATTRIBUTE_ALIGNED_VALUE
+#define ATTRIBUTE_ALIGNED_VALUE BIGGEST_ALIGNMENT
+#endif
+
+#ifndef SLOW_UNALIGNED_ACCESS
+#define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) STRICT_ALIGNMENT
+#endif
+
+/* For most ports anything that evaluates to a constant symbolic
+   or integer value is acceptable as a constant address.  */
+#ifndef CONSTANT_ADDRESS_P
+#define CONSTANT_ADDRESS_P(X)   (CONSTANT_P (X) && GET_CODE (X) != CONST_DOUBLE)
+#endif
+
+#ifndef MAX_FIXED_MODE_SIZE
+#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (DImode)
+#endif
+
+/* Nonzero if structures and unions should be returned in memory.
+
+   This should only be defined if compatibility with another compiler or
+   with an ABI is needed, because it results in slower code.  */
+
+#ifndef DEFAULT_PCC_STRUCT_RETURN
+#define DEFAULT_PCC_STRUCT_RETURN 1
+#endif
+
+#ifndef PCC_BITFIELD_TYPE_MATTERS
+#define PCC_BITFIELD_TYPE_MATTERS false
+#endif
+
+#ifndef INSN_SETS_ARE_DELAYED
+#define INSN_SETS_ARE_DELAYED(INSN) false
+#endif
+
+#ifndef INSN_REFERENCES_ARE_DELAYED
+#define INSN_REFERENCES_ARE_DELAYED(INSN) false
+#endif
+
+#ifndef NO_FUNCTION_CSE
+#define NO_FUNCTION_CSE false
+#endif
+
+#ifndef HARD_REGNO_RENAME_OK
+#define HARD_REGNO_RENAME_OK(FROM, TO) true
+#endif
+
+#ifndef EPILOGUE_USES
+#define EPILOGUE_USES(REG) false
+#endif
+
+#ifndef ARGS_GROW_DOWNWARD
+#define ARGS_GROW_DOWNWARD 0
+#endif
+
+#ifndef STACK_GROWS_DOWNWARD
+#define STACK_GROWS_DOWNWARD 0
+#endif
+
+#ifndef STACK_PUSH_CODE
+#if STACK_GROWS_DOWNWARD
+#define STACK_PUSH_CODE PRE_DEC
+#else
+#define STACK_PUSH_CODE PRE_INC
+#endif
+#endif
+
+/* Default value for flag_pie when flag_pie is initialized to -1:
+   --enable-default-pie: Default flag_pie to -fPIE.
+   --disable-default-pie: Default flag_pie to 0.
+ */
+#ifdef ENABLE_DEFAULT_PIE
+# ifndef DEFAULT_FLAG_PIE
+#  define DEFAULT_FLAG_PIE 2
+# endif
+#else
+# define DEFAULT_FLAG_PIE 0
+#endif
+
+#ifndef SWITCHABLE_TARGET
+#define SWITCHABLE_TARGET 0
+#endif
+
+/* If the target supports integers that are wider than two
+   HOST_WIDE_INTs on the host compiler, then the target should define
+   TARGET_SUPPORTS_WIDE_INT and make the appropriate fixups.
+   Otherwise the compiler really is not robust.  */
+#ifndef TARGET_SUPPORTS_WIDE_INT
+#define TARGET_SUPPORTS_WIDE_INT 0
+#endif
+
+#ifndef SHORT_IMMEDIATES_SIGN_EXTEND
+#define SHORT_IMMEDIATES_SIGN_EXTEND 0
+#endif
+
+#ifndef WORD_REGISTER_OPERATIONS
+#define WORD_REGISTER_OPERATIONS 0
+#endif
+
+#ifndef LOAD_EXTEND_OP
+#define LOAD_EXTEND_OP(M) UNKNOWN
+#endif
+
+#ifndef CONSTANT_ALIGNMENT
+#define CONSTANT_ALIGNMENT(EXP, ALIGN) ALIGN
+#endif
+
+#ifndef INITIAL_FRAME_ADDRESS_RTX
+#define INITIAL_FRAME_ADDRESS_RTX NULL
+#endif
+
+#ifndef SETUP_FRAME_ADDRESSES
+#define SETUP_FRAME_ADDRESSES() do { } while (0)
+#endif
+
+#ifndef DYNAMIC_CHAIN_ADDRESS
+#define DYNAMIC_CHAIN_ADDRESS(x) (x)
+#endif
+
+#ifndef FRAME_ADDR_RTX
+#define FRAME_ADDR_RTX(x) (x)
+#endif
+
+#ifndef REVERSE_CONDITION
+#define REVERSE_CONDITION(code, mode) reverse_condition (code)
+#endif
+
+#ifndef TARGET_PECOFF
+#define TARGET_PECOFF 0
+#endif
+
+#ifndef EH_RETURN_HANDLER_RTX
+#define EH_RETURN_HANDLER_RTX NULL
+#endif
+
+#ifdef GCC_INSN_FLAGS_H
+/* Dependent default target macro definitions
+
+   This section of defaults.h defines target macros that depend on generated
+   headers.  This is a bit awkward:  We want to put all default definitions
+   for target macros in defaults.h, but some of the defaults depend on the
+   HAVE_* flags defines of insn-flags.h.  But insn-flags.h is not always
+   included by files that do include defaults.h.
+
+   Fortunately, the default macro definitions that depend on the HAVE_*
+   macros are also the ones that will only be used inside GCC itself, i.e.
+   not in the gen* programs or in target objects like libgcc.
+
+   Obviously, it would be best to keep this section of defaults.h as small
+   as possible, by converting the macros defined below to target hooks or
+   functions.
+*/
+
+/* The default branch cost is 1.  */
+#ifndef BRANCH_COST
+#define BRANCH_COST(speed_p, predictable_p) 1
+#endif
+
+/* If a memory-to-memory move would take MOVE_RATIO or more simple
+   move-instruction sequences, we will do a movmem or libcall instead.  */
+
+#ifndef MOVE_RATIO
+#if defined (HAVE_movmemqi) || defined (HAVE_movmemhi) || defined (HAVE_movmemsi) || defined (HAVE_movmemdi) || defined (HAVE_movmemti)
+#define MOVE_RATIO(speed) 2
+#else
+/* If we are optimizing for space (-Os), cut down the default move ratio.  */
+#define MOVE_RATIO(speed) ((speed) ? 15 : 3)
+#endif
+#endif
+
+/* If a clear memory operation would take CLEAR_RATIO or more simple
+   move-instruction sequences, we will do a setmem or libcall instead.  */
+
+#ifndef CLEAR_RATIO
+#if defined (HAVE_setmemqi) || defined (HAVE_setmemhi) || defined (HAVE_setmemsi) || defined (HAVE_setmemdi) || defined (HAVE_setmemti)
+#define CLEAR_RATIO(speed) 2
+#else
+/* If we are optimizing for space, cut down the default clear ratio.  */
+#define CLEAR_RATIO(speed) ((speed) ? 15 :3)
+#endif
+#endif
+
+/* If a memory set (to value other than zero) operation would take
+   SET_RATIO or more simple move-instruction sequences, we will do a movmem
+   or libcall instead.  */
+#ifndef SET_RATIO
+#define SET_RATIO(speed) MOVE_RATIO (speed)
+#endif
+
+/* Supply a default definition for FUNCTION_ARG_PADDING:
+   usually pad upward, but pad short args downward on
+   big-endian machines.  */
+
+#define DEFAULT_FUNCTION_ARG_PADDING(MODE, TYPE)			\
+  (! BYTES_BIG_ENDIAN							\
+   ? upward								\
+   : (((MODE) == BLKmode						\
+       ? ((TYPE) && TREE_CODE (TYPE_SIZE (TYPE)) == INTEGER_CST		\
+	  && int_size_in_bytes (TYPE) < (PARM_BOUNDARY / BITS_PER_UNIT)) \
+       : GET_MODE_BITSIZE (MODE) < PARM_BOUNDARY)			\
+      ? downward : upward))
+
+#ifndef FUNCTION_ARG_PADDING
+#define FUNCTION_ARG_PADDING(MODE, TYPE)	\
+  DEFAULT_FUNCTION_ARG_PADDING ((MODE), (TYPE))
+#endif
+
+/* Supply a default definition of STACK_SAVEAREA_MODE for emit_stack_save.
+   Normally move_insn, so Pmode stack pointer.  */
+
+#ifndef STACK_SAVEAREA_MODE
+#define STACK_SAVEAREA_MODE(LEVEL) Pmode
+#endif
+
+/* Supply a default definition of STACK_SIZE_MODE for
+   allocate_dynamic_stack_space.  Normally PLUS/MINUS, so word_mode.  */
+
+#ifndef STACK_SIZE_MODE
+#define STACK_SIZE_MODE word_mode
+#endif
+
+/* Default value for flag_stack_protect when flag_stack_protect is initialized to -1:
+   --enable-default-ssp: Default flag_stack_protect to -fstack-protector-strong.
+   --disable-default-ssp: Default flag_stack_protect to 0.
+ */
+#ifdef ENABLE_DEFAULT_SSP
+# ifndef DEFAULT_FLAG_SSP
+#  define DEFAULT_FLAG_SSP 3
+# endif
+#else
+# define DEFAULT_FLAG_SSP 0
+#endif
+
+/* Provide default values for the macros controlling stack checking.  */
+
+/* The default is neither full builtin stack checking...  */
+#ifndef STACK_CHECK_BUILTIN
+#define STACK_CHECK_BUILTIN 0
+#endif
+
+/* ...nor static builtin stack checking.  */
+#ifndef STACK_CHECK_STATIC_BUILTIN
+#define STACK_CHECK_STATIC_BUILTIN 0
+#endif
+
+/* The default interval is one page (4096 bytes).  */
+#ifndef STACK_CHECK_PROBE_INTERVAL_EXP
+#define STACK_CHECK_PROBE_INTERVAL_EXP 12
+#endif
+
+/* The default is not to move the stack pointer.  */
+#ifndef STACK_CHECK_MOVING_SP
+#define STACK_CHECK_MOVING_SP 0
+#endif
+
+/* This is a kludge to try to capture the discrepancy between the old
+   mechanism (generic stack checking) and the new mechanism (static
+   builtin stack checking).  STACK_CHECK_PROTECT needs to be bumped
+   for the latter because part of the protection area is effectively
+   included in STACK_CHECK_MAX_FRAME_SIZE for the former.  */
+#ifdef STACK_CHECK_PROTECT
+#define STACK_OLD_CHECK_PROTECT STACK_CHECK_PROTECT
+#else
+#define STACK_OLD_CHECK_PROTECT						\
+ (!global_options.x_flag_exceptions					\
+  ? 75 * UNITS_PER_WORD							\
+  : targetm_common.except_unwind_info (&global_options) == UI_SJLJ	\
+    ? 4 * 1024								\
+    : 8 * 1024)
+#endif
+
+/* Minimum amount of stack required to recover from an anticipated stack
+   overflow detection.  The default value conveys an estimate of the amount
+   of stack required to propagate an exception.  */
+#ifndef STACK_CHECK_PROTECT
+#define STACK_CHECK_PROTECT						\
+ (!global_options.x_flag_exceptions					\
+  ? 4 * 1024								\
+  : targetm_common.except_unwind_info (&global_options) == UI_SJLJ	\
+    ? 8 * 1024								\
+    : 12 * 1024)
+#endif
+
+/* Make the maximum frame size be the largest we can and still only need
+   one probe per function.  */
+#ifndef STACK_CHECK_MAX_FRAME_SIZE
+#define STACK_CHECK_MAX_FRAME_SIZE \
+  ((1 << STACK_CHECK_PROBE_INTERVAL_EXP) - UNITS_PER_WORD)
+#endif
+
+/* This is arbitrary, but should be large enough everywhere.  */
+#ifndef STACK_CHECK_FIXED_FRAME_SIZE
+#define STACK_CHECK_FIXED_FRAME_SIZE (4 * UNITS_PER_WORD)
+#endif
+
+/* Provide a reasonable default for the maximum size of an object to
+   allocate in the fixed frame.  We may need to be able to make this
+   controllable by the user at some point.  */
+#ifndef STACK_CHECK_MAX_VAR_SIZE
+#define STACK_CHECK_MAX_VAR_SIZE (STACK_CHECK_MAX_FRAME_SIZE / 100)
+#endif
+
+/* By default, the C++ compiler will use function addresses in the
+   vtable entries.  Setting this nonzero tells the compiler to use
+   function descriptors instead.  The value of this macro says how
+   many words wide the descriptor is (normally 2).  It is assumed
+   that the address of a function descriptor may be treated as a
+   pointer to a function.  */
+#ifndef TARGET_VTABLE_USES_DESCRIPTORS
+#define TARGET_VTABLE_USES_DESCRIPTORS 0
+#endif
+
+#endif /* GCC_INSN_FLAGS_H  */
+
+#ifndef DWARF_GNAT_ENCODINGS_DEFAULT
+#define DWARF_GNAT_ENCODINGS_DEFAULT DWARF_GNAT_ENCODINGS_GDB
+#endif
+
+#endif  /* ! GCC_DEFAULTS_H */
diff --git a/libgcov/include/elf-lib.h b/libgcov/include/elf-lib.h
new file mode 100644
index 0000000..f50798c
--- /dev/null
+++ b/libgcov/include/elf-lib.h
@@ -0,0 +1,36 @@
+/* Definitions for Intel 386 ELF systems.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#ifdef __i386__
+/* Used by crtstuff.c to initialize the base of data-relative relocations.
+   These are GOT relative on x86, so return the pic register.  */
+#define CRT_GET_RFIB_DATA(BASE)						\
+  __asm__ ("call\t.LPR%=\n"						\
+	   ".LPR%=:\n\t"						\
+	   "pop{l}\t%0\n\t"						\
+	   /* Due to a GAS bug, this cannot use EAX.  That encodes	\
+	      smaller than the traditional EBX, which results in the	\
+	      offset being off by one.  */				\
+	   "add{l}\t{$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"		\
+		   "|%0,_GLOBAL_OFFSET_TABLE_+(.-.LPR%=)}"		\
+	   : "=d"(BASE))
+#endif
diff --git a/libgcov/include/filenames.h b/libgcov/include/filenames.h
new file mode 100644
index 0000000..5a2a055
--- /dev/null
+++ b/libgcov/include/filenames.h
@@ -0,0 +1,99 @@
+/* Macros for taking apart, interpreting and processing file names.
+
+   These are here because some non-Posix (a.k.a. DOSish) systems have
+   drive letter brain-damage at the beginning of an absolute file name,
+   use forward- and back-slash in path names interchangeably, and
+   some of them have case-insensitive file names.
+
+   Copyright (C) 2000-2017 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef FILENAMES_H
+#define FILENAMES_H
+
+#include "hashtab.h" /* for hashval_t */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
+#  ifndef HAVE_DOS_BASED_FILE_SYSTEM
+#    define HAVE_DOS_BASED_FILE_SYSTEM 1
+#  endif
+#  ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
+#    define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
+#  endif
+#  define HAS_DRIVE_SPEC(f) HAS_DOS_DRIVE_SPEC (f)
+#  define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
+#  define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
+#else /* not DOSish */
+#  if defined(__APPLE__)
+#    ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
+#      define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
+#    endif
+#  endif /* __APPLE__ */
+#  define HAS_DRIVE_SPEC(f) (0)
+#  define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
+#  define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
+#endif
+
+#define IS_DIR_SEPARATOR_1(dos_based, c)				\
+  (((c) == '/')								\
+   || (((c) == '\\') && (dos_based)))
+
+#define HAS_DRIVE_SPEC_1(dos_based, f)			\
+  ((f)[0] && ((f)[1] == ':') && (dos_based))
+
+/* Remove the drive spec from F, assuming HAS_DRIVE_SPEC (f).
+   The result is a pointer to the remainder of F.  */
+#define STRIP_DRIVE_SPEC(f)	((f) + 2)
+
+#define IS_DOS_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (1, c)
+#define IS_DOS_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (1, f)
+#define HAS_DOS_DRIVE_SPEC(f) HAS_DRIVE_SPEC_1 (1, f)
+
+#define IS_UNIX_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (0, c)
+#define IS_UNIX_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (0, f)
+
+/* Note that when DOS_BASED is true, IS_ABSOLUTE_PATH accepts d:foo as
+   well, although it is only semi-absolute.  This is because the users
+   of IS_ABSOLUTE_PATH want to know whether to prepend the current
+   working directory to a file name, which should not be done with a
+   name like d:foo.  */
+#define IS_ABSOLUTE_PATH_1(dos_based, f)		 \
+  (IS_DIR_SEPARATOR_1 (dos_based, (f)[0])		 \
+   || HAS_DRIVE_SPEC_1 (dos_based, f))
+
+extern int filename_cmp (const char *s1, const char *s2);
+#define FILENAME_CMP(s1, s2)	filename_cmp(s1, s2)
+
+extern int filename_ncmp (const char *s1, const char *s2,
+			  size_t n);
+
+extern hashval_t filename_hash (const void *s);
+
+extern int filename_eq (const void *s1, const void *s2);
+
+extern int canonical_filename_eq (const char *a, const char *b);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FILENAMES_H */
diff --git a/libgcov/include/gcov-counter.def b/libgcov/include/gcov-counter.def
new file mode 100644
index 0000000..85dcdae
--- /dev/null
+++ b/libgcov/include/gcov-counter.def
@@ -0,0 +1,54 @@
+/* Definitions for the gcov counters in the GNU compiler.
+   Copyright (C) 2001-2017 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+/* Before including this file, define a macro:
+
+     DEF_GCOV_COUNTER(COUNTER, NAME, FN_TYPE)
+
+   This macro will be expanded to all supported gcov counters, their
+   names, or the type of handler functions.  FN_TYPE will be
+   expanded to a handler function, like in gcov_merge, it is
+   expanded to __gcov_merge ## FN_TYPE.  */
+
+/* Arc transitions.  */
+DEF_GCOV_COUNTER(GCOV_COUNTER_ARCS, "arcs", _add)
+
+/* Histogram of value inside an interval.  */
+DEF_GCOV_COUNTER(GCOV_COUNTER_V_INTERVAL, "interval", _add)
+
+/* Histogram of exact power2 logarithm of a value.  */
+DEF_GCOV_COUNTER(GCOV_COUNTER_V_POW2, "pow2", _add)
+
+/* The most common value of expression.  */
+DEF_GCOV_COUNTER(GCOV_COUNTER_V_SINGLE, "single", _single)
+
+/* The most common indirect address.  */
+DEF_GCOV_COUNTER(GCOV_COUNTER_V_INDIR, "indirect_call", _single)
+
+/* Compute average value passed to the counter.  */
+DEF_GCOV_COUNTER(GCOV_COUNTER_AVERAGE, "average", _add)
+
+/* IOR of the all values passed to counter.  */
+DEF_GCOV_COUNTER(GCOV_COUNTER_IOR, "ior", _ior)
+
+/* Time profile collecting first run of a function */
+DEF_GCOV_COUNTER(GCOV_TIME_PROFILER, "time_profiler", _time_profile)
+
+/* Top N value tracking for indirect calls.  */
+DEF_GCOV_COUNTER(GCOV_COUNTER_ICALL_TOPNV, "indirect_call_topn", _icall_topn)
diff --git a/libgcov/include/gcov-io.c b/libgcov/include/gcov-io.c
new file mode 100644
index 0000000..64dedd5
--- /dev/null
+++ b/libgcov/include/gcov-io.c
@@ -0,0 +1,987 @@
+/* File format for coverage information
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   Contributed by Bob Manson <manson@cygnus.com>.
+   Completely remangled by Nathan Sidwell <nathan@codesourcery.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+/* Routines declared in gcov-io.h.  This file should be #included by
+   another source file, after having #included gcov-io.h.  */
+
+#if !IN_GCOV
+static void gcov_write_block (unsigned);
+static gcov_unsigned_t *gcov_write_words (unsigned);
+#endif
+static const gcov_unsigned_t *gcov_read_words (unsigned);
+#if !IN_LIBGCOV
+static void gcov_allocate (unsigned);
+#endif
+
+/* Optimum number of gcov_unsigned_t's read from or written to disk.  */
+#define GCOV_BLOCK_SIZE (1 << 10)
+
+struct gcov_var
+{
+  FILE *file;
+  gcov_position_t start;	/* Position of first byte of block */
+  unsigned offset;		/* Read/write position within the block.  */
+  unsigned length;		/* Read limit in the block.  */
+  unsigned overread;		/* Number of words overread.  */
+  int error;			/* < 0 overflow, > 0 disk error.  */
+  int mode;	                /* < 0 writing, > 0 reading */
+#if IN_LIBGCOV
+  /* Holds one block plus 4 bytes, thus all coverage reads & writes
+     fit within this buffer and we always can transfer GCOV_BLOCK_SIZE
+     to and from the disk. libgcov never backtracks and only writes 4
+     or 8 byte objects.  */
+  gcov_unsigned_t buffer[GCOV_BLOCK_SIZE + 1];
+#else
+  int endian;			/* Swap endianness.  */
+  /* Holds a variable length block, as the compiler can write
+     strings and needs to backtrack.  */
+  size_t alloc;
+  gcov_unsigned_t *buffer;
+#endif
+} gcov_var;
+
+/* Save the current position in the gcov file.  */
+/* We need to expose this function when compiling for gcov-tool.  */
+#ifndef IN_GCOV_TOOL
+static inline
+#endif
+gcov_position_t
+gcov_position (void)
+{
+  gcov_nonruntime_assert (gcov_var.mode > 0); 
+  return gcov_var.start + gcov_var.offset;
+}
+
+/* Return nonzero if the error flag is set.  */
+/* We need to expose this function when compiling for gcov-tool.  */
+#ifndef IN_GCOV_TOOL
+static inline
+#endif
+int
+gcov_is_error (void)
+{
+  return gcov_var.file ? gcov_var.error : 1;
+}
+
+#if IN_LIBGCOV
+/* Move to beginning of file and initialize for writing.  */
+GCOV_LINKAGE inline void
+gcov_rewrite (void)
+{
+  gcov_var.mode = -1; 
+  gcov_var.start = 0;
+  gcov_var.offset = 0;
+  fseek (gcov_var.file, 0L, SEEK_SET);
+}
+#endif
+
+static inline gcov_unsigned_t from_file (gcov_unsigned_t value)
+{
+#if !IN_LIBGCOV
+  if (gcov_var.endian)
+    {
+      value = (value >> 16) | (value << 16);
+      value = ((value & 0xff00ff) << 8) | ((value >> 8) & 0xff00ff);
+    }
+#endif
+  return value;
+}
+
+/* Open a gcov file. NAME is the name of the file to open and MODE
+   indicates whether a new file should be created, or an existing file
+   opened. If MODE is >= 0 an existing file will be opened, if
+   possible, and if MODE is <= 0, a new file will be created. Use
+   MODE=0 to attempt to reopen an existing file and then fall back on
+   creating a new one.  If MODE > 0, the file will be opened in
+   read-only mode.  Otherwise it will be opened for modification.
+   Return zero on failure, non-zero on success.  */
+
+GCOV_LINKAGE int
+#if IN_LIBGCOV
+gcov_open (const char *name)
+#else
+gcov_open (const char *name, int mode)
+#endif
+{
+#if IN_LIBGCOV
+  int mode = 0;
+#endif
+#if GCOV_LOCKED
+  struct flock s_flock;
+  int fd;
+
+  s_flock.l_whence = SEEK_SET;
+  s_flock.l_start = 0;
+  s_flock.l_len = 0; /* Until EOF.  */
+  s_flock.l_pid = getpid ();
+#endif
+
+  gcov_nonruntime_assert (!gcov_var.file);
+  gcov_var.start = 0;
+  gcov_var.offset = gcov_var.length = 0;
+  gcov_var.overread = -1u;
+  gcov_var.error = 0;
+#if !IN_LIBGCOV
+  gcov_var.endian = 0;
+#endif
+#if GCOV_LOCKED
+  if (mode > 0)
+    {
+      /* Read-only mode - acquire a read-lock.  */
+      s_flock.l_type = F_RDLCK;
+      /* pass mode (ignored) for compatibility */
+      fd = open (name, O_RDONLY, S_IRUSR | S_IWUSR);
+    }
+  else
+     {
+       /* Write mode - acquire a write-lock.  */
+       s_flock.l_type = F_WRLCK;
+       /* Truncate if force new mode.  */
+       fd = open (name, O_RDWR | O_CREAT | (mode < 0 ? O_TRUNC : 0), 0666);
+    }
+  if (fd < 0)
+    return 0;
+
+  while (fcntl (fd, F_SETLKW, &s_flock) && errno == EINTR)
+    continue;
+
+  gcov_var.file = fdopen (fd, (mode > 0) ? "rb" : "r+b");
+
+  if (!gcov_var.file)
+    {
+      close (fd);
+      return 0;
+    }
+#else
+  if (mode >= 0)
+    /* Open an existing file.  */
+    gcov_var.file = fopen (name, (mode > 0) ? "rb" : "r+b");
+
+  if (gcov_var.file)
+    mode = 1;
+  else if (mode <= 0)
+    /* Create a new file.  */
+    gcov_var.file = fopen (name, "w+b");
+
+  if (!gcov_var.file)
+    return 0;
+#endif
+
+  gcov_var.mode = mode ? mode : 1;
+
+  setbuf (gcov_var.file, (char *)0);
+
+  return 1;
+}
+
+/* Close the current gcov file. Flushes data to disk. Returns nonzero
+   on failure or error flag set.  */
+
+GCOV_LINKAGE int
+gcov_close (void)
+{
+  if (gcov_var.file)
+    {
+#if !IN_GCOV
+      if (gcov_var.offset && gcov_var.mode < 0)
+	gcov_write_block (gcov_var.offset);
+#endif
+      fclose (gcov_var.file);
+      gcov_var.file = 0;
+      gcov_var.length = 0;
+    }
+#if !IN_LIBGCOV
+  free (gcov_var.buffer);
+  gcov_var.alloc = 0;
+  gcov_var.buffer = 0;
+#endif
+  gcov_var.mode = 0;
+  return gcov_var.error;
+}
+
+#if !IN_LIBGCOV
+/* Check if MAGIC is EXPECTED. Use it to determine endianness of the
+   file. Returns +1 for same endian, -1 for other endian and zero for
+   not EXPECTED.  */
+
+GCOV_LINKAGE int
+gcov_magic (gcov_unsigned_t magic, gcov_unsigned_t expected)
+{
+  if (magic == expected)
+    return 1;
+  magic = (magic >> 16) | (magic << 16);
+  magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
+  if (magic == expected)
+    {
+      gcov_var.endian = 1;
+      return -1;
+    }
+  return 0;
+}
+#endif
+
+#if !IN_LIBGCOV
+static void
+gcov_allocate (unsigned length)
+{
+  size_t new_size = gcov_var.alloc;
+
+  if (!new_size)
+    new_size = GCOV_BLOCK_SIZE;
+  new_size += length;
+  new_size *= 2;
+
+  gcov_var.alloc = new_size;
+  gcov_var.buffer = XRESIZEVAR (gcov_unsigned_t, gcov_var.buffer, new_size << 2);
+}
+#endif
+
+#if !IN_GCOV
+/* Write out the current block, if needs be.  */
+
+static void
+gcov_write_block (unsigned size)
+{
+  if (fwrite (gcov_var.buffer, size << 2, 1, gcov_var.file) != 1)
+    gcov_var.error = 1;
+  gcov_var.start += size;
+  gcov_var.offset -= size;
+}
+
+/* Allocate space to write BYTES bytes to the gcov file. Return a
+   pointer to those bytes, or NULL on failure.  */
+
+static gcov_unsigned_t *
+gcov_write_words (unsigned words)
+{
+  gcov_unsigned_t *result;
+
+  gcov_nonruntime_assert (gcov_var.mode < 0);
+#if IN_LIBGCOV
+  if (gcov_var.offset >= GCOV_BLOCK_SIZE)
+    {
+      gcov_write_block (GCOV_BLOCK_SIZE);
+      if (gcov_var.offset)
+	{
+	  memcpy (gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4);
+	}
+    }
+#else
+  if (gcov_var.offset + words > gcov_var.alloc)
+    gcov_allocate (gcov_var.offset + words);
+#endif
+  result = &gcov_var.buffer[gcov_var.offset];
+  gcov_var.offset += words;
+
+  return result;
+}
+
+/* Write unsigned VALUE to coverage file.  Sets error flag
+   appropriately.  */
+
+GCOV_LINKAGE void
+gcov_write_unsigned (gcov_unsigned_t value)
+{
+  gcov_unsigned_t *buffer = gcov_write_words (1);
+
+  buffer[0] = value;
+}
+
+/* Write counter VALUE to coverage file.  Sets error flag
+   appropriately.  */
+
+#if IN_LIBGCOV
+GCOV_LINKAGE void
+gcov_write_counter (gcov_type value)
+{
+  gcov_unsigned_t *buffer = gcov_write_words (2);
+
+  buffer[0] = (gcov_unsigned_t) value;
+  if (sizeof (value) > sizeof (gcov_unsigned_t))
+    buffer[1] = (gcov_unsigned_t) (value >> 32);
+  else
+    buffer[1] = 0;
+}
+#endif /* IN_LIBGCOV */
+
+#if !IN_LIBGCOV
+/* Write STRING to coverage file.  Sets error flag on file
+   error, overflow flag on overflow */
+
+GCOV_LINKAGE void
+gcov_write_string (const char *string)
+{
+  unsigned length = 0;
+  unsigned alloc = 0;
+  gcov_unsigned_t *buffer;
+
+  if (string)
+    {
+      length = strlen (string);
+      alloc = (length + 4) >> 2;
+    }
+
+  buffer = gcov_write_words (1 + alloc);
+
+  buffer[0] = alloc;
+
+  if (alloc > 0)
+    {
+      buffer[alloc] = 0; /* place nul terminators.  */
+      memcpy (&buffer[1], string, length);
+    }
+}
+#endif
+
+#if !IN_LIBGCOV
+/* Write a tag TAG and reserve space for the record length. Return a
+   value to be used for gcov_write_length.  */
+
+GCOV_LINKAGE gcov_position_t
+gcov_write_tag (gcov_unsigned_t tag)
+{
+  gcov_position_t result = gcov_var.start + gcov_var.offset;
+  gcov_unsigned_t *buffer = gcov_write_words (2);
+
+  buffer[0] = tag;
+  buffer[1] = 0;
+
+  return result;
+}
+
+/* Write a record length using POSITION, which was returned by
+   gcov_write_tag.  The current file position is the end of the
+   record, and is restored before returning.  Returns nonzero on
+   overflow.  */
+
+GCOV_LINKAGE void
+gcov_write_length (gcov_position_t position)
+{
+  unsigned offset;
+  gcov_unsigned_t length;
+  gcov_unsigned_t *buffer;
+
+  gcov_nonruntime_assert (gcov_var.mode < 0);
+  gcov_nonruntime_assert (position + 2 <= gcov_var.start + gcov_var.offset);
+  gcov_nonruntime_assert (position >= gcov_var.start);
+  offset = position - gcov_var.start;
+  length = gcov_var.offset - offset - 2;
+  buffer = (gcov_unsigned_t *) &gcov_var.buffer[offset];
+  buffer[1] = length;
+  if (gcov_var.offset >= GCOV_BLOCK_SIZE)
+    gcov_write_block (gcov_var.offset);
+}
+
+#else /* IN_LIBGCOV */
+
+/* Write a tag TAG and length LENGTH.  */
+
+GCOV_LINKAGE void
+gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length)
+{
+  gcov_unsigned_t *buffer = gcov_write_words (2);
+
+  buffer[0] = tag;
+  buffer[1] = length;
+}
+
+/* Write a summary structure to the gcov file.  Return nonzero on
+   overflow.  */
+
+GCOV_LINKAGE void
+gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary)
+{
+  unsigned ix, h_ix, bv_ix, h_cnt = 0;
+  const struct gcov_ctr_summary *csum;
+  unsigned histo_bitvector[GCOV_HISTOGRAM_BITVECTOR_SIZE];
+
+  /* Count number of non-zero histogram entries, and fill in a bit vector
+     of non-zero indices. The histogram is only currently computed for arc
+     counters.  */
+  for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
+    histo_bitvector[bv_ix] = 0;
+  csum = &summary->ctrs[GCOV_COUNTER_ARCS];
+  for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
+    if (csum->histogram[h_ix].num_counters)
+      {
+	histo_bitvector[h_ix / 32] |= 1 << (h_ix % 32);
+	h_cnt++;
+      }
+  gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH (h_cnt));
+  gcov_write_unsigned (summary->checksum);
+  for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
+    {
+      gcov_write_unsigned (csum->num);
+      gcov_write_unsigned (csum->runs);
+      gcov_write_counter (csum->sum_all);
+      gcov_write_counter (csum->run_max);
+      gcov_write_counter (csum->sum_max);
+      if (ix != GCOV_COUNTER_ARCS)
+        {
+          for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
+            gcov_write_unsigned (0);
+          continue;
+        }
+      for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
+        gcov_write_unsigned (histo_bitvector[bv_ix]);
+      for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
+        {
+          if (!csum->histogram[h_ix].num_counters)
+            continue;
+          gcov_write_unsigned (csum->histogram[h_ix].num_counters);
+          gcov_write_counter (csum->histogram[h_ix].min_value);
+          gcov_write_counter (csum->histogram[h_ix].cum_value);
+        }
+    }
+}
+#endif /* IN_LIBGCOV */
+
+#endif /*!IN_GCOV */
+
+/* Return a pointer to read BYTES bytes from the gcov file. Returns
+   NULL on failure (read past EOF).  */
+
+static const gcov_unsigned_t *
+gcov_read_words (unsigned words)
+{
+  const gcov_unsigned_t *result;
+  unsigned excess = gcov_var.length - gcov_var.offset;
+
+  if (gcov_var.mode <= 0)
+    return NULL;
+
+  if (excess < words)
+    {
+      gcov_var.start += gcov_var.offset;
+      if (excess)
+	{
+#if IN_LIBGCOV
+	  memcpy (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, 4);
+#else
+	  memmove (gcov_var.buffer, gcov_var.buffer + gcov_var.offset,
+		   excess * 4);
+#endif
+	}
+      gcov_var.offset = 0;
+      gcov_var.length = excess;
+#if IN_LIBGCOV
+      excess = GCOV_BLOCK_SIZE;
+#else
+      if (gcov_var.length + words > gcov_var.alloc)
+	gcov_allocate (gcov_var.length + words);
+      excess = gcov_var.alloc - gcov_var.length;
+#endif
+      excess = fread (gcov_var.buffer + gcov_var.length,
+		      1, excess << 2, gcov_var.file) >> 2;
+      gcov_var.length += excess;
+      if (gcov_var.length < words)
+	{
+	  gcov_var.overread += words - gcov_var.length;
+	  gcov_var.length = 0;
+	  return 0;
+	}
+    }
+  result = &gcov_var.buffer[gcov_var.offset];
+  gcov_var.offset += words;
+  return result;
+}
+
+/* Read unsigned value from a coverage file. Sets error flag on file
+   error, overflow flag on overflow */
+
+GCOV_LINKAGE gcov_unsigned_t
+gcov_read_unsigned (void)
+{
+  gcov_unsigned_t value;
+  const gcov_unsigned_t *buffer = gcov_read_words (1);
+
+  if (!buffer)
+    return 0;
+  value = from_file (buffer[0]);
+  return value;
+}
+
+/* Read counter value from a coverage file. Sets error flag on file
+   error, overflow flag on overflow */
+
+GCOV_LINKAGE gcov_type
+gcov_read_counter (void)
+{
+  gcov_type value;
+  const gcov_unsigned_t *buffer = gcov_read_words (2);
+
+  if (!buffer)
+    return 0;
+  value = from_file (buffer[0]);
+  if (sizeof (value) > sizeof (gcov_unsigned_t))
+    value |= ((gcov_type) from_file (buffer[1])) << 32;
+  else if (buffer[1])
+    gcov_var.error = -1;
+
+  return value;
+}
+
+/* We need to expose the below function when compiling for gcov-tool.  */
+
+#if !IN_LIBGCOV || defined (IN_GCOV_TOOL)
+/* Read string from coverage file. Returns a pointer to a static
+   buffer, or NULL on empty string. You must copy the string before
+   calling another gcov function.  */
+
+GCOV_LINKAGE const char *
+gcov_read_string (void)
+{
+  unsigned length = gcov_read_unsigned ();
+
+  if (!length)
+    return 0;
+
+  return (const char *) gcov_read_words (length);
+}
+#endif
+
+GCOV_LINKAGE void
+gcov_read_summary (struct gcov_summary *summary)
+{
+  unsigned ix, h_ix, bv_ix, h_cnt = 0;
+  struct gcov_ctr_summary *csum;
+  unsigned histo_bitvector[GCOV_HISTOGRAM_BITVECTOR_SIZE];
+  unsigned cur_bitvector;
+
+  summary->checksum = gcov_read_unsigned ();
+  for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
+    {
+      csum->num = gcov_read_unsigned ();
+      csum->runs = gcov_read_unsigned ();
+      csum->sum_all = gcov_read_counter ();
+      csum->run_max = gcov_read_counter ();
+      csum->sum_max = gcov_read_counter ();
+      memset (csum->histogram, 0,
+              sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
+      for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
+        {
+          histo_bitvector[bv_ix] = gcov_read_unsigned ();
+#if IN_LIBGCOV
+          /* When building libgcov we don't include system.h, which includes
+             hwint.h (where popcount_hwi is declared). However, libgcov.a
+             is built by the bootstrapped compiler and therefore the builtins
+             are always available.  */
+          h_cnt += __builtin_popcount (histo_bitvector[bv_ix]);
+#else
+          h_cnt += popcount_hwi (histo_bitvector[bv_ix]);
+#endif
+        }
+      bv_ix = 0;
+      h_ix = 0;
+      cur_bitvector = 0;
+      while (h_cnt--)
+        {
+          /* Find the index corresponding to the next entry we will read in.
+             First find the next non-zero bitvector and re-initialize
+             the histogram index accordingly, then right shift and increment
+             the index until we find a set bit.  */
+          while (!cur_bitvector)
+            {
+              h_ix = bv_ix * 32;
+              if (bv_ix >= GCOV_HISTOGRAM_BITVECTOR_SIZE)
+                gcov_error ("corrupted profile info: summary histogram "
+                            "bitvector is corrupt");
+              cur_bitvector = histo_bitvector[bv_ix++];
+            }
+          while (!(cur_bitvector & 0x1))
+            {
+              h_ix++;
+              cur_bitvector >>= 1;
+            }
+          if (h_ix >= GCOV_HISTOGRAM_SIZE)
+            gcov_error ("corrupted profile info: summary histogram "
+                        "index is corrupt");
+
+          csum->histogram[h_ix].num_counters = gcov_read_unsigned ();
+          csum->histogram[h_ix].min_value = gcov_read_counter ();
+          csum->histogram[h_ix].cum_value = gcov_read_counter ();
+          /* Shift off the index we are done with and increment to the
+             corresponding next histogram entry.  */
+          cur_bitvector >>= 1;
+          h_ix++;
+        }
+    }
+}
+
+/* We need to expose the below function when compiling for gcov-tool.  */
+
+#if !IN_LIBGCOV || defined (IN_GCOV_TOOL)
+/* Reset to a known position.  BASE should have been obtained from
+   gcov_position, LENGTH should be a record length.  */
+
+GCOV_LINKAGE void
+gcov_sync (gcov_position_t base, gcov_unsigned_t length)
+{
+  gcov_nonruntime_assert (gcov_var.mode > 0);
+  base += length;
+  if (base - gcov_var.start <= gcov_var.length)
+    gcov_var.offset = base - gcov_var.start;
+  else
+    {
+      gcov_var.offset = gcov_var.length = 0;
+      fseek (gcov_var.file, base << 2, SEEK_SET);
+      gcov_var.start = ftell (gcov_var.file) >> 2;
+    }
+}
+#endif
+
+#if IN_LIBGCOV
+/* Move to a given position in a gcov file.  */
+
+GCOV_LINKAGE void
+gcov_seek (gcov_position_t base)
+{
+  if (gcov_var.offset)
+    gcov_write_block (gcov_var.offset);
+  fseek (gcov_var.file, base << 2, SEEK_SET);
+  gcov_var.start = ftell (gcov_var.file) >> 2;
+}
+#endif
+
+#if IN_GCOV > 0
+/* Return the modification time of the current gcov file.  */
+
+GCOV_LINKAGE time_t
+gcov_time (void)
+{
+  struct stat status;
+
+  if (fstat (fileno (gcov_var.file), &status))
+    return 0;
+  else
+    return status.st_mtime;
+}
+#endif /* IN_GCOV */
+
+#if !IN_GCOV
+/* Determine the index into histogram for VALUE. */
+
+#if IN_LIBGCOV
+static unsigned
+#else
+GCOV_LINKAGE unsigned
+#endif
+gcov_histo_index (gcov_type value)
+{
+  gcov_type_unsigned v = (gcov_type_unsigned)value;
+  unsigned r = 0;
+  unsigned prev2bits = 0;
+
+  /* Find index into log2 scale histogram, where each of the log2
+     sized buckets is divided into 4 linear sub-buckets for better
+     focus in the higher buckets.  */
+
+  /* Find the place of the most-significant bit set.  */
+  if (v > 0)
+    {
+#if IN_LIBGCOV
+      /* When building libgcov we don't include system.h, which includes
+         hwint.h (where floor_log2 is declared). However, libgcov.a
+         is built by the bootstrapped compiler and therefore the builtins
+         are always available.  */
+      r = sizeof (long long) * __CHAR_BIT__ - 1 - __builtin_clzll (v);
+#else
+      /* We use floor_log2 from hwint.c, which takes a HOST_WIDE_INT
+         that is 64 bits and gcov_type_unsigned is 64 bits.  */
+      r = floor_log2 (v);
+#endif
+    }
+
+  /* If at most the 2 least significant bits are set (value is
+     0 - 3) then that value is our index into the lowest set of
+     four buckets.  */
+  if (r < 2)
+    return (unsigned)value;
+
+  gcov_nonruntime_assert (r < 64);
+
+  /* Find the two next most significant bits to determine which
+     of the four linear sub-buckets to select.  */
+  prev2bits = (v >> (r - 2)) & 0x3;
+  /* Finally, compose the final bucket index from the log2 index and
+     the next 2 bits. The minimum r value at this point is 2 since we
+     returned above if r was 2 or more, so the minimum bucket at this
+     point is 4.  */
+  return (r - 1) * 4 + prev2bits;
+}
+
+/* Merge SRC_HISTO into TGT_HISTO. The counters are assumed to be in
+   the same relative order in both histograms, and are matched up
+   and merged in reverse order. Each counter is assigned an equal portion of
+   its entry's original cumulative counter value when computing the
+   new merged cum_value.  */
+
+static void gcov_histogram_merge (gcov_bucket_type *tgt_histo,
+                                  gcov_bucket_type *src_histo)
+{
+  int src_i, tgt_i, tmp_i = 0;
+  unsigned src_num, tgt_num, merge_num;
+  gcov_type src_cum, tgt_cum, merge_src_cum, merge_tgt_cum, merge_cum;
+  gcov_type merge_min;
+  gcov_bucket_type tmp_histo[GCOV_HISTOGRAM_SIZE];
+  int src_done = 0;
+
+  memset (tmp_histo, 0, sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
+
+  /* Assume that the counters are in the same relative order in both
+     histograms. Walk the histograms from largest to smallest entry,
+     matching up and combining counters in order.  */
+  src_num = 0;
+  src_cum = 0;
+  src_i = GCOV_HISTOGRAM_SIZE - 1;
+  for (tgt_i = GCOV_HISTOGRAM_SIZE - 1; tgt_i >= 0 && !src_done; tgt_i--)
+    {
+      tgt_num = tgt_histo[tgt_i].num_counters;
+      tgt_cum = tgt_histo[tgt_i].cum_value;
+      /* Keep going until all of the target histogram's counters at this
+         position have been matched and merged with counters from the
+         source histogram.  */
+      while (tgt_num > 0 && !src_done)
+        {
+          /* If this is either the first time through this loop or we just
+             exhausted the previous non-zero source histogram entry, look
+             for the next non-zero source histogram entry.  */
+          if (!src_num)
+            {
+              /* Locate the next non-zero entry.  */
+              while (src_i >= 0 && !src_histo[src_i].num_counters)
+                src_i--;
+              /* If source histogram has fewer counters, then just copy over the
+                 remaining target counters and quit.  */
+              if (src_i < 0)
+                {
+                  tmp_histo[tgt_i].num_counters += tgt_num;
+                  tmp_histo[tgt_i].cum_value += tgt_cum;
+                  if (!tmp_histo[tgt_i].min_value ||
+                      tgt_histo[tgt_i].min_value < tmp_histo[tgt_i].min_value)
+                    tmp_histo[tgt_i].min_value = tgt_histo[tgt_i].min_value;
+                  while (--tgt_i >= 0)
+                    {
+                      tmp_histo[tgt_i].num_counters
+                          += tgt_histo[tgt_i].num_counters;
+                      tmp_histo[tgt_i].cum_value += tgt_histo[tgt_i].cum_value;
+                      if (!tmp_histo[tgt_i].min_value ||
+                          tgt_histo[tgt_i].min_value
+                          < tmp_histo[tgt_i].min_value)
+                        tmp_histo[tgt_i].min_value = tgt_histo[tgt_i].min_value;
+                    }
+
+                  src_done = 1;
+                  break;
+                }
+
+              src_num = src_histo[src_i].num_counters;
+              src_cum = src_histo[src_i].cum_value;
+            }
+
+          /* The number of counters to merge on this pass is the minimum
+             of the remaining counters from the current target and source
+             histogram entries.  */
+          merge_num = tgt_num;
+          if (src_num < merge_num)
+            merge_num = src_num;
+
+          /* The merged min_value is the sum of the min_values from target
+             and source.  */
+          merge_min = tgt_histo[tgt_i].min_value + src_histo[src_i].min_value;
+
+          /* Compute the portion of source and target entries' cum_value
+             that will be apportioned to the counters being merged.
+             The total remaining cum_value from each entry is divided
+             equally among the counters from that histogram entry if we
+             are not merging all of them.  */
+          merge_src_cum = src_cum;
+          if (merge_num < src_num)
+            merge_src_cum = merge_num * src_cum / src_num;
+          merge_tgt_cum = tgt_cum;
+          if (merge_num < tgt_num)
+            merge_tgt_cum = merge_num * tgt_cum / tgt_num;
+          /* The merged cum_value is the sum of the source and target
+             components.  */
+          merge_cum = merge_src_cum + merge_tgt_cum;
+
+          /* Update the remaining number of counters and cum_value left
+             to be merged from this source and target entry.  */
+          src_cum -= merge_src_cum;
+          tgt_cum -= merge_tgt_cum;
+          src_num -= merge_num;
+          tgt_num -= merge_num;
+
+          /* The merged counters get placed in the new merged histogram
+             at the entry for the merged min_value.  */
+          tmp_i = gcov_histo_index (merge_min);
+          gcov_nonruntime_assert (tmp_i < GCOV_HISTOGRAM_SIZE);
+          tmp_histo[tmp_i].num_counters += merge_num;
+          tmp_histo[tmp_i].cum_value += merge_cum;
+          if (!tmp_histo[tmp_i].min_value ||
+              merge_min < tmp_histo[tmp_i].min_value)
+            tmp_histo[tmp_i].min_value = merge_min;
+
+          /* Ensure the search for the next non-zero src_histo entry starts
+             at the next smallest histogram bucket.  */
+          if (!src_num)
+            src_i--;
+        }
+    }
+
+  gcov_nonruntime_assert (tgt_i < 0);
+
+  /* In the case where there were more counters in the source histogram,
+     accumulate the remaining unmerged cumulative counter values. Add
+     those to the smallest non-zero target histogram entry. Otherwise,
+     the total cumulative counter values in the histogram will be smaller
+     than the sum_all stored in the summary, which will complicate
+     computing the working set information from the histogram later on.  */
+  if (src_num)
+    src_i--;
+  while (src_i >= 0)
+    {
+      src_cum += src_histo[src_i].cum_value;
+      src_i--;
+    }
+  /* At this point, tmp_i should be the smallest non-zero entry in the
+     tmp_histo.  */
+  gcov_nonruntime_assert (tmp_i >= 0 && tmp_i < GCOV_HISTOGRAM_SIZE
+                          && tmp_histo[tmp_i].num_counters > 0);
+  tmp_histo[tmp_i].cum_value += src_cum;
+
+  /* Finally, copy the merged histogram into tgt_histo.  */
+  memcpy (tgt_histo, tmp_histo,
+	  sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
+}
+#endif /* !IN_GCOV */
+
+/* This is used by gcov-dump (IN_GCOV == -1) and in the compiler
+   (!IN_GCOV && !IN_LIBGCOV).  */
+#if IN_GCOV <= 0 && !IN_LIBGCOV
+/* Compute the working set information from the counter histogram in
+   the profile summary. This is an array of information corresponding to a
+   range of percentages of the total execution count (sum_all), and includes
+   the number of counters required to cover that working set percentage and
+   the minimum counter value in that working set.  */
+
+GCOV_LINKAGE void
+compute_working_sets (const struct gcov_ctr_summary *summary,
+                      gcov_working_set_t *gcov_working_sets)
+{
+  gcov_type working_set_cum_values[NUM_GCOV_WORKING_SETS];
+  gcov_type ws_cum_hotness_incr;
+  gcov_type cum, tmp_cum;
+  const gcov_bucket_type *histo_bucket;
+  unsigned ws_ix, c_num, count;
+  int h_ix;
+
+  /* Compute the amount of sum_all that the cumulative hotness grows
+     by in each successive working set entry, which depends on the
+     number of working set entries.  */
+  ws_cum_hotness_incr = summary->sum_all / NUM_GCOV_WORKING_SETS;
+
+  /* Next fill in an array of the cumulative hotness values corresponding
+     to each working set summary entry we are going to compute below.
+     Skip 0% statistics, which can be extrapolated from the
+     rest of the summary data.  */
+  cum = ws_cum_hotness_incr;
+  for (ws_ix = 0; ws_ix < NUM_GCOV_WORKING_SETS;
+       ws_ix++, cum += ws_cum_hotness_incr)
+    working_set_cum_values[ws_ix] = cum;
+  /* The last summary entry is reserved for (roughly) 99.9% of the
+     working set. Divide by 1024 so it becomes a shift, which gives
+     almost exactly 99.9%.  */
+  working_set_cum_values[NUM_GCOV_WORKING_SETS-1]
+      = summary->sum_all - summary->sum_all/1024;
+
+  /* Next, walk through the histogram in decending order of hotness
+     and compute the statistics for the working set summary array.
+     As histogram entries are accumulated, we check to see which
+     working set entries have had their expected cum_value reached
+     and fill them in, walking the working set entries in increasing
+     size of cum_value.  */
+  ws_ix = 0; /* The current entry into the working set array.  */
+  cum = 0; /* The current accumulated counter sum.  */
+  count = 0; /* The current accumulated count of block counters.  */
+  for (h_ix = GCOV_HISTOGRAM_SIZE - 1;
+       h_ix >= 0 && ws_ix < NUM_GCOV_WORKING_SETS; h_ix--)
+    {
+      histo_bucket = &summary->histogram[h_ix];
+
+      /* If we haven't reached the required cumulative counter value for
+         the current working set percentage, simply accumulate this histogram
+         entry into the running sums and continue to the next histogram
+         entry.  */
+      if (cum + histo_bucket->cum_value < working_set_cum_values[ws_ix])
+        {
+          cum += histo_bucket->cum_value;
+          count += histo_bucket->num_counters;
+          continue;
+        }
+
+      /* If adding the current histogram entry's cumulative counter value
+         causes us to exceed the current working set size, then estimate
+         how many of this histogram entry's counter values are required to
+         reach the working set size, and fill in working set entries
+         as we reach their expected cumulative value.  */
+      for (c_num = 0, tmp_cum = cum;
+           c_num < histo_bucket->num_counters && ws_ix < NUM_GCOV_WORKING_SETS;
+           c_num++)
+        {
+          count++;
+          /* If we haven't reached the last histogram entry counter, add
+             in the minimum value again. This will underestimate the
+             cumulative sum so far, because many of the counter values in this
+             entry may have been larger than the minimum. We could add in the
+             average value every time, but that would require an expensive
+             divide operation.  */
+          if (c_num + 1 < histo_bucket->num_counters)
+            tmp_cum += histo_bucket->min_value;
+          /* If we have reached the last histogram entry counter, then add
+             in the entire cumulative value.  */
+          else
+            tmp_cum = cum + histo_bucket->cum_value;
+
+	  /* Next walk through successive working set entries and fill in
+	     the statistics for any whose size we have reached by accumulating
+	     this histogram counter.  */
+	  while (ws_ix < NUM_GCOV_WORKING_SETS
+		 && tmp_cum >= working_set_cum_values[ws_ix])
+            {
+              gcov_working_sets[ws_ix].num_counters = count;
+              gcov_working_sets[ws_ix].min_counter
+                  = histo_bucket->min_value;
+              ws_ix++;
+            }
+        }
+      /* Finally, update the running cumulative value since we were
+         using a temporary above.  */
+      cum += histo_bucket->cum_value;
+    }
+  gcov_nonruntime_assert (ws_ix == NUM_GCOV_WORKING_SETS);
+}
+#endif /* IN_GCOV <= 0 && !IN_LIBGCOV */
diff --git a/libgcov/include/gcov-io.h b/libgcov/include/gcov-io.h
new file mode 100644
index 0000000..1fb58dd
--- /dev/null
+++ b/libgcov/include/gcov-io.h
@@ -0,0 +1,424 @@
+/* File format for coverage information
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   Contributed by Bob Manson <manson@cygnus.com>.
+   Completely remangled by Nathan Sidwell <nathan@codesourcery.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+
+/* Coverage information is held in two files.  A notes file, which is
+   generated by the compiler, and a data file, which is generated by
+   the program under test.  Both files use a similar structure.  We do
+   not attempt to make these files backwards compatible with previous
+   versions, as you only need coverage information when developing a
+   program.  We do hold version information, so that mismatches can be
+   detected, and we use a format that allows tools to skip information
+   they do not understand or are not interested in.
+
+   Numbers are recorded in the 32 bit unsigned binary form of the
+   endianness of the machine generating the file. 64 bit numbers are
+   stored as two 32 bit numbers, the low part first.  Strings are
+   padded with 1 to 4 NUL bytes, to bring the length up to a multiple
+   of 4. The number of 4 bytes is stored, followed by the padded
+   string. Zero length and NULL strings are simply stored as a length
+   of zero (they have no trailing NUL or padding).
+
+   	int32:  byte3 byte2 byte1 byte0 | byte0 byte1 byte2 byte3
+	int64:  int32:low int32:high
+	string: int32:0 | int32:length char* char:0 padding
+	padding: | char:0 | char:0 char:0 | char:0 char:0 char:0
+	item: int32 | int64 | string
+
+   The basic format of the files is
+
+   	file : int32:magic int32:version int32:stamp record*
+
+   The magic ident is different for the notes and the data files.  The
+   magic ident is used to determine the endianness of the file, when
+   reading.  The version is the same for both files and is derived
+   from gcc's version number. The stamp value is used to synchronize
+   note and data files and to synchronize merging within a data
+   file. It need not be an absolute time stamp, merely a ticker that
+   increments fast enough and cycles slow enough to distinguish
+   different compile/run/compile cycles.
+
+   Although the ident and version are formally 32 bit numbers, they
+   are derived from 4 character ASCII strings.  The version number
+   consists of a two character major version number
+   (first digit starts from 'A' letter to not to clash with the older
+   numbering scheme), the single character minor version number,
+   and a single character indicating the status of the release.
+   That will be 'e' experimental, 'p' prerelease and 'r' for release.
+   Because, by good fortune, these are in alphabetical order, string
+   collating can be used to compare version strings.  Be aware that
+   the 'e' designation will (naturally) be unstable and might be
+   incompatible with itself.  For gcc 17.0 experimental, it would be
+   'B70e' (0x42373065).  As we currently do not release more than 5 minor
+   releases, the single character should be always fine.  Major number
+   is currently changed roughly every year, which gives us space
+   for next 250 years (maximum allowed number would be 259.9).
+
+   A record has a tag, length and variable amount of data.
+
+   	record: header data
+	header: int32:tag int32:length
+	data: item*
+
+   Records are not nested, but there is a record hierarchy.  Tag
+   numbers reflect this hierarchy.  Tags are unique across note and
+   data files.  Some record types have a varying amount of data.  The
+   LENGTH is the number of 4bytes that follow and is usually used to
+   determine how much data.  The tag value is split into 4 8-bit
+   fields, one for each of four possible levels.  The most significant
+   is allocated first.  Unused levels are zero.  Active levels are
+   odd-valued, so that the LSB of the level is one.  A sub-level
+   incorporates the values of its superlevels.  This formatting allows
+   you to determine the tag hierarchy, without understanding the tags
+   themselves, and is similar to the standard section numbering used
+   in technical documents.  Level values [1..3f] are used for common
+   tags, values [41..9f] for the notes file and [a1..ff] for the data
+   file.
+
+   The notes file contains the following records
+   	note: unit function-graph*
+	unit: header int32:checksum string:source
+	function-graph: announce_function basic_blocks {arcs | lines}*
+	announce_function: header int32:ident
+		int32:lineno_checksum int32:cfg_checksum
+		string:name string:source int32:lineno
+	basic_block: header int32:flags*
+	arcs: header int32:block_no arc*
+	arc:  int32:dest_block int32:flags
+        lines: header int32:block_no line*
+               int32:0 string:NULL
+	line:  int32:line_no | int32:0 string:filename
+
+   The BASIC_BLOCK record holds per-bb flags.  The number of blocks
+   can be inferred from its data length.  There is one ARCS record per
+   basic block.  The number of arcs from a bb is implicit from the
+   data length.  It enumerates the destination bb and per-arc flags.
+   There is one LINES record per basic block, it enumerates the source
+   lines which belong to that basic block.  Source file names are
+   introduced by a line number of 0, following lines are from the new
+   source file.  The initial source file for the function is NULL, but
+   the current source file should be remembered from one LINES record
+   to the next.  The end of a block is indicated by an empty filename
+   - this does not reset the current source file.  Note there is no
+   ordering of the ARCS and LINES records: they may be in any order,
+   interleaved in any manner.  The current filename follows the order
+   the LINES records are stored in the file, *not* the ordering of the
+   blocks they are for.
+
+   The data file contains the following records.
+        data: {unit summary:object summary:program* function-data*}*
+	unit: header int32:checksum
+        function-data:	announce_function present counts
+	announce_function: header int32:ident
+		int32:lineno_checksum int32:cfg_checksum
+	present: header int32:present
+	counts: header int64:count*
+	summary: int32:checksum {count-summary}GCOV_COUNTERS_SUMMABLE
+	count-summary:	int32:num int32:runs int64:sum
+			int64:max int64:sum_max histogram
+        histogram: {int32:bitvector}8 histogram-buckets*
+        histogram-buckets: int32:num int64:min int64:sum
+
+   The ANNOUNCE_FUNCTION record is the same as that in the note file,
+   but without the source location.  The COUNTS gives the
+   counter values for instrumented features.  The about the whole
+   program.  The checksum is used for whole program summaries, and
+   disambiguates different programs which include the same
+   instrumented object file.  There may be several program summaries,
+   each with a unique checksum.  The object summary's checksum is
+   zero.  Note that the data file might contain information from
+   several runs concatenated, or the data might be merged.
+
+   This file is included by both the compiler, gcov tools and the
+   runtime support library libgcov. IN_LIBGCOV and IN_GCOV are used to
+   distinguish which case is which.  If IN_LIBGCOV is nonzero,
+   libgcov is being built. If IN_GCOV is nonzero, the gcov tools are
+   being built. Otherwise the compiler is being built. IN_GCOV may be
+   positive or negative. If positive, we are compiling a tool that
+   requires additional functions (see the code for knowledge of what
+   those functions are).  */
+
+#ifndef GCC_GCOV_IO_H
+#define GCC_GCOV_IO_H
+
+#ifndef IN_LIBGCOV
+/* About the host */
+
+typedef unsigned gcov_unsigned_t;
+typedef unsigned gcov_position_t;
+/* gcov_type is typedef'd elsewhere for the compiler */
+#if IN_GCOV
+#define GCOV_LINKAGE static
+typedef int64_t gcov_type;
+typedef uint64_t gcov_type_unsigned;
+#if IN_GCOV > 0
+#include <sys/types.h>
+#endif
+#endif
+
+#if defined (HOST_HAS_F_SETLKW)
+#define GCOV_LOCKED 1
+#else
+#define GCOV_LOCKED 0
+#endif
+
+#define ATTRIBUTE_HIDDEN
+
+#endif /* !IN_LIBGOCV */
+
+#ifndef GCOV_LINKAGE
+#define GCOV_LINKAGE extern
+#endif
+
+#if IN_LIBGCOV
+#define gcov_nonruntime_assert(EXPR) ((void)(0 && (EXPR)))
+#else
+#define gcov_nonruntime_assert(EXPR) gcc_assert (EXPR)
+#define gcov_error(...) fatal_error (input_location, __VA_ARGS__)
+#endif
+
+/* File suffixes.  */
+#define GCOV_DATA_SUFFIX ".gcda"
+#define GCOV_NOTE_SUFFIX ".gcno"
+
+/* File magic. Must not be palindromes.  */
+#define GCOV_DATA_MAGIC ((gcov_unsigned_t)0x67636461) /* "gcda" */
+#define GCOV_NOTE_MAGIC ((gcov_unsigned_t)0x67636e6f) /* "gcno" */
+
+/* gcov-iov.h is automatically generated by the makefile from
+   version.c, it looks like
+   	#define GCOV_VERSION ((gcov_unsigned_t)0x89abcdef)
+*/
+#include "gcov-iov.h"
+
+/* Convert a magic or version number to a 4 character string.  */
+#define GCOV_UNSIGNED2STRING(ARRAY,VALUE)	\
+  ((ARRAY)[0] = (char)((VALUE) >> 24),		\
+   (ARRAY)[1] = (char)((VALUE) >> 16),		\
+   (ARRAY)[2] = (char)((VALUE) >> 8),		\
+   (ARRAY)[3] = (char)((VALUE) >> 0))
+
+/* The record tags.  Values [1..3f] are for tags which may be in either
+   file.  Values [41..9f] for those in the note file and [a1..ff] for
+   the data file.  The tag value zero is used as an explicit end of
+   file marker -- it is not required to be present.  */
+
+#define GCOV_TAG_FUNCTION	 ((gcov_unsigned_t)0x01000000)
+#define GCOV_TAG_FUNCTION_LENGTH (3)
+#define GCOV_TAG_BLOCKS		 ((gcov_unsigned_t)0x01410000)
+#define GCOV_TAG_BLOCKS_LENGTH(NUM) (NUM)
+#define GCOV_TAG_BLOCKS_NUM(LENGTH) (LENGTH)
+#define GCOV_TAG_ARCS		 ((gcov_unsigned_t)0x01430000)
+#define GCOV_TAG_ARCS_LENGTH(NUM)  (1 + (NUM) * 2)
+#define GCOV_TAG_ARCS_NUM(LENGTH)  (((LENGTH) - 1) / 2)
+#define GCOV_TAG_LINES		 ((gcov_unsigned_t)0x01450000)
+#define GCOV_TAG_COUNTER_BASE 	 ((gcov_unsigned_t)0x01a10000)
+#define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 2)
+#define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2)
+#define GCOV_TAG_OBJECT_SUMMARY  ((gcov_unsigned_t)0xa1000000) /* Obsolete */
+#define GCOV_TAG_PROGRAM_SUMMARY ((gcov_unsigned_t)0xa3000000)
+#define GCOV_TAG_SUMMARY_LENGTH(NUM)  \
+        (1 + GCOV_COUNTERS_SUMMABLE * (10 + 3 * 2) + (NUM) * 5)
+#define GCOV_TAG_AFDO_FILE_NAMES ((gcov_unsigned_t)0xaa000000)
+#define GCOV_TAG_AFDO_FUNCTION ((gcov_unsigned_t)0xac000000)
+#define GCOV_TAG_AFDO_WORKING_SET ((gcov_unsigned_t)0xaf000000)
+
+
+/* Counters that are collected.  */
+
+#define DEF_GCOV_COUNTER(COUNTER, NAME, MERGE_FN) COUNTER,
+enum {
+#include "gcov-counter.def"
+GCOV_COUNTERS
+};
+#undef DEF_GCOV_COUNTER
+
+/* Counters which can be summaried.  */
+#define GCOV_COUNTERS_SUMMABLE	(GCOV_COUNTER_ARCS + 1)
+
+/* The first of counters used for value profiling.  They must form a
+   consecutive interval and their order must match the order of
+   HIST_TYPEs in value-prof.h.  */
+#define GCOV_FIRST_VALUE_COUNTER GCOV_COUNTERS_SUMMABLE
+
+/* The last of counters used for value profiling.  */
+#define GCOV_LAST_VALUE_COUNTER (GCOV_COUNTERS - 1)
+
+/* Number of counters used for value profiling.  */
+#define GCOV_N_VALUE_COUNTERS \
+  (GCOV_LAST_VALUE_COUNTER - GCOV_FIRST_VALUE_COUNTER + 1)
+
+/* The number of hottest callees to be tracked.  */
+#define GCOV_ICALL_TOPN_VAL  2
+
+/* The number of counter entries per icall callsite.  */
+#define GCOV_ICALL_TOPN_NCOUNTS (1 + GCOV_ICALL_TOPN_VAL * 4)
+
+/* Convert a counter index to a tag.  */
+#define GCOV_TAG_FOR_COUNTER(COUNT)				\
+	(GCOV_TAG_COUNTER_BASE + ((gcov_unsigned_t)(COUNT) << 17))
+/* Convert a tag to a counter.  */
+#define GCOV_COUNTER_FOR_TAG(TAG)					\
+	((unsigned)(((TAG) - GCOV_TAG_COUNTER_BASE) >> 17))
+/* Check whether a tag is a counter tag.  */
+#define GCOV_TAG_IS_COUNTER(TAG)				\
+	(!((TAG) & 0xFFFF) && GCOV_COUNTER_FOR_TAG (TAG) < GCOV_COUNTERS)
+
+/* The tag level mask has 1's in the position of the inner levels, &
+   the lsb of the current level, and zero on the current and outer
+   levels.  */
+#define GCOV_TAG_MASK(TAG) (((TAG) - 1) ^ (TAG))
+
+/* Return nonzero if SUB is an immediate subtag of TAG.  */
+#define GCOV_TAG_IS_SUBTAG(TAG,SUB)				\
+	(GCOV_TAG_MASK (TAG) >> 8 == GCOV_TAG_MASK (SUB) 	\
+	 && !(((SUB) ^ (TAG)) & ~GCOV_TAG_MASK (TAG)))
+
+/* Return nonzero if SUB is at a sublevel to TAG.  */
+#define GCOV_TAG_IS_SUBLEVEL(TAG,SUB)				\
+     	(GCOV_TAG_MASK (TAG) > GCOV_TAG_MASK (SUB))
+
+/* Basic block flags.  */
+#define GCOV_BLOCK_UNEXPECTED	(1 << 1)
+
+/* Arc flags.  */
+#define GCOV_ARC_ON_TREE 	(1 << 0)
+#define GCOV_ARC_FAKE		(1 << 1)
+#define GCOV_ARC_FALLTHROUGH	(1 << 2)
+
+/* Structured records.  */
+
+/* Structure used for each bucket of the log2 histogram of counter values.  */
+typedef struct
+{
+  /* Number of counters whose profile count falls within the bucket.  */
+  gcov_unsigned_t num_counters;
+  /* Smallest profile count included in this bucket.  */
+  gcov_type min_value;
+  /* Cumulative value of the profile counts in this bucket.  */
+  gcov_type cum_value;
+} gcov_bucket_type;
+
+/* For a log2 scale histogram with each range split into 4
+   linear sub-ranges, there will be at most 64 (max gcov_type bit size) - 1 log2
+   ranges since the lowest 2 log2 values share the lowest 4 linear
+   sub-range (values 0 - 3).  This is 252 total entries (63*4).  */
+
+#define GCOV_HISTOGRAM_SIZE 252
+
+/* How many unsigned ints are required to hold a bit vector of non-zero
+   histogram entries when the histogram is written to the gcov file.
+   This is essentially a ceiling divide by 32 bits.  */
+#define GCOV_HISTOGRAM_BITVECTOR_SIZE (GCOV_HISTOGRAM_SIZE + 31) / 32
+
+/* Cumulative counter data.  */
+struct gcov_ctr_summary
+{
+  gcov_unsigned_t num;		/* number of counters.  */
+  gcov_unsigned_t runs;		/* number of program runs */
+  gcov_type sum_all;		/* sum of all counters accumulated.  */
+  gcov_type run_max;		/* maximum value on a single run.  */
+  gcov_type sum_max;    	/* sum of individual run max values.  */
+  gcov_bucket_type histogram[GCOV_HISTOGRAM_SIZE]; /* histogram of
+                                                      counter values.  */
+};
+
+/* Object & program summary record.  */
+struct gcov_summary
+{
+  gcov_unsigned_t checksum;	/* checksum of program */
+  struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE];
+};
+
+#if !defined(inhibit_libc)
+
+/* Functions for reading and writing gcov files. In libgcov you can
+   open the file for reading then writing. Elsewhere you can open the
+   file either for reading or for writing. When reading a file you may
+   use the gcov_read_* functions, gcov_sync, gcov_position, &
+   gcov_error. When writing a file you may use the gcov_write
+   functions, gcov_seek & gcov_error. When a file is to be rewritten
+   you use the functions for reading, then gcov_rewrite then the
+   functions for writing.  Your file may become corrupted if you break
+   these invariants.  */
+
+#if !IN_LIBGCOV
+GCOV_LINKAGE int gcov_open (const char */*name*/, int /*direction*/);
+GCOV_LINKAGE int gcov_magic (gcov_unsigned_t, gcov_unsigned_t);
+#endif
+
+/* Available everywhere.  */
+GCOV_LINKAGE int gcov_close (void) ATTRIBUTE_HIDDEN;
+GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned (void) ATTRIBUTE_HIDDEN;
+GCOV_LINKAGE gcov_type gcov_read_counter (void) ATTRIBUTE_HIDDEN;
+GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *) ATTRIBUTE_HIDDEN;
+GCOV_LINKAGE const char *gcov_read_string (void);
+GCOV_LINKAGE void gcov_sync (gcov_position_t /*base*/,
+			     gcov_unsigned_t /*length */);
+
+#if !IN_GCOV
+/* Available outside gcov */
+GCOV_LINKAGE void gcov_write_unsigned (gcov_unsigned_t) ATTRIBUTE_HIDDEN;
+#endif
+
+#if !IN_GCOV && !IN_LIBGCOV
+/* Available only in compiler */
+GCOV_LINKAGE unsigned gcov_histo_index (gcov_type value);
+GCOV_LINKAGE void gcov_write_string (const char *);
+GCOV_LINKAGE gcov_position_t gcov_write_tag (gcov_unsigned_t);
+GCOV_LINKAGE void gcov_write_length (gcov_position_t /*position*/);
+#endif
+
+#if IN_GCOV <= 0 && !IN_LIBGCOV
+/* Available in gcov-dump and the compiler.  */
+
+/* Number of data points in the working set summary array. Using 128
+   provides information for at least every 1% increment of the total
+   profile size. The last entry is hardwired to 99.9% of the total.  */
+#define NUM_GCOV_WORKING_SETS 128
+
+/* Working set size statistics for a given percentage of the entire
+   profile (sum_all from the counter summary).  */
+typedef struct gcov_working_set_info
+{
+  /* Number of hot counters included in this working set.  */
+  unsigned num_counters;
+  /* Smallest counter included in this working set.  */
+  gcov_type min_counter;
+} gcov_working_set_t;
+
+GCOV_LINKAGE void compute_working_sets (const struct gcov_ctr_summary *summary,
+                                        gcov_working_set_t *gcov_working_sets);
+#endif
+
+#if IN_GCOV > 0
+/* Available in gcov */
+GCOV_LINKAGE time_t gcov_time (void);
+#endif
+
+#endif /* !inhibit_libc  */
+
+#endif /* GCC_GCOV_IO_H */
diff --git a/libgcov/include/gcov.h b/libgcov/include/gcov.h
new file mode 100644
index 0000000..0333ecc
--- /dev/null
+++ b/libgcov/include/gcov.h
@@ -0,0 +1,41 @@
+/* GCOV interface routines.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 3, or (at your option) any later
+   version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_GCOV_H
+#define GCC_GCOV_H
+
+/* Set all counters to zero.  */
+
+extern void __gcov_reset (void);
+
+/* Write profile information to a file.  */
+
+extern void __gcov_dump (void);
+
+/* Write profile information to a file and reset counters to zero.
+   The function does operations under a mutex.  */
+
+extern void __gcov_flush (void);
+
+#endif /* GCC_GCOV_H */
diff --git a/libgcov/include/gthr-default.h b/libgcov/include/gthr-default.h
new file mode 100644
index 0000000..a54a32e
--- /dev/null
+++ b/libgcov/include/gthr-default.h
@@ -0,0 +1,889 @@
+/* Threads compatibility routines for libgcc2 and libobjc.  */
+/* Compile this one with gcc.  */
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_GTHR_POSIX_H
+#define GCC_GTHR_POSIX_H
+
+/* POSIX threads specific definitions.
+   Easy, since the interface is just one-to-one mapping.  */
+
+#define __GTHREADS 1
+#define __GTHREADS_CXX0X 1
+
+#include <pthread.h>
+
+#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
+     || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
+# include <unistd.h>
+# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
+#  define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
+# else
+#  define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
+# endif
+#endif
+
+typedef pthread_t __gthread_t;
+typedef pthread_key_t __gthread_key_t;
+typedef pthread_once_t __gthread_once_t;
+typedef pthread_mutex_t __gthread_mutex_t;
+typedef pthread_mutex_t __gthread_recursive_mutex_t;
+typedef pthread_cond_t __gthread_cond_t;
+typedef struct timespec __gthread_time_t;
+
+/* POSIX like conditional variables are supported.  Please look at comments
+   in gthr.h for details. */
+#define __GTHREAD_HAS_COND	1
+
+#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
+#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
+#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
+#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
+#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
+#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
+#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#else
+#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
+#endif
+#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
+#define __GTHREAD_TIME_INIT {0,0}
+
+#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
+# undef __GTHREAD_MUTEX_INIT
+#endif
+#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
+# undef __GTHREAD_RECURSIVE_MUTEX_INIT
+# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
+# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
+#endif
+#ifdef _GTHREAD_USE_COND_INIT_FUNC
+# undef __GTHREAD_COND_INIT
+# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
+#endif
+
+#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
+# ifndef __gthrw_pragma
+#  define __gthrw_pragma(pragma)
+# endif
+# define __gthrw2(name,name2,type) \
+  static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
+  __gthrw_pragma(weak type)
+# define __gthrw_(name) __gthrw_ ## name
+#else
+# define __gthrw2(name,name2,type)
+# define __gthrw_(name) name
+#endif
+
+/* Typically, __gthrw_foo is a weak reference to symbol foo.  */
+#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
+
+__gthrw(pthread_once)
+__gthrw(pthread_getspecific)
+__gthrw(pthread_setspecific)
+
+__gthrw(pthread_create)
+__gthrw(pthread_join)
+__gthrw(pthread_equal)
+__gthrw(pthread_self)
+__gthrw(pthread_detach)
+#ifndef __BIONIC__
+__gthrw(pthread_cancel)
+#endif
+__gthrw(sched_yield)
+
+__gthrw(pthread_mutex_lock)
+__gthrw(pthread_mutex_trylock)
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+__gthrw(pthread_mutex_timedlock)
+#endif
+__gthrw(pthread_mutex_unlock)
+__gthrw(pthread_mutex_init)
+__gthrw(pthread_mutex_destroy)
+
+__gthrw(pthread_cond_init)
+__gthrw(pthread_cond_broadcast)
+__gthrw(pthread_cond_signal)
+__gthrw(pthread_cond_wait)
+__gthrw(pthread_cond_timedwait)
+__gthrw(pthread_cond_destroy)
+
+__gthrw(pthread_key_create)
+__gthrw(pthread_key_delete)
+__gthrw(pthread_mutexattr_init)
+__gthrw(pthread_mutexattr_settype)
+__gthrw(pthread_mutexattr_destroy)
+
+
+#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
+/* Objective-C.  */
+__gthrw(pthread_exit)
+#ifdef _POSIX_PRIORITY_SCHEDULING
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+__gthrw(sched_get_priority_max)
+__gthrw(sched_get_priority_min)
+#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+__gthrw(pthread_attr_destroy)
+__gthrw(pthread_attr_init)
+__gthrw(pthread_attr_setdetachstate)
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+__gthrw(pthread_getschedparam)
+__gthrw(pthread_setschedparam)
+#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _LIBOBJC || _LIBOBJC_WEAK */
+
+#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
+
+/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
+   -pthreads is not specified.  The functions are dummies and most return an
+   error value.  However pthread_once returns 0 without invoking the routine
+   it is passed so we cannot pretend that the interface is active if -pthreads
+   is not specified.  On Solaris 2.5.1, the interface is not exposed at all so
+   we need to play the usual game with weak symbols.  On Solaris 10 and up, a
+   working interface is always exposed.  On FreeBSD 6 and later, libc also
+   exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
+   to 9 does.  FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
+   which means the alternate __gthread_active_p below cannot be used there.  */
+
+#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
+
+static volatile int __gthread_active = -1;
+
+static void
+__gthread_trigger (void)
+{
+  __gthread_active = 1;
+}
+
+static inline int
+__gthread_active_p (void)
+{
+  static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
+  static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
+
+  /* Avoid reading __gthread_active twice on the main code path.  */
+  int __gthread_active_latest_value = __gthread_active;
+
+  /* This test is not protected to avoid taking a lock on the main code
+     path so every update of __gthread_active in a threaded program must
+     be atomic with regard to the result of the test.  */
+  if (__builtin_expect (__gthread_active_latest_value < 0, 0))
+    {
+      if (__gthrw_(pthread_once))
+	{
+	  /* If this really is a threaded program, then we must ensure that
+	     __gthread_active has been set to 1 before exiting this block.  */
+	  __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
+	  __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
+	  __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
+	}
+
+      /* Make sure we'll never enter this block again.  */
+      if (__gthread_active < 0)
+	__gthread_active = 0;
+
+      __gthread_active_latest_value = __gthread_active;
+    }
+
+  return __gthread_active_latest_value != 0;
+}
+
+#else /* neither FreeBSD nor Solaris */
+
+/* For a program to be multi-threaded the only thing that it certainly must
+   be using is pthread_create.  However, there may be other libraries that
+   intercept pthread_create with their own definitions to wrap pthreads
+   functionality for some purpose.  In those cases, pthread_create being
+   defined might not necessarily mean that libpthread is actually linked
+   in.
+
+   For the GNU C library, we can use a known internal name.  This is always
+   available in the ABI, but no other library would define it.  That is
+   ideal, since any public pthread function might be intercepted just as
+   pthread_create might be.  __pthread_key_create is an "internal"
+   implementation symbol, but it is part of the public exported ABI.  Also,
+   it's among the symbols that the static libpthread.a always links in
+   whenever pthread_create is used, so there is no danger of a false
+   negative result in any statically-linked, multi-threaded program.
+
+   For others, we choose pthread_cancel as a function that seems unlikely
+   to be redefined by an interceptor library.  The bionic (Android) C
+   library does not provide pthread_cancel, so we do use pthread_create
+   there (and interceptor libraries lose).  */
+
+#ifdef __GLIBC__
+__gthrw2(__gthrw_(__pthread_key_create),
+	 __pthread_key_create,
+	 pthread_key_create)
+# define GTHR_ACTIVE_PROXY	__gthrw_(__pthread_key_create)
+#elif defined (__BIONIC__)
+# define GTHR_ACTIVE_PROXY	__gthrw_(pthread_create)
+#else
+# define GTHR_ACTIVE_PROXY	__gthrw_(pthread_cancel)
+#endif
+
+static inline int
+__gthread_active_p (void)
+{
+  static void *const __gthread_active_ptr
+    = __extension__ (void *) &GTHR_ACTIVE_PROXY;
+  return __gthread_active_ptr != 0;
+}
+
+#endif /* FreeBSD or Solaris */
+
+#else /* not SUPPORTS_WEAK */
+
+/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
+   calls in shared flavors of the HP-UX C library.  Most of the stubs
+   have no functionality.  The details are described in the "libc cumulative
+   patch" for each subversion of HP-UX 11.  There are two special interfaces
+   provided for checking whether an application is linked to a shared pthread
+   library or not.  However, these interfaces aren't available in early
+   libpthread libraries.  We also need a test that works for archive
+   libraries.  We can't use pthread_once as some libc versions call the
+   init function.  We also can't use pthread_create or pthread_attr_init
+   as these create a thread and thereby prevent changing the default stack
+   size.  The function pthread_default_stacksize_np is available in both
+   the archive and shared versions of libpthread.   It can be used to
+   determine the default pthread stack size.  There is a stub in some
+   shared libc versions which returns a zero size if pthreads are not
+   active.  We provide an equivalent stub to handle cases where libc
+   doesn't provide one.  */
+
+#if defined(__hppa__) && defined(__hpux__)
+
+static volatile int __gthread_active = -1;
+
+static inline int
+__gthread_active_p (void)
+{
+  /* Avoid reading __gthread_active twice on the main code path.  */
+  int __gthread_active_latest_value = __gthread_active;
+  size_t __s;
+
+  if (__builtin_expect (__gthread_active_latest_value < 0, 0))
+    {
+      pthread_default_stacksize_np (0, &__s);
+      __gthread_active = __s ? 1 : 0;
+      __gthread_active_latest_value = __gthread_active;
+    }
+
+  return __gthread_active_latest_value != 0;
+}
+
+#else /* not hppa-hpux */
+
+static inline int
+__gthread_active_p (void)
+{
+  return 1;
+}
+
+#endif /* hppa-hpux */
+
+#endif /* SUPPORTS_WEAK */
+
+#ifdef _LIBOBJC
+
+/* This is the config.h file in libobjc/ */
+#include <config.h>
+
+#ifdef HAVE_SCHED_H
+# include <sched.h>
+#endif
+
+/* Key structure for maintaining thread specific storage */
+static pthread_key_t _objc_thread_storage;
+static pthread_attr_t _objc_thread_attribs;
+
+/* Thread local storage for a single thread */
+static void *thread_local_storage = NULL;
+
+/* Backend initialization functions */
+
+/* Initialize the threads subsystem.  */
+static inline int
+__gthread_objc_init_thread_system (void)
+{
+  if (__gthread_active_p ())
+    {
+      /* Initialize the thread storage key.  */
+      if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
+	{
+	  /* The normal default detach state for threads is
+	   * PTHREAD_CREATE_JOINABLE which causes threads to not die
+	   * when you think they should.  */
+	  if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
+	      && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
+					      PTHREAD_CREATE_DETACHED) == 0)
+	    return 0;
+	}
+    }
+
+  return -1;
+}
+
+/* Close the threads subsystem.  */
+static inline int
+__gthread_objc_close_thread_system (void)
+{
+  if (__gthread_active_p ()
+      && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
+      && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
+    return 0;
+
+  return -1;
+}
+
+/* Backend thread functions */
+
+/* Create a new thread of execution.  */
+static inline objc_thread_t
+__gthread_objc_thread_detach (void (*func)(void *), void *arg)
+{
+  objc_thread_t thread_id;
+  pthread_t new_thread_handle;
+
+  if (!__gthread_active_p ())
+    return NULL;
+
+  if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
+				  (void *) func, arg)))
+    thread_id = (objc_thread_t) new_thread_handle;
+  else
+    thread_id = NULL;
+
+  return thread_id;
+}
+
+/* Set the current thread's priority.  */
+static inline int
+__gthread_objc_thread_set_priority (int priority)
+{
+  if (!__gthread_active_p ())
+    return -1;
+  else
+    {
+#ifdef _POSIX_PRIORITY_SCHEDULING
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+      pthread_t thread_id = __gthrw_(pthread_self) ();
+      int policy;
+      struct sched_param params;
+      int priority_min, priority_max;
+
+      if (__gthrw_(pthread_getschedparam) (thread_id, &policy, &params) == 0)
+	{
+	  if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
+	    return -1;
+
+	  if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
+	    return -1;
+
+	  if (priority > priority_max)
+	    priority = priority_max;
+	  else if (priority < priority_min)
+	    priority = priority_min;
+	  params.sched_priority = priority;
+
+	  /*
+	   * The solaris 7 and several other man pages incorrectly state that
+	   * this should be a pointer to policy but pthread.h is universally
+	   * at odds with this.
+	   */
+	  if (__gthrw_(pthread_setschedparam) (thread_id, policy, &params) == 0)
+	    return 0;
+	}
+#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+      return -1;
+    }
+}
+
+/* Return the current thread's priority.  */
+static inline int
+__gthread_objc_thread_get_priority (void)
+{
+#ifdef _POSIX_PRIORITY_SCHEDULING
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+  if (__gthread_active_p ())
+    {
+      int policy;
+      struct sched_param params;
+
+      if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, &params) == 0)
+	return params.sched_priority;
+      else
+	return -1;
+    }
+  else
+#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+    return OBJC_THREAD_INTERACTIVE_PRIORITY;
+}
+
+/* Yield our process time to another thread.  */
+static inline void
+__gthread_objc_thread_yield (void)
+{
+  if (__gthread_active_p ())
+    __gthrw_(sched_yield) ();
+}
+
+/* Terminate the current thread.  */
+static inline int
+__gthread_objc_thread_exit (void)
+{
+  if (__gthread_active_p ())
+    /* exit the thread */
+    __gthrw_(pthread_exit) (&__objc_thread_exit_status);
+
+  /* Failed if we reached here */
+  return -1;
+}
+
+/* Returns an integer value which uniquely describes a thread.  */
+static inline objc_thread_t
+__gthread_objc_thread_id (void)
+{
+  if (__gthread_active_p ())
+    return (objc_thread_t) __gthrw_(pthread_self) ();
+  else
+    return (objc_thread_t) 1;
+}
+
+/* Sets the thread's local storage pointer.  */
+static inline int
+__gthread_objc_thread_set_data (void *value)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
+  else
+    {
+      thread_local_storage = value;
+      return 0;
+    }
+}
+
+/* Returns the thread's local storage pointer.  */
+static inline void *
+__gthread_objc_thread_get_data (void)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_getspecific) (_objc_thread_storage);
+  else
+    return thread_local_storage;
+}
+
+/* Backend mutex functions */
+
+/* Allocate a mutex.  */
+static inline int
+__gthread_objc_mutex_allocate (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ())
+    {
+      mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
+
+      if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
+	{
+	  objc_free (mutex->backend);
+	  mutex->backend = NULL;
+	  return -1;
+	}
+    }
+
+  return 0;
+}
+
+/* Deallocate a mutex.  */
+static inline int
+__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ())
+    {
+      int count;
+
+      /*
+       * Posix Threads specifically require that the thread be unlocked
+       * for __gthrw_(pthread_mutex_destroy) to work.
+       */
+
+      do
+	{
+	  count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
+	  if (count < 0)
+	    return -1;
+	}
+      while (count);
+
+      if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
+	return -1;
+
+      objc_free (mutex->backend);
+      mutex->backend = NULL;
+    }
+  return 0;
+}
+
+/* Grab a lock on a mutex.  */
+static inline int
+__gthread_objc_mutex_lock (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ()
+      && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
+    {
+      return -1;
+    }
+
+  return 0;
+}
+
+/* Try to grab a lock on a mutex.  */
+static inline int
+__gthread_objc_mutex_trylock (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ()
+      && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
+    {
+      return -1;
+    }
+
+  return 0;
+}
+
+/* Unlock the mutex */
+static inline int
+__gthread_objc_mutex_unlock (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ()
+      && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
+    {
+      return -1;
+    }
+
+  return 0;
+}
+
+/* Backend condition mutex functions */
+
+/* Allocate a condition.  */
+static inline int
+__gthread_objc_condition_allocate (objc_condition_t condition)
+{
+  if (__gthread_active_p ())
+    {
+      condition->backend = objc_malloc (sizeof (pthread_cond_t));
+
+      if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
+	{
+	  objc_free (condition->backend);
+	  condition->backend = NULL;
+	  return -1;
+	}
+    }
+
+  return 0;
+}
+
+/* Deallocate a condition.  */
+static inline int
+__gthread_objc_condition_deallocate (objc_condition_t condition)
+{
+  if (__gthread_active_p ())
+    {
+      if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
+	return -1;
+
+      objc_free (condition->backend);
+      condition->backend = NULL;
+    }
+  return 0;
+}
+
+/* Wait on the condition */
+static inline int
+__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
+			      (pthread_mutex_t *) mutex->backend);
+  else
+    return 0;
+}
+
+/* Wake up all threads waiting on this condition.  */
+static inline int
+__gthread_objc_condition_broadcast (objc_condition_t condition)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
+  else
+    return 0;
+}
+
+/* Wake up one thread waiting on this condition.  */
+static inline int
+__gthread_objc_condition_signal (objc_condition_t condition)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
+  else
+    return 0;
+}
+
+#else /* _LIBOBJC */
+
+static inline int
+__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
+		  void *__args)
+{
+  return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
+}
+
+static inline int
+__gthread_join (__gthread_t __threadid, void **__value_ptr)
+{
+  return __gthrw_(pthread_join) (__threadid, __value_ptr);
+}
+
+static inline int
+__gthread_detach (__gthread_t __threadid)
+{
+  return __gthrw_(pthread_detach) (__threadid);
+}
+
+static inline int
+__gthread_equal (__gthread_t __t1, __gthread_t __t2)
+{
+  return __gthrw_(pthread_equal) (__t1, __t2);
+}
+
+static inline __gthread_t
+__gthread_self (void)
+{
+  return __gthrw_(pthread_self) ();
+}
+
+static inline int
+__gthread_yield (void)
+{
+  return __gthrw_(sched_yield) ();
+}
+
+static inline int
+__gthread_once (__gthread_once_t *__once, void (*__func) (void))
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_once) (__once, __func);
+  else
+    return -1;
+}
+
+static inline int
+__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
+{
+  return __gthrw_(pthread_key_create) (__key, __dtor);
+}
+
+static inline int
+__gthread_key_delete (__gthread_key_t __key)
+{
+  return __gthrw_(pthread_key_delete) (__key);
+}
+
+static inline void *
+__gthread_getspecific (__gthread_key_t __key)
+{
+  return __gthrw_(pthread_getspecific) (__key);
+}
+
+static inline int
+__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
+{
+  return __gthrw_(pthread_setspecific) (__key, __ptr);
+}
+
+static inline void
+__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    __gthrw_(pthread_mutex_init) (__mutex, NULL);
+}
+
+static inline int
+__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_destroy) (__mutex);
+  else
+    return 0;
+}
+
+static inline int
+__gthread_mutex_lock (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_lock) (__mutex);
+  else
+    return 0;
+}
+
+static inline int
+__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_trylock) (__mutex);
+  else
+    return 0;
+}
+
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+static inline int
+__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
+			   const __gthread_time_t *__abs_timeout)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
+  else
+    return 0;
+}
+#endif
+
+static inline int
+__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_unlock) (__mutex);
+  else
+    return 0;
+}
+
+#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
+  || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
+static inline int
+__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    {
+      pthread_mutexattr_t __attr;
+      int __r;
+
+      __r = __gthrw_(pthread_mutexattr_init) (&__attr);
+      if (!__r)
+	__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
+						   PTHREAD_MUTEX_RECURSIVE);
+      if (!__r)
+	__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
+      if (!__r)
+	__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
+      return __r;
+    }
+  return 0;
+}
+#endif
+
+static inline int
+__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_lock (__mutex);
+}
+
+static inline int
+__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_trylock (__mutex);
+}
+
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+static inline int
+__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
+				     const __gthread_time_t *__abs_timeout)
+{
+  return __gthread_mutex_timedlock (__mutex, __abs_timeout);
+}
+#endif
+
+static inline int
+__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_unlock (__mutex);
+}
+
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_destroy (__mutex);
+}
+
+#ifdef _GTHREAD_USE_COND_INIT_FUNC
+static inline void
+__gthread_cond_init_function (__gthread_cond_t *__cond)
+{
+  if (__gthread_active_p ())
+    __gthrw_(pthread_cond_init) (__cond, NULL);
+}
+#endif
+
+static inline int
+__gthread_cond_broadcast (__gthread_cond_t *__cond)
+{
+  return __gthrw_(pthread_cond_broadcast) (__cond);
+}
+
+static inline int
+__gthread_cond_signal (__gthread_cond_t *__cond)
+{
+  return __gthrw_(pthread_cond_signal) (__cond);
+}
+
+static inline int
+__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
+{
+  return __gthrw_(pthread_cond_wait) (__cond, __mutex);
+}
+
+static inline int
+__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
+			  const __gthread_time_t *__abs_timeout)
+{
+  return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
+}
+
+static inline int
+__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
+			       __gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_cond_wait (__cond, __mutex);
+}
+
+static inline int
+__gthread_cond_destroy (__gthread_cond_t* __cond)
+{
+  return __gthrw_(pthread_cond_destroy) (__cond);
+}
+
+#endif /* _LIBOBJC */
+
+#endif /* ! GCC_GTHR_POSIX_H */
diff --git a/libgcov/include/gthr.h b/libgcov/include/gthr.h
new file mode 100644
index 0000000..ed22dc9
--- /dev/null
+++ b/libgcov/include/gthr.h
@@ -0,0 +1,154 @@
+/* Threads compatibility routines for libgcc2.  */
+/* Compile this one with gcc.  */
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_GTHR_H
+#define GCC_GTHR_H
+
+#ifndef HIDE_EXPORTS
+#pragma GCC visibility push(default)
+#endif
+
+/* If this file is compiled with threads support, it must
+       #define __GTHREADS 1
+   to indicate that threads support is present.  Also it has define
+   function
+     int __gthread_active_p ()
+   that returns 1 if thread system is active, 0 if not.
+
+   The threads interface must define the following types:
+     __gthread_key_t
+     __gthread_once_t
+     __gthread_mutex_t
+     __gthread_recursive_mutex_t
+
+   The threads interface must define the following macros:
+
+     __GTHREAD_ONCE_INIT
+     		to initialize __gthread_once_t
+     __GTHREAD_MUTEX_INIT
+     		to initialize __gthread_mutex_t to get a fast
+		non-recursive mutex.
+     __GTHREAD_MUTEX_INIT_FUNCTION
+		to initialize __gthread_mutex_t to get a fast
+		non-recursive mutex.
+		Define this to a function which looks like this:
+		  void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
+     		Some systems can't initialize a mutex without a
+		function call.  Don't define __GTHREAD_MUTEX_INIT in this case.
+     __GTHREAD_RECURSIVE_MUTEX_INIT
+     __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
+     		as above, but for a recursive mutex.
+
+   The threads interface must define the following static functions:
+
+     int __gthread_once (__gthread_once_t *once, void (*func) ())
+
+     int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
+     int __gthread_key_delete (__gthread_key_t key)
+
+     void *__gthread_getspecific (__gthread_key_t key)
+     int __gthread_setspecific (__gthread_key_t key, const void *ptr)
+
+     int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
+     int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
+
+     int __gthread_mutex_lock (__gthread_mutex_t *mutex);
+     int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
+     int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
+
+     int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
+     int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
+     int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
+
+   The following are supported in POSIX threads only. They are required to
+   fix a deadlock in static initialization inside libsupc++. The header file
+   gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
+   features are supported.
+
+   Types:
+     __gthread_cond_t
+
+   Macros:
+     __GTHREAD_COND_INIT
+     __GTHREAD_COND_INIT_FUNCTION
+
+   Interface:
+     int __gthread_cond_broadcast (__gthread_cond_t *cond);
+     int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
+     int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
+					__gthread_recursive_mutex_t *mutex);
+
+   All functions returning int should return zero on success or the error
+   number.  If the operation is not supported, -1 is returned.
+
+   If the following are also defined, you should
+     #define __GTHREADS_CXX0X 1
+   to enable the c++0x thread library.
+
+   Types:
+     __gthread_t
+     __gthread_time_t
+
+   Interface:
+     int __gthread_create (__gthread_t *thread, void *(*func) (void*),
+                           void *args);
+     int __gthread_join (__gthread_t thread, void **value_ptr);
+     int __gthread_detach (__gthread_t thread);
+     int __gthread_equal (__gthread_t t1, __gthread_t t2);
+     __gthread_t __gthread_self (void);
+     int __gthread_yield (void);
+
+     int __gthread_mutex_timedlock (__gthread_mutex_t *m,
+                                    const __gthread_time_t *abs_timeout);
+     int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
+                                          const __gthread_time_t *abs_time);
+
+     int __gthread_cond_signal (__gthread_cond_t *cond);
+     int __gthread_cond_timedwait (__gthread_cond_t *cond,
+                                   __gthread_mutex_t *mutex,
+                                   const __gthread_time_t *abs_timeout);
+
+*/
+
+#if SUPPORTS_WEAK
+/* The pe-coff weak support isn't fully compatible to ELF's weak.
+   For static libraries it might would work, but as we need to deal
+   with shared versions too, we disable it for mingw-targets.  */
+#ifdef __MINGW32__
+#undef GTHREAD_USE_WEAK
+#define GTHREAD_USE_WEAK 0
+#endif
+
+#ifndef GTHREAD_USE_WEAK
+#define GTHREAD_USE_WEAK 1
+#endif
+#endif
+#include "gthr-default.h"
+
+#ifndef HIDE_EXPORTS
+#pragma GCC visibility pop
+#endif
+
+#endif /* ! GCC_GTHR_H */
diff --git a/libgcov/include/hashtab.h b/libgcov/include/hashtab.h
new file mode 100644
index 0000000..b5682f8
--- /dev/null
+++ b/libgcov/include/hashtab.h
@@ -0,0 +1,204 @@
+/* An expandable hash tables datatype.  
+   Copyright (C) 1999-2017 Free Software Foundation, Inc.
+   Contributed by Vladimir Makarov (vmakarov@cygnus.com).
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* This package implements basic hash table functionality.  It is possible
+   to search for an entry, create an entry and destroy an entry.
+
+   Elements in the table are generic pointers.
+
+   The size of the table is not fixed; if the occupancy of the table
+   grows too high the hash table will be expanded.
+
+   The abstract data implementation is based on generalized Algorithm D
+   from Knuth's book "The art of computer programming".  Hash table is
+   expanded by creation of new hash table and transferring elements from
+   the old table to the new table.  */
+
+#ifndef __HASHTAB_H__
+#define __HASHTAB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "ansidecl.h"
+
+/* The type for a hash code.  */
+typedef unsigned int hashval_t;
+
+/* Callback function pointer types.  */
+
+/* Calculate hash of a table entry.  */
+typedef hashval_t (*htab_hash) (const void *);
+
+/* Compare a table entry with a possible entry.  The entry already in
+   the table always comes first, so the second element can be of a
+   different type (but in this case htab_find and htab_find_slot
+   cannot be used; instead the variants that accept a hash value
+   must be used).  */
+typedef int (*htab_eq) (const void *, const void *);
+
+/* Cleanup function called whenever a live element is removed from
+   the hash table.  */
+typedef void (*htab_del) (void *);
+  
+/* Function called by htab_traverse for each live element.  The first
+   arg is the slot of the element (which can be passed to htab_clear_slot
+   if desired), the second arg is the auxiliary pointer handed to
+   htab_traverse.  Return 1 to continue scan, 0 to stop.  */
+typedef int (*htab_trav) (void **, void *);
+
+/* Memory-allocation function, with the same functionality as calloc().
+   Iff it returns NULL, the hash table implementation will pass an error
+   code back to the user, so if your code doesn't handle errors,
+   best if you use xcalloc instead.  */
+typedef void *(*htab_alloc) (size_t, size_t);
+
+/* We also need a free() routine.  */
+typedef void (*htab_free) (void *);
+
+/* Memory allocation and deallocation; variants which take an extra
+   argument.  */
+typedef void *(*htab_alloc_with_arg) (void *, size_t, size_t);
+typedef void (*htab_free_with_arg) (void *, void *);
+
+/* This macro defines reserved value for empty table entry.  */
+
+#define HTAB_EMPTY_ENTRY    ((PTR) 0)
+
+/* This macro defines reserved value for table entry which contained
+   a deleted element. */
+
+#define HTAB_DELETED_ENTRY  ((PTR) 1)
+
+/* Hash tables are of the following type.  The structure
+   (implementation) of this type is not needed for using the hash
+   tables.  All work with hash table should be executed only through
+   functions mentioned below.  The size of this structure is subject to
+   change.  */
+
+struct htab {
+  /* Pointer to hash function.  */
+  htab_hash hash_f;
+
+  /* Pointer to comparison function.  */
+  htab_eq eq_f;
+
+  /* Pointer to cleanup function.  */
+  htab_del del_f;
+
+  /* Table itself.  */
+  void **entries;
+
+  /* Current size (in entries) of the hash table.  */
+  size_t size;
+
+  /* Current number of elements including also deleted elements.  */
+  size_t n_elements;
+
+  /* Current number of deleted elements in the table.  */
+  size_t n_deleted;
+
+  /* The following member is used for debugging. Its value is number
+     of all calls of `htab_find_slot' for the hash table. */
+  unsigned int searches;
+
+  /* The following member is used for debugging.  Its value is number
+     of collisions fixed for time of work with the hash table. */
+  unsigned int collisions;
+
+  /* Pointers to allocate/free functions.  */
+  htab_alloc alloc_f;
+  htab_free free_f;
+
+  /* Alternate allocate/free functions, which take an extra argument.  */
+  void *alloc_arg;
+  htab_alloc_with_arg alloc_with_arg_f;
+  htab_free_with_arg free_with_arg_f;
+
+  /* Current size (in entries) of the hash table, as an index into the
+     table of primes.  */
+  unsigned int size_prime_index;
+};
+
+typedef struct htab *htab_t;
+
+/* An enum saying whether we insert into the hash table or not.  */
+enum insert_option {NO_INSERT, INSERT};
+
+/* The prototypes of the package functions. */
+
+extern htab_t	htab_create_alloc  (size_t, htab_hash,
+                                    htab_eq, htab_del,
+                                    htab_alloc, htab_free);
+
+extern htab_t	htab_create_alloc_ex (size_t, htab_hash,
+                                      htab_eq, htab_del,
+                                      void *, htab_alloc_with_arg,
+                                      htab_free_with_arg);
+
+extern htab_t  htab_create_typed_alloc (size_t, htab_hash, htab_eq, htab_del,
+					htab_alloc, htab_alloc, htab_free);
+
+/* Backward-compatibility functions.  */
+extern htab_t htab_create (size_t, htab_hash, htab_eq, htab_del);
+extern htab_t htab_try_create (size_t, htab_hash, htab_eq, htab_del);
+
+extern void	htab_set_functions_ex (htab_t, htab_hash,
+                                       htab_eq, htab_del,
+                                       void *, htab_alloc_with_arg,
+                                       htab_free_with_arg);
+
+extern void	htab_delete (htab_t);
+extern void	htab_empty (htab_t);
+
+extern void *	htab_find (htab_t, const void *);
+extern void **	htab_find_slot (htab_t, const void *, enum insert_option);
+extern void *	htab_find_with_hash (htab_t, const void *, hashval_t);
+extern void **	htab_find_slot_with_hash (htab_t, const void *,
+					  hashval_t, enum insert_option);
+extern void	htab_clear_slot	(htab_t, void **);
+extern void	htab_remove_elt	(htab_t, void *);
+extern void	htab_remove_elt_with_hash (htab_t, void *, hashval_t);
+
+extern void	htab_traverse (htab_t, htab_trav, void *);
+extern void	htab_traverse_noresize (htab_t, htab_trav, void *);
+
+extern size_t	htab_size (htab_t);
+extern size_t	htab_elements (htab_t);
+extern double	htab_collisions	(htab_t);
+
+/* A hash function for pointers.  */
+extern htab_hash htab_hash_pointer;
+
+/* An equality function for pointers.  */
+extern htab_eq htab_eq_pointer;
+
+/* A hash function for null-terminated strings.  */
+extern hashval_t htab_hash_string (const void *);
+
+/* An iterative hash function for arbitrary data.  */
+extern hashval_t iterative_hash (const void *, size_t, hashval_t);
+/* Shorthand for hashing something with an intrinsic size.  */
+#define iterative_hash_object(OB,INIT) iterative_hash (&OB, sizeof (OB), INIT)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __HASHTAB_H */
diff --git a/libgcov/include/libgcov.h b/libgcov/include/libgcov.h
new file mode 100644
index 0000000..eb5a914
--- /dev/null
+++ b/libgcov/include/libgcov.h
@@ -0,0 +1,346 @@
+/* Header file for libgcov-*.c.
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 3, or (at your option) any later
+   version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_LIBGCOV_H
+#define GCC_LIBGCOV_H
+
+/* work around the poisoned malloc/calloc in system.h.  */
+#ifndef xmalloc
+#define xmalloc malloc
+#endif
+#ifndef xcalloc
+#define xcalloc calloc
+#endif
+
+#ifndef IN_GCOV_TOOL
+/* About the target.  */
+/* This path will be used by libgcov runtime.  */
+
+#include "tconfig.h"
+#include "auto-target.h"
+#include "tsystem.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "libgcc_tm.h"
+#include "gcov.h"
+
+#if __CHAR_BIT__ == 8
+typedef unsigned gcov_unsigned_t __attribute__ ((mode (SI)));
+typedef unsigned gcov_position_t __attribute__ ((mode (SI)));
+#if LONG_LONG_TYPE_SIZE > 32
+typedef signed gcov_type __attribute__ ((mode (DI)));
+typedef unsigned gcov_type_unsigned __attribute__ ((mode (DI)));
+#else
+typedef signed gcov_type __attribute__ ((mode (SI)));
+typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI)));
+#endif
+#else
+#if __CHAR_BIT__ == 16
+typedef unsigned gcov_unsigned_t __attribute__ ((mode (HI)));
+typedef unsigned gcov_position_t __attribute__ ((mode (HI)));
+#if LONG_LONG_TYPE_SIZE > 32
+typedef signed gcov_type __attribute__ ((mode (SI)));
+typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI)));
+#else
+typedef signed gcov_type __attribute__ ((mode (HI)));
+typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI)));
+#endif
+#else
+typedef unsigned gcov_unsigned_t __attribute__ ((mode (QI)));
+typedef unsigned gcov_position_t __attribute__ ((mode (QI)));
+#if LONG_LONG_TYPE_SIZE > 32
+typedef signed gcov_type __attribute__ ((mode (HI)));
+typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI)));
+#else
+typedef signed gcov_type __attribute__ ((mode (QI)));
+typedef unsigned gcov_type_unsigned __attribute__ ((mode (QI)));
+#endif
+#endif
+#endif
+
+#if defined (TARGET_POSIX_IO)
+#define GCOV_LOCKED 1
+#else
+#define GCOV_LOCKED 0
+#endif
+
+/* In libgcov we need these functions to be extern, so prefix them with
+   __gcov.  In libgcov they must also be hidden so that the instance in
+   the executable is not also used in a DSO.  */
+#define gcov_var __gcov_var
+#define gcov_open __gcov_open
+#define gcov_close __gcov_close
+#define gcov_write_tag_length __gcov_write_tag_length
+#define gcov_position __gcov_position
+#define gcov_seek __gcov_seek
+#define gcov_rewrite __gcov_rewrite
+#define gcov_is_error __gcov_is_error
+#define gcov_write_unsigned __gcov_write_unsigned
+#define gcov_write_counter __gcov_write_counter
+#define gcov_write_summary __gcov_write_summary
+#define gcov_read_unsigned __gcov_read_unsigned
+#define gcov_read_counter __gcov_read_counter
+#define gcov_read_summary __gcov_read_summary
+#define gcov_sort_n_vals __gcov_sort_n_vals
+
+#else /* IN_GCOV_TOOL */
+/* About the host.  */
+/* This path will be compiled for the host and linked into
+   gcov-tool binary.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+
+typedef unsigned gcov_unsigned_t;
+typedef unsigned gcov_position_t;
+/* gcov_type is typedef'd elsewhere for the compiler */
+#if defined (HOST_HAS_F_SETLKW)
+#define GCOV_LOCKED 1
+#else
+#define GCOV_LOCKED 0
+#endif
+
+/* Some Macros specific to gcov-tool.  */
+
+#define L_gcov 1
+#define L_gcov_merge_add 1
+#define L_gcov_merge_single 1
+#define L_gcov_merge_ior 1
+#define L_gcov_merge_time_profile 1
+#define L_gcov_merge_icall_topn 1
+
+extern gcov_type gcov_read_counter_mem ();
+extern unsigned gcov_get_merge_weight ();
+extern struct gcov_info *gcov_list;
+
+#endif /* !IN_GCOV_TOOL */
+
+#if defined(inhibit_libc)
+#define IN_LIBGCOV (-1)
+#else
+#define IN_LIBGCOV 1
+#if defined(L_gcov)
+#define GCOV_LINKAGE /* nothing */
+#endif
+#endif
+
+/* Poison these, so they don't accidentally slip in.  */
+#pragma GCC poison gcov_write_string gcov_write_tag gcov_write_length
+#pragma GCC poison gcov_time gcov_magic
+
+#ifdef HAVE_GAS_HIDDEN
+#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
+#else
+#define ATTRIBUTE_HIDDEN
+#endif
+
+#include "gcov-io.h"
+
+/* Structures embedded in coveraged program.  The structures generated
+   by write_profile must match these.  */
+
+/* Information about counters for a single function.  */
+struct gcov_ctr_info
+{
+  gcov_unsigned_t num;		/* number of counters.  */
+  gcov_type *values;		/* their values.  */
+};
+
+/* Information about a single function.  This uses the trailing array
+   idiom. The number of counters is determined from the merge pointer
+   array in gcov_info.  The key is used to detect which of a set of
+   comdat functions was selected -- it points to the gcov_info object
+   of the object file containing the selected comdat function.  */
+
+struct gcov_fn_info
+{
+  const struct gcov_info *key;		/* comdat key */
+  gcov_unsigned_t ident;		/* unique ident of function */
+  gcov_unsigned_t lineno_checksum;	/* function lineo_checksum */
+  gcov_unsigned_t cfg_checksum;		/* function cfg checksum */
+  struct gcov_ctr_info ctrs[1];		/* instrumented counters */
+};
+
+/* Type of function used to merge counters.  */
+typedef void (*gcov_merge_fn) (gcov_type *, gcov_unsigned_t);
+
+/* Information about a single object file.  */
+struct gcov_info
+{
+  gcov_unsigned_t version;	/* expected version number */
+  struct gcov_info *next;	/* link to next, used by libgcov */
+
+  gcov_unsigned_t stamp;	/* uniquifying time stamp */
+  const char *filename;		/* output file name */
+
+  gcov_merge_fn merge[GCOV_COUNTERS];  /* merge functions (null for
+					  unused) */
+  
+  unsigned n_functions;		/* number of functions */
+
+#ifndef IN_GCOV_TOOL
+  const struct gcov_fn_info *const *functions; /* pointer to pointers
+                                                  to function information  */
+#else
+  const struct gcov_fn_info **functions;
+#endif /* !IN_GCOV_TOOL */
+};
+
+/* Root of a program/shared-object state */
+struct gcov_root
+{
+  struct gcov_info *list;
+  unsigned dumped : 1;	/* counts have been dumped.  */
+  unsigned run_counted : 1;  /* run has been accounted for.  */
+  struct gcov_root *next;
+  struct gcov_root *prev;
+};
+
+extern struct gcov_root __gcov_root ATTRIBUTE_HIDDEN;
+
+struct gcov_master
+{
+  gcov_unsigned_t version;
+  struct gcov_root *root;
+};
+  
+/* Exactly one of these will be active in the process.  */
+extern struct gcov_master __gcov_master;
+
+/* Dump a set of gcov objects.  */
+extern void __gcov_dump_one (struct gcov_root *) ATTRIBUTE_HIDDEN;
+
+/* Register a new object file module.  */
+extern void __gcov_init (struct gcov_info *) ATTRIBUTE_HIDDEN;
+
+/* GCOV exit function registered via a static destructor.  */
+extern void __gcov_exit (void) ATTRIBUTE_HIDDEN;
+
+/* Function to reset all counters to 0.  Both externally visible (and
+   overridable) and internal version.  */
+extern void __gcov_reset_int (void) ATTRIBUTE_HIDDEN;
+
+/* User function to enable early write of profile information so far.  */
+extern void __gcov_dump_int (void) ATTRIBUTE_HIDDEN;
+
+/* The merge function that just sums the counters.  */
+extern void __gcov_merge_add (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
+
+/* The merge function to select the minimum valid counter value.  */
+extern void __gcov_merge_time_profile (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
+
+/* The merge function to choose the most common value.  */
+extern void __gcov_merge_single (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
+
+/* The merge function that just ors the counters together.  */
+extern void __gcov_merge_ior (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
+
+/* The merge function is used for topn indirect call counters.  */
+extern void __gcov_merge_icall_topn (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
+
+/* The profiler functions.  */
+extern void __gcov_interval_profiler (gcov_type *, gcov_type, int, unsigned);
+extern void __gcov_interval_profiler_atomic (gcov_type *, gcov_type, int,
+					     unsigned);
+extern void __gcov_pow2_profiler (gcov_type *, gcov_type);
+extern void __gcov_pow2_profiler_atomic (gcov_type *, gcov_type);
+extern void __gcov_one_value_profiler (gcov_type *, gcov_type);
+extern void __gcov_one_value_profiler_atomic (gcov_type *, gcov_type);
+extern void __gcov_indirect_call_profiler_v2 (gcov_type, void *);
+extern void __gcov_time_profiler (gcov_type *);
+extern void __gcov_time_profiler_atomic (gcov_type *);
+extern void __gcov_average_profiler (gcov_type *, gcov_type);
+extern void __gcov_average_profiler_atomic (gcov_type *, gcov_type);
+extern void __gcov_ior_profiler (gcov_type *, gcov_type);
+extern void __gcov_ior_profiler_atomic (gcov_type *, gcov_type);
+extern void __gcov_indirect_call_topn_profiler (gcov_type, void *);
+extern void gcov_sort_n_vals (gcov_type *, int);
+
+#ifndef inhibit_libc
+/* The wrappers around some library functions..  */
+extern pid_t __gcov_fork (void) ATTRIBUTE_HIDDEN;
+extern int __gcov_execl (const char *, char *, ...) ATTRIBUTE_HIDDEN;
+extern int __gcov_execlp (const char *, char *, ...) ATTRIBUTE_HIDDEN;
+extern int __gcov_execle (const char *, char *, ...) ATTRIBUTE_HIDDEN;
+extern int __gcov_execv (const char *, char *const []) ATTRIBUTE_HIDDEN;
+extern int __gcov_execvp (const char *, char *const []) ATTRIBUTE_HIDDEN;
+extern int __gcov_execve (const char *, char  *const [], char *const [])
+  ATTRIBUTE_HIDDEN;
+
+/* Functions that only available in libgcov.  */
+GCOV_LINKAGE int gcov_open (const char */*name*/) ATTRIBUTE_HIDDEN;
+GCOV_LINKAGE void gcov_write_counter (gcov_type) ATTRIBUTE_HIDDEN;
+GCOV_LINKAGE void gcov_write_tag_length (gcov_unsigned_t, gcov_unsigned_t)
+    ATTRIBUTE_HIDDEN;
+GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/,
+                                      const struct gcov_summary *)
+    ATTRIBUTE_HIDDEN;
+GCOV_LINKAGE void gcov_seek (gcov_position_t /*position*/) ATTRIBUTE_HIDDEN;
+GCOV_LINKAGE void gcov_rewrite (void) ATTRIBUTE_HIDDEN;
+
+/* "Counts" stored in gcda files can be a real counter value, or
+   an target address. When differentiate these two types because
+   when manipulating counts, we should only change real counter values,
+   rather target addresses.  */
+
+static inline gcov_type
+gcov_get_counter (void)
+{
+#ifndef IN_GCOV_TOOL
+  /* This version is for reading count values in libgcov runtime:
+     we read from gcda files.  */
+
+  return gcov_read_counter ();
+#else
+  /* This version is for gcov-tool. We read the value from memory and
+     multiply it by the merge weight.  */
+
+  return gcov_read_counter_mem () * gcov_get_merge_weight ();
+#endif
+}
+
+/* Similar function as gcov_get_counter(), but handles target address
+   counters.  */
+
+static inline gcov_type
+gcov_get_counter_target (void)
+{
+#ifndef IN_GCOV_TOOL
+  /* This version is for reading count target values in libgcov runtime:
+     we read from gcda files.  */
+
+  return gcov_read_counter ();
+#else
+  /* This version is for gcov-tool.  We read the value from memory and we do NOT
+     multiply it by the merge weight.  */
+
+  return gcov_read_counter_mem ();
+#endif
+}
+
+#endif /* !inhibit_libc */
+
+#endif /* GCC_LIBGCOV_H */
diff --git a/libgcov/include/tsystem.h b/libgcov/include/tsystem.h
new file mode 100644
index 0000000..37c941b
--- /dev/null
+++ b/libgcov/include/tsystem.h
@@ -0,0 +1,137 @@
+/* Get common system includes and various definitions and declarations
+   based on target macros.
+   Copyright (C) 2000-2017 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_TSYSTEM_H
+#define GCC_TSYSTEM_H
+
+/* System headers (e.g. stdio.h, stdlib.h, unistd.h) sometimes
+   indirectly include getopt.h.  Our -I flags will cause gcc's gnu
+   getopt.h to be included, not the platform's copy.  In the default
+   case, gnu getopt.h will provide us with a no-argument prototype
+   which will generate -Wstrict-prototypes warnings.  None of the
+   target files actually use getopt, so it is safe to tell gnu
+   getopt.h we never need this prototype.  */
+#ifndef HAVE_DECL_GETOPT
+#define HAVE_DECL_GETOPT 1
+#endif
+
+/* We want everything from the glibc headers.  */
+#define _GNU_SOURCE 1
+
+/* GCC supplies these headers.  */
+#include <stddef.h>
+#include <float.h>
+
+#ifdef inhibit_libc
+
+#ifndef malloc
+extern void *malloc (size_t);
+#endif
+
+#ifndef free
+extern void free (void *);
+#endif
+
+#ifndef atexit
+extern int atexit (void (*)(void));
+#endif
+
+#ifndef abort
+extern void abort (void) __attribute__ ((__noreturn__));
+#endif
+
+#ifndef strlen
+extern size_t strlen (const char *);
+#endif
+
+#ifndef memcpy
+extern void *memcpy (void *, const void *, size_t);
+#endif
+
+#ifndef memset
+extern void *memset (void *, int, size_t);
+#endif
+
+#else /* ! inhibit_libc */
+/* We disable this when inhibit_libc, so that gcc can still be built without
+   needing header files first.  */
+/* ??? This is not a good solution, since prototypes may be required in
+   some cases for correct code.  */
+
+/* GCC supplies this header.  */
+#include <stdarg.h>
+
+/* All systems have this header.  */
+#include <stdio.h>
+
+/* All systems have this header.  */
+#include <sys/types.h>
+
+/* All systems have this header.  */
+#include <errno.h>
+
+#ifndef errno
+extern int errno;
+#endif
+
+/* If these system headers do not exist, fixincludes must create them.  */
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* GCC supplies this header.  */
+#include <limits.h>
+
+/* If these system headers do not exist, fixincludes must create them.  */
+#include <time.h>
+
+#endif /* inhibit_libc */
+
+/* Define a generic NULL if one hasn't already been defined.  */
+#ifndef NULL
+#define NULL 0
+#endif
+
+/* GCC always provides __builtin_alloca(x).  */
+#undef alloca
+#define alloca(x) __builtin_alloca(x)
+
+#ifdef ENABLE_RUNTIME_CHECKING
+#define gcc_assert(EXPR) ((void)(!(EXPR) ? abort (), 0 : 0))
+#else
+/* Include EXPR, so that unused variable warnings do not occur.  */
+#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
+#endif
+/* Use gcc_unreachable() to mark unreachable locations (like an
+   unreachable default case of a switch.  Do not use gcc_assert(0).  */
+#define gcc_unreachable() (abort ())
+
+#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
+#define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
+
+/* Filename handling macros.  */
+#include "filenames.h"
+
+#endif /* ! GCC_TSYSTEM_H */
diff --git a/libgcov/include/value-unwind.h b/libgcov/include/value-unwind.h
new file mode 100644
index 0000000..a4c32e0
--- /dev/null
+++ b/libgcov/include/value-unwind.h
@@ -0,0 +1,25 @@
+/* Store register values as _Unwind_Word type in DWARF2 EH unwind context.
+   Copyright (C) 2011-2017 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Define this macro if the target stores register values as _Unwind_Word
+   type in unwind context.  Only enable it for x32.  */
+#if defined __x86_64 && !defined __LP64__
+# define REG_VALUE_IN_UNWIND_CONTEXT
+#endif
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Thu May 21 20:22:18 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 21 May 2020 20: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 1jbrho-0007P7-5G; Thu, 21 May 2020 20:22:16 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=sRsn=7D=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jbrhn-0007P2-0e
 for minios-devel@lists.xenproject.org; Thu, 21 May 2020 20:22:15 +0000
X-Inumbo-ID: c1c6b0b2-9ba0-11ea-ae69-bc764e2007e4
Received: from mail-ej1-x641.google.com (unknown [2a00:1450:4864:20::641])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c1c6b0b2-9ba0-11ea-ae69-bc764e2007e4;
 Thu, 21 May 2020 20:22:14 +0000 (UTC)
Received: by mail-ej1-x641.google.com with SMTP id x1so10390545ejd.8
 for <minios-devel@lists.xenproject.org>; Thu, 21 May 2020 13:22: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:mime-version
 :content-transfer-encoding;
 bh=2lZMc66vmpa4xL7+FHcMTzR0NsiGFuufWOy1/FA44Ho=;
 b=VHymX2aAvlKDkqDRdPjQ0LRP8wokXuldhU8TwVdXS50bBq4XT3SWK3HHgyoVSe75Nx
 eLCOfg30Jq8JvONI7V1CfdOIUZNPYP6fUp07fpBbmusddPkGVRLJLBtXpa/HVXvh2Gt3
 bKqq+eTAS+bQqGNdMOMlFkzGEKYtZNQIrweAVXeFvGm6QcYtmvXjyn6uCL0IUSjhEh9k
 D4DhrH2P/juJrsobn6yk2WBhdMhBFMjSuGXgaDC/a8bO9QJyEAIqnkzAbqBzCHukCZeY
 P5/m5BLrq+1ArqbLXbaszufYj5L7yXc7tNJXaihdNUReMkC2ErgpM/0dt+3/xV5P68/O
 zD+g==
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=2lZMc66vmpa4xL7+FHcMTzR0NsiGFuufWOy1/FA44Ho=;
 b=qJ1KAHV3gD2Sujy1N6D9k5JW5Vuq6AKl5E6XLyhIbyg0Tq8zozZDTG/m6JKhCyU7fg
 m650WyWLHtzwLrkRw75susXpigrZAieRmGZVIvzUhvsZ96PztHemdzqWXwFxoMSMA9iV
 koLo5OehVXB0BszsQ9W9DFkyLu3P+Ug2UK42JCMVCOMnmi2IS0TcijiAXzGbzy12Fs5T
 +66HsHU/Uftb4et4NxxinuqbI5i55B8BGxcqqdsnvlv36krpwPrJPgo+6DSqjUMLgXhD
 gHiNbcSMqOkFlFfHqkUUfbiASFcRPCd6ZR47fmQoEJI961twdZNuzg3lUnU70pVul4pU
 EbYQ==
X-Gm-Message-State: AOAM532sOk5BAzCpC86LeF//R6YW6fz2iP1S2qRsJiqvHNAHkMAHLpK0
 5fr2S0SIU2VFLYxbYJVsSVOKAaQ6pg8=
X-Google-Smtp-Source: ABdhPJzylTSUancZX/NKXUd0dQweAItD7wg/gMCilEqxY/6sVqzl6d5te+BucW5pZl1OiQmjp/oCgg==
X-Received: by 2002:a17:906:4dd6:: with SMTP id
 f22mr5030320ejw.483.1590092532825; 
 Thu, 21 May 2020 13:22:12 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:48da:2797:1257:9eb0])
 by smtp.googlemail.com with ESMTPSA id zk10sm5872559ejb.9.2020.05.21.13.22.11
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 21 May 2020 13:22:11 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/VFSCORE PATCH] Quotes to symbol
Date: Thu, 21 May 2020 23:22:06 +0300
Message-Id: <20200521202206.371166-1-murarugeorgec@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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Add quotes to string symbol
Got a warning while trying to use "make kmenuconfig" saying the following:
"warning: style: quotes recommended around default value for string symbol
UK_ARCH (defined at .../unikraft/Config.uk:12)"

Signed-off-by: George Muraru <murarugeorgec@gmail.com>
---
 Config.uk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Config.uk b/Config.uk
index 3235b91..1d4143e 100644
--- a/Config.uk
+++ b/Config.uk
@@ -14,7 +14,7 @@ config UK_ARCH
 	default "x86_64" if ARCH_X86_64
 	default "arm64"  if ARCH_ARM_64
 	default "arm"	if ARCH_ARM_32
-	default $(UK_ARCH)
+	default "$(UK_ARCH)"
 
 config NO_APP
 	def_bool $(shell,test $(UK_BASE) = $(UK_APP) && echo y || echo n)
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Thu May 21 20:22:48 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 21 May 2020 20:22:48 +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 1jbriK-0007QZ-7n; Thu, 21 May 2020 20:22:48 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=sRsn=7D=gmail.com=murarugeorgec@srs-us1.protection.inumbo.net>)
 id 1jbriI-0007QU-UF
 for minios-devel@lists.xenproject.org; Thu, 21 May 2020 20:22:46 +0000
X-Inumbo-ID: d50d034c-9ba0-11ea-ae69-bc764e2007e4
Received: from mail-ej1-x643.google.com (unknown [2a00:1450:4864:20::643])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d50d034c-9ba0-11ea-ae69-bc764e2007e4;
 Thu, 21 May 2020 20:22:46 +0000 (UTC)
Received: by mail-ej1-x643.google.com with SMTP id h21so10423963ejq.5
 for <minios-devel@lists.xenproject.org>; Thu, 21 May 2020 13:22: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:mime-version
 :content-transfer-encoding;
 bh=cNPVMJP9GGnsYpy4M2MTez7S2xb1jo2wxCYEBRnRFW4=;
 b=mM+d2QdAUE8qosy5xp8mr8fCQEQ4wPin6zY5B8TBUcZkPtR+8jkEeWo/u2qF8ToToP
 Cp5U6QMgHI89IapULs1YV1PGp6ki99fjCLEEmmfJC8VhZC2whmPQ2Lh/U+MmzVyGpJzr
 EihjX0aBBWZtqJ3hE+puFg5J+uC7RQkXw/Q9G2WlbvE0sRBQ9BfaS8GP2I7gsCOj91C+
 0fGKugv00nDNhhHh4+k/n1NyyoCOFugGT/xiZCNAwI9lxaHJaDgP/vh930NhqR68JEdN
 B99XEzyVj2+/Wh4UEU66sjdjPDEIEbxETm0IewOM+gcDFmUHLPXgXK9p6tDdzDI34+uY
 4peA==
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=cNPVMJP9GGnsYpy4M2MTez7S2xb1jo2wxCYEBRnRFW4=;
 b=HXPm9bEwzrfhgpaH65adr79ApYf333hAEc/Bp0UPpsE+DmosqTNIPAg32iOQDXw8gB
 1MZVq1wdi4L0e4mUXLNqYBOkLKdvQMlf+W+YA2t1p/0OKZAXmb4srHreJs+sTEonjSA2
 VgHMpn1E3JAkG15FtQkbSv2nF6u0mbuj+0KXKwkjoj2ecUCw9LZIvQDOJbJO58lBAmZS
 ttzjpvPgVM7mv+jT4gbl0PqYUl7ZQn3fpBmMOdS+pQFc8Zfo/PdQxVwNHzO6pO3tDK0I
 8QW6gaT8UVlt/ij5JiTgkE5mo0ZqozpTU0pCPiX8Ikple22/WaXvBDKPznpySlXey/Ij
 jhEg==
X-Gm-Message-State: AOAM530e1DvCmL6x0+Or962MMmNLoSvmwNRSCANMsnHKlyQCL5YH1Q+n
 9H2rSffn2itLhi8seBs0mJEUZSLZcb0=
X-Google-Smtp-Source: ABdhPJxeCvIqP+3VE9qtRelvvfRS2BJoYZt7cLxC2/OwPeARA0fouf+Aa+LiXZGEP0i8RGLTc1ANzg==
X-Received: by 2002:a17:906:830f:: with SMTP id
 j15mr4986227ejx.451.1590092565227; 
 Thu, 21 May 2020 13:22:45 -0700 (PDT)
Received: from localhost.localdomain ([2a02:a58:8506:aa00:48da:2797:1257:9eb0])
 by smtp.googlemail.com with ESMTPSA id j26sm5918539ejc.118.2020.05.21.13.22.44
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 21 May 2020 13:22:44 -0700 (PDT)
From: George Muraru <murarugeorgec@gmail.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT/VFSCORE PATCH] Remove default value
Date: Thu, 21 May 2020 23:22:39 +0300
Message-Id: <20200521202239.371314-1-murarugeorgec@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>
Cc: Felipe.Huici@neclab.eu, George Muraru <murarugeorgec@gmail.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Setting a specific value to a choice config (from one of the libraries) cannot
overwrite a default value (that is set in Unikraft). It seems this is the case
for our C based Kconfig (from my knowledge we use this) - a default value set
earlier (in Unikraft) has a higher priority than a one set later (in a library).

For solving this issue, one solution is to use "named choices" - did that for
the tensorflowlite porting.

The information is obtained from an issue discussed here[1].

[1] https://github.com/zephyrproject-rtos/zephyr/issues/6948

Signed-off-by: George Muraru <murarugeorgec@gmail.com>
---
 lib/vfscore/Config.uk | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/vfscore/Config.uk b/lib/vfscore/Config.uk
index f64810f..212575c 100644
--- a/lib/vfscore/Config.uk
+++ b/lib/vfscore/Config.uk
@@ -28,7 +28,6 @@ help
 if LIBVFSCORE_AUTOMOUNT_ROOTFS
 	choice LIBVFSCORE_ROOTFS
 	prompt "Default root filesystem"
-	default LIBVFSCORE_ROOTFS_RAMFS
 
 		config LIBVFSCORE_ROOTFS_RAMFS
 		bool "RamFS"
-- 
2.25.1



From minios-devel-bounces@lists.xenproject.org Fri May 22 16:25:06 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 22 May 2020 16:25:06 +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 1jcATm-0007UV-Do; Fri, 22 May 2020 16:25:02 +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=Hct3=7E=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jcATl-0007UQ-DF
 for minios-devel@lists.xen.org; Fri, 22 May 2020 16:25:01 +0000
X-Inumbo-ID: c7776dc8-9c48-11ea-abf8-12813bfff9fa
Received: from mx.upb.ro (unknown [141.85.13.5])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id c7776dc8-9c48-11ea-abf8-12813bfff9fa;
 Fri, 22 May 2020 16:24:59 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 1E155B56220D;
 Fri, 22 May 2020 19:24:58 +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 ZLb7F8PZqqyZ; Fri, 22 May 2020 19:24:54 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id C353CB56284D;
 Fri, 22 May 2020 19:24:54 +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 78M7MANkoep3; Fri, 22 May 2020 19:24:54 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.27.71.51])
 by mx.upb.ro (Postfix) with ESMTPSA id 7CFECB56284B;
 Fri, 22 May 2020 19:24:54 +0300 (EEST)
Subject: Re: [LIBGCC/LIBGCOV PATCH 2/2] Makefile.uk: Enable macros through -D
 compile flag
To: Alice Suiu <alicesuiu17@gmail.com>, minios-devel@lists.xen.org
References: <20200521191844.3896-1-alicesuiu17@gmail.com>
 <20200521191844.3896-2-alicesuiu17@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <b53aa96b-4609-da8c-8de3-e7daa349b087@cs.pub.ro>
Date: Fri, 22 May 2020 19:24:54 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200521191844.3896-2-alicesuiu17@gmail.com>
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>
Cc: felipe.huici@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi Alice,

Again, this patch does 2 things: it adds the defines and also popcountdi2.c.

Please see my other comments inline.

On 5/21/20 10:18 PM, Alice Suiu wrote:
> Add -D compile flag to generate specific functions for libgcov.
> 
> Signed-off-by: Alice Suiu <alicesuiu17@gmail.com>
> ---
>  Makefile.uk                   |   8 +-
>  libgcov/include/popcountdi2.c |  39 ++++++++++
>  libgcov/include/popcountdi2.h | 137 ++++++++++++++++++++++++++++++++++
>  3 files changed, 183 insertions(+), 1 deletion(-)
>  create mode 100644 libgcov/include/popcountdi2.c
>  create mode 100644 libgcov/include/popcountdi2.h
> 
> diff --git a/Makefile.uk b/Makefile.uk
> index fe56ad8..fb68c95 100644
> --- a/Makefile.uk
> +++ b/Makefile.uk
> @@ -131,9 +131,15 @@ LIBGCOV_CINCLUDES-y = -I$(LIBGCC_BASE)/libgcov/include \
>  		-I$(LIBGCC_BASE)/libgcov/include/config
>  
>  LIBGCOV_CFLAGS-y += -O2 -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector \
> -	-DHAVE_CC_TLS
> +	-DHAVE_CC_TLS -DL_gcov_merge_add -DL_gcov_merge_single -DL_gcov_merge_ior -DL_gcov_merge_time_profile -DL_gcov_merge_icall_topn \
> +	-DL_gcov_interval_profiler -DL_gcov_interval_profiler_atomic -DL_gcov_pow2_profiler -DL_gcov_pow2_profiler_atomic \
> +	-DL_gcov_one_value_profiler -DL_gcov_one_value_profiler_atomic -DL_gcov_average_profiler -DL_gcov_average_profiler_atomic	\
> +	-DL_gcov_ior_profiler -DL_gcov_ior_profiler_atomic -DL_gcov_indirect_call_profiler_v2 -DL_gcov_time_profiler -DL_gcov_indirect_call_topn_profiler \
> +	-DL_gcov_dump -DL_gcov_flush -DL_gcov_fork -DL_gcov_execl -DL_gcov_execlp -DL_gcov_execle -DL_gcov_execv -DL_gcov_execvp -DL_gcov_execve \
> +	-DL_gcov_reset -DL_gcov \

Why do you add these here instead of the first patch?

>  
>  LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-merge.c
>  LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-profiler.c
>  LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-interface.c
>  LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-driver.c
> +LIBGCOV_SRCS-y += $(LIBGCOV_BASE)/libgcov/include/popcountdi2.c

This is a bit weird, why do you add add a source file in the include
directory?

Another thing, I don't think we need this at all. We already use a
`popcountdi2.c` source file from our compiler-rt library port. Did you
try using that one instead (i.e. using the compiler-rt library along
with libgcc)?

> diff --git a/libgcov/include/popcountdi2.c b/libgcov/include/popcountdi2.c
> new file mode 100644
> index 0000000..1009c01
> --- /dev/null
> +++ b/libgcov/include/popcountdi2.c
> @@ -0,0 +1,39 @@
> +#include "popcountdi2.h"
> +
> +const UQItype __popcount_tab[256] =
> +{
> +    0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
> +    1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
> +    1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
> +    2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
> +    1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
> +    2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
> +    2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
> +    3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
> +};
> +
> +int __popcountdi2 (UDWtype x)
> +{
> +  /* Force table lookup on targets like AVR and RL78 which only
> +     pretend they have LIBGCC2_UNITS_PER_WORD 4, but actually
> +     have 1, and other small word targets.  */
> +#if __SIZEOF_INT__ > 2 && defined (POPCOUNTCST) && __CHAR_BIT__ == 8
> +  const DWunion uu = {.ll = x};
> +  UWtype x1 = uu.s.low, x2 = uu.s.high;
> +  x1 = x1 - ((x1 >> 1) & POPCOUNTCST (0x55));
> +  x2 = x2 - ((x2 >> 1) & POPCOUNTCST (0x55));
> +  x1 = (x1 & POPCOUNTCST (0x33)) + ((x1 >> 2) & POPCOUNTCST (0x33));
> +  x2 = (x2 & POPCOUNTCST (0x33)) + ((x2 >> 2) & POPCOUNTCST (0x33));
> +  x1 = (x1 + (x1 >> 4)) & POPCOUNTCST (0x0F);
> +  x2 = (x2 + (x2 >> 4)) & POPCOUNTCST (0x0F);
> +  x1 += x2;
> +  return (x1 * POPCOUNTCST (0x01)) >> (W_TYPE_SIZE - __CHAR_BIT__);
> +#else
> +  int i, ret = 0;
> +
> +  for (i = 0; i < 2*W_TYPE_SIZE; i += 8)
> +    ret += __popcount_tab[(x >> i) & 0xff];
> +
> +  return ret;
> +#endif
> +}
> diff --git a/libgcov/include/popcountdi2.h b/libgcov/include/popcountdi2.h
> new file mode 100644
> index 0000000..becf8fc
> --- /dev/null
> +++ b/libgcov/include/popcountdi2.h
> @@ -0,0 +1,137 @@
> +typedef char SINT8;
> +typedef unsigned char UINT8;
> +typedef unsigned UINT32;
> +typedef signed SINT32;
> +
> +#if __GNUC__ || defined LINUX || defined SUNOS
> +typedef unsigned long long UINT64;
> +typedef signed long long SINT64;
> +#else
> +typedef unsigned __int64 UINT64;
> +typedef signed __int64 SINT64;
> +#endif
> +
> +#define USItype UINT32;
> +#define SItype SINT32;
> +#define UDItype UINT64;
> +#define DItype SINT64;
> +
> +typedef		 int QItype	__attribute__ ((mode (QI)));
> +typedef unsigned int UQItype	__attribute__ ((mode (QI)));
> +typedef		 int HItype	__attribute__ ((mode (HI)));
> +typedef unsigned int UHItype	__attribute__ ((mode (HI)));
> +#if MIN_UNITS_PER_WORD > 1
> +/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1.  */
> +typedef 	 int SItype	__attribute__ ((mode (SI)));
> +typedef unsigned int USItype	__attribute__ ((mode (SI)));
> +#if __SIZEOF_LONG_LONG__ > 4
> +/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2.  */
> +typedef		 int DItype	__attribute__ ((mode (DI)));
> +typedef unsigned int UDItype	__attribute__ ((mode (DI)));
> +#if MIN_UNITS_PER_WORD > 4
> +/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4.  */
> +typedef		 int TItype	__attribute__ ((mode (TI)));
> +typedef unsigned int UTItype	__attribute__ ((mode (TI)));
> +#endif
> +#endif
> +#endif
> +
> +#if LIBGCC2_HAS_HF_MODE
> +typedef		float HFtype	__attribute__ ((mode (HF)));
> +typedef _Complex float HCtype	__attribute__ ((mode (HC)));
> +#endif
> +#if LIBGCC2_HAS_SF_MODE
> +typedef 	float SFtype	__attribute__ ((mode (SF)));
> +typedef _Complex float SCtype	__attribute__ ((mode (SC)));
> +#endif
> +#if LIBGCC2_HAS_DF_MODE
> +typedef		float DFtype	__attribute__ ((mode (DF)));
> +typedef _Complex float DCtype	__attribute__ ((mode (DC)));
> +#endif
> +#if LIBGCC2_HAS_XF_MODE
> +typedef		float XFtype	__attribute__ ((mode (XF)));
> +typedef _Complex float XCtype	__attribute__ ((mode (XC)));
> +#endif
> +#if LIBGCC2_HAS_TF_MODE
> +typedef		float TFtype	__attribute__ ((mode (TF)));
> +typedef _Complex float TCtype	__attribute__ ((mode (TC)));
> +#endif
> +
> +
> +#if LIBGCC2_UNITS_PER_WORD == 8
> +#define W_TYPE_SIZE (8 * __CHAR_BIT__)
> +#define Wtype	DItype
> +#define UWtype	UDItype
> +#define HWtype	DItype
> +#define UHWtype	UDItype
> +#define DWtype	TItype
> +#define UDWtype	UTItype
> +#ifdef LIBGCC2_GNU_PREFIX
> +#define __NW(a,b)	__gnu_ ## a ## di ## b
> +#define __NDW(a,b)	__gnu_ ## a ## ti ## b
> +#else
> +#define __NW(a,b)	__ ## a ## di ## b
> +#define __NDW(a,b)	__ ## a ## ti ## b
> +#endif
> +#define COMPAT_SIMODE_TRAPPING_ARITHMETIC
> +#elif LIBGCC2_UNITS_PER_WORD == 4
> +#define W_TYPE_SIZE (4 * __CHAR_BIT__)
> +#define Wtype	SItype
> +#define UWtype	USItype
> +#define HWtype	SItype
> +#define UHWtype	USItype
> +#define DWtype	DItype
> +#define UDWtype	UDItype
> +#ifdef LIBGCC2_GNU_PREFIX
> +#define __NW(a,b)	__gnu_ ## a ## si ## b
> +#define __NDW(a,b)	__gnu_ ## a ## di ## b
> +#else
> +#define __NW(a,b)	__ ## a ## si ## b
> +#define __NDW(a,b)	__ ## a ## di ## b
> +#endif
> +#elif LIBGCC2_UNITS_PER_WORD == 2
> +#define W_TYPE_SIZE (2 * __CHAR_BIT__)
> +#define Wtype	HItype
> +#define UWtype	UHItype
> +#define HWtype	HItype
> +#define UHWtype	UHItype
> +#define DWtype	SItype
> +#define UDWtype	USItype
> +#ifdef LIBGCC2_GNU_PREFIX
> +#define __NW(a,b)	__gnu_ ## a ## hi ## b
> +#define __NDW(a,b)	__gnu_ ## a ## si ## b
> +#else
> +#define __NW(a,b)	__ ## a ## hi ## b
> +#define __NDW(a,b)	__ ## a ## si ## b
> +#endif
> +#else
> +#define W_TYPE_SIZE __CHAR_BIT__
> +#define Wtype	QItype
> +#define UWtype  UQItype
> +#define HWtype	QItype
> +#define UHWtype	UQItype
> +#define DWtype	HItype
> +#define UDWtype	UHItype
> +#ifdef LIBGCC2_GNU_PREFIX
> +#define __NW(a,b)	__gnu_ ## a ## qi ## b
> +#define __NDW(a,b)	__gnu_ ## a ## hi ## b
> +#else
> +#define __NW(a,b)	__ ## a ## qi ## b
> +#define __NDW(a,b)	__ ## a ## hi ## b
> +#endif
> +#endif
> +
> +/* DWstructs are pairs of Wtype values in the order determined by
> +   __BYTE_ORDER__.  */
> +
> +#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
> +  struct DWstruct {Wtype high, low;};
> +#else
> +  struct DWstruct {Wtype low, high;};
> +#endif
> +
> +typedef union
> +{
> +  struct DWstruct s;
> +  DWtype ll;
> +} DWunion;
> \ No newline at end of file
> 


From minios-devel-bounces@lists.xenproject.org Fri May 22 16:25:36 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 22 May 2020 16:25:36 +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 1jcAUK-0007W9-IW; Fri, 22 May 2020 16:25:36 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Hct3=7E=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1jcAUI-0007W2-VK
 for minios-devel@lists.xen.org; Fri, 22 May 2020 16:25:35 +0000
X-Inumbo-ID: daba94a0-9c48-11ea-b9cf-bc764e2007e4
Received: from mx.upb.ro (unknown [141.85.13.5])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id daba94a0-9c48-11ea-b9cf-bc764e2007e4;
 Fri, 22 May 2020 16:25:31 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id A7BE2B562687;
 Fri, 22 May 2020 19:25:30 +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 5pp51xKtxf5l; Fri, 22 May 2020 19:24:51 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id EAB4CB562723;
 Fri, 22 May 2020 19:24:50 +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 rt7FfxN_j0vo; Fri, 22 May 2020 19:24:50 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.27.71.51])
 by mx.upb.ro (Postfix) with ESMTPSA id 5A2B9B56220D;
 Fri, 22 May 2020 19:24:50 +0300 (EEST)
Subject: Re: [LIBGCC/LIBGCOV PATCH 1/2] Port libgcov library
To: Alice Suiu <alicesuiu17@gmail.com>, minios-devel@lists.xen.org
References: <20200521191844.3896-1-alicesuiu17@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <4c367643-e850-bc11-885b-b8ed31709352@cs.pub.ro>
Date: Fri, 22 May 2020 19:24:49 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <20200521191844.3896-1-alicesuiu17@gmail.com>
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>
Cc: felipe.huici@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi Alice,

Thanks for this work. Here are my comments:
1) First of all, this is a series and you should use a cover letter
(--cover-leter parameter when running `git format-patch`) where you
should say why you ported this. Some brief explanation should do. Please
do that for your v2 series.

2) A patch should generally do just one thing. Please don't try to
squeeze several things into one patch only. For example, this patch
introduces the gcov port *and* updates the origin version.

3) Why do you copy all these generated headers? Can't you generate them
at build time in the prepare step (e.g. `make prepare`) and use them
from the origin?

4) What does "existing headers" mean? What's the difference between the
"existing" headers and the "generated headers"? Why do we need both?
Please add more information in your commit message about that.

Please see my 2 other comments inline.

On 5/21/20 10:18 PM, Alice Suiu wrote:
> This port also adds generated headers which can be found in
> include/config/ directory and existing headers which can be located in
> include/ directory.
> 
> Signed-off-by: Alice Suiu <alicesuiu17@gmail.com>
> ---
>  Config.uk                            |    7 +
>  Makefile.uk                          |   20 +-
>  libgcov/include/ansidecl.h           |  355 ++++
>  libgcov/include/config/auto-host.h   | 2419 ++++++++++++++++++++++++++
>  libgcov/include/config/auto-target.h |   80 +
>  libgcov/include/config/gcov-iov.h    |    4 +
>  libgcov/include/config/libgcc_tm.h   |    6 +
>  libgcov/include/config/tconfig.h     |   10 +
>  libgcov/include/config/tm.h          |   52 +
>  libgcov/include/coretypes.h          |  376 ++++
>  libgcov/include/defaults.h           | 1478 ++++++++++++++++
>  libgcov/include/elf-lib.h            |   36 +
>  libgcov/include/filenames.h          |   99 ++
>  libgcov/include/gcov-counter.def     |   54 +
>  libgcov/include/gcov-io.c            |  987 +++++++++++
>  libgcov/include/gcov-io.h            |  424 +++++
>  libgcov/include/gcov.h               |   41 +
>  libgcov/include/gthr-default.h       |  889 ++++++++++
>  libgcov/include/gthr.h               |  154 ++
>  libgcov/include/hashtab.h            |  204 +++
>  libgcov/include/libgcov.h            |  346 ++++
>  libgcov/include/tsystem.h            |  137 ++
>  libgcov/include/value-unwind.h       |   25 +
>  23 files changed, 8202 insertions(+), 1 deletion(-)
>  create mode 100644 libgcov/include/ansidecl.h
>  create mode 100644 libgcov/include/config/auto-host.h
>  create mode 100644 libgcov/include/config/auto-target.h
>  create mode 100644 libgcov/include/config/gcov-iov.h
>  create mode 100644 libgcov/include/config/libgcc_tm.h
>  create mode 100644 libgcov/include/config/tconfig.h
>  create mode 100644 libgcov/include/config/tm.h
>  create mode 100644 libgcov/include/coretypes.h
>  create mode 100644 libgcov/include/defaults.h
>  create mode 100644 libgcov/include/elf-lib.h
>  create mode 100644 libgcov/include/filenames.h
>  create mode 100644 libgcov/include/gcov-counter.def
>  create mode 100644 libgcov/include/gcov-io.c
>  create mode 100644 libgcov/include/gcov-io.h
>  create mode 100644 libgcov/include/gcov.h
>  create mode 100644 libgcov/include/gthr-default.h
>  create mode 100644 libgcov/include/gthr.h
>  create mode 100644 libgcov/include/hashtab.h
>  create mode 100644 libgcov/include/libgcov.h
>  create mode 100644 libgcov/include/tsystem.h
>  create mode 100644 libgcov/include/value-unwind.h
> 
> diff --git a/Config.uk b/Config.uk
> index 5aaca7c..89a84b0 100644
> --- a/Config.uk
> +++ b/Config.uk
> @@ -26,4 +26,11 @@ config LIBFFI
>  if LIBFFI
>  endif
>  
> +config LIBGCOV
> +       bool "libgcov - A Profiling Library"
> +       default n
> +       select LIBPTHREAD_EMBEDDED
> +if LIBGCOV
> +endif
> +
>  endif
> diff --git a/Makefile.uk b/Makefile.uk
> index d5901e2..fe56ad8 100644
> --- a/Makefile.uk
> +++ b/Makefile.uk
> @@ -42,11 +42,12 @@
>  $(eval $(call addlib_s,libgcc,$(CONFIG_LIBGCC)))
>  $(eval $(call addlib_s,libbacktrace,$(CONFIG_LIBBACKTRACE)))
>  $(eval $(call addlib_s,libffi,$(CONFIG_LIBFFI)))
> +$(eval $(call addlib_s,libgcov,$(CONFIG_LIBGCOV)))
>  
>  ################################################################################
>  # Original sources
>  ################################################################################
> -LIBGCC_VERSION=7.3.0
> +LIBGCC_VERSION=7.5.0

As I said, this should come in a standalone patch. We would also need an
explanation why you updated it.

>  LIBGCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-$(LIBGCC_VERSION)/gcc-$(LIBGCC_VERSION).tar.gz
>  LIBGCC_SUBDIR=gcc-$(LIBGCC_VERSION)
>  $(eval $(call fetch,libgcc,$(LIBGCC_URL)))
> @@ -57,6 +58,7 @@ $(eval $(call fetch,libgcc,$(LIBGCC_URL)))
>  LIBGCC_EXTRACTED = $(LIBGCC_ORIGIN)/gcc-$(LIBGCC_VERSION)
>  LIBBACKTRACE_EXTRACTED = $(LIBGCC_EXTRACTED)/libbacktrace
>  LIBFFI_EXTRACTED = $(LIBGCC_EXTRACTED)/libffi
> +LIBGCOV_EXTRACTED = $(LIBGCC_EXTRACTED)/libgcc
>  
>  ################################################################################
>  # Library includes
> @@ -70,6 +72,9 @@ CXXINCLUDES-$(CONFIG_LIBBACKTRACE) += -I$(LIBGCC_BASE)/libbacktrace/include
>  CINCLUDES-$(CONFIG_LIBFFI)   += -I$(LIBGCC_BASE)/libffi/include
>  CXXINCLUDES-$(CONFIG_LIBFFI) += -I$(LIBGCC_BASE)/libffi/include
>  
> +CINCLUDES-$(CONFIG_LIBGCOV)   += -I$(LIBGCC_BASE)/libgcov/include
> +CXXINCLUDES-$(CONFIG_LIBGCOV) += -I$(LIBGCC_BASE)/libgcov/include
> +
>  ################################################################################
>  # libbacktrace code
>  ################################################################################
> @@ -119,3 +124,16 @@ LIBFFI_SRCS-y += $(LIBFFI_EXTRACTED)/src/raw_api.c
>  LIBFFI_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBFFI_EXTRACTED)/src/x86/ffi64.c
>  LIBFFI_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBFFI_EXTRACTED)/src/x86/unix64.S
>  
> +################################################################################
> +# libgcov code
> +################################################################################
> +LIBGCOV_CINCLUDES-y = -I$(LIBGCC_BASE)/libgcov/include \
> +		-I$(LIBGCC_BASE)/libgcov/include/config
> +
> +LIBGCOV_CFLAGS-y += -O2 -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector \
> +	-DHAVE_CC_TLS

You shouldn't add general flags here, so please get rid of '-O2'. This
would be selected only if wanted via menuconfig.

I saw in the next patch that you are adding more defines here. Is there
any reason why you use a separated patch for that?

> +
> +LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-merge.c
> +LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-profiler.c
> +LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-interface.c
> +LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-driver.c
> diff --git a/libgcov/include/ansidecl.h b/libgcov/include/ansidecl.h
> new file mode 100644
> index 0000000..25f33da
> --- /dev/null
> +++ b/libgcov/include/ansidecl.h
> @@ -0,0 +1,355 @@
> +/* ANSI and traditional C compatability macros
> +   Copyright (C) 1991-2017 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +This program is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 2 of the License, or
> +(at your option) any later version.
> +
> +This program is distributed in the hope that it will be useful,
> +but WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +GNU General Public License for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with this program; if not, write to the Free Software
> +Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
> +
> +/* ANSI and traditional C compatibility macros
> +
> +   ANSI C is assumed if __STDC__ is #defined.
> +
> +   Macro		ANSI C definition	Traditional C definition
> +   -----		---- - ----------	----------- - ----------
> +   PTR			`void *'		`char *'
> +   const		not defined		`'
> +   volatile		not defined		`'
> +   signed		not defined		`'
> +
> +   For ease of writing code which uses GCC extensions but needs to be
> +   portable to other compilers, we provide the GCC_VERSION macro that
> +   simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
> +   wrappers around __attribute__.  Also, __extension__ will be #defined
> +   to nothing if it doesn't work.  See below.  */
> +
> +#ifndef	_ANSIDECL_H
> +#define _ANSIDECL_H	1
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/* Every source file includes this file,
> +   so they will all get the switch for lint.  */
> +/* LINTLIBRARY */
> +
> +/* Using MACRO(x,y) in cpp #if conditionals does not work with some
> +   older preprocessors.  Thus we can't define something like this:
> +
> +#define HAVE_GCC_VERSION(MAJOR, MINOR) \
> +  (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
> +
> +and then test "#if HAVE_GCC_VERSION(2,7)".
> +
> +So instead we use the macro below and test it against specific values.  */
> +
> +/* This macro simplifies testing whether we are using gcc, and if it
> +   is of a particular minimum version. (Both major & minor numbers are
> +   significant.)  This macro will evaluate to 0 if we are not using
> +   gcc at all.  */
> +#ifndef GCC_VERSION
> +#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
> +#endif /* GCC_VERSION */
> +
> +#if defined (__STDC__) || defined(__cplusplus) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
> +/* All known AIX compilers implement these things (but don't always
> +   define __STDC__).  The RISC/OS MIPS compiler defines these things
> +   in SVR4 mode, but does not define __STDC__.  */
> +/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other
> +   C++ compilers, does not define __STDC__, though it acts as if this
> +   was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
> +
> +#define PTR		void *
> +
> +#undef const
> +#undef volatile
> +#undef signed
> +
> +/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
> +   it too, but it's not in C89.  */
> +#undef inline
> +#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))
> +/* it's a keyword */
> +#else
> +# if GCC_VERSION >= 2007
> +#  define inline __inline__   /* __inline__ prevents -pedantic warnings */
> +# else
> +#  define inline  /* nothing */
> +# endif
> +#endif
> +
> +#else	/* Not ANSI C.  */
> +
> +#define PTR		char *
> +
> +/* some systems define these in header files for non-ansi mode */
> +#undef const
> +#undef volatile
> +#undef signed
> +#undef inline
> +#define const
> +#define volatile
> +#define signed
> +#define inline
> +
> +#endif	/* ANSI C.  */
> +
> +/* Define macros for some gcc attributes.  This permits us to use the
> +   macros freely, and know that they will come into play for the
> +   version of gcc in which they are supported.  */
> +
> +#if (GCC_VERSION < 2007)
> +# define __attribute__(x)
> +#endif
> +
> +/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
> +#ifndef ATTRIBUTE_MALLOC
> +# if (GCC_VERSION >= 2096)
> +#  define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
> +# else
> +#  define ATTRIBUTE_MALLOC
> +# endif /* GNUC >= 2.96 */
> +#endif /* ATTRIBUTE_MALLOC */
> +
> +/* Attributes on labels were valid as of gcc 2.93 and g++ 4.5.  For
> +   g++ an attribute on a label must be followed by a semicolon.  */
> +#ifndef ATTRIBUTE_UNUSED_LABEL
> +# ifndef __cplusplus
> +#  if GCC_VERSION >= 2093
> +#   define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
> +#  else
> +#   define ATTRIBUTE_UNUSED_LABEL
> +#  endif
> +# else
> +#  if GCC_VERSION >= 4005
> +#   define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED ;
> +#  else
> +#   define ATTRIBUTE_UNUSED_LABEL
> +#  endif
> +# endif
> +#endif
> +
> +/* Similarly to ARG_UNUSED below.  Prior to GCC 3.4, the C++ frontend
> +   couldn't parse attributes placed after the identifier name, and now
> +   the entire compiler is built with C++.  */
> +#ifndef ATTRIBUTE_UNUSED
> +#if GCC_VERSION >= 3004
> +#  define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
> +#else
> +#define ATTRIBUTE_UNUSED
> +#endif
> +#endif /* ATTRIBUTE_UNUSED */
> +
> +/* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the
> +   identifier name.  */
> +#if ! defined(__cplusplus) || (GCC_VERSION >= 3004)
> +# define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED
> +#else /* !__cplusplus || GNUC >= 3.4 */
> +# define ARG_UNUSED(NAME) NAME
> +#endif /* !__cplusplus || GNUC >= 3.4 */
> +
> +#ifndef ATTRIBUTE_NORETURN
> +#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
> +#endif /* ATTRIBUTE_NORETURN */
> +
> +/* Attribute `nonnull' was valid as of gcc 3.3.  */
> +#ifndef ATTRIBUTE_NONNULL
> +# if (GCC_VERSION >= 3003)
> +#  define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
> +# else
> +#  define ATTRIBUTE_NONNULL(m)
> +# endif /* GNUC >= 3.3 */
> +#endif /* ATTRIBUTE_NONNULL */
> +
> +/* Attribute `returns_nonnull' was valid as of gcc 4.9.  */
> +#ifndef ATTRIBUTE_RETURNS_NONNULL
> +# if (GCC_VERSION >= 4009)
> +#  define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
> +# else
> +#  define ATTRIBUTE_RETURNS_NONNULL
> +# endif /* GNUC >= 4.9 */
> +#endif /* ATTRIBUTE_RETURNS_NONNULL */
> +
> +/* Attribute `pure' was valid as of gcc 3.0.  */
> +#ifndef ATTRIBUTE_PURE
> +# if (GCC_VERSION >= 3000)
> +#  define ATTRIBUTE_PURE __attribute__ ((__pure__))
> +# else
> +#  define ATTRIBUTE_PURE
> +# endif /* GNUC >= 3.0 */
> +#endif /* ATTRIBUTE_PURE */
> +
> +/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
> +   This was the case for the `printf' format attribute by itself
> +   before GCC 3.3, but as of 3.3 we need to add the `nonnull'
> +   attribute to retain this behavior.  */
> +#ifndef ATTRIBUTE_PRINTF
> +#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
> +#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
> +#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
> +#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
> +#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
> +#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
> +#endif /* ATTRIBUTE_PRINTF */
> +
> +/* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on
> +   a function pointer.  Format attributes were allowed on function
> +   pointers as of gcc 3.1.  */
> +#ifndef ATTRIBUTE_FPTR_PRINTF
> +# if (GCC_VERSION >= 3001)
> +#  define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n)
> +# else
> +#  define ATTRIBUTE_FPTR_PRINTF(m, n)
> +# endif /* GNUC >= 3.1 */
> +# define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2)
> +# define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3)
> +# define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4)
> +# define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5)
> +# define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6)
> +#endif /* ATTRIBUTE_FPTR_PRINTF */
> +
> +/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL.  A
> +   NULL format specifier was allowed as of gcc 3.3.  */
> +#ifndef ATTRIBUTE_NULL_PRINTF
> +# if (GCC_VERSION >= 3003)
> +#  define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
> +# else
> +#  define ATTRIBUTE_NULL_PRINTF(m, n)
> +# endif /* GNUC >= 3.3 */
> +# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
> +# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
> +# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
> +# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
> +# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
> +#endif /* ATTRIBUTE_NULL_PRINTF */
> +
> +/* Attribute `sentinel' was valid as of gcc 3.5.  */
> +#ifndef ATTRIBUTE_SENTINEL
> +# if (GCC_VERSION >= 3005)
> +#  define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
> +# else
> +#  define ATTRIBUTE_SENTINEL
> +# endif /* GNUC >= 3.5 */
> +#endif /* ATTRIBUTE_SENTINEL */
> +
> +
> +#ifndef ATTRIBUTE_ALIGNED_ALIGNOF
> +# if (GCC_VERSION >= 3000)
> +#  define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m))))
> +# else
> +#  define ATTRIBUTE_ALIGNED_ALIGNOF(m)
> +# endif /* GNUC >= 3.0 */
> +#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
> +
> +/* Useful for structures whose layout must match some binary specification
> +   regardless of the alignment and padding qualities of the compiler.  */
> +#ifndef ATTRIBUTE_PACKED
> +# define ATTRIBUTE_PACKED __attribute__ ((packed))
> +#endif
> +
> +/* Attribute `hot' and `cold' was valid as of gcc 4.3.  */
> +#ifndef ATTRIBUTE_COLD
> +# if (GCC_VERSION >= 4003)
> +#  define ATTRIBUTE_COLD __attribute__ ((__cold__))
> +# else
> +#  define ATTRIBUTE_COLD
> +# endif /* GNUC >= 4.3 */
> +#endif /* ATTRIBUTE_COLD */
> +#ifndef ATTRIBUTE_HOT
> +# if (GCC_VERSION >= 4003)
> +#  define ATTRIBUTE_HOT __attribute__ ((__hot__))
> +# else
> +#  define ATTRIBUTE_HOT
> +# endif /* GNUC >= 4.3 */
> +#endif /* ATTRIBUTE_HOT */
> +
> +/* Attribute 'no_sanitize_undefined' was valid as of gcc 4.9.  */
> +#ifndef ATTRIBUTE_NO_SANITIZE_UNDEFINED
> +# if (GCC_VERSION >= 4009)
> +#  define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined))
> +# else
> +#  define ATTRIBUTE_NO_SANITIZE_UNDEFINED
> +# endif /* GNUC >= 4.9 */
> +#endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */
> +
> +/* We use __extension__ in some places to suppress -pedantic warnings
> +   about GCC extensions.  This feature didn't work properly before
> +   gcc 2.8.  */
> +#if GCC_VERSION < 2008
> +#define __extension__
> +#endif
> +
> +/* This is used to declare a const variable which should be visible
> +   outside of the current compilation unit.  Use it as
> +     EXPORTED_CONST int i = 1;
> +   This is because the semantics of const are different in C and C++.
> +   "extern const" is permitted in C but it looks strange, and gcc
> +   warns about it when -Wc++-compat is not used.  */
> +#ifdef __cplusplus
> +#define EXPORTED_CONST extern const
> +#else
> +#define EXPORTED_CONST const
> +#endif
> +
> +/* Be conservative and only use enum bitfields with C++ or GCC.
> +   FIXME: provide a complete autoconf test for buggy enum bitfields.  */
> +
> +#ifdef __cplusplus
> +#define ENUM_BITFIELD(TYPE) enum TYPE
> +#elif (GCC_VERSION > 2000)
> +#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
> +#else
> +#define ENUM_BITFIELD(TYPE) unsigned int
> +#endif
> +
> +/* C++11 adds the ability to add "override" after an implementation of a
> +   virtual function in a subclass, to:
> +     (A) document that this is an override of a virtual function
> +     (B) allow the compiler to issue a warning if it isn't (e.g. a mismatch
> +         of the type signature).
> +
> +   Similarly, it allows us to add a "final" to indicate that no subclass
> +   may subsequently override the vfunc.
> +
> +   Provide OVERRIDE and FINAL as macros, allowing us to get these benefits
> +   when compiling with C++11 support, but without requiring C++11.
> +
> +   For gcc, use "-std=c++11" to enable C++11 support; gcc 6 onwards enables
> +   this by default (actually GNU++14).  */
> +
> +#if __cplusplus >= 201103
> +/* C++11 claims to be available: use it.  final/override were only
> +   implemented in 4.7, though.  */
> +# if GCC_VERSION < 4007
> +#  define OVERRIDE
> +#  define FINAL
> +# else
> +#  define OVERRIDE override
> +#  define FINAL final
> +# endif
> +#elif GCC_VERSION >= 4007
> +/* G++ 4.7 supports __final in C++98.  */
> +# define OVERRIDE
> +# define FINAL __final
> +#else
> +/* No C++11 support; leave the macros empty: */
> +# define OVERRIDE
> +# define FINAL
> +#endif
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif	/* ansidecl.h	*/
> diff --git a/libgcov/include/config/auto-host.h b/libgcov/include/config/auto-host.h
> new file mode 100644
> index 0000000..9b81bf2
> --- /dev/null
> +++ b/libgcov/include/config/auto-host.h
> @@ -0,0 +1,2419 @@
> +/* auto-host.h.  Generated from config.in by configure.  */
> +/* config.in.  Generated from configure.ac by autoheader.  */
> +
> +/* Define if this compiler should be built as the offload target compiler. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ACCEL_COMPILER */
> +#endif
> +
> +
> +/* Define if building universal (internal helper macro) */
> +#ifndef USED_FOR_TARGET
> +/* #undef AC_APPLE_UNIVERSAL_BUILD */
> +#endif
> +
> +
> +/* Define to the assembler option to enable compressed debug sections. */
> +#ifndef USED_FOR_TARGET
> +#define AS_COMPRESS_DEBUG_OPTION ""
> +#endif
> +
> +
> +/* Define to the assembler option to disable compressed debug sections. */
> +#ifndef USED_FOR_TARGET
> +#define AS_NO_COMPRESS_DEBUG_OPTION ""
> +#endif
> +
> +
> +/* Define as the number of bits in a byte, if `limits.h' doesn't. */
> +#ifndef USED_FOR_TARGET
> +/* #undef CHAR_BIT */
> +#endif
> +
> +
> +/* Define to 0/1 if you want more run-time sanity checks. This one gets a grab
> +   bag of miscellaneous but relatively cheap checks. */
> +#ifndef USED_FOR_TARGET
> +#define CHECKING_P 0
> +#endif
> +
> +
> +/* Define 0/1 to force the choice for exception handling model. */
> +#ifndef USED_FOR_TARGET
> +/* #undef CONFIG_SJLJ_EXCEPTIONS */
> +#endif
> +
> +
> +/* Define to enable the use of a default assembler. */
> +#ifndef USED_FOR_TARGET
> +/* #undef DEFAULT_ASSEMBLER */
> +#endif
> +
> +
> +/* Define to enable the use of a default linker. */
> +#ifndef USED_FOR_TARGET
> +/* #undef DEFAULT_LINKER */
> +#endif
> +
> +
> +/* Define if you want to use __cxa_atexit, rather than atexit, to register C++
> +   destructors for local statics and global objects. This is essential for
> +   fully standards-compliant handling of destructors, but requires
> +   __cxa_atexit in libc. */
> +#ifndef USED_FOR_TARGET
> +#define DEFAULT_USE_CXA_ATEXIT 2
> +#endif
> +
> +
> +/* The default for -fdiagnostics-color option */
> +#ifndef USED_FOR_TARGET
> +#define DIAGNOSTICS_COLOR_DEFAULT DIAGNOSTICS_COLOR_AUTO
> +#endif
> +
> +
> +/* Define if you want assertions enabled. This is a cheap check. */
> +#ifndef USED_FOR_TARGET
> +#define ENABLE_ASSERT_CHECKING 1
> +#endif
> +
> +
> +/* Define to 1 to specify that we are using the BID decimal floating point
> +   format instead of DPD */
> +#ifndef USED_FOR_TARGET
> +#define ENABLE_DECIMAL_BID_FORMAT 1
> +#endif
> +
> +
> +/* Define to 1 to enable decimal float extension to C. */
> +#ifndef USED_FOR_TARGET
> +#define ENABLE_DECIMAL_FLOAT 1
> +#endif
> +
> +
> +/* Define if your target supports default PIE and it is enabled. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_DEFAULT_PIE */
> +#endif
> +
> +
> +/* Define if your target supports default stack protector and it is enabled.
> +   */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_DEFAULT_SSP */
> +#endif
> +
> +
> +/* Define if you want more run-time sanity checks for dataflow. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_DF_CHECKING */
> +#endif
> +
> +
> +/* Define to 0/1 if you want extra run-time checking that might affect code
> +   generation. */
> +#ifndef USED_FOR_TARGET
> +#define ENABLE_EXTRA_CHECKING 0
> +#endif
> +
> +
> +/* Define to 1 to enable fixed-point arithmetic extension to C. */
> +#ifndef USED_FOR_TARGET
> +#define ENABLE_FIXED_POINT 0
> +#endif
> +
> +
> +/* Define if you want fold checked that it never destructs its argument. This
> +   is quite expensive. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_FOLD_CHECKING */
> +#endif
> +
> +
> +/* Define if you want the garbage collector to operate in maximally paranoid
> +   mode, validating the entire heap and collecting garbage at every
> +   opportunity. This is extremely expensive. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_GC_ALWAYS_COLLECT */
> +#endif
> +
> +
> +/* Define if you want the garbage collector to do object poisoning and other
> +   memory allocation checks. This is quite expensive. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_GC_CHECKING */
> +#endif
> +
> +
> +/* Define if you want operations on GIMPLE (the basic data structure of the
> +   high-level optimizers) to be checked for dynamic type safety at runtime.
> +   This is moderately expensive. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_GIMPLE_CHECKING */
> +#endif
> +
> +
> +/* Define this to enable support for generating HSAIL. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_HSA */
> +#endif
> +
> +
> +/* Define if gcc should always pass --build-id to linker. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_LD_BUILDID */
> +#endif
> +
> +
> +/* Define to 1 to enable libquadmath support */
> +#ifndef USED_FOR_TARGET
> +#define ENABLE_LIBQUADMATH_SUPPORT 1
> +#endif
> +
> +
> +/* Define to enable LTO support. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_LTO */
> +#endif
> +
> +
> +/* Define to 1 if translation of program messages to the user's native
> +   language is requested. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_NLS */
> +#endif
> +
> +
> +/* Define this to enable support for offloading. */
> +#ifndef USED_FOR_TARGET
> +#define ENABLE_OFFLOADING 0
> +#endif
> +
> +
> +/* Define to enable plugin support. */
> +#ifndef USED_FOR_TARGET
> +#define ENABLE_PLUGIN 1
> +#endif
> +
> +
> +/* Define if you want all operations on RTL (the basic data structure of the
> +   optimizer and back end) to be checked for dynamic type safety at runtime.
> +   This is quite expensive. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_RTL_CHECKING */
> +#endif
> +
> +
> +/* Define if you want RTL flag accesses to be checked against the RTL codes
> +   that are supported for each access macro. This is relatively cheap. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_RTL_FLAG_CHECKING */
> +#endif
> +
> +
> +/* Define if you want runtime assertions enabled. This is a cheap check. */
> +#define ENABLE_RUNTIME_CHECKING 1
> +
> +/* Define if you want all operations on trees (the basic data structure of the
> +   front ends) to be checked for dynamic type safety at runtime. This is
> +   moderately expensive. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_TREE_CHECKING */
> +#endif
> +
> +
> +/* Define if you want all gimple types to be verified after gimplifiation.
> +   This is cheap. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_TYPES_CHECKING */
> +#endif
> +
> +
> +/* Define to get calls to the valgrind runtime enabled. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_VALGRIND_ANNOTATIONS */
> +#endif
> +
> +
> +/* Define if you want to run subprograms and generated programs through
> +   valgrind (a memory checker). This is extremely expensive. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_VALGRIND_CHECKING */
> +#endif
> +
> +
> +/* Define 0/1 if vtable verification feature is enabled. */
> +#ifndef USED_FOR_TARGET
> +#define ENABLE_VTABLE_VERIFY 0
> +#endif
> +
> +
> +/* Define to 1 if installation paths should be looked up in the Windows
> +   Registry. Ignored on non-Windows hosts. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ENABLE_WIN32_REGISTRY */
> +#endif
> +
> +
> +/* Define to the name of a file containing a list of extra machine modes for
> +   this architecture. */
> +#ifndef USED_FOR_TARGET
> +#define EXTRA_MODES_FILE "config/i386/i386-modes.def"
> +#endif
> +
> +
> +/* Define to enable detailed memory allocation stats gathering. */
> +#ifndef USED_FOR_TARGET
> +#define GATHER_STATISTICS 0
> +#endif
> +
> +
> +/* Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>. */
> +#ifndef USED_FOR_TARGET
> +#define GWINSZ_IN_SYS_IOCTL 1
> +#endif
> +
> +
> +/* mcontext_t fields start with __ */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAS_MCONTEXT_T_UNDERSCORES */
> +#endif
> +
> +
> +/* Define if your assembler supports architecture modifiers. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_ARCHITECTURE_MODIFIERS */
> +#endif
> +
> +
> +/* Define if your avr assembler supports --mlink-relax option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_AVR_MLINK_RELAX_OPTION */
> +#endif
> +
> +
> +/* Define if your avr assembler supports -mrmw option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_AVR_MRMW_OPTION */
> +#endif
> +
> +
> +/* Define if your assembler supports cmpb. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_CMPB */
> +#endif
> +
> +
> +/* Define to the level of your assembler's compressed debug section support.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_AS_COMPRESS_DEBUG no
> +#endif
> +
> +
> +/* Define if your assembler supports the DCI/ICI instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_DCI */
> +#endif
> +
> +
> +/* Define if your assembler supports the --debug-prefix-map option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_DEBUG_PREFIX_MAP */
> +#endif
> +
> +
> +/* Define if your assembler supports DFP instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_DFP */
> +#endif
> +
> +
> +/* Define if your assembler supports .module. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_DOT_MODULE */
> +#endif
> +
> +
> +/* Define if your assembler supports DSPR1 mult. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_DSPR1_MULT */
> +#endif
> +
> +
> +/* Define if your assembler supports .dtprelword. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_DTPRELWORD */
> +#endif
> +
> +
> +/* Define if your assembler supports dwarf2 .file/.loc directives, and
> +   preserves file table indices exactly as given. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_DWARF2_DEBUG_LINE */
> +#endif
> +
> +
> +/* Define if your assembler supports the R_PPC64_ENTRY relocation. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_ENTRY_MARKERS */
> +#endif
> +
> +
> +/* Define if your assembler supports explicit relocations. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_EXPLICIT_RELOCS */
> +#endif
> +
> +
> +/* Define if your assembler supports FMAF, HPC, and VIS 3.0 instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_FMAF_HPC_VIS3 */
> +#endif
> +
> +
> +/* Define if your assembler supports fprnd. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_FPRND */
> +#endif
> +
> +
> +/* Define if your assembler supports the --gdwarf2 option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_GDWARF2_DEBUG_FLAG */
> +#endif
> +
> +
> +/* Define if your assembler supports .gnu_attribute. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_GNU_ATTRIBUTE */
> +#endif
> +
> +
> +/* Define true if the assembler supports '.long foo@GOTOFF'. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_AS_GOTOFF_IN_DATA 0
> +#endif
> +
> +
> +/* Define if your assembler supports the --gstabs option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_GSTABS_DEBUG_FLAG */
> +#endif
> +
> +
> +/* Define if your assembler supports the Sun syntax for cmov. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_CMOV_SUN_SYNTAX */
> +#endif
> +
> +
> +/* Define if your assembler supports the subtraction of symbols in different
> +   sections. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_DIFF_SECT_DELTA */
> +#endif
> +
> +
> +/* Define if your assembler supports the ffreep mnemonic. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_FFREEP */
> +#endif
> +
> +
> +/* Define if your assembler uses fildq and fistq mnemonics. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_FILDQ */
> +#endif
> +
> +
> +/* Define if your assembler uses filds and fists mnemonics. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_FILDS */
> +#endif
> +
> +
> +/* Define 0/1 if your assembler and linker support @GOT. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_AS_IX86_GOT32X 0
> +#endif
> +
> +
> +/* Define if your assembler supports HLE prefixes. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_HLE */
> +#endif
> +
> +
> +/* Define if your assembler supports interunit movq mnemonic. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_AS_IX86_INTERUNIT_MOVQ 0
> +#endif
> +
> +
> +/* Define if your assembler supports the .quad directive. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_QUAD */
> +#endif
> +
> +
> +/* Define if the assembler supports 'rep <insn>, lock <insn>'. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_REP_LOCK_PREFIX */
> +#endif
> +
> +
> +/* Define if your assembler supports the sahf mnemonic in 64bit mode. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_SAHF */
> +#endif
> +
> +
> +/* Define if your assembler supports the swap suffix. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_SWAP */
> +#endif
> +
> +
> +/* Define if your assembler and linker support @tlsgdplt. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_TLSGDPLT */
> +#endif
> +
> +
> +/* Define to 1 if your assembler and linker support @tlsldm. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_AS_IX86_TLSLDM 0
> +#endif
> +
> +
> +/* Define to 1 if your assembler and linker support @tlsldmplt. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_AS_IX86_TLSLDMPLT 0
> +#endif
> +
> +
> +/* Define 0/1 if your assembler and linker support calling ___tls_get_addr via
> +   GOT. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_AS_IX86_TLS_GET_ADDR_GOT 0
> +#endif
> +
> +
> +/* Define if your assembler supports the 'ud2' mnemonic. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_IX86_UD2 */
> +#endif
> +
> +
> +/* Define if your assembler supports the lituse_jsrdirect relocation. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_JSRDIRECT_RELOCS */
> +#endif
> +
> +
> +/* Define if your assembler supports .sleb128 and .uleb128. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_AS_LEB128 0
> +#endif
> +
> +
> +/* Define if your assembler supports LEON instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_LEON */
> +#endif
> +
> +
> +/* Define if the assembler won't complain about a line such as # 0 "" 2. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_LINE_ZERO */
> +#endif
> +
> +
> +/* Define if your assembler supports ltoffx and ldxmov relocations. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_LTOFFX_LDXMOV_RELOCS */
> +#endif
> +
> +
> +/* Define if your assembler supports LWSYNC instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_LWSYNC */
> +#endif
> +
> +
> +/* Define if your assembler supports the -mabi option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_MABI_OPTION */
> +#endif
> +
> +
> +/* Define if your assembler supports .machine and .machinemode. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_MACHINE_MACHINEMODE */
> +#endif
> +
> +
> +/* Define if your assembler supports mfcr field. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_MFCRF */
> +#endif
> +
> +
> +/* Define if your assembler supports mffgpr and mftgpr. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_MFPGPR */
> +#endif
> +
> +
> +/* Define if your Mac OS X assembler supports the -mmacos-version-min option.
> +   */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_MMACOSX_VERSION_MIN_OPTION */
> +#endif
> +
> +
> +/* Define if the assembler understands -mnan=. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_NAN */
> +#endif
> +
> +
> +/* Define if your assembler supports the -no-mul-bug-abort option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_NO_MUL_BUG_ABORT_OPTION */
> +#endif
> +
> +
> +/* Define if the assembler understands -mno-shared. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_NO_SHARED */
> +#endif
> +
> +
> +/* Define if your assembler supports offsetable %lo(). */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_OFFSETABLE_LO10 */
> +#endif
> +
> +
> +/* Define if your assembler supports popcntb field. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_POPCNTB */
> +#endif
> +
> +
> +/* Define if your assembler supports POPCNTD instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_POPCNTD */
> +#endif
> +
> +
> +/* Define if your assembler supports POWER8 instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_POWER8 */
> +#endif
> +
> +
> +/* Define if your assembler supports POWER9 instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_POWER9 */
> +#endif
> +
> +
> +/* Define if your assembler supports .ref */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_REF */
> +#endif
> +
> +
> +/* Define if your assembler supports .register. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
> +#endif
> +
> +
> +/* Define if your assembler supports R_PPC_REL16 relocs. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_REL16 */
> +#endif
> +
> +
> +/* Define if your assembler supports -relax option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_RELAX_OPTION */
> +#endif
> +
> +
> +/* Define if your assembler supports relocs needed by -fpic. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_SMALL_PIC_RELOCS */
> +#endif
> +
> +
> +/* Define if your assembler supports SPARC4 instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_SPARC4 */
> +#endif
> +
> +
> +/* Define if your assembler supports SPARC5 and VIS 4.0 instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_SPARC5_VIS4 */
> +#endif
> +
> +/* Define if your assembler supports SPARC6 instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_SPARC6 */
> +#endif
> +
> +/* Define if your assembler and linker support GOTDATA_OP relocs. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_SPARC_GOTDATA_OP */
> +#endif
> +
> +
> +/* Define if your assembler and linker support unaligned PC relative relocs.
> +   */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_SPARC_UA_PCREL */
> +#endif
> +
> +
> +/* Define if your assembler and linker support unaligned PC relative relocs
> +   against hidden symbols. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_SPARC_UA_PCREL_HIDDEN */
> +#endif
> +
> +
> +/* Define if your assembler supports .stabs. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_STABS_DIRECTIVE */
> +#endif
> +
> +
> +/* Define if your assembler and linker support thread-local storage. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_TLS */
> +#endif
> +
> +
> +/* Define if your assembler supports arg info for __tls_get_addr. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_TLS_MARKERS */
> +#endif
> +
> +
> +/* Define if your assembler supports VSX instructions. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_VSX */
> +#endif
> +
> +
> +/* Define if your assembler supports -xbrace_comment option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_AS_XBRACE_COMMENT_OPTION */
> +#endif
> +
> +
> +/* Define to 1 if you have the `atoq' function. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_ATOQ */
> +#endif
> +
> +
> +/* Define to 1 if you have the `clearerr_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_CLEARERR_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `clock' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_CLOCK 1
> +#endif
> +
> +
> +/* Define if <time.h> defines clock_t. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_CLOCK_T 1
> +#endif
> +
> +
> +/* Define 0/1 if your assembler and linker support COMDAT groups. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_COMDAT_GROUP 0
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'abort', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_ABORT 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'asprintf', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_ASPRINTF 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'atof', otherwise define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_ATOF 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'atol', otherwise define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_ATOL 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'atoll', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_ATOLL 1
> +#endif
> +
> +
> +/* Define to 1 if you have the declaration of `basename(const char*)', and to
> +   0 if you don't. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_BASENAME 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'calloc', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_CALLOC 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'clearerr_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_CLEARERR_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'clock', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_CLOCK 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'errno', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_ERRNO 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'feof_unlocked', otherwise define
> +   to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FEOF_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'ferror_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FERROR_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'fflush_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FFLUSH_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'ffs', otherwise define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FFS 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'fgetc_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FGETC_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'fgets_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FGETS_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'fileno_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FILENO_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'fprintf_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FPRINTF_UNLOCKED 0
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'fputc_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FPUTC_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'fputs_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FPUTS_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'fread_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FREAD_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'free', otherwise define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FREE 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'fwrite_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_FWRITE_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'getchar_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_GETCHAR_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'getcwd', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_GETCWD 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'getc_unlocked', otherwise define
> +   to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_GETC_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'getenv', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_GETENV 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'getopt', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_GETOPT 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'getpagesize', otherwise define
> +   to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_GETPAGESIZE 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'getrlimit', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_GETRLIMIT 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'getrusage', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_GETRUSAGE 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'getwd', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_GETWD 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'ldgetname', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_LDGETNAME 0
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'madvise', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_MADVISE 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'malloc', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_MALLOC 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'putchar_unlocked', otherwise
> +   define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_PUTCHAR_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'putc_unlocked', otherwise define
> +   to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_PUTC_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'realloc', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_REALLOC 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'sbrk', otherwise define to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_SBRK 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'setenv', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_SETENV 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'setrlimit', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_SETRLIMIT 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'sigaltstack', otherwise define
> +   to 0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_SIGALTSTACK 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'snprintf', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_SNPRINTF 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'stpcpy', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_STPCPY 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'strnlen', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_STRNLEN 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'strsignal', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_STRSIGNAL 1
> +#endif
> +
> +
> +/* Define to 1 if you have the declaration of `strstr(const char*,const
> +   char*)', and to 0 if you don't. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_STRSTR 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'strtol', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_STRTOL 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'strtoll', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_STRTOLL 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'strtoul', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_STRTOUL 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'strtoull', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_STRTOULL 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'strverscmp', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_STRVERSCMP 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'times', otherwise define to 0.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_TIMES 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'unsetenv', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_UNSETENV 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'vasprintf', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_VASPRINTF 1
> +#endif
> +
> +
> +/* Define to 1 if we found a declaration for 'vsnprintf', otherwise define to
> +   0. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DECL_VSNPRINTF 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <direct.h> header file. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_DIRECT_H */
> +#endif
> +
> +
> +/* Define to 1 if you have the <dlfcn.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_DLFCN_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <ext/hash_map> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_EXT_HASH_MAP 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <fcntl.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FCNTL_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `feof_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FEOF_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `ferror_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FERROR_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `fflush_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FFLUSH_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `fgetc_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FGETC_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `fgets_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FGETS_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `fileno_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FILENO_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `fork' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FORK 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `fprintf_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_FPRINTF_UNLOCKED */
> +#endif
> +
> +
> +/* Define to 1 if you have the `fputc_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FPUTC_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `fputs_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FPUTS_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `fread_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FREAD_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <ftw.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FTW_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `fwrite_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_FWRITE_UNLOCKED 1
> +#endif
> +
> +
> +/* Define if your assembler supports specifying the alignment of objects
> +   allocated using the GAS .comm command. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_ALIGNED_COMM */
> +#endif
> +
> +
> +/* Define if your assembler supports .balign and .p2align. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_BALIGN_AND_P2ALIGN */
> +#endif
> +
> +
> +/* Define 0/1 if your assembler supports CFI directives. */
> +#define HAVE_GAS_CFI_DIRECTIVE 0
> +
> +/* Define 0/1 if your assembler supports .cfi_personality. */
> +#define HAVE_GAS_CFI_PERSONALITY_DIRECTIVE 0
> +
> +/* Define 0/1 if your assembler supports .cfi_sections. */
> +#define HAVE_GAS_CFI_SECTIONS_DIRECTIVE 0
> +
> +/* Define if your assembler supports the .loc discriminator sub-directive. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_DISCRIMINATOR */
> +#endif
> +
> +
> +/* Define if your assembler supports @gnu_unique_object. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_GNU_UNIQUE_OBJECT */
> +#endif
> +
> +
> +/* Define if your assembler and linker support .hidden. */
> +/* #undef HAVE_GAS_HIDDEN */
> +
> +/* Define if your assembler supports .lcomm with an alignment field. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_LCOMM_WITH_ALIGNMENT */
> +#endif
> +
> +
> +/* Define if your assembler supports .literal16. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_LITERAL16 */
> +#endif
> +
> +
> +/* Define if your assembler supports specifying the maximum number of bytes to
> +   skip when using the GAS .p2align command. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_MAX_SKIP_P2ALIGN */
> +#endif
> +
> +
> +/* Define if your assembler supports the .set micromips directive */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_MICROMIPS */
> +#endif
> +
> +
> +/* Define if your assembler supports .nsubspa comdat option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_NSUBSPA_COMDAT */
> +#endif
> +
> +
> +/* Define if your assembler and linker support 32-bit section relative relocs
> +   via '.secrel32 label'. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_PE_SECREL32_RELOC */
> +#endif
> +
> +
> +/* Define if your assembler supports specifying the section flag e. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GAS_SECTION_EXCLUDE 0
> +#endif
> +
> +
> +/* Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GAS_SHF_MERGE 0
> +#endif
> +
> +
> +/* Define if your assembler supports .subsection and .subsection -1 starts
> +   emitting at the beginning of your section. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_SUBSECTION_ORDERING */
> +#endif
> +
> +
> +/* Define if your assembler supports .weak. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_WEAK */
> +#endif
> +
> +
> +/* Define if your assembler supports .weakref. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GAS_WEAKREF */
> +#endif
> +
> +
> +/* Define to 1 if you have the `getchar_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GETCHAR_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `getc_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GETC_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `getrlimit' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GETRLIMIT 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `getrusage' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GETRUSAGE 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `gettimeofday' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GETTIMEOFDAY 1
> +#endif
> +
> +
> +/* Define to 1 if using GNU as. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GNU_AS 1
> +#endif
> +
> +
> +/* Define if your system supports gnu indirect functions. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GNU_INDIRECT_FUNCTION 1
> +#endif
> +
> +
> +/* Define to 1 if using GNU ld. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_GNU_LD 1
> +#endif
> +
> +
> +/* Define if the gold linker supports split stack and is available as a
> +   non-default */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_GOLD_NON_DEFAULT_SPLIT_STACK */
> +#endif
> +
> +
> +/* Define if you have the iconv() function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_ICONV 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <iconv.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_ICONV_H 1
> +#endif
> +
> +
> +/* Define 0/1 if .init_array/.fini_array sections are available and working.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_INITFINI_ARRAY_SUPPORT 0
> +#endif
> +
> +
> +/* Define to 1 if the system has the type `intmax_t'. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_INTMAX_T 1
> +#endif
> +
> +
> +/* Define to 1 if the system has the type `intptr_t'. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_INTPTR_T 1
> +#endif
> +
> +
> +/* Define if you have a working <inttypes.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_INTTYPES_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `kill' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_KILL 1
> +#endif
> +
> +
> +/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LANGINFO_CODESET 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <langinfo.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LANGINFO_H 1
> +#endif
> +
> +
> +/* Define if your <locale.h> file defines LC_MESSAGES. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LC_MESSAGES 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <ldfcn.h> header file. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LDFCN_H */
> +#endif
> +
> +
> +/* Define if your linker supports --as-needed/--no-as-needed or equivalent
> +   options. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_AS_NEEDED */
> +#endif
> +
> +
> +/* Define if your linker supports -z bndplt */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_BNDPLT_SUPPORT */
> +#endif
> +
> +
> +/* Define if your linker supports --build-id. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_BUILDID */
> +#endif
> +
> +
> +/* Define if the linker supports clearing hardware capabilities via mapfile.
> +   */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_CLEARCAP */
> +#endif
> +
> +
> +/* Define to the level of your linker's compressed debug section support. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LD_COMPRESS_DEBUG 0
> +#endif
> +
> +
> +/* Define if your linker supports --demangle option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_DEMANGLE */
> +#endif
> +
> +
> +/* Define 0/1 if your linker supports CIE v3 in .eh_frame. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LD_EH_FRAME_CIEV3 0
> +#endif
> +
> +
> +/* Define if your linker supports .eh_frame_hdr. */
> +/* #undef HAVE_LD_EH_FRAME_HDR */
> +
> +/* Define if your linker supports garbage collection of sections in presence
> +   of EH frames. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_EH_GC_SECTIONS */
> +#endif
> +
> +
> +/* Define if your linker has buggy garbage collection of sections support when
> +   .text.startup.foo like sections are used. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_EH_GC_SECTIONS_BUG */
> +#endif
> +
> +
> +/* Define if your PowerPC64 linker supports a large TOC. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_LARGE_TOC */
> +#endif
> +
> +
> +/* Define if your PowerPC64 linker only needs function descriptor syms. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_NO_DOT_SYMS */
> +#endif
> +
> +
> +/* Define if your linker can relax absolute .eh_frame personality pointers
> +   into PC-relative form. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_PERSONALITY_RELAXATION */
> +#endif
> +
> +
> +/* Define if your linker supports PIE option. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_PIE */
> +#endif
> +
> +
> +/* Define 0/1 if your linker supports -pie option with copy reloc. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LD_PIE_COPYRELOC 0
> +#endif
> +
> +
> +/* Define if your PowerPC linker has .gnu.attributes long double support. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE */
> +#endif
> +
> +
> +/* Define if your linker supports --push-state/--pop-state */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_PUSHPOPSTATE_SUPPORT */
> +#endif
> +
> +
> +/* Define if your linker links a mix of read-only and read-write sections into
> +   a read-write section. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_RO_RW_SECTION_MIXING */
> +#endif
> +
> +
> +/* Define if your linker supports the *_sol2 emulations. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_SOL2_EMULATION */
> +#endif
> +
> +
> +/* Define if your linker supports -Bstatic/-Bdynamic or equivalent options. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_STATIC_DYNAMIC */
> +#endif
> +
> +
> +/* Define if your linker supports --sysroot. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_LD_SYSROOT */
> +#endif
> +
> +
> +/* Define to 1 if you have the <limits.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LIMITS_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <locale.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LOCALE_H 1
> +#endif
> +
> +
> +/* Define to 1 if the system has the type `long long'. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LONG_LONG 1
> +#endif
> +
> +
> +/* Define to 1 if the system has the type `long long int'. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LONG_LONG_INT 1
> +#endif
> +
> +
> +/* Define to the level of your linker's plugin support. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_LTO_PLUGIN 0
> +#endif
> +
> +
> +/* Define to 1 if you have the `madvise' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_MADVISE 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <malloc.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_MALLOC_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `mbstowcs' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_MBSTOWCS 1
> +#endif
> +
> +
> +/* Define if valgrind's memcheck.h header is installed. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_MEMCHECK_H */
> +#endif
> +
> +
> +/* Define to 1 if you have the <memory.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_MEMORY_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `mmap' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_MMAP 1
> +#endif
> +
> +
> +/* Define if mmap with MAP_ANON(YMOUS) works. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_MMAP_ANON 1
> +#endif
> +
> +
> +/* Define if mmap of /dev/zero works. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_MMAP_DEV_ZERO 1
> +#endif
> +
> +
> +/* Define if read-only mmap of a plain file works. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_MMAP_FILE 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `nl_langinfo' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_NL_LANGINFO 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `popen' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_POPEN 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `putchar_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_PUTCHAR_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `putc_unlocked' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_PUTC_UNLOCKED 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `setlocale' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SETLOCALE 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `setrlimit' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SETRLIMIT 1
> +#endif
> +
> +
> +/* Define if the system-provided CRTs are present on Solaris. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_SOLARIS_CRTS */
> +#endif
> +
> +
> +/* Define to 1 if you have the <stddef.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_STDDEF_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <stdint.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_STDINT_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <stdlib.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_STDLIB_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <strings.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_STRINGS_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <string.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_STRING_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `strsignal' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_STRSIGNAL 1
> +#endif
> +
> +
> +/* Define if <sys/times.h> defines struct tms. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_STRUCT_TMS 1
> +#endif
> +
> +
> +/* Define if <utility> defines std::swap. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SWAP_IN_UTILITY 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `sysconf' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYSCONF 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <sys/file.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYS_FILE_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <sys/mman.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYS_MMAN_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <sys/param.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYS_PARAM_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <sys/resource.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYS_RESOURCE_H 1
> +#endif
> +
> +
> +/* Define if your target C library provides sys/sdt.h */
> +/* #undef HAVE_SYS_SDT_H */
> +
> +/* Define to 1 if you have the <sys/stat.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYS_STAT_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <sys/times.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYS_TIMES_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <sys/time.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYS_TIME_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <sys/types.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYS_TYPES_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_SYS_WAIT_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `times' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_TIMES 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <time.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_TIME_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <tr1/unordered_map> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_TR1_UNORDERED_MAP 1
> +#endif
> +
> +
> +/* Define to 1 if the system has the type `uintmax_t'. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_UINTMAX_T 1
> +#endif
> +
> +
> +/* Define to 1 if the system has the type `uintptr_t'. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_UINTPTR_T 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <unistd.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_UNISTD_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <unordered_map> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_UNORDERED_MAP 1
> +#endif
> +
> +
> +/* Define to 1 if the system has the type `unsigned long long int'. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_UNSIGNED_LONG_LONG_INT 1
> +#endif
> +
> +
> +/* Define if valgrind's valgrind/memcheck.h header is installed. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_VALGRIND_MEMCHECK_H */
> +#endif
> +
> +
> +/* Define to 1 if you have the `vfork' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_VFORK 1
> +#endif
> +
> +
> +/* Define to 1 if you have the <vfork.h> header file. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_VFORK_H */
> +#endif
> +
> +
> +/* Define to 1 if you have the <wchar.h> header file. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_WCHAR_H 1
> +#endif
> +
> +
> +/* Define to 1 if you have the `wcswidth' function. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_WCSWIDTH 1
> +#endif
> +
> +
> +/* Define to 1 if `fork' works. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_WORKING_FORK 1
> +#endif
> +
> +
> +/* Define this macro if mbstowcs does not crash when its first argument is
> +   NULL. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_WORKING_MBSTOWCS 1
> +#endif
> +
> +
> +/* Define to 1 if `vfork' works. */
> +#ifndef USED_FOR_TARGET
> +#define HAVE_WORKING_VFORK 1
> +#endif
> +
> +
> +/* Define if your assembler supports AIX debug frame section label reference.
> +   */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_XCOFF_DWARF_EXTRAS */
> +#endif
> +
> +
> +/* Define if isl is in use. */
> +#ifndef USED_FOR_TARGET
> +/* #undef HAVE_isl */
> +#endif
> +
> +
> +/* Define if F_SETLKW supported by fcntl. */
> +#ifndef USED_FOR_TARGET
> +#define HOST_HAS_F_SETLKW 1
> +#endif
> +
> +
> +/* Define as const if the declaration of iconv() needs const. */
> +#ifndef USED_FOR_TARGET
> +#define ICONV_CONST 
> +#endif
> +
> +
> +/* Define if int64_t uses long as underlying type. */
> +#ifndef USED_FOR_TARGET
> +#define INT64_T_IS_LONG 1
> +#endif
> +
> +
> +/* Define to 1 if ld64 supports '-export_dynamic'. */
> +#ifndef USED_FOR_TARGET
> +/* #undef LD64_HAS_EXPORT_DYNAMIC */
> +#endif
> +
> +
> +/* Define to ld64 version. */
> +#ifndef USED_FOR_TARGET
> +/* #undef LD64_VERSION */
> +#endif
> +
> +
> +/* Define to the linker option to ignore unused dependencies. */
> +#ifndef USED_FOR_TARGET
> +/* #undef LD_AS_NEEDED_OPTION */
> +#endif
> +
> +
> +/* Define to the linker option to enable compressed debug sections. */
> +#ifndef USED_FOR_TARGET
> +#define LD_COMPRESS_DEBUG_OPTION ""
> +#endif
> +
> +
> +/* Define to the linker option to enable use of shared objects. */
> +#ifndef USED_FOR_TARGET
> +/* #undef LD_DYNAMIC_OPTION */
> +#endif
> +
> +
> +/* Define to the linker option to keep unused dependencies. */
> +#ifndef USED_FOR_TARGET
> +/* #undef LD_NO_AS_NEEDED_OPTION */
> +#endif
> +
> +
> +/* Define to the linker option to disable use of shared objects. */
> +#ifndef USED_FOR_TARGET
> +/* #undef LD_STATIC_OPTION */
> +#endif
> +
> +
> +/* The linker hash style */
> +#ifndef USED_FOR_TARGET
> +/* #undef LINKER_HASH_STYLE */
> +#endif
> +
> +
> +/* Define to the name of the LTO plugin DSO that must be passed to the
> +   linker's -plugin=LIB option. */
> +#ifndef USED_FOR_TARGET
> +#define LTOPLUGINSONAME "liblto_plugin.so"
> +#endif
> +
> +
> +/* Define to the sub-directory in which libtool stores uninstalled libraries.
> +   */
> +#ifndef USED_FOR_TARGET
> +#define LT_OBJDIR ".libs/"
> +#endif
> +
> +
> +/* Define if host mkdir takes a single argument. */
> +#ifndef USED_FOR_TARGET
> +/* #undef MKDIR_TAKES_ONE_ARG */
> +#endif
> +
> +
> +/* Define to offload targets, separated by commas. */
> +#ifndef USED_FOR_TARGET
> +#define OFFLOAD_TARGETS ""
> +#endif
> +
> +
> +/* Define to the address where bug reports for this package should be sent. */
> +#ifndef USED_FOR_TARGET
> +#define PACKAGE_BUGREPORT ""
> +#endif
> +
> +
> +/* Define to the full name of this package. */
> +#ifndef USED_FOR_TARGET
> +#define PACKAGE_NAME ""
> +#endif
> +
> +
> +/* Define to the full name and version of this package. */
> +#ifndef USED_FOR_TARGET
> +#define PACKAGE_STRING ""
> +#endif
> +
> +
> +/* Define to the one symbol short name of this package. */
> +#ifndef USED_FOR_TARGET
> +#define PACKAGE_TARNAME ""
> +#endif
> +
> +
> +/* Define to the home page for this package. */
> +#ifndef USED_FOR_TARGET
> +#define PACKAGE_URL ""
> +#endif
> +
> +
> +/* Define to the version of this package. */
> +#ifndef USED_FOR_TARGET
> +#define PACKAGE_VERSION ""
> +#endif
> +
> +
> +/* Specify plugin linker */
> +#ifndef USED_FOR_TARGET
> +#define PLUGIN_LD_SUFFIX ""
> +#endif
> +
> +
> +/* Define to .TOC. alignment forced by your linker. */
> +#ifndef USED_FOR_TARGET
> +/* #undef POWERPC64_TOC_POINTER_ALIGNMENT */
> +#endif
> +
> +
> +/* Define to PREFIX/include if cpp should also search that directory. */
> +#ifndef USED_FOR_TARGET
> +/* #undef PREFIX_INCLUDE_DIR */
> +#endif
> +
> +
> +/* The size of `int', as computed by sizeof. */
> +#ifndef USED_FOR_TARGET
> +#define SIZEOF_INT 4
> +#endif
> +
> +
> +/* The size of `long', as computed by sizeof. */
> +#ifndef USED_FOR_TARGET
> +#define SIZEOF_LONG 8
> +#endif
> +
> +
> +/* The size of `long long', as computed by sizeof. */
> +#ifndef USED_FOR_TARGET
> +#define SIZEOF_LONG_LONG 8
> +#endif
> +
> +
> +/* The size of `short', as computed by sizeof. */
> +#ifndef USED_FOR_TARGET
> +#define SIZEOF_SHORT 2
> +#endif
> +
> +
> +/* The size of `void *', as computed by sizeof. */
> +#ifndef USED_FOR_TARGET
> +#define SIZEOF_VOID_P 8
> +#endif
> +
> +
> +/* Define to 1 if you have the ANSI C header files. */
> +#ifndef USED_FOR_TARGET
> +#define STDC_HEADERS 1
> +#endif
> +
> +
> +/* Define if you can safely include both <string.h> and <strings.h>. */
> +#ifndef USED_FOR_TARGET
> +#define STRING_WITH_STRINGS 1
> +#endif
> +
> +
> +/* Define if TFmode long double should be the default */
> +#ifndef USED_FOR_TARGET
> +/* #undef TARGET_DEFAULT_LONG_DOUBLE_128 */
> +#endif
> +
> +
> +/* Define if your target C library provides the `dl_iterate_phdr' function. */
> +/* #undef TARGET_DL_ITERATE_PHDR */
> +
> +/* GNU C Library major version number used on the target, or 0. */
> +#ifndef USED_FOR_TARGET
> +#define TARGET_GLIBC_MAJOR 2
> +#endif
> +
> +
> +/* GNU C Library minor version number used on the target, or 0. */
> +#ifndef USED_FOR_TARGET
> +#define TARGET_GLIBC_MINOR 27
> +#endif
> +
> +
> +/* Define if your target C Library provides the AT_HWCAP value in the TCB */
> +#ifndef USED_FOR_TARGET
> +/* #undef TARGET_LIBC_PROVIDES_HWCAP_IN_TCB */
> +#endif
> +
> +
> +/* Define if your target C library provides stack protector support */
> +#ifndef USED_FOR_TARGET
> +#define TARGET_LIBC_PROVIDES_SSP 1
> +#endif
> +
> +
> +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
> +#ifndef USED_FOR_TARGET
> +#define TIME_WITH_SYS_TIME 1
> +#endif
> +
> +
> +/* Define to the flag used to mark TLS sections if the default (`T') doesn't
> +   work. */
> +#ifndef USED_FOR_TARGET
> +/* #undef TLS_SECTION_ASM_FLAG */
> +#endif
> +
> +
> +/* Define if your assembler mis-optimizes .eh_frame data. */
> +#ifndef USED_FOR_TARGET
> +/* #undef USE_AS_TRADITIONAL_FORMAT */
> +#endif
> +
> +
> +/* Define if you want to generate code by default that assumes that the Cygwin
> +   DLL exports wrappers to support libstdc++ function replacement. */
> +#ifndef USED_FOR_TARGET
> +/* #undef USE_CYGWIN_LIBSTDCXX_WRAPPERS */
> +#endif
> +
> +
> +/* Define to 1 if the 'long long' type is wider than 'long' but still
> +   efficiently supported by the host hardware. */
> +#ifndef USED_FOR_TARGET
> +/* #undef USE_LONG_LONG_FOR_WIDEST_FAST_INT */
> +#endif
> +
> +
> +/* Define if we should use leading underscore on 64 bit mingw targets */
> +#ifndef USED_FOR_TARGET
> +/* #undef USE_MINGW64_LEADING_UNDERSCORES */
> +#endif
> +
> +
> +/* Enable extensions on AIX 3, Interix.  */
> +#ifndef _ALL_SOURCE
> +# define _ALL_SOURCE 1
> +#endif
> +/* Enable GNU extensions on systems that have them.  */
> +#ifndef _GNU_SOURCE
> +# define _GNU_SOURCE 1
> +#endif
> +/* Enable threading extensions on Solaris.  */
> +#ifndef _POSIX_PTHREAD_SEMANTICS
> +# define _POSIX_PTHREAD_SEMANTICS 1
> +#endif
> +/* Enable extensions on HP NonStop.  */
> +#ifndef _TANDEM_SOURCE
> +# define _TANDEM_SOURCE 1
> +#endif
> +/* Enable general extensions on Solaris.  */
> +#ifndef __EXTENSIONS__
> +# define __EXTENSIONS__ 1
> +#endif
> +
> +
> +/* Define to be the last component of the Windows registry key under which to
> +   look for installation paths. The full key used will be
> +   HKEY_LOCAL_MACHINE/SOFTWARE/Free Software Foundation/{WIN32_REGISTRY_KEY}.
> +   The default is the GCC version number. */
> +#ifndef USED_FOR_TARGET
> +/* #undef WIN32_REGISTRY_KEY */
> +#endif
> +
> +
> +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
> +   significant byte first (like Motorola and SPARC, unlike Intel). */
> +#if defined AC_APPLE_UNIVERSAL_BUILD
> +# if defined __BIG_ENDIAN__
> +#  define WORDS_BIGENDIAN 1
> +# endif
> +#else
> +# ifndef WORDS_BIGENDIAN
> +/* #  undef WORDS_BIGENDIAN */
> +# endif
> +#endif
> +
> +/* Number of bits in a file offset, on hosts where this is settable. */
> +#ifndef USED_FOR_TARGET
> +/* #undef _FILE_OFFSET_BITS */
> +#endif
> +
> +
> +/* Define for large files, on AIX-style hosts. */
> +#ifndef USED_FOR_TARGET
> +/* #undef _LARGE_FILES */
> +#endif
> +
> +
> +/* Define to 1 if on MINIX. */
> +#ifndef USED_FOR_TARGET
> +/* #undef _MINIX */
> +#endif
> +
> +
> +/* Define to 2 if the system does not provide POSIX.1 features except with
> +   this defined. */
> +#ifndef USED_FOR_TARGET
> +/* #undef _POSIX_1_SOURCE */
> +#endif
> +
> +
> +/* Define to 1 if you need to in order for `stat' and other things to work. */
> +#ifndef USED_FOR_TARGET
> +/* #undef _POSIX_SOURCE */
> +#endif
> +
> +
> +/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
> +   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
> +   #define below would cause a syntax error. */
> +#ifndef USED_FOR_TARGET
> +/* #undef _UINT32_T */
> +#endif
> +
> +
> +/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
> +   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
> +   #define below would cause a syntax error. */
> +#ifndef USED_FOR_TARGET
> +/* #undef _UINT64_T */
> +#endif
> +
> +
> +/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
> +   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
> +   #define below would cause a syntax error. */
> +#ifndef USED_FOR_TARGET
> +/* #undef _UINT8_T */
> +#endif
> +
> +
> +/* Define to `char *' if <sys/types.h> does not define. */
> +#ifndef USED_FOR_TARGET
> +/* #undef caddr_t */
> +#endif
> +
> +
> +/* Define to `__inline__' or `__inline' if that's what the C compiler
> +   calls it, or to nothing if 'inline' is not supported under any name.  */
> +#ifndef __cplusplus
> +/* #undef inline */
> +#endif
> +
> +/* Define to the type of a signed integer type of width exactly 16 bits if
> +   such a type exists and the standard includes do not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef int16_t */
> +#endif
> +
> +
> +/* Define to the type of a signed integer type of width exactly 32 bits if
> +   such a type exists and the standard includes do not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef int32_t */
> +#endif
> +
> +
> +/* Define to the type of a signed integer type of width exactly 64 bits if
> +   such a type exists and the standard includes do not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef int64_t */
> +#endif
> +
> +
> +/* Define to the type of a signed integer type of width exactly 8 bits if such
> +   a type exists and the standard includes do not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef int8_t */
> +#endif
> +
> +
> +/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
> +   not define. */
> +#ifndef USED_FOR_TARGET
> +/* #undef intmax_t */
> +#endif
> +
> +
> +/* Define to the type of a signed integer type wide enough to hold a pointer,
> +   if such a type exists, and if the system does not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef intptr_t */
> +#endif
> +
> +
> +/* Define to `int' if <sys/types.h> does not define. */
> +#ifndef USED_FOR_TARGET
> +/* #undef pid_t */
> +#endif
> +
> +
> +/* Define to `long' if <sys/resource.h> doesn't define. */
> +#ifndef USED_FOR_TARGET
> +/* #undef rlim_t */
> +#endif
> +
> +
> +/* Define to `int' if <sys/types.h> does not define. */
> +#ifndef USED_FOR_TARGET
> +/* #undef ssize_t */
> +#endif
> +
> +
> +/* Define to the type of an unsigned integer type of width exactly 16 bits if
> +   such a type exists and the standard includes do not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef uint16_t */
> +#endif
> +
> +
> +/* Define to the type of an unsigned integer type of width exactly 32 bits if
> +   such a type exists and the standard includes do not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef uint32_t */
> +#endif
> +
> +
> +/* Define to the type of an unsigned integer type of width exactly 64 bits if
> +   such a type exists and the standard includes do not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef uint64_t */
> +#endif
> +
> +
> +/* Define to the type of an unsigned integer type of width exactly 8 bits if
> +   such a type exists and the standard includes do not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef uint8_t */
> +#endif
> +
> +
> +/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
> +   do not define. */
> +#ifndef USED_FOR_TARGET
> +/* #undef uintmax_t */
> +#endif
> +
> +
> +/* Define to the type of an unsigned integer type wide enough to hold a
> +   pointer, if such a type exists, and if the system does not define it. */
> +#ifndef USED_FOR_TARGET
> +/* #undef uintptr_t */
> +#endif
> +
> +
> +/* Define as `fork' if `vfork' does not work. */
> +#ifndef USED_FOR_TARGET
> +/* #undef vfork */
> +#endif
> +
> diff --git a/libgcov/include/config/auto-target.h b/libgcov/include/config/auto-target.h
> new file mode 100644
> index 0000000..1ab0d1b
> --- /dev/null
> +++ b/libgcov/include/config/auto-target.h
> @@ -0,0 +1,80 @@
> +/* auto-target.h.  Generated from config.in by configure.  */
> +/* config.in.  Generated from configure.ac by autoheader.  */
> +
> +/* Define to 1 if the target assembler supports thread-local storage. */
> +/* #undef HAVE_CC_TLS */
> +
> +/* Define to 1 if you have the <ftw.h> header file. */
> +#define HAVE_FTW_H 1
> +
> +/* Define if _Unwind_GetIPInfo is available. */
> +#define HAVE_GETIPINFO 1
> +
> +/* Define if the compiler supports init priority. */
> +#define HAVE_INIT_PRIORITY 1
> +
> +/* Define to 1 if you have the <inttypes.h> header file. */
> +#define HAVE_INTTYPES_H 1
> +
> +/* Define to 1 if you have the <memory.h> header file. */
> +#define HAVE_MEMORY_H 1
> +
> +/* Define if the system-provided CRTs are present on Solaris. */
> +/* #undef HAVE_SOLARIS_CRTS */
> +
> +/* Define to 1 if you have the <stdint.h> header file. */
> +#define HAVE_STDINT_H 1
> +
> +/* Define to 1 if you have the <stdlib.h> header file. */
> +#define HAVE_STDLIB_H 1
> +
> +/* Define to 1 if you have the <strings.h> header file. */
> +#define HAVE_STRINGS_H 1
> +
> +/* Define to 1 if you have the <string.h> header file. */
> +#define HAVE_STRING_H 1
> +
> +/* Define to 1 if you have the <sys/stat.h> header file. */
> +#define HAVE_SYS_STAT_H 1
> +
> +/* Define to 1 if you have the <sys/types.h> header file. */
> +#define HAVE_SYS_TYPES_H 1
> +
> +/* Define to 1 if you have the <unistd.h> header file. */
> +#define HAVE_UNISTD_H 1
> +
> +/* Define to the address where bug reports for this package should be sent. */
> +#define PACKAGE_BUGREPORT ""
> +
> +/* Define to the full name of this package. */
> +#define PACKAGE_NAME "GNU C Runtime Library"
> +
> +/* Define to the full name and version of this package. */
> +#define PACKAGE_STRING "GNU C Runtime Library 1.0"
> +
> +/* Define to the one symbol short name of this package. */
> +#define PACKAGE_TARNAME "libgcc"
> +
> +/* Define to the home page for this package. */
> +#define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
> +
> +/* Define to the version of this package. */
> +#define PACKAGE_VERSION "1.0"
> +
> +/* The size of `double', as computed by sizeof. */
> +#define SIZEOF_DOUBLE 8
> +
> +/* The size of `long double', as computed by sizeof. */
> +#define SIZEOF_LONG_DOUBLE 16
> +
> +/* Define to 1 if you have the ANSI C header files. */
> +#define STDC_HEADERS 1
> +
> +/* Define to 1 if the target use emutls for thread-local storage. */
> +/* #undef USE_EMUTLS */
> +
> +/* Number of bits in a file offset, on hosts where this is settable. */
> +/* #undef _FILE_OFFSET_BITS */
> +
> +/* Define for large files, on AIX-style hosts. */
> +/* #undef _LARGE_FILES */
> diff --git a/libgcov/include/config/gcov-iov.h b/libgcov/include/config/gcov-iov.h
> new file mode 100644
> index 0000000..4f4f2f5
> --- /dev/null
> +++ b/libgcov/include/config/gcov-iov.h
> @@ -0,0 +1,4 @@
> +/* Generated automatically by the program `build/gcov-iov'
> +   from `7.5.0 (7 5) and  (*)'.  */
> +
> +#define GCOV_VERSION ((gcov_unsigned_t)0x4137352a)  /* A75* */
> diff --git a/libgcov/include/config/libgcc_tm.h b/libgcov/include/config/libgcc_tm.h
> new file mode 100644
> index 0000000..491425c
> --- /dev/null
> +++ b/libgcov/include/config/libgcc_tm.h
> @@ -0,0 +1,6 @@
> +#ifndef LIBGCC_TM_H
> +#define LIBGCC_TM_H
> +/* Automatically generated by mkheader.sh.  */
> +#include "elf-lib.h"
> +#include "value-unwind.h"
> +#endif /* LIBGCC_TM_H */
> diff --git a/libgcov/include/config/tconfig.h b/libgcov/include/config/tconfig.h
> new file mode 100644
> index 0000000..7ec80a1
> --- /dev/null
> +++ b/libgcov/include/config/tconfig.h
> @@ -0,0 +1,10 @@
> +#ifndef GCC_TCONFIG_H
> +#define GCC_TCONFIG_H
> +#ifndef USED_FOR_TARGET
> +# define USED_FOR_TARGET
> +#endif
> +#include "auto-host.h"
> +#ifdef IN_GCC
> +# include "ansidecl.h"
> +#endif
> +#endif /* GCC_TCONFIG_H */
> diff --git a/libgcov/include/config/tm.h b/libgcov/include/config/tm.h
> new file mode 100644
> index 0000000..611fa76
> --- /dev/null
> +++ b/libgcov/include/config/tm.h
> @@ -0,0 +1,52 @@
> +#ifndef GCC_TM_H
> +#define GCC_TM_H
> +#ifndef LIBC_GLIBC
> +# define LIBC_GLIBC 1
> +#endif
> +#ifndef LIBC_UCLIBC
> +# define LIBC_UCLIBC 2
> +#endif
> +#ifndef LIBC_BIONIC
> +# define LIBC_BIONIC 3
> +#endif
> +#ifndef LIBC_MUSL
> +# define LIBC_MUSL 4
> +#endif
> +#ifndef DEFAULT_LIBC
> +# define DEFAULT_LIBC LIBC_GLIBC
> +#endif
> +#ifndef ANDROID_DEFAULT
> +# define ANDROID_DEFAULT 0
> +#endif
> +#ifdef IN_GCC
> +# include "options.h"
> +# include "insn-constants.h"
> +# include "config/vxworks-dummy.h"
> +# include "config/i386/biarch64.h"
> +# include "config/i386/i386.h"
> +# include "config/i386/unix.h"
> +# include "config/i386/att.h"
> +# include "config/dbxelf.h"
> +# include "config/elfos.h"
> +# include "config/gnu-user.h"
> +# include "config/glibc-stdint.h"
> +# include "config/i386/x86-64.h"
> +# include "config/i386/gnu-user-common.h"
> +# include "config/i386/gnu-user64.h"
> +# include "config/linux.h"
> +# include "config/linux-android.h"
> +# include "config/i386/linux-common.h"
> +# include "config/i386/linux64.h"
> +# include "config/initfini-array.h"
> +#endif
> +#if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET
> +# include "insn-flags.h"
> +#endif
> +#if defined IN_GCC && !defined GENERATOR_FILE
> +# include "insn-modes.h"
> +#endif
> +#if defined IN_GCC && defined GENERATOR_FILE && !defined BITS_PER_UNIT
> +#include "machmode.h"
> +#endif
> +# include "defaults.h"
> +#endif /* GCC_TM_H */
> diff --git a/libgcov/include/coretypes.h b/libgcov/include/coretypes.h
> new file mode 100644
> index 0000000..8eb33cc
> --- /dev/null
> +++ b/libgcov/include/coretypes.h
> @@ -0,0 +1,376 @@
> +/* GCC core type declarations.
> +   Copyright (C) 2002-2017 Free Software Foundation, Inc.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +Under Section 7 of GPL version 3, you are granted additional
> +permissions described in the GCC Runtime Library Exception, version
> +3.1, as published by the Free Software Foundation.
> +
> +You should have received a copy of the GNU General Public License and
> +a copy of the GCC Runtime Library Exception along with this program;
> +see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +<http://www.gnu.org/licenses/>.  */
> +
> +/* Provide forward declarations of core types which are referred to by
> +   most of the compiler.  This allows header files to use these types
> +   (e.g. in function prototypes) without concern for whether the full
> +   definitions are visible.  Some other declarations that need to be
> +   universally visible are here, too.
> +
> +   In the context of tconfig.h, most of these have special definitions
> +   which prevent them from being used except in further type
> +   declarations.  This is a kludge; the right thing is to avoid
> +   including the "tm.h" header set in the context of tconfig.h, but
> +   we're not there yet.  */
> +
> +#ifndef GCC_CORETYPES_H
> +#define GCC_CORETYPES_H
> +
> +#ifndef GTY
> +#define GTY(x)  /* nothing - marker for gengtype */
> +#endif
> +
> +#ifndef USED_FOR_TARGET
> +
> +typedef int64_t gcov_type;
> +typedef uint64_t gcov_type_unsigned;
> +
> +struct bitmap_head;
> +typedef struct bitmap_head *bitmap;
> +typedef const struct bitmap_head *const_bitmap;
> +struct simple_bitmap_def;
> +typedef struct simple_bitmap_def *sbitmap;
> +typedef const struct simple_bitmap_def *const_sbitmap;
> +struct rtx_def;
> +typedef struct rtx_def *rtx;
> +typedef const struct rtx_def *const_rtx;
> +
> +/* Subclasses of rtx_def, using indentation to show the class
> +   hierarchy, along with the relevant invariant.
> +   Where possible, keep this list in the same order as in rtl.def.  */
> +class rtx_def;
> +  class rtx_expr_list;           /* GET_CODE (X) == EXPR_LIST */
> +  class rtx_insn_list;           /* GET_CODE (X) == INSN_LIST */
> +  class rtx_sequence;            /* GET_CODE (X) == SEQUENCE */
> +  class rtx_insn;
> +    class rtx_debug_insn;      /* DEBUG_INSN_P (X) */
> +    class rtx_nonjump_insn;    /* NONJUMP_INSN_P (X) */
> +    class rtx_jump_insn;       /* JUMP_P (X) */
> +    class rtx_call_insn;       /* CALL_P (X) */
> +    class rtx_jump_table_data; /* JUMP_TABLE_DATA_P (X) */
> +    class rtx_barrier;         /* BARRIER_P (X) */
> +    class rtx_code_label;      /* LABEL_P (X) */
> +    class rtx_note;            /* NOTE_P (X) */
> +
> +struct rtvec_def;
> +typedef struct rtvec_def *rtvec;
> +typedef const struct rtvec_def *const_rtvec;
> +struct hwivec_def;
> +typedef struct hwivec_def *hwivec;
> +typedef const struct hwivec_def *const_hwivec;
> +union tree_node;
> +typedef union tree_node *tree;
> +typedef const union tree_node *const_tree;
> +struct gimple;
> +typedef gimple *gimple_seq;
> +struct gimple_stmt_iterator;
> +
> +/* Forward decls for leaf gimple subclasses (for individual gimple codes).
> +   Keep this in the same order as the corresponding codes in gimple.def.  */
> +
> +struct gcond;
> +struct gdebug;
> +struct ggoto;
> +struct glabel;
> +struct gswitch;
> +struct gassign;
> +struct gasm;
> +struct gcall;
> +struct gtransaction;
> +struct greturn;
> +struct gbind;
> +struct gcatch;
> +struct geh_filter;
> +struct geh_mnt;
> +struct geh_else;
> +struct gresx;
> +struct geh_dispatch;
> +struct gphi;
> +struct gtry;
> +struct gomp_atomic_load;
> +struct gomp_atomic_store;
> +struct gomp_continue;
> +struct gomp_critical;
> +struct gomp_ordered;
> +struct gomp_for;
> +struct gomp_parallel;
> +struct gomp_task;
> +struct gomp_sections;
> +struct gomp_single;
> +struct gomp_target;
> +struct gomp_teams;
> +
> +union section;
> +typedef union section section;
> +struct gcc_options;
> +struct cl_target_option;
> +struct cl_optimization;
> +struct cl_option;
> +struct cl_decoded_option;
> +struct cl_option_handlers;
> +struct diagnostic_context;
> +struct pretty_printer;
> +
> +/* Address space number for named address space support.  */
> +typedef unsigned char addr_space_t;
> +
> +/* The value of addr_space_t that represents the generic address space.  */
> +#define ADDR_SPACE_GENERIC 0
> +#define ADDR_SPACE_GENERIC_P(AS) ((AS) == ADDR_SPACE_GENERIC)
> +
> +/* The major intermediate representations of GCC.  */
> +enum ir_type {
> +  IR_GIMPLE,
> +  IR_RTL_CFGRTL,
> +  IR_RTL_CFGLAYOUT
> +};
> +
> +/* Provide forward struct declaration so that we don't have to include
> +   all of cpplib.h whenever a random prototype includes a pointer.
> +   Note that the cpp_reader and cpp_token typedefs remain part of
> +   cpplib.h.  */
> +
> +struct cpp_reader;
> +struct cpp_token;
> +
> +/* The thread-local storage model associated with a given VAR_DECL
> +   or SYMBOL_REF.  This isn't used much, but both trees and RTL refer
> +   to it, so it's here.  */
> +enum tls_model {
> +  TLS_MODEL_NONE,
> +  TLS_MODEL_EMULATED,
> +  TLS_MODEL_REAL,
> +  TLS_MODEL_GLOBAL_DYNAMIC = TLS_MODEL_REAL,
> +  TLS_MODEL_LOCAL_DYNAMIC,
> +  TLS_MODEL_INITIAL_EXEC,
> +  TLS_MODEL_LOCAL_EXEC
> +};
> +
> +/* Types of ABI for an offload compiler.  */
> +enum offload_abi {
> +  OFFLOAD_ABI_UNSET,
> +  OFFLOAD_ABI_LP64,
> +  OFFLOAD_ABI_ILP32
> +};
> +
> +/* Types of profile update methods.  */
> +enum profile_update {
> +  PROFILE_UPDATE_SINGLE,
> +  PROFILE_UPDATE_ATOMIC,
> +  PROFILE_UPDATE_PREFER_ATOMIC
> +};
> +
> +/* Types of unwind/exception handling info that can be generated.  */
> +
> +enum unwind_info_type
> +{
> +  UI_NONE,
> +  UI_SJLJ,
> +  UI_DWARF2,
> +  UI_TARGET,
> +  UI_SEH
> +};
> +
> +/* Callgraph node profile representation.  */
> +enum node_frequency {
> +  /* This function most likely won't be executed at all.
> +     (set only when profile feedback is available or via function attribute). */
> +  NODE_FREQUENCY_UNLIKELY_EXECUTED,
> +  /* For functions that are known to be executed once (i.e. constructors, destructors
> +     and main function.  */
> +  NODE_FREQUENCY_EXECUTED_ONCE,
> +  /* The default value.  */
> +  NODE_FREQUENCY_NORMAL,
> +  /* Optimize this function hard
> +     (set only when profile feedback is available or via function attribute). */
> +  NODE_FREQUENCY_HOT
> +};
> +
> +/* Ways of optimizing code.  */
> +enum optimization_type {
> +  /* Prioritize speed over size.  */
> +  OPTIMIZE_FOR_SPEED,
> +
> +  /* Only do things that are good for both size and speed.  */
> +  OPTIMIZE_FOR_BOTH,
> +
> +  /* Prioritize size over speed.  */
> +  OPTIMIZE_FOR_SIZE
> +};
> +
> +/* Possible initialization status of a variable.   When requested
> +   by the user, this information is tracked and recorded in the DWARF
> +   debug information, along with the variable's location.  */
> +enum var_init_status
> +{
> +  VAR_INIT_STATUS_UNKNOWN,
> +  VAR_INIT_STATUS_UNINITIALIZED,
> +  VAR_INIT_STATUS_INITIALIZED
> +};
> +
> +/* Names for the different levels of -Wstrict-overflow=N.  The numeric
> +   values here correspond to N.  */
> +enum warn_strict_overflow_code
> +{
> +  /* Overflow warning that should be issued with -Wall: a questionable
> +     construct that is easy to avoid even when using macros.  Example:
> +     folding (x + CONSTANT > x) to 1.  */
> +  WARN_STRICT_OVERFLOW_ALL = 1,
> +  /* Overflow warning about folding a comparison to a constant because
> +     of undefined signed overflow, other than cases covered by
> +     WARN_STRICT_OVERFLOW_ALL.  Example: folding (abs (x) >= 0) to 1
> +     (this is false when x == INT_MIN).  */
> +  WARN_STRICT_OVERFLOW_CONDITIONAL = 2,
> +  /* Overflow warning about changes to comparisons other than folding
> +     them to a constant.  Example: folding (x + 1 > 1) to (x > 0).  */
> +  WARN_STRICT_OVERFLOW_COMPARISON = 3,
> +  /* Overflow warnings not covered by the above cases.  Example:
> +     folding ((x * 10) / 5) to (x * 2).  */
> +  WARN_STRICT_OVERFLOW_MISC = 4,
> +  /* Overflow warnings about reducing magnitude of constants in
> +     comparison.  Example: folding (x + 2 > y) to (x + 1 >= y).  */
> +  WARN_STRICT_OVERFLOW_MAGNITUDE = 5
> +};
> +
> +/* The type of an alias set.  Code currently assumes that variables of
> +   this type can take the values 0 (the alias set which aliases
> +   everything) and -1 (sometimes indicating that the alias set is
> +   unknown, sometimes indicating a memory barrier) and -2 (indicating
> +   that the alias set should be set to a unique value but has not been
> +   set yet).  */
> +typedef int alias_set_type;
> +
> +struct edge_def;
> +typedef struct edge_def *edge;
> +typedef const struct edge_def *const_edge;
> +struct basic_block_def;
> +typedef struct basic_block_def *basic_block;
> +typedef const struct basic_block_def *const_basic_block;
> +
> +#if !defined (GENERATOR_FILE)
> +# define OBSTACK_CHUNK_SIZE     memory_block_pool::block_size
> +# define obstack_chunk_alloc    mempool_obstack_chunk_alloc
> +# define obstack_chunk_free     mempool_obstack_chunk_free
> +#else
> +# define OBSTACK_CHUNK_SIZE     0
> +# define obstack_chunk_alloc    xmalloc
> +# define obstack_chunk_free     free
> +#endif
> +
> +#define gcc_obstack_init(OBSTACK)				\
> +  obstack_specify_allocation ((OBSTACK), OBSTACK_CHUNK_SIZE, 0,	\
> +			      obstack_chunk_alloc,		\
> +			      obstack_chunk_free)
> +
> +/* enum reg_class is target specific, so it should not appear in
> +   target-independent code or interfaces, like the target hook declarations
> +   in target.h.  */
> +typedef int reg_class_t;
> +
> +class rtl_opt_pass;
> +
> +namespace gcc {
> +  class context;
> +}
> +
> +typedef std::pair <tree, tree> tree_pair;
> +
> +#else
> +
> +struct _dont_use_rtx_here_;
> +struct _dont_use_rtvec_here_;
> +struct _dont_use_rtx_insn_here_;
> +union _dont_use_tree_here_;
> +#define rtx struct _dont_use_rtx_here_ *
> +#define const_rtx struct _dont_use_rtx_here_ *
> +#define rtvec struct _dont_use_rtvec_here *
> +#define const_rtvec struct _dont_use_rtvec_here *
> +#define rtx_insn struct _dont_use_rtx_insn_here_
> +#define tree union _dont_use_tree_here_ *
> +#define const_tree union _dont_use_tree_here_ *
> +
> +#endif
> +
> +/* Classes of functions that compiler needs to check
> +   whether they are present at the runtime or not.  */
> +enum function_class {
> +  function_c94,
> +  function_c99_misc,
> +  function_c99_math_complex,
> +  function_sincos,
> +  function_c11_misc
> +};
> +
> +/* Enumerate visibility settings.  This is deliberately ordered from most
> +   to least visibility.  */
> +enum symbol_visibility
> +{
> +  VISIBILITY_DEFAULT,
> +  VISIBILITY_PROTECTED,
> +  VISIBILITY_HIDDEN,
> +  VISIBILITY_INTERNAL
> +};
> +
> +/* enums used by the targetm.excess_precision hook.  */
> +
> +enum flt_eval_method
> +{
> +  FLT_EVAL_METHOD_UNPREDICTABLE = -1,
> +  FLT_EVAL_METHOD_PROMOTE_TO_FLOAT = 0,
> +  FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE = 1,
> +  FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE = 2,
> +  FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 = 16
> +};
> +
> +enum excess_precision_type
> +{
> +  EXCESS_PRECISION_TYPE_IMPLICIT,
> +  EXCESS_PRECISION_TYPE_STANDARD,
> +  EXCESS_PRECISION_TYPE_FAST
> +};
> +
> +/* Support for user-provided GGC and PCH markers.  The first parameter
> +   is a pointer to a pointer, the second a cookie.  */
> +typedef void (*gt_pointer_operator) (void *, void *);
> +
> +#if !defined (HAVE_UCHAR)
> +typedef unsigned char uchar;
> +#endif
> +
> +/* Most host source files will require the following headers.  */
> +#if !defined (GENERATOR_FILE) && !defined (USED_FOR_TARGET)
> +#include "machmode.h"
> +#include "signop.h"
> +#include "wide-int.h" 
> +#include "double-int.h"
> +#include "real.h"
> +#include "fixed-value.h"
> +#include "hash-table.h"
> +#include "hash-set.h"
> +#include "input.h"
> +#include "is-a.h"
> +#include "memory-block.h"
> +#endif /* GENERATOR_FILE && !USED_FOR_TARGET */
> +
> +#endif /* coretypes.h */
> diff --git a/libgcov/include/defaults.h b/libgcov/include/defaults.h
> new file mode 100644
> index 0000000..7ad92d9
> --- /dev/null
> +++ b/libgcov/include/defaults.h
> @@ -0,0 +1,1478 @@
> +/* Definitions of various defaults for tm.h macros.
> +   Copyright (C) 1992-2017 Free Software Foundation, Inc.
> +   Contributed by Ron Guilmette (rfg@monkeys.com)
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +Under Section 7 of GPL version 3, you are granted additional
> +permissions described in the GCC Runtime Library Exception, version
> +3.1, as published by the Free Software Foundation.
> +
> +You should have received a copy of the GNU General Public License and
> +a copy of the GCC Runtime Library Exception along with this program;
> +see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +<http://www.gnu.org/licenses/>.  */
> +
> +#ifndef GCC_DEFAULTS_H
> +#define GCC_DEFAULTS_H
> +
> +/* How to start an assembler comment.  */
> +#ifndef ASM_COMMENT_START
> +#define ASM_COMMENT_START ";#"
> +#endif
> +
> +/* Store in OUTPUT a string (made with alloca) containing an
> +   assembler-name for a local static variable or function named NAME.
> +   LABELNO is an integer which is different for each call.  */
> +
> +#ifndef ASM_PN_FORMAT
> +# ifndef NO_DOT_IN_LABEL
> +#  define ASM_PN_FORMAT "%s.%lu"
> +# else
> +#  ifndef NO_DOLLAR_IN_LABEL
> +#   define ASM_PN_FORMAT "%s$%lu"
> +#  else
> +#   define ASM_PN_FORMAT "__%s_%lu"
> +#  endif
> +# endif
> +#endif /* ! ASM_PN_FORMAT */
> +
> +#ifndef ASM_FORMAT_PRIVATE_NAME
> +# define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
> +  do { const char *const name_ = (NAME); \
> +       char *const output_ = (OUTPUT) = \
> +	 (char *) alloca (strlen (name_) + 32); \
> +       sprintf (output_, ASM_PN_FORMAT, name_, (unsigned long)(LABELNO)); \
> +  } while (0)
> +#endif
> +
> +/* Choose a reasonable default for ASM_OUTPUT_ASCII.  */
> +
> +#ifndef ASM_OUTPUT_ASCII
> +#define ASM_OUTPUT_ASCII(MYFILE, MYSTRING, MYLENGTH) \
> +  do {									      \
> +    FILE *_hide_asm_out_file = (MYFILE);				      \
> +    const unsigned char *_hide_p = (const unsigned char *) (MYSTRING);	      \
> +    int _hide_thissize = (MYLENGTH);					      \
> +    {									      \
> +      FILE *asm_out_file = _hide_asm_out_file;				      \
> +      const unsigned char *p = _hide_p;					      \
> +      int thissize = _hide_thissize;					      \
> +      int i;								      \
> +      fprintf (asm_out_file, "\t.ascii \"");				      \
> +									      \
> +      for (i = 0; i < thissize; i++)					      \
> +	{								      \
> +	  int c = p[i];			   				      \
> +	  if (c == '\"' || c == '\\')					      \
> +	    putc ('\\', asm_out_file);					      \
> +	  if (ISPRINT (c))						      \
> +	    putc (c, asm_out_file);					      \
> +	  else								      \
> +	    {								      \
> +	      fprintf (asm_out_file, "\\%o", c);			      \
> +	      /* After an octal-escape, if a digit follows,		      \
> +		 terminate one string constant and start another.	      \
> +		 The VAX assembler fails to stop reading the escape	      \
> +		 after three digits, so this is the only way we		      \
> +		 can get it to parse the data properly.  */		      \
> +	      if (i < thissize - 1 && ISDIGIT (p[i + 1]))		      \
> +		fprintf (asm_out_file, "\"\n\t.ascii \"");		      \
> +	  }								      \
> +	}								      \
> +      fprintf (asm_out_file, "\"\n");					      \
> +    }									      \
> +  }									      \
> +  while (0)
> +#endif
> +
> +/* This is how we tell the assembler to equate two values.  */
> +#ifdef SET_ASM_OP
> +#ifndef ASM_OUTPUT_DEF
> +#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)				\
> + do {	fprintf ((FILE), "%s", SET_ASM_OP);				\
> +	assemble_name (FILE, LABEL1);					\
> +	fprintf (FILE, ",");						\
> +	assemble_name (FILE, LABEL2);					\
> +	fprintf (FILE, "\n");						\
> +  } while (0)
> +#endif
> +#endif
> +
> +#ifndef IFUNC_ASM_TYPE
> +#define IFUNC_ASM_TYPE "gnu_indirect_function"
> +#endif
> +
> +#ifndef TLS_COMMON_ASM_OP
> +#define TLS_COMMON_ASM_OP ".tls_common"
> +#endif
> +
> +#if defined (HAVE_AS_TLS) && !defined (ASM_OUTPUT_TLS_COMMON)
> +#define ASM_OUTPUT_TLS_COMMON(FILE, DECL, NAME, SIZE)			\
> +  do									\
> +    {									\
> +      fprintf ((FILE), "\t%s\t", TLS_COMMON_ASM_OP);			\
> +      assemble_name ((FILE), (NAME));					\
> +      fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",		\
> +	       (SIZE), DECL_ALIGN (DECL) / BITS_PER_UNIT);		\
> +    }									\
> +  while (0)
> +#endif
> +
> +/* Decide whether to defer emitting the assembler output for an equate
> +   of two values.  The default is to not defer output.  */
> +#ifndef TARGET_DEFERRED_OUTPUT_DEFS
> +#define TARGET_DEFERRED_OUTPUT_DEFS(DECL,TARGET) false
> +#endif
> +
> +/* This is how to output the definition of a user-level label named
> +   NAME, such as the label on variable NAME.  */
> +
> +#ifndef ASM_OUTPUT_LABEL
> +#define ASM_OUTPUT_LABEL(FILE,NAME) \
> +  do {						\
> +    assemble_name ((FILE), (NAME));		\
> +    fputs (":\n", (FILE));			\
> +  } while (0)
> +#endif
> +
> +/* This is how to output the definition of a user-level label named
> +   NAME, such as the label on a function.  */
> +
> +#ifndef ASM_OUTPUT_FUNCTION_LABEL
> +#define ASM_OUTPUT_FUNCTION_LABEL(FILE, NAME, DECL) \
> +  ASM_OUTPUT_LABEL ((FILE), (NAME))
> +#endif
> +
> +/* Output the definition of a compiler-generated label named NAME.  */
> +#ifndef ASM_OUTPUT_INTERNAL_LABEL
> +#define ASM_OUTPUT_INTERNAL_LABEL(FILE,NAME)	\
> +  do {						\
> +    assemble_name_raw ((FILE), (NAME));		\
> +    fputs (":\n", (FILE));			\
> +  } while (0)
> +#endif
> +
> +/* This is how to output a reference to a user-level label named NAME.  */
> +
> +#ifndef ASM_OUTPUT_LABELREF
> +#define ASM_OUTPUT_LABELREF(FILE,NAME)  \
> +  do {							\
> +    fputs (user_label_prefix, (FILE));			\
> +    fputs ((NAME), (FILE));				\
> +  } while (0);
> +#endif
> +
> +/* Allow target to print debug info labels specially.  This is useful for
> +   VLIW targets, since debug info labels should go into the middle of
> +   instruction bundles instead of breaking them.  */
> +
> +#ifndef ASM_OUTPUT_DEBUG_LABEL
> +#define ASM_OUTPUT_DEBUG_LABEL(FILE, PREFIX, NUM) \
> +  (*targetm.asm_out.internal_label) (FILE, PREFIX, NUM)
> +#endif
> +
> +/* This is how we tell the assembler that a symbol is weak.  */
> +#ifndef ASM_OUTPUT_WEAK_ALIAS
> +#if defined (ASM_WEAKEN_LABEL) && defined (ASM_OUTPUT_DEF)
> +#define ASM_OUTPUT_WEAK_ALIAS(STREAM, NAME, VALUE)	\
> +  do							\
> +    {							\
> +      ASM_WEAKEN_LABEL (STREAM, NAME);			\
> +      if (VALUE)					\
> +        ASM_OUTPUT_DEF (STREAM, NAME, VALUE);		\
> +    }							\
> +  while (0)
> +#endif
> +#endif
> +
> +/* This is how we tell the assembler that a symbol is a weak alias to
> +   another symbol that doesn't require the other symbol to be defined.
> +   Uses of the former will turn into weak uses of the latter, i.e.,
> +   uses that, in case the latter is undefined, will not cause errors,
> +   and will add it to the symbol table as weak undefined.  However, if
> +   the latter is referenced directly, a strong reference prevails.  */
> +#ifndef ASM_OUTPUT_WEAKREF
> +#if defined HAVE_GAS_WEAKREF
> +#define ASM_OUTPUT_WEAKREF(FILE, DECL, NAME, VALUE)			\
> +  do									\
> +    {									\
> +      fprintf ((FILE), "\t.weakref\t");					\
> +      assemble_name ((FILE), (NAME));					\
> +      fprintf ((FILE), ",");						\
> +      assemble_name ((FILE), (VALUE));					\
> +      fprintf ((FILE), "\n");						\
> +    }									\
> +  while (0)
> +#endif
> +#endif
> +
> +/* How to emit a .type directive.  */
> +#ifndef ASM_OUTPUT_TYPE_DIRECTIVE
> +#if defined TYPE_ASM_OP && defined TYPE_OPERAND_FMT
> +#define ASM_OUTPUT_TYPE_DIRECTIVE(STREAM, NAME, TYPE)	\
> +  do							\
> +    {							\
> +      fputs (TYPE_ASM_OP, STREAM);			\
> +      assemble_name (STREAM, NAME);			\
> +      fputs (", ", STREAM);				\
> +      fprintf (STREAM, TYPE_OPERAND_FMT, TYPE);		\
> +      putc ('\n', STREAM);				\
> +    }							\
> +  while (0)
> +#endif
> +#endif
> +
> +/* How to emit a .size directive.  */
> +#ifndef ASM_OUTPUT_SIZE_DIRECTIVE
> +#ifdef SIZE_ASM_OP
> +#define ASM_OUTPUT_SIZE_DIRECTIVE(STREAM, NAME, SIZE)	\
> +  do							\
> +    {							\
> +      HOST_WIDE_INT size_ = (SIZE);			\
> +      fputs (SIZE_ASM_OP, STREAM);			\
> +      assemble_name (STREAM, NAME);			\
> +      fprintf (STREAM, ", " HOST_WIDE_INT_PRINT_DEC "\n", size_); \
> +    }							\
> +  while (0)
> +
> +#define ASM_OUTPUT_MEASURED_SIZE(STREAM, NAME)		\
> +  do							\
> +    {							\
> +      fputs (SIZE_ASM_OP, STREAM);			\
> +      assemble_name (STREAM, NAME);			\
> +      fputs (", .-", STREAM);				\
> +      assemble_name (STREAM, NAME);			\
> +      putc ('\n', STREAM);				\
> +    }							\
> +  while (0)
> +
> +#endif
> +#endif
> +
> +/* This determines whether or not we support weak symbols.  SUPPORTS_WEAK
> +   must be a preprocessor constant.  */
> +#ifndef SUPPORTS_WEAK
> +#if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
> +#define SUPPORTS_WEAK 1
> +#else
> +#define SUPPORTS_WEAK 0
> +#endif
> +#endif
> +
> +/* This determines whether or not we support weak symbols during target
> +   code generation.  TARGET_SUPPORTS_WEAK can be any valid C expression.  */
> +#ifndef TARGET_SUPPORTS_WEAK
> +#define TARGET_SUPPORTS_WEAK (SUPPORTS_WEAK)
> +#endif
> +
> +/* This determines whether or not we support the discriminator
> +   attribute in the .loc directive.  */
> +#ifndef SUPPORTS_DISCRIMINATOR
> +#ifdef HAVE_GAS_DISCRIMINATOR
> +#define SUPPORTS_DISCRIMINATOR 1
> +#else
> +#define SUPPORTS_DISCRIMINATOR 0
> +#endif
> +#endif
> +
> +/* This determines whether or not we support link-once semantics.  */
> +#ifndef SUPPORTS_ONE_ONLY
> +#ifdef MAKE_DECL_ONE_ONLY
> +#define SUPPORTS_ONE_ONLY 1
> +#else
> +#define SUPPORTS_ONE_ONLY 0
> +#endif
> +#endif
> +
> +/* This determines whether weak symbols must be left out of a static
> +   archive's table of contents.  Defining this macro to be nonzero has
> +   the consequence that certain symbols will not be made weak that
> +   otherwise would be.  The C++ ABI requires this macro to be zero;
> +   see the documentation.  */
> +#ifndef TARGET_WEAK_NOT_IN_ARCHIVE_TOC
> +#define TARGET_WEAK_NOT_IN_ARCHIVE_TOC 0
> +#endif
> +
> +/* This determines whether or not we need linkonce unwind information.  */
> +#ifndef TARGET_USES_WEAK_UNWIND_INFO
> +#define TARGET_USES_WEAK_UNWIND_INFO 0
> +#endif
> +
> +/* By default, there is no prefix on user-defined symbols.  */
> +#ifndef USER_LABEL_PREFIX
> +#define USER_LABEL_PREFIX ""
> +#endif
> +
> +/* If the target supports weak symbols, define TARGET_ATTRIBUTE_WEAK to
> +   provide a weak attribute.  Else define it to nothing.
> +
> +   This would normally belong in ansidecl.h, but SUPPORTS_WEAK is
> +   not available at that time.
> +
> +   Note, this is only for use by target files which we know are to be
> +   compiled by GCC.  */
> +#ifndef TARGET_ATTRIBUTE_WEAK
> +# if SUPPORTS_WEAK
> +#  define TARGET_ATTRIBUTE_WEAK __attribute__ ((weak))
> +# else
> +#  define TARGET_ATTRIBUTE_WEAK
> +# endif
> +#endif
> +
> +/* By default we can assume that all global symbols are in one namespace,
> +   across all shared libraries.  */
> +#ifndef MULTIPLE_SYMBOL_SPACES
> +# define MULTIPLE_SYMBOL_SPACES 0
> +#endif
> +
> +/* If the target supports init_priority C++ attribute, give
> +   SUPPORTS_INIT_PRIORITY a nonzero value.  */
> +#ifndef SUPPORTS_INIT_PRIORITY
> +#define SUPPORTS_INIT_PRIORITY 1
> +#endif /* SUPPORTS_INIT_PRIORITY */
> +
> +/* If we have a definition of INCOMING_RETURN_ADDR_RTX, assume that
> +   the rest of the DWARF 2 frame unwind support is also provided.  */
> +#if !defined (DWARF2_UNWIND_INFO) && defined (INCOMING_RETURN_ADDR_RTX)
> +#define DWARF2_UNWIND_INFO 1
> +#endif
> +
> +/* If we have named sections, and we're using crtstuff to run ctors,
> +   use them for registering eh frame information.  */
> +#if defined (TARGET_ASM_NAMED_SECTION) && DWARF2_UNWIND_INFO \
> +    && !defined (EH_FRAME_THROUGH_COLLECT2)
> +#ifndef EH_FRAME_SECTION_NAME
> +#define EH_FRAME_SECTION_NAME ".eh_frame"
> +#endif
> +#endif
> +
> +/* On many systems, different EH table encodings are used under
> +   difference circumstances.  Some will require runtime relocations;
> +   some will not.  For those that do not require runtime relocations,
> +   we would like to make the table read-only.  However, since the
> +   read-only tables may need to be combined with read-write tables
> +   that do require runtime relocation, it is not safe to make the
> +   tables read-only unless the linker will merge read-only and
> +   read-write sections into a single read-write section.  If your
> +   linker does not have this ability, but your system is such that no
> +   encoding used with non-PIC code will ever require a runtime
> +   relocation, then you can define EH_TABLES_CAN_BE_READ_ONLY to 1 in
> +   your target configuration file.  */
> +#ifndef EH_TABLES_CAN_BE_READ_ONLY
> +#ifdef HAVE_LD_RO_RW_SECTION_MIXING
> +#define EH_TABLES_CAN_BE_READ_ONLY 1
> +#else
> +#define EH_TABLES_CAN_BE_READ_ONLY 0
> +#endif
> +#endif
> +
> +/* Provide defaults for stuff that may not be defined when using
> +   sjlj exceptions.  */
> +#ifndef EH_RETURN_DATA_REGNO
> +#define EH_RETURN_DATA_REGNO(N) INVALID_REGNUM
> +#endif
> +
> +/* Offset between the eh handler address and entry in eh tables.  */
> +#ifndef RETURN_ADDR_OFFSET
> +#define RETURN_ADDR_OFFSET 0
> +#endif
> +
> +#ifndef MASK_RETURN_ADDR
> +#define MASK_RETURN_ADDR NULL_RTX
> +#endif
> +
> +/* Number of hardware registers that go into the DWARF-2 unwind info.
> +   If not defined, equals FIRST_PSEUDO_REGISTER  */
> +
> +#ifndef DWARF_FRAME_REGISTERS
> +#define DWARF_FRAME_REGISTERS FIRST_PSEUDO_REGISTER
> +#endif
> +
> +/* Offsets recorded in opcodes are a multiple of this alignment factor.  */
> +#ifndef DWARF_CIE_DATA_ALIGNMENT
> +#ifdef STACK_GROWS_DOWNWARD
> +#define DWARF_CIE_DATA_ALIGNMENT (-((int) UNITS_PER_WORD))
> +#else
> +#define DWARF_CIE_DATA_ALIGNMENT ((int) UNITS_PER_WORD)
> +#endif
> +#endif
> +
> +/* The DWARF 2 CFA column which tracks the return address.  Normally this
> +   is the column for PC, or the first column after all of the hard
> +   registers.  */
> +#ifndef DWARF_FRAME_RETURN_COLUMN
> +#ifdef PC_REGNUM
> +#define DWARF_FRAME_RETURN_COLUMN	DWARF_FRAME_REGNUM (PC_REGNUM)
> +#else
> +#define DWARF_FRAME_RETURN_COLUMN	DWARF_FRAME_REGISTERS
> +#endif
> +#endif
> +
> +/* How to renumber registers for dbx and gdb.  If not defined, assume
> +   no renumbering is necessary.  */
> +
> +#ifndef DBX_REGISTER_NUMBER
> +#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
> +#endif
> +
> +/* The mapping from gcc register number to DWARF 2 CFA column number.
> +   By default, we just provide columns for all registers.  */
> +#ifndef DWARF_FRAME_REGNUM
> +#define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
> +#endif
> +
> +/* The mapping from dwarf CFA reg number to internal dwarf reg numbers.  */
> +#ifndef DWARF_REG_TO_UNWIND_COLUMN
> +#define DWARF_REG_TO_UNWIND_COLUMN(REGNO) (REGNO)
> +#endif
> +
> +/* Map register numbers held in the call frame info that gcc has
> +   collected using DWARF_FRAME_REGNUM to those that should be output in
> +   .debug_frame and .eh_frame.  */
> +#ifndef DWARF2_FRAME_REG_OUT
> +#define DWARF2_FRAME_REG_OUT(REGNO, FOR_EH) (REGNO)
> +#endif
> +
> +/* The size of addresses as they appear in the Dwarf 2 data.
> +   Some architectures use word addresses to refer to code locations,
> +   but Dwarf 2 info always uses byte addresses.  On such machines,
> +   Dwarf 2 addresses need to be larger than the architecture's
> +   pointers.  */
> +#ifndef DWARF2_ADDR_SIZE
> +#define DWARF2_ADDR_SIZE ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT)
> +#endif
> +
> +/* The size in bytes of a DWARF field indicating an offset or length
> +   relative to a debug info section, specified to be 4 bytes in the
> +   DWARF-2 specification.  The SGI/MIPS ABI defines it to be the same
> +   as PTR_SIZE.  */
> +#ifndef DWARF_OFFSET_SIZE
> +#define DWARF_OFFSET_SIZE 4
> +#endif
> +
> +/* The size in bytes of a DWARF 4 type signature.  */
> +#ifndef DWARF_TYPE_SIGNATURE_SIZE
> +#define DWARF_TYPE_SIGNATURE_SIZE 8
> +#endif
> +
> +/* Default sizes for base C types.  If the sizes are different for
> +   your target, you should override these values by defining the
> +   appropriate symbols in your tm.h file.  */
> +
> +#ifndef BITS_PER_WORD
> +#define BITS_PER_WORD (BITS_PER_UNIT * UNITS_PER_WORD)
> +#endif
> +
> +#ifndef CHAR_TYPE_SIZE
> +#define CHAR_TYPE_SIZE BITS_PER_UNIT
> +#endif
> +
> +#ifndef BOOL_TYPE_SIZE
> +/* `bool' has size and alignment `1', on almost all platforms.  */
> +#define BOOL_TYPE_SIZE CHAR_TYPE_SIZE
> +#endif
> +
> +#ifndef SHORT_TYPE_SIZE
> +#define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
> +#endif
> +
> +#ifndef INT_TYPE_SIZE
> +#define INT_TYPE_SIZE BITS_PER_WORD
> +#endif
> +
> +#ifndef LONG_TYPE_SIZE
> +#define LONG_TYPE_SIZE BITS_PER_WORD
> +#endif
> +
> +#ifndef LONG_LONG_TYPE_SIZE
> +#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
> +#endif
> +
> +#ifndef WCHAR_TYPE_SIZE
> +#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
> +#endif
> +
> +#ifndef FLOAT_TYPE_SIZE
> +#define FLOAT_TYPE_SIZE BITS_PER_WORD
> +#endif
> +
> +#ifndef DOUBLE_TYPE_SIZE
> +#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> +#endif
> +
> +#ifndef LONG_DOUBLE_TYPE_SIZE
> +#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> +#endif
> +
> +#ifndef DECIMAL32_TYPE_SIZE
> +#define DECIMAL32_TYPE_SIZE 32
> +#endif
> +
> +#ifndef DECIMAL64_TYPE_SIZE
> +#define DECIMAL64_TYPE_SIZE 64
> +#endif
> +
> +#ifndef DECIMAL128_TYPE_SIZE
> +#define DECIMAL128_TYPE_SIZE 128
> +#endif
> +
> +#ifndef SHORT_FRACT_TYPE_SIZE
> +#define SHORT_FRACT_TYPE_SIZE BITS_PER_UNIT
> +#endif
> +
> +#ifndef FRACT_TYPE_SIZE
> +#define FRACT_TYPE_SIZE (BITS_PER_UNIT * 2)
> +#endif
> +
> +#ifndef LONG_FRACT_TYPE_SIZE
> +#define LONG_FRACT_TYPE_SIZE (BITS_PER_UNIT * 4)
> +#endif
> +
> +#ifndef LONG_LONG_FRACT_TYPE_SIZE
> +#define LONG_LONG_FRACT_TYPE_SIZE (BITS_PER_UNIT * 8)
> +#endif
> +
> +#ifndef SHORT_ACCUM_TYPE_SIZE
> +#define SHORT_ACCUM_TYPE_SIZE (SHORT_FRACT_TYPE_SIZE * 2)
> +#endif
> +
> +#ifndef ACCUM_TYPE_SIZE
> +#define ACCUM_TYPE_SIZE (FRACT_TYPE_SIZE * 2)
> +#endif
> +
> +#ifndef LONG_ACCUM_TYPE_SIZE
> +#define LONG_ACCUM_TYPE_SIZE (LONG_FRACT_TYPE_SIZE * 2)
> +#endif
> +
> +#ifndef LONG_LONG_ACCUM_TYPE_SIZE
> +#define LONG_LONG_ACCUM_TYPE_SIZE (LONG_LONG_FRACT_TYPE_SIZE * 2)
> +#endif
> +
> +/* We let tm.h override the types used here, to handle trivial differences
> +   such as the choice of unsigned int or long unsigned int for size_t.
> +   When machines start needing nontrivial differences in the size type,
> +   it would be best to do something here to figure out automatically
> +   from other information what type to use.  */
> +
> +#ifndef SIZE_TYPE
> +#define SIZE_TYPE "long unsigned int"
> +#endif
> +
> +#ifndef SIZETYPE
> +#define SIZETYPE SIZE_TYPE
> +#endif
> +
> +#ifndef PID_TYPE
> +#define PID_TYPE "int"
> +#endif
> +
> +/* If GCC knows the exact uint_least16_t and uint_least32_t types from
> +   <stdint.h>, use them for char16_t and char32_t.  Otherwise, use
> +   these guesses; getting the wrong type of a given width will not
> +   affect C++ name mangling because in C++ these are distinct types
> +   not typedefs.  */
> +
> +#ifdef UINT_LEAST16_TYPE
> +#define CHAR16_TYPE UINT_LEAST16_TYPE
> +#else
> +#define CHAR16_TYPE "short unsigned int"
> +#endif
> +
> +#ifdef UINT_LEAST32_TYPE
> +#define CHAR32_TYPE UINT_LEAST32_TYPE
> +#else
> +#define CHAR32_TYPE "unsigned int"
> +#endif
> +
> +#ifndef WCHAR_TYPE
> +#define WCHAR_TYPE "int"
> +#endif
> +
> +/* WCHAR_TYPE gets overridden by -fshort-wchar.  */
> +#define MODIFIED_WCHAR_TYPE \
> +	(flag_short_wchar ? "short unsigned int" : WCHAR_TYPE)
> +
> +#ifndef PTRDIFF_TYPE
> +#define PTRDIFF_TYPE "long int"
> +#endif
> +
> +#ifndef WINT_TYPE
> +#define WINT_TYPE "unsigned int"
> +#endif
> +
> +#ifndef INTMAX_TYPE
> +#define INTMAX_TYPE ((INT_TYPE_SIZE == LONG_LONG_TYPE_SIZE)	\
> +		     ? "int"					\
> +		     : ((LONG_TYPE_SIZE == LONG_LONG_TYPE_SIZE)	\
> +			? "long int"				\
> +			: "long long int"))
> +#endif
> +
> +#ifndef UINTMAX_TYPE
> +#define UINTMAX_TYPE ((INT_TYPE_SIZE == LONG_LONG_TYPE_SIZE)	\
> +		     ? "unsigned int"				\
> +		     : ((LONG_TYPE_SIZE == LONG_LONG_TYPE_SIZE)	\
> +			? "long unsigned int"			\
> +			: "long long unsigned int"))
> +#endif
> +
> +
> +/* There are no default definitions of these <stdint.h> types.  */
> +
> +#ifndef SIG_ATOMIC_TYPE
> +#define SIG_ATOMIC_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT8_TYPE
> +#define INT8_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT16_TYPE
> +#define INT16_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT32_TYPE
> +#define INT32_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT64_TYPE
> +#define INT64_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT8_TYPE
> +#define UINT8_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT16_TYPE
> +#define UINT16_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT32_TYPE
> +#define UINT32_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT64_TYPE
> +#define UINT64_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT_LEAST8_TYPE
> +#define INT_LEAST8_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT_LEAST16_TYPE
> +#define INT_LEAST16_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT_LEAST32_TYPE
> +#define INT_LEAST32_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT_LEAST64_TYPE
> +#define INT_LEAST64_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT_LEAST8_TYPE
> +#define UINT_LEAST8_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT_LEAST16_TYPE
> +#define UINT_LEAST16_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT_LEAST32_TYPE
> +#define UINT_LEAST32_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT_LEAST64_TYPE
> +#define UINT_LEAST64_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT_FAST8_TYPE
> +#define INT_FAST8_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT_FAST16_TYPE
> +#define INT_FAST16_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT_FAST32_TYPE
> +#define INT_FAST32_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INT_FAST64_TYPE
> +#define INT_FAST64_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT_FAST8_TYPE
> +#define UINT_FAST8_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT_FAST16_TYPE
> +#define UINT_FAST16_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT_FAST32_TYPE
> +#define UINT_FAST32_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINT_FAST64_TYPE
> +#define UINT_FAST64_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef INTPTR_TYPE
> +#define INTPTR_TYPE ((const char *) NULL)
> +#endif
> +
> +#ifndef UINTPTR_TYPE
> +#define UINTPTR_TYPE ((const char *) NULL)
> +#endif
> +
> +/* Width in bits of a pointer.  Mind the value of the macro `Pmode'.  */
> +#ifndef POINTER_SIZE
> +#define POINTER_SIZE BITS_PER_WORD
> +#endif
> +#ifndef POINTER_SIZE_UNITS
> +#define POINTER_SIZE_UNITS ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT)
> +#endif
> +
> +
> +#ifndef PIC_OFFSET_TABLE_REGNUM
> +#define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM
> +#endif
> +
> +#ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
> +#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED 0
> +#endif
> +
> +#ifndef TARGET_DLLIMPORT_DECL_ATTRIBUTES
> +#define TARGET_DLLIMPORT_DECL_ATTRIBUTES 0
> +#endif
> +
> +#ifndef TARGET_DECLSPEC
> +#if TARGET_DLLIMPORT_DECL_ATTRIBUTES
> +/* If the target supports the "dllimport" attribute, users are
> +   probably used to the "__declspec" syntax.  */
> +#define TARGET_DECLSPEC 1
> +#else
> +#define TARGET_DECLSPEC 0
> +#endif
> +#endif
> +
> +/* By default, the preprocessor should be invoked the same way in C++
> +   as in C.  */
> +#ifndef CPLUSPLUS_CPP_SPEC
> +#ifdef CPP_SPEC
> +#define CPLUSPLUS_CPP_SPEC CPP_SPEC
> +#endif
> +#endif
> +
> +#ifndef ACCUMULATE_OUTGOING_ARGS
> +#define ACCUMULATE_OUTGOING_ARGS 0
> +#endif
> +
> +/* By default, use the GNU runtime for Objective C.  */
> +#ifndef NEXT_OBJC_RUNTIME
> +#define NEXT_OBJC_RUNTIME 0
> +#endif
> +
> +/* Supply a default definition for PUSH_ARGS.  */
> +#ifndef PUSH_ARGS
> +#ifdef PUSH_ROUNDING
> +#define PUSH_ARGS	!ACCUMULATE_OUTGOING_ARGS
> +#else
> +#define PUSH_ARGS	0
> +#endif
> +#endif
> +
> +/* Decide whether a function's arguments should be processed
> +   from first to last or from last to first.
> +
> +   They should if the stack and args grow in opposite directions, but
> +   only if we have push insns.  */
> +
> +#ifdef PUSH_ROUNDING
> +
> +#ifndef PUSH_ARGS_REVERSED
> +#if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
> +#define PUSH_ARGS_REVERSED  PUSH_ARGS
> +#endif
> +#endif
> +
> +#endif
> +
> +#ifndef PUSH_ARGS_REVERSED
> +#define PUSH_ARGS_REVERSED 0
> +#endif
> +
> +/* Default value for the alignment (in bits) a C conformant malloc has to
> +   provide. This default is intended to be safe and always correct.  */
> +#ifndef MALLOC_ABI_ALIGNMENT
> +#define MALLOC_ABI_ALIGNMENT BITS_PER_WORD
> +#endif
> +
> +/* If PREFERRED_STACK_BOUNDARY is not defined, set it to STACK_BOUNDARY.
> +   STACK_BOUNDARY is required.  */
> +#ifndef PREFERRED_STACK_BOUNDARY
> +#define PREFERRED_STACK_BOUNDARY STACK_BOUNDARY
> +#endif
> +
> +/* Set INCOMING_STACK_BOUNDARY to PREFERRED_STACK_BOUNDARY if it is not
> +   defined.  */
> +#ifndef INCOMING_STACK_BOUNDARY
> +#define INCOMING_STACK_BOUNDARY PREFERRED_STACK_BOUNDARY
> +#endif
> +
> +#ifndef TARGET_DEFAULT_PACK_STRUCT
> +#define TARGET_DEFAULT_PACK_STRUCT 0
> +#endif
> +
> +/* By default, the vtable entries are void pointers, the so the alignment
> +   is the same as pointer alignment.  The value of this macro specifies
> +   the alignment of the vtable entry in bits.  It should be defined only
> +   when special alignment is necessary.  */
> +#ifndef TARGET_VTABLE_ENTRY_ALIGN
> +#define TARGET_VTABLE_ENTRY_ALIGN POINTER_SIZE
> +#endif
> +
> +/* There are a few non-descriptor entries in the vtable at offsets below
> +   zero.  If these entries must be padded (say, to preserve the alignment
> +   specified by TARGET_VTABLE_ENTRY_ALIGN), set this to the number of
> +   words in each data entry.  */
> +#ifndef TARGET_VTABLE_DATA_ENTRY_DISTANCE
> +#define TARGET_VTABLE_DATA_ENTRY_DISTANCE 1
> +#endif
> +
> +/* Decide whether it is safe to use a local alias for a virtual function
> +   when constructing thunks.  */
> +#ifndef TARGET_USE_LOCAL_THUNK_ALIAS_P
> +#ifdef ASM_OUTPUT_DEF
> +#define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) 1
> +#else
> +#define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) 0
> +#endif
> +#endif
> +
> +/* Select a format to encode pointers in exception handling data.  We
> +   prefer those that result in fewer dynamic relocations.  Assume no
> +   special support here and encode direct references.  */
> +#ifndef ASM_PREFERRED_EH_DATA_FORMAT
> +#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  DW_EH_PE_absptr
> +#endif
> +
> +/* By default, the C++ compiler will use the lowest bit of the pointer
> +   to function to indicate a pointer-to-member-function points to a
> +   virtual member function.  However, if FUNCTION_BOUNDARY indicates
> +   function addresses aren't always even, the lowest bit of the delta
> +   field will be used.  */
> +#ifndef TARGET_PTRMEMFUNC_VBIT_LOCATION
> +#define TARGET_PTRMEMFUNC_VBIT_LOCATION \
> +  (FUNCTION_BOUNDARY >= 2 * BITS_PER_UNIT \
> +   ? ptrmemfunc_vbit_in_pfn : ptrmemfunc_vbit_in_delta)
> +#endif
> +
> +#ifndef DEFAULT_GDB_EXTENSIONS
> +#define DEFAULT_GDB_EXTENSIONS 1
> +#endif
> +
> +#ifndef SDB_DEBUGGING_INFO
> +#define SDB_DEBUGGING_INFO 0
> +#endif
> +
> +/* If more than one debugging type is supported, you must define
> +   PREFERRED_DEBUGGING_TYPE to choose the default.  */
> +
> +#if 1 < (defined (DBX_DEBUGGING_INFO) + (SDB_DEBUGGING_INFO) \
> +         + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO) \
> +         + defined (VMS_DEBUGGING_INFO))
> +#ifndef PREFERRED_DEBUGGING_TYPE
> +#error You must define PREFERRED_DEBUGGING_TYPE
> +#endif /* no PREFERRED_DEBUGGING_TYPE */
> +
> +/* If only one debugging format is supported, define PREFERRED_DEBUGGING_TYPE
> +   here so other code needn't care.  */
> +#elif defined DBX_DEBUGGING_INFO
> +#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
> +
> +#elif SDB_DEBUGGING_INFO
> +#define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
> +
> +#elif defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO
> +#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
> +
> +#elif defined VMS_DEBUGGING_INFO
> +#define PREFERRED_DEBUGGING_TYPE VMS_AND_DWARF2_DEBUG
> +
> +#elif defined XCOFF_DEBUGGING_INFO
> +#define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
> +
> +#else
> +/* No debugging format is supported by this target.  */
> +#define PREFERRED_DEBUGGING_TYPE NO_DEBUG
> +#endif
> +
> +#ifndef FLOAT_LIB_COMPARE_RETURNS_BOOL
> +#define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) false
> +#endif
> +
> +/* True if the targets integer-comparison functions return { 0, 1, 2
> +   } to indicate { <, ==, > }.  False if { -1, 0, 1 } is used
> +   instead.  The libgcc routines are biased.  */
> +#ifndef TARGET_LIB_INT_CMP_BIASED
> +#define TARGET_LIB_INT_CMP_BIASED (true)
> +#endif
> +
> +/* If FLOAT_WORDS_BIG_ENDIAN is not defined in the header files,
> +   then the word-endianness is the same as for integers.  */
> +#ifndef FLOAT_WORDS_BIG_ENDIAN
> +#define FLOAT_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
> +#endif
> +
> +#ifndef REG_WORDS_BIG_ENDIAN
> +#define REG_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
> +#endif
> +
> +
> +#ifndef TARGET_DEC_EVAL_METHOD
> +#define TARGET_DEC_EVAL_METHOD 2
> +#endif
> +
> +#ifndef HAS_LONG_COND_BRANCH
> +#define HAS_LONG_COND_BRANCH 0
> +#endif
> +
> +#ifndef HAS_LONG_UNCOND_BRANCH
> +#define HAS_LONG_UNCOND_BRANCH 0
> +#endif
> +
> +/* Determine whether __cxa_atexit, rather than atexit, is used to
> +   register C++ destructors for local statics and global objects.  */
> +#ifndef DEFAULT_USE_CXA_ATEXIT
> +#define DEFAULT_USE_CXA_ATEXIT 0
> +#endif
> +
> +#if GCC_VERSION >= 3000 && defined IN_GCC
> +/* These old constraint macros shouldn't appear anywhere in a
> +   configuration using MD constraint definitions.  */
> +#endif
> +
> +/* Determin whether the target runtime library is Bionic */
> +#ifndef TARGET_HAS_BIONIC
> +#define TARGET_HAS_BIONIC 0
> +#endif
> +
> +/* Indicate that CLZ and CTZ are undefined at zero.  */
> +#ifndef CLZ_DEFINED_VALUE_AT_ZERO
> +#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
> +#endif
> +#ifndef CTZ_DEFINED_VALUE_AT_ZERO
> +#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
> +#endif
> +
> +/* Provide a default value for STORE_FLAG_VALUE.  */
> +#ifndef STORE_FLAG_VALUE
> +#define STORE_FLAG_VALUE  1
> +#endif
> +
> +/* This macro is used to determine what the largest unit size that
> +   move_by_pieces can use is.  */
> +
> +/* MOVE_MAX_PIECES is the number of bytes at a time which we can
> +   move efficiently, as opposed to  MOVE_MAX which is the maximum
> +   number of bytes we can move with a single instruction.  */
> +
> +#ifndef MOVE_MAX_PIECES
> +#define MOVE_MAX_PIECES   MOVE_MAX
> +#endif
> +
> +/* STORE_MAX_PIECES is the number of bytes at a time that we can
> +   store efficiently.  Due to internal GCC limitations, this is
> +   MOVE_MAX_PIECES limited by the number of bytes GCC can represent
> +   for an immediate constant.  */
> +
> +#ifndef STORE_MAX_PIECES
> +#define STORE_MAX_PIECES  MIN (MOVE_MAX_PIECES, 2 * sizeof (HOST_WIDE_INT))
> +#endif
> +
> +/* Likewise for block comparisons.  */
> +#ifndef COMPARE_MAX_PIECES
> +#define COMPARE_MAX_PIECES  MOVE_MAX_PIECES
> +#endif
> +
> +#ifndef MAX_MOVE_MAX
> +#define MAX_MOVE_MAX MOVE_MAX
> +#endif
> +
> +#ifndef MIN_UNITS_PER_WORD
> +#define MIN_UNITS_PER_WORD UNITS_PER_WORD
> +#endif
> +
> +#ifndef MAX_BITS_PER_WORD
> +#define MAX_BITS_PER_WORD BITS_PER_WORD
> +#endif
> +
> +#ifndef STACK_POINTER_OFFSET
> +#define STACK_POINTER_OFFSET    0
> +#endif
> +
> +#ifndef LOCAL_REGNO
> +#define LOCAL_REGNO(REGNO)  0
> +#endif
> +
> +#ifndef HONOR_REG_ALLOC_ORDER
> +#define HONOR_REG_ALLOC_ORDER 0
> +#endif
> +
> +/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
> +   the stack pointer does not matter.  The value is tested only in
> +   functions that have frame pointers.  */
> +#ifndef EXIT_IGNORE_STACK
> +#define EXIT_IGNORE_STACK 0
> +#endif
> +
> +/* Assume that case vectors are not pc-relative.  */
> +#ifndef CASE_VECTOR_PC_RELATIVE
> +#define CASE_VECTOR_PC_RELATIVE 0
> +#endif
> +
> +/* Force minimum alignment to be able to use the least significant bits
> +   for distinguishing descriptor addresses from code addresses.  */
> +#define FUNCTION_ALIGNMENT(ALIGN)					\
> +  (lang_hooks.custom_function_descriptors				\
> +   && targetm.calls.custom_function_descriptors > 0			\
> +   ? MAX ((ALIGN),						\
> +	  2 * targetm.calls.custom_function_descriptors * BITS_PER_UNIT)\
> +   : (ALIGN))
> +
> +/* Assume that trampolines need function alignment.  */
> +#ifndef TRAMPOLINE_ALIGNMENT
> +#define TRAMPOLINE_ALIGNMENT FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY)
> +#endif
> +
> +/* Register mappings for target machines without register windows.  */
> +#ifndef INCOMING_REGNO
> +#define INCOMING_REGNO(N) (N)
> +#endif
> +
> +#ifndef OUTGOING_REGNO
> +#define OUTGOING_REGNO(N) (N)
> +#endif
> +
> +#ifndef SHIFT_COUNT_TRUNCATED
> +#define SHIFT_COUNT_TRUNCATED 0
> +#endif
> +
> +#ifndef LEGITIMATE_PIC_OPERAND_P
> +#define LEGITIMATE_PIC_OPERAND_P(X) 1
> +#endif
> +
> +#ifndef TARGET_MEM_CONSTRAINT
> +#define TARGET_MEM_CONSTRAINT 'm'
> +#endif
> +
> +#ifndef REVERSIBLE_CC_MODE
> +#define REVERSIBLE_CC_MODE(MODE) 0
> +#endif
> +
> +/* Biggest alignment supported by the object file format of this machine.  */
> +#ifndef MAX_OFILE_ALIGNMENT
> +#define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
> +#endif
> +
> +#ifndef FRAME_GROWS_DOWNWARD
> +#define FRAME_GROWS_DOWNWARD 0
> +#endif
> +
> +#ifndef RETURN_ADDR_IN_PREVIOUS_FRAME
> +#define RETURN_ADDR_IN_PREVIOUS_FRAME 0
> +#endif
> +
> +/* On most machines, the CFA coincides with the first incoming parm.  */
> +#ifndef ARG_POINTER_CFA_OFFSET
> +#define ARG_POINTER_CFA_OFFSET(FNDECL) \
> +  (FIRST_PARM_OFFSET (FNDECL) + crtl->args.pretend_args_size)
> +#endif
> +
> +/* On most machines, we use the CFA as DW_AT_frame_base.  */
> +#ifndef CFA_FRAME_BASE_OFFSET
> +#define CFA_FRAME_BASE_OFFSET(FNDECL) 0
> +#endif
> +
> +/* The offset from the incoming value of %sp to the top of the stack frame
> +   for the current function.  */
> +#ifndef INCOMING_FRAME_SP_OFFSET
> +#define INCOMING_FRAME_SP_OFFSET 0
> +#endif
> +
> +#ifndef HARD_REGNO_NREGS_HAS_PADDING
> +#define HARD_REGNO_NREGS_HAS_PADDING(REGNO, MODE) 0
> +#define HARD_REGNO_NREGS_WITH_PADDING(REGNO, MODE) -1
> +#endif
> +
> +#ifndef OUTGOING_REG_PARM_STACK_SPACE
> +#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 0
> +#endif
> +
> +/* MAX_STACK_ALIGNMENT is the maximum stack alignment guaranteed by
> +   the backend.  MAX_SUPPORTED_STACK_ALIGNMENT is the maximum best
> +   effort stack alignment supported by the backend.  If the backend
> +   supports stack alignment, MAX_SUPPORTED_STACK_ALIGNMENT and
> +   MAX_STACK_ALIGNMENT are the same.  Otherwise, the incoming stack
> +   boundary will limit the maximum guaranteed stack alignment.  */
> +#ifdef MAX_STACK_ALIGNMENT
> +#define MAX_SUPPORTED_STACK_ALIGNMENT MAX_STACK_ALIGNMENT
> +#else
> +#define MAX_STACK_ALIGNMENT STACK_BOUNDARY
> +#define MAX_SUPPORTED_STACK_ALIGNMENT PREFERRED_STACK_BOUNDARY
> +#endif
> +
> +#define SUPPORTS_STACK_ALIGNMENT (MAX_STACK_ALIGNMENT > STACK_BOUNDARY)
> +
> +#ifndef LOCAL_ALIGNMENT
> +#define LOCAL_ALIGNMENT(TYPE, ALIGNMENT) ALIGNMENT
> +#endif
> +
> +#ifndef STACK_SLOT_ALIGNMENT
> +#define STACK_SLOT_ALIGNMENT(TYPE,MODE,ALIGN) \
> +  ((TYPE) ? LOCAL_ALIGNMENT ((TYPE), (ALIGN)) : (ALIGN))
> +#endif
> +
> +#ifndef LOCAL_DECL_ALIGNMENT
> +#define LOCAL_DECL_ALIGNMENT(DECL) \
> +  LOCAL_ALIGNMENT (TREE_TYPE (DECL), DECL_ALIGN (DECL))
> +#endif
> +
> +#ifndef MINIMUM_ALIGNMENT
> +#define MINIMUM_ALIGNMENT(EXP,MODE,ALIGN) (ALIGN)
> +#endif
> +
> +/* Alignment value for attribute ((aligned)).  */
> +#ifndef ATTRIBUTE_ALIGNED_VALUE
> +#define ATTRIBUTE_ALIGNED_VALUE BIGGEST_ALIGNMENT
> +#endif
> +
> +#ifndef SLOW_UNALIGNED_ACCESS
> +#define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) STRICT_ALIGNMENT
> +#endif
> +
> +/* For most ports anything that evaluates to a constant symbolic
> +   or integer value is acceptable as a constant address.  */
> +#ifndef CONSTANT_ADDRESS_P
> +#define CONSTANT_ADDRESS_P(X)   (CONSTANT_P (X) && GET_CODE (X) != CONST_DOUBLE)
> +#endif
> +
> +#ifndef MAX_FIXED_MODE_SIZE
> +#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (DImode)
> +#endif
> +
> +/* Nonzero if structures and unions should be returned in memory.
> +
> +   This should only be defined if compatibility with another compiler or
> +   with an ABI is needed, because it results in slower code.  */
> +
> +#ifndef DEFAULT_PCC_STRUCT_RETURN
> +#define DEFAULT_PCC_STRUCT_RETURN 1
> +#endif
> +
> +#ifndef PCC_BITFIELD_TYPE_MATTERS
> +#define PCC_BITFIELD_TYPE_MATTERS false
> +#endif
> +
> +#ifndef INSN_SETS_ARE_DELAYED
> +#define INSN_SETS_ARE_DELAYED(INSN) false
> +#endif
> +
> +#ifndef INSN_REFERENCES_ARE_DELAYED
> +#define INSN_REFERENCES_ARE_DELAYED(INSN) false
> +#endif
> +
> +#ifndef NO_FUNCTION_CSE
> +#define NO_FUNCTION_CSE false
> +#endif
> +
> +#ifndef HARD_REGNO_RENAME_OK
> +#define HARD_REGNO_RENAME_OK(FROM, TO) true
> +#endif
> +
> +#ifndef EPILOGUE_USES
> +#define EPILOGUE_USES(REG) false
> +#endif
> +
> +#ifndef ARGS_GROW_DOWNWARD
> +#define ARGS_GROW_DOWNWARD 0
> +#endif
> +
> +#ifndef STACK_GROWS_DOWNWARD
> +#define STACK_GROWS_DOWNWARD 0
> +#endif
> +
> +#ifndef STACK_PUSH_CODE
> +#if STACK_GROWS_DOWNWARD
> +#define STACK_PUSH_CODE PRE_DEC
> +#else
> +#define STACK_PUSH_CODE PRE_INC
> +#endif
> +#endif
> +
> +/* Default value for flag_pie when flag_pie is initialized to -1:
> +   --enable-default-pie: Default flag_pie to -fPIE.
> +   --disable-default-pie: Default flag_pie to 0.
> + */
> +#ifdef ENABLE_DEFAULT_PIE
> +# ifndef DEFAULT_FLAG_PIE
> +#  define DEFAULT_FLAG_PIE 2
> +# endif
> +#else
> +# define DEFAULT_FLAG_PIE 0
> +#endif
> +
> +#ifndef SWITCHABLE_TARGET
> +#define SWITCHABLE_TARGET 0
> +#endif
> +
> +/* If the target supports integers that are wider than two
> +   HOST_WIDE_INTs on the host compiler, then the target should define
> +   TARGET_SUPPORTS_WIDE_INT and make the appropriate fixups.
> +   Otherwise the compiler really is not robust.  */
> +#ifndef TARGET_SUPPORTS_WIDE_INT
> +#define TARGET_SUPPORTS_WIDE_INT 0
> +#endif
> +
> +#ifndef SHORT_IMMEDIATES_SIGN_EXTEND
> +#define SHORT_IMMEDIATES_SIGN_EXTEND 0
> +#endif
> +
> +#ifndef WORD_REGISTER_OPERATIONS
> +#define WORD_REGISTER_OPERATIONS 0
> +#endif
> +
> +#ifndef LOAD_EXTEND_OP
> +#define LOAD_EXTEND_OP(M) UNKNOWN
> +#endif
> +
> +#ifndef CONSTANT_ALIGNMENT
> +#define CONSTANT_ALIGNMENT(EXP, ALIGN) ALIGN
> +#endif
> +
> +#ifndef INITIAL_FRAME_ADDRESS_RTX
> +#define INITIAL_FRAME_ADDRESS_RTX NULL
> +#endif
> +
> +#ifndef SETUP_FRAME_ADDRESSES
> +#define SETUP_FRAME_ADDRESSES() do { } while (0)
> +#endif
> +
> +#ifndef DYNAMIC_CHAIN_ADDRESS
> +#define DYNAMIC_CHAIN_ADDRESS(x) (x)
> +#endif
> +
> +#ifndef FRAME_ADDR_RTX
> +#define FRAME_ADDR_RTX(x) (x)
> +#endif
> +
> +#ifndef REVERSE_CONDITION
> +#define REVERSE_CONDITION(code, mode) reverse_condition (code)
> +#endif
> +
> +#ifndef TARGET_PECOFF
> +#define TARGET_PECOFF 0
> +#endif
> +
> +#ifndef EH_RETURN_HANDLER_RTX
> +#define EH_RETURN_HANDLER_RTX NULL
> +#endif
> +
> +#ifdef GCC_INSN_FLAGS_H
> +/* Dependent default target macro definitions
> +
> +   This section of defaults.h defines target macros that depend on generated
> +   headers.  This is a bit awkward:  We want to put all default definitions
> +   for target macros in defaults.h, but some of the defaults depend on the
> +   HAVE_* flags defines of insn-flags.h.  But insn-flags.h is not always
> +   included by files that do include defaults.h.
> +
> +   Fortunately, the default macro definitions that depend on the HAVE_*
> +   macros are also the ones that will only be used inside GCC itself, i.e.
> +   not in the gen* programs or in target objects like libgcc.
> +
> +   Obviously, it would be best to keep this section of defaults.h as small
> +   as possible, by converting the macros defined below to target hooks or
> +   functions.
> +*/
> +
> +/* The default branch cost is 1.  */
> +#ifndef BRANCH_COST
> +#define BRANCH_COST(speed_p, predictable_p) 1
> +#endif
> +
> +/* If a memory-to-memory move would take MOVE_RATIO or more simple
> +   move-instruction sequences, we will do a movmem or libcall instead.  */
> +
> +#ifndef MOVE_RATIO
> +#if defined (HAVE_movmemqi) || defined (HAVE_movmemhi) || defined (HAVE_movmemsi) || defined (HAVE_movmemdi) || defined (HAVE_movmemti)
> +#define MOVE_RATIO(speed) 2
> +#else
> +/* If we are optimizing for space (-Os), cut down the default move ratio.  */
> +#define MOVE_RATIO(speed) ((speed) ? 15 : 3)
> +#endif
> +#endif
> +
> +/* If a clear memory operation would take CLEAR_RATIO or more simple
> +   move-instruction sequences, we will do a setmem or libcall instead.  */
> +
> +#ifndef CLEAR_RATIO
> +#if defined (HAVE_setmemqi) || defined (HAVE_setmemhi) || defined (HAVE_setmemsi) || defined (HAVE_setmemdi) || defined (HAVE_setmemti)
> +#define CLEAR_RATIO(speed) 2
> +#else
> +/* If we are optimizing for space, cut down the default clear ratio.  */
> +#define CLEAR_RATIO(speed) ((speed) ? 15 :3)
> +#endif
> +#endif
> +
> +/* If a memory set (to value other than zero) operation would take
> +   SET_RATIO or more simple move-instruction sequences, we will do a movmem
> +   or libcall instead.  */
> +#ifndef SET_RATIO
> +#define SET_RATIO(speed) MOVE_RATIO (speed)
> +#endif
> +
> +/* Supply a default definition for FUNCTION_ARG_PADDING:
> +   usually pad upward, but pad short args downward on
> +   big-endian machines.  */
> +
> +#define DEFAULT_FUNCTION_ARG_PADDING(MODE, TYPE)			\
> +  (! BYTES_BIG_ENDIAN							\
> +   ? upward								\
> +   : (((MODE) == BLKmode						\
> +       ? ((TYPE) && TREE_CODE (TYPE_SIZE (TYPE)) == INTEGER_CST		\
> +	  && int_size_in_bytes (TYPE) < (PARM_BOUNDARY / BITS_PER_UNIT)) \
> +       : GET_MODE_BITSIZE (MODE) < PARM_BOUNDARY)			\
> +      ? downward : upward))
> +
> +#ifndef FUNCTION_ARG_PADDING
> +#define FUNCTION_ARG_PADDING(MODE, TYPE)	\
> +  DEFAULT_FUNCTION_ARG_PADDING ((MODE), (TYPE))
> +#endif
> +
> +/* Supply a default definition of STACK_SAVEAREA_MODE for emit_stack_save.
> +   Normally move_insn, so Pmode stack pointer.  */
> +
> +#ifndef STACK_SAVEAREA_MODE
> +#define STACK_SAVEAREA_MODE(LEVEL) Pmode
> +#endif
> +
> +/* Supply a default definition of STACK_SIZE_MODE for
> +   allocate_dynamic_stack_space.  Normally PLUS/MINUS, so word_mode.  */
> +
> +#ifndef STACK_SIZE_MODE
> +#define STACK_SIZE_MODE word_mode
> +#endif
> +
> +/* Default value for flag_stack_protect when flag_stack_protect is initialized to -1:
> +   --enable-default-ssp: Default flag_stack_protect to -fstack-protector-strong.
> +   --disable-default-ssp: Default flag_stack_protect to 0.
> + */
> +#ifdef ENABLE_DEFAULT_SSP
> +# ifndef DEFAULT_FLAG_SSP
> +#  define DEFAULT_FLAG_SSP 3
> +# endif
> +#else
> +# define DEFAULT_FLAG_SSP 0
> +#endif
> +
> +/* Provide default values for the macros controlling stack checking.  */
> +
> +/* The default is neither full builtin stack checking...  */
> +#ifndef STACK_CHECK_BUILTIN
> +#define STACK_CHECK_BUILTIN 0
> +#endif
> +
> +/* ...nor static builtin stack checking.  */
> +#ifndef STACK_CHECK_STATIC_BUILTIN
> +#define STACK_CHECK_STATIC_BUILTIN 0
> +#endif
> +
> +/* The default interval is one page (4096 bytes).  */
> +#ifndef STACK_CHECK_PROBE_INTERVAL_EXP
> +#define STACK_CHECK_PROBE_INTERVAL_EXP 12
> +#endif
> +
> +/* The default is not to move the stack pointer.  */
> +#ifndef STACK_CHECK_MOVING_SP
> +#define STACK_CHECK_MOVING_SP 0
> +#endif
> +
> +/* This is a kludge to try to capture the discrepancy between the old
> +   mechanism (generic stack checking) and the new mechanism (static
> +   builtin stack checking).  STACK_CHECK_PROTECT needs to be bumped
> +   for the latter because part of the protection area is effectively
> +   included in STACK_CHECK_MAX_FRAME_SIZE for the former.  */
> +#ifdef STACK_CHECK_PROTECT
> +#define STACK_OLD_CHECK_PROTECT STACK_CHECK_PROTECT
> +#else
> +#define STACK_OLD_CHECK_PROTECT						\
> + (!global_options.x_flag_exceptions					\
> +  ? 75 * UNITS_PER_WORD							\
> +  : targetm_common.except_unwind_info (&global_options) == UI_SJLJ	\
> +    ? 4 * 1024								\
> +    : 8 * 1024)
> +#endif
> +
> +/* Minimum amount of stack required to recover from an anticipated stack
> +   overflow detection.  The default value conveys an estimate of the amount
> +   of stack required to propagate an exception.  */
> +#ifndef STACK_CHECK_PROTECT
> +#define STACK_CHECK_PROTECT						\
> + (!global_options.x_flag_exceptions					\
> +  ? 4 * 1024								\
> +  : targetm_common.except_unwind_info (&global_options) == UI_SJLJ	\
> +    ? 8 * 1024								\
> +    : 12 * 1024)
> +#endif
> +
> +/* Make the maximum frame size be the largest we can and still only need
> +   one probe per function.  */
> +#ifndef STACK_CHECK_MAX_FRAME_SIZE
> +#define STACK_CHECK_MAX_FRAME_SIZE \
> +  ((1 << STACK_CHECK_PROBE_INTERVAL_EXP) - UNITS_PER_WORD)
> +#endif
> +
> +/* This is arbitrary, but should be large enough everywhere.  */
> +#ifndef STACK_CHECK_FIXED_FRAME_SIZE
> +#define STACK_CHECK_FIXED_FRAME_SIZE (4 * UNITS_PER_WORD)
> +#endif
> +
> +/* Provide a reasonable default for the maximum size of an object to
> +   allocate in the fixed frame.  We may need to be able to make this
> +   controllable by the user at some point.  */
> +#ifndef STACK_CHECK_MAX_VAR_SIZE
> +#define STACK_CHECK_MAX_VAR_SIZE (STACK_CHECK_MAX_FRAME_SIZE / 100)
> +#endif
> +
> +/* By default, the C++ compiler will use function addresses in the
> +   vtable entries.  Setting this nonzero tells the compiler to use
> +   function descriptors instead.  The value of this macro says how
> +   many words wide the descriptor is (normally 2).  It is assumed
> +   that the address of a function descriptor may be treated as a
> +   pointer to a function.  */
> +#ifndef TARGET_VTABLE_USES_DESCRIPTORS
> +#define TARGET_VTABLE_USES_DESCRIPTORS 0
> +#endif
> +
> +#endif /* GCC_INSN_FLAGS_H  */
> +
> +#ifndef DWARF_GNAT_ENCODINGS_DEFAULT
> +#define DWARF_GNAT_ENCODINGS_DEFAULT DWARF_GNAT_ENCODINGS_GDB
> +#endif
> +
> +#endif  /* ! GCC_DEFAULTS_H */
> diff --git a/libgcov/include/elf-lib.h b/libgcov/include/elf-lib.h
> new file mode 100644
> index 0000000..f50798c
> --- /dev/null
> +++ b/libgcov/include/elf-lib.h
> @@ -0,0 +1,36 @@
> +/* Definitions for Intel 386 ELF systems.
> +   Copyright (C) 2015-2017 Free Software Foundation, Inc.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +Under Section 7 of GPL version 3, you are granted additional
> +permissions described in the GCC Runtime Library Exception, version
> +3.1, as published by the Free Software Foundation.
> +
> +You should have received a copy of the GNU General Public License and
> +a copy of the GCC Runtime Library Exception along with this program;
> +see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +<http://www.gnu.org/licenses/>.  */
> +
> +#ifdef __i386__
> +/* Used by crtstuff.c to initialize the base of data-relative relocations.
> +   These are GOT relative on x86, so return the pic register.  */
> +#define CRT_GET_RFIB_DATA(BASE)						\
> +  __asm__ ("call\t.LPR%=\n"						\
> +	   ".LPR%=:\n\t"						\
> +	   "pop{l}\t%0\n\t"						\
> +	   /* Due to a GAS bug, this cannot use EAX.  That encodes	\
> +	      smaller than the traditional EBX, which results in the	\
> +	      offset being off by one.  */				\
> +	   "add{l}\t{$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"		\
> +		   "|%0,_GLOBAL_OFFSET_TABLE_+(.-.LPR%=)}"		\
> +	   : "=d"(BASE))
> +#endif
> diff --git a/libgcov/include/filenames.h b/libgcov/include/filenames.h
> new file mode 100644
> index 0000000..5a2a055
> --- /dev/null
> +++ b/libgcov/include/filenames.h
> @@ -0,0 +1,99 @@
> +/* Macros for taking apart, interpreting and processing file names.
> +
> +   These are here because some non-Posix (a.k.a. DOSish) systems have
> +   drive letter brain-damage at the beginning of an absolute file name,
> +   use forward- and back-slash in path names interchangeably, and
> +   some of them have case-insensitive file names.
> +
> +   Copyright (C) 2000-2017 Free Software Foundation, Inc.
> +
> +This file is part of BFD, the Binary File Descriptor library.
> +
> +This program is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 2 of the License, or
> +(at your option) any later version.
> +
> +This program is distributed in the hope that it will be useful,
> +but WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +GNU General Public License for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with this program; if not, write to the Free Software
> +Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
> +
> +#ifndef FILENAMES_H
> +#define FILENAMES_H
> +
> +#include "hashtab.h" /* for hashval_t */
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
> +#  ifndef HAVE_DOS_BASED_FILE_SYSTEM
> +#    define HAVE_DOS_BASED_FILE_SYSTEM 1
> +#  endif
> +#  ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
> +#    define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
> +#  endif
> +#  define HAS_DRIVE_SPEC(f) HAS_DOS_DRIVE_SPEC (f)
> +#  define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
> +#  define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
> +#else /* not DOSish */
> +#  if defined(__APPLE__)
> +#    ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
> +#      define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
> +#    endif
> +#  endif /* __APPLE__ */
> +#  define HAS_DRIVE_SPEC(f) (0)
> +#  define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
> +#  define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
> +#endif
> +
> +#define IS_DIR_SEPARATOR_1(dos_based, c)				\
> +  (((c) == '/')								\
> +   || (((c) == '\\') && (dos_based)))
> +
> +#define HAS_DRIVE_SPEC_1(dos_based, f)			\
> +  ((f)[0] && ((f)[1] == ':') && (dos_based))
> +
> +/* Remove the drive spec from F, assuming HAS_DRIVE_SPEC (f).
> +   The result is a pointer to the remainder of F.  */
> +#define STRIP_DRIVE_SPEC(f)	((f) + 2)
> +
> +#define IS_DOS_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (1, c)
> +#define IS_DOS_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (1, f)
> +#define HAS_DOS_DRIVE_SPEC(f) HAS_DRIVE_SPEC_1 (1, f)
> +
> +#define IS_UNIX_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (0, c)
> +#define IS_UNIX_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (0, f)
> +
> +/* Note that when DOS_BASED is true, IS_ABSOLUTE_PATH accepts d:foo as
> +   well, although it is only semi-absolute.  This is because the users
> +   of IS_ABSOLUTE_PATH want to know whether to prepend the current
> +   working directory to a file name, which should not be done with a
> +   name like d:foo.  */
> +#define IS_ABSOLUTE_PATH_1(dos_based, f)		 \
> +  (IS_DIR_SEPARATOR_1 (dos_based, (f)[0])		 \
> +   || HAS_DRIVE_SPEC_1 (dos_based, f))
> +
> +extern int filename_cmp (const char *s1, const char *s2);
> +#define FILENAME_CMP(s1, s2)	filename_cmp(s1, s2)
> +
> +extern int filename_ncmp (const char *s1, const char *s2,
> +			  size_t n);
> +
> +extern hashval_t filename_hash (const void *s);
> +
> +extern int filename_eq (const void *s1, const void *s2);
> +
> +extern int canonical_filename_eq (const char *a, const char *b);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* FILENAMES_H */
> diff --git a/libgcov/include/gcov-counter.def b/libgcov/include/gcov-counter.def
> new file mode 100644
> index 0000000..85dcdae
> --- /dev/null
> +++ b/libgcov/include/gcov-counter.def
> @@ -0,0 +1,54 @@
> +/* Definitions for the gcov counters in the GNU compiler.
> +   Copyright (C) 2001-2017 Free Software Foundation, Inc.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with GCC; see the file COPYING3.  If not see
> +<http://www.gnu.org/licenses/>.  */
> +
> +/* Before including this file, define a macro:
> +
> +     DEF_GCOV_COUNTER(COUNTER, NAME, FN_TYPE)
> +
> +   This macro will be expanded to all supported gcov counters, their
> +   names, or the type of handler functions.  FN_TYPE will be
> +   expanded to a handler function, like in gcov_merge, it is
> +   expanded to __gcov_merge ## FN_TYPE.  */
> +
> +/* Arc transitions.  */
> +DEF_GCOV_COUNTER(GCOV_COUNTER_ARCS, "arcs", _add)
> +
> +/* Histogram of value inside an interval.  */
> +DEF_GCOV_COUNTER(GCOV_COUNTER_V_INTERVAL, "interval", _add)
> +
> +/* Histogram of exact power2 logarithm of a value.  */
> +DEF_GCOV_COUNTER(GCOV_COUNTER_V_POW2, "pow2", _add)
> +
> +/* The most common value of expression.  */
> +DEF_GCOV_COUNTER(GCOV_COUNTER_V_SINGLE, "single", _single)
> +
> +/* The most common indirect address.  */
> +DEF_GCOV_COUNTER(GCOV_COUNTER_V_INDIR, "indirect_call", _single)
> +
> +/* Compute average value passed to the counter.  */
> +DEF_GCOV_COUNTER(GCOV_COUNTER_AVERAGE, "average", _add)
> +
> +/* IOR of the all values passed to counter.  */
> +DEF_GCOV_COUNTER(GCOV_COUNTER_IOR, "ior", _ior)
> +
> +/* Time profile collecting first run of a function */
> +DEF_GCOV_COUNTER(GCOV_TIME_PROFILER, "time_profiler", _time_profile)
> +
> +/* Top N value tracking for indirect calls.  */
> +DEF_GCOV_COUNTER(GCOV_COUNTER_ICALL_TOPNV, "indirect_call_topn", _icall_topn)
> diff --git a/libgcov/include/gcov-io.c b/libgcov/include/gcov-io.c
> new file mode 100644
> index 0000000..64dedd5
> --- /dev/null
> +++ b/libgcov/include/gcov-io.c
> @@ -0,0 +1,987 @@
> +/* File format for coverage information
> +   Copyright (C) 1996-2017 Free Software Foundation, Inc.
> +   Contributed by Bob Manson <manson@cygnus.com>.
> +   Completely remangled by Nathan Sidwell <nathan@codesourcery.com>.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +Under Section 7 of GPL version 3, you are granted additional
> +permissions described in the GCC Runtime Library Exception, version
> +3.1, as published by the Free Software Foundation.
> +
> +You should have received a copy of the GNU General Public License and
> +a copy of the GCC Runtime Library Exception along with this program;
> +see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +<http://www.gnu.org/licenses/>.  */
> +
> +/* Routines declared in gcov-io.h.  This file should be #included by
> +   another source file, after having #included gcov-io.h.  */
> +
> +#if !IN_GCOV
> +static void gcov_write_block (unsigned);
> +static gcov_unsigned_t *gcov_write_words (unsigned);
> +#endif
> +static const gcov_unsigned_t *gcov_read_words (unsigned);
> +#if !IN_LIBGCOV
> +static void gcov_allocate (unsigned);
> +#endif
> +
> +/* Optimum number of gcov_unsigned_t's read from or written to disk.  */
> +#define GCOV_BLOCK_SIZE (1 << 10)
> +
> +struct gcov_var
> +{
> +  FILE *file;
> +  gcov_position_t start;	/* Position of first byte of block */
> +  unsigned offset;		/* Read/write position within the block.  */
> +  unsigned length;		/* Read limit in the block.  */
> +  unsigned overread;		/* Number of words overread.  */
> +  int error;			/* < 0 overflow, > 0 disk error.  */
> +  int mode;	                /* < 0 writing, > 0 reading */
> +#if IN_LIBGCOV
> +  /* Holds one block plus 4 bytes, thus all coverage reads & writes
> +     fit within this buffer and we always can transfer GCOV_BLOCK_SIZE
> +     to and from the disk. libgcov never backtracks and only writes 4
> +     or 8 byte objects.  */
> +  gcov_unsigned_t buffer[GCOV_BLOCK_SIZE + 1];
> +#else
> +  int endian;			/* Swap endianness.  */
> +  /* Holds a variable length block, as the compiler can write
> +     strings and needs to backtrack.  */
> +  size_t alloc;
> +  gcov_unsigned_t *buffer;
> +#endif
> +} gcov_var;
> +
> +/* Save the current position in the gcov file.  */
> +/* We need to expose this function when compiling for gcov-tool.  */
> +#ifndef IN_GCOV_TOOL
> +static inline
> +#endif
> +gcov_position_t
> +gcov_position (void)
> +{
> +  gcov_nonruntime_assert (gcov_var.mode > 0); 
> +  return gcov_var.start + gcov_var.offset;
> +}
> +
> +/* Return nonzero if the error flag is set.  */
> +/* We need to expose this function when compiling for gcov-tool.  */
> +#ifndef IN_GCOV_TOOL
> +static inline
> +#endif
> +int
> +gcov_is_error (void)
> +{
> +  return gcov_var.file ? gcov_var.error : 1;
> +}
> +
> +#if IN_LIBGCOV
> +/* Move to beginning of file and initialize for writing.  */
> +GCOV_LINKAGE inline void
> +gcov_rewrite (void)
> +{
> +  gcov_var.mode = -1; 
> +  gcov_var.start = 0;
> +  gcov_var.offset = 0;
> +  fseek (gcov_var.file, 0L, SEEK_SET);
> +}
> +#endif
> +
> +static inline gcov_unsigned_t from_file (gcov_unsigned_t value)
> +{
> +#if !IN_LIBGCOV
> +  if (gcov_var.endian)
> +    {
> +      value = (value >> 16) | (value << 16);
> +      value = ((value & 0xff00ff) << 8) | ((value >> 8) & 0xff00ff);
> +    }
> +#endif
> +  return value;
> +}
> +
> +/* Open a gcov file. NAME is the name of the file to open and MODE
> +   indicates whether a new file should be created, or an existing file
> +   opened. If MODE is >= 0 an existing file will be opened, if
> +   possible, and if MODE is <= 0, a new file will be created. Use
> +   MODE=0 to attempt to reopen an existing file and then fall back on
> +   creating a new one.  If MODE > 0, the file will be opened in
> +   read-only mode.  Otherwise it will be opened for modification.
> +   Return zero on failure, non-zero on success.  */
> +
> +GCOV_LINKAGE int
> +#if IN_LIBGCOV
> +gcov_open (const char *name)
> +#else
> +gcov_open (const char *name, int mode)
> +#endif
> +{
> +#if IN_LIBGCOV
> +  int mode = 0;
> +#endif
> +#if GCOV_LOCKED
> +  struct flock s_flock;
> +  int fd;
> +
> +  s_flock.l_whence = SEEK_SET;
> +  s_flock.l_start = 0;
> +  s_flock.l_len = 0; /* Until EOF.  */
> +  s_flock.l_pid = getpid ();
> +#endif
> +
> +  gcov_nonruntime_assert (!gcov_var.file);
> +  gcov_var.start = 0;
> +  gcov_var.offset = gcov_var.length = 0;
> +  gcov_var.overread = -1u;
> +  gcov_var.error = 0;
> +#if !IN_LIBGCOV
> +  gcov_var.endian = 0;
> +#endif
> +#if GCOV_LOCKED
> +  if (mode > 0)
> +    {
> +      /* Read-only mode - acquire a read-lock.  */
> +      s_flock.l_type = F_RDLCK;
> +      /* pass mode (ignored) for compatibility */
> +      fd = open (name, O_RDONLY, S_IRUSR | S_IWUSR);
> +    }
> +  else
> +     {
> +       /* Write mode - acquire a write-lock.  */
> +       s_flock.l_type = F_WRLCK;
> +       /* Truncate if force new mode.  */
> +       fd = open (name, O_RDWR | O_CREAT | (mode < 0 ? O_TRUNC : 0), 0666);
> +    }
> +  if (fd < 0)
> +    return 0;
> +
> +  while (fcntl (fd, F_SETLKW, &s_flock) && errno == EINTR)
> +    continue;
> +
> +  gcov_var.file = fdopen (fd, (mode > 0) ? "rb" : "r+b");
> +
> +  if (!gcov_var.file)
> +    {
> +      close (fd);
> +      return 0;
> +    }
> +#else
> +  if (mode >= 0)
> +    /* Open an existing file.  */
> +    gcov_var.file = fopen (name, (mode > 0) ? "rb" : "r+b");
> +
> +  if (gcov_var.file)
> +    mode = 1;
> +  else if (mode <= 0)
> +    /* Create a new file.  */
> +    gcov_var.file = fopen (name, "w+b");
> +
> +  if (!gcov_var.file)
> +    return 0;
> +#endif
> +
> +  gcov_var.mode = mode ? mode : 1;
> +
> +  setbuf (gcov_var.file, (char *)0);
> +
> +  return 1;
> +}
> +
> +/* Close the current gcov file. Flushes data to disk. Returns nonzero
> +   on failure or error flag set.  */
> +
> +GCOV_LINKAGE int
> +gcov_close (void)
> +{
> +  if (gcov_var.file)
> +    {
> +#if !IN_GCOV
> +      if (gcov_var.offset && gcov_var.mode < 0)
> +	gcov_write_block (gcov_var.offset);
> +#endif
> +      fclose (gcov_var.file);
> +      gcov_var.file = 0;
> +      gcov_var.length = 0;
> +    }
> +#if !IN_LIBGCOV
> +  free (gcov_var.buffer);
> +  gcov_var.alloc = 0;
> +  gcov_var.buffer = 0;
> +#endif
> +  gcov_var.mode = 0;
> +  return gcov_var.error;
> +}
> +
> +#if !IN_LIBGCOV
> +/* Check if MAGIC is EXPECTED. Use it to determine endianness of the
> +   file. Returns +1 for same endian, -1 for other endian and zero for
> +   not EXPECTED.  */
> +
> +GCOV_LINKAGE int
> +gcov_magic (gcov_unsigned_t magic, gcov_unsigned_t expected)
> +{
> +  if (magic == expected)
> +    return 1;
> +  magic = (magic >> 16) | (magic << 16);
> +  magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
> +  if (magic == expected)
> +    {
> +      gcov_var.endian = 1;
> +      return -1;
> +    }
> +  return 0;
> +}
> +#endif
> +
> +#if !IN_LIBGCOV
> +static void
> +gcov_allocate (unsigned length)
> +{
> +  size_t new_size = gcov_var.alloc;
> +
> +  if (!new_size)
> +    new_size = GCOV_BLOCK_SIZE;
> +  new_size += length;
> +  new_size *= 2;
> +
> +  gcov_var.alloc = new_size;
> +  gcov_var.buffer = XRESIZEVAR (gcov_unsigned_t, gcov_var.buffer, new_size << 2);
> +}
> +#endif
> +
> +#if !IN_GCOV
> +/* Write out the current block, if needs be.  */
> +
> +static void
> +gcov_write_block (unsigned size)
> +{
> +  if (fwrite (gcov_var.buffer, size << 2, 1, gcov_var.file) != 1)
> +    gcov_var.error = 1;
> +  gcov_var.start += size;
> +  gcov_var.offset -= size;
> +}
> +
> +/* Allocate space to write BYTES bytes to the gcov file. Return a
> +   pointer to those bytes, or NULL on failure.  */
> +
> +static gcov_unsigned_t *
> +gcov_write_words (unsigned words)
> +{
> +  gcov_unsigned_t *result;
> +
> +  gcov_nonruntime_assert (gcov_var.mode < 0);
> +#if IN_LIBGCOV
> +  if (gcov_var.offset >= GCOV_BLOCK_SIZE)
> +    {
> +      gcov_write_block (GCOV_BLOCK_SIZE);
> +      if (gcov_var.offset)
> +	{
> +	  memcpy (gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4);
> +	}
> +    }
> +#else
> +  if (gcov_var.offset + words > gcov_var.alloc)
> +    gcov_allocate (gcov_var.offset + words);
> +#endif
> +  result = &gcov_var.buffer[gcov_var.offset];
> +  gcov_var.offset += words;
> +
> +  return result;
> +}
> +
> +/* Write unsigned VALUE to coverage file.  Sets error flag
> +   appropriately.  */
> +
> +GCOV_LINKAGE void
> +gcov_write_unsigned (gcov_unsigned_t value)
> +{
> +  gcov_unsigned_t *buffer = gcov_write_words (1);
> +
> +  buffer[0] = value;
> +}
> +
> +/* Write counter VALUE to coverage file.  Sets error flag
> +   appropriately.  */
> +
> +#if IN_LIBGCOV
> +GCOV_LINKAGE void
> +gcov_write_counter (gcov_type value)
> +{
> +  gcov_unsigned_t *buffer = gcov_write_words (2);
> +
> +  buffer[0] = (gcov_unsigned_t) value;
> +  if (sizeof (value) > sizeof (gcov_unsigned_t))
> +    buffer[1] = (gcov_unsigned_t) (value >> 32);
> +  else
> +    buffer[1] = 0;
> +}
> +#endif /* IN_LIBGCOV */
> +
> +#if !IN_LIBGCOV
> +/* Write STRING to coverage file.  Sets error flag on file
> +   error, overflow flag on overflow */
> +
> +GCOV_LINKAGE void
> +gcov_write_string (const char *string)
> +{
> +  unsigned length = 0;
> +  unsigned alloc = 0;
> +  gcov_unsigned_t *buffer;
> +
> +  if (string)
> +    {
> +      length = strlen (string);
> +      alloc = (length + 4) >> 2;
> +    }
> +
> +  buffer = gcov_write_words (1 + alloc);
> +
> +  buffer[0] = alloc;
> +
> +  if (alloc > 0)
> +    {
> +      buffer[alloc] = 0; /* place nul terminators.  */
> +      memcpy (&buffer[1], string, length);
> +    }
> +}
> +#endif
> +
> +#if !IN_LIBGCOV
> +/* Write a tag TAG and reserve space for the record length. Return a
> +   value to be used for gcov_write_length.  */
> +
> +GCOV_LINKAGE gcov_position_t
> +gcov_write_tag (gcov_unsigned_t tag)
> +{
> +  gcov_position_t result = gcov_var.start + gcov_var.offset;
> +  gcov_unsigned_t *buffer = gcov_write_words (2);
> +
> +  buffer[0] = tag;
> +  buffer[1] = 0;
> +
> +  return result;
> +}
> +
> +/* Write a record length using POSITION, which was returned by
> +   gcov_write_tag.  The current file position is the end of the
> +   record, and is restored before returning.  Returns nonzero on
> +   overflow.  */
> +
> +GCOV_LINKAGE void
> +gcov_write_length (gcov_position_t position)
> +{
> +  unsigned offset;
> +  gcov_unsigned_t length;
> +  gcov_unsigned_t *buffer;
> +
> +  gcov_nonruntime_assert (gcov_var.mode < 0);
> +  gcov_nonruntime_assert (position + 2 <= gcov_var.start + gcov_var.offset);
> +  gcov_nonruntime_assert (position >= gcov_var.start);
> +  offset = position - gcov_var.start;
> +  length = gcov_var.offset - offset - 2;
> +  buffer = (gcov_unsigned_t *) &gcov_var.buffer[offset];
> +  buffer[1] = length;
> +  if (gcov_var.offset >= GCOV_BLOCK_SIZE)
> +    gcov_write_block (gcov_var.offset);
> +}
> +
> +#else /* IN_LIBGCOV */
> +
> +/* Write a tag TAG and length LENGTH.  */
> +
> +GCOV_LINKAGE void
> +gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length)
> +{
> +  gcov_unsigned_t *buffer = gcov_write_words (2);
> +
> +  buffer[0] = tag;
> +  buffer[1] = length;
> +}
> +
> +/* Write a summary structure to the gcov file.  Return nonzero on
> +   overflow.  */
> +
> +GCOV_LINKAGE void
> +gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary)
> +{
> +  unsigned ix, h_ix, bv_ix, h_cnt = 0;
> +  const struct gcov_ctr_summary *csum;
> +  unsigned histo_bitvector[GCOV_HISTOGRAM_BITVECTOR_SIZE];
> +
> +  /* Count number of non-zero histogram entries, and fill in a bit vector
> +     of non-zero indices. The histogram is only currently computed for arc
> +     counters.  */
> +  for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
> +    histo_bitvector[bv_ix] = 0;
> +  csum = &summary->ctrs[GCOV_COUNTER_ARCS];
> +  for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
> +    if (csum->histogram[h_ix].num_counters)
> +      {
> +	histo_bitvector[h_ix / 32] |= 1 << (h_ix % 32);
> +	h_cnt++;
> +      }
> +  gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH (h_cnt));
> +  gcov_write_unsigned (summary->checksum);
> +  for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
> +    {
> +      gcov_write_unsigned (csum->num);
> +      gcov_write_unsigned (csum->runs);
> +      gcov_write_counter (csum->sum_all);
> +      gcov_write_counter (csum->run_max);
> +      gcov_write_counter (csum->sum_max);
> +      if (ix != GCOV_COUNTER_ARCS)
> +        {
> +          for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
> +            gcov_write_unsigned (0);
> +          continue;
> +        }
> +      for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
> +        gcov_write_unsigned (histo_bitvector[bv_ix]);
> +      for (h_ix = 0; h_ix < GCOV_HISTOGRAM_SIZE; h_ix++)
> +        {
> +          if (!csum->histogram[h_ix].num_counters)
> +            continue;
> +          gcov_write_unsigned (csum->histogram[h_ix].num_counters);
> +          gcov_write_counter (csum->histogram[h_ix].min_value);
> +          gcov_write_counter (csum->histogram[h_ix].cum_value);
> +        }
> +    }
> +}
> +#endif /* IN_LIBGCOV */
> +
> +#endif /*!IN_GCOV */
> +
> +/* Return a pointer to read BYTES bytes from the gcov file. Returns
> +   NULL on failure (read past EOF).  */
> +
> +static const gcov_unsigned_t *
> +gcov_read_words (unsigned words)
> +{
> +  const gcov_unsigned_t *result;
> +  unsigned excess = gcov_var.length - gcov_var.offset;
> +
> +  if (gcov_var.mode <= 0)
> +    return NULL;
> +
> +  if (excess < words)
> +    {
> +      gcov_var.start += gcov_var.offset;
> +      if (excess)
> +	{
> +#if IN_LIBGCOV
> +	  memcpy (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, 4);
> +#else
> +	  memmove (gcov_var.buffer, gcov_var.buffer + gcov_var.offset,
> +		   excess * 4);
> +#endif
> +	}
> +      gcov_var.offset = 0;
> +      gcov_var.length = excess;
> +#if IN_LIBGCOV
> +      excess = GCOV_BLOCK_SIZE;
> +#else
> +      if (gcov_var.length + words > gcov_var.alloc)
> +	gcov_allocate (gcov_var.length + words);
> +      excess = gcov_var.alloc - gcov_var.length;
> +#endif
> +      excess = fread (gcov_var.buffer + gcov_var.length,
> +		      1, excess << 2, gcov_var.file) >> 2;
> +      gcov_var.length += excess;
> +      if (gcov_var.length < words)
> +	{
> +	  gcov_var.overread += words - gcov_var.length;
> +	  gcov_var.length = 0;
> +	  return 0;
> +	}
> +    }
> +  result = &gcov_var.buffer[gcov_var.offset];
> +  gcov_var.offset += words;
> +  return result;
> +}
> +
> +/* Read unsigned value from a coverage file. Sets error flag on file
> +   error, overflow flag on overflow */
> +
> +GCOV_LINKAGE gcov_unsigned_t
> +gcov_read_unsigned (void)
> +{
> +  gcov_unsigned_t value;
> +  const gcov_unsigned_t *buffer = gcov_read_words (1);
> +
> +  if (!buffer)
> +    return 0;
> +  value = from_file (buffer[0]);
> +  return value;
> +}
> +
> +/* Read counter value from a coverage file. Sets error flag on file
> +   error, overflow flag on overflow */
> +
> +GCOV_LINKAGE gcov_type
> +gcov_read_counter (void)
> +{
> +  gcov_type value;
> +  const gcov_unsigned_t *buffer = gcov_read_words (2);
> +
> +  if (!buffer)
> +    return 0;
> +  value = from_file (buffer[0]);
> +  if (sizeof (value) > sizeof (gcov_unsigned_t))
> +    value |= ((gcov_type) from_file (buffer[1])) << 32;
> +  else if (buffer[1])
> +    gcov_var.error = -1;
> +
> +  return value;
> +}
> +
> +/* We need to expose the below function when compiling for gcov-tool.  */
> +
> +#if !IN_LIBGCOV || defined (IN_GCOV_TOOL)
> +/* Read string from coverage file. Returns a pointer to a static
> +   buffer, or NULL on empty string. You must copy the string before
> +   calling another gcov function.  */
> +
> +GCOV_LINKAGE const char *
> +gcov_read_string (void)
> +{
> +  unsigned length = gcov_read_unsigned ();
> +
> +  if (!length)
> +    return 0;
> +
> +  return (const char *) gcov_read_words (length);
> +}
> +#endif
> +
> +GCOV_LINKAGE void
> +gcov_read_summary (struct gcov_summary *summary)
> +{
> +  unsigned ix, h_ix, bv_ix, h_cnt = 0;
> +  struct gcov_ctr_summary *csum;
> +  unsigned histo_bitvector[GCOV_HISTOGRAM_BITVECTOR_SIZE];
> +  unsigned cur_bitvector;
> +
> +  summary->checksum = gcov_read_unsigned ();
> +  for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
> +    {
> +      csum->num = gcov_read_unsigned ();
> +      csum->runs = gcov_read_unsigned ();
> +      csum->sum_all = gcov_read_counter ();
> +      csum->run_max = gcov_read_counter ();
> +      csum->sum_max = gcov_read_counter ();
> +      memset (csum->histogram, 0,
> +              sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
> +      for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
> +        {
> +          histo_bitvector[bv_ix] = gcov_read_unsigned ();
> +#if IN_LIBGCOV
> +          /* When building libgcov we don't include system.h, which includes
> +             hwint.h (where popcount_hwi is declared). However, libgcov.a
> +             is built by the bootstrapped compiler and therefore the builtins
> +             are always available.  */
> +          h_cnt += __builtin_popcount (histo_bitvector[bv_ix]);
> +#else
> +          h_cnt += popcount_hwi (histo_bitvector[bv_ix]);
> +#endif
> +        }
> +      bv_ix = 0;
> +      h_ix = 0;
> +      cur_bitvector = 0;
> +      while (h_cnt--)
> +        {
> +          /* Find the index corresponding to the next entry we will read in.
> +             First find the next non-zero bitvector and re-initialize
> +             the histogram index accordingly, then right shift and increment
> +             the index until we find a set bit.  */
> +          while (!cur_bitvector)
> +            {
> +              h_ix = bv_ix * 32;
> +              if (bv_ix >= GCOV_HISTOGRAM_BITVECTOR_SIZE)
> +                gcov_error ("corrupted profile info: summary histogram "
> +                            "bitvector is corrupt");
> +              cur_bitvector = histo_bitvector[bv_ix++];
> +            }
> +          while (!(cur_bitvector & 0x1))
> +            {
> +              h_ix++;
> +              cur_bitvector >>= 1;
> +            }
> +          if (h_ix >= GCOV_HISTOGRAM_SIZE)
> +            gcov_error ("corrupted profile info: summary histogram "
> +                        "index is corrupt");
> +
> +          csum->histogram[h_ix].num_counters = gcov_read_unsigned ();
> +          csum->histogram[h_ix].min_value = gcov_read_counter ();
> +          csum->histogram[h_ix].cum_value = gcov_read_counter ();
> +          /* Shift off the index we are done with and increment to the
> +             corresponding next histogram entry.  */
> +          cur_bitvector >>= 1;
> +          h_ix++;
> +        }
> +    }
> +}
> +
> +/* We need to expose the below function when compiling for gcov-tool.  */
> +
> +#if !IN_LIBGCOV || defined (IN_GCOV_TOOL)
> +/* Reset to a known position.  BASE should have been obtained from
> +   gcov_position, LENGTH should be a record length.  */
> +
> +GCOV_LINKAGE void
> +gcov_sync (gcov_position_t base, gcov_unsigned_t length)
> +{
> +  gcov_nonruntime_assert (gcov_var.mode > 0);
> +  base += length;
> +  if (base - gcov_var.start <= gcov_var.length)
> +    gcov_var.offset = base - gcov_var.start;
> +  else
> +    {
> +      gcov_var.offset = gcov_var.length = 0;
> +      fseek (gcov_var.file, base << 2, SEEK_SET);
> +      gcov_var.start = ftell (gcov_var.file) >> 2;
> +    }
> +}
> +#endif
> +
> +#if IN_LIBGCOV
> +/* Move to a given position in a gcov file.  */
> +
> +GCOV_LINKAGE void
> +gcov_seek (gcov_position_t base)
> +{
> +  if (gcov_var.offset)
> +    gcov_write_block (gcov_var.offset);
> +  fseek (gcov_var.file, base << 2, SEEK_SET);
> +  gcov_var.start = ftell (gcov_var.file) >> 2;
> +}
> +#endif
> +
> +#if IN_GCOV > 0
> +/* Return the modification time of the current gcov file.  */
> +
> +GCOV_LINKAGE time_t
> +gcov_time (void)
> +{
> +  struct stat status;
> +
> +  if (fstat (fileno (gcov_var.file), &status))
> +    return 0;
> +  else
> +    return status.st_mtime;
> +}
> +#endif /* IN_GCOV */
> +
> +#if !IN_GCOV
> +/* Determine the index into histogram for VALUE. */
> +
> +#if IN_LIBGCOV
> +static unsigned
> +#else
> +GCOV_LINKAGE unsigned
> +#endif
> +gcov_histo_index (gcov_type value)
> +{
> +  gcov_type_unsigned v = (gcov_type_unsigned)value;
> +  unsigned r = 0;
> +  unsigned prev2bits = 0;
> +
> +  /* Find index into log2 scale histogram, where each of the log2
> +     sized buckets is divided into 4 linear sub-buckets for better
> +     focus in the higher buckets.  */
> +
> +  /* Find the place of the most-significant bit set.  */
> +  if (v > 0)
> +    {
> +#if IN_LIBGCOV
> +      /* When building libgcov we don't include system.h, which includes
> +         hwint.h (where floor_log2 is declared). However, libgcov.a
> +         is built by the bootstrapped compiler and therefore the builtins
> +         are always available.  */
> +      r = sizeof (long long) * __CHAR_BIT__ - 1 - __builtin_clzll (v);
> +#else
> +      /* We use floor_log2 from hwint.c, which takes a HOST_WIDE_INT
> +         that is 64 bits and gcov_type_unsigned is 64 bits.  */
> +      r = floor_log2 (v);
> +#endif
> +    }
> +
> +  /* If at most the 2 least significant bits are set (value is
> +     0 - 3) then that value is our index into the lowest set of
> +     four buckets.  */
> +  if (r < 2)
> +    return (unsigned)value;
> +
> +  gcov_nonruntime_assert (r < 64);
> +
> +  /* Find the two next most significant bits to determine which
> +     of the four linear sub-buckets to select.  */
> +  prev2bits = (v >> (r - 2)) & 0x3;
> +  /* Finally, compose the final bucket index from the log2 index and
> +     the next 2 bits. The minimum r value at this point is 2 since we
> +     returned above if r was 2 or more, so the minimum bucket at this
> +     point is 4.  */
> +  return (r - 1) * 4 + prev2bits;
> +}
> +
> +/* Merge SRC_HISTO into TGT_HISTO. The counters are assumed to be in
> +   the same relative order in both histograms, and are matched up
> +   and merged in reverse order. Each counter is assigned an equal portion of
> +   its entry's original cumulative counter value when computing the
> +   new merged cum_value.  */
> +
> +static void gcov_histogram_merge (gcov_bucket_type *tgt_histo,
> +                                  gcov_bucket_type *src_histo)
> +{
> +  int src_i, tgt_i, tmp_i = 0;
> +  unsigned src_num, tgt_num, merge_num;
> +  gcov_type src_cum, tgt_cum, merge_src_cum, merge_tgt_cum, merge_cum;
> +  gcov_type merge_min;
> +  gcov_bucket_type tmp_histo[GCOV_HISTOGRAM_SIZE];
> +  int src_done = 0;
> +
> +  memset (tmp_histo, 0, sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
> +
> +  /* Assume that the counters are in the same relative order in both
> +     histograms. Walk the histograms from largest to smallest entry,
> +     matching up and combining counters in order.  */
> +  src_num = 0;
> +  src_cum = 0;
> +  src_i = GCOV_HISTOGRAM_SIZE - 1;
> +  for (tgt_i = GCOV_HISTOGRAM_SIZE - 1; tgt_i >= 0 && !src_done; tgt_i--)
> +    {
> +      tgt_num = tgt_histo[tgt_i].num_counters;
> +      tgt_cum = tgt_histo[tgt_i].cum_value;
> +      /* Keep going until all of the target histogram's counters at this
> +         position have been matched and merged with counters from the
> +         source histogram.  */
> +      while (tgt_num > 0 && !src_done)
> +        {
> +          /* If this is either the first time through this loop or we just
> +             exhausted the previous non-zero source histogram entry, look
> +             for the next non-zero source histogram entry.  */
> +          if (!src_num)
> +            {
> +              /* Locate the next non-zero entry.  */
> +              while (src_i >= 0 && !src_histo[src_i].num_counters)
> +                src_i--;
> +              /* If source histogram has fewer counters, then just copy over the
> +                 remaining target counters and quit.  */
> +              if (src_i < 0)
> +                {
> +                  tmp_histo[tgt_i].num_counters += tgt_num;
> +                  tmp_histo[tgt_i].cum_value += tgt_cum;
> +                  if (!tmp_histo[tgt_i].min_value ||
> +                      tgt_histo[tgt_i].min_value < tmp_histo[tgt_i].min_value)
> +                    tmp_histo[tgt_i].min_value = tgt_histo[tgt_i].min_value;
> +                  while (--tgt_i >= 0)
> +                    {
> +                      tmp_histo[tgt_i].num_counters
> +                          += tgt_histo[tgt_i].num_counters;
> +                      tmp_histo[tgt_i].cum_value += tgt_histo[tgt_i].cum_value;
> +                      if (!tmp_histo[tgt_i].min_value ||
> +                          tgt_histo[tgt_i].min_value
> +                          < tmp_histo[tgt_i].min_value)
> +                        tmp_histo[tgt_i].min_value = tgt_histo[tgt_i].min_value;
> +                    }
> +
> +                  src_done = 1;
> +                  break;
> +                }
> +
> +              src_num = src_histo[src_i].num_counters;
> +              src_cum = src_histo[src_i].cum_value;
> +            }
> +
> +          /* The number of counters to merge on this pass is the minimum
> +             of the remaining counters from the current target and source
> +             histogram entries.  */
> +          merge_num = tgt_num;
> +          if (src_num < merge_num)
> +            merge_num = src_num;
> +
> +          /* The merged min_value is the sum of the min_values from target
> +             and source.  */
> +          merge_min = tgt_histo[tgt_i].min_value + src_histo[src_i].min_value;
> +
> +          /* Compute the portion of source and target entries' cum_value
> +             that will be apportioned to the counters being merged.
> +             The total remaining cum_value from each entry is divided
> +             equally among the counters from that histogram entry if we
> +             are not merging all of them.  */
> +          merge_src_cum = src_cum;
> +          if (merge_num < src_num)
> +            merge_src_cum = merge_num * src_cum / src_num;
> +          merge_tgt_cum = tgt_cum;
> +          if (merge_num < tgt_num)
> +            merge_tgt_cum = merge_num * tgt_cum / tgt_num;
> +          /* The merged cum_value is the sum of the source and target
> +             components.  */
> +          merge_cum = merge_src_cum + merge_tgt_cum;
> +
> +          /* Update the remaining number of counters and cum_value left
> +             to be merged from this source and target entry.  */
> +          src_cum -= merge_src_cum;
> +          tgt_cum -= merge_tgt_cum;
> +          src_num -= merge_num;
> +          tgt_num -= merge_num;
> +
> +          /* The merged counters get placed in the new merged histogram
> +             at the entry for the merged min_value.  */
> +          tmp_i = gcov_histo_index (merge_min);
> +          gcov_nonruntime_assert (tmp_i < GCOV_HISTOGRAM_SIZE);
> +          tmp_histo[tmp_i].num_counters += merge_num;
> +          tmp_histo[tmp_i].cum_value += merge_cum;
> +          if (!tmp_histo[tmp_i].min_value ||
> +              merge_min < tmp_histo[tmp_i].min_value)
> +            tmp_histo[tmp_i].min_value = merge_min;
> +
> +          /* Ensure the search for the next non-zero src_histo entry starts
> +             at the next smallest histogram bucket.  */
> +          if (!src_num)
> +            src_i--;
> +        }
> +    }
> +
> +  gcov_nonruntime_assert (tgt_i < 0);
> +
> +  /* In the case where there were more counters in the source histogram,
> +     accumulate the remaining unmerged cumulative counter values. Add
> +     those to the smallest non-zero target histogram entry. Otherwise,
> +     the total cumulative counter values in the histogram will be smaller
> +     than the sum_all stored in the summary, which will complicate
> +     computing the working set information from the histogram later on.  */
> +  if (src_num)
> +    src_i--;
> +  while (src_i >= 0)
> +    {
> +      src_cum += src_histo[src_i].cum_value;
> +      src_i--;
> +    }
> +  /* At this point, tmp_i should be the smallest non-zero entry in the
> +     tmp_histo.  */
> +  gcov_nonruntime_assert (tmp_i >= 0 && tmp_i < GCOV_HISTOGRAM_SIZE
> +                          && tmp_histo[tmp_i].num_counters > 0);
> +  tmp_histo[tmp_i].cum_value += src_cum;
> +
> +  /* Finally, copy the merged histogram into tgt_histo.  */
> +  memcpy (tgt_histo, tmp_histo,
> +	  sizeof (gcov_bucket_type) * GCOV_HISTOGRAM_SIZE);
> +}
> +#endif /* !IN_GCOV */
> +
> +/* This is used by gcov-dump (IN_GCOV == -1) and in the compiler
> +   (!IN_GCOV && !IN_LIBGCOV).  */
> +#if IN_GCOV <= 0 && !IN_LIBGCOV
> +/* Compute the working set information from the counter histogram in
> +   the profile summary. This is an array of information corresponding to a
> +   range of percentages of the total execution count (sum_all), and includes
> +   the number of counters required to cover that working set percentage and
> +   the minimum counter value in that working set.  */
> +
> +GCOV_LINKAGE void
> +compute_working_sets (const struct gcov_ctr_summary *summary,
> +                      gcov_working_set_t *gcov_working_sets)
> +{
> +  gcov_type working_set_cum_values[NUM_GCOV_WORKING_SETS];
> +  gcov_type ws_cum_hotness_incr;
> +  gcov_type cum, tmp_cum;
> +  const gcov_bucket_type *histo_bucket;
> +  unsigned ws_ix, c_num, count;
> +  int h_ix;
> +
> +  /* Compute the amount of sum_all that the cumulative hotness grows
> +     by in each successive working set entry, which depends on the
> +     number of working set entries.  */
> +  ws_cum_hotness_incr = summary->sum_all / NUM_GCOV_WORKING_SETS;
> +
> +  /* Next fill in an array of the cumulative hotness values corresponding
> +     to each working set summary entry we are going to compute below.
> +     Skip 0% statistics, which can be extrapolated from the
> +     rest of the summary data.  */
> +  cum = ws_cum_hotness_incr;
> +  for (ws_ix = 0; ws_ix < NUM_GCOV_WORKING_SETS;
> +       ws_ix++, cum += ws_cum_hotness_incr)
> +    working_set_cum_values[ws_ix] = cum;
> +  /* The last summary entry is reserved for (roughly) 99.9% of the
> +     working set. Divide by 1024 so it becomes a shift, which gives
> +     almost exactly 99.9%.  */
> +  working_set_cum_values[NUM_GCOV_WORKING_SETS-1]
> +      = summary->sum_all - summary->sum_all/1024;
> +
> +  /* Next, walk through the histogram in decending order of hotness
> +     and compute the statistics for the working set summary array.
> +     As histogram entries are accumulated, we check to see which
> +     working set entries have had their expected cum_value reached
> +     and fill them in, walking the working set entries in increasing
> +     size of cum_value.  */
> +  ws_ix = 0; /* The current entry into the working set array.  */
> +  cum = 0; /* The current accumulated counter sum.  */
> +  count = 0; /* The current accumulated count of block counters.  */
> +  for (h_ix = GCOV_HISTOGRAM_SIZE - 1;
> +       h_ix >= 0 && ws_ix < NUM_GCOV_WORKING_SETS; h_ix--)
> +    {
> +      histo_bucket = &summary->histogram[h_ix];
> +
> +      /* If we haven't reached the required cumulative counter value for
> +         the current working set percentage, simply accumulate this histogram
> +         entry into the running sums and continue to the next histogram
> +         entry.  */
> +      if (cum + histo_bucket->cum_value < working_set_cum_values[ws_ix])
> +        {
> +          cum += histo_bucket->cum_value;
> +          count += histo_bucket->num_counters;
> +          continue;
> +        }
> +
> +      /* If adding the current histogram entry's cumulative counter value
> +         causes us to exceed the current working set size, then estimate
> +         how many of this histogram entry's counter values are required to
> +         reach the working set size, and fill in working set entries
> +         as we reach their expected cumulative value.  */
> +      for (c_num = 0, tmp_cum = cum;
> +           c_num < histo_bucket->num_counters && ws_ix < NUM_GCOV_WORKING_SETS;
> +           c_num++)
> +        {
> +          count++;
> +          /* If we haven't reached the last histogram entry counter, add
> +             in the minimum value again. This will underestimate the
> +             cumulative sum so far, because many of the counter values in this
> +             entry may have been larger than the minimum. We could add in the
> +             average value every time, but that would require an expensive
> +             divide operation.  */
> +          if (c_num + 1 < histo_bucket->num_counters)
> +            tmp_cum += histo_bucket->min_value;
> +          /* If we have reached the last histogram entry counter, then add
> +             in the entire cumulative value.  */
> +          else
> +            tmp_cum = cum + histo_bucket->cum_value;
> +
> +	  /* Next walk through successive working set entries and fill in
> +	     the statistics for any whose size we have reached by accumulating
> +	     this histogram counter.  */
> +	  while (ws_ix < NUM_GCOV_WORKING_SETS
> +		 && tmp_cum >= working_set_cum_values[ws_ix])
> +            {
> +              gcov_working_sets[ws_ix].num_counters = count;
> +              gcov_working_sets[ws_ix].min_counter
> +                  = histo_bucket->min_value;
> +              ws_ix++;
> +            }
> +        }
> +      /* Finally, update the running cumulative value since we were
> +         using a temporary above.  */
> +      cum += histo_bucket->cum_value;
> +    }
> +  gcov_nonruntime_assert (ws_ix == NUM_GCOV_WORKING_SETS);
> +}
> +#endif /* IN_GCOV <= 0 && !IN_LIBGCOV */
> diff --git a/libgcov/include/gcov-io.h b/libgcov/include/gcov-io.h
> new file mode 100644
> index 0000000..1fb58dd
> --- /dev/null
> +++ b/libgcov/include/gcov-io.h
> @@ -0,0 +1,424 @@
> +/* File format for coverage information
> +   Copyright (C) 1996-2017 Free Software Foundation, Inc.
> +   Contributed by Bob Manson <manson@cygnus.com>.
> +   Completely remangled by Nathan Sidwell <nathan@codesourcery.com>.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +Under Section 7 of GPL version 3, you are granted additional
> +permissions described in the GCC Runtime Library Exception, version
> +3.1, as published by the Free Software Foundation.
> +
> +You should have received a copy of the GNU General Public License and
> +a copy of the GCC Runtime Library Exception along with this program;
> +see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +<http://www.gnu.org/licenses/>.  */
> +
> +
> +/* Coverage information is held in two files.  A notes file, which is
> +   generated by the compiler, and a data file, which is generated by
> +   the program under test.  Both files use a similar structure.  We do
> +   not attempt to make these files backwards compatible with previous
> +   versions, as you only need coverage information when developing a
> +   program.  We do hold version information, so that mismatches can be
> +   detected, and we use a format that allows tools to skip information
> +   they do not understand or are not interested in.
> +
> +   Numbers are recorded in the 32 bit unsigned binary form of the
> +   endianness of the machine generating the file. 64 bit numbers are
> +   stored as two 32 bit numbers, the low part first.  Strings are
> +   padded with 1 to 4 NUL bytes, to bring the length up to a multiple
> +   of 4. The number of 4 bytes is stored, followed by the padded
> +   string. Zero length and NULL strings are simply stored as a length
> +   of zero (they have no trailing NUL or padding).
> +
> +   	int32:  byte3 byte2 byte1 byte0 | byte0 byte1 byte2 byte3
> +	int64:  int32:low int32:high
> +	string: int32:0 | int32:length char* char:0 padding
> +	padding: | char:0 | char:0 char:0 | char:0 char:0 char:0
> +	item: int32 | int64 | string
> +
> +   The basic format of the files is
> +
> +   	file : int32:magic int32:version int32:stamp record*
> +
> +   The magic ident is different for the notes and the data files.  The
> +   magic ident is used to determine the endianness of the file, when
> +   reading.  The version is the same for both files and is derived
> +   from gcc's version number. The stamp value is used to synchronize
> +   note and data files and to synchronize merging within a data
> +   file. It need not be an absolute time stamp, merely a ticker that
> +   increments fast enough and cycles slow enough to distinguish
> +   different compile/run/compile cycles.
> +
> +   Although the ident and version are formally 32 bit numbers, they
> +   are derived from 4 character ASCII strings.  The version number
> +   consists of a two character major version number
> +   (first digit starts from 'A' letter to not to clash with the older
> +   numbering scheme), the single character minor version number,
> +   and a single character indicating the status of the release.
> +   That will be 'e' experimental, 'p' prerelease and 'r' for release.
> +   Because, by good fortune, these are in alphabetical order, string
> +   collating can be used to compare version strings.  Be aware that
> +   the 'e' designation will (naturally) be unstable and might be
> +   incompatible with itself.  For gcc 17.0 experimental, it would be
> +   'B70e' (0x42373065).  As we currently do not release more than 5 minor
> +   releases, the single character should be always fine.  Major number
> +   is currently changed roughly every year, which gives us space
> +   for next 250 years (maximum allowed number would be 259.9).
> +
> +   A record has a tag, length and variable amount of data.
> +
> +   	record: header data
> +	header: int32:tag int32:length
> +	data: item*
> +
> +   Records are not nested, but there is a record hierarchy.  Tag
> +   numbers reflect this hierarchy.  Tags are unique across note and
> +   data files.  Some record types have a varying amount of data.  The
> +   LENGTH is the number of 4bytes that follow and is usually used to
> +   determine how much data.  The tag value is split into 4 8-bit
> +   fields, one for each of four possible levels.  The most significant
> +   is allocated first.  Unused levels are zero.  Active levels are
> +   odd-valued, so that the LSB of the level is one.  A sub-level
> +   incorporates the values of its superlevels.  This formatting allows
> +   you to determine the tag hierarchy, without understanding the tags
> +   themselves, and is similar to the standard section numbering used
> +   in technical documents.  Level values [1..3f] are used for common
> +   tags, values [41..9f] for the notes file and [a1..ff] for the data
> +   file.
> +
> +   The notes file contains the following records
> +   	note: unit function-graph*
> +	unit: header int32:checksum string:source
> +	function-graph: announce_function basic_blocks {arcs | lines}*
> +	announce_function: header int32:ident
> +		int32:lineno_checksum int32:cfg_checksum
> +		string:name string:source int32:lineno
> +	basic_block: header int32:flags*
> +	arcs: header int32:block_no arc*
> +	arc:  int32:dest_block int32:flags
> +        lines: header int32:block_no line*
> +               int32:0 string:NULL
> +	line:  int32:line_no | int32:0 string:filename
> +
> +   The BASIC_BLOCK record holds per-bb flags.  The number of blocks
> +   can be inferred from its data length.  There is one ARCS record per
> +   basic block.  The number of arcs from a bb is implicit from the
> +   data length.  It enumerates the destination bb and per-arc flags.
> +   There is one LINES record per basic block, it enumerates the source
> +   lines which belong to that basic block.  Source file names are
> +   introduced by a line number of 0, following lines are from the new
> +   source file.  The initial source file for the function is NULL, but
> +   the current source file should be remembered from one LINES record
> +   to the next.  The end of a block is indicated by an empty filename
> +   - this does not reset the current source file.  Note there is no
> +   ordering of the ARCS and LINES records: they may be in any order,
> +   interleaved in any manner.  The current filename follows the order
> +   the LINES records are stored in the file, *not* the ordering of the
> +   blocks they are for.
> +
> +   The data file contains the following records.
> +        data: {unit summary:object summary:program* function-data*}*
> +	unit: header int32:checksum
> +        function-data:	announce_function present counts
> +	announce_function: header int32:ident
> +		int32:lineno_checksum int32:cfg_checksum
> +	present: header int32:present
> +	counts: header int64:count*
> +	summary: int32:checksum {count-summary}GCOV_COUNTERS_SUMMABLE
> +	count-summary:	int32:num int32:runs int64:sum
> +			int64:max int64:sum_max histogram
> +        histogram: {int32:bitvector}8 histogram-buckets*
> +        histogram-buckets: int32:num int64:min int64:sum
> +
> +   The ANNOUNCE_FUNCTION record is the same as that in the note file,
> +   but without the source location.  The COUNTS gives the
> +   counter values for instrumented features.  The about the whole
> +   program.  The checksum is used for whole program summaries, and
> +   disambiguates different programs which include the same
> +   instrumented object file.  There may be several program summaries,
> +   each with a unique checksum.  The object summary's checksum is
> +   zero.  Note that the data file might contain information from
> +   several runs concatenated, or the data might be merged.
> +
> +   This file is included by both the compiler, gcov tools and the
> +   runtime support library libgcov. IN_LIBGCOV and IN_GCOV are used to
> +   distinguish which case is which.  If IN_LIBGCOV is nonzero,
> +   libgcov is being built. If IN_GCOV is nonzero, the gcov tools are
> +   being built. Otherwise the compiler is being built. IN_GCOV may be
> +   positive or negative. If positive, we are compiling a tool that
> +   requires additional functions (see the code for knowledge of what
> +   those functions are).  */
> +
> +#ifndef GCC_GCOV_IO_H
> +#define GCC_GCOV_IO_H
> +
> +#ifndef IN_LIBGCOV
> +/* About the host */
> +
> +typedef unsigned gcov_unsigned_t;
> +typedef unsigned gcov_position_t;
> +/* gcov_type is typedef'd elsewhere for the compiler */
> +#if IN_GCOV
> +#define GCOV_LINKAGE static
> +typedef int64_t gcov_type;
> +typedef uint64_t gcov_type_unsigned;
> +#if IN_GCOV > 0
> +#include <sys/types.h>
> +#endif
> +#endif
> +
> +#if defined (HOST_HAS_F_SETLKW)
> +#define GCOV_LOCKED 1
> +#else
> +#define GCOV_LOCKED 0
> +#endif
> +
> +#define ATTRIBUTE_HIDDEN
> +
> +#endif /* !IN_LIBGOCV */
> +
> +#ifndef GCOV_LINKAGE
> +#define GCOV_LINKAGE extern
> +#endif
> +
> +#if IN_LIBGCOV
> +#define gcov_nonruntime_assert(EXPR) ((void)(0 && (EXPR)))
> +#else
> +#define gcov_nonruntime_assert(EXPR) gcc_assert (EXPR)
> +#define gcov_error(...) fatal_error (input_location, __VA_ARGS__)
> +#endif
> +
> +/* File suffixes.  */
> +#define GCOV_DATA_SUFFIX ".gcda"
> +#define GCOV_NOTE_SUFFIX ".gcno"
> +
> +/* File magic. Must not be palindromes.  */
> +#define GCOV_DATA_MAGIC ((gcov_unsigned_t)0x67636461) /* "gcda" */
> +#define GCOV_NOTE_MAGIC ((gcov_unsigned_t)0x67636e6f) /* "gcno" */
> +
> +/* gcov-iov.h is automatically generated by the makefile from
> +   version.c, it looks like
> +   	#define GCOV_VERSION ((gcov_unsigned_t)0x89abcdef)
> +*/
> +#include "gcov-iov.h"
> +
> +/* Convert a magic or version number to a 4 character string.  */
> +#define GCOV_UNSIGNED2STRING(ARRAY,VALUE)	\
> +  ((ARRAY)[0] = (char)((VALUE) >> 24),		\
> +   (ARRAY)[1] = (char)((VALUE) >> 16),		\
> +   (ARRAY)[2] = (char)((VALUE) >> 8),		\
> +   (ARRAY)[3] = (char)((VALUE) >> 0))
> +
> +/* The record tags.  Values [1..3f] are for tags which may be in either
> +   file.  Values [41..9f] for those in the note file and [a1..ff] for
> +   the data file.  The tag value zero is used as an explicit end of
> +   file marker -- it is not required to be present.  */
> +
> +#define GCOV_TAG_FUNCTION	 ((gcov_unsigned_t)0x01000000)
> +#define GCOV_TAG_FUNCTION_LENGTH (3)
> +#define GCOV_TAG_BLOCKS		 ((gcov_unsigned_t)0x01410000)
> +#define GCOV_TAG_BLOCKS_LENGTH(NUM) (NUM)
> +#define GCOV_TAG_BLOCKS_NUM(LENGTH) (LENGTH)
> +#define GCOV_TAG_ARCS		 ((gcov_unsigned_t)0x01430000)
> +#define GCOV_TAG_ARCS_LENGTH(NUM)  (1 + (NUM) * 2)
> +#define GCOV_TAG_ARCS_NUM(LENGTH)  (((LENGTH) - 1) / 2)
> +#define GCOV_TAG_LINES		 ((gcov_unsigned_t)0x01450000)
> +#define GCOV_TAG_COUNTER_BASE 	 ((gcov_unsigned_t)0x01a10000)
> +#define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 2)
> +#define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2)
> +#define GCOV_TAG_OBJECT_SUMMARY  ((gcov_unsigned_t)0xa1000000) /* Obsolete */
> +#define GCOV_TAG_PROGRAM_SUMMARY ((gcov_unsigned_t)0xa3000000)
> +#define GCOV_TAG_SUMMARY_LENGTH(NUM)  \
> +        (1 + GCOV_COUNTERS_SUMMABLE * (10 + 3 * 2) + (NUM) * 5)
> +#define GCOV_TAG_AFDO_FILE_NAMES ((gcov_unsigned_t)0xaa000000)
> +#define GCOV_TAG_AFDO_FUNCTION ((gcov_unsigned_t)0xac000000)
> +#define GCOV_TAG_AFDO_WORKING_SET ((gcov_unsigned_t)0xaf000000)
> +
> +
> +/* Counters that are collected.  */
> +
> +#define DEF_GCOV_COUNTER(COUNTER, NAME, MERGE_FN) COUNTER,
> +enum {
> +#include "gcov-counter.def"
> +GCOV_COUNTERS
> +};
> +#undef DEF_GCOV_COUNTER
> +
> +/* Counters which can be summaried.  */
> +#define GCOV_COUNTERS_SUMMABLE	(GCOV_COUNTER_ARCS + 1)
> +
> +/* The first of counters used for value profiling.  They must form a
> +   consecutive interval and their order must match the order of
> +   HIST_TYPEs in value-prof.h.  */
> +#define GCOV_FIRST_VALUE_COUNTER GCOV_COUNTERS_SUMMABLE
> +
> +/* The last of counters used for value profiling.  */
> +#define GCOV_LAST_VALUE_COUNTER (GCOV_COUNTERS - 1)
> +
> +/* Number of counters used for value profiling.  */
> +#define GCOV_N_VALUE_COUNTERS \
> +  (GCOV_LAST_VALUE_COUNTER - GCOV_FIRST_VALUE_COUNTER + 1)
> +
> +/* The number of hottest callees to be tracked.  */
> +#define GCOV_ICALL_TOPN_VAL  2
> +
> +/* The number of counter entries per icall callsite.  */
> +#define GCOV_ICALL_TOPN_NCOUNTS (1 + GCOV_ICALL_TOPN_VAL * 4)
> +
> +/* Convert a counter index to a tag.  */
> +#define GCOV_TAG_FOR_COUNTER(COUNT)				\
> +	(GCOV_TAG_COUNTER_BASE + ((gcov_unsigned_t)(COUNT) << 17))
> +/* Convert a tag to a counter.  */
> +#define GCOV_COUNTER_FOR_TAG(TAG)					\
> +	((unsigned)(((TAG) - GCOV_TAG_COUNTER_BASE) >> 17))
> +/* Check whether a tag is a counter tag.  */
> +#define GCOV_TAG_IS_COUNTER(TAG)				\
> +	(!((TAG) & 0xFFFF) && GCOV_COUNTER_FOR_TAG (TAG) < GCOV_COUNTERS)
> +
> +/* The tag level mask has 1's in the position of the inner levels, &
> +   the lsb of the current level, and zero on the current and outer
> +   levels.  */
> +#define GCOV_TAG_MASK(TAG) (((TAG) - 1) ^ (TAG))
> +
> +/* Return nonzero if SUB is an immediate subtag of TAG.  */
> +#define GCOV_TAG_IS_SUBTAG(TAG,SUB)				\
> +	(GCOV_TAG_MASK (TAG) >> 8 == GCOV_TAG_MASK (SUB) 	\
> +	 && !(((SUB) ^ (TAG)) & ~GCOV_TAG_MASK (TAG)))
> +
> +/* Return nonzero if SUB is at a sublevel to TAG.  */
> +#define GCOV_TAG_IS_SUBLEVEL(TAG,SUB)				\
> +     	(GCOV_TAG_MASK (TAG) > GCOV_TAG_MASK (SUB))
> +
> +/* Basic block flags.  */
> +#define GCOV_BLOCK_UNEXPECTED	(1 << 1)
> +
> +/* Arc flags.  */
> +#define GCOV_ARC_ON_TREE 	(1 << 0)
> +#define GCOV_ARC_FAKE		(1 << 1)
> +#define GCOV_ARC_FALLTHROUGH	(1 << 2)
> +
> +/* Structured records.  */
> +
> +/* Structure used for each bucket of the log2 histogram of counter values.  */
> +typedef struct
> +{
> +  /* Number of counters whose profile count falls within the bucket.  */
> +  gcov_unsigned_t num_counters;
> +  /* Smallest profile count included in this bucket.  */
> +  gcov_type min_value;
> +  /* Cumulative value of the profile counts in this bucket.  */
> +  gcov_type cum_value;
> +} gcov_bucket_type;
> +
> +/* For a log2 scale histogram with each range split into 4
> +   linear sub-ranges, there will be at most 64 (max gcov_type bit size) - 1 log2
> +   ranges since the lowest 2 log2 values share the lowest 4 linear
> +   sub-range (values 0 - 3).  This is 252 total entries (63*4).  */
> +
> +#define GCOV_HISTOGRAM_SIZE 252
> +
> +/* How many unsigned ints are required to hold a bit vector of non-zero
> +   histogram entries when the histogram is written to the gcov file.
> +   This is essentially a ceiling divide by 32 bits.  */
> +#define GCOV_HISTOGRAM_BITVECTOR_SIZE (GCOV_HISTOGRAM_SIZE + 31) / 32
> +
> +/* Cumulative counter data.  */
> +struct gcov_ctr_summary
> +{
> +  gcov_unsigned_t num;		/* number of counters.  */
> +  gcov_unsigned_t runs;		/* number of program runs */
> +  gcov_type sum_all;		/* sum of all counters accumulated.  */
> +  gcov_type run_max;		/* maximum value on a single run.  */
> +  gcov_type sum_max;    	/* sum of individual run max values.  */
> +  gcov_bucket_type histogram[GCOV_HISTOGRAM_SIZE]; /* histogram of
> +                                                      counter values.  */
> +};
> +
> +/* Object & program summary record.  */
> +struct gcov_summary
> +{
> +  gcov_unsigned_t checksum;	/* checksum of program */
> +  struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE];
> +};
> +
> +#if !defined(inhibit_libc)
> +
> +/* Functions for reading and writing gcov files. In libgcov you can
> +   open the file for reading then writing. Elsewhere you can open the
> +   file either for reading or for writing. When reading a file you may
> +   use the gcov_read_* functions, gcov_sync, gcov_position, &
> +   gcov_error. When writing a file you may use the gcov_write
> +   functions, gcov_seek & gcov_error. When a file is to be rewritten
> +   you use the functions for reading, then gcov_rewrite then the
> +   functions for writing.  Your file may become corrupted if you break
> +   these invariants.  */
> +
> +#if !IN_LIBGCOV
> +GCOV_LINKAGE int gcov_open (const char */*name*/, int /*direction*/);
> +GCOV_LINKAGE int gcov_magic (gcov_unsigned_t, gcov_unsigned_t);
> +#endif
> +
> +/* Available everywhere.  */
> +GCOV_LINKAGE int gcov_close (void) ATTRIBUTE_HIDDEN;
> +GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned (void) ATTRIBUTE_HIDDEN;
> +GCOV_LINKAGE gcov_type gcov_read_counter (void) ATTRIBUTE_HIDDEN;
> +GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *) ATTRIBUTE_HIDDEN;
> +GCOV_LINKAGE const char *gcov_read_string (void);
> +GCOV_LINKAGE void gcov_sync (gcov_position_t /*base*/,
> +			     gcov_unsigned_t /*length */);
> +
> +#if !IN_GCOV
> +/* Available outside gcov */
> +GCOV_LINKAGE void gcov_write_unsigned (gcov_unsigned_t) ATTRIBUTE_HIDDEN;
> +#endif
> +
> +#if !IN_GCOV && !IN_LIBGCOV
> +/* Available only in compiler */
> +GCOV_LINKAGE unsigned gcov_histo_index (gcov_type value);
> +GCOV_LINKAGE void gcov_write_string (const char *);
> +GCOV_LINKAGE gcov_position_t gcov_write_tag (gcov_unsigned_t);
> +GCOV_LINKAGE void gcov_write_length (gcov_position_t /*position*/);
> +#endif
> +
> +#if IN_GCOV <= 0 && !IN_LIBGCOV
> +/* Available in gcov-dump and the compiler.  */
> +
> +/* Number of data points in the working set summary array. Using 128
> +   provides information for at least every 1% increment of the total
> +   profile size. The last entry is hardwired to 99.9% of the total.  */
> +#define NUM_GCOV_WORKING_SETS 128
> +
> +/* Working set size statistics for a given percentage of the entire
> +   profile (sum_all from the counter summary).  */
> +typedef struct gcov_working_set_info
> +{
> +  /* Number of hot counters included in this working set.  */
> +  unsigned num_counters;
> +  /* Smallest counter included in this working set.  */
> +  gcov_type min_counter;
> +} gcov_working_set_t;
> +
> +GCOV_LINKAGE void compute_working_sets (const struct gcov_ctr_summary *summary,
> +                                        gcov_working_set_t *gcov_working_sets);
> +#endif
> +
> +#if IN_GCOV > 0
> +/* Available in gcov */
> +GCOV_LINKAGE time_t gcov_time (void);
> +#endif
> +
> +#endif /* !inhibit_libc  */
> +
> +#endif /* GCC_GCOV_IO_H */
> diff --git a/libgcov/include/gcov.h b/libgcov/include/gcov.h
> new file mode 100644
> index 0000000..0333ecc
> --- /dev/null
> +++ b/libgcov/include/gcov.h
> @@ -0,0 +1,41 @@
> +/* GCOV interface routines.
> +   Copyright (C) 2017 Free Software Foundation, Inc.
> +
> +   This file is part of GCC.
> +
> +   GCC is free software; you can redistribute it and/or modify it under
> +   the terms of the GNU General Public License as published by the Free
> +   Software Foundation; either version 3, or (at your option) any later
> +   version.
> +
> +   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +   WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +   for more details.
> +
> +   Under Section 7 of GPL version 3, you are granted additional
> +   permissions described in the GCC Runtime Library Exception, version
> +   3.1, as published by the Free Software Foundation.
> +
> +   You should have received a copy of the GNU General Public License and
> +   a copy of the GCC Runtime Library Exception along with this program;
> +   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#ifndef GCC_GCOV_H
> +#define GCC_GCOV_H
> +
> +/* Set all counters to zero.  */
> +
> +extern void __gcov_reset (void);
> +
> +/* Write profile information to a file.  */
> +
> +extern void __gcov_dump (void);
> +
> +/* Write profile information to a file and reset counters to zero.
> +   The function does operations under a mutex.  */
> +
> +extern void __gcov_flush (void);
> +
> +#endif /* GCC_GCOV_H */
> diff --git a/libgcov/include/gthr-default.h b/libgcov/include/gthr-default.h
> new file mode 100644
> index 0000000..a54a32e
> --- /dev/null
> +++ b/libgcov/include/gthr-default.h
> @@ -0,0 +1,889 @@
> +/* Threads compatibility routines for libgcc2 and libobjc.  */
> +/* Compile this one with gcc.  */
> +/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +Under Section 7 of GPL version 3, you are granted additional
> +permissions described in the GCC Runtime Library Exception, version
> +3.1, as published by the Free Software Foundation.
> +
> +You should have received a copy of the GNU General Public License and
> +a copy of the GCC Runtime Library Exception along with this program;
> +see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +<http://www.gnu.org/licenses/>.  */
> +
> +#ifndef GCC_GTHR_POSIX_H
> +#define GCC_GTHR_POSIX_H
> +
> +/* POSIX threads specific definitions.
> +   Easy, since the interface is just one-to-one mapping.  */
> +
> +#define __GTHREADS 1
> +#define __GTHREADS_CXX0X 1
> +
> +#include <pthread.h>
> +
> +#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
> +     || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
> +# include <unistd.h>
> +# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
> +#  define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
> +# else
> +#  define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
> +# endif
> +#endif
> +
> +typedef pthread_t __gthread_t;
> +typedef pthread_key_t __gthread_key_t;
> +typedef pthread_once_t __gthread_once_t;
> +typedef pthread_mutex_t __gthread_mutex_t;
> +typedef pthread_mutex_t __gthread_recursive_mutex_t;
> +typedef pthread_cond_t __gthread_cond_t;
> +typedef struct timespec __gthread_time_t;
> +
> +/* POSIX like conditional variables are supported.  Please look at comments
> +   in gthr.h for details. */
> +#define __GTHREAD_HAS_COND	1
> +
> +#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
> +#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
> +#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
> +#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
> +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
> +#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
> +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
> +#else
> +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
> +#endif
> +#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
> +#define __GTHREAD_TIME_INIT {0,0}
> +
> +#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
> +# undef __GTHREAD_MUTEX_INIT
> +#endif
> +#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
> +# undef __GTHREAD_RECURSIVE_MUTEX_INIT
> +# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
> +# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
> +#endif
> +#ifdef _GTHREAD_USE_COND_INIT_FUNC
> +# undef __GTHREAD_COND_INIT
> +# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
> +#endif
> +
> +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
> +# ifndef __gthrw_pragma
> +#  define __gthrw_pragma(pragma)
> +# endif
> +# define __gthrw2(name,name2,type) \
> +  static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
> +  __gthrw_pragma(weak type)
> +# define __gthrw_(name) __gthrw_ ## name
> +#else
> +# define __gthrw2(name,name2,type)
> +# define __gthrw_(name) name
> +#endif
> +
> +/* Typically, __gthrw_foo is a weak reference to symbol foo.  */
> +#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
> +
> +__gthrw(pthread_once)
> +__gthrw(pthread_getspecific)
> +__gthrw(pthread_setspecific)
> +
> +__gthrw(pthread_create)
> +__gthrw(pthread_join)
> +__gthrw(pthread_equal)
> +__gthrw(pthread_self)
> +__gthrw(pthread_detach)
> +#ifndef __BIONIC__
> +__gthrw(pthread_cancel)
> +#endif
> +__gthrw(sched_yield)
> +
> +__gthrw(pthread_mutex_lock)
> +__gthrw(pthread_mutex_trylock)
> +#if _GTHREAD_USE_MUTEX_TIMEDLOCK
> +__gthrw(pthread_mutex_timedlock)
> +#endif
> +__gthrw(pthread_mutex_unlock)
> +__gthrw(pthread_mutex_init)
> +__gthrw(pthread_mutex_destroy)
> +
> +__gthrw(pthread_cond_init)
> +__gthrw(pthread_cond_broadcast)
> +__gthrw(pthread_cond_signal)
> +__gthrw(pthread_cond_wait)
> +__gthrw(pthread_cond_timedwait)
> +__gthrw(pthread_cond_destroy)
> +
> +__gthrw(pthread_key_create)
> +__gthrw(pthread_key_delete)
> +__gthrw(pthread_mutexattr_init)
> +__gthrw(pthread_mutexattr_settype)
> +__gthrw(pthread_mutexattr_destroy)
> +
> +
> +#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
> +/* Objective-C.  */
> +__gthrw(pthread_exit)
> +#ifdef _POSIX_PRIORITY_SCHEDULING
> +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
> +__gthrw(sched_get_priority_max)
> +__gthrw(sched_get_priority_min)
> +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
> +#endif /* _POSIX_PRIORITY_SCHEDULING */
> +__gthrw(pthread_attr_destroy)
> +__gthrw(pthread_attr_init)
> +__gthrw(pthread_attr_setdetachstate)
> +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
> +__gthrw(pthread_getschedparam)
> +__gthrw(pthread_setschedparam)
> +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
> +#endif /* _LIBOBJC || _LIBOBJC_WEAK */
> +
> +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
> +
> +/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
> +   -pthreads is not specified.  The functions are dummies and most return an
> +   error value.  However pthread_once returns 0 without invoking the routine
> +   it is passed so we cannot pretend that the interface is active if -pthreads
> +   is not specified.  On Solaris 2.5.1, the interface is not exposed at all so
> +   we need to play the usual game with weak symbols.  On Solaris 10 and up, a
> +   working interface is always exposed.  On FreeBSD 6 and later, libc also
> +   exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
> +   to 9 does.  FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
> +   which means the alternate __gthread_active_p below cannot be used there.  */
> +
> +#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
> +
> +static volatile int __gthread_active = -1;
> +
> +static void
> +__gthread_trigger (void)
> +{
> +  __gthread_active = 1;
> +}
> +
> +static inline int
> +__gthread_active_p (void)
> +{
> +  static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
> +  static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
> +
> +  /* Avoid reading __gthread_active twice on the main code path.  */
> +  int __gthread_active_latest_value = __gthread_active;
> +
> +  /* This test is not protected to avoid taking a lock on the main code
> +     path so every update of __gthread_active in a threaded program must
> +     be atomic with regard to the result of the test.  */
> +  if (__builtin_expect (__gthread_active_latest_value < 0, 0))
> +    {
> +      if (__gthrw_(pthread_once))
> +	{
> +	  /* If this really is a threaded program, then we must ensure that
> +	     __gthread_active has been set to 1 before exiting this block.  */
> +	  __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
> +	  __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
> +	  __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
> +	}
> +
> +      /* Make sure we'll never enter this block again.  */
> +      if (__gthread_active < 0)
> +	__gthread_active = 0;
> +
> +      __gthread_active_latest_value = __gthread_active;
> +    }
> +
> +  return __gthread_active_latest_value != 0;
> +}
> +
> +#else /* neither FreeBSD nor Solaris */
> +
> +/* For a program to be multi-threaded the only thing that it certainly must
> +   be using is pthread_create.  However, there may be other libraries that
> +   intercept pthread_create with their own definitions to wrap pthreads
> +   functionality for some purpose.  In those cases, pthread_create being
> +   defined might not necessarily mean that libpthread is actually linked
> +   in.
> +
> +   For the GNU C library, we can use a known internal name.  This is always
> +   available in the ABI, but no other library would define it.  That is
> +   ideal, since any public pthread function might be intercepted just as
> +   pthread_create might be.  __pthread_key_create is an "internal"
> +   implementation symbol, but it is part of the public exported ABI.  Also,
> +   it's among the symbols that the static libpthread.a always links in
> +   whenever pthread_create is used, so there is no danger of a false
> +   negative result in any statically-linked, multi-threaded program.
> +
> +   For others, we choose pthread_cancel as a function that seems unlikely
> +   to be redefined by an interceptor library.  The bionic (Android) C
> +   library does not provide pthread_cancel, so we do use pthread_create
> +   there (and interceptor libraries lose).  */
> +
> +#ifdef __GLIBC__
> +__gthrw2(__gthrw_(__pthread_key_create),
> +	 __pthread_key_create,
> +	 pthread_key_create)
> +# define GTHR_ACTIVE_PROXY	__gthrw_(__pthread_key_create)
> +#elif defined (__BIONIC__)
> +# define GTHR_ACTIVE_PROXY	__gthrw_(pthread_create)
> +#else
> +# define GTHR_ACTIVE_PROXY	__gthrw_(pthread_cancel)
> +#endif
> +
> +static inline int
> +__gthread_active_p (void)
> +{
> +  static void *const __gthread_active_ptr
> +    = __extension__ (void *) &GTHR_ACTIVE_PROXY;
> +  return __gthread_active_ptr != 0;
> +}
> +
> +#endif /* FreeBSD or Solaris */
> +
> +#else /* not SUPPORTS_WEAK */
> +
> +/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
> +   calls in shared flavors of the HP-UX C library.  Most of the stubs
> +   have no functionality.  The details are described in the "libc cumulative
> +   patch" for each subversion of HP-UX 11.  There are two special interfaces
> +   provided for checking whether an application is linked to a shared pthread
> +   library or not.  However, these interfaces aren't available in early
> +   libpthread libraries.  We also need a test that works for archive
> +   libraries.  We can't use pthread_once as some libc versions call the
> +   init function.  We also can't use pthread_create or pthread_attr_init
> +   as these create a thread and thereby prevent changing the default stack
> +   size.  The function pthread_default_stacksize_np is available in both
> +   the archive and shared versions of libpthread.   It can be used to
> +   determine the default pthread stack size.  There is a stub in some
> +   shared libc versions which returns a zero size if pthreads are not
> +   active.  We provide an equivalent stub to handle cases where libc
> +   doesn't provide one.  */
> +
> +#if defined(__hppa__) && defined(__hpux__)
> +
> +static volatile int __gthread_active = -1;
> +
> +static inline int
> +__gthread_active_p (void)
> +{
> +  /* Avoid reading __gthread_active twice on the main code path.  */
> +  int __gthread_active_latest_value = __gthread_active;
> +  size_t __s;
> +
> +  if (__builtin_expect (__gthread_active_latest_value < 0, 0))
> +    {
> +      pthread_default_stacksize_np (0, &__s);
> +      __gthread_active = __s ? 1 : 0;
> +      __gthread_active_latest_value = __gthread_active;
> +    }
> +
> +  return __gthread_active_latest_value != 0;
> +}
> +
> +#else /* not hppa-hpux */
> +
> +static inline int
> +__gthread_active_p (void)
> +{
> +  return 1;
> +}
> +
> +#endif /* hppa-hpux */
> +
> +#endif /* SUPPORTS_WEAK */
> +
> +#ifdef _LIBOBJC
> +
> +/* This is the config.h file in libobjc/ */
> +#include <config.h>
> +
> +#ifdef HAVE_SCHED_H
> +# include <sched.h>
> +#endif
> +
> +/* Key structure for maintaining thread specific storage */
> +static pthread_key_t _objc_thread_storage;
> +static pthread_attr_t _objc_thread_attribs;
> +
> +/* Thread local storage for a single thread */
> +static void *thread_local_storage = NULL;
> +
> +/* Backend initialization functions */
> +
> +/* Initialize the threads subsystem.  */
> +static inline int
> +__gthread_objc_init_thread_system (void)
> +{
> +  if (__gthread_active_p ())
> +    {
> +      /* Initialize the thread storage key.  */
> +      if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
> +	{
> +	  /* The normal default detach state for threads is
> +	   * PTHREAD_CREATE_JOINABLE which causes threads to not die
> +	   * when you think they should.  */
> +	  if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
> +	      && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
> +					      PTHREAD_CREATE_DETACHED) == 0)
> +	    return 0;
> +	}
> +    }
> +
> +  return -1;
> +}
> +
> +/* Close the threads subsystem.  */
> +static inline int
> +__gthread_objc_close_thread_system (void)
> +{
> +  if (__gthread_active_p ()
> +      && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
> +      && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
> +    return 0;
> +
> +  return -1;
> +}
> +
> +/* Backend thread functions */
> +
> +/* Create a new thread of execution.  */
> +static inline objc_thread_t
> +__gthread_objc_thread_detach (void (*func)(void *), void *arg)
> +{
> +  objc_thread_t thread_id;
> +  pthread_t new_thread_handle;
> +
> +  if (!__gthread_active_p ())
> +    return NULL;
> +
> +  if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
> +				  (void *) func, arg)))
> +    thread_id = (objc_thread_t) new_thread_handle;
> +  else
> +    thread_id = NULL;
> +
> +  return thread_id;
> +}
> +
> +/* Set the current thread's priority.  */
> +static inline int
> +__gthread_objc_thread_set_priority (int priority)
> +{
> +  if (!__gthread_active_p ())
> +    return -1;
> +  else
> +    {
> +#ifdef _POSIX_PRIORITY_SCHEDULING
> +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
> +      pthread_t thread_id = __gthrw_(pthread_self) ();
> +      int policy;
> +      struct sched_param params;
> +      int priority_min, priority_max;
> +
> +      if (__gthrw_(pthread_getschedparam) (thread_id, &policy, &params) == 0)
> +	{
> +	  if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
> +	    return -1;
> +
> +	  if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
> +	    return -1;
> +
> +	  if (priority > priority_max)
> +	    priority = priority_max;
> +	  else if (priority < priority_min)
> +	    priority = priority_min;
> +	  params.sched_priority = priority;
> +
> +	  /*
> +	   * The solaris 7 and several other man pages incorrectly state that
> +	   * this should be a pointer to policy but pthread.h is universally
> +	   * at odds with this.
> +	   */
> +	  if (__gthrw_(pthread_setschedparam) (thread_id, policy, &params) == 0)
> +	    return 0;
> +	}
> +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
> +#endif /* _POSIX_PRIORITY_SCHEDULING */
> +      return -1;
> +    }
> +}
> +
> +/* Return the current thread's priority.  */
> +static inline int
> +__gthread_objc_thread_get_priority (void)
> +{
> +#ifdef _POSIX_PRIORITY_SCHEDULING
> +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
> +  if (__gthread_active_p ())
> +    {
> +      int policy;
> +      struct sched_param params;
> +
> +      if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, &params) == 0)
> +	return params.sched_priority;
> +      else
> +	return -1;
> +    }
> +  else
> +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
> +#endif /* _POSIX_PRIORITY_SCHEDULING */
> +    return OBJC_THREAD_INTERACTIVE_PRIORITY;
> +}
> +
> +/* Yield our process time to another thread.  */
> +static inline void
> +__gthread_objc_thread_yield (void)
> +{
> +  if (__gthread_active_p ())
> +    __gthrw_(sched_yield) ();
> +}
> +
> +/* Terminate the current thread.  */
> +static inline int
> +__gthread_objc_thread_exit (void)
> +{
> +  if (__gthread_active_p ())
> +    /* exit the thread */
> +    __gthrw_(pthread_exit) (&__objc_thread_exit_status);
> +
> +  /* Failed if we reached here */
> +  return -1;
> +}
> +
> +/* Returns an integer value which uniquely describes a thread.  */
> +static inline objc_thread_t
> +__gthread_objc_thread_id (void)
> +{
> +  if (__gthread_active_p ())
> +    return (objc_thread_t) __gthrw_(pthread_self) ();
> +  else
> +    return (objc_thread_t) 1;
> +}
> +
> +/* Sets the thread's local storage pointer.  */
> +static inline int
> +__gthread_objc_thread_set_data (void *value)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
> +  else
> +    {
> +      thread_local_storage = value;
> +      return 0;
> +    }
> +}
> +
> +/* Returns the thread's local storage pointer.  */
> +static inline void *
> +__gthread_objc_thread_get_data (void)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_getspecific) (_objc_thread_storage);
> +  else
> +    return thread_local_storage;
> +}
> +
> +/* Backend mutex functions */
> +
> +/* Allocate a mutex.  */
> +static inline int
> +__gthread_objc_mutex_allocate (objc_mutex_t mutex)
> +{
> +  if (__gthread_active_p ())
> +    {
> +      mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
> +
> +      if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
> +	{
> +	  objc_free (mutex->backend);
> +	  mutex->backend = NULL;
> +	  return -1;
> +	}
> +    }
> +
> +  return 0;
> +}
> +
> +/* Deallocate a mutex.  */
> +static inline int
> +__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
> +{
> +  if (__gthread_active_p ())
> +    {
> +      int count;
> +
> +      /*
> +       * Posix Threads specifically require that the thread be unlocked
> +       * for __gthrw_(pthread_mutex_destroy) to work.
> +       */
> +
> +      do
> +	{
> +	  count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
> +	  if (count < 0)
> +	    return -1;
> +	}
> +      while (count);
> +
> +      if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
> +	return -1;
> +
> +      objc_free (mutex->backend);
> +      mutex->backend = NULL;
> +    }
> +  return 0;
> +}
> +
> +/* Grab a lock on a mutex.  */
> +static inline int
> +__gthread_objc_mutex_lock (objc_mutex_t mutex)
> +{
> +  if (__gthread_active_p ()
> +      && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
> +    {
> +      return -1;
> +    }
> +
> +  return 0;
> +}
> +
> +/* Try to grab a lock on a mutex.  */
> +static inline int
> +__gthread_objc_mutex_trylock (objc_mutex_t mutex)
> +{
> +  if (__gthread_active_p ()
> +      && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
> +    {
> +      return -1;
> +    }
> +
> +  return 0;
> +}
> +
> +/* Unlock the mutex */
> +static inline int
> +__gthread_objc_mutex_unlock (objc_mutex_t mutex)
> +{
> +  if (__gthread_active_p ()
> +      && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
> +    {
> +      return -1;
> +    }
> +
> +  return 0;
> +}
> +
> +/* Backend condition mutex functions */
> +
> +/* Allocate a condition.  */
> +static inline int
> +__gthread_objc_condition_allocate (objc_condition_t condition)
> +{
> +  if (__gthread_active_p ())
> +    {
> +      condition->backend = objc_malloc (sizeof (pthread_cond_t));
> +
> +      if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
> +	{
> +	  objc_free (condition->backend);
> +	  condition->backend = NULL;
> +	  return -1;
> +	}
> +    }
> +
> +  return 0;
> +}
> +
> +/* Deallocate a condition.  */
> +static inline int
> +__gthread_objc_condition_deallocate (objc_condition_t condition)
> +{
> +  if (__gthread_active_p ())
> +    {
> +      if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
> +	return -1;
> +
> +      objc_free (condition->backend);
> +      condition->backend = NULL;
> +    }
> +  return 0;
> +}
> +
> +/* Wait on the condition */
> +static inline int
> +__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
> +			      (pthread_mutex_t *) mutex->backend);
> +  else
> +    return 0;
> +}
> +
> +/* Wake up all threads waiting on this condition.  */
> +static inline int
> +__gthread_objc_condition_broadcast (objc_condition_t condition)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
> +  else
> +    return 0;
> +}
> +
> +/* Wake up one thread waiting on this condition.  */
> +static inline int
> +__gthread_objc_condition_signal (objc_condition_t condition)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
> +  else
> +    return 0;
> +}
> +
> +#else /* _LIBOBJC */
> +
> +static inline int
> +__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
> +		  void *__args)
> +{
> +  return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
> +}
> +
> +static inline int
> +__gthread_join (__gthread_t __threadid, void **__value_ptr)
> +{
> +  return __gthrw_(pthread_join) (__threadid, __value_ptr);
> +}
> +
> +static inline int
> +__gthread_detach (__gthread_t __threadid)
> +{
> +  return __gthrw_(pthread_detach) (__threadid);
> +}
> +
> +static inline int
> +__gthread_equal (__gthread_t __t1, __gthread_t __t2)
> +{
> +  return __gthrw_(pthread_equal) (__t1, __t2);
> +}
> +
> +static inline __gthread_t
> +__gthread_self (void)
> +{
> +  return __gthrw_(pthread_self) ();
> +}
> +
> +static inline int
> +__gthread_yield (void)
> +{
> +  return __gthrw_(sched_yield) ();
> +}
> +
> +static inline int
> +__gthread_once (__gthread_once_t *__once, void (*__func) (void))
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_once) (__once, __func);
> +  else
> +    return -1;
> +}
> +
> +static inline int
> +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
> +{
> +  return __gthrw_(pthread_key_create) (__key, __dtor);
> +}
> +
> +static inline int
> +__gthread_key_delete (__gthread_key_t __key)
> +{
> +  return __gthrw_(pthread_key_delete) (__key);
> +}
> +
> +static inline void *
> +__gthread_getspecific (__gthread_key_t __key)
> +{
> +  return __gthrw_(pthread_getspecific) (__key);
> +}
> +
> +static inline int
> +__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
> +{
> +  return __gthrw_(pthread_setspecific) (__key, __ptr);
> +}
> +
> +static inline void
> +__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
> +{
> +  if (__gthread_active_p ())
> +    __gthrw_(pthread_mutex_init) (__mutex, NULL);
> +}
> +
> +static inline int
> +__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_mutex_destroy) (__mutex);
> +  else
> +    return 0;
> +}
> +
> +static inline int
> +__gthread_mutex_lock (__gthread_mutex_t *__mutex)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_mutex_lock) (__mutex);
> +  else
> +    return 0;
> +}
> +
> +static inline int
> +__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_mutex_trylock) (__mutex);
> +  else
> +    return 0;
> +}
> +
> +#if _GTHREAD_USE_MUTEX_TIMEDLOCK
> +static inline int
> +__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
> +			   const __gthread_time_t *__abs_timeout)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
> +  else
> +    return 0;
> +}
> +#endif
> +
> +static inline int
> +__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
> +{
> +  if (__gthread_active_p ())
> +    return __gthrw_(pthread_mutex_unlock) (__mutex);
> +  else
> +    return 0;
> +}
> +
> +#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
> +  || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
> +static inline int
> +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
> +{
> +  if (__gthread_active_p ())
> +    {
> +      pthread_mutexattr_t __attr;
> +      int __r;
> +
> +      __r = __gthrw_(pthread_mutexattr_init) (&__attr);
> +      if (!__r)
> +	__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
> +						   PTHREAD_MUTEX_RECURSIVE);
> +      if (!__r)
> +	__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
> +      if (!__r)
> +	__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
> +      return __r;
> +    }
> +  return 0;
> +}
> +#endif
> +
> +static inline int
> +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
> +{
> +  return __gthread_mutex_lock (__mutex);
> +}
> +
> +static inline int
> +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
> +{
> +  return __gthread_mutex_trylock (__mutex);
> +}
> +
> +#if _GTHREAD_USE_MUTEX_TIMEDLOCK
> +static inline int
> +__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
> +				     const __gthread_time_t *__abs_timeout)
> +{
> +  return __gthread_mutex_timedlock (__mutex, __abs_timeout);
> +}
> +#endif
> +
> +static inline int
> +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
> +{
> +  return __gthread_mutex_unlock (__mutex);
> +}
> +
> +static inline int
> +__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
> +{
> +  return __gthread_mutex_destroy (__mutex);
> +}
> +
> +#ifdef _GTHREAD_USE_COND_INIT_FUNC
> +static inline void
> +__gthread_cond_init_function (__gthread_cond_t *__cond)
> +{
> +  if (__gthread_active_p ())
> +    __gthrw_(pthread_cond_init) (__cond, NULL);
> +}
> +#endif
> +
> +static inline int
> +__gthread_cond_broadcast (__gthread_cond_t *__cond)
> +{
> +  return __gthrw_(pthread_cond_broadcast) (__cond);
> +}
> +
> +static inline int
> +__gthread_cond_signal (__gthread_cond_t *__cond)
> +{
> +  return __gthrw_(pthread_cond_signal) (__cond);
> +}
> +
> +static inline int
> +__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
> +{
> +  return __gthrw_(pthread_cond_wait) (__cond, __mutex);
> +}
> +
> +static inline int
> +__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
> +			  const __gthread_time_t *__abs_timeout)
> +{
> +  return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
> +}
> +
> +static inline int
> +__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
> +			       __gthread_recursive_mutex_t *__mutex)
> +{
> +  return __gthread_cond_wait (__cond, __mutex);
> +}
> +
> +static inline int
> +__gthread_cond_destroy (__gthread_cond_t* __cond)
> +{
> +  return __gthrw_(pthread_cond_destroy) (__cond);
> +}
> +
> +#endif /* _LIBOBJC */
> +
> +#endif /* ! GCC_GTHR_POSIX_H */
> diff --git a/libgcov/include/gthr.h b/libgcov/include/gthr.h
> new file mode 100644
> index 0000000..ed22dc9
> --- /dev/null
> +++ b/libgcov/include/gthr.h
> @@ -0,0 +1,154 @@
> +/* Threads compatibility routines for libgcc2.  */
> +/* Compile this one with gcc.  */
> +/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +Under Section 7 of GPL version 3, you are granted additional
> +permissions described in the GCC Runtime Library Exception, version
> +3.1, as published by the Free Software Foundation.
> +
> +You should have received a copy of the GNU General Public License and
> +a copy of the GCC Runtime Library Exception along with this program;
> +see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +<http://www.gnu.org/licenses/>.  */
> +
> +#ifndef GCC_GTHR_H
> +#define GCC_GTHR_H
> +
> +#ifndef HIDE_EXPORTS
> +#pragma GCC visibility push(default)
> +#endif
> +
> +/* If this file is compiled with threads support, it must
> +       #define __GTHREADS 1
> +   to indicate that threads support is present.  Also it has define
> +   function
> +     int __gthread_active_p ()
> +   that returns 1 if thread system is active, 0 if not.
> +
> +   The threads interface must define the following types:
> +     __gthread_key_t
> +     __gthread_once_t
> +     __gthread_mutex_t
> +     __gthread_recursive_mutex_t
> +
> +   The threads interface must define the following macros:
> +
> +     __GTHREAD_ONCE_INIT
> +     		to initialize __gthread_once_t
> +     __GTHREAD_MUTEX_INIT
> +     		to initialize __gthread_mutex_t to get a fast
> +		non-recursive mutex.
> +     __GTHREAD_MUTEX_INIT_FUNCTION
> +		to initialize __gthread_mutex_t to get a fast
> +		non-recursive mutex.
> +		Define this to a function which looks like this:
> +		  void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
> +     		Some systems can't initialize a mutex without a
> +		function call.  Don't define __GTHREAD_MUTEX_INIT in this case.
> +     __GTHREAD_RECURSIVE_MUTEX_INIT
> +     __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
> +     		as above, but for a recursive mutex.
> +
> +   The threads interface must define the following static functions:
> +
> +     int __gthread_once (__gthread_once_t *once, void (*func) ())
> +
> +     int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
> +     int __gthread_key_delete (__gthread_key_t key)
> +
> +     void *__gthread_getspecific (__gthread_key_t key)
> +     int __gthread_setspecific (__gthread_key_t key, const void *ptr)
> +
> +     int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
> +     int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
> +
> +     int __gthread_mutex_lock (__gthread_mutex_t *mutex);
> +     int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
> +     int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
> +
> +     int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
> +     int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
> +     int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
> +
> +   The following are supported in POSIX threads only. They are required to
> +   fix a deadlock in static initialization inside libsupc++. The header file
> +   gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
> +   features are supported.
> +
> +   Types:
> +     __gthread_cond_t
> +
> +   Macros:
> +     __GTHREAD_COND_INIT
> +     __GTHREAD_COND_INIT_FUNCTION
> +
> +   Interface:
> +     int __gthread_cond_broadcast (__gthread_cond_t *cond);
> +     int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
> +     int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
> +					__gthread_recursive_mutex_t *mutex);
> +
> +   All functions returning int should return zero on success or the error
> +   number.  If the operation is not supported, -1 is returned.
> +
> +   If the following are also defined, you should
> +     #define __GTHREADS_CXX0X 1
> +   to enable the c++0x thread library.
> +
> +   Types:
> +     __gthread_t
> +     __gthread_time_t
> +
> +   Interface:
> +     int __gthread_create (__gthread_t *thread, void *(*func) (void*),
> +                           void *args);
> +     int __gthread_join (__gthread_t thread, void **value_ptr);
> +     int __gthread_detach (__gthread_t thread);
> +     int __gthread_equal (__gthread_t t1, __gthread_t t2);
> +     __gthread_t __gthread_self (void);
> +     int __gthread_yield (void);
> +
> +     int __gthread_mutex_timedlock (__gthread_mutex_t *m,
> +                                    const __gthread_time_t *abs_timeout);
> +     int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
> +                                          const __gthread_time_t *abs_time);
> +
> +     int __gthread_cond_signal (__gthread_cond_t *cond);
> +     int __gthread_cond_timedwait (__gthread_cond_t *cond,
> +                                   __gthread_mutex_t *mutex,
> +                                   const __gthread_time_t *abs_timeout);
> +
> +*/
> +
> +#if SUPPORTS_WEAK
> +/* The pe-coff weak support isn't fully compatible to ELF's weak.
> +   For static libraries it might would work, but as we need to deal
> +   with shared versions too, we disable it for mingw-targets.  */
> +#ifdef __MINGW32__
> +#undef GTHREAD_USE_WEAK
> +#define GTHREAD_USE_WEAK 0
> +#endif
> +
> +#ifndef GTHREAD_USE_WEAK
> +#define GTHREAD_USE_WEAK 1
> +#endif
> +#endif
> +#include "gthr-default.h"
> +
> +#ifndef HIDE_EXPORTS
> +#pragma GCC visibility pop
> +#endif
> +
> +#endif /* ! GCC_GTHR_H */
> diff --git a/libgcov/include/hashtab.h b/libgcov/include/hashtab.h
> new file mode 100644
> index 0000000..b5682f8
> --- /dev/null
> +++ b/libgcov/include/hashtab.h
> @@ -0,0 +1,204 @@
> +/* An expandable hash tables datatype.  
> +   Copyright (C) 1999-2017 Free Software Foundation, Inc.
> +   Contributed by Vladimir Makarov (vmakarov@cygnus.com).
> +
> +This program is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 2 of the License, or
> +(at your option) any later version.
> +
> +This program is distributed in the hope that it will be useful,
> +but WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +GNU General Public License for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with this program; if not, write to the Free Software
> +Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
> +
> +/* This package implements basic hash table functionality.  It is possible
> +   to search for an entry, create an entry and destroy an entry.
> +
> +   Elements in the table are generic pointers.
> +
> +   The size of the table is not fixed; if the occupancy of the table
> +   grows too high the hash table will be expanded.
> +
> +   The abstract data implementation is based on generalized Algorithm D
> +   from Knuth's book "The art of computer programming".  Hash table is
> +   expanded by creation of new hash table and transferring elements from
> +   the old table to the new table.  */
> +
> +#ifndef __HASHTAB_H__
> +#define __HASHTAB_H__
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif /* __cplusplus */
> +
> +#include "ansidecl.h"
> +
> +/* The type for a hash code.  */
> +typedef unsigned int hashval_t;
> +
> +/* Callback function pointer types.  */
> +
> +/* Calculate hash of a table entry.  */
> +typedef hashval_t (*htab_hash) (const void *);
> +
> +/* Compare a table entry with a possible entry.  The entry already in
> +   the table always comes first, so the second element can be of a
> +   different type (but in this case htab_find and htab_find_slot
> +   cannot be used; instead the variants that accept a hash value
> +   must be used).  */
> +typedef int (*htab_eq) (const void *, const void *);
> +
> +/* Cleanup function called whenever a live element is removed from
> +   the hash table.  */
> +typedef void (*htab_del) (void *);
> +  
> +/* Function called by htab_traverse for each live element.  The first
> +   arg is the slot of the element (which can be passed to htab_clear_slot
> +   if desired), the second arg is the auxiliary pointer handed to
> +   htab_traverse.  Return 1 to continue scan, 0 to stop.  */
> +typedef int (*htab_trav) (void **, void *);
> +
> +/* Memory-allocation function, with the same functionality as calloc().
> +   Iff it returns NULL, the hash table implementation will pass an error
> +   code back to the user, so if your code doesn't handle errors,
> +   best if you use xcalloc instead.  */
> +typedef void *(*htab_alloc) (size_t, size_t);
> +
> +/* We also need a free() routine.  */
> +typedef void (*htab_free) (void *);
> +
> +/* Memory allocation and deallocation; variants which take an extra
> +   argument.  */
> +typedef void *(*htab_alloc_with_arg) (void *, size_t, size_t);
> +typedef void (*htab_free_with_arg) (void *, void *);
> +
> +/* This macro defines reserved value for empty table entry.  */
> +
> +#define HTAB_EMPTY_ENTRY    ((PTR) 0)
> +
> +/* This macro defines reserved value for table entry which contained
> +   a deleted element. */
> +
> +#define HTAB_DELETED_ENTRY  ((PTR) 1)
> +
> +/* Hash tables are of the following type.  The structure
> +   (implementation) of this type is not needed for using the hash
> +   tables.  All work with hash table should be executed only through
> +   functions mentioned below.  The size of this structure is subject to
> +   change.  */
> +
> +struct htab {
> +  /* Pointer to hash function.  */
> +  htab_hash hash_f;
> +
> +  /* Pointer to comparison function.  */
> +  htab_eq eq_f;
> +
> +  /* Pointer to cleanup function.  */
> +  htab_del del_f;
> +
> +  /* Table itself.  */
> +  void **entries;
> +
> +  /* Current size (in entries) of the hash table.  */
> +  size_t size;
> +
> +  /* Current number of elements including also deleted elements.  */
> +  size_t n_elements;
> +
> +  /* Current number of deleted elements in the table.  */
> +  size_t n_deleted;
> +
> +  /* The following member is used for debugging. Its value is number
> +     of all calls of `htab_find_slot' for the hash table. */
> +  unsigned int searches;
> +
> +  /* The following member is used for debugging.  Its value is number
> +     of collisions fixed for time of work with the hash table. */
> +  unsigned int collisions;
> +
> +  /* Pointers to allocate/free functions.  */
> +  htab_alloc alloc_f;
> +  htab_free free_f;
> +
> +  /* Alternate allocate/free functions, which take an extra argument.  */
> +  void *alloc_arg;
> +  htab_alloc_with_arg alloc_with_arg_f;
> +  htab_free_with_arg free_with_arg_f;
> +
> +  /* Current size (in entries) of the hash table, as an index into the
> +     table of primes.  */
> +  unsigned int size_prime_index;
> +};
> +
> +typedef struct htab *htab_t;
> +
> +/* An enum saying whether we insert into the hash table or not.  */
> +enum insert_option {NO_INSERT, INSERT};
> +
> +/* The prototypes of the package functions. */
> +
> +extern htab_t	htab_create_alloc  (size_t, htab_hash,
> +                                    htab_eq, htab_del,
> +                                    htab_alloc, htab_free);
> +
> +extern htab_t	htab_create_alloc_ex (size_t, htab_hash,
> +                                      htab_eq, htab_del,
> +                                      void *, htab_alloc_with_arg,
> +                                      htab_free_with_arg);
> +
> +extern htab_t  htab_create_typed_alloc (size_t, htab_hash, htab_eq, htab_del,
> +					htab_alloc, htab_alloc, htab_free);
> +
> +/* Backward-compatibility functions.  */
> +extern htab_t htab_create (size_t, htab_hash, htab_eq, htab_del);
> +extern htab_t htab_try_create (size_t, htab_hash, htab_eq, htab_del);
> +
> +extern void	htab_set_functions_ex (htab_t, htab_hash,
> +                                       htab_eq, htab_del,
> +                                       void *, htab_alloc_with_arg,
> +                                       htab_free_with_arg);
> +
> +extern void	htab_delete (htab_t);
> +extern void	htab_empty (htab_t);
> +
> +extern void *	htab_find (htab_t, const void *);
> +extern void **	htab_find_slot (htab_t, const void *, enum insert_option);
> +extern void *	htab_find_with_hash (htab_t, const void *, hashval_t);
> +extern void **	htab_find_slot_with_hash (htab_t, const void *,
> +					  hashval_t, enum insert_option);
> +extern void	htab_clear_slot	(htab_t, void **);
> +extern void	htab_remove_elt	(htab_t, void *);
> +extern void	htab_remove_elt_with_hash (htab_t, void *, hashval_t);
> +
> +extern void	htab_traverse (htab_t, htab_trav, void *);
> +extern void	htab_traverse_noresize (htab_t, htab_trav, void *);
> +
> +extern size_t	htab_size (htab_t);
> +extern size_t	htab_elements (htab_t);
> +extern double	htab_collisions	(htab_t);
> +
> +/* A hash function for pointers.  */
> +extern htab_hash htab_hash_pointer;
> +
> +/* An equality function for pointers.  */
> +extern htab_eq htab_eq_pointer;
> +
> +/* A hash function for null-terminated strings.  */
> +extern hashval_t htab_hash_string (const void *);
> +
> +/* An iterative hash function for arbitrary data.  */
> +extern hashval_t iterative_hash (const void *, size_t, hashval_t);
> +/* Shorthand for hashing something with an intrinsic size.  */
> +#define iterative_hash_object(OB,INIT) iterative_hash (&OB, sizeof (OB), INIT)
> +
> +#ifdef __cplusplus
> +}
> +#endif /* __cplusplus */
> +
> +#endif /* __HASHTAB_H */
> diff --git a/libgcov/include/libgcov.h b/libgcov/include/libgcov.h
> new file mode 100644
> index 0000000..eb5a914
> --- /dev/null
> +++ b/libgcov/include/libgcov.h
> @@ -0,0 +1,346 @@
> +/* Header file for libgcov-*.c.
> +   Copyright (C) 1996-2017 Free Software Foundation, Inc.
> +
> +   This file is part of GCC.
> +
> +   GCC is free software; you can redistribute it and/or modify it under
> +   the terms of the GNU General Public License as published by the Free
> +   Software Foundation; either version 3, or (at your option) any later
> +   version.
> +
> +   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +   WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +   for more details.
> +
> +   Under Section 7 of GPL version 3, you are granted additional
> +   permissions described in the GCC Runtime Library Exception, version
> +   3.1, as published by the Free Software Foundation.
> +
> +   You should have received a copy of the GNU General Public License and
> +   a copy of the GCC Runtime Library Exception along with this program;
> +   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#ifndef GCC_LIBGCOV_H
> +#define GCC_LIBGCOV_H
> +
> +/* work around the poisoned malloc/calloc in system.h.  */
> +#ifndef xmalloc
> +#define xmalloc malloc
> +#endif
> +#ifndef xcalloc
> +#define xcalloc calloc
> +#endif
> +
> +#ifndef IN_GCOV_TOOL
> +/* About the target.  */
> +/* This path will be used by libgcov runtime.  */
> +
> +#include "tconfig.h"
> +#include "auto-target.h"
> +#include "tsystem.h"
> +#include "coretypes.h"
> +#include "tm.h"
> +#include "libgcc_tm.h"
> +#include "gcov.h"
> +
> +#if __CHAR_BIT__ == 8
> +typedef unsigned gcov_unsigned_t __attribute__ ((mode (SI)));
> +typedef unsigned gcov_position_t __attribute__ ((mode (SI)));
> +#if LONG_LONG_TYPE_SIZE > 32
> +typedef signed gcov_type __attribute__ ((mode (DI)));
> +typedef unsigned gcov_type_unsigned __attribute__ ((mode (DI)));
> +#else
> +typedef signed gcov_type __attribute__ ((mode (SI)));
> +typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI)));
> +#endif
> +#else
> +#if __CHAR_BIT__ == 16
> +typedef unsigned gcov_unsigned_t __attribute__ ((mode (HI)));
> +typedef unsigned gcov_position_t __attribute__ ((mode (HI)));
> +#if LONG_LONG_TYPE_SIZE > 32
> +typedef signed gcov_type __attribute__ ((mode (SI)));
> +typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI)));
> +#else
> +typedef signed gcov_type __attribute__ ((mode (HI)));
> +typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI)));
> +#endif
> +#else
> +typedef unsigned gcov_unsigned_t __attribute__ ((mode (QI)));
> +typedef unsigned gcov_position_t __attribute__ ((mode (QI)));
> +#if LONG_LONG_TYPE_SIZE > 32
> +typedef signed gcov_type __attribute__ ((mode (HI)));
> +typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI)));
> +#else
> +typedef signed gcov_type __attribute__ ((mode (QI)));
> +typedef unsigned gcov_type_unsigned __attribute__ ((mode (QI)));
> +#endif
> +#endif
> +#endif
> +
> +#if defined (TARGET_POSIX_IO)
> +#define GCOV_LOCKED 1
> +#else
> +#define GCOV_LOCKED 0
> +#endif
> +
> +/* In libgcov we need these functions to be extern, so prefix them with
> +   __gcov.  In libgcov they must also be hidden so that the instance in
> +   the executable is not also used in a DSO.  */
> +#define gcov_var __gcov_var
> +#define gcov_open __gcov_open
> +#define gcov_close __gcov_close
> +#define gcov_write_tag_length __gcov_write_tag_length
> +#define gcov_position __gcov_position
> +#define gcov_seek __gcov_seek
> +#define gcov_rewrite __gcov_rewrite
> +#define gcov_is_error __gcov_is_error
> +#define gcov_write_unsigned __gcov_write_unsigned
> +#define gcov_write_counter __gcov_write_counter
> +#define gcov_write_summary __gcov_write_summary
> +#define gcov_read_unsigned __gcov_read_unsigned
> +#define gcov_read_counter __gcov_read_counter
> +#define gcov_read_summary __gcov_read_summary
> +#define gcov_sort_n_vals __gcov_sort_n_vals
> +
> +#else /* IN_GCOV_TOOL */
> +/* About the host.  */
> +/* This path will be compiled for the host and linked into
> +   gcov-tool binary.  */
> +
> +#include "config.h"
> +#include "system.h"
> +#include "coretypes.h"
> +#include "tm.h"
> +
> +typedef unsigned gcov_unsigned_t;
> +typedef unsigned gcov_position_t;
> +/* gcov_type is typedef'd elsewhere for the compiler */
> +#if defined (HOST_HAS_F_SETLKW)
> +#define GCOV_LOCKED 1
> +#else
> +#define GCOV_LOCKED 0
> +#endif
> +
> +/* Some Macros specific to gcov-tool.  */
> +
> +#define L_gcov 1
> +#define L_gcov_merge_add 1
> +#define L_gcov_merge_single 1
> +#define L_gcov_merge_ior 1
> +#define L_gcov_merge_time_profile 1
> +#define L_gcov_merge_icall_topn 1
> +
> +extern gcov_type gcov_read_counter_mem ();
> +extern unsigned gcov_get_merge_weight ();
> +extern struct gcov_info *gcov_list;
> +
> +#endif /* !IN_GCOV_TOOL */
> +
> +#if defined(inhibit_libc)
> +#define IN_LIBGCOV (-1)
> +#else
> +#define IN_LIBGCOV 1
> +#if defined(L_gcov)
> +#define GCOV_LINKAGE /* nothing */
> +#endif
> +#endif
> +
> +/* Poison these, so they don't accidentally slip in.  */
> +#pragma GCC poison gcov_write_string gcov_write_tag gcov_write_length
> +#pragma GCC poison gcov_time gcov_magic
> +
> +#ifdef HAVE_GAS_HIDDEN
> +#define ATTRIBUTE_HIDDEN  __attribute__ ((__visibility__ ("hidden")))
> +#else
> +#define ATTRIBUTE_HIDDEN
> +#endif
> +
> +#include "gcov-io.h"
> +
> +/* Structures embedded in coveraged program.  The structures generated
> +   by write_profile must match these.  */
> +
> +/* Information about counters for a single function.  */
> +struct gcov_ctr_info
> +{
> +  gcov_unsigned_t num;		/* number of counters.  */
> +  gcov_type *values;		/* their values.  */
> +};
> +
> +/* Information about a single function.  This uses the trailing array
> +   idiom. The number of counters is determined from the merge pointer
> +   array in gcov_info.  The key is used to detect which of a set of
> +   comdat functions was selected -- it points to the gcov_info object
> +   of the object file containing the selected comdat function.  */
> +
> +struct gcov_fn_info
> +{
> +  const struct gcov_info *key;		/* comdat key */
> +  gcov_unsigned_t ident;		/* unique ident of function */
> +  gcov_unsigned_t lineno_checksum;	/* function lineo_checksum */
> +  gcov_unsigned_t cfg_checksum;		/* function cfg checksum */
> +  struct gcov_ctr_info ctrs[1];		/* instrumented counters */
> +};
> +
> +/* Type of function used to merge counters.  */
> +typedef void (*gcov_merge_fn) (gcov_type *, gcov_unsigned_t);
> +
> +/* Information about a single object file.  */
> +struct gcov_info
> +{
> +  gcov_unsigned_t version;	/* expected version number */
> +  struct gcov_info *next;	/* link to next, used by libgcov */
> +
> +  gcov_unsigned_t stamp;	/* uniquifying time stamp */
> +  const char *filename;		/* output file name */
> +
> +  gcov_merge_fn merge[GCOV_COUNTERS];  /* merge functions (null for
> +					  unused) */
> +  
> +  unsigned n_functions;		/* number of functions */
> +
> +#ifndef IN_GCOV_TOOL
> +  const struct gcov_fn_info *const *functions; /* pointer to pointers
> +                                                  to function information  */
> +#else
> +  const struct gcov_fn_info **functions;
> +#endif /* !IN_GCOV_TOOL */
> +};
> +
> +/* Root of a program/shared-object state */
> +struct gcov_root
> +{
> +  struct gcov_info *list;
> +  unsigned dumped : 1;	/* counts have been dumped.  */
> +  unsigned run_counted : 1;  /* run has been accounted for.  */
> +  struct gcov_root *next;
> +  struct gcov_root *prev;
> +};
> +
> +extern struct gcov_root __gcov_root ATTRIBUTE_HIDDEN;
> +
> +struct gcov_master
> +{
> +  gcov_unsigned_t version;
> +  struct gcov_root *root;
> +};
> +  
> +/* Exactly one of these will be active in the process.  */
> +extern struct gcov_master __gcov_master;
> +
> +/* Dump a set of gcov objects.  */
> +extern void __gcov_dump_one (struct gcov_root *) ATTRIBUTE_HIDDEN;
> +
> +/* Register a new object file module.  */
> +extern void __gcov_init (struct gcov_info *) ATTRIBUTE_HIDDEN;
> +
> +/* GCOV exit function registered via a static destructor.  */
> +extern void __gcov_exit (void) ATTRIBUTE_HIDDEN;
> +
> +/* Function to reset all counters to 0.  Both externally visible (and
> +   overridable) and internal version.  */
> +extern void __gcov_reset_int (void) ATTRIBUTE_HIDDEN;
> +
> +/* User function to enable early write of profile information so far.  */
> +extern void __gcov_dump_int (void) ATTRIBUTE_HIDDEN;
> +
> +/* The merge function that just sums the counters.  */
> +extern void __gcov_merge_add (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
> +
> +/* The merge function to select the minimum valid counter value.  */
> +extern void __gcov_merge_time_profile (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
> +
> +/* The merge function to choose the most common value.  */
> +extern void __gcov_merge_single (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
> +
> +/* The merge function that just ors the counters together.  */
> +extern void __gcov_merge_ior (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
> +
> +/* The merge function is used for topn indirect call counters.  */
> +extern void __gcov_merge_icall_topn (gcov_type *, unsigned) ATTRIBUTE_HIDDEN;
> +
> +/* The profiler functions.  */
> +extern void __gcov_interval_profiler (gcov_type *, gcov_type, int, unsigned);
> +extern void __gcov_interval_profiler_atomic (gcov_type *, gcov_type, int,
> +					     unsigned);
> +extern void __gcov_pow2_profiler (gcov_type *, gcov_type);
> +extern void __gcov_pow2_profiler_atomic (gcov_type *, gcov_type);
> +extern void __gcov_one_value_profiler (gcov_type *, gcov_type);
> +extern void __gcov_one_value_profiler_atomic (gcov_type *, gcov_type);
> +extern void __gcov_indirect_call_profiler_v2 (gcov_type, void *);
> +extern void __gcov_time_profiler (gcov_type *);
> +extern void __gcov_time_profiler_atomic (gcov_type *);
> +extern void __gcov_average_profiler (gcov_type *, gcov_type);
> +extern void __gcov_average_profiler_atomic (gcov_type *, gcov_type);
> +extern void __gcov_ior_profiler (gcov_type *, gcov_type);
> +extern void __gcov_ior_profiler_atomic (gcov_type *, gcov_type);
> +extern void __gcov_indirect_call_topn_profiler (gcov_type, void *);
> +extern void gcov_sort_n_vals (gcov_type *, int);
> +
> +#ifndef inhibit_libc
> +/* The wrappers around some library functions..  */
> +extern pid_t __gcov_fork (void) ATTRIBUTE_HIDDEN;
> +extern int __gcov_execl (const char *, char *, ...) ATTRIBUTE_HIDDEN;
> +extern int __gcov_execlp (const char *, char *, ...) ATTRIBUTE_HIDDEN;
> +extern int __gcov_execle (const char *, char *, ...) ATTRIBUTE_HIDDEN;
> +extern int __gcov_execv (const char *, char *const []) ATTRIBUTE_HIDDEN;
> +extern int __gcov_execvp (const char *, char *const []) ATTRIBUTE_HIDDEN;
> +extern int __gcov_execve (const char *, char  *const [], char *const [])
> +  ATTRIBUTE_HIDDEN;
> +
> +/* Functions that only available in libgcov.  */
> +GCOV_LINKAGE int gcov_open (const char */*name*/) ATTRIBUTE_HIDDEN;
> +GCOV_LINKAGE void gcov_write_counter (gcov_type) ATTRIBUTE_HIDDEN;
> +GCOV_LINKAGE void gcov_write_tag_length (gcov_unsigned_t, gcov_unsigned_t)
> +    ATTRIBUTE_HIDDEN;
> +GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/,
> +                                      const struct gcov_summary *)
> +    ATTRIBUTE_HIDDEN;
> +GCOV_LINKAGE void gcov_seek (gcov_position_t /*position*/) ATTRIBUTE_HIDDEN;
> +GCOV_LINKAGE void gcov_rewrite (void) ATTRIBUTE_HIDDEN;
> +
> +/* "Counts" stored in gcda files can be a real counter value, or
> +   an target address. When differentiate these two types because
> +   when manipulating counts, we should only change real counter values,
> +   rather target addresses.  */
> +
> +static inline gcov_type
> +gcov_get_counter (void)
> +{
> +#ifndef IN_GCOV_TOOL
> +  /* This version is for reading count values in libgcov runtime:
> +     we read from gcda files.  */
> +
> +  return gcov_read_counter ();
> +#else
> +  /* This version is for gcov-tool. We read the value from memory and
> +     multiply it by the merge weight.  */
> +
> +  return gcov_read_counter_mem () * gcov_get_merge_weight ();
> +#endif
> +}
> +
> +/* Similar function as gcov_get_counter(), but handles target address
> +   counters.  */
> +
> +static inline gcov_type
> +gcov_get_counter_target (void)
> +{
> +#ifndef IN_GCOV_TOOL
> +  /* This version is for reading count target values in libgcov runtime:
> +     we read from gcda files.  */
> +
> +  return gcov_read_counter ();
> +#else
> +  /* This version is for gcov-tool.  We read the value from memory and we do NOT
> +     multiply it by the merge weight.  */
> +
> +  return gcov_read_counter_mem ();
> +#endif
> +}
> +
> +#endif /* !inhibit_libc */
> +
> +#endif /* GCC_LIBGCOV_H */
> diff --git a/libgcov/include/tsystem.h b/libgcov/include/tsystem.h
> new file mode 100644
> index 0000000..37c941b
> --- /dev/null
> +++ b/libgcov/include/tsystem.h
> @@ -0,0 +1,137 @@
> +/* Get common system includes and various definitions and declarations
> +   based on target macros.
> +   Copyright (C) 2000-2017 Free Software Foundation, Inc.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +Under Section 7 of GPL version 3, you are granted additional
> +permissions described in the GCC Runtime Library Exception, version
> +3.1, as published by the Free Software Foundation.
> +
> +You should have received a copy of the GNU General Public License and
> +a copy of the GCC Runtime Library Exception along with this program;
> +see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +<http://www.gnu.org/licenses/>.  */
> +
> +#ifndef GCC_TSYSTEM_H
> +#define GCC_TSYSTEM_H
> +
> +/* System headers (e.g. stdio.h, stdlib.h, unistd.h) sometimes
> +   indirectly include getopt.h.  Our -I flags will cause gcc's gnu
> +   getopt.h to be included, not the platform's copy.  In the default
> +   case, gnu getopt.h will provide us with a no-argument prototype
> +   which will generate -Wstrict-prototypes warnings.  None of the
> +   target files actually use getopt, so it is safe to tell gnu
> +   getopt.h we never need this prototype.  */
> +#ifndef HAVE_DECL_GETOPT
> +#define HAVE_DECL_GETOPT 1
> +#endif
> +
> +/* We want everything from the glibc headers.  */
> +#define _GNU_SOURCE 1
> +
> +/* GCC supplies these headers.  */
> +#include <stddef.h>
> +#include <float.h>
> +
> +#ifdef inhibit_libc
> +
> +#ifndef malloc
> +extern void *malloc (size_t);
> +#endif
> +
> +#ifndef free
> +extern void free (void *);
> +#endif
> +
> +#ifndef atexit
> +extern int atexit (void (*)(void));
> +#endif
> +
> +#ifndef abort
> +extern void abort (void) __attribute__ ((__noreturn__));
> +#endif
> +
> +#ifndef strlen
> +extern size_t strlen (const char *);
> +#endif
> +
> +#ifndef memcpy
> +extern void *memcpy (void *, const void *, size_t);
> +#endif
> +
> +#ifndef memset
> +extern void *memset (void *, int, size_t);
> +#endif
> +
> +#else /* ! inhibit_libc */
> +/* We disable this when inhibit_libc, so that gcc can still be built without
> +   needing header files first.  */
> +/* ??? This is not a good solution, since prototypes may be required in
> +   some cases for correct code.  */
> +
> +/* GCC supplies this header.  */
> +#include <stdarg.h>
> +
> +/* All systems have this header.  */
> +#include <stdio.h>
> +
> +/* All systems have this header.  */
> +#include <sys/types.h>
> +
> +/* All systems have this header.  */
> +#include <errno.h>
> +
> +#ifndef errno
> +extern int errno;
> +#endif
> +
> +/* If these system headers do not exist, fixincludes must create them.  */
> +#include <string.h>
> +#include <stdlib.h>
> +#include <unistd.h>
> +
> +/* GCC supplies this header.  */
> +#include <limits.h>
> +
> +/* If these system headers do not exist, fixincludes must create them.  */
> +#include <time.h>
> +
> +#endif /* inhibit_libc */
> +
> +/* Define a generic NULL if one hasn't already been defined.  */
> +#ifndef NULL
> +#define NULL 0
> +#endif
> +
> +/* GCC always provides __builtin_alloca(x).  */
> +#undef alloca
> +#define alloca(x) __builtin_alloca(x)
> +
> +#ifdef ENABLE_RUNTIME_CHECKING
> +#define gcc_assert(EXPR) ((void)(!(EXPR) ? abort (), 0 : 0))
> +#else
> +/* Include EXPR, so that unused variable warnings do not occur.  */
> +#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
> +#endif
> +/* Use gcc_unreachable() to mark unreachable locations (like an
> +   unreachable default case of a switch.  Do not use gcc_assert(0).  */
> +#define gcc_unreachable() (abort ())
> +
> +#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
> +#define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
> +
> +/* Filename handling macros.  */
> +#include "filenames.h"
> +
> +#endif /* ! GCC_TSYSTEM_H */
> diff --git a/libgcov/include/value-unwind.h b/libgcov/include/value-unwind.h
> new file mode 100644
> index 0000000..a4c32e0
> --- /dev/null
> +++ b/libgcov/include/value-unwind.h
> @@ -0,0 +1,25 @@
> +/* Store register values as _Unwind_Word type in DWARF2 EH unwind context.
> +   Copyright (C) 2011-2017 Free Software Foundation, Inc.
> +
> +   This file is part of GCC.
> +
> +   GCC is free software; you can redistribute it and/or modify it
> +   under the terms of the GNU General Public License as published
> +   by the Free Software Foundation; either version 3, or (at your
> +   option) any later version.
> +
> +   GCC is distributed in the hope that it will be useful, but WITHOUT
> +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> +   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
> +   License for more details.
> +
> +   You should have received a copy of the GNU General Public License and
> +   a copy of the GCC Runtime Library Exception along with this program;
> +   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +/* Define this macro if the target stores register values as _Unwind_Word
> +   type in unwind context.  Only enable it for x32.  */
> +#if defined __x86_64 && !defined __LP64__
> +# define REG_VALUE_IN_UNWIND_CONTEXT
> +#endif
> 


From minios-devel-bounces@lists.xenproject.org Fri May 22 17:27:57 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 22 May 2020 17:27: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 1jcBSc-0004fa-9l; Fri, 22 May 2020 17:27:54 +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=/xnb=7E=lancs.ac.uk=a.jung@srs-us1.protection.inumbo.net>)
 id 1jcBSa-0004fV-VP
 for minios-devel@lists.xen.org; Fri, 22 May 2020 17:27:52 +0000
X-Inumbo-ID: 8ef45598-9c51-11ea-ac01-12813bfff9fa
Received: from mh-is-0.lancs.ac.uk (unknown [148.88.65.128])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 8ef45598-9c51-11ea-ac01-12813bfff9fa;
 Fri, 22 May 2020 17:27:49 +0000 (UTC)
Received: from x4db6b5cf.dyn.telefonica.de ([77.182.181.207]
 helo=localhost.localdomain)
 by mh-is-0.lancs.ac.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128)
 (Exim 4.92.3) (envelope-from <a.jung@lancs.ac.uk>)
 id 1jcBSU-0003zT-0c; Fri, 22 May 2020 18:27:48 +0100
From: Alexander Jung <a.jung@lancs.ac.uk>
To: minios-devel@lists.xen.org
Subject: [UNIKRAFT/LIB-NGINX PATCH] Makefile.uk: Bump NGINX to v1.18.0
Date: Fri, 22 May 2020 19:27:01 +0200
Message-Id: <20200522172701.3568-1-a.jung@lancs.ac.uk>
X-Mailer: git-send-email 2.26.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: -1.0 (-)
X-Spam-Bar: -
X-Spam-Report: Spam detection software, running on the system
 "mh-is-0.lancs.ac.uk", has processed this message.
 The results are shown below. .
 Content analysis details:   (-1.0 points, 4.1 required) .
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Costin Lupu <costin.lupu@cs.pub.ro>,
 Alexander Jung <a.jung@lancs.ac.uk>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This commit:

 * increases the current version of NGINX;
 * sources the contents from GitHub;
 * tidies up the use of BASENAME in the patch method.

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
---
 Makefile.uk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile.uk b/Makefile.uk
index 812bdcd..813ca22 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -44,12 +44,12 @@ $(eval $(call addlib_s,libnginx,$(CONFIG_LIBNGINX)))
 ################################################################################
 # Sources
 ################################################################################
-LIBNGINX_VERSION = 1.15.6
+LIBNGINX_VERSION = 1.18.0
 LIBNGINX_BASENAME = nginx-$(LIBNGINX_VERSION)
-LIBNGINX_URL = http://nginx.org/download/$(LIBNGINX_BASENAME).tar.gz
+LIBNGINX_URL = https://github.com/nginx/nginx/archive/release-v$(LIBNGINX_VERSION).tar.gz
 LIBNGINX_PATCHDIR = $(LIBNGINX_BASE)/patches
 $(eval $(call fetch,libnginx,$(LIBNGINX_URL)))
-$(eval $(call patch,libnginx,$(LIBNGINX_PATCHDIR),nginx-$(LIBNGINX_VERSION)))
+$(eval $(call patch,libnginx,$(LIBNGINX_PATCHDIR),$(LIBNGINX_BASENAME)))
 
 ################################################################################
 # Helpers
-- 
2.11.0



From minios-devel-bounces@lists.xenproject.org Sun May 24 07:43:20 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 24 May 2020 07:43: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 1jclHv-0005jF-KQ; Sun, 24 May 2020 07:43: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=QdCD=7G=neclab.eu=hugo.lefeuvre@srs-us1.protection.inumbo.net>)
 id 1jclHt-0005jA-QB
 for minios-devel@lists.xen.org; Sun, 24 May 2020 07:43:13 +0000
X-Inumbo-ID: 376dd79e-9d92-11ea-b9cf-bc764e2007e4
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 376dd79e-9d92-11ea-b9cf-bc764e2007e4;
 Sun, 24 May 2020 07:43:11 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 64C8EF2004;
 Sun, 24 May 2020 09:43:10 +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 BT19lcfp4XsX; Sun, 24 May 2020 09:43:10 +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 1EC0BC024C;
 Sun, 24 May 2020 09:43:04 +0200 (CEST)
Received: from titania.office.hd (192.168.24.89) 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.1713.5; Sun, 24 May
 2020 09:43:03 +0200
Received: from titania.office.hd ([192.168.126.13]) by titania.office.hd
 ([192.168.126.13]) with mapi id 15.01.1713.009; Sun, 24 May 2020 09:43:03
 +0200
From: Hugo Lefeuvre <Hugo.Lefeuvre@neclab.eu>
To: Alexander Jung <a.jung@lancs.ac.uk>, "minios-devel@lists.xen.org"
 <minios-devel@lists.xen.org>
Subject: Re: [Minios-devel] [UNIKRAFT/PLAT-SOLO5] solo5: Fix ctortab start
 symbol name.
Thread-Topic: [Minios-devel] [UNIKRAFT/PLAT-SOLO5] solo5: Fix ctortab start
 symbol name.
Thread-Index: AQHV7j5zc9cBZWGWhEaGGCC7x/eCEKi3YRPO
Date: Sun, 24 May 2020 07:43:03 +0000
Message-ID: <c4df7fa01db04ce28c0af0142fd85813@neclab.eu>
References: <20200228135248.99124-1-a.jung@lancs.ac.uk>
In-Reply-To: <20200228135248.99124-1-a.jung@lancs.ac.uk>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [192.168.24.96]
Content-Type: multipart/alternative;
 boundary="_000_c4df7fa01db04ce28c0af0142fd85813neclabeu_"
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>
Cc: Felipe Huici <Felipe.Huici@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Haibo Xu <haibo.xu@arm.com>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

--_000_c4df7fa01db04ce28c0af0142fd85813neclabeu_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
________________________________
From: Minios-devel <minios-devel-bounces@lists.xenproject.org> on behalf of=
 Alexander Jung <a.jung@lancs.ac.uk>
Sent: Friday, February 28, 2020 2:52:48 PM
To: minios-devel@lists.xen.org
Cc: Felipe Huici; Simon Kuenzer; Haibo Xu; Alexander Jung
Subject: [Minios-devel] [UNIKRAFT/PLAT-SOLO5] solo5: Fix ctortab start symb=
ol name.

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
---
 link64.lds | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/link64.lds b/link64.lds
index 15a5cca..db1acbd 100644
--- a/link64.lds
+++ b/link64.lds
@@ -59,7 +59,7 @@ SECTIONS {
     __eh_frame_hdr_end =3D .;

     . =3D ALIGN(0x1000);
-    uk_ctortab =3D .;
+    uk_ctortab_start =3D .;
     .uk_ctortab :
     {
             KEEP(*(SORT_BY_NAME(.uk_ctortab[0-7])))
--
2.11.0


_______________________________________________
Minios-devel mailing list
Minios-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/minios-devel

--_000_c4df7fa01db04ce28c0af0142fd85813neclabeu_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div id=3D"divtagdefaultwrapper" style=3D"font-size:12pt;color:#000000;font=
-family:Calibri,Helvetica,sans-serif;" dir=3D"ltr">
<p><br>
</p>
<font size=3D"2"><span style=3D"font-size:10pt">Reviewed-by: Hugo Lefeuvre =
&lt;hugo.lefeuvre@neclab.eu&gt;</span></font><br>
<div dir=3D"ltr">
<hr tabindex=3D"-1" style=3D"display:inline-block; width:98%">
<div id=3D"x_divRplyFwdMsg" dir=3D"ltr"><font style=3D"font-size:11pt" face=
=3D"Calibri, sans-serif" color=3D"#000000"><b>From:</b> Minios-devel &lt;mi=
nios-devel-bounces@lists.xenproject.org&gt; on behalf of Alexander Jung &lt=
;a.jung@lancs.ac.uk&gt;<br>
<b>Sent:</b> Friday, February 28, 2020 2:52:48 PM<br>
<b>To:</b> minios-devel@lists.xen.org<br>
<b>Cc:</b> Felipe Huici; Simon Kuenzer; Haibo Xu; Alexander Jung<br>
<b>Subject:</b> [Minios-devel] [UNIKRAFT/PLAT-SOLO5] solo5: Fix ctortab sta=
rt symbol name.</font>
<div>&nbsp;</div>
</div>
</div>
<font size=3D"2"><span style=3D"font-size:10pt">
<div class=3D"PlainText">Signed-off-by: Alexander Jung &lt;a.jung@lancs.ac.=
uk&gt;<br>
---<br>
&nbsp;link64.lds | 2 &#43;-<br>
&nbsp;1 file changed, 1 insertion(&#43;), 1 deletion(-)<br>
<br>
diff --git a/link64.lds b/link64.lds<br>
index 15a5cca..db1acbd 100644<br>
--- a/link64.lds<br>
&#43;&#43;&#43; b/link64.lds<br>
@@ -59,7 &#43;59,7 @@ SECTIONS {<br>
&nbsp;&nbsp;&nbsp;&nbsp; __eh_frame_hdr_end =3D .;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; . =3D ALIGN(0x1000);<br>
-&nbsp;&nbsp;&nbsp; uk_ctortab =3D .;<br>
&#43;&nbsp;&nbsp;&nbsp; uk_ctortab_start =3D .;<br>
&nbsp;&nbsp;&nbsp;&nbsp; .uk_ctortab :<br>
&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; KE=
EP(*(SORT_BY_NAME(.uk_ctortab[0-7])))<br>
--<br>
2.11.0<br>
<br>
<br>
_______________________________________________<br>
Minios-devel mailing list<br>
Minios-devel@lists.xenproject.org<br>
<a href=3D"https://lists.xenproject.org/mailman/listinfo/minios-devel" id=
=3D"LPlnk165379" previewremoved=3D"true">https://lists.xenproject.org/mailm=
an/listinfo/minios-devel</a></div>
</span></font></div>
</body>
</html>

--_000_c4df7fa01db04ce28c0af0142fd85813neclabeu_--


From minios-devel-bounces@lists.xenproject.org Sun May 24 15:10:34 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 24 May 2020 15:10: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 1jcsGk-0002Bs-IY; Sun, 24 May 2020 15:10: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=/k04=7G=gmail.com=alicesuiu17@srs-us1.protection.inumbo.net>)
 id 1jcsGj-0002Bl-0A
 for minios-devel@lists.xen.org; Sun, 24 May 2020 15:10:29 +0000
X-Inumbo-ID: b02c2e4a-9dd0-11ea-b07b-bc764e2007e4
Received: from mail-ed1-x52c.google.com (unknown [2a00:1450:4864:20::52c])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id b02c2e4a-9dd0-11ea-b07b-bc764e2007e4;
 Sun, 24 May 2020 15:10:22 +0000 (UTC)
Received: by mail-ed1-x52c.google.com with SMTP id f13so12473713edr.13
 for <minios-devel@lists.xen.org>; Sun, 24 May 2020 08:10:22 -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=BkcZ+cBN2zJ980OkAuDx9NGhCvGe8rjOCPulJF6XTHs=;
 b=PXoP9+C7HSn2T2vPQLIzCOxIpcahQ00JjjrTCOkotOuju1LqskREGI5IOaVE3SM7IY
 c0HySm/YzsJQ2lILkQGpyLpRaGILOP/BzLvvlcsZ3jxsZImgV8kdpbRBhmV/OeVC3RCI
 uG6w5uKgqbO6lReH5mtwFvyd4tRmUI0Plsqj9MwxjWfAWmFo0oXSsaSaVK7G6Gs2kzTw
 QWmNueJUfB6iDzRuripdRT+6UVJj/Z0DoUs6xQeAAJfj3V5t4hfnatwRzJgryeDSAtOB
 DShxH+tsfEpG1NiyEeiNXglPICDscw02tajafStcqLLFlP+Ck1P7Bp6XmvYIfyz2uxfm
 aMhQ==
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=BkcZ+cBN2zJ980OkAuDx9NGhCvGe8rjOCPulJF6XTHs=;
 b=Quu/hJ9cnJqBtiSyoZ1JtzyijsWLJebTsYVW61QCTNQnQ1kub65p1xT8BRkoEIroFg
 KvfQhC+Zgf62mqREkHOJBYoQg5VAkS6YhYeu+/BeUYlFxGzfCLMhcaa/3AqpnPWau+aU
 3dW9wxJpS1Cs7knnHLfyPdin0ojmUeV3AP33aLFKwhYHUIe9wJ3q+jZ+7VtuABU01Mhd
 C7qjgSsJd8HTNpJBj1NNYOhrsqoxtf/qUNWcwMxDQr3ZEVCWtYhaP/EmwXz/bA2fWwT6
 i3T2H9sZwikwisO2kGq5U855DABN6FocHzsekD9F9ysPTuuPgObhOy9ybdBuofNwsNh+
 ksXA==
X-Gm-Message-State: AOAM530DJShH0Tv5rjtpXoGLPCIp4nCzkN5x5QOmtF3eBcGNO+fFza3X
 J1jgxjKLup4bI0pHQLrnr5uM1n+PePs=
X-Google-Smtp-Source: ABdhPJz7LvGmHWkMuXd/pOS5gq4uVBhUSapS639NIYIA5xKn4ky3Zs/yrqGeaELOms4YNCdWv8jjHQ==
X-Received: by 2002:a50:d715:: with SMTP id t21mr11072947edi.194.1590333019394; 
 Sun, 24 May 2020 08:10:19 -0700 (PDT)
Received: from localhost.localdomain
 ([2a02:2f0c:790c:7c00:b019:1955:85b3:5b3e])
 by smtp.gmail.com with ESMTPSA id r9sm13485541edg.13.2020.05.24.08.10.17
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 24 May 2020 08:10:18 -0700 (PDT)
From: Alice Suiu <alicesuiu17@gmail.com>
To: minios-devel@lists.xen.org
Subject: [LIBGCC/LIBGCOV PATCH v2] Port libgcov library to add PGO
 (Profile-Guided Optimization) support to Unikraft.
Date: Sun, 24 May 2020 18:10:14 +0300
Message-Id: <20200524151014.5703-1-alicesuiu17@gmail.com>
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>
Cc: felipe.huici@neclab.eu, Alice Suiu <alicesuiu17@gmail.com>,
 costin.lupu@cs.pub.ro
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This port also adds generated headers which are located in include/ directory.
These headers were generated using configuration scripts from GCC sources.
Several libraries (newlib, pthread-embedded, compiler-rt, libunwind, libcxx and libcxxabi)
were needed in order to configure libgcov in Unikraft.

Signed-off-by: Alice Suiu <alicesuiu17@gmail.com>
---
 Config.uk                      |   11 +
 Makefile.uk                    |   22 +
 libgcov/include/auto-host.h    | 2419 ++++++++++++++++++++++++++++++++
 libgcov/include/auto-target.h  |   80 ++
 libgcov/include/gcov-iov.h     |    4 +
 libgcov/include/gthr-default.h |  889 ++++++++++++
 libgcov/include/libgcc_tm.h    |    6 +
 libgcov/include/tconfig.h      |   10 +
 libgcov/include/tm.h           |   52 +
 9 files changed, 3493 insertions(+)
 create mode 100644 libgcov/include/auto-host.h
 create mode 100644 libgcov/include/auto-target.h
 create mode 100644 libgcov/include/gcov-iov.h
 create mode 100644 libgcov/include/gthr-default.h
 create mode 100644 libgcov/include/libgcc_tm.h
 create mode 100644 libgcov/include/tconfig.h
 create mode 100644 libgcov/include/tm.h

diff --git a/Config.uk b/Config.uk
index 5aaca7c..111bdb2 100644
--- a/Config.uk
+++ b/Config.uk
@@ -26,4 +26,15 @@ config LIBFFI
 if LIBFFI
 endif
 
+config LIBGCOV
+       bool "libgcov - A Profiling Library"
+       default n
+       select LIBPTHREAD_EMBEDDED
+       select LIBCOMPILER_RT
+       select LIBCXX
+       select LIBCXXABI
+       select LIBUNWIND
+if LIBGCOV
+endif
+
 endif
diff --git a/Makefile.uk b/Makefile.uk
index d5901e2..435b098 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -42,6 +42,7 @@
 $(eval $(call addlib_s,libgcc,$(CONFIG_LIBGCC)))
 $(eval $(call addlib_s,libbacktrace,$(CONFIG_LIBBACKTRACE)))
 $(eval $(call addlib_s,libffi,$(CONFIG_LIBFFI)))
+$(eval $(call addlib_s,libgcov,$(CONFIG_LIBGCOV)))
 
 ################################################################################
 # Original sources
@@ -70,6 +71,9 @@ CXXINCLUDES-$(CONFIG_LIBBACKTRACE) += -I$(LIBGCC_BASE)/libbacktrace/include
 CINCLUDES-$(CONFIG_LIBFFI)   += -I$(LIBGCC_BASE)/libffi/include
 CXXINCLUDES-$(CONFIG_LIBFFI) += -I$(LIBGCC_BASE)/libffi/include
 
+CINCLUDES-$(CONFIG_LIBGCOV)   += -I$(LIBGCC_BASE)/libgcov/include
+CXXINCLUDES-$(CONFIG_LIBGCOV) += -I$(LIBGCC_BASE)/libgcov/include
+
 ################################################################################
 # libbacktrace code
 ################################################################################
@@ -119,3 +123,21 @@ LIBFFI_SRCS-y += $(LIBFFI_EXTRACTED)/src/raw_api.c
 LIBFFI_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBFFI_EXTRACTED)/src/x86/ffi64.c
 LIBFFI_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBFFI_EXTRACTED)/src/x86/unix64.S
 
+################################################################################
+# libgcov code
+################################################################################
+LIBGCOV_CINCLUDES-y = -I$(LIBGCC_BASE)/libgcov/include  -I$(LIBGCC_EXTRACTED)/include \
+		-I$(LIBGCC_EXTRACTED)/gcc -I$(LIBGCC_EXTRACTED)/libgcc
+
+LIBGCOV_CFLAGS-y += -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector \
+	-DHAVE_CC_TLS -DL_gcov_merge_add -DL_gcov_merge_single -DL_gcov_merge_ior -DL_gcov_merge_time_profile -DL_gcov_merge_icall_topn \
+	-DL_gcov_interval_profiler -DL_gcov_interval_profiler_atomic -DL_gcov_pow2_profiler -DL_gcov_pow2_profiler_atomic \
+	-DL_gcov_one_value_profiler -DL_gcov_one_value_profiler_atomic -DL_gcov_average_profiler -DL_gcov_average_profiler_atomic	\
+	-DL_gcov_ior_profiler -DL_gcov_ior_profiler_atomic -DL_gcov_indirect_call_profiler_v2 -DL_gcov_time_profiler \
+	-DL_gcov_indirect_call_topn_profiler -DL_gcov_dump -DL_gcov_flush -DL_gcov_fork -DL_gcov_execl -DL_gcov_execlp -DL_gcov_execle \
+	-DL_gcov_execv -DL_gcov_execvp -DL_gcov_execve -DL_gcov_reset -DL_gcov \
+
+LIBGCOV_SRCS-y += $(LIBGCC_EXTRACTED)/libgcc/libgcov-merge.c
+LIBGCOV_SRCS-y += $(LIBGCC_EXTRACTED)/libgcc/libgcov-profiler.c
+LIBGCOV_SRCS-y += $(LIBGCC_EXTRACTED)/libgcc/libgcov-interface.c
+LIBGCOV_SRCS-y += $(LIBGCC_EXTRACTED)/libgcc/libgcov-driver.c
diff --git a/libgcov/include/auto-host.h b/libgcov/include/auto-host.h
new file mode 100644
index 0000000..9b81bf2
--- /dev/null
+++ b/libgcov/include/auto-host.h
@@ -0,0 +1,2419 @@
+/* auto-host.h.  Generated from config.in by configure.  */
+/* config.in.  Generated from configure.ac by autoheader.  */
+
+/* Define if this compiler should be built as the offload target compiler. */
+#ifndef USED_FOR_TARGET
+/* #undef ACCEL_COMPILER */
+#endif
+
+
+/* Define if building universal (internal helper macro) */
+#ifndef USED_FOR_TARGET
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+#endif
+
+
+/* Define to the assembler option to enable compressed debug sections. */
+#ifndef USED_FOR_TARGET
+#define AS_COMPRESS_DEBUG_OPTION ""
+#endif
+
+
+/* Define to the assembler option to disable compressed debug sections. */
+#ifndef USED_FOR_TARGET
+#define AS_NO_COMPRESS_DEBUG_OPTION ""
+#endif
+
+
+/* Define as the number of bits in a byte, if `limits.h' doesn't. */
+#ifndef USED_FOR_TARGET
+/* #undef CHAR_BIT */
+#endif
+
+
+/* Define to 0/1 if you want more run-time sanity checks. This one gets a grab
+   bag of miscellaneous but relatively cheap checks. */
+#ifndef USED_FOR_TARGET
+#define CHECKING_P 0
+#endif
+
+
+/* Define 0/1 to force the choice for exception handling model. */
+#ifndef USED_FOR_TARGET
+/* #undef CONFIG_SJLJ_EXCEPTIONS */
+#endif
+
+
+/* Define to enable the use of a default assembler. */
+#ifndef USED_FOR_TARGET
+/* #undef DEFAULT_ASSEMBLER */
+#endif
+
+
+/* Define to enable the use of a default linker. */
+#ifndef USED_FOR_TARGET
+/* #undef DEFAULT_LINKER */
+#endif
+
+
+/* Define if you want to use __cxa_atexit, rather than atexit, to register C++
+   destructors for local statics and global objects. This is essential for
+   fully standards-compliant handling of destructors, but requires
+   __cxa_atexit in libc. */
+#ifndef USED_FOR_TARGET
+#define DEFAULT_USE_CXA_ATEXIT 2
+#endif
+
+
+/* The default for -fdiagnostics-color option */
+#ifndef USED_FOR_TARGET
+#define DIAGNOSTICS_COLOR_DEFAULT DIAGNOSTICS_COLOR_AUTO
+#endif
+
+
+/* Define if you want assertions enabled. This is a cheap check. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_ASSERT_CHECKING 1
+#endif
+
+
+/* Define to 1 to specify that we are using the BID decimal floating point
+   format instead of DPD */
+#ifndef USED_FOR_TARGET
+#define ENABLE_DECIMAL_BID_FORMAT 1
+#endif
+
+
+/* Define to 1 to enable decimal float extension to C. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_DECIMAL_FLOAT 1
+#endif
+
+
+/* Define if your target supports default PIE and it is enabled. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_DEFAULT_PIE */
+#endif
+
+
+/* Define if your target supports default stack protector and it is enabled.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_DEFAULT_SSP */
+#endif
+
+
+/* Define if you want more run-time sanity checks for dataflow. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_DF_CHECKING */
+#endif
+
+
+/* Define to 0/1 if you want extra run-time checking that might affect code
+   generation. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_EXTRA_CHECKING 0
+#endif
+
+
+/* Define to 1 to enable fixed-point arithmetic extension to C. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_FIXED_POINT 0
+#endif
+
+
+/* Define if you want fold checked that it never destructs its argument. This
+   is quite expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_FOLD_CHECKING */
+#endif
+
+
+/* Define if you want the garbage collector to operate in maximally paranoid
+   mode, validating the entire heap and collecting garbage at every
+   opportunity. This is extremely expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_GC_ALWAYS_COLLECT */
+#endif
+
+
+/* Define if you want the garbage collector to do object poisoning and other
+   memory allocation checks. This is quite expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_GC_CHECKING */
+#endif
+
+
+/* Define if you want operations on GIMPLE (the basic data structure of the
+   high-level optimizers) to be checked for dynamic type safety at runtime.
+   This is moderately expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_GIMPLE_CHECKING */
+#endif
+
+
+/* Define this to enable support for generating HSAIL. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_HSA */
+#endif
+
+
+/* Define if gcc should always pass --build-id to linker. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_LD_BUILDID */
+#endif
+
+
+/* Define to 1 to enable libquadmath support */
+#ifndef USED_FOR_TARGET
+#define ENABLE_LIBQUADMATH_SUPPORT 1
+#endif
+
+
+/* Define to enable LTO support. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_LTO */
+#endif
+
+
+/* Define to 1 if translation of program messages to the user's native
+   language is requested. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_NLS */
+#endif
+
+
+/* Define this to enable support for offloading. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_OFFLOADING 0
+#endif
+
+
+/* Define to enable plugin support. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_PLUGIN 1
+#endif
+
+
+/* Define if you want all operations on RTL (the basic data structure of the
+   optimizer and back end) to be checked for dynamic type safety at runtime.
+   This is quite expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_RTL_CHECKING */
+#endif
+
+
+/* Define if you want RTL flag accesses to be checked against the RTL codes
+   that are supported for each access macro. This is relatively cheap. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_RTL_FLAG_CHECKING */
+#endif
+
+
+/* Define if you want runtime assertions enabled. This is a cheap check. */
+#define ENABLE_RUNTIME_CHECKING 1
+
+/* Define if you want all operations on trees (the basic data structure of the
+   front ends) to be checked for dynamic type safety at runtime. This is
+   moderately expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_TREE_CHECKING */
+#endif
+
+
+/* Define if you want all gimple types to be verified after gimplifiation.
+   This is cheap. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_TYPES_CHECKING */
+#endif
+
+
+/* Define to get calls to the valgrind runtime enabled. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_VALGRIND_ANNOTATIONS */
+#endif
+
+
+/* Define if you want to run subprograms and generated programs through
+   valgrind (a memory checker). This is extremely expensive. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_VALGRIND_CHECKING */
+#endif
+
+
+/* Define 0/1 if vtable verification feature is enabled. */
+#ifndef USED_FOR_TARGET
+#define ENABLE_VTABLE_VERIFY 0
+#endif
+
+
+/* Define to 1 if installation paths should be looked up in the Windows
+   Registry. Ignored on non-Windows hosts. */
+#ifndef USED_FOR_TARGET
+/* #undef ENABLE_WIN32_REGISTRY */
+#endif
+
+
+/* Define to the name of a file containing a list of extra machine modes for
+   this architecture. */
+#ifndef USED_FOR_TARGET
+#define EXTRA_MODES_FILE "config/i386/i386-modes.def"
+#endif
+
+
+/* Define to enable detailed memory allocation stats gathering. */
+#ifndef USED_FOR_TARGET
+#define GATHER_STATISTICS 0
+#endif
+
+
+/* Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>. */
+#ifndef USED_FOR_TARGET
+#define GWINSZ_IN_SYS_IOCTL 1
+#endif
+
+
+/* mcontext_t fields start with __ */
+#ifndef USED_FOR_TARGET
+/* #undef HAS_MCONTEXT_T_UNDERSCORES */
+#endif
+
+
+/* Define if your assembler supports architecture modifiers. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_ARCHITECTURE_MODIFIERS */
+#endif
+
+
+/* Define if your avr assembler supports --mlink-relax option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_AVR_MLINK_RELAX_OPTION */
+#endif
+
+
+/* Define if your avr assembler supports -mrmw option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_AVR_MRMW_OPTION */
+#endif
+
+
+/* Define if your assembler supports cmpb. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_CMPB */
+#endif
+
+
+/* Define to the level of your assembler's compressed debug section support.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_COMPRESS_DEBUG no
+#endif
+
+
+/* Define if your assembler supports the DCI/ICI instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DCI */
+#endif
+
+
+/* Define if your assembler supports the --debug-prefix-map option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DEBUG_PREFIX_MAP */
+#endif
+
+
+/* Define if your assembler supports DFP instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DFP */
+#endif
+
+
+/* Define if your assembler supports .module. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DOT_MODULE */
+#endif
+
+
+/* Define if your assembler supports DSPR1 mult. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DSPR1_MULT */
+#endif
+
+
+/* Define if your assembler supports .dtprelword. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DTPRELWORD */
+#endif
+
+
+/* Define if your assembler supports dwarf2 .file/.loc directives, and
+   preserves file table indices exactly as given. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_DWARF2_DEBUG_LINE */
+#endif
+
+
+/* Define if your assembler supports the R_PPC64_ENTRY relocation. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_ENTRY_MARKERS */
+#endif
+
+
+/* Define if your assembler supports explicit relocations. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_EXPLICIT_RELOCS */
+#endif
+
+
+/* Define if your assembler supports FMAF, HPC, and VIS 3.0 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_FMAF_HPC_VIS3 */
+#endif
+
+
+/* Define if your assembler supports fprnd. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_FPRND */
+#endif
+
+
+/* Define if your assembler supports the --gdwarf2 option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_GDWARF2_DEBUG_FLAG */
+#endif
+
+
+/* Define if your assembler supports .gnu_attribute. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_GNU_ATTRIBUTE */
+#endif
+
+
+/* Define true if the assembler supports '.long foo@GOTOFF'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_GOTOFF_IN_DATA 0
+#endif
+
+
+/* Define if your assembler supports the --gstabs option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_GSTABS_DEBUG_FLAG */
+#endif
+
+
+/* Define if your assembler supports the Sun syntax for cmov. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_CMOV_SUN_SYNTAX */
+#endif
+
+
+/* Define if your assembler supports the subtraction of symbols in different
+   sections. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_DIFF_SECT_DELTA */
+#endif
+
+
+/* Define if your assembler supports the ffreep mnemonic. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_FFREEP */
+#endif
+
+
+/* Define if your assembler uses fildq and fistq mnemonics. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_FILDQ */
+#endif
+
+
+/* Define if your assembler uses filds and fists mnemonics. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_FILDS */
+#endif
+
+
+/* Define 0/1 if your assembler and linker support @GOT. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_GOT32X 0
+#endif
+
+
+/* Define if your assembler supports HLE prefixes. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_HLE */
+#endif
+
+
+/* Define if your assembler supports interunit movq mnemonic. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_INTERUNIT_MOVQ 0
+#endif
+
+
+/* Define if your assembler supports the .quad directive. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_QUAD */
+#endif
+
+
+/* Define if the assembler supports 'rep <insn>, lock <insn>'. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_REP_LOCK_PREFIX */
+#endif
+
+
+/* Define if your assembler supports the sahf mnemonic in 64bit mode. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_SAHF */
+#endif
+
+
+/* Define if your assembler supports the swap suffix. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_SWAP */
+#endif
+
+
+/* Define if your assembler and linker support @tlsgdplt. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_TLSGDPLT */
+#endif
+
+
+/* Define to 1 if your assembler and linker support @tlsldm. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_TLSLDM 0
+#endif
+
+
+/* Define to 1 if your assembler and linker support @tlsldmplt. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_TLSLDMPLT 0
+#endif
+
+
+/* Define 0/1 if your assembler and linker support calling ___tls_get_addr via
+   GOT. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_IX86_TLS_GET_ADDR_GOT 0
+#endif
+
+
+/* Define if your assembler supports the 'ud2' mnemonic. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_IX86_UD2 */
+#endif
+
+
+/* Define if your assembler supports the lituse_jsrdirect relocation. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_JSRDIRECT_RELOCS */
+#endif
+
+
+/* Define if your assembler supports .sleb128 and .uleb128. */
+#ifndef USED_FOR_TARGET
+#define HAVE_AS_LEB128 0
+#endif
+
+
+/* Define if your assembler supports LEON instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_LEON */
+#endif
+
+
+/* Define if the assembler won't complain about a line such as # 0 "" 2. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_LINE_ZERO */
+#endif
+
+
+/* Define if your assembler supports ltoffx and ldxmov relocations. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_LTOFFX_LDXMOV_RELOCS */
+#endif
+
+
+/* Define if your assembler supports LWSYNC instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_LWSYNC */
+#endif
+
+
+/* Define if your assembler supports the -mabi option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MABI_OPTION */
+#endif
+
+
+/* Define if your assembler supports .machine and .machinemode. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MACHINE_MACHINEMODE */
+#endif
+
+
+/* Define if your assembler supports mfcr field. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MFCRF */
+#endif
+
+
+/* Define if your assembler supports mffgpr and mftgpr. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MFPGPR */
+#endif
+
+
+/* Define if your Mac OS X assembler supports the -mmacos-version-min option.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_MMACOSX_VERSION_MIN_OPTION */
+#endif
+
+
+/* Define if the assembler understands -mnan=. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_NAN */
+#endif
+
+
+/* Define if your assembler supports the -no-mul-bug-abort option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_NO_MUL_BUG_ABORT_OPTION */
+#endif
+
+
+/* Define if the assembler understands -mno-shared. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_NO_SHARED */
+#endif
+
+
+/* Define if your assembler supports offsetable %lo(). */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_OFFSETABLE_LO10 */
+#endif
+
+
+/* Define if your assembler supports popcntb field. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_POPCNTB */
+#endif
+
+
+/* Define if your assembler supports POPCNTD instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_POPCNTD */
+#endif
+
+
+/* Define if your assembler supports POWER8 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_POWER8 */
+#endif
+
+
+/* Define if your assembler supports POWER9 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_POWER9 */
+#endif
+
+
+/* Define if your assembler supports .ref */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_REF */
+#endif
+
+
+/* Define if your assembler supports .register. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
+#endif
+
+
+/* Define if your assembler supports R_PPC_REL16 relocs. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_REL16 */
+#endif
+
+
+/* Define if your assembler supports -relax option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_RELAX_OPTION */
+#endif
+
+
+/* Define if your assembler supports relocs needed by -fpic. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SMALL_PIC_RELOCS */
+#endif
+
+
+/* Define if your assembler supports SPARC4 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC4 */
+#endif
+
+
+/* Define if your assembler supports SPARC5 and VIS 4.0 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC5_VIS4 */
+#endif
+
+/* Define if your assembler supports SPARC6 instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC6 */
+#endif
+
+/* Define if your assembler and linker support GOTDATA_OP relocs. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC_GOTDATA_OP */
+#endif
+
+
+/* Define if your assembler and linker support unaligned PC relative relocs.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC_UA_PCREL */
+#endif
+
+
+/* Define if your assembler and linker support unaligned PC relative relocs
+   against hidden symbols. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_SPARC_UA_PCREL_HIDDEN */
+#endif
+
+
+/* Define if your assembler supports .stabs. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_STABS_DIRECTIVE */
+#endif
+
+
+/* Define if your assembler and linker support thread-local storage. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_TLS */
+#endif
+
+
+/* Define if your assembler supports arg info for __tls_get_addr. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_TLS_MARKERS */
+#endif
+
+
+/* Define if your assembler supports VSX instructions. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_VSX */
+#endif
+
+
+/* Define if your assembler supports -xbrace_comment option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_AS_XBRACE_COMMENT_OPTION */
+#endif
+
+
+/* Define to 1 if you have the `atoq' function. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_ATOQ */
+#endif
+
+
+/* Define to 1 if you have the `clearerr_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_CLEARERR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `clock' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_CLOCK 1
+#endif
+
+
+/* Define if <time.h> defines clock_t. */
+#ifndef USED_FOR_TARGET
+#define HAVE_CLOCK_T 1
+#endif
+
+
+/* Define 0/1 if your assembler and linker support COMDAT groups. */
+#ifndef USED_FOR_TARGET
+#define HAVE_COMDAT_GROUP 0
+#endif
+
+
+/* Define to 1 if we found a declaration for 'abort', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ABORT 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'asprintf', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ASPRINTF 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'atof', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ATOF 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'atol', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ATOL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'atoll', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ATOLL 1
+#endif
+
+
+/* Define to 1 if you have the declaration of `basename(const char*)', and to
+   0 if you don't. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_BASENAME 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'calloc', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_CALLOC 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'clearerr_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_CLEARERR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'clock', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_CLOCK 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'errno', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_ERRNO 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'feof_unlocked', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FEOF_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'ferror_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FERROR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fflush_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FFLUSH_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'ffs', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FFS 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fgetc_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FGETC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fgets_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FGETS_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fileno_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FILENO_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fprintf_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FPRINTF_UNLOCKED 0
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fputc_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FPUTC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fputs_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FPUTS_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fread_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FREAD_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'free', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FREE 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'fwrite_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_FWRITE_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getchar_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETCHAR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getcwd', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETCWD 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getc_unlocked', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getenv', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETENV 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getopt', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETOPT 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getpagesize', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETPAGESIZE 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getrlimit', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETRLIMIT 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getrusage', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETRUSAGE 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'getwd', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_GETWD 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'ldgetname', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_LDGETNAME 0
+#endif
+
+
+/* Define to 1 if we found a declaration for 'madvise', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_MADVISE 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'malloc', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_MALLOC 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'putchar_unlocked', otherwise
+   define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_PUTCHAR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'putc_unlocked', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_PUTC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'realloc', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_REALLOC 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'sbrk', otherwise define to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SBRK 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'setenv', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SETENV 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'setrlimit', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SETRLIMIT 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'sigaltstack', otherwise define
+   to 0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SIGALTSTACK 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'snprintf', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_SNPRINTF 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'stpcpy', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STPCPY 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strnlen', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRNLEN 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strsignal', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRSIGNAL 1
+#endif
+
+
+/* Define to 1 if you have the declaration of `strstr(const char*,const
+   char*)', and to 0 if you don't. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRSTR 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strtol', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRTOL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strtoll', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRTOLL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strtoul', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRTOUL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strtoull', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRTOULL 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'strverscmp', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_STRVERSCMP 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'times', otherwise define to 0.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_TIMES 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'unsetenv', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_UNSETENV 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'vasprintf', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_VASPRINTF 1
+#endif
+
+
+/* Define to 1 if we found a declaration for 'vsnprintf', otherwise define to
+   0. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DECL_VSNPRINTF 1
+#endif
+
+
+/* Define to 1 if you have the <direct.h> header file. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_DIRECT_H */
+#endif
+
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_DLFCN_H 1
+#endif
+
+
+/* Define to 1 if you have the <ext/hash_map> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_EXT_HASH_MAP 1
+#endif
+
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FCNTL_H 1
+#endif
+
+
+/* Define to 1 if you have the `feof_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FEOF_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `ferror_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FERROR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fflush_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FFLUSH_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fgetc_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FGETC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fgets_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FGETS_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fileno_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FILENO_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fork' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FORK 1
+#endif
+
+
+/* Define to 1 if you have the `fprintf_unlocked' function. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_FPRINTF_UNLOCKED */
+#endif
+
+
+/* Define to 1 if you have the `fputc_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FPUTC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fputs_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FPUTS_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `fread_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FREAD_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the <ftw.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FTW_H 1
+#endif
+
+
+/* Define to 1 if you have the `fwrite_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_FWRITE_UNLOCKED 1
+#endif
+
+
+/* Define if your assembler supports specifying the alignment of objects
+   allocated using the GAS .comm command. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_ALIGNED_COMM */
+#endif
+
+
+/* Define if your assembler supports .balign and .p2align. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_BALIGN_AND_P2ALIGN */
+#endif
+
+
+/* Define 0/1 if your assembler supports CFI directives. */
+#define HAVE_GAS_CFI_DIRECTIVE 0
+
+/* Define 0/1 if your assembler supports .cfi_personality. */
+#define HAVE_GAS_CFI_PERSONALITY_DIRECTIVE 0
+
+/* Define 0/1 if your assembler supports .cfi_sections. */
+#define HAVE_GAS_CFI_SECTIONS_DIRECTIVE 0
+
+/* Define if your assembler supports the .loc discriminator sub-directive. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_DISCRIMINATOR */
+#endif
+
+
+/* Define if your assembler supports @gnu_unique_object. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_GNU_UNIQUE_OBJECT */
+#endif
+
+
+/* Define if your assembler and linker support .hidden. */
+/* #undef HAVE_GAS_HIDDEN */
+
+/* Define if your assembler supports .lcomm with an alignment field. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_LCOMM_WITH_ALIGNMENT */
+#endif
+
+
+/* Define if your assembler supports .literal16. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_LITERAL16 */
+#endif
+
+
+/* Define if your assembler supports specifying the maximum number of bytes to
+   skip when using the GAS .p2align command. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_MAX_SKIP_P2ALIGN */
+#endif
+
+
+/* Define if your assembler supports the .set micromips directive */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_MICROMIPS */
+#endif
+
+
+/* Define if your assembler supports .nsubspa comdat option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_NSUBSPA_COMDAT */
+#endif
+
+
+/* Define if your assembler and linker support 32-bit section relative relocs
+   via '.secrel32 label'. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_PE_SECREL32_RELOC */
+#endif
+
+
+/* Define if your assembler supports specifying the section flag e. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GAS_SECTION_EXCLUDE 0
+#endif
+
+
+/* Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_GAS_SHF_MERGE 0
+#endif
+
+
+/* Define if your assembler supports .subsection and .subsection -1 starts
+   emitting at the beginning of your section. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_SUBSECTION_ORDERING */
+#endif
+
+
+/* Define if your assembler supports .weak. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_WEAK */
+#endif
+
+
+/* Define if your assembler supports .weakref. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GAS_WEAKREF */
+#endif
+
+
+/* Define to 1 if you have the `getchar_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETCHAR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `getc_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `getrlimit' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETRLIMIT 1
+#endif
+
+
+/* Define to 1 if you have the `getrusage' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETRUSAGE 1
+#endif
+
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GETTIMEOFDAY 1
+#endif
+
+
+/* Define to 1 if using GNU as. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GNU_AS 1
+#endif
+
+
+/* Define if your system supports gnu indirect functions. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GNU_INDIRECT_FUNCTION 1
+#endif
+
+
+/* Define to 1 if using GNU ld. */
+#ifndef USED_FOR_TARGET
+#define HAVE_GNU_LD 1
+#endif
+
+
+/* Define if the gold linker supports split stack and is available as a
+   non-default */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_GOLD_NON_DEFAULT_SPLIT_STACK */
+#endif
+
+
+/* Define if you have the iconv() function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_ICONV 1
+#endif
+
+
+/* Define to 1 if you have the <iconv.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_ICONV_H 1
+#endif
+
+
+/* Define 0/1 if .init_array/.fini_array sections are available and working.
+   */
+#ifndef USED_FOR_TARGET
+#define HAVE_INITFINI_ARRAY_SUPPORT 0
+#endif
+
+
+/* Define to 1 if the system has the type `intmax_t'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_INTMAX_T 1
+#endif
+
+
+/* Define to 1 if the system has the type `intptr_t'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_INTPTR_T 1
+#endif
+
+
+/* Define if you have a working <inttypes.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_INTTYPES_H 1
+#endif
+
+
+/* Define to 1 if you have the `kill' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_KILL 1
+#endif
+
+
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+#ifndef USED_FOR_TARGET
+#define HAVE_LANGINFO_CODESET 1
+#endif
+
+
+/* Define to 1 if you have the <langinfo.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LANGINFO_H 1
+#endif
+
+
+/* Define if your <locale.h> file defines LC_MESSAGES. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LC_MESSAGES 1
+#endif
+
+
+/* Define to 1 if you have the <ldfcn.h> header file. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LDFCN_H */
+#endif
+
+
+/* Define if your linker supports --as-needed/--no-as-needed or equivalent
+   options. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_AS_NEEDED */
+#endif
+
+
+/* Define if your linker supports -z bndplt */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_BNDPLT_SUPPORT */
+#endif
+
+
+/* Define if your linker supports --build-id. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_BUILDID */
+#endif
+
+
+/* Define if the linker supports clearing hardware capabilities via mapfile.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_CLEARCAP */
+#endif
+
+
+/* Define to the level of your linker's compressed debug section support. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LD_COMPRESS_DEBUG 0
+#endif
+
+
+/* Define if your linker supports --demangle option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_DEMANGLE */
+#endif
+
+
+/* Define 0/1 if your linker supports CIE v3 in .eh_frame. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LD_EH_FRAME_CIEV3 0
+#endif
+
+
+/* Define if your linker supports .eh_frame_hdr. */
+/* #undef HAVE_LD_EH_FRAME_HDR */
+
+/* Define if your linker supports garbage collection of sections in presence
+   of EH frames. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_EH_GC_SECTIONS */
+#endif
+
+
+/* Define if your linker has buggy garbage collection of sections support when
+   .text.startup.foo like sections are used. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_EH_GC_SECTIONS_BUG */
+#endif
+
+
+/* Define if your PowerPC64 linker supports a large TOC. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_LARGE_TOC */
+#endif
+
+
+/* Define if your PowerPC64 linker only needs function descriptor syms. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_NO_DOT_SYMS */
+#endif
+
+
+/* Define if your linker can relax absolute .eh_frame personality pointers
+   into PC-relative form. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_PERSONALITY_RELAXATION */
+#endif
+
+
+/* Define if your linker supports PIE option. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_PIE */
+#endif
+
+
+/* Define 0/1 if your linker supports -pie option with copy reloc. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LD_PIE_COPYRELOC 0
+#endif
+
+
+/* Define if your PowerPC linker has .gnu.attributes long double support. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE */
+#endif
+
+
+/* Define if your linker supports --push-state/--pop-state */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_PUSHPOPSTATE_SUPPORT */
+#endif
+
+
+/* Define if your linker links a mix of read-only and read-write sections into
+   a read-write section. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_RO_RW_SECTION_MIXING */
+#endif
+
+
+/* Define if your linker supports the *_sol2 emulations. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_SOL2_EMULATION */
+#endif
+
+
+/* Define if your linker supports -Bstatic/-Bdynamic or equivalent options. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_STATIC_DYNAMIC */
+#endif
+
+
+/* Define if your linker supports --sysroot. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_LD_SYSROOT */
+#endif
+
+
+/* Define to 1 if you have the <limits.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LIMITS_H 1
+#endif
+
+
+/* Define to 1 if you have the <locale.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LOCALE_H 1
+#endif
+
+
+/* Define to 1 if the system has the type `long long'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LONG_LONG 1
+#endif
+
+
+/* Define to 1 if the system has the type `long long int'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LONG_LONG_INT 1
+#endif
+
+
+/* Define to the level of your linker's plugin support. */
+#ifndef USED_FOR_TARGET
+#define HAVE_LTO_PLUGIN 0
+#endif
+
+
+/* Define to 1 if you have the `madvise' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MADVISE 1
+#endif
+
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MALLOC_H 1
+#endif
+
+
+/* Define to 1 if you have the `mbstowcs' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MBSTOWCS 1
+#endif
+
+
+/* Define if valgrind's memcheck.h header is installed. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_MEMCHECK_H */
+#endif
+
+
+/* Define to 1 if you have the <memory.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MEMORY_H 1
+#endif
+
+
+/* Define to 1 if you have the `mmap' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MMAP 1
+#endif
+
+
+/* Define if mmap with MAP_ANON(YMOUS) works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MMAP_ANON 1
+#endif
+
+
+/* Define if mmap of /dev/zero works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MMAP_DEV_ZERO 1
+#endif
+
+
+/* Define if read-only mmap of a plain file works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_MMAP_FILE 1
+#endif
+
+
+/* Define to 1 if you have the `nl_langinfo' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_NL_LANGINFO 1
+#endif
+
+
+/* Define to 1 if you have the `popen' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_POPEN 1
+#endif
+
+
+/* Define to 1 if you have the `putchar_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_PUTCHAR_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `putc_unlocked' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_PUTC_UNLOCKED 1
+#endif
+
+
+/* Define to 1 if you have the `setlocale' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SETLOCALE 1
+#endif
+
+
+/* Define to 1 if you have the `setrlimit' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SETRLIMIT 1
+#endif
+
+
+/* Define if the system-provided CRTs are present on Solaris. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_SOLARIS_CRTS */
+#endif
+
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STDDEF_H 1
+#endif
+
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STDINT_H 1
+#endif
+
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STDLIB_H 1
+#endif
+
+
+/* Define to 1 if you have the <strings.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STRINGS_H 1
+#endif
+
+
+/* Define to 1 if you have the <string.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STRING_H 1
+#endif
+
+
+/* Define to 1 if you have the `strsignal' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STRSIGNAL 1
+#endif
+
+
+/* Define if <sys/times.h> defines struct tms. */
+#ifndef USED_FOR_TARGET
+#define HAVE_STRUCT_TMS 1
+#endif
+
+
+/* Define if <utility> defines std::swap. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SWAP_IN_UTILITY 1
+#endif
+
+
+/* Define to 1 if you have the `sysconf' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYSCONF 1
+#endif
+
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_FILE_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_MMAN_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_PARAM_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_RESOURCE_H 1
+#endif
+
+
+/* Define if your target C library provides sys/sdt.h */
+/* #undef HAVE_SYS_SDT_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_STAT_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/times.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_TIMES_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_TIME_H 1
+#endif
+
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_TYPES_H 1
+#endif
+
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#ifndef USED_FOR_TARGET
+#define HAVE_SYS_WAIT_H 1
+#endif
+
+
+/* Define to 1 if you have the `times' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_TIMES 1
+#endif
+
+
+/* Define to 1 if you have the <time.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_TIME_H 1
+#endif
+
+
+/* Define to 1 if you have the <tr1/unordered_map> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_TR1_UNORDERED_MAP 1
+#endif
+
+
+/* Define to 1 if the system has the type `uintmax_t'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UINTMAX_T 1
+#endif
+
+
+/* Define to 1 if the system has the type `uintptr_t'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UINTPTR_T 1
+#endif
+
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UNISTD_H 1
+#endif
+
+
+/* Define to 1 if you have the <unordered_map> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UNORDERED_MAP 1
+#endif
+
+
+/* Define to 1 if the system has the type `unsigned long long int'. */
+#ifndef USED_FOR_TARGET
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+#endif
+
+
+/* Define if valgrind's valgrind/memcheck.h header is installed. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_VALGRIND_MEMCHECK_H */
+#endif
+
+
+/* Define to 1 if you have the `vfork' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_VFORK 1
+#endif
+
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_VFORK_H */
+#endif
+
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WCHAR_H 1
+#endif
+
+
+/* Define to 1 if you have the `wcswidth' function. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WCSWIDTH 1
+#endif
+
+
+/* Define to 1 if `fork' works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WORKING_FORK 1
+#endif
+
+
+/* Define this macro if mbstowcs does not crash when its first argument is
+   NULL. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WORKING_MBSTOWCS 1
+#endif
+
+
+/* Define to 1 if `vfork' works. */
+#ifndef USED_FOR_TARGET
+#define HAVE_WORKING_VFORK 1
+#endif
+
+
+/* Define if your assembler supports AIX debug frame section label reference.
+   */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_XCOFF_DWARF_EXTRAS */
+#endif
+
+
+/* Define if isl is in use. */
+#ifndef USED_FOR_TARGET
+/* #undef HAVE_isl */
+#endif
+
+
+/* Define if F_SETLKW supported by fcntl. */
+#ifndef USED_FOR_TARGET
+#define HOST_HAS_F_SETLKW 1
+#endif
+
+
+/* Define as const if the declaration of iconv() needs const. */
+#ifndef USED_FOR_TARGET
+#define ICONV_CONST 
+#endif
+
+
+/* Define if int64_t uses long as underlying type. */
+#ifndef USED_FOR_TARGET
+#define INT64_T_IS_LONG 1
+#endif
+
+
+/* Define to 1 if ld64 supports '-export_dynamic'. */
+#ifndef USED_FOR_TARGET
+/* #undef LD64_HAS_EXPORT_DYNAMIC */
+#endif
+
+
+/* Define to ld64 version. */
+#ifndef USED_FOR_TARGET
+/* #undef LD64_VERSION */
+#endif
+
+
+/* Define to the linker option to ignore unused dependencies. */
+#ifndef USED_FOR_TARGET
+/* #undef LD_AS_NEEDED_OPTION */
+#endif
+
+
+/* Define to the linker option to enable compressed debug sections. */
+#ifndef USED_FOR_TARGET
+#define LD_COMPRESS_DEBUG_OPTION ""
+#endif
+
+
+/* Define to the linker option to enable use of shared objects. */
+#ifndef USED_FOR_TARGET
+/* #undef LD_DYNAMIC_OPTION */
+#endif
+
+
+/* Define to the linker option to keep unused dependencies. */
+#ifndef USED_FOR_TARGET
+/* #undef LD_NO_AS_NEEDED_OPTION */
+#endif
+
+
+/* Define to the linker option to disable use of shared objects. */
+#ifndef USED_FOR_TARGET
+/* #undef LD_STATIC_OPTION */
+#endif
+
+
+/* The linker hash style */
+#ifndef USED_FOR_TARGET
+/* #undef LINKER_HASH_STYLE */
+#endif
+
+
+/* Define to the name of the LTO plugin DSO that must be passed to the
+   linker's -plugin=LIB option. */
+#ifndef USED_FOR_TARGET
+#define LTOPLUGINSONAME "liblto_plugin.so"
+#endif
+
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#ifndef USED_FOR_TARGET
+#define LT_OBJDIR ".libs/"
+#endif
+
+
+/* Define if host mkdir takes a single argument. */
+#ifndef USED_FOR_TARGET
+/* #undef MKDIR_TAKES_ONE_ARG */
+#endif
+
+
+/* Define to offload targets, separated by commas. */
+#ifndef USED_FOR_TARGET
+#define OFFLOAD_TARGETS ""
+#endif
+
+
+/* Define to the address where bug reports for this package should be sent. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_BUGREPORT ""
+#endif
+
+
+/* Define to the full name of this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_NAME ""
+#endif
+
+
+/* Define to the full name and version of this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_STRING ""
+#endif
+
+
+/* Define to the one symbol short name of this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_TARNAME ""
+#endif
+
+
+/* Define to the home page for this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_URL ""
+#endif
+
+
+/* Define to the version of this package. */
+#ifndef USED_FOR_TARGET
+#define PACKAGE_VERSION ""
+#endif
+
+
+/* Specify plugin linker */
+#ifndef USED_FOR_TARGET
+#define PLUGIN_LD_SUFFIX ""
+#endif
+
+
+/* Define to .TOC. alignment forced by your linker. */
+#ifndef USED_FOR_TARGET
+/* #undef POWERPC64_TOC_POINTER_ALIGNMENT */
+#endif
+
+
+/* Define to PREFIX/include if cpp should also search that directory. */
+#ifndef USED_FOR_TARGET
+/* #undef PREFIX_INCLUDE_DIR */
+#endif
+
+
+/* The size of `int', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_INT 4
+#endif
+
+
+/* The size of `long', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_LONG 8
+#endif
+
+
+/* The size of `long long', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_LONG_LONG 8
+#endif
+
+
+/* The size of `short', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_SHORT 2
+#endif
+
+
+/* The size of `void *', as computed by sizeof. */
+#ifndef USED_FOR_TARGET
+#define SIZEOF_VOID_P 8
+#endif
+
+
+/* Define to 1 if you have the ANSI C header files. */
+#ifndef USED_FOR_TARGET
+#define STDC_HEADERS 1
+#endif
+
+
+/* Define if you can safely include both <string.h> and <strings.h>. */
+#ifndef USED_FOR_TARGET
+#define STRING_WITH_STRINGS 1
+#endif
+
+
+/* Define if TFmode long double should be the default */
+#ifndef USED_FOR_TARGET
+/* #undef TARGET_DEFAULT_LONG_DOUBLE_128 */
+#endif
+
+
+/* Define if your target C library provides the `dl_iterate_phdr' function. */
+/* #undef TARGET_DL_ITERATE_PHDR */
+
+/* GNU C Library major version number used on the target, or 0. */
+#ifndef USED_FOR_TARGET
+#define TARGET_GLIBC_MAJOR 2
+#endif
+
+
+/* GNU C Library minor version number used on the target, or 0. */
+#ifndef USED_FOR_TARGET
+#define TARGET_GLIBC_MINOR 27
+#endif
+
+
+/* Define if your target C Library provides the AT_HWCAP value in the TCB */
+#ifndef USED_FOR_TARGET
+/* #undef TARGET_LIBC_PROVIDES_HWCAP_IN_TCB */
+#endif
+
+
+/* Define if your target C library provides stack protector support */
+#ifndef USED_FOR_TARGET
+#define TARGET_LIBC_PROVIDES_SSP 1
+#endif
+
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#ifndef USED_FOR_TARGET
+#define TIME_WITH_SYS_TIME 1
+#endif
+
+
+/* Define to the flag used to mark TLS sections if the default (`T') doesn't
+   work. */
+#ifndef USED_FOR_TARGET
+/* #undef TLS_SECTION_ASM_FLAG */
+#endif
+
+
+/* Define if your assembler mis-optimizes .eh_frame data. */
+#ifndef USED_FOR_TARGET
+/* #undef USE_AS_TRADITIONAL_FORMAT */
+#endif
+
+
+/* Define if you want to generate code by default that assumes that the Cygwin
+   DLL exports wrappers to support libstdc++ function replacement. */
+#ifndef USED_FOR_TARGET
+/* #undef USE_CYGWIN_LIBSTDCXX_WRAPPERS */
+#endif
+
+
+/* Define to 1 if the 'long long' type is wider than 'long' but still
+   efficiently supported by the host hardware. */
+#ifndef USED_FOR_TARGET
+/* #undef USE_LONG_LONG_FOR_WIDEST_FAST_INT */
+#endif
+
+
+/* Define if we should use leading underscore on 64 bit mingw targets */
+#ifndef USED_FOR_TARGET
+/* #undef USE_MINGW64_LEADING_UNDERSCORES */
+#endif
+
+
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+
+
+/* Define to be the last component of the Windows registry key under which to
+   look for installation paths. The full key used will be
+   HKEY_LOCAL_MACHINE/SOFTWARE/Free Software Foundation/{WIN32_REGISTRY_KEY}.
+   The default is the GCC version number. */
+#ifndef USED_FOR_TARGET
+/* #undef WIN32_REGISTRY_KEY */
+#endif
+
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* #  undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#ifndef USED_FOR_TARGET
+/* #undef _FILE_OFFSET_BITS */
+#endif
+
+
+/* Define for large files, on AIX-style hosts. */
+#ifndef USED_FOR_TARGET
+/* #undef _LARGE_FILES */
+#endif
+
+
+/* Define to 1 if on MINIX. */
+#ifndef USED_FOR_TARGET
+/* #undef _MINIX */
+#endif
+
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+#ifndef USED_FOR_TARGET
+/* #undef _POSIX_1_SOURCE */
+#endif
+
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#ifndef USED_FOR_TARGET
+/* #undef _POSIX_SOURCE */
+#endif
+
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#ifndef USED_FOR_TARGET
+/* #undef _UINT32_T */
+#endif
+
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#ifndef USED_FOR_TARGET
+/* #undef _UINT64_T */
+#endif
+
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#ifndef USED_FOR_TARGET
+/* #undef _UINT8_T */
+#endif
+
+
+/* Define to `char *' if <sys/types.h> does not define. */
+#ifndef USED_FOR_TARGET
+/* #undef caddr_t */
+#endif
+
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to the type of a signed integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef int16_t */
+#endif
+
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef int32_t */
+#endif
+
+
+/* Define to the type of a signed integer type of width exactly 64 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef int64_t */
+#endif
+
+
+/* Define to the type of a signed integer type of width exactly 8 bits if such
+   a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef int8_t */
+#endif
+
+
+/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
+   not define. */
+#ifndef USED_FOR_TARGET
+/* #undef intmax_t */
+#endif
+
+
+/* Define to the type of a signed integer type wide enough to hold a pointer,
+   if such a type exists, and if the system does not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef intptr_t */
+#endif
+
+
+/* Define to `int' if <sys/types.h> does not define. */
+#ifndef USED_FOR_TARGET
+/* #undef pid_t */
+#endif
+
+
+/* Define to `long' if <sys/resource.h> doesn't define. */
+#ifndef USED_FOR_TARGET
+/* #undef rlim_t */
+#endif
+
+
+/* Define to `int' if <sys/types.h> does not define. */
+#ifndef USED_FOR_TARGET
+/* #undef ssize_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uint16_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uint32_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uint64_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+   such a type exists and the standard includes do not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uint8_t */
+#endif
+
+
+/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
+   do not define. */
+#ifndef USED_FOR_TARGET
+/* #undef uintmax_t */
+#endif
+
+
+/* Define to the type of an unsigned integer type wide enough to hold a
+   pointer, if such a type exists, and if the system does not define it. */
+#ifndef USED_FOR_TARGET
+/* #undef uintptr_t */
+#endif
+
+
+/* Define as `fork' if `vfork' does not work. */
+#ifndef USED_FOR_TARGET
+/* #undef vfork */
+#endif
+
diff --git a/libgcov/include/auto-target.h b/libgcov/include/auto-target.h
new file mode 100644
index 0000000..1ab0d1b
--- /dev/null
+++ b/libgcov/include/auto-target.h
@@ -0,0 +1,80 @@
+/* auto-target.h.  Generated from config.in by configure.  */
+/* config.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if the target assembler supports thread-local storage. */
+/* #undef HAVE_CC_TLS */
+
+/* Define to 1 if you have the <ftw.h> header file. */
+#define HAVE_FTW_H 1
+
+/* Define if _Unwind_GetIPInfo is available. */
+#define HAVE_GETIPINFO 1
+
+/* Define if the compiler supports init priority. */
+#define HAVE_INIT_PRIORITY 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define if the system-provided CRTs are present on Solaris. */
+/* #undef HAVE_SOLARIS_CRTS */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "GNU C Runtime Library"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "GNU C Runtime Library 1.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libgcc"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.0"
+
+/* The size of `double', as computed by sizeof. */
+#define SIZEOF_DOUBLE 8
+
+/* The size of `long double', as computed by sizeof. */
+#define SIZEOF_LONG_DOUBLE 16
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if the target use emutls for thread-local storage. */
+/* #undef USE_EMUTLS */
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
diff --git a/libgcov/include/gcov-iov.h b/libgcov/include/gcov-iov.h
new file mode 100644
index 0000000..4f4f2f5
--- /dev/null
+++ b/libgcov/include/gcov-iov.h
@@ -0,0 +1,4 @@
+/* Generated automatically by the program `build/gcov-iov'
+   from `7.5.0 (7 5) and  (*)'.  */
+
+#define GCOV_VERSION ((gcov_unsigned_t)0x4137352a)  /* A75* */
diff --git a/libgcov/include/gthr-default.h b/libgcov/include/gthr-default.h
new file mode 100644
index 0000000..a54a32e
--- /dev/null
+++ b/libgcov/include/gthr-default.h
@@ -0,0 +1,889 @@
+/* Threads compatibility routines for libgcc2 and libobjc.  */
+/* Compile this one with gcc.  */
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_GTHR_POSIX_H
+#define GCC_GTHR_POSIX_H
+
+/* POSIX threads specific definitions.
+   Easy, since the interface is just one-to-one mapping.  */
+
+#define __GTHREADS 1
+#define __GTHREADS_CXX0X 1
+
+#include <pthread.h>
+
+#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
+     || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
+# include <unistd.h>
+# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
+#  define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
+# else
+#  define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
+# endif
+#endif
+
+typedef pthread_t __gthread_t;
+typedef pthread_key_t __gthread_key_t;
+typedef pthread_once_t __gthread_once_t;
+typedef pthread_mutex_t __gthread_mutex_t;
+typedef pthread_mutex_t __gthread_recursive_mutex_t;
+typedef pthread_cond_t __gthread_cond_t;
+typedef struct timespec __gthread_time_t;
+
+/* POSIX like conditional variables are supported.  Please look at comments
+   in gthr.h for details. */
+#define __GTHREAD_HAS_COND	1
+
+#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
+#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
+#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
+#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
+#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
+#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
+#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#else
+#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
+#endif
+#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
+#define __GTHREAD_TIME_INIT {0,0}
+
+#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
+# undef __GTHREAD_MUTEX_INIT
+#endif
+#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
+# undef __GTHREAD_RECURSIVE_MUTEX_INIT
+# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
+# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
+#endif
+#ifdef _GTHREAD_USE_COND_INIT_FUNC
+# undef __GTHREAD_COND_INIT
+# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
+#endif
+
+#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
+# ifndef __gthrw_pragma
+#  define __gthrw_pragma(pragma)
+# endif
+# define __gthrw2(name,name2,type) \
+  static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
+  __gthrw_pragma(weak type)
+# define __gthrw_(name) __gthrw_ ## name
+#else
+# define __gthrw2(name,name2,type)
+# define __gthrw_(name) name
+#endif
+
+/* Typically, __gthrw_foo is a weak reference to symbol foo.  */
+#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
+
+__gthrw(pthread_once)
+__gthrw(pthread_getspecific)
+__gthrw(pthread_setspecific)
+
+__gthrw(pthread_create)
+__gthrw(pthread_join)
+__gthrw(pthread_equal)
+__gthrw(pthread_self)
+__gthrw(pthread_detach)
+#ifndef __BIONIC__
+__gthrw(pthread_cancel)
+#endif
+__gthrw(sched_yield)
+
+__gthrw(pthread_mutex_lock)
+__gthrw(pthread_mutex_trylock)
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+__gthrw(pthread_mutex_timedlock)
+#endif
+__gthrw(pthread_mutex_unlock)
+__gthrw(pthread_mutex_init)
+__gthrw(pthread_mutex_destroy)
+
+__gthrw(pthread_cond_init)
+__gthrw(pthread_cond_broadcast)
+__gthrw(pthread_cond_signal)
+__gthrw(pthread_cond_wait)
+__gthrw(pthread_cond_timedwait)
+__gthrw(pthread_cond_destroy)
+
+__gthrw(pthread_key_create)
+__gthrw(pthread_key_delete)
+__gthrw(pthread_mutexattr_init)
+__gthrw(pthread_mutexattr_settype)
+__gthrw(pthread_mutexattr_destroy)
+
+
+#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
+/* Objective-C.  */
+__gthrw(pthread_exit)
+#ifdef _POSIX_PRIORITY_SCHEDULING
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+__gthrw(sched_get_priority_max)
+__gthrw(sched_get_priority_min)
+#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+__gthrw(pthread_attr_destroy)
+__gthrw(pthread_attr_init)
+__gthrw(pthread_attr_setdetachstate)
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+__gthrw(pthread_getschedparam)
+__gthrw(pthread_setschedparam)
+#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _LIBOBJC || _LIBOBJC_WEAK */
+
+#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
+
+/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
+   -pthreads is not specified.  The functions are dummies and most return an
+   error value.  However pthread_once returns 0 without invoking the routine
+   it is passed so we cannot pretend that the interface is active if -pthreads
+   is not specified.  On Solaris 2.5.1, the interface is not exposed at all so
+   we need to play the usual game with weak symbols.  On Solaris 10 and up, a
+   working interface is always exposed.  On FreeBSD 6 and later, libc also
+   exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
+   to 9 does.  FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
+   which means the alternate __gthread_active_p below cannot be used there.  */
+
+#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
+
+static volatile int __gthread_active = -1;
+
+static void
+__gthread_trigger (void)
+{
+  __gthread_active = 1;
+}
+
+static inline int
+__gthread_active_p (void)
+{
+  static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
+  static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
+
+  /* Avoid reading __gthread_active twice on the main code path.  */
+  int __gthread_active_latest_value = __gthread_active;
+
+  /* This test is not protected to avoid taking a lock on the main code
+     path so every update of __gthread_active in a threaded program must
+     be atomic with regard to the result of the test.  */
+  if (__builtin_expect (__gthread_active_latest_value < 0, 0))
+    {
+      if (__gthrw_(pthread_once))
+	{
+	  /* If this really is a threaded program, then we must ensure that
+	     __gthread_active has been set to 1 before exiting this block.  */
+	  __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
+	  __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
+	  __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
+	}
+
+      /* Make sure we'll never enter this block again.  */
+      if (__gthread_active < 0)
+	__gthread_active = 0;
+
+      __gthread_active_latest_value = __gthread_active;
+    }
+
+  return __gthread_active_latest_value != 0;
+}
+
+#else /* neither FreeBSD nor Solaris */
+
+/* For a program to be multi-threaded the only thing that it certainly must
+   be using is pthread_create.  However, there may be other libraries that
+   intercept pthread_create with their own definitions to wrap pthreads
+   functionality for some purpose.  In those cases, pthread_create being
+   defined might not necessarily mean that libpthread is actually linked
+   in.
+
+   For the GNU C library, we can use a known internal name.  This is always
+   available in the ABI, but no other library would define it.  That is
+   ideal, since any public pthread function might be intercepted just as
+   pthread_create might be.  __pthread_key_create is an "internal"
+   implementation symbol, but it is part of the public exported ABI.  Also,
+   it's among the symbols that the static libpthread.a always links in
+   whenever pthread_create is used, so there is no danger of a false
+   negative result in any statically-linked, multi-threaded program.
+
+   For others, we choose pthread_cancel as a function that seems unlikely
+   to be redefined by an interceptor library.  The bionic (Android) C
+   library does not provide pthread_cancel, so we do use pthread_create
+   there (and interceptor libraries lose).  */
+
+#ifdef __GLIBC__
+__gthrw2(__gthrw_(__pthread_key_create),
+	 __pthread_key_create,
+	 pthread_key_create)
+# define GTHR_ACTIVE_PROXY	__gthrw_(__pthread_key_create)
+#elif defined (__BIONIC__)
+# define GTHR_ACTIVE_PROXY	__gthrw_(pthread_create)
+#else
+# define GTHR_ACTIVE_PROXY	__gthrw_(pthread_cancel)
+#endif
+
+static inline int
+__gthread_active_p (void)
+{
+  static void *const __gthread_active_ptr
+    = __extension__ (void *) &GTHR_ACTIVE_PROXY;
+  return __gthread_active_ptr != 0;
+}
+
+#endif /* FreeBSD or Solaris */
+
+#else /* not SUPPORTS_WEAK */
+
+/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
+   calls in shared flavors of the HP-UX C library.  Most of the stubs
+   have no functionality.  The details are described in the "libc cumulative
+   patch" for each subversion of HP-UX 11.  There are two special interfaces
+   provided for checking whether an application is linked to a shared pthread
+   library or not.  However, these interfaces aren't available in early
+   libpthread libraries.  We also need a test that works for archive
+   libraries.  We can't use pthread_once as some libc versions call the
+   init function.  We also can't use pthread_create or pthread_attr_init
+   as these create a thread and thereby prevent changing the default stack
+   size.  The function pthread_default_stacksize_np is available in both
+   the archive and shared versions of libpthread.   It can be used to
+   determine the default pthread stack size.  There is a stub in some
+   shared libc versions which returns a zero size if pthreads are not
+   active.  We provide an equivalent stub to handle cases where libc
+   doesn't provide one.  */
+
+#if defined(__hppa__) && defined(__hpux__)
+
+static volatile int __gthread_active = -1;
+
+static inline int
+__gthread_active_p (void)
+{
+  /* Avoid reading __gthread_active twice on the main code path.  */
+  int __gthread_active_latest_value = __gthread_active;
+  size_t __s;
+
+  if (__builtin_expect (__gthread_active_latest_value < 0, 0))
+    {
+      pthread_default_stacksize_np (0, &__s);
+      __gthread_active = __s ? 1 : 0;
+      __gthread_active_latest_value = __gthread_active;
+    }
+
+  return __gthread_active_latest_value != 0;
+}
+
+#else /* not hppa-hpux */
+
+static inline int
+__gthread_active_p (void)
+{
+  return 1;
+}
+
+#endif /* hppa-hpux */
+
+#endif /* SUPPORTS_WEAK */
+
+#ifdef _LIBOBJC
+
+/* This is the config.h file in libobjc/ */
+#include <config.h>
+
+#ifdef HAVE_SCHED_H
+# include <sched.h>
+#endif
+
+/* Key structure for maintaining thread specific storage */
+static pthread_key_t _objc_thread_storage;
+static pthread_attr_t _objc_thread_attribs;
+
+/* Thread local storage for a single thread */
+static void *thread_local_storage = NULL;
+
+/* Backend initialization functions */
+
+/* Initialize the threads subsystem.  */
+static inline int
+__gthread_objc_init_thread_system (void)
+{
+  if (__gthread_active_p ())
+    {
+      /* Initialize the thread storage key.  */
+      if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
+	{
+	  /* The normal default detach state for threads is
+	   * PTHREAD_CREATE_JOINABLE which causes threads to not die
+	   * when you think they should.  */
+	  if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
+	      && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
+					      PTHREAD_CREATE_DETACHED) == 0)
+	    return 0;
+	}
+    }
+
+  return -1;
+}
+
+/* Close the threads subsystem.  */
+static inline int
+__gthread_objc_close_thread_system (void)
+{
+  if (__gthread_active_p ()
+      && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
+      && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
+    return 0;
+
+  return -1;
+}
+
+/* Backend thread functions */
+
+/* Create a new thread of execution.  */
+static inline objc_thread_t
+__gthread_objc_thread_detach (void (*func)(void *), void *arg)
+{
+  objc_thread_t thread_id;
+  pthread_t new_thread_handle;
+
+  if (!__gthread_active_p ())
+    return NULL;
+
+  if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
+				  (void *) func, arg)))
+    thread_id = (objc_thread_t) new_thread_handle;
+  else
+    thread_id = NULL;
+
+  return thread_id;
+}
+
+/* Set the current thread's priority.  */
+static inline int
+__gthread_objc_thread_set_priority (int priority)
+{
+  if (!__gthread_active_p ())
+    return -1;
+  else
+    {
+#ifdef _POSIX_PRIORITY_SCHEDULING
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+      pthread_t thread_id = __gthrw_(pthread_self) ();
+      int policy;
+      struct sched_param params;
+      int priority_min, priority_max;
+
+      if (__gthrw_(pthread_getschedparam) (thread_id, &policy, &params) == 0)
+	{
+	  if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
+	    return -1;
+
+	  if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
+	    return -1;
+
+	  if (priority > priority_max)
+	    priority = priority_max;
+	  else if (priority < priority_min)
+	    priority = priority_min;
+	  params.sched_priority = priority;
+
+	  /*
+	   * The solaris 7 and several other man pages incorrectly state that
+	   * this should be a pointer to policy but pthread.h is universally
+	   * at odds with this.
+	   */
+	  if (__gthrw_(pthread_setschedparam) (thread_id, policy, &params) == 0)
+	    return 0;
+	}
+#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+      return -1;
+    }
+}
+
+/* Return the current thread's priority.  */
+static inline int
+__gthread_objc_thread_get_priority (void)
+{
+#ifdef _POSIX_PRIORITY_SCHEDULING
+#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
+  if (__gthread_active_p ())
+    {
+      int policy;
+      struct sched_param params;
+
+      if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, &params) == 0)
+	return params.sched_priority;
+      else
+	return -1;
+    }
+  else
+#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
+#endif /* _POSIX_PRIORITY_SCHEDULING */
+    return OBJC_THREAD_INTERACTIVE_PRIORITY;
+}
+
+/* Yield our process time to another thread.  */
+static inline void
+__gthread_objc_thread_yield (void)
+{
+  if (__gthread_active_p ())
+    __gthrw_(sched_yield) ();
+}
+
+/* Terminate the current thread.  */
+static inline int
+__gthread_objc_thread_exit (void)
+{
+  if (__gthread_active_p ())
+    /* exit the thread */
+    __gthrw_(pthread_exit) (&__objc_thread_exit_status);
+
+  /* Failed if we reached here */
+  return -1;
+}
+
+/* Returns an integer value which uniquely describes a thread.  */
+static inline objc_thread_t
+__gthread_objc_thread_id (void)
+{
+  if (__gthread_active_p ())
+    return (objc_thread_t) __gthrw_(pthread_self) ();
+  else
+    return (objc_thread_t) 1;
+}
+
+/* Sets the thread's local storage pointer.  */
+static inline int
+__gthread_objc_thread_set_data (void *value)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
+  else
+    {
+      thread_local_storage = value;
+      return 0;
+    }
+}
+
+/* Returns the thread's local storage pointer.  */
+static inline void *
+__gthread_objc_thread_get_data (void)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_getspecific) (_objc_thread_storage);
+  else
+    return thread_local_storage;
+}
+
+/* Backend mutex functions */
+
+/* Allocate a mutex.  */
+static inline int
+__gthread_objc_mutex_allocate (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ())
+    {
+      mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
+
+      if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
+	{
+	  objc_free (mutex->backend);
+	  mutex->backend = NULL;
+	  return -1;
+	}
+    }
+
+  return 0;
+}
+
+/* Deallocate a mutex.  */
+static inline int
+__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ())
+    {
+      int count;
+
+      /*
+       * Posix Threads specifically require that the thread be unlocked
+       * for __gthrw_(pthread_mutex_destroy) to work.
+       */
+
+      do
+	{
+	  count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
+	  if (count < 0)
+	    return -1;
+	}
+      while (count);
+
+      if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
+	return -1;
+
+      objc_free (mutex->backend);
+      mutex->backend = NULL;
+    }
+  return 0;
+}
+
+/* Grab a lock on a mutex.  */
+static inline int
+__gthread_objc_mutex_lock (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ()
+      && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
+    {
+      return -1;
+    }
+
+  return 0;
+}
+
+/* Try to grab a lock on a mutex.  */
+static inline int
+__gthread_objc_mutex_trylock (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ()
+      && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
+    {
+      return -1;
+    }
+
+  return 0;
+}
+
+/* Unlock the mutex */
+static inline int
+__gthread_objc_mutex_unlock (objc_mutex_t mutex)
+{
+  if (__gthread_active_p ()
+      && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
+    {
+      return -1;
+    }
+
+  return 0;
+}
+
+/* Backend condition mutex functions */
+
+/* Allocate a condition.  */
+static inline int
+__gthread_objc_condition_allocate (objc_condition_t condition)
+{
+  if (__gthread_active_p ())
+    {
+      condition->backend = objc_malloc (sizeof (pthread_cond_t));
+
+      if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
+	{
+	  objc_free (condition->backend);
+	  condition->backend = NULL;
+	  return -1;
+	}
+    }
+
+  return 0;
+}
+
+/* Deallocate a condition.  */
+static inline int
+__gthread_objc_condition_deallocate (objc_condition_t condition)
+{
+  if (__gthread_active_p ())
+    {
+      if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
+	return -1;
+
+      objc_free (condition->backend);
+      condition->backend = NULL;
+    }
+  return 0;
+}
+
+/* Wait on the condition */
+static inline int
+__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
+			      (pthread_mutex_t *) mutex->backend);
+  else
+    return 0;
+}
+
+/* Wake up all threads waiting on this condition.  */
+static inline int
+__gthread_objc_condition_broadcast (objc_condition_t condition)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
+  else
+    return 0;
+}
+
+/* Wake up one thread waiting on this condition.  */
+static inline int
+__gthread_objc_condition_signal (objc_condition_t condition)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
+  else
+    return 0;
+}
+
+#else /* _LIBOBJC */
+
+static inline int
+__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
+		  void *__args)
+{
+  return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
+}
+
+static inline int
+__gthread_join (__gthread_t __threadid, void **__value_ptr)
+{
+  return __gthrw_(pthread_join) (__threadid, __value_ptr);
+}
+
+static inline int
+__gthread_detach (__gthread_t __threadid)
+{
+  return __gthrw_(pthread_detach) (__threadid);
+}
+
+static inline int
+__gthread_equal (__gthread_t __t1, __gthread_t __t2)
+{
+  return __gthrw_(pthread_equal) (__t1, __t2);
+}
+
+static inline __gthread_t
+__gthread_self (void)
+{
+  return __gthrw_(pthread_self) ();
+}
+
+static inline int
+__gthread_yield (void)
+{
+  return __gthrw_(sched_yield) ();
+}
+
+static inline int
+__gthread_once (__gthread_once_t *__once, void (*__func) (void))
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_once) (__once, __func);
+  else
+    return -1;
+}
+
+static inline int
+__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
+{
+  return __gthrw_(pthread_key_create) (__key, __dtor);
+}
+
+static inline int
+__gthread_key_delete (__gthread_key_t __key)
+{
+  return __gthrw_(pthread_key_delete) (__key);
+}
+
+static inline void *
+__gthread_getspecific (__gthread_key_t __key)
+{
+  return __gthrw_(pthread_getspecific) (__key);
+}
+
+static inline int
+__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
+{
+  return __gthrw_(pthread_setspecific) (__key, __ptr);
+}
+
+static inline void
+__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    __gthrw_(pthread_mutex_init) (__mutex, NULL);
+}
+
+static inline int
+__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_destroy) (__mutex);
+  else
+    return 0;
+}
+
+static inline int
+__gthread_mutex_lock (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_lock) (__mutex);
+  else
+    return 0;
+}
+
+static inline int
+__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_trylock) (__mutex);
+  else
+    return 0;
+}
+
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+static inline int
+__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
+			   const __gthread_time_t *__abs_timeout)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
+  else
+    return 0;
+}
+#endif
+
+static inline int
+__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    return __gthrw_(pthread_mutex_unlock) (__mutex);
+  else
+    return 0;
+}
+
+#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
+  || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
+static inline int
+__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+    {
+      pthread_mutexattr_t __attr;
+      int __r;
+
+      __r = __gthrw_(pthread_mutexattr_init) (&__attr);
+      if (!__r)
+	__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
+						   PTHREAD_MUTEX_RECURSIVE);
+      if (!__r)
+	__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
+      if (!__r)
+	__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
+      return __r;
+    }
+  return 0;
+}
+#endif
+
+static inline int
+__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_lock (__mutex);
+}
+
+static inline int
+__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_trylock (__mutex);
+}
+
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+static inline int
+__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
+				     const __gthread_time_t *__abs_timeout)
+{
+  return __gthread_mutex_timedlock (__mutex, __abs_timeout);
+}
+#endif
+
+static inline int
+__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_unlock (__mutex);
+}
+
+static inline int
+__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_mutex_destroy (__mutex);
+}
+
+#ifdef _GTHREAD_USE_COND_INIT_FUNC
+static inline void
+__gthread_cond_init_function (__gthread_cond_t *__cond)
+{
+  if (__gthread_active_p ())
+    __gthrw_(pthread_cond_init) (__cond, NULL);
+}
+#endif
+
+static inline int
+__gthread_cond_broadcast (__gthread_cond_t *__cond)
+{
+  return __gthrw_(pthread_cond_broadcast) (__cond);
+}
+
+static inline int
+__gthread_cond_signal (__gthread_cond_t *__cond)
+{
+  return __gthrw_(pthread_cond_signal) (__cond);
+}
+
+static inline int
+__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
+{
+  return __gthrw_(pthread_cond_wait) (__cond, __mutex);
+}
+
+static inline int
+__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
+			  const __gthread_time_t *__abs_timeout)
+{
+  return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
+}
+
+static inline int
+__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
+			       __gthread_recursive_mutex_t *__mutex)
+{
+  return __gthread_cond_wait (__cond, __mutex);
+}
+
+static inline int
+__gthread_cond_destroy (__gthread_cond_t* __cond)
+{
+  return __gthrw_(pthread_cond_destroy) (__cond);
+}
+
+#endif /* _LIBOBJC */
+
+#endif /* ! GCC_GTHR_POSIX_H */
diff --git a/libgcov/include/libgcc_tm.h b/libgcov/include/libgcc_tm.h
new file mode 100644
index 0000000..038a60b
--- /dev/null
+++ b/libgcov/include/libgcc_tm.h
@@ -0,0 +1,6 @@
+#ifndef LIBGCC_TM_H
+#define LIBGCC_TM_H
+/* Automatically generated by mkheader.sh.  */
+#include "config/i386/elf-lib.h"
+#include "config/i386/value-unwind.h"
+#endif /* LIBGCC_TM_H */
diff --git a/libgcov/include/tconfig.h b/libgcov/include/tconfig.h
new file mode 100644
index 0000000..7ec80a1
--- /dev/null
+++ b/libgcov/include/tconfig.h
@@ -0,0 +1,10 @@
+#ifndef GCC_TCONFIG_H
+#define GCC_TCONFIG_H
+#ifndef USED_FOR_TARGET
+# define USED_FOR_TARGET
+#endif
+#include "auto-host.h"
+#ifdef IN_GCC
+# include "ansidecl.h"
+#endif
+#endif /* GCC_TCONFIG_H */
diff --git a/libgcov/include/tm.h b/libgcov/include/tm.h
new file mode 100644
index 0000000..611fa76
--- /dev/null
+++ b/libgcov/include/tm.h
@@ -0,0 +1,52 @@
+#ifndef GCC_TM_H
+#define GCC_TM_H
+#ifndef LIBC_GLIBC
+# define LIBC_GLIBC 1
+#endif
+#ifndef LIBC_UCLIBC
+# define LIBC_UCLIBC 2
+#endif
+#ifndef LIBC_BIONIC
+# define LIBC_BIONIC 3
+#endif
+#ifndef LIBC_MUSL
+# define LIBC_MUSL 4
+#endif
+#ifndef DEFAULT_LIBC
+# define DEFAULT_LIBC LIBC_GLIBC
+#endif
+#ifndef ANDROID_DEFAULT
+# define ANDROID_DEFAULT 0
+#endif
+#ifdef IN_GCC
+# include "options.h"
+# include "insn-constants.h"
+# include "config/vxworks-dummy.h"
+# include "config/i386/biarch64.h"
+# include "config/i386/i386.h"
+# include "config/i386/unix.h"
+# include "config/i386/att.h"
+# include "config/dbxelf.h"
+# include "config/elfos.h"
+# include "config/gnu-user.h"
+# include "config/glibc-stdint.h"
+# include "config/i386/x86-64.h"
+# include "config/i386/gnu-user-common.h"
+# include "config/i386/gnu-user64.h"
+# include "config/linux.h"
+# include "config/linux-android.h"
+# include "config/i386/linux-common.h"
+# include "config/i386/linux64.h"
+# include "config/initfini-array.h"
+#endif
+#if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET
+# include "insn-flags.h"
+#endif
+#if defined IN_GCC && !defined GENERATOR_FILE
+# include "insn-modes.h"
+#endif
+#if defined IN_GCC && defined GENERATOR_FILE && !defined BITS_PER_UNIT
+#include "machmode.h"
+#endif
+# include "defaults.h"
+#endif /* GCC_TM_H */
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:57:57 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:57: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 1jeY1j-00061n-5Z; Fri, 29 May 2020 05:57:55 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY1i-00061b-5H
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:57:54 +0000
X-Inumbo-ID: 55729076-a171-11ea-8993-bc764e2007e4
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTP
 id 55729076-a171-11ea-8993-bc764e2007e4;
 Fri, 29 May 2020 05:57:52 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3E87A1042;
 Thu, 28 May 2020 22:57:52 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2CFDD3F305;
 Thu, 28 May 2020 22:57:49 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 01/27] plat/virtio: Introduce several helpers
 for virtio ring
Date: Fri, 29 May 2020 13:56:51 +0800
Message-Id: <20200529055717.88063-2-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch provides several virtqueue helpers for virtio mmio
initialization.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/include/virtio/virtqueue.h | 33 +++++++++++++++++++++++++
 plat/drivers/virtio/virtio_ring.c       | 32 ++++++++++++++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/plat/drivers/include/virtio/virtqueue.h b/plat/drivers/include/virtio/virtqueue.h
index 1479828..a717541 100644
--- a/plat/drivers/include/virtio/virtqueue.h
+++ b/plat/drivers/include/virtio/virtqueue.h
@@ -82,6 +82,39 @@ struct virtqueue {
  */
 __phys_addr virtqueue_physaddr(struct virtqueue *vq);
 
+/**
+ * Fetch the avail address of the descriptor ring.
+ * @param vq
+ *	Reference to the virtqueue.
+ *
+ * @return
+ *	Return the guest avail address of the vring.
+ */
+__phys_addr virtqueue_get_avail_addr(struct virtqueue *vq);
+
+/**
+ * Fetch the used address of the descriptor ring.
+ * @param vq
+ *	Reference to the virtqueue.
+ *
+ * @return
+ *	Return the guest used address of the vring.
+ */
+__phys_addr virtqueue_get_used_addr(struct virtqueue *vq);
+
+/**
+ * Get the number of vring for virtqueue
+ *
+ * @param vq
+ *	Reference to the virtual queue
+ *
+ * @return
+ *	the number of vring for virtqueue
+ *
+ */
+unsigned int virtqueue_vring_get_num(struct virtqueue *vq);
+
+
 /**
  * Ring interrupt handler. This function is invoked from the interrupt handler
  * in the virtio device for interrupt specific to the ring.
diff --git a/plat/drivers/virtio/virtio_ring.c b/plat/drivers/virtio/virtio_ring.c
index ab9287a..0f39895 100644
--- a/plat/drivers/virtio/virtio_ring.c
+++ b/plat/drivers/virtio/virtio_ring.c
@@ -262,6 +262,38 @@ __phys_addr virtqueue_physaddr(struct virtqueue *vq)
 	return ukplat_virt_to_phys(vrq->vring_mem);
 }
 
+__phys_addr virtqueue_get_avail_addr(struct virtqueue *vq)
+{
+	struct virtqueue_vring *vrq = NULL;
+
+	UK_ASSERT(vq);
+
+	vrq = to_virtqueue_vring(vq);
+	return virtqueue_physaddr(vq) +
+		((char *)vrq->vring.avail - (char *)vrq->vring.desc);
+}
+
+__phys_addr virtqueue_get_used_addr(struct virtqueue *vq)
+{
+	struct virtqueue_vring *vrq = NULL;
+
+	UK_ASSERT(vq);
+
+	vrq = to_virtqueue_vring(vq);
+	return virtqueue_physaddr(vq) +
+		((char *)vrq->vring.used - (char *)vrq->vring.desc);
+}
+
+unsigned int virtqueue_vring_get_num(struct virtqueue *vq)
+{
+	struct virtqueue_vring *vrq = NULL;
+
+	UK_ASSERT(vq);
+
+	vrq = to_virtqueue_vring(vq);
+	return vrq->vring.num;
+}
+
 int virtqueue_buffer_dequeue(struct virtqueue *vq, void **cookie, __u32 *len)
 {
 	struct virtqueue_vring *vrq = NULL;
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:57:57 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:57: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 1jeY1i-00061c-4C; Fri, 29 May 2020 05:57:54 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY1h-00061W-9f
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:57:53 +0000
X-Inumbo-ID: 53e2c37a-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 53e2c37a-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:57:50 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A671155D;
 Thu, 28 May 2020 22:57:49 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 931003F305;
 Thu, 28 May 2020 22:57:47 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 00/27] Impelment virtio_mmio and pci ecam
 controller for arm64 kvm plat
Date: Fri, 29 May 2020 13:56:50 +0800
Message-Id: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

To support virtio-* family device, we have 2 choices (virtio mmio, virtio pci)
on arm64 kvm plat. This patch series enable the support of virtio mmio. virtio
pci needs pci controller ECAM mode in arm64 Unikraft.

Previously, I proposed a separated series at [1], Julien had given some
comments including using fdt_get_address and refining the platform device
probing sequence. This series address them, but prevent changing too much
in original virtio mmio series.

Patch 1-5 implement the platform bus and virtio mmio skeleton.
Patch 8-10 implement the pci ecam skeleton
Patch 12-13 introduce the new probing interface for virtio mmio and pci
      on arm.
Patch 7,11,14,15,16 lib/fdt or ofw/fdt changes
Patch 17-19 split the arch specific pci bus codes into different directory
Else are the bug fixing or minor changes.

Test
====
The test case is a simple httpreply app.
test qemu cmdline:
- for virtio mmio
-device virtio-net-device,id=net1,netdev=hostnet1,mac=52:54:00:09:a4:38
- for virtio pci
-device 
virtio-net-pci,id=net0,netdev=hostnet0,mac=52:54:00:09:a4:31,disable-modern=on

Besides, I also tested it with nginx app which was suggested by Felipe. ping
and wget both worked. But there is still some occasional crash which I can't
address them all. But I am not sure the crash is irrelevant/relevant to this
patch series. 

[1] https://lists.xenproject.org/archives/html/minios-devel/2019-10/msg00688.html

Changes:
========
v2: Address the comments from felipe
  - fix the compilation warnings
  - change the better memory barriar for virtio communication
  - fix a bug in virtio-9p
  - make it compilable for individual patch
v1: https://lists.xenproject.org/archives/html/minios-devel/2020-03/msg00056.html

Jia He (27):
  plat/virtio: Introduce several helpers for virtio ring
  plat/platform: Introduce new platform bus
  plat/virtio: Support virtio_cread/cwrite on arm64
  plat/virtio: Add new virtio_mmio device/driver on arm64
  build: Enable the platform bus and virtio_mmio device on arm64
  plat/kvm: arm64: Fix arm64 memory layout for pcie ecam
  plat/ofw: Export fdt_find_irq_parent_offset
  plat/pci_ecam: Introduce pci/pci_ecam.h
  plat/pci_ecam: Introduce pci ecam skeleton
  lib/ukbus: Adjust default bus register priority
  plat/ofw: Add fdt_node_offset_idx_by_compatible_list
  plat/platform_bus: Add probe/match interface for platform devices
  plat/virtio_mmio: Implement platform probe for virtio_mmio
  plat/ofw: Support completed ranges mapping
  lib/fdt: Fix fdt_address_cell and fdt_size_cell
  plat/ofw: Add fdt_prop_read_bool
  plat/pci_bus: Split specific code into arch directory
  plat/pci_bus: arm64: Implement arch specific add/probe interfaces on
    arm64
  build: Make KVM_PCI default enable on arm64
  plat/pci_bus: Change the type of pci_device.base from u16 to unsigned
    long
  build: Enable pci library on arm64
  plat/pci_ecam: Fix a lot compilation warnings in pci_ecam
  plat/virtio: Fix virtio net device mac negotiation
  plat/virtio: Change the type of irq,base from u16 to u64 for arm64
  plat/virtio: Use better iormb/iowmb on arm64
  plat/virtio_9p: Fix max virtqueue number 1024 on arm64
  plat/platform_bus,virtio_mmio: Avoid useless log storm

 lib/fdt/exportsyms.uk                       |   1 +
 lib/fdt/fdt_addresses.c                     |  57 +-
 lib/ukbus/include/uk/bus.h                  |  16 +-
 plat/common/arm/pci_bus_arm64.c             | 200 +++++++
 plat/common/include/arm/arm64/cpu_defs.h    |   3 +
 plat/common/include/pci/pci_bus.h           | 105 +++-
 plat/common/include/pci/pci_ecam.h          | 101 ++++
 plat/common/include/platform_bus.h          | 116 +++++
 plat/common/pci_bus.c                       | 167 +-----
 plat/common/pci_ecam.c                      | 524 +++++++++++++++++++
 plat/common/platform_bus.c                  | 236 +++++++++
 plat/common/x86/pci_bus_x86.c               | 174 +++++++
 plat/drivers/include/ofw/fdt.h              |  74 +++
 plat/drivers/include/virtio/virtio_config.h |  73 ++-
 plat/drivers/include/virtio/virtio_mmio.h   | 137 +++++
 plat/drivers/include/virtio/virtqueue.h     |  33 ++
 plat/drivers/ofw/fdt.c                      |  81 ++-
 plat/drivers/virtio/virtio_9p.c             |   2 +-
 plat/drivers/virtio/virtio_mmio.c           | 550 ++++++++++++++++++++
 plat/drivers/virtio/virtio_net.c            |  15 +-
 plat/drivers/virtio/virtio_pci.c            |   6 +-
 plat/drivers/virtio/virtio_ring.c           |  32 ++
 plat/kvm/Config.uk                          |  14 +-
 plat/kvm/Makefile.uk                        |  29 +-
 plat/kvm/arm/pagetable64.S                  |  22 +-
 25 files changed, 2537 insertions(+), 231 deletions(-)
 create mode 100644 plat/common/arm/pci_bus_arm64.c
 create mode 100644 plat/common/include/pci/pci_ecam.h
 create mode 100644 plat/common/include/platform_bus.h
 create mode 100644 plat/common/pci_ecam.c
 create mode 100644 plat/common/platform_bus.c
 create mode 100644 plat/common/x86/pci_bus_x86.c
 create mode 100644 plat/drivers/include/virtio/virtio_mmio.h
 create mode 100644 plat/drivers/virtio/virtio_mmio.c

-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:00 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY1o-00062V-7F; Fri, 29 May 2020 05:58:00 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY1m-00062C-DL
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:57:58 +0000
X-Inumbo-ID: 57bd972d-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 57bd972d-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:57:57 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 61C6455D;
 Thu, 28 May 2020 22:57:57 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 512A33F305;
 Thu, 28 May 2020 22:57:55 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 03/27] plat/virtio: Support virtio_cread/cwrite
 on arm64
Date: Fri, 29 May 2020 13:56:53 +0800
Message-Id: <20200529055717.88063-4-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Add virtio_cread/cwrite on arm64 with. Also add iowmb/iormb

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/include/virtio/virtio_config.h | 63 ++++++++++++++++++++-
 1 file changed, 62 insertions(+), 1 deletion(-)

diff --git a/plat/drivers/include/virtio/virtio_config.h b/plat/drivers/include/virtio/virtio_config.h
index 1221bbc..b80f26a 100644
--- a/plat/drivers/include/virtio/virtio_config.h
+++ b/plat/drivers/include/virtio/virtio_config.h
@@ -54,6 +54,9 @@ extern "C" {
 #define VIRTIO_TRANSPORT_F_START    28
 #define VIRTIO_TRANSPORT_F_END      32
 
+/* v1.0 compliant. */
+#define VIRTIO_F_VERSION_1		32
+
 #ifdef __X86_64__
 static inline void _virtio_cwrite_bytes(const void *addr, const __u8 offset,
 					const void *buf, int len, int type_len)
@@ -110,7 +113,65 @@ static inline void _virtio_cread_bytes(const void *addr, const __u8 offset,
 	}
 }
 #else  /* __X86_64__ */
-#error "Virtio driver not supported for this architecture"
+
+/* IO barriers */
+#define __iormb()		rmb()
+#define __iowmb()		wmb()
+
+static inline void _virtio_cwrite_bytes(const void *addr, const __u8 offset,
+					const void *buf, int len, int type_len)
+{
+	int i = 0;
+	void *io_addr;
+	int count;
+
+	count  = len / type_len;
+	for (i = 0; i < count; i++) {
+		io_addr = (void *)addr + offset + (i * type_len);
+		__iowmb();
+		switch (type_len) {
+		case 1:
+			ioreg_write8(io_addr, ((__u8 *)buf)[i * type_len]);
+			break;
+		case 2:
+			ioreg_write16(io_addr, ((__u16 *)buf)[i * type_len]);
+			break;
+		case 4:
+			ioreg_write32(io_addr, ((__u32 *)buf)[i * type_len]);
+			break;
+		default:
+			UK_CRASH("Unsupported virtio write operation\n");
+		}
+	}
+}
+
+static inline void _virtio_cread_bytes(const void *addr, const __u8 offset,
+				       void *buf, int len, int type_len)
+{
+	int i = 0;
+	void *io_addr;
+	int count;
+
+	count = len / type_len;
+	for (i = 0; i < count; i++) {
+		io_addr = (void *)addr + offset + (i * type_len);
+		switch (type_len) {
+		case 1:
+			((__u8 *)buf)[i * type_len] = ioreg_read8(io_addr);
+			break;
+		case 2:
+			((__u16 *)buf)[i * type_len] = ioreg_read16(io_addr);
+			break;
+		case 4:
+			((__u32 *)buf)[i * type_len] = ioreg_read32(io_addr);
+			break;
+		default:
+			UK_CRASH("Unsupported virtio read operation\n");
+		}
+		__iormb();
+	}
+}
+
 #endif /* __X86_64__ */
 
 /**
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:00 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY1o-00062d-8b; Fri, 29 May 2020 05:58: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY1m-00062L-V3
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:57:58 +0000
X-Inumbo-ID: 56fed968-a171-11ea-9947-bc764e2007e4
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTP
 id 56fed968-a171-11ea-9947-bc764e2007e4;
 Fri, 29 May 2020 05:57:55 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C98DC55D;
 Thu, 28 May 2020 22:57:54 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B95B53F305;
 Thu, 28 May 2020 22:57:52 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 02/27] plat/platform: Introduce new platform bus
Date: Fri, 29 May 2020 13:56:52 +0800
Message-Id: <20200529055717.88063-3-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

platform bus is a simple bus interface for many devices, including
virtio_mmio device on arm64

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/include/platform_bus.h | 100 ++++++++++++
 plat/common/platform_bus.c         | 235 +++++++++++++++++++++++++++++
 2 files changed, 335 insertions(+)
 create mode 100644 plat/common/include/platform_bus.h
 create mode 100644 plat/common/platform_bus.c

diff --git a/plat/common/include/platform_bus.h b/plat/common/include/platform_bus.h
new file mode 100644
index 0000000..efc21a0
--- /dev/null
+++ b/plat/common/include/platform_bus.h
@@ -0,0 +1,100 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Jia He <justin.he@arm.com>
+ *
+ * Copyright (c) 2020, Arm Ltd. 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.
+ */
+
+#ifndef __UKPLAT_COMMON_PF_BUS_H__
+#define __UKPLAT_COMMON_PF_BUS_H__
+
+#include <uk/bus.h>
+#include <uk/alloc.h>
+
+/**
+ * A structure describing an ID for a Platform driver. Each driver provides a
+ * table of these IDs for each device that it supports.
+ */
+#define PLATFORM_DEVICE_ID_START (0x100)
+#define VIRTIO_MMIO_ID PLATFORM_DEVICE_ID_START
+#define PLATFORM_DEVICE_ID_END (PLATFORM_DEVICE_ID_START + 0x100)
+
+#define UK_MAX_VIRTIO_MMIO_DEVICE (0x2)
+
+struct pf_device_id {
+	uint16_t device_id;
+};
+
+struct pf_device;
+
+typedef int (*pf_driver_add_func_t)(struct pf_device *);
+typedef int (*pf_driver_init_func_t)(struct uk_alloc *a);
+
+struct pf_driver {
+	UK_TAILQ_ENTRY(struct pf_driver) next;
+	const struct pf_device_id *device_ids;
+	pf_driver_init_func_t init; /* optional */
+	pf_driver_add_func_t add_dev;
+};
+UK_TAILQ_HEAD(pf_driver_list, struct pf_driver);
+
+enum pf_device_state {
+	PF_DEVICE_STATE_RESET = 0,
+	PF_DEVICE_STATE_RUNNING
+};
+
+struct pf_device {
+	UK_TAILQ_ENTRY(struct pf_device) next; /**< used by pf_bus_handler */
+	struct pf_device_id  id;
+	struct pf_driver     *drv;
+	enum pf_device_state state;
+
+	uint64_t base;
+	unsigned long irq;
+};
+UK_TAILQ_HEAD(pf_device_list, struct pf_device);
+
+
+#define PF_REGISTER_DRIVER(b)                  \
+	_PF_REGISTER_DRIVER(__LIBNAME__, b)
+
+#define _PF_REGFNNAME(x, y)      x##y
+
+#define _PF_REGISTER_DRIVER(libname, b)				\
+	static void __constructor_prio(105)				\
+	_PF_REGFNNAME(libname, _pf_register_driver)(void)		\
+	{								\
+		_pf_register_driver((b));				\
+	}
+
+/* Do not use this function directly: */
+void _pf_register_driver(struct pf_driver *drv);
+
+#endif /* __UKPLAT_COMMON_PF_BUS_H__ */
diff --git a/plat/common/platform_bus.c b/plat/common/platform_bus.c
new file mode 100644
index 0000000..1410e71
--- /dev/null
+++ b/plat/common/platform_bus.c
@@ -0,0 +1,235 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Jia He <justin.he@arm.com>
+ *
+ * Copyright (c) 2020, Arm Ltd. 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.
+ */
+
+#include <string.h>
+#include <uk/print.h>
+#include <uk/plat/common/cpu.h>
+#include <platform_bus.h>
+#include <libfdt.h>
+#include <kvm/config.h>
+#include <gic/gic-v2.h>
+#include <ofw/fdt.h>
+
+#define fdt_start (_libkvmplat_cfg.dtb)
+
+struct pf_bus_handler {
+	struct uk_bus b;
+	struct uk_alloc *a;
+	struct pf_driver_list drv_list;  /**< List of platform drivers */
+	int drv_list_initialized;
+	struct pf_device_list dev_list;  /**< List of platform devices */
+};
+static struct pf_bus_handler pfh;
+
+static const char * const pf_device_list[] = {
+	"virtio,mmio",
+};
+
+static inline int pf_device_id_match(const struct pf_device_id *id0,
+					const struct pf_device_id *id1)
+{
+	int rc = 0;
+
+	if (id0->device_id == id1->device_id)
+		rc = 1;
+
+	return rc;
+}
+
+static inline struct pf_driver *pf_find_driver(struct pf_device_id *id)
+{
+	struct pf_driver *drv;
+
+	UK_TAILQ_FOREACH(drv, &pfh.drv_list, next) {
+		if (pf_device_id_match(id, drv->device_ids)) {
+			uk_pr_debug("pf driver found devid=%d\n", drv->device_ids->device_id);
+			return drv; /* driver found */
+		}
+	}
+
+	uk_pr_info("no pf driver found\n");
+
+	return NULL; /* no driver found */
+}
+
+static inline int pf_driver_add_device(struct pf_driver *drv,
+					struct pf_device_id *devid,
+					__u64 dev_base,
+					int dev_irq)
+{
+	struct pf_device *dev;
+	int ret;
+
+	UK_ASSERT(drv != NULL);
+	UK_ASSERT(drv->add_dev != NULL);
+
+	dev = (struct pf_device *) uk_calloc(pfh.a, 1, sizeof(*dev));
+	if (!dev) {
+		uk_pr_err("Platform : Failed to initialize: Out of memory!\n");
+		return -ENOMEM;
+	}
+
+	memcpy(&dev->id, devid, sizeof(dev->id));
+	uk_pr_debug("pf_driver_add_device dev->id=%d\n", dev->id.device_id);
+
+	dev->base = dev_base;
+	dev->irq = dev_irq;
+
+	ret = drv->add_dev(dev);
+	if (ret < 0) {
+		uk_pr_err("Platform Failed to initialize device driver\n");
+		uk_free(pfh.a, dev);
+	}
+
+	return ret;
+}
+
+static int pf_probe(void)
+{
+	struct pf_device_id devid;
+	struct pf_driver *drv;
+	int i;
+	int end_offset = -1;
+	int ret = -ENODEV;
+	const fdt32_t *prop;
+	int type, hwirq, prop_len;
+	__u64 reg_base;
+	__phys_addr dev_base;
+	int dev_irq;
+
+	uk_pr_info("Probe PF\n");
+
+	/* We only support virtio_mmio as a platform device here.
+	 * A loop here is needed for finding drivers if more devices
+	 */
+	devid.device_id = VIRTIO_MMIO_ID;
+
+	drv = pf_find_driver(&devid);
+	if (!drv) {
+		uk_pr_info("<no driver>\n");
+		return -ENODEV;
+	}
+
+	uk_pr_info("driver %p\n", drv);
+
+	/* qemu creates virtio devices in reverse order */
+	for (i = 0; i < UK_MAX_VIRTIO_MMIO_DEVICE; i++) {
+		end_offset = fdt_node_offset_by_compatible_list(fdt_start,
+							end_offset,
+							pf_device_list);
+		if (end_offset == -FDT_ERR_NOTFOUND) {
+			uk_pr_info("device not found in fdt\n");
+			goto error_exit;
+		} else {
+			prop = fdt_getprop(fdt_start, end_offset, "interrupts", &prop_len);
+			if (!prop) {
+				uk_pr_err("irq of device not found in fdt\n");
+				goto error_exit;
+			}
+
+			type = fdt32_to_cpu(prop[0]);
+			hwirq = fdt32_to_cpu(prop[1]);
+
+			prop = fdt_getprop(fdt_start, end_offset, "reg", &prop_len);
+			if (!prop) {
+				uk_pr_err("reg of device not found in fdt\n");
+				goto error_exit;
+			}
+
+			/* only care about base addr, ignore the size */
+			reg_base = fdt32_to_cpu(prop[0]);
+			reg_base = reg_base << 32 | fdt32_to_cpu(prop[1]);
+		}
+
+		dev_base = reg_base;
+		dev_irq = gic_irq_translate(type, hwirq);
+
+		ret = pf_driver_add_device(drv, &devid, dev_base, dev_irq);
+	}
+
+	return ret;
+
+error_exit:
+	return -ENODEV;
+}
+
+
+static int pf_init(struct uk_alloc *a)
+{
+	struct pf_driver *drv, *drv_next;
+	int ret = 0;
+
+	UK_ASSERT(a != NULL);
+
+	pfh.a = a;
+
+	if (!pfh.drv_list_initialized) {
+		UK_TAILQ_INIT(&pfh.drv_list);
+		pfh.drv_list_initialized = 1;
+	}
+	UK_TAILQ_INIT(&pfh.dev_list);
+
+	UK_TAILQ_FOREACH_SAFE(drv, &pfh.drv_list, next, drv_next) {
+		if (drv->init) {
+			ret = drv->init(a);
+			if (ret == 0)
+				continue;
+			uk_pr_err("Failed to initialize pf driver %p: %d\n",
+				  drv, ret);
+			UK_TAILQ_REMOVE(&pfh.drv_list, drv, next);
+		}
+	}
+	return 0;
+}
+
+void _pf_register_driver(struct pf_driver *drv)
+{
+	UK_ASSERT(drv != NULL);
+	uk_pr_debug("_pf_register_driver %p\n", drv);
+
+	if (!pfh.drv_list_initialized) {
+		UK_TAILQ_INIT(&pfh.drv_list);
+		pfh.drv_list_initialized = 1;
+	}
+	UK_TAILQ_INSERT_TAIL(&pfh.drv_list, drv, next);
+}
+
+
+/* Register this bus driver to libukbus:
+ */
+static struct pf_bus_handler pfh = {
+	.b.init = pf_init,
+	.b.probe = pf_probe
+};
+UK_BUS_REGISTER(&pfh.b);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:04 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY1s-00063g-AC; Fri, 29 May 2020 05:58:04 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY1r-00063N-75
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:03 +0000
X-Inumbo-ID: 5a36de28-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 5a36de28-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:00 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3828355D;
 Thu, 28 May 2020 22:58:00 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DD7803F305;
 Thu, 28 May 2020 22:57:57 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 04/27] plat/virtio: Add new virtio_mmio
 device/driver on arm64
Date: Fri, 29 May 2020 13:56:54 +0800
Message-Id: <20200529055717.88063-5-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Based on [1], but device removing/releasing is not supported.

[1] http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-1090002

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/include/virtio/virtio_mmio.h | 137 ++++++
 plat/drivers/virtio/virtio_mmio.c         | 480 ++++++++++++++++++++++
 2 files changed, 617 insertions(+)
 create mode 100644 plat/drivers/include/virtio/virtio_mmio.h
 create mode 100644 plat/drivers/virtio/virtio_mmio.c

diff --git a/plat/drivers/include/virtio/virtio_mmio.h b/plat/drivers/include/virtio/virtio_mmio.h
new file mode 100644
index 0000000..ecf532a
--- /dev/null
+++ b/plat/drivers/include/virtio/virtio_mmio.h
@@ -0,0 +1,137 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Virtio platform device driver
+ *
+ * Copyright 2011, ARM Ltd.
+ * Copyright 2018, ARM Ltd.
+ * Based on Virtio PCI driver by Anthony Liguori, copyright IBM Corp. 2007
+ *
+ * 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 IBM 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 IBM 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.
+ */
+#ifndef _LINUX_VIRTIO_MMIO_H
+#define _LINUX_VIRTIO_MMIO_H
+
+/*
+ * Control registers
+ */
+
+/* Magic value ("virt" string) - Read Only */
+#define VIRTIO_MMIO_MAGIC_VALUE		0x000
+
+/* Virtio device version - Read Only */
+#define VIRTIO_MMIO_VERSION		0x004
+
+/* Virtio device ID - Read Only */
+#define VIRTIO_MMIO_DEVICE_ID		0x008
+
+/* Virtio vendor ID - Read Only */
+#define VIRTIO_MMIO_VENDOR_ID		0x00c
+
+/* Bitmask of the features supported by the device (host)
+ * (32 bits per set) - Read Only */
+#define VIRTIO_MMIO_DEVICE_FEATURES	0x010
+
+/* Device (host) features set selector - Write Only */
+#define VIRTIO_MMIO_DEVICE_FEATURES_SEL	0x014
+
+/* Bitmask of features activated by the driver (guest)
+ * (32 bits per set) - Write Only */
+#define VIRTIO_MMIO_DRIVER_FEATURES	0x020
+
+/* Activated features set selector - Write Only */
+#define VIRTIO_MMIO_DRIVER_FEATURES_SEL	0x024
+
+
+#ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
+
+/* Guest's memory page size in bytes - Write Only */
+#define VIRTIO_MMIO_GUEST_PAGE_SIZE	0x028
+
+#endif
+
+
+/* Queue selector - Write Only */
+#define VIRTIO_MMIO_QUEUE_SEL		0x030
+
+/* Maximum size of the currently selected queue - Read Only */
+#define VIRTIO_MMIO_QUEUE_NUM_MAX	0x034
+
+/* Queue size for the currently selected queue - Write Only */
+#define VIRTIO_MMIO_QUEUE_NUM		0x038
+
+
+#ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
+
+/* Used Ring alignment for the currently selected queue - Write Only */
+#define VIRTIO_MMIO_QUEUE_ALIGN		0x03c
+
+/* Guest's PFN for the currently selected queue - Read Write */
+#define VIRTIO_MMIO_QUEUE_PFN		0x040
+
+#endif
+
+
+/* Ready bit for the currently selected queue - Read Write */
+#define VIRTIO_MMIO_QUEUE_READY		0x044
+
+/* Queue notifier - Write Only */
+#define VIRTIO_MMIO_QUEUE_NOTIFY	0x050
+
+/* Interrupt status - Read Only */
+#define VIRTIO_MMIO_INTERRUPT_STATUS	0x060
+
+/* Interrupt acknowledge - Write Only */
+#define VIRTIO_MMIO_INTERRUPT_ACK	0x064
+
+/* Device status register - Read Write */
+#define VIRTIO_MMIO_STATUS		0x070
+
+/* Selected queue's Descriptor Table address, 64 bits in two halves */
+#define VIRTIO_MMIO_QUEUE_DESC_LOW	0x080
+#define VIRTIO_MMIO_QUEUE_DESC_HIGH	0x084
+
+/* Selected queue's Available Ring address, 64 bits in two halves */
+#define VIRTIO_MMIO_QUEUE_AVAIL_LOW	0x090
+#define VIRTIO_MMIO_QUEUE_AVAIL_HIGH	0x094
+
+/* Selected queue's Used Ring address, 64 bits in two halves */
+#define VIRTIO_MMIO_QUEUE_USED_LOW	0x0a0
+#define VIRTIO_MMIO_QUEUE_USED_HIGH	0x0a4
+
+/* Configuration atomicity value */
+#define VIRTIO_MMIO_CONFIG_GENERATION	0x0fc
+
+/* The config space is defined by each driver as
+ * the per-driver configuration space - Read Write */
+#define VIRTIO_MMIO_CONFIG		0x100
+
+/*
+ * Interrupt flags (re: interrupt status & acknowledge registers)
+ */
+#define VIRTIO_MMIO_INT_VRING		(1 << 0)
+#define VIRTIO_MMIO_INT_CONFIG		(1 << 1)
+
+#endif
diff --git a/plat/drivers/virtio/virtio_mmio.c b/plat/drivers/virtio/virtio_mmio.c
new file mode 100644
index 0000000..6716153
--- /dev/null
+++ b/plat/drivers/virtio/virtio_mmio.c
@@ -0,0 +1,480 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Jia He <justin.he@arm.com>
+ *
+ * Copyright (c) 2020, Arm Ltd. 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.
+ */
+
+#include <uk/config.h>
+#include <uk/arch/types.h>
+#include <errno.h>
+#include <string.h>
+#include <uk/alloc.h>
+#include <uk/print.h>
+#include <uk/plat/lcpu.h>
+#include <uk/plat/irq.h>
+#include <uk/bus.h>
+#include <uk/bitops.h>
+
+#include <platform_bus.h>
+#include <virtio/virtio_config.h>
+#include <virtio/virtio_bus.h>
+#include <virtio/virtqueue.h>
+#include <virtio/virtio_mmio.h>
+
+/* The alignment to use between consumer and producer parts of vring.
+ * Currently hardcoded to the page size. */
+#define VIRTIO_MMIO_VRING_ALIGN		__PAGE_SIZE
+
+static struct uk_alloc *a;
+struct virtio_mmio_device_id {
+	uint16_t device_id;
+	uint32_t vendor;
+};
+
+struct virtio_mmio_device {
+	struct virtio_dev vdev;
+	char *name;
+	struct virtio_mmio_device_id  id;
+	struct virtio_mmio_driver     *drv;
+	unsigned long version;
+	unsigned long irq;
+	void *base;
+	struct pf_device *pfdev;
+};
+
+#define to_virtio_mmio_device(_dev) \
+	__containerof(_dev, struct virtio_mmio_device, vdev)
+
+struct virtio_mmio_vq_info {
+	/* the actual virtqueue */
+	struct virtqueue *vq;
+};
+typedef void vq_callback_t(struct virtqueue *);
+
+/* Configuration interface */
+
+static __u64 vm_get_features(struct virtio_dev *vdev)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+	__u64 features = 0;
+
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 1);
+	features = virtio_cread32(vm_dev->base, VIRTIO_MMIO_DEVICE_FEATURES);
+	features <<= 32;
+
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 0);
+	features |= virtio_cread32(vm_dev->base, VIRTIO_MMIO_DEVICE_FEATURES);
+
+	return features;
+}
+
+static void vm_set_features(struct virtio_dev *vdev,
+					 __u64 features)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+
+	/* Give virtio_ring a chance to accept features. */
+	virtqueue_feature_negotiate(features);
+
+	/* Make sure there is are no mixed devices */
+	if (vm_dev->version == 2 &&
+		!uk_test_bit(VIRTIO_F_VERSION_1, &vdev->features)) {
+		uk_pr_err("New virtio-mmio devices (version 2) must provide VIRTIO_F_VERSION_1 feature!\n");
+		return;
+	}
+
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_DRIVER_FEATURES_SEL, 1);
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_DRIVER_FEATURES,
+						(__u32)(vdev->features >> 32));
+
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_DRIVER_FEATURES_SEL, 0);
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_DRIVER_FEATURES,
+						(__u32)vdev->features);
+
+	return;
+}
+
+static int vm_get(struct virtio_dev *vdev, __u16 offset,
+		   void *buf, __u32 len, __u8 type_len __unused)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+	void *base = vm_dev->base + VIRTIO_MMIO_CONFIG;
+	__u8 b;
+	__u16 w;
+	__u32 l;
+
+	if (vm_dev->version == 1) {
+		__u8 *ptr = buf;
+		unsigned i;
+
+		for (i = 0; i < len; i++)
+			ptr[i] = virtio_cread8(base, offset + i);
+		return len;
+	}
+
+	switch (len) {
+	case 1:
+		b = virtio_cread8(base, offset);
+		memcpy(buf, &b, sizeof b);
+		break;
+	case 2:
+		w = (virtio_cread16(base, offset));
+		memcpy(buf, &w, sizeof w);
+		break;
+	case 4:
+		l = (virtio_cread32(base, offset));
+		memcpy(buf, &l, sizeof l);
+		break;
+	case 8:
+		l = (virtio_cread32(base, offset));
+		memcpy(buf, &l, sizeof l);
+		l = (virtio_cread32(base, offset + sizeof l));
+		memcpy(buf + sizeof l, &l, sizeof l);
+		break;
+	default:
+		uk_pr_err("Not supported length(%d) for io read\n", len);
+		UK_BUG();
+	}
+
+	return len;
+}
+
+static int vm_set(struct virtio_dev *vdev, __u16 offset,
+		   const void *buf, __u32 len)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+	void *base = vm_dev->base + VIRTIO_MMIO_CONFIG;
+	__u8 b;
+	__u16 w;
+	__u32 l;
+
+	if (vm_dev->version == 1) {
+		const __u8 *ptr = buf;
+		__u32 i;
+
+		for (i = 0; i < len; i++)
+			virtio_cwrite8(base, offset + i, ptr[i]);
+		return 0;
+	}
+
+	switch (len) {
+	case 1:
+		memcpy(&b, buf, sizeof b);
+		virtio_cwrite8(base, offset, b);
+		break;
+	case 2:
+		memcpy(&w, buf, sizeof w);
+		virtio_cwrite16(base, offset, w);
+		break;
+	case 4:
+		memcpy(&l, buf, sizeof l);
+		virtio_cwrite32(base, offset, l);
+		break;
+	case 8:
+		memcpy(&l, buf, sizeof l);
+		virtio_cwrite32(base, offset, l);
+		memcpy(&l, buf + sizeof l, sizeof(l));
+		virtio_cwrite32(base, offset + sizeof l, l);
+		break;
+	default:
+		uk_pr_err("Not supported length(%d) for io write\n", len);
+		UK_BUG();
+	}
+
+	return 0;
+}
+
+static __u8 vm_get_status(struct virtio_dev *vdev)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+
+	return virtio_cread32(vm_dev->base, VIRTIO_MMIO_STATUS) & 0xff;
+}
+
+static void vm_set_status(struct virtio_dev *vdev, __u8 status)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+
+	/* We should never be setting status to 0. */
+	UK_BUGON(status == 0);
+
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_STATUS, status);
+}
+
+static void vm_reset(struct virtio_dev *vdev)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+
+	/* 0 status means a reset. */
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_STATUS, 0);
+}
+
+/* Transport interface */
+
+/* the notify function used when creating a virt queue */
+static int vm_notify(struct virtio_dev *vdev, __u16 queue_id)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+
+	/* We write the queue's selector into the notification register to
+	 * signal the other end */
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_NOTIFY, queue_id);
+	return 1;
+}
+
+/* Notify all virtqueues on an interrupt. */
+static int vm_interrupt(void *opaque)
+{
+	struct virtio_mmio_device *vm_dev = opaque;
+	unsigned long status;
+	unsigned long flags;
+	int rc = 0;
+	struct virtqueue *vq;
+
+	/* Read and acknowledge interrupts */
+	status = virtio_cread32(vm_dev->base, VIRTIO_MMIO_INTERRUPT_STATUS);
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_INTERRUPT_ACK, status);
+
+	if (unlikely(status & VIRTIO_MMIO_INT_CONFIG)) {
+		uk_pr_warn("Unsupported config change interrupt received on virtio-mmio device %p\n",
+			   vm_dev);
+	}
+
+	if (likely(status & VIRTIO_MMIO_INT_VRING)) {
+		flags = ukplat_lcpu_save_irqf();
+		UK_TAILQ_FOREACH(vq, &vm_dev->vdev.vqs, next) {
+			rc |= virtqueue_ring_interrupt(vq);
+		}
+		ukplat_lcpu_restore_irqf(flags);
+	}
+
+	return rc;
+}
+
+
+static struct virtqueue *vm_setup_vq(struct virtio_dev *vdev,
+					__u16 queue_id,
+					__u16 num_desc,
+					virtqueue_callback_t callback,
+					struct uk_alloc *a)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+	struct virtqueue *vq;
+	unsigned long flags;
+
+	/* Create the vring */
+	vq = virtqueue_create(queue_id, num_desc, VIRTIO_MMIO_VRING_ALIGN,
+			      callback, vm_notify, vdev, a);
+
+	if (PTRISERR(vq)) {
+		uk_pr_err("Failed to create the virtqueue: %d\n",
+			  PTR2ERR(vq));
+
+		goto err_exit;
+	}
+
+	/* Select the queue we're interested in */
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_SEL, queue_id);
+
+	/* Activate the queue */
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_NUM, (__u32)virtqueue_vring_get_num(vq));
+	if (vm_dev->version == 1) {
+
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_ALIGN, __PAGE_SIZE);
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_PFN,
+					virtqueue_physaddr(vq) >> __PAGE_SHIFT);
+	} else {
+		__u64 addr;
+		addr = virtqueue_physaddr(vq);
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_DESC_LOW, (__u32)addr);
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_DESC_HIGH,
+								(__u32)(addr >> 32));
+
+		addr = virtqueue_get_avail_addr(vq);
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_AVAIL_LOW, (__u32)addr);
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_AVAIL_HIGH,
+								(__u32)(addr >> 32));
+
+		addr =  virtqueue_get_used_addr(vq);
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_USED_LOW, (__u32)addr);
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_USED_HIGH,
+								(__u32)(addr >> 32));
+
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_READY, 1);
+	}
+
+	flags = ukplat_lcpu_save_irqf();
+	UK_TAILQ_INSERT_TAIL(&vm_dev->vdev.vqs, vq, next);
+	ukplat_lcpu_restore_irqf(flags);
+
+err_exit:
+	return vq;
+}
+
+static int vm_find_vqs(struct virtio_dev *vdev, __u16 num_vqs, __u16 *qdesc_size)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+	unsigned int irq = vm_dev->pfdev->irq;
+	int i, err;
+	int vq_cnt = 0;
+
+	err = ukplat_irq_register(irq, vm_interrupt, vm_dev);
+	if (err)
+		return err;
+
+	for (i = 0; i < num_vqs; ++i) {
+		/* Select the queue we're interested in */
+		virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_QUEUE_SEL, i);
+
+		/* Queue shouldn't already be set up. */
+		if (virtio_cread32(vm_dev->base, (vm_dev->version == 1 ?
+				VIRTIO_MMIO_QUEUE_PFN : VIRTIO_MMIO_QUEUE_READY))) {
+			uk_pr_err("vm_find_vqs error mmio queue not ready\n");
+			err = -ENOENT;
+			goto error_exit;
+		}
+
+		qdesc_size[i] = virtio_cread32(vm_dev->base, VIRTIO_MMIO_QUEUE_NUM_MAX);
+		if (qdesc_size[i] == 0) {
+			err = -ENOENT;
+			goto error_exit;
+		}
+
+		vq_cnt++;
+	}
+
+	return vq_cnt;
+error_exit:
+	uk_pr_err("err in vm_find_vqs :%d\n", err);
+	return err;
+}
+
+static struct virtio_config_ops virtio_mmio_config_ops = {
+	.config_get	= vm_get,
+	.config_set	= vm_set,
+	.status_get	= vm_get_status,
+	.status_set	= vm_set_status,
+	.device_reset	= vm_reset,
+	.features_get	= vm_get_features,
+	.features_set	= vm_set_features,
+	.vqs_find	= vm_find_vqs,
+	.vq_setup	= vm_setup_vq,
+};
+
+static int virtio_mmio_add_dev(struct pf_device *pfdev)
+{
+	struct virtio_mmio_device *vm_dev;
+	unsigned int magic;
+	int rc;
+
+	UK_ASSERT(pfdev != NULL);
+	uk_pr_info("virtio_mmio_add dev\n");
+
+	vm_dev = uk_malloc(a, sizeof(*vm_dev));
+	if (!vm_dev) {
+		uk_pr_err("Failed to allocate virtio-pci device\n");
+		return -ENOMEM;
+	}
+
+	/* Fetch Pf Device information */
+	vm_dev->pfdev = pfdev;
+	vm_dev->base = (void *)pfdev->base;
+	vm_dev->vdev.cops = &virtio_mmio_config_ops;
+	vm_dev->name = "virtio_mmio";
+
+	if (vm_dev->base == NULL)
+		return -EFAULT;
+
+	magic = virtio_cread32(vm_dev->base, VIRTIO_MMIO_MAGIC_VALUE);
+	if (magic != ('v' | 'i' << 8 | 'r' << 16 | 't' << 24)) {
+		uk_pr_err("Wrong magic value 0x%x!\n", magic);
+		return -ENODEV;
+	}
+
+	/* Check device version */
+	vm_dev->version = virtio_cread32(vm_dev->base, VIRTIO_MMIO_VERSION);
+	if (vm_dev->version < 1 || vm_dev->version > 2) {
+		uk_pr_err("Version %ld not supported!\n", vm_dev->version);
+		return -ENXIO;
+	}
+
+	vm_dev->vdev.id.virtio_device_id = virtio_cread32(vm_dev->base, VIRTIO_MMIO_DEVICE_ID);
+	if (vm_dev->vdev.id.virtio_device_id == 0) {
+		/*
+		 * virtio-mmio device with an ID 0 is a (dummy) placeholder
+		 * with no function. End probing now with no error reported.
+		 */
+		uk_pr_err("virtio_device_id is 0\n");
+
+		return -ENODEV;
+	}
+	vm_dev->id.vendor = virtio_cread32(vm_dev->base, VIRTIO_MMIO_VENDOR_ID);
+
+	virtio_cwrite32(vm_dev->base, VIRTIO_MMIO_GUEST_PAGE_SIZE, __PAGE_SIZE);
+
+	rc = virtio_bus_register_device(&vm_dev->vdev);
+	if (rc != 0) {
+		uk_pr_err("Failed to register the virtio device: %d\n", rc);
+		goto free_pf_dev;
+	}
+
+	uk_pr_info("finish add a virtio mmio dev\n");
+
+	return rc;
+
+free_pf_dev:
+	uk_free(a, vm_dev);
+
+	return 0;
+}
+
+static int virtio_mmio_drv_init(struct uk_alloc *drv_allocator)
+{
+	/* driver initialization */
+	if (!drv_allocator)
+		return -EINVAL;
+
+	a = drv_allocator;
+
+	return 0;
+}
+
+static const struct pf_device_id virtio_mmio_ids = {
+		.device_id = VIRTIO_MMIO_ID
+};
+
+static struct pf_driver virtio_mmio_drv = {
+	.device_ids = &virtio_mmio_ids,
+	.init = virtio_mmio_drv_init,
+	.add_dev = virtio_mmio_add_dev
+};
+
+PF_REGISTER_DRIVER(&virtio_mmio_drv);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:05 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY1t-00064A-CU; Fri, 29 May 2020 05:58: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY1r-00063Y-Vd
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:04 +0000
X-Inumbo-ID: 5bbd17c6-a171-11ea-81bc-bc764e2007e4
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTP
 id 5bbd17c6-a171-11ea-81bc-bc764e2007e4;
 Fri, 29 May 2020 05:58:03 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C5DBC55D;
 Thu, 28 May 2020 22:58:02 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B3FDE3F305;
 Thu, 28 May 2020 22:58:00 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 05/27] build: Enable the platform bus and
 virtio_mmio device on arm64
Date: Fri, 29 May 2020 13:56:55 +0800
Message-Id: <20200529055717.88063-6-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Enable the config for KVM_PF and add virtio mmio to the build system.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/kvm/Config.uk   | 12 ++++++++++--
 plat/kvm/Makefile.uk | 12 ++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/plat/kvm/Config.uk b/plat/kvm/Config.uk
index 3372b6c..9540feb 100644
--- a/plat/kvm/Config.uk
+++ b/plat/kvm/Config.uk
@@ -73,10 +73,18 @@ config KVM_PCI
        help
                 PCI bus driver for probing and operating PCI devices
 
+config KVM_PF
+       bool "Platform Bus Driver"
+       default y
+       depends on (ARCH_ARM_64)
+       select LIBUKBUS
+       help
+               Platform bus driver for probing and operating platform devices
+
 config VIRTIO_BUS
       bool  "Virtio bus driver"
       default y
-      depends on (ARCH_X86_64)
+      depends on (ARCH_X86_64 || ARCH_ARM_64)
       depends on LIBUKBUS
       select LIBUKALLOC
       select LIBUKSGLIST
@@ -100,7 +108,7 @@ config VIRTIO_NET
        default n
        depends on LIBUKNETDEV
        imply VIRTIO_PCI if ARCH_X86_64
-       select VIRTIO_BUS
+       select VIRTIO
        select LIBUKSGLIST
        help
               Virtual network driver.
diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
index 94321e0..7b12b1a 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -8,6 +8,7 @@ $(eval $(call addplat_s,kvm,$(CONFIG_PLAT_KVM)))
 ##
 $(eval $(call addplatlib,kvm,libkvmplat))
 $(eval $(call addplatlib_s,kvm,libkvmpci,$(CONFIG_KVM_PCI)))
+$(eval $(call addplatlib_s,kvm,libkvmpf,$(CONFIG_KVM_PF)))
 $(eval $(call addplatlib_s,kvm,libkvmvirtio,$(CONFIG_VIRTIO_BUS)))
 $(eval $(call addplatlib_s,kvm,libkvmvirtionet,$(CONFIG_VIRTIO_NET)))
 $(eval $(call addplatlib_s,kvm,libkvmvirtioblk,$(CONFIG_VIRTIO_BLK)))
@@ -114,6 +115,15 @@ LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_X86_64)   += -I$(LIBKVMPLAT_BASE)/include
 LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_X86_64)   += -I$(UK_PLAT_COMMON_BASE)/include
 LIBKVMPCI_SRCS-$(CONFIG_ARCH_X86_64)        += $(UK_PLAT_COMMON_BASE)/pci_bus.c|common
 
+##
+## Platform bus library definitions
+##
+LIBKVMPF_ASINCLUDES-$(CONFIG_ARCH_ARM_64)  += -I$(UK_PLAT_COMMON_BASE)/include
+LIBKVMPF_CINCLUDES-$(CONFIG_ARCH_ARM_64)   += -I$(UK_PLAT_COMMON_BASE)/include
+LIBKVMPF_CINCLUDES-$(CONFIG_ARCH_ARM_64)   += -I$(LIBKVMPLAT_BASE)/include
+LIBKVMPF_CINCLUDES-$(CONFIG_ARCH_ARM_64)   += -I$(UK_PLAT_DRIVERS_BASE)/include
+LIBKVMPF_SRCS-$(CONFIG_ARCH_ARM_64) += $(UK_PLAT_COMMON_BASE)/platform_bus.c|common
+
 ##
 ## Virtio library definitions
 ##
@@ -129,6 +139,8 @@ LIBKVMVIRTIO_SRCS-$(CONFIG_VIRTIO_BUS) +=\
 			$(UK_PLAT_DRIVERS_BASE)/virtio/virtio_ring.c
 LIBKVMVIRTIO_SRCS-$(CONFIG_VIRTIO_PCI) +=\
 			$(UK_PLAT_DRIVERS_BASE)/virtio/virtio_pci.c
+LIBKVMVIRTIO_SRCS-$(CONFIG_ARCH_ARM_64)	+=\
+			$(UK_PLAT_DRIVERS_BASE)/virtio/virtio_mmio.c
 ##
 ## Virtio Net library definition
 ##
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:09 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY1x-00065P-Dq; Fri, 29 May 2020 05:58: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY1w-000653-7S
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:08 +0000
X-Inumbo-ID: 5d4a3bb4-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 5d4a3bb4-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:05 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5DC4A55D;
 Thu, 28 May 2020 22:58:05 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4CD6A3F305;
 Thu, 28 May 2020 22:58:03 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 06/27] plat/kvm: arm64: Fix arm64 memory layout
 for pcie ecam
Date: Fri, 29 May 2020 13:56:56 +0800
Message-Id: <20200529055717.88063-7-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

In previous memory layout, it doesn't consider the device memory type
for pci ecam controller. This patch creates pci ecam device memory
started from 0x40,0000,0000 for pci config space on arm64.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/include/arm/arm64/cpu_defs.h |  3 +++
 plat/kvm/arm/pagetable64.S               | 22 +++++++++++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/plat/common/include/arm/arm64/cpu_defs.h b/plat/common/include/arm/arm64/cpu_defs.h
index 675b9e6..06c07b9 100644
--- a/plat/common/include/arm/arm64/cpu_defs.h
+++ b/plat/common/include/arm/arm64/cpu_defs.h
@@ -302,6 +302,9 @@
 		(SECT_ATTR_DEFAULT | ATTR_UXN | \
 		ATTR_AP_RW_BIT | ATTR_IDX(NORMAL_WB))
 #define SECT_ATTR_DEVICE_nGnRE	\
+		(SECT_ATTR_DEFAULT | ATTR_XN | \
+		ATTR_IDX(DEVICE_nGnRE))
+#define SECT_ATTR_DEVICE_nGnRnE	\
 		(SECT_ATTR_DEFAULT | ATTR_XN | \
 		ATTR_IDX(DEVICE_nGnRnE))
 
diff --git a/plat/kvm/arm/pagetable64.S b/plat/kvm/arm/pagetable64.S
index 7899c19..1c2a349 100644
--- a/plat/kvm/arm/pagetable64.S
+++ b/plat/kvm/arm/pagetable64.S
@@ -48,10 +48,11 @@
 #define RAM_ADDR_START    0x40000000
 #define RAM_L2_ENTRIES    255
 #define RAM_ADDR_SIZE     (0x40000000 * RAM_L2_ENTRIES)
+#define PCIE_ECAM_START   0x4000000000
+#define PCIE_ECAM_L2_ENTRIES 256
 #define PCIE_ADDR_START   0x8000000000
 #define PCIE_L2_ENTRIES   512
 #define PCIE_ADDR_SIZE    0x8000000000
-
 /*
  * As we use VA == PA mapping, so the VIRT_BITS must be the same
  * as PA_BITS. We can get PA_BITS from ID_AA64MMFR0_EL1.PARange.
@@ -96,23 +97,34 @@ ENTRY(create_pagetables)
 	 * (0x40000000 ~ (256GiB -1)). The RAM areas that contain kernel
 	 * sections will be update later.
 	 */
-	add x6, x14, #L1_TABLE_OFFSET
+	add x6, x14, #L1_TABLE_OFFSET	/* 1st L2 table page */
 	ldr x7, =SECT_ATTR_NORMAL
 	mov x8, #RAM_ADDR_START
 	mov x9, x8
-	mov x10, #255
+	mov x10, #RAM_L2_ENTRIES
 	bl  build_l1_block_pagetable
 
+        /*
+         * Using 1GiB block to map PCIe ECAM address space
+         * (256GiB ~ 512GiB).
+         */
+        add x6, x14, #L1_TABLE_OFFSET	/* 1st L2 table page */
+        ldr x7, =SECT_ATTR_DEVICE_nGnRnE
+        mov x8, #PCIE_ECAM_START
+        mov x9, x8
+        mov x10, #PCIE_ECAM_L2_ENTRIES
+        bl  build_l1_block_pagetable
+
 	/*
 	 * Using 1GiB block to map high PCIe address space
 	 * (0x512GiB ~ (1TiB -1)).
 	 */
 	add x6, x14, #L1_TABLE_OFFSET
-	add x6, x6, #__PAGE_SIZE
+	add x6, x6, #__PAGE_SIZE	/* 2nd L2 table page */
 	ldr x7, =SECT_ATTR_DEVICE_nGnRE
 	mov x8, #PCIE_ADDR_START
 	mov x9, x8
-	mov x10, #512
+	mov x10, #PCIE_L2_ENTRIES
 	bl  build_l1_block_pagetable
 
 	/*
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:14 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58:14 +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 1jeY22-00066l-FQ; Fri, 29 May 2020 05:58: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY21-00066Z-7g
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:13 +0000
X-Inumbo-ID: 5ec3a5a2-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 5ec3a5a2-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:08 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E987B55D;
 Thu, 28 May 2020 22:58:07 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D91AF3F959;
 Thu, 28 May 2020 22:58:05 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 07/27] plat/ofw: Export
 fdt_find_irq_parent_offset
Date: Fri, 29 May 2020 13:56:57 +0800
Message-Id: <20200529055717.88063-8-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This changes fdt_find_irq_parent_offset from static to extern for pci ecam
to use.

Signed-off-by: Jia He <justin.he@arm.com>
---
 lib/fdt/exportsyms.uk          |  1 +
 plat/drivers/include/ofw/fdt.h | 21 +++++++++++++++++++++
 plat/drivers/ofw/fdt.c         |  2 +-
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/lib/fdt/exportsyms.uk b/lib/fdt/exportsyms.uk
index d64d9dc..a2e9ea8 100644
--- a/lib/fdt/exportsyms.uk
+++ b/lib/fdt/exportsyms.uk
@@ -61,3 +61,4 @@ fdt_stringlist_contains
 fdt_resize
 fdt_overlay_apply
 fdt_getprop_u32_by_offset
+fdt_find_irq_parent_offset
\ No newline at end of file
diff --git a/plat/drivers/include/ofw/fdt.h b/plat/drivers/include/ofw/fdt.h
index 6f80a27..8826845 100644
--- a/plat/drivers/include/ofw/fdt.h
+++ b/plat/drivers/include/ofw/fdt.h
@@ -37,6 +37,27 @@
 
 #define FDT_BAD_ADDR (uint64_t)(-1)
 
+/**
+ * fdt_find_irq_parent_offset - find the irq parent offset
+ * @fdt: pointer to the device tree blob
+ * @phandle: phandle value
+ *
+ * fdt_node_offset_by_phandle() returns the offset of the node
+ * which has the given phandle value.  If there is more than one node
+ * in the tree with the given phandle (an invalid tree), results are
+ * undefined.
+ *
+ * returns:
+ *	structure block offset of the located node (>= 0), on success
+ *	-FDT_ERR_NOTFOUND, no node with that phandle exists
+ *	-FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)
+ *	-FDT_ERR_BADMAGIC,
+ *	-FDT_ERR_BADVERSION,
+ *	-FDT_ERR_BADSTATE,
+ *	-FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_find_irq_parent_offset(const void *fdt, int offset);
+
 /**
  * fdt_interrupt_cells - retrieve the number of cells needed to encode an
  *                       interrupt source
diff --git a/plat/drivers/ofw/fdt.c b/plat/drivers/ofw/fdt.c
index 76f8ff3..c097331 100644
--- a/plat/drivers/ofw/fdt.c
+++ b/plat/drivers/ofw/fdt.c
@@ -44,7 +44,7 @@
 #define FDT_CHECK_COUNTS(na, ns)  ((na) > 0 && (na) <= FDT_MAX_ADDR_CELLS && \
 					(ns) > 0)
 
-static int fdt_find_irq_parent_offset(const void *fdt, int offset)
+int fdt_find_irq_parent_offset(const void *fdt, int offset)
 {
 	uint32_t irq_parent;
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:19 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY27-00067b-Gp; Fri, 29 May 2020 05:58: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY26-00067P-7d
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:18 +0000
X-Inumbo-ID: 603d2854-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 603d2854-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:10 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 81CBD55D;
 Thu, 28 May 2020 22:58:10 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 710F43F305;
 Thu, 28 May 2020 22:58:08 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 08/27] plat/pci_ecam: Introduce pci/pci_ecam.h
Date: Fri, 29 May 2020 13:56:58 +0800
Message-Id: <20200529055717.88063-9-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

On arm64. we use a special generic pci controller, currently it
supports ECAM mode only on arm64 kvm plat.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/include/pci/pci_ecam.h | 101 +++++++++++++++++++++++++++++
 1 file changed, 101 insertions(+)
 create mode 100644 plat/common/include/pci/pci_ecam.h

diff --git a/plat/common/include/pci/pci_ecam.h b/plat/common/include/pci/pci_ecam.h
new file mode 100644
index 0000000..f325a14
--- /dev/null
+++ b/plat/common/include/pci/pci_ecam.h
@@ -0,0 +1,101 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Jia He <justin.he@arm.com>
+ *
+ * Copyright (c) 2020, Arm Ltd. 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.
+ */
+
+
+#ifndef _PCI_ECAM_H
+#define _PCI_ECAM_H
+
+#include <uk/arch/types.h>
+#include <uk/list.h>
+#include <pci/pci_bus.h>
+#include <platform_bus.h>
+
+/*
+ * struct to hold bus shift of the config window
+ * for a PCI controller.
+ */
+struct pci_ecam_ops {
+	unsigned int			bus_shift;
+};
+
+/*
+ * struct to hold the mappings of a config space window. This
+ * is expected to be used for PCI controllers that
+ * use ECAM.
+ */
+struct bus_range {
+	__u8			bus_start;
+	__u8			bus_end;
+};
+
+struct pci_config_window {
+	__phys_addr		config_base;
+	__u64			config_space_size;
+	struct bus_range br;
+	struct pci_ecam_ops		*ops;
+	__phys_addr		pci_device_base;
+	__u64			pci_device_limit;
+};
+
+struct fdt_phandle_args {
+	int np;
+	int args_count;
+	uint32_t args[16];
+};
+
+/*
+ * IO resources have these defined flags.
+ *
+ * PCI devices expose these flags to userspace in the "resource" sysfs file,
+ * so don't move them.
+ */
+#define IORESOURCE_BITS		0x000000ff	/* Bus-specific bits */
+
+#define IORESOURCE_TYPE_BITS	0x00001f00	/* Resource type */
+#define IORESOURCE_IO		0x00000100	/* PCI/ISA I/O ports */
+#define IORESOURCE_MEM		0x00000200
+#define IORESOURCE_REG		0x00000300	/* Register offsets */
+#define IORESOURCE_IRQ		0x00000400
+#define IORESOURCE_DMA		0x00000800
+#define IORESOURCE_BUS		0x00001000
+
+
+int pci_generic_config_read(__u8 bus, __u8 devfn,
+			    int where, int size, __u32 *val);
+
+int pci_generic_config_write(__u8 bus, __u8 devfn,
+			     int where, int size, __u32 val);
+
+extern struct pf_driver gen_pci_driver;
+#endif
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY2C-00069C-IR; Fri, 29 May 2020 05:58:24 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2B-000691-7k
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:23 +0000
X-Inumbo-ID: 61c6a678-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 61c6a678-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:13 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1A4AA55D;
 Thu, 28 May 2020 22:58:13 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 092613F305;
 Thu, 28 May 2020 22:58:10 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 09/27] plat/pci_ecam: Introduce pci ecam
 skeleton
Date: Fri, 29 May 2020 13:56:59 +0800
Message-Id: <20200529055717.88063-10-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This patch adds support for a generic PCI host controller. The controller
itself has no configuration registers and has its address spaces described
entirely by the device-tree. Currently, only ECAM is supported.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/pci_ecam.c | 524 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 524 insertions(+)
 create mode 100644 plat/common/pci_ecam.c

diff --git a/plat/common/pci_ecam.c b/plat/common/pci_ecam.c
new file mode 100644
index 0000000..b97a580
--- /dev/null
+++ b/plat/common/pci_ecam.c
@@ -0,0 +1,524 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Jia He <justin.he@arm.com>
+ *
+ * Copyright (c) 2018, Arm Ltd. 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.
+ */
+
+#include <stdbool.h>
+#include <pci/pci_ecam.h>
+#include <platform_bus.h>
+#include <uk/list.h>
+#include <uk/alloc.h>
+#include <uk/print.h>
+#include <kvm/config.h>
+#include <uk/plat/common/cpu.h>
+#include <libfdt_env.h>
+#include <ofw/fdt.h>
+#include <libfdt.h>
+
+static struct uk_alloc *a;
+static struct pci_ecam_ops pci_generic_ecam_ops;
+static const struct device_match_table gen_pci_match_table[];
+
+struct pci_config_window pcw = {
+	.ops = &pci_generic_ecam_ops
+};
+
+struct pci_range_parser {
+	int offset;		/*  in fdt */
+	const fdt32_t *range;	/* start offset in offset */
+	const fdt32_t *end;	/* end offset in offset */
+	int np;			/* number of property */
+	int pna;		/* parent number of address cell */
+};
+
+struct pci_range {
+	__u32 pci_space;
+	__u64 pci_addr;
+	__u64 cpu_addr;
+	__u64 size;
+	__u32 flags;
+};
+
+#define fdt_start (_libkvmplat_cfg.dtb)
+
+static int gen_pci_fdt; // start offset of pci-ecam in fdt
+/*
+ * Function to implement the pci_ops ->map_bus method
+ */
+static void *pci_ecam_map_bus(__u8 bus, __u8 devfn, int where)
+{
+	__u8 bus_shift = pcw.ops->bus_shift;
+	__u8 devfn_shift = bus_shift - 8;
+	__u8 bus_start = pcw.br.bus_start;
+	__u8 bus_end = pcw.br.bus_end;
+	void *base = (void *)pcw.config_base;
+
+	if (bus < bus_start || bus > bus_end)
+		return NULL;
+
+	return base + (bus << bus_shift) + (devfn << devfn_shift) + where;
+}
+
+int pci_generic_config_read(__u8 bus, __u8 devfn,
+			    int where, int size, __u32 *val)
+{
+	void *addr;
+
+	/* add rmb before io read */
+	rmb();
+	addr = pci_ecam_map_bus(bus, devfn, where);
+	if (!addr) {
+		*val = ~0;
+		return -1;
+	}
+
+	if (size == 1)
+		*val = ioreg_read8(addr);
+	else if (size == 2)
+		*val = ioreg_read16(addr);
+	else if (size == 4)
+		*val = ioreg_read32(addr);
+	else
+		uk_pr_err("not support size pci config read\n");
+
+	return 0;
+}
+
+int pci_generic_config_write(__u8 bus, __u8 devfn,
+			     int where, int size, __u32 val)
+{
+	void *addr;
+	__u32 mask, tmp;
+
+	addr = pci_ecam_map_bus(bus, devfn, where);
+	if (!addr)
+		return -1;
+
+	if (size == 1)
+		ioreg_write8(addr, val);
+	else if (size == 2)
+		ioreg_write16(addr, val);
+	else if (size == 4)
+		ioreg_write32(addr, val);
+	else
+		uk_pr_err("not support size pci config write\n");
+
+	/* add wmb after io write */
+	wmb();
+
+	return 0;
+}
+
+/* ECAM cfg */
+static struct pci_ecam_ops pci_generic_ecam_ops = {
+	.bus_shift	= 20
+};
+
+static unsigned int pci_get_flags(const fdt32_t *addr)
+{
+	unsigned int flags = 0;
+	__u32 w = fdt32_to_cpu(*addr);
+
+	/* only IORESOURCE_IO is supported currently */
+	switch ((w >> 24) & 0x03) {
+	case 0x01:
+		flags |= IORESOURCE_IO;
+		break;
+	case 0x02: /* 32 bits */
+	case 0x03: /* 64 bits */
+	default:
+		uk_pr_err("only supported pci ioresource flags\n");
+		break;
+	}
+
+	return flags;
+}
+
+static int gen_pci_parser_range(struct pci_range_parser *parser, int offset)
+{
+	const int na = 3, ns = 2;
+	int rlen;
+
+	parser->pna = fdt_address_cells(fdt_start, offset);
+	parser->np = parser->pna + na + ns;
+	parser->range = fdt_getprop(fdt_start, offset, "ranges", &rlen);
+	if (parser->range == NULL)
+		return -ENOENT;
+
+	parser->end = parser->range + rlen / sizeof(fdt32_t);
+
+	return 0;
+}
+
+struct pci_range *pci_range_parser_one(struct pci_range_parser *parser,
+					struct pci_range *range, int offset)
+{
+	const int na = 3, ns = 2; /* address and size */
+
+	if (!range)
+		return NULL;
+
+	if (!parser->range || parser->range + parser->np > parser->end)
+		return NULL;
+
+	range->pci_space = fdt32_to_cpu(*parser->range);
+	range->flags = pci_get_flags(parser->range);
+	range->pci_addr = fdt_reg_read_number(parser->range + 1, ns);
+	range->cpu_addr = fdt_translate_address_by_ranges(fdt_start, offset,
+				parser->range + na);
+	range->size = fdt_reg_read_number(parser->range + parser->pna + na, ns);
+
+	parser->range += parser->np;
+
+	return range;
+}
+
+static int irq_find_parent(const void *fdt, int child)
+{
+	int p;
+	int plen;
+	fdt32_t *prop;
+	fdt32_t parent;
+
+	do {
+		prop = fdt_getprop(fdt, child, "interrupt-parent", &plen);
+		if (prop == NULL) {
+			p = fdt_parent_offset(fdt, child);
+		} else	{
+			parent = fdt32_to_cpu(prop[0]);
+			p = fdt_node_offset_by_phandle(fdt, parent);
+		}
+		child = p;
+	} while (p >= 0 && fdt_getprop(fdt, p, "#interrupt-cells", NULL) == NULL);
+
+	return p;
+}
+
+int gen_pci_irq_parse(const fdt32_t *addr, struct fdt_phandle_args *out_irq)
+{
+	int ipar, tnode, old = 0, newpar = 0;
+	fdt32_t initial_match_array[16];
+	const fdt32_t *match_array = initial_match_array;
+	const fdt32_t *tmp, *imap, *imask;
+	const fdt32_t dummy_imask[] = { [0 ... 16] = cpu_to_fdt32(~0) };
+	int intsize, newintsize;
+	int addrsize, newaddrsize = 0;
+	int imaplen, match, i, rc = -EINVAL;
+	int plen;
+	int *prop;
+
+	ipar = gen_pci_fdt;
+
+	/* First get the #interrupt-cells property of the current cursor
+	 * that tells us how to interpret the passed-in intspec. If there
+	 * is none, we are nice and just walk up the tree
+	 */
+	do {
+		prop = fdt_getprop(fdt_start, ipar, "#interrupt-cells", &plen);
+		if (prop != NULL)
+			break;
+		ipar = irq_find_parent(fdt_start, ipar);
+	} while (ipar >= 0);
+
+	if (ipar < 0) {
+		uk_pr_info(" -> no parent found !\n");
+		goto fail;
+	}
+
+	intsize = fdt32_to_cpu(prop[0]);
+	uk_pr_info("irq_parse_raw: ipar=%p, size=%d\n", ipar, intsize);
+
+	if (out_irq->args_count != intsize)
+		goto fail;
+
+	/* Look for this #address-cells. We have to implement the old linux
+	 * trick of looking for the parent here as some device-trees rely on it
+	 */
+	old = ipar;
+	do {
+		tmp = fdt_getprop(fdt_start, old, "#address-cells", NULL);
+		tnode = fdt_parent_offset(fdt_start, old);
+		old = tnode;
+	} while (old >= 0 && tmp == NULL);
+
+	old = 0;
+	addrsize = (tmp == NULL) ? 2 : fdt32_to_cpu(*tmp);
+	uk_pr_info(" -> addrsize=%d\n", addrsize);
+
+	/* Precalculate the match array - this simplifies match loop */
+	for (i = 0; i < addrsize; i++)
+		initial_match_array[i] = addr ? addr[i] : 0;
+	for (i = 0; i < intsize; i++)
+		initial_match_array[addrsize + i] = cpu_to_fdt32(out_irq->args[i]);
+
+	/* Now start the actual "proper" walk of the interrupt tree */
+	while (ipar >= 0) {
+		/* Now check if cursor is an interrupt-controller and if it is
+		 * then we are done
+		 */
+		if (fdt_prop_read_bool(fdt_start, ipar, "interrupt-controller")) {
+			uk_pr_info(" -> got it !\n");
+			return 0;
+		}
+
+		/*
+		 * interrupt-map parsing does not work without a reg
+		 * property when #address-cells != 0
+		 */
+		if (addrsize && !addr) {
+			uk_pr_info(" -> no reg passed in when needed !\n");
+			goto fail;
+		}
+
+		/* Now look for an interrupt-map */
+		imap = fdt_getprop(fdt_start, ipar, "interrupt-map", &imaplen);
+		/* No interrupt map, check for an interrupt parent */
+		if (imap == NULL) {
+			uk_pr_info(" -> no map, getting parent\n");
+			newpar = irq_find_parent(fdt_start, ipar);
+			goto skiplevel;
+		}
+		imaplen /= sizeof(__u32);
+
+		/* Look for a mask */
+		imask = fdt_getprop(fdt_start, ipar, "interrupt-map-mask", NULL);
+		if (!imask)
+			imask = dummy_imask;
+
+		/* Parse interrupt-map */
+		match = 0;
+		while (imaplen > (addrsize + intsize + 1) && !match) {
+			/* Compare specifiers */
+			match = 1;
+			for (i = 0; i < (addrsize + intsize); i++, imaplen--)
+				match &= !((match_array[i] ^ *imap++) & imask[i]);
+
+			uk_pr_info(" -> match=%d (imaplen=%d)\n", match, imaplen);
+
+			/* Get the interrupt parent */
+			newpar = fdt_node_offset_by_phandle(fdt_start, fdt32_to_cpu(*imap));
+			imap++;
+			--imaplen;
+
+			/* Check if not found */
+			if (newpar < 0) {
+				uk_pr_info(" -> imap parent not found !\n");
+				goto fail;
+			}
+
+			/* Get #interrupt-cells and #address-cells of new
+			 * parent
+			 */
+			prop = fdt_getprop(fdt_start, newpar, "#interrupt-cells",
+						 &plen);
+			if (prop == NULL) {
+				uk_pr_info(" -> parent lacks #interrupt-cells!\n");
+				goto fail;
+			}
+			newintsize = fdt32_to_cpu(prop[0]);
+
+			prop = fdt_getprop(fdt_start, newpar, "#address-cells",
+						 &plen);
+			if (prop == NULL) {
+				uk_pr_info(" -> parent lacks #address-cells!\n");
+				goto fail;
+			}
+			newaddrsize = fdt32_to_cpu(prop[0]);
+
+			uk_pr_debug(" -> newintsize=%d, newaddrsize=%d\n",
+			    newintsize, newaddrsize);
+
+			/* Check for malformed properties */
+			if ((newaddrsize + newintsize > 16)
+			    || (imaplen < (newaddrsize + newintsize))) {
+				rc = -EFAULT;
+				goto fail;
+			}
+
+			imap += newaddrsize + newintsize;
+			imaplen -= newaddrsize + newintsize;
+
+			uk_pr_info(" -> imaplen=%d\n", imaplen);
+		}
+		if (!match)
+			goto fail;
+
+		/*
+		 * Successfully parsed an interrrupt-map translation; copy new
+		 * interrupt specifier into the out_irq structure
+		 */
+		match_array = imap - newaddrsize - newintsize;
+		for (i = 0; i < newintsize; i++)
+			out_irq->args[i] = fdt32_to_cpu(*(imap - newintsize + i));
+		out_irq->args_count = intsize = newintsize;
+		addrsize = newaddrsize;
+
+skiplevel:
+		/* Iterate again with new parent */
+		out_irq->np = newpar;
+		uk_pr_info(" -> new parent: %pOF\n", newpar);
+
+		ipar = newpar;
+		newpar = 0;
+	}
+
+	rc = -ENOENT; /* No interrupt-map found */
+
+fail:
+	return rc;
+}
+
+
+static int gen_pci_probe(struct pf_device *pfdev)
+{
+	const fdt32_t *prop;
+	int prop_len;
+	__u64 reg_base;
+	__u64 reg_size;
+	int err;
+	struct pci_range range;
+	struct pci_range_parser parser;
+	struct fdt_phandle_args out_irq;
+	fdt32_t laddr[3];
+
+	/* 1.Get the base and size of config space */
+	gen_pci_fdt = fdt_node_offset_by_compatible(fdt_start, -1,
+						gen_pci_match_table[0].compatible);
+	if (gen_pci_fdt < 0) {
+		uk_pr_info("Error in searching pci controller in fdt\n");
+		goto error_exit;
+	} else {
+		prop = fdt_getprop(fdt_start, gen_pci_fdt, "reg", &prop_len);
+		if (!prop) {
+			uk_pr_err("reg of device not found in fdt\n");
+			goto error_exit;
+		}
+
+		/* Get the base addr and the size */
+		fdt_get_address(fdt_start, gen_pci_fdt, 0,
+					&reg_base, &reg_size);
+		reg_base = fdt32_to_cpu(prop[0]);
+		reg_base = reg_base << 32 | fdt32_to_cpu(prop[1]);
+		reg_size = fdt32_to_cpu(prop[2]);
+		reg_size = reg_size << 32 | fdt32_to_cpu(prop[3]);
+	}
+
+	pcw.config_base = reg_base;
+	pcw.config_space_size = reg_size;
+	uk_pr_info("generic pci config base(0x%llx),size(0x%llx)\n",
+				reg_base, reg_size);
+
+	/* 2.Get the bus range of pci controller */
+	prop = fdt_getprop(fdt_start, gen_pci_fdt, "bus-range", &prop_len);
+	if (!prop) {
+		uk_pr_err("bus-range of device not found in fdt\n");
+		goto error_exit;
+	}
+
+	pcw.br.bus_start = fdt32_to_cpu(prop[0]);
+	pcw.br.bus_end = fdt32_to_cpu(prop[1]);
+	uk_pr_info("generic pci bus start(%d),end(%d)\n",
+				pcw.br.bus_start, pcw.br.bus_end);
+
+	if (pcw.br.bus_start > pcw.br.bus_end) {
+		uk_pr_err("bus-range detect error in fdt\n");
+		goto error_exit;
+	}
+
+	/* 3.Get the pci addr base and limit size for pci devices */
+	err = gen_pci_parser_range(&parser, gen_pci_fdt);
+	do {
+		pci_range_parser_one(&parser, &range, gen_pci_fdt);
+		if (range.flags == IORESOURCE_IO) {
+			pcw.pci_device_base = range.cpu_addr;
+			pcw.pci_device_limit = range.size;
+			break;
+		}
+		parser.range += parser.np;
+	} while (parser.range + parser.np <= parser.end);
+	uk_pr_info("generic pci range base(0x%llx),size(0x%llx)\n",
+				pcw.pci_device_base, pcw.pci_device_limit);
+
+	return 0;
+
+error_exit:
+	return -ENODEV;
+}
+
+static int gen_pci_drv_init(struct uk_alloc *drv_allocator)
+{
+	/* driver initialization */
+	if (!drv_allocator)
+		return -EINVAL;
+
+	a = drv_allocator;
+
+	return 0;
+}
+
+static int gen_pci_add_dev(struct pf_device *pfdev __unused)
+{
+	return 0;
+}
+
+static const struct device_match_table gen_pci_match_table[];
+
+static struct pf_device_id *gen_pci_id_match_compatible(const char *compatible)
+{
+	int i;
+
+	for (int i = 0; gen_pci_match_table[i].compatible != NULL; i++)
+		if (strcmp(gen_pci_match_table[i].compatible, compatible) == 0)
+			return gen_pci_match_table[i].id;
+
+	return NULL;
+}
+
+static const struct pf_device_id gen_pci_ids = {
+		.device_id = GEN_PCI_ID
+};
+
+struct pf_driver gen_pci_driver = {
+	.device_ids = &gen_pci_ids,
+	.init = gen_pci_drv_init,
+	.probe = gen_pci_probe,
+	.add_dev = gen_pci_add_dev,
+	.match = gen_pci_id_match_compatible
+};
+
+static const struct device_match_table gen_pci_match_table[] = {
+	{ .compatible = "pci-host-ecam-generic",
+	  .id = &gen_pci_ids },
+	{NULL}
+};
+
+PF_REGISTER_DRIVER(&gen_pci_driver);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:27 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58:27 +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 1jeY2F-0006A8-Kt; Fri, 29 May 2020 05:58:27 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2E-00069t-Vf
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:27 +0000
X-Inumbo-ID: 698611f0-a171-11ea-81bc-bc764e2007e4
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTP
 id 698611f0-a171-11ea-81bc-bc764e2007e4;
 Fri, 29 May 2020 05:58:26 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EEE0455D;
 Thu, 28 May 2020 22:58:25 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DE6243F305;
 Thu, 28 May 2020 22:58:23 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 14/27] plat/ofw: Support completed ranges
 mapping
Date: Fri, 29 May 2020 13:57:04 +0800
Message-Id: <20200529055717.88063-15-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Previously, we only support 1:1 mapping for ranges property. This
is not enough for pci ecam on arm64.
e.g.
pcie@10000000 {
		interrupt-map-mask = < 0x1800 0x00 0x00 0x07 >;
		interrupt-map = < ... >;
		#interrupt-cells = < 0x01 >;
		ranges = < 0x1000000 0x00 0x00 0x00 0x3eff0000 0x00 0x10000 0x2000000 0x00 0x10000000 0x00 0x10000000 0x00 0x2eff0000 0x3000000 0x80 0x00 0x80 0x00 0x80 0x00 >;
		reg = < 0x40 0x10000000 0x00 0x10000000 >;
		msi-parent = < 0x8002 >;
		dma-coherent;
		bus-range = < 0x00 0xff >;
		linux,pci-domain = < 0x00 >;
		#size-cells = < 0x02 >;
		#address-cells = < 0x03 >;
		device_type = "pci";
		compatible = "pci-host-ecam-generic";
	};

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/ofw/fdt.c | 46 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 7 deletions(-)

diff --git a/plat/drivers/ofw/fdt.c b/plat/drivers/ofw/fdt.c
index 30ac270..780b8dd 100644
--- a/plat/drivers/ofw/fdt.c
+++ b/plat/drivers/ofw/fdt.c
@@ -97,6 +97,24 @@ static void fdt_default_count_cells(const void *fdt, int parentoffset,
 		*sizec = fdt_size_cells(fdt, parentoffset);
 }
 
+static __u64 fdt_default_map(fdt32_t *addr, const fdt32_t *range,
+		int na, int ns, int pna)
+{
+	__u64 cp, s, da;
+
+	cp = fdt_reg_read_number(range, na);
+	s  = fdt_reg_read_number(range + na + pna, ns);
+	da = fdt_reg_read_number(addr, na);
+
+	uk_pr_debug("default map, cp=%llx, s=%llx, da=%llx\n",
+		 (unsigned long long)cp, (unsigned long long)s,
+		 (unsigned long long)da);
+
+	if (da < cp || da >= (cp + s))
+		return FDT_BAD_ADDR;
+	return da - cp;
+}
+
 static int fdt_default_translate(fdt32_t *addr, uint64_t offset, int na)
 {
 	uint64_t a = fdt_reg_read_number(addr, na);
@@ -111,10 +129,11 @@ static int fdt_default_translate(fdt32_t *addr, uint64_t offset, int na)
 }
 
 static int fdt_translate_one(const void *fdt, int parent, fdt32_t *addr,
-				    int na, int pna, const char *rprop)
+				int na, int ns, int pna, const char *rprop)
 {
 	const fdt32_t *ranges;
 	int rlen;
+	int rone;
 	uint64_t offset = FDT_BAD_ADDR;
 
 	ranges = fdt_getprop(fdt, parent, rprop, &rlen);
@@ -126,10 +145,23 @@ static int fdt_translate_one(const void *fdt, int parent, fdt32_t *addr,
 		goto finish;
 	}
 
-	uk_pr_err("Error, only 1:1 translation is supported...\n");
-	return 1;
- finish:
-	uk_pr_debug("with offset: 0x%lx\n", offset);
+	uk_pr_debug("walking ranges...\n");
+	/* Now walk through the ranges */
+	rlen /= 4;
+	rone = na + pna + ns;
+	for (; rlen >= rone; rlen -= rone, ranges += rone) {
+		offset = fdt_default_map(addr, ranges, na, ns, pna);
+		if (offset != FDT_BAD_ADDR)
+			break;
+	}
+	if (offset == FDT_BAD_ADDR) {
+		uk_pr_debug("not found !\n");
+		return 1;
+	}
+	memcpy(addr, ranges + na, 4 * pna);
+
+finish:
+	uk_pr_info("parent translation for:%p %x", addr, pna);
 
 	/* Translate it into parent bus space */
 	return fdt_default_translate(addr, offset, pna);
@@ -140,7 +172,7 @@ static int fdt_translate_one(const void *fdt, int parent, fdt32_t *addr,
  * this walks up the tree and applies the various bus mappings on the
  * way.
  */
-static uint64_t fdt_translate_address_by_ranges(const void *fdt,
+uint64_t fdt_translate_address_by_ranges(const void *fdt,
 					int node_offset, const fdt32_t *regs)
 {
 	int parent;
@@ -188,7 +220,7 @@ static uint64_t fdt_translate_address_by_ranges(const void *fdt,
 
 		/* Apply bus translation */
 		if (fdt_translate_one(fdt, node_offset,
-					addr, na, pna, "ranges"))
+					addr, na, ns, pna, "ranges"))
 			break;
 
 		/* Complete the move up one level */
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:28 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY2G-0006Ac-M8; Fri, 29 May 2020 05:58:28 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2G-0006AV-87
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:28 +0000
X-Inumbo-ID: 635841e0-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 635841e0-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:15 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A603F55D;
 Thu, 28 May 2020 22:58:15 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9535A3F305;
 Thu, 28 May 2020 22:58:13 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 10/27] lib/ukbus: Adjust default bus register
 priority
Date: Fri, 29 May 2020 13:57:00 +0800
Message-Id: <20200529055717.88063-11-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

On arm64, platform bus should be probed before pci bus since the pci
controller is considered as a platform device. Thus set the default
priority from 1 to 2, then platform bus priority will be 1, higher
than pci bus.

Signed-off-by: Jia He <justin.he@arm.com>
---
 lib/ukbus/include/uk/bus.h | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/ukbus/include/uk/bus.h b/lib/ukbus/include/uk/bus.h
index fcb6842..5fbe325 100644
--- a/lib/ukbus/include/uk/bus.h
+++ b/lib/ukbus/include/uk/bus.h
@@ -68,22 +68,26 @@ void _uk_bus_register(struct uk_bus *b);
 /* Do not use this function directly: */
 void _uk_bus_unregister(struct uk_bus *b);
 
-/* registers a bus driver to the bus system */
+/* registers a bus driver to the bus system
+ * By default, the priority is 2 */
 #define UK_BUS_REGISTER(b) \
-	_UK_BUS_REGISTER(__LIBNAME__, b)
+	_UK_BUS_REGISTER(__LIBNAME__, b, 2)
+
+#define	UK_BUS_REGISTER_PRIORITY(b, prio) \
+	_UK_BUS_REGISTER(__LIBNAME__, b, prio)
 
 #define _UK_BUS_REGFNNAME(x, y)      x##y
 
-#define _UK_BUS_REGISTER_CTOR(ctor)  \
-	UK_CTOR_PRIO(ctor, UK_BUS_REGISTER_PRIO)
+#define _UK_BUS_REGISTER_CTOR(CTOR, prio)  \
+	UK_CTOR_FUNC(prio, CTOR)
 
-#define _UK_BUS_REGISTER(libname, b)				\
+#define _UK_BUS_REGISTER(libname, b, prio)			\
 	static void						\
 	_UK_BUS_REGFNNAME(libname, _uk_bus_register)(void)	\
 	{							\
 		_uk_bus_register((b));				\
 	}							\
-	_UK_BUS_REGISTER_CTOR(_UK_BUS_REGFNNAME(libname, _uk_bus_register))
+	_UK_BUS_REGISTER_CTOR(_UK_BUS_REGFNNAME(libname, _uk_bus_register), prio)
 
 #ifdef __cplusplus
 }
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:32 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58:32 +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 1jeY2K-0006Bo-Ne; Fri, 29 May 2020 05: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2K-0006BX-0E
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:32 +0000
X-Inumbo-ID: 6c90d38a-a171-11ea-81bc-bc764e2007e4
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTP
 id 6c90d38a-a171-11ea-81bc-bc764e2007e4;
 Fri, 29 May 2020 05:58:31 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 22FB055D;
 Thu, 28 May 2020 22:58:31 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 11EF93F305;
 Thu, 28 May 2020 22:58:28 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 16/27] plat/ofw: Add fdt_prop_read_bool
Date: Fri, 29 May 2020 13:57:06 +0800
Message-Id: <20200529055717.88063-17-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This fdt_prop_read_bool helper returns true when the property is
existed. This is helpful when we just need to know whether the property
is there instead of getting its value.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/include/ofw/fdt.h | 14 ++++++++++++++
 plat/drivers/ofw/fdt.c         |  8 ++++++++
 2 files changed, 22 insertions(+)

diff --git a/plat/drivers/include/ofw/fdt.h b/plat/drivers/include/ofw/fdt.h
index 0220fad..a3896ff 100644
--- a/plat/drivers/include/ofw/fdt.h
+++ b/plat/drivers/include/ofw/fdt.h
@@ -35,6 +35,8 @@
 #ifndef _PLAT_DRIVER_OFW_FDT_H
 #define _PLAT_DRIVER_OFW_FDT_H
 
+#include <stdbool.h>
+
 #define FDT_BAD_ADDR (uint64_t)(-1)
 
 /**
@@ -186,4 +188,16 @@ int fdt_node_offset_idx_by_compatible_list(const void *fdt, int startoffset,
  */
 int fdt_get_interrupt(const void *fdt, int nodeoffset,
 				uint32_t index, int *size, fdt32_t **prop);
+
+/**
+ * fdt_prop_read_bool - Find a property
+ * @fdt: pointer to the device tree blob
+ * @start_offset: start offset of the node to find the address for
+ * @propname:	name of the property to be searched.
+ *
+ * Search for a property in a device node.
+ * Returns true if the property exists false otherwise.
+ */
+bool fdt_prop_read_bool(const void *fdt, int start_offset,
+					 const char *propname);
 #endif
diff --git a/plat/drivers/ofw/fdt.c b/plat/drivers/ofw/fdt.c
index 876637d..48c5dfd 100644
--- a/plat/drivers/ofw/fdt.c
+++ b/plat/drivers/ofw/fdt.c
@@ -337,3 +337,11 @@ int fdt_get_interrupt(const void *fdt, int nodeoffset,
 
 	return 0;
 }
+
+bool fdt_prop_read_bool(const void *fdt, int start_offset,
+					 const char *propname)
+{
+	const struct fdt_property *prop = fdt_getprop(fdt, start_offset, propname, NULL);
+
+	return prop ? true : false;
+}
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:33 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY2L-0006CQ-P5; Fri, 29 May 2020 05:58:33 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2L-0006CF-8Q
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:33 +0000
X-Inumbo-ID: 64e98474-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 64e98474-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:18 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3E5B555D;
 Thu, 28 May 2020 22:58:18 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2D5793F305;
 Thu, 28 May 2020 22:58:15 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 11/27] plat/ofw: Add
 fdt_node_offset_idx_by_compatible_list
Date: Fri, 29 May 2020 13:57:01 +0800
Message-Id: <20200529055717.88063-12-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

The helper fdt_node_offset_idx_by_compatible_list is similar as
fdt_node_offset_by_compatible_list except that it returns the index
of compatible_list[] array when compatible string is matched.
This is useful when supporting multiple types of platform devices on
arm64.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/include/ofw/fdt.h | 28 ++++++++++++++++++++++++++++
 plat/drivers/ofw/fdt.c         | 18 ++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/plat/drivers/include/ofw/fdt.h b/plat/drivers/include/ofw/fdt.h
index 8826845..0220fad 100644
--- a/plat/drivers/include/ofw/fdt.h
+++ b/plat/drivers/include/ofw/fdt.h
@@ -139,6 +139,34 @@ int fdt_get_address(const void *fdt, int nodeoffset, uint32_t index,
 int fdt_node_offset_by_compatible_list(const void *fdt, int startoffset,
 					const char * const compatibles[]);
 
+/**
+ * fdt_node_offset_idx_by_compatible_list - find nodes with a given
+ *                                     'compatible' list value, and return
+ *                                     index of compatible array
+ * @fdt: pointer to the device tree blob
+ * @startoffset: only find nodes after this offset
+ * @compatibles: a list of 'compatible' string to match, should be ended
+ * with NULL string.
+ * @idx the index of compatible array
+ * fdt_node_offset_idx_by_compatible_list() returns the offset of the
+ * first matched node after startoffset, which has a 'compatible'
+ * property which lists the given compatible string; or if
+ * startoffset is -1, the very first such node in the tree.
+ *
+ * returns:
+ *     structure block offset of the located node (>= 0, >startoffset),
+ *              on success
+ *     -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
+ *             tree after startoffset
+ *     -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ *     -FDT_ERR_BADMAGIC,
+ *     -FDT_ERR_BADVERSION,
+ *     -FDT_ERR_BADSTATE,
+ *     -FDT_ERR_BADSTRUCTURE, standard meanings
+ */
+int fdt_node_offset_idx_by_compatible_list(const void *fdt, int startoffset,
+				const char * const compatibles[], int *index);
+
 /**
  * fdt_get_interrupt - retrieve device interrupt of a given index
  * @fdt: pointer to the device tree blob
diff --git a/plat/drivers/ofw/fdt.c b/plat/drivers/ofw/fdt.c
index c097331..30ac270 100644
--- a/plat/drivers/ofw/fdt.c
+++ b/plat/drivers/ofw/fdt.c
@@ -256,6 +256,24 @@ int fdt_node_offset_by_compatible_list(const void *fdt, int startoffset,
 	return -FDT_ERR_NOTFOUND;
 }
 
+int fdt_node_offset_idx_by_compatible_list(const void *fdt, int startoffset,
+			  const char * const compatibles[], int *index)
+{
+	int idx, offset;
+
+	for (idx = 0; compatibles[idx] != NULL; idx++) {
+		offset = fdt_node_offset_by_compatible(fdt, startoffset,
+				  compatibles[idx]);
+		if (offset >= 0) {
+			*index = idx;
+			return offset;
+		}
+	}
+
+	*index = idx;
+	return -FDT_ERR_NOTFOUND;
+}
+
 int fdt_get_interrupt(const void *fdt, int nodeoffset,
 			uint32_t index, int *size, fdt32_t **prop)
 {
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:38 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58:38 +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 1jeY2Q-0006Dw-Qt; Fri, 29 May 2020 05:58:38 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2Q-0006Dl-8d
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:38 +0000
X-Inumbo-ID: 667d1aee-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 667d1aee-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:21 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CA1BA55D;
 Thu, 28 May 2020 22:58:20 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B9CB33F305;
 Thu, 28 May 2020 22:58:18 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 12/27] plat/platform_bus: Add probe/match
 interface for platform devices
Date: Fri, 29 May 2020 13:57:02 +0800
Message-Id: <20200529055717.88063-13-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

There is no hardware ID for platform device on arm64 device-tree,
thus it introduces an ID match interface to identify the device id.
device id should be registered as a constant value.

Also it introduces probe interface to parse the neccessary resource
(irq, base/size) in device-tree.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/include/platform_bus.h |  26 ++++-
 plat/common/platform_bus.c         | 148 +++++++++++++++--------------
 2 files changed, 96 insertions(+), 78 deletions(-)

diff --git a/plat/common/include/platform_bus.h b/plat/common/include/platform_bus.h
index efc21a0..ad56e0e 100644
--- a/plat/common/include/platform_bus.h
+++ b/plat/common/include/platform_bus.h
@@ -43,8 +43,10 @@
  * table of these IDs for each device that it supports.
  */
 #define PLATFORM_DEVICE_ID_START (0x100)
-#define VIRTIO_MMIO_ID PLATFORM_DEVICE_ID_START
-#define PLATFORM_DEVICE_ID_END (PLATFORM_DEVICE_ID_START + 0x100)
+#define VIRTIO_MMIO_ID		(PLATFORM_DEVICE_ID_START)
+#define GEN_PCI_ID		(PLATFORM_DEVICE_ID_START + 1)
+
+#define PLATFORM_DEVICE_ID_END (GEN_PCI_ID + 1)
 
 #define UK_MAX_VIRTIO_MMIO_DEVICE (0x2)
 
@@ -52,16 +54,25 @@ struct pf_device_id {
 	uint16_t device_id;
 };
 
+struct device_match_table {
+	const char		*compatible;
+	struct pf_device_id	*id;
+};
+
 struct pf_device;
 
-typedef int (*pf_driver_add_func_t)(struct pf_device *);
 typedef int (*pf_driver_init_func_t)(struct uk_alloc *a);
+typedef int (*pf_driver_add_func_t)(struct pf_device *);
+typedef int (*pf_driver_probe_func_t)(struct pf_device *);
+typedef int (*pf_driver_match_func_t)(const char *);
 
 struct pf_driver {
 	UK_TAILQ_ENTRY(struct pf_driver) next;
 	const struct pf_device_id *device_ids;
 	pf_driver_init_func_t init; /* optional */
+	pf_driver_probe_func_t probe;
 	pf_driver_add_func_t add_dev;
+	pf_driver_match_func_t match;
 };
 UK_TAILQ_HEAD(pf_driver_list, struct pf_driver);
 
@@ -76,6 +87,7 @@ struct pf_device {
 	struct pf_driver     *drv;
 	enum pf_device_state state;
 
+	int fdt_offset;	/* The start offset of fdt node for device */
 	uint64_t base;
 	unsigned long irq;
 };
@@ -87,12 +99,16 @@ UK_TAILQ_HEAD(pf_device_list, struct pf_device);
 
 #define _PF_REGFNNAME(x, y)      x##y
 
+#define PF_REGISTER_CTOR(CTOR)				\
+		UK_CTOR_FUNC(1, CTOR)
+
 #define _PF_REGISTER_DRIVER(libname, b)				\
-	static void __constructor_prio(105)				\
+	static void						\
 	_PF_REGFNNAME(libname, _pf_register_driver)(void)		\
 	{								\
 		_pf_register_driver((b));				\
-	}
+	}								\
+	PF_REGISTER_CTOR(_PF_REGFNNAME(libname, _pf_register_driver))
 
 /* Do not use this function directly: */
 void _pf_register_driver(struct pf_driver *drv);
diff --git a/plat/common/platform_bus.c b/plat/common/platform_bus.c
index 1410e71..fecb389 100644
--- a/plat/common/platform_bus.c
+++ b/plat/common/platform_bus.c
@@ -52,8 +52,10 @@ struct pf_bus_handler {
 };
 static struct pf_bus_handler pfh;
 
-static const char * const pf_device_list[] = {
+static const char *pf_device_compatilbe_list[] = {
 	"virtio,mmio",
+	"pci-host-ecam-generic",
+	NULL
 };
 
 static inline int pf_device_id_match(const struct pf_device_id *id0,
@@ -67,14 +69,22 @@ static inline int pf_device_id_match(const struct pf_device_id *id0,
 	return rc;
 }
 
-static inline struct pf_driver *pf_find_driver(struct pf_device_id *id)
+static inline struct pf_driver *pf_find_driver(const char *compatible)
 {
 	struct pf_driver *drv;
+	struct pf_device_id id;
 
 	UK_TAILQ_FOREACH(drv, &pfh.drv_list, next) {
-		if (pf_device_id_match(id, drv->device_ids)) {
-			uk_pr_debug("pf driver found devid=%d\n", drv->device_ids->device_id);
-			return drv; /* driver found */
+		if (!drv->match)
+			continue;
+
+		id.device_id = (uint16_t)drv->match(compatible);
+		if (id.device_id) {
+			if (pf_device_id_match(&id, drv->device_ids)) {
+				uk_pr_debug("pf driver found  devid(0x%x)\n", id.device_id);
+
+				return drv;
+			}
 		}
 	}
 
@@ -84,104 +94,96 @@ static inline struct pf_driver *pf_find_driver(struct pf_device_id *id)
 }
 
 static inline int pf_driver_add_device(struct pf_driver *drv,
-					struct pf_device_id *devid,
-					__u64 dev_base,
-					int dev_irq)
+					struct pf_device *dev)
 {
-	struct pf_device *dev;
 	int ret;
 
 	UK_ASSERT(drv != NULL);
 	UK_ASSERT(drv->add_dev != NULL);
+	UK_ASSERT(dev != NULL);
 
-	dev = (struct pf_device *) uk_calloc(pfh.a, 1, sizeof(*dev));
-	if (!dev) {
-		uk_pr_err("Platform : Failed to initialize: Out of memory!\n");
-		return -ENOMEM;
-	}
-
-	memcpy(&dev->id, devid, sizeof(dev->id));
-	uk_pr_debug("pf_driver_add_device dev->id=%d\n", dev->id.device_id);
-
-	dev->base = dev_base;
-	dev->irq = dev_irq;
+	uk_pr_debug("pf_driver_add_device devid=%d\n", dev->id.device_id);
 
 	ret = drv->add_dev(dev);
 	if (ret < 0) {
 		uk_pr_err("Platform Failed to initialize device driver\n");
-		uk_free(pfh.a, dev);
 	}
 
 	return ret;
 }
 
+static inline int pf_driver_probe_device(struct pf_driver *drv,
+					struct pf_device *dev)
+{
+	int ret;
+
+	UK_ASSERT(drv != NULL && dev != NULL);
+	UK_ASSERT(drv->probe != NULL);
+
+	uk_pr_info("pf_driver_probe_device devid=%d\n", dev->id.device_id);
+
+	ret = drv->probe(dev);
+	if (ret < 0) {
+		uk_pr_err("Platform Failed to probe device driver\n");
+
+		return ret;
+	}
+
+	return 0;
+}
+
 static int pf_probe(void)
 {
-	struct pf_device_id devid;
 	struct pf_driver *drv;
-	int i;
-	int end_offset = -1;
+	int idx = 0;
 	int ret = -ENODEV;
-	const fdt32_t *prop;
-	int type, hwirq, prop_len;
-	__u64 reg_base;
-	__phys_addr dev_base;
-	int dev_irq;
+	struct pf_device *dev;
+	int fdt_pf = -1;
 
 	uk_pr_info("Probe PF\n");
 
-	/* We only support virtio_mmio as a platform device here.
-	 * A loop here is needed for finding drivers if more devices
-	 */
-	devid.device_id = VIRTIO_MMIO_ID;
+	/* Search all the platform bus devices provided by fdt */
+	do {
+		fdt_pf = fdt_node_offset_idx_by_compatible_list(_libkvmplat_cfg.dtb,
+						fdt_pf, pf_device_compatilbe_list, &idx);
+		if (fdt_pf < 0) {
+			uk_pr_info("End of searching platform devices\n");
+			break;
+		}
 
-	drv = pf_find_driver(&devid);
-	if (!drv) {
-		uk_pr_info("<no driver>\n");
-		return -ENODEV;
-	}
+		/* Alloc dev */
+		dev = (struct pf_device *) uk_calloc(pfh.a, 1, sizeof(*dev));
+		if (!dev) {
+			uk_pr_err("Platform : Failed to initialize: Out of memory!\n");
+			return -ENOMEM;
+		}
 
-	uk_pr_info("driver %p\n", drv);
-
-	/* qemu creates virtio devices in reverse order */
-	for (i = 0; i < UK_MAX_VIRTIO_MMIO_DEVICE; i++) {
-		end_offset = fdt_node_offset_by_compatible_list(fdt_start,
-							end_offset,
-							pf_device_list);
-		if (end_offset == -FDT_ERR_NOTFOUND) {
-			uk_pr_info("device not found in fdt\n");
-			goto error_exit;
-		} else {
-			prop = fdt_getprop(fdt_start, end_offset, "interrupts", &prop_len);
-			if (!prop) {
-				uk_pr_err("irq of device not found in fdt\n");
-				goto error_exit;
-			}
+		dev->fdt_offset = fdt_pf;
 
-			type = fdt32_to_cpu(prop[0]);
-			hwirq = fdt32_to_cpu(prop[1]);
+		/* Find drv with compatible-id match table */
+		drv = pf_find_driver(pf_device_compatilbe_list[idx]);
+		if (!drv) {
+			uk_free(pfh.a, dev);
+			continue;
+		}
 
-			prop = fdt_getprop(fdt_start, end_offset, "reg", &prop_len);
-			if (!prop) {
-				uk_pr_err("reg of device not found in fdt\n");
-				goto error_exit;
-			}
+		dev->id = *(struct pf_device_id *)drv->device_ids;
+		uk_pr_info("driver %p\n", drv);
 
-			/* only care about base addr, ignore the size */
-			reg_base = fdt32_to_cpu(prop[0]);
-			reg_base = reg_base << 32 | fdt32_to_cpu(prop[1]);
+		ret = pf_driver_probe_device(drv, dev);
+		if (ret < 0) {
+			uk_free(pfh.a, dev);
+			continue;
 		}
 
-		dev_base = reg_base;
-		dev_irq = gic_irq_translate(type, hwirq);
-
-		ret = pf_driver_add_device(drv, &devid, dev_base, dev_irq);
-	}
+		ret = pf_driver_add_device(drv, dev);
+		if (ret < 0) {
+			uk_pr_err("Platform Failed to initialize device driver, ret(%d)\n",ret);
+			uk_free(pfh.a, dev);
+		}
+	} while (1);
 
 	return ret;
-
-error_exit:
-	return -ENODEV;
 }
 
 
@@ -232,4 +234,4 @@ static struct pf_bus_handler pfh = {
 	.b.init = pf_init,
 	.b.probe = pf_probe
 };
-UK_BUS_REGISTER(&pfh.b);
+UK_BUS_REGISTER_PRIORITY(&pfh.b, 1);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:43 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY2V-0006FG-SR; Fri, 29 May 2020 05:58: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2V-0006F7-8e
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:43 +0000
X-Inumbo-ID: 67ea077a-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 67ea077a-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:23 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6291555D;
 Thu, 28 May 2020 22:58:23 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 51B213F305;
 Thu, 28 May 2020 22:58:21 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 13/27] plat/virtio_mmio: Implement platform
 probe for virtio_mmio
Date: Fri, 29 May 2020 13:57:03 +0800
Message-Id: <20200529055717.88063-14-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This implements the probe interface for virtio_mmio device upon platform
bus.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/virtio/virtio_mmio.c | 101 +++++++++++++++++++++++++-----
 1 file changed, 86 insertions(+), 15 deletions(-)

diff --git a/plat/drivers/virtio/virtio_mmio.c b/plat/drivers/virtio/virtio_mmio.c
index 6716153..9be07c1 100644
--- a/plat/drivers/virtio/virtio_mmio.c
+++ b/plat/drivers/virtio/virtio_mmio.c
@@ -42,12 +42,16 @@
 #include <uk/plat/irq.h>
 #include <uk/bus.h>
 #include <uk/bitops.h>
+#include <libfdt.h>
+#include <ofw/fdt.h>
+#include <kvm/config.h>
 
 #include <platform_bus.h>
 #include <virtio/virtio_config.h>
 #include <virtio/virtio_bus.h>
 #include <virtio/virtqueue.h>
 #include <virtio/virtio_mmio.h>
+#include <gic/gic-v2.h>
 
 /* The alignment to use between consumer and producer parts of vring.
  * Currently hardcoded to the page size. */
@@ -389,6 +393,48 @@ static struct virtio_config_ops virtio_mmio_config_ops = {
 	.vq_setup	= vm_setup_vq,
 };
 
+static int virtio_mmio_probe(struct pf_device *pfdev)
+{
+	const fdt32_t *prop;
+	int type, hwirq, prop_len;
+	int fdt_vm = pfdev->fdt_offset;
+	__u64 reg_base;
+	__u64 reg_size;
+
+	if (fdt_vm == -FDT_ERR_NOTFOUND) {
+		uk_pr_info("device not found in fdt\n");
+		goto error_exit;
+	} else {
+		prop = fdt_getprop(_libkvmplat_cfg.dtb, fdt_vm, "interrupts", &prop_len);
+		if (!prop) {
+			uk_pr_err("irq of device not found in fdt\n");
+			goto error_exit;
+		}
+
+		type = fdt32_to_cpu(prop[0]);
+		hwirq = fdt32_to_cpu(prop[1]);
+
+		prop = fdt_getprop(_libkvmplat_cfg.dtb, fdt_vm, "reg", &prop_len);
+		if (!prop) {
+			uk_pr_err("reg of device not found in fdt\n");
+			goto error_exit;
+		}
+
+		/* only care about base addr, ignore the size */
+		fdt_get_address(_libkvmplat_cfg.dtb, fdt_vm, 0,
+					&reg_base, &reg_size);
+	}
+
+	pfdev->base = reg_base;
+	pfdev->irq = gic_irq_translate(type, hwirq);
+	uk_pr_info("virtio mmio probe base(0x%lx) irq(%ld)\n",
+				pfdev->base, pfdev->irq);
+	return 0;
+
+error_exit:
+	return -EFAULT;
+}
+
 static int virtio_mmio_add_dev(struct pf_device *pfdev)
 {
 	struct virtio_mmio_device *vm_dev;
@@ -401,7 +447,8 @@ static int virtio_mmio_add_dev(struct pf_device *pfdev)
 	vm_dev = uk_malloc(a, sizeof(*vm_dev));
 	if (!vm_dev) {
 		uk_pr_err("Failed to allocate virtio-pci device\n");
-		return -ENOMEM;
+		rc = -ENOMEM;
+		goto free_vmdev;
 	}
 
 	/* Fetch Pf Device information */
@@ -410,20 +457,24 @@ static int virtio_mmio_add_dev(struct pf_device *pfdev)
 	vm_dev->vdev.cops = &virtio_mmio_config_ops;
 	vm_dev->name = "virtio_mmio";
 
-	if (vm_dev->base == NULL)
-		return -EFAULT;
+	if (vm_dev->base == NULL) {
+		rc = -EFAULT;
+		goto free_vmdev;
+	}
 
 	magic = virtio_cread32(vm_dev->base, VIRTIO_MMIO_MAGIC_VALUE);
 	if (magic != ('v' | 'i' << 8 | 'r' << 16 | 't' << 24)) {
 		uk_pr_err("Wrong magic value 0x%x!\n", magic);
-		return -ENODEV;
+		rc = -ENODEV;
+		goto free_vmdev;
 	}
 
 	/* Check device version */
 	vm_dev->version = virtio_cread32(vm_dev->base, VIRTIO_MMIO_VERSION);
 	if (vm_dev->version < 1 || vm_dev->version > 2) {
 		uk_pr_err("Version %ld not supported!\n", vm_dev->version);
-		return -ENXIO;
+		rc = -ENXIO;
+		goto free_vmdev;
 	}
 
 	vm_dev->vdev.id.virtio_device_id = virtio_cread32(vm_dev->base, VIRTIO_MMIO_DEVICE_ID);
@@ -434,7 +485,8 @@ static int virtio_mmio_add_dev(struct pf_device *pfdev)
 		 */
 		uk_pr_err("virtio_device_id is 0\n");
 
-		return -ENODEV;
+		rc = -ENODEV;
+		goto free_vmdev;
 	}
 	vm_dev->id.vendor = virtio_cread32(vm_dev->base, VIRTIO_MMIO_VENDOR_ID);
 
@@ -443,17 +495,15 @@ static int virtio_mmio_add_dev(struct pf_device *pfdev)
 	rc = virtio_bus_register_device(&vm_dev->vdev);
 	if (rc != 0) {
 		uk_pr_err("Failed to register the virtio device: %d\n", rc);
-		goto free_pf_dev;
+		goto free_vmdev;
 	}
 
-	uk_pr_info("finish add a virtio mmio dev\n");
-
-	return rc;
-
-free_pf_dev:
-	uk_free(a, vm_dev);
+	uk_pr_info("finish probing a virtio mmio dev\n");
 
 	return 0;
+
+free_vmdev:
+	return rc;
 }
 
 static int virtio_mmio_drv_init(struct uk_alloc *drv_allocator)
@@ -467,14 +517,35 @@ static int virtio_mmio_drv_init(struct uk_alloc *drv_allocator)
 	return 0;
 }
 
-static const struct pf_device_id virtio_mmio_ids = {
+static const struct device_match_table virtio_mmio_match_table[];
+
+static int virtio_mmio_id_match_compatible(const char *compatible)
+{
+	int i;
+
+	for (i = 0; virtio_mmio_match_table[i].compatible != NULL; i++)
+		if (strcmp(virtio_mmio_match_table[i].compatible, compatible) == 0)
+			return virtio_mmio_match_table[i].id->device_id;
+
+	return -1;
+}
+
+static struct pf_device_id virtio_mmio_ids = {
 		.device_id = VIRTIO_MMIO_ID
 };
 
 static struct pf_driver virtio_mmio_drv = {
 	.device_ids = &virtio_mmio_ids,
 	.init = virtio_mmio_drv_init,
-	.add_dev = virtio_mmio_add_dev
+	.probe = virtio_mmio_probe,
+	.add_dev = virtio_mmio_add_dev,
+	.match = virtio_mmio_id_match_compatible
+};
+
+static const struct device_match_table virtio_mmio_match_table[] = {
+	{ .compatible = "virtio,mmio",
+	  .id = &virtio_mmio_ids },
+	{NULL}
 };
 
 PF_REGISTER_DRIVER(&virtio_mmio_drv);
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:45 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY2X-0006G3-V1; Fri, 29 May 2020 05:58: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2W-0006Fh-Ri
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:44 +0000
X-Inumbo-ID: 74464a4c-a171-11ea-9dbe-bc764e2007e4
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTP
 id 74464a4c-a171-11ea-9dbe-bc764e2007e4;
 Fri, 29 May 2020 05:58:44 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1605655D;
 Thu, 28 May 2020 22:58:44 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 057243F305;
 Thu, 28 May 2020 22:58:41 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 21/27] build: Enable pci library on arm64
Date: Fri, 29 May 2020 13:57:11 +0800
Message-Id: <20200529055717.88063-22-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This enables pci library on arm64

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/kvm/Makefile.uk | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
index da2eb30..910108a 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -109,16 +109,18 @@ LIBKVMPLAT_SRCS-y              += $(UK_PLAT_KVM_DEF_LDS)
 ##
 ## PCI library definitions
 ##
-LIBKVMPCI_ASINCLUDES-$(CONFIG_ARCH_X86_64)  += -I$(LIBKVMPLAT_BASE)/include
-LIBKVMPCI_ASINCLUDES-$(CONFIG_ARCH_X86_64)  += -I$(UK_PLAT_COMMON_BASE)/include
-LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_X86_64)   += -I$(LIBKVMPLAT_BASE)/include
-LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_X86_64)   += -I$(UK_PLAT_COMMON_BASE)/include
-LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_ARM_64)   += -I$(UK_PLAT_DRIVERS_BASE)/include
-LIBKVMPCI_SRCS-y		            += $(UK_PLAT_COMMON_BASE)/pci_bus.c|common
+LIBKVMPCI_ASINCLUDES-y  += -I$(LIBKVMPLAT_BASE)/include
+LIBKVMPCI_ASINCLUDES-y  += -I$(UK_PLAT_COMMON_BASE)/include
+LIBKVMPCI_CINCLUDES-y   += -I$(LIBKVMPLAT_BASE)/include
+LIBKVMPCI_CINCLUDES-y   += -I$(UK_PLAT_COMMON_BASE)/include
+LIBKVMPCI_CINCLUDES-y   += -I$(UK_PLAT_DRIVERS_BASE)/include
+LIBKVMPCI_SRCS-y	+= $(UK_PLAT_COMMON_BASE)/pci_bus.c|common
 LIBKVMPCI_SRCS-$(CONFIG_ARCH_X86_64) += \
 				$(UK_PLAT_COMMON_BASE)/x86/pci_bus_x86.c|x86
 LIBKVMPCI_SRCS-$(CONFIG_ARCH_ARM_64) += \
 				$(UK_PLAT_COMMON_BASE)/arm/pci_bus_arm64.c|arm
+LIBKVMPCI_SRCS-$(CONFIG_ARCH_ARM_64) += \
+				$(UK_PLAT_COMMON_BASE)/pci_ecam.c|arm
 
 ##
 ## Platform bus library definitions
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY2b-0006Gw-01; Fri, 29 May 2020 05:58: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2a-0006Gj-8n
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:48 +0000
X-Inumbo-ID: 6afdf82c-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 6afdf82c-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:28 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8A65955D;
 Thu, 28 May 2020 22:58:28 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 795873F305;
 Thu, 28 May 2020 22:58:26 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 15/27] lib/fdt: Fix fdt_address_cell and
 fdt_size_cell
Date: Fri, 29 May 2020 13:57:05 +0800
Message-Id: <20200529055717.88063-16-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

The address-cell and size_cell should be probed from parent.

Signed-off-by: Jia He <justin.he@arm.com>
---
 lib/fdt/fdt_addresses.c | 57 ++++++++++++++++++++++-------------------
 plat/drivers/ofw/fdt.c  |  7 +++--
 2 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/lib/fdt/fdt_addresses.c b/lib/fdt/fdt_addresses.c
index a1860e6..736858a 100644
--- a/lib/fdt/fdt_addresses.c
+++ b/lib/fdt/fdt_addresses.c
@@ -55,42 +55,47 @@
 
 #include "libfdt_internal.h"
 
+#define OFW_ROOT_NODE_ADDR_CELLS_DEFAULT 2
+#define OFW_ROOT_NODE_SIZE_CELLS_DEFAULT 1
+
 int fdt_address_cells(const void *fdt, int nodeoffset)
 {
-	const fdt32_t *ac;
-	int val;
-	int len;
-
-	ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len);
-	if (!ac)
-		return 2;
+	int cells;
+	int parent;
+	int off = nodeoffset;
+	const fdt32_t *prop;
 
-	if (len != sizeof(*ac))
-		return -FDT_ERR_BADNCELLS;
+	do {
+		parent = fdt_parent_offset(fdt, off);
+		if (parent >= 0)
+			off = parent;
 
-	val = fdt32_to_cpu(*ac);
-	if ((val <= 0) || (val > FDT_MAX_NCELLS))
-		return -FDT_ERR_BADNCELLS;
+		prop = fdt_getprop(fdt, off, "#address-cells", &cells);
+		if (prop != NULL)
+			return fdt32_to_cpu(prop[0]);
+	} while (parent >= 0);
 
-	return val;
+	/* No #address-cells property for the root node */
+	return OFW_ROOT_NODE_ADDR_CELLS_DEFAULT;
 }
 
 int fdt_size_cells(const void *fdt, int nodeoffset)
 {
-	const fdt32_t *sc;
-	int val;
-	int len;
-
-	sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len);
-	if (!sc)
-		return 1;
+	int cells;
+	int parent;
+	int off = nodeoffset;
+	const fdt32_t *prop;
 
-	if (len != sizeof(*sc))
-		return -FDT_ERR_BADNCELLS;
+	do {
+		parent = fdt_parent_offset(fdt, off);
+		if (parent >= 0)
+			off = parent;
 
-	val = fdt32_to_cpu(*sc);
-	if ((val < 0) || (val > FDT_MAX_NCELLS))
-		return -FDT_ERR_BADNCELLS;
+		prop = fdt_getprop(fdt, off, "#size-cells", &cells);
+		if (prop != NULL)
+			return fdt32_to_cpu(prop[0]);
+	} while (parent >= 0);
 
-	return val;
+	/* No #size-cells property for the root node */
+	return OFW_ROOT_NODE_SIZE_CELLS_DEFAULT;
 }
diff --git a/plat/drivers/ofw/fdt.c b/plat/drivers/ofw/fdt.c
index 780b8dd..876637d 100644
--- a/plat/drivers/ofw/fdt.c
+++ b/plat/drivers/ofw/fdt.c
@@ -234,7 +234,7 @@ bail:
 int fdt_get_address(const void *fdt, int nodeoffset, uint32_t index,
 			uint64_t *addr, uint64_t *size)
 {
-	int parent;
+	int off = nodeoffset;
 	int len, prop_addr, prop_size;
 	int naddr, nsize, term_size;
 	const void *regs;
@@ -242,12 +242,11 @@ int fdt_get_address(const void *fdt, int nodeoffset, uint32_t index,
 	UK_ASSERT(addr && size);
 
 	/* Get address,size cell from parent */
-	parent = fdt_parent_offset(fdt, nodeoffset);
-	naddr = fdt_address_cells(fdt, parent);
+	naddr = fdt_address_cells(fdt, off);
 	if (naddr < 0 || naddr >= FDT_MAX_NCELLS)
 		return naddr;
 
-	nsize = fdt_size_cells(fdt, parent);
+	nsize = fdt_size_cells(fdt, off);
 	if (nsize < 0 || nsize >= FDT_MAX_NCELLS)
 		return nsize;
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:54 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY2g-0006IC-1S; Fri, 29 May 2020 05:58:54 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2f-0006Hz-8s
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:53 +0000
X-Inumbo-ID: 6e14d918-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 6e14d918-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:33 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AFB4955D;
 Thu, 28 May 2020 22:58:33 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9EC453F305;
 Thu, 28 May 2020 22:58:31 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 17/27] plat/pci_bus: Split specific code into
 arch directory
Date: Fri, 29 May 2020 13:57:07 +0800
Message-Id: <20200529055717.88063-18-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

There are significant difference for pci controller on arm64 and x86.
On arm64, only pci ecam is supported.
Hence split arch dependant codes into arch specific directory
No functional changes in this patch

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/include/pci/pci_bus.h |  97 +++++++++++++++++
 plat/common/pci_bus.c             | 167 +---------------------------
 plat/common/x86/pci_bus_x86.c     | 174 ++++++++++++++++++++++++++++++
 plat/kvm/Makefile.uk              |   9 +-
 4 files changed, 283 insertions(+), 164 deletions(-)
 create mode 100644 plat/common/x86/pci_bus_x86.c

diff --git a/plat/common/include/pci/pci_bus.h b/plat/common/include/pci/pci_bus.h
index db406a1..a15d663 100644
--- a/plat/common/include/pci/pci_bus.h
+++ b/plat/common/include/pci/pci_bus.h
@@ -174,5 +174,102 @@ struct pci_device {
 /* Do not use this function directly: */
 void _pci_register_driver(struct pci_driver *drv);
 
+struct pci_bus_handler {
+	struct uk_bus b;
+	struct uk_alloc *a;
+	struct uk_list_head drv_list;  /**< List of PCI drivers */
+	struct uk_list_head dev_list;  /**< List of PCI devices */
+};
+static struct pci_bus_handler ph;
+
+#define PCI_INVALID_ID              (0xFFFF)
+#define PCI_DEVICE_ID_MASK          (0xFFFF)
+
+#define PCI_CONFIG_ADDR             (0xCF8)
+#define PCI_CONFIG_DATA             (0xCFC)
+
+/* 8 bits for bus number, 5 bits for devices */
+#define PCI_MAX_BUSES               (1 << 8)
+#define PCI_MAX_DEVICES             (1 << 5)
+
+#define PCI_BUS_BIT_NBR					(8)
+#define PCI_DEV_BIT_NBR					(5)
+#define PCI_FN_BIT_NBR					(3)
+
+#define PCI_BUS_SHIFT               (16)
+#define PCI_DEVICE_SHIFT            (11)
+#define PCI_ENABLE_BIT              (1 << 31)
+
+#define PCI_CONF_CLASS_ID          (0x08)
+#define PCI_CONF_CLASS_ID_SHFT     (8)
+#define PCI_CONF_CLASS_ID_MASK     (0x00FFFFFF)
+
+#define PCI_CONF_VENDOR_ID          (0x00)
+#define PCI_CONF_VENDOR_ID_SHFT     (0)
+#define PCI_CONF_VENDOR_ID_MASK     (0x0000FFFF)
+
+#define PCI_CONF_DEVICE_ID          (0x00)
+#define PCI_CONF_DEVICE_ID_SHFT     (16)
+#define PCI_CONF_DEVICE_ID_MASK     (0x0000FFFF)
+
+#define PCI_CONF_SUBSYSVEN_ID          (0x2c)
+#define PCI_CONF_SUBSYSVEN_ID_SHFT     (0)
+#define PCI_CONF_SUBSYSVEN_ID_MASK     (0xFFFF)
+
+#define PCI_CONF_SUBSYS_ID          (0x2c)
+#define PCI_CONF_SUBSYS_ID_SHFT     (16)
+#define PCI_CONF_SUBSYS_ID_MASK     (0xFFFF)
+
+#define PCI_CONF_IRQ                (0X3C)
+#define PCI_CONF_IRQ_SHFT           (0x0)
+#define PCI_CONF_IRQ_MASK           (0XFF)
+
+#define PCI_CONF_IOBAR              (0x10)
+#define PCI_CONF_IOBAR_SHFT         (0x0)
+#define PCI_CONF_IOBAR_MASK         (~0x3)
+
+#define PCI_BASE_ADDRESS_0	0x10	/* 32 bits */
+#define PCI_BASE_ADDRESS_1	0x14	/* 32 bits */
+#define PCI_BASE_ADDRESS_2	0x18	/* 32 bits */
+#define PCI_BASE_ADDRESS_3	0x1c	/* 32 bits */
+#define PCI_BASE_ADDRESS_4	0x20	/* 32 bits */
+#define PCI_BASE_ADDRESS_5	0x24	/* 32 bits */
+
+#define PCI_VENDOR_ID		0x0
+#define PCI_DEV_ID			0x02
+
+#define PCI_BUS_OFFSET       16
+#define PCI_SLOT_OFFSET      11
+#define PCI_FUNC_OFFSET      8
+#define PCI_CONFIG_ADDRESS_ENABLE   0x80000000
+#define PCI_COMMAND_OFFSET   0x4
+#define PCI_BUS_MASTER_BIT   0x2
+#define PCI_STATUS_OFFSET    0x6
+#define PCI_CLASS_REVISION   0x8
+#define PCI_CLASS_OFFSET     0xb
+#define PCI_SUBCLASS_OFFSET	 0xa
+#define PCI_HEADER_TYPE      0xe
+#define PCI_SUBSYSTEM_ID     0x2e
+#define PCI_SUBSYSTEM_VID    0x2c
+#define PCI_HEADER_MULTI_FUNC   0x80
+#define PCI_BAR0_ADDR        0x10
+#define PCI_CONFIG_SECONDARY_BUS   0x19
+#define PCI_CAPABILITIES_PTR   0x34
+
+#define PCI_COMMAND		0x04	/* 16 bits */
+#define  PCI_COMMAND_IO		0x1	/* Enable response in I/O space */
+#define  PCI_COMMAND_MEMORY	0x2	/* Enable response in Memory space */
+#define  PCI_COMMAND_MASTER	0x4	/* Enable bus mastering */
+#define  PCI_COMMAND_SPECIAL	0x8	/* Enable response to special cycles */
+#define  PCI_COMMAND_INVALIDATE	0x10	/* Use memory write and invalidate */
+#define  PCI_COMMAND_VGA_PALETTE 0x20	/* Enable palette snooping */
+#define  PCI_COMMAND_PARITY	0x40	/* Enable parity checking */
+#define  PCI_COMMAND_WAIT	0x80	/* Enable address/data stepping */
+#define  PCI_COMMAND_SERR	0x100	/* Enable SERR */
+#define  PCI_COMMAND_FAST_BACK	0x200	/* Enable back-to-back writes */
+#define  PCI_COMMAND_INTX_DISABLE 0x400 /* INTx Emulation Disable */
+#define PCI_COMMAND_DECODE_ENABLE	(PCI_COMMAND_MEMORY | PCI_COMMAND_IO)
+
+struct pci_driver *pci_find_driver(struct pci_device_id *id);
 
 #endif /* __UKPLAT_COMMON_PCI_BUS_H__ */
diff --git a/plat/common/pci_bus.c b/plat/common/pci_bus.c
index 4077e3c..cd3874b 100644
--- a/plat/common/pci_bus.c
+++ b/plat/common/pci_bus.c
@@ -57,64 +57,7 @@
 #include <uk/plat/common/cpu.h>
 #include <pci/pci_bus.h>
 
-struct pci_bus_handler {
-	struct uk_bus b;
-	struct uk_alloc *a;
-	struct uk_list_head drv_list;  /**< List of PCI drivers */
-	struct uk_list_head dev_list;  /**< List of PCI devices */
-};
-static struct pci_bus_handler ph;
-
-#define PCI_INVALID_ID              (0xFFFF)
-#define PCI_DEVICE_ID_MASK          (0xFFFF)
-
-#define PCI_CONFIG_ADDR             (0xCF8)
-#define PCI_CONFIG_DATA             (0xCFC)
-
-/* 8 bits for bus number, 5 bits for devices */
-#define PCI_MAX_BUSES               (1 << 8)
-#define PCI_MAX_DEVICES             (1 << 5)
-
-#define PCI_BUS_SHIFT               (16)
-#define PCI_DEVICE_SHIFT            (11)
-#define PCI_ENABLE_BIT              (1 << 31)
-
-#define PCI_CONF_CLASS_ID          (0x08)
-#define PCI_CONF_CLASS_ID_SHFT     (8)
-#define PCI_CONF_CLASS_ID_MASK     (0x00FFFFFF)
-
-#define PCI_CONF_VENDOR_ID          (0x00)
-#define PCI_CONF_VENDOR_ID_SHFT     (0)
-#define PCI_CONF_VENDOR_ID_MASK     (0x0000FFFF)
-
-#define PCI_CONF_DEVICE_ID          (0x00)
-#define PCI_CONF_DEVICE_ID_SHFT     (16)
-#define PCI_CONF_DEVICE_ID_MASK     (0x0000FFFF)
-
-#define PCI_CONF_SUBSYSVEN_ID          (0x2c)
-#define PCI_CONF_SUBSYSVEN_ID_SHFT     (0)
-#define PCI_CONF_SUBSYSVEN_ID_MASK     (0xFFFF)
-
-#define PCI_CONF_SUBSYS_ID          (0x2c)
-#define PCI_CONF_SUBSYS_ID_SHFT     (16)
-#define PCI_CONF_SUBSYS_ID_MASK     (0xFFFF)
-
-#define PCI_CONF_IRQ                (0X3C)
-#define PCI_CONF_IRQ_SHFT           (0x0)
-#define PCI_CONF_IRQ_MASK           (0XFF)
-
-#define PCI_CONF_IOBAR              (0x10)
-#define PCI_CONF_IOBAR_SHFT         (0x0)
-#define PCI_CONF_IOBAR_MASK         (~0x3)
-
-#define PCI_CONF_READ(type, ret, a, s)					\
-	do {								\
-		uint32_t _conf_data;					\
-		outl(PCI_CONFIG_ADDR, (a) | PCI_CONF_##s);		\
-		_conf_data = ((inl(PCI_CONFIG_DATA) >> PCI_CONF_##s##_SHFT) \
-			      & PCI_CONF_##s##_MASK);			\
-		*(ret) = (type) _conf_data;				\
-	} while (0)
+extern int arch_pci_probe(struct uk_alloc *pha);
 
 static inline int pci_device_id_match(const struct pci_device_id *id0,
 					const struct pci_device_id *id1)
@@ -159,7 +102,7 @@ static inline int pci_device_id_is_any(const struct pci_device_id *id)
 	return 0;
 }
 
-static inline struct pci_driver *pci_find_driver(struct pci_device_id *id)
+struct pci_driver *pci_find_driver(struct pci_device_id *id)
 {
 	struct pci_driver *drv;
 	const struct pci_device_id *drv_id;
@@ -172,116 +115,15 @@ static inline struct pci_driver *pci_find_driver(struct pci_device_id *id)
 				return drv;
 		}
 	}
-	return NULL; /* no driver found */
-}
-
-static inline int pci_driver_add_device(struct pci_driver *drv,
-					struct pci_address *addr,
-					struct pci_device_id *devid)
-{
-	struct pci_device *dev;
-	uint32_t config_addr;
-	int ret;
-
-	UK_ASSERT(drv != NULL);
-	UK_ASSERT(drv->add_dev != NULL);
-	UK_ASSERT(addr != NULL);
-	UK_ASSERT(devid != NULL);
-
-	dev = (struct pci_device *) uk_calloc(ph.a, 1, sizeof(*dev));
-	if (!dev) {
-		uk_pr_err("PCI %02x:%02x.%02x: Failed to initialize: Out of memory!\n",
-			  (int) addr->bus,
-			  (int) addr->devid,
-			  (int) addr->function);
-		return -ENOMEM;
-	}
 
-	memcpy(&dev->id,   devid, sizeof(dev->id));
-	memcpy(&dev->addr, addr,  sizeof(dev->addr));
-	dev->drv = drv;
-
-	config_addr = (PCI_ENABLE_BIT)
-			| (addr->bus << PCI_BUS_SHIFT)
-			| (addr->devid << PCI_DEVICE_SHIFT);
-	PCI_CONF_READ(uint16_t, &dev->base, config_addr, IOBAR);
-	PCI_CONF_READ(uint8_t, &dev->irq, config_addr, IRQ);
-
-	ret = drv->add_dev(dev);
-	if (ret < 0) {
-		uk_pr_err("PCI %02x:%02x.%02x: Failed to initialize device driver\n",
-			  (int) addr->bus,
-			  (int) addr->devid,
-			  (int) addr->function);
-		uk_free(ph.a, dev);
-	}
-	return 0;
+	return NULL; /* no driver found */
 }
 
 static int pci_probe(void)
 {
-	struct pci_address addr;
-	struct pci_device_id devid;
-	struct pci_driver *drv;
-	uint32_t config_addr, config_data;
-	uint32_t bus;
-	uint8_t dev;
-
-	uk_pr_debug("Probe PCI\n");
-
-	for (bus = 0; bus < PCI_MAX_BUSES; ++bus) {
-		for (dev = 0; dev < PCI_MAX_DEVICES; ++dev) {
-			config_addr = (PCI_ENABLE_BIT)
-					| (bus << PCI_BUS_SHIFT)
-					| (dev << PCI_DEVICE_SHIFT);
-
-			outl(PCI_CONFIG_ADDR, config_addr);
-			config_data = inl(PCI_CONFIG_DATA);
-
-			/* TODO: Retrieve the device identfier */
-			addr.domain   = 0x0;
-			addr.bus      = bus;
-			addr.devid    = dev;
-			 /* TODO: Retrieve the function */
-			addr.function = 0x0;
-
-			devid.vendor_id = config_data & PCI_DEVICE_ID_MASK;
-			if (devid.vendor_id == PCI_INVALID_ID) {
-				/* Device doesn't exist */
-				continue;
-			}
-
-			PCI_CONF_READ(uint32_t, &devid.class_id,
-					config_addr, CLASS_ID);
-			PCI_CONF_READ(uint16_t, &devid.vendor_id,
-					config_addr, VENDOR_ID);
-			PCI_CONF_READ(uint16_t, &devid.device_id,
-					config_addr, DEVICE_ID);
-			PCI_CONF_READ(uint16_t, &devid.subsystem_device_id,
-					config_addr, SUBSYS_ID);
-			PCI_CONF_READ(uint16_t, &devid.subsystem_vendor_id,
-					config_addr, SUBSYSVEN_ID);
-
-			uk_pr_info("PCI %02x:%02x.%02x (%04x %04x:%04x): ",
-				   (int) addr.bus,
-				   (int) addr.devid,
-				   (int) addr.function,
-				   (int) devid.class_id,
-				   (int) devid.vendor_id,
-				   (int) devid.device_id);
-			drv = pci_find_driver(&devid);
-			if (!drv) {
-				uk_pr_info("<no driver>\n");
-				continue;
-			}
-			uk_pr_info("driver %p\n", drv);
-			pci_driver_add_device(drv, &addr, &devid);
-		}
-	}
-	return 0;
+	return arch_pci_probe(ph.a);
 }
 
-
 static int pci_init(struct uk_alloc *a)
 {
 	struct pci_driver *drv, *drv_next;
@@ -301,6 +143,7 @@ static int pci_init(struct uk_alloc *a)
 			uk_list_del_init(&drv->list);
 		}
 	}
+
 	return 0;
 }
 
diff --git a/plat/common/x86/pci_bus_x86.c b/plat/common/x86/pci_bus_x86.c
new file mode 100644
index 0000000..e07f3e5
--- /dev/null
+++ b/plat/common/x86/pci_bus_x86.c
@@ -0,0 +1,174 @@
+/* TODO: SPDX Header */
+/*
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ * Copyright (c) 2018, 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.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+/* Some code was derived from Solo5: */
+/*
+ * Copyright (c) 2015-2017 Contributors as noted in the AUTHORS file
+ *
+ * This file is part of Solo5, a unikernel base layer.
+ *
+ * Permission to use, copy, modify, and/or distribute this software
+ * for any purpose with or without fee is hereby granted, provided
+ * that the above copyright notice and this permission notice appear
+ * in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <string.h>
+#include <uk/print.h>
+#include <uk/plat/common/cpu.h>
+#include <pci/pci_bus.h>
+
+#define PCI_CONF_READ(type, ret, a, s)					\
+	do {								\
+		uint32_t _conf_data;					\
+		outl(PCI_CONFIG_ADDR, (a) | PCI_CONF_##s);		\
+		_conf_data = ((inl(PCI_CONFIG_DATA) >> PCI_CONF_##s##_SHFT) \
+			      & PCI_CONF_##s##_MASK);			\
+		*(ret) = (type) _conf_data;				\
+	} while (0)
+
+static inline int arch_pci_driver_add_device(struct pci_driver *drv,
+					struct pci_address *addr,
+					struct pci_device_id *devid,
+					struct uk_alloc *pha)
+{
+	struct pci_device *dev;
+	uint32_t config_addr;
+	int ret;
+
+	UK_ASSERT(drv != NULL);
+	UK_ASSERT(drv->add_dev != NULL);
+	UK_ASSERT(addr != NULL);
+	UK_ASSERT(devid != NULL);
+
+	dev = (struct pci_device *) uk_calloc(pha, 1, sizeof(*dev));
+	if (!dev) {
+		uk_pr_err("PCI %02x:%02x.%02x: Failed to initialize: Out of memory!\n",
+			  (int) addr->bus,
+			  (int) addr->devid,
+			  (int) addr->function);
+		return -ENOMEM;
+	}
+
+	memcpy(&dev->id,   devid, sizeof(dev->id));
+	memcpy(&dev->addr, addr,  sizeof(dev->addr));
+	dev->drv = drv;
+
+	config_addr = (PCI_ENABLE_BIT)
+			| (addr->bus << PCI_BUS_SHIFT)
+			| (addr->devid << PCI_DEVICE_SHIFT);
+	PCI_CONF_READ(uint16_t, &dev->base, config_addr, IOBAR);
+	PCI_CONF_READ(uint8_t, &dev->irq, config_addr, IRQ);
+
+	ret = drv->add_dev(dev);
+	if (ret < 0) {
+		uk_pr_err("PCI %02x:%02x.%02x: Failed to initialize device driver\n",
+			  (int) addr->bus,
+			  (int) addr->devid,
+			  (int) addr->function);
+		uk_free(pha, dev);
+	}
+	return 0;
+}
+
+int arch_pci_probe(void)
+{
+	struct pci_address addr;
+	struct pci_device_id devid;
+	struct pci_driver *drv;
+	uint32_t config_addr, config_data;
+	uint32_t bus;
+	uint8_t dev;
+
+	uk_pr_debug("Probe PCI\n");
+
+	for (bus = 0; bus < PCI_MAX_BUSES; ++bus) {
+		for (dev = 0; dev < PCI_MAX_DEVICES; ++dev) {
+			config_addr = (PCI_ENABLE_BIT)
+					| (bus << PCI_BUS_SHIFT)
+					| (dev << PCI_DEVICE_SHIFT);
+
+			outl(PCI_CONFIG_ADDR, config_addr);
+			config_data = inl(PCI_CONFIG_DATA);
+
+			/* TODO: Retrieve the device identfier */
+			addr.domain   = 0x0;
+			addr.bus      = bus;
+			addr.devid    = dev;
+			 /* TODO: Retrieve the function */
+			addr.function = 0x0;
+
+			devid.vendor_id = config_data & PCI_DEVICE_ID_MASK;
+			if (devid.vendor_id == PCI_INVALID_ID) {
+				/* Device doesn't exist */
+				continue;
+			}
+
+			PCI_CONF_READ(uint32_t, &devid.class_id,
+					config_addr, CLASS_ID);
+			PCI_CONF_READ(uint16_t, &devid.vendor_id,
+					config_addr, VENDOR_ID);
+			PCI_CONF_READ(uint16_t, &devid.device_id,
+					config_addr, DEVICE_ID);
+			PCI_CONF_READ(uint16_t, &devid.subsystem_device_id,
+					config_addr, SUBSYS_ID);
+			PCI_CONF_READ(uint16_t, &devid.subsystem_vendor_id,
+					config_addr, SUBSYSVEN_ID);
+
+			uk_pr_info("PCI %02x:%02x.%02x (%04x %04x:%04x): ",
+				   (int) addr.bus,
+				   (int) addr.devid,
+				   (int) addr.function,
+				   (int) devid.class_id,
+				   (int) devid.vendor_id,
+				   (int) devid.device_id);
+			drv = pci_find_driver(&devid);
+			if (!drv) {
+				uk_pr_info("<no driver>\n");
+				continue;
+			}
+			uk_pr_info("driver %p\n", drv);
+			arch_pci_driver_add_device(drv, &addr, &devid, ph.a);
+		}
+	}
+	return 0;
+}
diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
index 7b12b1a..da2eb30 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -113,7 +113,12 @@ LIBKVMPCI_ASINCLUDES-$(CONFIG_ARCH_X86_64)  += -I$(LIBKVMPLAT_BASE)/include
 LIBKVMPCI_ASINCLUDES-$(CONFIG_ARCH_X86_64)  += -I$(UK_PLAT_COMMON_BASE)/include
 LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_X86_64)   += -I$(LIBKVMPLAT_BASE)/include
 LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_X86_64)   += -I$(UK_PLAT_COMMON_BASE)/include
-LIBKVMPCI_SRCS-$(CONFIG_ARCH_X86_64)        += $(UK_PLAT_COMMON_BASE)/pci_bus.c|common
+LIBKVMPCI_CINCLUDES-$(CONFIG_ARCH_ARM_64)   += -I$(UK_PLAT_DRIVERS_BASE)/include
+LIBKVMPCI_SRCS-y		            += $(UK_PLAT_COMMON_BASE)/pci_bus.c|common
+LIBKVMPCI_SRCS-$(CONFIG_ARCH_X86_64) += \
+				$(UK_PLAT_COMMON_BASE)/x86/pci_bus_x86.c|x86
+LIBKVMPCI_SRCS-$(CONFIG_ARCH_ARM_64) += \
+				$(UK_PLAT_COMMON_BASE)/arm/pci_bus_arm64.c|arm
 
 ##
 ## Platform bus library definitions
@@ -122,7 +127,7 @@ LIBKVMPF_ASINCLUDES-$(CONFIG_ARCH_ARM_64)  += -I$(UK_PLAT_COMMON_BASE)/include
 LIBKVMPF_CINCLUDES-$(CONFIG_ARCH_ARM_64)   += -I$(UK_PLAT_COMMON_BASE)/include
 LIBKVMPF_CINCLUDES-$(CONFIG_ARCH_ARM_64)   += -I$(LIBKVMPLAT_BASE)/include
 LIBKVMPF_CINCLUDES-$(CONFIG_ARCH_ARM_64)   += -I$(UK_PLAT_DRIVERS_BASE)/include
-LIBKVMPF_SRCS-$(CONFIG_ARCH_ARM_64) += $(UK_PLAT_COMMON_BASE)/platform_bus.c|common
+LIBKVMPF_SRCS-$(CONFIG_KVM_PF) += $(UK_PLAT_COMMON_BASE)/platform_bus.c|common
 
 ##
 ## Virtio library definitions
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:58:59 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:58: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 1jeY2l-0006JB-34; Fri, 29 May 2020 05:58:59 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2k-0006J3-92
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:58:58 +0000
X-Inumbo-ID: 6fa32000-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 6fa32000-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:36 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4723455D;
 Thu, 28 May 2020 22:58:36 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 36C133F305;
 Thu, 28 May 2020 22:58:33 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 18/27] plat/pci_bus: arm64: Implement arch
 specific add/probe interfaces on arm64
Date: Fri, 29 May 2020 13:57:08 +0800
Message-Id: <20200529055717.88063-19-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This implements arch specific add/probe interfaces on arm64

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/arm/pci_bus_arm64.c   | 204 ++++++++++++++++++++++++++++++
 plat/common/include/pci/pci_bus.h |   5 +
 2 files changed, 209 insertions(+)
 create mode 100644 plat/common/arm/pci_bus_arm64.c

diff --git a/plat/common/arm/pci_bus_arm64.c b/plat/common/arm/pci_bus_arm64.c
new file mode 100644
index 0000000..1dfaeb3
--- /dev/null
+++ b/plat/common/arm/pci_bus_arm64.c
@@ -0,0 +1,204 @@
+/* TODO: SPDX Header */
+/*
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ * Copyright (c) 2018, 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.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+/* Some code was derived from Solo5: */
+/*
+ * Copyright (c) 2015-2017 Contributors as noted in the AUTHORS file
+ *
+ * This file is part of Solo5, a unikernel base layer.
+ *
+ * Permission to use, copy, modify, and/or distribute this software
+ * for any purpose with or without fee is hereby granted, provided
+ * that the above copyright notice and this permission notice appear
+ * in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <string.h>
+#include <uk/print.h>
+#include <uk/plat/common/cpu.h>
+#include <pci/pci_bus.h>
+#include <pci/pci_ecam.h>
+#include <libfdt_env.h>
+#include <gic/gic-v2.h>
+
+extern struct pci_config_window pcw;
+extern int gen_pci_irq_parse(const fdt32_t *addr, struct fdt_phandle_args *out_irq);
+
+#define DEVFN(dev, fn)   ((dev << PCI_FN_BIT_NBR) | fn)
+#define SIZE_PER_PCI_DEV 0x20	/* legacy pci device size, no msi */
+
+static inline int arch_pci_driver_add_device(struct pci_driver *drv,
+					struct pci_address *addr,
+					struct pci_device_id *devid,
+					int irq,
+					__u64 base,
+					struct uk_alloc *pha)
+{
+	struct pci_device *dev;
+	int ret;
+	__u32 val;
+
+	UK_ASSERT(drv != NULL);
+	UK_ASSERT(drv->add_dev != NULL);
+	UK_ASSERT(addr != NULL);
+	UK_ASSERT(devid != NULL);
+
+	dev = (struct pci_device *) uk_calloc(pha, 1, sizeof(*dev));
+	if (!dev) {
+		uk_pr_err("PCI %02x:%02x.%02x: Failed to initialize: Out of memory!\n",
+			  (int) addr->bus,
+			  (int) addr->devid,
+			  (int) addr->function);
+		return -ENOMEM;
+	}
+
+	memcpy(&dev->id, devid, sizeof(dev->id));
+	memcpy(&dev->addr, addr,  sizeof(dev->addr));
+	dev->drv = drv;
+
+	dev->base = base;
+	dev->irq = irq;
+	uk_pr_info("pci dev base(0x%llx) irq(%d)\n", dev->base, dev->irq);
+
+	if (drv->add_dev)
+		ret = drv->add_dev(dev); //virtio pci
+	if (ret < 0) {
+		uk_pr_err("PCI %02x:%02x.%02x: Failed to initialize device driver\n",
+			  (int) addr->bus,
+			  (int) addr->devid,
+			  (int) addr->function);
+		uk_free(pha, dev);
+	}
+
+	return 0;
+}
+
+int arch_pci_probe(struct uk_alloc *pha)
+{
+	struct pci_address addr;
+	struct pci_device_id devid;
+	struct pci_driver *drv;
+	uint32_t bus;
+	uint8_t dev;
+	int err;
+	int irq, pin = 0;
+	__u64 base;
+	int found_pci_device = 0;
+	struct fdt_phandle_args out_irq;
+	fdt32_t fdtaddr[3];
+
+	uk_pr_debug("Probe PCI\n");
+
+	for (bus = 0; bus < PCI_MAX_BUSES; ++bus) {
+		for (dev = 0; dev < PCI_MAX_DEVICES; ++dev) {
+			/* TODO: Retrieve the device identfier */
+			addr.domain   = 0x0;
+			addr.bus      = bus;
+			addr.devid    = dev;
+			 /* TODO: Retrieve the function bus, dev << PCI_DEV_BIT_NBR*/
+			addr.function = 0x0;
+
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, &devid.vendor_id);
+			if (devid.vendor_id == PCI_INVALID_ID) {
+				/* Device doesn't exist */
+				continue;
+			}
+
+			/* mark we found any pci device */
+			found_pci_device = 1;
+
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_CLASS_REVISION, 4, &devid.class_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, &devid.vendor_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_DEV_ID, 2, &devid.device_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_VID, 2, &devid.subsystem_vendor_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_ID, 2, &devid.subsystem_device_id);
+			uk_pr_info("PCI %02x:%02x.%02x (%04x %04x:%04x): sb=%d,sv=%4x\n",
+				   (int) addr.bus,
+				   (int) addr.devid,
+				   (int) addr.function,
+				   (int) devid.class_id,
+				   (int) devid.vendor_id,
+				   (int) devid.device_id,
+				   (int) devid.subsystem_device_id,
+				   (int) devid.subsystem_vendor_id);
+
+			/* TODO: gracefully judge it is a pci host bridge */
+			if (bus == 0 && DEVFN(dev, 0) == 0) {
+				pci_generic_config_write(bus, 0, PCI_COMMAND, 2, PCI_COMMAND_INTX_DISABLE);
+				pci_generic_config_write(bus, 0, PCI_COMMAND, 2, PCI_COMMAND_IO);
+				continue;
+			} else {
+				base = pcw.pci_device_base + (bus << 5 | dev)*SIZE_PER_PCI_DEV;
+				pci_generic_config_write(bus, DEVFN(dev, 0), PCI_COMMAND, 2, PCI_COMMAND_INTX_DISABLE);
+				pci_generic_config_write(bus, DEVFN(dev, 0), PCI_BASE_ADDRESS_0, 4, (bus << 5 | dev)*SIZE_PER_PCI_DEV);
+				pci_generic_config_write(bus, DEVFN(dev, 0), PCI_COMMAND, 2, PCI_COMMAND_MASTER | PCI_COMMAND_IO);
+			}
+
+			drv = pci_find_driver(&devid);
+			if (!drv) {
+				uk_pr_info("<no driver> for dev id=%d\n", devid);
+				continue;
+			}
+
+			uk_pr_info("driver %p\n", drv);
+
+			/* probe the irq info*/
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_INTERRUPT_PIN, 1, &pin);
+			out_irq.args_count = 1;
+			out_irq.args[0] = pin;
+			fdtaddr[0] = cpu_to_fdt32((bus << 16) | (DEVFN(dev,0) << 8));
+			fdtaddr[1] = fdtaddr[2] = cpu_to_fdt32(0);
+
+			gen_pci_irq_parse(fdtaddr, &out_irq);
+			irq = gic_irq_translate(0, out_irq.args[1]);
+
+			arch_pci_driver_add_device(drv, &addr, &devid, irq, base, pha);
+
+			uk_pr_info("pci dev base(0x%llx) irq(%d)\n");
+		}
+	}
+
+	if (found_pci_device == 0)
+		uk_pr_info("No pci device found!\n");
+
+	return 0;
+}
diff --git a/plat/common/include/pci/pci_bus.h b/plat/common/include/pci/pci_bus.h
index a15d663..58ad292 100644
--- a/plat/common/include/pci/pci_bus.h
+++ b/plat/common/include/pci/pci_bus.h
@@ -255,6 +255,11 @@ static struct pci_bus_handler ph;
 #define PCI_BAR0_ADDR        0x10
 #define PCI_CONFIG_SECONDARY_BUS   0x19
 #define PCI_CAPABILITIES_PTR   0x34
+/* 0x35-0x3b are reserved */
+#define PCI_INTERRUPT_LINE	0x3c	/* 8 bits */
+#define PCI_INTERRUPT_PIN	0x3d	/* 8 bits */
+#define PCI_MIN_GNT		0x3e	/* 8 bits */
+#define PCI_MAX_LAT		0x3f	/* 8 bits */
 
 #define PCI_COMMAND		0x04	/* 16 bits */
 #define  PCI_COMMAND_IO		0x1	/* Enable response in I/O space */
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:59:04 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:59: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 1jeY2q-0006KP-5V; Fri, 29 May 2020 05:59:04 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2p-0006K9-9H
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:59:03 +0000
X-Inumbo-ID: 7142ec6a-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 7142ec6a-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:39 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DC86C55D;
 Thu, 28 May 2020 22:58:38 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C2C243F305;
 Thu, 28 May 2020 22:58:36 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 19/27] build: Make KVM_PCI default enable on
 arm64
Date: Fri, 29 May 2020 13:57:09 +0800
Message-Id: <20200529055717.88063-20-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/kvm/Config.uk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plat/kvm/Config.uk b/plat/kvm/Config.uk
index 9540feb..2ee737e 100644
--- a/plat/kvm/Config.uk
+++ b/plat/kvm/Config.uk
@@ -68,7 +68,7 @@ endmenu
 config KVM_PCI
        bool "PCI Bus Driver"
        default y
-       depends on (ARCH_X86_64)
+       depends on (ARCH_X86_64 || ARCH_ARM_64)
        select LIBUKBUS
        help
                 PCI bus driver for probing and operating PCI devices
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:59:09 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:59: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 1jeY2v-0006LI-7F; Fri, 29 May 2020 05:59: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2u-0006LA-9X
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:59:08 +0000
X-Inumbo-ID: 72bf0402-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 72bf0402-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:41 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7DEC555D;
 Thu, 28 May 2020 22:58:41 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6411A3F305;
 Thu, 28 May 2020 22:58:39 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 20/27] plat/pci_bus: Change the type of
 pci_device.base from u16 to unsigned long
Date: Fri, 29 May 2020 13:57:10 +0800
Message-Id: <20200529055717.88063-21-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

On arm64, no ioport at all. It uses iomem instead, hence change the
base from u16 to unsigned long.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/include/pci/pci_bus.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/plat/common/include/pci/pci_bus.h b/plat/common/include/pci/pci_bus.h
index 58ad292..78ca977 100644
--- a/plat/common/include/pci/pci_bus.h
+++ b/plat/common/include/pci/pci_bus.h
@@ -69,6 +69,7 @@
 #include <uk/bus.h>
 #include <uk/alloc.h>
 #include <uk/ctors.h>
+#include <pci/pci_ecam.h>
 
 /**
  * A structure describing an ID for a PCI driver. Each driver provides a
@@ -150,7 +151,7 @@ struct pci_device {
 	struct pci_driver     *drv;
 	enum pci_device_state state;
 
-	uint16_t base;
+	unsigned long base;
 	unsigned long irq;
 };
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:59:14 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:59:14 +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 1jeY30-0006ML-8o; Fri, 29 May 2020 05:59: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY2z-0006MA-9o
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:59:13 +0000
X-Inumbo-ID: 75c7bd38-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 75c7bd38-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:46 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A254255D;
 Thu, 28 May 2020 22:58:46 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 917EF3F305;
 Thu, 28 May 2020 22:58:44 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 22/27] plat/pci_ecam: Fix a lot compilation
 warnings in pci_ecam
Date: Fri, 29 May 2020 13:57:12 +0800
Message-Id: <20200529055717.88063-23-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This fixes the compilation warnings when introducing pci_ecam

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/arm/pci_bus_arm64.c    | 22 ++++++---------
 plat/common/include/pci/pci_bus.h  |  2 +-
 plat/common/include/pci/pci_ecam.h |  2 +-
 plat/common/pci_ecam.c             | 44 +++++++++++++++---------------
 plat/drivers/include/ofw/fdt.h     | 11 ++++++++
 5 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/plat/common/arm/pci_bus_arm64.c b/plat/common/arm/pci_bus_arm64.c
index 1dfaeb3..4386d55 100644
--- a/plat/common/arm/pci_bus_arm64.c
+++ b/plat/common/arm/pci_bus_arm64.c
@@ -75,7 +75,6 @@ static inline int arch_pci_driver_add_device(struct pci_driver *drv,
 {
 	struct pci_device *dev;
 	int ret;
-	__u32 val;
 
 	UK_ASSERT(drv != NULL);
 	UK_ASSERT(drv->add_dev != NULL);
@@ -97,7 +96,7 @@ static inline int arch_pci_driver_add_device(struct pci_driver *drv,
 
 	dev->base = base;
 	dev->irq = irq;
-	uk_pr_info("pci dev base(0x%llx) irq(%d)\n", dev->base, dev->irq);
+	uk_pr_info("pci dev base(0x%lx) irq(%ld)\n", dev->base, dev->irq);
 
 	if (drv->add_dev)
 		ret = drv->add_dev(dev); //virtio pci
@@ -119,7 +118,6 @@ int arch_pci_probe(struct uk_alloc *pha)
 	struct pci_driver *drv;
 	uint32_t bus;
 	uint8_t dev;
-	int err;
 	int irq, pin = 0;
 	__u64 base;
 	int found_pci_device = 0;
@@ -137,7 +135,7 @@ int arch_pci_probe(struct uk_alloc *pha)
 			 /* TODO: Retrieve the function bus, dev << PCI_DEV_BIT_NBR*/
 			addr.function = 0x0;
 
-			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, &devid.vendor_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, (void *)&devid.vendor_id);
 			if (devid.vendor_id == PCI_INVALID_ID) {
 				/* Device doesn't exist */
 				continue;
@@ -146,11 +144,11 @@ int arch_pci_probe(struct uk_alloc *pha)
 			/* mark we found any pci device */
 			found_pci_device = 1;
 
-			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_CLASS_REVISION, 4, &devid.class_id);
-			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, &devid.vendor_id);
-			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_DEV_ID, 2, &devid.device_id);
-			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_VID, 2, &devid.subsystem_vendor_id);
-			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_ID, 2, &devid.subsystem_device_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_CLASS_REVISION, 4, (void *)&devid.class_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_VENDOR_ID, 2, (void *)&devid.vendor_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_DEV_ID, 2, (void *)&devid.device_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_VID, 2, (void *)&devid.subsystem_vendor_id);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_SUBSYSTEM_ID, 2, (void *)&devid.subsystem_device_id);
 			uk_pr_info("PCI %02x:%02x.%02x (%04x %04x:%04x): sb=%d,sv=%4x\n",
 				   (int) addr.bus,
 				   (int) addr.devid,
@@ -175,14 +173,14 @@ int arch_pci_probe(struct uk_alloc *pha)
 
 			drv = pci_find_driver(&devid);
 			if (!drv) {
-				uk_pr_info("<no driver> for dev id=%d\n", devid);
+				uk_pr_info("<no driver> for dev id=%d\n", devid.device_id);
 				continue;
 			}
 
 			uk_pr_info("driver %p\n", drv);
 
 			/* probe the irq info*/
-			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_INTERRUPT_PIN, 1, &pin);
+			pci_generic_config_read(bus, DEVFN(dev, 0), PCI_INTERRUPT_PIN, 1, (void *)&pin);
 			out_irq.args_count = 1;
 			out_irq.args[0] = pin;
 			fdtaddr[0] = cpu_to_fdt32((bus << 16) | (DEVFN(dev,0) << 8));
@@ -192,8 +190,6 @@ int arch_pci_probe(struct uk_alloc *pha)
 			irq = gic_irq_translate(0, out_irq.args[1]);
 
 			arch_pci_driver_add_device(drv, &addr, &devid, irq, base, pha);
-
-			uk_pr_info("pci dev base(0x%llx) irq(%d)\n");
 		}
 	}
 
diff --git a/plat/common/include/pci/pci_bus.h b/plat/common/include/pci/pci_bus.h
index 78ca977..3b6d863 100644
--- a/plat/common/include/pci/pci_bus.h
+++ b/plat/common/include/pci/pci_bus.h
@@ -181,7 +181,7 @@ struct pci_bus_handler {
 	struct uk_list_head drv_list;  /**< List of PCI drivers */
 	struct uk_list_head dev_list;  /**< List of PCI devices */
 };
-static struct pci_bus_handler ph;
+static struct pci_bus_handler ph __unused;
 
 #define PCI_INVALID_ID              (0xFFFF)
 #define PCI_DEVICE_ID_MASK          (0xFFFF)
diff --git a/plat/common/include/pci/pci_ecam.h b/plat/common/include/pci/pci_ecam.h
index f325a14..e2a42e2 100644
--- a/plat/common/include/pci/pci_ecam.h
+++ b/plat/common/include/pci/pci_ecam.h
@@ -92,7 +92,7 @@ struct fdt_phandle_args {
 
 
 int pci_generic_config_read(__u8 bus, __u8 devfn,
-			    int where, int size, __u32 *val);
+			    int where, int size, void *val);
 
 int pci_generic_config_write(__u8 bus, __u8 devfn,
 			     int where, int size, __u32 val);
diff --git a/plat/common/pci_ecam.c b/plat/common/pci_ecam.c
index b97a580..d07ff1d 100644
--- a/plat/common/pci_ecam.c
+++ b/plat/common/pci_ecam.c
@@ -89,7 +89,7 @@ static void *pci_ecam_map_bus(__u8 bus, __u8 devfn, int where)
 }
 
 int pci_generic_config_read(__u8 bus, __u8 devfn,
-			    int where, int size, __u32 *val)
+			    int where, int size, void *val)
 {
 	void *addr;
 
@@ -97,16 +97,16 @@ int pci_generic_config_read(__u8 bus, __u8 devfn,
 	rmb();
 	addr = pci_ecam_map_bus(bus, devfn, where);
 	if (!addr) {
-		*val = ~0;
+		*(int *)val = ~0;
 		return -1;
 	}
 
 	if (size == 1)
-		*val = ioreg_read8(addr);
+		*(uint8_t *)val = ioreg_read8(addr);
 	else if (size == 2)
-		*val = ioreg_read16(addr);
+		*(uint16_t *)val = ioreg_read16(addr);
 	else if (size == 4)
-		*val = ioreg_read32(addr);
+		*(uint32_t *)val = ioreg_read32(addr);
 	else
 		uk_pr_err("not support size pci config read\n");
 
@@ -117,7 +117,6 @@ int pci_generic_config_write(__u8 bus, __u8 devfn,
 			     int where, int size, __u32 val)
 {
 	void *addr;
-	__u32 mask, tmp;
 
 	addr = pci_ecam_map_bus(bus, devfn, where);
 	if (!addr)
@@ -206,7 +205,7 @@ static int irq_find_parent(const void *fdt, int child)
 {
 	int p;
 	int plen;
-	fdt32_t *prop;
+	const fdt32_t *prop;
 	fdt32_t parent;
 
 	do {
@@ -234,7 +233,7 @@ int gen_pci_irq_parse(const fdt32_t *addr, struct fdt_phandle_args *out_irq)
 	int addrsize, newaddrsize = 0;
 	int imaplen, match, i, rc = -EINVAL;
 	int plen;
-	int *prop;
+	const fdt32_t *prop;
 
 	ipar = gen_pci_fdt;
 
@@ -255,7 +254,7 @@ int gen_pci_irq_parse(const fdt32_t *addr, struct fdt_phandle_args *out_irq)
 	}
 
 	intsize = fdt32_to_cpu(prop[0]);
-	uk_pr_info("irq_parse_raw: ipar=%p, size=%d\n", ipar, intsize);
+	uk_pr_info("irq_parse_raw: ipar=%x, size=%d\n", ipar, intsize);
 
 	if (out_irq->args_count != intsize)
 		goto fail;
@@ -385,7 +384,7 @@ int gen_pci_irq_parse(const fdt32_t *addr, struct fdt_phandle_args *out_irq)
 skiplevel:
 		/* Iterate again with new parent */
 		out_irq->np = newpar;
-		uk_pr_info(" -> new parent: %pOF\n", newpar);
+		uk_pr_info(" -> new parent: %x\n", newpar);
 
 		ipar = newpar;
 		newpar = 0;
@@ -398,17 +397,15 @@ fail:
 }
 
 
-static int gen_pci_probe(struct pf_device *pfdev)
+static int gen_pci_probe(struct pf_device *pfdev __unused)
 {
 	const fdt32_t *prop;
 	int prop_len;
 	__u64 reg_base;
 	__u64 reg_size;
-	int err;
 	struct pci_range range;
 	struct pci_range_parser parser;
-	struct fdt_phandle_args out_irq;
-	fdt32_t laddr[3];
+	int err;
 
 	/* 1.Get the base and size of config space */
 	gen_pci_fdt = fdt_node_offset_by_compatible(fdt_start, -1,
@@ -434,7 +431,7 @@ static int gen_pci_probe(struct pf_device *pfdev)
 
 	pcw.config_base = reg_base;
 	pcw.config_space_size = reg_size;
-	uk_pr_info("generic pci config base(0x%llx),size(0x%llx)\n",
+	uk_pr_info("generic pci config base(0x%lx),size(0x%lx)\n",
 				reg_base, reg_size);
 
 	/* 2.Get the bus range of pci controller */
@@ -456,6 +453,11 @@ static int gen_pci_probe(struct pf_device *pfdev)
 
 	/* 3.Get the pci addr base and limit size for pci devices */
 	err = gen_pci_parser_range(&parser, gen_pci_fdt);
+	if (err < 0) {
+		uk_pr_err("bus-range detect error in fdt\n");
+		goto error_exit;
+	}
+
 	do {
 		pci_range_parser_one(&parser, &range, gen_pci_fdt);
 		if (range.flags == IORESOURCE_IO) {
@@ -465,7 +467,7 @@ static int gen_pci_probe(struct pf_device *pfdev)
 		}
 		parser.range += parser.np;
 	} while (parser.range + parser.np <= parser.end);
-	uk_pr_info("generic pci range base(0x%llx),size(0x%llx)\n",
+	uk_pr_info("generic pci range base(0x%lx),size(0x%lx)\n",
 				pcw.pci_device_base, pcw.pci_device_limit);
 
 	return 0;
@@ -492,18 +494,16 @@ static int gen_pci_add_dev(struct pf_device *pfdev __unused)
 
 static const struct device_match_table gen_pci_match_table[];
 
-static struct pf_device_id *gen_pci_id_match_compatible(const char *compatible)
+static int gen_pci_id_match_compatible(const char *compatible)
 {
-	int i;
-
 	for (int i = 0; gen_pci_match_table[i].compatible != NULL; i++)
 		if (strcmp(gen_pci_match_table[i].compatible, compatible) == 0)
-			return gen_pci_match_table[i].id;
+			return gen_pci_match_table[i].id->device_id;
 
-	return NULL;
+	return -1;
 }
 
-static const struct pf_device_id gen_pci_ids = {
+static struct pf_device_id gen_pci_ids = {
 		.device_id = GEN_PCI_ID
 };
 
diff --git a/plat/drivers/include/ofw/fdt.h b/plat/drivers/include/ofw/fdt.h
index a3896ff..13dfdc2 100644
--- a/plat/drivers/include/ofw/fdt.h
+++ b/plat/drivers/include/ofw/fdt.h
@@ -200,4 +200,15 @@ int fdt_get_interrupt(const void *fdt, int nodeoffset,
  */
 bool fdt_prop_read_bool(const void *fdt, int start_offset,
 					 const char *propname);
+
+/**
+ * fdt_translate_address_by_ranges - Translate an address from the
+ * device-tree into a CPU physical address, this walks up the tree and
+ * applies the various bus mappings on the way.
+ * @fdt: pointer to the device tree blob
+ * @node_offset: start offset of the node to find the address for
+ * @regs regs in device-tree
+ */
+uint64_t fdt_translate_address_by_ranges(const void *fdt,
+				int node_offset, const fdt32_t *regs);
 #endif
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:59:19 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:59: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 1jeY35-0006NI-AL; Fri, 29 May 2020 05:59: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY34-0006N5-A6
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:59:18 +0000
X-Inumbo-ID: 774fd8de-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 774fd8de-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:49 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3ADD955D;
 Thu, 28 May 2020 22:58:49 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 29E9F3F305;
 Thu, 28 May 2020 22:58:46 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 23/27] plat/virtio: Fix virtio net device mac
 negotiation
Date: Fri, 29 May 2020 13:57:13 +0800
Message-Id: <20200529055717.88063-24-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Otherwise, it causes virtio net mac negotiates failure on arm64.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/virtio/virtio_net.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/plat/drivers/virtio/virtio_net.c b/plat/drivers/virtio/virtio_net.c
index 3025ed3..f638ca8 100644
--- a/plat/drivers/virtio/virtio_net.c
+++ b/plat/drivers/virtio/virtio_net.c
@@ -835,7 +835,6 @@ static __u16 virtio_net_mtu_get(struct uk_netdev *n)
 static int virtio_netdev_feature_negotiate(struct virtio_net_device *vndev)
 {
 	__u64 host_features = 0;
-	__u16 hw_len;
 	int rc = 0;
 
 	/**
@@ -865,16 +864,18 @@ static int virtio_netdev_feature_negotiate(struct virtio_net_device *vndev)
 	 * virtio device in a separate header file which could be reused across
 	 * different virtio devices.
 	 */
-	hw_len = virtio_config_get(vndev->vdev,
+	virtio_config_get(vndev->vdev,
 				   __offsetof(struct virtio_net_config, mac),
 				   &vndev->hw_addr.addr_bytes[0],
 				   UK_NETDEV_HWADDR_LEN, 1);
-	if (unlikely(hw_len != UK_NETDEV_HWADDR_LEN)) {
-		uk_pr_err("Failed to retrieve the mac address from device\n");
-		rc = -EAGAIN;
-		goto exit;
-	}
 	rc = 0;
+	uk_pr_info("vndev->hw_addr.addr_bytes=[%x %x %x %x %x %x]\n",vndev->hw_addr.addr_bytes[0],
+		vndev->hw_addr.addr_bytes[1],
+		vndev->hw_addr.addr_bytes[2],
+		vndev->hw_addr.addr_bytes[3],
+		vndev->hw_addr.addr_bytes[4],
+		vndev->hw_addr.addr_bytes[5]);
+
 
 	/**
 	 * Mask out features supported by both driver and device.
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:59:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:59: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 1jeY3A-0006Og-Bv; Fri, 29 May 2020 05:59:24 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY39-0006OU-AJ
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:59:23 +0000
X-Inumbo-ID: 78f64ba0-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 78f64ba0-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:52 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CFCA855D;
 Thu, 28 May 2020 22:58:51 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B64493F305;
 Thu, 28 May 2020 22:58:49 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 24/27] plat/virtio: Change the type of irq,
 base from u16 to u64 for arm64
Date: Fri, 29 May 2020 13:57:14 +0800
Message-Id: <20200529055717.88063-25-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

On arm64, it only supports ECAM pci controller, hence u16 irq,base
is not enough.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/virtio/virtio_pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/plat/drivers/virtio/virtio_pci.c b/plat/drivers/virtio/virtio_pci.c
index c0c9032..3c62a3c 100644
--- a/plat/drivers/virtio/virtio_pci.c
+++ b/plat/drivers/virtio/virtio_pci.c
@@ -57,9 +57,9 @@ struct virtio_pci_dev {
 	/* Virtio Device */
 	struct virtio_dev vdev;
 	/* Pci base address */
-	__u16 pci_base_addr;
+	__u64 pci_base_addr;
 	/* ISR Address Range */
-	__u16 pci_isr_addr;
+	__u64 pci_isr_addr;
 	/* Pci device information */
 	struct pci_device *pdev;
 };
@@ -377,6 +377,8 @@ static int virtio_pci_legacy_add_dev(struct pci_device *pci_dev,
 
 	uk_pr_info("Added virtio-pci device %04x\n",
 		   pci_dev->id.device_id);
+	uk_pr_info("Added virtio-pci subsystem_device_id %04x\n",
+		   pci_dev->id.subsystem_device_id);
 
 	/* Mapping the virtio device identifier */
 	vpci_dev->vdev.id.virtio_device_id = pci_dev->id.subsystem_device_id;
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:59:29 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:59: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 1jeY3F-0006PU-DS; Fri, 29 May 2020 05:59:29 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY3E-0006PM-AZ
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:59:28 +0000
X-Inumbo-ID: 7a6dd3d6-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 7a6dd3d6-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:54 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 711A455D;
 Thu, 28 May 2020 22:58:54 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5767B3F305;
 Thu, 28 May 2020 22:58:52 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 25/27] plat/virtio: Use better iormb/iowmb on
 arm64
Date: Fri, 29 May 2020 13:57:15 +0800
Message-Id: <20200529055717.88063-26-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This replace better mb with the old rmb/wmb

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/include/virtio/virtio_config.h | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/plat/drivers/include/virtio/virtio_config.h b/plat/drivers/include/virtio/virtio_config.h
index b80f26a..84421b4 100644
--- a/plat/drivers/include/virtio/virtio_config.h
+++ b/plat/drivers/include/virtio/virtio_config.h
@@ -115,8 +115,18 @@ static inline void _virtio_cread_bytes(const void *addr, const __u8 offset,
 #else  /* __X86_64__ */
 
 /* IO barriers */
-#define __iormb()		rmb()
-#define __iowmb()		wmb()
+#define __iormb(v)							\
+({									\
+	unsigned long tmp;						\
+	dmb(oshld);							\
+									\
+	asm volatile("eor	%0, %1, %1\n"				\
+		     "cbnz	%0, ."					\
+		     : "=r" (tmp) : "r" ((unsigned long)(v))		\
+		     : "memory");					\
+})
+
+#define __iowmb()		dmb(oshst)
 
 static inline void _virtio_cwrite_bytes(const void *addr, const __u8 offset,
 					const void *buf, int len, int type_len)
@@ -168,7 +178,7 @@ static inline void _virtio_cread_bytes(const void *addr, const __u8 offset,
 		default:
 			UK_CRASH("Unsupported virtio read operation\n");
 		}
-		__iormb();
+		__iormb(io_addr);
 	}
 }
 
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:59:34 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:59: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 1jeY3K-0006QK-F0; Fri, 29 May 2020 05:59: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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY3J-0006QB-Ah
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:59:33 +0000
X-Inumbo-ID: 7bfa7d4e-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 7bfa7d4e-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:57 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1240755D;
 Thu, 28 May 2020 22:58:57 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id ECB893F305;
 Thu, 28 May 2020 22:58:54 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 26/27] plat/virtio_9p: Fix max virtqueue number
 1024 on arm64
Date: Fri, 29 May 2020 13:57:16 +0800
Message-Id: <20200529055717.88063-27-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

On arm64, the virtqueue max number provided by qemu is 1024.
Otherwise, it reports:
Expected 128 descriptors, found 1024 (virtqueue

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/drivers/virtio/virtio_9p.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plat/drivers/virtio/virtio_9p.c b/plat/drivers/virtio/virtio_9p.c
index fe0d69a..b29b1cb 100644
--- a/plat/drivers/virtio/virtio_9p.c
+++ b/plat/drivers/virtio/virtio_9p.c
@@ -44,7 +44,7 @@
 #include <uk/plat/spinlock.h>
 
 #define DRIVER_NAME	"virtio-9p"
-#define NUM_SEGMENTS	128 /** The number of virtqueue descriptors. */
+#define NUM_SEGMENTS	1024 /** The number of virtqueue descriptors. */
 static struct uk_alloc *a;
 
 /* List of initialized virtio 9p devices. */
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 05:59:39 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 05:59: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 1jeY3P-0006RJ-H7; Fri, 29 May 2020 05:59:39 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeY3O-0006RC-At
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 05:59:38 +0000
X-Inumbo-ID: 7d8fc8e4-a171-11ea-a86a-12813bfff9fa
Received: from foss.arm.com (unknown [217.140.110.172])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTP
 id 7d8fc8e4-a171-11ea-a86a-12813bfff9fa;
 Fri, 29 May 2020 05:58:59 +0000 (UTC)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E50155D;
 Thu, 28 May 2020 22:58:59 -0700 (PDT)
Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com
 [10.169.138.57])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8DFB53F305;
 Thu, 28 May 2020 22:58:57 -0700 (PDT)
From: Jia He <justin.he@arm.com>
To: minios-devel@lists.xenproject.org
Subject: [UNIKRAFT PATCH RFCv2 27/27] plat/platform_bus,
 virtio_mmio: Avoid useless log storm
Date: Fri, 29 May 2020 13:57:17 +0800
Message-Id: <20200529055717.88063-28-justin.he@arm.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200529055717.88063-1-justin.he@arm.com>
References: <20200529055717.88063-1-justin.he@arm.com>
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, Jia He <justin.he@arm.com>,
 Sharan.Santhanam@neclab.eu
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

This is to suppress and adjust some log line level for platform bus and
virtio_mmio. E.g. ENODEV is normal when qemu doesn't create any virtio
mmio devices in the platform bus probing.

Signed-off-by: Jia He <justin.he@arm.com>
---
 plat/common/platform_bus.c        | 7 +++----
 plat/drivers/virtio/virtio_mmio.c | 3 +--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/plat/common/platform_bus.c b/plat/common/platform_bus.c
index fecb389..83d3e70 100644
--- a/plat/common/platform_bus.c
+++ b/plat/common/platform_bus.c
@@ -81,7 +81,7 @@ static inline struct pf_driver *pf_find_driver(const char *compatible)
 		id.device_id = (uint16_t)drv->match(compatible);
 		if (id.device_id) {
 			if (pf_device_id_match(&id, drv->device_ids)) {
-				uk_pr_debug("pf driver found  devid(0x%x)\n", id.device_id);
+				uk_pr_debug("pf driver found devid(0x%x)\n", id.device_id);
 
 				return drv;
 			}
@@ -105,8 +105,8 @@ static inline int pf_driver_add_device(struct pf_driver *drv,
 	uk_pr_debug("pf_driver_add_device devid=%d\n", dev->id.device_id);
 
 	ret = drv->add_dev(dev);
-	if (ret < 0) {
-		uk_pr_err("Platform Failed to initialize device driver\n");
+	if (ret < 0 && ret != -ENODEV) {
+		uk_pr_err("Platform Failed to initialize device driver, ret(%d)\n",ret);
 	}
 
 	return ret;
@@ -178,7 +178,6 @@ static int pf_probe(void)
 
 		ret = pf_driver_add_device(drv, dev);
 		if (ret < 0) {
-			uk_pr_err("Platform Failed to initialize device driver, ret(%d)\n",ret);
 			uk_free(pfh.a, dev);
 		}
 	} while (1);
diff --git a/plat/drivers/virtio/virtio_mmio.c b/plat/drivers/virtio/virtio_mmio.c
index 9be07c1..be9e59d 100644
--- a/plat/drivers/virtio/virtio_mmio.c
+++ b/plat/drivers/virtio/virtio_mmio.c
@@ -442,7 +442,6 @@ static int virtio_mmio_add_dev(struct pf_device *pfdev)
 	int rc;
 
 	UK_ASSERT(pfdev != NULL);
-	uk_pr_info("virtio_mmio_add dev\n");
 
 	vm_dev = uk_malloc(a, sizeof(*vm_dev));
 	if (!vm_dev) {
@@ -483,7 +482,7 @@ static int virtio_mmio_add_dev(struct pf_device *pfdev)
 		 * virtio-mmio device with an ID 0 is a (dummy) placeholder
 		 * with no function. End probing now with no error reported.
 		 */
-		uk_pr_err("virtio_device_id is 0\n");
+		uk_pr_info("virtio_device_id is 0\n");
 
 		rc = -ENODEV;
 		goto free_vmdev;
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri May 29 07:01:15 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 07:01:15 +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 1jeZ0y-0003hk-0I; Fri, 29 May 2020 07:01:12 +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=n9Qv=7L=arm.com=justin.he@srs-us1.protection.inumbo.net>)
 id 1jeZ0w-0003hf-I5
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 07:01:10 +0000
X-Inumbo-ID: 2ad7b414-a17a-11ea-a874-12813bfff9fa
Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown
 [40.107.21.75]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 2ad7b414-a17a-11ea-a874-12813bfff9fa;
 Fri, 29 May 2020 07:01:07 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; 
 s=selector2-armh-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=au8GxDwtgkTbgOslzu08kxY+4CVBtVpWi6mcMrYkhJY=;
 b=NG4afsNUjQ+NqoX2w2onWbzXkc9+HhuD/4yWwxXoh8du56nz1HBtz9ykhNH+5YmVq0VG8qRcSePGIlZGNOM5GQCucYJ4cQrluzT57NF2vy3f+aGmg2oUzC6aG5K4jbA1cpWXPu9JncFtrJcTLJ/blqNkhbIYAeho7MFKkntSrXM=
Received: from AM6P195CA0099.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::40)
 by DB6PR08MB2869.eurprd08.prod.outlook.com (2603:10a6:6:22::10) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.27; Fri, 29 May
 2020 07:01:05 +0000
Received: from VE1EUR03FT015.eop-EUR03.prod.protection.outlook.com
 (2603:10a6:209:86:cafe::cb) by AM6P195CA0099.outlook.office365.com
 (2603:10a6:209:86::40) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17 via Frontend
 Transport; Fri, 29 May 2020 07:01:04 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123)
 smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was
 verified) header.d=armh.onmicrosoft.com;lists.xenproject.org;
 dmarc=bestguesspass action=none header.from=arm.com;
Received-SPF: Pass (protection.outlook.com: domain of arm.com designates
 63.35.35.123 as permitted sender) receiver=protection.outlook.com;
 client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com;
Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by
 VE1EUR03FT015.mail.protection.outlook.com (10.152.18.176) with
 Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.3021.23 via Frontend Transport; Fri, 29 May 2020 07:01:04 +0000
Received: ("Tessian outbound cff7dd4de28a:v57");
 Fri, 29 May 2020 07:01:04 +0000
X-CheckRecipientChecked: true
X-CR-MTA-CID: b6439595d12c0f52
X-CR-MTA-TID: 64aa7808
Received: from a16b9927fd03.3
 by 64aa7808-outbound-1.mta.getcheckrecipient.com id
 F7A09BE3-BE93-49D4-8B5F-EDEF798A2487.1; 
 Fri, 29 May 2020 07:00:58 +0000
Received: from EUR05-DB8-obe.outbound.protection.outlook.com
 by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a16b9927fd03.3
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384);
 Fri, 29 May 2020 07:00:58 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=GL+MNsnDLCtYByE+mGo0JQ7W6tq8/5JKg0mouw3XVd14tZXK6CSVyyelOvm0qoSaDi4UGHVBvpbrCr8cS/LRdfyHIiMu8CimmManp8fcKaMli6oYTWOXZbkGcDnetAy4xvd/zRsBtiVrdRnf8jeSqqBLT22uHSXO4oeXD6MluwYRacRjjGO9MC8mcwV0F+oNZ6AqNFA6EfcOPC8oy8+t70gbyQ+jUAqh+Ng49EoTdSxj8JC0HC//6itfCgja+TyyYpKFLhm2Jb9nWnCuvkCWPf/CUT7FNyXpF5uSsuSfqFhXIqV/J/bKW9UhmB/8PahAtvi1h/4AR59bJOVpLzIUzQ==
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=au8GxDwtgkTbgOslzu08kxY+4CVBtVpWi6mcMrYkhJY=;
 b=QkC/ncOsGFKemddebRKLW74SJibMtsW+aazzxv7/Yq4ZjWmRhpV6A2yL5dve9U1CRTcT6mKaeJl/+uCy8IFbtA3qNpJgC4o0ZwKa1GL5cjI5YFm6oRnR1W4VnS+VyLk4Wf3DEVounwMe/8lInZH6RLdvO04kUcq4MLjBfFOWiqsm4bdhJkJvE5YLDfLa6XOMdmAioxpNTtdQbW+ORajiayFWAkp1V2qd/nya2qCJO/jY/9y4phbFdjDf7+abs57YEK1giC8Qss3TQ+X0JKtYVuhqljpmNXbU7FJ03i/EwxzyC/Bkv6uIchETHQ/CGJjfUqdu+99wrIvHT0ZCwRVhYQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass
 header.d=arm.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; 
 s=selector2-armh-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=au8GxDwtgkTbgOslzu08kxY+4CVBtVpWi6mcMrYkhJY=;
 b=NG4afsNUjQ+NqoX2w2onWbzXkc9+HhuD/4yWwxXoh8du56nz1HBtz9ykhNH+5YmVq0VG8qRcSePGIlZGNOM5GQCucYJ4cQrluzT57NF2vy3f+aGmg2oUzC6aG5K4jbA1cpWXPu9JncFtrJcTLJ/blqNkhbIYAeho7MFKkntSrXM=
Received: from AM6PR08MB4069.eurprd08.prod.outlook.com (2603:10a6:20b:af::32)
 by AM6PR08MB2950.eurprd08.prod.outlook.com (2603:10a6:209:44::15)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19; Fri, 29 May
 2020 07:00:57 +0000
Received: from AM6PR08MB4069.eurprd08.prod.outlook.com
 ([fe80::8c97:9695:2f8d:3ae0]) by AM6PR08MB4069.eurprd08.prod.outlook.com
 ([fe80::8c97:9695:2f8d:3ae0%5]) with mapi id 15.20.3021.031; Fri, 29 May 2020
 07:00:57 +0000
From: Justin He <Justin.He@arm.com>
To: Justin He <Justin.He@arm.com>, "minios-devel@lists.xenproject.org"
 <minios-devel@lists.xenproject.org>
Subject: RE: [UNIKRAFT PATCH RFCv2 26/27] plat/virtio_9p: Fix max virtqueue
 number 1024 on arm64
Thread-Topic: [UNIKRAFT PATCH RFCv2 26/27] plat/virtio_9p: Fix max virtqueue
 number 1024 on arm64
Thread-Index: AQHWNX5DCCYHq7rT0kmjTX93Sc1/Sqi+ohKQ
Date: Fri, 29 May 2020 07:00:57 +0000
Message-ID: <AM6PR08MB406909E096CB471D2F35E076F78F0@AM6PR08MB4069.eurprd08.prod.outlook.com>
References: <20200529055717.88063-1-justin.he@arm.com>
 <20200529055717.88063-27-justin.he@arm.com>
In-Reply-To: <20200529055717.88063-27-justin.he@arm.com>
Accept-Language: en-US, zh-CN
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ts-tracking-id: 35df8049-7416-4475-b9d0-bce5a79c2c9e.1
Authentication-Results-Original: arm.com; dkim=none (message not signed)
 header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
x-originating-ip: [203.126.0.111]
x-ms-publictraffictype: Email
X-MS-Office365-Filtering-HT: Tenant
X-MS-Office365-Filtering-Correlation-Id: b24dcf6b-01b8-4aa3-15ed-08d8039e0df2
x-ms-traffictypediagnostic: AM6PR08MB2950:|DB6PR08MB2869:
x-ms-exchange-transport-forked: True
X-Microsoft-Antispam-PRVS: <DB6PR08MB2869CF73AF785D9F7C9C7F98F78F0@DB6PR08MB2869.eurprd08.prod.outlook.com>
x-checkrecipientrouted: true
nodisclaimer: true
x-ms-oob-tlc-oobclassifiers: OLM:2449;OLM:9508;
x-forefront-prvs: 04180B6720
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam-Untrusted: BCL:0;
X-Microsoft-Antispam-Message-Info-Original: pSInrVEbczJBI4t3U0JkBrsunl3vYr9xophP9DSMHN+lJisQ7nXHTV1zUowcJV5FGy6jX+jsD8PSK2JLUfcTwgZ7TkwP9FrFOZXVwtn6zMpw5rxVc4GSgYyQexmnbv1cvaoZ3qVW78bgJJbq1qgq/em79jYjXVJnnQUxzVn81EMom2lAUnEO5Ji56yvtDXiHEohBLmowGoJHSmzpGm5lmTlfVdSfXdHTw8dmEg/iQ3qee/7mdhdv9KeMoZZ107P6EQrEsOqSJgUIVCXlNqoZTv3XW3k5NiEBBkvX05Aquff30/BkpatSpWcUMYR5kcewzaBRT84lnkI9oAnCj5klpQ==
X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en;
 SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB4069.eurprd08.prod.outlook.com;
 PTR:; CAT:NONE; SFTY:;
 SFS:(4636009)(396003)(346002)(136003)(376002)(39860400002)(366004)(9686003)(83380400001)(86362001)(26005)(4326008)(186003)(8936002)(55016002)(6506007)(53546011)(33656002)(8676002)(316002)(7696005)(478600001)(71200400001)(110136005)(66556008)(54906003)(76116006)(66476007)(5660300002)(2906002)(66946007)(64756008)(52536014)(66446008);
 DIR:OUT; SFP:1101; 
x-ms-exchange-antispam-messagedata: ciJ2qatb1URxG0Wb7iA2jYKzakhkrN1bC0PztRtrIZmiu7hpKB+FRyqD3SeveXifPHkiBXRWIdA/BoKrTe40OQlnmISQn5Kw9m9vua3Hwue+vYSmmmEIPb+TYwGoH4Ca3sNCvYpIVRntslPAxNdLqqfb+HMsMKLTU1gAPasoEPF+0UorayN+buBBveRg4LzxRPxeAldK1QRrPWMdlxumSIpyS1/kH0RmRFk2GxWdksuTr6JXg039rFzVrJ8bHZUfvplvP7AndnQK6fO3nKRNhgE4tT3par5bJAi9nZfZ9CXSHT+VEx11VBXJgTGCycjaqrU4vOhaC3dGrJZN9L8KrGe0/DWEdG3hgKsl+h2l1FrG9cWVAyRIFINE5ct7BgLkaXgvVU+VkaERLnJKBQAA6523Ewwiz2ROexNwvPZYrEC7RiTzO65uBLPaMawS25ka5w4Og6veW2LKPZl6YqaT8/ES4WH8UngC8kiaOWfZEnQ=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB2950
Original-Authentication-Results: arm.com; dkim=none (message not signed)
 header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
X-EOPAttributedMessage: 0
X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT015.eop-EUR03.prod.protection.outlook.com
X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:;
 IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com;
 PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:;
 SFS:(4636009)(346002)(396003)(376002)(39860400002)(136003)(46966005)(47076004)(336012)(54906003)(26005)(36906005)(186003)(356005)(82310400002)(4326008)(6506007)(316002)(5660300002)(82740400003)(81166007)(53546011)(8676002)(70206006)(70586007)(110136005)(52536014)(55016002)(9686003)(83380400001)(2906002)(478600001)(7696005)(33656002)(86362001)(8936002);
 DIR:OUT; SFP:1101; 
X-MS-Office365-Filtering-Correlation-Id-Prvs: 813a64c9-edb3-4c9b-0a4e-08d8039e09d6
X-Forefront-PRVS: 04180B6720
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: 9PsntHrDDcg+wq4S+5qXLcw642qVbwG8xbqYv0wfFPbRaAjSl/4aEVZkJKUKsUygwSS1FlU6QI99w2V/k/sRYnakTen8p80NXQxs97YIyRaBppUC0pVEzR5Oe0gmXkmryYgr6iSNNK7fsBqwtqQ1I8nUieCrbsWEXLLSsZH8vNIbjB1LtUtR7ddSjQMkIRLBvQH68Aoah1tZWhYgUYhKj203HZZ9KUNdBp1gkf8RpZhSHln1gtk4vNa32RkzBu7uMVOOT03VA6uOcnPPmlp7/rjJL1Bcsxkqc/4NkVaILx9lLivk5WXN05+eK0QBILr50FRbYp6Qic5Zj2bEIA0+TnVkuOhL+CRVcl32XMUriUk5hKNZaodruRUk9Wd8ieJ/ehr7/LoaGg2M1unIix9xhQ==
X-OriginatorOrg: arm.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2020 07:01:04.5490 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: b24dcf6b-01b8-4aa3-15ed-08d8039e0df2
X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123];
 Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2869
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>
Cc: Felipe Huici <felipe.huici@neclab.eu>, Kaly Xin <Kaly.Xin@arm.com>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>,
 "Sharan.Santhanam@neclab.eu" <Sharan.Santhanam@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>



> -----Original Message-----
> From: Jia He <justin.he@arm.com>
> Sent: Friday, May 29, 2020 1:57 PM
> To: minios-devel@lists.xenproject.org
> Cc: Simon Kuenzer <simon.kuenzer@neclab.eu>;
> Sharan.Santhanam@neclab.eu; Felipe Huici <felipe.huici@neclab.eu>; Kaly
> Xin <Kaly.Xin@arm.com>; Justin He <Justin.He@arm.com>
> Subject: [UNIKRAFT PATCH RFCv2 26/27] plat/virtio_9p: Fix max virtqueue
> number 1024 on arm64
>
> On arm64, the virtqueue max number provided by qemu is 1024.
> Otherwise, it reports:
> Expected 128 descriptors, found 1024 (virtqueue
>
I am not sure it will have impact on x86 codes.
Maybe we could dynamically allocate NUM_SEGMENTS by probing
virtio-device since it is different btw arm64 virtio mmio and x86 virtio
pci device.

--
Cheers,
Justin (Jia He)


> Signed-off-by: Jia He <justin.he@arm.com>
> ---
>  plat/drivers/virtio/virtio_9p.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/plat/drivers/virtio/virtio_9p.c b/plat/drivers/virtio/virtio=
_9p.c
> index fe0d69a..b29b1cb 100644
> --- a/plat/drivers/virtio/virtio_9p.c
> +++ b/plat/drivers/virtio/virtio_9p.c
> @@ -44,7 +44,7 @@
>  #include <uk/plat/spinlock.h>
>
>  #define DRIVER_NAME"virtio-9p"
> -#define NUM_SEGMENTS128 /** The number of virtqueue descriptors.
> */
> +#define NUM_SEGMENTS1024 /** The number of virtqueue
> descriptors. */
>  static struct uk_alloc *a;
>
>  /* List of initialized virtio 9p devices. */
> --
> 2.17.1

IMPORTANT NOTICE: The contents of this email and any attachments are confid=
ential and may also be privileged. If you are not the intended recipient, p=
lease notify the sender immediately and do not disclose the contents to any=
 other person, use it for any purpose, or store or copy the information in =
any medium. Thank you.


From minios-devel-bounces@lists.xenproject.org Fri May 29 13:14:08 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 13:14:08 +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 1jeepq-0007Z0-2l; Fri, 29 May 2020 13:14: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=dol2=7L=lancaster.ac.uk=a.jung@srs-us1.protection.inumbo.net>)
 id 1jeepp-0007Yv-Po
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 13:14:05 +0000
X-Inumbo-ID: 4453ac49-a1ae-11ea-a8b4-12813bfff9fa
Received: from GBR01-LO2-obe.outbound.protection.outlook.com (unknown
 [40.107.10.124]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 4453ac49-a1ae-11ea-a8b4-12813bfff9fa;
 Fri, 29 May 2020 13:14:03 +0000 (UTC)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=C39PhtWPe4mAch9y8km6EW6Epzv1tYTwV5szwsq7PW0tX5ua+oXPV2H6MxtIcVhQUki9L18IzYN8aHeNgpQQF0gFZNFh5F54GnVwe9Su4XPI3EM3ab4b3lkL42oY332HneTz6P2ICO7gk/XB/2o7FZyiPJK+LClTpfREk2bLKi++t//CTn9i3maPYDoKei3vzkNlhsPBVgllgV+2/QYqVVUeu98Rpyz45nSj5Gra1yZzhng6NXgT9S2Gb7n/fbpv+TTeEhM7FocJw1wX2GSmuyDEZ5Hfr3otCKqb3GF5JXDbXdvq03SJ3vHpvtPw6Uus8V94NBsCOaelIF02lFdmmQ==
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=J8OZ4SCPSxeiIi5WwOLwVIZJ0KTGXH/4gRcPNHf6mEc=;
 b=ByRakGaqbfOmvYRuAl75VhxUHAjumQ0HoHbqr29ZC6ADw1zWKX4+HPLUQOKbsWZnwceoZX82eLaykXCAfHaUcEr/otGqoLZoe5y8R01Yc4Pz5JhG2d/4NNOxWbnX/U0RK/C3pWTCy7PRPbPb7tmIqwkozIMiB0vtF4fXAJj4X62RXInWc2Uw4ZmkiZBbYYwQ85Lj6gPOGEyJvhWsxkUE8KOqq/YfsdEbPIQ+3I2tKWomj4Kp4ZlWqr6P7sZdGsRqSE2FSsAH1ZPv/vj7YBGaubrwyun9phtP4UCPRRqnVgq9Wc2AESJ6nGT5LzpTltmnHDv8Xl1WquzXWggv9ZtevQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=lancaster.ac.uk; dmarc=pass action=none
 header.from=lancaster.ac.uk; dkim=pass header.d=lancaster.ac.uk; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=livelancsac.onmicrosoft.com; s=selector2-livelancsac-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=J8OZ4SCPSxeiIi5WwOLwVIZJ0KTGXH/4gRcPNHf6mEc=;
 b=f3m0cLoKFhxgTMTHBg7FxTusFmkBkjDCifxEeoU/8aMpR0Br3SY0R6xVu5m79IDPNppS3Ht/rP6iy8Truq79leRTZ910e/FPu842rX9L146EDVYnIirncTpbcycbpQ5aTxemwFrwravniCJfWpOpEzcpzHIn+VFchlgaa13AV7o=
Received: from LNXP265MB1468.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:82::21)
 by LNXP265MB0713.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:14::23) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17; Fri, 29 May
 2020 13:14:02 +0000
Received: from LNXP265MB1468.GBRP265.PROD.OUTLOOK.COM
 ([fe80::540a:e897:7b7b:a73a]) by LNXP265MB1468.GBRP265.PROD.OUTLOOK.COM
 ([fe80::540a:e897:7b7b:a73a%2]) with mapi id 15.20.3045.018; Fri, 29 May 2020
 13:14:02 +0000
From: "Jung, Alexander" <a.jung@lancaster.ac.uk>
To: =?utf-8?B?TWFsdGUgTcO8bmNo?= <mamu@stablerock.de>
Subject: Re: Unikraft stock project helloworld-cpp not compiling
Thread-Topic: Unikraft stock project helloworld-cpp not compiling
Thread-Index: AQHWNbsFZEf0zzGex0qTad1x6F/hng==
Date: Fri, 29 May 2020 13:14:01 +0000
Message-ID: <844A210B-61CC-410D-8AB4-D68F38A27764@lancaster.ac.uk>
References: <af6608ec-7baa-e7d1-2ce5-7cc7b696a98c@stablerock.de>
In-Reply-To: <af6608ec-7baa-e7d1-2ce5-7cc7b696a98c@stablerock.de>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
user-agent: Microsoft-MacOutlook/16.37.20051002
authentication-results: stablerock.de; dkim=none (message not signed)
 header.d=none;stablerock.de; dmarc=none action=none
 header.from=lancaster.ac.uk;
x-originating-ip: [176.199.210.154]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: f4c6db52-133c-4d7f-bed1-08d803d2281a
x-ms-traffictypediagnostic: LNXP265MB0713:
x-microsoft-antispam-prvs: <LNXP265MB0713F4B9E9C65264D94867D8CE8F0@LNXP265MB0713.GBRP265.PROD.OUTLOOK.COM>
x-ms-oob-tlc-oobclassifiers: OLM:8882;
x-forefront-prvs: 04180B6720
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: qZXKN9QtXiBsFGSIRWZWVq87TQ82IJLleTZ1/98oLmGqJneBWG1dfbFsOeeNO7ykCDK4icFA1MwR/MjdsMHXxQw6hXFNogIBiEbR3KgD68dU1K3lZGTyJyBCnhfQn1vOT+m0/g8cK+Mo2PfuAdGb5LQXUWjrRbB5Ky+5SsEmz4l3Ps2gy2ychfYIoQb2HgVyhb8/W1/94qGU8wYaiTj1lygqFS0M61knZ83dbJ38DQdqCwMQwEENDmtM9JdOrmKXgK8a6UQT7AUMPdSD3o6EOuj1Ba26P04Sushj1ggMStP3ofvXPA/eSCf5AqrW9aK8r6reuvIEXv5wURoOk2q+jsUHr/W10cA9yd9G6NwrOZLY6MloPj1UyOB5wzx2b7PsAXQoNWGKWt0vd+O/KKPjCg==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:LNXP265MB1468.GBRP265.PROD.OUTLOOK.COM; PTR:; CAT:NONE;
 SFTY:;
 SFS:(4636009)(396003)(136003)(39860400002)(366004)(346002)(376002)(8936002)(316002)(786003)(6486002)(54906003)(36756003)(6512007)(5660300002)(8676002)(2906002)(86362001)(478600001)(6916009)(76116006)(2616005)(66476007)(33656002)(26005)(186003)(6506007)(64756008)(91956017)(66556008)(66446008)(66574014)(83380400001)(66946007)(4326008)(71200400001);
 DIR:OUT; SFP:1102; 
x-ms-exchange-antispam-messagedata: xszX0zGNTSCkKKqsOB3bzZtqVrZcjZYBn62LwP3E0qZvqs9xvGhqvCIrkcBrd8SLqcgNFooTS4171jzBFInwz4Hc+FR0FmDeK7syydS6lSjmlPL0cvFzWhdoE/Ec13qjkqkCO2IvPXd9qNmIWHGTUcSWTsR1COYPHf39sYcyWnHATEDparqbMBy+/TwLzOTPz2Q/a9kUzFr3cRiTmXu48T50Wkw5K35EgL5nQetHynnm6YSQmigg6130K1nFO2Ox5KlKNosrPTqDKqHbe4fB/pWPU5Byls3LsJ4xrzhgpL59aRwvDzM7iQJiIslFCbILhiNJyzE2n1Kec2/vb/u+cGMr9kx8cLu0hnKNJMTf2t5FVO293Jgj8ey80Xq4REW/IX7XAA62mhXOMfl7lm9nCKG5sHXMN3RifCe/fQ+7EhIVlL1tbW/jLNnJnJJ2u1h/wc6bklPqEhaJ3p1co0gciNCn4BfhJUPv/OJqkIIZP9aprWMulr3VR6QhbO0+47q2
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="utf-8"
Content-ID: <B23AF967188B9444B1934A64CE8F9410@GBRP265.PROD.OUTLOOK.COM>
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-OriginatorOrg: lancaster.ac.uk
X-MS-Exchange-CrossTenant-Network-Message-Id: f4c6db52-133c-4d7f-bed1-08d803d2281a
X-MS-Exchange-CrossTenant-originalarrivaltime: 29 May 2020 13:14:01.9414 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 9c9bcd11-977a-4e9c-a9a0-bc734090164a
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: /uweEBCiHpCeDmBaDT4Ha1CM85HM+9No3hdkWkfOcFlOmta1J5ulbie8OQtIoeBYb9M/qJcK7bx6sjLvhA1R+g==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: LNXP265MB0713
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>
Cc: "minios-devel@lists.xenproject.org" <minios-devel@lists.xenproject.org>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

SGkgTWFsdGUsDQoNCkFwb2xvZ2llcyBmb3IgdGhlIGRlbGF5ZWQgcmVzcG9uc2UhDQoNCkkganVz
dCB0cmllZCB0aGlzIHNsaWdodGx5IHZlcmJvc2UgbWV0aG9kIG15c2VsZjoNCg0KYGBgYmFzaA0K
JCBwaXAzIGluc3RhbGwgZ2l0K2h0dHBzOi8vZ2l0aHViLmNvbS91bmlrcmFmdC9rcmFmdC5naXRA
OTljZGI5MGQ3NmM3M2M3NGIzYjY2OTk1Y2E2NGE4YWFkNDllNmI1OA0KJCBta2RpciBhcHAtY3Bw
DQokIGNkIGFwcC1jcHANCiQga3JhZnQgaW5pdCAtYSBoZWxsb3dvcmxkLWNwcCBhcHAtY3BwDQok
IGtyYWZ0IGNvbmZpZ3VyZSAtbSB4ODZfNjQgLXAga3ZtDQokIGtyYWZ0IGJ1aWxkDQpgYGANCg0K
QW5kIHdhcyBhYmxlIHRvIHJlLWNyZWF0ZSB0aGUgc2FtZSBwcm9ibGVtLiAgTG9va3MgbGlrZSB0
aGUgY29uZmlndXJhdGlvbiB3YXMgc2V0IHRvIFhlbiBhbmQgbm90IEtWTS4gIFRoZXJlIGlzIGEg
cXVpY2sgZml4IGZvciB0aGlzIGFuZCB0aGF0IGl0IGlzIHRvIGRlbGV0ZSB0aGUgbG9jYWwgYC5j
b25maWdgIGFuZCByZW1vdmUgYHhlbjogdHJ1ZWAgYW5kIGBsaW51eHU6IHRydWVgIGZyb20gdGhl
IGtyYWZ0LnlhbWwgZmlsZS4gDQoNCkknbGwgaGF2ZSBhIGxvb2sgYXQgd2h5IGtyYWZ0IGlzIGZv
cmNpbmcgYSBYZW4gY29uZmlndXJhdGlvbiBvdmVyIGEgS1ZNIHNlbGVjdGlvbiBhbmQgcHVzaCBh
biB1cGRhdGUgYXMgdGhpcyBzaG91bGQgbm90IGJlIHRoZSBkZWZhdWx0IGZ1bmN0aW9uYWxpdHku
DQoNCkhvd2V2ZXIsIHdoZW4gSSBmb3JjZSB0aGUgY2hhbmdlIHRvIEtWTSwgaXQgc3RpbGwgZ2V0
IHRoaXMgZXJyb3IuICBJIGFtIGNjJ2luZyBTaW1vbiB0byBoYXZlIGEgbG9vayBhdCB0aGlzIHRv
by4NCg0KQ2hlZXJzLA0KDQpBbGV4YW5kZXINCg0K77u/T24gMjAuMDUuMjAsIDE4OjE1LCAiTWlu
aW9zLWRldmVsIG9uIGJlaGFsZiBvZiBNYWx0ZSBNw7xuY2giIDxtaW5pb3MtZGV2ZWwtYm91bmNl
c0BsaXN0cy54ZW5wcm9qZWN0Lm9yZyBvbiBiZWhhbGYgb2YgbWFtdUBzdGFibGVyb2NrLmRlPiB3
cm90ZToNCg0KSGVsbG8gVW5pa3JhZnQtZGV2cywNCg0KaSBhbSBub3QgYWJsZSB0byBjb21waWxl
IHRoZSBjdXJyZW50IDAuNCBWZXJpb24gb2YgVW5pa3JhZnQgd2l0aCB0aGUNCkhlbGxvLVdvcmxk
IGV4YW1wbGUgd3JpdHRlbiBpbiBDKysuIEhlcmUgaXMgd2hhdCBpIHRyaWVkOg0KDQprcmFmdCB1
cCAtbSB4ODZfNjQgLXAga3ZtIGhlbGxvd29ybGQtY3BwDQoNClRoZSBwcm9jZXNzIGNyYXNoZXMg
d2l0aCB0aGUgZm9sbG93aW5nIGVycm9yOg0KDQpJbiBmaWxlIGluY2x1ZGVkIGZyb20NCi9ob21l
L3BnNjM1L2hlbGxvd29ybGRjcHAvYnVpbGQvbGliY3h4L29yaWdpbi9saWJjeHgtNy4wLjAuc3Jj
L2luY2x1ZGUvaW9zZndkOjkwLA0KICAgICAgICAgICAgICAgICBmcm9tDQovaG9tZS9wZzYzNS9o
ZWxsb3dvcmxkY3BwL2J1aWxkL2xpYmN4eC9vcmlnaW4vbGliY3h4LTcuMC4wLnNyYy9pbmNsdWRl
L2lvczoyMTUsDQogICAgICAgICAgICAgICAgIGZyb20NCi9ob21lL3BnNjM1L2hlbGxvd29ybGRj
cHAvYnVpbGQvbGliY3h4L29yaWdpbi9saWJjeHgtNy4wLjAuc3JjL2luY2x1ZGUvaW9zdHJlYW06
MzgsDQogICAgICAgICAgICAgICAgIGZyb20gL2hvbWUvcGc2MzUvaGVsbG93b3JsZGNwcC9oZWxs
b3dvcmxkLmNwcDoxOg0KL2hvbWUvcGc2MzUvaGVsbG93b3JsZGNwcC9idWlsZC9saWJjeHgvb3Jp
Z2luL2xpYmN4eC03LjAuMC5zcmMvaW5jbHVkZS93Y2hhci5oOjExOToxNToNCmZhdGFsIGVycm9y
OiB3Y2hhci5oOiBubyBzdWNoIGZpbGUgb3IgZGlyZWN0b3J5DQogI2luY2x1ZGVfbmV4dCA8d2No
YXIuaD4NCiAgICAgICAgICAgICAgIF5+fn5+fn5+fg0KDQprcmFmdCBpdHNlbGYgd29ya3MgYW5k
IGkgYW0gYWJsZSB0byBjb21waWxlIGFuZCBydW4gdGhlIEhlbGxvd29ybGQNCmFwcGxpY2F0aW9u
IHdyaXR0ZW4gaW4gQy4NCg0KTG9va2luZyBmb3J3YXJkIHRvIHlvdXIgcmVwbGllcy4NCg0KQmVz
dA0KTWFsdGUNCg0K


From minios-devel-bounces@lists.xenproject.org Fri May 29 21:09:39 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 29 May 2020 21:09: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 1jemG0-0001Ie-9J; Fri, 29 May 2020 21:09:36 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Ejrq=7L=stablerock.de=mamu@srs-us1.protection.inumbo.net>)
 id 1jeljF-0006kr-7w
 for minios-devel@lists.xenproject.org; Fri, 29 May 2020 20:35:45 +0000
X-Inumbo-ID: f71f1a0a-a1eb-11ea-9dbe-bc764e2007e4
Received: from mail.stablerock.de (unknown [2a03:4000:21:321::12])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id f71f1a0a-a1eb-11ea-9dbe-bc764e2007e4;
 Fri, 29 May 2020 20:35:43 +0000 (UTC)
Received: from [IPv6:2a02:908:4f6:7de0::ab1c] (<unknown>
 [2a02:908:4f6:7de0::ab1c])
 by srv.stablerock.de (OpenSMTPD) with ESMTPSA id 48b9e9c1
 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); 
 Fri, 29 May 2020 22:35:41 +0200 (CEST)
Subject: Re: Unikraft stock project helloworld-cpp not compiling
To: "Jung, Alexander" <a.jung@lancaster.ac.uk>
References: <af6608ec-7baa-e7d1-2ce5-7cc7b696a98c@stablerock.de>
 <844A210B-61CC-410D-8AB4-D68F38A27764@lancaster.ac.uk>
From: =?UTF-8?Q?Malte_M=c3=bcnch?= <mamu@stablerock.de>
Message-ID: <f1ccc06f-7ada-400d-d3fe-eb9cd11793ea@stablerock.de>
Date: Fri, 29 May 2020 22:35:42 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.1
MIME-Version: 1.0
In-Reply-To: <844A210B-61CC-410D-8AB4-D68F38A27764@lancaster.ac.uk>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Mailman-Approved-At: Fri, 29 May 2020 21:09:35 +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>
Cc: "minios-devel@lists.xenproject.org" <minios-devel@lists.xenproject.org>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>
Errors-To: minios-devel-bounces@lists.xenproject.org
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>

Hi,

i think i found the issue and i mailed the solution to Simon yesterday
already :) libnewlib is not activated in the config, when i activate the
libnewlib library it compiles without any issues.

I initialized my app-directory with "kraft up -p kvm -m x86_64
helloworld-cpp" i don't know if this made a difference. As far as i
remember i didnt have issues with wrong KVM or Xen settings.

The question is how to tell kraft to enable newlib directly. As far as i
can see it is already enabled in the kraft.yaml here:

https://github.com/unikraft/app-helloworld-cpp/blob/staging/kraft.yaml

Best regards and thanks for your answer

Malte

On 29.05.20 15:14, Jung, Alexander wrote:
> Hi Malte,
> 
> Apologies for the delayed response!
> 
> I just tried this slightly verbose method myself:
> 
> ```bash
> $ pip3 install git+https://github.com/unikraft/kraft.git@99cdb90d76c73c74b3b66995ca64a8aad49e6b58
> $ mkdir app-cpp
> $ cd app-cpp
> $ kraft init -a helloworld-cpp app-cpp
> $ kraft configure -m x86_64 -p kvm
> $ kraft build
> ```
> 
> And was able to re-create the same problem.  Looks like the configuration was set to Xen and not KVM.  There is a quick fix for this and that it is to delete the local `.config` and remove `xen: true` and `linuxu: true` from the kraft.yaml file. 
> 
> I'll have a look at why kraft is forcing a Xen configuration over a KVM selection and push an update as this should not be the default functionality.
> 
> However, when I force the change to KVM, it still get this error.  I am cc'ing Simon to have a look at this too.
> 
> Cheers,
> 
> Alexander
> 
> ﻿On 20.05.20, 18:15, "Minios-devel on behalf of Malte Münch" <minios-devel-bounces@lists.xenproject.org on behalf of mamu@stablerock.de> wrote:
> 
> Hello Unikraft-devs,
> 
> i am not able to compile the current 0.4 Verion of Unikraft with the
> Hello-World example written in C++. Here is what i tried:
> 
> kraft up -m x86_64 -p kvm helloworld-cpp
> 
> The process crashes with the following error:
> 
> In file included from
> /home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/iosfwd:90,
>                  from
> /home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/ios:215,
>                  from
> /home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/iostream:38,
>                  from /home/pg635/helloworldcpp/helloworld.cpp:1:
> /home/pg635/helloworldcpp/build/libcxx/origin/libcxx-7.0.0.src/include/wchar.h:119:15:
> fatal error: wchar.h: no such file or directory
>  #include_next <wchar.h>
>                ^~~~~~~~~
> 
> kraft itself works and i am able to compile and run the Helloworld
> application written in C.
> 
> Looking forward to your replies.
> 
> Best
> Malte
> 


