From: Mark Rutland <mark.rutland@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: marc.zyngier@arm.com, qemu-arm@nongnu.org,
kvmarm@lists.cs.columbia.edu, wu.wubin@huawei.com
Subject: Re: [PATCH RFC 7/7] ARM64: KVM: Add user set handler for id_aa64mmfr0_el1
Date: Thu, 9 Mar 2017 15:03:32 +0000 [thread overview]
Message-ID: <20170309150331.GA10724@leverpostej> (raw)
In-Reply-To: <20170309125218.GD114809@lvm>
On Thu, Mar 09, 2017 at 04:52:18AM -0800, Christoffer Dall wrote:
> On Mon, Jan 16, 2017 at 05:33:34PM +0800, Shannon Zhao wrote:
> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >
> > Check if the configuration is fine.
>
> This commit message really needs some love and attention.
>
> >
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > ---
> > arch/arm64/kvm/sys_regs.c | 32 +++++++++++++++++++++++++++++++-
> > 1 file changed, 31 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> > index f613e29..9763b79 100644
> > --- a/arch/arm64/kvm/sys_regs.c
> > +++ b/arch/arm64/kvm/sys_regs.c
> > @@ -1493,6 +1493,35 @@ static bool access_id_reg(struct kvm_vcpu *vcpu,
> > return true;
> > }
> >
> > +static int set_id_aa64mmfr0_el1(struct kvm_vcpu *vcpu,
> > + const struct sys_reg_desc *rd,
> > + const struct kvm_one_reg *reg,
> > + void __user *uaddr)
> > +{
> > + u64 val, id_aa64mmfr0;
> > +
> > + if (copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id)) != 0)
> > + return -EFAULT;
> > +
> > + asm volatile("mrs %0, id_aa64mmfr0_el1\n" : "=r" (id_aa64mmfr0));
>
> Doesn't the kernel have an abstraction for this already or a cached
> value?
Certainly we shouldn't be using a raw mrs instruction. We have
read_sysreg() or read_cpuid() for that.
The cpufeature code has a cached, system-wide safe value cached for each
system register. The cpuid_feature_extract_field() helper uses that.
> > + if ((val & GENMASK(3, 0)) > (id_aa64mmfr0 & GENMASK(3, 0)) ||
> > + (val & GENMASK(7, 4)) > (id_aa64mmfr0 & GENMASK(7, 4)) ||
> > + (val & GENMASK(11, 8)) > (id_aa64mmfr0 & GENMASK(11, 8)) ||
> > + (val & GENMASK(15, 12)) > (id_aa64mmfr0 & GENMASK(15, 12)) ||
> > + (val & GENMASK(19, 16)) > (id_aa64mmfr0 & GENMASK(19, 16)) ||
> > + (val & GENMASK(23, 20)) > (id_aa64mmfr0 & GENMASK(23, 20)) ||
> > + (val & GENMASK(27, 24)) < (id_aa64mmfr0 & GENMASK(27, 24)) ||
> > + (val & GENMASK(31, 28)) < (id_aa64mmfr0 & GENMASK(31, 28))) {
Please use mnemonics. For example, we have ID_AA64MMFR0_TGRAN*_SHIFT
defined in <asm/sysreg.h>.
We also have extraction helpers, see
cpuid_feature_extract_unsigned_field(), as used in
id_aa64mmfr0_mixed_endian_el0().
Thanks,
Mark.
WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: marc.zyngier@arm.com, qemu-arm@nongnu.org,
kvmarm@lists.cs.columbia.edu, wu.wubin@huawei.com
Subject: Re: [PATCH RFC 7/7] ARM64: KVM: Add user set handler for id_aa64mmfr0_el1
Date: Thu, 9 Mar 2017 15:03:32 +0000 [thread overview]
Message-ID: <20170309150331.GA10724@leverpostej> (raw)
In-Reply-To: <20170309125218.GD114809@lvm>
On Thu, Mar 09, 2017 at 04:52:18AM -0800, Christoffer Dall wrote:
> On Mon, Jan 16, 2017 at 05:33:34PM +0800, Shannon Zhao wrote:
> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >
> > Check if the configuration is fine.
>
> This commit message really needs some love and attention.
>
> >
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > ---
> > arch/arm64/kvm/sys_regs.c | 32 +++++++++++++++++++++++++++++++-
> > 1 file changed, 31 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> > index f613e29..9763b79 100644
> > --- a/arch/arm64/kvm/sys_regs.c
> > +++ b/arch/arm64/kvm/sys_regs.c
> > @@ -1493,6 +1493,35 @@ static bool access_id_reg(struct kvm_vcpu *vcpu,
> > return true;
> > }
> >
> > +static int set_id_aa64mmfr0_el1(struct kvm_vcpu *vcpu,
> > + const struct sys_reg_desc *rd,
> > + const struct kvm_one_reg *reg,
> > + void __user *uaddr)
> > +{
> > + u64 val, id_aa64mmfr0;
> > +
> > + if (copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id)) != 0)
> > + return -EFAULT;
> > +
> > + asm volatile("mrs %0, id_aa64mmfr0_el1\n" : "=r" (id_aa64mmfr0));
>
> Doesn't the kernel have an abstraction for this already or a cached
> value?
Certainly we shouldn't be using a raw mrs instruction. We have
read_sysreg() or read_cpuid() for that.
The cpufeature code has a cached, system-wide safe value cached for each
system register. The cpuid_feature_extract_field() helper uses that.
> > + if ((val & GENMASK(3, 0)) > (id_aa64mmfr0 & GENMASK(3, 0)) ||
> > + (val & GENMASK(7, 4)) > (id_aa64mmfr0 & GENMASK(7, 4)) ||
> > + (val & GENMASK(11, 8)) > (id_aa64mmfr0 & GENMASK(11, 8)) ||
> > + (val & GENMASK(15, 12)) > (id_aa64mmfr0 & GENMASK(15, 12)) ||
> > + (val & GENMASK(19, 16)) > (id_aa64mmfr0 & GENMASK(19, 16)) ||
> > + (val & GENMASK(23, 20)) > (id_aa64mmfr0 & GENMASK(23, 20)) ||
> > + (val & GENMASK(27, 24)) < (id_aa64mmfr0 & GENMASK(27, 24)) ||
> > + (val & GENMASK(31, 28)) < (id_aa64mmfr0 & GENMASK(31, 28))) {
Please use mnemonics. For example, we have ID_AA64MMFR0_TGRAN*_SHIFT
defined in <asm/sysreg.h>.
We also have extraction helpers, see
cpuid_feature_extract_unsigned_field(), as used in
id_aa64mmfr0_mixed_endian_el0().
Thanks,
Mark.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2017-03-09 15:02 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-16 9:33 [PATCH RFC 0/7] ARM64: KVM: Cross type vCPU support Shannon Zhao
2017-01-16 9:33 ` Shannon Zhao
2017-01-16 9:33 ` [PATCH RFC 1/7] ARM64: KVM: Add the definition of ID registers Shannon Zhao
2017-01-16 9:33 ` Shannon Zhao
2017-01-28 12:07 ` Andrew Jones
2017-01-28 12:07 ` Andrew Jones
2017-01-16 9:33 ` [PATCH RFC 2/7] ARM64: KVM: Add reset handlers for all " Shannon Zhao
2017-01-16 9:33 ` Shannon Zhao
2017-01-28 12:36 ` Andrew Jones
2017-01-28 12:36 ` Andrew Jones
2017-03-09 10:19 ` Christoffer Dall
2017-03-09 10:19 ` Christoffer Dall
2017-01-16 9:33 ` [PATCH RFC 3/7] ARM64: KVM: Reset ID registers when creating the VCPUs Shannon Zhao
2017-01-16 9:33 ` Shannon Zhao
2017-01-28 13:32 ` Andrew Jones
2017-01-28 13:32 ` Andrew Jones
2017-01-16 9:33 ` [PATCH RFC 4/7] ARM64: KVM: emulate accessing ID registers Shannon Zhao
2017-01-16 9:33 ` Shannon Zhao
2017-01-28 13:49 ` Andrew Jones
2017-01-28 13:49 ` [Qemu-arm] " Andrew Jones
2017-03-09 10:28 ` Christoffer Dall
2017-03-09 10:28 ` Christoffer Dall
2017-01-16 9:33 ` [PATCH RFC 5/7] ARM64: KVM: Support cross type vCPU Shannon Zhao
2017-01-16 9:33 ` Shannon Zhao
2017-01-28 14:47 ` Andrew Jones
2017-01-28 14:47 ` Andrew Jones
2017-03-09 10:56 ` Christoffer Dall
2017-03-09 10:56 ` Christoffer Dall
2017-01-16 9:33 ` [PATCH RFC 6/7] ARM64: KVM: Support heterogeneous system Shannon Zhao
2017-01-16 9:33 ` Shannon Zhao
2017-01-28 14:55 ` Andrew Jones
2017-01-28 14:55 ` Andrew Jones
2017-03-09 15:21 ` Suzuki K Poulose
2017-03-09 15:21 ` Suzuki K Poulose
2017-03-15 11:50 ` Christoffer Dall
2017-03-15 11:50 ` Christoffer Dall
2017-03-15 12:51 ` Andrew Jones
2017-03-15 12:51 ` Andrew Jones
2017-03-15 13:36 ` Christoffer Dall
2017-03-15 13:36 ` Christoffer Dall
2017-03-15 14:06 ` Andrew Jones
2017-03-15 14:06 ` Andrew Jones
2017-03-15 14:21 ` Peter Maydell
2017-03-15 14:21 ` [Qemu-arm] " Peter Maydell
2017-03-15 14:42 ` Andrew Jones
2017-03-15 14:42 ` Andrew Jones
2017-03-15 14:49 ` Mark Rutland
2017-03-15 14:49 ` Mark Rutland
2017-03-15 15:22 ` Christoffer Dall
2017-03-15 15:22 ` Christoffer Dall
2017-03-15 15:32 ` Andrew Jones
2017-03-15 15:32 ` Andrew Jones
2017-01-16 9:33 ` [PATCH RFC 7/7] ARM64: KVM: Add user set handler for id_aa64mmfr0_el1 Shannon Zhao
2017-01-16 9:33 ` Shannon Zhao
2017-01-28 15:22 ` Andrew Jones
2017-01-28 15:22 ` Andrew Jones
2017-03-09 12:52 ` Christoffer Dall
2017-03-09 12:52 ` Christoffer Dall
2017-03-09 15:03 ` Mark Rutland [this message]
2017-03-09 15:03 ` Mark Rutland
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=20170309150331.GA10724@leverpostej \
--to=mark.rutland@arm.com \
--cc=christoffer.dall@linaro.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.com \
--cc=qemu-arm@nongnu.org \
--cc=wu.wubin@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.