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

Re: [PATCH v1.1 61/65] x86/entry: Make syscall/sysenter entrypoints CET-IBT compatible


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 3 Dec 2021 14:48:44 +0100
  • 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=00IiUJ+qCnjd6G/lxZPyTmg1lhKbzuTbjO8qNUGdmNo=; b=j1HvlFMOG6ik3GhCLQOzpwpvpTmL5iDvcM24GwY1sk9fiwADSiBmAAWv+LiBgO6xFIl79SvRV7sMepsxTLKcb5LbI61LifXpw6+LYrZon0Xwvxsh8l6tt5E152Y79M2zv65EHIN152vw4EpYUfED3rWhyCVepO9P4+rosaGwFUYFZrTt4RNGwhSSI96rmEfsfXensdQ4uUQKkCVcLxBLbCzoolXv9rsWJ8uFFEM4lT7EdxkyckrbjalczE5iERQV4v15tE1dH7BIrKqqGk/Wb9vb1hrTyjYjNR1dB2wczh1k19BFmDLy6Pp5wV/7957rMV2h/j639NBq6dt/r8lySQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fLhQysXXbNa9WlEwrSS2qjP7SKaiRE1U8bZZtlb5XLM21Pv6VuNwOjELmJN+ln9EXgCCBbj9z0Hb6pgiHOMnd+JBny6gxuI5DkXCv6kjlGIGjVXaypdvJgfr4koj+2nfLW35rs/v+4LkbUat9CatTK7TuLX3nEmMm0iwcmMsy3dsJvPy5VM1hMDyxUckwUW9mbIWWW7m1dBfpFcQeTtIqflVaVJrfY1x83z5vI7Xy2dr06qP8/EI/DCd3VdyL5N2hoERQwF6PXngsoI12HXE3tVmBMgX3/8ORYxM67IZVykLdjY7gKLpTZDkBrJE/ju/sTQALwuNOzXpwANoC5m6XA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 03 Dec 2021 13:49:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.11.2021 17:37, Andrew Cooper wrote:
> Each of MSR_{L,C}STAR and MSR_SYSENTER_EIP need to land on an endbr64
> instruction.  For sysenter, this is easy.
> 
> Unfortunately for syscall, the stubs are already 29 byte long with a limit of
> 32.  endbr64 is 4 bytes.  Luckily, there is a 1 byte instruction which can
> move from the stubs into the main handlers.

Oh, you actually found a different solution to the space problem. I should
probably have looked here first, but this being a v1.1 it sits lower in my
mailbox ...

> Move the push %rax out of the stub and into {l,c}star_entry(), allowing room
> for the endbr64 instruction when appropriate.  Update the comment describing
> the entry state.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

> @@ -295,6 +296,12 @@ static unsigned int write_stub_trampoline(
>  {
>      unsigned char *p = stub;
>  
> +    if ( cpu_has_xen_ibt )
> +    {
> +        place_endbr64(p);
> +        p += 4;
> +    }
> +
>      /* Store guest %rax into %ss slot */
>      /* movabsq %rax, stack_bottom - 8 */
>      *p++ = 0x48;
> @@ -315,10 +322,6 @@ static unsigned int write_stub_trampoline(
>      *(uint64_t *)p = stack_bottom - 8;
>      p += 8;
>  
> -    /* Store guest %rsp into %rsp slot */
> -    /* pushq %rax */
> -    *p++ = 0x50;
> -
>      /* jmp target_va */
>      *p++ = 0xe9;
>      *(int32_t *)p = target_va - (stub_va + (p - stub) + 4);

With this it's even less clear to me why you did remove the 16-byte
alignment in the other patch. Initially I expected you would extend
the "first half" of stub space by 2 bytes.

Jan




 


Rackspace

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