[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y1LEO49pDvZ1yrNV@google.com>
Date: Fri, 21 Oct 2022 16:09:31 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Vitaly Kuznetsov <vkuznets@...hat.com>
Cc: kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Michael Kelley <mikelley@...rosoft.com>,
Siddharth Chandrasekaran <sidcha@...zon.de>,
Yuan Yao <yuan.yao@...ux.intel.com>,
Maxim Levitsky <mlevitsk@...hat.com>,
linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v11 16/46] KVM: x86: hyper-v: Don't use
sparse_set_to_vcpu_mask() in kvm_hv_send_ipi()
On Fri, Oct 21, 2022, Vitaly Kuznetsov wrote:
> Vitaly Kuznetsov <vkuznets@...hat.com> writes:
>
> > Sean Christopherson <seanjc@...gle.com> writes:
> >> Mostly because it's somewhat arbitrary that earlier code ensures valid_bank_mask
> >> is set in the all_cpus=true case, e.g. arguably KVM doesn't need to do the var_cnt
> >> sanity check in the all_cpus case:
> >>
> >> all_cpus = send_ipi_ex.vp_set.format == HV_GENERIC_SET_ALL;
> >> if (all_cpus)
> >> goto check_and_send_ipi;
> >>
> >> valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask;
> >> if (hc->var_cnt != hweight64(valid_bank_mask))
> >> return HV_STATUS_INVALID_HYPERCALL_INPUT;
> >>
> >> if (!hc->var_cnt)
> >> goto ret_success;
> >>
> >
> > I think 'var_cnt' (== hweight64(valid_bank_mask)) has to be checked in
> > 'all_cpus' case, especially in kvm_hv_flush_tlb(): the code which reads
> > TLB flush entries will read them from the wrong offset (data_offset/
> > consumed_xmm_halves) otherwise. The problem is less severe in
> > kvm_hv_send_ipi() as there's no data after CPU banks.
> >
> > At the bare minimum, "KVM: x86: hyper-v: Handle
> > HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST{,EX} calls gently" patch from this
> > series will have to be adjusted. I *think* mandating var_cnt==0 in 'all_cpus'
> > is OK but I don't recall such requirement from TLFS, maybe it's safer to
> > just adjust 'data_offset'/'consumed_xmm_halves' even in 'all_cpus' case.
> >
> > Let me do some tests...
>
> "We can neither confirm nor deny the existence of the problem". Windows
> guests seem to be smart enough to avoid using *_EX hypercalls altogether
> for "all cpus" case (as non-ex versions are good enough). Let's keep
> allowing non-zero var_cnt for 'all cpus' case for now
Sounds good.
> and think about hardening it later...
Eh, no need to add more work for ourselves. I wasn't thinking about hardening so
much as slightly simplifying KVM code.
Powered by blists - more mailing lists