Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp208616iob; Mon, 2 May 2022 17:15:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtMyUv4B/w2+nOy+yBSGAxCOq6YmIKgDzioqT7KFrv1wkBC4BYKziL3zpniO/AnrSCCZwm X-Received: by 2002:a63:610a:0:b0:3c2:5e0d:e7a2 with SMTP id v10-20020a63610a000000b003c25e0de7a2mr2872959pgb.444.1651536936937; Mon, 02 May 2022 17:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651536936; cv=none; d=google.com; s=arc-20160816; b=hdninHAfGRmfvOX9PJ+b30fbDpNwtjtvrcuE5UsTtgF9nDbheTuSpt3VbDtkJH1kjH z9FgMGYEwpOjcvMvtz2SWipA7g+GspqGbrK7GvGFwv/tdsQMPU7l+HYoPkX98TTQAJYW qfd/Un5oOeUHynb+lwc+LnNkjs0GynPsmIIX1BnZ7kPPF7fkJ5IrEBmUFYBJJ54ysRjh mzZxRGVCmmkRn3BbvVZewUyNZ7lslN1j+kU2IM3QpHSpcDUSGa7ZS3al/I5Pg3WWoJnp IYoFysnH0Zep2A4AXUEWm593pGmzGdFkfha9tGEIS81sg7pVGXuTuhw1HJxM/HMXj2ef vliw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PNUkiMcCvuqau25R+EENrrWPTYBEDVmpTh7ORFLGfdQ=; b=uIj+VbttGyx4VkNY1RgiPEBK79k1KCDucRkvoBu+f1IeETFZLOqP05LEsR9jT1wY6C ZfquM78XNQ/0aW7eLpIJd4/rxuo+5pE28kF22ILv1lIlHrqABqkpo9XzepY4ETKOD5b5 GptFv+ct/vuTxRyNl+sctbmgqY3PrnbnWn5rFw6xoxgJv0vA9JhMNeSJ/MlOB2oDJGAn +cWcHFPLfOXFiwCIkit0JvCwaJ3MQoo6PvSGSqSZKOmx7oaAi0jRV90A+abrWYGpQ4fN O4ssUqfFyMMi1NzO5vtoDC9llbQbSdZPuDnI0d9Sud8q10HJPwBgU+TDXINCPr8U1qfW 3UXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=V5ewJa5J; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p9-20020a170902e74900b001586f9a109fsi2033234plf.0.2022.05.02.17.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:15:36 -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=@google.com header.s=20210112 header.b=V5ewJa5J; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AEFB813F09; Mon, 2 May 2022 17:13:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382802AbiD3OUP (ORCPT + 99 others); Sat, 30 Apr 2022 10:20:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382800AbiD3OUO (ORCPT ); Sat, 30 Apr 2022 10:20:14 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E49A551E6B for ; Sat, 30 Apr 2022 07:16:51 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id c125so12341819iof.9 for ; Sat, 30 Apr 2022 07:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PNUkiMcCvuqau25R+EENrrWPTYBEDVmpTh7ORFLGfdQ=; b=V5ewJa5J23zM0KK4rrTVTkAiVJ/H28FHkYVWnfpJ3enYsHDRuCr7ybFix6+yPH6qtX b1tYX8kPl1TKvrEWFpQpoLCjMNSJ2SOsqjy2LnZ7mK4S1faBrQxvDz4e8Z/tes+7IT5p zr0etttNhsUpECK3hF+7Px6H6fEY+0SLcGLbUIjQjAmTgc9I7Ik6+QfP2eNH4OSjAOkk CLbNEVsYYY2O6uNiVBxyu7YLtMpcgl/adK0QkIGi54g671vik+F80kUdVP7mXcrbMlDp 8R3lsQDBUO+tYdS4LND9ZHnhFlN4c+Cuiiq212y/NOV3VPaYtoicSvj6lt7jSdREqfH/ MIqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PNUkiMcCvuqau25R+EENrrWPTYBEDVmpTh7ORFLGfdQ=; b=2AuvkALRfCqCNJ7701NFMIFBX99Q1+SliD3naAw4vON85co/meDNKZ6SLtxvzi581b 2lc3lcEEGHu8wbfgyFhODUzuFlC2FdpSs5+pgNXoMfZfV7hwOHsVXv+3OSnr4tamHnZL tmNaI1nWlU85l7I53hq8+C5+wzHYkS9TobZCIhkKOE0Zd+YYtPt930f7YYGKRmF1YXN9 kZA8ZmF4mRqUWnrB5T1UhMyYC0/adD7kJi8pNoBQvruLbtlRQem8VQ8v94qBk0UxS+vq B+vhD/Unomcs5b37Dj+itK2HMZuoCHoMntBg44y/9JfXEoX5C8Vqwp6mFJ3g0qodDWdp AoYg== X-Gm-Message-State: AOAM530oUy2JdDUbytvjBx0D2BVG+7NsTfEY6X0Zj5heHqrQyqBynN/P yfrBHSgk4SAjc5LR3WVwTJEwMg== X-Received: by 2002:a05:6602:482:b0:614:b990:28c9 with SMTP id y2-20020a056602048200b00614b99028c9mr1651794iov.6.1651328211000; Sat, 30 Apr 2022 07:16:51 -0700 (PDT) Received: from google.com (194.225.68.34.bc.googleusercontent.com. [34.68.225.194]) by smtp.gmail.com with ESMTPSA id y89-20020a029562000000b0032b3a78174asm1459351jah.14.2022.04.30.07.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Apr 2022 07:16:50 -0700 (PDT) Date: Sat, 30 Apr 2022 14:16:46 +0000 From: Oliver Upton To: Gavin Shan Cc: kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, eauger@redhat.com, Jonathan.Cameron@huawei.com, vkuznets@redhat.com, will@kernel.org, shannon.zhaosl@gmail.com, james.morse@arm.com, mark.rutland@arm.com, maz@kernel.org, pbonzini@redhat.com, shan.gavin@gmail.com Subject: Re: [PATCH v6 03/18] KVM: arm64: Add SDEI virtualization infrastructure Message-ID: References: <20220403153911.12332-1-gshan@redhat.com> <20220403153911.12332-4-gshan@redhat.com> <36899ea9-e8bd-27b2-8dfb-75b76eab50d7@redhat.com> <0e26da1a-00bb-3d63-a8bf-6cd3271b0a38@redhat.com> <96711526-c4f3-3b50-c015-beba8cc9fcc9@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <96711526-c4f3-3b50-c015-beba8cc9fcc9@redhat.com> X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 Gavin, On Sat, Apr 30, 2022 at 07:38:29PM +0800, Gavin Shan wrote: > Thank you for the comments and details. It should work by using bitmaps > to represent event's states. I will adopt your proposed structs in next > respin. However, there are more states needed. So I would adjust > "struct kvm_sdei_vcpu" like below in next respin. > > struct kvm_sdei_vcpu { > unsigned long registered; /* the event is registered or not */ > unsigned long enabled; /* the event is enabled or not */ > unsigned long unregistering; /* the event is pending for unregistration */ I'm not following why we need to keep track of the 'pending unregister' state directly. Is it not possible to infer from (active && !registered)? > unsigned long pending; /* the event is pending for delivery and handling */ > unsigned long active; /* the event is currently being handled */ > > : > > }; > > I rename @pending to @unregister. Besides, there are two states added: > > @pending: Indicate there has one event has been injected. The next step > for the event is to deliver it for handling. For one particular > event, we allow one pending event in the maximum. Right, if an event retriggers when it is pending we still dispatch a single event to the guest. And since we're only doing normal priority events, it is entirely implementation defined which gets dispatched first. > @active: Indicate the event is currently being handled. The information > stored in 'struct kvm_sdei_event_context' instance can be > correlated with the event. Does this need to be a bitmap though? We can't ever have more than one SDEI event active at a time since this is private to a vCPU. > Furthermore, it's fair enough to put the (vcpu) mask state into 'flags' > field of struct kvm_vcpu_arch :) I think you can get away with putting active in there too, I don't see why we need more than a single bit for this info. > > > > > > Do we need this if we disallow nesting events? > > > > > > > > > > > > > > > > Yes, we need this. "event == NULL" is used as indication of invalid > > > > > context. @event is the associated SDEI event when the context is > > > > > valid. > > > > > > > > What if we use some other plumbing to indicate the state of the vCPU? MP > > > > state comes to mind, for example. > > > > > > > > > > Even the indication is done by another state, kvm_sdei_vcpu_context still > > > need to be linked (associated) with the event. After the vCPU context becomes > > > valid after the event is delivered, we still need to know the associated > > > event when some of hypercalls are triggered. SDEI_1_0_FN_SDEI_EVENT_COMPLETE > > > is one of the examples, we need to decrease struct kvm_sdei_event::event_count > > > for the hypercall. > > > > Why do we need to keep track of how many times an event has been > > signaled? Nothing in SDEI seems to suggest that the number of event > > signals corresponds to the number of times the handler is invoked. In > > fact, the documentation on SDEI_EVENT_SIGNAL corroborates this: > > > > """ > > The event has edgetriggered semantics and the number of event signals > > may not correspond to the number of times the handler is invoked in the > > target PE. > > """ > > > > DEN0054C 5.1.16.1 > > > > So perhaps we queue at most 1 pending event for the guest. > > > > I'd also like to see if anyone else has thoughts on the topic, as I'd > > hate for you to go back to the whiteboard again in the next spin. > > > > Agreed. In next respin, we will have one pending event at most. Error > can be returned if user attempts to inject event whose pending state > (struct kvm_sdei_vcpu::pending) has been set. I don't believe we can do that. The SDEI_EVENT_SIGNAL call should succeed, even if the event was already pending. > Indeed, the hardest part is to determine the data structures and > functions we need. Oliver, your valuable comments are helping to > bring this series to the right track. However, I do think it's > helpful if somebody else can confirm the outcomes from the previous > discussions. I'm not sure if Marc has time for a quick scan and provide > comments. > > I would summarize the outcomes from our discussions, to help Marc > or others to confirm: Going to take a look at some of your later patches as well, just a heads up. > - Drop support for the shared event. > - Dropsupport for the critical event. > - The events in the implementations are all private and can be signaled > (raised) by software. > - Drop migration support for now, and we will consider it using > pseudo firmware registers. So add-on patches are expected to support > the migration in future. Migration will be supported in a future spin of this series, not a subsequent one right? :) I had just made the suggestion because there was a lot of renovations that we were discussing. > - Drop locking mechanism. All the functions are executed in vcpu context. Well, not entirely. Just need to make sure atomics are used to post events to another vCPU in the case of SDEI_EVENT_SIGNAL. set_bit() fits the bill here, as we've discussed. > - To use the data struct as you suggested. Besides, the vcpu's mask > state is put to struct kvm_arch_vcpu::flags. > enum kvm_sdei_event > struct kvm_sdei_event_handler > struct kvm_sdei_event_context > struct kvm_sdei_vcpu > > Thanks, > Gavin > -- Thanks, Oliver