All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v8 00/38] target/mips: Limited support for the R5900
@ 2018-10-21 15:30 Fredrik Noring
  2018-10-21 15:31 ` [Qemu-devel] [PATCH v8 01/38] target/mips: Define R5900 instructions and CPU preprocessor constants Fredrik Noring
                   ` (38 more replies)
  0 siblings, 39 replies; 59+ messages in thread
From: Fredrik Noring @ 2018-10-21 15:30 UTC (permalink / raw)
  To: Aleksandar Markovic, Maciej W. Rozycki, Philippe Mathieu-Daudé
  Cc: Richard Henderson, Aurelien Jarno, Petar Jovanovic,
	Peter Maydell, Jürgen Urban, qemu-devel

The primary purpose of these changes is to support programs compiled
by GCC for the R5900 target and thereby run R5900 Linux distributions,
for example Gentoo.

GCC in version 7.3, by itself, by inspection of the GCC source code
and inspection of the generated machine code, for the R5900 target,
only emits two instructions that are specific to the R5900: the three-
operand MULT and MULTU. GCC and libc also emit certain MIPS III
instructions that are not part of the R5900 ISA. They are normally
trapped and emulated by the Linux kernel, and therefore need to be
treated accordingly by QEMU. This is addressed, in turn, by the
patch series.

A program compiled by GCC is taken to mean source code compiled by GCC
under the restrictions above. One can, with the apparent limitations,
with a bit of effort obtain a fully functioning operating system such
as R5900 Gentoo. Strictly speaking, programs need not be compiled by
GCC to make use of this change.

Instructions and other facilities of the R5900 not implemented by these
changes are intended to signal provisional exceptions. One such example
is the FPU that is not compliant with IEEE 754-1985 in system mode. It
is therefore provisionally disabled. In user space the FPU is trapped
and emulated by IEEE 754-1985 compliant software in the kernel, and
this is handled accordingly by QEMU. Another example is the 93
multimedia instructions specific to the R5900 that generate provisional
reserved instruction exception signals.

One of the benefits of running a Linux distribution under QEMU is that
programs can be compiled with a native compiler, where the host and
target are the same, as opposed to a cross-compiler, where they are
not the same. This is especially important in cases where the target
hardware does not have the resources to run a native compiler.

Problems with cross-compilation are often related to host and target
differences in integer sizes, pointer sizes, endianness, machine code,
ABI, etc. Sometimes cross-compilation is not even supported by the
build script for a given package. One effective way to avoid those
problems is to replace the cross-compiler with a native compiler. This
change of compilation methods does not resolve the inherent problems
with cross-compilation.

The native compiler naturally replaces the cross-compiler, because one
typically uses one or the other, and preferably the native compiler
when the circumstances admit this. The native compiler is also a good
test case for the R5900 QEMU user mode. Additionally, Gentoo is well-
known for compiling and installing its packages from sources.

This change has been tested with Gentoo compiled for R5900, including
native compilation of several packages under QEMU. I used the Gentoo
sys-devel/crossdev package

https://wiki.gentoo.org/wiki/Crossdev

with patches mainly to simplify the handling of LL/SC and floating
point support, to avoid complications with additional configure and
compiler flags. Busybox

https://busybox.net/

can also be used to build a simple functional R5900 program. It can be
used to test the R5900 CPU in QEMU user mode.

The R5900 implements the 64-bit MIPS III instruction set except DMULT,
DMULTU, DDIV, DDIVU, LL, SC, LLD and SCD. The MIPS IV instructions MOVN,
MOVZ and PREF are implemented. It has the R5900 specific three-operand
instructions MADD, MADDU, MULT and MULTU as well as pipeline 1 versions
MULT1, MULTU1, DIV1, DIVU1, MADD1, MADDU1, MFHI1, MFLO1, MTHI1 and
MTLO1. A set of 93 128-bit multimedia instructions specific to the
R5900 is also implemented.

The Toshiba TX System RISC TX79 Core Architecture manual

https://wiki.qemu.org/File:C790.pdf

describes the C790 processor that is a follow-up to the R5900. There
are a few notable differences in that the R5900 FPU

- is not IEEE 754-1985 compliant,
- does not implement double format, and
- its machine code is nonstandard.

Changes in v8:
- Support, disassembly and tests for MADD, MADD1, MADDU and MADDU1
- Support, disassembly and tests for MTLO1, MTHI1, MFLO1 and MFHI1
- Support, disassembly and tests for MULT1, MULTU1, DIV1 and DIVU1
- Opcode definitions and placeholder code for all unsupported MMIs
- check_insn_opc_user_only flags parameter type is uint64_t
- Toshiba TX System RISC TX79 manual PDF QEMU wiki link
- Merge of [PATCH v7 7/7] with Toshiba/Sony rename

Changes in v7:
- Rename gen_mul_txxx to gen_mul_txx9
- Use MIPS_INVAL("mul TXx9")
- Reviewed-by: Philippe Mathieu-Daudé

Changes in v6:
- Set the CP0 PRId implementation number to 0x2E for the R5900
- Refer to the C790 follow-up in the definition of the R5900
- Define and use check_insn_opc_user_only in the same change
- Rename gen_mul_r5900 to gen_mul_txxx
- Enclose single statements in braces
- Expand and reword commit messages and notes
- Reword the cover letter subject line
- All changes build with GCC and Clang
- Approval from checkpatch.pl

Changes in v5:
- Reorder check_insn_opc_user_only calls
- Call check_insn_opc_removed in check_insn_opc_user_only

Changes in v4:
- Split into a patch series consisting of eight changes
- Expand commit messages and notes
- Introduce check_insn_opc_user_only
- Base R5900 on MIPS III, with MOVN, MOVZ and PREF from MIPS IV
- DMULT, DMULTU, DDIV, DDIVU, LL, SC, LLD and SCD are user only
- Note Toshiba/Sony R5900 for EF_MIPS_MACH_R5900 definition
- Rework gen_mul_r5900
- Fix ICE and DCE
- Fix SEGBITS and PABITS
- Fix indentation

Changes in v3:
- Apply to HEAD
- Remove the word "initial" from subject line

Changes in v2:
- Update mips_defs array with R5900 values
- LL/SC and FPU are user only

Fredrik Noring (38):
  target/mips: Define R5900 instructions and CPU preprocessor constants
  disas/mips: Define R5900 disassembly constants
  target/mips: R5900 Multimedia Instruction overview note
  target/mips: Define R5900 MMI class, and LQ and SQ opcode constants
  target/mips: Define R5900 MMI{0,1,2,3} subclasses and MMI opcode constants
  target/mips: Define R5900 MMI0 opcode constants
  target/mips: Define R5900 MMI1 opcode constants
  target/mips: Define R5900 MMI2 opcode constants
  target/mips: Define R5900 MMI3 opcode constants
  target/mips: Placeholder for R5900 MMI SQ, handle user mode RDHWR
  target/mips: Placeholder for R5900 MMI LQ
  target/mips: Placeholder for R5900 MMI instruction class
  target/mips: Placeholder for R5900 MMI0 instruction subclass
  target/mips: Placeholder for R5900 MMI1 instruction subclass
  target/mips: Placeholder for R5900 MMI2 instruction subclass
  target/mips: Placeholder for R5900 MMI3 instruction subclass
  target/mips: Support R5900 three-operand MULT and MULTU
  target/mips: Support R5900 three-operand MULT1 and MULTU1
  target/mips: Support R5900 MFLO1, MTLO1, MFHI1 and MTHI1
  target/mips: Support R5900 DIV1 and DIVU1
  target/mips: Support R5900 MOVN, MOVZ and PREF from MIPS IV
  target/mips: Support R5900 three-operand MADD and MADD1
  target/mips: Support R5900 three-operand MADDU and MADDU1
  target/mips: R5900 DMULT[U], DDIV[U], LL[D] and SC[D] are user only
  tests/tcg/mips: Test R5900 three-operand MULT
  tests/tcg/mips: Test R5900 three-operand MULTU
  tests/tcg/mips: Test R5900 three-operand MULT1
  tests/tcg/mips: Test R5900 three-operand MULTU1
  tests/tcg/mips: Test R5900 MFLO1 and MFHI1
  tests/tcg/mips: Test R5900 MTLO1 and MTHI1
  tests/tcg/mips: Test R5900 DIV1
  tests/tcg/mips: Test R5900 DIVU1
  tests/tcg/mips: Test R5900 three-operand MADD
  tests/tcg/mips: Test R5900 three-operand MADD1
  tests/tcg/mips: Test R5900 three-operand MADDU
  tests/tcg/mips: Test R5900 three-operand MADDU1
  target/mips: Define the R5900 CPU
  linux-user/mips: Recognise the R5900 CPU model

 disas/mips.c                       |  20 +
 linux-user/mips/target_elf.h       |   3 +
 target/mips/mips-defs.h            |   2 +
 target/mips/translate.c            | 871 ++++++++++++++++++++++++++++-
 target/mips/translate_init.inc.c   |  59 ++
 tests/tcg/mips/mipsr5900/Makefile  |  32 ++
 tests/tcg/mips/mipsr5900/div1.c    |  73 +++
 tests/tcg/mips/mipsr5900/divu1.c   |  48 ++
 tests/tcg/mips/mipsr5900/madd.c    |  78 +++
 tests/tcg/mips/mipsr5900/maddu.c   |  70 +++
 tests/tcg/mips/mipsr5900/mflohi1.c |  35 ++
 tests/tcg/mips/mipsr5900/mtlohi1.c |  40 ++
 tests/tcg/mips/mipsr5900/mult.c    |  76 +++
 tests/tcg/mips/mipsr5900/multu.c   |  68 +++
 14 files changed, 1465 insertions(+), 10 deletions(-)
 create mode 100644 tests/tcg/mips/mipsr5900/Makefile
 create mode 100644 tests/tcg/mips/mipsr5900/div1.c
 create mode 100644 tests/tcg/mips/mipsr5900/divu1.c
 create mode 100644 tests/tcg/mips/mipsr5900/madd.c
 create mode 100644 tests/tcg/mips/mipsr5900/maddu.c
 create mode 100644 tests/tcg/mips/mipsr5900/mflohi1.c
 create mode 100644 tests/tcg/mips/mipsr5900/mtlohi1.c
 create mode 100644 tests/tcg/mips/mipsr5900/mult.c
 create mode 100644 tests/tcg/mips/mipsr5900/multu.c

-- 
2.18.1

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: [Qemu-devel] [PULL 00/34] MIPS queue for October 2018 - part 2
@ 2018-10-23 19:49 Peter Maydell
  2018-10-23 20:37 ` [Qemu-devel] [PATCH v8 00/38] target/mips: Limited support for the R5900 Fredrik Noring
  0 siblings, 1 reply; 59+ messages in thread
From: Peter Maydell @ 2018-10-23 19:49 UTC (permalink / raw)
  To: Aleksandar Markovic; +Cc: QEMU Developers, Aleksandar Markovic

On 22 October 2018 at 13:57, Aleksandar Markovic
<aleksandar.markovic@rt-rk.com> wrote:
> From: Aleksandar Markovic <amarkovic@wavecomp.com>
>
> The following changes since commit b312532fd03413d0e6ae6767ec793a3e30f487b8:
>
>   Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2018-10-19 19:01:07 +0100)
>
> are available in the git repository at:
>
>   https://github.com/AMarkovic/qemu tags/mips-queue-oct-2018-part-2
>
> for you to fetch changes up to 2ec219776c633df9e43c5fa1557f70ee4f735f9d:
>
>   target/mips: Fix decoding of ALIGN and DALIGN instructions (2018-10-22 14:41:47 +0200)
>
> ----------------------------------------------------------------
> MIPS queue for October 2018 - part 2
>
> Limited support for R5900 ISA, MMI ASE, and two misc fixes.
>
> ----------------------------------------------------------------

Hi: I get compile errors on 32-bit hosts:

/home/petmay01/qemu-for-merges/disas/mips.c:615:35: error: large
integer implicitly truncated to unsigned type [-Werror=overflow]
 #define INSN_5900                 0x100000000
                                   ^
/home/petmay01/qemu-for-merges/disas/mips.c:1200:17: note: in
expansion of macro 'INSN_5900'
 #define EE      INSN_5900    /* Emotion Engine */
                 ^
/home/petmay01/qemu-for-merges/disas/mips.c:2326:73: note: in
expansion of macro 'EE'
 {"div1",    "z,s,t",  0x7000001a, 0xfc00ffff, RD_s | RD_t | WR_HILO, 0, EE },
                                                                         ^

(and repeats on other similar uses).

This is because this line is an initializer for "struct mips_opcode",
and the final field is "unsigned long membership", which may be only
32 bits wide, but you're trying to put a number in that's too big for that.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 59+ messages in thread

end of thread, other threads:[~2018-10-26 13:42 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-21 15:30 [Qemu-devel] [PATCH v8 00/38] target/mips: Limited support for the R5900 Fredrik Noring
2018-10-21 15:31 ` [Qemu-devel] [PATCH v8 01/38] target/mips: Define R5900 instructions and CPU preprocessor constants Fredrik Noring
2018-10-21 15:31 ` [Qemu-devel] [PATCH v8 02/38] disas/mips: Define R5900 disassembly constants Fredrik Noring
2018-10-21 15:32 ` [Qemu-devel] [PATCH v8 03/38] target/mips: R5900 Multimedia Instruction overview note Fredrik Noring
2018-10-21 15:33 ` [Qemu-devel] [PATCH v8 04/38] target/mips: Define R5900 MMI class, and LQ and SQ opcode constants Fredrik Noring
2018-10-21 15:33 ` [Qemu-devel] [PATCH v8 05/38] target/mips: Define R5900 MMI{0, 1, 2, 3} subclasses and MMI " Fredrik Noring
2018-10-21 15:34 ` [Qemu-devel] [PATCH v8 06/38] target/mips: Define R5900 MMI0 " Fredrik Noring
2018-10-21 15:34 ` [Qemu-devel] [PATCH v8 07/38] target/mips: Define R5900 MMI1 " Fredrik Noring
2018-10-21 15:34 ` [Qemu-devel] [PATCH v8 08/38] target/mips: Define R5900 MMI2 " Fredrik Noring
2018-10-21 15:34 ` [Qemu-devel] [PATCH v8 09/38] target/mips: Define R5900 MMI3 " Fredrik Noring
2018-10-21 15:35 ` [Qemu-devel] [PATCH v8 10/38] target/mips: Placeholder for R5900 MMI SQ, handle user mode RDHWR Fredrik Noring
2018-10-21 15:35 ` [Qemu-devel] [PATCH v8 11/38] target/mips: Placeholder for R5900 MMI LQ Fredrik Noring
2018-10-21 15:36 ` [Qemu-devel] [PATCH v8 12/38] target/mips: Placeholder for R5900 MMI instruction class Fredrik Noring
2018-10-21 15:36 ` [Qemu-devel] [PATCH v8 13/38] target/mips: Placeholder for R5900 MMI0 instruction subclass Fredrik Noring
2018-10-21 15:36 ` [Qemu-devel] [PATCH v8 14/38] target/mips: Placeholder for R5900 MMI1 " Fredrik Noring
2018-10-21 15:37 ` [Qemu-devel] [PATCH v8 15/38] target/mips: Placeholder for R5900 MMI2 " Fredrik Noring
2018-10-21 15:37 ` [Qemu-devel] [PATCH v8 16/38] target/mips: Placeholder for R5900 MMI3 " Fredrik Noring
2018-10-21 15:38 ` [Qemu-devel] [PATCH v8 17/38] target/mips: Support R5900 three-operand MULT and MULTU Fredrik Noring
2018-10-21 15:38 ` [Qemu-devel] [PATCH v8 18/38] target/mips: Support R5900 three-operand MULT1 and MULTU1 Fredrik Noring
2018-10-21 15:38 ` [Qemu-devel] [PATCH v8 19/38] target/mips: Support R5900 MFLO1, MTLO1, MFHI1 and MTHI1 Fredrik Noring
2018-10-21 15:39 ` [Qemu-devel] [PATCH v8 20/38] target/mips: Support R5900 DIV1 and DIVU1 Fredrik Noring
2018-10-21 15:39 ` [Qemu-devel] [PATCH v8 21/38] target/mips: Support R5900 MOVN, MOVZ and PREF from MIPS IV Fredrik Noring
2018-10-21 15:39 ` [Qemu-devel] [PATCH v8 22/38] target/mips: Support R5900 three-operand MADD and MADD1 Fredrik Noring
2018-10-21 15:40 ` [Qemu-devel] [PATCH v8 23/38] target/mips: Support R5900 three-operand MADDU and MADDU1 Fredrik Noring
2018-10-21 15:40 ` [Qemu-devel] [PATCH v8 24/38] target/mips: R5900 DMULT[U], DDIV[U], LL[D] and SC[D] are user only Fredrik Noring
2018-10-21 15:41 ` [Qemu-devel] [PATCH v8 25/38] tests/tcg/mips: Test R5900 three-operand MULT Fredrik Noring
2018-10-21 15:41 ` [Qemu-devel] [PATCH v8 26/38] tests/tcg/mips: Test R5900 three-operand MULTU Fredrik Noring
2018-10-21 15:41 ` [Qemu-devel] [PATCH v8 27/38] tests/tcg/mips: Test R5900 three-operand MULT1 Fredrik Noring
2018-10-21 15:41 ` [Qemu-devel] [PATCH v8 28/38] tests/tcg/mips: Test R5900 three-operand MULTU1 Fredrik Noring
2018-10-21 15:41 ` [Qemu-devel] [PATCH v8 29/38] tests/tcg/mips: Test R5900 MFLO1 and MFHI1 Fredrik Noring
2018-10-21 15:41 ` [Qemu-devel] [PATCH v8 30/38] tests/tcg/mips: Test R5900 MTLO1 and MTHI1 Fredrik Noring
2018-10-21 15:42 ` [Qemu-devel] [PATCH v8 31/38] tests/tcg/mips: Test R5900 DIV1 Fredrik Noring
2018-10-21 15:42 ` [Qemu-devel] [PATCH v8 32/38] tests/tcg/mips: Test R5900 DIVU1 Fredrik Noring
2018-10-21 15:43 ` [Qemu-devel] [PATCH v8 33/38] tests/tcg/mips: Test R5900 three-operand MADD Fredrik Noring
2018-10-21 15:43 ` [Qemu-devel] [PATCH v8 34/38] tests/tcg/mips: Test R5900 three-operand MADD1 Fredrik Noring
2018-10-21 15:43 ` [Qemu-devel] [PATCH v8 35/38] tests/tcg/mips: Test R5900 three-operand MADDU Fredrik Noring
2018-10-21 15:43 ` [Qemu-devel] [PATCH v8 36/38] tests/tcg/mips: Test R5900 three-operand MADDU1 Fredrik Noring
2018-10-21 15:44 ` [Qemu-devel] [PATCH v8 37/38] target/mips: Define the R5900 CPU Fredrik Noring
2018-10-21 15:44 ` [Qemu-devel] [PATCH v8 38/38] linux-user/mips: Recognise the R5900 CPU model Fredrik Noring
2018-10-22 13:03 ` [Qemu-devel] [PATCH v8 00/38] target/mips: Limited support for the R5900 Aleksandar Markovic
2018-10-22 17:23   ` Fredrik Noring
2018-10-22 18:10     ` Aleksandar Markovic
2018-10-22 19:00       ` Fredrik Noring
2018-10-22 18:31     ` Maciej W. Rozycki
2018-10-22 18:40       ` Maciej W. Rozycki
2018-10-22 23:16         ` Philippe Mathieu-Daudé
2018-10-23 19:10       ` Fredrik Noring
2018-10-25 17:38         ` Maciej W. Rozycki
2018-10-26 13:42           ` Fredrik Noring
2018-10-22 23:35   ` Philippe Mathieu-Daudé
2018-10-23 19:25   ` Fredrik Noring
2018-10-23 22:04     ` Maciej W. Rozycki
2018-10-23 19:49 [Qemu-devel] [PULL 00/34] MIPS queue for October 2018 - part 2 Peter Maydell
2018-10-23 20:37 ` [Qemu-devel] [PATCH v8 00/38] target/mips: Limited support for the R5900 Fredrik Noring
2018-10-24  8:04   ` Richard Henderson
2018-10-25 17:01     ` Fredrik Noring
2018-10-25 18:03       ` Maciej W. Rozycki
2018-10-25 18:20         ` Fredrik Noring
2018-10-26  7:26         ` Richard Henderson
2018-10-26 13:12           ` Maciej W. Rozycki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.