From patchwork Thu Jul 28 08:25:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Wenlong X-Patchwork-Id: 12931058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FAF4C04A68 for ; Thu, 28 Jul 2022 08:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235195AbiG1IZV (ORCPT ); Thu, 28 Jul 2022 04:25:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234026AbiG1IZQ (ORCPT ); Thu, 28 Jul 2022 04:25:16 -0400 Received: from out0-157.mail.aliyun.com (out0-157.mail.aliyun.com [140.205.0.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F5A9E0E2; Thu, 28 Jul 2022 01:25:11 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R531e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047188;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---.OfjlJW9_1658996707; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.OfjlJW9_1658996707) by smtp.aliyun-inc.com; Thu, 28 Jul 2022 16:25:08 +0800 From: "Hou Wenlong" To: kvm@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] KVM: x86: Add missing trace points for RDMSR/WRMSR in emulator path Date: Thu, 28 Jul 2022 16:25:05 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Since the RDMSR/WRMSR emulation uses a sepearte emualtor interface, the trace points for RDMSR/WRMSR can be added in emulator path like normal path. Signed-off-by: Hou Wenlong --- arch/x86/kvm/x86.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8df89b9c212f..6e45b20ce9a4 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7908,12 +7908,16 @@ static int emulator_get_msr_with_filter(struct x86_emulate_ctxt *ctxt, int r; r = kvm_get_msr_with_filter(vcpu, msr_index, pdata); - if (r) { + if (!r) { + trace_kvm_msr_read(msr_index, *pdata); + } else { if (kvm_msr_user_space(vcpu, msr_index, KVM_EXIT_X86_RDMSR, 0, - complete_emulated_rdmsr, r)) + complete_emulated_rdmsr, r)) { r = X86EMUL_IO_NEEDED; - else + } else { + trace_kvm_msr_read_ex(msr_index); r = X86EMUL_UNHANDLEABLE; + } } return r; @@ -7926,12 +7930,16 @@ static int emulator_set_msr_with_filter(struct x86_emulate_ctxt *ctxt, int r; r = kvm_set_msr_with_filter(vcpu, msr_index, data); - if (r > 0) { + if (!r) { + trace_kvm_msr_write(msr_index, data); + } else if (r > 0) { if (kvm_msr_user_space(vcpu, msr_index, KVM_EXIT_X86_WRMSR, data, - complete_emulated_msr_access, r)) + complete_emulated_msr_access, r)) { r = X86EMUL_IO_NEEDED; - else + } else { + trace_kvm_msr_write_ex(msr_index, data); r = X86EMUL_UNHANDLEABLE; + } } return r;