Инструкция по сборке системного вызова архитектуры SPAR C - PullRequest
2 голосов
/ 07 февраля 2020

От syscall man 2:

   The  first  table lists the instruction used to transition to kernel mode 
   (which might not be the fastest or best way to transi‐
   tion to the kernel, so you might have to refer to vdso(7)), the register used to indicate 
   the system call number,  the  register
   used to return the system call result, and the register used to signal an error.

   arch/ABI    instruction           syscall #  retval  error    Notes
   ────────────────────────────────────────────────────────────────────
   ...
   sparc/32    t 0x10                g1         o0      psr/csr  [1]
   sparc/64    t 0x6d                g1         o0      psr/csr  [1]
   ...

Когда я рассматриваю примеры сборок, выполняющих системные вызовы на SPAR C, я вижу два разных способа перехода в ядро:

  • t 0x10 (как указано в справочных страницах)
  • ta 8

Два случайных примера:

Однако я не вижу инструкции t в руководстве по архитектуре SPAR C. Вместо этого я вижу семейство инструкций ловушек (инструкций Ti cc), которое включает в себя инструкцию "trap всегда" ta.

Из руководства SPAR C (https://www.gaisler.com/doc/sparcv8.pdf):

A Ticc instruction evaluates the integer condition codes (icc) according to
the cond field of the instruction, producing either a “true” or “false” result.
If “true” and no higher priority exceptions or interrupt requests are pending,
then a trap_instruction trap is generated. If “false”, a trap_instruction trap
does not occur and the instruction behaves like a NOP.

If a trap_instruction trap is generated, the tt field of the Trap Base Register
(TBR) is written with 128 plus the least significant seven bits of “r[rs1] +
r[rs2]” if the i field is zero, or 128 plus the least significant seven bits of
“r[rs1] + sign_ext(software_trap#)” if the i field is one.

After a taken Ticc, the processor enters supervisor mode, disables traps,
decrements the CWP (modulo NWINDOWS), and saves PC and nPC into
r[17] and r[18] (local registers 1 and 2) of the new window. See Chapter 7,
“Traps.”

Я пытаюсь понять, какая запись TBR используется каждой версией этих системных вызовов. Поскольку все программные ловушки имеют размер 0x80 - 0xFF, он должен быть одним из них. В семействе Ti cc изложены два правила:

  • 128 плюс семь младших разрядов «r [rs1] + r [rs2]», если поле i равно нулю
  • 128 плюс семь младших разрядов «r [rs1] + sign_ext (software_trap #)», если поле i равно 1

Может кто-нибудь объяснить разницу между t 0x10 и * 1047? *? В частности, можете ли вы объяснить, какое из этих правил применяется и какое значение смещения TBR используется в каждом случае?

...