On Thu, Sep 17, 2020 at 08:01:00PM +0800, Peng Liang wrote:
> It's time to make ID registers configurable. When userspace (but not
> guest) want to set the values of ID registers, save the value in
> sysreg file so that guest can read the modified values.
>
> Signed-off-by: zhanghailiang <[email protected]>
> Signed-off-by: Peng Liang <[email protected]>
> ---
> arch/arm64/kvm/sys_regs.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index a642ecfebe0a..881b66494524 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -1263,10 +1263,6 @@ static int set_id_aa64zfr0_el1(struct kvm_vcpu *vcpu,
>
> /*
> * cpufeature ID register user accessors
> - *
> - * For now, these registers are immutable for userspace, so no values
> - * are stored, and for set_id_reg() we don't allow the effective value
> - * to be changed.
> */
> static int __get_id_reg(struct kvm_vcpu *vcpu,
> const struct sys_reg_desc *rd, void __user *uaddr,
> @@ -1290,9 +1286,15 @@ static int __set_id_reg(struct kvm_vcpu *vcpu,
> if (err)
> return err;
>
> - /* This is what we mean by invariant: you can't change it. */
> - if (val != read_id_reg(vcpu, rd, raz))
> - return -EINVAL;
> + if (raz) {
> + if (val != read_id_reg(vcpu, rd, raz))
val != 0 ?
> + return -EINVAL;
> + } else {
> + u32 reg_id = sys_reg((u32)rd->Op0, (u32)rd->Op1, (u32)rd->CRn,
> + (u32)rd->CRm, (u32)rd->Op2);
> + /* val should be checked in check_user */
It really doesn't make sense to share this trivial set_user function and
have different check functions. Just don't share the set_user function.
> + __vcpu_sys_reg(vcpu, ID_REG_INDEX(reg_id)) = val;
> + }
>
> return 0;
> }
> --
> 2.26.2
>
Thanks,
drew
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm