Received: by 10.213.65.68 with SMTP id h4csp188350imn; Wed, 21 Mar 2018 15:59:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELtjtY1nimRHCYq6Ombm0XO0pmFzwG+R8sq6CmkmA0/ZDhNw63+kUZPtGMHzu8qyy/6nH2yg X-Received: by 2002:a17:902:2f81:: with SMTP id t1-v6mr22569156plb.290.1521673142604; Wed, 21 Mar 2018 15:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521673142; cv=none; d=google.com; s=arc-20160816; b=GKcVO4uIOOSBNcApP6K3JYqGyHoAy8frQds5X/vxY5J8RwVTugCooulSANv/enlS9C V/rHiTR71em0DSsOcD0whMIJUr1ZFXXNbR39hTtMem0y3doJzyQrRSueyylLKW79KloU LKYSc6T+mxyvegPzokaJmM8goP6YedoYegKXQ4H99N3DZW9CZyDRS06coH0OBpvMJo01 ZrlaYfYchOwiDJBtpgZjJLawMbLc/xddmEAy4UY2wuLz7qSAVDHl7A6LlPkn/YK9tJJg CURYRLCLicLMbPygeMJNjh58pkihpjfQHPG3I+PooojmkNKCk7wrp8eRhumzQqa1X74w uSWA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=QmOdA8V0lApzK2mxmy/VZAgrmeV2vZaVXVe+ML5yH/s=; b=wahqcNVEaIr/33eZ3NdebmHVH2487j0Wyy69zqC7Rym8rPyZ0zktIRNKNa1okzvd6p goaM8KLFNhswfeZju8ltKgZhaMvOJTWESCHwBz0ri/uW26gwHmxmAsVFP/rHPqaw9cwa 5sRXyznL3C+Tp/W7HLnhe5iLq/llP8EeHBlLAohRuqEDTsymZrTCiaaIT0SwfiEGKGtD ZrjnkaLefftAxsrKp3xKTKv+gL42tpF2ceUNWSIxDJi9k7BTgtS6LL0xtM1caGc5yndI nnRz/BcCet8CSmhKeyNx9Hqp470U8X9DXeacu0Qj9a4Kl4e12nf/TdEWI2INRzP6T/7a VEYQ== 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 z62si3733628pfb.305.2018.03.21.15.58.47; Wed, 21 Mar 2018 15:59:02 -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 S1754138AbeCUW5R (ORCPT + 99 others); Wed, 21 Mar 2018 18:57:17 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:53862 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753715AbeCUW5Q (ORCPT ); Wed, 21 Mar 2018 18:57:16 -0400 Received: by vps-vb.mhejs.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1eymfJ-0005Uo-HS; Wed, 21 Mar 2018 23:57:05 +0100 Subject: Re: [PATCH] x86/speculation: Fill the RSB on context switch also on non-IBPB CPUs To: Dave Hansen Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , David Woodhouse , KarimAllah Ahmed , Andi Kleen , Tim Chen , thomas.lendacky@amd.com, x86@kernel.org, linux-kernel@vger.kernel.org References: <9eb945bd-f77e-0301-d977-d1acf931b19d@maciej.szmigiero.name> From: "Maciej S. Szmigiero" Message-ID: Date: Wed, 21 Mar 2018 23:57:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=US-ASCII Content-Language: en-US Content-Transfer-Encoding: 7BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21.03.2018 15:05, Dave Hansen wrote: > On 03/20/2018 04:17 AM, Maciej S. Szmigiero wrote: >> If we run on a CPU that does not have IBPB support RSB entries from one >> userspace process can influence 'ret' target prediction in another >> userspace process after a context switch. >> >> Since it is unlikely that existing RSB entries from the previous task match >> the new task call stack we can use the existing unconditional >> RSB-filling-on-context-switch infrastructure to protect against such >> userspace-to-userspace attacks. >> >> This patch brings a change in behavior only for the following CPU types: >> * Intel pre-Skylake CPUs without updated microcode, > > The assumption thus far (good or bad) is that everything will get a > microcode update. I actually don't know for sure if RSB manipulation is > effective on old microcode before Skylake. I'm pretty sure it has not > been documented publicly. > > How did you decide that this is an effective mitigation? > A RSB overwrite is already being done even on pre-Skylake Intel CPUs on VMEXIT to protect the host from the guest, regardless of the microcode version. But I see that an Intel guidance document published last month about retpolines says that "RET has this [predictable speculative] behavior on all processors (...) microarchitecture codename Broadwell and earlier when updated with the latest microcode". This suggests that updated microcode may be needed for protection anyway on such CPUs - as you say. Such update (hopefully) brings IBPB support, too, so I agree that the change introduced by this patch can be skipped on Intel CPUs. Maciej