Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp577502pxk; Thu, 24 Sep 2020 12:45:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSU+F2xi2639D86EvIw6JPIosKZp1j9Pz+CFTq3qJp+Tg4OYdvDMZL9sJxhjJHGwXxpsjT X-Received: by 2002:a05:6402:3193:: with SMTP id di19mr386902edb.211.1600976719540; Thu, 24 Sep 2020 12:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600976719; cv=none; d=google.com; s=arc-20160816; b=EuJTQZV67WaZfZX6ydtS8qbp+a8WyB8dCyK895ESk0v8sfv4S7guIRNX0fncmg8/Y1 VewVJ+f1uyKep6OXCgT26l1q8B7g7MdxJ14B6eDRLPr/kDUahuJPzlg+HNGtFu6dwUkh juGpuwhRTFemsUs3mVffLO0rTlZcqhXSu34RewL2z7Iqn2EepkkBr7+eD0CIq3647/t4 C/6oHvoYrME/kf8nJQyeijUzxNb1XfDY78J2xJmdth2qwdUhcKrD9cuLGiiLw9jQKhBp Kjskpa36Wq8LUFuA6Ks/2GvJlflhodlo0z2KUMTtnHHIySqTTkmHZTIMc4/+gdiFsLmC tiuQ== 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 :ironport-sdr:ironport-sdr; bh=E1Kw/dTypxJc32gGvxTIrWizJzjC+VbTNSr49xaiMyA=; b=VKh53GRibTlyG+LRKRFtcTOk1i3XQb43nN0FhJ73Re4oFHy34OdetYquobQ03m2Mua PH4rOUVGJS6p0qdovKKiBjE0Elxw7iW8Py/TrLRcZ/OHFPws/C9+gYH+63xkrk3y0E0m 5sfigRLkgQ5FD6KzBSvm9kofW9JcIrZp+hT1WJPiWgdJOW1SbSfodIa6XUx3O+XHbivW 19h3O6ASWFh9hVoMlz3xmCqEPOQuqmk0QERjxcHb2S/kwwAL/pYQhKIz7ZO12XblyfdJ LacX+XfxXyX721Jjz0PW7dDsQ59iTRGLbVzckUTxMEFW0jTzvOXtPPktN7XudGyQzots qaLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id gg11si332361ejb.700.2020.09.24.12.44.55; Thu, 24 Sep 2020 12:45:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726037AbgIXTnJ (ORCPT + 99 others); Thu, 24 Sep 2020 15:43:09 -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