Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1582978pxa; Thu, 20 Aug 2020 15:19:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF1ivFmkCEeyPX6UnFNXUFUtJDO2bBwd9FFD76EkJZlp8sSFFmWNfabNL/M9VbiQbhgLJl X-Received: by 2002:a17:906:300b:: with SMTP id 11mr64939ejz.270.1597961992393; Thu, 20 Aug 2020 15:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597961992; cv=none; d=google.com; s=arc-20160816; b=MsANmcHAH/wLTQUcClKxftRe42sNWyl59E1rM0IKtYvW/jvyv7PyaNbnyDwr3u73/a Vg5AdkJ571+M4rK/7Ag6w5LGVfZwxN3KYjsjTzdfYbNZ7zOrrKieJJI6HTAsa29Rj4zU TLUWZNKTvJ38rorHoCTAnny3wejUWg9aiEEZbkNDTW9d9CSBIiNhvVODIw/KX9qYhtFz NO35SPyrKqmc1DcfJB5+0UJEJ76PIJT8gnSBb1dyHcnxNBbsA0M6Gq0wZsDRBTDGGw8R 34HKJcWTHOpyVuXbRTHbVwtQYMdIaIPTcWiMoRFkQWiAhIGatmTomYSlkxjSZYFm1ULn WSpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=gfOupM0I85NAp8pxQ9lOEM+j2w7Bg5lcy0AHtng6FWA=; b=qTAocz72IgC8F3BXYSU3BgWt8Qz3MSUr5Jvwi4Ch3tgU4qp5Ut3Av1JIJ7gHC5nD80 wfAdeGKkicYfoCcjfHKeY0M9yk1gq424rIeoLcivjfNDbNQRLZlUvQFEwWAMHgzekwVm pRjqFTehSHvZNxaSBh0TrsLNnxiWG7CHhy3m85y5uejBhNjDuJXhKjCBYOfaqlflIVN0 Z1joo3efHS58/+wifQfKjcFbMlobkGXw7JbGMTyC8v+o1u4DLJj8F4IKyBjDiHG4iXlF bep0ZThpsFo/4DcM6PGQm5Ta5ywkQIGmIiFaOH7732mV/dGdziBFG2xY/xtn+pT5uhWb WHnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E8A9sbce; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q26si2193036edw.453.2020.08.20.15.19.27; Thu, 20 Aug 2020 15:19: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; dkim=pass header.i=@kernel.org header.s=default header.b=E8A9sbce; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728003AbgHTWH2 (ORCPT + 99 others); Thu, 20 Aug 2020 18:07:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:55270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726873AbgHTWHZ (ORCPT ); Thu, 20 Aug 2020 18:07:25 -0400 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 28C7522B49 for ; Thu, 20 Aug 2020 22:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597961244; bh=ttNYwH6YbdhiYjcE2D1IEfBaxfAxVirTGok7UtytaN8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=E8A9sbce8kF0eaLbRUesAeQpu2EMPJrdcpPL7fv2BFq5aVseBQ634FgjPr5VQDVfH sTTcle/fb5XH4vEC0dh6cdepoTMX1ex3THXLO7ZXncsxMelamqPaXcDXIoiaSpS9ZJ LQ6EC7Xxp2R0sxs23ouLtoA9Z/zDkmFHFDnyqzAo= Received: by mail-wm1-f54.google.com with SMTP id p14so120548wmg.1 for ; Thu, 20 Aug 2020 15:07:24 -0700 (PDT) X-Gm-Message-State: AOAM531dLw2nGF34yCZpwR/caYFgLhBDOkh/mGn0H+ema9nFYq1L3mdc LIoSfLu2hzt3Ose6SOB3H+rC/f51iLUYo4ZZSNIZXw== X-Received: by 2002:a1c:de86:: with SMTP id v128mr517196wmg.36.1597961242679; Thu, 20 Aug 2020 15:07:22 -0700 (PDT) MIME-Version: 1.0 References: <5756198D-C8BD-4290-BFCA-04424EB230A6@amacapital.net> <20200820220507.GA10269@sjchrist-ice> In-Reply-To: <20200820220507.GA10269@sjchrist-ice> From: Andy Lutomirski Date: Thu, 20 Aug 2020 15:07:10 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: FSGSBASE causing panic on 5.9-rc1 To: Sean Christopherson 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 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 w= rote: > > > > > > =EF=BB=BFOn 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 crash= ing. > > >>> > > >>> 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 nee= ds to be moved, too. > > > > > > > Depending on how much of a perf hit this is, we could also skip using R= DPID > > in the paranoid path on SVM-capable CPUs. > > Doesn't this affect VMX as well? KVM+VMX doesn't restore TSC_AUX until t= he > 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 mean= s > 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? --Andy