Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7287428ybl; Mon, 23 Dec 2019 23:06:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxf48vJsjHHGuxf7xClGaNw8qpUJqSuQvWlzjZp4DAbwPgUX9pIi0dfDZqrDv5rm4QSoZUo X-Received: by 2002:a05:6830:110a:: with SMTP id w10mr38169442otq.300.1577171210445; Mon, 23 Dec 2019 23:06:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577171210; cv=none; d=google.com; s=arc-20160816; b=bvafbjaUfx+FVVmDIN5rKgtXrJuQ2IxzNsVRk8z5PZJcrnVmfTT2iFl1DU+kIDRGU9 4y5TqbmiavcAfo8TF/bYrKgRzxx7A1aPKFV1ZuEFCt3x/cld+RALKcFzgkKmx6NIX56V AtuIQynapb05W2kpSNJpjFVnJxHso0Dj/7egYMC8MG0gmRBJWLYsMHgDvnnRCsUWwACf tGqJ/bDJJnwH9edmActgl6lfaWpcGpL3fUZnEoyzzIrl4zZSkAnjB2P6iBJFSMmAVKWo N7i9tkEqfdff6oHe6WdG12WvPuNIabP9qBGvyA7wywmAoNn0u4SKohLyTlYDiq41qzGm kozA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=+fa0+jm/uxp60ZtFhRJNUPOwJIMFUG10BEehxLfmbn4=; b=wtijyXyQ+4OMbHIrf+IDH20f3OC9KF31Yqa8LPHN7JWG2BjViuNJ9qsx6MTANlucva 9Kbqa7UWLt48aG2Y8OT/JZIEzpie2SEIemLfbVkxVhzZDjJdAnBI1QgN4utE9WyhFqWc hP+SZ4H+49ob3t59oELEKXHh5qX4Dka3RpA7exCu4b5Nz6YmdXQNpr5JxfjLo/M8S9ry ehNtoVBRecw05yMMLCYI57jxQJQH7Mx89sFKh78x8wIfyHRJaK+fDnSieN6qR10Ko10Q I8Fg7RcoqD+4bzuz5h2fRoevY7A+ZIDOMSiFitr8qOzP60fmwBUdB5NBubuApK6JEzcs C34g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f23si11235069oto.205.2019.12.23.23.06.37; Mon, 23 Dec 2019 23:06:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726084AbfLXHF4 (ORCPT + 99 others); Tue, 24 Dec 2019 02:05:56 -0500 Received: from foss.arm.com ([217.140.110.172]:50154 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbfLXHF4 (ORCPT ); Tue, 24 Dec 2019 02:05:56 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7957431B; Mon, 23 Dec 2019 23:05:55 -0800 (PST) Received: from [10.163.1.130] (unknown [10.163.1.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2BE43F6CF; Mon, 23 Dec 2019 23:08:53 -0800 (PST) Subject: Re: [PATCH] arm64: Set SSBS for user threads while creation To: Srinivas Ramana , will@kernel.org, catalin.marinas@arm.com, maz@kernel.org, will.deacon@arm.com Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <1577106146-8999-1-git-send-email-sramana@codeaurora.org> From: Anshuman Khandual Message-ID: Date: Tue, 24 Dec 2019 12:36:34 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1577106146-8999-1-git-send-email-sramana@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/23/2019 06:32 PM, Srinivas Ramana wrote: > Current SSBS implementation takes care of setting the > SSBS bit in start_thread() for user threads. While this works > for tasks launched with fork/clone followed by execve, for cases > where userspace would just call fork (eg, Java applications) this > leaves the SSBS bit unset. This results in performance > regression for such tasks. > > It is understood that commit cbdf8a189a66 ("arm64: Force SSBS > on context switch") masks this issue, but that was done for a > different reason where heterogeneous CPUs(both SSBS supported > and unsupported) are present. It is appropriate to take care > of the SSBS bit for all threads while creation itself. So this fixes the situation (i.e low performance) from the creation time of a task with fork() which will never see a subsequent execve, till it gets context switched for the very first time ? > > Fixes: 8f04e8e6e29c ("arm64: ssbd: Add support for PSTATE.SSBS rather than trapping to EL3") > Signed-off-by: Srinivas Ramana > --- > arch/arm64/kernel/process.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 71f788cd2b18..a8f05cc39261 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -399,6 +399,13 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, > */ > if (clone_flags & CLONE_SETTLS) > p->thread.uw.tp_value = childregs->regs[3]; > + > + if (arm64_get_ssbd_state() != ARM64_SSBD_FORCE_ENABLE) { > + if (is_compat_thread(task_thread_info(p))) > + set_compat_ssbs_bit(childregs); > + else > + set_ssbs_bit(childregs); > + } > } else { > memset(childregs, 0, sizeof(struct pt_regs)); > childregs->pstate = PSR_MODE_EL1h; >