Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Steal Time support in ARM #4866

Open
3 tasks done
Manciukic opened this issue Oct 22, 2024 · 2 comments
Open
3 tasks done

[Feature Request] Steal Time support in ARM #4866

Manciukic opened this issue Oct 22, 2024 · 2 comments
Labels
Good first issue Indicates a good issue for first-time contributors Priority: Medium Indicates than an issue or pull request should be resolved ahead of issues or pull requests labelled rust Pull requests that update Rust code Status: Parked Indicates that an issues or pull request will be revisited later Type: Enhancement Indicates new feature requests

Comments

@Manciukic
Copy link
Contributor

Feature Request

PV Steal Time reporting on ARM is available in KVM since 5.10 at least but Firecracker doesn't enable it.

Describe the desired solution

We could enable the PVTIME device in Firecracker on ARM to allow for stolen time reporting.

Describe possible alternatives

  • check if rust-vmm has some off-the-shelf implementation we could use

Additional context

I found that this is the KVM patch that introduced it: https://lwn.net/Articles/797954/
And this is how QEMU integrated with it: https://patchew.org/QEMU/[email protected]/[email protected]/

It needs to be enabled via ioctl to the vcpu fd, there's an example in the kernel self tests: https://github.com/amazonlinux/linux/blob/kernel-5.10.215-203.850.amzn2/tools/testing/selftests/kvm/steal_time.c#L172

static void steal_time_init(struct kvm_vm *vm)
{
        struct kvm_device_attr dev = {
                .group = KVM_ARM_VCPU_PVTIME_CTRL,
                .attr = KVM_ARM_VCPU_PVTIME_IPA,
        };
        int i, ret;

        ret = _vcpu_ioctl(vm, 0, KVM_HAS_DEVICE_ATTR, &dev);
        if (ret != 0 && errno == ENXIO) {
                print_skip("steal-time not supported");
                exit(KSFT_SKIP);
        }

        for (i = 0; i < NR_VCPUS; ++i) {
                uint64_t st_ipa;

                vcpu_ioctl(vm, i, KVM_HAS_DEVICE_ATTR, &dev);

                dev.addr = (uint64_t)&st_ipa;

                /* ST_GPA_BASE is identity mapped */
                st_gva[i] = (void *)(ST_GPA_BASE + i * STEAL_TIME_SIZE);
                sync_global_to_guest(vm, st_gva[i]);

                st_ipa = (ulong)st_gva[i] | 1;
                ret = _vcpu_ioctl(vm, i, KVM_SET_DEVICE_ATTR, &dev);
                TEST_ASSERT(ret == -1 && errno == EINVAL, "Bad IPA didn't report EINVAL");

                st_ipa = (ulong)st_gva[i];
                vcpu_ioctl(vm, i, KVM_SET_DEVICE_ATTR, &dev);

                ret = _vcpu_ioctl(vm, i, KVM_SET_DEVICE_ATTR, &dev);
                TEST_ASSERT(ret == -1 && errno == EEXIST, "Set IPA twice without EEXIST");

        }
}

Checks

  • Have you searched the Firecracker Issues database for similar requests?
  • Have you read all the existing relevant Firecracker documentation?
  • Have you read and understood Firecracker's core tenets?
@Manciukic Manciukic added Good first issue Indicates a good issue for first-time contributors Priority: Medium Indicates than an issue or pull request should be resolved ahead of issues or pull requests labelled Type: Enhancement Indicates new feature requests rust Pull requests that update Rust code labels Oct 22, 2024
@roypat
Copy link
Contributor

roypat commented Oct 22, 2024

Describe possible alternatives

* check if `rust-vmm` has some off-the-shelf implementation we could use

we definitely have KVM_{GET,SET}_DEVICE_ATTR ioctls in kvm-ioctls :)

@kalyazin kalyazin added the Status: Parked Indicates that an issues or pull request will be revisited later label Oct 23, 2024
@aerosouund
Copy link

Hello @Manciukic

I'd like to take this up please
While i am aware that my current competencies don't fully match whats needed to solve this, however i am ramping up my knowledge of rust and linux to eventually solve it
And i can see that it is parked, I assume this means you don't need a very quick solution. If thats ok and no one else is working on it please assign it to me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Indicates a good issue for first-time contributors Priority: Medium Indicates than an issue or pull request should be resolved ahead of issues or pull requests labelled rust Pull requests that update Rust code Status: Parked Indicates that an issues or pull request will be revisited later Type: Enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

4 participants