GNU/Weeb Mailing List <[email protected]>
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Dave Hansen <[email protected]>, Xin Li <[email protected]>,
	"H. Peter Anvin" <[email protected]>, Ingo Molnar <[email protected]>
Cc: Ammar Faizi <[email protected]>,
	Andrew Cooper <[email protected]>,
	Andy Lutomirski <[email protected]>, Borislav Petkov <[email protected]>,
	Thomas Gleixner <[email protected]>,
	Dave Hansen <[email protected]>,
	Peter Zijlstra <[email protected]>,
	"Kirill A. Shutemov" <[email protected]>,
	x86 Mailing List <[email protected]>,
	Linux Kernel Mailing List <[email protected]>,
	Linux Kselftest Mailing List <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [RESEND RFC PATCH v8 0/3] Intel FRED architecture support for the sysret_rip selftest
Date: Mon, 20 Feb 2023 10:09:56 +0700	[thread overview]
Message-ID: <[email protected]> (raw)

[ 
   RESEND, get rid of: Linux x86-64 Mailing List <[email protected]>
   from the CC list. It bounces and makes noise. Sorry for the wrong address.
]

Hi,

This is an RFC v8. Based on the x86/cpu branch in the tip tree.

The 'syscall' instruction on the Intel FRED architecture does not
clobber %rcx and %r11. This behavior leads to an assertion failure in
the sysret_rip selftest because it asserts %r11 = %rflags.

In the previous discussion, we agreed that there are two cases for
'syscall':

  A) 'syscall' in a FRED system preserves %rcx and %r11.

  B) 'syscall' in a non-FRED system sets %rcx=%rip and %r11=%rflags.

This series fixes the selftest. Make it work on the Intel FRED
architecture. Also, add more tests to ensure the syscall behavior is
consistent. It must always be (A) or always be (B). Not a mix of them.

See the previous discussion here:
https://lore.kernel.org/lkml/[email protected]

## Changelog revision

v8:
  - Stop using "+r"(rsp) to avoid the red zone problem because it
    generates the wrong Assembly code (Ammar).
    See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108799

  - Update commit message (Ammar).

v7:
  - Fix comment, REGS_ERROR no longer exists in the enum (Ammar).

  - Update commit message (Ammar).

v6:
  - Move the check-regs assertion in sigusr1() to check_regs_result() (HPA).

  - Add a new test just like sigusr1(), but don't modify REG_RCX and
    REG_R11. This is used to test SYSRET behavior consistency (HPA).

v5:
  - Fix do_syscall() return value (Ammar).

v4:
  - Fix the assertion condition inside the SIGUSR1 handler (Xin Li).

  - Explain the purpose of patch #2 in the commit message (HPA).

  - Update commit message (Ammar).

  - Repeat test_syscall_rcx_r11_consistent() 32 times to be more sure
    that the result is really consistent (Ammar).

v3:
  - Test that we don't get a mix of REGS_SAVED and REGS_SYSRET, which
    is a major part of the point (HPA).

v2:
  - Use "+r"(rsp) as the right way to avoid redzone problems per
    Andrew's comment (HPA).

Co-developed-by: H. Peter Anvin (Intel) <[email protected]>
Signed-off-by: H. Peter Anvin (Intel) <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---

Ammar Faizi (3):
  selftests/x86: sysret_rip: Handle syscall on the Intel FRED architecture
  selftests/x86: sysret_rip: Add more tests to verify the 'syscall' behavior
  selftests/x86: sysret_rip: Test SYSRET with a signal handler

 tools/testing/selftests/x86/sysret_rip.c | 169 +++++++++++++++++++++--
 1 file changed, 160 insertions(+), 9 deletions(-)


base-commit: e067248949e3de7fbeae812b0ccbbee7a401e7aa
-- 
Ammar Faizi


             reply	other threads:[~2023-02-20  3:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20  3:09 Ammar Faizi [this message]
2023-02-20  3:09 ` [RESEND RFC PATCH v8 1/3] selftests/x86: sysret_rip: Handle syscall on the Intel FRED architecture Ammar Faizi
2023-02-20  3:09 ` [RESEND RFC PATCH v8 2/3] selftests/x86: sysret_rip: Add more tests to verify the 'syscall' behavior Ammar Faizi
2023-02-20  3:09 ` [RESEND RFC PATCH v8 3/3] selftests/x86: sysret_rip: Test SYSRET with a signal handler Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox