From patchwork Tue Oct 6 09:44:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 1377314 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=RA255YKa; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=NOAgb2Ez; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C5CHV0T3Bz9sS8 for ; Tue, 6 Oct 2020 20:44:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zx+hE9Ceci1GW3e3anSC/uqMrAfteAtB4nlumS2snyU=; b=RA255YKadFt6Cmq3FwjjiuIvD he3spgiCpOfgFx8YZ7wvnA93R7bU5b2VNskDAjlhwQLcARqL/VmKUNFjAUeh4UkHV92KiIAoPNshM YPVh8hZcIMmxYQZDz/gn99qKP6UO7JacXgglYt0N3H0gZ6px1n4SjIT+fqOG4j0Wx18XrbD3KFnZr vyILWm402bcWa025IcWk9TfAU7gK/CC4rtaFZNxCGOsdpKJ5OyVXd4nyrTLsMjLqi3wcaDl1jNWg3 21hQ2T123yLDBBS3Kwib468z6Eek3AoBOzVLP5ELapicVyy3g5A239A+7EFuBcZ85Hntaxte6akgc FZkNUuoPw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPjWc-0008Jb-Me; Tue, 06 Oct 2020 09:44:50 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPjWY-0008I3-Vg for linux-um@lists.infradead.org; Tue, 06 Oct 2020 09:44:47 +0000 Received: by mail-pl1-x641.google.com with SMTP id m15so951679pls.8 for ; Tue, 06 Oct 2020 02:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aeduLP4IxG8QLm5XBKojGInFwj9Qco6vm9ib8DpEzok=; b=NOAgb2EzKIDQIfoNs0ZSPUHp2qbsYVXTyo8CNJ7XG+GZBEraYoaX6JU8PXJHtUJE2B bfNFQ3w/Esw6I7ru7yQh9LylS4XKFQWW7gJa0MyRjk/V3q9110LX9djxOkvbqnma+Imn d+v04wDXnHQsy6qaP891dJOUnMkFwx48bEQH+S/2zszqdvxxg/nBWw1vEmeNHgwjqL30 DwqNyVStcnM/pFT90yiCKMNbjWQmLgDsIMuSEMjSmqCzYAc+31f9xg4EA2Lbn2J8JGMp PLt4hP8JHBpOyR2+yRFGLMpKZEbuzO7PgtR4P0xX0asPpEI/fb5Ob2wv/uQpZOw/P2jU PxPQ== 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=aeduLP4IxG8QLm5XBKojGInFwj9Qco6vm9ib8DpEzok=; b=TgXsqPDcK+IWxFysHDqueD2KzTXvznxJIdZAWuitAHJHRmzFd1v2k1HLF0MMclmZFv 8w9Adq1VxBjC5L8vinN3UAlAqLHQ7RDrUvEP/GKoC2RUM+1mv0CMEcseEhHMYj3vj0vX JCNytBrE4Z3yNT+Jogxj7qNSZ6lLNC2Vu9EYsAaKpVy8u9bj8I2vP3+vL67oS4MnstK7 jgeBpDtPssb6HUKc+yPwXUcULxuP0RcT4NIhjeQJ6aF9PajXhvXiXkM4B/0U0V1okGfU +kqI7uFBmedRgMVnRmzV4lODOo09Q2f31XbfUT/v0Ul3Lpl27jEBQw4j4FkBz9E9o/7g TrDg== X-Gm-Message-State: AOAM53192oS4hoMjgdxdX/stt03Lss6f8bbNTRjJaUkyElvDwrfHzkXc YbKcagNQsRZYhj0bLRkTHIQ= X-Google-Smtp-Source: ABdhPJwfK7KyY/BU6mloggRGk7amkXG2i9TCxTK9ZytVcgmty25d7O1Hc7diSs9xxXUUhzMRXAzkFw== X-Received: by 2002:a17:90a:420b:: with SMTP id o11mr3492689pjg.142.1601977484877; Tue, 06 Oct 2020 02:44:44 -0700 (PDT) Received: from earth-mac.local (219x123x138x129.ap219.ftth.ucom.ne.jp. [219.123.138.129]) by smtp.gmail.com with ESMTPSA id w187sm356418pfb.93.2020.10.06.02.44.44 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Oct 2020 02:44:44 -0700 (PDT) Received: by earth-mac.local (Postfix, from userid 501) id 4091420390F417; Tue, 6 Oct 2020 18:44:42 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com Subject: [RFC v7 02/21] um: add os init and exit calls Date: Tue, 6 Oct 2020 18:44:11 +0900 Message-Id: <184f5b2c6a0c399edf519d27989519a35ab90700.1601960644.git.thehajime@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201006_054447_051917_9F4B6403 X-CRM114-Status: GOOD ( 14.07 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [thehajime[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:641 listed in] [list.dnswl.org] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tavi.purdila@gmail.com, linux-kernel-library@freelists.org, linux-arch@vger.kernel.org, Octavian Purdila , retrage01@gmail.com Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Octavian Purdila These calls are added in preparation for moving some of the code from the kernel to the host build. Signed-off-by: Octavian Purdila --- arch/um/include/shared/init.h | 14 ++++---------- arch/um/kernel/reboot.c | 5 +++++ arch/um/kernel/um_arch.c | 11 +++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/arch/um/include/shared/init.h b/arch/um/include/shared/init.h index c66de434a983..d09308330ca5 100644 --- a/arch/um/include/shared/init.h +++ b/arch/um/include/shared/init.h @@ -109,19 +109,13 @@ extern struct uml_param __uml_setup_start, __uml_setup_end; #ifdef __UM_HOST__ -#define __define_initcall(level,fn) \ - static initcall_t __initcall_##fn __used \ - __attribute__((__section__(".initcall" level ".init"))) = fn - -/* Userspace initcalls shouldn't depend on anything in the kernel, so we'll - * make them run first. - */ -#define __initcall(fn) __define_initcall("1", fn) +#undef __uml_exit_call +#define __uml_exit_call __used __section(os_exitcalls) +#define __init_call __used __section(os_initcalls) +#define __initcall(fn) static initcall_t __initcall_##fn __init_call = fn #define __exitcall(fn) static exitcall_t __exitcall_##fn __exit_call = fn -#define __init_call __used __section(.initcall.init) - #endif #endif /* _LINUX_UML_INIT_H */ diff --git a/arch/um/kernel/reboot.c b/arch/um/kernel/reboot.c index 48c0610d506e..5420aec411f4 100644 --- a/arch/um/kernel/reboot.c +++ b/arch/um/kernel/reboot.c @@ -35,10 +35,15 @@ static void kill_off_processes(void) read_unlock(&tasklist_lock); } +void __weak os_exitcalls(void) +{ +} + void uml_cleanup(void) { kmalloc_ok = 0; do_uml_exitcalls(); + os_exitcalls(); kill_off_processes(); } diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 00141e70de56..e2cb76c03b25 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c @@ -377,3 +377,14 @@ void *text_poke(void *addr, const void *opcode, size_t len) void text_poke_sync(void) { } + +int __weak os_initcalls(void) +{ + return 0; +} + +int __init run_os_initcalls(void) +{ + return os_initcalls(); +} +early_initcall(run_os_initcalls);