From patchwork Mon Dec 25 01:06:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 10132193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A6CF3605BA for ; Mon, 25 Dec 2017 01:08:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99DCD28BDE for ; Mon, 25 Dec 2017 01:08:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E33928BE7; Mon, 25 Dec 2017 01:08:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2CE7728BDF for ; Mon, 25 Dec 2017 01:08:00 +0000 (UTC) Received: from localhost ([::1]:49870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTHFH-0006oF-E1 for patchwork-qemu-devel@patchwork.kernel.org; Sun, 24 Dec 2017 20:07:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTHED-00064Z-1Q for qemu-devel@nongnu.org; Sun, 24 Dec 2017 20:06:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eTHEA-0007no-CO for qemu-devel@nongnu.org; Sun, 24 Dec 2017 20:06:53 -0500 Received: from mga03.intel.com ([134.134.136.65]:31731) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eTHEA-0007mF-1o for qemu-devel@nongnu.org; Sun, 24 Dec 2017 20:06:50 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Dec 2017 17:06:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,452,1508828400"; d="scan'208";a="5252910" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by orsmga007.jf.intel.com with ESMTP; 24 Dec 2017 17:06:48 -0800 From: Haozhong Zhang To: qemu-devel@nongnu.org Date: Mon, 25 Dec 2017 09:06:11 +0800 Message-Id: <20171225010611.32621-3-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171225010611.32621-1-haozhong.zhang@intel.com> References: <20171225010611.32621-1-haozhong.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 Subject: [Qemu-devel] [PATCH 2/2] mem/nvdimm: ensure persistence of QEMU writes to real NVDIMM device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang , Xiao Guangrong , mst@redhat.com, Stefan Hajnoczi , Igor Mammedov , Dan Williams Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP QEMU intercepts guest writes to vNVDIMM labels, and then stores them to the backend. When the backend is a real NVDIMM device, QEMU needs to ensure the write persistence before returning to guest, so that the guest labels will not be lost if QEMU exits abnormally. Signed-off-by: Haozhong Zhang --- hw/mem/nvdimm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 952fce5ec8..b644876eb1 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -23,6 +23,7 @@ */ #include "qemu/osdep.h" +#include "qemu/pmem.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "hw/mem/nvdimm.h" @@ -135,6 +136,8 @@ static void nvdimm_write_label_data(NVDIMMDevice *nvdimm, const void *buf, nvdimm_validate_rw_label_data(nvdimm, size, offset); memcpy(nvdimm->label_data + offset, buf, size); + /* Make QEMU writes persistent in case the backend is a real NVDIMM. */ + pmem_persistent(nvdimm->label_data + offset, size); mr = host_memory_backend_get_memory(dimm->hostmem, &error_abort); backend_offset = memory_region_size(mr) - nvdimm->label_size + offset;