From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D18D9C3A5A3 for ; Thu, 22 Aug 2019 15:46:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7C4423401 for ; Thu, 22 Aug 2019 15:46:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="grxDkyjP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7C4423401 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AhDwQk/N3QuPccCkURM5ay/84CG3zOSVbOSqlAheyuM=; b=grxDkyjPSr1XJ4 7BSmVRgO66UhCUIHEcANSq8IIyHq8WJlX3s8eR91ebV8pwB1ZAznV33sgjGZytUFTrvrLOGQeSAJU xJ2aPJt12CgijHlgJ6y1QoF10o7I5eDBwJZxIr1xKdr0r9nB+C46cYJDfRdl2GltG6cCJ6oMWbm84 SRm5rU7+BkuR8l92/TaaNhkTKlsQYCYgldrOZmdsUNaU21eg1ZkJKVA5y9haX3NgoKy1YPWQGvyWY JnVkS1xV/DNtribPHP10A/UKRdoa9M2DuXRNTgBEi/RAZqhdotphNiv1ATgBTrZaJisfJFh4aaTux nLwq5o3XQF/XE6kALutg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i0pI2-0007a8-97; Thu, 22 Aug 2019 15:46:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i0pHz-0007ZJ-No for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2019 15:46:17 +0000 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 A80BA337; Thu, 22 Aug 2019 08:46:13 -0700 (PDT) Received: from [10.1.196.133] (e112269-lin.cambridge.arm.com [10.1.196.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7BD53F718; Thu, 22 Aug 2019 08:46:11 -0700 (PDT) Subject: Re: [PATCH v3 04/10] KVM: Implement kvm_put_guest() To: Sean Christopherson References: <20190821153656.33429-1-steven.price@arm.com> <20190821153656.33429-5-steven.price@arm.com> <20190822152854.GE25467@linux.intel.com> From: Steven Price Message-ID: Date: Thu, 22 Aug 2019 16:46:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190822152854.GE25467@linux.intel.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190822_084615_819470_B276E0B7 X-CRM114-Status: GOOD ( 15.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org, Suzuki K Pouloze , Marc Zyngier , linux-doc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Paolo Bonzini , Will Deacon , kvmarm@lists.cs.columbia.edu, Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 22/08/2019 16:28, Sean Christopherson wrote: > On Wed, Aug 21, 2019 at 04:36:50PM +0100, Steven Price wrote: >> kvm_put_guest() is analogous to put_user() - it writes a single value to >> the guest physical address. The implementation is built upon put_user() >> and so it has the same single copy atomic properties. > > What you mean by "single copy atomic"? I.e. what guarantees does > put_user() provide that __copy_to_user() does not? Single-copy atomicity is defined by the Arm architecture[1] and I'm not going to try to go into the full details here, so this is a summary. For the sake of this feature what we care about is that the value written/read cannot be "torn". In other words if there is a read (in this case from another VCPU) that is racing with the write then the read will either get the old value or the new value. It cannot return a mixture. (This is of course assuming that the read is using a single-copy atomic safe method). __copy_to_user() is implemented as a memcpy() and as such cannot provide single-copy atomicity in the general case (the buffer could easily be bigger than the architecture can guarantee). put_user() on the other hand is implemented (on arm64) as an explicit store instruction and therefore is guaranteed by the architecture to be single-copy atomic (i.e. another CPU cannot see a half-written value). Steve [1] https://static.docs.arm.com/ddi0487/ea/DDI0487E_a_armv8_arm.pdf#page=110 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel