Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3887448rwl; Mon, 10 Apr 2023 02:43:34 -0700 (PDT) X-Google-Smtp-Source: AKy350ZCvRD7Vitr+n4JdF7+ozgCKtY/JLW2Y4djLG4pUexZg+A+AREz7R+hAlLplCrVBGHfCdtY X-Received: by 2002:a05:6a20:b555:b0:d9:2028:dfd4 with SMTP id ev21-20020a056a20b55500b000d92028dfd4mr6756293pzb.19.1681119814605; Mon, 10 Apr 2023 02:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681119814; cv=none; d=google.com; s=arc-20160816; b=hbTestJT8cLhd74gX2MXjA+/OtOqBcFAP0HQqCinKdHI90l0/2u3rWrQONYD+h+hsQ 5G3mDfL3WoG2u090Vln6ASoZuwKVX9gIqccdNPF/ogO+M69U9Ux80ybVoeTlbuVdFnT8 c5T+AZqCJeTYD7H7bgUzu2XA/xUJpSagunLUXZ8V/OTDbQjpml4q4UhuFAAEIZK6vonq 2wJUgDZ2fCgscAJqBMd32UThy8Q/eH//HmrLly3jO8M8rKwxh98KqyCtuBvk4cD2vAbp F1CrCQJV/ZPngdCgXHnpRxpXqQb2nkcYPdLTrmBlX1OJVZ/r6ly+gE/rvyUEb5li0Hg8 LwWw== 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 :dkim-signature; bh=F6HIMp5HPIYwzx39Zs3ERp+4XjFzUpn9IkIJmmm8N5g=; b=e2AKCoeFfkd2DHjeFmUwCC340nCybj2R/5Q7dks9p4E5prXo+8Y4yFej7ec4fo/gTv p+UVdmUDSp9UV9ujUr13j/BSnWmB0ZTcDB99JKzhHv9I58zAhcANkB1zsisbiBUqjVvR HKBmbIqzjgwvO1mUR90uB1+9E3bwFt/hAldE5F7iH5Fj2OxQpCjeiETqvnJJTMT7fFj7 K63FbF1jrPM3sk761VWFpDSFn9LMCxolHn+cufzeNKz+ikUB3qnGpDmh7RCgj8LvY2X+ pnK8sdtzC+29fryviHJn+bdug5ypzPDQXQPIs3GtCnR2nrQyiUyCvq1vPnkCv5AadASh WY2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=kTa1s8Ob; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sifive.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a63e44e000000b0051392b219dfsi10884790pgk.334.2023.04.10.02.43.23; Mon, 10 Apr 2023 02:43:34 -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; dkim=pass header.i=@sifive.com header.s=google header.b=kTa1s8Ob; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sifive.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229535AbjDJJmM (ORCPT + 99 others); Mon, 10 Apr 2023 05:42:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjDJJmL (ORCPT ); Mon, 10 Apr 2023 05:42:11 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 509A01FDD for ; Mon, 10 Apr 2023 02:42:10 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id be27so4743485ljb.12 for ; Mon, 10 Apr 2023 02:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1681119728; x=1683711728; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=F6HIMp5HPIYwzx39Zs3ERp+4XjFzUpn9IkIJmmm8N5g=; b=kTa1s8ObzL4x/scAUIpJ5lnCr3TBiHpj8kYi+LxKtdJi5MlPMYRV6fk5+XFsisYuWQ e3lDPNPGSxDtqEUomY77DWJNbyyehG8TRP4t3CvYblUwhNDnir8+TYvPQMS5FqEYxHdX h6cv75u9H4BEiGWMghObNIFHErPcWHQUfScn8nvb8BddTfqxAM8A8ZE0ghYNsC+dcc/3 TH2hXdVb6vN5/jKkI6FbZgdole8hP+pslpBmxYs9DzrnkiijnPrc1AC22/x9uuXZwNAj wHzZTzxxg4rGn3KKH8UGweCQ1lnVu5TTp5WsjPwrqJdQvYqk+lrWFVdZSHJDRUGWhOTy noUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681119728; x=1683711728; 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=F6HIMp5HPIYwzx39Zs3ERp+4XjFzUpn9IkIJmmm8N5g=; b=JjxlXy2KjZQDkw7wyk43/mEHD70t3bzJ/Y7F97XNa05GBY0Km4oWqnl3QSPN6JNZPo Um4A1OB5kd/lBOuGmWQMScbjfFdjjerfFyU5HNsFhcp5PO7v5xGGFjCYDHMDm20afVhi lwnKilPbOFfaECsH0Egru7ozPTczmVJTutFLcop/iEmzJXSIVLzCg5aW5p+qZrh2ZKcf XFTOoJe98yUY4LqAgElunBR+IMAI+7M8eDw9Z/uarX16Sxhf89rcDvqnqz+Ut3yDVs5J Rcu2WOfsjfovJc1OBwJKM9F3CnpHlVRiWPTswvcYjNGT9cRkYfJjPfc2I+s3Hq0lusWs BPyw== X-Gm-Message-State: AAQBX9e1xVM54YSbGuQ9L8+j6k05NbT7+/6sFVfsUi+rq+VW/6iu0CwJ QXIP63vYWkOlvhCjTHswpUQZxfj7vK0B0YGhA5pGhQ== X-Received: by 2002:a2e:9f44:0:b0:2a6:18c0:2b3e with SMTP id v4-20020a2e9f44000000b002a618c02b3emr2659377ljk.0.1681119728564; Mon, 10 Apr 2023 02:42:08 -0700 (PDT) MIME-Version: 1.0 References: <20230403065207.1070974-1-bjorn@kernel.org> In-Reply-To: <20230403065207.1070974-1-bjorn@kernel.org> From: Andy Chiu Date: Mon, 10 Apr 2023 17:41:57 +0800 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: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 2:54=E2=80=AFPM Bj=C3=B6rn T=C3=B6pel wrote: > > From: Bj=C3=B6rn T=C3=B6pel > > 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=C3=B6rn T=C3=B6pel This fix works for me, thanks! Tested-by: Andy Chiu