From: Scott Wood <scottwood@freescale.com>
To: Alexander Graf <agraf@suse.de>
Cc: <kvm-ppc@vger.kernel.org>, <kvm@vger.kernel.org>,
<linuxppc-dev@lists.ozlabs.org>
Subject: Re: [RFC PATCH 14/16] KVM: PPC: booke: category E.HV (GS-mode) support
Date: Tue, 10 Jan 2012 16:03:29 -0600 [thread overview]
Message-ID: <4F0CB5B1.6010601@freescale.com> (raw)
In-Reply-To: <A1483A2E-FF86-4E25-93CC-9EA1BA4925D4@suse.de>
On 01/09/2012 09:11 PM, Alexander Graf wrote:
> On 10.01.2012, at 01:51, Scott Wood wrote:
>> On 01/09/2012 11:46 AM, Alexander Graf wrote:
>>> On 21.12.2011, at 02:34, Scott Wood wrote:
>>>> + /* For debugging, encode the failing instruction and
>>>> + * report it to userspace. */
>>>> + run->hw.hardware_exit_reason = ~0ULL << 32;
>>>> + run->hw.hardware_exit_reason |= vcpu->arch.last_inst;
>>>
>>>
>>> I'm fairly sure you want to fix this :)
>>
>> Likewise, that's what booke.c already does. What should it do instead?
>
> This is what book3s does:
>
> case EMULATE_FAIL:
> printk(KERN_CRIT "%s: emulation at %lx failed (%08x)\n",
> __func__, kvmppc_get_pc(vcpu), kvmppc_get_last_inst(vcpu));
> kvmppc_core_queue_program(vcpu, flags);
> r = RESUME_GUEST;
>
> which also doesn't throttle the printk, but I think injecting a
> program fault into the guest is the most sensible thing to do if we
> don't know what the instruction is supposed to do. Best case we get
> an oops inside the guest telling us what broke :).
Ah, yes, it should send a program check.
>>> Ah, so that's what you want to use regs for. So is having a pt_regs
>>> struct that only contains useful register values in half its fields
>>> any useful here? Or could we keep control of the registers ourselves,
>>> enabling us to maybe one day optimize things more.
>>
>> I think it contains enough to be useful for debugging code such as sysrq
>> and tracers, and as noted in the comment we could copy the rest if we
>> care enough. MSR might be worth copying.
>>
>> It will eventually be used for machine checks as well, which I'd like to
>> hand reasonable register state to, at least for GPRs, LR, and PC.
>>
>> If there's a good enough performance reason, we could just copy
>> everything over for machine checks and pass NULL to do_IRQ (I think it
>> can take this -- a dummy regs struct if not), but it seems premature at
>> the moment unless the switch already causes measured performance loss
>> (cache utilization?).
>
> I'm definitely not concerned about performance, but complexity and uniqueness.
>
> With the pt_regs struct, we have a bunch of fields in the vcpu that are there, but unused. I find that situation pretty confusing.
I removed the registers from the vcpu, that are to be used in regs instead.
There are a few fields in regs that are not valid, though it is
explicitly pointed out via a comment.
> So yes, I would definitely prefer to copy registers during MC and keep the registers where they are today - unless there are SPRs for them of course.
>
> Imagine we'd one day want to share GPRs with user space through the
> kvm_run structure (see the s390 patches on the ML for this). I really
> wouldn't want to make pt_regs part of our userspace ABI.
Neither would I. If that's something that's reasonably likely to
happen, I guess that's a good enough reason to avoid this. We could
always add later a debug option to copy regs even on normal interrupts,
if needed.
>> We probably should defer the check until after we've disabled
>> interrupts, similar to signals -- even if we didn't exit for an
>> interrupt, we could have received one after enabling them.
>
> Yup. I just don't think you can call resched() with interrupts disabled, so a bit cleverness is probably required here.
I think it is actually allowed, but interrupts will be enabled on
return. We'll need to repeat prepare_to_enter if we do schedule. Since
we already need special handling for that, we might as well add a
local_irq_enable() once we know we are going to schedule, just in case.
>>>> diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
>>>> index 05d1d99..d53bcf2 100644
>>>> --- a/arch/powerpc/kvm/booke.h
>>>> +++ b/arch/powerpc/kvm/booke.h
>>>> @@ -48,7 +48,20 @@
>>>> #define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19
>>>> /* Internal pseudo-irqprio for level triggered externals */
>>>> #define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
>>>> -#define BOOKE_IRQPRIO_MAX 20
>>>> +#define BOOKE_IRQPRIO_DBELL 21
>>>> +#define BOOKE_IRQPRIO_DBELL_CRIT 22
>>>> +#define BOOKE_IRQPRIO_MAX 23
>>>
>>> So was MAX wrong before or is it too big now?
>>
>> MAX is just a marker for how many IRQPRIOs we have, not any sort of
>> external limit. This patch adds new IRQPRIOs, so MAX goes up.
>>
>> The actual limit is the number of bits in a long.
>
> Yes, and before the highest value was 20 with MAX being 20, now the
> highest value is 22 with MAX being 23. Either MAX == highest number
> or MAX == highest number + 1, but you're changing the semantics of
> MAX here. Maybe it was wrong before, I don't know, hence I'm asking
> :).
Oh, didn't notice that.
Actually, it looks like the two places that reference BOOKE_IRQPRIO_MAX
don't agree on what they're expecting. book3s uses "one greater than
the highest irqprio", so I guess we should resolve it that way (even
though I'd normally expect that to be phrased "num" rather than "max")
-- as a separate patch, of course.
-Scott
next prev parent reply other threads:[~2012-01-10 22:03 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-21 1:33 [RFC PATCH 00/16] KVM: PPC: e500mc support Scott Wood
2011-12-21 1:34 ` [RFC PATCH 01/16] powerpc/booke: Set CPU_FTR_DEBUG_LVL_EXC on 32-bit Scott Wood
2012-01-09 15:21 ` Alexander Graf
2012-01-09 19:14 ` Scott Wood
2011-12-21 1:34 ` [RFC PATCH 02/16] powerpc/e500: split CPU_FTRS_ALWAYS/CPU_FTRS_POSSIBLE Scott Wood
2011-12-21 1:34 ` [RFC PATCH 03/16] KVM: PPC: Use pt_regs in vcpu->arch Scott Wood
2011-12-21 1:34 ` [RFC PATCH 04/16] KVM: PPC: factor out lpid allocator from book3s_64_mmu_hv Scott Wood
2012-01-09 15:35 ` Alexander Graf
2012-01-12 4:16 ` Paul Mackerras
2011-12-21 1:34 ` [RFC PATCH 05/16] KVM: PPC: booke: add booke-level vcpu load/put Scott Wood
2011-12-21 1:34 ` [RFC PATCH 06/16] KVM: PPC: booke: Move vm core init/destroy out of booke.c Scott Wood
2011-12-21 1:34 ` [RFC PATCH 07/16] KVM: PPC: e500: rename e500_tlb.h to e500.h Scott Wood
2011-12-21 1:34 ` [RFC PATCH 08/16] KVM: PPC: e500: merge <asm/kvm_e500.h> into arch/powerpc/kvm/e500.h Scott Wood
2011-12-21 1:34 ` [RFC PATCH 09/16] KVM: PPC: e500: clean up arch/powerpc/kvm/e500.h Scott Wood
2011-12-21 1:34 ` [RFC PATCH 10/16] KVM: PPC: e500: refactor core-specific TLB code Scott Wood
2011-12-21 1:34 ` [RFC PATCH 11/16] KVM: PPC: e500: Track TLB1 entries with a bitmap Scott Wood
2011-12-21 1:34 ` [RFC PATCH 12/16] KVM: PPC: e500: emulate tlbilx Scott Wood
2012-01-09 16:23 ` Alexander Graf
2011-12-21 1:34 ` [RFC PATCH 13/16] powerpc/booke: Provide exception macros with interrupt name Scott Wood
2012-02-17 8:50 ` Benjamin Herrenschmidt
2011-12-21 1:34 ` [RFC PATCH 14/16] KVM: PPC: booke: category E.HV (GS-mode) support Scott Wood
2012-01-09 17:46 ` Alexander Graf
2012-01-10 0:51 ` Scott Wood
2012-01-10 3:11 ` Alexander Graf
2012-01-10 22:03 ` Scott Wood [this message]
2012-01-10 23:06 ` Alexander Graf
2012-01-12 6:44 ` Benjamin Herrenschmidt
2012-01-12 7:11 ` Alexander Graf
2012-01-12 16:26 ` Scott Wood
2012-02-15 19:36 ` Alexander Graf
2012-02-15 19:40 ` Scott Wood
2012-02-15 23:18 ` Alexander Graf
2011-12-21 1:34 ` [RFC PATCH 15/16] KVM: PPC: booke: standard PPC floating point support Scott Wood
2012-01-09 17:48 ` Alexander Graf
2012-01-09 21:48 ` Scott Wood
2012-01-09 22:17 ` Alexander Graf
2012-01-09 22:39 ` Scott Wood
2012-01-09 22:47 ` Alexander Graf
2012-01-09 22:54 ` Scott Wood
2012-01-09 22:56 ` Alexander Graf
2011-12-21 1:34 ` [RFC PATCH 16/16] KVM: PPC: e500mc support Scott Wood
2012-01-09 16:33 ` Avi Kivity
2012-01-09 19:29 ` Scott Wood
2012-01-10 8:37 ` Avi Kivity
2012-01-10 22:20 ` Scott Wood
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=4F0CB5B1.6010601@freescale.com \
--to=scottwood@freescale.com \
--cc=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox