Re: [PATCH v2] kvm: vmx: Raise #UD on unsupported RDSEED

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2017-08-19 2:45 GMT+08:00 Jim Mattson <jmattson@xxxxxxxxxx>:
> A guest may not be configured to support RDSEED, even when the host
> does. If the guest does not support RDSEED, intercept the instruction
> and synthesize #UD.
> ---

You miss your SOB? Otherwise, Reviewed-by: Wanpeng Li <wanpeng.li@xxxxxxxxxxx>

>  arch/x86/kvm/vmx.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index ed1074e98b8e..30dac6eb4b3d 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3662,6 +3662,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
>                         SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
>                         SECONDARY_EXEC_SHADOW_VMCS |
>                         SECONDARY_EXEC_XSAVES |
> +                       SECONDARY_EXEC_RDSEED |
>                         SECONDARY_EXEC_ENABLE_PML |
>                         SECONDARY_EXEC_TSC_SCALING |
>                         SECONDARY_EXEC_ENABLE_VMFUNC;
> @@ -5298,6 +5299,9 @@ static u32 vmx_secondary_exec_control(struct vcpu_vmx *vmx)
>         if (!enable_pml)
>                 exec_control &= ~SECONDARY_EXEC_ENABLE_PML;
>
> +       if (guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDSEED))
> +               exec_control &= ~SECONDARY_EXEC_RDSEED;
> +
>         return exec_control;
>  }
>
> @@ -6806,6 +6810,12 @@ static int handle_mwait(struct kvm_vcpu *vcpu)
>         return handle_nop(vcpu);
>  }
>
> +static int handle_invalid_op(struct kvm_vcpu *vcpu)
> +{
> +       kvm_queue_exception(vcpu, UD_VECTOR);
> +       return 1;
> +}
> +
>  static int handle_monitor_trap(struct kvm_vcpu *vcpu)
>  {
>         return 1;
> @@ -8050,6 +8060,7 @@ static int (*const kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
>         [EXIT_REASON_MONITOR_INSTRUCTION]     = handle_monitor,
>         [EXIT_REASON_INVEPT]                  = handle_invept,
>         [EXIT_REASON_INVVPID]                 = handle_invvpid,
> +       [EXIT_REASON_RDSEED]                  = handle_invalid_op,
>         [EXIT_REASON_XSAVES]                  = handle_xsaves,
>         [EXIT_REASON_XRSTORS]                 = handle_xrstors,
>         [EXIT_REASON_PML_FULL]                = handle_pml_full,
> --
> 2.14.1.480.gb18f417b89-goog
>



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux