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 D2090EEAA5D for ; Thu, 14 Sep 2023 18:22:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.602628.939304 (Exim 4.92) (envelope-from ) id 1qgqyj-0006v6-6Y; Thu, 14 Sep 2023 18:22:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 602628.939304; Thu, 14 Sep 2023 18:22:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qgqyj-0006uz-3n; Thu, 14 Sep 2023 18:22:13 +0000 Received: by outflank-mailman (input) for mailman id 602628; Thu, 14 Sep 2023 18:22:11 +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 1qgqyh-0006uq-Ru for xen-devel@lists.xenproject.org; Thu, 14 Sep 2023 18:22:11 +0000 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [2a00:1450:4864:20::32b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9e022272-532b-11ee-9b0d-b553b5be7939; Thu, 14 Sep 2023 20:22:09 +0200 (CEST) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-402cc6b8bedso14586185e9.1 for ; Thu, 14 Sep 2023 11:22:09 -0700 (PDT) Received: from [10.80.67.28] (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id m7-20020a05600c280700b003fed630f560sm2607989wmb.36.2023.09.14.11.22.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Sep 2023 11:22:08 -0700 (PDT) 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: 9e022272-532b-11ee-9b0d-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1694715729; x=1695320529; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:references:cc:to :content-language:subject:from:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=FllqSI5+xIUVUowtc5PxyKDUO8P+Ic0Lz0FkQ0j7WnU=; b=aV53yhGfTrYwA6ZY37Xm4j1aW0RZO7PX8oLvNOUUwOAks2XdBUg8K1brQY9Z2caYtf cCb/K3EI1ueK80rrkweEtxNXfdj8EGIyQCa8q5Ju7BPBBQu0KVwK/7h7fAJvo9LZAO5Z z8Fsrq2VOyZi6pt0hgBkY7p28A8J6g3qY7X6g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694715729; x=1695320529; h=content-transfer-encoding:in-reply-to:references:cc:to :content-language:subject:from:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FllqSI5+xIUVUowtc5PxyKDUO8P+Ic0Lz0FkQ0j7WnU=; b=SEDFoPObkyB5uIP/TzeVGxmW2Iv1kzFQ+c0/Xsj8K4s4ICwnM585LzEvgo4iC2KVy3 FrchwY1lIIjOSrPRaRQqT/SZ3H1F3fMhJCJkpn+mvkWGATf8tjVxsT4BesHuEMhTOSaq qTZqGUzR+UrBw6FylSiel2V6ivF1+O4opUsd8uDkpEoSR+i3I1aMje1Xkq+8LF8ic8on iITXwPA8HwNEWkfbeyW1UMPjFCOYAJplOWgNgfUAJF8CnT9xkDHor2GT+xo52BRbHDIz EHVNQbqEq0H96qDkuBzKR2l5WRNBMWYVZObMNsCkL55vQTDqe3Y2irVDyKui9KRENDbu 1skw== X-Gm-Message-State: AOJu0YydqeqvjPjdyJE/zVT3BVGs1EyUNiY9tRQVymicYJ2TnhYQeQUZ IyW6uZfcVdXDwk2335KSZXJvXw== X-Google-Smtp-Source: AGHT+IHkDkbjDiyKuf+xCnhRLgZ4z3TV/HnKjxMMvziNUx8wrMHH0mm3peNhamHB+sjZ+JVZolfpJA== X-Received: by 2002:a05:600c:219:b0:3fb:e189:3532 with SMTP id 25-20020a05600c021900b003fbe1893532mr5612218wmi.20.1694715729072; Thu, 14 Sep 2023 11:22:09 -0700 (PDT) Message-ID: Date: Thu, 14 Sep 2023 19:22:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 From: Andrew Cooper Subject: Re: [PATCH 3/5] x86/emul: Add a pending_dbg field to x86_emulate_ctxt.retire Content-Language: en-GB To: Jan Beulich Cc: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Wei Liu , Jinoh Kang , Xen-devel References: <20230912232113.402347-1-andrew.cooper3@citrix.com> <20230912232113.402347-4-andrew.cooper3@citrix.com> <1e71b915-bec5-2430-3304-f6f46842359d@suse.com> In-Reply-To: <1e71b915-bec5-2430-3304-f6f46842359d@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 14/09/2023 4:04 pm, Jan Beulich wrote: > On 13.09.2023 01:21, Andrew Cooper wrote: >> --- a/xen/arch/x86/x86_emulate/x86_emulate.c >> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c >> @@ -8379,7 +8379,10 @@ x86_emulate( >> if ( !mode_64bit() ) >> _regs.r(ip) = (uint32_t)_regs.r(ip); >> >> - /* Should a singlestep #DB be raised? */ >> + if ( singlestep ) >> + ctxt->retire.pending_dbg |= X86_DR6_BS; > We set "singlestep" about first thing in the function. Is it really correct > to latch that into pending_dbg without regard to rc? (Perhaps yes, seeing > the comment next to the field declaration.) Honestly, without seeing some real RTL, I'm not sure. The thing that is definitely buggy in this retire logic is saying "don't set singlestep if MovSS is pending".  The correct behaviour is to set both PENDING_DBG.BS and INTERRUPTIBILITY.MOVSS, the latter of which causes #DB to be skipped on this instruction boundary. That's why we get the XSA-260 behaviour - when the SYSCALL/INT/etc completes and we hit the subsequent instruction boundary, PENDING_DBG still has values latched in it. With the DONE path being removed, and with the plan to wire in the VMCS register for emulations that occur when something is already pending, then it probably does want to be restricted back to the OKAY case. e.g. We shouldn't latch BS in EXCEPTION Case, or we'd create more XSA-260-like behaviour. I'll adjust in light of this. ~Andrew