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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCAAAECAAD8 for ; Tue, 30 Aug 2022 17:45:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 392364B64E; Tue, 30 Aug 2022 13:45:23 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@linux.dev Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ovcqLIGvR2XT; Tue, 30 Aug 2022 13:45:21 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id CBDCA4B8DD; Tue, 30 Aug 2022 13:45:21 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 77FD24B8D8 for ; Tue, 30 Aug 2022 13:45:20 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1eDM+8-4G8SR for ; Tue, 30 Aug 2022 13:45:19 -0400 (EDT) Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 11ECD4B64E for ; Tue, 30 Aug 2022 13:45:18 -0400 (EDT) Date: Tue, 30 Aug 2022 12:45:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1661881517; 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=bZ/O3vOFDUvoL+xwB7YJSEtUpOZ6W45CAPj5b/aG6hs=; b=FW0OqKpqy3RbUkz4twa7NjQFBZuUkJapstDnlrevW9OKV8lDkgX3u1cof3AprNcoA3nNWt /Fp68JTIJ+Z6ku+RFpjQhQm7dUZZP0XGeDT3CYETvIlZ88EI0VqEYaYCOUwmHGPtDLhr5+ kv20p2660vzAYC5mu21QVsRSEqe8DtI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Reiji Watanabe Subject: Re: [PATCH 2/6] KVM: arm64: Remove internal accessor helpers for id regs Message-ID: References: <20220817214818.3243383-1-oliver.upton@linux.dev> <20220817214818.3243383-3-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Cc: Linux ARM , Marc Zyngier , Will Deacon , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Hi Reiji, On Mon, Aug 29, 2022 at 10:45:09PM -0700, Reiji Watanabe wrote: > Hi Oliver, > > On Wed, Aug 17, 2022 at 2:48 PM Oliver Upton wrote: > > > > The internal accessors are only ever called once. Dump out their > > contents in the caller. > > > > No functional change intended. > > > > Signed-off-by: Oliver Upton > > --- > > arch/arm64/kvm/sys_regs.c | 46 ++++++++++----------------------------- > > 1 file changed, 12 insertions(+), 34 deletions(-) > > > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > index e18efb9211f0..26210f3a0b27 100644 > > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -1153,25 +1153,17 @@ static unsigned int raz_visibility(const struct kvm_vcpu *vcpu, > > > > /* cpufeature ID register access trap handlers */ > > > > -static bool __access_id_reg(struct kvm_vcpu *vcpu, > > - struct sys_reg_params *p, > > - const struct sys_reg_desc *r, > > - bool raz) > > -{ > > - if (p->is_write) > > - return write_to_read_only(vcpu, p, r); > > - > > - p->regval = read_id_reg(vcpu, r, raz); > > - return true; > > -} > > - > > static bool access_id_reg(struct kvm_vcpu *vcpu, > > struct sys_reg_params *p, > > const struct sys_reg_desc *r) > > { > > bool raz = sysreg_visible_as_raz(vcpu, r); > > > > - return __access_id_reg(vcpu, p, r, raz); > > + if (p->is_write) > > + return write_to_read_only(vcpu, p, r); > > + > > + p->regval = read_id_reg(vcpu, r, raz); > > + return true; > > } > > > > /* Visibility overrides for SVE-specific control registers */ > > @@ -1226,31 +1218,13 @@ static int set_id_aa64pfr0_el1(struct kvm_vcpu *vcpu, > > * are stored, and for set_id_reg() we don't allow the effective value > > * to be changed. > > */ > > -static int __get_id_reg(const struct kvm_vcpu *vcpu, > > - const struct sys_reg_desc *rd, u64 *val, > > - bool raz) > > -{ > > - *val = read_id_reg(vcpu, rd, raz); > > - return 0; > > -} > > - > > -static int __set_id_reg(const struct kvm_vcpu *vcpu, > > - const struct sys_reg_desc *rd, u64 val, > > - bool raz) > > -{ > > - /* This is what we mean by invariant: you can't change it. */ > > - if (val != read_id_reg(vcpu, rd, raz)) > > - return -EINVAL; > > - > > - return 0; > > -} > > - > > static int get_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > u64 *val) > > { > > bool raz = sysreg_visible_as_raz(vcpu, rd); > > > > - return __get_id_reg(vcpu, rd, val, raz); > > + *val = read_id_reg(vcpu, rd, raz); > > + return 0; > > } > > > > static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > @@ -1258,7 +1232,11 @@ static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > { > > bool raz = sysreg_visible_as_raz(vcpu, rd); > > > > - return __set_id_reg(vcpu, rd, val, raz); > > + /* This is what we mean by invariant: you can't change it. */ > > + if (val != read_id_reg(vcpu, rd, raz)) > > + return -EINVAL; > > + > > + return 0; > > } > > I see no reason for read_id_reg() to take raz as an argument. > Perhaps having read_id_reg() call sysreg_visible_as_raz() instead > might make those functions even simpler? Good point, as this patch has done away with caller-specified RAZ. I'll incorporate that into v2. -- Best, Oliver _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 16414ECAAD1 for ; Tue, 30 Aug 2022 17:46:32 +0000 (UTC) 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=Bqcro2vHebMeQml4PfKcILjt6Byj7U4nvA/uKLChw0c=; b=lBdyOEzKp/A1x1 wu7PimBhOCKqiAkDN9wNIXVwh5WntWrCxY19IeqVBja7Q/JTnwNcvnAYl2IADTu+ag4mDTMKZbzAG O03NCWCIsnp0Fmbv+nhw++Cp9Y9F7NhiEux4OLWDcPmEzw5WuqqcmsU8WhDdCCE4OVbYcNiICL61v ez6pQ1tJfyyxOC8lYOvY86Hc+HitwiWyb/QPM9igzQcquEf5NcqCA/sWi83nAGQ5jt4dnEXjgVbMZ 99S/3fo6QrRneM/8cPsMMLTsNmul6J6aebjyfCn1NbBbGbyxLmiSxaOF8QfsICQhXlvrdAJEBYa8f WOafF0lHSDDAxNocvcPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT5Im-000yIw-E2; Tue, 30 Aug 2022 17:45:28 +0000 Received: from out2.migadu.com ([188.165.223.204]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT5Ih-000yFd-Qb for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2022 17:45:26 +0000 Date: Tue, 30 Aug 2022 12:45:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1661881517; 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=bZ/O3vOFDUvoL+xwB7YJSEtUpOZ6W45CAPj5b/aG6hs=; b=FW0OqKpqy3RbUkz4twa7NjQFBZuUkJapstDnlrevW9OKV8lDkgX3u1cof3AprNcoA3nNWt /Fp68JTIJ+Z6ku+RFpjQhQm7dUZZP0XGeDT3CYETvIlZ88EI0VqEYaYCOUwmHGPtDLhr5+ kv20p2660vzAYC5mu21QVsRSEqe8DtI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Reiji Watanabe Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Marc Zyngier , Will Deacon , Linux ARM Subject: Re: [PATCH 2/6] KVM: arm64: Remove internal accessor helpers for id regs Message-ID: References: <20220817214818.3243383-1-oliver.upton@linux.dev> <20220817214818.3243383-3-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220830_104525_233909_36B8F96C X-CRM114-Status: GOOD ( 23.38 ) 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 Hi Reiji, On Mon, Aug 29, 2022 at 10:45:09PM -0700, Reiji Watanabe wrote: > Hi Oliver, > > On Wed, Aug 17, 2022 at 2:48 PM Oliver Upton wrote: > > > > The internal accessors are only ever called once. Dump out their > > contents in the caller. > > > > No functional change intended. > > > > Signed-off-by: Oliver Upton > > --- > > arch/arm64/kvm/sys_regs.c | 46 ++++++++++----------------------------- > > 1 file changed, 12 insertions(+), 34 deletions(-) > > > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > index e18efb9211f0..26210f3a0b27 100644 > > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -1153,25 +1153,17 @@ static unsigned int raz_visibility(const struct kvm_vcpu *vcpu, > > > > /* cpufeature ID register access trap handlers */ > > > > -static bool __access_id_reg(struct kvm_vcpu *vcpu, > > - struct sys_reg_params *p, > > - const struct sys_reg_desc *r, > > - bool raz) > > -{ > > - if (p->is_write) > > - return write_to_read_only(vcpu, p, r); > > - > > - p->regval = read_id_reg(vcpu, r, raz); > > - return true; > > -} > > - > > static bool access_id_reg(struct kvm_vcpu *vcpu, > > struct sys_reg_params *p, > > const struct sys_reg_desc *r) > > { > > bool raz = sysreg_visible_as_raz(vcpu, r); > > > > - return __access_id_reg(vcpu, p, r, raz); > > + if (p->is_write) > > + return write_to_read_only(vcpu, p, r); > > + > > + p->regval = read_id_reg(vcpu, r, raz); > > + return true; > > } > > > > /* Visibility overrides for SVE-specific control registers */ > > @@ -1226,31 +1218,13 @@ static int set_id_aa64pfr0_el1(struct kvm_vcpu *vcpu, > > * are stored, and for set_id_reg() we don't allow the effective value > > * to be changed. > > */ > > -static int __get_id_reg(const struct kvm_vcpu *vcpu, > > - const struct sys_reg_desc *rd, u64 *val, > > - bool raz) > > -{ > > - *val = read_id_reg(vcpu, rd, raz); > > - return 0; > > -} > > - > > -static int __set_id_reg(const struct kvm_vcpu *vcpu, > > - const struct sys_reg_desc *rd, u64 val, > > - bool raz) > > -{ > > - /* This is what we mean by invariant: you can't change it. */ > > - if (val != read_id_reg(vcpu, rd, raz)) > > - return -EINVAL; > > - > > - return 0; > > -} > > - > > static int get_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > u64 *val) > > { > > bool raz = sysreg_visible_as_raz(vcpu, rd); > > > > - return __get_id_reg(vcpu, rd, val, raz); > > + *val = read_id_reg(vcpu, rd, raz); > > + return 0; > > } > > > > static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > @@ -1258,7 +1232,11 @@ static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > { > > bool raz = sysreg_visible_as_raz(vcpu, rd); > > > > - return __set_id_reg(vcpu, rd, val, raz); > > + /* This is what we mean by invariant: you can't change it. */ > > + if (val != read_id_reg(vcpu, rd, raz)) > > + return -EINVAL; > > + > > + return 0; > > } > > I see no reason for read_id_reg() to take raz as an argument. > Perhaps having read_id_reg() call sysreg_visible_as_raz() instead > might make those functions even simpler? Good point, as this patch has done away with caller-specified RAZ. I'll incorporate that into v2. -- Best, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98C88ECAAD1 for ; Tue, 30 Aug 2022 17:48:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbiH3Rsy (ORCPT ); Tue, 30 Aug 2022 13:48:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232186AbiH3Rsb (ORCPT ); Tue, 30 Aug 2022 13:48:31 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 947BF1FCCE for ; Tue, 30 Aug 2022 10:45:19 -0700 (PDT) Date: Tue, 30 Aug 2022 12:45:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1661881517; 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=bZ/O3vOFDUvoL+xwB7YJSEtUpOZ6W45CAPj5b/aG6hs=; b=FW0OqKpqy3RbUkz4twa7NjQFBZuUkJapstDnlrevW9OKV8lDkgX3u1cof3AprNcoA3nNWt /Fp68JTIJ+Z6ku+RFpjQhQm7dUZZP0XGeDT3CYETvIlZ88EI0VqEYaYCOUwmHGPtDLhr5+ kv20p2660vzAYC5mu21QVsRSEqe8DtI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Reiji Watanabe Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Marc Zyngier , Will Deacon , Linux ARM Subject: Re: [PATCH 2/6] KVM: arm64: Remove internal accessor helpers for id regs Message-ID: References: <20220817214818.3243383-1-oliver.upton@linux.dev> <20220817214818.3243383-3-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Reiji, On Mon, Aug 29, 2022 at 10:45:09PM -0700, Reiji Watanabe wrote: > Hi Oliver, > > On Wed, Aug 17, 2022 at 2:48 PM Oliver Upton wrote: > > > > The internal accessors are only ever called once. Dump out their > > contents in the caller. > > > > No functional change intended. > > > > Signed-off-by: Oliver Upton > > --- > > arch/arm64/kvm/sys_regs.c | 46 ++++++++++----------------------------- > > 1 file changed, 12 insertions(+), 34 deletions(-) > > > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > index e18efb9211f0..26210f3a0b27 100644 > > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -1153,25 +1153,17 @@ static unsigned int raz_visibility(const struct kvm_vcpu *vcpu, > > > > /* cpufeature ID register access trap handlers */ > > > > -static bool __access_id_reg(struct kvm_vcpu *vcpu, > > - struct sys_reg_params *p, > > - const struct sys_reg_desc *r, > > - bool raz) > > -{ > > - if (p->is_write) > > - return write_to_read_only(vcpu, p, r); > > - > > - p->regval = read_id_reg(vcpu, r, raz); > > - return true; > > -} > > - > > static bool access_id_reg(struct kvm_vcpu *vcpu, > > struct sys_reg_params *p, > > const struct sys_reg_desc *r) > > { > > bool raz = sysreg_visible_as_raz(vcpu, r); > > > > - return __access_id_reg(vcpu, p, r, raz); > > + if (p->is_write) > > + return write_to_read_only(vcpu, p, r); > > + > > + p->regval = read_id_reg(vcpu, r, raz); > > + return true; > > } > > > > /* Visibility overrides for SVE-specific control registers */ > > @@ -1226,31 +1218,13 @@ static int set_id_aa64pfr0_el1(struct kvm_vcpu *vcpu, > > * are stored, and for set_id_reg() we don't allow the effective value > > * to be changed. > > */ > > -static int __get_id_reg(const struct kvm_vcpu *vcpu, > > - const struct sys_reg_desc *rd, u64 *val, > > - bool raz) > > -{ > > - *val = read_id_reg(vcpu, rd, raz); > > - return 0; > > -} > > - > > -static int __set_id_reg(const struct kvm_vcpu *vcpu, > > - const struct sys_reg_desc *rd, u64 val, > > - bool raz) > > -{ > > - /* This is what we mean by invariant: you can't change it. */ > > - if (val != read_id_reg(vcpu, rd, raz)) > > - return -EINVAL; > > - > > - return 0; > > -} > > - > > static int get_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > u64 *val) > > { > > bool raz = sysreg_visible_as_raz(vcpu, rd); > > > > - return __get_id_reg(vcpu, rd, val, raz); > > + *val = read_id_reg(vcpu, rd, raz); > > + return 0; > > } > > > > static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > @@ -1258,7 +1232,11 @@ static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > { > > bool raz = sysreg_visible_as_raz(vcpu, rd); > > > > - return __set_id_reg(vcpu, rd, val, raz); > > + /* This is what we mean by invariant: you can't change it. */ > > + if (val != read_id_reg(vcpu, rd, raz)) > > + return -EINVAL; > > + > > + return 0; > > } > > I see no reason for read_id_reg() to take raz as an argument. > Perhaps having read_id_reg() call sysreg_visible_as_raz() instead > might make those functions even simpler? Good point, as this patch has done away with caller-specified RAZ. I'll incorporate that into v2. -- Best, Oliver