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=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 EE2EFC3A5A2 for ; Thu, 22 Aug 2019 15:29:06 +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 BF0CF233FD for ; Thu, 22 Aug 2019 15:29:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HJDO9Frz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF0CF233FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.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:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sagqX5qmFOSAERLjUuAZ+c/6PYcPYUib/vE7mnc1924=; b=HJDO9Frz5W4K3/ X3xfnclsXi6LapLTUhGLqoeWSSUGSshecitu0lQu2c0C8MrdNG6NCn5znqDb3yP6iB33LSeh2Xtkv Ql7KIiHRgyN9xOBB7MQLC7i7q7BmQFkMALM3JmsRhTd0hDg0OC7TjCnyappW2QnO0RGy2WPqd259R w5oAR87JJPoYoeoerTv5CVJwmz6CDY7uS6hLIhZ3cztKmaT7va++RO779ol+FUFnRlrd+tG9J+yoe jqSiuIrzmTGwmzMtBgg6VD3C5KnmcLy/nywJzkw+eqYTULV+Ty+iQxWlzgyt04Rnhziaw2udNrLYP txqbKZiMIUXhXyQrmrKw==; 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 1i0p1N-0004E8-Ry; Thu, 22 Aug 2019 15:29:05 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i0p1L-0004Dc-2k for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2019 15:29:04 +0000 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Aug 2019 08:28:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,417,1559545200"; d="scan'208";a="186601083" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by FMSMGA003.fm.intel.com with ESMTP; 22 Aug 2019 08:28:54 -0700 Date: Thu, 22 Aug 2019 08:28:54 -0700 From: Sean Christopherson To: Steven Price Subject: Re: [PATCH v3 04/10] KVM: Implement kvm_put_guest() Message-ID: <20190822152854.GE25467@linux.intel.com> References: <20190821153656.33429-1-steven.price@arm.com> <20190821153656.33429-5-steven.price@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190821153656.33429-5-steven.price@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190822_082903_137206_2FF3E27E X-CRM114-Status: GOOD ( 14.98 ) 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 , kvm@vger.kernel.org, Radim =?utf-8?B?S3LEjW3DocWZ?= , Marc Zyngier , Suzuki K Pouloze , linux-doc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, James Morse , Julien Thierry , Catalin Marinas , Paolo Bonzini , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org 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 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? > > Signed-off-by: Steven Price > --- > include/linux/kvm_host.h | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index fcb46b3374c6..e154a1897e20 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -746,6 +746,30 @@ int kvm_write_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc, > unsigned long len); > int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc, > gpa_t gpa, unsigned long len); > + > +#define __kvm_put_guest(kvm, gfn, offset, value, type) \ > +({ \ > + unsigned long __addr = gfn_to_hva(kvm, gfn); \ > + type __user *__uaddr = (type __user *)(__addr + offset); \ > + int __ret = 0; \ > + \ > + if (kvm_is_error_hva(__addr)) \ > + __ret = -EFAULT; \ > + else \ > + __ret = put_user(value, __uaddr); \ > + if (!__ret) \ > + mark_page_dirty(kvm, gfn); \ > + __ret; \ > +}) > + > +#define kvm_put_guest(kvm, gpa, value, type) \ > +({ \ > + gpa_t __gpa = gpa; \ > + struct kvm *__kvm = kvm; \ > + __kvm_put_guest(__kvm, __gpa >> PAGE_SHIFT, \ > + offset_in_page(__gpa), (value), type); \ > +}) > + > int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len); > int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len); > struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn); > -- > 2.20.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel