grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: grub-devel@gnu.org
Cc: dkiper@net-space.pl, Stefan Berger <stefanb@linux.ibm.com>,
	Hari Bathini <hbathini@linux.ibm.com>,
	Pavithra Prakash <pavrampu@in.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Carolyn Scherrer <cpscherr@us.ibm.com>,
	Mahesh Salgaonkar <mahesh@linux.ibm.com>,
	Sourabh Jain <sourabhjain@linux.ibm.com>
Subject: [PATCH 6/9] kern/ieee1275/init: ppc64: Implement alloc_mem_restricted
Date: Tue, 31 Oct 2023 13:50:28 -0400	[thread overview]
Message-ID: <20231031175031.370824-7-stefanb@linux.ibm.com> (raw)
In-Reply-To: <20231031175031.370824-1-stefanb@linux.ibm.com>

Implement alloc_mem_restricted that uses regions_claim() for memory
allocation. The ieee1275 loader will use this function on PowerVM
and PowerKVM and thus avoid usage of memory that it is not allowed
to use.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Pavithra Prakash <pavrampu@in.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Carolyn Scherrer <cpscherr@us.ibm.com>
Cc: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>
---
 grub-core/kern/ieee1275/init.c        | 7 +++++++
 include/grub/powerpc/ieee1275/alloc.h | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index 542a4c595..6a3532aa7 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -585,6 +585,13 @@ region_claim (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
   return ret;
 }
 
+int
+alloc_mem_restricted (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
+                      void *ctx)
+{
+  return regions_claim (addr, len, type, ctx);
+}
+
 static grub_err_t
 grub_ieee1275_mm_add_region (grub_size_t size, unsigned int flags)
 {
diff --git a/include/grub/powerpc/ieee1275/alloc.h b/include/grub/powerpc/ieee1275/alloc.h
index 6bfd3d986..14e37908e 100644
--- a/include/grub/powerpc/ieee1275/alloc.h
+++ b/include/grub/powerpc/ieee1275/alloc.h
@@ -14,4 +14,7 @@ struct regions_claim_request {
   grub_size_t align;      /* alignment restrictions */
 };
 
+int EXPORT_FUNC(alloc_mem_restricted) (grub_uint64_t addr, grub_uint64_t len,
+                                       grub_memory_type_t type, void *ctx);
+
 #endif /* GRUB_POWERPC_IEEE1275_ALLOC_HEADER */
-- 
2.25.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

  parent reply	other threads:[~2023-10-31 17:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 17:50 [PATCH 0/9] ppc64: Restrict memory allocations for kernel and initrd Stefan Berger
2023-10-31 17:50 ` [PATCH 1/9] kern/ieee1275/init: ppc64: Introduce a request for regions_claim Stefan Berger
2023-11-08 16:00   ` Daniel Kiper
2023-11-08 16:05   ` Daniel Kiper
2023-11-10 13:06   ` Hari Bathini
2023-10-31 17:50 ` [PATCH 2/9] kern/ieee1275/init: ppc64: Decide by request whether to initialize region Stefan Berger
2023-10-31 17:50 ` [PATCH 3/9] kern/ieee1275/init: ppc64: Return allocated address and len using context Stefan Berger
2023-11-10 13:07   ` Hari Bathini
2023-10-31 17:50 ` [PATCH 4/9] kern/ieee1275/init: ppc64: Check early for sufficiently large chunk Stefan Berger
2023-11-08 16:11   ` Daniel Kiper
2023-11-08 17:52     ` Stefan Berger
2023-10-31 17:50 ` [PATCH 5/9] kern/ieee1275/init: ppc64: Add support for alignment requirements Stefan Berger
2023-11-10 13:09   ` Hari Bathini
2023-11-10 14:23     ` Stefan Berger
2023-11-10 14:56       ` Stefan Berger
2023-10-31 17:50 ` Stefan Berger [this message]
2023-11-10 13:09   ` [PATCH 6/9] kern/ieee1275/init: ppc64: Implement alloc_mem_restricted Hari Bathini
2023-11-10 13:18     ` Daniel Kiper
2023-11-10 14:26       ` Stefan Berger
2023-11-10 15:51       ` Stefan Berger
2023-11-10 14:25     ` Stefan Berger
2023-10-31 17:50 ` [PATCH 7/9] kern/ieee1275/cmain: ppc64: Introduce flags to identify Power VM and KVM Stefan Berger
2023-10-31 17:50 ` [PATCH 8/9] loader/powerpc/ieee1275: Use new allocation function for kernel and initrd Stefan Berger
2023-10-31 17:50 ` [PATCH 9/9] kern/ieee1275/ieee1275.c: debug: Display successful memory claims Stefan Berger
2023-11-08 16:20 ` [PATCH 0/9] ppc64: Restrict memory allocations for kernel and initrd Daniel Kiper
2023-11-08 17:53   ` Stefan Berger

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=20231031175031.370824-7-stefanb@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=cpscherr@us.ibm.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=hbathini@linux.ibm.com \
    --cc=mahesh@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=pavrampu@in.ibm.com \
    --cc=sourabhjain@linux.ibm.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).