From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 0676D1F03C7 for ; Tue, 7 Jan 2025 09:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736242916; cv=none; b=sVwOIO5SyFo0QSjiWd9vq6N82mF4bp3LCnurqP6pKq66uYCtHisxdN4Nh1Y8ygCmtsjbzs4aFSS0q3AZx237fFfo0YJufmvu0GxwR19Rv043BxSCaWgr2NKn89Dl6lqgEQVChgh8WX1j8f8jujX0X1GMxDXcBHTV9Eraeb/yA/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736242916; c=relaxed/simple; bh=a3NYWgzXkYBPZFv34/0xZT77OvLwlQr9cTHSDaRgd7U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ozxAr0ybRQPQPx2OV8LfHIzEvlFWMAfYgFLNlHXXL9hH3h1PIF5pncWUvYUnZ2+PsbuOX8g8LrXguF2WM/zWNgxrGww7Q44YQpYE1QNSht6FxmcqMTsJ/cxW56R9SRY6PEhjMdyq9To0c8FnN5ZkKE6/hPvevg3cah3MWq9bAD8= 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=tsunp/jG; arc=none smtp.client-ip=209.85.208.54 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="tsunp/jG" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5d34030ebb2so10625299a12.1 for ; Tue, 07 Jan 2025 01:41:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736242913; x=1736847713; 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=Pj8/SaLudo4NEJ77c2SgPAbc3BlZnt/7rdnxCBQ6AWg=; b=tsunp/jGxlk05OlSOl90MZvzKcv/cEtXA4SSrrzfXBCz7ZMNDExDAkeYuzKa5PdTz+ ZeHB7lbcavJrMs56j8TzI/bieJl7+23CwOEYM7HD7zh0HpIt8L0ea0hOU42W9iXbycDf w6ftGRKG1tV9TQAoe1ELlUyIRdJmuwklzrvSJIzk6qJ21PPuH7saIUV4ayGgZyjRxnKB L1P4jz03/heDFcOarkpXduuUHwl6W704aJpAvblH593b3VzPEnfOYrZWVUQfJk8UjEkE tmZRUE3cvNmc703RBsmpTbTR3Gr0C5JqoAbGTb097Gz7B9tQyteD+K8GBND3z/cvGXAU 1DjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736242913; x=1736847713; 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=Pj8/SaLudo4NEJ77c2SgPAbc3BlZnt/7rdnxCBQ6AWg=; b=B+Ncwbw1WlrNXE3HENEvT+lRqliXgpOIxRy0q15/UTJl5E4ZM1mTruIAKJXO/k1R08 i0rqhgwzi03j5C4O3X0DIPFt8fO2AWLXvJ/dsP2kKFQsYdyOmNUEp2XSXLMagBsSBt7b pUio3NjnlMrlfZXi9KSP7qLevhMopIwwGBTt52FGoSvdYvIeAK3JCMquaqNPXD3n3Y3t cU/+QpqTwmAmj+SgmD5gfJjVhDtKSoZDUaVt6o+Hj3L7JrHrmCv3WcUkBPUY1NFZ50kK PTVYkMZzVnSh/0Ln0LJaxYo4UU+fDdSbbzfd1ypbzQHvJNMMVUhzmCL1H3NKKJIAUD8Z l6gg== X-Forwarded-Encrypted: i=1; AJvYcCUkkxYDkvw5sQM+LHrFjuJzZRwK6DPQzejyG0AA8j1oxJDISiOvHypz4k7eUYKSyynjHjDvZhtf0Pjq25g=@vger.kernel.org X-Gm-Message-State: AOJu0Yyj/NYohXcrd8p52RqWGEhZpkZvqnVoSnst56GRD6iA0e1LA6bA Dy7coWy8NgeKlDA38m+deyeOIkbfIsK+a5af821itap6378RZ3MGxI+UxjF7JRcLitZddNqBEOS jYbs= X-Gm-Gg: ASbGncsOjCw9yZLM8PngI/FsS5f35obl8rcrdUMsX0LPvFBNU8HKZr6dkmYLqzVoIm6 mp6qd5HQ8f+XzKgcpPyzzsVVql/KGhdvNPhwYFSo6jVzsh91ncbnjjVjKXV/nrcMC32MmQ7O1U7 nPo3OE1YMJASC0q5VeiltDDT8WKxqAzfgKXx3suyT5OGmnyZ8SPjjQnW5sUTMGLOldFpLpeMTNc OXAlSRqHz/dd6SMZ79Bz+65sBYCYoVKB1Dfg2QOQeJ65lCE7fZSnf+vG2bPV9yBbus= X-Google-Smtp-Source: AGHT+IHVxLk0EMwczs0Uxehy2LL79n8I1psLDTVXxkeoAqQionVlmgUKTFWz0Wz6ph/R5/p8X73BAg== X-Received: by 2002:a17:907:318c:b0:aaf:ab6f:da49 with SMTP id a640c23a62f3a-aafab6fdc82mr1319882366b.39.1736242913302; Tue, 07 Jan 2025 01:41:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 01:41:52 -0800 (PST) From: Linus Walleij Date: Tue, 07 Jan 2025 10:41:36 +0100 Subject: [PATCH RFC v3 20/30] ARM: entry: Untangle ret_fast_syscall/to_user 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-20-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 return to userspace is a bit hard to follow. To prepare the ground for further refactorings we rewrite the functions to ret_fast_syscall and ret_to_user are mostly stand-alone symbols. Signed-off-by: Linus Walleij --- arch/arm/kernel/entry-common.S | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index d27e34d7e97a079d62e7b778cf7cf97c302e4763..ece9215717143427de7572a18a6dbe620a9193e9 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -44,20 +44,23 @@ ret_fast_syscall: bl syscall_exit_to_user_mode ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing movs r1, r1, lsl #16 - beq no_work_pending - UNWIND(.fnend ) -ENDPROC(ret_fast_syscall) - - /* Slower path - fall through to work_pending */ + beq 2f tst r1, #_TIF_SYSCALL_WORK - beq slow_work_pending + beq 1f + b ret_to_user -slow_work_pending: - mov r0, sp @ 'regs' +1: mov r0, sp @ 'regs' bl do_work_pending - b no_work_pending + +2: asm_irqentry_exit_to_user_mode + +#ifdef CONFIG_GCC_PLUGIN_STACKLEAK + bl stackleak_erase_on_task_stack +#endif + restore_user_regs + UNWIND(.fnend ) ENDPROC(ret_fast_syscall) /* @@ -74,7 +77,9 @@ ENTRY(ret_to_user) ENTRY(ret_to_user_from_irq) ldr r1, [tsk, #TI_FLAGS] movs r1, r1, lsl #16 - bne slow_work_pending + beq no_work_pending + mov r0, sp @ 'regs' + bl do_work_pending no_work_pending: asm_irqentry_exit_to_user_mode -- 2.47.1