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

Re: [PATCH v2 3/3] x86/PVH: Support relocatable dom0 kernels


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Wed, 13 Mar 2024 17:02:56 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=BOA50aDClGxCZ7KJGc0o8TzBjN4VZHbs1YW90aGbT30=; b=i/RvT1UQWqJHEaBEmv+NyCIMLpwbk4qjYnOd2qnsVjPbLS+9Dk+z9iGek1Y1B1kIwoI8fD1EkfkxYQIm5gLVxpEWcps3M1dhdalkPpURU1xI1oKJj6+7JP64xqBMF2mKJRVDJ3+mjH1iZmi20gpCQzjVe/t9U1/BRCxhdIqbCXboxoi1Jmk+X99vaieHhmDMtfmGN0iPZvYMQV7m0TQcgIJ/5pcg4jIAYcnR/uJO8QR/8gZ3iEfKLd8I2Lhot7EIIH+5Yqjym08MLe3Nx54FNv47xAEzMwqoiLUjW6rx3O7r0jDtheaWgxCVXFJTbQPkwR0twiw3WXLu/CWBZgOIkA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JMKwaKhcpgQhawOrA1+H+tTRz+yf8CpAfuR33RbynQTaT5005BOLVreZ1M0S80kbhm7vNVCvBnvfB4s40zIXGj5RnNia2kxFwGoVVT3LMNT66/ELGAMCGFiqPYSTQbjXrBvfeRHBkwiM8RwFFFe/GKN+vMTIcqASUvbQ0YklV9FZYtDH4TkJcy8+qz30GpvZguVaCde/U2UjtA5p2O6vKyIB96vNmIp6YZaWRa/ioSzJcm4sN+CvrJamqzR1J+n8j+UA2Su28LoMUPJWRWEA4iFzGq+t6CYM/dlSmubURBTDcRnO69CCyvOsqOUmT/KlxunqVUvq71Z4Uj2D5vSEuA==
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 13 Mar 2024 21:11:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2024-03-13 15:30, Jason Andryuk wrote:
+/* Find an e820 RAM region that fits the kernel at a suitable alignment. */
+static paddr_t __init find_kernel_memory(
+    const struct domain *d, struct elf_binary *elf,
+    const struct elf_dom_parms *parms)
+{
+    paddr_t kernel_start = (paddr_t)elf->dest_base & PAGE_MASK;
+    paddr_t kernel_end = PAGE_ALIGN((paddr_t)elf->dest_base + elf->dest_size);
+    paddr_t kernel_size = kernel_end - kernel_start;
+    unsigned int i;
+
+    /*
+     * The memory map is sorted and all RAM regions starts and sizes are
+     * aligned to page boundaries.
+     */
+    for ( i = 0; i < d->arch.nr_e820; i++ )
+    {
+        paddr_t start = d->arch.e820[i].addr;
+        paddr_t end = d->arch.e820[i].addr + d->arch.e820[i].size;
+        paddr_t kstart, kend;
+
+        if ( d->arch.e820[i].type != E820_RAM )
+            continue;
+
+        if ( d->arch.e820[i].size < kernel_size )
+            continue;
+
+        kstart = ROUNDUP(start, parms->phys_align);
+        kstart = kstart < parms->phys_min ? parms->phys_min : kstart;

This should be
        kstart = MAX(kstart, parms->phys_min);

Regards,
Jason

+        kend = kstart + kernel_size;
+
+        if ( kend > parms->phys_max )
+            return 0;
+
+        if ( kend <= end )
+            return kstart;
+    }
+
+    return 0;
+}



 


Rackspace

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