From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F8F0C33CB3 for ; Sat, 1 Feb 2020 16:59:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 47E29206E3 for ; Sat, 1 Feb 2020 16:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726909AbgBAQ6V (ORCPT ); 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. >