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

Re: [PATCH] xen/efi: boot fix duplicated index, offset calculate operation in the copy_mapping loop


  • To: Paran Lee <p4ranlee@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 25 Apr 2022 08:02:27 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • 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=DI0mNHaVTQhsn0fbckggEE65l3p6hVlWm31IMwMt9NU=; b=PyzANgPiFpVkOMVhdCiOWxS671zvrnotFOkzwZAOE6gudHLuK8ULrXAX6rUra3vzk0mDn4bjGHsJIc8YCUmKX2Gs7SgbEbKjR1hR2V6eZhi41uzfdx4OhlcC1YE6iQcUtllLBvUkfz8fk4qF1Lvhiwzmc6PHcttAuSfqpsCfrmQejE8/gHquUagxNYJSJ7Nvf23t2zNjQiauuH3LCPvx8glKBT+n4rrjc6b0X41vLWEOAHv4u6rbpxGbU89eVgXQKTfPgDs4DamQPsHvbkk6O5po7HcvemolIjN6N7FMNxILhrJHQc1gpybA+4Z7vrqrFiT6MqIJHkb7TXCCB9hejg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wf3/ZJBpMh1g7w8qsl3LiA/1X0VMH1FOstLu7j1bg2QY0n4JjeiF4KQ/Nc65KDl8RMQlwhG1BO8/bUA3D2mWxCzXE6CZHUJKl1gOhBIzZl0fi45JNUsPfe2rUbuUZelNhcfcuCQnaQ+gbQRHwJSNH1T64jp6RHr1QrN9AtIYomxBQ3AQuQrBq2/gskRIFGLPiEDovk5nMsDHb4DNf6bJqIpKEwAct7dEtDRIlHtkisMk1VcULFHWoJjhBLXVq5s+ByWFvGhGmW73l7svmFIpKETb17+jRdsD8SaFqnYkzHO1gAiGrPbiAvP4RfAkE9lp9gLydpWuY13XwoT3KECNTA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Austin Kim <austindh.kim@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 25 Apr 2022 06:02:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.04.2022 16:44, Paran Lee wrote:
> It doesn't seem necessary to do that
> duplicated calculation of mfn to addr and l4 table index
> in the copy_mapping loop.

I'm not convinced this is an improvement. If the compiler sees fit, it
can CSE things like this, but it may see reasons not to (register
pressure, for example). Furthermore ...

> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1470,7 +1470,9 @@ static __init void copy_mapping(unsigned long mfn, 
> unsigned long end,
>  
>      for ( ; mfn < end; mfn = next )
>      {
> -        l4_pgentry_t l4e = efi_l4t[l4_table_offset(mfn << PAGE_SHIFT)];
> +        unsigned long addr = mfn << PAGE_SHIFT;

... this isn't 32-bit clean (we build EFI for 64-bit architectures
only right now, but this should not result in there being issues if
anyone wanted to enable the code for 32-bit as well).

> +        unsigned long l4_table_idx = l4_table_offset(addr);

There's no reason I can see for this to be wider than unsigned int.

> +        l4_pgentry_t l4e = efi_l4t[l4_table_idx];
>          unsigned long va = (unsigned long)mfn_to_virt(mfn);
>  
>          if ( !(mfn & ((1UL << (L4_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1)) )
> @@ -1489,7 +1491,7 @@ static __init void copy_mapping(unsigned long mfn, 
> unsigned long end,
>  
>              l3dst = alloc_mapped_pagetable(&l3mfn);
>              BUG_ON(!l3dst);
> -            efi_l4t[l4_table_offset(mfn << PAGE_SHIFT)] =
> +            efi_l4t[l4_table_idx] =
>                  l4e_from_mfn(l3mfn, __PAGE_HYPERVISOR);

_If_ your change was to be taken, you'd want to unwrap this statement
now that it first on a single line.

Jan




 


Rackspace

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