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

Re: [PATCH 1/2] x86/head: check base address alignment


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 2 May 2023 12:28:55 +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=N0ielytoTu6NUD/JoRmt6M7O4JGjqcE4ERzlv1AGDK4=; b=K2KFHNrDxIduEUI2O3sn/OoEkKlWmTH72OiK8fU2eQmefMdNPrufN5k5VfUflrLSs2j1MLsiRapYCHSViLH1S2f5MlQWs8YFGPjZ0c3f93+Vqe6xtC6cezz82M3IvsWMtU898KPUbwb2iKM7cO61hA7ZA+Jsr+c9+ENwrd1qPbC2RJB//EglLggU7CNYGIZC4e5sO/huP4AeptrmZyHS6tJSVzhvGXLTw6f3MJKpgqfdvcYZDZXa/Io3akQjlI8s4dfxEljtu4FBZRLaSOlbHoRR62Pf/kV8dF/YrktttODrBJYYF12vEVEqZRSf+5Y4iFZpuoVN224mB6JusAAZiw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ikwz2xTLMztoIowwUlLUlxyZuq6NeHRMzSqD8gdcgkeCYk318rqZPhKXOArDDPEYjT+A6Rs5lMhW7PZnZNlOiJ6/SKG81cBMHtwRP17KIzwDC3Rdbq5Oa7qGkngHzKYVEqc0aIpKeaTs6BTPr6Q4bX4T6uZ/S7W20wg4tb0iEqm09KOTGTm2eXUZ1zAwNeN+uWtSqOIv36NIgyTPSKFOsY41hEkDYzwZxGwqIOL0B3ARf1Jpo0EefzkLMNGo8M+u64uMcL0jhBX7fQvyvavkThTW0r8XquvfaRVMOUTi+ckKQW+wavMig6PguTWqJ2pSHNEyl2CpZ+Om6vKui4HIYg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 02 May 2023 10:29:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 02.05.2023 11:54, Andrew Cooper wrote:
> On 02/05/2023 10:22 am, Roger Pau Monne wrote:
>> Ensure that the base address is 2M aligned, or else the page table
>> entries created would be corrupt as reserved bits on the PDE end up
>> set.
>>
>> We have found a broken firmware where the loader would end up loading
>> Xen at a non 2M aligned region, and that caused a very difficult to
>> debug triple fault.
> 
> It's probably worth saying that in this case, the OEM has fixed their
> firmware.

I'm curious: What firmware loads Xen directly? I thought there was
always a boot loader involved (except for xen.efi of course).

I'm further a little puzzled by this talking about alignment and not
xen.efi: xen.gz only specifies alignment for MB2 afaik. For MB1 all
it does specify is the physical address (2Mb) that it wants to be
loaded at. So maybe MB2 wants mentioning here as well, for clarity?

>> @@ -670,6 +674,11 @@ trampoline_setup:
>>          cmp     %edi, %eax
>>          jb      1b
>>  
>> +        /* Check that the image base is aligned. */
>> +        lea     sym_esi(_start), %eax
>> +        and     $(1 << L2_PAGETABLE_SHIFT) - 1, %eax
>> +        jnz     not_aligned
> 
> You just want to check the value in %esi, which is the base of the Xen
> image.  Something like:
> 
> mov %esi, %eax
> and ...
> jnz

Or yet more simply "test $..., %esi" and then "jnz ..."?

Jan



 


Rackspace

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