Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1315806pxa; Thu, 20 Aug 2020 08:12:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCEO98DHDdrWU25JMYtC1UPqDBAM9QK0CU/Flit4t7JaK7OJ/MoLjSBUDToxpAaXfqM9/h X-Received: by 2002:a05:6402:d07:: with SMTP id eb7mr3501897edb.160.1597936355393; Thu, 20 Aug 2020 08:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597936355; cv=none; d=google.com; s=arc-20160816; b=uaxX15dK/xGofMaBGulC5ellHHWxpqCGUIudHPu86trlmYSP70IDuUBlrofTfMb1/e F5WZVBJJcXOPB5eU+x95a6knXJh1jzAt6gzaZP7pf5ieuqCMataIDTD0khbiT8W2GcQD lv0a8ho3L8+umb1mpR2lXLT4RdC1dwMNXkUWEKmX5/8gOlVdZAIgGCx058bf/huoRrvg KBFr+Yj39xivM4V2ekNPIVS/7E+SNmSTt7zOVoSwVCX2r1irQuk9cuNtJp9AM3Ih2Y5V +fUaaBm/8uVP++/DZkspjXeoq12IX3RWWi0TumvIjVWxP++Pm7n945HYRg5eTCcbjAiR KBHQ== 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=szxq6faJ6bUQm40SvOQ9J3uljuYB/bC4HCCJwGjrIog=; b=S2vVMIKCu2DcInhViQvsPnp90XzEQ1pD+dn/o0qsQqoA1Sdq3lE6nEFEflcswDFjaG NhVZWC1MfP91P1cC5FyFeEr/TYeZzjNazUyg6mM4CHR4Czhdb2OBFtPqmp7fQy9xqEg3 440ryiFH9RFIVK5COEqm2xXuCJtlUJB4/jpBxmmk6pch3cY6Khe5rvIbgTLGhzKc/enl qGLrbdGHFjLQjxzgkE4fKF2m8H7NhaAbOrcM2Z4JC/TFUb2h92sPx1v+wt0h40O7y6of GVrOkxbQ/HUosF8xnwtcF3R1Opw5Zk7lfu4h0GKJBXFEZPuY4a0MQLTzN4KYP8/nf0zM /03g== 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 m4si1390969eja.391.2020.08.20.08.12.11; Thu, 20 Aug 2020 08:12:35 -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 S1728986AbgHTPK5 (ORCPT + 99 others); Thu, 20 Aug 2020 11:10:57 -0400 Received: from mga01.intel.com ([192.55.52.88]:28338 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728838AbgHTPKw (ORCPT ); Thu, 20 Aug 2020 11:10:52 -0400 IronPort-SDR: woeuSBlpk3QMd7oy4u2yleh0UfeWnu6M9UpBRNbQEDUIjQobBcC8tszAdF7PNgxkFwV4aCg3Dc qhFT+7NZhK5w== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="173359450" X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="173359450" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 08:10:51 -0700 IronPort-SDR: UShScWwahsajGm/COqKzOkq2UGVevLxll6rnwhUkImZTCKKbkyY37oiYO8m18VEiAjk3r2ldOr uHh+W7e2AAXQ== X-IronPort-AV: E=Sophos;i="5.76,333,1592895600"; d="scan'208";a="497647253" Received: from sjchrist-ice.jf.intel.com (HELO sjchrist-ice) ([10.54.31.34]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2020 08:10:51 -0700 Date: Thu, 20 Aug 2020 08:10:49 -0700 From: Sean Christopherson To: Andy Lutomirski Cc: Tom Lendacky , Joerg Roedel , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , 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: <20200820151049.GA26595@sjchrist-ice> References: <39d57e4d-5db4-f536-6f5e-6b0414c0dccc@amd.com> <7dedb0ab-56a6-5d96-577b-21ab1ecdad24@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Wed, Aug 19, 2020 at 05:21:33PM -0700, Andy Lutomirski wrote: > On Wed, Aug 19, 2020 at 2:25 PM Andy Lutomirski wrote: > > > > On Wed, Aug 19, 2020 at 11:19 AM Tom Lendacky wrote: > > > > > > On 8/19/20 1:07 PM, Tom Lendacky wrote: > > > > It looks like the FSGSBASE support is crashing my second generation EPYC > > > > system. I was able to bisect it to: > > > > > > > > b745cfba44c1 ("x86/cpu: Enable FSGSBASE on 64bit by default and add a chicken bit") > > > > > > > > The panic only happens when using KVM. Doing kernel builds or stress > > > > on bare-metal appears fine. But if I fire up, in this case, a 64-vCPU > > > > guest and do a kernel build within the guest, I get the following: > > > > > > I should clarify that this panic is on the bare-metal system, not in the > > > guest. And that specifying nofsgsbase on the bare-metal command line fixes > > > the issue. > > > > I certainly see some oddities: > > > > We have this code: > > > > static void svm_vcpu_put(struct kvm_vcpu *vcpu) > > { > > struct vcpu_svm *svm = to_svm(vcpu); > > int i; > > > > avic_vcpu_put(vcpu); > > > > ++vcpu->stat.host_state_reload; > > kvm_load_ldt(svm->host.ldt); > > #ifdef CONFIG_X86_64 > > loadsegment(fs, svm->host.fs); > > wrmsrl(MSR_KERNEL_GS_BASE, current->thread.gsbase); Pretty sure current->thread.gsbase can be stale, i.e. this needs: current_save_fsgs(); wrmsrl(MSR_KERNEL_GS_BASE, current->thread.gsbase); On a related topic, we really should consolidate the VMX and SVM code for these flows, they're both ugly. > > load_gs_index(svm->host.gs); > > > > Surely that should do load_gs_index() *before* wrmsrl(). But that's > > not the problem at hand. > > > > There are also some open-coded rdmsr and wrmsrs of MSR_GS_BASE -- > > surely these should be x86_gsbase_read_cpu() and > > x86_gsbase_write_cpu(). (Those functions don't actually exist, but > > the fsbase equivalents do, and we should add them.) But that's also > > not the problem at hand. > > Make that cpu_kernelmode_gs_base(cpu). Perf win on all CPUs. > > But I still don't see the bug.