From nobody Sat May 18 04:13:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1562250102; cv=none; d=zoho.com; s=zohoarc; b=ftCRORGUZ/tEK+OuvGFpR6VrPbQ3mxLQyeWXxv+RQEk+wXtXcb8LWMEdkHvXzErWXRgNGEchHmMP6nG32c+Yp3I9owCXDALrtY5acKegDvVMBXaURePwXGxmAKcVYmHjRHy5yLf6s6jb8yEHD7q0ITsZIGHik9C+RcK/sGy+C8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250102; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=y2vuXrmq/JT4NCIyF08AXa1zIQrKXhKE3HksSwRif84=; b=NpN9FyJEiA6ceT1K1D129UajEv78fN0dVKT+jODAfhpB5WZ7vNTeeZAAmZjQShKOuRuZ9YkXvwnjj1PMV5oeVfbMmltYiJBoYEUs3NTfh5LFFDXX/zTwN3GR91JZzE0NhtyReyZm3cHnpLc4qv/0hmha42MA+O+aF+TP3ofzQlM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 156225010202655.62303986558993; Thu, 4 Jul 2019 07:21:42 -0700 (PDT) Received: from localhost ([::1]:46460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj2cC-0004ii-0e for importer@patchew.org; Thu, 04 Jul 2019 10:21:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57571) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj2an-00037m-2f for qemu-devel@nongnu.org; Thu, 04 Jul 2019 10:20:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hj2al-0006kx-WC for qemu-devel@nongnu.org; Thu, 04 Jul 2019 10:20:09 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:38044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hj2al-0006kL-OZ for qemu-devel@nongnu.org; Thu, 04 Jul 2019 10:20:07 -0400 Received: by mail-wm1-x343.google.com with SMTP id s15so6366400wmj.3 for ; Thu, 04 Jul 2019 07:20:07 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c1sm8917572wrh.1.2019.07.04.07.20.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 04 Jul 2019 07:20:05 -0700 (PDT) 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=y2vuXrmq/JT4NCIyF08AXa1zIQrKXhKE3HksSwRif84=; b=jotr24d/ZHImENcxd5LAOPtbpUgTnqn5wNT8asuaodhkC54AjrSl+/Nu5cN9FDMaGt 2YD6zvlf9yrEXFOTTZ/Hb0QTCeWd+n/+PN7OpSBMRiBEB7t0n8b1G78jwoemJVN0ZGTV xy5pn1YPTEXirxcM49g23aT7AGUgKmaGuwpMxFEV7p+wzjKzLIWl0cMXDhv2xRPUekRB XHPzPWYhvBeCxeCVvNzbMhaZ1v3c+uiMLlT2Ci3TW4ogVVBGiDZpCcEbEso69/495aqB MSUact+9SZXzRHgJPulmwUDdfT7dMHVql+zKDawlER10LxdU3z+GoaaVOo9235aCc5XI BfCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=y2vuXrmq/JT4NCIyF08AXa1zIQrKXhKE3HksSwRif84=; b=m0N/mJ7cN+E7TH26XLBg0ewAG91wn7L8EO1xxkFDgHQLS2gknM5H5SaH/UIUkt+pNr f1ErV1o2DFXdQJ2PdM1hOdWpzcETZdMNrlF5Rel/odYOuvdHv9F0sC0GP10cLq4nCR9y hA2uBBCOtQzOd2MNzhV/+ACggFhZKdP8H/oCLwJ82nwZTa1HI2YdLshAx3nSba4SIZE1 qnXi/9lttiEupNAA3cnJxFqIQLda/ygHv7qHbDbwnnn/nfKUw3PuA2a+UFzdVAbMxoTX CzJH6skrEMv6OL9EPRK4EUM3Jw92tkyTN75bnW44zFXN/Db0mBlT68zN4JrygNYJSRA0 8vbQ== X-Gm-Message-State: APjAAAWbIkcAtI0rcQGqs/YvwWYuG6Sq5kAyLk3eaBGxB6LPAEvAOUsC NQbo2fHWR9GnjClnuTfTC/6ixg== X-Google-Smtp-Source: APXvYqzig1qpi682TS9kUXdyu+tg14JbSDK38zsqiWLjlvQY6V0PWpAAr0sxvWo1P2YurDdS1jeedw== X-Received: by 2002:a1c:9696:: with SMTP id y144mr12844133wmd.73.1562250006394; Thu, 04 Jul 2019 07:20:06 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Thu, 4 Jul 2019 15:20:04 +0100 Message-Id: <20190704142004.7150-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH for-4.1] hw/arm/sbsa-ref: Remove unnecessary check for secure_sysmem == NULL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Radoslaw Biernacki , Leif Lindholm Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In the virt machine, we support TrustZone being either present or absent, and so the code must deal with the secure_sysmem pointer possibly being NULL. In the sbsa-ref machine, TrustZone is always present, but some code and comments copied from virt still treat it as possibly not being present. This causes Coverity to complain (CID 1407287) that we check secure_sysmem for being NULL after an unconditional dereference. Simplify the code so that instead of initializing the variable to NULL, unconditionally assigning it, and then testing it for NULL, we just initialize it correctly in the variable declaration and then assume it to be non-NULL. We also delete a comment which only applied to the non-TrustZone config. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Rados=C5=82aw Biernacki Tested-by: Rados=C5=82aw Biernacki --- Not a bug as such, but we should put it in for 4.1 to keep Coverity happy. --- hw/arm/sbsa-ref.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index ee53f0ff60d..6f315b79445 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -254,8 +254,6 @@ static void sbsa_flash_map(SBSAMachineState *sms, * sysmem is the system memory space. secure_sysmem is the secure view * of the system, and the first flash device should be made visible on= ly * there. The second flash device is visible to both secure and nonsec= ure. - * If sysmem =3D=3D secure_sysmem this means there is no separate Secu= re - * address space and both flash devices are generally visible. */ hwaddr flashsize =3D sbsa_ref_memmap[SBSA_FLASH].size / 2; hwaddr flashbase =3D sbsa_ref_memmap[SBSA_FLASH].base; @@ -588,7 +586,7 @@ static void sbsa_ref_init(MachineState *machine) SBSAMachineState *sms =3D SBSA_MACHINE(machine); MachineClass *mc =3D MACHINE_GET_CLASS(machine); MemoryRegion *sysmem =3D get_system_memory(); - MemoryRegion *secure_sysmem =3D NULL; + MemoryRegion *secure_sysmem =3D g_new(MemoryRegion, 1); MemoryRegion *ram =3D g_new(MemoryRegion, 1); bool firmware_loaded; const CPUArchIdList *possible_cpus; @@ -612,13 +610,11 @@ static void sbsa_ref_init(MachineState *machine) * containing the system memory at low priority; any secure-only * devices go in at higher priority and take precedence. */ - secure_sysmem =3D g_new(MemoryRegion, 1); memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory", UINT64_MAX); memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1); =20 - firmware_loaded =3D sbsa_firmware_init(sms, sysmem, - secure_sysmem ?: sysmem); + firmware_loaded =3D sbsa_firmware_init(sms, sysmem, secure_sysmem); =20 if (machine->kernel_filename && firmware_loaded) { error_report("sbsa-ref: No fw_cfg device on this machine, " --=20 2.20.1