From patchwork Mon Jun 20 14:04:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel De Graaf X-Patchwork-Id: 9187545 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 05211607D1 for ; Mon, 20 Jun 2016 14:06:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E62362780C for ; Mon, 20 Jun 2016 14:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAF992793A; Mon, 20 Jun 2016 14:06:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5BF782780C for ; Mon, 20 Jun 2016 14:06:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEzon-00010v-1c; Mon, 20 Jun 2016 14:04:49 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEzol-0000xZ-IF for xen-devel@lists.xen.org; Mon, 20 Jun 2016 14:04:47 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 67/43-26908-EF7F7675; Mon, 20 Jun 2016 14:04:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsXCoZPKofv3e3q 4wcotlhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a5iV+ZCibJVhx618HawHhevIuRk0NCwE9i yckr7F2MXBycArNZJH6+WMMK4kgIHGaUOL3nHBOIIyTQzigxrf8VI4SzjVHiedNkVpB+NgFdi QUHVzKB2CIC0hLXPl9mBLGZBbQlmt/NZAexhQUcJZ5N/AJkc3CwCKhKfOnTBwnzCrhJnDjxhg 3iDDmJm+c6mUFsTqD4+S+3wGwhAVeJi5Nvsk5g5FvAyLCKUaM4tagstUjX0EIvqSgzPaMkNzE zR9fQwFQvN7W4ODE9NScxqVgvOT93EyMwVBiAYAdj03bPQ4ySHExKorzTn6SHC/El5adUZiQW Z8QXleakFh9ilOHgUJLg5f4KlBMsSk1PrUjLzAEGLUxagoNHSYSXByTNW1yQmFucmQ6ROsWoK CXO++cLUEIAJJFRmgfXBouUS4yyUsK8jECHCPEUpBblZpagyr9iFOdgVBKG2M6TmVcCN/0V0G ImoMXL+sEWlyQipKQaGJ1u/+Kfbc8uUZ2duyLd9PwkRse7FuUvTnKul9yRsvnnBb/M9C7ZPVF 7olOjLBNmLTq+4O/ah+5tSbbpwr9CC17qXV9vHOJ/6mXUQYGOO8c2mywTqmz5xZytO3f/hmcf a9bYrDZeZaDT4v16f+GF7XLeGRsjl24OW8JwO+iamWFR1JozSTFbJymxFGckGmoxFxUnAgBi4 304jwIAAA== X-Env-Sender: dgdegra@tycho.nsa.gov X-Msg-Ref: server-10.tower-206.messagelabs.com!1466431478!28560704!6 X-Originating-IP: [8.44.101.8] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3542 invoked from network); 20 Jun 2016 14:04:45 -0000 Received: from smtp.nsa.gov (HELO emsm-gh1-uea10.nsa.gov) (8.44.101.8) by server-10.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Jun 2016 14:04:45 -0000 X-IronPort-AV: E=Sophos;i="5.26,498,1459814400"; d="scan'208";a="14811876" IronPort-PHdr: =?us-ascii?q?9a23=3A+32+6hBWSOdVE5TNyP/4UyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSP79psbcNUDSrc9gkEXOFd2CrakU2qyH7uu+BiQp2tWojjMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3Dwdp?= =?us-ascii?q?POO9QteU1JTmkbHvsMOMKyxzxxODIppKZC2sqgvQssREyaBDEY0WjiXzn31TZu?= =?us-ascii?q?5NznlpL1/A1zz158O34YIxu38I46FpytREGZneU+x4COYATWduD2dg9MDt8BXO?= =?us-ascii?q?UwaLzn8dSXkN1ApFBU7C9h6pcI32t37Wv+x81S3SEcC+Yqo9UDrqu6tkRBLnki?= =?us-ascii?q?4vKy8y8GaRjNd5yq1cvkTy9FRE34fIbdTNZ7JFdaTHcIZfHzJM?= X-IPAS-Result: =?us-ascii?q?A2GpAwAy92dX/wHyM5BdGgEBAQGDIIFTuFeECYYXAoExTAE?= =?us-ascii?q?BAQEBAQICYieCMYIbAgR5EBg5VxmIMMBIAQEBAQYCASSVDwWIEpBkjioCiVqFR?= =?us-ascii?q?kiPL1SCCByBaCAyikgBAQE?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea10.nsa.gov with ESMTP; 20 Jun 2016 14:04:32 +0000 Received: from moss-nexus.infosec.tycho.ncsc.mil (moss-nexus [192.168.25.48]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u5KE4U6A018300; Mon, 20 Jun 2016 10:04:30 -0400 From: Daniel De Graaf To: xen-devel@lists.xen.org Date: Mon, 20 Jun 2016 10:04:21 -0400 Message-Id: <1466431466-28055-13-git-send-email-dgdegra@tycho.nsa.gov> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466431466-28055-1-git-send-email-dgdegra@tycho.nsa.gov> References: <1466431466-28055-1-git-send-email-dgdegra@tycho.nsa.gov> Cc: Daniel De Graaf Subject: [Xen-devel] [PATCH 12/17] xen/xsm: remove .xsm_initcall.init section X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since FLASK is the only implementation of XSM hooks in Xen, using an iterated initcall dispatch for setup is overly complex. Change this to a direct function call to a globally visible function; if additional XSM hooks are added in the future, a switching mechanism will be needed regardless, and that can be placed in xsm_core.c. Signed-off-by: Daniel De Graaf Reviewed-by: Doug Goldstein Reviewed-by: Andrew Cooper Acked-by: Julien Grall --- xen/arch/arm/xen.lds.S | 5 ----- xen/arch/x86/xen.lds.S | 5 ----- xen/include/xsm/xsm.h | 16 ++++++++-------- xen/xsm/flask/hooks.c | 4 +--- xen/xsm/xsm_core.c | 13 +------------ 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index 76982b2..8320381 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -162,11 +162,6 @@ SECTIONS *(.initcall1.init) __initcall_end = .; } :text - .xsm_initcall.init : { - __xsm_initcall_start = .; - *(.xsm_initcall.init) - __xsm_initcall_end = .; - } :text __init_end_efi = .; . = ALIGN(STACK_SIZE); __init_end = .; diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index a43b29d..dcbb8fe 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -190,11 +190,6 @@ SECTIONS *(.initcall1.init) __initcall_end = .; } :text - .xsm_initcall.init : { - __xsm_initcall_start = .; - *(.xsm_initcall.init) - __xsm_initcall_end = .; - } :text . = ALIGN(PAGE_SIZE); __init_end = .; diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 8ed8ee5..0d525ec 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -46,14 +46,6 @@ typedef enum xsm_default xsm_default_t; extern char *policy_buffer; extern u32 policy_size; -typedef void (*xsm_initcall_t)(void); - -extern xsm_initcall_t __xsm_initcall_start[], __xsm_initcall_end[]; - -#define xsm_initcall(fn) \ - static xsm_initcall_t __initcall_##fn \ - __used_section(".xsm_initcall.init") = fn - struct xsm_operations { void (*security_domaininfo) (struct domain *d, struct xen_domctl_getdomaininfo *info); @@ -763,6 +755,14 @@ extern int unregister_xsm(struct xsm_operations *ops); extern struct xsm_operations dummy_xsm_ops; extern void xsm_fixup_ops(struct xsm_operations *ops); +#ifdef CONFIG_FLASK +extern void flask_init(void); +#else +static inline void flask_init(void) +{ +} +#endif + #else /* CONFIG_XSM */ #include diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 543406b..d632b0e 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1817,7 +1817,7 @@ static struct xsm_operations flask_ops = { .xen_version = flask_xen_version, }; -static __init void flask_init(void) +__init void flask_init(void) { int ret = -ENOENT; @@ -1860,8 +1860,6 @@ static __init void flask_init(void) printk(XENLOG_INFO "Flask: Starting in permissive mode.\n"); } -xsm_initcall(flask_init); - /* * Local variables: * mode: C diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 634ec98..3487742 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -36,17 +36,6 @@ static inline int verify(struct xsm_operations *ops) return 0; } -static void __init do_xsm_initcalls(void) -{ - xsm_initcall_t *call; - call = __xsm_initcall_start; - while ( call < __xsm_initcall_end ) - { - (*call) (); - call++; - } -} - static int __init xsm_core_init(void) { if ( verify(&dummy_xsm_ops) ) @@ -57,7 +46,7 @@ static int __init xsm_core_init(void) } xsm_ops = &dummy_xsm_ops; - do_xsm_initcalls(); + flask_init(); return 0; }