Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2469482imj; Mon, 18 Feb 2019 06:34:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IYlGi57xIirYH+8q9SLv7OmQn/UnSUuxGu510Go2rphZxIkxEbb3fDlN5ixxkaozRHby1VQ X-Received: by 2002:a63:d84b:: with SMTP id k11mr19253044pgj.142.1550500461364; Mon, 18 Feb 2019 06:34:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550500461; cv=none; d=google.com; s=arc-20160816; b=VccLJqJtAaglNo49p1GwrVSOfphtD54j+IKYzISpnXWqbB8V+33DoLeCwHwH9qjmWd O2L+U+KwNkvYQb1yd4Onn877ShZS1fXvYgQaOWw0A1fOeom5EoCPGkSB3qBkQJKUQOzJ weBL+HtTQFugs5bMDfXiLGev5fiQjCgrC2dfQhxit2PBS0AjmGsV7INaFE+cwbWfZBak KphGwxOlCJclC6O8DWp/3+stjFJuxSa+Day5ANNPYlTByO4OOXujZh96sPZWjKEQHr3F OFXc7BX6cUvRdRQUXFU8yLWFPqxzjH7E8q4LAYiHf8ZjQXVVsZO7igeHthpwJZn/Avv6 lY9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LGO5KC1z+Zv5bABxN6Sp96S22/qTsjljoqjhsgjcruk=; b=o/6p36blKtD4FSCeayolLPJLb2qjn3hF/NW9cBDn8A2npbk6Kztriyj4ra29/AtkRB 8jLeDOk2LVwMsucLyPTjvn7X6Cb+Ym5ITFJRndt/8Lzwtq+Y2INEY7z6pI3Z9iANpM1G nCJ41WiAf3ccK1ayTi1mvw8OZN1AXm1wKaRQ/GYujswUrQbfV9kFQ+WbGAGMpZPBRLGm ODDz7ovW+KgdwUVLFMyba9r00ZR4Miejy6ck/wyRqJPYVwm39V335qQ2/ro+7+nEK0DQ 6DhVr7u4Ujv9jdTOcLlAOh1LVdLv2tiMzW7Yqr1yjlWFnG/oDQh95gVsOYChjo5iqsNY 78UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KGQMULmS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p4si7802844pli.159.2019.02.18.06.34.05; Mon, 18 Feb 2019 06:34:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KGQMULmS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388036AbfBRN5I (ORCPT + 99 others); Mon, 18 Feb 2019 08:57:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:37436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387984AbfBRN5E (ORCPT ); Mon, 18 Feb 2019 08:57:04 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BBE34217D9; Mon, 18 Feb 2019 13:57:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498223; bh=IzIpPy8RkSNryIQH95SsymwWH9D9WVUdW5iaVpBxxYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KGQMULmSi7CFe9WrVON6KVkiqO4LFKwoBJasBmXp6UKKIgT7ovGEhQcsi/rwirarX PLPT0gZlRug+7N5Z313nTlWbeBC4S+fcVHe8r+PjtWhzzDSxA6YrlHj3f8ZaoZu3Wu F5jvn7ROZ+d+1Qvki8KXAzvi+//+ORXqVWrC2QWo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaoyao Li , Paolo Bonzini Subject: [PATCH 4.14 46/62] kvm: vmx: Fix entry number check for add_atomic_switch_msr() Date: Mon, 18 Feb 2019 14:43:52 +0100 Message-Id: <20190218133509.786715997@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133505.801423074@linuxfoundation.org> References: <20190218133505.801423074@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiaoyao Li commit 98ae70cc476e833332a2c6bb72f941a25f0de226 upstream. Commit ca83b4a7f2d068da79a0 ("x86/KVM/VMX: Add find_msr() helper function") introduces the helper function find_msr(), which returns -ENOENT when not find the msr in vmx->msr_autoload.guest/host. Correct checking contion of no more available entry in vmx->msr_autoload. Fixes: ca83b4a7f2d0 ("x86/KVM/VMX: Add find_msr() helper function") Cc: stable@vger.kernel.org Signed-off-by: Xiaoyao Li Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2230,7 +2230,8 @@ static void add_atomic_switch_msr(struct if (!entry_only) j = find_msr(&m->host, msr); - if (i == NR_AUTOLOAD_MSRS || j == NR_AUTOLOAD_MSRS) { + if ((i < 0 && m->guest.nr == NR_AUTOLOAD_MSRS) || + (j < 0 && m->host.nr == NR_AUTOLOAD_MSRS)) { printk_once(KERN_WARNING "Not enough msr switch entries. " "Can't add msr %x\n", msr); return;