Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7477200ybp; Wed, 16 Oct 2019 09:12:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzc83MCy2lwLroYcXiqLUdb4SSHcsRLFb1k5RruQ6IUM4BHBA0J97xnJFGxXsqpN9NNAww7 X-Received: by 2002:a05:6402:21c2:: with SMTP id bi2mr40237257edb.8.1571242379642; Wed, 16 Oct 2019 09:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571242379; cv=none; d=google.com; s=arc-20160816; b=sfESFLeoMIvJszuSYQfhJuAD8lbGfBSosxYjc1EdyIUyOfT8vtXDJd4vhCIkWf67Hb PpwOfIkexAImF0Tm07j7lQz8ggS7nt5AMjZF1bcsJy50ChhJYCDWumSeyu03PXErBDhJ 3VVYCA+VnvpjHxiLYzTlenzRooUnsNxTjPY0ZtVE6VR7IXjnERS4wX920A00fHkyqLt8 nz2HAvXeARDGwGPhw5EMJVOxns/0Acs4PpJR/tx38fvGu6xxl3vsHIPS75bxATxPRTIb LBugTn7Ay3bCNHGyblmVAaW4tWJWqhVgThOQvgg0Tc5lFzzLtAz8UBJ51ZWNQFMkTNz+ 6FcQ== 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=Bc7gkPDeSuKo8mrUFOYa6NlKk3qa9o4j7JsY4jVx7Qw=; b=mDJgoSJ26zf6lhykT5i5HMX+jOSC8FL4LLndmLd2dx+n1Kk8/7vUvPcx4xsoA6z2tt WwmeSM9i83Tp8NFzrOYfJ9GhEJNKke9Z8nzkgdwlCeSQBWTwUuj/liDiGNm7RL+g1YNA cL/3803Jdx+iRh23ef812GNTumoMZqYvIFmxOT2cFEE86yM9Ab7k1+TXDIZATg3q2MML bb6j4mzBygmQYwcv6zxuZcaGcrtZkXyYxhrcr6tJSVXSOBHNRkxe2utPJN+x+Vc6k7D0 rum1pOGTLj7e1g95syKXv41ebM+fSEVkNCnBdpgPUz6NxCSjIF9yfjfAKUqJw5YhoCOe 946A== 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 j28si20239108eda.161.2019.10.16.09.12.36; Wed, 16 Oct 2019 09:12:59 -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 S2393806AbfJPOIT (ORCPT + 99 others); Wed, 16 Oct 2019 10:08:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43360 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728316AbfJPOIS (ORCPT ); Wed, 16 Oct 2019 10:08:18 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (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 8E1194E83C for ; Wed, 16 Oct 2019 14:08:17 +0000 (UTC) Received: by mail-wm1-f70.google.com with SMTP id q22so1041760wmc.1 for ; Wed, 16 Oct 2019 07:08:17 -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=Bc7gkPDeSuKo8mrUFOYa6NlKk3qa9o4j7JsY4jVx7Qw=; b=cZXtHPlnPTjGhXudVLXqbE0XfWdNaNZR4JJcD41hovnYF12LMo7ePJYFycZv++0RZW TJncVAZ6rvscE1HGDBhX5Ae0b1ysZK9cxMi5VN61JT39HCstS0QoIqQ7ixqtY7WzqQ4C RcG1IVsy+k++zI3Up0hvmTG9WYmlnqnU4e/jIHdvP0R8/15OX3uePEw6fycrTaD2oms+ /6ijPfWhaF++LRtP+46HcrpCNo1zkgrG8e8MMZ1XAPwr2p+G+K6IM2jcS7OAIupdZgNb EBoFW7KTnZ+3+fMuQWA9W4RxlJmtDiR2yBaymnIW5duw2z9XANK3Dr7AylMNQO6WObqQ 4r7Q== X-Gm-Message-State: APjAAAXs3yHHZdkIRsAsOT0dghEaIPzdiAwLMoUtGyhtwmEaPyu0wIj4 4X4cPZav7iMpJatOsciZCYeG9Q9dMMnXogblsJDuoWhYbMTEPgZdRGLuMfaOd5aWCwtT7L+aEI/ nhA675IJzG4BoIDalaJyPik+1 X-Received: by 2002:a1c:8043:: with SMTP id b64mr3428839wmd.145.1571234896112; Wed, 16 Oct 2019 07:08:16 -0700 (PDT) X-Received: by 2002:a1c:8043:: with SMTP id b64mr3428811wmd.145.1571234895779; Wed, 16 Oct 2019 07:08:15 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:d001:591b:c73b:6c41? ([2001:b07:6468:f312:d001:591b:c73b:6c41]) by smtp.gmail.com with ESMTPSA id o70sm2980726wme.29.2019.10.16.07.08.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Oct 2019 07:08:14 -0700 (PDT) Subject: Re: [PATCH v9 09/17] x86/split_lock: Handle #AC exception for split lock To: Xiaoyao Li , Thomas Gleixner Cc: Sean Christopherson , Fenghua Yu , Ingo Molnar , Borislav Petkov , H Peter Anvin , Peter Zijlstra , Andrew Morton , Dave Hansen , Radim Krcmar , Ashok Raj , Tony Luck , Dan Williams , Sai Praneeth Prakhya , Ravi V Shankar , linux-kernel , x86 , kvm@vger.kernel.org References: <1560897679-228028-1-git-send-email-fenghua.yu@intel.com> <1560897679-228028-10-git-send-email-fenghua.yu@intel.com> <20190626203637.GC245468@romley-ivt3.sc.intel.com> <20190925180931.GG31852@linux.intel.com> <3ec328dc-2763-9da5-28d6-e28970262c58@redhat.com> <57f40083-9063-5d41-f06d-fa1ae4c78ec6@redhat.com> <3a12810b-1196-b70a-aa2e-9fe17dc7341a@redhat.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: Date: Wed, 16 Oct 2019 16:08:14 +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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/10/19 15:51, Xiaoyao Li wrote: > On 10/16/2019 7:58 PM, Paolo Bonzini wrote: >> On 16/10/19 13:49, Thomas Gleixner wrote: >>> On Wed, 16 Oct 2019, Paolo Bonzini wrote: >>>> Yes it does.  But Sean's proposal, as I understand it, leads to the >>>> guest receiving #AC when it wasn't expecting one.  So for an old guest, >>>> as soon as the guest kernel happens to do a split lock, it gets an >>>> unexpected #AC and crashes and burns.  And then, after much googling >>>> and >>>> gnashing of teeth, people proceed to disable split lock detection. >>> >>> I don't think that this was what he suggested/intended. >> >> Xiaoyao's reply suggests that he also understood it like that. > > Actually, what I replied is a little different from what you stated > above that guest won't receive #AC when it wasn't expecting one but the > userspace receives this #AC. Okay---but userspace has no choice but to crash the guest, which is okay for debugging but, most likely, undesirable behavior in production. >>> With your proposal you render #AC useless even on hosts which have SMT >>> disabled, which is just wrong. There are enough good reasons to disable >>> SMT. >> >> My lazy "solution" only applies to SMT enabled.  When SMT is either not >> supported, or disabled as in "nosmt=force", we can virtualize it like >> the posted patches have done so far. > > Do we really need to divide it into two cases of SMT enabled and SMT > disabled? Yes, absolutely. Because in one case MSR_TEST_CTRL behaves sanely, in the other it doesn't. >> Yes, that's a valid alternative.  But if SMT is possible, I think the >> only sane possibilities are global disable and SIGBUS.  SIGBUS (or >> better, a new KVM_RUN exit code) can be acceptable for debugging >> guests too. > > If SIGBUS, why need to globally disable? SIGBUS (actually a new KVM_EXIT_INTERNAL_ERROR result from KVM_RUN is better, but that's the idea) is for when you're debugging guests. Global disable (or alternatively, disable SMT) is for production use. > When there is an #AC due to split-lock in guest, KVM only has below two > choices: > 1) inject back into guest. >    - If kvm advertise this feature to guest, and guest kernel is latest, > and guest kernel must enable it too. It's the happy case that guest can > handler it on its own purpose. >    - Any other cases, guest get an unexpected #AC and crash. > 2) report to userspace (I think the same like a SIGBUS) > > So for simplicity, we can do what Paolo suggested that don't advertise > this feature and report #AC to userspace when an #AC due to split-lock > in guest *but* we never disable the host's split-lock detection due to > guest's split-lock. This is one possibility, but it must be opt-in. Either you make split lock detection opt-in in the host (and then a userspace exit is okay), or you make split lock detection opt-in for KVM (and then #AC causes a global disable of split-lock detection on the host). Breaking all old guests with the default options is not a valid choice. Paolo