* [Stable-7.2.7 01/62] hw/ppc: Introduce functions for conversion between timebase and nanoseconds
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 02/62] host-utils: Add muldiv64_round_up Michael Tokarev
` (60 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Nicholas Piggin, Cédric Le Goater,
Michael Tokarev
From: Nicholas Piggin <npiggin@gmail.com>
These calculations are repeated several times, and they will become
a little more complicated with subsequent changes.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
(cherry picked from commit 7798f5c576d898e7e10c4a2518f3f16411dedeb9)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index fbdc48911e..7392870e0e 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -490,10 +490,20 @@ void ppce500_set_mpic_proxy(bool enabled)
/*****************************************************************************/
/* PowerPC time base and decrementer emulation */
+static uint64_t ns_to_tb(uint32_t freq, int64_t clock)
+{
+ return muldiv64(clock, freq, NANOSECONDS_PER_SECOND);
+}
+
+static int64_t tb_to_ns(uint32_t freq, uint64_t tb)
+{
+ return muldiv64(tb, NANOSECONDS_PER_SECOND, freq);
+}
+
uint64_t cpu_ppc_get_tb(ppc_tb_t *tb_env, uint64_t vmclk, int64_t tb_offset)
{
/* TB time in tb periods */
- return muldiv64(vmclk, tb_env->tb_freq, NANOSECONDS_PER_SECOND) + tb_offset;
+ return ns_to_tb(tb_env->tb_freq, vmclk) + tb_offset;
}
uint64_t cpu_ppc_load_tbl (CPUPPCState *env)
@@ -534,8 +544,7 @@ uint32_t cpu_ppc_load_tbu (CPUPPCState *env)
static inline void cpu_ppc_store_tb(ppc_tb_t *tb_env, uint64_t vmclk,
int64_t *tb_offsetp, uint64_t value)
{
- *tb_offsetp = value -
- muldiv64(vmclk, tb_env->tb_freq, NANOSECONDS_PER_SECOND);
+ *tb_offsetp = value - ns_to_tb(tb_env->tb_freq, vmclk);
trace_ppc_tb_store(value, *tb_offsetp);
}
@@ -697,11 +706,11 @@ static inline int64_t _cpu_ppc_load_decr(CPUPPCState *env, uint64_t next)
diff = next - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (diff >= 0) {
- decr = muldiv64(diff, tb_env->decr_freq, NANOSECONDS_PER_SECOND);
+ decr = ns_to_tb(tb_env->decr_freq, diff);
} else if (tb_env->flags & PPC_TIMER_BOOKE) {
decr = 0;
} else {
- decr = -muldiv64(-diff, tb_env->decr_freq, NANOSECONDS_PER_SECOND);
+ decr = -ns_to_tb(tb_env->decr_freq, -diff);
}
trace_ppc_decr_load(decr);
@@ -846,7 +855,7 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
/* Calculate the next timer event */
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- next = now + muldiv64(value, NANOSECONDS_PER_SECOND, tb_env->decr_freq);
+ next = now + tb_to_ns(tb_env->decr_freq, value);
*nextp = next;
/* Adjust timer */
@@ -1135,7 +1144,7 @@ static void cpu_4xx_fit_cb (void *opaque)
/* Cannot occur, but makes gcc happy */
return;
}
- next = now + muldiv64(next, NANOSECONDS_PER_SECOND, tb_env->tb_freq);
+ next = now + tb_to_ns(tb_env->tb_freq, next);
if (next == now)
next++;
timer_mod(ppc40x_timer->fit_timer, next);
@@ -1163,8 +1172,7 @@ static void start_stop_pit (CPUPPCState *env, ppc_tb_t *tb_env, int is_excp)
} else {
trace_ppc4xx_pit_start(ppc40x_timer->pit_reload);
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- next = now + muldiv64(ppc40x_timer->pit_reload,
- NANOSECONDS_PER_SECOND, tb_env->decr_freq);
+ next = now + tb_to_ns(tb_env->decr_freq, ppc40x_timer->pit_reload);
if (is_excp)
next += tb_env->decr_next - now;
if (next == now)
@@ -1223,7 +1231,7 @@ static void cpu_4xx_wdt_cb (void *opaque)
/* Cannot occur, but makes gcc happy */
return;
}
- next = now + muldiv64(next, NANOSECONDS_PER_SECOND, tb_env->decr_freq);
+ next = now + tb_to_ns(tb_env->decr_freq, next);
if (next == now)
next++;
trace_ppc4xx_wdt(env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]);
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 02/62] host-utils: Add muldiv64_round_up
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 01/62] hw/ppc: Introduce functions for conversion between timebase and nanoseconds Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 03/62] hw/ppc: Round up the decrementer interval when converting to ns Michael Tokarev
` (59 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Nicholas Piggin, Richard Henderson,
Cédric Le Goater, Michael Tokarev
From: Nicholas Piggin <npiggin@gmail.com>
This will be used for converting time intervals in different base units
to host units, for the purpose of scheduling timers to emulate target
timers. Timers typically must not fire before their requested expiry
time but may fire some time afterward, so rounding up is the right way
to implement these.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
[ clg: renamed __muldiv64() to muldiv64_rounding() ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
(cherry picked from commit 47de6c4c287079744ceb96f606b3c0457addf380)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index b3434ec0bc..09daf58787 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -57,6 +57,11 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
return (__int128_t)a * b / c;
}
+static inline uint64_t muldiv64_round_up(uint64_t a, uint32_t b, uint32_t c)
+{
+ return ((__int128_t)a * b + c - 1) / c;
+}
+
static inline uint64_t divu128(uint64_t *plow, uint64_t *phigh,
uint64_t divisor)
{
@@ -84,7 +89,8 @@ void mulu64(uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b);
uint64_t divu128(uint64_t *plow, uint64_t *phigh, uint64_t divisor);
int64_t divs128(uint64_t *plow, int64_t *phigh, int64_t divisor);
-static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
+static inline uint64_t muldiv64_rounding(uint64_t a, uint32_t b, uint32_t c,
+ bool round_up)
{
union {
uint64_t ll;
@@ -100,12 +106,25 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
u.ll = a;
rl = (uint64_t)u.l.low * (uint64_t)b;
+ if (round_up) {
+ rl += c - 1;
+ }
rh = (uint64_t)u.l.high * (uint64_t)b;
rh += (rl >> 32);
res.l.high = rh / c;
res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c;
return res.ll;
}
+
+static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
+{
+ return muldiv64_rounding(a, b, c, false);
+}
+
+static inline uint64_t muldiv64_round_up(uint64_t a, uint32_t b, uint32_t c)
+{
+ return muldiv64_rounding(a, b, c, true);
+}
#endif
/**
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 03/62] hw/ppc: Round up the decrementer interval when converting to ns
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 01/62] hw/ppc: Introduce functions for conversion between timebase and nanoseconds Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 02/62] host-utils: Add muldiv64_round_up Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 04/62] hw/ppc: Avoid decrementer rounding errors Michael Tokarev
` (58 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Nicholas Piggin, Cédric Le Goater,
Michael Tokarev
From: Nicholas Piggin <npiggin@gmail.com>
The rule of timers is typically that they should never expire before the
timeout, but some time afterward. Rounding timer intervals up when doing
conversion is the right thing to do.
Under most circumstances it is impossible observe the decrementer
interrupt before the dec register has triggered. However with icount
timing, problems can arise. For example setting DEC to 0 can schedule
the timer for now, causing it to fire before any more instructions
have been executed and DEC is still 0.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
(cherry picked from commit eab0888418ab44344864965193cf6cd194ab6858)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index 7392870e0e..1996a03b57 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -490,14 +490,26 @@ void ppce500_set_mpic_proxy(bool enabled)
/*****************************************************************************/
/* PowerPC time base and decrementer emulation */
+/*
+ * Conversion between QEMU_CLOCK_VIRTUAL ns and timebase (TB) ticks:
+ * TB ticks are arrived at by multiplying tb_freq then dividing by
+ * ns per second, and rounding down. TB ticks drive all clocks and
+ * timers in the target machine.
+ *
+ * Converting TB intervals to ns for the purpose of setting a
+ * QEMU_CLOCK_VIRTUAL timer should go the other way, but rounding
+ * up. Rounding down could cause the timer to fire before the TB
+ * value has been reached.
+ */
static uint64_t ns_to_tb(uint32_t freq, int64_t clock)
{
return muldiv64(clock, freq, NANOSECONDS_PER_SECOND);
}
-static int64_t tb_to_ns(uint32_t freq, uint64_t tb)
+/* virtual clock in TB ticks, not adjusted by TB offset */
+static int64_t tb_to_ns_round_up(uint32_t freq, uint64_t tb)
{
- return muldiv64(tb, NANOSECONDS_PER_SECOND, freq);
+ return muldiv64_round_up(tb, NANOSECONDS_PER_SECOND, freq);
}
uint64_t cpu_ppc_get_tb(ppc_tb_t *tb_env, uint64_t vmclk, int64_t tb_offset)
@@ -855,7 +867,7 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
/* Calculate the next timer event */
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- next = now + tb_to_ns(tb_env->decr_freq, value);
+ next = now + tb_to_ns_round_up(tb_env->decr_freq, value);
*nextp = next;
/* Adjust timer */
@@ -1144,9 +1156,7 @@ static void cpu_4xx_fit_cb (void *opaque)
/* Cannot occur, but makes gcc happy */
return;
}
- next = now + tb_to_ns(tb_env->tb_freq, next);
- if (next == now)
- next++;
+ next = now + tb_to_ns_round_up(tb_env->tb_freq, next);
timer_mod(ppc40x_timer->fit_timer, next);
env->spr[SPR_40x_TSR] |= 1 << 26;
if ((env->spr[SPR_40x_TCR] >> 23) & 0x1) {
@@ -1172,11 +1182,10 @@ static void start_stop_pit (CPUPPCState *env, ppc_tb_t *tb_env, int is_excp)
} else {
trace_ppc4xx_pit_start(ppc40x_timer->pit_reload);
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- next = now + tb_to_ns(tb_env->decr_freq, ppc40x_timer->pit_reload);
+ next = now + tb_to_ns_round_up(tb_env->decr_freq,
+ ppc40x_timer->pit_reload);
if (is_excp)
next += tb_env->decr_next - now;
- if (next == now)
- next++;
timer_mod(tb_env->decr_timer, next);
tb_env->decr_next = next;
}
@@ -1231,9 +1240,7 @@ static void cpu_4xx_wdt_cb (void *opaque)
/* Cannot occur, but makes gcc happy */
return;
}
- next = now + tb_to_ns(tb_env->decr_freq, next);
- if (next == now)
- next++;
+ next = now + tb_to_ns_round_up(tb_env->decr_freq, next);
trace_ppc4xx_wdt(env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]);
switch ((env->spr[SPR_40x_TSR] >> 30) & 0x3) {
case 0x0:
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 04/62] hw/ppc: Avoid decrementer rounding errors
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (2 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 03/62] hw/ppc: Round up the decrementer interval when converting to ns Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 05/62] target/ppc: Sign-extend large decrementer to 64-bits Michael Tokarev
` (57 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Nicholas Piggin, Cédric Le Goater,
Michael Tokarev
From: Nicholas Piggin <npiggin@gmail.com>
The decrementer register contains a relative time in timebase units.
When writing to DECR this is converted and stored as an absolute value
in nanosecond units, reading DECR converts back to relative timebase.
The tb<->ns conversion of the relative part can cause rounding such that
a value writen to the decrementer can read back a different, with time
held constant. This is a particular problem for a deterministic icount
and record-replay trace.
Fix this by storing the absolute value in timebase units rather than
nanoseconds. The math before:
store: decr_next = now_ns + decr * ns_per_sec / tb_per_sec
load: decr = (decr_next - now_ns) * tb_per_sec / ns_per_sec
load(store): decr = decr * ns_per_sec / tb_per_sec * tb_per_sec /
ns_per_sec
After:
store: decr_next = now_ns * tb_per_sec / ns_per_sec + decr
load: decr = decr_next - now_ns * tb_per_sec / ns_per_sec
load(store): decr = decr
Fixes: 9fddaa0c0cab ("PowerPC merge: real time TB and decrementer - faster and simpler exception handling (Jocelyn Mayer)")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
(cherry picked from commit 8e0a5ac87800ccc6dd5013f89f27652f4480ab33)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index 1996a03b57..9961abc505 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -714,16 +714,17 @@ bool ppc_decr_clear_on_delivery(CPUPPCState *env)
static inline int64_t _cpu_ppc_load_decr(CPUPPCState *env, uint64_t next)
{
ppc_tb_t *tb_env = env->tb_env;
- int64_t decr, diff;
+ uint64_t now, n;
+ int64_t decr;
- diff = next - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- if (diff >= 0) {
- decr = ns_to_tb(tb_env->decr_freq, diff);
- } else if (tb_env->flags & PPC_TIMER_BOOKE) {
+ now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+ n = ns_to_tb(tb_env->decr_freq, now);
+ if (next > n && tb_env->flags & PPC_TIMER_BOOKE) {
decr = 0;
- } else {
- decr = -ns_to_tb(tb_env->decr_freq, -diff);
+ } else {
+ decr = next - n;
}
+
trace_ppc_decr_load(decr);
return decr;
@@ -865,13 +866,18 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
(*lower_excp)(cpu);
}
- /* Calculate the next timer event */
+ /*
+ * Calculate the next decrementer event and set a timer.
+ * decr_next is in timebase units to keep rounding simple. Note it is
+ * not adjusted by tb_offset because if TB changes via tb_offset changing,
+ * decrementer does not change, so not directly comparable with TB.
+ */
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- next = now + tb_to_ns_round_up(tb_env->decr_freq, value);
+ next = ns_to_tb(tb_env->decr_freq, now) + value;
*nextp = next;
/* Adjust timer */
- timer_mod(timer, next);
+ timer_mod(timer, tb_to_ns_round_up(tb_env->decr_freq, next));
}
static inline void _cpu_ppc_store_decr(PowerPCCPU *cpu, target_ulong decr,
@@ -1182,12 +1188,15 @@ static void start_stop_pit (CPUPPCState *env, ppc_tb_t *tb_env, int is_excp)
} else {
trace_ppc4xx_pit_start(ppc40x_timer->pit_reload);
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- next = now + tb_to_ns_round_up(tb_env->decr_freq,
- ppc40x_timer->pit_reload);
- if (is_excp)
- next += tb_env->decr_next - now;
+
+ if (is_excp) {
+ tb_env->decr_next += ppc40x_timer->pit_reload;
+ } else {
+ tb_env->decr_next = ns_to_tb(tb_env->decr_freq, now)
+ + ppc40x_timer->pit_reload;
+ }
+ next = tb_to_ns_round_up(tb_env->decr_freq, tb_env->decr_next);
timer_mod(tb_env->decr_timer, next);
- tb_env->decr_next = next;
}
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 05/62] target/ppc: Sign-extend large decrementer to 64-bits
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (3 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 04/62] hw/ppc: Avoid decrementer rounding errors Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 06/62] target/ppc: Decrementer fix BookE semantics Michael Tokarev
` (56 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Nicholas Piggin, Cédric Le Goater,
Michael Tokarev
From: Nicholas Piggin <npiggin@gmail.com>
When storing a large decrementer value with the most significant
implemented bit set, it is to be treated as a negative and sign
extended.
This isn't hit for book3s DEC because of another bug, fixing it
in the next patch exposes this one and can cause additional
problems, so fix this first. It can be hit with HDECR and other
edge triggered types.
Fixes: a8dafa52518 ("target/ppc: Implement large decrementer support for TCG")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[ clg: removed extra cpu and pcc variables shadowing local variables ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
(cherry picked from commit c8fbc6b9f2f3c732ee3307093c1c5c367eaa64ae)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index 9961abc505..5573ab467c 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -746,7 +746,9 @@ target_ulong cpu_ppc_load_decr(CPUPPCState *env)
* to 64 bits, otherwise it is a 32 bit value.
*/
if (env->spr[SPR_LPCR] & LPCR_LD) {
- return decr;
+ PowerPCCPU *cpu = env_archcpu(env);
+ PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+ return sextract64(decr, 0, pcc->lrg_decr_bits);
}
return (uint32_t) decr;
}
@@ -765,7 +767,7 @@ target_ulong cpu_ppc_load_hdecr(CPUPPCState *env)
* extended to 64 bits, otherwise it is 32 bits.
*/
if (pcc->lrg_decr_bits > 32) {
- return hdecr;
+ return sextract64(hdecr, 0, pcc->lrg_decr_bits);
}
return (uint32_t) hdecr;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 06/62] target/ppc: Decrementer fix BookE semantics
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (4 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 05/62] target/ppc: Sign-extend large decrementer to 64-bits Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 07/62] hw/ppc: Always store the decrementer value Michael Tokarev
` (55 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Nicholas Piggin, sdicaro, Daniel Henrique Barboza,
Michael Tokarev
From: Nicholas Piggin <npiggin@gmail.com>
The decrementer store function has logic that short-cuts the timer if a
very small value is stored (0, 1, or 2) and raises an interrupt
directly. There are two problem with this on BookE.
First is that BookE says a decrementer interrupt should not be raised
on a store of 0, only of a decrement from 1. Second is that raising
the irq directly will bypass the auto-reload logic in the booke decr
timer function, breaking autoreload when 1 or 2 is stored.
Fix this by removing that small-value special case. It makes this
tricky logic even more difficult to reason about, and it hardly matters
for performance.
Cc: sdicaro@DDCI.com
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20230530131214.373524-2-npiggin@gmail.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
(cherry picked from commit 17dd1354c1d1aba9caf4af01e11aa7dbe128474f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index 5573ab467c..dfa3945454 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -843,11 +843,7 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
}
/*
- * Going from 2 -> 1, 1 -> 0 or 0 -> -1 is the event to generate a DEC
- * interrupt.
- *
- * If we get a really small DEC value, we can assume that by the time we
- * handled it we should inject an interrupt already.
+ * Going from 1 -> 0 or 0 -> -1 is the event to generate a DEC interrupt.
*
* On MSB level based DEC implementations the MSB always means the interrupt
* is pending, so raise it on those.
@@ -855,8 +851,7 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
* On MSB edge based DEC implementations the MSB going from 0 -> 1 triggers
* an edge interrupt, so raise it here too.
*/
- if ((value < 3) ||
- ((tb_env->flags & PPC_DECR_UNDERFLOW_LEVEL) && signed_value < 0) ||
+ if (((tb_env->flags & PPC_DECR_UNDERFLOW_LEVEL) && signed_value < 0) ||
((tb_env->flags & PPC_DECR_UNDERFLOW_TRIGGERED) && signed_value < 0
&& signed_decr >= 0)) {
(*raise_excp)(cpu);
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 07/62] hw/ppc: Always store the decrementer value
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (5 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 06/62] target/ppc: Decrementer fix BookE semantics Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 08/62] linux-user/hppa: clear the PSW 'N' bit when delivering signals Michael Tokarev
` (54 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Nicholas Piggin, Cédric Le Goater,
Michael Tokarev
From: Nicholas Piggin <npiggin@gmail.com>
When writing a value to the decrementer that raises an exception, the
irq is raised, but the value is not stored so the store doesn't appear
to have changed the register when it is read again.
Always store the write value to the register.
Fixes: e81a982aa53 ("PPC: Clean up DECR implementation")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
(cherry picked from commit febb71d543a8f747b2f8aaf0182d0a385c6a02c3)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index dfa3945454..b17804fc17 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -842,6 +842,16 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
return;
}
+ /*
+ * Calculate the next decrementer event and set a timer.
+ * decr_next is in timebase units to keep rounding simple. Note it is
+ * not adjusted by tb_offset because if TB changes via tb_offset changing,
+ * decrementer does not change, so not directly comparable with TB.
+ */
+ now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+ next = ns_to_tb(tb_env->decr_freq, now) + value;
+ *nextp = next; /* nextp is in timebase units */
+
/*
* Going from 1 -> 0 or 0 -> -1 is the event to generate a DEC interrupt.
*
@@ -863,16 +873,6 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
(*lower_excp)(cpu);
}
- /*
- * Calculate the next decrementer event and set a timer.
- * decr_next is in timebase units to keep rounding simple. Note it is
- * not adjusted by tb_offset because if TB changes via tb_offset changing,
- * decrementer does not change, so not directly comparable with TB.
- */
- now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- next = ns_to_tb(tb_env->decr_freq, now) + value;
- *nextp = next;
-
/* Adjust timer */
timer_mod(timer, tb_to_ns_round_up(tb_env->decr_freq, next));
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 08/62] linux-user/hppa: clear the PSW 'N' bit when delivering signals
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (6 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 07/62] hw/ppc: Always store the decrementer value Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 09/62] linux-user/hppa: lock both words of function descriptor Michael Tokarev
` (53 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Mikulas Patocka, Helge Deller, Michael Tokarev
From: Mikulas Patocka <mpatocka@redhat.com>
qemu-hppa may crash when delivering a signal. It can be demonstrated with
this program. Compile the program with "hppa-linux-gnu-gcc -O2 signal.c"
and run it with "qemu-hppa -one-insn-per-tb a.out". It reports that the
address of the flag is 0xb4 and it crashes when attempting to touch it.
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <signal.h>
sig_atomic_t flag;
void sig(int n)
{
printf("&flag: %p\n", &flag);
flag = 1;
}
int main(void)
{
struct sigaction sa;
struct itimerval it;
sa.sa_handler = sig;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
if (sigaction(SIGALRM, &sa, NULL)) perror("sigaction"), exit(1);
it.it_interval.tv_sec = 0;
it.it_interval.tv_usec = 100;
it.it_value.tv_sec = it.it_interval.tv_sec;
it.it_value.tv_usec = it.it_interval.tv_usec;
if (setitimer(ITIMER_REAL, &it, NULL)) perror("setitimer"), exit(1);
while (1) {
}
}
The reason for the crash is that the signal handling routine doesn't clear
the 'N' flag in the PSW. If the signal interrupts a thread when the 'N'
flag is set, the flag remains set at the beginning of the signal handler
and the first instruction of the signal handler is skipped.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Helge Deller <deller@gmx.de>
Cc: qemu-stable@nongnu.org
Signed-off-by: Helge Deller <deller@gmx.de>
(cherry picked from commit 2529497cb6b298e732e8dbe5212da7925240b4f4)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c
index f253a15864..3a976ac693 100644
--- a/linux-user/hppa/signal.c
+++ b/linux-user/hppa/signal.c
@@ -159,6 +159,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
}
env->iaoq_f = haddr;
env->iaoq_b = haddr + 4;
+ env->psw_n = 0;
return;
give_sigsegv:
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 09/62] linux-user/hppa: lock both words of function descriptor
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (7 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 08/62] linux-user/hppa: clear the PSW 'N' bit when delivering signals Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 10/62] hw/cxl: Fix CFMW config memory leak Michael Tokarev
` (52 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Mikulas Patocka, Helge Deller, Michael Tokarev
From: Mikulas Patocka <mpatocka@redhat.com>
The code in setup_rt_frame reads two words at haddr, but locks only one.
This patch fixes it to lock both.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Helge Deller <deller@gmx.de>
Cc: qemu-stable@nongnu.org
Signed-off-by: Helge Deller <deller@gmx.de>
(cherry picked from commit 5b1270ef1477bb7f240c3bfe2cd8b0fe4721fd51)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c
index 3a976ac693..bda6e54655 100644
--- a/linux-user/hppa/signal.c
+++ b/linux-user/hppa/signal.c
@@ -149,12 +149,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
target_ulong *fdesc, dest;
haddr &= -4;
- if (!lock_user_struct(VERIFY_READ, fdesc, haddr, 1)) {
+ fdesc = lock_user(VERIFY_READ, haddr, 2 * sizeof(target_ulong), 1);
+ if (!fdesc) {
goto give_sigsegv;
}
__get_user(dest, fdesc);
__get_user(env->gr[19], fdesc + 1);
- unlock_user_struct(fdesc, haddr, 1);
+ unlock_user(fdesc, haddr, 0);
haddr = dest;
}
env->iaoq_f = haddr;
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 10/62] hw/cxl: Fix CFMW config memory leak
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (8 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 09/62] linux-user/hppa: lock both words of function descriptor Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 11/62] target/arm: Don't skip MTE checks for LDRT/STRT at EL0 Michael Tokarev
` (51 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Li Zhijian, Philippe Mathieu-Daudé,
Jonathan Cameron, Fan Ni, Michael Tokarev
From: Li Zhijian <lizhijian@cn.fujitsu.com>
Allocate targets and targets[n] resources when all sanity checks are
passed to avoid memory leaks.
Cc: qemu-stable@nongnu.org
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Fan Ni <fan.ni@samsung.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit 7b165fa164022b756c2b001d0a1525f98199d3ac)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c
index 1adf61231a..0fc3e57138 100644
--- a/hw/cxl/cxl-host.c
+++ b/hw/cxl/cxl-host.c
@@ -39,12 +39,6 @@ static void cxl_fixed_memory_window_config(CXLState *cxl_state,
return;
}
- fw->targets = g_malloc0_n(fw->num_targets, sizeof(*fw->targets));
- for (i = 0, target = object->targets; target; i++, target = target->next) {
- /* This link cannot be resolved yet, so stash the name for now */
- fw->targets[i] = g_strdup(target->value);
- }
-
if (object->size % (256 * MiB)) {
error_setg(errp,
"Size of a CXL fixed memory window must my a multiple of 256MiB");
@@ -64,6 +58,12 @@ static void cxl_fixed_memory_window_config(CXLState *cxl_state,
fw->enc_int_gran = 0;
}
+ fw->targets = g_malloc0_n(fw->num_targets, sizeof(*fw->targets));
+ for (i = 0, target = object->targets; target; i++, target = target->next) {
+ /* This link cannot be resolved yet, so stash the name for now */
+ fw->targets[i] = g_strdup(target->value);
+ }
+
cxl_state->fixed_windows = g_list_append(cxl_state->fixed_windows,
g_steal_pointer(&fw));
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 11/62] target/arm: Don't skip MTE checks for LDRT/STRT at EL0
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (9 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 10/62] hw/cxl: Fix CFMW config memory leak Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 12/62] accel/tcg: mttcg remove false-negative halted assertion Michael Tokarev
` (50 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Peter Maydell, Richard Henderson, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
The LDRT/STRT "unprivileged load/store" instructions behave like
normal ones if executed at EL0. We handle this correctly for
the load/store semantics, but get the MTE checking wrong.
We always look at s->mte_active[is_unpriv] to see whether we should
be doing MTE checks, but in hflags.c when we set the TB flags that
will be used to fill the mte_active[] array we only set the
MTE0_ACTIVE bit if UNPRIV is true (i.e. we are not at EL0).
This means that a LDRT at EL0 will see s->mte_active[1] as 0,
and will not do MTE checks even when MTE is enabled.
To avoid the translate-time code having to do an explicit check on
s->unpriv to see if it is OK to index into the mte_active[] array,
duplicate MTE_ACTIVE into MTE0_ACTIVE when UNPRIV is false.
(This isn't a very serious bug because generally nobody executes
LDRT/STRT at EL0, because they have no use there.)
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20230912140434.1333369-2-peter.maydell@linaro.org
(cherry picked from commit 903dbefc2b6918c10d12d9aafa0168cee8d287c7)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: before v7.2.0-1636-g671efad16a this code was in target/arm/helper.c)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 22bc935242..a52ef3dfe4 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -11301,6 +11301,15 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
&& !(env->pstate & PSTATE_TCO)
&& (sctlr & (el == 0 ? SCTLR_TCF0 : SCTLR_TCF))) {
DP_TBFLAG_A64(flags, MTE_ACTIVE, 1);
+ if (!EX_TBFLAG_A64(flags, UNPRIV)) {
+ /*
+ * In non-unpriv contexts (eg EL0), unpriv load/stores
+ * act like normal ones; duplicate the MTE info to
+ * avoid translate-a64.c having to check UNPRIV to see
+ * whether it is OK to index into MTE_ACTIVE[].
+ */
+ DP_TBFLAG_A64(flags, MTE0_ACTIVE, 1);
+ }
}
}
/* And again for unprivileged accesses, if required. */
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 12/62] accel/tcg: mttcg remove false-negative halted assertion
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (10 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 11/62] target/arm: Don't skip MTE checks for LDRT/STRT at EL0 Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 13/62] hw/scsi/scsi-disk: Disallow block sizes smaller than 512 [CVE-2023-42467] Michael Tokarev
` (49 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Nicholas Piggin, Ivan Warren, Richard Henderson,
Michael Tokarev
From: Nicholas Piggin <npiggin@gmail.com>
mttcg asserts that an execution ending with EXCP_HALTED must have
cpu->halted. However between the event or instruction that sets
cpu->halted and requests exit and the assertion here, an
asynchronous event could clear cpu->halted.
This leads to crashes running AIX on ppc/pseries because it uses
H_CEDE/H_PROD hcalls, where H_CEDE sets self->halted = 1 and
H_PROD sets other cpu->halted = 0 and kicks it.
H_PROD could be turned into an interrupt to wake, but several other
places in ppc, sparc, and semihosting follow what looks like a similar
pattern setting halted = 0 directly. So remove this assertion.
Reported-by: Ivan Warren <ivan@vmfacility.fr>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Message-Id: <20230829010658.8252-1-npiggin@gmail.com>
[rth: Keep the case label and adjust the comment.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit 0e5903436de712844b0e6cdd862b499c767e09e9)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index d50239e0e2..3a021624f4 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -100,14 +100,9 @@ static void *mttcg_cpu_thread_fn(void *arg)
break;
case EXCP_HALTED:
/*
- * during start-up the vCPU is reset and the thread is
- * kicked several times. If we don't ensure we go back
- * to sleep in the halted state we won't cleanly
- * start-up when the vCPU is enabled.
- *
- * cpu->halted should ensure we sleep in wait_io_event
+ * Usually cpu->halted is set, but may have already been
+ * reset by another thread by the time we arrive here.
*/
- g_assert(cpu->halted);
break;
case EXCP_ATOMIC:
qemu_mutex_unlock_iothread();
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 13/62] hw/scsi/scsi-disk: Disallow block sizes smaller than 512 [CVE-2023-42467]
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (11 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 12/62] accel/tcg: mttcg remove false-negative halted assertion Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 14/62] ui/vnc: fix debug output for invalid audio message Michael Tokarev
` (48 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Thomas Huth, Paolo Bonzini, Michael Tokarev
From: Thomas Huth <thuth@redhat.com>
We are doing things like
nb_sectors /= (s->qdev.blocksize / BDRV_SECTOR_SIZE);
in the code here (e.g. in scsi_disk_emulate_mode_sense()), so if
the blocksize is smaller than BDRV_SECTOR_SIZE (=512), this crashes
with a division by 0 exception. Thus disallow block sizes of 256
bytes to avoid this situation.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1813
CVE: 2023-42467
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20230925091854.49198-1-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 7cfcc79b0ab800959716738aff9419f53fc68c9c)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index e493c28814..915e0369cb 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -1624,9 +1624,10 @@ static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf)
* Since the existing code only checks/updates bits 8-15 of the block
* size, restrict ourselves to the same requirement for now to ensure
* that a block size set by a block descriptor and then read back by
- * a subsequent SCSI command will be the same
+ * a subsequent SCSI command will be the same. Also disallow a block
+ * size of 256 since we cannot handle anything below BDRV_SECTOR_SIZE.
*/
- if (bs && !(bs & ~0xff00) && bs != s->qdev.blocksize) {
+ if (bs && !(bs & ~0xfe00) && bs != s->qdev.blocksize) {
s->qdev.blocksize = bs;
trace_scsi_disk_mode_select_set_blocksize(s->qdev.blocksize);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 14/62] ui/vnc: fix debug output for invalid audio message
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (12 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 13/62] hw/scsi/scsi-disk: Disallow block sizes smaller than 512 [CVE-2023-42467] Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 15/62] ui/vnc: fix handling of VNC_FEATURE_XVP Michael Tokarev
` (47 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Paolo Bonzini, Daniel P . Berrangé,
Michael Tokarev
From: Paolo Bonzini <pbonzini@redhat.com>
The debug message was cut and pasted from the invalid audio format
case, but the audio message is at bytes 2-3.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 0cb9c5880e6b8dedc4e20026ce859dd1ea9aac84)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/ui/vnc.c b/ui/vnc.c
index 1856d57380..e04a251e72 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2565,7 +2565,7 @@ static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
vs, vs->ioc, vs->as.fmt, vs->as.nchannels, vs->as.freq);
break;
default:
- VNC_DEBUG("Invalid audio message %d\n", read_u8(data, 4));
+ VNC_DEBUG("Invalid audio message %d\n", read_u8(data, 2));
vnc_client_error(vs);
break;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 15/62] ui/vnc: fix handling of VNC_FEATURE_XVP
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (13 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 14/62] ui/vnc: fix debug output for invalid audio message Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 16/62] optionrom: Remove build-id section Michael Tokarev
` (46 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Paolo Bonzini, Michael Tokarev
From: Paolo Bonzini <pbonzini@redhat.com>
VNC_FEATURE_XVP was not shifted left before adding it to vs->features,
so it was never enabled; but it was also checked the wrong way with
a logical AND instead of vnc_has_feature. Fix both places.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 477b301000d665313217f65e3a368d2cb7769c42)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/ui/vnc.c b/ui/vnc.c
index e04a251e72..1ca16c0ff6 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2219,7 +2219,7 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)
break;
case VNC_ENCODING_XVP:
if (vs->vd->power_control) {
- vs->features |= VNC_FEATURE_XVP;
+ vs->features |= VNC_FEATURE_XVP_MASK;
send_xvp_message(vs, VNC_XVP_CODE_INIT);
}
break;
@@ -2468,7 +2468,7 @@ static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
vnc_client_cut_text(vs, read_u32(data, 4), data + 8);
break;
case VNC_MSG_CLIENT_XVP:
- if (!(vs->features & VNC_FEATURE_XVP)) {
+ if (!vnc_has_feature(vs, VNC_FEATURE_XVP)) {
error_report("vnc: xvp client message while disabled");
vnc_client_error(vs);
break;
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 16/62] optionrom: Remove build-id section
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (14 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 15/62] ui/vnc: fix handling of VNC_FEATURE_XVP Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 17/62] esp: use correct type for esp_dma_enable() in sysbus_esp_gpio_demux() Michael Tokarev
` (45 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Fabiano Rosas, Vasiliy Ulyanov, Thomas Huth,
Paolo Bonzini, Michael Tokarev
From: Fabiano Rosas <farosas@suse.de>
Our linker script for optionroms specifies only the placement of the
.text section, leaving the linker free to place the remaining sections
at arbitrary places in the file.
Since at least binutils 2.39, the .note.gnu.build-id section is now
being placed at the start of the file, which causes label addresses to
be shifted. For linuxboot_dma.bin that means that the PnP header
(among others) will not be found when determining the type of ROM at
optionrom_setup():
(0x1c is the label _pnph, where the magic "PnP" is)
$ xxd /usr/share/qemu/linuxboot_dma.bin | grep "PnP"
00000010: 0000 0000 0000 0000 0000 1c00 2450 6e50 ............$PnP
$ xxd pc-bios/optionrom/linuxboot_dma.bin | grep "PnP"
00000010: 0000 0000 0000 0000 0000 4c00 2450 6e50 ............$PnP
^bad
Using a freshly built linuxboot_dma.bin ROM results in a broken boot:
SeaBIOS (version rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org)
Booting from Hard Disk...
Boot failed: could not read the boot disk
Booting from Floppy...
Boot failed: could not read the boot disk
No bootable device.
We're not using the build-id section, so pass the --build-id=none
option to the linker to remove it entirely.
Note: In theory, this same issue could happen with any other
section. The ideal solution would be to have all unused sections
discarded in the linker script. However that would be a larger change,
specially for the pvh rom which uses the .bss and COMMON sections so
I'm addressing only the immediate issue here.
Reported-by: Vasiliy Ulyanov <vulyanov@suse.de>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20230926192502.15986-1-farosas@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 35ed01ba5448208695ada5fa20a13c0a4689a1c1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(mjt: remove unrelated stable@vger)
diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile
index b1fff0ba6c..30d07026c7 100644
--- a/pc-bios/optionrom/Makefile
+++ b/pc-bios/optionrom/Makefile
@@ -36,7 +36,7 @@ config-cc.mak: Makefile
$(call cc-option,-Wno-array-bounds)) 3> config-cc.mak
-include config-cc.mak
-override LDFLAGS = -nostdlib -Wl,-T,$(SRC_DIR)/flat.lds
+override LDFLAGS = -nostdlib -Wl,--build-id=none,-T,$(SRC_DIR)/flat.lds
pvh.img: pvh.o pvh_main.o
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 17/62] esp: use correct type for esp_dma_enable() in sysbus_esp_gpio_demux()
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (15 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 16/62] optionrom: Remove build-id section Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 18/62] esp: restrict non-DMA transfer length to that of available data Michael Tokarev
` (44 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Mark Cave-Ayland, Philippe Mathieu-Daudé,
Thomas Huth, Paolo Bonzini, Michael Tokarev
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
The call to esp_dma_enable() was being made with the SYSBUS_ESP type instead of
the ESP type. This meant that when GPIO 1 was being used to trigger a DMA
request from an external DMA controller, the setting of ESPState's dma_enabled
field would clobber unknown memory whilst the dma_cb callback pointer would
typically return NULL so the DMA request would never start.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20230913204410.65650-2-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit b86dc5cb0b4105fa8ad29e822ab5d21c589c5ec5)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index e52188d022..4218a6a960 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -1395,7 +1395,7 @@ static void sysbus_esp_gpio_demux(void *opaque, int irq, int level)
parent_esp_reset(s, irq, level);
break;
case 1:
- esp_dma_enable(opaque, irq, level);
+ esp_dma_enable(s, irq, level);
break;
}
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 18/62] esp: restrict non-DMA transfer length to that of available data
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (16 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 17/62] esp: use correct type for esp_dma_enable() in sysbus_esp_gpio_demux() Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 19/62] scsi-disk: ensure that FORMAT UNIT commands are terminated Michael Tokarev
` (43 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Mark Cave-Ayland, Thomas Huth, Paolo Bonzini,
Michael Tokarev
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
In the case where a SCSI layer transfer is incorrectly terminated, it is
possible for a TI command to cause a SCSI buffer overflow due to the
expected transfer data length being less than the available data in the
FIFO. When this occurs the unsigned async_len variable underflows and
becomes a large offset which writes past the end of the allocated SCSI
buffer.
Restrict the non-DMA transfer length to be the smallest of the expected
transfer length and the available FIFO data to ensure that it is no longer
possible for the SCSI buffer overflow to occur.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1810
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20230913204410.65650-3-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 77668e4b9bca03a856c27ba899a2513ddf52bb52)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 4218a6a960..9b11d8c573 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -759,7 +759,8 @@ static void esp_do_nodma(ESPState *s)
}
if (to_device) {
- len = MIN(fifo8_num_used(&s->fifo), ESP_FIFO_SZ);
+ len = MIN(s->async_len, ESP_FIFO_SZ);
+ len = MIN(len, fifo8_num_used(&s->fifo));
esp_fifo_pop_buf(&s->fifo, s->async_buf, len);
s->async_buf += len;
s->async_len -= len;
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 19/62] scsi-disk: ensure that FORMAT UNIT commands are terminated
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (17 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 18/62] esp: restrict non-DMA transfer length to that of available data Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 20/62] target/i386: fix operand size of unary SSE operations Michael Tokarev
` (42 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Mark Cave-Ayland, Thomas Huth, Paolo Bonzini,
Michael Tokarev
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Otherwise when a FORMAT UNIT command is issued, the SCSI layer can become
confused because it can find itself in the situation where it thinks there
is still data to be transferred which can cause the next emulated SCSI
command to fail.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Fixes: 6ab71761 ("scsi-disk: add FORMAT UNIT command")
Tested-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20230913204410.65650-4-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit be2b619a17345d007bcf9987a3e4afd1edea3e4f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 915e0369cb..b884a6f135 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -1952,6 +1952,10 @@ static void scsi_disk_emulate_write_data(SCSIRequest *req)
scsi_disk_emulate_write_same(r, r->iov.iov_base);
break;
+ case FORMAT_UNIT:
+ scsi_req_complete(&r->req, GOOD);
+ break;
+
default:
abort();
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 20/62] target/i386: fix operand size of unary SSE operations
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (18 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 19/62] scsi-disk: ensure that FORMAT UNIT commands are terminated Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 21/62] tests/tcg/i386: correct mask for VPERM2F128/VPERM2I128 Michael Tokarev
` (41 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Paolo Bonzini, Michael Tokarev
From: Paolo Bonzini <pbonzini@redhat.com>
VRCPSS, VRSQRTSS and VCVTSx2Sx have a 32-bit or 64-bit memory operand,
which is represented in the decoding tables by X86_VEX_REPScalar. Add it
to the tables, and make validate_vex() handle the case of an instruction
that is in exception type 4 without the REP prefix and exception type 5
with it; this is the cas of VRCP and VRSQRT.
Reported-by: yongwoo <https://gitlab.com/yongwoo36>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1377
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 3d304620ec6c95f31db17acc132f42f243369299)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index ee4f4a899f..1c8a3aae4f 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -105,6 +105,7 @@
#define vex3 .vex_class = 3,
#define vex4 .vex_class = 4,
#define vex4_unal .vex_class = 4, .vex_special = X86_VEX_SSEUnaligned,
+#define vex4_rep5 .vex_class = 4, .vex_special = X86_VEX_REPScalar,
#define vex5 .vex_class = 5,
#define vex6 .vex_class = 6,
#define vex7 .vex_class = 7,
@@ -850,8 +851,8 @@ static const X86OpEntry opcodes_0F[256] = {
[0x50] = X86_OP_ENTRY3(MOVMSK, G,y, None,None, U,x, vex7 p_00_66),
[0x51] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
- [0x52] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex5 p_00_f3),
- [0x53] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex5 p_00_f3),
+ [0x52] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex4_rep5 p_00_f3),
+ [0x53] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex4_rep5 p_00_f3),
[0x54] = X86_OP_ENTRY3(PAND, V,x, H,x, W,x, vex4 p_00_66), /* vand */
[0x55] = X86_OP_ENTRY3(PANDN, V,x, H,x, W,x, vex4 p_00_66), /* vandn */
[0x56] = X86_OP_ENTRY3(POR, V,x, H,x, W,x, vex4 p_00_66), /* vor */
@@ -889,7 +890,7 @@ static const X86OpEntry opcodes_0F[256] = {
[0x58] = X86_OP_ENTRY3(VADD, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
[0x59] = X86_OP_ENTRY3(VMUL, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
- [0x5a] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex3 p_00_66_f3_f2),
+ [0x5a] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
[0x5b] = X86_OP_GROUP0(0F5B),
[0x5c] = X86_OP_ENTRY3(VSUB, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
[0x5d] = X86_OP_ENTRY3(VMIN, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
@@ -1458,9 +1459,9 @@ static bool validate_vex(DisasContext *s, X86DecodedInsn *decode)
* Instructions which differ between 00/66 and F2/F3 in the
* exception classification and the size of the memory operand.
*/
- assert(e->vex_class == 1 || e->vex_class == 2);
+ assert(e->vex_class == 1 || e->vex_class == 2 || e->vex_class == 4);
if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) {
- e->vex_class = 3;
+ e->vex_class = e->vex_class < 4 ? 3 : 5;
if (s->vex_l) {
goto illegal;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 21/62] tests/tcg/i386: correct mask for VPERM2F128/VPERM2I128
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (19 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 20/62] target/i386: fix operand size of unary SSE operations Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 22/62] target/i386: Fix and add some comments next to SSE/AVX instructions Michael Tokarev
` (40 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Paolo Bonzini, Michael Tokarev
From: Paolo Bonzini <pbonzini@redhat.com>
The instructions also use bits 3 and 7 of their 8-byte immediate.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 9e65829699f901c62a612316a2897f4ad8a27049)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/tests/tcg/i386/test-avx.py b/tests/tcg/i386/test-avx.py
index d9ca00a49e..641a2ef69e 100755
--- a/tests/tcg/i386/test-avx.py
+++ b/tests/tcg/i386/test-avx.py
@@ -49,7 +49,7 @@
'VEXTRACT[FI]128': 0x01,
'VINSERT[FI]128': 0x01,
'VPBLENDD': 0xff,
- 'VPERM2[FI]128': 0x33,
+ 'VPERM2[FI]128': 0xbb,
'VPERMPD': 0xff,
'VPERMQ': 0xff,
'VPERMILPS': 0xff,
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 22/62] target/i386: Fix and add some comments next to SSE/AVX instructions.
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (20 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 21/62] tests/tcg/i386: correct mask for VPERM2F128/VPERM2I128 Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 23/62] target/i386: Fix exception classes for " Michael Tokarev
` (39 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Ricky Zhou, Paolo Bonzini, Michael Tokarev
From: Ricky Zhou <ricky@rzhou.org>
Adds some comments describing what instructions correspond to decoding
table entries and fixes some existing comments which named the wrong
instruction.
Message-Id: <20230501111428.95998-1-ricky@rzhou.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit afa94dabc52b17e340975e158d5a816ec2b2de23)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index 1c8a3aae4f..38eddd1adb 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -274,9 +274,9 @@ static void decode_0F78(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
{
static const X86OpEntry opcodes_0F78[4] = {
{},
- X86_OP_ENTRY3(EXTRQ_i, V,x, None,None, I,w, cpuid(SSE4A)),
+ X86_OP_ENTRY3(EXTRQ_i, V,x, None,None, I,w, cpuid(SSE4A)), /* AMD extension */
{},
- X86_OP_ENTRY3(INSERTQ_i, V,x, U,x, I,w, cpuid(SSE4A)),
+ X86_OP_ENTRY3(INSERTQ_i, V,x, U,x, I,w, cpuid(SSE4A)), /* AMD extension */
};
*entry = *decode_by_prefix(s, opcodes_0F78);
}
@@ -284,9 +284,9 @@ static void decode_0F78(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
static void decode_0F79(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b)
{
if (s->prefix & PREFIX_REPNZ) {
- entry->gen = gen_INSERTQ_r;
+ entry->gen = gen_INSERTQ_r; /* AMD extension */
} else if (s->prefix & PREFIX_DATA) {
- entry->gen = gen_EXTRQ_r;
+ entry->gen = gen_EXTRQ_r; /* AMD extension */
} else {
entry->gen = NULL;
};
@@ -660,15 +660,15 @@ static void decode_0F10(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
static void decode_0F11(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b)
{
static const X86OpEntry opcodes_0F11_reg[4] = {
- X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVPS */
- X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVPD */
+ X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPS */
+ X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPD */
X86_OP_ENTRY3(VMOVSS, W,x, H,x, V,x, vex4),
X86_OP_ENTRY3(VMOVLPx, W,x, H,x, V,q, vex4), /* MOVSD */
};
static const X86OpEntry opcodes_0F11_mem[4] = {
- X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVPS */
- X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVPD */
+ X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPS */
+ X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPD */
X86_OP_ENTRY3(VMOVSS_st, M,ss, None,None, V,x, vex4),
X86_OP_ENTRY3(VMOVLPx_st, M,sd, None,None, V,x, vex4), /* MOVSD */
};
@@ -850,9 +850,9 @@ static const X86OpEntry opcodes_0F[256] = {
[0x17] = X86_OP_ENTRY3(VMOVHPx_st, M,q, None,None, V,dq, vex4 p_00_66),
[0x50] = X86_OP_ENTRY3(MOVMSK, G,y, None,None, U,x, vex7 p_00_66),
- [0x51] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
- [0x52] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex4_rep5 p_00_f3),
- [0x53] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex4_rep5 p_00_f3),
+ [0x51] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2), /* sqrtps */
+ [0x52] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex4_rep5 p_00_f3), /* rsqrtps */
+ [0x53] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex4_rep5 p_00_f3), /* rcpps */
[0x54] = X86_OP_ENTRY3(PAND, V,x, H,x, W,x, vex4 p_00_66), /* vand */
[0x55] = X86_OP_ENTRY3(PANDN, V,x, H,x, W,x, vex4 p_00_66), /* vandn */
[0x56] = X86_OP_ENTRY3(POR, V,x, H,x, W,x, vex4 p_00_66), /* vor */
@@ -890,7 +890,7 @@ static const X86OpEntry opcodes_0F[256] = {
[0x58] = X86_OP_ENTRY3(VADD, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
[0x59] = X86_OP_ENTRY3(VMUL, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
- [0x5a] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
+ [0x5a] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2), /* CVTPS2PD */
[0x5b] = X86_OP_GROUP0(0F5B),
[0x5c] = X86_OP_ENTRY3(VSUB, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
[0x5d] = X86_OP_ENTRY3(VMIN, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 23/62] target/i386: Fix exception classes for SSE/AVX instructions.
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (21 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 22/62] target/i386: Fix and add some comments next to SSE/AVX instructions Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 24/62] target/i386: Fix exception classes for MOVNTPS/MOVNTPD Michael Tokarev
` (38 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Ricky Zhou, Paolo Bonzini, Michael Tokarev
From: Ricky Zhou <ricky@rzhou.org>
Fix the exception classes for some SSE/AVX instructions to match what is
documented in the Intel manual.
These changes are expected to have no functional effect on the behavior
that qemu implements (primarily >= 16-byte memory alignment checks). For
instance, since qemu does not implement the AC flag, there is no
difference in behavior between Exception Classes 4 and 5 for
instructions where the SSE version only takes <16 byte memory operands.
Message-Id: <20230501111428.95998-2-ricky@rzhou.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit cab529b0dc15746b270e87d77e1dd12c6216807c)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index 38eddd1adb..8c477c1bab 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -237,7 +237,7 @@ static void decode_group14(DisasContext *s, CPUX86State *env, X86OpEntry *entry,
static void decode_0F6F(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b)
{
static const X86OpEntry opcodes_0F6F[4] = {
- X86_OP_ENTRY3(MOVDQ, P,q, None,None, Q,q, vex1 mmx), /* movq */
+ X86_OP_ENTRY3(MOVDQ, P,q, None,None, Q,q, vex5 mmx), /* movq */
X86_OP_ENTRY3(MOVDQ, V,x, None,None, W,x, vex1), /* movdqa */
X86_OP_ENTRY3(MOVDQ, V,x, None,None, W,x, vex4_unal), /* movdqu */
{},
@@ -306,7 +306,7 @@ static void decode_0F7E(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
static void decode_0F7F(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b)
{
static const X86OpEntry opcodes_0F7F[4] = {
- X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex1 mmx), /* movq */
+ X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex5 mmx), /* movq */
X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex1), /* movdqa */
X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4_unal), /* movdqu */
{},
@@ -639,15 +639,15 @@ static void decode_0F10(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
static const X86OpEntry opcodes_0F10_reg[4] = {
X86_OP_ENTRY3(MOVDQ, V,x, None,None, W,x, vex4_unal), /* MOVUPS */
X86_OP_ENTRY3(MOVDQ, V,x, None,None, W,x, vex4_unal), /* MOVUPD */
- X86_OP_ENTRY3(VMOVSS, V,x, H,x, W,x, vex4),
- X86_OP_ENTRY3(VMOVLPx, V,x, H,x, W,x, vex4), /* MOVSD */
+ X86_OP_ENTRY3(VMOVSS, V,x, H,x, W,x, vex5),
+ X86_OP_ENTRY3(VMOVLPx, V,x, H,x, W,x, vex5), /* MOVSD */
};
static const X86OpEntry opcodes_0F10_mem[4] = {
X86_OP_ENTRY3(MOVDQ, V,x, None,None, W,x, vex4_unal), /* MOVUPS */
X86_OP_ENTRY3(MOVDQ, V,x, None,None, W,x, vex4_unal), /* MOVUPD */
- X86_OP_ENTRY3(VMOVSS_ld, V,x, H,x, M,ss, vex4),
- X86_OP_ENTRY3(VMOVSD_ld, V,x, H,x, M,sd, vex4),
+ X86_OP_ENTRY3(VMOVSS_ld, V,x, H,x, M,ss, vex5),
+ X86_OP_ENTRY3(VMOVSD_ld, V,x, H,x, M,sd, vex5),
};
if ((get_modrm(s, env) >> 6) == 3) {
@@ -662,15 +662,15 @@ static void decode_0F11(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
static const X86OpEntry opcodes_0F11_reg[4] = {
X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPS */
X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPD */
- X86_OP_ENTRY3(VMOVSS, W,x, H,x, V,x, vex4),
- X86_OP_ENTRY3(VMOVLPx, W,x, H,x, V,q, vex4), /* MOVSD */
+ X86_OP_ENTRY3(VMOVSS, W,x, H,x, V,x, vex5),
+ X86_OP_ENTRY3(VMOVLPx, W,x, H,x, V,q, vex5), /* MOVSD */
};
static const X86OpEntry opcodes_0F11_mem[4] = {
X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPS */
X86_OP_ENTRY3(MOVDQ, W,x, None,None, V,x, vex4), /* MOVUPD */
- X86_OP_ENTRY3(VMOVSS_st, M,ss, None,None, V,x, vex4),
- X86_OP_ENTRY3(VMOVLPx_st, M,sd, None,None, V,x, vex4), /* MOVSD */
+ X86_OP_ENTRY3(VMOVSS_st, M,ss, None,None, V,x, vex5),
+ X86_OP_ENTRY3(VMOVLPx_st, M,sd, None,None, V,x, vex5), /* MOVSD */
};
if ((get_modrm(s, env) >> 6) == 3) {
@@ -687,16 +687,16 @@ static void decode_0F12(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
* Use dq for operand for compatibility with gen_MOVSD and
* to allow VEX128 only.
*/
- X86_OP_ENTRY3(VMOVLPx_ld, V,dq, H,dq, M,q, vex4), /* MOVLPS */
- X86_OP_ENTRY3(VMOVLPx_ld, V,dq, H,dq, M,q, vex4), /* MOVLPD */
+ X86_OP_ENTRY3(VMOVLPx_ld, V,dq, H,dq, M,q, vex5), /* MOVLPS */
+ X86_OP_ENTRY3(VMOVLPx_ld, V,dq, H,dq, M,q, vex5), /* MOVLPD */
X86_OP_ENTRY3(VMOVSLDUP, V,x, None,None, W,x, vex4 cpuid(SSE3)),
- X86_OP_ENTRY3(VMOVDDUP, V,x, None,None, WM,q, vex4 cpuid(SSE3)), /* qq if VEX.256 */
+ X86_OP_ENTRY3(VMOVDDUP, V,x, None,None, WM,q, vex5 cpuid(SSE3)), /* qq if VEX.256 */
};
static const X86OpEntry opcodes_0F12_reg[4] = {
- X86_OP_ENTRY3(VMOVHLPS, V,dq, H,dq, U,dq, vex4),
- X86_OP_ENTRY3(VMOVLPx, W,x, H,x, U,q, vex4), /* MOVLPD */
+ X86_OP_ENTRY3(VMOVHLPS, V,dq, H,dq, U,dq, vex7),
+ X86_OP_ENTRY3(VMOVLPx, W,x, H,x, U,q, vex5), /* MOVLPD */
X86_OP_ENTRY3(VMOVSLDUP, V,x, None,None, U,x, vex4 cpuid(SSE3)),
- X86_OP_ENTRY3(VMOVDDUP, V,x, None,None, U,x, vex4 cpuid(SSE3)),
+ X86_OP_ENTRY3(VMOVDDUP, V,x, None,None, U,x, vex5 cpuid(SSE3)),
};
if ((get_modrm(s, env) >> 6) == 3) {
@@ -716,15 +716,15 @@ static void decode_0F16(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
* Operand 1 technically only reads the low 64 bits, but uses dq so that
* it is easier to check for op0 == op1 in an endianness-neutral manner.
*/
- X86_OP_ENTRY3(VMOVHPx_ld, V,dq, H,dq, M,q, vex4), /* MOVHPS */
- X86_OP_ENTRY3(VMOVHPx_ld, V,dq, H,dq, M,q, vex4), /* MOVHPD */
+ X86_OP_ENTRY3(VMOVHPx_ld, V,dq, H,dq, M,q, vex5), /* MOVHPS */
+ X86_OP_ENTRY3(VMOVHPx_ld, V,dq, H,dq, M,q, vex5), /* MOVHPD */
X86_OP_ENTRY3(VMOVSHDUP, V,x, None,None, W,x, vex4 cpuid(SSE3)),
{},
};
static const X86OpEntry opcodes_0F16_reg[4] = {
/* Same as above, operand 1 could be Hq if it wasn't for big-endian. */
- X86_OP_ENTRY3(VMOVLHPS, V,dq, H,dq, U,q, vex4),
- X86_OP_ENTRY3(VMOVHPx, V,x, H,x, U,x, vex4), /* MOVHPD */
+ X86_OP_ENTRY3(VMOVLHPS, V,dq, H,dq, U,q, vex7),
+ X86_OP_ENTRY3(VMOVHPx, V,x, H,x, U,x, vex5), /* MOVHPD */
X86_OP_ENTRY3(VMOVSHDUP, V,x, None,None, U,x, vex4 cpuid(SSE3)),
{},
};
@@ -824,7 +824,7 @@ static void decode_0FE6(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
static const X86OpEntry opcodes_0FE6[4] = {
{},
X86_OP_ENTRY2(VCVTTPD2DQ, V,x, W,x, vex2),
- X86_OP_ENTRY2(VCVTDQ2PD, V,x, W,x, vex2),
+ X86_OP_ENTRY2(VCVTDQ2PD, V,x, W,x, vex5),
X86_OP_ENTRY2(VCVTPD2DQ, V,x, W,x, vex2),
};
*entry = *decode_by_prefix(s, opcodes_0FE6);
@@ -842,12 +842,12 @@ static const X86OpEntry opcodes_0F[256] = {
[0x10] = X86_OP_GROUP0(0F10),
[0x11] = X86_OP_GROUP0(0F11),
[0x12] = X86_OP_GROUP0(0F12),
- [0x13] = X86_OP_ENTRY3(VMOVLPx_st, M,q, None,None, V,q, vex4 p_00_66),
+ [0x13] = X86_OP_ENTRY3(VMOVLPx_st, M,q, None,None, V,q, vex5 p_00_66),
[0x14] = X86_OP_ENTRY3(VUNPCKLPx, V,x, H,x, W,x, vex4 p_00_66),
[0x15] = X86_OP_ENTRY3(VUNPCKHPx, V,x, H,x, W,x, vex4 p_00_66),
[0x16] = X86_OP_GROUP0(0F16),
/* Incorrectly listed as Mq,Vq in the manual */
- [0x17] = X86_OP_ENTRY3(VMOVHPx_st, M,q, None,None, V,dq, vex4 p_00_66),
+ [0x17] = X86_OP_ENTRY3(VMOVHPx_st, M,q, None,None, V,dq, vex5 p_00_66),
[0x50] = X86_OP_ENTRY3(MOVMSK, G,y, None,None, U,x, vex7 p_00_66),
[0x51] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2), /* sqrtps */
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 24/62] target/i386: Fix exception classes for MOVNTPS/MOVNTPD.
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (22 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 23/62] target/i386: Fix exception classes for " Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 25/62] target/i386: generalize operand size "ph" for use in CVTPS2PD Michael Tokarev
` (37 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Ricky Zhou, Paolo Bonzini, Michael Tokarev
From: Ricky Zhou <ricky@rzhou.org>
Before this change, MOVNTPS and MOVNTPD were labeled as Exception Class
4 (only requiring alignment for legacy SSE instructions). This changes
them to Exception Class 1 (always requiring memory alignment), as
documented in the Intel manual.
Message-Id: <20230501111428.95998-3-ricky@rzhou.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 8bf171c2d126aea6b60b818f1cee7e0e9eef0390)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index 8c477c1bab..8a8d353b32 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -750,8 +750,9 @@ static void decode_0F2A(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
static void decode_0F2B(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b)
{
static const X86OpEntry opcodes_0F2B[4] = {
- X86_OP_ENTRY3(MOVDQ, M,x, None,None, V,x, vex4), /* MOVNTPS */
- X86_OP_ENTRY3(MOVDQ, M,x, None,None, V,x, vex4), /* MOVNTPD */
+ X86_OP_ENTRY3(MOVDQ, M,x, None,None, V,x, vex1), /* MOVNTPS */
+ X86_OP_ENTRY3(MOVDQ, M,x, None,None, V,x, vex1), /* MOVNTPD */
+ /* AMD extensions */
X86_OP_ENTRY3(VMOVSS_st, M,ss, None,None, V,x, vex4 cpuid(SSE4A)), /* MOVNTSS */
X86_OP_ENTRY3(VMOVLPx_st, M,sd, None,None, V,x, vex4 cpuid(SSE4A)), /* MOVNTSD */
};
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 25/62] target/i386: generalize operand size "ph" for use in CVTPS2PD
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (23 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 24/62] target/i386: Fix exception classes for MOVNTPS/MOVNTPD Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 26/62] target/i386: fix memory operand size for CVTPS2PD Michael Tokarev
` (36 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Paolo Bonzini, Michael Tokarev
From: Paolo Bonzini <pbonzini@redhat.com>
CVTPS2PD only loads a half-register for memory, like CVTPH2PS. It can
reuse the "ph" packed half-precision size to load a half-register,
but rename it to "xh" because it is now a variation of "x" (it is not
used only for half-precision values).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit a48b26978a090fe1f3f3e54319902d4ab56a6b3a)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index 8a8d353b32..a894e874bc 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -337,7 +337,7 @@ static const X86OpEntry opcodes_0F38_00toEF[240] = {
[0x07] = X86_OP_ENTRY3(PHSUBSW, V,x, H,x, W,x, vex4 cpuid(SSSE3) mmx avx2_256 p_00_66),
[0x10] = X86_OP_ENTRY2(PBLENDVB, V,x, W,x, vex4 cpuid(SSE41) avx2_256 p_66),
- [0x13] = X86_OP_ENTRY2(VCVTPH2PS, V,x, W,ph, vex11 cpuid(F16C) p_66),
+ [0x13] = X86_OP_ENTRY2(VCVTPH2PS, V,x, W,xh, vex11 cpuid(F16C) p_66),
[0x14] = X86_OP_ENTRY2(BLENDVPS, V,x, W,x, vex4 cpuid(SSE41) p_66),
[0x15] = X86_OP_ENTRY2(BLENDVPD, V,x, W,x, vex4 cpuid(SSE41) p_66),
/* Listed incorrectly as type 4 */
@@ -565,7 +565,7 @@ static const X86OpEntry opcodes_0F3A[256] = {
[0x15] = X86_OP_ENTRY3(PEXTRW, E,w, V,dq, I,b, vex5 cpuid(SSE41) zext0 p_66),
[0x16] = X86_OP_ENTRY3(PEXTR, E,y, V,dq, I,b, vex5 cpuid(SSE41) p_66),
[0x17] = X86_OP_ENTRY3(VEXTRACTPS, E,d, V,dq, I,b, vex5 cpuid(SSE41) p_66),
- [0x1d] = X86_OP_ENTRY3(VCVTPS2PH, W,ph, V,x, I,b, vex11 cpuid(F16C) p_66),
+ [0x1d] = X86_OP_ENTRY3(VCVTPS2PH, W,xh, V,x, I,b, vex11 cpuid(F16C) p_66),
[0x20] = X86_OP_ENTRY4(PINSRB, V,dq, H,dq, E,b, vex5 cpuid(SSE41) zext2 p_66),
[0x21] = X86_OP_GROUP0(VINSERTPS),
@@ -1104,7 +1104,7 @@ static bool decode_op_size(DisasContext *s, X86OpEntry *e, X86OpSize size, MemOp
*ot = s->vex_l ? MO_256 : MO_128;
return true;
- case X86_SIZE_ph: /* SSE/AVX packed half precision */
+ case X86_SIZE_xh: /* SSE/AVX packed half register */
*ot = s->vex_l ? MO_128 : MO_64;
return true;
diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h
index cb6b8bcf67..a542ec1681 100644
--- a/target/i386/tcg/decode-new.h
+++ b/target/i386/tcg/decode-new.h
@@ -92,7 +92,7 @@ typedef enum X86OpSize {
/* Custom */
X86_SIZE_d64,
X86_SIZE_f64,
- X86_SIZE_ph, /* SSE/AVX packed half precision */
+ X86_SIZE_xh, /* SSE/AVX packed half register */
} X86OpSize;
typedef enum X86CPUIDFeature {
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 26/62] target/i386: fix memory operand size for CVTPS2PD
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (24 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 25/62] target/i386: generalize operand size "ph" for use in CVTPS2PD Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 27/62] hw/display/ramfb: plug slight guest-triggerable leak on mode setting Michael Tokarev
` (35 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Paolo Bonzini, Michael Tokarev
From: Paolo Bonzini <pbonzini@redhat.com>
CVTPS2PD only loads a half-register for memory, unlike the other
operations under 0x0F 0x5A. "Unpack" the group into separate
emission functions instead of using gen_unary_fp_sse.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit abd41884c530aa025ada253bf1a5bd0c2b808219)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index a894e874bc..528e2fdfbb 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -805,10 +805,20 @@ static void decode_sse_unary(DisasContext *s, CPUX86State *env, X86OpEntry *entr
case 0x51: entry->gen = gen_VSQRT; break;
case 0x52: entry->gen = gen_VRSQRT; break;
case 0x53: entry->gen = gen_VRCP; break;
- case 0x5A: entry->gen = gen_VCVTfp2fp; break;
}
}
+static void decode_0F5A(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b)
+{
+ static const X86OpEntry opcodes_0F5A[4] = {
+ X86_OP_ENTRY2(VCVTPS2PD, V,x, W,xh, vex2), /* VCVTPS2PD */
+ X86_OP_ENTRY2(VCVTPD2PS, V,x, W,x, vex2), /* VCVTPD2PS */
+ X86_OP_ENTRY3(VCVTSS2SD, V,x, H,x, W,x, vex2_rep3), /* VCVTSS2SD */
+ X86_OP_ENTRY3(VCVTSD2SS, V,x, H,x, W,x, vex2_rep3), /* VCVTSD2SS */
+ };
+ *entry = *decode_by_prefix(s, opcodes_0F5A);
+}
+
static void decode_0F5B(DisasContext *s, CPUX86State *env, X86OpEntry *entry, uint8_t *b)
{
static const X86OpEntry opcodes_0F5B[4] = {
@@ -891,7 +901,7 @@ static const X86OpEntry opcodes_0F[256] = {
[0x58] = X86_OP_ENTRY3(VADD, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
[0x59] = X86_OP_ENTRY3(VMUL, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
- [0x5a] = X86_OP_GROUP3(sse_unary, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2), /* CVTPS2PD */
+ [0x5a] = X86_OP_GROUP0(0F5A),
[0x5b] = X86_OP_GROUP0(0F5B),
[0x5c] = X86_OP_ENTRY3(VSUB, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
[0x5d] = X86_OP_ENTRY3(VMIN, V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index 5d31fce65d..d6a9de8b3d 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -1917,12 +1917,22 @@ static void gen_VCOMI(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
set_cc_op(s, CC_OP_EFLAGS);
}
-static void gen_VCVTfp2fp(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
+static void gen_VCVTPD2PS(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{
- gen_unary_fp_sse(s, env, decode,
- gen_helper_cvtpd2ps_xmm, gen_helper_cvtps2pd_xmm,
- gen_helper_cvtpd2ps_ymm, gen_helper_cvtps2pd_ymm,
- gen_helper_cvtsd2ss, gen_helper_cvtss2sd);
+ if (s->vex_l) {
+ gen_helper_cvtpd2ps_ymm(cpu_env, OP_PTR0, OP_PTR2);
+ } else {
+ gen_helper_cvtpd2ps_xmm(cpu_env, OP_PTR0, OP_PTR2);
+ }
+}
+
+static void gen_VCVTPS2PD(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
+{
+ if (s->vex_l) {
+ gen_helper_cvtps2pd_ymm(cpu_env, OP_PTR0, OP_PTR2);
+ } else {
+ gen_helper_cvtps2pd_xmm(cpu_env, OP_PTR0, OP_PTR2);
+ }
}
static void gen_VCVTPS2PH(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
@@ -1939,6 +1949,16 @@ static void gen_VCVTPS2PH(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec
}
}
+static void gen_VCVTSD2SS(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
+{
+ gen_helper_cvtsd2ss(cpu_env, OP_PTR0, OP_PTR1, OP_PTR2);
+}
+
+static void gen_VCVTSS2SD(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
+{
+ gen_helper_cvtss2sd(cpu_env, OP_PTR0, OP_PTR1, OP_PTR2);
+}
+
static void gen_VCVTSI2Sx(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{
int vec_len = vector_len(s, decode);
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 27/62] hw/display/ramfb: plug slight guest-triggerable leak on mode setting
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (25 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 26/62] target/i386: fix memory operand size for CVTPS2PD Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 28/62] chardev/char-pty: Avoid losing bytes when the other side just (re-)connected Michael Tokarev
` (34 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Laszlo Ersek, Gerd Hoffmann, Marc-André Lureau,
Michael Tokarev
From: Laszlo Ersek <lersek@redhat.com>
The fw_cfg DMA write callback in ramfb prepares a new display surface in
QEMU; this new surface is put to use ("swapped in") upon the next display
update. At that time, the old surface (if any) is released.
If the guest triggers the fw_cfg DMA write callback at least twice between
two adjacent display updates, then the second callback (and further such
callbacks) will leak the previously prepared (but not yet swapped in)
display surface.
The issue can be shown by:
(1) starting QEMU with "-trace displaysurface_free", and
(2) running the following program in the guest UEFI shell:
> #include <Library/ShellCEntryLib.h> // ShellAppMain()
> #include <Library/UefiBootServicesTableLib.h> // gBS
> #include <Protocol/GraphicsOutput.h> // EFI_GRAPHICS_OUTPUT_PROTOCOL
>
> INTN
> EFIAPI
> ShellAppMain (
> IN UINTN Argc,
> IN CHAR16 **Argv
> )
> {
> EFI_STATUS Status;
> VOID *Interface;
> EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
> UINT32 Mode;
>
> Status = gBS->LocateProtocol (
> &gEfiGraphicsOutputProtocolGuid,
> NULL,
> &Interface
> );
> if (EFI_ERROR (Status)) {
> return 1;
> }
>
> Gop = Interface;
>
> Mode = 1;
> for ( ; ;) {
> Status = Gop->SetMode (Gop, Mode);
> if (EFI_ERROR (Status)) {
> break;
> }
>
> Mode = 1 - Mode;
> }
>
> return 1;
> }
The symptom is then that:
- only one trace message appears periodically,
- the time between adjacent messages keeps increasing -- implying that
some list structure (containing the leaked resources) keeps growing,
- the "surface" pointer is ever different.
> 18566@1695127471.449586:displaysurface_free surface=0x7f2fcc09a7c0
> 18566@1695127471.529559:displaysurface_free surface=0x7f2fcc9dac10
> 18566@1695127471.659812:displaysurface_free surface=0x7f2fcc441dd0
> 18566@1695127471.839669:displaysurface_free surface=0x7f2fcc0363d0
> 18566@1695127472.069674:displaysurface_free surface=0x7f2fcc413a80
> 18566@1695127472.349580:displaysurface_free surface=0x7f2fcc09cd00
> 18566@1695127472.679783:displaysurface_free surface=0x7f2fcc1395f0
> 18566@1695127473.059848:displaysurface_free surface=0x7f2fcc1cae50
> 18566@1695127473.489724:displaysurface_free surface=0x7f2fcc42fc50
> 18566@1695127473.969791:displaysurface_free surface=0x7f2fcc45dcc0
> 18566@1695127474.499708:displaysurface_free surface=0x7f2fcc70b9d0
> 18566@1695127475.079769:displaysurface_free surface=0x7f2fcc82acc0
> 18566@1695127475.709941:displaysurface_free surface=0x7f2fcc369c00
> 18566@1695127476.389619:displaysurface_free surface=0x7f2fcc32b910
> 18566@1695127477.119772:displaysurface_free surface=0x7f2fcc0d5a20
> 18566@1695127477.899517:displaysurface_free surface=0x7f2fcc086c40
> 18566@1695127478.729962:displaysurface_free surface=0x7f2fccc72020
> 18566@1695127479.609839:displaysurface_free surface=0x7f2fcc185160
> 18566@1695127480.539688:displaysurface_free surface=0x7f2fcc23a7e0
> 18566@1695127481.519759:displaysurface_free surface=0x7f2fcc3ec870
> 18566@1695127482.549930:displaysurface_free surface=0x7f2fcc634960
> 18566@1695127483.629661:displaysurface_free surface=0x7f2fcc26b140
> 18566@1695127484.759987:displaysurface_free surface=0x7f2fcc321700
> 18566@1695127485.940289:displaysurface_free surface=0x7f2fccaad100
We figured this wasn't a CVE-worthy problem, as only small amounts of
memory were leaked (the framebuffer itself is mapped from guest RAM, QEMU
only allocates administrative structures), plus libvirt restricts QEMU
memory footprint anyway, thus the guest can only DoS itself.
Plug the leak, by releasing the last prepared (not yet swapped in) display
surface, if any, in the fw_cfg DMA write callback.
Regarding the "reproducer", with the fix in place, the log is flooded with
trace messages (one per fw_cfg write), *and* the trace message alternates
between just two "surface" pointer values (i.e., nothing is leaked, the
allocator flip-flops between two objects in effect).
This issue appears to date back to the introducion of ramfb (995b30179bdc,
"hw/display: add ramfb, a simple boot framebuffer living in guest ram",
2018-06-18).
Cc: Gerd Hoffmann <kraxel@redhat.com> (maintainer:ramfb)
Cc: qemu-stable@nongnu.org
Fixes: 995b30179bdc
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20230919131955.27223-1-lersek@redhat.com>
(cherry picked from commit e0288a778473ebd35eac6cc1924faca7d477d241)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/display/ramfb.c b/hw/display/ramfb.c
index 79b9754a58..c2b002d534 100644
--- a/hw/display/ramfb.c
+++ b/hw/display/ramfb.c
@@ -97,6 +97,7 @@ static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len)
s->width = width;
s->height = height;
+ qemu_free_displaysurface(s->ds);
s->ds = surface;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 28/62] chardev/char-pty: Avoid losing bytes when the other side just (re-)connected
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (26 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 27/62] hw/display/ramfb: plug slight guest-triggerable leak on mode setting Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 29/62] linux-user/hppa: Fix struct target_sigcontext layout Michael Tokarev
` (33 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Thomas Huth, Marc Hartmayer,
Daniel P . Berrangé, Michael Tokarev
From: Thomas Huth <thuth@redhat.com>
When starting a guest via libvirt with "virsh start --console ...",
the first second of the console output is missing. This is especially
annoying on s390x that only has a text console by default and no graphical
output - if the bios fails to boot here, the information about what went
wrong is completely lost.
One part of the problem (there is also some things to be done on the
libvirt side) is that QEMU only checks with a 1 second timer whether
the other side of the pty is already connected, so the first second of
the console output is always lost.
This likely used to work better in the past, since the code once checked
for a re-connection during write, but this has been removed in commit
f8278c7d74 ("char-pty: remove the check for connection on write") to avoid
some locking.
To ease the situation here at least a little bit, let's check with g_poll()
whether we could send out the data anyway, even if the connection has not
been marked as "connected" yet. The file descriptor is marked as non-blocking
anyway since commit fac6688a18 ("Do not hang on full PTY"), so this should
not cause any trouble if the other side is not ready for receiving yet.
With this patch applied, I can now successfully see the bios output of
a s390x guest when running it with "virsh start --console" (with a patched
version of virsh that fixes the remaining issues there, too).
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20230816210743.1319018-1-thuth@redhat.com>
(cherry picked from commit 4f7689f0817a717d18cc8aca298990760f27a89b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: use TFR() instead of RETRY_ON_EINTR() before v7.2.0-538-g8b6aa69365)
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index 53f25c6bbd..e6d0b05211 100644
--- a/chardev/char-pty.c
+++ b/chardev/char-pty.c
@@ -108,11 +108,27 @@ static void pty_chr_update_read_handler(Chardev *chr)
static int char_pty_chr_write(Chardev *chr, const uint8_t *buf, int len)
{
PtyChardev *s = PTY_CHARDEV(chr);
+ GPollFD pfd;
+ int rc;
- if (!s->connected) {
- return len;
+ if (s->connected) {
+ return io_channel_send(s->ioc, buf, len);
+ }
+
+ /*
+ * The other side might already be re-connected, but the timer might
+ * not have fired yet. So let's check here whether we can write again:
+ */
+ pfd.fd = QIO_CHANNEL_FILE(s->ioc)->fd;
+ pfd.events = G_IO_OUT;
+ pfd.revents = 0;
+ TFR(rc = g_poll(&pfd, 1, 0));
+ g_assert(rc >= 0);
+ if (!(pfd.revents & G_IO_HUP) && (pfd.revents & G_IO_OUT)) {
+ io_channel_send(s->ioc, buf, len);
}
- return io_channel_send(s->ioc, buf, len);
+
+ return len;
}
static GSource *pty_chr_add_watch(Chardev *chr, GIOCondition cond)
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 29/62] linux-user/hppa: Fix struct target_sigcontext layout
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (27 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 28/62] chardev/char-pty: Avoid losing bytes when the other side just (re-)connected Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 30/62] amd_iommu: Fix APIC address check Michael Tokarev
` (32 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Richard Henderson, Philippe Mathieu-Daudé,
Michael Tokarev
From: Richard Henderson <richard.henderson@linaro.org>
Use abi_ullong not uint64_t so that the alignment of the field
and therefore the layout of the struct is correct.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit 33bc4fa78b06fc4e5fe22e5576811a97707e0cc6)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/linux-user/hppa/signal.c b/linux-user/hppa/signal.c
index bda6e54655..ec5f5412d1 100644
--- a/linux-user/hppa/signal.c
+++ b/linux-user/hppa/signal.c
@@ -25,7 +25,7 @@
struct target_sigcontext {
abi_ulong sc_flags;
abi_ulong sc_gr[32];
- uint64_t sc_fr[32];
+ abi_ullong sc_fr[32];
abi_ulong sc_iasq[2];
abi_ulong sc_iaoq[2];
abi_ulong sc_sar;
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 30/62] amd_iommu: Fix APIC address check
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (28 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 29/62] linux-user/hppa: Fix struct target_sigcontext layout Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:58 ` [Stable-7.2.7 31/62] migration/qmp: Fix crash on setting tls-authz with null Michael Tokarev
` (31 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Akihiko Odaki, Michael S . Tsirkin, Michael Tokarev
From: Akihiko Odaki <akihiko.odaki@daynix.com>
An MSI from I/O APIC may not exactly equal to APIC_DEFAULT_ADDRESS. In
fact, Windows 17763.3650 configures I/O APIC to set the dest_mode bit.
Cover the range assigned to APIC.
Fixes: 577c470f43 ("x86_iommu/amd: Prepare for interrupt remap support")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230921114612.40671-1-akihiko.odaki@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 0114c4513095598cdf1cd8d7dacdfff757628121)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 725f69095b..a20f3e1d50 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -1246,13 +1246,8 @@ static int amdvi_int_remap_msi(AMDVIState *iommu,
return -AMDVI_IR_ERR;
}
- if (origin->address & AMDVI_MSI_ADDR_HI_MASK) {
- trace_amdvi_err("MSI address high 32 bits non-zero when "
- "Interrupt Remapping enabled.");
- return -AMDVI_IR_ERR;
- }
-
- if ((origin->address & AMDVI_MSI_ADDR_LO_MASK) != APIC_DEFAULT_ADDRESS) {
+ if (origin->address < AMDVI_INT_ADDR_FIRST ||
+ origin->address + sizeof(origin->data) > AMDVI_INT_ADDR_LAST + 1) {
trace_amdvi_err("MSI is not from IOAPIC.");
return -AMDVI_IR_ERR;
}
diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h
index 79d38a3e41..210a37dfb1 100644
--- a/hw/i386/amd_iommu.h
+++ b/hw/i386/amd_iommu.h
@@ -210,8 +210,6 @@
#define AMDVI_INT_ADDR_FIRST 0xfee00000
#define AMDVI_INT_ADDR_LAST 0xfeefffff
#define AMDVI_INT_ADDR_SIZE (AMDVI_INT_ADDR_LAST - AMDVI_INT_ADDR_FIRST + 1)
-#define AMDVI_MSI_ADDR_HI_MASK (0xffffffff00000000ULL)
-#define AMDVI_MSI_ADDR_LO_MASK (0x00000000ffffffffULL)
/* SB IOAPIC is always on this device in AMD systems */
#define AMDVI_IOAPIC_SB_DEVID PCI_BUILD_BDF(0, PCI_DEVFN(0x14, 0))
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 31/62] migration/qmp: Fix crash on setting tls-authz with null
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (29 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 30/62] amd_iommu: Fix APIC address check Michael Tokarev
@ 2023-11-09 13:58 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 32/62] hw/audio/es1370: reset current sample counter Michael Tokarev
` (30 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:58 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Peter Xu, Daniel P . Berrangé, Fabiano Rosas,
Philippe Mathieu-Daudé, Juan Quintela, Michael Tokarev
From: Peter Xu <peterx@redhat.com>
QEMU will crash if anyone tries to set tls-authz (which is a type
StrOrNull) with 'null' value. Fix it in the easy way by converting it to
qstring just like the other two tls parameters.
Cc: qemu-stable@nongnu.org # v4.0+
Fixes: d2f1d29b95 ("migration: add support for a "tls-authz" migration parameter")
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20230905162335.235619-2-peterx@redhat.com>
(cherry picked from commit 86dec715a7339fc61c3bdb9715993b277b2089db)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: the function is in m/migration.c, not m/option.c; minor context tweak)
diff --git a/migration/migration.c b/migration/migration.c
index c19fb5cb3e..c8ca7927b4 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1809,20 +1809,25 @@ void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
{
MigrationParameters tmp;
- /* TODO Rewrite "" to null instead */
+ /* TODO Rewrite "" to null instead for all three tls_* parameters */
if (params->has_tls_creds
&& params->tls_creds->type == QTYPE_QNULL) {
qobject_unref(params->tls_creds->u.n);
params->tls_creds->type = QTYPE_QSTRING;
params->tls_creds->u.s = strdup("");
}
- /* TODO Rewrite "" to null instead */
if (params->has_tls_hostname
&& params->tls_hostname->type == QTYPE_QNULL) {
qobject_unref(params->tls_hostname->u.n);
params->tls_hostname->type = QTYPE_QSTRING;
params->tls_hostname->u.s = strdup("");
}
+ if (params->tls_authz
+ && params->tls_authz->type == QTYPE_QNULL) {
+ qobject_unref(params->tls_authz->u.n);
+ params->tls_authz->type = QTYPE_QSTRING;
+ params->tls_authz->u.s = strdup("");
+ }
migrate_params_test_apply(params, &tmp);
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 32/62] hw/audio/es1370: reset current sample counter
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (30 preceding siblings ...)
2023-11-09 13:58 ` [Stable-7.2.7 31/62] migration/qmp: Fix crash on setting tls-authz with null Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 33/62] disas/riscv: Fix the typo of inverted order of pmpaddr13 and pmpaddr14 Michael Tokarev
` (29 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Volker Rümelin, Rene Engel,
Marc-André Lureau, BALATON Zoltan, Michael Tokarev
From: Volker Rümelin <vr_qemu@t-online.de>
Reset the current sample counter when writing the Channel Sample
Count Register. The Linux ens1370 driver and the AROS sb128
driver expect the current sample counter counts down from sample
count to 0 after a write to the Channel Sample Count Register.
Currently the current sample counter starts from 0 after a reset
or the last count when the counter was stopped.
The current sample counter is used to raise an interrupt whenever
a complete buffer was transferred. When the counter starts with a
value lower than the reload value, the interrupt triggeres before
the buffer was completly transferred. This may lead to corrupted
audio streams.
Tested-by: Rene Engel <ReneEngel80@emailn.de>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Tested-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-Id: <20230917065813.6692-1-vr_qemu@t-online.de>
(cherry picked from commit 00e3b29d065f3b88bb3726afbd5c73f8b2bff1b4)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index 6904589814..7032bee2f6 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -503,7 +503,7 @@ static void es1370_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
case ES1370_REG_DAC2_SCOUNT:
case ES1370_REG_ADC_SCOUNT:
d += (addr - ES1370_REG_DAC1_SCOUNT) >> 2;
- d->scount = (val & 0xffff) | (d->scount & ~0xffff);
+ d->scount = (val & 0xffff) << 16 | (val & 0xffff);
ldebug ("chan %td CURR_SAMP_CT %d, SAMP_CT %d\n",
d - &s->chan[0], val >> 16, (val & 0xffff));
break;
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 33/62] disas/riscv: Fix the typo of inverted order of pmpaddr13 and pmpaddr14
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (31 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 32/62] hw/audio/es1370: reset current sample counter Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 34/62] hw/pvrdma: Protect against buggy or malicious guest driver Michael Tokarev
` (28 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Alvin Chang, Alvin Chang, Alistair Francis,
Michael Tokarev
From: Alvin Chang <vivahavey@gmail.com>
Fix the inverted order of pmpaddr13 and pmpaddr14 in csr_name().
Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20230907084500.328-1-alvinga@andestech.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
(cherry picked from commit cffa9954908830276c93b430681f66cc0e599aef)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/disas/riscv.c b/disas/riscv.c
index d216b9c39b..dee4e580a0 100644
--- a/disas/riscv.c
+++ b/disas/riscv.c
@@ -2173,8 +2173,8 @@ static const char *csr_name(int csrno)
case 0x03ba: return "pmpaddr10";
case 0x03bb: return "pmpaddr11";
case 0x03bc: return "pmpaddr12";
- case 0x03bd: return "pmpaddr14";
- case 0x03be: return "pmpaddr13";
+ case 0x03bd: return "pmpaddr13";
+ case 0x03be: return "pmpaddr14";
case 0x03bf: return "pmpaddr15";
case 0x0780: return "mtohost";
case 0x0781: return "mfromhost";
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 34/62] hw/pvrdma: Protect against buggy or malicious guest driver
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (32 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 33/62] disas/riscv: Fix the typo of inverted order of pmpaddr13 and pmpaddr14 Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 35/62] migration: Fix analyze-migration read operation signedness Michael Tokarev
` (27 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Yuval Shaia, Soul Chen, Thomas Huth, Michael Tokarev
From: Yuval Shaia <yuval.shaia.ml@gmail.com>
Guest driver allocates and initialize page tables to be used as a ring
of descriptors for CQ and async events.
The page table that represents the ring, along with the number of pages
in the page table is passed to the device.
Currently our device supports only one page table for a ring.
Let's make sure that the number of page table entries the driver
reports, do not exceeds the one page table size.
Reported-by: Soul Chen <soulchen8650@gmail.com>
Signed-off-by: Yuval Shaia <yuval.shaia.ml@gmail.com>
Fixes: CVE-2023-1544
Message-ID: <20230301142926.18686-1-yuval.shaia.ml@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit 85fc35afa93c7320d1641d344d0c5dfbe341d087)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c
index 4fc6712025..55b338046e 100644
--- a/hw/rdma/vmw/pvrdma_main.c
+++ b/hw/rdma/vmw/pvrdma_main.c
@@ -91,19 +91,33 @@ static int init_dev_ring(PvrdmaRing *ring, PvrdmaRingState **ring_state,
dma_addr_t dir_addr, uint32_t num_pages)
{
uint64_t *dir, *tbl;
- int rc = 0;
+ int max_pages, rc = 0;
if (!num_pages) {
rdma_error_report("Ring pages count must be strictly positive");
return -EINVAL;
}
+ /*
+ * Make sure we can satisfy the requested number of pages in a single
+ * TARGET_PAGE_SIZE sized page table (taking into account that first entry
+ * is reserved for ring-state)
+ */
+ max_pages = TARGET_PAGE_SIZE / sizeof(dma_addr_t) - 1;
+ if (num_pages > max_pages) {
+ rdma_error_report("Maximum pages on a single directory must not exceed %d\n",
+ max_pages);
+ return -EINVAL;
+ }
+
dir = rdma_pci_dma_map(pci_dev, dir_addr, TARGET_PAGE_SIZE);
if (!dir) {
rdma_error_report("Failed to map to page directory (ring %s)", name);
rc = -ENOMEM;
goto out;
}
+
+ /* We support only one page table for a ring */
tbl = rdma_pci_dma_map(pci_dev, dir[0], TARGET_PAGE_SIZE);
if (!tbl) {
rdma_error_report("Failed to map to page table (ring %s)", name);
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 35/62] migration: Fix analyze-migration read operation signedness
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (33 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 34/62] hw/pvrdma: Protect against buggy or malicious guest driver Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 36/62] linux-user/mips: fix abort on integer overflow Michael Tokarev
` (26 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Fabiano Rosas, Juan Quintela, Michael Tokarev
From: Fabiano Rosas <farosas@suse.de>
The migration code uses unsigned values for 16, 32 and 64-bit
operations. Fix the script to do the same.
This was causing an issue when parsing the migration stream generated
on the ppc64 target because one of instance_ids was larger than the
32bit signed maximum:
Traceback (most recent call last):
File "/home/fabiano/kvm/qemu/build/scripts/analyze-migration.py", line 658, in <module>
dump.read(dump_memory = args.memory)
File "/home/fabiano/kvm/qemu/build/scripts/analyze-migration.py", line 592, in read
classdesc = self.section_classes[section_key]
KeyError: ('spapr_iommu', -2147483648)
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231009184326.15777-6-farosas@suse.de>
(cherry picked from commit caea03279e11dfcb0e5a567b81fe7f02ee80af02)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py
index b82a1b0c58..44d306aedc 100755
--- a/scripts/analyze-migration.py
+++ b/scripts/analyze-migration.py
@@ -38,13 +38,13 @@ def __init__(self, filename):
self.file = open(self.filename, "rb")
def read64(self):
- return int.from_bytes(self.file.read(8), byteorder='big', signed=True)
+ return int.from_bytes(self.file.read(8), byteorder='big', signed=False)
def read32(self):
- return int.from_bytes(self.file.read(4), byteorder='big', signed=True)
+ return int.from_bytes(self.file.read(4), byteorder='big', signed=False)
def read16(self):
- return int.from_bytes(self.file.read(2), byteorder='big', signed=True)
+ return int.from_bytes(self.file.read(2), byteorder='big', signed=False)
def read8(self):
return int.from_bytes(self.file.read(1), byteorder='big', signed=True)
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 36/62] linux-user/mips: fix abort on integer overflow
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (34 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 35/62] migration: Fix analyze-migration read operation signedness Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 37/62] linux-user/sh4: Fix crashes on signal delivery Michael Tokarev
` (25 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Mikulas Patocka, Richard Henderson, Michael Tokarev
From: Mikulas Patocka <mpatocka@redhat.com>
QEMU mips userspace emulation crashes with "qemu: unhandled CPU exception
0x15 - aborting" when one of the integer arithmetic instructions detects
an overflow.
This patch fixes it so that it delivers SIGFPE with FPE_INTOVF instead.
Cc: qemu-stable@nongnu.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Message-Id: <3ef979a8-3ee1-eb2d-71f7-d788ff88dd11@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit 6fad9b4bb91dcc824f9c00a36ee843883b58313b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
index 8735e58bad..990b03e727 100644
--- a/linux-user/mips/cpu_loop.c
+++ b/linux-user/mips/cpu_loop.c
@@ -180,7 +180,9 @@ done_syscall:
}
force_sig_fault(TARGET_SIGFPE, si_code, env->active_tc.PC);
break;
-
+ case EXCP_OVERFLOW:
+ force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTOVF, env->active_tc.PC);
+ break;
/* The code below was inspired by the MIPS Linux kernel trap
* handling code in arch/mips/kernel/traps.c.
*/
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 37/62] linux-user/sh4: Fix crashes on signal delivery
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (35 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 36/62] linux-user/mips: fix abort on integer overflow Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 38/62] lasips2: LASI PS/2 devices are not user-createable Michael Tokarev
` (24 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Mikulas Patocka, Yoshinori Sato, Richard Henderson,
Michael Tokarev
From: Mikulas Patocka <mpatocka@redhat.com>
sh4 uses gUSA (general UserSpace Atomicity) to provide atomicity on CPUs
that don't have atomic instructions. A gUSA region that adds 1 to an
atomic variable stored in @R2 looks like this:
4004b6: 03 c7 mova 4004c4 <gusa+0x10>,r0
4004b8: f3 61 mov r15,r1
4004ba: 09 00 nop
4004bc: fa ef mov #-6,r15
4004be: 22 63 mov.l @r2,r3
4004c0: 01 73 add #1,r3
4004c2: 32 22 mov.l r3,@r2
4004c4: 13 6f mov r1,r15
R0 contains a pointer to the end of the gUSA region
R1 contains the saved stack pointer
R15 contains negative length of the gUSA region
When this region is interrupted by a signal, the kernel detects if
R15 >= -128U. If yes, the kernel rolls back PC to the beginning of the
region and restores SP by copying R1 to R15.
The problem happens if we are interrupted by a signal at address 4004c4.
R15 still holds the value -6, but the atomic value was already written by
an instruction at address 4004c2. In this situation we can't undo the
gUSA. The function unwind_gusa does nothing, the signal handler attempts
to push a signal frame to the address -6 and crashes.
This patch fixes it, so that if we are interrupted at the last instruction
in a gUSA region, we copy R1 to R15 to restore the correct stack pointer
and avoid crashing.
There's another bug: if we are interrupted in a delay slot, we save the
address of the instruction in the delay slot. We must save the address of
the previous instruction.
Cc: qemu-stable@nongnu.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Yoshinori Sato <ysato@users.sourcefoege.jp>
Message-Id: <b16389f7-6c62-70b7-59b3-87533c0bcc@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit 3b894b699c9a9c064466e128c18be80a3f2113bc)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c
index c4ba962708..c16c2c2d57 100644
--- a/linux-user/sh4/signal.c
+++ b/linux-user/sh4/signal.c
@@ -104,6 +104,14 @@ static void unwind_gusa(CPUSH4State *regs)
/* Reset the SP to the saved version in R1. */
regs->gregs[15] = regs->gregs[1];
+ } else if (regs->gregs[15] >= -128u && regs->pc == regs->gregs[0]) {
+ /* If we are on the last instruction of a gUSA region, we must reset
+ the SP, otherwise we would be pushing the signal context to
+ invalid memory. */
+ regs->gregs[15] = regs->gregs[1];
+ } else if (regs->flags & TB_FLAG_DELAY_SLOT) {
+ /* If we are in a delay slot, push the previous instruction. */
+ regs->pc -= 2;
}
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 38/62] lasips2: LASI PS/2 devices are not user-createable
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (36 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 37/62] linux-user/sh4: Fix crashes on signal delivery Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 39/62] hw/sd/sdhci: Block Size Register bits [14:12] is lost Michael Tokarev
` (23 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Helge Deller, Michael Tokarev
From: Helge Deller <deller@gmx.de>
Those PS/2 ports are created with the LASI controller when
a 32-bit PA-RISC machine is created.
Mark them not user-createable to avoid showing them in
the qemu device list.
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: qemu-stable@nongnu.org
(cherry picked from commit a1e6a5c46219bada2c7b932748527553b36559ae)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
index ea7c07a2ba..6075121b72 100644
--- a/hw/input/lasips2.c
+++ b/hw/input/lasips2.c
@@ -351,6 +351,11 @@ static void lasips2_port_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ /*
+ * The PS/2 mouse port is integreal part of LASI and can not be
+ * created by users without LASI.
+ */
+ dc->user_creatable = false;
dc->realize = lasips2_port_realize;
}
@@ -397,6 +402,11 @@ static void lasips2_kbd_port_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
LASIPS2PortDeviceClass *lpdc = LASIPS2_PORT_CLASS(klass);
+ /*
+ * The PS/2 keyboard port is integreal part of LASI and can not be
+ * created by users without LASI.
+ */
+ dc->user_creatable = false;
device_class_set_parent_realize(dc, lasips2_kbd_port_realize,
&lpdc->parent_realize);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 39/62] hw/sd/sdhci: Block Size Register bits [14:12] is lost
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (37 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 38/62] lasips2: LASI PS/2 devices are not user-createable Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 40/62] misc/led: LED state is set opposite of what is expected Michael Tokarev
` (22 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Lu Gao, Jianxian Wen, Philippe Mathieu-Daudé,
Philippe Mathieu-Daudé, Michael Tokarev
From: Lu Gao <lu.gao@verisilicon.com>
Block Size Register bits [14:12] is SDMA Buffer Boundary, it is missed
in register write, but it is needed in SDMA transfer. e.g. it will be
used in sdhci_sdma_transfer_multi_blocks to calculate boundary_ variables.
Missing this field will cause wrong operation for different SDMA Buffer
Boundary settings.
Fixes: d7dfca0807 ("hw/sdhci: introduce standard SD host controller")
Fixes: dfba99f17f ("hw/sdhci: Fix DMA Transfer Block Size field")
Signed-off-by: Lu Gao <lu.gao@verisilicon.com>
Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-ID: <20220321055618.4026-1-lu.gao@verisilicon.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit ae5f70baf549925080fcdbc6c1939c98a4a39246)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index 306070c872..ef60badc6b 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -321,6 +321,8 @@ static void sdhci_poweron_reset(DeviceState *dev)
static void sdhci_data_transfer(void *opaque);
+#define BLOCK_SIZE_MASK (4 * KiB - 1)
+
static void sdhci_send_command(SDHCIState *s)
{
SDRequest request;
@@ -371,7 +373,8 @@ static void sdhci_send_command(SDHCIState *s)
sdhci_update_irq(s);
- if (!timeout && s->blksize && (s->cmdreg & SDHC_CMD_DATA_PRESENT)) {
+ if (!timeout && (s->blksize & BLOCK_SIZE_MASK) &&
+ (s->cmdreg & SDHC_CMD_DATA_PRESENT)) {
s->data_count = 0;
sdhci_data_transfer(s);
}
@@ -406,7 +409,6 @@ static void sdhci_end_transfer(SDHCIState *s)
/*
* Programmed i/o data transfer
*/
-#define BLOCK_SIZE_MASK (4 * KiB - 1)
/* Fill host controller's read buffer with BLKSIZE bytes of data from card */
static void sdhci_read_block_from_card(SDHCIState *s)
@@ -1154,7 +1156,8 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
s->sdmasysad = (s->sdmasysad & mask) | value;
MASKED_WRITE(s->sdmasysad, mask, value);
/* Writing to last byte of sdmasysad might trigger transfer */
- if (!(mask & 0xFF000000) && s->blkcnt && s->blksize &&
+ if (!(mask & 0xFF000000) && s->blkcnt &&
+ (s->blksize & BLOCK_SIZE_MASK) &&
SDHC_DMA_TYPE(s->hostctl1) == SDHC_CTRL_SDMA) {
if (s->trnmod & SDHC_TRNS_MULTI) {
sdhci_sdma_transfer_multi_blocks(s);
@@ -1168,7 +1171,11 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
if (!TRANSFERRING_DATA(s->prnsts)) {
uint16_t blksize = s->blksize;
- MASKED_WRITE(s->blksize, mask, extract32(value, 0, 12));
+ /*
+ * [14:12] SDMA Buffer Boundary
+ * [11:00] Transfer Block Size
+ */
+ MASKED_WRITE(s->blksize, mask, extract32(value, 0, 15));
MASKED_WRITE(s->blkcnt, mask >> 16, value >> 16);
/* Limit block size to the maximum buffer size */
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 40/62] misc/led: LED state is set opposite of what is expected
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (38 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 39/62] hw/sd/sdhci: Block Size Register bits [14:12] is lost Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 41/62] tests/migration: Add -fno-stack-protector Michael Tokarev
` (21 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Glenn Miles, Peter Maydell, Andrew Jeffery,
Philippe Mathieu-Daudé, Michael Tokarev
From: Glenn Miles <milesg@linux.vnet.ibm.com>
Testing of the LED state showed that when the LED polarity was
set to GPIO_POLARITY_ACTIVE_LOW and a low logic value was set on
the input GPIO of the LED, the LED was being turn off when it was
expected to be turned on.
Fixes: ddb67f6402 ("hw/misc/led: Allow connecting from GPIO output")
Signed-off-by: Glenn Miles <milesg@linux.vnet.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Message-id: 20231024191945.4135036-1-milesg@linux.vnet.ibm.com
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 6f83dc67168d17856744275e2a0d7a6addf6cfb9)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/misc/led.c b/hw/misc/led.c
index f6d6d68bce..42bb43a39a 100644
--- a/hw/misc/led.c
+++ b/hw/misc/led.c
@@ -63,7 +63,7 @@ static void led_set_state_gpio_handler(void *opaque, int line, int new_state)
LEDState *s = LED(opaque);
assert(line == 0);
- led_set_state(s, !!new_state != s->gpio_active_high);
+ led_set_state(s, !!new_state == s->gpio_active_high);
}
static void led_reset(DeviceState *dev)
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 41/62] tests/migration: Add -fno-stack-protector
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (39 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 40/62] misc/led: LED state is set opposite of what is expected Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 42/62] tests/tcg: " Michael Tokarev
` (20 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Akihiko Odaki, Juan Quintela, Thomas Huth,
Philippe Mathieu-Daudé, Michael Tokarev
From: Akihiko Odaki <akihiko.odaki@daynix.com>
A build of GCC 13.2 will have stack protector enabled by default if it
was configured with --enable-default-ssp option. For such a compiler,
it is necessary to explicitly disable stack protector when linking
without standard libraries.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20230731091042.139159-2-akihiko.odaki@daynix.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit 7a06a8fec9df3b6a0f72e7b37dff0969430aab96)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/tests/migration/s390x/Makefile b/tests/migration/s390x/Makefile
index 6393c3e5b9..6671de2efc 100644
--- a/tests/migration/s390x/Makefile
+++ b/tests/migration/s390x/Makefile
@@ -6,8 +6,8 @@ all: a-b-bios.h
fwdir=../../../pc-bios/s390-ccw
CFLAGS+=-ffreestanding -fno-delete-null-pointer-checks -fPIE -Os \
- -msoft-float -march=z900 -fno-asynchronous-unwind-tables -Wl,-pie \
- -Wl,--build-id=none -nostdlib
+ -msoft-float -march=z900 -fno-asynchronous-unwind-tables \
+ -fno-stack-protector -Wl,-pie -Wl,--build-id=none -nostdlib
a-b-bios.h: s390x.elf
echo "$$__note" > header.tmp
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 42/62] tests/tcg: Add -fno-stack-protector
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (40 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 41/62] tests/migration: Add -fno-stack-protector Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 43/62] qemu-img: rebase: stop when reaching EOF of old backing file Michael Tokarev
` (19 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Akihiko Odaki, Richard Henderson, Alex Bennée,
Michael Tokarev
From: Akihiko Odaki <akihiko.odaki@daynix.com>
A build of GCC 13.2 will have stack protector enabled by default if it
was configured with --enable-default-ssp option. For such a compiler,
it is necessary to explicitly disable stack protector when linking
without standard libraries.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230731091042.139159-3-akihiko.odaki@daynix.com>
[AJB: fix comment string typo]
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20231029145033.592566-3-alex.bennee@linaro.org>
(cherry picked from commit 580731dcc87eb27a2b0dc20ec331f1ce51864c97)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target
index 14bc013181..368a053392 100644
--- a/tests/tcg/Makefile.target
+++ b/tests/tcg/Makefile.target
@@ -123,7 +123,7 @@ else
# For softmmu targets we include a different Makefile fragement as the
# build options for bare programs are usually pretty different. They
# are expected to provide their own build recipes.
-EXTRA_CFLAGS += -ffreestanding
+EXTRA_CFLAGS += -ffreestanding -fno-stack-protector
-include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
-include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index fc8d90ed69..a72578fccb 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -38,7 +38,7 @@ endif
# bti-1 tests the elf notes, so we require special compiler support.
ifneq ($(CROSS_CC_HAS_ARMV8_BTI),)
AARCH64_TESTS += bti-1 bti-3
-bti-1 bti-3: CFLAGS += -mbranch-protection=standard
+bti-1 bti-3: CFLAGS += -fno-stack-protector -mbranch-protection=standard
bti-1 bti-3: LDFLAGS += -nostdlib
endif
# bti-2 tests PROT_BTI, so no special compiler support required.
diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target
index b3b1504a1c..6b69672fcf 100644
--- a/tests/tcg/arm/Makefile.target
+++ b/tests/tcg/arm/Makefile.target
@@ -12,7 +12,7 @@ float_madds: CFLAGS+=-mfpu=neon-vfpv4
# Basic Hello World
ARM_TESTS = hello-arm
-hello-arm: CFLAGS+=-marm -ffreestanding
+hello-arm: CFLAGS+=-marm -ffreestanding -fno-stack-protector
hello-arm: LDFLAGS+=-nostdlib
# IWMXT floating point extensions
diff --git a/tests/tcg/cris/Makefile.target b/tests/tcg/cris/Makefile.target
index 372287bd03..ea1053236f 100644
--- a/tests/tcg/cris/Makefile.target
+++ b/tests/tcg/cris/Makefile.target
@@ -30,7 +30,7 @@ AS = $(CC) -x assembler-with-cpp
LD = $(CC)
# we rely on GCC inline:ing the stuff we tell it to in many places here.
-CFLAGS = -Winline -Wall -g -O2 -static
+CFLAGS = -Winline -Wall -g -O2 -static -fno-stack-protector
NOSTDFLAGS = -nostartfiles -nostdlib
ASFLAGS += -mcpu=v10 -g -Wa,-I,$(SRC_PATH)/tests/tcg/cris/bare
CRT_FILES = crt.o sys.o
diff --git a/tests/tcg/hexagon/Makefile.target b/tests/tcg/hexagon/Makefile.target
index 96a4d7a614..1b2b26e843 100644
--- a/tests/tcg/hexagon/Makefile.target
+++ b/tests/tcg/hexagon/Makefile.target
@@ -19,7 +19,7 @@
EXTRA_RUNS =
CFLAGS += -Wno-incompatible-pointer-types -Wno-undefined-internal
-CFLAGS += -fno-unroll-loops
+CFLAGS += -fno-unroll-loops -fno-stack-protector
HEX_SRC=$(SRC_PATH)/tests/tcg/hexagon
VPATH += $(HEX_SRC)
diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
index bafd8c2180..3aec3bba77 100644
--- a/tests/tcg/i386/Makefile.target
+++ b/tests/tcg/i386/Makefile.target
@@ -35,7 +35,7 @@ run-plugin-test-i386-adcox-%: QEMU_OPTS += -cpu max
#
# hello-i386 is a barebones app
#
-hello-i386: CFLAGS+=-ffreestanding
+hello-i386: CFLAGS+=-ffreestanding -fno-stack-protector
hello-i386: LDFLAGS+=-nostdlib
# test-386 includes a couple of additional objects that need to be
diff --git a/tests/tcg/minilib/Makefile.target b/tests/tcg/minilib/Makefile.target
index c821d2806a..af0bf54be9 100644
--- a/tests/tcg/minilib/Makefile.target
+++ b/tests/tcg/minilib/Makefile.target
@@ -12,7 +12,7 @@ SYSTEM_MINILIB_SRC=$(SRC_PATH)/tests/tcg/minilib
MINILIB_SRCS=$(wildcard $(SYSTEM_MINILIB_SRC)/*.c)
MINILIB_OBJS=$(patsubst $(SYSTEM_MINILIB_SRC)/%.c, %.o, $(MINILIB_SRCS))
-MINILIB_CFLAGS+=-nostdlib -ggdb -O0
+MINILIB_CFLAGS+=-nostdlib -fno-stack-protector -ggdb -O0
MINILIB_INC=-isystem $(SYSTEM_MINILIB_SRC)
.PRECIOUS: $(MINILIB_OBJS)
diff --git a/tests/tcg/mips/Makefile.target b/tests/tcg/mips/Makefile.target
index 1a994d5525..5d17c1706e 100644
--- a/tests/tcg/mips/Makefile.target
+++ b/tests/tcg/mips/Makefile.target
@@ -14,6 +14,6 @@ MIPS_TESTS=hello-mips
TESTS += $(MIPS_TESTS)
-hello-mips: CFLAGS+=-mno-abicalls -fno-PIC -mabi=32
+hello-mips: CFLAGS+=-mno-abicalls -fno-PIC -fno-stack-protector -mabi=32
hello-mips: LDFLAGS+=-nostdlib
endif
diff --git a/tests/tcg/mips/hello-mips.c b/tests/tcg/mips/hello-mips.c
index 4e1cf501af..38e22d00e3 100644
--- a/tests/tcg/mips/hello-mips.c
+++ b/tests/tcg/mips/hello-mips.c
@@ -5,8 +5,8 @@
* http://www.linux-mips.org/wiki/MIPSABIHistory
* http://www.linux.com/howtos/Assembly-HOWTO/mips.shtml
*
-* mipsel-linux-gcc -nostdlib -mno-abicalls -fno-PIC -mabi=32 \
-* -O2 -static -o hello-mips hello-mips.c
+* mipsel-linux-gcc -nostdlib -mno-abicalls -fno-PIC -fno-stack-protector \
+* -mabi=32 -O2 -static -o hello-mips hello-mips.c
*
*/
#define __NR_SYSCALL_BASE 4000
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 43/62] qemu-img: rebase: stop when reaching EOF of old backing file
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (41 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 42/62] tests/tcg: " Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 44/62] qemu-iotests: 024: add rebasing test case for overlay_size > backing_size Michael Tokarev
` (18 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Andrey Drobyshev, Denis V . Lunev, Hanna Czenczek,
Kevin Wolf, Michael Tokarev
From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
In case when we're rebasing within one backing chain, and when target image
is larger than old backing file, bdrv_is_allocated_above() ends up setting
*pnum = 0. As a result, target offset isn't getting incremented, and we
get stuck in an infinite for loop. Let's detect this case and proceed
further down the loop body, as the offsets beyond the old backing size need
to be explicitly zeroed.
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Message-ID: <20230919165804.439110-2-andrey.drobyshev@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 8b097fd6b06ec295faefd4f30f96f8709abc9605)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/qemu-img.c b/qemu-img.c
index a9b3a8103c..2c32d9da4e 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3753,6 +3753,8 @@ static int img_rebase(int argc, char **argv)
}
if (prefix_chain_bs) {
+ uint64_t bytes = n;
+
/*
* If cluster wasn't changed since prefix_chain, we don't need
* to take action
@@ -3765,9 +3767,18 @@ static int img_rebase(int argc, char **argv)
strerror(-ret));
goto out;
}
- if (!ret) {
+ if (!ret && n) {
continue;
}
+ if (!n) {
+ /*
+ * If we've reached EOF of the old backing, it means that
+ * offsets beyond the old backing size were read as zeroes.
+ * Now we will need to explicitly zero the cluster in
+ * order to preserve that state after the rebase.
+ */
+ n = bytes;
+ }
}
/*
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 44/62] qemu-iotests: 024: add rebasing test case for overlay_size > backing_size
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (42 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 43/62] qemu-img: rebase: stop when reaching EOF of old backing file Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 45/62] Revert "linux-user: add more compat ioctl definitions" Michael Tokarev
` (17 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Andrey Drobyshev, Denis V . Lunev, Hanna Czenczek,
Kevin Wolf, Michael Tokarev
From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Before previous commit, rebase was getting infitely stuck in case of
rebasing within the same backing chain and when overlay_size > backing_size.
Let's add this case to the rebasing test 024 to make sure it doesn't
break again.
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Message-ID: <20230919165804.439110-3-andrey.drobyshev@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 827171c3180533f4ad0bc338ea166f401bb5d348)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024
index 25a564a150..98a7c8fd65 100755
--- a/tests/qemu-iotests/024
+++ b/tests/qemu-iotests/024
@@ -199,6 +199,63 @@ echo
# $BASE_OLD and $BASE_NEW)
$QEMU_IMG map "$OVERLAY" | _filter_qemu_img_map
+# Check that rebase within the chain is working when
+# overlay_size > old_backing_size
+#
+# base_new <-- base_old <-- overlay
+#
+# Backing (new): 11 11 11 11 11
+# Backing (old): 22 22 22 22
+# Overlay: -- -- -- -- --
+#
+# As a result, overlay should contain data identical to base_old, with the
+# last cluster remaining unallocated.
+
+echo
+echo "=== Test rebase within one backing chain ==="
+echo
+
+echo "Creating backing chain"
+echo
+
+TEST_IMG=$BASE_NEW _make_test_img $(( CLUSTER_SIZE * 5 ))
+TEST_IMG=$BASE_OLD _make_test_img -b "$BASE_NEW" -F $IMGFMT \
+ $(( CLUSTER_SIZE * 4 ))
+TEST_IMG=$OVERLAY _make_test_img -b "$BASE_OLD" -F $IMGFMT \
+ $(( CLUSTER_SIZE * 5 ))
+
+echo
+echo "Fill backing files with data"
+echo
+
+$QEMU_IO "$BASE_NEW" -c "write -P 0x11 0 $(( CLUSTER_SIZE * 5 ))" \
+ | _filter_qemu_io
+$QEMU_IO "$BASE_OLD" -c "write -P 0x22 0 $(( CLUSTER_SIZE * 4 ))" \
+ | _filter_qemu_io
+
+echo
+echo "Check the last cluster is zeroed in overlay before the rebase"
+echo
+$QEMU_IO "$OVERLAY" -c "read -P 0x00 $(( CLUSTER_SIZE * 4 )) $CLUSTER_SIZE" \
+ | _filter_qemu_io
+
+echo
+echo "Rebase onto another image in the same chain"
+echo
+
+$QEMU_IMG rebase -b "$BASE_NEW" -F $IMGFMT "$OVERLAY"
+
+echo "Verify that data is read the same before and after rebase"
+echo
+
+# Verify the first 4 clusters are still read the same as in the old base
+$QEMU_IO "$OVERLAY" -c "read -P 0x22 0 $(( CLUSTER_SIZE * 4 ))" \
+ | _filter_qemu_io
+# Verify the last cluster still reads as zeroes
+$QEMU_IO "$OVERLAY" -c "read -P 0x00 $(( CLUSTER_SIZE * 4 )) $CLUSTER_SIZE" \
+ | _filter_qemu_io
+
+echo
# success, all done
echo "*** done"
diff --git a/tests/qemu-iotests/024.out b/tests/qemu-iotests/024.out
index 973a5a3711..245fe8b1d1 100644
--- a/tests/qemu-iotests/024.out
+++ b/tests/qemu-iotests/024.out
@@ -171,4 +171,34 @@ read 65536/65536 bytes at offset 196608
Offset Length File
0 0x30000 TEST_DIR/subdir/t.IMGFMT
0x30000 0x10000 TEST_DIR/subdir/t.IMGFMT.base_new
+
+=== Test rebase within one backing chain ===
+
+Creating backing chain
+
+Formatting 'TEST_DIR/subdir/t.IMGFMT.base_new', fmt=IMGFMT size=327680
+Formatting 'TEST_DIR/subdir/t.IMGFMT.base_old', fmt=IMGFMT size=262144 backing_file=TEST_DIR/subdir/t.IMGFMT.base_new backing_fmt=IMGFMT
+Formatting 'TEST_DIR/subdir/t.IMGFMT', fmt=IMGFMT size=327680 backing_file=TEST_DIR/subdir/t.IMGFMT.base_old backing_fmt=IMGFMT
+
+Fill backing files with data
+
+wrote 327680/327680 bytes at offset 0
+320 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 262144/262144 bytes at offset 0
+256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+Check the last cluster is zeroed in overlay before the rebase
+
+read 65536/65536 bytes at offset 262144
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+Rebase onto another image in the same chain
+
+Verify that data is read the same before and after rebase
+
+read 262144/262144 bytes at offset 0
+256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 65536/65536 bytes at offset 262144
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
*** done
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 45/62] Revert "linux-user: add more compat ioctl definitions"
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (43 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 44/62] qemu-iotests: 024: add rebasing test case for overlay_size > backing_size Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 46/62] Revert "linux-user: fix compat with glibc >= 2.36 sys/mount.h" Michael Tokarev
` (16 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Daniel P. Berrangé, Marc-André Lureau,
Laurent Vivier, Michael Tokarev
From: Daniel P. Berrangé <berrange@redhat.com>
This reverts commit c5495f4ecb0cdaaf2e9dddeb48f1689cdb520ca0.
glibc has fixed (in 2.36.9000-40-g774058d729) the problem
that caused a clash when both sys/mount.h annd linux/mount.h
are included, and backported this to the 2.36 stable release
too:
https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
It is saner for QEMU to remove the workaround it applied for
glibc 2.36 and expect distros to ship the 2.36 maint release
with the fix. This avoids needing to add a further workaround
to QEMU to deal with the fact that linux/brtfs.h now also pulls
in linux/mount.h via linux/fs.h since Linux 6.1
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230110174901.2580297-2-berrange@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
(cherry picked from commit 9f0246539ae84a5e21efd1cc4516fc343f08115a)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index cedf22c5b5..7037c51bca 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -111,31 +111,6 @@
#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
#define FS_IOC32_GETVERSION _IOR('v', 1, int)
#define FS_IOC32_SETVERSION _IOW('v', 2, int)
-
-#define BLKGETSIZE64 _IOR(0x12,114,size_t)
-#define BLKDISCARD _IO(0x12,119)
-#define BLKIOMIN _IO(0x12,120)
-#define BLKIOOPT _IO(0x12,121)
-#define BLKALIGNOFF _IO(0x12,122)
-#define BLKPBSZGET _IO(0x12,123)
-#define BLKDISCARDZEROES _IO(0x12,124)
-#define BLKSECDISCARD _IO(0x12,125)
-#define BLKROTATIONAL _IO(0x12,126)
-#define BLKZEROOUT _IO(0x12,127)
-
-#define FIBMAP _IO(0x00,1)
-#define FIGETBSZ _IO(0x00,2)
-
-struct file_clone_range {
- __s64 src_fd;
- __u64 src_offset;
- __u64 src_length;
- __u64 dest_offset;
-};
-
-#define FICLONE _IOW(0x94, 9, int)
-#define FICLONERANGE _IOW(0x94, 13, struct file_clone_range)
-
#else
#include <linux/fs.h>
#endif
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 46/62] Revert "linux-user: fix compat with glibc >= 2.36 sys/mount.h"
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (44 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 45/62] Revert "linux-user: add more compat ioctl definitions" Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 47/62] target/arm: Don't access TCG code when debugging with KVM Michael Tokarev
` (15 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Daniel P. Berrangé, Marc-André Lureau,
Laurent Vivier, Michael Tokarev
From: Daniel P. Berrangé <berrange@redhat.com>
This reverts commit 3cd3df2a9584e6f753bb62a0028bd67124ab5532.
glibc has fixed (in 2.36.9000-40-g774058d729) the problem
that caused a clash when both sys/mount.h annd linux/mount.h
are included, and backported this to the 2.36 stable release
too:
https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
It is saner for QEMU to remove the workaround it applied for
glibc 2.36 and expect distros to ship the 2.36 maint release
with the fix. This avoids needing to add a further workaround
to QEMU to deal with the fact that linux/brtfs.h now also pulls
in linux/mount.h via linux/fs.h since Linux 6.1
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230110174901.2580297-3-berrange@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
(cherry picked from commit 6003159ce18faad4e1bc7bf9c85669019cd4950e)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7037c51bca..aead0f6ac9 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -95,25 +95,7 @@
#include <linux/soundcard.h>
#include <linux/kd.h>
#include <linux/mtio.h>
-
-#ifdef HAVE_SYS_MOUNT_FSCONFIG
-/*
- * glibc >= 2.36 linux/mount.h conflicts with sys/mount.h,
- * which in turn prevents use of linux/fs.h. So we have to
- * define the constants ourselves for now.
- */
-#define FS_IOC_GETFLAGS _IOR('f', 1, long)
-#define FS_IOC_SETFLAGS _IOW('f', 2, long)
-#define FS_IOC_GETVERSION _IOR('v', 1, long)
-#define FS_IOC_SETVERSION _IOW('v', 2, long)
-#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
-#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
-#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
-#define FS_IOC32_GETVERSION _IOR('v', 1, int)
-#define FS_IOC32_SETVERSION _IOW('v', 2, int)
-#else
#include <linux/fs.h>
-#endif
#include <linux/fd.h>
#if defined(CONFIG_FIEMAP)
#include <linux/fiemap.h>
diff --git a/meson.build b/meson.build
index 450c48a9f0..787f91855e 100644
--- a/meson.build
+++ b/meson.build
@@ -2032,8 +2032,6 @@ config_host_data.set('HAVE_OPTRESET',
cc.has_header_symbol('getopt.h', 'optreset'))
config_host_data.set('HAVE_IPPROTO_MPTCP',
cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
-config_host_data.set('HAVE_SYS_MOUNT_FSCONFIG',
- cc.has_header_symbol('sys/mount.h', 'FSCONFIG_SET_FLAG'))
# has_member
config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 47/62] target/arm: Don't access TCG code when debugging with KVM
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (45 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 46/62] Revert "linux-user: fix compat with glibc >= 2.36 sys/mount.h" Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 48/62] target/arm: Don't allow stage 2 page table walks to downgrade to NS Michael Tokarev
` (14 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Fabiano Rosas, Richard Henderson,
Philippe Mathieu-Daudé, Peter Maydell, Michael Tokarev
From: Fabiano Rosas <farosas@suse.de>
When TCG is disabled this part of the code should not be reachable, so
wrap it with an ifdef for now.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 0d3de77a07f4f774f7a9248afa8ea497ad5f2ae5)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: trivial change which makes two subsequent cherry-picks to apply cleanly)
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index 0b16068557..fa013044c1 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -254,6 +254,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
ptw->out_host = NULL;
ptw->out_rw = false;
} else {
+#ifdef CONFIG_TCG
CPUTLBEntryFull *full;
int flags;
@@ -270,6 +271,9 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
ptw->out_rw = full->prot & PAGE_WRITE;
pte_attrs = full->pte_attrs;
pte_secure = full->attrs.secure;
+#else
+ g_assert_not_reached();
+#endif
}
if (regime_is_stage2(s2_mmu_idx)) {
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 48/62] target/arm: Don't allow stage 2 page table walks to downgrade to NS
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (46 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 47/62] target/arm: Don't access TCG code when debugging with KVM Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 49/62] target/arm: Fix handling of SW and NSW bits for stage 2 walks Michael Tokarev
` (13 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Peter Maydell, Richard Henderson,
Philippe Mathieu-Daudé, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
Bit 63 in a Table descriptor is only the NSTable bit for stage 1
translations; in stage 2 it is RES0. We were incorrectly looking at
it all the time.
This causes problems if:
* the stage 2 table descriptor was incorrectly setting the RES0 bit
* we are doing a stage 2 translation in Secure address space for
a NonSecure stage 1 regime -- in this case we would incorrectly
do an immediate downgrade to NonSecure
A bug elsewhere in the code currently prevents us from getting
to the second situation, but when we fix that it will be possible.
Cc: qemu-stable@nongnu.org
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: 20230504135425.2748672-2-peter.maydell@linaro.org
(cherry picked from commit 21a4ab8318ba6f049aac244e237cd1557586e216)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index fa013044c1..e593bc339a 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -1382,17 +1382,18 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw,
descaddrmask &= ~indexmask_grainsize;
/*
- * Secure accesses start with the page table in secure memory and
+ * Secure stage 1 accesses start with the page table in secure memory and
* can be downgraded to non-secure at any step. Non-secure accesses
* remain non-secure. We implement this by just ORing in the NSTable/NS
* bits at each step.
+ * Stage 2 never gets this kind of downgrade.
*/
tableattrs = is_secure ? 0 : (1 << 4);
next_level:
descaddr |= (address >> (stride * (4 - level))) & indexmask;
descaddr &= ~7ULL;
- nstable = extract32(tableattrs, 4, 1);
+ nstable = !regime_is_stage2(mmu_idx) && extract32(tableattrs, 4, 1);
if (nstable) {
/*
* Stage2_S -> Stage2 or Phys_S -> Phys_NS
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 49/62] target/arm: Fix handling of SW and NSW bits for stage 2 walks
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (47 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 48/62] target/arm: Don't allow stage 2 page table walks to downgrade to NS Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 50/62] target/arm: Correctly propagate stage 1 BTI guarded bit in a two-stage walk Michael Tokarev
` (12 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Peter Maydell, Richard Henderson, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
We currently don't correctly handle the VSTCR_EL2.SW and VTCR_EL2.NSW
configuration bits. These allow configuration of whether the stage 2
page table walks for Secure IPA and NonSecure IPA should do their
descriptor reads from Secure or NonSecure physical addresses. (This
is separate from how the translation table base address and other
parameters are set: an NS IPA always uses VTTBR_EL2 and VTCR_EL2
for its base address and walk parameters, regardless of the NSW bit,
and similarly for Secure.)
Provide a new function ptw_idx_for_stage_2() which returns the
MMU index to use for descriptor reads, and use it to set up
the .in_ptw_idx wherever we call get_phys_addr_lpae().
For a stage 2 walk, wherever we call get_phys_addr_lpae():
* .in_ptw_idx should be ptw_idx_for_stage_2() of the .in_mmu_idx
* .in_secure should be true if .in_mmu_idx is Stage2_S
This allows us to correct S1_ptw_translate() so that it consistently
always sets its (out_secure, out_phys) to the result it gets from the
S2 walk (either by calling get_phys_addr_lpae() or by TLB lookup).
This makes better conceptual sense because the S2 walk should return
us an (address space, address) tuple, not an address that we then
randomly assign to S or NS.
Our previous handling of SW and NSW was broken, so guest code
trying to use these bits to put the s2 page tables in the "other"
address space wouldn't work correctly.
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1600
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20230504135425.2748672-3-peter.maydell@linaro.org
(cherry picked from commit fcc0b0418fff655f20fd0cf86a1bbdc41fd2e7c6)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index e593bc339a..97c85f3c95 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -103,6 +103,37 @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env)
return stage_1_mmu_idx(arm_mmu_idx(env));
}
+/*
+ * Return where we should do ptw loads from for a stage 2 walk.
+ * This depends on whether the address we are looking up is a
+ * Secure IPA or a NonSecure IPA, which we know from whether this is
+ * Stage2 or Stage2_S.
+ * If this is the Secure EL1&0 regime we need to check the NSW and SW bits.
+ */
+static ARMMMUIdx ptw_idx_for_stage_2(CPUARMState *env, ARMMMUIdx stage2idx)
+{
+ bool s2walk_secure;
+
+ /*
+ * We're OK to check the current state of the CPU here because
+ * (1) we always invalidate all TLBs when the SCR_EL3.NS bit changes
+ * (2) there's no way to do a lookup that cares about Stage 2 for a
+ * different security state to the current one for AArch64, and AArch32
+ * never has a secure EL2. (AArch32 ATS12NSO[UP][RW] allow EL3 to do
+ * an NS stage 1+2 lookup while the NS bit is 0.)
+ */
+ if (!arm_is_secure_below_el3(env) || !arm_el_is_aa64(env, 3)) {
+ return ARMMMUIdx_Phys_NS;
+ }
+ if (stage2idx == ARMMMUIdx_Stage2_S) {
+ s2walk_secure = !(env->cp15.vstcr_el2 & VSTCR_SW);
+ } else {
+ s2walk_secure = !(env->cp15.vtcr_el2 & VTCR_NSW);
+ }
+ return s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
+
+}
+
static bool regime_translation_big_endian(CPUARMState *env, ARMMMUIdx mmu_idx)
{
return (regime_sctlr(env, mmu_idx) & SCTLR_EE) != 0;
@@ -220,7 +251,6 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx;
uint8_t pte_attrs;
- bool pte_secure;
ptw->out_virt = addr;
@@ -232,8 +262,8 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
if (regime_is_stage2(s2_mmu_idx)) {
S1Translate s2ptw = {
.in_mmu_idx = s2_mmu_idx,
- .in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS,
- .in_secure = is_secure,
+ .in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx),
+ .in_secure = s2_mmu_idx == ARMMMUIdx_Stage2_S,
.in_debug = true,
};
GetPhysAddrResult s2 = { };
@@ -244,12 +274,12 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
}
ptw->out_phys = s2.f.phys_addr;
pte_attrs = s2.cacheattrs.attrs;
- pte_secure = s2.f.attrs.secure;
+ ptw->out_secure = s2.f.attrs.secure;
} else {
/* Regime is physical. */
ptw->out_phys = addr;
pte_attrs = 0;
- pte_secure = is_secure;
+ ptw->out_secure = s2_mmu_idx == ARMMMUIdx_Phys_S;
}
ptw->out_host = NULL;
ptw->out_rw = false;
@@ -270,7 +300,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
ptw->out_phys = full->phys_addr | (addr & ~TARGET_PAGE_MASK);
ptw->out_rw = full->prot & PAGE_WRITE;
pte_attrs = full->pte_attrs;
- pte_secure = full->attrs.secure;
+ ptw->out_secure = full->attrs.secure;
#else
g_assert_not_reached();
#endif
@@ -293,11 +323,6 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
}
}
- /* Check if page table walk is to secure or non-secure PA space. */
- ptw->out_secure = (is_secure
- && !(pte_secure
- ? env->cp15.vstcr_el2 & VSTCR_SW
- : env->cp15.vtcr_el2 & VTCR_NSW));
ptw->out_be = regime_translation_big_endian(env, mmu_idx);
return true;
@@ -2610,7 +2635,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
hwaddr ipa;
int s1_prot, s1_lgpgsz;
bool is_secure = ptw->in_secure;
- bool ret, ipa_secure, s2walk_secure;
+ bool ret, ipa_secure;
ARMCacheAttrs cacheattrs1;
bool is_el0;
uint64_t hcr;
@@ -2624,20 +2649,11 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
ipa = result->f.phys_addr;
ipa_secure = result->f.attrs.secure;
- if (is_secure) {
- /* Select TCR based on the NS bit from the S1 walk. */
- s2walk_secure = !(ipa_secure
- ? env->cp15.vstcr_el2 & VSTCR_SW
- : env->cp15.vtcr_el2 & VTCR_NSW);
- } else {
- assert(!ipa_secure);
- s2walk_secure = false;
- }
is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0;
- ptw->in_mmu_idx = s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
- ptw->in_ptw_idx = s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
- ptw->in_secure = s2walk_secure;
+ ptw->in_mmu_idx = ipa_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
+ ptw->in_secure = ipa_secure;
+ ptw->in_ptw_idx = ptw_idx_for_stage_2(env, ptw->in_mmu_idx);
/*
* S1 is done, now do S2 translation.
@@ -2729,6 +2745,16 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw,
ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
break;
+ case ARMMMUIdx_Stage2:
+ case ARMMMUIdx_Stage2_S:
+ /*
+ * Second stage lookup uses physical for ptw; whether this is S or
+ * NS may depend on the SW/NSW bits if this is a stage 2 lookup for
+ * the Secure EL2&0 regime.
+ */
+ ptw->in_ptw_idx = ptw_idx_for_stage_2(env, mmu_idx);
+ break;
+
case ARMMMUIdx_E10_0:
s1_mmu_idx = ARMMMUIdx_Stage1_E0;
goto do_twostage;
@@ -2752,7 +2778,7 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw,
/* fall through */
default:
- /* Single stage and second stage uses physical for ptw. */
+ /* Single stage uses physical for ptw. */
ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS;
break;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 50/62] target/arm: Correctly propagate stage 1 BTI guarded bit in a two-stage walk
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (48 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 49/62] target/arm: Fix handling of SW and NSW bits for stage 2 walks Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 51/62] block/nvme: nvme_process_completion() fix bound for cid Michael Tokarev
` (11 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-stable, Peter Maydell, Richard Henderson, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
In a two-stage translation, the result of the BTI guarded bit should
be the guarded bit from the first stage of translation, as there is
no BTI guard information in stage two. Our code tried to do this,
but got it wrong, because we currently have two fields where the GP
bit information might live (ARMCacheAttrs::guarded and
CPUTLBEntryFull::extra::arm::guarded), and we were storing the GP bit
in the latter during the stage 1 walk but trying to copy the former
in combine_cacheattrs().
Remove the duplicated storage, and always use the field in
CPUTLBEntryFull; correctly propagate the stage 1 value to the output
in get_phys_addr_twostage().
Note for stable backports: in v8.0 and earlier the field is named
result->f.guarded, not result->f.extra.arm.guarded.
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1950
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20231031173723.26582-1-peter.maydell@linaro.org
(cherry picked from commit 4c09abeae8704970ff03bf2196973f6bf08ab6f9)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: replace f.extra.arm.guarded -> f.guarded due to v8.1.0-1179-ga81fef4b64)
diff --git a/target/arm/internals.h b/target/arm/internals.h
index 161e42d50f..3c7ff51c99 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -1129,7 +1129,6 @@ typedef struct ARMCacheAttrs {
unsigned int attrs:8;
unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */
bool is_s2_format:1;
- bool guarded:1; /* guarded bit of the v8-64 PTE */
} ARMCacheAttrs;
/* Fields that are valid upon success. */
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index 97c85f3c95..be0cc3e347 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -2635,7 +2635,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
hwaddr ipa;
int s1_prot, s1_lgpgsz;
bool is_secure = ptw->in_secure;
- bool ret, ipa_secure;
+ bool ret, ipa_secure, s1_guarded;
ARMCacheAttrs cacheattrs1;
bool is_el0;
uint64_t hcr;
@@ -2661,6 +2661,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
*/
s1_prot = result->f.prot;
s1_lgpgsz = result->f.lg_page_size;
+ s1_guarded = result->f.guarded;
cacheattrs1 = result->cacheattrs;
memset(result, 0, sizeof(*result));
@@ -2701,6 +2702,9 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
result->cacheattrs = combine_cacheattrs(hcr, cacheattrs1,
result->cacheattrs);
+ /* No BTI GP information in stage 2, we just use the S1 value */
+ result->f.guarded = s1_guarded;
+
/*
* Check if IPA translates to secure or non-secure PA space.
* Note that VSTCR overrides VTCR and {N}SW overrides {N}SA.
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 51/62] block/nvme: nvme_process_completion() fix bound for cid
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (49 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 50/62] target/arm: Correctly propagate stage 1 BTI guarded bit in a two-stage walk Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 52/62] ati-vga: Implement fallback for pixman routines Michael Tokarev
` (10 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Vladimir Sementsov-Ogievskiy, Stefan Hajnoczi,
Maksim Davydov, Peter Maydell, Michael Tokarev
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
NVMeQueuePair::reqs has length NVME_NUM_REQS, which less than
NVME_QUEUE_SIZE by 1.
Fixes: 1086e95da17050 ("block/nvme: switch to a NVMeRequest freelist")
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Maksim Davydov <davydov-max@yandex-team.ru>
Message-id: 20231017125941.810461-5-vsementsov@yandex-team.ru
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit cc8fb0c3ae3c950eb40e969607e17ff16a7519ac)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/block/nvme.c b/block/nvme.c
index 656624c585..14d01a5ea9 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -419,9 +419,10 @@ static bool nvme_process_completion(NVMeQueuePair *q)
q->cq_phase = !q->cq_phase;
}
cid = le16_to_cpu(c->cid);
- if (cid == 0 || cid > NVME_QUEUE_SIZE) {
- warn_report("NVMe: Unexpected CID in completion queue: %"PRIu32", "
- "queue size: %u", cid, NVME_QUEUE_SIZE);
+ if (cid == 0 || cid > NVME_NUM_REQS) {
+ warn_report("NVMe: Unexpected CID in completion queue: %" PRIu32
+ ", should be within: 1..%u inclusively", cid,
+ NVME_NUM_REQS);
continue;
}
trace_nvme_complete_command(s, q->index, cid);
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 52/62] ati-vga: Implement fallback for pixman routines
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (50 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 51/62] block/nvme: nvme_process_completion() fix bound for cid Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 53/62] ui/gtk: force realization of drawing area Michael Tokarev
` (9 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, BALATON Zoltan, Marc-André Lureau,
Michael Tokarev
From: BALATON Zoltan <balaton@eik.bme.hu>
Pixman routines can fail if no implementation is available and it will
become optional soon so add fallbacks when pixman does not work.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <ed0fba3f74e48143f02228b83bf8796ca49f3e7d.1698871239.git.balaton@eik.bme.hu>
(cherry picked from commit 08730ee0cc01c3fceb907a93436d15170a7556c4)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/display/ati.c b/hw/display/ati.c
index 6e38e00502..4f3bebcfd3 100644
--- a/hw/display/ati.c
+++ b/hw/display/ati.c
@@ -1014,6 +1014,7 @@ static Property ati_vga_properties[] = {
DEFINE_PROP_UINT16("x-device-id", ATIVGAState, dev_id,
PCI_DEVICE_ID_ATI_RAGE128_PF),
DEFINE_PROP_BOOL("guest_hwcursor", ATIVGAState, cursor_guest_mode, false),
+ DEFINE_PROP_UINT8("x-pixman", ATIVGAState, use_pixman, 3),
DEFINE_PROP_END_OF_LIST()
};
@@ -1035,11 +1036,18 @@ static void ati_vga_class_init(ObjectClass *klass, void *data)
k->exit = ati_vga_exit;
}
+static void ati_vga_init(Object *o)
+{
+ object_property_set_description(o, "x-pixman", "Use pixman for: "
+ "1: fill, 2: blit");
+}
+
static const TypeInfo ati_vga_info = {
.name = TYPE_ATI_VGA,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(ATIVGAState),
.class_init = ati_vga_class_init,
+ .instance_init = ati_vga_init,
.interfaces = (InterfaceInfo[]) {
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
{ },
diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c
index 7d786653e8..0e6b8e4367 100644
--- a/hw/display/ati_2d.c
+++ b/hw/display/ati_2d.c
@@ -92,6 +92,7 @@ void ati_2d_blt(ATIVGAState *s)
switch (s->regs.dp_mix & GMC_ROP3_MASK) {
case ROP3_SRCCOPY:
{
+ bool fallback = false;
unsigned src_x = (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ?
s->regs.src_x : s->regs.src_x + 1 - s->regs.dst_width);
unsigned src_y = (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ?
@@ -122,27 +123,50 @@ void ati_2d_blt(ATIVGAState *s)
src_bits, dst_bits, src_stride, dst_stride, bpp, bpp,
src_x, src_y, dst_x, dst_y,
s->regs.dst_width, s->regs.dst_height);
- if (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT &&
+ if ((s->use_pixman & BIT(1)) &&
+ s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT &&
s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM) {
- pixman_blt((uint32_t *)src_bits, (uint32_t *)dst_bits,
- src_stride, dst_stride, bpp, bpp,
- src_x, src_y, dst_x, dst_y,
- s->regs.dst_width, s->regs.dst_height);
- } else {
+ fallback = !pixman_blt((uint32_t *)src_bits, (uint32_t *)dst_bits,
+ src_stride, dst_stride, bpp, bpp,
+ src_x, src_y, dst_x, dst_y,
+ s->regs.dst_width, s->regs.dst_height);
+ } else if (s->use_pixman & BIT(1)) {
/* FIXME: We only really need a temporary if src and dst overlap */
int llb = s->regs.dst_width * (bpp / 8);
int tmp_stride = DIV_ROUND_UP(llb, sizeof(uint32_t));
uint32_t *tmp = g_malloc(tmp_stride * sizeof(uint32_t) *
s->regs.dst_height);
- pixman_blt((uint32_t *)src_bits, tmp,
- src_stride, tmp_stride, bpp, bpp,
- src_x, src_y, 0, 0,
- s->regs.dst_width, s->regs.dst_height);
- pixman_blt(tmp, (uint32_t *)dst_bits,
- tmp_stride, dst_stride, bpp, bpp,
- 0, 0, dst_x, dst_y,
- s->regs.dst_width, s->regs.dst_height);
+ fallback = !pixman_blt((uint32_t *)src_bits, tmp,
+ src_stride, tmp_stride, bpp, bpp,
+ src_x, src_y, 0, 0,
+ s->regs.dst_width, s->regs.dst_height);
+ if (!fallback) {
+ fallback = !pixman_blt(tmp, (uint32_t *)dst_bits,
+ tmp_stride, dst_stride, bpp, bpp,
+ 0, 0, dst_x, dst_y,
+ s->regs.dst_width, s->regs.dst_height);
+ }
g_free(tmp);
+ } else {
+ fallback = true;
+ }
+ if (fallback) {
+ unsigned int y, i, j, bypp = bpp / 8;
+ unsigned int src_pitch = src_stride * sizeof(uint32_t);
+ unsigned int dst_pitch = dst_stride * sizeof(uint32_t);
+
+ for (y = 0; y < s->regs.dst_height; y++) {
+ i = dst_x * bypp;
+ j = src_x * bypp;
+ if (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM) {
+ i += (dst_y + y) * dst_pitch;
+ j += (src_y + y) * src_pitch;
+ } else {
+ i += (dst_y + s->regs.dst_height - 1 - y) * dst_pitch;
+ j += (src_y + s->regs.dst_height - 1 - y) * src_pitch;
+ }
+ memmove(&dst_bits[i], &src_bits[j], s->regs.dst_width * bypp);
+ }
}
if (dst_bits >= s->vga.vram_ptr + s->vga.vbe_start_addr &&
dst_bits < s->vga.vram_ptr + s->vga.vbe_start_addr +
@@ -180,14 +204,21 @@ void ati_2d_blt(ATIVGAState *s)
dst_stride /= sizeof(uint32_t);
DPRINTF("pixman_fill(%p, %d, %d, %d, %d, %d, %d, %x)\n",
- dst_bits, dst_stride, bpp,
- dst_x, dst_y,
- s->regs.dst_width, s->regs.dst_height,
- filler);
- pixman_fill((uint32_t *)dst_bits, dst_stride, bpp,
- dst_x, dst_y,
- s->regs.dst_width, s->regs.dst_height,
- filler);
+ dst_bits, dst_stride, bpp, dst_x, dst_y,
+ s->regs.dst_width, s->regs.dst_height, filler);
+ if (!(s->use_pixman & BIT(0)) ||
+ !pixman_fill((uint32_t *)dst_bits, dst_stride, bpp, dst_x, dst_y,
+ s->regs.dst_width, s->regs.dst_height, filler)) {
+ /* fallback when pixman failed or we don't want to call it */
+ unsigned int x, y, i, bypp = bpp / 8;
+ unsigned int dst_pitch = dst_stride * sizeof(uint32_t);
+ for (y = 0; y < s->regs.dst_height; y++) {
+ i = dst_x * bypp + (dst_y + y) * dst_pitch;
+ for (x = 0; x < s->regs.dst_width; x++, i += bypp) {
+ stn_he_p(&dst_bits[i], bypp, filler);
+ }
+ }
+ }
if (dst_bits >= s->vga.vram_ptr + s->vga.vbe_start_addr &&
dst_bits < s->vga.vram_ptr + s->vga.vbe_start_addr +
s->vga.vbe_regs[VBE_DISPI_INDEX_YRES] * s->vga.vbe_line_offset) {
diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h
index 8acb9c7466..055aa2d140 100644
--- a/hw/display/ati_int.h
+++ b/hw/display/ati_int.h
@@ -89,6 +89,7 @@ struct ATIVGAState {
char *model;
uint16_t dev_id;
uint8_t mode;
+ uint8_t use_pixman;
bool cursor_guest_mode;
uint16_t cursor_size;
uint32_t cursor_offset;
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 53/62] ui/gtk: force realization of drawing area
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (51 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 52/62] ati-vga: Implement fallback for pixman routines Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 54/62] ui/gtk-egl: apply scale factor when calculating window's dimension Michael Tokarev
` (8 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Marc-André Lureau, Antonio Caggiano,
Michael Tokarev
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Fixes the GL context creation from a widget that isn't yet realized (in
a hidden tab for example).
Resolves:
https://gitlab.com/qemu-project/qemu/-/issues/1727
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Antonio Caggiano <quic_acaggian@quicinc.com>
Message-Id: <20231017111642.1155545-1-marcandre.lureau@redhat.com>
(cherry picked from commit 565f85a9c293818a91a3d3414311303de7e00cec)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/ui/gtk.c b/ui/gtk.c
index e681e8c319..283c41a1a1 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2317,6 +2317,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
GdkDisplay *window_display;
GtkIconTheme *theme;
char *dir;
+ int idx;
if (!gtkinit) {
fprintf(stderr, "gtk initialization failed\n");
@@ -2379,6 +2380,15 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
+
+ for (idx = 0;; idx++) {
+ QemuConsole *con = qemu_console_lookup_by_index(idx);
+ if (!con) {
+ break;
+ }
+ gtk_widget_realize(s->vc[idx].gfx.drawing_area);
+ }
+
if (opts->u.gtk.has_show_menubar &&
!opts->u.gtk.show_menubar) {
gtk_widget_hide(s->menu_bar);
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 54/62] ui/gtk-egl: apply scale factor when calculating window's dimension
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (52 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 53/62] ui/gtk: force realization of drawing area Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 55/62] ui/gtk-egl: Check EGLSurface before doing scanout Michael Tokarev
` (7 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Dongwon Kim, Marc-André Lureau, Michael Tokarev
From: Dongwon Kim <dongwon.kim@intel.com>
Scale factor needs to be applied when calculating width/height of the
GTK windows.
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20231012222643.13996-1-dongwon.kim@intel.com>
(cherry picked from commit 47fd6ab1e334962890bc3e8d2e32857f6594e1c1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index e99e3b0d8c..52c6246a33 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -66,15 +66,16 @@ void gd_egl_draw(VirtualConsole *vc)
#ifdef CONFIG_GBM
QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf;
#endif
- int ww, wh;
+ int ww, wh, ws;
if (!vc->gfx.gls) {
return;
}
window = gtk_widget_get_window(vc->gfx.drawing_area);
- ww = gdk_window_get_width(window);
- wh = gdk_window_get_height(window);
+ ws = gdk_window_get_scale_factor(window);
+ ww = gdk_window_get_width(window) * ws;
+ wh = gdk_window_get_height(window) * ws;
if (vc->gfx.scanout_mode) {
#ifdef CONFIG_GBM
@@ -300,7 +301,7 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
{
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
GdkWindow *window;
- int ww, wh;
+ int ww, wh, ws;
if (!vc->gfx.scanout_mode) {
return;
@@ -313,8 +314,9 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
vc->gfx.esurface, vc->gfx.ectx);
window = gtk_widget_get_window(vc->gfx.drawing_area);
- ww = gdk_window_get_width(window);
- wh = gdk_window_get_height(window);
+ ws = gdk_window_get_scale_factor(window);
+ ww = gdk_window_get_width(window) * ws;
+ wh = gdk_window_get_height(window) * ws;
egl_fb_setup_default(&vc->gfx.win_fb, ww, wh);
if (vc->gfx.cursor_fb.texture) {
egl_texture_blit(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.guest_fb,
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 55/62] ui/gtk-egl: Check EGLSurface before doing scanout
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (53 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 54/62] ui/gtk-egl: apply scale factor when calculating window's dimension Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 56/62] target/mips: Fix MSA BZ/BNZ opcodes displacement Michael Tokarev
` (6 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Antonio Caggiano, Marc-André Lureau,
Michael Tokarev
From: Antonio Caggiano <quic_acaggian@quicinc.com>
The first time gd_egl_scanout_texture() is called, there's a possibility
that the GTK drawing area might not be realized yet, in which case its
associated GdkWindow is NULL. This means gd_egl_init() was also skipped
and the EGLContext and EGLSurface stored in the VirtualGfxConsole are
not valid yet.
Continuing with the scanout in this conditions would result in hitting
an assert in libepoxy: "Couldn't find current GLX or EGL context".
A possible workaround is to just ignore the scanout request, giving the
the GTK drawing area some time to finish its realization. At that point,
the gd_egl_init() will succeed and the EGLContext and EGLSurface stored
in the VirtualGfxConsole will be valid.
Signed-off-by: Antonio Caggiano <quic_acaggian@quicinc.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20231016123215.2699269-1-quic_acaggian@quicinc.com>
(cherry picked from commit 6f189a08c1b0085808af1bfbf4567f0da193ecc1)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 52c6246a33..17755b1185 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -234,12 +234,19 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
vc->gfx.h = h;
vc->gfx.y0_top = backing_y_0_top;
- eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
- vc->gfx.esurface, vc->gfx.ectx);
+ if (!vc->gfx.esurface) {
+ gd_egl_init(vc);
+ if (!vc->gfx.esurface) {
+ return;
+ }
- gtk_egl_set_scanout_mode(vc, true);
- egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
- backing_id, false);
+ eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
+ vc->gfx.esurface, vc->gfx.ectx);
+
+ gtk_egl_set_scanout_mode(vc, true);
+ egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
+ backing_id, false);
+ }
}
void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 56/62] target/mips: Fix MSA BZ/BNZ opcodes displacement
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (54 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 55/62] ui/gtk-egl: Check EGLSurface before doing scanout Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 57/62] target/mips: Fix TX79 LQ/SQ opcodes Michael Tokarev
` (5 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Philippe Mathieu-Daudé, Sergey Evlashev,
Richard Henderson, Michael Tokarev
From: Philippe Mathieu-Daudé <philmd@linaro.org>
The PC offset is *signed*.
Cc: qemu-stable@nongnu.org
Reported-by: Sergey Evlashev <vectorchiefrocks@gmail.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1624
Fixes: c7a9ef7517 ("target/mips: Introduce decode tree bindings for MSA ASE")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230914085807.12241-1-philmd@linaro.org>
(cherry picked from commit 04591b3ddd9a96b9298a1dd437a6464ab55e62ee)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/mips/tcg/msa.decode b/target/mips/tcg/msa.decode
index 9575289195..4410e2a02e 100644
--- a/target/mips/tcg/msa.decode
+++ b/target/mips/tcg/msa.decode
@@ -31,8 +31,8 @@
@lsa ...... rs:5 rt:5 rd:5 ... sa:2 ...... &r
@ldst ...... sa:s10 ws:5 wd:5 .... df:2 &msa_i
-@bz_v ...... ... .. wt:5 sa:16 &msa_bz df=3
-@bz ...... ... df:2 wt:5 sa:16 &msa_bz
+@bz_v ...... ... .. wt:5 sa:s16 &msa_bz df=3
+@bz ...... ... df:2 wt:5 sa:s16 &msa_bz
@elm_df ...... .... ...... ws:5 wd:5 ...... &msa_elm_df df=%elm_df n=%elm_n
@elm ...... .......... ws:5 wd:5 ...... &msa_elm
@vec ...... ..... wt:5 ws:5 wd:5 ...... &msa_r df=0
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 57/62] target/mips: Fix TX79 LQ/SQ opcodes
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (55 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 56/62] target/mips: Fix MSA BZ/BNZ opcodes displacement Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 58/62] hw/ide: reset: cancel async DMA operation before resetting state Michael Tokarev
` (4 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Philippe Mathieu-Daudé, Richard Henderson,
Michael Tokarev
From: Philippe Mathieu-Daudé <philmd@linaro.org>
The base register address offset is *signed*.
Cc: qemu-stable@nongnu.org
Fixes: aaaa82a9f9 ("target/mips/tx79: Introduce LQ opcode (Load Quadword)")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230914090447.12557-1-philmd@linaro.org>
(cherry picked from commit 18f86aecd6a1bea0f78af14587a684ad966d8d3a)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/mips/tcg/tx79.decode b/target/mips/tcg/tx79.decode
index 57d87a2076..578b8c54c0 100644
--- a/target/mips/tcg/tx79.decode
+++ b/target/mips/tcg/tx79.decode
@@ -24,7 +24,7 @@
@rs ...... rs:5 ..... .......... ...... &r sa=0 rt=0 rd=0
@rd ...... .......... rd:5 ..... ...... &r sa=0 rs=0 rt=0
-@ldst ...... base:5 rt:5 offset:16 &i
+@ldst ...... base:5 rt:5 offset:s16 &i
###########################################################################
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 58/62] hw/ide: reset: cancel async DMA operation before resetting state
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (56 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 57/62] target/mips: Fix TX79 LQ/SQ opcodes Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 59/62] tests/qtest: ahci-test: add test exposing reset issue with pending callback Michael Tokarev
` (3 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Fiona Ebner, Philippe Mathieu-Daudé, simon.rowe,
Michael Tokarev
From: Fiona Ebner <f.ebner@proxmox.com>
If there is a pending DMA operation during ide_bus_reset(), the fact
that the IDEState is already reset before the operation is canceled
can be problematic. In particular, ide_dma_cb() might be called and
then use the reset IDEState which contains the signature after the
reset. When used to construct the IO operation this leads to
ide_get_sector() returning 0 and nsector being 1. This is particularly
bad, because a write command will thus destroy the first sector which
often contains a partition table or similar.
Traces showing the unsolicited write happening with IDEState
0x5595af6949d0 being used after reset:
> ahci_port_write ahci(0x5595af6923f0)[0]: port write [reg:PxSCTL] @ 0x2c: 0x00000300
> ahci_reset_port ahci(0x5595af6923f0)[0]: reset port
> ide_reset IDEstate 0x5595af6949d0
> ide_reset IDEstate 0x5595af694da8
> ide_bus_reset_aio aio_cancel
> dma_aio_cancel dbs=0x7f64600089a0
> dma_blk_cb dbs=0x7f64600089a0 ret=0
> dma_complete dbs=0x7f64600089a0 ret=0 cb=0x5595acd40b30
> ahci_populate_sglist ahci(0x5595af6923f0)[0]
> ahci_dma_prepare_buf ahci(0x5595af6923f0)[0]: prepare buf limit=512 prepared=512
> ide_dma_cb IDEState 0x5595af6949d0; sector_num=0 n=1 cmd=DMA WRITE
> dma_blk_io dbs=0x7f6420802010 bs=0x5595ae2c6c30 offset=0 to_dev=1
> dma_blk_cb dbs=0x7f6420802010 ret=0
> (gdb) p *qiov
> $11 = {iov = 0x7f647c76d840, niov = 1, {{nalloc = 1, local_iov = {iov_base = 0x0,
> iov_len = 512}}, {__pad = "\001\000\000\000\000\000\000\000\000\000\000",
> size = 512}}}
> (gdb) bt
> #0 blk_aio_pwritev (blk=0x5595ae2c6c30, offset=0, qiov=0x7f6420802070, flags=0,
> cb=0x5595ace6f0b0 <dma_blk_cb>, opaque=0x7f6420802010)
> at ../block/block-backend.c:1682
> #1 0x00005595ace6f185 in dma_blk_cb (opaque=0x7f6420802010, ret=<optimized out>)
> at ../softmmu/dma-helpers.c:179
> #2 0x00005595ace6f778 in dma_blk_io (ctx=0x5595ae0609f0,
> sg=sg@entry=0x5595af694d00, offset=offset@entry=0, align=align@entry=512,
> io_func=io_func@entry=0x5595ace6ee30 <dma_blk_write_io_func>,
> io_func_opaque=io_func_opaque@entry=0x5595ae2c6c30,
> cb=0x5595acd40b30 <ide_dma_cb>, opaque=0x5595af6949d0,
> dir=DMA_DIRECTION_TO_DEVICE) at ../softmmu/dma-helpers.c:244
> #3 0x00005595ace6f90a in dma_blk_write (blk=0x5595ae2c6c30,
> sg=sg@entry=0x5595af694d00, offset=offset@entry=0, align=align@entry=512,
> cb=cb@entry=0x5595acd40b30 <ide_dma_cb>, opaque=opaque@entry=0x5595af6949d0)
> at ../softmmu/dma-helpers.c:280
> #4 0x00005595acd40e18 in ide_dma_cb (opaque=0x5595af6949d0, ret=<optimized out>)
> at ../hw/ide/core.c:953
> #5 0x00005595ace6f319 in dma_complete (ret=0, dbs=0x7f64600089a0)
> at ../softmmu/dma-helpers.c:107
> #6 dma_blk_cb (opaque=0x7f64600089a0, ret=0) at ../softmmu/dma-helpers.c:127
> #7 0x00005595ad12227d in blk_aio_complete (acb=0x7f6460005b10)
> at ../block/block-backend.c:1527
> #8 blk_aio_complete (acb=0x7f6460005b10) at ../block/block-backend.c:1524
> #9 blk_aio_write_entry (opaque=0x7f6460005b10) at ../block/block-backend.c:1594
> #10 0x00005595ad258cfb in coroutine_trampoline (i0=<optimized out>,
> i1=<optimized out>) at ../util/coroutine-ucontext.c:177
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: simon.rowe@nutanix.com
Message-ID: <20230906130922.142845-1-f.ebner@proxmox.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit 7d7512019fc40c577e2bdd61f114f31a9eb84a8e)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 1477935270..3e97d665d9 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2491,19 +2491,19 @@ static void ide_dummy_transfer_stop(IDEState *s)
void ide_bus_reset(IDEBus *bus)
{
- bus->unit = 0;
- bus->cmd = 0;
- ide_reset(&bus->ifs[0]);
- ide_reset(&bus->ifs[1]);
- ide_clear_hob(bus);
-
- /* pending async DMA */
+ /* pending async DMA - needs the IDEState before it is reset */
if (bus->dma->aiocb) {
trace_ide_bus_reset_aio();
blk_aio_cancel(bus->dma->aiocb);
bus->dma->aiocb = NULL;
}
+ bus->unit = 0;
+ bus->cmd = 0;
+ ide_reset(&bus->ifs[0]);
+ ide_reset(&bus->ifs[1]);
+ ide_clear_hob(bus);
+
/* reset dma provider too */
if (bus->dma->ops->reset) {
bus->dma->ops->reset(bus->dma);
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 59/62] tests/qtest: ahci-test: add test exposing reset issue with pending callback
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (57 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 58/62] hw/ide: reset: cancel async DMA operation before resetting state Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 60/62] target/s390x: Fix LAALG not updating cc_src Michael Tokarev
` (2 subsequent siblings)
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Fiona Ebner, Philippe Mathieu-Daudé,
Michael Tokarev
From: Fiona Ebner <f.ebner@proxmox.com>
Before commit "hw/ide: reset: cancel async DMA operation before
resetting state", this test would fail, because a reset with a
pending write operation would lead to an unsolicited write to the
first sector of the disk.
The test writes a pattern to the beginning of the disk and verifies
that it is still intact after a reset with a pending operation. It
also checks that the pending operation actually completes correctly.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Message-ID: <20230906130922.142845-2-f.ebner@proxmox.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit cc610857bbd3551f4b86ae2299336b5d9aa0db2b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index 66652fed04..388223291f 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -1424,6 +1424,89 @@ static void test_reset(void)
ahci_shutdown(ahci);
}
+static void test_reset_pending_callback(void)
+{
+ AHCIQState *ahci;
+ AHCICommand *cmd;
+ uint8_t port;
+ uint64_t ptr1;
+ uint64_t ptr2;
+
+ int bufsize = 4 * 1024;
+ int speed = bufsize + (bufsize / 2);
+ int offset1 = 0;
+ int offset2 = bufsize / AHCI_SECTOR_SIZE;
+
+ g_autofree unsigned char *tx1 = g_malloc(bufsize);
+ g_autofree unsigned char *tx2 = g_malloc(bufsize);
+ g_autofree unsigned char *rx1 = g_malloc0(bufsize);
+ g_autofree unsigned char *rx2 = g_malloc0(bufsize);
+
+ /* Uses throttling to make test independent of specific environment. */
+ ahci = ahci_boot_and_enable("-drive if=none,id=drive0,file=%s,"
+ "cache=writeback,format=%s,"
+ "throttling.bps-write=%d "
+ "-M q35 "
+ "-device ide-hd,drive=drive0 ",
+ tmp_path, imgfmt, speed);
+
+ port = ahci_port_select(ahci);
+ ahci_port_clear(ahci, port);
+
+ ptr1 = ahci_alloc(ahci, bufsize);
+ ptr2 = ahci_alloc(ahci, bufsize);
+
+ g_assert(ptr1 && ptr2);
+
+ /* Need two different patterns. */
+ do {
+ generate_pattern(tx1, bufsize, AHCI_SECTOR_SIZE);
+ generate_pattern(tx2, bufsize, AHCI_SECTOR_SIZE);
+ } while (memcmp(tx1, tx2, bufsize) == 0);
+
+ qtest_bufwrite(ahci->parent->qts, ptr1, tx1, bufsize);
+ qtest_bufwrite(ahci->parent->qts, ptr2, tx2, bufsize);
+
+ /* Write to beginning of disk to check it wasn't overwritten later. */
+ ahci_guest_io(ahci, port, CMD_WRITE_DMA_EXT, ptr1, bufsize, offset1);
+
+ /* Issue asynchronously to get a pending callback during reset. */
+ cmd = ahci_command_create(CMD_WRITE_DMA_EXT);
+ ahci_command_adjust(cmd, offset2, ptr2, bufsize, 0);
+ ahci_command_commit(ahci, cmd, port);
+ ahci_command_issue_async(ahci, cmd);
+
+ ahci_set(ahci, AHCI_GHC, AHCI_GHC_HR);
+
+ ahci_command_free(cmd);
+
+ /* Wait for throttled write to finish. */
+ sleep(1);
+
+ /* Start again. */
+ ahci_clean_mem(ahci);
+ ahci_pci_enable(ahci);
+ ahci_hba_enable(ahci);
+ port = ahci_port_select(ahci);
+ ahci_port_clear(ahci, port);
+
+ /* Read and verify. */
+ ahci_guest_io(ahci, port, CMD_READ_DMA_EXT, ptr1, bufsize, offset1);
+ qtest_bufread(ahci->parent->qts, ptr1, rx1, bufsize);
+ g_assert_cmphex(memcmp(tx1, rx1, bufsize), ==, 0);
+
+ ahci_guest_io(ahci, port, CMD_READ_DMA_EXT, ptr2, bufsize, offset2);
+ qtest_bufread(ahci->parent->qts, ptr2, rx2, bufsize);
+ g_assert_cmphex(memcmp(tx2, rx2, bufsize), ==, 0);
+
+ ahci_free(ahci, ptr1);
+ ahci_free(ahci, ptr2);
+
+ ahci_clean_mem(ahci);
+
+ ahci_shutdown(ahci);
+}
+
static void test_ncq_simple(void)
{
AHCIQState *ahci;
@@ -1943,7 +2026,8 @@ int main(int argc, char **argv)
qtest_add_func("/ahci/migrate/dma/halted", test_migrate_halted_dma);
qtest_add_func("/ahci/max", test_max);
- qtest_add_func("/ahci/reset", test_reset);
+ qtest_add_func("/ahci/reset/simple", test_reset);
+ qtest_add_func("/ahci/reset/pending_callback", test_reset_pending_callback);
qtest_add_func("/ahci/io/ncq/simple", test_ncq_simple);
qtest_add_func("/ahci/migrate/ncq/simple", test_migrate_ncq);
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 60/62] target/s390x: Fix LAALG not updating cc_src
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (58 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 59/62] tests/qtest: ahci-test: add test exposing reset issue with pending callback Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 61/62] tests/tcg/s390x: Test LAALG with negative cc_src Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 62/62] hw/ide/ahci: trigger either error IRQ or regular IRQ, not both Michael Tokarev
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Ilya Leoshkevich, David Hildenbrand,
Richard Henderson, Thomas Huth, Michael Tokarev
From: Ilya Leoshkevich <iii@linux.ibm.com>
LAALG uses op_laa() and wout_addu64(). The latter expects cc_src to be
set, but the former does not do it. This can lead to assertion failures
if something sets cc_src to neither 0 nor 1 before.
Fix by introducing op_laa_addu64(), which sets cc_src, and using it for
LAALG.
Fixes: 4dba4d6fef61 ("target/s390x: Use atomic operations for LOAD AND OP")
Cc: qemu-stable@nongnu.org
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20231106093605.1349201-4-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit bea402482a8c94389638cbd3d7fe3963fb317f4c)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/s390x/tcg/insn-data.h.inc b/target/s390x/tcg/insn-data.h.inc
index 0e328ea0fd..7c3362d2e7 100644
--- a/target/s390x/tcg/insn-data.h.inc
+++ b/target/s390x/tcg/insn-data.h.inc
@@ -442,7 +442,7 @@
D(0xebe8, LAAG, RSY_a, ILA, r3, a2, new, in2_r1, laa, adds64, MO_TEUQ)
/* LOAD AND ADD LOGICAL */
D(0xebfa, LAAL, RSY_a, ILA, r3_32u, a2, new, in2_r1_32, laa, addu32, MO_TEUL)
- D(0xebea, LAALG, RSY_a, ILA, r3, a2, new, in2_r1, laa, addu64, MO_TEUQ)
+ D(0xebea, LAALG, RSY_a, ILA, r3, a2, new, in2_r1, laa_addu64, addu64, MO_TEUQ)
/* LOAD AND AND */
D(0xebf4, LAN, RSY_a, ILA, r3_32s, a2, new, in2_r1_32, lan, nz32, MO_TESL)
D(0xebe4, LANG, RSY_a, ILA, r3, a2, new, in2_r1, lan, nz64, MO_TEUQ)
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index ff64d6c28f..b0173e968e 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -2809,17 +2809,32 @@ static DisasJumpType op_kxb(DisasContext *s, DisasOps *o)
return DISAS_NEXT;
}
-static DisasJumpType op_laa(DisasContext *s, DisasOps *o)
+static DisasJumpType help_laa(DisasContext *s, DisasOps *o, bool addu64)
{
/* The real output is indeed the original value in memory;
recompute the addition for the computation of CC. */
tcg_gen_atomic_fetch_add_i64(o->in2, o->in2, o->in1, get_mem_index(s),
s->insn->data | MO_ALIGN);
/* However, we need to recompute the addition for setting CC. */
- tcg_gen_add_i64(o->out, o->in1, o->in2);
+ if (addu64) {
+ tcg_gen_movi_i64(cc_src, 0);
+ tcg_gen_add2_i64(o->out, cc_src, o->in1, cc_src, o->in2, cc_src);
+ } else {
+ tcg_gen_add_i64(o->out, o->in1, o->in2);
+ }
return DISAS_NEXT;
}
+static DisasJumpType op_laa(DisasContext *s, DisasOps *o)
+{
+ return help_laa(s, o, false);
+}
+
+static DisasJumpType op_laa_addu64(DisasContext *s, DisasOps *o)
+{
+ return help_laa(s, o, true);
+}
+
static DisasJumpType op_lan(DisasContext *s, DisasOps *o)
{
/* The real output is indeed the original value in memory;
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 61/62] tests/tcg/s390x: Test LAALG with negative cc_src
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (59 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 60/62] target/s390x: Fix LAALG not updating cc_src Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
2023-11-09 13:59 ` [Stable-7.2.7 62/62] hw/ide/ahci: trigger either error IRQ or regular IRQ, not both Michael Tokarev
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Ilya Leoshkevich, Richard Henderson, Thomas Huth,
Michael Tokarev
From: Ilya Leoshkevich <iii@linux.ibm.com>
Add a small test to prevent regressions.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20231106093605.1349201-5-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit ebc14107f1f3ac1db13132cd28cf94adcd38e5d7)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: context fix in tests/tcg/s390x/Makefile.target)
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index cb90d4183d..ea9fa67152 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -24,6 +24,7 @@ TESTS+=trap
TESTS+=signals-s390x
TESTS+=branch-relative-long
TESTS+=noexec
+TESTS+=laalg
Z13_TESTS=vistr
Z13_TESTS+=lcbb
diff --git a/tests/tcg/s390x/laalg.c b/tests/tcg/s390x/laalg.c
new file mode 100644
index 0000000000..797d168bb1
--- /dev/null
+++ b/tests/tcg/s390x/laalg.c
@@ -0,0 +1,27 @@
+/*
+ * Test the LAALG instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ unsigned long cc = 0, op1, op2 = 40, op3 = 2;
+
+ asm("slgfi %[cc],1\n" /* Set cc_src = -1. */
+ "laalg %[op1],%[op3],%[op2]\n"
+ "ipm %[cc]"
+ : [cc] "+r" (cc)
+ , [op1] "=r" (op1)
+ , [op2] "+T" (op2)
+ : [op3] "r" (op3)
+ : "cc");
+
+ assert(cc == 0xffffffff10ffffff);
+ assert(op1 == 40);
+ assert(op2 == 42);
+
+ return EXIT_SUCCESS;
+}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread
* [Stable-7.2.7 62/62] hw/ide/ahci: trigger either error IRQ or regular IRQ, not both
2023-11-09 13:58 [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19 Michael Tokarev
` (60 preceding siblings ...)
2023-11-09 13:59 ` [Stable-7.2.7 61/62] tests/tcg/s390x: Test LAALG with negative cc_src Michael Tokarev
@ 2023-11-09 13:59 ` Michael Tokarev
61 siblings, 0 replies; 63+ messages in thread
From: Michael Tokarev @ 2023-11-09 13:59 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-stable, Niklas Cassel, Philippe Mathieu-Daudé,
Kevin Wolf, Michael Tokarev
From: Niklas Cassel <niklas.cassel@wdc.com>
According to AHCI 1.3.1, 5.3.8.1 RegFIS:Entry, if ERR_STAT is set,
we jump to state ERR:FatalTaskfile, which will raise a TFES IRQ
unconditionally, regardless if the I bit is set in the FIS or not.
Thus, we should never raise a normal IRQ after having sent an error
IRQ.
NOTE: for QEMU platforms that use SeaBIOS, this patch depends on QEMU
commit 784155cdcb02 ("seabios: update submodule to git snapshot"), and
QEMU commit 14f5a7bae4cb ("seabios: update binaries to git snapshot"),
which update SeaBIOS to a version that contains SeaBIOS commit 1281e340
("ahci: handle TFES irq correctly").
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Message-ID: <20231011131220.1992064-1-nks@flawful.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit b523a3d54f3d031a54cd0931cc5d855608e63140)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index c5e79b6e6d..73739567ee 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -896,11 +896,10 @@ static bool ahci_write_fis_d2h(AHCIDevice *ad, bool d2h_fis_i)
pr->tfdata = (ad->port.ifs[0].error << 8) |
ad->port.ifs[0].status;
+ /* TFES IRQ is always raised if ERR_STAT is set, regardless of I bit. */
if (d2h_fis[2] & ERR_STAT) {
ahci_trigger_irq(ad->hba, ad, AHCI_PORT_IRQ_BIT_TFES);
- }
-
- if (d2h_fis_i) {
+ } else if (d2h_fis_i) {
ahci_trigger_irq(ad->hba, ad, AHCI_PORT_IRQ_BIT_DHRS);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 63+ messages in thread