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

Re: [PATCH v3 03/16] x86/boot: add cmdline to struct boot_domain


  • To: Denis Mukhin <dmkhn@xxxxxxxxx>
  • From: Alejandro Vallejo <agarciav@xxxxxxx>
  • Date: Thu, 10 Apr 2025 13:02:48 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=proton.me 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=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=zZ2nJtowApfrh7mjutfINTXmd8npFWaFh2bbOnPVgs4=; b=UE4fGvcXLIU6rabqLyOl4W8/uSCuPqt6eCUyHTBLJxpas0r7+a2r92EPkTMJa3k01dxATikjumHxqSCFRMZq47mQDLPc73cJb++IxAU03XrsM3iJYh/imAPyFXBESFBvwxTixBqKMQ+jI3AsK3I3qbJPDJTtKz0f7tnnie089TwXJoGiFEXBp74eLo6grW2C5v/lhoznv95vf2kdcfjWsG6YNI33ILDdGrwGCNpr3YGyb2fTMRQ7KX0e26hxMGxKuRjyuhK0j/ga7NkMWJnKnV+ZUhFDvKSipGXjZlQWAU4ai0alDY4TzCMSaetNtqKFYcc/0Igp/pX04nZWShCLIQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kosnbQTFLXM6u7onP7CdcAl3epyV2qt6uAiKmnHmMf/Y58qljWuESlTknR6lm9o5HEQXhcRrhpzic9XODYb/7RF+A3Wr5aOMnB0AaJdUEBsDFNpvEQ5kliT7aoz+LVW9SMbk5TLb8hQlqjH729w0IJIBA6XqTFp/59QxUKW+L6UXXV0BIkHnuquVJygSeI/e3ux2Ce8WtgZ/Aa2WwwGaQ7LwyezdC5E27PRpvMQ11kSJMTiTnt3iStlPFXqix6oPbRZpvx3orACqY439AjWQMMpe4g2QlbKh3pAXvQ1cgUGts96KIpNZxMMDJjJ7opEbRYh5/AghDmRyXc1MUlZL7A==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, "Xenia Ragiadakou" <xenia.ragiadakou@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 10 Apr 2025 12:03:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed Apr 9, 2025 at 10:05 PM BST, Denis Mukhin wrote:
> On Tuesday, April 8th, 2025 at 9:07 AM, Alejandro Vallejo <agarciav@xxxxxxx> 
> wrote:
>
>> 
>> 
>> From: "Daniel P. Smith" dpsmith@xxxxxxxxxxxxxxxxxxxx
>> 
>> 
>> Add a container for the "cooked" command line for a domain. This
>> provides for the backing memory to be directly associated with the
>> domain being constructed. This is done in anticipation that the domain
>> construction path may need to be invoked multiple times, thus ensuring
>> each instance had a distinct memory allocation.
>> 
>> Signed-off-by: Daniel P. Smith dpsmith@xxxxxxxxxxxxxxxxxxxx
>> 
>> Signed-off-by: Jason Andryuk jason.andryuk@xxxxxxx
>> 
>> Signed-off-by: Alejandro Vallejo agarciav@xxxxxxx
>> 
>> ---
>> No changes on ACPI cmdline handling on PVH, as it's orthogonal to the
>> purpose of this patch.
>> 
>> v3:
>> * s/xfree/XFREE/ on failed construct_dom0() to avoid a dangling
>> cmdline ptr.
>> * Re-flow hvm_copy_to_guest_phys() into a multi-line call.
>> * s/bd->cmdline != NULL/b->cmdline/ (to homogenise with the previous
>> 
>> cmdline pointer check)
>> ---
>> xen/arch/x86/hvm/dom0_build.c | 12 +++----
>> xen/arch/x86/include/asm/boot-domain.h | 1 +
>> xen/arch/x86/pv/dom0_build.c | 4 +--
>> xen/arch/x86/setup.c | 50 +++++++++++++++++++-------
>> 4 files changed, 47 insertions(+), 20 deletions(-)
>> 
>> diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
>> index 2a094b3145..ebad5a49b8 100644
>> --- a/xen/arch/x86/hvm/dom0_build.c
>> +++ b/xen/arch/x86/hvm/dom0_build.c
>> @@ -653,7 +653,6 @@ static int __init pvh_load_kernel(
>> void *image_start = image_base + image->headroom;
>> 
>> unsigned long image_len = image->size;
>> 
>> unsigned long initrd_len = initrd ? initrd->size : 0;
>> 
>> - const char *cmdline = image->cmdline_pa ? __va(image->cmdline_pa) : NULL;
>> 
>> const char *initrd_cmdline = NULL;
>> struct elf_binary elf;
>> struct elf_dom_parms parms;
>> @@ -736,8 +735,8 @@ static int __init pvh_load_kernel(
>> initrd = NULL;
>> }
>> 
>> - if ( cmdline )
>> - extra_space += elf_round_up(&elf, strlen(cmdline) + 1);
>> + if ( bd->cmdline )
>> 
>> + extra_space += elf_round_up(&elf, strlen(bd->cmdline) + 1);
>
> I think it makes sense to use local variable to cache the results of 
>
>   strlen(bd->cmdline) + 1
>
> since the construct is used multiple times within pvh_load_kernel()
>
> E.g. cmdline_len similarly to {image,initrd}_len.
>

Seeing how you're the second person to propose the same thing, I'll bite
and just do it. I really dislike the wall of locals in
pvh_load_kernel(), but oh well...

Cheers,
Alejandro



 


Rackspace

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