Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2587564rwb; Wed, 30 Nov 2022 08:22:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ve7c3jWfbDMi2Dl/u/4Y4GrekqTLgyQLFbalsU920s97vR4k4IHZZj5NVvvKqm2h/qMxQ X-Received: by 2002:a17:907:c70a:b0:7ad:d6c6:eb7c with SMTP id ty10-20020a170907c70a00b007add6c6eb7cmr44331340ejc.249.1669825336099; Wed, 30 Nov 2022 08:22:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669825336; cv=none; d=google.com; s=arc-20160816; b=ssukjC4rM7F/MyspY0ucky8vTnZsXXnJu9hQOvij/oNJkChd9MK0TfhhBlYULxr9uE nxI1Q5qA6XtsfO4yXODn+nZ04entFBiRXQ/rxfAd3MkA8ed2ZmhXOjPK4X6gloEwC18v gTYFmJh3a3bpW2wteIha6zU1pZjknNMx8Nh7HGzQcn4TABGh742Xo2SAFXkfEivNSAld T966BdlqtYKaQ5k2mFO8P1eOOtwNdsJ91deQSdSm0OCp5H44kITHjQRKRoBEtSMHYoKv Mn8xd8ieM5xP1Qth9Tzlu2ziU6yDJO8VMKclxHOC0z+cz4AhqbmF7OOslx8QL6bcTdbA hdOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=F3sWtcU7a7aYF64WpYOXHrijQk18lttkWuDDJI5zwjE=; b=WAWsgMh7CGC/1gEjurh+mtb2oLuP/R0ahhiobh3nZfL5LHqt0thqEnb6vsjCO45Z+0 ZfCjqfcTKvL+OYT2l9iBEdXlAPpD0NltqQKQGYjNol9IPLSDwF5AYsJontO6TQn0gYPO 4GoeRK3BjzsWWQYMlVFrRiph0If6KSFZOqaWttyxCu0We8WajyDl7uHWsUhwYlO/ijXb x3Uug2I/izeH8E05xECHa3qh8PWYMTeh8TAmRQrGR32a29lWH5DAbyqMdkNZnqfFwurN 4PRBoXDiQtt1wSJa30SsXelTIE9FQaX5acjYV7dc3VFIXtOWgCTYVOxHFCUgcCroVH7Q hoaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qljpPVH1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l14-20020a50d6ce000000b00458a650f3fasi1544167edj.409.2022.11.30.08.21.55; Wed, 30 Nov 2022 08:22:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qljpPVH1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230114AbiK3QEJ (ORCPT + 83 others); Wed, 30 Nov 2022 11:04:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbiK3QEI (ORCPT ); Wed, 30 Nov 2022 11:04:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 384CA43861; Wed, 30 Nov 2022 08:04:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B09DA61CD1; Wed, 30 Nov 2022 16:04:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91EDDC433C1; Wed, 30 Nov 2022 16:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669824247; bh=F3sWtcU7a7aYF64WpYOXHrijQk18lttkWuDDJI5zwjE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=qljpPVH1X/YzQkI471Z5zFai4D6J7ig8vaK36cf/yQl9LtdX6cnagLUpDf592B5G2 tRBwIZAFi0V7VHmC0A/+jpl/AiUrq77XV2/9KS8MNBRXFQgTRnsyU6SGiUEHKWgumQ 7qItlXEulP8r7LSDjQRBwxJmnIY/THzjqngUTjfve/2wtFb6vZ1YFhUcqfwSYFJ/Mn F+ZggTdDzWlNDO5DWbsmKyWFUrU9DL1cWG6FpkkdJQl+dMgzPs5bXUALUTxdagTdV+ uFzrUdBMz2yEBZw7bpkfsDzTrojbx2J+o6IPhWKe/c2d3pobnAgArC0WDsUjzj2l14 b3f3O0x8pi7Cg== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Pu Lehui , bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Paul Walmsley , Palmer Dabbelt , Albert Ou , Pu Lehui , Pu Lehui Subject: Re: [PATCH bpf] riscv, bpf: Emit fixed-length imm64 for BPF_PSEUDO_FUNC In-Reply-To: <87h6yg1xlo.fsf@all.your.base.are.belong.to.us> References: <20221130033806.2967822-1-pulehui@huaweicloud.com> <87h6yg1xlo.fsf@all.your.base.are.belong.to.us> Date: Wed, 30 Nov 2022 17:04:04 +0100 Message-ID: <87a648ig3v.fsf@all.your.base.are.belong.to.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Bj=C3=B6rn T=C3=B6pel writes: > The range of valid address for RV64 (sv39 to sv57) are > 0xffffffff00000000 to 0xffffffffffffffff, so I think we can do better > than 6 insn, no? My gut feeling (I need to tinker a bit) is that 4 > should be sufficient. Ok, thinking a bit more about it; A proper address will at have at least 2B alignment, so that means that we can construct an address with lui, addi, and slli (31 bits). u64 addr =3D 0xffffffff12345678; u32 (imm |=3D 0xffffffffUL) >> 1; u32 upper =3D (imm + (1 << 11)) >> 12; u32 lower =3D imm & 0xfff; u32 rupper =3D upper | 0x80000; // for sign extend NB! Make sure it's !C insn, and emit: lui xx, rupper addi xx, xx, lower slli xx, xx, 1 Now we'll have fixed three insns. WDYT? Bj=C3=B6rn