[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87v91cjhch.fsf@vitty.brq.redhat.com>
Date: Mon, 01 Nov 2021 11:33:18 +0100
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
linux-hyperv@...r.kernel.org, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org, Ajay Garg <ajaygargnsit@...il.com>,
Paolo Bonzini <pbonzini@...hat.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Wei Liu <wei.liu@...nel.org>, Dexuan Cui <decui@...rosoft.com>,
Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v2 8/8] KVM: x86: Add checks for reserved-to-zero
Hyper-V hypercall fields
Sean Christopherson <seanjc@...gle.com> writes:
> Add checks for the three fields in Hyper-V's hypercall params that must
> be zero. Per the TLFS, HV_STATUS_INVALID_HYPERCALL_INPUT is returned if
> "A reserved bit in the specified hypercall input value is non-zero."
>
> Note, the TLFS has an off-by-one bug for the last reserved field, which
> it defines as being bits 64:60. The same section states "The input field
> 64-bit value called a hypercall input value.", i.e. bit 64 doesn't
> exist.
This version are you looking at? I can't see this issue in 6.0b
>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
> arch/x86/kvm/hyperv.c | 5 +++++
> include/asm-generic/hyperv-tlfs.h | 6 ++++++
> 2 files changed, 11 insertions(+)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index ad455df850c9..1cdcf3ad5684 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -2228,6 +2228,11 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
> goto hypercall_complete;
> }
>
> + if (unlikely(hc.param & HV_HYPERCALL_RSVD_MASK)) {
> + ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
> + goto hypercall_complete;
> + }
> +
> if (hc.fast && is_xmm_fast_hypercall(&hc)) {
> if (unlikely(hv_vcpu->enforce_cpuid &&
> !(hv_vcpu->cpuid_cache.features_edx &
> diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h
> index 1ba8e6da4427..92b9ce5882f8 100644
> --- a/include/asm-generic/hyperv-tlfs.h
> +++ b/include/asm-generic/hyperv-tlfs.h
> @@ -183,11 +183,17 @@ enum HV_GENERIC_SET_FORMAT {
> #define HV_HYPERCALL_FAST_BIT BIT(16)
> #define HV_HYPERCALL_VARHEAD_OFFSET 17
> #define HV_HYPERCALL_VARHEAD_MASK GENMASK_ULL(26, 17)
> +#define HV_HYPERCALL_RSVD0_MASK GENMASK_ULL(31, 27)
> #define HV_HYPERCALL_REP_COMP_OFFSET 32
> #define HV_HYPERCALL_REP_COMP_1 BIT_ULL(32)
> #define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32)
> +#define HV_HYPERCALL_RSVD1_MASK GENMASK_ULL(47, 44)
> #define HV_HYPERCALL_REP_START_OFFSET 48
> #define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48)
> +#define HV_HYPERCALL_RSVD2_MASK GENMASK_ULL(63, 60)
> +#define HV_HYPERCALL_RSVD_MASK (HV_HYPERCALL_RSVD0_MASK | \
> + HV_HYPERCALL_RSVD1_MASK | \
> + HV_HYPERCALL_RSVD2_MASK)
>
> /* hypercall status code */
> #define HV_STATUS_SUCCESS 0
Reviewed-by: Vitaly Kuznetsov <vkuznets@...hat.com>
--
Vitaly
Powered by blists - more mailing lists