From: Paul Mackerras <paulus@samba.org>
To: Alexander Graf <agraf@suse.de>
Cc: kvm-ppc@vger.kernel.org, KVM list <kvm@vger.kernel.org>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH v3 1/2] KVM: PPC: Book3S: Get/set guest SPRs using the GET/SET_ONE_REG interface
Date: Mon, 24 Sep 2012 22:16:51 +1000 [thread overview]
Message-ID: <20120924121651.GA21174@bloggs.ozlabs.ibm.com> (raw)
In-Reply-To: <0906175A-396F-4647-9CDF-BEF0B906DF67@suse.de>
On Fri, Sep 21, 2012 at 11:15:51AM +0200, Alexander Graf wrote:
> So how about something like
>
> #define kvmppc_set_reg(id, val, reg) { \
> switch (one_reg_size(id)) { \
> case 4: val.wval = reg; break; \
> case 8: val.dval = reg; break; \
> default: BUG(); \
> } \
> }
>
> case KVM_REG_PPC_DAR:
> kvmppc_set_reg(reg->id, &val, vcpu->arch.shared->dar);
> break;
I tried that and it was fine for the wval vs. dval thing, and gcc even
compiled it to the same number of instructions as what I had before.
But it breaks down when you get to VMX and VSX -- firstly because
there are two different types that are both 16 bytes, and secondly
because when you do this:
#define kvmppc_get_reg(id, val, reg) { \
switch (one_reg_size(id)) { \
case 4: val.wval = reg; break; \
case 8: val.dval = reg; break; \
case 16: val.vval = reg; break; \
default: BUG(); \
} \
}
you get compile errors on things like:
kvmppc_set_reg(reg->id, val, vcpu->arch.shared->dar);
because val.vval is a vector128, and vcpu->arch.shared->dar is a u64,
and you can't assign a u64 to a vector128 since vector128 is a struct.
In other words, all of the cases of the switch have to satisfy the
type rules even though only one of them will ever be used. Basically
that trick will only work for integer types, and we don't have 128 bit
integer support in gcc.
Given all that, I would like to see my patches go in while we continue
to search for a way to avoid the potential mistakes you're talking
about.
Paul.
next prev parent reply other threads:[~2012-09-24 12:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-21 5:44 [PATCH v3 1/2] KVM: PPC: Book3S: Get/set guest SPRs using the GET/SET_ONE_REG interface Paul Mackerras
2012-09-21 5:45 ` [PATCH v3 2/2] KVM: PPC: Book3S: Get/set guest FP regs " Paul Mackerras
2012-09-21 9:15 ` [PATCH v3 1/2] KVM: PPC: Book3S: Get/set guest SPRs " Alexander Graf
2012-09-21 9:52 ` Paul Mackerras
2012-09-21 10:07 ` Alexander Graf
2012-09-24 12:16 ` Paul Mackerras [this message]
2012-09-24 12:29 ` Alexander Graf
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=20120924121651.GA21174@bloggs.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/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