Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2826486pxv; Mon, 12 Jul 2021 02:54:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy88kNg86mZn+I936igiX0UbaNPA3MAOj5qLh5yPZX8jBV3glechdkVDiLKQ9Wu7EqfRpZ8 X-Received: by 2002:a92:d344:: with SMTP id a4mr8199866ilh.230.1626083690199; Mon, 12 Jul 2021 02:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083690; cv=none; d=google.com; s=arc-20160816; b=Qnf191uZ93toGAisjvRaOHjfTpaOIoMcvkyMpbVjcfU9+BzNZut4/RVULyiYhwLhp7 b+TbM9MBhxBXNN8N8bj+LBygIvukAAfwvHPQTjvEFVtf99nFRPbAmr5+G3f5G2fd3PKP SgFbHMYVze2YPpoBw3NR0t/TVUhZZix0pfq37/powUov7jjDQduoMQVln+Rn5xYqcs5h bzKF9WaIgm2HGe/3n6TUPcyhEnxiQbAvXrteamnA9SCz1vIiNxNLlzS+oI7YB9KP4vJM EtfZdFiJ3ItfoNgEli+SvdfFOPHX+oL2YNnqvgB+fwWYm/26WbCzVC7qQ4zMyvH/XpA2 UfHA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GIouFdUWk4JATW0IDbQFxHZxBnodikqtTUQkBIBZEsk=; b=pq5CaFjqSiW88x6iQv3uyerpZx+k2MkcgRDnLLmASdsRubMLrrqNQ3iFLhMuxLBuSY Hxs0/D71adbzIxUchgG1hqCjmbb6vCB+c4wO54nqLaX8UKfuJ0PuUNtCighRFv8zvgsQ JM+Rk/nwgrM3F0LpNRdf2Iim1ZzzYy/JfL4Pj92/sil8RsU0GgW+p8Xqj7C26im+IrCJ zCrDXtNWUHd8CFZI83f6anZZ424Ax/R5VpVyhw9ml/nnEaMk0ZB8B5d+DuC7MbwAsQTF ikmESv01xU3ky342q95SNr3/SZ0JMojjSjdQirlkjcLtaSw3Kyzjh5Zi0lkVqFszPor7 Cb4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="DugiXA/r"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d18si17381259ilf.137.2021.07.12.02.54.38; Mon, 12 Jul 2021 02:54:50 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="DugiXA/r"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240158AbhGLGzy (ORCPT + 99 others); Mon, 12 Jul 2021 02:55:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:34338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235787AbhGLGkl (ORCPT ); Mon, 12 Jul 2021 02:40:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DB9B0610CC; Mon, 12 Jul 2021 06:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071867; bh=DM5O0Rl8lYyuLNHnD7fnCTHHQIbFTFBHfhjq0GjpWOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DugiXA/r8yeqDW6nnufp+aRu6U3Ph3vc3ZfzhCGA8VO4LMZ57bAAhNhXQA7uogbAW Jt7J4plmOSeTjzArc5ZridmHCSyGNfHrU6vYqv20vjfCiCszRVPYJjFJdq/r5t4yle 6xbOr/kX7r8K8oHUTpyW0R84uSJakl3yfqMihzpQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.10 255/593] KVM: nVMX: Ensure 64-bit shift when checking VMFUNC bitmap Date: Mon, 12 Jul 2021 08:06:55 +0200 Message-Id: <20210712060911.090597712@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson [ Upstream commit 0e75225dfa4c5d5d51291f54a3d2d5895bad38da ] Use BIT_ULL() instead of an open-coded shift to check whether or not a function is enabled in L1's VMFUNC bitmap. This is a benign bug as KVM supports only bit 0, and will fail VM-Enter if any other bits are set, i.e. bits 63:32 are guaranteed to be zero. Note, "function" is bounded by hardware as VMFUNC will #UD before taking a VM-Exit if the function is greater than 63. Before: if ((vmcs12->vm_function_control & (1 << function)) == 0) 0x000000000001a916 <+118>: mov $0x1,%eax 0x000000000001a91b <+123>: shl %cl,%eax 0x000000000001a91d <+125>: cltq 0x000000000001a91f <+127>: and 0x128(%rbx),%rax After: if (!(vmcs12->vm_function_control & BIT_ULL(function & 63))) 0x000000000001a955 <+117>: mov 0x128(%rbx),%rdx 0x000000000001a95c <+124>: bt %rax,%rdx Fixes: 27c42a1bb867 ("KVM: nVMX: Enable VMFUNC for the L1 hypervisor") Signed-off-by: Sean Christopherson Message-Id: <20210609234235.1244004-3-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx/nested.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 4cd998bb1f0a..8f1319b7d3bd 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -5536,7 +5536,7 @@ static int handle_vmfunc(struct kvm_vcpu *vcpu) } vmcs12 = get_vmcs12(vcpu); - if ((vmcs12->vm_function_control & (1 << function)) == 0) + if (!(vmcs12->vm_function_control & BIT_ULL(function))) goto fail; switch (function) { -- 2.30.2