OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anup Patel <anup.patel@wdc.com>
To: opensbi@lists.infradead.org
Subject: [PATCH 1/7] lib: sbi: Domains can be registered only before finalizing domains
Date: Sat, 10 Apr 2021 12:48:02 +0530	[thread overview]
Message-ID: <20210410071808.759856-2-anup.patel@wdc.com> (raw)
In-Reply-To: <20210410071808.759856-1-anup.patel@wdc.com>

The domains are boot-time system-level partitions so we should
allow platform support to register domains only before hart
domain assignments are finalized.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
---
 lib/sbi/sbi_domain.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
index 195c941..2849241 100644
--- a/lib/sbi/sbi_domain.c
+++ b/lib/sbi/sbi_domain.c
@@ -19,8 +19,8 @@
 
 struct sbi_domain *hartid_to_domain_table[SBI_HARTMASK_MAX_BITS] = { 0 };
 struct sbi_domain *domidx_to_domain_table[SBI_DOMAIN_MAX_INDEX] = { 0 };
-
 static u32 domain_count = 0;
+static bool domain_finalized = false;
 
 static struct sbi_hartmask root_hmask = { 0 };
 
@@ -376,7 +376,8 @@ int sbi_domain_register(struct sbi_domain *dom,
 	u32 cold_hartid = current_hartid();
 	const struct sbi_platform *plat = sbi_platform_thishart_ptr();
 
-	if (!dom || !assign_mask)
+	/* Sanity checks */
+	if (!dom || !assign_mask || domain_finalized)
 		return SBI_EINVAL;
 
 	/* Check if domain already discovered */
@@ -490,6 +491,12 @@ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid)
 		}
 	}
 
+	/*
+	 * Set the finalized flag so that the root domain
+	 * regions can't be changed.
+	 */
+	domain_finalized = true;
+
 	return 0;
 }
 
-- 
2.25.1



  reply	other threads:[~2021-04-10  7:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10  7:18 [PATCH 0/7] Protect M-mode only MMIO devices Anup Patel
2021-04-10  7:18 ` Anup Patel [this message]
2021-04-11  7:49   ` [PATCH 1/7] lib: sbi: Domains can be registered only before finalizing domains Xiang W
2021-04-11 21:19   ` Alistair Francis
2021-04-10  7:18 ` [PATCH 2/7] lib: sbi: Add sbi_domain_memregion_init() API Anup Patel
2021-04-11  7:50   ` Xiang W
2021-04-11 21:22   ` Alistair Francis
2021-04-10  7:18 ` [PATCH 3/7] lib: sbi: Add sbi_domain_root_add_memregion() API Anup Patel
2021-04-11  8:43   ` Xiang W
2021-04-11 21:27   ` Alistair Francis
2021-04-10  7:18 ` [PATCH 4/7] lib: utils/sys: Add CLINT memregion in the root domain Anup Patel
2021-04-11  9:05   ` Xiang W
2021-04-12  5:23     ` Anup Patel
2021-04-12  5:42       ` Xiang W
2021-04-12  6:24         ` Anup Patel
2021-04-10  7:18 ` [PATCH 5/7] lib: sbi: Make the root domain instance global variable Anup Patel
2021-04-11 10:07   ` Xiang W
2021-04-11 21:29   ` Alistair Francis
2021-04-10  7:18 ` [PATCH 6/7] lib: utils: Copy over restricted root domain memregions to FDT domains Anup Patel
2021-04-11 10:07   ` Xiang W
2021-04-11 21:30   ` Alistair Francis
2021-04-10  7:18 ` [PATCH 7/7] lib: sbi: Make sbi_domain_memregion_initfw() a local function Anup Patel
2021-04-11 10:07   ` Xiang W
2021-04-11 21:32   ` Alistair Francis

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=20210410071808.759856-2-anup.patel@wdc.com \
    --to=anup.patel@wdc.com \
    --cc=opensbi@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox