Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2271710imu; Sat, 22 Dec 2018 17:29:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mrtsNkHfuKDNklchZyKKx2xLxnO+kwoIJo0dUQ+oixebg+D+ta+YnGAM0VagpPtP/9EjE X-Received: by 2002:a62:47d9:: with SMTP id p86mr8075226pfi.95.1545528550731; Sat, 22 Dec 2018 17:29:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545528550; cv=none; d=google.com; s=arc-20160816; b=FKbXyFAVmRp7O29HdqG7J+v94XenPshL0Ia9piIx6ervQzYo9E5wegbSR/6gKHPSQB RdkojqUHW32b2epAfluvCEInQWC1UGRN4AegNxdIRk9Nr/zWOdRCAP1TjPNoUT5XE139 hwKO75NXUi5PQeYyTBzkV5N0QYQH+1HXkiGuuDkhp4MuGg8S3xAoXwjD8vMtgVzUwBAl gLSIKliTP6Xoa+diKwCiYibW+Y2BAKL8At2I9wokgo1mxDIDcikVPbu8qz/GwaMZlrbc +dcxE5K6dwFntsFWzNBP02e2bBiodpQV0F11nxz0fti1JcLdj+nwA36DLXbbXgDgeWCQ 7vHA== 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=+3oIgzMYSGpRMTGjMC8G5htx2OQ47BK5Wfpi+mdajPQ=; b=w9k1ODCXOGzgBMGKXjtdvMs7vTDhm22cfYcYTvFK5F+U0h9q32QAPeG964evSXkxV1 ipP+5Wg+M/LWIwtFB4t7pdvaWRSS4xEZS8aWcgKKdRX3Op58aVFkTdsLqhfXC2RC6Qgf iKzaPElMQJlx8WDNS5S2ILZi7hH12IipJmZmlbPACvE26ba5Hh8JI4War6NvaKrq/S1N ez9siztVjiNp9A+cWuBsBeeeTOTRbg5PTIUnM0XKV2mhhFhrADxroZFQmvI3yn11ebYu C5T3UBCKyWjnjTabQflv+m8GbCpD7fKpZVoYSRGckMLh4o0SEu3a+ryxVgqBdHQmrsYk HSZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=HYPdpERI; 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 197si5661641pgb.564.2018.12.22.17.28.24; Sat, 22 Dec 2018 17:29:10 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=HYPdpERI; 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 S2391433AbeLUSZX (ORCPT + 99 others); Fri, 21 Dec 2018 13:25:23 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:35214 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388745AbeLUSZW (ORCPT ); Fri, 21 Dec 2018 13:25:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+3oIgzMYSGpRMTGjMC8G5htx2OQ47BK5Wfpi+mdajPQ=; b=HYPdpERIQ336JfjJC5Z+FaPM1 vdg/xTlNXbSi4vE7USoDcgPsRi348Z7T6j9E+4vPV+lL05QVF0ObjEzzfHlNpARSsPKe6XKAaf/lR Q9kzrkM+XZt+tH2LlsIoIr/2Sfqh3vdrTMI6rMfug+PKNalbIPXz5VIRFm8pbSkjCVw635TFem4oN J9BbSShJ3tBRMHPDdSeMEyu8DFEV0fBAf8hNgk0IWL5kutI6LJKsY9u8OgsGmCdPOHIDN7uLnbO5K zkJmYbQPur0QZC99nHHZVti/l3HIxC2V1sdj0pm7NcHyc7uNZTkh5Xr9Se45+ulSWRrmqGLrOjXIC CiDlwZZuQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gaPU4-0004eG-EX; Fri, 21 Dec 2018 18:25:16 +0000 Date: Fri, 21 Dec 2018 10:25:16 -0800 From: Matthew Wilcox To: Igor Stoppa Cc: 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: <20181221182515.GF10600@bombadil.infradead.org> References: <20181221181423.20455-1-igor.stoppa@huawei.com> <20181221181423.20455-2-igor.stoppa@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181221181423.20455-2-igor.stoppa@huawei.com> User-Agent: Mutt/1.9.2 (2017-12-15) 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 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;