From patchwork Mon Sep 20 17:25:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 12506041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDDE2C433EF for ; Mon, 20 Sep 2021 17:35:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7912E61B08 for ; Mon, 20 Sep 2021 17:35:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7912E61B08 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.191095.341029 (Exim 4.92) (envelope-from ) id 1mSNC2-0003CF-R7; Mon, 20 Sep 2021 17:35:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 191095.341029; Mon, 20 Sep 2021 17:35:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSNC2-0003C8-ME; Mon, 20 Sep 2021 17:35:02 +0000 Received: by outflank-mailman (input) for mailman id 191095; Mon, 20 Sep 2021 17:35:01 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSNC1-0002pz-NW for xen-devel@lists.xenproject.org; Mon, 20 Sep 2021 17:35:01 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 119f6c43-1a39-11ec-b87a-12813bfff9fa; Mon, 20 Sep 2021 17:34:56 +0000 (UTC) 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: 119f6c43-1a39-11ec-b87a-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1632159296; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GcABwI8oWHgu530a+/KgqxWauKwNAPSdO5EboEi94Ao=; b=Yg74MBquc/o5k5Q+yVrZvcVvjRK6IaWTq3GXWJg/cxo700e/cQfaB535 qRKIzxVl1FmHmj4j7l+zh5Xz4mEubpEHGRaVggUNvsn53PBBSl4vor6yq unpP3XxHiS5qmtJXwUhJCvatk5daTcQ4bJkRxGjhxcjhiO/JNjG5v3ljb c=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: P7famdpIYSd9Iat7FzhqXhX4HUaZbz0EeCQRaQ6rqyFmwr5Za3YaAPyV85GzKrtJQ9tu5bJl42 RWVeXfrsmVfZfnTu7+4KmVQ2weBwttctvKGxwvm8JsPlsch+c4pgYAi4Kfj46ORWsLxZT2SWXG 0XP/YPlEZ+z0Sh/xibisxBH9+J9OS2VSH93KzVr/acBK4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CJmRtR FBex6CjABkmVPlhbhBhpdnh+5nyvZ643MD02wYzT/HNCRz0oyPLkX9sDMFWex4yb5dslc7BS 07PowJBjKK/z1PzNvQfXm5FMOxzlfKIPY28Dpj8N4MSCrAsJF7v1Hw/Pia4gjGy+HXAZIliY P93h+73Vi1EYUmmpRLrL9ogPUgDnHFmmTyLGsClkHxKE9O2PRaodFvMC3PWBshR0U9OiFS9H w93O5TYxhNBfvf5ZyWLo4cfIUpTdSowBIzsqtwRfemGe1I0FGYkAv7X4LUgZ406wPgFyraWp imwCh1C1V7ypXzbMgHWOHptX6ziAMRkpnUhMC1yYVvxgyo/YZyi5bs0focseeV17/RqyPN5F qFXe8iJDvlVZC7A/jARMcv0oIB4LUz5jgOSJSu1JjM4esc4FQDO/9bleCrp9TUPUXXr5Zdv/ eX421qCE5QZRglkAMLHU96Vzgu87SoHheZ/f0rUOd0PKk/ix5dndn7qhfgtLsBSdRianmmG1 xybCAszrPXWp9Nn68HAgK2Jotv7E+Z6GUYGTWDX4azvaHvf92unh4RBTPyJbXbWU2atoPeuY uBczvfdNvwbnQkV79ogQugzla9utcHyo7J6zxh/GCSZZlumPbpsP32a0JQdraZK3LJY5VO7V 0/nFgO24llV1BcJyGIsGTc= IronPort-HdrOrdr: A9a23:c5rIWqCFmITTuWvlHemU55DYdb4zR+YMi2TC1yhKJyC9Ffbo7v xG/c5rsyMc5wxwZJhNo7y90ey7MBbhHP1OkO4s1NWZLWrbUQKTRekIh+bfKn/baknDH4ZmpN 9dmsNFaeEYY2IUsS+D2njbL+od X-IronPort-AV: E=Sophos;i="5.85,309,1624334400"; d="scan'208";a="52741880" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 12/12] x86/trace: Clean up trace handling Date: Mon, 20 Sep 2021 18:25:29 +0100 Message-ID: <20210920172529.24932-13-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210920172529.24932-1-andrew.cooper3@citrix.com> References: <20210920172529.24932-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Use more appropriate types. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu v2: * New --- xen/arch/x86/irq.c | 4 +- xen/arch/x86/mm/p2m-pt.c | 6 +- xen/arch/x86/mm/shadow/multi.c | 2 +- xen/arch/x86/pv/trace.c | 159 +++++++++++++++++++---------------------- 4 files changed, 78 insertions(+), 93 deletions(-) diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index a1693f92dd92..67cbf6b979dc 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -130,8 +130,8 @@ static void _trace_irq_mask(uint32_t event, int irq, int vector, const cpumask_t *mask) { struct { - unsigned int irq:16, vec:16; - unsigned int mask[6]; + uint16_t irq, vec; + uint32_t mask[6]; } d = { .irq = irq, .vec = vector, diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 5a0c0f5aceff..09c99d78aa40 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -609,9 +609,9 @@ p2m_pt_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn, if ( tb_init_done ) { struct { - u64 gfn, mfn; - int p2mt; - int d:16,order:16; + uint64_t gfn, mfn; + uint32_t p2mt; + uint16_t d, order; } t; t.gfn = gfn; diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 8bb028c2e2fa..15265fc81dca 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -2118,7 +2118,7 @@ static inline void trace_shadow_emulate(guest_l1e_t gl1e, unsigned long va) so put it first for alignment sake. */ guest_l1e_t gl1e, write_val; guest_va_t va; - unsigned flags:29, emulation_count:3; + uint32_t flags:29, emulation_count:3; } d; u32 event; diff --git a/xen/arch/x86/pv/trace.c b/xen/arch/x86/pv/trace.c index 550c22765bae..a952fbc1eb0f 100644 --- a/xen/arch/x86/pv/trace.c +++ b/xen/arch/x86/pv/trace.c @@ -7,38 +7,35 @@ void __trace_pv_trap(int trapnr, unsigned long eip, { if ( is_pv_32bit_vcpu(current) ) { - struct __packed { - unsigned eip:32, - trapnr:15, - use_error_code:1, - error_code:16; - } d; - - d.eip = eip; - d.trapnr = trapnr; - d.error_code = error_code; - d.use_error_code=!!use_error_code; + struct { + uint32_t eip; + uint16_t trapnr:15; + bool use_error_code:1; + uint16_t error_code; + } d = { + .eip = eip, + .trapnr = trapnr, + .use_error_code = use_error_code, + .error_code = error_code, + }; __trace_var(TRC_PV_TRAP, 1, sizeof(d), &d); } else { struct __packed { - unsigned long eip; - unsigned trapnr:15, - use_error_code:1, - error_code:16; - } d; - unsigned event; - - d.eip = eip; - d.trapnr = trapnr; - d.error_code = error_code; - d.use_error_code=!!use_error_code; - - event = TRC_PV_TRAP; - event |= TRC_64_FLAG; - __trace_var(event, 1, sizeof(d), &d); + uint64_t rip; + uint16_t trapnr:15; + bool use_error_code:1; + uint16_t error_code; + } d = { + .rip = eip, + .trapnr = trapnr, + .use_error_code = use_error_code, + .error_code = error_code, + }; + + __trace_var(TRC_PV_TRAP | TRC_64_FLAG, 1, sizeof(d), &d); } } @@ -48,30 +45,28 @@ void __trace_pv_page_fault(unsigned long addr, unsigned error_code) if ( is_pv_32bit_vcpu(current) ) { - struct __packed { - u32 eip, addr, error_code; - } d; - - d.eip = eip; - d.addr = addr; - d.error_code = error_code; + struct { + uint32_t eip, addr, error_code; + } d = { + .eip = eip, + .addr = addr, + .error_code = error_code, + }; __trace_var(TRC_PV_PAGE_FAULT, 1, sizeof(d), &d); } else { struct __packed { - unsigned long eip, addr; - u32 error_code; - } d; - unsigned event; - - d.eip = eip; - d.addr = addr; - d.error_code = error_code; - event = TRC_PV_PAGE_FAULT; - event |= TRC_64_FLAG; - __trace_var(event, 1, sizeof(d), &d); + uint64_t eip, addr; + uint32_t error_code; + } d = { + .eip = eip, + .addr = addr, + .error_code = error_code, + }; + + __trace_var(TRC_PV_PAGE_FAULT | TRC_64_FLAG, 1, sizeof(d), &d); } } @@ -83,10 +78,7 @@ void __trace_trap_one_addr(unsigned event, unsigned long va) __trace_var(event, 1, sizeof(d), &d); } else - { - event |= TRC_64_FLAG; - __trace_var(event, 1, sizeof(va), &va); - } + __trace_var(event | TRC_64_FLAG, 1, sizeof(va), &va); } void __trace_trap_two_addr(unsigned event, unsigned long va1, @@ -94,22 +86,25 @@ void __trace_trap_two_addr(unsigned event, unsigned long va1, { if ( is_pv_32bit_vcpu(current) ) { - struct __packed { - u32 va1, va2; - } d; - d.va1=va1; - d.va2=va2; + struct { + uint32_t va1, va2; + } d = { + .va1 = va1, + .va2 = va2, + }; + __trace_var(event, 1, sizeof(d), &d); } else { - struct __packed { - unsigned long va1, va2; - } d; - d.va1=va1; - d.va2=va2; - event |= TRC_64_FLAG; - __trace_var(event, 1, sizeof(d), &d); + struct { + uint64_t va1, va2; + } d = { + .va1 = va1, + .va2 = va2, + }; + + __trace_var(event | TRC_64_FLAG, 1, sizeof(d), &d); } } @@ -117,40 +112,30 @@ void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte) { unsigned long eip = guest_cpu_user_regs()->rip; - /* We have a couple of different modes to worry about: - * - 32-on-32: 32-bit pte, 32-bit virtual addresses - * - pae-on-pae, pae-on-64: 64-bit pte, 32-bit virtual addresses - * - 64-on-64: 64-bit pte, 64-bit virtual addresses - * pae-on-64 is the only one that requires extra code; in all other - * cases, "unsigned long" is the size of a guest virtual address. - */ - if ( is_pv_32bit_vcpu(current) ) { - struct __packed { - l1_pgentry_t pte; - u32 addr, eip; - } d; - d.addr = addr; - d.eip = eip; - d.pte = npte; + struct { + uint64_t pte; + uint32_t addr, eip; + } d = { + .pte = l1e_get_intpte(npte), + .addr = addr, + .eip = eip, + }; __trace_var(TRC_PV_PTWR_EMULATION_PAE, 1, sizeof(d), &d); } else { struct { - l1_pgentry_t pte; - unsigned long addr, eip; - } d; - unsigned event; - - d.addr = addr; - d.eip = eip; - d.pte = npte; - - event = TRC_PV_PTWR_EMULATION; - event |= TRC_64_FLAG; - __trace_var(event, 1/*tsc*/, sizeof(d), &d); + uint64_t pte; + uint64_t addr, rip; + } d = { + .pte = l1e_get_intpte(npte), + .addr = addr, + .rip = eip, + }; + + __trace_var(TRC_PV_PTWR_EMULATION | TRC_64_FLAG, 1, sizeof(d), &d); } }