From nobody Sun Feb 8 04:52:12 2026 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=1653950463; cv=pass; d=zohomail.com; s=zohoarc; b=EjX2/IjQhXx6+fEdAWHtJQYYX8WJEiidJbGtDCSWdhcTtzYt/gD/WamJWTTMs4VVn+sqm/lXgyastipPy9s+WawGjhMgNQhV4KCSJqouumROUXQBO7AXe8quqV8hKdmWHG6cpsBmr1vZxoGUEC1k953iGrUrCy/OLLP9OAU4vVY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950463; 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=0S5/4L9LbrEvX7ep2X/hy4hvb0TSeot95E50192YMEs=; b=SXqs5sDBQ8ooNBzJ6D4/xI4r8iHwaLD600k6hCyMovKOknE+nNs0pWd+ESItvLt2qcMvA+vRBMjfqvp98tmKcIA6+p6EK6kUusMJ1z/bd7VVFPoVolVvXy2w5wYya6GuGTKfuPB35t3q1K/jmjuGbK8EXLdRIX8A1AdlyiBrFFY= 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 1653950463619377.9143671028412; Mon, 30 May 2022 15:41:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.338848.563682 (Exim 4.92) (envelope-from ) id 1nvo3s-0006ho-C4; Mon, 30 May 2022 22:40:32 +0000 Received: by outflank-mailman (output) from mailman id 338848.563682; Mon, 30 May 2022 22:40:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvo3s-0006hh-8r; Mon, 30 May 2022 22:40:32 +0000 Received: by outflank-mailman (input) for mailman id 338848; Mon, 30 May 2022 22:40:31 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvo3r-0006Rh-KE for xen-devel@lists.xenproject.org; Mon, 30 May 2022 22:40:31 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8190b2a7-e069-11ec-bd2c-47488cf2e6aa; Tue, 31 May 2022 00:40:30 +0200 (CEST) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 165395041836510.052349096133753; Mon, 30 May 2022 15:40:18 -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: 8190b2a7-e069-11ec-bd2c-47488cf2e6aa ARC-Seal: i=1; a=rsa-sha256; t=1653950420; cv=none; d=zohomail.com; s=zohoarc; b=OcHcxNHbBQaLLq6H7Twbp6kwJsElx3wQQcGTWIhVXoSFZdGizJQVdR2oQqRq3l03F9CndUYg+V2YWMIjSxbMUgE9M0dMpjJEeJrS5D8Rjm3W9FcOSuUco8AIjpt7hIEnN6IfraiO5sQk7asy/G/uTxx3m+Lg6Tteze68xPJJHMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950420; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=0S5/4L9LbrEvX7ep2X/hy4hvb0TSeot95E50192YMEs=; b=KDPXSkXlI9gzVbSWH2hTH/htLO0/8AUC7IKu7hVVaGov3exCSQEmAXWq3j6PBkAY0PwnfTDf9xDuixGUipwS9u4Ev4YWAYBTcMGqo/cMR1vw5vDQ7fhg6Ld8Ht+uFAaUUBUHbm/+u0vEGQk+37A5Hj6KVaaL+tAqCCW4sXICpVU= 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=1653950420; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=0S5/4L9LbrEvX7ep2X/hy4hvb0TSeot95E50192YMEs=; b=JTk1CUoJBkxrhY0eIfzMeBlVKISWSxQkYOrSIssbJSXYb4jTKAybCYtXRtJTbVSp ExSF92bmXTGDq4wqZHflOTZPrXMGrQqysM+C2ty+siFe2gjnKq9A4G8bkN9zT1Ve999 tmr5bvOfgdu6Im1MG9NrSI8GvYVn/qRIwdvD6ZcM= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org, "Daniel P. Smith" Cc: scott.davis@starlab.io, christopher.clark@starlab.io, jandryuk@gmail.com, Daniel De Graaf Subject: [v2 1/3] xsm: only search for a policy file when needed Date: Mon, 30 May 2022 22:39:41 -0400 Message-Id: <20220531023945.22196-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220531023945.22196-1-dpsmith@apertussolutions.com> References: <20220531023945.22196-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: 1653950465320100001 Content-Type: text/plain; charset="utf-8" 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 du= mmy or the SILO policy is selected as the enforcing policy. This is not ideal f= or 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 fl= ag is set to true, will XSM search the boot modules for a policy file. Signed-off-by: Daniel P. Smith --- 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 =3D XSM_BOOTPARAM_DUMMY; #endif =20 +static bool __initdata policy_file_required =3D + IS_ENABLED(CONFIG_XSM_FLASK_DEFAULT); + static int __init cf_check parse_xsm_param(const char *s) { int rc =3D 0; =20 if ( !strcmp(s, "dummy") ) + { xsm_bootparam =3D XSM_BOOTPARAM_DUMMY; + policy_file_required =3D false; + } #ifdef CONFIG_XSM_FLASK else if ( !strcmp(s, "flask") ) + { xsm_bootparam =3D XSM_BOOTPARAM_FLASK; + policy_file_required =3D true; + } #endif #ifdef CONFIG_XSM_SILO else if ( !strcmp(s, "silo") ) + { xsm_bootparam =3D XSM_BOOTPARAM_SILO; + policy_file_required =3D false; + } #endif else rc =3D -EINVAL; @@ -148,7 +160,7 @@ int __init xsm_multiboot_init( =20 printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n"); =20 - if ( XSM_MAGIC ) + if ( policy_file_required && XSM_MAGIC ) { ret =3D xsm_multiboot_policy_init(module_map, mbi, &policy_buffer, &policy_size); @@ -176,7 +188,7 @@ int __init xsm_dt_init(void) =20 printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n"); =20 - if ( XSM_MAGIC ) + if ( policy_file_required && XSM_MAGIC ) { ret =3D xsm_dt_policy_init(&policy_buffer, &policy_size); if ( ret ) --=20 2.20.1 From nobody Sun Feb 8 04:52:12 2026 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=1653950468; cv=pass; d=zohomail.com; s=zohoarc; b=Fz6DIsUz9s4IkklQxZlLCJkJJSka4AVZKEvCTV/tl/Jq9Ol+8z+T8w4P3Y158XQ+1o2IPNTvmCU4PkZg3NgcZQiQ2rc9adaVUeRIzYGj2RRU8u0MhpM4Fly+zSnfeF2ED8l5nunUNbwW1n4dl/CPxet2v9a6THumjx18sNParBU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950468; 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=C2+K4LrGQhQgI5/c0uDyjquPaNz/qaLDWh7HXB1QsBw=; b=AGToqdOG+AUmLk0vcbHin70/VvuR/u+Au4u06h7/WaHF9IqXsC7GfJVjKxaKUevKU2tp9HUtGFAXaCHd85LK5BSNPHKZB8YUQyb3EGMkpcw+66Ptzs3WZug0eIem1k60I1MnR/PBa5BmKQcuoP1/Kk9Stog7GtdjA9Mdi8vt26s= 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 1653950468519288.7069884977187; Mon, 30 May 2022 15:41:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.338853.563694 (Exim 4.92) (envelope-from ) id 1nvo48-0007CO-MV; Mon, 30 May 2022 22:40:48 +0000 Received: by outflank-mailman (output) from mailman id 338853.563694; Mon, 30 May 2022 22:40:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvo48-0007CF-JV; Mon, 30 May 2022 22:40:48 +0000 Received: by outflank-mailman (input) for mailman id 338853; Mon, 30 May 2022 22:40:47 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvo47-0006Rh-LW for xen-devel@lists.xenproject.org; Mon, 30 May 2022 22:40:47 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8b16ea55-e069-11ec-bd2c-47488cf2e6aa; Tue, 31 May 2022 00:40:46 +0200 (CEST) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 165395041961343.19770802633229; Mon, 30 May 2022 15:40:19 -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: 8b16ea55-e069-11ec-bd2c-47488cf2e6aa ARC-Seal: i=1; a=rsa-sha256; t=1653950422; cv=none; d=zohomail.com; s=zohoarc; b=HaPbuXhvTV3X6Se6zXMBzcGDRhj3MDypTXFfiWd7HBCmoEeXAbCF3BKOieyMma85KzeEcOP37uWPyTlJCT/qPU07m39QVWQ07itW3vYl+C++tHB7/x8H0evkHx1ghinfy8NOeJM88zWtdaB6etHJoqUO25CsGD2H8qADhtYtgT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950422; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=C2+K4LrGQhQgI5/c0uDyjquPaNz/qaLDWh7HXB1QsBw=; b=DAvVEOemHHwllNmMfxOKFgYw0cvol/HZDanJ7SB8cEeaVo1VbAvfg8UwaKyEkA8g9Hw8skFXPpuwe6PZff2AGUtc2gz7c8B+iFfqS2pcmJWHE15kg29HEq2kftZkWZk+2FYmBqnwxDzWJMqedA4l1Vi10M8tT9e8rIRnqwz3Z94= 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=1653950422; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=C2+K4LrGQhQgI5/c0uDyjquPaNz/qaLDWh7HXB1QsBw=; b=p+2ffkQ8+v9rkLWLkoI7WG7m6Y92l8Ixb2GEM+Hswve7eXqHY58klOSe1MvU6fiC kl3kUPOb3oRPIqKNKW3XxQ5i/VkyAXpzfOuU/jbO7FYtLx3r+e+BCITxXc1z2OGBNGy d4FBls6G0+n49Se8ADvVzui1096HezJsVc/kSg60= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org, "Daniel P. Smith" Cc: scott.davis@starlab.io, christopher.clark@starlab.io, jandryuk@gmail.com, Daniel De Graaf Subject: [v2 1/3] xsm: optimize policy loading Date: Mon, 30 May 2022 22:39:42 -0400 Message-Id: <20220531023945.22196-3-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220531023945.22196-1-dpsmith@apertussolutions.com> References: <20220531023945.22196-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: 1653950469335100001 Content-Type: text/plain; charset="utf-8" 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 du= mmy or the SILO policy is selected as the enforcing policy. This is not ideal f= or configurations like hyperlaunch and dom0less when there could be a number of modules to be walked or unnecessary device tree lookups 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 fl= ag is set to true will XSM search the boot modules for a policy file. Signed-off-by: Daniel P. Smith --- 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 =3D XSM_BOOTPARAM_DUMMY; #endif =20 +static bool __initdata policy_file_required =3D + IS_ENABLED(CONFIG_XSM_FLASK_DEFAULT); + static int __init cf_check parse_xsm_param(const char *s) { int rc =3D 0; =20 if ( !strcmp(s, "dummy") ) + { xsm_bootparam =3D XSM_BOOTPARAM_DUMMY; + policy_file_required =3D false; + } #ifdef CONFIG_XSM_FLASK else if ( !strcmp(s, "flask") ) + { xsm_bootparam =3D XSM_BOOTPARAM_FLASK; + policy_file_required =3D true; + } #endif #ifdef CONFIG_XSM_SILO else if ( !strcmp(s, "silo") ) + { xsm_bootparam =3D XSM_BOOTPARAM_SILO; + policy_file_required =3D false; + } #endif else rc =3D -EINVAL; @@ -148,7 +160,7 @@ int __init xsm_multiboot_init( =20 printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n"); =20 - if ( XSM_MAGIC ) + if ( policy_file_required && XSM_MAGIC ) { ret =3D xsm_multiboot_policy_init(module_map, mbi, &policy_buffer, &policy_size); @@ -176,7 +188,7 @@ int __init xsm_dt_init(void) =20 printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n"); =20 - if ( XSM_MAGIC ) + if ( policy_file_required && XSM_MAGIC ) { ret =3D xsm_dt_policy_init(&policy_buffer, &policy_size); if ( ret ) --=20 2.20.1 From nobody Sun Feb 8 04:52:12 2026 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=1653950481; cv=pass; d=zohomail.com; s=zohoarc; b=WEhxhiBLvjVF1homqMS7pGN09F7zBC9o7Hbmx9c4geKuIDSFzbu6PEq85S7LFOvEkPLrkKfQf0eNK33QouHnXMcSEpaPhIs2yTWEYrlNKun7W6QaehgNDwh6DYfBF+DsJh2m4jIw2EPbXYWiOfG4tdLH/g8A1bidFiWKid9XcdA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950481; 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=Sjrnmu86gujeudz33+MAWmkOkhEiPemzBi/wKxHuwM0=; b=la2M5tzx6KopMzM+HRFDW7uoKG8zyKI9t+pOJKEm7RzrmlBVsT+K0o/C0uF7cmg2FH24TncU5L/itzNrtg6awW3UNi5rXuzTzKT+0lgSaew9dEVRwOtImX1D2npXKQNUApaUhXOd5GPYoKl7hptfnYe+L/opxtfZyajJX79oEiA= 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 1653950481145985.6978008301145; Mon, 30 May 2022 15:41:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.338862.563705 (Exim 4.92) (envelope-from ) id 1nvo4L-0007qn-5K; Mon, 30 May 2022 22:41:01 +0000 Received: by outflank-mailman (output) from mailman id 338862.563705; Mon, 30 May 2022 22:41:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvo4L-0007qf-1G; Mon, 30 May 2022 22:41:01 +0000 Received: by outflank-mailman (input) for mailman id 338862; Mon, 30 May 2022 22:40:59 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvo4J-000799-2A for xen-devel@lists.xenproject.org; Mon, 30 May 2022 22:40:59 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 913f81d1-e069-11ec-837f-e5687231ffcc; Tue, 31 May 2022 00:40:57 +0200 (CEST) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1653950420926611.7977371210424; Mon, 30 May 2022 15:40:20 -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: 913f81d1-e069-11ec-837f-e5687231ffcc ARC-Seal: i=1; a=rsa-sha256; t=1653950423; cv=none; d=zohomail.com; s=zohoarc; b=Q1nnC1nn3zePeyAu2QZJrs+CV8LOCaWnInhAuKCH0PWQF66UanH2JFPiEF4dh39r+Cd+Z1avIOpgx0qiSCygkaadiYWmiNNFZu/zsBkEPHDQSitKoagitMVeAEyopdBT4wrwD/5QeVHwsH1WoytgU0jvmpxqfacSxCLOg0Fo658= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950423; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Sjrnmu86gujeudz33+MAWmkOkhEiPemzBi/wKxHuwM0=; b=Y0Wr/Xef4SfE9Uhb9H/8QEI0HFA2qArR2RvbASNZTQNMvDP4LghQ39TmDthDLf08trl3+N2zb+0N4EXj8adoiW4C6ibss9IOb111rKpzmnlom7zosNJxrE1uFP6bn5EaQdSG3j4KaYN3yCUJj2fUYIslbAhVJdymYwutMUZEWYo= 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=1653950423; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=Sjrnmu86gujeudz33+MAWmkOkhEiPemzBi/wKxHuwM0=; b=lJocetZNXMF8Sn3/gMH+c9NxySv2OYe6r1+QRh/pVzBoqnTgPE0wMrBfIQIJMdn+ S04mtPUFsjWMdQ4G34hDGfTYPRGg3vcivu96zsMUoONv/A7wtJpF2e+hLon8VU6plaM H0VybZ1ojBHiMYr0+qm8zSxpXSe93UUxOhea3Kos= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org, "Daniel P. Smith" Cc: scott.davis@starlab.io, christopher.clark@starlab.io, jandryuk@gmail.com, Daniel De Graaf Subject: [v2 2/3] xsm: consolidate loading the policy buffer Date: Mon, 30 May 2022 22:39:43 -0400 Message-Id: <20220531023945.22196-4-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220531023945.22196-1-dpsmith@apertussolutions.com> References: <20220531023945.22196-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: 1653950481864100001 Content-Type: text/plain; charset="utf-8" Previously, initializing the policy buffer was split between two functions, xsm_{multiboot,dt}_policy_init() and xsm_core_init(). The latter for loading the policy from boot modules and the former for falling back to built-in po= licy. This patch moves all policy buffer initialization logic under the xsm_{multiboot,dt}_policy_init() functions. It then ensures that an error message is printed for every error condition that may occur in the function= s. With all policy buffer init contained and only called when the policy buffer must be populated, the respective xsm_{mb,dt}_init() functions will panic i= f an error occurs attempting to populate the policy buffer. Signed-off-by: Daniel P. Smith --- xen/include/xsm/xsm.h | 2 +- xen/xsm/xsm_core.c | 18 +++--------------- xen/xsm/xsm_policy.c | 31 +++++++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 3e2b7fe3db..1676c261c9 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -775,7 +775,7 @@ 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); + const unsigned char *policy_buffer[], size_t *policy_size); #endif =20 #ifdef CONFIG_HAS_DEVICE_TREE diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 4a29ee9558..8f6c3de8a6 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -92,14 +92,6 @@ static int __init xsm_core_init(const void *policy_buffe= r, size_t policy_size) { const struct xsm_ops *ops =3D NULL; =20 -#ifdef CONFIG_XSM_FLASK_POLICY - if ( policy_size =3D=3D 0 ) - { - policy_buffer =3D xsm_flask_init_policy; - policy_size =3D xsm_flask_init_policy_size; - } -#endif - if ( xsm_ops_registered !=3D XSM_OPS_UNREGISTERED ) { printk(XENLOG_ERR @@ -155,7 +147,7 @@ int __init xsm_multiboot_init( unsigned long *module_map, const multiboot_info_t *mbi) { int ret =3D 0; - void *policy_buffer =3D NULL; + const unsigned char *policy_buffer; size_t policy_size =3D 0; =20 printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n"); @@ -167,8 +159,7 @@ int __init xsm_multiboot_init( if ( ret ) { bootstrap_map(NULL); - printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret); - return -EINVAL; + panic(XENLOG_ERR "Error %d initializing XSM policy\n", ret); } } =20 @@ -192,10 +183,7 @@ int __init xsm_dt_init(void) { ret =3D xsm_dt_policy_init(&policy_buffer, &policy_size); if ( ret ) - { - printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret); - return -EINVAL; - } + panic(XENLOG_ERR "Error %d initializing XSM policy\n", ret); } =20 ret =3D xsm_core_init(policy_buffer, policy_size); diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 8dafbc9381..6a4f769aec 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -8,7 +8,7 @@ * Contributors: * Michael LeMay, * George Coker, - * =20 + * * 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. @@ -32,14 +32,21 @@ #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) + const unsigned char *policy_buffer[], size_t *policy_size) { int i; module_t *mod =3D (module_t *)__va(mbi->mods_addr); - int rc =3D 0; + int rc =3D -ENOENT; u32 *_policy_start; unsigned long _policy_len; =20 +#ifdef CONFIG_XSM_FLASK_POLICY + /* Initially set to builtin policy, overriden if boot module is found.= */ + *policy_buffer =3D xsm_flask_init_policy; + *policy_size =3D xsm_flask_init_policy_size; + rc =3D 0; +#endif + /* * Try all modules and see whichever could be the binary policy. * Adjust module_map for the module that is the binary policy. @@ -54,13 +61,14 @@ int __init xsm_multiboot_policy_init( =20 if ( (xsm_magic_t)(*_policy_start) =3D=3D XSM_MAGIC ) { - *policy_buffer =3D _policy_start; + *policy_buffer =3D (unsigned char *)_policy_start; *policy_size =3D _policy_len; =20 printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); =20 __clear_bit(i, module_map); + rc =3D 0; break; =20 } @@ -68,6 +76,9 @@ int __init xsm_multiboot_policy_init( bootstrap_map(NULL); } =20 + if ( rc =3D=3D -ENOENT ) + printk(XENLOG_ERR "xsm: Unable to locate policy file\n"); + return rc; } #endif @@ -79,7 +90,16 @@ int __init xsm_dt_policy_init(void **policy_buffer, size= _t *policy_size) paddr_t paddr, len; =20 if ( !mod || !mod->size ) + { +#ifdef CONFIG_XSM_FLASK_POLICY + *policy_buffer =3D (void *)xsm_flask_init_policy; + *policy_size =3D xsm_flask_init_policy_size; return 0; +#else + printk(XENLOG_ERR "xsm: Unable to locate policy file\n"); + return -ENOENT; +#endif + } =20 paddr =3D mod->start; len =3D mod->size; @@ -95,7 +115,10 @@ int __init xsm_dt_policy_init(void **policy_buffer, siz= e_t *policy_size) =20 *policy_buffer =3D xmalloc_bytes(len); if ( !*policy_buffer ) + { + printk(XENLOG_ERR "xsm: Unable to allocate memory for XSM policy\n= "); return -ENOMEM; + } =20 copy_from_paddr(*policy_buffer, paddr, len); *policy_size =3D len; --=20 2.20.1 From nobody Sun Feb 8 04:52:12 2026 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=1653950490; cv=pass; d=zohomail.com; s=zohoarc; b=Rh1l3p4WngIV25N2wVsBjj5AalIw4aHFTxZ+2qb4O40jqqcwu4e1RukPkxBXBorECw/iw/sMgSmiBE/Hl9GU6k0HDaG64TpdLCmD3nZmxKNnKWag1b00SOmLcRgj6vz0otszdn5cECH5REEE7oZbPWZc3iZ1jGEA0P6CgXbjcIo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950490; 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=527tT9WU0HgntC22WaUmTxYXfawaS2vBXUjSXSJ4Fmo=; b=X2HOFdKCmfe+mO2aid5E4J1EwcRhgGuZt42GphRclqtcWE6qijz11fL/V1amtuDgcsE3YIlhjlJsE1BFHXelNKt3lJucRgRVGkOdB/lY9Obch6FoluaHSJvoL/9kBOa72/zXzdqz2xld0Q21mb7YINeEAIYaY8HCbWEjRDEOocg= 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 1653950490042347.6114011538647; Mon, 30 May 2022 15:41:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.338872.563715 (Exim 4.92) (envelope-from ) id 1nvo4S-0008Ho-EK; Mon, 30 May 2022 22:41:08 +0000 Received: by outflank-mailman (output) from mailman id 338872.563715; Mon, 30 May 2022 22:41:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvo4S-0008Hh-BU; Mon, 30 May 2022 22:41:08 +0000 Received: by outflank-mailman (input) for mailman id 338872; Mon, 30 May 2022 22:41:07 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvo4R-000799-Jk for xen-devel@lists.xenproject.org; Mon, 30 May 2022 22:41:07 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 96a334e7-e069-11ec-837f-e5687231ffcc; Tue, 31 May 2022 00:41:05 +0200 (CEST) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1653950422129887.0158623525535; Mon, 30 May 2022 15:40:22 -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: 96a334e7-e069-11ec-837f-e5687231ffcc ARC-Seal: i=1; a=rsa-sha256; t=1653950424; cv=none; d=zohomail.com; s=zohoarc; b=mbmVHmKKxaCOIAv8wvakvVru164Uh3L/bS0tJI2/mGHlQb3VMW2HlZ536yC2dVMIuXSTjpaxJqcfoMtBtXbL/kayV4zZMB5mHt07Pvo8OLBS7xG2TwTi+K2KqAUVqcUbXfNNt6o6OHDORmgAfDnxyRosSFQNSbNcXC+eFooqNuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950424; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=527tT9WU0HgntC22WaUmTxYXfawaS2vBXUjSXSJ4Fmo=; b=B5qP2MX2+v3cK1Ur12RXPLY4Wg4T4GhcTVEB2HsIsg/HQIZlp3RHFQ5IJCbEHFOkQq3i1yViWrrZPmQ9zq1B4uEU+AlANFwsjXuy+XI+Ug/6GYEiEhlRbm/BmZGcOpzdGxzvQgZPBtyyz5eZ9KLPoHWfslpXlo6bM94wZuiJyE0= 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=1653950424; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=527tT9WU0HgntC22WaUmTxYXfawaS2vBXUjSXSJ4Fmo=; b=pfnpokIbgJE+lrYnquFN1jbTz8b4QZYQar4suUwlwJ4BIiSWxBM2eJ/90KNobZjL 2Aw4Y1Sy/0R4rTFWtk8wy2C/0JL3NjF7eseY8J+NepStbb7UrERop93HnWhjRuhknat 3opZAsh2XkNmj4FRJlLG0ZlJsXyEUb4XepnWYP1A= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org, "Daniel P. Smith" Cc: scott.davis@starlab.io, christopher.clark@starlab.io, jandryuk@gmail.com, Daniel De Graaf Subject: [v2 2/3] xsm: refactor policy loading Date: Mon, 30 May 2022 22:39:44 -0400 Message-Id: <20220531023945.22196-5-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220531023945.22196-1-dpsmith@apertussolutions.com> References: <20220531023945.22196-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: 1653950491769100001 Content-Type: text/plain; charset="utf-8" Previously initializing the policy buffer was split between two functions, xsm_{multiboot,dt}_policy_init() and xsm_core_init(). The latter for loading the policy from boot modules and the former for falling back to built-in po= licy. This patch moves all policy buffer initialization logic under the xsm_{multiboot,dt}_policy_init() functions. It then ensures that an error message is printed for every error condition that may occur in the function= s. With all policy buffer init contained and only called when the policy buffer must be populated, the respective xsm_{mb,dt}_init() functions will panic i= f an error occurs attempting to populate the policy buffer. Signed-off-by: Daniel P. Smith --- xen/include/xsm/xsm.h | 2 +- xen/xsm/xsm_core.c | 18 +++--------------- xen/xsm/xsm_policy.c | 31 +++++++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 3e2b7fe3db..1676c261c9 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -775,7 +775,7 @@ 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); + const unsigned char *policy_buffer[], size_t *policy_size); #endif =20 #ifdef CONFIG_HAS_DEVICE_TREE diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 4a29ee9558..8f6c3de8a6 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -92,14 +92,6 @@ static int __init xsm_core_init(const void *policy_buffe= r, size_t policy_size) { const struct xsm_ops *ops =3D NULL; =20 -#ifdef CONFIG_XSM_FLASK_POLICY - if ( policy_size =3D=3D 0 ) - { - policy_buffer =3D xsm_flask_init_policy; - policy_size =3D xsm_flask_init_policy_size; - } -#endif - if ( xsm_ops_registered !=3D XSM_OPS_UNREGISTERED ) { printk(XENLOG_ERR @@ -155,7 +147,7 @@ int __init xsm_multiboot_init( unsigned long *module_map, const multiboot_info_t *mbi) { int ret =3D 0; - void *policy_buffer =3D NULL; + const unsigned char *policy_buffer; size_t policy_size =3D 0; =20 printk("XSM Framework v" XSM_FRAMEWORK_VERSION " initialized\n"); @@ -167,8 +159,7 @@ int __init xsm_multiboot_init( if ( ret ) { bootstrap_map(NULL); - printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret); - return -EINVAL; + panic(XENLOG_ERR "Error %d initializing XSM policy\n", ret); } } =20 @@ -192,10 +183,7 @@ int __init xsm_dt_init(void) { ret =3D xsm_dt_policy_init(&policy_buffer, &policy_size); if ( ret ) - { - printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret); - return -EINVAL; - } + panic(XENLOG_ERR "Error %d initializing XSM policy\n", ret); } =20 ret =3D xsm_core_init(policy_buffer, policy_size); diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 8dafbc9381..6a4f769aec 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -8,7 +8,7 @@ * Contributors: * Michael LeMay, * George Coker, - * =20 + * * 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. @@ -32,14 +32,21 @@ #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) + const unsigned char *policy_buffer[], size_t *policy_size) { int i; module_t *mod =3D (module_t *)__va(mbi->mods_addr); - int rc =3D 0; + int rc =3D -ENOENT; u32 *_policy_start; unsigned long _policy_len; =20 +#ifdef CONFIG_XSM_FLASK_POLICY + /* Initially set to builtin policy, overriden if boot module is found.= */ + *policy_buffer =3D xsm_flask_init_policy; + *policy_size =3D xsm_flask_init_policy_size; + rc =3D 0; +#endif + /* * Try all modules and see whichever could be the binary policy. * Adjust module_map for the module that is the binary policy. @@ -54,13 +61,14 @@ int __init xsm_multiboot_policy_init( =20 if ( (xsm_magic_t)(*_policy_start) =3D=3D XSM_MAGIC ) { - *policy_buffer =3D _policy_start; + *policy_buffer =3D (unsigned char *)_policy_start; *policy_size =3D _policy_len; =20 printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); =20 __clear_bit(i, module_map); + rc =3D 0; break; =20 } @@ -68,6 +76,9 @@ int __init xsm_multiboot_policy_init( bootstrap_map(NULL); } =20 + if ( rc =3D=3D -ENOENT ) + printk(XENLOG_ERR "xsm: Unable to locate policy file\n"); + return rc; } #endif @@ -79,7 +90,16 @@ int __init xsm_dt_policy_init(void **policy_buffer, size= _t *policy_size) paddr_t paddr, len; =20 if ( !mod || !mod->size ) + { +#ifdef CONFIG_XSM_FLASK_POLICY + *policy_buffer =3D (void *)xsm_flask_init_policy; + *policy_size =3D xsm_flask_init_policy_size; return 0; +#else + printk(XENLOG_ERR "xsm: Unable to locate policy file\n"); + return -ENOENT; +#endif + } =20 paddr =3D mod->start; len =3D mod->size; @@ -95,7 +115,10 @@ int __init xsm_dt_policy_init(void **policy_buffer, siz= e_t *policy_size) =20 *policy_buffer =3D xmalloc_bytes(len); if ( !*policy_buffer ) + { + printk(XENLOG_ERR "xsm: Unable to allocate memory for XSM policy\n= "); return -ENOMEM; + } =20 copy_from_paddr(*policy_buffer, paddr, len); *policy_size =3D len; --=20 2.20.1 From nobody Sun Feb 8 04:52:12 2026 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=1653950535; cv=pass; d=zohomail.com; s=zohoarc; b=F1M2tzCaN+adXpyu71IzYALGbudyqW3QaGaw25vb6tt7HoXLEza16WwfO21nVdK/7YxrCvcEadPvkWKda1rLGETygYXKMF75xp5xptTKrWnNmlhMTe4GoH66mZTMdE6gD2JqmzmmRYFw6bB+LDdUh+SPlnm/ksdP+Z1f3yJ37is= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950535; 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=nndS4b5R/wYFUWfqbrv+HVeHYowHUAVZYTBTrHEBrVY=; b=n/myfF+PEN/KdpYFzsU4bgpDoc/VfRtQ4UpJpARzpo9kLqA+vhkPLgFbFIqTgwKU1AfFdijcHNnDIfjSXypGrpjo1V8jtKiQRMbY6PD6bF3mRowRicRjGMVgL8ehsHy8OK1cgABrgoZaCVKCkNFn00XjWe9uIpb/KjBg2k1pTwM= 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 1653950535767284.5758787482339; Mon, 30 May 2022 15:42:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.338893.563726 (Exim 4.92) (envelope-from ) id 1nvo5C-0000sg-OH; Mon, 30 May 2022 22:41:54 +0000 Received: by outflank-mailman (output) from mailman id 338893.563726; Mon, 30 May 2022 22:41: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 1nvo5C-0000sZ-Lc; Mon, 30 May 2022 22:41:54 +0000 Received: by outflank-mailman (input) for mailman id 338893; Mon, 30 May 2022 22:41:53 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nvo4a-000799-S6 for xen-devel@lists.xenproject.org; Mon, 30 May 2022 22:41:16 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9bc7b1ed-e069-11ec-837f-e5687231ffcc; Tue, 31 May 2022 00:41:14 +0200 (CEST) Received: from sisyou.hme. (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1653950423920903.2613018163844; Mon, 30 May 2022 15:40:23 -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: 9bc7b1ed-e069-11ec-837f-e5687231ffcc ARC-Seal: i=1; a=rsa-sha256; t=1653950426; cv=none; d=zohomail.com; s=zohoarc; b=XrvTuKYnQvr4VmxSf5tKRMwkglQkygeiNP8xPTO7MSvDJTb3+NNc27XqncdtfI4B0i8G+kfSlo6TrobfI/qBKVIHcZ+KXC+fxZ3Xj1los2vhTppGjMd5/LUklExRkJjKh1acQl1mfTy/2Vqida9Tifrrxl9R2Dr7JYFcTpm0GMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653950426; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nndS4b5R/wYFUWfqbrv+HVeHYowHUAVZYTBTrHEBrVY=; b=WQl/+jdaHNXtbkvckiP8rTWW8rTh7BA6MtU7VyRcG+jYKQ9J/8P+o9LW5n6/8PJFiPVo2Sbic/6rBkijPst/uTFtLG8QYbTXfnvn+hDXk8zJDCYOF2BF3GLj1Gg1xAI5rHywJpF1nTEiEl5fgLjE4THK7U1JHG7ZC3ur1HWbC2Y= 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=1653950426; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=nndS4b5R/wYFUWfqbrv+HVeHYowHUAVZYTBTrHEBrVY=; b=H0EVJc5QO8n65Xn2pOmGFcrLtETK1L93L5emmI7SvD7IJmlm6N8jVKMKQ/qhtDC1 MsfbX0whXMUEVu/2dEbLGW/LniKy1bop36BnG46+2xl4EqUx0I6B9lmbreZx/ynolBc rcEVUD4PKjckwSAmnLCsLDyo7rxfcxxrm8CH+tsc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org, Volodymyr Babchuk , Wei Liu , "Daniel P. Smith" Cc: scott.davis@starlab.io, christopher.clark@starlab.io, jandryuk@gmail.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Daniel De Graaf Subject: [v2 3/3] xsm: properly handle error from XSM init Date: Mon, 30 May 2022 22:39:45 -0400 Message-Id: <20220531023945.22196-6-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220531023945.22196-1-dpsmith@apertussolutions.com> References: <20220531023945.22196-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: 1653950538063100001 Content-Type: text/plain; charset="utf-8" This commit is to move towards providing a uniform interface across architectures to initialize the XSM framework. Specifically, it provides a common handling of initialization failure by providing the printing of a warning message. For Arm, xsm_dt_init() was tailored to have an Arm specific expansion of the return values. This expansion added a value to reflect whether the security supported XSM policy module was the enforcing policy module. This was then = used to determine if a warning message would be printed. Despite this expansion, like x86, Arm does not address any XSM initialization errors that may have occurred. Signed-off-by: Daniel P. Smith Reviewed-by: Bertrand Marquis --- xen/arch/arm/setup.c | 10 +++++----- xen/arch/x86/setup.c | 9 +++++++-- xen/xsm/xsm_core.c | 22 +++++++++++----------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index ea1f5ee3d3..6bf71e1064 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -967,11 +967,11 @@ void __init start_xen(unsigned long boot_phys_offset, =20 tasklet_subsys_init(); =20 - if ( xsm_dt_init() !=3D 1 ) - warning_add("WARNING: SILO mode is not enabled.\n" - "It has implications on the security of the system,\n" - "unless the communications have been forbidden between= \n" - "untrusted domains.\n"); + if ( xsm_dt_init() ) + warning_add("WARNING: XSM failed to initialize.\n" + "This has implications on the security of the system,\= n" + "as uncontrolled communications between trusted and\n" + "untrusted domains may occur.\n"); =20 init_maintenance_interrupt(); init_timer_interrupt(); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 53a73010e0..ed67b50c9d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #ifdef CONFIG_COMPAT @@ -1690,7 +1691,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) =20 open_softirq(NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ, new_tlbflush_clock_per= iod); =20 - if ( opt_watchdog )=20 + if ( opt_watchdog ) nmi_watchdog =3D NMI_LOCAL_APIC; =20 find_smp_config(); @@ -1700,7 +1701,11 @@ void __init noreturn __start_xen(unsigned long mbi_p) mmio_ro_ranges =3D rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); =20 - xsm_multiboot_init(module_map, mbi); + if ( xsm_multiboot_init(module_map, mbi) ) + warning_add("WARNING: XSM failed to initialize.\n" + "This has implications on the security of the system,\= n" + "as uncontrolled communications between trusted and\n" + "untrusted domains may occur.\n"); =20 /* * IOMMU-related ACPI table parsing may require some of the system dom= ains diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 8f6c3de8a6..6377895e1e 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -10,23 +10,17 @@ * as published by the Free Software Foundation. */ =20 -#include #include +#include +#include #include #include - -#include +#include #include =20 -#ifdef CONFIG_XSM - -#ifdef CONFIG_MULTIBOOT #include -#endif =20 -#ifdef CONFIG_HAS_DEVICE_TREE -#include -#endif +#ifdef CONFIG_XSM =20 #define XSM_FRAMEWORK_VERSION "1.0.1" =20 @@ -190,7 +184,13 @@ int __init xsm_dt_init(void) =20 xfree(policy_buffer); =20 - return ret ?: (xsm_bootparam =3D=3D XSM_BOOTPARAM_SILO); + if ( xsm_bootparam !=3D XSM_BOOTPARAM_SILO ) + warning_add("WARNING: SILO mode is not enabled.\n" + "It has implications on the security of the system,\n" + "unless the communications have been forbidden between= \n" + "untrusted domains.\n"); + + return ret; } =20 /** --=20 2.20.1