diff mbox series

[SRU,Xenial] UBUNTU: SAUCE: Restore the IBRS host state on VMEXIT

Message ID 20190115083315.11951-1-juergh@canonical.com
State New
Headers show
Series [SRU,Xenial] UBUNTU: SAUCE: Restore the IBRS host state on VMEXIT | expand

Commit Message

Juerg Haefliger Jan. 15, 2019, 8:33 a.m. UTC
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 <gavin.guo@canonical.com>
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 arch/x86/kernel/cpu/bugs.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Colin Ian King Jan. 15, 2019, 9:15 a.m. UTC | #1
On 15/01/2019 08:33, Juerg Haefliger wrote:
> 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 <gavin.guo@canonical.com>
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  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);
> 

Makes sense.

Acked-by: Colin Ian King <colin.king@canonical.com>
Gavin Guo Jan. 18, 2019, 9:12 a.m. UTC | #2
On Tue, Jan 15, 2019 at 4:33 PM Juerg Haefliger
<juerg.haefliger@canonical.com> wrote:
>
> 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 <gavin.guo@canonical.com>
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  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);
> --
> 2.19.1
>
>
> --
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

The kernel with the patch based on version v4.4.0-141.167 has been
tested[1] and the bug cannot be reproduced.
[1]. https://kernel.ubuntu.com/~juergh/lp1764956/

Acked-by: Gavin Guo <gavin.guo@canonical.com>
Tested-by: Gavin Guo <gavin.guo@canonical.com>
Stefan Bader Feb. 1, 2019, 12:45 p.m. UTC | #3
On 15.01.19 09:33, Juerg Haefliger wrote:
> 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 <gavin.guo@canonical.com>
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
Applied to xenial/master-next. Thanks.

-Stefan
>  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);
>
diff mbox series

Patch

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);