From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87CF5C433DF for ; Thu, 16 Jul 2020 19:51:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51B73207BC for ; Thu, 16 Jul 2020 19:51:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YeQdEmXM"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="obtkJwyT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729754AbgGPTu6 (ORCPT ); Thu, 16 Jul 2020 15:50:58 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:35274 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729682AbgGPTuw (ORCPT ); Thu, 16 Jul 2020 15:50:52 -0400 Message-Id: <20200716185424.658427667@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1594929050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=hm0SGxiCrQHQkfsKjql/X4GV7MtYKpxZQquxBECJJ+c=; b=YeQdEmXMSr+7kwj1h20ury1vxph6Q6pGLKfN+hqR8tt3X+gpEl2WrRnzWDnQ4cGVr9kfxm l9wR98GBPWzbuwagUsnnRV2CUsF98ikw/dkyC71WzapqKcUbY1dn/yI67H3Mgik7xyRTbV M34D86bV+Xn4xLBgeISfJDx257UPywjz5ZFPVL1AZ2b1OPpgRz+iGUjMq5O8lkyhYBQUJK L6Ks1ejANygnOjnDsiOwrEKf/7/CHf8V/JwUDLOx+TIs5uP9fecILD/q4Fb/8ezQEL4GpT VsD/PWFh13CohjW+/PYf04pLpg/Cpv2V1xFU1EvDNG5ocGzxxBVydQB38Jp/Ug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1594929050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=hm0SGxiCrQHQkfsKjql/X4GV7MtYKpxZQquxBECJJ+c=; b=obtkJwyTzhno54Ob6seTeBpsV8ZwaKtWMbLcbRpMottNV3jZA1ohI6wiRhCD5os6fHRcwK IqjKsa04C0hlFcAg== Date: Thu, 16 Jul 2020 20:22:15 +0200 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, linux-arch@vger.kernel.org, Will Deacon , Arnd Bergmann , Mark Rutland , Kees Cook , Keno Fischer , Paolo Bonzini , kvm@vger.kernel.org Subject: [patch V3 07/13] x86/ptrace: Provide pt_regs helpers for entry/exit References: <20200716182208.180916541@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-transfer-encoding: 8-bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As a preparatory step for moving the syscall and interrupt entry/exit handling into generic code, provide pt_regs helpers which allow to: - Retrieve the syscall number from pt_regs - Retrieve the syscall return value from pt_regs - Retrieve the interrupt state from pt_regs to check whether interrupts are reenabled by return from interrupt/exception. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/ptrace.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/arch/x86/include/asm/ptrace.h +++ b/arch/x86/include/asm/ptrace.h @@ -209,6 +209,21 @@ static inline void user_stack_pointer_se regs->sp = val; } +static inline unsigned long regs_syscall_nr(struct pt_regs *regs) +{ + return regs->orig_ax; +} + +static inline long regs_syscall_retval(struct pt_regs *regs) +{ + return regs->ax; +} + +static __always_inline bool regs_irqs_disabled(struct pt_regs *regs) +{ + return !(regs->flags & X86_EFLAGS_IF); +} + /* Query offset/name of register from its name/offset */ extern int regs_query_register_offset(const char *name); extern const char *regs_query_register_name(unsigned int offset);