Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp267639pxx; Thu, 29 Oct 2020 02:02:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/1AgrpM6gupy9wpSLie10bE86KGLU5ELG3dfg7oO+oY2bjOcpfNvpxf65EYTZebQqMXiO X-Received: by 2002:a17:906:4811:: with SMTP id w17mr2873702ejq.431.1603962135588; Thu, 29 Oct 2020 02:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603962135; cv=none; d=google.com; s=arc-20160816; b=InKHpKXy5D98pf8Y3lU3F3zC4bXvXqSMoC/dVvymsa1GK9bgfzZ7lyvkYjNbELPBSp P0vouKOAc+Mc6C8oTD/GvzmxOp7AyDGvBEotmgHfDjAgkTYP69fhL0GWVSL/Q8BWYY2K nQDcbplwYYz5PH4ktUJFflT1rhph1SMNl+w+e5UL/X4Oeet+utRyAuD72XR6dmRdO9Te O+maDHEDG2xvR/tLVWKJNSePbN38YK46jaaBROvQqpt09uUFbf7ybdtdzYr3w9s5jJRe YAZRI/FNs5ok8sBFbaRPgg2yzSbKbzG44bRZGaAePLsfvIJACBUfYr8WlI2fcC6I+GJh AeJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=D0RG6XCsiYk3Hov12UB1Ls79tsmNIPNALmBWI6I8Qe0=; b=vTWArMX0561h56MdG45InUwGK7gAZCJ/ze+WifdjXTpa+OplsM0AaO082iaE0N+5bH cIlgfOQqmAklB5JgnF3ywzJNO+Je1bfclMcAy3DeHbM922qfeify2gdaxqBsLRpGlqHv wPUuTNSmypstZ7XSUx140kdtcMpR/B8euqgOqQ+/4uPqAeMbnGSds0J4+SZQEYU16xAH ZdQA8Lm2rE+WLiaNNLudEMebQzzQ+D6h6ljh8Z2/xGfrUmHuZtRnO8dgYeugvzPcHXaV WXDVlJjXZOfcduD86qnftJy/xrmyUta5NLOndxUw+4W65rKbDzlPHzZyPXBS2GBnAbFf kymg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qh8nc7in; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz6si548111ejb.116.2020.10.29.02.01.53; Thu, 29 Oct 2020 02:02:15 -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=@google.com header.s=20161025 header.b=qh8nc7in; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730264AbgJ2HkY (ORCPT + 99 others); Thu, 29 Oct 2020 03:40:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727566AbgJ2HYv (ORCPT ); Thu, 29 Oct 2020 03:24:51 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD098C08E81A for ; Wed, 28 Oct 2020 23:51:54 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id b25so1750626ybj.2 for ; Wed, 28 Oct 2020 23:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=D0RG6XCsiYk3Hov12UB1Ls79tsmNIPNALmBWI6I8Qe0=; b=qh8nc7inquFnCZ1Gl+JJNsIMjS5CH78e+QQXwZNY+cPKUHEiXtycFZ0CFtimd8zYCG Amr92TjpnzexbaTLGJft6X2m4Nuwr+fWmwBS0URNtMy6WUz0iS6epHvM/4LP1fLoRRAH 33kdoDqgQQneOIDrhKCztqDz0revwKmhBAm37QdYLaClLZhrD/9Qxi1YSWS7U85J/kbJ V6duXsFjEeTyc36s+8tRF00xM/Y3/M9XkTGr9BPhdw0WFZdWUsGZyI2diFfRel48fLPE 0U0JHOnqT+XNWleskOVhe299dCMDba1YWTiuuiSRYE4AVqipNk/OFSKpMH6f5BVkzrZw QR3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=D0RG6XCsiYk3Hov12UB1Ls79tsmNIPNALmBWI6I8Qe0=; b=VnTT79QruQ1MQIIsktryutdKrZ8FUnvF/0VXLOtW0Mo+Go7UsifbsQgjhWGnCAh6Qq 1yv/obsFiGaiDaFJI3wI6wxt/N4m+AN5ifIrY5RPX4Z8q2suUcqJV4bB+Ay29cmFZrfR dSRi72RsIzolPfnWe1+868xCcpHcotey95ZPzyXX1JymwbiDGwtBggRL4uc8zE0F2WPi C5dSzjQQAAmQzjNzug9b0WVyxhsLr2fY5WbDc/Z9bGXdkIV2b0DEzvxLehEQ3UW7ab0q GepqUVQ4564qBIwrRO+FbGZTlLKFCsZXQpC6OUOpDrBydCJ1Yz0g+SvBHWpHFxa3YeW5 dIjw== X-Gm-Message-State: AOAM530MtdJeLxQbM12LWDwozqa86mkJXqrE1J2QuPL2i0B8MeD1G/EU FVpitP6fIdQ8SZPqVROkOQzeGyizRzhZ Sender: "amistry via sendgmr" X-Received: from nandos.syd.corp.google.com ([2401:fa00:9:14:725a:fff:fe46:72ab]) (user=amistry job=sendgmr) by 2002:a5b:e89:: with SMTP id z9mr3926538ybr.44.1603954313929; Wed, 28 Oct 2020 23:51:53 -0700 (PDT) Date: Thu, 29 Oct 2020 17:51:32 +1100 Message-Id: <20201029065133.3027749-1-amistry@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH 0/1] x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP From: Anand K Mistry To: x86@kernel.org, linux-kernel@kernel.org Cc: Thomas.Lendacky@amd.com, joelaf@google.com, asteinhauser@google.com, tglx@linutronix.de, Anand K Mistry , Borislav Petkov , "H. Peter Anvin" , Ingo Molnar , Josh Poimboeuf , Mark Gross , Mike Rapoport , Pawan Gupta , Tony Luck , Vineela Tummalapalli , Waiman Long , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When attempting to do some performance testing of IBPB on and AMD platform, I noticed the IBPB instruction was never being issued, even though it was conditionally on and various seccomp protected processes were force enabling it. Turns out, on those AMD CPUs, STIBP is set to always-on and this was causing an early-out on the prctl() which turns off IB speculation. Here is my attempt to fix it. I'm hoping someone that understands this better than me can explain why I'm wrong. Anand K Mistry (1): x86/speculation: Allow IBPB to be conditionally enabled on CPUs with always-on STIBP arch/x86/kernel/cpu/bugs.c | 41 +++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) -- 2.29.1.341.ge80a0c044ae-goog