Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp784894ybl; Fri, 31 Jan 2020 07:59:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzq0WFApj8YgLxv3VdxHX+EQRCz/NG4NYHEppzteue/WH79dR13d/KMh42vWxf4zplfYhgx X-Received: by 2002:a05:6808:8ee:: with SMTP id d14mr5343206oic.138.1580486376699; Fri, 31 Jan 2020 07:59:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580486376; cv=none; d=google.com; s=arc-20160816; b=xP7L2hFC3f1KUPy4CwiwOOZDwiwoDugHLChpP160eJX551PhkQh1omX57iausbZN1M msepBxK3IEq5SS2krK47EHuYOA2HWCtux684tYs0AOps3qcRDcXOQzjb0YlZqQadSBgi 4QoaWAIMtPr2ysJPCO/u6WYs/LqA6Vhwg2B1/oWLvopCOpM0Ky59W20gNWarcr1z4KfU MluTDSRcDtGJ5oylRi9bSEeFwvKhmW8Ogqm8qmiE87GMeg3m6T08Uafrq2IiaID0kgsf 9/Qlls98BYfn8KOUHkFJ0Tia58UBydMlQS22oGukOPANlGa93ukhfYOp8bm5wpElVgON v8Sw== 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=bSGTyy/5oLl1376gdfOtyURihjTrVjIvCTf+KTM5l3Q=; b=LUJn8SYEdZYlSb3fIzWNR8MJSifvNIZrMHVk8wiE2pg8XW7xNmYcdpIiIXl1EIhQR2 qmsBYwGAfeKTHxkjyVunIpAs8mnMzsjhBjynWO3Vqt0DP1K662op89ujAF60sjIMNhLO qvChNUrYis3AR2ocR/Xtyk40dIdZ4fkBzvaC+kXnzawbdoazCy3Nqrn48DnMYIMhcMK6 WfrDcUquz3Y9veEAr/wzDRq19ZUGzYnFPicuYDLRQQk7H3b0pSIBrjS3SCJwoXcENomu 7SRu8hiLwPg5OdoOSlugUKjrD0a/KVb1NfTctBUQCYYpUBdaYaAndkECjrxJ+5/2g2dy +61A== 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=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a23si2298264oie.81.2020.01.31.07.59.22; Fri, 31 Jan 2020 07:59:36 -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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729192AbgAaP5Z (ORCPT + 99 others); Fri, 31 Jan 2020 10:57:25 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:34228 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728922AbgAaP5Z (ORCPT ); Fri, 31 Jan 2020 10:57:25 -0500 Received: from 1.general.cascardo.us.vpn ([10.172.70.58] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1ixYfZ-0005XW-Gz; Fri, 31 Jan 2020 15:57:22 +0000 From: Thadeu Lima de Souza Cascardo To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, sean.j.christopherson@intel.com, wanpengli@tencent.com, vkuznets@redhat.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86/kvm: do not setup pv tlb flush when not paravirtualized Date: Fri, 31 Jan 2020 12:56:55 -0300 Message-Id: <20200131155655.49812-1-cascardo@canonical.com> X-Mailer: git-send-email 2.24.0 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 kvm_setup_pv_tlb_flush will waste memory and print a misguiding message when KVM paravirtualization is not available. Intel SDM says that the when cpuid is used with EAX higher than the maximum supported value for basic of extended function, the data for the highest supported basic function will be returned. So, in some systems, kvm_arch_para_features will return bogus data, causing kvm_setup_pv_tlb_flush to detect support for pv tlb flush. Testing for kvm_para_available will work as it checks for the hypervisor signature. Besides, when the "nopv" command line parameter is used, it should not continue as well, as kvm_guest_init will no be called in that case. Signed-off-by: Thadeu Lima de Souza Cascardo --- arch/x86/kernel/kvm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 81045aabb6f4..d817f255aed8 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -736,6 +736,9 @@ static __init int kvm_setup_pv_tlb_flush(void) { int cpu; + if (!kvm_para_available() || nopv) + return 0; + if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) && !kvm_para_has_hint(KVM_HINTS_REALTIME) && kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) { -- 2.24.0