From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51616C4363D for ; Thu, 24 Sep 2020 19:43:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 009122399A for ; Thu, 24 Sep 2020 19:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726477AbgIXTnK (ORCPT ); Thu, 24 Sep 2020 15:43:10 -0400 Received: from mga18.intel.com ([134.134.136.126]:31793 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726281AbgIXTm5 (ORCPT ); Thu, 24 Sep 2020 15:42:57 -0400 IronPort-SDR: ohw5qSIGv1JOtoD33b4wdLdDQEOD2xDrYBW+dXDkoJWz7Kvc/3lVIZ/vxQdx1wUHF7tuL8JdUT xMUycXakq+nw== X-IronPort-AV: E=McAfee;i="6000,8403,9754"; a="149076396" X-IronPort-AV: E=Sophos;i="5.77,299,1596524400"; d="scan'208";a="149076396" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2020 12:42:53 -0700 IronPort-SDR: sphcFmOIPr8ZyE0rndpU52g9haCu2iElE9atdGqEklsDjD4YMe5fSZ4uDvFw+nShMxWcT6YPTo SDhoNzVh6JeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,299,1596524400"; d="scan'208";a="347953060" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.160]) by FMSMGA003.fm.intel.com with ESMTP; 24 Sep 2020 12:42:53 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 5/5] KVM: VMX: Use "illegal GPA" helper for PT/RTIT output base check Date: Thu, 24 Sep 2020 12:42:50 -0700 Message-Id: <20200924194250.19137-6-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200924194250.19137-1-sean.j.christopherson@intel.com> References: <20200924194250.19137-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use kvm_vcpu_is_illegal_gpa() to check for a legal GPA when validating a PT output base instead of open coding a clever, but difficult to read, variant. Code readability is far more important than shaving a few uops in a slow path. No functional change intended. Suggested-by: Paolo Bonzini Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 7987de212057..8f1eb5dca794 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1037,7 +1037,7 @@ static inline bool pt_can_write_msr(struct vcpu_vmx *vmx) static inline bool pt_output_base_valid(struct kvm_vcpu *vcpu, u64 base) { /* The base must be 128-byte aligned and a legal physical address. */ - return !(base & (~((1UL << cpuid_maxphyaddr(vcpu)) - 1) | 0x7f)); + return !kvm_vcpu_is_illegal_gpa(vcpu, base) && !(base & 0x7f); } static inline void pt_load_msr(struct pt_ctx *ctx, u32 addr_range) -- 2.28.0