[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v6 4/4] xen/console: switch conring runtime allocation to xvmalloc


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: dmukhin@xxxxxxxx
  • Date: Fri, 8 May 2026 17:57:14 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 205.220.161.53) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=ford.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ford.com; dkim=pass (signature was verified) header.d=saarlouis.ford.com; dkim=pass (signature was verified) header.d=ford.com; arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QYm8EAry6WG8/+zkqrDQqEF0fU/zew7ZJhkCv6bfAns=; b=Ip4d7rn6W86+SgtfK2XYX0MaFjgx9WafG6aewBPdnCboG9Ft3TWKxYON/tQJE0E/YHaEfBkjAd7cVxyVSIYLMQBJLIHQqoRMNONfrPVaE/Y8iVK3wzMoMA9SPuZlJrD7vKSXlf1lQ4Xz0m5rtAN1SHXNU4Sjebo/kVGVnOCfu42dFr5U7l3t+1mnWgkUNOI4tM4uMJWjQAQGCHafqAopbf2PpPLfGet7mk9fgpMfRvWKDm99mCnaurYv43CNxI+XruSSVa88HAtXgyj69UZBsKiD+0esme4BbsJpWTdDo/gtN6cTgCSDdD/QYaVsvsCNxec/HdPyrWINbWDn50WkFg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xBah3hE6FUezzwxApmOYVTnuPz+RAapmDqurdg7guGv9q1ljDEM7DuC1eAQBuvRehoQzRbgqR2gBbOmEG+FdkBfr7bNp3bTOH+UyxFShZCMWL6Z98CwM5SRwoM/w2j+8zi9iViGDxYxv479zDcdjCSjXOxERTdOMdlodMUTdQw6JZSsSK47UPYeYYo7gOzdECFnFwmvRiuICUVjIQazF+52bhUvfQpMKq36KHV2SLGp48TD5T1/ODVzWBZYPiIHrCYyTGK7DoXvW34XbYPW0a2ZGwun9QiN3R/Bbrf4PKc1Ohl9oQ9tAdzxrw4SB3b3z+i6iR0jTNim1S3z1hKgS6Q==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=ppford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=selector2-azureford-onmicrosoft-com header.d=azureford.onmicrosoft.com header.i="@azureford.onmicrosoft.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=ppserprodsaar header.d=saarlouis.ford.com header.i="@saarlouis.ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=ppfserpocford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"
  • Cc: andrew.cooper3@xxxxxxxxxx, anthony.perard@xxxxxxxxxx, jbeulich@xxxxxxxx, julien@xxxxxxx, michal.orzel@xxxxxxx, roger.pau@xxxxxxxxxx, sstabellini@xxxxxxxxxx, dmukhin@xxxxxxxx
  • Delivery-date: Sat, 09 May 2026 00:57:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Pser-m365-app: SER-APP

From: Denis Mukhin <dmukhin@xxxxxxxx> 

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
warnings when the requested size is adjusted.

Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
Changes since v5:
- switched to xvmalloc_array()
- fixed conring size checks
- corrected diagnostic messages
---
 xen/drivers/char/console.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 5cac87d052b9..29b9359468e7 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>
@@ -343,6 +344,7 @@ static void cf_check do_dec_thresh(unsigned char key, bool 
unused)
 static unsigned int __initdata opt_conring_size;
 size_param("conring_size", opt_conring_size);
 
+#define CONRING_SIZE_MIN    (1U << 14)
 #define _CONRING_SIZE       (1U << CONFIG_CONRING_SHIFT)
 #define CONRING_IDX_MASK(i) ((i) & (conring_size - 1))
 static char __initdata _conring[_CONRING_SIZE];
@@ -464,20 +466,33 @@ void __init console_init_ring(void)
 {
     char *ring;
     XENCONS_RING_IDX i, size;
-    unsigned int order, memflags;
+    unsigned int order;
     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 )
+    size = PAGE_SIZE << order;
+    if ( size != opt_conring_size )
     {
-        BUG_ON(order == 0);
-        order--;
+        opt_conring_size = size;
+        printk(XENLOG_WARNING "Normalizing console ring size.\n");
     }
-    opt_conring_size = PAGE_SIZE << order;
+    if ( opt_conring_size < CONRING_SIZE_MIN )
+    {
+        opt_conring_size = 0;
+        printk(XENLOG_WARNING "Ignoring too-small console ring size 
override.\n");
+        return;
+    }
+    else if ( opt_conring_size > GB(2) )
+    {
+        opt_conring_size = GB(2);
+        printk(XENLOG_WARNING "Limiting user-configured console ring size to 2 
GiB.\n");
+    }
+
+    ring = xvmalloc_array(char, opt_conring_size);
+    BUG_ON(ring == NULL);
 
     nrspin_lock_irqsave(&console_lock, flags);
 
-- 
2.54.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.