From nobody Mon May 6 17:09:26 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=1562592269; cv=none; d=zoho.com; s=zohoarc; b=G8S8k7VdUVSbX48hMsx5L+TfEdxuf0LW+YYSkWulFMr9c2mLvq8A0Lgki07V3BgOwakH2P95MmQep33jNdFi8Rp4khWV4KPph+OSAwQwPaiB3DFFFuypEfsKjDbf7ea6Otbjy2vjE8hmetz483V2sWBYDDB9L9wC0tZqirmJhS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562592269; h=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=4k6A6Sehnb0t0NBVSTvBu5NVlmPUHPOJZHFdQpfg10w=; b=F5lbi7fno8McBUQ7gjA8+xv/1d6gbEPlOw9Y/tE+3ZbVkHOub+WOtfUOfhAi4r0aNpPX/ftGKlveL1attzcvPFVEOlJ3HRbRPj9sbjSwMqRw9xd8IA9Z5CZ0VNa+c2rtN4Z8LbHYAPPKuSrlN/mE5enOrezK6Wqcw9qmT41OQFk= 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1562592269855295.24768545955067; Mon, 8 Jul 2019 06:24:29 -0700 (PDT) Received: from localhost ([::1]:41708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkTd6-0007JX-UO for importer@patchew.org; Mon, 08 Jul 2019 09:24:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52256) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkTbO-00060v-FR for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkTbN-0003wz-HG for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:42 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:50882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkTbN-0003wM-AY for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:41 -0400 Received: by mail-wm1-x334.google.com with SMTP id v15so5418568wml.0 for ; Mon, 08 Jul 2019 06:22:41 -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.39 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 06:22:39 -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=4k6A6Sehnb0t0NBVSTvBu5NVlmPUHPOJZHFdQpfg10w=; b=eCbpLJMrhl395Gb/YUzE1PI7Gifv0RbFXq3AhcQsB2Sn8X7qFarnOrpmm66NB5Eixb BWUXqgM15W1qj22w4ffJOa5++uM10+oFJCDhDZEBqg9Eck6TwV5yKgtRcZD/w/pNm0me fVn4jAo/6csDRCHKTha159Ujj+1vGVH7tpyUFdprGZKoG1l13yydUE9CrCmuO4bzaBPV zaLa5cd/k25Hg79EobKZUS8FAdFIKzIP8fJMTGPokVrZKzGIunRJRT/ENrC4hBJPaGhF xTUccdOpIQ2p+w1tMkNW59bg5MohnPxzMgD6LrsNSM0xdi3A6lwxL6BdOw37zJNUlUBn MZRw== 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=4k6A6Sehnb0t0NBVSTvBu5NVlmPUHPOJZHFdQpfg10w=; b=e6LFKrR3zv+/zOi1uCalY9Y4mjKcCgag572lUAaNYRnqJuOqVnPjResY3iz15OO0g8 TfAFnPa1T3hIduYq8/7pwKJOgwydoeCNBE4pAOIJtW5iPBJF7fhygPw5iDYByEWE/aQW E0+yRRMfEs+TMdsBqtQivZ4Trs0ZLlnGhIV/5RuZ0qLnmVGNXhwwY99IwQIiua2cQezr S4sFEVxuJHpbBnvraFFw2Zzb1/tL7+j6+FmeIlsfEG+BIRrTGsLAAFOpC3fFMejejmVN xS4QBuZty0zFVouxxTHd34jT0YbrvA/TRNrPT9a8HVcsgrGIdq7kOC4CKPY+f+/oVMzt blgQ== X-Gm-Message-State: APjAAAUl96G5NSj+Im30gApea4XDptPWAckiLhfQGGoLUHjk8b4XfIlI m19JMrAvbD2KW6gTeEh2NLF06HVsqynsQA== X-Google-Smtp-Source: APXvYqw6APfdjJGbepJ8dI2feTB15mqQMvQw+CTJuWe4KiCeDtNHOLMF8KAHlVA73GokLxNazE+6tA== X-Received: by 2002:a1c:6504:: with SMTP id z4mr16592151wmb.172.1562592160044; Mon, 08 Jul 2019 06:22:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 8 Jul 2019 14:22:34 +0100 Message-Id: <20190708132237.7911-2-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-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::334 Subject: [Qemu-devel] [PULL 1/4] target/arm: Fix sve_zcr_len_for_el 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) Content-Type: text/plain; charset="utf-8" From: Richard Henderson Off by one error in the EL2 and EL3 tests. Remove the test against EL3 entirely, since it must always be true. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Message-id: 20190702104732.31154-1-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 2df7152a9cd..20f8728be11 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5283,10 +5283,10 @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int e= l) if (el <=3D 1) { zcr_len =3D MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); } - if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { + if (el <=3D 2 && arm_feature(env, ARM_FEATURE_EL2)) { zcr_len =3D MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[2]); } - if (el < 3 && arm_feature(env, ARM_FEATURE_EL3)) { + if (arm_feature(env, ARM_FEATURE_EL3)) { zcr_len =3D MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); } return zcr_len; --=20 2.20.1 From nobody Mon May 6 17:09:26 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=1562592273; cv=none; d=zoho.com; s=zohoarc; b=BTx3UhSGOUyMXR1EEQ3GOCaCIpCr7e4gBF9Cr61Or4JdfR2zla8IQ/LLSdihs44QfGaRH/X38INOidurczKgNE+jMuKDBeq0UahRcFBFgjSX+6SfDaI0mjbtPRf9qW6dn5F3kMJvtvk7rjiSHCUXHVCcbQ3GYPpCy/94kl+kAN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562592273; 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=g9eAQagE0QheHxHPruslRXBJov60L65Bz5mc5X82Q1s=; b=m5S5RH/Ol4jOKdVHaA02j0PpMzqkEGrvxaLzXLdxbD4plnu6+gXY+gq0cLzJmnSD25YrXtlOywSD16QRS3ey3ivtbh8FKPqiVW2msww5V0wGySNcaXbZp/NDEhMPhrivYQ6RKsVgNKAJsi5wbKbcPaPMCQyeRtlvQjQE2Jj/H1c= 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156259227323932.03478768978505; Mon, 8 Jul 2019 06:24:33 -0700 (PDT) Received: from localhost ([::1]:41710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkTd8-0007OD-8D for importer@patchew.org; Mon, 08 Jul 2019 09:24:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52276) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkTbQ-000619-47 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 1hkTbO-0003xt-Eb for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:44 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:51867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkTbO-0003x3-73 for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:42 -0400 Received: by mail-wm1-x344.google.com with SMTP id 207so15798055wma.1 for ; Mon, 08 Jul 2019 06:22:42 -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:40 -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=g9eAQagE0QheHxHPruslRXBJov60L65Bz5mc5X82Q1s=; b=J7wnSgeATIQ2AvmHjvU8KPSc540FeoJA9oP0Jv73H3zKYojxl/5ZNRQxJR369N6/0S Qzhtrsi+AzpaNVsbhvG/xd9wv87Fi6HqA4mw85nfzsm368cZa+QgGtG8PWum2efvUnxz CG/EF1Q738uwONJ7ZjBCYL7PFliYoiciXve9aMJMe6DybpPnf+L+5xVgTEUOEjQeQ0p2 cGEM9CQSNq3t1oVmKcBWZF+UwgKrw985/U1rJHHFIgmyIUuGNDPomL9BsmwfYzQWCeaJ l+hMH1iU5DufV6n5AZGHjVj6KpVraLsbHeUunJhdPgk+t9pl//WlMMNyPNP0xRK6BGXH CYUg== 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=g9eAQagE0QheHxHPruslRXBJov60L65Bz5mc5X82Q1s=; b=hTjeKkhoNHG6iwnD5xREOneGUn6i/CzENKiLYrTxb+IEhLWYdVX7oYSIkUUTV+J7Tj PSktOK5G09pYTKEz/EY9jbipOdHKYKU9x0UzxSj/X9++AOt9xtJdFBy+/4v5vmHPCwQj 5HSsOKZBV6ifJsGkthYYjWtYQFlJjPKcc5vIGbe7JxRJ7HPGAyqOG5HvSmVJ3a6wKpTQ 3Tkadubbtc7GQYS8oBHTmqKUXsa1QouiylHCMejP/Hem8cLA+fWbEo6BYmlemGbWlAAq aGcQIZCdCkktQtdv8NXh/kVpcmmRY6baBGGhsHClscfemzjmCn0d7BDuvI/NTpTEpskH t6zw== X-Gm-Message-State: APjAAAUMkuV4KIGftfDoX/x+6sDOjseihkrl97YAckABHghIn6RT81X+ pzeLp/E95bSLVbYwpMAfYhJn14zmCSkE6A== X-Google-Smtp-Source: APXvYqzbfQsMdA3r3GqoxZK9Jvc00ytLiNS+n0T8IUZUvfI+RUcowzDrzbjVBcDI8YNnqWpacPuj4A== X-Received: by 2002:a05:600c:303:: with SMTP id q3mr17365420wmd.130.1562592160921; Mon, 08 Jul 2019 06:22:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 8 Jul 2019 14:22:35 +0100 Message-Id: <20190708132237.7911-3-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::344 Subject: [Qemu-devel] [PULL 2/4] tests/migration-test: Fix read off end of aarch64_kernel array 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) The test aarch64 kernel is in an array defined with unsigned char aarch64_kernel[] =3D { [...] } which means it could be any size; currently it's quite small. However we write it to a file using init_bootfile(), which writes exactly 512 bytes to the file. This will break if we ever end up with a kernel larger than that, and will read garbage off the end of the array in the current setup where the kernel is smaller. Make init_bootfile() take an argument giving the length of the data to write. This allows us to use it for all architectures (previously s390 had a special-purpose init_bootfile_s390x which hardcoded the file to write so it could write the correct length). We assert that the x86 bootfile really is exactly 512 bytes as it should be (and as we were previously just assuming it was). This was detected by the clang-7 asan: =3D=3D15607=3D=3DERROR: AddressSanitizer: global-buffer-overflow on address= 0x55a796f51d20 at pc 0x55a796b89c2f bp 0x7ffc58e89160 sp 0x7ffc58e88908 READ of size 512 at 0x55a796f51d20 thread T0 #0 0x55a796b89c2e in fwrite (/home/petmay01/linaro/qemu-from-laptop/qem= u/build/sanitizers/tests/migration-test+0xb0c2e) #1 0x55a796c46492 in init_bootfile /home/petmay01/linaro/qemu-from-lapt= op/qemu/tests/migration-test.c:99:5 #2 0x55a796c46492 in test_migrate_start /home/petmay01/linaro/qemu-from= -laptop/qemu/tests/migration-test.c:593 #3 0x55a796c44101 in test_baddest /home/petmay01/linaro/qemu-from-lapto= p/qemu/tests/migration-test.c:854:9 #4 0x7f906ffd3cc9 (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x72cc9) #5 0x7f906ffd3bfa (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x72bfa) #6 0x7f906ffd3bfa (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x72bfa) #7 0x7f906ffd3ea1 in g_test_run_suite (/usr/lib/x86_64-linux-gnu/libgli= b-2.0.so.0+0x72ea1) #8 0x7f906ffd3ec0 in g_test_run (/usr/lib/x86_64-linux-gnu/libglib-2.0.= so.0+0x72ec0) #9 0x55a796c43707 in main /home/petmay01/linaro/qemu-from-laptop/qemu/t= ests/migration-test.c:1187:11 #10 0x7f906e9abb96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/= csu/../csu/libc-start.c:310 #11 0x55a796b6c2d9 in _start (/home/petmay01/linaro/qemu-from-laptop/qe= mu/build/sanitizers/tests/migration-test+0x932d9) Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20190702150311.20467-1-peter.maydell@linaro.org --- tests/migration-test.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 0cd014dbe51..b6434628e1c 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -91,23 +91,13 @@ static const char *tmpfs; */ #include "tests/migration/i386/a-b-bootblock.h" #include "tests/migration/aarch64/a-b-kernel.h" - -static void init_bootfile(const char *bootpath, void *content) -{ - FILE *bootfile =3D fopen(bootpath, "wb"); - - g_assert_cmpint(fwrite(content, 512, 1, bootfile), =3D=3D, 1); - fclose(bootfile); -} - #include "tests/migration/s390x/a-b-bios.h" =20 -static void init_bootfile_s390x(const char *bootpath) +static void init_bootfile(const char *bootpath, void *content, size_t len) { FILE *bootfile =3D fopen(bootpath, "wb"); - size_t len =3D sizeof(s390x_elf); =20 - g_assert_cmpint(fwrite(s390x_elf, len, 1, bootfile), =3D=3D, 1); + g_assert_cmpint(fwrite(content, len, 1, bootfile), =3D=3D, 1); fclose(bootfile); } =20 @@ -537,7 +527,9 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, got_stop =3D false; bootpath =3D g_strdup_printf("%s/bootsect", tmpfs); if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - init_bootfile(bootpath, x86_bootsect); + /* the assembled x86 boot sector should be exactly one sector larg= e */ + assert(sizeof(x86_bootsect) =3D=3D 512); + init_bootfile(bootpath, x86_bootsect, sizeof(x86_bootsect)); extra_opts =3D use_shmem ? get_shmem_opts("150M", shmem_path) : NU= LL; cmd_src =3D g_strdup_printf("-machine accel=3D%s -m 150M" " -name source,debug-threads=3Don" @@ -555,7 +547,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, start_address =3D X86_TEST_MEM_START; end_address =3D X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { - init_bootfile_s390x(bootpath); + init_bootfile(bootpath, s390x_elf, sizeof(s390x_elf)); extra_opts =3D use_shmem ? get_shmem_opts("128M", shmem_path) : NU= LL; cmd_src =3D g_strdup_printf("-machine accel=3D%s -m 128M" " -name source,debug-threads=3Don" @@ -590,7 +582,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, start_address =3D PPC_TEST_MEM_START; end_address =3D PPC_TEST_MEM_END; } else if (strcmp(arch, "aarch64") =3D=3D 0) { - init_bootfile(bootpath, aarch64_kernel); + init_bootfile(bootpath, aarch64_kernel, sizeof(aarch64_kernel)); extra_opts =3D use_shmem ? get_shmem_opts("150M", shmem_path) : NU= LL; cmd_src =3D g_strdup_printf("-machine virt,accel=3D%s,gic-version= =3Dmax " "-name vmsource,debug-threads=3Don -cpu = max " --=20 2.20.1 From nobody Mon May 6 17:09:27 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=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 From nobody Mon May 6 17:09:27 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=1562592415; cv=none; d=zoho.com; s=zohoarc; b=CQ6tzxA0alc2DEkwM0JPrd4ggFgYUDd9mdTea2Ptnn3grD4al6BLd3S2AX/qrEGNoUrRd0093dXKL0J6pWYAfgBllAiD6yrdLkeznOnc7TVDMWIh8CPq37ti/47mXkVtrA03NZv/+aGHzKjmfJafMEKGusbVBEY2fFJexPQ0IVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562592415; 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=inhHrQ3AI5RlPujeD5LJ2O+2+s1WgKNbXgbANrqMOi4=; b=ezMVBRd2dGh6DNuaSn5cDUZ4U22GiumGV6g3cQ+Q1X5qb8jtJN2uZkcLLMsHvwpH+QI8rhsqPLFQKDXXCVfkSUMuIhcYL3E2hrcM+5rK5P4gw4E9Spmw2M6LxYS5o12LsZgan72NUuiElysYzcpy4jVrsK6dhPEN2BGo+lmmLOI= 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1562592415777685.3852745257627; Mon, 8 Jul 2019 06:26:55 -0700 (PDT) Received: from localhost ([::1]:41726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkTfS-0001GZ-Qq for importer@patchew.org; Mon, 08 Jul 2019 09:26:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52297) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkTbR-00063U-Is for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkTbQ-0003zd-ED for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:45 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:44358) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkTbQ-0003yv-7R for qemu-devel@nongnu.org; Mon, 08 Jul 2019 09:22:44 -0400 Received: by mail-wr1-x42b.google.com with SMTP id p17so5924192wrf.11 for ; Mon, 08 Jul 2019 06:22:44 -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.42 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 06:22:42 -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=inhHrQ3AI5RlPujeD5LJ2O+2+s1WgKNbXgbANrqMOi4=; b=eTVPVhdeyherxUvJSK5IGkZJpBPhn2xeuofXNrNzc3eGHyVAgNJasZIFhUkBIwr2Hb 4TDpLXwb0BnID8zQIrUFfeXDs29DZuNh+xV8C/iUqf/F9tyZYktd7NpLsbAl9e6abXnb kTeoYjwKuRbN9GEG/3vSbRdDFUGf+3XjrdemUe2JHnNLnZI4CCHdz5psBJKv0G6rgRO9 3PxcZSmUwP02PReFjLSCIXVDzuGw2+21IzqT7MH6ykiq7c5VbliEW5CcolLOayrNKQCy 9BugsbcOEraMhLHtd8Ae+YFagJZry0TiJYeo8V4iUGMePi/EME5PjJh9W/oXcnJbeSkJ TAnA== 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=inhHrQ3AI5RlPujeD5LJ2O+2+s1WgKNbXgbANrqMOi4=; b=XI6K3h+0IrCznbD018JY5pU/0zW/9BoLJwH8j1aIBQSYen7CSSY5KWniY0tOihOJLn +tHQfhcrHtSLVH4cwxTPodau+m2/oXdhk5E25IaVnOegNzMz3fqZ+qwgYiwd9Pp+WFqi GRVJMpN7oxRUJGsj5wWH1NwZjpPXbvWHadNC4Qls8RlnVa7aak2pxlSAx5H5I6N/6+m4 tqoeqRAxKhPV6xJMPQ4ti2UJrzaD+VRjBCS52x3eM4GpDOc09vhX69GnuPhbAFkoTQuV aV4pihiBqUVDacSjSEe537fySDrODjdvopOQGpXrjnAnjnCoredIKTFN2mVdSUWQmO7Y oc7Q== X-Gm-Message-State: APjAAAUMDKx8nzzuQLNNgIhXp9g+P2Fo/keZ+TZprZzTKK0Zyf7Hz06g dYfqkxLdFbnxyUtRxm2Aqk9cu69ecSMZRA== X-Google-Smtp-Source: APXvYqyqGzYOCvxpQ+6zCX+siHSIcHvRe7Vo/GSYtDSr+eKBFVH/gaorozOpBXc77asIoRpZLcTl1g== X-Received: by 2002:a5d:5308:: with SMTP id e8mr18643789wrv.219.1562592162974; Mon, 08 Jul 2019 06:22:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 8 Jul 2019 14:22:37 +0100 Message-Id: <20190708132237.7911-5-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::42b Subject: [Qemu-devel] [PULL 4/4] target/arm/vfp_helper: Call set_fpscr_to_host before updating to FPSCR 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) From: Philippe Mathieu-Daud=C3=A9 In commit e9d652824b0 we extracted the vfp_set_fpscr_to_host() function but failed at calling it in the correct place, we call it after xregs[ARM_VFP_FPSCR] is modified. Fix by calling this function before we update FPSCR. Reported-by: Laurent Desnogues Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Desnogues Tested-by: Laurent Desnogues Message-id: 20190705124318.1075-1-philmd@redhat.com Signed-off-by: Peter Maydell --- target/arm/vfp_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index 46041e32949..9710ef1c3e5 100644 --- a/target/arm/vfp_helper.c +++ b/target/arm/vfp_helper.c @@ -197,6 +197,8 @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t v= al) val &=3D 0xf7c0009f; } =20 + vfp_set_fpscr_to_host(env, val); + /* * We don't implement trapped exception handling, so the * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) @@ -217,8 +219,6 @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t v= al) env->vfp.qc[1] =3D 0; env->vfp.qc[2] =3D 0; env->vfp.qc[3] =3D 0; - - vfp_set_fpscr_to_host(env, val); } =20 void vfp_set_fpscr(CPUARMState *env, uint32_t val) --=20 2.20.1