From patchwork Fri Jan 6 11:22:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1722380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=dXz/C22Q; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=goxlAf4n; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NpLY45djrz23fc for ; Fri, 6 Jan 2023 22:22:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xpaU4X3dBETK54mYOliVo02qn0ul/DWEoOznHgR+NpA=; b=dXz/C22QsEtYus a2hErVyvnRBdEDTuLHmnFLSp/5qAWLjDST8MHoOEViO23GPqe4XHLDpslR5DXqeoyDMTOxj6NuYRB HnzVguyRMDiKfUhF6lOMwx/SScXP2noG8FPNBqGDCyNa21rvWu3/9blpuc027uUsSBmj6hg+PRONN BwEsg2Pw7x8HA9t2LLWMH+CO3yFJjTY2Y42Fst2PFv3Or4+DcqAPm6lQyVOIO7YicwpRpYNM6089D 1HYZ6xhWHrMw1xArnwKFUT0EYKxrNOqURet0aiCviLQHvFAMueUn3FTTlxw8kVAnHcLmfHRg8yLqs 0CUfYZp/wb2Ohq/20e6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDknv-007iE7-17; Fri, 06 Jan 2023 11:22:31 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDknp-007i7f-Mu for opensbi@lists.infradead.org; Fri, 06 Jan 2023 11:22:27 +0000 Received: by mail-wm1-x332.google.com with SMTP id ja17so846071wmb.3 for ; Fri, 06 Jan 2023 03:22:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HoDoFXTUEnBamlOJFiQJa3oZghwJVA1Yq8HD9bgAK/Y=; b=goxlAf4ns+uq6EymF2dzoTvUGbR3+KoTV2owXs2nLDOJCI/5H4xeMzsRGU8F6aDjN9 IeRkO1er6ZVDiQfkuZSygyVmxcn/KS18GB7i9hohfHpWtJDiJpDfKGt4Ht2iFGc3Q8yk Y0zPnjObArl56yceITxr+lEnu5BCo/b5iaWjxRfW8RUflk/k03qgKIED8sgmQko3F8s7 jUUIPt4p3XJxHNTVWMHhyme2NPZTunhvx4/CEffUEXme7Ih+Y4XOCtnAPPDd9/IuhIo3 BZaNbxFuEA+36r6gRyk0m224TRWn2CrizwY3klG3pRC/nkGbUSCzwfc5sRJwGuwff9cV WSlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HoDoFXTUEnBamlOJFiQJa3oZghwJVA1Yq8HD9bgAK/Y=; b=DMW4oKO35KQk1s1ENamGErkMY0+x+4B7Y7RITrSD7pcKUBo9ZOrljMexWdM66cGvaQ fdtEG7Eb19XSyiJ35u1tiUydz2BZeiUE6J5+g6c0KtamSYc1jUE1FzHIy70y0qj9OqpO u85N/91ZyPHKuhbyTIhxz1P6itrRnZ5JSk2byNPvyfV2+OR0OMsbA47Aob/KYpaCa3MU n/Apqk7KF2iW45GKshj/t4IVL6LRmhorOHLfkInOHh9OKHL6w+NXz0NW1eUCj8TwK6fn JlSC6ch+Hp/2FkUr8TLOzdh/fFEEDcL45tPYSEBH1zgfudwOW4Lsn1Y6Ko1iX4Lu5hkS 3W5g== X-Gm-Message-State: AFqh2kqxL90q38HOveHpk+dSSy2TQU/Kfnya5s6QliSHm7oKFDHCpmjE vaWy7psQfBBmi1ADi+VV1z5Urdz/QMTg9+fl X-Google-Smtp-Source: AMrXdXtlJyD2h0iXoJvTnY/G9EdGFG4zJZMAJmZBxOgGi2japQwX0gX19KoYIYdnbKE/EKS5liMJ/w== X-Received: by 2002:a05:600c:3ac8:b0:3d3:4ae6:a71b with SMTP id d8-20020a05600c3ac800b003d34ae6a71bmr39911618wms.2.1673004142294; Fri, 06 Jan 2023 03:22:22 -0800 (PST) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id p16-20020a05600c469000b003d9b87296a9sm6452432wmo.25.2023.01.06.03.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 03:22:21 -0800 (PST) From: Andrew Jones To: opensbi@lists.infradead.org Cc: 'Sia Jee Heng ' , 'Anup Patel ' , 'Ley Foon Tan ' , 'Atish Patra ' Subject: [RFC PATCH 08/11] lib: sbi: Add system_suspend_allowed domain property Date: Fri, 6 Jan 2023 12:22:06 +0100 Message-Id: <20230106112209.441825-9-ajones@ventanamicro.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230106112209.441825-1-ajones@ventanamicro.com> References: <20230106112209.441825-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230106_032225_780264_01E015EE X-CRM114-Status: GOOD ( 15.54 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Only privileged domains should be allowed to suspend the entire system. Give the root domain this property by default and allow other domains to be given the property by specifying it in the DT. Signed-off-by: Andrew Jones --- docs/domain_support.md | 5 +++++ include/sbi/sbi_domain.h | 2 ++ lib/sbi/sbi_domain.c | 4 ++++ lib/utils/fdt/fdt_domain.c | 7 +++++++ 4 files [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:332 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Only privileged domains should be allowed to suspend the entire system. Give the root domain this property by default and allow other domains to be given the property by specifying it in the DT. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- docs/domain_support.md | 5 +++++ include/sbi/sbi_domain.h | 2 ++ lib/sbi/sbi_domain.c | 4 ++++ lib/utils/fdt/fdt_domain.c | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/docs/domain_support.md b/docs/domain_support.md index 8963b57e3787..ac8c73d40b3e 100644 --- a/docs/domain_support.md +++ b/docs/domain_support.md @@ -52,6 +52,7 @@ has following details: * **next_mode** - Privilege mode of the next booting stage for this domain. This can be either S-mode or U-mode. * **system_reset_allowed** - Is domain allowed to reset the system? +* **system_suspend_allowed** - Is domain allowed to suspend the system? The memory regions represented by **regions** in **struct sbi_domain** have following additional constraints to align with RISC-V PMP requirements: @@ -91,6 +92,7 @@ following manner: * **next_mode** - Next booting stage mode in coldboot HART scratch space is the next mode for the ROOT domain * **system_reset_allowed** - The ROOT domain is allowed to reset the system +* **system_suspend_allowed** - The ROOT domain is allowed to suspend the system Domain Effects -------------- @@ -187,6 +189,8 @@ The DT properties of a domain instance DT node are as follows: stage mode of coldboot HART** is used as default value. * **system-reset-allowed** (Optional) - A boolean flag representing whether the domain instance is allowed to do system reset. +* **system-suspend-allowed** (Optional) - A boolean flag representing + whether the domain instance is allowed to do system suspend. ### Assigning HART To Domain Instance @@ -252,6 +256,7 @@ be done: next-addr = <0x0 0x80100000>; next-mode = <0x0>; system-reset-allowed; + system-suspend-allowed; }; udomain: untrusted-domain { diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index f0d9289ec7cc..6f51b3f6324c 100644 --- a/include/sbi/sbi_domain.h +++ b/include/sbi/sbi_domain.h @@ -78,6 +78,8 @@ struct sbi_domain { unsigned long next_mode; /** Is domain allowed to reset the system */ bool system_reset_allowed; + /** Is domain allowed to suspend the system */ + bool system_suspend_allowed; }; /** The root domain instance */ diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index 19e2029e6c4c..38684cdc6527 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -34,6 +34,7 @@ struct sbi_domain root = { .possible_harts = &root_hmask, .regions = root_memregs, .system_reset_allowed = true, + .system_suspend_allowed = true, }; bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartid) @@ -374,6 +375,9 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix) sbi_printf("Domain%d SysReset %s: %s\n", dom->index, suffix, (dom->system_reset_allowed) ? "yes" : "no"); + + sbi_printf("Domain%d SysSuspend %s: %s\n", + dom->index, suffix, (dom->system_suspend_allowed) ? "yes" : "no"); } void sbi_domain_dump_all(const char *suffix) diff --git a/lib/utils/fdt/fdt_domain.c b/lib/utils/fdt/fdt_domain.c index 35462a2008aa..32be6a5ab7e4 100644 --- a/lib/utils/fdt/fdt_domain.c +++ b/lib/utils/fdt/fdt_domain.c @@ -405,6 +405,13 @@ static int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque) else dom->system_reset_allowed = false; + /* Read "system-suspend-allowed" DT property */ + if (fdt_get_property(fdt, domain_offset, + "system-suspend-allowed", NULL)) + dom->system_suspend_allowed = true; + else + dom->system_suspend_allowed = false; + /* Find /cpus DT node */ cpus_offset = fdt_path_offset(fdt, "/cpus"); if (cpus_offset < 0)