From patchwork Thu Sep 24 07:12:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 1370366 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=Mp4/HcRi; 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=e9hMfqV+; 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 4BxmVx3Xbqz9sTH for ; Thu, 24 Sep 2020 17:14:01 +1000 (AEST) 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=Mp4/HcRi+/+cembmwJ+/VAIRO 7am9Mzd4VdEipx7E2zVVXIDFywCZBoWdum8CaCfNQ9r8K9bvhYGue56VU6iP1U0IAodI2I/XLs41P 6Cs9Ef1CiuZN5cHKOWiPZwieI8Ihtt5PBz2Wbim/8cXxhIcjtCR7hwuMwTEbJdI0kGXfVCWCHcWBa 5Cm2cR3phDEDHvitnuucA/cgSBoznG3WVudLXoyjDMN3ds8cckcjbYzS+GnXjZMOPpCSuHrrShLF/ gq0yHJLYr5VZCVvy6FAJ83OsVgphqS0llHYxORhWJI6AFP31kqxyeoQuNPYnZ+sjPGkglrCqYk6qj /nDdXWMNw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLLS2-000385-9O; Thu, 24 Sep 2020 07:13:58 +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 1kLLRx-00034u-U0 for linux-um@lists.infradead.org; Thu, 24 Sep 2020 07:13:55 +0000 Received: by mail-pl1-x641.google.com with SMTP id q12so1171265plr.12 for ; Thu, 24 Sep 2020 00:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aeduLP4IxG8QLm5XBKojGInFwj9Qco6vm9ib8DpEzok=; b=e9hMfqV+8Qyp+mFEsnlBzQhOkdw4jChVTgzW2atFzOcF6eQ2Ofe+ye8hUrWWTsOjbQ KkdbtHtBxKy1AJRynUw4HSB0vXLCxFsa14oVWiRAm5JrhM3q0VdvWCLDqpl+yAIknf66 iZUAiqGudwylI/vJ76rkJXpQYUawD+CYpv2uwpS1p1VxTrS2qAaeKS/rMVxpm0XdeyJs xizwF8wbY5eO7ItoYXfu0UsFcPWjtleNbAdGhB70x0F/6M7pCEoIXIJtSisOBVbVNo2P ZbIl0bNdqIWGtBwCmC3JEfIlHJrgxbiMzleiQwicYy8uiE7YPq5LoNK/0jPejrVzOn0g SNfw== 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=AbUwnVGyINFORZ7x58YD5iMOBX9B/fnr0o00DYwnryUsQqWCqcRhaV0QRqc8OxKRbU JlPxnz2ku2tzw+fgpfdbPINiussY5J81YhCTm2544EjuYYAuSjzHeR6k/rpSMosJ4ahK cbTmhsHVni9XiyNNKVWYzGti137Egt2N9DGbU0hANU9WS11B2cvPwA77ZzZSg7VJys4y xy+YETgHASGsDDxsXeTDlXR1ay5jNyHWZomFGzOuGQa7SZxiHEzaBYpBeOt8fxrkPFJs U09l/xoZG4TcAYE8+ZtmvqmN58I9xoPkUcWvzt17DVXdJxbv0/OG6E6DNqcj5wrp8cka vdjA== X-Gm-Message-State: AOAM531qTfdT/vvQIe2KXAyF+hfaOiUcyoIDLf92w3UEwdHFnbJgBGiC 4G5tQVQnUCCCTR5mkq2wy/I= X-Google-Smtp-Source: ABdhPJy6l/2edLKPoLJJy/XOmFKZ6m7ZQp1W8mAAVtYqAunDxDl8EBLdy0PozZJ9/JBpa04m6QK7UA== X-Received: by 2002:a17:902:ec02:b029:d1:fc2b:fe95 with SMTP id l2-20020a170902ec02b02900d1fc2bfe95mr3408136pld.79.1600931631684; Thu, 24 Sep 2020 00:13:51 -0700 (PDT) Received: from earth-mac.local (219x123x138x129.ap219.ftth.ucom.ne.jp. [219.123.138.129]) by smtp.gmail.com with ESMTPSA id y79sm1846800pfb.45.2020.09.24.00.13.51 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Sep 2020 00:13:51 -0700 (PDT) Received: by earth-mac.local (Postfix, from userid 501) id 5B88E2037C202F; Thu, 24 Sep 2020 16:13:49 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com Subject: [RFC v6 02/21] um: add os init and exit calls Date: Thu, 24 Sep 2020 16:12:42 +0900 Message-Id: <0479e4453fbc20abc3a9a7fbd892bb258440712a.1600922528.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-20200924_031354_055174_6FAB3C7B X-CRM114-Status: GOOD ( 13.64 ) 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 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.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [thehajime[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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);