From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FB36C433F5 for ; Thu, 30 Sep 2021 13:31:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FB1F613A9 for ; Thu, 30 Sep 2021 13:31:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1FB1F613A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f5neCIEb0K4fOCsHUo8bkHYyL7X6XVE0hTtb0IX8Hbs=; b=1IhZHSyWP8hzZ/ aSnYP5RdhHY8mq6zvejwbg3vUnkqtc3zhXZOMG3iFbIKzDqg8xn2p3Ypoy4E5h6dpxKXc5/dVVEif 4xjCTQpVqVJp606LSlz/lggHq+yEDi83PGUX6WEkA07vmAD4V6DIVfW1a+bXrhSFKkZTUEjikgMyB c7TdeyRQK66oH9BTfySdurxmb26AfS/2iauNtWnEKa933hQKvuWviOIhh55/hJbvJ+GAWOxB2nFjt kSP045yTdjhJRhbLFrr1IT/aXaN9n4WtSWzBk9qKfAGhDNlnQCrmCioTuB93Pm4OAGMJNtI1pTyHd d0LLNbyQcOMO5q+XSdYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVw83-00EU1I-JU; Thu, 30 Sep 2021 13:29:39 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVw7m-00ETyf-3k for linux-arm-kernel@lists.infradead.org; Thu, 30 Sep 2021 13:29:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633008560; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Isl/b69bzCC4NRdxJvMAiKAJHzi4T9gPXKhGDEYhYsE=; b=EsoNItJuODie2VK44flN/h1TQK4fgr0EQTzdNwW/jvjQ4T6GKopFjlAn3VcDAAVCNFgqbh tUQv25RphIuHIZgfUW4JADAV3E77rqLgoeRPeK9Bb8deHLrU2Yh80iLCV2TZg23iSZLGuS 6fDWDTZgbxOXfgjSDGeJYhbUZc2lSyg= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-5MvRCj8_N4aOR2_iVH2khw-1; Thu, 30 Sep 2021 09:29:19 -0400 X-MC-Unique: 5MvRCj8_N4aOR2_iVH2khw-1 Received: by mail-qt1-f200.google.com with SMTP id x28-20020ac8701c000000b0029f4b940566so11723215qtm.19 for ; Thu, 30 Sep 2021 06:29:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Isl/b69bzCC4NRdxJvMAiKAJHzi4T9gPXKhGDEYhYsE=; b=WxDhKzqcLvw7fVz2esCZd4RyJFut72oWTemw4+UrD7AoD5paJYUaDcuTl27laq5orV QmNU8HStsL6aIg5HsMRIIjgYeMzYpygDZfe30rdoKyiNofsCB1P1rcfrFcBUrosCvMtd 1ji5uPSIVV8Nt9rSrlZjEsW9goe+5+CX1nO3LiuSYQUDmKBZ9Xy545zGvgeBRByMD/Qv tJ28qYVgDhbp0+OWRk7a0TDytcvmgqgRkjtZ0WkWhaa/ATSCuTX6zU1STmWKHhY258o4 WWUrZVYoWUHMPesWyjL+84824pXFAitFn1AUDLXXiDDr53t4BJY+S959eeOX8Or0pFww lTsg== X-Gm-Message-State: AOAM531Jou7PyHUpbAOzo2TfhEUtIhM9GviIT08muJr64xJYaXY/1rLM 1LilNUn9FcLTU8oj007jTDnUnzoe3A39XsBlt7q8RSEEBcGrxHgX8lT4MSgrZiixwbJm9Jy+jjx qHX4YLFF3O57nFH63hVqLqVplopsZlkfSNjU= X-Received: by 2002:a05:6214:393:: with SMTP id l19mr5390441qvy.8.1633008559123; Thu, 30 Sep 2021 06:29:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFnirPv4PoNfVoyAlW5rSeeodnWwuclzJETP5skeYr77i7Uavc83v1bilffS7/xWhNPosu5g== X-Received: by 2002:a05:6214:393:: with SMTP id l19mr5390424qvy.8.1633008558909; Thu, 30 Sep 2021 06:29:18 -0700 (PDT) Received: from gator (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id w11sm1627246qts.9.2021.09.30.06.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 06:29:18 -0700 (PDT) Date: Thu, 30 Sep 2021 15:29:15 +0200 From: Andrew Jones To: Alexandru Elisei Cc: maz@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Subject: Re: [PATCH 2/2] KVM: arm64: Use get_raz_reg() for userspace reads of PMSWINC_EL0 Message-ID: <20210930132915.cpfzxdlws2zlou47@gator> References: <20210927124911.191729-1-alexandru.elisei@arm.com> <20210927124911.191729-3-alexandru.elisei@arm.com> MIME-Version: 1.0 In-Reply-To: <20210927124911.191729-3-alexandru.elisei@arm.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210930_062922_293642_0F9273D5 X-CRM114-Status: GOOD ( 25.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Sep 27, 2021 at 01:49:11PM +0100, Alexandru Elisei wrote: > PMSWINC_EL0 is a write-only register and was initially part of the VCPU > register state, but was later removed in commit 7a3ba3095a32 ("KVM: > arm64: Remove PMSWINC_EL0 shadow register"). To prevent regressions, the > register was kept accessible from userspace as Read-As-Zero (RAZ). > > The read function that is used to handle userspace reads of this > register is get_raz_id_reg(), which, while technically correct, as it > returns 0, it is not semantically correct, as PMSWINC_EL0 is not an ID > register as the function name suggests. > > Add a new function, get_raz_reg(), to use it as the accessor for > PMSWINC_EL0, as to not conflate get_raz_id_reg() to handle other types > of registers. > > No functional change intended. > > Signed-off-by: Alexandru Elisei > --- > arch/arm64/kvm/sys_regs.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 4adda8bf3168..1be827740f87 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -1285,6 +1285,15 @@ static int set_raz_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > return __set_id_reg(vcpu, rd, uaddr, true); > } > > +static int get_raz_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > + const struct kvm_one_reg *reg, void __user *uaddr) > +{ > + const u64 id = sys_reg_to_index(rd); > + const u64 val = 0; > + > + return reg_to_user(uaddr, &val, id); > +} > + > static int set_wi_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > const struct kvm_one_reg *reg, void __user *uaddr) > { > @@ -1647,7 +1656,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { > * previously (and pointlessly) advertised in the past... > */ > { PMU_SYS_REG(SYS_PMSWINC_EL0), > - .get_user = get_raz_id_reg, .set_user = set_wi_reg, > + .get_user = get_raz_reg, .set_user = set_wi_reg, > .access = access_pmswinc, .reset = NULL }, > { PMU_SYS_REG(SYS_PMSELR_EL0), > .access = access_pmselr, .reset = reset_pmselr, .reg = PMSELR_EL0 }, > -- > 2.33.0 > What about replacing get_raz_id_reg() with this new function? Do really need both? Thanks, drew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel