Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp48744ybm; Tue, 26 May 2020 10:25:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3oSxtSemTpf9zm6+EDv2LEl2DT50bdaSo1Su6uiyP7vy+2o/G0GlCFff89OVwXpXV8J9B X-Received: by 2002:a17:906:4088:: with SMTP id u8mr2120202ejj.444.1590513943719; Tue, 26 May 2020 10:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590513943; cv=none; d=google.com; s=arc-20160816; b=uL+e3MVtlj8ae+U+vpDr5OaCil5HcKwVv9AXq7NbM+ayBTs3B1CUe1M9bJX/atyZq0 4NAOCkRRppD6BmlRlg2XzrV0Qaba+c5zJ3n3VXRI20TVzskhPU0dICPaTQGtI6BxeTT4 YfxSGgbe4U263dHB5gTt9x/43QIorAFLc4YyEkI/8csCV93VLu6TDv1u0zr2b+lAky60 p/KgLSC676uje3e9yeACf+TglAZYw1hfdLOL1rI32X/TA9hH3e5nHN2H7qzgnlBHz1Fm SjF71QCeTJVsn48SbFbrQu1jhvMdffrqjyEbLt5GNl7KF8/yzxbeuvxAqyG39OcRpvEw 5zSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fix62+yXIEwhQT8pT+Ezxe5NkSkqTahVbDMIy8YhWHE=; b=VRR369vEL8uTustP4QjNHnnMp9UeZP2UNUqH+qKe2j6nVwKv6363wEQF8x93pzA4rP KG0g7JJUNnhuYXXZW4hv84q8G2cb+J0RmKvOJUma4kGYRfY390hIAtTFAbHo3UWKDS0A B7zra0r8e4GoFTD43fRJx/rIGksfoBK/Qp+5J2HtanoCG9nIT74kfnhlXS/MIlitIxha m1NAnu9982PC903o20G+uVNf3KGipRcLrbZwUXymWgjo3R5q8PqCgI+hsfD7nOku9+uC mzVhN2VOq7sQ+7aTzQIWUdv0mDHXIGTTRbYfZMf+zRkYOrf2l03fKiz4oIn/arJ4a2GM mraA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P7Agg5Lr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si256517edr.478.2020.05.26.10.25.20; Tue, 26 May 2020 10:25:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P7Agg5Lr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389222AbgEZRX3 (ORCPT + 99 others); Tue, 26 May 2020 13:23:29 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:46887 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389185AbgEZRXZ (ORCPT ); Tue, 26 May 2020 13:23:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590513804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fix62+yXIEwhQT8pT+Ezxe5NkSkqTahVbDMIy8YhWHE=; b=P7Agg5LrzE/33JL5uT8XpIU/IASRV2olyu2W8T4YGaEjANO2vSi7Jmp0TKT9i58tz0diIm MIMZyAEwpIip5evN/oHQUkZCByD9SA8B7lZ3b5xtk66nhBAH0yJ78pQt8aiQITc2QrFmYT gL1KpMUY3YZQ9ttz94/0CzCajRRMR4A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-78-tOIGW1zLNTKQLvoYrlVYyQ-1; Tue, 26 May 2020 13:23:22 -0400 X-MC-Unique: tOIGW1zLNTKQLvoYrlVYyQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1316D107ACF7; Tue, 26 May 2020 17:23:21 +0000 (UTC) Received: from virtlab511.virt.lab.eng.bos.redhat.com (virtlab511.virt.lab.eng.bos.redhat.com [10.19.152.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id D59055C1D6; Tue, 26 May 2020 17:23:19 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: vkuznets@redhat.com, mlevitsk@redhat.com, Sean Christopherson , Jim Mattson Subject: [PATCH 12/28] KVM: nSVM: clean up tsc_offset update Date: Tue, 26 May 2020 13:22:52 -0400 Message-Id: <20200526172308.111575-13-pbonzini@redhat.com> In-Reply-To: <20200526172308.111575-1-pbonzini@redhat.com> References: <20200526172308.111575-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use l1_tsc_offset to compute svm->vcpu.arch.tsc_offset and svm->vmcb->control.tsc_offset, instead of relying on hsave. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 7fbd7aaa4ce0..5a9d131a153e 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -241,8 +241,6 @@ static void load_nested_vmcb_control(struct vcpu_svm *svm, svm->nested.intercept_dr = control->intercept_dr; svm->nested.intercept_exceptions = control->intercept_exceptions; svm->nested.intercept = control->intercept; - - svm->vcpu.arch.tsc_offset += control->tsc_offset; } static void nested_prepare_vmcb_save(struct vcpu_svm *svm, struct vmcb *nested_vmcb) @@ -288,7 +286,8 @@ static void nested_prepare_vmcb_control(struct vcpu_svm *svm, struct vmcb *neste else svm->vcpu.arch.hflags &= ~HF_VINTR_MASK; - svm->vmcb->control.tsc_offset = svm->vcpu.arch.tsc_offset; + svm->vmcb->control.tsc_offset = svm->vcpu.arch.tsc_offset = + svm->vcpu.arch.l1_tsc_offset + nested_vmcb->control.tsc_offset; svm->vmcb->control.int_ctl = nested_vmcb->control.int_ctl | V_INTR_MASKING_MASK; svm->vmcb->control.virt_ext = nested_vmcb->control.virt_ext; @@ -553,7 +552,9 @@ int nested_svm_vmexit(struct vcpu_svm *svm) /* Restore the original control entries */ copy_vmcb_control_area(vmcb, hsave); - svm->vcpu.arch.tsc_offset = svm->vmcb->control.tsc_offset; + svm->vmcb->control.tsc_offset = svm->vcpu.arch.tsc_offset = + svm->vcpu.arch.l1_tsc_offset; + kvm_clear_exception_queue(&svm->vcpu); kvm_clear_interrupt_queue(&svm->vcpu); -- 2.26.2