mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 21:57:43 +00:00
KVM: arm64: Get rid of reg_from/to_user()
These helpers are only used by the invariant stuff now, and while they pretend to support non-64bit registers, this only serves as a way to scare the casual reviewer... Replace these helpers with our good friends get/put_user(), and don't look back. Reviewed-by: Reiji Watanabe <reijiw@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
parent
978ceeb3e4
commit
5a420ed964
1 changed files with 6 additions and 24 deletions
|
@ -44,8 +44,6 @@
|
||||||
* 64bit interface.
|
* 64bit interface.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int reg_from_user(u64 *val, const void __user *uaddr, u64 id);
|
|
||||||
static int reg_to_user(void __user *uaddr, const u64 *val, u64 id);
|
|
||||||
static u64 sys_reg_to_index(const struct sys_reg_desc *reg);
|
static u64 sys_reg_to_index(const struct sys_reg_desc *reg);
|
||||||
|
|
||||||
static bool read_from_write_only(struct kvm_vcpu *vcpu,
|
static bool read_from_write_only(struct kvm_vcpu *vcpu,
|
||||||
|
@ -2657,21 +2655,7 @@ static struct sys_reg_desc invariant_sys_regs[] = {
|
||||||
{ SYS_DESC(SYS_CTR_EL0), NULL, get_ctr_el0 },
|
{ SYS_DESC(SYS_CTR_EL0), NULL, get_ctr_el0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int reg_from_user(u64 *val, const void __user *uaddr, u64 id)
|
static int get_invariant_sys_reg(u64 id, u64 __user *uaddr)
|
||||||
{
|
|
||||||
if (copy_from_user(val, uaddr, KVM_REG_SIZE(id)) != 0)
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int reg_to_user(void __user *uaddr, const u64 *val, u64 id)
|
|
||||||
{
|
|
||||||
if (copy_to_user(uaddr, val, KVM_REG_SIZE(id)) != 0)
|
|
||||||
return -EFAULT;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_invariant_sys_reg(u64 id, void __user *uaddr)
|
|
||||||
{
|
{
|
||||||
const struct sys_reg_desc *r;
|
const struct sys_reg_desc *r;
|
||||||
|
|
||||||
|
@ -2680,23 +2664,21 @@ static int get_invariant_sys_reg(u64 id, void __user *uaddr)
|
||||||
if (!r)
|
if (!r)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
return reg_to_user(uaddr, &r->val, id);
|
return put_user(r->val, uaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_invariant_sys_reg(u64 id, void __user *uaddr)
|
static int set_invariant_sys_reg(u64 id, u64 __user *uaddr)
|
||||||
{
|
{
|
||||||
const struct sys_reg_desc *r;
|
const struct sys_reg_desc *r;
|
||||||
int err;
|
u64 val;
|
||||||
u64 val = 0; /* Make sure high bits are 0 for 32-bit regs */
|
|
||||||
|
|
||||||
r = get_reg_by_id(id, invariant_sys_regs,
|
r = get_reg_by_id(id, invariant_sys_regs,
|
||||||
ARRAY_SIZE(invariant_sys_regs));
|
ARRAY_SIZE(invariant_sys_regs));
|
||||||
if (!r)
|
if (!r)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
err = reg_from_user(&val, uaddr, id);
|
if (get_user(val, uaddr))
|
||||||
if (err)
|
return -EFAULT;
|
||||||
return err;
|
|
||||||
|
|
||||||
/* This is what we mean by invariant: you can't change it. */
|
/* This is what we mean by invariant: you can't change it. */
|
||||||
if (r->val != val)
|
if (r->val != val)
|
||||||
|
|
Loading…
Reference in a new issue