Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5763386imm; Mon, 23 Jul 2018 05:47:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcPrFLheeUM6GK4tejMpjtdC1bd7WMFVqzu/aHh9BlwFJuEeX6Z4LRleXBX10LxYreH3p71 X-Received: by 2002:a63:161a:: with SMTP id w26-v6mr12375842pgl.257.1532350029307; Mon, 23 Jul 2018 05:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532350029; cv=none; d=google.com; s=arc-20160816; b=sv5NQpLQuC+20jTr8YU29zpixRKi/UcB8rGiU+a4vF6uS/AONvkV/BGSPqxkJ5UR3L nXmS6wQBWJu9kmbLCJMDS5YTqFYvh0/ZRuyLdA6mrS7rhqI6DVRqufL+3QAw0Wc1kT7Y SL426Kiba2+NsjoaAgHfKzi4FwKPLuzprfxeq97rOtyo60chSMVnodOKQEmrR5bdOYgp DA0ARr1WBlbe2vLflxhTYR6uB7pN34FewL+iusZM40+Qy6LS23k/fypdT2Au6pS3FZjx qwnf+DAdg+qHjzv6l1QhA3oKu89FwoDXu+pKsEuD1yCXz3iirmkN8D1wP9FflhETh18i Ji2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=I6qVjHSxZ2bIrGCOSlcIQFd58sIY/Wr0XU9kbAlbm9k=; b=YXDg1q6jzBFzQ+aeimidsZEZe7pMTg1BWYa+mrkGOT/aGbk+hcCo4ypwRqPxCJPi8k 9byWBz01FR3g7xjEd0AJpzRkA8SQw/xbVrgt/bG1vd7WYluijwGVK7xf8AbaBpsE4Y0l Nzm1NfrH98AgPImQvtMgXPOqgssDBZdaojXEwOXHbihiGwb0kbd97s5QXAcPuJ0ZPkk5 Af4cskhpYPBzU+V6qRuiW3IKlgfQM+yiFvG6LVtWHdr+Co9BlAjWfnEiNLFhjH+70+SZ t2qe9T7BfSyg+EYJSV2CwoGB1iB2SgALwBJFThbQO9IZt5eWCGgR8+8tRz/inXSyXBu6 l6LQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 17-v6si7466312pgp.289.2018.07.23.05.46.54; Mon, 23 Jul 2018 05:47:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388606AbeGWNqD (ORCPT + 99 others); Mon, 23 Jul 2018 09:46:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49958 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388102AbeGWNqD (ORCPT ); Mon, 23 Jul 2018 09:46:03 -0400 Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8E609C18; Mon, 23 Jul 2018 12:44:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Boris Ostrovsky , Thomas Gleixner , David Woodhouse , "Srivatsa S. Bhat" , "Matt Helsley (VMware)" , Alexey Makhalov , Bo Gan Subject: [PATCH 4.4 047/107] x86/amd: dont set X86_BUG_SYSRET_SS_ATTRS when running under Xen Date: Mon, 23 Jul 2018 14:41:41 +0200 Message-Id: <20180723122415.243662310@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Woodhouse commit def9331a12977770cc6132d79f8e6565871e8e38 upstream When running as Xen pv guest X86_BUG_SYSRET_SS_ATTRS must not be set on AMD cpus. This bug/feature bit is kind of special as it will be used very early when switching threads. Setting the bit and clearing it a little bit later leaves a critical window where things can go wrong. This time window has enlarged a little bit by using setup_clear_cpu_cap() instead of the hypervisor's set_cpu_features callback. It seems this larger window now makes it rather easy to hit the problem. The proper solution is to never set the bit in case of Xen. Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Acked-by: Thomas Gleixner Signed-off-by: Juergen Gross Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman Signed-off-by: Srivatsa S. Bhat Reviewed-by: Matt Helsley (VMware) Reviewed-by: Alexey Makhalov Reviewed-by: Bo Gan Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/amd.c | 5 +++-- arch/x86/xen/enlighten.c | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -791,8 +791,9 @@ static void init_amd(struct cpuinfo_x86 if (cpu_has(c, X86_FEATURE_3DNOW) || cpu_has(c, X86_FEATURE_LM)) set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH); - /* AMD CPUs don't reset SS attributes on SYSRET */ - set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS); + /* AMD CPUs don't reset SS attributes on SYSRET, Xen does. */ + if (!cpu_has(c, X86_FEATURE_XENPV)) + set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS); } #ifdef CONFIG_X86_32 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -462,10 +462,8 @@ static void __init xen_init_cpuid_mask(v static void __init xen_init_capabilities(void) { - if (xen_pv_domain()) { - setup_clear_cpu_cap(X86_BUG_SYSRET_SS_ATTRS); + if (xen_pv_domain()) setup_force_cpu_cap(X86_FEATURE_XENPV); - } } static void xen_set_debugreg(int reg, unsigned long val)