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

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


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 3 May 2023 10:08:20 +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=DaxVrrA90NzQvNu/mjQcPr0kvA7Gj9knhoypR4X+QXI=; b=iV8/Xlb4DUaL29JayndH83Kz4ubk71ihxSlEJJW04n9e39Ovx2huPR1Zgs1hysbHy7+Ck+70jnBO+63OfFbrdHoJ3FM5V+msospBfGiHOuxk/siEdJi9vUZc5oOjlhpb3nmMSDzlrLiUlWEjNZSiPNCKJLs1yMMDTS9eyFh4QV/uCCZgYpQBOsAKX7OjkM/n1A0stUXZx9vkKrwWHPxuXTHnQ0OJFcmIdP2vI8W1Xe6VpB8YIqzfjdiGmkzTjtdoLWZy4HBVCvt7+aeRnuL1qP4KB+30OK9ZmxovvUNwQSfQ/vjERddH4aX5CbhDrhmp7QUVMZKc30CaEN4c771NMQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ifkwBpCendxZkEV9W6kA0Vw6qpd2Qm5WNJsTHbZW1oHTD0uBt23rug0QR8Ge/SL/KoJxK0svfoTZOID+gSXKpCQ6H27Z/HDfysoT0Hl9cg8bsPYBw1W5jFD4OD+eaSPWXvWMotDG0cKdb4LxLg7u40dU2af1stzUOyFjEQPC7Uf3Uy16rLcm61JG3A/FrhlLFaztTEbZWyaR3IptzD/FsS9k2rXo+miLS9vrQVkMLTDPxXEidoeh6YRUx/O7R6vhHhVqk4V5cOX6857X4nfr2t2fH1r1KRBylSEyS2KsNLx+pTCJYdmPKEKI6GwIDiIMrNKGynSl8M+Pnapia0nT9A==
  • 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: Wed, 03 May 2023 08:08:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 02.05.2023 16:59, 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 encountered a broken firmware where grub2 would end up loading
> Xen at a non 2M aligned region when using the multiboot2 protocol, and
> that caused a very difficult to debug triple fault.
> 
> If the alignment is not as required by the page tables print an error
> message and stop the boot.  Also add a build time check that the
> calculation of symbol offsets don't break alignment of passed
> addresses.
> 
> The check could be performed earlier, but so far the alignment is
> required by the page tables, and hence feels more natural that the
> check lives near to the piece of code that requires it.
> 
> Note that when booted as an EFI application from the PE entry point
> the alignment check is already performed by
> efi_arch_load_addr_check(), and hence there's no need to add another
> check at the point where page tables get built in
> efi_arch_memory_setup().
> 
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Would you mind if, while committing, ...

> @@ -146,6 +148,9 @@ bad_cpu:
>  not_multiboot:
>          add     $sym_offs(.Lbad_ldr_msg),%esi   # Error message
>          jmp     .Lget_vtb
> +not_aligned:

... a .L prefix was added to this label, bringing it out of sync with the
earlier one, but in line with e.g. ...

> +        add     $sym_offs(.Lbag_alg_msg),%esi   # Error message
> +        jmp     .Lget_vtb
>  .Lmb2_no_st:

... this one? I don't think the label is particularly useful to have in
the symbol table (nor are not_multiboot and likely a few others).

Jan



 


Rackspace

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