Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp932812ybp; Thu, 17 Oct 2019 05:49:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeU8037dvmP33DGHZ3rPAITImYhO8cczlCdzI3IL3IHVNOsv2D8CAKvfgutqEvbkWCz6aq X-Received: by 2002:a17:906:2961:: with SMTP id x1mr3264179ejd.91.1571316558200; Thu, 17 Oct 2019 05:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571316558; cv=none; d=google.com; s=arc-20160816; b=cJqJzNotvA9ZK5qv2dggpW1sx5YWUghbFUsMHMb+O7V7OSY3PqeAVX9nDu3yOjtm9U N4+lWpFkDgelaV5RYWzNnXJPy93R9GkfbZskUe423VQIRG8stgAUF7U6aRYrALbTW+Ew rCID7C30NXSncip3N4+0+yckGjozPmjWileVNRMbQDegrBARIMk6UxdgJ3O8ioceim8x qLpNEtkiXx6UWhMd+Pr2Mg4DakadUJ/Un9lGXGftDsrpL9fp429tf+ZKAmaJF/lO0ikZ /YANv2ePq0Ps1D4c+wbJDRjravK9MhPHhXKmFuUlGNJrxOux1kvY7bkuq8C5vvtqADgo n1Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=wz+YbVd3hsT0VZERAIR8PSomZWodKeCHq1MnZ7MNtxI=; b=J+NyB3eUNJjNaTAcB8ZTjRoti/9oAfXLE30W6eFzwGLtdXYGymzEcMvAf3FY8aJt/+ 0SDKhGKwai8xPcwdXduceZ9DPBUwsCruOHO0QoSx4n5Mf6ZzuA002lHQsPg5YKmhCRAF /ZQazne4ezHDFaIxhJQEWeciDbFiY5ucLET99lnFBx0MVPSRObbb4/pYnjAhpfuuUG4/ lHe0KY/9XiuAQNIBfCBaplSTLxNMhEvXIDfHQ9YDvsSt33r4/n7DlGUQv6UHABuwGNFj fVyvXvKu6lfhzx6dDg8lx7NFBGM8BEJmVpZv9Kri1aA3pwPp2viExl0pYMMni9B4px3K AVMg== 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 u6si1393809eds.173.2019.10.17.05.48.55; Thu, 17 Oct 2019 05:49:18 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390468AbfJPRmC (ORCPT + 99 others); Wed, 16 Oct 2019 13:42:02 -0400 Received: from mga17.intel.com ([192.55.52.151]:59198 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389196AbfJPRmC (ORCPT ); Wed, 16 Oct 2019 13:42:02 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 10:42:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,304,1566889200"; d="scan'208";a="279606123" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by orsmga001.jf.intel.com with ESMTP; 16 Oct 2019 10:42:00 -0700 Date: Wed, 16 Oct 2019 10:42:00 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Xiaoyao Li , Thomas Gleixner , 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 Subject: Re: [PATCH v9 09/17] x86/split_lock: Handle #AC exception for split lock Message-ID: <20191016174200.GF5866@linux.intel.com> References: <3ec328dc-2763-9da5-28d6-e28970262c58@redhat.com> <57f40083-9063-5d41-f06d-fa1ae4c78ec6@redhat.com> <3a12810b-1196-b70a-aa2e-9fe17dc7341a@redhat.com> <20191016154116.GA5866@linux.intel.com> <20191016162337.GC5866@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191016162337.GC5866@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 16, 2019 at 09:23:37AM -0700, Sean Christopherson wrote: > On Wed, Oct 16, 2019 at 05:43:53PM +0200, Paolo Bonzini wrote: > > On 16/10/19 17:41, Sean Christopherson wrote: > > > On Wed, Oct 16, 2019 at 04:08:14PM +0200, Paolo Bonzini wrote: > > >> 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. > > > > > > Alternatively, for guests without split-lock #AC enabled, what if KVM were > > > to emulate the faulting instruction with split-lock detection temporarily > > > disabled? > > > > Yes we can get fancy, but remember that KVM is not yet supporting > > emulation of locked instructions. Adding it is possible but shouldn't > > be in the critical path for the whole feature. > > Ah, didn't realize that. I'm surprised emulating all locks with cmpxchg > doesn't cause problems (or am I misreading the code?). Assuming I'm > reading the code correctly, the #AC path could kick all other vCPUS on > emulation failure and then retry emulation to "guarantee" success. Though > that's starting to build quite the house of cards. Ugh, doesn't the existing emulation behavior create another KVM issue? KVM uses a locked cmpxchg in emulator_cmpxchg_emulated() and the address is guest controlled, e.g. a guest could coerce the host into disabling split-lock detection via the host's #AC handler by triggering emulation and inducing an #AC in the emulator. > > How would you disable split-lock detection temporarily? Just tweak > > MSR_TEST_CTRL for the time of running the one instruction, and cross > > fingers that the sibling doesn't notice? > > Tweak MSR_TEST_CTRL, with logic to handle the scenario where split-lock > detection is globally disable during emulation (so KVM doesn't > inadvertantly re-enable it). > > There isn't much for the sibling to notice. The kernel would temporarily > allow split-locks on the sibling, but that's a performance issue and isn't > directly fatal. A missed #AC in the host kernel would only delay the > inevitable global disabling of split-lock. A missed #AC in userspace would > again just delay the inevitable SIGBUS.