Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp986030pxb; Fri, 15 Apr 2022 17:28:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5kccEOdbFxv6LxMbGFBAfxi3Ew1zdEb9HbMstfP/eGOxCh1UE6jwOQsi2+QZjpVIS/JJ7 X-Received: by 2002:a63:1b10:0:b0:39d:9c2e:5c93 with SMTP id b16-20020a631b10000000b0039d9c2e5c93mr1126752pgb.133.1650068880192; Fri, 15 Apr 2022 17:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650068880; cv=none; d=google.com; s=arc-20160816; b=XaJwDpc1ujMpTq1qjr1ny/RnZxlPFrDYPHWWqDrcdXht5SQ5Hdv6+i+tCCnNCUHnFx jDvd5IVTnEBZA+JUZG24R37n+1u9+/kJf7/mrN7SwOJBp+SeMOZ4T5c7HfKt2qvpIuQY 7QZUYP+sX5Sc6Oyuip69N9HXHxSiF3VC3InklXmatGorC6C6m6z2Q4IFH8E7LA7mFH41 o2CMpHblJTumvtiEKO/41wJsaAJpq6nmjHngT07/wTWbsfCWAmExa/WnwIY0S2kKN9HT uwMNSb7Cmq+/ZA2taYEimoBnN+Wxy57cOMRd7DiZ9Pcx7QrhdPDqJofes/AoPCJ3IoxI Sk4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=LW/cxIkMV+KcV5YakpVjCj9cPSrPD+KnHGG+1ZCmEp4=; b=ye2FAjrfZEzzENga9PEG5P4FLTs+o2WugW9YPPFEATUqI6qdnRcMuAXvleoJgCcvS3 K2NT4rcanNS6deOh5dI6Gu634B9Ch0XzsCWYapCWaJ1FZ+RkcfmoqNtdzfJib8Xbqwn2 IbP7hJJANQtieImYKc29pV7yzrk6PBhzZvDIS2omdZbwUm99ZQbCbKDOKO98SeAX+KjG MCalWctR+1C5GNfMBep+tTdD8hchCTIr3ovFqscXy8NxznZt7gxXLFQt16IJyJJ91SLK UPt2Q9f5jQw2fzAStxus1xHPH8AUbksJ2MriB2csWsNPOXX7P3LesVJDgyVIdssLZb+k awGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hAuXqJM2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k62-20020a638441000000b0039db9ceaea8si2558861pgd.771.2022.04.15.17.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:28:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hAuXqJM2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27A09D8F7F; Fri, 15 Apr 2022 17:25:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351634AbiDOJBW (ORCPT + 99 others); Fri, 15 Apr 2022 05:01:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiDOJBU (ORCPT ); Fri, 15 Apr 2022 05:01:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD4174AE3C; Fri, 15 Apr 2022 01:58:52 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 6AC78B82BA2; Fri, 15 Apr 2022 08:58:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E5BDC385A5; Fri, 15 Apr 2022 08:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650013130; bh=hmyUcR5B3a1JYAACRpixD+wAFOU2ad1+pzcX/kp3Lqs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hAuXqJM27oaJH9m54lnFFKdgGSLq9IWJKcXBb4RixaCPDhmKw6bcRuphlBSv8kCg9 5223zUp5amCyY4TTwoGsdaodb9V1M+Y04gpx40/kbtZkTM3GnINtypYtauhJfyIu8h H19BDdhSnxbiksdwtxCyNqft2Hg9LG+5M1dpTmOD5NKFUpWSdoPq/jRDhNNHV2Deav UWDvt3GlDdn6DPBd8SyTCX4mCL09ChpkLmW50IThW0cxDLAZHasv6wKJbkA8W2Vkhw rarWgiR1EtvOP7MOApVVqifpYOwLS1G1RMaAZ0ObTc0FiTYZFgBbjewAizBcEVDq4e DURbPpho/L8ZA== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nfHmx-004W4x-H4; Fri, 15 Apr 2022 09:58:47 +0100 Date: Fri, 15 Apr 2022 09:58:47 +0100 Message-ID: <8735iebu48.wl-maz@kernel.org> From: Marc Zyngier To: Gavin Shan Cc: Raghavendra Rao Ananta , Andrew Jones , James Morse , Alexandru Elisei , Suzuki K Poulose , kvm@vger.kernel.org, Catalin Marinas , Peter Shier , linux-kernel@vger.kernel.org, Paolo Bonzini , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5 00/10] KVM: arm64: Add support for hypercall services selection In-Reply-To: <92eb2304-9259-0461-247f-d3a4e5eb4fd5@redhat.com> References: <20220407011605.1966778-1-rananta@google.com> <92eb2304-9259-0461-247f-d3a4e5eb4fd5@redhat.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/27.1 (x86_64-pc-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: gshan@redhat.com, rananta@google.com, drjones@redhat.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, kvm@vger.kernel.org, catalin.marinas@arm.com, pshier@google.com, linux-kernel@vger.kernel.org, pbonzini@redhat.com, will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Fri, 15 Apr 2022 07:44:55 +0100, Gavin Shan wrote: > > Hi Raghavendra, > > On 4/7/22 9:15 AM, Raghavendra Rao Ananta wrote: > > Continuing the discussion from [1], the series tries to add support > > for the userspace to elect the hypercall services that it wishes > > to expose to the guest, rather than the guest discovering them > > unconditionally. The idea employed by the series was taken from > > [1] as suggested by Marc Z. > > > > In a broad sense, the concept is similar to the current implementation > > of PSCI interface- create a 'firmware psuedo-register' to handle the > > firmware revisions. The series extends this idea to all the other > > hypercalls such as TRNG (True Random Number Generator), PV_TIME > > (Paravirtualized Time), and PTP (Precision Time protocol). > > > > For better categorization and future scaling, these firmware registers > > are categorized based on the service call owners. Also, unlike the > > existing firmware psuedo-registers, they hold the features supported > > in the form of a bitmap. > > > > During the VM initialization, the registers holds an upper-limit of > > the features supported by each one of them. It's expected that the > > userspace discover the features provided by each register via GET_ONE_REG, > > and writeback the desired values using SET_ONE_REG. KVM allows this > > modification only until the VM has started. > > > > Some of the standard function-ids, such as ARM_SMCCC_VERSION_FUNC_ID, > > need not be associated with a feature bit. For such ids, the series > > introduced an allowed-list, hvc_func_default_allowed_list[], that holds > > all such ids. As a result, the functions that are not elected by userspace, > > or if they are not a part of this allowed-list, will be denied for when > > the guests invoke them. > > > > Older VMMs can simply ignore this interface and the hypercall services > > will be exposed unconditionally to the guests, thus ensuring backward > > compatibility. > > > > [...] > > I rethinking about the design again and just get one question. Hopefully, > someone have the answer for us. The newly added 3 pseudo registers and > the existing ones like KVM_REG_ARM_PSCI_VERSION are all tied up with > vcpu, instead of VM. I don't think it's correct. I'm not sure if VM-scoped > pseudo registers aren't allowed by ARM architecture or the effort isn't > worthy to support it. We have had that discussion before (around version 2 of this series, if I remember well). > > These pseudo registers are introduced to present the available hypercalls, > and then they can be disabled from userspace. In the implementation, these 3 > registers are vcpu scoped. It means that multiple vcpus can be asymmetric > in terms of usable hypercalls. For example, ARM_SMCCC_TRNG hypercalls > can be enabled on vcpu0, but disabled on vcpu1. I don't think it's expected. No, that's not the way this is supposed to work. These hypercalls are of course global, even if the accessor is per-vcpu. This is similar to tons of other things, such as some of the PMU data, the timer virtual offset... the list goes on. If that's not what this code does, then it is a bug and it needs to be fixed. > On the other hand, the information stored in these 3 registers needs to > be migrated through {GET,SET}_ONE_REG by VMM (QEMU). all the information > stored in these 3 registers are all same on all vcpus, which is exactly > as we expect. In migration circumstance, we're transporting identical > information for all vcpus and it's unnecessary. Yes, we all understand that. My response to that was (and still is): - There is no need to invent a new userspace interface. The one we have is terrible enough, and we don't need another square wheel that would need to be maintained beside the existing one. - Let's say we have 1024 new pseudo-registers, 1024 vcpus, 64bit regs: that's 8MB worth of extra data. This is not insignificant, but also not really a problem given that such a large VM is probably attached to a proportionally large amount of memory. In practice, we're talking of less than 10 registers, and less than 100 vcpus. A crazy 8kB at most. Who cares? - If this is eventually deemed to be a *real* scalability problem, we can always expose a map of registers that are global, and let userspace know that it can elide the rest. Problem solved, backward compatibility preserved. And I'm willing to bet that we won't need it in my lifetime. Thanks, M. -- Without deviation from the norm, progress is not possible.