From nobody Mon Feb 9 18:19:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1612222080; cv=none; d=zohomail.com; s=zohoarc; b=hy3vF6eZvs6596KSvxT/XWyOR1CeJbkakB+/uSPtabiGCmxLCoIyTPpbZYoPd7inKM4QGwDrB3oV9Lgi+fKFEKbgp18zrAIxzEdifL6Sog/c3riQJgzl+gfz88BWNPvMidUBnwhqkcUHrShinsKaermiflB8Ijdkk9AvtL8/E5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612222080; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2gGw3o2aMJZd504hAfObj5UWikMzdiQF5XDlG+P6WJ0=; b=EePYRoYPrpQITJqDDt4/ZHv3MHTDuDEdDylKU9xES1V677QBikxjMpyJlGbOr4dX9xfTXays4VEQhSJ6UN1j0d8wqOXcmAbkBYbibFlSnNoUFGzpj0KuIFghC5XQ/i01Y/KfBMWWNXS+1A9dnnCO13+y4/NiiQ50pEVntX8oFGE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1612222080138581.373519906156; Mon, 1 Feb 2021 15:28:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.80192.146530 (Exim 4.92) (envelope-from ) id 1l6ibg-0007az-EX; Mon, 01 Feb 2021 23:27:44 +0000 Received: by outflank-mailman (output) from mailman id 80192.146530; Mon, 01 Feb 2021 23:27:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l6ibg-0007ao-AW; Mon, 01 Feb 2021 23:27:44 +0000 Received: by outflank-mailman (input) for mailman id 80192; Mon, 01 Feb 2021 23:27:42 +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 1l6ibe-0007P6-Qz for xen-devel@lists.xenproject.org; Mon, 01 Feb 2021 23:27:42 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 38cdcfa4-521c-43b8-a188-6a21d06b37d7; Mon, 01 Feb 2021 23:27:32 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 38cdcfa4-521c-43b8-a188-6a21d06b37d7 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1612222052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FBfo6N9u3Sukj0MKNcU3Z9nO9VLLQT0Q251N7HMr1t4=; b=W+AMHjrZtM0JdgByJWxIl+Q2o2kC0Hp+Z9c35pgJCUOdxofBHtd98ugt RyZDO/x/pM4EgnPbFfZCGkc55tUQmV4eFGJoOUA6CBObgj8HKNCgP4qOR kcP4/TbGNemXwKraGvRA8t4gwVByqsLzui2w2iE3zM4UD6yoANyCv7Ovu c=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 12MhwBfguQk0bLxFSPpqPdTqs4n6Fxn3l25XKaRAqX09hFa34kLWoantVeiJPyoIOd9c4ScBOK XdoOLk0DmbE9RXIcx5/P8DrSsQjR2Z5G7N8+/5fREE/G/xf2Hs2kZMC7PP0dz0TRULbtnT9GDN UeuaOsfeX6ntwJ9t/j1Sier4gog6YGqKhufTg89OcsascmaJjD595nU4buluHAhcmM/AbDDKaG VEwpqi+7FCZgnV4tL58dn2dChMjNxvo2jrOSElEgx+2fxxPWFzJCgsl0j7HNderxoke4jPvCPH Y+4= X-SBRS: 5.1 X-MesageID: 36523028 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.79,393,1602561600"; d="scan'208";a="36523028" From: Andrew Cooper To: Xen-devel CC: Tamas K Lengyel , Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Jun Nakajima , Kevin Tian , =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= , Tamas K Lengyel Subject: [PATCH v9 09/11] xen/vmtrace: support for VM forks Date: Mon, 1 Feb 2021 23:27:01 +0000 Message-ID: <20210201232703.29275-10-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210201232703.29275-1-andrew.cooper3@citrix.com> References: <20210201232703.29275-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) From: Tamas K Lengyel Implement vmtrace_reset_pt function. Properly set IPT state for VM forks. Signed-off-by: Tamas K Lengyel Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Jun Nakajima CC: Kevin Tian CC: Micha=C5=82 Leszczy=C5=84ski CC: Tamas K Lengyel v7: * New --- tools/misc/xen-vmtrace.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 11 +++++++++++ xen/arch/x86/mm/mem_sharing.c | 3 +++ xen/include/asm-x86/hvm/hvm.h | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/misc/xen-vmtrace.c b/tools/misc/xen-vmtrace.c index cc58a0707b..7572e880c5 100644 --- a/tools/misc/xen-vmtrace.c +++ b/tools/misc/xen-vmtrace.c @@ -43,7 +43,7 @@ static uint32_t domid, vcpu; static size_t size; static char *buf; =20 -static sig_atomic_t interrupted =3D 0; +static sig_atomic_t interrupted; static void int_handler(int signum) { interrupted =3D 1; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index beb5692b8b..faba95d057 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2392,6 +2392,16 @@ static int vmtrace_output_position(struct vcpu *v, u= int64_t *pos) return v->arch.hvm.vmx.ipt_active; } =20 +static int vmtrace_reset(struct vcpu *v) +{ + if ( !v->arch.hvm.vmx.ipt_active ) + return -EINVAL; + + v->arch.msrs->rtit.output_offset =3D 0; + v->arch.msrs->rtit.status =3D 0; + return 0; +} + static struct hvm_function_table __initdata vmx_function_table =3D { .name =3D "VMX", .cpu_up_prepare =3D vmx_cpu_up_prepare, @@ -2451,6 +2461,7 @@ static struct hvm_function_table __initdata vmx_funct= ion_table =3D { .vmtrace_output_position =3D vmtrace_output_position, .vmtrace_set_option =3D vmtrace_set_option, .vmtrace_get_option =3D vmtrace_get_option, + .vmtrace_reset =3D vmtrace_reset, .tsc_scaling =3D { .max_ratio =3D VMX_TSC_MULTIPLIER_MAX, }, diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index adaeab4612..00ada05c10 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1632,6 +1632,8 @@ static int copy_vcpu_settings(struct domain *cd, cons= t struct domain *d) copy_domain_page(new_vcpu_info_mfn, vcpu_info_mfn); } =20 + hvm_vmtrace_reset(cd_vcpu); + /* * TODO: to support VMs with PV interfaces copy additional * settings here, such as PV timers. @@ -1782,6 +1784,7 @@ static int fork(struct domain *cd, struct domain *d) cd->max_pages =3D d->max_pages; *cd->arch.cpuid =3D *d->arch.cpuid; *cd->arch.msr =3D *d->arch.msr; + cd->vmtrace_size =3D d->vmtrace_size; cd->parent =3D d; } =20 diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 960ec03917..150746de66 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -219,6 +219,7 @@ struct hvm_function_table { int (*vmtrace_output_position)(struct vcpu *v, uint64_t *pos); int (*vmtrace_set_option)(struct vcpu *v, uint64_t key, uint64_t value= ); int (*vmtrace_get_option)(struct vcpu *v, uint64_t key, uint64_t *valu= e); + int (*vmtrace_reset)(struct vcpu *v); =20 /* * Parameters and callbacks for hardware-assisted TSC scaling, @@ -696,6 +697,14 @@ static inline int hvm_vmtrace_get_option( return -EOPNOTSUPP; } =20 +static inline int hvm_vmtrace_reset(struct vcpu *v) +{ + if ( hvm_funcs.vmtrace_reset ) + return hvm_funcs.vmtrace_reset(v); + + return -EOPNOTSUPP; +} + /* * This must be defined as a macro instead of an inline function, * because it uses 'struct vcpu' and 'struct domain' which have --=20 2.11.0