All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Smith" <dpsmith@apertussolutions.com>
To: xen-devel@lists.xenproject.org,
	"Daniel P. Smith" <dpsmith@apertussolutions.com>
Cc: scott.davis@starlab.io, christopher.clark@starlab.io,
	jandryuk@gmail.com, Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: [PATCH v3 1/3] xsm: only search for a policy file when needed
Date: Tue, 31 May 2022 11:08:55 -0400	[thread overview]
Message-ID: <20220531150857.19727-2-dpsmith@apertussolutions.com> (raw)
In-Reply-To: <20220531150857.19727-1-dpsmith@apertussolutions.com>

It is possible to select a few different build configurations that results in
the unnecessary walking of the boot module list looking for a policy module.
This specifically occurs when the flask policy is enabled but either the dummy
or the SILO policy is selected as the enforcing policy. This is not ideal for
configurations like hyperlaunch and dom0less when there could be a number of
modules to be walked or doing an unnecessary device tree lookup.

This patch introduces the policy_file_required flag for tracking when an XSM
policy module requires a policy file. Only when the policy_file_required flag
is set to true, will XSM search the boot modules for a policy file.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/xsm/xsm_core.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c
index 2286a502e3..4a29ee9558 100644
--- a/xen/xsm/xsm_core.c
+++ b/xen/xsm/xsm_core.c
@@ -55,19 +55,31 @@ static enum xsm_bootparam __initdata xsm_bootparam =
     XSM_BOOTPARAM_DUMMY;
 #endif
 
+static bool __initdata policy_file_required =
+    IS_ENABLED(CONFIG_XSM_FLASK_DEFAULT);
+
 static int __init cf_check parse_xsm_param(const char *s)
 {
     int rc = 0;
 
     if ( !strcmp(s, "dummy") )
+    {
         xsm_bootparam = XSM_BOOTPARAM_DUMMY;
+        policy_file_required = false;
+    }
 #ifdef CONFIG_XSM_FLASK
     else if ( !strcmp(s, "flask") )
+    {
         xsm_bootparam = XSM_BOOTPARAM_FLASK;
+        policy_file_required = true;
+    }
 #endif
 #ifdef CONFIG_XSM_SILO
     else if ( !strcmp(s, "silo") )
+    {
         xsm_bootparam = XSM_BOOTPARAM_SILO;
+        policy_file_required = false;
+    }
 #endif
     else
         rc = -EINVAL;
@@ -148,7 +160,7 @@ int __init xsm_multiboot_init(
 
     printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n");
 
-    if ( XSM_MAGIC )
+    if ( policy_file_required && XSM_MAGIC )
     {
         ret = xsm_multiboot_policy_init(module_map, mbi, &policy_buffer,
                                         &policy_size);
@@ -176,7 +188,7 @@ int __init xsm_dt_init(void)
 
     printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n");
 
-    if ( XSM_MAGIC )
+    if ( policy_file_required && XSM_MAGIC )
     {
         ret = xsm_dt_policy_init(&policy_buffer, &policy_size);
         if ( ret )
-- 
2.20.1



  reply	other threads:[~2022-05-31 15:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-31 15:08 [PATCH v3 0/3] xsm: refactor and optimize policy loading Daniel P. Smith
2022-05-31 15:08 ` Daniel P. Smith [this message]
2022-05-31 15:51   ` [PATCH v3 1/3] xsm: only search for a policy file when needed Jan Beulich
2022-05-31 16:15     ` Daniel P. Smith
2022-06-01  6:04       ` Jan Beulich
2022-06-07 12:07         ` Daniel P. Smith
2022-06-01  6:08   ` Jan Beulich
2022-06-07 12:08     ` Daniel P. Smith
2022-05-31 15:08 ` [PATCH v3 2/3] xsm: consolidate loading the policy buffer Daniel P. Smith
2022-05-31 16:05   ` Jan Beulich
2022-05-31 17:02     ` Daniel P. Smith
2022-05-31 15:08 ` [PATCH v3 3/3] xsm: properly handle error from XSM init Daniel P. Smith
2022-06-01  6:14   ` Jan Beulich
2022-06-07 12:14     ` Daniel P. Smith
2022-06-07 13:21       ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220531150857.19727-2-dpsmith@apertussolutions.com \
    --to=dpsmith@apertussolutions.com \
    --cc=christopher.clark@starlab.io \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=jandryuk@gmail.com \
    --cc=scott.davis@starlab.io \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.