Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1392052ybx; Tue, 5 Nov 2019 15:28:45 -0800 (PST) X-Google-Smtp-Source: APXvYqzYv2i0KNYIFQlsg+XmBp2a2nslX87EoPfAZTh39TjQLSueEp0yDU2vRwhK7uX1iH3bqYV6 X-Received: by 2002:a50:ec83:: with SMTP id e3mr16370765edr.292.1572996525238; Tue, 05 Nov 2019 15:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572996525; cv=none; d=google.com; s=arc-20160816; b=dgcjqsZ0+kf4ZKiGO9e94bUxTauaR7KYqc6G1fFegxkY6vDSC/9M8s82cdwogAsK36 6kE9a6V9nLgylwrGI6qTKxyUDqvVTbdy6++MevMPuyY4Utj8mYuOzsGVpYLm+R5DsMvg 1xLDg863n7sieKVkrTDDdmBJcHH25ITXk0LbjWrqQaelYLUWNtLTCXe5GpA/iTUQ115Q tASFvCwuOF96GfhEabV/VyKg1idEykeGGdbHY0DJazEPWVIV7z3HsDV+ryOG2i/Rlu/f 310vJMkmGiCSBMOqVz9lZ6CWRnZ3NRV/UdJYqcM8DNQpZazI0pFuTGYarCN79BAPesdA /tyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=6OOP+rut6B7pW4gXw6lBsTFuFf4swJLgwITXhFjG3sM=; b=f1h05ti653yBkSvDQVMnny969tNRyKRAnndSwTyCxstLD1YDN+xdhj5knKk3mgCxoX xDdPtiUzEJEimlgbyYBE6hF9YQjSemCapJTNJyz6U97ISnP0024ihQPIXxyx9QaQ3qJ3 LHjEjtV8TSqn8uOjDb/fMmMj187aSuIjGn0M7xDVO1tFLuxQAB/x1M4xmKMpfpBumxde zcNIA8o/pQ6fx2jYgnI9m0TNBp34NpYAvT9KRhhd7gPqQZfqqQ6e6NU8fTZzk6asRufd 30qSHM0h1D9mk+fpyaEZTzkEk/PoVDZRUjWypvbR9e2/cQr0jRlfwgwnxokaoJ/C7M7d py7g== 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 v27si15545354ejk.63.2019.11.05.15.28.08; Tue, 05 Nov 2019 15:28:45 -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 S1729792AbfKEXZ3 (ORCPT + 99 others); Tue, 5 Nov 2019 18:25:29 -0500 Received: from mga05.intel.com ([192.55.52.43]:5100 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729692AbfKEXZ3 (ORCPT ); Tue, 5 Nov 2019 18:25:29 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Nov 2019 15:25:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,271,1569308400"; d="scan'208";a="285479561" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by orsmga001.jf.intel.com with ESMTP; 05 Nov 2019 15:25:28 -0800 Date: Tue, 5 Nov 2019 15:25:28 -0800 From: Sean Christopherson To: Peter Zijlstra Cc: Vitaly Kuznetsov , kvm@vger.kernel.org, x86@kernel.org, Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Jim Mattson , Liran Alon , linux-kernel@vger.kernel.org, "H. Peter Anvin" Subject: Re: [PATCH RFC] KVM: x86: tell guests if the exposed SMT topology is trustworthy Message-ID: <20191105232528.GF23297@linux.intel.com> References: <20191105161737.21395-1-vkuznets@redhat.com> <20191105200218.GF3079@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191105200218.GF3079@worktop.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 05, 2019 at 09:02:18PM +0100, Peter Zijlstra wrote: > On Tue, Nov 05, 2019 at 05:17:37PM +0100, Vitaly Kuznetsov wrote: > > Virtualized guests may pick a different strategy to mitigate hardware > > vulnerabilities when it comes to hyper-threading: disable SMT completely, > > use core scheduling, or, for example, opt in for STIBP. Making the > > decision, however, requires an extra bit of information which is currently > > missing: does the topology the guest see match hardware or if it is 'fake' > > and two vCPUs which look like different cores from guest's perspective can > > actually be scheduled on the same physical core. Disabling SMT or doing > > core scheduling only makes sense when the topology is trustworthy. > > > > Add two feature bits to KVM: KVM_FEATURE_TRUSTWORTHY_SMT with the meaning > > that KVM_HINTS_TRUSTWORTHY_SMT bit answers the question if the exposed SMT > > topology is actually trustworthy. It would, of course, be possible to get > > away with a single bit (e.g. 'KVM_FEATURE_FAKE_SMT') and not lose backwards > > compatibility but the current approach looks more straightforward. > > The only way virt topology can make any sense what so ever is if the > vcpus are pinned to physical CPUs. > > And I was under the impression we already had a bit for that (isn't it > used to disable paravirt spinlocks and the like?). But I cannot seem to > find it in a hurry. Yep, KVM_HINTS_REALTIME does what you describe. > So I would much rather you have a bit that indicates the 1:1 vcpu/cpu > mapping and if that is set accept the topology information and otherwise > completely ignore it.