From patchwork Wed Jul 31 18:16:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregor Haas X-Patchwork-Id: 1967259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=Y2A3X327; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=OrAorYQ0; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WZ0g10lLCz20Mv for ; Thu, 1 Aug 2024 04:17:01 +1000 (AEST) 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=5JHZShUn5BmvEnBKH3KG52ekCuxbD0HGuTbi2yY3bE0=; b=Y2A3X327EGDDda aFEIZNL3E+utmEL2YZklGA667+xazKzBaLZ7fBCQ/ZZNKdvZ1ZW1vQ2Kyw25FSjtnWek9OiieGcDc LEydQhKJUOTAIFA5AEt57/711gw++00iEMfwnqSnuGovsrd6vY0QdWlYOmsKAqW2cNKjEWtxyEIcL MCB24xqjJwFkXHUUI64BzH34v7A352vhMgvIhMKkqxUbKaetA7krJHGLuYKH3aSI5uyLMJ+kjzB/5 /wqoQ6r/WLofqFzJ3+2VLqAAoNN2hJJQ5Pn3vPQ2n1+6MyYyEk/1v5U2ZXnoyrIqU6GbyT9bhfUg7 E+lHG8kW+nwCQe2ujYCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZDsb-000000026jX-42Jr; Wed, 31 Jul 2024 18:16:53 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZDsX-000000026fG-1EcM for opensbi@lists.infradead.org; Wed, 31 Jul 2024 18:16:50 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-70d1cbbeeaeso4444870b3a.0 for ; Wed, 31 Jul 2024 11:16:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722449808; x=1723054608; darn=lists.infradead.org; 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=kmc2W94peZoWhT56Qs4Qb6A+5Mo3rnKlJlUVRz++Oyw=; b=OrAorYQ08jbWmVc7gMZisH6W/x8YlLBC1fit1wHbGlHuKFpIPcdabKyx4o0R2A7VbD ufaUpQg2vkwIuCBzSADbMwTh6lQ/ivAsc7wc6G4VGl9t3Wr9LHmVV2WdYz2MJP7cxG1j LAHFmteO8IP9q+ArGNd/G51M6VW6xvxdMI1k/CDlRQO/RoiP8JB8zMYJsRdO9FQrDIJ+ d3OuQBWgGhvqKkdN99zvtlXt9amgkf8mTnmACoxzEP0goA/kJDCa+ZRM/Sk0sfWolb9/ nl5LvyQCBdmKdo7zW9poTTxIFGpFURwKcW+58xtt+YlPL5h68CXFRl3spDfNhR02gYTL TI7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722449808; x=1723054608; 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=kmc2W94peZoWhT56Qs4Qb6A+5Mo3rnKlJlUVRz++Oyw=; b=jXjWVRzR/e3LKC7YQ8t0RPIHAPZIOeCAAGrExUsTdyEb84Nn9ckivTc20YzfEHe1us wYmUfnHvBNn5e5AmzC/XFjBMEw5AhcX08ParMzaOx5Ej/y0/IWF8hDfNcswTXDADIFbB 8UpVrPk42N+hbtQfYeMxJRHg8wTNaDFuiiNyc6EkDciRqn6pyS6xQsTGTpE8Z3ZaMMW2 pZAHHcobcfwZh9lKLwScuGse2+biwUG1DsXP9AKSObkhKfY4vDMqVqQgy1cVtkOjiNl2 sE1krc8x/qOiQIcWr5jg43KSnz1MbpA1Ixi/urOl88NQMVoz17R77x65F/uoSevJhDcY IBRg== X-Gm-Message-State: AOJu0YxAPa0Y49R7+voWTge7q9OAEypC5eqWgm4Z4+1FHPee9qJUaodR 0WrnhVzRZeaA8VtojJ/yh6AnIGZ4jm4Jcd+TobjLdQ89AuWlH/X/SK36ItQH X-Google-Smtp-Source: AGHT+IF3153iIgkCVJRvo7UKmAd+z+cIouJ9oTSkwHBgNYEdnntRg1f5/2ur5EeSStEXOgfYFbRrHw== X-Received: by 2002:a05:6a20:c6ce:b0:1c3:b210:418b with SMTP id adf61e73a8af0-1c68d2cef3cmr185816637.52.1722449807952; Wed, 31 Jul 2024 11:16:47 -0700 (PDT) Received: from localhost ([136.27.11.53]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fed7ee889asm123278225ad.126.2024.07.31.11.16.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 31 Jul 2024 11:16:47 -0700 (PDT) From: Gregor Haas To: opensbi@lists.infradead.org Cc: atishp@rivosinc.com, Gregor Haas Subject: [PATCH 8/8] lib: sbi: memregion: Move memregion_sanitize_pmp() closer to its call site Date: Wed, 31 Jul 2024 11:16:29 -0700 Message-ID: <20240731181629.269898-9-gregorhaas1997@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731181629.269898-1-gregorhaas1997@gmail.com> References: <20240731181629.269898-1-gregorhaas1997@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240731_111649_379306_1E32E5E3 X-CRM114-Status: GOOD ( 11.34 ) X-Spam-Score: -1.8 (-) 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: This is a code movement change to move the previously created memregion_sanitize_pmp() function closer to its call site. --- lib/sbi/sbi_memregion.c | 44 ++++++++++++++++++++ 1 fi [...] Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42d listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [gregorhaas1997(at)gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [gregorhaas1997(at)gmail.com] 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 This is a code movement change to move the previously created memregion_sanitize_pmp() function closer to its call site. --- lib/sbi/sbi_memregion.c | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/sbi/sbi_memregion.c b/lib/sbi/sbi_memregion.c index 3783a0a..7c5a977 100644 --- a/lib/sbi/sbi_memregion.c +++ b/lib/sbi/sbi_memregion.c @@ -4,28 +4,6 @@ #include #include -static void memregion_sanitize_pmp(struct sbi_memregion *reg) -{ - unsigned long base = 0, order; - unsigned long addr = reg->base, size = reg->size; - for (order = log2roundup(size) ; order <= __riscv_xlen; order++) { - if (order < __riscv_xlen) { - base = addr & ~((1UL << order) - 1UL); - if ((base <= addr) && - (addr < (base + (1UL << order))) && - (base <= (addr + size - 1UL)) && - ((addr + size - 1UL) < (base + (1UL << order)))) - break; - } else { - base = 0; - break; - } - } - - reg->base = base; - reg->size = (order == __riscv_xlen) ? -1UL : BIT(order); -} - void sbi_memregion_init(unsigned long addr, unsigned long size, unsigned long flags, @@ -212,6 +190,28 @@ static void merge_memregions(struct sbi_domain *dom, int *nmerged) } } +static void memregion_sanitize_pmp(struct sbi_memregion *reg) +{ + unsigned long base = 0, order; + unsigned long addr = reg->base, size = reg->size; + for (order = log2roundup(size) ; order <= __riscv_xlen; order++) { + if (order < __riscv_xlen) { + base = addr & ~((1UL << order) - 1UL); + if ((base <= addr) && + (addr < (base + (1UL << order))) && + (base <= (addr + size - 1UL)) && + ((addr + size - 1UL) < (base + (1UL << order)))) + break; + } else { + base = 0; + break; + } + } + + reg->base = base; + reg->size = (order == __riscv_xlen) ? -1UL : BIT(order); +} + static int memregion_sanitize(struct sbi_domain *dom, struct sbi_memregion *reg, enum sbi_isolation_method type)