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_2 autolearn=ham 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 3ABC1C3A59D for ; Thu, 22 Aug 2019 10:30:13 +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 0749222CE3 for ; Thu, 22 Aug 2019 10:30:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="c0MQ5l/D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0749222CE3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.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:MIME-Version:References:In-Reply-To: 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=tfdks3tidNviXaC00ydgoVJ7bq2B2mXmf/EAw4uOQZI=; b=c0MQ5l/DETdWcu el7EglFQbnW34TRbQ7IjqCsMRULXT42tnHPHDcqi4PMVKA9vFIf9oZhrr9F3pI/vKOy8To5qAQJGP NVHnicgFyAEr2lj3UFLb5u0LKDkyBypTCOXygj64J8VpW9ElIYiqe0HJyJlV2jlSjYH0fCvsvAP5v VIFe+hTzvYuRbPQ0GlHvF305RbUPpYxKzl0vePaEFLFJMEAuvt9QLOZKlct6g2J1QrHqW2aNcRWvl kX55Eyir2fqAZsx+Xwj8cXP3iCgaPbDNLH7OD4t9xU1GoQI6h99yLw4mWRHg7Ek+ECLo3RVMk8g4e 84W2hUZ+uCYqq6gOwQ8g==; 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 1i0kLv-0000wE-7e; Thu, 22 Aug 2019 10:29:59 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i0kLr-0000vP-4T for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2019 10:29:57 +0000 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B334BCD1D3E5D29EB50F; Thu, 22 Aug 2019 18:29:50 +0800 (CST) Received: from localhost (10.202.226.61) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Thu, 22 Aug 2019 18:29:44 +0800 Date: Thu, 22 Aug 2019 11:29:30 +0100 From: Jonathan Cameron To: Steven Price Subject: Re: [PATCH v3 04/10] KVM: Implement kvm_put_guest() Message-ID: <20190822112930.000052db@huawei.com> In-Reply-To: <20190821153656.33429-5-steven.price@arm.com> References: <20190821153656.33429-1-steven.price@arm.com> <20190821153656.33429-5-steven.price@arm.com> Organization: Huawei X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.202.226.61] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190822_032955_334690_3ABE3F58 X-CRM114-Status: GOOD ( 12.18 ) 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?Q?Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , Suzuki K Pouloze , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Russell King , 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, 21 Aug 2019 16:36:50 +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. > > 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; \ Why initialize __ret? > + \ > + 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); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel