public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Patrick Bellasi <derkling@google.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Sean Christopherson <seanjc@google.com>,
	Yosry Ahmed <yosry.ahmed@linux.dev>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	 Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	x86@kernel.org, kvm@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Patrick Bellasi <derkling@matbug.net>,
	 Brendan Jackman <jackmanb@google.com>,
	David Kaplan <David.Kaplan@amd.com>
Subject: Re: [PATCH final?] x86/bugs: KVM: Add support for SRSO_MSR_FIX
Date: Tue, 18 Feb 2025 14:42:57 +0000	[thread overview]
Message-ID: <20250218144257.1033452-1-derkling@google.com> (raw)
In-Reply-To: <20250218111306.GFZ7RrQh3RD4JKj1lu@fat_crate.local>

> in the interest of finally making some progress here I'd like to commit this
> below (will test it one more time just in case but it should work :-P). It is
> simple and straight-forward and doesn't need an IBPB when the bit gets
> cleared.

That's indeed simple and straight-forward for the time being.

Maybe a small improvement we could add on top is to have a separate and
dedicated cmdline option?

Indeed, with `X86_FEATURE_SRSO_USER_KERNEL_NO` we are not effectively using an
IBPB on VM-Exit anymore. Something like the diff down below?

Best,
Patrick

---
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 1d7afc40f2272..7609d80eda123 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -2531,6 +2531,7 @@ enum srso_mitigation_cmd {
        SRSO_CMD_SAFE_RET,
        SRSO_CMD_IBPB,
        SRSO_CMD_IBPB_ON_VMEXIT,
+       SRSO_CMD_BP_SPEC_REDUCE,
 };

 static const char * const srso_strings[] = {
@@ -2562,6 +2563,8 @@ static int __init srso_parse_cmdline(char *str)
                srso_cmd = SRSO_CMD_IBPB;
        else if (!strcmp(str, "ibpb-vmexit"))
                srso_cmd = SRSO_CMD_IBPB_ON_VMEXIT;
+       else if (!strcmp(str, "spec-reduce"))
+               srso_cmd = SRSO_CMD_BP_SPEC_REDUCE;
        else
                pr_err("Ignoring unknown SRSO option (%s).", str);

@@ -2617,7 +2620,7 @@ static void __init srso_select_mitigation(void)

        case SRSO_CMD_SAFE_RET:
                if (boot_cpu_has(X86_FEATURE_SRSO_USER_KERNEL_NO))
-                       goto ibpb_on_vmexit;
+                       goto spec_reduce;

                if (IS_ENABLED(CONFIG_MITIGATION_SRSO)) {
                        /*
@@ -2670,14 +2673,7 @@ static void __init srso_select_mitigation(void)
                }
                break;

-ibpb_on_vmexit:
        case SRSO_CMD_IBPB_ON_VMEXIT:
-               if (boot_cpu_has(X86_FEATURE_SRSO_BP_SPEC_REDUCE)) {
-                       pr_notice("Reducing speculation to address VM/HV SRSO attack vector.\n");
-                       srso_mitigation = SRSO_MITIGATION_BP_SPEC_REDUCE;
-                       break;
-               }
-
                if (IS_ENABLED(CONFIG_MITIGATION_IBPB_ENTRY)) {
                        if (has_microcode) {
                                setup_force_cpu_cap(X86_FEATURE_IBPB_ON_VMEXIT);
@@ -2694,6 +2690,14 @@ static void __init srso_select_mitigation(void)
                        pr_err("WARNING: kernel not compiled with MITIGATION_IBPB_ENTRY.\n");
                }
                break;
+
+spec_reduce:
+       case SRSO_CMD_BP_SPEC_REDUCE:
+               if (boot_cpu_has(X86_FEATURE_SRSO_BP_SPEC_REDUCE)) {
+                       pr_notice("Reducing speculation to address VM/HV SRSO attack vector.\n");
+                       srso_mitigation = SRSO_MITIGATION_BP_SPEC_REDUCE;
+                       break;
+               }
        default:
                break;
        }

  reply	other threads:[~2025-02-18 14:43 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 12:04 [PATCH v2 0/4] x86/bugs: Adjust SRSO mitigation to new features Borislav Petkov
2024-12-02 12:04 ` [PATCH v2 1/4] x86/bugs: Add SRSO_USER_KERNEL_NO support Borislav Petkov
2024-12-10  6:53   ` Josh Poimboeuf
2024-12-10 15:37     ` Borislav Petkov
2024-12-11  7:53       ` Josh Poimboeuf
2024-12-11 20:38         ` Borislav Petkov
2024-12-11 22:35           ` Sean Christopherson
2024-12-16 17:21             ` Borislav Petkov
2024-12-02 12:04 ` [PATCH v2 2/4] KVM: x86: Advertise SRSO_USER_KERNEL_NO to userspace Borislav Petkov
2024-12-02 12:04 ` [PATCH v2 3/4] x86/bugs: KVM: Add support for SRSO_MSR_FIX Borislav Petkov
2024-12-11 22:27   ` Sean Christopherson
2024-12-16 17:31     ` Borislav Petkov
2024-12-16 18:51       ` Sean Christopherson
2024-12-17  9:34         ` Borislav Petkov
2024-12-30 11:14         ` Borislav Petkov
2025-01-08 13:38           ` Sean Christopherson
2025-01-08 15:49             ` Borislav Petkov
2025-01-08 17:18               ` Sean Christopherson
2025-01-08 18:14                 ` Borislav Petkov
2025-01-08 18:37                   ` Jim Mattson
2025-01-08 19:14                     ` Borislav Petkov
2025-01-08 19:43                       ` Jim Mattson
2025-01-08 19:45                         ` Borislav Petkov
2025-01-11 12:52                   ` [PATCH] " Borislav Petkov
2025-01-17 18:56                     ` Sean Christopherson
2025-01-18 15:26                       ` Borislav Petkov
2025-01-23 16:25                         ` Sean Christopherson
2025-01-23 17:01                           ` Borislav Petkov
2025-01-23 18:04                             ` Sean Christopherson
2025-01-24 12:58                               ` Borislav Petkov
2025-02-11 19:19                                 ` Jim Mattson
2025-02-11 20:51                                   ` Borislav Petkov
2025-02-13 10:53                             ` Patrick Bellasi
2025-02-13 13:44                               ` Patrick Bellasi
2025-02-13 14:28                                 ` Borislav Petkov
2025-02-13 17:50                                   ` Patrick Bellasi
2025-02-14 20:10                                     ` Borislav Petkov
2025-02-15  0:57                                       ` Yosry Ahmed
2025-02-15  9:15                                         ` Borislav Petkov
2025-02-17  5:47                                           ` Yosry Ahmed
2025-02-17 15:26                                             ` Borislav Petkov
2025-02-15 12:53                                       ` Borislav Petkov
2025-02-17  5:59                                         ` Yosry Ahmed
2025-02-17 16:07                                           ` Borislav Petkov
2025-02-17 19:56                                             ` Yosry Ahmed
2025-02-17 20:20                                               ` Borislav Petkov
2025-02-17 20:32                                                 ` Yosry Ahmed
2025-02-18 11:13                                                   ` [PATCH final?] " Borislav Petkov
2025-02-18 14:42                                                     ` Patrick Bellasi [this message]
2025-02-18 15:34                                                       ` Borislav Petkov
2025-04-29 13:25                                                     ` x86/bugs: KVM: Add support for SRSO_MSR_FIX, back for moar Borislav Petkov
2025-04-30 23:33                                                       ` Sean Christopherson
2025-05-01  0:42                                                         ` Michael Larabel
2025-05-01  8:19                                                         ` Borislav Petkov
2025-05-01 16:56                                                           ` Sean Christopherson
2025-05-05 15:25                                                             ` Borislav Petkov
2025-05-05 15:40                                                               ` Kaplan, David
2025-05-05 15:47                                                                 ` Borislav Petkov
2025-05-05 16:30                                                                 ` Sean Christopherson
2025-05-05 16:42                                                                   ` Kaplan, David
2025-05-05 18:03                                                                     ` Sean Christopherson
2025-05-05 18:25                                                                       ` Kaplan, David
2024-12-02 12:04 ` [PATCH v2 4/4] Documentation/kernel-parameters: Fix a typo in kvm.enable_virt_at_load text Borislav Petkov
2024-12-03 14:30 ` [PATCH v2 0/4] x86/bugs: Adjust SRSO mitigation to new features Nikolay Borisov
  -- strict thread matches above, loose matches on Subject: below --
2025-02-26 18:45 [PATCH final?] x86/bugs: KVM: Add support for SRSO_MSR_FIX Patrick Bellasi
2025-02-26 19:51 ` Yosry Ahmed
2025-03-03 13:59   ` Borislav Petkov
2025-03-03 14:10 ` Borislav Petkov
2025-03-03 15:05 Patrick Bellasi
2025-03-11 12:03 ` Borislav Petkov
2025-03-11 13:36   ` Brendan Jackman
2025-03-12 19:17     ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250218144257.1033452-1-derkling@google.com \
    --to=derkling@google.com \
    --cc=David.Kaplan@amd.com \
    --cc=bp@alien8.de \
    --cc=derkling@matbug.net \
    --cc=jackmanb@google.com \
    --cc=jpoimboe@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=x86@kernel.org \
    --cc=yosry.ahmed@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox