Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase changes from mips_rel/4_1_0/master #1

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions linux-user/mips/cpu_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,10 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
if (env->insn_flags & ISA_NANOMIPS32) {
return;
}
if (((info->elf_flags & EF_MIPS_NAN2008) != 0) !=
((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) != 0)) {
if (info->fp_abi != MIPS_ABI_FP_SOFT
&& ((info->elf_flags & EF_MIPS_NAN2008) != 0) !=
((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) != 0))
{
if ((env->active_fpu.fcr31_rw_bitmask &
(1 << FCR31_NAN2008)) == 0) {
fprintf(stderr, "ELF binary's NaN mode not supported by CPU\n");
Expand Down
77 changes: 39 additions & 38 deletions qemu-io-cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,20 @@ static void cvtstr(double value, char *str, size_t size)



static struct timespec tsub(struct timespec t1, struct timespec t2)
static struct timeval tsub(struct timeval t1, struct timeval t2)
{
t1.tv_nsec -= t2.tv_nsec;
if (t1.tv_nsec < 0) {
t1.tv_nsec += NANOSECONDS_PER_SECOND;
t1.tv_usec -= t2.tv_usec;
if (t1.tv_usec < 0) {
t1.tv_usec += 1000000;
t1.tv_sec--;
}
t1.tv_sec -= t2.tv_sec;
return t1;
}

static double tdiv(double value, struct timespec tv)
static double tdiv(double value, struct timeval tv)
{
double seconds = tv.tv_sec + (tv.tv_nsec / 1e9);
return value / seconds;
return value / ((double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0));
}

#define HOURS(sec) ((sec) / (60 * 60))
Expand All @@ -286,27 +285,29 @@ enum {
VERBOSE_FIXED_TIME = 0x2,
};

static void timestr(struct timespec *tv, char *ts, size_t size, int format)
static void timestr(struct timeval *tv, char *ts, size_t size, int format)
{
double frac_sec = tv->tv_nsec / 1e9;
double usec = (double)tv->tv_usec / 1000000.0;

if (format & TERSE_FIXED_TIME) {
if (!HOURS(tv->tv_sec)) {
snprintf(ts, size, "%u:%05.2f",
(unsigned int) MINUTES(tv->tv_sec),
SECONDS(tv->tv_sec) + frac_sec);
snprintf(ts, size, "%u:%02u.%02u",
(unsigned int) MINUTES(tv->tv_sec),
(unsigned int) SECONDS(tv->tv_sec),
(unsigned int) (usec * 100));
return;
}
format |= VERBOSE_FIXED_TIME; /* fallback if hours needed */
}

if ((format & VERBOSE_FIXED_TIME) || tv->tv_sec) {
snprintf(ts, size, "%u:%02u:%05.2f",
snprintf(ts, size, "%u:%02u:%02u.%02u",
(unsigned int) HOURS(tv->tv_sec),
(unsigned int) MINUTES(tv->tv_sec),
SECONDS(tv->tv_sec) + frac_sec);
(unsigned int) SECONDS(tv->tv_sec),
(unsigned int) (usec * 100));
} else {
snprintf(ts, size, "%05.2f sec", frac_sec);
snprintf(ts, size, "0.%04u sec", (unsigned int) (usec * 10000));
}
}

Expand Down Expand Up @@ -467,7 +468,7 @@ static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
}
}

static void print_report(const char *op, struct timespec *t, int64_t offset,
static void print_report(const char *op, struct timeval *t, int64_t offset,
int64_t count, int64_t total, int cnt, bool Cflag)
{
char s1[64], s2[64], ts[64];
Expand Down Expand Up @@ -707,7 +708,7 @@ static const cmdinfo_t read_cmd = {

static int read_f(BlockBackend *blk, int argc, char **argv)
{
struct timespec t1, t2;
struct timeval t1, t2;
bool Cflag = false, qflag = false, vflag = false;
bool Pflag = false, sflag = false, lflag = false, bflag = false;
int c, cnt, ret;
Expand Down Expand Up @@ -825,13 +826,13 @@ static int read_f(BlockBackend *blk, int argc, char **argv)

buf = qemu_io_alloc(blk, count, 0xab, flags & BDRV_REQ_REGISTERED_BUF);

clock_gettime(CLOCK_MONOTONIC, &t1);
gettimeofday(&t1, NULL);
if (bflag) {
ret = do_load_vmstate(blk, buf, offset, count, &total);
} else {
ret = do_pread(blk, buf, offset, count, flags, &total);
}
clock_gettime(CLOCK_MONOTONIC, &t2);
gettimeofday(&t2, NULL);

if (ret < 0) {
printf("read failed: %s\n", strerror(-ret));
Expand Down Expand Up @@ -904,7 +905,7 @@ static const cmdinfo_t readv_cmd = {

static int readv_f(BlockBackend *blk, int argc, char **argv)
{
struct timespec t1, t2;
struct timeval t1, t2;
bool Cflag = false, qflag = false, vflag = false;
int c, cnt, ret;
char *buf;
Expand Down Expand Up @@ -964,9 +965,9 @@ static int readv_f(BlockBackend *blk, int argc, char **argv)
return -EINVAL;
}

clock_gettime(CLOCK_MONOTONIC, &t1);
gettimeofday(&t1, NULL);
ret = do_aio_readv(blk, &qiov, offset, flags, &total);
clock_gettime(CLOCK_MONOTONIC, &t2);
gettimeofday(&t2, NULL);

if (ret < 0) {
printf("readv failed: %s\n", strerror(-ret));
Expand Down Expand Up @@ -1047,7 +1048,7 @@ static const cmdinfo_t write_cmd = {

static int write_f(BlockBackend *blk, int argc, char **argv)
{
struct timespec t1, t2;
struct timeval t1, t2;
bool Cflag = false, qflag = false, bflag = false;
bool Pflag = false, zflag = false, cflag = false, sflag = false;
BdrvRequestFlags flags = 0;
Expand Down Expand Up @@ -1190,7 +1191,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
}
}

clock_gettime(CLOCK_MONOTONIC, &t1);
gettimeofday(&t1, NULL);
if (bflag) {
ret = do_save_vmstate(blk, buf, offset, count, &total);
} else if (zflag) {
Expand All @@ -1200,7 +1201,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
} else {
ret = do_pwrite(blk, buf, offset, count, flags, &total);
}
clock_gettime(CLOCK_MONOTONIC, &t2);
gettimeofday(&t2, NULL);

if (ret < 0) {
printf("write failed: %s\n", strerror(-ret));
Expand Down Expand Up @@ -1260,7 +1261,7 @@ static const cmdinfo_t writev_cmd = {

static int writev_f(BlockBackend *blk, int argc, char **argv)
{
struct timespec t1, t2;
struct timeval t1, t2;
bool Cflag = false, qflag = false;
BdrvRequestFlags flags = 0;
int c, cnt, ret;
Expand Down Expand Up @@ -1317,9 +1318,9 @@ static int writev_f(BlockBackend *blk, int argc, char **argv)
return -EINVAL;
}

clock_gettime(CLOCK_MONOTONIC, &t1);
gettimeofday(&t1, NULL);
ret = do_aio_writev(blk, &qiov, offset, flags, &total);
clock_gettime(CLOCK_MONOTONIC, &t2);
gettimeofday(&t2, NULL);

if (ret < 0) {
printf("writev failed: %s\n", strerror(-ret));
Expand Down Expand Up @@ -1355,15 +1356,15 @@ struct aio_ctx {
BlockAcctCookie acct;
int pattern;
BdrvRequestFlags flags;
struct timespec t1;
struct timeval t1;
};

static void aio_write_done(void *opaque, int ret)
{
struct aio_ctx *ctx = opaque;
struct timespec t2;
struct timeval t2;

clock_gettime(CLOCK_MONOTONIC, &t2);
gettimeofday(&t2, NULL);


if (ret < 0) {
Expand Down Expand Up @@ -1394,9 +1395,9 @@ static void aio_write_done(void *opaque, int ret)
static void aio_read_done(void *opaque, int ret)
{
struct aio_ctx *ctx = opaque;
struct timespec t2;
struct timeval t2;

clock_gettime(CLOCK_MONOTONIC, &t2);
gettimeofday(&t2, NULL);

if (ret < 0) {
printf("readv failed: %s\n", strerror(-ret));
Expand Down Expand Up @@ -1537,7 +1538,7 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv)
return -EINVAL;
}

clock_gettime(CLOCK_MONOTONIC, &ctx->t1);
gettimeofday(&ctx->t1, NULL);
block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size,
BLOCK_ACCT_READ);
blk_aio_preadv(blk, ctx->offset, &ctx->qiov, ctx->flags, aio_read_done,
Expand Down Expand Up @@ -1692,7 +1693,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)
return -EINVAL;
}

clock_gettime(CLOCK_MONOTONIC, &ctx->t1);
gettimeofday(&ctx->t1, NULL);
block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size,
BLOCK_ACCT_WRITE);

Expand Down Expand Up @@ -2159,7 +2160,7 @@ static const cmdinfo_t discard_cmd = {

static int discard_f(BlockBackend *blk, int argc, char **argv)
{
struct timespec t1, t2;
struct timeval t1, t2;
bool Cflag = false, qflag = false;
int c, ret;
int64_t offset, bytes;
Expand Down Expand Up @@ -2200,9 +2201,9 @@ static int discard_f(BlockBackend *blk, int argc, char **argv)
return -EINVAL;
}

clock_gettime(CLOCK_MONOTONIC, &t1);
gettimeofday(&t1, NULL);
ret = blk_pdiscard(blk, offset, bytes);
clock_gettime(CLOCK_MONOTONIC, &t2);
gettimeofday(&t2, NULL);

if (ret < 0) {
printf("discard failed: %s\n", strerror(-ret));
Expand Down
8 changes: 7 additions & 1 deletion scripts/archive-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ if test $# -lt 1; then
error "Usage: $0 <output tarball>"
fi

tar_file=$(realpath "$1")
which realpath
if [ $? -eq 0 ]; then
tar_file=$(realpath -s "$1")
else
d=$(dirname "$1")
tar_file=$(readlink -e "$d")"/"$(basename "$1")
fi
sub_tdir=$(mktemp -d "${tar_file%.tar}.sub.XXXXXXXX")
sub_file="${sub_tdir}/submodule.tar"

Expand Down
14 changes: 9 additions & 5 deletions target/mips/cpu-defs.c.inc
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ const mips_def_t mips_defs[] =
.CP1_fcr31_rw_bitmask = 0xFF83FFFF,
.SEGBITS = 32,
.PABITS = 40,
.insn_flags = CPU_MIPS32R5,
.insn_flags = CPU_MIPS32R5 | ASE_MICROMIPS,
.mmu_type = MMU_TYPE_R4000,
},
{
Expand All @@ -478,14 +478,15 @@ const mips_def_t mips_defs[] =
(2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
(0 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
.CP0_Config2 = MIPS_CONFIG2,
.CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_BP) | (1 << CP0C3_BI) |
.CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_MSAP) |
(1 << CP0C3_BP) | (1 << CP0C3_BI) |
(2 << CP0C3_ISA) | (1 << CP0C3_ULRI) |
(1 << CP0C3_RXI) | (1U << CP0C3_M),
.CP0_Config4 = MIPS_CONFIG4 | (0xfc << CP0C4_KScrExist) |
(3 << CP0C4_IE) | (1U << CP0C4_M),
.CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_LLB),
.CP0_Config5_rw_bitmask = (1 << CP0C5_SBRI) | (1 << CP0C5_FRE) |
(1 << CP0C5_UFE),
.CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 << CP0C5_UFE) |
(1 << CP0C5_FRE) | (1 << CP0C5_SBRI),
.CP0_LLAddr_rw_bitmask = 0,
.CP0_LLAddr_shift = 0,
.SYNCI_Step = 32,
Expand All @@ -499,6 +500,7 @@ const mips_def_t mips_defs[] =
(1 << FCR0_S) | (0x00 << FCR0_PRID) | (0x0 << FCR0_REV),
.CP1_fcr31 = (1 << FCR31_ABS2008) | (1 << FCR31_NAN2008),
.CP1_fcr31_rw_bitmask = 0x0103FFFF,
.MSAIR = 0x03 << MSAIR_ProcID,
.SEGBITS = 32,
.PABITS = 32,
.insn_flags = CPU_MIPS32R6 | ASE_MICROMIPS,
Expand Down Expand Up @@ -676,7 +678,9 @@ const mips_def_t mips_defs[] =
(2 << CP0C1_DS) | (4 << CP0C1_DL) | (3 << CP0C1_DA) |
(1 << CP0C1_PC) | (1 << CP0C1_WR) | (1 << CP0C1_EP),
.CP0_Config2 = MIPS_CONFIG2,
.CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA),
.CP0_Config3 = MIPS_CONFIG3 | (1 << CP0C3_LPA) |
(1 << CP0C3_VInt) | (1 << CP0C3_MSAP),
.CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn),
.CP0_LLAddr_rw_bitmask = 0,
.CP0_LLAddr_shift = 0,
.SYNCI_Step = 32,
Expand Down
2 changes: 2 additions & 0 deletions target/mips/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ DEF_HELPER_FLAGS_1(bitswap, TCG_CALL_NO_RWG_SE, tl, tl)
DEF_HELPER_FLAGS_1(dbitswap, TCG_CALL_NO_RWG_SE, tl, tl)
#endif

DEF_HELPER_3(crc32, tl, tl, tl, i32)
DEF_HELPER_3(crc32c, tl, tl, tl, i32)
DEF_HELPER_FLAGS_4(rotx, TCG_CALL_NO_RWG_SE, tl, tl, i32, i32, i32)

/* microMIPS functions */
Expand Down
1 change: 1 addition & 0 deletions target/mips/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mips_ss.add(files(
'gdbstub.c',
'msa.c',
))
mips_ss.add(zlib)

if have_system
subdir('sysemu')
Expand Down
7 changes: 5 additions & 2 deletions target/mips/sysemu/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ static int get_tlb(QEMUFile *f, void *pv, size_t size,
qemu_get_betls(f, &v->VPN);
qemu_get_be32s(f, &v->PageMask);
qemu_get_be16s(f, &v->ASID);
qemu_get_be32s(f, &v->MMID);
qemu_get_be16s(f, &flags);
v->G = (flags >> 10) & 1;
v->C0 = (flags >> 7) & 3;
Expand All @@ -167,6 +168,7 @@ static int put_tlb(QEMUFile *f, void *pv, size_t size,
r4k_tlb_t *v = pv;

uint16_t asid = v->ASID;
uint32_t mmid = v->MMID;
uint16_t flags = ((v->EHINV << 15) |
(v->RI1 << 14) |
(v->RI0 << 13) |
Expand All @@ -183,6 +185,7 @@ static int put_tlb(QEMUFile *f, void *pv, size_t size,
qemu_put_betls(f, &v->VPN);
qemu_put_be32s(f, &v->PageMask);
qemu_put_be16s(f, &asid);
qemu_put_be32s(f, &mmid);
qemu_put_be16s(f, &flags);
qemu_put_be64s(f, &v->PFN[0]);
qemu_put_be64s(f, &v->PFN[1]);
Expand All @@ -204,8 +207,8 @@ static const VMStateInfo vmstate_info_tlb = {

static const VMStateDescription vmstate_tlb = {
.name = "cpu/tlb",
.version_id = 2,
.minimum_version_id = 2,
.version_id = 3,
.minimum_version_id = 3,
.fields = (const VMStateField[]) {
VMSTATE_UINT32(nb_tlb, CPUMIPSTLBContext),
VMSTATE_UINT32(tlb_in_use, CPUMIPSTLBContext),
Expand Down
Loading
Loading