From minios-devel-bounces@lists.xenproject.org Thu Oct 01 07:24:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 01 Oct 2020 07:24:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.780.3559 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNswx-0003uG-2o; Thu, 01 Oct 2020 07:24:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 780.3559; Thu, 01 Oct 2020 07:24:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNsww-0003to-Ny; Thu, 01 Oct 2020 07:24:22 +0000
Received: by outflank-mailman (input) for mailman id 780;
 Wed, 30 Sep 2020 14: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=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
 id 1kNdIB-00034S-GZ
 for minios-devel@lists.xen.org; Wed, 30 Sep 2020 14:41:15 +0000
Received: from mail-ed1-x533.google.com (unknown [2a00:1450:4864:20::533])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 67035473-a61a-4213-9bb4-050d3dff4e19;
 Wed, 30 Sep 2020 14:41:14 +0000 (UTC)
Received: by mail-ed1-x533.google.com with SMTP id w1so2142057edr.3
 for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 07:41:14 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
 by smtp.gmail.com with ESMTPSA id y24sm1638234eds.35.2020.09.30.07.41.11
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 30 Sep 2020 07:41:11 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
	id 1kNdIB-00034S-GZ
	for minios-devel@lists.xen.org; Wed, 30 Sep 2020 14:41:15 +0000
X-Inumbo-ID: 67035473-a61a-4213-9bb4-050d3dff4e19
Received: from mail-ed1-x533.google.com (unknown [2a00:1450:4864:20::533])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 67035473-a61a-4213-9bb4-050d3dff4e19;
	Wed, 30 Sep 2020 14:41:14 +0000 (UTC)
Received: by mail-ed1-x533.google.com with SMTP id w1so2142057edr.3
        for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 07:41: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=Z4L/ofaA0fqBQ7lzNgZ0t1N7DcYc5aEaEAWRUTvwJco=;
        b=OaAUqvnDhYEDviXt9NL3M9bNknCc+KofEZ0bb+P0GQLUfPeCt3vyyE+rW0lyU/oJLc
         aiCF6PdreIcq3KFfyz4lVpcsUv79oSah2Da56OKbhcwBts3OPuGaeGc8dDEjnzK9SkB/
         ZgrFQg+XWxk47Q6DLGHrb0rUA86OHuwOzxsphjMyaMCxVg+KoLyAWPElZkEZLLaaUl5K
         p+MRFEuRtErh9Ehp6qkQtgSw9r4vQCS1dyAAqtjaqf02iU2AqPl6kd90aMVfjUg+RkBB
         4y0/7A1EDMvdZCXdSLapiBJnEgFg0TGGDaHVsvPXVKy1nMnPxvXR6FyIMbMl1ibuUS9I
         thwA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
         :references:mime-version:content-transfer-encoding;
        bh=Z4L/ofaA0fqBQ7lzNgZ0t1N7DcYc5aEaEAWRUTvwJco=;
        b=uNhIY+QsUzTQphicI3BTq5uX2vipJCXOBe7I9OOQSCD0bbLv0Yi58Iln2sfrvAFDBN
         fbJ790RbV3LRqqUAKdIv6j0Sp13VPjfvK/2PeXStgXJcec3GXXQFRgHIZ3c/UhxfJOCb
         mN6b5hMBuviPflhzM9+Jlnz/hEENBAnfdIWICxd8oyls8k4fDyjJsjO3o/mVOl3F6dom
         x4zzGv6vrO15pUS31ztsB4fFO97H20gG/UP7hbZwQMG5mxd7OCvh+DWt21xPw3mBOei3
         NQbssgS7C0EfaXrtXRrXfZfu3mr6n0EyjmBSWg71EOnjz74O0EZp6nalYxdyn2SshBd3
         RYCQ==
X-Gm-Message-State: AOAM530SZznmTYHDGQicaE/sfK1nbCEXcSdtdtP0Kn5+Maen2Ml4/m/G
	E9M3vKIbDFPZxFzzd0iSu5olHTuGwk5Zhg==
X-Google-Smtp-Source: ABdhPJzry+pkXrMLafIKXTnIHxASDF0sQKNRbCIN+lEFtdu+kiWd2Mm0CcS40C+4lyr7/1ZBt8NrMw==
X-Received: by 2002:a05:6402:6d6:: with SMTP id n22mr3043346edy.79.1601476872302;
        Wed, 30 Sep 2020 07:41:12 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
        by smtp.gmail.com with ESMTPSA id y24sm1638234eds.35.2020.09.30.07.41.11
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 30 Sep 2020 07:41:11 -0700 (PDT)
From: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
To: minios-devel@lists.xen.org
Cc: cezar.craciunoiu@gmail.com,
	felipe.huici@neclab.eu
Subject: [UNIKRAFT/LIBP11-KIT 3/3] Add Makefile.uk with the build logic
Date: Wed, 30 Sep 2020 17:40:31 +0300
Message-Id: <efbdcfa7afaa885b7cc9b459cdb4cde8f3c21a35.1601473377.git.cezar.craciunoiu@gmail.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <cover.1601473377.git.cezar.craciunoiu@gmail.com>
References: <cover.1601473377.git.cezar.craciunoiu@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

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

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

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

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



From minios-devel-bounces@lists.xenproject.org Thu Oct 01 07:24:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 01 Oct 2020 07:24:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.778.3553 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNsww-0003tp-Sf; Thu, 01 Oct 2020 07:24:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 778.3553; Thu, 01 Oct 2020 07:24:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNsww-0003tb-Le; Thu, 01 Oct 2020 07:24:22 +0000
Received: by outflank-mailman (input) for mailman id 778;
 Wed, 30 Sep 2020 14:41: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=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
 id 1kNdI3-000345-I4
 for minios-devel@lists.xen.org; Wed, 30 Sep 2020 14:41:07 +0000
Received: from mail-ej1-x643.google.com (unknown [2a00:1450:4864:20::643])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 0dad63f7-7252-49db-8b27-d5976b88ca6c;
 Wed, 30 Sep 2020 14:41:06 +0000 (UTC)
Received: by mail-ej1-x643.google.com with SMTP id nw23so3208029ejb.4
 for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 07:41:06 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
 by smtp.gmail.com with ESMTPSA id y24sm1638234eds.35.2020.09.30.07.41.04
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 30 Sep 2020 07:41:04 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
	id 1kNdI3-000345-I4
	for minios-devel@lists.xen.org; Wed, 30 Sep 2020 14:41:07 +0000
X-Inumbo-ID: 0dad63f7-7252-49db-8b27-d5976b88ca6c
Received: from mail-ej1-x643.google.com (unknown [2a00:1450:4864:20::643])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 0dad63f7-7252-49db-8b27-d5976b88ca6c;
	Wed, 30 Sep 2020 14:41:06 +0000 (UTC)
Received: by mail-ej1-x643.google.com with SMTP id nw23so3208029ejb.4
        for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 07: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:in-reply-to:references
         :mime-version:content-transfer-encoding;
        bh=TrEuj8mb7fOOq4D+AmBF6HfCD6vBCbkScMbu4Ru+0UE=;
        b=CBx6jf5T1WJJ7WZuwhcHqiDeArntdzP5ODrZXqohYc1n12Xs2d1QulXprFB7tteC7b
         jjGdx08BHphcFkhjVEEC1N5q08VTpuPZCJNllb+kUpuDTXaJPxIlgDeaJk5f8cw3xxrA
         0d9P1PxkZpxwdDuxrT1AJ4mNYAmDPgEPosrcR4aoRT6YQZc6iV463j7G/+Xwctb1ovo4
         3EfH1IqZVrzbNKQweSLV/4CgOCzLE+zAZcY7Wlmi5d//sKpZMFc5Mr1Pg3PUvo2UL8Kh
         CioUk+ZsyUkwlfIkpTIL9UoH7U2XjPNIkXu79IXrmyNzKFeuL1CHA+9TlUeTl6m8mm6/
         K8iA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
         :references:mime-version:content-transfer-encoding;
        bh=TrEuj8mb7fOOq4D+AmBF6HfCD6vBCbkScMbu4Ru+0UE=;
        b=LAzBKWPREhsLSy1U0YdSMjYAbMfGmPWTemaIKndDSFV0Cl2LI4+6w5f5RfaTukBi6T
         a62CQdw6EK0hw4+7EgxyDLJ6E1BpJ0wehhgHthn+2jToNKlPsT5dcp88hYqlia+ZzZpJ
         s1phlLZ6rH27sKzRaSKXgEeTq0qZlf4uWpJ2pdemJHNbcz3gbJrId2ffGGU5PzKqrKTF
         5QTWgBFr0O3X2t/wXPRtlN67/p15ocZlm3HP1YkEvwevA0IamP3Kno3/kyBRGGUMmtT0
         imtwXFc82xEkj2q/kXKQBk/zldsoxOejyzT95hJOpTOJC+DEU/IcV7WB6EZF9ho0+dun
         kiGA==
X-Gm-Message-State: AOAM532yKXbJ/C2o5ra+jukpbS/+0pYlpDU3eOCf9N9csj9Frikz/4gt
	g5jhfZB4k820Huag9H1ZJTSMriliZxA9Fw==
X-Google-Smtp-Source: ABdhPJzM0E7TCG7IL4zUN3YlQbRPFO5733dQB8wugjaQNKLmr+AtDBF3+Z2Cr2eaSRXAtUF2T0Khrw==
X-Received: by 2002:a17:906:5809:: with SMTP id m9mr3095928ejq.304.1601476865059;
        Wed, 30 Sep 2020 07:41:05 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
        by smtp.gmail.com with ESMTPSA id y24sm1638234eds.35.2020.09.30.07.41.04
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 30 Sep 2020 07:41:04 -0700 (PDT)
From: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
To: minios-devel@lists.xen.org
Cc: cezar.craciunoiu@gmail.com,
	felipe.huici@neclab.eu
Subject: [UNIKRAFT/LIBP11-KIT 2/3] Add necessary functions as glue code
Date: Wed, 30 Sep 2020 17:40:30 +0300
Message-Id: <3498546551d7a10cf0695c5f39a354fea3437c95.1601473377.git.cezar.craciunoiu@gmail.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <cover.1601473377.git.cezar.craciunoiu@gmail.com>
References: <cover.1601473377.git.cezar.craciunoiu@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

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

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

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

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

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



From minios-devel-bounces@lists.xenproject.org Thu Oct 01 07:24:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 01 Oct 2020 07:24:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.776.3552 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNsww-0003tc-TB; Thu, 01 Oct 2020 07:24:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 776.3552; Thu, 01 Oct 2020 07:24:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNsww-0003tI-Jl; Thu, 01 Oct 2020 07:24:22 +0000
Received: by outflank-mailman (input) for mailman id 776;
 Wed, 30 Sep 2020 14:41:01 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
 id 1kNdHx-00033i-CT
 for minios-devel@lists.xen.org; Wed, 30 Sep 2020 14:41:01 +0000
Received: from mail-ed1-x531.google.com (unknown [2a00:1450:4864:20::531])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 579dba7e-65d1-43ae-93fe-29b6ac9c4e30;
 Wed, 30 Sep 2020 14:41:00 +0000 (UTC)
Received: by mail-ed1-x531.google.com with SMTP id n13so2102909edo.10
 for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 07:41:00 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
 by smtp.gmail.com with ESMTPSA id y24sm1638234eds.35.2020.09.30.07.40.58
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 30 Sep 2020 07:40:58 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
	id 1kNdHx-00033i-CT
	for minios-devel@lists.xen.org; Wed, 30 Sep 2020 14:41:01 +0000
X-Inumbo-ID: 579dba7e-65d1-43ae-93fe-29b6ac9c4e30
Received: from mail-ed1-x531.google.com (unknown [2a00:1450:4864:20::531])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 579dba7e-65d1-43ae-93fe-29b6ac9c4e30;
	Wed, 30 Sep 2020 14:41:00 +0000 (UTC)
Received: by mail-ed1-x531.google.com with SMTP id n13so2102909edo.10
        for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 07:41: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
         :mime-version:content-transfer-encoding;
        bh=qz9Wxdl1TK/5QSqW3SsaaPT3WgWNct8ysbBlm61AITQ=;
        b=SiqgT7TTGeD3+Mz5kCeQ28DbqSfoUJFEka1tYVbzcSdAjsU6uiU/woP9F45lAta7MO
         WghrasgOfqfdYdE1Y1Tp9cG/M2REDCXcXEe5NII/LU53ggQznDxo5oG0BQvIkD1aKRyJ
         L5/Es1iho/MoDsl/Y39y0fcrPQC1rGcce+xu8XXajJoilQ8eD8GfpUZR168exWte6PqR
         D8m2XV3rAx+qx+p218hcMpZ+/3qdyAbkQVx3gcO4riMOXVuoZzR2psudkJUT+U7gVy7w
         Ckc7hY1H7W5srUfmAdGlXuTG7NkVFqYAx+3OWGkeFyDYE1VQTQlBDOJbtDBcgrOV7Cu4
         RbHg==
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=qz9Wxdl1TK/5QSqW3SsaaPT3WgWNct8ysbBlm61AITQ=;
        b=i2xbT59CQwdmOToXm4XdZSbmnfBq0HhnARz5+ZFiX0p1oNpOBHHUX/A2BYNFh+vtJl
         NGkv64q5LJQG6Q1pDrSQVFjBab8OkB2z0eFAkmnzq+kS8mUSVBBWjOQBGRXbMU5WrHqO
         NYu2kfWOdSJ0i18+tyxakmr0qifaipV7iLi9KCS0KOSNYhOh9c9bnQGWQG2GSZg0h8vl
         2T2HO+vNUQDxLuXX0Rmalt34kbHzEU66l6dK8l5wCBiGB2BC7eC5UScDElkiIkRuQk+6
         9LmSAjbb0QIIDmwFnVaBgu3VMh1LmMLpkOMMDs5ar1TVSb+tdjA2MR/MGvjFcELkg7cz
         Z2Kg==
X-Gm-Message-State: AOAM532wgG0DNCG1oaJ5CsGNVJHMyyL7OB3s4P05OzNErv+k1gjhcWD5
	mPUXcSmAUB2PB/OE+rxiLUJ8gh0g8iI34A==
X-Google-Smtp-Source: ABdhPJyBQgCgKLeOsn6GXBRRq+XCFx+emiyXSMeU3mfbdfeCfFtiTaOzdaWIxRl+1/kzq6YU/Ru8OQ==
X-Received: by 2002:a50:8e17:: with SMTP id 23mr3032980edw.42.1601476859042;
        Wed, 30 Sep 2020 07:40:59 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
        by smtp.gmail.com with ESMTPSA id y24sm1638234eds.35.2020.09.30.07.40.58
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 30 Sep 2020 07:40:58 -0700 (PDT)
From: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
To: minios-devel@lists.xen.org
Cc: cezar.craciunoiu@gmail.com,
	felipe.huici@neclab.eu
Subject: [UNIKRAFT/LIBP11-KIT 1/3] Add all information files and Config.uk
Date: Wed, 30 Sep 2020 17:40:29 +0300
Message-Id: <53e461884409c6423425b3bb4e0e29d0bb90519c.1601473377.git.cezar.craciunoiu@gmail.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <cover.1601473377.git.cezar.craciunoiu@gmail.com>
References: <cover.1601473377.git.cezar.craciunoiu@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

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

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

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

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



From minios-devel-bounces@lists.xenproject.org Thu Oct 01 07:24:24 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 01 Oct 2020 07:24:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.774.3551 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNsww-0003tR-SD; Thu, 01 Oct 2020 07:24:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 774.3551; Thu, 01 Oct 2020 07:24:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNsww-0003t9-IE; Thu, 01 Oct 2020 07:24:22 +0000
Received: by outflank-mailman (input) for mailman id 774;
 Wed, 30 Sep 2020 14:40:50 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
 id 1kNdHl-00033G-Tv
 for minios-devel@lists.xen.org; Wed, 30 Sep 2020 14:40:50 +0000
Received: from mail-ed1-x531.google.com (unknown [2a00:1450:4864:20::531])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 2e020aa1-e795-44e1-9cdb-fddad899a161;
 Wed, 30 Sep 2020 14:40:49 +0000 (UTC)
Received: by mail-ed1-x531.google.com with SMTP id e22so2124884edq.6
 for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 07:40:49 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
 by smtp.gmail.com with ESMTPSA id y24sm1638234eds.35.2020.09.30.07.40.46
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 30 Sep 2020 07:40:47 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
	id 1kNdHl-00033G-Tv
	for minios-devel@lists.xen.org; Wed, 30 Sep 2020 14:40:50 +0000
X-Inumbo-ID: 2e020aa1-e795-44e1-9cdb-fddad899a161
Received: from mail-ed1-x531.google.com (unknown [2a00:1450:4864:20::531])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 2e020aa1-e795-44e1-9cdb-fddad899a161;
	Wed, 30 Sep 2020 14:40:49 +0000 (UTC)
Received: by mail-ed1-x531.google.com with SMTP id e22so2124884edq.6
        for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 07:40:49 -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=pz0UvKxG2X3OSc+PbAYNUuXAIiSY/5SH4YqRK0g1qq4=;
        b=TANeoQXF4hHNWOWAlclzAkE3c/0wO2ywpgnAINxgakiXJLs3v4Q0BwVzMlhaf0EBiB
         TT4UgXux57GAJhSSTFGdXhMViIbkS1L+y3z94ewXIbpuuqq77qBpGqeKox9OL5JgUV9s
         t0x9mJfWc5wI88NMoOXlT3/azBU8MoatLnXgw8OzL1UaOpQZS9Fy7sCGTXoZY6rMVRZO
         IiSKCm1s+lJTvfH+UjTA9V8UnvH8tWzN4r50ZXJuO/G1f+D/Fpje+iNk30v5jbrMrDHk
         y/Ifk2NsoaV7NNhYZbhT0CmVYVS882xHfG1FEVjnTpMYZEn0WUI5RlGwIHbbWc36Q8NO
         47+Q==
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=pz0UvKxG2X3OSc+PbAYNUuXAIiSY/5SH4YqRK0g1qq4=;
        b=QozGZ1ourqVURKpfjABhrJPKqmjdvTQsqkCkYwlTXZ+rH5fjIdJXrpTMT9CK/sQ4aV
         UHGZqzkXVyAesMS44a1WcrT0Elhr9CVRYvVCThwMgO77EgmgQvqQJY3NsaksowCLzKwK
         TgRGw3zVCmJA4piaqDFCc/2/83l23mQlrcWAyAFtHzwdf2WJjLxv8gbGkHC4R7DATSe/
         ofIvnW2goIpTeGtE2oE/ngXc6CEahRi0fIevPO2TYuLDp+FNzf6Y5Eaxp4xNn3IzDZ38
         b8sOyd6jC4tJoR3Oj5CW+NbomcGLbvtfsdvXaAz5b5MigfEUdO78bSgpO/ot0PTvUmO0
         S2Sg==
X-Gm-Message-State: AOAM532D3OCdbDRSmv5FpV2lxUxxW+L3f16xvPXxyQjZb/qYehv3F/xm
	ghLidKgbQYQX4bWq/jTrwPFpB/XCtrpslg==
X-Google-Smtp-Source: ABdhPJx9uFnOokaJLURVDHmlyLMbpDHYhb2Nf1p3lnV3oWxc0c6ZIUN7HRy3UH+Hgv09vPpFN0c6fg==
X-Received: by 2002:a50:d802:: with SMTP id o2mr3170037edj.152.1601476847972;
        Wed, 30 Sep 2020 07:40:47 -0700 (PDT)
Received: from localhost.localdomain ([79.117.132.73])
        by smtp.gmail.com with ESMTPSA id y24sm1638234eds.35.2020.09.30.07.40.46
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 30 Sep 2020 07:40:47 -0700 (PDT)
From: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
To: minios-devel@lists.xen.org
Cc: cezar.craciunoiu@gmail.com,
	felipe.huici@neclab.eu
Subject: [UNIKRAFT/LIBP11-KIT 0/3] Initial port of libp11-kit
Date: Wed, 30 Sep 2020 17:40:28 +0300
Message-Id: <cover.1601473377.git.cezar.craciunoiu@gmail.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

The libp11-kit library provides a way to load and enumerate PKCS#11
modules. In the case of Unikraft, it will work hand-in-hand with
libtasn1, if configured correctly.

The port ensures functionality for both Linuxu and KVM, as it
was tested. In the case of Xen, position independent code was not
available, so library object files could not be put toghether with
the ones from Unikraft.

Cezar Craciunoiu (3):
  Added all information files and Config.uk needed.
  Add necessary functions as glue code for unikraft
  Add Makefile.uk with all the build logic needed

-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Thu Oct 01 07:24:26 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 01 Oct 2020 07:24:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.737.3548 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNsww-0003t3-Mb; Thu, 01 Oct 2020 07:24:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 737.3548; Thu, 01 Oct 2020 07:24:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNsww-0003sv-Gn; Thu, 01 Oct 2020 07:24:22 +0000
Received: by outflank-mailman (input) for mailman id 737;
 Wed, 30 Sep 2020 13:59: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=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
 id 1kNceA-0006Qf-SK
 for minios-devel@lists.xen.org; Wed, 30 Sep 2020 13:59:54 +0000
Received: from mail-ej1-x632.google.com (unknown [2a00:1450:4864:20::632])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id fc079bd8-8f2a-43ee-a035-3dfccff285b4;
 Wed, 30 Sep 2020 13:59:53 +0000 (UTC)
Received: by mail-ej1-x632.google.com with SMTP id a3so2190355ejy.11
 for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 06:59:53 -0700 (PDT)
Received: from [192.168.0.3] ([79.117.132.73])
 by smtp.gmail.com with ESMTPSA id p3sm1547146edp.28.2020.09.30.06.59.50
 for <minios-devel@lists.xen.org>
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Wed, 30 Sep 2020 06:59:51 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=FZ/q=DH=gmail.com=cezar.craciunoiu@srs-us1.protection.inumbo.net>)
	id 1kNceA-0006Qf-SK
	for minios-devel@lists.xen.org; Wed, 30 Sep 2020 13:59:54 +0000
X-Inumbo-ID: fc079bd8-8f2a-43ee-a035-3dfccff285b4
Received: from mail-ej1-x632.google.com (unknown [2a00:1450:4864:20::632])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id fc079bd8-8f2a-43ee-a035-3dfccff285b4;
	Wed, 30 Sep 2020 13:59:53 +0000 (UTC)
Received: by mail-ej1-x632.google.com with SMTP id a3so2190355ejy.11
        for <minios-devel@lists.xen.org>; Wed, 30 Sep 2020 06:59:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=mime-version:date:message-id:subject:from:to:user-agent;
        bh=WiHmPCVqtdT/IROmOqxVXQ/J/k97jClR8d9yHCE7OR8=;
        b=rAK14QyEjFNly5tgxZiC3srFXKpopQ99pOePgubho6xvkOJ+As+xHb2sRMmbtz4ZKL
         PSzcjqrChM0zu2OQpesB+8bkpV7p3KdrvYO4VYpVaGEIknDl5MVlIHbZDbNBzrOAaZvm
         eyemeJmNM0W+KMdYSFntHy0pP8MQfzfGpJa0XTRq0J+sX2RQVwa7I1H/nojfJBLd5jOm
         G1cDbodkp/ZM1DyHX5xVadGq90NmvAaDBkA55hLx58I3pk8rPaU5X/M6v53lS/cudV1h
         3bpMrAUPI2UwbJVMmcjuoIPskB2M5KWAJ4t4VvrziiKY+56ZfXmXh9FDCkXZ+LEnmAqX
         QQxA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:date:message-id:subject:from:to
         :user-agent;
        bh=WiHmPCVqtdT/IROmOqxVXQ/J/k97jClR8d9yHCE7OR8=;
        b=PUqqbQPzeb45/xV4NjATjfMN6nNy/FqC/MCck8Oju9L3XU8R/ZR1wRZJKKpvhxuCWd
         Tj3EgfbZlBdICChmwBnWbJa65T5mc7nO7o5WSvpkvN0+jfBob4LZjkRR94qTwKoT6vQB
         vFuGnQ+Sm3g/Snegn+KZm0J8sdoT14fLFXvxYrZkTdkNRmmCeEr6ZMykmvCTJGmYHiq2
         I9C9IcV5ARNUjouXNamTHZ2d4KdY5owYkOUYUSYwPblNpo9MuzBbC0NRr0u1yVGqDAJO
         Z1c8EfBvSV0CKdyy/qXE3cyzKHkm9UrW1rH0xwGC35TS9uyVMp6q6wUosRhoJjGEbWaG
         hY8w==
X-Gm-Message-State: AOAM531zpYRGalqafBn2J+dPWyMn69/2YqVYIiGHVJjXMBGbdHRqsZQo
	5XJGDd+u0wlx3C+8WAWUHoEgJT0r18/YRA==
X-Google-Smtp-Source: ABdhPJxR0DDIkk/GZ1eDiMi0qotyRWR7bsS4d1oDyhHT6XQgAA64JOJYDh9sJMh/KqJEqB5LUdjy9Q==
X-Received: by 2002:a17:906:1f89:: with SMTP id t9mr3076690ejr.143.1601474391886;
        Wed, 30 Sep 2020 06:59:51 -0700 (PDT)
Received: from [192.168.0.3] ([79.117.132.73])
        by smtp.gmail.com with ESMTPSA id p3sm1547146edp.28.2020.09.30.06.59.50
        for <minios-devel@lists.xen.org>
        (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 30 Sep 2020 06:59:51 -0700 (PDT)
Content-Type: multipart/alternative;
 boundary="----=_NextPart_35545767.701554111323"
MIME-Version: 1.0
Date: Wed, 30 Sep 2020 16:59:20 +0300
Message-ID: <Mailbird-9671d667-f491-4026-86fa-9f3c8c27be67@gmail.com>
Subject: [COMMENT] Ignore last patches
From: "Cezar Craciunoiu" <cezar.craciunoiu@gmail.com>
To: "" <minios-devel@lists.xen.org>
User-Agent: Mailbird/2.8.43.0
X-Mailbird-ID: Mailbird-9671d667-f491-4026-86fa-9f3c8c27be67@gmail.com

------=_NextPart_35545767.701554111323
Content-Type: text/plain;
 charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Please ignore the last 3 Patches sent by me as they do not have=C2=A0the
proper formatting required.
------=_NextPart_35545767.701554111323
Content-Type: text/html;
 charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<div id=3D"__MailbirdStyleContent" style=3D"font-size: 10pt;font-family: Ar=
ial;color: #000000">Please ignore the last 3 Patches sent by me as they do =
not have&nbsp;<span style=3D"font-size: 10pt">the</span><div><span style=3D=
"font-size: 10pt">proper formatting required.</span><div><div class=3D"mb_s=
ig"></div></div></div></div><img class=3D"mailbird" width=3D"1" height=3D"1=
" style=3D"border:0; width:1; height:1;" src=3D"http://tracking.getmailbird=
.com:8000/opentrackingpixel/?messageId=3DMailbird-9671d667-f491-4026-86fa-9=
f3c8c27be67@gmail.com&senderHash=3D428129F4185574465E427FF361B7A682A725F0E0=
9E2FF4560B6E3FC22B0B586D&recipientHash=3D91AE0C4B8384A044BF33A9B47FFCFC6BE2=
3C7E4379AC07CED68375A5DFECF100&internalId=3De10550c8-0d03-470d-9812-a55178e=
f6bcc">

------=_NextPart_35545767.701554111323--


From minios-devel-bounces@lists.xenproject.org Thu Oct 01 09:37:22 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 01 Oct 2020 09:37:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1144.3764 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNv1b-0000V8-TP; Thu, 01 Oct 2020 09:37:19 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1144.3764; Thu, 01 Oct 2020 09:37:19 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNv1b-0000V1-QL; Thu, 01 Oct 2020 09:37:19 +0000
Received: by outflank-mailman (input) for mailman id 1144;
 Thu, 01 Oct 2020 09:37: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=Tj+q=DI=gmail.com=wei.liu.xen@srs-us1.protection.inumbo.net>)
 id 1kNv1a-0000Uw-Uc
 for minios-devel@lists.xenproject.org; Thu, 01 Oct 2020 09:37:18 +0000
Received: from mail-wr1-f68.google.com (unknown [209.85.221.68])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a8d2bfc4-a7d1-4583-a8fb-d9265447f5c0;
 Thu, 01 Oct 2020 09:37:17 +0000 (UTC)
Received: by mail-wr1-f68.google.com with SMTP id k15so4844360wrn.10;
 Thu, 01 Oct 2020 02:37:17 -0700 (PDT)
Received: from liuwe-devbox-debian-v2 ([51.145.34.42])
 by smtp.gmail.com with ESMTPSA id 185sm8475760wma.18.2020.10.01.02.37.15
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 01 Oct 2020 02:37:15 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=Tj+q=DI=gmail.com=wei.liu.xen@srs-us1.protection.inumbo.net>)
	id 1kNv1a-0000Uw-Uc
	for minios-devel@lists.xenproject.org; Thu, 01 Oct 2020 09:37:18 +0000
X-Inumbo-ID: a8d2bfc4-a7d1-4583-a8fb-d9265447f5c0
Received: from mail-wr1-f68.google.com (unknown [209.85.221.68])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id a8d2bfc4-a7d1-4583-a8fb-d9265447f5c0;
	Thu, 01 Oct 2020 09:37:17 +0000 (UTC)
Received: by mail-wr1-f68.google.com with SMTP id k15so4844360wrn.10;
        Thu, 01 Oct 2020 02:37:17 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:cc:subject:message-id:references
         :mime-version:content-disposition:in-reply-to:user-agent;
        bh=LLZQPOYWmcB5OcvPbTDTfwETRWYxrmdG96TWBsyI9VY=;
        b=fQsXnkvgkJ67zoE2Ehr9TRD7DFy7o+SQPLBHd7yOvQVvVS6f775Un+AFCJ9tuMFiii
         +XuoU8oOsvuIOVyTlV32Yto8BdlS32gQatTex1u0xUH15R5JkELLljbWdmgTJ51couY6
         7uqys0pwkBCQAHZUUbHLoRxz4ePzmmLNI0Y23qY+12NiAZlrrcIEkwE8KCeerl5pbR0T
         gXdrA0hU82lP/tAFaRzHlE5c5gv5iA8BhgNsDZQYyEvQKzxAorQKwHtRizJSm+WpGLup
         LfekMbbrDN+74pvlDbh/LldElZH7fwFnXFN3SpaJ22JvlQKrj+tHPvz5TTIhMX9nlcr9
         yFow==
X-Gm-Message-State: AOAM531Vo1qiH5g2hzalrL34n5xFbqjaHe72SBO0xDoIbxHDBYxGleQw
	VZPV9IkM7GHbJ9iwl45uJZQ=
X-Google-Smtp-Source: ABdhPJzE23z/Iabn8OLDLbEXKIeu7gT8UV4Ljqia8gjLDC2AmQKhZJdscRBdzLVrvgBBaC+yFPE1Lg==
X-Received: by 2002:adf:a3d4:: with SMTP id m20mr8403169wrb.29.1601545036696;
        Thu, 01 Oct 2020 02:37:16 -0700 (PDT)
Received: from liuwe-devbox-debian-v2 ([51.145.34.42])
        by smtp.gmail.com with ESMTPSA id 185sm8475760wma.18.2020.10.01.02.37.15
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 01 Oct 2020 02:37:15 -0700 (PDT)
Date: Thu, 1 Oct 2020 09:37:14 +0000
From: Wei Liu <wl@xen.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org,
	samuel.thibault@ens-lyon.org, wl@xen.org
Subject: Re: [PATCH 0/2] mini-os: netfront: fix some issues
Message-ID: <20201001093714.bcfs7rf4myle6t7g@liuwe-devbox-debian-v2>
References: <20200922105826.26274-1-jgross@suse.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20200922105826.26274-1-jgross@suse.com>
User-Agent: NeoMutt/20180716

On Tue, Sep 22, 2020 at 12:58:24PM +0200, Juergen Gross wrote:
> Fix two issues in mini-os netfront:
> 
> - undo init_netfront interface change and replace it with an alternative
> - fix mini-os suspend/resume handling in netfront
> 
> Juergen Gross (2):
>   mini-os: netfront: retrieve netmask and gateway via extra function
>   mini-os: netfront: fix suspend/resume handling
> 
>  include/netfront.h |   4 +-
>  lwip-net.c         |   4 +-
>  netfront.c         | 173 ++++++++++++++++++++-------------------------
>  test.c             |   2 +-
>  4 files changed, 84 insertions(+), 99 deletions(-)

Pushed to mini-os.

Wei.

> 
> -- 
> 2.26.2
> 


From minios-devel-bounces@lists.xenproject.org Thu Oct 01 12:43:27 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 01 Oct 2020 12:43:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1250.4219 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNxve-00045A-TV; Thu, 01 Oct 2020 12:43:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1250.4219; Thu, 01 Oct 2020 12:43:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNxve-000453-QP; Thu, 01 Oct 2020 12:43:22 +0000
Received: by outflank-mailman (input) for mailman id 1250;
 Thu, 01 Oct 2020 12:43:22 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=z8q3=DI=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kNxve-00044y-Ey
 for minios-devel@lists.xen.org; Thu, 01 Oct 2020 12:43:22 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id eb7c2f60-4061-4664-9cf2-78fee18b3c4e;
 Thu, 01 Oct 2020 12:43:20 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 34C67F2213;
 Thu,  1 Oct 2020 14:43:19 +0200 (CEST)
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 ClHIKRDimTyz; Thu,  1 Oct 2020 14:43:19 +0200 (CEST)
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 067E7F220E
 for <minios-devel@lists.xen.org>; Thu,  1 Oct 2020 14:43:17 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 1 Oct 2020
 14:43:16 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=z8q3=DI=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kNxve-00044y-Ey
	for minios-devel@lists.xen.org; Thu, 01 Oct 2020 12:43:22 +0000
X-Inumbo-ID: eb7c2f60-4061-4664-9cf2-78fee18b3c4e
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id eb7c2f60-4061-4664-9cf2-78fee18b3c4e;
	Thu, 01 Oct 2020 12:43:20 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 34C67F2213;
	Thu,  1 Oct 2020 14:43:19 +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 ClHIKRDimTyz; Thu,  1 Oct 2020 14:43:19 +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 067E7F220E
	for <minios-devel@lists.xen.org>; Thu,  1 Oct 2020 14:43:17 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 1 Oct 2020
 14:43:16 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH] plat/xen: x86: Maximum command line length from Xen headers
Date: Thu, 1 Oct 2020 14:43:14 +0200
Message-ID: <20201001124314.10976-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)

Instead of defining an own maximum size for the command line, in this
commit we use `MAX_GUEST_CMDLINE` from the Xen headers to defining the
maximum command line length.

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

diff --git a/plat/xen/x86/setup.c b/plat/xen/x86/setup.c
index 14b2c26f..7882ebef 100644
--- a/plat/xen/x86/setup.c
+++ b/plat/xen/x86/setup.c
@@ -90,8 +90,7 @@
 #include <xen/arch-x86/cpuid.h>
 #include <xen/arch-x86/hvm/start_info.h>
 
-#define MAX_CMDLINE_SIZE 1024
-static char cmdline[MAX_CMDLINE_SIZE];
+static char cmdline[MAX_GUEST_CMDLINE];
 
 start_info_t *HYPERVISOR_start_info;
 shared_info_t *HYPERVISOR_shared_info;
@@ -180,7 +179,7 @@ void _libxenplat_x86entry(void *start_info)
 	_init_shared_info(); /* remaps shared info */
 
 	strncpy(cmdline, (char *)HYPERVISOR_start_info->cmd_line,
-		MAX_CMDLINE_SIZE);
+		MAX_GUEST_CMDLINE);
 
 	/* Set up events. */
 	init_events();
@@ -193,5 +192,5 @@ void _libxenplat_x86entry(void *start_info)
 
 	init_console();
 
-	ukplat_entry_argp(CONFIG_UK_NAME, cmdline, MAX_CMDLINE_SIZE);
+	ukplat_entry_argp(CONFIG_UK_NAME, cmdline, MAX_GUEST_CMDLINE);
 }
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Thu Oct 01 12:43:33 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 01 Oct 2020 12:43:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1251.4223 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNxvo-000467-Vd; Thu, 01 Oct 2020 12:43:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1251.4223; Thu, 01 Oct 2020 12:43:32 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNxvo-00045z-SM; Thu, 01 Oct 2020 12:43:32 +0000
Received: by outflank-mailman (input) for mailman id 1251;
 Thu, 01 Oct 2020 12:43:31 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=z8q3=DI=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kNxvn-00045r-Pl
 for minios-devel@lists.xen.org; Thu, 01 Oct 2020 12:43:31 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id e027b2fd-5811-47fe-ba1f-b70fca74f91f;
 Thu, 01 Oct 2020 12:43:29 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 7D5E3104AAE;
 Thu,  1 Oct 2020 14:43:28 +0200 (CEST)
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 MIPnItM5UJ67; Thu,  1 Oct 2020 14:43:28 +0200 (CEST)
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 5D8CD104A9F
 for <minios-devel@lists.xen.org>; Thu,  1 Oct 2020 14:43:28 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 1 Oct 2020
 14:43:28 +0200
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=z8q3=DI=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kNxvn-00045r-Pl
	for minios-devel@lists.xen.org; Thu, 01 Oct 2020 12:43:31 +0000
X-Inumbo-ID: e027b2fd-5811-47fe-ba1f-b70fca74f91f
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id e027b2fd-5811-47fe-ba1f-b70fca74f91f;
	Thu, 01 Oct 2020 12:43:29 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 7D5E3104AAE;
	Thu,  1 Oct 2020 14:43:28 +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 MIPnItM5UJ67; Thu,  1 Oct 2020 14:43:28 +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 5D8CD104A9F
	for <minios-devel@lists.xen.org>; Thu,  1 Oct 2020 14:43:28 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 1 Oct 2020
 14:43:28 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH] plat/xen: x86: Detect initrd entry from start_info
Date: Thu, 1 Oct 2020 14:43:25 +0200
Message-ID: <20201001124325.11042-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)

Registers an init ramdisk as memory region.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 plat/xen/x86/setup.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/plat/xen/x86/setup.c b/plat/xen/x86/setup.c
index 7882ebef..5ac24124 100644
--- a/plat/xen/x86/setup.c
+++ b/plat/xen/x86/setup.c
@@ -104,7 +104,7 @@ char _libxenplat_bootstack[2*__STACK_SIZE];
 /*
  * Memory region description
  */
-#define UKPLAT_MEMRD_MAX_ENTRIES 2
+#define UKPLAT_MEMRD_MAX_ENTRIES 3
 unsigned int _libxenplat_mrd_num;
 struct ukplat_memregion_desc _libxenplat_mrd[UKPLAT_MEMRD_MAX_ENTRIES];
 
@@ -163,6 +163,24 @@ static inline void _init_mem(void)
 			DEMAND_MAP_PAGES);
 
 	_libxenplat_mrd_num = 2;
+
+	/* initrd */
+	if (HYPERVISOR_start_info->mod_len) {
+		if (HYPERVISOR_start_info->flags & SIF_MOD_START_PFN)
+			_libxenplat_mrd[2].base  =
+				to_virt(HYPERVISOR_start_info->mod_start);
+		else
+			_libxenplat_mrd[2].base  =
+				(void *) HYPERVISOR_start_info->mod_start;
+		_libxenplat_mrd[2].len   =
+			(size_t) HYPERVISOR_start_info->mod_len;
+		_libxenplat_mrd[2].flags = (UKPLAT_MEMRF_INITRD
+					    | UKPLAT_MEMRF_WRITABLE);
+#if CONFIG_UKPLAT_MEMRNAME
+		_libxenplat_mrd[2].name  = "initrd";
+#endif
+		_libxenplat_mrd_num++;
+	}
 }
 
 void _libxenplat_x86entry(void *start_info) __noreturn;
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Thu Oct 01 14:47:45 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 01 Oct 2020 14:47:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1317.4386 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNzry-0007Ye-V7; Thu, 01 Oct 2020 14:47:42 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1317.4386; Thu, 01 Oct 2020 14:47:42 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kNzry-0007Ya-S7; Thu, 01 Oct 2020 14:47:42 +0000
Received: by outflank-mailman (input) for mailman id 1317;
 Thu, 01 Oct 2020 14:47:41 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=z8q3=DI=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kNzrx-0007YR-95
 for minios-devel@lists.xen.org; Thu, 01 Oct 2020 14:47:41 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id fd4ae64a-9cfe-4b58-a69c-786b5de69aa4;
 Thu, 01 Oct 2020 14:47:39 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id B7C90F207F;
 Thu,  1 Oct 2020 16:47:38 +0200 (CEST)
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 YazeGhskPtuv; Thu,  1 Oct 2020 16:47:38 +0200 (CEST)
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 8622AF2076
 for <minios-devel@lists.xen.org>; Thu,  1 Oct 2020 16:47:36 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 1 Oct 2020
 16:47:36 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=z8q3=DI=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kNzrx-0007YR-95
	for minios-devel@lists.xen.org; Thu, 01 Oct 2020 14:47:41 +0000
X-Inumbo-ID: fd4ae64a-9cfe-4b58-a69c-786b5de69aa4
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id fd4ae64a-9cfe-4b58-a69c-786b5de69aa4;
	Thu, 01 Oct 2020 14:47:39 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id B7C90F207F;
	Thu,  1 Oct 2020 16:47:38 +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 YazeGhskPtuv; Thu,  1 Oct 2020 16:47:38 +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 8622AF2076
	for <minios-devel@lists.xen.org>; Thu,  1 Oct 2020 16:47:36 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 1 Oct 2020
 16:47:36 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH] lib/uknetdev: UK_ETH_FRAME_8021AD_MAXLEN: Fix typo
Date: Thu, 1 Oct 2020 16:47:34 +0200
Message-ID: <20201001144734.32159-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)

This commit fixes a typo in the `UK_ETH_FRAME_8021AD_MAXLEN`
definition that causes also a compilation issue when using the
`UK_ETH_FRAME_MAXLEN` definition.

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

diff --git a/lib/uknetdev/include/uk/netdev_core.h b/lib/uknetdev/include/uk/netdev_core.h
index b9a994e3..e7fa97f2 100644
--- a/lib/uknetdev/include/uk/netdev_core.h
+++ b/lib/uknetdev/include/uk/netdev_core.h
@@ -103,7 +103,7 @@ UK_TAILQ_HEAD(uk_netdev_list, struct uk_netdev);
 					 UK_ETH_PAYLOAD_MAXLEN)
 #define UK_ETH_FRAME_8021Q_MAXLEN	(UK_ETH_HDR_8021_LEN + \
 					 UK_ETH_PAYLOAD_MAXLEN)
-#define UK_ETH_FRAME_8021AD_MAXLEN	(UK_ETH_HDR_8021ADLEN + \
+#define UK_ETH_FRAME_8021AD_MAXLEN	(UK_ETH_HDR_8021AD_LEN + \
 					 UK_ETH_PAYLOAD_MAXLEN)
 #define UK_ETH_FRAME_MAXLEN		(UK_ETH_FRAME_8021AD_MAXLEN)
 
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 05 11:13:57 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 05 Oct 2020 11:13:57 +0000
Received: from list by lists.xenproject.org with outflank-mailman.2974.8549 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kPORG-0001FL-QM; Mon, 05 Oct 2020 11:13:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 2974.8549; Mon, 05 Oct 2020 11:13:54 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kPORG-0001FE-NU; Mon, 05 Oct 2020 11:13:54 +0000
Received: by outflank-mailman (input) for mailman id 2974;
 Mon, 05 Oct 2020 11:13: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=TVZW=DM=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kPORF-0001F9-Cl
 for minios-devel@lists.xen.org; Mon, 05 Oct 2020 11:13:53 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 50f50498-88ab-4eed-bdd9-9c4489d94a9e;
 Mon, 05 Oct 2020 11:13:51 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id E8C6DF21EC;
 Mon,  5 Oct 2020 13:13:49 +0200 (CEST)
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 5C47Ove_3leq; Mon,  5 Oct 2020 13:13:49 +0200 (CEST)
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 B2E0EF21EB
 for <minios-devel@lists.xen.org>; Mon,  5 Oct 2020 13:13:47 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 5 Oct 2020
 13:13:47 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=TVZW=DM=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kPORF-0001F9-Cl
	for minios-devel@lists.xen.org; Mon, 05 Oct 2020 11:13:53 +0000
X-Inumbo-ID: 50f50498-88ab-4eed-bdd9-9c4489d94a9e
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 50f50498-88ab-4eed-bdd9-9c4489d94a9e;
	Mon, 05 Oct 2020 11:13:51 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id E8C6DF21EC;
	Mon,  5 Oct 2020 13:13:49 +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 5C47Ove_3leq; Mon,  5 Oct 2020 13:13:49 +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 B2E0EF21EB
	for <minios-devel@lists.xen.org>; Mon,  5 Oct 2020 13:13:47 +0200 (CEST)
Received: from localhost (192.168.24.96) by puck.office.hd (192.168.24.91)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 5 Oct 2020
 13:13:47 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH] lib/ukblkdev: blkdev.h: Include <uk/assert.h>
Date: Mon, 5 Oct 2020 13:13:45 +0200
Message-ID: <20201005111345.20945-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)

The header file `blkdev.h` uses UK_ASSERT but did not include
`<uk/assert.h>`.

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

diff --git a/lib/ukblkdev/include/uk/blkdev.h b/lib/ukblkdev/include/uk/blkdev.h
index c8de0038..7aa09909 100644
--- a/lib/ukblkdev/include/uk/blkdev.h
+++ b/lib/ukblkdev/include/uk/blkdev.h
@@ -66,6 +66,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <limits.h>
+#include <uk/assert.h>
 #include <uk/list.h>
 #include <uk/errptr.h>
 
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Fri Oct 16 14:51:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 16 Oct 2020 14:51:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.7356.21656 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006vY-Px; Fri, 16 Oct 2020 14:51:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 7356.21656; Fri, 16 Oct 2020 14:51:46 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006vE-DW; Fri, 16 Oct 2020 14:51:46 +0000
Received: by outflank-mailman (input) for mailman id 7356;
 Thu, 15 Oct 2020 13:08:39 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
 id 1kT2zn-0004qg-Ox
 for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:39 +0000
Received: from mail-ej1-x62c.google.com (unknown [2a00:1450:4864:20::62c])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 9c295e3a-82ec-4b51-a73c-79b5a7c6d0f2;
 Thu, 15 Oct 2020 13:08:28 +0000 (UTC)
Received: by mail-ej1-x62c.google.com with SMTP id qp15so3548932ejb.3
 for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08:28 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
 by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.25
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 15 Oct 2020 06:08:26 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
	id 1kT2zn-0004qg-Ox
	for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:39 +0000
X-Inumbo-ID: 9c295e3a-82ec-4b51-a73c-79b5a7c6d0f2
Received: from mail-ej1-x62c.google.com (unknown [2a00:1450:4864:20::62c])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 9c295e3a-82ec-4b51-a73c-79b5a7c6d0f2;
	Thu, 15 Oct 2020 13:08:28 +0000 (UTC)
Received: by mail-ej1-x62c.google.com with SMTP id qp15so3548932ejb.3
        for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08: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
         :in-reply-to:references;
        bh=1u0k6C8hkUqdWAMzKRG9xHOKtPrqnTPtoB0sDkgUKqU=;
        b=CzUktdocOBm2gF2pOdjGb8gIHBECwqJZky8nWDUWIrrEoCaKS1ZpDkRHeIOu9WsYV1
         ygGw6dgsrd5XCMrhaaR0qDTXptl15aoicft406b1+hBSVMMtWhGfLotSw5CSS/e0q9dl
         XE8HfAk5IXZ9pTeBo1q+Gp87uyro7dUryxukOZUP05L6TMWGFTtZ7rilFq0wHHqYnvbG
         SnI7nwQBGJiVS67agDm8ob2VZZO839Lx/DZpNZyvYXDgD2ENnXN9y58hLm+UdT1gybKN
         Hjk056ooCxrITs93Tfv3hD0yDZfH/1a3d3GePeiSsyVhon0VR82UyALaQ4XGUPMIS8Z0
         JuAw==
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:in-reply-to:references;
        bh=1u0k6C8hkUqdWAMzKRG9xHOKtPrqnTPtoB0sDkgUKqU=;
        b=SCCF9F6gfAjOeLIGm5GvuEYvsi+wshkrZyDa8LR1pD20Ok5+py9+yz91+lC3LGfzGH
         ZFH92laToAdQ/cbTkYe70uhWj8e8jgywq2HoRMyAJKJkoZI+dUhR96YD3PCmo8HyHsSU
         P9yw25xQlLM/F3o1hTX8PgUzhjOZOZIFysXZtaypOraXNl8kC1y3Lqvi+NpIQsh3BNkE
         APHKLJ4oSvATfNKvKAZsQV3t1Vn9o/0N9ijK9hrxUT8jfzw4Md4xrWGLKT4h4sAc2kPO
         JCSYGFBel8Qe4J0mp19UGbArI44BMK/UhxornMKJX7jdLZKjNjitKm7yOxtjJI8ADn2X
         iOGQ==
X-Gm-Message-State: AOAM531FhBzvly14TESmIzuqvw4v7zSi3ceWVWgsD4AnkQf7zrpLdzdS
	rROURCqHzMZ6YJS8MiV0JnRPRzuRZ707AIZ2
X-Google-Smtp-Source: ABdhPJzPSNVw1alWJDg2DSHB8SU/Q/bxCqigONHJz1iXFAZYEtt52ZDlr0tVqyH2UCbGE49Olyi/uA==
X-Received: by 2002:a17:906:388:: with SMTP id b8mr4153641eja.62.1602767306847;
        Thu, 15 Oct 2020 06:08:26 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
        by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.25
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 15 Oct 2020 06:08:26 -0700 (PDT)
From: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
Subject: [<UNIKRAFT/LIBHOGWEED> 3/4] Add Makefile.uk
Date: Thu, 15 Oct 2020 16:07:43 +0300
Message-Id: <7e9e0359acdee9d26ba4024f85ce824ac61e3d61.1602712689.git.dragosargint21@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <cover.1602712689.git.dragosargint21@gmail.com>
References: <cover.1602712689.git.dragosargint21@gmail.com>
In-Reply-To: <cover.1602712689.git.dragosargint21@gmail.com>
References: <cover.1602712689.git.dragosargint21@gmail.com>

Signed-off-by: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
---
 Makefile.uk | 464 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 464 insertions(+)
 create mode 100644 Makefile.uk

diff --git a/Makefile.uk b/Makefile.uk
new file mode 100644
index 0000000..be58a91
--- /dev/null
+++ b/Makefile.uk
@@ -0,0 +1,464 @@
+#  SPDX-License-Identifier: BSD-3-Clause
+#
+#  libhogweed Makefile.uk
+#
+#  Authors: Argint Dragos Iulian <dragosargint21@gmail.com>
+#
+#  Copyright (c) 2020, University Politehnica of Bucharest. All rights reserved.
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#  3. Neither the name of the copyright holder nor the names of its
+#     contributors may be used to endorse or promote products derived from
+#     this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#  POSSIBILITY OF SUCH DAMAGE.
+#
+#  THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+#
+
+################################################################################
+# Library registration
+################################################################################
+$(eval $(call addlib_s,libhogweed,$(CONFIG_LIBHOGWEED)))
+#$(eval $(call addlib_s,libhogweedglue,$(CONFIG_LIBHOGWEED)))
+
+################################################################################
+# Original sources
+################################################################################
+LIBHOGWEED_VERSION=3.6
+LIBHOGWEED_URL=https://ftp.gnu.org/gnu/nettle/nettle-$(LIBHOGWEED_VERSION).tar.gz
+LIBHOGWEED_PATCHDIR=$(LIBHOGWEED_BASE)/patches
+LIBHOGWEED_SUBDIR=nettle-$(LIBHOGWEED_VERSION)
+$(eval $(call fetch,libhogweed,$(LIBHOGWEED_URL)))
+#$(eval $(call patch,libhogweed,$(LIBHOHWEED_PATCHDIR),$(LIBHOGWEED_SUBDIR)))
+
+################################################################################
+# Helpers
+################################################################################
+LIBHOGWEED_EXTRACTED = $(LIBHOGWEED_ORIGIN)/nettle-$(LIBHOGWEED_VERSION)
+
+################################################################################
+# Library includes
+################################################################################
+LIBHOGWEED_COMMON_INCLUDES-y     += -I$(LIBHOGWEED_BASE)/include
+LIBHOGWEED_COMMON_INCLUDES-y     += -I$(LIBHOGWEED_EXTRACTED)
+CINCLUDES-$(CONFIG_LIBHOGWEED)   += $(LIBHOGWEED_COMMON_INCLUDES-y)
+CXXINCLUDES-$(CONFIG_LIBHOGWEED) += $(LIBHOGWEED_COMMON_INCLUDES-y)
+
+LIBHOGWEED_CINCLUDES   += -I$(LIBHOGWEED_EXTRACTED)
+LIBHOGWEED_CXXINCLUDES += -I$(LIBHOGWEED_EXTRACTED)
+
+################################################################################
+# Global flags
+################################################################################
+# Suppress flags
+LIBHOGWEED_SUPPRESS_FLAGS += -Wno-unused-parameter \
+        -Wno-unused-variable -Wno-unused-value -Wno-unused-function \
+        -Wno-missing-field-initializers -Wno-implicit-fallthrough \
+        -Wno-sign-compare
+LIBHOGWEED_CFLAGS-y   += $(LIBHOGWEED_SUPPRESS_FLAGS) \
+        -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
+LIBHOGWEED_CXXFLAGS-y += $(LIBHOGWEED_SUPPRESS_FLAGS)
+
+# Preprocessing symbols
+LIBHOGWEED_DEFINES    += -DHAVE_CONFIG_H
+LIBHOGWEED_CFLAGS-y   += $(LIBHOGWEED_DEFINES)
+LIBHOGWEED_CXXFLAGS-y += $(LIBHOGWEED_DEFINES)
+
+################################################################################
+# HOGWEED code -- bignum
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/bignum.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/bignum-random.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/bignum-random-prime.c
+
+################################################################################
+# HOGWEED code -- yarrow
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/yarrow256.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/yarrow_key_event.c
+
+################################################################################
+# HOGWEED code -- gmp
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/mini-gmp.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/gmp-glue.c
+
+################################################################################
+# HOGWEED code -- aes
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/aes-encrypt.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/aes-decrypt.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/aes-encrypt-internal.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/aes-encrypt-table.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/aes-decrypt-internal.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/aes-set-key-internal.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/aes256-set-encrypt-key.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/aes256-set-decrypt-key.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/aes-invert-internal.c
+
+################################################################################
+# HOGWEED code -- sha
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha1-meta.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha1-compress.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha256.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha256-meta.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha256-compress.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha512.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha512-meta.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha512-compress.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha3.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha3-permute.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha3-256.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha384-meta.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sha224-meta.c
+
+################################################################################
+# HOGWEED code -- md5
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/md5.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/md5-compress.c
+
+################################################################################
+# HOGWEED code -- write
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/write-be32.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/write-le32.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/write-le64.c
+
+################################################################################
+# HOGWEED code -- buffer
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/buffer.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/buffer-init.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/realloc.c
+
+################################################################################
+# HOGWEED code -- rsa
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sign-tr.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-keygen.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-encrypt.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-decrypt.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-decrypt-tr.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sha1-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sha1-sign-tr.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sha1-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-md5-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-md5-sign-tr.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-md5-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-pss-sha256-sign-tr.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-pss-sha256-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-pss-sha512-sign-tr.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-pss-sha512-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-pkcs1-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-pkcs1-sign-tr.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-pkcs1-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sha256-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sha256-sign-tr.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sha256-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sha512-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sha512-sign-tr.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sha512-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sec-decrypt.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-sec-compute-root.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa2sexp.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa-blind.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/rsa2openpgp.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pgp-encode.c
+
+################################################################################
+# HOGWEED code -- pss
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pss.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pss-mgf1.c
+
+################################################################################
+# HOGWEED code -- pkcs
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pkcs1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pkcs1-encrypt.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pkcs1-decrypt.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pkcs1-sec-decrypt.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pkcs1-rsa-sha1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pkcs1-rsa-sha256.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pkcs1-rsa-sha512.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pkcs1-rsa-digest.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/pkcs1-rsa-md5.c
+
+################################################################################
+# HOGWEED code -- dsa
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-hash.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-keygen.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-compat.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-compat-keygen.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-gen-params.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-sha1-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-sha1-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-sha256-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa-sha256-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/dsa2sexp.c
+
+################################################################################
+# HOGWEED code -- ecdsa
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecdsa-keygen.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecdsa-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecdsa-verify.c
+
+################################################################################
+# HOGWEED code -- ecc
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-a-to-j.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-add-eh.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-add-ehh.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-add-jja.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-add-jjj.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-add-th.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-add-thh.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-curve25519-modp.s
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-curve25519.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-curve448-modp.s
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-curve448.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-dup-eh.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-dup-jj.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-dup-th.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-ecdsa-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-ecdsa-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-eh-to-a.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-gost-gc256b.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-gost-gc512a.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-gostdsa-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-gostdsa-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-hash.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-j-to-a.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-mod-arith.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-mod-inv.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-mod.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-mul-a-eh.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-mul-a.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-mul-g-eh.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-mul-g.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-mul-m.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-point.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-random.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-scalar.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp192r1-modp.s
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp192r1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp224r1-modp.s
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp224r1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp256r1-redc.s
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp256r1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp384r1-modp.s
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp384r1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp521r1-modp.s
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-secp521r1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ecc-size.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sec-add-1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sec-tabselect.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/cnd-copy.c
+
+################################################################################
+# HOGWEED code -- curve
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/curve25519-mul.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/curve25519-mul-g.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/curve25519-eh-to-x.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/curve448-mul.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/curve448-mul-g.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/curve448-eh-to-x.c
+
+################################################################################
+# HOGWEED code -- gostdsa
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/gostdsa-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/gostdsa-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/gostdsa-vko.c
+
+################################################################################
+# HOGWEED code -- eddsa
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/eddsa-compress.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/eddsa-decompress.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/eddsa-sign.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/eddsa-verify.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/eddsa-expand.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/eddsa-hash.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/eddsa-pubkey.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ed25519-sha512.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/ed448-shake256.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/shake256.c
+
+################################################################################
+# HOGWEED code -- sexp
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sexp.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sexp2rsa.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sexp-format.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sexp2bignum.c
+#LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/sexp-transport-format.c
+
+################################################################################
+# HOGWEED code -- hex encoding
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/base16-encode.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/base16-decode.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/base64-encode.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/base64-decode.c
+
+################################################################################
+# HOGWEED code -- miscellaneous
+################################################################################
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/knuth-lfib.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/hmac.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/hmac-sha1.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/memxor.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/memxor3.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/cnd-memcpy.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/memeql-sec.c
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/cbc.c
+
+################################################################################
+# HOGWEED code -- tests
+################################################################################
+ifeq ($(CONFIG_RSA_COMPUTE_ROOT_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/rsa-compute-root-test.c
+endif
+ifeq ($(CONFIG_RSA_ENCRYPT_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/rsa-encrypt-test.c
+endif
+ifeq ($(CONFIG_RSA_KEYGEN_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/rsa-keygen-test.c
+endif
+ifeq ($(CONFIG_RSA_PSS_SIGN_TR_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/rsa-pss-sign-tr-test.c
+endif
+ifeq ($(CONFIG_RSA_SEC_DECRYPT_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/rsa-sec-decrypt-test.c
+endif
+ifeq ($(CONFIG_RSA_SIGN_TR_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/rsa-sign-tr-test.c
+endif
+ifeq ($(CONFIG_RSA_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/rsa-test.c
+endif
+ifeq ($(CONFIG_RSA2SEXP_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/rsa2sexp-test.c
+endif
+ifeq ($(CONFIG_SEXP2RSA_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/sexp2rsa-test.c
+endif
+ifeq ($(CONFIG_CURVE25519_DH_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/curve25519-dh-test.c
+endif
+ifeq ($(CONFIG_CURVE448_DH_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/curve448-dh-test.c
+endif
+ifeq ($(CONFIG_DSA_KEYGEN_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/dsa-keygen-test.c
+endif
+ifeq ($(CONFIG_DSA_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/dsa-test.c
+endif
+ifeq ($(CONFIG_ECDSA_KEYGEN_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/ecdsa-keygen-test.c
+endif
+ifeq ($(CONFIG_ECDSA_SIGN_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/ecdsa-sign-test.c
+endif
+ifeq ($(CONFIG_ECDSA_VERIFY_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/ecdsa-verify-test.c
+endif
+ifeq ($(CONFIG_EDDSA_COMPRESS_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/eddsa-compress-test.c
+endif
+ifeq ($(CONFIG_EDDSA_SIGN_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/eddsa-sign-test.c
+endif
+ifeq ($(CONFIG_EDDSA_VERIFY_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/eddsa-verify-test.c
+endif
+ifeq ($(CONFIG_GOSTDSA_KEYGEN_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/gostdsa-keygen-test.c
+endif
+ifeq ($(CONFIG_GOSTDSA_SIGN_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/gostdsa-sign-test.c
+endif
+ifeq ($(CONFIG_GOSTDSA_VERIFY_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/gostdsa-verify-test.c
+endif
+ifeq ($(CONFIG_GOSTDSA_VKO_TEST),y)
+LIBHOGWEED_SRCS-y += $(LIBHOGWEED_EXTRACTED)/testsuite/gostdsa-vko-test.c
+endif
+
+################################################################################
+# HOGWEED prepare
+################################################################################
+# Run ./configure
+$(LIBHOGWEED_EXTRACTED)/config.h: $(LIBHOGWEED_BUILD)/.origin
+	$(call verbose_cmd,CONFIG,libhogweed: $(notdir $@), \
+        cd $(LIBHOGWEED_EXTRACTED) && ./configure --enable-mini-gmp \
+    )
+
+$(LIBHOGWEED_EXTRACTED)/make_auxiliar: $(LIBHOGWEED_BUILD)/.origin
+	$(call verbose_cmd,CONFIG,libhogweed: $(notdir $@), \
+        cd $(LIBHOGWEED_EXTRACTED) && \
+        make ecc-secp192r1.h && \
+        make ecc-secp224r1.h && \
+        make ecc-secp256r1.h && \
+       	make ecc-secp384r1.h && \
+        make ecc-secp521r1.h && \
+        make ecc-curve25519.h && \
+        make ecc-curve448.h && \
+        make ecc-gost-gc256b.h && \
+        make ecc-gost-gc512a.h && \
+        /usr/bin/m4 ./asm.m4 machine.m4 config.m4 ecc-curve25519-modp.asm \
+        	> ecc-curve25519-modp.s && \
+        /usr/bin/m4 ./asm.m4 machine.m4 config.m4 ecc-curve448-modp.asm \
+        	> ecc-curve448-modp.s && \
+        /usr/bin/m4 ./asm.m4 machine.m4 config.m4 ecc-secp192r1-modp.asm \
+        	> ecc-secp192r1-modp.s && \
+        /usr/bin/m4 ./asm.m4 machine.m4 config.m4 ecc-secp224r1-modp.asm \
+            > ecc-secp224r1-modp.s && \
+        /usr/bin/m4 ./asm.m4 machine.m4 config.m4 ecc-secp256r1-redc.asm \
+        	> ecc-secp256r1-redc.s && \
+        /usr/bin/m4 ./asm.m4 machine.m4 config.m4 ecc-secp384r1-modp.asm \
+        	> ecc-secp384r1-modp.s && \
+        /usr/bin/m4 ./asm.m4 machine.m4 config.m4 ecc-secp521r1-modp.asm \
+        	> ecc-secp521r1-modp.s && \
+        echo "done" > make_auxiliar \
+    )
+
+LIBHOGWEED_PREPARED_DEPS = $(LIBHOGWEED_EXTRACTED)/config.h \
+							$(LIBHOGWEED_EXTRACTED)/make_auxiliar
+
+$(LIBHOGWEED_BUILD)/.prepared: $(LIBHOGWEED_PREPARED_DEPS)
+
+UK_PREPARE += $(LIBHOGWEED_BUILD)/.prepared
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri Oct 16 14:51:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 16 Oct 2020 14:51:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.7350.21643 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006ue-Dd; Fri, 16 Oct 2020 14:51:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 7350.21643; Fri, 16 Oct 2020 14:51:46 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006uX-7h; Fri, 16 Oct 2020 14:51:46 +0000
Received: by outflank-mailman (input) for mailman id 7350;
 Thu, 15 Oct 2020 13:08: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=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
 id 1kT2zZ-0004qg-Jm
 for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:25 +0000
Received: from mail-ej1-x642.google.com (unknown [2a00:1450:4864:20::642])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d3ef699a-16e9-423e-8d91-a001b6b7b573;
 Thu, 15 Oct 2020 13:08:24 +0000 (UTC)
Received: by mail-ej1-x642.google.com with SMTP id c22so3585840ejx.0
 for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08:23 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
 by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.21
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 15 Oct 2020 06:08:22 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
	id 1kT2zZ-0004qg-Jm
	for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:25 +0000
X-Inumbo-ID: d3ef699a-16e9-423e-8d91-a001b6b7b573
Received: from mail-ej1-x642.google.com (unknown [2a00:1450:4864:20::642])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id d3ef699a-16e9-423e-8d91-a001b6b7b573;
	Thu, 15 Oct 2020 13:08:24 +0000 (UTC)
Received: by mail-ej1-x642.google.com with SMTP id c22so3585840ejx.0
        for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08: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;
        bh=s4MmXvCOiFTH6IeJIIk3rD8VpyPrD8iMHUZRPpxwl74=;
        b=h2S0XaQZ5EWUgK0ZnM8W0UO4n1YJLCvlm3WLoHeNLEMtVYggLMrJQ8xiQCMx7hlSCV
         VIrgBbRIXWyyt48/niK25IwdJpPCrh4z1SUhpa5Kzgo+822E/BgsGj0+IVIkwDAWuUbb
         vC/rrnTuOpY8pXrZD8FlM2swxbON1NnjrvRh0SnBDYasyDHTvX0NRfIPtfRw9VKXLu2K
         8efWjhJR1OPJchkt0VxUmP28Zg5V0vwuM1KLBAqxsAZbcFMAfMAuZxFrPFw1p7ANHTRe
         eqM71ZH86xQ+4ouQ9rbVMp+tdaqlZkAZdRAkdhidG6BDTzeA8oc6nIAILf0ibmw8cuq5
         w0Xg==
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=s4MmXvCOiFTH6IeJIIk3rD8VpyPrD8iMHUZRPpxwl74=;
        b=tQBJ0ymNLDfwfOti3sefjZhFWzvn8V7R736nR6Kp8LXKV3tnaLOy45jyMl9lxo/dAg
         khJGTA+QNIbZjNLpjkMmGBLtHzB5+GXUwj8vudcLjtmOBAZh5Gg9epacfg8x3iyjZSDA
         4Sr+JhtinBZLK8f0Ze3oh/SFZTpwfq2VmYnsl2noQwO8fHJJWP6w59hpJ4EoaRTr8EgA
         hxWQtqmhUCNT9cRx+TJjrPICuI2GNvglLQYvhZ1CpZtGuCZhkc2+ox2kJ/OkDHwoaIQy
         Q8Ut49eHMIRP6QXs9mbU+ksfzaqL4KU/SrCJHBXaBkjxRfTLhYRAkGedAow6r/FZy3bW
         J14A==
X-Gm-Message-State: AOAM53367YbfocpMcqrD0NkVr1N2kmy9pDNs8rC4n8kkP9dbXv14l541
	oC4tM6kmrHMZAF0wJloGzkSTmbqnbwRkDQ==
X-Google-Smtp-Source: ABdhPJz345H9yMzPiVZYG/RIpBhUiJQHH9DvsQhujreN8c1LnHqBUvATwkBdpyShngACaeBf5RcPAw==
X-Received: by 2002:a17:906:f92:: with SMTP id q18mr4208279ejj.237.1602767302846;
        Thu, 15 Oct 2020 06:08:22 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
        by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.21
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 15 Oct 2020 06:08:22 -0700 (PDT)
From: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
Subject: [<UNIKRAFT/LIBHOGWEED> 0/4] Initial port of libhogweed on Unikraft
Date: Thu, 15 Oct 2020 16:07:40 +0300
Message-Id: <cover.1602712689.git.dragosargint21@gmail.com>
X-Mailer: git-send-email 2.17.1

Nettle is a cryptographic library that is designed to fit easily in more or
less any context: In crypto toolkits for object-oriented languages
(C++, Python, Pike, ...), in applications like LSH or GNUPG, or even in kernel
space.

Nettle actually consists of two libraries, libnettle and libhogweed. The
libhogweed library contains those functions of Nettle that uses bignum
operations, and depends on the GMP library.

github repository: https://github.com/dragosargint/libhogweed.git


ARGINT DRAGOS IULIAN (4):
  Add md files
  Add Config.uk
  Add Makefile.uk
  Add test directory

 .gitignore            |  27 ++
 CODING_STYLE.md       |   4 +
 CONTRIBUTING.md       |   4 +
 COPYING.md            |  39 +++
 Config.uk             |  62 ++++
 MAINTAINERS.md        |  11 +
 Makefile.uk           | 464 ++++++++++++++++++++++++++++
 README.md             |  39 +++
 test/Config.uk        |   5 +
 test/Makefile         |   9 +
 test/Makefile.uk      |   2 +
 test/testutils.h      | 305 ++++++++++++++++++
 test/testutils_glue.c | 696 ++++++++++++++++++++++++++++++++++++++++++
 13 files changed, 1667 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 CODING_STYLE.md
 create mode 100644 CONTRIBUTING.md
 create mode 100644 COPYING.md
 create mode 100644 Config.uk
 create mode 100644 MAINTAINERS.md
 create mode 100644 Makefile.uk
 create mode 100644 README.md
 create mode 100644 test/Config.uk
 create mode 100644 test/Makefile
 create mode 100644 test/Makefile.uk
 create mode 100644 test/testutils.h
 create mode 100644 test/testutils_glue.c

-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri Oct 16 14:51:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 16 Oct 2020 14:51:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.7358.21659 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006vq-Qd; Fri, 16 Oct 2020 14:51:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 7358.21659; Fri, 16 Oct 2020 14:51:46 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006vU-G0; Fri, 16 Oct 2020 14:51:46 +0000
Received: by outflank-mailman (input) for mailman id 7358;
 Thu, 15 Oct 2020 13:08: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=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
 id 1kT2zs-0004qg-P9
 for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:44 +0000
Received: from mail-ej1-x62a.google.com (unknown [2a00:1450:4864:20::62a])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 95a7abda-3a5e-411b-aea5-a22e44fdc665;
 Thu, 15 Oct 2020 13:08:30 +0000 (UTC)
Received: by mail-ej1-x62a.google.com with SMTP id ce10so3538905ejc.5
 for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08:30 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
 by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.27
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 15 Oct 2020 06:08:27 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
	id 1kT2zs-0004qg-P9
	for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:44 +0000
X-Inumbo-ID: 95a7abda-3a5e-411b-aea5-a22e44fdc665
Received: from mail-ej1-x62a.google.com (unknown [2a00:1450:4864:20::62a])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 95a7abda-3a5e-411b-aea5-a22e44fdc665;
	Thu, 15 Oct 2020 13:08:30 +0000 (UTC)
Received: by mail-ej1-x62a.google.com with SMTP id ce10so3538905ejc.5
        for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08: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
         :in-reply-to:references;
        bh=1qQ0pDlpJ4athQkxnG+3umjMzwe2caWu31+uK5UYLb4=;
        b=XGXgMkOGpYMNHSrlkhmzclnnsFtVFatx5jEDCMssvwzuihfiGgGJgKJ0hPQusGWmnV
         G1+yMhw5VbEi7DK/PG3hyQezGZoE43oGIeyHx8ELfWOxjsJkBExUOd6EzQsVuT75TPIY
         di+2VkAlk3ffBm7YJiO8tQpYhVYd1gk5Fhn48oVRTc4iGuaU/tIxp7sqYb5CrP8elqKT
         XrHhAz5G0ouQq+Fb3vB0hixGnxW4Eh6pm77yfdCs8pcoCI3JOOXL1ApxJvYg4dqWvgg8
         wYCKOENvriNdCfwTv/brpGi0xj1LmAGzn7b3wvviy9XyW6bH3bPkhwtSKNPrHKADL4e7
         NxzA==
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:in-reply-to:references;
        bh=1qQ0pDlpJ4athQkxnG+3umjMzwe2caWu31+uK5UYLb4=;
        b=gH2l8fE1fU6CcpYtaclUorNIo6LAWkx34rdp9x7iR5AXoa/PH6yPPl1zVx0fX5qqml
         68Pmmi6v0GwqHkfFP51/pIsG43tECE7OxHnTgqSC7b62bySgWaf7givbwhlCc2AslM2Z
         s8dG3dVTvLW/h3IqvChfNb5ynmn3k8cYWUZaeA3glf74Lllf1xwtsPIaS1NIb+euuVEL
         Wf3fhHoeONWZ6YfB8QucRC7zX/3OIGiegQF5jyGVvqEkuciU2eWD6sirVs2CkeOkRQRL
         1B4UJQRgWhXRn2nJdZq+xqehHbtr5hQ3qeSrbqOgPQbzjg3Wpdor3YaIbQ99KbxHOx9F
         D+jw==
X-Gm-Message-State: AOAM532IbpnqHryu15xvlnqlHsEtOJ6J5wtA7C5HS1LP8aPIi5o+uKhc
	bp7/izTwmbC+yQt+bQgXSuRWwamXAWTQe9Uz
X-Google-Smtp-Source: ABdhPJzzCKEfiEWKrb8X0WKfJCZ2UCvpjJ7osthztdJouVpddK75UElfQMJBLv1i2x+z8BEGJvg/fg==
X-Received: by 2002:a17:906:c407:: with SMTP id u7mr4335868ejz.206.1602767307843;
        Thu, 15 Oct 2020 06:08:27 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
        by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.27
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 15 Oct 2020 06:08:27 -0700 (PDT)
From: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
Subject: [<UNIKRAFT/LIBHOGWEED> 4/4] Add test directory
Date: Thu, 15 Oct 2020 16:07:44 +0300
Message-Id: <254bc00bda62f519262e16cdacac1f9b0cc7ecdf.1602712689.git.dragosargint21@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <cover.1602712689.git.dragosargint21@gmail.com>
References: <cover.1602712689.git.dragosargint21@gmail.com>
In-Reply-To: <cover.1602712689.git.dragosargint21@gmail.com>
References: <cover.1602712689.git.dragosargint21@gmail.com>

Signed-off-by: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
---
 test/Config.uk        |   5 +
 test/Makefile         |   9 +
 test/Makefile.uk      |   2 +
 test/testutils.h      | 305 ++++++++++++++++++
 test/testutils_glue.c | 696 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1017 insertions(+)
 create mode 100644 test/Config.uk
 create mode 100644 test/Makefile
 create mode 100644 test/Makefile.uk
 create mode 100644 test/testutils.h
 create mode 100644 test/testutils_glue.c

diff --git a/test/Config.uk b/test/Config.uk
new file mode 100644
index 0000000..14fcc3c
--- /dev/null
+++ b/test/Config.uk
@@ -0,0 +1,5 @@
+### Invisible option for dependencies
+config TEST_DEPENDENCIES
+	bool
+	default y
+
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..a6dd029
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,9 @@
+UK_ROOT ?= $(PWD)/../../../unikraft
+UK_LIBS ?= $(PWD)/../../../libs
+LIBS := $(UK_LIBS)/newlib:$(UK_LIBS)/libhogweed
+
+all:
+	@$(MAKE) -C $(UK_ROOT) A=$(PWD) L=$(LIBS)
+
+$(MAKECMDGOALS):
+	@$(MAKE) -C $(UK_ROOT) A=$(PWD) L=$(LIBS) $(MAKECMDGOALS)
diff --git a/test/Makefile.uk b/test/Makefile.uk
new file mode 100644
index 0000000..a96d0d3
--- /dev/null
+++ b/test/Makefile.uk
@@ -0,0 +1,2 @@
+$(eval $(call addlib,test))
+TEST_SRCS-y += $(TEST_BASE)/testutils_glue.c
diff --git a/test/testutils.h b/test/testutils.h
new file mode 100644
index 0000000..c7f5365
--- /dev/null
+++ b/test/testutils.h
@@ -0,0 +1,305 @@
+#ifndef NETTLE_TESTUTILS_H_INCLUDED
+#define NETTLE_TESTUTILS_H_INCLUDED
+
+/* config.h should usually be first in each .c file. This is an
+   exception, include it here to reduce clutter in the test cases. */
+//#if HAVE_CONFIG_H
+# include "config.h"
+//#endif
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "nettle-types.h"
+#include "version.h"
+
+#if WITH_HOGWEED
+# include "rsa.h"
+# include "dsa-compat.h"
+# include "ecc-curve.h"
+# include "ecc.h"
+# include "ecc-internal.h"
+# include "ecdsa.h"
+# include "gmp-glue.h"
+# if NETTLE_USE_MINI_GMP
+#  include "knuth-lfib.h"
+# endif
+
+/* Undo dsa-compat name mangling */
+#undef dsa_generate_keypair
+#define dsa_generate_keypair nettle_dsa_generate_keypair
+#endif /* WITH_HOGWEED */
+
+#include "nettle-meta.h"
+
+/* Forward declare */
+struct nettle_aead;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void
+die(const char *format, ...) PRINTF_STYLE (1, 2) NORETURN;
+
+void *
+xalloc(size_t size);
+
+struct tstring {
+  struct tstring *next;
+  size_t length;
+  uint8_t data[1];
+};
+
+struct tstring *
+tstring_alloc (size_t length);
+
+void
+tstring_clear(void);
+
+struct tstring *
+tstring_data(size_t length, const uint8_t *data);
+
+struct tstring *
+tstring_hex(const char *hex);
+
+void
+tstring_print_hex(const struct tstring *s);
+
+/* Decodes a NUL-terminated hex string. */
+
+void
+print_hex(size_t length, const uint8_t *data);
+
+/* The main program */
+void
+test_main(void);
+
+extern int verbose;
+
+/* Test functions deallocate their inputs when finished.*/
+void
+test_cipher(const struct nettle_cipher *cipher,
+	    const struct tstring *key,
+	    const struct tstring *cleartext,
+	    const struct tstring *ciphertext);
+
+void
+test_cipher_cbc(const struct nettle_cipher *cipher,
+		const struct tstring *key,
+		const struct tstring *cleartext,
+		const struct tstring *ciphertext,
+		const struct tstring *iv);
+
+void
+test_cipher_cfb(const struct nettle_cipher *cipher,
+		const struct tstring *key,
+		const struct tstring *cleartext,
+		const struct tstring *ciphertext,
+		const struct tstring *iv);
+
+void
+test_cipher_cfb8(const struct nettle_cipher *cipher,
+		 const struct tstring *key,
+		 const struct tstring *cleartext,
+		 const struct tstring *ciphertext,
+		 const struct tstring *iv);
+
+void
+test_cipher_ctr(const struct nettle_cipher *cipher,
+		const struct tstring *key,
+		const struct tstring *cleartext,
+		const struct tstring *ciphertext,
+		const struct tstring *iv);
+
+void
+test_cipher_stream(const struct nettle_cipher *cipher,
+		   const struct tstring *key,
+		   const struct tstring *cleartext,
+		   const struct tstring *ciphertext);
+
+void
+test_aead(const struct nettle_aead *aead,
+	  nettle_hash_update_func *set_nonce,
+	  const struct tstring *key,
+	  const struct tstring *authtext,
+	  const struct tstring *cleartext,
+	  const struct tstring *ciphertext,
+	  const struct tstring *nonce,
+	  const struct tstring *digest);
+
+void
+test_hash(const struct nettle_hash *hash,
+	  const struct tstring *msg,
+	  const struct tstring *digest);
+
+void
+test_hash_large(const struct nettle_hash *hash,
+		size_t count, size_t length,
+		uint8_t c,
+		const struct tstring *digest);
+
+void
+test_mac(const struct nettle_mac *mac,
+	 const struct tstring *key,
+	 const struct tstring *msg,
+	 const struct tstring *digest);
+
+void
+test_armor(const struct nettle_armor *armor,
+           size_t data_length,
+           const uint8_t *data,
+           const char *ascii);
+
+#if WITH_HOGWEED
+
+#if NETTLE_USE_MINI_GMP
+typedef struct knuth_lfib_ctx gmp_randstate_t[1];
+
+void gmp_randinit_default (struct knuth_lfib_ctx *ctx);
+#define gmp_randclear(state)
+void mpz_urandomb (mpz_t r, struct knuth_lfib_ctx *ctx, mp_bitcnt_t bits);
+/* This is cheating */
+#define mpz_rrandomb mpz_urandomb
+
+#endif /* NETTLE_USE_MINI_GMP */
+
+void
+mpn_out_str (FILE *f, int base, const mp_limb_t *xp, mp_size_t xn);
+
+mp_limb_t *
+xalloc_limbs (mp_size_t n);
+
+void
+write_mpn (FILE *f, int base, const mp_limb_t *xp, mp_size_t n);
+
+void
+test_rsa_set_key_1(struct rsa_public_key *pub,
+		   struct rsa_private_key *key);
+
+void
+test_rsa_md5(struct rsa_public_key *pub,
+	     struct rsa_private_key *key,
+	     mpz_t expected);
+
+void
+test_rsa_sha1(struct rsa_public_key *pub,
+	      struct rsa_private_key *key,
+	      mpz_t expected);
+
+void
+test_rsa_sha256(struct rsa_public_key *pub,
+		struct rsa_private_key *key,
+		mpz_t expected);
+
+void
+test_rsa_sha512(struct rsa_public_key *pub,
+		struct rsa_private_key *key,
+		mpz_t expected);
+
+void
+test_rsa_key(struct rsa_public_key *pub,
+	     struct rsa_private_key *key);
+
+void
+test_dsa160(const struct dsa_public_key *pub,
+	    const struct dsa_private_key *key,
+	    const struct dsa_signature *expected);
+
+void
+test_dsa256(const struct dsa_public_key *pub,
+	    const struct dsa_private_key *key,
+	    const struct dsa_signature *expected);
+
+#if 0
+void
+test_dsa_sign(const struct dsa_public_key *pub,
+	      const struct dsa_private_key *key,
+	      const struct nettle_hash *hash,
+	      const struct dsa_signature *expected);
+#endif
+
+void
+test_dsa_verify(const struct dsa_params *params,
+		const mpz_t pub,
+		const struct nettle_hash *hash,
+		struct tstring *msg,
+		const struct dsa_signature *ref);
+
+void
+test_dsa_key(const struct dsa_params *params,
+	     const mpz_t pub,
+	     const mpz_t key,
+	     unsigned q_size);
+
+extern const struct ecc_curve * const ecc_curves[];
+
+struct ecc_ref_point
+{
+  const char *x;
+  const char *y;
+};
+
+void
+test_ecc_point (const struct ecc_curve *ecc,
+		const struct ecc_ref_point *ref,
+		const mp_limb_t *p);
+
+void
+test_ecc_mul_a (unsigned curve, unsigned n, const mp_limb_t *p);
+
+void
+test_ecc_mul_h (unsigned curve, unsigned n, const mp_limb_t *p);
+
+/* Checks that p == g (affine coordinates) */
+void
+test_ecc_ga (unsigned curve, const mp_limb_t *p);
+
+/* Gets the curve generator, with coordinates in redc form, if
+   appropriate, and with an appended z = 1 coordinate. */
+void
+test_ecc_get_g (unsigned curve, mp_limb_t *rp);
+
+/* Variant with only two coordinates, and no redc. */
+void
+test_ecc_get_ga (unsigned curve, mp_limb_t *rp);
+
+#endif /* WITH_HOGWEED */
+
+/* String literal of type unsigned char. The GNUC version is safer. */
+#if __GNUC__
+#define US(s) ({ static const unsigned char us_s[] = s; us_s; })
+#else
+#define US(s) ((const uint8_t *) (s))
+#endif
+  
+/* LDATA needs to handle NUL characters. */
+#define LLENGTH(x) (sizeof(x) - 1)
+#define LDATA(x) LLENGTH(x), US(x)
+#define LDUP(x) strlen(x), strdup(x)
+
+#define SHEX(x) (tstring_hex(x))
+#define SDATA(x) ((const struct tstring *)tstring_data(LLENGTH(x), US(x)))
+#define H(x) (SHEX(x)->data)
+
+#define MEMEQ(length, a, b) (!memcmp((a), (b), (length)))
+
+#define FAIL() abort()
+#define SKIP() exit(77)
+
+#define ASSERT(x) do {							\
+    if (!(x))								\
+      {									\
+	fprintf(stderr, "Assert failed: %s:%d: %s\n", \
+		__FILE__, __LINE__, #x);					\
+	FAIL();								\
+      }									\
+  } while(0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NETTLE_TESTUTILS_H_INCLUDED */
diff --git a/test/testutils_glue.c b/test/testutils_glue.c
new file mode 100644
index 0000000..531bb80
--- /dev/null
+++ b/test/testutils_glue.c
@@ -0,0 +1,696 @@
+/* testutils.c */
+
+#include "testutils.h"
+
+#include "base16.h"
+#include "cbc.h"
+#include "cfb.h"
+#include "ctr.h"
+#include "knuth-lfib.h"
+#include "macros.h"
+#include "nettle-internal.h"
+
+#include <assert.h>
+#include <ctype.h>
+
+void
+die(const char *format, ...)
+{
+  va_list args;
+  va_start(args, format);
+  vfprintf(stderr, format, args);
+  va_end(args);
+
+  abort ();
+}
+
+void *
+xalloc(size_t size)
+{
+  void *p = malloc(size);
+  if (size && !p)
+    {
+      fprintf(stderr, "Virtual memory exhausted.\n");
+      abort();
+    }
+
+  return p;
+}
+
+static struct tstring *tstring_first = NULL;
+
+struct tstring *
+tstring_alloc (size_t length)
+{
+  struct tstring *s = xalloc(sizeof(struct tstring) + length);
+  s->length = length;
+  s->next = tstring_first;
+  /* NUL-terminate, for convenience. */
+  s->data[length] = '\0';
+  tstring_first = s;
+  return s;
+}
+
+void
+tstring_clear(void)
+{
+  while (tstring_first)
+    {
+      struct tstring *s = tstring_first;
+      tstring_first = s->next;
+      free(s);
+    }
+}
+
+struct tstring *
+tstring_data(size_t length, const uint8_t *data)
+{
+  struct tstring *s = tstring_alloc (length);
+  memcpy (s->data, data, length);
+  return s;
+}
+
+struct tstring *
+tstring_hex(const char *hex)
+{
+  struct base16_decode_ctx ctx;
+  struct tstring *s;
+  size_t length = strlen(hex);
+
+  s = tstring_alloc(BASE16_DECODE_LENGTH (length));
+  base16_decode_init (&ctx);
+  ASSERT (base16_decode_update (&ctx, &s->length, s->data,
+				length, hex));
+  ASSERT (base16_decode_final (&ctx));
+
+  return s;
+}
+
+void
+tstring_print_hex(const struct tstring *s)
+{
+  print_hex (s->length, s->data);
+}
+
+void
+print_hex(size_t length, const uint8_t *data)
+{
+  size_t i;
+  
+  for (i = 0; i < length; i++)
+    {
+      switch (i % 16)
+	{
+	default:
+	  break;
+	case 0:
+	  printf("\n");
+	  break;
+	case 8:
+	  printf(" ");
+	  break;
+	}
+      printf("%02x", data[i]);
+    }
+  printf("\n");
+}
+
+int verbose = 0;
+
+int
+main(int argc, char **argv)
+{
+  if (argc > 1)
+    {
+      if (argc == 2 && !strcmp(argv[1], "-v"))
+	verbose = 1;
+      else
+	{
+	  fprintf(stderr, "Invalid argument `%s', only accepted option is `-v'.\n",
+		  argv[1]);
+	  return 1;
+	}
+    }
+
+  test_main();
+
+  tstring_clear();
+  puts("SUCCESS");
+  return EXIT_SUCCESS;
+}
+
+
+void
+mpn_out_str (FILE *f, int base, const mp_limb_t *xp, mp_size_t xn)
+{
+  mpz_t x;
+  mpz_out_str (f, base, mpz_roinit_n (x, xp, xn));
+}
+
+#if NETTLE_USE_MINI_GMP
+void
+gmp_randinit_default (struct knuth_lfib_ctx *ctx)
+{
+  knuth_lfib_init (ctx, 17);
+}
+void
+mpz_urandomb (mpz_t r, struct knuth_lfib_ctx *ctx, mp_bitcnt_t bits)
+{
+  size_t bytes = (bits+7)/8;
+  uint8_t *buf = xalloc (bytes);
+
+  knuth_lfib_random (ctx, bytes, buf);
+  buf[0] &= 0xff >> (8*bytes - bits);
+  nettle_mpz_set_str_256_u (r, bytes, buf);
+  free (buf);
+}
+#endif /* NETTLE_USE_MINI_GMP */
+
+mp_limb_t *
+xalloc_limbs (mp_size_t n)
+{
+  return xalloc (n * sizeof (mp_limb_t));
+}
+
+/* Expects local variables pub, key, rstate, digest, signature */
+#define SIGN(hash, msg, expected) do { \
+  hash##_update(&hash, LDATA(msg));					\
+  ASSERT(rsa_##hash##_sign(key, &hash, signature));			\
+  if (verbose)								\
+    {									\
+      fprintf(stderr, "rsa-%s signature: ", #hash);			\
+      mpz_out_str(stderr, 16, signature);				\
+      fprintf(stderr, "\n");						\
+    }									\
+  ASSERT(mpz_cmp (signature, expected) == 0);				\
+									\
+  hash##_update(&hash, LDATA(msg));					\
+  ASSERT(rsa_##hash##_sign_tr(pub, key, &rstate,			\
+			      (nettle_random_func *) knuth_lfib_random,	\
+			      &hash, signature));			\
+  ASSERT(mpz_cmp (signature, expected) == 0);				\
+									\
+  hash##_update(&hash, LDATA(msg));					\
+  hash##_digest(&hash, sizeof(digest), digest);				\
+  ASSERT(rsa_##hash##_sign_digest(key, digest, signature));		\
+  ASSERT(mpz_cmp (signature, expected) == 0);				\
+									\
+  ASSERT(rsa_##hash##_sign_digest_tr(pub, key, &rstate,			\
+				     (nettle_random_func *)knuth_lfib_random, \
+				     digest, signature));		\
+  ASSERT(mpz_cmp (signature, expected) == 0);				\
+} while(0)
+
+#define VERIFY(key, hash, msg, signature) (	\
+  hash##_update(&hash, LDATA(msg)),		\
+  rsa_##hash##_verify(key, &hash, signature)	\
+)
+
+void
+test_rsa_set_key_1(struct rsa_public_key *pub,
+		   struct rsa_private_key *key)
+{
+  /* Initialize key pair for test programs */
+  /* 1000-bit key, generated by
+   *
+   *   lsh-keygen -a rsa -l 1000 -f advanced-hex
+   *
+   * (private-key (rsa-pkcs1 
+   *        (n #69abd505285af665 36ddc7c8f027e6f0 ed435d6748b16088
+   *            4fd60842b3a8d7fb bd8a3c98f0cc50ae 4f6a9f7dd73122cc
+   *            ec8afa3f77134406 f53721973115fc2d 8cfbba23b145f28d
+   *            84f81d3b6ae8ce1e 2850580c026e809b cfbb52566ea3a3b3
+   *            df7edf52971872a7 e35c1451b8636d22 279a8fb299368238
+   *            e545fbb4cf#)
+   *        (e #0db2ad57#)
+   *        (d #3240a56f4cd0dcc2 4a413eb4ea545259 5c83d771a1c2ba7b
+   *            ec47c5b43eb4b374 09bd2aa1e236dd86 481eb1768811412f
+   *            f8d91be3545912af b55c014cb55ceac6 54216af3b85d5c4f
+   *            4a32894e3b5dfcde 5b2875aa4dc8d9a8 6afd0ca92ef50d35
+   *            bd09f1c47efb4c8d c631e07698d362aa 4a83fd304e66d6c5
+   *            468863c307#)
+   *        (p #0a66399919be4b4d e5a78c5ea5c85bf9 aba8c013cb4a8732
+   *            14557a12bd67711e bb4073fd39ad9a86 f4e80253ad809e5b
+   *            f2fad3bc37f6f013 273c9552c9f489#)
+   *        (q #0a294f069f118625 f5eae2538db9338c 776a298eae953329
+   *            9fd1eed4eba04e82 b2593bc98ba8db27 de034da7daaea795
+   *            2d55b07b5f9a5875 d1ca5f6dcab897#)
+   *        (a #011b6c48eb592eee e85d1bb35cfb6e07 344ea0b5e5f03a28
+   *            5b405396cbc78c5c 868e961db160ba8d 4b984250930cf79a
+   *            1bf8a9f28963de53 128aa7d690eb87#)
+   *        (b #0409ecf3d2557c88 214f1af5e1f17853 d8b2d63782fa5628
+   *            60cf579b0833b7ff 5c0529f2a97c6452 2fa1a8878a9635ab
+   *            ce56debf431bdec2 70b308fa5bf387#)
+   *        (c #04e103ee925cb5e6 6653949fa5e1a462 c9e65e1adcd60058
+   *            e2df9607cee95fa8 daec7a389a7d9afc 8dd21fef9d83805a
+   *            40d46f49676a2f6b 2926f70c572c00#)))
+   */
+  
+  mpz_set_str(pub->n,
+	      "69abd505285af665" "36ddc7c8f027e6f0" "ed435d6748b16088"
+	      "4fd60842b3a8d7fb" "bd8a3c98f0cc50ae" "4f6a9f7dd73122cc"
+	      "ec8afa3f77134406" "f53721973115fc2d" "8cfbba23b145f28d"
+	      "84f81d3b6ae8ce1e" "2850580c026e809b" "cfbb52566ea3a3b3"
+	      "df7edf52971872a7" "e35c1451b8636d22" "279a8fb299368238"
+	      "e545fbb4cf", 16);
+  mpz_set_str(pub->e, "0db2ad57", 16);
+
+  ASSERT (rsa_public_key_prepare(pub));
+  
+  /* d is not used */
+#if 0  
+  mpz_set_str(key->d,
+	      "3240a56f4cd0dcc2" "4a413eb4ea545259" "5c83d771a1c2ba7b"
+	      "ec47c5b43eb4b374" "09bd2aa1e236dd86" "481eb1768811412f"
+	      "f8d91be3545912af" "b55c014cb55ceac6" "54216af3b85d5c4f"
+	      "4a32894e3b5dfcde" "5b2875aa4dc8d9a8" "6afd0ca92ef50d35"
+	      "bd09f1c47efb4c8d" "c631e07698d362aa" "4a83fd304e66d6c5"
+	      "468863c307", 16);
+#endif
+  
+  mpz_set_str(key->p,
+	      "0a66399919be4b4d" "e5a78c5ea5c85bf9" "aba8c013cb4a8732"
+	      "14557a12bd67711e" "bb4073fd39ad9a86" "f4e80253ad809e5b"
+	      "f2fad3bc37f6f013" "273c9552c9f489", 16);
+
+  mpz_set_str(key->q,
+	      "0a294f069f118625" "f5eae2538db9338c" "776a298eae953329"
+	      "9fd1eed4eba04e82" "b2593bc98ba8db27" "de034da7daaea795"
+	      "2d55b07b5f9a5875" "d1ca5f6dcab897", 16);
+  
+  mpz_set_str(key->a,
+	      "011b6c48eb592eee" "e85d1bb35cfb6e07" "344ea0b5e5f03a28"
+	      "5b405396cbc78c5c" "868e961db160ba8d" "4b984250930cf79a"
+	      "1bf8a9f28963de53" "128aa7d690eb87", 16);
+  
+  mpz_set_str(key->b,
+	      "0409ecf3d2557c88" "214f1af5e1f17853" "d8b2d63782fa5628"
+	      "60cf579b0833b7ff" "5c0529f2a97c6452" "2fa1a8878a9635ab"
+	      "ce56debf431bdec2" "70b308fa5bf387", 16);
+  
+  mpz_set_str(key->c,
+	      "04e103ee925cb5e6" "6653949fa5e1a462" "c9e65e1adcd60058"
+	      "e2df9607cee95fa8" "daec7a389a7d9afc" "8dd21fef9d83805a"
+	      "40d46f49676a2f6b" "2926f70c572c00", 16);
+
+  ASSERT (rsa_private_key_prepare(key));
+  ASSERT (pub->size == key->size);
+}
+
+void
+test_rsa_md5(struct rsa_public_key *pub,
+	     struct rsa_private_key *key,
+	     mpz_t expected)
+{
+  struct md5_ctx md5;
+  struct knuth_lfib_ctx rstate;
+  uint8_t digest[MD5_DIGEST_SIZE];
+  mpz_t signature;
+
+  md5_init(&md5);
+  mpz_init(signature);
+  knuth_lfib_init (&rstate, 15);
+
+  SIGN(md5, "The magic words are squeamish ossifrage", expected);
+
+  /* Try bad data */
+  ASSERT (!VERIFY(pub, md5,
+		  "The magick words are squeamish ossifrage", signature));
+
+  /* Try correct data */
+  ASSERT (VERIFY(pub, md5,
+		 "The magic words are squeamish ossifrage", signature));
+
+  /* Try bad signature */
+  mpz_combit(signature, 17);
+  ASSERT (!VERIFY(pub, md5,
+		  "The magic words are squeamish ossifrage", signature));
+
+  mpz_clear(signature);
+}
+
+void
+test_rsa_sha1(struct rsa_public_key *pub,
+	      struct rsa_private_key *key,
+	      mpz_t expected)
+{
+  struct sha1_ctx sha1;
+  struct knuth_lfib_ctx rstate;
+  uint8_t digest[SHA1_DIGEST_SIZE];
+  mpz_t signature;
+
+  sha1_init(&sha1);
+  mpz_init(signature);
+  knuth_lfib_init (&rstate, 16);
+
+  SIGN(sha1, "The magic words are squeamish ossifrage", expected);
+
+  /* Try bad data */
+  ASSERT (!VERIFY(pub, sha1,
+		  "The magick words are squeamish ossifrage", signature));
+
+  /* Try correct data */
+  ASSERT (VERIFY(pub, sha1,
+		 "The magic words are squeamish ossifrage", signature));
+
+  /* Try bad signature */
+  mpz_combit(signature, 17);
+  ASSERT (!VERIFY(pub, sha1,
+		  "The magic words are squeamish ossifrage", signature));
+
+  mpz_clear(signature);
+}
+
+void
+test_rsa_sha256(struct rsa_public_key *pub,
+		struct rsa_private_key *key,
+		mpz_t expected)
+{
+  struct sha256_ctx sha256;
+  struct knuth_lfib_ctx rstate;
+  uint8_t digest[SHA256_DIGEST_SIZE];
+  mpz_t signature;
+
+  sha256_init(&sha256);
+  mpz_init(signature);
+  knuth_lfib_init (&rstate, 17);
+
+  SIGN(sha256, "The magic words are squeamish ossifrage", expected);
+
+  /* Try bad data */
+  ASSERT (!VERIFY(pub, sha256,
+		  "The magick words are squeamish ossifrage", signature));
+
+  /* Try correct data */
+  ASSERT (VERIFY(pub, sha256,
+		 "The magic words are squeamish ossifrage", signature));
+
+  /* Try bad signature */
+  mpz_combit(signature, 17);
+  ASSERT (!VERIFY(pub, sha256,
+		  "The magic words are squeamish ossifrage", signature));
+
+  mpz_clear(signature);
+}
+
+void
+test_rsa_sha512(struct rsa_public_key *pub,
+		struct rsa_private_key *key,
+		mpz_t expected)
+{
+  struct sha512_ctx sha512;
+  struct knuth_lfib_ctx rstate;
+  uint8_t digest[SHA512_DIGEST_SIZE];
+  mpz_t signature;
+
+  sha512_init(&sha512);
+  mpz_init(signature);
+  knuth_lfib_init (&rstate, 18);
+
+  SIGN(sha512, "The magic words are squeamish ossifrage", expected);
+
+  /* Try bad data */
+  ASSERT (!VERIFY(pub, sha512,
+		  "The magick words are squeamish ossifrage", signature));
+
+  /* Try correct data */
+  ASSERT (VERIFY(pub, sha512,
+		 "The magic words are squeamish ossifrage", signature));
+
+  /* Try bad signature */
+  mpz_combit(signature, 17);
+  ASSERT (!VERIFY(pub, sha512,
+		  "The magic words are squeamish ossifrage", signature));
+
+  mpz_clear(signature);
+}
+
+#undef SIGN
+#undef VERIFY
+
+void
+test_rsa_key(struct rsa_public_key *pub,
+	     struct rsa_private_key *key)
+{
+  mpz_t tmp;
+  mpz_t phi;
+  
+  mpz_init(tmp); mpz_init(phi);
+  
+  if (verbose)
+    {
+      /* FIXME: Use gmp_printf */
+      fprintf(stderr, "Public key: n=");
+      mpz_out_str(stderr, 16, pub->n);
+      fprintf(stderr, "\n    e=");
+      mpz_out_str(stderr, 16, pub->e);
+
+      fprintf(stderr, "\n\nPrivate key: d=");
+      mpz_out_str(stderr, 16, key->d);
+      fprintf(stderr, "\n    p=");
+      mpz_out_str(stderr, 16, key->p);
+      fprintf(stderr, "\n    q=");
+      mpz_out_str(stderr, 16, key->q);
+      fprintf(stderr, "\n    a=");
+      mpz_out_str(stderr, 16, key->a);
+      fprintf(stderr, "\n    b=");
+      mpz_out_str(stderr, 16, key->b);
+      fprintf(stderr, "\n    c=");
+      mpz_out_str(stderr, 16, key->c);
+      fprintf(stderr, "\n\n");
+    }
+
+  /* Check n = p q */
+  mpz_mul(tmp, key->p, key->q);
+  ASSERT (mpz_cmp(tmp, pub->n)== 0);
+
+  /* Check c q = 1 mod p */
+  mpz_mul(tmp, key->c, key->q);
+  mpz_fdiv_r(tmp, tmp, key->p);
+  ASSERT (mpz_cmp_ui(tmp, 1) == 0);
+
+  /* Check ed = 1 (mod phi) */
+  mpz_sub_ui(phi, key->p, 1);
+  mpz_sub_ui(tmp, key->q, 1);
+
+  mpz_mul(phi, phi, tmp);
+
+  mpz_mul(tmp, pub->e, key->d);
+  mpz_fdiv_r(tmp, tmp, phi);
+  ASSERT (mpz_cmp_ui(tmp, 1) == 0);
+
+  /* Check a e = 1 (mod (p-1) ) */
+  mpz_sub_ui(phi, key->p, 1);
+  mpz_mul(tmp, pub->e, key->a);
+  mpz_fdiv_r(tmp, tmp, phi);
+  ASSERT (mpz_cmp_ui(tmp, 1) == 0);
+  
+  /* Check b e = 1 (mod (q-1) ) */
+  mpz_sub_ui(phi, key->q, 1);
+  mpz_mul(tmp, pub->e, key->b);
+  mpz_fdiv_r(tmp, tmp, phi);
+  ASSERT (mpz_cmp_ui(tmp, 1) == 0);
+  
+  mpz_clear(tmp); mpz_clear(phi);
+}
+
+/* Requires that the context is named like the hash algorithm. */
+#define DSA_VERIFY(key, hash, msg, signature)	\
+  (hash##_update(&hash, LDATA(msg)),		\
+   dsa_##hash##_verify(key, &hash, signature))
+
+void
+test_dsa160(const struct dsa_public_key *pub,
+	    const struct dsa_private_key *key,
+	    const struct dsa_signature *expected)
+{
+  struct sha1_ctx sha1;
+  struct dsa_signature signature;
+  struct knuth_lfib_ctx lfib;
+  
+  sha1_init(&sha1);
+  dsa_signature_init(&signature);
+  knuth_lfib_init(&lfib, 1111);
+  
+  sha1_update(&sha1, LDATA("The magic words are squeamish ossifrage"));
+  ASSERT (dsa_sha1_sign(pub, key,
+			&lfib, (nettle_random_func *) knuth_lfib_random,
+			&sha1, &signature));
+
+  if (verbose)
+    {
+      fprintf(stderr, "dsa160 signature: ");
+      mpz_out_str(stderr, 16, signature.r);
+      fprintf(stderr, ", ");
+      mpz_out_str(stderr, 16, signature.s);
+      fprintf(stderr, "\n");
+    }
+
+  if (expected)
+    ASSERT (mpz_cmp (signature.r, expected->r) == 0
+	    && mpz_cmp (signature.s, expected->s) == 0);
+  
+  /* Try bad data */
+  ASSERT (!DSA_VERIFY(pub, sha1,
+		      "The magick words are squeamish ossifrage",
+		      &signature));
+
+  /* Try correct data */
+  ASSERT (DSA_VERIFY(pub, sha1,
+		     "The magic words are squeamish ossifrage",
+		     &signature));
+
+  /* Try bad signature */
+  mpz_combit(signature.r, 17);
+  ASSERT (!DSA_VERIFY(pub, sha1,
+		      "The magic words are squeamish ossifrage",
+		      &signature));
+
+  dsa_signature_clear(&signature);
+}
+
+void
+test_dsa256(const struct dsa_public_key *pub,
+	    const struct dsa_private_key *key,
+	    const struct dsa_signature *expected)
+{
+  struct sha256_ctx sha256;
+  struct dsa_signature signature;
+  struct knuth_lfib_ctx lfib;
+  
+  sha256_init(&sha256);
+  dsa_signature_init(&signature);
+  knuth_lfib_init(&lfib, 1111);
+  
+  sha256_update(&sha256, LDATA("The magic words are squeamish ossifrage"));
+  ASSERT (dsa_sha256_sign(pub, key,
+			&lfib, (nettle_random_func *) knuth_lfib_random,
+			&sha256, &signature));
+  
+  if (verbose)
+    {
+      fprintf(stderr, "dsa256 signature: ");
+      mpz_out_str(stderr, 16, signature.r);
+      fprintf(stderr, ", ");
+      mpz_out_str(stderr, 16, signature.s);
+      fprintf(stderr, "\n");
+    }
+
+  if (expected)
+    ASSERT (mpz_cmp (signature.r, expected->r) == 0
+	    && mpz_cmp (signature.s, expected->s) == 0);
+  
+  /* Try bad data */
+  ASSERT (!DSA_VERIFY(pub, sha256,
+		      "The magick words are squeamish ossifrage",
+		      &signature));
+
+  /* Try correct data */
+  ASSERT (DSA_VERIFY(pub, sha256,
+		     "The magic words are squeamish ossifrage",
+		     &signature));
+
+  /* Try bad signature */
+  mpz_combit(signature.r, 17);
+  ASSERT (!DSA_VERIFY(pub, sha256,
+		      "The magic words are squeamish ossifrage",
+		      &signature));
+
+  dsa_signature_clear(&signature);
+}
+
+
+void
+test_dsa_verify(const struct dsa_params *params,
+		const mpz_t pub,
+		const struct nettle_hash *hash,
+		struct tstring *msg,
+		const struct dsa_signature *ref)
+{
+  void *ctx = xalloc (hash->context_size);
+  uint8_t *digest = xalloc (hash->digest_size);
+  struct dsa_signature signature;
+
+  dsa_signature_init (&signature);
+
+  hash->init(ctx);
+  
+  hash->update (ctx, msg->length, msg->data);
+  hash->digest (ctx, hash->digest_size, digest);
+
+  mpz_set (signature.r, ref->r);
+  mpz_set (signature.s, ref->s);
+
+  ASSERT (dsa_verify (params, pub,
+		       hash->digest_size, digest,
+		       &signature));
+
+  /* Try bad signature */
+  mpz_combit(signature.r, 17);
+  ASSERT (!dsa_verify (params, pub,
+		       hash->digest_size, digest,
+		       &signature));
+  
+  /* Try bad data */
+  digest[hash->digest_size / 2-1] ^= 8;
+  ASSERT (!dsa_verify (params, pub,
+		       hash->digest_size, digest,
+		       ref));
+
+  free (ctx);
+  free (digest);
+  dsa_signature_clear(&signature);  
+}
+
+void
+test_dsa_key(const struct dsa_params *params,
+	     const mpz_t pub,
+	     const mpz_t key,
+	     unsigned q_size)
+{
+  mpz_t t;
+
+  mpz_init(t);
+
+  ASSERT(mpz_sizeinbase(params->q, 2) == q_size);
+  ASSERT(mpz_sizeinbase(params->p, 2) >= DSA_SHA1_MIN_P_BITS);
+  
+  ASSERT(mpz_probab_prime_p(params->p, 10));
+
+  ASSERT(mpz_probab_prime_p(params->q, 10));
+
+  mpz_fdiv_r(t, params->p, params->q);
+
+  ASSERT(0 == mpz_cmp_ui(t, 1));
+
+  ASSERT(mpz_cmp_ui(params->g, 1) > 0);
+  
+  mpz_powm(t, params->g, params->q, params->p);
+  ASSERT(0 == mpz_cmp_ui(t, 1));
+  
+  mpz_powm(t, params->g, key, params->p);
+  ASSERT(0 == mpz_cmp(t, pub));
+
+  mpz_clear(t);
+}
+
+const struct ecc_curve * const ecc_curves[] = {
+  &_nettle_secp_192r1,
+  &_nettle_secp_224r1,
+  &_nettle_secp_256r1,
+  &_nettle_secp_384r1,
+  &_nettle_secp_521r1,
+  &_nettle_curve25519,
+  &_nettle_curve448,
+  &_nettle_gost_gc256b,
+  &_nettle_gost_gc512a,
+  NULL
+};
+
+
+void
+write_mpn (FILE *f, int base, const mp_limb_t *xp, mp_size_t n)
+{
+  mpz_t t;
+  mpz_out_str (f, base, mpz_roinit_n (t,xp, n));
+}
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri Oct 16 14:51:50 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 16 Oct 2020 14:51:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.7354.21645 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006vB-Iq; Fri, 16 Oct 2020 14:51:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 7354.21645; Fri, 16 Oct 2020 14:51:46 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006uu-Ar; Fri, 16 Oct 2020 14:51:46 +0000
Received: by outflank-mailman (input) for mailman id 7354;
 Thu, 15 Oct 2020 13:08: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=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
 id 1kT2zi-0004qg-Oo
 for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:34 +0000
Received: from mail-ej1-x62d.google.com (unknown [2a00:1450:4864:20::62d])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id bc2caac4-f7dc-42da-809b-24a6272df63d;
 Thu, 15 Oct 2020 13:08:26 +0000 (UTC)
Received: by mail-ej1-x62d.google.com with SMTP id p15so3528734ejm.7
 for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08:26 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
 by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.24
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 15 Oct 2020 06:08:24 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
	id 1kT2zi-0004qg-Oo
	for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:34 +0000
X-Inumbo-ID: bc2caac4-f7dc-42da-809b-24a6272df63d
Received: from mail-ej1-x62d.google.com (unknown [2a00:1450:4864:20::62d])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id bc2caac4-f7dc-42da-809b-24a6272df63d;
	Thu, 15 Oct 2020 13:08:26 +0000 (UTC)
Received: by mail-ej1-x62d.google.com with SMTP id p15so3528734ejm.7
        for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08: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
         :in-reply-to:references;
        bh=b9+sh4vb+E+NfScSRf5G6dW1K+p2qHMUQwR9FIE+i5w=;
        b=It9OaQyqvWTvlGaE23bMwaH4oHn/Gp/aUPgSGO4VLlmS6zD7J3NyflC1CAXOH3jiks
         q1X94u/8XkFxcl5EC5bMEvvrqt01ozi0OxZ5qJTFbwzLQXlzfQdqwWHhQrKssTKUf3mQ
         erFfkvS/urqX3Xo+WSjsMfk8fm4g6qanysLLwuaeAnz+eClQVhiSWXH3zx9Ekhda73vH
         GhyeIoFpSfGdLXL2IioaoFFTgq3xL4JVHqwyyUmW9WsUJGGsNrtNDvrWrgR5InHOsNZ3
         VAhZpyk4ayvga4TjQuaQpyLORCZ9RopJgeJeRpz6HyvVdWkiZ9kFpnv5qY1nlcZJ2+0+
         h/sA==
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:in-reply-to:references;
        bh=b9+sh4vb+E+NfScSRf5G6dW1K+p2qHMUQwR9FIE+i5w=;
        b=dUhFPxyMiNhJHZsmI8NtO3qCKwCYVcLmFDfEYvVr+jdBQfkSZYvjKVVdGEYBo0vvdo
         RM5jOxt190H1BWnJ4t85YCThfFtIUDP3fZ8RrAW5dFX6hVDLMssNHhd6ZSw9//OIe+r5
         7/EbwxDchP8JUBUv2/HoGQ9WwIfqDl7IQLy6niLa3WRe7SuzSMtpMj6jd/fGW0YgN5q8
         Z1y4x9V5gtpTo+NrJyxQv7ZHiKzsQbQNYJqmw4TogB6lt8/EmNQHb2AbIeZRwP3KVXwk
         OlGo5st4ug46+0H5la0m4I2eUgcp36u3HFEOUkfYCXGjdCoUmDvsnXZtZ0MeAQahFStL
         yfsQ==
X-Gm-Message-State: AOAM5301SumPXm3h8BqONMET1XxqlUpHCQlCr+PxVKafUYpwECrzAPTo
	8ZwxLXD8lHATVTdZClljXb2WhzVCV0j1LCPv
X-Google-Smtp-Source: ABdhPJwztoE/yKVpcOBMusrPKLplj/Zg0gVbdDMMMqOPuRgEYdCvMt7Yt/ldLyzj72KBJ4cayijIiw==
X-Received: by 2002:a17:906:3bc9:: with SMTP id v9mr4259233ejf.340.1602767305810;
        Thu, 15 Oct 2020 06:08:25 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
        by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.24
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 15 Oct 2020 06:08:24 -0700 (PDT)
From: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
Subject: [<UNIKRAFT/LIBHOGWEED> 2/4] Add Config.uk
Date: Thu, 15 Oct 2020 16:07:42 +0300
Message-Id: <503309fe43250aca04e7373fb979b6d39f8f3c82.1602712689.git.dragosargint21@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <cover.1602712689.git.dragosargint21@gmail.com>
References: <cover.1602712689.git.dragosargint21@gmail.com>
In-Reply-To: <cover.1602712689.git.dragosargint21@gmail.com>
References: <cover.1602712689.git.dragosargint21@gmail.com>

Signed-off-by: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
---
 Config.uk | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Config.uk

diff --git a/Config.uk b/Config.uk
new file mode 100644
index 0000000..e342c06
--- /dev/null
+++ b/Config.uk
@@ -0,0 +1,62 @@
+config LIBHOGWEED
+	bool "libhogweed - Public-key algorithms"
+	default n
+
+if LIBHOGWEED
+	config TESTSUITE
+		bool "testsuite - tests for libhogweed"
+		default n
+	if TESTSUITE
+	choice
+		prompt "TEST"
+		config RSA_COMPUTE_ROOT_TEST
+			bool "rsa-compute-root-test"
+		config RSA_ENCRYPT_TEST
+			bool "rsa-encrypt-test"
+		config RSA_KEYGEN_TEST
+			bool "rsa-keygen-test"
+		config RSA_PSS_SIGN_TR_TEST
+			bool "rsa-pss-sign-tr-test"
+		config RSA_SEC_DECRYPT_TEST
+			bool "rsa-sec-decrypt-test"
+		config RSA_SIGN_TR_TEST
+			bool "rsa-sign-tr-test"
+		config RSA_TEST
+			bool "rsa-test"
+		config RSA2SEXP_TEST
+			bool "rsa2sexp-test"
+		config SEXP2RSA_TEST
+			bool "sexp2rsa-test"
+		config CURVE25519_DH_TEST
+			bool "curve25519-dh-test"
+		config CURVE448_DH_TEST
+			bool "curve448-dh-test"
+		config DSA_KEYGEN_TEST
+			bool "dsa-keygen-test"
+		config DSA_TEST
+			bool "dsa-test"
+		config ECDSA_KEYGEN_TEST
+			bool "ecdsa-keygen-test"
+		config ECDSA_SIGN_TEST
+			bool "ecdsa-sign-test"
+		config ECDSA_VERIFY_TEST
+			bool "ecdsa-verify-test"
+		config EDDSA_COMPRESS_TEST
+			bool "eddsa-compress-test"
+		config EDDSA_SIGN_TEST
+			bool "eddsa-sign-test"
+		config EDDSA_VERIFY_TEST
+			bool "eddsa-verify-test"
+		config GOSTDSA_KEYGEN_TEST
+			bool "gostdsa-keygen-test"
+		config GOSTDSA_SIGN_TEST
+			bool "gostdsa-sign-test"
+		config GOSTDSA_VERIFY_TEST
+			bool "gostdsa-verify-test"
+		config GOSTDSA_VKO_TEST
+			bool "gostdsa-vko-test"
+	endchoice
+	endif
+endif
+
+
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Fri Oct 16 14:51:50 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 16 Oct 2020 14:51:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.7352.21648 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006v1-Ke; Fri, 16 Oct 2020 14:51:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 7352.21648; Fri, 16 Oct 2020 14:51:46 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kTR58-0006uj-97; Fri, 16 Oct 2020 14:51:46 +0000
Received: by outflank-mailman (input) for mailman id 7352;
 Thu, 15 Oct 2020 13:08: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=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
 id 1kT2zd-0004qg-Od
 for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:29 +0000
Received: from mail-ej1-x643.google.com (unknown [2a00:1450:4864:20::643])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id b21c27ce-a193-4fc3-87e1-8204ead57053;
 Thu, 15 Oct 2020 13:08:25 +0000 (UTC)
Received: by mail-ej1-x643.google.com with SMTP id u8so3563558ejg.1
 for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08:25 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
 by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.23
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 15 Oct 2020 06:08:23 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=UM7r=DW=gmail.com=dragosargint21@srs-us1.protection.inumbo.net>)
	id 1kT2zd-0004qg-Od
	for minios-devel@lists.xen.org; Thu, 15 Oct 2020 13:08:29 +0000
X-Inumbo-ID: b21c27ce-a193-4fc3-87e1-8204ead57053
Received: from mail-ej1-x643.google.com (unknown [2a00:1450:4864:20::643])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id b21c27ce-a193-4fc3-87e1-8204ead57053;
	Thu, 15 Oct 2020 13:08:25 +0000 (UTC)
Received: by mail-ej1-x643.google.com with SMTP id u8so3563558ejg.1
        for <minios-devel@lists.xen.org>; Thu, 15 Oct 2020 06:08: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
         :in-reply-to:references;
        bh=CVvLoS1X7F7E72lCzzWWb+coI6Kh6PVbs8gSf+oUu90=;
        b=l/RmXUtKeGzzJz9ToQ9ESR2je4GDsuAumjSgABwYIy+rzEBx5K7gkEVNQPnHRHh6In
         zMQ+hw24QJhroANTlPG2MUypQF80ipLOlqn7TV776VZLjRGPlHEo6uZpI04uh3Ac4QgP
         QSym4pbD4k/uB346HXyjVAPkQiw7sqAX+k5tIRZkLukF+PmK4kEIOwXdynTkKQtYbTu0
         QKVfd6V/5t+o9vNBdQCG24fpMg+jwUJeXQxTYlwlHYIiYFcZkvtRmsoELrR/kwDNEpLl
         7c5N//4PoD6lyPOKutjOsmeagABJsuIx05i+fgrgtj12DNxot9IKDn4gI1JV6q0V2nYD
         mwOQ==
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:in-reply-to:references;
        bh=CVvLoS1X7F7E72lCzzWWb+coI6Kh6PVbs8gSf+oUu90=;
        b=d2r9dxVA88jUZrFnOM58cbldXTIYpjo6b8fRZiANwKbOA482F+morsXNgns/wcFio+
         N9A5KTXrbLl+zABoS0Q/DVi7RLTHaviNU7no4W0no4GUQDQFRsCjSVmMFvHq8qVd8BqK
         v/ZKw1HVzqpdgKBTP8TGPHLTkPy0VjlZET2w/s/l/64fd6JBRaG7Ms8dJeIXRX17ywsM
         cAu1T8LFzbwie8ki/ySlR3P5gWkuVjmQ/xwsBhZN4mSb18beb+F3I8Co4vG7V95z4gj5
         wyNsb5dcSUk9KiQK3hB4r2eS6OJAY2xvZQnGJR2W3ghO7OztMjOMi/QpFERglnIsJ2+X
         FmVg==
X-Gm-Message-State: AOAM533KxWtI7Cd7R9l2ocWJ0X4+AaxwxaqJuAr+ztJJdWBEo+oedoGK
	c8EOeMDKvKPtwIgR/+9b3q6kFijX98J4OI6E
X-Google-Smtp-Source: ABdhPJwSPL4gSA5iiKR07HvRZV9Xd0yYxM5TtRLPy5B0vyoKFKHjtIPF7uYVC4vsst+Kez7HLCLr0A==
X-Received: by 2002:a17:906:e103:: with SMTP id gj3mr4249995ejb.442.1602767304169;
        Thu, 15 Oct 2020 06:08:24 -0700 (PDT)
Received: from localhost.localdomain ([82.79.100.106])
        by smtp.gmail.com with ESMTPSA id v6sm1522769ejx.101.2020.10.15.06.08.23
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 15 Oct 2020 06:08:23 -0700 (PDT)
From: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
To: minios-devel@lists.xen.org
Cc: felipe.huici@neclab.eu,
	ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
Subject: [<UNIKRAFT/LIBHOGWEED> 1/4] Add md files
Date: Thu, 15 Oct 2020 16:07:41 +0300
Message-Id: <761f1e1a85b1298e30b2c5e8987de06f6657a9ef.1602712689.git.dragosargint21@gmail.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <cover.1602712689.git.dragosargint21@gmail.com>
References: <cover.1602712689.git.dragosargint21@gmail.com>
In-Reply-To: <cover.1602712689.git.dragosargint21@gmail.com>
References: <cover.1602712689.git.dragosargint21@gmail.com>

Signed-off-by: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
---
 .gitignore      | 27 +++++++++++++++++++++++++++
 CODING_STYLE.md |  4 ++++
 CONTRIBUTING.md |  4 ++++
 COPYING.md      | 39 +++++++++++++++++++++++++++++++++++++++
 MAINTAINERS.md  | 11 +++++++++++
 README.md       | 39 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 124 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 CODING_STYLE.md
 create mode 100644 CONTRIBUTING.md
 create mode 100644 COPYING.md
 create mode 100644 MAINTAINERS.md
 create mode 100644 README.md

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..75d2fd3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,27 @@
+*.depend
+*.o
+*.a
+*.d
+*.so
+*.orig
+*.rej
+*.bak
+*.swp
+*~
+,*
+\#*\#
+.\#*
+\#_*\#
+.\#_*
+!.gitignore
+.*
+
+# gnu global files
+GPATH
+GRTAGS
+GSYMS
+GTAGS
+
+# cscope files
+cscope.*
+ncscope.*
diff --git a/CODING_STYLE.md b/CODING_STYLE.md
new file mode 100644
index 0000000..5730041
--- /dev/null
+++ b/CODING_STYLE.md
@@ -0,0 +1,4 @@
+Coding Style
+============
+
+Please refer to the `CODING_STYLE.md` file in the main Unikraft repository.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..14f6ac6
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,4 @@
+Contributing to Unikraft
+========================
+
+Please refer to the `CONTRIBUTING.md` file in the main Unikraft repository.
diff --git a/COPYING.md b/COPYING.md
new file mode 100644
index 0000000..f8cb1fb
--- /dev/null
+++ b/COPYING.md
@@ -0,0 +1,39 @@
+License
+=======
+
+Unikraft hogweed wrappers
+----------------------------------
+
+This repository contains wrapper code to build hogweed 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/MAINTAINERS.md b/MAINTAINERS.md
new file mode 100644
index 0000000..7c2004f
--- /dev/null
+++ b/MAINTAINERS.md
@@ -0,0 +1,11 @@
+Maintainers List
+================
+
+For notes on how to read this information, please refer to `MAINTAINERS.md` in
+the main Unikraft repository.
+
+	LIBHOGWEED-UNIKRAFT
+	M:	Argint Dragos Iulian <dragosargint21@gmail.com>
+	M:      Felipe Huici <felipe.huici@neclab.eu>
+	L:      minios-devel@lists.xen.org
+	F: *
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..74a4429
--- /dev/null
+++ b/README.md
@@ -0,0 +1,39 @@
+libhogweed for Unikraft
+=============================
+
+This is the port of nettle's libhogweed for Unikraft as external library.
+
+Libhogweed depends on newlib, so please make sure you add the following line
+to the `LIBS` variable in your `Makefile`:
+	`...:$(UK_LIBS)/newlib:$(UK_LIBS)/libhogweed:...`
+
+TESTING:
+For running the tests: Enter `test` directory, enable the `testsuite` option in
+the configuration menu and select the desired test. Note that you can only run
+a test at a time, and the `main` function is in the `testutils_glue.c` file.
+
+APPLICATIONS:
+To run an application that requires a filesystem, you'll need to run them on
+kvm and enable 9pfs, selecting the following menu options, all of them under
+`Library Configuration`:
+	* libnewlib
+	* libhogweed
+	* vfscore: VFS Core Interface ---> vfscore: Configuration ---> 
+	  Automatically mount a root filesystem ---> Default root filesystem
+	  ---> 9PFS
+	* uk9p: 9p client
+	* 9pfs: 9p filesystem
+	* devfs: devfs file system ---> Mount /dev during boot
+	* ukswrand: Software random number generator ---> Register random and
+	  urandom device to devfs
+In order to mount the filesystem you'll need to provide the following Qemu
+parameters:
+	-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
+Note that if you use a different `mount_tag`, you'll need to add it in `Default
+root device` in `vfscore configuration`. Also, to provide command line 
+arguments to the kernel, you'll need to use -append "param1 param2 ...".
+	
+Please refer to the `README.md` as well as the documentation in the `doc/`
+subdirectory of the main unikraft repository.
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 08:24:53 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 08:24:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8631.23119 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTK-0003VI-QO; Mon, 19 Oct 2020 08:24:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8631.23119; Mon, 19 Oct 2020 08:24:50 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTK-0003VB-NV; Mon, 19 Oct 2020 08:24:50 +0000
Received: by outflank-mailman (input) for mailman id 8631;
 Mon, 19 Oct 2020 08:24: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=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
 id 1kUQTH-0003V6-VU
 for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:24:49 +0000
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 078d453d-fdcf-49e2-807f-b7311f3f31d3;
 Mon, 19 Oct 2020 08:24:45 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be
 (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 71E8C200DBA8;
 Mon, 19 Oct 2020 10:24:44 +0200 (CEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
	id 1kUQTH-0003V6-VU
	for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:24:49 +0000
X-Inumbo-ID: 078d453d-fdcf-49e2-807f-b7311f3f31d3
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 078d453d-fdcf-49e2-807f-b7311f3f31d3;
	Mon, 19 Oct 2020 08:24:45 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 71E8C200DBA8;
	Mon, 19 Oct 2020 10:24:44 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be 71E8C200DBA8
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be;
	s=ulg20190529; t=1603095884;
	bh=qWwB/yOrGlMXOOYjMmON7MgH/EVKihjZxDF3kR+W8tY=;
	h=From:To:Cc:Subject:Date:From;
	b=HN0avj5dvaK4D/VhJjUbVF61b4i8Wlr5/zU6OuxrABImbO/Veg3Bh2DOnUSh3OOSy
	 Pwthl9t7QAAz1xmO/LxukL9Q/v4yXt/2VZjwDkCweFVmwNljLy9lTdiHrt3glsTBQX
	 Vx6jwvPlfEIkET+VMNQkDq4J4+rJQYXjLNT0fjRCaKj8y3JDEzMMLLNUT31HVQwjWo
	 bzjB783kBp4jamwpRJGB+RPVSXFcS8UA36tTxLKb7jF4TCjKZY0LEwCjVxeaiD1c8n
	 mG7gZ+k1ZFhBxqHeslk4iA+p7GaTV105sq2+W3kwaJspkhCPJA8rEWl9q7tQb9lfFy
	 fuj8cOmNLwz4w==
From: gaulthier.gain@uliege.be
To: minios-devel@lists.xenproject.org
Cc: simon.kuenzer@neclab.eu,
	gaulthier gain <gaulthier.gain@uliege.be>
Subject: [UNIKRAFT/MUSL PATCH 0/7] Continue MUSL integration
Date: Mon, 19 Oct 2020 08:24:30 +0000
Message-Id: <20201019082437.24937-1-gaulthier.gain@uliege.be>
X-Mailer: git-send-email 2.17.1

From: gaulthier gain <gaulthier.gain@uliege.be>

In this pacth series, we continue our work on MUSL by adding new
fixes and features. MUSL is now subdivided into several components
which can be selected during the library configuration (based on
Alex's work). In addition, we fixed the flush bug with stdout.

Gaulthier Gain (7):
  Makefile.*, Config.uk: Sub-componentize MUSL
  scripts: Add header helper script
  patches: Update ioctl prototype definition
  Synchronize musl with POSIX internal libs with musl
  Fix stdout flushing in musl
  Prevent syscall shim layer libc wrapper generation
  README.md: Update with latest changes

 Config.uk                                     | 219 ++++-
 Makefile.rules                                |  31 +
 Makefile.uk                                   | 126 ++-
 Makefile.uk.musl.aio                          |  22 +-
 Makefile.uk.musl.complex                      | 142 +--
 Makefile.uk.musl.conf                         |  24 +-
 Makefile.uk.musl.crypt                        |  27 +-
 Makefile.uk.musl.ctype                        |  90 +-
 Makefile.uk.musl.dirent                       |  42 +-
 Makefile.uk.musl.env                          |  38 +-
 Makefile.uk.musl.errno                        |  13 +-
 Makefile.uk.musl.exit                         |  28 +-
 Makefile.uk.musl.fcntl                        |  20 +-
 Makefile.uk.musl.fenv                         |  55 +-
 Makefile.uk.musl.internal                     |  66 +-
 Makefile.uk.musl.ipc                          |  41 +-
 Makefile.uk.musl.ldso                         |  70 +-
 Makefile.uk.musl.legacy                       |  58 +-
 Makefile.uk.musl.linux                        | 156 +--
 Makefile.uk.musl.locale                       |  82 +-
 Makefile.uk.musl.malloc                       |  32 +-
 Makefile.uk.musl.math                         | 926 +++++++++---------
 Makefile.uk.musl.misc                         | 121 ++-
 Makefile.uk.musl.mman                         |  49 +-
 Makefile.uk.musl.mq                           |  32 +-
 Makefile.uk.musl.multibyte                    |  51 +-
 Makefile.uk.musl.network                      | 197 ++--
 Makefile.uk.musl.passwd                       |  65 +-
 Makefile.uk.musl.prng                         |  30 +-
 Makefile.uk.musl.process                      |  90 +-
 Makefile.uk.musl.regex                        |  34 +-
 Makefile.uk.musl.sched                        |  29 +-
 Makefile.uk.musl.search                       |  17 +-
 Makefile.uk.musl.select                       |  17 +-
 Makefile.uk.musl.setjmp                       |  62 +-
 Makefile.uk.musl.signal                       | 155 +--
 Makefile.uk.musl.stat                         |  51 +-
 Makefile.uk.musl.stdio                        | 266 ++---
 Makefile.uk.musl.stdlib                       |  60 +-
 Makefile.uk.musl.string                       | 189 ++--
 Makefile.uk.musl.temp                         |  26 +-
 Makefile.uk.musl.termios                      |  28 +-
 Makefile.uk.musl.thread                       | 413 ++++----
 Makefile.uk.musl.time                         | 117 ++-
 Makefile.uk.musl.unistd                       | 196 ++--
 README.md                                     |  26 +-
 patches/0008-Fix-sys_ioctl_h-conflicts.patch  |  27 -
 .../0008-Use-compatible-ioctl-prototype.patch |  30 +
 .../0009-Fix-stdout-flushing-in-musl.patch    |  46 +
 ...09-update__stdout_write_for_flushing.patch |  25 -
 scripts/list-headers.sh                       |  68 ++
 51 files changed, 3017 insertions(+), 1808 deletions(-)
 create mode 100644 Makefile.rules
 delete mode 100644 patches/0008-Fix-sys_ioctl_h-conflicts.patch
 create mode 100644 patches/0008-Use-compatible-ioctl-prototype.patch
 create mode 100644 patches/0009-Fix-stdout-flushing-in-musl.patch
 delete mode 100644 patches/0009-update__stdout_write_for_flushing.patch
 create mode 100644 scripts/list-headers.sh

-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 08:24:53 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 08:24:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8632.23124 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTN-0003Vs-S3; Mon, 19 Oct 2020 08:24:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8632.23124; Mon, 19 Oct 2020 08:24:53 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTN-0003Vl-P6; Mon, 19 Oct 2020 08:24:53 +0000
Received: by outflank-mailman (input) for mailman id 8632;
 Mon, 19 Oct 2020 08:24:52 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
 id 1kUQTM-0003V6-SW
 for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:24:52 +0000
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 69bcbdb2-5769-4c7b-adfe-4f688b099f45;
 Mon, 19 Oct 2020 08:24:51 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be
 (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 5EB12200DBAD;
 Mon, 19 Oct 2020 10:24:50 +0200 (CEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
	id 1kUQTM-0003V6-SW
	for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:24:52 +0000
X-Inumbo-ID: 69bcbdb2-5769-4c7b-adfe-4f688b099f45
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 69bcbdb2-5769-4c7b-adfe-4f688b099f45;
	Mon, 19 Oct 2020 08:24:51 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 5EB12200DBAD;
	Mon, 19 Oct 2020 10:24:50 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be 5EB12200DBAD
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be;
	s=ulg20190529; t=1603095890;
	bh=nykuNCMC92z54zoCp931n0qdyt/Fwc8Lno/MBTs7dBk=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=AL0uMopIKeovAToXEIKErgKsGVfgMIF5zVQ95QZXVoImsKnAtdOlnbQcnOyDyVbNo
	 7ZWjMX1o/7BNBiQ8rItO2wWVLb9Lq48PnDlOOZGms4FEb7abqOWti6Eu5UNdCffjb6
	 HfAeOZlv+NYWYoeySzJLpRriqJLYD/JzPttOxH70w8NzDTknUEnEQvXHY6mkIdHxgt
	 HFfGhKVNOUP9Ncj75012GvpIWlHzqM7iYYL9iuhLzL99Q31Q65uYkygmyjcijTlpFY
	 FTNX+OzGNIqLKdDQO+pVcTKkz6AqZ2wxxvdEzg3it+Keo5L3Y3IyGb14HOgl+05N6I
	 HzfPbxL1I4xtA==
From: gaulthier.gain@uliege.be
To: minios-devel@lists.xenproject.org
Cc: simon.kuenzer@neclab.eu,
	Gaulthier Gain <gaulthier.gain@uliege.be>,
	Alexander Jung <alexander.jung@neclab.eu>
Subject: [UNIKRAFT/MUSL PATCH 2/7] scripts: Add header helper script
Date: Mon, 19 Oct 2020 08:24:32 +0000
Message-Id: <20201019082437.24937-3-gaulthier.gain@uliege.be>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201019082437.24937-1-gaulthier.gain@uliege.be>
References: <20201019082437.24937-1-gaulthier.gain@uliege.be>

From: Gaulthier Gain <gaulthier.gain@uliege.be>

This helper script naively iterates through the source files of a
MUSL subcomponent and outputs the list of headers which it uses.

Signed-off-by: Alexander Jung <alexander.jung@neclab.eu>
Signed-off-by: Gaulthier Gain <gaulthier.gain@uliege.be>
---
 scripts/list-headers.sh | 68 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 scripts/list-headers.sh

diff --git a/scripts/list-headers.sh b/scripts/list-headers.sh
new file mode 100644
index 0000000..fc40923
--- /dev/null
+++ b/scripts/list-headers.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+# Generate list of MUSL headers for a given library
+#
+# Authors: Alexander Jung <alexander.jung@neclab.eu>
+#
+# Copyright (c) 2020, NEC Europe Ltd., NEC Corporation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the copyright holder nor the names of its
+#    contributors may be used to endorse or promote products derived from
+#    this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+MUSL_SRC=$1
+MUSL_LIB=$2
+
+if [ "x$MUSL_SRC" == "x" ]; then
+  echo "Usage: $0 [MUSL_SRC] [LIBRARY]"
+  exit 1
+elif [ ! -d $MUSL_SRC/src ]; then
+  echo "Could not find: $MUSL_SRC"
+  exit 1
+elif [ ! "x$MUSL_LIB" == "x" ] && [ ! -d $MUSL_SRC/src/$MUSL_LIB ]; then
+  echo "Could not find: $MUSL_SRC/src/$MUSL_LIB"
+  exit 1
+fi
+
+LIB_HDRS=()
+
+FILES=$(find $MUSL_SRC/src/$MUSL_LIB/ -type f -name '*.c')
+
+for FILE in $FILES; do
+  FILE_HDRS=$(grep -oP '#\s*include\s*[<"]\K[\w\/]+.h' $FILE)
+  LIB_HDRS+=($FILE_HDRS)
+done
+
+# Remove duplicates
+IFS=$'\n' LIB_HDRS=($(sort -u <<<"${LIB_HDRS[*]}"))
+unset IFS
+
+for HDR in "${LIB_HDRS[@]}"; do
+  if [ -f $MUSL_SRC/include/$HDR ]; then
+    echo "LIBMUSL_${MUSL_LIB^^}_HDRS-y += \$(LIBMUSL)/include/$HDR"
+  elif [ -f $MUSL_SRC/src/internal/$HDR ]; then
+    echo "LIBMUSL_${MUSL_LIB^^}_HDRS-y += \$(LIBMUSL)/src/internal/$HDR"
+  else
+    echo "# LIBMUSL_${MUSL_LIB^^}_HDRS-y += $HDR # not found"
+  fi
+done
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 08:24:56 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 08:24:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8633.23127 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTQ-0003Wg-TT; Mon, 19 Oct 2020 08:24:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8633.23127; Mon, 19 Oct 2020 08:24:56 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTQ-0003WZ-Qc; Mon, 19 Oct 2020 08:24:56 +0000
Received: by outflank-mailman (input) for mailman id 8633;
 Mon, 19 Oct 2020 08:24: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=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
 id 1kUQTP-0003WK-7y
 for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:24:55 +0000
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 80a4c61b-1ff8-4239-a1f9-5dec18a98e78;
 Mon, 19 Oct 2020 08:24:52 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be
 (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id E1658200DBB2;
 Mon, 19 Oct 2020 10:24:51 +0200 (CEST)
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=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
	id 1kUQTP-0003WK-7y
	for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:24:55 +0000
X-Inumbo-ID: 80a4c61b-1ff8-4239-a1f9-5dec18a98e78
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 80a4c61b-1ff8-4239-a1f9-5dec18a98e78;
	Mon, 19 Oct 2020 08:24:52 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id E1658200DBB2;
	Mon, 19 Oct 2020 10:24:51 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be E1658200DBB2
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be;
	s=ulg20190529; t=1603095891;
	bh=b7a0FH9tXHCHuD+4D8zeTaWDo7STqtj5eHYrOpczKCo=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=FiTcum6WOZedRPDmLZpQKNMsVHye5WGk/5gH0n/a+3ET5n3vVik8BUUfcwvZ0mwX/
	 s36vOtun4spqyk+i537Zfd0PWUtK0D2C3HMzma/cenN4dFiD1wCU9oEUlu4igTX+lB
	 Jx8Q/r19jMHjRUEcDBnGCCgCSeJv6eVq8TL5yznMILZfYettrNp++3rlXqZqkavXpo
	 XqjkcoOpYxnzGcILL4SAa0m1DdagMMcIGtmG7HrFm9HHrZzBtbDwax9v4TU6mQUqs6
	 NgLJpnpBIPx+5CXBxkR8FPo28kMdLG07kjm0+nlHWTjIl0UcGVwrPwKu6l4jF6T+KY
	 ft6tQSW93t+cQ==
From: gaulthier.gain@uliege.be
To: minios-devel@lists.xenproject.org
Cc: simon.kuenzer@neclab.eu,
	Gaulthier Gain <gaulthier.gain@uliege.be>,
	Alexander Jung <alexander.jung@neclab.eu>
Subject: [UNIKRAFT/MUSL PATCH 3/7] patches: Update ioctl prototype definition
Date: Mon, 19 Oct 2020 08:24:33 +0000
Message-Id: <20201019082437.24937-4-gaulthier.gain@uliege.be>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201019082437.24937-1-gaulthier.gain@uliege.be>
References: <20201019082437.24937-1-gaulthier.gain@uliege.be>

From: Gaulthier Gain <gaulthier.gain@uliege.be>

This patch updates the `ioctl` prototype with a more precise definition
which is also compliant with vfscore.

Signed-off-by: Alexander Jung <alexander.jung@neclab.eu>
Signed-off-by: Gaulthier Gain <gaulthier.gain@uliege.be>
---
 patches/0008-Fix-sys_ioctl_h-conflicts.patch  | 27 -----------------
 .../0008-Use-compatible-ioctl-prototype.patch | 30 +++++++++++++++++++
 2 files changed, 30 insertions(+), 27 deletions(-)
 delete mode 100644 patches/0008-Fix-sys_ioctl_h-conflicts.patch
 create mode 100644 patches/0008-Use-compatible-ioctl-prototype.patch

diff --git a/patches/0008-Fix-sys_ioctl_h-conflicts.patch b/patches/0008-Fix-sys_ioctl_h-conflicts.patch
deleted file mode 100644
index 953b8ad..0000000
--- a/patches/0008-Fix-sys_ioctl_h-conflicts.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 2aa8ddeb0deb165b28f9e70b14da69b7bf9b938d Mon Sep 17 00:00:00 2001
-From: gaulthier gain <gaulthier.gain@uliege.be>
-Date: Mon, 24 Feb 2020 21:01:40 +0000
-Subject: [PATCH] Remove <sys/ioctl> from musl internal
-
-Signed-off-by: Gaulthier Gain <gaulthier.gain@uliege.be>
----
- include/sys/mount.h | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/include/sys/mount.h b/include/sys/mount.h
-index 57a89c0..6516a51 100644
---- a/include/sys/mount.h
-+++ b/include/sys/mount.h
-@@ -5,7 +5,9 @@
- extern "C" {
- #endif
-
-+#ifndef _VFSCORE_SYS_MOUNT_H_
- #include <sys/ioctl.h>
-+#endif
-
- #define BLKROSET   _IO(0x12, 93)
- #define BLKROGET   _IO(0x12, 94)
---
-2.17.1
-
diff --git a/patches/0008-Use-compatible-ioctl-prototype.patch b/patches/0008-Use-compatible-ioctl-prototype.patch
new file mode 100644
index 0000000..85cd3b0
--- /dev/null
+++ b/patches/0008-Use-compatible-ioctl-prototype.patch
@@ -0,0 +1,30 @@
+From 150959f0fd0b04919fb1384abb8998fd8e2c1ca4 Mon Sep 17 00:00:00 2001
+From: Alexander Jung <alexander.jung@neclab.eu>
+Date: Tue, 30 Jun 2020 19:45:36 +0200
+Subject: [PATCH] Use compatible ioctl prototype
+
+This patch updates the `ioctl` prototype with a more precise definition
+which is also compliant with vfscore.
+
+Signed-off-by: Alexander Jung <alexander.jung@neclab.eu>
+---
+ include/sys/ioctl.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h
+index d0415b3..9929002 100644
+--- a/include/sys/ioctl.h
++++ b/include/sys/ioctl.h
+@@ -6,7 +6,8 @@ extern "C" {
+ 
+ #include <bits/ioctl.h>
+ 
+-int ioctl (int, int, ...);
++// int ioctl (int, int, ...);
++int ioctl(int fd, unsigned long int request, ...);
+ 
+ #ifdef __cplusplus
+ }
+-- 
+2.20.1
+
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 08:24:58 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 08:24:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8634.23132 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTS-0003XU-Uz; Mon, 19 Oct 2020 08:24:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8634.23132; Mon, 19 Oct 2020 08:24:58 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTS-0003XN-S0; Mon, 19 Oct 2020 08:24:58 +0000
Received: by outflank-mailman (input) for mailman id 8634;
 Mon, 19 Oct 2020 08:24: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=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
 id 1kUQTR-0003V6-Rc
 for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:24:57 +0000
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 05be7749-8c9b-4390-980d-4608a85c6c20;
 Mon, 19 Oct 2020 08:24:53 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be
 (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 0F394200DBB3;
 Mon, 19 Oct 2020 10:24:53 +0200 (CEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
	id 1kUQTR-0003V6-Rc
	for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:24:57 +0000
X-Inumbo-ID: 05be7749-8c9b-4390-980d-4608a85c6c20
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 05be7749-8c9b-4390-980d-4608a85c6c20;
	Mon, 19 Oct 2020 08:24:53 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 0F394200DBB3;
	Mon, 19 Oct 2020 10:24:53 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be 0F394200DBB3
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be;
	s=ulg20190529; t=1603095893;
	bh=0+3J8VXi5jjf/JYLrZa/wARC61CkJvxfx+D+sXtBKsc=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=J2HJKoc2jpRMOul9Ey0IFsKbC1q15t3Bv6SZU8T8fueySGlRX7rj33fH4rdq6Yk3X
	 mfG9BBuPdrghF4jCWGiXn3QA0/Fg+MegaD+AmjjzAsNzDDaAcUmKuCNHQDhpgpBfvT
	 qg/Q+8iETXwK2TIq24iyXZ333WoWZUDy9V8/JhhIUQ+2qfHbaV+XwYWtFZbojX6lJN
	 wgmlIaUQWhCj43jOZch9coixM1qOpxP5itek3SEsH8A6KOqI/L5hihIyfvg+a4+nJZ
	 z6XqfooKfdjgcKSNHkZ6fvEdbJHYNJk+kV6Kv8ONodknyTwkxHHEbmdRXYg65ICjeA
	 LhDMB1nCCy78A==
From: gaulthier.gain@uliege.be
To: minios-devel@lists.xenproject.org
Cc: simon.kuenzer@neclab.eu,
	Gaulthier Gain <gaulthier.gain@uliege.be>
Subject: [UNIKRAFT/MUSL PATCH 4/7] Synchronize musl with POSIX internal libs with musl
Date: Mon, 19 Oct 2020 08:24:34 +0000
Message-Id: <20201019082437.24937-5-gaulthier.gain@uliege.be>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201019082437.24937-1-gaulthier.gain@uliege.be>
References: <20201019082437.24937-1-gaulthier.gain@uliege.be>

From: Gaulthier Gain <gaulthier.gain@uliege.be>

In this commit, we avoid conflicts between POSIX internal libs and
musl by checking if internal libraries are already registered in the
build system.

Signed-off-by: Gaulthier Gain <gaulthier.gain@uliege.be>
---
 Makefile.uk.musl.conf   |  2 ++
 Makefile.uk.musl.ldso   |  2 ++
 Makefile.uk.musl.legacy |  2 ++
 Makefile.uk.musl.linux  |  6 +++++-
 Makefile.uk.musl.misc   |  8 ++++++--
 Makefile.uk.musl.passwd |  7 ++++++-
 Makefile.uk.musl.time   |  2 +-
 Makefile.uk.musl.unistd | 13 ++++++++++---
 8 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/Makefile.uk.musl.conf b/Makefile.uk.musl.conf
index e4e49de..54b5301 100644
--- a/Makefile.uk.musl.conf
+++ b/Makefile.uk.musl.conf
@@ -1,3 +1,4 @@
+ifneq ($(CONFIG_LIBPOSIX_SYSINFO),y)
 LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/include/errno.h
 LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/src/internal/libc.h
 LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/include/limits.h
@@ -15,3 +16,4 @@ LIBMUSL_CONF_SRCS-y += $(LIBMUSL)/src/conf/pathconf.c
 LIBMUSL_CONF_SRCS-y += $(LIBMUSL)/src/conf/sysconf.c
 
 $(eval $(call _libmusl_import_lib,conf,$(LIBMUSL_CONF_HDRS-y),$(LIBMUSL_CONF_SRCS-y)))
+endif
diff --git a/Makefile.uk.musl.ldso b/Makefile.uk.musl.ldso
index 7e1b74b..497a522 100644
--- a/Makefile.uk.musl.ldso
+++ b/Makefile.uk.musl.ldso
@@ -1,3 +1,4 @@
+ifneq ($(CONFIG_LIBPOSIX_LIBDL),y)
 LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/include/dlfcn.h
 LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/include/elf.h
 LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/src/internal/libc.h
@@ -31,6 +32,7 @@ LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/tlsdesc.c
 LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/dlsym.c
 endif
 
+endif
 #LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/aarch64/dlsym.s
 #LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/aarch64/tlsdesc.s
 #LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/microblaze/dlsym.s
diff --git a/Makefile.uk.musl.legacy b/Makefile.uk.musl.legacy
index 3671f28..d9d036c 100644
--- a/Makefile.uk.musl.legacy
+++ b/Makefile.uk.musl.legacy
@@ -28,7 +28,9 @@ LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/ftw.c
 #LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/futimes.c
 LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getdtablesize.c
 LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getloadavg.c
+ifneq ($(CONFIG_LIBPOSIX_SYSINFO),y)
 LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getpagesize.c
+endif
 LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getpass.c
 LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getusershell.c
 LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/isastream.c
diff --git a/Makefile.uk.musl.linux b/Makefile.uk.musl.linux
index 50dd483..d797a08 100644
--- a/Makefile.uk.musl.linux
+++ b/Makefile.uk.musl.linux
@@ -69,10 +69,14 @@ LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/readahead.c
 LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/reboot.c
 LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/remap_file_pages.c
 LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/sbrk.c
-#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/sendfile.c
+ifneq ($(CONFIG_LIBLWIP),y)
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/sendfile.c
+endif
 LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/setfsgid.c
 LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/setfsuid.c
+ifneq ($(CONFIG_LIBPOSIX_USER),y)
 LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/setgroups.c
+endif
 #LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/sethostname.c
 LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/setns.c
 LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/settimeofday.c
diff --git a/Makefile.uk.musl.misc b/Makefile.uk.musl.misc
index d62c1ab..c82827c 100644
--- a/Makefile.uk.musl.misc
+++ b/Makefile.uk.musl.misc
@@ -52,14 +52,16 @@ LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/gethostid.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getopt.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getopt_long.c
 #LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getpriority.c
-LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getresgid.c
-LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getresuid.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getrlimit.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getrusage.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getsubopt.c
+ifneq ($(CONFIG_LIBPOSIX_USER),y)
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getresgid.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getresuid.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/initgroups.c
 #LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/ioctl.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/issetugid.c
+endif
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/lockf.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/login_tty.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/mntent.c
@@ -73,7 +75,9 @@ LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/setdomainname.c
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/setrlimit.c
 #LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/syscall.c|misc
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/syslog.c
+ifneq ($(CONFIG_LIBPOSIX_SYSINFO),y)
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/uname.c
+endif
 LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/wordexp.c
 
 $(eval $(call _libmusl_import_lib,misc,$(LIBMUSL_MISC_HDRS-y),$(LIBMUSL_MISC_SRCS-y)))
diff --git a/Makefile.uk.musl.passwd b/Makefile.uk.musl.passwd
index dbad5fd..74912f3 100644
--- a/Makefile.uk.musl.passwd
+++ b/Makefile.uk.musl.passwd
@@ -16,18 +16,23 @@ LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/sys/socket.h
 LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/sys/stat.h
 LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/unistd.h
 
+
+ifneq ($(CONFIG_LIBPOSIX_USER),y)
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/fgetgrent.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/fgetpwent.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/fgetspent.c
+
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgr_a.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgr_r.c
+
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgrent.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgrent_a.c
-LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgrouplist.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getpw_a.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getpw_r.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getpwent.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getpwent_a.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgrouplist.c
+endif
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getspent.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getspnam.c
 LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getspnam_r.c
diff --git a/Makefile.uk.musl.time b/Makefile.uk.musl.time
index ec42edf..363c089 100644
--- a/Makefile.uk.musl.time
+++ b/Makefile.uk.musl.time
@@ -54,7 +54,7 @@ LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/gmtime.c
 LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/gmtime_r.c
 LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/localtime.c
 LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/localtime_r.c
-#LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/mktime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/mktime.c
 #LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/nanosleep.c
 LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/strftime.c
 LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/strptime.c
diff --git a/Makefile.uk.musl.unistd b/Makefile.uk.musl.unistd
index a4378b4..deb96c4 100644
--- a/Makefile.uk.musl.unistd
+++ b/Makefile.uk.musl.unistd
@@ -38,19 +38,24 @@ LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/fchownat.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/fsync.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/ftruncate.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getcwd.c
+ifneq ($(CONFIG_LIBPOSIX_USER),y)
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getegid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/geteuid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getgid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getgroups.c
-#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/gethostname.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getlogin.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getlogin_r.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getuid.c
+endif
+ifneq ($(CONFIG_LIBPOSIX_SYSINFO),y)
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/gethostname.c
+endif
+
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getpgid.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getpgrp.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getpid.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getppid.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getsid.c
-LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getuid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/isatty.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/lchown.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/link.c
@@ -71,6 +76,7 @@ LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/readlinkat.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/readv.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/renameat.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/rmdir.c
+ifneq ($(CONFIG_LIBPOSIX_USER),y)
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setegid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/seteuid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setgid.c
@@ -80,9 +86,10 @@ LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setregid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setresgid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setresuid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setreuid.c
-#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setsid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setuid.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setsid.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setxid.c
+endif
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/sleep.c
 #LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/symlink.c
 LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/symlinkat.c
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 08:25:04 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 08:25:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8635.23136 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTY-0003Yp-1I; Mon, 19 Oct 2020 08:25:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8635.23136; Mon, 19 Oct 2020 08:25:04 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTX-0003Yi-TY; Mon, 19 Oct 2020 08:25:03 +0000
Received: by outflank-mailman (input) for mailman id 8635;
 Mon, 19 Oct 2020 08:25: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=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
 id 1kUQTW-0003V6-Rq
 for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:25:02 +0000
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 83a65a01-1586-4306-91b5-6fdc6f39a8a0;
 Mon, 19 Oct 2020 08:24:54 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be
 (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 4B365200DF83;
 Mon, 19 Oct 2020 10:24:54 +0200 (CEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
	id 1kUQTW-0003V6-Rq
	for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:25:02 +0000
X-Inumbo-ID: 83a65a01-1586-4306-91b5-6fdc6f39a8a0
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 83a65a01-1586-4306-91b5-6fdc6f39a8a0;
	Mon, 19 Oct 2020 08:24:54 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 4B365200DF83;
	Mon, 19 Oct 2020 10:24:54 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be 4B365200DF83
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be;
	s=ulg20190529; t=1603095894;
	bh=5pbhADcusno+rdg5br1X5WHwFwJdWABMw1Z3xOfzr1Y=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=pXVLGyOk1vgR8R9RkopbJZEVi0aWc8liUMjQqj6/admj5qZQPYYJgg1Ta0buCg7Se
	 9SL8BEb73EnUGRJV5Yo9PbqY61OZObFmMWc59VKDBNXGl9WY2pfU2lzB65wBCa5KGN
	 nhFC6iLPOyNCiwiRAMI1TF2yV0PkmhTLLTPGvkWFH5j6QPjiauf0pH1+BW/LaVr8x1
	 uyz3ma548gU+Avaq7Hrd/tF4Wab8bOLqja+WQGedqWl9ficbVm2soQJm0MKcPngLFW
	 aQW2nQWGO4onhenPCaL5GADhrnWf0lHRrhgGaynrC+RtJvcZUSz7QSqUGkcD5REu4f
	 6/usYi+spkRtw==
From: gaulthier.gain@uliege.be
To: minios-devel@lists.xenproject.org
Cc: simon.kuenzer@neclab.eu,
	Gaulthier Gain <gaulthier.gain@uliege.be>
Subject: [UNIKRAFT/MUSL PATCH 5/7] Fix stdout flushing in musl
Date: Mon, 19 Oct 2020 08:24:35 +0000
Message-Id: <20201019082437.24937-6-gaulthier.gain@uliege.be>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201019082437.24937-1-gaulthier.gain@uliege.be>
References: <20201019082437.24937-1-gaulthier.gain@uliege.be>

From: Gaulthier Gain <gaulthier.gain@uliege.be>

In this commit, we replace our old patch by a more robust patch
series. We temporary remove the call to `ioctl` in `__stdout_write.c`
which causes an assertion error due to invalid argument order. In
addition, `__stdio_write` is fixed by updating a condition to avoid an
infinite loop since the last caracter of the buffer is skipped when
the `cnt` variable is tested with the `iov_len` variable.

Signed-off-by: Gaulthier Gain <gaulthier.gain@uliege.be>
---
 .../0009-Fix-stdout-flushing-in-musl.patch    | 46 +++++++++++++++++++
 ...09-update__stdout_write_for_flushing.patch | 25 ----------
 2 files changed, 46 insertions(+), 25 deletions(-)
 create mode 100644 patches/0009-Fix-stdout-flushing-in-musl.patch
 delete mode 100644 patches/0009-update__stdout_write_for_flushing.patch

diff --git a/patches/0009-Fix-stdout-flushing-in-musl.patch b/patches/0009-Fix-stdout-flushing-in-musl.patch
new file mode 100644
index 0000000..2ad48f7
--- /dev/null
+++ b/patches/0009-Fix-stdout-flushing-in-musl.patch
@@ -0,0 +1,46 @@
+From e38b6114fb02f14ed51870e68116d336aa462add Mon Sep 17 00:00:00 2001
+From: gaulthier gain <gaulthier.gain@uliege.be>
+Date: Sun, 18 Oct 2020 10:26:45 +0000
+Subject: [PATCH] Fix stdout flushing in musl
+
+In this patch, we temporary remove the call to `ioctl` in
+`__stdout_write.c` which causes an assertion error due to invalid
+argument order. In addition, `__stdio_write` is fixed by updating
+a condition to avoid an infinite loop since the last caracter of the
+buffer is skipped when the `cnt` variable is tested with the
+`iov_len` variable.
+
+Signed-off-by: gaulthier gain <gaulthier.gain@uliege.be>
+---
+ src/stdio/__stdio_write.c  | 2 +-
+ src/stdio/__stdout_write.c | 2 --
+ 2 files changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c
+index d2d8947..6ebf59e 100644
+--- a/src/stdio/__stdio_write.c
++++ b/src/stdio/__stdio_write.c
+@@ -24,7 +24,7 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
+ 			return iovcnt == 2 ? 0 : len-iov[0].iov_len;
+ 		}
+ 		rem -= cnt;
+-		if (cnt > iov[0].iov_len) {
++		if (cnt >= iov[0].iov_len) {
+ 			cnt -= iov[0].iov_len;
+ 			iov++; iovcnt--;
+ 		}
+diff --git a/src/stdio/__stdout_write.c b/src/stdio/__stdout_write.c
+index dd1ec60..1fdc12e 100644
+--- a/src/stdio/__stdout_write.c
++++ b/src/stdio/__stdout_write.c
+@@ -5,7 +5,5 @@ size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len)
+ {
+ 	struct winsize wsz;
+ 	f->write = __stdio_write;
+-	if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, &wsz))
+-		f->lbf = -1;
+ 	return __stdio_write(f, buf, len);
+ }
+-- 
+2.17.1
+
diff --git a/patches/0009-update__stdout_write_for_flushing.patch b/patches/0009-update__stdout_write_for_flushing.patch
deleted file mode 100644
index bda423f..0000000
--- a/patches/0009-update__stdout_write_for_flushing.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 235b3d8240fbc99782f2fb8449786f519fcb3bde Mon Sep 17 00:00:00 2001
-From: gaulthier gain <gaulthier.gain@uliege.be>
-Date: Fri, 28 Feb 2020 17:05:28 +0000
-Subject: [UNIKRAFT/MUSL] Update __stdout_write to allow flushing on stdout
-
-Signed-off-by: gaulthier gain <gaulthier.gain@uliege.be>
----
- src/stdio/__stdout_write.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/stdio/__stdout_write.c b/src/stdio/__stdout_write.c
-index dd1ec60..f9c9489 100644
---- a/src/stdio/__stdout_write.c
-+++ b/src/stdio/__stdout_write.c
-@@ -6,6 +6,6 @@ size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len)
-	struct winsize wsz;
-	f->write = __stdio_write;
-	if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, &wsz))
--		f->lbf = -1;
-+		f->lbf = '\n';
-	return __stdio_write(f, buf, len);
- }
---
-2.17.1
-
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 08:25:09 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 08:25:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8636.23140 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTd-0003aH-2l; Mon, 19 Oct 2020 08:25:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8636.23140; Mon, 19 Oct 2020 08:25:09 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTc-0003aA-WB; Mon, 19 Oct 2020 08:25:08 +0000
Received: by outflank-mailman (input) for mailman id 8636;
 Mon, 19 Oct 2020 08:25: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=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
 id 1kUQTb-0003V6-Ry
 for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:25:07 +0000
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 963a1d9e-09f2-447a-be41-bfadad143efc;
 Mon, 19 Oct 2020 08:24:57 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be
 (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 50F59200DF89;
 Mon, 19 Oct 2020 10:24:56 +0200 (CEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
	id 1kUQTb-0003V6-Ry
	for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:25:07 +0000
X-Inumbo-ID: 963a1d9e-09f2-447a-be41-bfadad143efc
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 963a1d9e-09f2-447a-be41-bfadad143efc;
	Mon, 19 Oct 2020 08:24:57 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 50F59200DF89;
	Mon, 19 Oct 2020 10:24:56 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be 50F59200DF89
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be;
	s=ulg20190529; t=1603095896;
	bh=pvzhg7hbA8m3rT0x+7CbCHGpTgC2secuHt9cj1lvOp8=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=NkY30tghBADBFa8/7A7PY4Fww2Q0npX2k1pOG1bHxxU7xRRmevFmG72pAsdal/m5N
	 M26FQBoGs70uCqtosItHohX+0i35PGBuPO2DXKpGO6i/hXk3lKeehdjUOK4fgdXEjn
	 klfL0DsnA8bXA6t12HCPLhFtoHeNqC383azZooZCTauFwiXdyZV4ebXLXx2KpznAMa
	 fy0KBnxGe1N0r2I1YmxQOSx6jxKhRHi0ncwqZD2/Oz4laoBlvIlBxfKSHNuH97aKM/
	 3bgpQO+YThVoTd8TH6jyo+As8eVdDbQIGVaMxt3f+cjLerb6ZJIKY2lck0T3n+FT4J
	 hyk0hVsZNZSJA==
From: gaulthier.gain@uliege.be
To: minios-devel@lists.xenproject.org
Cc: simon.kuenzer@neclab.eu,
	Gaulthier Gain <gaulthier.gain@uliege.be>,
	Cyril Soldani <cyril.soldani@uliege.be>
Subject: [UNIKRAFT/MUSL PATCH 6/7] Prevent syscall shim layer libc wrapper generation
Date: Mon, 19 Oct 2020 08:24:36 +0000
Message-Id: <20201019082437.24937-7-gaulthier.gain@uliege.be>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201019082437.24937-1-gaulthier.gain@uliege.be>
References: <20201019082437.24937-1-gaulthier.gain@uliege.be>

From: Gaulthier Gain <gaulthier.gain@uliege.be>

The musl libc provides its own wrappers around syscalls, which we
prefer to the shim-layer-generated ones as they often do additional
bookkeeping. And we can not have both as it would lead to conflicts.

Signed-off-by: Cyril Soldani <cyril.soldani@uliege.be>
Signed-off-by: Gaulthier Gain <gaulthier.gain@uliege.be>
---
 Makefile.uk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.uk b/Makefile.uk
index 6de0b77..7afb9f7 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -118,6 +118,7 @@ LIBMUSL_CFLAGS-y += -Wno-missing-braces
 LIBMUSL_CFLAGS-y += -Wno-cast-function-type
 LIBMUSL_CFLAGS-y += -Wno-format-contains-nul
 LIBMUSL_CFLAGS-y += -Wno-type-limits
+LIBMUSL_CFLAGS-y += -DUK_LIBC_SYSCALL=0
 LIBMUSL_CFLAGS-y += $(LIBMUSL_HDRS_FLAGS-y)
 
 # We globally switch off warnings that are caused by musl's public headers
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 08:25:14 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 08:25:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8637.23144 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTi-0003bh-5H; Mon, 19 Oct 2020 08:25:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8637.23144; Mon, 19 Oct 2020 08:25:14 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTi-0003bU-1U; Mon, 19 Oct 2020 08:25:14 +0000
Received: by outflank-mailman (input) for mailman id 8637;
 Mon, 19 Oct 2020 08:25:12 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
 id 1kUQTg-0003V6-SA
 for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:25:12 +0000
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id bfdb2ce4-04f8-496a-a19a-cf17e1d3de12;
 Mon, 19 Oct 2020 08:24:58 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be
 (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 6A532200DFB0;
 Mon, 19 Oct 2020 10:24:57 +0200 (CEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
	id 1kUQTg-0003V6-SA
	for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:25:12 +0000
X-Inumbo-ID: bfdb2ce4-04f8-496a-a19a-cf17e1d3de12
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id bfdb2ce4-04f8-496a-a19a-cf17e1d3de12;
	Mon, 19 Oct 2020 08:24:58 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id 6A532200DFB0;
	Mon, 19 Oct 2020 10:24:57 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be 6A532200DFB0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be;
	s=ulg20190529; t=1603095897;
	bh=QaYUmUwb/EoUoPtA2gN/NqVzvR8LbDYRo5v2H9V6VtI=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=G6zi6RJD+QoZxzxKX9d9H8Op/4e8BiG5PWKHHaBPCDeWTZBB3FQ11egkTX7sET0ND
	 MbUFw83szZ1lOKQXN/5zMxuh3ghovq994m7fVQgMEUZH7rJaWxyWX6ut1dgA/MaQHr
	 O2yx6WgPtTPXlmwdjvxKWbHxtnHW/gXASIRTa6E0VVs6eUgKp1BwB5SD9qLwmKGnzb
	 3tyT7bYcycJyiumKUH0MSYZY8TVV7CM63dZUW4753NRrfuJNUKGaSEd8rej7VrSF8s
	 PQtDaCtR32Zl5xi03tWf34cxRusUPNZYxw+xp9UpB+smYh4SZ//H1cJBeNvkNohaID
	 nZXbbcqEXpm4Q==
From: gaulthier.gain@uliege.be
To: minios-devel@lists.xenproject.org
Cc: simon.kuenzer@neclab.eu,
	Gaulthier Gain <gaulthier.gain@uliege.be>
Subject: [UNIKRAFT/MUSL PATCH 7/7] README.md: Update with latest changes
Date: Mon, 19 Oct 2020 08:24:37 +0000
Message-Id: <20201019082437.24937-8-gaulthier.gain@uliege.be>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201019082437.24937-1-gaulthier.gain@uliege.be>
References: <20201019082437.24937-1-gaulthier.gain@uliege.be>

From: Gaulthier Gain <gaulthier.gain@uliege.be>

Signed-off-by: Gaulthier Gain <gaulthier.gain@uliege.be>
---
 README.md | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/README.md b/README.md
index 3ceb4e0..16c448b 100644
--- a/README.md
+++ b/README.md
@@ -1,30 +1,32 @@
 musl for Unikraft
 ===================
 
-This first release provides a functional version of musl (compiles and
+This release provides a functional version of musl (compiles and
 links) on Unikraft but some functions are not supported (especially
-the ones related to threads and network). Furthermore, some functions
-can have unexpected behaviour since they use musl internal thread
-support.
+the ones related to threads). Furthermore, some functions can have
+unexpected behaviour since they use musl internal thread support.
 
 ## Build
 
 In order to avoid multiple definitions errors, the following libraries
 MUST NOT BE INCLUDED with musl:
 
-* `POSIX-user`
-* `lwip`
+* `lwip->socket`
 * `pthread-embedded`
 
 ## Known Issues
 
-* At this stage, we noticed that there are some issues with buffering
-on stdout. We are currently investigating this issue but a temporary
-fix is to call `fflush()` after each output on the console.
-
+* At this stage, we noticed that there are some issues with `ioctl`
+and buffering on stdin. We are currently investigating these issues.
 As things stabilize, we will update this file to reflect this.
+* Some syscalls need to be implemented. Please have a look at the
+following map:
+https://people.montefiore.uliege.be/gain/unikraft/syscalls.png for
+futher information.
+* Due to missing syscalls, there is some unexpected behaviour
+concerning threads.
 
 ## Further information
 
-Please refer to the `README.md` as well as the documentation in the `doc/`
-subdirectory of the main unikraft repository.
+Please refer to the `README.md` as well as the documentation in the
+`doc/` subdirectory of the main unikraft repository.
\ No newline at end of file
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 08:25:19 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 08:25:19 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8639.23148 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTn-0003d7-8U; Mon, 19 Oct 2020 08:25:19 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8639.23148; Mon, 19 Oct 2020 08:25:19 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUQTn-0003cz-4p; Mon, 19 Oct 2020 08:25:19 +0000
Received: by outflank-mailman (input) for mailman id 8639;
 Mon, 19 Oct 2020 08:25: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=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
 id 1kUQTl-0003V6-SD
 for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:25:17 +0000
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id f602df6b-f3be-4612-9b8e-75703a1d7b7b;
 Mon, 19 Oct 2020 08:24:47 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be
 (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id B6BBD200DBA4;
 Mon, 19 Oct 2020 10:24:46 +0200 (CEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=jc8Z=D2=uliege.be=gaulthier.gain@srs-us1.protection.inumbo.net>)
	id 1kUQTl-0003V6-SD
	for minios-devel@lists.xenproject.org; Mon, 19 Oct 2020 08:25:17 +0000
X-Inumbo-ID: f602df6b-f3be-4612-9b8e-75703a1d7b7b
Received: from serv108.segi.ulg.ac.be (unknown [139.165.32.111])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id f602df6b-f3be-4612-9b8e-75703a1d7b7b;
	Mon, 19 Oct 2020 08:24:47 +0000 (UTC)
Received: from sauron.run.montefiore.ulg.ac.be (sauron.run.montefiore.ulg.ac.be [139.165.223.31])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by serv108.segi.ulg.ac.be (Postfix) with ESMTPSA id B6BBD200DBA4;
	Mon, 19 Oct 2020 10:24:46 +0200 (CEST)
DKIM-Filter: OpenDKIM Filter v2.11.0 serv108.segi.ulg.ac.be B6BBD200DBA4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uliege.be;
	s=ulg20190529; t=1603095887;
	bh=45FMiD+oQ3dA8hVbvmXv8Gun0HIOxpgzAB2hZJVb2BY=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=OaVGCjEZTS7LyDScx+k4i2eO7GFpzcxmljbDipmaudXhuf06HonkrZzF0mfFa2khh
	 OTY/chNfqjo0ZZhdsYWgg980BwaZ+nSiWprC+H3tENac1EswCZQhtrH+stSbnntkqj
	 hXHLWUaTVbN1TknfA8dW8yQnB9KWej2/r4sV4T/wDNe07KLEQrxrU3+m2oVIG8027s
	 FjqvukduTw1Ed/toVwkT5b5FwbZFxA+hlH2v1VLQaqkmcznz2Lr2SJe2zX7DrEm1Ip
	 hV7CHdxUJeJTNBwXtgthQ7W+czkhFuFgEo60EKYb+GqIa9Ag0/EC65PVsQXF1At8Vx
	 QSAwTsD2nV9jA==
From: gaulthier.gain@uliege.be
To: minios-devel@lists.xenproject.org
Cc: simon.kuenzer@neclab.eu,
	Gaulthier Gain <gaulthier.gain@uliege.be>,
	Alexander Jung <alexander.jung@neclab.eu>
Subject: [UNIKRAFT/MUSL PATCH 1/7] Makefile.*, Config.uk: Sub-componentize MUSL
Date: Mon, 19 Oct 2020 08:24:31 +0000
Message-Id: <20201019082437.24937-2-gaulthier.gain@uliege.be>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201019082437.24937-1-gaulthier.gain@uliege.be>
References: <20201019082437.24937-1-gaulthier.gain@uliege.be>

From: Gaulthier Gain <gaulthier.gain@uliege.be>

This commit introduces the ability to select paticular subcomponents
within the MUSL standard library framework through Unikraft's KConfig
system.  In order to achieve distinction between libraries, additional
rules were created to copy the necessary headers from the
subcomponents into the microlibrary's build directory.  This is
achieved by adding to an appropriate subcomponent list of headers
(standarized via `*_HDRS-y`) and then calling a subcomponent
registration macro `_libmusl_import_lib`.

Signed-off-by: Alexander Jung <alexander.jung@neclab.eu>
Signed-off-by: Gaulthier Gain <gaulthier.gain@uliege.be>
---
 Config.uk                  | 219 ++++++++-
 Makefile.rules             |  31 ++
 Makefile.uk                | 125 ++++-
 Makefile.uk.musl.aio       |  22 +-
 Makefile.uk.musl.complex   | 142 +++---
 Makefile.uk.musl.conf      |  22 +-
 Makefile.uk.musl.crypt     |  27 +-
 Makefile.uk.musl.ctype     |  90 ++--
 Makefile.uk.musl.dirent    |  42 +-
 Makefile.uk.musl.env       |  38 +-
 Makefile.uk.musl.errno     |  13 +-
 Makefile.uk.musl.exit      |  28 +-
 Makefile.uk.musl.fcntl     |  20 +-
 Makefile.uk.musl.fenv      |  55 ++-
 Makefile.uk.musl.internal  |  66 ++-
 Makefile.uk.musl.ipc       |  41 +-
 Makefile.uk.musl.ldso      |  68 +--
 Makefile.uk.musl.legacy    |  56 ++-
 Makefile.uk.musl.linux     | 152 +++---
 Makefile.uk.musl.locale    |  82 +++-
 Makefile.uk.musl.malloc    |  32 +-
 Makefile.uk.musl.math      | 926 +++++++++++++++++++------------------
 Makefile.uk.musl.misc      | 117 +++--
 Makefile.uk.musl.mman      |  49 +-
 Makefile.uk.musl.mq        |  32 +-
 Makefile.uk.musl.multibyte |  51 +-
 Makefile.uk.musl.network   | 197 +++++---
 Makefile.uk.musl.passwd    |  60 ++-
 Makefile.uk.musl.prng      |  30 +-
 Makefile.uk.musl.process   |  90 ++--
 Makefile.uk.musl.regex     |  34 +-
 Makefile.uk.musl.sched     |  29 +-
 Makefile.uk.musl.search    |  17 +-
 Makefile.uk.musl.select    |  17 +-
 Makefile.uk.musl.setjmp    |  62 +--
 Makefile.uk.musl.signal    | 155 ++++---
 Makefile.uk.musl.stat      |  51 +-
 Makefile.uk.musl.stdio     | 266 ++++++-----
 Makefile.uk.musl.stdlib    |  60 ++-
 Makefile.uk.musl.string    | 189 ++++----
 Makefile.uk.musl.temp      |  26 +-
 Makefile.uk.musl.termios   |  28 +-
 Makefile.uk.musl.thread    | 413 +++++++++--------
 Makefile.uk.musl.time      | 117 +++--
 Makefile.uk.musl.unistd    | 189 ++++----
 45 files changed, 2832 insertions(+), 1744 deletions(-)
 create mode 100644 Makefile.rules

diff --git a/Config.uk b/Config.uk
index 7862da8..8b530c6 100644
--- a/Config.uk
+++ b/Config.uk
@@ -1,9 +1,214 @@
 # hidden
 menuconfig LIBMUSL
-        bool "musl - A C standard library"
-        default n
-        select HAVE_LIBC
-        select LIBKUALLOC
-        select LIBSYSCALL_SHIM
-        select LIBVFSCORE
-        select LIBPOSIX_PROCESS
+  bool "musl: A C standard library"
+  default n
+  select HAVE_LIBC
+  select LIBKUALLOC
+  select LIBSYSCALL_SHIM
+  select LIBVFSCORE
+  select LIBPOSIX_PROCESS
+
+  select LIBMUSL_CTYPE
+  select LIBMUSL_DIRENT
+  select LIBMUSL_ENV
+  select LIBMUSL_ERRNO
+  select LIBMUSL_EXIT
+  select LIBMUSL_INTERNAL
+  select LIBMUSL_LOCALE
+  select LIBMUSL_STAT
+  select LIBMUSL_STDIO
+  select LIBMUSL_STDLIB
+  select LIBMUSL_STRING
+  select LIBMUSL_TERMIOS
+
+if LIBMUSL
+
+config LIBMUSL_AIO
+  bool "libaio"
+  default y
+
+config LIBMUSL_COMPLEX
+  bool "libcomplex"
+  default y
+
+config LIBMUSL_CONF
+  bool "libconf"
+  default y
+
+config LIBMUSL_CRYPT
+  bool "libcrypt"
+  default y
+
+config LIBMUSL_CTYPE
+  bool "libctype"
+  default y
+
+config LIBMUSL_DIRENT
+  bool "libdirent"
+  default y
+
+config LIBMUSL_ENV
+  bool "libenv"
+  default y
+
+config LIBMUSL_ERRNO
+  bool "liberrno"
+  default y
+
+config LIBMUSL_EXIT
+  bool "libexit"
+  default y
+
+config LIBMUSL_FCNTL
+  bool "libfcntl"
+  default y
+
+config LIBMUSL_FENV
+  bool "libfenv"
+  default y
+
+config LIBMUSL_INTERNAL
+  bool "libinternal"
+  default y
+
+config LIBMUSL_IPC
+  bool "libipc"
+  default y
+
+config LIBMUSL_LDSO
+  bool "libldso"
+  default y
+
+config LIBMUSL_LEGACY
+  bool "liblegacy"
+  default y
+
+config LIBMUSL_LINUX
+  bool "liblinux"
+  default y
+
+config LIBMUSL_LOCALE
+  bool "liblocale"
+  default y
+  select LIBMUSL_TIME
+
+config LIBMUSL_MALLOC
+  bool "libmalloc"
+  default y
+
+config LIBMUSL_MATH
+  bool "libmath"
+  default y
+  select LIBMUSL_FENV
+
+config LIBMUSL_MISC
+  bool "libmisc"
+  default y
+  select LIBMUSL_NETWORK
+
+config LIBMUSL_MMAN
+  bool "libmman"
+  default y
+
+config LIBMUSL_MQ
+  bool "libmq"
+  default y
+  select LIBMUSL_NETWORK
+
+config LIBMUSL_MULTIBYTE
+  bool "libmultibyte"
+  default y
+
+config LIBMUSL_NETWORK
+  bool "libnetwork"
+  default y
+
+config LIBMUSL_PASSWD
+  bool "libpasswd"
+  default y
+
+config LIBMUSL_PRNG
+  bool "libprng"
+  default y
+
+config LIBMUSL_PROCESS
+  bool "libprocess"
+  default y
+  select LIBMUSL_THREAD
+
+config LIBMUSL_REGEX
+  bool "libregex"
+  default y
+
+config LIBMUSL_SCHED
+  bool "libsched"
+  default y
+
+config LIBMUSL_SEARCH
+  bool "libsearch"
+  default y
+
+config LIBMUSL_SELECT
+  bool "libselect"
+  default y
+
+config LIBMUSL_SETJMP
+  bool "libsetjmp"
+  default y
+
+config LIBMUSL_SIGNAL
+  bool "libsignal"
+  default y
+  select LIBMUSL_SETJMP
+
+config LIBMUSL_STAT
+  bool "libstat"
+  default y
+
+config LIBMUSL_STDIO
+  bool "libstdio"
+  default y
+  select LIBMUSL_FENV
+  select LIBMUSL_MATH
+  select LIBMUSL_TEMP
+  select LIBMUSL_UNISTD
+
+config LIBMUSL_STDLIB
+  bool "libstdlib"
+  default y
+  select LIBMUSL_SIGNAL
+  select LIBMUSL_MULTIBYTE
+
+config LIBMUSL_STRING
+  bool "libstring"
+  default y
+
+config LIBMUSL_TEMP
+  bool "libtemp"
+  default y
+
+config LIBMUSL_TERMIOS
+  bool "libtermios"
+  default y
+
+config LIBMUSL_THREAD
+  bool "libthread"
+  default y
+  select LIBMUSL_SCHED
+  select LIBMUSL_MMAN
+
+config LIBMUSL_FORCE_THREAD
+  bool
+  default y if LIBUKSCHED
+  default n
+  select LIBMUSL_THREAD
+
+config LIBMUSL_TIME
+  bool "libtime"
+  default y
+  
+config LIBMUSL_UNISTD
+  bool "libunistd"
+  default y
+
+endif
diff --git a/Makefile.rules b/Makefile.rules
new file mode 100644
index 0000000..53e8477
--- /dev/null
+++ b/Makefile.rules
@@ -0,0 +1,31 @@
+#
+# Import a sub-library of musl
+#
+# @param $(1)
+#   The name of the sub-library within musl.
+# @param $(2)
+#   The headers for this sub-library.
+# @param $(3)
+#   The source files for this sub-library.
+#
+define _libmusl_import_lib
+$(LIBMUSL_BUILD)/include/$(1):
+	$(call verbose_cmd,MKDIR,libmusl: $(subst $(LIBMUSL_BUILD),,$(1)): $(notdir $$@), mkdir -p $$@)
+
+# Make a symbolic link of the original header file to a sub-library directory
+$(LIBMUSL_BUILD)/include/$(1)/%.h:
+	$$(Q)mkdir -p $$(shell dirname $$@)
+	$(call verbose_cmd,HOSTLN,libmusl: $(1): $$(subst $(LIBMUSL_BUILD)/include/$(1)/,,$$@), \
+		ln -sf $$(subst $(LIBMUSL_BUILD)/include/$(1)/,$(LIBMUSL),$$@) $$@)
+
+LIBMUSL_$(call uc,$(1))_INCLUDES-y += -I$(LIBMUSL_BUILD)/include/$(1)/include
+LIBMUSL_$(call uc,$(1))_INCLUDES-y += -I$(LIBMUSL_BUILD)/include/$(1)/src/internal
+LIBMUSL_$(call uc,$(1))_INCLUDES-y += -I$(LIBMUSL_BUILD)/include/$(1)/src/$(1)
+LIBMUSL_SRCS-y += $(3)
+
+CINCLUDES-y += $$(LIBMUSL_$(call uc,$(1))_INCLUDES-y)
+CXXINCLUDES-y += $$(LIBMUSL_$(call uc,$(1))_INCLUDES-y)
+
+# Append the sub library directory to the include path
+$(LIBMUSL_BUILD)/.prepared: $(subst $(LIBMUSL),$(LIBMUSL_BUILD)/include/$(1),$(2))
+endef
diff --git a/Makefile.uk b/Makefile.uk
index 9657bb7..6de0b77 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -1,6 +1,8 @@
 #  libmusl Makefile.uk
 #
 #  Authors: Felipe Huici <felipe.huici@neclab.eu>
+#           Gaulthier Gain <gaulthier.gain@uliege.be>
+#           Alexander Jung <alexander.jung@neclab.eu>
 #
 #  Copyright (c) 2017, NEC Europe Ltd., NEC Corporation. All rights reserved.
 #
@@ -36,6 +38,7 @@
 # Library registration
 ################################################################################
 $(eval $(call addlib_s,libmusl,$(CONFIG_LIBMUSL)))
+
 # Additionally, build glue code. This is put into a separate library so that we
 # can apply a thick helping of warning suppressions to musl, which throws
 # lots of compilation warnings, but keep our glue code up to our standards.
@@ -56,13 +59,14 @@ $(eval $(call patch,libmusl,$(LIBMUSL_PATCHDIR),musl-$(LIBMUSL_VERSION)))
 LIBMUSL_SUBDIR=musl-$(LIBMUSL_VERSION)
 LIBMUSL=$(LIBMUSL_ORIGIN)/$(LIBMUSL_SUBDIR)/
 
+# Additional macros for musl sub-libraries
+include $(LIBMUSL_BASE)/Makefile.rules
+
 ################################################################################
 # Library includes
 ################################################################################
 LIBMUSL_GLOBAL_INCLUDES-y   += -I$(LIBMUSL)/arch/$(ARCH)
 LIBMUSL_GLOBAL_INCLUDES-y   += -I$(LIBMUSL)/arch/generic
-LIBMUSL_GLOBAL_INCLUDES-y   += -I$(LIBMUSL)/src/internal
-LIBMUSL_GLOBAL_INCLUDES-y   += -I$(LIBMUSL)/include
 LIBMUSL_GLOBAL_INCLUDES-y   += -I$(LIBMUSL_BASE)/include
 
 CINCLUDES-y    += $(LIBMUSL_GLOBAL_INCLUDES-y)
@@ -87,15 +91,22 @@ $(LIBMUSL)/src/internal/version.h:
 
 UK_PREPARE += $(LIBMUSL)/arch/$(ARCH)/bits/alltypes.h
 UK_PREPARE += $(LIBMUSL)/src/internal/version.h
+UK_PREPARE += $(LIBMUSL_BUILD)/.prepared
 
 LIBMUSL_CLEAN += $(LIBMUSL)/arch/$(ARCH)/bits/alltypes.h
 LIBMUSL_CLEAN += $(LIBMUSL)/src/internal/version.h
+LIBMUSL_CLEAN += $(LIBMUSL_BUILD)/include
 
 ################################################################################
 # Global flags
 ################################################################################
-LIBMUSL_HEADER_FLAGS-y += -Wno-unused-parameter -Wno-unused-value \
-			  -Wno-parentheses
+LIBMUSL_HDRS_FLAGS-y += -Wno-unused-parameter
+LIBMUSL_HDRS_FLAGS-y += -Wno-unused-value
+LIBMUSL_HDRS_FLAGS-y += -Wno-parentheses
+LIBMUSL_HDRS_FLAGS-y += -Wno-error=sign-compare
+LIBMUSL_HDRS_FLAGS-y += -Wno-builtin-macro-redefined
+LIBMUSL_HDRS_FLAGS-y += -D_POSIX_SOURCE -D_BSD_SOURCE
+
 LIBMUSL_CFLAGS-y += -Wno-implicit-fallthrough
 LIBMUSL_CFLAGS-y += -Wno-restrict
 LIBMUSL_CFLAGS-y += -Wno-unused-but-set-variable
@@ -107,59 +118,159 @@ LIBMUSL_CFLAGS-y += -Wno-missing-braces
 LIBMUSL_CFLAGS-y += -Wno-cast-function-type
 LIBMUSL_CFLAGS-y += -Wno-format-contains-nul
 LIBMUSL_CFLAGS-y += -Wno-type-limits
-LIBMUSL_CFLAGS-y += $(LIBMUSL_HEADER_FLAGS-y)
+LIBMUSL_CFLAGS-y += $(LIBMUSL_HDRS_FLAGS-y)
 
 # We globally switch off warnings that are caused by musl's public headers
-CFLAGS += $(LIBMUSL_HEADER_FLAGS-y)
-CXXFLAGS += $(LIBMUSL_HEADER_FLAGS-y)
+CFLAGS += $(LIBMUSL_HDRS_FLAGS-y)
+CXXFLAGS += $(LIBMUSL_HDRS_FLAGS-y)
 
 ################################################################################
 # OS dependencies code - Glue between Unicore and musl
 ################################################################################
 LIBMUSLGLUE_SRCS-y += $(LIBMUSL_BASE)/mem.c
 
+################################################################################
+# Core Standard Library
+################################################################################
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/sys/types.h
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/sys/param.h
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/sys/time.h
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/sys/mount.h
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/sys/sysmacros.h
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/sys/file.h
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/alloca.h
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/stdbool.h
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_CORE_HDRS-y += $(LIBMUSL)/include/assert.h
+
+$(eval $(call _libmusl_import_lib,core,$(LIBMUSL_CORE_HDRS-y),$(LIBMUSL_CORE_SRCS-y)))
+
 ################################################################################
 # musl code -- one external Makefile per sub-lib
 ################################################################################
+ifeq ($(CONFIG_LIBMUSL_MQ),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.mq
+endif
+ifeq ($(CONFIG_LIBMUSL_DIRENT),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.dirent
+endif
+ifeq ($(CONFIG_LIBMUSL_MISC),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.misc
+endif
+ifeq ($(CONFIG_LIBMUSL_TEMP),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.temp
+endif
+ifeq ($(CONFIG_LIBMUSL_MULTIBYTE),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.multibyte
+endif
+ifeq ($(CONFIG_LIBMUSL_PROCESS),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.process
+endif
+ifeq ($(CONFIG_LIBMUSL_MMAN),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.mman
+endif
+ifeq ($(CONFIG_LIBMUSL_STDLIB),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.stdlib
+endif
+ifeq ($(CONFIG_LIBMUSL_FCNTL),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.fcntl
+endif
+ifeq ($(CONFIG_LIBMUSL_STDIO),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.stdio
+endif
+ifeq ($(CONFIG_LIBMUSL_CONF),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.conf
+endif
+ifeq ($(CONFIG_LIBMUSL_MATH),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.math
+endif
+ifeq ($(CONFIG_LIBMUSL_AIO),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.aio
+endif
+ifeq ($(CONFIG_LIBMUSL_STAT),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.stat
+endif
+ifeq ($(CONFIG_LIBMUSL_SEARCH),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.search
+endif
+ifeq ($(CONFIG_LIBMUSL_CRYPT),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.crypt
+endif
+ifeq ($(CONFIG_LIBMUSL_SELECT),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.select
+endif
+ifeq ($(CONFIG_LIBMUSL_MALLOC),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.malloc
+endif
+ifeq ($(CONFIG_LIBMUSL_UNISTD),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.unistd
+endif
+ifeq ($(CONFIG_LIBMUSL_SIGNAL),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.signal
+endif
+ifeq ($(CONFIG_LIBMUSL_THREAD),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.thread
+endif
+ifeq ($(CONFIG_LIBMUSL_LEGACY),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.legacy
+endif
+ifeq ($(CONFIG_LIBMUSL_ENV),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.env
+endif
+ifeq ($(CONFIG_LIBMUSL_TIME),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.time
+endif
+ifeq ($(CONFIG_LIBMUSL_ERRNO),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.errno
+endif
+ifeq ($(CONFIG_LIBMUSL_IPC),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.ipc
+endif
+ifeq ($(CONFIG_LIBMUSL_PRNG),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.prng
+endif
+ifeq ($(CONFIG_LIBMUSL_LDSO),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.ldso
+endif
+ifeq ($(CONFIG_LIBMUSL_PASSWD),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.passwd
+endif
+ifeq ($(CONFIG_LIBMUSL_FENV),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.fenv
+endif
+ifeq ($(CONFIG_LIBMUSL_CTYPE),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.ctype
+endif
+ifeq ($(CONFIG_LIBMUSL_LINUX),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.linux
+endif
+ifeq ($(CONFIG_LIBMUSL_INTERNAL),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.internal
+endif
+ifeq ($(CONFIG_LIBMUSL_NETWORK),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.network
+endif
+ifeq ($(CONFIG_LIBMUSL_SCHED),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.sched
+endif
+ifeq ($(CONFIG_LIBMUSL_STRING),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.string
+endif
+ifeq ($(CONFIG_LIBMUSL_REGEX),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.regex
+endif
+ifeq ($(CONFIG_LIBMUSL_TERMIOS),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.termios
+endif
+ifeq ($(CONFIG_LIBMUSL_EXIT),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.exit
+endif
+ifeq ($(CONFIG_LIBMUSL_SETJMP),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.setjmp
+endif
+ifeq ($(CONFIG_LIBMUSL_LOCALE),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.locale
+endif
+ifeq ($(CONFIG_LIBMUSL_COMPLEX),y)
 include $(LIBMUSL_BASE)/Makefile.uk.musl.complex
+endif
diff --git a/Makefile.uk.musl.aio b/Makefile.uk.musl.aio
index f59397a..ac4ab88 100644
--- a/Makefile.uk.musl.aio
+++ b/Makefile.uk.musl.aio
@@ -1,3 +1,19 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/aio/aio.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/aio/aio_suspend.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/aio/lio_listio.c
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/include/aio.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/include/pthread.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/include/semaphore.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/include/time.h
+LIBMUSL_AIO_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+LIBMUSL_AIO_SRCS-y += $(LIBMUSL)/src/aio/aio.c
+LIBMUSL_AIO_SRCS-y += $(LIBMUSL)/src/aio/aio_suspend.c
+LIBMUSL_AIO_SRCS-y += $(LIBMUSL)/src/aio/lio_listio.c
+
+$(eval $(call _libmusl_import_lib,aio,$(LIBMUSL_AIO_HDRS-y),$(LIBMUSL_AIO_SRCS-y)))
diff --git a/Makefile.uk.musl.complex b/Makefile.uk.musl.complex
index 14ea162..84c8d26 100644
--- a/Makefile.uk.musl.complex
+++ b/Makefile.uk.musl.complex
@@ -1,71 +1,77 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/casinh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/csinhl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/creal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/__cexpf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/casinl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cabs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cexp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ctanl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ccosl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ccoshf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ccosh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/csqrt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ccos.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cacos.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cacosl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cexpf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cprojf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/conjf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/catanhl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/creall.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/catanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/csinl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cacosf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/csinh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cimag.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ctan.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/casinf.c
+LIBMUSL_COMPLEX_HDRS-y += $(LIBMUSL)/include/complex.h
+LIBMUSL_COMPLEX_HDRS-y += $(LIBMUSL)/include/float.h
+LIBMUSL_COMPLEX_HDRS-y += $(LIBMUSL)/src/intenal/libm.h
+
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/casinh.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/csinhl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/creal.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/__cexpf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/casinl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cabs.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cexp.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ctanl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ccosl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ccoshf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ccosh.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/csqrt.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ccos.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cacos.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cacosl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cexpf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cprojf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/conjf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/catanhl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/creall.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/catanf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/csinl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cacosf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/csinh.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cimag.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ctan.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/casinf.c
 # TO DO: missing __mulxc3
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cpowl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cacoshf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ctanhl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/casinhl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/casinhf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/catanl.c
+#LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cpowl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cacoshf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ctanhl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/casinhl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/casinhf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/catanl.c
 # TO DO: missing __muldc3
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cpow.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/catanh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/__cexp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/clogl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cacosh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cargl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/catanhf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cimagl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cprojl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/conj.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cproj.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cargf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/catan.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cacoshl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/clogf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/csqrtf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/clog.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/casin.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ctanh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cexpl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/csin.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cabsf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ctanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cimagf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ctanhf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/carg.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/csinhf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/csinf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/crealf.c
+#LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cpow.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/catanh.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/__cexp.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/clogl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cacosh.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cargl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/catanhf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cimagl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cprojl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/conj.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cproj.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cargf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/catan.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cacoshl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/clogf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/csqrtf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/clog.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/casin.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ctanh.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cexpl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/csin.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cabsf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ctanf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cimagf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ctanhf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/carg.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/csinhf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/csinf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/crealf.c
 # TO DO: missing __mulsc3
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cpowf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/cabsl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/conjl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ccoshl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/csqrtl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/complex/ccosf.c
+#LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cpowf.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/cabsl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/conjl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ccoshl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/csqrtl.c
+LIBMUSL_COMPLEX_SRCS-y += $(LIBMUSL)/src/complex/ccosf.c
+
+$(eval $(call _libmusl_import_lib,complex,$(LIBMUSL_COMPLEX_HDRS-y),$(LIBMUSL_COMPLEX_SRCS-y)))
diff --git a/Makefile.uk.musl.conf b/Makefile.uk.musl.conf
index 4e89e81..e4e49de 100644
--- a/Makefile.uk.musl.conf
+++ b/Makefile.uk.musl.conf
@@ -1,5 +1,17 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/conf/confstr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/conf/fpathconf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/conf/legacy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/conf/pathconf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/conf/sysconf.c
+LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/include/sys/resource.h
+LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/include/sys/sysinfo.h
+LIBMUSL_CONF_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+LIBMUSL_CONF_SRCS-y += $(LIBMUSL)/src/conf/confstr.c
+LIBMUSL_CONF_SRCS-y += $(LIBMUSL)/src/conf/fpathconf.c
+LIBMUSL_CONF_SRCS-y += $(LIBMUSL)/src/conf/legacy.c
+LIBMUSL_CONF_SRCS-y += $(LIBMUSL)/src/conf/pathconf.c
+LIBMUSL_CONF_SRCS-y += $(LIBMUSL)/src/conf/sysconf.c
+
+$(eval $(call _libmusl_import_lib,conf,$(LIBMUSL_CONF_HDRS-y),$(LIBMUSL_CONF_SRCS-y)))
diff --git a/Makefile.uk.musl.crypt b/Makefile.uk.musl.crypt
index 71ceda6..0d491ac 100644
--- a/Makefile.uk.musl.crypt
+++ b/Makefile.uk.musl.crypt
@@ -1,8 +1,19 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/crypt/crypt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/crypt/crypt_blowfish.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/crypt/crypt_des.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/crypt/crypt_md5.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/crypt/crypt_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/crypt/crypt_sha256.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/crypt/crypt_sha512.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/crypt/encrypt.c
+LIBMUSL_CRYPT_HDRS-y += $(LIBMUSL)/include/crypt.h
+LIBMUSL_CRYPT_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_CRYPT_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_CRYPT_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_CRYPT_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_CRYPT_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_CRYPT_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_CRYPT_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+LIBMUSL_CRYPT_SRCS-y += $(LIBMUSL)/src/crypt/crypt.c
+LIBMUSL_CRYPT_SRCS-y += $(LIBMUSL)/src/crypt/crypt_blowfish.c
+LIBMUSL_CRYPT_SRCS-y += $(LIBMUSL)/src/crypt/crypt_des.c
+LIBMUSL_CRYPT_SRCS-y += $(LIBMUSL)/src/crypt/crypt_md5.c
+LIBMUSL_CRYPT_SRCS-y += $(LIBMUSL)/src/crypt/crypt_r.c
+LIBMUSL_CRYPT_SRCS-y += $(LIBMUSL)/src/crypt/crypt_sha256.c
+LIBMUSL_CRYPT_SRCS-y += $(LIBMUSL)/src/crypt/crypt_sha512.c
+LIBMUSL_CRYPT_SRCS-y += $(LIBMUSL)/src/crypt/encrypt.c
+
+$(eval $(call _libmusl_import_lib,crypt,$(LIBMUSL_CRYPT_HDRS-y),$(LIBMUSL_CRYPT_SRCS-y)))
diff --git a/Makefile.uk.musl.ctype b/Makefile.uk.musl.ctype
index c02dfed..0da9391 100644
--- a/Makefile.uk.musl.ctype
+++ b/Makefile.uk.musl.ctype
@@ -1,37 +1,53 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/__ctype_b_loc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/__ctype_get_mb_cur_max.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/__ctype_tolower_loc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/__ctype_toupper_loc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isalnum.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isalpha.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isascii.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isblank.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iscntrl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isdigit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isgraph.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/islower.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isprint.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/ispunct.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isspace.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isupper.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswalnum.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswalpha.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswblank.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswcntrl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswctype.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswdigit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswgraph.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswlower.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswprint.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswpunct.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswspace.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswupper.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/iswxdigit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/isxdigit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/toascii.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/tolower.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/toupper.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/towctrans.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/wcswidth.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/wctrans.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ctype/wcwidth.c
+# LIBMUSL_CTYPE_HDRS-y += alpha.h # not found
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/include/endian.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/src/internal/locale_impl.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/src/ctype/nonspacing.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/src/ctype/punct.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/include/wchar.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/include/wctype.h
+LIBMUSL_CTYPE_HDRS-y += $(LIBMUSL)/src/ctype/wide.h
+
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/__ctype_b_loc.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/__ctype_get_mb_cur_max.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/__ctype_tolower_loc.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/__ctype_toupper_loc.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isalnum.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isalpha.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isascii.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isblank.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iscntrl.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isdigit.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isgraph.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/islower.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isprint.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/ispunct.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isspace.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isupper.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswalnum.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswalpha.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswblank.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswcntrl.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswctype.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswdigit.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswgraph.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswlower.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswprint.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswpunct.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswspace.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswupper.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/iswxdigit.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/isxdigit.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/toascii.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/tolower.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/toupper.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/towctrans.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/wcswidth.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/wctrans.c
+LIBMUSL_CTYPE_SRCS-y += $(LIBMUSL)/src/ctype/wcwidth.c
+
+$(eval $(call _libmusl_import_lib,ctype,$(LIBMUSL_CTYPE_HDRS-y),$(LIBMUSL_CTYPE_SRCS-y)))
diff --git a/Makefile.uk.musl.dirent b/Makefile.uk.musl.dirent
index 3bb54a3..c64b2d7 100644
--- a/Makefile.uk.musl.dirent
+++ b/Makefile.uk.musl.dirent
@@ -1,13 +1,29 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/__getdents.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/alphasort.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/closedir.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/dirfd.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/fdopendir.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/opendir.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/readdir.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/readdir_r.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/rewinddir.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/scandir.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/seekdir.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/telldir.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/dirent/versionsort.c
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/include/dirent.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/include/string.h
+
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/include/unistd.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/src/dirent/__dirent.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_DIRENT_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+
+LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/__getdents.c
+LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/alphasort.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/closedir.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/dirfd.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/fdopendir.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/opendir.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/readdir.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/readdir_r.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/rewinddir.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/scandir.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/seekdir.c
+#LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/telldir.c
+LIBMUSL_DIRENT_SRCS-y += $(LIBMUSL)/src/dirent/versionsort.c
+
+$(eval $(call _libmusl_import_lib,dirent,$(LIBMUSL_DIRENT_HDRS-y),$(LIBMUSL_DIRENT_SRCS-y)))
diff --git a/Makefile.uk.musl.env b/Makefile.uk.musl.env
index b724725..cab319e 100644
--- a/Makefile.uk.musl.env
+++ b/Makefile.uk.musl.env
@@ -1,10 +1,28 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/__environ.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/__init_tls.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/__libc_start_main.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/__reset_tls.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/__stack_chk_fail.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/clearenv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/getenv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/putenv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/setenv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/env/unsetenv.c
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/elf.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/poll.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_ENV_HDRS-y += $(LIBMUSL)/include/sys/mman.h
+
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/__environ.c
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/__init_tls.c
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/__libc_start_main.c
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/__reset_tls.c
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/__stack_chk_fail.c
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/clearenv.c
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/getenv.c
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/putenv.c
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/setenv.c
+LIBMUSL_ENV_SRCS-y += $(LIBMUSL)/src/env/unsetenv.c
+
+$(eval $(call _libmusl_import_lib,env,$(LIBMUSL_ENV_HDRS-y),$(LIBMUSL_ENV_SRCS-y)))
diff --git a/Makefile.uk.musl.errno b/Makefile.uk.musl.errno
index d43226e..985f93a 100644
--- a/Makefile.uk.musl.errno
+++ b/Makefile.uk.musl.errno
@@ -1,2 +1,11 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/errno/__errno_location.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/errno/strerror.c
+LIBMUSL_ERRNO_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_ERRNO_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_ERRNO_HDRS-y += $(LIBMUSL)/src/internal/locale_impl.h
+LIBMUSL_ERRNO_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_ERRNO_HDRS-y += $(LIBMUSL)/src/errno/__strerror.h
+LIBMUSL_ERRNO_HDRS-y += $(LIBMUSL)/include/string.h
+
+LIBMUSL_ERRNO_SRCS-y += $(LIBMUSL)/src/errno/__errno_location.c
+LIBMUSL_ERRNO_SRCS-y += $(LIBMUSL)/src/errno/strerror.c
+
+$(eval $(call _libmusl_import_lib,errno,$(LIBMUSL_ERRNO_HDRS-y),$(LIBMUSL_ERRNO_SRCS-y)))
diff --git a/Makefile.uk.musl.exit b/Makefile.uk.musl.exit
index eea591c..b9386be 100644
--- a/Makefile.uk.musl.exit
+++ b/Makefile.uk.musl.exit
@@ -1,8 +1,20 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/exit/_Exit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/exit/abort.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/exit/arm/__aeabi_atexit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/exit/assert.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/exit/at_quick_exit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/exit/atexit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/exit/exit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/exit/quick_exit.c
+LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/include/getopt.h
+LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_EXIT_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+
+LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/_Exit.c
+LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/abort.c
+LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/arm/__aeabi_atexit.c
+LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/assert.c
+LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/at_quick_exit.c
+LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/atexit.c
+LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/exit.c
+LIBMUSL_EXIT_SRCS-y += $(LIBMUSL)/src/exit/quick_exit.c
+
+$(eval $(call _libmusl_import_lib,exit,$(LIBMUSL_EXIT_HDRS-y),$(LIBMUSL_EXIT_SRCS-y)))
diff --git a/Makefile.uk.musl.fcntl b/Makefile.uk.musl.fcntl
index b2f8d2b..78a94c8 100644
--- a/Makefile.uk.musl.fcntl
+++ b/Makefile.uk.musl.fcntl
@@ -1,6 +1,14 @@
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fcntl/creat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fcntl/fcntl.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fcntl/open.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fcntl/openat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fcntl/posix_fadvise.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fcntl/posix_fallocate.c
+LIBMUSL_FCNTL_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_FCNTL_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_FCNTL_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_FCNTL_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_FCNTL_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+
+#LIBMUSL_FCNTL_SRCS-y += $(LIBMUSL)/src/fcntl/creat.c
+#LIBMUSL_FCNTL_SRCS-y += $(LIBMUSL)/src/fcntl/fcntl.c
+#LIBMUSL_FCNTL_SRCS-y += $(LIBMUSL)/src/fcntl/open.c
+#LIBMUSL_FCNTL_SRCS-y += $(LIBMUSL)/src/fcntl/openat.c
+#LIBMUSL_FCNTL_SRCS-y += $(LIBMUSL)/src/fcntl/posix_fadvise.c
+LIBMUSL_FCNTL_SRCS-y += $(LIBMUSL)/src/fcntl/posix_fallocate.c
+
+$(eval $(call _libmusl_import_lib,fcntl,$(LIBMUSL_FCNTL_HDRS-y),$(LIBMUSL_FCNTL_SRCS-y)))
diff --git a/Makefile.uk.musl.fenv b/Makefile.uk.musl.fenv
index 355beca..62e46b1 100644
--- a/Makefile.uk.musl.fenv
+++ b/Makefile.uk.musl.fenv
@@ -1,32 +1,37 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/__flt_rounds.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/fegetexceptflag.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/feholdexcept.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/fesetexceptflag.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/fesetround.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/feupdateenv.c
+LIBMUSL_FENV_HDRS-y += $(LIBMUSL)/include/fenv.h
+LIBMUSL_FENV_HDRS-y += $(LIBMUSL)/include/float.h
+
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/__flt_rounds.c
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/fegetexceptflag.c
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/feholdexcept.c
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/fesetexceptflag.c
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/fesetround.c
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/feupdateenv.c
 
 ifeq (arm,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/arm/fenv-hf.S|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/arm/fenv.c|arm
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/arm/fenv-hf.S|arm
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/arm/fenv.c|arm
 else ifeq (x86_32,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/i386/fenv.s|x86_32
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/i386/fenv.s|x86_32
 else ifeq (x86_64,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/x86_64/fenv.s|x86_64
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/x86_64/fenv.s|x86_64
 else
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/fenv.c
+LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/fenv.c
 endif
 
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/aarch64/fenv.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/mips/fenv-sf.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/mips/fenv.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/mips64/fenv-sf.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/mips64/fenv.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/mipsn32/fenv-sf.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/mipsn32/fenv.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/powerpc/fenv-sf.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/powerpc/fenv.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/powerpc64/fenv.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/s390x/fenv.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/sh/fenv-nofpu.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/sh/fenv.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/fenv/x32/fenv.s
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/aarch64/fenv.s
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/mips/fenv-sf.c
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/mips/fenv.S
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/mips64/fenv-sf.c
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/mips64/fenv.S
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/mipsn32/fenv-sf.c
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/mipsn32/fenv.S
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/powerpc/fenv-sf.c
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/powerpc/fenv.S
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/powerpc64/fenv.c
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/s390x/fenv.c
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/sh/fenv-nofpu.c
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/sh/fenv.S
+#LIBMUSL_FENV_SRCS-y += $(LIBMUSL)/src/fenv/x32/fenv.s
+
+$(eval $(call _libmusl_import_lib,fenv,$(LIBMUSL_FENV_HDRS-y),$(LIBMUSL_FENV_SRCS-y)))
diff --git a/Makefile.uk.musl.internal b/Makefile.uk.musl.internal
index b65b15b..6f909ff 100644
--- a/Makefile.uk.musl.internal
+++ b/Makefile.uk.musl.internal
@@ -1,32 +1,48 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/floatscan.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/intscan.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/libc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/procfdname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/shgetc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/syscall.c|internal
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/syscall_ret.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/vdso.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/version.c
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/elf.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/float.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/src/internal/floatscan.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/link.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/math.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/src/internal/shgetc.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_INTERNAL_HDRS-y += $(LIBMUSL)/src/internal/version.h
+
+LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/floatscan.c
+LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/intscan.c
+LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/libc.c
+LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/procfdname.c
+LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/shgetc.c
+LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/syscall.c|internal
+LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/syscall_ret.c
+LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/vdso.c
+LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/version.c
 
 #ifeq (arm,$(CONFIG_UK_ARCH))
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/arm/syscall.s|arm
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/arm/syscall.s|arm
 #else ifeq (x86_32,$(CONFIG_UK_ARCH))
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/i386/syscall.s|i386
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/i386/syscall.s|i386
 #else ifeq (x86_64,$(CONFIG_UK_ARCH))
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/x86_64/syscall.s|x86_64
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/x86_64/syscall.s|x86_64
 #endif
 
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/aarch64/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/microblaze/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/mips/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/mips64/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/mipsn32/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/or1k/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/powerpc/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/powerpc64/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/s390x/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/sh/__shcall.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/sh/syscall.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/internal/x32/syscall.s|x32
-
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/aarch64/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/microblaze/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/mips/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/mips64/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/mipsn32/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/or1k/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/powerpc/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/powerpc64/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/s390x/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/sh/__shcall.c
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/sh/syscall.s
+#LIBMUSL_INTERNAL_SRCS-y += $(LIBMUSL)/src/internal/x32/syscall.s|x32
 
+$(eval $(call _libmusl_import_lib,internal,$(LIBMUSL_INTERNAL_HDRS-y),$(LIBMUSL_INTERNAL_SRCS-y)))
diff --git a/Makefile.uk.musl.ipc b/Makefile.uk.musl.ipc
index 02f4c25..a64d38e 100644
--- a/Makefile.uk.musl.ipc
+++ b/Makefile.uk.musl.ipc
@@ -1,13 +1,28 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/ftok.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/msgctl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/msgget.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/msgrcv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/msgsnd.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/semctl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/semget.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/semop.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/semtimedop.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/shmat.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/shmctl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/shmdt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ipc/shmget.c
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/src/ipc/ipc.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/include/sys/ipc.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/include/sys/msg.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/include/sys/sem.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/include/sys/shm.h
+LIBMUSL_IPC_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/ftok.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/msgctl.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/msgget.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/msgrcv.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/msgsnd.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/semctl.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/semget.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/semop.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/semtimedop.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/shmat.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/shmctl.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/shmdt.c
+LIBMUSL_IPC_SRCS-y += $(LIBMUSL)/src/ipc/shmget.c
+
+$(eval $(call _libmusl_import_lib,ipc,$(LIBMUSL_IPC_HDRS-y),$(LIBMUSL_IPC_SRCS-y)))
diff --git a/Makefile.uk.musl.ldso b/Makefile.uk.musl.ldso
index a689004..7e1b74b 100644
--- a/Makefile.uk.musl.ldso
+++ b/Makefile.uk.musl.ldso
@@ -1,35 +1,47 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/__dlsym.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/dl_iterate_phdr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/dladdr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/dlclose.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/dlerror.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/dlinfo.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/dlopen.c
+LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/include/dlfcn.h
+LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/include/elf.h
+LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/include/link.h
+LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_LDSO_HDRS-y += $(LIBMUSL)/include/stdlib.h
+
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/__dlsym.c
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/dl_iterate_phdr.c
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/dladdr.c
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/dlclose.c
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/dlerror.c
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/dlinfo.c
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/dlopen.c
 
 ifeq (arm,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/arm/dlsym.s|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/arm/find_exidx.c|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/tlsdesc.c
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/arm/dlsym.s|arm
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/arm/find_exidx.c|arm
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/tlsdesc.c
 else ifeq (x86_32,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/i386/dlsym.s|x86_32
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/i386/tlsdesc.s|x86_32
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/i386/dlsym.s|x86_32
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/i386/tlsdesc.s|x86_32
 else ifeq (x86_64,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/x86_64/dlsym.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/x86_64/tlsdesc.s|x86_64
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/x86_64/dlsym.s|x86_64
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/x86_64/tlsdesc.s|x86_64
 else
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/tlsdesc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/dlsym.c
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/tlsdesc.c
+LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/dlsym.c
 endif
 
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/aarch64/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/aarch64/tlsdesc.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/microblaze/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/mips/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/mips64/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/mipsn32/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/or1k/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/powerpc/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/powerpc64/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/s390x/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/sh/dlsym.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/ldso/x32/dlsym.s
\ No newline at end of file
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/aarch64/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/aarch64/tlsdesc.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/microblaze/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/mips/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/mips64/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/mipsn32/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/or1k/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/powerpc/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/powerpc64/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/s390x/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/sh/dlsym.s
+#LIBMUSL_LDSO_SRCS-y += $(LIBMUSL)/src/ldso/x32/dlsym.s
+
+$(eval $(call _libmusl_import_lib,ldso,$(LIBMUSL_LDSO_HDRS-y),$(LIBMUSL_LDSO_SRCS-y)))
diff --git a/Makefile.uk.musl.legacy b/Makefile.uk.musl.legacy
index 9d73217..3671f28 100644
--- a/Makefile.uk.musl.legacy
+++ b/Makefile.uk.musl.legacy
@@ -1,16 +1,40 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/cuserid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/daemon.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/err.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/euidaccess.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/ftw.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/futimes.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/getdtablesize.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/getloadavg.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/getpagesize.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/getpass.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/getusershell.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/isastream.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/lutimes.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/ulimit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/utmpx.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/legacy/valloc.c
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/err.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/ftw.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/pwd.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/stropts.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/sys/resource.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/sys/sysinfo.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/sys/time.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/termios.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/ulimit.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/unistd.h
+LIBMUSL_LEGACY_HDRS-y += $(LIBMUSL)/include/utmpx.h
+
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/cuserid.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/daemon.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/err.c
+#LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/euidaccess.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/ftw.c
+#LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/futimes.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getdtablesize.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getloadavg.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getpagesize.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getpass.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/getusershell.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/isastream.c
+#LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/lutimes.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/ulimit.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/utmpx.c
+LIBMUSL_LEGACY_SRCS-y += $(LIBMUSL)/src/legacy/valloc.c
+
+$(eval $(call _libmusl_import_lib,legacy,$(LIBMUSL_LEGACY_HDRS-y),$(LIBMUSL_LEGACY_SRCS-y)))
diff --git a/Makefile.uk.musl.linux b/Makefile.uk.musl.linux
index 510f642..50dd483 100644
--- a/Makefile.uk.musl.linux
+++ b/Makefile.uk.musl.linux
@@ -1,57 +1,97 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/adjtime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/adjtimex.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/arch_prctl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/brk.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/cache.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/cap.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/chroot.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/clock_adjtime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/clone.c|linux
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/epoll.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/eventfd.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/fallocate.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/fanotify.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/flock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/inotify.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/ioperm.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/iopl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/klogctl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/module.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/mount.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/personality.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/pivot_root.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/ppoll.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/prctl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/prlimit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/process_vm.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/ptrace.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/quotactl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/readahead.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/reboot.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/remap_file_pages.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/sbrk.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/sendfile.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/setfsgid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/setfsuid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/setgroups.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/sethostname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/setns.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/settimeofday.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/signalfd.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/splice.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/stime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/swap.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/sync_file_range.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/syncfs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/sysinfo.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/tee.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/timerfd.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/unshare.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/utimes.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/vhangup.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/vmsplice.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/wait3.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/wait4.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/xattr.c
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/poll.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sched.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/epoll.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/eventfd.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/fanotify.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/file.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/fsuid.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/inotify.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/io.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/klog.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/mman.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/mount.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/personality.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/prctl.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/ptrace.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/quota.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/reboot.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/resource.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/sendfile.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/signalfd.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/swap.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/sysinfo.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/time.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/timerfd.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/timex.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/uio.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/wait.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/sys/xattr.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/time.h
+LIBMUSL_LINUX_HDRS-y += $(LIBMUSL)/include/unistd.h
 
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/linux/x32/sysinfo.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/adjtime.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/adjtimex.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/arch_prctl.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/brk.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/cache.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/cap.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/chroot.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/clock_adjtime.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/clone.c|linux
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/epoll.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/eventfd.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/fallocate.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/fanotify.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/flock.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/inotify.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/ioperm.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/iopl.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/klogctl.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/module.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/mount.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/personality.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/pivot_root.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/ppoll.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/prctl.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/prlimit.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/process_vm.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/ptrace.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/quotactl.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/readahead.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/reboot.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/remap_file_pages.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/sbrk.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/sendfile.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/setfsgid.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/setfsuid.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/setgroups.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/sethostname.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/setns.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/settimeofday.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/signalfd.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/splice.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/stime.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/swap.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/sync_file_range.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/syncfs.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/sysinfo.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/tee.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/timerfd.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/unshare.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/utimes.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/vhangup.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/vmsplice.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/wait3.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/wait4.c
+LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/xattr.c
+#LIBMUSL_LINUX_SRCS-y += $(LIBMUSL)/src/linux/x32/sysinfo.c
+
+$(eval $(call _libmusl_import_lib,linux,$(LIBMUSL_LINUX_HDRS-y),$(LIBMUSL_LINUX_SRCS-y)))
diff --git a/Makefile.uk.musl.locale b/Makefile.uk.musl.locale
index fd060d8..bffe0a2 100644
--- a/Makefile.uk.musl.locale
+++ b/Makefile.uk.musl.locale
@@ -1,25 +1,57 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/__lctrans.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/__mo_lookup.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/bind_textdomain_codeset.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/c_locale.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/catclose.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/catgets.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/catopen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/dcngettext.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/duplocale.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/freelocale.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/iconv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/iconv_close.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/langinfo.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/locale_map.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/localeconv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/newlocale.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/pleval.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/setlocale.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/strcoll.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/strfmon.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/strxfrm.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/textdomain.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/uselocale.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/wcscoll.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/locale/wcsxfrm.c
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/locale/big5.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/locale/codepages.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/locale/gb18030.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/locale/hkscs.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/iconv.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/locale/jis0208.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/locale/ksc.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/langinfo.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/locale/legacychars.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/libintl.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/locale.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/internal/locale_impl.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/monetary.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/nl_types.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/src/locale/revjis.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/strings.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_LOCALE_HDRS-y += $(LIBMUSL)/include/wchar.h
+
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/__lctrans.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/__mo_lookup.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/bind_textdomain_codeset.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/c_locale.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/catclose.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/catgets.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/catopen.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/dcngettext.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/duplocale.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/freelocale.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/iconv.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/iconv_close.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/langinfo.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/locale_map.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/localeconv.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/newlocale.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/pleval.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/setlocale.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/strcoll.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/strfmon.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/strxfrm.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/textdomain.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/uselocale.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/wcscoll.c
+LIBMUSL_LOCALE_SRCS-y += $(LIBMUSL)/src/locale/wcsxfrm.c
+
+$(eval $(call _libmusl_import_lib,locale,$(LIBMUSL_LOCALE_HDRS-y),$(LIBMUSL_LOCALE_SRCS-y)))
diff --git a/Makefile.uk.musl.malloc b/Makefile.uk.musl.malloc
index 1d2c4d5..e9c2113 100644
--- a/Makefile.uk.musl.malloc
+++ b/Makefile.uk.musl.malloc
@@ -1,9 +1,23 @@
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/malloc/__brk.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/malloc/aligned_alloc.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/malloc/calloc.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/malloc/expand_heap.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/malloc/lite_malloc.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/malloc/malloc.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/malloc/malloc_usable_size.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/malloc/memalign.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/malloc/posix_memalign.c
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/include/malloc.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_MALLOC_HDRS-y += $(LIBMUSL)/include/sys/mman.h
+
+#LIBMUSL_MALLOC_SRCS-y += $(LIBMUSL)/src/malloc/__brk.c
+#LIBMUSL_MALLOC_SRCS-y += $(LIBMUSL)/src/malloc/aligned_alloc.c
+#LIBMUSL_MALLOC_SRCS-y += $(LIBMUSL)/src/malloc/calloc.c
+#LIBMUSL_MALLOC_SRCS-y += $(LIBMUSL)/src/malloc/expand_heap.c
+#LIBMUSL_MALLOC_SRCS-y += $(LIBMUSL)/src/malloc/lite_malloc.c
+#LIBMUSL_MALLOC_SRCS-y += $(LIBMUSL)/src/malloc/malloc.c
+#LIBMUSL_MALLOC_SRCS-y += $(LIBMUSL)/src/malloc/malloc_usable_size.c
+#LIBMUSL_MALLOC_SRCS-y += $(LIBMUSL)/src/malloc/memalign.c
+#LIBMUSL_MALLOC_SRCS-y += $(LIBMUSL)/src/malloc/posix_memalign.c
+
+$(eval $(call _libmusl_import_lib,malloc,$(LIBMUSL_MALLOC_HDRS-y),$(LIBMUSL_MALLOC_SRCS-y)))
diff --git a/Makefile.uk.musl.math b/Makefile.uk.musl.math
index 682de34..37a4bb2 100644
--- a/Makefile.uk.musl.math
+++ b/Makefile.uk.musl.math
@@ -1,462 +1,478 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__cos.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__cosdf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__cosl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__expo2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__expo2f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__fpclassify.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__fpclassifyf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__fpclassifyl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__invtrigl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__polevll.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__rem_pio2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__rem_pio2_large.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__rem_pio2f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__rem_pio2l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__signbit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__signbitf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__signbitl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__sin.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__sindf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__sinl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__tan.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__tandf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/__tanl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/acos.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/acosf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/acosh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/acoshf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/acoshl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/asin.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/asinf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/asinh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/asinhf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/asinhl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atan.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atan2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atan2f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atanh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atanhf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atanhl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/cbrt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/cbrtf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/cbrtl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ceil.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ceilf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/copysign.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/copysignf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/copysignl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/cos.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/cosf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/cosh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/coshf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/coshl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/cosl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/erf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/erff.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/erfl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/exp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/exp10.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/exp10f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/exp10l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/exp2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/exp2f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/expf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/expm1.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/expm1f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fdim.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fdimf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fdiml.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/finite.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/finitef.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/floor.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/floorf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fma.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmaf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmax.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmaxf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmaxl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmin.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fminf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fminl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmod.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmodf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/frexp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/frexpf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/frexpl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/hypot.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/hypotf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/hypotl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/scalb.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/scalbf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/scalbln.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/scalblnf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/scalblnl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/scalbn.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/scalbnf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/scalbnl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/signgam.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/significand.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/significandf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sin.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sincos.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sincosf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sincosl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sinf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sinh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sinhf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sinhl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sinl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/tan.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/tanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/tanh.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/tanhf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/tanhl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/tanl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/tgamma.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/tgammaf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/tgammal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/trunc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/truncf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ilogb.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ilogbf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ilogbl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/j0.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/j0f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/j1.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/j1f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/jn.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/jnf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ldexp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ldexpf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ldexpl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lgamma.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lgamma_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lgammaf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lgammaf_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lgammal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/llround.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/llroundf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/llroundl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log10.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log10f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log1p.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log1pf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log2f.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/logb.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/logbf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/logbl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/logf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lround.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lroundf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lroundl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/modf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/modff.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/modfl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nan.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nanl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nearbyint.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nearbyintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nearbyintl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nextafter.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nextafterf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nextafterl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nexttoward.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nexttowardf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/nexttowardl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/pow.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/remainder.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/remainderf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/remquo.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/remquof.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/remquol.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/rint.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/rintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/round.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/roundf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/roundl.c
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/include/fenv.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/include/float.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/src/math/__invtrigl.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/src/internal/libm.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/include/math.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/include/complex.h
+LIBMUSL_MATH_HDRS-y += $(LIBMUSL)/include/endian.h
+
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__cos.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__cosdf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__cosl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__expo2.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__expo2f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__fpclassify.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__fpclassifyf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__fpclassifyl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__invtrigl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__polevll.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__rem_pio2.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__rem_pio2_large.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__rem_pio2f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__rem_pio2l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__signbit.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__signbitf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__signbitl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__sin.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__sindf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__sinl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__tan.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__tandf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/__tanl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/acos.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/acosf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/acosh.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/acoshf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/acoshl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/asin.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/asinf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/asinh.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/asinhf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/asinhl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atan.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atan2.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atan2f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atanf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atanh.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atanhf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atanhl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/cbrt.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/cbrtf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/cbrtl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ceil.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ceilf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/copysign.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/copysignf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/copysignl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/cos.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/cosf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/cosh.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/coshf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/coshl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/cosl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/erf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/erff.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/erfl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/exp.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/exp10.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/exp10f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/exp10l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/exp2.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/exp2f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/expf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/expm1.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/expm1f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fdim.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fdimf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fdiml.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/finite.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/finitef.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/floor.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/floorf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fma.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmaf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmal.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmax.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmaxf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmaxl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmin.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fminf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fminl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmod.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmodf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/frexp.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/frexpf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/frexpl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/hypot.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/hypotf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/hypotl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/scalb.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/scalbf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/scalbln.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/scalblnf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/scalblnl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/scalbn.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/scalbnf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/scalbnl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/signgam.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/significand.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/significandf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sin.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sincos.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sincosf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sincosl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sinf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sinh.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sinhf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sinhl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sinl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/tan.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/tanf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/tanh.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/tanhf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/tanhl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/tanl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/tgamma.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/tgammaf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/tgammal.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/trunc.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/truncf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ilogb.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ilogbf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ilogbl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/j0.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/j0f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/j1.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/j1f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/jn.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/jnf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ldexp.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ldexpf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ldexpl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lgamma.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lgamma_r.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lgammaf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lgammaf_r.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lgammal.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/llround.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/llroundf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/llroundl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log10.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log10f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log1p.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log1pf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log2.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log2f.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/logb.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/logbf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/logbl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/logf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lround.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lroundf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lroundl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/modf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/modff.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/modfl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nan.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nanf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nanl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nearbyint.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nearbyintf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nearbyintl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nextafter.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nextafterf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nextafterl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nexttoward.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nexttowardf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/nexttowardl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/pow.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/remainder.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/remainderf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/remquo.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/remquof.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/remquol.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/rint.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/rintf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/round.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/roundf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/roundl.c
 
 ifeq (x86_32,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/__invtrigl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/acos.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/acosf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/acosl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/asin.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/asinf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/asinl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/atan.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/atan2.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/atan2f.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/atan2l.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/atanf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/atanl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/ceil.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/ceilf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/ceill.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/exp.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/exp2.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/exp2f.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/exp2l.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/expf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/expl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/expm1.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/expm1f.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/expm1l.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/fabs.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/fabsf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/fabsl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/floor.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/floorf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/floorl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/fmod.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/fmodf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/fmodl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/hypot.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/hypotf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/ldexp.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/ldexpf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/ldexpl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/llrint.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/llrintf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/llrintl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log10.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log10f.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log10l.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log1p.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log1pf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log1pl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log2.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log2f.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/log2l.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/logf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/logl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/lrint.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/lrintf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/lrintl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/remainder.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/remainderf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/remainderl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/remquo.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/remquof.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/remquol.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/rint.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/rintf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/rintl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/scalbln.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/scalblnf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/scalblnl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/scalbn.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/scalbnf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/scalbnl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/sqrt.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/sqrtf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/sqrtl.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/trunc.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/truncf.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/i386/truncl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/__invtrigl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/acos.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/acosf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/acosl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/asin.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/asinf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/asinl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/atan.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/atan2.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/atan2f.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/atan2l.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/atanf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/atanl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/ceil.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/ceilf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/ceill.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/exp.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/exp2.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/exp2f.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/exp2l.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/expf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/expl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/expm1.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/expm1f.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/expm1l.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/fabs.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/fabsf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/fabsl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/floor.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/floorf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/floorl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/fmod.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/fmodf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/fmodl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/hypot.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/hypotf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/ldexp.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/ldexpf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/ldexpl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/llrint.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/llrintf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/llrintl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log10.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log10f.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log10l.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log1p.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log1pf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log1pl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log2.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log2f.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/log2l.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/logf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/logl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/lrint.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/lrintf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/lrintl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/remainder.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/remainderf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/remainderl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/remquo.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/remquof.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/remquol.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/rint.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/rintf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/rintl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/scalbln.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/scalblnf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/scalblnl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/scalbn.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/scalbnf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/scalbnl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/sqrt.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/sqrtf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/sqrtl.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/trunc.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/truncf.s|i386
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/i386/truncl.s|i386
 else ifeq (x86_64,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/__invtrigl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/acosl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/asinl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/atan2l.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/atanl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/ceill.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/exp2l.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/expl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/expm1l.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/fabs.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/fabsf.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/fabsl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/floorl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/fmodl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/llrint.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/llrintf.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/llrintl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/log10l.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/log1pl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/log2l.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/logl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/lrint.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/lrintf.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/lrintl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/remainderl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/rintl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/sqrt.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/sqrtf.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/sqrtl.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x86_64/truncl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/__invtrigl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/acosl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/asinl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/atan2l.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/atanl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/ceill.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/exp2l.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/expl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/expm1l.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/fabs.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/fabsf.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/fabsl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/floorl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/fmodl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/llrint.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/llrintf.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/llrintl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/log10l.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/log1pl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/log2l.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/logl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/lrint.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/lrintf.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/lrintl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/remainderl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/rintl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/sqrt.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/sqrtf.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/sqrtl.s|x86_64
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x86_64/truncl.s|x86_64
 else ifeq (arm,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/acosl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/asinl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atan2l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atanl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/expm1l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/exp2l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/expl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fabsl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/floorl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ceill.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/truncl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmodl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lrintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/llrint.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/llrintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/llrintl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log10l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log1pl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log2l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/logl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lrint.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lrintl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/remainderl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/rintl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sqrtl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/arm/fabs.c|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/arm/fabsf.c|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/arm/sqrt.c|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/arm/sqrtf.c|arm
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/acosl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/asinl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atan2l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atanl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/expm1l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/exp2l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/expl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fabsl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/floorl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ceill.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/truncl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmodl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lrintf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/llrint.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/llrintf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/llrintl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log10l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log1pl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log2l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/logl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lrint.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lrintl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/remainderl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/rintl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sqrtl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/arm/fabs.c|arm
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/arm/fabsf.c|arm
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/arm/sqrt.c|arm
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/arm/sqrtf.c|arm
 else
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/acosl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/asinl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atan2l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/atanl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/expm1l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/exp2l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/expl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fabsl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/floorl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/ceill.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/truncl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fmodl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lrintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/llrint.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/llrintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/llrintl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log10l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log1pl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/log2l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/logl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lrint.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/lrintl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/remainderl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/rintl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sqrtl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fabs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/fabsf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sqrt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/sqrtf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/acosl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/asinl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atan2l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/atanl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/expm1l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/exp2l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/expl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fabsl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/floorl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/ceill.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/truncl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fmodl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lrintf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/llrint.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/llrintf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/llrintl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log10l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log1pl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/log2l.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/logl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lrint.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/lrintl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/remainderl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/rintl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sqrtl.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fabs.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/fabsf.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sqrt.c
+LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/sqrtf.c
 endif
 
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/ceil.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/ceilf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/fabs.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/fabsf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/floor.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/floorf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/fma.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/fmaf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/fmax.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/fmaxf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/fmin.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/fminf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/llrint.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/llrintf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/llround.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/llroundf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/lrint.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/lrintf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/lround.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/lroundf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/nearbyint.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/nearbyintf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/rint.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/rintf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/round.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/roundf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/sqrt.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/sqrtf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/trunc.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/aarch64/truncf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/ceil.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/ceilf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fabs.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fabsf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/floor.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/floorf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fma.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fmaf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fmax.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fmaxf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fmin.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fminf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/lrint.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/lrintf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/lround.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/lroundf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/round.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/roundf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/sqrt.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/sqrtf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/trunc.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/powerpc64/truncf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/ceil.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/ceilf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/ceill.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/fabs.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/fabsf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/fabsl.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/floor.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/floorf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/floorl.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/nearbyint.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/nearbyintf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/nearbyintl.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/rint.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/rintf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/rintl.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/round.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/roundf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/roundl.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/sqrt.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/sqrtf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/sqrtl.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/trunc.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/truncf.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/s390x/truncl.c
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/__invtrigl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/acosl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/asinl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/atan2l.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/atanl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/ceill.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/exp2l.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/expl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/expm1l.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/fabs.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/fabsf.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/fabsl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/floorl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/fmodl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/llrint.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/llrintf.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/llrintl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/log10l.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/log1pl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/log2l.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/logl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/lrint.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/lrintf.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/lrintl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/remainderl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/rintl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/sqrt.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/sqrtf.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/sqrtl.s|x32
-# LIBMUSL_SRCS-y += $(LIBMUSL)/src/math/x32/truncl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/ceil.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/ceilf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/fabs.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/fabsf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/floor.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/floorf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/fma.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/fmaf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/fmax.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/fmaxf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/fmin.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/fminf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/llrint.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/llrintf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/llround.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/llroundf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/lrint.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/lrintf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/lround.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/lroundf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/nearbyint.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/nearbyintf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/rint.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/rintf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/round.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/roundf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/sqrt.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/sqrtf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/trunc.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/aarch64/truncf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/ceil.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/ceilf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fabs.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fabsf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/floor.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/floorf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fma.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fmaf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fmax.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fmaxf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fmin.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/fminf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/lrint.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/lrintf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/lround.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/lroundf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/round.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/roundf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/sqrt.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/sqrtf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/trunc.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/powerpc64/truncf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/ceil.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/ceilf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/ceill.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/fabs.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/fabsf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/fabsl.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/floor.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/floorf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/floorl.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/nearbyint.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/nearbyintf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/nearbyintl.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/rint.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/rintf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/rintl.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/round.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/roundf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/roundl.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/sqrt.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/sqrtf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/sqrtl.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/trunc.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/truncf.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/s390x/truncl.c
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/__invtrigl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/acosl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/asinl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/atan2l.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/atanl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/ceill.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/exp2l.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/expl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/expm1l.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/fabs.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/fabsf.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/fabsl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/floorl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/fmodl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/llrint.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/llrintf.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/llrintl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/log10l.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/log1pl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/log2l.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/logl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/lrint.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/lrintf.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/lrintl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/remainderl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/rintl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/sqrt.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/sqrtf.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/sqrtl.s|x32
+# LIBMUSL_MATH_SRCS-y += $(LIBMUSL)/src/math/x32/truncl.s|x32
+
+# CINCLUDES-y += -D_GNU_SOURCE
+
+$(eval $(call _libmusl_import_lib,math,$(LIBMUSL_MATH_HDRS-y),$(LIBMUSL_MATH_SRCS-y)))
diff --git a/Makefile.uk.musl.misc b/Makefile.uk.musl.misc
index da54093..d62c1ab 100644
--- a/Makefile.uk.musl.misc
+++ b/Makefile.uk.musl.misc
@@ -1,38 +1,79 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/a64l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/basename.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/dirname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/ffs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/ffsl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/ffsll.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/fmtmsg.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/forkpty.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/get_current_dir_name.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getauxval.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getdomainname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/gethostid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getopt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getopt_long.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getpriority.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getresgid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getresuid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getrlimit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getrusage.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/getsubopt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/initgroups.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/ioctl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/issetugid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/lockf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/login_tty.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/mntent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/nftw.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/openpty.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/ptsname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/pty.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/realpath.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/setdomainname.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/setpriority.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/setrlimit.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/syscall.c|misc
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/syslog.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/uname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/misc/wordexp.c
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/dirent.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/fmtmsg.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/ftw.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/getopt.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/grp.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/libgen.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/src/internal/locale_impl.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/mntent.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/pthread.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/pty.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/strings.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/sys/auxv.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/sys/ioctl.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/syslog.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/sys/resource.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/sys/socket.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/sys/utsname.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/sys/wait.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/time.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/unistd.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/utmp.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/wchar.h
+LIBMUSL_MISC_HDRS-y += $(LIBMUSL)/include/wordexp.h
+
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/a64l.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/basename.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/dirname.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/ffs.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/ffsl.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/ffsll.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/fmtmsg.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/forkpty.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/get_current_dir_name.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getauxval.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getdomainname.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/gethostid.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getopt.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getopt_long.c
+#LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getpriority.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getresgid.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getresuid.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getrlimit.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getrusage.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/getsubopt.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/initgroups.c
+#LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/ioctl.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/issetugid.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/lockf.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/login_tty.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/mntent.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/nftw.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/openpty.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/ptsname.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/pty.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/realpath.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/setdomainname.c
+#LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/setpriority.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/setrlimit.c
+#LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/syscall.c|misc
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/syslog.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/uname.c
+LIBMUSL_MISC_SRCS-y += $(LIBMUSL)/src/misc/wordexp.c
+
+$(eval $(call _libmusl_import_lib,misc,$(LIBMUSL_MISC_HDRS-y),$(LIBMUSL_MISC_SRCS-y)))
diff --git a/Makefile.uk.musl.mman b/Makefile.uk.musl.mman
index c989771..c64bc9d 100644
--- a/Makefile.uk.musl.mman
+++ b/Makefile.uk.musl.mman
@@ -1,13 +1,36 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/madvise.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/mincore.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/mlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/mlockall.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/mmap.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/mprotect.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/mremap.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/msync.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/munlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/munlockall.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/munmap.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/posix_madvise.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mman/shm_open.c
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/pthread.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/sys/syscall.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/sys/mman.h
+LIBMUSL_MMAN_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+# ifeq (arm,$(ARCH))
+# LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/arch/arm/syscall_arch.h
+# else ifeq (x86_32,$(ARCH))
+# LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/arch/i386/syscall_arch.h
+# else ifeq (x86_64,$(ARCH))
+# LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/arch/x86_64/syscall_arch.h
+# endif
+
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/madvise.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/mincore.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/mlock.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/mlockall.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/mmap.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/mprotect.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/mremap.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/msync.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/munlock.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/munlockall.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/munmap.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/posix_madvise.c
+LIBMUSL_MMAN_SRCS-y += $(LIBMUSL)/src/mman/shm_open.c
+
+$(eval $(call _libmusl_import_lib,mman,$(LIBMUSL_MMAN_HDRS-y),$(LIBMUSL_MMAN_SRCS-y)))
diff --git a/Makefile.uk.musl.mq b/Makefile.uk.musl.mq
index 24da79c..48ec5f8 100644
--- a/Makefile.uk.musl.mq
+++ b/Makefile.uk.musl.mq
@@ -1,10 +1,22 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_close.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_getattr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_notify.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_open.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_receive.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_send.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_setattr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_timedreceive.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_timedsend.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/mq/mq_unlink.c
+LIBMUSL_MQ_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_MQ_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_MQ_HDRS-y += $(LIBMUSL)/include/mqueue.h
+LIBMUSL_MQ_HDRS-y += $(LIBMUSL)/include/pthread.h
+LIBMUSL_MQ_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_MQ_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_MQ_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_MQ_HDRS-y += $(LIBMUSL)/include/sys/socket.h
+LIBMUSL_MQ_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_close.c
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_getattr.c
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_notify.c
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_open.c
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_receive.c
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_send.c
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_setattr.c
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_timedreceive.c
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_timedsend.c
+LIBMUSL_MQ_SRCS-y += $(LIBMUSL)/src/mq/mq_unlink.c
+
+$(eval $(call _libmusl_import_lib,mq,$(LIBMUSL_MQ_HDRS-y),$(LIBMUSL_MQ_SRCS-y)))
diff --git a/Makefile.uk.musl.multibyte b/Makefile.uk.musl.multibyte
index fed5400..b4418eb 100644
--- a/Makefile.uk.musl.multibyte
+++ b/Makefile.uk.musl.multibyte
@@ -1,20 +1,31 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/btowc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/c16rtomb.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/c32rtomb.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/internal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mblen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mbrlen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mbrtoc16.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mbrtoc32.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mbrtowc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mbsinit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mbsnrtowcs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mbsrtowcs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mbstowcs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/mbtowc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/wcrtomb.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/wcsnrtombs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/wcsrtombs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/wcstombs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/wctob.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/multibyte/wctomb.c
+LIBMUSL_MULTIBYTE_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_MULTIBYTE_HDRS-y += $(LIBMUSL)/src/multibyte/internal.h
+LIBMUSL_MULTIBYTE_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_MULTIBYTE_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_MULTIBYTE_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_MULTIBYTE_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_MULTIBYTE_HDRS-y += $(LIBMUSL)/include/uchar.h
+LIBMUSL_MULTIBYTE_HDRS-y += $(LIBMUSL)/include/wchar.h
+
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/btowc.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/c16rtomb.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/c32rtomb.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/internal.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mblen.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mbrlen.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mbrtoc16.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mbrtoc32.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mbrtowc.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mbsinit.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mbsnrtowcs.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mbsrtowcs.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mbstowcs.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/mbtowc.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/wcrtomb.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/wcsnrtombs.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/wcsrtombs.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/wcstombs.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/wctob.c
+LIBMUSL_MULTIBYTE_SRCS-y += $(LIBMUSL)/src/multibyte/wctomb.c
+
+$(eval $(call _libmusl_import_lib,multibyte,$(LIBMUSL_MULTIBYTE_HDRS-y),$(LIBMUSL_MULTIBYTE_SRCS-y)))
diff --git a/Makefile.uk.musl.network b/Makefile.uk.musl.network
index b0879a3..b934863 100644
--- a/Makefile.uk.musl.network
+++ b/Makefile.uk.musl.network
@@ -1,77 +1,120 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/accept.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/accept4.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/bind.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/connect.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/dn_comp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/dn_expand.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/dn_skipname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/dns_parse.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/ent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/ether.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/freeaddrinfo.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/gai_strerror.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getaddrinfo.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/gethostbyaddr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/gethostbyaddr_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/gethostbyname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/gethostbyname2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/gethostbyname2_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/gethostbyname_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getifaddrs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getnameinfo.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getpeername.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getservbyname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getservbyname_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getservbyport.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getservbyport_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getsockname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/getsockopt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/h_errno.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/herror.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/hstrerror.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/htonl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/htons.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/if_freenameindex.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/if_indextoname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/if_nameindex.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/if_nametoindex.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/in6addr_any.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/in6addr_loopback.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/inet_addr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/inet_aton.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/inet_legacy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/inet_ntoa.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/inet_ntop.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/inet_pton.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/listen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/lookup_ipliteral.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/lookup_name.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/lookup_serv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/netlink.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/netname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/ns_parse.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/ntohl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/ntohs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/proto.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/recv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/recvfrom.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/recvmmsg.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/recvmsg.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/res_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/res_mkquery.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/res_msend.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/res_query.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/res_querydomain.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/res_send.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/res_state.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/resolvconf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/send.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/sendmmsg.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/sendmsg.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/sendto.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/serv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/setsockopt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/shutdown.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/sockatmark.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/socket.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/network/socketpair.c
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/arpa/inet.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/arpa/nameser.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/byteswap.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/ifaddrs.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/inttypes.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/src/internal/locale_impl.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/src/network/lookup.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/netdb.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/net/ethernet.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/net/if.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/net/if_arp.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/netinet/ether.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/netinet/if_ether.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/netinet/in.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/netinet/tcp.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/src/network/netlink.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/poll.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/pthread.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/resolv.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/src/internal/stdio_impl.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/sys/ioctl.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/sys/un.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/time.h
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+ifneq ($(CONFIG_LIBPOSIX_SOCKET),y)
+LIBMUSL_NETWORK_HDRS-y += $(LIBMUSL)/include/sys/socket.h
+
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/socket.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/accept.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/accept4.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/bind.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/shutdown.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getpeername.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getsockname.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getsockopt.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/setsockopt.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/connect.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/listen.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/recv.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/recvfrom.c
+# LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/recvmmsg.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/recvmsg.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/send.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/sendmsg.c
+# LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/sendmmsg.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/sendto.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/socketpair.c
+endif
+
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/dn_comp.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/dn_expand.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/dn_skipname.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/dns_parse.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/ent.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/ether.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/freeaddrinfo.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/gai_strerror.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getaddrinfo.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/gethostbyaddr.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/gethostbyaddr_r.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/gethostbyname.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/gethostbyname2.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/gethostbyname2_r.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/gethostbyname_r.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getifaddrs.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getnameinfo.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getservbyname.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getservbyname_r.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getservbyport.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/getservbyport_r.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/h_errno.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/herror.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/hstrerror.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/htonl.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/htons.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/if_freenameindex.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/if_indextoname.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/if_nameindex.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/if_nametoindex.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/in6addr_any.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/in6addr_loopback.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/inet_addr.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/inet_aton.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/inet_legacy.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/inet_ntoa.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/inet_ntop.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/inet_pton.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/lookup_ipliteral.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/lookup_name.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/lookup_serv.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/netlink.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/netname.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/ns_parse.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/ntohl.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/ntohs.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/proto.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/res_init.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/res_mkquery.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/res_msend.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/res_query.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/res_querydomain.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/res_send.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/res_state.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/resolvconf.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/serv.c
+LIBMUSL_NETWORK_SRCS-y += $(LIBMUSL)/src/network/sockatmark.c
+
+$(eval $(call _libmusl_import_lib,network,$(LIBMUSL_NETWORK_HDRS-y),$(LIBMUSL_NETWORK_SRCS-y)))
diff --git a/Makefile.uk.musl.passwd b/Makefile.uk.musl.passwd
index a08cd6f..dbad5fd 100644
--- a/Makefile.uk.musl.passwd
+++ b/Makefile.uk.musl.passwd
@@ -1,20 +1,40 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/fgetgrent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/fgetpwent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/fgetspent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getgr_a.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getgr_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getgrent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getgrent_a.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getgrouplist.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getpw_a.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getpw_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getpwent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getpwent_a.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getspent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getspnam.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/getspnam_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/lckpwdf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/nscd_query.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/putgrent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/putpwent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/passwd/putspent.c
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/byteswap.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/grp.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/src/passwd/nscd.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/pthread.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/pwd.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/src/passwd/pwf.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/shadow.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/sys/socket.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_PASSWD_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/fgetgrent.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/fgetpwent.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/fgetspent.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgr_a.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgr_r.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgrent.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgrent_a.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getgrouplist.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getpw_a.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getpw_r.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getpwent.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getpwent_a.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getspent.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getspnam.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/getspnam_r.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/lckpwdf.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/nscd_query.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/putgrent.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/putpwent.c
+LIBMUSL_PASSWD_SRCS-y += $(LIBMUSL)/src/passwd/putspent.c
+
+$(eval $(call _libmusl_import_lib,passwd,$(LIBMUSL_PASSWD_HDRS-y),$(LIBMUSL_PASSWD_SRCS-y)))
diff --git a/Makefile.uk.musl.prng b/Makefile.uk.musl.prng
index b4b786c..cfcccc2 100644
--- a/Makefile.uk.musl.prng
+++ b/Makefile.uk.musl.prng
@@ -1,11 +1,19 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/__rand48_step.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/__seed48.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/drand48.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/lcong48.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/lrand48.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/mrand48.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/rand.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/rand_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/random.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/seed48.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/prng/srand48.c
+LIBMUSL_PRNG_HDRS-y += $(LIBMUSL)/include/inttypes.h
+LIBMUSL_PRNG_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_PRNG_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_PRNG_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_PRNG_HDRS-y += $(LIBMUSL)/include/string.h
+
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/__rand48_step.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/__seed48.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/drand48.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/lcong48.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/lrand48.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/mrand48.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/rand.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/rand_r.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/random.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/seed48.c
+LIBMUSL_PRNG_SRCS-y += $(LIBMUSL)/src/prng/srand48.c
+
+$(eval $(call _libmusl_import_lib,prng,$(LIBMUSL_PRNG_HDRS-y),$(LIBMUSL_PRNG_SRCS-y)))
diff --git a/Makefile.uk.musl.process b/Makefile.uk.musl.process
index 1bc77e7..71b4042 100644
--- a/Makefile.uk.musl.process
+++ b/Makefile.uk.musl.process
@@ -1,42 +1,60 @@
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/execl.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/execle.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/execlp.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/execv.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/execve.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/execvp.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/fexecve.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/fork.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawn.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_addclose.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_adddup2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_addopen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_getflags.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_getpgroup.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_getsigdefault.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_getsigmask.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_sched.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_setflags.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_setpgroup.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_setsigdefault.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_setsigmask.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/posix_spawnp.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/system.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/wait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/waitid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/waitpid.c
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/src/process/fdop.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/sched.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/spawn.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/sys/wait.h
+LIBMUSL_PROCESS_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/execl.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/execle.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/execlp.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/execv.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/execve.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/execvp.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/fexecve.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/fork.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawn.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_addclose.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_adddup2.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_addopen.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_destroy.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawn_file_actions_init.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_destroy.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_getflags.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_getpgroup.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_getsigdefault.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_getsigmask.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_init.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_sched.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_setflags.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_setpgroup.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_setsigdefault.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnattr_setsigmask.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/posix_spawnp.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/system.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/wait.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/waitid.c
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/waitpid.c
 
 ifeq (x86_32,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/i386/vfork.s|i386
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/i386/vfork.s|i386
 else ifeq (x86_64,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/x86_64/vfork.s|x86_64
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/x86_64/vfork.s|x86_64
 else
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/vfork.c
+LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/vfork.c
 endif
 
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/s390x/vfork.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/sh/vfork.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/process/x32/vfork.s
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/s390x/vfork.s
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/sh/vfork.s
+#LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/x32/vfork.s
+
+$(eval $(call _libmusl_import_lib,process,$(LIBMUSL_PROCESS_HDRS-y),$(LIBMUSL_PROCESS_SRCS-y)))
diff --git a/Makefile.uk.musl.regex b/Makefile.uk.musl.regex
index e564903..edd7df1 100644
--- a/Makefile.uk.musl.regex
+++ b/Makefile.uk.musl.regex
@@ -1,6 +1,28 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/regex/fnmatch.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/regex/glob.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/regex/regcomp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/regex/regerror.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/regex/regexec.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/regex/tre-mem.c
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/assert.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/dirent.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/fnmatch.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/glob.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/src/internal/locale_impl.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/regex.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/src/regex/tre.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/wchar.h
+LIBMUSL_REGEX_HDRS-y += $(LIBMUSL)/include/wctype.h
+
+LIBMUSL_REGEX_SRCS-y += $(LIBMUSL)/src/regex/fnmatch.c
+LIBMUSL_REGEX_SRCS-y += $(LIBMUSL)/src/regex/glob.c
+LIBMUSL_REGEX_SRCS-y += $(LIBMUSL)/src/regex/regcomp.c
+LIBMUSL_REGEX_SRCS-y += $(LIBMUSL)/src/regex/regerror.c
+LIBMUSL_REGEX_SRCS-y += $(LIBMUSL)/src/regex/regexec.c
+LIBMUSL_REGEX_SRCS-y += $(LIBMUSL)/src/regex/tre-mem.c
+
+$(eval $(call _libmusl_import_lib,regex,$(LIBMUSL_REGEX_HDRS-y),$(LIBMUSL_REGEX_SRCS-y)))
diff --git a/Makefile.uk.musl.sched b/Makefile.uk.musl.sched
index efa511e..4fe268d 100644
--- a/Makefile.uk.musl.sched
+++ b/Makefile.uk.musl.sched
@@ -1,10 +1,19 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/affinity.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/sched_cpucount.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/sched_get_priority_max.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/sched_getcpu.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/sched_getparam.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/sched_getscheduler.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/sched_rr_get_interval.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/sched_setparam.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/sched_setscheduler.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/sched/sched_yield.c
+LIBMUSL_SCHED_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_SCHED_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_SCHED_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_SCHED_HDRS-y += $(LIBMUSL)/include/sched.h
+LIBMUSL_SCHED_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_SCHED_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/affinity.c
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/sched_cpucount.c
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/sched_get_priority_max.c
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/sched_getcpu.c
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/sched_getparam.c
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/sched_getscheduler.c
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/sched_rr_get_interval.c
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/sched_setparam.c
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/sched_setscheduler.c
+LIBMUSL_SCHED_SRCS-y += $(LIBMUSL)/src/sched/sched_yield.c
+
+$(eval $(call _libmusl_import_lib,sched,$(LIBMUSL_SCHED_HDRS-y),$(LIBMUSL_SCHED_SRCS-y)))
diff --git a/Makefile.uk.musl.search b/Makefile.uk.musl.search
index 9b34f3b..d611b93 100644
--- a/Makefile.uk.musl.search
+++ b/Makefile.uk.musl.search
@@ -1,5 +1,12 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/search/hsearch.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/search/insque.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/search/lsearch.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/search/tdestroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/search/tsearch_avl.c
+LIBMUSL_SEARCH_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_SEARCH_HDRS-y += $(LIBMUSL)/include/search.h
+LIBMUSL_SEARCH_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_SEARCH_HDRS-y += $(LIBMUSL)/include/string.h
+
+LIBMUSL_SEARCH_SRCS-y += $(LIBMUSL)/src/search/hsearch.c
+LIBMUSL_SEARCH_SRCS-y += $(LIBMUSL)/src/search/insque.c
+LIBMUSL_SEARCH_SRCS-y += $(LIBMUSL)/src/search/lsearch.c
+LIBMUSL_SEARCH_SRCS-y += $(LIBMUSL)/src/search/tdestroy.c
+LIBMUSL_SEARCH_SRCS-y += $(LIBMUSL)/src/search/tsearch_avl.c
+
+$(eval $(call _libmusl_import_lib,search,$(LIBMUSL_SEARCH_HDRS-y),$(LIBMUSL_SEARCH_SRCS-y)))
diff --git a/Makefile.uk.musl.select b/Makefile.uk.musl.select
index 21c1a9a..3ac5a3f 100644
--- a/Makefile.uk.musl.select
+++ b/Makefile.uk.musl.select
@@ -1,3 +1,14 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/select/poll.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/select/pselect.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/select/select.c
+LIBMUSL_SELECT_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_SELECT_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_SELECT_HDRS-y += $(LIBMUSL)/include/poll.h
+LIBMUSL_SELECT_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_SELECT_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_SELECT_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_SELECT_HDRS-y += $(LIBMUSL)/include/sys/select.h
+LIBMUSL_SELECT_HDRS-y += $(LIBMUSL)/include/time.h
+
+LIBMUSL_SELECT_SRCS-y += $(LIBMUSL)/src/select/poll.c
+LIBMUSL_SELECT_SRCS-y += $(LIBMUSL)/src/select/pselect.c
+LIBMUSL_SELECT_SRCS-y += $(LIBMUSL)/src/select/select.c
+
+$(eval $(call _libmusl_import_lib,select,$(LIBMUSL_SELECT_HDRS-y),$(LIBMUSL_SELECT_SRCS-y)))
diff --git a/Makefile.uk.musl.setjmp b/Makefile.uk.musl.setjmp
index c4bf289..9a9b267 100644
--- a/Makefile.uk.musl.setjmp
+++ b/Makefile.uk.musl.setjmp
@@ -1,36 +1,38 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/setjmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/longjmp.c
+LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/setjmp.c
+LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/longjmp.c
 
 ifeq (arm,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/arm/longjmp.s|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/arm/setjmp.s|arm
+LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/arm/longjmp.s|arm
+LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/arm/setjmp.s|arm
 else ifeq (x86_32,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/i386/longjmp.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/i386/setjmp.s|i386
+LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/i386/longjmp.s|i386
+LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/i386/setjmp.s|i386
 else ifeq (x86_64,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/x86_64/longjmp.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/x86_64/setjmp.s|x86_64
+LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/x86_64/longjmp.s|x86_64
+LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/x86_64/setjmp.s|x86_64
 endif
 
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/aarch64/longjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/aarch64/setjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/microblaze/longjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/microblaze/setjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/mips/longjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/mips/setjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/mips64/longjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/mips64/setjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/mipsn32/longjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/mipsn32/setjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/or1k/longjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/or1k/setjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/powerpc/longjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/powerpc/setjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/powerpc64/longjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/powerpc64/setjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/s390x/longjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/s390x/setjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/sh/longjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/sh/setjmp.S
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/x32/longjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/setjmp/x32/setjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/aarch64/longjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/aarch64/setjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/microblaze/longjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/microblaze/setjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/mips/longjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/mips/setjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/mips64/longjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/mips64/setjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/mipsn32/longjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/mipsn32/setjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/or1k/longjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/or1k/setjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/powerpc/longjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/powerpc/setjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/powerpc64/longjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/powerpc64/setjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/s390x/longjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/s390x/setjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/sh/longjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/sh/setjmp.S
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/x32/longjmp.s
+#LIBMUSL_SETJMP_SRCS-y += $(LIBMUSL)/src/setjmp/x32/setjmp.s
+
+$(eval $(call _libmusl_import_lib,setjmp,$(LIBMUSL_SETJMP_HDRS-y),$(LIBMUSL_SETJMP_SRCS-y)))
diff --git a/Makefile.uk.musl.signal b/Makefile.uk.musl.signal
index 24969ef..a7af11f 100644
--- a/Makefile.uk.musl.signal
+++ b/Makefile.uk.musl.signal
@@ -1,72 +1,97 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/block.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/getitimer.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/kill.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/killpg.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/psiginfo.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/psignal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/raise.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/setitimer.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigaction.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigaddset.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigaltstack.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigandset.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigdelset.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigemptyset.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigfillset.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sighold.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigignore.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/siginterrupt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigisemptyset.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigismember.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/siglongjmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/signal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigorset.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigpause.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigpending.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigprocmask.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigqueue.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigrelse.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigrtmax.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigrtmin.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigset.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigsetjmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigsetjmp_tail.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigsuspend.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigtimedwait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigwait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sigwaitinfo.c
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/src/internal/ksigaction.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/setjmp.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/sys/syscall.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/sys/time.h
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+ifeq (arm,$(ARCH))
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/arch/arm/bits/signal.h
+else ifeq (x86_32,$(ARCH))
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/arch/i386/bits/signal.h
+else ifeq (x86_64,$(ARCH))
+LIBMUSL_SIGNAL_HDRS-y += $(LIBMUSL)/arch/x86_64/bits/signal.h
+endif
+
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/block.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/getitimer.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/kill.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/killpg.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/psiginfo.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/psignal.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/raise.c
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/setitimer.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigaction.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigaddset.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigaltstack.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigandset.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigdelset.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigemptyset.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigfillset.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sighold.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigignore.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/siginterrupt.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigisemptyset.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigismember.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/siglongjmp.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/signal.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigorset.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigpause.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigpending.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigprocmask.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigqueue.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigrelse.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigrtmax.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigrtmin.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigset.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigsetjmp.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigsetjmp_tail.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigsuspend.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigtimedwait.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigwait.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sigwaitinfo.c
 
 ifeq (x86_32,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/i386/restore.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/i386/sigsetjmp.s|i386
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/i386/restore.s|i386
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/i386/sigsetjmp.s|i386
 else ifeq (x86_64,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/x86_64/restore.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/x86_64/sigsetjmp.s|x86_64
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/x86_64/restore.s|x86_64
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/x86_64/sigsetjmp.s|x86_64
 else ifeq (arm,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/arm/restore.s|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/arm/sigsetjmp.s|arm
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/arm/restore.s|arm
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/arm/sigsetjmp.s|arm
 else
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/restore.c
+LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/restore.c
 endif
 
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/aarch64/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/aarch64/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/microblaze/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/microblaze/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/mips/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/mips/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/mips64/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/mips64/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/mipsn32/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/mipsn32/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/or1k/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/powerpc/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/powerpc/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/powerpc64/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/powerpc64/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/s390x/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/s390x/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sh/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/sh/sigsetjmp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/x32/restore.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/signal/x32/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/aarch64/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/aarch64/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/microblaze/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/microblaze/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/mips/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/mips/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/mips64/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/mips64/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/mipsn32/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/mipsn32/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/or1k/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/powerpc/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/powerpc/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/powerpc64/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/powerpc64/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/s390x/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/s390x/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sh/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/sh/sigsetjmp.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/x32/restore.s
+#LIBMUSL_SIGNAL_SRCS-y += $(LIBMUSL)/src/signal/x32/sigsetjmp.s
+
+$(eval $(call _libmusl_import_lib,signal,$(LIBMUSL_SIGNAL_HDRS-y),$(LIBMUSL_SIGNAL_SRCS-y)))
diff --git a/Makefile.uk.musl.stat b/Makefile.uk.musl.stat
index c754192..5ecc50b 100644
--- a/Makefile.uk.musl.stat
+++ b/Makefile.uk.musl.stat
@@ -1,20 +1,31 @@
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/__xstat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/chmod.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/fchmod.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/fchmodat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/fstat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/fstatat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/futimens.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/futimesat.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/lchmod.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/lstat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/mkdir.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/mkdirat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/mkfifo.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/mkfifoat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/mknod.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/mknodat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/stat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/statvfs.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/umask.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stat/utimensat.c
+LIBMUSL_STAT_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_STAT_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_STAT_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_STAT_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_STAT_HDRS-y += $(LIBMUSL)/include/sys/statfs.h
+LIBMUSL_STAT_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_STAT_HDRS-y += $(LIBMUSL)/include/sys/statvfs.h
+LIBMUSL_STAT_HDRS-y += $(LIBMUSL)/include/sys/time.h
+
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/__xstat.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/chmod.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/fchmod.c
+LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/fchmodat.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/fstat.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/fstatat.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/futimens.c
+LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/futimesat.c
+LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/lchmod.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/lstat.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/mkdir.c
+LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/mkdirat.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/mkfifo.c
+LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/mkfifoat.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/mknod.c
+LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/mknodat.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/stat.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/statvfs.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/umask.c
+#LIBMUSL_STAT_SRCS-y += $(LIBMUSL)/src/stat/utimensat.c
+
+$(eval $(call _libmusl_import_lib,stat,$(LIBMUSL_STAT_HDRS-y),$(LIBMUSL_STAT_SRCS-y)))
diff --git a/Makefile.uk.musl.stdio b/Makefile.uk.musl.stdio
index 8a9254e..8e4417e 100644
--- a/Makefile.uk.musl.stdio
+++ b/Makefile.uk.musl.stdio
@@ -1,117 +1,149 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__fclose_ca.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__fdopen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__fmodeflags.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__fopen_rb_ca.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__lockfile.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__overflow.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_close.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_exit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_read.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_seek.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_write.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__stdout_write.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__string_read.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__toread.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__towrite.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/__uflow.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/asprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/clearerr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/dprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/ext.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/ext2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fclose.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/feof.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/ferror.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fflush.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fgetc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fgetln.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fgetpos.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fgets.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fgetwc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fgetws.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fileno.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/flockfile.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fmemopen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fopen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fopencookie.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fputc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fputs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fputwc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fputws.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fread.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/freopen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fseek.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fsetpos.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/ftell.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/ftrylockfile.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/funlockfile.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fwide.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fwprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fwrite.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/fwscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/getc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/getc_unlocked.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/getchar.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/getchar_unlocked.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/getdelim.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/getline.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/gets.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/getw.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/getwc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/getwchar.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/ofl.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/ofl_add.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/open_memstream.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/open_wmemstream.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/pclose.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/perror.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/popen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/printf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/putc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/putc_unlocked.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/putchar.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/putchar_unlocked.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/puts.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/putw.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/putwc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/putwchar.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/remove.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/rename.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/rewind.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/scanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/setbuf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/setbuffer.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/setlinebuf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/setvbuf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/snprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/sprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/sscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/stderr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/stdin.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/stdout.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/swprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/swscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/tempnam.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/tmpfile.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/tmpnam.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/ungetc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/ungetwc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vasprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vdprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vfprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vfscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vfwprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vfwscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vsnprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vsprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vsscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vswprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vswscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vwprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/vwscanf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/wprintf.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdio/wscanf.c
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/float.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/src/internal/floatscan.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/src/internal/intscan.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/inttypes.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/src/internal/locale_impl.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/math.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/src/internal/shgetc.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/spawn.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/stdio_ext.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/src/internal/stdio_impl.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/sys/ioctl.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/sys/uio.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/unistd.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/wchar.h
+LIBMUSL_STDIO_HDRS-y += $(LIBMUSL)/include/wctype.h
+
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__fclose_ca.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__fdopen.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__fmodeflags.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__fopen_rb_ca.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__lockfile.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__overflow.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_close.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_exit.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_read.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_seek.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__stdio_write.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__stdout_write.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__string_read.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__toread.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__towrite.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/__uflow.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/asprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/clearerr.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/dprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/ext.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/ext2.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fclose.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/feof.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/ferror.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fflush.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fgetc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fgetln.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fgetpos.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fgets.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fgetwc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fgetws.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fileno.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/flockfile.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fmemopen.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fopen.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fopencookie.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fputc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fputs.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fputwc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fputws.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fread.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/freopen.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fseek.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fsetpos.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/ftell.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/ftrylockfile.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/funlockfile.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fwide.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fwprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fwrite.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/fwscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/getc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/getc_unlocked.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/getchar.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/getchar_unlocked.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/getdelim.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/getline.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/gets.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/getw.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/getwc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/getwchar.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/ofl.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/ofl_add.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/open_memstream.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/open_wmemstream.c
+#LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/pclose.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/perror.c
+#LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/popen.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/printf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/putc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/putc_unlocked.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/putchar.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/putchar_unlocked.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/puts.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/putw.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/putwc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/putwchar.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/remove.c
+#LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/rename.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/rewind.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/scanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/setbuf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/setbuffer.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/setlinebuf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/setvbuf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/snprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/sprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/sscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/stderr.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/stdin.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/stdout.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/swprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/swscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/tempnam.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/tmpfile.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/tmpnam.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/ungetc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/ungetwc.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vasprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vdprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vfprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vfscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vfwprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vfwscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vsnprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vsprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vsscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vswprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vswscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vwprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/vwscanf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/wprintf.c
+LIBMUSL_STDIO_SRCS-y += $(LIBMUSL)/src/stdio/wscanf.c
+
+$(eval $(call _libmusl_import_lib,stdio,$(LIBMUSL_STDIO_HDRS-y),$(LIBMUSL_STDIO_SRCS-y)))
diff --git a/Makefile.uk.musl.stdlib b/Makefile.uk.musl.stdlib
index 21167f1..9529226 100644
--- a/Makefile.uk.musl.stdlib
+++ b/Makefile.uk.musl.stdlib
@@ -1,21 +1,39 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/abs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/atof.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/atoi.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/atol.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/atoll.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/bsearch.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/div.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/ecvt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/fcvt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/gcvt.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/imaxabs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/imaxdiv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/labs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/ldiv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/llabs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/lldiv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/qsort.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/strtod.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/strtol.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/wcstod.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/stdlib/wcstol.c
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/src/internal/floatscan.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/src/internal/intscan.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/include/inttypes.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/src/internal/shgetc.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/src/internal/stdio_impl.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/include/wchar.h
+LIBMUSL_STDLIB_HDRS-y += $(LIBMUSL)/include/wctype.h
+
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/abs.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/atof.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/atoi.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/atol.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/atoll.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/bsearch.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/div.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/ecvt.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/fcvt.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/gcvt.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/imaxabs.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/imaxdiv.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/labs.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/ldiv.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/llabs.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/lldiv.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/qsort.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/strtod.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/strtol.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/wcstod.c
+LIBMUSL_STDLIB_SRCS-y += $(LIBMUSL)/src/stdlib/wcstol.c
+
+$(eval $(call _libmusl_import_lib,stdlib,$(LIBMUSL_STDLIB_HDRS-y),$(LIBMUSL_STDLIB_SRCS-y)))
diff --git a/Makefile.uk.musl.string b/Makefile.uk.musl.string
index 63794f5..45316b4 100644
--- a/Makefile.uk.musl.string
+++ b/Makefile.uk.musl.string
@@ -1,91 +1,108 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/bcmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/bcopy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/bzero.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/index.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memccpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memchr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memcmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memmem.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/mempcpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memrchr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/rindex.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/stpcpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/stpncpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strcasecmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strcasestr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strcat.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strchr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strchrnul.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strcmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strcpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strcspn.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strdup.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strerror_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strlcat.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strlcpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strlen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strncasecmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strncat.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strncmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strncpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strndup.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strnlen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strpbrk.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strrchr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strsep.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strsignal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strspn.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strstr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strtok.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strtok_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/strverscmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/swab.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcpcpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcpncpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcscasecmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcscasecmp_l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcscat.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcschr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcscmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcscpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcscspn.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsdup.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcslen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsncasecmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsncasecmp_l.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsncat.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsncmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsncpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsnlen.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcspbrk.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsrchr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsspn.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcsstr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcstok.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wcswcs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wmemchr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wmemcmp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wmemcpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wmemmove.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/wmemset.c
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/endian.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/src/internal/locale_impl.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/strings.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/unistd.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/wchar.h
+LIBMUSL_STRING_HDRS-y += $(LIBMUSL)/include/wctype.h
+
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/bcmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/bcopy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/bzero.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/index.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memccpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memchr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memcmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memmem.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/mempcpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memrchr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/rindex.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/stpcpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/stpncpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strcasecmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strcasestr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strcat.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strchr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strchrnul.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strcmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strcpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strcspn.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strdup.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strerror_r.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strlcat.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strlcpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strlen.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strncasecmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strncat.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strncmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strncpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strndup.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strnlen.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strpbrk.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strrchr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strsep.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strsignal.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strspn.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strstr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strtok.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strtok_r.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/strverscmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/swab.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcpcpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcpncpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcscasecmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcscasecmp_l.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcscat.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcschr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcscmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcscpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcscspn.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsdup.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcslen.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsncasecmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsncasecmp_l.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsncat.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsncmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsncpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsnlen.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcspbrk.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsrchr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsspn.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcsstr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcstok.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wcswcs.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wmemchr.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wmemcmp.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wmemcpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wmemmove.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/wmemset.c
 
 ifeq (arm,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/arm/__aeabi_memcpy.s|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/arm/__aeabi_memset.s|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/arm/memcpy.c|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/arm/memcpy_le.S|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memmove.c|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memset.c|arm
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/arm/__aeabi_memcpy.s|arm
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/arm/__aeabi_memset.s|arm
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/arm/memcpy.c|arm
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/arm/memcpy_le.S|arm
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memmove.c|arm
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memset.c|arm
 else ifeq (x86_32,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/i386/memcpy.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/i386/memmove.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/i386/memset.s|i386
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/i386/memcpy.s|i386
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/i386/memmove.s|i386
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/i386/memset.s|i386
 else ifeq (x86_64,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/x86_64/memcpy.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/x86_64/memmove.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/x86_64/memset.s|x86_64
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/x86_64/memcpy.s|x86_64
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/x86_64/memmove.s|x86_64
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/x86_64/memset.s|x86_64
 else
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memcpy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memmove.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/string/memset.c
-endif
\ No newline at end of file
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memcpy.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memmove.c
+LIBMUSL_STRING_SRCS-y += $(LIBMUSL)/src/string/memset.c
+endif
+
+$(eval $(call _libmusl_import_lib,string,$(LIBMUSL_STRING_HDRS-y),$(LIBMUSL_STRING_SRCS-y)))
diff --git a/Makefile.uk.musl.temp b/Makefile.uk.musl.temp
index 1107ffc..3d7f554 100644
--- a/Makefile.uk.musl.temp
+++ b/Makefile.uk.musl.temp
@@ -1,7 +1,19 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/temp/__randname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/temp/mkdtemp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/temp/mkostemp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/temp/mkostemps.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/temp/mkstemp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/temp/mkstemps.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/temp/mktemp.c
+LIBMUSL_TEMP_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_TEMP_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_TEMP_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_TEMP_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_TEMP_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_TEMP_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_TEMP_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_TEMP_HDRS-y += $(LIBMUSL)/include/time.h
+LIBMUSL_TEMP_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+LIBMUSL_TEMP_SRCS-y += $(LIBMUSL)/src/temp/__randname.c
+LIBMUSL_TEMP_SRCS-y += $(LIBMUSL)/src/temp/mkdtemp.c
+LIBMUSL_TEMP_SRCS-y += $(LIBMUSL)/src/temp/mkostemp.c
+LIBMUSL_TEMP_SRCS-y += $(LIBMUSL)/src/temp/mkostemps.c
+LIBMUSL_TEMP_SRCS-y += $(LIBMUSL)/src/temp/mkstemp.c
+LIBMUSL_TEMP_SRCS-y += $(LIBMUSL)/src/temp/mkstemps.c
+LIBMUSL_TEMP_SRCS-y += $(LIBMUSL)/src/temp/mktemp.c
+
+$(eval $(call _libmusl_import_lib,temp,$(LIBMUSL_TEMP_HDRS-y),$(LIBMUSL_TEMP_SRCS-y)))
diff --git a/Makefile.uk.musl.termios b/Makefile.uk.musl.termios
index 734c13b..318fc92 100644
--- a/Makefile.uk.musl.termios
+++ b/Makefile.uk.musl.termios
@@ -1,10 +1,18 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/cfgetospeed.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/cfmakeraw.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/cfsetospeed.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/tcdrain.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/tcflow.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/tcflush.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/tcgetattr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/tcgetsid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/tcsendbreak.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/termios/tcsetattr.c
+LIBMUSL_TERMIOS_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_TERMIOS_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_TERMIOS_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_TERMIOS_HDRS-y += $(LIBMUSL)/include/sys/ioctl.h
+LIBMUSL_TERMIOS_HDRS-y += $(LIBMUSL)/include/termios.h
+
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/cfgetospeed.c
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/cfmakeraw.c
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/cfsetospeed.c
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/tcdrain.c
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/tcflow.c
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/tcflush.c
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/tcgetattr.c
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/tcgetsid.c
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/tcsendbreak.c
+LIBMUSL_TERMIOS_SRCS-y += $(LIBMUSL)/src/termios/tcsetattr.c
+
+$(eval $(call _libmusl_import_lib,termios,$(LIBMUSL_TERMIOS_HDRS-y),$(LIBMUSL_TERMIOS_SRCS-y)))
diff --git a/Makefile.uk.musl.thread b/Makefile.uk.musl.thread
index f5e567a..2f2f7be 100644
--- a/Makefile.uk.musl.thread
+++ b/Makefile.uk.musl.thread
@@ -1,197 +1,230 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/__futex.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/__lock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/__syscall_cp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/__timedwait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/__tls_get_addr.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/__wait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/call_once.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/cnd_broadcast.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/cnd_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/cnd_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/cnd_signal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/cnd_timedwait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/cnd_wait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/lock_ptc.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mtx_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mtx_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mtx_lock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mtx_timedlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mtx_trylock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mtx_unlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_atfork.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_get.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setdetachstate.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setguardsize.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setinheritsched.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setschedparam.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setschedpolicy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setscope.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setstack.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setstacksize.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrier_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrier_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrier_wait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrierattr_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrierattr_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrierattr_setpshared.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_cancel.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_cleanup_push.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_broadcast.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_signal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_timedwait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_wait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_condattr_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_condattr_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_condattr_setclock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_condattr_setpshared.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_create.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_detach.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_equal.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_getattr_np.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_getconcurrency.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_getcpuclockid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_getschedparam.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_getspecific.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_join.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_key_create.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_kill.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_consistent.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_getprioceiling.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_lock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_setprioceiling.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_timedlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_trylock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_unlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_setprotocol.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_setpshared.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_setrobust.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_settype.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_once.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_rdlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_timedrdlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_timedwrlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_tryrdlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_trywrlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_unlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_wrlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlockattr_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlockattr_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlockattr_setpshared.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_self.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_setattr_default_np.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_setcancelstate.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_setcanceltype.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_setconcurrency.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_setname_np.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_setschedparam.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_setschedprio.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_setspecific.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_sigmask.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_lock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_trylock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_unlock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/pthread_testcancel.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sem_destroy.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sem_getvalue.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sem_init.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sem_open.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sem_post.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sem_timedwait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sem_trywait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sem_unlink.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sem_wait.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/synccall.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/syscall_cp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/thrd_create.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/thrd_exit.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/thrd_join.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/thrd_sleep.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/thrd_yield.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/tls.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/tss_create.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/tss_delete.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/tss_set.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/vmlock.c
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/dirent.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/src/internal/dynlink.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/elf.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/src/internal/futex.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/pthread.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/semaphore.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/stdarg.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/src/internal/stdio_impl.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/sys/mman.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/sys/prctl.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/sys/select.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/sys/syscall.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/threads.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/time.h
+LIBMUSL_THREAD_HDRS-y += $(LIBMUSL)/include/unistd.h
+
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/__futex.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/__lock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/__syscall_cp.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/__timedwait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/__tls_get_addr.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/__wait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/call_once.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/cnd_broadcast.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/cnd_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/cnd_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/cnd_signal.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/cnd_timedwait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/cnd_wait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/lock_ptc.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mtx_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mtx_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mtx_lock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mtx_timedlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mtx_trylock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mtx_unlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_atfork.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_get.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setdetachstate.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setguardsize.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setinheritsched.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setschedparam.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setschedpolicy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setscope.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setstack.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_attr_setstacksize.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrier_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrier_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrier_wait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrierattr_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrierattr_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_barrierattr_setpshared.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_cancel.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_cleanup_push.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_broadcast.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_signal.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_timedwait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_cond_wait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_condattr_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_condattr_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_condattr_setclock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_condattr_setpshared.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_create.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_detach.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_equal.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_getattr_np.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_getconcurrency.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_getcpuclockid.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_getschedparam.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_getspecific.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_join.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_key_create.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_kill.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_consistent.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_getprioceiling.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_lock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_setprioceiling.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_timedlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_trylock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutex_unlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_setprotocol.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_setpshared.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_setrobust.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_mutexattr_settype.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_once.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_rdlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_timedrdlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_timedwrlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_tryrdlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_trywrlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_unlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlock_wrlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlockattr_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlockattr_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_rwlockattr_setpshared.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_self.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_setattr_default_np.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_setcancelstate.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_setcanceltype.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_setconcurrency.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_setname_np.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_setschedparam.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_setschedprio.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_setspecific.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_sigmask.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_lock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_trylock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_spin_unlock.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/pthread_testcancel.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sem_destroy.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sem_getvalue.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sem_init.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sem_open.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sem_post.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sem_timedwait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sem_trywait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sem_unlink.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sem_wait.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/synccall.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/syscall_cp.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/thrd_create.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/thrd_exit.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/thrd_join.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/thrd_sleep.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/thrd_yield.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/tls.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/tss_create.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/tss_delete.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/tss_set.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/vmlock.c
 
 ifeq (x86_32,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/i386/__set_thread_area.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/i386/__unmapself.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/i386/clone.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/i386/syscall_cp.s|i386
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/i386/tls.s|i386
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/i386/__set_thread_area.s|i386
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/i386/__unmapself.s|i386
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/i386/clone.s|i386
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/i386/syscall_cp.s|i386
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/i386/tls.s|i386
 else ifeq (x86_64,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/x86_64/__set_thread_area.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/x86_64/__unmapself.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/x86_64/clone.s|x86_64
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/x86_64/syscall_cp.s|x86_64
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/x86_64/__set_thread_area.s|x86_64
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/x86_64/__unmapself.s|x86_64
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/x86_64/clone.s|x86_64
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/x86_64/syscall_cp.s|x86_64
 else ifeq (arm,$(CONFIG_UK_ARCH))
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/arm/__aeabi_read_tp.s|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/arm/__aeabi_read_tp_c.c|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/arm/__set_thread_area.c|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/arm/__unmapself.s|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/arm/atomics.s|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/arm/clone.s|arm
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/arm/syscall_cp.s|arm
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/arm/__aeabi_read_tp.s|arm
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/arm/__aeabi_read_tp_c.c|arm
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/arm/__set_thread_area.c|arm
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/arm/__unmapself.s|arm
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/arm/atomics.s|arm
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/arm/clone.s|arm
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/arm/syscall_cp.s|arm
 else
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/__set_thread_area.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/__unmapself.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/clone.c|thread
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/__set_thread_area.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/__unmapself.c
+LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/clone.c|thread
 endif
 
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/aarch64/__set_thread_area.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/aarch64/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/aarch64/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/aarch64/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/microblaze/__set_thread_area.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/microblaze/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/microblaze/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/microblaze/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mips/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mips/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mips/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mips64/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mips64/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mips64/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mipsn32/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mipsn32/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/mipsn32/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/or1k/__set_thread_area.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/or1k/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/or1k/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/or1k/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/powerpc/__set_thread_area.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/powerpc/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/powerpc/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/powerpc/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/powerpc64/__set_thread_area.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/powerpc64/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/powerpc64/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/powerpc64/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/s390x/__set_thread_area.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/s390x/__tls_get_offset.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/s390x/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/s390x/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/s390x/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sh/__set_thread_area.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sh/__unmapself.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sh/__unmapself_mmu.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sh/atomics.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sh/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/sh/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/x32/__set_thread_area.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/x32/__unmapself.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/x32/clone.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/x32/syscall_cp.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/thread/x32/syscall_cp_fixup.c
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/aarch64/__set_thread_area.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/aarch64/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/aarch64/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/aarch64/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/microblaze/__set_thread_area.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/microblaze/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/microblaze/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/microblaze/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mips/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mips/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mips/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mips64/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mips64/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mips64/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mipsn32/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mipsn32/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/mipsn32/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/or1k/__set_thread_area.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/or1k/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/or1k/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/or1k/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/powerpc/__set_thread_area.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/powerpc/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/powerpc/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/powerpc/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/powerpc64/__set_thread_area.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/powerpc64/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/powerpc64/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/powerpc64/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/s390x/__set_thread_area.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/s390x/__tls_get_offset.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/s390x/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/s390x/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/s390x/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sh/__set_thread_area.c
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sh/__unmapself.c
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sh/__unmapself_mmu.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sh/atomics.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sh/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/sh/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/x32/__set_thread_area.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/x32/__unmapself.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/x32/clone.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/x32/syscall_cp.s
+#LIBMUSL_THREAD_SRCS-y += $(LIBMUSL)/src/thread/x32/syscall_cp_fixup.c
+
+$(eval $(call _libmusl_import_lib,thread,$(LIBMUSL_THREAD_HDRS-y),$(LIBMUSL_THREAD_SRCS-y)))
diff --git a/Makefile.uk.musl.time b/Makefile.uk.musl.time
index db4a736..ec42edf 100644
--- a/Makefile.uk.musl.time
+++ b/Makefile.uk.musl.time
@@ -1,40 +1,77 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/__asctime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/__map_file.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/__month_to_secs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/__secs_to_tm.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/__tm_to_secs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/__tz.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/__year_to_secs.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/asctime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/asctime_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/clock.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/clock_getcpuclockid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/clock_getres.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/clock_gettime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/clock_nanosleep.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/clock_settime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/ctime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/ctime_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/difftime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/ftime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/getdate.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/gettimeofday.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/gmtime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/gmtime_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/localtime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/localtime_r.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/mktime.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/nanosleep.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/strftime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/strptime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/time.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/timegm.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/timer_create.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/timer_delete.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/timer_getoverrun.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/timer_gettime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/timer_settime.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/times.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/timespec_get.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/utime.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/time/wcsftime.c
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/src/internal/atomic.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/ctype.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/langinfo.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/locale.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/src/internal/locale_impl.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/pthread.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/setjmp.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/stddef.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/stdint.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/strings.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/sys/mman.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/sys/timeb.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/sys/time.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/sys/times.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/time.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/src/time/time_impl.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/unistd.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/utime.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/wchar.h
+LIBMUSL_TIME_HDRS-y += $(LIBMUSL)/include/nl_types.h
+
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/__asctime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/__map_file.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/__month_to_secs.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/__secs_to_tm.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/__tm_to_secs.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/__tz.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/__year_to_secs.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/asctime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/asctime_r.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/clock.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/clock_getcpuclockid.c
+#LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/clock_getres.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/clock_gettime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/clock_nanosleep.c
+#LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/clock_settime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/ctime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/ctime_r.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/difftime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/ftime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/getdate.c
+#LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/gettimeofday.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/gmtime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/gmtime_r.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/localtime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/localtime_r.c
+#LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/mktime.c
+#LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/nanosleep.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/strftime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/strptime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/time.c
+#LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/timegm.c
+
+ifneq ($(CONFIG_LIBUKTIME),y)
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/timer_create.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/timer_delete.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/timer_gettime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/timer_settime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/timer_getoverrun.c
+endif
+
+#LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/times.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/timespec_get.c
+#LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/utime.c
+LIBMUSL_TIME_SRCS-y += $(LIBMUSL)/src/time/wcsftime.c
+
+$(eval $(call _libmusl_import_lib,time,$(LIBMUSL_TIME_HDRS-y),$(LIBMUSL_TIME_SRCS-y)))
diff --git a/Makefile.uk.musl.unistd b/Makefile.uk.musl.unistd
index 1b02a3b..a4378b4 100644
--- a/Makefile.uk.musl.unistd
+++ b/Makefile.uk.musl.unistd
@@ -1,84 +1,107 @@
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/_exit.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/access.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/acct.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/alarm.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/chdir.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/chown.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/close.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/ctermid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/dup.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/dup2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/dup3.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/faccessat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/fchdir.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/fchown.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/fchownat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/fdatasync.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/fsync.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/ftruncate.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getcwd.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getegid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/geteuid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getgid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getgroups.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/gethostname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getlogin.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getlogin_r.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getpgid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getpgrp.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getpid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getppid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getsid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/getuid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/isatty.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/lchown.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/link.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/linkat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/lseek.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/nice.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/pause.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/pipe.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/pipe2.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/posix_close.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/pread.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/preadv.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/pwrite.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/pwritev.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/read.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/readlink.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/readlinkat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/readv.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/renameat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/rmdir.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setegid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/seteuid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setgid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setpgid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setpgrp.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setregid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setresgid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setresuid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setreuid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setsid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setuid.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/setxid.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/sleep.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/symlink.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/symlinkat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/sync.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/tcgetpgrp.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/tcsetpgrp.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/truncate.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/ttyname.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/ttyname_r.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/ualarm.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/unlink.c
-LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/unlinkat.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/usleep.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/write.c
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/writev.c
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/errno.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/fcntl.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/src/internal/libc.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/limits.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/src/internal/pthread_impl.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/signal.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/stdio.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/stdlib.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/string.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/src/internal/syscall.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/sys/ioctl.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/sys/resource.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/sys/stat.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/sys/time.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/sys/uio.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/sys/utsname.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/sys/wait.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/termios.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/time.h
+LIBMUSL_UNISTD_HDRS-y += $(LIBMUSL)/include/unistd.h
 
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/mips/pipe.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/mips64/pipe.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/mipsn32/pipe.s
-#LIBMUSL_SRCS-y += $(LIBMUSL)/src/unistd/sh/pipe.s
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/_exit.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/access.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/acct.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/alarm.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/chdir.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/chown.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/close.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/ctermid.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/dup.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/dup2.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/dup3.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/faccessat.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/fchdir.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/fchown.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/fchownat.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/fdatasync.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/fsync.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/ftruncate.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getcwd.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getegid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/geteuid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getgid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getgroups.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/gethostname.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getlogin.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getlogin_r.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getpgid.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getpgrp.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getpid.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getppid.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getsid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/getuid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/isatty.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/lchown.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/link.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/linkat.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/lseek.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/nice.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/pause.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/pipe.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/pipe2.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/posix_close.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/pread.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/preadv.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/pwrite.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/pwritev.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/read.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/readlink.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/readlinkat.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/readv.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/renameat.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/rmdir.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setegid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/seteuid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setgid.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setpgid.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setpgrp.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setregid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setresgid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setresuid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setreuid.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setsid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setuid.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/setxid.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/sleep.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/symlink.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/symlinkat.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/sync.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/tcgetpgrp.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/tcsetpgrp.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/truncate.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/ttyname.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/ttyname_r.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/ualarm.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/unlink.c
+LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/unlinkat.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/usleep.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/write.c
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/writev.c
+
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/mips/pipe.s
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/mips64/pipe.s
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/mipsn32/pipe.s
+#LIBMUSL_UNISTD_SRCS-y += $(LIBMUSL)/src/unistd/sh/pipe.s
+
+$(eval $(call _libmusl_import_lib,unistd,$(LIBMUSL_UNISTD_HDRS-y),$(LIBMUSL_UNISTD_SRCS-y)))
-- 
2.17.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 10:17:10 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 10:17:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8694.23293 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUSDz-0005mN-On; Mon, 19 Oct 2020 10:17:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8694.23293; Mon, 19 Oct 2020 10:17:07 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUSDz-0005mG-M4; Mon, 19 Oct 2020 10:17:07 +0000
Received: by outflank-mailman (input) for mailman id 8694;
 Mon, 19 Oct 2020 10:17:07 +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=YuWH=D2=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kUSDz-0005mB-07
 for minios-devel@lists.xen.org; Mon, 19 Oct 2020 10:17:07 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 1218f810-3ab7-418c-80a0-e1100260d284;
 Mon, 19 Oct 2020 10:17:03 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 2C24FF2289;
 Mon, 19 Oct 2020 12:17:02 +0200 (CEST)
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 UlhcfnMkx1uk; Mon, 19 Oct 2020 12:17:02 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id EE47CF2163
 for <minios-devel@lists.xen.org>; Mon, 19 Oct 2020 12:16:59 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 19 Oct
 2020 12:16:59 +0200
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=YuWH=D2=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kUSDz-0005mB-07
	for minios-devel@lists.xen.org; Mon, 19 Oct 2020 10:17:07 +0000
X-Inumbo-ID: 1218f810-3ab7-418c-80a0-e1100260d284
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 1218f810-3ab7-418c-80a0-e1100260d284;
	Mon, 19 Oct 2020 10:17:03 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 2C24FF2289;
	Mon, 19 Oct 2020 12:17:02 +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 UlhcfnMkx1uk; Mon, 19 Oct 2020 12:17:02 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id EE47CF2163
	for <minios-devel@lists.xen.org>; Mon, 19 Oct 2020 12:16:59 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 19 Oct
 2020 12:16:59 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/TLSF PATCH] Provide LIBTLSF_INCLUDED (invisible, always "y")
Date: Mon, 19 Oct 2020 12:16:56 +0200
Message-ID: <20201019101656.8306-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 titania.office.hd
 (192.168.24.89)

Introduces 'LIBTLSF_INCLUDED' that can be used to determine if the library was
included to the build. It is expected that this option is an intermediate
solution until we are able to dynamically register configuration options to
other libraries like 'ukboot'.

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

diff --git a/Config.uk b/Config.uk
index d74c0a5..71bff7b 100644
--- a/Config.uk
+++ b/Config.uk
@@ -1,3 +1,9 @@
+# Invisible option that is used to detect
+# if LIBTLSF is availbale for configuration
+config LIBTLSF_INCLUDED
+	   bool
+	   default y
+
 menuconfig LIBTLSF
 	   bool "tlsf - dynamic memory allocator for embedded systems"
 	   default y
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Mon Oct 19 10:17:33 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 19 Oct 2020 10:17:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.8696.23297 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUSEP-0005oO-Rg; Mon, 19 Oct 2020 10:17:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 8696.23297; Mon, 19 Oct 2020 10:17:33 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kUSEP-0005oH-OW; Mon, 19 Oct 2020 10:17:33 +0000
Received: by outflank-mailman (input) for mailman id 8696;
 Mon, 19 Oct 2020 10:17:32 +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=YuWH=D2=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kUSEO-0005oB-8W
 for minios-devel@lists.xen.org; Mon, 19 Oct 2020 10:17:32 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id c757e606-519a-49f5-8548-1de371362d7b;
 Mon, 19 Oct 2020 10:17:31 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 75726FFB3E;
 Mon, 19 Oct 2020 12:17:30 +0200 (CEST)
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 vAD_HgsR9Yw1; Mon, 19 Oct 2020 12:17:30 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 54D0FFFAD0
 for <minios-devel@lists.xen.org>; Mon, 19 Oct 2020 12:17:30 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 19 Oct
 2020 12:17:30 +0200
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=YuWH=D2=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kUSEO-0005oB-8W
	for minios-devel@lists.xen.org; Mon, 19 Oct 2020 10:17:32 +0000
X-Inumbo-ID: c757e606-519a-49f5-8548-1de371362d7b
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id c757e606-519a-49f5-8548-1de371362d7b;
	Mon, 19 Oct 2020 10:17:31 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 75726FFB3E;
	Mon, 19 Oct 2020 12:17:30 +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 vAD_HgsR9Yw1; Mon, 19 Oct 2020 12:17:30 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 54D0FFFAD0
	for <minios-devel@lists.xen.org>; Mon, 19 Oct 2020 12:17:30 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 19 Oct
 2020 12:17:30 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH] lib/ukboot: Provide option to initialize TLSF
Date: Mon, 19 Oct 2020 12:17:27 +0200
Message-ID: <20201019101727.8445-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 titania.office.hd
 (192.168.24.89)

Provides the option to initialize TLSF as allocator. The option is only made
available when `LIBTLSF_INCLUDED` is set. This should be done by the TLSF
library as soon included to Unikraft. It is expected that this solution
intermediate until we are able to dynamically register configuration options to
core libraries.

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

diff --git a/lib/ukboot/Config.uk b/lib/ukboot/Config.uk
index 57cf1e36..9e2996d7 100644
--- a/lib/ukboot/Config.uk
+++ b/lib/ukboot/Config.uk
@@ -92,6 +92,11 @@ if LIBUKBOOT
 		  Satisfy allocation as fast as possible. No support for free().
 		  Refer to help in ukallocregion for more information.
 
+		config LIBUKBOOT_INITTLSF
+		bool "TLSF"
+		depends on LIBTLSF_INCLUDED
+		select LIBTLSF
+
 		config LIBUKBOOT_NOALLOC
 		bool "None"
 
diff --git a/lib/ukboot/boot.c b/lib/ukboot/boot.c
index a4e12bf7..2f7ab24a 100644
--- a/lib/ukboot/boot.c
+++ b/lib/ukboot/boot.c
@@ -45,6 +45,8 @@
 #include <uk/allocbbuddy.h>
 #elif CONFIG_LIBUKBOOT_INITREGION
 #include <uk/allocregion.h>
+#elif CONFIG_LIBUKBOOT_INITTLSF
+#include <uk/tlsf.h>
 #endif
 #if CONFIG_LIBUKSCHED
 #include <uk/sched.h>
@@ -239,6 +241,8 @@ void ukplat_entry(int argc, char *argv[])
 			a = uk_allocbbuddy_init(md.base, md.len);
 #elif CONFIG_LIBUKBOOT_INITREGION
 			a = uk_allocregion_init(md.base, md.len);
+#elif CONFIG_LIBUKBOOT_INITTLSF
+			a = uk_tlsf_init(md.base, md.len);
 #endif
 		} else {
 			uk_alloc_addmem(a, md.base, md.len);
-- 
2.20.1



From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:01:11 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:01:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10364.27589 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVYLD-00054P-KI; Thu, 22 Oct 2020 11:01:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10364.27589; Thu, 22 Oct 2020 11:01:07 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVYLD-00054I-HQ; Thu, 22 Oct 2020 11:01:07 +0000
Received: by outflank-mailman (input) for mailman id 10364;
 Thu, 22 Oct 2020 11:01: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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVYLC-00054D-Jd
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:01:06 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 6e29b47d-2cb1-438d-91a4-ae25bbedde0b;
 Thu, 22 Oct 2020 11:01:02 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 82FB9104030;
 Thu, 22 Oct 2020 13:01:01 +0200 (CEST)
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 LViTIBTUNmV9; Thu, 22 Oct 2020 13:01:01 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 5763E103AE4;
 Thu, 22 Oct 2020 13:01:01 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:01:00 +0200
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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVYLC-00054D-Jd
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:01:06 +0000
X-Inumbo-ID: 6e29b47d-2cb1-438d-91a4-ae25bbedde0b
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 6e29b47d-2cb1-438d-91a4-ae25bbedde0b;
	Thu, 22 Oct 2020 11:01:02 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 82FB9104030;
	Thu, 22 Oct 2020 13:01:01 +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 LViTIBTUNmV9; Thu, 22 Oct 2020 13:01:01 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 5763E103AE4;
	Thu, 22 Oct 2020 13:01:01 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:01:00 +0200
Subject: Re: [UNIKRAFT PATCH v4 04/12] plat/xen/drivers/net: Configure
 netfront device
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
CC: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-5-costin.lupu@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <bc823bb1-ced0-8563-1227-7557c56878df@neclab.eu>
Date: Thu, 22 Oct 2020 13:00:21 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20200813085342.29799-5-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Please find some minor comments inline:

Thanks & Regards

Sharan

On 8/13/20 10:53 AM, Costin Lupu wrote:
> The information needed for configuring netfront devices is in the Xenstore. For
> now, we only retrieve the MAC and IP addresses from there in order to
> initialize the device.
>
> This patch introduces the `netfront_dev` structure which integrates both netdev
> and Xenbus device information and also keeps the configuration parameters.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
> ---
>   plat/xen/Makefile.uk               |   1 +
>   plat/xen/drivers/net/netfront.c    | 100 ++++++++++++++
>   plat/xen/drivers/net/netfront.h    |  66 ++++++++++
>   plat/xen/drivers/net/netfront_xb.h |  43 ++++++
>   plat/xen/drivers/net/netfront_xs.c | 205 +++++++++++++++++++++++++++++
>   5 files changed, 415 insertions(+)
>   create mode 100644 plat/xen/drivers/net/netfront.h
>   create mode 100644 plat/xen/drivers/net/netfront_xb.h
>   create mode 100644 plat/xen/drivers/net/netfront_xs.c
>
> diff --git a/plat/xen/Makefile.uk b/plat/xen/Makefile.uk
> index 339b1b21..dfca58fe 100644
> --- a/plat/xen/Makefile.uk
> +++ b/plat/xen/Makefile.uk
> @@ -121,6 +121,7 @@ LIBXENNETFRONT_ASINCLUDES-y    += $(LIBXENPLAT_ASINCLUDES-y)
>   LIBXENNETFRONT_CFLAGS-y        += $(LIBXENPLAT_CFLAGS-y)
>   LIBXENNETFRONT_CINCLUDES-y     += $(LIBXENPLAT_CINCLUDES-y)
>   LIBXENNETFRONT_SRCS-y          += $(LIBXENPLAT_BASE)/drivers/net/netfront.c
> +LIBXENNETFRONT_SRCS-y          += $(LIBXENPLAT_BASE)/drivers/net/netfront_xs.c
>   endif
>   
>   ifeq ($(CONFIG_XEN_BLKFRONT),y)
> diff --git a/plat/xen/drivers/net/netfront.c b/plat/xen/drivers/net/netfront.c
> index b455911e..539e1cbc 100644
> --- a/plat/xen/drivers/net/netfront.c
> +++ b/plat/xen/drivers/net/netfront.c
> @@ -33,21 +33,121 @@
>    * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
>    */
>   
> +#include <uk/assert.h>
> +#include <uk/print.h>
> +#include <uk/alloc.h>
> +#include <uk/netdev_driver.h>
>   #include <xenbus/xenbus.h>
> +#include "netfront.h"
> +#include "netfront_xb.h"
>   
>   
>   #define DRIVER_NAME  "xen-netfront"
>   
> +#define to_netfront_dev(dev) \
> +	__containerof(dev, struct netfront_dev, netdev)
> +
>   static struct uk_alloc *drv_allocator;
>   
> +static const void *netfront_einfo_get(struct uk_netdev *n,
> +		enum uk_netdev_einfo_type einfo_type)
> +{
> +	struct netfront_dev *nfdev;
> +
> +	UK_ASSERT(n != NULL);
> +
> +	nfdev = to_netfront_dev(n);
> +	switch (einfo_type) {
> +	case UK_NETDEV_IPV4_ADDR_STR:
> +		return nfdev->econf.ipv4addr;
> +	case UK_NETDEV_IPV4_MASK_STR:
> +		return nfdev->econf.ipv4mask;
> +	case UK_NETDEV_IPV4_GW_STR:
> +		return nfdev->econf.ipv4gw;
> +	default:
> +		break;
> +	}
> +
> +	/* type not supported */
> +	return NULL;
> +}
> +
> +static const struct uk_hwaddr *netfront_mac_get(struct uk_netdev *n)
> +{
> +	struct netfront_dev *nfdev;
> +
> +	UK_ASSERT(n != NULL);
> +	nfdev = to_netfront_dev(n);
> +	return &nfdev->hw_addr;
> +}
> +
> +static uint16_t netfront_mtu_get(struct uk_netdev *n)
> +{
> +	struct netfront_dev *nfdev;
> +
> +	UK_ASSERT(n != NULL);
> +	nfdev = to_netfront_dev(n);
> +	return nfdev->mtu;
> +}
> +
> +static unsigned int netfront_promisc_get(struct uk_netdev *n)
> +{
> +	struct netfront_dev *nfdev;
> +
> +	UK_ASSERT(n != NULL);
> +	nfdev = to_netfront_dev(n);
> +	return nfdev->promisc;
> +}
> +
> +static const struct uk_netdev_ops netfront_ops = {
> +	.einfo_get = netfront_einfo_get,
> +	.hwaddr_get = netfront_mac_get,
> +	.mtu_get = netfront_mtu_get,
> +	.promiscuous_get = netfront_promisc_get,
> +};
>   
>   static int netfront_add_dev(struct xenbus_device *xendev)
>   {
> +	struct netfront_dev *nfdev;
>   	int rc = 0;
>   
>   	UK_ASSERT(xendev != NULL);
>   
> +	nfdev = uk_calloc(drv_allocator, 1, sizeof(*nfdev));
> +	if (!nfdev) {
> +		rc = -ENOMEM;
> +		goto err_out;
> +	}
> +
> +	nfdev->xendev = xendev;
> +	nfdev->mtu = ETH_PKT_PAYLOAD_LEN;
Adapt it to make it compatible with latest macro.
> +
> +	/* Xenbus initialization */
> +	rc = netfront_xb_init(nfdev, drv_allocator);
> +	if (rc) {
> +		uk_pr_err("Error initializing Xenbus data: %d\n", rc);
> +		goto err_xenbus;
> +	}
> +
> +	/* register netdev */
> +	nfdev->netdev.ops = &netfront_ops;
> +	rc = uk_netdev_drv_register(&nfdev->netdev, drv_allocator, DRIVER_NAME);
> +	if (rc < 0) {
> +		uk_pr_err("Failed to register %s device with libuknetdev\n",
> +			DRIVER_NAME);
> +		goto err_register;
> +	}
> +	nfdev->uid = rc;
> +	rc = 0;
> +
> +out:
>   	return rc;
> +err_register:
> +	netfront_xb_fini(nfdev, drv_allocator);
> +err_xenbus:
> +	uk_free(drv_allocator, nfdev);
> +err_out:
> +	goto out;
>   }
>   
>   static int netfront_drv_init(struct uk_alloc *allocator)
> diff --git a/plat/xen/drivers/net/netfront.h b/plat/xen/drivers/net/netfront.h
> new file mode 100644
> index 00000000..0cc8230b
> --- /dev/null
> +++ b/plat/xen/drivers/net/netfront.h
> @@ -0,0 +1,66 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Authors: Costin Lupu <costin.lupu@cs.pub.ro>
> + *          Razvan Cojocaru <razvan.cojocaru93@gmail.com>
> + *
> + * Copyright (c) 2020, University Politehnica of Bucharest. All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of the copyright holder nor the names of its
> + *    contributors may be used to endorse or promote products derived from
> + *    this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> + * POSSIBILITY OF SUCH DAMAGE.
> + *
> + * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
> + */
> +
> +#ifndef __NETFRONT_H__
> +#define __NETFRONT_H__
> +
> +#include <uk/netdev.h>
> +
> +struct xs_econf {
> +	char *ipv4addr;
> +	char *ipv4mask;
> +	char *ipv4gw;
> +};
> +
> +struct netfront_dev {
> +	/* Xenbus device */
> +	struct xenbus_device *xendev;
> +	/* Network device */
> +	struct uk_netdev netdev;
> +
> +	/* Configuration parameters */
> +	struct xs_econf econf;
> +
> +	/* The netdevice identifier */
> +	uint16_t uid;
> +	/* The mtu */
> +	uint16_t mtu;
> +	/* The hw address of the netdevice */
> +	struct uk_hwaddr hw_addr;
> +	/* RX promiscuous mode. */
> +	uint8_t promisc : 1;
> +};
> +
> +#endif /* __NETFRONT_H__ */
> diff --git a/plat/xen/drivers/net/netfront_xb.h b/plat/xen/drivers/net/netfront_xb.h
> new file mode 100644
> index 00000000..6332cf71
> --- /dev/null
> +++ b/plat/xen/drivers/net/netfront_xb.h
> @@ -0,0 +1,43 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Authors: Costin Lupu <costin.lupu@cs.pub.ro>
> + *
> + * Copyright (c) 2020, University Politehnica of Bucharest. All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of the copyright holder nor the names of its
> + *    contributors may be used to endorse or promote products derived from
> + *    this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> + * POSSIBILITY OF SUCH DAMAGE.
> + *
> + * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
> + */
> +
> +#ifndef __NETFRONT_XB_H__
> +#define __NETFRONT_XB_H__
> +
> +#include "netfront.h"
> +
> +int  netfront_xb_init(struct netfront_dev *netdev, struct uk_alloc *a);
> +void netfront_xb_fini(struct netfront_dev *netdev, struct uk_alloc *a);
> +
> +#endif /* __NETFRONT_XB_H__ */
> diff --git a/plat/xen/drivers/net/netfront_xs.c b/plat/xen/drivers/net/netfront_xs.c
> new file mode 100644
> index 00000000..48f01b34
> --- /dev/null
> +++ b/plat/xen/drivers/net/netfront_xs.c
> @@ -0,0 +1,205 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Authors: Costin Lupu <costin.lupu@cs.pub.ro>
> + *
> + * Copyright (c) 2020, University Politehnica of Bucharest. All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *
> + * 1. Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in the
> + *    documentation and/or other materials provided with the distribution.
> + * 3. Neither the name of the copyright holder nor the names of its
> + *    contributors may be used to endorse or promote products derived from
> + *    this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
> + * POSSIBILITY OF SUCH DAMAGE.
> + *
> + * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
> + */
> +#include <inttypes.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <uk/errptr.h>
> +#include <uk/print.h>
> +#include <uk/assert.h>
> +#include <xenbus/xs.h>
> +#include "netfront_xb.h"
> +
> +
> +static int xs_read_backend_id(const char *nodename, domid_t *domid)
> +{
> +	char path[strlen(nodename) + sizeof("/backend-id")];
> +	int value, rc;
UK_ASSERT(nodename);
> +
> +	sprintf(path, "%s/backend-id", nodename);
snprintf instead of sprintf
> +
> +	rc = xs_read_integer(XBT_NIL, path, &value);
> +	if (!rc)
> +		*domid = (domid_t) value;
> +
> +	return rc;
> +}
> +
> +static void xs_econf_fini(struct xs_econf *econf,
> +		struct uk_alloc *a)
> +{
> +	if (econf->ipv4addr) {
> +		uk_free(a, econf->ipv4addr);
> +		econf->ipv4addr = NULL;
> +	}
> +	if (econf->ipv4mask) {
> +		uk_free(a, econf->ipv4mask);
> +		econf->ipv4mask = NULL;
> +	}
> +	if (econf->ipv4gw) {
> +		uk_free(a, econf->ipv4gw);
> +		econf->ipv4gw = NULL;
> +	}
> +}
> +
> +static int xs_econf_init(struct xs_econf *econf, char *ip_str,
> +		struct uk_alloc *a)
> +{
> +	int rc = -1;
> +	char *ip_addr = NULL, *ip_gw_str = NULL, *ip_mask_str = NULL;
> +
> +	/* IP */
> +	ip_addr = strtok(ip_str, " ");
> +	if (ip_addr == NULL)
> +		goto out_err;
> +	econf->ipv4addr = uk_malloc(a, strlen(ip_addr) + 1);
> +	if (!econf->ipv4addr) {
> +		uk_pr_err("Error allocating ip config.\n");
> +		goto out_err;
> +	}
> +	memcpy(econf->ipv4addr, ip_addr, strlen(ip_addr) + 1);
> +
> +	/* Mask */
> +	ip_mask_str = strtok(NULL, " ");
> +	if (ip_mask_str == NULL)
> +		goto out_err;
> +	econf->ipv4mask = uk_malloc(a, strlen(ip_mask_str) + 1);
> +	if (!econf->ipv4mask) {
> +		uk_pr_err("Error allocating ip mask config.\n");
> +		goto out_err;
> +	}
> +	memcpy(econf->ipv4mask, ip_mask_str, strlen(ip_mask_str) + 1);
> +
> +	/* Gateway */
> +	ip_gw_str = strtok(NULL, " ");
> +	if (ip_gw_str == NULL)
> +		goto out_err;
> +	econf->ipv4gw = uk_malloc(a, strlen(ip_gw_str) + 1);
> +	if (!econf->ipv4gw) {
> +		uk_pr_err("Error allocating ip gateway config.\n");
> +		goto out_err;
> +	}
> +	memcpy(econf->ipv4gw, ip_gw_str, strlen(ip_gw_str) + 1);
> +
> +	rc = 0;
> +out:
> +	return rc;
> +out_err:
> +	xs_econf_fini(econf, a);
> +	goto out;
> +}
> +
> +int netfront_xb_init(struct netfront_dev *nfdev, struct uk_alloc *a)
> +{
> +	struct xenbus_device *xendev;
> +	char *mac_str, *p, *ip_str;
> +	int rc;
> +
> +	UK_ASSERT(nfdev != NULL);
> +
> +	xendev = nfdev->xendev;
> +	UK_ASSERT(xendev != NULL);
> +
> +	rc = xs_read_backend_id(xendev->nodename, &xendev->otherend_id);
> +	if (rc)
> +		goto out;
> +
> +	/* read backend path */
> +	xendev->otherend = xs_read(XBT_NIL, xendev->nodename, "backend");
> +	if (PTRISERR(xendev->otherend)) {
> +		uk_pr_err("Error reading backend path.\n");
> +		rc = PTR2ERR(xendev->otherend);
> +		xendev->otherend = NULL;
> +		goto out;
> +	}
> +
> +	/* read MAC address */
> +	mac_str = xs_read(XBT_NIL, xendev->nodename, "mac");
> +	if (PTRISERR(mac_str)) {
> +		uk_pr_err("Error reading MAC address.\n");
> +		rc = PTR2ERR(mac_str);
> +		goto no_conf;
> +	}
> +	uk_pr_info("\tMAC %s\n", mac_str);
> +
> +	p = mac_str;
> +	for (int i = 0; i < UK_NETDEV_HWADDR_LEN; i++) {
> +		nfdev->hw_addr.addr_bytes[i] = (uint8_t) strtoul(p, &p, 16);
> +		p++;
> +	}
> +	free(mac_str);
> +
> +	/* read IP address */
> +	ip_str = xs_read(XBT_NIL, xendev->otherend, "ip");
> +	if (PTRISERR(ip_str)) {
> +		uk_pr_err("Error reading IP address.\n");
> +		rc = PTR2ERR(ip_str);
> +		goto no_conf;
> +	}
> +	uk_pr_info("\tIP: %s\n", ip_str);
> +
> +	rc = xs_econf_init(&nfdev->econf, ip_str, a);
> +	if (rc)
> +		goto no_conf;
> +	free(ip_str);
> +
> +	/* TODO spit event channels */
> +
> +	/* TODO netmap */
> +
> +out:
> +	return rc;
> +no_conf:
> +	if (xendev->otherend) {
> +		free(xendev->otherend);
> +		xendev->otherend = NULL;
> +	}
> +	goto out;
> +}
> +
> +void netfront_xb_fini(struct netfront_dev *nfdev, struct uk_alloc *a)
> +{
> +	struct xenbus_device *xendev;
> +
> +	UK_ASSERT(nfdev != NULL);
> +
> +	xendev = nfdev->xendev;
> +	UK_ASSERT(xendev != NULL);
> +
> +	xs_econf_fini(&nfdev->econf, a);
> +
> +	if (xendev->otherend) {
> +		free(xendev->otherend);
> +		xendev->otherend = NULL;
> +	}
> +}


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:03:54 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:03:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10367.27593 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVYNt-0005Af-SE; Thu, 22 Oct 2020 11:03:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10367.27593; Thu, 22 Oct 2020 11:03:53 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVYNt-0005AY-PS; Thu, 22 Oct 2020 11:03:53 +0000
Received: by outflank-mailman (input) for mailman id 10367;
 Thu, 22 Oct 2020 11:03:52 +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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVYNs-0005AT-Bm
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:03:52 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 22219fe7-2028-485e-94f4-c875482a71a5;
 Thu, 22 Oct 2020 11:03:51 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 31288104030;
 Thu, 22 Oct 2020 13:03:50 +0200 (CEST)
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 2l1-wqdOgVlt; Thu, 22 Oct 2020 13:03:50 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 0CF69103AE4;
 Thu, 22 Oct 2020 13:03:50 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:03:49 +0200
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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVYNs-0005AT-Bm
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:03:52 +0000
X-Inumbo-ID: 22219fe7-2028-485e-94f4-c875482a71a5
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 22219fe7-2028-485e-94f4-c875482a71a5;
	Thu, 22 Oct 2020 11:03:51 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 31288104030;
	Thu, 22 Oct 2020 13:03:50 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-a.office.hd)
Received: from mailer1.neclab.eu ([127.0.0.1])
	by localhost (atlas-a.office.hd [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 2l1-wqdOgVlt; Thu, 22 Oct 2020 13:03:50 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 0CF69103AE4;
	Thu, 22 Oct 2020 13:03:50 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:03:49 +0200
Subject: Re: [UNIKRAFT PATCH v4 01/12] plat/drivers/virtio: Fill MTU and
 queues alignments when retrieving information
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-2-costin.lupu@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <523f0fa8-156b-8967-6525-7a88e3a41b36@neclab.eu>
Date: Thu, 22 Oct 2020 13:03:48 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20200813085342.29799-2-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Thanks for the work

Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>

Thanks & Regards
Sharan

On 8/13/20 10:53 AM, Costin Lupu wrote:
> This patch sets the max MTU value when retrieving device information and the
> alignments used when allocating packets for each queue.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> ---
>   plat/drivers/virtio/virtio_net.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/plat/drivers/virtio/virtio_net.c b/plat/drivers/virtio/virtio_net.c
> index b0663e60..0e748b8f 100644
> --- a/plat/drivers/virtio/virtio_net.c
> +++ b/plat/drivers/virtio/virtio_net.c
> @@ -770,6 +770,7 @@ static int virtio_netdev_rxq_info_get(struct uk_netdev *dev,
>   	rxq = &vndev->rxqs[queue_id];
>   	qinfo->nb_min = 1;
>   	qinfo->nb_max = rxq->max_nb_desc;
> +	qinfo->nb_align = sizeof(void *); /* word size alignment */
>   	qinfo->nb_is_power_of_two = 1;
>   
>   exit:
> @@ -797,6 +798,7 @@ static int virtio_netdev_txq_info_get(struct uk_netdev *dev,
>   	txq = &vndev->txqs[queue_id];
>   	qinfo->nb_min = 1;
>   	qinfo->nb_max = txq->max_nb_desc;
> +	qinfo->nb_align = sizeof(void *); /* word size alignment */
>   	qinfo->nb_is_power_of_two = 1;
>   
>   exit:
> @@ -1048,6 +1050,7 @@ static void virtio_net_info_get(struct uk_netdev *dev,
>   
>   	dev_info->max_rx_queues = vndev->max_vqueue_pairs;
>   	dev_info->max_tx_queues = vndev->max_vqueue_pairs;
> +	dev_info->max_mtu = vndev->max_mtu;
>   	dev_info->nb_encap_tx = sizeof(struct virtio_net_hdr_padded);
>   	dev_info->nb_encap_rx = sizeof(struct virtio_net_hdr_padded);
>   	dev_info->features = UK_FEATURE_RXQ_INTR_AVAILABLE;


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:14:26 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:14:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10370.27597 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVYY4-00067W-MS; Thu, 22 Oct 2020 11:14:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10370.27597; Thu, 22 Oct 2020 11:14:24 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVYY4-00067P-JL; Thu, 22 Oct 2020 11:14:24 +0000
Received: by outflank-mailman (input) for mailman id 10370;
 Thu, 22 Oct 2020 11:14: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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVYY3-00066r-Pl
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:14:23 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a578ad68-df8e-4de9-8980-0676de904820;
 Thu, 22 Oct 2020 11:14:21 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 439BC104030;
 Thu, 22 Oct 2020 13:14:20 +0200 (CEST)
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 e0eQucv1BFge; Thu, 22 Oct 2020 13:14:20 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 13FC0103AE4;
 Thu, 22 Oct 2020 13:14:20 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:14:19 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVYY3-00066r-Pl
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:14:23 +0000
X-Inumbo-ID: a578ad68-df8e-4de9-8980-0676de904820
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id a578ad68-df8e-4de9-8980-0676de904820;
	Thu, 22 Oct 2020 11:14:21 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 439BC104030;
	Thu, 22 Oct 2020 13:14:20 +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 e0eQucv1BFge; Thu, 22 Oct 2020 13:14:20 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 13FC0103AE4;
	Thu, 22 Oct 2020 13:14:20 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:14:19 +0200
Subject: Re: [UNIKRAFT PATCH v4 05/12] plat/xen/drivers/net: Create netfront
 queues
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
CC: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-6-costin.lupu@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <c31212d2-05d2-9146-2986-3dc86728ac8d@neclab.eu>
Date: Thu, 22 Oct 2020 13:13:51 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20200813085342.29799-6-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Hello Costin,

I have a minor comments inline but the rest of it fine.

Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>


Thanks & Regards

Sharan

On 8/13/20 10:53 AM, Costin Lupu wrote:
> We continue with the device configuration by retrieving the Xenstore
> information regarding the number of queues and their associated event channels.
> Netfront devices operate pairs of Rx/Tx queues and for notifications we can
> either use a single event channel per pair or split event channels.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
> ---
>   plat/xen/drivers/net/netfront.c    | 81 ++++++++++++++++++++++++++++++
>   plat/xen/drivers/net/netfront.h    | 20 ++++++++
>   plat/xen/drivers/net/netfront_xs.c | 18 ++++++-
>   3 files changed, 117 insertions(+), 2 deletions(-)
>
> diff --git a/plat/xen/drivers/net/netfront.c b/plat/xen/drivers/net/netfront.c
> index 539e1cbc..ddbb4b70 100644
> --- a/plat/xen/drivers/net/netfront.c
> +++ b/plat/xen/drivers/net/netfront.c
> @@ -49,6 +49,84 @@
>   
>   static struct uk_alloc *drv_allocator;
>   
> +static int netfront_rxtx_alloc(struct netfront_dev *nfdev,
> +		const struct uk_netdev_conf *conf)
> +{
> +	int rc = 0;
> +
> +	if (conf->nb_tx_queues != conf->nb_rx_queues) {
> +		uk_pr_err("Different number of queues not supported\n");
> +		rc = -ENOTSUP;
> +		goto err_free_txrx;
> +	}
> +
> +	nfdev->max_queue_pairs =
> +		MIN(nfdev->max_queue_pairs, conf->nb_tx_queues);

Should we change the max_queue_pair to the user input or retain the max 
value provided by the system and use separate variable in the structure 
to store this?

> +
> +	nfdev->txqs = uk_calloc(drv_allocator,
> +		nfdev->max_queue_pairs, sizeof(*nfdev->txqs));
> +	if (unlikely(!nfdev->txqs)) {
> +		uk_pr_err("Failed to allocate memory for tx queues\n");
> +		rc = -ENOMEM;
> +		goto err_free_txrx;
> +	}
> +
> +	nfdev->rxqs = uk_calloc(drv_allocator,
> +		nfdev->max_queue_pairs, sizeof(*nfdev->rxqs));
> +	if (unlikely(!nfdev->rxqs)) {
> +		uk_pr_err("Failed to allocate memory for rx queues\n");
> +		rc = -ENOMEM;
> +		goto err_free_txrx;
> +	}
> +
> +	return rc;
> +
> +err_free_txrx:
> +	if (!nfdev->rxqs)
> +		uk_free(drv_allocator, nfdev->rxqs);
> +	if (!nfdev->txqs)
> +		uk_free(drv_allocator, nfdev->txqs);
> +
> +	return rc;
> +}
> +
> +static int netfront_configure(struct uk_netdev *n,
> +		const struct uk_netdev_conf *conf)
> +{
> +	int rc;
> +	struct netfront_dev *nfdev;
> +
> +	UK_ASSERT(n != NULL);
> +	UK_ASSERT(conf != NULL);
> +
> +	nfdev = to_netfront_dev(n);
> +
> +	rc = netfront_rxtx_alloc(nfdev, conf);
> +	if (rc != 0) {
> +		uk_pr_err("Failed to allocate rx and tx rings %d\n", rc);
> +		goto out;
> +	}
> +
> +out:
> +	return rc;
> +}
> +
> +static void netfront_info_get(struct uk_netdev *n,
> +		struct uk_netdev_info *dev_info)
> +{
> +	struct netfront_dev *nfdev;
> +
> +	UK_ASSERT(n != NULL);
> +	UK_ASSERT(dev_info != NULL);
> +
> +	nfdev = to_netfront_dev(n);
> +	dev_info->max_rx_queues = nfdev->max_queue_pairs;
> +	dev_info->max_tx_queues = nfdev->max_queue_pairs;
> +	dev_info->max_mtu = nfdev->mtu;
> +	dev_info->nb_encap_tx = 0;
> +	dev_info->nb_encap_rx = 0;
> +}
> +
>   static const void *netfront_einfo_get(struct uk_netdev *n,
>   		enum uk_netdev_einfo_type einfo_type)
>   {
> @@ -100,6 +178,8 @@ static unsigned int netfront_promisc_get(struct uk_netdev *n)
>   }
>   
>   static const struct uk_netdev_ops netfront_ops = {
> +	.configure = netfront_configure,
> +	.info_get = netfront_info_get,
>   	.einfo_get = netfront_einfo_get,
>   	.hwaddr_get = netfront_mac_get,
>   	.mtu_get = netfront_mtu_get,
> @@ -121,6 +201,7 @@ static int netfront_add_dev(struct xenbus_device *xendev)
>   
>   	nfdev->xendev = xendev;
>   	nfdev->mtu = ETH_PKT_PAYLOAD_LEN;
> +	nfdev->max_queue_pairs = 1;
>   
>   	/* Xenbus initialization */
>   	rc = netfront_xb_init(nfdev, drv_allocator);
> diff --git a/plat/xen/drivers/net/netfront.h b/plat/xen/drivers/net/netfront.h
> index 0cc8230b..a811b092 100644
> --- a/plat/xen/drivers/net/netfront.h
> +++ b/plat/xen/drivers/net/netfront.h
> @@ -38,6 +38,18 @@
>   
>   #include <uk/netdev.h>
>   
> +/**
> + * internal structure to represent the transmit queue.
> + */
> +struct uk_netdev_tx_queue {
> +};
> +
> +/**
> + * internal structure to represent the receive queue.
> + */
> +struct uk_netdev_rx_queue {
> +};
> +
>   struct xs_econf {
>   	char *ipv4addr;
>   	char *ipv4mask;
> @@ -50,6 +62,14 @@ struct netfront_dev {
>   	/* Network device */
>   	struct uk_netdev netdev;
>   
> +	/* List of the Rx/Tx queues */
> +	struct uk_netdev_tx_queue *txqs;
> +	struct uk_netdev_rx_queue *rxqs;
> +	/* Maximum number of queue pairs */
> +	uint16_t  max_queue_pairs;
> +	/* True if using split event channels */
> +	bool split_evtchn;
> +
>   	/* Configuration parameters */
>   	struct xs_econf econf;
>   
> diff --git a/plat/xen/drivers/net/netfront_xs.c b/plat/xen/drivers/net/netfront_xs.c
> index 48f01b34..1bde44e0 100644
> --- a/plat/xen/drivers/net/netfront_xs.c
> +++ b/plat/xen/drivers/net/netfront_xs.c
> @@ -122,7 +122,7 @@ out_err:
>   int netfront_xb_init(struct netfront_dev *nfdev, struct uk_alloc *a)
>   {
>   	struct xenbus_device *xendev;
> -	char *mac_str, *p, *ip_str;
> +	char *mac_str, *p, *ip_str, *int_str;
>   	int rc;
>   
>   	UK_ASSERT(nfdev != NULL);
> @@ -173,7 +173,21 @@ int netfront_xb_init(struct netfront_dev *nfdev, struct uk_alloc *a)
>   		goto no_conf;
>   	free(ip_str);
>   
> -	/* TODO spit event channels */
> +	/* maximum queues number */
> +	int_str = xs_read(XBT_NIL, xendev->otherend,
> +		"multi-queue-max-queues");
> +	if (!PTRISERR(int_str)) {
> +		nfdev->max_queue_pairs = (uint16_t) strtoul(int_str, NULL, 10);
> +		free(int_str);
> +	}
> +
> +	/* spit event channels */
> +	int_str = xs_read(XBT_NIL, xendev->otherend,
> +		"feature-split-event-channels");
> +	if (!PTRISERR(int_str)) {
> +		nfdev->split_evtchn = (bool) strtoul(int_str, NULL, 10);
> +		free(int_str);
> +	}
>   
>   	/* TODO netmap */
>   


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:54:18 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:54:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10381.27631 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZAf-0001mI-6e; Thu, 22 Oct 2020 11:54:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10381.27631; Thu, 22 Oct 2020 11:54:17 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZAf-0001mB-3m; Thu, 22 Oct 2020 11:54:17 +0000
Received: by outflank-mailman (input) for mailman id 10381;
 Thu, 22 Oct 2020 11:54: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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVZAe-0001m6-86
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:54:16 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 92c8b892-f672-4291-9851-8ebdfc5dffd1;
 Thu, 22 Oct 2020 11:54:14 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 2F048F20C6;
 Thu, 22 Oct 2020 13:54:13 +0200 (CEST)
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 kkkemr0sBwpM; Thu, 22 Oct 2020 13:54:13 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 023CFF20AF;
 Thu, 22 Oct 2020 13:54:07 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:54:06 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVZAe-0001m6-86
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:54:16 +0000
X-Inumbo-ID: 92c8b892-f672-4291-9851-8ebdfc5dffd1
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 92c8b892-f672-4291-9851-8ebdfc5dffd1;
	Thu, 22 Oct 2020 11:54:14 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 2F048F20C6;
	Thu, 22 Oct 2020 13:54:13 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
	by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id kkkemr0sBwpM; Thu, 22 Oct 2020 13:54:13 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 023CFF20AF;
	Thu, 22 Oct 2020 13:54:07 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:54:06 +0200
Subject: Re: [UNIKRAFT PATCH v4 06/12] plat/xen/drivers/net: Configure
 netfront tx queue
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
CC: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-7-costin.lupu@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <0f8e24f0-0827-e1c7-6891-6e83193864ec@neclab.eu>
Date: Thu, 22 Oct 2020 13:53:28 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20200813085342.29799-7-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Please find the comments inline:

Thanks & Regards

Sharan

On 8/13/20 10:53 AM, Costin Lupu wrote:
> For each queue, either rx or tx, the packets references are kept in a Xen
> shared ring. This patch introduces the initialization of tx shared ring. Each
> time the driver will send a packet it will add a request on the tx shared ring
> which will be serviced by the backend. Therefore we need to keep track of the
> requests by keeping track of their IDs. Because our resources are limited, we
> will maintain a pool of IDs (see `freelist` array) for this purpose.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
> ---
>   plat/xen/drivers/net/netfront.c | 108 ++++++++++++++++++++++++++++++++
>   plat/xen/drivers/net/netfront.h |  30 +++++++++
>   2 files changed, 138 insertions(+)
>
> diff --git a/plat/xen/drivers/net/netfront.c b/plat/xen/drivers/net/netfront.c
> index ddbb4b70..3c936743 100644
> --- a/plat/xen/drivers/net/netfront.c
> +++ b/plat/xen/drivers/net/netfront.c
> @@ -33,10 +33,12 @@
>    * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
>    */
>   
> +#include <string.h>
>   #include <uk/assert.h>
>   #include <uk/print.h>
>   #include <uk/alloc.h>
>   #include <uk/netdev_driver.h>
> +#include <xen-x86/mm.h>
>   #include <xenbus/xenbus.h>
>   #include "netfront.h"
>   #include "netfront_xb.h"
> @@ -49,6 +51,83 @@
>   
>   static struct uk_alloc *drv_allocator;
>   
> +
> +static void add_id_to_freelist(uint16_t id, uint16_t *freelist)
> +{
> +	freelist[id + 1] = freelist[0];
> +	freelist[0]  = id;
> +}
> +
> +static uint16_t get_id_from_freelist(uint16_t *freelist)
> +{
> +	uint16_t id;
> +
> +	id = freelist[0];
> +	freelist[0] = freelist[id + 1];
> +	return id;
> +}
> +
> +static struct uk_netdev_tx_queue *netfront_txq_setup(struct uk_netdev *n,
> +		uint16_t queue_id,
> +		uint16_t nb_desc __unused,
> +		struct uk_netdev_txqueue_conf *conf __unused)
> +{
> +	int rc;
> +	struct netfront_dev *nfdev;
> +	struct uk_netdev_tx_queue *txq;
> +	netif_tx_sring_t *sring;
> +
> +	UK_ASSERT(n != NULL);
> +
> +	nfdev = to_netfront_dev(n);
> +	if (queue_id >= nfdev->max_queue_pairs) {
> +		uk_pr_err("Invalid queue identifier: %"__PRIu16"\n", queue_id);
> +		return ERR2PTR(-EINVAL);
> +	}
> +
> +	txq  = &nfdev->txqs[queue_id];
> +	UK_ASSERT(!txq->initialized);
> +	txq->netfront_dev = nfdev;
> +	txq->lqueue_id = queue_id;
> +
> +	/* Setup shared ring */
> +	sring = uk_palloc(drv_allocator, 1);

Shouldn't the allocator from the txqueue_conf be used here while

setting up the ring

> +	if (!sring)
> +		return ERR2PTR(-ENOMEM);
> +	memset(sring, 0, PAGE_SIZE);
> +	SHARED_RING_INIT(sring);
> +	FRONT_RING_INIT(&txq->ring, sring, PAGE_SIZE);
> +	txq->ring_size = NET_TX_RING_SIZE;
> +	txq->ring_ref = gnttab_grant_access(nfdev->xendev->otherend_id,
> +		virt_to_mfn(sring), 0);
> +	UK_ASSERT(txq->ring_ref != GRANT_INVALID_REF);
> +
> +	/* Setup event channel */
> +	rc = evtchn_alloc_unbound(nfdev->xendev->otherend_id,
> +			NULL, NULL,
> +			&txq->evtchn);
> +	if (rc) {
> +		uk_pr_err("Error creating event channel: %d\n", rc);
> +		gnttab_end_access(txq->ring_ref);
> +		uk_pfree(drv_allocator, sring, 1);
> +		return ERR2PTR(-rc);
> +	}
> +	/* Events are always disabled for tx queue */
> +	mask_evtchn(txq->evtchn);
> +
> +	/* Initialize list of request ids */
> +	uk_semaphore_init(&txq->sem, NET_TX_RING_SIZE);
> +	for (uint16_t i = 0; i < NET_TX_RING_SIZE; i++) {
> +		add_id_to_freelist(i, txq->freelist);
> +		txq->gref[i] = GRANT_INVALID_REF;
> +	}
> +
> +	txq->initialized = true;
> +	nfdev->txqs_num++;
> +
> +	return txq;
> +}
> +
>   static int netfront_rxtx_alloc(struct netfront_dev *nfdev,
>   		const struct uk_netdev_conf *conf)
>   {
> @@ -90,6 +169,33 @@ err_free_txrx:
>   	return rc;
>   }
>   
> +static int netfront_txq_info_get(struct uk_netdev *n,
> +		uint16_t queue_id,
> +		struct uk_netdev_queue_info *qinfo)
> +{
> +	struct netfront_dev *nfdev;
> +	struct uk_netdev_tx_queue *txq;
> +	int rc = 0;
> +
> +	UK_ASSERT(n != NULL);
> +	UK_ASSERT(qinfo != NULL);
> +
> +	nfdev = to_netfront_dev(n);
> +	if (unlikely(queue_id >= nfdev->txqs_num)) {

txqs_num is updated only after the queue is configured. The

txq_info_get should be called before the txq_configure. This

would provide the user of netdev the information needed to

configure the txq.

> +		uk_pr_err("Invalid queue_id %"__PRIu16"\n", queue_id);
> +		rc = -EINVAL;
> +		goto exit;
> +	}
> +	txq = &nfdev->txqs[queue_id];
> +	qinfo->nb_min = txq->ring_size;
> +	qinfo->nb_max = txq->ring_size;
> +	qinfo->nb_align = PAGE_SIZE;
> +	qinfo->nb_is_power_of_two = 1;
> +
> +exit:
> +	return rc;
> +}
> +
>   static int netfront_configure(struct uk_netdev *n,
>   		const struct uk_netdev_conf *conf)
>   {
> @@ -179,6 +285,8 @@ static unsigned int netfront_promisc_get(struct uk_netdev *n)
>   
>   static const struct uk_netdev_ops netfront_ops = {
>   	.configure = netfront_configure,
> +	.txq_configure = netfront_txq_setup,
> +	.txq_info_get = netfront_txq_info_get,
>   	.info_get = netfront_info_get,
>   	.einfo_get = netfront_einfo_get,
>   	.hwaddr_get = netfront_mac_get,
> diff --git a/plat/xen/drivers/net/netfront.h b/plat/xen/drivers/net/netfront.h
> index a811b092..d3f603b3 100644
> --- a/plat/xen/drivers/net/netfront.h
> +++ b/plat/xen/drivers/net/netfront.h
> @@ -37,11 +37,40 @@
>   #define __NETFRONT_H__
>   
>   #include <uk/netdev.h>
> +#include <uk/semaphore.h>
> +#include <xen/io/netif.h>
> +#include <common/gnttab.h>
> +#include <common/events.h>
> +
> +
> +#define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE)
>   
>   /**
>    * internal structure to represent the transmit queue.
>    */
>   struct uk_netdev_tx_queue {
> +	/* The netfront device */
> +	struct netfront_dev *netfront_dev;
> +	/* The libuknet queue identifier */
> +	uint16_t lqueue_id;
> +	/* True if initialized */
> +	bool initialized;
> +
> +	/* Shared ring size */
> +	uint16_t ring_size;
> +	/* Shared ring */
> +	netif_tx_front_ring_t ring;
> +	/* Shared ring grant ref */
> +	grant_ref_t ring_ref;
> +	/* Queue event channel */
> +	evtchn_port_t evtchn;
> +
> +	/* Free list protecting semaphore */
> +	struct uk_semaphore sem;
> +	/* Free list of transmitting request IDs */
> +	uint16_t freelist[NET_TX_RING_SIZE + 1];
> +	/* Grants for transmit buffers */
> +	grant_ref_t gref[NET_TX_RING_SIZE];
>   };
>   
>   /**
> @@ -63,6 +92,7 @@ struct netfront_dev {
>   	struct uk_netdev netdev;
>   
>   	/* List of the Rx/Tx queues */
> +	uint16_t txqs_num;
>   	struct uk_netdev_tx_queue *txqs;
>   	struct uk_netdev_rx_queue *rxqs;
>   	/* Maximum number of queue pairs */


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:55:22 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:55:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10384.27636 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZBh-0001oG-Af; Thu, 22 Oct 2020 11:55:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10384.27636; Thu, 22 Oct 2020 11:55:21 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZBh-0001o9-7j; Thu, 22 Oct 2020 11:55:21 +0000
Received: by outflank-mailman (input) for mailman id 10384;
 Thu, 22 Oct 2020 11:55: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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVZBg-0001o4-88
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:55:20 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 2f88f588-76f3-4d6a-b568-e64948fffbdf;
 Thu, 22 Oct 2020 11:55:17 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 127C41041CE;
 Thu, 22 Oct 2020 13:55:17 +0200 (CEST)
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 LsJdePrDcw5b; Thu, 22 Oct 2020 13:55:16 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id E2F901041A0
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:55:16 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:55:16 +0200
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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVZBg-0001o4-88
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:55:20 +0000
X-Inumbo-ID: 2f88f588-76f3-4d6a-b568-e64948fffbdf
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 2f88f588-76f3-4d6a-b568-e64948fffbdf;
	Thu, 22 Oct 2020 11:55:17 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 127C41041CE;
	Thu, 22 Oct 2020 13:55:17 +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 LsJdePrDcw5b; Thu, 22 Oct 2020 13:55:16 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id E2F901041A0
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:55:16 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:55:16 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 0/7] lib/ukblkdev: Minor API improvements and fixes
Date: Thu, 22 Oct 2020 13:55:00 +0200
Message-ID: <20201022115507.4983-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 titania.office.hd
 (192.168.24.89)

This series consists of a number of minor improvements and
fixes of the ukblkdev API. This is mainly done to inline
the ukblkdev API with the uknetdev API.

Simon Kuenzer (7):
  lib/ukblkdev: blkdev.h: Include <uk/assert.h>
  lib/ukblkdev: blkreq.h: Include <uk/arch/atomic.h>
  lib/ukblkdev: blkreq.h: Use typedef for __sector
  lib/ukblkdev: blkreq.h: Use UK_BLKREQ_ prefix for states and ops
  lib/ukblkdev: API refactoring: `uk_blkdev_queue_configure()`
  lib/ukblkdev: Provide `uk_blkdev_size()`
  lib/ukblkdev: blkdev.h: Description about interrupts

 lib/ukblkdev/blkdev.c                   | 16 ++++++++--------
 lib/ukblkdev/exportsyms.uk              |  2 +-
 lib/ukblkdev/include/uk/blkdev.h        | 19 ++++++++++++-------
 lib/ukblkdev/include/uk/blkdev_core.h   |  6 +++---
 lib/ukblkdev/include/uk/blkdev_driver.h |  2 +-
 lib/ukblkdev/include/uk/blkreq.h        | 21 +++++++++++++--------
 plat/drivers/virtio/virtio_blk.c        | 16 ++++++++--------
 plat/xen/drivers/blk/blkfront.c         | 14 +++++++-------
 8 files changed, 53 insertions(+), 43 deletions(-)

-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:56:26 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:56:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10387.27639 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZCk-0001ql-Eb; Thu, 22 Oct 2020 11:56:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10387.27639; Thu, 22 Oct 2020 11:56:26 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZCk-0001qe-Bc; Thu, 22 Oct 2020 11:56:26 +0000
Received: by outflank-mailman (input) for mailman id 10387;
 Thu, 22 Oct 2020 11:56: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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVZCj-0001qZ-89
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:25 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 018de765-87e9-49f0-830f-ef0a7b4b2d0e;
 Thu, 22 Oct 2020 11:56:24 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 3446EF20C6;
 Thu, 22 Oct 2020 13:56:23 +0200 (CEST)
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 6Sujo6TEzFb5; Thu, 22 Oct 2020 13:56:23 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 0C43FF20AF
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:21 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:20 +0200
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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVZCj-0001qZ-89
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:25 +0000
X-Inumbo-ID: 018de765-87e9-49f0-830f-ef0a7b4b2d0e
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 018de765-87e9-49f0-830f-ef0a7b4b2d0e;
	Thu, 22 Oct 2020 11:56:24 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 3446EF20C6;
	Thu, 22 Oct 2020 13:56: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 6Sujo6TEzFb5; Thu, 22 Oct 2020 13:56:23 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 0C43FF20AF
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:21 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:20 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 1/7] lib/ukblkdev: blkdev.h: Include <uk/assert.h>
Date: Thu, 22 Oct 2020 13:55:01 +0200
Message-ID: <20201022115507.4983-2-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
References: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

The header `blkdev.h` uses UK_ASSERT but did not include
`<uk/assert.h>`.

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

diff --git a/lib/ukblkdev/include/uk/blkdev.h b/lib/ukblkdev/include/uk/blkdev.h
index c8de0038..7aa09909 100644
--- a/lib/ukblkdev/include/uk/blkdev.h
+++ b/lib/ukblkdev/include/uk/blkdev.h
@@ -66,6 +66,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <limits.h>
+#include <uk/assert.h>
 #include <uk/list.h>
 #include <uk/errptr.h>
 
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:56:27 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:56:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10388.27644 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZCl-0001rO-GE; Thu, 22 Oct 2020 11:56:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10388.27644; Thu, 22 Oct 2020 11:56:27 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZCl-0001rH-D4; Thu, 22 Oct 2020 11:56:27 +0000
Received: by outflank-mailman (input) for mailman id 10388;
 Thu, 22 Oct 2020 11:56: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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVZCl-0001rC-1N
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:27 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 5e125d82-b128-4c22-bcaa-e84c8d9ef0f6;
 Thu, 22 Oct 2020 11:56:26 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 41D39F20C6;
 Thu, 22 Oct 2020 13:56:25 +0200 (CEST)
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 q4sYHw6DmYSm; Thu, 22 Oct 2020 13:56:25 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 18891F20AF
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:23 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:22 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVZCl-0001rC-1N
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:27 +0000
X-Inumbo-ID: 5e125d82-b128-4c22-bcaa-e84c8d9ef0f6
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 5e125d82-b128-4c22-bcaa-e84c8d9ef0f6;
	Thu, 22 Oct 2020 11:56:26 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 41D39F20C6;
	Thu, 22 Oct 2020 13:56:25 +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 q4sYHw6DmYSm; Thu, 22 Oct 2020 13:56:25 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 18891F20AF
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:23 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:22 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 2/7] lib/ukblkdev: blkreq.h: Include <uk/arch/atomic.h>
Date: Thu, 22 Oct 2020 13:55:02 +0200
Message-ID: <20201022115507.4983-3-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
References: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

The header `blkreq.h` uses atomic operations but did not include
`<uk/arch/atomic.h>`.

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

diff --git a/lib/ukblkdev/include/uk/blkreq.h b/lib/ukblkdev/include/uk/blkreq.h
index 2c4b9b99..17daa6b5 100644
--- a/lib/ukblkdev/include/uk/blkreq.h
+++ b/lib/ukblkdev/include/uk/blkreq.h
@@ -48,6 +48,8 @@ extern "C" {
 #endif
 
 #define __sector size_t
+#include <uk/arch/atomic.h>
+
 struct uk_blkreq;
 
 /**
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:56:38 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:56:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10389.27648 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZCw-0001tI-Hn; Thu, 22 Oct 2020 11:56:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10389.27648; Thu, 22 Oct 2020 11:56:38 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZCw-0001tB-Eq; Thu, 22 Oct 2020 11:56:38 +0000
Received: by outflank-mailman (input) for mailman id 10389;
 Thu, 22 Oct 2020 11:56:37 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVZCv-0001sv-Af
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:37 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 4a900074-4f94-4153-b64a-a057482dabac;
 Thu, 22 Oct 2020 11:56:35 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id D7C791040D5;
 Thu, 22 Oct 2020 13:56:34 +0200 (CEST)
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 SzjwAplRCwOv; Thu, 22 Oct 2020 13:56:34 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id B7953103AE4
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:34 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:34 +0200
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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVZCv-0001sv-Af
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:37 +0000
X-Inumbo-ID: 4a900074-4f94-4153-b64a-a057482dabac
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 4a900074-4f94-4153-b64a-a057482dabac;
	Thu, 22 Oct 2020 11:56:35 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id D7C791040D5;
	Thu, 22 Oct 2020 13:56: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 SzjwAplRCwOv; Thu, 22 Oct 2020 13:56:34 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id B7953103AE4
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:34 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:34 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 3/7] lib/ukblkdev: blkreq.h: Use typedef for __sector
Date: Thu, 22 Oct 2020 13:55:03 +0200
Message-ID: <20201022115507.4983-4-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
References: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Introduces `__sector` with a type definition instead with an alias macro.
This is done for consistency reasons. Additionally, the print format macro
`__PRIsctr` is introduced so that a sector number can be printed
correctly.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukblkdev/include/uk/blkreq.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/ukblkdev/include/uk/blkreq.h b/lib/ukblkdev/include/uk/blkreq.h
index 17daa6b5..5b1b5f13 100644
--- a/lib/ukblkdev/include/uk/blkreq.h
+++ b/lib/ukblkdev/include/uk/blkreq.h
@@ -47,9 +47,12 @@
 extern "C" {
 #endif
 
-#define __sector size_t
+#include <uk/arch/limits.h>
 #include <uk/arch/atomic.h>
 
+typedef __sz __sector;
+#define __PRIsctr __PRIsz
+
 struct uk_blkreq;
 
 /**
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:56:41 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:56:41 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10391.27652 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZCz-0001uD-JU; Thu, 22 Oct 2020 11:56:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10391.27652; Thu, 22 Oct 2020 11:56:41 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZCz-0001u5-GI; Thu, 22 Oct 2020 11:56:41 +0000
Received: by outflank-mailman (input) for mailman id 10391;
 Thu, 22 Oct 2020 11:56: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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVZCy-0001tt-Ek
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:40 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 6aff7a32-0e23-4893-8534-4bf59d17a5a4;
 Thu, 22 Oct 2020 11:56:39 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 7F7FDF20C6;
 Thu, 22 Oct 2020 13:56:38 +0200 (CEST)
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 kdRy5i-dEZEW; Thu, 22 Oct 2020 13:56:38 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 57AEDF20AF
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:36 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:35 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVZCy-0001tt-Ek
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:40 +0000
X-Inumbo-ID: 6aff7a32-0e23-4893-8534-4bf59d17a5a4
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 6aff7a32-0e23-4893-8534-4bf59d17a5a4;
	Thu, 22 Oct 2020 11:56:39 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 7F7FDF20C6;
	Thu, 22 Oct 2020 13:56:38 +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 kdRy5i-dEZEW; Thu, 22 Oct 2020 13:56:38 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 57AEDF20AF
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:36 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:35 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 4/7] lib/ukblkdev: blkreq.h: Use UK_BLKREQ_ prefix for states and ops
Date: Thu, 22 Oct 2020 13:55:04 +0200
Message-ID: <20201022115507.4983-5-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
References: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Instead of using `UK_BLKDEV_REQ_` prefix for `struct uk_blkreq`
states (finished, unfinished) and `UK_BLKDEV_` prefix for operation
requests (read, write, flush) this commits simplifies the API by using
the `UK_BLKREQ_` prefix.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukblkdev/include/uk/blkdev.h        | 10 +++++-----
 lib/ukblkdev/include/uk/blkdev_driver.h |  2 +-
 lib/ukblkdev/include/uk/blkreq.h        | 14 +++++++-------
 plat/drivers/virtio/virtio_blk.c        | 12 ++++++------
 plat/xen/drivers/blk/blkfront.c         | 10 +++++-----
 5 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/lib/ukblkdev/include/uk/blkdev.h b/lib/ukblkdev/include/uk/blkdev.h
index 7aa09909..abc228d9 100644
--- a/lib/ukblkdev/include/uk/blkdev.h
+++ b/lib/ukblkdev/include/uk/blkdev.h
@@ -459,18 +459,18 @@ int uk_blkdev_sync_io(struct uk_blkdev *dev,
 		sector,		\
 		nb_sectors,	\
 		buf)		\
-	uk_blkdev_sync_io(blkdev, queue_id, UK_BLKDEV_WRITE, sector, \
-			nb_sectors, buf) \
+	uk_blkdev_sync_io(blkdev, queue_id, UK_BLKREQ_WRITE, sector, \
+			  nb_sectors, buf)			     \
 
 #define uk_blkdev_sync_read(blkdev,\
 		queue_id,	\
 		sector,		\
 		nb_sectors,	\
 		buf)		\
-	uk_blkdev_sync_io(blkdev, queue_id, UK_BLKDEV_READ, sector, \
-			nb_sectors, buf) \
+	uk_blkdev_sync_io(blkdev, queue_id, UK_BLKREQ_READ, sector, \
+			  nb_sectors, buf)			    \
 
-#endif
+#endif /* CONFIG_LIBUKBLKDEV_SYNC_IO_BLOCKED_WAITING */
 
 /**
  * Stop a Unikraft block device, and set its state to UK_BLKDEV_CONFIGURED
diff --git a/lib/ukblkdev/include/uk/blkdev_driver.h b/lib/ukblkdev/include/uk/blkdev_driver.h
index be807069..cb1b3ba3 100644
--- a/lib/ukblkdev/include/uk/blkdev_driver.h
+++ b/lib/ukblkdev/include/uk/blkdev_driver.h
@@ -104,7 +104,7 @@ static inline void uk_blkdev_drv_queue_event(struct uk_blkdev *dev,
  *	uk_blkreq structure
  */
 #define uk_blkreq_finished(req) \
-	(ukarch_store_n(&(req)->state.counter, UK_BLKDEV_REQ_FINISHED))
+	(ukarch_store_n(&(req)->state.counter, UK_BLKREQ_FINISHED))
 
 /**
  * Frees the data allocated for the Unikraft Block Device.
diff --git a/lib/ukblkdev/include/uk/blkreq.h b/lib/ukblkdev/include/uk/blkreq.h
index 5b1b5f13..dce76424 100644
--- a/lib/ukblkdev/include/uk/blkreq.h
+++ b/lib/ukblkdev/include/uk/blkreq.h
@@ -59,8 +59,8 @@ struct uk_blkreq;
  *	Operation status
  */
 enum uk_blkreq_state {
-	UK_BLKDEV_REQ_FINISHED = 0,
-	UK_BLKDEV_REQ_UNFINISHED
+	UK_BLKREQ_FINISHED = 0,
+	UK_BLKREQ_UNFINISHED
 };
 
 /**
@@ -68,11 +68,11 @@ enum uk_blkreq_state {
  */
 enum uk_blkreq_op {
 	/* Read operation */
-	UK_BLKDEV_READ = 0,
+	UK_BLKREQ_READ = 0,
 	/* Write operation */
-	UK_BLKDEV_WRITE,
+	UK_BLKREQ_WRITE,
 	/* Flush the volatile write cache */
-	UK_BLKDEV_FFLUSH = 4
+	UK_BLKREQ_FFLUSH = 4
 };
 
 /**
@@ -136,7 +136,7 @@ static inline void uk_blkreq_init(struct uk_blkreq *req,
 	req->start_sector = start;
 	req->nb_sectors = nb_sectors;
 	req->aio_buf = aio_buf;
-	ukarch_store_n(&req->state.counter, UK_BLKDEV_REQ_UNFINISHED);
+	ukarch_store_n(&req->state.counter, UK_BLKREQ_UNFINISHED);
 	req->cb = cb;
 	req->cb_cookie = cb_cookie;
 }
@@ -148,7 +148,7 @@ static inline void uk_blkreq_init(struct uk_blkreq *req,
  *	uk_blkreq structure
  **/
 #define uk_blkreq_is_done(req) \
-		(ukarch_load_n(&(req)->state.counter) == UK_BLKDEV_REQ_FINISHED)
+		(ukarch_load_n(&(req)->state.counter) == UK_BLKREQ_FINISHED)
 
 #ifdef __cplusplus
 }
diff --git a/plat/drivers/virtio/virtio_blk.c b/plat/drivers/virtio/virtio_blk.c
index ff33cc11..262355b4 100644
--- a/plat/drivers/virtio/virtio_blk.c
+++ b/plat/drivers/virtio/virtio_blk.c
@@ -186,7 +186,7 @@ static int virtio_blkdev_request_write(struct uk_blkdev_queue *queue,
 	vbdev = queue->vbd;
 	cap = &vbdev->blkdev.capabilities;
 	req = virtio_blk_req->req;
-	if (req->operation == UK_BLKDEV_WRITE &&
+	if (req->operation == UK_BLKREQ_WRITE &&
 			cap->mode == O_RDONLY)
 		return -EPERM;
 
@@ -209,11 +209,11 @@ static int virtio_blkdev_request_write(struct uk_blkdev_queue *queue,
 		goto out;
 	}
 
-	if (req->operation == UK_BLKDEV_WRITE) {
+	if (req->operation == UK_BLKREQ_WRITE) {
 		*read_segs = queue->sg.sg_nseg - 1;
 		*write_segs = 1;
 		virtio_blk_req->virtio_blk_outhdr.type = VIRTIO_BLK_T_OUT;
-	} else if (req->operation == UK_BLKDEV_READ) {
+	} else if (req->operation == UK_BLKREQ_READ) {
 		*read_segs = 1;
 		*write_segs = queue->sg.sg_nseg - 1;
 		virtio_blk_req->virtio_blk_outhdr.type = VIRTIO_BLK_T_IN;
@@ -278,11 +278,11 @@ static int virtio_blkdev_queue_enqueue(struct uk_blkdev_queue *queue,
 
 	virtio_blk_req->req = req;
 	virtio_blk_req->virtio_blk_outhdr.sector = req->start_sector;
-	if (req->operation == UK_BLKDEV_WRITE ||
-			req->operation == UK_BLKDEV_READ)
+	if (req->operation == UK_BLKREQ_WRITE ||
+			req->operation == UK_BLKREQ_READ)
 		rc = virtio_blkdev_request_write(queue, virtio_blk_req,
 				&read_segs, &write_segs);
-	else if (req->operation == UK_BLKDEV_FFLUSH)
+	else if (req->operation == UK_BLKREQ_FFLUSH)
 		rc = virtio_blkdev_request_flush(queue, virtio_blk_req,
 				&read_segs, &write_segs);
 	else
diff --git a/plat/xen/drivers/blk/blkfront.c b/plat/xen/drivers/blk/blkfront.c
index 5cd5cf22..60b63466 100644
--- a/plat/xen/drivers/blk/blkfront.c
+++ b/plat/xen/drivers/blk/blkfront.c
@@ -250,7 +250,7 @@ static void blkif_request_init(struct blkif_request *ring_req,
 	UK_ASSERT(nb_segments <= BLKIF_MAX_SEGMENTS_PER_REQUEST);
 
 	/* Set ring request */
-	ring_req->operation = (req->operation == UK_BLKDEV_WRITE) ?
+	ring_req->operation = (req->operation == UK_BLKREQ_WRITE) ?
 			BLKIF_OP_WRITE : BLKIF_OP_READ;
 	ring_req->nr_segments = nb_segments;
 	ring_req->sector_number = req->start_sector;
@@ -281,7 +281,7 @@ static int blkfront_request_write(struct blkfront_request *blkfront_req,
 	dev = blkfront_req->queue->dev;
 	cap = &dev->blkdev.capabilities;
 	sector_size = cap->ssize;
-	if (req->operation == UK_BLKDEV_WRITE && cap->mode == O_RDONLY)
+	if (req->operation == UK_BLKREQ_WRITE && cap->mode == O_RDONLY)
 		return -EPERM;
 
 	if (req->aio_buf == NULL)
@@ -360,10 +360,10 @@ static int blkfront_queue_enqueue(struct uk_blkdev_queue *queue,
 	ring_req->id = (uintptr_t) blkfront_req;
 	ring_req->handle = dev->handle;
 
-	if (req->operation == UK_BLKDEV_READ ||
-			req->operation == UK_BLKDEV_WRITE)
+	if (req->operation == UK_BLKREQ_READ ||
+			req->operation == UK_BLKREQ_WRITE)
 		rc = blkfront_request_write(blkfront_req, ring_req);
-	else if (req->operation == UK_BLKDEV_FFLUSH)
+	else if (req->operation == UK_BLKREQ_FFLUSH)
 		rc =  blkfront_request_flush(blkfront_req, ring_req);
 	else
 		rc = -EINVAL;
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:56:53 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:56:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10394.27656 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZDB-0001w7-M4; Thu, 22 Oct 2020 11:56:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10394.27656; Thu, 22 Oct 2020 11:56:53 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZDB-0001w0-Iv; Thu, 22 Oct 2020 11:56:53 +0000
Received: by outflank-mailman (input) for mailman id 10394;
 Thu, 22 Oct 2020 11:56:52 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVZDA-0001vt-Rx
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:52 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 723b8cec-cd83-477a-9944-c1163ab052c2;
 Thu, 22 Oct 2020 11:56:51 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id DA5BEF20C6;
 Thu, 22 Oct 2020 13:56:50 +0200 (CEST)
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 7q3JjnksnG2n; Thu, 22 Oct 2020 13:56:50 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id B6268F20AF
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:48 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:48 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVZDA-0001vt-Rx
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:52 +0000
X-Inumbo-ID: 723b8cec-cd83-477a-9944-c1163ab052c2
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 723b8cec-cd83-477a-9944-c1163ab052c2;
	Thu, 22 Oct 2020 11:56:51 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id DA5BEF20C6;
	Thu, 22 Oct 2020 13:56:50 +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 7q3JjnksnG2n; Thu, 22 Oct 2020 13:56:50 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id B6268F20AF
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:48 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:48 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 5/7] lib/ukblkdev: API refactoring: `uk_blkdev_queue_configure()`
Date: Thu, 22 Oct 2020 13:55:05 +0200
Message-ID: <20201022115507.4983-6-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
References: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

For API consistency reasons, this patch renames `uk_blkdev_queue_setup()` to
`uk_blkdev_queue_configure()`. This is done to be inline with
lib/uknetdev. Additionally and as counterpart for queue configuration, we
rename `uk_blkdev_release()` to `uk_blkdev_unconfigure()`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukblkdev/blkdev.c                 | 16 ++++++++--------
 lib/ukblkdev/exportsyms.uk            |  2 +-
 lib/ukblkdev/include/uk/blkdev.h      |  2 +-
 lib/ukblkdev/include/uk/blkdev_core.h |  6 +++---
 plat/drivers/virtio/virtio_blk.c      |  4 ++--
 plat/xen/drivers/blk/blkfront.c       |  4 ++--
 6 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/ukblkdev/blkdev.c b/lib/ukblkdev/blkdev.c
index fc5038ba..9cafa0c4 100644
--- a/lib/ukblkdev/blkdev.c
+++ b/lib/ukblkdev/blkdev.c
@@ -82,7 +82,7 @@ int uk_blkdev_drv_register(struct uk_blkdev *dev, struct uk_alloc *a,
 	UK_ASSERT(dev->dev_ops);
 	UK_ASSERT(dev->dev_ops->dev_configure);
 	UK_ASSERT(dev->dev_ops->dev_start);
-	UK_ASSERT(dev->dev_ops->queue_setup);
+	UK_ASSERT(dev->dev_ops->queue_configure);
 	UK_ASSERT(dev->dev_ops->get_info);
 	UK_ASSERT(dev->dev_ops->queue_get_info);
 	UK_ASSERT(dev->submit_one);
@@ -313,7 +313,7 @@ int uk_blkdev_queue_configure(struct uk_blkdev *dev, uint16_t queue_id,
 	UK_ASSERT(dev);
 	UK_ASSERT(dev->_data);
 	UK_ASSERT(dev->dev_ops);
-	UK_ASSERT(dev->dev_ops->queue_setup);
+	UK_ASSERT(dev->dev_ops->queue_configure);
 	UK_ASSERT(dev->finish_reqs);
 	UK_ASSERT(queue_id < CONFIG_LIBUKBLKDEV_MAXNBQUEUES);
 	UK_ASSERT(queue_conf);
@@ -339,7 +339,7 @@ int uk_blkdev_queue_configure(struct uk_blkdev *dev, uint16_t queue_id,
 	if (err)
 		goto err_out;
 
-	dev->_queue[queue_id] = dev->dev_ops->queue_setup(dev, queue_id,
+	dev->_queue[queue_id] = dev->dev_ops->queue_configure(dev, queue_id,
 			nb_desc,
 			queue_conf);
 	if (PTRISERR(dev->_queue[queue_id])) {
@@ -493,21 +493,21 @@ int uk_blkdev_stop(struct uk_blkdev *dev)
 	return rc;
 }
 
-int uk_blkdev_queue_release(struct uk_blkdev *dev, uint16_t queue_id)
+int uk_blkdev_queue_unconfigure(struct uk_blkdev *dev, uint16_t queue_id)
 {
 	int rc = 0;
 
 	UK_ASSERT(dev != NULL);
 	UK_ASSERT(dev->_data);
 	UK_ASSERT(dev->dev_ops);
-	UK_ASSERT(dev->dev_ops->queue_release);
+	UK_ASSERT(dev->dev_ops->queue_unconfigure);
 	UK_ASSERT(queue_id < CONFIG_LIBUKBLKDEV_MAXNBQUEUES);
 	UK_ASSERT(dev->_data->state == UK_BLKDEV_CONFIGURED);
 	UK_ASSERT(!PTRISERR(dev->_queue[queue_id]));
 
-	rc = dev->dev_ops->queue_release(dev, dev->_queue[queue_id]);
+	rc = dev->dev_ops->queue_unconfigure(dev, dev->_queue[queue_id]);
 	if (rc)
-		uk_pr_err("Failed to release blkdev%"PRIu16"-q%"PRIu16": %d\n",
+		uk_pr_err("Failed to unconfigure blkdev%"PRIu16"-q%"PRIu16": %d\n",
 				dev->_data->id, queue_id, rc);
 	else {
 #if CONFIG_LIBUKBLKDEV_DISPATCHERTHREADS
@@ -515,7 +515,7 @@ int uk_blkdev_queue_release(struct uk_blkdev *dev, uint16_t queue_id)
 			_destroy_event_handler(
 					&dev->_data->queue_handler[queue_id]);
 #endif
-		uk_pr_info("Released blkdev%"PRIu16"-q%"PRIu16"\n",
+		uk_pr_info("Unconfigured blkdev%"PRIu16"-q%"PRIu16"\n",
 				dev->_data->id, queue_id);
 		dev->_queue[queue_id] = NULL;
 	}
diff --git a/lib/ukblkdev/exportsyms.uk b/lib/ukblkdev/exportsyms.uk
index f3be6c51..dd93e394 100644
--- a/lib/ukblkdev/exportsyms.uk
+++ b/lib/ukblkdev/exportsyms.uk
@@ -13,6 +13,6 @@ uk_blkdev_queue_submit_one
 uk_blkdev_queue_finish_reqs
 uk_blkdev_sync_io
 uk_blkdev_stop
-uk_blkdev_queue_release
+uk_blkdev_queue_unconfigure
 uk_blkdev_drv_unregister
 uk_blkdev_unconfigure
diff --git a/lib/ukblkdev/include/uk/blkdev.h b/lib/ukblkdev/include/uk/blkdev.h
index abc228d9..699b56bc 100644
--- a/lib/ukblkdev/include/uk/blkdev.h
+++ b/lib/ukblkdev/include/uk/blkdev.h
@@ -501,7 +501,7 @@ int uk_blkdev_stop(struct uk_blkdev *dev);
  *	- 0: Success
  *	- (<0): on error returned by driver
  */
-int uk_blkdev_queue_release(struct uk_blkdev *dev, uint16_t queue_id);
+int uk_blkdev_queue_unconfigure(struct uk_blkdev *dev, uint16_t queue_id);
 
 /**
  * Close a stopped Unikraft block device.
diff --git a/lib/ukblkdev/include/uk/blkdev_core.h b/lib/ukblkdev/include/uk/blkdev_core.h
index 56632c7f..11a642c4 100644
--- a/lib/ukblkdev/include/uk/blkdev_core.h
+++ b/lib/ukblkdev/include/uk/blkdev_core.h
@@ -207,7 +207,7 @@ typedef int (*uk_blkdev_queue_finish_reqs_t)(struct uk_blkdev *dev,
 typedef int (*uk_blkdev_stop_t)(struct uk_blkdev *dev);
 
 /** Driver callback type to release a queue of an Unikraft block device. */
-typedef int (*uk_blkdev_queue_release_t)(struct uk_blkdev *dev,
+typedef int (*uk_blkdev_queue_unconfigure_t)(struct uk_blkdev *dev,
 		struct uk_blkdev_queue *queue);
 
 /** Driver callback type to unconfigure an Unikraft block device. */
@@ -217,12 +217,12 @@ struct uk_blkdev_ops {
 	uk_blkdev_get_info_t				get_info;
 	uk_blkdev_configure_t				dev_configure;
 	uk_blkdev_queue_get_info_t			queue_get_info;
-	uk_blkdev_queue_configure_t			queue_setup;
+	uk_blkdev_queue_configure_t			queue_configure;
 	uk_blkdev_start_t				dev_start;
 	uk_blkdev_stop_t				dev_stop;
 	uk_blkdev_queue_intr_enable_t			queue_intr_enable;
 	uk_blkdev_queue_intr_disable_t			queue_intr_disable;
-	uk_blkdev_queue_release_t			queue_release;
+	uk_blkdev_queue_unconfigure_t			queue_unconfigure;
 	uk_blkdev_unconfigure_t				dev_unconfigure;
 };
 
diff --git a/plat/drivers/virtio/virtio_blk.c b/plat/drivers/virtio/virtio_blk.c
index 262355b4..dac8eb38 100644
--- a/plat/drivers/virtio/virtio_blk.c
+++ b/plat/drivers/virtio/virtio_blk.c
@@ -861,12 +861,12 @@ static const struct uk_blkdev_ops virtio_blkdev_ops = {
 		.get_info = virtio_blkdev_get_info,
 		.dev_configure = virtio_blkdev_configure,
 		.queue_get_info = virtio_blkdev_queue_info_get,
-		.queue_setup = virtio_blkdev_queue_setup,
+		.queue_configure = virtio_blkdev_queue_setup,
 		.queue_intr_enable = virtio_blkdev_queue_intr_enable,
 		.dev_start = virtio_blkdev_start,
 		.dev_stop = virtio_blkdev_stop,
 		.queue_intr_disable = virtio_blkdev_queue_intr_disable,
-		.queue_release = virtio_blkdev_queue_release,
+		.queue_unconfigure = virtio_blkdev_queue_release,
 		.dev_unconfigure = virtio_blkdev_unconfigure,
 };
 
diff --git a/plat/xen/drivers/blk/blkfront.c b/plat/xen/drivers/blk/blkfront.c
index 60b63466..a4137340 100644
--- a/plat/xen/drivers/blk/blkfront.c
+++ b/plat/xen/drivers/blk/blkfront.c
@@ -891,8 +891,8 @@ static const struct uk_blkdev_ops blkfront_ops = {
 	.get_info = blkfront_get_info,
 	.dev_configure = blkfront_configure,
 	.queue_get_info = blkfront_queue_get_info,
-	.queue_setup = blkfront_queue_setup,
-	.queue_release = blkfront_queue_release,
+	.queue_configure = blkfront_queue_setup,
+	.queue_unconfigure = blkfront_queue_release,
 	.dev_start = blkfront_start,
 	.dev_stop = blkfront_stop,
 	.dev_unconfigure = blkfront_unconfigure,
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:56:58 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:56:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10396.27660 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZDG-0001x9-Nl; Thu, 22 Oct 2020 11:56:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10396.27660; Thu, 22 Oct 2020 11:56:58 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZDG-0001x0-KT; Thu, 22 Oct 2020 11:56:58 +0000
Received: by outflank-mailman (input) for mailman id 10396;
 Thu, 22 Oct 2020 11:56: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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVZDF-0001vt-Qv
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:57 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 78a28714-5dd1-44e5-b50d-fd89ea88271c;
 Thu, 22 Oct 2020 11:56:53 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id E7AF4F20C6;
 Thu, 22 Oct 2020 13:56:52 +0200 (CEST)
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 RCrNMmefVc5V; Thu, 22 Oct 2020 13:56:52 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id BE2C9F20AF
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:50 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:49 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVZDF-0001vt-Qv
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:56:57 +0000
X-Inumbo-ID: 78a28714-5dd1-44e5-b50d-fd89ea88271c
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 78a28714-5dd1-44e5-b50d-fd89ea88271c;
	Thu, 22 Oct 2020 11:56:53 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id E7AF4F20C6;
	Thu, 22 Oct 2020 13:56:52 +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 RCrNMmefVc5V; Thu, 22 Oct 2020 13:56:52 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id BE2C9F20AF
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:56:50 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:56:49 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 6/7] lib/ukblkdev: Provide `uk_blkdev_size()`
Date: Thu, 22 Oct 2020 13:55:06 +0200
Message-ID: <20201022115507.4983-7-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
References: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

This commits provides a shortcut macro for retrieving the block device size in
number of bytes.

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

diff --git a/lib/ukblkdev/include/uk/blkdev.h b/lib/ukblkdev/include/uk/blkdev.h
index 699b56bc..ab90a548 100644
--- a/lib/ukblkdev/include/uk/blkdev.h
+++ b/lib/ukblkdev/include/uk/blkdev.h
@@ -255,6 +255,9 @@ static inline const struct uk_blkdev_cap *uk_blkdev_capabilities(
 #define uk_blkdev_sectors(blkdev) \
 	(uk_blkdev_capabilities(blkdev)->sectors)
 
+#define uk_blkdev_size(blkdev) \
+	((size_t) uk_blkdev_sectors(blkdev) * uk_blkdev_ssize(blkdev))
+
 #define uk_blkdev_ioalign(blkdev) \
 	(uk_blkdev_capabilities(blkdev)->ioalign)
 /**
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 11:57:05 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 11:57:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10397.27663 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZDN-0001yT-P2; Thu, 22 Oct 2020 11:57:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10397.27663; Thu, 22 Oct 2020 11:57:05 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVZDN-0001yL-M0; Thu, 22 Oct 2020 11:57:05 +0000
Received: by outflank-mailman (input) for mailman id 10397;
 Thu, 22 Oct 2020 11:57:04 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVZDM-0001y9-DX
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:57:04 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id ecfdbdd9-55df-4e76-b830-d10fc30faf83;
 Thu, 22 Oct 2020 11:57:03 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 72BF91041E2;
 Thu, 22 Oct 2020 13:57:02 +0200 (CEST)
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 bbwVmdLerVSr; Thu, 22 Oct 2020 13:57:02 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 527591041DF
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:57:02 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:57:02 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVZDM-0001y9-DX
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 11:57:04 +0000
X-Inumbo-ID: ecfdbdd9-55df-4e76-b830-d10fc30faf83
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id ecfdbdd9-55df-4e76-b830-d10fc30faf83;
	Thu, 22 Oct 2020 11:57:03 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 72BF91041E2;
	Thu, 22 Oct 2020 13:57:02 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-a.office.hd)
Received: from mailer1.neclab.eu ([127.0.0.1])
	by localhost (atlas-a.office.hd [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id bbwVmdLerVSr; Thu, 22 Oct 2020 13:57:02 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 527591041DF
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 13:57:02 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 13:57:02 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 7/7] lib/ukblkdev: blkdev.h: Description about interrupts
Date: Thu, 22 Oct 2020 13:55:07 +0200
Message-ID: <20201022115507.4983-8-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
References: <20201022115507.4983-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukblkdev/include/uk/blkdev.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/ukblkdev/include/uk/blkdev.h b/lib/ukblkdev/include/uk/blkdev.h
index ab90a548..9bcfd577 100644
--- a/lib/ukblkdev/include/uk/blkdev.h
+++ b/lib/ukblkdev/include/uk/blkdev.h
@@ -413,7 +413,8 @@ int uk_blkdev_queue_submit_one(struct uk_blkdev *dev, uint16_t queue_id,
 					     | UK_BLKDEV_STATUS_MORE))
 
 /**
- * Get responses from the queue
+ * Get responses from the queue and re-enable interrupts on the target queue
+ * when they were enabled before.
  *
  * @param dev
  *	The Unikraft Block Device
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 13:33:13 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 13:33:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10433.27723 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVaiK-0003Dp-TQ; Thu, 22 Oct 2020 13:33:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10433.27723; Thu, 22 Oct 2020 13:33:08 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVaiK-0003Di-QH; Thu, 22 Oct 2020 13:33:08 +0000
Received: by outflank-mailman (input) for mailman id 10433;
 Thu, 22 Oct 2020 13:33: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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVaiJ-0003Dd-4p
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:33:07 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 06db465f-c507-4fed-b551-27e91038ec67;
 Thu, 22 Oct 2020 13:33:04 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 4589C103AE4;
 Thu, 22 Oct 2020 15:33:03 +0200 (CEST)
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 GziaE0G6pX3Z; Thu, 22 Oct 2020 15:33:03 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 1BC1110391F;
 Thu, 22 Oct 2020 15:33:03 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:33:02 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVaiJ-0003Dd-4p
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:33:07 +0000
X-Inumbo-ID: 06db465f-c507-4fed-b551-27e91038ec67
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 06db465f-c507-4fed-b551-27e91038ec67;
	Thu, 22 Oct 2020 13:33:04 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 4589C103AE4;
	Thu, 22 Oct 2020 15:33:03 +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 GziaE0G6pX3Z; Thu, 22 Oct 2020 15:33:03 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 1BC1110391F;
	Thu, 22 Oct 2020 15:33:03 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:33:02 +0200
Subject: Re: [UNIKRAFT PATCH v4 07/12] plat/xen/drivers/net: Configure
 netfront rx queue
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
CC: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-8-costin.lupu@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <6902b9b4-7797-3106-09a8-f445be78faa0@neclab.eu>
Date: Thu, 22 Oct 2020 15:33:01 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20200813085342.29799-8-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Please find the comment inline:

Thanks & Regards

Sharan

On 8/13/20 10:53 AM, Costin Lupu wrote:
> Incoming packets are saved in buffers allocated with user-provided callbacks.
> Whenever such packet is available, the driver is notified via event channels.
> This patch introduces the configuration logic for rx queues and the handler
> used in dealing with the notifications.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
> ---
>   plat/xen/drivers/net/netfront.c | 212 ++++++++++++++++++++++++++++++--
>   plat/xen/drivers/net/netfront.h |  29 +++++
>   2 files changed, 232 insertions(+), 9 deletions(-)
>
> diff --git a/plat/xen/drivers/net/netfront.c b/plat/xen/drivers/net/netfront.c
> index 3c936743..742e05cf 100644
> --- a/plat/xen/drivers/net/netfront.c
> +++ b/plat/xen/drivers/net/netfront.c
> @@ -52,6 +52,11 @@
>   static struct uk_alloc *drv_allocator;
>   
>   
> +static uint16_t xennet_rxidx(RING_IDX idx)
> +{
> +	return (uint16_t) (idx & (NET_RX_RING_SIZE - 1));
> +}
> +
>   static void add_id_to_freelist(uint16_t id, uint16_t *freelist)
>   {
>   	freelist[id + 1] = freelist[0];
> @@ -67,6 +72,82 @@ static uint16_t get_id_from_freelist(uint16_t *freelist)
>   	return id;
>   }
>   
> +static int netfront_rxq_enqueue(struct uk_netdev_rx_queue *rxq,
> +		struct uk_netbuf *netbuf)
> +{
> +	RING_IDX req_prod;
> +	uint16_t id;
> +	netif_rx_request_t *rx_req;
> +	struct netfront_dev *nfdev;
> +	int notify;
> +
> +	/* buffer must be page aligned */
> +	UK_ASSERT(((unsigned long) netbuf->data & ~PAGE_MASK) == 0);
> +
> +	if (RING_FULL(&rxq->ring)) {
> +		uk_pr_debug("rx queue is full\n");
> +		return -ENOSPC;
> +	}
> +
> +	/* get request */
> +	req_prod = rxq->ring.req_prod_pvt;
> +	id = xennet_rxidx(req_prod);
> +	rx_req = RING_GET_REQUEST(&rxq->ring, req_prod);
> +	rx_req->id = id;
> +
> +	/* save buffer */
> +	rxq->netbuf[id] = netbuf;
> +	/* setup grant for buffer data */
> +	nfdev = rxq->netfront_dev;
> +	rxq->gref[id] = rx_req->gref =
> +		gnttab_grant_access(nfdev->xendev->otherend_id,
> +			virt_to_mfn(netbuf->data), 0);
> +	UK_ASSERT(rx_req->gref != GRANT_INVALID_REF);
> +
> +	wmb(); /* Ensure backend sees requests */
> +	rxq->ring.req_prod_pvt = req_prod + 1;
> +
> +	RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&rxq->ring, notify);
> +	if (notify)
> +		notify_remote_via_evtchn(rxq->evtchn);
> +
> +	return 0;
> +}
> +
> +static int netfront_rx_fillup(struct uk_netdev_rx_queue *rxq, uint16_t nb_desc)
> +{
> +	struct uk_netbuf *netbuf[nb_desc];
> +	int rc, status = 0;
> +	uint16_t cnt;
> +
> +	cnt = rxq->alloc_rxpkts(rxq->alloc_rxpkts_argp, netbuf, nb_desc);
> +
> +	for (uint16_t i = 0; i < cnt; i++) {
> +		rc = netfront_rxq_enqueue(rxq, netbuf[i]);
> +		if (unlikely(rc < 0)) {
> +			uk_pr_err("Failed to add a buffer to rx queue %p: %d\n",
> +				rxq, rc);
> +
> +			/*
> +			 * Release netbufs that we are not going
> +			 * to use anymore
> +			 */
> +			for (uint16_t j = i; j < cnt; j++)
> +				uk_netbuf_free(netbuf[j]);
> +
> +			status |= UK_NETDEV_STATUS_UNDERRUN;
> +
> +			goto out;
> +		}
> +	}
> +
> +	if (unlikely(cnt < nb_desc))
> +		status |= UK_NETDEV_STATUS_UNDERRUN;
> +
> +out:
> +	return status;
> +}
> +
>   static struct uk_netdev_tx_queue *netfront_txq_setup(struct uk_netdev *n,
>   		uint16_t queue_id,
>   		uint16_t nb_desc __unused,
> @@ -103,15 +184,19 @@ static struct uk_netdev_tx_queue *netfront_txq_setup(struct uk_netdev *n,
>   	UK_ASSERT(txq->ring_ref != GRANT_INVALID_REF);
>   
>   	/* Setup event channel */
> -	rc = evtchn_alloc_unbound(nfdev->xendev->otherend_id,
> -			NULL, NULL,
> -			&txq->evtchn);
> -	if (rc) {
> -		uk_pr_err("Error creating event channel: %d\n", rc);
> -		gnttab_end_access(txq->ring_ref);
> -		uk_pfree(drv_allocator, sring, 1);
> -		return ERR2PTR(-rc);
> -	}
> +	if (nfdev->split_evtchn || !nfdev->rxqs[queue_id].initialized) {
> +		rc = evtchn_alloc_unbound(nfdev->xendev->otherend_id,
> +				NULL, NULL,
> +				&txq->evtchn);
> +		if (rc) {
> +			uk_pr_err("Error creating event channel: %d\n", rc);
> +			gnttab_end_access(txq->ring_ref);
> +			uk_pfree(drv_allocator, sring, 1);
> +			return ERR2PTR(rc);
> +		}
> +	} else
> +		txq->evtchn = nfdev->rxqs[queue_id].evtchn;

In the next version maybe this can go to the previous patch.


> +
>   	/* Events are always disabled for tx queue */
>   	mask_evtchn(txq->evtchn);
>   
> @@ -128,6 +213,86 @@ static struct uk_netdev_tx_queue *netfront_txq_setup(struct uk_netdev *n,
>   	return txq;
>   }
>   
> +static void netfront_handler(evtchn_port_t port __unused,
> +		struct __regs *regs __unused, void *arg)
> +{
> +	struct uk_netdev_rx_queue *rxq = arg;
> +
> +	/* Indicate to the network stack about an event */
> +	uk_netdev_drv_rx_event(&rxq->netfront_dev->netdev, rxq->lqueue_id);
> +}
> +
> +static struct uk_netdev_rx_queue *netfront_rxq_setup(struct uk_netdev *n,
> +		uint16_t queue_id,
> +		uint16_t nb_desc __unused,
> +		struct uk_netdev_rxqueue_conf *conf)
> +{
> +	int rc;
> +	struct netfront_dev *nfdev;
> +	struct uk_netdev_rx_queue *rxq;
> +	netif_rx_sring_t *sring;
> +
> +	UK_ASSERT(n != NULL);
> +	UK_ASSERT(conf != NULL);
> +
> +	nfdev = to_netfront_dev(n);
> +	if (queue_id >= nfdev->max_queue_pairs) {
> +		uk_pr_err("Invalid queue identifier: %"__PRIu16"\n", queue_id);
> +		return ERR2PTR(-EINVAL);
> +	}
> +
> +	rxq = &nfdev->rxqs[queue_id];
> +	UK_ASSERT(!rxq->initialized);
> +	rxq->netfront_dev = nfdev;
> +	rxq->lqueue_id = queue_id;
> +
> +	/* Setup shared ring */
> +	sring = uk_palloc(drv_allocator, 1);
Allocator from the conf should be used here.
> +	if (!sring)
> +		return ERR2PTR(-ENOMEM);
> +	memset(sring, 0, PAGE_SIZE);
> +	SHARED_RING_INIT(sring);
> +	FRONT_RING_INIT(&rxq->ring, sring, PAGE_SIZE);
> +	rxq->ring_size = NET_RX_RING_SIZE;
> +	rxq->ring_ref = gnttab_grant_access(nfdev->xendev->otherend_id,
> +		virt_to_mfn(sring), 0);
> +	UK_ASSERT(rxq->ring_ref != GRANT_INVALID_REF);
> +
> +	/* Setup event channel */
> +	if (nfdev->split_evtchn || !nfdev->txqs[queue_id].initialized) {
> +		rc = evtchn_alloc_unbound(nfdev->xendev->otherend_id,
> +				netfront_handler, rxq,
> +				&rxq->evtchn);
> +		if (rc) {
> +			uk_pr_err("Error creating event channel: %d\n", rc);
> +			gnttab_end_access(rxq->ring_ref);
> +			uk_pfree(drv_allocator, sring, 1);
> +			return ERR2PTR(rc);
> +		}
> +	} else {
> +		rxq->evtchn = nfdev->txqs[queue_id].evtchn;
> +		/* overwriting event handler */
> +		bind_evtchn(rxq->evtchn, netfront_handler, rxq);
> +	}
> +	/*
> +	 * By default, events are disabled and it is up to the user or
> +	 * network stack to explicitly enable them.
> +	 */
> +	mask_evtchn(rxq->evtchn);
> +	rxq->intr_enabled = 0;
> +
> +	rxq->alloc_rxpkts = conf->alloc_rxpkts;
> +	rxq->alloc_rxpkts_argp = conf->alloc_rxpkts_argp;
> +
> +	/* Allocate receive buffers for this queue */
> +	netfront_rx_fillup(rxq, rxq->ring_size);
> +
> +	rxq->initialized = true;
> +	nfdev->rxqs_num++;
> +
> +	return rxq;
> +}
> +
>   static int netfront_rxtx_alloc(struct netfront_dev *nfdev,
>   		const struct uk_netdev_conf *conf)
>   {
> @@ -196,6 +361,33 @@ exit:
>   	return rc;
>   }
>   
> +static int netfront_rxq_info_get(struct uk_netdev *n,
> +		uint16_t queue_id,
> +		struct uk_netdev_queue_info *qinfo)
> +{
> +	struct netfront_dev *nfdev;
> +	struct uk_netdev_rx_queue *rxq;
> +	int rc = 0;
> +
> +	UK_ASSERT(n != NULL);
> +	UK_ASSERT(qinfo != NULL);
> +
> +	nfdev = to_netfront_dev(n);
> +	if (unlikely(queue_id >= nfdev->rxqs_num)) {
Same as the txq info get
> +		uk_pr_err("Invalid queue id: %"__PRIu16"\n", queue_id);
> +		rc = -EINVAL;
> +		goto exit;
> +	}
> +	rxq = &nfdev->rxqs[queue_id];
> +	qinfo->nb_min = rxq->ring_size;
> +	qinfo->nb_max = rxq->ring_size;
> +	qinfo->nb_align = PAGE_SIZE;
> +	qinfo->nb_is_power_of_two = 1;
> +
> +exit:
> +	return rc;
> +}
> +
>   static int netfront_configure(struct uk_netdev *n,
>   		const struct uk_netdev_conf *conf)
>   {
> @@ -286,7 +478,9 @@ static unsigned int netfront_promisc_get(struct uk_netdev *n)
>   static const struct uk_netdev_ops netfront_ops = {
>   	.configure = netfront_configure,
>   	.txq_configure = netfront_txq_setup,
> +	.rxq_configure = netfront_rxq_setup,
>   	.txq_info_get = netfront_txq_info_get,
> +	.rxq_info_get = netfront_rxq_info_get,
>   	.info_get = netfront_info_get,
>   	.einfo_get = netfront_einfo_get,
>   	.hwaddr_get = netfront_mac_get,
> diff --git a/plat/xen/drivers/net/netfront.h b/plat/xen/drivers/net/netfront.h
> index d3f603b3..c8364815 100644
> --- a/plat/xen/drivers/net/netfront.h
> +++ b/plat/xen/drivers/net/netfront.h
> @@ -44,6 +44,7 @@
>   
>   
>   #define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE)
> +#define NET_RX_RING_SIZE __CONST_RING_SIZE(netif_rx, PAGE_SIZE)
>   
>   /**
>    * internal structure to represent the transmit queue.
> @@ -77,6 +78,33 @@ struct uk_netdev_tx_queue {
>    * internal structure to represent the receive queue.
>    */
>   struct uk_netdev_rx_queue {
> +	/* The netfront device */
> +	struct netfront_dev *netfront_dev;
> +	/* The libuknet queue identifier */
> +	uint16_t lqueue_id;
> +	/* True if initialized */
> +	bool initialized;
> +
> +	/* Shared ring size */
> +	uint16_t ring_size;
> +	/* Shared ring */
> +	netif_rx_front_ring_t ring;
> +	/* Shared ring grant ref */
> +	grant_ref_t ring_ref;
> +	/* Queue event channel */
> +	evtchn_port_t evtchn;
> +
> +	/* The flag to interrupt on the transmit queue */
> +	uint8_t intr_enabled;
> +
> +	/* User-provided receive buffer allocation function */
> +	uk_netdev_alloc_rxpkts alloc_rxpkts;
> +	void *alloc_rxpkts_argp;
> +
> +	/* Receive buffers for incoming packets */
> +	struct uk_netbuf *netbuf[NET_RX_RING_SIZE];
> +	/* Grants for receive buffers */
> +	grant_ref_t gref[NET_RX_RING_SIZE];
>   };
>   
>   struct xs_econf {
> @@ -93,6 +121,7 @@ struct netfront_dev {
>   
>   	/* List of the Rx/Tx queues */
>   	uint16_t txqs_num;
> +	uint16_t rxqs_num;
>   	struct uk_netdev_tx_queue *txqs;
>   	struct uk_netdev_rx_queue *rxqs;
>   	/* Maximum number of queue pairs */


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 13:35:12 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 13:35:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10438.27738 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVakJ-0003R2-BJ; Thu, 22 Oct 2020 13:35:11 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10438.27738; Thu, 22 Oct 2020 13:35:11 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVakJ-0003Qv-8S; Thu, 22 Oct 2020 13:35:11 +0000
Received: by outflank-mailman (input) for mailman id 10438;
 Thu, 22 Oct 2020 13:35:10 +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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVakI-0003Qn-2d
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:35:10 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id aa7de4b0-e6b2-404a-a33a-b8bf75e31cb4;
 Thu, 22 Oct 2020 13:35:07 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 984E0F2233;
 Thu, 22 Oct 2020 15:35:06 +0200 (CEST)
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 0bD39D6rVnjy; Thu, 22 Oct 2020 15:35:06 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 6CC02F2232;
 Thu, 22 Oct 2020 15:35:00 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:34:59 +0200
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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVakI-0003Qn-2d
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:35:10 +0000
X-Inumbo-ID: aa7de4b0-e6b2-404a-a33a-b8bf75e31cb4
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id aa7de4b0-e6b2-404a-a33a-b8bf75e31cb4;
	Thu, 22 Oct 2020 13:35:07 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 984E0F2233;
	Thu, 22 Oct 2020 15:35:06 +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 0bD39D6rVnjy; Thu, 22 Oct 2020 15:35:06 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 6CC02F2232;
	Thu, 22 Oct 2020 15:35:00 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:34:59 +0200
Subject: Re: [UNIKRAFT PATCH v4 08/12] plat/xen/drivers/net: Enable/disable
 interrupts for rx queues
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
CC: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-9-costin.lupu@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <b3634685-2ec6-5c0a-f7dd-a1a55682f42a@neclab.eu>
Date: Thu, 22 Oct 2020 15:34:37 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20200813085342.29799-9-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Thanks for the work.

Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>

Thanks & Regards
Sharan

On 8/13/20 10:53 AM, Costin Lupu wrote:
> The user can enable/disable interrupts for devices according with the operation
> mode he or she chooses for the device. This patch follows closely the logic
> implemented in the virtio net driver.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
> ---
>   plat/xen/drivers/net/netfront.c | 67 +++++++++++++++++++++++++++++++++
>   1 file changed, 67 insertions(+)
>
> diff --git a/plat/xen/drivers/net/netfront.c b/plat/xen/drivers/net/netfront.c
> index 742e05cf..6b708790 100644
> --- a/plat/xen/drivers/net/netfront.c
> +++ b/plat/xen/drivers/net/netfront.c
> @@ -46,6 +46,12 @@
>   
>   #define DRIVER_NAME  "xen-netfront"
>   
> +/* TODO Same interrupt macros we use in virtio-net */
> +#define NETFRONT_INTR_EN             (1 << 0)
> +#define NETFRONT_INTR_EN_MASK        (1)
> +#define NETFRONT_INTR_USR_EN         (1 << 1)
> +#define NETFRONT_INTR_USR_EN_MASK    (2)
> +
>   #define to_netfront_dev(dev) \
>   	__containerof(dev, struct netfront_dev, netdev)
>   
> @@ -148,6 +154,22 @@ out:
>   	return status;
>   }
>   
> +/* Returns 1 if more packets available */
> +static int netfront_rxq_intr_enable(struct uk_netdev_rx_queue *rxq)
> +{
> +	int more;
> +
> +	/* Check if there are no more packets enabled */
> +	RING_FINAL_CHECK_FOR_RESPONSES(&rxq->ring, more);
> +	if (!more) {
> +		/* No more packets, we can enable interrupts */
> +		rxq->intr_enabled |= NETFRONT_INTR_EN;
> +		unmask_evtchn(rxq->evtchn);
> +	}
> +
> +	return (more > 0);
> +}
> +
>   static struct uk_netdev_tx_queue *netfront_txq_setup(struct uk_netdev *n,
>   		uint16_t queue_id,
>   		uint16_t nb_desc __unused,
> @@ -218,6 +240,10 @@ static void netfront_handler(evtchn_port_t port __unused,
>   {
>   	struct uk_netdev_rx_queue *rxq = arg;
>   
> +	/* Disable the interrupt for the ring */
> +	rxq->intr_enabled &= ~(NETFRONT_INTR_EN);
> +	mask_evtchn(rxq->evtchn);
> +
>   	/* Indicate to the network stack about an event */
>   	uk_netdev_drv_rx_event(&rxq->netfront_dev->netdev, rxq->lqueue_id);
>   }
> @@ -334,6 +360,45 @@ err_free_txrx:
>   	return rc;
>   }
>   
> +static int netfront_rx_intr_enable(struct uk_netdev *n,
> +		struct uk_netdev_rx_queue *rxq)
> +{
> +	int rc;
> +
> +	UK_ASSERT(n != NULL);
> +	UK_ASSERT(rxq != NULL);
> +	UK_ASSERT(&rxq->netfront_dev->netdev == n);
> +
> +	/* If the interrupt is enabled */
> +	if (rxq->intr_enabled & NETFRONT_INTR_EN)
> +		return 0;
> +
> +	/**
> +	 * Enable the user configuration bit. This would cause the interrupt to
> +	 * be enabled automatically if the interrupt could not be enabled now
> +	 * due to data in the queue.
> +	 */
> +	rxq->intr_enabled = NETFRONT_INTR_USR_EN;
> +	rc = netfront_rxq_intr_enable(rxq);
> +	if (!rc)
> +		rxq->intr_enabled |= NETFRONT_INTR_EN;
> +
> +	return rc;
> +}
> +
> +static int netfront_rx_intr_disable(struct uk_netdev *n,
> +		struct uk_netdev_rx_queue *rxq)
> +{
> +	UK_ASSERT(n != NULL);
> +	UK_ASSERT(rxq != NULL);
> +	UK_ASSERT(&rxq->netfront_dev->netdev == n);
> +
> +	rxq->intr_enabled &= ~(NETFRONT_INTR_USR_EN | NETFRONT_INTR_EN);
> +	mask_evtchn(rxq->evtchn);
> +
> +	return 0;
> +}
> +
>   static int netfront_txq_info_get(struct uk_netdev *n,
>   		uint16_t queue_id,
>   		struct uk_netdev_queue_info *qinfo)
> @@ -479,6 +544,8 @@ static const struct uk_netdev_ops netfront_ops = {
>   	.configure = netfront_configure,
>   	.txq_configure = netfront_txq_setup,
>   	.rxq_configure = netfront_rxq_setup,
> +	.rxq_intr_enable = netfront_rx_intr_enable,
> +	.rxq_intr_disable = netfront_rx_intr_disable,
>   	.txq_info_get = netfront_txq_info_get,
>   	.rxq_info_get = netfront_rxq_info_get,
>   	.info_get = netfront_info_get,


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 13:36:03 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 13:36:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10441.27742 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVal9-0003UH-Ey; Thu, 22 Oct 2020 13:36:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10441.27742; Thu, 22 Oct 2020 13:36:03 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVal9-0003UA-Bs; Thu, 22 Oct 2020 13:36:03 +0000
Received: by outflank-mailman (input) for mailman id 10441;
 Thu, 22 Oct 2020 13:36: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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVal8-0003U5-Dr
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:36:02 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 4f306696-c9c6-44f5-abf9-b4892292943c;
 Thu, 22 Oct 2020 13:36:00 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id C4A51103AE4;
 Thu, 22 Oct 2020 15:35:59 +0200 (CEST)
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 LHFck-ICcbFD; Thu, 22 Oct 2020 15:35:59 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 9C0BB10391F;
 Thu, 22 Oct 2020 15:35:59 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:35:58 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVal8-0003U5-Dr
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:36:02 +0000
X-Inumbo-ID: 4f306696-c9c6-44f5-abf9-b4892292943c
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 4f306696-c9c6-44f5-abf9-b4892292943c;
	Thu, 22 Oct 2020 13:36:00 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id C4A51103AE4;
	Thu, 22 Oct 2020 15:35:59 +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 LHFck-ICcbFD; Thu, 22 Oct 2020 15:35:59 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 9C0BB10391F;
	Thu, 22 Oct 2020 15:35:59 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:35:58 +0200
Subject: Re: [UNIKRAFT PATCH v4 09/12] plat/xen/drivers/net: Start netfront
 device
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
CC: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-10-costin.lupu@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <9ce45043-6eb6-ba35-8713-674f599bfa27@neclab.eu>
Date: Thu, 22 Oct 2020 15:35:57 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20200813085342.29799-10-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Thanks for the work.

Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>

Thanks & Regards

Sharan

On 8/13/20 10:53 AM, Costin Lupu wrote:
> Starting the device implies establishing the connection between netfront and
> netback. The connection is set up after a negociation between the two end
> points. After configuring the device queues, the netfront publishes via
> Xenstore the information associated with the queues which will be used by the
> backend to connect.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
> ---
>   plat/xen/drivers/net/netfront.c    |  18 ++
>   plat/xen/drivers/net/netfront_xb.h |   3 +
>   plat/xen/drivers/net/netfront_xs.c | 303 +++++++++++++++++++++++++++++
>   3 files changed, 324 insertions(+)
>
> diff --git a/plat/xen/drivers/net/netfront.c b/plat/xen/drivers/net/netfront.c
> index 6b708790..858d124a 100644
> --- a/plat/xen/drivers/net/netfront.c
> +++ b/plat/xen/drivers/net/netfront.c
> @@ -474,6 +474,23 @@ out:
>   	return rc;
>   }
>   
> +static int netfront_start(struct uk_netdev *n)
> +{
> +	struct netfront_dev *nfdev;
> +	int rc;
> +
> +	UK_ASSERT(n != NULL);
> +	nfdev = to_netfront_dev(n);
> +
> +	rc = netfront_xb_connect(nfdev);
> +	if (rc) {
> +		uk_pr_err("Error connecting to backend: %d\n", rc);
> +		return rc;
> +	}
> +
> +	return rc;
> +}
> +
>   static void netfront_info_get(struct uk_netdev *n,
>   		struct uk_netdev_info *dev_info)
>   {
> @@ -542,6 +559,7 @@ static unsigned int netfront_promisc_get(struct uk_netdev *n)
>   
>   static const struct uk_netdev_ops netfront_ops = {
>   	.configure = netfront_configure,
> +	.start = netfront_start,
>   	.txq_configure = netfront_txq_setup,
>   	.rxq_configure = netfront_rxq_setup,
>   	.rxq_intr_enable = netfront_rx_intr_enable,
> diff --git a/plat/xen/drivers/net/netfront_xb.h b/plat/xen/drivers/net/netfront_xb.h
> index 6332cf71..07dde171 100644
> --- a/plat/xen/drivers/net/netfront_xb.h
> +++ b/plat/xen/drivers/net/netfront_xb.h
> @@ -40,4 +40,7 @@
>   int  netfront_xb_init(struct netfront_dev *netdev, struct uk_alloc *a);
>   void netfront_xb_fini(struct netfront_dev *netdev, struct uk_alloc *a);
>   
> +int netfront_xb_connect(struct netfront_dev *netdev);
> +int netfront_xb_disconnect(struct netfront_dev *netdev);
> +
>   #endif /* __NETFRONT_XB_H__ */
> diff --git a/plat/xen/drivers/net/netfront_xs.c b/plat/xen/drivers/net/netfront_xs.c
> index 1bde44e0..618496e7 100644
> --- a/plat/xen/drivers/net/netfront_xs.c
> +++ b/plat/xen/drivers/net/netfront_xs.c
> @@ -31,6 +31,7 @@
>    *
>    * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
>    */
> +#define _GNU_SOURCE
>   #include <inttypes.h>
>   #include <stdio.h>
>   #include <string.h>
> @@ -38,9 +39,14 @@
>   #include <uk/print.h>
>   #include <uk/assert.h>
>   #include <xenbus/xs.h>
> +#include <xenbus/client.h>
>   #include "netfront_xb.h"
>   
>   
> +static int netfront_xb_wait_be_connect(struct netfront_dev *nfdev);
> +static int netfront_xb_wait_be_disconnect(struct netfront_dev *nfdev);
> +
> +
>   static int xs_read_backend_id(const char *nodename, domid_t *domid)
>   {
>   	char path[strlen(nodename) + sizeof("/backend-id")];
> @@ -217,3 +223,300 @@ void netfront_xb_fini(struct netfront_dev *nfdev, struct uk_alloc *a)
>   		xendev->otherend = NULL;
>   	}
>   }
> +
> +static int xs_write_queue(struct netfront_dev *nfdev, uint16_t queue_id,
> +		xenbus_transaction_t xbt, int write_hierarchical)
> +{
> +	struct xenbus_device *xendev = nfdev->xendev;
> +	struct uk_netdev_tx_queue *txq = &nfdev->txqs[queue_id];
> +	struct uk_netdev_rx_queue *rxq = &nfdev->rxqs[queue_id];
> +	char *path;
> +	int rc;
> +
> +	if (write_hierarchical) {
> +		rc = asprintf(&path, "%s/queue-%u", xendev->nodename, queue_id);
> +		if (rc < 0)
> +			goto out;
> +	} else
> +		path = xendev->nodename;
> +
> +	rc = xs_printf(xbt, path, "tx-ring-ref", "%u", txq->ring_ref);
> +	if (rc < 0)
> +		goto out_path;
> +
> +	rc = xs_printf(xbt, path, "rx-ring-ref", "%u", rxq->ring_ref);
> +	if (rc < 0)
> +		goto out_path;
> +
> +	if (nfdev->split_evtchn) {
> +		/* split event channels */
> +		rc = xs_printf(xbt, path, "event-channel-tx", "%u",
> +			txq->evtchn);
> +		if (rc < 0)
> +			goto out_path;
> +
> +		rc = xs_printf(xbt, path, "event-channel-rx", "%u",
> +			rxq->evtchn);
> +		if (rc < 0)
> +			goto out_path;
> +	} else {
> +		/* shared event channel */
> +		rc = xs_printf(xbt, path, "event-channel", "%u",
> +			txq->evtchn);
> +		if (rc < 0)
> +			goto out_path;
> +	}
> +
> +	rc = 0;
> +
> +out_path:
> +	if (write_hierarchical)
> +		free(path);
> +out:
> +	return rc;
> +}
> +
> +static void xs_delete_queue(struct netfront_dev *nfdev, uint16_t queue_id,
> +		xenbus_transaction_t xbt, int write_hierarchical)
> +{
> +	struct xenbus_device *xendev = nfdev->xendev;
> +	char *dir, *path;
> +	int rc;
> +
> +	if (write_hierarchical) {
> +		rc = asprintf(&dir, "%s/queue-%u", xendev->nodename, queue_id);
> +		if (rc < 0)
> +			return;
> +	} else
> +		dir = xendev->nodename;
> +
> +	rc = asprintf(&path, "%s/tx-ring-ref", dir);
> +	if (rc < 0)
> +		goto out;
> +	xs_rm(xbt, path);
> +	free(path);
> +
> +	rc = asprintf(&path, "%s/rx-ring-ref", dir);
> +	if (rc < 0)
> +		goto out;
> +	xs_rm(xbt, path);
> +	free(path);
> +
> +	if (nfdev->split_evtchn) {
> +		/* split event channels */
> +		rc = asprintf(&path, "%s/event-channel-tx", dir);
> +		if (rc < 0)
> +			goto out;
> +		xs_rm(xbt, path);
> +		free(path);
> +		rc = asprintf(&path, "%s/event-channel-rx", dir);
> +		if (rc < 0)
> +			goto out;
> +		xs_rm(xbt, path);
> +		free(path);
> +	} else {
> +		/* shared event channel */
> +		rc = asprintf(&path, "%s/event-channel", dir);
> +		if (rc < 0)
> +			goto out;
> +		xs_rm(xbt, path);
> +		free(path);
> +	}
> +
> +out:
> +	if (write_hierarchical)
> +		free(dir);
> +}
> +
> +static int netfront_xb_front_init(struct netfront_dev *nfdev,
> +		xenbus_transaction_t xbt)
> +{
> +	struct xenbus_device *xendev = nfdev->xendev;
> +	int rc, i;
> +
> +	if (nfdev->rxqs_num == 1) {
> +		rc = xs_write_queue(nfdev, 0, xbt, 0);
> +		if (rc)
> +			goto out;
> +	} else {
> +		for (i = 0; i < nfdev->rxqs_num; i++) {
> +			rc = xs_write_queue(nfdev, i, xbt, 1);
> +			if (rc)
> +				goto out;
> +		}
> +	}
> +
> +	rc = xs_printf(xbt, xendev->nodename, "request-rx-copy", "%u", 1);
> +	if (rc < 0)
> +		goto out;
> +
> +	rc = 0;
> +
> +out:
> +	return rc;
> +}
> +
> +static void netfront_xb_front_fini(struct netfront_dev *nfdev,
> +		xenbus_transaction_t xbt)
> +{
> +	int i;
> +
> +	if (nfdev->rxqs_num == 1)
> +		xs_delete_queue(nfdev, 0, xbt, 0);
> +	else {
> +		for (i = 0; i < nfdev->rxqs_num; i++)
> +			xs_delete_queue(nfdev, i, xbt, 1);
> +	}
> +}
> +
> +int netfront_xb_connect(struct netfront_dev *nfdev)
> +{
> +	struct xenbus_device *xendev;
> +	xenbus_transaction_t xbt;
> +	int rc;
> +
> +	UK_ASSERT(nfdev != NULL);
> +
> +	xendev = nfdev->xendev;
> +	UK_ASSERT(xendev != NULL);
> +
> +again:
> +	rc = xs_transaction_start(&xbt);
> +	if (rc)
> +		goto abort_transaction;
> +
> +	rc = netfront_xb_front_init(nfdev, xbt);
> +	if (rc)
> +		goto abort_transaction;
> +
> +	rc = xenbus_switch_state(xbt, xendev, XenbusStateConnected);
> +	if (rc)
> +		goto abort_transaction;
> +
> +	rc = xs_transaction_end(xbt, 0);
> +	if (rc == -EAGAIN)
> +		goto again;
> +
> +	rc = netfront_xb_wait_be_connect(nfdev);
> +	if (rc)
> +		netfront_xb_front_fini(nfdev, xbt);
> +
> +	return rc;
> +
> +abort_transaction:
> +	xs_transaction_end(xbt, 1);
> +
> +	return rc;
> +}
> +
> +int netfront_xb_disconnect(struct netfront_dev *nfdev)
> +{
> +	struct xenbus_device *xendev;
> +	int rc;
> +
> +	UK_ASSERT(nfdev != NULL);
> +
> +	xendev = nfdev->xendev;
> +	UK_ASSERT(xendev != NULL);
> +
> +	uk_pr_debug("Close network: backend at %s\n", xendev->otherend);
> +
> +	rc = xenbus_switch_state(XBT_NIL, xendev, XenbusStateClosing);
> +	if (rc)
> +		goto out;
> +
> +	rc = netfront_xb_wait_be_disconnect(nfdev);
> +	if (rc)
> +		goto out;
> +
> +	netfront_xb_front_fini(nfdev, XBT_NIL);
> +
> +out:
> +	return rc;
> +}
> +
> +static int be_watch_start(struct xenbus_device *xendev, const char *path)
> +{
> +	struct xenbus_watch *watch;
> +
> +	watch = xs_watch_path(XBT_NIL, path);
> +	if (PTRISERR(watch))
> +		return PTR2ERR(watch);
> +
> +	xendev->otherend_watch = watch;
> +
> +	return 0;
> +}
> +
> +static int be_watch_stop(struct xenbus_device *xendev)
> +{
> +	return xs_unwatch(XBT_NIL, xendev->otherend_watch);
> +}
> +
> +#define WAIT_BE_STATE_CHANGE_WHILE_COND(state_cond) \
> +	do { \
> +		rc = xs_read_integer(XBT_NIL, be_state_path, \
> +			(int *) &be_state); \
> +		if (rc) \
> +			goto out; \
> +		while (!rc && (state_cond)) \
> +			rc = xenbus_wait_for_state_change(be_state_path, \
> +				&be_state, xendev->otherend_watch); \
> +		if (rc) \
> +			goto out; \
> +	} while (0)
> +
> +static int netfront_xb_wait_be_connect(struct netfront_dev *nfdev)
> +{
> +	struct xenbus_device *xendev = nfdev->xendev;
> +	char be_state_path[strlen(xendev->otherend) + sizeof("/state")];
> +	XenbusState be_state;
> +	int rc;
> +
> +	sprintf(be_state_path, "%s/state", xendev->otherend);
> +
> +	rc = be_watch_start(xendev, be_state_path);
> +	if (rc)
> +		goto out;
> +
> +	WAIT_BE_STATE_CHANGE_WHILE_COND(be_state < XenbusStateConnected);
> +
> +	if (be_state != XenbusStateConnected) {
> +		uk_pr_err("Backend not available, state=%s\n",
> +				xenbus_state_to_str(be_state));
> +		be_watch_stop(xendev);
> +	}
> +
> +out:
> +	return rc;
> +}
> +
> +static int netfront_xb_wait_be_disconnect(struct netfront_dev *nfdev)
> +{
> +	struct xenbus_device *xendev = nfdev->xendev;
> +	char be_state_path[strlen(xendev->otherend) + sizeof("/state")];
> +	XenbusState be_state;
> +	int rc;
> +
> +	sprintf(be_state_path, "%s/state", xendev->otherend);
> +
> +	WAIT_BE_STATE_CHANGE_WHILE_COND(be_state < XenbusStateClosing);
> +
> +	rc = xenbus_switch_state(XBT_NIL, xendev, XenbusStateClosed);
> +	if (rc)
> +		goto out;
> +
> +	WAIT_BE_STATE_CHANGE_WHILE_COND(be_state < XenbusStateClosed);
> +
> +	rc = xenbus_switch_state(XBT_NIL, xendev, XenbusStateInitialising);
> +	if (rc)
> +		goto out;
> +
> +	WAIT_BE_STATE_CHANGE_WHILE_COND(be_state < XenbusStateInitWait ||
> +			be_state >= XenbusStateClosed);
> +
> +	be_watch_stop(xendev);
> +
> +out:
> +	return rc;
> +}


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 13:39:00 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 13:39:00 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10447.27758 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVanz-0003fj-VG; Thu, 22 Oct 2020 13:38:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10447.27758; Thu, 22 Oct 2020 13:38:59 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVanz-0003fc-SQ; Thu, 22 Oct 2020 13:38:59 +0000
Received: by outflank-mailman (input) for mailman id 10447;
 Thu, 22 Oct 2020 13:38:58 +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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVany-0003fU-FA
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:38:58 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id c71ca6f5-aa19-40cb-87b6-c867e4c13e4c;
 Thu, 22 Oct 2020 13:38:48 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 14985103AE4;
 Thu, 22 Oct 2020 15:38:47 +0200 (CEST)
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 y4SwGyCg9_GF; Thu, 22 Oct 2020 15:38:46 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id E038110391F;
 Thu, 22 Oct 2020 15:38:46 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:38:46 +0200
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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVany-0003fU-FA
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:38:58 +0000
X-Inumbo-ID: c71ca6f5-aa19-40cb-87b6-c867e4c13e4c
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id c71ca6f5-aa19-40cb-87b6-c867e4c13e4c;
	Thu, 22 Oct 2020 13:38:48 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 14985103AE4;
	Thu, 22 Oct 2020 15:38: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 y4SwGyCg9_GF; Thu, 22 Oct 2020 15:38:46 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id E038110391F;
	Thu, 22 Oct 2020 15:38:46 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:38:46 +0200
Subject: Re: [UNIKRAFT PATCH v4 10/12] plat/xen/drivers/net: Add transmit
 operation
To: Simon Kuenzer <simon.kuenzer@neclab.eu>, Costin Lupu
	<costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
CC: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-11-costin.lupu@cs.pub.ro>
 <494d8796-a3e0-a3d5-df36-6343df10d571@neclab.eu>
 <c71f09f9-79b7-816f-bced-a190ed6665fc@cs.pub.ro>
 <726dd84d-33cb-877f-3e22-a5d92870ac35@neclab.eu>
 <06f26c34-1a23-6fae-d5ba-46b4b49dfc13@cs.pub.ro>
 <a106f115-336c-d97c-f441-f130633c4c53@neclab.eu>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <86653183-2b07-4d26-83fc-53dcd265f31a@neclab.eu>
Date: Thu, 22 Oct 2020 15:38:23 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <a106f115-336c-d97c-f441-f130633c4c53@neclab.eu>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Please find the review comments inline:

Thanks & Regards

Sharan

On 8/21/20 3:04 PM, Simon Kuenzer wrote:
> On 21.08.20 13:24, Costin Lupu wrote:
>> On 8/21/20 1:49 PM, Simon Kuenzer wrote:
>>> On 21.08.20 11:32, Costin Lupu wrote:
>>>> On 8/20/20 6:49 PM, Simon Kuenzer wrote:
>>>>> On 13.08.20 10:53, Costin Lupu wrote:
>>>>>> Whenever a packet is transmitted, the request describing it is 
>>>>>> written
>>>>>> in the
>>>>>> shared ring. The packet itself is written in a page referenced by 
>>>>>> the
>>>>>> request
>>>>>> and shared, as well, with the backend. At the end of each transmit
>>>>>> operation, a
>>>>>> cleanup operation is performed free'ing the resources allocated 
>>>>>> for the
>>>>>> previously transmitted packets.
>>>>>>
>>>>>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>>>>>> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
>>>>>> ---
>>>>>>     plat/xen/drivers/net/netfront.c | 102
>>>>>> ++++++++++++++++++++++++++++++++
>>>>>>     1 file changed, 102 insertions(+)
>>>>>>
>>>>>> diff --git a/plat/xen/drivers/net/netfront.c
>>>>>> b/plat/xen/drivers/net/netfront.c
>>>>>> index 858d124a..f2b81329 100644
>>>>>> --- a/plat/xen/drivers/net/netfront.c
>>>>>> +++ b/plat/xen/drivers/net/netfront.c
>>>>>> @@ -39,6 +39,7 @@
>>>>>>     #include <uk/alloc.h>
>>>>>>     #include <uk/netdev_driver.h>
>>>>>>     #include <xen-x86/mm.h>
>>>>>> +#include <xen-x86/irq.h>
>>>>>>     #include <xenbus/xenbus.h>
>>>>>>     #include "netfront.h"
>>>>>>     #include "netfront_xb.h"
>>>>>> @@ -78,6 +79,106 @@ static uint16_t get_id_from_freelist(uint16_t
>>>>>> *freelist)
>>>>>>         return id;
>>>>>>     }
>>>>>>     +static int network_tx_buf_gc(struct uk_netdev_tx_queue *txq)
>>>>>> +{
>>>>>> +    RING_IDX prod, cons;
>>>>>> +    netif_tx_response_t *tx_rsp;
>>>>>> +    uint16_t id;
>>>>>> +    bool more_to_do;
>>>>>> +    int count = 0;
>>>>>> +
>>>>>> +    do {
>>>>>> +        prod = txq->ring.sring->rsp_prod;
>>>>>> +        rmb(); /* Ensure we see responses up to 'rp'. */
>>>>>> +
>>>>>> +        for (cons = txq->ring.rsp_cons; cons != prod; cons++) {
>>>>>> +            tx_rsp = RING_GET_RESPONSE(&txq->ring, cons);
>>>>>> +
>>>>>> +            if (tx_rsp->status == NETIF_RSP_NULL)
>>>>>> +                continue;
>>>>>> +
>>>>>> +            if (tx_rsp->status == NETIF_RSP_ERROR)
>>>>>> +                uk_pr_err("packet error\n");
>>>>>
>>>>> "netdev%u: Transmission error on txq %u\n" ?
>>>>>
>>>>
>>>> Ack.
>>>>
>>>>>> +
>>>>>> +            id  = tx_rsp->id;
>>>>>> +            UK_ASSERT(id < NET_TX_RING_SIZE);
>>>>>> +
>>>>>> +            gnttab_end_access(txq->gref[id]);
>>>>>> +            txq->gref[id] = GRANT_INVALID_REF;
>>>>>> +
>>>>>> +            add_id_to_freelist(id, txq->freelist);
>>>>>> +            uk_semaphore_up(&txq->sem);
Shouldn't we free up the netbuf we receive from the ring?
>>>>>> +
>>>>>> +            count++;
>>>>>> +        }
>>>>>> +
>>>>>> +        txq->ring.rsp_cons = prod;
>>>>>> +
>>>>>> + RING_FINAL_CHECK_FOR_RESPONSES(&txq->ring, more_to_do);
>>>>>> +    } while (more_to_do);
>>>>>> +
>>>>>> +    return count;
>>>>>> +}
>>>>>> +
>>>>>> +static int netfront_xmit(struct uk_netdev *n,
>>>>>> +        struct uk_netdev_tx_queue *txq,
>>>>>> +        struct uk_netbuf *pkt)
>>>>>> +{
>>>>>> +    struct netfront_dev *nfdev;
>>>>>> +    unsigned long flags;
>>>>>> +    uint16_t id;
>>>>>> +    RING_IDX req_prod;
>>>>>> +    netif_tx_request_t *tx_req;
>>>>>> +    int notify;
>>>>>> +    int status = 0, count;
>>>>>> +
>>>>>> +    UK_ASSERT(n != NULL);
>>>>>> +    UK_ASSERT(txq != NULL);
>>>>>> +    UK_ASSERT(pkt != NULL);
>>>>>> +    UK_ASSERT(pkt->len < PAGE_SIZE);
>>>>>> +
>>>>>> +    nfdev = to_netfront_dev(n);
>>>>>> +
>>>>>> +    /* get request id */
>>>>>> +    uk_semaphore_down(&txq->sem);
>>>>>> +    local_irq_save(flags);
>>>>>> +    id = get_id_from_freelist(txq->freelist);
>>>>>
>>>>> What happens when we are out of space and the ring is full?
>>>>> The xmit function should be non-blocking so that we can use it in
>>>>> polling mode. We should return in such a case that the transmission
>>>>> queue is currently full...
>>>>>
>>>>
>>>> Ack.
>>>>
>>>>>> +    local_irq_restore(flags);
>>>>>> +
>>>>>> +    /* get request */
>>>>>> +    req_prod = txq->ring.req_prod_pvt;
>>>>>> +    tx_req = RING_GET_REQUEST(&txq->ring, req_prod); > +
>>>>>> +    /* setup grant for buffer data */
>>>>>> +    txq->gref[id] = tx_req->gref =
>>>>>> + gnttab_grant_access(nfdev->xendev->otherend_id,
>>>>>> +            virt_to_mfn(pkt->data), 1);
>>>>>> +    UK_ASSERT(tx_req->gref != GRANT_INVALID_REF);
>>>>>> +
>>>>>> +    tx_req->offset = 0;
>>>>>> +    tx_req->size = (uint16_t) pkt->len;
>>>>>> +    tx_req->flags = 0;
>>>>>> +    tx_req->id = id;
>>>>>> +
>>>>>> +    txq->ring.req_prod_pvt = req_prod + 1;
>>>>>> +    wmb(); /* Ensure backend sees requests */
>>>>>> +
>>>>>> + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&txq->ring, notify);
>>>>>> +    if (notify)
>>>>>> +        notify_remote_via_evtchn(txq->evtchn); > +
>>>>>> +    status |= UK_NETDEV_STATUS_SUCCESS;
>>>>>> +
>>>>>> +    /* some cleanup */
>>>>>> +    local_irq_save(flags);
>>>>>> +    count = network_tx_buf_gc(txq);
>>>>>
>>>>> The clean-up should happen before enqueuing the given packet to the
>>>>> transmit queue, it is the first thing of xmit(). Since we anyway 
>>>>> need to
>>>>> do it and we do not have an advantage by delaying this operation.
>>>>
>>>> Of course there is an advantage. You push the packets in order for 
>>>> them
>>>> to be processed ASAP by the backend and deal with cleaning up
>>>> afterwards. It's a kind of parallelization. Otherwise you would delay
>>>> the transmissions.
>>>>
>>>>> We can also deal much better with full rings. Otherwise we
>>>>> unnecessarily drop a packets for transmission although there would
>>>>> have been space when clean-up finished. After calling cleaning you
>>>>> can check if there is space on the ring and return if we run out of
>>>>> it (use an `unlikely` to the condition so that we speed up the
>>>>> successful sending case).
>>>>>
>>>>
>>>> The only scenario when this would solve anything would be when you 
>>>> have
>>>> the ring full and just before you decide to send a new packet the
>>>> backend starts processing your previous transmitted packets, 
>>>> leaving you
>>>> at least one free slot. There are 2 unlikely events here: first, the
>>>> ring is full, and second, the backend starts to process again when the
>>>> ring gets full (for the latter event, it's unlikely that the backend
>>>> will wake up given that it couldn't process 256 transmitted packets,
>>>> where 256 is the current number of slots). And for this very unlikely
>>>> context you would introduce a delay for all the transmissions if we
>>>> followed your suggestion.
>>>>
>>>> Anyway, both Linux and FreeBSD do the cleanup after pushing the
>>>> requests, so I don't think we have much more to say about this.
>>>>
>>>
>>> Hum... I double-checked with Intel DPDK's ixgbe (10 Gig) driver:
>>>
>>> http://git.dpdk.org/dpdk-stable/tree/drivers/net/ixgbe/ixgbe_rxtx.c?h=20.02#n230 
>>>
>>>
>>>
>>> They clean the slots before sending. I derived my conclusion from 
>>> there.
>>> However I noticed now that there is one minor difference: They do 
>>> both -
>>> cleanup and enqueuing - before they notify the card about changes on 
>>> the
>>> ring. In that case it does not add any delay if you swap the order of
>>> cleanup and enqueuing. In your case this is probably different because
>>> you can cleanup without notifying. Here, I agree with you that we add
>>> unnecessary xmit delays by swapping the order.
>>>
>>
>> ixgbe is a native driver, so there is no backend driver in that case.
>> It's a different scenario.
>
> You could consider the card itself as a backend driver, but fine. 
> There is a ABI difference between ixgbe and netback.
>
>>
>>> However and in general, having a full ring is not an uncommon and
>>> unlikely case. To my experience, this can already happen with a single
>>> TCP connection if your network stack is feeding next packets fast 
>>> enough
>>> and if the current TCP window allows to send them. It also depends on
>>> when the driver domain is scheduled; on which CPU core your netfront
>>> domain and the driver domain sit; and even on the underlying physical
>>> device that might be busy with other traffic.
>>>
>>
>> What I tried to say with the events probabilities explanation is that
>> you add delay for the common case in order to remove delay for the much
>> less probable corner case.
>
> I got that and agreed.
>
>>
>>> Another thing we are having in mind for uknetdev - and this is probably
>>> different to Linux/BSD's implementation - we plan to change the xmit
>>> function to do batching (as DPDK does). Sharan could push virtio-net
>>> performance further with this. You are able to reduce the number of
>>> notifies to the backend because you enqueue multiple packets at once 
>>> and
>>> due to locality of batching you can utilize CPU caches ways better.
>>>
>>> What about this idea for netfront: We could do first a check for
>>> available space and - if needed - clean-up just as many extra slots 
>>> that
>>> you need to complete the transmission (for now this is anyways just one
>>> slot). Then we proceed with enqueuing and do the cleanup of the rest of
>>> the slots after we notified the backend. What do you think?
>>>
>>
>> This will stay just as it is for the current patches. Feel free to
>> change anything after upstreaming these patches.
>
> No, it won't stay like this. At least, you have to call clean-up when 
> the ring is full before you leave the non-blocking function. Otherwise 
> you end up in never getting space back on a full ring, but I think 
> this is clear.
>
>>
>>>>
>>>> Btw, I'm waiting for reviews on the other patches as well before I 
>>>> send
>>>> the v5.
>>>
>>> Yes, sure.
>>>
>>>>
>>>>
>>>>>> +    local_irq_restore(flags);
>>>>>> +
>>>>>> +    status |= likely(count > 0) ? UK_NETDEV_STATUS_MORE : 0x0;
>>>>>> +
>>>>>> +    return status;
>>>>>> +}
>>>>>> +
>>>>>>     static int netfront_rxq_enqueue(struct uk_netdev_rx_queue *rxq,
>>>>>>             struct uk_netbuf *netbuf)
>>>>>>     {
>>>>>> @@ -598,6 +699,7 @@ static int netfront_add_dev(struct xenbus_device
>>>>>> *xendev)
>>>>>>         }
>>>>>>           /* register netdev */
>>>>>> +    nfdev->netdev.tx_one = netfront_xmit;
>>>>>>         nfdev->netdev.ops = &netfront_ops;
>>>>>>         rc = uk_netdev_drv_register(&nfdev->netdev, drv_allocator,
>>>>>> DRIVER_NAME);
>>>>>>         if (rc < 0) {
>>>>>>
>>>>>
>>>
>>> Thanks,
>>>
>>> Simon
>>>


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 13:41:02 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 13:41:02 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10454.27774 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVapy-0004W1-JM; Thu, 22 Oct 2020 13:41:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10454.27774; Thu, 22 Oct 2020 13:41:02 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVapy-0004Vu-GX; Thu, 22 Oct 2020 13:41:02 +0000
Received: by outflank-mailman (input) for mailman id 10454;
 Thu, 22 Oct 2020 13:41:01 +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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVapx-0004Vp-3c
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:41:01 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id bd0cbbcf-3bec-43dc-9679-28969257fc00;
 Thu, 22 Oct 2020 13:40:59 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id EAD3CF2233;
 Thu, 22 Oct 2020 15:40:58 +0200 (CEST)
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 1T6ETDicgaC1; Thu, 22 Oct 2020 15:40:58 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id BEE78F2232;
 Thu, 22 Oct 2020 15:40:52 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:40:52 +0200
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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVapx-0004Vp-3c
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:41:01 +0000
X-Inumbo-ID: bd0cbbcf-3bec-43dc-9679-28969257fc00
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id bd0cbbcf-3bec-43dc-9679-28969257fc00;
	Thu, 22 Oct 2020 13:40:59 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id EAD3CF2233;
	Thu, 22 Oct 2020 15:40:58 +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 1T6ETDicgaC1; Thu, 22 Oct 2020 15:40:58 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id BEE78F2232;
	Thu, 22 Oct 2020 15:40:52 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:40:52 +0200
Subject: Re: [UNIKRAFT PATCH v4 11/12] plat/xen/drivers/net: Add receive
 operation
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
CC: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-12-costin.lupu@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <dedf2594-7e8b-dec0-92d3-148e55330ec0@neclab.eu>
Date: Thu, 22 Oct 2020 15:40:51 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20200813085342.29799-12-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Please find the review comment inline:

Thanks & Regards
Sharan

On 8/13/20 10:53 AM, Costin Lupu wrote:
> Incoming packets are written in pages allocated by the netfront. Such pages are
> allocated and registered to the shared ring after completion of receiving
> operations.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
> ---
>   plat/xen/drivers/net/netfront.c | 100 ++++++++++++++++++++++++++++++++
>   1 file changed, 100 insertions(+)
>
> diff --git a/plat/xen/drivers/net/netfront.c b/plat/xen/drivers/net/netfront.c
> index f2b81329..101e38c8 100644
> --- a/plat/xen/drivers/net/netfront.c
> +++ b/plat/xen/drivers/net/netfront.c
> @@ -221,6 +221,49 @@ static int netfront_rxq_enqueue(struct uk_netdev_rx_queue *rxq,
>   	return 0;
>   }
>   
> +static int netfront_rxq_dequeue(struct uk_netdev_rx_queue *rxq,
> +		struct uk_netbuf **netbuf)
> +{
> +	RING_IDX prod, cons;
> +	netif_rx_response_t *rx_rsp;
> +	uint16_t len, id;
> +	struct uk_netbuf *buf = NULL;
> +	int count = 0;
> +
> +	UK_ASSERT(rxq != NULL);
> +	UK_ASSERT(netbuf != NULL);
> +
> +	prod = rxq->ring.sring->rsp_prod;
> +	rmb(); /* Ensure we see queued responses up to 'rp'. */
> +	cons = rxq->ring.rsp_cons;
> +	/* No new descriptor since last dequeue operation */
> +	if (cons == prod)

We should set it here:

*netbuf = NULL;

> +		goto out;
> +
> +	/* get response */
> +	rx_rsp = RING_GET_RESPONSE(&rxq->ring, cons);
> +	UK_ASSERT(rx_rsp->status > NETIF_RSP_NULL);
> +	id = rx_rsp->id;
> +	UK_ASSERT(id < NET_RX_RING_SIZE);
> +
> +	/* remove grant for buffer data */
> +	gnttab_end_access(rxq->gref[id]);
> +
> +	buf = rxq->netbuf[id];
> +	len = (uint16_t) rx_rsp->status;
> +	if (len > ETH_PKT_LEN)
> +		len = ETH_PKT_LEN;
> +	buf->len = len;
> +
> +	*netbuf = buf;
> +
> +	rxq->ring.rsp_cons++;
> +	count = 1;
> +
> +out:
> +	return count;
> +}
> +
>   static int netfront_rx_fillup(struct uk_netdev_rx_queue *rxq, uint16_t nb_desc)
>   {
>   	struct uk_netbuf *netbuf[nb_desc];
> @@ -271,6 +314,62 @@ static int netfront_rxq_intr_enable(struct uk_netdev_rx_queue *rxq)
>   	return (more > 0);
>   }
>   
> +static int netfront_recv(struct uk_netdev *n,
> +		struct uk_netdev_rx_queue *rxq,
> +		struct uk_netbuf **pkt)
> +{
> +	int rc, status = 0;
> +
> +	UK_ASSERT(n != NULL);
> +	UK_ASSERT(rxq != NULL);
> +	UK_ASSERT(pkt != NULL);
> +
> +	/* Queue interrupts have to be off when calling receive */
> +	UK_ASSERT(!(rxq->intr_enabled & NETFRONT_INTR_EN));
> +
> +	rc = netfront_rxq_dequeue(rxq, pkt);
> +	UK_ASSERT(rc >= 0);
> +
> +	status |= (*pkt) ? UK_NETDEV_STATUS_SUCCESS : 0x0;
> +	status |= netfront_rx_fillup(rxq, rc);
> +
> +	/* Enable interrupt only when user had previously enabled it */
> +	if (rxq->intr_enabled & NETFRONT_INTR_USR_EN_MASK) {
> +		/* Need to enable the interrupt on the last packet */
> +		rc = netfront_rxq_intr_enable(rxq);
> +		if (rc == 1 && !(*pkt)) {
> +			/**
> +			 * Packet arrive after reading the queue and before
> +			 * enabling the interrupt
> +			 */
> +			rc = netfront_rxq_dequeue(rxq, pkt);
> +			UK_ASSERT(rc >= 0);
> +			status |= UK_NETDEV_STATUS_SUCCESS;
> +
> +			/*
> +			 * Since we received something, we need to fillup
> +			 * and notify
> +			 */
> +			status |= netfront_rx_fillup(rxq, rc);
> +
> +			/* Need to enable the interrupt on the last packet */
> +			rc = netfront_rxq_intr_enable(rxq);
> +			status |= (rc == 1) ? UK_NETDEV_STATUS_MORE : 0x0;
> +		} else if (*pkt) {
> +			/* When we originally got a packet and there is more */
> +			status |= (rc == 1) ? UK_NETDEV_STATUS_MORE : 0x0;
> +		}
> +	} else if (*pkt) {
> +		/**
> +		 * For polling case, we report always there are further
> +		 * packets unless the queue is empty.
> +		 */
> +		status |= UK_NETDEV_STATUS_MORE;
> +	}
> +
> +	return status;
> +}
> +
>   static struct uk_netdev_tx_queue *netfront_txq_setup(struct uk_netdev *n,
>   		uint16_t queue_id,
>   		uint16_t nb_desc __unused,
> @@ -700,6 +799,7 @@ static int netfront_add_dev(struct xenbus_device *xendev)
>   
>   	/* register netdev */
>   	nfdev->netdev.tx_one = netfront_xmit;
> +	nfdev->netdev.rx_one = netfront_recv;
>   	nfdev->netdev.ops = &netfront_ops;
>   	rc = uk_netdev_drv_register(&nfdev->netdev, drv_allocator, DRIVER_NAME);
>   	if (rc < 0) {


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 13:43:26 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 13:43:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10457.27779 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVasH-0004fS-QT; Thu, 22 Oct 2020 13:43:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10457.27779; Thu, 22 Oct 2020 13:43:25 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVasH-0004fL-Na; Thu, 22 Oct 2020 13:43:25 +0000
Received: by outflank-mailman (input) for mailman id 10457;
 Thu, 22 Oct 2020 13:43: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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVasG-0004fG-Kx
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:43:24 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 673b4010-7aca-4574-a068-0882d44fad53;
 Thu, 22 Oct 2020 13:43:23 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id C88411040D5;
 Thu, 22 Oct 2020 15:43:22 +0200 (CEST)
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 lp2Pwq0CnHHg; Thu, 22 Oct 2020 15:43:22 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id A34D9103AE4;
 Thu, 22 Oct 2020 15:43:22 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:43:22 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVasG-0004fG-Kx
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:43:24 +0000
X-Inumbo-ID: 673b4010-7aca-4574-a068-0882d44fad53
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 673b4010-7aca-4574-a068-0882d44fad53;
	Thu, 22 Oct 2020 13:43:23 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id C88411040D5;
	Thu, 22 Oct 2020 15:43:22 +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 lp2Pwq0CnHHg; Thu, 22 Oct 2020 15:43:22 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id A34D9103AE4;
	Thu, 22 Oct 2020 15:43:22 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:43:22 +0200
Subject: Re: [UNIKRAFT PATCH v4 12/12] lib/uknetdev: Enable default drivers
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-13-costin.lupu@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <b1e46f2b-3268-46ad-0bf5-f24b5d32516b@neclab.eu>
Date: Thu, 22 Oct 2020 15:43:20 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20200813085342.29799-13-costin.lupu@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Please find the comments inline

Thanks & Regards

Sharan

On 8/13/20 10:53 AM, Costin Lupu wrote:
> Currently, for KVM and Xen we only have one network driver each. We enable
> them by default whenever uknetdev library is enabled.
>
> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
> ---
>   lib/uknetdev/Config.uk | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/lib/uknetdev/Config.uk b/lib/uknetdev/Config.uk
> index 186dd462..2af47efb 100644
> --- a/lib/uknetdev/Config.uk
> +++ b/lib/uknetdev/Config.uk
> @@ -5,6 +5,8 @@ menuconfig LIBUKNETDEV
>   	select LIBUKDEBUG
>   	select LIBUKALLOC
>   	imply LIBUKLIBPARAM
> +	imply VIRTIO_NET if PLAT_KVM
> +	imply XEN_NETFRONT if PLAT_XEN

Instead of imply we can set `default y if LIBUKNETDEV` in each of the 
driver kconfig.

What do you think?

>   
>   if LIBUKNETDEV
>   	config LIBUKNETDEV_MAXNBQUEUES


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 13:45:17 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 13:45:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10460.27783 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVau4-0004iB-Te; Thu, 22 Oct 2020 13:45:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10460.27783; Thu, 22 Oct 2020 13:45:16 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVau4-0004i4-Qc; Thu, 22 Oct 2020 13:45:16 +0000
Received: by outflank-mailman (input) for mailman id 10460;
 Thu, 22 Oct 2020 13:45: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=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kVau3-0004hz-G5
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:45:15 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id ae631966-90fd-4041-8c4c-9436565e8744;
 Thu, 22 Oct 2020 13:45:14 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 2E648F2234;
 Thu, 22 Oct 2020 15:45:13 +0200 (CEST)
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 Xo61V685JTsx; Thu, 22 Oct 2020 15:45:13 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id DD3E4F2232
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 15:45:10 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:45:10 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=Xwwe=D5=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kVau3-0004hz-G5
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 13:45:15 +0000
X-Inumbo-ID: ae631966-90fd-4041-8c4c-9436565e8744
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id ae631966-90fd-4041-8c4c-9436565e8744;
	Thu, 22 Oct 2020 13:45:14 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 2E648F2234;
	Thu, 22 Oct 2020 15:45:13 +0200 (CEST)
X-Virus-Scanned: Amavisd on Debian GNU/Linux (atlas-b.office.hd)
Received: from mailer2.neclab.eu ([127.0.0.1])
	by localhost (atlas-b.office.hd [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Xo61V685JTsx; Thu, 22 Oct 2020 15:45:13 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id DD3E4F2232
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 15:45:10 +0200 (CEST)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 15:45:10 +0200
Subject: Re: [UNIKRAFT PATCH] lib/uknetdev: UK_ETH_FRAME_8021AD_MAXLEN: Fix
 typo
To: Simon Kuenzer <simon.kuenzer@neclab.eu>, <minios-devel@lists.xen.org>
CC: Felipe Huici <felipe.huici@neclab.eu>
References: <20201001144734.32159-1-simon.kuenzer@neclab.eu>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <448ff0c9-f9cf-dd62-4b8a-99a4384ad77f@neclab.eu>
Date: Thu, 22 Oct 2020 15:44:44 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20201001144734.32159-1-simon.kuenzer@neclab.eu>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Hello Simon,

Thanks for the work.

Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>

Thanks & Regards

Sharan

On 10/1/20 4:47 PM, Simon Kuenzer wrote:
> This commit fixes a typo in the `UK_ETH_FRAME_8021AD_MAXLEN`
> definition that causes also a compilation issue when using the
> `UK_ETH_FRAME_MAXLEN` definition.
>
> Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
> ---
>   lib/uknetdev/include/uk/netdev_core.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/uknetdev/include/uk/netdev_core.h b/lib/uknetdev/include/uk/netdev_core.h
> index b9a994e3..e7fa97f2 100644
> --- a/lib/uknetdev/include/uk/netdev_core.h
> +++ b/lib/uknetdev/include/uk/netdev_core.h
> @@ -103,7 +103,7 @@ UK_TAILQ_HEAD(uk_netdev_list, struct uk_netdev);
>   					 UK_ETH_PAYLOAD_MAXLEN)
>   #define UK_ETH_FRAME_8021Q_MAXLEN	(UK_ETH_HDR_8021_LEN + \
>   					 UK_ETH_PAYLOAD_MAXLEN)
> -#define UK_ETH_FRAME_8021AD_MAXLEN	(UK_ETH_HDR_8021ADLEN + \
> +#define UK_ETH_FRAME_8021AD_MAXLEN	(UK_ETH_HDR_8021AD_LEN + \
>   					 UK_ETH_PAYLOAD_MAXLEN)
>   #define UK_ETH_FRAME_MAXLEN		(UK_ETH_FRAME_8021AD_MAXLEN)
>   


From minios-devel-bounces@lists.xenproject.org Thu Oct 22 14:44:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 22 Oct 2020 14:44:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10494.27892 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVbpd-0002hZ-Db; Thu, 22 Oct 2020 14:44:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10494.27892; Thu, 22 Oct 2020 14:44:45 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVbpd-0002hR-AE; Thu, 22 Oct 2020 14:44:45 +0000
Received: by outflank-mailman (input) for mailman id 10494;
 Thu, 22 Oct 2020 14:44: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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVbpb-0002h9-Sn
 for minios-devel@lists.xen.org; Thu, 22 Oct 2020 14:44:43 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 92d4dd97-8d8e-41c2-89e4-8882d737f036;
 Thu, 22 Oct 2020 14:44:40 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id E57D4103A1C;
 Thu, 22 Oct 2020 16:44:39 +0200 (CEST)
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 yWU8uDYg8He7; Thu, 22 Oct 2020 16:44:39 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id C5FD8101371
 for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 16:44:39 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 16:44:39 +0200
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=2/LL=D5=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVbpb-0002h9-Sn
	for minios-devel@lists.xen.org; Thu, 22 Oct 2020 14:44:43 +0000
X-Inumbo-ID: 92d4dd97-8d8e-41c2-89e4-8882d737f036
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 92d4dd97-8d8e-41c2-89e4-8882d737f036;
	Thu, 22 Oct 2020 14:44:40 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id E57D4103A1C;
	Thu, 22 Oct 2020 16:44:39 +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 yWU8uDYg8He7; Thu, 22 Oct 2020 16:44:39 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id C5FD8101371
	for <minios-devel@lists.xen.org>; Thu, 22 Oct 2020 16:44:39 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct
 2020 16:44:39 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Felipe Huici
	<felipe.huici@neclab.eu>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH] plat/xen: Automatically enable blkfront, 9pfront
Date: Thu, 22 Oct 2020 16:44:26 +0200
Message-ID: <20201022144426.12066-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 titania.office.hd
 (192.168.24.89)

Automatically enables drivers in the configuration when according backend
libraries are enabled. This commit affects blkfront and 9pfront.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 plat/xen/Config.uk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/plat/xen/Config.uk b/plat/xen/Config.uk
index 3e542be1..ec7b580b 100644
--- a/plat/xen/Config.uk
+++ b/plat/xen/Config.uk
@@ -100,6 +100,7 @@ config XEN_NETFRONT
 
 menuconfig XEN_BLKFRONT
 	bool "Xenbus Blkfront Driver"
+	default y if LIBUKBLKDEV
 	default n
 	depends on LIBUKBLKDEV
 	help
@@ -125,6 +126,7 @@ config XEN_BLKFRONT_GREFPOOL
 
 menuconfig XEN_9PFRONT
 	bool "Xenbus 9pfront Driver"
+	default y if LIBUK9P
 	default n
 	depends on LIBUK9P
 	help
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 11:58:25 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 11:58:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10899.29042 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVviB-0002uT-89; Fri, 23 Oct 2020 11:58:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10899.29042; Fri, 23 Oct 2020 11:58:23 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVviB-0002uM-53; Fri, 23 Oct 2020 11:58:23 +0000
Received: by outflank-mailman (input) for mailman id 10899;
 Fri, 23 Oct 2020 11:58: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVvi9-0002uH-JK
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:21 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id dca974c0-57e9-49ee-b40b-0bfd61be5ead;
 Fri, 23 Oct 2020 11:58:19 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 81F90F210C;
 Fri, 23 Oct 2020 13:58:18 +0200 (CEST)
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 B0eBAGiKm2Dt; Fri, 23 Oct 2020 13:58:18 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 4F651F225C
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:16 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:16 +0200
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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVvi9-0002uH-JK
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:21 +0000
X-Inumbo-ID: dca974c0-57e9-49ee-b40b-0bfd61be5ead
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id dca974c0-57e9-49ee-b40b-0bfd61be5ead;
	Fri, 23 Oct 2020 11:58:19 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 81F90F210C;
	Fri, 23 Oct 2020 13: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 B0eBAGiKm2Dt; Fri, 23 Oct 2020 13:58:18 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 4F651F225C
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:16 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:16 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 0/5] Memory Pools
Date: Fri, 23 Oct 2020 13:56:49 +0200
Message-ID: <20201023115654.1899-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 titania.office.hd
 (192.168.24.89)

This series implements a memory pool allocator. Pool objects have the same
size and are pre-allocated. Due to this simplification allocations and free
operations are as cheap as O(1). Its intended use is performance critical
allocations when allocation sizes do not vary, like network stacks or disk
buffer caches.

Simon Kuenzer (5):
  lib/ukallocpool: Library skeleton
  lib/ukallocpool: LIFO pool implementation
  lib/ukallocpool: Allocate pool on parent allocator
  lib/ukallocpool: `lib/ukalloc` compatible interface
  lib/ukallocpool: Batched allocation

 lib/Makefile.uk                        |   1 +
 lib/ukallocpool/Config.uk              |   6 +
 lib/ukallocpool/Makefile.uk            |   6 +
 lib/ukallocpool/exportsyms.uk          |  10 +
 lib/ukallocpool/include/uk/allocpool.h | 206 +++++++++++++++
 lib/ukallocpool/pool.c                 | 347 +++++++++++++++++++++++++
 6 files changed, 576 insertions(+)
 create mode 100644 lib/ukallocpool/Config.uk
 create mode 100644 lib/ukallocpool/Makefile.uk
 create mode 100644 lib/ukallocpool/exportsyms.uk
 create mode 100644 lib/ukallocpool/include/uk/allocpool.h
 create mode 100644 lib/ukallocpool/pool.c

-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 11:58:32 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 11:58:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10900.29046 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVviK-0002vJ-9z; Fri, 23 Oct 2020 11:58:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10900.29046; Fri, 23 Oct 2020 11:58:32 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVviK-0002vC-6t; Fri, 23 Oct 2020 11:58:32 +0000
Received: by outflank-mailman (input) for mailman id 10900;
 Fri, 23 Oct 2020 11:58: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVviJ-0002v6-E8
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:31 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id dbe46252-7588-498c-a2d3-c8ea13df95b5;
 Fri, 23 Oct 2020 11:58:29 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 87F19103EC2;
 Fri, 23 Oct 2020 13:58:28 +0200 (CEST)
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 LF0Ml-tJ-AvF; Fri, 23 Oct 2020 13:58:28 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 676B7103AE4
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:28 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:28 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVviJ-0002v6-E8
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:31 +0000
X-Inumbo-ID: dbe46252-7588-498c-a2d3-c8ea13df95b5
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id dbe46252-7588-498c-a2d3-c8ea13df95b5;
	Fri, 23 Oct 2020 11:58:29 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 87F19103EC2;
	Fri, 23 Oct 2020 13:58:28 +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 LF0Ml-tJ-AvF; Fri, 23 Oct 2020 13:58:28 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 676B7103AE4
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:28 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:28 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 1/5] lib/ukallocpool: Library skeleton
Date: Fri, 23 Oct 2020 13:56:50 +0200
Message-ID: <20201023115654.1899-2-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
References: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Registers the library skeleton for ukallocpool.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/Makefile.uk             | 1 +
 lib/ukallocpool/Config.uk   | 6 ++++++
 lib/ukallocpool/Makefile.uk | 4 ++++
 3 files changed, 11 insertions(+)
 create mode 100644 lib/ukallocpool/Config.uk
 create mode 100644 lib/ukallocpool/Makefile.uk

diff --git a/lib/Makefile.uk b/lib/Makefile.uk
index ff69dfab..7fffdac7 100644
--- a/lib/Makefile.uk
+++ b/lib/Makefile.uk
@@ -15,6 +15,7 @@ $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/nolibc))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukalloc))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocbbuddy))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocregion))
+$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocpool))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uksched))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukschedcoop))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/fdt))
diff --git a/lib/ukallocpool/Config.uk b/lib/ukallocpool/Config.uk
new file mode 100644
index 00000000..5c300117
--- /dev/null
+++ b/lib/ukallocpool/Config.uk
@@ -0,0 +1,6 @@
+config LIBUKALLOCPOOL
+	bool "ukallocpool: Memory pool allocator"
+	default n
+	select LIBNOLIBC if !HAVE_LIBC
+	select LIBUKDEBUG
+	select LIBUKALLOC
diff --git a/lib/ukallocpool/Makefile.uk b/lib/ukallocpool/Makefile.uk
new file mode 100644
index 00000000..c71c9764
--- /dev/null
+++ b/lib/ukallocpool/Makefile.uk
@@ -0,0 +1,4 @@
+$(eval $(call addlib_s,libukallocpool,$(CONFIG_LIBUKALLOCPOOL)))
+
+CINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
+CXXINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 11:58:35 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 11:58:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10901.29050 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVviN-0002w9-Be; Fri, 23 Oct 2020 11:58:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10901.29050; Fri, 23 Oct 2020 11:58:35 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVviN-0002w2-8T; Fri, 23 Oct 2020 11:58:35 +0000
Received: by outflank-mailman (input) for mailman id 10901;
 Fri, 23 Oct 2020 11:58: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVviM-0002vs-4B
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:34 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id a728c73d-9bc3-4281-a8e8-394b76fda883;
 Fri, 23 Oct 2020 11:58:32 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id E75D0F2259;
 Fri, 23 Oct 2020 13:58:31 +0200 (CEST)
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 Myp9Pz48JY9X; Fri, 23 Oct 2020 13:58:31 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id B9CE6F210C
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:29 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:29 +0200
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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVviM-0002vs-4B
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:34 +0000
X-Inumbo-ID: a728c73d-9bc3-4281-a8e8-394b76fda883
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id a728c73d-9bc3-4281-a8e8-394b76fda883;
	Fri, 23 Oct 2020 11:58:32 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id E75D0F2259;
	Fri, 23 Oct 2020 13:58:31 +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 Myp9Pz48JY9X; Fri, 23 Oct 2020 13:58:31 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id B9CE6F210C
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:29 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:29 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 2/5] lib/ukallocpool: LIFO pool implementation
Date: Fri, 23 Oct 2020 13:56:51 +0200
Message-ID: <20201023115654.1899-3-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
References: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Initial implementation of a memory pool (same-sized and fixed-sized object
allocator) following LIFO principle by using a single list to keep track of
free objects. LIFO is chosen to potentially better utilize hardware caches.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/Makefile.uk            |   2 +
 lib/ukallocpool/exportsyms.uk          |   4 +
 lib/ukallocpool/include/uk/allocpool.h | 109 +++++++++++++++
 lib/ukallocpool/pool.c                 | 186 +++++++++++++++++++++++++
 4 files changed, 301 insertions(+)
 create mode 100644 lib/ukallocpool/exportsyms.uk
 create mode 100644 lib/ukallocpool/include/uk/allocpool.h
 create mode 100644 lib/ukallocpool/pool.c

diff --git a/lib/ukallocpool/Makefile.uk b/lib/ukallocpool/Makefile.uk
index c71c9764..63c24dc1 100644
--- a/lib/ukallocpool/Makefile.uk
+++ b/lib/ukallocpool/Makefile.uk
@@ -2,3 +2,5 @@ $(eval $(call addlib_s,libukallocpool,$(CONFIG_LIBUKALLOCPOOL)))
 
 CINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
 CXXINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
+
+LIBUKALLOCPOOL_SRCS-y += $(LIBUKALLOCPOOL_BASE)/pool.c
diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
new file mode 100644
index 00000000..2f29b409
--- /dev/null
+++ b/lib/ukallocpool/exportsyms.uk
@@ -0,0 +1,4 @@
+uk_allocpool_init
+uk_allocpool_availcount
+uk_allocpool_take
+uk_allocpool_return
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
new file mode 100644
index 00000000..ce3d939d
--- /dev/null
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -0,0 +1,109 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Simple memory pool using LIFO principle
+ *
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation,
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __LIBUKALLOCPOOL_H__
+#define __LIBUKALLOCPOOL_H__
+
+#include <uk/alloc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*uk_allocpool_obj_init_t)(void *obj, size_t len, void *cookie);
+
+struct uk_allocpool;
+
+/**
+ * Initializes a memory pool on a given memory range.
+ *
+ * @param base
+ *  Base address of memory range
+ * @param len
+ *  Length of memory range (bytes)
+ * @param obj_len
+ *  Size of one object (bytes)
+ * @param obj_align
+ *  Alignment requirement for each pool object
+ * @param obj_init
+ *  Function pointer to object initialization
+ * @param obj_init_cookie
+ *  Cookie that is hand-over to object initialization
+ * @return
+ *  - (NULL): Not enough memory for pool
+ *  - pointer to initializes pool
+ */
+struct uk_allocpool *uk_allocpool_init(void *base, size_t len,
+				       size_t obj_len, size_t obj_align,
+				       uk_allocpool_obj_init_t obj_init,
+				       void *obj_init_cookie);
+
+/**
+ * Return the number of current available (free) objects
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @return
+ *  Number of free objects in the pool.
+ */
+unsigned int uk_allocpool_availcount(struct uk_allocpool *p);
+
+/**
+ * Get one object from a pool
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @return
+ *  - (NULL): No more free objects available
+ *  - Pointer to object.
+ */
+void *uk_allocpool_take(struct uk_allocpool *p);
+
+/**
+ * Return one object back to a pool
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @param obj
+ *  Pointer to object that should be returned.
+ */
+void uk_allocpool_return(struct uk_allocpool *p, void *obj);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LIBUKALLOCPOOL_H__ */
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
new file mode 100644
index 00000000..55d0ee56
--- /dev/null
+++ b/lib/ukallocpool/pool.c
@@ -0,0 +1,186 @@
+/*
+ * Simple memory pool using LIFO principle
+ *
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ *
+ * Copyright (c) 2013-2017, NEC Europe Ltd., NEC Corporation All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <uk/essentials.h>
+#include <uk/alloc_impl.h>
+#include <uk/allocpool.h>
+#include <uk/list.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * POOL: MEMORY LAYOUT
+ *
+ *          ++--------------------++
+ *          ||   struct mempool   ||
+ *          ||                    ||
+ *          ++--------------------++
+ *          |    // padding //     |
+ *          +======================+
+ *          |       OBJECT 1       |
+ *          +======================+
+ *          |       OBJECT 2       |
+ *          +======================+
+ *          |       OBJECT 3       |
+ *          +======================+
+ *          |         ...          |
+ *          v                      v
+ */
+
+#define MIN_OBJ_ALIGN sizeof(void *)
+#define MIN_OBJ_LEN   sizeof(struct uk_list_head)
+
+struct uk_allocpool {
+	struct uk_list_head free_obj;
+	unsigned int free_obj_count;
+
+	size_t obj_align;
+	size_t obj_len;
+	unsigned int obj_count;
+	uk_allocpool_obj_init_t obj_init;
+	void *obj_init_cookie;
+};
+
+struct free_obj {
+	struct uk_list_head list;
+};
+
+static inline void _prepend_free_obj(struct uk_allocpool *p, void *obj)
+{
+	struct uk_list_head *entry;
+
+	UK_ASSERT(p);
+	UK_ASSERT(obj);
+	UK_ASSERT(p->free_obj_count < p->obj_count);
+
+	entry = &((struct free_obj *) obj)->list;
+	uk_list_add(entry, &p->free_obj);
+	p->free_obj_count++;
+}
+
+static inline void *_take_free_obj(struct uk_allocpool *p)
+{
+	struct free_obj *obj;
+
+	UK_ASSERT(p);
+	UK_ASSERT(p->free_obj_count > 0);
+
+	/* get object from list head */
+	obj = uk_list_first_entry(&p->free_obj, struct free_obj, list);
+	uk_list_del(&obj->list);
+	p->free_obj_count--;
+	if (p->obj_init)
+		p->obj_init((void *) obj, p->obj_len, p->obj_init_cookie);
+	return (void *) obj;
+}
+
+void *uk_allocpool_take(struct uk_allocpool *p)
+{
+	UK_ASSERT(p);
+
+	if (unlikely(uk_list_empty(&p->free_obj)))
+		return NULL;
+
+	return _take_free_obj(p);
+}
+
+void uk_allocpool_return(struct uk_allocpool *p, void *obj)
+{
+	UK_ASSERT(p);
+
+	_prepend_free_obj(p, obj);
+}
+
+unsigned int uk_allocpool_availcount(struct uk_allocpool *p)
+{
+	return p->free_obj_count;
+}
+
+struct uk_allocpool *uk_allocpool_init(void *base, size_t len,
+				       size_t obj_len, size_t obj_align,
+				       uk_allocpool_obj_init_t obj_init,
+				       void * obj_init_cookie)
+{
+	struct uk_allocpool *p;
+	struct uk_alloc *a;
+	size_t obj_alen;
+	size_t left;
+	void *obj_ptr;
+
+	UK_ASSERT(POWER_OF_2(obj_align));
+
+	if (!base || sizeof(struct uk_allocpool) > len) {
+		errno = ENOSPC;
+		return NULL;
+	}
+
+	/* apply minimum requirements */
+	obj_len   = MAX(obj_len, MIN_OBJ_LEN);
+	obj_align = MAX(obj_align, MIN_OBJ_ALIGN);
+
+	p = (struct uk_allocpool *) base;
+	memset(p, 0, sizeof(*p));
+	a = uk_allocpool2alloc(p);
+
+	obj_alen = ALIGN_UP(obj_len, obj_align);
+	obj_ptr = (void *) ALIGN_UP((uintptr_t) base + sizeof(*p),
+				    obj_align);
+	if ((uintptr_t) obj_ptr > (uintptr_t) base + len) {
+		uk_pr_debug("%p: Empty pool: Not enough space for allocating objects\n",
+			    p);
+		goto out;
+	}
+
+	left = len - ((uintptr_t) obj_ptr - (uintptr_t) base);
+
+	p->obj_count = 0;
+	p->free_obj_count = 0;
+	UK_INIT_LIST_HEAD(&p->free_obj);
+	while (left >= obj_alen) {
+		++p->obj_count;
+		_prepend_free_obj(p, obj_ptr);
+		obj_ptr = (void *) ((uintptr_t) obj_ptr + obj_alen);
+		left -= obj_alen;
+	}
+
+out:
+	p->obj_len         = obj_alen;
+	p->obj_align       = obj_align;
+	p->obj_init        = obj_init;
+	p->obj_init_cookie = obj_init_cookie;
+
+	uk_pr_debug("%p: Pool created (%"__PRIsz" B): %u objs of %"__PRIsz" B, aligned to %"__PRIsz" B\n",
+		    p, len, p->obj_count, p->obj_len, p->obj_align);
+	return p;
+}
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 11:58:45 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 11:58:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10903.29053 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVviX-0002xs-DA; Fri, 23 Oct 2020 11:58:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10903.29053; Fri, 23 Oct 2020 11:58:45 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVviX-0002xl-AD; Fri, 23 Oct 2020 11:58:45 +0000
Received: by outflank-mailman (input) for mailman id 10903;
 Fri, 23 Oct 2020 11:58: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVviV-0002xX-PK
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:43 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 9016c22e-00be-4c53-8ca0-eb467bd80788;
 Fri, 23 Oct 2020 11:58:42 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id EC843103EC2;
 Fri, 23 Oct 2020 13:58:41 +0200 (CEST)
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 Wpnrag6vTp-i; Fri, 23 Oct 2020 13:58:41 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id CBFED103AE4
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:41 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:41 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVviV-0002xX-PK
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:43 +0000
X-Inumbo-ID: 9016c22e-00be-4c53-8ca0-eb467bd80788
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 9016c22e-00be-4c53-8ca0-eb467bd80788;
	Fri, 23 Oct 2020 11:58:42 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id EC843103EC2;
	Fri, 23 Oct 2020 13:58:41 +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 Wpnrag6vTp-i; Fri, 23 Oct 2020 13:58:41 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id CBFED103AE4
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:41 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:41 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 3/5] lib/ukallocpool: Allocate pool on parent allocator
Date: Fri, 23 Oct 2020 13:56:52 +0200
Message-ID: <20201023115654.1899-4-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
References: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Provides a function that allocates and initializes a pool on a
given parent allocator.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/exportsyms.uk          |  3 ++
 lib/ukallocpool/include/uk/allocpool.h | 51 +++++++++++++++++++++
 lib/ukallocpool/pool.c                 | 62 ++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)

diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
index 2f29b409..9e19e8b2 100644
--- a/lib/ukallocpool/exportsyms.uk
+++ b/lib/ukallocpool/exportsyms.uk
@@ -1,4 +1,7 @@
+uk_allocpool_alloc
+uk_allocpool_free
 uk_allocpool_init
+uk_allocpool_reqmem
 uk_allocpool_availcount
 uk_allocpool_take
 uk_allocpool_return
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
index ce3d939d..13fbd187 100644
--- a/lib/ukallocpool/include/uk/allocpool.h
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -47,6 +47,57 @@ typedef void (*uk_allocpool_obj_init_t)(void *obj, size_t len, void *cookie);
 
 struct uk_allocpool;
 
+/**
+ * Computes the required memory for a pool allocation
+ *
+ * @param obj_count
+ *  Number of objects that are allocated with the pool
+ * @param obj_len
+ *  Size of one object (bytes)
+ * @param obj_align
+ *  Alignment requirement for each pool object
+ * @return
+ *  Number of bytes needed for pool allocation
+ */
+size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
+			   size_t obj_align);
+
+/**
+ * Allocates a memory pool on a parent allocator.
+ *
+ * @param obj_count
+ *  Number of objects that are allocated with the pool
+ * @param obj_len
+ *  Size of one object (bytes)
+ * @param obj_align
+ *  Alignment requirement for each pool object
+ * @param obj_init
+ *  Function pointer to object initialization
+ * @param obj_init_cookie
+ *  Cookie that is hand-over to object initialization
+ * @return
+ *  - (NULL): If allocation failed (e.g., ENOMEM)
+ *  - pointer to allocated pool
+ */
+struct uk_allocpool *uk_allocpool_alloc(struct uk_alloc *parent,
+					unsigned int obj_count,
+					size_t obj_len, size_t obj_align,
+					uk_allocpool_obj_init_t obj_init,
+					void *obj_init_cookie);
+
+/**
+ * Frees a memory pool that was allocated with
+ * uk_allocpool_alloc(). The memory is returned to
+ * the parent allocator.
+ * Note: Please make sure that all taken objects
+ * are returned to the pool before free'ing the
+ * pool.
+ *
+ * @param p
+ *  Pointer to memory pool that will be free'd.
+ */
+void uk_allocpool_free(struct uk_allocpool *p);
+
 /**
  * Initializes a memory pool on a given memory range.
  *
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index 55d0ee56..d1dcf841 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -70,6 +70,9 @@ struct uk_allocpool {
 	unsigned int obj_count;
 	uk_allocpool_obj_init_t obj_init;
 	void *obj_init_cookie;
+
+	struct uk_alloc *parent;
+	void *base;
 };
 
 struct free_obj {
@@ -122,6 +125,21 @@ void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 	_prepend_free_obj(p, obj);
 }
 
+size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
+			   size_t obj_align)
+{
+	size_t obj_alen;
+
+	UK_ASSERT(POWER_OF_2(obj_align));
+
+	obj_len   = MAX(obj_len, MIN_OBJ_LEN);
+	obj_align = MAX(obj_align, MIN_OBJ_ALIGN);
+	obj_alen  = ALIGN_UP(obj_len, obj_align);
+	return (sizeof(struct uk_allocpool)
+		+ obj_align
+		+ ((size_t) obj_count * obj_alen));
+}
+
 unsigned int uk_allocpool_availcount(struct uk_allocpool *p)
 {
 	return p->free_obj_count;
@@ -179,8 +197,52 @@ out:
 	p->obj_align       = obj_align;
 	p->obj_init        = obj_init;
 	p->obj_init_cookie = obj_init_cookie;
+	p->base            = base;
+	p->parent          = NULL;
 
 	uk_pr_debug("%p: Pool created (%"__PRIsz" B): %u objs of %"__PRIsz" B, aligned to %"__PRIsz" B\n",
 		    p, len, p->obj_count, p->obj_len, p->obj_align);
 	return p;
 }
+
+struct uk_allocpool *uk_allocpool_alloc(struct uk_alloc *parent,
+					unsigned int obj_count,
+					size_t obj_len, size_t obj_align,
+					uk_allocpool_obj_init_t obj_init,
+					void *obj_init_cookie)
+{
+	struct uk_allocpool *p;
+	void *base;
+	size_t len;
+
+	/* uk_allocpool_reqmem computes minimum requirement */
+	len = uk_allocpool_reqmem(obj_count, obj_len, obj_align);
+	base = uk_malloc(parent, len);
+	if (!base)
+		return NULL;
+
+	p = uk_allocpool_init(base, len, obj_len, obj_align,
+			      obj_init, obj_init_cookie);
+	if (!p) {
+		uk_free(parent, base);
+		errno = ENOSPC;
+		return NULL;
+	}
+
+	p->parent = parent;
+	return p;
+}
+
+void uk_allocpool_free(struct uk_allocpool *p)
+{
+	/* If we do not have a parent, this pool was created with
+	 * uk_allocpool_init(). Such a pool cannot be free'd with
+	 * this function since we are not the owner of the allocation
+	 */
+	UK_ASSERT(p->parent);
+
+	/* Make sure we got all objects back */
+	UK_ASSERT(p->free_obj_count == p->obj_count);
+
+	uk_free(p->parent, p->base);
+}
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 11:58:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 11:58:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10904.29058 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVvib-0002yu-Fa; Fri, 23 Oct 2020 11:58:49 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10904.29058; Fri, 23 Oct 2020 11:58:49 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVvib-0002ym-C9; Fri, 23 Oct 2020 11:58:49 +0000
Received: by outflank-mailman (input) for mailman id 10904;
 Fri, 23 Oct 2020 11:58: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVviZ-0002xX-R2
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:47 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e9bab20d-5090-4181-8768-907a5bb94d89;
 Fri, 23 Oct 2020 11:58:46 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 3108FF2259;
 Fri, 23 Oct 2020 13:58:45 +0200 (CEST)
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 Ywl-0B-WlunT; Fri, 23 Oct 2020 13:58:45 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 07491F210C
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:43 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:42 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVviZ-0002xX-R2
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:47 +0000
X-Inumbo-ID: e9bab20d-5090-4181-8768-907a5bb94d89
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id e9bab20d-5090-4181-8768-907a5bb94d89;
	Fri, 23 Oct 2020 11:58:46 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 3108FF2259;
	Fri, 23 Oct 2020 13:58:45 +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 Ywl-0B-WlunT; Fri, 23 Oct 2020 13:58:45 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 07491F210C
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:43 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:42 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 4/5] lib/ukallocpool: `lib/ukalloc` compatible interface
Date: Fri, 23 Oct 2020 13:56:53 +0200
Message-ID: <20201023115654.1899-5-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
References: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Provide a ukalloc compatible interface. This enables the usage of pools
with common allocator interfaces, like `uk_malloc()`, `uk_free()`,
and `uk_memalign()`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/exportsyms.uk          |  1 +
 lib/ukallocpool/include/uk/allocpool.h | 16 ++++++
 lib/ukallocpool/pool.c                 | 70 ++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)

diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
index 9e19e8b2..d119db32 100644
--- a/lib/ukallocpool/exportsyms.uk
+++ b/lib/ukallocpool/exportsyms.uk
@@ -5,3 +5,4 @@ uk_allocpool_reqmem
 uk_allocpool_availcount
 uk_allocpool_take
 uk_allocpool_return
+uk_allocpool2ukalloc
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
index 13fbd187..a60acb35 100644
--- a/lib/ukallocpool/include/uk/allocpool.h
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -122,6 +122,18 @@ struct uk_allocpool *uk_allocpool_init(void *base, size_t len,
 				       uk_allocpool_obj_init_t obj_init,
 				       void *obj_init_cookie);
 
+/**
+ * Return uk_alloc compatible interface for allocpool.
+ * With this interface, uk_malloc(), uk_free(), etc. can
+ * be used with the pool.
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @return
+ *  Pointer to uk_alloc interface of given pool.
+ */
+struct uk_alloc *uk_allocpool2alloc(struct uk_allocpool *p);
+
 /**
  * Return the number of current available (free) objects
  *
@@ -134,6 +146,8 @@ unsigned int uk_allocpool_availcount(struct uk_allocpool *p);
 
 /**
  * Get one object from a pool
+ * HINT: It is recommended to use this call instead of uk_malloc() whenever
+ *       feasible. This call is avoiding indirections.
  *
  * @param p
  *  Pointer to memory pool.
@@ -145,6 +159,8 @@ void *uk_allocpool_take(struct uk_allocpool *p);
 
 /**
  * Return one object back to a pool
+ * HINT: It is recommended to use this call instead of uk_free() whenever
+ *       feasible. This call is avoiding indirections.
  *
  * @param p
  *  Pointer to memory pool.
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index d1dcf841..90e7bb56 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -62,6 +62,8 @@
 #define MIN_OBJ_LEN   sizeof(struct uk_list_head)
 
 struct uk_allocpool {
+	struct uk_alloc self;
+
 	struct uk_list_head free_obj;
 	unsigned int free_obj_count;
 
@@ -79,6 +81,18 @@ struct free_obj {
 	struct uk_list_head list;
 };
 
+static inline struct uk_allocpool *ukalloc2pool(struct uk_alloc *a)
+{
+	UK_ASSERT(a);
+	return __containerof(a, struct uk_allocpool, self);
+}
+
+struct uk_alloc *uk_allocpool2alloc(struct uk_allocpool *p)
+{
+	UK_ASSERT(p);
+	return &p->self;
+}
+
 static inline void _prepend_free_obj(struct uk_allocpool *p, void *obj)
 {
 	struct uk_list_head *entry;
@@ -108,6 +122,42 @@ static inline void *_take_free_obj(struct uk_allocpool *p)
 	return (void *) obj;
 }
 
+static void pool_free(struct uk_alloc *a, void *ptr)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	if (likely(ptr))
+		_prepend_free_obj(p, ptr);
+}
+
+static void *pool_malloc(struct uk_alloc *a, size_t size)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	if (unlikely((size > p->obj_len)
+		     || uk_list_empty(&p->free_obj))) {
+		errno = ENOMEM;
+		return NULL;
+	}
+
+	return _take_free_obj(p);
+}
+
+static int pool_posix_memalign(struct uk_alloc *a, void **memptr, size_t align,
+				size_t size)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	if (unlikely((size > p->obj_len)
+		     || (align > p->obj_align)
+		     || uk_list_empty(&p->free_obj))) {
+		return ENOMEM;
+	}
+
+	*memptr = _take_free_obj(p);
+	return 0;
+}
+
 void *uk_allocpool_take(struct uk_allocpool *p)
 {
 	UK_ASSERT(p);
@@ -125,6 +175,14 @@ void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 	_prepend_free_obj(p, obj);
 }
 
+#if CONFIG_LIBUKALLOC_IFSTATS
+static size_t pool_availmem(struct uk_alloc *a)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+	return (size_t) p->free_obj_count * p->obj_len;
+}
+#endif
+
 size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
 			   size_t obj_align)
 {
@@ -200,6 +258,18 @@ out:
 	p->base            = base;
 	p->parent          = NULL;
 
+	uk_alloc_init_malloc(a,
+			     pool_malloc,
+			     uk_calloc_compat,
+			     uk_realloc_compat,
+			     pool_free,
+			     pool_posix_memalign,
+			     uk_memalign_compat,
+			     NULL);
+#if CONFIG_LIBUKALLOC_IFSTATS
+	ret->availmem = pool_availmem;
+#endif
+
 	uk_pr_debug("%p: Pool created (%"__PRIsz" B): %u objs of %"__PRIsz" B, aligned to %"__PRIsz" B\n",
 		    p, len, p->obj_count, p->obj_len, p->obj_align);
 	return p;
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 11:58:58 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 11:58:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10905.29061 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVvik-00030M-Hk; Fri, 23 Oct 2020 11:58:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10905.29061; Fri, 23 Oct 2020 11:58:58 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVvik-00030H-El; Fri, 23 Oct 2020 11:58:58 +0000
Received: by outflank-mailman (input) for mailman id 10905;
 Fri, 23 Oct 2020 11:58: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVvii-000308-U7
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:56 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id ed159215-be05-4601-995c-3b96ab4ea9dd;
 Fri, 23 Oct 2020 11:58:55 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 2E008103FAA;
 Fri, 23 Oct 2020 13:58:55 +0200 (CEST)
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 PkEPrOZXFqlO; Fri, 23 Oct 2020 13:58:55 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 0E74F103F3C
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:55 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:54 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVvii-000308-U7
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 11:58:56 +0000
X-Inumbo-ID: ed159215-be05-4601-995c-3b96ab4ea9dd
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id ed159215-be05-4601-995c-3b96ab4ea9dd;
	Fri, 23 Oct 2020 11:58:55 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 2E008103FAA;
	Fri, 23 Oct 2020 13:58:55 +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 PkEPrOZXFqlO; Fri, 23 Oct 2020 13:58:55 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 0E74F103F3C
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 13:58:55 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 13:58:54 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 5/5] lib/ukallocpool: Batched allocation
Date: Fri, 23 Oct 2020 13:56:54 +0200
Message-ID: <20201023115654.1899-6-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
References: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Introduce low-overhead interfaces for batched allocations and batched freeing
of objects.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/exportsyms.uk          |  2 ++
 lib/ukallocpool/include/uk/allocpool.h | 30 ++++++++++++++++++++++++++
 lib/ukallocpool/pool.c                 | 29 +++++++++++++++++++++++++
 3 files changed, 61 insertions(+)

diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
index d119db32..5a6d9f6b 100644
--- a/lib/ukallocpool/exportsyms.uk
+++ b/lib/ukallocpool/exportsyms.uk
@@ -4,5 +4,7 @@ uk_allocpool_init
 uk_allocpool_reqmem
 uk_allocpool_availcount
 uk_allocpool_take
+uk_allocpool_take_batch
 uk_allocpool_return
+uk_allocpool_return_batch
 uk_allocpool2ukalloc
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
index a60acb35..a9f9cb59 100644
--- a/lib/ukallocpool/include/uk/allocpool.h
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -157,6 +157,22 @@ unsigned int uk_allocpool_availcount(struct uk_allocpool *p);
  */
 void *uk_allocpool_take(struct uk_allocpool *p);
 
+/**
+ * Get multiple objects from a pool.
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @param obj
+ *  Pointer to array that will be filled with pointers of
+ *  allocated objects from the pool.
+ * @param count
+ *  Maximum number of objects that should be taken from the pool
+ * @return
+ *  Number of successfully allocated objects on the given array
+ */
+unsigned int uk_allocpool_take_batch(struct uk_allocpool *p,
+				     void *obj[], unsigned int count);
+
 /**
  * Return one object back to a pool
  * HINT: It is recommended to use this call instead of uk_free() whenever
@@ -169,6 +185,20 @@ void *uk_allocpool_take(struct uk_allocpool *p);
  */
 void uk_allocpool_return(struct uk_allocpool *p, void *obj);
 
+/**
+ * Return multiple objects to a pool.
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @param obj
+ *  Pointer to array that with pointers of objects that
+ *  should be returned.
+ * @param count
+ *  Number of objects that are on the array.
+ */
+void uk_allocpool_return_batch(struct uk_allocpool *p,
+			       void *obj[], unsigned int count);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index 90e7bb56..ddaa93fa 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -168,6 +168,23 @@ void *uk_allocpool_take(struct uk_allocpool *p)
 	return _take_free_obj(p);
 }
 
+unsigned int uk_allocpool_take_batch(struct uk_allocpool *p,
+				     void *obj[], unsigned int count)
+{
+	unsigned int i;
+
+	UK_ASSERT(p);
+	UK_ASSERT(obj);
+
+	for (i = 0; i < count; ++i) {
+		if (unlikely(uk_list_empty(&p->free_obj)))
+			break;
+		obj[i] = _take_free_obj(p);
+	}
+
+	return i;
+}
+
 void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 {
 	UK_ASSERT(p);
@@ -175,6 +192,18 @@ void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 	_prepend_free_obj(p, obj);
 }
 
+void uk_allocpool_return_batch(struct uk_allocpool *p,
+			       void *obj[], unsigned int count)
+{
+	unsigned int i;
+
+	UK_ASSERT(p);
+	UK_ASSERT(obj);
+
+	for (i = 0; i < count; ++i)
+		_prepend_free_obj(p, obj[i]);
+}
+
 #if CONFIG_LIBUKALLOC_IFSTATS
 static size_t pool_availmem(struct uk_alloc *a)
 {
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 12:10:39 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 12:10:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10944.29077 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVvu2-0004uM-3X; Fri, 23 Oct 2020 12:10:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10944.29077; Fri, 23 Oct 2020 12:10:38 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVvu2-0004uF-0S; Fri, 23 Oct 2020 12:10:38 +0000
Received: by outflank-mailman (input) for mailman id 10944;
 Fri, 23 Oct 2020 12:10: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVvu0-0004uA-Ug
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:10:36 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id b06d1dda-a595-41e1-9289-69e2752133b3;
 Fri, 23 Oct 2020 12:10:35 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 3CED0103EC2;
 Fri, 23 Oct 2020 14:10:34 +0200 (CEST)
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 aN569L2RiUhT; Fri, 23 Oct 2020 14:10:34 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 19195103AE4
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:10:34 +0200 (CEST)
Received: from [10.7.2.19] (192.168.24.96) by titania.office.hd
 (192.168.24.89) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:10:33 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVvu0-0004uA-Ug
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:10:36 +0000
X-Inumbo-ID: b06d1dda-a595-41e1-9289-69e2752133b3
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id b06d1dda-a595-41e1-9289-69e2752133b3;
	Fri, 23 Oct 2020 12:10:35 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 3CED0103EC2;
	Fri, 23 Oct 2020 14:10: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 aN569L2RiUhT; Fri, 23 Oct 2020 14:10:34 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 19195103AE4
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:10:34 +0200 (CEST)
Received: from [10.7.2.19] (192.168.24.96) by titania.office.hd
 (192.168.24.89) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:10:33 +0200
Subject: Re: [UNIKRAFT PATCH 0/5] Memory Pools
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>
References: <20201023115654.1899-1-simon.kuenzer@neclab.eu>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <b18fd319-96b5-48a1-a12d-5e4a38bee9d1@neclab.eu>
Date: Fri, 23 Oct 2020 14:10:31 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0)
 Gecko/20100101 Thunderbird/68.12.1
MIME-Version: 1.0
In-Reply-To: <20201023115654.1899-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: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

I am sorry. `pool.c` has a wrong license header. I am sending a v2.

Thanks,

Simon

On 23.10.20 13:56, Simon Kuenzer wrote:
> This series implements a memory pool allocator. Pool objects have the same
> size and are pre-allocated. Due to this simplification allocations and free
> operations are as cheap as O(1). Its intended use is performance critical
> allocations when allocation sizes do not vary, like network stacks or disk
> buffer caches.
> 
> Simon Kuenzer (5):
>    lib/ukallocpool: Library skeleton
>    lib/ukallocpool: LIFO pool implementation
>    lib/ukallocpool: Allocate pool on parent allocator
>    lib/ukallocpool: `lib/ukalloc` compatible interface
>    lib/ukallocpool: Batched allocation
> 
>   lib/Makefile.uk                        |   1 +
>   lib/ukallocpool/Config.uk              |   6 +
>   lib/ukallocpool/Makefile.uk            |   6 +
>   lib/ukallocpool/exportsyms.uk          |  10 +
>   lib/ukallocpool/include/uk/allocpool.h | 206 +++++++++++++++
>   lib/ukallocpool/pool.c                 | 347 +++++++++++++++++++++++++
>   6 files changed, 576 insertions(+)
>   create mode 100644 lib/ukallocpool/Config.uk
>   create mode 100644 lib/ukallocpool/Makefile.uk
>   create mode 100644 lib/ukallocpool/exportsyms.uk
>   create mode 100644 lib/ukallocpool/include/uk/allocpool.h
>   create mode 100644 lib/ukallocpool/pool.c
> 


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 12:50:12 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 12:50:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10962.29118 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWI-0000XR-NL; Fri, 23 Oct 2020 12:50:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10962.29118; Fri, 23 Oct 2020 12:50:10 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWI-0000XK-KH; Fri, 23 Oct 2020 12:50:10 +0000
Received: by outflank-mailman (input) for mailman id 10962;
 Fri, 23 Oct 2020 12:50: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVwWH-0000XF-Fl
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:09 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 062a851c-1e94-4f98-9623-c903c5554859;
 Fri, 23 Oct 2020 12:50:07 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 1D73C103EC2;
 Fri, 23 Oct 2020 14:50:07 +0200 (CEST)
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 VKw8rUKoWg_C; Fri, 23 Oct 2020 14:50:07 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id ED825103AE4
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:06 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:06 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVwWH-0000XF-Fl
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:09 +0000
X-Inumbo-ID: 062a851c-1e94-4f98-9623-c903c5554859
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 062a851c-1e94-4f98-9623-c903c5554859;
	Fri, 23 Oct 2020 12:50:07 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 1D73C103EC2;
	Fri, 23 Oct 2020 14:50:07 +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 VKw8rUKoWg_C; Fri, 23 Oct 2020 14:50:07 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id ED825103AE4
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:06 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:06 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v2 0/5] Memory Pools
Date: Fri, 23 Oct 2020 14:49:48 +0200
Message-ID: <20201023124953.4000-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 titania.office.hd
 (192.168.24.89)

This series implements a memory pool allocator. Pool objects have the same
size and are pre-allocated. Due to this simplification allocations and free
operations are as cheap as O(1). Its intended use is performance critical
allocations when allocation sizes do not vary, like network stacks or disk
buffer caches.

Changes since v1:
 - Correct license header in `pool.c`

Simon Kuenzer (5):
  lib/ukallocpool: Library skeleton
  lib/ukallocpool: LIFO pool implementation
  lib/ukallocpool: Allocate pool on parent allocator
  lib/ukallocpool: `lib/ukalloc` compatible interface
  lib/ukallocpool: Batched allocation

 lib/Makefile.uk                        |   1 +
 lib/ukallocpool/Config.uk              |   6 +
 lib/ukallocpool/Makefile.uk            |   6 +
 lib/ukallocpool/exportsyms.uk          |  10 +
 lib/ukallocpool/include/uk/allocpool.h | 206 +++++++++++++++
 lib/ukallocpool/pool.c                 | 349 +++++++++++++++++++++++++
 6 files changed, 578 insertions(+)
 create mode 100644 lib/ukallocpool/Config.uk
 create mode 100644 lib/ukallocpool/Makefile.uk
 create mode 100644 lib/ukallocpool/exportsyms.uk
 create mode 100644 lib/ukallocpool/include/uk/allocpool.h
 create mode 100644 lib/ukallocpool/pool.c

-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 12:50:14 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 12:50:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10963.29121 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWM-0000YF-P5; Fri, 23 Oct 2020 12:50:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10963.29121; Fri, 23 Oct 2020 12:50:14 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWM-0000Y8-Lv; Fri, 23 Oct 2020 12:50:14 +0000
Received: by outflank-mailman (input) for mailman id 10963;
 Fri, 23 Oct 2020 12:50:13 +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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVwWL-0000Xu-Td
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:13 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id e76ce59b-0949-48a2-a7a3-9969e991de91;
 Fri, 23 Oct 2020 12:50:11 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 49453F2260;
 Fri, 23 Oct 2020 14:50:10 +0200 (CEST)
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 VYET4eJDylTq; Fri, 23 Oct 2020 14:50:10 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 208F1F210A
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:08 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:07 +0200
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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVwWL-0000Xu-Td
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:13 +0000
X-Inumbo-ID: e76ce59b-0949-48a2-a7a3-9969e991de91
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id e76ce59b-0949-48a2-a7a3-9969e991de91;
	Fri, 23 Oct 2020 12:50:11 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 49453F2260;
	Fri, 23 Oct 2020 14:50: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 VYET4eJDylTq; Fri, 23 Oct 2020 14:50:10 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 208F1F210A
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:08 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:07 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v2 1/5] lib/ukallocpool: Library skeleton
Date: Fri, 23 Oct 2020 14:49:49 +0200
Message-ID: <20201023124953.4000-2-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
References: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Registers the library skeleton for ukallocpool.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/Makefile.uk             | 1 +
 lib/ukallocpool/Config.uk   | 6 ++++++
 lib/ukallocpool/Makefile.uk | 4 ++++
 3 files changed, 11 insertions(+)
 create mode 100644 lib/ukallocpool/Config.uk
 create mode 100644 lib/ukallocpool/Makefile.uk

diff --git a/lib/Makefile.uk b/lib/Makefile.uk
index ff69dfab..7fffdac7 100644
--- a/lib/Makefile.uk
+++ b/lib/Makefile.uk
@@ -15,6 +15,7 @@ $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/nolibc))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukalloc))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocbbuddy))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocregion))
+$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocpool))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uksched))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukschedcoop))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/fdt))
diff --git a/lib/ukallocpool/Config.uk b/lib/ukallocpool/Config.uk
new file mode 100644
index 00000000..5c300117
--- /dev/null
+++ b/lib/ukallocpool/Config.uk
@@ -0,0 +1,6 @@
+config LIBUKALLOCPOOL
+	bool "ukallocpool: Memory pool allocator"
+	default n
+	select LIBNOLIBC if !HAVE_LIBC
+	select LIBUKDEBUG
+	select LIBUKALLOC
diff --git a/lib/ukallocpool/Makefile.uk b/lib/ukallocpool/Makefile.uk
new file mode 100644
index 00000000..c71c9764
--- /dev/null
+++ b/lib/ukallocpool/Makefile.uk
@@ -0,0 +1,4 @@
+$(eval $(call addlib_s,libukallocpool,$(CONFIG_LIBUKALLOCPOOL)))
+
+CINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
+CXXINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 12:50:23 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 12:50:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10964.29126 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWV-0000Zh-Qu; Fri, 23 Oct 2020 12:50:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10964.29126; Fri, 23 Oct 2020 12:50:23 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWV-0000ZZ-Nd; Fri, 23 Oct 2020 12:50:23 +0000
Received: by outflank-mailman (input) for mailman id 10964;
 Fri, 23 Oct 2020 12:50: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVwWU-0000ZO-Pl
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:22 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 7a2728c7-ee99-4586-b808-34da4b40b4e9;
 Fri, 23 Oct 2020 12:50:21 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 2B921103EC2;
 Fri, 23 Oct 2020 14:50:20 +0200 (CEST)
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 3Gqp43DJRbDG; Fri, 23 Oct 2020 14:50:20 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 099CA103AE4
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:20 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:19 +0200
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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVwWU-0000ZO-Pl
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:22 +0000
X-Inumbo-ID: 7a2728c7-ee99-4586-b808-34da4b40b4e9
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 7a2728c7-ee99-4586-b808-34da4b40b4e9;
	Fri, 23 Oct 2020 12:50:21 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 2B921103EC2;
	Fri, 23 Oct 2020 14:50:20 +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 3Gqp43DJRbDG; Fri, 23 Oct 2020 14:50:20 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 099CA103AE4
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:20 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:19 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v2 2/5] lib/ukallocpool: LIFO pool implementation
Date: Fri, 23 Oct 2020 14:49:50 +0200
Message-ID: <20201023124953.4000-3-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
References: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Initial implementation of a memory pool (same-sized and fixed-sized object
allocator) following LIFO principle by using a single list to keep track of
free objects. LIFO is chosen to potentially better utilize hardware caches.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/Makefile.uk            |   2 +
 lib/ukallocpool/exportsyms.uk          |   4 +
 lib/ukallocpool/include/uk/allocpool.h | 109 ++++++++++++++
 lib/ukallocpool/pool.c                 | 188 +++++++++++++++++++++++++
 4 files changed, 303 insertions(+)
 create mode 100644 lib/ukallocpool/exportsyms.uk
 create mode 100644 lib/ukallocpool/include/uk/allocpool.h
 create mode 100644 lib/ukallocpool/pool.c

diff --git a/lib/ukallocpool/Makefile.uk b/lib/ukallocpool/Makefile.uk
index c71c9764..63c24dc1 100644
--- a/lib/ukallocpool/Makefile.uk
+++ b/lib/ukallocpool/Makefile.uk
@@ -2,3 +2,5 @@ $(eval $(call addlib_s,libukallocpool,$(CONFIG_LIBUKALLOCPOOL)))
 
 CINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
 CXXINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
+
+LIBUKALLOCPOOL_SRCS-y += $(LIBUKALLOCPOOL_BASE)/pool.c
diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
new file mode 100644
index 00000000..2f29b409
--- /dev/null
+++ b/lib/ukallocpool/exportsyms.uk
@@ -0,0 +1,4 @@
+uk_allocpool_init
+uk_allocpool_availcount
+uk_allocpool_take
+uk_allocpool_return
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
new file mode 100644
index 00000000..ce3d939d
--- /dev/null
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -0,0 +1,109 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Simple memory pool using LIFO principle
+ *
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation,
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __LIBUKALLOCPOOL_H__
+#define __LIBUKALLOCPOOL_H__
+
+#include <uk/alloc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*uk_allocpool_obj_init_t)(void *obj, size_t len, void *cookie);
+
+struct uk_allocpool;
+
+/**
+ * Initializes a memory pool on a given memory range.
+ *
+ * @param base
+ *  Base address of memory range
+ * @param len
+ *  Length of memory range (bytes)
+ * @param obj_len
+ *  Size of one object (bytes)
+ * @param obj_align
+ *  Alignment requirement for each pool object
+ * @param obj_init
+ *  Function pointer to object initialization
+ * @param obj_init_cookie
+ *  Cookie that is hand-over to object initialization
+ * @return
+ *  - (NULL): Not enough memory for pool
+ *  - pointer to initializes pool
+ */
+struct uk_allocpool *uk_allocpool_init(void *base, size_t len,
+				       size_t obj_len, size_t obj_align,
+				       uk_allocpool_obj_init_t obj_init,
+				       void *obj_init_cookie);
+
+/**
+ * Return the number of current available (free) objects
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @return
+ *  Number of free objects in the pool.
+ */
+unsigned int uk_allocpool_availcount(struct uk_allocpool *p);
+
+/**
+ * Get one object from a pool
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @return
+ *  - (NULL): No more free objects available
+ *  - Pointer to object.
+ */
+void *uk_allocpool_take(struct uk_allocpool *p);
+
+/**
+ * Return one object back to a pool
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @param obj
+ *  Pointer to object that should be returned.
+ */
+void uk_allocpool_return(struct uk_allocpool *p, void *obj);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LIBUKALLOCPOOL_H__ */
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
new file mode 100644
index 00000000..2da97cef
--- /dev/null
+++ b/lib/ukallocpool/pool.c
@@ -0,0 +1,188 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Simple memory pool using LIFO principle
+ *
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation,
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <uk/essentials.h>
+#include <uk/alloc_impl.h>
+#include <uk/allocpool.h>
+#include <uk/list.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * POOL: MEMORY LAYOUT
+ *
+ *          ++--------------------++
+ *          ||   struct mempool   ||
+ *          ||                    ||
+ *          ++--------------------++
+ *          |    // padding //     |
+ *          +======================+
+ *          |       OBJECT 1       |
+ *          +======================+
+ *          |       OBJECT 2       |
+ *          +======================+
+ *          |       OBJECT 3       |
+ *          +======================+
+ *          |         ...          |
+ *          v                      v
+ */
+
+#define MIN_OBJ_ALIGN sizeof(void *)
+#define MIN_OBJ_LEN   sizeof(struct uk_list_head)
+
+struct uk_allocpool {
+	struct uk_list_head free_obj;
+	unsigned int free_obj_count;
+
+	size_t obj_align;
+	size_t obj_len;
+	unsigned int obj_count;
+	uk_allocpool_obj_init_t obj_init;
+	void *obj_init_cookie;
+};
+
+struct free_obj {
+	struct uk_list_head list;
+};
+
+static inline void _prepend_free_obj(struct uk_allocpool *p, void *obj)
+{
+	struct uk_list_head *entry;
+
+	UK_ASSERT(p);
+	UK_ASSERT(obj);
+	UK_ASSERT(p->free_obj_count < p->obj_count);
+
+	entry = &((struct free_obj *) obj)->list;
+	uk_list_add(entry, &p->free_obj);
+	p->free_obj_count++;
+}
+
+static inline void *_take_free_obj(struct uk_allocpool *p)
+{
+	struct free_obj *obj;
+
+	UK_ASSERT(p);
+	UK_ASSERT(p->free_obj_count > 0);
+
+	/* get object from list head */
+	obj = uk_list_first_entry(&p->free_obj, struct free_obj, list);
+	uk_list_del(&obj->list);
+	p->free_obj_count--;
+	if (p->obj_init)
+		p->obj_init((void *) obj, p->obj_len, p->obj_init_cookie);
+	return (void *) obj;
+}
+
+void *uk_allocpool_take(struct uk_allocpool *p)
+{
+	UK_ASSERT(p);
+
+	if (unlikely(uk_list_empty(&p->free_obj)))
+		return NULL;
+
+	return _take_free_obj(p);
+}
+
+void uk_allocpool_return(struct uk_allocpool *p, void *obj)
+{
+	UK_ASSERT(p);
+
+	_prepend_free_obj(p, obj);
+}
+
+unsigned int uk_allocpool_availcount(struct uk_allocpool *p)
+{
+	return p->free_obj_count;
+}
+
+struct uk_allocpool *uk_allocpool_init(void *base, size_t len,
+				       size_t obj_len, size_t obj_align,
+				       uk_allocpool_obj_init_t obj_init,
+				       void * obj_init_cookie)
+{
+	struct uk_allocpool *p;
+	struct uk_alloc *a;
+	size_t obj_alen;
+	size_t left;
+	void *obj_ptr;
+
+	UK_ASSERT(POWER_OF_2(obj_align));
+
+	if (!base || sizeof(struct uk_allocpool) > len) {
+		errno = ENOSPC;
+		return NULL;
+	}
+
+	/* apply minimum requirements */
+	obj_len   = MAX(obj_len, MIN_OBJ_LEN);
+	obj_align = MAX(obj_align, MIN_OBJ_ALIGN);
+
+	p = (struct uk_allocpool *) base;
+	memset(p, 0, sizeof(*p));
+	a = uk_allocpool2alloc(p);
+
+	obj_alen = ALIGN_UP(obj_len, obj_align);
+	obj_ptr = (void *) ALIGN_UP((uintptr_t) base + sizeof(*p),
+				    obj_align);
+	if ((uintptr_t) obj_ptr > (uintptr_t) base + len) {
+		uk_pr_debug("%p: Empty pool: Not enough space for allocating objects\n",
+			    p);
+		goto out;
+	}
+
+	left = len - ((uintptr_t) obj_ptr - (uintptr_t) base);
+
+	p->obj_count = 0;
+	p->free_obj_count = 0;
+	UK_INIT_LIST_HEAD(&p->free_obj);
+	while (left >= obj_alen) {
+		++p->obj_count;
+		_prepend_free_obj(p, obj_ptr);
+		obj_ptr = (void *) ((uintptr_t) obj_ptr + obj_alen);
+		left -= obj_alen;
+	}
+
+out:
+	p->obj_len         = obj_alen;
+	p->obj_align       = obj_align;
+	p->obj_init        = obj_init;
+	p->obj_init_cookie = obj_init_cookie;
+
+	uk_pr_debug("%p: Pool created (%"__PRIsz" B): %u objs of %"__PRIsz" B, aligned to %"__PRIsz" B\n",
+		    p, len, p->obj_count, p->obj_len, p->obj_align);
+	return p;
+}
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 12:50:25 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 12:50:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10965.29130 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWX-0000aT-TA; Fri, 23 Oct 2020 12:50:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10965.29130; Fri, 23 Oct 2020 12:50:25 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWX-0000aL-P6; Fri, 23 Oct 2020 12:50:25 +0000
Received: by outflank-mailman (input) for mailman id 10965;
 Fri, 23 Oct 2020 12:50: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVwWX-0000ZO-7z
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:25 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 214e6d62-1f42-479c-a8a7-3cdf01181af0;
 Fri, 23 Oct 2020 12:50:24 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 54E6BF2260;
 Fri, 23 Oct 2020 14:50:23 +0200 (CEST)
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 fx79gUraJ1eg; Fri, 23 Oct 2020 14:50:23 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 27925F210A
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:21 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:20 +0200
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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVwWX-0000ZO-7z
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:25 +0000
X-Inumbo-ID: 214e6d62-1f42-479c-a8a7-3cdf01181af0
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 214e6d62-1f42-479c-a8a7-3cdf01181af0;
	Fri, 23 Oct 2020 12:50:24 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 54E6BF2260;
	Fri, 23 Oct 2020 14:50: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 fx79gUraJ1eg; Fri, 23 Oct 2020 14:50:23 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 27925F210A
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:21 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:20 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v2 3/5] lib/ukallocpool: Allocate pool on parent allocator
Date: Fri, 23 Oct 2020 14:49:51 +0200
Message-ID: <20201023124953.4000-4-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
References: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Provides a function that allocates and initializes a pool on a
given parent allocator.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/exportsyms.uk          |  3 ++
 lib/ukallocpool/include/uk/allocpool.h | 51 +++++++++++++++++++++
 lib/ukallocpool/pool.c                 | 62 ++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)

diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
index 2f29b409..9e19e8b2 100644
--- a/lib/ukallocpool/exportsyms.uk
+++ b/lib/ukallocpool/exportsyms.uk
@@ -1,4 +1,7 @@
+uk_allocpool_alloc
+uk_allocpool_free
 uk_allocpool_init
+uk_allocpool_reqmem
 uk_allocpool_availcount
 uk_allocpool_take
 uk_allocpool_return
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
index ce3d939d..13fbd187 100644
--- a/lib/ukallocpool/include/uk/allocpool.h
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -47,6 +47,57 @@ typedef void (*uk_allocpool_obj_init_t)(void *obj, size_t len, void *cookie);
 
 struct uk_allocpool;
 
+/**
+ * Computes the required memory for a pool allocation
+ *
+ * @param obj_count
+ *  Number of objects that are allocated with the pool
+ * @param obj_len
+ *  Size of one object (bytes)
+ * @param obj_align
+ *  Alignment requirement for each pool object
+ * @return
+ *  Number of bytes needed for pool allocation
+ */
+size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
+			   size_t obj_align);
+
+/**
+ * Allocates a memory pool on a parent allocator.
+ *
+ * @param obj_count
+ *  Number of objects that are allocated with the pool
+ * @param obj_len
+ *  Size of one object (bytes)
+ * @param obj_align
+ *  Alignment requirement for each pool object
+ * @param obj_init
+ *  Function pointer to object initialization
+ * @param obj_init_cookie
+ *  Cookie that is hand-over to object initialization
+ * @return
+ *  - (NULL): If allocation failed (e.g., ENOMEM)
+ *  - pointer to allocated pool
+ */
+struct uk_allocpool *uk_allocpool_alloc(struct uk_alloc *parent,
+					unsigned int obj_count,
+					size_t obj_len, size_t obj_align,
+					uk_allocpool_obj_init_t obj_init,
+					void *obj_init_cookie);
+
+/**
+ * Frees a memory pool that was allocated with
+ * uk_allocpool_alloc(). The memory is returned to
+ * the parent allocator.
+ * Note: Please make sure that all taken objects
+ * are returned to the pool before free'ing the
+ * pool.
+ *
+ * @param p
+ *  Pointer to memory pool that will be free'd.
+ */
+void uk_allocpool_free(struct uk_allocpool *p);
+
 /**
  * Initializes a memory pool on a given memory range.
  *
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index 2da97cef..a6d868b9 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -72,6 +72,9 @@ struct uk_allocpool {
 	unsigned int obj_count;
 	uk_allocpool_obj_init_t obj_init;
 	void *obj_init_cookie;
+
+	struct uk_alloc *parent;
+	void *base;
 };
 
 struct free_obj {
@@ -124,6 +127,21 @@ void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 	_prepend_free_obj(p, obj);
 }
 
+size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
+			   size_t obj_align)
+{
+	size_t obj_alen;
+
+	UK_ASSERT(POWER_OF_2(obj_align));
+
+	obj_len   = MAX(obj_len, MIN_OBJ_LEN);
+	obj_align = MAX(obj_align, MIN_OBJ_ALIGN);
+	obj_alen  = ALIGN_UP(obj_len, obj_align);
+	return (sizeof(struct uk_allocpool)
+		+ obj_align
+		+ ((size_t) obj_count * obj_alen));
+}
+
 unsigned int uk_allocpool_availcount(struct uk_allocpool *p)
 {
 	return p->free_obj_count;
@@ -181,8 +199,52 @@ out:
 	p->obj_align       = obj_align;
 	p->obj_init        = obj_init;
 	p->obj_init_cookie = obj_init_cookie;
+	p->base            = base;
+	p->parent          = NULL;
 
 	uk_pr_debug("%p: Pool created (%"__PRIsz" B): %u objs of %"__PRIsz" B, aligned to %"__PRIsz" B\n",
 		    p, len, p->obj_count, p->obj_len, p->obj_align);
 	return p;
 }
+
+struct uk_allocpool *uk_allocpool_alloc(struct uk_alloc *parent,
+					unsigned int obj_count,
+					size_t obj_len, size_t obj_align,
+					uk_allocpool_obj_init_t obj_init,
+					void *obj_init_cookie)
+{
+	struct uk_allocpool *p;
+	void *base;
+	size_t len;
+
+	/* uk_allocpool_reqmem computes minimum requirement */
+	len = uk_allocpool_reqmem(obj_count, obj_len, obj_align);
+	base = uk_malloc(parent, len);
+	if (!base)
+		return NULL;
+
+	p = uk_allocpool_init(base, len, obj_len, obj_align,
+			      obj_init, obj_init_cookie);
+	if (!p) {
+		uk_free(parent, base);
+		errno = ENOSPC;
+		return NULL;
+	}
+
+	p->parent = parent;
+	return p;
+}
+
+void uk_allocpool_free(struct uk_allocpool *p)
+{
+	/* If we do not have a parent, this pool was created with
+	 * uk_allocpool_init(). Such a pool cannot be free'd with
+	 * this function since we are not the owner of the allocation
+	 */
+	UK_ASSERT(p->parent);
+
+	/* Make sure we got all objects back */
+	UK_ASSERT(p->free_obj_count == p->obj_count);
+
+	uk_free(p->parent, p->base);
+}
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 12:50:35 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 12:50:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10968.29134 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWh-0000cP-Ur; Fri, 23 Oct 2020 12:50:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10968.29134; Fri, 23 Oct 2020 12:50:35 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWh-0000cI-Ro; Fri, 23 Oct 2020 12:50:35 +0000
Received: by outflank-mailman (input) for mailman id 10968;
 Fri, 23 Oct 2020 12:50: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVwWh-0000cC-5N
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:35 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 17f4c700-d2d9-4a40-8151-3aedc303add4;
 Fri, 23 Oct 2020 12:50:34 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 58BBD103F3C;
 Fri, 23 Oct 2020 14:50:33 +0200 (CEST)
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 RbXp3WdQpfGk; Fri, 23 Oct 2020 14:50:33 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 377E9103ED3
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:33 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:32 +0200
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVwWh-0000cC-5N
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:35 +0000
X-Inumbo-ID: 17f4c700-d2d9-4a40-8151-3aedc303add4
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 17f4c700-d2d9-4a40-8151-3aedc303add4;
	Fri, 23 Oct 2020 12:50:34 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 58BBD103F3C;
	Fri, 23 Oct 2020 14:50: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 RbXp3WdQpfGk; Fri, 23 Oct 2020 14:50:33 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 377E9103ED3
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:33 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:32 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v2 4/5] lib/ukallocpool: `lib/ukalloc` compatible interface
Date: Fri, 23 Oct 2020 14:49:52 +0200
Message-ID: <20201023124953.4000-5-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
References: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Provide a ukalloc compatible interface. This enables the usage of pools
with common allocator interfaces, like `uk_malloc()`, `uk_free()`,
and `uk_memalign()`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/exportsyms.uk          |  1 +
 lib/ukallocpool/include/uk/allocpool.h | 16 ++++++
 lib/ukallocpool/pool.c                 | 70 ++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)

diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
index 9e19e8b2..d119db32 100644
--- a/lib/ukallocpool/exportsyms.uk
+++ b/lib/ukallocpool/exportsyms.uk
@@ -5,3 +5,4 @@ uk_allocpool_reqmem
 uk_allocpool_availcount
 uk_allocpool_take
 uk_allocpool_return
+uk_allocpool2ukalloc
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
index 13fbd187..a60acb35 100644
--- a/lib/ukallocpool/include/uk/allocpool.h
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -122,6 +122,18 @@ struct uk_allocpool *uk_allocpool_init(void *base, size_t len,
 				       uk_allocpool_obj_init_t obj_init,
 				       void *obj_init_cookie);
 
+/**
+ * Return uk_alloc compatible interface for allocpool.
+ * With this interface, uk_malloc(), uk_free(), etc. can
+ * be used with the pool.
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @return
+ *  Pointer to uk_alloc interface of given pool.
+ */
+struct uk_alloc *uk_allocpool2alloc(struct uk_allocpool *p);
+
 /**
  * Return the number of current available (free) objects
  *
@@ -134,6 +146,8 @@ unsigned int uk_allocpool_availcount(struct uk_allocpool *p);
 
 /**
  * Get one object from a pool
+ * HINT: It is recommended to use this call instead of uk_malloc() whenever
+ *       feasible. This call is avoiding indirections.
  *
  * @param p
  *  Pointer to memory pool.
@@ -145,6 +159,8 @@ void *uk_allocpool_take(struct uk_allocpool *p);
 
 /**
  * Return one object back to a pool
+ * HINT: It is recommended to use this call instead of uk_free() whenever
+ *       feasible. This call is avoiding indirections.
  *
  * @param p
  *  Pointer to memory pool.
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index a6d868b9..f063ed74 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -64,6 +64,8 @@
 #define MIN_OBJ_LEN   sizeof(struct uk_list_head)
 
 struct uk_allocpool {
+	struct uk_alloc self;
+
 	struct uk_list_head free_obj;
 	unsigned int free_obj_count;
 
@@ -81,6 +83,18 @@ struct free_obj {
 	struct uk_list_head list;
 };
 
+static inline struct uk_allocpool *ukalloc2pool(struct uk_alloc *a)
+{
+	UK_ASSERT(a);
+	return __containerof(a, struct uk_allocpool, self);
+}
+
+struct uk_alloc *uk_allocpool2alloc(struct uk_allocpool *p)
+{
+	UK_ASSERT(p);
+	return &p->self;
+}
+
 static inline void _prepend_free_obj(struct uk_allocpool *p, void *obj)
 {
 	struct uk_list_head *entry;
@@ -110,6 +124,42 @@ static inline void *_take_free_obj(struct uk_allocpool *p)
 	return (void *) obj;
 }
 
+static void pool_free(struct uk_alloc *a, void *ptr)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	if (likely(ptr))
+		_prepend_free_obj(p, ptr);
+}
+
+static void *pool_malloc(struct uk_alloc *a, size_t size)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	if (unlikely((size > p->obj_len)
+		     || uk_list_empty(&p->free_obj))) {
+		errno = ENOMEM;
+		return NULL;
+	}
+
+	return _take_free_obj(p);
+}
+
+static int pool_posix_memalign(struct uk_alloc *a, void **memptr, size_t align,
+				size_t size)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	if (unlikely((size > p->obj_len)
+		     || (align > p->obj_align)
+		     || uk_list_empty(&p->free_obj))) {
+		return ENOMEM;
+	}
+
+	*memptr = _take_free_obj(p);
+	return 0;
+}
+
 void *uk_allocpool_take(struct uk_allocpool *p)
 {
 	UK_ASSERT(p);
@@ -127,6 +177,14 @@ void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 	_prepend_free_obj(p, obj);
 }
 
+#if CONFIG_LIBUKALLOC_IFSTATS
+static size_t pool_availmem(struct uk_alloc *a)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+	return (size_t) p->free_obj_count * p->obj_len;
+}
+#endif
+
 size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
 			   size_t obj_align)
 {
@@ -202,6 +260,18 @@ out:
 	p->base            = base;
 	p->parent          = NULL;
 
+	uk_alloc_init_malloc(a,
+			     pool_malloc,
+			     uk_calloc_compat,
+			     uk_realloc_compat,
+			     pool_free,
+			     pool_posix_memalign,
+			     uk_memalign_compat,
+			     NULL);
+#if CONFIG_LIBUKALLOC_IFSTATS
+	ret->availmem = pool_availmem;
+#endif
+
 	uk_pr_debug("%p: Pool created (%"__PRIsz" B): %u objs of %"__PRIsz" B, aligned to %"__PRIsz" B\n",
 		    p, len, p->obj_count, p->obj_len, p->obj_align);
 	return p;
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 12:50:39 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 12:50:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.10970.29138 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWl-0000dP-09; Fri, 23 Oct 2020 12:50:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 10970.29138; Fri, 23 Oct 2020 12:50:38 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVwWk-0000dI-TS; Fri, 23 Oct 2020 12:50:38 +0000
Received: by outflank-mailman (input) for mailman id 10970;
 Fri, 23 Oct 2020 12:50: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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kVwWk-0000dA-FB
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:38 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 4b594dbb-8437-475d-a6c3-e186d93fa633;
 Fri, 23 Oct 2020 12:50:37 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id A1E4EF2260;
 Fri, 23 Oct 2020 14:50:36 +0200 (CEST)
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 tA2yHUpzZRH4; Fri, 23 Oct 2020 14:50:36 +0200 (CEST)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 6F2FFF210A
 for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:34 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:34 +0200
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=1HaS=D6=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kVwWk-0000dA-FB
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 12:50:38 +0000
X-Inumbo-ID: 4b594dbb-8437-475d-a6c3-e186d93fa633
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 4b594dbb-8437-475d-a6c3-e186d93fa633;
	Fri, 23 Oct 2020 12:50:37 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id A1E4EF2260;
	Fri, 23 Oct 2020 14:50:36 +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 tA2yHUpzZRH4; Fri, 23 Oct 2020 14:50:36 +0200 (CEST)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 6F2FFF210A
	for <minios-devel@lists.xen.org>; Fri, 23 Oct 2020 14:50:34 +0200 (CEST)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 23 Oct
 2020 14:50:34 +0200
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v2 5/5] lib/ukallocpool: Batched allocation
Date: Fri, 23 Oct 2020 14:49:53 +0200
Message-ID: <20201023124953.4000-6-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
References: <20201023124953.4000-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Introduce low-overhead interfaces for batched allocations and batched freeing
of objects.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/exportsyms.uk          |  2 ++
 lib/ukallocpool/include/uk/allocpool.h | 30 ++++++++++++++++++++++++++
 lib/ukallocpool/pool.c                 | 29 +++++++++++++++++++++++++
 3 files changed, 61 insertions(+)

diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
index d119db32..5a6d9f6b 100644
--- a/lib/ukallocpool/exportsyms.uk
+++ b/lib/ukallocpool/exportsyms.uk
@@ -4,5 +4,7 @@ uk_allocpool_init
 uk_allocpool_reqmem
 uk_allocpool_availcount
 uk_allocpool_take
+uk_allocpool_take_batch
 uk_allocpool_return
+uk_allocpool_return_batch
 uk_allocpool2ukalloc
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
index a60acb35..a9f9cb59 100644
--- a/lib/ukallocpool/include/uk/allocpool.h
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -157,6 +157,22 @@ unsigned int uk_allocpool_availcount(struct uk_allocpool *p);
  */
 void *uk_allocpool_take(struct uk_allocpool *p);
 
+/**
+ * Get multiple objects from a pool.
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @param obj
+ *  Pointer to array that will be filled with pointers of
+ *  allocated objects from the pool.
+ * @param count
+ *  Maximum number of objects that should be taken from the pool
+ * @return
+ *  Number of successfully allocated objects on the given array
+ */
+unsigned int uk_allocpool_take_batch(struct uk_allocpool *p,
+				     void *obj[], unsigned int count);
+
 /**
  * Return one object back to a pool
  * HINT: It is recommended to use this call instead of uk_free() whenever
@@ -169,6 +185,20 @@ void *uk_allocpool_take(struct uk_allocpool *p);
  */
 void uk_allocpool_return(struct uk_allocpool *p, void *obj);
 
+/**
+ * Return multiple objects to a pool.
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @param obj
+ *  Pointer to array that with pointers of objects that
+ *  should be returned.
+ * @param count
+ *  Number of objects that are on the array.
+ */
+void uk_allocpool_return_batch(struct uk_allocpool *p,
+			       void *obj[], unsigned int count);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index f063ed74..9b909959 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -170,6 +170,23 @@ void *uk_allocpool_take(struct uk_allocpool *p)
 	return _take_free_obj(p);
 }
 
+unsigned int uk_allocpool_take_batch(struct uk_allocpool *p,
+				     void *obj[], unsigned int count)
+{
+	unsigned int i;
+
+	UK_ASSERT(p);
+	UK_ASSERT(obj);
+
+	for (i = 0; i < count; ++i) {
+		if (unlikely(uk_list_empty(&p->free_obj)))
+			break;
+		obj[i] = _take_free_obj(p);
+	}
+
+	return i;
+}
+
 void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 {
 	UK_ASSERT(p);
@@ -177,6 +194,18 @@ void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 	_prepend_free_obj(p, obj);
 }
 
+void uk_allocpool_return_batch(struct uk_allocpool *p,
+			       void *obj[], unsigned int count)
+{
+	unsigned int i;
+
+	UK_ASSERT(p);
+	UK_ASSERT(obj);
+
+	for (i = 0; i < count; ++i)
+		_prepend_free_obj(p, obj[i]);
+}
+
 #if CONFIG_LIBUKALLOC_IFSTATS
 static size_t pool_availmem(struct uk_alloc *a)
 {
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 14:16:20 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 14:16:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.11010.29224 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVxrc-0000hq-0M; Fri, 23 Oct 2020 14:16:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 11010.29224; Fri, 23 Oct 2020 14:16:15 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVxrb-0000hj-Tf; Fri, 23 Oct 2020 14:16:15 +0000
Received: by outflank-mailman (input) for mailman id 11010;
 Fri, 23 Oct 2020 14:16: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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kVxra-0000he-Ll
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 14:16:14 +0000
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id cde8ad9c-b48d-4184-aaf3-d29a713f20f7;
 Fri, 23 Oct 2020 14:16:11 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 68BA4B561DCB;
 Fri, 23 Oct 2020 17:16:10 +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 22wANRrBLnOi; Fri, 23 Oct 2020 17:16:05 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 05646B561E3B;
 Fri, 23 Oct 2020 17:16:05 +0300 (EEST)
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 7HJxBBzjehes; Fri, 23 Oct 2020 17:16:04 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id 6BE67B561DCB;
 Fri, 23 Oct 2020 17:16:04 +0300 (EEST)
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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kVxra-0000he-Ll
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 14:16:14 +0000
X-Inumbo-ID: cde8ad9c-b48d-4184-aaf3-d29a713f20f7
Received: from mx.upb.ro (unknown [141.85.13.200])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id cde8ad9c-b48d-4184-aaf3-d29a713f20f7;
	Fri, 23 Oct 2020 14:16:11 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 68BA4B561DCB;
	Fri, 23 Oct 2020 17:16:10 +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 22wANRrBLnOi; Fri, 23 Oct 2020 17:16:05 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 05646B561E3B;
	Fri, 23 Oct 2020 17:16: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 7HJxBBzjehes; Fri, 23 Oct 2020 17:16:04 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id 6BE67B561DCB;
	Fri, 23 Oct 2020 17:16:04 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v4 04/12] plat/xen/drivers/net: Configure
 netfront device
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-5-costin.lupu@cs.pub.ro>
 <bc823bb1-ced0-8563-1227-7557c56878df@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <e9441f24-3693-0acc-b798-515f29415f61@cs.pub.ro>
Date: Fri, 23 Oct 2020 17:16:04 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <bc823bb1-ced0-8563-1227-7557c56878df@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

Hi Sharan,

Please see inline.

On 10/22/20 2:00 PM, Sharan Santhanam wrote:
> Hello Costin,
>=20
> Please find some minor comments inline:
>=20
> Thanks & Regards
>=20
> Sharan
>=20
> On 8/13/20 10:53 AM, Costin Lupu wrote:
>> The information needed for configuring netfront devices is in the
>> Xenstore. For
>> now, we only retrieve the MAC and IP addresses from there in order to
>> initialize the device.
>>
>> This patch introduces the `netfront_dev` structure which integrates
>> both netdev
>> and Xenbus device information and also keeps the configuration
>> parameters.
>>
>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
>> ---
>> =C2=A0 plat/xen/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 1 +
>> =C2=A0 plat/xen/drivers/net/netfront.c=C2=A0=C2=A0=C2=A0 | 100 +++++++=
+++++++
>> =C2=A0 plat/xen/drivers/net/netfront.h=C2=A0=C2=A0=C2=A0 |=C2=A0 66 ++=
++++++++
>> =C2=A0 plat/xen/drivers/net/netfront_xb.h |=C2=A0 43 ++++++
>> =C2=A0 plat/xen/drivers/net/netfront_xs.c | 205 ++++++++++++++++++++++=
+++++++
>> =C2=A0 5 files changed, 415 insertions(+)
>> =C2=A0 create mode 100644 plat/xen/drivers/net/netfront.h
>> =C2=A0 create mode 100644 plat/xen/drivers/net/netfront_xb.h
>> =C2=A0 create mode 100644 plat/xen/drivers/net/netfront_xs.c
>>
>> diff --git a/plat/xen/Makefile.uk b/plat/xen/Makefile.uk
>> index 339b1b21..dfca58fe 100644
>> --- a/plat/xen/Makefile.uk
>> +++ b/plat/xen/Makefile.uk
>> @@ -121,6 +121,7 @@ LIBXENNETFRONT_ASINCLUDES-y=C2=A0=C2=A0=C2=A0 +=3D
>> $(LIBXENPLAT_ASINCLUDES-y)
>> =C2=A0 LIBXENNETFRONT_CFLAGS-y=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 +=3D $(LIBXENPLAT_CFLAGS-y)
>> =C2=A0 LIBXENNETFRONT_CINCLUDES-y=C2=A0=C2=A0=C2=A0=C2=A0 +=3D $(LIBXE=
NPLAT_CINCLUDES-y)
>> =C2=A0 LIBXENNETFRONT_SRCS-y=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 +=3D
>> $(LIBXENPLAT_BASE)/drivers/net/netfront.c
>> +LIBXENNETFRONT_SRCS-y=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 +=3D
>> $(LIBXENPLAT_BASE)/drivers/net/netfront_xs.c
>> =C2=A0 endif
>> =C2=A0 =C2=A0 ifeq ($(CONFIG_XEN_BLKFRONT),y)
>> diff --git a/plat/xen/drivers/net/netfront.c
>> b/plat/xen/drivers/net/netfront.c
>> index b455911e..539e1cbc 100644
>> --- a/plat/xen/drivers/net/netfront.c
>> +++ b/plat/xen/drivers/net/netfront.c
>> @@ -33,21 +33,121 @@
>> =C2=A0=C2=A0 * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY=
.
>> =C2=A0=C2=A0 */
>> =C2=A0 +#include <uk/assert.h>
>> +#include <uk/print.h>
>> +#include <uk/alloc.h>
>> +#include <uk/netdev_driver.h>
>> =C2=A0 #include <xenbus/xenbus.h>
>> +#include "netfront.h"
>> +#include "netfront_xb.h"
>> =C2=A0 =C2=A0 =C2=A0 #define DRIVER_NAME=C2=A0 "xen-netfront"
>> =C2=A0 +#define to_netfront_dev(dev) \
>> +=C2=A0=C2=A0=C2=A0 __containerof(dev, struct netfront_dev, netdev)
>> +
>> =C2=A0 static struct uk_alloc *drv_allocator;
>> =C2=A0 +static const void *netfront_einfo_get(struct uk_netdev *n,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 enum uk_netdev_einfo_type =
einfo_type)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +=C2=A0=C2=A0=C2=A0 switch (einfo_type) {
>> +=C2=A0=C2=A0=C2=A0 case UK_NETDEV_IPV4_ADDR_STR:
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return nfdev->econf.ipv4ad=
dr;
>> +=C2=A0=C2=A0=C2=A0 case UK_NETDEV_IPV4_MASK_STR:
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return nfdev->econf.ipv4ma=
sk;
>> +=C2=A0=C2=A0=C2=A0 case UK_NETDEV_IPV4_GW_STR:
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return nfdev->econf.ipv4gw=
;
>> +=C2=A0=C2=A0=C2=A0 default:
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 /* type not supported */
>> +=C2=A0=C2=A0=C2=A0 return NULL;
>> +}
>> +
>> +static const struct uk_hwaddr *netfront_mac_get(struct uk_netdev *n)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +=C2=A0=C2=A0=C2=A0 return &nfdev->hw_addr;
>> +}
>> +
>> +static uint16_t netfront_mtu_get(struct uk_netdev *n)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +=C2=A0=C2=A0=C2=A0 return nfdev->mtu;
>> +}
>> +
>> +static unsigned int netfront_promisc_get(struct uk_netdev *n)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +=C2=A0=C2=A0=C2=A0 return nfdev->promisc;
>> +}
>> +
>> +static const struct uk_netdev_ops netfront_ops =3D {
>> +=C2=A0=C2=A0=C2=A0 .einfo_get =3D netfront_einfo_get,
>> +=C2=A0=C2=A0=C2=A0 .hwaddr_get =3D netfront_mac_get,
>> +=C2=A0=C2=A0=C2=A0 .mtu_get =3D netfront_mtu_get,
>> +=C2=A0=C2=A0=C2=A0 .promiscuous_get =3D netfront_promisc_get,
>> +};
>> =C2=A0 =C2=A0 static int netfront_add_dev(struct xenbus_device *xendev=
)
>> =C2=A0 {
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int rc =3D 0;
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 UK_ASSERT(xendev !=3D NULL);
>> =C2=A0 +=C2=A0=C2=A0=C2=A0 nfdev =3D uk_calloc(drv_allocator, 1, sizeo=
f(*nfdev));
>> +=C2=A0=C2=A0=C2=A0 if (!nfdev) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D -ENOMEM;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto err_out;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev->xendev =3D xendev;
>> +=C2=A0=C2=A0=C2=A0 nfdev->mtu =3D ETH_PKT_PAYLOAD_LEN;
> Adapt it to make it compatible with latest macro.
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Xenbus initialization */
>> +=C2=A0=C2=A0=C2=A0 rc =3D netfront_xb_init(nfdev, drv_allocator);
>> +=C2=A0=C2=A0=C2=A0 if (rc) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Error initializ=
ing Xenbus data: %d\n", rc);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto err_xenbus;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 /* register netdev */
>> +=C2=A0=C2=A0=C2=A0 nfdev->netdev.ops =3D &netfront_ops;
>> +=C2=A0=C2=A0=C2=A0 rc =3D uk_netdev_drv_register(&nfdev->netdev, drv_=
allocator,
>> DRIVER_NAME);
>> +=C2=A0=C2=A0=C2=A0 if (rc < 0) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Failed to regis=
ter %s device with libuknetdev\n",
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 DR=
IVER_NAME);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto err_register;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 nfdev->uid =3D rc;
>> +=C2=A0=C2=A0=C2=A0 rc =3D 0;
>> +
>> +out:
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc;
>> +err_register:
>> +=C2=A0=C2=A0=C2=A0 netfront_xb_fini(nfdev, drv_allocator);
>> +err_xenbus:
>> +=C2=A0=C2=A0=C2=A0 uk_free(drv_allocator, nfdev);
>> +err_out:
>> +=C2=A0=C2=A0=C2=A0 goto out;
>> =C2=A0 }
>> =C2=A0 =C2=A0 static int netfront_drv_init(struct uk_alloc *allocator)
>> diff --git a/plat/xen/drivers/net/netfront.h
>> b/plat/xen/drivers/net/netfront.h
>> new file mode 100644
>> index 00000000..0cc8230b
>> --- /dev/null
>> +++ b/plat/xen/drivers/net/netfront.h
>> @@ -0,0 +1,66 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause */
>> +/*
>> + * Authors: Costin Lupu <costin.lupu@cs.pub.ro>
>> + *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Razvan Cojoc=
aru <razvan.cojocaru93@gmail.com>
>> + *
>> + * Copyright (c) 2020, University Politehnica of Bucharest. All
>> rights reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + *
>> + * 1. Redistributions of source code must retain the above copyright
>> + *=C2=A0=C2=A0=C2=A0 notice, this list of conditions and the followin=
g disclaimer.
>> + * 2. Redistributions in binary form must reproduce the above copyrig=
ht
>> + *=C2=A0=C2=A0=C2=A0 notice, this list of conditions and the followin=
g disclaimer in
>> the
>> + *=C2=A0=C2=A0=C2=A0 documentation and/or other materials provided wi=
th the
>> distribution.
>> + * 3. Neither the name of the copyright holder nor the names of its
>> + *=C2=A0=C2=A0=C2=A0 contributors may be used to endorse or promote p=
roducts derived
>> from
>> + *=C2=A0=C2=A0=C2=A0 this software without specific prior written per=
mission.
>> + *
>> + * 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, O=
R
>> + * 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 __NETFRONT_H__
>> +#define __NETFRONT_H__
>> +
>> +#include <uk/netdev.h>
>> +
>> +struct xs_econf {
>> +=C2=A0=C2=A0=C2=A0 char *ipv4addr;
>> +=C2=A0=C2=A0=C2=A0 char *ipv4mask;
>> +=C2=A0=C2=A0=C2=A0 char *ipv4gw;
>> +};
>> +
>> +struct netfront_dev {
>> +=C2=A0=C2=A0=C2=A0 /* Xenbus device */
>> +=C2=A0=C2=A0=C2=A0 struct xenbus_device *xendev;
>> +=C2=A0=C2=A0=C2=A0 /* Network device */
>> +=C2=A0=C2=A0=C2=A0 struct uk_netdev netdev;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Configuration parameters */
>> +=C2=A0=C2=A0=C2=A0 struct xs_econf econf;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* The netdevice identifier */
>> +=C2=A0=C2=A0=C2=A0 uint16_t uid;
>> +=C2=A0=C2=A0=C2=A0 /* The mtu */
>> +=C2=A0=C2=A0=C2=A0 uint16_t mtu;
>> +=C2=A0=C2=A0=C2=A0 /* The hw address of the netdevice */
>> +=C2=A0=C2=A0=C2=A0 struct uk_hwaddr hw_addr;
>> +=C2=A0=C2=A0=C2=A0 /* RX promiscuous mode. */
>> +=C2=A0=C2=A0=C2=A0 uint8_t promisc : 1;
>> +};
>> +
>> +#endif /* __NETFRONT_H__ */
>> diff --git a/plat/xen/drivers/net/netfront_xb.h
>> b/plat/xen/drivers/net/netfront_xb.h
>> new file mode 100644
>> index 00000000..6332cf71
>> --- /dev/null
>> +++ b/plat/xen/drivers/net/netfront_xb.h
>> @@ -0,0 +1,43 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause */
>> +/*
>> + * Authors: Costin Lupu <costin.lupu@cs.pub.ro>
>> + *
>> + * Copyright (c) 2020, University Politehnica of Bucharest. All
>> rights reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + *
>> + * 1. Redistributions of source code must retain the above copyright
>> + *=C2=A0=C2=A0=C2=A0 notice, this list of conditions and the followin=
g disclaimer.
>> + * 2. Redistributions in binary form must reproduce the above copyrig=
ht
>> + *=C2=A0=C2=A0=C2=A0 notice, this list of conditions and the followin=
g disclaimer in
>> the
>> + *=C2=A0=C2=A0=C2=A0 documentation and/or other materials provided wi=
th the
>> distribution.
>> + * 3. Neither the name of the copyright holder nor the names of its
>> + *=C2=A0=C2=A0=C2=A0 contributors may be used to endorse or promote p=
roducts derived
>> from
>> + *=C2=A0=C2=A0=C2=A0 this software without specific prior written per=
mission.
>> + *
>> + * 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, O=
R
>> + * 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 __NETFRONT_XB_H__
>> +#define __NETFRONT_XB_H__
>> +
>> +#include "netfront.h"
>> +
>> +int=C2=A0 netfront_xb_init(struct netfront_dev *netdev, struct uk_all=
oc *a);
>> +void netfront_xb_fini(struct netfront_dev *netdev, struct uk_alloc *a=
);
>> +
>> +#endif /* __NETFRONT_XB_H__ */
>> diff --git a/plat/xen/drivers/net/netfront_xs.c
>> b/plat/xen/drivers/net/netfront_xs.c
>> new file mode 100644
>> index 00000000..48f01b34
>> --- /dev/null
>> +++ b/plat/xen/drivers/net/netfront_xs.c
>> @@ -0,0 +1,205 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause */
>> +/*
>> + * Authors: Costin Lupu <costin.lupu@cs.pub.ro>
>> + *
>> + * Copyright (c) 2020, University Politehnica of Bucharest. All
>> rights reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + *
>> + * 1. Redistributions of source code must retain the above copyright
>> + *=C2=A0=C2=A0=C2=A0 notice, this list of conditions and the followin=
g disclaimer.
>> + * 2. Redistributions in binary form must reproduce the above copyrig=
ht
>> + *=C2=A0=C2=A0=C2=A0 notice, this list of conditions and the followin=
g disclaimer in
>> the
>> + *=C2=A0=C2=A0=C2=A0 documentation and/or other materials provided wi=
th the
>> distribution.
>> + * 3. Neither the name of the copyright holder nor the names of its
>> + *=C2=A0=C2=A0=C2=A0 contributors may be used to endorse or promote p=
roducts derived
>> from
>> + *=C2=A0=C2=A0=C2=A0 this software without specific prior written per=
mission.
>> + *
>> + * 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, O=
R
>> + * 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 <inttypes.h>
>> +#include <stdio.h>
>> +#include <string.h>
>> +#include <uk/errptr.h>
>> +#include <uk/print.h>
>> +#include <uk/assert.h>
>> +#include <xenbus/xs.h>
>> +#include "netfront_xb.h"
>> +
>> +
>> +static int xs_read_backend_id(const char *nodename, domid_t *domid)
>> +{
>> +=C2=A0=C2=A0=C2=A0 char path[strlen(nodename) + sizeof("/backend-id")=
];
>> +=C2=A0=C2=A0=C2=A0 int value, rc;
> UK_ASSERT(nodename);

Actually this is too late to assert it here. Given that this is a static
function and we control how we call it, the assertion should actually be
made in netfront_xb_init().

>> +
>> +=C2=A0=C2=A0=C2=A0 sprintf(path, "%s/backend-id", nodename);
> snprintf instead of sprintf

Ack.


>> +
>> +=C2=A0=C2=A0=C2=A0 rc =3D xs_read_integer(XBT_NIL, path, &value);
>> +=C2=A0=C2=A0=C2=A0 if (!rc)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *domid =3D (domid_t) value=
;
>> +
>> +=C2=A0=C2=A0=C2=A0 return rc;
>> +}
>> +
>> +static void xs_econf_fini(struct xs_econf *econf,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_alloc *a)
>> +{
>> +=C2=A0=C2=A0=C2=A0 if (econf->ipv4addr) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_free(a, econf->ipv4addr=
);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 econf->ipv4addr =3D NULL;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 if (econf->ipv4mask) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_free(a, econf->ipv4mask=
);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 econf->ipv4mask =3D NULL;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 if (econf->ipv4gw) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_free(a, econf->ipv4gw);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 econf->ipv4gw =3D NULL;
>> +=C2=A0=C2=A0=C2=A0 }
>> +}
>> +
>> +static int xs_econf_init(struct xs_econf *econf, char *ip_str,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_alloc *a)
>> +{
>> +=C2=A0=C2=A0=C2=A0 int rc =3D -1;
>> +=C2=A0=C2=A0=C2=A0 char *ip_addr =3D NULL, *ip_gw_str =3D NULL, *ip_m=
ask_str =3D NULL;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* IP */
>> +=C2=A0=C2=A0=C2=A0 ip_addr =3D strtok(ip_str, " ");
>> +=C2=A0=C2=A0=C2=A0 if (ip_addr =3D=3D NULL)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_err;
>> +=C2=A0=C2=A0=C2=A0 econf->ipv4addr =3D uk_malloc(a, strlen(ip_addr) +=
 1);
>> +=C2=A0=C2=A0=C2=A0 if (!econf->ipv4addr) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Error allocatin=
g ip config.\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_err;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 memcpy(econf->ipv4addr, ip_addr, strlen(ip_addr) +=
 1);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Mask */
>> +=C2=A0=C2=A0=C2=A0 ip_mask_str =3D strtok(NULL, " ");
>> +=C2=A0=C2=A0=C2=A0 if (ip_mask_str =3D=3D NULL)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_err;
>> +=C2=A0=C2=A0=C2=A0 econf->ipv4mask =3D uk_malloc(a, strlen(ip_mask_st=
r) + 1);
>> +=C2=A0=C2=A0=C2=A0 if (!econf->ipv4mask) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Error allocatin=
g ip mask config.\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_err;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 memcpy(econf->ipv4mask, ip_mask_str, strlen(ip_mas=
k_str) + 1);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Gateway */
>> +=C2=A0=C2=A0=C2=A0 ip_gw_str =3D strtok(NULL, " ");
>> +=C2=A0=C2=A0=C2=A0 if (ip_gw_str =3D=3D NULL)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_err;
>> +=C2=A0=C2=A0=C2=A0 econf->ipv4gw =3D uk_malloc(a, strlen(ip_gw_str) +=
 1);
>> +=C2=A0=C2=A0=C2=A0 if (!econf->ipv4gw) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Error allocatin=
g ip gateway config.\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_err;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 memcpy(econf->ipv4gw, ip_gw_str, strlen(ip_gw_str)=
 + 1);
>> +
>> +=C2=A0=C2=A0=C2=A0 rc =3D 0;
>> +out:
>> +=C2=A0=C2=A0=C2=A0 return rc;
>> +out_err:
>> +=C2=A0=C2=A0=C2=A0 xs_econf_fini(econf, a);
>> +=C2=A0=C2=A0=C2=A0 goto out;
>> +}
>> +
>> +int netfront_xb_init(struct netfront_dev *nfdev, struct uk_alloc *a)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct xenbus_device *xendev;
>> +=C2=A0=C2=A0=C2=A0 char *mac_str, *p, *ip_str;
>> +=C2=A0=C2=A0=C2=A0 int rc;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(nfdev !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 xendev =3D nfdev->xendev;
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(xendev !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 rc =3D xs_read_backend_id(xendev->nodename, &xende=
v->otherend_id);
>> +=C2=A0=C2=A0=C2=A0 if (rc)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* read backend path */
>> +=C2=A0=C2=A0=C2=A0 xendev->otherend =3D xs_read(XBT_NIL, xendev->node=
name, "backend");
>> +=C2=A0=C2=A0=C2=A0 if (PTRISERR(xendev->otherend)) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Error reading b=
ackend path.\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D PTR2ERR(xendev->oth=
erend);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 xendev->otherend =3D NULL;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 /* read MAC address */
>> +=C2=A0=C2=A0=C2=A0 mac_str =3D xs_read(XBT_NIL, xendev->nodename, "ma=
c");
>> +=C2=A0=C2=A0=C2=A0 if (PTRISERR(mac_str)) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Error reading M=
AC address.\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D PTR2ERR(mac_str);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto no_conf;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 uk_pr_info("\tMAC %s\n", mac_str);
>> +
>> +=C2=A0=C2=A0=C2=A0 p =3D mac_str;
>> +=C2=A0=C2=A0=C2=A0 for (int i =3D 0; i < UK_NETDEV_HWADDR_LEN; i++) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->hw_addr.addr_bytes[=
i] =3D (uint8_t) strtoul(p, &p, 16);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 p++;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 free(mac_str);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* read IP address */
>> +=C2=A0=C2=A0=C2=A0 ip_str =3D xs_read(XBT_NIL, xendev->otherend, "ip"=
);
>> +=C2=A0=C2=A0=C2=A0 if (PTRISERR(ip_str)) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Error reading I=
P address.\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D PTR2ERR(ip_str);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto no_conf;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 uk_pr_info("\tIP: %s\n", ip_str);
>> +
>> +=C2=A0=C2=A0=C2=A0 rc =3D xs_econf_init(&nfdev->econf, ip_str, a);
>> +=C2=A0=C2=A0=C2=A0 if (rc)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto no_conf;
>> +=C2=A0=C2=A0=C2=A0 free(ip_str);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* TODO spit event channels */
>> +
>> +=C2=A0=C2=A0=C2=A0 /* TODO netmap */
>> +
>> +out:
>> +=C2=A0=C2=A0=C2=A0 return rc;
>> +no_conf:
>> +=C2=A0=C2=A0=C2=A0 if (xendev->otherend) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 free(xendev->otherend);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 xendev->otherend =3D NULL;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 goto out;
>> +}
>> +
>> +void netfront_xb_fini(struct netfront_dev *nfdev, struct uk_alloc *a)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct xenbus_device *xendev;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(nfdev !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 xendev =3D nfdev->xendev;
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(xendev !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 xs_econf_fini(&nfdev->econf, a);
>> +
>> +=C2=A0=C2=A0=C2=A0 if (xendev->otherend) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 free(xendev->otherend);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 xendev->otherend =3D NULL;
>> +=C2=A0=C2=A0=C2=A0 }
>> +}
>=20


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 14:50:19 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 14:50:19 +0000
Received: from list by lists.xenproject.org with outflank-mailman.11047.29289 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVyOY-0004s5-1Q; Fri, 23 Oct 2020 14:50:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 11047.29289; Fri, 23 Oct 2020 14:50:18 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVyOX-0004ry-Ud; Fri, 23 Oct 2020 14:50:17 +0000
Received: by outflank-mailman (input) for mailman id 11047;
 Fri, 23 Oct 2020 14:50: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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kVyOX-0004rt-3D
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 14:50:17 +0000
Received: from mx.upb.ro (unknown [141.85.13.230])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id f9d32ca3-d3fd-4440-8bf6-dd6046555f61;
 Fri, 23 Oct 2020 14:50:14 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id D729AB5625EA;
 Fri, 23 Oct 2020 17:50:13 +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 1KnWtEp5Wk5J; Fri, 23 Oct 2020 17:50:10 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 6F39FB5625DE;
 Fri, 23 Oct 2020 17:50:10 +0300 (EEST)
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 q7x44TwVhg99; Fri, 23 Oct 2020 17:50:10 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id 19A92B5625D3;
 Fri, 23 Oct 2020 17:50:09 +0300 (EEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kVyOX-0004rt-3D
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 14:50:17 +0000
X-Inumbo-ID: f9d32ca3-d3fd-4440-8bf6-dd6046555f61
Received: from mx.upb.ro (unknown [141.85.13.230])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id f9d32ca3-d3fd-4440-8bf6-dd6046555f61;
	Fri, 23 Oct 2020 14:50:14 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id D729AB5625EA;
	Fri, 23 Oct 2020 17:50:13 +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 1KnWtEp5Wk5J; Fri, 23 Oct 2020 17:50:10 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 6F39FB5625DE;
	Fri, 23 Oct 2020 17:50:10 +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 q7x44TwVhg99; Fri, 23 Oct 2020 17:50:10 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id 19A92B5625D3;
	Fri, 23 Oct 2020 17:50:09 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v4 05/12] plat/xen/drivers/net: Create netfront
 queues
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-6-costin.lupu@cs.pub.ro>
 <c31212d2-05d2-9146-2986-3dc86728ac8d@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <e83791d5-fd0e-67b0-69f4-12d8ef7f27bc@cs.pub.ro>
Date: Fri, 23 Oct 2020 17:50:09 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <c31212d2-05d2-9146-2986-3dc86728ac8d@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

Hi Sharan,

Please see inline.

On 10/22/20 2:13 PM, Sharan Santhanam wrote:
> Hello Costin,
>=20
> I have a minor comments inline but the rest of it fine.
>=20
> Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
>=20
>=20
> Thanks & Regards
>=20
> Sharan
>=20
> On 8/13/20 10:53 AM, Costin Lupu wrote:
>> We continue with the device configuration by retrieving the Xenstore
>> information regarding the number of queues and their associated event
>> channels.
>> Netfront devices operate pairs of Rx/Tx queues and for notifications
>> we can
>> either use a single event channel per pair or split event channels.
>>
>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
>> ---
>> =C2=A0 plat/xen/drivers/net/netfront.c=C2=A0=C2=A0=C2=A0 | 81 ++++++++=
++++++++++++++++++++++
>> =C2=A0 plat/xen/drivers/net/netfront.h=C2=A0=C2=A0=C2=A0 | 20 ++++++++
>> =C2=A0 plat/xen/drivers/net/netfront_xs.c | 18 ++++++-
>> =C2=A0 3 files changed, 117 insertions(+), 2 deletions(-)
>>
>> diff --git a/plat/xen/drivers/net/netfront.c
>> b/plat/xen/drivers/net/netfront.c
>> index 539e1cbc..ddbb4b70 100644
>> --- a/plat/xen/drivers/net/netfront.c
>> +++ b/plat/xen/drivers/net/netfront.c
>> @@ -49,6 +49,84 @@
>> =C2=A0 =C2=A0 static struct uk_alloc *drv_allocator;
>> =C2=A0 +static int netfront_rxtx_alloc(struct netfront_dev *nfdev,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct uk_netdev_con=
f *conf)
>> +{
>> +=C2=A0=C2=A0=C2=A0 int rc =3D 0;
>> +
>> +=C2=A0=C2=A0=C2=A0 if (conf->nb_tx_queues !=3D conf->nb_rx_queues) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Different numbe=
r of queues not supported\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D -ENOTSUP;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto err_free_txrx;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev->max_queue_pairs =3D
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 MIN(nfdev->max_queue_pairs=
, conf->nb_tx_queues);
>=20
> Should we change the max_queue_pair to the user input or retain the max
> value provided by the system and use separate variable in the structure
> to store this?
>=20

The max value provided by the system has no usage anymore after the user
configures it. The new value has to be published by the frontend in
order to be used by the system (i.e. netback driver) as well. However,
the current version doesn't do that, so I'll have to add the changes in
'09/12 plat/xen/drivers/net: Start netfront device' patch.

>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev->txqs =3D uk_calloc(drv_allocator,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->max_queue_pairs, si=
zeof(*nfdev->txqs));
>> +=C2=A0=C2=A0=C2=A0 if (unlikely(!nfdev->txqs)) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Failed to alloc=
ate memory for tx queues\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D -ENOMEM;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto err_free_txrx;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev->rxqs =3D uk_calloc(drv_allocator,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->max_queue_pairs, si=
zeof(*nfdev->rxqs));
>> +=C2=A0=C2=A0=C2=A0 if (unlikely(!nfdev->rxqs)) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Failed to alloc=
ate memory for rx queues\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D -ENOMEM;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto err_free_txrx;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 return rc;
>> +
>> +err_free_txrx:
>> +=C2=A0=C2=A0=C2=A0 if (!nfdev->rxqs)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_free(drv_allocator, nfd=
ev->rxqs);
>> +=C2=A0=C2=A0=C2=A0 if (!nfdev->txqs)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_free(drv_allocator, nfd=
ev->txqs);
>> +
>> +=C2=A0=C2=A0=C2=A0 return rc;
>> +}
>> +
>> +static int netfront_configure(struct uk_netdev *n,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct uk_netdev_con=
f *conf)
>> +{
>> +=C2=A0=C2=A0=C2=A0 int rc;
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(conf !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +
>> +=C2=A0=C2=A0=C2=A0 rc =3D netfront_rxtx_alloc(nfdev, conf);
>> +=C2=A0=C2=A0=C2=A0 if (rc !=3D 0) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Failed to alloc=
ate rx and tx rings %d\n", rc);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +out:
>> +=C2=A0=C2=A0=C2=A0 return rc;
>> +}
>> +
>> +static void netfront_info_get(struct uk_netdev *n,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_info *dev=
_info)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(dev_info !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +=C2=A0=C2=A0=C2=A0 dev_info->max_rx_queues =3D nfdev->max_queue_pairs=
;
>> +=C2=A0=C2=A0=C2=A0 dev_info->max_tx_queues =3D nfdev->max_queue_pairs=
;
>> +=C2=A0=C2=A0=C2=A0 dev_info->max_mtu =3D nfdev->mtu;
>> +=C2=A0=C2=A0=C2=A0 dev_info->nb_encap_tx =3D 0;
>> +=C2=A0=C2=A0=C2=A0 dev_info->nb_encap_rx =3D 0;
>> +}
>> +
>> =C2=A0 static const void *netfront_einfo_get(struct uk_netdev *n,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 enum uk_netdev_=
einfo_type einfo_type)
>> =C2=A0 {
>> @@ -100,6 +178,8 @@ static unsigned int netfront_promisc_get(struct
>> uk_netdev *n)
>> =C2=A0 }
>> =C2=A0 =C2=A0 static const struct uk_netdev_ops netfront_ops =3D {
>> +=C2=A0=C2=A0=C2=A0 .configure =3D netfront_configure,
>> +=C2=A0=C2=A0=C2=A0 .info_get =3D netfront_info_get,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .einfo_get =3D netfront_einfo_get,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .hwaddr_get =3D netfront_mac_get,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .mtu_get =3D netfront_mtu_get,
>> @@ -121,6 +201,7 @@ static int netfront_add_dev(struct xenbus_device
>> *xendev)
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->xendev =3D xendev;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->mtu =3D ETH_PKT_PAYLOAD_LEN;
>> +=C2=A0=C2=A0=C2=A0 nfdev->max_queue_pairs =3D 1;
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Xenbus initialization */
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D netfront_xb_init(nfdev, drv_allo=
cator);
>> diff --git a/plat/xen/drivers/net/netfront.h
>> b/plat/xen/drivers/net/netfront.h
>> index 0cc8230b..a811b092 100644
>> --- a/plat/xen/drivers/net/netfront.h
>> +++ b/plat/xen/drivers/net/netfront.h
>> @@ -38,6 +38,18 @@
>> =C2=A0 =C2=A0 #include <uk/netdev.h>
>> =C2=A0 +/**
>> + * internal structure to represent the transmit queue.
>> + */
>> +struct uk_netdev_tx_queue {
>> +};
>> +
>> +/**
>> + * internal structure to represent the receive queue.
>> + */
>> +struct uk_netdev_rx_queue {
>> +};
>> +
>> =C2=A0 struct xs_econf {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 char *ipv4addr;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 char *ipv4mask;
>> @@ -50,6 +62,14 @@ struct netfront_dev {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Network device */
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev netdev;
>> =C2=A0 +=C2=A0=C2=A0=C2=A0 /* List of the Rx/Tx queues */
>> +=C2=A0=C2=A0=C2=A0 struct uk_netdev_tx_queue *txqs;
>> +=C2=A0=C2=A0=C2=A0 struct uk_netdev_rx_queue *rxqs;
>> +=C2=A0=C2=A0=C2=A0 /* Maximum number of queue pairs */
>> +=C2=A0=C2=A0=C2=A0 uint16_t=C2=A0 max_queue_pairs;
>> +=C2=A0=C2=A0=C2=A0 /* True if using split event channels */
>> +=C2=A0=C2=A0=C2=A0 bool split_evtchn;
>> +
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Configuration parameters */
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct xs_econf econf;
>> =C2=A0 diff --git a/plat/xen/drivers/net/netfront_xs.c
>> b/plat/xen/drivers/net/netfront_xs.c
>> index 48f01b34..1bde44e0 100644
>> --- a/plat/xen/drivers/net/netfront_xs.c
>> +++ b/plat/xen/drivers/net/netfront_xs.c
>> @@ -122,7 +122,7 @@ out_err:
>> =C2=A0 int netfront_xb_init(struct netfront_dev *nfdev, struct uk_allo=
c *a)
>> =C2=A0 {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct xenbus_device *xendev;
>> -=C2=A0=C2=A0=C2=A0 char *mac_str, *p, *ip_str;
>> +=C2=A0=C2=A0=C2=A0 char *mac_str, *p, *ip_str, *int_str;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int rc;
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 UK_ASSERT(nfdev !=3D NULL);
>> @@ -173,7 +173,21 @@ int netfront_xb_init(struct netfront_dev *nfdev,
>> struct uk_alloc *a)
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto no_conf;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 free(ip_str);
>> =C2=A0 -=C2=A0=C2=A0=C2=A0 /* TODO spit event channels */
>> +=C2=A0=C2=A0=C2=A0 /* maximum queues number */
>> +=C2=A0=C2=A0=C2=A0 int_str =3D xs_read(XBT_NIL, xendev->otherend,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "multi-queue-max-queues");
>> +=C2=A0=C2=A0=C2=A0 if (!PTRISERR(int_str)) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->max_queue_pairs =3D=
 (uint16_t) strtoul(int_str, NULL, 10);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 free(int_str);
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 /* spit event channels */
>> +=C2=A0=C2=A0=C2=A0 int_str =3D xs_read(XBT_NIL, xendev->otherend,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "feature-split-event-chann=
els");
>> +=C2=A0=C2=A0=C2=A0 if (!PTRISERR(int_str)) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->split_evtchn =3D (b=
ool) strtoul(int_str, NULL, 10);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 free(int_str);
>> +=C2=A0=C2=A0=C2=A0 }
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* TODO netmap */
>> =C2=A0=20
>=20


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 14:58:37 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 14:58:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.11058.29316 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVyWa-0005Jh-2g; Fri, 23 Oct 2020 14:58:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 11058.29316; Fri, 23 Oct 2020 14:58:36 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVyWZ-0005Ja-W4; Fri, 23 Oct 2020 14:58:35 +0000
Received: by outflank-mailman (input) for mailman id 11058;
 Fri, 23 Oct 2020 14:58:35 +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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kVyWZ-0005JV-0v
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 14:58:35 +0000
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 020d278e-5d91-434a-a406-d2ff01caebf4;
 Fri, 23 Oct 2020 14:58:33 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id AA594B561DCB;
 Fri, 23 Oct 2020 17:58: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 6oO5NvOb3ql7; Fri, 23 Oct 2020 17:58:30 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id A951BB561E3B;
 Fri, 23 Oct 2020 17:58:30 +0300 (EEST)
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 HGY8d68WflUK; Fri, 23 Oct 2020 17:58:30 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id 71A23B561DCB;
 Fri, 23 Oct 2020 17:58:30 +0300 (EEST)
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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kVyWZ-0005JV-0v
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 14:58:35 +0000
X-Inumbo-ID: 020d278e-5d91-434a-a406-d2ff01caebf4
Received: from mx.upb.ro (unknown [141.85.13.200])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 020d278e-5d91-434a-a406-d2ff01caebf4;
	Fri, 23 Oct 2020 14:58:33 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id AA594B561DCB;
	Fri, 23 Oct 2020 17:58: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 6oO5NvOb3ql7; Fri, 23 Oct 2020 17:58:30 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id A951BB561E3B;
	Fri, 23 Oct 2020 17:58:30 +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 HGY8d68WflUK; Fri, 23 Oct 2020 17:58:30 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id 71A23B561DCB;
	Fri, 23 Oct 2020 17:58:30 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v4 12/12] lib/uknetdev: Enable default drivers
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-13-costin.lupu@cs.pub.ro>
 <b1e46f2b-3268-46ad-0bf5-f24b5d32516b@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <af4b9af1-846b-98c6-534d-571ff3fc1ff5@cs.pub.ro>
Date: Fri, 23 Oct 2020 17:58:30 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <b1e46f2b-3268-46ad-0bf5-f24b5d32516b@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

Hi Sharan,

Please see inline.

On 10/22/20 4:43 PM, Sharan Santhanam wrote:
> Hello Costin,
>=20
> Please find the comments inline
>=20
> Thanks & Regards
>=20
> Sharan
>=20
> On 8/13/20 10:53 AM, Costin Lupu wrote:
>> Currently, for KVM and Xen we only have one network driver each. We
>> enable
>> them by default whenever uknetdev library is enabled.
>>
>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>> ---
>> =C2=A0 lib/uknetdev/Config.uk | 2 ++
>> =C2=A0 1 file changed, 2 insertions(+)
>>
>> diff --git a/lib/uknetdev/Config.uk b/lib/uknetdev/Config.uk
>> index 186dd462..2af47efb 100644
>> --- a/lib/uknetdev/Config.uk
>> +++ b/lib/uknetdev/Config.uk
>> @@ -5,6 +5,8 @@ menuconfig LIBUKNETDEV
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 select LIBUKDEBUG
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 select LIBUKALLOC
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 imply LIBUKLIBPARAM
>> +=C2=A0=C2=A0=C2=A0 imply VIRTIO_NET if PLAT_KVM
>> +=C2=A0=C2=A0=C2=A0 imply XEN_NETFRONT if PLAT_XEN
>=20
> Instead of imply we can set `default y if LIBUKNETDEV` in each of the
> driver kconfig.
>=20
> What do you think?

Yes, Simone had the same suggestion on patch 01 review.

>=20
>> =C2=A0 =C2=A0 if LIBUKNETDEV
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 config LIBUKNETDEV_MAXNBQUEUES
>=20


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 15:18:13 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 15:18:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.11075.29345 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVypW-0007T2-1B; Fri, 23 Oct 2020 15:18:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 11075.29345; Fri, 23 Oct 2020 15:18:10 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVypV-0007Sv-UY; Fri, 23 Oct 2020 15:18:09 +0000
Received: by outflank-mailman (input) for mailman id 11075;
 Fri, 23 Oct 2020 15:18: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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kVypU-0007Sq-GQ
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 15:18:08 +0000
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id ff504f0b-d0b7-4ae7-b274-1c24d3cd0151;
 Fri, 23 Oct 2020 15:18:06 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 683DEB561DCB;
 Fri, 23 Oct 2020 18:18: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 x0ILTsZrmiNv; Fri, 23 Oct 2020 18:18:02 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 3D560B5625D5;
 Fri, 23 Oct 2020 18:18:02 +0300 (EEST)
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 aelUjYXjG9Xh; Fri, 23 Oct 2020 18:18:02 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id EB992B561DCB;
 Fri, 23 Oct 2020 18:18:01 +0300 (EEST)
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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kVypU-0007Sq-GQ
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 15:18:08 +0000
X-Inumbo-ID: ff504f0b-d0b7-4ae7-b274-1c24d3cd0151
Received: from mx.upb.ro (unknown [141.85.13.200])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id ff504f0b-d0b7-4ae7-b274-1c24d3cd0151;
	Fri, 23 Oct 2020 15:18:06 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 683DEB561DCB;
	Fri, 23 Oct 2020 18:18: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 x0ILTsZrmiNv; Fri, 23 Oct 2020 18:18:02 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 3D560B5625D5;
	Fri, 23 Oct 2020 18:18: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 aelUjYXjG9Xh; Fri, 23 Oct 2020 18:18:02 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id EB992B561DCB;
	Fri, 23 Oct 2020 18:18:01 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v4 06/12] plat/xen/drivers/net: Configure
 netfront tx queue
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-7-costin.lupu@cs.pub.ro>
 <0f8e24f0-0827-e1c7-6891-6e83193864ec@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <22a39f52-f2af-c77e-8672-4895002737d2@cs.pub.ro>
Date: Fri, 23 Oct 2020 18:18:01 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <0f8e24f0-0827-e1c7-6891-6e83193864ec@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

Hi Sharan,

Please see inline.

On 10/22/20 2:53 PM, Sharan Santhanam wrote:
> Hello Costin,
>=20
> Please find the comments inline:
>=20
> Thanks & Regards
>=20
> Sharan
>=20
> On 8/13/20 10:53 AM, Costin Lupu wrote:
>> For each queue, either rx or tx, the packets references are kept in a =
Xen
>> shared ring. This patch introduces the initialization of tx shared
>> ring. Each
>> time the driver will send a packet it will add a request on the tx
>> shared ring
>> which will be serviced by the backend. Therefore we need to keep track
>> of the
>> requests by keeping track of their IDs. Because our resources are
>> limited, we
>> will maintain a pool of IDs (see `freelist` array) for this purpose.
>>
>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
>> ---
>> =C2=A0 plat/xen/drivers/net/netfront.c | 108 +++++++++++++++++++++++++=
+++++++
>> =C2=A0 plat/xen/drivers/net/netfront.h |=C2=A0 30 +++++++++
>> =C2=A0 2 files changed, 138 insertions(+)
>>
>> diff --git a/plat/xen/drivers/net/netfront.c
>> b/plat/xen/drivers/net/netfront.c
>> index ddbb4b70..3c936743 100644
>> --- a/plat/xen/drivers/net/netfront.c
>> +++ b/plat/xen/drivers/net/netfront.c
>> @@ -33,10 +33,12 @@
>> =C2=A0=C2=A0 * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY=
.
>> =C2=A0=C2=A0 */
>> =C2=A0 +#include <string.h>
>> =C2=A0 #include <uk/assert.h>
>> =C2=A0 #include <uk/print.h>
>> =C2=A0 #include <uk/alloc.h>
>> =C2=A0 #include <uk/netdev_driver.h>
>> +#include <xen-x86/mm.h>
>> =C2=A0 #include <xenbus/xenbus.h>
>> =C2=A0 #include "netfront.h"
>> =C2=A0 #include "netfront_xb.h"
>> @@ -49,6 +51,83 @@
>> =C2=A0 =C2=A0 static struct uk_alloc *drv_allocator;
>> =C2=A0 +
>> +static void add_id_to_freelist(uint16_t id, uint16_t *freelist)
>> +{
>> +=C2=A0=C2=A0=C2=A0 freelist[id + 1] =3D freelist[0];
>> +=C2=A0=C2=A0=C2=A0 freelist[0]=C2=A0 =3D id;
>> +}
>> +
>> +static uint16_t get_id_from_freelist(uint16_t *freelist)
>> +{
>> +=C2=A0=C2=A0=C2=A0 uint16_t id;
>> +
>> +=C2=A0=C2=A0=C2=A0 id =3D freelist[0];
>> +=C2=A0=C2=A0=C2=A0 freelist[0] =3D freelist[id + 1];
>> +=C2=A0=C2=A0=C2=A0 return id;
>> +}
>> +
>> +static struct uk_netdev_tx_queue *netfront_txq_setup(struct uk_netdev
>> *n,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t queue_id,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t nb_desc __unused,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_txqueue_c=
onf *conf __unused)
>> +{
>> +=C2=A0=C2=A0=C2=A0 int rc;
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +=C2=A0=C2=A0=C2=A0 struct uk_netdev_tx_queue *txq;
>> +=C2=A0=C2=A0=C2=A0 netif_tx_sring_t *sring;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +=C2=A0=C2=A0=C2=A0 if (queue_id >=3D nfdev->max_queue_pairs) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Invalid queue i=
dentifier: %"__PRIu16"\n", queue_id);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ERR2PTR(-EINVAL);
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 txq=C2=A0 =3D &nfdev->txqs[queue_id];
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(!txq->initialized);
>> +=C2=A0=C2=A0=C2=A0 txq->netfront_dev =3D nfdev;
>> +=C2=A0=C2=A0=C2=A0 txq->lqueue_id =3D queue_id;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Setup shared ring */
>> +=C2=A0=C2=A0=C2=A0 sring =3D uk_palloc(drv_allocator, 1);
>=20
> Shouldn't the allocator from the txqueue_conf be used here while
>=20
> setting up the ring
>=20

I see, I wasn't aware of that.

>> +=C2=A0=C2=A0=C2=A0 if (!sring)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ERR2PTR(-ENOMEM);
>> +=C2=A0=C2=A0=C2=A0 memset(sring, 0, PAGE_SIZE);
>> +=C2=A0=C2=A0=C2=A0 SHARED_RING_INIT(sring);
>> +=C2=A0=C2=A0=C2=A0 FRONT_RING_INIT(&txq->ring, sring, PAGE_SIZE);
>> +=C2=A0=C2=A0=C2=A0 txq->ring_size =3D NET_TX_RING_SIZE;
>> +=C2=A0=C2=A0=C2=A0 txq->ring_ref =3D gnttab_grant_access(nfdev->xende=
v->otherend_id,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 virt_to_mfn(sring), 0);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(txq->ring_ref !=3D GRANT_INVALID_REF);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Setup event channel */
>> +=C2=A0=C2=A0=C2=A0 rc =3D evtchn_alloc_unbound(nfdev->xendev->otheren=
d_id,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NU=
LL, NULL,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &t=
xq->evtchn);
>> +=C2=A0=C2=A0=C2=A0 if (rc) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Error creating =
event channel: %d\n", rc);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gnttab_end_access(txq->rin=
g_ref);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pfree(drv_allocator, sr=
ing, 1);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ERR2PTR(-rc);
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 /* Events are always disabled for tx queue */
>> +=C2=A0=C2=A0=C2=A0 mask_evtchn(txq->evtchn);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Initialize list of request ids */
>> +=C2=A0=C2=A0=C2=A0 uk_semaphore_init(&txq->sem, NET_TX_RING_SIZE);
>> +=C2=A0=C2=A0=C2=A0 for (uint16_t i =3D 0; i < NET_TX_RING_SIZE; i++) =
{
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 add_id_to_freelist(i, txq-=
>freelist);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 txq->gref[i] =3D GRANT_INV=
ALID_REF;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 txq->initialized =3D true;
>> +=C2=A0=C2=A0=C2=A0 nfdev->txqs_num++;
>> +
>> +=C2=A0=C2=A0=C2=A0 return txq;
>> +}
>> +
>> =C2=A0 static int netfront_rxtx_alloc(struct netfront_dev *nfdev,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct uk=
_netdev_conf *conf)
>> =C2=A0 {
>> @@ -90,6 +169,33 @@ err_free_txrx:
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc;
>> =C2=A0 }
>> =C2=A0 +static int netfront_txq_info_get(struct uk_netdev *n,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t queue_id,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_queue_inf=
o *qinfo)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +=C2=A0=C2=A0=C2=A0 struct uk_netdev_tx_queue *txq;
>> +=C2=A0=C2=A0=C2=A0 int rc =3D 0;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(qinfo !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +=C2=A0=C2=A0=C2=A0 if (unlikely(queue_id >=3D nfdev->txqs_num)) {
>=20
> txqs_num is updated only after the queue is configured. The
>=20
> txq_info_get should be called before the txq_configure. This
>=20
> would provide the user of netdev the information needed to
>=20
> configure the txq.
>=20

Yeah, nfdev->max_queue_pairs should make more sense.

>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Invalid queue_i=
d %"__PRIu16"\n", queue_id);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D -EINVAL;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto exit;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 txq =3D &nfdev->txqs[queue_id];
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_min =3D txq->ring_size;
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_max =3D txq->ring_size;
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_align =3D PAGE_SIZE;
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_is_power_of_two =3D 1;
>> +
>> +exit:
>> +=C2=A0=C2=A0=C2=A0 return rc;
>> +}
>> +
>> =C2=A0 static int netfront_configure(struct uk_netdev *n,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct uk=
_netdev_conf *conf)
>> =C2=A0 {
>> @@ -179,6 +285,8 @@ static unsigned int netfront_promisc_get(struct
>> uk_netdev *n)
>> =C2=A0 =C2=A0 static const struct uk_netdev_ops netfront_ops =3D {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .configure =3D netfront_configure,
>> +=C2=A0=C2=A0=C2=A0 .txq_configure =3D netfront_txq_setup,
>> +=C2=A0=C2=A0=C2=A0 .txq_info_get =3D netfront_txq_info_get,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .info_get =3D netfront_info_get,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .einfo_get =3D netfront_einfo_get,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .hwaddr_get =3D netfront_mac_get,
>> diff --git a/plat/xen/drivers/net/netfront.h
>> b/plat/xen/drivers/net/netfront.h
>> index a811b092..d3f603b3 100644
>> --- a/plat/xen/drivers/net/netfront.h
>> +++ b/plat/xen/drivers/net/netfront.h
>> @@ -37,11 +37,40 @@
>> =C2=A0 #define __NETFRONT_H__
>> =C2=A0 =C2=A0 #include <uk/netdev.h>
>> +#include <uk/semaphore.h>
>> +#include <xen/io/netif.h>
>> +#include <common/gnttab.h>
>> +#include <common/events.h>
>> +
>> +
>> +#define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE)
>> =C2=A0 =C2=A0 /**
>> =C2=A0=C2=A0 * internal structure to represent the transmit queue.
>> =C2=A0=C2=A0 */
>> =C2=A0 struct uk_netdev_tx_queue {
>> +=C2=A0=C2=A0=C2=A0 /* The netfront device */
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *netfront_dev;
>> +=C2=A0=C2=A0=C2=A0 /* The libuknet queue identifier */
>> +=C2=A0=C2=A0=C2=A0 uint16_t lqueue_id;
>> +=C2=A0=C2=A0=C2=A0 /* True if initialized */
>> +=C2=A0=C2=A0=C2=A0 bool initialized;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Shared ring size */
>> +=C2=A0=C2=A0=C2=A0 uint16_t ring_size;
>> +=C2=A0=C2=A0=C2=A0 /* Shared ring */
>> +=C2=A0=C2=A0=C2=A0 netif_tx_front_ring_t ring;
>> +=C2=A0=C2=A0=C2=A0 /* Shared ring grant ref */
>> +=C2=A0=C2=A0=C2=A0 grant_ref_t ring_ref;
>> +=C2=A0=C2=A0=C2=A0 /* Queue event channel */
>> +=C2=A0=C2=A0=C2=A0 evtchn_port_t evtchn;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Free list protecting semaphore */
>> +=C2=A0=C2=A0=C2=A0 struct uk_semaphore sem;
>> +=C2=A0=C2=A0=C2=A0 /* Free list of transmitting request IDs */
>> +=C2=A0=C2=A0=C2=A0 uint16_t freelist[NET_TX_RING_SIZE + 1];
>> +=C2=A0=C2=A0=C2=A0 /* Grants for transmit buffers */
>> +=C2=A0=C2=A0=C2=A0 grant_ref_t gref[NET_TX_RING_SIZE];
>> =C2=A0 };
>> =C2=A0 =C2=A0 /**
>> @@ -63,6 +92,7 @@ struct netfront_dev {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev netdev;
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* List of the Rx/Tx queues */
>> +=C2=A0=C2=A0=C2=A0 uint16_t txqs_num;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_tx_queue *txqs;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_rx_queue *rxqs;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Maximum number of queue pairs */
>=20


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 15:24:10 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 15:24:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.11082.29361 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVyvI-0008Sq-Px; Fri, 23 Oct 2020 15:24:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 11082.29361; Fri, 23 Oct 2020 15:24:08 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVyvI-0008Sj-Mc; Fri, 23 Oct 2020 15:24:08 +0000
Received: by outflank-mailman (input) for mailman id 11082;
 Fri, 23 Oct 2020 15:24:07 +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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kVyvH-0008S0-6i
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 15:24:07 +0000
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 76a4e79b-3cfe-4dde-bc74-124587eb1eee;
 Fri, 23 Oct 2020 15:24:06 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 3D9F9B561DCB;
 Fri, 23 Oct 2020 18:24: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 5sLc7x5XjaL4; Fri, 23 Oct 2020 18:24:00 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 5896EB561E50;
 Fri, 23 Oct 2020 18:24:00 +0300 (EEST)
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 32E-tAHEPDBT; Fri, 23 Oct 2020 18:24:00 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id 016DDB561DCB;
 Fri, 23 Oct 2020 18:23:59 +0300 (EEST)
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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kVyvH-0008S0-6i
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 15:24:07 +0000
X-Inumbo-ID: 76a4e79b-3cfe-4dde-bc74-124587eb1eee
Received: from mx.upb.ro (unknown [141.85.13.200])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 76a4e79b-3cfe-4dde-bc74-124587eb1eee;
	Fri, 23 Oct 2020 15:24:06 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 3D9F9B561DCB;
	Fri, 23 Oct 2020 18:24: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 5sLc7x5XjaL4; Fri, 23 Oct 2020 18:24:00 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 5896EB561E50;
	Fri, 23 Oct 2020 18:24:00 +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 32E-tAHEPDBT; Fri, 23 Oct 2020 18:24:00 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id 016DDB561DCB;
	Fri, 23 Oct 2020 18:23:59 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v4 07/12] plat/xen/drivers/net: Configure
 netfront rx queue
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-8-costin.lupu@cs.pub.ro>
 <6902b9b4-7797-3106-09a8-f445be78faa0@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <8941f127-520d-73eb-dad9-1ba0b4e61b3f@cs.pub.ro>
Date: Fri, 23 Oct 2020 18:23:59 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <6902b9b4-7797-3106-09a8-f445be78faa0@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

Hi Sharan,

Please see inline.

On 10/22/20 4:33 PM, Sharan Santhanam wrote:
> Hello Costin,
>=20
> Please find the comment inline:
>=20
> Thanks & Regards
>=20
> Sharan
>=20
> On 8/13/20 10:53 AM, Costin Lupu wrote:
>> Incoming packets are saved in buffers allocated with user-provided
>> callbacks.
>> Whenever such packet is available, the driver is notified via event
>> channels.
>> This patch introduces the configuration logic for rx queues and the
>> handler
>> used in dealing with the notifications.
>>
>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
>> ---
>> =C2=A0 plat/xen/drivers/net/netfront.c | 212 +++++++++++++++++++++++++=
+++++--
>> =C2=A0 plat/xen/drivers/net/netfront.h |=C2=A0 29 +++++
>> =C2=A0 2 files changed, 232 insertions(+), 9 deletions(-)
>>
>> diff --git a/plat/xen/drivers/net/netfront.c
>> b/plat/xen/drivers/net/netfront.c
>> index 3c936743..742e05cf 100644
>> --- a/plat/xen/drivers/net/netfront.c
>> +++ b/plat/xen/drivers/net/netfront.c
>> @@ -52,6 +52,11 @@
>> =C2=A0 static struct uk_alloc *drv_allocator;
>> =C2=A0 =C2=A0 +static uint16_t xennet_rxidx(RING_IDX idx)
>> +{
>> +=C2=A0=C2=A0=C2=A0 return (uint16_t) (idx & (NET_RX_RING_SIZE - 1));
>> +}
>> +
>> =C2=A0 static void add_id_to_freelist(uint16_t id, uint16_t *freelist)
>> =C2=A0 {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 freelist[id + 1] =3D freelist[0];
>> @@ -67,6 +72,82 @@ static uint16_t get_id_from_freelist(uint16_t
>> *freelist)
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return id;
>> =C2=A0 }
>> =C2=A0 +static int netfront_rxq_enqueue(struct uk_netdev_rx_queue *rxq=
,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netbuf *netbuf)
>> +{
>> +=C2=A0=C2=A0=C2=A0 RING_IDX req_prod;
>> +=C2=A0=C2=A0=C2=A0 uint16_t id;
>> +=C2=A0=C2=A0=C2=A0 netif_rx_request_t *rx_req;
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +=C2=A0=C2=A0=C2=A0 int notify;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* buffer must be page aligned */
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(((unsigned long) netbuf->data & ~PAGE_MA=
SK) =3D=3D 0);
>> +
>> +=C2=A0=C2=A0=C2=A0 if (RING_FULL(&rxq->ring)) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_debug("rx queue is f=
ull\n");
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -ENOSPC;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 /* get request */
>> +=C2=A0=C2=A0=C2=A0 req_prod =3D rxq->ring.req_prod_pvt;
>> +=C2=A0=C2=A0=C2=A0 id =3D xennet_rxidx(req_prod);
>> +=C2=A0=C2=A0=C2=A0 rx_req =3D RING_GET_REQUEST(&rxq->ring, req_prod);
>> +=C2=A0=C2=A0=C2=A0 rx_req->id =3D id;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* save buffer */
>> +=C2=A0=C2=A0=C2=A0 rxq->netbuf[id] =3D netbuf;
>> +=C2=A0=C2=A0=C2=A0 /* setup grant for buffer data */
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D rxq->netfront_dev;
>> +=C2=A0=C2=A0=C2=A0 rxq->gref[id] =3D rx_req->gref =3D
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gnttab_grant_access(nfdev-=
>xendev->otherend_id,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vi=
rt_to_mfn(netbuf->data), 0);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(rx_req->gref !=3D GRANT_INVALID_REF);
>> +
>> +=C2=A0=C2=A0=C2=A0 wmb(); /* Ensure backend sees requests */
>> +=C2=A0=C2=A0=C2=A0 rxq->ring.req_prod_pvt =3D req_prod + 1;
>> +
>> +=C2=A0=C2=A0=C2=A0 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&rxq->ring, no=
tify);
>> +=C2=A0=C2=A0=C2=A0 if (notify)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 notify_remote_via_evtchn(r=
xq->evtchn);
>> +
>> +=C2=A0=C2=A0=C2=A0 return 0;
>> +}
>> +
>> +static int netfront_rx_fillup(struct uk_netdev_rx_queue *rxq,
>> uint16_t nb_desc)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct uk_netbuf *netbuf[nb_desc];
>> +=C2=A0=C2=A0=C2=A0 int rc, status =3D 0;
>> +=C2=A0=C2=A0=C2=A0 uint16_t cnt;
>> +
>> +=C2=A0=C2=A0=C2=A0 cnt =3D rxq->alloc_rxpkts(rxq->alloc_rxpkts_argp, =
netbuf, nb_desc);
>> +
>> +=C2=A0=C2=A0=C2=A0 for (uint16_t i =3D 0; i < cnt; i++) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D netfront_rxq_enqueu=
e(rxq, netbuf[i]);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (unlikely(rc < 0)) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk=
_pr_err("Failed to add a buffer to rx queue %p: %d\n",
>> +=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 rxq, rc);
>> +
>> +=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=C2=A0=C2=
=A0 * Release netbufs that we are not going
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 * to use anymore
>> +=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=C2=A0=C2=A0 fo=
r (uint16_t j =3D i; j < cnt; j++)
>> +=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 uk_netbuf_free(netbuf[j]);
>> +
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 st=
atus |=3D UK_NETDEV_STATUS_UNDERRUN;
>> +
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 go=
to out;
>> +=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 if (unlikely(cnt < nb_desc))
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 status |=3D UK_NETDEV_STAT=
US_UNDERRUN;
>> +
>> +out:
>> +=C2=A0=C2=A0=C2=A0 return status;
>> +}
>> +
>> =C2=A0 static struct uk_netdev_tx_queue *netfront_txq_setup(struct
>> uk_netdev *n,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t queue_=
id,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t nb_des=
c __unused,
>> @@ -103,15 +184,19 @@ static struct uk_netdev_tx_queue
>> *netfront_txq_setup(struct uk_netdev *n,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 UK_ASSERT(txq->ring_ref !=3D GRANT_INVA=
LID_REF);
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Setup event channel */
>> -=C2=A0=C2=A0=C2=A0 rc =3D evtchn_alloc_unbound(nfdev->xendev->otheren=
d_id,
>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NU=
LL, NULL,
>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &t=
xq->evtchn);
>> -=C2=A0=C2=A0=C2=A0 if (rc) {
>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Error creating =
event channel: %d\n", rc);
>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gnttab_end_access(txq->rin=
g_ref);
>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pfree(drv_allocator, sr=
ing, 1);
>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ERR2PTR(-rc);
>> -=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 if (nfdev->split_evtchn || !nfdev->rxqs[queue_id].=
initialized) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D evtchn_alloc_unboun=
d(nfdev->xendev->otherend_id,
>> +=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 NULL, NULL,
>> +=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 &txq->evtchn);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk=
_pr_err("Error creating event channel: %d\n", rc);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gn=
ttab_end_access(txq->ring_ref);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk=
_pfree(drv_allocator, sring, 1);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re=
turn ERR2PTR(rc);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 } else
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 txq->evtchn =3D nfdev->rxq=
s[queue_id].evtchn;
>=20
> In the next version maybe this can go to the previous patch.
>=20

Well actually this cannot be moved in the previous patch because we
don't have the definitions for the rx queue structure there.

>=20
>> +
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Events are always disabled for tx qu=
eue */
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mask_evtchn(txq->evtchn);
>> =C2=A0 @@ -128,6 +213,86 @@ static struct uk_netdev_tx_queue
>> *netfront_txq_setup(struct uk_netdev *n,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return txq;
>> =C2=A0 }
>> =C2=A0 +static void netfront_handler(evtchn_port_t port __unused,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct __regs *regs __unus=
ed, void *arg)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct uk_netdev_rx_queue *rxq =3D arg;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Indicate to the network stack about an event */
>> +=C2=A0=C2=A0=C2=A0 uk_netdev_drv_rx_event(&rxq->netfront_dev->netdev,=
 rxq->lqueue_id);
>> +}
>> +
>> +static struct uk_netdev_rx_queue *netfront_rxq_setup(struct uk_netdev
>> *n,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t queue_id,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t nb_desc __unused,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_rxqueue_c=
onf *conf)
>> +{
>> +=C2=A0=C2=A0=C2=A0 int rc;
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +=C2=A0=C2=A0=C2=A0 struct uk_netdev_rx_queue *rxq;
>> +=C2=A0=C2=A0=C2=A0 netif_rx_sring_t *sring;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(conf !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +=C2=A0=C2=A0=C2=A0 if (queue_id >=3D nfdev->max_queue_pairs) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Invalid queue i=
dentifier: %"__PRIu16"\n", queue_id);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ERR2PTR(-EINVAL);
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 rxq =3D &nfdev->rxqs[queue_id];
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(!rxq->initialized);
>> +=C2=A0=C2=A0=C2=A0 rxq->netfront_dev =3D nfdev;
>> +=C2=A0=C2=A0=C2=A0 rxq->lqueue_id =3D queue_id;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Setup shared ring */
>> +=C2=A0=C2=A0=C2=A0 sring =3D uk_palloc(drv_allocator, 1);
> Allocator from the conf should be used here.

Ack.

>> +=C2=A0=C2=A0=C2=A0 if (!sring)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ERR2PTR(-ENOMEM);
>> +=C2=A0=C2=A0=C2=A0 memset(sring, 0, PAGE_SIZE);
>> +=C2=A0=C2=A0=C2=A0 SHARED_RING_INIT(sring);
>> +=C2=A0=C2=A0=C2=A0 FRONT_RING_INIT(&rxq->ring, sring, PAGE_SIZE);
>> +=C2=A0=C2=A0=C2=A0 rxq->ring_size =3D NET_RX_RING_SIZE;
>> +=C2=A0=C2=A0=C2=A0 rxq->ring_ref =3D gnttab_grant_access(nfdev->xende=
v->otherend_id,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 virt_to_mfn(sring), 0);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(rxq->ring_ref !=3D GRANT_INVALID_REF);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Setup event channel */
>> +=C2=A0=C2=A0=C2=A0 if (nfdev->split_evtchn || !nfdev->txqs[queue_id].=
initialized) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D evtchn_alloc_unboun=
d(nfdev->xendev->otherend_id,
>> +=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 netfront_handler, rxq,
>> +=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 &rxq->evtchn);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk=
_pr_err("Error creating event channel: %d\n", rc);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gn=
ttab_end_access(rxq->ring_ref);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk=
_pfree(drv_allocator, sring, 1);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re=
turn ERR2PTR(rc);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 } else {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rxq->evtchn =3D nfdev->txq=
s[queue_id].evtchn;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* overwriting event handl=
er */
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bind_evtchn(rxq->evtchn, n=
etfront_handler, rxq);
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 /*
>> +=C2=A0=C2=A0=C2=A0=C2=A0 * By default, events are disabled and it is =
up to the user or
>> +=C2=A0=C2=A0=C2=A0=C2=A0 * network stack to explicitly enable them.
>> +=C2=A0=C2=A0=C2=A0=C2=A0 */
>> +=C2=A0=C2=A0=C2=A0 mask_evtchn(rxq->evtchn);
>> +=C2=A0=C2=A0=C2=A0 rxq->intr_enabled =3D 0;
>> +
>> +=C2=A0=C2=A0=C2=A0 rxq->alloc_rxpkts =3D conf->alloc_rxpkts;
>> +=C2=A0=C2=A0=C2=A0 rxq->alloc_rxpkts_argp =3D conf->alloc_rxpkts_argp=
;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Allocate receive buffers for this queue */
>> +=C2=A0=C2=A0=C2=A0 netfront_rx_fillup(rxq, rxq->ring_size);
>> +
>> +=C2=A0=C2=A0=C2=A0 rxq->initialized =3D true;
>> +=C2=A0=C2=A0=C2=A0 nfdev->rxqs_num++;
>> +
>> +=C2=A0=C2=A0=C2=A0 return rxq;
>> +}
>> +
>> =C2=A0 static int netfront_rxtx_alloc(struct netfront_dev *nfdev,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct uk=
_netdev_conf *conf)
>> =C2=A0 {
>> @@ -196,6 +361,33 @@ exit:
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return rc;
>> =C2=A0 }
>> =C2=A0 +static int netfront_rxq_info_get(struct uk_netdev *n,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t queue_id,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_queue_inf=
o *qinfo)
>> +{
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>> +=C2=A0=C2=A0=C2=A0 struct uk_netdev_rx_queue *rxq;
>> +=C2=A0=C2=A0=C2=A0 int rc =3D 0;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(qinfo !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>> +=C2=A0=C2=A0=C2=A0 if (unlikely(queue_id >=3D nfdev->rxqs_num)) {
> Same as the txq info get

Ack.

>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uk_pr_err("Invalid queue i=
d: %"__PRIu16"\n", queue_id);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D -EINVAL;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto exit;
>> +=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 rxq =3D &nfdev->rxqs[queue_id];
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_min =3D rxq->ring_size;
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_max =3D rxq->ring_size;
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_align =3D PAGE_SIZE;
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_is_power_of_two =3D 1;
>> +
>> +exit:
>> +=C2=A0=C2=A0=C2=A0 return rc;
>> +}
>> +
>> =C2=A0 static int netfront_configure(struct uk_netdev *n,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct uk=
_netdev_conf *conf)
>> =C2=A0 {
>> @@ -286,7 +478,9 @@ static unsigned int netfront_promisc_get(struct
>> uk_netdev *n)
>> =C2=A0 static const struct uk_netdev_ops netfront_ops =3D {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .configure =3D netfront_configure,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .txq_configure =3D netfront_txq_setup,
>> +=C2=A0=C2=A0=C2=A0 .rxq_configure =3D netfront_rxq_setup,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .txq_info_get =3D netfront_txq_info_get=
,
>> +=C2=A0=C2=A0=C2=A0 .rxq_info_get =3D netfront_rxq_info_get,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .info_get =3D netfront_info_get,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .einfo_get =3D netfront_einfo_get,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .hwaddr_get =3D netfront_mac_get,
>> diff --git a/plat/xen/drivers/net/netfront.h
>> b/plat/xen/drivers/net/netfront.h
>> index d3f603b3..c8364815 100644
>> --- a/plat/xen/drivers/net/netfront.h
>> +++ b/plat/xen/drivers/net/netfront.h
>> @@ -44,6 +44,7 @@
>> =C2=A0 =C2=A0 =C2=A0 #define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_=
tx, PAGE_SIZE)
>> +#define NET_RX_RING_SIZE __CONST_RING_SIZE(netif_rx, PAGE_SIZE)
>> =C2=A0 =C2=A0 /**
>> =C2=A0=C2=A0 * internal structure to represent the transmit queue.
>> @@ -77,6 +78,33 @@ struct uk_netdev_tx_queue {
>> =C2=A0=C2=A0 * internal structure to represent the receive queue.
>> =C2=A0=C2=A0 */
>> =C2=A0 struct uk_netdev_rx_queue {
>> +=C2=A0=C2=A0=C2=A0 /* The netfront device */
>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *netfront_dev;
>> +=C2=A0=C2=A0=C2=A0 /* The libuknet queue identifier */
>> +=C2=A0=C2=A0=C2=A0 uint16_t lqueue_id;
>> +=C2=A0=C2=A0=C2=A0 /* True if initialized */
>> +=C2=A0=C2=A0=C2=A0 bool initialized;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Shared ring size */
>> +=C2=A0=C2=A0=C2=A0 uint16_t ring_size;
>> +=C2=A0=C2=A0=C2=A0 /* Shared ring */
>> +=C2=A0=C2=A0=C2=A0 netif_rx_front_ring_t ring;
>> +=C2=A0=C2=A0=C2=A0 /* Shared ring grant ref */
>> +=C2=A0=C2=A0=C2=A0 grant_ref_t ring_ref;
>> +=C2=A0=C2=A0=C2=A0 /* Queue event channel */
>> +=C2=A0=C2=A0=C2=A0 evtchn_port_t evtchn;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* The flag to interrupt on the transmit queue */
>> +=C2=A0=C2=A0=C2=A0 uint8_t intr_enabled;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* User-provided receive buffer allocation functio=
n */
>> +=C2=A0=C2=A0=C2=A0 uk_netdev_alloc_rxpkts alloc_rxpkts;
>> +=C2=A0=C2=A0=C2=A0 void *alloc_rxpkts_argp;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Receive buffers for incoming packets */
>> +=C2=A0=C2=A0=C2=A0 struct uk_netbuf *netbuf[NET_RX_RING_SIZE];
>> +=C2=A0=C2=A0=C2=A0 /* Grants for receive buffers */
>> +=C2=A0=C2=A0=C2=A0 grant_ref_t gref[NET_RX_RING_SIZE];
>> =C2=A0 };
>> =C2=A0 =C2=A0 struct xs_econf {
>> @@ -93,6 +121,7 @@ struct netfront_dev {
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* List of the Rx/Tx queues */
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t txqs_num;
>> +=C2=A0=C2=A0=C2=A0 uint16_t rxqs_num;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_tx_queue *txqs;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_rx_queue *rxqs;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Maximum number of queue pairs */
>=20


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 15:55:09 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 15:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.11131.29509 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVzPI-0004HF-5M; Fri, 23 Oct 2020 15:55:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 11131.29509; Fri, 23 Oct 2020 15:55:08 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVzPI-0004H8-2B; Fri, 23 Oct 2020 15:55:08 +0000
Received: by outflank-mailman (input) for mailman id 11131;
 Fri, 23 Oct 2020 15:55: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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kVzPG-0004H3-Lh
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 15:55:06 +0000
Received: from mx.upb.ro (unknown [141.85.13.220])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id cf69f969-e5a5-4efd-ad04-6a5f25f1bac8;
 Fri, 23 Oct 2020 15:55:05 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id D41ACB5625D5;
 Fri, 23 Oct 2020 18:55:03 +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 Wu19QSRIOgLX; Fri, 23 Oct 2020 18:54:59 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 9CF7DB561E2D;
 Fri, 23 Oct 2020 18:54:59 +0300 (EEST)
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 ixaD81EHP-6T; Fri, 23 Oct 2020 18:54:59 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id 20A30B561DCB;
 Fri, 23 Oct 2020 18:54:59 +0300 (EEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kVzPG-0004H3-Lh
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 15:55:06 +0000
X-Inumbo-ID: cf69f969-e5a5-4efd-ad04-6a5f25f1bac8
Received: from mx.upb.ro (unknown [141.85.13.220])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id cf69f969-e5a5-4efd-ad04-6a5f25f1bac8;
	Fri, 23 Oct 2020 15:55:05 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id D41ACB5625D5;
	Fri, 23 Oct 2020 18:55:03 +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 Wu19QSRIOgLX; Fri, 23 Oct 2020 18:54:59 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 9CF7DB561E2D;
	Fri, 23 Oct 2020 18:54:59 +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 ixaD81EHP-6T; Fri, 23 Oct 2020 18:54:59 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id 20A30B561DCB;
	Fri, 23 Oct 2020 18:54:59 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v4 10/12] plat/xen/drivers/net: Add transmit
 operation
To: Sharan Santhanam <sharan.santhanam@neclab.eu>,
 Simon Kuenzer <simon.kuenzer@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-11-costin.lupu@cs.pub.ro>
 <494d8796-a3e0-a3d5-df36-6343df10d571@neclab.eu>
 <c71f09f9-79b7-816f-bced-a190ed6665fc@cs.pub.ro>
 <726dd84d-33cb-877f-3e22-a5d92870ac35@neclab.eu>
 <06f26c34-1a23-6fae-d5ba-46b4b49dfc13@cs.pub.ro>
 <a106f115-336c-d97c-f441-f130633c4c53@neclab.eu>
 <86653183-2b07-4d26-83fc-53dcd265f31a@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <1b789288-6f5c-2af2-8723-9e04787fc305@cs.pub.ro>
Date: Fri, 23 Oct 2020 18:54:58 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <86653183-2b07-4d26-83fc-53dcd265f31a@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

Hi Sharan,

Please see inline.

On 10/22/20 4:38 PM, Sharan Santhanam wrote:
> Hello Costin,
>=20
> Please find the review comments inline:
>=20
> Thanks & Regards
>=20
> Sharan
>=20
> On 8/21/20 3:04 PM, Simon Kuenzer wrote:
>> On 21.08.20 13:24, Costin Lupu wrote:
>>> On 8/21/20 1:49 PM, Simon Kuenzer wrote:
>>>> On 21.08.20 11:32, Costin Lupu wrote:
>>>>> On 8/20/20 6:49 PM, Simon Kuenzer wrote:
>>>>>> On 13.08.20 10:53, Costin Lupu wrote:
>>>>>>> Whenever a packet is transmitted, the request describing it is
>>>>>>> written
>>>>>>> in the
>>>>>>> shared ring. The packet itself is written in a page referenced by
>>>>>>> the
>>>>>>> request
>>>>>>> and shared, as well, with the backend. At the end of each transmi=
t
>>>>>>> operation, a
>>>>>>> cleanup operation is performed free'ing the resources allocated
>>>>>>> for the
>>>>>>> previously transmitted packets.
>>>>>>>
>>>>>>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>>>>>>> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
>>>>>>> ---
>>>>>>> =C2=A0=C2=A0=C2=A0 plat/xen/drivers/net/netfront.c | 102
>>>>>>> ++++++++++++++++++++++++++++++++
>>>>>>> =C2=A0=C2=A0=C2=A0 1 file changed, 102 insertions(+)
>>>>>>>
>>>>>>> diff --git a/plat/xen/drivers/net/netfront.c
>>>>>>> b/plat/xen/drivers/net/netfront.c
>>>>>>> index 858d124a..f2b81329 100644
>>>>>>> --- a/plat/xen/drivers/net/netfront.c
>>>>>>> +++ b/plat/xen/drivers/net/netfront.c
>>>>>>> @@ -39,6 +39,7 @@
>>>>>>> =C2=A0=C2=A0=C2=A0 #include <uk/alloc.h>
>>>>>>> =C2=A0=C2=A0=C2=A0 #include <uk/netdev_driver.h>
>>>>>>> =C2=A0=C2=A0=C2=A0 #include <xen-x86/mm.h>
>>>>>>> +#include <xen-x86/irq.h>
>>>>>>> =C2=A0=C2=A0=C2=A0 #include <xenbus/xenbus.h>
>>>>>>> =C2=A0=C2=A0=C2=A0 #include "netfront.h"
>>>>>>> =C2=A0=C2=A0=C2=A0 #include "netfront_xb.h"
>>>>>>> @@ -78,6 +79,106 @@ static uint16_t get_id_from_freelist(uint16_t
>>>>>>> *freelist)
>>>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return id;
>>>>>>> =C2=A0=C2=A0=C2=A0 }
>>>>>>> =C2=A0=C2=A0=C2=A0 +static int network_tx_buf_gc(struct uk_netdev=
_tx_queue *txq)
>>>>>>> +{
>>>>>>> +=C2=A0=C2=A0=C2=A0 RING_IDX prod, cons;
>>>>>>> +=C2=A0=C2=A0=C2=A0 netif_tx_response_t *tx_rsp;
>>>>>>> +=C2=A0=C2=A0=C2=A0 uint16_t id;
>>>>>>> +=C2=A0=C2=A0=C2=A0 bool more_to_do;
>>>>>>> +=C2=A0=C2=A0=C2=A0 int count =3D 0;
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 do {
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prod =3D txq->ring.sr=
ing->rsp_prod;
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rmb(); /* Ensure we s=
ee responses up to 'rp'. */
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (cons =3D txq->ri=
ng.rsp_cons; cons !=3D prod; cons++) {
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 tx_rsp =3D RING_GET_RESPONSE(&txq->ring, cons);
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 if (tx_rsp->status =3D=3D NETIF_RSP_NULL)
>>>>>>> +=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 continue;
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 if (tx_rsp->status =3D=3D NETIF_RSP_ERROR)
>>>>>>> +=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 uk_pr_err("packet error\n");
>>>>>>
>>>>>> "netdev%u: Transmission error on txq %u\n" ?
>>>>>>
>>>>>
>>>>> Ack.
>>>>>
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 id=C2=A0 =3D tx_rsp->id;
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 UK_ASSERT(id < NET_TX_RING_SIZE);
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 gnttab_end_access(txq->gref[id]);
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 txq->gref[id] =3D GRANT_INVALID_REF;
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 add_id_to_freelist(id, txq->freelist);
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 uk_semaphore_up(&txq->sem);
> Shouldn't we free up the netbuf we receive from the ring?

Yeah, I wasn't aware of that either. In minios the tx buffers are reused
and therefore never freed.

For the next version I follow the approach in virtio net driver and keep
a reference to the netbuf in order to free it here.

>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 count++;
>>>>>>> +=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 txq->ring.rsp_cons =3D=
 prod;
>>>>>>> +
>>>>>>> + RING_FINAL_CHECK_FOR_RESPONSES(&txq->ring, more_to_do);
>>>>>>> +=C2=A0=C2=A0=C2=A0 } while (more_to_do);
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 return count;
>>>>>>> +}
>>>>>>> +
>>>>>>> +static int netfront_xmit(struct uk_netdev *n,
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_tx_q=
ueue *txq,
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netbuf *pkt=
)
>>>>>>> +{
>>>>>>> +=C2=A0=C2=A0=C2=A0 struct netfront_dev *nfdev;
>>>>>>> +=C2=A0=C2=A0=C2=A0 unsigned long flags;
>>>>>>> +=C2=A0=C2=A0=C2=A0 uint16_t id;
>>>>>>> +=C2=A0=C2=A0=C2=A0 RING_IDX req_prod;
>>>>>>> +=C2=A0=C2=A0=C2=A0 netif_tx_request_t *tx_req;
>>>>>>> +=C2=A0=C2=A0=C2=A0 int notify;
>>>>>>> +=C2=A0=C2=A0=C2=A0 int status =3D 0, count;
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>>>>>>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(txq !=3D NULL);
>>>>>>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(pkt !=3D NULL);
>>>>>>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(pkt->len < PAGE_SIZE);
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 nfdev =3D to_netfront_dev(n);
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 /* get request id */
>>>>>>> +=C2=A0=C2=A0=C2=A0 uk_semaphore_down(&txq->sem);
>>>>>>> +=C2=A0=C2=A0=C2=A0 local_irq_save(flags);
>>>>>>> +=C2=A0=C2=A0=C2=A0 id =3D get_id_from_freelist(txq->freelist);
>>>>>>
>>>>>> What happens when we are out of space and the ring is full?
>>>>>> The xmit function should be non-blocking so that we can use it in
>>>>>> polling mode. We should return in such a case that the transmissio=
n
>>>>>> queue is currently full...
>>>>>>
>>>>>
>>>>> Ack.
>>>>>
>>>>>>> +=C2=A0=C2=A0=C2=A0 local_irq_restore(flags);
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 /* get request */
>>>>>>> +=C2=A0=C2=A0=C2=A0 req_prod =3D txq->ring.req_prod_pvt;
>>>>>>> +=C2=A0=C2=A0=C2=A0 tx_req =3D RING_GET_REQUEST(&txq->ring, req_p=
rod); > +
>>>>>>> +=C2=A0=C2=A0=C2=A0 /* setup grant for buffer data */
>>>>>>> +=C2=A0=C2=A0=C2=A0 txq->gref[id] =3D tx_req->gref =3D
>>>>>>> + gnttab_grant_access(nfdev->xendev->otherend_id,
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 virt_to_mfn(pkt->data), 1);
>>>>>>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(tx_req->gref !=3D GRANT_INVALID_REF=
);
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 tx_req->offset =3D 0;
>>>>>>> +=C2=A0=C2=A0=C2=A0 tx_req->size =3D (uint16_t) pkt->len;
>>>>>>> +=C2=A0=C2=A0=C2=A0 tx_req->flags =3D 0;
>>>>>>> +=C2=A0=C2=A0=C2=A0 tx_req->id =3D id;
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 txq->ring.req_prod_pvt =3D req_prod + 1;
>>>>>>> +=C2=A0=C2=A0=C2=A0 wmb(); /* Ensure backend sees requests */
>>>>>>> +
>>>>>>> + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&txq->ring, notify);
>>>>>>> +=C2=A0=C2=A0=C2=A0 if (notify)
>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 notify_remote_via_evt=
chn(txq->evtchn); > +
>>>>>>> +=C2=A0=C2=A0=C2=A0 status |=3D UK_NETDEV_STATUS_SUCCESS;
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 /* some cleanup */
>>>>>>> +=C2=A0=C2=A0=C2=A0 local_irq_save(flags);
>>>>>>> +=C2=A0=C2=A0=C2=A0 count =3D network_tx_buf_gc(txq);
>>>>>>
>>>>>> The clean-up should happen before enqueuing the given packet to th=
e
>>>>>> transmit queue, it is the first thing of xmit(). Since we anyway
>>>>>> need to
>>>>>> do it and we do not have an advantage by delaying this operation.
>>>>>
>>>>> Of course there is an advantage. You push the packets in order for
>>>>> them
>>>>> to be processed ASAP by the backend and deal with cleaning up
>>>>> afterwards. It's a kind of parallelization. Otherwise you would del=
ay
>>>>> the transmissions.
>>>>>
>>>>>> We can also deal much better with full rings. Otherwise we
>>>>>> unnecessarily drop a packets for transmission although there would
>>>>>> have been space when clean-up finished. After calling cleaning you
>>>>>> can check if there is space on the ring and return if we run out o=
f
>>>>>> it (use an `unlikely` to the condition so that we speed up the
>>>>>> successful sending case).
>>>>>>
>>>>>
>>>>> The only scenario when this would solve anything would be when you
>>>>> have
>>>>> the ring full and just before you decide to send a new packet the
>>>>> backend starts processing your previous transmitted packets,
>>>>> leaving you
>>>>> at least one free slot. There are 2 unlikely events here: first, th=
e
>>>>> ring is full, and second, the backend starts to process again when =
the
>>>>> ring gets full (for the latter event, it's unlikely that the backen=
d
>>>>> will wake up given that it couldn't process 256 transmitted packets=
,
>>>>> where 256 is the current number of slots). And for this very unlike=
ly
>>>>> context you would introduce a delay for all the transmissions if we
>>>>> followed your suggestion.
>>>>>
>>>>> Anyway, both Linux and FreeBSD do the cleanup after pushing the
>>>>> requests, so I don't think we have much more to say about this.
>>>>>
>>>>
>>>> Hum... I double-checked with Intel DPDK's ixgbe (10 Gig) driver:
>>>>
>>>> http://git.dpdk.org/dpdk-stable/tree/drivers/net/ixgbe/ixgbe_rxtx.c?=
h=3D20.02#n230
>>>>
>>>>
>>>>
>>>> They clean the slots before sending. I derived my conclusion from
>>>> there.
>>>> However I noticed now that there is one minor difference: They do
>>>> both -
>>>> cleanup and enqueuing - before they notify the card about changes on
>>>> the
>>>> ring. In that case it does not add any delay if you swap the order o=
f
>>>> cleanup and enqueuing. In your case this is probably different becau=
se
>>>> you can cleanup without notifying. Here, I agree with you that we ad=
d
>>>> unnecessary xmit delays by swapping the order.
>>>>
>>>
>>> ixgbe is a native driver, so there is no backend driver in that case.
>>> It's a different scenario.
>>
>> You could consider the card itself as a backend driver, but fine.
>> There is a ABI difference between ixgbe and netback.
>>
>>>
>>>> However and in general, having a full ring is not an uncommon and
>>>> unlikely case. To my experience, this can already happen with a sing=
le
>>>> TCP connection if your network stack is feeding next packets fast
>>>> enough
>>>> and if the current TCP window allows to send them. It also depends o=
n
>>>> when the driver domain is scheduled; on which CPU core your netfront
>>>> domain and the driver domain sit; and even on the underlying physica=
l
>>>> device that might be busy with other traffic.
>>>>
>>>
>>> What I tried to say with the events probabilities explanation is that
>>> you add delay for the common case in order to remove delay for the mu=
ch
>>> less probable corner case.
>>
>> I got that and agreed.
>>
>>>
>>>> Another thing we are having in mind for uknetdev - and this is proba=
bly
>>>> different to Linux/BSD's implementation - we plan to change the xmit
>>>> function to do batching (as DPDK does). Sharan could push virtio-net
>>>> performance further with this. You are able to reduce the number of
>>>> notifies to the backend because you enqueue multiple packets at once
>>>> and
>>>> due to locality of batching you can utilize CPU caches ways better.
>>>>
>>>> What about this idea for netfront: We could do first a check for
>>>> available space and - if needed - clean-up just as many extra slots
>>>> that
>>>> you need to complete the transmission (for now this is anyways just =
one
>>>> slot). Then we proceed with enqueuing and do the cleanup of the rest=
 of
>>>> the slots after we notified the backend. What do you think?
>>>>
>>>
>>> This will stay just as it is for the current patches. Feel free to
>>> change anything after upstreaming these patches.
>>
>> No, it won't stay like this. At least, you have to call clean-up when
>> the ring is full before you leave the non-blocking function. Otherwise
>> you end up in never getting space back on a full ring, but I think
>> this is clear.
>>
>>>
>>>>>
>>>>> Btw, I'm waiting for reviews on the other patches as well before I
>>>>> send
>>>>> the v5.
>>>>
>>>> Yes, sure.
>>>>
>>>>>
>>>>>
>>>>>>> +=C2=A0=C2=A0=C2=A0 local_irq_restore(flags);
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 status |=3D likely(count > 0) ? UK_NETDEV_STA=
TUS_MORE : 0x0;
>>>>>>> +
>>>>>>> +=C2=A0=C2=A0=C2=A0 return status;
>>>>>>> +}
>>>>>>> +
>>>>>>> =C2=A0=C2=A0=C2=A0 static int netfront_rxq_enqueue(struct uk_netd=
ev_rx_queue *rxq,
>>>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 struct uk_netbuf *netbuf)
>>>>>>> =C2=A0=C2=A0=C2=A0 {
>>>>>>> @@ -598,6 +699,7 @@ static int netfront_add_dev(struct xenbus_dev=
ice
>>>>>>> *xendev)
>>>>>>> =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 /* register net=
dev */
>>>>>>> +=C2=A0=C2=A0=C2=A0 nfdev->netdev.tx_one =3D netfront_xmit;
>>>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->netdev.ops =3D =
&netfront_ops;
>>>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D uk_netdev_drv_r=
egister(&nfdev->netdev, drv_allocator,
>>>>>>> DRIVER_NAME);
>>>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc < 0) {
>>>>>>>
>>>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Simon
>>>>
>=20


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 15:55:38 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 15:55:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.11133.29513 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVzPm-0004J6-7w; Fri, 23 Oct 2020 15:55:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 11133.29513; Fri, 23 Oct 2020 15:55:38 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVzPm-0004Iz-4u; Fri, 23 Oct 2020 15:55:38 +0000
Received: by outflank-mailman (input) for mailman id 11133;
 Fri, 23 Oct 2020 15:55: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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kVzPk-0004It-QV
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 15:55:36 +0000
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id ca7c4296-f071-4d81-a8ba-0b5f6e42f3bf;
 Fri, 23 Oct 2020 15:55:35 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 61EFDB561DCB;
 Fri, 23 Oct 2020 18:55:34 +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 QqqzMYnEYUYB; Fri, 23 Oct 2020 18:55:31 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 6C4DBB5625D3;
 Fri, 23 Oct 2020 18:55:31 +0300 (EEST)
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 ZNLn0HP5aTh8; Fri, 23 Oct 2020 18:55:31 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id 2AA90B561E2D;
 Fri, 23 Oct 2020 18:55:31 +0300 (EEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kVzPk-0004It-QV
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 15:55:36 +0000
X-Inumbo-ID: ca7c4296-f071-4d81-a8ba-0b5f6e42f3bf
Received: from mx.upb.ro (unknown [141.85.13.200])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id ca7c4296-f071-4d81-a8ba-0b5f6e42f3bf;
	Fri, 23 Oct 2020 15:55:35 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 61EFDB561DCB;
	Fri, 23 Oct 2020 18:55:34 +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 QqqzMYnEYUYB; Fri, 23 Oct 2020 18:55:31 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 6C4DBB5625D3;
	Fri, 23 Oct 2020 18:55:31 +0300 (EEST)
X-Virus-Scanned: amavisd-new at upb.ro
Received: from mx.upb.ro ([127.0.0.1])
	by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026)
	with ESMTP id ZNLn0HP5aTh8; Fri, 23 Oct 2020 18:55:31 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id 2AA90B561E2D;
	Fri, 23 Oct 2020 18:55:31 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v4 11/12] plat/xen/drivers/net: Add receive
 operation
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-12-costin.lupu@cs.pub.ro>
 <dedf2594-7e8b-dec0-92d3-148e55330ec0@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <585f4c8e-3adb-12dc-354f-17d44456c783@cs.pub.ro>
Date: Fri, 23 Oct 2020 18:55:30 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <dedf2594-7e8b-dec0-92d3-148e55330ec0@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable



On 10/22/20 4:40 PM, Sharan Santhanam wrote:
> Hello Costin,
>=20
> Please find the review comment inline:
>=20
> Thanks & Regards
> Sharan
>=20
> On 8/13/20 10:53 AM, Costin Lupu wrote:
>> Incoming packets are written in pages allocated by the netfront. Such
>> pages are
>> allocated and registered to the shared ring after completion of receiv=
ing
>> operations.
>>
>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
>> ---
>> =C2=A0 plat/xen/drivers/net/netfront.c | 100 +++++++++++++++++++++++++=
+++++++
>> =C2=A0 1 file changed, 100 insertions(+)
>>
>> diff --git a/plat/xen/drivers/net/netfront.c
>> b/plat/xen/drivers/net/netfront.c
>> index f2b81329..101e38c8 100644
>> --- a/plat/xen/drivers/net/netfront.c
>> +++ b/plat/xen/drivers/net/netfront.c
>> @@ -221,6 +221,49 @@ static int netfront_rxq_enqueue(struct
>> uk_netdev_rx_queue *rxq,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0;
>> =C2=A0 }
>> =C2=A0 +static int netfront_rxq_dequeue(struct uk_netdev_rx_queue *rxq=
,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netbuf **netbuf)
>> +{
>> +=C2=A0=C2=A0=C2=A0 RING_IDX prod, cons;
>> +=C2=A0=C2=A0=C2=A0 netif_rx_response_t *rx_rsp;
>> +=C2=A0=C2=A0=C2=A0 uint16_t len, id;
>> +=C2=A0=C2=A0=C2=A0 struct uk_netbuf *buf =3D NULL;
>> +=C2=A0=C2=A0=C2=A0 int count =3D 0;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(rxq !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(netbuf !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 prod =3D rxq->ring.sring->rsp_prod;
>> +=C2=A0=C2=A0=C2=A0 rmb(); /* Ensure we see queued responses up to 'rp=
'. */
>> +=C2=A0=C2=A0=C2=A0 cons =3D rxq->ring.rsp_cons;
>> +=C2=A0=C2=A0=C2=A0 /* No new descriptor since last dequeue operation =
*/
>> +=C2=A0=C2=A0=C2=A0 if (cons =3D=3D prod)
>=20
> We should set it here:
>=20
> *netbuf =3D NULL;
>=20

ACK.

>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out;
>> +
>> +=C2=A0=C2=A0=C2=A0 /* get response */
>> +=C2=A0=C2=A0=C2=A0 rx_rsp =3D RING_GET_RESPONSE(&rxq->ring, cons);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(rx_rsp->status > NETIF_RSP_NULL);
>> +=C2=A0=C2=A0=C2=A0 id =3D rx_rsp->id;
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(id < NET_RX_RING_SIZE);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* remove grant for buffer data */
>> +=C2=A0=C2=A0=C2=A0 gnttab_end_access(rxq->gref[id]);
>> +
>> +=C2=A0=C2=A0=C2=A0 buf =3D rxq->netbuf[id];
>> +=C2=A0=C2=A0=C2=A0 len =3D (uint16_t) rx_rsp->status;
>> +=C2=A0=C2=A0=C2=A0 if (len > ETH_PKT_LEN)
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 len =3D ETH_PKT_LEN;
>> +=C2=A0=C2=A0=C2=A0 buf->len =3D len;
>> +
>> +=C2=A0=C2=A0=C2=A0 *netbuf =3D buf;
>> +
>> +=C2=A0=C2=A0=C2=A0 rxq->ring.rsp_cons++;
>> +=C2=A0=C2=A0=C2=A0 count =3D 1;
>> +
>> +out:
>> +=C2=A0=C2=A0=C2=A0 return count;
>> +}
>> +
>> =C2=A0 static int netfront_rx_fillup(struct uk_netdev_rx_queue *rxq,
>> uint16_t nb_desc)
>> =C2=A0 {
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netbuf *netbuf[nb_desc];
>> @@ -271,6 +314,62 @@ static int netfront_rxq_intr_enable(struct
>> uk_netdev_rx_queue *rxq)
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return (more > 0);
>> =C2=A0 }
>> =C2=A0 +static int netfront_recv(struct uk_netdev *n,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netdev_rx_queue =
*rxq,
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct uk_netbuf **pkt)
>> +{
>> +=C2=A0=C2=A0=C2=A0 int rc, status =3D 0;
>> +
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(n !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(rxq !=3D NULL);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(pkt !=3D NULL);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Queue interrupts have to be off when calling re=
ceive */
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(!(rxq->intr_enabled & NETFRONT_INTR_EN))=
;
>> +
>> +=C2=A0=C2=A0=C2=A0 rc =3D netfront_rxq_dequeue(rxq, pkt);
>> +=C2=A0=C2=A0=C2=A0 UK_ASSERT(rc >=3D 0);
>> +
>> +=C2=A0=C2=A0=C2=A0 status |=3D (*pkt) ? UK_NETDEV_STATUS_SUCCESS : 0x=
0;
>> +=C2=A0=C2=A0=C2=A0 status |=3D netfront_rx_fillup(rxq, rc);
>> +
>> +=C2=A0=C2=A0=C2=A0 /* Enable interrupt only when user had previously =
enabled it */
>> +=C2=A0=C2=A0=C2=A0 if (rxq->intr_enabled & NETFRONT_INTR_USR_EN_MASK)=
 {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Need to enable the inte=
rrupt on the last packet */
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D netfront_rxq_intr_e=
nable(rxq);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc =3D=3D 1 && !(*pkt)=
) {
>> +=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=C2=A0=C2=
=A0 * Packet arrive after reading the queue and before
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 * enabling the interrupt
>> +=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=C2=A0=C2=A0 rc=
 =3D netfront_rxq_dequeue(rxq, pkt);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 UK=
_ASSERT(rc >=3D 0);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 st=
atus |=3D UK_NETDEV_STATUS_SUCCESS;
>> +
>> +=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=C2=A0=C2=
=A0 * Since we received something, we need to fillup
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 * and notify
>> +=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=C2=A0=C2=A0 st=
atus |=3D netfront_rx_fillup(rxq, rc);
>> +
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /*=
 Need to enable the interrupt on the last packet */
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc=
 =3D netfront_rxq_intr_enable(rxq);
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 st=
atus |=3D (rc =3D=3D 1) ? UK_NETDEV_STATUS_MORE : 0x0;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } else if (*pkt) {
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /*=
 When we originally got a packet and there is more */
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 st=
atus |=3D (rc =3D=3D 1) ? UK_NETDEV_STATUS_MORE : 0x0;
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
>> +=C2=A0=C2=A0=C2=A0 } else if (*pkt) {
>> +=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 * For polling case, =
we report always there are further
>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * packets unless the=
 queue is empty.
>> +=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 status |=3D UK_NETDEV_STAT=
US_MORE;
>> +=C2=A0=C2=A0=C2=A0 }
>> +
>> +=C2=A0=C2=A0=C2=A0 return status;
>> +}
>> +
>> =C2=A0 static struct uk_netdev_tx_queue *netfront_txq_setup(struct
>> uk_netdev *n,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t queue_=
id,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint16_t nb_des=
c __unused,
>> @@ -700,6 +799,7 @@ static int netfront_add_dev(struct xenbus_device
>> *xendev)
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* register netdev */
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->netdev.tx_one =3D netfront_xmit;
>> +=C2=A0=C2=A0=C2=A0 nfdev->netdev.rx_one =3D netfront_recv;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nfdev->netdev.ops =3D &netfront_ops;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D uk_netdev_drv_register(&nfdev->n=
etdev, drv_allocator,
>> DRIVER_NAME);
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc < 0) {
>=20


From minios-devel-bounces@lists.xenproject.org Fri Oct 23 16:29:27 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 23 Oct 2020 16:29:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.11258.29884 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVzwS-0002tU-QM; Fri, 23 Oct 2020 16:29:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 11258.29884; Fri, 23 Oct 2020 16:29:24 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kVzwS-0002tN-NV; Fri, 23 Oct 2020 16:29:24 +0000
Received: by outflank-mailman (input) for mailman id 11258;
 Fri, 23 Oct 2020 16:29: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=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kVzwR-0002tC-BP
 for minios-devel@lists.xen.org; Fri, 23 Oct 2020 16:29:23 +0000
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 6ada2178-75bc-46f2-90e5-f750cbb7f251;
 Fri, 23 Oct 2020 16:29:22 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id EC751B561DCB;
 Fri, 23 Oct 2020 19:29:20 +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 oMaXAnDSJIhC; Fri, 23 Oct 2020 19:29:19 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 388C0B561E2D;
 Fri, 23 Oct 2020 19:29:19 +0300 (EEST)
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 3jUbUPUB-3mk; Fri, 23 Oct 2020 19:29:19 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id D9701B561DCB;
 Fri, 23 Oct 2020 19:29:18 +0300 (EEST)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=eizJ=D6=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kVzwR-0002tC-BP
	for minios-devel@lists.xen.org; Fri, 23 Oct 2020 16:29:23 +0000
X-Inumbo-ID: 6ada2178-75bc-46f2-90e5-f750cbb7f251
Received: from mx.upb.ro (unknown [141.85.13.200])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 6ada2178-75bc-46f2-90e5-f750cbb7f251;
	Fri, 23 Oct 2020 16:29:22 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id EC751B561DCB;
	Fri, 23 Oct 2020 19:29:20 +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 oMaXAnDSJIhC; Fri, 23 Oct 2020 19:29:19 +0300 (EEST)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 388C0B561E2D;
	Fri, 23 Oct 2020 19:29:19 +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 3jUbUPUB-3mk; Fri, 23 Oct 2020 19:29:19 +0300 (EEST)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id D9701B561DCB;
	Fri, 23 Oct 2020 19:29:18 +0300 (EEST)
Subject: Re: [UNIKRAFT PATCH v4 11/12] plat/xen/drivers/net: Add receive
 operation
From: Costin Lupu <costin.lupu@cs.pub.ro>
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-12-costin.lupu@cs.pub.ro>
 <dedf2594-7e8b-dec0-92d3-148e55330ec0@neclab.eu>
 <585f4c8e-3adb-12dc-354f-17d44456c783@cs.pub.ro>
Message-ID: <37a218c6-e883-1c7a-def9-2402792a2170@cs.pub.ro>
Date: Fri, 23 Oct 2020 19:29:18 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <585f4c8e-3adb-12dc-354f-17d44456c783@cs.pub.ro>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit

Thanks for the reviews, Sharan!

Just as a reminder, I'll send the v5 after I get the reviews for the 2
patches of lwip as well.

Cheers,
Costin


From minios-devel-bounces@lists.xenproject.org Mon Oct 26 10:47:36 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 26 Oct 2020 10:47:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12216.31984 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX02I-0007HE-SA; Mon, 26 Oct 2020 10:47:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12216.31984; Mon, 26 Oct 2020 10:47:34 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX02I-0007H7-PA; Mon, 26 Oct 2020 10:47:34 +0000
Received: by outflank-mailman (input) for mailman id 12216;
 Mon, 26 Oct 2020 10:47: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=HIrU=EB=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
 id 1kX02H-0007H2-AI
 for minios-devel@lists.xen.org; Mon, 26 Oct 2020 10:47:33 +0000
Received: from mail-ej1-x642.google.com (unknown [2a00:1450:4864:20::642])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e6c13b0a-3417-4c56-a58f-a2fa49f8e3e6;
 Mon, 26 Oct 2020 10:47:32 +0000 (UTC)
Received: by mail-ej1-x642.google.com with SMTP id z5so12663787ejw.7
 for <minios-devel@lists.xen.org>; Mon, 26 Oct 2020 03:47:32 -0700 (PDT)
Received: from arch.localdomain (5-12-21-167.residential.rdsnet.ro.
 [5.12.21.167])
 by smtp.gmail.com with ESMTPSA id g23sm4940823edp.33.2020.10.26.03.47.29
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 26 Oct 2020 03:47:30 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=HIrU=EB=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
	id 1kX02H-0007H2-AI
	for minios-devel@lists.xen.org; Mon, 26 Oct 2020 10:47:33 +0000
X-Inumbo-ID: e6c13b0a-3417-4c56-a58f-a2fa49f8e3e6
Received: from mail-ej1-x642.google.com (unknown [2a00:1450:4864:20::642])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id e6c13b0a-3417-4c56-a58f-a2fa49f8e3e6;
	Mon, 26 Oct 2020 10:47:32 +0000 (UTC)
Received: by mail-ej1-x642.google.com with SMTP id z5so12663787ejw.7
        for <minios-devel@lists.xen.org>; Mon, 26 Oct 2020 03:47:32 -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=1Mg2DHrZpB4TzULo6oXu+/w+BibuEqT7OdJCb5yC8rY=;
        b=enXMjEwyV6eZXGuj7LCT/HtU7Bf1wBrPyrHklZ/3npM+Qxk9yysOgA8SO0k2bSu7NL
         0ZiGTohBxA1k/VSw5t9e9fYPJXjTKgfIHVHIRkIKL8xAoOSvrSsYMKgnR905CyOiYYn6
         f3kWXVufIHO9fznm9VDiN/An3P/9HqywDjU2QZTwEPA36H+/nn5mGIOoASZGrsW8LqTH
         rMaMa325jDoKI4O+XEHXkgkzPoRaArtxYRRumerVZsqJJ1dU76Z9BFVQ1U0ROZmWqJf2
         fnXmgniMbLf6fP1qs9I7YJtp2bY4K3xTpoQpk7XTltI3Ok2K25LWalpAK/1Rmd4llwVO
         BeMg==
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=1Mg2DHrZpB4TzULo6oXu+/w+BibuEqT7OdJCb5yC8rY=;
        b=BVCcOkCUHMgRX6iUALVmmdOn0OzpIc+u6s1KtboVT2PLrRoGAHbpO26hNJhD5XT3fJ
         jhPJHI7HMYViwQDa3pTG+Fc6u+PTb7clANmBXr3WI/MP5TWJvKrJh8Ir68vpfIDaZ1NP
         qpIctN9TiomS4artahLyzXPwWkDnFiyrNVAiY/sBnizO6Rt5zW2TLVrgSwzC84y/Gm1U
         FfgkrGSVTNeQwr+BjS0/tzcIN0weRf3I0tpRb2rdyuowcs3IiGLVvJAUriT6HDptdj7i
         1rz4BGCEtXJmReZVloN8M+MBRCzbUEy3hywec2DjAUc+meMbhh3C6OPb6wJQMUr4/y9o
         Z1Yw==
X-Gm-Message-State: AOAM531e1sh4DJTHsgNM7q7pmOqZBqxCrM/SkGZ/iMReaxKUrUAF1HXt
	1/LSqvgTT3qSoFqPcUn17OXsEHtwvikP/Q==
X-Google-Smtp-Source: ABdhPJzzrCuPM0fBbwcrJbHFQnBRQzeGu5nKHwon2ooTOMokZL98PyE9tDyDdXK9ZJ+eE+dJm0KsjQ==
X-Received: by 2002:a17:906:6004:: with SMTP id o4mr14640792ejj.309.1603709251017;
        Mon, 26 Oct 2020 03:47:31 -0700 (PDT)
Received: from arch.localdomain (5-12-21-167.residential.rdsnet.ro. [5.12.21.167])
        by smtp.gmail.com with ESMTPSA id g23sm4940823edp.33.2020.10.26.03.47.29
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Mon, 26 Oct 2020 03:47:30 -0700 (PDT)
From: stefanl.teodorescu@gmail.com
To: minios-devel@lists.xen.org
Cc: costin.lup@gmail.com,
	Stefan Teodorescu <stefanl.teodorescu@gmail.com>
Subject: [UNIKRAFT PATCH 1/2] plat/kvm: Support non-executable pages on x86
Date: Mon, 26 Oct 2020 12:47:21 +0200
Message-Id: <20201026104722.266120-1-stefanl.teodorescu@gmail.com>
X-Mailer: git-send-email 2.29.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>

Setting this bit enables page table entries to have the NX bit set, to
have the ability to map pages as non-executable. Currently, our whole
memory is mapped as executable.

Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
---
 plat/kvm/x86/entry64.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/plat/kvm/x86/entry64.S b/plat/kvm/x86/entry64.S
index 274ab0b3..169f4c82 100644
--- a/plat/kvm/x86/entry64.S
+++ b/plat/kvm/x86/entry64.S
@@ -88,6 +88,7 @@ ENTRY(_libkvmplat_start32)
 	movl $0xc0000080, %ecx
 	rdmsr
 	orl $X86_EFER_LME, %eax
+	orl $X86_EFER_NXE, %eax
 	wrmsr

 	/* 3: load pml4 pointer */
--
2.29.0



From minios-devel-bounces@lists.xenproject.org Mon Oct 26 10:47:39 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 26 Oct 2020 10:47:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12217.31988 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX02N-0007Hw-Tq; Mon, 26 Oct 2020 10:47:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12217.31988; Mon, 26 Oct 2020 10:47:39 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX02N-0007Hp-Ql; Mon, 26 Oct 2020 10:47:39 +0000
Received: by outflank-mailman (input) for mailman id 12217;
 Mon, 26 Oct 2020 10:47: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=HIrU=EB=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
 id 1kX02M-0007H2-8p
 for minios-devel@lists.xen.org; Mon, 26 Oct 2020 10:47:38 +0000
Received: from mail-ed1-x544.google.com (unknown [2a00:1450:4864:20::544])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 69720ea0-4842-42b2-bfe1-a21f53d3c69a;
 Mon, 26 Oct 2020 10:47:33 +0000 (UTC)
Received: by mail-ed1-x544.google.com with SMTP id w23so8740531edl.0
 for <minios-devel@lists.xen.org>; Mon, 26 Oct 2020 03:47:33 -0700 (PDT)
Received: from arch.localdomain (5-12-21-167.residential.rdsnet.ro.
 [5.12.21.167])
 by smtp.gmail.com with ESMTPSA id g23sm4940823edp.33.2020.10.26.03.47.31
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 26 Oct 2020 03:47:31 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=HIrU=EB=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
	id 1kX02M-0007H2-8p
	for minios-devel@lists.xen.org; Mon, 26 Oct 2020 10:47:38 +0000
X-Inumbo-ID: 69720ea0-4842-42b2-bfe1-a21f53d3c69a
Received: from mail-ed1-x544.google.com (unknown [2a00:1450:4864:20::544])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 69720ea0-4842-42b2-bfe1-a21f53d3c69a;
	Mon, 26 Oct 2020 10:47:33 +0000 (UTC)
Received: by mail-ed1-x544.google.com with SMTP id w23so8740531edl.0
        for <minios-devel@lists.xen.org>; Mon, 26 Oct 2020 03:47: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
         :mime-version:content-transfer-encoding;
        bh=uvoJXCUMlLWfH//C33Q5bnlTDsHZKrKhqsFQD5yXdv8=;
        b=RE2CXkdAFsH2O02WIrUpVNCqgJpcWyTPCYx2z3EicTqlxkzOVXunzPYQzniGINLEF6
         jXccJSnhwOm2bNH3X+z34fW40NpZWOZYYUWZfO6OJOniN/pxm67zdgG0RdPF+Q/JSt87
         HC2b2hDeunjavDcgioTxMBzPxkWrAwifYXcc7iB4P+u7uXaIri8SPkPRCh+Qiu3bHEaN
         wV438naOE1h5RMsh5m/Q8Jt1QhMxYA9iHc9rEIGbJeqldrp9JwUER7W2Ed5PaE3BdI6P
         MPyhoxgwDXROrBO1+KmMBRiFJIHTtNY05/l5iDy0I01Hv+P08P4e0L3/rVj9P6j1gibi
         l3/A==
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=uvoJXCUMlLWfH//C33Q5bnlTDsHZKrKhqsFQD5yXdv8=;
        b=hfyMwiKIP9QO6BBjCFnPcu2fBsLB4vyWNJEJPzZUZxzj0w07DwGoeNCSbjCcaia/x5
         sRX/mV6CwvDuwSQESNOldzh3L7oNT67pe8o5gv8CGAKRGqne7WOjN71vYiT/3zolCvKb
         uMhq1yvtfmgxOMtsb+MPIw2iodChNGH5DP5uTxV/IO//KuCw3RX/NkUy3ffoNoivjUrh
         VLUxhzwqA6zCr/wIXR+qirm5APUSdENcbKPgRiD/MJPrQlUgVysfUZWoeEBQvDRDMj6i
         P7ENKtA6ofwqkyMUH2XtN2jbhYP9ITP3MVRq+FTEIsoAfEMxBgOpZ83xqy/Q/cjo/w3Z
         a+hQ==
X-Gm-Message-State: AOAM531Lb12M7ydyOBA/fJHrR/Pv9LR+IRHHr1E0BS5LVl0at4gz0Bu4
	mDTUlbAcErcktNQc2DBHJJNzrUb5q6pwqg==
X-Google-Smtp-Source: ABdhPJxmgTUDBM3W1Y82yIEUsLYTSSHTzz+wXsAemoHvirpxaeexq6fZjnqEp58GNlO49Nb1rn6zvg==
X-Received: by 2002:a05:6402:1c10:: with SMTP id ck16mr15341605edb.7.1603709252103;
        Mon, 26 Oct 2020 03:47:32 -0700 (PDT)
Received: from arch.localdomain (5-12-21-167.residential.rdsnet.ro. [5.12.21.167])
        by smtp.gmail.com with ESMTPSA id g23sm4940823edp.33.2020.10.26.03.47.31
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Mon, 26 Oct 2020 03:47:31 -0700 (PDT)
From: stefanl.teodorescu@gmail.com
To: minios-devel@lists.xen.org
Cc: costin.lup@gmail.com,
	Stefan Teodorescu <stefanl.teodorescu@gmail.com>
Subject: [UNIKRAFT PATCH 2/2] include: Move sections.h to include/uk
Date: Mon, 26 Oct 2020 12:47:22 +0200
Message-Id: <20201026104722.266120-2-stefanl.teodorescu@gmail.com>
X-Mailer: git-send-email 2.29.0
In-Reply-To: <20201026104722.266120-1-stefanl.teodorescu@gmail.com>
References: <20201026104722.266120-1-stefanl.teodorescu@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>

Move plat/common/include/uk/plat/common/sections.h to
include/uk/sections.h to be able to include it in arch code. This file
is platform independent, so it does not affect anything.

Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
---
 .../include/uk/plat/common => include/uk}/sections.h      | 0
 plat/kvm/arm/entry64.S                                    | 2 +-
 plat/kvm/arm/setup.c                                      | 2 +-
 plat/kvm/memory.c                                         | 2 +-
 plat/kvm/x86/setup.c                                      | 2 +-
 plat/xen/arm/setup.c                                      | 2 +-
 plat/xen/include/xen-arm/mm.h                             | 2 +-
 plat/xen/include/xen-x86/mm.h                             | 2 +-
 plat/xen/memory.c                                         | 2 +-
 plat/xen/x86/mm.c                                         | 8 ++++----
 10 files changed, 12 insertions(+), 12 deletions(-)
 rename {plat/common/include/uk/plat/common => include/uk}/sections.h (100%)

diff --git a/plat/common/include/uk/plat/common/sections.h b/include/uk/sections.h
similarity index 100%
rename from plat/common/include/uk/plat/common/sections.h
rename to include/uk/sections.h
diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S
index c4de334c..8be3d59f 100644
--- a/plat/kvm/arm/entry64.S
+++ b/plat/kvm/arm/entry64.S
@@ -35,7 +35,7 @@
 #include <uk/asm.h>
 #include <kvm-arm/mm.h>
 #include <arm/cpu_defs.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <uk/config.h>

 .global page_table_size
diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
index 41e63755..8513b48c 100644
--- a/plat/kvm/arm/setup.c
+++ b/plat/kvm/arm/setup.c
@@ -20,7 +20,7 @@
  */
 #include <uk/config.h>
 #include <libfdt.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <kvm/console.h>
 #include <kvm/config.h>
 #include <uk/assert.h>
diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
index 1d9269ec..61d3e6ca 100644
--- a/plat/kvm/memory.c
+++ b/plat/kvm/memory.c
@@ -19,7 +19,7 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */

-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <sys/types.h>
 #include <uk/plat/memory.h>
 #include <uk/assert.h>
diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c
index 9c7a93a8..1cab0a63 100644
--- a/plat/kvm/x86/setup.c
+++ b/plat/kvm/x86/setup.c
@@ -27,7 +27,7 @@
  */

 #include <string.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <x86/cpu.h>
 #include <x86/traps.h>
 #include <kvm/config.h>
diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
index 2df3b46c..bcbc939e 100644
--- a/plat/xen/arm/setup.c
+++ b/plat/xen/arm/setup.c
@@ -25,7 +25,7 @@
 /* Ported from Mini-OS */

 #include <string.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <xen-arm/os.h>
 #include <xen-arm/mm.h>
 #include <xen/xen.h>
diff --git a/plat/xen/include/xen-arm/mm.h b/plat/xen/include/xen-arm/mm.h
index 659de843..bbd31ddd 100644
--- a/plat/xen/include/xen-arm/mm.h
+++ b/plat/xen/include/xen-arm/mm.h
@@ -28,7 +28,7 @@
 #define _ARCH_MM_H_

 #include <stdint.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <uk/arch/limits.h>

 typedef uint64_t paddr_t;
diff --git a/plat/xen/include/xen-x86/mm.h b/plat/xen/include/xen-x86/mm.h
index ffbedb09..99ba6d05 100644
--- a/plat/xen/include/xen-x86/mm.h
+++ b/plat/xen/include/xen-x86/mm.h
@@ -25,7 +25,7 @@
 #ifndef _ARCH_MM_H_
 #define _ARCH_MM_H_

-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #ifndef __ASSEMBLY__
 #include <xen/xen.h>
 #if defined(__i386__)
diff --git a/plat/xen/memory.c b/plat/xen/memory.c
index 8e7a7dda..27a317c4 100644
--- a/plat/xen/memory.c
+++ b/plat/xen/memory.c
@@ -34,7 +34,7 @@
  */

 #include <string.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>

 #include <common/gnttab.h>
 #if (defined __X86_32__) || (defined __X86_64__)
diff --git a/plat/xen/x86/mm.c b/plat/xen/x86/mm.c
index e006ab7f..50786d19 100644
--- a/plat/xen/x86/mm.c
+++ b/plat/xen/x86/mm.c
@@ -36,7 +36,7 @@
  */

 #include <string.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <errno.h>
 #include <uk/alloc.h>
 #include <uk/plat/config.h>
@@ -604,7 +604,7 @@ void _init_mem_set_readonly(void *text, void *etext)
         page = tab[offset];
         mfn = pte_to_mfn(page);
         tab = to_virt(mfn_to_pfn(mfn) << PAGE_SHIFT);
-        offset = l2_table_offset(start_address);
+        offset = l2_table_offset(start_address);
         if ( !(tab[offset] & _PAGE_PSE) )
         {
             page = tab[offset];
@@ -617,7 +617,7 @@ void _init_mem_set_readonly(void *text, void *etext)
         if ( start_address != (unsigned long)&_libxenplat_shared_info )
         {
 #ifdef CONFIG_PARAVIRT
-            mmu_updates[count].ptr =
+            mmu_updates[count].ptr =
                 ((pgentry_t)mfn << PAGE_SHIFT) + sizeof(pgentry_t) * offset;
             mmu_updates[count].val = tab[offset] & ~_PAGE_RW;
             count++;
@@ -631,7 +631,7 @@ void _init_mem_set_readonly(void *text, void *etext)
         start_address += page_size;

 #ifdef CONFIG_PARAVIRT
-        if ( count == L1_PAGETABLE_ENTRIES ||
+        if ( count == L1_PAGETABLE_ENTRIES ||
              start_address + page_size > end_address )
         {
             rc = HYPERVISOR_mmu_update(mmu_updates, count, NULL, DOMID_SELF);
--
2.29.0



From minios-devel-bounces@lists.xenproject.org Mon Oct 26 16:06:27 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 26 Oct 2020 16:06:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12412.32318 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX50o-000449-HX; Mon, 26 Oct 2020 16:06:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12412.32318; Mon, 26 Oct 2020 16:06:22 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX50o-000442-EX; Mon, 26 Oct 2020 16:06:22 +0000
Received: by outflank-mailman (input) for mailman id 12412;
 Mon, 26 Oct 2020 16:06: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=cz9p=EB=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kX50n-00043x-TG
 for minios-devel@lists.xen.org; Mon, 26 Oct 2020 16:06:21 +0000
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 559391f5-5f2a-4af2-995e-bb4761dc5c9e;
 Mon, 26 Oct 2020 16:06:20 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 7F02DB561EB9;
 Mon, 26 Oct 2020 18:06:18 +0200 (EET)
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 PEciuHDEy7o7; Mon, 26 Oct 2020 18:06:16 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 26A3AB561EC6;
 Mon, 26 Oct 2020 18:06:13 +0200 (EET)
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 ntnrFpFMoWbM; Mon, 26 Oct 2020 18:06:13 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id E35CFB561EB9;
 Mon, 26 Oct 2020 18:06:12 +0200 (EET)
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=cz9p=EB=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kX50n-00043x-TG
	for minios-devel@lists.xen.org; Mon, 26 Oct 2020 16:06:21 +0000
X-Inumbo-ID: 559391f5-5f2a-4af2-995e-bb4761dc5c9e
Received: from mx.upb.ro (unknown [141.85.13.200])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 559391f5-5f2a-4af2-995e-bb4761dc5c9e;
	Mon, 26 Oct 2020 16:06:20 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 7F02DB561EB9;
	Mon, 26 Oct 2020 18:06:18 +0200 (EET)
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 PEciuHDEy7o7; Mon, 26 Oct 2020 18:06:16 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 26A3AB561EC6;
	Mon, 26 Oct 2020 18:06:13 +0200 (EET)
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 ntnrFpFMoWbM; Mon, 26 Oct 2020 18:06:13 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id E35CFB561EB9;
	Mon, 26 Oct 2020 18:06:12 +0200 (EET)
Subject: Re: [UNIKRAFT PATCH 1/2] plat/kvm: Support non-executable pages on
 x86
To: stefanl.teodorescu@gmail.com, minios-devel@lists.xen.org
References: <20201026104722.266120-1-stefanl.teodorescu@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <658f3029-2418-eb7a-130d-bcd6a4784c7c@cs.pub.ro>
Date: Mon, 26 Oct 2020 18:06:12 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <20201026104722.266120-1-stefanl.teodorescu@gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit

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

On 10/26/20 12:47 PM, stefanl.teodorescu@gmail.com wrote:
> From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> 
> Setting this bit enables page table entries to have the NX bit set, to
> have the ability to map pages as non-executable. Currently, our whole
> memory is mapped as executable.
> 
> Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> ---
>  plat/kvm/x86/entry64.S | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/plat/kvm/x86/entry64.S b/plat/kvm/x86/entry64.S
> index 274ab0b3..169f4c82 100644
> --- a/plat/kvm/x86/entry64.S
> +++ b/plat/kvm/x86/entry64.S
> @@ -88,6 +88,7 @@ ENTRY(_libkvmplat_start32)
>  	movl $0xc0000080, %ecx
>  	rdmsr
>  	orl $X86_EFER_LME, %eax
> +	orl $X86_EFER_NXE, %eax
>  	wrmsr
> 
>  	/* 3: load pml4 pointer */
> --
> 2.29.0
> 
> 


From minios-devel-bounces@lists.xenproject.org Mon Oct 26 16:15:10 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 26 Oct 2020 16:15:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12424.32350 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX59J-00059g-To; Mon, 26 Oct 2020 16:15:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12424.32350; Mon, 26 Oct 2020 16:15:09 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX59J-00059Z-Qm; Mon, 26 Oct 2020 16:15:09 +0000
Received: by outflank-mailman (input) for mailman id 12424;
 Mon, 26 Oct 2020 16:15: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=HIrU=EB=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
 id 1kX59I-00059U-Le
 for minios-devel@lists.xen.org; Mon, 26 Oct 2020 16:15:08 +0000
Received: from mail-ed1-x543.google.com (unknown [2a00:1450:4864:20::543])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 16936e88-e6bc-418c-bfad-274061679de1;
 Mon, 26 Oct 2020 16:15:07 +0000 (UTC)
Received: by mail-ed1-x543.google.com with SMTP id bc23so9990054edb.5
 for <minios-devel@lists.xen.org>; Mon, 26 Oct 2020 09:15:07 -0700 (PDT)
Received: from arch.localdomain (5-12-21-167.residential.rdsnet.ro.
 [5.12.21.167])
 by smtp.gmail.com with ESMTPSA id j20sm989429edt.4.2020.10.26.09.15.04
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 26 Oct 2020 09:15:05 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=HIrU=EB=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
	id 1kX59I-00059U-Le
	for minios-devel@lists.xen.org; Mon, 26 Oct 2020 16:15:08 +0000
X-Inumbo-ID: 16936e88-e6bc-418c-bfad-274061679de1
Received: from mail-ed1-x543.google.com (unknown [2a00:1450:4864:20::543])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 16936e88-e6bc-418c-bfad-274061679de1;
	Mon, 26 Oct 2020 16:15:07 +0000 (UTC)
Received: by mail-ed1-x543.google.com with SMTP id bc23so9990054edb.5
        for <minios-devel@lists.xen.org>; Mon, 26 Oct 2020 09:15:07 -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=aedjZoVaqE/GP/k+17LVwPhiOp2DV4jQDWUN929WgWk=;
        b=mRaE8sU5N70ibcCg5V+3OKEHu9Fl+f+utHxffzz30cfs25Mx2xNap21IO429kKoX8E
         +gxCOnv6tPhfEwmQEXfevFP/+uSlxscDz+HhUMVFYlf8iiY6vwAZJ/p7at+qol8psgI0
         GizHCtUKl/FWaLO8srq29eAwn5Is9yIyRCHhu/QjnyJSaHcXO3mCGF7TS93UCAZyRBeg
         pwV42owpt35WwFPoepKGfSeDVszXAdK3ZREVsY1q2QKieyIGdyMTKNYrPMSw0bUiYDVD
         lar2ndTlyceutw5BliduxnkByhRHqGXsReCOTtrhuW8cHN0vDpJuJ79eP+exVbe7FAz5
         agYQ==
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=aedjZoVaqE/GP/k+17LVwPhiOp2DV4jQDWUN929WgWk=;
        b=f/l5Ik0K1hXx/7ePj55fCyiJCXeFwkyAB5axtwTHWM9K2DBnIH/ZpDoQ35TmB+DBDy
         WuA83mbXcnm4IVZZ1clU5K5IMSCetq7dwnHMo/WuA8p3T0VsiLYKrRlDHIamMpUYs8KM
         gQOo9WbRmDCGJ7FgNFlUiaCm/cllQTaOcSjPKGBi7HrrxTG8kKYHoMNMNChfqhErqY4W
         e2yXzMkO4V5TFq3ou7/j4Eg/QSLd/W/ILAm4gN8RJ1iksRF5RblgIh79mmS9s+YDmjRh
         4aWaBH3OBKmADt2NpcuqPJPvPG1JMVBWOfA+YTx2KJZcZzo84vthYotf+CyXmpPTgjD5
         rjwg==
X-Gm-Message-State: AOAM532xIHJr5TvImh/Mt40moLRrqEfSe2rmfdFo820LzRjBYCW/uzZq
	lL/pzVHwO0uWIgWtSE6+Eh09bs33QW8tLA==
X-Google-Smtp-Source: ABdhPJyJc4mr2ZAaLO8MMZiS1Y2Enlg1twh1nGe2YLKQ8uEr11T8rTrMe1GRyyo2pmSWCywXcuPXpA==
X-Received: by 2002:a50:99c3:: with SMTP id n3mr6741630edb.213.1603728905937;
        Mon, 26 Oct 2020 09:15:05 -0700 (PDT)
Received: from arch.localdomain (5-12-21-167.residential.rdsnet.ro. [5.12.21.167])
        by smtp.gmail.com with ESMTPSA id j20sm989429edt.4.2020.10.26.09.15.04
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Mon, 26 Oct 2020 09:15:05 -0700 (PDT)
From: stefanl.teodorescu@gmail.com
To: minios-devel@lists.xen.org
Cc: costin.lup@gmail.com,
	Stefan Teodorescu <stefanl.teodorescu@gmail.com>
Subject: [UNIKRAFT PATCH v2] include: Move sections.h to include/uk
Date: Mon, 26 Oct 2020 18:14:55 +0200
Message-Id: <20201026161455.298231-1-stefanl.teodorescu@gmail.com>
X-Mailer: git-send-email 2.29.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>

Move plat/common/include/uk/plat/common/sections.h to
include/uk/sections.h to be able to include it in arch code. This file
is platform independent, so it does not affect anything.

Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
---
 {plat/common/include/uk/plat/common => include/uk}/sections.h | 0
 plat/kvm/arm/entry64.S                                        | 2 +-
 plat/kvm/arm/setup.c                                          | 2 +-
 plat/kvm/memory.c                                             | 2 +-
 plat/kvm/x86/setup.c                                          | 2 +-
 plat/xen/arm/setup.c                                          | 2 +-
 plat/xen/include/xen-arm/mm.h                                 | 2 +-
 plat/xen/include/xen-x86/mm.h                                 | 2 +-
 plat/xen/memory.c                                             | 2 +-
 plat/xen/x86/mm.c                                             | 2 +-
 10 files changed, 9 insertions(+), 9 deletions(-)
 rename {plat/common/include/uk/plat/common => include/uk}/sections.h (100%)

diff --git a/plat/common/include/uk/plat/common/sections.h b/include/uk/sections.h
similarity index 100%
rename from plat/common/include/uk/plat/common/sections.h
rename to include/uk/sections.h
diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S
index c4de334c..8be3d59f 100644
--- a/plat/kvm/arm/entry64.S
+++ b/plat/kvm/arm/entry64.S
@@ -35,7 +35,7 @@
 #include <uk/asm.h>
 #include <kvm-arm/mm.h>
 #include <arm/cpu_defs.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <uk/config.h>

 .global page_table_size
diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
index 41e63755..8513b48c 100644
--- a/plat/kvm/arm/setup.c
+++ b/plat/kvm/arm/setup.c
@@ -20,7 +20,7 @@
  */
 #include <uk/config.h>
 #include <libfdt.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <kvm/console.h>
 #include <kvm/config.h>
 #include <uk/assert.h>
diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
index 1d9269ec..61d3e6ca 100644
--- a/plat/kvm/memory.c
+++ b/plat/kvm/memory.c
@@ -19,7 +19,7 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */

-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <sys/types.h>
 #include <uk/plat/memory.h>
 #include <uk/assert.h>
diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c
index 9c7a93a8..1cab0a63 100644
--- a/plat/kvm/x86/setup.c
+++ b/plat/kvm/x86/setup.c
@@ -27,7 +27,7 @@
  */

 #include <string.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <x86/cpu.h>
 #include <x86/traps.h>
 #include <kvm/config.h>
diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
index 2df3b46c..bcbc939e 100644
--- a/plat/xen/arm/setup.c
+++ b/plat/xen/arm/setup.c
@@ -25,7 +25,7 @@
 /* Ported from Mini-OS */

 #include <string.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <xen-arm/os.h>
 #include <xen-arm/mm.h>
 #include <xen/xen.h>
diff --git a/plat/xen/include/xen-arm/mm.h b/plat/xen/include/xen-arm/mm.h
index 659de843..bbd31ddd 100644
--- a/plat/xen/include/xen-arm/mm.h
+++ b/plat/xen/include/xen-arm/mm.h
@@ -28,7 +28,7 @@
 #define _ARCH_MM_H_

 #include <stdint.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <uk/arch/limits.h>

 typedef uint64_t paddr_t;
diff --git a/plat/xen/include/xen-x86/mm.h b/plat/xen/include/xen-x86/mm.h
index ffbedb09..99ba6d05 100644
--- a/plat/xen/include/xen-x86/mm.h
+++ b/plat/xen/include/xen-x86/mm.h
@@ -25,7 +25,7 @@
 #ifndef _ARCH_MM_H_
 #define _ARCH_MM_H_

-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #ifndef __ASSEMBLY__
 #include <xen/xen.h>
 #if defined(__i386__)
diff --git a/plat/xen/memory.c b/plat/xen/memory.c
index 8e7a7dda..27a317c4 100644
--- a/plat/xen/memory.c
+++ b/plat/xen/memory.c
@@ -34,7 +34,7 @@
  */

 #include <string.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>

 #include <common/gnttab.h>
 #if (defined __X86_32__) || (defined __X86_64__)
diff --git a/plat/xen/x86/mm.c b/plat/xen/x86/mm.c
index e006ab7f..9e352eed 100644
--- a/plat/xen/x86/mm.c
+++ b/plat/xen/x86/mm.c
@@ -36,7 +36,7 @@
  */

 #include <string.h>
-#include <uk/plat/common/sections.h>
+#include <uk/sections.h>
 #include <errno.h>
 #include <uk/alloc.h>
 #include <uk/plat/config.h>
--
2.29.0



From minios-devel-bounces@lists.xenproject.org Mon Oct 26 17:47:42 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 26 Oct 2020 17:47:42 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12520.32594 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX6ap-0006cJ-HC; Mon, 26 Oct 2020 17:47:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12520.32594; Mon, 26 Oct 2020 17:47:39 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX6ap-0006cC-E7; Mon, 26 Oct 2020 17:47:39 +0000
Received: by outflank-mailman (input) for mailman id 12520;
 Mon, 26 Oct 2020 17:47: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=cz9p=EB=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kX6ao-0006c7-NB
 for minios-devel@lists.xen.org; Mon, 26 Oct 2020 17:47:38 +0000
Received: from mx.upb.ro (unknown [141.85.13.220])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 587c1ea5-4799-435c-8d9a-253808e36a8b;
 Mon, 26 Oct 2020 17:47:36 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id E56A3B56125C;
 Mon, 26 Oct 2020 19:47:34 +0200 (EET)
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 YzqodyjuuITf; Mon, 26 Oct 2020 19:47:32 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 4C2C7B561EC0;
 Mon, 26 Oct 2020 19:47:32 +0200 (EET)
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 KYAIPeX3_hcO; Mon, 26 Oct 2020 19:47:32 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id F348CB56125C;
 Mon, 26 Oct 2020 19:47:31 +0200 (EET)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=cz9p=EB=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kX6ao-0006c7-NB
	for minios-devel@lists.xen.org; Mon, 26 Oct 2020 17:47:38 +0000
X-Inumbo-ID: 587c1ea5-4799-435c-8d9a-253808e36a8b
Received: from mx.upb.ro (unknown [141.85.13.220])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 587c1ea5-4799-435c-8d9a-253808e36a8b;
	Mon, 26 Oct 2020 17:47:36 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id E56A3B56125C;
	Mon, 26 Oct 2020 19:47:34 +0200 (EET)
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 YzqodyjuuITf; Mon, 26 Oct 2020 19:47:32 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 4C2C7B561EC0;
	Mon, 26 Oct 2020 19:47:32 +0200 (EET)
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 KYAIPeX3_hcO; Mon, 26 Oct 2020 19:47:32 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id F348CB56125C;
	Mon, 26 Oct 2020 19:47:31 +0200 (EET)
Subject: Re: [UNIKRAFT PATCH v2] include: Move sections.h to include/uk
To: stefanl.teodorescu@gmail.com, minios-devel@lists.xen.org
References: <20201026161455.298231-1-stefanl.teodorescu@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <cca11f04-bd12-26d5-20f8-3fd3086e6b2f@cs.pub.ro>
Date: Mon, 26 Oct 2020 19:47:31 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <20201026161455.298231-1-stefanl.teodorescu@gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit

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

On 10/26/20 6:14 PM, stefanl.teodorescu@gmail.com wrote:
> From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> 
> Move plat/common/include/uk/plat/common/sections.h to
> include/uk/sections.h to be able to include it in arch code. This file
> is platform independent, so it does not affect anything.
> 
> Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> ---
>  {plat/common/include/uk/plat/common => include/uk}/sections.h | 0
>  plat/kvm/arm/entry64.S                                        | 2 +-
>  plat/kvm/arm/setup.c                                          | 2 +-
>  plat/kvm/memory.c                                             | 2 +-
>  plat/kvm/x86/setup.c                                          | 2 +-
>  plat/xen/arm/setup.c                                          | 2 +-
>  plat/xen/include/xen-arm/mm.h                                 | 2 +-
>  plat/xen/include/xen-x86/mm.h                                 | 2 +-
>  plat/xen/memory.c                                             | 2 +-
>  plat/xen/x86/mm.c                                             | 2 +-
>  10 files changed, 9 insertions(+), 9 deletions(-)
>  rename {plat/common/include/uk/plat/common => include/uk}/sections.h (100%)
> 
> diff --git a/plat/common/include/uk/plat/common/sections.h b/include/uk/sections.h
> similarity index 100%
> rename from plat/common/include/uk/plat/common/sections.h
> rename to include/uk/sections.h
> diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S
> index c4de334c..8be3d59f 100644
> --- a/plat/kvm/arm/entry64.S
> +++ b/plat/kvm/arm/entry64.S
> @@ -35,7 +35,7 @@
>  #include <uk/asm.h>
>  #include <kvm-arm/mm.h>
>  #include <arm/cpu_defs.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>  #include <uk/config.h>
> 
>  .global page_table_size
> diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
> index 41e63755..8513b48c 100644
> --- a/plat/kvm/arm/setup.c
> +++ b/plat/kvm/arm/setup.c
> @@ -20,7 +20,7 @@
>   */
>  #include <uk/config.h>
>  #include <libfdt.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>  #include <kvm/console.h>
>  #include <kvm/config.h>
>  #include <uk/assert.h>
> diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
> index 1d9269ec..61d3e6ca 100644
> --- a/plat/kvm/memory.c
> +++ b/plat/kvm/memory.c
> @@ -19,7 +19,7 @@
>   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>   */
> 
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>  #include <sys/types.h>
>  #include <uk/plat/memory.h>
>  #include <uk/assert.h>
> diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c
> index 9c7a93a8..1cab0a63 100644
> --- a/plat/kvm/x86/setup.c
> +++ b/plat/kvm/x86/setup.c
> @@ -27,7 +27,7 @@
>   */
> 
>  #include <string.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>  #include <x86/cpu.h>
>  #include <x86/traps.h>
>  #include <kvm/config.h>
> diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
> index 2df3b46c..bcbc939e 100644
> --- a/plat/xen/arm/setup.c
> +++ b/plat/xen/arm/setup.c
> @@ -25,7 +25,7 @@
>  /* Ported from Mini-OS */
> 
>  #include <string.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>  #include <xen-arm/os.h>
>  #include <xen-arm/mm.h>
>  #include <xen/xen.h>
> diff --git a/plat/xen/include/xen-arm/mm.h b/plat/xen/include/xen-arm/mm.h
> index 659de843..bbd31ddd 100644
> --- a/plat/xen/include/xen-arm/mm.h
> +++ b/plat/xen/include/xen-arm/mm.h
> @@ -28,7 +28,7 @@
>  #define _ARCH_MM_H_
> 
>  #include <stdint.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>  #include <uk/arch/limits.h>
> 
>  typedef uint64_t paddr_t;
> diff --git a/plat/xen/include/xen-x86/mm.h b/plat/xen/include/xen-x86/mm.h
> index ffbedb09..99ba6d05 100644
> --- a/plat/xen/include/xen-x86/mm.h
> +++ b/plat/xen/include/xen-x86/mm.h
> @@ -25,7 +25,7 @@
>  #ifndef _ARCH_MM_H_
>  #define _ARCH_MM_H_
> 
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>  #ifndef __ASSEMBLY__
>  #include <xen/xen.h>
>  #if defined(__i386__)
> diff --git a/plat/xen/memory.c b/plat/xen/memory.c
> index 8e7a7dda..27a317c4 100644
> --- a/plat/xen/memory.c
> +++ b/plat/xen/memory.c
> @@ -34,7 +34,7 @@
>   */
> 
>  #include <string.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
> 
>  #include <common/gnttab.h>
>  #if (defined __X86_32__) || (defined __X86_64__)
> diff --git a/plat/xen/x86/mm.c b/plat/xen/x86/mm.c
> index e006ab7f..9e352eed 100644
> --- a/plat/xen/x86/mm.c
> +++ b/plat/xen/x86/mm.c
> @@ -36,7 +36,7 @@
>   */
> 
>  #include <string.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>  #include <errno.h>
>  #include <uk/alloc.h>
>  #include <uk/plat/config.h>
> --
> 2.29.0
> 
> 


From minios-devel-bounces@lists.xenproject.org Mon Oct 26 18:05:36 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 26 Oct 2020 18:05:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12528.32609 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX6sB-0008SW-45; Mon, 26 Oct 2020 18:05:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12528.32609; Mon, 26 Oct 2020 18:05:35 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kX6sB-0008SP-17; Mon, 26 Oct 2020 18:05:35 +0000
Received: by outflank-mailman (input) for mailman id 12528;
 Mon, 26 Oct 2020 18:05: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=cz9p=EB=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kX6s9-0008SK-RA
 for minios-devel@lists.xen.org; Mon, 26 Oct 2020 18:05:33 +0000
Received: from mx.upb.ro (unknown [141.85.13.210])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 18e8c371-18c0-4d9c-9655-f295b4587166;
 Mon, 26 Oct 2020 18:05:32 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 592BEB56125C;
 Mon, 26 Oct 2020 20:05:31 +0200 (EET)
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 aFedfRE3CtAw; Mon, 26 Oct 2020 20:05:29 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 540FFB561C89;
 Mon, 26 Oct 2020 20:05:29 +0200 (EET)
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 XTv8DN05KZO4; Mon, 26 Oct 2020 20:05:29 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id 14A1AB56125C;
 Mon, 26 Oct 2020 20:05:28 +0200 (EET)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=cz9p=EB=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kX6s9-0008SK-RA
	for minios-devel@lists.xen.org; Mon, 26 Oct 2020 18:05:33 +0000
X-Inumbo-ID: 18e8c371-18c0-4d9c-9655-f295b4587166
Received: from mx.upb.ro (unknown [141.85.13.210])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 18e8c371-18c0-4d9c-9655-f295b4587166;
	Mon, 26 Oct 2020 18:05:32 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 592BEB56125C;
	Mon, 26 Oct 2020 20:05:31 +0200 (EET)
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 aFedfRE3CtAw; Mon, 26 Oct 2020 20:05:29 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 540FFB561C89;
	Mon, 26 Oct 2020 20:05:29 +0200 (EET)
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 XTv8DN05KZO4; Mon, 26 Oct 2020 20:05:29 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id 14A1AB56125C;
	Mon, 26 Oct 2020 20:05:28 +0200 (EET)
Subject: Re: [UNIKRAFT PATCH v4 01/12] plat/drivers/virtio: Fill MTU and
 queues alignments when retrieving information
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-2-costin.lupu@cs.pub.ro>
 <523f0fa8-156b-8967-6525-7a88e3a41b36@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <25d2733c-6a81-b4d0-b12e-c9043e8f0c33@cs.pub.ro>
Date: Mon, 26 Oct 2020 20:05:28 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <523f0fa8-156b-8967-6525-7a88e3a41b36@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

This can be pushed separately, as Simon already suggested.

Costin

On 10/22/20 2:03 PM, Sharan Santhanam wrote:
> Hello Costin,
>=20
> Thanks for the work
>=20
> Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
>=20
> Thanks & Regards
> Sharan
>=20
> On 8/13/20 10:53 AM, Costin Lupu wrote:
>> This patch sets the max MTU value when retrieving device information
>> and the
>> alignments used when allocating packets for each queue.
>>
>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>> ---
>> =C2=A0 plat/drivers/virtio/virtio_net.c | 3 +++
>> =C2=A0 1 file changed, 3 insertions(+)
>>
>> diff --git a/plat/drivers/virtio/virtio_net.c
>> b/plat/drivers/virtio/virtio_net.c
>> index b0663e60..0e748b8f 100644
>> --- a/plat/drivers/virtio/virtio_net.c
>> +++ b/plat/drivers/virtio/virtio_net.c
>> @@ -770,6 +770,7 @@ static int virtio_netdev_rxq_info_get(struct
>> uk_netdev *dev,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rxq =3D &vndev->rxqs[queue_id];
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qinfo->nb_min =3D 1;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qinfo->nb_max =3D rxq->max_nb_desc;
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_align =3D sizeof(void *); /* word size a=
lignment */
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qinfo->nb_is_power_of_two =3D 1;
>> =C2=A0 =C2=A0 exit:
>> @@ -797,6 +798,7 @@ static int virtio_netdev_txq_info_get(struct
>> uk_netdev *dev,
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 txq =3D &vndev->txqs[queue_id];
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qinfo->nb_min =3D 1;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qinfo->nb_max =3D txq->max_nb_desc;
>> +=C2=A0=C2=A0=C2=A0 qinfo->nb_align =3D sizeof(void *); /* word size a=
lignment */
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qinfo->nb_is_power_of_two =3D 1;
>> =C2=A0 =C2=A0 exit:
>> @@ -1048,6 +1050,7 @@ static void virtio_net_info_get(struct uk_netdev
>> *dev,
>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_info->max_rx_queues =3D vnde=
v->max_vqueue_pairs;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_info->max_tx_queues =3D vndev->max_=
vqueue_pairs;
>> +=C2=A0=C2=A0=C2=A0 dev_info->max_mtu =3D vndev->max_mtu;
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_info->nb_encap_tx =3D sizeof(struct=
 virtio_net_hdr_padded);
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_info->nb_encap_rx =3D sizeof(struct=
 virtio_net_hdr_padded);
>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_info->features =3D UK_FEATURE_RXQ_I=
NTR_AVAILABLE;
>=20


From minios-devel-bounces@lists.xenproject.org Tue Oct 27 09:41:37 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 27 Oct 2020 09:41:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12717.32968 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXLTv-0003nY-VO; Tue, 27 Oct 2020 09:41:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12717.32968; Tue, 27 Oct 2020 09:41:31 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXLTv-0003nR-SF; Tue, 27 Oct 2020 09:41:31 +0000
Received: by outflank-mailman (input) for mailman id 12717;
 Tue, 27 Oct 2020 09:41: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=a4eq=EC=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kXLTu-0003nM-IW
 for minios-devel@lists.xen.org; Tue, 27 Oct 2020 09:41:30 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a61a57a6-8d69-43aa-ad63-a0df35815bb1;
 Tue, 27 Oct 2020 09:41:28 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id D7B2CF2223;
 Tue, 27 Oct 2020 10:41:26 +0100 (CET)
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 jfC_YPlGRgro; Tue, 27 Oct 2020 10:41:26 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 9B125F20C0;
 Tue, 27 Oct 2020 10:41:22 +0100 (CET)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 27 Oct
 2020 10:41:22 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=a4eq=EC=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kXLTu-0003nM-IW
	for minios-devel@lists.xen.org; Tue, 27 Oct 2020 09:41:30 +0000
X-Inumbo-ID: a61a57a6-8d69-43aa-ad63-a0df35815bb1
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id a61a57a6-8d69-43aa-ad63-a0df35815bb1;
	Tue, 27 Oct 2020 09:41:28 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id D7B2CF2223;
	Tue, 27 Oct 2020 10:41:26 +0100 (CET)
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 jfC_YPlGRgro; Tue, 27 Oct 2020 10:41:26 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 9B125F20C0;
	Tue, 27 Oct 2020 10:41:22 +0100 (CET)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 27 Oct
 2020 10:41:22 +0100
Subject: Re: [UNIKRAFT PATCH v4 01/12] plat/drivers/virtio: Fill MTU and
 queues alignments when retrieving information
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-2-costin.lupu@cs.pub.ro>
 <523f0fa8-156b-8967-6525-7a88e3a41b36@neclab.eu>
 <25d2733c-6a81-b4d0-b12e-c9043e8f0c33@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <a0c0413d-b5c4-e982-e3ff-bcb842f433be@neclab.eu>
Date: Tue, 27 Oct 2020 10:41:03 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <25d2733c-6a81-b4d0-b12e-c9043e8f0c33@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Sure, we will upstream this patch.

On 10/26/20 7:05 PM, Costin Lupu wrote:
> This can be pushed separately, as Simon already suggested.
>
> Costin
>
> On 10/22/20 2:03 PM, Sharan Santhanam wrote:
>> Hello Costin,
>>
>> Thanks for the work
>>
>> Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
>>
>> Thanks & Regards
>> Sharan
>>
>> On 8/13/20 10:53 AM, Costin Lupu wrote:
>>> This patch sets the max MTU value when retrieving device information
>>> and the
>>> alignments used when allocating packets for each queue.
>>>
>>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>>> ---
>>>    plat/drivers/virtio/virtio_net.c | 3 +++
>>>    1 file changed, 3 insertions(+)
>>>
>>> diff --git a/plat/drivers/virtio/virtio_net.c
>>> b/plat/drivers/virtio/virtio_net.c
>>> index b0663e60..0e748b8f 100644
>>> --- a/plat/drivers/virtio/virtio_net.c
>>> +++ b/plat/drivers/virtio/virtio_net.c
>>> @@ -770,6 +770,7 @@ static int virtio_netdev_rxq_info_get(struct
>>> uk_netdev *dev,
>>>        rxq = &vndev->rxqs[queue_id];
>>>        qinfo->nb_min = 1;
>>>        qinfo->nb_max = rxq->max_nb_desc;
>>> +    qinfo->nb_align = sizeof(void *); /* word size alignment */
>>>        qinfo->nb_is_power_of_two = 1;
>>>      exit:
>>> @@ -797,6 +798,7 @@ static int virtio_netdev_txq_info_get(struct
>>> uk_netdev *dev,
>>>        txq = &vndev->txqs[queue_id];
>>>        qinfo->nb_min = 1;
>>>        qinfo->nb_max = txq->max_nb_desc;
>>> +    qinfo->nb_align = sizeof(void *); /* word size alignment */
>>>        qinfo->nb_is_power_of_two = 1;
>>>      exit:
>>> @@ -1048,6 +1050,7 @@ static void virtio_net_info_get(struct uk_netdev
>>> *dev,
>>>          dev_info->max_rx_queues = vndev->max_vqueue_pairs;
>>>        dev_info->max_tx_queues = vndev->max_vqueue_pairs;
>>> +    dev_info->max_mtu = vndev->max_mtu;
>>>        dev_info->nb_encap_tx = sizeof(struct virtio_net_hdr_padded);
>>>        dev_info->nb_encap_rx = sizeof(struct virtio_net_hdr_padded);
>>>        dev_info->features = UK_FEATURE_RXQ_INTR_AVAILABLE;


From minios-devel-bounces@lists.xenproject.org Tue Oct 27 09:46:08 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 27 Oct 2020 09:46:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12721.32984 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXLYO-0003vD-J9; Tue, 27 Oct 2020 09:46:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12721.32984; Tue, 27 Oct 2020 09:46:08 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXLYO-0003v9-GJ; Tue, 27 Oct 2020 09:46:08 +0000
Received: by outflank-mailman (input) for mailman id 12721;
 Tue, 27 Oct 2020 09:46:07 +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=a4eq=EC=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kXLYN-0003uv-96
 for minios-devel@lists.xen.org; Tue, 27 Oct 2020 09:46:07 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 250f04a4-1a6f-47f4-83f2-227651aebc0d;
 Tue, 27 Oct 2020 09:46:04 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id AE75C103A70;
 Tue, 27 Oct 2020 10:46:03 +0100 (CET)
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 lkqX54uRXpzL; Tue, 27 Oct 2020 10:46:03 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 89D69FFB48;
 Tue, 27 Oct 2020 10:46:03 +0100 (CET)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 27 Oct
 2020 10:46:03 +0100
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=a4eq=EC=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kXLYN-0003uv-96
	for minios-devel@lists.xen.org; Tue, 27 Oct 2020 09:46:07 +0000
X-Inumbo-ID: 250f04a4-1a6f-47f4-83f2-227651aebc0d
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 250f04a4-1a6f-47f4-83f2-227651aebc0d;
	Tue, 27 Oct 2020 09:46:04 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id AE75C103A70;
	Tue, 27 Oct 2020 10:46:03 +0100 (CET)
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 lkqX54uRXpzL; Tue, 27 Oct 2020 10:46:03 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 89D69FFB48;
	Tue, 27 Oct 2020 10:46:03 +0100 (CET)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 27 Oct
 2020 10:46:03 +0100
Subject: Re: [UNIKRAFT PATCH v4 11/12] plat/xen/drivers/net: Add receive
 operation
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-12-costin.lupu@cs.pub.ro>
 <dedf2594-7e8b-dec0-92d3-148e55330ec0@neclab.eu>
 <585f4c8e-3adb-12dc-354f-17d44456c783@cs.pub.ro>
 <37a218c6-e883-1c7a-def9-2402792a2170@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <e1a00f42-2c70-9a95-5096-873a222eca09@neclab.eu>
Date: Tue, 27 Oct 2020 10:46:01 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <37a218c6-e883-1c7a-def9-2402792a2170@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Hello Costin,

Simon is looking into that series and is it necessary we need to wait 
for that series for this driver changes. The driver should be able to 
work with the current version of the LWIP patches isn't it.

Thanks & Regards

Sharan

On 10/23/20 6:29 PM, Costin Lupu wrote:
> Thanks for the reviews, Sharan!
>
> Just as a reminder, I'll send the v5 after I get the reviews for the 2
> patches of lwip as well.
>
> Cheers,
> Costin


From minios-devel-bounces@lists.xenproject.org Tue Oct 27 10:14:46 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 27 Oct 2020 10:14:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12737.33000 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXM02-0006km-1g; Tue, 27 Oct 2020 10:14:42 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12737.33000; Tue, 27 Oct 2020 10:14:42 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXM01-0006kf-U3; Tue, 27 Oct 2020 10:14:41 +0000
Received: by outflank-mailman (input) for mailman id 12737;
 Tue, 27 Oct 2020 10:14:41 +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=vCSa=EC=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kXM01-0006ka-3M
 for minios-devel@lists.xen.org; Tue, 27 Oct 2020 10:14:41 +0000
Received: from mx.upb.ro (unknown [141.85.13.220])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 29b351dc-815b-46fa-8213-c878e6bb1e65;
 Tue, 27 Oct 2020 10:14:38 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id B9FD4B561F22;
 Tue, 27 Oct 2020 12:14:37 +0200 (EET)
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 gcpJn_xkNQvc; Tue, 27 Oct 2020 12:14:36 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 0FBA1B561F5D;
 Tue, 27 Oct 2020 12:14:36 +0200 (EET)
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 BiooOXW5TQso; Tue, 27 Oct 2020 12:14:35 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id D0071B561F22;
 Tue, 27 Oct 2020 12:14:35 +0200 (EET)
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=vCSa=EC=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kXM01-0006ka-3M
	for minios-devel@lists.xen.org; Tue, 27 Oct 2020 10:14:41 +0000
X-Inumbo-ID: 29b351dc-815b-46fa-8213-c878e6bb1e65
Received: from mx.upb.ro (unknown [141.85.13.220])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 29b351dc-815b-46fa-8213-c878e6bb1e65;
	Tue, 27 Oct 2020 10:14:38 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id B9FD4B561F22;
	Tue, 27 Oct 2020 12:14:37 +0200 (EET)
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 gcpJn_xkNQvc; Tue, 27 Oct 2020 12:14:36 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 0FBA1B561F5D;
	Tue, 27 Oct 2020 12:14:36 +0200 (EET)
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 BiooOXW5TQso; Tue, 27 Oct 2020 12:14:35 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id D0071B561F22;
	Tue, 27 Oct 2020 12:14:35 +0200 (EET)
Subject: Re: [UNIKRAFT PATCH v4 11/12] plat/xen/drivers/net: Add receive
 operation
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-12-costin.lupu@cs.pub.ro>
 <dedf2594-7e8b-dec0-92d3-148e55330ec0@neclab.eu>
 <585f4c8e-3adb-12dc-354f-17d44456c783@cs.pub.ro>
 <37a218c6-e883-1c7a-def9-2402792a2170@cs.pub.ro>
 <e1a00f42-2c70-9a95-5096-873a222eca09@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <60d19afc-683f-8059-0a36-a587cdc644c9@cs.pub.ro>
Date: Tue, 27 Oct 2020 12:14:35 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <e1a00f42-2c70-9a95-5096-873a222eca09@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 10/27/20 11:46 AM, Sharan Santhanam wrote:
> Hello Costin,
> 
> Simon is looking into that series and is it necessary we need to wait
> for that series for this driver changes. The driver should be able to
> work with the current version of the LWIP patches isn't it.

Yeah, the current version of netfront (v4) should work with the current
version of LWIP changes (v3), if that's what you're asking me.

Costin


From minios-devel-bounces@lists.xenproject.org Tue Oct 27 11:29:40 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 27 Oct 2020 11:29:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12805.33173 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXNAV-000600-91; Tue, 27 Oct 2020 11:29:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12805.33173; Tue, 27 Oct 2020 11:29:35 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXNAV-0005zt-62; Tue, 27 Oct 2020 11:29:35 +0000
Received: by outflank-mailman (input) for mailman id 12805;
 Tue, 27 Oct 2020 11:29: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=a4eq=EC=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
 id 1kXNAT-0005zo-40
 for minios-devel@lists.xen.org; Tue, 27 Oct 2020 11:29:33 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 3cdfdd37-141a-4c36-b811-8a7346bdc802;
 Tue, 27 Oct 2020 11:29:30 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id A057DF2229;
 Tue, 27 Oct 2020 12:29:29 +0100 (CET)
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 ULDygz901NAX; Tue, 27 Oct 2020 12:29:29 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 782E3F2226;
 Tue, 27 Oct 2020 12:29:25 +0100 (CET)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 27 Oct
 2020 12:29:24 +0100
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=a4eq=EC=neclab.eu=sharan.santhanam@srs-us1.protection.inumbo.net>)
	id 1kXNAT-0005zo-40
	for minios-devel@lists.xen.org; Tue, 27 Oct 2020 11:29:33 +0000
X-Inumbo-ID: 3cdfdd37-141a-4c36-b811-8a7346bdc802
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 3cdfdd37-141a-4c36-b811-8a7346bdc802;
	Tue, 27 Oct 2020 11:29:30 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id A057DF2229;
	Tue, 27 Oct 2020 12:29:29 +0100 (CET)
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 ULDygz901NAX; Tue, 27 Oct 2020 12:29:29 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 782E3F2226;
	Tue, 27 Oct 2020 12:29:25 +0100 (CET)
Received: from [10.7.1.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 27 Oct
 2020 12:29:24 +0100
Subject: Re: [UNIKRAFT PATCH v4 11/12] plat/xen/drivers/net: Add receive
 operation
To: Costin Lupu <costin.lupu@cs.pub.ro>, <minios-devel@lists.xen.org>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-12-costin.lupu@cs.pub.ro>
 <dedf2594-7e8b-dec0-92d3-148e55330ec0@neclab.eu>
 <585f4c8e-3adb-12dc-354f-17d44456c783@cs.pub.ro>
 <37a218c6-e883-1c7a-def9-2402792a2170@cs.pub.ro>
 <e1a00f42-2c70-9a95-5096-873a222eca09@neclab.eu>
 <60d19afc-683f-8059-0a36-a587cdc644c9@cs.pub.ro>
From: Sharan Santhanam <sharan.santhanam@neclab.eu>
Message-ID: <32406e5d-446e-b261-a786-c897b7f4f7cc@neclab.eu>
Date: Tue, 27 Oct 2020 12:29:24 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <60d19afc-683f-8059-0a36-a587cdc644c9@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)


On 10/27/20 11:14 AM, Costin Lupu wrote:
> On 10/27/20 11:46 AM, Sharan Santhanam wrote:
>> Hello Costin,
>>
>> Simon is looking into that series and is it necessary we need to wait
>> for that series for this driver changes. The driver should be able to
>> work with the current version of the LWIP patches isn't it.
> Yeah, the current version of netfront (v4) should work with the current
> version of LWIP changes (v3), if that's what you're asking me.

I meant netfront (v5) should also work with LWIP v3. Do we have to wait 
for the other?

-- Sharan


>
> Costin


From minios-devel-bounces@lists.xenproject.org Tue Oct 27 12:07:12 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 27 Oct 2020 12:07:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.12825.33203 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXNks-0001Fl-Vj; Tue, 27 Oct 2020 12:07:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 12825.33203; Tue, 27 Oct 2020 12:07:10 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXNks-0001Fe-Sv; Tue, 27 Oct 2020 12:07:10 +0000
Received: by outflank-mailman (input) for mailman id 12825;
 Tue, 27 Oct 2020 12:07: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=vCSa=EC=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kXNkr-0001FZ-1L
 for minios-devel@lists.xen.org; Tue, 27 Oct 2020 12:07:09 +0000
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id cacf4200-40d4-4931-921c-0ee8216ad720;
 Tue, 27 Oct 2020 12:07:06 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id A7D8CB561D39;
 Tue, 27 Oct 2020 14:07:04 +0200 (EET)
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 lCDIouhbQaQD; Tue, 27 Oct 2020 14:07:02 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id C877DB561F78;
 Tue, 27 Oct 2020 14:07:02 +0200 (EET)
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 WDjK2GIbqL-m; Tue, 27 Oct 2020 14:07:02 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id 7B0ADB561D39;
 Tue, 27 Oct 2020 14:07:02 +0200 (EET)
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=vCSa=EC=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kXNkr-0001FZ-1L
	for minios-devel@lists.xen.org; Tue, 27 Oct 2020 12:07:09 +0000
X-Inumbo-ID: cacf4200-40d4-4931-921c-0ee8216ad720
Received: from mx.upb.ro (unknown [141.85.13.200])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id cacf4200-40d4-4931-921c-0ee8216ad720;
	Tue, 27 Oct 2020 12:07:06 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id A7D8CB561D39;
	Tue, 27 Oct 2020 14:07:04 +0200 (EET)
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 lCDIouhbQaQD; Tue, 27 Oct 2020 14:07:02 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id C877DB561F78;
	Tue, 27 Oct 2020 14:07:02 +0200 (EET)
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 WDjK2GIbqL-m; Tue, 27 Oct 2020 14:07:02 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id 7B0ADB561D39;
	Tue, 27 Oct 2020 14:07:02 +0200 (EET)
Subject: Re: [UNIKRAFT PATCH v4 11/12] plat/xen/drivers/net: Add receive
 operation
To: Sharan Santhanam <sharan.santhanam@neclab.eu>, minios-devel@lists.xen.org
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-12-costin.lupu@cs.pub.ro>
 <dedf2594-7e8b-dec0-92d3-148e55330ec0@neclab.eu>
 <585f4c8e-3adb-12dc-354f-17d44456c783@cs.pub.ro>
 <37a218c6-e883-1c7a-def9-2402792a2170@cs.pub.ro>
 <e1a00f42-2c70-9a95-5096-873a222eca09@neclab.eu>
 <60d19afc-683f-8059-0a36-a587cdc644c9@cs.pub.ro>
 <32406e5d-446e-b261-a786-c897b7f4f7cc@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <a2922688-30eb-e146-2bc6-3af31428767e@cs.pub.ro>
Date: Tue, 27 Oct 2020 14:07:01 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <32406e5d-446e-b261-a786-c897b7f4f7cc@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 10/27/20 1:29 PM, Sharan Santhanam wrote:
> 
> On 10/27/20 11:14 AM, Costin Lupu wrote:
>> On 10/27/20 11:46 AM, Sharan Santhanam wrote:
>>> Hello Costin,
>>>
>>> Simon is looking into that series and is it necessary we need to wait
>>> for that series for this driver changes. The driver should be able to
>>> work with the current version of the LWIP patches isn't it.
>> Yeah, the current version of netfront (v4) should work with the current
>> version of LWIP changes (v3), if that's what you're asking me.
> 
> I meant netfront (v5) should also work with LWIP v3. Do we have to wait
> for the other?

As I said in previous emails, I will send the netfront v5 *only after* I
get the reviews for LWIP v3.

Costin


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 13:14:34 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 13:14:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13597.34288 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXlHY-0001lH-W6; Wed, 28 Oct 2020 13:14:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13597.34288; Wed, 28 Oct 2020 13:14:28 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXlHY-0001lA-TH; Wed, 28 Oct 2020 13:14:28 +0000
Received: by outflank-mailman (input) for mailman id 13597;
 Wed, 28 Oct 2020 13:14: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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kXlHW-0001l4-QS
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 13:14:26 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 6b5c53a5-3d8b-451d-b2df-87a283a6e5f4;
 Wed, 28 Oct 2020 13:14:23 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 4C03210397A;
 Wed, 28 Oct 2020 14:14:22 +0100 (CET)
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 HMRkk1Zm2AYz; Wed, 28 Oct 2020 14:14:22 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 239D4100188;
 Wed, 28 Oct 2020 14:14:22 +0100 (CET)
Received: from [10.7.2.48] (192.168.24.96) by titania.office.hd
 (192.168.24.89) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 14:14:21 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kXlHW-0001l4-QS
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 13:14:26 +0000
X-Inumbo-ID: 6b5c53a5-3d8b-451d-b2df-87a283a6e5f4
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 6b5c53a5-3d8b-451d-b2df-87a283a6e5f4;
	Wed, 28 Oct 2020 13:14:23 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 4C03210397A;
	Wed, 28 Oct 2020 14:14:22 +0100 (CET)
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 HMRkk1Zm2AYz; Wed, 28 Oct 2020 14:14:22 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 239D4100188;
	Wed, 28 Oct 2020 14:14:22 +0100 (CET)
Received: from [10.7.2.48] (192.168.24.96) by titania.office.hd
 (192.168.24.89) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 14:14:21 +0100
Subject: Re: [UNIKRAFT PATCH v2] include: Move sections.h to include/uk
To: <stefanl.teodorescu@gmail.com>, <minios-devel@lists.xen.org>
CC: <costin.lup@gmail.com>
References: <20201026161455.298231-1-stefanl.teodorescu@gmail.com>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <cd39a36f-0e1a-0b90-3107-f2666d98a1c3@neclab.eu>
Date: Wed, 28 Oct 2020 14:14:07 +0100
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0)
 Gecko/20100101 Thunderbird/68.12.1
MIME-Version: 1.0
In-Reply-To: <20201026161455.298231-1-stefanl.teodorescu@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: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Hey Stefan, hey Costin,

what is the reason that arch code needs sections.h? I can't read it from 
the commit message. Architecture code should only be the parts that are 
totally independent on the platform details. They are mostly helpers for 
arithmetics and CPU register definitions. I am concerned that 
architecture code may break when doing assumptions on symbol locations; 
imagine ASLR where locations are moved at runtime.

The NX bit patch is upstream.

Thanks,

Simon

On 26.10.20 17:14, stefanl.teodorescu@gmail.com wrote:
> From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> 
> Move plat/common/include/uk/plat/common/sections.h to
> include/uk/sections.h to be able to include it in arch code. This file
> is platform independent, so it does not affect anything.
> 
> Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> ---
>   {plat/common/include/uk/plat/common => include/uk}/sections.h | 0
>   plat/kvm/arm/entry64.S                                        | 2 +-
>   plat/kvm/arm/setup.c                                          | 2 +-
>   plat/kvm/memory.c                                             | 2 +-
>   plat/kvm/x86/setup.c                                          | 2 +-
>   plat/xen/arm/setup.c                                          | 2 +-
>   plat/xen/include/xen-arm/mm.h                                 | 2 +-
>   plat/xen/include/xen-x86/mm.h                                 | 2 +-
>   plat/xen/memory.c                                             | 2 +-
>   plat/xen/x86/mm.c                                             | 2 +-
>   10 files changed, 9 insertions(+), 9 deletions(-)
>   rename {plat/common/include/uk/plat/common => include/uk}/sections.h (100%)
> 
> diff --git a/plat/common/include/uk/plat/common/sections.h b/include/uk/sections.h
> similarity index 100%
> rename from plat/common/include/uk/plat/common/sections.h
> rename to include/uk/sections.h
> diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S
> index c4de334c..8be3d59f 100644
> --- a/plat/kvm/arm/entry64.S
> +++ b/plat/kvm/arm/entry64.S
> @@ -35,7 +35,7 @@
>   #include <uk/asm.h>
>   #include <kvm-arm/mm.h>
>   #include <arm/cpu_defs.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>   #include <uk/config.h>
> 
>   .global page_table_size
> diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
> index 41e63755..8513b48c 100644
> --- a/plat/kvm/arm/setup.c
> +++ b/plat/kvm/arm/setup.c
> @@ -20,7 +20,7 @@
>    */
>   #include <uk/config.h>
>   #include <libfdt.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>   #include <kvm/console.h>
>   #include <kvm/config.h>
>   #include <uk/assert.h>
> diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
> index 1d9269ec..61d3e6ca 100644
> --- a/plat/kvm/memory.c
> +++ b/plat/kvm/memory.c
> @@ -19,7 +19,7 @@
>    * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>    */
> 
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>   #include <sys/types.h>
>   #include <uk/plat/memory.h>
>   #include <uk/assert.h>
> diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c
> index 9c7a93a8..1cab0a63 100644
> --- a/plat/kvm/x86/setup.c
> +++ b/plat/kvm/x86/setup.c
> @@ -27,7 +27,7 @@
>    */
> 
>   #include <string.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>   #include <x86/cpu.h>
>   #include <x86/traps.h>
>   #include <kvm/config.h>
> diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
> index 2df3b46c..bcbc939e 100644
> --- a/plat/xen/arm/setup.c
> +++ b/plat/xen/arm/setup.c
> @@ -25,7 +25,7 @@
>   /* Ported from Mini-OS */
> 
>   #include <string.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>   #include <xen-arm/os.h>
>   #include <xen-arm/mm.h>
>   #include <xen/xen.h>
> diff --git a/plat/xen/include/xen-arm/mm.h b/plat/xen/include/xen-arm/mm.h
> index 659de843..bbd31ddd 100644
> --- a/plat/xen/include/xen-arm/mm.h
> +++ b/plat/xen/include/xen-arm/mm.h
> @@ -28,7 +28,7 @@
>   #define _ARCH_MM_H_
> 
>   #include <stdint.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>   #include <uk/arch/limits.h>
> 
>   typedef uint64_t paddr_t;
> diff --git a/plat/xen/include/xen-x86/mm.h b/plat/xen/include/xen-x86/mm.h
> index ffbedb09..99ba6d05 100644
> --- a/plat/xen/include/xen-x86/mm.h
> +++ b/plat/xen/include/xen-x86/mm.h
> @@ -25,7 +25,7 @@
>   #ifndef _ARCH_MM_H_
>   #define _ARCH_MM_H_
> 
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>   #ifndef __ASSEMBLY__
>   #include <xen/xen.h>
>   #if defined(__i386__)
> diff --git a/plat/xen/memory.c b/plat/xen/memory.c
> index 8e7a7dda..27a317c4 100644
> --- a/plat/xen/memory.c
> +++ b/plat/xen/memory.c
> @@ -34,7 +34,7 @@
>    */
> 
>   #include <string.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
> 
>   #include <common/gnttab.h>
>   #if (defined __X86_32__) || (defined __X86_64__)
> diff --git a/plat/xen/x86/mm.c b/plat/xen/x86/mm.c
> index e006ab7f..9e352eed 100644
> --- a/plat/xen/x86/mm.c
> +++ b/plat/xen/x86/mm.c
> @@ -36,7 +36,7 @@
>    */
> 
>   #include <string.h>
> -#include <uk/plat/common/sections.h>
> +#include <uk/sections.h>
>   #include <errno.h>
>   #include <uk/alloc.h>
>   #include <uk/plat/config.h>
> --
> 2.29.0
> 
> 


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 13:19:12 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 13:19:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13600.34292 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXlM7-0001ri-CY; Wed, 28 Oct 2020 13:19:11 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13600.34292; Wed, 28 Oct 2020 13:19:11 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXlM7-0001ra-9a; Wed, 28 Oct 2020 13:19:11 +0000
Received: by outflank-mailman (input) for mailman id 13600;
 Wed, 28 Oct 2020 13: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=xQ4D=ED=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kXlM6-0001qs-O0
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 13:19:10 +0000
Received: from mx.upb.ro (unknown [141.85.13.210])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 8895c932-d652-478f-83c4-6496ff6ad4ee;
 Wed, 28 Oct 2020 13:19:08 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id A880FB560093;
 Wed, 28 Oct 2020 15:19:07 +0200 (EET)
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 NezwBCgjkTDm; Wed, 28 Oct 2020 15:19:04 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id D4BBBB561D11;
 Wed, 28 Oct 2020 15:19:04 +0200 (EET)
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 U38r9mIifo9D; Wed, 28 Oct 2020 15:19:04 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id 7E74AB560093;
 Wed, 28 Oct 2020 15:19:04 +0200 (EET)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=xQ4D=ED=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kXlM6-0001qs-O0
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 13:19:10 +0000
X-Inumbo-ID: 8895c932-d652-478f-83c4-6496ff6ad4ee
Received: from mx.upb.ro (unknown [141.85.13.210])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 8895c932-d652-478f-83c4-6496ff6ad4ee;
	Wed, 28 Oct 2020 13:19:08 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id A880FB560093;
	Wed, 28 Oct 2020 15:19:07 +0200 (EET)
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 NezwBCgjkTDm; Wed, 28 Oct 2020 15:19:04 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id D4BBBB561D11;
	Wed, 28 Oct 2020 15:19:04 +0200 (EET)
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 U38r9mIifo9D; Wed, 28 Oct 2020 15:19:04 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id 7E74AB560093;
	Wed, 28 Oct 2020 15:19:04 +0200 (EET)
Subject: Re: [UNIKRAFT PATCH v2] include: Move sections.h to include/uk
To: Simon Kuenzer <simon.kuenzer@neclab.eu>, stefanl.teodorescu@gmail.com,
 minios-devel@lists.xen.org
References: <20201026161455.298231-1-stefanl.teodorescu@gmail.com>
 <cd39a36f-0e1a-0b90-3107-f2666d98a1c3@neclab.eu>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <26b619c3-299c-b1aa-23f6-b0df5443550c@cs.pub.ro>
Date: Wed, 28 Oct 2020 15:19:04 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <cd39a36f-0e1a-0b90-3107-f2666d98a1c3@neclab.eu>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

Hi Simon,

Regardless whether these changes are needed or not by arch code (I'll
leave that for =C8=98tefan to explain), the definitions in sections.h sho=
uld
stay under include/uk in order to be accessible from everywhere.
Moreover, the definitions in it are related to neither arch or platform.

Cheers,
Costin

On 10/28/20 3:14 PM, Simon Kuenzer wrote:
> Hey Stefan, hey Costin,
>=20
> what is the reason that arch code needs sections.h? I can't read it fro=
m
> the commit message. Architecture code should only be the parts that are
> totally independent on the platform details. They are mostly helpers fo=
r
> arithmetics and CPU register definitions. I am concerned that
> architecture code may break when doing assumptions on symbol locations;
> imagine ASLR where locations are moved at runtime.
>=20
> The NX bit patch is upstream.
>=20
> Thanks,
>=20
> Simon
>=20
> On 26.10.20 17:14, stefanl.teodorescu@gmail.com wrote:
>> From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
>>
>> Move plat/common/include/uk/plat/common/sections.h to
>> include/uk/sections.h to be able to include it in arch code. This file
>> is platform independent, so it does not affect anything.
>>
>> Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
>> ---
>> =C2=A0 {plat/common/include/uk/plat/common =3D> include/uk}/sections.h=
 | 0
>> =C2=A0 plat/kvm/arm/entry64.S=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=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 | 2 +-
>> =C2=A0 plat/kvm/arm/setup.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=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=C2=A0=C2=A0 | 2 +-
>> =C2=A0 plat/kvm/memory.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=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 2 +-
>> =C2=A0 plat/kvm/x86/setup.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=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=C2=A0=C2=A0 | 2 +-
>> =C2=A0 plat/xen/arm/setup.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=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=C2=A0=C2=A0 | 2 +-
>> =C2=A0 plat/xen/include/xen-arm/mm.h=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=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 plat/xen/include/xen-x86/mm.h=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=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 plat/xen/memory.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=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 2 +-
>> =C2=A0 plat/xen/x86/mm.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=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 2 +-
>> =C2=A0 10 files changed, 9 insertions(+), 9 deletions(-)
>> =C2=A0 rename {plat/common/include/uk/plat/common =3D> include/uk}/sec=
tions.h
>> (100%)
>>
>> diff --git a/plat/common/include/uk/plat/common/sections.h
>> b/include/uk/sections.h
>> similarity index 100%
>> rename from plat/common/include/uk/plat/common/sections.h
>> rename to include/uk/sections.h
>> diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S
>> index c4de334c..8be3d59f 100644
>> --- a/plat/kvm/arm/entry64.S
>> +++ b/plat/kvm/arm/entry64.S
>> @@ -35,7 +35,7 @@
>> =C2=A0 #include <uk/asm.h>
>> =C2=A0 #include <kvm-arm/mm.h>
>> =C2=A0 #include <arm/cpu_defs.h>
>> -#include <uk/plat/common/sections.h>
>> +#include <uk/sections.h>
>> =C2=A0 #include <uk/config.h>
>>
>> =C2=A0 .global page_table_size
>> diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
>> index 41e63755..8513b48c 100644
>> --- a/plat/kvm/arm/setup.c
>> +++ b/plat/kvm/arm/setup.c
>> @@ -20,7 +20,7 @@
>> =C2=A0=C2=A0 */
>> =C2=A0 #include <uk/config.h>
>> =C2=A0 #include <libfdt.h>
>> -#include <uk/plat/common/sections.h>
>> +#include <uk/sections.h>
>> =C2=A0 #include <kvm/console.h>
>> =C2=A0 #include <kvm/config.h>
>> =C2=A0 #include <uk/assert.h>
>> diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
>> index 1d9269ec..61d3e6ca 100644
>> --- a/plat/kvm/memory.c
>> +++ b/plat/kvm/memory.c
>> @@ -19,7 +19,7 @@
>> =C2=A0=C2=A0 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE=
.
>> =C2=A0=C2=A0 */
>>
>> -#include <uk/plat/common/sections.h>
>> +#include <uk/sections.h>
>> =C2=A0 #include <sys/types.h>
>> =C2=A0 #include <uk/plat/memory.h>
>> =C2=A0 #include <uk/assert.h>
>> diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c
>> index 9c7a93a8..1cab0a63 100644
>> --- a/plat/kvm/x86/setup.c
>> +++ b/plat/kvm/x86/setup.c
>> @@ -27,7 +27,7 @@
>> =C2=A0=C2=A0 */
>>
>> =C2=A0 #include <string.h>
>> -#include <uk/plat/common/sections.h>
>> +#include <uk/sections.h>
>> =C2=A0 #include <x86/cpu.h>
>> =C2=A0 #include <x86/traps.h>
>> =C2=A0 #include <kvm/config.h>
>> diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
>> index 2df3b46c..bcbc939e 100644
>> --- a/plat/xen/arm/setup.c
>> +++ b/plat/xen/arm/setup.c
>> @@ -25,7 +25,7 @@
>> =C2=A0 /* Ported from Mini-OS */
>>
>> =C2=A0 #include <string.h>
>> -#include <uk/plat/common/sections.h>
>> +#include <uk/sections.h>
>> =C2=A0 #include <xen-arm/os.h>
>> =C2=A0 #include <xen-arm/mm.h>
>> =C2=A0 #include <xen/xen.h>
>> diff --git a/plat/xen/include/xen-arm/mm.h
>> b/plat/xen/include/xen-arm/mm.h
>> index 659de843..bbd31ddd 100644
>> --- a/plat/xen/include/xen-arm/mm.h
>> +++ b/plat/xen/include/xen-arm/mm.h
>> @@ -28,7 +28,7 @@
>> =C2=A0 #define _ARCH_MM_H_
>>
>> =C2=A0 #include <stdint.h>
>> -#include <uk/plat/common/sections.h>
>> +#include <uk/sections.h>
>> =C2=A0 #include <uk/arch/limits.h>
>>
>> =C2=A0 typedef uint64_t paddr_t;
>> diff --git a/plat/xen/include/xen-x86/mm.h
>> b/plat/xen/include/xen-x86/mm.h
>> index ffbedb09..99ba6d05 100644
>> --- a/plat/xen/include/xen-x86/mm.h
>> +++ b/plat/xen/include/xen-x86/mm.h
>> @@ -25,7 +25,7 @@
>> =C2=A0 #ifndef _ARCH_MM_H_
>> =C2=A0 #define _ARCH_MM_H_
>>
>> -#include <uk/plat/common/sections.h>
>> +#include <uk/sections.h>
>> =C2=A0 #ifndef __ASSEMBLY__
>> =C2=A0 #include <xen/xen.h>
>> =C2=A0 #if defined(__i386__)
>> diff --git a/plat/xen/memory.c b/plat/xen/memory.c
>> index 8e7a7dda..27a317c4 100644
>> --- a/plat/xen/memory.c
>> +++ b/plat/xen/memory.c
>> @@ -34,7 +34,7 @@
>> =C2=A0=C2=A0 */
>>
>> =C2=A0 #include <string.h>
>> -#include <uk/plat/common/sections.h>
>> +#include <uk/sections.h>
>>
>> =C2=A0 #include <common/gnttab.h>
>> =C2=A0 #if (defined __X86_32__) || (defined __X86_64__)
>> diff --git a/plat/xen/x86/mm.c b/plat/xen/x86/mm.c
>> index e006ab7f..9e352eed 100644
>> --- a/plat/xen/x86/mm.c
>> +++ b/plat/xen/x86/mm.c
>> @@ -36,7 +36,7 @@
>> =C2=A0=C2=A0 */
>>
>> =C2=A0 #include <string.h>
>> -#include <uk/plat/common/sections.h>
>> +#include <uk/sections.h>
>> =C2=A0 #include <errno.h>
>> =C2=A0 #include <uk/alloc.h>
>> =C2=A0 #include <uk/plat/config.h>
>> --=20
>> 2.29.0
>>
>>


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 13:45:29 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 13:45:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13609.34309 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXllY-0004QA-Cd; Wed, 28 Oct 2020 13:45:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13609.34309; Wed, 28 Oct 2020 13:45:28 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXllY-0004Q3-9R; Wed, 28 Oct 2020 13:45:28 +0000
Received: by outflank-mailman (input) for mailman id 13609;
 Wed, 28 Oct 2020 13:45: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=UbzB=ED=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
 id 1kXllX-0004Py-E4
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 13:45:27 +0000
Received: from mail-lf1-x142.google.com (unknown [2a00:1450:4864:20::142])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d1b28f50-5c10-451f-a94f-b7f199c796a4;
 Wed, 28 Oct 2020 13:45:23 +0000 (UTC)
Received: by mail-lf1-x142.google.com with SMTP id i6so2364915lfd.1
 for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 06:45:23 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=UbzB=ED=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
	id 1kXllX-0004Py-E4
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 13:45:27 +0000
X-Inumbo-ID: d1b28f50-5c10-451f-a94f-b7f199c796a4
Received: from mail-lf1-x142.google.com (unknown [2a00:1450:4864:20::142])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id d1b28f50-5c10-451f-a94f-b7f199c796a4;
	Wed, 28 Oct 2020 13:45:23 +0000 (UTC)
Received: by mail-lf1-x142.google.com with SMTP id i6so2364915lfd.1
        for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 06:45:23 -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:content-transfer-encoding;
        bh=DxjzMYggqXpPz8tNOLWyuibodgp6bZeIdgujWlSCioM=;
        b=MN60njHompoWdAnkrKQJ8Hy9N8f0jpJa5iJ+JHi1zhURXADZrFJESnN2pkYvSWUBkr
         cjmm+5JlXRghh7caV09OgVt/TeZ2HxJnLZO34AvwzeJPNrjkuVrASsK0bjZhwGEjBODD
         3W9Q5OppMyxwnSFicClDN/ERvCiXJl98+iV/NbEzDMklQNDktELdAqs+6jPeZGpZi4Oc
         Kf0Yb0gFynEZ1SjAcV3MdcYiOH6mPU/ZYDyGXTv2/iD6Heb4BKfmQuLvRFuobagLeAoN
         WFMsEJ5cNCo7bWQW+KGK5eUHq0ao5TKGujZT5m3eyIz6+el0a7+1AwVbYE4+TKVvgS7M
         bS7A==
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:content-transfer-encoding;
        bh=DxjzMYggqXpPz8tNOLWyuibodgp6bZeIdgujWlSCioM=;
        b=CoRvnzp+kQ4L2UYJ0JwpbC8ImLMcnPSdGUfEu9pLXfqzY/tQSgMt3bK/CEYkORWU05
         J/P2Jiprd7LkTVCWK2PZlaEOvUKRaxD3CHfpg+UmAUbdHctSyVOU7oUl1yvbR3mqrY76
         NSZaKUgGKu+QQMTtvjZOmunsqaX2KhAfpx+9kKP/pmhWr2A+w/Phh6GlRw3foFAohawM
         jbMp8KvV0ABaYBpMzDScbOaZN9gDVCwyJEjJ54JFJ3TtoDbWDlF9SidcnCirdyUul/v1
         3yu5yFf2GgMhmEaOkl+LIsEyb5mbgxylmx9zlUbhRrhncN+sU40Vi+sVw5MF/je0Cl5k
         sobQ==
X-Gm-Message-State: AOAM532XIpMDFEnMLnzFfzLavwfCtrkJt0FXUVqKvBl9RiN7JtjfQdtu
	nznmqbcEDM3i3fbdw/ftEHCMVMjaVVjmTnqhqIs=
X-Google-Smtp-Source: ABdhPJxm+36WJdnNoZPjDy1Pat3aypBbYq7LjKjrXnAycOQ2WTLz4kYJlX5DN3CqNmliXCKZuAmntfAlaUEjmVJCdeU=
X-Received: by 2002:a19:84d3:: with SMTP id g202mr2886465lfd.346.1603892721666;
 Wed, 28 Oct 2020 06:45:21 -0700 (PDT)
MIME-Version: 1.0
References: <20201026161455.298231-1-stefanl.teodorescu@gmail.com>
 <cd39a36f-0e1a-0b90-3107-f2666d98a1c3@neclab.eu> <26b619c3-299c-b1aa-23f6-b0df5443550c@cs.pub.ro>
In-Reply-To: <26b619c3-299c-b1aa-23f6-b0df5443550c@cs.pub.ro>
From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
Date: Wed, 28 Oct 2020 15:45:10 +0200
Message-ID: <CAEiTdV77aNL280eDjTikQUtYLL6cnVkLSRhhozFi9tctHSPpEw@mail.gmail.com>
Subject: Re: [UNIKRAFT PATCH v2] include: Move sections.h to include/uk
To: Costin Lupu <costin.lupu@cs.pub.ro>
Cc: Simon Kuenzer <simon.kuenzer@neclab.eu>, minios-devel@lists.xen.org
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi everyone,

Sorry for the confusion, this is my fault that I didn't clarify enough
in the commit message and that I didn't update it in the meantime.

I am using the sections.h header in the mem_layout.h header (which is
also in include/uk) that I am writing now to describe the virtual
memory areas (kernel, stack, heap etc.). At the moment, I think I was
using the sections.h header in some arch code but this is not the case
anymore. However, as Costin mentioned, we thought at the time that we
could move this anyway, since it's not actually platform dependent.

I'll send a v2 with an updated commit message.

Thanks,
Stefan



On Wed, Oct 28, 2020 at 3:19 PM Costin Lupu <costin.lupu@cs.pub.ro> wrote:
>
> Hi Simon,
>
> Regardless whether these changes are needed or not by arch code (I'll
> leave that for =C8=98tefan to explain), the definitions in sections.h sho=
uld
> stay under include/uk in order to be accessible from everywhere.
> Moreover, the definitions in it are related to neither arch or platform.
>
> Cheers,
> Costin
>
> On 10/28/20 3:14 PM, Simon Kuenzer wrote:
> > Hey Stefan, hey Costin,
> >
> > what is the reason that arch code needs sections.h? I can't read it fro=
m
> > the commit message. Architecture code should only be the parts that are
> > totally independent on the platform details. They are mostly helpers fo=
r
> > arithmetics and CPU register definitions. I am concerned that
> > architecture code may break when doing assumptions on symbol locations;
> > imagine ASLR where locations are moved at runtime.
> >
> > The NX bit patch is upstream.
> >
> > Thanks,
> >
> > Simon
> >
> > On 26.10.20 17:14, stefanl.teodorescu@gmail.com wrote:
> >> From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> >>
> >> Move plat/common/include/uk/plat/common/sections.h to
> >> include/uk/sections.h to be able to include it in arch code. This file
> >> is platform independent, so it does not affect anything.
> >>
> >> Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> >> ---
> >>   {plat/common/include/uk/plat/common =3D> include/uk}/sections.h | 0
> >>   plat/kvm/arm/entry64.S                                        | 2 +-
> >>   plat/kvm/arm/setup.c                                          | 2 +-
> >>   plat/kvm/memory.c                                             | 2 +-
> >>   plat/kvm/x86/setup.c                                          | 2 +-
> >>   plat/xen/arm/setup.c                                          | 2 +-
> >>   plat/xen/include/xen-arm/mm.h                                 | 2 +-
> >>   plat/xen/include/xen-x86/mm.h                                 | 2 +-
> >>   plat/xen/memory.c                                             | 2 +-
> >>   plat/xen/x86/mm.c                                             | 2 +-
> >>   10 files changed, 9 insertions(+), 9 deletions(-)
> >>   rename {plat/common/include/uk/plat/common =3D> include/uk}/sections=
.h
> >> (100%)
> >>
> >> diff --git a/plat/common/include/uk/plat/common/sections.h
> >> b/include/uk/sections.h
> >> similarity index 100%
> >> rename from plat/common/include/uk/plat/common/sections.h
> >> rename to include/uk/sections.h
> >> diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S
> >> index c4de334c..8be3d59f 100644
> >> --- a/plat/kvm/arm/entry64.S
> >> +++ b/plat/kvm/arm/entry64.S
> >> @@ -35,7 +35,7 @@
> >>   #include <uk/asm.h>
> >>   #include <kvm-arm/mm.h>
> >>   #include <arm/cpu_defs.h>
> >> -#include <uk/plat/common/sections.h>
> >> +#include <uk/sections.h>
> >>   #include <uk/config.h>
> >>
> >>   .global page_table_size
> >> diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
> >> index 41e63755..8513b48c 100644
> >> --- a/plat/kvm/arm/setup.c
> >> +++ b/plat/kvm/arm/setup.c
> >> @@ -20,7 +20,7 @@
> >>    */
> >>   #include <uk/config.h>
> >>   #include <libfdt.h>
> >> -#include <uk/plat/common/sections.h>
> >> +#include <uk/sections.h>
> >>   #include <kvm/console.h>
> >>   #include <kvm/config.h>
> >>   #include <uk/assert.h>
> >> diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
> >> index 1d9269ec..61d3e6ca 100644
> >> --- a/plat/kvm/memory.c
> >> +++ b/plat/kvm/memory.c
> >> @@ -19,7 +19,7 @@
> >>    * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> >>    */
> >>
> >> -#include <uk/plat/common/sections.h>
> >> +#include <uk/sections.h>
> >>   #include <sys/types.h>
> >>   #include <uk/plat/memory.h>
> >>   #include <uk/assert.h>
> >> diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c
> >> index 9c7a93a8..1cab0a63 100644
> >> --- a/plat/kvm/x86/setup.c
> >> +++ b/plat/kvm/x86/setup.c
> >> @@ -27,7 +27,7 @@
> >>    */
> >>
> >>   #include <string.h>
> >> -#include <uk/plat/common/sections.h>
> >> +#include <uk/sections.h>
> >>   #include <x86/cpu.h>
> >>   #include <x86/traps.h>
> >>   #include <kvm/config.h>
> >> diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
> >> index 2df3b46c..bcbc939e 100644
> >> --- a/plat/xen/arm/setup.c
> >> +++ b/plat/xen/arm/setup.c
> >> @@ -25,7 +25,7 @@
> >>   /* Ported from Mini-OS */
> >>
> >>   #include <string.h>
> >> -#include <uk/plat/common/sections.h>
> >> +#include <uk/sections.h>
> >>   #include <xen-arm/os.h>
> >>   #include <xen-arm/mm.h>
> >>   #include <xen/xen.h>
> >> diff --git a/plat/xen/include/xen-arm/mm.h
> >> b/plat/xen/include/xen-arm/mm.h
> >> index 659de843..bbd31ddd 100644
> >> --- a/plat/xen/include/xen-arm/mm.h
> >> +++ b/plat/xen/include/xen-arm/mm.h
> >> @@ -28,7 +28,7 @@
> >>   #define _ARCH_MM_H_
> >>
> >>   #include <stdint.h>
> >> -#include <uk/plat/common/sections.h>
> >> +#include <uk/sections.h>
> >>   #include <uk/arch/limits.h>
> >>
> >>   typedef uint64_t paddr_t;
> >> diff --git a/plat/xen/include/xen-x86/mm.h
> >> b/plat/xen/include/xen-x86/mm.h
> >> index ffbedb09..99ba6d05 100644
> >> --- a/plat/xen/include/xen-x86/mm.h
> >> +++ b/plat/xen/include/xen-x86/mm.h
> >> @@ -25,7 +25,7 @@
> >>   #ifndef _ARCH_MM_H_
> >>   #define _ARCH_MM_H_
> >>
> >> -#include <uk/plat/common/sections.h>
> >> +#include <uk/sections.h>
> >>   #ifndef __ASSEMBLY__
> >>   #include <xen/xen.h>
> >>   #if defined(__i386__)
> >> diff --git a/plat/xen/memory.c b/plat/xen/memory.c
> >> index 8e7a7dda..27a317c4 100644
> >> --- a/plat/xen/memory.c
> >> +++ b/plat/xen/memory.c
> >> @@ -34,7 +34,7 @@
> >>    */
> >>
> >>   #include <string.h>
> >> -#include <uk/plat/common/sections.h>
> >> +#include <uk/sections.h>
> >>
> >>   #include <common/gnttab.h>
> >>   #if (defined __X86_32__) || (defined __X86_64__)
> >> diff --git a/plat/xen/x86/mm.c b/plat/xen/x86/mm.c
> >> index e006ab7f..9e352eed 100644
> >> --- a/plat/xen/x86/mm.c
> >> +++ b/plat/xen/x86/mm.c
> >> @@ -36,7 +36,7 @@
> >>    */
> >>
> >>   #include <string.h>
> >> -#include <uk/plat/common/sections.h>
> >> +#include <uk/sections.h>
> >>   #include <errno.h>
> >>   #include <uk/alloc.h>
> >>   #include <uk/plat/config.h>
> >> --
> >> 2.29.0
> >>
> >>


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 14:26:32 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 14:26:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13623.34325 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXmPD-0007we-Or; Wed, 28 Oct 2020 14:26:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13623.34325; Wed, 28 Oct 2020 14:26:27 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXmPD-0007wX-Ld; Wed, 28 Oct 2020 14:26:27 +0000
Received: by outflank-mailman (input) for mailman id 13623;
 Wed, 28 Oct 2020 14:26:26 +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=oDhg=ED=opensynergy.com=michalis.pappas@srs-us1.protection.inumbo.net>)
 id 1kXmPC-0007wS-4R
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 14:26:26 +0000
Received: from plasma4.jpberlin.de (unknown [80.241.57.33])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id c3549bf9-a22d-4dec-a1d8-a297f3426087;
 Wed, 28 Oct 2020 14:26:22 +0000 (UTC)
Received: from spamfilter05.heinlein-hosting.de
 (spamfilter05.heinlein-hosting.de [80.241.56.123])
 by plasma.jpberlin.de (Postfix) with ESMTP id 0A197ABC34;
 Wed, 28 Oct 2020 15:26:17 +0100 (CET)
Received: from plasma.jpberlin.de ([80.241.56.68])
 by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de
 [80.241.56.123]) (amavisd-new, port 10030)
 with ESMTP id wkoLdHGu8Xun; Wed, 28 Oct 2020 15:26:15 +0100 (CET)
Received: from webmail.opensynergy.com (unknown [217.66.60.5])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))
 (Client CN "*.opensynergy.com",
 Issuer "Starfield Secure Certificate Authority - G2" (not verified))
 (Authenticated sender: opensynergy@jpberlin.de)
 by plasma.jpberlin.de (Postfix) with ESMTPSA id 7FC74ABE09;
 Wed, 28 Oct 2020 15:26:15 +0100 (CET)
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=oDhg=ED=opensynergy.com=michalis.pappas@srs-us1.protection.inumbo.net>)
	id 1kXmPC-0007wS-4R
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 14:26:26 +0000
X-Inumbo-ID: c3549bf9-a22d-4dec-a1d8-a297f3426087
Received: from plasma4.jpberlin.de (unknown [80.241.57.33])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id c3549bf9-a22d-4dec-a1d8-a297f3426087;
	Wed, 28 Oct 2020 14:26:22 +0000 (UTC)
Received: from spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123])
	by plasma.jpberlin.de (Postfix) with ESMTP id 0A197ABC34;
	Wed, 28 Oct 2020 15:26:17 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from plasma.jpberlin.de ([80.241.56.68])
	by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030)
	with ESMTP id wkoLdHGu8Xun; Wed, 28 Oct 2020 15:26:15 +0100 (CET)
Received: from webmail.opensynergy.com (unknown [217.66.60.5])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))
	(Client CN "*.opensynergy.com", Issuer "Starfield Secure Certificate Authority - G2" (not verified))
	(Authenticated sender: opensynergy@jpberlin.de)
	by plasma.jpberlin.de (Postfix) with ESMTPSA id 7FC74ABE09;
	Wed, 28 Oct 2020 15:26:15 +0100 (CET)
Subject: Re: [UNIKRAFT PATCH v2] include: Move sections.h to include/uk
To: Stefan Teodorescu <stefanl.teodorescu@gmail.com>, Costin Lupu
	<costin.lupu@cs.pub.ro>
CC: Simon Kuenzer <simon.kuenzer@neclab.eu>, <minios-devel@lists.xen.org>
References: <20201026161455.298231-1-stefanl.teodorescu@gmail.com>
 <cd39a36f-0e1a-0b90-3107-f2666d98a1c3@neclab.eu>
 <26b619c3-299c-b1aa-23f6-b0df5443550c@cs.pub.ro>
 <CAEiTdV77aNL280eDjTikQUtYLL6cnVkLSRhhozFi9tctHSPpEw@mail.gmail.com>
From: Michalis Pappas <michalis.pappas@opensynergy.com>
Message-ID: <214ca2dd-2b50-3b37-8cca-737677a0c311@opensynergy.com>
Date: Wed, 28 Oct 2020 15:26:13 +0100
MIME-Version: 1.0
In-Reply-To: <CAEiTdV77aNL280eDjTikQUtYLL6cnVkLSRhhozFi9tctHSPpEw@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-US
X-ClientProxiedBy: SR-MAIL-01.open-synergy.com (10.26.10.21) To
 SR-MAIL-02.open-synergy.com (10.26.10.22)
X-MBO-SPAM-Probability: 
X-Rspamd-Score: -6.51 / 15.00 / 15.00
X-Rspamd-Queue-Id: 0A197ABC34
X-Rspamd-UID: b83f5f

Before exposing sections.h to applications, I would like to take the 
opportunity to discuss some architectural matters.

Currently linker scripts and their associated symbol definitions are 
owned by platforms. At the same time, sections.h is under plat/common/, 
and contains some common symbol names that are more or less declared by 
all platforms. Platforms wishing to declare additional, and perhaps less 
common symbol names, have the option to either (1) pollute sections.h, 
or (2) add these symbols to a platform-specific header. In case (1) 
sections.h will eventually contain a superset of all section symbols 
declared by all platforms, which is dirty. In case (2) platforms lose 
the ability to export their additional symbols to applications, which is 
also a problem.

One possible approach to work around this would be to make symbols.h 
platform-specific, and then allow platforms to export platform-specific 
headers under platform subdirectories in include/uk/plat/ (eg 
include/uk/plat/kvm/sections.h), or alternatively export the current 
sections.h through include/uk/ and export additional platform-specific 
headers through platform subdirectories in include/uk/plat/, as above.

Thanks,

Michalis

On 28/10/2020 14:45, Stefan Teodorescu wrote:
> Hi everyone,
>
> Sorry for the confusion, this is my fault that I didn't clarify enough
> in the commit message and that I didn't update it in the meantime.
>
> I am using the sections.h header in the mem_layout.h header (which is
> also in include/uk) that I am writing now to describe the virtual
> memory areas (kernel, stack, heap etc.). At the moment, I think I was
> using the sections.h header in some arch code but this is not the case
> anymore. However, as Costin mentioned, we thought at the time that we
> could move this anyway, since it's not actually platform dependent.
>
> I'll send a v2 with an updated commit message.
>
> Thanks,
> Stefan
>
>
>
> On Wed, Oct 28, 2020 at 3:19 PM Costin Lupu <costin.lupu@cs.pub.ro> wrote:
>> Hi Simon,
>>
>> Regardless whether these changes are needed or not by arch code (I'll
>> leave that for Ștefan to explain), the definitions in sections.h should
>> stay under include/uk in order to be accessible from everywhere.
>> Moreover, the definitions in it are related to neither arch or platform.
>>
>> Cheers,
>> Costin
>>
>> On 10/28/20 3:14 PM, Simon Kuenzer wrote:
>>> Hey Stefan, hey Costin,
>>>
>>> what is the reason that arch code needs sections.h? I can't read it from
>>> the commit message. Architecture code should only be the parts that are
>>> totally independent on the platform details. They are mostly helpers for
>>> arithmetics and CPU register definitions. I am concerned that
>>> architecture code may break when doing assumptions on symbol locations;
>>> imagine ASLR where locations are moved at runtime.
>>>
>>> The NX bit patch is upstream.
>>>
>>> Thanks,
>>>
>>> Simon
>>>
>>> On 26.10.20 17:14, stefanl.teodorescu@gmail.com wrote:
>>>> From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
>>>>
>>>> Move plat/common/include/uk/plat/common/sections.h to
>>>> include/uk/sections.h to be able to include it in arch code. This file
>>>> is platform independent, so it does not affect anything.
>>>>
>>>> Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
>>>> ---
>>>>    {plat/common/include/uk/plat/common => include/uk}/sections.h | 0
>>>>    plat/kvm/arm/entry64.S                                        | 2 +-
>>>>    plat/kvm/arm/setup.c                                          | 2 +-
>>>>    plat/kvm/memory.c                                             | 2 +-
>>>>    plat/kvm/x86/setup.c                                          | 2 +-
>>>>    plat/xen/arm/setup.c                                          | 2 +-
>>>>    plat/xen/include/xen-arm/mm.h                                 | 2 +-
>>>>    plat/xen/include/xen-x86/mm.h                                 | 2 +-
>>>>    plat/xen/memory.c                                             | 2 +-
>>>>    plat/xen/x86/mm.c                                             | 2 +-
>>>>    10 files changed, 9 insertions(+), 9 deletions(-)
>>>>    rename {plat/common/include/uk/plat/common => include/uk}/sections.h
>>>> (100%)
>>>>
>>>> diff --git a/plat/common/include/uk/plat/common/sections.h
>>>> b/include/uk/sections.h
>>>> similarity index 100%
>>>> rename from plat/common/include/uk/plat/common/sections.h
>>>> rename to include/uk/sections.h
>>>> diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S
>>>> index c4de334c..8be3d59f 100644
>>>> --- a/plat/kvm/arm/entry64.S
>>>> +++ b/plat/kvm/arm/entry64.S
>>>> @@ -35,7 +35,7 @@
>>>>    #include <uk/asm.h>
>>>>    #include <kvm-arm/mm.h>
>>>>    #include <arm/cpu_defs.h>
>>>> -#include <uk/plat/common/sections.h>
>>>> +#include <uk/sections.h>
>>>>    #include <uk/config.h>
>>>>
>>>>    .global page_table_size
>>>> diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
>>>> index 41e63755..8513b48c 100644
>>>> --- a/plat/kvm/arm/setup.c
>>>> +++ b/plat/kvm/arm/setup.c
>>>> @@ -20,7 +20,7 @@
>>>>     */
>>>>    #include <uk/config.h>
>>>>    #include <libfdt.h>
>>>> -#include <uk/plat/common/sections.h>
>>>> +#include <uk/sections.h>
>>>>    #include <kvm/console.h>
>>>>    #include <kvm/config.h>
>>>>    #include <uk/assert.h>
>>>> diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
>>>> index 1d9269ec..61d3e6ca 100644
>>>> --- a/plat/kvm/memory.c
>>>> +++ b/plat/kvm/memory.c
>>>> @@ -19,7 +19,7 @@
>>>>     * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>>>>     */
>>>>
>>>> -#include <uk/plat/common/sections.h>
>>>> +#include <uk/sections.h>
>>>>    #include <sys/types.h>
>>>>    #include <uk/plat/memory.h>
>>>>    #include <uk/assert.h>
>>>> diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c
>>>> index 9c7a93a8..1cab0a63 100644
>>>> --- a/plat/kvm/x86/setup.c
>>>> +++ b/plat/kvm/x86/setup.c
>>>> @@ -27,7 +27,7 @@
>>>>     */
>>>>
>>>>    #include <string.h>
>>>> -#include <uk/plat/common/sections.h>
>>>> +#include <uk/sections.h>
>>>>    #include <x86/cpu.h>
>>>>    #include <x86/traps.h>
>>>>    #include <kvm/config.h>
>>>> diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
>>>> index 2df3b46c..bcbc939e 100644
>>>> --- a/plat/xen/arm/setup.c
>>>> +++ b/plat/xen/arm/setup.c
>>>> @@ -25,7 +25,7 @@
>>>>    /* Ported from Mini-OS */
>>>>
>>>>    #include <string.h>
>>>> -#include <uk/plat/common/sections.h>
>>>> +#include <uk/sections.h>
>>>>    #include <xen-arm/os.h>
>>>>    #include <xen-arm/mm.h>
>>>>    #include <xen/xen.h>
>>>> diff --git a/plat/xen/include/xen-arm/mm.h
>>>> b/plat/xen/include/xen-arm/mm.h
>>>> index 659de843..bbd31ddd 100644
>>>> --- a/plat/xen/include/xen-arm/mm.h
>>>> +++ b/plat/xen/include/xen-arm/mm.h
>>>> @@ -28,7 +28,7 @@
>>>>    #define _ARCH_MM_H_
>>>>
>>>>    #include <stdint.h>
>>>> -#include <uk/plat/common/sections.h>
>>>> +#include <uk/sections.h>
>>>>    #include <uk/arch/limits.h>
>>>>
>>>>    typedef uint64_t paddr_t;
>>>> diff --git a/plat/xen/include/xen-x86/mm.h
>>>> b/plat/xen/include/xen-x86/mm.h
>>>> index ffbedb09..99ba6d05 100644
>>>> --- a/plat/xen/include/xen-x86/mm.h
>>>> +++ b/plat/xen/include/xen-x86/mm.h
>>>> @@ -25,7 +25,7 @@
>>>>    #ifndef _ARCH_MM_H_
>>>>    #define _ARCH_MM_H_
>>>>
>>>> -#include <uk/plat/common/sections.h>
>>>> +#include <uk/sections.h>
>>>>    #ifndef __ASSEMBLY__
>>>>    #include <xen/xen.h>
>>>>    #if defined(__i386__)
>>>> diff --git a/plat/xen/memory.c b/plat/xen/memory.c
>>>> index 8e7a7dda..27a317c4 100644
>>>> --- a/plat/xen/memory.c
>>>> +++ b/plat/xen/memory.c
>>>> @@ -34,7 +34,7 @@
>>>>     */
>>>>
>>>>    #include <string.h>
>>>> -#include <uk/plat/common/sections.h>
>>>> +#include <uk/sections.h>
>>>>
>>>>    #include <common/gnttab.h>
>>>>    #if (defined __X86_32__) || (defined __X86_64__)
>>>> diff --git a/plat/xen/x86/mm.c b/plat/xen/x86/mm.c
>>>> index e006ab7f..9e352eed 100644
>>>> --- a/plat/xen/x86/mm.c
>>>> +++ b/plat/xen/x86/mm.c
>>>> @@ -36,7 +36,7 @@
>>>>     */
>>>>
>>>>    #include <string.h>
>>>> -#include <uk/plat/common/sections.h>
>>>> +#include <uk/sections.h>
>>>>    #include <errno.h>
>>>>    #include <uk/alloc.h>
>>>>    #include <uk/plat/config.h>
>>>> --
>>>> 2.29.0
>>>>
>>>>
>
-- 
Michalis Pappas
Senior Software Engineer

OpenSynergy GmbH
Rotherstr. 20, 10245 Berlin

p: +49 (30) 60 98 54 0 - 0
f: +49 (30) 60 98 54 0 - 99

e: michalis.pappas@opensynergy.com

w: www.opensynergy.com

registered: Amtsgericht Charlottenburg, HRB 108616B

Handelsregister: Amtsgericht Charlottenburg, HRB 108616B
Geschäftsführer/Managing Director: Regis Adjamah



From minios-devel-bounces@lists.xenproject.org Wed Oct 28 20:09:19 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 20:09:19 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13893.34732 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXrky-0007MN-0a; Wed, 28 Oct 2020 20:09:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13893.34732; Wed, 28 Oct 2020 20:09:15 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXrkx-0007MG-Tz; Wed, 28 Oct 2020 20:09:15 +0000
Received: by outflank-mailman (input) for mailman id 13893;
 Wed, 28 Oct 2020 20:09:15 +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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kXrkx-0007MB-KI
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 20:09:15 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 25eb64c4-41d2-4639-ad24-60626516205e;
 Wed, 28 Oct 2020 20:09:12 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 535AEF2137;
 Wed, 28 Oct 2020 21:09:11 +0100 (CET)
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 GBr89JwDdvpI; Wed, 28 Oct 2020 21:09:11 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 157D4F212C;
 Wed, 28 Oct 2020 21:09:03 +0100 (CET)
Received: from [10.7.2.38] (192.168.24.96) by titania.office.hd
 (192.168.24.89) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 21:09:02 +0100
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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kXrkx-0007MB-KI
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 20:09:15 +0000
X-Inumbo-ID: 25eb64c4-41d2-4639-ad24-60626516205e
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 25eb64c4-41d2-4639-ad24-60626516205e;
	Wed, 28 Oct 2020 20:09:12 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 535AEF2137;
	Wed, 28 Oct 2020 21:09:11 +0100 (CET)
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 GBr89JwDdvpI; Wed, 28 Oct 2020 21:09:11 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 157D4F212C;
	Wed, 28 Oct 2020 21:09:03 +0100 (CET)
Received: from [10.7.2.38] (192.168.24.96) by titania.office.hd
 (192.168.24.89) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 21:09:02 +0100
Subject: Re: [UNIKRAFT PATCH v2] include: Move sections.h to include/uk
To: Michalis Pappas <michalis.pappas@opensynergy.com>, Stefan Teodorescu
	<stefanl.teodorescu@gmail.com>, Costin Lupu <costin.lupu@cs.pub.ro>, Sharan
 Santhanam <sharan.santhanam@neclab.eu>
CC: <minios-devel@lists.xen.org>
References: <20201026161455.298231-1-stefanl.teodorescu@gmail.com>
 <cd39a36f-0e1a-0b90-3107-f2666d98a1c3@neclab.eu>
 <26b619c3-299c-b1aa-23f6-b0df5443550c@cs.pub.ro>
 <CAEiTdV77aNL280eDjTikQUtYLL6cnVkLSRhhozFi9tctHSPpEw@mail.gmail.com>
 <214ca2dd-2b50-3b37-8cca-737677a0c311@opensynergy.com>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <dc168170-1e8b-7cf1-eea9-35ef07799acc@neclab.eu>
Date: Wed, 28 Oct 2020 21:08:39 +0100
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0)
 Gecko/20100101 Thunderbird/68.12.1
MIME-Version: 1.0
In-Reply-To: <214ca2dd-2b50-3b37-8cca-737677a0c311@opensynergy.com>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Hi all,

@Michalis
I think, a problem that we still architecturally have is that we compile 
general purpose libs (like ukboot) once and link them multiple times for 
each selected platform. This implies that exposing platform-specific 
symbols to general purpose code is tricky. In general purpose code, you 
can only rely on symbols that every platform is providing. This is why I 
think that such specific symbols (like _dtb) should stay within the 
platform and should be (indirectly) exported (if at all needed) through 
a driver~ish or query API, something similar we have with the memory 
regions, uknetdev, and ukblkdev. The original idea was to make sure that 
general purpose applications stay portable across different platforms. 
Of course, this consideration does not include the case where you want 
to develop something just for a single platform, like a driver domain 
for Xen which would anyways not be portable to, lets say KVM. For now 
you would be forced to put such code as platform library which isn't 
nice, I agree. I think this needs a solution in general. Maybe the build 
system could behave differently and unlock additional defintions when we 
select only a single platform.

@Stefan
Regarding moving sections.h to the generic `include/` folder, I still 
did not really understand the reason and it is unclear to me what should 
be the defined behavior in case of ASLR. In comparison, what does happen 
with PIE executables on Linux? To my understanding, the linker will 
resolve the symbols with the addresses in the image at compile time. Do 
you know if PIE executables make use of the dynamic linker for 
resolving? In such a case, this is a less problematic point.

Alternatively, would the memory region query interface fit, too? The 
idea of this would to overcome the problem that some things may change 
at runtime (e.g., early platform boot code) compared to compile time.

I think, we have two options:

(1) In the case that the dynamic linker is normally taking care of 
solving such symbols for position-independent executables, I think it 
should be fine to place the header to `include/uk/plat/sections.h`. The 
idea would be to revisit it later when we introduce ASLR. In general we 
should make sure that we define only the symbols in there which all 
platforms linker scripts provide (like the ones for text, bss, etc). 
Platform-specific symbols should stay in the platform, like `_dtb`.

(2) Do not expose section.h to general purpose code and use the memory 
region interface and maybe extend it with what you need.

What do you think?

Thanks,

Simon

On 28.10.20 15:26, Michalis Pappas wrote:
> Before exposing sections.h to applications, I would like to take the 
> opportunity to discuss some architectural matters.
> 
> Currently linker scripts and their associated symbol definitions are 
> owned by platforms. At the same time, sections.h is under plat/common/, 
> and contains some common symbol names that are more or less declared by 
> all platforms. Platforms wishing to declare additional, and perhaps less 
> common symbol names, have the option to either (1) pollute sections.h, 
> or (2) add these symbols to a platform-specific header. In case (1) 
> sections.h will eventually contain a superset of all section symbols 
> declared by all platforms, which is dirty. In case (2) platforms lose 
> the ability to export their additional symbols to applications, which is 
> also a problem.
> 
> One possible approach to work around this would be to make symbols.h 
> platform-specific, and then allow platforms to export platform-specific 
> headers under platform subdirectories in include/uk/plat/ (eg 
> include/uk/plat/kvm/sections.h), or alternatively export the current 
> sections.h through include/uk/ and export additional platform-specific 
> headers through platform subdirectories in include/uk/plat/, as above.
> 
> Thanks,
> 
> Michalis
> 
> On 28/10/2020 14:45, Stefan Teodorescu wrote:
>> Hi everyone,
>>
>> Sorry for the confusion, this is my fault that I didn't clarify enough
>> in the commit message and that I didn't update it in the meantime.
>>
>> I am using the sections.h header in the mem_layout.h header (which is
>> also in include/uk) that I am writing now to describe the virtual
>> memory areas (kernel, stack, heap etc.). At the moment, I think I was
>> using the sections.h header in some arch code but this is not the case
>> anymore. However, as Costin mentioned, we thought at the time that we
>> could move this anyway, since it's not actually platform dependent.
>>
>> I'll send a v2 with an updated commit message.
>>
>> Thanks,
>> Stefan
>>
>>
>>
>> On Wed, Oct 28, 2020 at 3:19 PM Costin Lupu <costin.lupu@cs.pub.ro> 
>> wrote:
>>> Hi Simon,
>>>
>>> Regardless whether these changes are needed or not by arch code (I'll
>>> leave that for Ștefan to explain), the definitions in sections.h should
>>> stay under include/uk in order to be accessible from everywhere.
>>> Moreover, the definitions in it are related to neither arch or platform.
>>>
>>> Cheers,
>>> Costin
>>>
>>> On 10/28/20 3:14 PM, Simon Kuenzer wrote:
>>>> Hey Stefan, hey Costin,
>>>>
>>>> what is the reason that arch code needs sections.h? I can't read it 
>>>> from
>>>> the commit message. Architecture code should only be the parts that are
>>>> totally independent on the platform details. They are mostly helpers 
>>>> for
>>>> arithmetics and CPU register definitions. I am concerned that
>>>> architecture code may break when doing assumptions on symbol locations;
>>>> imagine ASLR where locations are moved at runtime.
>>>>
>>>> The NX bit patch is upstream.
>>>>
>>>> Thanks,
>>>>
>>>> Simon
>>>>
>>>> On 26.10.20 17:14, stefanl.teodorescu@gmail.com wrote:
>>>>> From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
>>>>>
>>>>> Move plat/common/include/uk/plat/common/sections.h to
>>>>> include/uk/sections.h to be able to include it in arch code. This file
>>>>> is platform independent, so it does not affect anything.
>>>>>
>>>>> Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
>>>>> ---
>>>>>    {plat/common/include/uk/plat/common => include/uk}/sections.h | 0
>>>>>    plat/kvm/arm/entry64.S                                        | 
>>>>> 2 +-
>>>>>    plat/kvm/arm/setup.c                                          | 
>>>>> 2 +-
>>>>>    plat/kvm/memory.c                                             | 
>>>>> 2 +-
>>>>>    plat/kvm/x86/setup.c                                          | 
>>>>> 2 +-
>>>>>    plat/xen/arm/setup.c                                          | 
>>>>> 2 +-
>>>>>    plat/xen/include/xen-arm/mm.h                                 | 
>>>>> 2 +-
>>>>>    plat/xen/include/xen-x86/mm.h                                 | 
>>>>> 2 +-
>>>>>    plat/xen/memory.c                                             | 
>>>>> 2 +-
>>>>>    plat/xen/x86/mm.c                                             | 
>>>>> 2 +-
>>>>>    10 files changed, 9 insertions(+), 9 deletions(-)
>>>>>    rename {plat/common/include/uk/plat/common => 
>>>>> include/uk}/sections.h
>>>>> (100%)
>>>>>
>>>>> diff --git a/plat/common/include/uk/plat/common/sections.h
>>>>> b/include/uk/sections.h
>>>>> similarity index 100%
>>>>> rename from plat/common/include/uk/plat/common/sections.h
>>>>> rename to include/uk/sections.h
>>>>> diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S
>>>>> index c4de334c..8be3d59f 100644
>>>>> --- a/plat/kvm/arm/entry64.S
>>>>> +++ b/plat/kvm/arm/entry64.S
>>>>> @@ -35,7 +35,7 @@
>>>>>    #include <uk/asm.h>
>>>>>    #include <kvm-arm/mm.h>
>>>>>    #include <arm/cpu_defs.h>
>>>>> -#include <uk/plat/common/sections.h>
>>>>> +#include <uk/sections.h>
>>>>>    #include <uk/config.h>
>>>>>
>>>>>    .global page_table_size
>>>>> diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
>>>>> index 41e63755..8513b48c 100644
>>>>> --- a/plat/kvm/arm/setup.c
>>>>> +++ b/plat/kvm/arm/setup.c
>>>>> @@ -20,7 +20,7 @@
>>>>>     */
>>>>>    #include <uk/config.h>
>>>>>    #include <libfdt.h>
>>>>> -#include <uk/plat/common/sections.h>
>>>>> +#include <uk/sections.h>
>>>>>    #include <kvm/console.h>
>>>>>    #include <kvm/config.h>
>>>>>    #include <uk/assert.h>
>>>>> diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
>>>>> index 1d9269ec..61d3e6ca 100644
>>>>> --- a/plat/kvm/memory.c
>>>>> +++ b/plat/kvm/memory.c
>>>>> @@ -19,7 +19,7 @@
>>>>>     * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>>>>>     */
>>>>>
>>>>> -#include <uk/plat/common/sections.h>
>>>>> +#include <uk/sections.h>
>>>>>    #include <sys/types.h>
>>>>>    #include <uk/plat/memory.h>
>>>>>    #include <uk/assert.h>
>>>>> diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c
>>>>> index 9c7a93a8..1cab0a63 100644
>>>>> --- a/plat/kvm/x86/setup.c
>>>>> +++ b/plat/kvm/x86/setup.c
>>>>> @@ -27,7 +27,7 @@
>>>>>     */
>>>>>
>>>>>    #include <string.h>
>>>>> -#include <uk/plat/common/sections.h>
>>>>> +#include <uk/sections.h>
>>>>>    #include <x86/cpu.h>
>>>>>    #include <x86/traps.h>
>>>>>    #include <kvm/config.h>
>>>>> diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
>>>>> index 2df3b46c..bcbc939e 100644
>>>>> --- a/plat/xen/arm/setup.c
>>>>> +++ b/plat/xen/arm/setup.c
>>>>> @@ -25,7 +25,7 @@
>>>>>    /* Ported from Mini-OS */
>>>>>
>>>>>    #include <string.h>
>>>>> -#include <uk/plat/common/sections.h>
>>>>> +#include <uk/sections.h>
>>>>>    #include <xen-arm/os.h>
>>>>>    #include <xen-arm/mm.h>
>>>>>    #include <xen/xen.h>
>>>>> diff --git a/plat/xen/include/xen-arm/mm.h
>>>>> b/plat/xen/include/xen-arm/mm.h
>>>>> index 659de843..bbd31ddd 100644
>>>>> --- a/plat/xen/include/xen-arm/mm.h
>>>>> +++ b/plat/xen/include/xen-arm/mm.h
>>>>> @@ -28,7 +28,7 @@
>>>>>    #define _ARCH_MM_H_
>>>>>
>>>>>    #include <stdint.h>
>>>>> -#include <uk/plat/common/sections.h>
>>>>> +#include <uk/sections.h>
>>>>>    #include <uk/arch/limits.h>
>>>>>
>>>>>    typedef uint64_t paddr_t;
>>>>> diff --git a/plat/xen/include/xen-x86/mm.h
>>>>> b/plat/xen/include/xen-x86/mm.h
>>>>> index ffbedb09..99ba6d05 100644
>>>>> --- a/plat/xen/include/xen-x86/mm.h
>>>>> +++ b/plat/xen/include/xen-x86/mm.h
>>>>> @@ -25,7 +25,7 @@
>>>>>    #ifndef _ARCH_MM_H_
>>>>>    #define _ARCH_MM_H_
>>>>>
>>>>> -#include <uk/plat/common/sections.h>
>>>>> +#include <uk/sections.h>
>>>>>    #ifndef __ASSEMBLY__
>>>>>    #include <xen/xen.h>
>>>>>    #if defined(__i386__)
>>>>> diff --git a/plat/xen/memory.c b/plat/xen/memory.c
>>>>> index 8e7a7dda..27a317c4 100644
>>>>> --- a/plat/xen/memory.c
>>>>> +++ b/plat/xen/memory.c
>>>>> @@ -34,7 +34,7 @@
>>>>>     */
>>>>>
>>>>>    #include <string.h>
>>>>> -#include <uk/plat/common/sections.h>
>>>>> +#include <uk/sections.h>
>>>>>
>>>>>    #include <common/gnttab.h>
>>>>>    #if (defined __X86_32__) || (defined __X86_64__)
>>>>> diff --git a/plat/xen/x86/mm.c b/plat/xen/x86/mm.c
>>>>> index e006ab7f..9e352eed 100644
>>>>> --- a/plat/xen/x86/mm.c
>>>>> +++ b/plat/xen/x86/mm.c
>>>>> @@ -36,7 +36,7 @@
>>>>>     */
>>>>>
>>>>>    #include <string.h>
>>>>> -#include <uk/plat/common/sections.h>
>>>>> +#include <uk/sections.h>
>>>>>    #include <errno.h>
>>>>>    #include <uk/alloc.h>
>>>>>    #include <uk/plat/config.h>
>>>>> -- 
>>>>> 2.29.0
>>>>>
>>>>>
>>


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 22:53:36 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 22:53:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13920.34772 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuJv-0004wE-D0; Wed, 28 Oct 2020 22:53:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13920.34772; Wed, 28 Oct 2020 22:53:31 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuJv-0004w7-9l; Wed, 28 Oct 2020 22:53:31 +0000
Received: by outflank-mailman (input) for mailman id 13920;
 Wed, 28 Oct 2020 22:53: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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kXuJt-0004w2-Dy
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:29 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id dfb242f8-5c25-4d97-a5db-a0531c6f3d0b;
 Wed, 28 Oct 2020 22:53:27 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 163F510397A;
 Wed, 28 Oct 2020 23:53:26 +0100 (CET)
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 mSpvI0EZAdHn; Wed, 28 Oct 2020 23:53:25 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id E7BAA1003D0
 for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:25 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:25 +0100
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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kXuJt-0004w2-Dy
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:29 +0000
X-Inumbo-ID: dfb242f8-5c25-4d97-a5db-a0531c6f3d0b
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id dfb242f8-5c25-4d97-a5db-a0531c6f3d0b;
	Wed, 28 Oct 2020 22:53:27 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 163F510397A;
	Wed, 28 Oct 2020 23:53:26 +0100 (CET)
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 mSpvI0EZAdHn; Wed, 28 Oct 2020 23:53:25 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id E7BAA1003D0
	for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:25 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:25 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v3 0/5] Memory Pools
Date: Wed, 28 Oct 2020 23:53:18 +0100
Message-ID: <20201028225323.15275-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 titania.office.hd
 (192.168.24.89)

This series implements a memory pool allocator. Pool objects have the same
size and are pre-allocated. Due to this simplification allocations and free
operations are as cheap as O(1). Its intended use is performance critical
allocations when allocation sizes do not vary, like network stacks or disk
buffer caches.

Changes since v2:
 - Fix compile error when `CONFIG_LIBUKALLOC_IFSTATS` is activated

Changes since v1:
 - Correct license header in `pool.c`

Simon Kuenzer (5):
  lib/ukallocpool: Library skeleton
  lib/ukallocpool: LIFO pool implementation
  lib/ukallocpool: Allocate pool on parent allocator
  lib/ukallocpool: `lib/ukalloc` compatible interface
  lib/ukallocpool: Batched allocation

 lib/Makefile.uk                        |   1 +
 lib/ukallocpool/Config.uk              |   6 +
 lib/ukallocpool/Makefile.uk            |   6 +
 lib/ukallocpool/exportsyms.uk          |  10 +
 lib/ukallocpool/include/uk/allocpool.h | 206 +++++++++++++++
 lib/ukallocpool/pool.c                 | 350 +++++++++++++++++++++++++
 6 files changed, 579 insertions(+)
 create mode 100644 lib/ukallocpool/Config.uk
 create mode 100644 lib/ukallocpool/Makefile.uk
 create mode 100644 lib/ukallocpool/exportsyms.uk
 create mode 100644 lib/ukallocpool/include/uk/allocpool.h
 create mode 100644 lib/ukallocpool/pool.c

-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 22:53:44 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 22:53:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13921.34775 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuK8-0004x8-Eh; Wed, 28 Oct 2020 22:53:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13921.34775; Wed, 28 Oct 2020 22:53:44 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuK8-0004x1-Br; Wed, 28 Oct 2020 22:53:44 +0000
Received: by outflank-mailman (input) for mailman id 13921;
 Wed, 28 Oct 2020 22:53: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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kXuK7-0004wu-Bq
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:43 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id dc4a3bbd-09a6-4eda-b9f7-4cd7309cebba;
 Wed, 28 Oct 2020 22:53:41 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 64AF9F226C;
 Wed, 28 Oct 2020 23:53:40 +0100 (CET)
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 s775P97OUKrI; Wed, 28 Oct 2020 23:53:40 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 2CD8FF226A
 for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:38 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:37 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kXuK7-0004wu-Bq
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:43 +0000
X-Inumbo-ID: dc4a3bbd-09a6-4eda-b9f7-4cd7309cebba
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id dc4a3bbd-09a6-4eda-b9f7-4cd7309cebba;
	Wed, 28 Oct 2020 22:53:41 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 64AF9F226C;
	Wed, 28 Oct 2020 23:53:40 +0100 (CET)
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 s775P97OUKrI; Wed, 28 Oct 2020 23:53:40 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 2CD8FF226A
	for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:38 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:37 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v3 1/5] lib/ukallocpool: Library skeleton
Date: Wed, 28 Oct 2020 23:53:19 +0100
Message-ID: <20201028225323.15275-2-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
References: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Registers the library skeleton for ukallocpool.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/Makefile.uk             | 1 +
 lib/ukallocpool/Config.uk   | 6 ++++++
 lib/ukallocpool/Makefile.uk | 4 ++++
 3 files changed, 11 insertions(+)
 create mode 100644 lib/ukallocpool/Config.uk
 create mode 100644 lib/ukallocpool/Makefile.uk

diff --git a/lib/Makefile.uk b/lib/Makefile.uk
index ff69dfab..7fffdac7 100644
--- a/lib/Makefile.uk
+++ b/lib/Makefile.uk
@@ -15,6 +15,7 @@ $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/nolibc))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukalloc))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocbbuddy))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocregion))
+$(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukallocpool))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/uksched))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/ukschedcoop))
 $(eval $(call _import_lib,$(CONFIG_UK_BASE)/lib/fdt))
diff --git a/lib/ukallocpool/Config.uk b/lib/ukallocpool/Config.uk
new file mode 100644
index 00000000..5c300117
--- /dev/null
+++ b/lib/ukallocpool/Config.uk
@@ -0,0 +1,6 @@
+config LIBUKALLOCPOOL
+	bool "ukallocpool: Memory pool allocator"
+	default n
+	select LIBNOLIBC if !HAVE_LIBC
+	select LIBUKDEBUG
+	select LIBUKALLOC
diff --git a/lib/ukallocpool/Makefile.uk b/lib/ukallocpool/Makefile.uk
new file mode 100644
index 00000000..c71c9764
--- /dev/null
+++ b/lib/ukallocpool/Makefile.uk
@@ -0,0 +1,4 @@
+$(eval $(call addlib_s,libukallocpool,$(CONFIG_LIBUKALLOCPOOL)))
+
+CINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
+CXXINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 22:53:49 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 22:53:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13922.34779 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuKD-0004y8-Gn; Wed, 28 Oct 2020 22:53:49 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13922.34779; Wed, 28 Oct 2020 22:53:49 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuKD-0004y1-DS; Wed, 28 Oct 2020 22:53:49 +0000
Received: by outflank-mailman (input) for mailman id 13922;
 Wed, 28 Oct 2020 22: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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kXuKC-0004wu-6f
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:48 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 0e142a45-0f9b-4ac8-84b0-d2b5b2046eb1;
 Wed, 28 Oct 2020 22:53:43 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 6705EF226D;
 Wed, 28 Oct 2020 23:53:42 +0100 (CET)
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 3nSeFPlk0f5E; Wed, 28 Oct 2020 23:53:42 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 38D68F226A
 for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:40 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:39 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kXuKC-0004wu-6f
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:48 +0000
X-Inumbo-ID: 0e142a45-0f9b-4ac8-84b0-d2b5b2046eb1
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 0e142a45-0f9b-4ac8-84b0-d2b5b2046eb1;
	Wed, 28 Oct 2020 22:53:43 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 6705EF226D;
	Wed, 28 Oct 2020 23:53:42 +0100 (CET)
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 3nSeFPlk0f5E; Wed, 28 Oct 2020 23:53:42 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 38D68F226A
	for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:40 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:39 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v3 2/5] lib/ukallocpool: LIFO pool implementation
Date: Wed, 28 Oct 2020 23:53:20 +0100
Message-ID: <20201028225323.15275-3-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
References: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Initial implementation of a memory pool (same-sized and fixed-sized object
allocator) following LIFO principle by using a single list to keep track of
free objects. LIFO is chosen to potentially better utilize hardware caches.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/Makefile.uk            |   2 +
 lib/ukallocpool/exportsyms.uk          |   4 +
 lib/ukallocpool/include/uk/allocpool.h | 109 ++++++++++++++
 lib/ukallocpool/pool.c                 | 188 +++++++++++++++++++++++++
 4 files changed, 303 insertions(+)
 create mode 100644 lib/ukallocpool/exportsyms.uk
 create mode 100644 lib/ukallocpool/include/uk/allocpool.h
 create mode 100644 lib/ukallocpool/pool.c

diff --git a/lib/ukallocpool/Makefile.uk b/lib/ukallocpool/Makefile.uk
index c71c9764..63c24dc1 100644
--- a/lib/ukallocpool/Makefile.uk
+++ b/lib/ukallocpool/Makefile.uk
@@ -2,3 +2,5 @@ $(eval $(call addlib_s,libukallocpool,$(CONFIG_LIBUKALLOCPOOL)))
 
 CINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
 CXXINCLUDES-$(CONFIG_LIBUKALLOCPOOL)	+= -I$(LIBUKALLOCPOOL_BASE)/include
+
+LIBUKALLOCPOOL_SRCS-y += $(LIBUKALLOCPOOL_BASE)/pool.c
diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
new file mode 100644
index 00000000..2f29b409
--- /dev/null
+++ b/lib/ukallocpool/exportsyms.uk
@@ -0,0 +1,4 @@
+uk_allocpool_init
+uk_allocpool_availcount
+uk_allocpool_take
+uk_allocpool_return
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
new file mode 100644
index 00000000..ce3d939d
--- /dev/null
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -0,0 +1,109 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Simple memory pool using LIFO principle
+ *
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation,
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __LIBUKALLOCPOOL_H__
+#define __LIBUKALLOCPOOL_H__
+
+#include <uk/alloc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*uk_allocpool_obj_init_t)(void *obj, size_t len, void *cookie);
+
+struct uk_allocpool;
+
+/**
+ * Initializes a memory pool on a given memory range.
+ *
+ * @param base
+ *  Base address of memory range
+ * @param len
+ *  Length of memory range (bytes)
+ * @param obj_len
+ *  Size of one object (bytes)
+ * @param obj_align
+ *  Alignment requirement for each pool object
+ * @param obj_init
+ *  Function pointer to object initialization
+ * @param obj_init_cookie
+ *  Cookie that is hand-over to object initialization
+ * @return
+ *  - (NULL): Not enough memory for pool
+ *  - pointer to initializes pool
+ */
+struct uk_allocpool *uk_allocpool_init(void *base, size_t len,
+				       size_t obj_len, size_t obj_align,
+				       uk_allocpool_obj_init_t obj_init,
+				       void *obj_init_cookie);
+
+/**
+ * Return the number of current available (free) objects
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @return
+ *  Number of free objects in the pool.
+ */
+unsigned int uk_allocpool_availcount(struct uk_allocpool *p);
+
+/**
+ * Get one object from a pool
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @return
+ *  - (NULL): No more free objects available
+ *  - Pointer to object.
+ */
+void *uk_allocpool_take(struct uk_allocpool *p);
+
+/**
+ * Return one object back to a pool
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @param obj
+ *  Pointer to object that should be returned.
+ */
+void uk_allocpool_return(struct uk_allocpool *p, void *obj);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LIBUKALLOCPOOL_H__ */
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
new file mode 100644
index 00000000..d9614776
--- /dev/null
+++ b/lib/ukallocpool/pool.c
@@ -0,0 +1,188 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Simple memory pool using LIFO principle
+ *
+ * Authors: Simon Kuenzer <simon.kuenzer@neclab.eu>
+ *
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation,
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <uk/essentials.h>
+#include <uk/alloc_impl.h>
+#include <uk/allocpool.h>
+#include <uk/list.h>
+#include <string.h>
+#include <errno.h>
+
+/*
+ * POOL: MEMORY LAYOUT
+ *
+ *          ++--------------------++
+ *          ||   struct mempool   ||
+ *          ||                    ||
+ *          ++--------------------++
+ *          |    // padding //     |
+ *          +======================+
+ *          |       OBJECT 1       |
+ *          +======================+
+ *          |       OBJECT 2       |
+ *          +======================+
+ *          |       OBJECT 3       |
+ *          +======================+
+ *          |         ...          |
+ *          v                      v
+ */
+
+#define MIN_OBJ_ALIGN sizeof(void *)
+#define MIN_OBJ_LEN   sizeof(struct uk_list_head)
+
+struct uk_allocpool {
+	struct uk_list_head free_obj;
+	unsigned int free_obj_count;
+
+	size_t obj_align;
+	size_t obj_len;
+	unsigned int obj_count;
+	uk_allocpool_obj_init_t obj_init;
+	void *obj_init_cookie;
+};
+
+struct free_obj {
+	struct uk_list_head list;
+};
+
+static inline void _prepend_free_obj(struct uk_allocpool *p, void *obj)
+{
+	struct uk_list_head *entry;
+
+	UK_ASSERT(p);
+	UK_ASSERT(obj);
+	UK_ASSERT(p->free_obj_count < p->obj_count);
+
+	entry = &((struct free_obj *) obj)->list;
+	uk_list_add(entry, &p->free_obj);
+	p->free_obj_count++;
+}
+
+static inline void *_take_free_obj(struct uk_allocpool *p)
+{
+	struct free_obj *obj;
+
+	UK_ASSERT(p);
+	UK_ASSERT(p->free_obj_count > 0);
+
+	/* get object from list head */
+	obj = uk_list_first_entry(&p->free_obj, struct free_obj, list);
+	uk_list_del(&obj->list);
+	p->free_obj_count--;
+	if (p->obj_init)
+		p->obj_init((void *) obj, p->obj_len, p->obj_init_cookie);
+	return (void *) obj;
+}
+
+void *uk_allocpool_take(struct uk_allocpool *p)
+{
+	UK_ASSERT(p);
+
+	if (unlikely(uk_list_empty(&p->free_obj)))
+		return NULL;
+
+	return _take_free_obj(p);
+}
+
+void uk_allocpool_return(struct uk_allocpool *p, void *obj)
+{
+	UK_ASSERT(p);
+
+	_prepend_free_obj(p, obj);
+}
+
+unsigned int uk_allocpool_availcount(struct uk_allocpool *p)
+{
+	return p->free_obj_count;
+}
+
+struct uk_allocpool *uk_allocpool_init(void *base, size_t len,
+				       size_t obj_len, size_t obj_align,
+				       uk_allocpool_obj_init_t obj_init,
+				       void *obj_init_cookie)
+{
+	struct uk_allocpool *p;
+	struct uk_alloc *a;
+	size_t obj_alen;
+	size_t left;
+	void *obj_ptr;
+
+	UK_ASSERT(POWER_OF_2(obj_align));
+
+	if (!base || sizeof(struct uk_allocpool) > len) {
+		errno = ENOSPC;
+		return NULL;
+	}
+
+	/* apply minimum requirements */
+	obj_len   = MAX(obj_len, MIN_OBJ_LEN);
+	obj_align = MAX(obj_align, MIN_OBJ_ALIGN);
+
+	p = (struct uk_allocpool *) base;
+	memset(p, 0, sizeof(*p));
+	a = uk_allocpool2alloc(p);
+
+	obj_alen = ALIGN_UP(obj_len, obj_align);
+	obj_ptr = (void *) ALIGN_UP((uintptr_t) base + sizeof(*p),
+				    obj_align);
+	if ((uintptr_t) obj_ptr > (uintptr_t) base + len) {
+		uk_pr_debug("%p: Empty pool: Not enough space for allocating objects\n",
+			    p);
+		goto out;
+	}
+
+	left = len - ((uintptr_t) obj_ptr - (uintptr_t) base);
+
+	p->obj_count = 0;
+	p->free_obj_count = 0;
+	UK_INIT_LIST_HEAD(&p->free_obj);
+	while (left >= obj_alen) {
+		++p->obj_count;
+		_prepend_free_obj(p, obj_ptr);
+		obj_ptr = (void *) ((uintptr_t) obj_ptr + obj_alen);
+		left -= obj_alen;
+	}
+
+out:
+	p->obj_len         = obj_alen;
+	p->obj_align       = obj_align;
+	p->obj_init        = obj_init;
+	p->obj_init_cookie = obj_init_cookie;
+
+	uk_pr_debug("%p: Pool created (%"__PRIsz" B): %u objs of %"__PRIsz" B, aligned to %"__PRIsz" B\n",
+		    p, len, p->obj_count, p->obj_len, p->obj_align);
+	return p;
+}
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 22:53:55 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 22:53:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13923.34783 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuKJ-0004zM-J4; Wed, 28 Oct 2020 22:53:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13923.34783; Wed, 28 Oct 2020 22:53:55 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuKJ-0004zH-G9; Wed, 28 Oct 2020 22:53:55 +0000
Received: by outflank-mailman (input) for mailman id 13923;
 Wed, 28 Oct 2020 22:53: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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kXuKI-0004z7-9s
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:54 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 12d873ae-fbf6-4c45-910a-133e9de819d9;
 Wed, 28 Oct 2020 22:53:52 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 959F310397A;
 Wed, 28 Oct 2020 23:53:51 +0100 (CET)
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 e2abd2_ijiYj; Wed, 28 Oct 2020 23:53:51 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 74C881003D0
 for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:51 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:51 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kXuKI-0004z7-9s
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:54 +0000
X-Inumbo-ID: 12d873ae-fbf6-4c45-910a-133e9de819d9
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 12d873ae-fbf6-4c45-910a-133e9de819d9;
	Wed, 28 Oct 2020 22:53:52 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 959F310397A;
	Wed, 28 Oct 2020 23:53:51 +0100 (CET)
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 e2abd2_ijiYj; Wed, 28 Oct 2020 23:53:51 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 74C881003D0
	for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:51 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:51 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v3 3/5] lib/ukallocpool: Allocate pool on parent allocator
Date: Wed, 28 Oct 2020 23:53:21 +0100
Message-ID: <20201028225323.15275-4-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
References: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Provides a function that allocates and initializes a pool on a
given parent allocator.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/exportsyms.uk          |  3 ++
 lib/ukallocpool/include/uk/allocpool.h | 51 +++++++++++++++++++++
 lib/ukallocpool/pool.c                 | 62 ++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)

diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
index 2f29b409..9e19e8b2 100644
--- a/lib/ukallocpool/exportsyms.uk
+++ b/lib/ukallocpool/exportsyms.uk
@@ -1,4 +1,7 @@
+uk_allocpool_alloc
+uk_allocpool_free
 uk_allocpool_init
+uk_allocpool_reqmem
 uk_allocpool_availcount
 uk_allocpool_take
 uk_allocpool_return
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
index ce3d939d..13fbd187 100644
--- a/lib/ukallocpool/include/uk/allocpool.h
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -47,6 +47,57 @@ typedef void (*uk_allocpool_obj_init_t)(void *obj, size_t len, void *cookie);
 
 struct uk_allocpool;
 
+/**
+ * Computes the required memory for a pool allocation
+ *
+ * @param obj_count
+ *  Number of objects that are allocated with the pool
+ * @param obj_len
+ *  Size of one object (bytes)
+ * @param obj_align
+ *  Alignment requirement for each pool object
+ * @return
+ *  Number of bytes needed for pool allocation
+ */
+size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
+			   size_t obj_align);
+
+/**
+ * Allocates a memory pool on a parent allocator.
+ *
+ * @param obj_count
+ *  Number of objects that are allocated with the pool
+ * @param obj_len
+ *  Size of one object (bytes)
+ * @param obj_align
+ *  Alignment requirement for each pool object
+ * @param obj_init
+ *  Function pointer to object initialization
+ * @param obj_init_cookie
+ *  Cookie that is hand-over to object initialization
+ * @return
+ *  - (NULL): If allocation failed (e.g., ENOMEM)
+ *  - pointer to allocated pool
+ */
+struct uk_allocpool *uk_allocpool_alloc(struct uk_alloc *parent,
+					unsigned int obj_count,
+					size_t obj_len, size_t obj_align,
+					uk_allocpool_obj_init_t obj_init,
+					void *obj_init_cookie);
+
+/**
+ * Frees a memory pool that was allocated with
+ * uk_allocpool_alloc(). The memory is returned to
+ * the parent allocator.
+ * Note: Please make sure that all taken objects
+ * are returned to the pool before free'ing the
+ * pool.
+ *
+ * @param p
+ *  Pointer to memory pool that will be free'd.
+ */
+void uk_allocpool_free(struct uk_allocpool *p);
+
 /**
  * Initializes a memory pool on a given memory range.
  *
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index d9614776..bbc50793 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -72,6 +72,9 @@ struct uk_allocpool {
 	unsigned int obj_count;
 	uk_allocpool_obj_init_t obj_init;
 	void *obj_init_cookie;
+
+	struct uk_alloc *parent;
+	void *base;
 };
 
 struct free_obj {
@@ -124,6 +127,21 @@ void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 	_prepend_free_obj(p, obj);
 }
 
+size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
+			   size_t obj_align)
+{
+	size_t obj_alen;
+
+	UK_ASSERT(POWER_OF_2(obj_align));
+
+	obj_len   = MAX(obj_len, MIN_OBJ_LEN);
+	obj_align = MAX(obj_align, MIN_OBJ_ALIGN);
+	obj_alen  = ALIGN_UP(obj_len, obj_align);
+	return (sizeof(struct uk_allocpool)
+		+ obj_align
+		+ ((size_t) obj_count * obj_alen));
+}
+
 unsigned int uk_allocpool_availcount(struct uk_allocpool *p)
 {
 	return p->free_obj_count;
@@ -181,8 +199,52 @@ out:
 	p->obj_align       = obj_align;
 	p->obj_init        = obj_init;
 	p->obj_init_cookie = obj_init_cookie;
+	p->base            = base;
+	p->parent          = NULL;
 
 	uk_pr_debug("%p: Pool created (%"__PRIsz" B): %u objs of %"__PRIsz" B, aligned to %"__PRIsz" B\n",
 		    p, len, p->obj_count, p->obj_len, p->obj_align);
 	return p;
 }
+
+struct uk_allocpool *uk_allocpool_alloc(struct uk_alloc *parent,
+					unsigned int obj_count,
+					size_t obj_len, size_t obj_align,
+					uk_allocpool_obj_init_t obj_init,
+					void *obj_init_cookie)
+{
+	struct uk_allocpool *p;
+	void *base;
+	size_t len;
+
+	/* uk_allocpool_reqmem computes minimum requirement */
+	len = uk_allocpool_reqmem(obj_count, obj_len, obj_align);
+	base = uk_malloc(parent, len);
+	if (!base)
+		return NULL;
+
+	p = uk_allocpool_init(base, len, obj_len, obj_align,
+			      obj_init, obj_init_cookie);
+	if (!p) {
+		uk_free(parent, base);
+		errno = ENOSPC;
+		return NULL;
+	}
+
+	p->parent = parent;
+	return p;
+}
+
+void uk_allocpool_free(struct uk_allocpool *p)
+{
+	/* If we do not have a parent, this pool was created with
+	 * uk_allocpool_init(). Such a pool cannot be free'd with
+	 * this function since we are not the owner of the allocation
+	 */
+	UK_ASSERT(p->parent);
+
+	/* Make sure we got all objects back */
+	UK_ASSERT(p->free_obj_count == p->obj_count);
+
+	uk_free(p->parent, p->base);
+}
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 22:53:58 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 22:53:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13924.34788 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuKM-00050I-KQ; Wed, 28 Oct 2020 22:53:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13924.34788; Wed, 28 Oct 2020 22:53:58 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuKM-00050A-Hc; Wed, 28 Oct 2020 22:53:58 +0000
Received: by outflank-mailman (input) for mailman id 13924;
 Wed, 28 Oct 2020 22:53:57 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kXuKL-0004zy-48
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:57 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 27402bf3-11ee-477f-ad19-92310ee8a020;
 Wed, 28 Oct 2020 22:53:55 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id ED6A1F226C;
 Wed, 28 Oct 2020 23:53:54 +0100 (CET)
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 Gp1VPOxjQZrY; Wed, 28 Oct 2020 23:53:54 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id C7336F226A
 for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:52 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:52 +0100
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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kXuKL-0004zy-48
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:53:57 +0000
X-Inumbo-ID: 27402bf3-11ee-477f-ad19-92310ee8a020
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 27402bf3-11ee-477f-ad19-92310ee8a020;
	Wed, 28 Oct 2020 22:53:55 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id ED6A1F226C;
	Wed, 28 Oct 2020 23:53:54 +0100 (CET)
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 Gp1VPOxjQZrY; Wed, 28 Oct 2020 23:53:54 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id C7336F226A
	for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:53:52 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:53:52 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v3 4/5] lib/ukallocpool: `lib/ukalloc` compatible interface
Date: Wed, 28 Oct 2020 23:53:22 +0100
Message-ID: <20201028225323.15275-5-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
References: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Provide a ukalloc compatible interface. This enables the usage of pools
with common allocator interfaces, like `uk_malloc()`, `uk_free()`,
and `uk_memalign()`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/exportsyms.uk          |  1 +
 lib/ukallocpool/include/uk/allocpool.h | 16 ++++++
 lib/ukallocpool/pool.c                 | 71 ++++++++++++++++++++++++++
 3 files changed, 88 insertions(+)

diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
index 9e19e8b2..d119db32 100644
--- a/lib/ukallocpool/exportsyms.uk
+++ b/lib/ukallocpool/exportsyms.uk
@@ -5,3 +5,4 @@ uk_allocpool_reqmem
 uk_allocpool_availcount
 uk_allocpool_take
 uk_allocpool_return
+uk_allocpool2ukalloc
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
index 13fbd187..a60acb35 100644
--- a/lib/ukallocpool/include/uk/allocpool.h
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -122,6 +122,18 @@ struct uk_allocpool *uk_allocpool_init(void *base, size_t len,
 				       uk_allocpool_obj_init_t obj_init,
 				       void *obj_init_cookie);
 
+/**
+ * Return uk_alloc compatible interface for allocpool.
+ * With this interface, uk_malloc(), uk_free(), etc. can
+ * be used with the pool.
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @return
+ *  Pointer to uk_alloc interface of given pool.
+ */
+struct uk_alloc *uk_allocpool2alloc(struct uk_allocpool *p);
+
 /**
  * Return the number of current available (free) objects
  *
@@ -134,6 +146,8 @@ unsigned int uk_allocpool_availcount(struct uk_allocpool *p);
 
 /**
  * Get one object from a pool
+ * HINT: It is recommended to use this call instead of uk_malloc() whenever
+ *       feasible. This call is avoiding indirections.
  *
  * @param p
  *  Pointer to memory pool.
@@ -145,6 +159,8 @@ void *uk_allocpool_take(struct uk_allocpool *p);
 
 /**
  * Return one object back to a pool
+ * HINT: It is recommended to use this call instead of uk_free() whenever
+ *       feasible. This call is avoiding indirections.
  *
  * @param p
  *  Pointer to memory pool.
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index bbc50793..bcdef670 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -64,6 +64,8 @@
 #define MIN_OBJ_LEN   sizeof(struct uk_list_head)
 
 struct uk_allocpool {
+	struct uk_alloc self;
+
 	struct uk_list_head free_obj;
 	unsigned int free_obj_count;
 
@@ -81,6 +83,18 @@ struct free_obj {
 	struct uk_list_head list;
 };
 
+static inline struct uk_allocpool *ukalloc2pool(struct uk_alloc *a)
+{
+	UK_ASSERT(a);
+	return __containerof(a, struct uk_allocpool, self);
+}
+
+struct uk_alloc *uk_allocpool2alloc(struct uk_allocpool *p)
+{
+	UK_ASSERT(p);
+	return &p->self;
+}
+
 static inline void _prepend_free_obj(struct uk_allocpool *p, void *obj)
 {
 	struct uk_list_head *entry;
@@ -110,6 +124,42 @@ static inline void *_take_free_obj(struct uk_allocpool *p)
 	return (void *) obj;
 }
 
+static void pool_free(struct uk_alloc *a, void *ptr)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	if (likely(ptr))
+		_prepend_free_obj(p, ptr);
+}
+
+static void *pool_malloc(struct uk_alloc *a, size_t size)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	if (unlikely((size > p->obj_len)
+		     || uk_list_empty(&p->free_obj))) {
+		errno = ENOMEM;
+		return NULL;
+	}
+
+	return _take_free_obj(p);
+}
+
+static int pool_posix_memalign(struct uk_alloc *a, void **memptr, size_t align,
+				size_t size)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	if (unlikely((size > p->obj_len)
+		     || (align > p->obj_align)
+		     || uk_list_empty(&p->free_obj))) {
+		return ENOMEM;
+	}
+
+	*memptr = _take_free_obj(p);
+	return 0;
+}
+
 void *uk_allocpool_take(struct uk_allocpool *p)
 {
 	UK_ASSERT(p);
@@ -127,6 +177,15 @@ void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 	_prepend_free_obj(p, obj);
 }
 
+#if CONFIG_LIBUKALLOC_IFSTATS
+static ssize_t pool_availmem(struct uk_alloc *a)
+{
+	struct uk_allocpool *p = ukalloc2pool(a);
+
+	return (size_t) p->free_obj_count * p->obj_len;
+}
+#endif
+
 size_t uk_allocpool_reqmem(unsigned int obj_count, size_t obj_len,
 			   size_t obj_align)
 {
@@ -202,6 +261,18 @@ out:
 	p->base            = base;
 	p->parent          = NULL;
 
+	uk_alloc_init_malloc(a,
+			     pool_malloc,
+			     uk_calloc_compat,
+			     uk_realloc_compat,
+			     pool_free,
+			     pool_posix_memalign,
+			     uk_memalign_compat,
+			     NULL);
+#if CONFIG_LIBUKALLOC_IFSTATS
+	p->self.availmem = pool_availmem;
+#endif
+
 	uk_pr_debug("%p: Pool created (%"__PRIsz" B): %u objs of %"__PRIsz" B, aligned to %"__PRIsz" B\n",
 		    p, len, p->obj_count, p->obj_len, p->obj_align);
 	return p;
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Wed Oct 28 22:54:09 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 28 Oct 2020 22:54:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.13926.34791 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuKX-00052b-MY; Wed, 28 Oct 2020 22:54:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 13926.34791; Wed, 28 Oct 2020 22:54:09 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kXuKX-00052U-Ji; Wed, 28 Oct 2020 22:54:09 +0000
Received: by outflank-mailman (input) for mailman id 13926;
 Wed, 28 Oct 2020 22:54: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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kXuKW-00052A-3v
 for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:54:08 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 84943c78-10dd-402c-99ca-1671964683e5;
 Wed, 28 Oct 2020 22:54:07 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 306DE103987;
 Wed, 28 Oct 2020 23:54:06 +0100 (CET)
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 mGJe7XCTg4sH; Wed, 28 Oct 2020 23:54:06 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id F0CED103983
 for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:54:05 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:54:05 +0100
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=yB6h=ED=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kXuKW-00052A-3v
	for minios-devel@lists.xen.org; Wed, 28 Oct 2020 22:54:08 +0000
X-Inumbo-ID: 84943c78-10dd-402c-99ca-1671964683e5
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 84943c78-10dd-402c-99ca-1671964683e5;
	Wed, 28 Oct 2020 22:54:07 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 306DE103987;
	Wed, 28 Oct 2020 23:54:06 +0100 (CET)
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 mGJe7XCTg4sH; Wed, 28 Oct 2020 23:54:06 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id F0CED103983
	for <minios-devel@lists.xen.org>; Wed, 28 Oct 2020 23:54:05 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 28 Oct
 2020 23:54:05 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH v3 5/5] lib/ukallocpool: Batched allocation
Date: Wed, 28 Oct 2020 23:53:23 +0100
Message-ID: <20201028225323.15275-6-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
References: <20201028225323.15275-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Introduce low-overhead interfaces for batched allocations and batched
freeing of objects.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/ukallocpool/exportsyms.uk          |  2 ++
 lib/ukallocpool/include/uk/allocpool.h | 30 ++++++++++++++++++++++++++
 lib/ukallocpool/pool.c                 | 29 +++++++++++++++++++++++++
 3 files changed, 61 insertions(+)

diff --git a/lib/ukallocpool/exportsyms.uk b/lib/ukallocpool/exportsyms.uk
index d119db32..5a6d9f6b 100644
--- a/lib/ukallocpool/exportsyms.uk
+++ b/lib/ukallocpool/exportsyms.uk
@@ -4,5 +4,7 @@ uk_allocpool_init
 uk_allocpool_reqmem
 uk_allocpool_availcount
 uk_allocpool_take
+uk_allocpool_take_batch
 uk_allocpool_return
+uk_allocpool_return_batch
 uk_allocpool2ukalloc
diff --git a/lib/ukallocpool/include/uk/allocpool.h b/lib/ukallocpool/include/uk/allocpool.h
index a60acb35..a9f9cb59 100644
--- a/lib/ukallocpool/include/uk/allocpool.h
+++ b/lib/ukallocpool/include/uk/allocpool.h
@@ -157,6 +157,22 @@ unsigned int uk_allocpool_availcount(struct uk_allocpool *p);
  */
 void *uk_allocpool_take(struct uk_allocpool *p);
 
+/**
+ * Get multiple objects from a pool.
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @param obj
+ *  Pointer to array that will be filled with pointers of
+ *  allocated objects from the pool.
+ * @param count
+ *  Maximum number of objects that should be taken from the pool
+ * @return
+ *  Number of successfully allocated objects on the given array
+ */
+unsigned int uk_allocpool_take_batch(struct uk_allocpool *p,
+				     void *obj[], unsigned int count);
+
 /**
  * Return one object back to a pool
  * HINT: It is recommended to use this call instead of uk_free() whenever
@@ -169,6 +185,20 @@ void *uk_allocpool_take(struct uk_allocpool *p);
  */
 void uk_allocpool_return(struct uk_allocpool *p, void *obj);
 
+/**
+ * Return multiple objects to a pool.
+ *
+ * @param p
+ *  Pointer to memory pool.
+ * @param obj
+ *  Pointer to array that with pointers of objects that
+ *  should be returned.
+ * @param count
+ *  Number of objects that are on the array.
+ */
+void uk_allocpool_return_batch(struct uk_allocpool *p,
+			       void *obj[], unsigned int count);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/ukallocpool/pool.c b/lib/ukallocpool/pool.c
index bcdef670..c84ccd46 100644
--- a/lib/ukallocpool/pool.c
+++ b/lib/ukallocpool/pool.c
@@ -170,6 +170,23 @@ void *uk_allocpool_take(struct uk_allocpool *p)
 	return _take_free_obj(p);
 }
 
+unsigned int uk_allocpool_take_batch(struct uk_allocpool *p,
+				     void *obj[], unsigned int count)
+{
+	unsigned int i;
+
+	UK_ASSERT(p);
+	UK_ASSERT(obj);
+
+	for (i = 0; i < count; ++i) {
+		if (unlikely(uk_list_empty(&p->free_obj)))
+			break;
+		obj[i] = _take_free_obj(p);
+	}
+
+	return i;
+}
+
 void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 {
 	UK_ASSERT(p);
@@ -177,6 +194,18 @@ void uk_allocpool_return(struct uk_allocpool *p, void *obj)
 	_prepend_free_obj(p, obj);
 }
 
+void uk_allocpool_return_batch(struct uk_allocpool *p,
+			       void *obj[], unsigned int count)
+{
+	unsigned int i;
+
+	UK_ASSERT(p);
+	UK_ASSERT(obj);
+
+	for (i = 0; i < count; ++i)
+		_prepend_free_obj(p, obj[i]);
+}
+
 #if CONFIG_LIBUKALLOC_IFSTATS
 static ssize_t pool_availmem(struct uk_alloc *a)
 {
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 09:13:05 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 09:13:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.15535.38513 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYQT0-0002dV-M0; Fri, 30 Oct 2020 09:13:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 15535.38513; Fri, 30 Oct 2020 09:13:02 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYQT0-0002dO-Iq; Fri, 30 Oct 2020 09:13:02 +0000
Received: by outflank-mailman (input) for mailman id 15535;
 Fri, 30 Oct 2020 09:13: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=wZ3U=EF=opensynergy.com=michalis.pappas@srs-us1.protection.inumbo.net>)
 id 1kYQSy-0002dH-GU
 for minios-devel@lists.xenproject.org; Fri, 30 Oct 2020 09:13:00 +0000
Received: from plasma4.jpberlin.de (unknown [80.241.57.33])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 92f932da-31fd-422e-9470-a509dd25ebc3;
 Fri, 30 Oct 2020 09:12:56 +0000 (UTC)
Received: from gerste.heinlein-support.de (gerste.heinlein-support.de
 [91.198.250.173])
 by plasma.jpberlin.de (Postfix) with ESMTP id 9D9FDAB91C
 for <minios-devel@lists.xenproject.org>; Fri, 30 Oct 2020 10:12:53 +0100 (CET)
Received: from plasma.jpberlin.de ([91.198.250.140])
 by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173])
 (amavisd-new, port 10030)
 with ESMTP id lU57V0wsjy7s for <minios-devel@lists.xenproject.org>;
 Fri, 30 Oct 2020 10:12:51 +0100 (CET)
Received: from webmail.opensynergy.com (unknown [217.66.60.5])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))
 (Client CN "*.opensynergy.com",
 Issuer "Starfield Secure Certificate Authority - G2" (not verified))
 (Authenticated sender: opensynergy@jpberlin.de)
 by plasma.jpberlin.de (Postfix) with ESMTPSA id DA5A3AB7FE
 for <minios-devel@lists.xenproject.org>; Fri, 30 Oct 2020 10:12:51 +0100 (CET)
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=wZ3U=EF=opensynergy.com=michalis.pappas@srs-us1.protection.inumbo.net>)
	id 1kYQSy-0002dH-GU
	for minios-devel@lists.xenproject.org; Fri, 30 Oct 2020 09:13:00 +0000
X-Inumbo-ID: 92f932da-31fd-422e-9470-a509dd25ebc3
Received: from plasma4.jpberlin.de (unknown [80.241.57.33])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 92f932da-31fd-422e-9470-a509dd25ebc3;
	Fri, 30 Oct 2020 09:12:56 +0000 (UTC)
Received: from gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173])
	by plasma.jpberlin.de (Postfix) with ESMTP id 9D9FDAB91C
	for <minios-devel@lists.xenproject.org>; Fri, 30 Oct 2020 10:12:53 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from plasma.jpberlin.de ([91.198.250.140])
	by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030)
	with ESMTP id lU57V0wsjy7s for <minios-devel@lists.xenproject.org>;
	Fri, 30 Oct 2020 10:12:51 +0100 (CET)
Received: from webmail.opensynergy.com (unknown [217.66.60.5])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))
	(Client CN "*.opensynergy.com", Issuer "Starfield Secure Certificate Authority - G2" (not verified))
	(Authenticated sender: opensynergy@jpberlin.de)
	by plasma.jpberlin.de (Postfix) with ESMTPSA id DA5A3AB7FE
	for <minios-devel@lists.xenproject.org>; Fri, 30 Oct 2020 10:12:51 +0100 (CET)
Subject: Re: [UNIKRAFT PATCH v2] include: Move sections.h to include/uk
To: <minios-devel@lists.xenproject.org>
References: <20201026161455.298231-1-stefanl.teodorescu@gmail.com>
 <cd39a36f-0e1a-0b90-3107-f2666d98a1c3@neclab.eu>
 <26b619c3-299c-b1aa-23f6-b0df5443550c@cs.pub.ro>
 <CAEiTdV77aNL280eDjTikQUtYLL6cnVkLSRhhozFi9tctHSPpEw@mail.gmail.com>
 <214ca2dd-2b50-3b37-8cca-737677a0c311@opensynergy.com>
 <dc168170-1e8b-7cf1-eea9-35ef07799acc@neclab.eu>
From: Michalis Pappas <michalis.pappas@opensynergy.com>
Message-ID: <2260143b-4a4e-03fb-111c-0a7f0dc1cc4a@opensynergy.com>
Date: Fri, 30 Oct 2020 10:12:50 +0100
MIME-Version: 1.0
In-Reply-To: <dc168170-1e8b-7cf1-eea9-35ef07799acc@neclab.eu>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-US
X-ClientProxiedBy: SR-MAIL-02.open-synergy.com (10.26.10.22) To
 SR-MAIL-01.open-synergy.com (10.26.10.21)
X-MBO-SPAM-Probability: 
X-Rspamd-Score: -7.62 / 15.00 / 15.00
X-Rspamd-Queue-Id: 9D9FDAB91C
X-Rspamd-UID: 9f7b5a

On 28/10/2020 21:08, Simon Kuenzer wrote:
> Hi all,
>
> @Michalis
> I think, a problem that we still architecturally have is that we 
> compile general purpose libs (like ukboot) once and link them multiple 
> times for each selected platform. This implies that exposing 
> platform-specific symbols to general purpose code is tricky. In 
> general purpose code, you can only rely on symbols that every platform 
> is providing. This is why I think that such specific symbols (like 
> _dtb) should stay within the platform and should be (indirectly) 
> exported (if at all needed) through a driver~ish or query API, 
> something similar we have with the memory regions, uknetdev, and 
> ukblkdev. The original idea was to make sure that general purpose 
> applications stay portable across different platforms. Of course, this 
> consideration does not include the case where you want to develop 
> something just for a single platform, like a driver domain for Xen 
> which would anyways not be portable to, lets say KVM. For now you 
> would be forced to put such code as platform library which isn't nice, 
> I agree. I think this needs a solution in general. Maybe the build 
> system could behave differently and unlock additional defintions when 
> we select only a single platform.

So the dtb address is something we need in all of our applications. I 
think it's a reasonable requirement for low-level applications / 
libraries in general. Recently we came up with a case where the 
application needs to know unikraft's base address. I am not sure if this 
a strong enough indication of a requirement for all section symbols to 
be available to applications, or whether exporting the dbt address would 
suffice. Of course, we can always work around this, but for the sake of 
backwards compatibility we would rather stick to upstream as much as we can.

>
> @Stefan
> Regarding moving sections.h to the generic `include/` folder, I still 
> did not really understand the reason and it is unclear to me what 
> should be the defined behavior in case of ASLR. In comparison, what 
> does happen with PIE executables on Linux? To my understanding, the 
> linker will resolve the symbols with the addresses in the image at 
> compile time. Do you know if PIE executables make use of the dynamic 
> linker for resolving? In such a case, this is a less problematic point.
>
> Alternatively, would the memory region query interface fit, too? The 
> idea of this would to overcome the problem that some things may change 
> at runtime (e.g., early platform boot code) compared to compile time.
>
> I think, we have two options:
>
> (1) In the case that the dynamic linker is normally taking care of 
> solving such symbols for position-independent executables, I think it 
> should be fine to place the header to `include/uk/plat/sections.h`. 
> The idea would be to revisit it later when we introduce ASLR. In 
> general we should make sure that we define only the symbols in there 
> which all platforms linker scripts provide (like the ones for text, 
> bss, etc). Platform-specific symbols should stay in the platform, like 
> `_dtb`.
>
> (2) Do not expose section.h to general purpose code and use the memory 
> region interface and maybe extend it with what you need.
>
> What do you think?
>
> Thanks,
>
> Simon
>
> On 28.10.20 15:26, Michalis Pappas wrote:
>> Before exposing sections.h to applications, I would like to take the 
>> opportunity to discuss some architectural matters.
>>
>> Currently linker scripts and their associated symbol definitions are 
>> owned by platforms. At the same time, sections.h is under 
>> plat/common/, and contains some common symbol names that are more or 
>> less declared by all platforms. Platforms wishing to declare 
>> additional, and perhaps less common symbol names, have the option to 
>> either (1) pollute sections.h, or (2) add these symbols to a 
>> platform-specific header. In case (1) sections.h will eventually 
>> contain a superset of all section symbols declared by all platforms, 
>> which is dirty. In case (2) platforms lose the ability to export 
>> their additional symbols to applications, which is also a problem.
>>
>> One possible approach to work around this would be to make symbols.h 
>> platform-specific, and then allow platforms to export 
>> platform-specific headers under platform subdirectories in 
>> include/uk/plat/ (eg include/uk/plat/kvm/sections.h), or 
>> alternatively export the current sections.h through include/uk/ and 
>> export additional platform-specific headers through platform 
>> subdirectories in include/uk/plat/, as above.
>>
>> Thanks,
>>
>> Michalis
>>
>> On 28/10/2020 14:45, Stefan Teodorescu wrote:
>>> Hi everyone,
>>>
>>> Sorry for the confusion, this is my fault that I didn't clarify enough
>>> in the commit message and that I didn't update it in the meantime.
>>>
>>> I am using the sections.h header in the mem_layout.h header (which is
>>> also in include/uk) that I am writing now to describe the virtual
>>> memory areas (kernel, stack, heap etc.). At the moment, I think I was
>>> using the sections.h header in some arch code but this is not the case
>>> anymore. However, as Costin mentioned, we thought at the time that we
>>> could move this anyway, since it's not actually platform dependent.
>>>
>>> I'll send a v2 with an updated commit message.
>>>
>>> Thanks,
>>> Stefan
>>>
>>>
>>>
>>> On Wed, Oct 28, 2020 at 3:19 PM Costin Lupu <costin.lupu@cs.pub.ro> 
>>> wrote:
>>>> Hi Simon,
>>>>
>>>> Regardless whether these changes are needed or not by arch code (I'll
>>>> leave that for Ștefan to explain), the definitions in sections.h 
>>>> should
>>>> stay under include/uk in order to be accessible from everywhere.
>>>> Moreover, the definitions in it are related to neither arch or 
>>>> platform.
>>>>
>>>> Cheers,
>>>> Costin
>>>>
>>>> On 10/28/20 3:14 PM, Simon Kuenzer wrote:
>>>>> Hey Stefan, hey Costin,
>>>>>
>>>>> what is the reason that arch code needs sections.h? I can't read 
>>>>> it from
>>>>> the commit message. Architecture code should only be the parts 
>>>>> that are
>>>>> totally independent on the platform details. They are mostly 
>>>>> helpers for
>>>>> arithmetics and CPU register definitions. I am concerned that
>>>>> architecture code may break when doing assumptions on symbol 
>>>>> locations;
>>>>> imagine ASLR where locations are moved at runtime.
>>>>>
>>>>> The NX bit patch is upstream.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Simon
>>>>>
>>>>> On 26.10.20 17:14, stefanl.teodorescu@gmail.com wrote:
>>>>>> From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
>>>>>>
>>>>>> Move plat/common/include/uk/plat/common/sections.h to
>>>>>> include/uk/sections.h to be able to include it in arch code. This 
>>>>>> file
>>>>>> is platform independent, so it does not affect anything.
>>>>>>
>>>>>> Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
>>>>>> ---
>>>>>>    {plat/common/include/uk/plat/common => include/uk}/sections.h | 0
>>>>>> plat/kvm/arm/entry64.S | 2 +-
>>>>>> plat/kvm/arm/setup.c | 2 +-
>>>>>> plat/kvm/memory.c | 2 +-
>>>>>> plat/kvm/x86/setup.c | 2 +-
>>>>>> plat/xen/arm/setup.c | 2 +-
>>>>>> plat/xen/include/xen-arm/mm.h | 2 +-
>>>>>> plat/xen/include/xen-x86/mm.h | 2 +-
>>>>>> plat/xen/memory.c | 2 +-
>>>>>> plat/xen/x86/mm.c | 2 +-
>>>>>>    10 files changed, 9 insertions(+), 9 deletions(-)
>>>>>>    rename {plat/common/include/uk/plat/common => 
>>>>>> include/uk}/sections.h
>>>>>> (100%)
>>>>>>
>>>>>> diff --git a/plat/common/include/uk/plat/common/sections.h
>>>>>> b/include/uk/sections.h
>>>>>> similarity index 100%
>>>>>> rename from plat/common/include/uk/plat/common/sections.h
>>>>>> rename to include/uk/sections.h
>>>>>> diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S
>>>>>> index c4de334c..8be3d59f 100644
>>>>>> --- a/plat/kvm/arm/entry64.S
>>>>>> +++ b/plat/kvm/arm/entry64.S
>>>>>> @@ -35,7 +35,7 @@
>>>>>>    #include <uk/asm.h>
>>>>>>    #include <kvm-arm/mm.h>
>>>>>>    #include <arm/cpu_defs.h>
>>>>>> -#include <uk/plat/common/sections.h>
>>>>>> +#include <uk/sections.h>
>>>>>>    #include <uk/config.h>
>>>>>>
>>>>>>    .global page_table_size
>>>>>> diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c
>>>>>> index 41e63755..8513b48c 100644
>>>>>> --- a/plat/kvm/arm/setup.c
>>>>>> +++ b/plat/kvm/arm/setup.c
>>>>>> @@ -20,7 +20,7 @@
>>>>>>     */
>>>>>>    #include <uk/config.h>
>>>>>>    #include <libfdt.h>
>>>>>> -#include <uk/plat/common/sections.h>
>>>>>> +#include <uk/sections.h>
>>>>>>    #include <kvm/console.h>
>>>>>>    #include <kvm/config.h>
>>>>>>    #include <uk/assert.h>
>>>>>> diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
>>>>>> index 1d9269ec..61d3e6ca 100644
>>>>>> --- a/plat/kvm/memory.c
>>>>>> +++ b/plat/kvm/memory.c
>>>>>> @@ -19,7 +19,7 @@
>>>>>>     * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>>>>>>     */
>>>>>>
>>>>>> -#include <uk/plat/common/sections.h>
>>>>>> +#include <uk/sections.h>
>>>>>>    #include <sys/types.h>
>>>>>>    #include <uk/plat/memory.h>
>>>>>>    #include <uk/assert.h>
>>>>>> diff --git a/plat/kvm/x86/setup.c b/plat/kvm/x86/setup.c
>>>>>> index 9c7a93a8..1cab0a63 100644
>>>>>> --- a/plat/kvm/x86/setup.c
>>>>>> +++ b/plat/kvm/x86/setup.c
>>>>>> @@ -27,7 +27,7 @@
>>>>>>     */
>>>>>>
>>>>>>    #include <string.h>
>>>>>> -#include <uk/plat/common/sections.h>
>>>>>> +#include <uk/sections.h>
>>>>>>    #include <x86/cpu.h>
>>>>>>    #include <x86/traps.h>
>>>>>>    #include <kvm/config.h>
>>>>>> diff --git a/plat/xen/arm/setup.c b/plat/xen/arm/setup.c
>>>>>> index 2df3b46c..bcbc939e 100644
>>>>>> --- a/plat/xen/arm/setup.c
>>>>>> +++ b/plat/xen/arm/setup.c
>>>>>> @@ -25,7 +25,7 @@
>>>>>>    /* Ported from Mini-OS */
>>>>>>
>>>>>>    #include <string.h>
>>>>>> -#include <uk/plat/common/sections.h>
>>>>>> +#include <uk/sections.h>
>>>>>>    #include <xen-arm/os.h>
>>>>>>    #include <xen-arm/mm.h>
>>>>>>    #include <xen/xen.h>
>>>>>> diff --git a/plat/xen/include/xen-arm/mm.h
>>>>>> b/plat/xen/include/xen-arm/mm.h
>>>>>> index 659de843..bbd31ddd 100644
>>>>>> --- a/plat/xen/include/xen-arm/mm.h
>>>>>> +++ b/plat/xen/include/xen-arm/mm.h
>>>>>> @@ -28,7 +28,7 @@
>>>>>>    #define _ARCH_MM_H_
>>>>>>
>>>>>>    #include <stdint.h>
>>>>>> -#include <uk/plat/common/sections.h>
>>>>>> +#include <uk/sections.h>
>>>>>>    #include <uk/arch/limits.h>
>>>>>>
>>>>>>    typedef uint64_t paddr_t;
>>>>>> diff --git a/plat/xen/include/xen-x86/mm.h
>>>>>> b/plat/xen/include/xen-x86/mm.h
>>>>>> index ffbedb09..99ba6d05 100644
>>>>>> --- a/plat/xen/include/xen-x86/mm.h
>>>>>> +++ b/plat/xen/include/xen-x86/mm.h
>>>>>> @@ -25,7 +25,7 @@
>>>>>>    #ifndef _ARCH_MM_H_
>>>>>>    #define _ARCH_MM_H_
>>>>>>
>>>>>> -#include <uk/plat/common/sections.h>
>>>>>> +#include <uk/sections.h>
>>>>>>    #ifndef __ASSEMBLY__
>>>>>>    #include <xen/xen.h>
>>>>>>    #if defined(__i386__)
>>>>>> diff --git a/plat/xen/memory.c b/plat/xen/memory.c
>>>>>> index 8e7a7dda..27a317c4 100644
>>>>>> --- a/plat/xen/memory.c
>>>>>> +++ b/plat/xen/memory.c
>>>>>> @@ -34,7 +34,7 @@
>>>>>>     */
>>>>>>
>>>>>>    #include <string.h>
>>>>>> -#include <uk/plat/common/sections.h>
>>>>>> +#include <uk/sections.h>
>>>>>>
>>>>>>    #include <common/gnttab.h>
>>>>>>    #if (defined __X86_32__) || (defined __X86_64__)
>>>>>> diff --git a/plat/xen/x86/mm.c b/plat/xen/x86/mm.c
>>>>>> index e006ab7f..9e352eed 100644
>>>>>> --- a/plat/xen/x86/mm.c
>>>>>> +++ b/plat/xen/x86/mm.c
>>>>>> @@ -36,7 +36,7 @@
>>>>>>     */
>>>>>>
>>>>>>    #include <string.h>
>>>>>> -#include <uk/plat/common/sections.h>
>>>>>> +#include <uk/sections.h>
>>>>>>    #include <errno.h>
>>>>>>    #include <uk/alloc.h>
>>>>>>    #include <uk/plat/config.h>
>>>>>> -- 
>>>>>> 2.29.0
>>>>>>
>>>>>>
>>>
>
>
-- 
Michalis Pappas
Senior Software Engineer

OpenSynergy GmbH
Rotherstr. 20, 10245 Berlin

p: +49 (30) 60 98 54 0 - 0
f: +49 (30) 60 98 54 0 - 99

e: michalis.pappas@opensynergy.com

w: www.opensynergy.com

registered: Amtsgericht Charlottenburg, HRB 108616B

Handelsregister: Amtsgericht Charlottenburg, HRB 108616B
Geschäftsführer/Managing Director: Regis Adjamah



From minios-devel-bounces@lists.xenproject.org Fri Oct 30 11:13:40 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 11:13:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.15671.38735 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYSLg-0006QD-ER; Fri, 30 Oct 2020 11:13:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 15671.38735; Fri, 30 Oct 2020 11:13:36 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYSLg-0006Q6-BT; Fri, 30 Oct 2020 11:13:36 +0000
Received: by outflank-mailman (input) for mailman id 15671;
 Fri, 30 Oct 2020 11:13: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=lCH5=EF=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
 id 1kYSLf-0006Q1-FE
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 11:13:35 +0000
Received: from mail-ed1-x543.google.com (unknown [2a00:1450:4864:20::543])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 3bb740a7-d778-4f69-a1ea-d0265720a514;
 Fri, 30 Oct 2020 11:13:34 +0000 (UTC)
Received: by mail-ed1-x543.google.com with SMTP id x1so6239932eds.1
 for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 04:13:34 -0700 (PDT)
Received: from arch.localdomain (5-12-21-167.residential.rdsnet.ro.
 [5.12.21.167])
 by smtp.gmail.com with ESMTPSA id p18sm3046984edt.23.2020.10.30.04.13.32
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 30 Oct 2020 04:13:32 -0700 (PDT)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=lCH5=EF=gmail.com=stefanl.teodorescu@srs-us1.protection.inumbo.net>)
	id 1kYSLf-0006Q1-FE
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 11:13:35 +0000
X-Inumbo-ID: 3bb740a7-d778-4f69-a1ea-d0265720a514
Received: from mail-ed1-x543.google.com (unknown [2a00:1450:4864:20::543])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 3bb740a7-d778-4f69-a1ea-d0265720a514;
	Fri, 30 Oct 2020 11:13:34 +0000 (UTC)
Received: by mail-ed1-x543.google.com with SMTP id x1so6239932eds.1
        for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 04:13:34 -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=U7gxbeQHyhDKv2N6DIa6XTF88kxjuUW02XmU5TKHQ44=;
        b=i+1gcrOxvfrjkcSKFYVD3zcStu557Ojhd8JdQ/3FJUfSvASPp5hgiNVG9i8guSFiMW
         IVZPu4Oa/UGyMfpPPE8SjVLkHZCQCdksZ9lQMOoWWvbmnZua/V0pdk4SRjiXWxrsbhOO
         E4Vif9j6jtMP6s90qHXBFEZOKm/NJH9RnwZMBvCZtNCL0R9TLoHnMG8ML4yZm7crEfxk
         3Z3E4QRD1pNOP3D6PxWx+dm91hI45gWpnC+VFPgaAOG4zEfHWzhdEt5xEvNtC2EZFs0z
         5xXD4AK07RQbPrOIpu5QdmxaTCuLIv8EradNAEc5Xu7THUr/ljM2pW5A6lxGUtqfmGel
         qTNg==
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=U7gxbeQHyhDKv2N6DIa6XTF88kxjuUW02XmU5TKHQ44=;
        b=WPvo1MkatYy/G0+SMs8wdJ/wX2yDXP72E5MFKPqF4Her7Rxrmrtd5sKD1/yK1hov5h
         5TEVEoz6TjoJjavsE/WF0x9pjkZ+KSsdLCm0fZon5x+/BcM12HsUmmPmq2GUYur8/517
         EOdRHQ34teCHh81noU3vBHwlxyQSu1zWUsxS/9O4LpCqEVv2HYfKM/+c4ti3r6uMHzKC
         fo4WnslINciQYCq27jpkIYrT+RlnnjGPupDfIidwLCCAdHuxZcQpZ9ydAnwfJUwTd7ex
         Gc7Bx361gguOI6JjBirynn+qZzQUPOEivWzsYIcv4Pt9izAWjk7XubFcgEWZQqG3NfLz
         mEgg==
X-Gm-Message-State: AOAM5321je5fixLRpLoKLsI0RRiKwmsBfpq1RtANXdoZLi98slg/6Ju/
	JpjzIqSZ4c9nBdOfByZ+0bta4YOZMBkWfQ==
X-Google-Smtp-Source: ABdhPJzwYHAabBBNJ/v/zLVBLXnsLCaq6U+o2vFhdI5m2hcPrlDZtCS9CK9Yx3VY1i+9i4tCCS/ESQ==
X-Received: by 2002:aa7:d7ca:: with SMTP id e10mr1639245eds.269.1604056413423;
        Fri, 30 Oct 2020 04:13:33 -0700 (PDT)
Received: from arch.localdomain (5-12-21-167.residential.rdsnet.ro. [5.12.21.167])
        by smtp.gmail.com with ESMTPSA id p18sm3046984edt.23.2020.10.30.04.13.32
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 30 Oct 2020 04:13:32 -0700 (PDT)
From: stefanl.teodorescu@gmail.com
To: minios-devel@lists.xen.org
Cc: costin.lup@gmail.com,
	Stefan Teodorescu <stefanl.teodorescu@gmail.com>
Subject: [UNIKRAFT PATCH] include: Include string.h in uk/bitmap.h
Date: Fri, 30 Oct 2020 13:13:24 +0200
Message-Id: <20201030111324.545565-1-stefanl.teodorescu@gmail.com>
X-Mailer: git-send-email 2.29.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>

The string.h header was not included in uk/bitmap.h and was generating
compiler warnings for implicit declaration of memset.

Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
---
 include/uk/bitmap.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uk/bitmap.h b/include/uk/bitmap.h
index d6e360ab..f635b7f8 100644
--- a/include/uk/bitmap.h
+++ b/include/uk/bitmap.h
@@ -30,6 +30,7 @@
 #ifndef _LINUX_BITMAP_H_
 #define	_LINUX_BITMAP_H_

+#include <string.h>
 #include <uk/bitops.h>

 static inline void
--
2.29.0



From minios-devel-bounces@lists.xenproject.org Fri Oct 30 11:54:31 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 11:54:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.15711.38792 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYSzD-0001sQ-LM; Fri, 30 Oct 2020 11:54:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 15711.38792; Fri, 30 Oct 2020 11:54:27 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYSzD-0001sJ-IF; Fri, 30 Oct 2020 11:54:27 +0000
Received: by outflank-mailman (input) for mailman id 15711;
 Fri, 30 Oct 2020 11:54:26 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=JCc7=EF=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
 id 1kYSzC-0001sE-K9
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 11:54:26 +0000
Received: from mx.upb.ro (unknown [141.85.13.200])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id df502437-c55a-4898-9e42-82f754935268;
 Fri, 30 Oct 2020 11:54:24 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id E4EBDB561EA2;
 Fri, 30 Oct 2020 13:54:22 +0200 (EET)
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 ImoSGBGNZ7gW; Fri, 30 Oct 2020 13:54:21 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
 by mx.upb.ro (Postfix) with ESMTP id 2D074B562287;
 Fri, 30 Oct 2020 13:54:21 +0200 (EET)
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 QfLA4SPi8j3Q; Fri, 30 Oct 2020 13:54:21 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
 by mx.upb.ro (Postfix) with ESMTPSA id E69E3B561EA2;
 Fri, 30 Oct 2020 13:54:20 +0200 (EET)
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=JCc7=EF=cs.pub.ro=costin.lupu@srs-us1.protection.inumbo.net>)
	id 1kYSzC-0001sE-K9
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 11:54:26 +0000
X-Inumbo-ID: df502437-c55a-4898-9e42-82f754935268
Received: from mx.upb.ro (unknown [141.85.13.200])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id df502437-c55a-4898-9e42-82f754935268;
	Fri, 30 Oct 2020 11:54:24 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id E4EBDB561EA2;
	Fri, 30 Oct 2020 13:54:22 +0200 (EET)
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 ImoSGBGNZ7gW; Fri, 30 Oct 2020 13:54:21 +0200 (EET)
Received: from localhost (localhost [127.0.0.1])
	by mx.upb.ro (Postfix) with ESMTP id 2D074B562287;
	Fri, 30 Oct 2020 13:54:21 +0200 (EET)
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 QfLA4SPi8j3Q; Fri, 30 Oct 2020 13:54:21 +0200 (EET)
Received: from [192.168.1.35] (unknown [188.25.174.124])
	by mx.upb.ro (Postfix) with ESMTPSA id E69E3B561EA2;
	Fri, 30 Oct 2020 13:54:20 +0200 (EET)
Subject: Re: [UNIKRAFT PATCH] include: Include string.h in uk/bitmap.h
To: stefanl.teodorescu@gmail.com, minios-devel@lists.xen.org
References: <20201030111324.545565-1-stefanl.teodorescu@gmail.com>
From: Costin Lupu <costin.lupu@cs.pub.ro>
Message-ID: <1593e4d4-612b-95c5-53fe-1c0fbf823a0b@cs.pub.ro>
Date: Fri, 30 Oct 2020 13:54:20 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.3.1
MIME-Version: 1.0
In-Reply-To: <20201030111324.545565-1-stefanl.teodorescu@gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit

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

On 10/30/20 1:13 PM, stefanl.teodorescu@gmail.com wrote:
> From: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> 
> The string.h header was not included in uk/bitmap.h and was generating
> compiler warnings for implicit declaration of memset.
> 
> Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
> ---
>  include/uk/bitmap.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/uk/bitmap.h b/include/uk/bitmap.h
> index d6e360ab..f635b7f8 100644
> --- a/include/uk/bitmap.h
> +++ b/include/uk/bitmap.h
> @@ -30,6 +30,7 @@
>  #ifndef _LINUX_BITMAP_H_
>  #define	_LINUX_BITMAP_H_
> 
> +#include <string.h>
>  #include <uk/bitops.h>
> 
>  static inline void
> --
> 2.29.0
> 
> 


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 13:41:42 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 13:41:42 +0000
Received: from list by lists.xenproject.org with outflank-mailman.15838.39059 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUey-00050X-73; Fri, 30 Oct 2020 13:41:40 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 15838.39059; Fri, 30 Oct 2020 13:41:40 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUey-00050Q-3y; Fri, 30 Oct 2020 13:41:40 +0000
Received: by outflank-mailman (input) for mailman id 15838;
 Fri, 30 Oct 2020 13:41: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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYUew-00050I-PM
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:41:38 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 84c6cdda-94f9-452a-a1de-0fffb5c0746b;
 Fri, 30 Oct 2020 13:41:36 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 947B61041EF;
 Fri, 30 Oct 2020 14:41:35 +0100 (CET)
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 QdL9JXiYqaBS; Fri, 30 Oct 2020 14:41:35 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 703D6103075
 for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:41:35 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:41:35 +0100
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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYUew-00050I-PM
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:41:38 +0000
X-Inumbo-ID: 84c6cdda-94f9-452a-a1de-0fffb5c0746b
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 84c6cdda-94f9-452a-a1de-0fffb5c0746b;
	Fri, 30 Oct 2020 13:41:36 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 947B61041EF;
	Fri, 30 Oct 2020 14:41:35 +0100 (CET)
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 QdL9JXiYqaBS; Fri, 30 Oct 2020 14:41:35 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 703D6103075
	for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:41:35 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:41:35 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 0/4] lib/uknetdev: Aligned netbufs
Date: Fri, 30 Oct 2020 14:41:29 +0100
Message-ID: <20201030134133.15307-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 titania.office.hd
 (192.168.24.89)

Provide the ability for allocating aligned netbufs that some
devices require (e.g., Xen netfront). For this purpose, the
netbuf metadata is moved to the end of an allocation instead
to the start which normally cause an unknown offset of the
packet buffer area.
Similar to lib/ukblkdev, an `ioalign` parameter is provided
so that alignment requirements of network devices for packet
buffers can be queried.

Simon Kuenzer (4):
  lib/uknetdev: netbuf: Store allocation base
  lib/uknetdev: netbuf: Metadata at the end of an allocation
  lib/uknetdev: `uk_netbuf_alloc_buf()`: Introduce alignment
  lib/uknetdev: Introduce ioalign

 lib/uknetdev/include/uk/netbuf.h      |  34 +++----
 lib/uknetdev/include/uk/netdev_core.h |   5 +-
 lib/uknetdev/netbuf.c                 | 122 +++++++++++---------------
 plat/drivers/virtio/virtio_net.c      |   3 +-
 4 files changed, 73 insertions(+), 91 deletions(-)

-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 13:41:53 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 13:41:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.15840.39063 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUfB-000529-9N; Fri, 30 Oct 2020 13:41:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 15840.39063; Fri, 30 Oct 2020 13:41:53 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUfB-000521-5z; Fri, 30 Oct 2020 13:41:53 +0000
Received: by outflank-mailman (input) for mailman id 15840;
 Fri, 30 Oct 2020 13:41:51 +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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYUf9-00051q-Hh
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:41:51 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 6bec4708-11d0-4544-9bfb-be01b87b6f95;
 Fri, 30 Oct 2020 13:41:50 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id B53F0F21D0;
 Fri, 30 Oct 2020 14:41:49 +0100 (CET)
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 s2my7UXlK_zD; Fri, 30 Oct 2020 14:41:49 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 81023F21CC
 for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:41:47 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:41:47 +0100
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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYUf9-00051q-Hh
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:41:51 +0000
X-Inumbo-ID: 6bec4708-11d0-4544-9bfb-be01b87b6f95
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 6bec4708-11d0-4544-9bfb-be01b87b6f95;
	Fri, 30 Oct 2020 13:41:50 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id B53F0F21D0;
	Fri, 30 Oct 2020 14:41:49 +0100 (CET)
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 s2my7UXlK_zD; Fri, 30 Oct 2020 14:41:49 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 81023F21CC
	for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:41:47 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:41:47 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 1/4] lib/uknetdev: netbuf: Store allocation base
Date: Fri, 30 Oct 2020 14:41:30 +0100
Message-ID: <20201030134133.15307-2-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201030134133.15307-1-simon.kuenzer@neclab.eu>
References: <20201030134133.15307-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

In order to support flexible location of meta data (`struct uk_netbuf`) as
part of a corresponding allocation, we store the base address of it as
netbuf internal data. This address will be hand-over to the free operation
when such a netbuf is released.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/uknetdev/include/uk/netbuf.h |  1 +
 lib/uknetdev/netbuf.c            | 25 +++++++++++++++----------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lib/uknetdev/include/uk/netbuf.h b/lib/uknetdev/include/uk/netbuf.h
index df691eab..f21d082b 100644
--- a/lib/uknetdev/include/uk/netbuf.h
+++ b/lib/uknetdev/include/uk/netbuf.h
@@ -119,6 +119,7 @@ struct uk_netbuf {
 
 	uk_netbuf_dtor_t dtor; /**< Destructor callback */
 	struct uk_alloc *_a;   /**< @internal Allocator for free'ing */
+	void *_b;              /**< @internal Base address for free'ing */
 };
 
 /*
diff --git a/lib/uknetdev/netbuf.c b/lib/uknetdev/netbuf.c
index bd39c543..5156e808 100644
--- a/lib/uknetdev/netbuf.c
+++ b/lib/uknetdev/netbuf.c
@@ -58,7 +58,8 @@ void uk_netbuf_init_indir(struct uk_netbuf *m,
 
 	m->priv   = priv;
 	m->dtor   = dtor;
-	m->_a      = NULL;
+	m->_a     = NULL;
+	m->_b     = NULL;
 }
 
 struct uk_netbuf *uk_netbuf_alloc_indir(struct uk_alloc *a,
@@ -89,6 +90,7 @@ struct uk_netbuf *uk_netbuf_alloc_indir(struct uk_alloc *a,
 	 * for free'ing this uk_netbuf.
 	 */
 	m->_a = a;
+	m->_b = m;
 
 	return m;
 }
@@ -138,10 +140,11 @@ struct uk_netbuf *uk_netbuf_alloc_buf(struct uk_alloc *a, size_t buflen,
 			     privlen > 0 ? ((void *) m + priv_offset) : NULL,
 			     dtor);
 
-	/* Save reference to allocator that is used
-	 * for free'ing this uk_netbuf.
+	/* Save reference to allocator and allocation
+	 * that is used for free'ing this uk_netbuf.
 	 */
 	m->_a = a;
+	m->_b = m;
 
 	return m;
 }
@@ -246,6 +249,7 @@ void uk_netbuf_append(struct uk_netbuf *head,
 void uk_netbuf_free_single(struct uk_netbuf *m)
 {
 	struct uk_alloc *a;
+	void *b;
 
 	UK_ASSERT(m);
 
@@ -258,19 +262,20 @@ void uk_netbuf_free_single(struct uk_netbuf *m)
 		/* Disconnect this netbuf from the chain. */
 		uk_netbuf_disconnect(m);
 
-		/* Copy the reference of the allocator in case
-		 * the destructor is free'ing up our memory
+		/* Copy the reference of the allocator and base address
+		 * in case the destructor is free'ing up our memory
 		 * (e.g., uk_netbuf_init_indir() used).
-		 * In such a case `a` should be (NULL), however
-		 * we need to access it for a  check after we have
-		 * called the destructor.
+		 * In such a case `a` and `b` should be (NULL),
+		 * however we need to access them for a check after
+		 * we have called the destructor.
 		 */
 		a = m->_a;
+		b = m->_b;
 
 		if (m->dtor)
 			m->dtor(m);
-		if (a)
-			uk_free(a, m);
+		if (a && b)
+			uk_free(a, b);
 	} else {
 		uk_pr_debug("Not freeing netbuf %p (next: %p): refcount greater than 1",
 			    m, m->next);
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 13:41:56 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 13:41:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.15841.39067 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUfE-000537-B3; Fri, 30 Oct 2020 13:41:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 15841.39067; Fri, 30 Oct 2020 13:41:56 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUfE-000530-7Y; Fri, 30 Oct 2020 13:41:56 +0000
Received: by outflank-mailman (input) for mailman id 15841;
 Fri, 30 Oct 2020 13:41: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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYUfD-00052l-2M
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:41:55 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 722f932a-a073-453b-ada5-f80a7753e55d;
 Fri, 30 Oct 2020 13:41:52 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id BCA23F21D0;
 Fri, 30 Oct 2020 14:41:51 +0100 (CET)
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 hJclS1imuGmH; Fri, 30 Oct 2020 14:41:51 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 91434F21CC
 for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:41:49 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:41:48 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYUfD-00052l-2M
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:41:55 +0000
X-Inumbo-ID: 722f932a-a073-453b-ada5-f80a7753e55d
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 722f932a-a073-453b-ada5-f80a7753e55d;
	Fri, 30 Oct 2020 13:41:52 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id BCA23F21D0;
	Fri, 30 Oct 2020 14:41:51 +0100 (CET)
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 hJclS1imuGmH; Fri, 30 Oct 2020 14:41:51 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 91434F21CC
	for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:41:49 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:41:48 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 2/4] lib/uknetdev: netbuf: Metadata at the end of an allocation
Date: Fri, 30 Oct 2020 14:41:31 +0100
Message-ID: <20201030134133.15307-3-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201030134133.15307-1-simon.kuenzer@neclab.eu>
References: <20201030134133.15307-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Place the netbuf metadata (`struct netbuf`) at the end of an allocation.
This enables forwarding possible alignments of an underlying allocation
to the buffer area of a netbuf. The metadata will no longer cause an offset
of the buffer start address (`m->buf`).

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/uknetdev/include/uk/netbuf.h | 29 +++++-----
 lib/uknetdev/netbuf.c            | 97 ++++++++++++--------------------
 2 files changed, 50 insertions(+), 76 deletions(-)

diff --git a/lib/uknetdev/include/uk/netbuf.h b/lib/uknetdev/include/uk/netbuf.h
index f21d082b..ea803ae8 100644
--- a/lib/uknetdev/include/uk/netbuf.h
+++ b/lib/uknetdev/include/uk/netbuf.h
@@ -57,18 +57,6 @@ typedef void (*uk_netbuf_dtor_t)(struct uk_netbuf *);
  * The structure can be chained to describe a packet with multiple scattered
  * buffers.
  *
- * NETBUF
- *                  +----------------------+
- *                  |   struct uk_netbuf   |
- *                  |                      |
- *                  +----------------------+
- *
- * PRIVATE META DATA
- *         *priv -> +----------------------+
- *                  |      private meta    |
- *                  |       data area      |
- *                  +----------------------+
- *
  * PACKET BUFFER
  *          *buf -> +----------------------+ \
  *                  |      HEAD ROOM       |  |
@@ -82,6 +70,17 @@ typedef void (*uk_netbuf_dtor_t)(struct uk_netbuf *);
  *                  |      TAIL ROOM       |  |
  * *buf + buflen -> +----------------------+ /
  *
+ * NETBUF
+ *                  +----------------------+
+ *                  |   struct uk_netbuf   |
+ *                  |                      |
+ *                  +----------------------+
+ *
+ * PRIVATE META DATA
+ *         *priv -> +----------------------+
+ *                  |      private meta    |
+ *                  |       data area      |
+ *                  +----------------------+
  *
  * The private data area is intended for glue code that wants to embed stack-
  * specific data to the netbuf (e.g., `struct pbuf` for lwIP). This avoids
@@ -237,7 +236,8 @@ struct uk_netbuf *uk_netbuf_alloc_indir(struct uk_alloc *a,
 
 /**
  * Allocate and initialize netbuf with data buffer area.
- * m->len is initialized with 0.
+ * m->len is initialized with 0. Metadata (struct uknetbuf, priv)
+ * is placed at the end of the according allocation.
  * @param a
  *   Allocator to be used for allocating `struct uk_netbuf` and the
  *   corresponding buffer area (single allocation).
@@ -268,7 +268,8 @@ struct uk_netbuf *uk_netbuf_alloc_buf(struct uk_alloc *a, size_t buflen,
 
 /**
  * Initialize netbuf with data buffer on a user given allocated memory area
- * m->len is initialized with 0.
+ * m->len is initialized with 0. Metadata (struct uknetbuf, priv)
+ * is placed at the end of the given allocation.
  * @param mem
  *   Reference to user provided memory region
  * @param buflen
diff --git a/lib/uknetdev/netbuf.c b/lib/uknetdev/netbuf.c
index 5156e808..c5cf662e 100644
--- a/lib/uknetdev/netbuf.c
+++ b/lib/uknetdev/netbuf.c
@@ -37,7 +37,10 @@
 
 /* Used to align netbuf's priv and data areas to `long long` data type */
 #define NETBUF_ADDR_ALIGNMENT (sizeof(long long))
-#define NETBUF_ADDR_ALIGN_UP(x) ALIGN_UP((x), NETBUF_ADDR_ALIGNMENT)
+#define NETBUF_ADDR_ALIGN_UP(x)   ALIGN_UP((__uptr) (x), \
+					   NETBUF_ADDR_ALIGNMENT)
+#define NETBUF_ADDR_ALIGN_DOWN(x) ALIGN_DOWN((__uptr) (x), \
+					     NETBUF_ADDR_ALIGNMENT)
 
 void uk_netbuf_init_indir(struct uk_netbuf *m,
 			  void *buf, size_t buflen, uint16_t headroom,
@@ -99,52 +102,34 @@ struct uk_netbuf *uk_netbuf_alloc_buf(struct uk_alloc *a, size_t buflen,
 				      uint16_t headroom,
 				      size_t privlen, uk_netbuf_dtor_t dtor)
 {
+	void *mem;
+	size_t alloc_len;
 	struct uk_netbuf *m;
-	size_t buf_offset = 0;
-	size_t priv_offset = 0;
-	size_t headroom_extra = 0;
 
 	UK_ASSERT(buflen > 0);
 	UK_ASSERT(headroom <= buflen);
 
-	m = uk_malloc(a, NETBUF_ADDR_ALIGN_UP(sizeof(*m))
-		      + NETBUF_ADDR_ALIGN_UP(privlen)
-		      + buflen);
-	if (!m)
+	alloc_len = NETBUF_ADDR_ALIGN_UP(buflen)
+		    + NETBUF_ADDR_ALIGN_UP(sizeof(*m) + privlen);
+	mem = uk_malloc(a, alloc_len);
+	if (!mem)
 		return NULL;
 
-	/* Place buf right behind `m` or `m->priv` region if privlen > 0.
-	 * In order to keep `m->data - headroom` aligned the padding bytes
-	 *  are added to the headroom.
-	 * We can only do this if the given headroom stays within
-	 *  uint16_t bounds after the operation.
-	 */
-	if (likely((size_t)(UINT16_MAX - headroom) > NETBUF_ADDR_ALIGNMENT)) {
-		if (privlen == 0) {
-			priv_offset    = 0;
-			buf_offset     = sizeof(*m);
-			headroom_extra = NETBUF_ADDR_ALIGN_UP(sizeof(*m))
-					 - sizeof(*m);
-		} else {
-			priv_offset    = NETBUF_ADDR_ALIGN_UP(sizeof(*m));
-			buf_offset     = priv_offset + privlen;
-			headroom_extra = NETBUF_ADDR_ALIGN_UP(privlen)
-					 - privlen;
-		}
+	m = uk_netbuf_prepare_buf(mem,
+				  alloc_len,
+				  headroom,
+				  privlen,
+				  dtor);
+	if (!m) {
+		uk_free(a, mem);
+		return NULL;
 	}
 
-	uk_netbuf_init_indir(m,
-			     (void *) m + buf_offset,
-			     buflen + headroom_extra,
-			     headroom + headroom_extra,
-			     privlen > 0 ? ((void *) m + priv_offset) : NULL,
-			     dtor);
-
 	/* Save reference to allocator and allocation
 	 * that is used for free'ing this uk_netbuf.
 	 */
 	m->_a = a;
-	m->_b = m;
+	m->_b = mem;
 
 	return m;
 }
@@ -154,41 +139,29 @@ struct uk_netbuf *uk_netbuf_prepare_buf(void *mem, size_t size,
 					size_t privlen, uk_netbuf_dtor_t dtor)
 {
 	struct uk_netbuf *m;
-	size_t buf_offset = 0;
-	size_t priv_offset = 0;
+	size_t meta_len = 0;
 
 	UK_ASSERT(mem);
-	if ((NETBUF_ADDR_ALIGN_UP(sizeof(*m))
-	     + NETBUF_ADDR_ALIGN_UP(privlen)
-	     + headroom) > size)
-		return NULL;
 
-	/* Place buf right behind `m` or `m->priv` region if privlen > 0.
-	 * In order to keep `m->data - headroom` aligned the padding bytes
-	 *  are added to the headroom.
-	 * We can only do this if the given headroom stays within
-	 *  uint16_t bounds after the operation.
+	/* Place headroom and buf at the beginning of the allocation,
+	 * This is done in order to forward potential alignments of the
+	 * underlying allocation directly to the netbuf data area.
+	 * `m` (followed by `m->priv` if privlen > 0) will be placed at
+	 * the end of the given memory.
 	 */
-	if (likely((size_t)(UINT16_MAX - headroom) > NETBUF_ADDR_ALIGNMENT)) {
-		if (privlen == 0) {
-			priv_offset = 0;
-			buf_offset  = sizeof(*m);
-			headroom   += NETBUF_ADDR_ALIGN_UP(sizeof(*m))
-				      - sizeof(*m);
-		} else {
-			priv_offset = NETBUF_ADDR_ALIGN_UP(sizeof(*m));
-			buf_offset  = priv_offset + privlen;
-			headroom   += NETBUF_ADDR_ALIGN_UP(privlen)
-				      - privlen;
-		}
-	}
+	meta_len = NETBUF_ADDR_ALIGN_UP(sizeof(*m) + privlen);
+	if (meta_len > NETBUF_ADDR_ALIGN_DOWN((__uptr) mem + size))
+		return NULL;
+
+	m = (struct uk_netbuf *) (NETBUF_ADDR_ALIGN_DOWN((__uptr) mem + size)
+				  - meta_len);
 
-	m = (struct uk_netbuf *) mem;
 	uk_netbuf_init_indir(m,
-			     mem + buf_offset,
-			     size - buf_offset,
+			     mem,
+			     (size_t) ((__uptr) m - (__uptr) mem),
 			     headroom,
-			     privlen > 0 ? (mem + priv_offset) : NULL,
+			     privlen > 0 ? (void *) ((__uptr) m+ sizeof(*m))
+					 : NULL,
 			     dtor);
 	return m;
 }
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 13:42:04 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 13:42:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.15844.39070 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUfM-00054u-CU; Fri, 30 Oct 2020 13:42:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 15844.39070; Fri, 30 Oct 2020 13:42:04 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUfM-00054n-9Q; Fri, 30 Oct 2020 13:42:04 +0000
Received: by outflank-mailman (input) for mailman id 15844;
 Fri, 30 Oct 2020 13:42: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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYUfK-00054W-CV
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:42:02 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 8f2a35cf-01c4-4ec7-b0b8-43362b356b72;
 Fri, 30 Oct 2020 13:42:01 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id BA9B21041F9;
 Fri, 30 Oct 2020 14:42:00 +0100 (CET)
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 Hcm8hOKIl7S4; Fri, 30 Oct 2020 14:42:00 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 99A8B1041EF
 for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:42:00 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:42:00 +0100
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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYUfK-00054W-CV
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:42:02 +0000
X-Inumbo-ID: 8f2a35cf-01c4-4ec7-b0b8-43362b356b72
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 8f2a35cf-01c4-4ec7-b0b8-43362b356b72;
	Fri, 30 Oct 2020 13:42:01 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id BA9B21041F9;
	Fri, 30 Oct 2020 14:42:00 +0100 (CET)
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 Hcm8hOKIl7S4; Fri, 30 Oct 2020 14:42:00 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 99A8B1041EF
	for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:42:00 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:42:00 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 3/4] lib/uknetdev: `uk_netbuf_alloc_buf()`: Introduce alignment
Date: Fri, 30 Oct 2020 14:41:32 +0100
Message-ID: <20201030134133.15307-4-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201030134133.15307-1-simon.kuenzer@neclab.eu>
References: <20201030134133.15307-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

The API function `uk_netbuf_alloc_buf()` gets an alignment parameter which
can be used to request an aligned allocation for the packet buffer area
(`m->buf`).

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/uknetdev/include/uk/netbuf.h | 4 +++-
 lib/uknetdev/netbuf.c            | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/uknetdev/include/uk/netbuf.h b/lib/uknetdev/include/uk/netbuf.h
index ea803ae8..5212614a 100644
--- a/lib/uknetdev/include/uk/netbuf.h
+++ b/lib/uknetdev/include/uk/netbuf.h
@@ -245,6 +245,8 @@ struct uk_netbuf *uk_netbuf_alloc_indir(struct uk_alloc *a,
  *   to this allocator.
  * @param buflen
  *   Size of the buffer area
+ * @param bufalign
+ *   Alignment for the buffer area (`m->buf` will be aligned to it)
  * @param headroom
  *   Number of bytes reserved as headroom from the buffer area.
  *   `headroom` has to be smaller or equal to `buflen`.
@@ -263,7 +265,7 @@ struct uk_netbuf *uk_netbuf_alloc_indir(struct uk_alloc *a,
  *   - initialized uk_netbuf
  */
 struct uk_netbuf *uk_netbuf_alloc_buf(struct uk_alloc *a, size_t buflen,
-				      uint16_t headroom,
+				      size_t bufalign, uint16_t headroom,
 				      size_t privlen, uk_netbuf_dtor_t dtor);
 
 /**
diff --git a/lib/uknetdev/netbuf.c b/lib/uknetdev/netbuf.c
index c5cf662e..d87af053 100644
--- a/lib/uknetdev/netbuf.c
+++ b/lib/uknetdev/netbuf.c
@@ -99,7 +99,7 @@ struct uk_netbuf *uk_netbuf_alloc_indir(struct uk_alloc *a,
 }
 
 struct uk_netbuf *uk_netbuf_alloc_buf(struct uk_alloc *a, size_t buflen,
-				      uint16_t headroom,
+				      size_t bufalign, uint16_t headroom,
 				      size_t privlen, uk_netbuf_dtor_t dtor)
 {
 	void *mem;
@@ -111,7 +111,7 @@ struct uk_netbuf *uk_netbuf_alloc_buf(struct uk_alloc *a, size_t buflen,
 
 	alloc_len = NETBUF_ADDR_ALIGN_UP(buflen)
 		    + NETBUF_ADDR_ALIGN_UP(sizeof(*m) + privlen);
-	mem = uk_malloc(a, alloc_len);
+	mem = uk_memalign(a, bufalign, alloc_len);
 	if (!mem)
 		return NULL;
 
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 13:42:07 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 13:42:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.15845.39075 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUfP-00055w-EJ; Fri, 30 Oct 2020 13:42:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 15845.39075; Fri, 30 Oct 2020 13:42:07 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYUfP-00055o-As; Fri, 30 Oct 2020 13:42:07 +0000
Received: by outflank-mailman (input) for mailman id 15845;
 Fri, 30 Oct 2020 13:42: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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYUfO-00055X-4g
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:42:06 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id ca3198cd-d814-4b6c-9fad-6520eb115f8d;
 Fri, 30 Oct 2020 13:42:04 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id E7159F21D0;
 Fri, 30 Oct 2020 14:42:03 +0100 (CET)
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 PzBPW64QKWDG; Fri, 30 Oct 2020 14:42:03 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id BE8F3F21CC
 for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:42:01 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:42:01 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYUfO-00055X-4g
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 13:42:06 +0000
X-Inumbo-ID: ca3198cd-d814-4b6c-9fad-6520eb115f8d
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id ca3198cd-d814-4b6c-9fad-6520eb115f8d;
	Fri, 30 Oct 2020 13:42:04 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id E7159F21D0;
	Fri, 30 Oct 2020 14:42:03 +0100 (CET)
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 PzBPW64QKWDG; Fri, 30 Oct 2020 14:42:03 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id BE8F3F21CC
	for <minios-devel@lists.xen.org>; Fri, 30 Oct 2020 14:42:01 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 14:42:01 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Simon Kuenzer
	<simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT PATCH 4/4] lib/uknetdev: Introduce ioalign
Date: Fri, 30 Oct 2020 14:41:33 +0100
Message-ID: <20201030134133.15307-5-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201030134133.15307-1-simon.kuenzer@neclab.eu>
References: <20201030134133.15307-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Similar to lib/ukblkdev, we introduce a device info parameter (`struct
uk_netdev_info`) to query alignment requirements of packet buffer areas
for a uknetdev device: `ioalign`.
At the same time the commit clarifies a confusion with the queue
information parameter `nb_align`. This parameter is intended to describe
requirements for sizing a rx/tx queue. The comment is updated and the
`virtio-net` driver is corrected. This fixes commit a52168588.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 lib/uknetdev/include/uk/netdev_core.h | 5 +++--
 plat/drivers/virtio/virtio_net.c      | 3 +--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/uknetdev/include/uk/netdev_core.h b/lib/uknetdev/include/uk/netdev_core.h
index e7fa97f2..df6ceebf 100644
--- a/lib/uknetdev/include/uk/netdev_core.h
+++ b/lib/uknetdev/include/uk/netdev_core.h
@@ -147,6 +147,7 @@ struct uk_netdev_info {
 	uint16_t max_mtu;   /**< Maximum supported MTU size. */
 	uint16_t nb_encap_tx;  /**< Number of bytes required as headroom for tx. */
 	uint16_t nb_encap_rx;  /**< Number of bytes required as headroom for rx. */
+	uint16_t ioalign;  /**< Alignment in bytes for packet data buffers */
 	uint32_t features; /**< bitmap of the features supported */
 };
 
@@ -156,8 +157,8 @@ struct uk_netdev_info {
 struct uk_netdev_queue_info {
 	uint16_t nb_max;        /**< Max allowed number of descriptors. */
 	uint16_t nb_min;        /**< Min allowed number of descriptors. */
-	uint16_t nb_align;      /**< Number should be a multiple of nb_align. */
-	int nb_is_power_of_two; /**< Number should be a power of two. */
+	uint16_t nb_align;      /**< Number of descriptors should be aligned. */
+	int nb_is_power_of_two; /**< Number of descriptors should be a power of two. */
 };
 
 /**
diff --git a/plat/drivers/virtio/virtio_net.c b/plat/drivers/virtio/virtio_net.c
index 9930859a..b5979d1e 100644
--- a/plat/drivers/virtio/virtio_net.c
+++ b/plat/drivers/virtio/virtio_net.c
@@ -770,7 +770,6 @@ static int virtio_netdev_rxq_info_get(struct uk_netdev *dev,
 	rxq = &vndev->rxqs[queue_id];
 	qinfo->nb_min = 1;
 	qinfo->nb_max = rxq->max_nb_desc;
-	qinfo->nb_align = sizeof(void *); /* word size alignment */
 	qinfo->nb_is_power_of_two = 1;
 
 exit:
@@ -798,7 +797,6 @@ static int virtio_netdev_txq_info_get(struct uk_netdev *dev,
 	txq = &vndev->txqs[queue_id];
 	qinfo->nb_min = 1;
 	qinfo->nb_max = txq->max_nb_desc;
-	qinfo->nb_align = sizeof(void *); /* word size alignment */
 	qinfo->nb_is_power_of_two = 1;
 
 exit:
@@ -1053,6 +1051,7 @@ static void virtio_net_info_get(struct uk_netdev *dev,
 	dev_info->max_mtu = vndev->max_mtu;
 	dev_info->nb_encap_tx = sizeof(struct virtio_net_hdr_padded);
 	dev_info->nb_encap_rx = sizeof(struct virtio_net_hdr_padded);
+	dev_info->ioalign = sizeof(void *); /* word size alignment */
 	dev_info->features = UK_FEATURE_RXQ_INTR_AVAILABLE;
 }
 
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 18:32:37 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 18:32:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.16162.39488 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCU-0000PK-Vl; Fri, 30 Oct 2020 18:32:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 16162.39488; Fri, 30 Oct 2020 18:32:34 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCU-0000PD-Sx; Fri, 30 Oct 2020 18:32:34 +0000
Received: by outflank-mailman (input) for mailman id 16162;
 Fri, 30 Oct 2020 18:32: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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYZCT-0000OU-4r
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:33 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id a29c98eb-58e0-482b-ad6d-67e3ee6b66b1;
 Fri, 30 Oct 2020 18:32:30 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 1F806F22E9;
 Fri, 30 Oct 2020 19:32:29 +0100 (CET)
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 bO3oymXUeLAX; Fri, 30 Oct 2020 19:32:28 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id DB53CF21EF;
 Fri, 30 Oct 2020 19:32:24 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:24 +0100
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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYZCT-0000OU-4r
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:33 +0000
X-Inumbo-ID: a29c98eb-58e0-482b-ad6d-67e3ee6b66b1
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id a29c98eb-58e0-482b-ad6d-67e3ee6b66b1;
	Fri, 30 Oct 2020 18:32:30 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 1F806F22E9;
	Fri, 30 Oct 2020 19:32:29 +0100 (CET)
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 bO3oymXUeLAX; Fri, 30 Oct 2020 19:32:28 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id DB53CF21EF;
	Fri, 30 Oct 2020 19:32:24 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:24 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Costin Lupu
	<costin.lupu@cs.pub.ro>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/LWIP PATCH v4 0/5] Xen netfront support
Date: Fri, 30 Oct 2020 19:31:45 +0100
Message-ID: <20201030183151.22543-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 titania.office.hd
 (192.168.24.89)

The current changes are required for supporting netfront devices in
Unikraft. They basically add support for aligned packet buffer
allocations as required by netfront devices.

This patch series depends on the series 1560
(https://patchwork.unikraft.org/project/unikraft/list/?series=1560)
for the Unikraft base.

Changes since v3:
 Due to drastic changes of the Unikraft base,
 this is a rewrite of this patch series at v3.
 It applies:
 - Use ioalign field from uknetdev
 - Use aligned netbuf allocation helpers from lib/uknetdev
 - Make use of uknetdev scratch pad for device local fields

Changes since v2:
 - Use nb_align field for queue infos
 - First patch of v3 was already upstreamed

Costin Lupu (1):
  lwipopts.h: Disable Ethernet frame padding

Simon Kuenzer (4):
  uknetdev: Per device `lwip_data` to callbacks
  uknetdev: Per device RX/TX headroom
  netbuf: Aligned buffers with `lwip_alloc_netbuf()`
  uknetdev: Retrieve `ioalign` from device

 Config.uk         |  2 +-
 include/arch/cc.h |  4 ++-
 netbuf.c          | 26 ++++-----------
 netbuf.h          |  2 +-
 uknetdev.c        | 83 ++++++++++++++++++++++++++---------------------
 5 files changed, 57 insertions(+), 60 deletions(-)

-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 18:32:38 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 18:32:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.16163.39492 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCY-0000Q1-17; Fri, 30 Oct 2020 18:32:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 16163.39492; Fri, 30 Oct 2020 18:32:38 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCX-0000Pu-UT; Fri, 30 Oct 2020 18:32:37 +0000
Received: by outflank-mailman (input) for mailman id 16163;
 Fri, 30 Oct 2020 18:32: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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYZCW-0000Pa-5T
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:36 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 21cf183a-9a1a-4065-891f-fec465c03e68;
 Fri, 30 Oct 2020 18:32:34 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 278CAF22E9;
 Fri, 30 Oct 2020 19:32:33 +0100 (CET)
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 nn_9kEP_e-OD; Fri, 30 Oct 2020 19:32:33 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id F28BAF21EF;
 Fri, 30 Oct 2020 19:32:28 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:25 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYZCW-0000Pa-5T
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:36 +0000
X-Inumbo-ID: 21cf183a-9a1a-4065-891f-fec465c03e68
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 21cf183a-9a1a-4065-891f-fec465c03e68;
	Fri, 30 Oct 2020 18:32:34 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 278CAF22E9;
	Fri, 30 Oct 2020 19:32:33 +0100 (CET)
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 nn_9kEP_e-OD; Fri, 30 Oct 2020 19:32:33 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id F28BAF21EF;
	Fri, 30 Oct 2020 19:32:28 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:25 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Costin Lupu
	<costin.lupu@cs.pub.ro>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/LWIP PATCH v4 1/5] uknetdev: Per device `lwip_data` to callbacks
Date: Fri, 30 Oct 2020 19:31:46 +0100
Message-ID: <20201030183151.22543-2-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
References: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

In order to hand-over per device `lwip_data` to the rx/tx packet allocation
function (`netif_alloc_rxpkts()`), we move storing the reference to the
allocator that used for packet allocations to `lwip_data`. In the future,
this can be used to enable per device buffer pools (e.g.,
with `ukallocpool`) for faster allocation and freeing requests.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 Config.uk  |  2 +-
 uknetdev.c | 32 ++++++++++++++++++++++----------
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/Config.uk b/Config.uk
index e2eacb5..32deb3a 100644
--- a/Config.uk
+++ b/Config.uk
@@ -25,7 +25,7 @@ config LWIP_UKNETDEV
 
 config LWIP_UKNETDEV_SCRATCH
 	int
-	default 32
+	default 48
 	help
 		The network stack reserves space in the uknetdev device for its
 		use. Please do not change this value and in case change this
diff --git a/uknetdev.c b/uknetdev.c
index e794c37..e645ac1 100644
--- a/uknetdev.c
+++ b/uknetdev.c
@@ -64,6 +64,7 @@
 
 struct lwip_netdev_data {
 	uint32_t features;
+	struct uk_alloc *pkt_a;
 #ifdef CONFIG_HAVE_SCHED
 	struct uk_thread *poll_thread; /* Thread per device */
 	char *_name; /* Thread name */
@@ -71,6 +72,15 @@ struct lwip_netdev_data {
 #endif /* CONFIG_HAVE_SCHED */
 };
 
+/*
+ * Compile-time assertion that ensures that the uknetdev scratch pad can fit
+ * `struct lwip_netdev_data`. In case this is not fulfilled, please adopt
+ * LWIP_UKNETDEV_SCRATCH in `Config.uk`. The purpose of using the
+ * scratch pad is performance: `struct lwip_netdev_data` is on the same
+ * allocation as `struct uknetdev`. Cache-locality can be utilized better.
+ */
+UK_CTASSERT((sizeof(struct lwip_netdev_data)) <= CONFIG_UK_NETDEV_SCRATCH_SIZE);
+
 /*
  * Global headroom settings for buffer allocations used on receive
  * and transmit. We are taking the maximum of all uknetdev devices as
@@ -89,15 +99,17 @@ static uint16_t tx_headroom = ETH_PAD_SIZE;
 static uint16_t netif_alloc_rxpkts(void *argp, struct uk_netbuf *nb[],
 				   uint16_t count)
 {
-	struct uk_alloc *a;
+	struct lwip_netdev_data *lwip_data;
 	uint16_t i;
 
 	UK_ASSERT(argp);
 
-	a = (struct uk_alloc *) argp;
+	lwip_data = (struct lwip_netdev_data *) argp;
 
 	for (i = 0; i < count; ++i) {
-		nb[i] = lwip_alloc_netbuf(a, UKNETDEV_BUFLEN, rx_headroom);
+		nb[i] = lwip_alloc_netbuf(lwip_data->pkt_a,
+					  UKNETDEV_BUFLEN,
+					  rx_headroom);
 		if (!nb[i]) {
 			/* we run out of memory */
 			break;
@@ -109,8 +121,8 @@ static uint16_t netif_alloc_rxpkts(void *argp, struct uk_netbuf *nb[],
 
 static err_t uknetdev_output(struct netif *nf, struct pbuf *p)
 {
-	struct uk_alloc *a;
 	struct uk_netdev *dev;
+	struct lwip_netdev_data *lwip_data;
 	struct pbuf *q;
 	struct uk_netbuf *nb;
 	void *allocation;
@@ -120,18 +132,17 @@ static err_t uknetdev_output(struct netif *nf, struct pbuf *p)
 	UK_ASSERT(nf);
 	dev = netif_to_uknetdev(nf);
 	UK_ASSERT(dev);
+	lwip_data = (struct lwip_netdev_data *) dev->scratch_pad;
+	UK_ASSERT(lwip_data);
 
-	a = uk_alloc_get_default();
-	if (!a)
-		return ERR_MEM;
-
-	allocation = uk_malloc(a, UKNETDEV_BUFLEN);
+	allocation = uk_malloc(lwip_data->pkt_a, UKNETDEV_BUFLEN);
 	if (!allocation)
 		return ERR_MEM;
 	nb = uk_netbuf_prepare_buf(allocation, UKNETDEV_BUFLEN,
 				   tx_headroom, 0, NULL);
 	UK_ASSERT(nb);
 	nb->_a = a; /* register allocator for free operation */
+	nb->_b = allocation;
 
 	if (unlikely(p->tot_len > uk_netbuf_tailroom(nb))) {
 		LWIP_DEBUGF(NETIF_DEBUG,
@@ -479,6 +490,7 @@ err_t uknetdev_init(struct netif *nf)
 	if (!info.max_rx_queues || !info.max_tx_queues)
 		return ERR_IF;
 	lwip_data->features = info.features;
+	lwip_data->pkt_a    = a;
 
 	/*
 	 * Update our global (rx|tx)_headroom setting that we use for
@@ -514,7 +526,7 @@ err_t uknetdev_init(struct netif *nf)
 	 */
 	rxq_conf.a = a;
 	rxq_conf.alloc_rxpkts = netif_alloc_rxpkts;
-	rxq_conf.alloc_rxpkts_argp = a;
+	rxq_conf.alloc_rxpkts_argp = lwip_data;
 #ifdef CONFIG_LWIP_NOTHREADS
 	/*
 	 * In mainloop mode, we will not use interrupts.
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 18:32:43 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 18:32:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.16164.39497 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCd-0000R3-2z; Fri, 30 Oct 2020 18:32:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 16164.39497; Fri, 30 Oct 2020 18:32:43 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCc-0000Qw-Vx; Fri, 30 Oct 2020 18:32:42 +0000
Received: by outflank-mailman (input) for mailman id 16164;
 Fri, 30 Oct 2020 18:32:41 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYZCb-0000Pa-47
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:41 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id d190ffd6-5d19-46fb-8086-6b62d88823f2;
 Fri, 30 Oct 2020 18:32:39 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 5FEDE101F0F;
 Fri, 30 Oct 2020 19:32:38 +0100 (CET)
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 uQQKxxhjfxdK; Fri, 30 Oct 2020 19:32:38 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 3B653FF9FB;
 Fri, 30 Oct 2020 19:32:38 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:37 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYZCb-0000Pa-47
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:41 +0000
X-Inumbo-ID: d190ffd6-5d19-46fb-8086-6b62d88823f2
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id d190ffd6-5d19-46fb-8086-6b62d88823f2;
	Fri, 30 Oct 2020 18:32:39 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 5FEDE101F0F;
	Fri, 30 Oct 2020 19:32:38 +0100 (CET)
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 uQQKxxhjfxdK; Fri, 30 Oct 2020 19:32:38 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 3B653FF9FB;
	Fri, 30 Oct 2020 19:32:38 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:37 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Costin Lupu
	<costin.lupu@cs.pub.ro>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/LWIP PATCH v4 2/5] lwipopts.h: Disable Ethernet frame padding
Date: Fri, 30 Oct 2020 19:31:47 +0100
Message-ID: <20201030183151.22543-3-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
References: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

From: Costin Lupu <costin.lupu@cs.pub.ro>

We set ETH_PAD_SIZE to 0 considering that padding and alignment is
handled according to each driver capabilities.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 include/arch/cc.h | 4 +++-
 uknetdev.c        | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/arch/cc.h b/include/arch/cc.h
index a1d0c34..b4526e0 100644
--- a/include/arch/cc.h
+++ b/include/arch/cc.h
@@ -51,7 +51,9 @@
 
 /* 32 bit checksum calculation */
 #define LWIP_CHKSUM_ALGORITHM 3
-#define ETH_PAD_SIZE 2
+
+/* Disable padding on Ethernet frames (only some uknetdev driver support it) */
+#define ETH_PAD_SIZE 0
 
 /* rand */
 #define LWIP_RAND() uk_swrand_randr()
diff --git a/uknetdev.c b/uknetdev.c
index e645ac1..ccb7368 100644
--- a/uknetdev.c
+++ b/uknetdev.c
@@ -259,6 +259,12 @@ static void uknetdev_input(struct uk_netdev *dev,
 
 		/* Send packet to lwip */
 #if ETH_PAD_SIZE
+		/* If the following assertion fails, the driver most likely does
+		 * not support padded receive. In such a case ETH_PAD_SIZE has
+		 * to be set to 0.
+		 */
+		UK_ASSERT(uk_netbuf_headroom(nb) >= ETH_PAD_SIZE);
+
 		uk_netbuf_header(nb, ETH_PAD_SIZE);
 #endif /* ETH_PAD_SIZE */
 		p = lwip_netbuf_to_pbuf(nb);
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 18:32:47 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 18:32:47 +0000
Received: from list by lists.xenproject.org with outflank-mailman.16165.39500 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCh-0000S6-4N; Fri, 30 Oct 2020 18:32:47 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 16165.39500; Fri, 30 Oct 2020 18:32:47 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCh-0000S2-1F; Fri, 30 Oct 2020 18:32:47 +0000
Received: by outflank-mailman (input) for mailman id 16165;
 Fri, 30 Oct 2020 18:32: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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYZCf-0000Rm-Gf
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:45 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 90088408-5989-4381-a044-9aa0e11f602d;
 Fri, 30 Oct 2020 18:32:44 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 850EDF22E9;
 Fri, 30 Oct 2020 19:32:43 +0100 (CET)
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 cjxlTdV6ot6s; Fri, 30 Oct 2020 19:32:43 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 59E3AF21EF;
 Fri, 30 Oct 2020 19:32:39 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:39 +0100
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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYZCf-0000Rm-Gf
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:45 +0000
X-Inumbo-ID: 90088408-5989-4381-a044-9aa0e11f602d
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 90088408-5989-4381-a044-9aa0e11f602d;
	Fri, 30 Oct 2020 18:32:44 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 850EDF22E9;
	Fri, 30 Oct 2020 19:32:43 +0100 (CET)
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 cjxlTdV6ot6s; Fri, 30 Oct 2020 19:32:43 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 59E3AF21EF;
	Fri, 30 Oct 2020 19:32:39 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:39 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Costin Lupu
	<costin.lupu@cs.pub.ro>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/LWIP PATCH v4 3/5] uknetdev: Per device RX/TX headroom
Date: Fri, 30 Oct 2020 19:31:48 +0100
Message-ID: <20201030183151.22543-4-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
References: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Store required rx and tx headroom on `lwip_data`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 uknetdev.c | 39 ++++++++++++++-------------------------
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/uknetdev.c b/uknetdev.c
index ccb7368..ba7d41c 100644
--- a/uknetdev.c
+++ b/uknetdev.c
@@ -65,6 +65,8 @@
 struct lwip_netdev_data {
 	uint32_t features;
 	struct uk_alloc *pkt_a;
+	uint16_t rx_headroom;
+	uint16_t tx_headroom;
 #ifdef CONFIG_HAVE_SCHED
 	struct uk_thread *poll_thread; /* Thread per device */
 	char *_name; /* Thread name */
@@ -81,18 +83,6 @@ struct lwip_netdev_data {
  */
 UK_CTASSERT((sizeof(struct lwip_netdev_data)) <= CONFIG_UK_NETDEV_SCRATCH_SIZE);
 
-/*
- * Global headroom settings for buffer allocations used on receive
- * and transmit. We are taking the maximum of all uknetdev devices as
- * simplification.
- * TODO: A per-device setting might be more efficient but requires more data
- *       fields for `netif->state`. For now we point directly to the according
- *       `struct uk_netdev` in order to avoid another allocation for these
- *       per-device fields.
- */
-static uint16_t rx_headroom = ETH_PAD_SIZE;
-static uint16_t tx_headroom = ETH_PAD_SIZE;
-
 #define netif_to_uknetdev(nf) \
 	((struct uk_netdev *) (nf)->state)
 
@@ -109,7 +99,7 @@ static uint16_t netif_alloc_rxpkts(void *argp, struct uk_netbuf *nb[],
 	for (i = 0; i < count; ++i) {
 		nb[i] = lwip_alloc_netbuf(lwip_data->pkt_a,
 					  UKNETDEV_BUFLEN,
-					  rx_headroom);
+					  lwip_data->rx_headroom);
 		if (!nb[i]) {
 			/* we run out of memory */
 			break;
@@ -139,7 +129,7 @@ static err_t uknetdev_output(struct netif *nf, struct pbuf *p)
 	if (!allocation)
 		return ERR_MEM;
 	nb = uk_netbuf_prepare_buf(allocation, UKNETDEV_BUFLEN,
-				   tx_headroom, 0, NULL);
+				   lwip_data->tx_headroom, 0, NULL);
 	UK_ASSERT(nb);
 	nb->_a = a; /* register allocator for free operation */
 	nb->_b = allocation;
@@ -495,21 +485,20 @@ err_t uknetdev_init(struct netif *nf)
 	uk_netdev_info_get(dev, &info);
 	if (!info.max_rx_queues || !info.max_tx_queues)
 		return ERR_IF;
-	lwip_data->features = info.features;
-	lwip_data->pkt_a    = a;
+	lwip_data->features    = info.features;
+#if ETH_PAD_SIZE
+	lwip_data->rx_headroom = info.nb_encap_rx + ETH_PAD_SIZE;
+	lwip_data->tx_headroom = info.nb_encap_tx + ETH_PAD_SIZE;
+#else
+	lwip_data->rx_headroom = info.nb_encap_rx;
+	lwip_data->tx_headroom = info.nb_encap_tx;
+#endif
+	lwip_data->pkt_a       = a;
 
-	/*
-	 * Update our global (rx|tx)_headroom setting that we use for
-	 * buffer allocations
-	 */
-	rx_headroom = (rx_headroom < info.nb_encap_rx)
-		      ? info.nb_encap_rx : rx_headroom;
-	tx_headroom = (tx_headroom < info.nb_encap_tx)
-		      ? info.nb_encap_tx : tx_headroom;
 	LWIP_DEBUGF(NETIF_DEBUG,
 		    ("%s: %c%c%u: Need headroom rx:%"PRIu16", tx:%"PRIu16"\n",
 		     __func__, nf->name[0], nf->name[1], nf->num,
-		     info.nb_encap_rx, info.nb_encap_tx));
+		     lwip_data->rx_headroom, lwip_data->tx_headroom));
 
 	/*
 	 * Device configuration,
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 18:32:55 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 18:32:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.16166.39505 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCp-0000Ts-65; Fri, 30 Oct 2020 18:32:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 16166.39505; Fri, 30 Oct 2020 18:32:55 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCp-0000To-2x; Fri, 30 Oct 2020 18:32:55 +0000
Received: by outflank-mailman (input) for mailman id 16166;
 Fri, 30 Oct 2020 18:32:53 +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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYZCn-0000TU-Nl
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:53 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 721e0e0d-140a-4ca7-9274-c80e62159085;
 Fri, 30 Oct 2020 18:32:52 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id BC370101F0F;
 Fri, 30 Oct 2020 19:32:51 +0100 (CET)
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 VHxEgK--81PR; Fri, 30 Oct 2020 19:32:51 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 9A2EFFF9FB;
 Fri, 30 Oct 2020 19:32:51 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:51 +0100
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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYZCn-0000TU-Nl
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:32:53 +0000
X-Inumbo-ID: 721e0e0d-140a-4ca7-9274-c80e62159085
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
	id 721e0e0d-140a-4ca7-9274-c80e62159085;
	Fri, 30 Oct 2020 18:32:52 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id BC370101F0F;
	Fri, 30 Oct 2020 19:32:51 +0100 (CET)
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 VHxEgK--81PR; Fri, 30 Oct 2020 19:32:51 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 9A2EFFF9FB;
	Fri, 30 Oct 2020 19:32:51 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:51 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Costin Lupu
	<costin.lupu@cs.pub.ro>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/LWIP PATCH v4 4/5] netbuf: Aligned buffers with `lwip_alloc_netbuf()`
Date: Fri, 30 Oct 2020 19:31:49 +0100
Message-ID: <20201030183151.22543-5-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
References: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)

Adds an alignment parameter to `lwip_alloc_netbuf()`. The netbuf
buffer area (`m->buf`) will be aligned.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 netbuf.c   | 26 ++++++--------------------
 netbuf.h   |  2 +-
 uknetdev.c |  1 +
 3 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/netbuf.c b/netbuf.c
index 4878f74..97c129c 100644
--- a/netbuf.c
+++ b/netbuf.c
@@ -50,32 +50,20 @@ static void _netbuf_free(struct pbuf *p)
 }
 
 struct uk_netbuf *lwip_alloc_netbuf(struct uk_alloc *a, size_t alloc_size,
-				    size_t headroom)
+				    size_t alloc_align, uint16_t headroom)
 {
-	void *allocation;
 	struct uk_netbuf *b;
 	struct _netbuf_pbuf *np;
 
-	allocation = uk_malloc(a, alloc_size);
-	if (unlikely(!allocation))
-		goto err_out;
-
-	b = uk_netbuf_prepare_buf(allocation, alloc_size,
-				  headroom, sizeof(struct _netbuf_pbuf), NULL);
+	b = uk_netbuf_alloc_buf(a, alloc_size, alloc_align,
+				headroom, sizeof(struct _netbuf_pbuf), NULL);
 	if (unlikely(!b)) {
 		LWIP_DEBUGF(PBUF_DEBUG,
-			    ("Failed to initialize netbuf with encapsulated pbuf: requested headroom: %"__PRIsz", alloc_size: %"__PRIsz"\n",
-			     headroom, alloc_size));
-		goto err_free_allocation;
+			    ("Failed to allocate netbuf with encapsulated pbuf: requested headroom: %"__PRIu16", size: %"__PRIsz", alignement: %"__PRIsz"\n",
+			     headroom, alloc_size, alloc_align));
+		goto err_out;
 	}
 
-	/*
-	 * Register allocator so that uk_netbuf_free() will
-	 * return our memory back to this allocator when free'ing
-	 * this netbuf
-	 */
-	b->_a = a;
-
 	/* Fill-out meta data */
 	np = (struct _netbuf_pbuf *) uk_netbuf_get_priv(b);
 	memset(np, 0, sizeof(struct _netbuf_pbuf));
@@ -97,8 +85,6 @@ struct uk_netbuf *lwip_alloc_netbuf(struct uk_alloc *a, size_t alloc_size,
 		     b, b->buflen, uk_netbuf_headroom(b)));
 	return b;
 
-err_free_allocation:
-	uk_free(a, allocation);
 err_out:
 	return NULL;
 }
diff --git a/netbuf.h b/netbuf.h
index 1492065..db5adf7 100644
--- a/netbuf.h
+++ b/netbuf.h
@@ -61,7 +61,7 @@ struct _netbuf_pbuf {
  * before handing over the embedded pbuf to the network stack.
  */
 struct uk_netbuf *lwip_alloc_netbuf(struct uk_alloc *a, size_t alloc_size,
-				    size_t headroom);
+				    size_t alloc_align, uint16_t headroom);
 
 /**
  * Returns the reference of the embedded pbuf of a netbuf
diff --git a/uknetdev.c b/uknetdev.c
index ba7d41c..7b689f9 100644
--- a/uknetdev.c
+++ b/uknetdev.c
@@ -99,6 +99,7 @@ static uint16_t netif_alloc_rxpkts(void *argp, struct uk_netbuf *nb[],
 	for (i = 0; i < count; ++i) {
 		nb[i] = lwip_alloc_netbuf(lwip_data->pkt_a,
 					  UKNETDEV_BUFLEN,
+					  1,
 					  lwip_data->rx_headroom);
 		if (!nb[i]) {
 			/* we run out of memory */
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 18:33:04 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 18:33:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.16168.39510 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCy-0000X7-9h; Fri, 30 Oct 2020 18:33:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 16168.39510; Fri, 30 Oct 2020 18:33:04 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZCy-0000X0-53; Fri, 30 Oct 2020 18:33:04 +0000
Received: by outflank-mailman (input) for mailman id 16168;
 Fri, 30 Oct 2020 18:33: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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYZCw-0000Wm-4d
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:33:02 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id da9d710c-7db5-46a6-9d89-8514c0b8378f;
 Fri, 30 Oct 2020 18:32:57 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 1687CF22E9;
 Fri, 30 Oct 2020 19:32:57 +0100 (CET)
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 Vn1A0SutF7Qm; Fri, 30 Oct 2020 19:32:56 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id E02B3F21EF;
 Fri, 30 Oct 2020 19:32:52 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:52 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYZCw-0000Wm-4d
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 18:33:02 +0000
X-Inumbo-ID: da9d710c-7db5-46a6-9d89-8514c0b8378f
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id da9d710c-7db5-46a6-9d89-8514c0b8378f;
	Fri, 30 Oct 2020 18:32:57 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 1687CF22E9;
	Fri, 30 Oct 2020 19:32:57 +0100 (CET)
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 Vn1A0SutF7Qm; Fri, 30 Oct 2020 19:32:56 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id E02B3F21EF;
	Fri, 30 Oct 2020 19:32:52 +0100 (CET)
Received: from localhost (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 19:32:52 +0100
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
To: <minios-devel@lists.xen.org>
CC: Sharan Santhanam <sharan.santhanam@neclab.eu>, Costin Lupu
	<costin.lupu@cs.pub.ro>, Simon Kuenzer <simon.kuenzer@neclab.eu>
Subject: [UNIKRAFT/LWIP PATCH v4 5/5] uknetdev: Retrieve `ioalign` from device
Date: Fri, 30 Oct 2020 19:31:50 +0100
Message-ID: <20201030183151.22543-6-simon.kuenzer@neclab.eu>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
References: <20201030183151.22543-1-simon.kuenzer@neclab.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Retrieve `ioalign` from uknetdev device and apply it to packet buffer
allocations.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
---
 uknetdev.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/uknetdev.c b/uknetdev.c
index 7b689f9..50c6460 100644
--- a/uknetdev.c
+++ b/uknetdev.c
@@ -67,6 +67,7 @@ struct lwip_netdev_data {
 	struct uk_alloc *pkt_a;
 	uint16_t rx_headroom;
 	uint16_t tx_headroom;
+	uint16_t ioalign; /* required alignment for RX/TX buffers */
 #ifdef CONFIG_HAVE_SCHED
 	struct uk_thread *poll_thread; /* Thread per device */
 	char *_name; /* Thread name */
@@ -99,7 +100,7 @@ static uint16_t netif_alloc_rxpkts(void *argp, struct uk_netbuf *nb[],
 	for (i = 0; i < count; ++i) {
 		nb[i] = lwip_alloc_netbuf(lwip_data->pkt_a,
 					  UKNETDEV_BUFLEN,
-					  1,
+					  lwip_data->ioalign,
 					  lwip_data->rx_headroom);
 		if (!nb[i]) {
 			/* we run out of memory */
@@ -116,7 +117,6 @@ static err_t uknetdev_output(struct netif *nf, struct pbuf *p)
 	struct lwip_netdev_data *lwip_data;
 	struct pbuf *q;
 	struct uk_netbuf *nb;
-	void *allocation;
 	char *wpos;
 	int ret;
 
@@ -126,14 +126,13 @@ static err_t uknetdev_output(struct netif *nf, struct pbuf *p)
 	lwip_data = (struct lwip_netdev_data *) dev->scratch_pad;
 	UK_ASSERT(lwip_data);
 
-	allocation = uk_malloc(lwip_data->pkt_a, UKNETDEV_BUFLEN);
-	if (!allocation)
+	nb = uk_netbuf_alloc_buf(lwip_data->pkt_a,
+				 UKNETDEV_BUFLEN,
+				 lwip_data->ioalign,
+				 lwip_data->tx_headroom,
+				 0, NULL);
+	if (!nb)
 		return ERR_MEM;
-	nb = uk_netbuf_prepare_buf(allocation, UKNETDEV_BUFLEN,
-				   lwip_data->tx_headroom, 0, NULL);
-	UK_ASSERT(nb);
-	nb->_a = a; /* register allocator for free operation */
-	nb->_b = allocation;
 
 	if (unlikely(p->tot_len > uk_netbuf_tailroom(nb))) {
 		LWIP_DEBUGF(NETIF_DEBUG,
@@ -494,12 +493,14 @@ err_t uknetdev_init(struct netif *nf)
 	lwip_data->rx_headroom = info.nb_encap_rx;
 	lwip_data->tx_headroom = info.nb_encap_tx;
 #endif
+	lwip_data->ioalign     = info.ioalign;
 	lwip_data->pkt_a       = a;
 
 	LWIP_DEBUGF(NETIF_DEBUG,
-		    ("%s: %c%c%u: Need headroom rx:%"PRIu16", tx:%"PRIu16"\n",
+		    ("%s: %c%c%u: Headroom rx:%"PRIu16", tx:%"PRIu16"; I/O align: 0x%"PRIx16"\n",
 		     __func__, nf->name[0], nf->name[1], nf->num,
-		     lwip_data->rx_headroom, lwip_data->tx_headroom));
+		     lwip_data->rx_headroom, lwip_data->tx_headroom,
+		     lwip_data->ioalign));
 
 	/*
 	 * Device configuration,
-- 
2.20.1


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 19:11:27 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 19:11:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.16203.39565 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZo6-0004Jc-2e; Fri, 30 Oct 2020 19:11:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 16203.39565; Fri, 30 Oct 2020 19:11:26 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYZo5-0004JV-Vb; Fri, 30 Oct 2020 19:11:25 +0000
Received: by outflank-mailman (input) for mailman id 16203;
 Fri, 30 Oct 2020 19:11: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=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYZo4-0004JQ-VH
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 19:11:25 +0000
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id dba7849b-f08d-40b0-8f8a-b12f513d1413;
 Fri, 30 Oct 2020 19:11:22 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer2.neclab.eu (Postfix) with ESMTP id 8AAF7F21C7;
 Fri, 30 Oct 2020 20:11:21 +0100 (CET)
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 o3sHqt4pp4uq; Fri, 30 Oct 2020 20:11:21 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer2.neclab.eu (Postfix) with ESMTPS id 4BCE6F21C0;
 Fri, 30 Oct 2020 20:11:17 +0100 (CET)
Received: from [10.7.2.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 20:11:16 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYZo4-0004JQ-VH
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 19:11:25 +0000
X-Inumbo-ID: dba7849b-f08d-40b0-8f8a-b12f513d1413
Received: from mailer2.neclab.eu (unknown [195.37.70.41])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id dba7849b-f08d-40b0-8f8a-b12f513d1413;
	Fri, 30 Oct 2020 19:11:22 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer2.neclab.eu (Postfix) with ESMTP id 8AAF7F21C7;
	Fri, 30 Oct 2020 20:11:21 +0100 (CET)
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 o3sHqt4pp4uq; Fri, 30 Oct 2020 20:11:21 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer2.neclab.eu (Postfix) with ESMTPS id 4BCE6F21C0;
	Fri, 30 Oct 2020 20:11:17 +0100 (CET)
Received: from [10.7.2.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 20:11:16 +0100
Subject: Re: [UNIKRAFT PATCH v4 10/12] plat/xen/drivers/net: Add transmit
 operation
To: Costin Lupu <costin.lupu@cs.pub.ro>, Sharan Santhanam
	<sharan.santhanam@neclab.eu>, <minios-devel@lists.xen.org>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-11-costin.lupu@cs.pub.ro>
 <494d8796-a3e0-a3d5-df36-6343df10d571@neclab.eu>
 <c71f09f9-79b7-816f-bced-a190ed6665fc@cs.pub.ro>
 <726dd84d-33cb-877f-3e22-a5d92870ac35@neclab.eu>
 <06f26c34-1a23-6fae-d5ba-46b4b49dfc13@cs.pub.ro>
 <a106f115-336c-d97c-f441-f130633c4c53@neclab.eu>
 <86653183-2b07-4d26-83fc-53dcd265f31a@neclab.eu>
 <1b789288-6f5c-2af2-8723-9e04787fc305@cs.pub.ro>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <f80f5529-6fbf-2d78-150e-397bbf0d5a47@neclab.eu>
Date: Fri, 30 Oct 2020 20:11:16 +0100
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0)
 Gecko/20100101 Thunderbird/68.12.1
MIME-Version: 1.0
In-Reply-To: <1b789288-6f5c-2af2-8723-9e04787fc305@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: titania.office.hd (192.168.24.89) To titania.office.hd
 (192.168.24.89)

Hi Costin,

since I worked on the lwip adoption, I found something in your tx 
function. Please see it inline.

Thanks,

Simon

On 23.10.20 17:54, Costin Lupu wrote:
> Hi Sharan,
> 
> Please see inline.
> 
> On 10/22/20 4:38 PM, Sharan Santhanam wrote:
>> Hello Costin,
>>
>> Please find the review comments inline:
>>
>> Thanks & Regards
>>
>> Sharan
>>
>> On 8/21/20 3:04 PM, Simon Kuenzer wrote:
>>> On 21.08.20 13:24, Costin Lupu wrote:
>>>> On 8/21/20 1:49 PM, Simon Kuenzer wrote:
>>>>> On 21.08.20 11:32, Costin Lupu wrote:
>>>>>> On 8/20/20 6:49 PM, Simon Kuenzer wrote:
>>>>>>> On 13.08.20 10:53, Costin Lupu wrote:
>>>>>>>> Whenever a packet is transmitted, the request describing it is
>>>>>>>> written
>>>>>>>> in the
>>>>>>>> shared ring. The packet itself is written in a page referenced by
>>>>>>>> the
>>>>>>>> request
>>>>>>>> and shared, as well, with the backend. At the end of each transmit
>>>>>>>> operation, a
>>>>>>>> cleanup operation is performed free'ing the resources allocated
>>>>>>>> for the
>>>>>>>> previously transmitted packets.
>>>>>>>>
>>>>>>>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>>>>>>>> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
>>>>>>>> ---
>>>>>>>>      plat/xen/drivers/net/netfront.c | 102
>>>>>>>> ++++++++++++++++++++++++++++++++
>>>>>>>>      1 file changed, 102 insertions(+)
>>>>>>>>
>>>>>>>> diff --git a/plat/xen/drivers/net/netfront.c
>>>>>>>> b/plat/xen/drivers/net/netfront.c
>>>>>>>> index 858d124a..f2b81329 100644
>>>>>>>> --- a/plat/xen/drivers/net/netfront.c
>>>>>>>> +++ b/plat/xen/drivers/net/netfront.c
>>>>>>>> @@ -39,6 +39,7 @@
>>>>>>>>      #include <uk/alloc.h>
>>>>>>>>      #include <uk/netdev_driver.h>
>>>>>>>>      #include <xen-x86/mm.h>
>>>>>>>> +#include <xen-x86/irq.h>
>>>>>>>>      #include <xenbus/xenbus.h>
>>>>>>>>      #include "netfront.h"
>>>>>>>>      #include "netfront_xb.h"
>>>>>>>> @@ -78,6 +79,106 @@ static uint16_t get_id_from_freelist(uint16_t
>>>>>>>> *freelist)
>>>>>>>>          return id;
>>>>>>>>      }
>>>>>>>>      +static int network_tx_buf_gc(struct uk_netdev_tx_queue *txq)
>>>>>>>> +{
>>>>>>>> +    RING_IDX prod, cons;
>>>>>>>> +    netif_tx_response_t *tx_rsp;
>>>>>>>> +    uint16_t id;
>>>>>>>> +    bool more_to_do;
>>>>>>>> +    int count = 0;
>>>>>>>> +
>>>>>>>> +    do {
>>>>>>>> +        prod = txq->ring.sring->rsp_prod;
>>>>>>>> +        rmb(); /* Ensure we see responses up to 'rp'. */
>>>>>>>> +
>>>>>>>> +        for (cons = txq->ring.rsp_cons; cons != prod; cons++) {
>>>>>>>> +            tx_rsp = RING_GET_RESPONSE(&txq->ring, cons);
>>>>>>>> +
>>>>>>>> +            if (tx_rsp->status == NETIF_RSP_NULL)
>>>>>>>> +                continue;
>>>>>>>> +
>>>>>>>> +            if (tx_rsp->status == NETIF_RSP_ERROR)
>>>>>>>> +                uk_pr_err("packet error\n");
>>>>>>>
>>>>>>> "netdev%u: Transmission error on txq %u\n" ?
>>>>>>>
>>>>>>
>>>>>> Ack.
>>>>>>
>>>>>>>> +
>>>>>>>> +            id  = tx_rsp->id;
>>>>>>>> +            UK_ASSERT(id < NET_TX_RING_SIZE);
>>>>>>>> +
>>>>>>>> +            gnttab_end_access(txq->gref[id]);
>>>>>>>> +            txq->gref[id] = GRANT_INVALID_REF;
>>>>>>>> +
>>>>>>>> +            add_id_to_freelist(id, txq->freelist);
>>>>>>>> +            uk_semaphore_up(&txq->sem);
>> Shouldn't we free up the netbuf we receive from the ring?
> 
> Yeah, I wasn't aware of that either. In minios the tx buffers are reused
> and therefore never freed.
> 
> For the next version I follow the approach in virtio net driver and keep
> a reference to the netbuf in order to free it here.
> 
>>>>>>>> +
>>>>>>>> +            count++;
>>>>>>>> +        }
>>>>>>>> +
>>>>>>>> +        txq->ring.rsp_cons = prod;
>>>>>>>> +
>>>>>>>> + RING_FINAL_CHECK_FOR_RESPONSES(&txq->ring, more_to_do);
>>>>>>>> +    } while (more_to_do);
>>>>>>>> +
>>>>>>>> +    return count;
>>>>>>>> +}
>>>>>>>> +
>>>>>>>> +static int netfront_xmit(struct uk_netdev *n,
>>>>>>>> +        struct uk_netdev_tx_queue *txq,
>>>>>>>> +        struct uk_netbuf *pkt)
>>>>>>>> +{
>>>>>>>> +    struct netfront_dev *nfdev;
>>>>>>>> +    unsigned long flags;
>>>>>>>> +    uint16_t id;
>>>>>>>> +    RING_IDX req_prod;
>>>>>>>> +    netif_tx_request_t *tx_req;
>>>>>>>> +    int notify;
>>>>>>>> +    int status = 0, count;
>>>>>>>> +
>>>>>>>> +    UK_ASSERT(n != NULL);
>>>>>>>> +    UK_ASSERT(txq != NULL);
>>>>>>>> +    UK_ASSERT(pkt != NULL);
>>>>>>>> +    UK_ASSERT(pkt->len < PAGE_SIZE);
>>>>>>>> +
>>>>>>>> +    nfdev = to_netfront_dev(n);
>>>>>>>> +
>>>>>>>> +    /* get request id */
>>>>>>>> +    uk_semaphore_down(&txq->sem);
>>>>>>>> +    local_irq_save(flags);
>>>>>>>> +    id = get_id_from_freelist(txq->freelist);
>>>>>>>
>>>>>>> What happens when we are out of space and the ring is full?
>>>>>>> The xmit function should be non-blocking so that we can use it in
>>>>>>> polling mode. We should return in such a case that the transmission
>>>>>>> queue is currently full...
>>>>>>>
>>>>>>
>>>>>> Ack.
>>>>>>
>>>>>>>> +    local_irq_restore(flags);
>>>>>>>> +
>>>>>>>> +    /* get request */
>>>>>>>> +    req_prod = txq->ring.req_prod_pvt;
>>>>>>>> +    tx_req = RING_GET_REQUEST(&txq->ring, req_prod); > +
>>>>>>>> +    /* setup grant for buffer data */
>>>>>>>> +    txq->gref[id] = tx_req->gref =
>>>>>>>> + gnttab_grant_access(nfdev->xendev->otherend_id,
>>>>>>>> +            virt_to_mfn(pkt->data), 1);
>>>>>>>> +    UK_ASSERT(tx_req->gref != GRANT_INVALID_REF);
>>>>>>>> +
>>>>>>>> +    tx_req->offset = 0;

I found that if you set the offset to the following, the driver does 
support sending of packets that are having a headroom.

tx_req->offset = (uint16_t) uk_netbuf_headroom(pkt);

At the function entrance I would also check that this is the only 
segment and that the pkt buffer is page aligned:

UK_ASSERT(!pkt->next);
UK_ASSERT(((unsigned long) pkt->buf & ~PAGE_MASK) == 0);

Instead of building the grant with the data pointer, you could use the 
buf address instead. This one should be page aligned and the offset with 
headroom to it would be correctly point to data.
Please also, double-check with series 1560:
https://patchwork.unikraft.org/project/unikraft/list/?series=1560

With this you have your assumptions for a zero-copy tx confirmed.

>>>>>>>> +    tx_req->size = (uint16_t) pkt->len;
>>>>>>>> +    tx_req->flags = 0;
>>>>>>>> +    tx_req->id = id;
>>>>>>>> +
>>>>>>>> +    txq->ring.req_prod_pvt = req_prod + 1;
>>>>>>>> +    wmb(); /* Ensure backend sees requests */
>>>>>>>> +
>>>>>>>> + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&txq->ring, notify);
>>>>>>>> +    if (notify)
>>>>>>>> +        notify_remote_via_evtchn(txq->evtchn); > +
>>>>>>>> +    status |= UK_NETDEV_STATUS_SUCCESS;
>>>>>>>> +
>>>>>>>> +    /* some cleanup */
>>>>>>>> +    local_irq_save(flags);
>>>>>>>> +    count = network_tx_buf_gc(txq);
>>>>>>>
>>>>>>> The clean-up should happen before enqueuing the given packet to the
>>>>>>> transmit queue, it is the first thing of xmit(). Since we anyway
>>>>>>> need to
>>>>>>> do it and we do not have an advantage by delaying this operation.
>>>>>>
>>>>>> Of course there is an advantage. You push the packets in order for
>>>>>> them
>>>>>> to be processed ASAP by the backend and deal with cleaning up
>>>>>> afterwards. It's a kind of parallelization. Otherwise you would delay
>>>>>> the transmissions.
>>>>>>
>>>>>>> We can also deal much better with full rings. Otherwise we
>>>>>>> unnecessarily drop a packets for transmission although there would
>>>>>>> have been space when clean-up finished. After calling cleaning you
>>>>>>> can check if there is space on the ring and return if we run out of
>>>>>>> it (use an `unlikely` to the condition so that we speed up the
>>>>>>> successful sending case).
>>>>>>>
>>>>>>
>>>>>> The only scenario when this would solve anything would be when you
>>>>>> have
>>>>>> the ring full and just before you decide to send a new packet the
>>>>>> backend starts processing your previous transmitted packets,
>>>>>> leaving you
>>>>>> at least one free slot. There are 2 unlikely events here: first, the
>>>>>> ring is full, and second, the backend starts to process again when the
>>>>>> ring gets full (for the latter event, it's unlikely that the backend
>>>>>> will wake up given that it couldn't process 256 transmitted packets,
>>>>>> where 256 is the current number of slots). And for this very unlikely
>>>>>> context you would introduce a delay for all the transmissions if we
>>>>>> followed your suggestion.
>>>>>>
>>>>>> Anyway, both Linux and FreeBSD do the cleanup after pushing the
>>>>>> requests, so I don't think we have much more to say about this.
>>>>>>
>>>>>
>>>>> Hum... I double-checked with Intel DPDK's ixgbe (10 Gig) driver:
>>>>>
>>>>> http://git.dpdk.org/dpdk-stable/tree/drivers/net/ixgbe/ixgbe_rxtx.c?h=20.02#n230
>>>>>
>>>>>
>>>>>
>>>>> They clean the slots before sending. I derived my conclusion from
>>>>> there.
>>>>> However I noticed now that there is one minor difference: They do
>>>>> both -
>>>>> cleanup and enqueuing - before they notify the card about changes on
>>>>> the
>>>>> ring. In that case it does not add any delay if you swap the order of
>>>>> cleanup and enqueuing. In your case this is probably different because
>>>>> you can cleanup without notifying. Here, I agree with you that we add
>>>>> unnecessary xmit delays by swapping the order.
>>>>>
>>>>
>>>> ixgbe is a native driver, so there is no backend driver in that case.
>>>> It's a different scenario.
>>>
>>> You could consider the card itself as a backend driver, but fine.
>>> There is a ABI difference between ixgbe and netback.
>>>
>>>>
>>>>> However and in general, having a full ring is not an uncommon and
>>>>> unlikely case. To my experience, this can already happen with a single
>>>>> TCP connection if your network stack is feeding next packets fast
>>>>> enough
>>>>> and if the current TCP window allows to send them. It also depends on
>>>>> when the driver domain is scheduled; on which CPU core your netfront
>>>>> domain and the driver domain sit; and even on the underlying physical
>>>>> device that might be busy with other traffic.
>>>>>
>>>>
>>>> What I tried to say with the events probabilities explanation is that
>>>> you add delay for the common case in order to remove delay for the much
>>>> less probable corner case.
>>>
>>> I got that and agreed.
>>>
>>>>
>>>>> Another thing we are having in mind for uknetdev - and this is probably
>>>>> different to Linux/BSD's implementation - we plan to change the xmit
>>>>> function to do batching (as DPDK does). Sharan could push virtio-net
>>>>> performance further with this. You are able to reduce the number of
>>>>> notifies to the backend because you enqueue multiple packets at once
>>>>> and
>>>>> due to locality of batching you can utilize CPU caches ways better.
>>>>>
>>>>> What about this idea for netfront: We could do first a check for
>>>>> available space and - if needed - clean-up just as many extra slots
>>>>> that
>>>>> you need to complete the transmission (for now this is anyways just one
>>>>> slot). Then we proceed with enqueuing and do the cleanup of the rest of
>>>>> the slots after we notified the backend. What do you think?
>>>>>
>>>>
>>>> This will stay just as it is for the current patches. Feel free to
>>>> change anything after upstreaming these patches.
>>>
>>> No, it won't stay like this. At least, you have to call clean-up when
>>> the ring is full before you leave the non-blocking function. Otherwise
>>> you end up in never getting space back on a full ring, but I think
>>> this is clear.
>>>
>>>>
>>>>>>
>>>>>> Btw, I'm waiting for reviews on the other patches as well before I
>>>>>> send
>>>>>> the v5.
>>>>>
>>>>> Yes, sure.
>>>>>
>>>>>>
>>>>>>
>>>>>>>> +    local_irq_restore(flags);
>>>>>>>> +
>>>>>>>> +    status |= likely(count > 0) ? UK_NETDEV_STATUS_MORE : 0x0;
>>>>>>>> +
>>>>>>>> +    return status;
>>>>>>>> +}
>>>>>>>> +
>>>>>>>>      static int netfront_rxq_enqueue(struct uk_netdev_rx_queue *rxq,
>>>>>>>>              struct uk_netbuf *netbuf)
>>>>>>>>      {
>>>>>>>> @@ -598,6 +699,7 @@ static int netfront_add_dev(struct xenbus_device
>>>>>>>> *xendev)
>>>>>>>>          }
>>>>>>>>            /* register netdev */
>>>>>>>> +    nfdev->netdev.tx_one = netfront_xmit;
>>>>>>>>          nfdev->netdev.ops = &netfront_ops;
>>>>>>>>          rc = uk_netdev_drv_register(&nfdev->netdev, drv_allocator,
>>>>>>>> DRIVER_NAME);
>>>>>>>>          if (rc < 0) {
>>>>>>>>
>>>>>>>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Simon
>>>>>
>>
> 


From minios-devel-bounces@lists.xenproject.org Fri Oct 30 19:32:25 2020
Return-path: <minios-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 30 Oct 2020 19:32:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.16212.39588 (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYa8O-00069c-47; Fri, 30 Oct 2020 19:32:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 16212.39588; Fri, 30 Oct 2020 19:32:24 +0000
X-BeenThere: minios-devel@lists.xenproject.org
List-Id: Mini-os development list <minios-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:minios-devel@lists.xenproject.org>
List-Help: <mailto:minios-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/minios-devel>, 
 <mailto:minios-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: minios-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "Minios-devel" <minios-devel-bounces@lists.xenproject.org>
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <minios-devel-bounces@lists.xenproject.org>)
	id 1kYa8O-00069V-1J; Fri, 30 Oct 2020 19:32:24 +0000
Received: by outflank-mailman (input) for mailman id 16212;
 Fri, 30 Oct 2020 19:32:22 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
 id 1kYa8M-00069Q-TY
 for minios-devel@lists.xen.org; Fri, 30 Oct 2020 19:32:22 +0000
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 6549b109-5f4d-416a-8aa5-215da10a0db0;
 Fri, 30 Oct 2020 19:32:20 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by mailer1.neclab.eu (Postfix) with ESMTP id 92C34103AFA;
 Fri, 30 Oct 2020 20:32:19 +0100 (CET)
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 Wl9pR3stxwjb; Fri, 30 Oct 2020 20:32:19 +0100 (CET)
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (No client certificate requested)
 by mailer1.neclab.eu (Postfix) with ESMTPS id 5C7FE101F0F;
 Fri, 30 Oct 2020 20:32:19 +0100 (CET)
Received: from [10.7.2.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 20:32:18 +0100
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <SRS0=z5EY=EF=neclab.eu=simon.kuenzer@srs-us1.protection.inumbo.net>)
	id 1kYa8M-00069Q-TY
	for minios-devel@lists.xen.org; Fri, 30 Oct 2020 19:32:22 +0000
X-Inumbo-ID: 6549b109-5f4d-416a-8aa5-215da10a0db0
Received: from mailer1.neclab.eu (unknown [195.37.70.40])
	by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
	id 6549b109-5f4d-416a-8aa5-215da10a0db0;
	Fri, 30 Oct 2020 19:32:20 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by mailer1.neclab.eu (Postfix) with ESMTP id 92C34103AFA;
	Fri, 30 Oct 2020 20:32:19 +0100 (CET)
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 Wl9pR3stxwjb; Fri, 30 Oct 2020 20:32:19 +0100 (CET)
X-ENC: Last-Hop-TLS-encrypted
X-ENC: Last-Hop-TLS-encrypted
Received: from titania.office.hd (titania.office.hd [192.168.24.89])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by mailer1.neclab.eu (Postfix) with ESMTPS id 5C7FE101F0F;
	Fri, 30 Oct 2020 20:32:19 +0100 (CET)
Received: from [10.7.2.9] (192.168.24.96) by titania.office.hd (192.168.24.89)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 30 Oct
 2020 20:32:18 +0100
Subject: Re: [UNIKRAFT PATCH v4 06/12] plat/xen/drivers/net: Configure
 netfront tx queue
To: Costin Lupu <costin.lupu@cs.pub.ro>, Sharan Santhanam
	<sharan.santhanam@neclab.eu>, <minios-devel@lists.xen.org>
References: <20200813085342.29799-1-costin.lupu@cs.pub.ro>
 <20200813085342.29799-7-costin.lupu@cs.pub.ro>
 <0f8e24f0-0827-e1c7-6891-6e83193864ec@neclab.eu>
 <22a39f52-f2af-c77e-8672-4895002737d2@cs.pub.ro>
From: Simon Kuenzer <simon.kuenzer@neclab.eu>
Message-ID: <ed36f47d-bfe8-53d8-0945-54fd886b6fa0@neclab.eu>
Date: Fri, 30 Oct 2020 20:31:58 +0100
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0)
 Gecko/20100101 Thunderbird/68.12.1
MIME-Version: 1.0
In-Reply-To: <22a39f52-f2af-c77e-8672-4895002737d2@cs.pub.ro>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Originating-IP: [192.168.24.96]
X-ClientProxiedBy: oberon.office.hd (192.168.24.90) To titania.office.hd
 (192.168.24.89)



On 23.10.20 17:18, Costin Lupu wrote:
> Hi Sharan,
> 
> Please see inline.
> 
> On 10/22/20 2:53 PM, Sharan Santhanam wrote:
>> Hello Costin,
>>
>> Please find the comments inline:
>>
>> Thanks & Regards
>>
>> Sharan
>>
>> On 8/13/20 10:53 AM, Costin Lupu wrote:
>>> For each queue, either rx or tx, the packets references are kept in a Xen
>>> shared ring. This patch introduces the initialization of tx shared
>>> ring. Each
>>> time the driver will send a packet it will add a request on the tx
>>> shared ring
>>> which will be serviced by the backend. Therefore we need to keep track
>>> of the
>>> requests by keeping track of their IDs. Because our resources are
>>> limited, we
>>> will maintain a pool of IDs (see `freelist` array) for this purpose.
>>>
>>> Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
>>> Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
>>> ---
>>>    plat/xen/drivers/net/netfront.c | 108 ++++++++++++++++++++++++++++++++
>>>    plat/xen/drivers/net/netfront.h |  30 +++++++++
>>>    2 files changed, 138 insertions(+)
>>>
>>> diff --git a/plat/xen/drivers/net/netfront.c
>>> b/plat/xen/drivers/net/netfront.c
>>> index ddbb4b70..3c936743 100644
>>> --- a/plat/xen/drivers/net/netfront.c
>>> +++ b/plat/xen/drivers/net/netfront.c
>>> @@ -33,10 +33,12 @@
>>>     * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
>>>     */
>>>    +#include <string.h>
>>>    #include <uk/assert.h>
>>>    #include <uk/print.h>
>>>    #include <uk/alloc.h>
>>>    #include <uk/netdev_driver.h>
>>> +#include <xen-x86/mm.h>
>>>    #include <xenbus/xenbus.h>
>>>    #include "netfront.h"
>>>    #include "netfront_xb.h"
>>> @@ -49,6 +51,83 @@
>>>      static struct uk_alloc *drv_allocator;
>>>    +
>>> +static void add_id_to_freelist(uint16_t id, uint16_t *freelist)
>>> +{
>>> +    freelist[id + 1] = freelist[0];
>>> +    freelist[0]  = id;
>>> +}
>>> +
>>> +static uint16_t get_id_from_freelist(uint16_t *freelist)
>>> +{
>>> +    uint16_t id;
>>> +
>>> +    id = freelist[0];
>>> +    freelist[0] = freelist[id + 1];
>>> +    return id;
>>> +}
>>> +
>>> +static struct uk_netdev_tx_queue *netfront_txq_setup(struct uk_netdev
>>> *n,
>>> +        uint16_t queue_id,
>>> +        uint16_t nb_desc __unused,
>>> +        struct uk_netdev_txqueue_conf *conf __unused)
>>> +{
>>> +    int rc;
>>> +    struct netfront_dev *nfdev;
>>> +    struct uk_netdev_tx_queue *txq;
>>> +    netif_tx_sring_t *sring;
>>> +
>>> +    UK_ASSERT(n != NULL);
>>> +
>>> +    nfdev = to_netfront_dev(n);
>>> +    if (queue_id >= nfdev->max_queue_pairs) {
>>> +        uk_pr_err("Invalid queue identifier: %"__PRIu16"\n", queue_id);
>>> +        return ERR2PTR(-EINVAL);
>>> +    }
>>> +
>>> +    txq  = &nfdev->txqs[queue_id];
>>> +    UK_ASSERT(!txq->initialized);
>>> +    txq->netfront_dev = nfdev;
>>> +    txq->lqueue_id = queue_id;
>>> +
>>> +    /* Setup shared ring */
>>> +    sring = uk_palloc(drv_allocator, 1);
>>
>> Shouldn't the allocator from the txqueue_conf be used here while
>>
>> setting up the ring
>>
> 
> I see, I wasn't aware of that.
> 
>>> +    if (!sring)
>>> +        return ERR2PTR(-ENOMEM);
>>> +    memset(sring, 0, PAGE_SIZE);
>>> +    SHARED_RING_INIT(sring);
>>> +    FRONT_RING_INIT(&txq->ring, sring, PAGE_SIZE);
>>> +    txq->ring_size = NET_TX_RING_SIZE;
>>> +    txq->ring_ref = gnttab_grant_access(nfdev->xendev->otherend_id,
>>> +        virt_to_mfn(sring), 0);
>>> +    UK_ASSERT(txq->ring_ref != GRANT_INVALID_REF);
>>> +
>>> +    /* Setup event channel */
>>> +    rc = evtchn_alloc_unbound(nfdev->xendev->otherend_id,
>>> +            NULL, NULL,
>>> +            &txq->evtchn);
>>> +    if (rc) {
>>> +        uk_pr_err("Error creating event channel: %d\n", rc);
>>> +        gnttab_end_access(txq->ring_ref);
>>> +        uk_pfree(drv_allocator, sring, 1);
>>> +        return ERR2PTR(-rc);
>>> +    }
>>> +    /* Events are always disabled for tx queue */
>>> +    mask_evtchn(txq->evtchn);
>>> +
>>> +    /* Initialize list of request ids */
>>> +    uk_semaphore_init(&txq->sem, NET_TX_RING_SIZE);
>>> +    for (uint16_t i = 0; i < NET_TX_RING_SIZE; i++) {
>>> +        add_id_to_freelist(i, txq->freelist);
>>> +        txq->gref[i] = GRANT_INVALID_REF;
>>> +    }
>>> +
>>> +    txq->initialized = true;
>>> +    nfdev->txqs_num++;
>>> +
>>> +    return txq;
>>> +}
>>> +
>>>    static int netfront_rxtx_alloc(struct netfront_dev *nfdev,
>>>            const struct uk_netdev_conf *conf)
>>>    {
>>> @@ -90,6 +169,33 @@ err_free_txrx:
>>>        return rc;
>>>    }
>>>    +static int netfront_txq_info_get(struct uk_netdev *n,
>>> +        uint16_t queue_id,
>>> +        struct uk_netdev_queue_info *qinfo)
>>> +{
>>> +    struct netfront_dev *nfdev;
>>> +    struct uk_netdev_tx_queue *txq;
>>> +    int rc = 0;
>>> +
>>> +    UK_ASSERT(n != NULL);
>>> +    UK_ASSERT(qinfo != NULL);
>>> +
>>> +    nfdev = to_netfront_dev(n);
>>> +    if (unlikely(queue_id >= nfdev->txqs_num)) {
>>
>> txqs_num is updated only after the queue is configured. The
>>
>> txq_info_get should be called before the txq_configure. This
>>
>> would provide the user of netdev the information needed to
>>
>> configure the txq.
>>
> 
> Yeah, nfdev->max_queue_pairs should make more sense.
> 
>>> +        uk_pr_err("Invalid queue_id %"__PRIu16"\n", queue_id);
>>> +        rc = -EINVAL;
>>> +        goto exit;
>>> +    }
>>> +    txq = &nfdev->txqs[queue_id];
>>> +    qinfo->nb_min = txq->ring_size;
>>> +    qinfo->nb_max = txq->ring_size;
>>> +    qinfo->nb_align = PAGE_SIZE;
>>> +    qinfo->nb_is_power_of_two = 1;

I noticed that there is a mis-understanding with nb_align and 
nb_is_power_of_two. These parameters are related to the "number of 
descriptors". They are describing restrictiond that apply for sizing a 
queue. uknetdev does currently not have an align parameter for packet 
buffers which we need for netfront, in fact.
Similar to ukblkdev, I added one called `ioalign` to netdev with the 
patch series 1560:
https://patchwork.unikraft.org/project/unikraft/list/?series=1560
Something like this we need for properly support netfront. Sharan is 
doing the review of 1560 currently.

Thanks,

Simon

>>> +
>>> +exit:
>>> +    return rc;
>>> +}
>>> +
>>>    static int netfront_configure(struct uk_netdev *n,
>>>            const struct uk_netdev_conf *conf)
>>>    {
>>> @@ -179,6 +285,8 @@ static unsigned int netfront_promisc_get(struct
>>> uk_netdev *n)
>>>      static const struct uk_netdev_ops netfront_ops = {
>>>        .configure = netfront_configure,
>>> +    .txq_configure = netfront_txq_setup,
>>> +    .txq_info_get = netfront_txq_info_get,
>>>        .info_get = netfront_info_get,
>>>        .einfo_get = netfront_einfo_get,
>>>        .hwaddr_get = netfront_mac_get,
>>> diff --git a/plat/xen/drivers/net/netfront.h
>>> b/plat/xen/drivers/net/netfront.h
>>> index a811b092..d3f603b3 100644
>>> --- a/plat/xen/drivers/net/netfront.h
>>> +++ b/plat/xen/drivers/net/netfront.h
>>> @@ -37,11 +37,40 @@
>>>    #define __NETFRONT_H__
>>>      #include <uk/netdev.h>
>>> +#include <uk/semaphore.h>
>>> +#include <xen/io/netif.h>
>>> +#include <common/gnttab.h>
>>> +#include <common/events.h>
>>> +
>>> +
>>> +#define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE)
>>>      /**
>>>     * internal structure to represent the transmit queue.
>>>     */
>>>    struct uk_netdev_tx_queue {
>>> +    /* The netfront device */
>>> +    struct netfront_dev *netfront_dev;
>>> +    /* The libuknet queue identifier */
>>> +    uint16_t lqueue_id;
>>> +    /* True if initialized */
>>> +    bool initialized;
>>> +
>>> +    /* Shared ring size */
>>> +    uint16_t ring_size;
>>> +    /* Shared ring */
>>> +    netif_tx_front_ring_t ring;
>>> +    /* Shared ring grant ref */
>>> +    grant_ref_t ring_ref;
>>> +    /* Queue event channel */
>>> +    evtchn_port_t evtchn;
>>> +
>>> +    /* Free list protecting semaphore */
>>> +    struct uk_semaphore sem;
>>> +    /* Free list of transmitting request IDs */
>>> +    uint16_t freelist[NET_TX_RING_SIZE + 1];
>>> +    /* Grants for transmit buffers */
>>> +    grant_ref_t gref[NET_TX_RING_SIZE];
>>>    };
>>>      /**
>>> @@ -63,6 +92,7 @@ struct netfront_dev {
>>>        struct uk_netdev netdev;
>>>          /* List of the Rx/Tx queues */
>>> +    uint16_t txqs_num;
>>>        struct uk_netdev_tx_queue *txqs;
>>>        struct uk_netdev_rx_queue *rxqs;
>>>        /* Maximum number of queue pairs */
>>
> 


