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 15B7CCA100B for ; Sat, 31 Aug 2024 07:43: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rvXB2cpO0G0IphOj3nm5pVDtAImlUuj0yMMtT3rYFjM=; b=kGzmDKQqzFlu4R2QAE5jHkkZI2 YeiXwTkeqYjU3Y/vHP6OWTVcO5xf0MLAxbWv+SEk/DfpNA7hb3l5qI46kS4WDbwdNFRUGdwSGJVdS gnZL2r+05Z3WXKbEaME6jsGY+YA7CGVFho81+urIoquxuS58M8nQH9SCdK8dHfjlw3d1xt/lQP28z DNKYVXnHPs/lw4sRjilynAALErld3KUUjAQaGdf1h9pHQkhC81a5sZAyK5Pt5lt6PUAymeL0uy9CE sCDmApHEUThCSqsdrmN9GWOp+bgxVEKlxizYJvQWoJzmmwTPIfFYb1bNrCw5DuS0VUkcpKZl3Pdiy 8dML4k9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skIlV-00000008sJh-3PgA; Sat, 31 Aug 2024 07:43:21 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skIkd-00000008sFw-1cYs for linux-arm-kernel@lists.infradead.org; Sat, 31 Aug 2024 07:42:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 94B455C0FA3; Sat, 31 Aug 2024 07:42:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 924FDC4CEC0; Sat, 31 Aug 2024 07:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725090146; bh=CSYles6ImJnP6hRgL02AQveRmBHZZvF8jl7dwBIrqss=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tn0HWQeuZfUPF/N6YWMS4/kIkP/e80G4QduNmZ186OA2/aDlwmBaNQ5jPMh3h5MXV 8PqZdrQdMSAWU0TUxH1kAhPPckZyXnTDRBqHNndHMOoZ+gsrqWswRH4ZA0WvpqohFr 3VH1Ljj2nqhiZgBh+kIr4vmILJ763GWrG5zCPUcEkxdvMeRkpXCZAJgxfdLhpYVmK4 /p9WGi3pIQPYbKN0ghTwVOpxUkkDe/RPZMkSTcxsfpcSblT56zn0Kf09Zy1KJICtpC zHHCsJJbHaQzUdRxb0cUGF+c9csvH+TnmNwe0PvUptstp9Ukf4g7P6+yEeguh/2r0g LJB3+stHfRLXw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1skIka-008RVF-7l; Sat, 31 Aug 2024 08:42:24 +0100 Date: Sat, 31 Aug 2024 08:42:23 +0100 Message-ID: <86zfotuoio.wl-maz@kernel.org> From: Marc Zyngier To: Tangnianyao Cc: Will Deacon , , , , , "guoyang (C)" , Ard Biesheuvel Subject: Re: Question on get random long worse in VM than on host In-Reply-To: <214e37e9-7aba-1e61-f63f-85cb10c9a878@huawei.com> References: <214e37e9-7aba-1e61-f63f-85cb10c9a878@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tangnianyao@huawei.com, will@kernel.org, oliver.upton@linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, guoyang2@huawei.com, ardb@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240831_004227_489421_7259E689 X-CRM114-Status: GOOD ( 18.96 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org [+ Ard, who actually understands the whole RNG thing] On Sat, 31 Aug 2024 04:34:33 +0100, Tangnianyao wrote: > > Hi, all > > On ARM64 server(Kunpeng), performance of some syscall cases (like fork > and open) in guest, which need random u64, are 10~20% worse than > those on host. Because CONFIG_ARCH_HAS_ELF_RANDOMIZE=y and > CONFIG_STACKPROTECTOR=y, guest kernel need random u64 and > require them from host kvm using hvc. > > If FEAT_RNG is supported and EL3 firmware not support smccc trng, host > kvm finally return random u64 using RNDRRS to guest. > > Shall we firstly let guest get random u64 from RNDRRS to avoid hvc trap? > For example, if host find smccc trng not available, then tell guest smccc > trng not available when guest check trng version. My recollection is that it was a deliberate decision to decouple what the host firmware offers from what the guest sees (we can always implement the SMCCC TRNG using any mechanism that the host has to deliver entropy). Now, userspace has almost complete freedom to expose what the guest sees in terms of PV services. In this particular case, it can write to the KVM_REG_ARM_STD_BMAP pseudo register to remove the KVM_REG_ARM_STD_BIT_TRNG_V1_0 bit from the bitmap, which will hide the functionality. Isn't this sufficient here? Given that you seem to be micro-optimising for a particular platform, this seems like the easiest way to reach your goal without having to change anything. Thanks, M. -- Without deviation from the norm, progress is not possible.