Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp324918imn; Thu, 28 Jul 2022 01:36:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s5mlhwN2UTXE5rOwI4RLs22CCt6eN/FeZNYY3WFXq4w+4iEH9rKT35YLIMoTzUGQxRJr0H X-Received: by 2002:a17:907:2d0b:b0:72b:978a:c6df with SMTP id gs11-20020a1709072d0b00b0072b978ac6dfmr20596436ejc.618.1658997364627; Thu, 28 Jul 2022 01:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658997364; cv=none; d=google.com; s=arc-20160816; b=BvinqhXnJhYKZQku97nExXKql2fvqYuEDtSUX1oqE+1dr9RL9U8TL84xyIrrpeh5Oh aQjpEqGvLkUd++ILTqpi8BZHoH4JB+ve/TDqSkaEjetkSbfFv2lMCV0ujddcZ5mIE5Yl l85ghCNTPxJMZcRBLcoYzd1VbGuukpFcw5CUWAPsJ1hkyR5Skq6lj1/bJ0t9HdImVLrZ bTAdJMQNyzUVsDj+oN/8Y7e102vFj6K3/S2Y23J7x+EGU9YFBAnkMKb2RN2Ps8pysTFf 8Z4Itjaa+/MORHnYSzibV2gIybFuo7AMjR2hZ7njL0kqgDxJlrjqowyxFDwmWIpOtFK6 bGkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YRh6w6PIpPVie2ajG7h9/V/BKG2Na6GcXk8Rvopb15g=; b=TYJbuhBvbKuaApjSCgn9nLJjfU7ks+hyCvnID0GYDJhXRVuCyIR6/fWmliZ8ItP5u/ itLmCA8RZwbuqQXfZSGXTlu7ov/Ya36La+ZgU2OrGCyUPHmHu+HneDFSS4LU3yXMPuzL VGyJwnVyG7+VJy0DoK8jcTBtWhj7ijseebKdfz1SJ3Us7AmLmuFuBNXIqyh6DkOtjgrL ZAM92wwo34wGSWEivsFHtBA2nYq2ifZd576Hn7hQiZns0haGw4I2JSqd/kYTVVJ0U7zS xwFTSxnaKDq4UhjWc+SoQD+zJpBG0YefCcGjeH54oYa61bfTwbIssxSS4shgQGmNQVaP Qb9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e27-20020a170906081b00b0072b3a7457fesi181510ejd.846.2022.07.28.01.35.39; Thu, 28 Jul 2022 01:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235199AbiG1IZV (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.31.1