From patchwork Thu Jan 20 15:16:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 533594 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp132460imr; Thu, 20 Jan 2022 12:21:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrWJFgPl50oRcHr+CkkmLxpWygt9YrSVvd66VfNEPqhSkhawDvwODkjo6PobDuu3PwNO6F X-Received: by 2002:a25:8250:: with SMTP id d16mr1240155ybn.110.1642710089837; Thu, 20 Jan 2022 12:21:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642710089; cv=none; d=google.com; s=arc-20160816; b=GP8BfXRbcz8tuo8HV7iTBqmMQ4KpCfoxx91MOUklRldC3nynzRp+Q5PxgOgHpagj70 lzt01OnFlw4yqlU1mUa69T19BoNjoudTpem/T4B0gsoF9mgpbNlRJ7uMLX9X/AccTPYL SWMgMNxpaYiWGDBxkgNDfQurWzuN+IxssiZ44Qb8mZx3j8Tvn+HyafQUMMBzU5rrSpCK 7/EAs84vuEQMle3CSL3G52OYE6C4ip8qSC+gwB3hDLQTWXy/y1bR4vrMX6aIUvddN8C3 20hOnNozsIcDEmaJ300jJNmbant0qhVyT7eArCF9XLg9RKHNdp0BjIFSbeexh1HtCPvv Fbvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=dUP+xAeqwqhgnTkt7Pfw/iOMWfGPZPxV5IL8xzgDVz0=; b=WQUobVEP8zvIul0CDK2nwkJj1Mr5h2EPUoi8dxETZ7OJUS7ULk92Q6SVoKm1T1oYrU hq24W1TCcd6PAoyqx67C5akfQPT7ey7AW5bxwalhJGmiqvsFCT8kVhm3TPZOsajk//Jb eIBJHarzhzvNeg3FJMq4hH2sRmyN97E31o8sz4yWtPYYjz575V08U2z+2SDSoRnNTW98 x+9//sMdYXWixJJ0y0QYytuagmy87gnTKWO35s2rldJ4YOnC6pyuRqPXEDsK+dVbwd/E hISe5V5lvLY58L/O/8VyEnqvg/TY+pKYGKPsgQpCZ8bECvzrP1+WqCoCHtPiDMi5GT7A TuQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="G/QDk7j6"; 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 k134si5079995ybf.65.2022.01.20.12.21.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Jan 2022 12:21:29 -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="G/QDk7j6"; 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]:38066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAdw0-0003QH-R4 for patch@linaro.org; Thu, 20 Jan 2022 15:21:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAZBF-0007pv-DU for qemu-devel@nongnu.org; Thu, 20 Jan 2022 10:16:53 -0500 Received: from [2a00:1450:4864:20::32b] (port=53844 helo=mail-wm1-x32b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nAZBD-0003T5-LR for qemu-devel@nongnu.org; Thu, 20 Jan 2022 10:16:53 -0500 Received: by mail-wm1-x32b.google.com with SMTP id n8so12757457wmk.3 for ; Thu, 20 Jan 2022 07:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dUP+xAeqwqhgnTkt7Pfw/iOMWfGPZPxV5IL8xzgDVz0=; b=G/QDk7j6SK0aygeX0/NWPq6ZS48SZn2xdwx4jOzKKBc5NCaDU5qkiEhjzdcm3veGOb X3cvNdDs8VuonPloXgUK6qPgIusJzBmW9XPPG7hSIMd+pydwSxGjtRreLN20Jqs3Q+7Z opLv1Xl5FZH0LjdTiN9+qdAZzR0DViiL3PDi5OaisoBig/GEN3Bl09XtxUizCrC7QNiC OLXiZWia/upq+B4iHHouApDPeAkJjOkQ9DZNmFn+hREaFN/usCtY+Qi/UqmSWStb9QmE MWR6Xt/BPdoZbmziC2tS+F4DKT0MdvqP2bRHzGakxzNQedVAJL/GHskqd82QwROrwLIG KHuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dUP+xAeqwqhgnTkt7Pfw/iOMWfGPZPxV5IL8xzgDVz0=; b=waDJfyr+aGNb0CypdwIK1T/IWswTUXDFE/Js0DBtnRAgIYHWnvQg6hEbziW1tQJKNy TXCzTfjeAX43kJTgQchNQovdBLrfzOZF2xz45b8/YKwMt0+31GRIQjSMExZTgTTmMafg qqzooDtijiK8AEKS2hB3zC4nHYvA2fEkdX6VH51Q3eT0XtAz9HX828cIfjZCW6UsBeiG Z/kmHOIynb3L3+vCwFXgEPxovxTsO7+l/sc0uk2FldEwTICDzB2ED2s6ztUm/qr6LV4c mfZRx1K3TYBmgijMDIhfhbE2So/28Ec4VVAgX0qF+vQqJ/AfzWwlfDulmj41/YF2VxW3 sHAg== X-Gm-Message-State: AOAM531oEbsnmuUru70V7h67Z73W7oot3EAM9d4QZiM90duYqmbR0N0Z iblEyIlVs+flycLHP1lPxK5VXy988lGdig== X-Received: by 2002:a05:600c:291:: with SMTP id 17mr9291417wmk.123.1642691810003; Thu, 20 Jan 2022 07:16:50 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id w6sm1972079wmi.15.2022.01.20.07.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 07:16:49 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH] hw/char/exynos4210_uart: Fix crash on trying to load VM state Date: Thu, 20 Jan 2022 15:16:48 +0000 Message-Id: <20220120151648.433736-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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 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: , Cc: Guenter Roeck Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The exynos4210_uart_post_load() function assumes that it is passed the Exynos4210UartState, but it has been attached to the VMStateDescription for the Exynos4210UartFIFO type. The result is a SIGSEGV when attempting to load VM state for any machine type including this device. Fix the bug by attaching the post-load function to the VMSD for the Exynos4210UartState. This is the logical place for it, because the actions it does relate to the entire UART state, not just the FIFO. Thanks to the bug reporter @TrungNguyen1909 for the clear bug description and the suggested fix. Fixes: c9d3396d80fe7ece9b ("hw/char/exynos4210_uart: Implement post_load function") Buglink: https://gitlab.com/qemu-project/qemu/-/issues/638 Signed-off-by: Peter Maydell Reviewed-by: Guenter Roeck Reviewed-by: Philippe Mathieu-Daudé --- hw/char/exynos4210_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c index 80d401a3795..addcd59b028 100644 --- a/hw/char/exynos4210_uart.c +++ b/hw/char/exynos4210_uart.c @@ -628,7 +628,6 @@ static const VMStateDescription vmstate_exynos4210_uart_fifo = { .name = "exynos4210.uart.fifo", .version_id = 1, .minimum_version_id = 1, - .post_load = exynos4210_uart_post_load, .fields = (VMStateField[]) { VMSTATE_UINT32(sp, Exynos4210UartFIFO), VMSTATE_UINT32(rp, Exynos4210UartFIFO), @@ -641,6 +640,7 @@ static const VMStateDescription vmstate_exynos4210_uart = { .name = "exynos4210.uart", .version_id = 1, .minimum_version_id = 1, + .post_load = exynos4210_uart_post_load, .fields = (VMStateField[]) { VMSTATE_STRUCT(rx, Exynos4210UartState, 1, vmstate_exynos4210_uart_fifo, Exynos4210UartFIFO),