From patchwork Tue Jul 25 05:37:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 793194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xGn830LCmz9s2s for ; Tue, 25 Jul 2017 15:37:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ozlabs-ru.20150623.gappssmtp.com header.i=@ozlabs-ru.20150623.gappssmtp.com header.b="kRncAi7D"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xGn826KRlzDrFG for ; Tue, 25 Jul 2017 15:37:54 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ozlabs-ru.20150623.gappssmtp.com header.i=@ozlabs-ru.20150623.gappssmtp.com header.b="kRncAi7D"; dkim-atps=neutral X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from mail-it0-x242.google.com (mail-it0-x242.google.com [IPv6:2607:f8b0:4001:c0b::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xGn7t2vjtzDqpj for ; Tue, 25 Jul 2017 15:37:46 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ozlabs-ru.20150623.gappssmtp.com header.i=@ozlabs-ru.20150623.gappssmtp.com header.b="kRncAi7D"; dkim-atps=neutral Received: by mail-it0-x242.google.com with SMTP id t6so8909093itb.0 for ; Mon, 24 Jul 2017 22:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs-ru.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zbWxX1Rt3lc8pNLcZHvlgh39zTGxu2X3mBT6fe9sDDU=; b=kRncAi7DdmV0L9iVY/H/I9CyuijTFgzjjTKmHqjLGbx07/FepqxeE+THAB6YlXyaRb kJ4Wtw7eSIvgXfEWF7RrxLSDWY2QK8k04jsyztuRhDd9xU1N0NmhBXFZM1s1YkDDS8lx zdW/0lTEhOqVcrU+3MK99ohKC/uBqUOY0sl1ZaC+pMcCeaKwcVUvJjqfBrckOYZcCAdx eyMDqqiwMP5KxRdZq8Idh5dua8l2rpTAqt8xp4pN91lyXZ8h7VFfNyAn0810DQ3HzpoD nDfd0BLo2CiDtElJXqkcbuyp6z9eF2Rj4W4AlHXEGODUO5W2gqv2bc5yUhC57iDmt9DZ AV7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zbWxX1Rt3lc8pNLcZHvlgh39zTGxu2X3mBT6fe9sDDU=; b=DOHBEejhpCZc7Br1t1mO8Nf0J/8Zyk5DS5hIWWY9ltKj13uaQevr18k4MUO/Pfo/+O UQheosmvWTShp6G+A2+sVBYHyWJVj4zIMAp+X5QTYpVrRt66kzgrcgvrs/lJ0ov+mSnA kjvWTD/tp1w3e3y5HAgbks7cETKIxD4lbqlAzpSTyRijwm9Yud5WK0+/TmUjolI8BQyZ FxRq7iIwo8w9RdIgHvaKJBNBc7TKROmKIcCpsN8d43jDVTyi5UipFb2gYCNGgRkoH5gq dMzrQwUqmyaWEng5XG7K5re1xEUfLdzr2t/uj/cTgtPWXWIWQ4WnTX73W7mELt52NAo+ 3LrQ== X-Gm-Message-State: AIVw112L7Q6wVY+Q8lOkrTBbb7AdyGiD9WcmpEvdMSiDUQ0URunnTSYw fWg59gVm/nqcddCB X-Received: by 10.36.184.7 with SMTP id m7mr9236764ite.112.1500961064184; Mon, 24 Jul 2017 22:37:44 -0700 (PDT) Received: from [10.61.2.175] ([122.99.82.10]) by smtp.googlemail.com with ESMTPSA id y2sm4582072ita.9.2017.07.24.22.37.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 22:37:43 -0700 (PDT) To: slof@lists.ozlabs.org, Thomas Huth References: <150089967343.21184.17474774545195474225.stgit@bahia.lan> From: Alexey Kardashevskiy Message-ID: <6329842f-be32-a58b-c7df-c59f6aed12b9@ozlabs.ru> Date: Tue, 25 Jul 2017 15:37:40 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <150089967343.21184.17474774545195474225.stgit@bahia.lan> Content-Language: en-AU Subject: Re: [SLOF] [PATCH v4] board-qemu: add private hcall to inform host on "phandle" update X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" Thomas, What is this business with phandle replacements all about? I looked at the history which says "SLOF has a different concept of phandles" but it does not say what would break if SLOF kept using phandles from QEMU. I applied the chunk below and could not see any difference in how SLOF or a guest kernel behave (slof can boot from virtio-net, guest can use mellanox iov vfio-pci device): What am I missing here? ps. the patch is correct assuming we still need the phandle replacement trick :) On 24/07/17 22:34, Greg Kurz wrote: > The "interrupt-map" property in each PHB node references the "phandle" > property of the "interrupt-controller" node. This is used by the guest > OS to setup IRQs for any PCI device plugged into the PHB. QEMU sets this > property to an arbitrary value in the flattened DT passed to SLOF. > > Since commit 82954d4c1088, SLOF has some generic code to convert all > references to any "phandle" property to a SLOF specific value. > > This is is perfectly okay for coldplug devices, since the guest OS only > sees the converted value in "interrupt-map". It is a problem though for > hotplug devices. Since they don't go through SLOF, the guest OS receives > the arbitrary value set by QEMU and fails to setup IRQs. > > In order to support PHB hotplug, this patch introduces a new private > hcall, which allows SLOF to tell QEMU that a "phandle" was converted > from an old value to a new value. > > Suggested-by: Thomas Huth > Signed-off-by: Greg Kurz > --- > v4: - fix bad stack usage in fdt-hv-update-phandle error path > > v3: - drop "<> 0" before IF > > v2: - use ?dup > - switch the order of the parameters of hv-update-phandle > - added stack comment to hv-update-phandle > --- > board-qemu/slof/fdt.fs | 14 ++++++++++++-- > lib/libhvcall/hvcall.code | 7 +++++++ > lib/libhvcall/hvcall.in | 1 + > lib/libhvcall/libhvcall.h | 1 + > 4 files changed, 21 insertions(+), 2 deletions(-) > > diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs > index 851645eae299..a24e3449e7c1 100644 > --- a/board-qemu/slof/fdt.fs > +++ b/board-qemu/slof/fdt.fs > @@ -308,18 +308,28 @@ fdt-claim-reserve > 3drop > ; > > +\ Tell QEMU about the updated phandle: > +: fdt-hv-update-phandle ( old new -- ) > + hv-update-phandle ?dup IF > + \ Ignore hcall not implemented error, print error otherwise > + dup -2 <> IF ." HV-UPDATE-PHANDLE error: " . cr ELSE drop THEN > + THEN > +; > + > \ Replace one FDT phandle "val" with a OF1275 phandle "node" in the > \ whole tree: > : fdt-update-phandle ( val node -- ) > >r > FALSE TO (fdt-phandle-replaced) > - r@ s" /" find-node ( val node root ) > - fdt-replace-all-phandles > + r@ 2dup s" /" find-node ( val node val node root ) > + fdt-replace-all-phandles ( val node ) > (fdt-phandle-replaced) IF > + fdt-hv-update-phandle > r@ set-node > s" phandle" delete-property > s" linux,phandle" delete-property > ELSE > + 2drop > diagnostic-mode? IF > cr ." Warning: Did not replace phandle in " r@ node>path type cr > THEN > diff --git a/lib/libhvcall/hvcall.code b/lib/libhvcall/hvcall.code > index 0ff50f27e8a9..834974862ef5 100644 > --- a/lib/libhvcall/hvcall.code > +++ b/lib/libhvcall/hvcall.code > @@ -129,3 +129,10 @@ PRIM(check_X2d_and_X2d_patch_X2d_sc1) > > patch_broken_sc1((void*)start, (void*)end, (void*)patch_ins); > MIRP > + > +// : hv-update-phandle ( old_phandle new_phandle -- res ) > +PRIM(hv_X2d_update_X2d_phandle) > + uint32_t new_phandle = TOS.u; POP; > + uint32_t old_phandle = TOS.u; > + TOS.u = hv_generic(KVMPPC_H_UPDATE_PHANDLE, old_phandle, new_phandle); > +MIRP > diff --git a/lib/libhvcall/hvcall.in b/lib/libhvcall/hvcall.in > index 4437b77f001d..ab7513af8977 100644 > --- a/lib/libhvcall/hvcall.in > +++ b/lib/libhvcall/hvcall.in > @@ -31,4 +31,5 @@ cod(RX!) > cod(hv-logical-memop) > cod(hv-cas) > cod(hv-rtas-update) > +cod(hv-update-phandle) > cod(get-print-version) > diff --git a/lib/libhvcall/libhvcall.h b/lib/libhvcall/libhvcall.h > index b2ea3f6bf944..5776a2b772f7 100644 > --- a/lib/libhvcall/libhvcall.h > +++ b/lib/libhvcall/libhvcall.h > @@ -25,6 +25,7 @@ > /* Client Architecture support */ > #define KVMPPC_H_CAS (KVMPPC_HCALL_BASE + 0x2) > #define KVMPPC_H_RTAS_UPDATE (KVMPPC_HCALL_BASE + 0x3) > +#define KVMPPC_H_UPDATE_PHANDLE (KVMPPC_HCALL_BASE + 0x4) > > #ifndef __ASSEMBLY__ > > > _______________________________________________ > SLOF mailing list > SLOF@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/slof > diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs index a24e344..54a4bf8 100644 --- a/board-qemu/slof/fdt.fs +++ b/board-qemu/slof/fdt.fs @@ -449,4 +449,4 @@ r> drop fdt-cas-fix? ; -s" /" find-node fdt-fix-phandles +\ s" /" find-node fdt-fix-phandles