Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4605567ybg; Mon, 8 Jun 2020 12:03:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMSQbTw0Sp42X2asac4/NdZY11mOnrEQktGJJfF/V2JTbHz2Nd1EcquXZCiMnSfJng3HVs X-Received: by 2002:a50:eb0a:: with SMTP id y10mr23544001edp.312.1591643032244; Mon, 08 Jun 2020 12:03:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591643032; cv=none; d=google.com; s=arc-20160816; b=VxNcL3m6TEYoOkJUBvh+Yhsp9Vem+X0b9fVp1oeomzh7HJwe+lgswmOdXY9DnOi4gZ nCwm0QYNGclsMdhk6tO4UgswU+lwBc3QjrR5uQfD1fHxSejhWTfEfJqC+jG78mt4GYkC 7oYo2HCM2lYetEerMI2kkI3MRaSShYn6nh98hWxB9dDuT79g+ePDyPKWgiEuKz7Y8mXO s8CUnjdcIjco5wn1Ol9JItYINEWXPqhREv6OqoqP2OzPgwwENTmE4r+I8tc7g9XThDl5 CLhlLJZGV6V8vo7ACXh68gSAgbJfXQixfjLwb+B4H/JpQ48lw+3TrkN70tgCH4AJuk4f wBMw== 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:ironport-sdr:ironport-sdr; bh=lEpv3K4a7NjIMwWa4JaibE1OaYtUPyFEkEak0EorrIw=; b=Bp9kwv6pPnvGe5SPvfu9gPl86WKcRKxlxPLqEzeg0nJdYHzywth+5MvGu6t47Z53pR AZOBhGsv2o0GLpWsBNtSuueq6fWNc8WSb8k2Yyy4PsDcgRPLJgl61mTZpKSoE5xIoS/L pv/7LmtAoFWzJ65wMYL/zegp8eFFaEalkIEkevxS/FHXcTCuwXXmPfhTngBpuWngMVYo CvtovcTbyIwi8U0SHH2NM+eMZ5T2kCHIwZ6IL0NFtpv785t7N4nIv7xS72cZqbnxvRA6 aSs22GBkWEu+8iGLjiV3IH9Q+O3IdgJfzvQ9HvEq4ZGUqaLHPab28CW6GK/jjM0jhG5e 0mMA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si8004454eje.741.2020.06.08.12.03.29; Mon, 08 Jun 2020 12:03:52 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726481AbgFHTBH (ORCPT + 99 others); Mon, 8 Jun 2020 15:01:07 -0400 Received: from mga04.intel.com ([192.55.52.120]:18317 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbgFHTBH (ORCPT ); Mon, 8 Jun 2020 15:01:07 -0400 IronPort-SDR: QEuyRz/g42TmCN0XKxAqGRn6ALE/MF+l7ZMWlo8Bj/ZMwP03qN4f2KPkaN9/0rnLOLO03VQHT2 atlxBKK1M0VQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 12:01:06 -0700 IronPort-SDR: EQlxERhkzHD1JWLiTMmnAgcga9oyo0n2vZwirSbiHiIuANHm8GKEBz++5+m0pbH0cLmmD5ywF9 b4wrwTttcb2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,487,1583222400"; d="scan'208";a="306032234" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by orsmga008.jf.intel.com with ESMTP; 08 Jun 2020 12:01:05 -0700 Date: Mon, 8 Jun 2020 12:01:05 -0700 From: Sean Christopherson To: Xiaoyao Li Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Paolo Bonzini , kvm@vger.kernel.org Subject: Re: [PATCH] x86/split_lock: Don't write MSR_TEST_CTRL on CPUs that aren't whitelisted Message-ID: <20200608190105.GE8223@linux.intel.com> References: <20200605192605.7439-1-sean.j.christopherson@intel.com> <985fb434-523d-3fa0-072c-c039d532bbb0@intel.com> <20200607170646.GD24576@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200607170646.GD24576@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 Sun, Jun 07, 2020 at 10:06:46AM -0700, Sean Christopherson wrote: > On Sat, Jun 06, 2020 at 10:51:06AM +0800, Xiaoyao Li wrote: > > On 6/6/2020 3:26 AM, Sean Christopherson wrote: > > >Choo! Choo! All aboard the Split Lock Express, with direct service to > > >Wreckage! > > > > > >Skip split_lock_verify_msr() if the CPU isn't whitelisted as a possible > > >SLD-enabled CPU model to avoid writing MSR_TEST_CTRL. MSR_TEST_CTRL > > >exists, and is writable, on many generations of CPUs. Writing the MSR, > > >even with '0', can result in bizarre, undocumented behavior. > > > > > >This fixes a crash on Haswell when resuming from suspend with a live KVM > > >guest. Because APs use the standard SMP boot flow for resume, they will > > >go through split_lock_init() and the subsequent RDMSR/WRMSR sequence, > > >which runs even when sld_state==sld_off to ensure SLD is disabled. On > > >Haswell (at least, my Haswell), writing MSR_TEST_CTRL with '0' will > > >succeed and _may_ take the SMT _sibling_ out of VMX root mode. > > > > > >When KVM has an active guest, KVM performs VMXON as part of CPU onlining > > >(see kvm_starting_cpu()). Because SMP boot is serialized, the resulting > > >flow is effectively: > > > > > > on_each_ap_cpu() { > > > WRMSR(MSR_TEST_CTRL, 0) > > > VMXON > > > } > > > > > >As a result, the WRMSR can disable VMX on a different CPU that has > > >already done VMXON. This ultimately results in a #UD on VMPTRLD when > > >KVM regains control and attempt run its vCPUs. > > > > > >The above voodoo was confirmed by reworking KVM's VMXON flow to write > > >MSR_TEST_CTRL prior to VMXON, and to serialize the sequence as above. > > >Further verification of the insanity was done by redoing VMXON on all > > >APs after the initial WRMSR->VMXON sequence. The additional VMXON, > > >which should VM-Fail, occasionally succeeded, and also eliminated the > > >unexpected #UD on VMPTRLD. > > > > > >The damage done by writing MSR_TEST_CTRL doesn't appear to be limited > > >to VMX, e.g. after suspend with an active KVM guest, subsequent reboots > > >almost always hang (even when fudging VMXON), a #UD on a random Jcc was > > >observed, suspend/resume stability is qualitatively poor, and so on and > > >so forth. > > > > > > > I'm wondering if all those side-effects of MSR_TEST_CTRL exist on CPUs have > > SLD feature, have you ever tested on a SLD capable CPU? > > No, I'll poke at it on ICX tomorrow. Tested on ICX with SLD both enabled and disabled by writing MSR_TEST_CTRL on every logical CPU during vCPU creation, no weirdness observed.