Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3607866ybl; Mon, 3 Feb 2020 03:24:57 -0800 (PST) X-Google-Smtp-Source: APXvYqx+e8s/UoCtY3tOxz8KZwsk7bnmisTqxxo1qeo73PIXOYpPCIiC2m70ZUbsm4/+yL5IpYrj X-Received: by 2002:a9d:6183:: with SMTP id g3mr17190742otk.304.1580729096724; Mon, 03 Feb 2020 03:24:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580729096; cv=none; d=google.com; s=arc-20160816; b=hzZyTklJ4bPoU5FcvZcNrDHFdAZhwuPShHRPCvUuXFl9tHL3oV9PBkb1uZ+wqf3ZK/ HJ+bvgQGrevofobRsX+sGFrE7HtWjq9is7y64BvZFEur4RuSYhKj9k7M8I1k46WgGzwJ YGGlO4cF9yRDKV95XQdP0DOE2pd6Q7i9Yn3oB9tI4KK+MusT2NC3QxYCIm8rVynZW5SO DWGsOJ0sAKfXrDNKGBBFvDFzdQp97nBk1qGv4Z9+SSqwAQDAL7on5G6igQnHg7U1pmXA 3yDZE/5u/d/t1VxmMhcrdTTBbtq45xGOrGs4SvIGwSK4zEcdtn0pomyL9J1+2Md9aHWj KgNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=hN0XJ3e40Iv8crpZTtg0MhsXfkxzrtU4D3I/YBNqM/A=; b=QAQUZd9FcTz9DX9IqI6pSF+4JknaAJQ92eQneMIQliu5EnQukXGGnYR+um207oNOVn ALjlYLnusiPC03U6oRxQwuMMmKsIILJxQzuf0GtD6YFevn79PxXOFAMOe7oLd0tTl3HR LLMB97fFQpNdngwE03h7cB9rTjpMjeUOGuH8Wa/GfD0SxxlFd8+Hu8ZbThDgexXl6fJZ YZcEA0PLrdJYxBmwAlDti8T+Ut/ESI2hcS3/1B6Opd+jYPbUPlalac5+iylhV5uDMNHL g/dRBnGwFT8iEU8mVIVn8youMU6OLU8S0vArc3EwVgcegbhdMpZ+mIM8fo9LklYQgpOy 2Z2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P8IRp2Cl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12si10034385otk.215.2020.02.03.03.24.44; Mon, 03 Feb 2020 03:24:56 -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=@redhat.com header.s=mimecast20190719 header.b=P8IRp2Cl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727357AbgBCJ7P (ORCPT + 99 others); Mon, 3 Feb 2020 04:59:15 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:52477 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727337AbgBCJ7P (ORCPT ); Mon, 3 Feb 2020 04:59:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580723954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hN0XJ3e40Iv8crpZTtg0MhsXfkxzrtU4D3I/YBNqM/A=; b=P8IRp2Cl8t0XzxGn5IxtpP8hRjcazyGUY1LN3aJLCQfxzNPfFq+bNInKiZBLQoIcO51Tnc 4Li1yPkmrJ14V543hytcbhJ7Som6BimTf8+Y3JlNpQSq80R8z6JhuV4sSt+l8XMikfEglC QVv3wiDNOUnl2eYbLW2LiOQ69nZGqXo= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-ypO9tWPKOKmBlP3Npb96oQ-1; Mon, 03 Feb 2020 04:59:13 -0500 X-MC-Unique: ypO9tWPKOKmBlP3Npb96oQ-1 Received: by mail-wr1-f69.google.com with SMTP id c6so7918841wrm.18 for ; Mon, 03 Feb 2020 01:59:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=hN0XJ3e40Iv8crpZTtg0MhsXfkxzrtU4D3I/YBNqM/A=; b=n1B+F412kVIS1gh0kpwO6LfIjOrd0vxW3smIJaDRPSCuhdRYjSEFd6IIUMQVOCjCom 4tCp1tXTZSxeCShtbxem6gf4SfyvU9Yd7stJ8na/1Ju9zXOamC+z1N41DokoeI566VAN iM8t4HcQukJ5GZlgKPIZ1KiW4RNREkB98/wyj3vIZMXFSoDL0XtrkOd97xCuAQjk9pQR Gff6TyqAnoC3UThYQrGVm6sJ9t1fwQFCx8wgUTtopiVlJBtxPJY3CDphXD9GbVmAc9Vo RnsjWqmZ0Tqg8hCjgqgq7BUMR1Y2N4eZolIzMzMmzTqynvMmA13ctXIII2QsYOyXlsfT LeBA== X-Gm-Message-State: APjAAAV0mDXgJwkYYLKERaZ4p0frDuFMB52EF8jcjB2GKfKz4Xq/Fh7F RGhK29bd55iX24d+iCIeV0cctVWUDVKzfpiOayYJV2IB7HasN0ta7jzs+L1nFQXCIhCcE5WYI5+ VpG775+ivDz2zzXKsiJywN0nw X-Received: by 2002:a5d:4b8f:: with SMTP id b15mr14441999wrt.100.1580723951852; Mon, 03 Feb 2020 01:59:11 -0800 (PST) X-Received: by 2002:a5d:4b8f:: with SMTP id b15mr14441966wrt.100.1580723951639; Mon, 03 Feb 2020 01:59:11 -0800 (PST) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id y6sm24389481wrl.17.2020.02.03.01.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 01:59:11 -0800 (PST) From: Vitaly Kuznetsov To: Thadeu Lima de Souza Cascardo Cc: pbonzini@redhat.com, sean.j.christopherson@intel.com, wanpengli@tencent.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, kvm@vger.kernel.org Subject: Re: [PATCH] x86/kvm: do not setup pv tlb flush when not paravirtualized In-Reply-To: <20200131155655.49812-1-cascardo@canonical.com> References: <20200131155655.49812-1-cascardo@canonical.com> Date: Mon, 03 Feb 2020 10:59:10 +0100 Message-ID: <87wo94ng9d.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thadeu Lima de Souza Cascardo writes: > 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)) { The patch will fix the immediate issue, but why kvm_setup_pv_tlb_flush() is just an arch_initcall() which will be executed regardless of the fact if we are running on KVM or not? In Hyper-V we setup PV TLB flush from ms_hyperv_init_platform() -- which only happens if Hyper-V platform was detected. Why don't we do it from kvm_init_platform() in KVM? -- Vitaly