lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <89a8002f-a9b0-1864-a568-36285eb2c485@arm.com>
Date:   Mon, 21 Oct 2019 12:24:19 +0100
From:   Steven Price <steven.price@....com>
To:     Marc Zyngier <maz@...nel.org>
Cc:     Mark Rutland <mark.rutland@....com>,
        Radim Krčmář <rkrcmar@...hat.com>,
        kvm@...r.kernel.org, Suzuki K Pouloze <suzuki.poulose@....com>,
        Catalin Marinas <catalin.marinas@....com>,
        linux-doc@...r.kernel.org, Russell King <linux@...linux.org.uk>,
        linux-kernel@...r.kernel.org, James Morse <james.morse@....com>,
        linux-arm-kernel@...ts.infradead.org,
        Paolo Bonzini <pbonzini@...hat.com>,
        Will Deacon <will@...nel.org>, kvmarm@...ts.cs.columbia.edu,
        Julien Thierry <julien.thierry.kdev@...il.com>
Subject: Re: [PATCH v6 05/10] KVM: arm64: Support stolen time reporting via
 shared structure

On 21/10/2019 11:40, Marc Zyngier wrote:
> 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@....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@....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.

Ok, fair enough. Although it ends up with this strange looking fragment
in kvm_hvc_call_handler():

	case ARM_SMCCC_HV_PV_TIME_ST:
		gpa = kvm_init_stolen_time(vcpu);
		if (gpa != GPA_INVALID)
			val = gpa;
		break;

But I agree the gpa_t return type is clearer.

Thanks,

Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ