From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH v2 14/18] nvdimm: support NFIT_CMD_IMPLEMENTED function Date: Wed, 26 Aug 2015 18:46:35 +0800 Message-ID: <55DD990B.80204@linux.intel.com> References: <1439563931-12352-1-git-send-email-guangrong.xiao@linux.intel.com> <1439563931-12352-15-git-send-email-guangrong.xiao@linux.intel.com> <20150825162327.GG8344@stefanha-thinkpad.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: pbonzini@redhat.com, imammedo@redhat.com, gleb@kernel.org, mtosatti@redhat.com, stefanha@redhat.com, mst@redhat.com, rth@twiddle.net, ehabkost@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org To: Stefan Hajnoczi Return-path: Received: from mga11.intel.com ([192.55.52.93]:23943 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756072AbbHZKwX (ORCPT ); Wed, 26 Aug 2015 06:52:23 -0400 In-Reply-To: <20150825162327.GG8344@stefanha-thinkpad.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 08/26/2015 12:23 AM, Stefan Hajnoczi wrote: > 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). > Okay, will adjust all the defines in the next version. >> 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. The ACPI code and emulation code both are from qemu, if that happens, it's really a bug, aborting the VM is better than throwing a debug message under this case to avoid potential data corruption. > >> + >> + 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. Yes, my mistake, will fix.