2021-01-14 19:47:04

by Josh Poimboeuf

[permalink] [raw]
Subject: [PATCH 15/21] x86/xen/pvh: Convert indirect jump to retpoline

It's kernel policy to not have (unannotated) indirect jumps because of
Spectre v2. This one's probably harmless, but better safe than sorry.
Convert it to a retpoline.

Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Signed-off-by: Josh Poimboeuf <[email protected]>
---
arch/x86/platform/pvh/head.S | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/platform/pvh/head.S b/arch/x86/platform/pvh/head.S
index 43b4d864817e..d87cebd08d32 100644
--- a/arch/x86/platform/pvh/head.S
+++ b/arch/x86/platform/pvh/head.S
@@ -16,6 +16,7 @@
#include <asm/boot.h>
#include <asm/processor-flags.h>
#include <asm/msr.h>
+#include <asm/nospec-branch.h>
#include <xen/interface/elfnote.h>

__HEAD
@@ -105,7 +106,7 @@ SYM_CODE_START_LOCAL(pvh_start_xen)
/* startup_64 expects boot_params in %rsi. */
mov $_pa(pvh_bootparams), %rsi
mov $_pa(startup_64), %rax
- jmp *%rax
+ JMP_NOSPEC rax

#else /* CONFIG_X86_64 */

--
2.29.2


2021-01-15 00:37:32

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [PATCH 15/21] x86/xen/pvh: Convert indirect jump to retpoline


On 1/14/21 2:40 PM, Josh Poimboeuf wrote:
> It's kernel policy to not have (unannotated) indirect jumps because of
> Spectre v2. This one's probably harmless, but better safe than sorry.
> Convert it to a retpoline.
>
> Cc: Boris Ostrovsky <[email protected]>
> Cc: Juergen Gross <[email protected]>
> Signed-off-by: Josh Poimboeuf <[email protected]>


Reviewed-by: Boris Ostrovsky <[email protected]>

2021-01-15 05:52:17

by Jürgen Groß

[permalink] [raw]
Subject: Re: [PATCH 15/21] x86/xen/pvh: Convert indirect jump to retpoline

On 14.01.21 20:40, Josh Poimboeuf wrote:
> It's kernel policy to not have (unannotated) indirect jumps because of
> Spectre v2. This one's probably harmless, but better safe than sorry.
> Convert it to a retpoline.
>
> Cc: Boris Ostrovsky <[email protected]>
> Cc: Juergen Gross <[email protected]>
> Signed-off-by: Josh Poimboeuf <[email protected]>
> ---
> arch/x86/platform/pvh/head.S | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/platform/pvh/head.S b/arch/x86/platform/pvh/head.S
> index 43b4d864817e..d87cebd08d32 100644
> --- a/arch/x86/platform/pvh/head.S
> +++ b/arch/x86/platform/pvh/head.S
> @@ -16,6 +16,7 @@
> #include <asm/boot.h>
> #include <asm/processor-flags.h>
> #include <asm/msr.h>
> +#include <asm/nospec-branch.h>
> #include <xen/interface/elfnote.h>
>
> __HEAD
> @@ -105,7 +106,7 @@ SYM_CODE_START_LOCAL(pvh_start_xen)
> /* startup_64 expects boot_params in %rsi. */
> mov $_pa(pvh_bootparams), %rsi
> mov $_pa(startup_64), %rax
> - jmp *%rax
> + JMP_NOSPEC rax

I'd rather have it annotated only.

Using ALTERNATIVE in very early boot code is just adding needless
clutter, as the retpoline variant won't ever be active.


Juergen


Attachments:
OpenPGP_0xB0DE9DD628BF132F.asc (3.06 kB)
OpenPGP_signature (505.00 B)
OpenPGP digital signature
Download all attachments

2021-01-15 15:11:07

by Josh Poimboeuf

[permalink] [raw]
Subject: Re: [PATCH 15/21] x86/xen/pvh: Convert indirect jump to retpoline

On Fri, Jan 15, 2021 at 06:24:10AM +0100, Jürgen Groß wrote:
> On 14.01.21 20:40, Josh Poimboeuf wrote:
> > It's kernel policy to not have (unannotated) indirect jumps because of
> > Spectre v2. This one's probably harmless, but better safe than sorry.
> > Convert it to a retpoline.
> >
> > Cc: Boris Ostrovsky <[email protected]>
> > Cc: Juergen Gross <[email protected]>
> > Signed-off-by: Josh Poimboeuf <[email protected]>
> > ---
> > arch/x86/platform/pvh/head.S | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/platform/pvh/head.S b/arch/x86/platform/pvh/head.S
> > index 43b4d864817e..d87cebd08d32 100644
> > --- a/arch/x86/platform/pvh/head.S
> > +++ b/arch/x86/platform/pvh/head.S
> > @@ -16,6 +16,7 @@
> > #include <asm/boot.h>
> > #include <asm/processor-flags.h>
> > #include <asm/msr.h>
> > +#include <asm/nospec-branch.h>
> > #include <xen/interface/elfnote.h>
> > __HEAD
> > @@ -105,7 +106,7 @@ SYM_CODE_START_LOCAL(pvh_start_xen)
> > /* startup_64 expects boot_params in %rsi. */
> > mov $_pa(pvh_bootparams), %rsi
> > mov $_pa(startup_64), %rax
> > - jmp *%rax
> > + JMP_NOSPEC rax
>
> I'd rather have it annotated only.
>
> Using ALTERNATIVE in very early boot code is just adding needless
> clutter, as the retpoline variant won't ever be active.

Yeah, Andy pointed out something similar. I'll be changing this to an
annotation.

--
Josh