From patchwork Fri Sep 15 20:36:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13387667 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 F06A0CD379F for ; Fri, 15 Sep 2023 20:36:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.603362.940348 (Exim 4.92) (envelope-from ) id 1qhFYW-0001YQ-HA; Fri, 15 Sep 2023 20:36:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 603362.940348; Fri, 15 Sep 2023 20:36:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qhFYW-0001XY-9E; Fri, 15 Sep 2023 20:36:48 +0000 Received: by outflank-mailman (input) for mailman id 603362; Fri, 15 Sep 2023 20:36:46 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qhFYU-0001T8-QQ for xen-devel@lists.xenproject.org; Fri, 15 Sep 2023 20:36:46 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 96400495-5407-11ee-8788-cb3800f73035; Fri, 15 Sep 2023 22:36:46 +0200 (CEST) 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: 96400495-5407-11ee-8788-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1694810205; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dnP+oePB0vRmA7Ftd/dfzOPN8MOvJT2QivCpHSwftUo=; b=NnwB3GwOnO8SvjmeYphhRsOJSoHZLkBM2bPEUwVlcZIS4F18H6udfgJ7 WGzTRVkdU6Gcv42pW4gZclg6h94DLQAfjU7ljhZTZCelyTzLhTW4NV5Q6 hxMWaYRKSR4t+bwtDP73V+7X9S8cjhMS7sU12MiCYEr8MmB5IrX391jSR o=; X-CSE-ConnectionGUID: eus45eGnS1utRCA1wDu4og== X-CSE-MsgGUID: Tom/6qoBRv24WmLJKJR2AQ== Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 121464506 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:CyQJ2ao/F8zo5JUaNgPskv6+nh9eBmIuZRIvgKrLsJaIsI4StFCzt garIBmFPfaCZWSke90lOY3j9E1XvsOByYUwHAY+qSBmESoSopuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbOCYmYpA1Y8FE/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GlwUmAWP6gR5wePziRNV/rzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAD0QdUzeis2w++umVtNHr508ANS3O4xK7xmMzRmBZRonaZXKQqGM7t5ExjYgw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Talos-MUID: 9a23:BSAEngwHvJFWDn6KbdPFtN7oKgyaqJipDQdTiJIsgdfeaRN1HxW+rg7ta7Zyfw== X-IronPort-AV: E=Sophos;i="6.02,150,1688443200"; d="scan'208";a="121464506" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Jinoh Kang Subject: [PATCH 3/7] x86/pv: Fix the determiniation of whether to inject #DB Date: Fri, 15 Sep 2023 21:36:24 +0100 Message-ID: <20230915203628.837732-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230915203628.837732-1-andrew.cooper3@citrix.com> References: <20230915203628.837732-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 We long ago fixed the emulator to not inject exceptions behind our back. Therefore, assert that that a PV event (including interrupts, because that would be buggy too) isn't pending, rather than skipping the #DB injection if one is. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu CC: Jinoh Kang v2: * Drop X86EMUL_DONE adjustment. --- xen/arch/x86/pv/emul-priv-op.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c index 142bc4818cb5..0d9f84f458ba 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -1358,14 +1358,17 @@ int pv_emulate_privileged_op(struct cpu_user_regs *regs) switch ( rc ) { case X86EMUL_OKAY: + ASSERT(!curr->arch.pv.trap_bounce.flags); + if ( ctxt.ctxt.retire.singlestep ) ctxt.bpmatch |= DR_STEP; + if ( ctxt.bpmatch ) { curr->arch.dr6 |= ctxt.bpmatch | DR_STATUS_RESERVED_ONE; - if ( !(curr->arch.pv.trap_bounce.flags & TBF_EXCEPTION) ) - pv_inject_hw_exception(X86_EXC_DB, X86_EVENT_NO_EC); + pv_inject_hw_exception(X86_EXC_DB, X86_EVENT_NO_EC); } + /* fall through */ case X86EMUL_RETRY: return EXCRET_fault_fixed;