Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp338013yba; Thu, 16 May 2019 01:28:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqygcniDZbL8FyDKS2Hrr83zRYZ6ytDAs3OfKXg3dWFHsdMSpGEhx/C3EG5UyErkM+6P3i3d X-Received: by 2002:a62:4e86:: with SMTP id c128mr51901110pfb.39.1557995280310; Thu, 16 May 2019 01:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557995280; cv=none; d=google.com; s=arc-20160816; b=bL7kjoriHTVzY+wH64zkfEafSxlxvSnm5+Vks9Y0ng4yjRaLFA1L1eBSU9NqCjoBwu EI7Z9nXpVf2SfKQViTA2xhBnlL9iATz9QscFgwz5MXuWyeaeoUJwshG2YFNNa8m1OqJ+ Jig8zAbNtVV4YY54P1L3noyzlK8M4Dn4TS/xf8LlNnqKDtRrvACWD35srAYHJqnVU/lq /ha3es8eimQGgz5oD2oa7IVlh6Oxgy+G+rZRoHQI73mE6o8pfdER6Vb7f7z2/uGNstGe 5fp1OnJV18rNJDq4st2NmvJWwHn+cbU9rNl0I/JL0Q3t96aaTrOzVpySYWJz3Pt2M6Fv kkQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=0HV96XMn/UtdjlpYAgYwDHsCyjYlr/QKW5aZ/qSmj5g=; b=Vj6M4QoBEtVVUZGgj2Z9jr05/u1x5H9pNC9yhMU8YIYaX2FPXBweiwO91zIyQlS44g d+1GkgK8s8MRmAxCgn3Yv8W7jLBIlxKf04dUouCFWP4eE12kF4dpUlHqqZwG9F+udhf/ rDQ0rqNOhZzYklgxCc4uPusYS6L1Pf5SpFiPwA2az5EGYqqWMRiCwGE5A5ycwCVHdgx5 PSE9JDWTcBQ3Ez9j/CXFbh6wvK/XUjz1iBL13uLPapQ0LVunAKuOBV86pQSwDdtbaqbO hefr+KXU7b10/nO8ehmSmbdIbWWLRd0612m3nQjy3G3w4H3qTZhLMDYIehMO8NxMRzrl qz9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si4641522pfr.279.2019.05.16.01.27.45; Thu, 16 May 2019 01:28:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726717AbfEPI0h (ORCPT + 99 others); Thu, 16 May 2019 04:26:37 -0400 Received: from mga11.intel.com ([192.55.52.93]:22098 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbfEPI0g (ORCPT ); Thu, 16 May 2019 04:26:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 May 2019 01:26:36 -0700 X-ExtLoop1: 1 Received: from skl-s2.bj.intel.com ([10.240.192.102]) by orsmga005.jf.intel.com with ESMTP; 16 May 2019 01:26:34 -0700 From: Luwei Kang To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, Luwei Kang Subject: [PATCH v1 0/6] KVM: VMX: Intel PT configuration switch using XSAVES/XRSTORS on VM-Entry/Exit Date: Thu, 16 May 2019 16:25:08 +0800 Message-Id: <1557995114-21629-1-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch set is mainly used for reduce the overhead of switch Intel PT configuation contex on VM-Entry/Exit by XSAVES/XRSTORS instructions. I measured the cycles number of context witch on Manual and XSAVES/XRSTORES by rdtsc, and the data as below: Manual save(rdmsr): ~334 cycles Manual restore(wrmsr): ~1668 cycles XSAVES insturction: ~124 cycles XRSTORS instruction: ~378 cycles Manual: Switch the configuration by rdmsr and wrmsr instruction, and there have 8 registers need to be saved or restore. They are IA32_RTIT_OUTPUT_BASE, *_OUTPUT_MASK_PTRS, *_STATUS, *_CR3_MATCH, *_ADDR0_A, *_ADDR0_B, *_ADDR1_A, *_ADDR1_B. XSAVES/XRSTORS: Switch the configuration context by XSAVES/XRSTORS instructions. This patch set will allocate separate "struct fpu" structure to save host and guest PT state. Only a small portion of this structure will be used because we only save/restore PT state (not save AVX, AVX-512, MPX, PKRU and so on). This patch set also do some code clean e.g. patch 2 will reuse the fpu pt_state to save the PT configuration contex and patch 3 will dymamic allocate Intel PT configuration state. Luwei Kang (6): x86/fpu: Introduce new fpu state for Intel processor trace KVM: VMX: Reuse the pt_state structure for PT context KVM: VMX: Dymamic allocate Intel PT configuration state KVM: VMX: Allocate XSAVE area for Intel PT configuration KVM: VMX: Intel PT configration context switch using XSAVES/XRSTORS KVM: VMX: Get PT state from xsave area to variables arch/x86/include/asm/fpu/types.h | 13 ++ arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/vmx/vmx.c | 338 ++++++++++++++++++++++++++------------- arch/x86/kvm/vmx/vmx.h | 21 +-- 4 files changed, 243 insertions(+), 131 deletions(-) -- 1.8.3.1