Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2661474pxb; Mon, 18 Apr 2022 05:49:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxrY8lcMcVgpj/KZOKqR7V5Fu4L07ghPTr229vh+OuNYMZafPvDNcQxSPep2Leln+RvCQt X-Received: by 2002:a05:6a00:148a:b0:50a:40f7:5a80 with SMTP id v10-20020a056a00148a00b0050a40f75a80mr12378293pfu.58.1650286197674; Mon, 18 Apr 2022 05:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650286197; cv=none; d=google.com; s=arc-20160816; b=oBlAbwI80/jWzDT9BVLgshZbJLJOX3RsCLOMLVdtWdLTejslUx1vehNWg6b5Pefdmg c/OMOwk3Ow2sjl7YdnIh1JIIBiSl4KAhhhf2lrSPJCT9X+Upp/i3XMJjgcp/samhJEip oKStqFOw4ouuXbc28rKPTYaI7HvDfA14pm6anFT3UMKp3FYFyCIa9NvI2JoX0Ws+/KG8 KpxJbBy4qEI/r5OOAu9VKmoUExD9YQLiqsbheEPuB9/djkHYFx4Y3Q9IPriYrmTYjami OwU3ABoOehPlHLRhkan6KT/neXTUy+k6KHNVe1X7eg8vTv6ruP7rZVqKU+UR13obckGS YcDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:reply-to:dkim-signature; bh=SAA55/OcVLuGltaWPBBCrOhinXHqpswrBBNXxyLN+Rc=; b=KD4YZMvw6x/oFdaIA/YSu4v0Ei0huuRYFiondfgTEDMKyA1KIMOX3Xa8zrg3w0/m8p zNoXJLNacAy35ZSmnJMC+sbEVwh/ejQm8gO6M6I+V6VGFEYcYvr41qdPzUMi/Qm42RrG O/McZRGeLXncEtAuuFmyjrR+5xS6f0UOf4zjX3bsYywx+up78rU3FAIQaXAgHBA4gq+/ r8Ah5tGvRbnI//yeshclPcAOPWBRao415mSeW+qPCh9oB3qbwL9jHR8vmNor7Zs84d+i r2cpkf2HqaAFL4e2mrj8qEb6LPvyGqw8f5Y7DGeqP6DNy95sr/PkqAs75FliYdQu0iBn W9nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NkJ+9YSY; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x36-20020a634a24000000b003816043f0dasi9109234pga.719.2022.04.18.05.49.42; Mon, 18 Apr 2022 05:49:57 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=NkJ+9YSY; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235902AbiDRC46 (ORCPT + 99 others); Sun, 17 Apr 2022 22:56:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235897AbiDRC44 (ORCPT ); Sun, 17 Apr 2022 22:56:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EAF7517E3A for ; Sun, 17 Apr 2022 19:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650250458; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SAA55/OcVLuGltaWPBBCrOhinXHqpswrBBNXxyLN+Rc=; b=NkJ+9YSYBxdDFPeY82j3pnk+9NFI6LsCmCA4DPMZN5vYsYHV1ZihYo63DVaOi2MDKmGa6u FDO4rxwfUBvSMgN3m2B98c6lXMeysvmSkr/yiha6PPwXNMrinqhPxZU33p+GdUkFfXENfp gpzaMB9kYz9KFKQcUEjiFYmtklZc0u8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-568-Qwn9yRcYNxGw18zXIgXPpA-1; Sun, 17 Apr 2022 22:54:12 -0400 X-MC-Unique: Qwn9yRcYNxGw18zXIgXPpA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4BB45101AA42; Mon, 18 Apr 2022 02:54:11 +0000 (UTC) Received: from [10.72.13.171] (ovpn-13-171.pek2.redhat.com [10.72.13.171]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3608B40F4961; Mon, 18 Apr 2022 02:54:03 +0000 (UTC) Reply-To: Gavin Shan Subject: Re: [PATCH v5 00/10] KVM: arm64: Add support for hypercall services selection To: Marc Zyngier 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 References: <20220407011605.1966778-1-rananta@google.com> <92eb2304-9259-0461-247f-d3a4e5eb4fd5@redhat.com> <8735iebu48.wl-maz@kernel.org> From: Gavin Shan Message-ID: <8d257221-e3bf-b5fc-5cf4-01f9fff53eca@redhat.com> Date: Mon, 18 Apr 2022 10:53:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <8735iebu48.wl-maz@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_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 Hi Marc, On 4/15/22 4:58 PM, Marc Zyngier wrote: > On Fri, 15 Apr 2022 07:44:55 +0100, > Gavin Shan wrote: >> 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). > Yeah, I'm chime-in this series lately. There must be some discussions, including this topic, I missed :) >> >> 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. > Ok. >> 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. > The reason why I raised question is just to check if it's a missed point in the design. As I said, I obviously missed the previous discussions and glad that this has been discussed through. Thanks for the details. Yes, it's totally fine to migrate 8KB data. Besides, VMM (QEMU) can choose to do migration on one single vcpu, instead of all of them, as you said. Thanks, Gavin