Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1610473ybj; Fri, 20 Sep 2019 13:21:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzP+ghPXRLZsKvV7meWDYBL7bl8tyvZrSsDVE7I54tAILuWtBwPG975dDqDIb1Q8iohnHKz X-Received: by 2002:a05:6402:1246:: with SMTP id l6mr23554388edw.213.1569010884942; Fri, 20 Sep 2019 13:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569010884; cv=none; d=google.com; s=arc-20160816; b=Vn9xpSV4itEYfSwmCOPiviOQWZiZtzuxfVFebGMxUDFfJFpJgzq2F/nVxWQUH5YaAV +DutVcYR752i/Sqo0tTgLKHMOvYxZXRNOt3KnqQzhXTMhMJ6aFzyw1qUM7HLRYD8piMM Ys2x495LVg1fa88IUxvt4Ff2aksm39HpvuPgecin7jNSiNVboh4nO2Y+1W1vLNNfyvTr XNriPStqZWkcTtLevl0QHYyLTY6mg7SDoJrZeXiUdqWcuB16/QfGKnbUETJBP1d4ZeX4 VcPqbZ/J1y9ECj5XiQ8qapJaaepUOSNe4gFm0VE05RcfL31QY2pCgQjwQ2MpRS5uCr23 poJg== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=DzaqOHso6nU4OYclMJbUQJ34JAI+AxwNnBB6gxtZfBY=; b=SgH6kHKiMHOj0GFtH2ox0pHm4uk/O7imq+qN6W6yCTYtlv6f9omwOEofe0ejg5cxiW WQ/7SVpyIgFW8G44pAzd9S8XxtYYMv+7sWFR/skPTi9As1NUxKTDs+zzJI5Qkm5iJtK6 SjaUzXLQrfo6p8h7r1JDEROiDKH6FDNvnKhTdDqv462UP7gKYYOkqmQ5Hs4mIKC/IVh4 WFjrkcKse3f1xDFRQo4OsNc7PMIS6lX7JXZq0f06E1WyaU/TrhyDhydcmybzE1oCyKmi T7mejm+0F2iPbiHZ9jY5+Qs8MEuS7v8xU5eR6n6FURa5DNOdHNmGSBNgronUCq9Lezuo jZbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 y27si2205510edd.249.2019.09.20.13.21.00; Fri, 20 Sep 2019 13:21:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728367AbfITOQ6 (ORCPT + 99 others); Fri, 20 Sep 2019 10:16:58 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:38758 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728297AbfITOQ6 (ORCPT ); Fri, 20 Sep 2019 10:16:58 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 32F2C1F437AB7F57F8C5; Fri, 20 Sep 2019 22:16:55 +0800 (CST) Received: from [127.0.0.1] (10.202.227.179) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Fri, 20 Sep 2019 22:16:48 +0800 Subject: Re: [PATCH 2/2] [v2] crypto: hisilicon - allow compile-testing on x86 To: Arnd Bergmann References: <20190919140650.1289963-2-arnd@arndb.de> <20190919140917.1290556-1-arnd@arndb.de> CC: Herbert Xu , "David S. Miller" , Zhou Wang , Jonathan Cameron , Kenneth Lee , "Mao Wenan" , Hao Fang , Shiju Jose , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , "linux-kernel@vger.kernel.org" , Will Deacon From: John Garry Message-ID: <531214d6-2caf-2963-0f57-2cd615a18762@huawei.com> Date: Fri, 20 Sep 2019 15:16:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.179] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 20/09/2019 14:36, Arnd Bergmann wrote: > On Fri, Sep 20, 2019 at 3:26 PM Arnd Bergmann wrote: >> >> On Fri, Sep 20, 2019 at 10:34 AM John Garry wrote: >> >>>> + if (!IS_ENABLED(CONFIG_ARM64)) { >>>> + memcpy_toio(fun_base, src, 16); >>>> + wmb(); >>>> + return; >>>> + } >>>> + >>>> asm volatile("ldp %0, %1, %3\n" >>>> "stp %0, %1, %2\n" >>>> "dsb sy\n" >>>> >>> >>> As I understand, this operation needs to be done atomically. So - even >>> though your change is just for compile testing - the memcpy_to_io() may >>> not do the same thing on other archs, right? >>> >>> I just wonder if it's right to make that change, or at least warn the >>> imaginary user of possible malfunction for !arm64. >> Hi Arnd, >> It's probably not necessary here. From what I can tell from the documentation, >> this is only safe on ARMv8.4 or higher anyway, earlier ARMv8.x implementations >> don't guarantee that an stp arrives on the bus in one piece either. >> >> Usually, hardware like this has no hard requirement on an atomic store, >> it just needs the individual bits to arrive in a particular order, and then >> triggers the update on the last bit that gets stored. If that is the case here >> as well, it might actually be better to use two writeq_relaxed() and >> a barrier. This would also solve the endianess issue. > > See also https://lkml.org/lkml/2018/1/26/554 for a previous attempt > to introduce 128-bit MMIO accessors, this got rejected since they > are not atomic even on ARMv8.4. So this is proprietary IP integrated with a proprietary ARMv8 implementation, so there could be a tight coupling, the like of which Will mentioned in that thread, but I'm doubtful. I'm looking at the electronically translated documentation on this HW, and it reads "The Mailbox operation performed by the CPU cannot be interleaved", and then tells that software should lock against concurrent accesses or alternatively use a 128-bit access. So it seems that the 128b op used is only to guarantee software is atomic. Wang Zhou can confirm my understanding. If true, I see that we seem to be already guaranteeing mutual exclusion in qm_mb(), in taking a mutex. Thanks, John > > Arnd > > . >