From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9150C1F0E2B for ; Tue, 7 Jan 2025 09:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736242921; cv=none; b=PcqkYQdYzB9DdoEka5l3FPCWltQFylryvjjbpXqBKesgasnrDr82z9o8svRpst40pn50zaZV6avWWtIgyC/AbrzLsiJpM4HWakPhlwOt9FcvmfHyrgfdgQJg6J8YGHJAwCfxaAzTzcrJyDKvxTQnNRxQ9B7iP9nOCNYD5UUigho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736242921; c=relaxed/simple; bh=w4/wJPwzx6ZalJ483q/QBSNJnPg/wX8zz8MMNeaHOgU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ImzFHZmfx+f0nQE5hWlRfx2WujJCr8bCZ+pWM0teF/82FuNVNpmtKoErSHIqdc7zbgwp0nklLVZ6LZOdHZwklAWanbbXLtXkPaCdWoTg8VfQZlHmb9io5YR132WRHk6ojocuY9Px9Po/RWoJ6l2JT0VA9Znbu6U8FiWSMQPF2lc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ilBfRKvT; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ilBfRKvT" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-aaeef97ff02so1919389366b.1 for ; Tue, 07 Jan 2025 01:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736242917; x=1736847717; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1fSpPlBqZE2GxPZ8aqxBgZ4u22dj0xDyR7PMf5d8jHM=; b=ilBfRKvTZfBIbprrGWxlZ49vzcw6lbJqda9QLLd4pR+UZ57fhf7URssdHiNM9z8vwl blzA0neuJobAciReAD+XVmgpSN8mcOaFtTUK9bYjRj3JucMhKL87r1uB61Oh9Xkg1tbY db5JXZne+25yXrsBfT7ucdiKWj4AwRO5MMei37ITBHCxWYbUtib62HbTm7hNiWuXappY vWEZwySJba9FLmwJbZvGv6rlFSVKv5Yr+sE1Ph7qc6eHsVMzeotxPBiZ9SJH26COarK2 pB3Ncop6mh0OtWfqGiYQ9MQk4VCs+xJ1uvkY4Cbu+FPUKSHaccEeSO4Rf7BMWeCHwVDd Amiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736242917; x=1736847717; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1fSpPlBqZE2GxPZ8aqxBgZ4u22dj0xDyR7PMf5d8jHM=; b=HW286AdNsFCLy4rr9WyzQCc3zumQeUxPKyObqgKGT4MJENxFwGHRBvSqiWhurIZ8Mr jGqnREb2kzT4yKw2kMgsNYcug8g/UQaKIkybcVNdyHDs8vNvAx/ja1dTXM3uES8R6Mke /TR0tNx55oQsBVHA+IU6Ef7QqefVyuWNrHbHoAyGhzGLebHqGQrwzbzpQYC8BhSqNK0N 04k48PUskkMnFGqhYuZ/RGVLpE9qaaeV7otKumSYXnBxcutjrzjqhN9gc9cuCFx5uUyP T932LeDktERfJ7o+0e8MP0nJysoWsI79hKiQHNn7cpoDWsF5CegxhyOdbBQRgcsbKBQe adGA== X-Forwarded-Encrypted: i=1; AJvYcCVfV3i5fcx8pOYwwxFgX9uFSdve4Le2ZdEfeHZ1fa6hkD33rjSDPj7D9EyzoBbznqmZo14e+DLZKhgjSyI=@vger.kernel.org X-Gm-Message-State: AOJu0YxufuSAwiYPdCIGF8nqolovxLQ7YLsUD/0TmWfLkS5aci/ywCnJ MFbJh2FpeBytjK6G5IMG0uSh1Ehl9urkBqErC2mKfDx2+uFJb0RbtlLFVz/b0eo= X-Gm-Gg: ASbGnctSXTIK98fkA0A3Ut+W5S6Sx7yph9fbQgj24pARNCeML0HUUsk95C8j2US/P+v dSQOyU0GIfvgff8gqB4/FNyqburbQYavl1Fk6mfxr1ZNl/JqXXzfrH+zS4XwkNBBtQLnEdPF0F7 I89xOJU1X3uUgnmmfAVLeDHoHtsZkR5SAfEIsWe+DzaL4cBEprsirwtc2e5xeVr4Gruyeib/vfz JFWbje1W2GyR2YNCIaPvvNfPA3QbINwfdGvPsVzArMzEUukCCygSPXflX8mjIos7S4= X-Google-Smtp-Source: AGHT+IH/dI1PxCW+yp4QARSJfd4dkKI+h1pdEwCvQ+1RIosRFpfUhuopq0xYZv8q0GQqsFrKty0/6A== X-Received: by 2002:a17:907:96a7:b0:aa6:3223:19e6 with SMTP id a640c23a62f3a-aac345fabc9mr4954124166b.60.1736242916794; Tue, 07 Jan 2025 01:41:56 -0800 (PST) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aac0f012229sm2356901166b.133.2025.01.07.01.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 01:41:56 -0800 (PST) From: Linus Walleij Date: Tue, 07 Jan 2025 10:41:39 +0100 Subject: [PATCH RFC v3 23/30] ARM: entry: Stop exiting syscalls like IRQs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250107-arm-generic-entry-v3-23-4e5f3c15db2d@linaro.org> References: <20250107-arm-generic-entry-v3-0-4e5f3c15db2d@linaro.org> In-Reply-To: <20250107-arm-generic-entry-v3-0-4e5f3c15db2d@linaro.org> To: Dmitry Vyukov , Oleg Nesterov , Russell King , Kees Cook , Andy Lutomirski , Will Drewry , Frederic Weisbecker , "Paul E. McKenney" , Jinjie Ruan , Arnd Bergmann , Ard Biesheuvel , Al Viro Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.2 The syscalls are issued as software interrupts, and to this point they were sharing code with the other exception handlers, but this does not work with generic entry. Make syscall_exit_to_user_mode do what irqentry_exit_to_user_mode does at it's tail, and drop the invocations of irqentry_exit_to_user_mode from the syscall path so that these are now exception-exclusive. Split ret_to_user and ret_to_user_from_irq into two distinct execution paths. Signed-off-by: Linus Walleij --- arch/arm/kernel/entry-common.S | 14 ++++++++++++-- arch/arm/kernel/entry.c | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 5385574c4339714f3d8b5ab6894f27466b89f932..e2ac6d3216b6828d948d60c424ff95ccdad12331 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -42,7 +42,6 @@ ret_fast_syscall: /* do_rseq_syscall needs interrupts enabled. */ mov r0, sp @ 'regs' bl syscall_exit_to_user_mode - asm_irqentry_exit_to_user_mode #ifdef CONFIG_GCC_PLUGIN_STACKLEAK bl stackleak_erase_on_task_stack @@ -62,6 +61,18 @@ ENTRY(ret_to_user) enable_irq_notrace @ enable interrupts mov r0, sp @ 'regs' bl syscall_exit_to_user_mode + ldr r1, [tsk, #TI_FLAGS] + movs r1, r1, lsl #16 + beq 1f + mov r0, sp @ 'regs' + bl do_work_pending +1: +#ifdef CONFIG_GCC_PLUGIN_STACKLEAK + bl stackleak_erase_on_task_stack +#endif + restore_user_regs +ENDPROC(ret_to_user) + ENTRY(ret_to_user_from_irq) ldr r1, [tsk, #TI_FLAGS] movs r1, r1, lsl #16 @@ -76,7 +87,6 @@ no_work_pending: #endif restore_user_regs ENDPROC(ret_to_user_from_irq) -ENDPROC(ret_to_user) /* * This is how we return from a fork. diff --git a/arch/arm/kernel/entry.c b/arch/arm/kernel/entry.c index 0e3960844b94b14325eb00ce7dd791b36c43ac3c..88a7a699306ab61153d57333c26266b9161f5466 100644 --- a/arch/arm/kernel/entry.c +++ b/arch/arm/kernel/entry.c @@ -30,6 +30,10 @@ void syscall_exit_to_user_mode(struct pt_regs *regs) local_irq_disable(); if (has_syscall_work(flags)) do_work_pending(regs, flags); + + trace_hardirqs_on(); + /* This context tracking call has inverse naming */ + user_enter_callable(); } noinstr void irqentry_enter_from_user_mode(struct pt_regs *regs) -- 2.47.1