Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4995154pxv; Tue, 6 Jul 2021 14:34:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg2C+3jYhA0an7m6O3zCfYwV74ohP7LGtt4xqObHy1oq+6WuajB0g8Puxd1Lb1vapCRwma X-Received: by 2002:a05:6e02:218c:: with SMTP id j12mr16319714ila.188.1625607258324; Tue, 06 Jul 2021 14:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625607258; cv=none; d=google.com; s=arc-20160816; b=EcBKm2ZQFeagreZSK6nSdk28tRdjBlaVtReTI/p7PnR+SmxpUb74WZM72QB4k+BrEg P/oauwelLbOWDl6by5+8yXjEPCGS1vBkzt6olEkP74e18c4kKUMgVVLHW4prq3e0xShy EqAfXZ1dy+fVOlHBtGbS65OvIbiDTabbMjHJJX0IuIKQj1c3lIfGIv0cL4hR6tMmUFbf NgoF9h3o13Q4WPkgujnNhpynTcQWAFpImdjH25nJcx6dn7n34t7OKIuyo3mc2K8PPKaP r8a7HseSgddkIsZxOzbT6XmsjDhx7JO5SIDAr+HX8HqxB884iPZjC/wW8QGbjgTfAz4t TXyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=WYXYXa+th2cYeV7B6S0tgQlmASzmnAP4QbXludRovGE=; b=cJZsJbSyo/Yv58fc6iq9W1SaPQnle5Yiua8EyYwDvmihzfs4AcZN4yEWEFABOuiHNp YAggQsKOhrot/tewQo/yvQ/Z0AdBKJ/X9f4LfevgoMsUVYgPLnaiwRxMA4sJlojifQSz lgl2prYvBFk4eyKBTyV/MfE9I8mH/Pe8AUzX37MglbnwSCkJoXvRUB2iB4rBZz2GT6Fn arqP1lXFCj3glT1bZkr+JwtzIy+VPlG4k7S5M8OAI628wkQ1OF2DtKi8tkdG4xZdsdLy 0N2mW9z2SBX5egOyuAC5jOIePTa0qm7jTunx9TuKE2Ea1CsHLUjv0bEjxI5L1zAlox9W rY5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E9mT4GXO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n4si1140196ion.62.2021.07.06.14.34.06; Tue, 06 Jul 2021 14:34:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E9mT4GXO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229753AbhGFVgS (ORCPT + 99 others); Tue, 6 Jul 2021 17:36:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52424 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbhGFVgR (ORCPT ); Tue, 6 Jul 2021 17:36:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625607218; 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=WYXYXa+th2cYeV7B6S0tgQlmASzmnAP4QbXludRovGE=; b=E9mT4GXO6bHnr2GGo2X3sp9hr7HlWZs/FEF/1+SII9VIQ+EIr4SIxmBsl345rdplj7TGOr yKUcQj8E/lU215/tY4AiAEPwdjgOcReeANbp5hFva2Gg48ZcvoJRNcO2YC8sWRwgWCw5ax GuUrLtwesDMcXJYlMf82Cuc1jakh/g8= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-300-ngitzSKOMZufYcKmF-q8WA-1; Tue, 06 Jul 2021 17:33:37 -0400 X-MC-Unique: ngitzSKOMZufYcKmF-q8WA-1 Received: by mail-lf1-f72.google.com with SMTP id x5-20020a0565121305b029032696702876so54448lfu.5 for ; Tue, 06 Jul 2021 14:33: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:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WYXYXa+th2cYeV7B6S0tgQlmASzmnAP4QbXludRovGE=; b=qH7UBxNxu1cnv9+slh33UpKezqwYDmEiia0nY4ECQ7ExJAF84KAqmI3wvQZCiLKBcV XriEgoszQkQbk5uU9RqdRCLTq8sk0Pcglw1z7itGRFWzW0rjalSzDn3KOT3witLxTFu3 /xvOJMtaee0nWIi9FB1NDfkyBMpBS87LQkb5LocLKd3H6oLoFWO36trfyk4nivPnamLF sty1vJxp04nXPDtIRsuQ6XMrVyr+AraNE8r7T8LtSCCwqIFvWYRjxZl6CKnl0WQeCwNG 5F3mEMgXG04djuEzK9+XkkjA1eA5698tPtvbKOrShLv3bHo+hk5ln6RpP55B0CuyCjWV oiiA== X-Gm-Message-State: AOAM531hDkamGPAiqeUWNUyNTPiu3F3iVIpE/l+96vc4+0BKZp+5Tu9Y rLW3mfRQVrUy/hynYImDRg1dU8UjbUUUNK3fZkeAMG0S+shLExpbPl1YGCKqeATDQsd0SAITKVD mHcSCUCWmSTNxsxzmOOjyru6fM+EfjHHvCg1iU2k3 X-Received: by 2002:a2e:8001:: with SMTP id j1mr17136826ljg.332.1625607215517; Tue, 06 Jul 2021 14:33:35 -0700 (PDT) X-Received: by 2002:a2e:8001:: with SMTP id j1mr17136776ljg.332.1625607215277; Tue, 06 Jul 2021 14:33:35 -0700 (PDT) MIME-Version: 1.0 References: <20210706195233.h6w4cm73oktfqpgz@habkost.net> <4cc2c5fe-2153-05c5-dedd-8cb650753740@redhat.com> In-Reply-To: <4cc2c5fe-2153-05c5-dedd-8cb650753740@redhat.com> From: Eduardo Habkost Date: Tue, 6 Jul 2021 17:33:19 -0400 Message-ID: Subject: Re: [PATCH 4/4] x86/tsx: Add cmdline tsx=fake to not clear CPUID bits RTM and HLE To: Paolo Bonzini Cc: Pawan Gupta , Thomas Gleixner , Borislav Petkov , Jonathan Corbet , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , x86@kernel.org, "H. Peter Anvin" , "Paul E. McKenney" , Randy Dunlap , Andrew Morton , "Maciej W. Rozycki" , Viresh Kumar , Vlastimil Babka , Tony Luck , Sean Christopherson , Kyung Min Park , Fenghua Yu , Ricardo Neri , Tom Lendacky , Juergen Gross , Krish Sadhukhan , Kan Liang , Joerg Roedel , Victor Ding , Srinivas Pandruvada , Brijesh Singh , Dave Hansen , Mike Rapoport , Anthony Steinhauser , Anand K Mistry , Andi Kleen , Miguel Ojeda , Nick Desaulniers , Joe Perches , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 6, 2021 at 5:05 PM Paolo Bonzini wrote: > > On 06/07/21 21:52, Eduardo Habkost wrote: > > On Wed, Jun 09, 2021 at 02:14:39PM -0700, Pawan Gupta wrote: > >> On CPUs that deprecated TSX, clearing the enumeration bits CPUID.RTM and > >> CPUID.HLE may not be desirable in some corner cases. Like a saved guest > >> would refuse to resume if it was saved before the microcode update > >> that deprecated TSX. > > Why is a global option necessary to allow those guests to be > > resumed? Why can't KVM_GET_SUPPORTED_CPUID always return the HLE > > and RTM bits as supported when the host CPU has them? > > It's a bit tricky, because HLE and RTM won't really behave well. An old > guest that sees RTM=1 might end up retrying and aborting transactions > too much. So I'm not sure that a QEMU "-cpu host" guest should have HLE > and RTM enabled. Is the purpose of GET_SUPPORTED_CPUID to return what is supported by KVM, or to return what "-cpu host" should enable by default? They are conflicting requirements in this case. > > So it makes sense to handle it in userspace, with one of the two > following possibilities: > > - userspace sees TSX_FORCE_ABORT and if so it somehow "discourages" > setting HLE/RTM, even though they are shown as supported > > - userspace sees TSX_FORCE_ABORT and if so it knows HLE/RTM can be set, > even though they are discouraged in general In either case, we can make new userspace behave well. I'm worried about existing userspace: Returning HLE=1,RTM=1 in GET_SUPPORTED_CPUID makes existing userspace take bad decisions until it's updated. Returning HLE=0,RTM=0 in GET_SUPPORTED_CPUID prevents existing userspace from resuming existing VMs (despite being technically possible). The first option has an easy workaround that doesn't require a software update (disabling HLE/RTM in the VM configuration). The second option doesn't have a workaround. I'm inclined towards the first option. > > In any case, KVM's "supported CPUID" is based on the host features but > independent. KVM can decide to show or hide the hardware HLE and RTM > bits independent of the host tsx= setting; it may make sense to hide the > bits via a module parameter, but in any case this patch is not needed. > > Paolo > -- Eduardo