From: Paul Durrant <xadimgnik@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Paul Durrant <pdurrant@amazon.com>,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2 11/12] KVM: selftests / xen: don't explicitly set the vcpu_info address
Date: Mon, 18 Sep 2023 14:41:08 +0100 [thread overview]
Message-ID: <f5eab713-fa74-2cbc-7df5-81d8d26fee0a@xen.org> (raw)
In-Reply-To: <c9a1961812b0cbb6e9f641dec5c6edcb21482161.camel@infradead.org>
On 18/09/2023 14:36, David Woodhouse wrote:
> On Mon, 2023-09-18 at 14:26 +0100, Paul Durrant wrote:
>> On 18/09/2023 14:21, David Woodhouse wrote:
>>> On Mon, 2023-09-18 at 11:21 +0000, Paul Durrant wrote:
>>>> From: Paul Durrant <pdurrant@amazon.com>
>>>>
>>>> If the vCPU id is set and the shared_info is mapped using HVA then we can
>>>> infer that KVM has the ability to use a default vcpu_info mapping. Hence
>>>> we can stop setting the address of the vcpu_info structure.
>>>
>>> Again that means we're not *testing* it any more when the test is run
>>> on newer kernels. Can we perhaps set it explicitly, after *half* the
>>> tests are done? Maybe to a *different* address than the default which
>>> is derived from the Xen vcpu_id? And check that the memcpy works right
>>> when we do?
>>>
>>
>> Ok. The VMM is currently responsible for that memcpy. Are you suggesting
>> we push that into KVM too?
>
> Ah OK.
>
> Hm, maybe we should?
>
> What happened before in the case where interrupts were being delivered,
> and the vcpu_info address was changed.
>
> In Xen, I guess it's effectively atomic? Some locking will mean that
> the event channel is delivered to the vcpu_info either *before* the
> memcpy, or *after* it, but never to the old address after the copy has
> been done, so that the event (well the index of it) gets lost?
>
> In KVM before we did the automatic placement, it was the VMM's problem.
>
> If there are any interrupts set up for direct delivery, I suppose the
> VMM should have *removed* the vcpu_info mapping before doing the
> memcpy, then restored it at the new address? I may have to check qemu
> gets that right.
>
> Then again, it's a very hard race to trigger, given that a guest can
> only set the vcpu_info once. So it can move it from the shinfo to a
> separate address and attempt to trigger this race just that one time.
>
> But in the case where auto-placement has happened, and then the guest
> sets an explicit vcpu_info location... are we saying that the VMM must
> explicitly *unmap* the vcpu_info first, then memcpy, then set it to the
> new location? Or will we handle the memcpy in-kernel?
>
Well, if the VMM is using the default then it can't unmap it. But
setting a vcpu_info *after* enabling any event channels would be a very
odd thing for a guest to do and IMO it gets to keep the pieces if it
does so.
Paul
next prev parent reply other threads:[~2023-09-18 15:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 11:21 [PATCH v2 00/12] KVM: xen: update shared_info and vcpu_info handling Paul Durrant
2023-09-18 11:21 ` [PATCH v2 01/12] KVM: pfncache: add a map helper function Paul Durrant
2023-09-18 11:21 ` [PATCH v2 02/12] KVM: pfncache: add a mark-dirty helper Paul Durrant
2023-09-18 11:21 ` [PATCH v2 03/12] KVM: pfncache: add a helper to get the gpa Paul Durrant
2023-09-18 11:21 ` [PATCH v2 04/12] KVM: pfncache: base offset check on khva rather than gpa Paul Durrant
2023-09-18 11:21 ` [PATCH v2 05/12] KVM: pfncache: allow a cache to be activated with a fixed (userspace) HVA Paul Durrant
2023-09-18 11:34 ` David Woodhouse
2023-09-18 12:11 ` Paul Durrant
2023-09-18 12:59 ` David Woodhouse
2023-09-18 13:00 ` Paul Durrant
2023-09-18 11:21 ` [PATCH v2 06/12] KVM: xen: allow shared_info to be mapped by fixed HVA Paul Durrant
2023-09-18 11:21 ` [PATCH v2 07/12] KVM: xen: prepare for using 'default' vcpu_info Paul Durrant
2023-09-18 11:21 ` [PATCH v2 08/12] KVM: xen: automatically use the vcpu_info embedded in shared_info Paul Durrant
2023-09-18 11:49 ` David Woodhouse
2023-09-18 12:15 ` Paul Durrant
2023-09-18 11:21 ` [PATCH v2 09/12] KVM: selftests / xen: set KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID Paul Durrant
2023-09-18 11:59 ` David Woodhouse
2023-09-18 12:18 ` Paul Durrant
2023-09-18 12:26 ` David Woodhouse
2023-09-18 11:21 ` [PATCH v2 10/12] KVM: selftests / xen: map shared_info using HVA rather than GFN Paul Durrant
2023-09-18 13:19 ` David Woodhouse
2023-09-18 13:24 ` Paul Durrant
2023-09-18 13:30 ` David Woodhouse
2023-09-18 11:21 ` [PATCH v2 11/12] KVM: selftests / xen: don't explicitly set the vcpu_info address Paul Durrant
2023-09-18 13:21 ` David Woodhouse
2023-09-18 13:26 ` Paul Durrant
2023-09-18 13:36 ` David Woodhouse
2023-09-18 13:41 ` Paul Durrant [this message]
2023-09-18 14:05 ` David Woodhouse
2023-09-18 14:14 ` Paul Durrant
2023-09-18 11:21 ` [PATCH v2 12/12] KVM: xen: advertize the KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA capability Paul Durrant
2023-09-18 13:22 ` David Woodhouse
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=f5eab713-fa74-2cbc-7df5-81d8d26fee0a@xen.org \
--to=xadimgnik@gmail.com \
--cc=dwmw2@infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=pdurrant@amazon.com \
--cc=seanjc@google.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
all inboxes | Powered by JetHome®