From: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: "kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
"maz@kernel.org" <maz@kernel.org>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"will@kernel.org" <will@kernel.org>,
"mark.rutland@arm.com" <mark.rutland@arm.com>,
"cohuck@redhat.com" <cohuck@redhat.com>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
yuzenghui <yuzenghui@huawei.com>,
"Wangzhou (B)" <wangzhou1@hisilicon.com>,
jiangkunkun <jiangkunkun@huawei.com>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Anthony Jebson <anthony.jebson@huawei.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Linuxarm <linuxarm@huawei.com>
Subject: RE: [RFC PATCH v2 1/3] KVM: arm64: Add hypercall support for retrieving migration targets
Date: Tue, 29 Oct 2024 16:00:39 +0000 [thread overview]
Message-ID: <d97cd23a1962460990a642ee8a653d2f@huawei.com> (raw)
In-Reply-To: <ZxrzhAh3qE9hLV-U@linux.dev>
Hi Oliver,
> -----Original Message-----
> From: Oliver Upton <oliver.upton@linux.dev>
> Sent: Friday, October 25, 2024 2:25 AM
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
> Cc: kvmarm@lists.linux.dev; maz@kernel.org; catalin.marinas@arm.com;
> will@kernel.org; mark.rutland@arm.com; cohuck@redhat.com;
> eric.auger@redhat.com; yuzenghui <yuzenghui@huawei.com>; Wangzhou
> (B) <wangzhou1@hisilicon.com>; jiangkunkun <jiangkunkun@huawei.com>;
> Jonathan Cameron <jonathan.cameron@huawei.com>; Anthony Jebson
> <anthony.jebson@huawei.com>; linux-arm-kernel@lists.infradead.org;
> Linuxarm <linuxarm@huawei.com>
> Subject: Re: [RFC PATCH v2 1/3] KVM: arm64: Add hypercall support for
> retrieving migration targets
>
> Hi,
>
> On Thu, Oct 24, 2024 at 10:40:10AM +0100, Shameer Kolothum wrote:
> > +``ARM_SMCCC_VENDOR_HYP_KVM_MIGRN_TARGET_NUM_FUNC_ID``
> > +------------------------------------------------------
> > +
> > +Query total number of migration target CPUs the Guest VM will be
> running during its
> > +lifetime and version information applicable to the data format used for
> > +``ARM_SMCCC_VENDOR_HYP_KVM_MIGRN_TARGET_CPUS_FUNC_ID``.
> The maximum number of targets
> > +supported is 64. Also the version number supported currently is 1.0. This
> hypercall
> > +must be handled by the userspace VMM.
> > +
> > ++---------------------+-------------------------------------------------------------+
> > +| Presence: | Optional; KVM/ARM64 Guests only |
> > ++---------------------+-------------------------------------------------------------+
> > +| Calling convention: | HVC64 |
> > ++---------------------+----------+--------------------------------------------------+
> > +| Function ID: | (uint32) | 0xC600007D |
> > ++---------------------+----------+--------------------------------------------------+
> > +| Arguments: | None |
> > ++---------------------+----------+----+---------------------------------------------+
> > +| Return Values: | (int64) | R0 | ``NOT_SUPPORTED (-1)`` on error,
> else |
> > +| | | | [0-31] total migration targets |
> > +| | | | [32-63] version number |
> > ++---------------------+----------+----+---------------------------------------------+
>
> We can't treat a single register as both a signed quantity *and* a full
> 64 bits of bitfields. Maybe just scrap the version and have this thing
> either return a negative error or positive quantity of implementations.
Ok. I had a look at PV_TIME_ST/ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID
and got that idea. Separate registers make sense though.
Do we really need to skip the version number? The idea was to use that as a
future proof for data format in case we realize that MIDR/REVIDR is not good
enough for errata later.
>
> > +``ARM_SMCCC_VENDOR_HYP_KVM_MIGRN_TARGET_CPUS_FUNC_ID``
> > +-------------------------------------------------------
> > +
> > +Request migration target CPU information for the Guest VM. The
> information must be
> > +provided as per the format described by the version info in
> > +``ARM_SMCCC_VENDOR_HYP_KVM_MIGRN_TARGET_NUM_FUNC_ID``.
> At present, we only support
> > +the below format which corresponds to version 1.0. This hypercall will
> always be
> > +preceded by
> ``ARM_SMCCC_VENDOR_HYP_KVM_MIGRN_TARGET_NUM_FUNC_ID`` and
> may be
> > +invoked multiple times to retrieve the total number of target CPUs
> information
> > +advertised. This hypercall must be handled by the userspace VMM.
> > +
> > +A typical userspace usage scenario will be like below:
> > +
> > +1. Receives
> ``ARM_SMCCC_VENDOR_HYP_KVM_MIGRN_TARGET_NUM_FUNC_ID``
> > +
> > + * Returns total number of migration targets and version number
> > + * Reset current target index to zero
> > +2. Receives
> ``ARM_SMCCC_VENDOR_HYP_KVM_MIGRN_TARGET_CPUS_FUNC_ID``
> > +
> > + * Returns MIDR/REVIDR info in return register fields. Can return up to
> 4
> > + * Update current target index based on returned target info
> > + * If there are remaining register fields, return zero to indicate the end
> > + * Repeat step 2 until current target index == total number of migration
> targets
>
> Hmm... I'd rather we make the guest supply the target index of the
> implementation it wants to discover. Otherwise, the VMM implementation
> of this hypercall interface is *stateful* and needs to remember to
> migrate that...
Ok. I had the same feedback from Jonathan in an internal discussion as well
and on re-reading Marc's comments on v1, he also had the same suggestion
that I missed. Will change that.
> > ++---------------------+-------------------------------------------------------------+
> > +| Presence: | Optional; KVM/ARM64 Guests only |
> > ++---------------------+-------------------------------------------------------------+
> > +| Calling convention: | HVC64 |
> > ++---------------------+----------+--------------------------------------------------+
> > +| Function ID: | (uint32) | 0xC600007E |
> > ++---------------------+----------+----+---------------------------------------------+
> > +| Arguments: | None |
> > ++---------------------+----------+----+---------------------------------------------+
> > +| Return Values: | (int64) | R0 | ``NOT_SUPPORTED (-1)`` on error,
> else |
> > +| | | | [0-31] MIDR, [31-63] REVIDR, else |
> > +| | | | [0-63] Zero to mark end. |
> > ++---------------------+----------+----+---------------------------------------------+
>
> Same deal here, x0 needs to always be treated as a signed quantity.
>
> How about -1 on error, 0 on success?
>
> Then, in the remaining registers:
>
> > +| | (uint64) | R1 | [0-31] MIDR, [32-63] REVIDR, else |
> > +| | | | [0-63] Zero to mark end. |
> > ++---------------------+----------+----+---------------------------------------------+
>
> Both MIDR_EL1 and REVIDR_EL1 are 64 bit registers in AArch64. So we need
> to transfer a full 64 bits, even if the top half is _presently_ RES0 in
> MIDR_EL1.
Ok.
>
> > +| | (uint64) | R2 | [0-31] MIDR, [32-63] REVIDR, else |
> > +| | | | [0-63] Zero to mark end. |
> > ++---------------------+----------+----+---------------------------------------------+
> > +| | (uint64) | R3 | [0-31] MIDR, [32-63] REVIDR, else |
> > +| | | | [0-63] Zero to mark end. |
> > ++---------------------+----------+----+---------------------------------------------+
>
> I think it's fine to have this hypercall return a single MIDR/REVIDR
> pair at a time. This is not a performance sensitive interface and will
> only be called a few times at boot.
>
> Actually -- what if we crammed everything into a single hypercall?
>
> DISCOVER_IMPLEMENTATION_FUNC_ID
>
> - Arguments:
> - arg0: selected implementation index
>
> - Return value:
> - r0: -1 on error, otherwise the maximum possible implementation index
> - r1: MIDR_EL1 of the selected implementation
> - r2: REVIDR_EL1 of the selected implementation
>
> We're guaranteed at least one CPU implementation of course, so the guest
> can just start w/ index 0 and iterate from there.
Ok. I will rework based on these and will sent out something soon.
Thanks,
Shameer
next prev parent reply other threads:[~2024-10-29 17:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 9:40 [RFC PATCH v2 0/3] KVM: arm64: Errata management for VM Live migration Shameer Kolothum
2024-10-24 9:40 ` [RFC PATCH v2 1/3] KVM: arm64: Add hypercall support for retrieving migration targets Shameer Kolothum
2024-10-25 1:25 ` Oliver Upton
2024-10-29 16:00 ` Shameerali Kolothum Thodi [this message]
2024-10-30 4:39 ` Oliver Upton
2024-10-24 9:40 ` [RFC PATCH v2 2/3] KVM: arm64: Use hypercall to retrieve any " Shameer Kolothum
2024-10-24 9:40 ` [RFC PATCH v2 3/3] KVM: arm64: Enable errata based on migration target CPUs Shameer Kolothum
2024-10-25 1:36 ` Oliver Upton
2024-10-28 17:29 ` Shameerali Kolothum Thodi
2024-10-30 4:33 ` Oliver Upton
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=d97cd23a1962460990a642ee8a653d2f@huawei.com \
--to=shameerali.kolothum.thodi@huawei.com \
--cc=anthony.jebson@huawei.com \
--cc=catalin.marinas@arm.com \
--cc=cohuck@redhat.com \
--cc=eric.auger@redhat.com \
--cc=jiangkunkun@huawei.com \
--cc=jonathan.cameron@huawei.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=wangzhou1@hisilicon.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.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;
as well as URLs for NNTP newsgroup(s).