From patchwork Wed May 30 11:38:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 922736 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-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40wpWj3ZSxz9s1b; Wed, 30 May 2018 21:38:41 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fNzR4-0006Jg-Vm; Wed, 30 May 2018 11:38:35 +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 1fNzQx-0006EX-Aa for kernel-team@lists.ubuntu.com; Wed, 30 May 2018 11:38:27 +0000 Received: from mail-wm0-f72.google.com ([74.125.82.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fNzQw-0006SP-Vk for kernel-team@lists.ubuntu.com; Wed, 30 May 2018 11:38:26 +0000 Received: by mail-wm0-f72.google.com with SMTP id a7-v6so546650wmg.0 for ; Wed, 30 May 2018 04:38:26 -0700 (PDT) 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; bh=I/90fbrkQP4p9XJmKyg+lXqk8VG+O+DWUJgGfH/Et3g=; b=ftN8BQhRVcD1e+CvH8LVoYTGTHqi5PZhZxRLd39Tld5Odfh79WLs39RgX6XZWQw4A1 aXrw82AkIWzvwio81HjeI11aHqnATEQ3mre7EX0IBNEYzJ7Ntk01CLnhCRRVya6jvcZy 8TXZst+SMAPGZTlnhQLZzB8NsDqO5idx82YoqFktyt5u1cY+H8Axwec6I6EtyJwR6lOP 723hAdr90EptZ/BwLIyLX8sEqTnYS7liCT+JEDY/7tBGtvvPOLzPFXwPmRLL+Uo3MBsC qfQKL18f8eQ6vbPlWjZCgxZHlz7fkQ1ySKzHhZVB1hqJQZVJTLa9AsDt9FU024Hz1pFu y4Ng== X-Gm-Message-State: ALKqPwd/0ZJHFNPyjFYyYD4DqMuSpGIx+EUAx1IFYUuX1bcUx3koCCLC oCouxHi0cOLnX+ET8LiCaSPSbpxdo63t4xJv2aIAoRTWLgA5DOEbVIKJYQPpkI0pCmHYOe7lsDT VTQxs2qUWScCtlSD1AGxgQEHhTbnJNRO9sL8Wztp9iA== X-Received: by 2002:a50:d1c5:: with SMTP id i5-v6mr3132028edg.231.1527680306519; Wed, 30 May 2018 04:38:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIjwnjHSgZ/wdwCheDgJoUARmeClksI299rjKSgb4FOZmUz1czblkWtinKLd90rFk+CxTGfQA== X-Received: by 2002:a50:d1c5:: with SMTP id i5-v6mr3132018edg.231.1527680306356; Wed, 30 May 2018 04:38:26 -0700 (PDT) Received: from localhost.localdomain ([81.221.205.149]) by smtp.gmail.com with ESMTPSA id g1-v6sm9265853edi.41.2018.05.30.04.38.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 04:38:25 -0700 (PDT) From: Juerg Haefliger X-Google-Original-From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [SRU][Xenial][PATCH 6/6] UBUNTU: SAUCE: x86/speculation: Query individual feature flags when reloading microcode Date: Wed, 30 May 2018 13:38:17 +0200 Message-Id: <20180530113817.14784-7-juergh@canonical.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530113817.14784-1-juergh@canonical.com> References: <20180530113817.14784-1-juergh@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" CVE-2018-3639 (x86) We now have individual feature flags for IBRS and IBPB, so query them when reloading microcode. Just like we do on boot (in arch/x86/kernel/cpu/common.c). Signed-off-by: Juerg Haefliger --- arch/x86/kernel/cpu/microcode/core.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 55d4f5cc353b..63e3db171945 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -439,22 +439,26 @@ static ssize_t reload_store(struct device *dev, if (!ret) perf_check_microcode(); - if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) { - printk_once(KERN_INFO "FEATURE SPEC_CTRL Present\n"); + /* Initialize Indirect Branch Prediction Barrier if supported */ + if (boot_cpu_has(X86_FEATURE_IBPB)) { + setup_force_cpu_cap(X86_FEATURE_USE_IBPB); + pr_info("Enabling Indirect Branch Prediction Barrier\n"); + mutex_lock(&spec_ctrl_mutex); - set_ibrs_supported(); set_ibpb_supported(); - if (ibrs_inuse) - sysctl_ibrs_enabled = 1; if (ibpb_inuse) sysctl_ibpb_enabled = 1; mutex_unlock(&spec_ctrl_mutex); - } else if (boot_cpu_has(X86_FEATURE_IBPB)) { - printk_once(KERN_INFO "FEATURE IBPB Present\n"); + } + + /* Initialize Indirect Branch Restricted Speculation if supported */ + if (boot_cpu_has(X86_FEATURE_IBRS)) { + pr_info("Enabling Indirect Branch Restricted Speculation\n"); + mutex_lock(&spec_ctrl_mutex); - set_ibpb_supported(); - if (ibpb_inuse) - sysctl_ibpb_enabled = 1; + set_ibrs_supported(); + if (ibrs_inuse) + sysctl_ibrs_enabled = 1; mutex_unlock(&spec_ctrl_mutex); }