Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2436963imu; Sat, 22 Dec 2018 23:00:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/WeOM9ABz7iaZYx8y8peNEtYi7bdUh4BW0lm9CdLFeRZzY+JdiA30IYkYpZ+g29xrdfa+bf X-Received: by 2002:a62:ea09:: with SMTP id t9mr9330334pfh.228.1545548458631; Sat, 22 Dec 2018 23:00:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545548458; cv=none; d=google.com; s=arc-20160816; b=rlu35VrHfErPguLBy/JkkJllLbd4qy6qbP68ZP5N4gvZyZ4oOIaVO1EMjKgtIaoAVi dZmYeAh9w1afo22/7nGIGBXRKZbyxkiPjN5ukDhjLI7pif3kVKj5by6NBoaYf23NXqqN pPfKP2Ij9uIC3NbhPR3gC7R1g7wC9re9sWGtOsu5911NsKiAAmPhNlgwrTV9a4N76ppr DheB7fYuoHp6pIM1qC84Z1csfPz1B0OJRVQ/HNZbIJD9iQDRWrmfBNLMrqXgVsdNa8qz 0xNkbB5Oqioqhndt6ZIsZ4gwK62nShSJPN0H9YpIVKQYTgvy5qncvzjt9pEwAQsdV1sS UBxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SHVi8H9/6KagMWPzw8Fwg0KqblmVuLDJSo4G/Y5UnRg=; b=Rj+Ve5gEKDo/mBYcaTakSqDMWswXftjSYi4T7SrIIyA4jBT/ZUzylrQQwbzuMeiXZD h860vGNkWHsEjcZmcqj2BTycJ10s9pEtrzZvE2wajNqtDz7+daX2an2pWf8LC85JmXDI Fmi5HnHPvsaGLbxpGg8zx3SiqMJhVbpTbHqkh0AVdu5hoOqZRwsDzx1qQrNfyuIhtylO 62XBWY1KUqFK6JmEixf/UzjwK9d07sCitTTCQno422RjvzCF6A/azzk7O3QtYWwFoaIM A5U5I5m7Jq8LS7sf6Trg99O2uB2+P65HeO4Ln7rhSoaEL21YrPK8QToL+ISmvTPsDDHT pScg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RqG3zCCV; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j65si3586216pge.444.2018.12.22.23.00.29; Sat, 22 Dec 2018 23:00:58 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RqG3zCCV; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391830AbeLUUFu (ORCPT + 99 others); Fri, 21 Dec 2018 15:05:50 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:34416 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729924AbeLUUFu (ORCPT ); Fri, 21 Dec 2018 15:05:50 -0500 Received: by mail-lf1-f66.google.com with SMTP id p6so4749784lfc.1; Fri, 21 Dec 2018 12:05:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SHVi8H9/6KagMWPzw8Fwg0KqblmVuLDJSo4G/Y5UnRg=; b=RqG3zCCV/5fTVva/jkuNUUogx6+7AVH10TiOC+nqzfoBZCUPqfUpx9fuq0z4nLsx1j H0QFDvnSWLriCxvRint9FAEGBs5DQS/4TxTdnajv2R0DZQJZBD637U07Vg4HQr0Sg/so 2puI7L55yRSqE8kSTdUSwhAAWSwIZZoniKHeDwlil7vBdhfTSheCH2zd+W5fu/Q9EuNM AKVo6ubO2ik6PGcvkE0/BQHfbDL6ur6iNtDhmjudr7/cQIwPEDUVbrqnWCgrJ8eOJubF CCuSOWP1Cgm1yHP33+0Iz8GKLxR8fsZl17u8W4wk+cofLJ6PN5XgXY4wvUrMOYwKTYDM salw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=SHVi8H9/6KagMWPzw8Fwg0KqblmVuLDJSo4G/Y5UnRg=; b=NjHeNf+HrfWhFKxMRFBUE+urmEzkIn+uNbmg+xMqTRKSYTIBv1ylejIg8L2sjBeZqB dbvtZbifuWDQIsjov7qkJcAeNXfAm9QlvIWEi111YEBdG2Z6zy0wWbQYlsJ7wu1Wn3E8 Wh17G34VCRjZ8VldeiaMJu094pfqATD3hRv4Y0EO0D8kDOImy3ORP/xX1RkP7FInhE9M PGxqOLUPvNr8z/FNWrBp3GC5EqyPSxLlgwc0IM/84q3uwext1W71pBfepicvRb0CRepV NaBcEOrvxjWCJiKdUKUPRfk36HgYq4ATYWICOLablwbB185cFcG8YWGCYOIIm4fhtpB9 VCDA== X-Gm-Message-State: AA+aEWbtXt5uVRv9GGw4Vvei50NqP+rZGO4q3duAzhD7yOz4jUhh+YM4 zW1FQblkcQRMT3isJelnPqs= X-Received: by 2002:a19:ee08:: with SMTP id g8mr2257605lfb.72.1545422747896; Fri, 21 Dec 2018 12:05:47 -0800 (PST) Received: from uranus.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id t9-v6sm4792831ljj.87.2018.12.21.12.05.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Dec 2018 12:05:47 -0800 (PST) Received: by uranus.localdomain (Postfix, from userid 1000) id 878F8460769; Fri, 21 Dec 2018 23:05:46 +0300 (MSK) Date: Fri, 21 Dec 2018 23:05:46 +0300 From: Cyrill Gorcunov To: Matthew Wilcox Cc: Igor Stoppa , Andy Lutomirski , Peter Zijlstra , Dave Hansen , Mimi Zohar , Thiago Jung Bauermann , igor.stoppa@huawei.com, Nadav Amit , Kees Cook , Ahmed Soliman , linux-integrity@vger.kernel.org, kernel-hardening@lists.openwall.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/12] x86_64: memset_user() Message-ID: <20181221200546.GA8441@uranus> References: <20181221181423.20455-1-igor.stoppa@huawei.com> <20181221181423.20455-2-igor.stoppa@huawei.com> <20181221182515.GF10600@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181221182515.GF10600@bombadil.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 21, 2018 at 10:25:16AM -0800, Matthew Wilcox wrote: > On Fri, Dec 21, 2018 at 08:14:12PM +0200, Igor Stoppa wrote: > > +unsigned long __memset_user(void __user *addr, int c, unsigned long size) > > +{ > > + long __d0; > > + unsigned long pattern = 0; > > + int i; > > + > > + for (i = 0; i < 8; i++) > > + pattern = (pattern << 8) | (0xFF & c); > > That's inefficient. > > pattern = (unsigned char)c; > pattern |= pattern << 8; > pattern |= pattern << 16; > pattern |= pattern << 32; Won't pattern = 0x0101010101010101 * c; do the same but faster?