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

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


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 2 May 2023 13:11:12 +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=n75EAu9Yc8oJm1hbgtfHoz+EO3uNctXze4Zfpbc9TFU=; b=Z4tD5AIZC/Ptji/ehoWxrAyDuS9l3MgsuP9bSm5vBMJf0JMsOTOYVR7GrzEDZsxt/HCXAyJ1jr9BBrLELynrzaqIxS2DDfSxP5Ieigmy67Ddfix26I3fUTpPiMCN56eM6KCfOSPK7JyWRhHkKsqUlBr266v95CY6RvOa8UFACSJqb23SX7dvlcUe6HgYC+Ahh5UHsrZaTfHWry0MPZ9vga9qhG2Fi2g4jkv7ptma14P+P1tVGzCxG6fdMVXZQfWNy4z6xRJ314AXo/1F8Nqop4u8Auu/meUa3zZJ/M5zWodXGJSCUwgZMb0diUUAtUuHP3XY27KP631KKow+2Z55KA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lSV+nmqpe7tb4fBc6V/h5l9GR1v4OFNloFdlKtBv+U8wvV2gBUBRcM7ItadxZA7FXhU7zse8/iUP4Z1cRDoELrKZn4Gzg43P2sQCvcFfVH3gGr9EpDfAoHM1j+Q7hIfsn51h4d35A7M1RDuVEK+R6eYQK8wHFZQyh4BZ6lH6kPLSUHIGhKNKpSMLnEaAKC6GFq5C0F1BpzK8FTiK21Beh/CiEd5ESaOYx3NaTc3Ju98Q66ghg3FEjy0QOGrNg9u4ISIwZS9TtWCSc8Sy9AcK2OaNONcc/rD8KPPsmZ45zmdSKLAmftAcd/gbh9Ju78K2PaaXVKW7aj61Rn84uzr0Ww==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 02 May 2023 11:11:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 02.05.2023 13:05, Jan Beulich wrote:
> On 02.05.2023 12:51, Roger Pau Monné wrote:
>> On Tue, May 02, 2023 at 12:28:55PM +0200, Jan Beulich wrote:
>>> On 02.05.2023 11:54, Andrew Cooper wrote:
>>>> On 02/05/2023 10:22 am, Roger Pau Monne wrote:
>>>>> @@ -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 ..."?
>>
>> As replied to Andrew, I would rather keep this inline with the address
>> used to build the PDE, which is sym_esi(_start).
> 
> Well, I won't insist, and you've got Andrew's R-b already.

Actually, one more remark here: While using sym_esi() is more in line
with the actual consumer of the data, the check triggering because of
the transformation yielding a misaligned value (in turn because of a
bug elsewhere) would yield a misleading error message: We might well
have been loaded at a 2Mb-aligned boundary, and instead its internal
logic which would then have been wrong. (I'm sorry, now you'll get to
judge whether keeping the check in line with other code or with the
diagnostic is going to be better. Or split things into a build-time
and a runtime check, as previously suggested.)

Jan



 


Rackspace

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