Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 486B7C433DF for ; Thu, 9 Jul 2020 05:35:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 111BD20657 for ; Thu, 9 Jul 2020 05:35:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="c/Y90lmR"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Fa4XBalT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 111BD20657 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:Reply-To:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R1YPZAEk+e0yTNzqiHVgRMCL7EwCCpKGCuqhhi2wkWE=; b=c/Y90lmRrt1Ln2 CUMfQMKMQTyW1KWk8mg7Bc+5cWv4hODYHc4olUVMpmyyfqIKgVg+Cr4joY6+tSIFSHWokft5kPNCU HfR+94hwtWDUsz6KWXQJw8DX1abSesF0rOYSukXfr8vdCaaf6xeE4H4UkDESlU5hECQ3ghWLnK4SK tqbPEueHzZ0E4V3SxhpmdZdGg2DkR8fKG/sll8WfR/EvCdubhcrtQFNUe7NnZoAMAMCNS6sPbjbKX VsKzRbV3i3aMKpgsHVIuoTq7z88ujQpsAOlYkeVjlwFMVo4/ODkkwOuxXtrSYHbZVO6LoLIV+adKd 9i8rzC/FONHLG4SI6N+A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtPC1-0002NT-JJ; Thu, 09 Jul 2020 05:33:57 +0000 Received: from us-smtp-1.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jtPBw-0002Ld-2s for linux-arm-kernel@lists.infradead.org; Thu, 09 Jul 2020 05:33:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594272830; 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=kUZ+qV4jcdmguAybsURaQwp1u9VfFlI7Mox20D8kRQo=; b=Fa4XBalTeETRJbBFVchsHA0PFnOBzPQAwSHm8eCDtAYj68l8RKekacWWXmVum1U/l2yHAR gWtPZJ4OolK12Q4QkjaX6P8KxRUfPav57/u9pdwOAKTxfaolsSE0b+6R/UaHsL0Tu4h1Su zvC4QfNCoNPXp6DFMfqJOQtIq1vVa2M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-163-WfAK_i3OPDmbfaEqv3tK4Q-1; Thu, 09 Jul 2020 01:33:48 -0400 X-MC-Unique: WfAK_i3OPDmbfaEqv3tK4Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54B261902EA0; Thu, 9 Jul 2020 05:33:47 +0000 (UTC) Received: from localhost.localdomain (vpn2-54-54.bne.redhat.com [10.64.54.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2C0B2B6D8; Thu, 9 Jul 2020 05:33:45 +0000 (UTC) Subject: Re: [Question] How to testing SDEI client driver To: Paolo Bonzini , James Morse References: <8cdef8ea-e550-ccff-2041-526d6f6fcda0@redhat.com> <3cc7e69c-9315-5138-85f7-7b36e17b67a1@redhat.com> <2b5ef5b2-cf6b-3f4e-4250-c1d0a34e9873@arm.com> <69ecf58f-bf9d-6c2d-37ab-4397b30fff4b@redhat.com> From: Gavin Shan Message-ID: <7c234a0a-3a64-b893-cb40-4b5cca865beb@redhat.com> Date: Thu, 9 Jul 2020 15:33:41 +1000 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: <69ecf58f-bf9d-6c2d-37ab-4397b30fff4b@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=gshan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200709_013352_224737_FCDF5C0B X-CRM114-Status: GOOD ( 30.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Gavin Shan Cc: mark.rutland@arm.com, maz@kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi James and Paolo, On 7/9/20 2:49 AM, Paolo Bonzini wrote: > On 08/07/20 18:11, James Morse wrote: >> On 03/07/2020 01:26, Gavin Shan wrote: >>> On 7/1/20 9:57 PM, James Morse wrote: >>>> On 30/06/2020 06:17, Gavin Shan wrote: [...] >> >>> Sorry that I didn't mention the story a bit last time. We plan to use SDEI to >>> deliver the notification (signal) from host to guest, needed by the asynchronous >>> page fault feature. The RFCv2 patchset was post a while ago [1]. >> >> Thanks. So this is to hint to the guest that you'd swapped its memory to disk. Yuck. >> >> When would you do this? > > These days, the main reason is on-demand paging with live migration. > Instead of waiting to have a consistent version of guest memory on the > destination, memory that the guest has dirtied can be copied on demand > from source to destination while the guest is running. Letting the > guest reschedule is surprisingly effective in this case, especially with > workloads that have a lot of threads. > Paolo, thanks for the explanation. [...] >>> For the SDEI >>> events needed by the async page fault, it's originated from KVM (host). In order >>> to achieve the goal, KVM needs some code so that SDEI event can be injected and >>> delivered. Also, the SDEI related hypercalls needs to be handled either. >> >> I avoided doing this because it makes it massively complicated for the VMM. All that >> in-kernel state now has to be migrated. KVM has to expose APIs to let the VMM inject >> events, which gets nasty for shared events where some CPUs are masked, and others aren't. >> >> Having something like Qemu drive the reference code from TFA is the right thing to do for >> SDEI. > > Are there usecases for injecting SDEIs from QEMU? > > If not, it can be done much more easily with KVM (and it would also > would be really, really slow if each page fault had to be redirected > through QEMU), which wouldn't have more than a handful of SDEI events. > The in-kernel state is 4 64-bit values (EP address and argument, flags, > affinity) per event. > I don't think there is existing usercase to inject SDEIs from qemu. However, there is one ioctl command is reserved for this purpose in my code, so that QEMU can inject SDEI event if needed. Yes, the implementation of my code is done in kvm to inject SDEI event directly, on request received from the consumer like APF. By the way, I just finished splitting the code into RFC patches. Please let me I should post it to provide more details, or it should be deferred until this discussion is finished. >>> Yes, The SDEI specification already mentioned >>> this: the client handler should have all required resources in place before >>> the handler is going to run. However, I don't see it's a problem so far. >> >> What if they are swapped out? This thing becomes re-entrant ... which the spec forbids. >> The host has no clue what is in guest memory. > > On x86 we don't do the notification if interrupts are disabled. On ARM > I guess you'd do the same until SDEI_EVENT_COMPLETE (so yeah that would > be some state that has to be migrated). In fact it would be nice if > SDEI_EVENT_COMPLETE meant "wait for synchronous page-in" while > SDEI_EVENT_COMPLETE_AND_RESUME meant "handle it asynchronously". > I'm not sure I understand this issue completely. When the vCPU is preempted, all registers should have been saved to vcpu->arch.ctxt. The SDEI context is saved to vcpu->arch.ctxt either. They will be restored when the vCPU gets running afterwards. From the syntax perspective, it's not broken. Yes, I plan to use private event, which is only visible to kvm and guest. Also, it has critical priority. The new SDEI event can't be delivered until the previous critical event is finished. Paolo, it's intresting idea to reuse SDEI_EVENT_COMPLETE/AND_RESUME. Do you mean to use these two hypercalls to designate PAGE_NOT_READY and PAGE_READY separately? If possible, please provide more details. [...] Thanks, Gavin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel