From patchwork Wed Nov 21 13:58:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 1001169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 430PLZ21vCz9s3l; Thu, 22 Nov 2018 00:58:46 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gPT1c-0008D2-0i; Wed, 21 Nov 2018 13:58:40 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gPT1a-0008Cd-1e for kernel-team@lists.ubuntu.com; Wed, 21 Nov 2018 13:58:38 +0000 Received: from mail-ed1-f69.google.com ([209.85.208.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gPT1Z-0002fD-QN for kernel-team@lists.ubuntu.com; Wed, 21 Nov 2018 13:58:37 +0000 Received: by mail-ed1-f69.google.com with SMTP id m19so3038483edc.6 for ; Wed, 21 Nov 2018 05:58:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f6cJGotc/xXuBXZqQqKW0nzxQKjK2uW45CtMnSpfhDs=; b=UVhTQ2OTUG8j7bvp5Nxw8I4QUIg7BoGoZXbHNv4XtNnSjOW8ublbGc0ULUfBRJnwTK cvHqSP0l6JTz+b26wgWSvlvMxG6BZsHUyAYKaAgHG4zku/saGRX0RCy4/zv7RWy3VBco mYqQAwJbVKEYFZxasW4N6BdIb98fVVV2F9JUAvkKX4+LoHvlramd4P6G8KsSjWIuNxpB uUJSTeQFlEq1uOb3K7fRS8pu6C2I2b9dC2aed+zp5XutGf6mP3l7dsG5qt8Y6c/wWAH7 pmoy/1G0ccZjhXkTMVwwRZmpteLRARBcEEFF8GvODotUSZvndCwrQV6f/SKDCu6YdULf f7Ow== X-Gm-Message-State: AA+aEWaqY9dcQNQUDWWmxQ1NWY/kiWOIKJXFoTKu62xSSJPeS/pN3+2w Vvl/Dpz9fgdTbQ1AQS8qgs07dFP9ncty7FBce4vdIJZtngchXOCCei8it7BAhY9Xqcw2NgxcjX7 Hxml3QBbI2ANeRkK2DwobeA/DZ33BiHxGPQqhIWqwPQ== X-Received: by 2002:aa7:df07:: with SMTP id c7mr5805044edy.85.1542808717270; Wed, 21 Nov 2018 05:58:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xn2Ue/hagZ3ba9qkKCnRw60nTOwsLL1/aSjMCbp5HzDgnFQjmtU6Z/UmOEuPH89Px2hdq0cw== X-Received: by 2002:aa7:df07:: with SMTP id c7mr5805034edy.85.1542808717022; Wed, 21 Nov 2018 05:58:37 -0800 (PST) Received: from localhost.localdomain ([81.221.192.120]) by smtp.gmail.com with ESMTPSA id v14sm1139933edq.74.2018.11.21.05.58.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 05:58:36 -0800 (PST) From: Juerg Haefliger X-Google-Original-From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [SRU][Xenial][PATCH 3/3] UBUNTU: SAUCE: x86/speculation: Move RSB_CTXSW hunk Date: Wed, 21 Nov 2018 14:58:31 +0100 Message-Id: <20181121135831.25405-4-juergh@canonical.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181121135831.25405-1-juergh@canonical.com> References: <20181121135831.25405-1-juergh@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" Move the RSB_CTXSW hunk further up in spectre_v2_select_mitigation() to match upstream. No functional changes. CVE-2017-5715 Signed-off-by: Juerg Haefliger Acked-by: Tyler Hicks --- arch/x86/kernel/cpu/bugs.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index a4565038ab35..60907abf12f5 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -410,6 +410,17 @@ specv2_set_mode: spectre_v2_enabled = mode; pr_info("%s\n", spectre_v2_strings[mode]); + /* + * If spectre v2 protection has been enabled, unconditionally fill + * RSB during a context switch; this protects against two independent + * issues: + * + * - RSB underflow (and switch to BTB) on Skylake+ + * - SpectreRSB variant of spectre v2 on X86_BUG_SPECTRE_V2 CPUs + */ + setup_force_cpu_cap(X86_FEATURE_RSB_CTXSW); + pr_info("Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch\n"); + /* * Initialize Indirect Branch Prediction Barrier if supported and not * disabled on the commandline @@ -424,17 +435,6 @@ specv2_set_mode: } } - /* - * If spectre v2 protection has been enabled, unconditionally fill - * RSB during a context switch; this protects against two independent - * issues: - * - * - RSB underflow (and switch to BTB) on Skylake+ - * - SpectreRSB variant of spectre v2 on X86_BUG_SPECTRE_V2 CPUs - */ - setup_force_cpu_cap(X86_FEATURE_RSB_CTXSW); - pr_info("Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch\n"); - /* * Retpoline means the kernel is safe because it has no indirect * branches. Enhanced IBRS protects firmware too, so, enable restricted