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

Re: [PATCH 6/8] x86/entry: Track the IST-ness of an entry for the exit paths


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 14 Sep 2023 11:32:04 +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=w0+kUN7Q3YoxPaK9V0YptjbAt6nhVQFSlr+4KgqzW4w=; b=FxDAOQQEM3hErYl/XBf5t/cw/auPKYh7y/C4x7aPA4l9FuXpldstvsn7E4QC1+LMSbdBYlnphpntAlvXLcFt9++pYlFhnyhIRTUqpFindW9m021VXGtoX3Yr+R1cEF0W1l8ZGczATypoACrIjRFmgyc5//ChhU0R0xgojDvEfOpJWNTtR6ZwSXjVcbVLhuRsYq90XcMlXsiFUUOAZOgiokJy4pe1fob2vYA95dhUomYPjIBenAiaLDh3UnZskrqOFy3/w/yvjRZjYAA5zfuHZ7J0GiCwCslRd7XyScASRztluUUpC/95sg6FS1UvwvaIzSJVGNw+RNd0Yky3E6vDng==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l/sQ/hPf7aJMvgujH5SL/Okk7QmqCbFu4Ubk6MOl8OrXQpYJpqMh3k1fhp8m86qXoQBT/HfKGw3tJyXYyI0NeCdqBQw9QQVU3WwcGi3iAetl6x8JS/SNSkDbeouALb5oCu9Ls6FtdbXpqA6AgRJGhuvyBSaKYg7kUn4Ccn/QkVdhTii2J2mc4sKqgO7FM7QQ4G4xsH6i68bh5kQs/ltM7RJBERzCW6ZmKq5UqQvznPYSVYrbrhMPTX+aXawOQiPO1D/7uuvLMq+9al8UuWm6HIJ458ERFAnYztRzb1gY37N0xr2Ax160yHrLDKqAOWD+/O+Rvb9rMxDCLP606jvK6A==
  • 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: Thu, 14 Sep 2023 09:34:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 13.09.2023 22:27, Andrew Cooper wrote:
> --- a/xen/arch/x86/x86_64/compat/entry.S
> +++ b/xen/arch/x86/x86_64/compat/entry.S
> @@ -117,8 +117,15 @@ compat_process_trap:
>          call  compat_create_bounce_frame
>          jmp   compat_test_all_events
>  
> -/* %rbx: struct vcpu, interrupts disabled */
> +/* %rbx: struct vcpu, %r12: ist_exit, interrupts disabled */
>  ENTRY(compat_restore_all_guest)
> +
> +#ifdef CONFIG_DEBUG
> +        mov   %rsp, %rdi
> +        mov   %r12, %rsi
> +        call  check_ist_exit
> +#endif
> +
>          ASSERT_INTERRUPTS_DISABLED
>          mov   $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), %r11d
>          and   UREGS_eflags(%rsp),%r11d

Without having peeked ahead, is there any use of %r12 going to appear
on this path? I thought it's only going to be restore_all_xen?

> --- a/xen/arch/x86/x86_64/entry.S
> +++ b/xen/arch/x86/x86_64/entry.S
> @@ -142,10 +142,16 @@ process_trap:
>  
>          .section .text.entry, "ax", @progbits
>  
> -/* %rbx: struct vcpu, interrupts disabled */
> +/* %rbx: struct vcpu, %r12: ist_exit, interrupts disabled */
>  restore_all_guest:
> -        ASSERT_INTERRUPTS_DISABLED
>  
> +#ifdef CONFIG_DEBUG
> +        mov   %rsp, %rdi
> +        mov   %r12, %rsi
> +        call  check_ist_exit
> +#endif
> +
> +        ASSERT_INTERRUPTS_DISABLED
>          /* Stash guest SPEC_CTRL value while we can read struct vcpu. */
>          mov VCPU_arch_msrs(%rbx), %rdx
>          mov VCPUMSR_spec_ctrl_raw(%rdx), %r15d

Even here I don't think I see a need for the addition. Plus if the check
is warranted here, is it really necessary for it to live ahead of the
interrupts-disabled check? Further, seeing that being marco-ized, would
it make sense to have a CHECK_IST_EXIT macro in case more than a single
use site remains?

> @@ -1087,6 +1100,10 @@ handle_ist_exception:
>  .L_ist_dispatch_done:
>          mov   %r15, STACK_CPUINFO_FIELD(xen_cr3)(%r14)
>          mov   %bl, STACK_CPUINFO_FIELD(use_pv_cr3)(%r14)
> +
> +        /* This is an IST exit */
> +        mov   $1, %r12
> +
>          cmpb  $X86_EXC_NMI, UREGS_entry_vector(%rsp)
>          jne   ret_from_intr

Could I talk you into using a less than 7-byte insn here? "or $1, %r12"
would be 4 bytes, "mov $1, %r12b", "inc %r12", and "not %r12" would be
just 3. All have certain downsides, yes, but I wonder whether switching
isn't worth it. Even "mov $1, %r12d" would be at least one byte less,
without any downsides. And the OR and INC variants would allow the
remaining 63 bits to be used for another purpose down the road.

Jan



 


Rackspace

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