Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp295138pxb; Mon, 8 Feb 2021 23:58:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5xiyYNoaWFNQ0DA8X34djPvxL8sp7w9p3lweBBXNhX+tv5d32lC318PGVBSOXIG954aCY X-Received: by 2002:a05:6402:3114:: with SMTP id dc20mr21425224edb.197.1612857536430; Mon, 08 Feb 2021 23:58:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612857536; cv=none; d=google.com; s=arc-20160816; b=sGVcM9RpSHqAVV6Am8fhqstDRLnrWR2lMQm73EbGBW6EKx5I3BJGJpCCLrpaTUXHNn r+P5m7jQ6a4eXcbAUe+D6agOpBkYjOuZQvUF0QnCqBG6RzLINUVRZwF2BTu6H1ASNuq7 G3RyM/Vk3FlYTzFLhKMNDlAmzoy9V9Lde7ZbfVhoUR4+R4uYUKu9ahGWfpzVZGmIaBDd IOQDOVg8G8D4c9y368b1EucY3x+n41be+ovt4te+KbQAJ9oz4P5LdG57euLrjagmr/ZT XNzkqtVH8vvDpW9DXAM46qdiU9KjHQvCZk873sz/DyRhkbTtv9R2gE2jUiqPLz7qbZ+t 9qLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id :mime-version:in-reply-to:references:cc:to:subject:from:date :dkim-signature; bh=IKtDbkpTW92/CPv0ahP5JLmJlZUSWpczGDc7m2oxTH8=; b=g9zFlW6WTI1rMLY6z+CIHCODJUAtwMiehA59QwxW67+ZHc2D6bzlsy/yEdTzdWGAI8 kkbsg+CfSZwG2ppWbkNOg1WR+wuM3CzKvR1F3sbHCXkhzRQhC4pBSAvFS5TOMcHqi7qi VREtm5kWjuinQh2MmWMQVBukJR+DAO5ax+Sn1hVTo09cxFzG8rTqLU/KP0FGSlZQi+zE PjlbFXXsl8S7VDj74qEYi8X/ZmEp3xEqzkBUyZCtMAIgioNDhmO6n+4XH4yTV75hQ1Sb 5Dwl74tJgv/m1D1LaajbnDTwNepwrvcxeAF/RVJsy9HAkGElDn0iiiYli+Eggt0f1SMe WEHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SkBJdGJE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c5si15245235ejd.228.2021.02.08.23.58.33; Mon, 08 Feb 2021 23:58:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SkBJdGJE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229636AbhBIH53 (ORCPT + 99 others); Tue, 9 Feb 2021 02:57:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbhBIH50 (ORCPT ); Tue, 9 Feb 2021 02:57:26 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCFC6C061786 for ; Mon, 8 Feb 2021 23:56:45 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id u11so9273146plg.13 for ; Mon, 08 Feb 2021 23:56:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=IKtDbkpTW92/CPv0ahP5JLmJlZUSWpczGDc7m2oxTH8=; b=SkBJdGJEHT4IkA/vrqy4/eKEYfeLuq/49hO/9zSk+FVJ6OD/YMaAB4WQN4PQ6peKc0 3bDvkqZUBcAFFyX8yOUA2LMWqC/TW8xf7aXYms8/f06DUCsXNQPu0GUK4O1SXMg5ADJj JTE5WPvK75VljUjWJ6asLKqFsIHvTWCC79oZMznWD+9DWQTOnvTp2CAny4RKqiyXruCI a0ZT4QJ+Juyj6EVXvL1V0AwUMfUBOObCwjaxVp8PXmJ69hHKSFU3oLwLa8jc6F5QGQ12 70Lj7so1IBFWLE4zNLdG8rH+M3E6DtsaLXj8vc/hJIsJfMT2INqEZdOTVFeVE4noosF/ ZDDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=IKtDbkpTW92/CPv0ahP5JLmJlZUSWpczGDc7m2oxTH8=; b=OUyXMmojDmpQ1sV9damjeh0ZKXJL9j9pc6F2V2pDEbMPgsbWy+NVFpN72M4h6WURhf xhDotATkAs4wLSdMXA3BFjVmrDj96DjOoI32NxUGpdEk0CHsy3MUePzkrNZhViq4T6Nz I+uQPo4KSvVNKtoMTU3bf9e+UhPIhYuiCZerea9+IYTYi9utbUSjPFVFM7/Xw96LG6KE UFV9D3+5sogZpBHp10g25qIZQ8zkpwEysuzuGgRGrf5Zqy+PP33ZyF0SrMiohA7CoYYy wVg1VXsMSw6KJ0bizmrv3FL1UQR33MRG1OFqzCAmY0bEq6E2iwnMjPhXe2APJHNFFyc/ gbSQ== X-Gm-Message-State: AOAM5315lQZ4Wd5qMHRUVfq4gSETlz8/oEMtFliBhWWmzzagbI49chRa XYxEAYo5vkfppGf/TJ394bM= X-Received: by 2002:a17:90a:6588:: with SMTP id k8mr2792812pjj.43.1612857405439; Mon, 08 Feb 2021 23:56:45 -0800 (PST) Received: from localhost ([1.132.144.180]) by smtp.gmail.com with ESMTPSA id n1sm6641098pgn.94.2021.02.08.23.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 23:56:44 -0800 (PST) Date: Tue, 09 Feb 2021 17:56:38 +1000 From: Nicholas Piggin Subject: Re: [PATCH v5 17/22] powerpc/syscall: Do not check unsupported scv vector on PPC32 To: Benjamin Herrenschmidt , Christophe Leroy , Michael Ellerman , msuchanek@suse.de, Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <1612835741.qmlhg8iwmj.astroid@bobo.none> <82c4abb1-cb52-e856-b2dd-d7c7d48bd292@csgroup.eu> In-Reply-To: <82c4abb1-cb52-e856-b2dd-d7c7d48bd292@csgroup.eu> MIME-Version: 1.0 Message-Id: <1612857042.f9qpgkdvz6.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Excerpts from Christophe Leroy's message of February 9, 2021 4:13 pm: >=20 >=20 > Le 09/02/2021 =C3=A0 03:00, Nicholas Piggin a =C3=A9crit=C2=A0: >> Excerpts from Christophe Leroy's message of February 9, 2021 1:10 am: >>> Only PPC64 has scv. No need to check the 0x7ff0 trap on PPC32. >>> For that, add a helper trap_is_unsupported_scv() similar to >>> trap_is_scv(). >>> >>> And ignore the scv parameter in syscall_exit_prepare (Save 14 cycles >>> 346 =3D> 332 cycles) >>> >>> Signed-off-by: Christophe Leroy >>> --- >>> v5: Added a helper trap_is_unsupported_scv() >>> --- >>> arch/powerpc/include/asm/ptrace.h | 5 +++++ >>> arch/powerpc/kernel/entry_32.S | 1 - >>> arch/powerpc/kernel/interrupt.c | 7 +++++-- >>> 3 files changed, 10 insertions(+), 3 deletions(-) >>> >>> diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/a= sm/ptrace.h >>> index 58f9dc060a7b..2c842b11a924 100644 >>> --- a/arch/powerpc/include/asm/ptrace.h >>> +++ b/arch/powerpc/include/asm/ptrace.h >>> @@ -229,6 +229,11 @@ static inline bool trap_is_scv(struct pt_regs *reg= s) >>> return (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && TRAP(regs) =3D=3D 0x3000= ); >>> } >>> =20 >>> +static inline bool trap_is_unsupported_scv(struct pt_regs *regs) >>> +{ >>> + return (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && TRAP(regs) =3D=3D 0x7ff0)= ; >>> +} >>=20 >> This change is good. >>=20 >>> + >>> static inline bool trap_is_syscall(struct pt_regs *regs) >>> { >>> return (trap_is_scv(regs) || TRAP(regs) =3D=3D 0xc00); >>> diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry= _32.S >>> index cffe58e63356..7c824e8928d0 100644 >>> --- a/arch/powerpc/kernel/entry_32.S >>> +++ b/arch/powerpc/kernel/entry_32.S >>> @@ -344,7 +344,6 @@ transfer_to_syscall: >>> =20 >>> ret_from_syscall: >>> addi r4,r1,STACK_FRAME_OVERHEAD >>> - li r5,0 >>> bl syscall_exit_prepare >>=20 >> For this one, I think it would be nice to do the "right" thing and make >> the function prototypes different on !64S. They could then declare a >> local const bool scv =3D 0. >>=20 >> We could have syscall_exit_prepare and syscall_exit_prepare_maybe_scv >> or something like that, 64s can use the latter one and the former can be >> a wrapper that passes constant 0 for scv. Then we don't have different >> prototypes for the same function, but you just have to make the 32-bit >> version static inline and the 64-bit version exported to asm. >=20 > You can't call a static inline function from ASM, I don't understand you. I mean #ifdef CONFIG_PPC_BOOK3S_64 notrace unsigned long syscall_exit_prepare_scv(unsigned long r3, struct pt_regs *regs, long scv) #else static inline long syscall_exit_prepare_scv(unsigned long r3, struct pt_regs *regs, long scv) #endif #ifndef CONFIG_PPC_BOOK3S_64 notrace unsigned long syscall_exit_prepare(unsigned long r3, struct pt_regs *regs) { return syscall_exit_prepare_scv(r3, regs, 0); } #endif >=20 > What is wrong for you really here ? Is that the fact we leave scv random,= or is that the below=20 > IS_ENABLED() ? That scv arg is random. I know generated code essentially would be no=20 different and no possibility of tracing, but would just prefer to call=20 the C "correctly" if possible. > I don't mind keeping the 'li r5,0' before calling the function if you fin= d it cleaner, the real=20 > performance gain is with setting scv to 0 below for PPC32 (and maybe it s= hould be set to zero for=20 > book3e/64 too ?). Yes 64e would like this optimisation. Thanks, Nick