From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290403; cv=pass; d=zohomail.com; s=zohoarc; b=keBbZg+GriWBEq/KLdLQn+Q9EFtJhUyQESOEB7tLaScGkZqPkg/p8KDZmHRjPi2cETGxNo0bUpd2rS2IKBf09CHqVXOOGD7OBm8yMRWWWYlzIQjVFAr57PNaheBpJMwDJ0yHIHvFEExw6k9TEmzppFnfLSa09Uh8RTEiyjyGtkA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290403; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tLQ4wb+FrQv7YprfemUlYGSVQiae5X1F/rSp63hNSzo=; b=DrbN+x99wRGySLj9k3r+RvyvBw3iPQgA7VmTLpve6dEfQweQvadkVxlXY7M2Jn7wUggI7URg6ECYxBIMVDYG33N8nc4nyXBWatvMiaHzZWbOa2c1tUJioUonmijw4UONaKTot8arLZsz8G8fE2zljI7MqQ2dPiP67dCdPKCzDqU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631290403032549.7806850029797; Fri, 10 Sep 2021 09:13:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184576.333279 (Exim 4.92) (envelope-from ) id 1mOj9D-0006de-Cb; Fri, 10 Sep 2021 16:13:03 +0000 Received: by outflank-mailman (output) from mailman id 184576.333279; Fri, 10 Sep 2021 16:13:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOj9D-0006dV-94; Fri, 10 Sep 2021 16:13:03 +0000 Received: by outflank-mailman (input) for mailman id 184576; Fri, 10 Sep 2021 16:13:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOj9C-0006Mo-8Z for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:13:02 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e5969009-43a6-454c-8afc-04b5103295e9; Fri, 10 Sep 2021 16:13:01 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1631290372344276.49709791440694; Fri, 10 Sep 2021 09:12:52 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e5969009-43a6-454c-8afc-04b5103295e9 ARC-Seal: i=1; a=rsa-sha256; t=1631290375; cv=none; d=zohomail.com; s=zohoarc; b=NbcvrcfBQp9+lo4wOZaNruDGRNjgGTsmc/WlQ0wfS3uPwT8RmDhZqESzWGo5D8zqqP6aADEy78h8KOt99J+Ka60zOvjFJQy+6hcLBJG9M5ENwsQ0m4Ww18GyrqGGYo56pChthlBVaspsl0bnrFZdqs8mAVIh+mwxzd+glODztho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290375; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=tLQ4wb+FrQv7YprfemUlYGSVQiae5X1F/rSp63hNSzo=; b=BqW/PhIxreNOFzDfzGghyPUJXNjckJ4PuCCBTpm9KQWEl7zWI0iVnqcwrwxg8KKU6oEj6d8i7ZT7l4SHA6XczoG2iuVOPxAR0fdsw6vXVSHj0/4t8HaPIsiCOpfL2OrWAC7YAwvnl8z9L0hALGGb2NTjXfXqpZmDNeAvH3fAdDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290375; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=tLQ4wb+FrQv7YprfemUlYGSVQiae5X1F/rSp63hNSzo=; b=Y1NDr+IeQvHJnFHw3K9gOCe0QP4uipoZhPVw0XLjaLmwta1fUBNx9pZou4khacaU nzOJ61ipmq7gTYJePV7KKECJDW/1f1HP3mX4RpwHct0HbuKd61rxryMqfO9NirsWKEI L64L5Bgian5hVSzR504RcgwP/CwisP6v65skoajo= From: "Daniel P. Smith" To: Wei Liu , xen-devel@lists.xenproject.org Cc: Andrew Cooper , "Daniel P . Smith" , Jan Beulich , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bob Eshleman , Alistair Francis , Connor Davis , George Dunlap , Ian Jackson Subject: [PATCH v6 01/10] xen: Implement xen/alternative-call.h for use in common code Date: Fri, 10 Sep 2021 16:12:56 -0400 Message-Id: <20210910201305.32526-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290404972100002 From: Andrew Cooper The alternative call infrastructure is x86-only for now, but the common iom= mu code has a variant and more common code wants to use the infrastructure. Introduce CONFIG_ALTERNATIVE_CALL and a conditional implemetnation so common code can use the optimisation when available, without requiring all architectures to implement no-op stubs. Write some documentation, which was thus far entirely absent, covering the requirements for an architecture to implement this optimsiation, and how to use the infrastructure in general code. Signed-off-by: Andrew Cooper Signed-off-by: Daniel P. Smith Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bob Eshleman CC: Alistair Francis CC: Connor Davis CC: Daniel P. Smith v3: * Drop __alt_call_maybe_initconst This is a pre-requisite to "xsm: refactor xsm_ops handling" to avoid breaki= ng the ARM build. Build test for the XSM code: diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 5eab21e1b168..592074e8f41c 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -195,6 +195,16 @@ bool __init has_xsm_magic(paddr_t start) } #endif +#include +struct foo { + int (*bar)(void *); +} foo __alt_call_maybe_initdata; + +int test_alternative_call(void) +{ + return alternative_call(foo.bar, NULL); +} + int __init register_xsm(struct xsm_operations *ops) { if ( verify(ops) ) --- xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 3 ++ xen/include/xen/alternative-call.h | 63 ++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 xen/include/xen/alternative-call.h diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 9b164db641..1f83518ee0 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -6,6 +6,7 @@ config X86 def_bool y select ACPI select ACPI_LEGACY_TABLES_LOOKUP + select ALTERNATIVE_CALL select ARCH_SUPPORTS_INT128 select CORE_PARKING select HAS_ALTERNATIVE diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 0ddd18e11a..ac5491b1cc 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -22,6 +22,9 @@ config GRANT_TABLE =20 If unsure, say Y. =20 +config ALTERNATIVE_CALL + bool + config HAS_ALTERNATIVE bool =20 diff --git a/xen/include/xen/alternative-call.h b/xen/include/xen/alternati= ve-call.h new file mode 100644 index 0000000000..c0be270e28 --- /dev/null +++ b/xen/include/xen/alternative-call.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef XEN_ALTERNATIVE_CALL +#define XEN_ALTERNATIVE_CALL + +/* + * Some subsystems in Xen may have multiple implementions, which can be + * resolved to a single implementation at boot time. By default, this will + * result in the use of function pointers. + * + * Some architectures may have mechanisms for dynamically modifying .text. + * Using this mechnaism, function pointers can be converted to direct calls + * which are typically more efficient at runtime. + * + * For architectures to support: + * + * - Implement alternative_{,v}call() in asm/alternative.h. Code generati= on + * requirements are to emit a function pointer call at build time, and s= tash + * enough metadata to simplify the call at boot once the implementation = has + * been resolved. + * - Select ALTERNATIVE_CALL in Kconfig. + * + * To use: + * + * Consider the following simplified example. + * + * 1) struct foo_ops __alt_call_maybe_initdata ops; + * + * 2) const struct foo_ops __initconstrel foo_a_ops =3D { ... }; + * const struct foo_ops __initconstrel foo_b_ops =3D { ... }; + * + * void __init foo_init(void) + * { + * ... + * if ( use_impl_a ) + * ops =3D *foo_a_ops; + * else if ( use_impl_b ) + * ops =3D *foo_b_ops; + * ... + * } + * + * 3) alternative_call(ops.bar, ...); + * + * There needs to a single ops object (1) which will eventually contain the + * function pointers. This should be populated in foo's init() function (= 2) + * by one of the available implementations. To call functions, use + * alternative_{,v}call() referencing the main ops object (3). + */ + +#ifdef CONFIG_ALTERNATIVE_CALL + +#include + +#define __alt_call_maybe_initdata __initdata + +#else + +#define alternative_call(func, args...) (func)(args) +#define alternative_vcall(func, args...) (func)(args) + +#define __alt_call_maybe_initdata __read_mostly + +#endif /* !CONFIG_ALTERNATIVE_CALL */ +#endif /* XEN_ALTERNATIVE_CALL */ --=20 2.20.1 From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290413; cv=pass; d=zohomail.com; s=zohoarc; b=JVM4vllILfH0rBOLdPtnfA4qjcvjIRiBRW5LIHT3olNx8xPx9zWTT+Gmwpapu3h0fMpxDXL6u/gKxXzjqASFt3+JWa6awyz2VECUS79eLArhTlytLQ8t4YXNUUu0CIxjaQnlw/ygPTgoAb3bqEiV5u4b2pMdMdL0w8NHBhGngZQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290413; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R9fWktmmlY/XpFnqpgzdSmnNqMw4SOU1eoy5oHGQ8QI=; b=e1E+W63S2Dwh6Hfz2Hx1knnSByWEy+QFfdPZdPwXqloIeC8MKNC7I/iV0u4MyRa6LE+ym9U2P6DFgsw1P9GDKbQmzcppciRjilJZPVIq+8uuALK8xPh0MdotojD+MNaiXCyDpoECVKq0uylrsmvpQ3X7jCIxgKQeu5HTGerhaPE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631290413303683.6650191498677; Fri, 10 Sep 2021 09:13:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184580.333290 (Exim 4.92) (envelope-from ) id 1mOj9T-00077e-L3; Fri, 10 Sep 2021 16:13:19 +0000 Received: by outflank-mailman (output) from mailman id 184580.333290; Fri, 10 Sep 2021 16:13:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOj9T-00077X-HH; Fri, 10 Sep 2021 16:13:19 +0000 Received: by outflank-mailman (input) for mailman id 184580; Fri, 10 Sep 2021 16:13:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOj9S-00075v-GJ for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:13:18 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 87d67a80-b29d-4c26-8405-e69cb21b773d; Fri, 10 Sep 2021 16:13:17 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1631290374880385.695511741147; Fri, 10 Sep 2021 09:12:54 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 87d67a80-b29d-4c26-8405-e69cb21b773d ARC-Seal: i=1; a=rsa-sha256; t=1631290378; cv=none; d=zohomail.com; s=zohoarc; b=eftcgl6WBbiBfHcWeuvjVd4/qZ8X9u42X6fasPZ2qPXlTG5r79DCz37iXh9nVOyHnh2aIeLDypzdcder0sgkQDVF74Y4EBY3u1uBiMw1pxUsM62nD3CWHluaOLahdf8NobOM/cYLzallBx1Z795TJ4F3YKKziz5jmO966aQRxJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290378; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=R9fWktmmlY/XpFnqpgzdSmnNqMw4SOU1eoy5oHGQ8QI=; b=Ujk8UKtyRxBcHSK/03ujSNKhs/hpyY21D+xMAp3nYgi88uHY0Mjh23oMSt9/FCeW01AE8cJT5bfRoDd/i+Y0nhZ6Yor9I7HsEVHCk1b52LRBcKuyWuFDCqdWNTTOBNIeYFgv8q5ebopnqfUnDacmMCMlZIBh1+qC9IEt7LFQT64= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290378; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=R9fWktmmlY/XpFnqpgzdSmnNqMw4SOU1eoy5oHGQ8QI=; b=ZhTDnfQS85Ean6yaJtku37HJH9WA+GP+D5wzSnLVtH/8J+WDzntUuwhurhi46EtE 4oXYXm6XpoVuCltFirV+sDBQDvBORsxhaAueSG46Pj3rkwdgs3AY541ovPbAgQp08zC gUbXLZTU0FO9sJguuuYTz5TCQNxk7Q1OVHN8hQUM= From: "Daniel P. Smith" To: "Daniel P. Smith" , xen-devel@lists.xenproject.org Cc: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Daniel De Graaf Subject: [PATCH v6 02/10] xsm: remove the ability to disable flask Date: Fri, 10 Sep 2021 16:12:57 -0400 Message-Id: <20210910201305.32526-3-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290414010100001 Content-Type: text/plain; charset="utf-8" On Linux when SELinux is put into permissive mode the descretionary access controls are still in place. Whereas for Xen when the enforcing state of fl= ask is set to permissive, all operations for all domains would succeed, i.e. it does not fall back to the default access controls. To provide a means to mi= mic a similar but not equivalent behavior, a flask op is present to allow a one-time switch back to the default access controls, aka the "dummy policy". While this may be desirable for an OS, Xen is a hypervisor and should not a= llow the switching of which security policy framework is being enforced after bo= ot. This patch removes the flask op to enforce the desired XSM usage model requiring a reboot of Xen to change the XSM policy module in use. Signed-off-by: Daniel P. Smith Acked-by: Andrew Cooper --- xen/include/public/xsm/flask_op.h | 2 +- xen/xsm/flask/flask_op.c | 30 ------------------------------ 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/xen/include/public/xsm/flask_op.h b/xen/include/public/xsm/fla= sk_op.h index 16af7bc22f..b41dd6dac8 100644 --- a/xen/include/public/xsm/flask_op.h +++ b/xen/include/public/xsm/flask_op.h @@ -188,7 +188,7 @@ struct xen_flask_op { #define FLASK_SETBOOL 12 #define FLASK_COMMITBOOLS 13 #define FLASK_MLS 14 -#define FLASK_DISABLE 15 +#define FLASK_DISABLE 15 /* No longer implemented */ #define FLASK_GETAVC_THRESHOLD 16 #define FLASK_SETAVC_THRESHOLD 17 #define FLASK_AVC_HASHSTATS 18 diff --git a/xen/xsm/flask/flask_op.c b/xen/xsm/flask/flask_op.c index 01e52138a1..f41c025391 100644 --- a/xen/xsm/flask/flask_op.c +++ b/xen/xsm/flask/flask_op.c @@ -223,32 +223,6 @@ static int flask_security_sid(struct xen_flask_sid_con= text *arg) =20 #ifndef COMPAT =20 -static int flask_disable(void) -{ - static int flask_disabled =3D 0; - - if ( ss_initialized ) - { - /* Not permitted after initial policy load. */ - return -EINVAL; - } - - if ( flask_disabled ) - { - /* Only do this once. */ - return -EINVAL; - } - - printk("Flask: Disabled at runtime.\n"); - - flask_disabled =3D 1; - - /* Reset xsm_ops to the original module. */ - xsm_ops =3D &dummy_xsm_ops; - - return 0; -} - static int flask_security_setavc_threshold(struct xen_flask_setavc_thresho= ld *arg) { int rv =3D 0; @@ -698,10 +672,6 @@ ret_t do_flask_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) u_f= lask_op) rv =3D flask_mls_enabled; break; =20 =20 - case FLASK_DISABLE: - rv =3D flask_disable(); - break; - case FLASK_GETAVC_THRESHOLD: rv =3D avc_cache_threshold; break; --=20 2.20.1 From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290433; cv=pass; d=zohomail.com; s=zohoarc; b=UQO6DCn6TpPEmZVoEFU8GNkkK94FSyqvZ8L5z1gr9k4D6MQWVqiM874snxVO060sklqyWE45SBxoSNI1Rcz08T+jFj/27nL/swMxudcECBx3OU4mz8mjARf9a9U/SSPzo14D6jWDtlhcwv9X0Y6u4nAbRlyoO5LqYAoUIMuVKr0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290433; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2IE2exj9FVV6j0OTxj+ijceEC3Bs7d1+JzBzHRRpcYI=; b=LW621pqfVARmo3TVkkZs2U7/9kWR4Rwn3g5OPYdOXKKErsDas/dYDwC3cj1Oi1y0MSdZFS2GnxZ2dh2668rXtxs8oSObEEM7YqDJsVVOnbybvasGttanDSzsx8oIQ7ncJOjqpJp68H4pTT7wMdR/BgZEm/eZZ3WG+yoVP0FGE6g= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631290433432789.3745575348136; Fri, 10 Sep 2021 09:13:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184593.333301 (Exim 4.92) (envelope-from ) id 1mOj9m-0007pm-Td; Fri, 10 Sep 2021 16:13:38 +0000 Received: by outflank-mailman (output) from mailman id 184593.333301; Fri, 10 Sep 2021 16:13:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOj9m-0007pb-QH; Fri, 10 Sep 2021 16:13:38 +0000 Received: by outflank-mailman (input) for mailman id 184593; Fri, 10 Sep 2021 16:13:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOj9l-00075v-8G for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:13:37 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ca8ce114-82cb-4ca1-8ddf-7eba1622de29; Fri, 10 Sep 2021 16:13:31 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 163129037659656.3504099923116; Fri, 10 Sep 2021 09:12:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ca8ce114-82cb-4ca1-8ddf-7eba1622de29 ARC-Seal: i=1; a=rsa-sha256; t=1631290379; cv=none; d=zohomail.com; s=zohoarc; b=DWzvGC/MvXBC2nLTXp+5lSjhdtveh+ZwiCJY05cuX5NJVEG6wf2jJvYQEbQ7xxhkxe0C6gpIDlH0MTswDvd16IZySqGFziow+rit+LT2sa2AxHhgLcR8hoEOKCgx+8vkLCOi3jwBO0wwdQ5GrAiQjpuveZqZpwnxeRsXDJuQba0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290379; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2IE2exj9FVV6j0OTxj+ijceEC3Bs7d1+JzBzHRRpcYI=; b=Ubkb2ItdvZldo5RTvxFoM10O3W79QUSDKc8hB41cgJux2Hu21qyDNuUUT1O//ZgNcBFgXLwJRIhK24QkEAjW8L9WZXjl3Z/gFyLnZLAfxvY+Qp3qVYqTwILLSQ2z98oTIyh0qoHy2SdIVvyNwpPme5S97f1Gv+Cpbk1O4KipJkk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290379; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=2IE2exj9FVV6j0OTxj+ijceEC3Bs7d1+JzBzHRRpcYI=; b=L9EdEVmVhiaJX0ta79XPP7F17m1vHwUT9/YLGTQQvDDy3rFnpCYZOsHgQxq56nxL DZ+jyfyFkk5GDDp5xhEZrgTq+qXzI1f3YDQyvTbbuNPds0jZn0ljewG6q0Lnr2p0K/b gARtpsR1r5iNK0BlarD6ZtPeTlCpxStDShf8NUB0= From: "Daniel P. Smith" To: "Daniel P. Smith" , xen-devel@lists.xenproject.org Cc: Jan Beulich , Daniel De Graaf Subject: [PATCH v6 03/10] xsm: remove remnants of xsm_memtype hook Date: Fri, 10 Sep 2021 16:12:58 -0400 Message-Id: <20210910201305.32526-4-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290434469100001 Content-Type: text/plain; charset="utf-8" In c/s fcb8baddf00e the xsm_memtype hook was removed but some remnants were left behind. This commit cleans up those remnants. Signed-off-by: Daniel P. Smith Acked-by: Jan Beulich --- xen/include/xsm/xsm.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index ad3cddbf7d..335ba1b022 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -161,7 +161,6 @@ struct xsm_operations { int (*shadow_control) (struct domain *d, uint32_t op); int (*mem_sharing_op) (struct domain *d, struct domain *cd, int op); int (*apic) (struct domain *d, int cmd); - int (*memtype) (uint32_t access); int (*machine_memory_map) (void); int (*domain_memory_map) (struct domain *d); #define XSM_MMU_UPDATE_READ 1 @@ -632,11 +631,6 @@ static inline int xsm_apic (xsm_default_t def, struct = domain *d, int cmd) return xsm_ops->apic(d, cmd); } =20 -static inline int xsm_memtype (xsm_default_t def, uint32_t access) -{ - return xsm_ops->memtype(access); -} - static inline int xsm_machine_memory_map(xsm_default_t def) { return xsm_ops->machine_memory_map(); --=20 2.20.1 From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290440; cv=pass; d=zohomail.com; s=zohoarc; b=hRbUnQpuBZ7qJ07toCpFTCSMv6c2NLLqDaf5fOPrZ5Qua5TSOA7okZxRxE30Trdl5LMsoZgSNJP5fiJznfeNf+b90KIvMVUwidWp9xIzk+bfYrYsHNeVTmMcLZIIicSEr4BedxZwnB0IYxLUKIEBVBXkSA1gOlEeyRmLp0zqRDw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290440; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Lq07B1AF5Rs92+IfuaXrGvK7UyuYlp7NAcCIhzsP44w=; b=QwzELxR0c6ezbFlfNQWZY8vwPRkPgk4t+p+Gm2qlgC/9MXxo+DkPQhU2ynM1IqJrwa9TlQbPtT0V4deiFSeXGNQ0JD4iDvv3hSXXM4CGlmY5YE5Dnc+hrNH8GWaW+5b/KkMyeht7It+HxW3Fy/v7ifqcKu4sLJSb2sLpGOKneH8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163129044032373.33236042147894; Fri, 10 Sep 2021 09:14:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184596.333312 (Exim 4.92) (envelope-from ) id 1mOj9t-0008EI-BD; Fri, 10 Sep 2021 16:13:45 +0000 Received: by outflank-mailman (output) from mailman id 184596.333312; Fri, 10 Sep 2021 16:13:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOj9t-0008EB-7E; Fri, 10 Sep 2021 16:13:45 +0000 Received: by outflank-mailman (input) for mailman id 184596; Fri, 10 Sep 2021 16:13:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOj9r-0008BY-SZ for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:13:43 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d8ef56ff-e209-46b2-b010-340fcfd9b559; Fri, 10 Sep 2021 16:13:42 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1631290377952988.6809551754033; Fri, 10 Sep 2021 09:12:57 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d8ef56ff-e209-46b2-b010-340fcfd9b559 ARC-Seal: i=1; a=rsa-sha256; t=1631290382; cv=none; d=zohomail.com; s=zohoarc; b=DbVRloX7A6lGIS8oE42ZEP4KKTTc7HlacfVMy2uv2QrGrCRoiGRr7CAIOBhAYgVlodQhVr1hv/DqrretUTuO3xehn8oPDG2DXhadJMr3PCDY575FaNxuW28Q7u3NwbDGsvMhXm3BqK5K644SziVIyl41oxhRbJzOHoUNyyQxYP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290382; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Lq07B1AF5Rs92+IfuaXrGvK7UyuYlp7NAcCIhzsP44w=; b=UTgU0f2lY3Vnx/jw13HUIepIBNBSyGgaXEEmmqRFPjlYwLY5/MYxj/b06xXm72t/p5mAwN4cVUuXia6BekdYWd0hiTllJugqPpWGVH1yK9sneC++K6RlTvT/1rWhYgMvRoOJNw5Zr/YdyRqsSzMi3mDolox8xBAyUYEXulzIIYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290382; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=Lq07B1AF5Rs92+IfuaXrGvK7UyuYlp7NAcCIhzsP44w=; b=cKLCvkgDCgR/ef1rWKLrref4oC1TDlrwcIt0rJh/jkoNlVsEobNn7OFWilx2nWIh BFE/7N0U+6HuLq0rmLFyEiMo0E/K0SZgTcw21eT1mdc1WrnSKxdJUON4T8XIoikQPBC fefq1TXxFnAjlj395CnU8SaF5aztRftz4UUjLAqQ= From: "Daniel P. Smith" To: "Daniel P. Smith" , xen-devel@lists.xenproject.org Cc: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Daniel De Graaf Subject: [PATCH v6 04/10] xsm: drop dubious xsm_op_t type Date: Fri, 10 Sep 2021 16:12:59 -0400 Message-Id: <20210910201305.32526-5-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290441248100001 Content-Type: text/plain; charset="utf-8" The type xsm_op_t masks the use of void pointers. This commit drops the xsm_op_t type and replaces it and all its uses with an explicit void. Signed-off-by: Daniel P. Smith Acked-by: Andrew Cooper --- xen/include/xen/hypercall.h | 4 ++-- xen/include/xsm/dummy.h | 4 ++-- xen/include/xsm/xsm.h | 11 ++++------- xen/xsm/flask/flask_op.c | 2 +- xen/xsm/flask/hooks.c | 4 ++-- xen/xsm/xsm_core.c | 4 ++-- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h index 34b7f1fed6..3771487a30 100644 --- a/xen/include/xen/hypercall.h +++ b/xen/include/xen/hypercall.h @@ -127,7 +127,7 @@ do_kexec_op( =20 extern long do_xsm_op( - XEN_GUEST_HANDLE_PARAM(xsm_op_t) u_xsm_op); + XEN_GUEST_HANDLE_PARAM(void) u_xsm_op); =20 #ifdef CONFIG_ARGO extern long do_argo_op( @@ -198,7 +198,7 @@ compat_set_timer_op( s32 hi); =20 extern int compat_xsm_op( - XEN_GUEST_HANDLE_PARAM(xsm_op_t) op); + XEN_GUEST_HANDLE_PARAM(void) op); =20 extern int compat_kexec_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) = uarg); =20 diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index 363c6d7798..214b5408b1 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -442,13 +442,13 @@ static XSM_INLINE int xsm_hypfs_op(XSM_DEFAULT_VOID) return xsm_default_action(action, current->domain, NULL); } =20 -static XSM_INLINE long xsm_do_xsm_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) op) +static XSM_INLINE long xsm_do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) { return -ENOSYS; } =20 #ifdef CONFIG_COMPAT -static XSM_INLINE int xsm_do_compat_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) op) +static XSM_INLINE int xsm_do_compat_op(XEN_GUEST_HANDLE_PARAM(void) op) { return -ENOSYS; } diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 335ba1b022..16b90be2c5 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -18,9 +18,6 @@ #include #include =20 -typedef void xsm_op_t; -DEFINE_XEN_GUEST_HANDLE(xsm_op_t); - /* policy magic number (defined by XSM_MAGIC) */ typedef u32 xsm_magic_t; =20 @@ -129,9 +126,9 @@ struct xsm_operations { int (*page_offline)(uint32_t cmd); int (*hypfs_op)(void); =20 - long (*do_xsm_op) (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op); + long (*do_xsm_op) (XEN_GUEST_HANDLE_PARAM(void) op); #ifdef CONFIG_COMPAT - int (*do_compat_op) (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op); + int (*do_compat_op) (XEN_GUEST_HANDLE_PARAM(void) op); #endif =20 int (*hvm_param) (struct domain *d, unsigned long op); @@ -542,13 +539,13 @@ static inline int xsm_hypfs_op(xsm_default_t def) return xsm_ops->hypfs_op(); } =20 -static inline long xsm_do_xsm_op (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op) +static inline long xsm_do_xsm_op (XEN_GUEST_HANDLE_PARAM(void) op) { return xsm_ops->do_xsm_op(op); } =20 #ifdef CONFIG_COMPAT -static inline int xsm_do_compat_op (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op) +static inline int xsm_do_compat_op (XEN_GUEST_HANDLE_PARAM(void) op) { return xsm_ops->do_compat_op(op); } diff --git a/xen/xsm/flask/flask_op.c b/xen/xsm/flask/flask_op.c index f41c025391..221ff00fd3 100644 --- a/xen/xsm/flask/flask_op.c +++ b/xen/xsm/flask/flask_op.c @@ -607,7 +607,7 @@ static int flask_relabel_domain(struct xen_flask_relabe= l *arg) =20 #endif /* !COMPAT */ =20 -ret_t do_flask_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) u_flask_op) +ret_t do_flask_op(XEN_GUEST_HANDLE_PARAM(void) u_flask_op) { xen_flask_op_t op; int rv; diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index f1a1217c98..1465db125a 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1742,8 +1742,8 @@ static int flask_argo_send(const struct domain *d, co= nst struct domain *t) =20 #endif =20 -long do_flask_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) u_flask_op); -int compat_flask_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) u_flask_op); +long do_flask_op(XEN_GUEST_HANDLE_PARAM(void) u_flask_op); +int compat_flask_op(XEN_GUEST_HANDLE_PARAM(void) u_flask_op); =20 static struct xsm_operations flask_ops =3D { .security_domaininfo =3D flask_security_domaininfo, diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 5eab21e1b1..ac553f9c0d 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -213,13 +213,13 @@ int __init register_xsm(struct xsm_operations *ops) =20 #endif =20 -long do_xsm_op (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op) +long do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) { return xsm_do_xsm_op(op); } =20 #ifdef CONFIG_COMPAT -int compat_xsm_op (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op) +int compat_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) { return xsm_do_compat_op(op); } --=20 2.20.1 From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290460; cv=pass; d=zohomail.com; s=zohoarc; b=DSCEUcO8NvZT0DfYdyeC63jCH1cBxYY0Iv0Cm94vzCW0rA8r1I2RxB6CoDNHb88jCRE+jsmpFmgVUYf/dta03fnn96kvIwRjLiiYyzENrSf+gkUu6NEmhhcEK1nsO2hJayOKIyjthBF5J4Fk+8PVBHIr073Ui8oNggGYRaUOFOQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290460; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SpoxjhcWcUqmXLou3DVlP7swX206Dz0qNxPdTVQSBNw=; b=aP1h3Bfc5vrHNRYufeMxwqfaKWfCAq/WWJDpDaZWQaCFMSx2MqcpjmPV+iDEyHBX1R9OUNdOry7cmUov/ZRHH75LJG/Yt6Cz101I5o+/P4MkJNDBiIbtHL/ZhFHxg4udDtqyVbwQEyVAwpCm41FpaH3k1Cc2mEe5Q+Q5MGVu/x8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631290460389935.8569938017304; Fri, 10 Sep 2021 09:14:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184604.333322 (Exim 4.92) (envelope-from ) id 1mOjAB-0000YX-L1; Fri, 10 Sep 2021 16:14:03 +0000 Received: by outflank-mailman (output) from mailman id 184604.333322; Fri, 10 Sep 2021 16:14:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOjAB-0000XU-Hf; Fri, 10 Sep 2021 16:14:03 +0000 Received: by outflank-mailman (input) for mailman id 184604; Fri, 10 Sep 2021 16:14:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOjAA-0000Vk-IU for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:14:02 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a1a144a5-645d-440a-8495-135b51333765; Fri, 10 Sep 2021 16:13:58 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1631290379745178.98198710030078; Fri, 10 Sep 2021 09:12:59 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a1a144a5-645d-440a-8495-135b51333765 ARC-Seal: i=1; a=rsa-sha256; t=1631290383; cv=none; d=zohomail.com; s=zohoarc; b=SN11h5uFKpvyekn+Li0+8REwK6MV5UXaW2uDEdjPDCY+wmRkSMTbFMun+rzCivad3R5udeHv1X+nUmFYvAf9I6sWIAKsPzXcD0ia57PBM2w3q/8AOMcya+URTnhU8uJP4BpAaHZKiPZSzrzkjiGa7daVci+Kdv9hUltT29hZ0zQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290383; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=SpoxjhcWcUqmXLou3DVlP7swX206Dz0qNxPdTVQSBNw=; b=LtwY4YEwwp15jjVbUcc+XaAp+LxhE0P/07tbIRWjNeniy0WneUHXaeBSwRSkajj0/4/VL9WhDmJJhWJbCP/L0xk3Mymh4k2tnCsGzjXfRmLkr6uRDl872BYLyn+i9kF+K39sXdK9FEjit6AuqWWS59xobzmu/lyEC1KV+/N3jxQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290383; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=SpoxjhcWcUqmXLou3DVlP7swX206Dz0qNxPdTVQSBNw=; b=h78uGQttDHiCCKGiH0BPm/c/TYijwKK680IXfZsCFQ0V93RNZ3DRpLGThecTYWuD OzoO8ktKHO7yWxYHH94a8ydq8BD5L7H+7VUbrYTzDElqYULQ5BPZhnHV3/CVRffgdQR EFY7+dYxV4WihMJvbO/49pSn64xPll0OyELpXGQQ= From: "Daniel P. Smith" To: "Daniel P. Smith" , xen-devel@lists.xenproject.org Cc: Daniel De Graaf Subject: [PATCH v6 05/10] xsm: apply coding style Date: Fri, 10 Sep 2021 16:13:00 -0400 Message-Id: <20210910201305.32526-6-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290462336100003 Content-Type: text/plain; charset="utf-8" Instead of intermixing coding style changes with code changes as they are come upon in this patch set, moving all coding style changes into a single commit. The focus of coding style changes here are, - move trailing comments to line above - ensuring line length does not exceed 80 chars - ensuring proper indentation for 80 char wrapping - covert u32 type statements to uint32_t - remove space between closing and opening parens - drop extern on function declarations Signed-off-by: Daniel P. Smith Acked-by: Jan Beulich --- xen/include/xsm/dummy.h | 190 +++++++++------ xen/include/xsm/xsm.h | 495 ++++++++++++++++++++++------------------ xen/xsm/xsm_core.c | 8 +- xen/xsm/xsm_policy.c | 7 +- 4 files changed, 396 insertions(+), 304 deletions(-) diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index 214b5408b1..3b1b378b58 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -19,7 +19,8 @@ #include #include =20 -/* Cannot use BUILD_BUG_ON here because the expressions we check are not +/* + * Cannot use BUILD_BUG_ON here because the expressions we check are not * considered constant at compile time. Instead, rely on constant propagat= ion to * inline out the calls to this invalid function, which will cause linker = errors * if references remain at link time. @@ -44,7 +45,8 @@ void __xsm_action_mismatch_detected(void); =20 #ifdef CONFIG_XSM =20 -/* In CONFIG_XSM builds, this header file is included from xsm/dummy.c, and +/* + * In CONFIG_XSM builds, this header file is included from xsm/dummy.c, and * contains static (not inline) functions compiled to the dummy XSM module. * There is no xsm_default_t argument available, so the value from the ass= ertion * is used to initialize the variable. @@ -57,7 +59,8 @@ void __xsm_action_mismatch_detected(void); =20 #else /* CONFIG_XSM */ =20 -/* In !CONFIG_XSM builds, this header file is included from xsm/xsm.h, and +/* + * In !CONFIG_XSM builds, this header file is included from xsm/xsm.h, and * contains inline functions for each XSM hook. These functions also perfo= rm * compile-time checks on the xsm_default_t argument to ensure that the be= havior * of the dummy XSM module is the same as the behavior with XSM disabled. @@ -98,13 +101,14 @@ static always_inline int xsm_default_action( } } =20 -static XSM_INLINE void xsm_security_domaininfo(struct domain *d, - struct xen_domctl_getdomaininfo *info) +static XSM_INLINE void xsm_security_domaininfo( + struct domain *d, struct xen_domctl_getdomaininfo *info) { return; } =20 -static XSM_INLINE int xsm_domain_create(XSM_DEFAULT_ARG struct domain *d, = u32 ssidref) +static XSM_INLINE int xsm_domain_create( + XSM_DEFAULT_ARG struct domain *d, uint32_t ssidref) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); @@ -116,7 +120,8 @@ static XSM_INLINE int xsm_getdomaininfo(XSM_DEFAULT_ARG= struct domain *d) return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_domctl_scheduler_op(XSM_DEFAULT_ARG struct domai= n *d, int cmd) +static XSM_INLINE int xsm_domctl_scheduler_op( + XSM_DEFAULT_ARG struct domain *d, int cmd) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); @@ -128,7 +133,8 @@ static XSM_INLINE int xsm_sysctl_scheduler_op(XSM_DEFAU= LT_ARG int cmd) return xsm_default_action(action, current->domain, NULL); } =20 -static XSM_INLINE int xsm_set_target(XSM_DEFAULT_ARG struct domain *d, str= uct domain *e) +static XSM_INLINE int xsm_set_target( + XSM_DEFAULT_ARG struct domain *d, struct domain *e) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, NULL); @@ -173,38 +179,43 @@ static XSM_INLINE void xsm_free_security_domain(struc= t domain *d) return; } =20 -static XSM_INLINE int xsm_grant_mapref(XSM_DEFAULT_ARG struct domain *d1, = struct domain *d2, - uint32_t f= lags) +static XSM_INLINE int xsm_grant_mapref( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2, uint32_t flags) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, d1, d2); } =20 -static XSM_INLINE int xsm_grant_unmapref(XSM_DEFAULT_ARG struct domain *d1= , struct domain *d2) +static XSM_INLINE int xsm_grant_unmapref( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, d1, d2); } =20 -static XSM_INLINE int xsm_grant_setup(XSM_DEFAULT_ARG struct domain *d1, s= truct domain *d2) +static XSM_INLINE int xsm_grant_setup( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d1, d2); } =20 -static XSM_INLINE int xsm_grant_transfer(XSM_DEFAULT_ARG struct domain *d1= , struct domain *d2) +static XSM_INLINE int xsm_grant_transfer( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, d1, d2); } =20 -static XSM_INLINE int xsm_grant_copy(XSM_DEFAULT_ARG struct domain *d1, st= ruct domain *d2) +static XSM_INLINE int xsm_grant_copy( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, d1, d2); } =20 -static XSM_INLINE int xsm_grant_query_size(XSM_DEFAULT_ARG struct domain *= d1, struct domain *d2) +static XSM_INLINE int xsm_grant_query_size( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d1, d2); @@ -216,14 +227,15 @@ static XSM_INLINE int xsm_memory_exchange(XSM_DEFAULT= _ARG struct domain *d) return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_memory_adjust_reservation(XSM_DEFAULT_ARG struct= domain *d1, - struct domain = *d2) +static XSM_INLINE int xsm_memory_adjust_reservation( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d1, d2); } =20 -static XSM_INLINE int xsm_memory_stat_reservation(XSM_DEFAULT_ARG struct d= omain *d1, struct domain *d2) +static XSM_INLINE int xsm_memory_stat_reservation( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d1, d2); @@ -253,14 +265,16 @@ static XSM_INLINE int xsm_kexec(XSM_DEFAULT_VOID) return xsm_default_action(action, current->domain, NULL); } =20 -static XSM_INLINE int xsm_schedop_shutdown(XSM_DEFAULT_ARG struct domain *= d1, struct domain *d2) +static XSM_INLINE int xsm_schedop_shutdown( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_DM_PRIV); return xsm_default_action(action, d1, d2); } =20 -static XSM_INLINE int xsm_memory_pin_page(XSM_DEFAULT_ARG struct domain *d= 1, struct domain *d2, - struct page_info *page) +static XSM_INLINE int xsm_memory_pin_page( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2, + struct page_info *page) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, d1, d2); @@ -272,15 +286,16 @@ static XSM_INLINE int xsm_claim_pages(XSM_DEFAULT_ARG= struct domain *d) return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_evtchn_unbound(XSM_DEFAULT_ARG struct domain *d,= struct evtchn *chn, - domid_t id2) +static XSM_INLINE int xsm_evtchn_unbound( + XSM_DEFAULT_ARG struct domain *d, struct evtchn *chn, domid_t id2) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_evtchn_interdomain(XSM_DEFAULT_ARG struct domain= *d1, struct evtchn - *chan1, struct domain *d2, struct evtchn *= chan2) +static XSM_INLINE int xsm_evtchn_interdomain( + XSM_DEFAULT_ARG struct domain *d1, struct evtchn *chan1, struct domain= *d2, + struct evtchn *chan2) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, d1, d2); @@ -291,19 +306,22 @@ static XSM_INLINE void xsm_evtchn_close_post(struct e= vtchn *chn) return; } =20 -static XSM_INLINE int xsm_evtchn_send(XSM_DEFAULT_ARG struct domain *d, st= ruct evtchn *chn) +static XSM_INLINE int xsm_evtchn_send( + XSM_DEFAULT_ARG struct domain *d, struct evtchn *chn) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, d, NULL); } =20 -static XSM_INLINE int xsm_evtchn_status(XSM_DEFAULT_ARG struct domain *d, = struct evtchn *chn) +static XSM_INLINE int xsm_evtchn_status( + XSM_DEFAULT_ARG struct domain *d, struct evtchn *chn) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_evtchn_reset(XSM_DEFAULT_ARG struct domain *d1, = struct domain *d2) +static XSM_INLINE int xsm_evtchn_reset( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d1, d2); @@ -321,7 +339,8 @@ static XSM_INLINE void xsm_free_security_evtchns( return; } =20 -static XSM_INLINE char *xsm_show_security_evtchn(struct domain *d, const s= truct evtchn *chn) +static XSM_INLINE char *xsm_show_security_evtchn( + struct domain *d, const struct evtchn *chn) { return NULL; } @@ -357,13 +376,15 @@ static XSM_INLINE int xsm_get_device_group(XSM_DEFAUL= T_ARG uint32_t machine_bdf) return xsm_default_action(action, current->domain, NULL); } =20 -static XSM_INLINE int xsm_assign_device(XSM_DEFAULT_ARG struct domain *d, = uint32_t machine_bdf) +static XSM_INLINE int xsm_assign_device( + XSM_DEFAULT_ARG struct domain *d, uint32_t machine_bdf) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_deassign_device(XSM_DEFAULT_ARG struct domain *d= , uint32_t machine_bdf) +static XSM_INLINE int xsm_deassign_device( + XSM_DEFAULT_ARG struct domain *d, uint32_t machine_bdf) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); @@ -372,15 +393,15 @@ static XSM_INLINE int xsm_deassign_device(XSM_DEFAULT= _ARG struct domain *d, uint #endif /* HAS_PASSTHROUGH && HAS_PCI */ =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) -static XSM_INLINE int xsm_assign_dtdevice(XSM_DEFAULT_ARG struct domain *d, - const char *dtpath) +static XSM_INLINE int xsm_assign_dtdevice( + XSM_DEFAULT_ARG struct domain *d, const char *dtpath) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_deassign_dtdevice(XSM_DEFAULT_ARG struct domain = *d, - const char *dtpath) +static XSM_INLINE int xsm_deassign_dtdevice( + XSM_DEFAULT_ARG struct domain *d, const char *dtpath) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); @@ -400,19 +421,22 @@ static XSM_INLINE int xsm_resource_unplug_core(XSM_DE= FAULT_VOID) return xsm_default_action(action, current->domain, NULL); } =20 -static XSM_INLINE int xsm_resource_plug_pci(XSM_DEFAULT_ARG uint32_t machi= ne_bdf) +static XSM_INLINE int xsm_resource_plug_pci( + XSM_DEFAULT_ARG uint32_t machine_bdf) { XSM_ASSERT_ACTION(XSM_PRIV); return xsm_default_action(action, current->domain, NULL); } =20 -static XSM_INLINE int xsm_resource_unplug_pci(XSM_DEFAULT_ARG uint32_t mac= hine_bdf) +static XSM_INLINE int xsm_resource_unplug_pci( + XSM_DEFAULT_ARG uint32_t machine_bdf) { XSM_ASSERT_ACTION(XSM_PRIV); return xsm_default_action(action, current->domain, NULL); } =20 -static XSM_INLINE int xsm_resource_setup_pci(XSM_DEFAULT_ARG uint32_t mach= ine_bdf) +static XSM_INLINE int xsm_resource_setup_pci( + XSM_DEFAULT_ARG uint32_t machine_bdf) { XSM_ASSERT_ACTION(XSM_PRIV); return xsm_default_action(action, current->domain, NULL); @@ -465,8 +489,8 @@ static XSM_INLINE int xsm_map_domain_pirq(XSM_DEFAULT_A= RG struct domain *d) return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_map_domain_irq(XSM_DEFAULT_ARG struct domain *d, - int irq, const void *data) +static XSM_INLINE int xsm_map_domain_irq( + XSM_DEFAULT_ARG struct domain *d, int irq, const void *data) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); @@ -478,76 +502,86 @@ static XSM_INLINE int xsm_unmap_domain_pirq(XSM_DEFAU= LT_ARG struct domain *d) return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_bind_pt_irq(XSM_DEFAULT_ARG struct domain *d, st= ruct xen_domctl_bind_pt_irq *bind) +static XSM_INLINE int xsm_bind_pt_irq( + XSM_DEFAULT_ARG struct domain *d, struct xen_domctl_bind_pt_irq *bind) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_unbind_pt_irq(XSM_DEFAULT_ARG struct domain *d, = struct xen_domctl_bind_pt_irq *bind) +static XSM_INLINE int xsm_unbind_pt_irq( + XSM_DEFAULT_ARG struct domain *d, struct xen_domctl_bind_pt_irq *bind) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_unmap_domain_irq(XSM_DEFAULT_ARG struct domain *= d, - int irq, const void *data) +static XSM_INLINE int xsm_unmap_domain_irq( + XSM_DEFAULT_ARG struct domain *d, int irq, const void *data) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_irq_permission(XSM_DEFAULT_ARG struct domain *d,= int pirq, uint8_t allow) +static XSM_INLINE int xsm_irq_permission( + XSM_DEFAULT_ARG struct domain *d, int pirq, uint8_t allow) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_iomem_permission(XSM_DEFAULT_ARG struct domain *= d, uint64_t s, uint64_t e, uint8_t allow) +static XSM_INLINE int xsm_iomem_permission( + XSM_DEFAULT_ARG struct domain *d, uint64_t s, uint64_t e, uint8_t allo= w) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_iomem_mapping(XSM_DEFAULT_ARG struct domain *d, = uint64_t s, uint64_t e, uint8_t allow) +static XSM_INLINE int xsm_iomem_mapping( + XSM_DEFAULT_ARG struct domain *d, uint64_t s, uint64_t e, uint8_t allo= w) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_pci_config_permission(XSM_DEFAULT_ARG struct dom= ain *d, uint32_t machine_bdf, - uint16_t start, uint16_t end, - uint8_t access) +static XSM_INLINE int xsm_pci_config_permission( + XSM_DEFAULT_ARG struct domain *d, uint32_t machine_bdf, uint16_t start, + uint16_t end, uint8_t access) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1= , struct domain *d2) +static XSM_INLINE int xsm_add_to_physmap( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d1, d2); } =20 -static XSM_INLINE int xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domai= n *d1, struct domain *d2) +static XSM_INLINE int xsm_remove_from_physmap( + XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d1, d2); } =20 -static XSM_INLINE int xsm_map_gmfn_foreign(XSM_DEFAULT_ARG struct domain *= d, struct domain *t) +static XSM_INLINE int xsm_map_gmfn_foreign( + XSM_DEFAULT_ARG struct domain *d, struct domain *t) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d, t); } =20 -static XSM_INLINE int xsm_hvm_param(XSM_DEFAULT_ARG struct domain *d, unsi= gned long op) +static XSM_INLINE int xsm_hvm_param( + XSM_DEFAULT_ARG struct domain *d, unsigned long op) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_hvm_control(XSM_DEFAULT_ARG struct domain *d, un= signed long op) +static XSM_INLINE int xsm_hvm_control( + XSM_DEFAULT_ARG struct domain *d, unsigned long op) { XSM_ASSERT_ACTION(XSM_DM_PRIV); return xsm_default_action(action, current->domain, d); @@ -559,7 +593,8 @@ static XSM_INLINE int xsm_hvm_param_altp2mhvm(XSM_DEFAU= LT_ARG struct domain *d) return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_hvm_altp2mhvm_op(XSM_DEFAULT_ARG struct domain *= d, uint64_t mode, uint32_t op) +static XSM_INLINE int xsm_hvm_altp2mhvm_op( + XSM_DEFAULT_ARG struct domain *d, uint64_t mode, uint32_t op) { XSM_ASSERT_ACTION(XSM_OTHER); =20 @@ -578,7 +613,8 @@ static XSM_INLINE int xsm_hvm_altp2mhvm_op(XSM_DEFAULT_= ARG struct domain *d, uin } } =20 -static XSM_INLINE int xsm_vm_event_control(XSM_DEFAULT_ARG struct domain *= d, int mode, int op) +static XSM_INLINE int xsm_vm_event_control( + XSM_DEFAULT_ARG struct domain *d, int mode, int op) { XSM_ASSERT_ACTION(XSM_PRIV); return xsm_default_action(action, current->domain, d); @@ -621,13 +657,15 @@ static XSM_INLINE int xsm_do_mca(XSM_DEFAULT_VOID) return xsm_default_action(action, current->domain, NULL); } =20 -static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d,= uint32_t op) +static XSM_INLINE int xsm_shadow_control( + XSM_DEFAULT_ARG struct domain *d, uint32_t op) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_mem_sharing_op(XSM_DEFAULT_ARG struct domain *d,= struct domain *cd, int op) +static XSM_INLINE int xsm_mem_sharing_op( + XSM_DEFAULT_ARG struct domain *d, struct domain *cd, int op) { XSM_ASSERT_ACTION(XSM_DM_PRIV); return xsm_default_action(action, current->domain, cd); @@ -651,8 +689,9 @@ static XSM_INLINE int xsm_domain_memory_map(XSM_DEFAULT= _ARG struct domain *d) return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_mmu_update(XSM_DEFAULT_ARG struct domain *d, str= uct domain *t, - struct domain *f, uint32_t flags) +static XSM_INLINE int xsm_mmu_update( + XSM_DEFAULT_ARG struct domain *d, struct domain *t, struct domain *f, + uint32_t flags) { int rc =3D 0; XSM_ASSERT_ACTION(XSM_TARGET); @@ -663,38 +702,43 @@ static XSM_INLINE int xsm_mmu_update(XSM_DEFAULT_ARG = struct domain *d, struct do return rc; } =20 -static XSM_INLINE int xsm_mmuext_op(XSM_DEFAULT_ARG struct domain *d, stru= ct domain *f) +static XSM_INLINE int xsm_mmuext_op( + XSM_DEFAULT_ARG struct domain *d, struct domain *f) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d, f); } =20 -static XSM_INLINE int xsm_update_va_mapping(XSM_DEFAULT_ARG struct domain = *d, struct domain *f,=20 - l1_pgentry_t p= te) +static XSM_INLINE int xsm_update_va_mapping( + XSM_DEFAULT_ARG struct domain *d, struct domain *f, l1_pgentry_t pte) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d, f); } =20 -static XSM_INLINE int xsm_priv_mapping(XSM_DEFAULT_ARG struct domain *d, s= truct domain *t) +static XSM_INLINE int xsm_priv_mapping( + XSM_DEFAULT_ARG struct domain *d, struct domain *t) { XSM_ASSERT_ACTION(XSM_TARGET); return xsm_default_action(action, d, t); } =20 -static XSM_INLINE int xsm_ioport_permission(XSM_DEFAULT_ARG struct domain = *d, uint32_t s, uint32_t e, uint8_t allow) +static XSM_INLINE int xsm_ioport_permission( + XSM_DEFAULT_ARG struct domain *d, uint32_t s, uint32_t e, uint8_t allo= w) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_ioport_mapping(XSM_DEFAULT_ARG struct domain *d,= uint32_t s, uint32_t e, uint8_t allow) +static XSM_INLINE int xsm_ioport_mapping( + XSM_DEFAULT_ARG struct domain *d, uint32_t s, uint32_t e, uint8_t allo= w) { XSM_ASSERT_ACTION(XSM_HOOK); return xsm_default_action(action, current->domain, d); } =20 -static XSM_INLINE int xsm_pmu_op (XSM_DEFAULT_ARG struct domain *d, unsign= ed int op) +static XSM_INLINE int xsm_pmu_op( + XSM_DEFAULT_ARG struct domain *d, unsigned int op) { XSM_ASSERT_ACTION(XSM_OTHER); switch ( op ) @@ -723,8 +767,8 @@ static XSM_INLINE int xsm_argo_enable(const struct doma= in *d) return 0; } =20 -static XSM_INLINE int xsm_argo_register_single_source(const struct domain = *d, - const struct domain = *t) +static XSM_INLINE int xsm_argo_register_single_source( + const struct domain *d, const struct domain *t) { return 0; } @@ -734,8 +778,8 @@ static XSM_INLINE int xsm_argo_register_any_source(cons= t struct domain *d) return 0; } =20 -static XSM_INLINE int xsm_argo_send(const struct domain *d, - const struct domain *t) +static XSM_INLINE int xsm_argo_send( + const struct domain *d, const struct domain *t) { return 0; } @@ -743,7 +787,7 @@ static XSM_INLINE int xsm_argo_send(const struct domain= *d, #endif /* CONFIG_ARGO */ =20 #include -static XSM_INLINE int xsm_xen_version (XSM_DEFAULT_ARG uint32_t op) +static XSM_INLINE int xsm_xen_version(XSM_DEFAULT_ARG uint32_t op) { XSM_ASSERT_ACTION(XSM_OTHER); switch ( op ) diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 16b90be2c5..7673d605a6 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -19,7 +19,7 @@ #include =20 /* policy magic number (defined by XSM_MAGIC) */ -typedef u32 xsm_magic_t; +typedef uint32_t xsm_magic_t; =20 #ifdef CONFIG_XSM_FLASK #define XSM_MAGIC 0xf97cff8c @@ -27,7 +27,8 @@ typedef u32 xsm_magic_t; #define XSM_MAGIC 0x0 #endif =20 -/* These annotations are used by callers and in dummy.h to document the +/* + * These annotations are used by callers and in dummy.h to document the * default actions of XSM hooks. They should be compiled out otherwise. */ enum xsm_default { @@ -41,147 +42,154 @@ enum xsm_default { typedef enum xsm_default xsm_default_t; =20 struct xsm_operations { - void (*security_domaininfo) (struct domain *d, - struct xen_domctl_getdomaininfo *i= nfo); - int (*domain_create) (struct domain *d, u32 ssidref); - int (*getdomaininfo) (struct domain *d); - int (*domctl_scheduler_op) (struct domain *d, int op); - int (*sysctl_scheduler_op) (int op); - int (*set_target) (struct domain *d, struct domain *e); - int (*domctl) (struct domain *d, int cmd); - int (*sysctl) (int cmd); - int (*readconsole) (uint32_t clear); - - int (*evtchn_unbound) (struct domain *d, struct evtchn *chn, domid_t i= d2); - int (*evtchn_interdomain) (struct domain *d1, struct evtchn *chn1, - struct domain *d2, struct evtchn *= chn2); - void (*evtchn_close_post) (struct evtchn *chn); - int (*evtchn_send) (struct domain *d, struct evtchn *chn); - int (*evtchn_status) (struct domain *d, struct evtchn *chn); - int (*evtchn_reset) (struct domain *d1, struct domain *d2); - - int (*grant_mapref) (struct domain *d1, struct domain *d2, uint32_t fl= ags); - int (*grant_unmapref) (struct domain *d1, struct domain *d2); - int (*grant_setup) (struct domain *d1, struct domain *d2); - int (*grant_transfer) (struct domain *d1, struct domain *d2); - int (*grant_copy) (struct domain *d1, struct domain *d2); - int (*grant_query_size) (struct domain *d1, struct domain *d2); - - int (*alloc_security_domain) (struct domain *d); - void (*free_security_domain) (struct domain *d); - int (*alloc_security_evtchns) (struct evtchn chn[], unsigned int nr); - void (*free_security_evtchns) (struct evtchn chn[], unsigned int nr); - char *(*show_security_evtchn) (struct domain *d, const struct evtchn *= chn); - int (*init_hardware_domain) (struct domain *d); - - int (*get_pod_target) (struct domain *d); - int (*set_pod_target) (struct domain *d); - int (*memory_exchange) (struct domain *d); - int (*memory_adjust_reservation) (struct domain *d1, struct domain *d2= ); - int (*memory_stat_reservation) (struct domain *d1, struct domain *d2); - int (*memory_pin_page) (struct domain *d1, struct domain *d2, struct p= age_info *page); - int (*add_to_physmap) (struct domain *d1, struct domain *d2); - int (*remove_from_physmap) (struct domain *d1, struct domain *d2); - int (*map_gmfn_foreign) (struct domain *d, struct domain *t); - int (*claim_pages) (struct domain *d); - - int (*console_io) (struct domain *d, int cmd); - - int (*profile) (struct domain *d, int op); - - int (*kexec) (void); - int (*schedop_shutdown) (struct domain *d1, struct domain *d2); - - char *(*show_irq_sid) (int irq); - int (*map_domain_pirq) (struct domain *d); - int (*map_domain_irq) (struct domain *d, int irq, const void *data); - int (*unmap_domain_pirq) (struct domain *d); - int (*unmap_domain_irq) (struct domain *d, int irq, const void *data); - int (*bind_pt_irq) (struct domain *d, struct xen_domctl_bind_pt_irq *b= ind); - int (*unbind_pt_irq) (struct domain *d, struct xen_domctl_bind_pt_irq = *bind); - int (*irq_permission) (struct domain *d, int pirq, uint8_t allow); - int (*iomem_permission) (struct domain *d, uint64_t s, uint64_t e, uin= t8_t allow); - int (*iomem_mapping) (struct domain *d, uint64_t s, uint64_t e, uint8_= t allow); - int (*pci_config_permission) (struct domain *d, uint32_t machine_bdf, = uint16_t start, uint16_t end, uint8_t access); + void (*security_domaininfo)(struct domain *d, + struct xen_domctl_getdomaininfo *info); + int (*domain_create)(struct domain *d, uint32_t ssidref); + int (*getdomaininfo)(struct domain *d); + int (*domctl_scheduler_op)(struct domain *d, int op); + int (*sysctl_scheduler_op)(int op); + int (*set_target)(struct domain *d, struct domain *e); + int (*domctl)(struct domain *d, int cmd); + int (*sysctl)(int cmd); + int (*readconsole)(uint32_t clear); + + int (*evtchn_unbound)(struct domain *d, struct evtchn *chn, domid_t id= 2); + int (*evtchn_interdomain)(struct domain *d1, struct evtchn *chn1, + struct domain *d2, struct evtchn *chn2); + void (*evtchn_close_post)(struct evtchn *chn); + int (*evtchn_send)(struct domain *d, struct evtchn *chn); + int (*evtchn_status)(struct domain *d, struct evtchn *chn); + int (*evtchn_reset)(struct domain *d1, struct domain *d2); + + int (*grant_mapref)(struct domain *d1, struct domain *d2, uint32_t fla= gs); + int (*grant_unmapref)(struct domain *d1, struct domain *d2); + int (*grant_setup)(struct domain *d1, struct domain *d2); + int (*grant_transfer)(struct domain *d1, struct domain *d2); + int (*grant_copy)(struct domain *d1, struct domain *d2); + int (*grant_query_size)(struct domain *d1, struct domain *d2); + + int (*alloc_security_domain)(struct domain *d); + void (*free_security_domain)(struct domain *d); + int (*alloc_security_evtchns)(struct evtchn chn[], unsigned int nr); + void (*free_security_evtchns)(struct evtchn chn[], unsigned int nr); + char *(*show_security_evtchn)(struct domain *d, const struct evtchn *c= hn); + int (*init_hardware_domain)(struct domain *d); + + int (*get_pod_target)(struct domain *d); + int (*set_pod_target)(struct domain *d); + int (*memory_exchange)(struct domain *d); + int (*memory_adjust_reservation)(struct domain *d1, struct domain *d2); + int (*memory_stat_reservation)(struct domain *d1, struct domain *d2); + int (*memory_pin_page)(struct domain *d1, struct domain *d2, + struct page_info *page); + int (*add_to_physmap)(struct domain *d1, struct domain *d2); + int (*remove_from_physmap)(struct domain *d1, struct domain *d2); + int (*map_gmfn_foreign)(struct domain *d, struct domain *t); + int (*claim_pages)(struct domain *d); + + int (*console_io)(struct domain *d, int cmd); + + int (*profile)(struct domain *d, int op); + + int (*kexec)(void); + int (*schedop_shutdown)(struct domain *d1, struct domain *d2); + + char *(*show_irq_sid)(int irq); + int (*map_domain_pirq)(struct domain *d); + int (*map_domain_irq)(struct domain *d, int irq, const void *data); + int (*unmap_domain_pirq)(struct domain *d); + int (*unmap_domain_irq)(struct domain *d, int irq, const void *data); + int (*bind_pt_irq)(struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd); + int (*unbind_pt_irq)(struct domain *d, struct xen_domctl_bind_pt_irq *= bind); + int (*irq_permission)(struct domain *d, int pirq, uint8_t allow); + int (*iomem_permission)(struct domain *d, uint64_t s, uint64_t e, + uint8_t allow); + int (*iomem_mapping)(struct domain *d, uint64_t s, uint64_t e, + uint8_t allow); + int (*pci_config_permission)(struct domain *d, uint32_t machine_bdf, + uint16_t start, uint16_t end, uint8_t acc= ess); =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) - int (*get_device_group) (uint32_t machine_bdf); - int (*assign_device) (struct domain *d, uint32_t machine_bdf); - int (*deassign_device) (struct domain *d, uint32_t machine_bdf); + int (*get_device_group)(uint32_t machine_bdf); + int (*assign_device)(struct domain *d, uint32_t machine_bdf); + int (*deassign_device)(struct domain *d, uint32_t machine_bdf); #endif =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) - int (*assign_dtdevice) (struct domain *d, const char *dtpath); - int (*deassign_dtdevice) (struct domain *d, const char *dtpath); + int (*assign_dtdevice)(struct domain *d, const char *dtpath); + int (*deassign_dtdevice)(struct domain *d, const char *dtpath); #endif =20 - int (*resource_plug_core) (void); - int (*resource_unplug_core) (void); - int (*resource_plug_pci) (uint32_t machine_bdf); - int (*resource_unplug_pci) (uint32_t machine_bdf); - int (*resource_setup_pci) (uint32_t machine_bdf); - int (*resource_setup_gsi) (int gsi); - int (*resource_setup_misc) (void); + int (*resource_plug_core)(void); + int (*resource_unplug_core)(void); + int (*resource_plug_pci)(uint32_t machine_bdf); + int (*resource_unplug_pci)(uint32_t machine_bdf); + int (*resource_setup_pci)(uint32_t machine_bdf); + int (*resource_setup_gsi)(int gsi); + int (*resource_setup_misc)(void); =20 int (*page_offline)(uint32_t cmd); int (*hypfs_op)(void); =20 - long (*do_xsm_op) (XEN_GUEST_HANDLE_PARAM(void) op); + long (*do_xsm_op)(XEN_GUEST_HANDLE_PARAM(void) op); #ifdef CONFIG_COMPAT - int (*do_compat_op) (XEN_GUEST_HANDLE_PARAM(void) op); + int (*do_compat_op)(XEN_GUEST_HANDLE_PARAM(void) op); #endif =20 - int (*hvm_param) (struct domain *d, unsigned long op); - int (*hvm_control) (struct domain *d, unsigned long op); - int (*hvm_param_altp2mhvm) (struct domain *d); - int (*hvm_altp2mhvm_op) (struct domain *d, uint64_t mode, uint32_t op); - int (*get_vnumainfo) (struct domain *d); + int (*hvm_param)(struct domain *d, unsigned long op); + int (*hvm_control)(struct domain *d, unsigned long op); + int (*hvm_param_altp2mhvm)(struct domain *d); + int (*hvm_altp2mhvm_op)(struct domain *d, uint64_t mode, uint32_t op); + int (*get_vnumainfo)(struct domain *d); =20 - int (*vm_event_control) (struct domain *d, int mode, int op); + int (*vm_event_control)(struct domain *d, int mode, int op); =20 #ifdef CONFIG_MEM_ACCESS - int (*mem_access) (struct domain *d); + int (*mem_access)(struct domain *d); #endif =20 #ifdef CONFIG_MEM_PAGING - int (*mem_paging) (struct domain *d); + int (*mem_paging)(struct domain *d); #endif =20 #ifdef CONFIG_MEM_SHARING - int (*mem_sharing) (struct domain *d); + int (*mem_sharing)(struct domain *d); #endif =20 - int (*platform_op) (uint32_t cmd); + int (*platform_op)(uint32_t cmd); =20 #ifdef CONFIG_X86 - int (*do_mca) (void); - int (*shadow_control) (struct domain *d, uint32_t op); - int (*mem_sharing_op) (struct domain *d, struct domain *cd, int op); - int (*apic) (struct domain *d, int cmd); - int (*machine_memory_map) (void); - int (*domain_memory_map) (struct domain *d); + int (*do_mca)(void); + int (*shadow_control)(struct domain *d, uint32_t op); + int (*mem_sharing_op)(struct domain *d, struct domain *cd, int op); + int (*apic)(struct domain *d, int cmd); + int (*machine_memory_map)(void); + int (*domain_memory_map)(struct domain *d); #define XSM_MMU_UPDATE_READ 1 #define XSM_MMU_UPDATE_WRITE 2 #define XSM_MMU_NORMAL_UPDATE 4 #define XSM_MMU_MACHPHYS_UPDATE 8 - int (*mmu_update) (struct domain *d, struct domain *t, - struct domain *f, uint32_t flags); - int (*mmuext_op) (struct domain *d, struct domain *f); - int (*update_va_mapping) (struct domain *d, struct domain *f, l1_pgent= ry_t pte); - int (*priv_mapping) (struct domain *d, struct domain *t); - int (*ioport_permission) (struct domain *d, uint32_t s, uint32_t e, ui= nt8_t allow); - int (*ioport_mapping) (struct domain *d, uint32_t s, uint32_t e, uint8= _t allow); - int (*pmu_op) (struct domain *d, unsigned int op); + int (*mmu_update)(struct domain *d, struct domain *t, + struct domain *f, uint32_t flags); + int (*mmuext_op)(struct domain *d, struct domain *f); + int (*update_va_mapping)(struct domain *d, struct domain *f, + l1_pgentry_t pte); + int (*priv_mapping)(struct domain *d, struct domain *t); + int (*ioport_permission)(struct domain *d, uint32_t s, uint32_t e, + uint8_t allow); + int (*ioport_mapping)(struct domain *d, uint32_t s, uint32_t e, + uint8_t allow); + int (*pmu_op)(struct domain *d, unsigned int op); #endif - int (*dm_op) (struct domain *d); - int (*xen_version) (uint32_t cmd); - int (*domain_resource_map) (struct domain *d); + int (*dm_op)(struct domain *d); + int (*xen_version)(uint32_t cmd); + int (*domain_resource_map)(struct domain *d); #ifdef CONFIG_ARGO - int (*argo_enable) (const struct domain *d); - int (*argo_register_single_source) (const struct domain *d, - const struct domain *t); - int (*argo_register_any_source) (const struct domain *d); - int (*argo_send) (const struct domain *d, const struct domain *t); + int (*argo_enable)(const struct domain *d); + int (*argo_register_single_source)(const struct domain *d, + const struct domain *t); + int (*argo_register_any_source)(const struct domain *d); + int (*argo_send)(const struct domain *d, const struct domain *t); #endif }; =20 @@ -191,121 +199,133 @@ extern struct xsm_operations *xsm_ops; =20 #ifndef XSM_NO_WRAPPERS =20 -static inline void xsm_security_domaininfo (struct domain *d, - struct xen_domctl_getdomaininfo *i= nfo) +static inline void xsm_security_domaininfo( + struct domain *d, struct xen_domctl_getdomaininfo *info) { xsm_ops->security_domaininfo(d, info); } =20 -static inline int xsm_domain_create (xsm_default_t def, struct domain *d, = u32 ssidref) +static inline int xsm_domain_create( + xsm_default_t def, struct domain *d, uint32_t ssidref) { return xsm_ops->domain_create(d, ssidref); } =20 -static inline int xsm_getdomaininfo (xsm_default_t def, struct domain *d) +static inline int xsm_getdomaininfo(xsm_default_t def, struct domain *d) { return xsm_ops->getdomaininfo(d); } =20 -static inline int xsm_domctl_scheduler_op (xsm_default_t def, struct domai= n *d, int cmd) +static inline int xsm_domctl_scheduler_op( + xsm_default_t def, struct domain *d, int cmd) { return xsm_ops->domctl_scheduler_op(d, cmd); } =20 -static inline int xsm_sysctl_scheduler_op (xsm_default_t def, int cmd) +static inline int xsm_sysctl_scheduler_op(xsm_default_t def, int cmd) { return xsm_ops->sysctl_scheduler_op(cmd); } =20 -static inline int xsm_set_target (xsm_default_t def, struct domain *d, str= uct domain *e) +static inline int xsm_set_target( + xsm_default_t def, struct domain *d, struct domain *e) { return xsm_ops->set_target(d, e); } =20 -static inline int xsm_domctl (xsm_default_t def, struct domain *d, int cmd) +static inline int xsm_domctl(xsm_default_t def, struct domain *d, int cmd) { return xsm_ops->domctl(d, cmd); } =20 -static inline int xsm_sysctl (xsm_default_t def, int cmd) +static inline int xsm_sysctl(xsm_default_t def, int cmd) { return xsm_ops->sysctl(cmd); } =20 -static inline int xsm_readconsole (xsm_default_t def, uint32_t clear) +static inline int xsm_readconsole(xsm_default_t def, uint32_t clear) { return xsm_ops->readconsole(clear); } =20 -static inline int xsm_evtchn_unbound (xsm_default_t def, struct domain *d1= , struct evtchn *chn, - domid_= t id2) +static inline int xsm_evtchn_unbound( + xsm_default_t def, struct domain *d1, struct evtchn *chn, domid_t id2) { return xsm_ops->evtchn_unbound(d1, chn, id2); } =20 -static inline int xsm_evtchn_interdomain (xsm_default_t def, struct domain= *d1, - struct evtchn *chan1, struct domain *d2, struct evtchn *ch= an2) +static inline int xsm_evtchn_interdomain( + xsm_default_t def, struct domain *d1, struct evtchn *chan1, + struct domain *d2, struct evtchn *chan2) { return xsm_ops->evtchn_interdomain(d1, chan1, d2, chan2); } =20 -static inline void xsm_evtchn_close_post (struct evtchn *chn) +static inline void xsm_evtchn_close_post(struct evtchn *chn) { xsm_ops->evtchn_close_post(chn); } =20 -static inline int xsm_evtchn_send (xsm_default_t def, struct domain *d, st= ruct evtchn *chn) +static inline int xsm_evtchn_send( + xsm_default_t def, struct domain *d, struct evtchn *chn) { return xsm_ops->evtchn_send(d, chn); } =20 -static inline int xsm_evtchn_status (xsm_default_t def, struct domain *d, = struct evtchn *chn) +static inline int xsm_evtchn_status( + xsm_default_t def, struct domain *d, struct evtchn *chn) { return xsm_ops->evtchn_status(d, chn); } =20 -static inline int xsm_evtchn_reset (xsm_default_t def, struct domain *d1, = struct domain *d2) +static inline int xsm_evtchn_reset( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->evtchn_reset(d1, d2); } =20 -static inline int xsm_grant_mapref (xsm_default_t def, struct domain *d1, = struct domain *d2, - uint32_t f= lags) +static inline int xsm_grant_mapref( + xsm_default_t def, struct domain *d1, struct domain *d2, uint32_t flag= s) { return xsm_ops->grant_mapref(d1, d2, flags); } =20 -static inline int xsm_grant_unmapref (xsm_default_t def, struct domain *d1= , struct domain *d2) +static inline int xsm_grant_unmapref( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->grant_unmapref(d1, d2); } =20 -static inline int xsm_grant_setup (xsm_default_t def, struct domain *d1, s= truct domain *d2) +static inline int xsm_grant_setup( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->grant_setup(d1, d2); } =20 -static inline int xsm_grant_transfer (xsm_default_t def, struct domain *d1= , struct domain *d2) +static inline int xsm_grant_transfer( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->grant_transfer(d1, d2); } =20 -static inline int xsm_grant_copy (xsm_default_t def, struct domain *d1, st= ruct domain *d2) +static inline int xsm_grant_copy( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->grant_copy(d1, d2); } =20 -static inline int xsm_grant_query_size (xsm_default_t def, struct domain *= d1, struct domain *d2) +static inline int xsm_grant_query_size( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->grant_query_size(d1, d2); } =20 -static inline int xsm_alloc_security_domain (struct domain *d) +static inline int xsm_alloc_security_domain(struct domain *d) { return xsm_ops->alloc_security_domain(d); } =20 -static inline void xsm_free_security_domain (struct domain *d) +static inline void xsm_free_security_domain(struct domain *d) { xsm_ops->free_security_domain(d); } @@ -322,60 +342,65 @@ static inline void xsm_free_security_evtchns( xsm_ops->free_security_evtchns(chn, nr); } =20 -static inline char *xsm_show_security_evtchn (struct domain *d, const stru= ct evtchn *chn) +static inline char *xsm_show_security_evtchn( + struct domain *d, const struct evtchn *chn) { return xsm_ops->show_security_evtchn(d, chn); } =20 -static inline int xsm_init_hardware_domain (xsm_default_t def, struct doma= in *d) +static inline int xsm_init_hardware_domain(xsm_default_t def, struct domai= n *d) { return xsm_ops->init_hardware_domain(d); } =20 -static inline int xsm_get_pod_target (xsm_default_t def, struct domain *d) +static inline int xsm_get_pod_target(xsm_default_t def, struct domain *d) { return xsm_ops->get_pod_target(d); } =20 -static inline int xsm_set_pod_target (xsm_default_t def, struct domain *d) +static inline int xsm_set_pod_target(xsm_default_t def, struct domain *d) { return xsm_ops->set_pod_target(d); } =20 -static inline int xsm_memory_exchange (xsm_default_t def, struct domain *d) +static inline int xsm_memory_exchange(xsm_default_t def, struct domain *d) { return xsm_ops->memory_exchange(d); } =20 -static inline int xsm_memory_adjust_reservation (xsm_default_t def, struct= domain *d1, struct - domain= *d2) +static inline int xsm_memory_adjust_reservation( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->memory_adjust_reservation(d1, d2); } =20 -static inline int xsm_memory_stat_reservation (xsm_default_t def, struct d= omain *d1, - struct domain = *d2) +static inline int xsm_memory_stat_reservation( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->memory_stat_reservation(d1, d2); } =20 -static inline int xsm_memory_pin_page(xsm_default_t def, struct domain *d1= , struct domain *d2, - struct page_info *page) +static inline int xsm_memory_pin_page( + xsm_default_t def, struct domain *d1, struct domain *d2, + struct page_info *page) { return xsm_ops->memory_pin_page(d1, d2, page); } =20 -static inline int xsm_add_to_physmap(xsm_default_t def, struct domain *d1,= struct domain *d2) +static inline int xsm_add_to_physmap( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->add_to_physmap(d1, d2); } =20 -static inline int xsm_remove_from_physmap(xsm_default_t def, struct domain= *d1, struct domain *d2) +static inline int xsm_remove_from_physmap( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->remove_from_physmap(d1, d2); } =20 -static inline int xsm_map_gmfn_foreign (xsm_default_t def, struct domain *= d, struct domain *t) +static inline int xsm_map_gmfn_foreign( + xsm_default_t def, struct domain *d, struct domain *t) { return xsm_ops->map_gmfn_foreign(d, t); } @@ -385,79 +410,87 @@ static inline int xsm_claim_pages(xsm_default_t def, = struct domain *d) return xsm_ops->claim_pages(d); } =20 -static inline int xsm_console_io (xsm_default_t def, struct domain *d, int= cmd) +static inline int xsm_console_io(xsm_default_t def, struct domain *d, int = cmd) { return xsm_ops->console_io(d, cmd); } =20 -static inline int xsm_profile (xsm_default_t def, struct domain *d, int op) +static inline int xsm_profile(xsm_default_t def, struct domain *d, int op) { return xsm_ops->profile(d, op); } =20 -static inline int xsm_kexec (xsm_default_t def) +static inline int xsm_kexec(xsm_default_t def) { return xsm_ops->kexec(); } =20 -static inline int xsm_schedop_shutdown (xsm_default_t def, struct domain *= d1, struct domain *d2) +static inline int xsm_schedop_shutdown( + xsm_default_t def, struct domain *d1, struct domain *d2) { return xsm_ops->schedop_shutdown(d1, d2); } =20 -static inline char *xsm_show_irq_sid (int irq) +static inline char *xsm_show_irq_sid(int irq) { return xsm_ops->show_irq_sid(irq); } =20 -static inline int xsm_map_domain_pirq (xsm_default_t def, struct domain *d) +static inline int xsm_map_domain_pirq(xsm_default_t def, struct domain *d) { return xsm_ops->map_domain_pirq(d); } =20 -static inline int xsm_map_domain_irq (xsm_default_t def, struct domain *d,= int irq, void *data) +static inline int xsm_map_domain_irq( + xsm_default_t def, struct domain *d, int irq, void *data) { return xsm_ops->map_domain_irq(d, irq, data); } =20 -static inline int xsm_unmap_domain_pirq (xsm_default_t def, struct domain = *d) +static inline int xsm_unmap_domain_pirq(xsm_default_t def, struct domain *= d) { return xsm_ops->unmap_domain_pirq(d); } =20 -static inline int xsm_unmap_domain_irq (xsm_default_t def, struct domain *= d, int irq, void *data) +static inline int xsm_unmap_domain_irq( + xsm_default_t def, struct domain *d, int irq, void *data) { return xsm_ops->unmap_domain_irq(d, irq, data); } =20 -static inline int xsm_bind_pt_irq(xsm_default_t def, struct domain *d, - struct xen_domctl_bind_pt_irq *bind) +static inline int xsm_bind_pt_irq( + xsm_default_t def, struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd) { return xsm_ops->bind_pt_irq(d, bind); } =20 -static inline int xsm_unbind_pt_irq(xsm_default_t def, struct domain *d, - struct xen_domctl_bind_pt_irq *bind) +static inline int xsm_unbind_pt_irq( + xsm_default_t def, struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd) { return xsm_ops->unbind_pt_irq(d, bind); } =20 -static inline int xsm_irq_permission (xsm_default_t def, struct domain *d,= int pirq, uint8_t allow) +static inline int xsm_irq_permission( + xsm_default_t def, struct domain *d, int pirq, uint8_t allow) { return xsm_ops->irq_permission(d, pirq, allow); } =20 -static inline int xsm_iomem_permission (xsm_default_t def, struct domain *= d, uint64_t s, uint64_t e, uint8_t allow) +static inline int xsm_iomem_permission( + xsm_default_t def, struct domain *d, uint64_t s, uint64_t e, uint8_t a= llow) { return xsm_ops->iomem_permission(d, s, e, allow); } =20 -static inline int xsm_iomem_mapping (xsm_default_t def, struct domain *d, = uint64_t s, uint64_t e, uint8_t allow) +static inline int xsm_iomem_mapping( + xsm_default_t def, struct domain *d, uint64_t s, uint64_t e, uint8_t a= llow) { return xsm_ops->iomem_mapping(d, s, e, allow); } =20 -static inline int xsm_pci_config_permission (xsm_default_t def, struct dom= ain *d, uint32_t machine_bdf, uint16_t start, uint16_t end, uint8_t access) +static inline int xsm_pci_config_permission( + xsm_default_t def, struct domain *d, uint32_t machine_bdf, uint16_t st= art, + uint16_t end, uint8_t access) { return xsm_ops->pci_config_permission(d, machine_bdf, start, end, acce= ss); } @@ -468,63 +501,67 @@ static inline int xsm_get_device_group(xsm_default_t = def, uint32_t machine_bdf) return xsm_ops->get_device_group(machine_bdf); } =20 -static inline int xsm_assign_device(xsm_default_t def, struct domain *d, u= int32_t machine_bdf) +static inline int xsm_assign_device( + xsm_default_t def, struct domain *d, uint32_t machine_bdf) { return xsm_ops->assign_device(d, machine_bdf); } =20 -static inline int xsm_deassign_device(xsm_default_t def, struct domain *d,= uint32_t machine_bdf) +static inline int xsm_deassign_device( + xsm_default_t def, struct domain *d, uint32_t machine_bdf) { return xsm_ops->deassign_device(d, machine_bdf); } #endif /* HAS_PASSTHROUGH && HAS_PCI) */ =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) -static inline int xsm_assign_dtdevice(xsm_default_t def, struct domain *d, - const char *dtpath) +static inline int xsm_assign_dtdevice( + xsm_default_t def, struct domain *d, const char *dtpath) { return xsm_ops->assign_dtdevice(d, dtpath); } =20 -static inline int xsm_deassign_dtdevice(xsm_default_t def, struct domain *= d, - const char *dtpath) +static inline int xsm_deassign_dtdevice( + xsm_default_t def, struct domain *d, const char *dtpath) { return xsm_ops->deassign_dtdevice(d, dtpath); } =20 #endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ =20 -static inline int xsm_resource_plug_pci (xsm_default_t def, uint32_t machi= ne_bdf) +static inline int xsm_resource_plug_pci(xsm_default_t def, uint32_t machin= e_bdf) { return xsm_ops->resource_plug_pci(machine_bdf); } =20 -static inline int xsm_resource_unplug_pci (xsm_default_t def, uint32_t mac= hine_bdf) +static inline int xsm_resource_unplug_pci( + xsm_default_t def, uint32_t machine_bdf) { return xsm_ops->resource_unplug_pci(machine_bdf); } =20 -static inline int xsm_resource_plug_core (xsm_default_t def) +static inline int xsm_resource_plug_core(xsm_default_t def) { return xsm_ops->resource_plug_core(); } =20 -static inline int xsm_resource_unplug_core (xsm_default_t def) +static inline int xsm_resource_unplug_core(xsm_default_t def) { return xsm_ops->resource_unplug_core(); } =20 -static inline int xsm_resource_setup_pci (xsm_default_t def, uint32_t mach= ine_bdf) +static inline int xsm_resource_setup_pci( + xsm_default_t def, uint32_t machine_bdf) { return xsm_ops->resource_setup_pci(machine_bdf); } =20 -static inline int xsm_resource_setup_gsi (xsm_default_t def, int gsi) +static inline int xsm_resource_setup_gsi(xsm_default_t def, int gsi) { return xsm_ops->resource_setup_gsi(gsi); } =20 -static inline int xsm_resource_setup_misc (xsm_default_t def) +static inline int xsm_resource_setup_misc(xsm_default_t def) { return xsm_ops->resource_setup_misc(); } @@ -539,70 +576,74 @@ static inline int xsm_hypfs_op(xsm_default_t def) return xsm_ops->hypfs_op(); } =20 -static inline long xsm_do_xsm_op (XEN_GUEST_HANDLE_PARAM(void) op) +static inline long xsm_do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) { return xsm_ops->do_xsm_op(op); } =20 #ifdef CONFIG_COMPAT -static inline int xsm_do_compat_op (XEN_GUEST_HANDLE_PARAM(void) op) +static inline int xsm_do_compat_op(XEN_GUEST_HANDLE_PARAM(void) op) { return xsm_ops->do_compat_op(op); } #endif =20 -static inline int xsm_hvm_param (xsm_default_t def, struct domain *d, unsi= gned long op) +static inline int xsm_hvm_param( + xsm_default_t def, struct domain *d, unsigned long op) { return xsm_ops->hvm_param(d, op); } =20 -static inline int xsm_hvm_control(xsm_default_t def, struct domain *d, uns= igned long op) +static inline int xsm_hvm_control( + xsm_default_t def, struct domain *d, unsigned long op) { return xsm_ops->hvm_control(d, op); } =20 -static inline int xsm_hvm_param_altp2mhvm (xsm_default_t def, struct domai= n *d) +static inline int xsm_hvm_param_altp2mhvm(xsm_default_t def, struct domain= *d) { return xsm_ops->hvm_param_altp2mhvm(d); } =20 -static inline int xsm_hvm_altp2mhvm_op (xsm_default_t def, struct domain *= d, uint64_t mode, uint32_t op) +static inline int xsm_hvm_altp2mhvm_op( + xsm_default_t def, struct domain *d, uint64_t mode, uint32_t op) { return xsm_ops->hvm_altp2mhvm_op(d, mode, op); } =20 -static inline int xsm_get_vnumainfo (xsm_default_t def, struct domain *d) +static inline int xsm_get_vnumainfo(xsm_default_t def, struct domain *d) { return xsm_ops->get_vnumainfo(d); } =20 -static inline int xsm_vm_event_control (xsm_default_t def, struct domain *= d, int mode, int op) +static inline int xsm_vm_event_control( + xsm_default_t def, struct domain *d, int mode, int op) { return xsm_ops->vm_event_control(d, mode, op); } =20 #ifdef CONFIG_MEM_ACCESS -static inline int xsm_mem_access (xsm_default_t def, struct domain *d) +static inline int xsm_mem_access(xsm_default_t def, struct domain *d) { return xsm_ops->mem_access(d); } #endif =20 #ifdef CONFIG_MEM_PAGING -static inline int xsm_mem_paging (xsm_default_t def, struct domain *d) +static inline int xsm_mem_paging(xsm_default_t def, struct domain *d) { return xsm_ops->mem_paging(d); } #endif =20 #ifdef CONFIG_MEM_SHARING -static inline int xsm_mem_sharing (xsm_default_t def, struct domain *d) +static inline int xsm_mem_sharing(xsm_default_t def, struct domain *d) { return xsm_ops->mem_sharing(d); } #endif =20 -static inline int xsm_platform_op (xsm_default_t def, uint32_t op) +static inline int xsm_platform_op(xsm_default_t def, uint32_t op) { return xsm_ops->platform_op(op); } @@ -613,17 +654,19 @@ static inline int xsm_do_mca(xsm_default_t def) return xsm_ops->do_mca(); } =20 -static inline int xsm_shadow_control (xsm_default_t def, struct domain *d,= uint32_t op) +static inline int xsm_shadow_control( + xsm_default_t def, struct domain *d, uint32_t op) { return xsm_ops->shadow_control(d, op); } =20 -static inline int xsm_mem_sharing_op (xsm_default_t def, struct domain *d,= struct domain *cd, int op) +static inline int xsm_mem_sharing_op( + xsm_default_t def, struct domain *d, struct domain *cd, int op) { return xsm_ops->mem_sharing_op(d, cd, op); } =20 -static inline int xsm_apic (xsm_default_t def, struct domain *d, int cmd) +static inline int xsm_apic(xsm_default_t def, struct domain *d, int cmd) { return xsm_ops->apic(d, cmd); } @@ -638,39 +681,45 @@ static inline int xsm_domain_memory_map(xsm_default_t= def, struct domain *d) return xsm_ops->domain_memory_map(d); } =20 -static inline int xsm_mmu_update (xsm_default_t def, struct domain *d, str= uct domain *t, - struct domain *f, uint32_t flags) +static inline int xsm_mmu_update( + xsm_default_t def, struct domain *d, struct domain *t, struct domain *= f, + uint32_t flags) { return xsm_ops->mmu_update(d, t, f, flags); } =20 -static inline int xsm_mmuext_op (xsm_default_t def, struct domain *d, stru= ct domain *f) +static inline int xsm_mmuext_op( + xsm_default_t def, struct domain *d, struct domain *f) { return xsm_ops->mmuext_op(d, f); } =20 -static inline int xsm_update_va_mapping(xsm_default_t def, struct domain *= d, struct domain *f, - l1_pgentry_t p= te) +static inline int xsm_update_va_mapping( + xsm_default_t def, struct domain *d, struct domain *f, l1_pgentry_t pt= e) { return xsm_ops->update_va_mapping(d, f, pte); } =20 -static inline int xsm_priv_mapping(xsm_default_t def, struct domain *d, st= ruct domain *t) +static inline int xsm_priv_mapping( + xsm_default_t def, struct domain *d, struct domain *t) { return xsm_ops->priv_mapping(d, t); } =20 -static inline int xsm_ioport_permission (xsm_default_t def, struct domain = *d, uint32_t s, uint32_t e, uint8_t allow) +static inline int xsm_ioport_permission( + xsm_default_t def, struct domain *d, uint32_t s, uint32_t e, uint8_t a= llow) { return xsm_ops->ioport_permission(d, s, e, allow); } =20 -static inline int xsm_ioport_mapping (xsm_default_t def, struct domain *d,= uint32_t s, uint32_t e, uint8_t allow) +static inline int xsm_ioport_mapping( + xsm_default_t def, struct domain *d, uint32_t s, uint32_t e, uint8_t a= llow) { return xsm_ops->ioport_mapping(d, s, e, allow); } =20 -static inline int xsm_pmu_op (xsm_default_t def, struct domain *d, unsigne= d int op) +static inline int xsm_pmu_op( + xsm_default_t def, struct domain *d, unsigned int op) { return xsm_ops->pmu_op(d, op); } @@ -682,7 +731,7 @@ static inline int xsm_dm_op(xsm_default_t def, struct d= omain *d) return xsm_ops->dm_op(d); } =20 -static inline int xsm_xen_version (xsm_default_t def, uint32_t op) +static inline int xsm_xen_version(xsm_default_t def, uint32_t op) { return xsm_ops->xen_version(op); } @@ -698,8 +747,8 @@ static inline int xsm_argo_enable(const struct domain *= d) return xsm_ops->argo_enable(d); } =20 -static inline int xsm_argo_register_single_source(const struct domain *d, - const struct domain *t) +static inline int xsm_argo_register_single_source( + const struct domain *d, const struct domain *t) { return xsm_ops->argo_register_single_source(d, t); } @@ -719,12 +768,11 @@ static inline int xsm_argo_send(const struct domain *= d, const struct domain *t) #endif /* XSM_NO_WRAPPERS */ =20 #ifdef CONFIG_MULTIBOOT -extern int xsm_multiboot_init(unsigned long *module_map, - const multiboot_info_t *mbi); -extern int xsm_multiboot_policy_init(unsigned long *module_map, - const multiboot_info_t *mbi, - void **policy_buffer, - size_t *policy_size); +int xsm_multiboot_init( + unsigned long *module_map, const multiboot_info_t *mbi); +int xsm_multiboot_policy_init( + unsigned long *module_map, const multiboot_info_t *mbi, + void **policy_buffer, size_t *policy_size); #endif =20 #ifdef CONFIG_HAS_DEVICE_TREE @@ -733,18 +781,19 @@ extern int xsm_multiboot_policy_init(unsigned long *m= odule_map, * * On success, return 1 if using SILO mode else 0. */ -extern int xsm_dt_init(void); -extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size); -extern bool has_xsm_magic(paddr_t); +int xsm_dt_init(void); +int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size); +bool has_xsm_magic(paddr_t); #endif =20 -extern int register_xsm(struct xsm_operations *ops); +int register_xsm(struct xsm_operations *ops); =20 extern struct xsm_operations dummy_xsm_ops; -extern void xsm_fixup_ops(struct xsm_operations *ops); + +void xsm_fixup_ops(struct xsm_operations *ops); =20 #ifdef CONFIG_XSM_FLASK -extern void flask_init(const void *policy_buffer, size_t policy_size); +void flask_init(const void *policy_buffer, size_t policy_size); #else static inline void flask_init(const void *policy_buffer, size_t policy_siz= e) { @@ -757,7 +806,7 @@ extern const unsigned int xsm_flask_init_policy_size; #endif =20 #ifdef CONFIG_XSM_SILO -extern void silo_init(void); +void silo_init(void); #else static inline void silo_init(void) {} #endif @@ -767,8 +816,8 @@ static inline void silo_init(void) {} #include =20 #ifdef CONFIG_MULTIBOOT -static inline int xsm_multiboot_init (unsigned long *module_map, - const multiboot_info_t *mbi) +static inline int xsm_multiboot_init ( + unsigned long *module_map, const multiboot_info_t *mbi) { return 0; } diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index ac553f9c0d..ac8560aade 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -117,8 +117,8 @@ static int __init xsm_core_init(const void *policy_buff= er, size_t policy_size) } =20 #ifdef CONFIG_MULTIBOOT -int __init xsm_multiboot_init(unsigned long *module_map, - const multiboot_info_t *mbi) +int __init xsm_multiboot_init( + unsigned long *module_map, const multiboot_info_t *mbi) { int ret =3D 0; void *policy_buffer =3D NULL; @@ -128,8 +128,8 @@ int __init xsm_multiboot_init(unsigned long *module_map, =20 if ( XSM_MAGIC ) { - ret =3D xsm_multiboot_policy_init(module_map, mbi, - &policy_buffer, &policy_size); + ret =3D xsm_multiboot_policy_init(module_map, mbi, &policy_buffer, + &policy_size); if ( ret ) { bootstrap_map(NULL); diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 33ab37717f..8dafbc9381 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -30,10 +30,9 @@ #endif =20 #ifdef CONFIG_MULTIBOOT -int __init xsm_multiboot_policy_init(unsigned long *module_map, - const multiboot_info_t *mbi, - void **policy_buffer, - size_t *policy_size) +int __init xsm_multiboot_policy_init( + unsigned long *module_map, const multiboot_info_t *mbi, + void **policy_buffer, size_t *policy_size) { int i; module_t *mod =3D (module_t *)__va(mbi->mods_addr); --=20 2.20.1 From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290478; cv=pass; d=zohomail.com; s=zohoarc; b=Eje0qohhI1osAlsKnzl9NsxOyGmcXpwaxKkZmE9yHXvAEfQetN4or5z3P0y4nRIRjOUTE603SZZwOO3omWF3TS2TEcvyy1WqC5s/VuBgD/E+C2oioYLFZA4ne3SmBCuKsIvp3Qyot+UzHdoXFuR6wvrmnXgTn0dRE/4TX3tWq3w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290478; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=62lCiJwjowOdYP+QWrqMZ3ZE9UsyiwSgMGIsRjZIrF0=; b=kGBqJkVU8OR/4oXhXGeweFLkBG6HlzjP5vO7MGv4stTDfqxUHWbswKcboUC/shyz6O7I6QsJqnBthLPAS5OPLxZlWE6ykGGeHpzsFLurd8BanL2JthKafj7gnH7LqJeS4b9qY28zLxZfmHcFL3xk65uFJ462W/QS9AvPgc2bN7c= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631290478370710.1087636324411; Fri, 10 Sep 2021 09:14:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184615.333334 (Exim 4.92) (envelope-from ) id 1mOjAS-0001C5-6v; Fri, 10 Sep 2021 16:14:20 +0000 Received: by outflank-mailman (output) from mailman id 184615.333334; Fri, 10 Sep 2021 16:14:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOjAS-0001Bv-0p; Fri, 10 Sep 2021 16:14:20 +0000 Received: by outflank-mailman (input) for mailman id 184615; Fri, 10 Sep 2021 16:14:18 +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 ) id 1mOjAQ-0001BB-KZ for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:14:18 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 24e84592-1252-11ec-b254-12813bfff9fa; Fri, 10 Sep 2021 16:14:16 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1631290380841623.9985037915408; Fri, 10 Sep 2021 09:13:00 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 24e84592-1252-11ec-b254-12813bfff9fa ARC-Seal: i=1; a=rsa-sha256; t=1631290384; cv=none; d=zohomail.com; s=zohoarc; b=YUjP6pZpyZzKSDkQxMcFN8AM+Fpfob0GWW5OYLm5aFDe/bw0s54SGqCotW53qSKMp/z7HnLTRQYeVFh5OjOLesmuD9ZVGOW5gw/lUhTC3oREh9rjtf5U1NLVBc2QznI+U+APOqb8QRweNlY12TMQZfW4ai3piCRQXw9LaFEIQrw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290384; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=62lCiJwjowOdYP+QWrqMZ3ZE9UsyiwSgMGIsRjZIrF0=; b=crNdhpjaOldbFu6s12AxAmXk3KALxH2oxz0KVoRhld3sgC8cjZM9O7Siqd0P51uuokzYWCcQmGGix0O+H4qvrByXx/KMTW7lGT92pmdHc1OE6jLZyu92cmaKL+uRQ2ytc2ar17SLrNtG9qduYzpiwDpRutEsW9JL6TRdm0L/5nM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290384; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=62lCiJwjowOdYP+QWrqMZ3ZE9UsyiwSgMGIsRjZIrF0=; b=KuzWJLYEID8pEzQq2X+tg32FUxoeVFk3dccPXFRKQAdOQ3iE4Y1WSdu/JwPS+C4n o/ikkb2iCMNXw6Xe+4iyXnP71TGvTimgqtuyO70n3pmpJUzUq/5rh9GNiM+Kwi4rJhz 3KRmc+rTCObhRguD+IeejtE2GBufnoZwDd3xmApM= From: "Daniel P. Smith" To: "Daniel P. Smith" , xen-devel@lists.xenproject.org Cc: Andrew Cooper , Daniel De Graaf Subject: [PATCH v6 06/10] xsm: refactor xsm_ops handling Date: Fri, 10 Sep 2021 16:13:01 -0400 Message-Id: <20210910201305.32526-7-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290480395100001 Content-Type: text/plain; charset="utf-8" This renames the `struct xsm_operations` to the shorter `struct xsm_ops` and converts the global xsm_ops from being a pointer to an explicit instance. As part of this conversion, it reworks the XSM modules init function to return their xsm_ops struct which is copied in to the global xsm_ops instance. Signed-off-by: Daniel P. Smith Acked-by: Andrew Cooper --- xen/include/xsm/xsm.h | 220 +++++++++++++++++++++--------------------- xen/xsm/dummy.c | 4 +- xen/xsm/flask/hooks.c | 12 +-- xen/xsm/silo.c | 7 +- xen/xsm/xsm_core.c | 72 +++++++------- 5 files changed, 161 insertions(+), 154 deletions(-) diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 7673d605a6..556903aa21 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -41,7 +41,7 @@ enum xsm_default { }; typedef enum xsm_default xsm_default_t; =20 -struct xsm_operations { +struct xsm_ops { void (*security_domaininfo)(struct domain *d, struct xen_domctl_getdomaininfo *info); int (*domain_create)(struct domain *d, uint32_t ssidref); @@ -195,322 +195,322 @@ struct xsm_operations { =20 #ifdef CONFIG_XSM =20 -extern struct xsm_operations *xsm_ops; +extern struct xsm_ops xsm_ops; =20 #ifndef XSM_NO_WRAPPERS =20 static inline void xsm_security_domaininfo( struct domain *d, struct xen_domctl_getdomaininfo *info) { - xsm_ops->security_domaininfo(d, info); + xsm_ops.security_domaininfo(d, info); } =20 static inline int xsm_domain_create( xsm_default_t def, struct domain *d, uint32_t ssidref) { - return xsm_ops->domain_create(d, ssidref); + return xsm_ops.domain_create(d, ssidref); } =20 static inline int xsm_getdomaininfo(xsm_default_t def, struct domain *d) { - return xsm_ops->getdomaininfo(d); + return xsm_ops.getdomaininfo(d); } =20 static inline int xsm_domctl_scheduler_op( xsm_default_t def, struct domain *d, int cmd) { - return xsm_ops->domctl_scheduler_op(d, cmd); + return xsm_ops.domctl_scheduler_op(d, cmd); } =20 static inline int xsm_sysctl_scheduler_op(xsm_default_t def, int cmd) { - return xsm_ops->sysctl_scheduler_op(cmd); + return xsm_ops.sysctl_scheduler_op(cmd); } =20 static inline int xsm_set_target( xsm_default_t def, struct domain *d, struct domain *e) { - return xsm_ops->set_target(d, e); + return xsm_ops.set_target(d, e); } =20 static inline int xsm_domctl(xsm_default_t def, struct domain *d, int cmd) { - return xsm_ops->domctl(d, cmd); + return xsm_ops.domctl(d, cmd); } =20 static inline int xsm_sysctl(xsm_default_t def, int cmd) { - return xsm_ops->sysctl(cmd); + return xsm_ops.sysctl(cmd); } =20 static inline int xsm_readconsole(xsm_default_t def, uint32_t clear) { - return xsm_ops->readconsole(clear); + return xsm_ops.readconsole(clear); } =20 static inline int xsm_evtchn_unbound( xsm_default_t def, struct domain *d1, struct evtchn *chn, domid_t id2) { - return xsm_ops->evtchn_unbound(d1, chn, id2); + return xsm_ops.evtchn_unbound(d1, chn, id2); } =20 static inline int xsm_evtchn_interdomain( xsm_default_t def, struct domain *d1, struct evtchn *chan1, struct domain *d2, struct evtchn *chan2) { - return xsm_ops->evtchn_interdomain(d1, chan1, d2, chan2); + return xsm_ops.evtchn_interdomain(d1, chan1, d2, chan2); } =20 static inline void xsm_evtchn_close_post(struct evtchn *chn) { - xsm_ops->evtchn_close_post(chn); + xsm_ops.evtchn_close_post(chn); } =20 static inline int xsm_evtchn_send( xsm_default_t def, struct domain *d, struct evtchn *chn) { - return xsm_ops->evtchn_send(d, chn); + return xsm_ops.evtchn_send(d, chn); } =20 static inline int xsm_evtchn_status( xsm_default_t def, struct domain *d, struct evtchn *chn) { - return xsm_ops->evtchn_status(d, chn); + return xsm_ops.evtchn_status(d, chn); } =20 static inline int xsm_evtchn_reset( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->evtchn_reset(d1, d2); + return xsm_ops.evtchn_reset(d1, d2); } =20 static inline int xsm_grant_mapref( xsm_default_t def, struct domain *d1, struct domain *d2, uint32_t flag= s) { - return xsm_ops->grant_mapref(d1, d2, flags); + return xsm_ops.grant_mapref(d1, d2, flags); } =20 static inline int xsm_grant_unmapref( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->grant_unmapref(d1, d2); + return xsm_ops.grant_unmapref(d1, d2); } =20 static inline int xsm_grant_setup( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->grant_setup(d1, d2); + return xsm_ops.grant_setup(d1, d2); } =20 static inline int xsm_grant_transfer( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->grant_transfer(d1, d2); + return xsm_ops.grant_transfer(d1, d2); } =20 static inline int xsm_grant_copy( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->grant_copy(d1, d2); + return xsm_ops.grant_copy(d1, d2); } =20 static inline int xsm_grant_query_size( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->grant_query_size(d1, d2); + return xsm_ops.grant_query_size(d1, d2); } =20 static inline int xsm_alloc_security_domain(struct domain *d) { - return xsm_ops->alloc_security_domain(d); + return xsm_ops.alloc_security_domain(d); } =20 static inline void xsm_free_security_domain(struct domain *d) { - xsm_ops->free_security_domain(d); + xsm_ops.free_security_domain(d); } =20 static inline int xsm_alloc_security_evtchns( struct evtchn chn[], unsigned int nr) { - return xsm_ops->alloc_security_evtchns(chn, nr); + return xsm_ops.alloc_security_evtchns(chn, nr); } =20 static inline void xsm_free_security_evtchns( struct evtchn chn[], unsigned int nr) { - xsm_ops->free_security_evtchns(chn, nr); + xsm_ops.free_security_evtchns(chn, nr); } =20 static inline char *xsm_show_security_evtchn( struct domain *d, const struct evtchn *chn) { - return xsm_ops->show_security_evtchn(d, chn); + return xsm_ops.show_security_evtchn(d, chn); } =20 static inline int xsm_init_hardware_domain(xsm_default_t def, struct domai= n *d) { - return xsm_ops->init_hardware_domain(d); + return xsm_ops.init_hardware_domain(d); } =20 static inline int xsm_get_pod_target(xsm_default_t def, struct domain *d) { - return xsm_ops->get_pod_target(d); + return xsm_ops.get_pod_target(d); } =20 static inline int xsm_set_pod_target(xsm_default_t def, struct domain *d) { - return xsm_ops->set_pod_target(d); + return xsm_ops.set_pod_target(d); } =20 static inline int xsm_memory_exchange(xsm_default_t def, struct domain *d) { - return xsm_ops->memory_exchange(d); + return xsm_ops.memory_exchange(d); } =20 static inline int xsm_memory_adjust_reservation( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->memory_adjust_reservation(d1, d2); + return xsm_ops.memory_adjust_reservation(d1, d2); } =20 static inline int xsm_memory_stat_reservation( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->memory_stat_reservation(d1, d2); + return xsm_ops.memory_stat_reservation(d1, d2); } =20 static inline int xsm_memory_pin_page( xsm_default_t def, struct domain *d1, struct domain *d2, struct page_info *page) { - return xsm_ops->memory_pin_page(d1, d2, page); + return xsm_ops.memory_pin_page(d1, d2, page); } =20 static inline int xsm_add_to_physmap( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->add_to_physmap(d1, d2); + return xsm_ops.add_to_physmap(d1, d2); } =20 static inline int xsm_remove_from_physmap( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->remove_from_physmap(d1, d2); + return xsm_ops.remove_from_physmap(d1, d2); } =20 static inline int xsm_map_gmfn_foreign( xsm_default_t def, struct domain *d, struct domain *t) { - return xsm_ops->map_gmfn_foreign(d, t); + return xsm_ops.map_gmfn_foreign(d, t); } =20 static inline int xsm_claim_pages(xsm_default_t def, struct domain *d) { - return xsm_ops->claim_pages(d); + return xsm_ops.claim_pages(d); } =20 static inline int xsm_console_io(xsm_default_t def, struct domain *d, int = cmd) { - return xsm_ops->console_io(d, cmd); + return xsm_ops.console_io(d, cmd); } =20 static inline int xsm_profile(xsm_default_t def, struct domain *d, int op) { - return xsm_ops->profile(d, op); + return xsm_ops.profile(d, op); } =20 static inline int xsm_kexec(xsm_default_t def) { - return xsm_ops->kexec(); + return xsm_ops.kexec(); } =20 static inline int xsm_schedop_shutdown( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops->schedop_shutdown(d1, d2); + return xsm_ops.schedop_shutdown(d1, d2); } =20 static inline char *xsm_show_irq_sid(int irq) { - return xsm_ops->show_irq_sid(irq); + return xsm_ops.show_irq_sid(irq); } =20 static inline int xsm_map_domain_pirq(xsm_default_t def, struct domain *d) { - return xsm_ops->map_domain_pirq(d); + return xsm_ops.map_domain_pirq(d); } =20 static inline int xsm_map_domain_irq( xsm_default_t def, struct domain *d, int irq, void *data) { - return xsm_ops->map_domain_irq(d, irq, data); + return xsm_ops.map_domain_irq(d, irq, data); } =20 static inline int xsm_unmap_domain_pirq(xsm_default_t def, struct domain *= d) { - return xsm_ops->unmap_domain_pirq(d); + return xsm_ops.unmap_domain_pirq(d); } =20 static inline int xsm_unmap_domain_irq( xsm_default_t def, struct domain *d, int irq, void *data) { - return xsm_ops->unmap_domain_irq(d, irq, data); + return xsm_ops.unmap_domain_irq(d, irq, data); } =20 static inline int xsm_bind_pt_irq( xsm_default_t def, struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd) { - return xsm_ops->bind_pt_irq(d, bind); + return xsm_ops.bind_pt_irq(d, bind); } =20 static inline int xsm_unbind_pt_irq( xsm_default_t def, struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd) { - return xsm_ops->unbind_pt_irq(d, bind); + return xsm_ops.unbind_pt_irq(d, bind); } =20 static inline int xsm_irq_permission( xsm_default_t def, struct domain *d, int pirq, uint8_t allow) { - return xsm_ops->irq_permission(d, pirq, allow); + return xsm_ops.irq_permission(d, pirq, allow); } =20 static inline int xsm_iomem_permission( xsm_default_t def, struct domain *d, uint64_t s, uint64_t e, uint8_t a= llow) { - return xsm_ops->iomem_permission(d, s, e, allow); + return xsm_ops.iomem_permission(d, s, e, allow); } =20 static inline int xsm_iomem_mapping( xsm_default_t def, struct domain *d, uint64_t s, uint64_t e, uint8_t a= llow) { - return xsm_ops->iomem_mapping(d, s, e, allow); + return xsm_ops.iomem_mapping(d, s, e, allow); } =20 static inline int xsm_pci_config_permission( xsm_default_t def, struct domain *d, uint32_t machine_bdf, uint16_t st= art, uint16_t end, uint8_t access) { - return xsm_ops->pci_config_permission(d, machine_bdf, start, end, acce= ss); + return xsm_ops.pci_config_permission(d, machine_bdf, start, end, acces= s); } =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) static inline int xsm_get_device_group(xsm_default_t def, uint32_t machine= _bdf) { - return xsm_ops->get_device_group(machine_bdf); + return xsm_ops.get_device_group(machine_bdf); } =20 static inline int xsm_assign_device( xsm_default_t def, struct domain *d, uint32_t machine_bdf) { - return xsm_ops->assign_device(d, machine_bdf); + return xsm_ops.assign_device(d, machine_bdf); } =20 static inline int xsm_deassign_device( xsm_default_t def, struct domain *d, uint32_t machine_bdf) { - return xsm_ops->deassign_device(d, machine_bdf); + return xsm_ops.deassign_device(d, machine_bdf); } #endif /* HAS_PASSTHROUGH && HAS_PCI) */ =20 @@ -518,249 +518,249 @@ static inline int xsm_deassign_device( static inline int xsm_assign_dtdevice( xsm_default_t def, struct domain *d, const char *dtpath) { - return xsm_ops->assign_dtdevice(d, dtpath); + return xsm_ops.assign_dtdevice(d, dtpath); } =20 static inline int xsm_deassign_dtdevice( xsm_default_t def, struct domain *d, const char *dtpath) { - return xsm_ops->deassign_dtdevice(d, dtpath); + return xsm_ops.deassign_dtdevice(d, dtpath); } =20 #endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ =20 static inline int xsm_resource_plug_pci(xsm_default_t def, uint32_t machin= e_bdf) { - return xsm_ops->resource_plug_pci(machine_bdf); + return xsm_ops.resource_plug_pci(machine_bdf); } =20 static inline int xsm_resource_unplug_pci( xsm_default_t def, uint32_t machine_bdf) { - return xsm_ops->resource_unplug_pci(machine_bdf); + return xsm_ops.resource_unplug_pci(machine_bdf); } =20 static inline int xsm_resource_plug_core(xsm_default_t def) { - return xsm_ops->resource_plug_core(); + return xsm_ops.resource_plug_core(); } =20 static inline int xsm_resource_unplug_core(xsm_default_t def) { - return xsm_ops->resource_unplug_core(); + return xsm_ops.resource_unplug_core(); } =20 static inline int xsm_resource_setup_pci( xsm_default_t def, uint32_t machine_bdf) { - return xsm_ops->resource_setup_pci(machine_bdf); + return xsm_ops.resource_setup_pci(machine_bdf); } =20 static inline int xsm_resource_setup_gsi(xsm_default_t def, int gsi) { - return xsm_ops->resource_setup_gsi(gsi); + return xsm_ops.resource_setup_gsi(gsi); } =20 static inline int xsm_resource_setup_misc(xsm_default_t def) { - return xsm_ops->resource_setup_misc(); + return xsm_ops.resource_setup_misc(); } =20 static inline int xsm_page_offline(xsm_default_t def, uint32_t cmd) { - return xsm_ops->page_offline(cmd); + return xsm_ops.page_offline(cmd); } =20 static inline int xsm_hypfs_op(xsm_default_t def) { - return xsm_ops->hypfs_op(); + return xsm_ops.hypfs_op(); } =20 static inline long xsm_do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) { - return xsm_ops->do_xsm_op(op); + return xsm_ops.do_xsm_op(op); } =20 #ifdef CONFIG_COMPAT static inline int xsm_do_compat_op(XEN_GUEST_HANDLE_PARAM(void) op) { - return xsm_ops->do_compat_op(op); + return xsm_ops.do_compat_op(op); } #endif =20 static inline int xsm_hvm_param( xsm_default_t def, struct domain *d, unsigned long op) { - return xsm_ops->hvm_param(d, op); + return xsm_ops.hvm_param(d, op); } =20 static inline int xsm_hvm_control( xsm_default_t def, struct domain *d, unsigned long op) { - return xsm_ops->hvm_control(d, op); + return xsm_ops.hvm_control(d, op); } =20 static inline int xsm_hvm_param_altp2mhvm(xsm_default_t def, struct domain= *d) { - return xsm_ops->hvm_param_altp2mhvm(d); + return xsm_ops.hvm_param_altp2mhvm(d); } =20 static inline int xsm_hvm_altp2mhvm_op( xsm_default_t def, struct domain *d, uint64_t mode, uint32_t op) { - return xsm_ops->hvm_altp2mhvm_op(d, mode, op); + return xsm_ops.hvm_altp2mhvm_op(d, mode, op); } =20 static inline int xsm_get_vnumainfo(xsm_default_t def, struct domain *d) { - return xsm_ops->get_vnumainfo(d); + return xsm_ops.get_vnumainfo(d); } =20 static inline int xsm_vm_event_control( xsm_default_t def, struct domain *d, int mode, int op) { - return xsm_ops->vm_event_control(d, mode, op); + return xsm_ops.vm_event_control(d, mode, op); } =20 #ifdef CONFIG_MEM_ACCESS static inline int xsm_mem_access(xsm_default_t def, struct domain *d) { - return xsm_ops->mem_access(d); + return xsm_ops.mem_access(d); } #endif =20 #ifdef CONFIG_MEM_PAGING static inline int xsm_mem_paging(xsm_default_t def, struct domain *d) { - return xsm_ops->mem_paging(d); + return xsm_ops.mem_paging(d); } #endif =20 #ifdef CONFIG_MEM_SHARING static inline int xsm_mem_sharing(xsm_default_t def, struct domain *d) { - return xsm_ops->mem_sharing(d); + return xsm_ops.mem_sharing(d); } #endif =20 static inline int xsm_platform_op(xsm_default_t def, uint32_t op) { - return xsm_ops->platform_op(op); + return xsm_ops.platform_op(op); } =20 #ifdef CONFIG_X86 static inline int xsm_do_mca(xsm_default_t def) { - return xsm_ops->do_mca(); + return xsm_ops.do_mca(); } =20 static inline int xsm_shadow_control( xsm_default_t def, struct domain *d, uint32_t op) { - return xsm_ops->shadow_control(d, op); + return xsm_ops.shadow_control(d, op); } =20 static inline int xsm_mem_sharing_op( xsm_default_t def, struct domain *d, struct domain *cd, int op) { - return xsm_ops->mem_sharing_op(d, cd, op); + return xsm_ops.mem_sharing_op(d, cd, op); } =20 static inline int xsm_apic(xsm_default_t def, struct domain *d, int cmd) { - return xsm_ops->apic(d, cmd); + return xsm_ops.apic(d, cmd); } =20 static inline int xsm_machine_memory_map(xsm_default_t def) { - return xsm_ops->machine_memory_map(); + return xsm_ops.machine_memory_map(); } =20 static inline int xsm_domain_memory_map(xsm_default_t def, struct domain *= d) { - return xsm_ops->domain_memory_map(d); + return xsm_ops.domain_memory_map(d); } =20 static inline int xsm_mmu_update( xsm_default_t def, struct domain *d, struct domain *t, struct domain *= f, uint32_t flags) { - return xsm_ops->mmu_update(d, t, f, flags); + return xsm_ops.mmu_update(d, t, f, flags); } =20 static inline int xsm_mmuext_op( xsm_default_t def, struct domain *d, struct domain *f) { - return xsm_ops->mmuext_op(d, f); + return xsm_ops.mmuext_op(d, f); } =20 static inline int xsm_update_va_mapping( xsm_default_t def, struct domain *d, struct domain *f, l1_pgentry_t pt= e) { - return xsm_ops->update_va_mapping(d, f, pte); + return xsm_ops.update_va_mapping(d, f, pte); } =20 static inline int xsm_priv_mapping( xsm_default_t def, struct domain *d, struct domain *t) { - return xsm_ops->priv_mapping(d, t); + return xsm_ops.priv_mapping(d, t); } =20 static inline int xsm_ioport_permission( xsm_default_t def, struct domain *d, uint32_t s, uint32_t e, uint8_t a= llow) { - return xsm_ops->ioport_permission(d, s, e, allow); + return xsm_ops.ioport_permission(d, s, e, allow); } =20 static inline int xsm_ioport_mapping( xsm_default_t def, struct domain *d, uint32_t s, uint32_t e, uint8_t a= llow) { - return xsm_ops->ioport_mapping(d, s, e, allow); + return xsm_ops.ioport_mapping(d, s, e, allow); } =20 static inline int xsm_pmu_op( xsm_default_t def, struct domain *d, unsigned int op) { - return xsm_ops->pmu_op(d, op); + return xsm_ops.pmu_op(d, op); } =20 #endif /* CONFIG_X86 */ =20 static inline int xsm_dm_op(xsm_default_t def, struct domain *d) { - return xsm_ops->dm_op(d); + return xsm_ops.dm_op(d); } =20 static inline int xsm_xen_version(xsm_default_t def, uint32_t op) { - return xsm_ops->xen_version(op); + return xsm_ops.xen_version(op); } =20 static inline int xsm_domain_resource_map(xsm_default_t def, struct domain= *d) { - return xsm_ops->domain_resource_map(d); + return xsm_ops.domain_resource_map(d); } =20 #ifdef CONFIG_ARGO static inline int xsm_argo_enable(const struct domain *d) { - return xsm_ops->argo_enable(d); + return xsm_ops.argo_enable(d); } =20 static inline int xsm_argo_register_single_source( const struct domain *d, const struct domain *t) { - return xsm_ops->argo_register_single_source(d, t); + return xsm_ops.argo_register_single_source(d, t); } =20 static inline int xsm_argo_register_any_source(const struct domain *d) { - return xsm_ops->argo_register_any_source(d); + return xsm_ops.argo_register_any_source(d); } =20 static inline int xsm_argo_send(const struct domain *d, const struct domai= n *t) { - return xsm_ops->argo_send(d, t); + return xsm_ops.argo_send(d, t); } =20 #endif /* CONFIG_ARGO */ @@ -786,17 +786,18 @@ int xsm_dt_policy_init(void **policy_buffer, size_t *= policy_size); bool has_xsm_magic(paddr_t); #endif =20 -int register_xsm(struct xsm_operations *ops); +extern struct xsm_ops dummy_xsm_ops; =20 -extern struct xsm_operations dummy_xsm_ops; - -void xsm_fixup_ops(struct xsm_operations *ops); +void xsm_fixup_ops(struct xsm_ops *ops); =20 #ifdef CONFIG_XSM_FLASK -void flask_init(const void *policy_buffer, size_t policy_size); +extern const struct xsm_ops *flask_init(const void *policy_buffer, + size_t policy_size); #else -static inline void flask_init(const void *policy_buffer, size_t policy_siz= e) +static const inline struct xsm_ops *flask_init(const void *policy_buffer, + size_t policy_size) { + return NULL; } #endif =20 @@ -806,9 +807,12 @@ extern const unsigned int xsm_flask_init_policy_size; #endif =20 #ifdef CONFIG_XSM_SILO -void silo_init(void); +extern const struct xsm_ops *silo_init(void); #else -static inline void silo_init(void) {} +static const inline struct xsm_ops *silo_init(void) +{ + return NULL; +} #endif =20 #else /* CONFIG_XSM */ diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index de44b10130..d8c935328e 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -13,15 +13,13 @@ #define XSM_NO_WRAPPERS #include =20 -struct xsm_operations dummy_xsm_ops; - #define set_to_dummy_if_null(ops, function) \ do { \ if ( !ops->function ) \ ops->function =3D xsm_##function; \ } while (0) =20 -void __init xsm_fixup_ops (struct xsm_operations *ops) +void __init xsm_fixup_ops (struct xsm_ops *ops) { set_to_dummy_if_null(ops, security_domaininfo); set_to_dummy_if_null(ops, domain_create); diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index 1465db125a..25e87180b4 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1745,7 +1745,7 @@ static int flask_argo_send(const struct domain *d, co= nst struct domain *t) long do_flask_op(XEN_GUEST_HANDLE_PARAM(void) u_flask_op); int compat_flask_op(XEN_GUEST_HANDLE_PARAM(void) u_flask_op); =20 -static struct xsm_operations flask_ops =3D { +static const struct xsm_ops __initconstrel flask_ops =3D { .security_domaininfo =3D flask_security_domaininfo, .domain_create =3D flask_domain_create, .getdomaininfo =3D flask_getdomaininfo, @@ -1883,7 +1883,8 @@ static struct xsm_operations flask_ops =3D { #endif }; =20 -void __init flask_init(const void *policy_buffer, size_t policy_size) +const struct xsm_ops *__init flask_init(const void *policy_buffer, + size_t policy_size) { int ret =3D -ENOENT; =20 @@ -1891,7 +1892,7 @@ void __init flask_init(const void *policy_buffer, siz= e_t policy_size) { case FLASK_BOOTPARAM_DISABLED: printk(XENLOG_INFO "Flask: Disabled at boot.\n"); - return; + return NULL; =20 case FLASK_BOOTPARAM_PERMISSIVE: flask_enforcing =3D 0; @@ -1908,9 +1909,6 @@ void __init flask_init(const void *policy_buffer, siz= e_t policy_size) =20 avc_init(); =20 - if ( register_xsm(&flask_ops) ) - panic("Flask: Unable to register with XSM\n"); - if ( policy_size && flask_bootparam !=3D FLASK_BOOTPARAM_LATELOAD ) ret =3D security_load_policy(policy_buffer, policy_size); =20 @@ -1923,6 +1921,8 @@ void __init flask_init(const void *policy_buffer, siz= e_t policy_size) printk(XENLOG_INFO "Flask: Starting in enforcing mode.\n"); else printk(XENLOG_INFO "Flask: Starting in permissive mode.\n"); + + return &flask_ops; } =20 /* diff --git a/xen/xsm/silo.c b/xen/xsm/silo.c index fc2ca5cd2d..3550dded7b 100644 --- a/xen/xsm/silo.c +++ b/xen/xsm/silo.c @@ -100,7 +100,7 @@ static int silo_argo_send(const struct domain *d1, cons= t struct domain *d2) =20 #endif =20 -static struct xsm_operations silo_xsm_ops =3D { +static const struct xsm_ops __initconstrel silo_xsm_ops =3D { .evtchn_unbound =3D silo_evtchn_unbound, .evtchn_interdomain =3D silo_evtchn_interdomain, .grant_mapref =3D silo_grant_mapref, @@ -112,12 +112,11 @@ static struct xsm_operations silo_xsm_ops =3D { #endif }; =20 -void __init silo_init(void) +const struct xsm_ops *__init silo_init(void) { printk("Initialising XSM SILO mode\n"); =20 - if ( register_xsm(&silo_xsm_ops) ) - panic("SILO: Unable to register with XSM\n"); + return &silo_xsm_ops; } =20 /* diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index ac8560aade..21fffbcb41 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -28,9 +28,17 @@ #include #endif =20 -#define XSM_FRAMEWORK_VERSION "1.0.0" +#define XSM_FRAMEWORK_VERSION "1.0.1" =20 -struct xsm_operations *xsm_ops; +struct xsm_ops __read_mostly xsm_ops; + +enum xsm_ops_state { + XSM_OPS_UNREGISTERED, + XSM_OPS_REG_FAILED, + XSM_OPS_REGISTERED, +}; + +static enum xsm_ops_state __initdata xsm_ops_registered =3D XSM_OPS_UNREGI= STERED; =20 enum xsm_bootparam { XSM_BOOTPARAM_DUMMY, @@ -68,17 +76,10 @@ static int __init parse_xsm_param(const char *s) } custom_param("xsm", parse_xsm_param); =20 -static inline int verify(struct xsm_operations *ops) -{ - /* verify the security_operations structure exists */ - if ( !ops ) - return -EINVAL; - xsm_fixup_ops(ops); - return 0; -} - static int __init xsm_core_init(const void *policy_buffer, size_t policy_s= ize) { + const struct xsm_ops *ops =3D NULL; + #ifdef CONFIG_XSM_FLASK_POLICY if ( policy_size =3D=3D 0 ) { @@ -87,25 +88,25 @@ static int __init xsm_core_init(const void *policy_buff= er, size_t policy_size) } #endif =20 - if ( verify(&dummy_xsm_ops) ) + if ( xsm_ops_registered !=3D XSM_OPS_UNREGISTERED ) { - printk(XENLOG_ERR "Could not verify dummy_xsm_ops structure\n"); + printk(XENLOG_ERR + "Could not init XSM, xsm_ops register already attempted\n"); return -EIO; } =20 - xsm_ops =3D &dummy_xsm_ops; - switch ( xsm_bootparam ) { case XSM_BOOTPARAM_DUMMY: + xsm_ops_registered =3D XSM_OPS_REGISTERED; break; =20 case XSM_BOOTPARAM_FLASK: - flask_init(policy_buffer, policy_size); + ops =3D flask_init(policy_buffer, policy_size); break; =20 case XSM_BOOTPARAM_SILO: - silo_init(); + ops =3D silo_init(); break; =20 default: @@ -113,6 +114,27 @@ static int __init xsm_core_init(const void *policy_buf= fer, size_t policy_size) break; } =20 + if ( ops ) + { + xsm_ops_registered =3D XSM_OPS_REGISTERED; + xsm_ops =3D *ops; + } + /* + * This handles three cases, + * - dummy policy module was selected + * - a policy module does not provide all handlers + * - a policy module failed to init + */ + xsm_fixup_ops(&xsm_ops); + + if ( xsm_ops_registered !=3D XSM_OPS_REGISTERED ) + { + xsm_ops_registered =3D XSM_OPS_REG_FAILED; + printk(XENLOG_ERR + "Could not init XSM, xsm_ops register failed\n"); + return -EFAULT; + } + return 0; } =20 @@ -195,22 +217,6 @@ bool __init has_xsm_magic(paddr_t start) } #endif =20 -int __init register_xsm(struct xsm_operations *ops) -{ - if ( verify(ops) ) - { - printk(XENLOG_ERR "Could not verify xsm_operations structure\n"); - return -EINVAL; - } - - if ( xsm_ops !=3D &dummy_xsm_ops ) - return -EAGAIN; - - xsm_ops =3D ops; - - return 0; -} - #endif =20 long do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) --=20 2.20.1 From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290481; cv=pass; d=zohomail.com; s=zohoarc; b=OnOTrV9HvmRYJyiiY5GsGDkZQSdq7SI3G05tY1914CQztgcx2pouCZm1Hedzb9IjzGxVjUqr6B/6LFGwftr0KvdC0tdUIrzY8Bvoheltfx4J+h4Qai7nU8dWNXZkZqOaxrbmn3QlJwh/osJOyUJ/uzKkg9mAZ6EtZYpqKmIf3Ek= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290481; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/B6/3FHiNB3IVMfbChqH0I39/uMG5o4Sw9RJ3RiDpic=; b=H1kpLVWpT1i4fAsb4X6plh8MZzazyac/ofPY5rvOtclzcC1zJItkI5quYMhYz96LqqpvpC2HxjGvnrQnLmceclC0tOwC4nl0IXnPwgV9buS8pwCA/8jxsYvoyI1wRtLPqZyRCmu9xuM51dcOX8XxUMtH07sFU1WOJq46i7EkarY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631290481376269.9603593536292; Fri, 10 Sep 2021 09:14:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184618.333344 (Exim 4.92) (envelope-from ) id 1mOjAY-0001cj-Iq; Fri, 10 Sep 2021 16:14:26 +0000 Received: by outflank-mailman (output) from mailman id 184618.333344; Fri, 10 Sep 2021 16:14:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOjAY-0001cH-FH; Fri, 10 Sep 2021 16:14:26 +0000 Received: by outflank-mailman (input) for mailman id 184618; Fri, 10 Sep 2021 16:14: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 ) id 1mOjAX-0001bc-QQ for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:14:25 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2923eaf9-1252-11ec-b254-12813bfff9fa; Fri, 10 Sep 2021 16:14:24 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 163129038197236.20358463523735; Fri, 10 Sep 2021 09:13:01 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2923eaf9-1252-11ec-b254-12813bfff9fa ARC-Seal: i=1; a=rsa-sha256; t=1631290385; cv=none; d=zohomail.com; s=zohoarc; b=fqgyhdyjgF8V/9UEth2NtEpYfmyh/zBDvgDqe6vPUYZdMs25Q0j4i0+/NiJE/Y1QKzGH9xbYCDvbuplZrOgi48uVrCLK5AbIsjPH47+r1x+rKcAA8nzuBCIwtrXB2KMiuDYbl2etOQdtyeYjzAJfRqgTD39gy5up1nZ1C3tXeFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290385; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=/B6/3FHiNB3IVMfbChqH0I39/uMG5o4Sw9RJ3RiDpic=; b=TZCEN+9c43tDj+4tKPJz0BWXpI3VMBNCD3qQpqNhljbX+PlmFGrPTQQa79VUfeMjZ1nyX9Zrm7nlSZtMhqo/mgKJOwv2+L/bLGdm5sN0b4kvq+TKBM1kUb99mauCAlhaP0SOa5GJp+b/sIc6qnaMssIKbkXVtgdap1xJrRLL3lE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290385; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=/B6/3FHiNB3IVMfbChqH0I39/uMG5o4Sw9RJ3RiDpic=; b=SohyymauANCXM83TXc/1JCgAUM8EkyBtdVK4c2KWVFs3yhPHZFy8VAJiqzHwEB/n SsaRy+aj451lNc4UzzgkWMRiuAyypCaNoUbVhtsvQ1EfvL/S9duj+LUAM9Lm9gdg2Fq Un/7wgXLJ0JEOigp2b8wPq10dJwd5ZGmHDFzifkw= From: "Daniel P. Smith" To: "Daniel P. Smith" , xen-devel@lists.xenproject.org Cc: Andrew Cooper , Daniel De Graaf Subject: [PATCH v6 07/10] xsm: convert xsm_ops hook calls to alternative call Date: Fri, 10 Sep 2021 16:13:02 -0400 Message-Id: <20210910201305.32526-8-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290482856100001 Content-Type: text/plain; charset="utf-8" To reduce retpolines convert all the pointer function calls of the xsm_ops hooks over to the alternative_call infrastructure. Signed-off-by: Daniel P. Smith Acked-by: Andrew Cooper --- xen/include/xsm/xsm.h | 191 +++++++++++++++++++++--------------------- 1 file changed, 96 insertions(+), 95 deletions(-) diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 556903aa21..c101e653f6 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -15,6 +15,7 @@ #ifndef __XSM_H__ #define __XSM_H__ =20 +#include #include #include =20 @@ -202,315 +203,315 @@ extern struct xsm_ops xsm_ops; static inline void xsm_security_domaininfo( struct domain *d, struct xen_domctl_getdomaininfo *info) { - xsm_ops.security_domaininfo(d, info); + alternative_vcall(xsm_ops.security_domaininfo, d, info); } =20 static inline int xsm_domain_create( xsm_default_t def, struct domain *d, uint32_t ssidref) { - return xsm_ops.domain_create(d, ssidref); + return alternative_call(xsm_ops.domain_create, d, ssidref); } =20 static inline int xsm_getdomaininfo(xsm_default_t def, struct domain *d) { - return xsm_ops.getdomaininfo(d); + return alternative_call(xsm_ops.getdomaininfo, d); } =20 static inline int xsm_domctl_scheduler_op( xsm_default_t def, struct domain *d, int cmd) { - return xsm_ops.domctl_scheduler_op(d, cmd); + return alternative_call(xsm_ops.domctl_scheduler_op, d, cmd); } =20 static inline int xsm_sysctl_scheduler_op(xsm_default_t def, int cmd) { - return xsm_ops.sysctl_scheduler_op(cmd); + return alternative_call(xsm_ops.sysctl_scheduler_op, cmd); } =20 static inline int xsm_set_target( xsm_default_t def, struct domain *d, struct domain *e) { - return xsm_ops.set_target(d, e); + return alternative_call(xsm_ops.set_target, d, e); } =20 static inline int xsm_domctl(xsm_default_t def, struct domain *d, int cmd) { - return xsm_ops.domctl(d, cmd); + return alternative_call(xsm_ops.domctl, d, cmd); } =20 static inline int xsm_sysctl(xsm_default_t def, int cmd) { - return xsm_ops.sysctl(cmd); + return alternative_call(xsm_ops.sysctl, cmd); } =20 static inline int xsm_readconsole(xsm_default_t def, uint32_t clear) { - return xsm_ops.readconsole(clear); + return alternative_call(xsm_ops.readconsole, clear); } =20 static inline int xsm_evtchn_unbound( xsm_default_t def, struct domain *d1, struct evtchn *chn, domid_t id2) { - return xsm_ops.evtchn_unbound(d1, chn, id2); + return alternative_call(xsm_ops.evtchn_unbound, d1, chn, id2); } =20 static inline int xsm_evtchn_interdomain( xsm_default_t def, struct domain *d1, struct evtchn *chan1, struct domain *d2, struct evtchn *chan2) { - return xsm_ops.evtchn_interdomain(d1, chan1, d2, chan2); + return alternative_call(xsm_ops.evtchn_interdomain, d1, chan1, d2, cha= n2); } =20 static inline void xsm_evtchn_close_post(struct evtchn *chn) { - xsm_ops.evtchn_close_post(chn); + alternative_vcall(xsm_ops.evtchn_close_post, chn); } =20 static inline int xsm_evtchn_send( xsm_default_t def, struct domain *d, struct evtchn *chn) { - return xsm_ops.evtchn_send(d, chn); + return alternative_call(xsm_ops.evtchn_send, d, chn); } =20 static inline int xsm_evtchn_status( xsm_default_t def, struct domain *d, struct evtchn *chn) { - return xsm_ops.evtchn_status(d, chn); + return alternative_call(xsm_ops.evtchn_status, d, chn); } =20 static inline int xsm_evtchn_reset( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.evtchn_reset(d1, d2); + return alternative_call(xsm_ops.evtchn_reset, d1, d2); } =20 static inline int xsm_grant_mapref( xsm_default_t def, struct domain *d1, struct domain *d2, uint32_t flag= s) { - return xsm_ops.grant_mapref(d1, d2, flags); + return alternative_call(xsm_ops.grant_mapref, d1, d2, flags); } =20 static inline int xsm_grant_unmapref( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.grant_unmapref(d1, d2); + return alternative_call(xsm_ops.grant_unmapref, d1, d2); } =20 static inline int xsm_grant_setup( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.grant_setup(d1, d2); + return alternative_call(xsm_ops.grant_setup, d1, d2); } =20 static inline int xsm_grant_transfer( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.grant_transfer(d1, d2); + return alternative_call(xsm_ops.grant_transfer, d1, d2); } =20 static inline int xsm_grant_copy( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.grant_copy(d1, d2); + return alternative_call(xsm_ops.grant_copy, d1, d2); } =20 static inline int xsm_grant_query_size( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.grant_query_size(d1, d2); + return alternative_call(xsm_ops.grant_query_size, d1, d2); } =20 static inline int xsm_alloc_security_domain(struct domain *d) { - return xsm_ops.alloc_security_domain(d); + return alternative_call(xsm_ops.alloc_security_domain, d); } =20 static inline void xsm_free_security_domain(struct domain *d) { - xsm_ops.free_security_domain(d); + alternative_vcall(xsm_ops.free_security_domain, d); } =20 static inline int xsm_alloc_security_evtchns( struct evtchn chn[], unsigned int nr) { - return xsm_ops.alloc_security_evtchns(chn, nr); + return alternative_call(xsm_ops.alloc_security_evtchns, chn, nr); } =20 static inline void xsm_free_security_evtchns( struct evtchn chn[], unsigned int nr) { - xsm_ops.free_security_evtchns(chn, nr); + alternative_vcall(xsm_ops.free_security_evtchns, chn, nr); } =20 static inline char *xsm_show_security_evtchn( struct domain *d, const struct evtchn *chn) { - return xsm_ops.show_security_evtchn(d, chn); + return alternative_call(xsm_ops.show_security_evtchn, d, chn); } =20 static inline int xsm_init_hardware_domain(xsm_default_t def, struct domai= n *d) { - return xsm_ops.init_hardware_domain(d); + return alternative_call(xsm_ops.init_hardware_domain, d); } =20 static inline int xsm_get_pod_target(xsm_default_t def, struct domain *d) { - return xsm_ops.get_pod_target(d); + return alternative_call(xsm_ops.get_pod_target, d); } =20 static inline int xsm_set_pod_target(xsm_default_t def, struct domain *d) { - return xsm_ops.set_pod_target(d); + return alternative_call(xsm_ops.set_pod_target, d); } =20 static inline int xsm_memory_exchange(xsm_default_t def, struct domain *d) { - return xsm_ops.memory_exchange(d); + return alternative_call(xsm_ops.memory_exchange, d); } =20 static inline int xsm_memory_adjust_reservation( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.memory_adjust_reservation(d1, d2); + return alternative_call(xsm_ops.memory_adjust_reservation, d1, d2); } =20 static inline int xsm_memory_stat_reservation( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.memory_stat_reservation(d1, d2); + return alternative_call(xsm_ops.memory_stat_reservation, d1, d2); } =20 static inline int xsm_memory_pin_page( xsm_default_t def, struct domain *d1, struct domain *d2, struct page_info *page) { - return xsm_ops.memory_pin_page(d1, d2, page); + return alternative_call(xsm_ops.memory_pin_page, d1, d2, page); } =20 static inline int xsm_add_to_physmap( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.add_to_physmap(d1, d2); + return alternative_call(xsm_ops.add_to_physmap, d1, d2); } =20 static inline int xsm_remove_from_physmap( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.remove_from_physmap(d1, d2); + return alternative_call(xsm_ops.remove_from_physmap, d1, d2); } =20 static inline int xsm_map_gmfn_foreign( xsm_default_t def, struct domain *d, struct domain *t) { - return xsm_ops.map_gmfn_foreign(d, t); + return alternative_call(xsm_ops.map_gmfn_foreign, d, t); } =20 static inline int xsm_claim_pages(xsm_default_t def, struct domain *d) { - return xsm_ops.claim_pages(d); + return alternative_call(xsm_ops.claim_pages, d); } =20 static inline int xsm_console_io(xsm_default_t def, struct domain *d, int = cmd) { - return xsm_ops.console_io(d, cmd); + return alternative_call(xsm_ops.console_io, d, cmd); } =20 static inline int xsm_profile(xsm_default_t def, struct domain *d, int op) { - return xsm_ops.profile(d, op); + return alternative_call(xsm_ops.profile, d, op); } =20 static inline int xsm_kexec(xsm_default_t def) { - return xsm_ops.kexec(); + return alternative_call(xsm_ops.kexec); } =20 static inline int xsm_schedop_shutdown( xsm_default_t def, struct domain *d1, struct domain *d2) { - return xsm_ops.schedop_shutdown(d1, d2); + return alternative_call(xsm_ops.schedop_shutdown, d1, d2); } =20 static inline char *xsm_show_irq_sid(int irq) { - return xsm_ops.show_irq_sid(irq); + return alternative_call(xsm_ops.show_irq_sid, irq); } =20 static inline int xsm_map_domain_pirq(xsm_default_t def, struct domain *d) { - return xsm_ops.map_domain_pirq(d); + return alternative_call(xsm_ops.map_domain_pirq, d); } =20 static inline int xsm_map_domain_irq( xsm_default_t def, struct domain *d, int irq, void *data) { - return xsm_ops.map_domain_irq(d, irq, data); + return alternative_call(xsm_ops.map_domain_irq, d, irq, data); } =20 static inline int xsm_unmap_domain_pirq(xsm_default_t def, struct domain *= d) { - return xsm_ops.unmap_domain_pirq(d); + return alternative_call(xsm_ops.unmap_domain_pirq, d); } =20 static inline int xsm_unmap_domain_irq( xsm_default_t def, struct domain *d, int irq, void *data) { - return xsm_ops.unmap_domain_irq(d, irq, data); + return alternative_call(xsm_ops.unmap_domain_irq, d, irq, data); } =20 static inline int xsm_bind_pt_irq( xsm_default_t def, struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd) { - return xsm_ops.bind_pt_irq(d, bind); + return alternative_call(xsm_ops.bind_pt_irq, d, bind); } =20 static inline int xsm_unbind_pt_irq( xsm_default_t def, struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd) { - return xsm_ops.unbind_pt_irq(d, bind); + return alternative_call(xsm_ops.unbind_pt_irq, d, bind); } =20 static inline int xsm_irq_permission( xsm_default_t def, struct domain *d, int pirq, uint8_t allow) { - return xsm_ops.irq_permission(d, pirq, allow); + return alternative_call(xsm_ops.irq_permission, d, pirq, allow); } =20 static inline int xsm_iomem_permission( xsm_default_t def, struct domain *d, uint64_t s, uint64_t e, uint8_t a= llow) { - return xsm_ops.iomem_permission(d, s, e, allow); + return alternative_call(xsm_ops.iomem_permission, d, s, e, allow); } =20 static inline int xsm_iomem_mapping( xsm_default_t def, struct domain *d, uint64_t s, uint64_t e, uint8_t a= llow) { - return xsm_ops.iomem_mapping(d, s, e, allow); + return alternative_call(xsm_ops.iomem_mapping, d, s, e, allow); } =20 static inline int xsm_pci_config_permission( xsm_default_t def, struct domain *d, uint32_t machine_bdf, uint16_t st= art, uint16_t end, uint8_t access) { - return xsm_ops.pci_config_permission(d, machine_bdf, start, end, acces= s); + return alternative_call(xsm_ops.pci_config_permission, d, machine_bdf,= start, end, access); } =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) static inline int xsm_get_device_group(xsm_default_t def, uint32_t machine= _bdf) { - return xsm_ops.get_device_group(machine_bdf); + return alternative_call(xsm_ops.get_device_group, machine_bdf); } =20 static inline int xsm_assign_device( xsm_default_t def, struct domain *d, uint32_t machine_bdf) { - return xsm_ops.assign_device(d, machine_bdf); + return alternative_call(xsm_ops.assign_device, d, machine_bdf); } =20 static inline int xsm_deassign_device( xsm_default_t def, struct domain *d, uint32_t machine_bdf) { - return xsm_ops.deassign_device(d, machine_bdf); + return alternative_call(xsm_ops.deassign_device, d, machine_bdf); } #endif /* HAS_PASSTHROUGH && HAS_PCI) */ =20 @@ -518,62 +519,62 @@ static inline int xsm_deassign_device( static inline int xsm_assign_dtdevice( xsm_default_t def, struct domain *d, const char *dtpath) { - return xsm_ops.assign_dtdevice(d, dtpath); + return alternative_call(xsm_ops.assign_dtdevice, d, dtpath); } =20 static inline int xsm_deassign_dtdevice( xsm_default_t def, struct domain *d, const char *dtpath) { - return xsm_ops.deassign_dtdevice(d, dtpath); + return alternative_call(xsm_ops.deassign_dtdevice, d, dtpath); } =20 #endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ =20 static inline int xsm_resource_plug_pci(xsm_default_t def, uint32_t machin= e_bdf) { - return xsm_ops.resource_plug_pci(machine_bdf); + return alternative_call(xsm_ops.resource_plug_pci, machine_bdf); } =20 static inline int xsm_resource_unplug_pci( xsm_default_t def, uint32_t machine_bdf) { - return xsm_ops.resource_unplug_pci(machine_bdf); + return alternative_call(xsm_ops.resource_unplug_pci, machine_bdf); } =20 static inline int xsm_resource_plug_core(xsm_default_t def) { - return xsm_ops.resource_plug_core(); + return alternative_call(xsm_ops.resource_plug_core); } =20 static inline int xsm_resource_unplug_core(xsm_default_t def) { - return xsm_ops.resource_unplug_core(); + return alternative_call(xsm_ops.resource_unplug_core); } =20 static inline int xsm_resource_setup_pci( xsm_default_t def, uint32_t machine_bdf) { - return xsm_ops.resource_setup_pci(machine_bdf); + return alternative_call(xsm_ops.resource_setup_pci, machine_bdf); } =20 static inline int xsm_resource_setup_gsi(xsm_default_t def, int gsi) { - return xsm_ops.resource_setup_gsi(gsi); + return alternative_call(xsm_ops.resource_setup_gsi, gsi); } =20 static inline int xsm_resource_setup_misc(xsm_default_t def) { - return xsm_ops.resource_setup_misc(); + return alternative_call(xsm_ops.resource_setup_misc); } =20 static inline int xsm_page_offline(xsm_default_t def, uint32_t cmd) { - return xsm_ops.page_offline(cmd); + return alternative_call(xsm_ops.page_offline, cmd); } =20 static inline int xsm_hypfs_op(xsm_default_t def) { - return xsm_ops.hypfs_op(); + return alternative_call(xsm_ops.hypfs_op); } =20 static inline long xsm_do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) @@ -591,107 +592,107 @@ static inline int xsm_do_compat_op(XEN_GUEST_HANDLE= _PARAM(void) op) static inline int xsm_hvm_param( xsm_default_t def, struct domain *d, unsigned long op) { - return xsm_ops.hvm_param(d, op); + return alternative_call(xsm_ops.hvm_param, d, op); } =20 static inline int xsm_hvm_control( xsm_default_t def, struct domain *d, unsigned long op) { - return xsm_ops.hvm_control(d, op); + return alternative_call(xsm_ops.hvm_control, d, op); } =20 static inline int xsm_hvm_param_altp2mhvm(xsm_default_t def, struct domain= *d) { - return xsm_ops.hvm_param_altp2mhvm(d); + return alternative_call(xsm_ops.hvm_param_altp2mhvm, d); } =20 static inline int xsm_hvm_altp2mhvm_op( xsm_default_t def, struct domain *d, uint64_t mode, uint32_t op) { - return xsm_ops.hvm_altp2mhvm_op(d, mode, op); + return alternative_call(xsm_ops.hvm_altp2mhvm_op, d, mode, op); } =20 static inline int xsm_get_vnumainfo(xsm_default_t def, struct domain *d) { - return xsm_ops.get_vnumainfo(d); + return alternative_call(xsm_ops.get_vnumainfo, d); } =20 static inline int xsm_vm_event_control( xsm_default_t def, struct domain *d, int mode, int op) { - return xsm_ops.vm_event_control(d, mode, op); + return alternative_call(xsm_ops.vm_event_control, d, mode, op); } =20 #ifdef CONFIG_MEM_ACCESS static inline int xsm_mem_access(xsm_default_t def, struct domain *d) { - return xsm_ops.mem_access(d); + return alternative_call(xsm_ops.mem_access, d); } #endif =20 #ifdef CONFIG_MEM_PAGING static inline int xsm_mem_paging(xsm_default_t def, struct domain *d) { - return xsm_ops.mem_paging(d); + return alternative_call(xsm_ops.mem_paging, d); } #endif =20 #ifdef CONFIG_MEM_SHARING static inline int xsm_mem_sharing(xsm_default_t def, struct domain *d) { - return xsm_ops.mem_sharing(d); + return alternative_call(xsm_ops.mem_sharing, d); } #endif =20 static inline int xsm_platform_op(xsm_default_t def, uint32_t op) { - return xsm_ops.platform_op(op); + return alternative_call(xsm_ops.platform_op, op); } =20 #ifdef CONFIG_X86 static inline int xsm_do_mca(xsm_default_t def) { - return xsm_ops.do_mca(); + return alternative_call(xsm_ops.do_mca); } =20 static inline int xsm_shadow_control( xsm_default_t def, struct domain *d, uint32_t op) { - return xsm_ops.shadow_control(d, op); + return alternative_call(xsm_ops.shadow_control, d, op); } =20 static inline int xsm_mem_sharing_op( xsm_default_t def, struct domain *d, struct domain *cd, int op) { - return xsm_ops.mem_sharing_op(d, cd, op); + return alternative_call(xsm_ops.mem_sharing_op, d, cd, op); } =20 static inline int xsm_apic(xsm_default_t def, struct domain *d, int cmd) { - return xsm_ops.apic(d, cmd); + return alternative_call(xsm_ops.apic, d, cmd); } =20 static inline int xsm_machine_memory_map(xsm_default_t def) { - return xsm_ops.machine_memory_map(); + return alternative_call(xsm_ops.machine_memory_map); } =20 static inline int xsm_domain_memory_map(xsm_default_t def, struct domain *= d) { - return xsm_ops.domain_memory_map(d); + return alternative_call(xsm_ops.domain_memory_map, d); } =20 static inline int xsm_mmu_update( xsm_default_t def, struct domain *d, struct domain *t, struct domain *= f, uint32_t flags) { - return xsm_ops.mmu_update(d, t, f, flags); + return alternative_call(xsm_ops.mmu_update, d, t, f, flags); } =20 static inline int xsm_mmuext_op( xsm_default_t def, struct domain *d, struct domain *f) { - return xsm_ops.mmuext_op(d, f); + return alternative_call(xsm_ops.mmuext_op, d, f); } =20 static inline int xsm_update_va_mapping( @@ -703,64 +704,64 @@ static inline int xsm_update_va_mapping( static inline int xsm_priv_mapping( xsm_default_t def, struct domain *d, struct domain *t) { - return xsm_ops.priv_mapping(d, t); + return alternative_call(xsm_ops.priv_mapping, d, t); } =20 static inline int xsm_ioport_permission( xsm_default_t def, struct domain *d, uint32_t s, uint32_t e, uint8_t a= llow) { - return xsm_ops.ioport_permission(d, s, e, allow); + return alternative_call(xsm_ops.ioport_permission, d, s, e, allow); } =20 static inline int xsm_ioport_mapping( xsm_default_t def, struct domain *d, uint32_t s, uint32_t e, uint8_t a= llow) { - return xsm_ops.ioport_mapping(d, s, e, allow); + return alternative_call(xsm_ops.ioport_mapping, d, s, e, allow); } =20 static inline int xsm_pmu_op( xsm_default_t def, struct domain *d, unsigned int op) { - return xsm_ops.pmu_op(d, op); + return alternative_call(xsm_ops.pmu_op, d, op); } =20 #endif /* CONFIG_X86 */ =20 static inline int xsm_dm_op(xsm_default_t def, struct domain *d) { - return xsm_ops.dm_op(d); + return alternative_call(xsm_ops.dm_op, d); } =20 static inline int xsm_xen_version(xsm_default_t def, uint32_t op) { - return xsm_ops.xen_version(op); + return alternative_call(xsm_ops.xen_version, op); } =20 static inline int xsm_domain_resource_map(xsm_default_t def, struct domain= *d) { - return xsm_ops.domain_resource_map(d); + return alternative_call(xsm_ops.domain_resource_map, d); } =20 #ifdef CONFIG_ARGO static inline int xsm_argo_enable(const struct domain *d) { - return xsm_ops.argo_enable(d); + return alternative_call(xsm_ops.argo_enable, d); } =20 static inline int xsm_argo_register_single_source( const struct domain *d, const struct domain *t) { - return xsm_ops.argo_register_single_source(d, t); + return alternative_call(xsm_ops.argo_register_single_source, d, t); } =20 static inline int xsm_argo_register_any_source(const struct domain *d) { - return xsm_ops.argo_register_any_source(d); + return alternative_call(xsm_ops.argo_register_any_source, d); } =20 static inline int xsm_argo_send(const struct domain *d, const struct domai= n *t) { - return xsm_ops.argo_send(d, t); + return alternative_call(xsm_ops.argo_send, d, t); } =20 #endif /* CONFIG_ARGO */ --=20 2.20.1 From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290497; cv=pass; d=zohomail.com; s=zohoarc; b=RwLYUYB6rMla3ZXImwUMxg+esMYusvDClvuKU8K73g2MlwiJ4/rVS57Dk4PpHyIZTUWoJD0TRyVhchSSOxeRk5+lZMZSURWVDx85ozIRlD4EoC+g3DNnEXEpUHnPu8skgrQvwZKi4cnfXtWNQoRdYJuKfrieLbTkhHDL+36LFbY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290497; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=U4vkiI6jA5JfL4SpY5vIqb7cvn2myZYK53ZNu0HWpvw=; b=gZWnx6lkxk5sg551wY8JsAJr8CUYFrx74IDDzm+jhu/ADWJllDiwa4WsTG6K/b8n9NxqoJAilVMfo/At9Lxn5nTlul4tcx+o9VErC8dVYeV9eReSdNDvaxL7NpCajv1Bw00h5cxZQ+DLGKpSsw6eb4IrwYd0QOJBDLLWRY8xx2I= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631290497719583.7409290073299; Fri, 10 Sep 2021 09:14:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184630.333356 (Exim 4.92) (envelope-from ) id 1mOjAn-0002R8-Tx; Fri, 10 Sep 2021 16:14:41 +0000 Received: by outflank-mailman (output) from mailman id 184630.333356; Fri, 10 Sep 2021 16:14:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOjAn-0002Qz-QM; Fri, 10 Sep 2021 16:14:41 +0000 Received: by outflank-mailman (input) for mailman id 184630; Fri, 10 Sep 2021 16:14:40 +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 ) id 1mOjAm-0002BT-9D for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:14:40 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 313b4880-1252-11ec-b254-12813bfff9fa; Fri, 10 Sep 2021 16:14:37 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1631290383073126.11756631031028; Fri, 10 Sep 2021 09:13:03 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 313b4880-1252-11ec-b254-12813bfff9fa ARC-Seal: i=1; a=rsa-sha256; t=1631290387; cv=none; d=zohomail.com; s=zohoarc; b=kmr7QhAEn2CC6arXUVSB1zGITc8hi+KffyslYNzn1BmOT6DsIFKc+yBImn0Lu33uTcowuP1xaCevrZfNaFRQLPuXiDyMS75IUgOW1s0LSXDczBH2YDXQdygaZbC+e+ElBkGxaPCGwPmnK8iupbhuCtNOQ1/F2hrkGGfRvIrfDpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290387; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=U4vkiI6jA5JfL4SpY5vIqb7cvn2myZYK53ZNu0HWpvw=; b=DaRw+ncpJUt5UzcyyCcdUiVm5xmcd3T2Gx29P0QntrtkpUpxQjvVEJGxtVXMyf5noTn6vcD40GAzE+Qe6BBbeMkqtCHU2RC660Rj4gqnaTmSGIxfP5wFSjyfV+BJI29TEpQhpiYB/DIaxr17wqC9EKr8ELDqKsbzumbIzFaI22U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290387; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=U4vkiI6jA5JfL4SpY5vIqb7cvn2myZYK53ZNu0HWpvw=; b=FAicfY6jCy3hHmBNgnQIC5bvg6zpCpfSNFZp2cxcRcHkeUvwjIORdzYS1WErMsow DRgxU62pNRf35tVQ5MX+ghtlC9ZZOUsBNEcQIKZlSWsPVA0wpfO7MMhIVCm4CLlL/xD 01rn4Qz3ciHd94apLhcRrfGx1+feqWsdYzyLC8ac= From: "Daniel P. Smith" To: "Daniel P. Smith" , xen-devel@lists.xenproject.org Cc: Daniel De Graaf Subject: [PATCH v6 08/10] xsm: decouple xsm header inclusion selection Date: Fri, 10 Sep 2021 16:13:03 -0400 Message-Id: <20210910201305.32526-9-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290499211100005 Content-Type: text/plain; charset="utf-8" Multiple preprocessor defines were used as a mechanism to selective include parts of the xsm.h header file. This makes it difficult to know which porti= on is being included at any one time. This commit works to simplify this by separating the core structures and functions of XSM into xsm-core.h away fr= om the wrapper functions which remain in xsm.h and dummy.h. Signed-off-by: Daniel P. Smith --- xen/include/xsm/dummy.h | 2 +- xen/include/xsm/xsm-core.h | 267 +++++++++++++++++++++++++++++++++++++ xen/include/xsm/xsm.h | 248 +--------------------------------- xen/xsm/dummy.c | 1 - xen/xsm/silo.c | 2 +- xen/xsm/xsm_core.c | 5 + 6 files changed, 275 insertions(+), 250 deletions(-) create mode 100644 xen/include/xsm/xsm-core.h diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index 3b1b378b58..be8877a195 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -16,7 +16,7 @@ */ =20 #include -#include +#include #include =20 /* diff --git a/xen/include/xsm/xsm-core.h b/xen/include/xsm/xsm-core.h new file mode 100644 index 0000000000..3c4a25d7fc --- /dev/null +++ b/xen/include/xsm/xsm-core.h @@ -0,0 +1,267 @@ +/* + * This file contains the XSM hook definitions for Xen. + * + * This work is based on the LSM implementation in Linux 2.6.13.4. + * + * Author: George Coker, + * + * Contributors: Michael LeMay, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + */ + +#ifndef __XSM_CORE_H__ +#define __XSM_CORE_H__ + +#include +#include + +/* policy magic number */ +typedef uint32_t xsm_magic_t; + +#ifdef CONFIG_XSM_FLASK +#define XSM_MAGIC 0xf97cff8c +#else +#define XSM_MAGIC 0x0 +#endif + +/* + * These annotations are used by callers and in dummy.h to document the + * default actions of XSM hooks. They should be compiled out otherwise. + */ +enum xsm_default { + XSM_HOOK, /* Guests can normally access the hypercall */ + XSM_DM_PRIV, /* Device model can perform on its target domain */ + XSM_TARGET, /* Can perform on self or your target domain */ + XSM_PRIV, /* Privileged - normally restricted to dom0 */ + XSM_XS_PRIV, /* Xenstore domain - can do some privileged operations */ + XSM_OTHER /* Something more complex */ +}; +typedef enum xsm_default xsm_default_t; + +struct xsm_ops { + void (*security_domaininfo)(struct domain *d, + struct xen_domctl_getdomaininfo *info); + int (*domain_create)(struct domain *d, uint32_t ssidref); + int (*getdomaininfo)(struct domain *d); + int (*domctl_scheduler_op)(struct domain *d, int op); + int (*sysctl_scheduler_op)(int op); + int (*set_target)(struct domain *d, struct domain *e); + int (*domctl)(struct domain *d, int cmd); + int (*sysctl)(int cmd); + int (*readconsole)(uint32_t clear); + + int (*evtchn_unbound)(struct domain *d, struct evtchn *chn, domid_t id= 2); + int (*evtchn_interdomain)(struct domain *d1, struct evtchn *chn1, + struct domain *d2, struct evtchn *chn2); + void (*evtchn_close_post)(struct evtchn *chn); + int (*evtchn_send)(struct domain *d, struct evtchn *chn); + int (*evtchn_status)(struct domain *d, struct evtchn *chn); + int (*evtchn_reset)(struct domain *d1, struct domain *d2); + + int (*grant_mapref)(struct domain *d1, struct domain *d2, uint32_t fla= gs); + int (*grant_unmapref)(struct domain *d1, struct domain *d2); + int (*grant_setup)(struct domain *d1, struct domain *d2); + int (*grant_transfer)(struct domain *d1, struct domain *d2); + int (*grant_copy)(struct domain *d1, struct domain *d2); + int (*grant_query_size)(struct domain *d1, struct domain *d2); + + int (*alloc_security_domain)(struct domain *d); + void (*free_security_domain)(struct domain *d); + int (*alloc_security_evtchns)(struct evtchn chn[], unsigned int nr); + void (*free_security_evtchns)(struct evtchn chn[], unsigned int nr); + char *(*show_security_evtchn)(struct domain *d, const struct evtchn *c= hn); + int (*init_hardware_domain)(struct domain *d); + + int (*get_pod_target)(struct domain *d); + int (*set_pod_target)(struct domain *d); + int (*memory_exchange)(struct domain *d); + int (*memory_adjust_reservation)(struct domain *d1, struct domain *d2); + int (*memory_stat_reservation)(struct domain *d1, struct domain *d2); + int (*memory_pin_page)(struct domain *d1, struct domain *d2, + struct page_info *page); + int (*add_to_physmap)(struct domain *d1, struct domain *d2); + int (*remove_from_physmap)(struct domain *d1, struct domain *d2); + int (*map_gmfn_foreign)(struct domain *d, struct domain *t); + int (*claim_pages)(struct domain *d); + + int (*console_io)(struct domain *d, int cmd); + + int (*profile)(struct domain *d, int op); + + int (*kexec)(void); + int (*schedop_shutdown)(struct domain *d1, struct domain *d2); + + char *(*show_irq_sid)(int irq); + int (*map_domain_pirq)(struct domain *d); + int (*map_domain_irq)(struct domain *d, int irq, const void *data); + int (*unmap_domain_pirq)(struct domain *d); + int (*unmap_domain_irq)(struct domain *d, int irq, const void *data); + int (*bind_pt_irq)(struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd); + int (*unbind_pt_irq)(struct domain *d, struct xen_domctl_bind_pt_irq *= bind); + int (*irq_permission)(struct domain *d, int pirq, uint8_t allow); + int (*iomem_permission)(struct domain *d, uint64_t s, uint64_t e, + uint8_t allow); + int (*iomem_mapping)(struct domain *d, uint64_t s, uint64_t e, + uint8_t allow); + int (*pci_config_permission)(struct domain *d, uint32_t machine_bdf, + uint16_t start, uint16_t end, uint8_t acc= ess); + +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) + int (*get_device_group)(uint32_t machine_bdf); + int (*assign_device)(struct domain *d, uint32_t machine_bdf); + int (*deassign_device)(struct domain *d, uint32_t machine_bdf); +#endif + +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) + int (*assign_dtdevice)(struct domain *d, const char *dtpath); + int (*deassign_dtdevice)(struct domain *d, const char *dtpath); +#endif + + int (*resource_plug_core)(void); + int (*resource_unplug_core)(void); + int (*resource_plug_pci)(uint32_t machine_bdf); + int (*resource_unplug_pci)(uint32_t machine_bdf); + int (*resource_setup_pci)(uint32_t machine_bdf); + int (*resource_setup_gsi)(int gsi); + int (*resource_setup_misc)(void); + + int (*page_offline)(uint32_t cmd); + int (*hypfs_op)(void); + + long (*do_xsm_op)(XEN_GUEST_HANDLE_PARAM(void) op); +#ifdef CONFIG_COMPAT + int (*do_compat_op)(XEN_GUEST_HANDLE_PARAM(void) op); +#endif + + int (*hvm_param)(struct domain *d, unsigned long op); + int (*hvm_control)(struct domain *d, unsigned long op); + int (*hvm_param_altp2mhvm)(struct domain *d); + int (*hvm_altp2mhvm_op)(struct domain *d, uint64_t mode, uint32_t op); + int (*get_vnumainfo)(struct domain *d); + + int (*vm_event_control)(struct domain *d, int mode, int op); + +#ifdef CONFIG_MEM_ACCESS + int (*mem_access)(struct domain *d); +#endif + +#ifdef CONFIG_MEM_PAGING + int (*mem_paging)(struct domain *d); +#endif + +#ifdef CONFIG_MEM_SHARING + int (*mem_sharing)(struct domain *d); +#endif + + int (*platform_op)(uint32_t cmd); + +#ifdef CONFIG_X86 + int (*do_mca)(void); + int (*shadow_control)(struct domain *d, uint32_t op); + int (*mem_sharing_op)(struct domain *d, struct domain *cd, int op); + int (*apic)(struct domain *d, int cmd); + int (*machine_memory_map)(void); + int (*domain_memory_map)(struct domain *d); +#define XSM_MMU_UPDATE_READ 1 +#define XSM_MMU_UPDATE_WRITE 2 +#define XSM_MMU_NORMAL_UPDATE 4 +#define XSM_MMU_MACHPHYS_UPDATE 8 + int (*mmu_update)(struct domain *d, struct domain *t, + struct domain *f, uint32_t flags); + int (*mmuext_op)(struct domain *d, struct domain *f); + int (*update_va_mapping)(struct domain *d, struct domain *f, + l1_pgentry_t pte); + int (*priv_mapping)(struct domain *d, struct domain *t); + int (*ioport_permission)(struct domain *d, uint32_t s, uint32_t e, + uint8_t allow); + int (*ioport_mapping)(struct domain *d, uint32_t s, uint32_t e, + uint8_t allow); + int (*pmu_op)(struct domain *d, unsigned int op); +#endif + + int (*dm_op)(struct domain *d); + + int (*xen_version)(uint32_t cmd); + + int (*domain_resource_map)(struct domain *d); + +#ifdef CONFIG_ARGO + int (*argo_enable)(const struct domain *d); + int (*argo_register_single_source)(const struct domain *d, + const struct domain *t); + int (*argo_register_any_source)(const struct domain *d); + int (*argo_send)(const struct domain *d, const struct domain *t); +#endif +}; + +void xsm_fixup_ops(struct xsm_ops *ops); + +#ifdef CONFIG_XSM + +#ifdef CONFIG_MULTIBOOT +int xsm_multiboot_init( + unsigned long *module_map, const multiboot_info_t *mbi); +int xsm_multiboot_policy_init( + unsigned long *module_map, const multiboot_info_t *mbi, + void **policy_buffer, size_t *policy_size); +#endif + +#ifdef CONFIG_HAS_DEVICE_TREE +/* + * Initialize XSM + * + * On success, return 1 if using SILO mode else 0. + */ +int xsm_dt_init(void); +int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size); +bool has_xsm_magic(paddr_t); +#endif + +#ifdef CONFIG_XSM_FLASK +const struct xsm_ops *flask_init( + const void *policy_buffer, size_t policy_size); +#else +static inline const struct xsm_ops *flask_init( + const void *policy_buffer, size_t policy_size) +{ + return NULL; +} +#endif + +#ifdef CONFIG_XSM_SILO +const struct xsm_ops *silo_init(void); +#else +static const inline struct xsm_ops *silo_init(void) +{ + return NULL; +} +#endif + +#else /* CONFIG_XSM */ + +#ifdef CONFIG_MULTIBOOT +static inline int xsm_multiboot_init( + unsigned long *module_map, const multiboot_info_t *mbi) +{ + return 0; +} +#endif + +#ifdef CONFIG_HAS_DEVICE_TREE +static inline int xsm_dt_init(void) +{ + return 0; +} + +static inline bool has_xsm_magic(paddr_t start) +{ + return false; +} +#endif /* CONFIG_HAS_DEVICE_TREE */ + +#endif /* CONFIG_XSM */ + +#endif /* __XSM_CORE_H */ diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index c101e653f6..7b1611d10b 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -18,188 +18,12 @@ #include #include #include - -/* policy magic number (defined by XSM_MAGIC) */ -typedef uint32_t xsm_magic_t; - -#ifdef CONFIG_XSM_FLASK -#define XSM_MAGIC 0xf97cff8c -#else -#define XSM_MAGIC 0x0 -#endif - -/* - * These annotations are used by callers and in dummy.h to document the - * default actions of XSM hooks. They should be compiled out otherwise. - */ -enum xsm_default { - XSM_HOOK, /* Guests can normally access the hypercall */ - XSM_DM_PRIV, /* Device model can perform on its target domain */ - XSM_TARGET, /* Can perform on self or your target domain */ - XSM_PRIV, /* Privileged - normally restricted to dom0 */ - XSM_XS_PRIV, /* Xenstore domain - can do some privileged operations */ - XSM_OTHER /* Something more complex */ -}; -typedef enum xsm_default xsm_default_t; - -struct xsm_ops { - void (*security_domaininfo)(struct domain *d, - struct xen_domctl_getdomaininfo *info); - int (*domain_create)(struct domain *d, uint32_t ssidref); - int (*getdomaininfo)(struct domain *d); - int (*domctl_scheduler_op)(struct domain *d, int op); - int (*sysctl_scheduler_op)(int op); - int (*set_target)(struct domain *d, struct domain *e); - int (*domctl)(struct domain *d, int cmd); - int (*sysctl)(int cmd); - int (*readconsole)(uint32_t clear); - - int (*evtchn_unbound)(struct domain *d, struct evtchn *chn, domid_t id= 2); - int (*evtchn_interdomain)(struct domain *d1, struct evtchn *chn1, - struct domain *d2, struct evtchn *chn2); - void (*evtchn_close_post)(struct evtchn *chn); - int (*evtchn_send)(struct domain *d, struct evtchn *chn); - int (*evtchn_status)(struct domain *d, struct evtchn *chn); - int (*evtchn_reset)(struct domain *d1, struct domain *d2); - - int (*grant_mapref)(struct domain *d1, struct domain *d2, uint32_t fla= gs); - int (*grant_unmapref)(struct domain *d1, struct domain *d2); - int (*grant_setup)(struct domain *d1, struct domain *d2); - int (*grant_transfer)(struct domain *d1, struct domain *d2); - int (*grant_copy)(struct domain *d1, struct domain *d2); - int (*grant_query_size)(struct domain *d1, struct domain *d2); - - int (*alloc_security_domain)(struct domain *d); - void (*free_security_domain)(struct domain *d); - int (*alloc_security_evtchns)(struct evtchn chn[], unsigned int nr); - void (*free_security_evtchns)(struct evtchn chn[], unsigned int nr); - char *(*show_security_evtchn)(struct domain *d, const struct evtchn *c= hn); - int (*init_hardware_domain)(struct domain *d); - - int (*get_pod_target)(struct domain *d); - int (*set_pod_target)(struct domain *d); - int (*memory_exchange)(struct domain *d); - int (*memory_adjust_reservation)(struct domain *d1, struct domain *d2); - int (*memory_stat_reservation)(struct domain *d1, struct domain *d2); - int (*memory_pin_page)(struct domain *d1, struct domain *d2, - struct page_info *page); - int (*add_to_physmap)(struct domain *d1, struct domain *d2); - int (*remove_from_physmap)(struct domain *d1, struct domain *d2); - int (*map_gmfn_foreign)(struct domain *d, struct domain *t); - int (*claim_pages)(struct domain *d); - - int (*console_io)(struct domain *d, int cmd); - - int (*profile)(struct domain *d, int op); - - int (*kexec)(void); - int (*schedop_shutdown)(struct domain *d1, struct domain *d2); - - char *(*show_irq_sid)(int irq); - int (*map_domain_pirq)(struct domain *d); - int (*map_domain_irq)(struct domain *d, int irq, const void *data); - int (*unmap_domain_pirq)(struct domain *d); - int (*unmap_domain_irq)(struct domain *d, int irq, const void *data); - int (*bind_pt_irq)(struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd); - int (*unbind_pt_irq)(struct domain *d, struct xen_domctl_bind_pt_irq *= bind); - int (*irq_permission)(struct domain *d, int pirq, uint8_t allow); - int (*iomem_permission)(struct domain *d, uint64_t s, uint64_t e, - uint8_t allow); - int (*iomem_mapping)(struct domain *d, uint64_t s, uint64_t e, - uint8_t allow); - int (*pci_config_permission)(struct domain *d, uint32_t machine_bdf, - uint16_t start, uint16_t end, uint8_t acc= ess); - -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) - int (*get_device_group)(uint32_t machine_bdf); - int (*assign_device)(struct domain *d, uint32_t machine_bdf); - int (*deassign_device)(struct domain *d, uint32_t machine_bdf); -#endif - -#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) - int (*assign_dtdevice)(struct domain *d, const char *dtpath); - int (*deassign_dtdevice)(struct domain *d, const char *dtpath); -#endif - - int (*resource_plug_core)(void); - int (*resource_unplug_core)(void); - int (*resource_plug_pci)(uint32_t machine_bdf); - int (*resource_unplug_pci)(uint32_t machine_bdf); - int (*resource_setup_pci)(uint32_t machine_bdf); - int (*resource_setup_gsi)(int gsi); - int (*resource_setup_misc)(void); - - int (*page_offline)(uint32_t cmd); - int (*hypfs_op)(void); - - long (*do_xsm_op)(XEN_GUEST_HANDLE_PARAM(void) op); -#ifdef CONFIG_COMPAT - int (*do_compat_op)(XEN_GUEST_HANDLE_PARAM(void) op); -#endif - - int (*hvm_param)(struct domain *d, unsigned long op); - int (*hvm_control)(struct domain *d, unsigned long op); - int (*hvm_param_altp2mhvm)(struct domain *d); - int (*hvm_altp2mhvm_op)(struct domain *d, uint64_t mode, uint32_t op); - int (*get_vnumainfo)(struct domain *d); - - int (*vm_event_control)(struct domain *d, int mode, int op); - -#ifdef CONFIG_MEM_ACCESS - int (*mem_access)(struct domain *d); -#endif - -#ifdef CONFIG_MEM_PAGING - int (*mem_paging)(struct domain *d); -#endif - -#ifdef CONFIG_MEM_SHARING - int (*mem_sharing)(struct domain *d); -#endif - - int (*platform_op)(uint32_t cmd); - -#ifdef CONFIG_X86 - int (*do_mca)(void); - int (*shadow_control)(struct domain *d, uint32_t op); - int (*mem_sharing_op)(struct domain *d, struct domain *cd, int op); - int (*apic)(struct domain *d, int cmd); - int (*machine_memory_map)(void); - int (*domain_memory_map)(struct domain *d); -#define XSM_MMU_UPDATE_READ 1 -#define XSM_MMU_UPDATE_WRITE 2 -#define XSM_MMU_NORMAL_UPDATE 4 -#define XSM_MMU_MACHPHYS_UPDATE 8 - int (*mmu_update)(struct domain *d, struct domain *t, - struct domain *f, uint32_t flags); - int (*mmuext_op)(struct domain *d, struct domain *f); - int (*update_va_mapping)(struct domain *d, struct domain *f, - l1_pgentry_t pte); - int (*priv_mapping)(struct domain *d, struct domain *t); - int (*ioport_permission)(struct domain *d, uint32_t s, uint32_t e, - uint8_t allow); - int (*ioport_mapping)(struct domain *d, uint32_t s, uint32_t e, - uint8_t allow); - int (*pmu_op)(struct domain *d, unsigned int op); -#endif - int (*dm_op)(struct domain *d); - int (*xen_version)(uint32_t cmd); - int (*domain_resource_map)(struct domain *d); -#ifdef CONFIG_ARGO - int (*argo_enable)(const struct domain *d); - int (*argo_register_single_source)(const struct domain *d, - const struct domain *t); - int (*argo_register_any_source)(const struct domain *d); - int (*argo_send)(const struct domain *d, const struct domain *t); -#endif -}; +#include =20 #ifdef CONFIG_XSM =20 extern struct xsm_ops xsm_ops; =20 -#ifndef XSM_NO_WRAPPERS - static inline void xsm_security_domaininfo( struct domain *d, struct xen_domctl_getdomaininfo *info) { @@ -766,80 +590,10 @@ static inline int xsm_argo_send(const struct domain *= d, const struct domain *t) =20 #endif /* CONFIG_ARGO */ =20 -#endif /* XSM_NO_WRAPPERS */ - -#ifdef CONFIG_MULTIBOOT -int xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi); -int xsm_multiboot_policy_init( - unsigned long *module_map, const multiboot_info_t *mbi, - void **policy_buffer, size_t *policy_size); -#endif - -#ifdef CONFIG_HAS_DEVICE_TREE -/* - * Initialize XSM - * - * On success, return 1 if using SILO mode else 0. - */ -int xsm_dt_init(void); -int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size); -bool has_xsm_magic(paddr_t); -#endif - -extern struct xsm_ops dummy_xsm_ops; - -void xsm_fixup_ops(struct xsm_ops *ops); - -#ifdef CONFIG_XSM_FLASK -extern const struct xsm_ops *flask_init(const void *policy_buffer, - size_t policy_size); -#else -static const inline struct xsm_ops *flask_init(const void *policy_buffer, - size_t policy_size) -{ - return NULL; -} -#endif - -#ifdef CONFIG_XSM_FLASK_POLICY -extern const unsigned char xsm_flask_init_policy[]; -extern const unsigned int xsm_flask_init_policy_size; -#endif - -#ifdef CONFIG_XSM_SILO -extern const struct xsm_ops *silo_init(void); -#else -static const inline struct xsm_ops *silo_init(void) -{ - return NULL; -} -#endif - #else /* CONFIG_XSM */ =20 #include =20 -#ifdef CONFIG_MULTIBOOT -static inline int xsm_multiboot_init ( - unsigned long *module_map, const multiboot_info_t *mbi) -{ - return 0; -} -#endif - -#ifdef CONFIG_HAS_DEVICE_TREE -static inline int xsm_dt_init(void) -{ - return 0; -} - -static inline bool has_xsm_magic(paddr_t start) -{ - return false; -} -#endif /* CONFIG_HAS_DEVICE_TREE */ - #endif /* CONFIG_XSM */ =20 #endif /* __XSM_H */ diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index d8c935328e..b848580eaa 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -10,7 +10,6 @@ * as published by the Free Software Foundation. */ =20 -#define XSM_NO_WRAPPERS #include =20 #define set_to_dummy_if_null(ops, function) \ diff --git a/xen/xsm/silo.c b/xen/xsm/silo.c index 3550dded7b..66a2cb1505 100644 --- a/xen/xsm/silo.c +++ b/xen/xsm/silo.c @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License along= with * this program; If not, see . */ -#define XSM_NO_WRAPPERS +#include #include =20 /* diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 21fffbcb41..e1fe4e66a7 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -32,6 +32,11 @@ =20 struct xsm_ops __read_mostly xsm_ops; =20 +#ifdef CONFIG_XSM_FLASK_POLICY +extern const unsigned char xsm_flask_init_policy[]; +extern const unsigned int xsm_flask_init_policy_size; +#endif + enum xsm_ops_state { XSM_OPS_UNREGISTERED, XSM_OPS_REG_FAILED, --=20 2.20.1 From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290508; cv=pass; d=zohomail.com; s=zohoarc; b=m0O9oZXRXftZNj5dxuN+QmC0dSLfBAndDgrcz+IouiYrLJlhSBqsNzBUf/+39NO5Nf2TxwqTemse9tHQ8NTm1gBjUXdzM8kJLJdMkqEHw/fK1QRnAFovQ49W7VIEleX07a+2pJ91jQqixpzIC4XKfk7dlSirSPsvAYprdQdcfZU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290508; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jZDCRllTZCiN1iiOgOzXnECMuRaKvU/NWYVDT7sgqzA=; b=Szqbx+Jo9apmGTLKr8Kt1ERUUF1EWtY7o7Je1NgE2/b1rnBwBfw3f22woQlhyBPL+LbPzrF9gW+OOOGx/8ggKLnI/BmpFkSl7SmcX0QyuNsT0+6hirgagqeIOpOc5ONcbQrKLg20E9pk4JcaGYYNWaKvpdJhJ4kP2A7G+sz8isM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631290508446544.5355468972242; Fri, 10 Sep 2021 09:15:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184634.333367 (Exim 4.92) (envelope-from ) id 1mOjB0-00034R-C7; Fri, 10 Sep 2021 16:14:54 +0000 Received: by outflank-mailman (output) from mailman id 184634.333367; Fri, 10 Sep 2021 16:14:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOjB0-00034I-7C; Fri, 10 Sep 2021 16:14:54 +0000 Received: by outflank-mailman (input) for mailman id 184634; Fri, 10 Sep 2021 16:14: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 ) id 1mOjAy-0002zi-Hb for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:14:52 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 3991169a-1252-11ec-b254-12813bfff9fa; Fri, 10 Sep 2021 16:14:51 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1631290384333494.1230487143405; Fri, 10 Sep 2021 09:13:04 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3991169a-1252-11ec-b254-12813bfff9fa ARC-Seal: i=1; a=rsa-sha256; t=1631290388; cv=none; d=zohomail.com; s=zohoarc; b=Znt32WbdrCZ9UZmMCZr9wX8IyotivqfqP4pebYdnoqZfWYHythBprnt1aDrZivLThdU3hRwPdPchI0GswlfI4KWgBPw7w4EgYNJH8m+osU6KIAfAew/b0wDv3UpWbJr4ORb8N+hXTm4WCoHJF4WfHMtnLmrNez4layvLFhpwP14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290388; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=jZDCRllTZCiN1iiOgOzXnECMuRaKvU/NWYVDT7sgqzA=; b=ZFLBcMRy+oAUYrxf9X32UsbhaPyH2cIfRpwyrv7bHXGV0hblJhrJMLwIrel40FfktgqCzxsYL2jLjPAa0bkRg+KFBpG67LbO41itMCi0kRU0qISKInW7HsVl5gMTPYYCfyb569cbudgX9X6KFW8G4ZtuNTQcAaLL33PB8UAhVaE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290388; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=jZDCRllTZCiN1iiOgOzXnECMuRaKvU/NWYVDT7sgqzA=; b=gVtmlZl48kPW3qfkm1ZSZ/TBsAIj1kiyfvtWnvY9AfPRTBsmslhLXsUYnVt4aDpt siekwF9onwidKXBf0jp+in49e5uPjYxF3Oeq14iwaqEijLZ+lp5nOxGDHsn4wSv91dY NbgfBwM+vafJon8OdyMIx+mSmuoTPjjRTI67dBmo= From: "Daniel P. Smith" To: "Daniel P. Smith" , xen-devel@lists.xenproject.org Cc: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Daniel De Graaf Subject: [PATCH v6 09/10] kconfig: update xsm config to reflect reality Date: Fri, 10 Sep 2021 16:13:04 -0400 Message-Id: <20210910201305.32526-10-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290510253100001 Content-Type: text/plain; charset="utf-8" It has been a very long time since XSM Flask was the only XSM module, yet t= he concenpt of turning XSM on/off continues to be synonymous with enabling and disabling XSM Flask. Even when XSM Flask was the only module, turning XSM on/off did not disable or remove the XSM hooks but simply controlled whether they were implemented as direct inline functions or dispatch calls. This commit updates XSM kconfig to ensure that it is clear in the code as w= ell to the user, via the help messages, that the option is about configuring wh= ich XSM policy module(s) are available and which is the default. Signed-off-by: Daniel P. Smith --- xen/common/Kconfig | 49 ++++++++++++++++++-------------------- xen/include/xen/sched.h | 2 +- xen/include/xsm/dummy.h | 23 +++++++++--------- xen/include/xsm/xsm-core.h | 6 ++--- xen/include/xsm/xsm.h | 6 ++--- xen/xsm/Makefile | 4 ++-- xen/xsm/xsm_core.c | 4 ++-- 7 files changed, 46 insertions(+), 48 deletions(-) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index ac5491b1cc..2f85538920 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -200,23 +200,20 @@ config XENOPROF =20 If unsure, say Y. =20 -config XSM - bool "Xen Security Modules support" +config XSM_CONFIGURABLE + bool "Configure Xen Security Modules" default ARM - ---help--- - Enables the security framework known as Xen Security Modules which - allows administrators fine-grained control over a Xen domain and - its capabilities by defining permissible interactions between domains, - the hypervisor itself, and related resources such as memory and - devices. + help + Allows for configuring the Xen Security Modules (XSM) policy or policies + modules that will be availble and which will be the default. =20 If unsure, say N. =20 config XSM_FLASK - def_bool y - prompt "FLux Advanced Security Kernel support" - depends on XSM - ---help--- + bool "FLux Advanced Security Kernel support" + depends on XSM_CONFIGURABLE + select XSM_EVTCHN_LABELING + help Enables FLASK (FLux Advanced Security Kernel) as the access control mechanism used by the XSM framework. This provides a mandatory access control framework by which security enforcement, isolation, and @@ -226,10 +223,10 @@ config XSM_FLASK If unsure, say Y. =20 config XSM_FLASK_AVC_STATS - def_bool y - prompt "Maintain statistics on the FLASK access vector cache" if EXPERT + bool "Maintain statistics on the FLASK access vector cache" if EXPERT + default y depends on XSM_FLASK - ---help--- + help Maintain counters on the access vector cache that can be viewed using the FLASK_AVC_CACHESTATS sub-op of the xsm_op hypercall. Disabling this will save a tiny amount of memory and time to update the stats. @@ -240,7 +237,7 @@ config XSM_FLASK_POLICY bool "Compile Xen with a built-in FLASK security policy" default y if "$(XEN_HAS_CHECKPOLICY)" =3D "y" depends on XSM_FLASK - ---help--- + help This includes a default XSM policy in the hypervisor so that the bootloader does not need to load a policy to get sane behavior from an XSM-enabled hypervisor. If this is disabled, a policy must be @@ -253,10 +250,10 @@ config XSM_FLASK_POLICY If unsure, say Y. =20 config XSM_SILO - def_bool y - prompt "SILO support" - depends on XSM - ---help--- + bool "SILO support" + default y if ARM + depends on XSM_CONFIGURABLE + help Enables SILO as the access control mechanism used by the XSM framework. This is not the default module, add boot parameter xsm=3Dsilo to choose it. This will deny any unmediated communication channels (grant tables @@ -265,14 +262,14 @@ config XSM_SILO If unsure, say Y. =20 choice - prompt "Default XSM implementation" - depends on XSM + prompt "Default XSM module" + depends on XSM_CONFIGURABLE default XSM_SILO_DEFAULT if XSM_SILO && ARM default XSM_FLASK_DEFAULT if XSM_FLASK default XSM_SILO_DEFAULT if XSM_SILO default XSM_DUMMY_DEFAULT config XSM_DUMMY_DEFAULT - bool "Match non-XSM behavior" + bool "Classic Dom0 behavior" config XSM_FLASK_DEFAULT bool "FLux Advanced Security Kernel" if XSM_FLASK config XSM_SILO_DEFAULT @@ -282,15 +279,15 @@ endchoice config LATE_HWDOM bool "Dedicated hardware domain" default n - depends on XSM && X86 - ---help--- + depends on XSM_FLASK && X86 + help Allows the creation of a dedicated hardware domain distinct from domain 0 that manages devices without needing access to other privileged functionality such as the ability to manage domains. This requires that the actual domain 0 be a stub domain that constructs the actual hardware domain instead of initializing the hardware itself. Because the hardware domain needs access to - hypercalls not available to unprivileged guests, an XSM policy + hypercalls not available to unprivileged guests, an XSM Flask policy is required to properly define the privilege of these domains. =20 This feature does nothing if the "hardware_dom" boot parameter is diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 28146ee404..7f4bfa855b 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -120,7 +120,7 @@ struct evtchn unsigned short notify_vcpu_id; /* VCPU for local delivery notification= */ uint32_t fifo_lastq; /* Data for identifying last queue. */ =20 -#ifdef CONFIG_XSM +#ifdef CONFIG_XSM_CONFIGURABLE union { #ifdef XSM_NEED_GENERIC_EVTCHN_SSID /* diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index be8877a195..a0fe257b8e 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -43,13 +43,13 @@ static inline void __xsm_action_mismatch_detected(void) void __xsm_action_mismatch_detected(void); #endif =20 -#ifdef CONFIG_XSM +#ifdef CONFIG_XSM_CONFIGURABLE =20 /* - * In CONFIG_XSM builds, this header file is included from xsm/dummy.c, and - * contains static (not inline) functions compiled to the dummy XSM module. - * There is no xsm_default_t argument available, so the value from the ass= ertion - * is used to initialize the variable. + * In CONFIG_XSM_CONFIGURABLE builds, this header file is included from + * xsm/dummy.c, and contains static (not inline) functions compiled to the + * dummy XSM module. There is no xsm_default_t argument available, so the + * value from the assertion is used to initialize the variable. */ #define XSM_INLINE __maybe_unused =20 @@ -57,20 +57,21 @@ void __xsm_action_mismatch_detected(void); #define XSM_DEFAULT_VOID void #define XSM_ASSERT_ACTION(def) xsm_default_t action =3D def; (void)action =20 -#else /* CONFIG_XSM */ +#else /* CONFIG_XSM_CONFIGURABLE */ =20 /* - * In !CONFIG_XSM builds, this header file is included from xsm/xsm.h, and - * contains inline functions for each XSM hook. These functions also perfo= rm - * compile-time checks on the xsm_default_t argument to ensure that the be= havior - * of the dummy XSM module is the same as the behavior with XSM disabled. + * In !CONFIG_XSM_CONFIGURABLE builds, this header file is included from + * xsm/xsm.h, and contains inline functions for each XSM hook. These funct= ions + * also perform compile-time checks on the xsm_default_t argument to ensure + * that the behavior of the dummy XSM module is the same as the behavior w= ith + * XSM disabled. */ #define XSM_INLINE always_inline #define XSM_DEFAULT_ARG xsm_default_t action, #define XSM_DEFAULT_VOID xsm_default_t action #define XSM_ASSERT_ACTION(def) LINKER_BUG_ON(def !=3D action) =20 -#endif /* CONFIG_XSM */ +#endif /* CONFIG_XSM_CONFIGURABLE */ =20 static always_inline int xsm_default_action( xsm_default_t action, struct domain *src, struct domain *target) diff --git a/xen/include/xsm/xsm-core.h b/xen/include/xsm/xsm-core.h index 3c4a25d7fc..59355937ef 100644 --- a/xen/include/xsm/xsm-core.h +++ b/xen/include/xsm/xsm-core.h @@ -199,7 +199,7 @@ struct xsm_ops { =20 void xsm_fixup_ops(struct xsm_ops *ops); =20 -#ifdef CONFIG_XSM +#ifdef CONFIG_XSM_CONFIGURABLE =20 #ifdef CONFIG_MULTIBOOT int xsm_multiboot_init( @@ -240,7 +240,7 @@ static const inline struct xsm_ops *silo_init(void) } #endif =20 -#else /* CONFIG_XSM */ +#else /* CONFIG_XSM_CONFIGURABLE */ =20 #ifdef CONFIG_MULTIBOOT static inline int xsm_multiboot_init( @@ -262,6 +262,6 @@ static inline bool has_xsm_magic(paddr_t start) } #endif /* CONFIG_HAS_DEVICE_TREE */ =20 -#endif /* CONFIG_XSM */ +#endif /* CONFIG_XSM_CONFIGURABLE */ =20 #endif /* __XSM_CORE_H */ diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 7b1611d10b..14f039673e 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -20,7 +20,7 @@ #include #include =20 -#ifdef CONFIG_XSM +#ifdef CONFIG_XSM_CONFIGURABLE =20 extern struct xsm_ops xsm_ops; =20 @@ -590,10 +590,10 @@ static inline int xsm_argo_send(const struct domain *= d, const struct domain *t) =20 #endif /* CONFIG_ARGO */ =20 -#else /* CONFIG_XSM */ +#else /* CONFIG_XSM_CONFIGURABLE */ =20 #include =20 -#endif /* CONFIG_XSM */ +#endif /* CONFIG_XSM_CONFIGURABLE */ =20 #endif /* __XSM_H */ diff --git a/xen/xsm/Makefile b/xen/xsm/Makefile index cf0a728f1c..09b9311b1d 100644 --- a/xen/xsm/Makefile +++ b/xen/xsm/Makefile @@ -1,6 +1,6 @@ obj-y +=3D xsm_core.o -obj-$(CONFIG_XSM) +=3D xsm_policy.o -obj-$(CONFIG_XSM) +=3D dummy.o +obj-$(CONFIG_XSM_CONFIGURABLE) +=3D xsm_policy.o +obj-$(CONFIG_XSM_CONFIGURABLE) +=3D dummy.o obj-$(CONFIG_XSM_SILO) +=3D silo.o =20 obj-$(CONFIG_XSM_FLASK) +=3D flask/ diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index e1fe4e66a7..8fd2f6e180 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -18,7 +18,7 @@ #include #include =20 -#ifdef CONFIG_XSM +#ifdef CONFIG_XSM_CONFIGURABLE =20 #ifdef CONFIG_MULTIBOOT #include @@ -222,7 +222,7 @@ bool __init has_xsm_magic(paddr_t start) } #endif =20 -#endif +#endif /* CONFIG_XSM_CONFIGURABLE */ =20 long do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) { --=20 2.20.1 From nobody Thu Apr 25 09:25:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1631290541; cv=pass; d=zohomail.com; s=zohoarc; b=WmVooIabOm+qzI7r+UvHh+DUBFV5X8iZ5XHgGZCHYGCHBVOtBcw8xNeMOjYb22JBpixDSrm7HsuaMUaIyjKdvTq0y7wEM4myl5oDm4rs44Qyy55OUEDNgG2ILBiu4veC0m67Mt1ZLAR2O1p8WrdDDUi/GLHdviUhHqWJbTgnFrg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290541; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DSfNAwyaArRS4T2ujyt4gshuXZrkX6KzNK3M7dH8EmI=; b=RnjTmXlmcnqiyYBH/9NEYye9FeCBW9utcMXBP1uIfHpJ2IbLFW+QaOaa5z179k649SD+N9sUGE6qXiYYtTPQOfG8Z9by7iz9l55yBtOuJ3G29VL7iQd0IVMUzre9VGU7IUPJumnotKF72rY+cnsnzyZb6XvX4XR55Eb+C8DxTno= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631290541761726.2574010980304; Fri, 10 Sep 2021 09:15:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.184651.333378 (Exim 4.92) (envelope-from ) id 1mOjBQ-0003xT-M8; Fri, 10 Sep 2021 16:15:20 +0000 Received: by outflank-mailman (output) from mailman id 184651.333378; Fri, 10 Sep 2021 16:15:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOjBQ-0003xL-Hm; Fri, 10 Sep 2021 16:15:20 +0000 Received: by outflank-mailman (input) for mailman id 184651; Fri, 10 Sep 2021 16:15:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOjBO-0003wo-Kv for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 16:15:18 +0000 Received: from sender4-of-o51.zoho.com (unknown [136.143.188.51]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 54df16f4-79c9-4d68-834a-5d0a1fb313df; Fri, 10 Sep 2021 16:15:14 +0000 (UTC) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1631290386362893.7000982855852; Fri, 10 Sep 2021 09:13:06 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 54df16f4-79c9-4d68-834a-5d0a1fb313df ARC-Seal: i=1; a=rsa-sha256; t=1631290389; cv=none; d=zohomail.com; s=zohoarc; b=fqcb1to0vCor3i4hwdrT5/dzOOVc0VwsVGKYuZKXY4ohmVhZ4iPdWjsi1b65UOZJG9RJU89T5i+1hc2jNI3IPqg+eqcJrEdQriV2clQwJGK291AIs0UDFYi8HuriFHzlAXaXipvs4Rv3E3p1Yap5jmJRGV552UpchOr7J6PZS1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631290389; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=DSfNAwyaArRS4T2ujyt4gshuXZrkX6KzNK3M7dH8EmI=; b=B72qb1lr3+X5WFutespgImogO1y/rikMx+jNLmYPkLCQK+jD54QOkKVwN+ydDKHCNHIBeBFO7WM4Rk+ozmIsQgCbXy8E8OYmEFEZMeAcRfSMvryybZFpAjYLtH76GmSKVW9WwinGrV1IulKcfIcV34t4ZvnKJTLKvS2IG1u6ZDE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1631290389; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=DSfNAwyaArRS4T2ujyt4gshuXZrkX6KzNK3M7dH8EmI=; b=ujhyX22+sRzXJEILCJJp8nDhdf2tQSsVvd8E4dT+7GTGRqJOi+NVevTiZLAa0wi9 LBg21TZopqM7iRht3srgyrc+87kG7OevHjmBMqFVD08ZmTqOPob9OOcP1/BuGU5ElYK BWAuYmHistAx/aj7NXbPcOnK2zYwfNT2KdUKCTNU= From: "Daniel P. Smith" To: "Daniel P. Smith" , xen-devel@lists.xenproject.org Cc: Daniel De Graaf Subject: [PATCH v6 10/10] xsm: remove alternate xsm hook interface Date: Fri, 10 Sep 2021 16:13:05 -0400 Message-Id: <20210910201305.32526-11-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210910201305.32526-1-dpsmith@apertussolutions.com> References: <20210910201305.32526-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1631290543696100001 Content-Type: text/plain; charset="utf-8" Hidden behind macro magic is an alternative xsm hook interface dedicated for use when the dummy/default policy is the only one built. This alternative interface increases code complexity and code size in the core security framework of Xen. This results in code requiring additional maintanence and additional risk for securit-relevant bugs. This patch removes this additional interface, making Xen's security framewo= rk have a single, consistent interface that works in a single and consistent manner regardless of which XSM policy is in use. Signed-off-by: Daniel P. Smith --- xen/include/xsm/xsm-core.h | 51 ++- xen/include/xsm/xsm.h | 275 ++++++++++------ xen/xsm/Makefile | 2 +- xen/xsm/dummy.c | 2 +- xen/xsm/dummy.h | 659 +++++++++++++++++++++++++++++++++++++ xen/xsm/silo.c | 2 +- xen/xsm/xsm_core.c | 4 - 7 files changed, 868 insertions(+), 127 deletions(-) create mode 100644 xen/xsm/dummy.h diff --git a/xen/include/xsm/xsm-core.h b/xen/include/xsm/xsm-core.h index 59355937ef..4b01564410 100644 --- a/xen/include/xsm/xsm-core.h +++ b/xen/include/xsm/xsm-core.h @@ -18,6 +18,31 @@ #include #include =20 +/* Cannot use BUILD_BUG_ON here because the expressions we check are not + * considered constant at compile time. Instead, rely on constant propagat= ion to + * inline out the calls to this invalid function, which will cause linker = errors + * if references remain at link time. + */ +#define XSM_LINKER_BUG_ON(x) do { if (x) __xsm_action_mismatch_detected();= } while (0) + +#if defined(CONFIG_COVERAGE) && defined(__clang__) +/* + * LLVM coverage support seems to disable some of the optimizations needed= in + * order for XSM to compile. Since coverage should not be used in producti= on + * provide an implementation of __xsm_action_mismatch_detected to satisfy = the + * linker. + */ +static inline void __xsm_action_mismatch_detected(void) +{ + ASSERT_UNREACHABLE(); +} +#else +/* DO NOT implement this function; it is supposed to trigger link errors */ +void __xsm_action_mismatch_detected(void); +#endif + +#define XSM_ASSERT_ACTION(def) XSM_LINKER_BUG_ON(def !=3D action) + /* policy magic number */ typedef uint32_t xsm_magic_t; =20 @@ -199,8 +224,6 @@ struct xsm_ops { =20 void xsm_fixup_ops(struct xsm_ops *ops); =20 -#ifdef CONFIG_XSM_CONFIGURABLE - #ifdef CONFIG_MULTIBOOT int xsm_multiboot_init( unsigned long *module_map, const multiboot_info_t *mbi); @@ -240,28 +263,4 @@ static const inline struct xsm_ops *silo_init(void) } #endif =20 -#else /* CONFIG_XSM_CONFIGURABLE */ - -#ifdef CONFIG_MULTIBOOT -static inline int xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi) -{ - return 0; -} -#endif - -#ifdef CONFIG_HAS_DEVICE_TREE -static inline int xsm_dt_init(void) -{ - return 0; -} - -static inline bool has_xsm_magic(paddr_t start) -{ - return false; -} -#endif /* CONFIG_HAS_DEVICE_TREE */ - -#endif /* CONFIG_XSM_CONFIGURABLE */ - #endif /* __XSM_CORE_H */ diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 14f039673e..e58dd96974 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -20,8 +20,6 @@ #include #include =20 -#ifdef CONFIG_XSM_CONFIGURABLE - extern struct xsm_ops xsm_ops; =20 static inline void xsm_security_domaininfo( @@ -31,58 +29,68 @@ static inline void xsm_security_domaininfo( } =20 static inline int xsm_domain_create( - xsm_default_t def, struct domain *d, uint32_t ssidref) + xsm_default_t action, struct domain *d, uint32_t ssidref) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.domain_create, d, ssidref); } =20 -static inline int xsm_getdomaininfo(xsm_default_t def, struct domain *d) +static inline int xsm_getdomaininfo(xsm_default_t action, struct domain *d) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.getdomaininfo, d); } =20 static inline int xsm_domctl_scheduler_op( - xsm_default_t def, struct domain *d, int cmd) + xsm_default_t action, struct domain *d, int cmd) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.domctl_scheduler_op, d, cmd); } =20 -static inline int xsm_sysctl_scheduler_op(xsm_default_t def, int cmd) +static inline int xsm_sysctl_scheduler_op(xsm_default_t action, int cmd) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.sysctl_scheduler_op, cmd); } =20 static inline int xsm_set_target( - xsm_default_t def, struct domain *d, struct domain *e) + xsm_default_t action, struct domain *d, struct domain *e) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.set_target, d, e); } =20 -static inline int xsm_domctl(xsm_default_t def, struct domain *d, int cmd) +static inline int xsm_domctl(xsm_default_t action, struct domain *d, int c= md) { + XSM_ASSERT_ACTION(XSM_OTHER); return alternative_call(xsm_ops.domctl, d, cmd); } =20 -static inline int xsm_sysctl(xsm_default_t def, int cmd) +static inline int xsm_sysctl(xsm_default_t action, int cmd) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.sysctl, cmd); } =20 -static inline int xsm_readconsole(xsm_default_t def, uint32_t clear) +static inline int xsm_readconsole(xsm_default_t action, uint32_t clear) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.readconsole, clear); } =20 static inline int xsm_evtchn_unbound( - xsm_default_t def, struct domain *d1, struct evtchn *chn, domid_t id2) + xsm_default_t action, struct domain *d1, struct evtchn *chn, domid_t i= d2) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.evtchn_unbound, d1, chn, id2); } =20 static inline int xsm_evtchn_interdomain( - xsm_default_t def, struct domain *d1, struct evtchn *chan1, + xsm_default_t action, struct domain *d1, struct evtchn *chan1, struct domain *d2, struct evtchn *chan2) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.evtchn_interdomain, d1, chan1, d2, cha= n2); } =20 @@ -92,56 +100,65 @@ static inline void xsm_evtchn_close_post(struct evtchn= *chn) } =20 static inline int xsm_evtchn_send( - xsm_default_t def, struct domain *d, struct evtchn *chn) + xsm_default_t action, struct domain *d, struct evtchn *chn) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.evtchn_send, d, chn); } =20 static inline int xsm_evtchn_status( - xsm_default_t def, struct domain *d, struct evtchn *chn) + xsm_default_t action, struct domain *d, struct evtchn *chn) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.evtchn_status, d, chn); } =20 static inline int xsm_evtchn_reset( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.evtchn_reset, d1, d2); } =20 static inline int xsm_grant_mapref( - xsm_default_t def, struct domain *d1, struct domain *d2, uint32_t flag= s) + xsm_default_t action, struct domain *d1, struct domain *d2, uint32_t f= lags) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.grant_mapref, d1, d2, flags); } =20 static inline int xsm_grant_unmapref( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.grant_unmapref, d1, d2); } =20 static inline int xsm_grant_setup( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.grant_setup, d1, d2); } =20 static inline int xsm_grant_transfer( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.grant_transfer, d1, d2); } =20 static inline int xsm_grant_copy( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.grant_copy, d1, d2); } =20 static inline int xsm_grant_query_size( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.grant_query_size, d1, d2); } =20 @@ -173,86 +190,103 @@ static inline char *xsm_show_security_evtchn( return alternative_call(xsm_ops.show_security_evtchn, d, chn); } =20 -static inline int xsm_init_hardware_domain(xsm_default_t def, struct domai= n *d) +static inline int xsm_init_hardware_domain(xsm_default_t action, + struct domain *d) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.init_hardware_domain, d); } =20 -static inline int xsm_get_pod_target(xsm_default_t def, struct domain *d) +static inline int xsm_get_pod_target(xsm_default_t action, struct domain *= d) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.get_pod_target, d); } =20 -static inline int xsm_set_pod_target(xsm_default_t def, struct domain *d) +static inline int xsm_set_pod_target(xsm_default_t action, struct domain *= d) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.set_pod_target, d); } =20 -static inline int xsm_memory_exchange(xsm_default_t def, struct domain *d) +static inline int xsm_memory_exchange(xsm_default_t action, struct domain = *d) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.memory_exchange, d); } =20 static inline int xsm_memory_adjust_reservation( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.memory_adjust_reservation, d1, d2); } =20 static inline int xsm_memory_stat_reservation( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.memory_stat_reservation, d1, d2); } =20 static inline int xsm_memory_pin_page( - xsm_default_t def, struct domain *d1, struct domain *d2, + xsm_default_t action, struct domain *d1, struct domain *d2, struct page_info *page) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.memory_pin_page, d1, d2, page); } =20 static inline int xsm_add_to_physmap( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.add_to_physmap, d1, d2); } =20 static inline int xsm_remove_from_physmap( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.remove_from_physmap, d1, d2); } =20 static inline int xsm_map_gmfn_foreign( - xsm_default_t def, struct domain *d, struct domain *t) + xsm_default_t action, struct domain *d, struct domain *t) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.map_gmfn_foreign, d, t); } =20 -static inline int xsm_claim_pages(xsm_default_t def, struct domain *d) +static inline int xsm_claim_pages(xsm_default_t action, struct domain *d) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.claim_pages, d); } =20 -static inline int xsm_console_io(xsm_default_t def, struct domain *d, int = cmd) +static inline int xsm_console_io(xsm_default_t action, struct domain *d, + int cmd) { + XSM_ASSERT_ACTION(XSM_OTHER); return alternative_call(xsm_ops.console_io, d, cmd); } =20 -static inline int xsm_profile(xsm_default_t def, struct domain *d, int op) +static inline int xsm_profile(xsm_default_t action, struct domain *d, int = op) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.profile, d, op); } =20 -static inline int xsm_kexec(xsm_default_t def) +static inline int xsm_kexec(xsm_default_t action) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.kexec); } =20 static inline int xsm_schedop_shutdown( - xsm_default_t def, struct domain *d1, struct domain *d2) + xsm_default_t action, struct domain *d1, struct domain *d2) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.schedop_shutdown, d1, d2); } =20 @@ -261,143 +295,172 @@ static inline char *xsm_show_irq_sid(int irq) return alternative_call(xsm_ops.show_irq_sid, irq); } =20 -static inline int xsm_map_domain_pirq(xsm_default_t def, struct domain *d) +static inline int xsm_map_domain_pirq(xsm_default_t action, struct domain = *d) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.map_domain_pirq, d); } =20 static inline int xsm_map_domain_irq( - xsm_default_t def, struct domain *d, int irq, void *data) + xsm_default_t action, struct domain *d, int irq, void *data) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.map_domain_irq, d, irq, data); } =20 -static inline int xsm_unmap_domain_pirq(xsm_default_t def, struct domain *= d) +static inline int xsm_unmap_domain_pirq(xsm_default_t action, struct domai= n *d) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.unmap_domain_pirq, d); } =20 static inline int xsm_unmap_domain_irq( - xsm_default_t def, struct domain *d, int irq, void *data) + xsm_default_t action, struct domain *d, int irq, void *data) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.unmap_domain_irq, d, irq, data); } =20 static inline int xsm_bind_pt_irq( - xsm_default_t def, struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd) + xsm_default_t action, struct domain *d, struct xen_domctl_bind_pt_irq = *bind) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.bind_pt_irq, d, bind); } =20 static inline int xsm_unbind_pt_irq( - xsm_default_t def, struct domain *d, struct xen_domctl_bind_pt_irq *bi= nd) + xsm_default_t action, struct domain *d, struct xen_domctl_bind_pt_irq = *bind) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.unbind_pt_irq, d, bind); } =20 static inline int xsm_irq_permission( - xsm_default_t def, struct domain *d, int pirq, uint8_t allow) + xsm_default_t action, struct domain *d, int pirq, uint8_t allow) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.irq_permission, d, pirq, allow); } =20 static inline int xsm_iomem_permission( - xsm_default_t def, struct domain *d, uint64_t s, uint64_t e, uint8_t a= llow) + xsm_default_t action, struct domain *d, uint64_t s, uint64_t e, + uint8_t allow) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.iomem_permission, d, s, e, allow); } =20 static inline int xsm_iomem_mapping( - xsm_default_t def, struct domain *d, uint64_t s, uint64_t e, uint8_t a= llow) + xsm_default_t action, struct domain *d, uint64_t s, uint64_t e, + uint8_t allow) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.iomem_mapping, d, s, e, allow); } =20 static inline int xsm_pci_config_permission( - xsm_default_t def, struct domain *d, uint32_t machine_bdf, uint16_t st= art, - uint16_t end, uint8_t access) + xsm_default_t action, struct domain *d, uint32_t machine_bdf, + uint16_t start, uint16_t end, uint8_t access) { - return alternative_call(xsm_ops.pci_config_permission, d, machine_bdf,= start, end, access); + XSM_ASSERT_ACTION(XSM_HOOK); + return alternative_call(xsm_ops.pci_config_permission, d, machine_bdf, + start, end, access); } =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) -static inline int xsm_get_device_group(xsm_default_t def, uint32_t machine= _bdf) +static inline int xsm_get_device_group(xsm_default_t action, + uint32_t machine_bdf) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.get_device_group, machine_bdf); } =20 static inline int xsm_assign_device( - xsm_default_t def, struct domain *d, uint32_t machine_bdf) + xsm_default_t action, struct domain *d, uint32_t machine_bdf) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.assign_device, d, machine_bdf); } =20 static inline int xsm_deassign_device( - xsm_default_t def, struct domain *d, uint32_t machine_bdf) + xsm_default_t action, struct domain *d, uint32_t machine_bdf) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.deassign_device, d, machine_bdf); } #endif /* HAS_PASSTHROUGH && HAS_PCI) */ =20 #if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) static inline int xsm_assign_dtdevice( - xsm_default_t def, struct domain *d, const char *dtpath) + xsm_default_t action, struct domain *d, const char *dtpath) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.assign_dtdevice, d, dtpath); } =20 static inline int xsm_deassign_dtdevice( - xsm_default_t def, struct domain *d, const char *dtpath) + xsm_default_t action, struct domain *d, const char *dtpath) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.deassign_dtdevice, d, dtpath); } =20 #endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ =20 -static inline int xsm_resource_plug_pci(xsm_default_t def, uint32_t machin= e_bdf) +static inline int xsm_resource_plug_pci(xsm_default_t action, + uint32_t machine_bdf) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.resource_plug_pci, machine_bdf); } =20 static inline int xsm_resource_unplug_pci( - xsm_default_t def, uint32_t machine_bdf) + xsm_default_t action, uint32_t machine_bdf) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.resource_unplug_pci, machine_bdf); } =20 -static inline int xsm_resource_plug_core(xsm_default_t def) +static inline int xsm_resource_plug_core(xsm_default_t action) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.resource_plug_core); } =20 -static inline int xsm_resource_unplug_core(xsm_default_t def) +static inline int xsm_resource_unplug_core(xsm_default_t action) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.resource_unplug_core); } =20 static inline int xsm_resource_setup_pci( - xsm_default_t def, uint32_t machine_bdf) + xsm_default_t action, uint32_t machine_bdf) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.resource_setup_pci, machine_bdf); } =20 -static inline int xsm_resource_setup_gsi(xsm_default_t def, int gsi) +static inline int xsm_resource_setup_gsi(xsm_default_t action, int gsi) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.resource_setup_gsi, gsi); } =20 -static inline int xsm_resource_setup_misc(xsm_default_t def) +static inline int xsm_resource_setup_misc(xsm_default_t action) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.resource_setup_misc); } =20 -static inline int xsm_page_offline(xsm_default_t def, uint32_t cmd) +static inline int xsm_page_offline(xsm_default_t action, uint32_t cmd) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.page_offline, cmd); } =20 -static inline int xsm_hypfs_op(xsm_default_t def) +static inline int xsm_hypfs_op(xsm_default_t action) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.hypfs_op); } =20 @@ -414,155 +477,185 @@ static inline int xsm_do_compat_op(XEN_GUEST_HANDLE= _PARAM(void) op) #endif =20 static inline int xsm_hvm_param( - xsm_default_t def, struct domain *d, unsigned long op) + xsm_default_t action, struct domain *d, unsigned long op) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.hvm_param, d, op); } =20 static inline int xsm_hvm_control( - xsm_default_t def, struct domain *d, unsigned long op) + xsm_default_t action, struct domain *d, unsigned long op) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.hvm_control, d, op); } =20 -static inline int xsm_hvm_param_altp2mhvm(xsm_default_t def, struct domain= *d) +static inline int xsm_hvm_param_altp2mhvm(xsm_default_t action, + struct domain *d) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.hvm_param_altp2mhvm, d); } =20 static inline int xsm_hvm_altp2mhvm_op( - xsm_default_t def, struct domain *d, uint64_t mode, uint32_t op) + xsm_default_t action, struct domain *d, uint64_t mode, uint32_t op) { + XSM_ASSERT_ACTION(XSM_OTHER); return alternative_call(xsm_ops.hvm_altp2mhvm_op, d, mode, op); } =20 -static inline int xsm_get_vnumainfo(xsm_default_t def, struct domain *d) +static inline int xsm_get_vnumainfo(xsm_default_t action, struct domain *d) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.get_vnumainfo, d); } =20 static inline int xsm_vm_event_control( - xsm_default_t def, struct domain *d, int mode, int op) + xsm_default_t action, struct domain *d, int mode, int op) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.vm_event_control, d, mode, op); } =20 #ifdef CONFIG_MEM_ACCESS -static inline int xsm_mem_access(xsm_default_t def, struct domain *d) +static inline int xsm_mem_access(xsm_default_t action, struct domain *d) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.mem_access, d); } #endif =20 #ifdef CONFIG_MEM_PAGING -static inline int xsm_mem_paging(xsm_default_t def, struct domain *d) +static inline int xsm_mem_paging(xsm_default_t action, struct domain *d) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.mem_paging, d); } #endif =20 #ifdef CONFIG_MEM_SHARING -static inline int xsm_mem_sharing(xsm_default_t def, struct domain *d) +static inline int xsm_mem_sharing(xsm_default_t action, struct domain *d) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.mem_sharing, d); } #endif =20 -static inline int xsm_platform_op(xsm_default_t def, uint32_t op) +static inline int xsm_platform_op(xsm_default_t action, uint32_t op) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.platform_op, op); } =20 #ifdef CONFIG_X86 -static inline int xsm_do_mca(xsm_default_t def) +static inline int xsm_do_mca(xsm_default_t action) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.do_mca); } =20 static inline int xsm_shadow_control( - xsm_default_t def, struct domain *d, uint32_t op) + xsm_default_t action, struct domain *d, uint32_t op) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.shadow_control, d, op); } =20 static inline int xsm_mem_sharing_op( - xsm_default_t def, struct domain *d, struct domain *cd, int op) + xsm_default_t action, struct domain *d, struct domain *cd, int op) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.mem_sharing_op, d, cd, op); } =20 -static inline int xsm_apic(xsm_default_t def, struct domain *d, int cmd) +static inline int xsm_apic(xsm_default_t action, struct domain *d, int cmd) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.apic, d, cmd); } =20 -static inline int xsm_machine_memory_map(xsm_default_t def) +static inline int xsm_machine_memory_map(xsm_default_t action) { + XSM_ASSERT_ACTION(XSM_PRIV); return alternative_call(xsm_ops.machine_memory_map); } =20 -static inline int xsm_domain_memory_map(xsm_default_t def, struct domain *= d) +static inline int xsm_domain_memory_map(xsm_default_t action, struct domai= n *d) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.domain_memory_map, d); } =20 static inline int xsm_mmu_update( - xsm_default_t def, struct domain *d, struct domain *t, struct domain *= f, + xsm_default_t action, struct domain *d, struct domain *t, struct domai= n *f, uint32_t flags) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.mmu_update, d, t, f, flags); } =20 static inline int xsm_mmuext_op( - xsm_default_t def, struct domain *d, struct domain *f) + xsm_default_t action, struct domain *d, struct domain *f) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.mmuext_op, d, f); } =20 static inline int xsm_update_va_mapping( - xsm_default_t def, struct domain *d, struct domain *f, l1_pgentry_t pt= e) + xsm_default_t action, struct domain *d, struct domain *f, l1_pgentry_t= pte) { + XSM_ASSERT_ACTION(XSM_TARGET); return xsm_ops.update_va_mapping(d, f, pte); } =20 static inline int xsm_priv_mapping( - xsm_default_t def, struct domain *d, struct domain *t) + xsm_default_t action, struct domain *d, struct domain *t) { + XSM_ASSERT_ACTION(XSM_TARGET); return alternative_call(xsm_ops.priv_mapping, d, t); } =20 static inline int xsm_ioport_permission( - xsm_default_t def, struct domain *d, uint32_t s, uint32_t e, uint8_t a= llow) + xsm_default_t action, struct domain *d, uint32_t s, uint32_t e, + uint8_t allow) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.ioport_permission, d, s, e, allow); } =20 static inline int xsm_ioport_mapping( - xsm_default_t def, struct domain *d, uint32_t s, uint32_t e, uint8_t a= llow) + xsm_default_t action, struct domain *d, uint32_t s, uint32_t e, + uint8_t allow) { + XSM_ASSERT_ACTION(XSM_HOOK); return alternative_call(xsm_ops.ioport_mapping, d, s, e, allow); } =20 static inline int xsm_pmu_op( - xsm_default_t def, struct domain *d, unsigned int op) + xsm_default_t action, struct domain *d, unsigned int op) { + XSM_ASSERT_ACTION(XSM_OTHER); return alternative_call(xsm_ops.pmu_op, d, op); } =20 #endif /* CONFIG_X86 */ =20 -static inline int xsm_dm_op(xsm_default_t def, struct domain *d) +static inline int xsm_dm_op(xsm_default_t action, struct domain *d) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.dm_op, d); } =20 -static inline int xsm_xen_version(xsm_default_t def, uint32_t op) +static inline int xsm_xen_version(xsm_default_t action, uint32_t op) { + XSM_ASSERT_ACTION(XSM_OTHER); return alternative_call(xsm_ops.xen_version, op); } =20 -static inline int xsm_domain_resource_map(xsm_default_t def, struct domain= *d) +static inline int xsm_domain_resource_map(xsm_default_t action, + struct domain *d) { + XSM_ASSERT_ACTION(XSM_DM_PRIV); return alternative_call(xsm_ops.domain_resource_map, d); } =20 @@ -590,10 +683,4 @@ static inline int xsm_argo_send(const struct domain *d= , const struct domain *t) =20 #endif /* CONFIG_ARGO */ =20 -#else /* CONFIG_XSM_CONFIGURABLE */ - -#include - -#endif /* CONFIG_XSM_CONFIGURABLE */ - #endif /* __XSM_H */ diff --git a/xen/xsm/Makefile b/xen/xsm/Makefile index 09b9311b1d..121a0eda7d 100644 --- a/xen/xsm/Makefile +++ b/xen/xsm/Makefile @@ -1,6 +1,6 @@ obj-y +=3D xsm_core.o +obj-y +=3D dummy.o obj-$(CONFIG_XSM_CONFIGURABLE) +=3D xsm_policy.o -obj-$(CONFIG_XSM_CONFIGURABLE) +=3D dummy.o obj-$(CONFIG_XSM_SILO) +=3D silo.o =20 obj-$(CONFIG_XSM_FLASK) +=3D flask/ diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index b848580eaa..e18afe0673 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -10,7 +10,7 @@ * as published by the Free Software Foundation. */ =20 -#include +#include "dummy.h" =20 #define set_to_dummy_if_null(ops, function) \ do { \ diff --git a/xen/xsm/dummy.h b/xen/xsm/dummy.h new file mode 100644 index 0000000000..206e168815 --- /dev/null +++ b/xen/xsm/dummy.h @@ -0,0 +1,659 @@ +/* + * Default XSM hooks - IS_PRIV and IS_PRIV_FOR checks + * + * Author: Daniel De Graaf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * + * Dummy XSM hooks implementing the default access check. Each hook should + * have as its first line XSM_DEFAULT_ACTION declaring the privilege level + * required for this access. + */ + +#ifndef __XSM_DUMMY_H__ +#define __XSM_DUMMY_H__ + +#include +#include +#include + +#define XSM_DEFAULT_ACTION(def) xsm_default_t action =3D def; (void)action + +static always_inline int xsm_default_action( + xsm_default_t action, struct domain *src, struct domain *target) +{ + switch ( action ) + { + case XSM_HOOK: + return 0; + case XSM_TARGET: + if ( evaluate_nospec(src =3D=3D target) ) + { + return 0; + case XSM_XS_PRIV: + if ( evaluate_nospec(is_xenstore_domain(src)) ) + return 0; + } + /* fall through */ + case XSM_DM_PRIV: + if ( target && evaluate_nospec(src->target =3D=3D target) ) + return 0; + /* fall through */ + case XSM_PRIV: + if ( is_control_domain(src) ) + return 0; + return -EPERM; + default: + XSM_LINKER_BUG_ON(1); + return -EPERM; + } +} + +static inline void xsm_security_domaininfo( + struct domain *d, struct xen_domctl_getdomaininfo *info) +{ + return; +} + +static inline int xsm_domain_create(struct domain *d, uint32_t ssidref) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_getdomaininfo(struct domain *d) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_domctl_scheduler_op(struct domain *d, int cmd) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_sysctl_scheduler_op(int cmd) +{ + return xsm_default_action(XSM_HOOK, current->domain, NULL); +} + +static inline int xsm_set_target(struct domain *d, struct domain *e) +{ + return xsm_default_action(XSM_HOOK, current->domain, NULL); +} + +static inline int xsm_domctl(struct domain *d, int cmd) +{ + switch ( cmd ) + { + case XEN_DOMCTL_ioport_mapping: + case XEN_DOMCTL_memory_mapping: + case XEN_DOMCTL_bind_pt_irq: + case XEN_DOMCTL_unbind_pt_irq: + return xsm_default_action(XSM_DM_PRIV, current->domain, d); + case XEN_DOMCTL_getdomaininfo: + return xsm_default_action(XSM_XS_PRIV, current->domain, d); + default: + return xsm_default_action(XSM_PRIV, current->domain, d); + } +} + +static inline int xsm_sysctl(int cmd) +{ + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline int xsm_readconsole(uint32_t clear) +{ + return xsm_default_action(XSM_HOOK, current->domain, NULL); +} + +static inline int xsm_alloc_security_domain(struct domain *d) +{ + return 0; +} + +static inline void xsm_free_security_domain(struct domain *d) +{ + return; +} + +static inline int xsm_grant_mapref( + struct domain *d1, struct domain *d2, uint32_t flags) +{ + return xsm_default_action(XSM_HOOK, d1, d2); +} + +static inline int xsm_grant_unmapref(struct domain *d1, struct domain *d2) +{ + return xsm_default_action(XSM_HOOK, d1, d2); +} + +static inline int xsm_grant_setup(struct domain *d1, struct domain *d2) +{ + return xsm_default_action(XSM_TARGET, d1, d2); +} + +static inline int xsm_grant_transfer(struct domain *d1, struct domain *d2) +{ + return xsm_default_action(XSM_HOOK, d1, d2); +} + +static inline int xsm_grant_copy(struct domain *d1, struct domain *d2) +{ + return xsm_default_action(XSM_HOOK, d1, d2); +} + +static inline int xsm_grant_query_size(struct domain *d1, struct domain *d= 2) +{ + return xsm_default_action(XSM_TARGET, d1, d2); +} + +static inline int xsm_memory_exchange(struct domain *d) +{ + return xsm_default_action(XSM_TARGET, current->domain, d); +} + +static inline int xsm_memory_adjust_reservation( + struct domain *d1, struct domain *d2) +{ + return xsm_default_action(XSM_TARGET, d1, d2); +} + +static inline int xsm_memory_stat_reservation( + struct domain *d1, struct domain *d2) +{ + return xsm_default_action(XSM_TARGET, d1, d2); +} + +static inline int xsm_console_io(struct domain *d, int cmd) +{ + if ( d->is_console ) + return xsm_default_action(XSM_HOOK, d, NULL); +#ifdef CONFIG_VERBOSE_DEBUG + if ( cmd =3D=3D CONSOLEIO_write ) + return xsm_default_action(XSM_HOOK, d, NULL); +#endif + return xsm_default_action(XSM_PRIV, d, NULL); +} + +static inline int xsm_profile(struct domain *d, int op) +{ + return xsm_default_action(XSM_HOOK, d, NULL); +} + +static inline int xsm_kexec(void) +{ + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline int xsm_schedop_shutdown(struct domain *d1, struct domain *d= 2) +{ + return xsm_default_action(XSM_DM_PRIV, d1, d2); +} + +static inline int xsm_memory_pin_page( + struct domain *d1, struct domain *d2, struct page_info *page) +{ + return xsm_default_action(XSM_HOOK, d1, d2); +} + +static inline int xsm_claim_pages(struct domain *d) +{ + return xsm_default_action(XSM_PRIV, current->domain, d); +} + +static inline int xsm_evtchn_unbound( + struct domain *d, struct evtchn *chn, domid_t id2) +{ + return xsm_default_action(XSM_TARGET, current->domain, d); +} + +static inline int xsm_evtchn_interdomain( + struct domain *d1, struct evtchn *chan1, struct domain *d2, + struct evtchn *chan2) +{ + return xsm_default_action(XSM_HOOK, d1, d2); +} + +static inline void xsm_evtchn_close_post(struct evtchn *chn) +{ + return; +} + +static inline int xsm_evtchn_send(struct domain *d, struct evtchn *chn) +{ + return xsm_default_action(XSM_HOOK, d, NULL); +} + +static inline int xsm_evtchn_status(struct domain *d, struct evtchn *chn) +{ + return xsm_default_action(XSM_TARGET, current->domain, d); +} + +static inline int xsm_evtchn_reset(struct domain *d1, struct domain *d2) +{ + return xsm_default_action(XSM_TARGET, d1, d2); +} + +static inline int xsm_alloc_security_evtchns( + struct evtchn chn[], unsigned int nr) +{ + return 0; +} + +static inline void xsm_free_security_evtchns( + struct evtchn chn[], unsigned int nr) +{ + return; +} + +static inline char *xsm_show_security_evtchn( + struct domain *d, const struct evtchn *chn) +{ + return NULL; +} + +static inline int xsm_init_hardware_domain(struct domain *d) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_get_pod_target(struct domain *d) +{ + return xsm_default_action(XSM_PRIV, current->domain, d); +} + +static inline int xsm_set_pod_target(struct domain *d) +{ + return xsm_default_action(XSM_PRIV, current->domain, d); +} + +static inline int xsm_get_vnumainfo(struct domain *d) +{ + return xsm_default_action(XSM_TARGET, current->domain, d); +} + +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_PCI) +static inline int xsm_get_device_group(uint32_t machine_bdf) +{ + return xsm_default_action(XSM_HOOK, current->domain, NULL); +} + +static inline int xsm_assign_device(struct domain *d, uint32_t machine_bdf) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_deassign_device(struct domain *d, uint32_t machine_b= df) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +#endif /* HAS_PASSTHROUGH && HAS_PCI */ + +#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE) +static inline int xsm_assign_dtdevice(struct domain *d, const char *dtpath) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_deassign_dtdevice(struct domain *d, const char *dtpa= th) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ + +static inline int xsm_resource_plug_core(void) +{ + return xsm_default_action(XSM_HOOK, current->domain, NULL); +} + +static inline int xsm_resource_unplug_core(void) +{ + return xsm_default_action(XSM_HOOK, current->domain, NULL); +} + +static inline int xsm_resource_plug_pci(uint32_t machine_bdf) +{ + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline int xsm_resource_unplug_pci(uint32_t machine_bdf) +{ + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline int xsm_resource_setup_pci(uint32_t machine_bdf) +{ + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline int xsm_resource_setup_gsi(int gsi) +{ + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline int xsm_resource_setup_misc(void) +{ + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline int xsm_page_offline(uint32_t cmd) +{ + return xsm_default_action(XSM_HOOK, current->domain, NULL); +} + +static inline int xsm_hypfs_op(void) +{ + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline long xsm_do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) +{ + return -ENOSYS; +} + +#ifdef CONFIG_COMPAT +static inline int xsm_do_compat_op(XEN_GUEST_HANDLE_PARAM(void) op) +{ + return -ENOSYS; +} +#endif + +static inline char *xsm_show_irq_sid(int irq) +{ + return NULL; +} + +static inline int xsm_map_domain_pirq(struct domain *d) +{ + return xsm_default_action(XSM_DM_PRIV, current->domain, d); +} + +static inline int xsm_map_domain_irq( + struct domain *d, int irq, const void *data) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_unmap_domain_pirq(struct domain *d) +{ + return xsm_default_action(XSM_DM_PRIV, current->domain, d); +} + +static inline int xsm_bind_pt_irq( + struct domain *d, struct xen_domctl_bind_pt_irq *bind) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_unbind_pt_irq( + struct domain *d, struct xen_domctl_bind_pt_irq *bind) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_unmap_domain_irq( + struct domain *d, int irq, const void *data) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_irq_permission(struct domain *d, int pirq, uint8_t a= llow) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_iomem_permission( + struct domain *d, uint64_t s, uint64_t e, uint8_t allow) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_iomem_mapping( + struct domain *d, uint64_t s, uint64_t e, uint8_t allow) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_pci_config_permission( + struct domain *d, uint32_t machine_bdf, uint16_t start, uint16_t end, + uint8_t access) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_add_to_physmap(struct domain *d1, struct domain *d2) +{ + return xsm_default_action(XSM_TARGET, d1, d2); +} + +static inline int xsm_remove_from_physmap(struct domain *d1, struct domain= *d2) +{ + return xsm_default_action(XSM_TARGET, d1, d2); +} + +static inline int xsm_map_gmfn_foreign(struct domain *d, struct domain *t) +{ + return xsm_default_action(XSM_TARGET, d, t); +} + +static inline int xsm_hvm_param(struct domain *d, unsigned long op) +{ + return xsm_default_action(XSM_TARGET, current->domain, d); +} + +static inline int xsm_hvm_control(struct domain *d, unsigned long op) +{ + return xsm_default_action(XSM_DM_PRIV, current->domain, d); +} + +static inline int xsm_hvm_param_altp2mhvm(struct domain *d) +{ + return xsm_default_action(XSM_PRIV, current->domain, d); +} + +static inline int xsm_hvm_altp2mhvm_op( + struct domain *d, uint64_t mode, uint32_t op) +{ + + switch ( mode ) + { + case XEN_ALTP2M_mixed: + return xsm_default_action(XSM_TARGET, current->domain, d); + case XEN_ALTP2M_external: + return xsm_default_action(XSM_DM_PRIV, current->domain, d); + case XEN_ALTP2M_limited: + if ( HVMOP_altp2m_vcpu_enable_notify =3D=3D op ) + return xsm_default_action(XSM_TARGET, current->domain, d); + return xsm_default_action(XSM_DM_PRIV, current->domain, d); + default: + return -EPERM; + } +} + +static inline int xsm_vm_event_control(struct domain *d, int mode, int op) +{ + return xsm_default_action(XSM_PRIV, current->domain, d); +} + +#ifdef CONFIG_MEM_ACCESS +static inline int xsm_mem_access(struct domain *d) +{ + return xsm_default_action(XSM_DM_PRIV, current->domain, d); +} +#endif + +#ifdef CONFIG_MEM_PAGING +static inline int xsm_mem_paging(struct domain *d) +{ + XSM_DEFAULT_ACTION(XSM_DM_PRIV); + return xsm_default_action(XSM_DM_PRIV, current->domain, d); +} +#endif + +#ifdef CONFIG_MEM_SHARING +static inline int xsm_mem_sharing(struct domain *d) +{ + XSM_DEFAULT_ACTION(XSM_DM_PRIV); + return xsm_default_action(XSM_DM_PRIV, current->domain, d); +} +#endif + +static inline int xsm_platform_op(uint32_t op) +{ + XSM_DEFAULT_ACTION(XSM_PRIV); + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +#ifdef CONFIG_X86 +static inline int xsm_do_mca(void) +{ + XSM_DEFAULT_ACTION(XSM_PRIV); + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline int xsm_shadow_control(struct domain *d, uint32_t op) +{ + XSM_DEFAULT_ACTION(XSM_HOOK); + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_mem_sharing_op( + struct domain *d, struct domain *cd, int op) +{ + return xsm_default_action(XSM_DM_PRIV, current->domain, cd); +} + +static inline int xsm_apic(struct domain *d, int cmd) +{ + return xsm_default_action(XSM_PRIV, d, NULL); +} + +static inline int xsm_machine_memory_map(void) +{ + return xsm_default_action(XSM_PRIV, current->domain, NULL); +} + +static inline int xsm_domain_memory_map(struct domain *d) +{ + return xsm_default_action(XSM_TARGET, current->domain, d); +} + +static inline int xsm_mmu_update( + struct domain *d, struct domain *t, struct domain *f, uint32_t flags) +{ + int rc =3D 0; + if ( f !=3D dom_io ) + rc =3D xsm_default_action(XSM_TARGET, d, f); + if ( evaluate_nospec(t) && !rc ) + rc =3D xsm_default_action(XSM_TARGET, d, t); + return rc; +} + +static inline int xsm_mmuext_op(struct domain *d, struct domain *f) +{ + return xsm_default_action(XSM_TARGET, d, f); +} + +static inline int xsm_update_va_mapping( + struct domain *d, struct domain *f, l1_pgentry_t pte) +{ + return xsm_default_action(XSM_TARGET, d, f); +} + +static inline int xsm_priv_mapping(struct domain *d, struct domain *t) +{ + return xsm_default_action(XSM_TARGET, d, t); +} + +static inline int xsm_ioport_permission( + struct domain *d, uint32_t s, uint32_t e, uint8_t allow) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_ioport_mapping( + struct domain *d, uint32_t s, uint32_t e, uint8_t allow) +{ + return xsm_default_action(XSM_HOOK, current->domain, d); +} + +static inline int xsm_pmu_op(struct domain *d, unsigned int op) +{ + switch ( op ) + { + case XENPMU_init: + case XENPMU_finish: + case XENPMU_lvtpc_set: + case XENPMU_flush: + return xsm_default_action(XSM_HOOK, d, current->domain); + default: + return xsm_default_action(XSM_PRIV, d, current->domain); + } +} + +#endif /* CONFIG_X86 */ + +static inline int xsm_dm_op(struct domain *d) +{ + return xsm_default_action(XSM_DM_PRIV, current->domain, d); +} + +#ifdef CONFIG_ARGO +static inline int xsm_argo_enable(const struct domain *d) +{ + return 0; +} + +static inline int xsm_argo_register_single_source( + const struct domain *d, const struct domain *t) +{ + return 0; +} + +static inline int xsm_argo_register_any_source(const struct domain *d) +{ + return 0; +} + +static inline int xsm_argo_send(const struct domain *d, const struct domai= n *t) +{ + return 0; +} + +#endif /* CONFIG_ARGO */ + +#include +static inline int xsm_xen_version(uint32_t op) +{ + switch ( op ) + { + case XENVER_version: + case XENVER_platform_parameters: + case XENVER_get_features: + /* These sub-ops ignore the permission checks and return data. */ + block_speculation(); + return 0; + case XENVER_extraversion: + case XENVER_compile_info: + case XENVER_capabilities: + case XENVER_changeset: + case XENVER_pagesize: + case XENVER_guest_handle: + /* These MUST always be accessible to any guest by default. */ + return xsm_default_action(XSM_HOOK, current->domain, NULL); + default: + return xsm_default_action(XSM_PRIV, current->domain, NULL); + } +} + +static inline int xsm_domain_resource_map(struct domain *d) +{ + return xsm_default_action(XSM_DM_PRIV, current->domain, d); +} + +#endif /* __XSM_DUMMY_H__ */ diff --git a/xen/xsm/silo.c b/xen/xsm/silo.c index 66a2cb1505..350612971f 100644 --- a/xen/xsm/silo.c +++ b/xen/xsm/silo.c @@ -18,7 +18,7 @@ * this program; If not, see . */ #include -#include +#include "dummy.h" =20 /* * Check if inter-domain communication is allowed. diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 8fd2f6e180..a1cd2eb6b9 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -18,8 +18,6 @@ #include #include =20 -#ifdef CONFIG_XSM_CONFIGURABLE - #ifdef CONFIG_MULTIBOOT #include #endif @@ -222,8 +220,6 @@ bool __init has_xsm_magic(paddr_t start) } #endif =20 -#endif /* CONFIG_XSM_CONFIGURABLE */ - long do_xsm_op(XEN_GUEST_HANDLE_PARAM(void) op) { return xsm_do_xsm_op(op); --=20 2.20.1