From patchwork Thu Aug 27 06:12:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 52754 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 570EA22E9E for ; Thu, 27 Aug 2015 06:14:57 +0000 (UTC) Received: by wicbi2 with SMTP id bi2sf14131408wic.3 for ; Wed, 26 Aug 2015 23:14:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:cc:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=H3iQS2tg47nggkUpsxX5/DZZgH//tJAnXrFY9Hp/T1k=; b=YC/C5jwTh48pw3dhCwz1GknUUmfVCupisTzZjVZ3+61op4NxRpT8mlL3Ho3wdXWDcI /SY3mUNhWliLjNbljRv937CdYrB2aXwwa9nWkJ+g4jfK3eBsu1SHGKJw1rsdl+DOojoK jCvGryoJHh1z3pWYLYD5zmlfXhIOruPehLW3az+lu8n4BeRJjqHRH39dsbz5LEkOgCgX DnlUGFDYCcn00u+lqAWQI0UsGZIHiyk8L6029gm2pHU0ZNkJIFgT7/O4sQ6MDKZH9RmE TRx/qGfKJrXwtOL7VPoPL97uBlHAUJUhLVTSTYronWvBU8l/PlqH7u9Rk4UAWQlrAIxD WGoA== X-Gm-Message-State: ALoCoQnlGyKWPu8hjnXogUgparhMcDut3cme5VMa25T9wgV1xh69U87Hf5JCtLIlrpU4Jis5YqiO X-Received: by 10.112.172.70 with SMTP id ba6mr473395lbc.1.1440656096564; Wed, 26 Aug 2015 23:14:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.100 with SMTP id u4ls35414lae.51.gmail; Wed, 26 Aug 2015 23:14:56 -0700 (PDT) X-Received: by 10.152.5.169 with SMTP id t9mr1329200lat.55.1440656096436; Wed, 26 Aug 2015 23:14:56 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id oc2si1061452lbb.76.2015.08.26.23.14.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 23:14:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbpu9 with SMTP id pu9so5049434lbb.3 for ; Wed, 26 Aug 2015 23:14:56 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr1318405lac.73.1440656095950; Wed, 26 Aug 2015 23:14:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.162.200 with SMTP id yc8csp4401735lbb; Wed, 26 Aug 2015 23:14:54 -0700 (PDT) X-Received: by 10.66.248.72 with SMTP id yk8mr3949258pac.112.1440656094090; Wed, 26 Aug 2015 23:14:54 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id h8si1801984pdm.251.2015.08.26.23.14.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 23:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUqQq-00056y-N9; Thu, 27 Aug 2015 06:13:04 +0000 Received: from mail-wi0-f179.google.com ([209.85.212.179]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUqQn-00050h-RU for linux-arm-kernel@lists.infradead.org; Thu, 27 Aug 2015 06:13:02 +0000 Received: by wicge2 with SMTP id ge2so100545wic.1 for ; Wed, 26 Aug 2015 23:12:39 -0700 (PDT) X-Received: by 10.194.92.109 with SMTP id cl13mr2441502wjb.156.1440655959857; Wed, 26 Aug 2015 23:12:39 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by smtp.gmail.com with ESMTPSA id r8sm10889630wik.16.2015.08.26.23.12.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 23:12:39 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, catalin.marinas@arm.com, jianhua.ljh@gmail.com, chunyan.zhang@spreadtrum.com Subject: [PATCH] arm64: flush FP/SIMD state correctly after execve() Date: Thu, 27 Aug 2015 08:12:33 +0200 Message-Id: <1440655953-31431-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150826_231302_040372_9A14F09D X-CRM114-Status: GOOD ( 13.94 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.179 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.179 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 When a task calls execve(), its FP/SIMD state is flushed so that none of the original program state is observeable by the incoming program. However, since this flushing consists of setting the in-memory copy of the FP/SIMD state to all zeroes, the CPU field is set to CPU 0 as well, which indicates to the lazy FP/SIMD preserve/restore code that the FP/SIMD state does not need to be reread from memory if the task is scheduled again on CPU 0 without any other tasks having entered userland (or used the FP/SIMD in kernel mode) on the same CPU in the mean time. If this happens, the FP/SIMD state of the old program will still be present in the registers when the new program starts. So set the CPU field to the invalid value of NR_CPUS when performing the flush, by calling fpsimd_flush_task_state(). Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/fpsimd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 44d6f7545505..c56956a16d3f 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -158,6 +158,7 @@ void fpsimd_thread_switch(struct task_struct *next) void fpsimd_flush_thread(void) { memset(¤t->thread.fpsimd_state, 0, sizeof(struct fpsimd_state)); + fpsimd_flush_task_state(current); set_thread_flag(TIF_FOREIGN_FPSTATE); }