From patchwork Thu Nov 8 09:51:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 10673865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 461621057 for ; Thu, 8 Nov 2018 09:52:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3603B2CB2F for ; Thu, 8 Nov 2018 09:52:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A4FE2CFAA; Thu, 8 Nov 2018 09:52:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C97702CB2F for ; Thu, 8 Nov 2018 09:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727083AbeKHT05 (ORCPT ); Thu, 8 Nov 2018 14:26:57 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:60328 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726517AbeKHT05 (ORCPT ); Thu, 8 Nov 2018 14:26:57 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA89kdXe018055; Thu, 8 Nov 2018 09:52:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=Q6iEnVy9RaLW8o5SZQ5BLUzQhWe9zWNQcEQCtkmOius=; b=jy+HTbgKfApNl/BeBWRzXE+JejcNxvf2+i0Ms02hUR6Kzp38ta8P3N8DSL7AeZakLknn 7OlROjxk+p5c+3a2o3mBpsC5EJ5Gv/awqKl6mLWoQgCS1TO7VoBjKAy0GyHSax+jS1H3 /u4yhrWuBUmdNJqCVO/MIVSeaTOOo5tDeg18+h4rDify0s52SQ5ARAflAH9X6lGFarQo fkbb508p36akGJSlQEVok2HkEsJlSzLo9ZcT7BeSVDJkj0aAMqH+o4fxnc+KlVmBJFCF 4H0UR8JZYqGCVv/6qVYmsNqxxNzIAZM8sOShmfsDfwSqYb6mrRWfdVkx0zDHYK15uEN4 Ag== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2nh33u8f50-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 08 Nov 2018 09:52:13 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wA89qDei023296 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Nov 2018 09:52:13 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wA89qDIB008601; Thu, 8 Nov 2018 09:52:13 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Nov 2018 01:51:58 -0800 From: Liran Alon To: pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org Cc: idan.brown@oracle.com, Liran Alon Subject: [PATCH v2 2/2] KVM: x86: Trace changes to active TSC offset regardless if vCPU in guest-mode Date: Thu, 8 Nov 2018 11:51:30 +0200 Message-Id: <20181108095130.64904-2-liran.alon@oracle.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181108095130.64904-1-liran.alon@oracle.com> References: <20181108095130.64904-1-liran.alon@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9070 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=794 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811080085 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From some unknown reasons, kvm_x86_ops->write_tsc_offset() skipped trace of change to active TSC offset in case vCPU is in guest-mode. This patch changes write_tsc_offset() behavior to trace any change to active TSC offset to aid debugging. Reviewed-by: Mihai Carabas Signed-off-by: Liran Alon --- arch/x86/kvm/svm.c | 8 ++++---- arch/x86/kvm/vmx.c | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 842d4bb053d1..bcf1433f0d85 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1456,11 +1456,11 @@ static u64 svm_write_tsc_offset(struct kvm_vcpu *vcpu, u64 l1_offset) g_tsc_offset = svm->vmcb->control.tsc_offset - svm->nested.hsave->control.tsc_offset; svm->nested.hsave->control.tsc_offset = l1_offset; - } else - trace_kvm_write_tsc_offset(vcpu->vcpu_id, - svm->vmcb->control.tsc_offset, - l1_offset); + } + trace_kvm_write_tsc_offset(vcpu->vcpu_id, + svm->vmcb->control.tsc_offset, + l1_offset + g_tsc_offset); svm->vmcb->control.tsc_offset = l1_offset + g_tsc_offset; mark_dirty(svm->vmcb, VMCB_INTERCEPTS); diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 20d90ebd6cc8..36456314bc0f 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3465,11 +3465,10 @@ static u64 vmx_write_tsc_offset(struct kvm_vcpu *vcpu, u64 l1_offset) struct vmcs12 *vmcs12 = get_vmcs12(vcpu); if (nested_cpu_has(vmcs12, CPU_BASED_USE_TSC_OFFSETING)) active_offset += vmcs12->tsc_offset; - } else { - trace_kvm_write_tsc_offset(vcpu->vcpu_id, - vmcs_read64(TSC_OFFSET), l1_offset); } + trace_kvm_write_tsc_offset(vcpu->vcpu_id, + vmcs_read64(TSC_OFFSET), active_offset); vmcs_write64(TSC_OFFSET, active_offset); return active_offset; }