Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1581556pxa; Thu, 20 Aug 2020 15:17:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjoqtDErlbo10yzQXPKe1tIcRJKFBhfVUk8wuXEoFkwwfoRC0cMCh2BC65yCu+yxwVZ//I X-Received: by 2002:a05:6402:17a1:: with SMTP id j1mr26273edy.99.1597961834193; Thu, 20 Aug 2020 15:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597961834; cv=none; d=google.com; s=arc-20160816; b=arSFhyj6F/atLNBQQ7XVHJz73a1UaLdbDMPTNrQLhYVAOiumG7D+jxYijz6u/j1zXh 7hQ2py7drnoACsB9BamllzX4RnOyN6EbSgE7n/+jMua+OR9OQpeHSV+47QUpU2BDonl6 GVK27WuDYV8sIqM8YZdRyBhQOnCHAyhffMUBa6RhfqqP1NthAH+pEBkGdRNg+E2+SJDX alnWW7SduNL3kW7Oyv0EwJbn7myNW/ZpHWt+OQqVxcttxI3KQE0mzGy75pL0yug/mxRy wEIvUIDsXd0h0doUuIw09JVjGLRhkqYIQEJdhtO2cxM3kkYhAcvRkvBSNbO5PHdXNr0w jYwA== 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=NWCm6/OSRnAEXX8XSVLfN7CzCQ+KASwOY8m6Bp+d55o=; b=rIB5Bl8KFzTSJYhQkboQszYSjLTQKqRgiryfdYxUnlnAxdiELROHtJR8fc691YtvtS 48D+rDlynRjcuBxK/NMW7veg4/wMmDccXpu/3IUfrwXmT46AAjXDS+Nv3Gtsh5e1LiIE ZYdZBVJg+Ak8zbs3URJ/pujmpBmSiLgHpYdAMxRZTncvW7aPijrKiXZ/aViyWkJlM7/C i+MzgE10jVhfIKKb0x2dQq5MqOOrEnfU5et1Y+ON9LQLm6STh5acRtTXyTKFTxUGAxMW kfqsSlhEtCfIIEexmE1tEqxIrlNqYV/IKhYyiSqDNiqM2at5oDGuEu4iJ4O5yMr2CX3m DESA== 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 a3si2212935edk.48.2020.08.20.15.16.50; Thu, 20 Aug 2020 15:17:14 -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 S1727104AbgHTWFL (ORCPT + 99 others); Thu, 20 Aug 2020 18:05:11 -0400 Received: from mga18.intel.com ([134.134.136.126]:17228 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726792AbgHTWFK (ORCPT ); Thu, 20 Aug 2020 18:05:10 -0400 IronPort-SDR: vtX/XxUMpqeeyVcuraCdfVlnkwd5O7FTDMw1zhDscFj7/XcKIW4wMXF/v6xegtQtAJiTywGzFq KgyeKPLPArxA== X-IronPort-AV: E=McAfee;i="6000,8403,9719"; a="143047686" X-IronPort-AV: E=Sophos;i="5.76,334,1592895600"; d="scan'208";a="143047686" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 15:05:09 -0700 IronPort-SDR: wqdYLbs6WfnHGQlxHSYr2Jg9454YjHMiEFCTxA7D6/yVDL0AYR5JCfd+obUu/2HaUKjpABmH0a GswPQFAqq4jA== X-IronPort-AV: E=Sophos;i="5.76,334,1592895600"; d="scan'208";a="498305073" Received: from sjchrist-ice.jf.intel.com (HELO sjchrist-ice) ([10.54.31.34]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 15:05:08 -0700 Date: Thu, 20 Aug 2020 15:05:07 -0700 From: Sean Christopherson To: Andy Lutomirski Cc: Tom Lendacky , Dave Hansen , Jim Mattson , Andy Lutomirski , 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: <20200820220507.GA10269@sjchrist-ice> References: <5756198D-C8BD-4290-BFCA-04424EB230A6@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5756198D-C8BD-4290-BFCA-04424EB230A6@amacapital.net> 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 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.