Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1908961ybl; Sat, 1 Feb 2020 09:00:44 -0800 (PST) X-Google-Smtp-Source: APXvYqy1WKhBDRLNQKEOorhP/pTycYNqzYQ271UzKkzvqCFb396x2vEfA7Sv1lEG6Pu1L3I01qqv X-Received: by 2002:a9d:22:: with SMTP id 31mr11333820ota.173.1580576443939; Sat, 01 Feb 2020 09:00:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580576443; cv=none; d=google.com; s=arc-20160816; b=PqU2nEBxMRuBJwXDDuNia80SkQDem08yY2CLIeMSutI0jgQVt9AEOIE1E57y5xGNyY JB/cVDP14PxuKm/neMgpZzzYP1mRzOnte1tZGxCSHEu306iWhZlXenUyUBivgYCCTUMN oFeSlbLu13Ou2yzoQRpNqYGmArXa4uqSj5jq90Vi21BRnAa014JRmpUGtSX0auHB92fV bv6m+PoTOZHqaPMWAcxLWMY1iGx2rh/8G9mb5kypqVh98EH3sWm9nrhPUwsQvasQmTge FL01S7Up+rkB5goaWKtuMDDx9P4vHyMlRVuEZktwDfGp5RT2408PyQ+9QglqG8dgsKNh ns1w== 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:from:references:cc:to:subject; bh=UI8MBu6jZPwTB+NSxHgYqqNCLSURvphPXBo0Af1Xpic=; b=xqHhAx5cc5nHNavWzT8JXdHATGWDtkt5tpfM9xL7lk3NNWIiZIxNvBf4zTqvO0BWOw o65d1nwzx4n1tA73c14KB+XDY8aK3uJv1w2vJ8oBPrwPit7aOZkAeiZjVrGFJbA0Jp05 VILYlhRxeAdx2ytTfoOI+pHWu1n08Yr2BwL/8fEMuiRYhlbIbpcpPoSJzttt/QRhHGBa GYu/PEFhs3HiHh5BbfHMPFg+RQni2aga9lwPRNhZj/UVf3ZqdgaBN3zEo28eIEl48dF7 rUfoLNdOsgJdQvgBcmxv0cP79cbbJr83Y9AIACJdwGMD/iA/ObS7dnAzO5TItj5HUAtR rLmA== 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 d1si6292888oth.158.2020.02.01.09.00.29; Sat, 01 Feb 2020 09:00:43 -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 S1726839AbgBAQ6V (ORCPT + 99 others); Sat, 1 Feb 2020 11:58:21 -0500 Received: from mga07.intel.com ([134.134.136.100]:37934 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgBAQ6U (ORCPT ); Sat, 1 Feb 2020 11:58:20 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2020 08:58:20 -0800 X-IronPort-AV: E=Sophos;i="5.70,390,1574150400"; d="scan'208";a="218922079" Received: from xiaoyaol-mobl.ccr.corp.intel.com (HELO [10.249.174.29]) ([10.249.174.29]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 01 Feb 2020 08:58:17 -0800 Subject: Re: [PATCH 2/2] KVM: VMX: Extend VMX's #AC handding To: Andy Lutomirski , Sean Christopherson Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Paolo Bonzini , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <20200131210424.GG18946@linux.intel.com> From: Xiaoyao Li Message-ID: Date: Sun, 2 Feb 2020 00:58:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed 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 2/1/2020 5:33 AM, Andy Lutomirski wrote: > > >> On Jan 31, 2020, at 1:04 PM, Sean Christopherson wrote: >> >> On Fri, Jan 31, 2020 at 12:57:51PM -0800, Andy Lutomirski wrote: >>> >>>>> On Jan 31, 2020, at 12:18 PM, Sean Christopherson wrote: >>>> >>>> This is essentially what I proposed a while back. KVM would allow enabling >>>> split-lock #AC in the guest if and only if SMT is disabled or the enable bit >>>> is per-thread, *or* the host is in "warn" mode (can live with split-lock #AC >>>> being randomly disabled/enabled) and userspace has communicated to KVM that >>>> it is pinning vCPUs. >>> >>> How about covering the actual sensible case: host is set to fatal? In this >>> mode, the guest gets split lock detection whether it wants it or not. How do >>> we communicate this to the guest? >> >> KVM doesn't advertise split-lock #AC to the guest and returns -EFAULT to the >> userspace VMM if the guest triggers a split-lock #AC. >> >> Effectively the same behavior as any other userspace process, just that KVM >> explicitly returns -EFAULT instead of the process getting a SIGBUS. > > > Which helps how if the guest is actually SLD-aware? > > I suppose we could make the argument that, if an SLD-aware guest gets #AC at CPL0, it’s a bug, but it still seems rather nicer to forward the #AC to the guest instead of summarily killing it. If KVM does advertise split-lock detection to the guest, then kvm/host can know whether a guest is SLD-aware by checking guest's MSR_TEST_CTRL.SPLIT_LOCK_DETECT bit. - If guest's MSR_TEST_CTRL.SPLIT_LOCK_DETECT is set, it indicates guest is SLD-aware so KVM forwards #AC to guest. - If not set. It may be a old guest or a malicious guest or a guest without SLD support, and we cannot figure it out. So we have to kill the guest when host is SLD-fatal, and let guest survive when SLD-WARN for old sane buggy guest. In a word, all the above is on the condition that KVM advertise split-lock detection to guest. But this patch doesn't do this. Maybe I should add that part in v2. > ISTM, on an SLD-fatal host with an SLD-aware guest, the host should tell the guest “hey, you may not do split locks — SLD is forced on” and the guest should somehow acknowledge it so that it sees the architectural behavior instead of something we made up. Hence my suggestion. >