linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: kvm: Restrict X86_FEATURE_VMMCALL to x86_64 platform
@ 2018-07-30 19:40 Matthew Whitehead
  2018-07-31  7:39 ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Matthew Whitehead @ 2018-07-30 19:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: Matthew Whitehead, Paolo Bonzini

early_init_amd() is called on all AMD processors, both 64 and 32 bit.
Presently 32 bit processors get the X86_FEATURE_VMMCALL feature set, which
they do not support. Add conditionals to restrict it to 64 bit processors.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
---
 arch/x86/kernel/cpu/amd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 38915fbfae73..df06919324cd 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -662,12 +662,14 @@ static void early_init_amd(struct cpuinfo_x86 *c)
 	}
 #endif
 
+#ifdef CONFIG_X86_64
 	/*
 	 * This is only needed to tell the kernel whether to use VMCALL
 	 * and VMMCALL.  VMMCALL is never executed except under virt, so
 	 * we can set it unconditionally.
 	 */
 	set_cpu_cap(c, X86_FEATURE_VMMCALL);
+#endif
 
 	/* F16h erratum 793, CVE-2013-6885 */
 	if (c->x86 == 0x16 && c->x86_model <= 0xf)
-- 
2.16.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: kvm: Restrict X86_FEATURE_VMMCALL to x86_64 platform
  2018-07-30 19:40 [PATCH] x86: kvm: Restrict X86_FEATURE_VMMCALL to x86_64 platform Matthew Whitehead
@ 2018-07-31  7:39 ` Paolo Bonzini
  2018-07-31 12:57   ` tedheadster
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2018-07-31  7:39 UTC (permalink / raw)
  To: Matthew Whitehead, linux-kernel

On 30/07/2018 21:40, Matthew Whitehead wrote:
> early_init_amd() is called on all AMD processors, both 64 and 32 bit.
> Presently 32 bit processors get the X86_FEATURE_VMMCALL feature set, which
> they do not support. Add conditionals to restrict it to 64 bit processors.

This shouldn't be necessary; for systems that don't have virtualization
extensions, the comment explains why setting X86_FEATURE_VMMCALL is safe.

But it is also wrong, because you can run a 32-bit kernel as a guest on
a 64-bit processor, and then it should set X86_FEATURE_VMMCALL because
the processor has the vmmcall instruction and not Intel's vmcall.

Thanks,

Paolo

> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
> ---
>  arch/x86/kernel/cpu/amd.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index 38915fbfae73..df06919324cd 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -662,12 +662,14 @@ static void early_init_amd(struct cpuinfo_x86 *c)
>  	}
>  #endif
>  
> +#ifdef CONFIG_X86_64
>  	/*
>  	 * This is only needed to tell the kernel whether to use VMCALL
>  	 * and VMMCALL.  VMMCALL is never executed except under virt, so
>  	 * we can set it unconditionally.
>  	 */
>  	set_cpu_cap(c, X86_FEATURE_VMMCALL);
> +#endif
>  
>  	/* F16h erratum 793, CVE-2013-6885 */
>  	if (c->x86 == 0x16 && c->x86_model <= 0xf)
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: kvm: Restrict X86_FEATURE_VMMCALL to x86_64 platform
  2018-07-31  7:39 ` Paolo Bonzini
@ 2018-07-31 12:57   ` tedheadster
  2018-07-31 12:59     ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: tedheadster @ 2018-07-31 12:57 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Linux Kernel Mailing List

>
> This shouldn't be necessary; for systems that don't have virtualization
> extensions, the comment explains why setting X86_FEATURE_VMMCALL is safe.
>
> But it is also wrong, because you can run a 32-bit kernel as a guest on
> a 64-bit processor, and then it should set X86_FEATURE_VMMCALL because
> the processor has the vmmcall instruction and not Intel's vmcall.
>

Paolo,
  I'm running this on a bare metal machine (no virtualization) with a
32-bit AMD i486 class cpu. Should the feature be showing up in
/proc/cpuinfo under the 'flags' line? It does on my machine, and it
looked wrong to me.

- Matthew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: kvm: Restrict X86_FEATURE_VMMCALL to x86_64 platform
  2018-07-31 12:57   ` tedheadster
@ 2018-07-31 12:59     ` Paolo Bonzini
  2018-08-01 15:21       ` Brian Gerst
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2018-07-31 12:59 UTC (permalink / raw)
  To: whiteheadm; +Cc: Linux Kernel Mailing List

On 31/07/2018 14:57, tedheadster wrote:
>>
>> This shouldn't be necessary; for systems that don't have virtualization
>> extensions, the comment explains why setting X86_FEATURE_VMMCALL is safe.
>>
>> But it is also wrong, because you can run a 32-bit kernel as a guest on
>> a 64-bit processor, and then it should set X86_FEATURE_VMMCALL because
>> the processor has the vmmcall instruction and not Intel's vmcall.
>>
> 
> Paolo,
>   I'm running this on a bare metal machine (no virtualization) with a
> 32-bit AMD i486 class cpu. Should the feature be showing up in
> /proc/cpuinfo under the 'flags' line? It does on my machine, and it
> looked wrong to me.

It's a bit silly, but it's not particularly wrong.

Paolo


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: kvm: Restrict X86_FEATURE_VMMCALL to x86_64 platform
  2018-07-31 12:59     ` Paolo Bonzini
@ 2018-08-01 15:21       ` Brian Gerst
  2018-08-01 15:27         ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Brian Gerst @ 2018-08-01 15:21 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: whiteheadm, Linux Kernel Mailing List

On Tue, Jul 31, 2018 at 9:00 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 31/07/2018 14:57, tedheadster wrote:
> >>
> >> This shouldn't be necessary; for systems that don't have virtualization
> >> extensions, the comment explains why setting X86_FEATURE_VMMCALL is safe.
> >>
> >> But it is also wrong, because you can run a 32-bit kernel as a guest on
> >> a 64-bit processor, and then it should set X86_FEATURE_VMMCALL because
> >> the processor has the vmmcall instruction and not Intel's vmcall.
> >>
> >
> > Paolo,
> >   I'm running this on a bare metal machine (no virtualization) with a
> > 32-bit AMD i486 class cpu. Should the feature be showing up in
> > /proc/cpuinfo under the 'flags' line? It does on my machine, and it
> > looked wrong to me.
>
> It's a bit silly, but it's not particularly wrong.

Why is there even a specific feature flag for VMMCALL?  Isn't
X86_FEATURE_SVM sufficient to differentiate which opcode to use?

--
Brian Gerst

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: kvm: Restrict X86_FEATURE_VMMCALL to x86_64 platform
  2018-08-01 15:21       ` Brian Gerst
@ 2018-08-01 15:27         ` Paolo Bonzini
  0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2018-08-01 15:27 UTC (permalink / raw)
  To: Brian Gerst; +Cc: whiteheadm, Linux Kernel Mailing List

On 01/08/2018 17:21, Brian Gerst wrote:
> On Tue, Jul 31, 2018 at 9:00 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> On 31/07/2018 14:57, tedheadster wrote:
>>>>
>>>> This shouldn't be necessary; for systems that don't have virtualization
>>>> extensions, the comment explains why setting X86_FEATURE_VMMCALL is safe.
>>>>
>>>> But it is also wrong, because you can run a 32-bit kernel as a guest on
>>>> a 64-bit processor, and then it should set X86_FEATURE_VMMCALL because
>>>> the processor has the vmmcall instruction and not Intel's vmcall.
>>>>
>>>
>>> Paolo,
>>>   I'm running this on a bare metal machine (no virtualization) with a
>>> 32-bit AMD i486 class cpu. Should the feature be showing up in
>>> /proc/cpuinfo under the 'flags' line? It does on my machine, and it
>>> looked wrong to me.
>>
>> It's a bit silly, but it's not particularly wrong.
> 
> Why is there even a specific feature flag for VMMCALL?  Isn't
> X86_FEATURE_SVM sufficient to differentiate which opcode to use?

No, X86_FEATURE_SVM is there in the host while X86_FEATURE_VMMCALL is
used in the guest.

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-08-01 15:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30 19:40 [PATCH] x86: kvm: Restrict X86_FEATURE_VMMCALL to x86_64 platform Matthew Whitehead
2018-07-31  7:39 ` Paolo Bonzini
2018-07-31 12:57   ` tedheadster
2018-07-31 12:59     ` Paolo Bonzini
2018-08-01 15:21       ` Brian Gerst
2018-08-01 15:27         ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).