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 D5990C433EF for ; Mon, 11 Jul 2022 09:43:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 826D74BB79; Mon, 11 Jul 2022 05:43:01 -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 gRHldkyXytjO; Mon, 11 Jul 2022 05:43:00 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id EB50B4BB54; Mon, 11 Jul 2022 05:42:57 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id AD6B84B57E for ; Fri, 8 Jul 2022 15:35:38 -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 IwfrxHUcSqVO for ; Fri, 8 Jul 2022 15:35:37 -0400 (EDT) Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 88CA94B569 for ; Fri, 8 Jul 2022 15:35:37 -0400 (EDT) Date: Fri, 8 Jul 2022 12:35:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1657308932; 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=3Ycz7xdndecdoawfzbIyPAd3t3ebJtVTm3UIiAKwNFg=; b=olzZ+ookEIfsTd28pXfJRmRAuF2JhpMmJkZGekjmDkJWrRfcTMaB4oKdkxiZnMiKk1m9pp 0qjzQzyC4BkzeXkoddp7UEhYYP3FV7I+XT8g4sLVkvS8MLL+lToUNsChah6E3OfBHQcqtD EWKCDcynDRaXTRZgGSXVaFl8j2Z0eN4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Subject: Re: [PATCH 06/19] KVM: arm64: Get rid of reg_from/to_user() Message-ID: References: <20220706164304.1582687-1-maz@kernel.org> <20220706164304.1582687-7-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220706164304.1582687-7-maz@kernel.org> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Mailman-Approved-At: Mon, 11 Jul 2022 05:42:55 -0400 Cc: kvm@vger.kernel.org, kernel-team@android.com, Schspa Shi , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.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 On Wed, Jul 06, 2022 at 05:42:51PM +0100, Marc Zyngier wrote: > 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. > > Signed-off-by: Marc Zyngier Reviewed-by: Oliver Upton > --- > arch/arm64/kvm/sys_regs.c | 33 +++++++++------------------------ > 1 file changed, 9 insertions(+), 24 deletions(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 1ce439eed3d8..b66be9df7a02 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -44,8 +44,6 @@ > * 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 bool read_from_write_only(struct kvm_vcpu *vcpu, > @@ -2661,21 +2659,7 @@ static struct sys_reg_desc invariant_sys_regs[] = { > { SYS_DESC(SYS_CTR_EL0), NULL, get_ctr_el0 }, > }; > > -static int reg_from_user(u64 *val, const void __user *uaddr, u64 id) > -{ > - 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) > +static int get_invariant_sys_reg(u64 id, u64 __user *uaddr) > { > const struct sys_reg_desc *r; > > @@ -2684,23 +2668,24 @@ static int get_invariant_sys_reg(u64 id, void __user *uaddr) > if (!r) > return -ENOENT; > > - return reg_to_user(uaddr, &r->val, id); > + if (put_user(r->val, uaddr)) > + return -EFAULT; > + > + return 0; > } > > -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; > - int err; > - u64 val = 0; /* Make sure high bits are 0 for 32-bit regs */ > + u64 val; > > r = get_reg_by_id(id, invariant_sys_regs, > ARRAY_SIZE(invariant_sys_regs)); > if (!r) > return -ENOENT; > > - err = reg_from_user(&val, uaddr, id); > - if (err) > - return err; > + if (get_user(val, uaddr)) > + return -EFAULT; > > /* This is what we mean by invariant: you can't change it. */ > if (r->val != val) > -- > 2.34.1 > _______________________________________________ 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 20DDAC43334 for ; Fri, 8 Jul 2022 19:36:31 +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=TEtbSu15i6nNisr9btcWB+4efpAawDgp/284MC1sXtk=; b=RGjFxGCv3+fZDm FNYHio2tqVVNNI02EwejlTZ6iIOSgRGnwlCQgEI076HJgghPjVQPmH+Z6UzDuQLdtyqt3REBfCnik pKXG/Idf/UI/B4O4wio9OypV2GX3t4Ahzil0NTDFL5j6rhJwb/2Ohyn2esEBNrRuntO0jWvkWw3nd SGhZLZzgGkCqZOlbig+14kLiDr18ZmcnHD9itDky/e68Yd1VHO/ThBvk7ygmWpv2mVZXWpBIoqi5w juQMxjet+AqY8zMv6I2X6M78DRyFrINY/x0NWmspPbScjisnpu4nKWIwFO5PgsNA0XRiUp9OfwEWq wN6CtsRoSrgGMxu9/x5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9tlM-005cw0-Q6; Fri, 08 Jul 2022 19:35:40 +0000 Received: from out1.migadu.com ([91.121.223.63]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9tlK-005cuz-23 for linux-arm-kernel@lists.infradead.org; Fri, 08 Jul 2022 19:35:39 +0000 Date: Fri, 8 Jul 2022 12:35:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1657308932; 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=3Ycz7xdndecdoawfzbIyPAd3t3ebJtVTm3UIiAKwNFg=; b=olzZ+ookEIfsTd28pXfJRmRAuF2JhpMmJkZGekjmDkJWrRfcTMaB4oKdkxiZnMiKk1m9pp 0qjzQzyC4BkzeXkoddp7UEhYYP3FV7I+XT8g4sLVkvS8MLL+lToUNsChah6E3OfBHQcqtD EWKCDcynDRaXTRZgGSXVaFl8j2Z0eN4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Alexandru Elisei , Schspa Shi , kernel-team@android.com Subject: Re: [PATCH 06/19] KVM: arm64: Get rid of reg_from/to_user() Message-ID: References: <20220706164304.1582687-1-maz@kernel.org> <20220706164304.1582687-7-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220706164304.1582687-7-maz@kernel.org> 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-20220708_123538_273741_89436AE5 X-CRM114-Status: GOOD ( 21.58 ) 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 Wed, Jul 06, 2022 at 05:42:51PM +0100, Marc Zyngier wrote: > 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. > > Signed-off-by: Marc Zyngier Reviewed-by: Oliver Upton > --- > arch/arm64/kvm/sys_regs.c | 33 +++++++++------------------------ > 1 file changed, 9 insertions(+), 24 deletions(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 1ce439eed3d8..b66be9df7a02 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -44,8 +44,6 @@ > * 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 bool read_from_write_only(struct kvm_vcpu *vcpu, > @@ -2661,21 +2659,7 @@ static struct sys_reg_desc invariant_sys_regs[] = { > { SYS_DESC(SYS_CTR_EL0), NULL, get_ctr_el0 }, > }; > > -static int reg_from_user(u64 *val, const void __user *uaddr, u64 id) > -{ > - 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) > +static int get_invariant_sys_reg(u64 id, u64 __user *uaddr) > { > const struct sys_reg_desc *r; > > @@ -2684,23 +2668,24 @@ static int get_invariant_sys_reg(u64 id, void __user *uaddr) > if (!r) > return -ENOENT; > > - return reg_to_user(uaddr, &r->val, id); > + if (put_user(r->val, uaddr)) > + return -EFAULT; > + > + return 0; > } > > -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; > - int err; > - u64 val = 0; /* Make sure high bits are 0 for 32-bit regs */ > + u64 val; > > r = get_reg_by_id(id, invariant_sys_regs, > ARRAY_SIZE(invariant_sys_regs)); > if (!r) > return -ENOENT; > > - err = reg_from_user(&val, uaddr, id); > - if (err) > - return err; > + if (get_user(val, uaddr)) > + return -EFAULT; > > /* This is what we mean by invariant: you can't change it. */ > if (r->val != val) > -- > 2.34.1 > _______________________________________________ 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 D539CC433EF for ; Fri, 8 Jul 2022 19:35:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238874AbiGHTfj (ORCPT ); Fri, 8 Jul 2022 15:35:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238121AbiGHTfi (ORCPT ); Fri, 8 Jul 2022 15:35:38 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200FB57245 for ; Fri, 8 Jul 2022 12:35:38 -0700 (PDT) Date: Fri, 8 Jul 2022 12:35:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1657308932; 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=3Ycz7xdndecdoawfzbIyPAd3t3ebJtVTm3UIiAKwNFg=; b=olzZ+ookEIfsTd28pXfJRmRAuF2JhpMmJkZGekjmDkJWrRfcTMaB4oKdkxiZnMiKk1m9pp 0qjzQzyC4BkzeXkoddp7UEhYYP3FV7I+XT8g4sLVkvS8MLL+lToUNsChah6E3OfBHQcqtD EWKCDcynDRaXTRZgGSXVaFl8j2Z0eN4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Alexandru Elisei , Schspa Shi , kernel-team@android.com Subject: Re: [PATCH 06/19] KVM: arm64: Get rid of reg_from/to_user() Message-ID: References: <20220706164304.1582687-1-maz@kernel.org> <20220706164304.1582687-7-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220706164304.1582687-7-maz@kernel.org> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Wed, Jul 06, 2022 at 05:42:51PM +0100, Marc Zyngier wrote: > 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. > > Signed-off-by: Marc Zyngier Reviewed-by: Oliver Upton > --- > arch/arm64/kvm/sys_regs.c | 33 +++++++++------------------------ > 1 file changed, 9 insertions(+), 24 deletions(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 1ce439eed3d8..b66be9df7a02 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -44,8 +44,6 @@ > * 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 bool read_from_write_only(struct kvm_vcpu *vcpu, > @@ -2661,21 +2659,7 @@ static struct sys_reg_desc invariant_sys_regs[] = { > { SYS_DESC(SYS_CTR_EL0), NULL, get_ctr_el0 }, > }; > > -static int reg_from_user(u64 *val, const void __user *uaddr, u64 id) > -{ > - 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) > +static int get_invariant_sys_reg(u64 id, u64 __user *uaddr) > { > const struct sys_reg_desc *r; > > @@ -2684,23 +2668,24 @@ static int get_invariant_sys_reg(u64 id, void __user *uaddr) > if (!r) > return -ENOENT; > > - return reg_to_user(uaddr, &r->val, id); > + if (put_user(r->val, uaddr)) > + return -EFAULT; > + > + return 0; > } > > -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; > - int err; > - u64 val = 0; /* Make sure high bits are 0 for 32-bit regs */ > + u64 val; > > r = get_reg_by_id(id, invariant_sys_regs, > ARRAY_SIZE(invariant_sys_regs)); > if (!r) > return -ENOENT; > > - err = reg_from_user(&val, uaddr, id); > - if (err) > - return err; > + if (get_user(val, uaddr)) > + return -EFAULT; > > /* This is what we mean by invariant: you can't change it. */ > if (r->val != val) > -- > 2.34.1 >