From: David Hildenbrand <david@redhat.com>
To: "Roman Kagan" <rkagan@virtuozzo.com>,
kvm@vger.kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Denis V. Lunev" <den@openvz.org>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>
Subject: Re: [PATCH v5 2/2] kvm: x86: hyperv: guest->host event signaling via eventfd
Date: Wed, 13 Dec 2017 12:57:11 +0100 [thread overview]
Message-ID: <fca5964d-9ce2-2461-e2aa-c658c8ffd324@redhat.com> (raw)
In-Reply-To: <752b8f33-805f-002a-6ae5-a37b3c8b012a@redhat.com>
On 13.12.2017 12:51, David Hildenbrand wrote:
> On 13.12.2017 12:46, David Hildenbrand wrote:
>> On 13.12.2017 12:44, Roman Kagan wrote:
>>> On Wed, Dec 13, 2017 at 10:55:02AM +0100, David Hildenbrand wrote:
>>>>
>>>>> +static u16 kvm_hvcall_signal_event(struct kvm_vcpu *vcpu, bool fast, u64 param)
>>>>> +{
>>>>> + u16 ret;
>>>>> + u32 conn_id, flag_no;
>>>>> + int idx;
>>>>> + struct eventfd_ctx *eventfd;
>>>>> +
>>>>> + if (unlikely(!fast)) {
>>>>> + gpa_t gpa = param;
>>>>> +
>>>>> + if ((gpa & (__alignof__(param) - 1)) ||
>>>>> + offset_in_page(gpa) + sizeof(param) > PAGE_SIZE)
>>>>> + return HV_STATUS_INVALID_ALIGNMENT;
>>>>> +
>>>>> + idx = srcu_read_lock(&vcpu->kvm->srcu);
>>>>> + ret = kvm_vcpu_read_guest(vcpu, gpa, ¶m, sizeof(param));
>>>>> + srcu_read_unlock(&vcpu->kvm->srcu, idx);
>>>>> +
>>>>> + if (ret < 0)
>>>>> + return HV_STATUS_INSUFFICIENT_MEMORY;
>>>>
>>>> "... event flags do not require any buffer allocation or queuing within
>>>> the hypervisor, so HvSignalEvent will never fail due to insufficient
>>>> resources."
>>>
>>> Ouch. I wonder what else to map -EFAULT to then... Looks like
>>> HV_STATUS_INVALID_ALIGNMENT is the most appropriate (as in "The input or
>>> output GPA pointer is not within the bounds of the GPA space.")
>>>
>>> Thanks,
>>> Roman.
>>>
>>
>> It is likely happen rearelyn, but usually if we are out of memory we
>> should report to user space. (chances that we won't be able to continue
>> for longer either way are very high)
>>
> (I implied -ENOMEM is translated to -EFAULT) it can of course happen if
> the address is wrong.
>
> Also wonder how to deal with that. Could it be that we even have to
> trigger a page fault in the guest?
>
The hypervisor will validate that the calling partition can read from
the input page before executing the
requested hypercall. This validation consists of two checks: the
specified GPA is mapped and the GPA is
marked readable. If either of these tests fails, the hypervisor
generates a memory intercept message.
So memory intercept message is the right thing to do I guess?
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2017-12-13 11:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-12 16:07 [PATCH v5 0/2] kvm: x86: hyperv: guest->host event signaling via eventfd Roman Kagan
2017-12-12 16:07 ` [PATCH v5 1/2] kvm: x86: factor out kvm.arch.hyperv (de)init Roman Kagan
2017-12-12 16:07 ` [PATCH v5 2/2] kvm: x86: hyperv: guest->host event signaling via eventfd Roman Kagan
2017-12-12 16:22 ` Paolo Bonzini
2017-12-12 16:29 ` David Hildenbrand
2017-12-12 18:18 ` Roman Kagan
2017-12-12 18:20 ` David Hildenbrand
2017-12-13 8:41 ` Roman Kagan
2017-12-13 9:35 ` David Hildenbrand
2017-12-13 10:00 ` Roman Kagan
2017-12-12 17:03 ` Roman Kagan
2017-12-13 9:51 ` David Hildenbrand
2017-12-13 11:04 ` Roman Kagan
2017-12-13 11:14 ` David Hildenbrand
2017-12-13 12:16 ` Roman Kagan
2017-12-13 9:55 ` David Hildenbrand
2017-12-13 11:44 ` Roman Kagan
2017-12-13 11:46 ` David Hildenbrand
2017-12-13 11:51 ` David Hildenbrand
2017-12-13 11:57 ` David Hildenbrand [this message]
2017-12-13 12:58 ` Roman Kagan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fca5964d-9ce2-2461-e2aa-c658c8ffd324@redhat.com \
--to=david@redhat.com \
--cc=den@openvz.org \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkagan@virtuozzo.com \
--cc=rkrcmar@redhat.com \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox