Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1160511img; Tue, 19 Mar 2019 01:32:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwj/CFj2orP0sZufkHH+Hw8frfVr32trzr5N4cFtmVJZPT5Yzy4TTivIG2O+c1DxJ9+L1l1 X-Received: by 2002:a62:57d7:: with SMTP id i84mr1027751pfj.125.1552984330320; Tue, 19 Mar 2019 01:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552984330; cv=none; d=google.com; s=arc-20160816; b=mjqiN3L5qzAvGQTOda4YIRRu7zywXj4KEa5GI0kS/NlJ/JSLOJiATdemQOx0/vRW1X 5tMdYIw8viTFXIZo6U96m7F+dvbyiG2aXyBJorNaRh+AtK7D5aglp01E5vOsx1taA5cd ZTfFp8QFHEI9I0GlRHCMPH6EEN5yS40HTlWL06tPfxrJoo3sAw+fNToWiy9J/enwFhn7 htNWeej/cXN5E9Rs1YXTg0o4nuz8ReKjKONbobCuySzDNyE9t9PV22V5Y6La8qUaFmky VdT7C9lRD2LVW0Xw0hfOMSsK77UDBiUaAnUaulNuVpnVN1h8iLl05na+CuM+TCKXh+BB aTKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=80oEx7EXOWYe9lNm8FtZEQLWb//Yg1syvNwrmVCjoq8=; b=c0iwq9xYPskbnIMjLJ5Mj2xraByMC6XsyHv1Ab1XnySMHAjSXR+bVdq4Au55gg5J0J CWwqjzdSTYwy9iqhzFpPLic47fpTd2teH/kqvG20t9JB35jxmd3nVxYwT6HmglYe6TV1 O4StSMxf+PFo+GE3WCR29AahzFoyepeJpIZxAXdHgMZTFLNiWBKtP0XuZGDhEaNr4w23 7X+hiOv9HThxzuW16Zgqjky1YvZrbuJf5Evh78kwzbJ2Xkeju84rfBhREFdvHq2gY+Gi I9WZYyeT6sN44L057CxoRiOrXE9P3rzqXwH7YB8lICzar8doJT0PZRWtf8WLBMpQbnkg bJhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi12si11215529plb.205.2019.03.19.01.31.55; Tue, 19 Mar 2019 01:32:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727404AbfCSIbP (ORCPT + 99 others); Tue, 19 Mar 2019 04:31:15 -0400 Received: from foss.arm.com ([217.140.101.70]:46948 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbfCSIbP (ORCPT ); Tue, 19 Mar 2019 04:31:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DFEEA1596; Tue, 19 Mar 2019 01:31:14 -0700 (PDT) Received: from a075553-lin.blr.arm.com (a075553-lin.blr.arm.com [10.162.0.144]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A7D953F59C; Tue, 19 Mar 2019 01:31:10 -0700 (PDT) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org Cc: Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon , Andrew Jones , Dave Martin , Ramana Radhakrishnan , kvmarm@lists.cs.columbia.edu, Kristina Martsenko , linux-kernel@vger.kernel.org, Amit Daniel Kachhap , Mark Rutland , James Morse , Julien Thierry Subject: [PATCH v7 1/10] KVM: arm64: Propagate vcpu into read_id_reg() Date: Tue, 19 Mar 2019 14:00:34 +0530 Message-Id: <1552984243-7689-2-git-send-email-amit.kachhap@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552984243-7689-1-git-send-email-amit.kachhap@arm.com> References: <1552984243-7689-1-git-send-email-amit.kachhap@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Martin Architecture features that are conditionally visible to the guest will require run-time checks in the ID register accessor functions. In particular, read_id_reg() will need to perform checks in order to generate the correct emulated value for certain ID register fields such as ID_AA64PFR0_EL1.SVE for example. This patch propagates vcpu into read_id_reg() so that future patches can add run-time checks on the guest configuration here. For now, there is no functional change. Signed-off-by: Dave Martin Reviewed-by: Alex Bennee --- arch/arm64/kvm/sys_regs.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 539feec..a5d14b5 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1044,7 +1044,8 @@ static bool access_arch_timer(struct kvm_vcpu *vcpu, } /* Read a sanitised cpufeature ID register by sys_reg_desc */ -static u64 read_id_reg(struct sys_reg_desc const *r, bool raz) +static u64 read_id_reg(const struct kvm_vcpu *vcpu, + struct sys_reg_desc const *r, bool raz) { u32 id = sys_reg((u32)r->Op0, (u32)r->Op1, (u32)r->CRn, (u32)r->CRm, (u32)r->Op2); @@ -1078,7 +1079,7 @@ static bool __access_id_reg(struct kvm_vcpu *vcpu, if (p->is_write) return write_to_read_only(vcpu, p, r); - p->regval = read_id_reg(r, raz); + p->regval = read_id_reg(vcpu, r, raz); return true; } @@ -1107,16 +1108,18 @@ static u64 sys_reg_to_index(const struct sys_reg_desc *reg); * are stored, and for set_id_reg() we don't allow the effective value * to be changed. */ -static int __get_id_reg(const struct sys_reg_desc *rd, void __user *uaddr, +static int __get_id_reg(const struct kvm_vcpu *vcpu, + const struct sys_reg_desc *rd, void __user *uaddr, bool raz) { const u64 id = sys_reg_to_index(rd); - const u64 val = read_id_reg(rd, raz); + const u64 val = read_id_reg(vcpu, rd, raz); return reg_to_user(uaddr, &val, id); } -static int __set_id_reg(const struct sys_reg_desc *rd, void __user *uaddr, +static int __set_id_reg(const struct kvm_vcpu *vcpu, + const struct sys_reg_desc *rd, void __user *uaddr, bool raz) { const u64 id = sys_reg_to_index(rd); @@ -1128,7 +1131,7 @@ static int __set_id_reg(const struct sys_reg_desc *rd, void __user *uaddr, return err; /* This is what we mean by invariant: you can't change it. */ - if (val != read_id_reg(rd, raz)) + if (val != read_id_reg(vcpu, rd, raz)) return -EINVAL; return 0; @@ -1137,25 +1140,25 @@ static int __set_id_reg(const struct sys_reg_desc *rd, void __user *uaddr, static int get_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, const struct kvm_one_reg *reg, void __user *uaddr) { - return __get_id_reg(rd, uaddr, false); + return __get_id_reg(vcpu, rd, uaddr, false); } static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, const struct kvm_one_reg *reg, void __user *uaddr) { - return __set_id_reg(rd, uaddr, false); + return __set_id_reg(vcpu, rd, uaddr, false); } static int get_raz_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, const struct kvm_one_reg *reg, void __user *uaddr) { - return __get_id_reg(rd, uaddr, true); + return __get_id_reg(vcpu, rd, uaddr, true); } static int set_raz_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, const struct kvm_one_reg *reg, void __user *uaddr) { - return __set_id_reg(rd, uaddr, true); + return __set_id_reg(vcpu, rd, uaddr, true); } static bool access_ctr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, -- 2.7.4