Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp305609ybx; Wed, 6 Nov 2019 00:33:56 -0800 (PST) X-Google-Smtp-Source: APXvYqx/dM8pjMLEUNKkYfxyDMR8BOXxOZp2msum7npYgwGh+mxgf52a7u14UHFnCJwflqMH0v5e X-Received: by 2002:a17:906:2786:: with SMTP id j6mr31803962ejc.206.1573029236498; Wed, 06 Nov 2019 00:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573029236; cv=none; d=google.com; s=arc-20160816; b=B4H1RSeKy6r5ZnvjOE/kEnKuuBSM6RP/239EELRMrwztHpCNzwZ4mDz6GNnCAKyjFf P+BAhNJbIxnAqRaxP0ESiQA5yNy3M7zOZvvVMeyyOTF1faW+iHYSPh0l4TL6lYvpIDFd ctX5Ys8KyUqzDGpcD3BGT6Pu0n4BTENLsLbERDKAh4NQbAIdjwxiodV06pwo0ohOHAAG DqyCISDQUs/A4gTn99Xj/piOpEeRGYR6Ee9coeb6Ristsklut/xUfmbxpqyuafXsvzzk EDXDhGhdNRKgetQPuY7sfl40syeSVhoMHnDzxEomYWDx/4/CI6ZWv3pa/mGZLfk8i6ft Xj3A== 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:dkim-signature; bh=JQcWfG3124w8lNoztrGuavAOXYtN6kCwqs+HotAy+So=; b=HsYQmKM/fZ9nqKkGSWvhxPBpoH546xgQj0OxkVoIlb5b73qQK4AJ2tpjbgnb7usYi0 YYWXF3FQZwwHXDsZDC9mMJmYKMUaMu3uzawKuRGuynpuXKbJWbqWmGDyrkXUaSqlzW17 q48vYDIP+we/QE4ytztLce69xKyrsqZTvIj6sWA/S3NNW4dWVTrmOlV0Z0zpur0mlnSn vOP7pX1p0jw0Rm7GpjmnPEasProRcIMu0kzdBjrzFIchQgrzjq9PBCVpHNmFNaj5Zwy8 c8PLckek/ykQg1h2Q4AXvHuaNEBOO93UaO1Y808oH49cF05cl2AANnyGJja6Ajul6daD LWzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=EgpPWSF8; 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 j26si315648edq.389.2019.11.06.00.33.33; Wed, 06 Nov 2019 00:33: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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=EgpPWSF8; 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 S1731444AbfKFIco (ORCPT + 99 others); Wed, 6 Nov 2019 03:32:44 -0500 Received: from merlin.infradead.org ([205.233.59.134]:47612 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729951AbfKFIcn (ORCPT ); Wed, 6 Nov 2019 03:32:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JQcWfG3124w8lNoztrGuavAOXYtN6kCwqs+HotAy+So=; b=EgpPWSF8eMk3N3qqPjbk4Jt+E SxjSom1p1GGu+dLQgS/BgYBczHGQ+p511sCdvLqyGafRJJ3MewDobDhoOoP/iu/f1hupBJn7Viylt 5SmKD5yKloD2DnB0SRnD1QD9956xOIjtGzztvF54GV9+JigeAgpM0y8s0OwQyQiWbPhB8a0jNbOul H1wTz4VDTNU2OdiWY9t/KRa04hsmhYy/8wc3kzg/MXvQ5tQxZNhYm8Jxw5fD1pY0Zx+YrsEhdroIC 3OMA9Apo5UMREI2WNL8wVJjWkxr16RFRMQL8kMSC6JL4fE5HHvO5ud0e1R6nd9vhad47eakOmeV2E 0Ht94iGTA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iSGjg-0004RW-JA; Wed, 06 Nov 2019 08:32:16 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C9090301747; Wed, 6 Nov 2019 09:31:08 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C85132020D8FD; Wed, 6 Nov 2019 09:32:12 +0100 (CET) Date: Wed, 6 Nov 2019 09:32:12 +0100 From: Peter Zijlstra To: Paolo Bonzini Cc: Vitaly Kuznetsov , kvm@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Sean Christopherson , 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: <20191106083212.GO4131@hirez.programming.kicks-ass.net> References: <20191105161737.21395-1-vkuznets@redhat.com> <20191105200218.GF3079@worktop.programming.kicks-ass.net> <51c9fe0c-0bda-978c-27f7-85fe7e59e91d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51c9fe0c-0bda-978c-27f7-85fe7e59e91d@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 06, 2019 at 12:51:30AM +0100, Paolo Bonzini wrote: > On 05/11/19 21:02, 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. > > This is a subset of the requirements for "trustworthy" SMT. You can have: > > - vCPUs pinned to two threads in the same core and exposed as multiple > cores in the guest Why the .... would one do anything like that? > - vCPUs from different guests pinned to two threads in the same core > > and that would be okay as far as KVM_HINTS_REALTIME is concerned, but > would still allow exploitation of side-channels, respectively within the > VM and between VMs. Hardly, RT really rather would not have SMT. SMT is pretty crap for determinism.