From patchwork Thu Jul 13 22:25:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 788008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x7rBW10W1z9s7m for ; Fri, 14 Jul 2017 08:30:59 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3x7rBV6mFWzDqkq for ; Fri, 14 Jul 2017 08:30:58 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from 8.mo173.mail-out.ovh.net (8.mo173.mail-out.ovh.net [46.105.46.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3x7rBM6dKkzDqkm for ; Fri, 14 Jul 2017 08:30:51 +1000 (AEST) Received: from player687.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id CFFD16734F for ; Fri, 14 Jul 2017 00:25:32 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player687.ha.ovh.net (Postfix) with ESMTPA id 92DA62C0073; Fri, 14 Jul 2017 00:25:30 +0200 (CEST) From: Greg Kurz To: slof@lists.ozlabs.org Date: Fri, 14 Jul 2017 00:25:29 +0200 Message-ID: <149998472932.13629.5595173121521891953.stgit@bahia.lan> In-Reply-To: <149998470010.13629.16124878075303408145.stgit@bahia.lan> References: <149998470010.13629.16124878075303408145.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 X-Ovh-Tracer-Id: 17535891051348597042 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrfedvgddukecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Subject: [SLOF] [PATCH v2 3/3] 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: Thomas Huth Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" 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 --- 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 1aeee3d93688..f274ffa072ac 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 0 <> IF + \ Ignore hcall not implemented error, print error otherwise + ?dup -2 <> IF ." HV-UPDATE-PHANDLE error: " . cr 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__