Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1593061pxa; Thu, 20 Aug 2020 15:37:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwToNeqA+VBclH3K2dBCAK/nCaJckwAgYtexzr3iNVI7aaKayOH+WOTieOt4vfnD6E+D4Dz X-Received: by 2002:a50:8d01:: with SMTP id s1mr77215eds.225.1597963041116; Thu, 20 Aug 2020 15:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597963041; cv=none; d=google.com; s=arc-20160816; b=q5BWVpPZLM9lmJtOY2PL2m+XCZujIwQgE9BHRzejaER6zS0/tj5okMaZPCqCQX/Tl1 v0dHpzdYnv9c9UDPxYDEaPnhlp1Se7dr+Bx5y9S31eD8SYx2oxHBhEWq3ne3xG1Y8fZ7 a6SoORYBbdDCCTzmf/arFVc3ak5fQpglTEIq/xTMgo3esefPDwaicP52Msd7WNk1TvKB Volwgz2gqxL954vyDg66dWe0pgtBv0171sdhWDX4DBqreb3Hv22gHyTg5CfGHvq5uRGi QSqwAiljRV1ebGntQ9nVWuc9PwpD/uTy0qqY1sGbn7/vW8blAZc3G680Z7YF+ZrZd7N9 MYng== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=gocgP9XiBrG9HDOPkEp3dbXLn8iYziFeRk7r3lYA3ik=; b=rS5bu+B7xYJQ7YbzzyO8NiJJY+fJVNV8f2/6nCu1cIGoDKRuAe8ebroLPeQDzX+9wS k9jS5BQAJXuxEhXd6MSMOteJi4nfhLDKW/jNiT1K/+q59dHLRcjk2OW1057rUxb2bbME j7FRFKfiYFxt86AcguH480AJV+sazju1i3DNmNq7WmVgzWajfBhBdmWilNGz0Ew0E4tM T6r8U5ufh+48i2zifJV1rP+pw1bgUwyKtnI0ah+Mlv3k0937kEpILMQJyYlTlHkqAIso g0QHBd9q3/1YgMxMaPHU2YLBSrfpeLs+Q28uRwefoZBcuznjVe4AOjvTGqF7CwfXdKMI COzw== 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 s3si2296128edy.554.2020.08.20.15.36.55; Thu, 20 Aug 2020 15:37:21 -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 S1728139AbgHTWef (ORCPT + 99 others); Thu, 20 Aug 2020 18:34:35 -0400 Received: from mga09.intel.com ([134.134.136.24]:13363 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726666AbgHTWee (ORCPT ); Thu, 20 Aug 2020 18:34:34 -0400 IronPort-SDR: hBjZ9GT3i0px5RDw5DDaDm54NjgS6Tmih0X8AydHbWKAcIRLdry2+RPAPoCM8BHzKGWgfWwYPs NzA8hioo9yTw== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="156473935" X-IronPort-AV: E=Sophos;i="5.76,334,1592895600"; d="scan'208";a="156473935" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 15:34:34 -0700 IronPort-SDR: M9a8VIwmIYg9vmlw98pQBFNG63T5/n3EcIMbTlXje/QT7KcRQxs6jbVFMv80HTw62qbuClWvb/ 5GI5Kra5fi8w== X-IronPort-AV: E=Sophos;i="5.76,334,1592895600"; d="scan'208";a="321053505" Received: from sjchrist-ice.jf.intel.com (HELO sjchrist-ice) ([10.54.31.34]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 15:34:33 -0700 Date: Thu, 20 Aug 2020 15:34:31 -0700 From: Sean Christopherson To: Andy Lutomirski Cc: Tom Lendacky , Dave Hansen , Jim Mattson , Joerg Roedel , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Linux Kernel Mailing List , X86 ML , "Chang S. Bae" , Thomas Gleixner , Sasha Levin , Borislav Petkov , Peter Zijlstra , Ingo Molnar Subject: Re: FSGSBASE causing panic on 5.9-rc1 Message-ID: <20200820223431.GB10269@sjchrist-ice> References: <5756198D-C8BD-4290-BFCA-04424EB230A6@amacapital.net> <20200820220507.GA10269@sjchrist-ice> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 20, 2020 at 03:07:10PM -0700, Andy Lutomirski wrote: > On Thu, Aug 20, 2020 at 3:05 PM Sean Christopherson > wrote: > > > > On Thu, Aug 20, 2020 at 01:36:46PM -0700, Andy Lutomirski wrote: > > > > > > > > > > On Aug 20, 2020, at 1:15 PM, Tom Lendacky wrote: > > > > > > > > On 8/20/20 3:07 PM, Dave Hansen wrote: > > > >> On 8/20/20 12:05 PM, Tom Lendacky wrote: > > > >>>> I added a quick hack to save TSC_AUX to a new variable in the SVM > > > >>>> struct and then restore it right after VMEXIT (just after where GS is > > > >>>> restored in svm_vcpu_enter_exit()) and my guest is no longer crashing. > > > >>> > > > >>> Sorry, I mean my host is no longer crashing. > > > >> Just to make sure I've got this: > > > >> 1. Older CPUs didn't have X86_FEATURE_RDPID > > > >> 2. FSGSBASE patches started using RDPID in the NMI entry path when > > > >> supported *AND* FSGSBASE was enabled > > > >> 3. There was a latent SVM bug which did not restore the RDPID data > > > >> before NMIs were reenabled after VMEXIT > > > >> 4. If an NMI comes in the window between VMEXIT and the > > > >> wrmsr(TSC_AUX)... boom > > > > > > > > Right, which means that the setting of TSC_AUX to the guest value needs to be moved, too. > > > > > > > > > > Depending on how much of a perf hit this is, we could also skip using RDPID > > > in the paranoid path on SVM-capable CPUs. > > > > Doesn't this affect VMX as well? KVM+VMX doesn't restore TSC_AUX until the > > kernel returns to userspace. I don't see anything that prevents the NMI > > RDPID path from affecting Intel CPUs. > > > > Assuming that's the case, I would strongly prefer this be handled in the > > paranoid path. NMIs are unblocked immediately on VMX VM-Exit, which means > > using the MSR load lists in the VMCS, and I hate those with a vengeance. > > > > Perf overhead on VMX would be 8-10% for VM-Exits that would normally stay > > in KVM's run loop, e.g. ~125 cycles for the WMRSR, ~1300-1500 cycles to > > handle the most common VM-Exits. It'd be even higher overhead for the > > VMX preemption timer, which is handled without even enabling IRQs and is > > a hot path as it's used to emulate the TSC deadline timer for the guest. > > I'm fine with that -- let's get rid of RDPID unconditionally in the > paranoid path. Want to send a patch that also adds as comment > explaining why we're not using RDPID? Sure, though I won't object if Tom beats me to the punch :-)