From patchwork Tue Feb 8 11:39:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 540766 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp450505imo; Tue, 8 Feb 2022 04:32:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNQzx52m/iL1zrg3CUAS6B04whpocQxejzX7EZXdQL04riA5OmRPj7Pc6yGaOVp2dD01cs X-Received: by 2002:a81:3744:: with SMTP id e65mr4546182ywa.191.1644323528849; Tue, 08 Feb 2022 04:32:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644323528; cv=none; d=google.com; s=arc-20160816; b=tlCnrZyCN4XiEhy1jttx1Koyr4CNwIcujX8jAnF7+uPI7AoaT9OwpGhWJT4bZJZ6XK 3ek8FNPLaOr2PeA1SiUit7XHvhXRPP+vhB/uc5vSGGOQ+q86HXFPWp/4gKju3EDLjPfN LE5MI+qlnsCncwCFl017W9tHB/nZ0KSy1Mvj9ocsB90PZBNIqrmYmb5Q9x+aA4egSRiy YDmrpsfkPCWIU/FBPrNivU4lKdBsxrvXA6tNaNZGjxjCp0iCL46G66E38iAw0/pP1elt CJRQ+ybIqrJxwhTifRmxDeLfFW1HnpmRPCWX6tDzNoDvdURomyauY38bBJLn3ATy4MS/ gLTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ihHWYxdE5z0CuYDIY4LqywVkWHM3vo8ypMEKSXKgPrs=; b=QmR0grCbPSSPePmF3Cxho//mL48O8+HICnLgEn3NnC1UxKm1PgKN1W5HURSiYSN2BG D6OdT8IoGK9S1Eik+uPYkQpDJHLQW35zu+iCHPLBsMOBZKqd+xOygRs97N0gAow+lzLA XMBaeI3OxLXXhGxBS/nCvIYwSzrFB4lXpwIZa6w20BMVIC5C4t7Z9wIIukjXbCuLfg97 tANF4smLg5SNwzWxfIS01h8mg0DvcNew7AKDo7Gc/cE/EpsTu/UG8qJH/gn+0y+P6dN1 g5U/gj/n7jZMKmuyx+QwpVuBTvvyfW7QgdlkVNF2mnXgB0caEPXzsT9SHgOs+ex9lfjS ptOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eQdoidTj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g27si3001766ybe.204.2022.02.08.04.32.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 04:32:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eQdoidTj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHPfE-0000TF-AW for patch@linaro.org; Tue, 08 Feb 2022 07:32:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHOr1-0000xS-PS for qemu-devel@nongnu.org; Tue, 08 Feb 2022 06:40:15 -0500 Received: from [2a00:1450:4864:20::42e] (port=45052 helo=mail-wr1-x42e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHOqt-00029D-9U for qemu-devel@nongnu.org; Tue, 08 Feb 2022 06:40:15 -0500 Received: by mail-wr1-x42e.google.com with SMTP id k18so30169848wrg.11 for ; Tue, 08 Feb 2022 03:40:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ihHWYxdE5z0CuYDIY4LqywVkWHM3vo8ypMEKSXKgPrs=; b=eQdoidTjv0eMbtL8olYadlxkO/2CEqarNGfWzrLtj7wicklk2cwhb/JcF4kfuj09fQ dKCi2E7QYz/jmmBeCx+1CItdBIHQ2UUEWYAVEl9X6YVdYRKAPhtBv9QoUOldh3zWfbe8 shLEeNu+zP35aR3WUOccsMX5lBZ8/p6u+BOBsNmfswYYXohxkrKwB1Zs/gmck2jPwW7I QMMohmhpnntI6HspAn/eq/KiNWP3zIuW5iUB9IiHYTyjxluzhO7R1Yp3uDK6l8rtvQuc FXqMBOnLm6LVcyq5sTcmjHrYKY8DGVe1/YJ+j/OKEyBd4WK+nMLB/Mnrkv8+BJHu67Zw Id6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ihHWYxdE5z0CuYDIY4LqywVkWHM3vo8ypMEKSXKgPrs=; b=MU6rsK5LDUdzBrDThXO99FIE30wNfpszP9bACsyxETC3qj3/3us0BOVZ7cN0TTp8D5 O58Nq4j+fPmhLgaabriVF1lCZOQezQaWLl/S1Wsx8Fr4svug7FqsRf+zR18pm2XmrWyY Fzx761wYPHo1e34wjDx//jEfndP6T+JgdiYlj6c3P+Tj4gbo6iVUVjS5QCyCX3cwKPAp 8FZzPNYyGOU4Y9OrqtaMK9roQFFgeNvRib2e9u1TwvKcNobYF2MrzI4EqxLHPs8X+GT7 UKhQqPyfvndGMBHwdvZKqWjfWCD6N3IeklKuCLnwSjAYMIrvNcz9/jp6ytVJs8HIUKSf SY8Q== X-Gm-Message-State: AOAM533XvdzAzmSm+VyICDeXs8XfEF5k3DLdbhW8CYF5NTbiXcGceNL9 RoK2kf9a1leLjjtna6V4y9cWPan1w+Diwg== X-Received: by 2002:adf:d1ed:: with SMTP id g13mr3198917wrd.477.1644320403727; Tue, 08 Feb 2022 03:40:03 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id r11sm4245199wrt.28.2022.02.08.03.40.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 03:40:03 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/39] hw/arm/boot: Drop existing dtb /psci node rather than retaining it Date: Tue, 8 Feb 2022 11:39:30 +0000 Message-Id: <20220208113948.3217356-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208113948.3217356-1-peter.maydell@linaro.org> References: <20220208113948.3217356-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If we're using PSCI emulation, we add a /psci node to the device tree we pass to the guest. At the moment, if the dtb already has a /psci node in it, we retain it, rather than replacing it. (This behaviour was added in commit c39770cd637765 in 2018.) This is a problem if the existing node doesn't match our PSCI emulation. In particular, it might specify the wrong method (HVC vs SMC), or wrong function IDs for cpu_suspend/cpu_off/etc, in which case the guest will not get the behaviour it wants when it makes PSCI calls. An example of this is trying to boot the highbank or midway board models using the device tree supplied in the kernel sources: this device tree includes a /psci node that specifies function IDs that don't match the (PSCI 0.2 compliant) IDs that QEMU uses. The dtb cpu_suspend function ID happens to match the PSCI 0.2 cpu_off ID, so the guest hangs after booting when the kernel tries to idle the CPU and instead it gets turned off. Instead of retaining an existing /psci node, delete it entirely and replace it with a node whose properties match QEMU's PSCI emulation behaviour. This matches the way we handle /memory nodes, where we also delete any existing nodes and write in ones that match the way QEMU is going to behave. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Niek Linnenbank Tested-by: Edgar E. Iglesias Tested-by: Cédric Le Goater Tested-by: Niek Linnenbank Message-id: 20220127154639.2090164-17-peter.maydell@linaro.org --- hw/arm/boot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index b46f1fe889e..b1e95978f26 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -478,12 +478,13 @@ static void fdt_add_psci_node(void *fdt) } /* - * If /psci node is present in provided DTB, assume that no fixup - * is necessary and all PSCI configuration should be taken as-is + * A pre-existing /psci node might specify function ID values + * that don't match QEMU's PSCI implementation. Delete the whole + * node and put our own in instead. */ rc = fdt_path_offset(fdt, "/psci"); if (rc >= 0) { - return; + qemu_fdt_nop_node(fdt, "/psci"); } qemu_fdt_add_subnode(fdt, "/psci");