From: Denis Mukhin <[email protected]>
The console ring only needs to be virtually contiguous; it does not need
a naturally aligned or physically contiguous allocation. Replace the
runtime xenheap allocation in console_init_ring() with an xvmalloc-backed
buffer.
Also clamp the user-configured ring size to the supported range and emit
warning when the requested size is adjusted.
Drop full stops in all diagnostic messages in console_init_ring() to align
code with the common code pattern.
Suggested-by: Andrew Cooper <[email protected]>
Signed-off-by: Denis Mukhin <[email protected]>
---
Changes since v7:
- Jan's feedback from
https://lore.kernel.org/xen-devel/[email protected]/
---
xen/drivers/char/console.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 40355c1d14d6..09282a7a4f8e 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -33,6 +33,7 @@
#include <asm/setup.h>
#include <xen/sections.h>
#include <xen/consoled.h>
+#include <xen/xvmalloc.h>
#ifdef CONFIG_X86
#include <asm/guest.h>
@@ -464,20 +465,30 @@ void __init console_init_ring(void)
{
char *ring;
unsigned int done, size, n;
- unsigned int order, memflags;
unsigned long flags;
if ( !opt_conring_size )
return;
- order = get_order_from_bytes(max(opt_conring_size, conring_size));
- memflags = MEMF_bits(crashinfo_maxaddr_bits);
- while ( (ring = alloc_xenheap_pages(order, memflags)) == NULL )
+ if ( opt_conring_size < GB(2) )
{
- BUG_ON(order == 0);
- order--;
+ unsigned int order = get_order_from_bytes(max(opt_conring_size,
+ conring_size));
+
+ opt_conring_size = PAGE_SIZE << order;
+ }
+ else
+ {
+ printk(XENLOG_WARNING
+ "Limiting user-configured console ring size to 2 GiB\n");
+ opt_conring_size = GB(2);
+ }
+
+ while ( (ring = xvmalloc_array(char, opt_conring_size)) == NULL )
+ {
+ BUG_ON(opt_conring_size == 0);
+ opt_conring_size >>= 1;
}
- opt_conring_size = PAGE_SIZE << order;
nrspin_lock_irqsave(&console_lock, flags);
@@ -498,7 +509,7 @@ void __init console_init_ring(void)
conring_size = opt_conring_size;
nrspin_unlock_irqrestore(&console_lock, flags);
- printk("Allocated console ring of %u KiB.\n", opt_conring_size >> 10);
+ printk("Allocated console ring of %u KiB\n", opt_conring_size >> 10);
}
/*
--
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.