From patchwork Tue Sep 12 23:21:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13382302 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 3ABDAEE57DF for ; Tue, 12 Sep 2023 23:21:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.600818.936618 (Exim 4.92) (envelope-from ) id 1qgChI-00009B-Ab; Tue, 12 Sep 2023 23:21:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 600818.936618; Tue, 12 Sep 2023 23:21:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qgChI-000094-7X; Tue, 12 Sep 2023 23:21:32 +0000 Received: by outflank-mailman (input) for mailman id 600818; Tue, 12 Sep 2023 23:21:30 +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 1qgChG-0008LM-Rf for xen-devel@lists.xenproject.org; Tue, 12 Sep 2023 23:21:30 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 195576dd-51c3-11ee-8786-cb3800f73035; Wed, 13 Sep 2023 01:21:29 +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: 195576dd-51c3-11ee-8786-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1694560889; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=TPtQd6hiTg1m7iqDzeBPWUoVM8rZQDcw4p+B8we5LIA=; b=MPHVI741XHz6h2i8gBrf/EhRl9qqCXWlfRcuskSMmf4HICyqJ1YdMAC6 TJnuiYEKfxnhBdkTGBtv9qAUiysWfUBmRg/1WFlKERqJvQnF1VMOBeFAG bOWeTfxLvgZL2iNfmAiVseKRaf1TzStPwgGW/P7aWEFz+P0UnzBkKsfrd k=; X-CSE-ConnectionGUID: nO66D9+OQ+yXSxiZ0nj3dw== X-CSE-MsgGUID: 9ZiftbiVQ4e8oDFfvcXOCg== Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 125168440 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:CuUizasrubwxiTh+yJaol1NFAOfnVH5eMUV32f8akzHdYApBsoF/q tZmKW7Vaa3eamShLdwgaIm3/UgP78Ldxt9gQFduqn00FyxA+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVaicfHg3HFc4IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4rKq4lv0gnRkPaoQ5A6HzSFIZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwLhdTMDzSxMWPg6OLcflttJwlLpLnI9ZK0p1g5Wmx4fcORJnCR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AV: E=Sophos;i="6.02,141,1688443200"; d="scan'208";a="125168440" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Jinoh Kang Subject: [PATCH 0/5] x86/pv: #DB vs %dr6 fixes, part 2 Date: Wed, 13 Sep 2023 00:21:08 +0100 Message-ID: <20230912232113.402347-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Slightly RFC. This is the next chunk of debug fixes from the bug that Jinoh reported. I've decided to tackle PV guests alone to simplify the problem (No introspection, get some of the core changes in place). Patch 5 is still a bit chunky to follow, but I can't see any way to simplify it without transiently breaking something. Patchs 1 and 3 are entirely new, relative to previous postings of this work. Others are rebased/shuffled. There are still bugs/misfeatures: 1) Data breakpoints during emulation (copy to/from guest) are accounted against Xen and not given back to the guest. 2) Instruction breakpoints aren't calculated for FEP; CPUID. This may not matter, but like everything in PV, it's undocumented and unclear if it's intended behaviour or not. that can be left to some other future to fix. Andrew Cooper (5): x86/pv: Fix the determiniation of whether to inject #DB x86: Introduce x86_merge_dr6() x86/emul: Add a pending_dbg field to x86_emulate_ctxt.retire x86/pv: Drop priv_op_ctxt.bpmatch and use pending_dbg instead x86/pv: Rewrite %dr6 handling xen/arch/x86/debug.c | 20 +++++++++++++++++ xen/arch/x86/include/asm/debugreg.h | 7 ++++++ xen/arch/x86/include/asm/domain.h | 12 ++++++++++ xen/arch/x86/include/asm/x86-defns.h | 7 ++++++ xen/arch/x86/pv/emul-priv-op.c | 31 +++++++++++++------------- xen/arch/x86/pv/emulate.c | 6 ++--- xen/arch/x86/pv/ro-page-fault.c | 4 ++-- xen/arch/x86/pv/traps.c | 17 ++++++++++---- xen/arch/x86/traps.c | 12 +++++----- xen/arch/x86/x86_emulate/x86_emulate.c | 6 ++++- xen/arch/x86/x86_emulate/x86_emulate.h | 22 ++++++++++++++---- 11 files changed, 109 insertions(+), 35 deletions(-)