From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUH0Y-0004vS-A2 for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:23:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUH0V-0003Na-NW for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:23:34 -0400 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]:36779) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUH0V-0003NS-Gu for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:23:31 -0400 Received: by wicja10 with SMTP id ja10so20140017wic.1 for ; Tue, 25 Aug 2015 09:23:30 -0700 (PDT) Date: Tue, 25 Aug 2015 17:23:27 +0100 From: Stefan Hajnoczi Message-ID: <20150825162327.GG8344@stefanha-thinkpad.redhat.com> References: <1439563931-12352-1-git-send-email-guangrong.xiao@linux.intel.com> <1439563931-12352-15-git-send-email-guangrong.xiao@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1439563931-12352-15-git-send-email-guangrong.xiao@linux.intel.com> Subject: Re: [Qemu-devel] [PATCH v2 14/18] nvdimm: support NFIT_CMD_IMPLEMENTED function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xiao Guangrong Cc: ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com, gleb@kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, imammedo@redhat.com, pbonzini@redhat.com, rth@twiddle.net On Fri, Aug 14, 2015 at 10:52:07PM +0800, Xiao Guangrong wrote: > @@ -306,6 +354,18 @@ struct dsm_buffer { > static ram_addr_t dsm_addr; > static size_t dsm_size; > > +struct cmd_out_implemented { QEMU coding style uses typedef struct {} CamelCase. Please follow this convention in all user-defined structs (see ./CODING_STYLE). > static void dsm_write(void *opaque, hwaddr addr, > uint64_t val, unsigned size) > { > + struct MemoryRegion *dsm_ram_mr = opaque; > + struct dsm_buffer *dsm; > + struct dsm_out *out; > + void *buf; > + > assert(val == NOTIFY_VALUE); The guest should not be able to cause an abort(3). If val != NOTIFY_VALUE we can do nvdebug() and then return. > + > + buf = memory_region_get_ram_ptr(dsm_ram_mr); > + dsm = buf; > + out = buf; > + > + le32_to_cpus(&dsm->handle); > + le32_to_cpus(&dsm->arg1); > + le32_to_cpus(&dsm->arg2); Can SMP guests modify DSM RAM while this thread is running? We must avoid race conditions. It's probably better to copy in data before byte-swapping or checking input values.