From patchwork Mon Oct 14 10:51:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 13834746 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AB0DD1A443 for ; Mon, 14 Oct 2024 11:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=twrm68OiK67WHyagewVh5Zt+7fq3tI4qgYe+7dBabpM=; b=ohWYa8TN6ViQZYzGwaUc/qRz7y dMBqC+PGhG2LiqIda2yD/F7TAZNEKzJV/spsJ98YK9Qn1xdFnHLGD8bbx+X1pK/dy9uiQ62orJ/EL Z7u+feNPLPCGoPhBzSChjwsKhCs5OsYPyykq4GzoNX8h8r3S/Ng+EpjNrMXrDHGFuZlKbaC0YFhLr Zhe+Lz8Cca5pRXT/fNu7BG2JhSUz7dd7/VghYs9Cyl0T/GkB2vN0JN5OWTmDnShNi1otVYC/OCsFf 8XbuxY71HG/PH7mGUgLCbqLwfr4vhAyCNS28ub9kQRi6lYYBRLgn8R+bPW6bvnfI6EPJF4KWCm8rB eHqI7Njg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Iqi-00000004oye-2TtL; Mon, 14 Oct 2024 11:02:52 +0000 Received: from mgamail.intel.com ([198.175.65.13]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0IgN-00000004l0S-1U99 for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 10:52:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728903131; x=1760439131; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NF3SWiWc6dI2FV3WgDiuj4mVl+ymLqKeoOTcA5Qp884=; b=SRQ6Rt8kApOjnVHCg4cnxEIZHKBAeAqDSGRBL2kV6uHsEh4cS+IsdBN5 pxcNqd0sFaGawXmYNiPbMo9EiLPcmrbSF2u6G3ZGZtizusQGk6Id1Ucwz R7aT1+w/RpXbyypqBLqanaC9D0Kf/ud8GMDZjnmFH1tPBUVsgz1MSt3Dr KiEYh7bkbfQqV48VSaBq5UgI6NP4C+WGDy1994wzMPabcL84pEdmdgfoo MYuBEeByRNPe1tEeJQMorHpIKdyjP+4NlGW2Iy5+R7gdPyOKqZ1MX6R+t 1tFUmsFEhYMlwDDn4tBBJeGAe/u1QFMnyNXuoWbbbwRwo8xTV7VeWpRXy A==; X-CSE-ConnectionGUID: Z2jSHVTESL2pY44M1mfu+A== X-CSE-MsgGUID: ckYC53BwS06E6NN8Ll8tEQ== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="39366046" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="39366046" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2024 03:52:09 -0700 X-CSE-ConnectionGUID: KUnehGpBTBmPV9AdOAViGA== X-CSE-MsgGUID: SPh3VvcQST6bPQMQBOqyxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,202,1725346800"; d="scan'208";a="77727380" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.245.115.59]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2024 03:51:59 -0700 From: Adrian Hunter To: Peter Zijlstra , Sean Christopherson , Paolo Bonzini Cc: Ingo Molnar , Mark Rutland , Alexander Shishkin , Heiko Carstens , Thomas Richter , Hendrik Brueckner , Suzuki K Poulose , Mike Leach , James Clark , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Yicong Yang , Jonathan Cameron , Will Deacon , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Ian Rogers , Andi Kleen , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, H Peter Anvin , Kan Liang , Zhenyu Wang , mizhang@google.com, kvm@vger.kernel.org, Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH V13 02/14] KVM: x86: Fix Intel PT IA32_RTIT_CTL MSR validation Date: Mon, 14 Oct 2024 13:51:12 +0300 Message-ID: <20241014105124.24473-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014105124.24473-1-adrian.hunter@intel.com> References: <20241014105124.24473-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_035211_491559_50430B0C X-CRM114-Status: GOOD ( 12.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Fix KVM IA32_RTIT_CTL MSR validation logic so that if RTIT_CTL_TRACEEN bit is cleared, then other bits are allowed to change also. For example, writing 0 to IA32_RTIT_CTL in order to stop tracing, is valid. Fixes: bf8c55d8dc09 ("KVM: x86: Implement Intel PT MSRs read/write emulation") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter --- arch/x86/kvm/vmx/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 1a4438358c5e..eaf4965ac6df 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1635,7 +1635,8 @@ static int vmx_rtit_ctl_check(struct kvm_vcpu *vcpu, u64 data) * result in a #GP unless the same write also clears TraceEn. */ if ((vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) && - ((vmx->pt_desc.guest.ctl ^ data) & ~RTIT_CTL_TRACEEN)) + (data & RTIT_CTL_TRACEEN) && + data != vmx->pt_desc.guest.ctl) return 1; /*