From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <c.dall@virtualopensystems.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>,
Christoffer Dall <cdall@cs.columbia.edu>,
"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [kvmarm] [PATCH v2 2/2] ARM: KVM: Power State Coordination Interface implementation
Date: Fri, 11 Jan 2013 17:43:11 +0000 [thread overview]
Message-ID: <50F04F2F.80306@arm.com> (raw)
In-Reply-To: <CANM98qJ2ZSwxMWFRWiunTQtoV7iFb3fn3Cf6VWvOndBcU=+Tmg@mail.gmail.com>
On 11/01/13 17:33, Christoffer Dall wrote:
> On Fri, Jan 11, 2013 at 12:24 PM, Marc Zyngier <marc.zyngier@arm.com> wrote:
>> On 11/01/13 17:12, Russell King - ARM Linux wrote:
>>> On Thu, Jan 10, 2013 at 04:06:45PM +0000, Marc Zyngier wrote:
>>>> +int kvm_psci_call(struct kvm_vcpu *vcpu)
>>>> +{
>>>> + unsigned long psci_fn = *vcpu_reg(vcpu, 0) & ~((u32) 0);
>>>> + unsigned long val;
>>>> +
>>>> + switch (psci_fn) {
>>>> + case KVM_PSCI_FN_CPU_OFF:
>>>> + kvm_psci_vcpu_off(vcpu);
>>>> + val = KVM_PSCI_RET_SUCCESS;
>>>> + break;
>>>> + case KVM_PSCI_FN_CPU_ON:
>>>> + val = kvm_psci_vcpu_on(vcpu);
>>>> + break;
>>>> + case KVM_PSCI_FN_CPU_SUSPEND:
>>>> + case KVM_PSCI_FN_MIGRATE:
>>>> + val = KVM_PSCI_RET_NI;
>>>> + break;
>>>> +
>>>> + default:
>>>> + return -1;
>>>> + }
>>>> +
>>>> + *vcpu_reg(vcpu, 0) = val;
>>>> + return 0;
>>>> +}
>>>
>>> We were discussing recently on #kernel about kernel APIs and the way that
>>> our integer-returning functions pretty much use 0 for success, and -errno
>>> for failures, whereas our pointer-returning functions are a mess.
>>>
>>> And above we have something returning -1 to some other chunk of code outside
>>> this compilation unit. That doesn't sound particularly clever to me.
>>
>> The original code used to return -EINVAL, see:
>> https://lists.cs.columbia.edu/pipermail/kvmarm/2013-January/004509.html
>>
>> Christoffer (Cc-ed) didn't like this, hence the -1. I'm happy to revert
>> the code to its original state though.
>>
> I don't want to return -EINVAL, because for the rest of the KVM code
> this would mean kill the guest.
>
> The convention used in other archs of KVM as well as for ARM is that
> the handle_exit functions return:
>
> -ERRNO: Error, report this error to user space
> 0: Everything is fine, but return to user space to let it do I/O
> emulation and whatever it wants to do
> 1: Everything is fine, return directly to the guest without going to user space
That is assuming we propagate the handle_exit convention down to the
leaf calls, and I object to that. The 3 possible values only apply to
handle_exit, and we should keep that convention as local as possible,
because this is the odd case.
> And then you do:
> if (handle_something() == 0)
> return 1;
>
> which I thought was confusing, so I said make the function a bool, to
> avoid the confusion, like Rusty did for all the coprocessor emulation
> functions.
I don't see a compelling reason to propagate this convention to areas
that do not require it. In the PSCI case, we have a basic
handled/not-handled state, the later indicating the reason. The exit
handling functions can convert the error codes to whatever the run loop
requires.
> There are obviously other ways to handle the "return 1" case, like
> having an extra state that you carry around, and we can change all the
> code to do that, but I just don't think it's worth it, as we are in
> fact quite close to the existing kernel API.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2013-01-11 17:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-10 16:06 [PATCH v2 0/2] KVM/ARM implementation of PSCI Marc Zyngier
2013-01-10 16:06 ` [PATCH v2 1/2] ARM: KVM: move one-time init to its own function Marc Zyngier
2013-01-10 16:06 ` [PATCH v2 2/2] ARM: KVM: Power State Coordination Interface implementation Marc Zyngier
2013-01-11 17:12 ` Russell King - ARM Linux
2013-01-11 17:24 ` Marc Zyngier
2013-01-11 17:33 ` [kvmarm] " Christoffer Dall
2013-01-11 17:40 ` Russell King - ARM Linux
2013-01-11 17:43 ` Marc Zyngier [this message]
2013-01-11 17:48 ` Christoffer Dall
2013-01-11 17:57 ` Russell King - ARM Linux
2013-01-11 18:07 ` Christoffer Dall
2013-01-11 18:14 ` Russell King - ARM Linux
2013-01-11 18:15 ` Christoffer Dall
2013-01-11 18:09 ` Marc Zyngier
2013-01-11 18:18 ` Christoffer Dall
2013-01-10 17:51 ` [kvmarm] [PATCH v2 0/2] KVM/ARM implementation of PSCI Christoffer Dall
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=50F04F2F.80306@arm.com \
--to=marc.zyngier@arm.com \
--cc=c.dall@virtualopensystems.com \
--cc=cdall@cs.columbia.edu \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux@arm.linux.org.uk \
/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