Skip to contentSkip to conversation

kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest

PATCH Liran Alon 2 participants 2 messages Jan 8, 2018 – Jan 9, 2018 KVM

lore
Share & tools
lore

Liran Alon

author
#0 lore raw
Quoted 21 lines · ----- [email protected] wrote:

----- Original Message -----

Quoted 2 lines

From: "David Woodhouse" <[email protected]>
To: "Paolo Bonzini" <[email protected]>,

[email protected], [email protected]

Quoted 1 line
Cc [email protected], [email protected], "thomas lendacky"

<[email protected]>, [email protected]

Quoted 2 lines

Sent: Monday, January 8, 2018 8:41:07 PM
Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and

MSR_IA32_PRED_CMD down to the guest

Quoted 11 lines · Paolo Bonzini
Quoted 4 lines

+       if (have_spec_ctrl && vmx->spec_ctrl != 0) +               wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); +

I think this one probably *is* safe even without an 'else lfence', which means that the CPU can speculate around it, but it wants a comment explaining that someone has properly analysed it and saying precisely why.

Quoted 6 lines

This one is okay as long as there are no indirect jumps until vmresume. But the one on vmexit is only okay because right now it's *disabling* IBRS. Once IBRS is used by Linux, we'll need an lfence there. I'll add a comment.

Paolo

That is true but from what I understand, there is an indirect branch from this point until vmresume. That indirect branch resides in atomic_switch_perf_msrs() immediately called after this WRMSR:
atomic_switch_perf_msrs() -> perf_guest_get_msrs() -> x86_pmu.guest_get_msrs().

-Liran

maintainer
#1 lore raw
Quoted 29 lines · Liran Alon
Quoted 26 lines · ----- [email protected] wrote:

----- Original Message -----

Quoted 2 lines

From: "David Woodhouse" <[email protected]>
To: "Paolo Bonzini" <[email protected]>,

[email protected], [email protected]

Quoted 1 line
Cc [email protected], [email protected], "thomas lendacky"

<[email protected]>, [email protected]

Quoted 2 lines

Sent: Monday, January 8, 2018 8:41:07 PM
Subject: Re: [PATCH 3/7] kvm: vmx: pass MSR_IA32_SPEC_CTRL and

MSR_IA32_PRED_CMD down to the guest

Quoted 11 lines · Paolo Bonzini
Quoted 4 lines

+       if (have_spec_ctrl && vmx->spec_ctrl != 0) +               wrmsrl(MSR_IA32_SPEC_CTRL, vmx->spec_ctrl); +

I think this one probably *is* safe even without an 'else lfence', which means that the CPU can speculate around it, but it wants a comment explaining that someone has properly analysed it and saying precisely why.

This one is okay as long as there are no indirect jumps until vmresume. But the one on vmexit is only okay because right now it's *disabling* IBRS. Once IBRS is used by Linux, we'll need an lfence there. I'll add a comment.

Quoted 5 lines
Quoted 1 line

Paolo

That is true but from what I understand, there is an indirect branch from this point until vmresume. That indirect branch resides in atomic_switch_perf_msrs() immediately called after this WRMSR:
atomic_switch_perf_msrs() -> perf_guest_get_msrs() -> x86_pmu.guest_get_msrs().

Sure, it has to move later as pointed out by other reviewers.

Paolo