Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5944630ybe; Tue, 17 Sep 2019 16:36:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjFYpoAX59Nhtybra0Zz1XWPdCIumdd5TMIDwS++1aw5+FVMxiL4yDSRumluG66HQINyXh X-Received: by 2002:a05:6402:121a:: with SMTP id c26mr6042838edw.100.1568763372026; Tue, 17 Sep 2019 16:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568763372; cv=none; d=google.com; s=arc-20160816; b=sl9bE6hiZFRiilm0kFQN1AJjeRFWxQRGV8OmbDvVEtMNDO/zi1r48SQZ+4+7HZSsF+ LL6n5tLYgXNNy4BOUoK3DP7E7/0xDK/YqYKqUQlXIgtFk1zuiyOIIEdtbaPrXtslQA3F qGHQ8RnkEJsHqwVLOlcv/jKYy7OB1HbmQBOgaAZOEBARhlAZsw1+r6ns5hsJzXhvFrcU pmX1GEfsVuzn1CLUtpePUilCZgu5OCZffLoD21GYoYvRybOCHhnj9hqGl5AwoBdsUX6u 5Xv/YmeK3X7DQ9FiEXMQf+Xbj9SM3Q7owu2/gGaPLYG/rn6hqM8+/c51AVmY5aDmwoKX 9RBg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=zo94M/S+0QMhxiiEtdJA09kaXmZqIlmiIBtzBP4Qi5Q=; b=rbhcNiEeM8M77PcvpgXqsGGcrw2IZyZxAaHU3u05ExocqTHclEXocobJmuW/UApmee 9q8yjwxuNhRtjbYvI54R8E2rFULJJUhRHvqt0KoKQWEvZsQ//eVB9ECJuYQv97xV2H3T hzObR4b3gf6QTDRIh2zjvUhW0g1Kl+DSmbhr8gKwSrKGFJuGvM4F29Wz6xExLg60KFk6 WmG+SJb4d7vqPf03b7YoBcWZqpJ344UWvQ1VIsnPW/dLERvWrPZ46QqCNaIRFPv/LQKl jtWToYud4HjMFKDx0F63IK6ZIDNdaedRp29fH2Xx6fl0dKbsXSOGzU4QAzBNW8/vs8OO 7bxA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n17si2158037edo.143.2019.09.17.16.35.48; Tue, 17 Sep 2019 16:36:12 -0700 (PDT) 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727003AbfIQOIh (ORCPT + 99 others); Tue, 17 Sep 2019 10:08:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48656 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbfIQOIg (ORCPT ); Tue, 17 Sep 2019 10:08:36 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4AE75C010927 for ; Tue, 17 Sep 2019 14:08:36 +0000 (UTC) Received: by mail-wm1-f72.google.com with SMTP id o188so1305442wmo.5 for ; Tue, 17 Sep 2019 07:08:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zo94M/S+0QMhxiiEtdJA09kaXmZqIlmiIBtzBP4Qi5Q=; b=qrgWQTQ5soWy2LpQxG5VxRwUPmPCa9cbCXjDSWIMn6ZVd7O0IvBceau/RRl+ydKbvy VyHtttQLYMbweXVYnki5BNch+Tni59e33HT384tdyyI9XYN/1WmtCbCbfbbQLN3ZGBGa G3AcRi8ZcqYEYJEnvz/gbzoOrx3co4ehz7bIr2PEE8zzcBBWqDPPddn5g58OZAHiecK4 v+Z4Fm2PotdKlftUwg4/LuTpnLES7FVXoI/mI901PupRCMOV3p8yWm/NSdQnaUbKg0Ce a+tpQ52r6GzagrhsV1ZL9PWFK2rknRiOCnMXvHY19i55LHRLsruV4ZMTLW12QyiU4Btn iabQ== X-Gm-Message-State: APjAAAX75bDa6TqFnG91Kv7QA79rAjoTMBjlfx7xKgw25m18gkpmMfiL LnAGumM1IqdpgGPLw70Iy0yQg71PieJVOG1vDHmFID7+8JkVSQ9YVogpa9bEORMTHAn++VGTG4y og/qDdmnH/u4QBDgxpRzRNxQz X-Received: by 2002:a5d:5005:: with SMTP id e5mr3115540wrt.79.1568729314707; Tue, 17 Sep 2019 07:08:34 -0700 (PDT) X-Received: by 2002:a5d:5005:: with SMTP id e5mr3115522wrt.79.1568729314447; Tue, 17 Sep 2019 07:08:34 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c46c:2acb:d8d2:21d8? ([2001:b07:6468:f312:c46c:2acb:d8d2:21d8]) by smtp.gmail.com with ESMTPSA id l18sm2701304wrc.18.2019.09.17.07.08.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Sep 2019 07:08:34 -0700 (PDT) Subject: Re: [PATCH 2/3] KVM: x86: hyper-v: set NoNonArchitecturalCoreSharing CPUID bit when SMT is impossible To: Vitaly Kuznetsov , Jim Mattson Cc: kvm list , LKML , linux-hyperv@vger.kernel.org, the arch/x86 maintainers , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "Peter Zijlstra (Intel)" , Michael Kelley , Roman Kagan References: <20190916162258.6528-1-vkuznets@redhat.com> <20190916162258.6528-3-vkuznets@redhat.com> <87ef0fb72x.fsf@vitty.brq.redhat.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: Date: Tue, 17 Sep 2019 16:08:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <87ef0fb72x.fsf@vitty.brq.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/09/19 11:33, Vitaly Kuznetsov wrote: > Jim Mattson writes: > >> On Mon, Sep 16, 2019 at 9:23 AM Vitaly Kuznetsov wrote: >>> >>> Hyper-V 2019 doesn't expose MD_CLEAR CPUID bit to guests when it cannot >>> guarantee that two virtual processors won't end up running on sibling SMT >>> threads without knowing about it. This is done as an optimization as in >>> this case there is nothing the guest can do to protect itself against MDS >>> and issuing additional flush requests is just pointless. On bare metal the >>> topology is known, however, when Hyper-V is running nested (e.g. on top of >>> KVM) it needs an additional piece of information: a confirmation that the >>> exposed topology (wrt vCPU placement on different SMT threads) is >>> trustworthy. >>> >>> NoNonArchitecturalCoreSharing (CPUID 0x40000004 EAX bit 18) is described in >>> TLFS as follows: "Indicates that a virtual processor will never share a >>> physical core with another virtual processor, except for virtual processors >>> that are reported as sibling SMT threads." From KVM we can give such >>> guarantee in two cases: >>> - SMT is unsupported or forcefully disabled (just 'disabled' doesn't work >>> as it can become re-enabled during the lifetime of the guest). >>> - vCPUs are properly pinned so the scheduler won't put them on sibling >>> SMT threads (when they're not reported as such). >> >> That's a nice bit of information. Have you considered a mechanism for >> communicating this information to kvm guests in a way that doesn't >> require Hyper-V enlightenments? >> > > (I haven't put much thought in this) but can we re-use MD_CLEAR CPUID > bit for that? Like if the hypervisor can't guarantee usefulness > (e.g. when two random vCPUs can be put on sibling SMT threads) of > flushing, is there any reason to still make the guest think the feature > is there? Yes, that's a good idea. Paolo