From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 009F53858CDB for ; Mon, 26 Feb 2024 16:48:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 009F53858CDB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 009F53858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708966115; cv=none; b=tyBvQh0vmJPe7vXianBGQFTOc5NxPUmDPWQz+javq/FSUDu+Ama0weCHvE+gHKr2a6vXEPoBUsgNHOleRDBDKCazlZM1MGzripVR5SkZ8VGQqBnppCfTs4t8Ti/IAotF4zksMGJe87J0M1EFSuyQncjUq9ZV8J+W0sWmbponvWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708966115; c=relaxed/simple; bh=uoLt9s3EPtgkgA0lV0ayXXo5w47cJU3BKQphj8Y91vw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=R7FyQp0b26omOGBORSpi6kMZxv6CRj76+cyVybuqMhTnYZ57wulB0zGIHD3v2C4sI7RjeJdH3FrYDKSx7xsVmL7wRmreTq72DdYDl2wld6/NpTQ2xJ7fkZYz/Y+T6a7oaRamwHCH2q9Rwp+3fHz2eViLqKv/H8RYHYEpB6mWpS4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-512bd533be0so3928735e87.0 for ; Mon, 26 Feb 2024 08:48:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1708966102; x=1709570902; darn=sourceware.org; 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=xaZHiajv/kb2Po3M1UJY5W/IkyTe1myKzLfWu/iP7uY=; b=keYylW2/uFnEtL3cet5yFbB2JQXTpAfrsudHjxd1Pb5v/zlgjbU3p6c3dBgmi+tEqx r5/wibpgD5LmV6gGIqw2+Z6UXFqJJwacIRnTv5snq7X45NyAN0oXZmHrvTPdYoclzIs3 N7331j35Qybjz5haOniaL5M71DOEuUGvsINJNtJjETh4EftTu/O+hqfPpgdVm0CUlXDN 4viCatkslOte/lOERYMc8Sy+e9y5d9kKhvQ5XrK2gBN5bZGhZxybr/USSCRr/VxH1LDH aNg0LoFegO+e6eSDyEn8XVy30cvDLUDUoOhezOAuGyxKZeZVrzFVR7imtzjzZZ3k+Auy xeqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708966102; x=1709570902; 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=xaZHiajv/kb2Po3M1UJY5W/IkyTe1myKzLfWu/iP7uY=; b=Gh93CmOGWgsCqcvox8wYX02s+n/5mgUaeRDLeTH2XZz3xYxh5XRqMQglxST/Flg3DO 5XiX373/8sdFEM+gugcBpVbZSHN6X1QnMpuCDYIUb1hhGaDC6ZpAvX03NmKIN1stZw4R 1RRXDVSXEI1tdgYcfI2VFEKeYBD647pZXUqtbZhf51qbomdY1BMjGNwdvpfzjDICrqaZ pUhfeyWVu4EprjYVlDnT/4njY0We5Pl+LxyBn4Jyurv40UBvMC6tr0uFz/etfGnI1RKP 0IBdb31NcamZ5i7cXXDNfREUXHdDH3uGDsZ8SWqIOpbLshHu0ISsolAinazLo+fTU/ep RRQA== X-Forwarded-Encrypted: i=1; AJvYcCU6d0FhJ3ciELWaD1vxSDXqNIqld0ACX05Ou76ZtPK9DVHZyjShqHfvhN1tCFd2j+ifJzMes3v0W/16ejVArWpzAoaKDogQ9wDL X-Gm-Message-State: AOJu0Ywdu63rr2D10YQwcbmT8YUWBAelrK3TINLFGBfyGEtnUe2D+0IE jMoSruoXY4sybz+CTQMKmRiMMCxdoYuj5Qs8aCzFNzZIKFb4YQiQTXfA8hrzjTlj+9fqaVjPoRy VXLULqaooSiDv5FYVFenNGbXYSVr1VK3v3WWG3w== X-Google-Smtp-Source: AGHT+IEJTORj7RasJRcFKBhk3Yq8jUMuF761FWk0680Q/KfrXRA73wRJBAS6XCPJp+GyzM7DinZsEabNuPCAn1ikoNM= X-Received: by 2002:a05:6512:138a:b0:513:122:19a7 with SMTP id fc10-20020a056512138a00b00513012219a7mr1607448lfb.29.1708966102373; Mon, 26 Feb 2024 08:48:22 -0800 (PST) MIME-Version: 1.0 References: <20240214143159.2951158-1-evan@rivosinc.com> <20240214143159.2951158-3-evan@rivosinc.com> <877cj47t0f.fsf@oldenburg.str.redhat.com> <87sf1iw0nu.fsf@mid.deneb.enyo.de> In-Reply-To: <87sf1iw0nu.fsf@mid.deneb.enyo.de> From: Evan Green Date: Mon, 26 Feb 2024 08:47:46 -0800 Message-ID: Subject: Re: [PATCH v12 2/7] linux: Introduce INTERNAL_VSYSCALL To: Florian Weimer Cc: Florian Weimer , libc-alpha@sourceware.org, vineetg@rivosinc.com, slewis@rivosinc.com, palmer@rivosinc.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sat, Feb 24, 2024 at 3:40=E2=80=AFAM Florian Weimer w= rote: > > * Evan Green: > > > It's kinda awkward without the label because the regular syscall is > > made either if vdsop is NULL or returns ENOSYS (which is two checks on > > the return value, so doesn't lend itself to inlining in the if > > statement). The best I could come up with without the label is to > > duplicate the syscall_call: > > > > #define INTERNAL_VSYSCALL(name, nr, args...) \ > > ({ \ > > long int sc_ret; \ > > \ > > __typeof (GLRO(dl_vdso_##name)) vdsop =3D GLRO(dl_vdso_##name); = \ > > if (vdsop !=3D NULL) \ > > { \ > > sc_ret =3D INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); = \ > > if ((INTERNAL_SYSCALL_ERROR_P (sc_ret)) && \ > > (INTERNAL_SYSCALL_ERRNO (sc_ret) =3D=3D ENOSYS)) \ > > sc_ret =3D INTERNAL_SYSCALL_CALL (name, ##args); \ > > } \ > > else \ > > { \ > > sc_ret =3D INTERNAL_SYSCALL_CALL (name, ##args); \ > > } \ > > sc_ret; \ > > }) > > Indentation is off for me, for clarification: Yeah sorry I just pasted it into the gmail client, which mangles everything= . > > #define INTERNAL_VSYSCALL(name, nr, args...) \ > ({ \ > long int sc_ret; \ > \ > __typeof (GLRO(dl_vdso_##name)) vdsop =3D GLRO(dl_vdso_##name); = \ > if (vdsop !=3D NULL) = \ > { \ > sc_ret =3D INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); = \ > if ((INTERNAL_SYSCALL_ERROR_P (sc_ret)) && \ > (INTERNAL_SYSCALL_ERRNO (sc_ret) =3D=3D ENOSYS)) = \ > sc_ret =3D INTERNAL_SYSCALL_CALL (name, ##args); = \ > } \ > else \ > { \ > sc_ret =3D INTERNAL_SYSCALL_CALL (name, ##args); = \ > } \ > sc_ret; \ > }) > > ?: does not work because the comparison with -ENOSYS discards the > return value. > > Does this look correct? > > #define INTERNAL_VSYSCALL(name, nr, args...) \ > ({ \ > long int sc_ret =3D -ENOSYS; = \ > __typeof (GLRO(dl_vdso_##name)) vdsop =3D GLRO(dl_vdso_##name); = \ > if (vdsop !=3D NULL) = \ > sc_ret =3D INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); = \ > if (sc_ret =3D=3D -ENOSYS) = \ > sc_ret =3D INTERNAL_SYSCALL_CALL (name, ##args); = \ > sc_ret; \ > }) > > I expect GCC to generate decent code for it. I like it! I'm guessing I should continue to use the INTERNAL_SYSCALL_ERRNO_P() and INTERNAL_SYSCALL_ERRNO(), and you omitted it for example's sake. Will plan to spin with this. -Evan