[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-9.1.3 31/58] hw/intc/arm_gicv3_its: Zero initialize local DTEntr
From: |
Michael Tokarev |
Subject: |
[Stable-9.1.3 31/58] hw/intc/arm_gicv3_its: Zero initialize local DTEntry etc structs |
Date: |
Mon, 27 Jan 2025 23:25:17 +0300 |
In the GICv3 ITS model, we have a common coding pattern which has a
local C struct like "DTEntry dte", which is a C representation of an
in-guest-memory data structure, and we call a function such as
get_dte() to read guest memory and fill in the C struct. These
functions to read in the struct sometimes have cases where they will
leave early and not fill in the whole struct (for instance get_dte()
will set "dte->valid = false" and nothing else for the case where it
is passed an entry_addr implying that there is no L2 table entry for
the DTE). This then causes potential use of uninitialized memory
later, for instance when we call a trace event which prints all the
fields of the struct. Sufficiently advanced compilers may produce
-Wmaybe-uninitialized warnings about this, especially if LTO is
enabled.
Rather than trying to carefully separate out these trace events into
"only the 'valid' field is initialized" and "all fields can be
printed", zero-init all the structs when we define them. None of
these structs are large (the biggest is 24 bytes) and having
consistent behaviour is less likely to be buggy.
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2718
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241213182337.3343068-1-peter.maydell@linaro.org
(cherry picked from commit 9678b9c505725732353baefedb88b53c2eb8a184)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
index bf31158470..752322a3e7 100644
--- a/hw/intc/arm_gicv3_its.c
+++ b/hw/intc/arm_gicv3_its.c
@@ -465,7 +465,7 @@ static ItsCmdResult lookup_vte(GICv3ITSState *s, const char
*who,
static ItsCmdResult process_its_cmd_phys(GICv3ITSState *s, const ITEntry *ite,
int irqlevel)
{
- CTEntry cte;
+ CTEntry cte = {};
ItsCmdResult cmdres;
cmdres = lookup_cte(s, __func__, ite->icid, &cte);
@@ -479,7 +479,7 @@ static ItsCmdResult process_its_cmd_phys(GICv3ITSState *s,
const ITEntry *ite,
static ItsCmdResult process_its_cmd_virt(GICv3ITSState *s, const ITEntry *ite,
int irqlevel)
{
- VTEntry vte;
+ VTEntry vte = {};
ItsCmdResult cmdres;
cmdres = lookup_vte(s, __func__, ite->vpeid, &vte);
@@ -514,8 +514,8 @@ static ItsCmdResult process_its_cmd_virt(GICv3ITSState *s,
const ITEntry *ite,
static ItsCmdResult do_process_its_cmd(GICv3ITSState *s, uint32_t devid,
uint32_t eventid, ItsCmdType cmd)
{
- DTEntry dte;
- ITEntry ite;
+ DTEntry dte = {};
+ ITEntry ite = {};
ItsCmdResult cmdres;
int irqlevel;
@@ -583,8 +583,8 @@ static ItsCmdResult process_mapti(GICv3ITSState *s, const
uint64_t *cmdpkt,
uint32_t pIntid = 0;
uint64_t num_eventids;
uint16_t icid = 0;
- DTEntry dte;
- ITEntry ite;
+ DTEntry dte = {};
+ ITEntry ite = {};
devid = (cmdpkt[0] & DEVID_MASK) >> DEVID_SHIFT;
eventid = cmdpkt[1] & EVENTID_MASK;
@@ -651,8 +651,8 @@ static ItsCmdResult process_vmapti(GICv3ITSState *s, const
uint64_t *cmdpkt,
{
uint32_t devid, eventid, vintid, doorbell, vpeid;
uint32_t num_eventids;
- DTEntry dte;
- ITEntry ite;
+ DTEntry dte = {};
+ ITEntry ite = {};
if (!its_feature_virtual(s)) {
return CMD_CONTINUE;
@@ -761,7 +761,7 @@ static bool update_cte(GICv3ITSState *s, uint16_t icid,
const CTEntry *cte)
static ItsCmdResult process_mapc(GICv3ITSState *s, const uint64_t *cmdpkt)
{
uint16_t icid;
- CTEntry cte;
+ CTEntry cte = {};
icid = cmdpkt[2] & ICID_MASK;
cte.valid = cmdpkt[2] & CMD_FIELD_VALID_MASK;
@@ -822,7 +822,7 @@ static bool update_dte(GICv3ITSState *s, uint32_t devid,
const DTEntry *dte)
static ItsCmdResult process_mapd(GICv3ITSState *s, const uint64_t *cmdpkt)
{
uint32_t devid;
- DTEntry dte;
+ DTEntry dte = {};
devid = (cmdpkt[0] & DEVID_MASK) >> DEVID_SHIFT;
dte.size = cmdpkt[1] & SIZE_MASK;
@@ -886,9 +886,9 @@ static ItsCmdResult process_movi(GICv3ITSState *s, const
uint64_t *cmdpkt)
{
uint32_t devid, eventid;
uint16_t new_icid;
- DTEntry dte;
- CTEntry old_cte, new_cte;
- ITEntry old_ite;
+ DTEntry dte = {};
+ CTEntry old_cte = {}, new_cte = {};
+ ITEntry old_ite = {};
ItsCmdResult cmdres;
devid = FIELD_EX64(cmdpkt[0], MOVI_0, DEVICEID);
@@ -965,7 +965,7 @@ static bool update_vte(GICv3ITSState *s, uint32_t vpeid,
const VTEntry *vte)
static ItsCmdResult process_vmapp(GICv3ITSState *s, const uint64_t *cmdpkt)
{
- VTEntry vte;
+ VTEntry vte = {};
uint32_t vpeid;
if (!its_feature_virtual(s)) {
@@ -1030,7 +1030,7 @@ static void vmovp_callback(gpointer data, gpointer opaque)
*/
GICv3ITSState *s = data;
VmovpCallbackData *cbdata = opaque;
- VTEntry vte;
+ VTEntry vte = {};
ItsCmdResult cmdres;
cmdres = lookup_vte(s, __func__, cbdata->vpeid, &vte);
@@ -1085,9 +1085,9 @@ static ItsCmdResult process_vmovi(GICv3ITSState *s, const
uint64_t *cmdpkt)
{
uint32_t devid, eventid, vpeid, doorbell;
bool doorbell_valid;
- DTEntry dte;
- ITEntry ite;
- VTEntry old_vte, new_vte;
+ DTEntry dte = {};
+ ITEntry ite = {};
+ VTEntry old_vte = {}, new_vte = {};
ItsCmdResult cmdres;
if (!its_feature_virtual(s)) {
@@ -1186,10 +1186,10 @@ static ItsCmdResult process_vinvall(GICv3ITSState *s,
const uint64_t *cmdpkt)
static ItsCmdResult process_inv(GICv3ITSState *s, const uint64_t *cmdpkt)
{
uint32_t devid, eventid;
- ITEntry ite;
- DTEntry dte;
- CTEntry cte;
- VTEntry vte;
+ ITEntry ite = {};
+ DTEntry dte = {};
+ CTEntry cte = {};
+ VTEntry vte = {};
ItsCmdResult cmdres;
devid = FIELD_EX64(cmdpkt[0], INV_0, DEVICEID);
--
2.39.5
- [Stable-9.1.3 17/58] 9pfs: fix 'Tgetattr' after unlink, (continued)
- [Stable-9.1.3 17/58] 9pfs: fix 'Tgetattr' after unlink, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 18/58] tests/9p: also check 'Tgetattr' in 'use-after-unlink' test, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 20/58] target/ppc: Fix THREAD_SIBLING_FOREACH for multi-socket, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 21/58] hw/nvme: fix msix_uninit with exclusive bar, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 19/58] target/ppc: Fix non-maskable interrupt while halted, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 24/58] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt(), Michael Tokarev, 2025/01/28
- [Stable-9.1.3 26/58] tcg: Reset free_temps before tcg_optimize, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 25/58] 9pfs: fix regression regarding CVE-2023-2861, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 30/58] pc-bios: add missing riscv64 descriptor, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 27/58] tcg/riscv: Fix StoreStore barrier generation, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 31/58] hw/intc/arm_gicv3_its: Zero initialize local DTEntry etc structs,
Michael Tokarev <=
- [Stable-9.1.3 28/58] x86/loader: only patch linux kernels, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 22/58] hw/nvme: take a reference on the subsystem on vf realization, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 32/58] meson.build: Disallow libnfs v6 to fix the broken macOS build, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 29/58] roms: re-add edk2-basetools target, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 33/58] vhost-user: fix shared object return values, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 34/58] target/i386: Reset TSCs of parked vCPUs too on VM reset, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 35/58] hw/intc/riscv_aplic: Fix APLIC in_clrip and clripnum write emulation, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 40/58] target/i386/cpu: Fix notes for CPU models, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 43/58] migration: Fix parsing of s390 stream, Michael Tokarev, 2025/01/28
- [Stable-9.1.3 37/58] config/targets: update aarch64_be-linux-user gdb XML list, Michael Tokarev, 2025/01/28