From nobody Tue Apr 15 22:22:25 2025 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=1562592420; cv=none; d=zoho.com; s=zohoarc; b=Ry0lkX2NzKZYXX8Z+gp/3cQcxv2eC0Dhi1S53YKy6XGIED5cZrxdjUxQiDfaavkoyVpAkQqKSUwszGa81EIr7VEdITMDH/oAKjQajrsYfGaY0Piwc5FCqy109RRGE0Ozq/mzznXe1eIMjcialaD3kfoX+YslNLWOE8Cvb173Vww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562592420; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=pKM2iILzmzhmTqm7MEMC5botAaQF87nwgPiMoPvLMns=; b=UwCY4HrZAXxWQAqtFoe/SZqtnQDI+IaJZBAJG8qyUJ6YPFJ5uD1waY6ENkJCsNuQXr3bKlVahGMw7ujc+RGtBmNAiKEnnp4qo39R08pcjix4y28v6HUiTDF1rIkukTqUgtqdhEnwIxJMae4aOiwPLGSxO9JgahBf3aInl8aoOr8= 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 1562592420066662.4239279513016; Mon, 8 Jul 2019 06:27:00 -0700 (PDT) Received: from localhost ([::1]:41724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkTfS-0001Fg-4H for importer@patchew.org; Mon, 08 Jul 2019 09:26:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52286) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkTbQ-00061b-Q6 for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkTbP-0003z7-Kc for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:44 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:45192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkTbP-0003yJ-DZ for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:43 -0400 Received: by mail-wr1-x431.google.com with SMTP id f9so17071774wre.12 for ; Mon, 08 Jul 2019 06:22:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v15sm13773744wrt.25.2019.07.08.06.22.40 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 06:22:41 -0700 (PDT) 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=pKM2iILzmzhmTqm7MEMC5botAaQF87nwgPiMoPvLMns=; b=YTH0RLqeggG5rfz11OfxKD7+0CEdGqqxd2/vCjX3gmnz2PMmN5XC31hJ86ZqMMY8CG HMTuhadm3LOGJ/IagFEumjmLVauYeT0vDyGIlaIL8O70M61UnBQTjCIPy00s3nOj0xrf g++6Y1JWihTlNNx38R/uOyIvjEoUsNlPrI9R7USfG97rDqxWclHQ/N3RacVtZE50N0Nz sNQn24Y7GLJ+qcYtgLlEZ3GznSaF+g+svcrr7N2x/xVBBAr/1mKYgTH/fm/B0DzPjpBi BqGK8973EPh4Pd5n+5HrRYDS416wB1y+ftMfVJUZipgLTXXcfo880T86ED8egJ0Xj/LU mdlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pKM2iILzmzhmTqm7MEMC5botAaQF87nwgPiMoPvLMns=; b=h2AgjFLXo5pDv+XH3ljU5L4mvdGY6qAUgNzuupD2R/tYJJcqNpgfi3iXZK0Qs662SY 9ihj6pZe/RexI5+aEmkMP28e8oYZ5K5Mzk1VITGaifHGYG9Rc+006BLzPPJax6HkzGkm 6Jeb5gI0L16nFd2OURHFioWbw2eDfZnL0ZnSygYZHeRT6CFz1FbnMxRLvJm3h/B6cTR9 4g6r2o6zANVWS98VFhRveQYNIK0dzpRQ4SewIc9HJDqi5Vgs3Mv3GjKxGuI0h9cnvRmO rmrE0rsO37HbWHJBbA7N0FGdGHFvQh5WAUtYQ9KfZqQHtGBpJqte6PzsMWpjFf5+a0x5 sEog== X-Gm-Message-State: APjAAAWnFDNwkuqDp2joXKeC4KNpdIiY5cV2eJPBKStc7ugshwsk24sa bWFX7cyebvD/LHRY9P8VFxr/Dslb3b8OWw== X-Google-Smtp-Source: APXvYqy0k76u0+Xc0tBxR4ayVap+r+17gY2+Hzy5iIyRn1jPxInc6qFuk2DzcDdD0kp6hBiRaCECEA== X-Received: by 2002:a5d:4cc5:: with SMTP id c5mr9107067wrt.278.1562592162133; Mon, 08 Jul 2019 06:22:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 8 Jul 2019 14:22:36 +0100 Message-Id: <20190708132237.7911-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190708132237.7911-1-peter.maydell@linaro.org> References: <20190708132237.7911-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::431 Subject: [Qemu-devel] [PULL 3/4] 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 Message-id: 20190704142004.7150-1-peter.maydell@linaro.org Tested-by: Rados=C5=82aw Biernacki Reviewed-by: Rados=C5=82aw Biernacki --- 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 e8c65e31c70..9c67d5c6f9e 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; @@ -591,7 +589,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; @@ -615,13 +613,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