All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Steven Price <steven.price@arm.com>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
	kvm@vger.kernel.org, "Radim Krčmář" <rkrcmar@redhat.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Suzuki K Pouloze" <suzuki.poulose@arm.com>,
	linux-doc@vger.kernel.org, "Russell King" <linux@armlinux.org.uk>,
	linux-kernel@vger.kernel.org, "James Morse" <james.morse@arm.com>,
	"Julien Thierry" <julien.thierry.kdev@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Will Deacon" <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v6 05/10] KVM: arm64: Support stolen time reporting via  shared structure
Date: Mon, 21 Oct 2019 11:40:15 +0100	[thread overview]
Message-ID: <cc639f743d621198ef02f880089bb54d@www.loen.fr> (raw)
In-Reply-To: <1bb10eb5-0fe8-57c9-3b67-9b3661a73d29@arm.com>

On 2019-10-21 11:21, Steven Price wrote:
> On 19/10/2019 12:12, Marc Zyngier wrote:
>> On Fri, 11 Oct 2019 13:59:25 +0100,
>> Steven Price <steven.price@arm.com> wrote:
>>>
>>> Implement the service call for configuring a shared structure 
>>> between a
>>> VCPU and the hypervisor in which the hypervisor can write the time
>>> stolen from the VCPU's execution time by other tasks on the host.
>>>
>>> User space allocates memory which is placed at an IPA also chosen 
>>> by user
>>> space. The hypervisor then updates the shared structure using
>>> kvm_put_guest() to ensure single copy atomicity of the 64-bit value
>>> reporting the stolen time in nanoseconds.
>>>
>>> Whenever stolen time is enabled by the guest, the stolen time 
>>> counter is
>>> reset.
>>>
>>> The stolen time itself is retrieved from the sched_info structure
>>> maintained by the Linux scheduler code. We enable SCHEDSTATS when
>>> selecting KVM Kconfig to ensure this value is meaningful.
>>>
>>> Signed-off-by: Steven Price <steven.price@arm.com>
>>> ---
>>>  arch/arm/include/asm/kvm_host.h   | 20 +++++++++++
>>>  arch/arm64/include/asm/kvm_host.h | 21 +++++++++++-
>>>  arch/arm64/kvm/Kconfig            |  1 +
>>>  include/linux/kvm_types.h         |  2 ++
>>>  virt/kvm/arm/arm.c                | 11 ++++++
>>>  virt/kvm/arm/hypercalls.c         |  3 ++
>>>  virt/kvm/arm/pvtime.c             | 56 
>>> +++++++++++++++++++++++++++++++
>>>  7 files changed, 113 insertions(+), 1 deletion(-)

[...]

>>> +long kvm_hypercall_stolen_time(struct kvm_vcpu *vcpu)
>>
>> Why long? If that's a base address, then it is either a phys_addr_t 
>> or
>> a gpa_t. I'd suggest you move the error check to the caller.
>
> This is a bit more tricky. It's a long because that's the declared 
> type
> of the SMCCC return in kvm_hvc_call_handler(). I can't (easily) move 
> the
> code into kvm_hvc_call_handler() because that is compiled for arm (as
> well as arm64) and we don't have the definitions for stolen time 
> there.
> The best option I could come up with is to have a dummy stub for arm 
> and
> use generic types for this function.
>
> This means we need a type which can contain both a gpa_t and the
> SMCCC_RET_NOT_SUPPORTED error code.
>
> I'm open to alternative suggestions on how to make this work.

My suggestion would be to always return a gpa_t from this function, and
change the 32bit stub for kvm_hypercall_stolen_time() to always return
GPA_INVALID.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Steven Price <steven.price@arm.com>
Cc: kvm@vger.kernel.org, Catalin Marinas <catalin.marinas@arm.com>,
	linux-doc@vger.kernel.org, Russell King <linux@armlinux.org.uk>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Will Deacon <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH v6 05/10] KVM: arm64: Support stolen time reporting via shared structure
Date: Mon, 21 Oct 2019 11:40:15 +0100	[thread overview]
Message-ID: <cc639f743d621198ef02f880089bb54d@www.loen.fr> (raw)
In-Reply-To: <1bb10eb5-0fe8-57c9-3b67-9b3661a73d29@arm.com>

On 2019-10-21 11:21, Steven Price wrote:
> On 19/10/2019 12:12, Marc Zyngier wrote:
>> On Fri, 11 Oct 2019 13:59:25 +0100,
>> Steven Price <steven.price@arm.com> wrote:
>>>
>>> Implement the service call for configuring a shared structure 
>>> between a
>>> VCPU and the hypervisor in which the hypervisor can write the time
>>> stolen from the VCPU's execution time by other tasks on the host.
>>>
>>> User space allocates memory which is placed at an IPA also chosen 
>>> by user
>>> space. The hypervisor then updates the shared structure using
>>> kvm_put_guest() to ensure single copy atomicity of the 64-bit value
>>> reporting the stolen time in nanoseconds.
>>>
>>> Whenever stolen time is enabled by the guest, the stolen time 
>>> counter is
>>> reset.
>>>
>>> The stolen time itself is retrieved from the sched_info structure
>>> maintained by the Linux scheduler code. We enable SCHEDSTATS when
>>> selecting KVM Kconfig to ensure this value is meaningful.
>>>
>>> Signed-off-by: Steven Price <steven.price@arm.com>
>>> ---
>>>  arch/arm/include/asm/kvm_host.h   | 20 +++++++++++
>>>  arch/arm64/include/asm/kvm_host.h | 21 +++++++++++-
>>>  arch/arm64/kvm/Kconfig            |  1 +
>>>  include/linux/kvm_types.h         |  2 ++
>>>  virt/kvm/arm/arm.c                | 11 ++++++
>>>  virt/kvm/arm/hypercalls.c         |  3 ++
>>>  virt/kvm/arm/pvtime.c             | 56 
>>> +++++++++++++++++++++++++++++++
>>>  7 files changed, 113 insertions(+), 1 deletion(-)

[...]

>>> +long kvm_hypercall_stolen_time(struct kvm_vcpu *vcpu)
>>
>> Why long? If that's a base address, then it is either a phys_addr_t 
>> or
>> a gpa_t. I'd suggest you move the error check to the caller.
>
> This is a bit more tricky. It's a long because that's the declared 
> type
> of the SMCCC return in kvm_hvc_call_handler(). I can't (easily) move 
> the
> code into kvm_hvc_call_handler() because that is compiled for arm (as
> well as arm64) and we don't have the definitions for stolen time 
> there.
> The best option I could come up with is to have a dummy stub for arm 
> and
> use generic types for this function.
>
> This means we need a type which can contain both a gpa_t and the
> SMCCC_RET_NOT_SUPPORTED error code.
>
> I'm open to alternative suggestions on how to make this work.

My suggestion would be to always return a gpa_t from this function, and
change the 32bit stub for kvm_hypercall_stolen_time() to always return
GPA_INVALID.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Steven Price <steven.price@arm.com>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	kvm@vger.kernel.org, "Suzuki K Pouloze" <suzuki.poulose@arm.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	linux-doc@vger.kernel.org, "Russell King" <linux@armlinux.org.uk>,
	linux-kernel@vger.kernel.org, "James Morse" <james.morse@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Will Deacon" <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu,
	"Julien Thierry" <julien.thierry.kdev@gmail.com>
Subject: Re: [PATCH v6 05/10] KVM: arm64: Support stolen time reporting via shared structure
Date: Mon, 21 Oct 2019 11:40:15 +0100	[thread overview]
Message-ID: <cc639f743d621198ef02f880089bb54d@www.loen.fr> (raw)
In-Reply-To: <1bb10eb5-0fe8-57c9-3b67-9b3661a73d29@arm.com>

On 2019-10-21 11:21, Steven Price wrote:
> On 19/10/2019 12:12, Marc Zyngier wrote:
>> On Fri, 11 Oct 2019 13:59:25 +0100,
>> Steven Price <steven.price@arm.com> wrote:
>>>
>>> Implement the service call for configuring a shared structure 
>>> between a
>>> VCPU and the hypervisor in which the hypervisor can write the time
>>> stolen from the VCPU's execution time by other tasks on the host.
>>>
>>> User space allocates memory which is placed at an IPA also chosen 
>>> by user
>>> space. The hypervisor then updates the shared structure using
>>> kvm_put_guest() to ensure single copy atomicity of the 64-bit value
>>> reporting the stolen time in nanoseconds.
>>>
>>> Whenever stolen time is enabled by the guest, the stolen time 
>>> counter is
>>> reset.
>>>
>>> The stolen time itself is retrieved from the sched_info structure
>>> maintained by the Linux scheduler code. We enable SCHEDSTATS when
>>> selecting KVM Kconfig to ensure this value is meaningful.
>>>
>>> Signed-off-by: Steven Price <steven.price@arm.com>
>>> ---
>>>  arch/arm/include/asm/kvm_host.h   | 20 +++++++++++
>>>  arch/arm64/include/asm/kvm_host.h | 21 +++++++++++-
>>>  arch/arm64/kvm/Kconfig            |  1 +
>>>  include/linux/kvm_types.h         |  2 ++
>>>  virt/kvm/arm/arm.c                | 11 ++++++
>>>  virt/kvm/arm/hypercalls.c         |  3 ++
>>>  virt/kvm/arm/pvtime.c             | 56 
>>> +++++++++++++++++++++++++++++++
>>>  7 files changed, 113 insertions(+), 1 deletion(-)

[...]

>>> +long kvm_hypercall_stolen_time(struct kvm_vcpu *vcpu)
>>
>> Why long? If that's a base address, then it is either a phys_addr_t 
>> or
>> a gpa_t. I'd suggest you move the error check to the caller.
>
> This is a bit more tricky. It's a long because that's the declared 
> type
> of the SMCCC return in kvm_hvc_call_handler(). I can't (easily) move 
> the
> code into kvm_hvc_call_handler() because that is compiled for arm (as
> well as arm64) and we don't have the definitions for stolen time 
> there.
> The best option I could come up with is to have a dummy stub for arm 
> and
> use generic types for this function.
>
> This means we need a type which can contain both a gpa_t and the
> SMCCC_RET_NOT_SUPPORTED error code.
>
> I'm open to alternative suggestions on how to make this work.

My suggestion would be to always return a gpa_t from this function, and
change the 32bit stub for kvm_hypercall_stolen_time() to always return
GPA_INVALID.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-10-21 10:40 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 12:59 [PATCH v6 00/10] arm64: Stolen time support Steven Price
2019-10-11 12:59 ` Steven Price
2019-10-11 12:59 ` Steven Price
2019-10-11 12:59 ` [PATCH v6 01/10] KVM: arm64: Document PV-time interface Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-15 17:56   ` Mark Rutland
2019-10-17  9:40     ` Steven Price
2019-10-18 17:10     ` Mark Rutland
2019-10-21 13:40       ` Steven Price
2019-10-21 14:38         ` Mark Rutland
2019-10-11 12:59 ` [PATCH v6 02/10] KVM: arm/arm64: Factor out hypercall handling from PSCI code Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59 ` [PATCH v6 03/10] KVM: arm64: Implement PV_TIME_FEATURES call Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59 ` [PATCH v6 04/10] KVM: Implement kvm_put_guest() Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59 ` [PATCH v6 05/10] KVM: arm64: Support stolen time reporting via shared structure Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-19 11:12   ` Marc Zyngier
2019-10-19 11:12     ` Marc Zyngier
2019-10-19 11:12     ` Marc Zyngier
2019-10-21 10:21     ` Steven Price
2019-10-21 10:21       ` Steven Price
2019-10-21 10:21       ` Steven Price
2019-10-21 10:40       ` Marc Zyngier [this message]
2019-10-21 10:40         ` Marc Zyngier
2019-10-21 10:40         ` Marc Zyngier
2019-10-21 11:24         ` Steven Price
2019-10-21 11:24           ` Steven Price
2019-10-21 11:24           ` Steven Price
2019-10-11 12:59 ` [PATCH v6 06/10] KVM: Allow kvm_device_ops to be const Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59 ` [PATCH v6 07/10] KVM: arm64: Provide VCPU attributes for stolen time Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-19 11:28   ` Marc Zyngier
2019-10-19 11:28     ` Marc Zyngier
2019-10-19 11:28     ` Marc Zyngier
2019-10-21 11:00     ` Steven Price
2019-10-21 11:00       ` Steven Price
2019-10-21 11:00       ` Steven Price
2019-10-11 12:59 ` [PATCH v6 08/10] arm/arm64: Provide a wrapper for SMCCC 1.1 calls Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-21 11:42   ` Marc Zyngier
2019-10-21 11:42     ` Marc Zyngier
2019-10-21 11:42     ` Marc Zyngier
2019-10-21 13:43     ` Steven Price
2019-10-21 13:43       ` Steven Price
2019-10-21 13:43       ` Steven Price
2019-10-21 14:05       ` Marc Zyngier
2019-10-21 14:05         ` Marc Zyngier
2019-10-21 14:05         ` Marc Zyngier
2019-10-11 12:59 ` [PATCH v6 09/10] arm/arm64: Make use of the SMCCC 1.1 wrapper Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59 ` [PATCH v6 10/10] arm64: Retrieve stolen time as paravirtualized guest Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-11 12:59   ` Steven Price
2019-10-19 20:28   ` Marc Zyngier
2019-10-19 20:28     ` Marc Zyngier
2019-10-19 20:28     ` Marc Zyngier
2019-10-21  5:01     ` Jürgen Groß
2019-10-21  5:01       ` Jürgen Groß
2019-10-21  5:01       ` Jürgen Groß
2019-10-21  7:55       ` Marc Zyngier
2019-10-21  7:55         ` Marc Zyngier
2019-10-21  7:55         ` Marc Zyngier
2019-10-21 12:14     ` Steven Price
2019-10-21 12:14       ` Steven Price
2019-10-21 12:14       ` Steven Price

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=cc639f743d621198ef02f880089bb54d@www.loen.fr \
    --to=maz@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=steven.price@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.