From patchwork Tue Jan 15 08:33:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 1025052 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 43f3Wr3mMBz9sBQ; Tue, 15 Jan 2019 19:33:28 +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 1gjK9w-0001K2-1U; Tue, 15 Jan 2019 08:33:20 +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 1gjK9u-0001Ju-Ao for kernel-team@lists.ubuntu.com; Tue, 15 Jan 2019 08:33:18 +0000 Received: from mail-ed1-f70.google.com ([209.85.208.70]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1gjK9u-0007Ex-3O for kernel-team@lists.ubuntu.com; Tue, 15 Jan 2019 08:33:18 +0000 Received: by mail-ed1-f70.google.com with SMTP id l45so839156edb.1 for ; Tue, 15 Jan 2019 00:33:18 -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:mime-version :content-transfer-encoding; bh=bX65get5DsuQfrhbXnb8P946HLVYlGqhd9ywS1FMwQI=; b=q57Rqc53yM6WhC0ScrOeDpceyZYP67nREv5UKObalVNUE6J4AjV1I4sP8IJrszzPXL 1pYXSTRrjEBZFIK0Grlv/vGEsa991HG1hP0oRzJ34jIodb6gWSBNI09TR3AT+qN0Vz5q 4n9ywBJ0iRPfT7/as8sichd7wjsF8xrSynL1/MrmOgLySY73LmSz4Qw3ipKMPivsTPOX uH+J41SM7J5ML6o+kYnVoVDSdLxRWT1jqJAjl6RvHAzpfYdUyJH9QypS4WUQwHBHcJvu HPb8ScWojrr/UeCD8DZ3mi6/GKZakyAFpKubFqIvimI2NE314d/qc6CDv0tqicurRvjy qJBw== X-Gm-Message-State: AJcUukdt3T0l+BA9TzjToKWMrlMdnokmas28mhwqDVghZKOBSe12n8a/ lVsU7d2hGVc2hKL6erg3xI1nYX1uQ1zcjlKeLyc006ZNMwcHOPtVDruU6+JZUZwlNyrc105pGpr tmhr1H8hOUsHhTiEEpfedPvMVqtZZAlxh8NjPI89IVw== X-Received: by 2002:a17:906:7057:: with SMTP id r23-v6mr2176266ejj.113.1547541197547; Tue, 15 Jan 2019 00:33:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN4oA0vj705CI6DUXit1sjxE9E5zd+KenFfTJxLwppoE/VN0d7beWQzxNWfOqK16zfsK2cCOdg== X-Received: by 2002:a17:906:7057:: with SMTP id r23-v6mr2176257ejj.113.1547541197265; Tue, 15 Jan 2019 00:33:17 -0800 (PST) Received: from gollum.fritz.box ([81.221.192.120]) by smtp.gmail.com with ESMTPSA id q3-v6sm2703951ejz.30.2019.01.15.00.33.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 00:33:16 -0800 (PST) From: Juerg Haefliger X-Google-Original-From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [SRU][Xenial][PATCH] UBUNTU: SAUCE: Restore the IBRS host state on VMEXIT Date: Tue, 15 Jan 2019 09:33:15 +0100 Message-Id: <20190115083315.11951-1-juergh@canonical.com> X-Mailer: git-send-email 2.19.1 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" BugLink: https://bugs.launchpad.net/bugs/1764956 IBRS in Ubuntu can be controlled dynamically from userspace. Make sure the correct state is restored on VMEXIT. Suggested-by: Gavin Guo Signed-off-by: Juerg Haefliger Acked-by: Colin Ian King Acked-by: Gavin Guo Tested-by: Gavin Guo --- arch/x86/kernel/cpu/bugs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 15867c20ed1c..63d5b84e680b 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -189,6 +189,10 @@ x86_virt_spec_ctrl(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl, bool setguest) if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD)) hostval |= ssbd_tif_to_spec_ctrl(ti->flags); + /* IBRS dynamically controlled in MSR_SPEC_CTRL */ + if (ibrs_enabled) + hostval |= SPEC_CTRL_IBRS; + if (hostval != guestval) { msrval = setguest ? guestval : hostval; wrmsrl(MSR_IA32_SPEC_CTRL, msrval);