Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1096822rdb; Wed, 6 Dec 2023 08:29:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEozGVss6IlOmaGeRaZTIgZabjCD/idmQkowntLUffaQBvupci3U80G85HROo/lgh559RXC X-Received: by 2002:a17:90b:4f4e:b0:281:d84:a97e with SMTP id pj14-20020a17090b4f4e00b002810d84a97emr1481141pjb.2.1701880155128; Wed, 06 Dec 2023 08:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701880155; cv=none; d=google.com; s=arc-20160816; b=Gte9RepbrDDgLEJsKXLn0SVDbIr61kCfTiZXF9BSuZ8yKUIpQQt/MnRqwVqlSTVIY3 3qVA5JVYVc2AfEiG6Z60tJE09MbpGQO6Z4dGhFTP7Luff+L2P0EPExInKB4+Hx96VBeS NVn2yELc0sGJzZrIqs4Az62E7Kzos/BFGBjUbIxexZ1bScc6Zte74ljYW6fmilB+DJVr Fkts6zDm6n8BgyRA1IxIJBQxDtuZYLIoZ1Vv6y9RlrCINDH5ScFDAwY6J/gLKnfXvf5F v9+PfbAy4YyoLnKKjJlbKnXAm2wSBZ1zlIrYQI/gJOZbv8lmvPYae8JwSfrrShqv7KaS 2Gmw== 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:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=B5ZbGGmoH/lFlZhMRZN1vjFtS/EFqjm5PsB2wakbCe8=; fh=n1XjXj719Scq01PKQBy1DpxpwpBy6bbIT3/n8Njwgwg=; b=Kcx5wXsA9aFEG+la20ooA5JCT+Zo52Jee6gKiGgyxg4coLUL3JL2bhxgXReGbOIP5e eto0TTb2X3tSS9UZhRBqDGywnlCtdZ6o0Dnztw6assyIC295IwMFJapPy9/8BOgtZKZl zoHPhwCJK+/hCPyn6WOe1NQ45X8x0gsZb1Dxk8KnSe1jutSMDvhtH1xGIsaUI7XPtENu QoskQiSCKtFOKrpCqbV+9Lir7j2hwhwZjTYd3T6wijdqNGQwkn98d5FO2vt/iqAOi1rK Mepxe1VPW31asDVaDjCLDUZWMLZrXX03URfrq0UMbaExCCzL0u9bfCuhbHlB34+OMu0P k40Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=JUP9Q7hQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id nh2-20020a17090b364200b00286e8838b6fsi84101pjb.119.2023.12.06.08.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 08:29:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=JUP9Q7hQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id E89F8826EEBB; Wed, 6 Dec 2023 08:29:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378023AbjLFQ25 (ORCPT + 99 others); Wed, 6 Dec 2023 11:28:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbjLFQ24 (ORCPT ); Wed, 6 Dec 2023 11:28:56 -0500 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 924C3D44 for ; Wed, 6 Dec 2023 08:29:02 -0800 (PST) Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6d9ae075e5fso495828a34.0 for ; Wed, 06 Dec 2023 08:29:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1701880142; x=1702484942; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=B5ZbGGmoH/lFlZhMRZN1vjFtS/EFqjm5PsB2wakbCe8=; b=JUP9Q7hQu9MmC8qT+pvq4Rvvq1eyIaYqOLTyljMFCuaeJS7pJri5kF+MfbVN26lg8h NbQAtypwudwKwgAnl4F2e4YIGPKgeXQvCYWKRhvhrePNzfDBNQjnAmx3w0yttDn3Oh3u ELEA6s41uIP/aJhbtXh+sPC9yDZT9uIzzw8hYMBOlmldIVohtdFSayFtHKXNaNvqL5pG 9tblrpZ2IEvFHK9wSOzSLLFgV4RzVHl/wk4ZebAjuD4uzFEHnsFLXVCabYheSQxM0mcF YHN8LrpFy1MRsuxZMFzIztIK7s5iEy3vvBvlIQEWH2LK3ZJgZDe+ojzcDzEyyNwMYljO 5Fmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701880142; x=1702484942; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=B5ZbGGmoH/lFlZhMRZN1vjFtS/EFqjm5PsB2wakbCe8=; b=q8k+lSms88OqR/t389FDYUMlFGtmqA0jOgee4G9i2D8O8pW55fT5j63yf30WYrwfO5 2d/gECgI4AArpdfJxpL6KVBHVahNlCI7ZPfKHhpa6Vitt1z5x41hXVMPa+yTGNVKcJ+X 38qUHThWv0baslRb1j7t2YDdDQXnRxCaNUXFnLiTx83W+hFXOPaWKgnXH2jfPa5un83e 7QvgzMO6Q/9DpNVpBFoNqPaTpS3efesUfqruyT1sFH6Z/fRoxB2Njt17vsLoNe8SxW0v W0ZZnhr+sCW2D//3Z7KYGW0qj+BmuFrql/dTmjxAiuD6O7x8yZ8CKjYP9YJnNB2z65MB MnyA== X-Gm-Message-State: AOJu0YxbDJGNaP7CQxhB+FHVRX3sDRrbrrio6DbXyzZQdmI2MwLvK0FR goyhYaTa7aXCb5RshZA50QQ3QA== X-Received: by 2002:a9d:6385:0:b0:6d9:9ed9:f0e0 with SMTP id w5-20020a9d6385000000b006d99ed9f0e0mr559336otk.14.1701880141802; Wed, 06 Dec 2023 08:29:01 -0800 (PST) Received: from localhost ([192.184.165.199]) by smtp.gmail.com with ESMTPSA id c25-20020a9d6859000000b006d9a0bf775asm24697oto.7.2023.12.06.08.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 08:29:01 -0800 (PST) Date: Wed, 06 Dec 2023 08:29:01 -0800 (PST) X-Google-Original-Date: Wed, 06 Dec 2023 08:28:59 PST (-0800) Subject: Re: [PATCH v2] selftests: sud_test: return correct emulated syscall value on RISC-V In-Reply-To: <20231206134438.473166-1-cleger@rivosinc.com> CC: shuah@kernel.org, krisman@collabora.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, cleger@rivosinc.com, Bjorn Topel From: Palmer Dabbelt To: cleger@rivosinc.com, tglx@linutronix.de Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 06 Dec 2023 08:29:12 -0800 (PST) On Wed, 06 Dec 2023 05:44:37 PST (-0800), cleger@rivosinc.com wrote: > Currently, the sud_test expects the emulated syscall to return the > emulated syscall number. This assumption only works on architectures > were the syscall calling convention use the same register for syscall > number/syscall return value. This is not the case for RISC-V and thus > the return value must be also emulated using the provided ucontext. > > Signed-off-by: Clément Léger > Reviewed-by: Palmer Dabbelt > Acked-by: Palmer Dabbelt > > --- > > Changes in V2: > - Changes comment to be more explicit > - Use A7 syscall arg rather than hardcoding MAGIC_SYSCALL_1 > > --- > .../selftests/syscall_user_dispatch/sud_test.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/tools/testing/selftests/syscall_user_dispatch/sud_test.c b/tools/testing/selftests/syscall_user_dispatch/sud_test.c > index b5d592d4099e..d975a6767329 100644 > --- a/tools/testing/selftests/syscall_user_dispatch/sud_test.c > +++ b/tools/testing/selftests/syscall_user_dispatch/sud_test.c > @@ -158,6 +158,20 @@ static void handle_sigsys(int sig, siginfo_t *info, void *ucontext) > > /* In preparation for sigreturn. */ > SYSCALL_DISPATCH_OFF(glob_sel); > + > + /* > + * The tests for argument handling assume that `syscall(x) == x`. This > + * is a NOP on x86 because the syscall number is passed in %rax, which > + * happens to also be the function ABI return register. Other > + * architectures may need to swizzle the arguments around. > + */ > +#if defined(__riscv) > +/* REG_A7 is not defined in libc headers */ > +# define REG_A7 (REG_A0 + 7) > + > + ((ucontext_t *)ucontext)->uc_mcontext.__gregs[REG_A0] = > + ((ucontext_t *)ucontext)->uc_mcontext.__gregs[REG_A7]; > +#endif > } > > TEST(dispatch_and_return) Thanks. Thomas: looks like you picked up all the commits that touched this? No rush on my end, just LMK if you want me to pick it up -- I'm going to leave it alone for now.