From patchwork Wed Mar 6 13:44:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13584094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA802C5475B for ; Wed, 6 Mar 2024 13:45:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.689333.1074172 (Exim 4.92) (envelope-from ) id 1rhrZs-0006t1-F4; Wed, 06 Mar 2024 13:45:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 689333.1074172; Wed, 06 Mar 2024 13:45:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rhrZs-0006su-CT; Wed, 06 Mar 2024 13:45:00 +0000 Received: by outflank-mailman (input) for mailman id 689333; Wed, 06 Mar 2024 13:44:59 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rhrZr-0006so-3k for xen-devel@lists.xenproject.org; Wed, 06 Mar 2024 13:44:59 +0000 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [2a00:1450:4864:20::533]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b7fa7d10-dbbf-11ee-a1ee-f123f15fe8a2; Wed, 06 Mar 2024 14:44:56 +0100 (CET) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5640fef9fa6so8434230a12.0 for ; Wed, 06 Mar 2024 05:44:56 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id z42-20020a509e2d000000b005669d904871sm7287020ede.49.2024.03.06.05.44.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Mar 2024 05:44:56 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b7fa7d10-dbbf-11ee-a1ee-f123f15fe8a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1709732696; x=1710337496; darn=lists.xenproject.org; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=PTTS79cJ01BN+KslCMfXg18XV1FMJ23RKExX5h1sW5g=; b=AXK2RjIkvw2OeOogSSIq6tfnAR9inGkpurs4zYO5PjASI7T90Q8/sW2xW1l8sPukgq 0wvFfmYeq3vHYOaZeGMUSJS7xf3qVf5a+7t1KES6iOFWp2J2+RJUyOYSBfcxOmjUQuRJ anAnMDMctNqabwtFRAj8u+ZawsYhK/9I0f0FhUIX++SiHrhyP/3DiEbLZ57FiYTuTogi ZIUGgh7s0FADqcCHN/7B+jdPHFhKMaRinppH2scshOzAjyDkaYkuOg2v+7kj+mOnJvN6 GY1lJc12Dp9R/9bmF0UaxvSi45qZah23ncGdIPuiRMYt/oHqoKTPG1X+eWyeYpnSX8rs 69xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709732696; x=1710337496; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PTTS79cJ01BN+KslCMfXg18XV1FMJ23RKExX5h1sW5g=; b=kQSuxXA5nRWJv4faMvVD0QrAKve1wH7rPu+Hr7yXZxElILk1seGbaGDHsQMC25x2Ie SvUsa2NxbDRbTaFOdiMmUK5PW/rsvDUrplDlHhD08RoSbpsMAIOVbXIDgxNSroOv+DH8 SwQvg8S21MNIxoZ97B421Z4YisrGjfKFGJpNk+S1oOWL/mIQZ3k30q6TqQ+8H/NYMEJA ciGNE7J+E7iPLq46BX6/QKvpyu/p6xKW/ztXRhk9osmhq4gc+9ZsEHV5QbzKaGmvM+GG QRYz7x2EcFS+/n6WtXLUNSJdRUh086sw/dZym/AwZf8ny4A7c8qdn2H2jh4SewgH1iJd 4Jpw== X-Gm-Message-State: AOJu0Yzh8/SVdrOzNDzYo9VwnZE5Vre8dA2PnS7GOZ9QREuRBBd1CRNi p4QwJ9eiEJwUQpzG4QBmeHb7fc0eZm8BtC4phhbPFVWIjB2qRY7RYiKLcsgQKHXeSB7bEqwwYos = X-Google-Smtp-Source: AGHT+IEQxSdjMAMzec/52TfDdoDu9tqo4chsAUQ2GTT7Oyqqct74SzPGy7Urfh8vu+i31mx2FrFBEQ== X-Received: by 2002:a50:c8cb:0:b0:566:a235:9355 with SMTP id k11-20020a50c8cb000000b00566a2359355mr11142264edh.33.1709732696236; Wed, 06 Mar 2024 05:44:56 -0800 (PST) Message-ID: <36cf1c15-faa5-4e25-8fdd-9c52076f4ca2@suse.com> Date: Wed, 6 Mar 2024 14:44:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= From: Jan Beulich Subject: [PATCH] x86/entry: don't clear DF when raising #UD for lack of syscall handler Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/e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lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL While doing so is intentional when invoking the actual callback, to mimic a hard-coded SYCALL_MASK / FMASK MSR, the same should not be done when no handler is available and hence #UD is raised. Fixes: ca6fcf4321b3 ("x86/pv: Inject #UD for missing SYSCALL callbacks") Reported-by: Andrew Cooper Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -38,6 +38,14 @@ FUNC_LOCAL(switch_to_kernel) setc %cl leal (,%rcx,TBF_INTERRUPT),%ecx + /* + * The PV ABI hardcodes the (guest-inaccessible and virtual) + * SYSCALL_MASK MSR such that DF (and nothing else) would be cleared. + * Note that the equivalent of IF (VGCF_syscall_disables_events) is + * dealt with separately above. + */ + mov $~X86_EFLAGS_DF, %esi + test %rax, %rax UNLIKELY_START(z, syscall_no_callback) /* TB_eip == 0 => #UD */ mov VCPU_trap_ctxt(%rbx), %rdi @@ -47,12 +55,13 @@ UNLIKELY_START(z, syscall_no_callback) / testb $4, X86_EXC_UD * TRAPINFO_sizeof + TRAPINFO_flags(%rdi) setnz %cl lea TBF_EXCEPTION(, %rcx, TBF_INTERRUPT), %ecx + or $~0, %esi # don't clear DF UNLIKELY_END(syscall_no_callback) movq %rax,TRAPBOUNCE_eip(%rdx) movb %cl,TRAPBOUNCE_flags(%rdx) call create_bounce_frame - andl $~X86_EFLAGS_DF,UREGS_eflags(%rsp) + and %esi, UREGS_eflags(%rsp) /* %rbx: struct vcpu */ test_all_events: ASSERT_NOT_IN_ATOMIC