Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1203473imj; Thu, 14 Feb 2019 02:57:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IbDz2eBTQ8qomrEJUd6nKEzUfBZgOxwfMIeru94MoTj959g8Bq39xrtOcUTSZKvfIe+ktT1 X-Received: by 2002:a17:902:d83:: with SMTP id 3mr3409942plv.43.1550141837261; Thu, 14 Feb 2019 02:57:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550141837; cv=none; d=google.com; s=arc-20160816; b=ljEyKfl9tgAXRXF13pfajVUwOnzh2NEcACaiyeQaX1zraR7EZvl+Hho8Ed/sa2mjHL p+i51gE6r2B4/UROzXXEsKolVKGTwSjlsA0tFI8ZrsTRHyNt5pL1HG3sZh84a7u6nMCQ OFjCHyciGigSIqnmyQVgN5pf+w+XqRudg3/ptu8mNwGRmxQzypc+bKts26gO0vSEj2ID z9l2D9zATuJhk5Y4/h+lbu27dHBVy7P+6qRYPWd9GXnGAQzn6Ph03YVRNmdnqnvBdLfT VX/a3CQX+ZXs5LuwqhQPm7K8IwUksd0ACu616R0ExY8n10PP0weLlcjXVHWbC0rC7Zse hDlQ== 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 :message-id:date:subject:cc:to:from; bh=44YcveqdcBlTVBPxk4rtAlf6uAK1EgAt4PoD1CL0l/k=; b=Ybl0JMGMCG/qElXfrEK63WrWzInnRJZs5+iV2PnnoXUooKdSi9Cbhi6xu1gIuHOLiy DJVBOMTUGqCJEaM3gkXJUXhJchGpoUNHhc8jqR72Ri4ICNyr/UzNbQ2rvKP59LFSdxlE 5jrPc7ZHQZuZpmXjqj9FHBtMg1meQLNUK/dGA5SltoCsaPprXoUUaxqaUOGzT0wNGFC3 T1oRPeNufKaSMJE9lKQwtZc/tGZppCUyICZJHtcnOJ0wsvm9yzxVW11ArLI7sqc7pyjk X6n6dP4QXK65mN/BXKW+Pa94GFfzREFQjwBujwaJyCtF6eoW+SY0XVGxezGvwJIumOSR 9V0g== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e67si2447653pfh.212.2019.02.14.02.57.01; Thu, 14 Feb 2019 02:57:17 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387698AbfBNEMB (ORCPT + 99 others); Wed, 13 Feb 2019 23:12:01 -0500 Received: from mga14.intel.com ([192.55.52.115]:53764 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727739AbfBNEMB (ORCPT ); Wed, 13 Feb 2019 23:12:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2019 20:12:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,367,1544515200"; d="scan'208";a="318870398" Received: from lxy-dell.sh.intel.com ([10.239.159.147]) by fmsmga006.fm.intel.com with ESMTP; 13 Feb 2019 20:11:58 -0800 From: Xiaoyao Li To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Xiaoyao Li , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Subject: [PATCH] kvm: vmx: Fix entry nubmer check for add_atomic_switch_msr() Date: Thu, 14 Feb 2019 12:08:58 +0800 Message-Id: <20190214040858.15975-1-xiaoyao.li@linux.intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") Signed-off-by: Xiaoyao Li --- 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 95d618045001..1aaef2d536bd 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -863,7 +863,8 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr, 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; -- 2.19.1