Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2841105pxj; Mon, 10 May 2021 11:58:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3Y91hFbEx62MZ1+GH6sfZNaiEL5+38jLARU3VcFbGsnAnuUd6lkTldbl7y3SpbtMn+nGJ X-Received: by 2002:a17:906:600b:: with SMTP id o11mr27261992ejj.345.1620673080261; Mon, 10 May 2021 11:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620673080; cv=none; d=google.com; s=arc-20160816; b=JMsk8HN7M2aJ2InttRFqo/OVPmdlPb7mWMWfCY9m9MtHa8aonvAngTKd45Uv3EEPCe pi+HH3MNYBfm4Ve8QXfuWQ7qYifAp7G8plHP0nm4vgGJCrcGvqZ9FyzjpHK7ccw5Ykyk 7HEycTpKd8LEyDNQ+GAITUMIG/mUZk2cSGxafU9cie/R2UPrLFRaS2YfdbigU39KL9hn PZdJzNYsJz+2dcM67/SlBszDDTOVxpCWcblHtBUb2NJF4FHlaudNVAVJkvBViqFk7gLr PmZ4zQDp65gSGW/gPBL0/I5RVSWRXZL8eS+kiY+Ap6RAMncWVT7/0nxSdn8BpNg2zsv2 FudQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=QkaTTiwvtH2PVWgSD8V19SdiOHceCecPmtWF6NhrBQU=; b=hEns2FJAnPVkqAN1eIbXaZcXleWH7gDQ73l4mzKXdLzHKcbvHY5Af55FaSxLE1JwLD wpE740Hj9KJVWboVgLLfrmrhqVQHfPblIWdWAfHkZM5BdNW1Dn5FUMVVMMjxJ3AV+Pia o6e4p8u+hDKSk7+ir13xaXCKZd/LzVhCoGjzNTHkUc1zW5whcLUP3LtG13cHQkZTXKq7 3vdDUeA3hN9qylaMV7etL7tq4jOhbT9ses/sN4XHDGsBpPBs5XjJ20HP6ddzsmclaY1Z uqURZa4NQ5Z/qt4KYZrkootNcYGAJti8m9ZJ75joos7lkzSasPnze9Q6NAWpVhv9EzzG dpdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2021042801 header.b=HGmFFKvP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si16180616edr.0.2021.05.10.11.57.36; Mon, 10 May 2021 11:58:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2021042801 header.b=HGmFFKvP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233274AbhEJSzB (ORCPT + 99 others); Mon, 10 May 2021 14:55:01 -0400 Received: from terminus.zytor.com ([198.137.202.136]:45441 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232977AbhEJSyr (ORCPT ); Mon, 10 May 2021 14:54:47 -0400 Received: from tazenda.hos.anvin.org ([IPv6:2601:646:8602:8be0:7285:c2ff:fefb:fd4]) (authenticated bits=0) by mail.zytor.com (8.16.1/8.15.2) with ESMTPSA id 14AIrNlc2459085 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 10 May 2021 11:53:29 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 14AIrNlc2459085 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2021042801; t=1620672810; bh=QkaTTiwvtH2PVWgSD8V19SdiOHceCecPmtWF6NhrBQU=; h=From:To:Cc:Subject:Date:From; b=HGmFFKvPiD3EIBGL4wW0O6x1YTbmLxP75Ggbe42U/gH3DKA70Q0O8XR/EhDEHuJhq FAf+dkwWcqCdIglniUZg32hvekZBjhvhR75AqPi+nG15oaJ6sZ+yo2bjpmEnYUAASw MSwKzaUMwB8VasQDXdIY/lES0Qw38jo6Yry/rRp6Lo5GLMb1mEj81oVLpbXt2BsXnn SXYL+iI5LSxbCEulAD+RXW8LWnRhvWFb/rC5dIlLaEBAf5LhQa0cLUoW3fc9Wciy2B XngH0oJdq4ZhWCNQviWvIomGn+FVTaNdhvRokJSZtRNU9+ySgW73OxWQAWcsEgTjt0 GkQ62Se9dmJHA== From: "H. Peter Anvin" To: Ingo Molnar , Thomas Gleixner , Borislav Petkov , Andy Lutomirski Cc: "H. Peter Anvin" , Linux Kernel Mailing List Subject: [RFC v2 PATCH 0/6] x86/entry: cleanups and consistent syscall number handling Date: Mon, 10 May 2021 11:53:09 -0700 Message-Id: <20210510185316.3307264-1-hpa@zytor.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "H. Peter Anvin (Intel)" This patchset: 1. Cleans up some duplications between and . 2. Swaps the arguments to do_syscall_64() for consistency *and* speed. 3. Adds the maximum number of flags to MSR_SYSCALL_MASK; the previous is more of a minimum. The more flags that are masked, the less the likelihood of a control leak into the kernel. 4. Consistently treat the system call number as a signed int. This is what syscall_get_nr() already does, and therefore what all architecture-independent code (e.g. seccomp) already expects. 5. As per the defined semantics of syscall_get_nr(), only the value -1 is defined as a non-system call, so comparing >= 0 is incorrect. Change to != -1. 6. Call sys_ni_syscall() for system calls which are out of range except for -1, which is used by ptrace and seccomp as a "skip system call" marker) just as for system call numbers that correspond to holes in the table. 7. In , factor the PUSH_AND_CLEAR_REGS macro into separate PUSH_REGS and CLEAR_REGS macros which can be used separately if desired. This will be used by the FRED entry code at a later date. Changes from v1: * Only -1 should be a non-system call per the cross-architectural definition of sys_ni_syscall(). * Fix/improve patch descriptions. --- arch/x86/entry/calling.h | 45 ++++++-------------------- arch/x86/entry/common.c | 71 ++++++++++++++++++++++++++++-------------- arch/x86/entry/entry_64.S | 4 +-- arch/x86/include/asm/syscall.h | 13 ++++---- arch/x86/kernel/cpu/common.c | 12 +++++-- arch/x86/kernel/head_64.S | 6 ++-- 6 files changed, 77 insertions(+), 74 deletions(-)