Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6144099rwl; Tue, 4 Apr 2023 08:24:10 -0700 (PDT) X-Google-Smtp-Source: AKy350bKgmdoW+McIKtoj2tLLzcUuKPZHI6J064kuhiUOzPOFCSUXy9Yarc8i5eQL0AORQ+u8On7 X-Received: by 2002:a17:90b:4a10:b0:234:5eb:2177 with SMTP id kk16-20020a17090b4a1000b0023405eb2177mr3699948pjb.9.1680621850448; Tue, 04 Apr 2023 08:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680621850; cv=none; d=google.com; s=arc-20160816; b=dTGkK2r/orGpDTgKC4C4/HNeb9wGZwf9O3KEcyOPqBOnf9mKfwfABoiPxYXtvUuofb wkyr6TALiNGSjA9gI88BoOhkDtQGGwQh/jrwqhUCD9Hvov39mwkN58PsMCrimmaZr22e IYAH8MJEigPTV9L0VBHdCsXKQWsZWJJCTjhPBhTroykwTst5u/kVUFkCpqY/51y0xy9d lo5PBkzBbfnw6GgAGqR2Nxc857RJJAm7tYoKmQIOhaF8hmVwSVyoxledZPQLcOXTvVtN GIRKjTubFq9wg96am6ydwyYrNkx1y2Ys7ZgZtqJcKFOvxoNTykXJvxv7wrbLy6EhIPL0 RUUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=rU3XUVuY6TMVOFPxj7L5piHWt9qTLMDPnH8MqcGTj9A=; b=OLSj558oSDby7XTY4Kuaw2mZrRyDGmF/PnXMkL/ngfqpIxUiw44gwsvTMtT7BfgJkP ioMeB77GDfXgk5pnnX+zLzlw3w6eoCUeVh1KzePR0UbExlnz6AcrDGUswHTLJAUyKa+2 cGAHU+MbXiCJbbXNW15WNc9BQ/0g1hOHqrya08BqCLTpGO5ztBVSWJUyIc+zJMPZ42mD e2ZP+noxiZLGrKe0ppsIU4MU4gQ7GwGF1My9HKQ2kaGZy1Lh4omJWyfTR/2/JxvBT1pu RIDzW155TFdyycTdGQA8o8XpZsndYxUw7u/cHFeF7nW07JMAv77QpBF3wDRiEdEGsDGS Cl4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a17090a65c700b0023b4158aaf1si9834312pjs.62.2023.04.04.08.23.11; Tue, 04 Apr 2023 08:24:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235282AbjDDPGu convert rfc822-to-8bit (ORCPT + 99 others); Tue, 4 Apr 2023 11:06:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234826AbjDDPGt (ORCPT ); Tue, 4 Apr 2023 11:06:49 -0400 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 622E43C2F for ; Tue, 4 Apr 2023 08:06:48 -0700 (PDT) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-544787916d9so618566787b3.13 for ; Tue, 04 Apr 2023 08:06:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680620807; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KwzDPt+9Axnp6bNzN+6EpAA+HQRFVNX7yH6ulz2lZ88=; b=qgaR7eW0kJgtUewGlR8rFg1TY2t2Rd+EoSDVC8kqrCSA3GweazF3yzWAQLFV1+DwtU I4Owu0mjth/1ezL3Q2w99GzBAmYUUczyKD1mkO+h+p4bTY6eSXluzAyqIas0l0mjiXMV ho+VyHeiFYrubFqEmFne2h5BFeSFfWqbGuZS2YsRt/PEzYomL+9qJvtSib9WbdyQyjW4 B7VIXoaE844CbhgZokq9ENgKRtYyAkr6nyGLt76PT3Gnm9sW4d3HlAFZoOuoc5bjTY+8 pBHJnSxqWuu6Y8nTBg7ArYJKIsV+fcWPHAt3aYEl4vFrpk2x9yxwEX9EBX83skgSSNnr ieIQ== X-Gm-Message-State: AAQBX9ciygBV5zMr9+L3tWjwPOtDCkfwJTrhQM+34kvUZyT8WPA2J0n6 QjJMhGlCINFDb2zuQLhp96zfE2ksW2CPsZ5A X-Received: by 2002:a81:6c10:0:b0:536:cb48:9059 with SMTP id h16-20020a816c10000000b00536cb489059mr3209248ywc.50.1680620807274; Tue, 04 Apr 2023 08:06:47 -0700 (PDT) Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com. [209.85.128.174]) by smtp.gmail.com with ESMTPSA id dg3-20020a05690c0fc300b00545a08184fcsm3200872ywb.140.2023.04.04.08.06.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Apr 2023 08:06:46 -0700 (PDT) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-5463fa0c2bfso288705277b3.1 for ; Tue, 04 Apr 2023 08:06:46 -0700 (PDT) X-Received: by 2002:a81:440f:0:b0:545:5e70:323f with SMTP id r15-20020a81440f000000b005455e70323fmr1593040ywa.4.1680620806640; Tue, 04 Apr 2023 08:06:46 -0700 (PDT) MIME-Version: 1.0 References: <20230403065207.1070974-1-bjorn@kernel.org> In-Reply-To: <20230403065207.1070974-1-bjorn@kernel.org> From: Geert Uytterhoeven Date: Tue, 4 Apr 2023 17:06:35 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] riscv: entry: Save a0 prior syscall_enter_from_user_mode() To: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Cc: Albert Ou , Paul Walmsley , Palmer Dabbelt , linux-riscv@lists.infradead.org, Guo Ren , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , =?UTF-8?Q?Heiko_St=C3=BCbner?= , Conor Dooley , Yipeng Zou , linux-kernel@vger.kernel.org, Palmer Dabbelt , Heiko Stuebner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 3, 2023 at 8:54 AM Björn Töpel wrote: > From: Björn Töpel > > The RISC-V calling convention passes the first argument, and the > return value in the a0 register. For this reason, the a0 register > needs some extra care; When handling syscalls, the a0 register is > saved into regs->orig_a0, so a0 can be properly restored for, > e.g. interrupted syscalls. > > This functionality was broken with the introduction of the generic > entry patches. Here, a0 was saved into orig_a0 after calling > syscall_enter_from_user_mode(), which can change regs->a0 for some > paths, incorrectly restoring a0. > > This is resolved, by saving a0 prior doing the > syscall_enter_from_user_mode() call. > > Fixes: f0bddf50586d ("riscv: entry: Convert to generic entry") > Reviewed-by: Heiko Stuebner > Tested-by: Heiko Stuebner > Signed-off-by: Björn Töpel Tested-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds