diff mbox

[1/2] xsm: move the XSM_MAGIC value to Kconfig

Message ID 1457376161-24982-1-git-send-email-cardoe@cardoe.com (mailing list archive)
State New, archived
Headers show

Commit Message

Douglas Goldstein March 7, 2016, 6:42 p.m. UTC
Let Kconfig set the XSM_MAGIC value for us.

Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
---
CC: Daniel De Graaf <dgdegra@tycho.nsa.gov>
---
 xen/common/Kconfig       | 8 ++++++++
 xen/include/xen/config.h | 1 -
 xen/include/xsm/xsm.h    | 5 +----
 xen/xsm/xsm_core.c       | 4 ++--
 xen/xsm/xsm_policy.c     | 6 +++---
 5 files changed, 14 insertions(+), 10 deletions(-)

Comments

Jan Beulich March 8, 2016, 9:44 a.m. UTC | #1
>>> On 07.03.16 at 19:42, <cardoe@cardoe.com> wrote:
> Let Kconfig set the XSM_MAGIC value for us.

What's the benefit of doing this at the Kconfig layer?

> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -113,6 +113,14 @@ config XSM
>  
>  	  If unsure, say N.
>  
> +# XSM magic for policy detection
> +config XSM_MAGIC
> +    hex
> +    default 0xf97cff8c if FLASK
> +    default 0 if !FLASK

This second "if" is pointless.

Also note the broken indentation (using spaces instead of a tab).

Jan
Daniel De Graaf March 8, 2016, 4:22 p.m. UTC | #2
On 03/07/2016 01:42 PM, Doug Goldstein wrote:
> Let Kconfig set the XSM_MAGIC value for us.
>
> Signed-off-by: Doug Goldstein <cardoe@cardoe.com>

This is not the best place to define this constant: it doesn't
make sense for it to be user-configurable.  If you want to move it
out of config.h, I think the best solution is to define XSM_MAGIC
inside xsm/xsm.h depending on the value of CONFIG_FLASK.
diff mbox

Patch

diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index 8fbc46d..d661da3 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -113,6 +113,14 @@  config XSM
 
 	  If unsure, say N.
 
+# XSM magic for policy detection
+config XSM_MAGIC
+    hex
+    default 0xf97cff8c if FLASK
+    default 0 if !FLASK
+    ---help---
+      Identifies a FLASK XSM policy start point
+
 # Enable schedulers
 menu "Schedulers"
 	visible if EXPERT = "y"
diff --git a/xen/include/xen/config.h b/xen/include/xen/config.h
index 96f5539..3f8c53d 100644
--- a/xen/include/xen/config.h
+++ b/xen/include/xen/config.h
@@ -79,7 +79,6 @@ 
 #define STR(...) __STR(__VA_ARGS__)
 
 #ifdef CONFIG_FLASK
-#define XSM_MAGIC 0xf97cff8c
 /* Maintain statistics on the access vector cache */
 #define FLASK_AVC_STATS 1
 #endif
diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
index 3afed70..7f313ad 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -21,11 +21,8 @@ 
 typedef void xsm_op_t;
 DEFINE_XEN_GUEST_HANDLE(xsm_op_t);
 
-/* policy magic number (defined by XSM_MAGIC) */
+/* policy magic number (defined by CONFIG_XSM_MAGIC) */
 typedef u32 xsm_magic_t;
-#ifndef XSM_MAGIC
-#define XSM_MAGIC 0x00000000
-#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.
diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c
index 5e432de..d6965ba 100644
--- a/xen/xsm/xsm_core.c
+++ b/xen/xsm/xsm_core.c
@@ -67,7 +67,7 @@  int __init xsm_multiboot_init(unsigned long *module_map,
 
     printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n");
 
-    if ( XSM_MAGIC )
+    if ( CONFIG_XSM_MAGIC )
     {
         ret = xsm_multiboot_policy_init(module_map, mbi, bootstrap_map);
         if ( ret )
@@ -92,7 +92,7 @@  int __init xsm_dt_init(void)
 
     printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n");
 
-    if ( XSM_MAGIC )
+    if ( CONFIG_XSM_MAGIC )
     {
         ret = xsm_dt_policy_init();
         if ( ret )
diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c
index b60d822..52aa4a9 100644
--- a/xen/xsm/xsm_policy.c
+++ b/xen/xsm/xsm_policy.c
@@ -54,7 +54,7 @@  int __init xsm_multiboot_policy_init(unsigned long *module_map,
         _policy_start = bootstrap_map(mod + i);
         _policy_len   = mod[i].mod_end;
 
-        if ( (xsm_magic_t)(*_policy_start) == XSM_MAGIC )
+        if ( (xsm_magic_t)(*_policy_start) == CONFIG_XSM_MAGIC )
         {
             policy_buffer = (char *)_policy_start;
             policy_size = _policy_len;
@@ -89,10 +89,10 @@  int __init xsm_dt_policy_init(void)
 
     copy_from_paddr(&magic, paddr, sizeof(magic));
 
-    if ( magic != XSM_MAGIC )
+    if ( magic != CONFIG_XSM_MAGIC )
     {
         printk(XENLOG_ERR "xsm: Invalid magic for XSM blob got 0x%x "
-               "expected 0x%x\n", magic, XSM_MAGIC);
+               "expected 0x%x\n", magic, CONFIG_XSM_MAGIC);
         return -EINVAL;
     }