Fix icount accounting.

Replace bitrev8 with revbit8.
 Fixes for set but not used warnings.
 -----BEGIN PGP SIGNATURE-----
 
 iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmD/LQEdHHJpY2hhcmQu
 aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV9RnwgAq3wti4fF3FrSUCQ5
 zsspEi2JIU1dybpxjM9PXqi9uXZiO4ITlCrhmB9o+7DA78/rx/EjoAqFNK5MyPf4
 v1g12LvuuwxwOv6LMPiH5io+Aygbaz8Xk+AJsYr6eMMxh+4zLcyiYg03eBH65IkS
 1HceGon67gYHjIqeb9OJ6R6VgvSwCsZ3J+uAR1f4/BzfwoM/+zxMFiWzwFTJxX1t
 sc7VhX1dZwoVJoCUtL52+7a8kVMFud70aOuE0Uwlwt1nryf1HUHTS26ghF95e/6v
 +QPZEobbfuyt+X97/qiRGYHzYLDrJX1SiBZ3vTIUNoDUDip2Nyt3SncYTXHuEoHy
 SN6vFw==
 =4/cY
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210726' into staging

Fix icount accounting.
Replace bitrev8 with revbit8.
Fixes for set but not used warnings.

# gpg: Signature made Mon 26 Jul 2021 22:45:37 BST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth-gitlab/tags/pull-tcg-20210726:
  tests/unit: Remove unused variable from test_io
  linux-user/syscall: Remove unused variable from execve
  hw/pci-hist/pnv_phb4: Fix typo in pnv_phb4_ioda_write
  hw/ppc/spapr_events: Remove unused variable from check_exception
  hw/audio/adlib: Remove unused variable in adlib_callback
  net/checksum: Remove unused variable in net_checksum_add_iov
  util/selfmap: Discard mapping on error
  accel/tcg: Remove unused variable in cpu_exec
  nbd/server: Mark variable unused in nbd_negotiate_meta_queries
  bitops.h: revert db1ffc32dd ("qemu/bitops.h: add bitrev8 implementation")
  accel/tcg: Remove unnecessary check on icount_extra in cpu_loop_exec_tb()
  accel/tcg: Don't use CF_COUNT_MASK as the max value of icount_decr.u16.low

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2021-07-27 08:35:01 +01:00
commit c08ccd1b53
11 changed files with 30 additions and 64 deletions

View File

@ -834,7 +834,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
/* Ensure global icount has gone forward */
icount_update(cpu);
/* Refill decrementer and continue execution. */
insns_left = MIN(CF_COUNT_MASK, cpu->icount_budget);
insns_left = MIN(0xffff, cpu->icount_budget);
cpu_neg(cpu)->icount_decr.u16.low = insns_left;
cpu->icount_extra = cpu->icount_budget - insns_left;
@ -843,7 +843,9 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
* execute we need to ensure we find/generate a TB with exactly
* insns_left instructions in it.
*/
if (!cpu->icount_extra && insns_left > 0 && insns_left < tb->icount) {
if (insns_left > 0 && insns_left < tb->icount) {
assert(insns_left <= CF_COUNT_MASK);
assert(cpu->icount_extra == 0);
cpu->cflags_next_tb = (tb->cflags & ~CF_COUNT_MASK) | insns_left;
}
#endif
@ -853,7 +855,6 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
int cpu_exec(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
int ret;
SyncClocks sc = { 0 };
@ -887,19 +888,14 @@ int cpu_exec(CPUState *cpu)
* that we support, but is still unfixed in clang:
* https://bugs.llvm.org/show_bug.cgi?id=21183
*
* Reload essential local variables here for those compilers.
* Reload an essential local variable here for those compilers.
* Newer versions of gcc would complain about this code (-Wclobbered),
* so we only perform the workaround for clang.
*/
cpu = current_cpu;
cc = CPU_GET_CLASS(cpu);
#else
/*
* Non-buggy compilers preserve these locals; assert that
* they have the correct value.
*/
/* Non-buggy compilers preserve this; assert the correct value. */
g_assert(cpu == current_cpu);
g_assert(cc == CPU_GET_CLASS(cpu));
#endif
#ifndef CONFIG_SOFTMMU

View File

@ -186,7 +186,7 @@ static int write_audio (AdlibState *s, int samples)
static void adlib_callback (void *opaque, int free)
{
AdlibState *s = opaque;
int samples, net = 0, to_play, written;
int samples, to_play, written;
samples = free >> SHIFT;
if (!(s->active && s->enabled) || !samples) {
@ -219,7 +219,6 @@ static void adlib_callback (void *opaque, int free)
written = write_audio (s, samples);
if (written) {
net += written;
samples -= written;
s->pos = (s->pos + written) % s->samples;
}

View File

@ -334,7 +334,7 @@ static void q800_init(MachineState *machine)
prom = memory_region_get_ram_ptr(dp8393x_prom);
checksum = 0;
for (i = 0; i < 6; i++) {
prom[i] = bitrev8(nd_table[0].macaddr.a[i]);
prom[i] = revbit8(nd_table[0].macaddr.a[i]);
checksum ^= prom[i];
}
prom[7] = 0xff - checksum;

View File

@ -392,7 +392,7 @@ static void pnv_phb4_ioda_write(PnvPHB4 *phb, uint64_t val)
v &= 0xffffffffffff0000ull;
v |= 0x000000000000cfffull & val;
}
*tptr = val;
*tptr = v;
break;
}
case IODA3_TBL_MBT:

View File

@ -934,7 +934,6 @@ static void check_exception(PowerPCCPU *cpu, SpaprMachineState *spapr,
uint32_t nret, target_ulong rets)
{
uint32_t mask, buf, len, event_len;
uint64_t xinfo;
SpaprEventLogEntry *event;
struct rtas_error_log header;
int i;
@ -944,13 +943,9 @@ static void check_exception(PowerPCCPU *cpu, SpaprMachineState *spapr,
return;
}
xinfo = rtas_ld(args, 1);
mask = rtas_ld(args, 2);
buf = rtas_ld(args, 4);
len = rtas_ld(args, 5);
if (nargs == 7) {
xinfo |= (uint64_t)rtas_ld(args, 6) << 32;
}
event = rtas_event_log_dequeue(spapr, mask);
if (!event) {

View File

@ -618,26 +618,4 @@ static inline uint64_t half_unshuffle64(uint64_t x)
return x;
}
/**
* bitrev8:
* @x: 8-bit value to be reversed
*
* Given an input value with bits::
*
* ABCDEFGH
*
* return the value with its bits reversed from left to right::
*
* HGFEDCBA
*
* Returns: the bit-reversed value.
*/
static inline uint8_t bitrev8(uint8_t x)
{
x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa);
x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc);
x = (x >> 4) | (x << 4) ;
return x;
}
#endif

View File

@ -8364,7 +8364,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
abi_ulong guest_envp;
abi_ulong addr;
char **q;
int total_size = 0;
argc = 0;
guest_argp = arg2;
@ -8396,7 +8395,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
total_size += strlen(*q) + 1;
}
*q = NULL;
@ -8408,7 +8406,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
total_size += strlen(*q) + 1;
}
*q = NULL;

View File

@ -973,7 +973,8 @@ static int nbd_negotiate_meta_queries(NBDClient *client,
{
int ret;
g_autofree char *export_name = NULL;
g_autofree bool *bitmaps = NULL;
/* Mark unused to work around https://bugs.llvm.org/show_bug.cgi?id=3888 */
g_autofree G_GNUC_UNUSED bool *bitmaps = NULL;
NBDExportMetaContexts local_meta = {0};
uint32_t nb_queries;
size_t i;

View File

@ -186,12 +186,11 @@ uint32_t
net_checksum_add_iov(const struct iovec *iov, const unsigned int iov_cnt,
uint32_t iov_off, uint32_t size, uint32_t csum_offset)
{
size_t iovec_off, buf_off;
size_t iovec_off;
unsigned int i;
uint32_t res = 0;
iovec_off = 0;
buf_off = 0;
for (i = 0; i < iov_cnt && size; i++) {
if (iov_off < (iovec_off + iov[i].iov_len)) {
size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size);
@ -200,7 +199,6 @@ net_checksum_add_iov(const struct iovec *iov, const unsigned int iov_cnt,
res += net_checksum_add_cont(len, chunk_buf, csum_offset);
csum_offset += len;
buf_off += len;
iov_off += len;
size -= len;
}

View File

@ -158,7 +158,7 @@ static void test_io(void)
int sv[2];
int r;
unsigned i, j, k, s, t;
unsigned i, j, k, s;
fd_set fds;
unsigned niov;
struct iovec *iov, *siov;
@ -182,7 +182,6 @@ static void test_io(void)
FD_ZERO(&fds);
t = 0;
if (fork() == 0) {
/* writer */
@ -201,7 +200,6 @@ static void test_io(void)
g_assert(memcmp(iov, siov, sizeof(*iov)*niov) == 0);
if (r >= 0) {
k += r;
t += r;
usleep(g_test_rand_int_range(0, 30));
} else if (errno == EAGAIN) {
select(sv[1]+1, NULL, &fds, NULL, NULL);
@ -238,7 +236,6 @@ static void test_io(void)
g_assert(memcmp(iov, siov, sizeof(*iov)*niov) == 0);
if (r > 0) {
k += r;
t += r;
} else if (!r) {
if (s) {
break;

View File

@ -23,29 +23,34 @@ GSList *read_self_maps(void)
gchar **fields = g_strsplit(lines[i], " ", 6);
if (g_strv_length(fields) > 4) {
MapInfo *e = g_new0(MapInfo, 1);
int errors;
int errors = 0;
const char *end;
errors = qemu_strtoul(fields[0], &end, 16, &e->start);
errors += qemu_strtoul(end + 1, NULL, 16, &e->end);
errors |= qemu_strtoul(fields[0], &end, 16, &e->start);
errors |= qemu_strtoul(end + 1, NULL, 16, &e->end);
e->is_read = fields[1][0] == 'r';
e->is_write = fields[1][1] == 'w';
e->is_exec = fields[1][2] == 'x';
e->is_priv = fields[1][3] == 'p';
errors += qemu_strtoul(fields[2], NULL, 16, &e->offset);
errors |= qemu_strtoul(fields[2], NULL, 16, &e->offset);
e->dev = g_strdup(fields[3]);
errors += qemu_strtou64(fields[4], NULL, 10, &e->inode);
errors |= qemu_strtou64(fields[4], NULL, 10, &e->inode);
/*
* The last field may have leading spaces which we
* need to strip.
*/
if (g_strv_length(fields) == 6) {
e->path = g_strdup(g_strchug(fields[5]));
if (!errors) {
/*
* The last field may have leading spaces which we
* need to strip.
*/
if (g_strv_length(fields) == 6) {
e->path = g_strdup(g_strchug(fields[5]));
}
map_info = g_slist_prepend(map_info, e);
} else {
g_free(e->dev);
g_free(e);
}
map_info = g_slist_prepend(map_info, e);
}
g_strfreev(fields);